index-700f8bec.js 222 KB

123456789101112131415161718192021222324252627282930313233343536
  1. var ia=Object.defineProperty;var oa=(r,e,t)=>e in r?ia(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var c=(r,e,t)=>(oa(r,typeof e!="symbol"?e+"":e,t),t);import{c as Ge,i as aa,d as ji,e as Et,f as Ii,l as wn,t as ca,g as Me,m as ar,S as ua,r as ha,P as la,h as fa,j as da,_ as xn,a as pa,b as ma}from"./main-4801cc52.js";class ba{constructor(e,t,s){c(this,"owner");c(this,"name");c(this,"fn");this.owner=e,this.name=t,this.fn=s}unbind(){this.owner&&(this.owner.unbind(this.name,this.fn),this.owner=null,this.name=null,this.fn=null)}call(){this.fn&&this.fn.call(this.owner,arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6],arguments[7])}on(e,t){return this.owner.on(e,t)}}let ga=class{constructor(){c(this,"_events");c(this,"_suspendEvents");this._events={},this._suspendEvents=!1}get suspendEvents(){return this._suspendEvents}set suspendEvents(e){this._suspendEvents=!!e}nextTick(e,t){this.on(e,function(){let s=null;return function(...n){s&&clearTimeout(s),s=setTimeout(t.bind(null,...n))}}())}on(e,t){const s=this._events[e];return s===void 0?this._events[e]=[t]:s.indexOf(t)==-1&&s.push(t),new ba(this,e,t)}once(e,t){const s=this,n=this.on(e,function(...i){t.call(s,...i),n.unbind()});return n}emit(e,...t){if(this._suspendEvents)return;let s=this._events[e];if(s){s=s.slice(0);for(let n=0;n<s.length;n++)if(s[n])try{s[n].call(this,...t)}catch(i){console.info("%c%s %c(event error)","color: #06f",e,"color: #f00"),console.error(i)}}}unbind(e,t){if(e){const s=this._events[e];if(!s)return this;if(t){const n=s.indexOf(t);n!==-1&&(s.length===1?delete this._events[e]:s.splice(n,1))}else delete this._events[e]}else this._events={};return this}};function _a(r){return typeof r=="function"||Object.prototype.toString.call(r)==="[object Object]"&&!aa(r)}const ya=function(r){delete r.slotOptions;const{slots:e={},...t}=r,s=ji(t),n=function(o){let a;const{slots:h,...l}=o;return Ge(s,l,_a(a=wa(this,h))?a:{default:()=>[a]})},i=n.bind(()=>i);return Object.setPrototypeOf(i,n),Object.keys(e).forEach(o=>{i[o]=e[o]}),i.slots=function(o){return o},i};function wa(r,e={}){const t=r();return Object.keys(t).forEach(n=>{e[n]=xa(e,n,t[n])}),e}function xa(r,e,t){const s=r[e];return s?(n={},i={})=>{const o=s(n,i);if(o)return o!=n?o:Ge(t,o,null)}:n=>Ge(t,n,null)}ya({setup(){return()=>null}});const va=URL.createObjectURL,Sa=URL.revokeObjectURL;URL.createObjectURL=function(r){const e=va(r);return Ti.set(e,r),e};URL.revokeObjectURL=function(r){Sa(r),Ti.delete(r)};const Ti=new Map;var Ni={exports:{}},Ui=function(e,t){return function(){for(var n=new Array(arguments.length),i=0;i<n.length;i++)n[i]=arguments[i];return e.apply(t,n)}},Ea=Ui,$s=Object.prototype.toString,Ls=function(r){return function(e){var t=$s.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())}}(Object.create(null));function We(r){return r=r.toLowerCase(),function(t){return Ls(t)===r}}function Ds(r){return Array.isArray(r)}function pr(r){return typeof r>"u"}function Aa(r){return r!==null&&!pr(r)&&r.constructor!==null&&!pr(r.constructor)&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}var Mi=We("ArrayBuffer");function Pa(r){var e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&Mi(r.buffer),e}function Oa(r){return typeof r=="string"}function Ca(r){return typeof r=="number"}function Fi(r){return r!==null&&typeof r=="object"}function cr(r){if(Ls(r)!=="object")return!1;var e=Object.getPrototypeOf(r);return e===null||e===Object.prototype}var ka=We("Date"),Ra=We("File"),ja=We("Blob"),Ia=We("FileList");function qs(r){return $s.call(r)==="[object Function]"}function Ta(r){return Fi(r)&&qs(r.pipe)}function Na(r){var e="[object FormData]";return r&&(typeof FormData=="function"&&r instanceof FormData||$s.call(r)===e||qs(r.toString)&&r.toString()===e)}var Ua=We("URLSearchParams");function Ma(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function Fa(){return typeof navigator<"u"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window<"u"&&typeof document<"u"}function Bs(r,e){if(!(r===null||typeof r>"u"))if(typeof r!="object"&&(r=[r]),Ds(r))for(var t=0,s=r.length;t<s;t++)e.call(null,r[t],t,r);else for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.call(null,r[n],n,r)}function xs(){var r={};function e(n,i){cr(r[i])&&cr(n)?r[i]=xs(r[i],n):cr(n)?r[i]=xs({},n):Ds(n)?r[i]=n.slice():r[i]=n}for(var t=0,s=arguments.length;t<s;t++)Bs(arguments[t],e);return r}function $a(r,e,t){return Bs(e,function(n,i){t&&typeof n=="function"?r[i]=Ea(n,t):r[i]=n}),r}function La(r){return r.charCodeAt(0)===65279&&(r=r.slice(1)),r}function Da(r,e,t,s){r.prototype=Object.create(e.prototype,s),r.prototype.constructor=r,t&&Object.assign(r.prototype,t)}function qa(r,e,t){var s,n,i,o={};e=e||{};do{for(s=Object.getOwnPropertyNames(r),n=s.length;n-- >0;)i=s[n],o[i]||(e[i]=r[i],o[i]=!0);r=Object.getPrototypeOf(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e}function Ba(r,e,t){r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;var s=r.indexOf(e,t);return s!==-1&&s===t}function Ha(r){if(!r)return null;var e=r.length;if(pr(e))return null;for(var t=new Array(e);e-- >0;)t[e]=r[e];return t}var Ja=function(r){return function(e){return r&&e instanceof r}}(typeof Uint8Array<"u"&&Object.getPrototypeOf(Uint8Array)),K={isArray:Ds,isArrayBuffer:Mi,isBuffer:Aa,isFormData:Na,isArrayBufferView:Pa,isString:Oa,isNumber:Ca,isObject:Fi,isPlainObject:cr,isUndefined:pr,isDate:ka,isFile:Ra,isBlob:ja,isFunction:qs,isStream:Ta,isURLSearchParams:Ua,isStandardBrowserEnv:Fa,forEach:Bs,merge:xs,extend:$a,trim:Ma,stripBOM:La,inherits:Da,toFlatObject:qa,kindOf:Ls,kindOfTest:We,endsWith:Ba,toArray:Ha,isTypedArray:Ja,isFileList:Ia},rt=K;function vn(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var $i=function(e,t,s){if(!t)return e;var n;if(s)n=s(t);else if(rt.isURLSearchParams(t))n=t.toString();else{var i=[];rt.forEach(t,function(h,l){h===null||typeof h>"u"||(rt.isArray(h)?l=l+"[]":h=[h],rt.forEach(h,function(g){rt.isDate(g)?g=g.toISOString():rt.isObject(g)&&(g=JSON.stringify(g)),i.push(vn(l)+"="+vn(g))}))}),n=i.join("&")}if(n){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+n}return e},za=K;function Pr(){this.handlers=[]}Pr.prototype.use=function(e,t,s){return this.handlers.push({fulfilled:e,rejected:t,synchronous:s?s.synchronous:!1,runWhen:s?s.runWhen:null}),this.handlers.length-1};Pr.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};Pr.prototype.forEach=function(e){za.forEach(this.handlers,function(s){s!==null&&e(s)})};var Ga=Pr,Va=K,Wa=function(e,t){Va.forEach(e,function(n,i){i!==t&&i.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[i])})},Li=K;function ht(r,e,t,s,n){Error.call(this),this.message=r,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),s&&(this.request=s),n&&(this.response=n)}Li.inherits(ht,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var Di=ht.prototype,qi={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach(function(r){qi[r]={value:r}});Object.defineProperties(ht,qi);Object.defineProperty(Di,"isAxiosError",{value:!0});ht.from=function(r,e,t,s,n,i){var o=Object.create(Di);return Li.toFlatObject(r,o,function(h){return h!==Error.prototype}),ht.call(o,r.message,e,t,s,n),o.name=r.name,i&&Object.assign(o,i),o};var bt=ht,Bi={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ge=K;function Ya(r,e){e=e||new FormData;var t=[];function s(i){return i===null?"":ge.isDate(i)?i.toISOString():ge.isArrayBuffer(i)||ge.isTypedArray(i)?typeof Blob=="function"?new Blob([i]):Buffer.from(i):i}function n(i,o){if(ge.isPlainObject(i)||ge.isArray(i)){if(t.indexOf(i)!==-1)throw Error("Circular reference detected in "+o);t.push(i),ge.forEach(i,function(h,l){if(!ge.isUndefined(h)){var m=o?o+"."+l:l,g;if(h&&!o&&typeof h=="object"){if(ge.endsWith(l,"{}"))h=JSON.stringify(h);else if(ge.endsWith(l,"[]")&&(g=ge.toArray(h))){g.forEach(function(b){!ge.isUndefined(b)&&e.append(m,s(b))});return}}n(h,m)}}),t.pop()}else e.append(o,s(i))}return n(r),e}var Hi=Ya,Yr,Sn;function Ka(){if(Sn)return Yr;Sn=1;var r=bt;return Yr=function(t,s,n){var i=n.config.validateStatus;!n.status||!i||i(n.status)?t(n):s(new r("Request failed with status code "+n.status,[r.ERR_BAD_REQUEST,r.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))},Yr}var Kr,En;function Xa(){if(En)return Kr;En=1;var r=K;return Kr=r.isStandardBrowserEnv()?function(){return{write:function(s,n,i,o,a,h){var l=[];l.push(s+"="+encodeURIComponent(n)),r.isNumber(i)&&l.push("expires="+new Date(i).toGMTString()),r.isString(o)&&l.push("path="+o),r.isString(a)&&l.push("domain="+a),h===!0&&l.push("secure"),document.cookie=l.join("; ")},read:function(s){var n=document.cookie.match(new RegExp("(^|;\\s*)("+s+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(s){this.write(s,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}(),Kr}var Za=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)},Qa=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e},ec=Za,tc=Qa,Ji=function(e,t){return e&&!ec(t)?tc(e,t):t},Xr,An;function rc(){if(An)return Xr;An=1;var r=K,e=["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"];return Xr=function(s){var n={},i,o,a;return s&&r.forEach(s.split(`
  2. `),function(l){if(a=l.indexOf(":"),i=r.trim(l.substr(0,a)).toLowerCase(),o=r.trim(l.substr(a+1)),i){if(n[i]&&e.indexOf(i)>=0)return;i==="set-cookie"?n[i]=(n[i]?n[i]:[]).concat([o]):n[i]=n[i]?n[i]+", "+o:o}}),n},Xr}var Zr,Pn;function sc(){if(Pn)return Zr;Pn=1;var r=K;return Zr=r.isStandardBrowserEnv()?function(){var t=/(msie|trident)/i.test(navigator.userAgent),s=document.createElement("a"),n;function i(o){var a=o;return t&&(s.setAttribute("href",a),a=s.href),s.setAttribute("href",a),{href:s.href,protocol:s.protocol?s.protocol.replace(/:$/,""):"",host:s.host,search:s.search?s.search.replace(/^\?/,""):"",hash:s.hash?s.hash.replace(/^#/,""):"",hostname:s.hostname,port:s.port,pathname:s.pathname.charAt(0)==="/"?s.pathname:"/"+s.pathname}}return n=i(window.location.href),function(a){var h=r.isString(a)?i(a):a;return h.protocol===n.protocol&&h.host===n.host}}():function(){return function(){return!0}}(),Zr}var Qr,On;function Or(){if(On)return Qr;On=1;var r=bt,e=K;function t(s){r.call(this,s??"canceled",r.ERR_CANCELED),this.name="CanceledError"}return e.inherits(t,r,{__CANCEL__:!0}),Qr=t,Qr}var es,Cn;function nc(){return Cn||(Cn=1,es=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}),es}var ts,kn;function Rn(){if(kn)return ts;kn=1;var r=K,e=Ka(),t=Xa(),s=$i,n=Ji,i=rc(),o=sc(),a=Bi,h=bt,l=Or(),m=nc();return ts=function(b){return new Promise(function(A,k){var R=b.data,M=b.headers,N=b.responseType,U;function J(){b.cancelToken&&b.cancelToken.unsubscribe(U),b.signal&&b.signal.removeEventListener("abort",U)}r.isFormData(R)&&r.isStandardBrowserEnv()&&delete M["Content-Type"];var T=new XMLHttpRequest;if(b.auth){var Te=b.auth.username||"",Ke=b.auth.password?unescape(encodeURIComponent(b.auth.password)):"";M.Authorization="Basic "+btoa(Te+":"+Ke)}var de=n(b.baseURL,b.url);T.open(b.method.toUpperCase(),s(de,b.params,b.paramsSerializer),!0),T.timeout=b.timeout;function ee(){if(T){var z="getAllResponseHeaders"in T?i(T.getAllResponseHeaders()):null,ue=!N||N==="text"||N==="json"?T.responseText:T.response,X={data:ue,status:T.status,statusText:T.statusText,headers:z,config:b,request:T};e(function(He){A(He),J()},function(He){k(He),J()},X),T=null}}if("onloadend"in T?T.onloadend=ee:T.onreadystatechange=function(){!T||T.readyState!==4||T.status===0&&!(T.responseURL&&T.responseURL.indexOf("file:")===0)||setTimeout(ee)},T.onabort=function(){T&&(k(new h("Request aborted",h.ECONNABORTED,b,T)),T=null)},T.onerror=function(){k(new h("Network Error",h.ERR_NETWORK,b,T,T)),T=null},T.ontimeout=function(){var ue=b.timeout?"timeout of "+b.timeout+"ms exceeded":"timeout exceeded",X=b.transitional||a;b.timeoutErrorMessage&&(ue=b.timeoutErrorMessage),k(new h(ue,X.clarifyTimeoutError?h.ETIMEDOUT:h.ECONNABORTED,b,T)),T=null},r.isStandardBrowserEnv()){var Ee=(b.withCredentials||o(de))&&b.xsrfCookieName?t.read(b.xsrfCookieName):void 0;Ee&&(M[b.xsrfHeaderName]=Ee)}"setRequestHeader"in T&&r.forEach(M,function(ue,X){typeof R>"u"&&X.toLowerCase()==="content-type"?delete M[X]:T.setRequestHeader(X,ue)}),r.isUndefined(b.withCredentials)||(T.withCredentials=!!b.withCredentials),N&&N!=="json"&&(T.responseType=b.responseType),typeof b.onDownloadProgress=="function"&&T.addEventListener("progress",b.onDownloadProgress),typeof b.onUploadProgress=="function"&&T.upload&&T.upload.addEventListener("progress",b.onUploadProgress),(b.cancelToken||b.signal)&&(U=function(z){T&&(k(!z||z&&z.type?new l:z),T.abort(),T=null)},b.cancelToken&&b.cancelToken.subscribe(U),b.signal&&(b.signal.aborted?U():b.signal.addEventListener("abort",U))),R||(R=null);var Ne=m(de);if(Ne&&["http","https","file"].indexOf(Ne)===-1){k(new h("Unsupported protocol "+Ne+":",h.ERR_BAD_REQUEST,b));return}T.send(R)})},ts}var rs,jn;function ic(){return jn||(jn=1,rs=null),rs}var G=K,In=Wa,Tn=bt,oc=Bi,ac=Hi,cc={"Content-Type":"application/x-www-form-urlencoded"};function Nn(r,e){!G.isUndefined(r)&&G.isUndefined(r["Content-Type"])&&(r["Content-Type"]=e)}function uc(){var r;return(typeof XMLHttpRequest<"u"||typeof process<"u"&&Object.prototype.toString.call(process)==="[object process]")&&(r=Rn()),r}function hc(r,e,t){if(G.isString(r))try{return(e||JSON.parse)(r),G.trim(r)}catch(s){if(s.name!=="SyntaxError")throw s}return(t||JSON.stringify)(r)}var Cr={transitional:oc,adapter:uc(),transformRequest:[function(e,t){if(In(t,"Accept"),In(t,"Content-Type"),G.isFormData(e)||G.isArrayBuffer(e)||G.isBuffer(e)||G.isStream(e)||G.isFile(e)||G.isBlob(e))return e;if(G.isArrayBufferView(e))return e.buffer;if(G.isURLSearchParams(e))return Nn(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var s=G.isObject(e),n=t&&t["Content-Type"],i;if((i=G.isFileList(e))||s&&n==="multipart/form-data"){var o=this.env&&this.env.FormData;return ac(i?{"files[]":e}:e,o&&new o)}else if(s||n==="application/json")return Nn(t,"application/json"),hc(e);return e}],transformResponse:[function(e){var t=this.transitional||Cr.transitional,s=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,i=!s&&this.responseType==="json";if(i||n&&G.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(i)throw o.name==="SyntaxError"?Tn.from(o,Tn.ERR_BAD_RESPONSE,this,null,this.response):o}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ic()},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};G.forEach(["delete","get","head"],function(e){Cr.headers[e]={}});G.forEach(["post","put","patch"],function(e){Cr.headers[e]=G.merge(cc)});var Hs=Cr,lc=K,fc=Hs,dc=function(e,t,s){var n=this||fc;return lc.forEach(s,function(o){e=o.call(n,e,t)}),e},ss,Un;function zi(){return Un||(Un=1,ss=function(e){return!!(e&&e.__CANCEL__)}),ss}var Mn=K,ns=dc,pc=zi(),mc=Hs,bc=Or();function is(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new bc}var gc=function(e){is(e),e.headers=e.headers||{},e.data=ns.call(e,e.data,e.headers,e.transformRequest),e.headers=Mn.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Mn.forEach(["delete","get","head","post","put","patch","common"],function(n){delete e.headers[n]});var t=e.adapter||mc.adapter;return t(e).then(function(n){return is(e),n.data=ns.call(e,n.data,n.headers,e.transformResponse),n},function(n){return pc(n)||(is(e),n&&n.response&&(n.response.data=ns.call(e,n.response.data,n.response.headers,e.transformResponse))),Promise.reject(n)})},ie=K,Gi=function(e,t){t=t||{};var s={};function n(m,g){return ie.isPlainObject(m)&&ie.isPlainObject(g)?ie.merge(m,g):ie.isPlainObject(g)?ie.merge({},g):ie.isArray(g)?g.slice():g}function i(m){if(ie.isUndefined(t[m])){if(!ie.isUndefined(e[m]))return n(void 0,e[m])}else return n(e[m],t[m])}function o(m){if(!ie.isUndefined(t[m]))return n(void 0,t[m])}function a(m){if(ie.isUndefined(t[m])){if(!ie.isUndefined(e[m]))return n(void 0,e[m])}else return n(void 0,t[m])}function h(m){if(m in t)return n(e[m],t[m]);if(m in e)return n(void 0,e[m])}var l={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:h};return ie.forEach(Object.keys(e).concat(Object.keys(t)),function(g){var b=l[g]||i,w=b(g);ie.isUndefined(w)&&b!==h||(s[g]=w)}),s},os,Fn;function Vi(){return Fn||(Fn=1,os={version:"0.27.2"}),os}var _c=Vi().version,Fe=bt,Js={};["object","boolean","number","function","string","symbol"].forEach(function(r,e){Js[r]=function(s){return typeof s===r||"a"+(e<1?"n ":" ")+r}});var $n={};Js.transitional=function(e,t,s){function n(i,o){return"[Axios v"+_c+"] Transitional option '"+i+"'"+o+(s?". "+s:"")}return function(i,o,a){if(e===!1)throw new Fe(n(o," has been removed"+(t?" in "+t:"")),Fe.ERR_DEPRECATED);return t&&!$n[o]&&($n[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,a):!0}};function yc(r,e,t){if(typeof r!="object")throw new Fe("options must be an object",Fe.ERR_BAD_OPTION_VALUE);for(var s=Object.keys(r),n=s.length;n-- >0;){var i=s[n],o=e[i];if(o){var a=r[i],h=a===void 0||o(a,i,r);if(h!==!0)throw new Fe("option "+i+" must be "+h,Fe.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Fe("Unknown option "+i,Fe.ERR_BAD_OPTION)}}var wc={assertOptions:yc,validators:Js},Wi=K,xc=$i,Ln=Ga,Dn=gc,kr=Gi,vc=Ji,Yi=wc,st=Yi.validators;function lt(r){this.defaults=r,this.interceptors={request:new Ln,response:new Ln}}lt.prototype.request=function(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=kr(this.defaults,t),t.method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var s=t.transitional;s!==void 0&&Yi.assertOptions(s,{silentJSONParsing:st.transitional(st.boolean),forcedJSONParsing:st.transitional(st.boolean),clarifyTimeoutError:st.transitional(st.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(t)===!1||(i=i&&w.synchronous,n.unshift(w.fulfilled,w.rejected))});var o=[];this.interceptors.response.forEach(function(w){o.push(w.fulfilled,w.rejected)});var a;if(!i){var h=[Dn,void 0];for(Array.prototype.unshift.apply(h,n),h=h.concat(o),a=Promise.resolve(t);h.length;)a=a.then(h.shift(),h.shift());return a}for(var l=t;n.length;){var m=n.shift(),g=n.shift();try{l=m(l)}catch(b){g(b);break}}try{a=Dn(l)}catch(b){return Promise.reject(b)}for(;o.length;)a=a.then(o.shift(),o.shift());return a};lt.prototype.getUri=function(e){e=kr(this.defaults,e);var t=vc(e.baseURL,e.url);return xc(t,e.params,e.paramsSerializer)};Wi.forEach(["delete","get","head","options"],function(e){lt.prototype[e]=function(t,s){return this.request(kr(s||{},{method:e,url:t,data:(s||{}).data}))}});Wi.forEach(["post","put","patch"],function(e){function t(s){return function(i,o,a){return this.request(kr(a||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}lt.prototype[e]=t(),lt.prototype[e+"Form"]=t(!0)});var Sc=lt,as,qn;function Ec(){if(qn)return as;qn=1;var r=Or();function e(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var s;this.promise=new Promise(function(o){s=o});var n=this;this.promise.then(function(i){if(n._listeners){var o,a=n._listeners.length;for(o=0;o<a;o++)n._listeners[o](i);n._listeners=null}}),this.promise.then=function(i){var o,a=new Promise(function(h){n.subscribe(h),o=h}).then(i);return a.cancel=function(){n.unsubscribe(o)},a},t(function(o){n.reason||(n.reason=new r(o),s(n.reason))})}return e.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},e.prototype.subscribe=function(s){if(this.reason){s(this.reason);return}this._listeners?this._listeners.push(s):this._listeners=[s]},e.prototype.unsubscribe=function(s){if(this._listeners){var n=this._listeners.indexOf(s);n!==-1&&this._listeners.splice(n,1)}},e.source=function(){var s,n=new e(function(o){s=o});return{token:n,cancel:s}},as=e,as}var cs,Bn;function Ac(){return Bn||(Bn=1,cs=function(e){return function(s){return e.apply(null,s)}}),cs}var us,Hn;function Pc(){if(Hn)return us;Hn=1;var r=K;return us=function(t){return r.isObject(t)&&t.isAxiosError===!0},us}var Jn=K,Oc=Ui,ur=Sc,Cc=Gi,kc=Hs;function Ki(r){var e=new ur(r),t=Oc(ur.prototype.request,e);return Jn.extend(t,ur.prototype,e),Jn.extend(t,e),t.create=function(n){return Ki(Cc(r,n))},t}var re=Ki(kc);re.Axios=ur;re.CanceledError=Or();re.CancelToken=Ec();re.isCancel=zi();re.VERSION=Vi().version;re.toFormData=Hi;re.AxiosError=bt;re.Cancel=re.CanceledError;re.all=function(e){return Promise.all(e)};re.spread=Ac();re.isAxiosError=Pc();Ni.exports=re;Ni.exports.default=re;var Rc={exports:{}};(function(r){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function n(h,l,m){this.fn=h,this.context=l,this.once=m||!1}function i(h,l,m,g,b){if(typeof m!="function")throw new TypeError("The listener must be a function");var w=new n(m,g||h,b),A=t?t+l:l;return h._events[A]?h._events[A].fn?h._events[A]=[h._events[A],w]:h._events[A].push(w):(h._events[A]=w,h._eventsCount++),h}function o(h,l){--h._eventsCount===0?h._events=new s:delete h._events[l]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var l=[],m,g;if(this._eventsCount===0)return l;for(g in m=this._events)e.call(m,g)&&l.push(t?g.slice(1):g);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(m)):l},a.prototype.listeners=function(l){var m=t?t+l:l,g=this._events[m];if(!g)return[];if(g.fn)return[g.fn];for(var b=0,w=g.length,A=new Array(w);b<w;b++)A[b]=g[b].fn;return A},a.prototype.listenerCount=function(l){var m=t?t+l:l,g=this._events[m];return g?g.fn?1:g.length:0},a.prototype.emit=function(l,m,g,b,w,A){var k=t?t+l:l;if(!this._events[k])return!1;var R=this._events[k],M=arguments.length,N,U;if(R.fn){switch(R.once&&this.removeListener(l,R.fn,void 0,!0),M){case 1:return R.fn.call(R.context),!0;case 2:return R.fn.call(R.context,m),!0;case 3:return R.fn.call(R.context,m,g),!0;case 4:return R.fn.call(R.context,m,g,b),!0;case 5:return R.fn.call(R.context,m,g,b,w),!0;case 6:return R.fn.call(R.context,m,g,b,w,A),!0}for(U=1,N=new Array(M-1);U<M;U++)N[U-1]=arguments[U];R.fn.apply(R.context,N)}else{var J=R.length,T;for(U=0;U<J;U++)switch(R[U].once&&this.removeListener(l,R[U].fn,void 0,!0),M){case 1:R[U].fn.call(R[U].context);break;case 2:R[U].fn.call(R[U].context,m);break;case 3:R[U].fn.call(R[U].context,m,g);break;case 4:R[U].fn.call(R[U].context,m,g,b);break;default:if(!N)for(T=1,N=new Array(M-1);T<M;T++)N[T-1]=arguments[T];R[U].fn.apply(R[U].context,N)}}return!0},a.prototype.on=function(l,m,g){return i(this,l,m,g,!1)},a.prototype.once=function(l,m,g){return i(this,l,m,g,!0)},a.prototype.removeListener=function(l,m,g,b){var w=t?t+l:l;if(!this._events[w])return this;if(!m)return o(this,w),this;var A=this._events[w];if(A.fn)A.fn===m&&(!b||A.once)&&(!g||A.context===g)&&o(this,w);else{for(var k=0,R=[],M=A.length;k<M;k++)(A[k].fn!==m||b&&!A[k].once||g&&A[k].context!==g)&&R.push(A[k]);R.length?this._events[w]=R.length===1?R[0]:R:o(this,w)}return this},a.prototype.removeAllListeners=function(l){var m;return l?(m=t?t+l:l,this._events[m]&&o(this,m)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,r.exports=a})(Rc);class Rr extends ga{constructor(){super(),this.init()}init(){console.log("controller init")}onReady(){console.log("here can call other controller")}}function jc(r){let e=$c();return Ic(r,e),Dc(e)}function Ic(r,e){let t=r.sub;t!==void 0&&(Oe(e,10),er(e,t));let s=r.msg;s!==void 0&&(Oe(e,18),er(e,s));let n=r.error;n!==void 0&&(Oe(e,26),er(e,n));let i=r.type;i!==void 0&&(Oe(e,34),er(e,i));let o=r.fva11;o!==void 0&&(Oe(e,45),Wn(e,o));let a=r.fva12;a!==void 0&&(Oe(e,53),Wn(e,a));let h=r.iva11;h!==void 0&&(Oe(e,56),Yn(e,zn(h)));let l=r.iva12;l!==void 0&&(Oe(e,64),Yn(e,zn(l)))}function Tc(r){return Nc(Lc(r))}function Nc(r){let e={};e:for(;!qc(r);){let t=Ue(r);switch(t>>>3){case 0:break e;case 1:{e.sub=Qt(r,Ue(r));break}case 2:{e.msg=Qt(r,Ue(r));break}case 3:{e.error=Qt(r,Ue(r));break}case 4:{e.type=Qt(r,Ue(r));break}case 5:{e.fva11=Vn(r);break}case 6:{e.fva12=Vn(r);break}case 7:{e.iva11=Ue(r);break}case 8:{e.iva12=Ue(r);break}default:Uc(r,t&7)}}return e}function Uc(r,e){switch(e){case 0:for(;Xi(r)&128;);break;case 2:hs(r,Ue(r));break;case 5:hs(r,4);break;case 1:hs(r,8);break;default:throw new Error("Unimplemented type: "+e)}}let zs=new Float32Array(1),$e=new Uint8Array(zs.buffer),Mc=new Float64Array(1);new Uint8Array(Mc.buffer);function zn(r){return r|=0,{low:r,high:r>>31,unsigned:r>=0}}let Fc=[];function $c(){const r=Fc.pop();return r?(r.offset=r.limit=0,r):{bytes:new Uint8Array(64),offset:0,limit:0}}function Lc(r){return{bytes:r,offset:0,limit:r.length}}function Dc(r){let e=r.bytes,t=r.limit;return e.length===t?e:e.subarray(0,t)}function hs(r,e){if(r.offset+e>r.limit)throw new Error("Skip past limit");r.offset+=e}function qc(r){return r.offset>=r.limit}function jr(r,e){let t=r.bytes,s=r.offset,n=r.limit,i=s+e;if(i>t.length){let o=new Uint8Array(i*2);o.set(t),r.bytes=o}return r.offset=i,i>n&&(r.limit=i),s}function Gs(r,e){let t=r.offset;if(t+e>r.limit)throw new Error("Read past limit");return r.offset+=e,t}function Qt(r,e){let t=Gs(r,e),s=String.fromCharCode,n=r.bytes,i="�",o="";for(let a=0;a<e;a++){let h=n[a+t],l,m,g,b;h&128?(h&224)===192?a+1>=e?o+=i:(l=n[a+t+1],(l&192)!==128?o+=i:(b=(h&31)<<6|l&63,b<128?o+=i:(o+=s(b),a++))):(h&240)==224?a+2>=e?o+=i:(l=n[a+t+1],m=n[a+t+2],((l|m<<8)&49344)!==32896?o+=i:(b=(h&15)<<12|(l&63)<<6|m&63,b<2048||b>=55296&&b<=57343?o+=i:(o+=s(b),a+=2))):(h&248)==240?a+3>=e?o+=i:(l=n[a+t+1],m=n[a+t+2],g=n[a+t+3],((l|m<<8|g<<16)&12632256)!==8421504?o+=i:(b=(h&7)<<18|(l&63)<<12|(m&63)<<6|g&63,b<65536||b>1114111?o+=i:(b-=65536,o+=s((b>>10)+55296,(b&1023)+56320),a+=3))):o+=i:o+=s(h)}return o}function er(r,e){let t=e.length,s=0;for(let o=0;o<t;o++){let a=e.charCodeAt(o);a>=55296&&a<=56319&&o+1<t&&(a=(a<<10)+e.charCodeAt(++o)-56613888),s+=a<128?1:a<2048?2:a<65536?3:4}Oe(r,s);let n=jr(r,s),i=r.bytes;for(let o=0;o<t;o++){let a=e.charCodeAt(o);a>=55296&&a<=56319&&o+1<t&&(a=(a<<10)+e.charCodeAt(++o)-56613888),a<128?i[n++]=a:(a<2048?i[n++]=a>>6&31|192:(a<65536?i[n++]=a>>12&15|224:(i[n++]=a>>18&7|240,i[n++]=a>>12&63|128),i[n++]=a>>6&63|128),i[n++]=a&63|128)}}function Xi(r){return r.bytes[Gs(r,1)]}function Gn(r,e){let t=jr(r,1);r.bytes[t]=e}function Vn(r){let e=Gs(r,4),t=r.bytes;return $e[0]=t[e++],$e[1]=t[e++],$e[2]=t[e++],$e[3]=t[e++],zs[0]}function Wn(r,e){let t=jr(r,4),s=r.bytes;zs[0]=e,s[t++]=$e[0],s[t++]=$e[1],s[t++]=$e[2],s[t++]=$e[3]}function Ue(r){let e=0,t=0,s;do s=Xi(r),e<32&&(t|=(s&127)<<e),e+=7;while(s&128);return t}function Oe(r,e){for(e>>>=0;e>=128;)Gn(r,e&127|128),e>>>=7;Gn(r,e)}function Yn(r,e){let t=e.low>>>0,s=(e.low>>>28|e.high<<4)>>>0,n=e.high>>>24,i=n===0?s===0?t<1<<14?t<1<<7?1:2:t<1<<21?3:4:s<1<<14?s<1<<7?5:6:s<1<<21?7:8:n<1<<7?9:10,o=jr(r,i),a=r.bytes;switch(i){case 10:a[o+9]=n>>>7&1;break;case 9:a[o+8]=i!==9?n|128:n&127;break;case 8:a[o+7]=i!==8?s>>>21|128:s>>>21&127;break;case 7:a[o+6]=i!==7?s>>>14|128:s>>>14&127;break;case 6:a[o+5]=i!==6?s>>>7|128:s>>>7&127;break;case 5:a[o+4]=i!==5?s|128:s&127;break;case 4:a[o+3]=i!==4?t>>>21|128:t>>>21&127;break;case 3:a[o+2]=i!==3?t>>>14|128:t>>>14&127;break;case 2:a[o+1]=i!==2?t>>>7|128:t>>>7&127;break;case 1:a[o]=i!==1?t|128:t&127}}var Zi={exports:{}};(function(r,e){(function(t,s){s()})(Et,function(){function t(l,m){return typeof m>"u"?m={autoBom:!1}:typeof m!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),m={autoBom:!m}),m.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(l.type)?new Blob(["\uFEFF",l],{type:l.type}):l}function s(l,m,g){var b=new XMLHttpRequest;b.open("GET",l),b.responseType="blob",b.onload=function(){h(b.response,m,g)},b.onerror=function(){console.error("could not download file")},b.send()}function n(l){var m=new XMLHttpRequest;m.open("HEAD",l,!1);try{m.send()}catch{}return 200<=m.status&&299>=m.status}function i(l){try{l.dispatchEvent(new MouseEvent("click"))}catch{var m=document.createEvent("MouseEvents");m.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),l.dispatchEvent(m)}}var o=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Et=="object"&&Et.global===Et?Et:void 0,a=o.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),h=o.saveAs||(typeof window!="object"||window!==o?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(l,m,g){var b=o.URL||o.webkitURL,w=document.createElement("a");m=m||l.name||"download",w.download=m,w.rel="noopener",typeof l=="string"?(w.href=l,w.origin===location.origin?i(w):n(w.href)?s(l,m,g):i(w,w.target="_blank")):(w.href=b.createObjectURL(l),setTimeout(function(){b.revokeObjectURL(w.href)},4e4),setTimeout(function(){i(w)},0))}:"msSaveOrOpenBlob"in navigator?function(l,m,g){if(m=m||l.name||"download",typeof l!="string")navigator.msSaveOrOpenBlob(t(l,g),m);else if(n(l))s(l,m,g);else{var b=document.createElement("a");b.href=l,b.target="_blank",setTimeout(function(){i(b)})}}:function(l,m,g,b){if(b=b||open("","_blank"),b&&(b.document.title=b.document.body.innerText="downloading..."),typeof l=="string")return s(l,m,g);var w=l.type==="application/octet-stream",A=/constructor/i.test(o.HTMLElement)||o.safari,k=/CriOS\/[\d]+/.test(navigator.userAgent);if((k||w&&A||a)&&typeof FileReader<"u"){var R=new FileReader;R.onloadend=function(){var U=R.result;U=k?U:U.replace(/^data:[^;]*;/,"data:attachment/file;"),b?b.location.href=U:location=U,b=null},R.readAsDataURL(l)}else{var M=o.URL||o.webkitURL,N=M.createObjectURL(l);b?b.location=N:location.href=N,b=null,setTimeout(function(){M.revokeObjectURL(N)},4e4)}});o.saveAs=h.saveAs=h,r.exports=h})})(Zi);var Bc=Zi.exports;const Qi="3.7.5",Hc=Qi,Jc=typeof atob=="function",zc=typeof btoa=="function",gt=typeof Buffer=="function",Kn=typeof TextDecoder=="function"?new TextDecoder:void 0,Xn=typeof TextEncoder=="function"?new TextEncoder:void 0,Gc="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Pt=Array.prototype.slice.call(Gc),tr=(r=>{let e={};return r.forEach((t,s)=>e[t]=s),e})(Pt),Vc=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,W=String.fromCharCode.bind(String),Zn=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):r=>new Uint8Array(Array.prototype.slice.call(r,0)),eo=r=>r.replace(/=/g,"").replace(/[+\/]/g,e=>e=="+"?"-":"_"),to=r=>r.replace(/[^A-Za-z0-9\+\/]/g,""),ro=r=>{let e,t,s,n,i="";const o=r.length%3;for(let a=0;a<r.length;){if((t=r.charCodeAt(a++))>255||(s=r.charCodeAt(a++))>255||(n=r.charCodeAt(a++))>255)throw new TypeError("invalid character found");e=t<<16|s<<8|n,i+=Pt[e>>18&63]+Pt[e>>12&63]+Pt[e>>6&63]+Pt[e&63]}return o?i.slice(0,o-3)+"===".substring(o):i},Vs=zc?r=>btoa(r):gt?r=>Buffer.from(r,"binary").toString("base64"):ro,vs=gt?r=>Buffer.from(r).toString("base64"):r=>{let t=[];for(let s=0,n=r.length;s<n;s+=4096)t.push(W.apply(null,r.subarray(s,s+4096)));return Vs(t.join(""))},hr=(r,e=!1)=>e?eo(vs(r)):vs(r),Wc=r=>{if(r.length<2){var e=r.charCodeAt(0);return e<128?r:e<2048?W(192|e>>>6)+W(128|e&63):W(224|e>>>12&15)+W(128|e>>>6&63)+W(128|e&63)}else{var e=65536+(r.charCodeAt(0)-55296)*1024+(r.charCodeAt(1)-56320);return W(240|e>>>18&7)+W(128|e>>>12&63)+W(128|e>>>6&63)+W(128|e&63)}},Yc=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,so=r=>r.replace(Yc,Wc),Qn=gt?r=>Buffer.from(r,"utf8").toString("base64"):Xn?r=>vs(Xn.encode(r)):r=>Vs(so(r)),ot=(r,e=!1)=>e?eo(Qn(r)):Qn(r),ei=r=>ot(r,!0),Kc=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Xc=r=>{switch(r.length){case 4:var e=(7&r.charCodeAt(0))<<18|(63&r.charCodeAt(1))<<12|(63&r.charCodeAt(2))<<6|63&r.charCodeAt(3),t=e-65536;return W((t>>>10)+55296)+W((t&1023)+56320);case 3:return W((15&r.charCodeAt(0))<<12|(63&r.charCodeAt(1))<<6|63&r.charCodeAt(2));default:return W((31&r.charCodeAt(0))<<6|63&r.charCodeAt(1))}},no=r=>r.replace(Kc,Xc),io=r=>{if(r=r.replace(/\s+/g,""),!Vc.test(r))throw new TypeError("malformed base64.");r+="==".slice(2-(r.length&3));let e,t="",s,n;for(let i=0;i<r.length;)e=tr[r.charAt(i++)]<<18|tr[r.charAt(i++)]<<12|(s=tr[r.charAt(i++)])<<6|(n=tr[r.charAt(i++)]),t+=s===64?W(e>>16&255):n===64?W(e>>16&255,e>>8&255):W(e>>16&255,e>>8&255,e&255);return t},Ws=Jc?r=>atob(to(r)):gt?r=>Buffer.from(r,"base64").toString("binary"):io,oo=gt?r=>Zn(Buffer.from(r,"base64")):r=>Zn(Ws(r).split("").map(e=>e.charCodeAt(0))),ao=r=>oo(co(r)),Zc=gt?r=>Buffer.from(r,"base64").toString("utf8"):Kn?r=>Kn.decode(oo(r)):r=>no(Ws(r)),co=r=>to(r.replace(/[-_]/g,e=>e=="-"?"+":"/")),Ss=r=>Zc(co(r)),Qc=r=>{if(typeof r!="string")return!1;const e=r.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(e)||!/[^\s0-9a-zA-Z\-_]/.test(e)},uo=r=>({value:r,enumerable:!1,writable:!0,configurable:!0}),ho=function(){const r=(e,t)=>Object.defineProperty(String.prototype,e,uo(t));r("fromBase64",function(){return Ss(this)}),r("toBase64",function(e){return ot(this,e)}),r("toBase64URI",function(){return ot(this,!0)}),r("toBase64URL",function(){return ot(this,!0)}),r("toUint8Array",function(){return ao(this)})},lo=function(){const r=(e,t)=>Object.defineProperty(Uint8Array.prototype,e,uo(t));r("toBase64",function(e){return hr(this,e)}),r("toBase64URI",function(){return hr(this,!0)}),r("toBase64URL",function(){return hr(this,!0)})},eu=()=>{ho(),lo()},fo={version:Qi,VERSION:Hc,atob:Ws,atobPolyfill:io,btoa:Vs,btoaPolyfill:ro,fromBase64:Ss,toBase64:ot,encode:ot,encodeURI:ei,encodeURL:ei,utob:so,btou:no,decode:Ss,isValid:Qc,fromUint8Array:hr,toUint8Array:ao,extendString:ho,extendUint8Array:lo,extendBuiltins:eu};class tu extends Rr{constructor(){super();c(this,"ipc");c(this,"_conn");c(this,"profile",{wsPort:"",version:"",dataDir:"",exeDir:"",exeName:"",exePath:""});window.ipc?this.ipc=window.ipc:this.ipc={emit(t,...s){console.error("emit msg=>",t,s)},on(t){console.error("on message",t)}},this.initEvent()}initEvent(){const t=this;this.ipc.on("OnDragEnter",function(s){t.emit("onDragEnter",s)}),this.ipc.on("downloadsucc",(s,n)=>{t.emit("downloadsucc",s,n)}),this.ipc.emit("GetSocketUri",[],s=>{let n=new WebSocket(s);n.onopen=i=>{console.log("bus socket connected!!!")},n.onclose=i=>{console.log("app bus socket conn closed",i),setTimeout(()=>{this._conn=new WebSocket(s)},1e3)},n.onmessage=function(i){if(!(!i.data||i.data==""))try{i.data.arrayBuffer().then(a=>{const h=Tc(new Uint8Array(a));t.emit("on"+h.sub,h)})}catch(o){console.error(i.data,typeof i.data,o)}},this._conn=n})}async onReady(){this.profile=await this.getLocalAppProfile()}getLocalAppProfile(){return new Promise(t=>{this.ipc.emit("LocalAppProfile",[],function(n){t(n)})})}SelectDir(){const t=Date.now(),s="c"+t;return new Promise(n=>{const i=this.ipc;i.emit("SelectDir",[t],function(o){console.log("call=>",o),o||n(""),i.on(s,function(a){n(a)})})})}IsDirEmpty(t){return new Promise(s=>{this.ipc.emit("IsDirEmpty",[t],function(i){s(i)})})}IsFileExit(t){return new Promise(s=>{this.ipc.emit("IsFileExit",[t],function(i){s(i)})})}WriteFileText(t,s){return new Promise(n=>{this.ipc.emit("WriteFileText",[t,s],function(o){n(o)})})}ReadFileText(t){return new Promise(s=>{this.ipc.emit("ReadFileText",[t],function(i){s(i)})})}CopyFile(t,s){const i="copy"+Date.now();return new Promise(o=>{const a=this.ipc;a.on(i,function(h){o(h)}),a.emit("CopyFile",[i,t,s])})}SaveSysConfigItem(t,s){return new Promise(n=>{this.ipc.emit("SaveAppConfigItem",[t,s],function(o){n(o)})})}GetSysConfigItem(t){return new Promise(s=>{this.ipc.emit("GetAppConfigItem",[t],function(i){s(i)})})}RemoveSysConfigItem(t){return new Promise(s=>{this.ipc.emit("RemoveSysConfigItem",[t],function(i){s(i)})})}GetSysDataBaseUrl(){return new Promise(t=>{this.ipc.emit("GetAppDataBaseUrl",[],function(n){t(n)})})}CopyFileToAppData(t,s){return new Promise(n=>{this.ipc.emit("CopyFileToAppData",[t,s],function(o){n(o)})})}RemoveAppData(t){return new Promise(s=>{this.ipc.emit("RemoveAppData",[t],function(i){s(i)})})}OpenDir(t){return new Promise(s=>{this.ipc.emit("OpenDir",[t],function(i){s(i)})})}SelectOneFilePath(t,s){const n=Date.now();return new Promise(i=>{const o=this.ipc,a="c"+n;o.emit("SelectOneFilePath",[n,t,s],function(h){h||i(""),o.on(a,function(l){i(l)})})})}StartHttpServer(t){return new Promise(s=>{this.ipc.emit("StartProjectHttpServer",[t],function(i){s(i)})})}DownloadFile(t,s,n=60*20){const i="d"+Date.now();return new Promise(o=>{this.ipc.emit("DownloadFile",[i,s,t,n],function(){o(!0)})})}Unzip(t,s,n){const i="unzip"+Date.now();return new Promise(o=>{this.ipc.emit("Unzip",[i,t,s])})}GetDirSize(t){return new Promise(s=>{this.ipc.emit("GetDirSize",[t],function(i){s(i)})})}GetAppDataDir(){return new Promise(t=>{this.ipc.emit("GetAppDataDir",[],function(n){t(n)})})}OpenAssetWindow(t){return new Promise(s=>{this.ipc.emit("openAssetsWindow",[`${location.host}/library.html?path=${t}`,"资源管理库",1280,960],function(i){s(i)})})}SendMsg(t,s){const n=this._conn;if(!n){console.error("应用socket异常");return}n.send(jc({sub:t,msg:s}))}OnMsg(t,s){return this.on("on"+t,s)}UploadSync(t){return new Promise(s=>{this.ipc.emit("UploadSync",[t],function(i){s(i)})})}UploadASync(t){const s="u"+Date.now();return new Promise(n=>{const i=this.ipc;i.emit("UploadASync",[s,t],function(o){if(!o){n([]);return}i.on(s,a=>{n(a)})})})}UploadDir(t,s){const n="u"+Date.now();return new Promise(i=>{const o=this.ipc;o.emit("UploadDir",[n,t,s],function(a){if(!a){i([]);return}o.on(n,h=>{i(h)})})})}GetFilesInDir(t,s){return new Promise(n=>{this.ipc.emit("GetFilesInDir",[t,s],function(o){n(o)})})}GetRunningApp(){return new Promise(t=>{this.ipc.emit("GetRunningApp",[],function(n){t(n)})})}GetSubDirNames(t){return new Promise(s=>{this.ipc.emit("GetSubDirNames",[t],function(i){s(i)})})}RemoveFile(t){return new Promise(s=>{this.ipc.emit("RemoveFile",[t],function(i){s(i)})})}RemoveDir(t){return new Promise(s=>{this.ipc.emit("RemoveDir",[t],function(i){s(i)})})}GetSaveFile(t,s="图片(*.png;*.jpg)"){const n="sf"+Date.now();return new Promise(i=>{const o=this.ipc;o.emit("GetSaveFile",[n,t,s],function(a){if(a){o.on(n,h=>{i(h)});return}i("")})})}OpenOneFile(t,s="图片(*.png;*.jpg)"){const n="sf"+Date.now();return new Promise(i=>{this.ipc.emit("OpenOneFile",[n,t,s],function(a){setTimeout(()=>{i(a)},0)})})}GetImageMeta(t){return new Promise(s=>{const n=new Image;n.onload=()=>{s({Width:n.width,Height:n.height,Size:0})},n.src=t})}SetMainTitle(t){return new Promise(s=>{this.ipc.emit("SetMainTitle",[t],function(i){s(i)})})}SaveFile(t,s){return new Promise(n=>{this.ipc.emit("SaveFile",[t,Array.from(s)],function(o){n(o)})})}OpenQueen5(t,s){return new Promise(n=>{this.ipc.emit("OpenQueen5",[t,s],function(o){n(o)})})}OpenQueen5Play(t,s){return new Promise(n=>{this.ipc.emit("OpenQueen5Play",[t,s],function(o){n(o)})})}SaveBlobFile(t,s){return console.log("save blob to ",s),new Promise(n=>{const i=this.on("downloadsucc",o=>{console.log("fpath=>",o),s==fo.encode(o)&&(i.unbind(),n(!0))});Bc.saveAs(t,s)})}SaveClipboard(t){return navigator.clipboard.write([new ClipboardItem({"image/png":t})])}GetNatsProfile(){return new Promise(t=>{this.ipc.emit("NatsProfile",[],function(n){t(n)})})}OpenWeb(t,s,n=1280,i=720){return new Promise(o=>{this.ipc.emit("OpenWeb",[t,s,n,i],function(h){o(h)})})}RunNativeApp(t,s,n,i,o){return new Promise(a=>{this.ipc.emit("RunNativeApp",[t,s,n,i,o],function(l){console.log("xxxx",l),a(l)})})}RunCmdSvcApp(t,s,n,i,o,a){return new Promise(h=>{this.ipc.emit("RunCmdSvcApp",[t,s,n,i,o,a],function(m){console.log("xxxx",m),h(m)})})}StopNativeApp(t){return new Promise(s=>{this.ipc.emit("StopNativeApp",[t],function(i){s(i)})})}LancherUpgrade(t,s){return new Promise(n=>{this.ipc.emit("Upgrade",[t,s],function(o){n(o)})})}CreateShortcut(t,s,n){return new Promise(i=>{this.ipc.emit("CreateShortcut",[t,s,n],function(a){i(a)})})}DeleteShortcut(t){return new Promise(s=>{this.ipc.emit("DeleteShortcut",[t],function(i){s(i)})})}ResumeMainWnd(){return new Promise(t=>{this.ipc.emit("ResumeMainWnd",[],function(n){t(n)})})}HideMainWnd(){return new Promise(t=>{this.ipc.emit("HideMainWnd",[],function(n){t(n)})})}QuitLancher(){return new Promise(t=>{this.ipc.emit("QuitLancher",[],function(n){t(n)})})}MaxWindow(t){return new Promise(s=>{this.ipc.emit("MaxWindow",[t],function(i){s(i)})})}FoldWindow(t){return new Promise(s=>{this.ipc.emit("FoldWindow",[t],function(i){s(i)})})}TrayNotice(t){return new Promise(s=>{this.ipc.emit("TrayNotice",[t.title||"提示",t.context,t.timeout||2e3],function(i){s(i)})})}UpdateConfig(t){return new Promise(s=>{this.ipc.emit("UpdateConfig",[t],function(i){s(i)})})}}class ru extends Rr{constructor(){super(...arguments);c(this,"RootDir","");c(this,"DataDir","");c(this,"HostURL","");c(this,"_swiftLocal",!0);c(this,"_spu3dFile");c(this,"UserId","spu3d");c(this,"NatsProfile",{apiPort:"",wsPort:"",ip:""})}async onReady(){const t=ye().deviceCtrl;t.GetAppDataDir().then(s=>{this.DataDir=s,this.RootDir=s}),this.NatsProfile=await t.GetNatsProfile(),console.log("nats profile=>",this.NatsProfile)}getOutputDir(){return this.RootDir+"/outputs"}getAppDataDir(){return this.DataDir}getAppInstallDir(){return this.createPath("installDir")}getDefaultLogo(){return this.DataDir+"/static/thumbnail.png"}createPath(t){return this.RootDir+"/"+t}createBase64Path(t){const s=fo.encode(this.createPath(t));return console.log("str",s),s}getSwiftUri(t){return this._swiftLocal?this.getLocalAbsoluteUri(t):this.getHttpAbsoluteUri(t)}getHttpAbsoluteUri(t){return t?t.substring(0,2)=="//"?"http://"+t:t.substring(0,4)=="http"?t:t.charAt(0)=="/"?this.HostURL+t.substring(1):this.HostURL+t:""}getLocalAbsoluteUri(t){return t?t.substring(0,2)=="//"?"http://"+t:t.substring(0,4)=="http"?t:t.charAt(0)=="/"?this.RootDir+t:this.RootDir+"/"+t:""}getRelativeUri(t){let s=this.HostURL.length,n=t.substring(0,s);return n==this.HostURL||(s=this.RootDir.length,n=t.substring(0,s),n==this.RootDir)?t.substring(s+1):""}async pickProject(){const s=await ye().deviceCtrl.SelectDir();return await this.isProjectExit(s)?s:Promise.reject()}async isProjectExit(t){return await ye().deviceCtrl.IsFileExit(`${t}/project.spu3d`)}isProjectFile(t){return t.substring(0,this.RootDir.length)==this.RootDir}async copy2Project(t,s){if(this.isProjectFile(t))return t.substring(this.RootDir.length+1);const n=t.substring(t.lastIndexOf(".")),i=s(n);return await ye().deviceCtrl.CopyFile(t,this.createPath(i)),i}}var Es=function(r,e){return Es=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,s){t.__proto__=s}||function(t,s){for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(t[n]=s[n])},Es(r,e)};function Lt(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");Es(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function As(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],s=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&s>=r.length&&(r=void 0),{value:r&&r[s++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function mr(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var s=t.call(r),n,i=[],o;try{for(;(e===void 0||e-- >0)&&!(n=s.next()).done;)i.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=s.return)&&t.call(s)}finally{if(o)throw o.error}}return i}function br(r,e,t){if(t||arguments.length===2)for(var s=0,n=e.length,i;s<n;s++)(i||!(s in e))&&(i||(i=Array.prototype.slice.call(e,0,s)),i[s]=e[s]);return r.concat(i||Array.prototype.slice.call(e))}function Re(r){return typeof r=="function"}function po(r){var e=function(s){Error.call(s),s.stack=new Error().stack},t=r(e);return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var ls=po(function(r){return function(t){r(this),this.message=t?t.length+` errors occurred during unsubscription:
  3. `+t.map(function(s,n){return n+1+") "+s.toString()}).join(`
  4. `):"",this.name="UnsubscriptionError",this.errors=t}});function Ps(r,e){if(r){var t=r.indexOf(e);0<=t&&r.splice(t,1)}}var Ir=function(){function r(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return r.prototype.unsubscribe=function(){var e,t,s,n,i;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var a=As(o),h=a.next();!h.done;h=a.next()){var l=h.value;l.remove(this)}}catch(k){e={error:k}}finally{try{h&&!h.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}else o.remove(this);var m=this.initialTeardown;if(Re(m))try{m()}catch(k){i=k instanceof ls?k.errors:[k]}var g=this._finalizers;if(g){this._finalizers=null;try{for(var b=As(g),w=b.next();!w.done;w=b.next()){var A=w.value;try{ti(A)}catch(k){i=i??[],k instanceof ls?i=br(br([],mr(i)),mr(k.errors)):i.push(k)}}}catch(k){s={error:k}}finally{try{w&&!w.done&&(n=b.return)&&n.call(b)}finally{if(s)throw s.error}}}if(i)throw new ls(i)}},r.prototype.add=function(e){var t;if(e&&e!==this)if(this.closed)ti(e);else{if(e instanceof r){if(e.closed||e._hasParent(this))return;e._addParent(this)}(this._finalizers=(t=this._finalizers)!==null&&t!==void 0?t:[]).push(e)}},r.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},r.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},r.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Ps(t,e)},r.prototype.remove=function(e){var t=this._finalizers;t&&Ps(t,e),e instanceof r&&e._removeParent(this)},r.EMPTY=function(){var e=new r;return e.closed=!0,e}(),r}(),mo=Ir.EMPTY;function bo(r){return r instanceof Ir||r&&"closed"in r&&Re(r.remove)&&Re(r.add)&&Re(r.unsubscribe)}function ti(r){Re(r)?r():r.unsubscribe()}var go={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},Os={setTimeout:function(r,e){for(var t=[],s=2;s<arguments.length;s++)t[s-2]=arguments[s];var n=Os.delegate;return n!=null&&n.setTimeout?n.setTimeout.apply(n,br([r,e],mr(t))):setTimeout.apply(void 0,br([r,e],mr(t)))},clearTimeout:function(r){var e=Os.delegate;return((e==null?void 0:e.clearTimeout)||clearTimeout)(r)},delegate:void 0};function su(r){Os.setTimeout(function(){throw r})}function ri(){}function lr(r){r()}var _o=function(r){Lt(e,r);function e(t){var s=r.call(this)||this;return s.isStopped=!1,t?(s.destination=t,bo(t)&&t.add(s)):s.destination=au,s}return e.create=function(t,s,n){return new Cs(t,s,n)},e.prototype.next=function(t){this.isStopped||this._next(t)},e.prototype.error=function(t){this.isStopped||(this.isStopped=!0,this._error(t))},e.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},e.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,r.prototype.unsubscribe.call(this),this.destination=null)},e.prototype._next=function(t){this.destination.next(t)},e.prototype._error=function(t){try{this.destination.error(t)}finally{this.unsubscribe()}},e.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},e}(Ir),nu=Function.prototype.bind;function fs(r,e){return nu.call(r,e)}var iu=function(){function r(e){this.partialObserver=e}return r.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(s){rr(s)}},r.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(s){rr(s)}else rr(e)},r.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(t){rr(t)}},r}(),Cs=function(r){Lt(e,r);function e(t,s,n){var i=r.call(this)||this,o;if(Re(t)||!t)o={next:t??void 0,error:s??void 0,complete:n??void 0};else{var a;i&&go.useDeprecatedNextContext?(a=Object.create(t),a.unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&fs(t.next,a),error:t.error&&fs(t.error,a),complete:t.complete&&fs(t.complete,a)}):o=t}return i.destination=new iu(o),i}return e}(_o);function rr(r){su(r)}function ou(r){throw r}var au={closed:!0,next:ri,error:ou,complete:ri},cu=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function uu(r){return r}function hu(r){return r.length===0?uu:r.length===1?r[0]:function(t){return r.reduce(function(s,n){return n(s)},t)}}var si=function(){function r(e){e&&(this._subscribe=e)}return r.prototype.lift=function(e){var t=new r;return t.source=this,t.operator=e,t},r.prototype.subscribe=function(e,t,s){var n=this,i=fu(e)?e:new Cs(e,t,s);return lr(function(){var o=n,a=o.operator,h=o.source;i.add(a?a.call(i,h):h?n._subscribe(i):n._trySubscribe(i))}),i},r.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},r.prototype.forEach=function(e,t){var s=this;return t=ni(t),new t(function(n,i){var o=new Cs({next:function(a){try{e(a)}catch(h){i(h),o.unsubscribe()}},error:i,complete:n});s.subscribe(o)})},r.prototype._subscribe=function(e){var t;return(t=this.source)===null||t===void 0?void 0:t.subscribe(e)},r.prototype[cu]=function(){return this},r.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return hu(e)(this)},r.prototype.toPromise=function(e){var t=this;return e=ni(e),new e(function(s,n){var i;t.subscribe(function(o){return i=o},function(o){return n(o)},function(){return s(i)})})},r.create=function(e){return new r(e)},r}();function ni(r){var e;return(e=r??go.Promise)!==null&&e!==void 0?e:Promise}function lu(r){return r&&Re(r.next)&&Re(r.error)&&Re(r.complete)}function fu(r){return r&&r instanceof _o||lu(r)&&bo(r)}var du=po(function(r){return function(){r(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),yo=function(r){Lt(e,r);function e(){var t=r.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return e.prototype.lift=function(t){var s=new ii(this,this);return s.operator=t,s},e.prototype._throwIfClosed=function(){if(this.closed)throw new du},e.prototype.next=function(t){var s=this;lr(function(){var n,i;if(s._throwIfClosed(),!s.isStopped){s.currentObservers||(s.currentObservers=Array.from(s.observers));try{for(var o=As(s.currentObservers),a=o.next();!a.done;a=o.next()){var h=a.value;h.next(t)}}catch(l){n={error:l}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}}})},e.prototype.error=function(t){var s=this;lr(function(){if(s._throwIfClosed(),!s.isStopped){s.hasError=s.isStopped=!0,s.thrownError=t;for(var n=s.observers;n.length;)n.shift().error(t)}})},e.prototype.complete=function(){var t=this;lr(function(){if(t._throwIfClosed(),!t.isStopped){t.isStopped=!0;for(var s=t.observers;s.length;)s.shift().complete()}})},e.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(e.prototype,"observed",{get:function(){var t;return((t=this.observers)===null||t===void 0?void 0:t.length)>0},enumerable:!1,configurable:!0}),e.prototype._trySubscribe=function(t){return this._throwIfClosed(),r.prototype._trySubscribe.call(this,t)},e.prototype._subscribe=function(t){return this._throwIfClosed(),this._checkFinalizedStatuses(t),this._innerSubscribe(t)},e.prototype._innerSubscribe=function(t){var s=this,n=this,i=n.hasError,o=n.isStopped,a=n.observers;return i||o?mo:(this.currentObservers=null,a.push(t),new Ir(function(){s.currentObservers=null,Ps(a,t)}))},e.prototype._checkFinalizedStatuses=function(t){var s=this,n=s.hasError,i=s.thrownError,o=s.isStopped;n?t.error(i):o&&t.complete()},e.prototype.asObservable=function(){var t=new si;return t.source=this,t},e.create=function(t,s){return new ii(t,s)},e}(si),ii=function(r){Lt(e,r);function e(t,s){var n=r.call(this)||this;return n.destination=t,n.source=s,n}return e.prototype.next=function(t){var s,n;(n=(s=this.destination)===null||s===void 0?void 0:s.next)===null||n===void 0||n.call(s,t)},e.prototype.error=function(t){var s,n;(n=(s=this.destination)===null||s===void 0?void 0:s.error)===null||n===void 0||n.call(s,t)},e.prototype.complete=function(){var t,s;(s=(t=this.destination)===null||t===void 0?void 0:t.complete)===null||s===void 0||s.call(t)},e.prototype._subscribe=function(t){var s,n;return(n=(s=this.source)===null||s===void 0?void 0:s.subscribe(t))!==null&&n!==void 0?n:mo},e}(yo),pu=function(r){Lt(e,r);function e(t){var s=r.call(this)||this;return s._value=t,s}return Object.defineProperty(e.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),e.prototype._subscribe=function(t){var s=r.prototype._subscribe.call(this,t);return!s.closed&&t.next(this._value),s},e.prototype.getValue=function(){var t=this,s=t.hasError,n=t.thrownError,i=t._value;if(s)throw n;return this._throwIfClosed(),i},e.prototype.next=function(t){r.prototype.next.call(this,this._value=t)},e}(yo);class Ys{constructor(e,t,s,n){c(this,"Id");c(this,"Value");c(this,"OldValue");c(this,"Rx");this.Id=e,this.Value=t,this.OldValue=s,this.Rx=n}redo(){this.Rx.next({value:this.Value,_hstry:!1})}undo(){this.Rx.next({value:this.OldValue,_hstry:!1})}clone(){return new Ys(this.Id,this.Value,this.OldValue,this.Rx)}}function mu(r,e){return new pu({value:r,_hstry:e})}let oi=0;function bu(r,e,t){let s=oi+1;return oi+=1,new Ys(s+"",r,e,t)}class gu{static create(e,t){let s={__rx:!0};return s._historySnap={},s._historySub={},s._rxs={},s._fields=e,s._history=t,s._refs={},Object.keys(e).forEach(i=>{const o=i,a=e[o];if(typeof a=="object"&&a.__rx){s[o]=a;return}const l=mu(a,!!t);s._rxs[i]=l;const m=bu(a,a,l);s._historySnap[i]=m;const g=Ii({value:a});Object.defineProperty(s,o,{get:function(){return g.value},set:function(w){l.next({value:w})},configurable:!0,enumerable:!0});const b=o.slice(0,1).toUpperCase()+o.slice(1);s["set"+b]=function(w,A=!1){l.next({value:w,_hstry:!A})},s["on"+b+"Changed"]=function(w){return l.subscribe(A=>{w(A.value,m.OldValue)})},s._historySub[i]=l.subscribe(w=>{if(m.OldValue=g.value,g.value=w.value,s._history&&s._history.enable){if(!w._hstry)return;const A=m.clone();A.Value=w.value,s._history.record(A)}})}),s.setHistory=function(i){s._history=i},s.toJson=function(){const i={};return Object.keys(e).forEach(a=>{const h=e[a];if(typeof h=="object"&&h.__rx){i[a]=s[a].toJson();return}i[a]=wn.cloneDeep(ca(s._rxs[a].getValue().value))}),i},s.fromJson=function(i){const o={};return Object.keys(e).forEach(h=>{const l=e[h];if(typeof l=="object"&&l.__rx){i[h]&&(o[h]=s[h].fromJson(i[h]));return}s._rxs[h].next({value:i[h]!=null?i[h]:wn.cloneDeep(l),_hstry:!1})}),o},s}}class _u extends Rr{constructor(){super(...arguments);c(this,"state",gu.create({apps:[],installing:!1,installApp:{},downProgress:"",installProgress:""}))}async onReady(){return window.DownloadStartJsFunc=this.DownloadStartJsFunc,window.DownloadProgressJsFunc=this.DownloadProgressJsFunc.bind(this),window.DownloadSuccJsFunc=this.DownloadSuccJsFunc.bind(this),window.DownloadErrorJsFunc=this.DownloadErrorJsFunc.bind(this),window.UnzipProgressJsFunc=this.UnzipProgressJsFunc.bind(this),window.UnzipSuccJsFunc=this.UnzipSuccJsFunc.bind(this),window.UnzipErrorJsFunc=this.UnzipErrorJsFunc.bind(this),await this.parseInstalledApp()}async parseInstalledApp(){const{deviceCtrl:t,prjCtrl:s}=ye(),n=[];try{const i=await t.ReadFileText(`${s.RootDir}/app.json`);if(!i.error&&i.text){const o=JSON.parse(i.text);n.push(o)}}catch(i){console.error(i)}this.state.setApps(n)}async install(t){console.log("install=>",t);const{deviceCtrl:s,prjCtrl:n}=ye(),i=n.createPath(`${t._id}.zip`);this.state.installing=!0,this.state.installApp=t,s.DownloadFile(t.url,i,60*10)}DownloadStartJsFunc(){console.log("download start")}DownloadProgressJsFunc(t,s,n){Me.show(`下载完成 ${((n||0)*100).toFixed(1)}%`)}async DownloadSuccJsFunc(){const{deviceCtrl:t,prjCtrl:s}=ye();Me.hidden(),ar.success("下载成功,开始安装!");const n=this.state.installApp,i=s.createPath(`${n._id}.zip`),o=s.RootDir;await t.Unzip(i,o)}DownloadErrorJsFunc(){const{deviceCtrl:t}=ye();Me.hidden(),this.state.installing=!1,t.TrayNotice({context:"下载失败,请检查你的网络设置"})}UnzipProgressJsFunc(t,s,n){Me.show(`安装完成 ${((n||0)*10).toFixed(1)}%`)}async UnzipSuccJsFunc(){const{deviceCtrl:t,prjCtrl:s}=ye();Me.hidden();try{this.state.installing=!1;const n=this.state.installApp,i=s.createPath(`${n._id}.zip`);await t.UpdateConfig(n.version),await this.parseInstalledApp(),t.RemoveFile(i),t.TrayNotice({context:"安装成功!"})}catch(n){console.log(n)}}UnzipErrorJsFunc(){const{deviceCtrl:t}=ye();Me.hidden(),this.state.installing=!1,t.TrayNotice({context:"安装失败!"})}}const se=new Uint8Array(0),Ye=new TextEncoder,ae=new TextDecoder;function yu(...r){let e=0;for(let n=0;n<r.length;n++)e+=r[n].length;const t=new Uint8Array(e);let s=0;for(let n=0;n<r.length;n++)t.set(r[n],s),s+=r[n].length;return t}function kt(...r){const e=[];for(let t=0;t<r.length;t++)e.push(Ye.encode(r[t]));return e.length===0?se:e.length===1?e[0]:yu(...e)}function ai(r){return!r||r.length===0?"":ae.decode(r)}const ci="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",ui=36,wu=0xcfd41b9100000,hi=33,xu=333,li=12+10;function vu(r){for(let e=0;e<r.length;e++)r[e]=Math.floor(Math.random()*255)}function Su(r){var e;(e=globalThis==null?void 0:globalThis.crypto)!=null&&e.getRandomValues?globalThis.crypto.getRandomValues(r):vu(r)}class Eu{constructor(){c(this,"buf");c(this,"seq");c(this,"inc");this.buf=new Uint8Array(li),this.init()}init(){this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(Math.random()*wu),this.inc=Math.floor(Math.random()*(xu-hi)+hi)}setPre(){const e=new Uint8Array(12);Su(e);for(let t=0;t<12;t++){const s=e[t]%36;this.buf[t]=ci.charCodeAt(s)}}fillSeq(){let e=this.seq;for(let t=li-1;t>=12;t--)this.buf[t]=ci.charCodeAt(e%ui),e=Math.floor(e/ui)}next(){return this.seq+=this.inc,this.seq>0xcfd41b9100000&&(this.setPre(),this.initSeqAndInc()),this.fillSeq(),String.fromCharCode.apply(String,this.buf)}reset(){this.init()}}const Dt=new Eu;var Ce;(function(r){r.Disconnect="disconnect",r.Reconnect="reconnect",r.Update="update",r.LDM="ldm",r.Error="error"})(Ce||(Ce={}));var at;(function(r){r.Reconnecting="reconnecting",r.PingTimer="pingTimer",r.StaleConnection="staleConnection",r.ClientInitiatedReconnect="client initiated reconnect"})(at||(at={}));var P;(function(r){r.ApiError="BAD API",r.BadAuthentication="BAD_AUTHENTICATION",r.BadCreds="BAD_CREDS",r.BadHeader="BAD_HEADER",r.BadJson="BAD_JSON",r.BadPayload="BAD_PAYLOAD",r.BadSubject="BAD_SUBJECT",r.Cancelled="CANCELLED",r.ConnectionClosed="CONNECTION_CLOSED",r.ConnectionDraining="CONNECTION_DRAINING",r.ConnectionRefused="CONNECTION_REFUSED",r.ConnectionTimeout="CONNECTION_TIMEOUT",r.Disconnect="DISCONNECT",r.InvalidOption="INVALID_OPTION",r.InvalidPayload="INVALID_PAYLOAD",r.MaxPayloadExceeded="MAX_PAYLOAD_EXCEEDED",r.NoResponders="503",r.NotFunction="NOT_FUNC",r.RequestError="REQUEST_ERROR",r.ServerOptionNotAvailable="SERVER_OPT_NA",r.SubClosed="SUB_CLOSED",r.SubDraining="SUB_DRAINING",r.Timeout="TIMEOUT",r.Tls="TLS",r.Unknown="UNKNOWN_ERROR",r.WssRequired="WSS_REQUIRED",r.JetStreamInvalidAck="JESTREAM_INVALID_ACK",r.JetStream404NoMessages="404",r.JetStream408RequestTimeout="408",r.JetStream409MaxAckPendingExceeded="409",r.JetStream409="409",r.JetStreamNotEnabled="503",r.JetStreamIdleHeartBeat="IDLE_HEARTBEAT",r.AuthorizationViolation="AUTHORIZATION_VIOLATION",r.AuthenticationExpired="AUTHENTICATION_EXPIRED",r.ProtocolError="NATS_PROTOCOL_ERR",r.PermissionsViolation="PERMISSIONS_VIOLATION",r.AuthenticationTimeout="AUTHENTICATION_TIMEOUT"})(P||(P={}));function Au(r){return typeof r.code=="string"}class wo{constructor(){c(this,"messages");this.messages=new Map,this.messages.set(P.InvalidPayload,"Invalid payload type - payloads can be 'binary', 'string', or 'json'"),this.messages.set(P.BadJson,"Bad JSON"),this.messages.set(P.WssRequired,"TLS is required, therefore a secure websocket connection is also required")}static getMessage(e){return Pu.getMessage(e)}getMessage(e){return this.messages.get(e)||e}}const Pu=new wo;class j extends Error{constructor(t,s,n){super(t);c(this,"name");c(this,"message");c(this,"code");c(this,"permissionContext");c(this,"chainedError");c(this,"api_error");this.name="NatsError",this.message=t,this.code=s,this.chainedError=n}static errorForCode(t,s){const n=wo.getMessage(t);return new j(n,t,s)}isAuthError(){return this.code===P.AuthenticationExpired||this.code===P.AuthorizationViolation}isAuthTimeout(){return this.code===P.AuthenticationTimeout}isPermissionError(){return this.code===P.PermissionsViolation}isProtocolError(){return this.code===P.ProtocolError}isJetStreamError(){return this.api_error!==void 0}jsError(){return this.api_error?this.api_error:null}}var oe;(function(r){r[r.Exact=0]="Exact",r[r.CanonicalMIME=1]="CanonicalMIME",r[r.IgnoreCase=2]="IgnoreCase"})(oe||(oe={}));var Se;(function(r){r.Timer="timer",r.Count="count",r.JitterTimer="jitterTimer",r.SentinelMsg="sentinelMsg"})(Se||(Se={}));var Rt;(function(r){r.STATS="io.nats.micro.v1.stats_response",r.INFO="io.nats.micro.v1.info_response",r.PING="io.nats.micro.v1.ping_response"})(Rt||(Rt={}));const gr="Nats-Service-Error",_r="Nats-Service-Error-Code";class yr extends Error{constructor(t,s){super(s);c(this,"code");this.code=t}static isServiceError(t){return yr.toServiceError(t)!==null}static toServiceError(t){var n,i;const s=((n=t==null?void 0:t.headers)==null?void 0:n.get(_r))||"";if(s!==""){const o=parseInt(s)||400,a=((i=t==null?void 0:t.headers)==null?void 0:i.get(gr))||"";return new yr(o,a.length?a:s)}return null}}function je(r=""){if(r=r||"_INBOX",typeof r!="string")throw new Error("prefix must be a string");return r.split(".").forEach(e=>{if(e==="*"||e===">")throw new Error(`inbox prefixes cannot have wildcards '${r}'`)}),`${r}.${Dt.next()}`}const ks="127.0.0.1";var Le;(function(r){r.PING="PING",r.STATS="STATS",r.INFO="INFO"})(Le||(Le={}));function Tr(r,...e){for(let t=0;t<e.length;t++){const s=e[t];Object.keys(s).forEach(function(n){r[n]=s[n]})}return r}function sr(r){const e="␍",t="␊";return ae.decode(r).replace(/\n/g,t).replace(/\r/g,e)}function ft(r,e=!0){const t=e?j.errorForCode(P.Timeout):null;let s,n;const i=new Promise((o,a)=>{s={cancel:()=>{n&&clearTimeout(n)}},n=setTimeout(()=>{a(t===null?j.errorForCode(P.Timeout):t)},r)});return Object.assign(i,s)}function qt(r=0){return new Promise(e=>{setTimeout(()=>{e()},r)})}function B(){let r={};const e=new Promise((t,s)=>{r={resolve:t,reject:s}});return Object.assign(e,r)}function xo(r){for(let e=r.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1));[r[e],r[t]]=[r[t],r[e]]}return r}function Ou(r){return r===0?0:Math.floor(r/2+Math.random()*r)}function vo(r=[0,250,250,500,500,3e3,5e3]){Array.isArray(r)||(r=[0,250,250,500,500,3e3,5e3]);const e=r.length-1;return{backoff(t){return Ou(t>e?r[e]:r[t])}}}class dt{constructor(){c(this,"buffers");c(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...e){let t=0;for(let i=0;i<e.length;i++)t+=e[i].length;const s=new Uint8Array(t);let n=0;for(let i=0;i<e.length;i++)s.set(e[i],n),n+=e[i].length;return s}static fromAscii(e){return e||(e=""),Ye.encode(e)}static toAscii(e){return ae.decode(e)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){const e=new Uint8Array(this.byteLength);let t=0;for(let s=0;s<this.buffers.length;s++)e.set(this.buffers[s],t),t+=this.buffers[s].length;this.buffers.length=0,this.buffers.push(e)}}shift(){if(this.buffers.length){const e=this.buffers.shift();if(e)return this.byteLength-=e.length,e}return new Uint8Array(0)}drain(e){if(this.buffers.length){this.pack();const t=this.buffers.pop();if(t){const s=this.byteLength;(e===void 0||e>s)&&(e=s);const n=t.subarray(0,e);return s>e&&this.buffers.push(t.subarray(e)),this.byteLength=s-e,n}}return new Uint8Array(0)}fill(e,...t){e&&(this.buffers.push(e),this.byteLength+=e.length);for(let s=0;s<t.length;s++)t[s]&&t[s].length&&(this.buffers.push(t[s]),this.byteLength+=t[s].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}let ce;function Cu(r){ce=r}function So(){return ce!==void 0&&ce.defaultPort!==void 0?ce.defaultPort:4222}function ds(){return ce!==void 0&&ce.urlParseFn?ce.urlParseFn:void 0}function ku(){if(!ce||typeof ce.factory!="function")throw new Error("transport fn is not set");return ce.factory()}function Eo(){return ce!==void 0&&ce.dnsResolveFn?ce.dnsResolveFn:void 0}const fr=`\r
  5. `,wr=dt.fromAscii(fr),Ru=new Uint8Array(wr)[0],ju=new Uint8Array(wr)[1];function Iu(r){for(let e=0;e<r.length;e++){const t=e+1;if(r.byteLength>t&&r[e]===Ru&&r[t]===ju)return t+1}return 0}function Tu(r){const e=Iu(r);if(e>0){const s=new Uint8Array(r).slice(0,e);return ae.decode(s)}return""}const Nu=4,Ao=48,Uu=65,Mu=97;function Fu(r,e,t,s){const n=new Uint8Array(16);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((o,a)=>{n[a]=o}),n[12]=r,n[13]=e,n[14]=t,n[15]=s,n}function Rs(r){return $u(r)!==void 0}function $u(r){for(let e=0;e<r.length;e++)switch(r[e]){case".":return Po(r);case":":return Lu(r)}}function Po(r){const e=new Uint8Array(4);for(let t=0;t<4;t++){if(r.length===0)return;if(t>0){if(r[0]!==".")return;r=r.substring(1)}const{n:s,c:n,ok:i}=Du(r);if(!i||s>255)return;r=r.substring(n),e[t]=s}return Fu(e[0],e[1],e[2],e[3])}function Lu(r){const e=new Uint8Array(16);let t=-1;if(r.length>=2&&r[0]===":"&&r[1]===":"&&(t=0,r=r.substring(2),r.length===0))return e;let s=0;for(;s<16;){const{n,c:i,ok:o}=qu(r);if(!o||n>65535)return;if(i<r.length&&r[i]==="."){if(t<0&&s!=16-4||s+4>16)return;const a=Po(r);if(a===void 0)return;e[s]=a[12],e[s+1]=a[13],e[s+2]=a[14],e[s+3]=a[15],r="",s+=Nu;break}if(e[s]=n>>8,e[s+1]=n,s+=2,r=r.substring(i),r.length===0)break;if(r[0]!==":"||r.length==1)return;if(r=r.substring(1),r[0]===":"){if(t>=0)return;if(t=s,r=r.substring(1),r.length===0)break}}if(r.length===0){if(s<16){if(t<0)return;const n=16-s;for(let i=s-1;i>=t;i--)e[i+n]=e[i];for(let i=t+n-1;i>=t;i--)e[i]=0}else if(t>=0)return;return e}}function Du(r){let e=0,t=0;for(e=0;e<r.length&&48<=r.charCodeAt(e)&&r.charCodeAt(e)<=57;e++)if(t=t*10+(r.charCodeAt(e)-Ao),t>=16777215)return{n:16777215,c:e,ok:!1};return e===0?{n:0,c:0,ok:!1}:{n:t,c:e,ok:!0}}function qu(r){let e=0,t=0;for(t=0;t<r.length;t++){if(48<=r.charCodeAt(t)&&r.charCodeAt(t)<=57)e*=16,e+=r.charCodeAt(t)-Ao;else if(97<=r.charCodeAt(t)&&r.charCodeAt(t)<=102)e*=16,e+=r.charCodeAt(t)-Mu+10;else if(65<=r.charCodeAt(t)&&r.charCodeAt(t)<=70)e*=16,e+=r.charCodeAt(t)-Uu+10;else break;if(e>=16777215)return{n:0,c:t,ok:!1}}return t===0?{n:0,c:t,ok:!1}:{n:e,c:t,ok:!0}}function Bu(r){return r.indexOf(".")!==-1?!0:r.indexOf("[")!==-1||r.indexOf("::")!==-1?!1:r.split(":").length<=2}function js(r){return!Bu(r)}function Hu(r){const e="::FFFF:",t=r.toUpperCase().indexOf(e);if(t!==-1&&r.indexOf(".")!==-1){let s=r.substring(t+e.length);return s=s.replace("[",""),s.replace("]","")}return r}function Ju(r){r=r.trim(),r.match(/^(.*:\/\/)(.*)/m)&&(r=r.replace(/^(.*:\/\/)(.*)/gm,"$2")),r=Hu(r),js(r)&&r.indexOf("[")===-1&&(r=`[${r}]`);const e=js(r)?r.match(/(]:)(\d+)/):r.match(/(:)(\d+)/),t=e&&e.length===3&&e[1]&&e[2]?parseInt(e[2]):4222,s=t===80?"https":"http",n=new URL(`${s}://${r}`);n.port=`${t}`;let i=n.hostname;return i.charAt(0)==="["&&(i=i.substring(1,i.length-1)),{listen:n.host,hostname:i,port:t}}class jt{constructor(e,t=!1){c(this,"src");c(this,"listen");c(this,"hostname");c(this,"port");c(this,"didConnect");c(this,"reconnects");c(this,"lastConnect");c(this,"gossiped");c(this,"tlsName");c(this,"resolves");this.src=e,this.tlsName="";const s=Ju(e);this.listen=s.listen,this.hostname=s.hostname,this.port=s.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=t}toString(){return this.listen}async resolve(e){if(!e.fn)return[this];const t=[];if(Rs(this.hostname))return[this];{const s=await e.fn(this.hostname);e.debug&&console.log(`resolve ${this.hostname} = ${s.join(",")}`);for(const n of s){const i=this.port===80?"https":"http",o=new URL(`${i}://${js(n)?"["+n+"]":n}`);o.port=`${this.port}`;const a=new jt(o.host,!1);a.tlsName=this.hostname,t.push(a)}}return e.randomize&&xo(t),this.resolves=t,t}}class zu{constructor(e=[],t={}){c(this,"firstSelect");c(this,"servers");c(this,"currentServer");c(this,"tlsName");c(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=t.randomize||!1;const s=ds();e&&(e.forEach(n=>{n=s?s(n):n,this.servers.push(new jt(n))}),this.randomize&&(this.servers=xo(this.servers))),this.servers.length===0&&this.addServer(`${ks}:${So()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const e=this.getCurrentServer();Rs(e.hostname)||(this.tlsName=e.hostname,this.servers.forEach(t=>{t.gossiped&&(t.tlsName=this.tlsName)}))}getCurrentServer(){return this.currentServer}addServer(e,t=!1){const s=ds();e=s?s(e):e;const n=new jt(e,t);Rs(n.hostname)&&(n.tlsName=this.tlsName),this.servers.push(n)}selectServer(){if(this.firstSelect)return this.firstSelect=!1,this.currentServer;const e=this.servers.shift();return e&&(this.servers.push(e),this.currentServer=e),e}removeCurrentServer(){this.removeServer(this.currentServer)}removeServer(e){if(e){const t=this.servers.indexOf(e);this.servers.splice(t,1)}}length(){return this.servers.length}next(){return this.servers.length?this.servers[0]:void 0}getServers(){return this.servers}update(e){const t=[];let s=[];const n=ds(),i=new Map;e.connect_urls&&e.connect_urls.length>0&&e.connect_urls.forEach(a=>{a=n?n(a):a;const h=new jt(a,!0);i.set(a,h)});const o=[];return this.servers.forEach((a,h)=>{const l=a.listen;a.gossiped&&this.currentServer.listen!==l&&i.get(l)===void 0&&o.push(h),i.delete(l)}),o.reverse(),o.forEach(a=>{const h=this.servers.splice(a,1);s=s.concat(h[0].listen)}),i.forEach((a,h)=>{this.servers.push(a),t.push(h)}),{added:t,deleted:s}}}class Y{constructor(){c(this,"inflight");c(this,"processed");c(this,"received");c(this,"noIterator");c(this,"iterClosed");c(this,"done");c(this,"signal");c(this,"yields");c(this,"filtered");c(this,"pendingFiltered");c(this,"ingestionFilterFn");c(this,"protocolFilterFn");c(this,"dispatchedFn");c(this,"ctx");c(this,"_data");c(this,"err");c(this,"time");c(this,"yielding");this.inflight=0,this.filtered=0,this.pendingFiltered=0,this.processed=0,this.received=0,this.noIterator=!1,this.done=!1,this.signal=B(),this.yields=[],this.iterClosed=B(),this.time=0,this.yielding=!1}[Symbol.asyncIterator](){return this.iterate()}push(e){if(this.done)return;if(typeof e=="function"){this.yields.push(e),this.signal.resolve();return}const{ingest:t,protocol:s}=this.ingestionFilterFn?this.ingestionFilterFn(e,this.ctx||this):{ingest:!0,protocol:!1};t&&(s&&(this.filtered++,this.pendingFiltered++),this.yields.push(e),this.signal.resolve())}async*iterate(){if(this.noIterator)throw new j("unsupported iterator",P.ApiError);if(this.yielding)throw new j("already yielding",P.ApiError);this.yielding=!0;try{for(;;){if(this.yields.length===0&&await this.signal,this.err)throw this.err;const e=this.yields;this.inflight=e.length,this.yields=[];for(let t=0;t<e.length;t++){if(typeof e[t]=="function"){const n=e[t];try{n()}catch(i){throw i}if(this.err)throw this.err;continue}if(this.protocolFilterFn?this.protocolFilterFn(e[t]):!0){this.processed++;const n=Date.now();yield e[t],this.time=Date.now()-n,this.dispatchedFn&&e[t]&&this.dispatchedFn(e[t])}else this.pendingFiltered--;this.inflight--}if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=B())}}finally{this.stop()}}stop(e){this.done||(this.err=e,this.done=!0,this.signal.resolve(),this.iterClosed.resolve())}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}function fi(r){let s=!0;const n=new Array(r.length);for(let i=0;i<r.length;i++){let o=r.charCodeAt(i);if(o===58||o<33||o>126)throw new j(`'${r[i]}' is not a valid character for a header key`,P.BadHeader);s&&97<=o&&o<=122?o-=32:!s&&65<=o&&o<=90&&(o+=32),n[i]=o,s=o==45}return String.fromCharCode(...n)}function Ie(r=0,e=""){if(r===0&&e!==""||r>0&&e==="")throw new Error("setting status requires both code and description");return new De(r,e)}const ps="NATS/1.0";class De{constructor(e=0,t=""){c(this,"_code");c(this,"headers");c(this,"_description");this._code=e,this._description=t,this.headers=new Map}[Symbol.iterator](){return this.headers.entries()}size(){return this.headers.size}equals(e){if(e&&this.headers.size===e.headers.size&&this._code===e._code){for(const[t,s]of this.headers){const n=e.values(t);if(s.length!==n.length)return!1;const i=[...s].sort(),o=[...n].sort();for(let a=0;a<i.length;a++)if(i[a]!==o[a])return!1}return!0}return!1}static decode(e){const t=new De,n=ae.decode(e).split(`\r
  6. `),i=n[0];if(i!==ps){let o=i.replace(ps,"").trim();if(o.length>0){t._code=parseInt(o,10),isNaN(t._code)&&(t._code=0);const a=t._code.toString();o=o.replace(a,""),t._description=o.trim()}}return n.length>=1&&n.slice(1).map(o=>{if(o){const a=o.indexOf(":");if(a>-1){const h=o.slice(0,a),l=o.slice(a+1).trim();t.append(h,l)}}}),t}toString(){if(this.headers.size===0&&this._code===0)return"";let e=ps;this._code>0&&this._description!==""&&(e+=` ${this._code} ${this._description}`);for(const[t,s]of this.headers)for(let n=0;n<s.length;n++)e=`${e}\r
  7. ${t}: ${s[n]}`;return`${e}\r
  8. \r
  9. `}encode(){return Ye.encode(this.toString())}static validHeaderValue(e){if(/[\r\n]/.test(e))throw new j("invalid header value - \\r and \\n are not allowed.",P.BadHeader);return e.trim()}keys(){const e=[];for(const t of this.headers.keys())e.push(t);return e}findKeys(e,t=oe.Exact){const s=this.keys();switch(t){case oe.Exact:return s.filter(n=>n===e);case oe.CanonicalMIME:return e=fi(e),s.filter(n=>n===e);default:{const n=e.toLowerCase();return s.filter(i=>n===i.toLowerCase())}}}get(e,t=oe.Exact){const s=this.findKeys(e,t);if(s.length){const n=this.headers.get(s[0]);if(n)return Array.isArray(n)?n[0]:n}return""}last(e,t=oe.Exact){const s=this.findKeys(e,t);if(s.length){const n=this.headers.get(s[0]);if(n)return Array.isArray(n)?n[n.length-1]:n}return""}has(e,t=oe.Exact){return this.findKeys(e,t).length>0}set(e,t,s=oe.Exact){this.delete(e,s),this.append(e,t,s)}append(e,t,s=oe.Exact){const n=fi(e);s===oe.CanonicalMIME&&(e=n);const i=this.findKeys(e,s);e=i.length>0?i[0]:e;const o=De.validHeaderValue(t);let a=this.headers.get(e);a||(a=[],this.headers.set(e,a)),a.push(o)}values(e,t=oe.Exact){const s=[];return this.findKeys(e,t).forEach(i=>{const o=this.headers.get(i);o&&s.push(...o)}),s}delete(e,t=oe.Exact){this.findKeys(e,t).forEach(n=>{this.headers.delete(n)})}get hasError(){return this._code>=300}get status(){return`${this._code} ${this._description}`.trim()}toRecord(){const e={};return this.keys().forEach(t=>{e[t]=this.values(t)}),e}get code(){return this._code}get description(){return this._description}static fromRecord(e){const t=new De;for(const s in e)t.headers.set(s,e[s]);return t}}function xr(){return{encode(r){return Ye.encode(r)},decode(r){return ae.decode(r)}}}function we(r){return{encode(e){try{return e===void 0&&(e=null),Ye.encode(JSON.stringify(e))}catch(t){throw j.errorForCode(P.BadJson,t)}},decode(e){try{return JSON.parse(ae.decode(e),r)}catch(t){throw j.errorForCode(P.BadJson,t)}}}}function Oo(r){var e;return r&&r.data.length===0&&((e=r.headers)==null?void 0:e.code)===503?j.errorForCode(P.NoResponders):null}class Ks{constructor(e,t,s){c(this,"_headers");c(this,"_msg");c(this,"_rdata");c(this,"_reply");c(this,"_subject");c(this,"publisher");this._msg=e,this._rdata=t,this.publisher=s}get subject(){return this._subject?this._subject:(this._subject=ae.decode(this._msg.subject),this._subject)}get reply(){return this._reply?this._reply:(this._reply=ae.decode(this._msg.reply),this._reply)}get sid(){return this._msg.sid}get headers(){if(this._msg.hdr>-1&&!this._headers){const e=this._rdata.subarray(0,this._msg.hdr);this._headers=De.decode(e)}return this._headers}get data(){return this._rdata?this._msg.hdr>-1?this._rdata.subarray(this._msg.hdr):this._rdata:new Uint8Array(0)}respond(e=se,t){return this.reply?(this.publisher.publish(this.reply,e,t),!0):!1}size(){var n;const e=this._msg.subject.length,t=((n=this._msg.reply)==null?void 0:n.length)||0,s=this._msg.size===-1?0:this._msg.size;return e+t+s}json(e){return we(e).decode(this.data)}string(){return ae.decode(this.data)}}c(Ks,"jc");class Gu{constructor(){c(this,"baseInbox");c(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(e){return this.baseInbox=`${je(e)}.`,this.baseInbox}add(e){isNaN(e.received)||(e.received=0),this.reqs.set(e.token,e)}get(e){return this.reqs.get(e)}cancel(e){this.reqs.delete(e.token)}getToken(e){const t=e.subject||"";return t.indexOf(this.baseInbox)===0?t.substring(this.baseInbox.length):null}all(){return Array.from(this.reqs.values())}handleError(e,t){if(t&&t.permissionContext){if(e)return this.all().forEach(n=>{n.resolver(t,{})}),!0;const s=t.permissionContext;if(s.operation==="publish"){const n=this.all().find(i=>i.requestSubject===s.subject);if(n)return n.resolver(t,{}),!0}}return!1}dispatcher(){return(e,t)=>{const s=this.getToken(t);if(s){const n=this.get(s);n&&(e===null&&t.headers&&(e=Oo(t)),n.resolver(e,t))}}}close(){const e=j.errorForCode(P.Timeout);this.reqs.forEach(t=>{t.resolver(e,{})})}}class Vu{constructor(e,t,s){c(this,"ph");c(this,"interval");c(this,"maxOut");c(this,"timer");c(this,"pendings");this.ph=e,this.interval=t,this.maxOut=s,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel(e){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this._reset(),e&&this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:at.PingTimer,data:`${this.pendings.length+1}`}),this.pendings.length===this.maxOut){this.cancel(!0);return}const e=B();this.ph.flush(e).then(()=>{this._reset()}).catch(()=>{this.cancel()}),this.pendings.push(e),this._schedule()},this.interval)}_reset(){this.pendings=this.pendings.filter(e=>(e.resolve(),!1))}}class Wu extends Error{constructor(e){super(e),this.name="AssertionError"}}function Yu(r,e="Assertion failed."){if(!r)throw new Wu(e)}const di=32*1024,ms=2**32-2;function nr(r,e,t=0){const s=e.byteLength-t;return r.byteLength>s&&(r=r.subarray(0,s)),e.set(r,t),r.byteLength}class bs{constructor(e){c(this,"_buf");c(this,"_off");if(this._off=0,e==null){this._buf=new Uint8Array(0);return}this._buf=new Uint8Array(e)}bytes(e={copy:!0}){return e.copy===!1?this._buf.subarray(this._off):this._buf.slice(this._off)}empty(){return this._buf.byteLength<=this._off}get length(){return this._buf.byteLength-this._off}get capacity(){return this._buf.buffer.byteLength}truncate(e){if(e===0){this.reset();return}if(e<0||e>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+e)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice(e){const t=this._buf.byteLength;return e<=this.capacity-t?(this._reslice(t+e),t):-1}_reslice(e){Yu(e<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,e)}readByte(){const e=new Uint8Array(1);return this.read(e)?e[0]:null}read(e){if(this.empty())return this.reset(),e.byteLength===0?0:null;const t=nr(this._buf.subarray(this._off),e);return this._off+=t,t}writeByte(e){return this.write(Uint8Array.of(e))}writeString(e){return this.write(Ye.encode(e))}write(e){const t=this._grow(e.byteLength);return nr(e,this._buf,t)}_grow(e){const t=this.length;t===0&&this._off!==0&&this.reset();const s=this._tryGrowByReslice(e);if(s>=0)return s;const n=this.capacity;if(e<=Math.floor(n/2)-t)nr(this._buf.subarray(this._off),this._buf);else{if(n+e>ms)throw new Error("The buffer cannot be grown beyond the maximum size.");{const i=new Uint8Array(Math.min(2*n+e,ms));nr(this._buf.subarray(this._off),i),this._buf=i}}return this._off=0,this._reslice(Math.min(t+e,ms)),t}grow(e){if(e<0)throw Error("Buffer._grow: negative count");const t=this._grow(e);this._reslice(t)}readFrom(e){let t=0;const s=new Uint8Array(di);for(;;){const n=this.capacity-this.length<di,i=n?s:new Uint8Array(this._buf.buffer,this.length),o=e.read(i);if(o===null)return t;n?this.write(i.subarray(0,o)):this._reslice(this.length+o),t+=o}}}var Z;(function(r){r[r.OK=0]="OK",r[r.ERR=1]="ERR",r[r.MSG=2]="MSG",r[r.INFO=3]="INFO",r[r.PING=4]="PING",r[r.PONG=5]="PONG"})(Z||(Z={}));function pi(){const r={};return r.sid=-1,r.hdr=-1,r.size=-1,r}const Ku=48;class mi{constructor(e){c(this,"dispatcher");c(this,"state");c(this,"as");c(this,"drop");c(this,"hdr");c(this,"ma");c(this,"argBuf");c(this,"msgBuf");this.dispatcher=e,this.state=O.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(e){let t;for(t=0;t<e.length;t++){const s=e[t];switch(this.state){case O.OP_START:switch(s){case C.M:case C.m:this.state=O.OP_M,this.hdr=-1,this.ma=pi();break;case C.H:case C.h:this.state=O.OP_H,this.hdr=0,this.ma=pi();break;case C.P:case C.p:this.state=O.OP_P;break;case C.PLUS:this.state=O.OP_PLUS;break;case C.MINUS:this.state=O.OP_MINUS;break;case C.I:case C.i:this.state=O.OP_I;break;default:throw this.fail(e.subarray(t))}break;case O.OP_H:switch(s){case C.M:case C.m:this.state=O.OP_M;break;default:throw this.fail(e.subarray(t))}break;case O.OP_M:switch(s){case C.S:case C.s:this.state=O.OP_MS;break;default:throw this.fail(e.subarray(t))}break;case O.OP_MS:switch(s){case C.G:case C.g:this.state=O.OP_MSG;break;default:throw this.fail(e.subarray(t))}break;case O.OP_MSG:switch(s){case C.SPACE:case C.TAB:this.state=O.OP_MSG_SPC;break;default:throw this.fail(e.subarray(t))}break;case O.OP_MSG_SPC:switch(s){case C.SPACE:case C.TAB:continue;default:this.state=O.MSG_ARG,this.as=t}break;case O.MSG_ARG:switch(s){case C.CR:this.drop=1;break;case C.NL:{const n=this.argBuf?this.argBuf.bytes():e.subarray(this.as,t-this.drop);this.processMsgArgs(n),this.drop=0,this.as=t+1,this.state=O.MSG_PAYLOAD,t=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(s)}break;case O.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){const n=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:Z.MSG,msg:this.ma,data:n}),this.argBuf=void 0,this.msgBuf=void 0,this.state=O.MSG_END}else{let n=this.ma.size-this.msgBuf.length;const i=e.length-t;i<n&&(n=i),n>0?(this.msgBuf.write(e.subarray(t,t+n)),t=t+n-1):this.msgBuf.writeByte(s)}else t-this.as>=this.ma.size&&(this.dispatcher.push({kind:Z.MSG,msg:this.ma,data:e.subarray(this.as,t)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=O.MSG_END);break;case O.MSG_END:switch(s){case C.NL:this.drop=0,this.as=t+1,this.state=O.OP_START;break;default:continue}break;case O.OP_PLUS:switch(s){case C.O:case C.o:this.state=O.OP_PLUS_O;break;default:throw this.fail(e.subarray(t))}break;case O.OP_PLUS_O:switch(s){case C.K:case C.k:this.state=O.OP_PLUS_OK;break;default:throw this.fail(e.subarray(t))}break;case O.OP_PLUS_OK:switch(s){case C.NL:this.dispatcher.push({kind:Z.OK}),this.drop=0,this.state=O.OP_START;break}break;case O.OP_MINUS:switch(s){case C.E:case C.e:this.state=O.OP_MINUS_E;break;default:throw this.fail(e.subarray(t))}break;case O.OP_MINUS_E:switch(s){case C.R:case C.r:this.state=O.OP_MINUS_ER;break;default:throw this.fail(e.subarray(t))}break;case O.OP_MINUS_ER:switch(s){case C.R:case C.r:this.state=O.OP_MINUS_ERR;break;default:throw this.fail(e.subarray(t))}break;case O.OP_MINUS_ERR:switch(s){case C.SPACE:case C.TAB:this.state=O.OP_MINUS_ERR_SPC;break;default:throw this.fail(e.subarray(t))}break;case O.OP_MINUS_ERR_SPC:switch(s){case C.SPACE:case C.TAB:continue;default:this.state=O.MINUS_ERR_ARG,this.as=t}break;case O.MINUS_ERR_ARG:switch(s){case C.CR:this.drop=1;break;case C.NL:{let n;this.argBuf?(n=this.argBuf.bytes(),this.argBuf=void 0):n=e.subarray(this.as,t-this.drop),this.dispatcher.push({kind:Z.ERR,data:n}),this.drop=0,this.as=t+1,this.state=O.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(s))}break;case O.OP_P:switch(s){case C.I:case C.i:this.state=O.OP_PI;break;case C.O:case C.o:this.state=O.OP_PO;break;default:throw this.fail(e.subarray(t))}break;case O.OP_PO:switch(s){case C.N:case C.n:this.state=O.OP_PON;break;default:throw this.fail(e.subarray(t))}break;case O.OP_PON:switch(s){case C.G:case C.g:this.state=O.OP_PONG;break;default:throw this.fail(e.subarray(t))}break;case O.OP_PONG:switch(s){case C.NL:this.dispatcher.push({kind:Z.PONG}),this.drop=0,this.state=O.OP_START;break}break;case O.OP_PI:switch(s){case C.N:case C.n:this.state=O.OP_PIN;break;default:throw this.fail(e.subarray(t))}break;case O.OP_PIN:switch(s){case C.G:case C.g:this.state=O.OP_PING;break;default:throw this.fail(e.subarray(t))}break;case O.OP_PING:switch(s){case C.NL:this.dispatcher.push({kind:Z.PING}),this.drop=0,this.state=O.OP_START;break}break;case O.OP_I:switch(s){case C.N:case C.n:this.state=O.OP_IN;break;default:throw this.fail(e.subarray(t))}break;case O.OP_IN:switch(s){case C.F:case C.f:this.state=O.OP_INF;break;default:throw this.fail(e.subarray(t))}break;case O.OP_INF:switch(s){case C.O:case C.o:this.state=O.OP_INFO;break;default:throw this.fail(e.subarray(t))}break;case O.OP_INFO:switch(s){case C.SPACE:case C.TAB:this.state=O.OP_INFO_SPC;break;default:throw this.fail(e.subarray(t))}break;case O.OP_INFO_SPC:switch(s){case C.SPACE:case C.TAB:continue;default:this.state=O.INFO_ARG,this.as=t}break;case O.INFO_ARG:switch(s){case C.CR:this.drop=1;break;case C.NL:{let n;this.argBuf?(n=this.argBuf.bytes(),this.argBuf=void 0):n=e.subarray(this.as,t-this.drop),this.dispatcher.push({kind:Z.INFO,data:n}),this.drop=0,this.as=t+1,this.state=O.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(s)}break;default:throw this.fail(e.subarray(t))}}(this.state===O.MSG_ARG||this.state===O.MINUS_ERR_ARG||this.state===O.INFO_ARG)&&!this.argBuf&&(this.argBuf=new bs(e.subarray(this.as,t-this.drop))),this.state===O.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new bs(e.subarray(this.as)))}cloneMsgArg(){const e=this.ma.subject.length,t=this.ma.reply?this.ma.reply.length:0,s=new Uint8Array(e+t);s.set(this.ma.subject),this.ma.reply&&s.set(this.ma.reply,e),this.argBuf=new bs(s),this.ma.subject=s.subarray(0,e),this.ma.reply&&(this.ma.reply=s.subarray(e))}processMsgArgs(e){if(this.hdr>=0)return this.processHeaderMsgArgs(e);const t=[];let s=-1;for(let n=0;n<e.length;n++)switch(e[n]){case C.SPACE:case C.TAB:case C.CR:case C.NL:s>=0&&(t.push(e.subarray(s,n)),s=-1);break;default:s<0&&(s=n)}switch(s>=0&&t.push(e.subarray(s)),t.length){case 3:this.ma.subject=t[0],this.ma.sid=this.protoParseInt(t[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(t[2]);break;case 4:this.ma.subject=t[0],this.ma.sid=this.protoParseInt(t[1]),this.ma.reply=t[2],this.ma.size=this.protoParseInt(t[3]);break;default:throw this.fail(e,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(e,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail(e,"processMsgArgs Bad or Missing Size Error")}fail(e,t=""){return t?t=`${t} [${this.state}]`:t=`parse error [${this.state}]`,new Error(`${t}: ${ae.decode(e)}`)}processHeaderMsgArgs(e){const t=[];let s=-1;for(let n=0;n<e.length;n++)switch(e[n]){case C.SPACE:case C.TAB:case C.CR:case C.NL:s>=0&&(t.push(e.subarray(s,n)),s=-1);break;default:s<0&&(s=n)}switch(s>=0&&t.push(e.subarray(s)),t.length){case 4:this.ma.subject=t[0],this.ma.sid=this.protoParseInt(t[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(t[2]),this.ma.size=this.protoParseInt(t[3]);break;case 5:this.ma.subject=t[0],this.ma.sid=this.protoParseInt(t[1]),this.ma.reply=t[2],this.ma.hdr=this.protoParseInt(t[3]),this.ma.size=this.protoParseInt(t[4]);break;default:throw this.fail(e,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(e,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt(e){if(e.length===0)return-1;let t=0;for(let s=0;s<e.length;s++){if(e[s]<48||e[s]>57)return-1;t=t*10+(e[s]-Ku)}return t}}var O;(function(r){r[r.OP_START=0]="OP_START",r[r.OP_PLUS=1]="OP_PLUS",r[r.OP_PLUS_O=2]="OP_PLUS_O",r[r.OP_PLUS_OK=3]="OP_PLUS_OK",r[r.OP_MINUS=4]="OP_MINUS",r[r.OP_MINUS_E=5]="OP_MINUS_E",r[r.OP_MINUS_ER=6]="OP_MINUS_ER",r[r.OP_MINUS_ERR=7]="OP_MINUS_ERR",r[r.OP_MINUS_ERR_SPC=8]="OP_MINUS_ERR_SPC",r[r.MINUS_ERR_ARG=9]="MINUS_ERR_ARG",r[r.OP_M=10]="OP_M",r[r.OP_MS=11]="OP_MS",r[r.OP_MSG=12]="OP_MSG",r[r.OP_MSG_SPC=13]="OP_MSG_SPC",r[r.MSG_ARG=14]="MSG_ARG",r[r.MSG_PAYLOAD=15]="MSG_PAYLOAD",r[r.MSG_END=16]="MSG_END",r[r.OP_H=17]="OP_H",r[r.OP_P=18]="OP_P",r[r.OP_PI=19]="OP_PI",r[r.OP_PIN=20]="OP_PIN",r[r.OP_PING=21]="OP_PING",r[r.OP_PO=22]="OP_PO",r[r.OP_PON=23]="OP_PON",r[r.OP_PONG=24]="OP_PONG",r[r.OP_I=25]="OP_I",r[r.OP_IN=26]="OP_IN",r[r.OP_INF=27]="OP_INF",r[r.OP_INFO=28]="OP_INFO",r[r.OP_INFO_SPC=29]="OP_INFO_SPC",r[r.INFO_ARG=30]="INFO_ARG"})(O||(O={}));var C;(function(r){r[r.CR="\r".charCodeAt(0)]="CR",r[r.E="E".charCodeAt(0)]="E",r[r.e="e".charCodeAt(0)]="e",r[r.F="F".charCodeAt(0)]="F",r[r.f="f".charCodeAt(0)]="f",r[r.G="G".charCodeAt(0)]="G",r[r.g="g".charCodeAt(0)]="g",r[r.H="H".charCodeAt(0)]="H",r[r.h="h".charCodeAt(0)]="h",r[r.I="I".charCodeAt(0)]="I",r[r.i="i".charCodeAt(0)]="i",r[r.K="K".charCodeAt(0)]="K",r[r.k="k".charCodeAt(0)]="k",r[r.M="M".charCodeAt(0)]="M",r[r.m="m".charCodeAt(0)]="m",r[r.MINUS="-".charCodeAt(0)]="MINUS",r[r.N="N".charCodeAt(0)]="N",r[r.n="n".charCodeAt(0)]="n",r[r.NL=`
  10. `.charCodeAt(0)]="NL",r[r.O="O".charCodeAt(0)]="O",r[r.o="o".charCodeAt(0)]="o",r[r.P="P".charCodeAt(0)]="P",r[r.p="p".charCodeAt(0)]="p",r[r.PLUS="+".charCodeAt(0)]="PLUS",r[r.R="R".charCodeAt(0)]="R",r[r.r="r".charCodeAt(0)]="r",r[r.S="S".charCodeAt(0)]="S",r[r.s="s".charCodeAt(0)]="s",r[r.SPACE=" ".charCodeAt(0)]="SPACE",r[r.TAB=" ".charCodeAt(0)]="TAB"})(C||(C={}));function Ve(r=""){const e=r.match(/(\d+).(\d+).(\d+)/);if(e)return{major:parseInt(e[1]),minor:parseInt(e[2]),micro:parseInt(e[3])};throw new Error(`'${r}' is not a semver value`)}function Is(r,e){return r.major<e.major?-1:r.major>e.major?1:r.minor<e.minor?-1:r.minor>e.minor?1:r.micro<e.micro?-1:r.micro>e.micro?1:0}var L;(function(r){r.JS_KV="js_kv",r.JS_OBJECTSTORE="js_objectstore",r.JS_PULL_MAX_BYTES="js_pull_max_bytes",r.JS_NEW_CONSUMER_CREATE_API="js_new_consumer_create",r.JS_ALLOW_DIRECT="js_allow_direct",r.JS_MULTIPLE_CONSUMER_FILTER="js_multiple_consumer_filter",r.JS_SIMPLIFICATION="js_simplification",r.JS_STREAM_CONSUMER_METADATA="js_stream_consumer_metadata",r.JS_CONSUMER_FILTER_SUBJECTS="js_consumer_filter_subjects",r.JS_STREAM_FIRST_SEQ="js_stream_first_seq",r.JS_STREAM_SUBJECT_TRANSFORM="js_stream_subject_transform",r.JS_STREAM_SOURCE_SUBJECT_TRANSFORM="js_stream_source_subject_transform",r.JS_STREAM_COMPRESSION="js_stream_compression",r.JS_DEFAULT_CONSUMER_LIMITS="js_default_consumer_limits"})(L||(L={}));class Xu{constructor(e){c(this,"server");c(this,"features");c(this,"disabled");this.features=new Map,this.disabled=[],this.update(e)}resetDisabled(){this.disabled.length=0,this.update(this.server)}disable(e){this.disabled.push(e),this.update(this.server)}isDisabled(e){return this.disabled.indexOf(e)!==-1}update(e){typeof e=="string"&&(e=Ve(e)),this.server=e,this.set(L.JS_KV,"2.6.2"),this.set(L.JS_OBJECTSTORE,"2.6.3"),this.set(L.JS_PULL_MAX_BYTES,"2.8.3"),this.set(L.JS_NEW_CONSUMER_CREATE_API,"2.9.0"),this.set(L.JS_ALLOW_DIRECT,"2.9.0"),this.set(L.JS_MULTIPLE_CONSUMER_FILTER,"2.10.0"),this.set(L.JS_SIMPLIFICATION,"2.9.4"),this.set(L.JS_STREAM_CONSUMER_METADATA,"2.10.0"),this.set(L.JS_CONSUMER_FILTER_SUBJECTS,"2.10.0"),this.set(L.JS_STREAM_FIRST_SEQ,"2.10.0"),this.set(L.JS_STREAM_SUBJECT_TRANSFORM,"2.10.0"),this.set(L.JS_STREAM_SOURCE_SUBJECT_TRANSFORM,"2.10.0"),this.set(L.JS_STREAM_COMPRESSION,"2.10.0"),this.set(L.JS_DEFAULT_CONSUMER_LIMITS,"2.10.0"),this.disabled.forEach(t=>{this.features.delete(t)})}set(e,t){this.features.set(e,{min:t,ok:Is(this.server,Ve(t))>=0})}get(e){return this.features.get(e)||{min:"unknown",ok:!1}}supports(e){var t;return((t=this.get(e))==null?void 0:t.ok)||!1}require(e){return typeof e=="string"&&(e=Ve(e)),Is(this.server,e)>=0}}(function(r){var e=function(u,d){this.hi=u|0,this.lo=d|0},t=function(u){var d,f=new Float64Array(16);if(u)for(d=0;d<u.length;d++)f[d]=u[d];return f},s=function(){throw new Error("no PRNG")},n=new Uint8Array(16),i=new Uint8Array(32);i[0]=9;var o=t(),a=t([1]),h=t([56129,1]),l=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),m=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),b=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),w=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function A(u,d){return u<<d|u>>>32-d}function k(u,d){var f=u[d+3]&255;return f=f<<8|u[d+2]&255,f=f<<8|u[d+1]&255,f<<8|u[d+0]&255}function R(u,d){var f=u[d]<<24|u[d+1]<<16|u[d+2]<<8|u[d+3],p=u[d+4]<<24|u[d+5]<<16|u[d+6]<<8|u[d+7];return new e(f,p)}function M(u,d,f){var p;for(p=0;p<4;p++)u[d+p]=f&255,f>>>=8}function N(u,d,f){u[d]=f.hi>>24&255,u[d+1]=f.hi>>16&255,u[d+2]=f.hi>>8&255,u[d+3]=f.hi&255,u[d+4]=f.lo>>24&255,u[d+5]=f.lo>>16&255,u[d+6]=f.lo>>8&255,u[d+7]=f.lo&255}function U(u,d,f,p,_){var y,S=0;for(y=0;y<_;y++)S|=u[d+y]^f[p+y];return(1&S-1>>>8)-1}function J(u,d,f,p){return U(u,d,f,p,16)}function T(u,d,f,p){return U(u,d,f,p,32)}function Te(u,d,f,p,_){var y=new Uint32Array(16),S=new Uint32Array(16),E=new Uint32Array(16),x=new Uint32Array(4),v,I,$;for(v=0;v<4;v++)S[5*v]=k(p,4*v),S[1+v]=k(f,4*v),S[6+v]=k(d,4*v),S[11+v]=k(f,16+4*v);for(v=0;v<16;v++)E[v]=S[v];for(v=0;v<20;v++){for(I=0;I<4;I++){for($=0;$<4;$++)x[$]=S[(5*I+4*$)%16];for(x[1]^=A(x[0]+x[3]|0,7),x[2]^=A(x[1]+x[0]|0,9),x[3]^=A(x[2]+x[1]|0,13),x[0]^=A(x[3]+x[2]|0,18),$=0;$<4;$++)y[4*I+(I+$)%4]=x[$]}for($=0;$<16;$++)S[$]=y[$]}if(_){for(v=0;v<16;v++)S[v]=S[v]+E[v]|0;for(v=0;v<4;v++)S[5*v]=S[5*v]-k(p,4*v)|0,S[6+v]=S[6+v]-k(d,4*v)|0;for(v=0;v<4;v++)M(u,4*v,S[5*v]),M(u,16+4*v,S[6+v])}else for(v=0;v<16;v++)M(u,4*v,S[v]+E[v]|0)}function Ke(u,d,f,p){return Te(u,d,f,p,!1),0}function de(u,d,f,p){return Te(u,d,f,p,!0),0}var ee=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Ee(u,d,f,p,_,y,S){var E=new Uint8Array(16),x=new Uint8Array(64),v,I;if(!_)return 0;for(I=0;I<16;I++)E[I]=0;for(I=0;I<8;I++)E[I]=y[I];for(;_>=64;){for(Ke(x,E,S,ee),I=0;I<64;I++)u[d+I]=(f?f[p+I]:0)^x[I];for(v=1,I=8;I<16;I++)v=v+(E[I]&255)|0,E[I]=v&255,v>>>=8;_-=64,d+=64,f&&(p+=64)}if(_>0)for(Ke(x,E,S,ee),I=0;I<_;I++)u[d+I]=(f?f[p+I]:0)^x[I];return 0}function Ne(u,d,f,p,_){return Ee(u,d,null,0,f,p,_)}function z(u,d,f,p,_){var y=new Uint8Array(32);return de(y,p,_,ee),Ne(u,d,f,p.subarray(16),y)}function ue(u,d,f,p,_,y,S){var E=new Uint8Array(32);return de(E,y,S,ee),Ee(u,d,f,p,_,y.subarray(16),E)}function X(u,d){var f,p=0;for(f=0;f<17;f++)p=p+(u[f]+d[f]|0)|0,u[f]=p&255,p>>>=8}var Ur=new Uint32Array([5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252]);function He(u,d,f,p,_,y){var S,E,x,v,I=new Uint32Array(17),$=new Uint32Array(17),D=new Uint32Array(17),be=new Uint32Array(17),tt=new Uint32Array(17);for(x=0;x<17;x++)$[x]=D[x]=0;for(x=0;x<16;x++)$[x]=y[x];for($[3]&=15,$[4]&=252,$[7]&=15,$[8]&=252,$[11]&=15,$[12]&=252,$[15]&=15;_>0;){for(x=0;x<17;x++)be[x]=0;for(x=0;x<16&&x<_;++x)be[x]=f[p+x];for(be[x]=1,p+=x,_-=x,X(D,be),E=0;E<17;E++)for(I[E]=0,x=0;x<17;x++)I[E]=I[E]+D[x]*(x<=E?$[E-x]:320*$[E+17-x]|0)|0|0;for(E=0;E<17;E++)D[E]=I[E];for(v=0,x=0;x<16;x++)v=v+D[x]|0,D[x]=v&255,v>>>=8;for(v=v+D[16]|0,D[16]=v&3,v=5*(v>>>2)|0,x=0;x<16;x++)v=v+D[x]|0,D[x]=v&255,v>>>=8;v=v+D[16]|0,D[16]=v}for(x=0;x<17;x++)tt[x]=D[x];for(X(D,Ur),S=-(D[16]>>>7)|0,x=0;x<17;x++)D[x]^=S&(tt[x]^D[x]);for(x=0;x<16;x++)be[x]=y[x+16];for(be[16]=0,X(D,be),x=0;x<16;x++)u[d+x]=D[x];return 0}function on(u,d,f,p,_,y){var S=new Uint8Array(16);return He(S,0,f,p,_,y),J(u,d,S,0)}function Mr(u,d,f,p,_){var y;if(f<32)return-1;for(ue(u,0,d,0,f,p,_),He(u,16,u,32,f-32,u),y=0;y<16;y++)u[y]=0;return 0}function Fr(u,d,f,p,_){var y,S=new Uint8Array(32);if(f<32||(z(S,0,32,p,_),on(d,16,d,32,f-32,S)!==0))return-1;for(ue(u,0,d,0,f,p,_),y=0;y<32;y++)u[y]=0;return 0}function Ae(u,d){var f;for(f=0;f<16;f++)u[f]=d[f]|0}function _t(u){var d,f;for(f=0;f<16;f++)u[f]+=65536,d=Math.floor(u[f]/65536),u[(f+1)*(f<15?1:0)]+=d-1+37*(d-1)*(f===15?1:0),u[f]-=d*65536}function Xe(u,d,f){for(var p,_=~(f-1),y=0;y<16;y++)p=_&(u[y]^d[y]),u[y]^=p,d[y]^=p}function Ze(u,d){var f,p,_,y=t(),S=t();for(f=0;f<16;f++)S[f]=d[f];for(_t(S),_t(S),_t(S),p=0;p<2;p++){for(y[0]=S[0]-65517,f=1;f<15;f++)y[f]=S[f]-65535-(y[f-1]>>16&1),y[f-1]&=65535;y[15]=S[15]-32767-(y[14]>>16&1),_=y[15]>>16&1,y[14]&=65535,Xe(S,y,1-_)}for(f=0;f<16;f++)u[2*f]=S[f]&255,u[2*f+1]=S[f]>>8}function an(u,d){var f=new Uint8Array(32),p=new Uint8Array(32);return Ze(f,u),Ze(p,d),T(f,0,p,0)}function cn(u){var d=new Uint8Array(32);return Ze(d,u),d[0]&1}function $r(u,d){var f;for(f=0;f<16;f++)u[f]=d[2*f]+(d[2*f+1]<<8);u[15]&=32767}function pe(u,d,f){var p;for(p=0;p<16;p++)u[p]=d[p]+f[p]|0}function me(u,d,f){var p;for(p=0;p<16;p++)u[p]=d[p]-f[p]|0}function F(u,d,f){var p,_,y=new Float64Array(31);for(p=0;p<31;p++)y[p]=0;for(p=0;p<16;p++)for(_=0;_<16;_++)y[p+_]+=d[p]*f[_];for(p=0;p<15;p++)y[p]+=38*y[p+16];for(p=0;p<16;p++)u[p]=y[p];_t(u),_t(u)}function he(u,d){F(u,d,d)}function un(u,d){var f=t(),p;for(p=0;p<16;p++)f[p]=d[p];for(p=253;p>=0;p--)he(f,f),p!==2&&p!==4&&F(f,f,d);for(p=0;p<16;p++)u[p]=f[p]}function hn(u,d){var f=t(),p;for(p=0;p<16;p++)f[p]=d[p];for(p=250;p>=0;p--)he(f,f),p!==1&&F(f,f,d);for(p=0;p<16;p++)u[p]=f[p]}function Jt(u,d,f){var p=new Uint8Array(32),_=new Float64Array(80),y,S,E=t(),x=t(),v=t(),I=t(),$=t(),D=t();for(S=0;S<31;S++)p[S]=d[S];for(p[31]=d[31]&127|64,p[0]&=248,$r(_,f),S=0;S<16;S++)x[S]=_[S],I[S]=E[S]=v[S]=0;for(E[0]=I[0]=1,S=254;S>=0;--S)y=p[S>>>3]>>>(S&7)&1,Xe(E,x,y),Xe(v,I,y),pe($,E,v),me(E,E,v),pe(v,x,I),me(x,x,I),he(I,$),he(D,E),F(E,v,E),F(v,x,$),pe($,E,v),me(E,E,v),he(x,E),me(v,I,D),F(E,v,h),pe(E,E,I),F(v,v,E),F(E,I,D),F(I,x,_),he(x,$),Xe(E,x,y),Xe(v,I,y);for(S=0;S<16;S++)_[S+16]=E[S],_[S+32]=v[S],_[S+48]=x[S],_[S+64]=I[S];var be=_.subarray(32),tt=_.subarray(16);return un(be,be),F(tt,tt,be),Ze(u,tt),0}function zt(u,d){return Jt(u,d,i)}function ln(u,d){return s(d,32),zt(u,d)}function Gt(u,d,f){var p=new Uint8Array(32);return Jt(p,f,d),de(u,n,p,ee)}var fn=Mr,Jo=Fr;function zo(u,d,f,p,_,y){var S=new Uint8Array(32);return Gt(S,_,y),fn(u,d,f,p,S)}function Go(u,d,f,p,_,y){var S=new Uint8Array(32);return Gt(S,_,y),Jo(u,d,f,p,S)}function yt(){var u=0,d=0,f=0,p=0,_=65535,y,S,E;for(E=0;E<arguments.length;E++)y=arguments[E].lo,S=arguments[E].hi,u+=y&_,d+=y>>>16,f+=S&_,p+=S>>>16;return d+=u>>>16,f+=d>>>16,p+=f>>>16,new e(f&_|p<<16,u&_|d<<16)}function dn(u,d){return new e(u.hi>>>d,u.lo>>>d|u.hi<<32-d)}function Vt(){var u=0,d=0,f;for(f=0;f<arguments.length;f++)u^=arguments[f].lo,d^=arguments[f].hi;return new e(d,u)}function xe(u,d){var f,p,_=32-d;return d<32?(f=u.hi>>>d|u.lo<<_,p=u.lo>>>d|u.hi<<_):d<64&&(f=u.lo>>>d|u.hi<<_,p=u.hi>>>d|u.lo<<_),new e(f,p)}function Vo(u,d,f){var p=u.hi&d.hi^~u.hi&f.hi,_=u.lo&d.lo^~u.lo&f.lo;return new e(p,_)}function Wo(u,d,f){var p=u.hi&d.hi^u.hi&f.hi^d.hi&f.hi,_=u.lo&d.lo^u.lo&f.lo^d.lo&f.lo;return new e(p,_)}function Yo(u){return Vt(xe(u,28),xe(u,34),xe(u,39))}function Ko(u){return Vt(xe(u,14),xe(u,18),xe(u,41))}function Xo(u){return Vt(xe(u,1),xe(u,8),dn(u,7))}function Zo(u){return Vt(xe(u,19),xe(u,61),dn(u,6))}var Qo=[new e(1116352408,3609767458),new e(1899447441,602891725),new e(3049323471,3964484399),new e(3921009573,2173295548),new e(961987163,4081628472),new e(1508970993,3053834265),new e(2453635748,2937671579),new e(2870763221,3664609560),new e(3624381080,2734883394),new e(310598401,1164996542),new e(607225278,1323610764),new e(1426881987,3590304994),new e(1925078388,4068182383),new e(2162078206,991336113),new e(2614888103,633803317),new e(3248222580,3479774868),new e(3835390401,2666613458),new e(4022224774,944711139),new e(264347078,2341262773),new e(604807628,2007800933),new e(770255983,1495990901),new e(1249150122,1856431235),new e(1555081692,3175218132),new e(1996064986,2198950837),new e(2554220882,3999719339),new e(2821834349,766784016),new e(2952996808,2566594879),new e(3210313671,3203337956),new e(3336571891,1034457026),new e(3584528711,2466948901),new e(113926993,3758326383),new e(338241895,168717936),new e(666307205,1188179964),new e(773529912,1546045734),new e(1294757372,1522805485),new e(1396182291,2643833823),new e(1695183700,2343527390),new e(1986661051,1014477480),new e(2177026350,1206759142),new e(2456956037,344077627),new e(2730485921,1290863460),new e(2820302411,3158454273),new e(3259730800,3505952657),new e(3345764771,106217008),new e(3516065817,3606008344),new e(3600352804,1432725776),new e(4094571909,1467031594),new e(275423344,851169720),new e(430227734,3100823752),new e(506948616,1363258195),new e(659060556,3750685593),new e(883997877,3785050280),new e(958139571,3318307427),new e(1322822218,3812723403),new e(1537002063,2003034995),new e(1747873779,3602036899),new e(1955562222,1575990012),new e(2024104815,1125592928),new e(2227730452,2716904306),new e(2361852424,442776044),new e(2428436474,593698344),new e(2756734187,3733110249),new e(3204031479,2999351573),new e(3329325298,3815920427),new e(3391569614,3928383900),new e(3515267271,566280711),new e(3940187606,3454069534),new e(4118630271,4000239992),new e(116418474,1914138554),new e(174292421,2731055270),new e(289380356,3203993006),new e(460393269,320620315),new e(685471733,587496836),new e(852142971,1086792851),new e(1017036298,365543100),new e(1126000580,2618297676),new e(1288033470,3409855158),new e(1501505948,4234509866),new e(1607167915,987167468),new e(1816402316,1246189591)];function pn(u,d,f){var p=[],_=[],y=[],S=[],E,x,v;for(x=0;x<8;x++)p[x]=y[x]=R(u,8*x);for(var I=0;f>=128;){for(x=0;x<16;x++)S[x]=R(d,8*x+I);for(x=0;x<80;x++){for(v=0;v<8;v++)_[v]=y[v];for(E=yt(y[7],Ko(y[4]),Vo(y[4],y[5],y[6]),Qo[x],S[x%16]),_[7]=yt(E,Yo(y[0]),Wo(y[0],y[1],y[2])),_[3]=yt(_[3],E),v=0;v<8;v++)y[(v+1)%8]=_[v];if(x%16===15)for(v=0;v<16;v++)S[v]=yt(S[v],S[(v+9)%16],Xo(S[(v+1)%16]),Zo(S[(v+14)%16]))}for(x=0;x<8;x++)y[x]=yt(y[x],p[x]),p[x]=y[x];I+=128,f-=128}for(x=0;x<8;x++)N(u,8*x,p[x]);return f}var ea=new Uint8Array([106,9,230,103,243,188,201,8,187,103,174,133,132,202,167,59,60,110,243,114,254,148,248,43,165,79,245,58,95,29,54,241,81,14,82,127,173,230,130,209,155,5,104,140,43,62,108,31,31,131,217,171,251,65,189,107,91,224,205,25,19,126,33,121]);function Je(u,d,f){var p=new Uint8Array(64),_=new Uint8Array(256),y,S=f;for(y=0;y<64;y++)p[y]=ea[y];for(pn(p,d,f),f%=128,y=0;y<256;y++)_[y]=0;for(y=0;y<f;y++)_[y]=d[S-f+y];for(_[f]=128,f=256-128*(f<112?1:0),_[f-9]=0,N(_,f-8,new e(S/536870912|0,S<<3)),pn(p,_,f),y=0;y<64;y++)u[y]=p[y];return 0}function Wt(u,d){var f=t(),p=t(),_=t(),y=t(),S=t(),E=t(),x=t(),v=t(),I=t();me(f,u[1],u[0]),me(I,d[1],d[0]),F(f,f,I),pe(p,u[0],u[1]),pe(I,d[0],d[1]),F(p,p,I),F(_,u[3],d[3]),F(_,_,m),F(y,u[2],d[2]),pe(y,y,y),me(S,p,f),me(E,y,_),pe(x,y,_),pe(v,p,f),F(u[0],S,E),F(u[1],v,x),F(u[2],x,E),F(u[3],S,v)}function mn(u,d,f){var p;for(p=0;p<4;p++)Xe(u[p],d[p],f)}function Lr(u,d){var f=t(),p=t(),_=t();un(_,d[2]),F(f,d[0],_),F(p,d[1],_),Ze(u,p),u[31]^=cn(f)<<7}function Dr(u,d,f){var p,_;for(Ae(u[0],o),Ae(u[1],a),Ae(u[2],a),Ae(u[3],o),_=255;_>=0;--_)p=f[_/8|0]>>(_&7)&1,mn(u,d,p),Wt(d,u),Wt(u,u),mn(u,d,p)}function Yt(u,d){var f=[t(),t(),t(),t()];Ae(f[0],g),Ae(f[1],b),Ae(f[2],a),F(f[3],g,b),Dr(u,f,d)}function qr(u,d,f){var p=new Uint8Array(64),_=[t(),t(),t(),t()],y;for(f||s(d,32),Je(p,d,32),p[0]&=248,p[31]&=127,p[31]|=64,Yt(_,p),Lr(u,_),y=0;y<32;y++)d[y+32]=u[y];return 0}var Kt=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Br(u,d){var f,p,_,y;for(p=63;p>=32;--p){for(f=0,_=p-32,y=p-12;_<y;++_)d[_]+=f-16*d[p]*Kt[_-(p-32)],f=Math.floor((d[_]+128)/256),d[_]-=f*256;d[_]+=f,d[p]=0}for(f=0,_=0;_<32;_++)d[_]+=f-(d[31]>>4)*Kt[_],f=d[_]>>8,d[_]&=255;for(_=0;_<32;_++)d[_]-=f*Kt[_];for(p=0;p<32;p++)d[p+1]+=d[p]>>8,u[p]=d[p]&255}function Hr(u){var d=new Float64Array(64),f;for(f=0;f<64;f++)d[f]=u[f];for(f=0;f<64;f++)u[f]=0;Br(u,d)}function bn(u,d,f,p){var _=new Uint8Array(64),y=new Uint8Array(64),S=new Uint8Array(64),E,x,v=new Float64Array(64),I=[t(),t(),t(),t()];Je(_,p,32),_[0]&=248,_[31]&=127,_[31]|=64;var $=f+64;for(E=0;E<f;E++)u[64+E]=d[E];for(E=0;E<32;E++)u[32+E]=_[32+E];for(Je(S,u.subarray(32),f+32),Hr(S),Yt(I,S),Lr(u,I),E=32;E<64;E++)u[E]=p[E];for(Je(y,u,f+64),Hr(y),E=0;E<64;E++)v[E]=0;for(E=0;E<32;E++)v[E]=S[E];for(E=0;E<32;E++)for(x=0;x<32;x++)v[E+x]+=y[E]*_[x];return Br(u.subarray(32),v),$}function ta(u,d){var f=t(),p=t(),_=t(),y=t(),S=t(),E=t(),x=t();return Ae(u[2],a),$r(u[1],d),he(_,u[1]),F(y,_,l),me(_,_,u[2]),pe(y,u[2],y),he(S,y),he(E,S),F(x,E,S),F(f,x,_),F(f,f,y),hn(f,f),F(f,f,_),F(f,f,y),F(f,f,y),F(u[0],f,y),he(p,u[0]),F(p,p,y),an(p,_)&&F(u[0],u[0],w),he(p,u[0]),F(p,p,y),an(p,_)?-1:(cn(u[0])===d[31]>>7&&me(u[0],o,u[0]),F(u[3],u[0],u[1]),0)}function Jr(u,d,f,p){var _,y=new Uint8Array(32),S=new Uint8Array(64),E=[t(),t(),t(),t()],x=[t(),t(),t(),t()];if(f<64||ta(x,p))return-1;for(_=0;_<f;_++)u[_]=d[_];for(_=0;_<32;_++)u[_+32]=p[_];if(Je(S,u,f),Hr(S),Dr(E,x,S),Yt(x,d.subarray(32)),Wt(E,x),Lr(y,E),f-=64,T(d,0,y,0)){for(_=0;_<f;_++)u[_]=0;return-1}for(_=0;_<f;_++)u[_]=d[_+64];return f}var zr=32,Xt=24,wt=32,Qe=16,xt=32,Zt=32,vt=32,St=32,Gr=32,gn=Xt,ra=wt,sa=Qe,Pe=64,ze=32,et=64,Vr=32,Wr=64;r.lowlevel={crypto_core_hsalsa20:de,crypto_stream_xor:ue,crypto_stream:z,crypto_stream_salsa20_xor:Ee,crypto_stream_salsa20:Ne,crypto_onetimeauth:He,crypto_onetimeauth_verify:on,crypto_verify_16:J,crypto_verify_32:T,crypto_secretbox:Mr,crypto_secretbox_open:Fr,crypto_scalarmult:Jt,crypto_scalarmult_base:zt,crypto_box_beforenm:Gt,crypto_box_afternm:fn,crypto_box:zo,crypto_box_open:Go,crypto_box_keypair:ln,crypto_hash:Je,crypto_sign:bn,crypto_sign_keypair:qr,crypto_sign_open:Jr,crypto_secretbox_KEYBYTES:zr,crypto_secretbox_NONCEBYTES:Xt,crypto_secretbox_ZEROBYTES:wt,crypto_secretbox_BOXZEROBYTES:Qe,crypto_scalarmult_BYTES:xt,crypto_scalarmult_SCALARBYTES:Zt,crypto_box_PUBLICKEYBYTES:vt,crypto_box_SECRETKEYBYTES:St,crypto_box_BEFORENMBYTES:Gr,crypto_box_NONCEBYTES:gn,crypto_box_ZEROBYTES:ra,crypto_box_BOXZEROBYTES:sa,crypto_sign_BYTES:Pe,crypto_sign_PUBLICKEYBYTES:ze,crypto_sign_SECRETKEYBYTES:et,crypto_sign_SEEDBYTES:Vr,crypto_hash_BYTES:Wr,gf:t,D:l,L:Kt,pack25519:Ze,unpack25519:$r,M:F,A:pe,S:he,Z:me,pow2523:hn,add:Wt,set25519:Ae,modL:Br,scalarmult:Dr,scalarbase:Yt};function _n(u,d){if(u.length!==zr)throw new Error("bad key size");if(d.length!==Xt)throw new Error("bad nonce size")}function na(u,d){if(u.length!==vt)throw new Error("bad public key size");if(d.length!==St)throw new Error("bad secret key size")}function ne(){for(var u=0;u<arguments.length;u++)if(!(arguments[u]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function yn(u){for(var d=0;d<u.length;d++)u[d]=0}r.randomBytes=function(u){var d=new Uint8Array(u);return s(d,u),d},r.secretbox=function(u,d,f){ne(u,d,f),_n(f,d);for(var p=new Uint8Array(wt+u.length),_=new Uint8Array(p.length),y=0;y<u.length;y++)p[y+wt]=u[y];return Mr(_,p,p.length,d,f),_.subarray(Qe)},r.secretbox.open=function(u,d,f){ne(u,d,f),_n(f,d);for(var p=new Uint8Array(Qe+u.length),_=new Uint8Array(p.length),y=0;y<u.length;y++)p[y+Qe]=u[y];return p.length<32||Fr(_,p,p.length,d,f)!==0?null:_.subarray(wt)},r.secretbox.keyLength=zr,r.secretbox.nonceLength=Xt,r.secretbox.overheadLength=Qe,r.scalarMult=function(u,d){if(ne(u,d),u.length!==Zt)throw new Error("bad n size");if(d.length!==xt)throw new Error("bad p size");var f=new Uint8Array(xt);return Jt(f,u,d),f},r.scalarMult.base=function(u){if(ne(u),u.length!==Zt)throw new Error("bad n size");var d=new Uint8Array(xt);return zt(d,u),d},r.scalarMult.scalarLength=Zt,r.scalarMult.groupElementLength=xt,r.box=function(u,d,f,p){var _=r.box.before(f,p);return r.secretbox(u,d,_)},r.box.before=function(u,d){ne(u,d),na(u,d);var f=new Uint8Array(Gr);return Gt(f,u,d),f},r.box.after=r.secretbox,r.box.open=function(u,d,f,p){var _=r.box.before(f,p);return r.secretbox.open(u,d,_)},r.box.open.after=r.secretbox.open,r.box.keyPair=function(){var u=new Uint8Array(vt),d=new Uint8Array(St);return ln(u,d),{publicKey:u,secretKey:d}},r.box.keyPair.fromSecretKey=function(u){if(ne(u),u.length!==St)throw new Error("bad secret key size");var d=new Uint8Array(vt);return zt(d,u),{publicKey:d,secretKey:new Uint8Array(u)}},r.box.publicKeyLength=vt,r.box.secretKeyLength=St,r.box.sharedKeyLength=Gr,r.box.nonceLength=gn,r.box.overheadLength=r.secretbox.overheadLength,r.sign=function(u,d){if(ne(u,d),d.length!==et)throw new Error("bad secret key size");var f=new Uint8Array(Pe+u.length);return bn(f,u,u.length,d),f},r.sign.open=function(u,d){if(ne(u,d),d.length!==ze)throw new Error("bad public key size");var f=new Uint8Array(u.length),p=Jr(f,u,u.length,d);if(p<0)return null;for(var _=new Uint8Array(p),y=0;y<_.length;y++)_[y]=f[y];return _},r.sign.detached=function(u,d){for(var f=r.sign(u,d),p=new Uint8Array(Pe),_=0;_<p.length;_++)p[_]=f[_];return p},r.sign.detached.verify=function(u,d,f){if(ne(u,d,f),d.length!==Pe)throw new Error("bad signature size");if(f.length!==ze)throw new Error("bad public key size");var p=new Uint8Array(Pe+u.length),_=new Uint8Array(Pe+u.length),y;for(y=0;y<Pe;y++)p[y]=d[y];for(y=0;y<u.length;y++)p[y+Pe]=u[y];return Jr(_,p,p.length,f)>=0},r.sign.keyPair=function(){var u=new Uint8Array(ze),d=new Uint8Array(et);return qr(u,d),{publicKey:u,secretKey:d}},r.sign.keyPair.fromSecretKey=function(u){if(ne(u),u.length!==et)throw new Error("bad secret key size");for(var d=new Uint8Array(ze),f=0;f<d.length;f++)d[f]=u[32+f];return{publicKey:d,secretKey:new Uint8Array(u)}},r.sign.keyPair.fromSeed=function(u){if(ne(u),u.length!==Vr)throw new Error("bad seed size");for(var d=new Uint8Array(ze),f=new Uint8Array(et),p=0;p<32;p++)f[p]=u[p];return qr(d,f,!0),{publicKey:d,secretKey:f}},r.sign.publicKeyLength=ze,r.sign.secretKeyLength=et,r.sign.seedLength=Vr,r.sign.signatureLength=Pe,r.hash=function(u){ne(u);var d=new Uint8Array(Wr);return Je(d,u,u.length),d},r.hash.hashLength=Wr,r.verify=function(u,d){return ne(u,d),u.length===0||d.length===0||u.length!==d.length?!1:U(u,0,d,0,u.length)===0},r.setPRNG=function(u){s=u},function(){var u=typeof globalThis<"u"?globalThis.crypto||globalThis.msCrypto:null;if(u&&u.getRandomValues){var d=65536;r.setPRNG(function(f,p){var _,y=new Uint8Array(p);for(_=0;_<p;_+=d)u.getRandomValues(y.subarray(_,_+Math.min(p-_,d)));for(_=0;_<p;_++)f[_]=y[_];yn(y)})}else typeof require<"u"&&(u=require("crypto"),u&&u.randomBytes&&r.setPRNG(function(f,p){var _,y=u.randomBytes(p);for(_=0;_<p;_++)f[_]=y[_];yn(y)}))}()})(typeof module<"u"&&module.exports?module.exports:globalThis.nacl=globalThis.nacl||{});const ir=typeof module<"u"&&module.exports?module.exports:globalThis.nacl;ir.sign.keyPair.fromSeed,ir.sign.detached,ir.sign.detached.verify,ir.randomBytes;var bi;(function(r){r.InvalidPrefixByte="nkeys: invalid prefix byte",r.InvalidKey="nkeys: invalid key",r.InvalidPublicKey="nkeys: invalid public key",r.InvalidSeedLen="nkeys: invalid seed length",r.InvalidSeed="nkeys: invalid seed",r.InvalidEncoding="nkeys: invalid encoded key",r.InvalidSignature="nkeys: signature verification failed",r.CannotSign="nkeys: cannot sign, no private key available",r.PublicKeyOnly="nkeys: no seed or private key available",r.InvalidChecksum="nkeys: invalid checksum",r.SerializationError="nkeys: serialization error",r.ApiError="nkeys: api error",r.ClearedPair="nkeys: pair is cleared"})(bi||(bi={}));var gi;(function(r){r[r.Seed=144]="Seed",r[r.Private=120]="Private",r[r.Operator=112]="Operator",r[r.Server=104]="Server",r[r.Cluster=16]="Cluster",r[r.Account=0]="Account",r[r.User=160]="User"})(gi||(gi={}));function Zu(r){return e=>{let t={};return r.forEach(s=>{const n=s(e)||{};t=Object.assign(t,n)}),t}}function Qu(){return()=>{}}function eh(r,e){return()=>{const t=typeof r=="function"?r():r,s=typeof e=="function"?e():e;return{user:t,pass:s}}}function th(r){return()=>({auth_token:typeof r=="function"?r():r})}const Co=2*60*1e3,rh=2,ko=2*1e3;function sh(){return{maxPingOut:2,maxReconnectAttempts:10,noRandomize:!1,pedantic:!1,pingInterval:Co,reconnect:!0,reconnectJitter:100,reconnectJitterTLS:1e3,reconnectTimeWait:ko,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1}}function nh(r){const e=[];return typeof r.authenticator=="function"&&e.push(r.authenticator),Array.isArray(r.authenticator)&&e.push(...r.authenticator),r.token&&e.push(th(r.token)),r.user&&e.push(eh(r.user,r.pass)),e.length===0?Qu():Zu(e)}function ih(r){const e=`${ks}:${So()}`;if(r=r||{servers:[e]},r.servers=r.servers||[],typeof r.servers=="string"&&(r.servers=[r.servers]),r.servers.length>0&&r.port)throw new j("port and servers options are mutually exclusive",P.InvalidOption);r.servers.length===0&&r.port&&(r.servers=[`${ks}:${r.port}`]),r.servers&&r.servers.length===0&&(r.servers=[e]);const t=Tr(sh(),r);if(t.authenticator=nh(t),["reconnectDelayHandler","authenticator"].forEach(s=>{if(t[s]&&typeof t[s]!="function")throw new j(`${s} option should be a function`,P.NotFunction)}),t.reconnectDelayHandler||(t.reconnectDelayHandler=()=>{let s=t.tls?t.reconnectJitterTLS:t.reconnectJitter;return s&&(s++,s=Math.floor(Math.random()*s)),t.reconnectTimeWait+s}),t.inboxPrefix)try{je(t.inboxPrefix)}catch(s){throw new j(s.message,P.ApiError)}if(t.resolve&&typeof Eo()!="function")throw new j("'resolve' is not supported on this client",P.InvalidOption);return t}function oh(r,e){const{proto:t,tls_required:s,tls_available:n}=r;if((t===void 0||t<1)&&e.noEcho)throw new j("noEcho",P.ServerOptionNotAvailable);const i=s||n||!1;if(e.tls&&!i)throw new j("tls",P.ServerOptionNotAvailable)}const ah=1024*32,ch=/^INFO\s+([^\r\n]+)\r\n/i,uh=kt(`PONG\r
  11. `),_i=kt(`PING\r
  12. `);class hh{constructor(e,t,s){c(this,"echo");c(this,"no_responders");c(this,"protocol");c(this,"verbose");c(this,"pedantic");c(this,"jwt");c(this,"nkey");c(this,"sig");c(this,"user");c(this,"pass");c(this,"auth_token");c(this,"tls_required");c(this,"name");c(this,"lang");c(this,"version");c(this,"headers");this.protocol=1,this.version=e.version,this.lang=e.lang,this.echo=t.noEcho?!1:void 0,this.verbose=t.verbose,this.pedantic=t.pedantic,this.tls_required=t.tls?!0:void 0,this.name=t.name;const n=(t&&typeof t.authenticator=="function"?t.authenticator(s):{})||{};Tr(this,n)}}class Ro extends Y{constructor(t,s,n={}){var o;super();c(this,"sid");c(this,"queue");c(this,"draining");c(this,"max");c(this,"subject");c(this,"drained");c(this,"protocol");c(this,"timer");c(this,"info");c(this,"cleanupFn");c(this,"closed");c(this,"requestSubject");Tr(this,n),this.protocol=t,this.subject=s,this.draining=!1,this.noIterator=typeof n.callback=="function",this.closed=B();const i=!((o=t.options)!=null&&o.noAsyncTraces);n.timeout&&(this.timer=ft(n.timeout,i),this.timer.then(()=>{this.timer=void 0}).catch(a=>{this.stop(a),this.noIterator&&this.callback(a,{})})),this.noIterator||this.iterClosed.then(()=>{this.closed.resolve(),this.unsubscribe()})}setPrePostHandlers(t){if(this.noIterator){const s=this.callback,n=t.ingestionFilterFn?t.ingestionFilterFn:()=>({ingest:!0,protocol:!1}),i=t.protocolFilterFn?t.protocolFilterFn:()=>!0,o=t.dispatchedFn?t.dispatchedFn:()=>{};this.callback=(a,h)=>{const{ingest:l}=n(h);l&&i(h)&&(s(a,h),o(h))}}else this.protocolFilterFn=t.protocolFilterFn,this.dispatchedFn=t.dispatchedFn}callback(t,s){this.cancelTimeout(),t?this.stop(t):this.push(s)}close(){if(!this.isClosed()){this.cancelTimeout();const t=()=>{if(this.stop(),this.cleanupFn)try{this.cleanupFn(this,this.info)}catch{}this.closed.resolve()};this.noIterator?t():this.push(t)}}unsubscribe(t){this.protocol.unsubscribe(this,t)}cancelTimeout(){this.timer&&(this.timer.cancel(),this.timer=void 0)}drain(){return this.protocol.isClosed()?Promise.reject(j.errorForCode(P.ConnectionClosed)):this.isClosed()?Promise.reject(j.errorForCode(P.SubClosed)):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush(B()).then(()=>{this.protocol.subscriptions.cancel(this)}).catch(()=>{this.protocol.subscriptions.cancel(this)})),this.drained)}isDraining(){return this.draining}isClosed(){return this.done}getSubject(){return this.subject}getMax(){return this.max}getID(){return this.sid}}class lh{constructor(){c(this,"mux");c(this,"subs");c(this,"sidCounter");this.sidCounter=0,this.mux=null,this.subs=new Map}size(){return this.subs.size}add(e){return this.sidCounter++,e.sid=this.sidCounter,this.subs.set(e.sid,e),e}setMux(e){return this.mux=e,e}getMux(){return this.mux}get(e){return this.subs.get(e)}resub(e){return this.sidCounter++,this.subs.delete(e.sid),e.sid=this.sidCounter,this.subs.set(e.sid,e),e}all(){return Array.from(this.subs.values())}cancel(e){e&&(e.close(),this.subs.delete(e.sid))}handleError(e){if(e&&e.permissionContext){const t=e.permissionContext,s=this.all();let n;if(t.operation==="subscription"&&(n=s.find(i=>i.subject===t.subject)),t.operation==="publish"&&(n=s.find(i=>i.requestSubject===t.subject)),n)return n.callback(e,{}),n.close(),this.subs.delete(n.sid),n!==this.mux}return!1}close(){this.subs.forEach(e=>{e.close()})}}class vr{constructor(e,t){c(this,"connected");c(this,"connectedOnce");c(this,"infoReceived");c(this,"info");c(this,"muxSubscriptions");c(this,"options");c(this,"outbound");c(this,"pongs");c(this,"subscriptions");c(this,"transport");c(this,"noMorePublishing");c(this,"connectError");c(this,"publisher");c(this,"_closed");c(this,"closed");c(this,"listeners");c(this,"heartbeats");c(this,"parser");c(this,"outMsgs");c(this,"inMsgs");c(this,"outBytes");c(this,"inBytes");c(this,"pendingLimit");c(this,"lastError");c(this,"abortReconnect");c(this,"servers");c(this,"server");c(this,"features");c(this,"connectPromise");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=ah,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=e,this.publisher=t,this.subscriptions=new lh,this.muxSubscriptions=new Gu,this.outbound=new dt,this.pongs=[],this.pendingLimit=e.pendingLimit||this.pendingLimit,this.features=new Xu({major:0,minor:0,micro:0}),this.connectPromise=null;const s=typeof e.servers=="string"?[e.servers]:e.servers;this.servers=new zu(s,{randomize:!e.noRandomize}),this.closed=B(),this.parser=new mi(this),this.heartbeats=new Vu(this,this.options.pingInterval||Co,this.options.maxPingOut||rh)}resetOutbound(){this.outbound.reset();const e=this.pongs;this.pongs=[];const t=j.errorForCode(P.Disconnect);t.stack="",e.forEach(s=>{s.reject(t)}),this.parser=new mi(this),this.infoReceived=!1}dispatchStatus(e){this.listeners.forEach(t=>{t.push(e)})}status(){const e=new Y;return this.listeners.push(e),e}prepare(){this.transport&&this.transport.discard(),this.info=void 0,this.resetOutbound();const e=B();return e.catch(()=>{}),this.pongs.unshift(e),this.connectError=t=>{e.reject(t)},this.transport=ku(),this.transport.closed().then(async t=>{if(this.connected=!1,!this.isClosed()){await this.disconnected(this.transport.closeError||this.lastError);return}}),e}disconnect(){this.dispatchStatus({type:at.StaleConnection,data:""}),this.transport.disconnect()}reconnect(){return this.connected&&(this.dispatchStatus({type:at.ClientInitiatedReconnect,data:""}),this.transport.disconnect()),Promise.resolve()}async disconnected(e){this.dispatchStatus({type:Ce.Disconnect,data:this.servers.getCurrentServer().toString()}),this.options.reconnect?await this.dialLoop().then(()=>{var t;this.dispatchStatus({type:Ce.Reconnect,data:this.servers.getCurrentServer().toString()}),((t=this.lastError)==null?void 0:t.code)===P.AuthenticationExpired&&(this.lastError=void 0)}).catch(t=>{this._close(t)}):await this._close(e)}async dial(e){const t=this.prepare();let s;try{s=ft(this.options.timeout||2e4);const n=this.transport.connect(e,this.options);await Promise.race([n,s]),(async()=>{try{for await(const i of this.transport)this.parser.parse(i)}catch(i){console.log("reader closed",i)}})().then()}catch(n){t.reject(n)}try{await Promise.race([s,t]),s&&s.cancel(),this.connected=!0,this.connectError=void 0,this.sendSubscriptions(),this.connectedOnce=!0,this.server.didConnect=!0,this.server.reconnects=0,this.flushPending(),this.heartbeats.start()}catch(n){throw s&&s.cancel(),await this.transport.close(n),n}}async _doDial(e){const t=await e.resolve({fn:Eo(),debug:this.options.debug,randomize:!this.options.noRandomize});let s=null;for(const n of t)try{s=null,this.dispatchStatus({type:at.Reconnecting,data:n.toString()}),await this.dial(n);return}catch(i){s=i}throw s}dialLoop(){return this.connectPromise===null&&(this.connectPromise=this.dodialLoop(),this.connectPromise.then(()=>{}).catch(()=>{}).finally(()=>{this.connectPromise=null})),this.connectPromise}async dodialLoop(){let e;for(;;){this._closed&&this.servers.clear();const t=this.options.reconnectDelayHandler?this.options.reconnectDelayHandler():ko;let s=t;const n=this.selectServer();if(!n||this.abortReconnect)throw e||(this.lastError?this.lastError:j.errorForCode(P.ConnectionRefused));const i=Date.now();if(n.lastConnect===0||n.lastConnect+t<=i){n.lastConnect=Date.now();try{await this._doDial(n);break}catch(o){if(e=o,!this.connectedOnce){if(this.options.waitOnFirstConnect)continue;this.servers.removeCurrentServer()}n.reconnects++;const a=this.options.maxReconnectAttempts||0;a!==-1&&n.reconnects>=a&&this.servers.removeCurrentServer()}}else s=Math.min(s,n.lastConnect+t-i),await qt(s)}}static async connect(e,t){const s=new vr(e,t);return await s.dialLoop(),s}static toError(e){const t=e?e.toLowerCase():"";if(t.indexOf("permissions violation")!==-1){const s=new j(e,P.PermissionsViolation),n=e.match(/(Publish|Subscription) to "(\S+)"/);return n&&(s.permissionContext={operation:n[1].toLowerCase(),subject:n[2]}),s}else return t.indexOf("authorization violation")!==-1?new j(e,P.AuthorizationViolation):t.indexOf("user authentication expired")!==-1?new j(e,P.AuthenticationExpired):t.indexOf("authentication timeout")!==-1?new j(e,P.AuthenticationTimeout):new j(e,P.ProtocolError)}processMsg(e,t){if(this.inMsgs++,this.inBytes+=t.length,!this.subscriptions.sidCounter)return;const s=this.subscriptions.get(e.sid);s&&(s.received+=1,s.callback&&s.callback(null,new Ks(e,t,this)),s.max!==void 0&&s.received>=s.max&&s.unsubscribe())}processError(e){const t=ai(e),s=vr.toError(t),n={type:Ce.Error,data:s.code};if(s.isPermissionError()){let i=!1;if(s.permissionContext){n.permissionContext=s.permissionContext;const o=this.subscriptions.getMux();i=(o==null?void 0:o.subject)===s.permissionContext.subject}this.subscriptions.handleError(s),this.muxSubscriptions.handleError(i,s),i&&this.subscriptions.setMux(null)}this.dispatchStatus(n),this.handleError(s)}handleError(e){e.isAuthError()?this.handleAuthError(e):e.isProtocolError()?this.lastError=e:e.isAuthTimeout()&&(this.lastError=e),e.isPermissionError()||(this.lastError=e)}handleAuthError(e){this.lastError&&e.code===this.lastError.code&&this.options.ignoreAuthErrorAbort===!1&&(this.abortReconnect=!0),this.connectError?this.connectError(e):this.disconnect()}processPing(){this.transport.send(uh)}processPong(){const e=this.pongs.shift();e&&e.resolve()}processInfo(e){const t=JSON.parse(ai(e));this.info=t;const s=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(t);if(!this.infoReceived){this.features.update(Ve(t.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:i,lang:o}=this.transport;try{const a=new hh({version:i,lang:o},this.options,t.nonce);t.headers&&(a.headers=!0,a.no_responders=!0);const h=JSON.stringify(a);this.transport.send(kt(`CONNECT ${h}${fr}`)),this.transport.send(_i)}catch(a){this._close(a)}}s&&this.dispatchStatus({type:Ce.Update,data:s}),(t.ldm!==void 0?t.ldm:!1)&&this.dispatchStatus({type:Ce.LDM,data:this.servers.getCurrentServer().toString()})}push(e){switch(e.kind){case Z.MSG:{const{msg:t,data:s}=e;this.processMsg(t,s);break}case Z.OK:break;case Z.ERR:this.processError(e.data);break;case Z.PING:this.processPing();break;case Z.PONG:this.processPong();break;case Z.INFO:this.processInfo(e.data);break}}sendCommand(e,...t){const s=this.outbound.length();let n;typeof e=="string"?n=kt(e):n=e,this.outbound.fill(n,...t),s===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(e,t=se,s){let n;if(t instanceof Uint8Array)n=t;else if(typeof t=="string")n=Ye.encode(t);else throw j.errorForCode(P.BadPayload);let i=n.length;s=s||{},s.reply=s.reply||"";let o=se,a=0;if(s.headers){if(this.info&&!this.info.headers)throw new j("headers",P.ServerOptionNotAvailable);o=s.headers.encode(),a=o.length,i=n.length+a}if(this.info&&i>this.info.max_payload)throw j.errorForCode(P.MaxPayloadExceeded);this.outBytes+=i,this.outMsgs++;let h;s.headers?(s.reply?h=`HPUB ${e} ${s.reply} ${a} ${i}\r
  13. `:h=`HPUB ${e} ${a} ${i}\r
  14. `,this.sendCommand(h,o,n,wr)):(s.reply?h=`PUB ${e} ${s.reply} ${i}\r
  15. `:h=`PUB ${e} ${i}\r
  16. `,this.sendCommand(h,n,wr))}request(e){return this.initMux(),this.muxSubscriptions.add(e),e}subscribe(e){return this.subscriptions.add(e),this._subunsub(e),e}_sub(e){e.queue?this.sendCommand(`SUB ${e.subject} ${e.queue} ${e.sid}\r
  17. `):this.sendCommand(`SUB ${e.subject} ${e.sid}\r
  18. `)}_subunsub(e){return this._sub(e),e.max&&this.unsubscribe(e,e.max),e}unsubscribe(e,t){this.unsub(e,t),(e.max===void 0||e.received>=e.max)&&this.subscriptions.cancel(e)}unsub(e,t){!e||this.isClosed()||(t?this.sendCommand(`UNSUB ${e.sid} ${t}\r
  19. `):this.sendCommand(`UNSUB ${e.sid}\r
  20. `),e.max=t)}resub(e,t){!e||this.isClosed()||(e.subject=t,this.subscriptions.resub(e),this._sub(e))}flush(e){return e||(e=B()),this.pongs.push(e),this.outbound.fill(_i),this.flushPending(),e}sendSubscriptions(){const e=[];this.subscriptions.all().forEach(t=>{const s=t;s.queue?e.push(`SUB ${s.subject} ${s.queue} ${s.sid}${fr}`):e.push(`SUB ${s.subject} ${s.sid}${fr}`)}),e.length&&this.transport.send(kt(e.join("")))}async _close(e){this._closed||(this.heartbeats.cancel(),this.connectError&&(this.connectError(e),this.connectError=void 0),this.muxSubscriptions.close(),this.subscriptions.close(),this.listeners.forEach(t=>{t.stop()}),this._closed=!0,await this.transport.close(e),await this.closed.resolve(e))}close(){return this._close()}isClosed(){return this._closed}drain(){const e=this.subscriptions.all(),t=[];return e.forEach(s=>{t.push(s.drain())}),Promise.all(t).then(async()=>(this.noMorePublishing=!0,await this.flush(),this.close())).catch(()=>{})}flushPending(){if(!(!this.infoReceived||!this.connected)&&this.outbound.size()){const e=this.outbound.drain();this.transport.send(e)}}initMux(){if(!this.subscriptions.getMux()){const t=this.muxSubscriptions.init(this.options.inboxPrefix),s=new Ro(this,`${t}*`);s.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(s),this.subscribe(s)}}selectServer(){const e=this.servers.selectServer();if(e!==void 0)return this.server=e,this.server}getServer(){return this.server}}class jo{constructor(e,t,s=!0){c(this,"token");c(this,"received");c(this,"ctx");c(this,"requestSubject");c(this,"mux");this.mux=e,this.requestSubject=t,this.received=0,this.token=Dt.next(),s&&(this.ctx=new Error)}}class fh extends jo{constructor(t,s,n={maxWait:1e3}){super(t,s);c(this,"callback");c(this,"done");c(this,"timer");c(this,"max");c(this,"opts");if(this.opts=n,typeof this.opts.callback!="function")throw new Error("callback is required");this.callback=this.opts.callback,this.max=typeof n.maxMessages=="number"&&n.maxMessages>0?n.maxMessages:-1,this.done=B(),this.done.then(()=>{this.callback(null,null)}),this.timer=setTimeout(()=>{this.cancel()},n.maxWait)}cancel(t){t&&this.callback(t,null),clearTimeout(this.timer),this.mux.cancel(this),this.done.resolve()}resolver(t,s){t?(this.ctx&&(t.stack+=`
  21. ${this.ctx.stack}`),this.cancel(t)):(this.callback(null,s),this.opts.strategy===Se.Count&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy===Se.JitterTimer&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.jitter||300)),this.opts.strategy===Se.SentinelMsg&&s&&s.data.length===0&&this.cancel())}}class Io extends jo{constructor(t,s,n={timeout:1e3},i=!0){super(t,s,i);c(this,"deferred");c(this,"timer");this.deferred=B(),this.timer=ft(n.timeout,i)}resolver(t,s){this.timer&&this.timer.cancel(),t?(this.ctx&&(t.stack+=`
  22. ${this.ctx.stack}`),this.deferred.reject(t)):this.deferred.resolve(s),this.cancel()}cancel(t){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(t||j.errorForCode(P.Cancelled))}}function ct(r){return Xs("durable",r)}function te(r){return Xs("stream",r)}function Xs(r,e=""){if(e==="")throw Error(`${r} name required`);return[".","*",">","/","\\"," "," ",`
  23. `,"\r"].forEach(s=>{if(e.indexOf(s)!==-1){switch(s){case`
  24. `:s="\\n";break;case"\r":s="\\r";break;case" ":s="\\t";break}throw Error(`invalid ${r} name - ${r} name cannot contain '${s}'`)}}),""}function Ot(r,e=""){if(e==="")throw Error(`${r} name required`);const t=dh(e);if(t.length)throw new Error(`invalid ${r} name - ${r} name ${t}`)}function dh(r=""){if(r==="")throw Error("name required");const e=/^[-\w]+$/g;if(r.match(e)===null){for(const s of r.split(""))if(s.match(e)===null)return`cannot contain '${s}'`}return""}function q(r){return r*1e6}function Zs(r){return Math.floor(r/1e6)}function Ts(r){if(r.data.length>0)return!1;const e=r.headers;return e?e.code>=100&&e.code<200:!1}function Ns(r){var e;return Ts(r)&&((e=r.headers)==null?void 0:e.description)==="Idle Heartbeat"}function ph(r,e,t){const s=Ie(r,e),n={hdr:1,sid:0,size:0},i=new Ks(n,se,{});return i._headers=s,i._subject=t,i}function ut(r){if(r.data.length!==0)return null;const e=r.headers;return e?To(e.code,e.description):null}var fe;(function(r){r.MaxBatchExceeded="exceeded maxrequestbatch of",r.MaxExpiresExceeded="exceeded maxrequestexpires of",r.MaxBytesExceeded="exceeded maxrequestmaxbytes of",r.MaxMessageSizeExceeded="message size exceeds maxbytes",r.PushConsumer="consumer is push based",r.MaxWaitingExceeded="exceeded maxwaiting",r.IdleHeartbeatMissed="idle heartbeats missed",r.ConsumerDeleted="consumer deleted"})(fe||(fe={}));function mh(r){return r.code!==P.JetStream409?!1:[fe.MaxBatchExceeded,fe.MaxExpiresExceeded,fe.MaxBytesExceeded,fe.MaxMessageSizeExceeded,fe.PushConsumer,fe.IdleHeartbeatMissed,fe.ConsumerDeleted].find(t=>r.message.indexOf(t)!==-1)!==void 0}function To(r,e=""){if(r<300)return null;switch(e=e.toLowerCase(),r){case 404:return new j(e,P.JetStream404NoMessages);case 408:return new j(e,P.JetStream408RequestTimeout);case 409:{const t=e.startsWith(fe.IdleHeartbeatMissed)?P.JetStreamIdleHeartBeat:P.JetStream409;return new j(e,t)}case 503:return j.errorForCode(P.JetStreamNotEnabled,new Error(e));default:return e===""&&(e=P.Unknown),new j(e,`${r}`)}}const bh="$JS.API";function gh(r){return r=r||{},r.domain&&(r.apiPrefix=`$JS.${r.domain}.API`,delete r.domain),Tr({apiPrefix:bh,timeout:5e3},r)}class Bt{constructor(e,t){c(this,"nc");c(this,"opts");c(this,"prefix");c(this,"timeout");c(this,"jc");this.nc=e,this.opts=gh(t),this._parseOpts(),this.prefix=this.opts.apiPrefix,this.timeout=this.opts.timeout,this.jc=we()}getOptions(){return Object.assign({},this.opts)}_parseOpts(){let e=this.opts.apiPrefix;if(!e||e.length===0)throw new Error("invalid empty prefix");e[e.length-1]==="."&&(e=e.substr(0,e.length-1)),this.opts.apiPrefix=e}async _request(e,t=null,s){s=s||{},s.timeout=this.timeout;let n=se;t&&(n=this.jc.encode(t));const i=await this.nc.request(e,n,s);return this.parseJsResponse(i)}async findStream(e){const t={subject:e},n=await this._request(`${this.prefix}.STREAM.NAMES`,t);if(!n.streams||n.streams.length!==1)throw new Error("no stream matches subject");return n.streams[0]}getConnection(){return this.nc}parseJsResponse(e){const t=this.jc.decode(e.data),s=t;if(s.error){const n=To(s.error.code,s.error.description);if(n!==null)throw n.api_error=s.error,n}return t}}class _h{static encode(e){if(typeof e=="string")return btoa(e);const t=Array.from(e);return btoa(String.fromCharCode(...t))}static decode(e,t=!1){const s=atob(e);return t?Uint8Array.from(s,n=>n.charCodeAt(0)):s}}class It{static encode(e){return It.toB64URLEncoding(_h.encode(e))}static decode(e,t=!1){return It.decode(It.fromB64URLEncoding(e),t)}static toB64URLEncoding(e){return e.replace(/\+/g,"-").replace(/\//g,"_")}static fromB64URLEncoding(e){return e.replace(/_/g,"/").replace(/-/g,"+")}}var Us;(function(r){r.Limits="limits",r.Interest="interest",r.Workqueue="workqueue"})(Us||(Us={}));var Ut;(function(r){r.Old="old",r.New="new"})(Ut||(Ut={}));var Ms;(function(r){r.File="file",r.Memory="memory"})(Ms||(Ms={}));var H;(function(r){r.All="all",r.Last="last",r.New="new",r.StartSequence="by_start_sequence",r.StartTime="by_start_time",r.LastPerSubject="last_per_subject"})(H||(H={}));var V;(function(r){r.None="none",r.All="all",r.Explicit="explicit",r.NotSet=""})(V||(V={}));var pt;(function(r){r.Instant="instant",r.Original="original"})(pt||(pt={}));var Be;(function(r){r.None="none",r.S2="s2"})(Be||(Be={}));var Sr;(function(r){r.CreateOrUpdate="",r.Update="update",r.Create="create"})(Sr||(Sr={}));function yh(r,e={}){return Object.assign({name:r,deliver_policy:H.All,ack_policy:V.Explicit,ack_wait:q(30*1e3),replay_policy:pt.Instant},e)}var yi;(function(r){r.API="api_audit",r.StreamAction="stream_action",r.ConsumerAction="consumer_action",r.SnapshotCreate="snapshot_create",r.SnapshotComplete="snapshot_complete",r.RestoreCreate="restore_create",r.RestoreComplete="restore_complete",r.MaxDeliver="max_deliver",r.Terminated="terminated",r.Ack="consumer_ack",r.StreamLeaderElected="stream_leader_elected",r.StreamQuorumLost="stream_quorum_lost",r.ConsumerLeaderElected="consumer_leader_elected",r.ConsumerQuorumLost="consumer_quorum_lost"})(yi||(yi={}));var Q;(function(r){r.StreamSourceHdr="Nats-Stream-Source",r.LastConsumerSeqHdr="Nats-Last-Consumer",r.LastStreamSeqHdr="Nats-Last-Stream",r.ConsumerStalledHdr="Nats-Consumer-Stalled",r.MessageSizeHdr="Nats-Msg-Size",r.RollupHdr="Nats-Rollup",r.RollupValueSubject="sub",r.RollupValueAll="all",r.PendingMessagesHdr="Nats-Pending-Messages",r.PendingBytesHdr="Nats-Pending-Bytes"})(Q||(Q={}));var _e;(function(r){r.LastValue="",r.AllHistory="history",r.UpdatesOnly="updates"})(_e||(_e={}));var it;(function(r){r.Stream="Nats-Stream",r.Sequence="Nats-Sequence",r.TimeStamp="Nats-Time-Stamp",r.Subject="Nats-Subject"})(it||(it={}));var wi;(function(r){r.Stream="Nats-Stream",r.Subject="Nats-Subject",r.Sequence="Nats-Sequence",r.LastSequence="Nats-Last-Sequence",r.Size="Nats-Msg-Size"})(wi||(wi={}));const le="KV_";class wh{constructor(e){c(this,"config");c(this,"ordered");c(this,"mack");c(this,"stream");c(this,"callbackFn");c(this,"max");c(this,"qname");c(this,"isBind");c(this,"filters");this.stream="",this.mack=!1,this.ordered=!1,this.config=yh("",e||{})}getOpts(){var t;const e={};if(e.config=Object.assign({},this.config),e.config.filter_subject&&(this.filterSubject(e.config.filter_subject),e.config.filter_subject=void 0),e.config.filter_subjects&&((t=e.config.filter_subjects)==null||t.forEach(s=>{this.filterSubject(s)}),e.config.filter_subjects=void 0),e.mack=this.mack,e.stream=this.stream,e.callbackFn=this.callbackFn,e.max=this.max,e.queue=this.qname,e.ordered=this.ordered,e.config.ack_policy=e.ordered?V.None:e.config.ack_policy,e.isBind=e.isBind||!1,this.filters)switch(this.filters.length){case 0:break;case 1:e.config.filter_subject=this.filters[0];break;default:e.config.filter_subjects=this.filters}return e}description(e){return this.config.description=e,this}deliverTo(e){return this.config.deliver_subject=e,this}durable(e){return ct(e),this.config.durable_name=e,this}startSequence(e){if(e<=0)throw new Error("sequence must be greater than 0");return this.config.deliver_policy=H.StartSequence,this.config.opt_start_seq=e,this}startTime(e){return this.config.deliver_policy=H.StartTime,this.config.opt_start_time=e.toISOString(),this}deliverAll(){return this.config.deliver_policy=H.All,this}deliverLastPerSubject(){return this.config.deliver_policy=H.LastPerSubject,this}deliverLast(){return this.config.deliver_policy=H.Last,this}deliverNew(){return this.config.deliver_policy=H.New,this}startAtTimeDelta(e){return this.startTime(new Date(Date.now()-e)),this}headersOnly(){return this.config.headers_only=!0,this}ackNone(){return this.config.ack_policy=V.None,this}ackAll(){return this.config.ack_policy=V.All,this}ackExplicit(){return this.config.ack_policy=V.Explicit,this}ackWait(e){return this.config.ack_wait=q(e),this}maxDeliver(e){return this.config.max_deliver=e,this}filterSubject(e){return this.filters=this.filters||[],this.filters.push(e),this}replayInstantly(){return this.config.replay_policy=pt.Instant,this}replayOriginal(){return this.config.replay_policy=pt.Original,this}sample(e){if(e=Math.trunc(e),e<0||e>100)throw new Error("value must be between 0-100");return this.config.sample_freq=`${e}%`,this}limit(e){return this.config.rate_limit_bps=e,this}maxWaiting(e){return this.config.max_waiting=e,this}maxAckPending(e){return this.config.max_ack_pending=e,this}idleHeartbeat(e){return this.config.idle_heartbeat=q(e),this}flowControl(){return this.config.flow_control=!0,this}deliverGroup(e){return this.queue(e),this}manualAck(){return this.mack=!0,this}maxMessages(e){return this.max=e,this}callback(e){return this.callbackFn=e,this}queue(e){return this.qname=e,this.config.deliver_group=e,this}orderedConsumer(){return this.ordered=!0,this}bind(e,t){return this.stream=e,this.config.durable_name=t,this.isBind=!0,this}bindStream(e){return this.stream=e,this}inactiveEphemeralThreshold(e){return this.config.inactive_threshold=q(e),this}maxPullBatch(e){return this.config.max_batch=e,this}maxPullRequestExpires(e){return this.config.max_expires=q(e),this}memory(){return this.config.mem_storage=!0,this}numReplicas(e){return this.config.num_replicas=e,this}}function qe(r){return new wh(r)}function xi(r){return typeof r.getOpts=="function"}function vi(r){const e=r.length;let t=r.indexOf("=");t===-1&&(t=e);const s=t===e?0:4-t%4;return[t,s]}function xh(r,e,t=!1){function s(o,a){return Math.floor((o+a)*3/4-a)}function n(o){return r[o>>18&63]+r[o>>12&63]+r[o>>6&63]+r[o&63]}function i(o,a,h){const l=new Array((h-a)/3);for(let m=a,g=0;m<h;m+=3)l[g++]=n((o[m]<<16)+(o[m+1]<<8)+o[m+2]);return l.join("")}return{byteLength(o){return s.apply(null,vi(o))},toUint8Array(o){const[a,h]=vi(o),l=new Uint8Array(s(a,h)),m=h?a-4:a;let g,b=0,w;for(w=0;w<m;w+=4)g=e[o.charCodeAt(w)]<<18|e[o.charCodeAt(w+1)]<<12|e[o.charCodeAt(w+2)]<<6|e[o.charCodeAt(w+3)],l[b++]=g>>16&255,l[b++]=g>>8&255,l[b++]=g&255;return h===2?(g=e[o.charCodeAt(w)]<<2|e[o.charCodeAt(w+1)]>>4,l[b++]=g&255):h===1&&(g=e[o.charCodeAt(w)]<<10|e[o.charCodeAt(w+1)]<<4|e[o.charCodeAt(w+2)]>>2,l[b++]=g>>8&255,l[b++]=g&255),l},fromUint8Array(o){const h=o.length,l=h%3,m=h-l,g=new Array(Math.ceil(m/16383)+(l?1:0));let b=0,w;for(let k=0;k<m;k+=16383)w=k+16383,g[b++]=i(o,k,w>m?m:w);let A;return l===1?(A=o[m],g[b]=r[A>>2]+r[A<<4&63],t||(g[b]+="==")):l===2&&(A=o[m]<<8|o[m+1]&255,g[b]=r[A>>10]+r[A>>4&63]+r[A<<2&63],t||(g[b]+="=")),g.join("")}}}const No=[],Uo=[],gs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";for(let r=0,e=gs.length;r<e;++r)No[r]=gs[r],Uo[gs.charCodeAt(r)]=r;const{byteLength:El,toUint8Array:vh,fromUint8Array:Sh}=xh(No,Uo,!0),Eh=new TextDecoder,Ah=new TextEncoder;function Ph(r){return r.reduce((e,t)=>`${e}${t<16?"0":""}${t.toString(16)}`,"")}function Oh(r){const e=r.length;if(e%2||!/^[0-9a-fA-F]+$/.test(r))throw new TypeError("Invalid hex string.");r=r.toLowerCase();const t=new Uint8Array(Math.floor(e/2)),s=e/2;for(let n=0;n<s;++n)t[n]=parseInt(r.substr(n*2,2),16);return t}function Ch(r,e="utf8"){if(/^utf-?8$/i.test(e))return Eh.decode(r);if(/^base64$/i.test(e))return Sh(r);if(/^hex(?:adecimal)?$/i.test(e))return Ph(r);throw new TypeError("Unsupported string encoding.")}function kh(r,e="utf8"){if(/^utf-?8$/i.test(e))return Ah.encode(r);if(/^base64$/i.test(e))return vh(r);if(/^hex(?:adecimal)?$/i.test(e))return Oh(r);throw new TypeError("Unsupported string encoding.")}class Si{constructor(){c(this,"hashSize",32);c(this,"_buf");c(this,"_bufIdx");c(this,"_count");c(this,"_K");c(this,"_H");c(this,"_finalized");this._buf=new Uint8Array(64),this._K=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),this.init()}init(){return this._H=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),this._bufIdx=0,this._count=new Uint32Array(2),this._buf.fill(0),this._finalized=!1,this}update(e,t){if(e===null)throw new TypeError("msg must be a string or Uint8Array.");typeof e=="string"&&(e=kh(e,t));for(let n=0,i=e.length;n<i;n++)this._buf[this._bufIdx++]=e[n],this._bufIdx===64&&(this._transform(),this._bufIdx=0);const s=this._count;return(s[0]+=e.length<<3)<e.length<<3&&s[1]++,s[1]+=e.length>>>29,this}digest(e){if(this._finalized)throw new Error("digest has already been called.");this._finalized=!0;const t=this._buf;let s=this._bufIdx;for(t[s++]=128;s!==56;)s===64&&(this._transform(),s=0),t[s++]=0;const n=this._count;t[56]=n[1]>>>24&255,t[57]=n[1]>>>16&255,t[58]=n[1]>>>8&255,t[59]=n[1]>>>0&255,t[60]=n[0]>>>24&255,t[61]=n[0]>>>16&255,t[62]=n[0]>>>8&255,t[63]=n[0]>>>0&255,this._transform();const i=new Uint8Array(32);for(let o=0;o<8;o++)i[(o<<2)+0]=this._H[o]>>>24&255,i[(o<<2)+1]=this._H[o]>>>16&255,i[(o<<2)+2]=this._H[o]>>>8&255,i[(o<<2)+3]=this._H[o]>>>0&255;return this.init(),e?Ch(i,e):i}_transform(){const e=this._H;let t=e[0],s=e[1],n=e[2],i=e[3],o=e[4],a=e[5],h=e[6],l=e[7];const m=new Uint32Array(16);let g;for(g=0;g<16;g++)m[g]=this._buf[(g<<2)+3]|this._buf[(g<<2)+2]<<8|this._buf[(g<<2)+1]<<16|this._buf[g<<2]<<24;for(g=0;g<64;g++){let b;if(g<16)b=m[g];else{let w=m[g+1&15],A=m[g+14&15];b=m[g&15]=(w>>>7^w>>>18^w>>>3^w<<25^w<<14)+(A>>>17^A>>>19^A>>>10^A<<15^A<<13)+m[g&15]+m[g+9&15]|0}b=b+l+(o>>>6^o>>>11^o>>>25^o<<26^o<<21^o<<7)+(h^o&(a^h))+this._K[g]|0,l=h,h=a,a=o,o=i+b,i=n,n=s,s=t,t=b+(s&n^i&(s^n))+(s>>>2^s>>>13^s>>>22^s<<30^s<<19^s<<10)|0}e[0]=e[0]+t|0,e[1]=e[1]+s|0,e[2]=e[2]+n|0,e[3]=e[3]+i|0,e[4]=e[4]+o|0,e[5]=e[5]+a|0,e[6]=e[6]+h|0,e[7]=e[7]+l|0}}class Ct{constructor(e,t,s,n){c(this,"err");c(this,"offset");c(this,"pageInfo");c(this,"subject");c(this,"jsm");c(this,"filter");c(this,"payload");if(!e)throw new Error("subject is required");this.subject=e,this.jsm=s,this.offset=0,this.pageInfo={},this.filter=t,this.payload=n||{}}async next(){if(this.err)return[];if(this.pageInfo&&this.offset>=this.pageInfo.total)return[];const e={offset:this.offset};this.payload&&Object.assign(e,this.payload);try{const t=await this.jsm._request(this.subject,e,{timeout:this.jsm.timeout});return this.pageInfo=t,this.offset+=this.countResponse(t),this.filter(t)}catch(t){throw this.err=t,t}}countResponse(e){var t;switch(e==null?void 0:e.type){case"io.nats.jetstream.api.v1.stream_names_response":case"io.nats.jetstream.api.v1.stream_list_response":return e.streams.length;case"io.nats.jetstream.api.v1.consumer_list_response":return e.consumers.length;default:return console.error(`jslister.ts: unknown API response for paged output: ${e==null?void 0:e.type}`),((t=e.streams)==null?void 0:t.length)||0}return 0}async*[Symbol.asyncIterator](){let e=await this.next();for(;e.length>0;){for(const t of e)yield t;e=await this.next()}}}class Qs extends Bt{constructor(e,t){super(e,t)}async add(e,t,s=Sr.Create){if(te(e),t.deliver_group&&t.flow_control)throw new Error("jetstream flow control is not supported with queue groups");if(t.deliver_group&&t.idle_heartbeat)throw new Error("jetstream idle heartbeat is not supported with queue groups");const n={};n.config=t,n.stream_name=e,n.action=s,n.config.durable_name&&ct(n.config.durable_name);const i=this.nc;let{min:o,ok:a}=i.features.get(L.JS_NEW_CONSUMER_CREATE_API);const h=t.name===""?void 0:t.name;if(h&&!a)throw new Error(`consumer 'name' requires server ${o}`);if(h)try{Xs("name",h)}catch(b){const w=b.message,A=w.indexOf("cannot contain");throw A!==-1?new Error(`consumer 'name' ${w.substring(A)}`):b}let l,m="";if(Array.isArray(t.filter_subjects)){const{min:b,ok:w}=i.features.get(L.JS_MULTIPLE_CONSUMER_FILTER);if(!w)throw new Error(`consumer 'filter_subjects' requires server ${b}`);a=!1}if(t.metadata){const{min:b,ok:w}=i.features.get(L.JS_STREAM_CONSUMER_METADATA);if(!w)throw new Error(`consumer 'metadata' requires server ${b}`)}if(a&&(m=t.name??t.durable_name??""),m!==""){let b=t.filter_subject??void 0;b===">"&&(b=void 0),l=b!==void 0?`${this.prefix}.CONSUMER.CREATE.${e}.${m}.${b}`:`${this.prefix}.CONSUMER.CREATE.${e}.${m}`}else l=t.durable_name?`${this.prefix}.CONSUMER.DURABLE.CREATE.${e}.${t.durable_name}`:`${this.prefix}.CONSUMER.CREATE.${e}`;return await this._request(l,n)}async update(e,t,s){const n=await this.info(e,t),i=s;return this.add(e,Object.assign(n.config,i),Sr.Update)}async info(e,t){return te(e),ct(t),await this._request(`${this.prefix}.CONSUMER.INFO.${e}.${t}`)}async delete(e,t){return te(e),ct(t),(await this._request(`${this.prefix}.CONSUMER.DELETE.${e}.${t}`)).success}list(e){te(e);const t=n=>n.consumers,s=`${this.prefix}.CONSUMER.LIST.${e}`;return new Ct(s,t,this)}}const Ei=Uint8Array.of(43,65,67,75),Rh=Uint8Array.of(45,78,65,75),At=Uint8Array.of(43,87,80,73),jh=Uint8Array.of(43,78,88,84),Ih=Uint8Array.of(43,84,69,82,77),Th=Uint8Array.of(32);function Mt(r){return new Uh(r)}function Nh(r){const e=r.split(".");if(e.length===9&&e.splice(2,0,"_",""),e.length<11||e[0]!=="$JS"||e[1]!=="ACK")throw new Error("not js message");const t={};return t.domain=e[2]==="_"?"":e[2],t.account_hash=e[3],t.stream=e[4],t.consumer=e[5],t.redeliveryCount=parseInt(e[6],10),t.redelivered=t.redeliveryCount>1,t.streamSequence=parseInt(e[7],10),t.deliverySequence=parseInt(e[8],10),t.timestampNanos=parseInt(e[9],10),t.pending=parseInt(e[10],10),t}class Uh{constructor(e){c(this,"msg");c(this,"di");c(this,"didAck");this.msg=e,this.didAck=!1}get subject(){return this.msg.subject}get sid(){return this.msg.sid}get data(){return this.msg.data}get headers(){return this.msg.headers}get info(){return this.di||(this.di=Nh(this.reply)),this.di}get redelivered(){return this.info.redeliveryCount>1}get reply(){return this.msg.reply||""}get seq(){return this.info.streamSequence}doAck(e){this.didAck||(this.didAck=!this.isWIP(e),this.msg.respond(e))}isWIP(e){return e.length===4&&e[0]===At[0]&&e[1]===At[1]&&e[2]===At[2]&&e[3]===At[3]}async ackAck(){var e;if(!this.didAck&&(this.didAck=!0,this.msg.reply)){const s=this.msg.publisher,n=!((e=s.options)!=null&&e.noAsyncTraces),i=new Io(s.muxSubscriptions,this.msg.reply,{timeout:1e3},n);s.request(i);try{s.publish(this.msg.reply,Ei,{reply:`${s.muxSubscriptions.baseInbox}${i.token}`})}catch(o){i.cancel(o)}try{return await Promise.race([i.timer,i.deferred]),!0}catch(o){i.cancel(o)}}return!1}ack(){this.doAck(Ei)}nak(e){let t=Rh;e&&(t=xr().encode(`-NAK ${JSON.stringify({delay:q(e)})}`)),this.doAck(t)}working(){this.doAck(At)}next(e,t={batch:1}){const s={};s.batch=t.batch||1,s.no_wait=t.no_wait||!1,t.expires&&t.expires>0&&(s.expires=q(t.expires));const n=we().encode(s),i=dt.concat(jh,Th,n),o=e?{reply:e}:void 0;this.msg.respond(i,o)}term(e=""){let t=Ih;(e==null?void 0:e.length)>0&&(t=xr().encode(`+TERM ${e}`)),this.doAck(t)}json(){return this.msg.json()}string(){return this.msg.string()}}function nt(r,e,t=!1){if(t===!0&&!r)throw j.errorForCode(P.ApiError,new Error(`${e} is not a function`));if(r&&typeof r!="function")throw j.errorForCode(P.ApiError,new Error(`${e} is not a function`))}class Mh extends Y{constructor(t,s,n){super();c(this,"sub");c(this,"adapter");c(this,"subIterDone");nt(n.adapter,"adapter",!0),this.adapter=n.adapter,n.callback&&nt(n.callback,"callback"),this.noIterator=typeof n.callback=="function",n.ingestionFilterFn&&(nt(n.ingestionFilterFn,"ingestionFilterFn"),this.ingestionFilterFn=n.ingestionFilterFn),n.protocolFilterFn&&(nt(n.protocolFilterFn,"protocolFilterFn"),this.protocolFilterFn=n.protocolFilterFn),n.dispatchedFn&&(nt(n.dispatchedFn,"dispatchedFn"),this.dispatchedFn=n.dispatchedFn),n.cleanupFn&&nt(n.cleanupFn,"cleanupFn");let i=(m,g)=>{this.callback(m,g)};if(n.callback){const m=n.callback;i=(g,b)=>{const[w,A]=this.adapter(g,b);if(w){m(w,null);return}const{ingest:k}=this.ingestionFilterFn?this.ingestionFilterFn(A,this):{ingest:!0};k&&(!this.protocolFilterFn||this.protocolFilterFn(A))&&(m(w,A),this.dispatchedFn&&A&&this.dispatchedFn(A))}}const{max:o,queue:a,timeout:h}=n,l={queue:a,timeout:h,callback:i};o&&o>0&&(l.max=o),this.sub=t.subscribe(s,l),n.cleanupFn&&(this.sub.cleanupFn=n.cleanupFn),this.noIterator||this.iterClosed.then(()=>{this.unsubscribe()}),this.subIterDone=B(),Promise.all([this.sub.closed,this.iterClosed]).then(()=>{this.subIterDone.resolve()}).catch(()=>{this.subIterDone.resolve()}),(async m=>{await m.closed,this.stop()})(this.sub).then().catch()}unsubscribe(t){this.sub.unsubscribe(t)}drain(){return this.sub.drain()}isDraining(){return this.sub.isDraining()}isClosed(){return this.sub.isClosed()}callback(t,s){this.sub.cancelTimeout();const[n,i]=this.adapter(t,s);n&&this.stop(n),i&&this.push(i)}getSubject(){return this.sub.getSubject()}getReceived(){return this.sub.getReceived()}getProcessed(){return this.sub.getProcessed()}getPending(){return this.sub.getPending()}getID(){return this.sub.getID()}getMax(){return this.sub.getMax()}get closed(){return this.sub.closed}}class en{constructor(e,t,s={maxOut:2}){c(this,"interval");c(this,"maxOut");c(this,"cancelAfter");c(this,"timer");c(this,"autoCancelTimer");c(this,"last");c(this,"missed");c(this,"count");c(this,"callback");this.interval=e,this.maxOut=(s==null?void 0:s.maxOut)||2,this.cancelAfter=(s==null?void 0:s.cancelAfter)||0,this.last=Date.now(),this.missed=0,this.count=0,this.callback=t,this._schedule()}cancel(){this.autoCancelTimer&&clearTimeout(this.autoCancelTimer),this.timer&&clearInterval(this.timer),this.timer=0,this.autoCancelTimer=0}work(){this.last=Date.now(),this.missed=0}_change(e,t=0,s=2){this.interval=e,this.maxOut=s,this.cancelAfter=t,this.restart()}restart(){this.cancel(),this._schedule()}_schedule(){this.cancelAfter>0&&(this.autoCancelTimer=setTimeout(()=>{this.cancel()},this.cancelAfter)),this.timer=setInterval(()=>{if(this.count++,Date.now()-this.last>this.interval&&this.missed++,this.missed>=this.maxOut)try{this.callback(this.missed)===!0&&this.cancel()}catch(e){console.log(e)}},this.interval)}}var ve;(function(r){r[r.Unset=-1]="Unset",r[r.Consume=0]="Consume",r[r.Fetch=1]="Fetch"})(ve||(ve={}));var mt;(function(r){r.HeartbeatsMissed="heartbeats_missed",r.ConsumerNotFound="consumer_not_found",r.OrderedConsumerRecreated="ordered_consumer_recreated"})(mt||(mt={}));var Tt;(function(r){r.DebugEvent="debug",r.Discard="discard",r.Next="next"})(Tt||(Tt={}));class _s extends Y{constructor(t,s,n=!1){super();c(this,"consumer");c(this,"opts");c(this,"sub");c(this,"monitor");c(this,"pending");c(this,"inbox");c(this,"refilling");c(this,"stack");c(this,"pong");c(this,"callback");c(this,"timeout");c(this,"cleanupHandler");c(this,"listeners");c(this,"statusIterator");c(this,"forOrderedConsumer");c(this,"resetHandler");this.consumer=t,this.opts=this.parseOptions(s,n),this.callback=s.callback||null,this.noIterator=typeof this.callback=="function",this.monitor=null,this.pong=null,this.pending={msgs:0,bytes:0,requests:0},this.refilling=n,this.stack=new Error().stack.split(`
  25. `).slice(1).join(`
  26. `),this.timeout=null,this.inbox=je(t.api.nc.options.inboxPrefix),this.listeners=[],this.forOrderedConsumer=!1,this.start()}start(){const{max_messages:t,max_bytes:s,idle_heartbeat:n,threshold_bytes:i,threshold_messages:o}=this.opts;this.closed().then(()=>{if(this.cleanupHandler)try{this.cleanupHandler()}catch{}});const{sub:a}=this;a&&a.unsubscribe(),this.sub=this.consumer.api.nc.subscribe(this.inbox,{callback:(h,l)=>{var g,b,w,A;if(h){this.stop();return}if((g=this.monitor)==null||g.work(),l.subject===this.inbox){if(Ns(l))return;const k=(b=l.headers)==null?void 0:b.code,R=((A=(w=l.headers)==null?void 0:w.description)==null?void 0:A.toLowerCase())||"unknown",{msgsLeft:M,bytesLeft:N}=this.parseDiscard(l.headers);if(M>0||N>0)this.pending.msgs-=M,this.pending.bytes-=N,this.pending.requests--,this.notify(Tt.Discard,{msgsLeft:M,bytesLeft:N});else{const U=()=>{const J=new j(R,`${k}`);return J.stack+=`
  27. ${this.stack}`,J};if(k===400){const J=U();this._push(()=>{this.stop(J)})}else if(k===409&&R==="consumer deleted"){const J=U();this.stop(J)}else this.notify(Tt.DebugEvent,`${k} ${R}`)}}else this._push(Mt(l)),this.received++,this.pending.msgs&&this.pending.msgs--,this.pending.bytes&&(this.pending.bytes-=l.size());if(this.pending.msgs===0&&this.pending.bytes===0&&(this.pending.requests=0),this.refilling){if(t&&this.pending.msgs<=o||s&&this.pending.bytes<=i){const k=this.pullOptions();this.pull(k)}}else this.pending.requests===0&&this._push(()=>{this.stop()})}}),this.sub.closed.then(()=>{this.sub.draining&&this._push(()=>{this.stop()})}),n&&(this.monitor=new en(n,h=>(this.notify(mt.HeartbeatsMissed,h),this.resetPending().then(()=>{}).catch(()=>{}),!1),{maxOut:2})),(async()=>{var l;const h=this.consumer.api.nc.status();this.statusIterator=h;for await(const m of h)switch(m.type){case Ce.Disconnect:(l=this.monitor)==null||l.cancel();break;case Ce.Reconnect:this.resetPending().then(g=>{var b;g&&((b=this.monitor)==null||b.restart())}).catch(()=>{});break}})(),this.pull(this.pullOptions())}_push(t){if(!this.callback)super.push(t);else{const s=typeof t=="function"?t:null;try{s?s():this.callback(t)}catch(n){this.stop(n)}}}notify(t,s){this.listeners.length>0&&this.listeners.forEach(n=>{n.done||n.push({type:t,data:s})})}async resetPending(){let t=0;const s=vo();let n=0;for(;;){if(this.consumer.api.nc.isClosed())return console.error("aborting resetPending - connection is closed"),!1;try{return await this.consumer.info(),t=0,this.pending.msgs=0,this.pending.bytes=0,this.pending.requests=0,this.pull(this.pullOptions()),!0}catch(i){if(i.message==="consumer not found"){if(t++,this.notify(mt.ConsumerNotFound,t),this.resetHandler)try{this.resetHandler()}catch{}if(this.forOrderedConsumer)return!1}else t=0;const o=s.backoff(n);await Promise.race([qt(o),this.consumer.api.nc.closed()]),n++}}}pull(t){this.pending.bytes+=t.max_bytes??0,this.pending.msgs+=t.batch??0,this.pending.requests++;const s=this.consumer.api.nc;this._push(()=>{s.publish(`${this.consumer.api.prefix}.CONSUMER.MSG.NEXT.${this.consumer.stream}.${this.consumer.name}`,this.consumer.api.jc.encode(t),{reply:this.inbox}),this.notify(Tt.Next,t)})}pullOptions(){const t=this.opts.max_messages-this.pending.msgs,s=this.opts.max_bytes-this.pending.bytes,n=q(this.opts.idle_heartbeat),i=q(this.opts.expires);return{batch:t,max_bytes:s,idle_heartbeat:n,expires:i}}parseDiscard(t){const s={msgsLeft:0,bytesLeft:0},n=t==null?void 0:t.get(Q.PendingMessagesHdr);n&&(s.msgsLeft=parseInt(n));const i=t==null?void 0:t.get(Q.PendingBytesHdr);return i&&(s.bytesLeft=parseInt(i)),s}trackTimeout(t){this.timeout=t}close(){return this.stop(),this.iterClosed}closed(){return this.iterClosed}clearTimers(){var t,s;(t=this.monitor)==null||t.cancel(),this.monitor=null,(s=this.timeout)==null||s.cancel(),this.timeout=null}setCleanupHandler(t){this.cleanupHandler=t}stop(t){var s,n;(s=this.sub)==null||s.unsubscribe(),this.clearTimers(),(n=this.statusIterator)==null||n.stop(),this._push(()=>{super.stop(t),this.listeners.forEach(i=>{i.stop()})})}parseOptions(t,s=!1){const n=t||{};if(n.max_messages=n.max_messages||0,n.max_bytes=n.max_bytes||0,n.max_messages!==0&&n.max_bytes!==0)throw new Error("only specify one of max_messages or max_bytes");if(n.max_messages===0&&(n.max_messages=100),n.expires=n.expires||3e4,n.expires<1e3)throw new Error("expires should be at least 1000ms");if(n.idle_heartbeat=n.idle_heartbeat||n.expires/2,n.idle_heartbeat=n.idle_heartbeat>3e4?3e4:n.idle_heartbeat,s){const i=Math.round(n.max_messages*.75)||1;n.threshold_messages=n.threshold_messages||i;const o=Math.round(n.max_bytes*.75)||1;n.threshold_bytes=n.threshold_bytes||o}return n}status(){const t=new Y;return this.listeners.push(t),Promise.resolve(t)}}class Ai extends Y{constructor(){super();c(this,"src");c(this,"listeners");this.listeners=[]}setSource(t){this.src&&(this.src.resetHandler=void 0,this.src.setCleanupHandler(),this.src.stop()),this.src=t,this.src.setCleanupHandler(()=>{this.close().catch()}),(async()=>{const s=await this.src.status();for await(const n of s)this.notify(n.type,n.data)})().catch(()=>{})}notify(t,s){this.listeners.length>0&&this.listeners.forEach(n=>{n.done||n.push({type:t,data:s})})}stop(t){var s;(s=this.src)==null||s.stop(t),super.stop(t),this.listeners.forEach(n=>{n.stop()})}close(){return this.stop(),this.iterClosed}status(){const t=new Y;return this.listeners.push(t),Promise.resolve(t)}}class Mo{constructor(e,t){c(this,"api");c(this,"_info");c(this,"stream");c(this,"name");this.api=e,this._info=t,this.stream=t.stream_name,this.name=t.name}consume(e={max_messages:100,expires:3e4}){return Promise.resolve(new _s(this,e,!0))}fetch(e={max_messages:100,expires:3e4}){const t=new _s(this,e,!1),s=Math.round(t.opts.expires*1.05),n=ft(s);return t.closed().then(()=>{n.cancel()}),n.catch(()=>{t.close().catch()}),t.trackTimeout(n),Promise.resolve(t)}next(e={expires:3e4}){const t=B(),s=e;s.max_messages=1;const n=new _s(this,s,!1),i=Math.round(n.opts.expires*1.05);i>=6e4&&(async()=>{for await(const a of await n.status())if(a.type===mt.HeartbeatsMissed&&a.data>=2){t.reject(new Error("consumer missed heartbeats"));break}})().catch(),(async()=>{for await(const a of n){t.resolve(a);break}})().catch();const o=ft(i);return n.closed().then(()=>{t.resolve(null),o.cancel()}).catch(a=>{t.reject(a)}),o.catch(a=>{t.resolve(null),n.close().catch()}),n.trackTimeout(o),t}delete(){const{stream_name:e,name:t}=this._info;return this.api.delete(e,t)}info(e=!1){if(e)return Promise.resolve(this._info);const{stream_name:t,name:s}=this._info;return this.api.info(t,s).then(n=>(this._info=n,this._info))}}class Fh{constructor(e,t,s={}){c(this,"api");c(this,"consumerOpts");c(this,"consumer");c(this,"opts");c(this,"cursor");c(this,"stream");c(this,"namePrefix");c(this,"serial");c(this,"currentConsumer");c(this,"userCallback");c(this,"iter");c(this,"type");c(this,"startSeq");this.api=e,this.stream=t,this.cursor={stream_seq:1,deliver_seq:0},this.namePrefix=Dt.next(),this.serial=0,this.currentConsumer=null,this.userCallback=null,this.iter=null,this.type=ve.Unset,this.consumerOpts=s,this.startSeq=this.consumerOpts.opt_start_seq||0,this.cursor.stream_seq=this.startSeq>0?this.startSeq-1:0}getConsumerOpts(e){this.serial++;const t=`${this.namePrefix}_${this.serial}`;e=e===0?1:e;const s={name:t,deliver_policy:H.StartSequence,opt_start_seq:e,ack_policy:V.None,inactive_threshold:q(5*60*1e3),num_replicas:1};return this.consumerOpts.headers_only===!0&&(s.headers_only=!0),Array.isArray(this.consumerOpts.filterSubjects)&&(s.filter_subjects=this.consumerOpts.filterSubjects),typeof this.consumerOpts.filterSubjects=="string"&&(s.filter_subject=this.consumerOpts.filterSubjects),e===this.startSeq+1&&(s.deliver_policy=this.consumerOpts.deliver_policy||H.StartSequence,(this.consumerOpts.deliver_policy===H.LastPerSubject||this.consumerOpts.deliver_policy===H.New||this.consumerOpts.deliver_policy===H.Last)&&(delete s.opt_start_seq,s.deliver_policy=this.consumerOpts.deliver_policy),s.deliver_policy===H.LastPerSubject&&typeof s.filter_subjects>"u"&&typeof s.filter_subject>"u"&&(s.filter_subject=">"),this.consumerOpts.opt_start_time&&(delete s.opt_start_seq,s.deliver_policy=H.StartTime,s.opt_start_time=this.consumerOpts.opt_start_time),this.consumerOpts.inactive_threshold&&(s.inactive_threshold=q(this.consumerOpts.inactive_threshold))),s}async resetConsumer(e=0){var i,o;(i=this.consumer)==null||i.delete().catch(()=>{}),e=e===0?1:e,this.cursor.deliver_seq=0;const t=this.getConsumerOpts(e);t.max_deliver=1,t.mem_storage=!0;const s=vo();let n;for(let a=0;;a++)try{n=await this.api.add(this.stream,t),(o=this.iter)==null||o.notify(mt.OrderedConsumerRecreated,n.name);break}catch(h){if(e===0&&a>=30)throw h;await qt(s.backoff(a+1))}return n}internalHandler(e){return t=>{var n;if(this.serial!==e)return;const s=t.info.deliverySequence;if(s!==this.cursor.deliver_seq+1){this.reset(this.opts);return}this.cursor.deliver_seq=s,this.cursor.stream_seq=t.info.streamSequence,this.userCallback?this.userCallback(t):(n=this.iter)==null||n.push(t)}}async reset(e={max_messages:100,expires:3e4},t=!1){this.currentConsumer=await this.resetConsumer(this.cursor.stream_seq+1),this.iter===null&&(this.iter=new Ai),this.consumer=new Mo(this.api,this.currentConsumer);const s=e;s.callback=this.internalHandler(this.serial);let n=null;if(this.type===ve.Fetch&&t)n=await this.consumer.fetch(e);else if(this.type===ve.Consume)n=await this.consumer.consume(e);else return Promise.reject("reset called with unset consumer type");const i=n;return i.forOrderedConsumer=!0,i.resetHandler=()=>{this.reset(this.opts)},this.iter.setSource(i),this.iter}consume(e={max_messages:100,expires:3e4}){if(this.type===ve.Fetch)return Promise.reject(new Error("ordered consumer initialized as fetch"));if(this.type===ve.Consume)return Promise.reject(new Error("ordered consumer doesn't support concurrent consume"));const{callback:t}=e;return t&&(this.userCallback=t),this.type=ve.Consume,this.opts=e,this.reset(e)}fetch(e={max_messages:100,expires:3e4}){var s;if(this.type===ve.Consume)return Promise.reject(new Error("ordered consumer already initialized as consume"));if(((s=this.iter)==null?void 0:s.done)===!1)return Promise.reject(new Error("ordered consumer doesn't support concurrent fetch"));const{callback:t}=e;return t&&(this.userCallback=t),this.type=ve.Fetch,this.opts=e,this.iter=new Ai,this.reset(e,!0)}async next(e={expires:3e4}){const t=B(),s=e;return s.max_messages=1,s.callback=i=>{this.userCallback=null,t.resolve(i)},(await this.fetch(s)).iterClosed.then(()=>{t.resolve(null)}).catch(i=>{t.reject(i)}),t}delete(){return this.currentConsumer?this.api.delete(this.stream,this.currentConsumer.name).then(e=>Promise.resolve(e)).catch(e=>Promise.reject(e)).finally(()=>{this.currentConsumer=null}):Promise.resolve(!1)}async info(e){return this.currentConsumer==null?(this.currentConsumer=await this.resetConsumer(this.serial),Promise.resolve(this.currentConsumer)):e&&this.currentConsumer?Promise.resolve(this.currentConsumer):this.api.info(this.stream,this.currentConsumer.name)}}function or(r){if(r===void 0)return;const{domain:e}=r;if(e===void 0)return r;const t=Object.assign({},r);if(delete t.domain,e==="")return t;if(t.external)throw new Error("domain and external are both set");return t.external={api:`$JS.${e}.API`},t}var ke;const tn="OBJ_";class Fo{constructor(e){c(this,"api");c(this,"notified");this.api=e,this.notified=!1}checkVersion(){const e=this.api.nc.features.get(L.JS_SIMPLIFICATION);return e.ok?Promise.resolve():Promise.reject(new Error(`consumers framework is only supported on servers ${e.min} or better`))}async get(e,t={}){return typeof t=="object"?this.ordered(e,t):(await this.checkVersion(),this.api.info(e,t).then(s=>s.config.deliver_subject!==void 0?Promise.reject(new Error("push consumer not supported")):new Mo(this.api,s)).catch(s=>Promise.reject(s)))}async ordered(e,t){await this.checkVersion();const s=this.api;return new rn(s.nc,s.opts).info(e).then(i=>Promise.resolve(new Fh(this.api,e,t))).catch(i=>Promise.reject(i))}}class Nr{constructor(e,t){c(this,"api");c(this,"_info");this.api=e,this._info=t}get name(){return this._info.config.name}alternates(){return this.info().then(e=>e.alternates?e.alternates:[])}async best(){if(await this.info(),this._info.alternates){const e=await this.api.info(this._info.alternates[0].name);return new Nr(this.api,e)}else return this}info(e=!1,t){return e?Promise.resolve(this._info):this.api.info(this.name,t).then(s=>(this._info=s,this._info))}getConsumer(e){return new Fo(new Qs(this.api.nc,this.api.opts)).get(this.name,e)}getMessage(e){return this.api.getMessage(this.name,e)}deleteMessage(e,t){return this.api.deleteMessage(this.name,e,t)}}function $o(){return{key:{encode(r){return r},decode(r){return r}},value:{encode(r){return r},decode(r){return r}}}}function $h(){return{replicas:1,history:1,timeout:2e3,maxBucketSize:-1,maxValueSize:-1,codec:$o(),storage:Ms.File}}const Er="KV-Operation",Pi="$KV",Lh=/^[-/=.\w]+$/,Dh=/^[-/=.>*\w]+$/,qh=/^[-\w]+$/;function Bh(r){if(r.startsWith(".")||r.endsWith(".")||!Lh.test(r))throw new Error(`invalid key: ${r}`)}function Hh(r){if(r.startsWith(".")||r.endsWith(".")||!Dh.test(r))throw new Error(`invalid key: ${r}`)}function Jh(r){if(r.startsWith(".")||r.endsWith("."))throw new Error(`invalid key: ${r}`);const e=r.split(".");let t=!1;for(let s=0;s<e.length;s++)switch(e[s]){case"*":t=!0;break;case">":if(s!==e.length-1)throw new Error(`invalid key: ${r}`);t=!0;break}return t}function dr(r){if(!qh.test(r))throw new Error(`invalid bucket name: ${r}`)}(function(r){r.MsgIdHdr="Nats-Msg-Id",r.ExpectedStreamHdr="Nats-Expected-Stream",r.ExpectedLastSeqHdr="Nats-Expected-Last-Sequence",r.ExpectedLastMsgIdHdr="Nats-Expected-Last-Msg-Id",r.ExpectedLastSubjectSequenceHdr="Nats-Expected-Last-Subject-Sequence"})(ke||(ke={}));class Ft{constructor(e,t,s){c(this,"js");c(this,"jsm");c(this,"stream");c(this,"bucket");c(this,"direct");c(this,"codec");c(this,"prefix");c(this,"editPrefix");c(this,"useJsPrefix");c(this,"_prefixLen");c(this,"validateKey",Bh);c(this,"validateSearchKey",Hh);c(this,"hasWildcards",Jh);dr(e),this.js=t,this.jsm=s,this.bucket=e,this.prefix=Pi,this.editPrefix="",this.useJsPrefix=!1,this._prefixLen=0}static async create(e,t,s={}){dr(t);const n=await e.jetstreamManager(),i=new Ft(t,e,n);return await i.init(s),i}static async bind(e,t,s={}){const n=await e.jetstreamManager(),i=await n.streams.info(`${le}${t}`);dr(i.config.name);const o=new Ft(t,e,n);return Object.assign(o,i),o.codec=s.codec||$o(),o.direct=i.config.allow_direct??!1,o.initializePrefixes(i),o}async init(e={}){const t=Object.assign($h(),e);this.codec=t.codec;const s={};this.stream=s.name=e.streamName??this.bucketName(),s.retention=Us.Limits,s.max_msgs_per_subject=t.history,t.maxBucketSize&&(t.max_bytes=t.maxBucketSize),t.max_bytes&&(s.max_bytes=t.max_bytes),s.max_msg_size=t.maxValueSize,s.storage=t.storage;const n=e.placementCluster??"";if(n&&(e.placement={},e.placement.cluster=n,e.placement.tags=[]),e.placement&&(s.placement=e.placement),e.republish&&(s.republish=e.republish),e.description&&(s.description=e.description),e.mirror){const g=Object.assign({},e.mirror);g.name.startsWith(le)||(g.name=`${le}${g.name}`),s.mirror=g,s.mirror_direct=!0}else if(e.sources){const g=e.sources.map(b=>{const w=Object.assign({},b);w.name.startsWith(le)||(w.name=`${le}${w.name}`)});s.sources=g}else s.subjects=[this.subjectForBucket()];e.metadata&&(s.metadata=e.metadata),typeof e.compression=="boolean"&&(s.compression=e.compression?Be.S2:Be.None);const i=this.js.nc,o=i.getServerVersion(),a=o?Is(o,Ve("2.7.2"))>=0:!1;s.discard=a?Ut.New:Ut.Old;const{ok:h,min:l}=i.features.get(L.JS_ALLOW_DIRECT);if(!h&&e.allow_direct===!0){const g=o?`${o.major}.${o.minor}.${o.micro}`:"unknown";return Promise.reject(new Error(`allow_direct is not available on server version ${g} - requires ${l}`))}e.allow_direct=typeof e.allow_direct=="boolean"?e.allow_direct:h,s.allow_direct=e.allow_direct,this.direct=s.allow_direct,s.num_replicas=t.replicas,t.ttl&&(s.max_age=q(t.ttl)),s.allow_rollup_hdrs=!0;let m;try{m=await this.jsm.streams.info(s.name),!m.config.allow_direct&&this.direct===!0&&(this.direct=!1)}catch(g){if(g.message==="stream not found")m=await this.jsm.streams.add(s);else throw g}this.initializePrefixes(m)}initializePrefixes(e){this._prefixLen=0,this.prefix=`$KV.${this.bucket}`,this.useJsPrefix=this.js.apiPrefix!=="$JS.API";const{mirror:t}=e.config;if(t){let s=t.name;if(s.startsWith(le)&&(s=s.substring(le.length)),t.external&&t.external.api!==""){const n=t.name.substring(le.length);this.useJsPrefix=!1,this.prefix=`$KV.${n}`,this.editPrefix=`${t.external.api}.$KV.${s}`}else this.editPrefix=this.prefix}}bucketName(){return this.stream??`${le}${this.bucket}`}subjectForBucket(){return`${this.prefix}.${this.bucket}.>`}subjectForKey(e,t=!1){const s=[];return t?(this.useJsPrefix&&s.push(this.js.apiPrefix),this.editPrefix!==""?s.push(this.editPrefix):s.push(this.prefix)):this.prefix&&s.push(this.prefix),s.push(e),s.join(".")}fullKeyName(e){return this.prefix!==""?`${this.prefix}.${e}`:`${Pi}.${this.bucket}.${e}`}get prefixLen(){return this._prefixLen===0&&(this._prefixLen=this.prefix.length+1),this._prefixLen}encodeKey(e){const t=[];for(const s of e.split("."))switch(s){case">":case"*":t.push(s);break;default:t.push(this.codec.key.encode(s));break}return t.join(".")}decodeKey(e){const t=[];for(const s of e.split("."))switch(s){case">":case"*":t.push(s);break;default:t.push(this.codec.key.decode(s));break}return t.join(".")}close(){return Promise.resolve()}dataLen(e,t){const s=t&&t.get(Q.MessageSizeHdr)||"";return s!==""?parseInt(s,10):e.length}smToEntry(e){return new Wh(this.bucket,this.prefixLen,e)}jmToEntry(e){const t=this.decodeKey(e.subject.substring(this.prefixLen));return new Yh(this.bucket,t,e)}async create(e,t){var i;let s;try{const o=await this.put(e,t,{previousSeq:0});return Promise.resolve(o)}catch(o){if(s=o,((i=o==null?void 0:o.api_error)==null?void 0:i.err_code)!==10071)return Promise.reject(o)}let n=0;try{const o=await this.get(e);return(o==null?void 0:o.operation)==="DEL"||(o==null?void 0:o.operation)==="PURGE"?(n=o!==null?o.revision:0,this.update(e,t,n)):Promise.reject(s)}catch(o){return Promise.reject(o)}}update(e,t,s){if(s<=0)throw new Error("version must be greater than 0");return this.put(e,t,{previousSeq:s})}async put(e,t,s={}){var o,a;const n=this.encodeKey(e);this.validateKey(n);const i={};if(s.previousSeq!==void 0){const h=Ie();i.headers=h,h.set(ke.ExpectedLastSubjectSequenceHdr,`${s.previousSeq}`)}try{return(await this.js.publish(this.subjectForKey(n,!0),t,i)).seq}catch(h){const l=h;return l.isJetStreamError()?(l.message=(o=l.api_error)==null?void 0:o.description,l.code=`${(a=l.api_error)==null?void 0:a.code}`,Promise.reject(l)):Promise.reject(h)}}async get(e,t){const s=this.encodeKey(e);this.validateKey(s);let n={last_by_subj:this.subjectForKey(s)};t&&t.revision>0&&(n={seq:t.revision});let i;try{this.direct?i=await this.jsm.direct.getMessage(this.bucketName(),n):i=await this.jsm.streams.getMessage(this.bucketName(),n);const o=this.smToEntry(i);return o.key!==s?null:o}catch(o){if(o.code===P.JetStream404NoMessages)return null;throw o}}purge(e){return this._deleteOrPurge(e,"PURGE")}delete(e){return this._deleteOrPurge(e,"DEL")}async purgeDeletes(e=30*60*1e3){const t=B(),s=[],n=await this.watch({key:">",initializedFn:()=>{t.resolve()}});(async()=>{for await(const h of n)(h.operation==="DEL"||h.operation==="PURGE")&&s.push(h)})().then(),await t,n.stop();const i=Date.now()-e,o=s.map(h=>{const l=this.subjectForKey(h.key);return h.created.getTime()>=i?this.jsm.streams.purge(this.stream,{filter:l,keep:1}):this.jsm.streams.purge(this.stream,{filter:l,keep:0})}),a=await Promise.all(o);return a.unshift({success:!0,purged:0}),a.reduce((h,l)=>(h.purged+=l.purged,h))}async _deleteOrPurge(e,t){if(!this.hasWildcards(e))return this._doDeleteOrPurge(e,t);const s=await this.keys(e),n=[];for await(const i of s)n.push(this._doDeleteOrPurge(i,t)),n.length===100&&(await Promise.all(n),n.length=0);n.length>0&&await Promise.all(n)}async _doDeleteOrPurge(e,t){const s=this.encodeKey(e);this.validateKey(s);const n=Ie();n.set(Er,t),t==="PURGE"&&n.set(Q.RollupHdr,Q.RollupValueSubject),await this.js.publish(this.subjectForKey(s,!0),se,{headers:n})}_buildCC(e,t,s={}){const n=this.encodeKey(e);this.validateSearchKey(e);let i=H.LastPerSubject;return t===_e.AllHistory&&(i=H.All),t===_e.UpdatesOnly&&(i=H.New),Object.assign({deliver_policy:i,ack_policy:V.None,filter_subject:this.fullKeyName(n),flow_control:!0,idle_heartbeat:q(5*1e3)},s)}remove(e){return this.purge(e)}async history(e={}){const t=e.key??">",s=new Y,n={};n.headers_only=e.headers_only||!1;let i;i=()=>{s.stop()};let o=0;const a=this._buildCC(t,_e.AllHistory,n),h=a.filter_subject,l=qe(a);l.bindStream(this.stream),l.orderedConsumer(),l.callback((g,b)=>{if(g){s.stop(g);return}if(b){const w=this.jmToEntry(b);s.push(w),s.received++,(i&&o>0&&s.received>=o||b.info.pending===0)&&(s.push(i),i=void 0)}});const m=await this.js.subscribe(h,l);if(i){const{info:{last:g}}=m,b=g.num_pending+g.delivered.consumer_seq;if(b===0||s.received>=b)try{i()}catch(w){s.stop(w)}finally{i=void 0}else o=b}return s._data=m,s.iterClosed.then(()=>{m.unsubscribe()}),m.closed.then(()=>{s.stop()}).catch(g=>{s.stop(g)}),s}async watch(e={}){const t=e.key??">",s=new Y,n={};n.headers_only=e.headers_only||!1;let i=_e.LastValue;e.include===_e.AllHistory?i=_e.AllHistory:e.include===_e.UpdatesOnly&&(i=_e.UpdatesOnly);const o=e.ignoreDeletes===!0;let a=e.initializedFn,h=0;const l=this._buildCC(t,i,n),m=l.filter_subject,g=qe(l);g.bindStream(this.stream),g.orderedConsumer(),g.callback((w,A)=>{if(w){s.stop(w);return}if(A){const k=this.jmToEntry(A);if(o&&k.operation==="DEL")return;s.push(k),s.received++,a&&(h>0&&s.received>=h||A.info.pending===0)&&(s.push(a),a=void 0)}});const b=await this.js.subscribe(m,g);if(a){const{info:{last:w}}=b,A=w.num_pending+w.delivered.consumer_seq;if(A===0||s.received>=A)try{a()}catch(k){s.stop(k)}finally{a=void 0}else h=A}return s._data=b,s.iterClosed.then(()=>{b.unsubscribe()}),b.closed.then(()=>{s.stop()}).catch(w=>{s.stop(w)}),s}async keys(e=">"){const t=new Y,s=this._buildCC(e,_e.LastValue,{headers_only:!0}),n=s.filter_subject,i=qe(s);i.bindStream(this.stream),i.orderedConsumer();const o=await this.js.subscribe(n,i);return(async()=>{var h;for await(const l of o){const m=(h=l.headers)==null?void 0:h.get(Er);if(m!=="DEL"&&m!=="PURGE"){const g=this.decodeKey(l.subject.substring(this.prefixLen));t.push(g)}l.info.pending===0&&o.unsubscribe()}})().then(()=>{t.stop()}).catch(h=>{t.stop(h)}),o.info.last.num_pending===0&&o.unsubscribe(),t}purgeBucket(e){return this.jsm.streams.purge(this.bucketName(),e)}destroy(){return this.jsm.streams.delete(this.bucketName())}async status(){var i;const t=((i=this.js.nc.info)==null?void 0:i.cluster)??"",s=this.bucketName(),n=await this.jsm.streams.info(s);return new Lo(n,t)}}class Lo{constructor(e,t=""){c(this,"si");c(this,"cluster");this.si=e,this.cluster=t}get bucket(){return this.si.config.name.startsWith(le)?this.si.config.name.substring(le.length):this.si.config.name}get values(){return this.si.state.messages}get history(){return this.si.config.max_msgs_per_subject}get ttl(){return Zs(this.si.config.max_age)}get bucket_location(){return this.cluster}get backingStore(){return this.si.config.storage}get storage(){return this.si.config.storage}get replicas(){return this.si.config.num_replicas}get description(){return this.si.config.description??""}get maxBucketSize(){return this.si.config.max_bytes}get maxValueSize(){return this.si.config.max_msg_size}get max_bytes(){return this.si.config.max_bytes}get placement(){return this.si.config.placement||{cluster:"",tags:[]}}get placementCluster(){var e;return((e=this.si.config.placement)==null?void 0:e.cluster)??""}get republish(){return this.si.config.republish??{src:"",dest:""}}get streamInfo(){return this.si}get size(){return this.si.state.bytes}get metadata(){return this.si.config.metadata??{}}get compression(){return this.si.config.compression?this.si.config.compression!==Be.None:!1}}const Oi="SHA-256=";function zh(r){return dr(r),`${tn}${r}`}function Gh(r){return r.startsWith(tn)?r.substring(4):r}class Fs{constructor(e){c(this,"si");c(this,"backingStore");this.si=e,this.backingStore="JetStream"}get bucket(){return Gh(this.si.config.name)}get description(){return this.si.config.description??""}get ttl(){return this.si.config.max_age}get storage(){return this.si.config.storage}get replicas(){return this.si.config.num_replicas}get sealed(){return this.si.config.sealed}get size(){return this.si.state.bytes}get streamInfo(){return this.si}get metadata(){return this.si.config.metadata}get compression(){return this.si.config.compression?this.si.config.compression!==Be.None:!1}}class rn extends Bt{constructor(e,t){super(e,t)}checkStreamConfigVersions(e){const t=this.nc;if(e.metadata){const{min:n,ok:i}=t.features.get(L.JS_STREAM_CONSUMER_METADATA);if(!i)throw new Error(`stream 'metadata' requires server ${n}`)}if(e.first_seq){const{min:n,ok:i}=t.features.get(L.JS_STREAM_FIRST_SEQ);if(!i)throw new Error(`stream 'first_seq' requires server ${n}`)}if(e.subject_transform){const{min:n,ok:i}=t.features.get(L.JS_STREAM_SUBJECT_TRANSFORM);if(!i)throw new Error(`stream 'subject_transform' requires server ${n}`)}if(e.compression){const{min:n,ok:i}=t.features.get(L.JS_STREAM_COMPRESSION);if(!i)throw new Error(`stream 'compression' requires server ${n}`)}if(e.consumer_limits){const{min:n,ok:i}=t.features.get(L.JS_DEFAULT_CONSUMER_LIMITS);if(!i)throw new Error(`stream 'consumer_limits' requires server ${n}`)}function s(n,i){var a;if((((a=i.subject_transforms)==null?void 0:a.length)||0)>0){const{min:h,ok:l}=t.features.get(L.JS_STREAM_SOURCE_SUBJECT_TRANSFORM);if(!l)throw new Error(`${n} 'subject_transforms' requires server ${h}`)}}e.sources&&e.sources.forEach(n=>{s("stream sources",n)}),e.mirror&&s("stream mirror",e.mirror)}async add(e={}){var n;this.checkStreamConfigVersions(e),te(e.name),e.mirror=or(e.mirror),e.sources=(n=e.sources)==null?void 0:n.map(or);const s=await this._request(`${this.prefix}.STREAM.CREATE.${e.name}`,e);return this._fixInfo(s),s}async delete(e){return te(e),(await this._request(`${this.prefix}.STREAM.DELETE.${e}`)).success}async update(e,t={}){var a;if(typeof e=="object"){const h=e;e=h.name,t=h,console.trace("\x1B[33m >> streams.update(config: StreamConfig) api changed to streams.update(name: string, config: StreamUpdateConfig) - this shim will be removed - update your code. \x1B[0m")}this.checkStreamConfigVersions(t),te(e);const s=await this.info(e),n=Object.assign(s.config,t);n.mirror=or(n.mirror),n.sources=(a=n.sources)==null?void 0:a.map(or);const o=await this._request(`${this.prefix}.STREAM.UPDATE.${e}`,n);return this._fixInfo(o),o}async info(e,t){te(e);const s=`${this.prefix}.STREAM.INFO.${e}`;let i=await this._request(s,t),{total:o,limit:a}=i,h=i.state.subjects?Object.getOwnPropertyNames(i.state.subjects).length:1;if(o&&o>h){const l=[i],m=t||{};let g=0;for(;o>h;){g++,m.offset=a*g;const w=await this._request(s,m);o=w.total,l.push(w);const A=Object.getOwnPropertyNames(w.state.subjects).length;if(h+=A,A<a)break}let b={};for(let w=0;w<l.length;w++)i=l[w],i.state.subjects&&(b=Object.assign(b,i.state.subjects));i.offset=0,i.total=0,i.limit=0,i.state.subjects=b}return this._fixInfo(i),i}list(e=""){const t=e!=null&&e.length?{subject:e}:{},s=i=>{const o=i;return o.streams.forEach(a=>{this._fixInfo(a)}),o.streams},n=`${this.prefix}.STREAM.LIST`;return new Ct(n,s,this,t)}_fixInfo(e){e.config.sealed=e.config.sealed||!1,e.config.deny_delete=e.config.deny_delete||!1,e.config.deny_purge=e.config.deny_purge||!1,e.config.allow_rollup_hdrs=e.config.allow_rollup_hdrs||!1}async purge(e,t){if(t){const{keep:n,seq:i}=t;if(typeof n=="number"&&typeof i=="number")throw new Error("can specify one of keep or seq")}return te(e),await this._request(`${this.prefix}.STREAM.PURGE.${e}`,t)}async deleteMessage(e,t,s=!0){te(e);const n={seq:t};return s||(n.no_erase=!0),(await this._request(`${this.prefix}.STREAM.MSG.DELETE.${e}`,n)).success}async getMessage(e,t){te(e);const n=await this._request(`${this.prefix}.STREAM.MSG.GET.${e}`,t);return new Do(n)}find(e){return this.findStream(e)}listKvs(){const e=s=>{var h;const i=s.streams.filter(l=>l.config.name.startsWith(le));i.forEach(l=>{this._fixInfo(l)});let o="";return i.length&&(o=((h=this.nc.info)==null?void 0:h.cluster)??""),i.map(l=>new Lo(l,o))},t=`${this.prefix}.STREAM.LIST`;return new Ct(t,e,this)}listObjectStores(){const e=s=>{const i=s.streams.filter(a=>a.config.name.startsWith(tn));return i.forEach(a=>{this._fixInfo(a)}),i.map(a=>new Fs(a))},t=`${this.prefix}.STREAM.LIST`;return new Ct(t,e,this)}names(e=""){const t=e!=null&&e.length?{subject:e}:{},s=i=>i.streams,n=`${this.prefix}.STREAM.NAMES`;return new Ct(n,s,this,t)}async get(e){const t=await this.info(e);return Promise.resolve(new Nr(this,t))}}class Do{constructor(e){c(this,"_header");c(this,"smr");this.smr=e}get subject(){return this.smr.message.subject}get seq(){return this.smr.message.seq}get timestamp(){return this.smr.message.time}get time(){return new Date(Date.parse(this.timestamp))}get data(){return this.smr.message.data?this._parse(this.smr.message.data):se}get header(){if(!this._header)if(this.smr.message.hdrs){const e=this._parse(this.smr.message.hdrs);this._header=De.decode(e)}else this._header=Ie();return this._header}_parse(e){const t=atob(e),s=t.length,n=new Uint8Array(s);for(let i=0;i<s;i++)n[i]=t.charCodeAt(i);return n}json(e){return we(e).decode(this.data)}string(){return ae.decode(this.data)}}c(Do,"jc");class Vh{constructor(e){c(this,"api");this.api=e}get(e){return this.api.info(e).then(t=>new Nr(this.api,t))}}class Wh{constructor(e,t,s){c(this,"bucket");c(this,"sm");c(this,"prefixLen");this.bucket=e,this.prefixLen=t,this.sm=s}get key(){return this.sm.subject.substring(this.prefixLen)}get value(){return this.sm.data}get delta(){return 0}get created(){return this.sm.time}get revision(){return this.sm.seq}get operation(){return this.sm.header.get(Er)||"PUT"}get length(){const e=this.sm.header.get(Q.MessageSizeHdr)||"";return e!==""?parseInt(e,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class Yh{constructor(e,t,s){c(this,"bucket");c(this,"key");c(this,"sm");this.bucket=e,this.key=t,this.sm=s}get value(){return this.sm.data}get created(){return new Date(Zs(this.sm.info.timestampNanos))}get revision(){return this.sm.seq}get operation(){var e;return((e=this.sm.headers)==null?void 0:e.get(Er))||"PUT"}get delta(){return this.sm.info.pending}get length(){var t;const e=((t=this.sm.headers)==null?void 0:t.get(Q.MessageSizeHdr))||"";return e!==""?parseInt(e,10):this.sm.data.length}json(){return this.sm.json()}string(){return this.sm.string()}}class ys{constructor(e){c(this,"info");c(this,"hdrs");this.info=e}get name(){return this.info.name}get description(){return this.info.description??""}get headers(){return this.hdrs||(this.hdrs=De.fromRecord(this.info.headers||{})),this.hdrs}get options(){return this.info.options}get bucket(){return this.info.bucket}get chunks(){return this.info.chunks}get deleted(){return this.info.deleted??!1}get digest(){return this.info.digest}get mtime(){return this.info.mtime}get nuid(){return this.info.nuid}get size(){return this.info.size}get revision(){return this.info.revision}get metadata(){return this.info.metadata||{}}isLink(){var e,t;return((e=this.info.options)==null?void 0:e.link)!==void 0&&((t=this.info.options)==null?void 0:t.link)!==null}}function Ci(r){const e={name:r.name,description:r.description??"",options:r.options,metadata:r.metadata};if(r.headers){const t=r.headers;e.headers=t.toRecord()}return e}function Kh(){return new ReadableStream({pull(r){r.enqueue(new Uint8Array(0)),r.close()}})}class Nt{constructor(e,t,s){c(this,"jsm");c(this,"js");c(this,"stream");c(this,"name");this.name=e,this.jsm=t,this.js=s}_checkNotEmpty(e){return!e||e.length===0?{name:e,error:new Error("name cannot be empty")}:{name:e}}async info(e){const t=await this.rawInfo(e);return t?new ys(t):null}async list(){const e=[],t=await this.watch({ignoreDeletes:!0,includeHistory:!0});for await(const s of t){if(s===null)break;e.push(s)}return Promise.resolve(e)}async rawInfo(e){const{name:t,error:s}=this._checkNotEmpty(e);if(s)return Promise.reject(s);const n=this._metaSubject(t);try{const i=await this.jsm.streams.getMessage(this.stream,{last_by_subj:n}),a=we().decode(i.data);return a.revision=i.seq,a}catch(i){return i.code==="404"?null:Promise.reject(i)}}async _si(e){try{return await this.jsm.streams.info(this.stream,e)}catch(t){return t.code==="404"?null:Promise.reject(t)}}async seal(){let e=await this._si();return e===null?Promise.reject(new Error("object store not found")):(e.config.sealed=!0,e=await this.jsm.streams.update(this.stream,e.config),Promise.resolve(new Fs(e)))}async status(e){const t=await this._si(e);return t===null?Promise.reject(new Error("object store not found")):Promise.resolve(new Fs(t))}destroy(){return this.jsm.streams.delete(this.stream)}async _put(e,t,s){var J;const n=this.js.getOptions();s=s||{timeout:n.timeout},s.timeout=s.timeout||n.timeout,s.previousRevision=s.previousRevision??void 0;const{timeout:i,previousRevision:o}=s,a=this.js.nc.info,h=(a==null?void 0:a.max_payload)||1024;e=e||{},e.options=e.options||{};let l=((J=e.options)==null?void 0:J.max_chunk_size)||128*1024;l=l>h?h:l,e.options.max_chunk_size=l;const m=await this.info(e.name),{name:g,error:b}=this._checkNotEmpty(e.name);if(b)return Promise.reject(b);const w=Dt.next(),A=this._chunkSubject(w),k=this._metaSubject(g),R=Object.assign({bucket:this.name,nuid:w,size:0,chunks:0},Ci(e)),M=B(),N=[],U=new dt;try{const T=t?t.getReader():null,Te=new Si;for(;;){const{done:Ke,value:de}=T?await T.read():{done:!0,value:void 0};if(Ke){if(U.size()>0){const X=U.drain();Te.update(X),R.chunks++,R.size+=X.length,N.push(this.js.publish(A,X,{timeout:i}))}await Promise.all(N),N.length=0,R.mtime=new Date().toISOString();const ee=Te.digest("base64"),Ee=ee.length%3,Ne=Ee>0?"=".repeat(Ee):"";R.digest=`${Oi}${ee}${Ne}`,R.deleted=!1;const z=Ie();typeof o=="number"&&z.set(ke.ExpectedLastSubjectSequenceHdr,`${o}`),z.set(Q.RollupHdr,Q.RollupValueSubject);const ue=await this.js.publish(k,we().encode(R),{headers:z,timeout:i});if(R.revision=ue.seq,m)try{await this.jsm.streams.purge(this.stream,{filter:`$O.${this.name}.C.${m.nuid}`})}catch{}M.resolve(new ys(R));break}if(de)for(U.fill(de);U.size()>l;){R.chunks++,R.size+=l;const ee=U.drain(e.options.max_chunk_size);Te.update(ee),N.push(this.js.publish(A,ee,{timeout:i}))}}}catch(T){await this.jsm.streams.purge(this.stream,{filter:A}),M.reject(T)}return M}putBlob(e,t,s){function n(i){return new ReadableStream({pull(o){o.enqueue(i),o.close()}})}return t===null&&(t=new Uint8Array(0)),this.put(e,n(t),s)}put(e,t,s){var n;return(n=e==null?void 0:e.options)!=null&&n.link?Promise.reject(new Error("link cannot be set when putting the object in bucket")):this._put(e,t,s)}async getBlob(e){async function t(i){const o=new dt,a=i.getReader();for(;;){const{done:h,value:l}=await a.read();if(h)return o.drain();l&&l.length&&o.fill(l)}}const s=await this.get(e);if(s===null)return Promise.resolve(null);const n=await Promise.all([s.error,t(s.data)]);return n[0]?Promise.reject(n[0]):Promise.resolve(n[1])}async get(e){const t=await this.rawInfo(e);if(t===null||t.deleted)return Promise.resolve(null);if(t.options&&t.options.link){const m=t.options.link.name||"";if(m==="")throw new Error("link is a bucket");return(t.options.link.bucket!==this.name?await Nt.create(this.js,t.options.link.bucket):this).get(m)}const s=B(),n={info:new ys(t),error:s};if(t.size===0)return n.data=Kh(),s.resolve(null),Promise.resolve(n);let i;const o=qe();o.orderedConsumer();const a=new Si,h=`$O.${this.name}.C.${t.nuid}`,l=await this.js.subscribe(h,o);return(async()=>{for await(const m of l)if(m.data.length>0&&(a.update(m.data),i.enqueue(m.data)),m.info.pending===0){const g=a.digest("base64"),b=g.length%3,w=b>0?"=".repeat(b):"",A=`${Oi}${g}${w}`;A!==t.digest?i.error(new Error(`received a corrupt object, digests do not match received: ${t.digest} calculated ${A}`)):i.close(),l.unsubscribe()}})().then(()=>{s.resolve()}).catch(m=>{i.error(m),s.reject(m)}),n.data=new ReadableStream({start(m){i=m},cancel(){l.unsubscribe()}}),n}linkStore(e,t){if(!(t instanceof Nt))return Promise.reject("bucket required");const s=t,{name:n,error:i}=this._checkNotEmpty(e);if(i)return Promise.reject(i);const o={name:n,options:{link:{bucket:s.name}}};return this._put(o,null)}async link(e,t){const{name:s,error:n}=this._checkNotEmpty(e);if(n)return Promise.reject(n);if(t.deleted)return Promise.reject(new Error("src object is deleted"));if(t.isLink())return Promise.reject(new Error("src object is a link"));const i=await this.rawInfo(e);if(i!==null&&!i.deleted)return Promise.reject(new Error("an object already exists with that name"));const o={bucket:t.bucket,name:t.name},a={name:s,bucket:t.bucket,options:{link:o}};await this.js.publish(this._metaSubject(e),JSON.stringify(a));const h=await this.info(e);return Promise.resolve(h)}async delete(e){const t=await this.rawInfo(e);if(t===null)return Promise.resolve({purged:0,success:!1});t.deleted=!0,t.size=0,t.chunks=0,t.digest="";const s=we(),n=Ie();return n.set(Q.RollupHdr,Q.RollupValueSubject),await this.js.publish(this._metaSubject(t.name),s.encode(t),{headers:n}),this.jsm.streams.purge(this.stream,{filter:this._chunkSubject(t.nuid)})}async update(e,t={}){const s=await this.rawInfo(e);if(s===null)return Promise.reject(new Error("object not found"));if(s.deleted)return Promise.reject(new Error("cannot update meta for a deleted object"));t.name=t.name??s.name;const{name:n,error:i}=this._checkNotEmpty(t.name);if(i)return Promise.reject(i);if(e!==t.name){const h=await this.info(t.name);if(h&&!h.deleted)return Promise.reject(new Error("an object already exists with that name"))}t.name=n;const o=Object.assign({},s,Ci(t)),a=await this.js.publish(this._metaSubject(o.name),JSON.stringify(o));return e!==t.name&&await this.jsm.streams.purge(this.stream,{filter:this._metaSubject(e)}),Promise.resolve(a)}async watch(e={}){e.includeHistory=e.includeHistory??!1,e.ignoreDeletes=e.ignoreDeletes??!1;let t=!1;const s=new Y,n=this._metaSubjectAll();try{await this.jsm.streams.getMessage(this.stream,{last_by_subj:n})}catch(h){h.code==="404"?(s.push(null),t=!0):s.stop(h)}const i=we(),o=qe();o.orderedConsumer(),e.includeHistory?o.deliverLastPerSubject():(t=!0,o.deliverNew()),o.callback((h,l)=>{var m;if(h){s.stop(h);return}if(l!==null){const g=i.decode(l.data);g.deleted&&e.ignoreDeletes===!0||s.push(g),((m=l.info)==null?void 0:m.pending)===0&&!t&&(t=!0,s.push(null))}});const a=await this.js.subscribe(n,o);return s._data=a,s.iterClosed.then(()=>{a.unsubscribe()}),a.closed.then(()=>{s.stop()}).catch(h=>{s.stop(h)}),s}_chunkSubject(e){return`$O.${this.name}.C.${e}`}_metaSubject(e){return`$O.${this.name}.M.${It.encode(e)}`}_metaSubjectAll(){return`$O.${this.name}.M.>`}async init(e={}){try{this.stream=zh(this.name)}catch(n){return Promise.reject(n)}const t=(e==null?void 0:e.ttl)||0;delete e.ttl;const s=Object.assign({max_age:t},e);s.name=this.stream,s.allow_direct=!0,s.allow_rollup_hdrs=!0,s.discard=Ut.New,s.subjects=[`$O.${this.name}.C.>`,`$O.${this.name}.M.>`],e.placement&&(s.placement=e.placement),e.metadata&&(s.metadata=e.metadata),typeof e.compression=="boolean"&&(s.compression=e.compression?Be.S2:Be.None);try{await this.jsm.streams.info(s.name)}catch(n){n.message==="stream not found"&&await this.jsm.streams.add(s)}}static async create(e,t,s={}){const n=await e.jetstreamManager(),i=new Nt(t,n,e);return await i.init(s),Promise.resolve(i)}}class Xh{constructor(e){c(this,"js");c(this,"jsm");this.js=e}kv(e,t={}){const s=this.js,{ok:n,min:i}=s.nc.features.get(L.JS_KV);return n?t.bindOnly?Ft.bind(this.js,e):Ft.create(this.js,e,t):Promise.reject(new Error(`kv is only supported on servers ${i} or better`))}os(e,t={}){var o;if(typeof((o=crypto==null?void 0:crypto.subtle)==null?void 0:o.digest)!="function")return Promise.reject(new Error("objectstore: unable to calculate hashes - crypto.subtle.digest with sha256 support is required"));const s=this.js,{ok:n,min:i}=s.nc.features.get(L.JS_OBJECTSTORE);return n?Nt.create(this.js,e,t):Promise.reject(new Error(`objectstore is only supported on servers ${i} or better`))}}class sn extends Bt{constructor(t,s){super(t,s);c(this,"consumers");c(this,"streams");c(this,"consumerAPI");c(this,"streamAPI");this.consumerAPI=new Qs(t,s),this.streamAPI=new rn(t,s),this.consumers=new Fo(this.consumerAPI),this.streams=new Vh(this.streamAPI)}jetstreamManager(t){const s=Object.assign({checkAPI:t},this.opts);return this.nc.jetstreamManager(s)}get apiPrefix(){return this.prefix}get views(){return new Xh(this)}async publish(t,s=se,n){n=n||{},n.expect=n.expect||{};const i=(n==null?void 0:n.headers)||Ie();n&&(n.msgID&&i.set(ke.MsgIdHdr,n.msgID),n.expect.lastMsgID&&i.set(ke.ExpectedLastMsgIdHdr,n.expect.lastMsgID),n.expect.streamName&&i.set(ke.ExpectedStreamHdr,n.expect.streamName),typeof n.expect.lastSequence=="number"&&i.set(ke.ExpectedLastSeqHdr,`${n.expect.lastSequence}`),typeof n.expect.lastSubjectSequence=="number"&&i.set(ke.ExpectedLastSubjectSequenceHdr,`${n.expect.lastSubjectSequence}`));const o=n.timeout||this.timeout,a={};o&&(a.timeout=o),n&&(a.headers=i);let{retries:h,retry_delay:l}=n;h=h||1,l=l||250;let m;for(let b=0;b<h;b++)try{m=await this.nc.request(t,s,a);break}catch(w){if(w.code==="503"&&b+1<h)await qt(l);else throw w}const g=this.parseJsResponse(m);if(g.stream==="")throw j.errorForCode(P.JetStreamInvalidAck);return g.duplicate=g.duplicate?g.duplicate:!1,g}async pull(t,s,n=0){te(t),ct(s);let i=this.timeout;n>i&&(i=n),n=n<0?0:q(n);const o={batch:1,no_wait:n===0,expires:n},a=await this.nc.request(`${this.prefix}.CONSUMER.MSG.NEXT.${t}.${s}`,this.jc.encode(o),{noMux:!0,timeout:i}),h=ut(a);if(h)throw h;return Mt(a)}fetch(t,s,n={}){te(t),ct(s);let i=null;const o=(n.max_bytes??0)>0;let a=0;const h=o?n.max_bytes:0;let l=null;const m={};if(m.batch=n.batch||1,h){const N=this.nc.features.get(L.JS_PULL_MAX_BYTES);if(!N.ok)throw new Error(`max_bytes is only supported on servers ${N.min} or better`);m.max_bytes=h}m.no_wait=n.no_wait||!1,m.no_wait&&m.expires&&(m.expires=0);const g=n.expires||0;if(g&&(m.expires=q(g)),g===0&&m.no_wait===!1)throw new Error("expires or no_wait is required");const b=n.idle_heartbeat||0;b&&(m.idle_heartbeat=q(b),n.delay_heartbeat===!0&&(m.idle_heartbeat=q(b*4)));const w=new Y,A=m.batch;let k=0;w.protocolFilterFn=(N,U=!1)=>Ns(N.msg)?(l==null||l.work(),!1):!0,w.dispatchedFn=N=>{if(N){if(o&&(a+=N.data.length),k++,i&&N.info.pending===0)return;(w.getPending()===1&&N.info.pending===0||A===k||h>0&&a>=h)&&w.stop()}};const R=je(this.nc.options.inboxPrefix),M=this.nc.subscribe(R,{max:n.batch,callback:(N,U)=>{N===null&&(N=ut(U)),N!==null?(i&&(i.cancel(),i=null),Au(N)?w.stop(Bo(N)===null?void 0:N):w.stop(N)):(l==null||l.work(),w.received++,w.push(Mt(U)))}});return g&&(i=ft(g),i.catch(()=>{M.isClosed()||(M.drain().catch(()=>{}),i=null),l&&l.cancel()})),(async()=>{try{b&&(l=new en(b,N=>(w.push(()=>{w.err=new j(`${fe.IdleHeartbeatMissed}: ${N}`,P.JetStreamIdleHeartBeat)}),!0)))}catch{}await M.closed,i!==null&&(i.cancel(),i=null),l&&l.cancel(),w.stop()})().catch(),this.nc.publish(`${this.prefix}.CONSUMER.MSG.NEXT.${t}.${s}`,this.jc.encode(m),{reply:R}),w}async pullSubscribe(t,s=qe()){const n=await this._processOptions(t,s);if(n.ordered)throw new Error("pull subscribers cannot be be ordered");if(n.config.deliver_subject)throw new Error("consumer info specifies deliver_subject - pull consumers cannot have deliver_subject set");const i=n.config.ack_policy;if(i===V.None||i===V.All)throw new Error("ack policy for pull consumers must be explicit");const o=this._buildTypedSubscriptionOpts(n),a=new Zh(this,n.deliver,o);a.info=n;try{await this._maybeCreateConsumer(n)}catch(h){throw a.unsubscribe(),h}return a}async subscribe(t,s=qe()){const n=await this._processOptions(t,s);if(!n.isBind&&!n.config.deliver_subject)throw new Error("push consumer requires deliver_subject");const i=this._buildTypedSubscriptionOpts(n),o=new qo(this,n.deliver,i);o.info=n;try{await this._maybeCreateConsumer(n)}catch(a){throw o.unsubscribe(),a}return o._maybeSetupHbMonitoring(),o}async _processOptions(t,s=qe()){const n=xi(s)?s.getOpts():s;if(n.isBind=xi(s)?s.isBind:!1,n.flow_control={heartbeat_count:0,fc_count:0,consumer_restarts:0},n.ordered){if(n.ordered_consumer_sequence={stream_seq:0,delivery_seq:0},n.config.ack_policy!==V.NotSet&&n.config.ack_policy!==V.None)throw new j("ordered consumer: ack_policy can only be set to 'none'",P.ApiError);if(n.config.durable_name&&n.config.durable_name.length>0)throw new j("ordered consumer: durable_name cannot be set",P.ApiError);if(n.config.deliver_subject&&n.config.deliver_subject.length>0)throw new j("ordered consumer: deliver_subject cannot be set",P.ApiError);if(n.config.max_deliver!==void 0&&n.config.max_deliver>1)throw new j("ordered consumer: max_deliver cannot be set",P.ApiError);if(n.config.deliver_group&&n.config.deliver_group.length>0)throw new j("ordered consumer: deliver_group cannot be set",P.ApiError);n.config.deliver_subject=je(this.nc.options.inboxPrefix),n.config.ack_policy=V.None,n.config.max_deliver=1,n.config.flow_control=!0,n.config.idle_heartbeat=n.config.idle_heartbeat||q(5e3),n.config.ack_wait=q(22*60*60*1e3),n.config.mem_storage=!0,n.config.num_replicas=1}if(n.config.ack_policy===V.NotSet&&(n.config.ack_policy=V.All),n.api=this,n.config=n.config||{},n.stream=n.stream?n.stream:await this.findStream(t),n.attached=!1,n.config.durable_name)try{const i=await this.consumerAPI.info(n.stream,n.config.durable_name);if(i){if(i.config.filter_subject&&i.config.filter_subject!==t)throw new Error("subject does not match consumer");const o=n.config.deliver_group??"";if(o===""&&i.push_bound===!0)throw new Error("duplicate subscription");const a=i.config.deliver_group??"";if(o!==a)throw a===""?new Error("durable requires no queue group"):new Error(`durable requires queue group '${a}'`);n.last=i,n.config=i.config,n.attached=!0,n.config.durable_name||(n.name=i.name)}}catch(i){if(i.code!=="404")throw i}return!n.attached&&n.config.filter_subject===void 0&&n.config.filter_subjects===void 0&&(n.config.filter_subject=t),n.deliver=n.config.deliver_subject||je(this.nc.options.inboxPrefix),n}_buildTypedSubscriptionOpts(t){const s={};return s.adapter=Qh(t.callbackFn===void 0),s.ingestionFilterFn=sn.ingestionFn(t.ordered),s.protocolFilterFn=(n,i=!1)=>{const o=n;return Ts(o.msg)?(i||o.msg.respond(),!1):!0},!t.mack&&t.config.ack_policy!==V.None&&(s.dispatchedFn=rl),t.callbackFn&&(s.callback=t.callbackFn),s.max=t.max||0,s.queue=t.queue,s}async _maybeCreateConsumer(t){if(t.attached)return;if(t.isBind)throw new Error(`unable to bind - durable consumer ${t.config.durable_name} doesn't exist in ${t.stream}`);t.config=Object.assign({deliver_policy:H.All,ack_policy:V.Explicit,ack_wait:q(30*1e3),replay_policy:pt.Instant},t.config);const s=await this.consumerAPI.add(t.stream,t.config);if(Array.isArray(t.config.filter_subjects&&!Array.isArray(s.config.filter_subjects)))throw new Error("jetstream server doesn't support consumers with multiple filter subjects");t.name=s.name,t.config=s.config,t.last=s}static ingestionFn(t){return(s,n)=>{var h;const i=n;if(!s)return{ingest:!1,protocol:!1};const o=s;if(ut(o.msg)||(h=i.monitor)==null||h.work(),Ns(o.msg)){const l=t?i._checkHbOrderConsumer(o.msg):!0;return t||i.info.flow_control.heartbeat_count++,{ingest:l,protocol:!0}}else if(Ts(o.msg))return i.info.flow_control.fc_count++,{ingest:!0,protocol:!0};return{ingest:t?i._checkOrderedConsumer(s):!0,protocol:!1}}}}class qo extends Mh{constructor(t,s,n){super(t.nc,s,n);c(this,"js");c(this,"monitor");this.js=t,this.monitor=null,this.sub.closed.then(()=>{this.monitor&&this.monitor.cancel()})}set info(t){this.sub.info=t}get info(){return this.sub.info}_resetOrderedConsumer(t){if(this.info===null||this.sub.isClosed())return;const s=je(this.js.nc.options.inboxPrefix);this.js.nc._resub(this.sub,s);const i=this.info;i.ordered_consumer_sequence.delivery_seq=0,i.flow_control.heartbeat_count=0,i.flow_control.fc_count=0,i.flow_control.consumer_restarts++,i.deliver=s,i.config.deliver_subject=s,i.config.deliver_policy=H.StartSequence,i.config.opt_start_seq=t;const o={};o.stream_name=this.info.stream,o.config=i.config;const a=`${i.api.prefix}.CONSUMER.CREATE.${i.stream}`;this.js._request(a,o).then(h=>{const l=h;this.info.config=l.config,this.info.name=l.name}).catch(h=>{const l=new j(`unable to recreate ordered consumer ${i.stream} at seq ${t}`,P.RequestError,h);this.sub.callback(l,{})})}_maybeSetupHbMonitoring(){var s,n;const t=((n=(s=this.info)==null?void 0:s.config)==null?void 0:n.idle_heartbeat)||0;t&&this._setupHbMonitoring(Zs(t))}_setupHbMonitoring(t,s=0){const n={cancelAfter:0,maxOut:2};s&&(n.cancelAfter=s);const i=this.sub,o=a=>{var m,g,b;const h=ph(409,`${fe.IdleHeartbeatMissed}: ${a}`,this.sub.subject);if(!((m=this.info)==null?void 0:m.ordered))this.sub.callback(null,h);else{if(!this.js.nc.protocol.connected)return!1;const w=((b=(g=this.info)==null?void 0:g.ordered_consumer_sequence)==null?void 0:b.stream_seq)||0;return this._resetOrderedConsumer(w+1),!1}return!i.noIterator};this.monitor=new en(t,o,n)}_checkHbOrderConsumer(t){const s=t.headers.get(Q.ConsumerStalledHdr);s!==""&&this.js.nc.publish(s);const n=parseInt(t.headers.get(Q.LastConsumerSeqHdr),10),i=this.info.ordered_consumer_sequence;return this.info.flow_control.heartbeat_count++,n!==i.delivery_seq&&this._resetOrderedConsumer(i.stream_seq+1),!1}_checkOrderedConsumer(t){const s=this.info.ordered_consumer_sequence,n=t.info.streamSequence,i=t.info.deliverySequence;return i!=s.delivery_seq+1?(this._resetOrderedConsumer(s.stream_seq+1),!1):(s.delivery_seq=i,s.stream_seq=n,!0)}async destroy(){this.isClosed()||await this.drain();const t=this.sub.info,s=t.config.durable_name||t.name,n=`${t.api.prefix}.CONSUMER.DELETE.${t.stream}.${s}`;await t.api._request(n)}async consumerInfo(){const t=this.sub.info,s=t.config.durable_name||t.name,n=`${t.api.prefix}.CONSUMER.INFO.${t.stream}.${s}`,i=await t.api._request(n);return t.last=i,i}}class Zh extends qo{constructor(e,t,s){super(e,t,s)}pull(e={batch:1}){const{stream:t,config:s,name:n}=this.sub.info,i=s.durable_name??n,o={};if(o.batch=e.batch||1,o.no_wait=e.no_wait||!1,(e.max_bytes??0)>0){const l=this.js.nc.features.get(L.JS_PULL_MAX_BYTES);if(!l.ok)throw new Error(`max_bytes is only supported on servers ${l.min} or better`);o.max_bytes=e.max_bytes}let a=0;e.expires&&e.expires>0&&(a=e.expires,o.expires=q(a));let h=0;if(e.idle_heartbeat&&e.idle_heartbeat>0&&(h=e.idle_heartbeat,o.idle_heartbeat=q(h)),h&&a===0)throw new Error("idle_heartbeat requires expires");if(h>a)throw new Error("expires must be greater than idle_heartbeat");if(this.info){this.monitor&&this.monitor.cancel(),a&&h&&(this.monitor?this.monitor._change(h,a):this._setupHbMonitoring(h,a));const l=this.info.api,m=`${l.prefix}.CONSUMER.MSG.NEXT.${t}.${i}`,g=this.sub.subject;l.nc.publish(m,l.jc.encode(o),{reply:g})}}}function Qh(r){return r?tl:el}function el(r,e){return r?[r,null]:(r=ut(e),r?[r,null]:[null,Mt(e)])}function tl(r,e){if(r)return[r,null];const t=ut(e);return t!==null?[Bo(t),null]:[null,Mt(e)]}function Bo(r){if(r!==null)switch(r.code){case P.JetStream404NoMessages:case P.JetStream408RequestTimeout:return null;case P.JetStream409:return mh(r)?r:null;default:return r}return null}function rl(r){r&&r.ack()}class sl extends Bt{constructor(e,t){super(e,t)}async getMessage(e,t){te(e);let s=t;const{last_by_subj:n}=s;n&&(s=null);const i=s?this.jc.encode(s):se,o=this.opts.apiPrefix||"$JS.API",a=n?`${o}.DIRECT.GET.${e}.${n}`:`${o}.DIRECT.GET.${e}`,h=await this.nc.request(a,i),l=ut(h);if(l)return Promise.reject(l);const m=new Ho(h);return Promise.resolve(m)}}class Ho{constructor(e){c(this,"data");c(this,"header");if(!e.headers)throw new Error("headers expected");this.data=e.data,this.header=e.headers}get subject(){return this.header.last(it.Subject)}get seq(){const e=this.header.last(it.Sequence);return typeof e=="string"?parseInt(e):0}get time(){return new Date(Date.parse(this.timestamp))}get timestamp(){return this.header.last(it.TimeStamp)}get stream(){return this.header.last(it.Stream)}json(e){return we(e).decode(this.data)}string(){return ae.decode(this.data)}}c(Ho,"jc");class nl extends Bt{constructor(t,s){super(t,s);c(this,"streams");c(this,"consumers");c(this,"direct");this.streams=new rn(t,s),this.consumers=new Qs(t,s),this.direct=new sl(t,s)}async getAccountInfo(){return await this._request(`${this.prefix}.INFO`)}jetstream(){return this.nc.jetstream(this.getOptions())}advisories(){const t=new Y;return this.nc.subscribe("$JS.EVENT.ADVISORY.>",{callback:(s,n)=>{if(s)throw s;try{const i=this.parseJsResponse(n),o=i.type.split("."),a=o[o.length-1];t.push({kind:a,data:i})}catch(i){t.stop(i)}}}),t}}const il="$SRV";class ki{constructor(e){c(this,"msg");this.msg=e}get data(){return this.msg.data}get sid(){return this.msg.sid}get subject(){return this.msg.subject}get reply(){return this.msg.reply||""}get headers(){return this.msg.headers}respond(e,t){return this.msg.respond(e,t)}respondError(e,t,s,n){var i,o;return n=n||{},n.headers=n.headers||Ie(),(i=n.headers)==null||i.set(_r,`${e}`),(o=n.headers)==null||o.set(gr,t),this.msg.respond(s,n)}json(e){return this.msg.json(e)}string(){return this.msg.string()}}class $t{constructor(e,t="",s=""){c(this,"subject");c(this,"queue");c(this,"srv");t!==""&&al("service group",t);let n="";if(e instanceof Ht)this.srv=e,n="";else if(e instanceof $t){const i=e;this.srv=i.srv,s===""&&i.queue!==""&&(s=i.queue),n=i.subject}else throw new Error("unknown ServiceGroup type");this.subject=this.calcSubject(n,t),this.queue=s}calcSubject(e,t=""){return t===""?e:e!==""?`${e}.${t}`:t}addEndpoint(e="",t){t=t||{subject:e};const s=typeof t=="function"?{handler:t,subject:e}:t;Ot("endpoint",e);let{subject:n,handler:i,metadata:o,queue:a}=s;n=n||e,a=a||this.queue,ol("endpoint subject",n),n=this.calcSubject(this.subject,n);const h={name:e,subject:n,queue:a,handler:i,metadata:o};return this.srv._addEndpoint(h)}addGroup(e="",t=""){return new $t(this,e,t)}}function ol(r,e){if(e==="")throw new Error(`${r} cannot be empty`);if(e.indexOf(" ")!==-1)throw new Error(`${r} cannot contain spaces: '${e}'`);const t=e.split(".");t.forEach((s,n)=>{if(s===">"&&n!==t.length-1)throw new Error(`${r} cannot have internal '>': '${e}'`)})}function al(r,e){if(e.indexOf(" ")!==-1)throw new Error(`${r} cannot contain spaces: '${e}'`);e.split(".").forEach(s=>{if(s===">")throw new Error(`${r} name cannot contain internal '>': '${e}'`)})}class Ht{constructor(e,t={name:"",version:""}){c(this,"nc");c(this,"_id");c(this,"config");c(this,"handlers");c(this,"internal");c(this,"_stopped");c(this,"_done");c(this,"started");this.nc=e,this.config=Object.assign({},t),this.config.queue||(this.config.queue="q"),Ot("name",this.config.name),Ot("queue",this.config.queue),Ve(this.config.version),this._id=Dt.next(),this.internal=[],this._done=B(),this._stopped=!1,this.handlers=[],this.started=new Date().toISOString(),this.reset(),this.nc.closed().then(()=>{this.close().catch()}).catch(s=>{this.close(s).catch()})}static controlSubject(e,t="",s="",n){const i=n??il;return t===""&&s===""?`${i}.${e}`:(Ot("control subject name",t),s!==""?(Ot("control subject id",s),`${i}.${e}.${t}.${s}`):`${i}.${e}.${t}`)}get subjects(){return this.handlers.filter(e=>e.internal===!1).map(e=>e.subject)}get id(){return this._id}get name(){return this.config.name}get description(){return this.config.description??""}get version(){return this.config.version}get metadata(){return this.config.metadata}errorToHeader(e){const t=Ie();if(e instanceof yr){const s=e;t.set(gr,s.message),t.set(_r,`${s.code}`)}else t.set(gr,e.message),t.set(_r,"500");return t}setupHandler(e,t=!1){const s=t?"":e.queue?e.queue:this.config.queue,{name:n,subject:i,handler:o}=e,a=e;a.internal=t,t&&this.internal.push(a),a.stats=new cl(n,i,s),a.queue=s;const h=o?(l,m)=>{if(l){this.close(l);return}const g=Date.now();try{o(l,new ki(m))}catch(b){a.stats.countError(b),m==null||m.respond(se,{headers:this.errorToHeader(b)})}finally{a.stats.countLatency(g)}}:void 0;return a.sub=this.nc.subscribe(i,{callback:h,queue:s}),a.sub.closed.then(()=>{this._stopped||this.close(new Error(`required subscription ${e.subject} stopped`)).catch()}).catch(l=>{if(!this._stopped){const m=new Error(`required subscription ${e.subject} errored: ${l.message}`);m.stack=l.stack,this.close(m).catch()}}),a}info(){return{type:Rt.INFO,name:this.name,id:this.id,version:this.version,description:this.description,metadata:this.metadata,endpoints:this.endpoints()}}endpoints(){return this.handlers.map(e=>{const{subject:t,metadata:s,name:n,queue:i}=e;return{subject:t,metadata:s,name:n,queue_group:i}})}async stats(){const e=[];for(const t of this.handlers){if(typeof this.config.statsHandler=="function")try{t.stats.data=await this.config.statsHandler(t)}catch(s){t.stats.countError(s)}e.push(t.stats.stats(t.qi))}return{type:Rt.STATS,name:this.name,id:this.id,version:this.version,started:this.started,metadata:this.metadata,endpoints:e}}addInternalHandler(e,t){const s=`${e}`.toUpperCase();this._doAddInternalHandler(`${s}-all`,e,t),this._doAddInternalHandler(`${s}-kind`,e,t,this.name),this._doAddInternalHandler(`${s}`,e,t,this.name,this.id)}_doAddInternalHandler(e,t,s,n="",i=""){const o={};o.name=e,o.subject=Ht.controlSubject(t,n,i),o.handler=s,this.setupHandler(o,!0)}start(){const e=we(),t=(o,a)=>o?(this.close(o),Promise.reject(o)):this.stats().then(h=>(a==null||a.respond(e.encode(h)),Promise.resolve())),s=(o,a)=>o?(this.close(o),Promise.reject(o)):(a==null||a.respond(e.encode(this.info())),Promise.resolve()),n=e.encode(this.ping()),i=(o,a)=>o?(this.close(o).then().catch(),Promise.reject(o)):(a.respond(n),Promise.resolve());return this.addInternalHandler(Le.PING,i),this.addInternalHandler(Le.STATS,t),this.addInternalHandler(Le.INFO,s),this.handlers.forEach(o=>{const{subject:a}=o;typeof a=="string"&&o.handler!==null&&this.setupHandler(o)}),Promise.resolve(this)}close(e){if(this._stopped)return this._done;this._stopped=!0;let t=[];return this.nc.isClosed()||(t=this.handlers.concat(this.internal).map(s=>s.sub.drain())),Promise.allSettled(t).then(()=>{this._done.resolve(e||null)}),this._done}get stopped(){return this._done}get isStopped(){return this._stopped}stop(e){return this.close(e)}ping(){return{type:Rt.PING,name:this.name,id:this.id,version:this.version,metadata:this.metadata}}reset(){if(this.started=new Date().toISOString(),this.handlers)for(const e of this.handlers)e.stats.reset(e.qi)}addGroup(e,t){return new $t(this,e,t)}addEndpoint(e,t){return new $t(this).addEndpoint(e,t)}_addEndpoint(e){const t=new Y;t.noIterator=typeof e.handler=="function",t.noIterator||(e.handler=(n,i)=>{n?this.stop(n).catch():t.push(new ki(i))},t.iterClosed.then(()=>{this.close().catch()}));const s=this.setupHandler(e,!1);return s.qi=t,this.handlers.push(s),t}}class cl{constructor(e,t,s=""){c(this,"name");c(this,"subject");c(this,"average_processing_time");c(this,"num_requests");c(this,"processing_time");c(this,"num_errors");c(this,"last_error");c(this,"data");c(this,"metadata");c(this,"queue");this.name=e,this.subject=t,this.average_processing_time=0,this.num_errors=0,this.num_requests=0,this.processing_time=0,this.queue=s}reset(e){this.num_requests=0,this.processing_time=0,this.average_processing_time=0,this.num_errors=0,this.last_error=void 0,this.data=void 0;const t=e;t&&(t.time=0,t.processed=0)}countLatency(e){this.num_requests++,this.processing_time+=q(Date.now()-e),this.average_processing_time=Math.round(this.processing_time/this.num_requests)}countError(e){this.num_errors++,this.last_error=e.message}_stats(){const{name:e,subject:t,average_processing_time:s,num_errors:n,num_requests:i,processing_time:o,last_error:a,data:h,queue:l}=this;return{name:e,subject:t,average_processing_time:s,num_errors:n,num_requests:i,processing_time:o,last_error:a,data:h,queue_group:l}}stats(e){const t=e;return(t==null?void 0:t.noIterator)===!1&&(this.processing_time=t.time,this.num_requests=t.processed,this.average_processing_time=this.processing_time>0&&this.num_requests>0?this.processing_time/this.num_requests:0),this._stats()}}class ul{constructor(e,t={strategy:Se.JitterTimer,maxWait:2e3},s){c(this,"nc");c(this,"prefix");c(this,"opts");this.nc=e,this.prefix=s,this.opts=t}ping(e="",t=""){return this.q(Le.PING,e,t)}stats(e="",t=""){return this.q(Le.STATS,e,t)}info(e="",t=""){return this.q(Le.INFO,e,t)}async q(e,t="",s=""){const n=new Y,i=we(),o=Ht.controlSubject(e,t,s,this.prefix),a=await this.nc.requestMany(o,se,this.opts);return(async()=>{for await(const h of a)try{const l=i.decode(h.data);n.push(l)}catch(l){n.push(()=>{n.stop(l)})}n.push(()=>{n.stop()})})().catch(h=>{n.stop(h)}),n}}class nn{constructor(e){c(this,"options");c(this,"protocol");c(this,"draining");c(this,"listeners");c(this,"_services");this.draining=!1,this.options=ih(e),this.listeners=[]}static connect(e={}){return new Promise((t,s)=>{const n=new nn(e);vr.connect(n.options,n).then(i=>{n.protocol=i,async function(){for await(const o of i.status())n.listeners.forEach(a=>{a.push(o)})}(),t(n)}).catch(i=>{s(i)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}_check(e,t,s){if(this.isClosed())throw j.errorForCode(P.ConnectionClosed);if(t&&this.isDraining()||s&&this.protocol.noMorePublishing)throw j.errorForCode(P.ConnectionDraining);if(e=e||"",e.length===0)throw j.errorForCode(P.BadSubject)}publish(e,t,s){this._check(e,!1,!0),this.protocol.publish(e,t,s)}subscribe(e,t={}){this._check(e,!0,!1);const s=new Ro(this.protocol,e,t);return this.protocol.subscribe(s),s}_resub(e,t,s){this._check(t,!0,!1);const n=e;n.max=s,s&&(n.max=s+n.received),this.protocol.resub(n,t)}requestMany(e,t=se,s={maxWait:1e3,maxMessages:-1}){const n=!this.protocol.options.noAsyncTraces;try{this._check(e,!0,!0)}catch(h){return Promise.reject(h)}if(s.strategy=s.strategy||Se.Timer,s.maxWait=s.maxWait||1e3,s.maxWait<1)return Promise.reject(new j("timeout",P.InvalidOption));const i=new Y;function o(h){i.push(()=>{i.stop(h)})}function a(h,l){h||l===null?o(h===null?void 0:h):i.push(l)}if(s.noMux){const h=n?new Error().stack:null;let l=typeof s.maxMessages=="number"&&s.maxMessages>0?s.maxMessages:-1;const m=this.subscribe(je(this.options.inboxPrefix),{callback:(A,k)=>{var R,M;if(((R=k==null?void 0:k.data)==null?void 0:R.length)===0&&((M=k==null?void 0:k.headers)==null?void 0:M.status)===P.NoResponders&&(A=j.errorForCode(P.NoResponders)),A){h&&(A.stack+=`
  28. ${h}`),g(A);return}a(null,k),s.strategy===Se.Count&&(l--,l===0&&g()),s.strategy===Se.JitterTimer&&(w(),b=setTimeout(()=>{g()},300)),s.strategy===Se.SentinelMsg&&k&&k.data.length===0&&g()}});m.closed.then(()=>{o()}).catch(A=>{i.stop(A)});const g=A=>{A&&i.push(()=>{throw A}),w(),m.drain().then(()=>{o()}).catch(k=>{o()})};i.iterClosed.then(()=>{w(),m==null||m.unsubscribe()}).catch(A=>{w(),m==null||m.unsubscribe()});try{this.publish(e,t,{reply:m.getSubject()})}catch(A){g(A)}let b=setTimeout(()=>{g()},s.maxWait);const w=()=>{b&&clearTimeout(b)}}else{const h=s;h.callback=a,i.iterClosed.then(()=>{l.cancel()}).catch(m=>{l.cancel(m)});const l=new fh(this.protocol.muxSubscriptions,e,h);this.protocol.request(l);try{this.publish(e,t,{reply:`${this.protocol.muxSubscriptions.baseInbox}${l.token}`,headers:s.headers})}catch(m){l.cancel(m)}}return Promise.resolve(i)}request(e,t,s={timeout:1e3,noMux:!1}){try{this._check(e,!0,!0)}catch(i){return Promise.reject(i)}const n=!this.protocol.options.noAsyncTraces;if(s.timeout=s.timeout||1e3,s.timeout<1)return Promise.reject(new j("timeout",P.InvalidOption));if(!s.noMux&&s.reply)return Promise.reject(new j("reply can only be used with noMux",P.InvalidOption));if(s.noMux){const i=s.reply?s.reply:je(this.options.inboxPrefix),o=B(),a=n?new Error:null,h=this.subscribe(i,{max:1,timeout:s.timeout,callback:(l,m)=>{l?(a&&l.code!==P.Timeout&&(l.stack+=`
  29. ${a.stack}`),o.reject(l)):(l=Oo(m),l?(a&&(l.stack+=`
  30. ${a.stack}`),o.reject(l)):o.resolve(m))}});return h.requestSubject=e,this.protocol.publish(e,t,{reply:i,headers:s.headers}),o}else{const i=new Io(this.protocol.muxSubscriptions,e,s,n);this.protocol.request(i);try{this.publish(e,t,{reply:`${this.protocol.muxSubscriptions.baseInbox}${i.token}`,headers:s.headers})}catch(a){i.cancel(a)}const o=Promise.race([i.timer,i.deferred]);return o.catch(()=>{i.cancel()}),o}}flush(){return this.isClosed()?Promise.reject(j.errorForCode(P.ConnectionClosed)):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(j.errorForCode(P.ConnectionClosed)):this.isDraining()?Promise.reject(j.errorForCode(P.ConnectionDraining)):(this.draining=!0,this.protocol.drain())}isClosed(){return this.protocol.isClosed()}isDraining(){return this.draining}getServer(){const e=this.protocol.getServer();return e?e.listen:""}status(){const e=new Y;return e.iterClosed.then(()=>{const t=this.listeners.indexOf(e);this.listeners.splice(t,1)}),this.listeners.push(e),e}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}async jetstreamManager(e={}){const t=new nl(this,e);if(e.checkAPI!==!1)try{await t.getAccountInfo()}catch(s){const n=s;throw n.code===P.NoResponders&&(n.code=P.JetStreamNotEnabled),n}return t}jetstream(e={}){return new sn(this,e)}getServerVersion(){const e=this.info;return e?Ve(e.version):void 0}async rtt(){if(!this.protocol._closed&&!this.protocol.connected)throw j.errorForCode(P.Disconnect);const e=Date.now();return await this.flush(),Date.now()-e}get features(){return this.protocol.features}get services(){return this._services||(this._services=new hl(this)),this._services}reconnect(){return this.isClosed()?Promise.reject(j.errorForCode(P.ConnectionClosed)):this.isDraining()?Promise.reject(j.errorForCode(P.ConnectionDraining)):this.protocol.reconnect()}}class hl{constructor(e){c(this,"nc");this.nc=e}add(e){try{return new Ht(this.nc,e).start()}catch(t){return Promise.reject(t)}}client(e,t){return new ul(this.nc,e,t)}}const ll="1.19.1",fl="nats.ws";class dl{constructor(){c(this,"version");c(this,"lang");c(this,"closeError");c(this,"connected");c(this,"done");c(this,"socket");c(this,"options");c(this,"socketClosed");c(this,"encrypted");c(this,"peeked");c(this,"yields");c(this,"signal");c(this,"closedNotification");this.version=ll,this.lang=fl,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=B(),this.closedNotification=B()}async connect(e,t){const s=B();if(t.tls)return s.reject(new j("tls",P.InvalidOption)),s;this.options=t;const n=e.src;if(t.wsFactory){const{socket:i,encrypted:o}=await t.wsFactory(e.src,t);this.socket=i,this.encrypted=o}else this.encrypted=n.indexOf("wss://")===0,this.socket=new WebSocket(n);return this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{this.isDiscarded()},this.socket.onmessage=i=>{if(this.isDiscarded())return;if(this.yields.push(new Uint8Array(i.data)),this.peeked){this.signal.resolve();return}const o=dt.concat(...this.yields),a=Tu(o);if(a!==""){const h=ch.exec(a);if(!h){t.debug&&console.error("!!!",sr(o)),s.reject(new Error("unexpected response from server"));return}try{const l=JSON.parse(h[1]);oh(l,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),s.resolve()}catch(l){s.reject(l);return}}},this.socket.onclose=i=>{if(this.isDiscarded())return;this.socketClosed=!0;let o;this.done||(i.wasClean||(o=new Error(i.reason)),this._closed(o))},this.socket.onerror=i=>{if(this.isDiscarded())return;const o=i,a=new j(o.message,P.Unknown,new Error(o.error));s.reject(a)},s}disconnect(){this._closed(void 0,!0)}async _closed(e,t=!0){if(!this.isDiscarded()&&this.connected&&!this.done){if(this.closeError=e,!e)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await qt(100);this.done=!0;try{this.socket.close(e?1002:1e3,e?e.message:void 0)}catch{}t&&this.closedNotification.resolve(e)}}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.isDiscarded())return;this.yields.length===0&&await this.signal;const e=this.yields;this.yields=[];for(let t=0;t<e.length;t++)this.options.debug&&console.info(`> ${sr(e[t])}`),yield e[t];if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=B())}}isEncrypted(){return this.connected&&this.encrypted}send(e){if(!this.isDiscarded())try{this.socket.send(e.buffer),this.options.debug&&console.info(`< ${sr(e)}`);return}catch(t){this.options.debug&&console.error(`!!! ${sr(e)}: ${t}`)}}close(e){return this._closed(e,!1)}closed(){return this.closedNotification}isDiscarded(){return this.done?(this.discard(),!0):!1}discard(){var e;this.done=!0;try{(e=this.socket)==null||e.close()}catch{}}}function pl(r){/^(.*:\/\/)(.*)/.test(r)||(r=`https://${r}`);let t=new URL(r);const s=t.protocol.toLowerCase();s!=="https:"&&s!=="http"&&(r=r.replace(/^(.*:\/\/)(.*)/gm,"$2"),t=new URL(`http://${r}`));let n,i;const o=t.hostname,a=t.pathname,h=t.search||"";switch(s){case"http:":case"ws:":case"nats:":i=t.port||"80",n="ws:";break;default:i=t.port||"443",n="wss:";break}return`${n}//${o}:${i}${a}${h}`}function ml(r={}){return Cu({defaultPort:443,urlParseFn:pl,factory:()=>new dl}),nn.connect(r)}class bl extends Rr{constructor(){super(...arguments);c(this,"_conn");c(this,"_isConned",!1);c(this,"_startInit",!1)}async onReady(){await this.initConn()}async initConn(){if(this._startInit)return;this._startInit=!0,Me.show("服务连接中...");const{deviceCtrl:t}=ye(),s=await t.GetNatsProfile(),n=`nats://${s.ip}:${s.wsPort}`;console.log("ws host=>",n);let i=!1;try{this._conn=await ml({servers:n}),this._isConned=!!this._conn,i=!0}catch(o){console.log(o),ar.error("连接失败!")}return Me.hidden(),this._startInit=!1,i}async GetConn(){return this._conn}async subscribe(t,s,n={}){if(!this._isConned){console.error("建立连接失败");return}const i=xr(),o=this._conn.subscribe(t,n);return(async()=>{for await(const a of o){const h=i.decode(a.data);console.log(t,"=>recieved");try{if(h&&h[0]=="{"){const l=JSON.parse(h);s(l)}else s(h)}catch(l){console.log(t,"=>recieved json parse eror",h),console.log(l)}}console.log(t,"subscription closed")})(),function(){o.unsubscribe()}}async requestApi(t,s,n){const i=await this.request(t,s,n);if(console.log("request api=>",i),i.error||i.result.ErrorNo&&i.result.ErrorNo!=200){ar.error(i.error||i.result.ErrorDesc);return}try{const o=i.result.Result;return o?o[0]!="{"&&o[0]!="["?o:JSON.parse(o):void 0}catch(o){console.log(i),console.error(o)}}async request(t,s,n){const i={error:"",result:null};if(!this._isConned)return console.error("建立连接失败"),i.error="建立连接失败",ar.error("请求数据失败,请重新启动后再试!"),i;const o=xr();try{let a=se;s&&(typeof s!="string"?a=o.encode(JSON.stringify(s)):a=o.encode(s));const h={timeout:5e3};n&&(h.timeout=n);const l=await this._conn.request(t,a,h);let m=o.decode(l.data);try{m=JSON.parse(m),console.log("m=>",m)}catch(g){console.log(g)}i.result=m}catch(a){console.error(a),i.error=a.message||"请求"+t+"出错",i.error=="503"&&(i.error="网路异常,请重启服务")}return i}close(){if(this._isConned)return this._conn.close()}}const Ar={prjCtrl:new ru,deviceCtrl:new tu,installCtrl:new _u,natsCtrl:new bl};let ws=["deviceCtrl","natsCtrl","prjCtrl","installCtrl"],gl=Object.keys(Ar),Ri=[];async function _l(){console.log("begin init ");let r=ws.length;for(let t=0;t<r;t++)await Ar[ws[t]].onReady();const e=gl.slice(0);for(;r--;)ws.indexOf(e[r])!=-1&&e.splice(r,1);if(Ri.length>0)for(r=e.length;r--;)Ri.indexOf(e[r])!=-1&&e.splice(r,1);e.forEach(t=>{Ar[t].onReady()}),console.log("end init")}function ye(){return Ar}const yl=ji(()=>{const r=Ii({loading:!0});try{_l().then(()=>{r.loading=!1})}catch{r.loading=!0,alert("控制器初始化失败! 请在app中打开当前页面")}return()=>r.loading?Ge("div",{class:"pt-40px text-center"},[Ge(ua,{tip:"初始加载中..."},null)]):Ge(la,null,{default:()=>[Ge(ha("router-view"),null,null)]})}),wl=fa({history:da(),routes:[{path:"/",name:"home",component:()=>xn(()=>import("./index-fae1c727.js"),["./index-fae1c727.js","./image-e1abec51.js","./main-4801cc52.js","./main-f8bd3d55.css","./index-f79a4cc5.js","./index-33c9ec48.js","./useFlexGapSupport-310043de.js","./dayjs.min-486c7a11.js","./index-00053b44.js","./Col-7508b53a.js","./index-2d379a5b.js","./index-149ee1ea.css"],import.meta.url)},{path:"/404",name:"404",component:()=>xn(()=>import("./index-55e8f3dc.js"),["./index-55e8f3dc.js","./main-4801cc52.js","./main-f8bd3d55.css"],import.meta.url)},{path:"/:catchAll(.*)",redirect:"/404"}]});pa(yl).use(wl).use(ma()).mount("#app");export{ye as u};