@edifice.io/share-node-client 0.0.0-stage → 0.1.0-snapshot.20261112145213
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5473 -0
- package/dist/index.umd.cjs +23 -0
- package/dist/nats/client.d.ts +24 -0
- package/dist/nats/client.d.ts.map +1 -0
- package/package.json +56 -3
- package/README.md +0 -3
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
(function(Te,he){typeof exports=="object"&&typeof module<"u"?he(exports):typeof define=="function"&&define.amd?define(["exports"],he):(Te=typeof globalThis<"u"?globalThis:Te||self,he((Te["@edifice"]=Te["@edifice"]||{},Te["@edifice"]["io/share-node-client"]={})))})(this,function(Te){"use strict";var Qs=Object.defineProperty;var eo=(Te,he,tt)=>he in Te?Qs(Te,he,{enumerable:!0,configurable:!0,writable:!0,value:tt}):Te[he]=tt;var d=(Te,he,tt)=>(eo(Te,typeof he!="symbol"?he+"":he,tt),tt);var he=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function tt(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(i){var a=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(r,i,a.get?a:{enumerable:!0,get:function(){return t[i]}})}),r}var Hr={},Vr={},wt={},ye={},ke={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.TD=t.TE=t.Empty=void 0,t.encode=r,t.decode=i,t.Empty=new Uint8Array(0),t.TE=new TextEncoder,t.TD=new TextDecoder;function e(...a){let u=0;for(let P=0;P<a.length;P++)u+=a[P].length;const l=new Uint8Array(u);let m=0;for(let P=0;P<a.length;P++)l.set(a[P],m),m+=a[P].length;return l}function r(...a){const u=[];for(let l=0;l<a.length;l++)u.push(t.TE.encode(a[l]));return u.length===0?t.Empty:u.length===1?u[0]:e(...u)}function i(a){return!a||a.length===0?"":t.TD.decode(a)}})(ke);var te={};Object.defineProperty(te,"__esModule",{value:!0}),te.errors=te.PermissionViolationError=te.NoRespondersError=te.TimeoutError=te.RequestError=te.ProtocolError=te.ConnectionError=te.DrainingConnectionError=te.ClosedConnectionError=te.AuthorizationError=te.UserAuthenticationExpiredError=te.InvalidOperationError=te.InvalidArgumentError=te.InvalidSubjectError=void 0;class Jr extends Error{constructor(e,r){super(`illegal subject: '${e}'`,r),this.name="InvalidSubjectError"}}te.InvalidSubjectError=Jr;class qt extends Error{constructor(e,r){super(e,r),this.name="InvalidArgumentError"}static format(e,r,i){return Array.isArray(r)&&r.length>1&&(r=r[0]),Array.isArray(e)?(e=e.map(a=>`'${a}'`),e=e.join(",")):e=`'${e}'`,new qt(`${e} ${r}`,i)}}te.InvalidArgumentError=qt;class Yr extends Error{constructor(e,r){super(e,r),this.name="InvalidOperationError"}}te.InvalidOperationError=Yr;class zt extends Error{constructor(e,r){super(e,r),this.name="UserAuthenticationExpiredError"}static parse(e){return e.toLowerCase().indexOf("user authentication expired")!==-1?new zt(e):null}}te.UserAuthenticationExpiredError=zt;class Gt extends Error{constructor(e,r){super(e,r),this.name="AuthorizationError"}static parse(e){const r=["authorization violation","account authentication expired","authentication timeout"],i=e.toLowerCase();for(let a=0;a<r.length;a++)if(i.indexOf(r[a])!==-1)return new Gt(e);return null}}te.AuthorizationError=Gt;class Wr extends Error{constructor(){super("closed connection"),this.name="ClosedConnectionError"}}te.ClosedConnectionError=Wr;class Xr extends Error{constructor(){super("connection draining"),this.name="DrainingConnectionError"}}te.DrainingConnectionError=Xr;class Zr extends Error{constructor(e,r){super(e,r),this.name="ConnectionError"}}te.ConnectionError=Zr;class Qr extends Error{constructor(e,r){super(e,r),this.name="ProtocolError"}}te.ProtocolError=Qr;class en extends Error{constructor(e="",r){super(e,r),this.name="RequestError"}isNoResponders(){return this.cause instanceof lr}}te.RequestError=en;class tn extends Error{constructor(e){super("timeout",e),this.name="TimeoutError"}}te.TimeoutError=tn;class lr extends Error{constructor(r,i){super(`no responders: '${r}'`,i);d(this,"subject");this.subject=r,this.name="NoResponders"}}te.NoRespondersError=lr;class Ht extends Error{constructor(r,i,a,u,l){super(r,l);d(this,"operation");d(this,"subject");d(this,"queue");this.name="PermissionViolationError",this.operation=i,this.subject=a,this.queue=u}static parse(r){if((r?r.toLowerCase():"").indexOf("permissions violation")===-1)return null;let a="publish",u="",l;const m=r.match(/(Publish|Subscription) to "(\S+)"/);if(m&&(a=m[1].toLowerCase(),u=m[2],a==="subscription")){const P=r.match(/using queue "(\S+)"/);P&&(l=P[1])}return new Ht(r,a,u,l)}}te.PermissionViolationError=Ht,te.errors={AuthorizationError:Gt,ClosedConnectionError:Wr,ConnectionError:Zr,DrainingConnectionError:Xr,InvalidArgumentError:qt,InvalidOperationError:Yr,InvalidSubjectError:Jr,NoRespondersError:lr,PermissionViolationError:Ht,ProtocolError:Qr,RequestError:en,TimeoutError:tn,UserAuthenticationExpiredError:zt},Object.defineProperty(ye,"__esModule",{value:!0}),ye.SimpleMutex=ye.Perf=void 0,ye.extend=fi,ye.render=ui,ye.timeout=hi,ye.delay=li,ye.deadline=di,ye.deferred=br,ye.debugDeferred=bi,ye.shuffle=yi,ye.collect=_i,ye.jitter=rn,ye.backoff=vi,ye.nanos=xi,ye.millis=pi;const ci=ke,dr=te;function fi(t,...e){for(let r=0;r<e.length;r++){const i=e[r];Object.keys(i).forEach(function(a){t[a]=i[a]})}return t}function ui(t){return ci.TD.decode(t).replace(/\n/g,"␊").replace(/\r/g,"␍")}function hi(t,e=!0){const r=e?new dr.TimeoutError:null;let i,a;const u=new Promise((l,m)=>{i={cancel:()=>{a&&clearTimeout(a)}},a=setTimeout(()=>{m(r===null?new dr.TimeoutError:r)},t)});return Object.assign(u,i)}function li(t=0){let e;const r=new Promise(i=>{const a=setTimeout(()=>{i()},t);e={cancel:()=>{a&&(clearTimeout(a),i())}}});return Object.assign(r,e)}async function di(t,e=1e3){const r=br(),i=setTimeout(()=>{r.reject(new dr.TimeoutError)},e);try{return await Promise.race([t,r])}finally{clearTimeout(i)}}function br(){let t={};const e=new Promise((r,i)=>{t={resolve:r,reject:i}});return Object.assign(e,t)}function bi(){let t={};const e=new Promise((r,i)=>{t={resolve:a=>{console.trace("resolve",a),r(a)},reject:a=>{console.trace("reject"),i(a)}}});return Object.assign(e,t)}function yi(t){for(let e=t.length-1;e>0;e--){const r=Math.floor(Math.random()*(e+1));[t[e],t[r]]=[t[r],t[e]]}return t}async function _i(t){const e=[];for await(const r of t)e.push(r);return e}class gi{constructor(){d(this,"timers");d(this,"measures");this.timers=new Map,this.measures=new Map}mark(e){this.timers.set(e,performance.now())}measure(e,r,i){const a=this.timers.get(r);if(a===void 0)throw new Error(`${r} is not defined`);const u=this.timers.get(i);if(u===void 0)throw new Error(`${i} is not defined`);this.measures.set(e,u-a)}getEntries(){const e=[];return this.measures.forEach((r,i)=>{e.push({name:i,duration:r})}),e}}ye.Perf=gi;class mi{constructor(e=1){d(this,"max");d(this,"current");d(this,"waiting");this.max=e,this.current=0,this.waiting=[]}lock(){if(this.current++,this.current<=this.max)return Promise.resolve();const e=br();return this.waiting.push(e),e}unlock(){this.current--;const e=this.waiting.pop();e==null||e.resolve()}}ye.SimpleMutex=mi;function rn(t){return t===0?0:Math.floor(t/2+Math.random()*t)}function vi(t=[0,250,250,500,500,3e3,5e3]){Array.isArray(t)||(t=[0,250,250,500,500,3e3,5e3]);const e=t.length-1;return{backoff(r){return rn(r>e?t[e]:t[r])}}}function xi(t){return t*1e6}function pi(t){return Math.floor(t/1e6)}var je={},rt={},Ae={},Pt={},ft={};Object.defineProperty(ft,"__esModule",{value:!0}),ft.nuid=ft.Nuid=void 0;const nn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",yr=36,Vt=12,Ei=10,sn=0xcfd41b9100000,on=33,wi=333,an=Vt+Ei;function Pi(t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*255)}function Si(t){var e;(e=globalThis==null?void 0:globalThis.crypto)!=null&&e.getRandomValues?globalThis.crypto.getRandomValues(t):Pi(t)}class cn{constructor(){d(this,"buf");d(this,"seq");d(this,"inc");d(this,"inited");this.buf=new Uint8Array(an),this.inited=!1}init(){this.inited=!0,this.setPre(),this.initSeqAndInc(),this.fillSeq()}initSeqAndInc(){this.seq=Math.floor(Math.random()*sn),this.inc=Math.floor(Math.random()*(wi-on)+on)}setPre(){const e=new Uint8Array(Vt);Si(e);for(let r=0;r<Vt;r++){const i=e[r]%yr;this.buf[r]=nn.charCodeAt(i)}}fillSeq(){let e=this.seq;for(let r=an-1;r>=Vt;r--)this.buf[r]=nn.charCodeAt(e%yr),e=Math.floor(e/yr)}next(){return this.inited||this.init(),this.seq+=this.inc,this.seq>sn&&(this.setPre(),this.initSeqAndInc()),this.fillSeq(),String.fromCharCode.apply(String,this.buf)}reset(){this.init()}}ft.Nuid=cn,ft.nuid=new cn,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.nuid=t.Nuid=void 0;var e=ft;Object.defineProperty(t,"Nuid",{enumerable:!0,get:function(){return e.Nuid}}),Object.defineProperty(t,"nuid",{enumerable:!0,get:function(){return e.nuid}})}(Pt),Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.DEFAULT_HOST=Ae.DEFAULT_PORT=Ae.Match=void 0,Ae.syncIterator=Ci,Ae.createInbox=Mi;const Oi=Pt,Ai=te;Ae.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function Ci(t){const e=t[Symbol.asyncIterator]();return{async next(){const r=await e.next();return r.done?Promise.resolve(null):Promise.resolve(r.value)}}}function Mi(t=""){if(t=t||"_INBOX",typeof t!="string")throw new TypeError("prefix must be a string");return t.split(".").forEach(e=>{if(e==="*"||e===">")throw Ai.InvalidArgumentError.format("prefix",`cannot have wildcards ('${t}')`)}),`${t}.${Oi.nuid.next()}`}Ae.DEFAULT_PORT=4222,Ae.DEFAULT_HOST="127.0.0.1";var nt={};Object.defineProperty(nt,"__esModule",{value:!0}),nt.DataBuffer=void 0;const fn=ke;class Ii{constructor(){d(this,"buffers");d(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...e){let r=0;for(let u=0;u<e.length;u++)r+=e[u].length;const i=new Uint8Array(r);let a=0;for(let u=0;u<e.length;u++)i.set(e[u],a),a+=e[u].length;return i}static fromAscii(e){return e||(e=""),fn.TE.encode(e)}static toAscii(e){return fn.TD.decode(e)}reset(){this.buffers.length=0,this.byteLength=0}pack(){if(this.buffers.length>1){const e=new Uint8Array(this.byteLength);let r=0;for(let i=0;i<this.buffers.length;i++)e.set(this.buffers[i],r),r+=this.buffers[i].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 r=this.buffers.pop();if(r){const i=this.byteLength;(e===void 0||e>i)&&(e=i);const a=r.subarray(0,e);return i>e&&this.buffers.push(r.subarray(e)),this.byteLength=i-e,a}}return new Uint8Array(0)}fill(e,...r){e&&(this.buffers.push(e),this.byteLength+=e.length);for(let i=0;i<r.length;i++)r[i]&&r[i].length&&(this.buffers.push(r[i]),this.byteLength+=r[i].length)}peek(){return this.buffers.length?(this.pack(),this.buffers[0]):new Uint8Array(0)}size(){return this.byteLength}length(){return this.buffers.length}}nt.DataBuffer=Ii,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.LF=t.CR=t.CRLF=t.CR_LF_LEN=t.CR_LF=void 0,t.setTransportFactory=u,t.defaultPort=l,t.getUrlParseFn=m,t.newTransport=P,t.getResolveFn=g,t.protoLen=E,t.extractProtocolMessage=w;const e=ke,r=Ae,i=nt;let a;function u(b){a=b}function l(){return a!==void 0&&a.defaultPort!==void 0?a.defaultPort:r.DEFAULT_PORT}function m(){return a!==void 0&&a.urlParseFn?a.urlParseFn:void 0}function P(){if(!a||typeof a.factory!="function")throw new Error("transport fn is not set");return a.factory()}function g(){return a!==void 0&&a.dnsResolveFn?a.dnsResolveFn:void 0}t.CR_LF=`\r
|
|
2
|
+
`,t.CR_LF_LEN=t.CR_LF.length,t.CRLF=i.DataBuffer.fromAscii(t.CR_LF),t.CR=new Uint8Array(t.CRLF)[0],t.LF=new Uint8Array(t.CRLF)[1];function E(b){for(let x=0;x<b.length;x++){const R=x+1;if(b.byteLength>R&&b[x]===t.CR&&b[R]===t.LF)return R+1}return 0}function w(b){const x=E(b);if(x>0){const j=new Uint8Array(b).slice(0,x);return e.TD.decode(j)}return""}}(rt);var Je={},ut={};Object.defineProperty(ut,"__esModule",{value:!0}),ut.ipV4=dn,ut.isIP=Ni,ut.parseIP=bn;const St=4,it=16,Jt=48,un=57,hn=65,ji=70,ln=97,Ti=102,_r=16777215;function dn(t,e,r,i){const a=new Uint8Array(it);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((l,m)=>{a[m]=l}),a[12]=t,a[13]=e,a[14]=r,a[15]=i,a}function Ni(t){return bn(t)!==void 0}function bn(t){for(let e=0;e<t.length;e++)switch(t[e]){case".":return yn(t);case":":return Ri(t)}}function yn(t){const e=new Uint8Array(St);for(let r=0;r<St;r++){if(t.length===0)return;if(r>0){if(t[0]!==".")return;t=t.substring(1)}const{n:i,c:a,ok:u}=ki(t);if(!u||i>255)return;t=t.substring(a),e[r]=i}return dn(e[0],e[1],e[2],e[3])}function Ri(t){const e=new Uint8Array(it);let r=-1;if(t.length>=2&&t[0]===":"&&t[1]===":"&&(r=0,t=t.substring(2),t.length===0))return e;let i=0;for(;i<it;){const{n:a,c:u,ok:l}=Ui(t);if(!l||a>65535)return;if(u<t.length&&t[u]==="."){if(r<0&&i!=it-St||i+St>it)return;const m=yn(t);if(m===void 0)return;e[i]=m[12],e[i+1]=m[13],e[i+2]=m[14],e[i+3]=m[15],t="",i+=St;break}if(e[i]=a>>8,e[i+1]=a,i+=2,t=t.substring(u),t.length===0)break;if(t[0]!==":"||t.length==1)return;if(t=t.substring(1),t[0]===":"){if(r>=0)return;if(r=i,t=t.substring(1),t.length===0)break}}if(t.length===0){if(i<it){if(r<0)return;const a=it-i;for(let u=i-1;u>=r;u--)e[u+a]=e[u];for(let u=r+a-1;u>=r;u--)e[u]=0}else if(r>=0)return;return e}}function ki(t){let e=0,r=0;for(e=0;e<t.length&&Jt<=t.charCodeAt(e)&&t.charCodeAt(e)<=un;e++)if(r=r*10+(t.charCodeAt(e)-Jt),r>=_r)return{n:_r,c:e,ok:!1};return e===0?{n:0,c:0,ok:!1}:{n:r,c:e,ok:!0}}function Ui(t){let e=0,r=0;for(r=0;r<t.length;r++){if(Jt<=t.charCodeAt(r)&&t.charCodeAt(r)<=un)e*=16,e+=t.charCodeAt(r)-Jt;else if(ln<=t.charCodeAt(r)&&t.charCodeAt(r)<=Ti)e*=16,e+=t.charCodeAt(r)-ln+10;else if(hn<=t.charCodeAt(r)&&t.charCodeAt(r)<=ji)e*=16,e+=t.charCodeAt(r)-hn+10;else break;if(e>=_r)return{n:0,c:r,ok:!1}}return r===0?{n:0,c:r,ok:!1}:{n:e,c:r,ok:!0}}Object.defineProperty(Je,"__esModule",{value:!0}),Je.Servers=Je.ServerImpl=void 0,Je.isIPV4OrHostname=mn,Je.hostPort=vn;const Yt=rt,_n=ye,gr=ut,gn=Ae;function mn(t){return t.indexOf("[")!==-1||t.indexOf("::")!==-1?!1:t.indexOf(".")!==-1||t.split(":").length<=2}function mr(t){return!mn(t)}function Li(t){const e="::FFFF:",r=t.toUpperCase().indexOf(e);if(r!==-1&&t.indexOf(".")!==-1){let i=t.substring(r+e.length);return i=i.replace("[",""),i.replace("]","")}return t}function vn(t){t=t.trim(),t.match(/^(.*:\/\/)(.*)/m)&&(t=t.replace(/^(.*:\/\/)(.*)/gm,"$2")),t=Li(t),mr(t)&&t.indexOf("[")===-1&&(t=`[${t}]`);const e=mr(t)?t.match(/(]:)(\d+)/):t.match(/(:)(\d+)/),r=e&&e.length===3&&e[1]&&e[2]?parseInt(e[2]):gn.DEFAULT_PORT,i=r===80?"https":"http",a=new URL(`${i}://${t}`);a.port=`${r}`;let u=a.hostname;return u.charAt(0)==="["&&(u=u.substring(1,u.length-1)),{listen:a.host,hostname:u,port:r}}class ht{constructor(e,r=!1){d(this,"src");d(this,"listen");d(this,"hostname");d(this,"port");d(this,"didConnect");d(this,"reconnects");d(this,"lastConnect");d(this,"gossiped");d(this,"tlsName");d(this,"resolves");this.src=e,this.tlsName="";const i=vn(e);this.listen=i.listen,this.hostname=i.hostname,this.port=i.port,this.didConnect=!1,this.reconnects=0,this.lastConnect=0,this.gossiped=r}toString(){return this.listen}async resolve(e){if(!e.fn||e.resolve===!1)return[this];const r=[];if((0,gr.isIP)(this.hostname))return[this];{const i=await e.fn(this.hostname);e.debug&&console.log(`resolve ${this.hostname} = ${i.join(",")}`);for(const a of i){const u=this.port===80?"https":"http",l=new URL(`${u}://${mr(a)?"["+a+"]":a}`);l.port=`${this.port}`;const m=new ht(l.host,!1);m.tlsName=this.hostname,r.push(m)}}return e.randomize&&(0,_n.shuffle)(r),this.resolves=r,r}}Je.ServerImpl=ht;class Fi{constructor(e=[],r={}){d(this,"firstSelect");d(this,"servers");d(this,"currentServer");d(this,"tlsName");d(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=r.randomize||!1;const i=(0,Yt.getUrlParseFn)();e&&(e.forEach(a=>{a=i?i(a):a,this.servers.push(new ht(a))}),this.randomize&&(this.servers=(0,_n.shuffle)(this.servers))),this.servers.length===0&&this.addServer(`${gn.DEFAULT_HOST}:${(0,Yt.defaultPort)()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const e=this.getCurrentServer();(0,gr.isIP)(e.hostname)||(this.tlsName=e.hostname,this.servers.forEach(r=>{r.gossiped&&(r.tlsName=this.tlsName)}))}getCurrentServer(){return this.currentServer}addServer(e,r=!1){const i=(0,Yt.getUrlParseFn)();e=i?i(e):e;const a=new ht(e,r);(0,gr.isIP)(a.hostname)&&(a.tlsName=this.tlsName),this.servers.push(a)}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 r=this.servers.indexOf(e);this.servers.splice(r,1)}}length(){return this.servers.length}next(){return this.servers.length?this.servers[0]:void 0}getServers(){return this.servers}update(e,r){const i=[];let a=[];const u=(0,Yt.getUrlParseFn)(),l=new Map;e.connect_urls&&e.connect_urls.length>0&&e.connect_urls.forEach(P=>{P=u?u(P,r):P;const g=new ht(P,!0);l.set(P,g)});const m=[];return this.servers.forEach((P,g)=>{const E=P.listen;P.gossiped&&this.currentServer.listen!==E&&l.get(E)===void 0&&m.push(g),l.delete(E)}),m.reverse(),m.forEach(P=>{const g=this.servers.splice(P,1);a=a.concat(g[0].listen)}),l.forEach((P,g)=>{this.servers.push(P),i.push(g)}),{added:i,deleted:a}}}Je.Servers=Fi;var lt={};Object.defineProperty(lt,"__esModule",{value:!0}),lt.QueuedIteratorImpl=void 0;const vr=ye,xn=te;class Ki{constructor(){d(this,"inflight");d(this,"processed");d(this,"received");d(this,"noIterator");d(this,"iterClosed");d(this,"done");d(this,"signal");d(this,"yields");d(this,"filtered");d(this,"pendingFiltered");d(this,"ctx");d(this,"_data");d(this,"err");d(this,"time");d(this,"profile");d(this,"yielding");d(this,"didBreak");this.inflight=0,this.filtered=0,this.pendingFiltered=0,this.processed=0,this.received=0,this.noIterator=!1,this.done=!1,this.signal=(0,vr.deferred)(),this.yields=[],this.iterClosed=(0,vr.deferred)(),this.time=0,this.yielding=!1,this.didBreak=!1,this.profile=!1}[Symbol.asyncIterator](){return this.iterate()}push(e){if(!this.done){if(this.didBreak){if(typeof e=="function"){const r=e;try{r()}catch{}}return}typeof e=="function"&&this.pendingFiltered++,this.yields.push(e),this.signal.resolve()}}async*iterate(){if(this.noIterator)throw new xn.InvalidOperationError("iterator cannot be used when a callback is registered");if(this.yielding)throw new xn.InvalidOperationError("iterator is already yielding");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 r=0;r<e.length;r++){if(typeof e[r]=="function"){this.pendingFiltered--;const a=e[r];try{a()}catch(u){throw u}if(this.err)throw this.err;continue}this.processed++,this.inflight--;const i=this.profile?Date.now():0;yield e[r],this.time=this.profile?Date.now()-i:0}if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=(0,vr.deferred)())}}finally{this.didBreak=!0,this.stop()}}stop(e){this.done||(this.err=e,this.done=!0,this.signal.resolve(),this.iterClosed.resolve(e))}getProcessed(){return this.noIterator?this.received:this.processed}getPending(){return this.yields.length+this.inflight-this.pendingFiltered}getReceived(){return this.received-this.filtered}}lt.QueuedIteratorImpl=Ki;var Ot={};Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.MuxSubscription=void 0;const Bi=Ae,pn=te;class Di{constructor(){d(this,"baseInbox");d(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(e){return this.baseInbox=`${(0,Bi.createInbox)(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 r=e.subject||"";return r.indexOf(this.baseInbox)===0?r.substring(this.baseInbox.length):null}all(){return Array.from(this.reqs.values())}handleError(e,r){if(e)return this.all().forEach(i=>{i.resolver(r,{})}),!0;if(r.operation==="publish"){const i=this.all().find(a=>a.requestSubject===r.subject);if(i)return i.resolver(r,{}),!0}return!1}dispatcher(){return(e,r)=>{var a,u;const i=this.getToken(r);if(i){const l=this.get(i);l&&(e===null&&(e=((a=r==null?void 0:r.data)==null?void 0:a.length)===0&&((u=r.headers)==null?void 0:u.code)===503?new pn.NoRespondersError(l.requestSubject):null),l.resolver(e,r))}}}close(){const e=new pn.RequestError("connection closed");this.reqs.forEach(r=>{r.resolver(e,{})})}}Ot.MuxSubscription=Di;var At={};Object.defineProperty(At,"__esModule",{value:!0}),At.Heartbeat=void 0;const $i=ye;class qi{constructor(e,r,i){d(this,"ph");d(this,"interval");d(this,"maxOut");d(this,"timer");d(this,"pendings");this.ph=e,this.interval=r,this.maxOut=i,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:"ping",pendingPings:this.pendings.length+1}),this.pendings.length===this.maxOut){this.cancel(!0);return}const e=(0,$i.deferred)();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))}}At.Heartbeat=qi;var xr={},pr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DenoBuffer=t.MAX_SIZE=t.AssertionError=void 0,t.assert=i,t.concat=l,t.append=m,t.readAll=g,t.writeAll=E;const e=ke;class r extends Error{constructor(b){super(b),this.name="AssertionError"}}t.AssertionError=r;function i(w,b="Assertion failed."){if(!w)throw new r(b)}const a=32*1024;t.MAX_SIZE=2**32-2;function u(w,b,x=0){const R=b.byteLength-x;return w.byteLength>R&&(w=w.subarray(0,R)),b.set(w,x),w.byteLength}function l(w,b){if(w===void 0&&b===void 0)return new Uint8Array(0);if(w===void 0)return b;if(b===void 0)return w;const x=new Uint8Array(w.length+b.length);return x.set(w,0),x.set(b,w.length),x}function m(w,b){return l(w,Uint8Array.of(b))}class P{constructor(b){d(this,"_buf");d(this,"_off");if(this._off=0,b==null){this._buf=new Uint8Array(0);return}this._buf=new Uint8Array(b)}bytes(b={copy:!0}){return b.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(b){if(b===0){this.reset();return}if(b<0||b>this.length)throw Error("bytes.Buffer: truncation out of range");this._reslice(this._off+b)}reset(){this._reslice(0),this._off=0}_tryGrowByReslice(b){const x=this._buf.byteLength;return b<=this.capacity-x?(this._reslice(x+b),x):-1}_reslice(b){i(b<=this._buf.buffer.byteLength),this._buf=new Uint8Array(this._buf.buffer,0,b)}readByte(){const b=new Uint8Array(1);return this.read(b)?b[0]:null}read(b){if(this.empty())return this.reset(),b.byteLength===0?0:null;const x=u(this._buf.subarray(this._off),b);return this._off+=x,x}writeByte(b){return this.write(Uint8Array.of(b))}writeString(b){return this.write(e.TE.encode(b))}write(b){const x=this._grow(b.byteLength);return u(b,this._buf,x)}_grow(b){const x=this.length;x===0&&this._off!==0&&this.reset();const R=this._tryGrowByReslice(b);if(R>=0)return R;const j=this.capacity;if(b<=Math.floor(j/2)-x)u(this._buf.subarray(this._off),this._buf);else{if(j+b>t.MAX_SIZE)throw new Error("The buffer cannot be grown beyond the maximum size.");{const U=new Uint8Array(Math.min(2*j+b,t.MAX_SIZE));u(this._buf.subarray(this._off),U),this._buf=U}}return this._off=0,this._reslice(Math.min(x+b,t.MAX_SIZE)),x}grow(b){if(b<0)throw Error("Buffer._grow: negative count");const x=this._grow(b);this._reslice(x)}readFrom(b){let x=0;const R=new Uint8Array(a);for(;;){const j=this.capacity-this.length<a,U=j?R:new Uint8Array(this._buf.buffer,this.length),ie=b.read(U);if(ie===null)return x;j?this.write(U.subarray(0,ie)):this._reslice(this.length+ie),x+=ie}}}t.DenoBuffer=P;function g(w){const b=new P;return b.readFrom(w),b.bytes()}function E(w,b){let x=0;for(;x<b.length;)x+=w.write(b.subarray(x))}})(pr),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.cc=t.State=t.Parser=t.Kind=void 0,t.describe=i;const e=pr,r=ke;t.Kind={OK:0,ERR:1,MSG:2,INFO:3,PING:4,PONG:5};function i(P){let g,E="";switch(P.kind){case t.Kind.MSG:g="MSG";break;case t.Kind.OK:g="OK";break;case t.Kind.ERR:g="ERR",E=r.TD.decode(P.data);break;case t.Kind.PING:g="PING";break;case t.Kind.PONG:g="PONG";break;case t.Kind.INFO:g="INFO",E=r.TD.decode(P.data)}return`${g}: ${E}`}function a(){const P={};return P.sid=-1,P.hdr=-1,P.size=-1,P}const u=48,l=57;class m{constructor(g){d(this,"dispatcher");d(this,"state");d(this,"as");d(this,"drop");d(this,"hdr");d(this,"ma");d(this,"argBuf");d(this,"msgBuf");this.dispatcher=g,this.state=t.State.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(g){let E;for(E=0;E<g.length;E++){const w=g[E];switch(this.state){case t.State.OP_START:switch(w){case t.cc.M:case t.cc.m:this.state=t.State.OP_M,this.hdr=-1,this.ma=a();break;case t.cc.H:case t.cc.h:this.state=t.State.OP_H,this.hdr=0,this.ma=a();break;case t.cc.P:case t.cc.p:this.state=t.State.OP_P;break;case t.cc.PLUS:this.state=t.State.OP_PLUS;break;case t.cc.MINUS:this.state=t.State.OP_MINUS;break;case t.cc.I:case t.cc.i:this.state=t.State.OP_I;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_H:switch(w){case t.cc.M:case t.cc.m:this.state=t.State.OP_M;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_M:switch(w){case t.cc.S:case t.cc.s:this.state=t.State.OP_MS;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_MS:switch(w){case t.cc.G:case t.cc.g:this.state=t.State.OP_MSG;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_MSG:switch(w){case t.cc.SPACE:case t.cc.TAB:this.state=t.State.OP_MSG_SPC;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_MSG_SPC:switch(w){case t.cc.SPACE:case t.cc.TAB:continue;default:this.state=t.State.MSG_ARG,this.as=E}break;case t.State.MSG_ARG:switch(w){case t.cc.CR:this.drop=1;break;case t.cc.NL:{const b=this.argBuf?this.argBuf.bytes():g.subarray(this.as,E-this.drop);this.processMsgArgs(b),this.drop=0,this.as=E+1,this.state=t.State.MSG_PAYLOAD,E=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(w)}break;case t.State.MSG_PAYLOAD:if(this.msgBuf)if(this.msgBuf.length>=this.ma.size){const b=this.msgBuf.bytes({copy:!1});this.dispatcher.push({kind:t.Kind.MSG,msg:this.ma,data:b}),this.argBuf=void 0,this.msgBuf=void 0,this.state=t.State.MSG_END}else{let b=this.ma.size-this.msgBuf.length;const x=g.length-E;x<b&&(b=x),b>0?(this.msgBuf.write(g.subarray(E,E+b)),E=E+b-1):this.msgBuf.writeByte(w)}else E-this.as>=this.ma.size&&(this.dispatcher.push({kind:t.Kind.MSG,msg:this.ma,data:g.subarray(this.as,E)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=t.State.MSG_END);break;case t.State.MSG_END:switch(w){case t.cc.NL:this.drop=0,this.as=E+1,this.state=t.State.OP_START;break;default:continue}break;case t.State.OP_PLUS:switch(w){case t.cc.O:case t.cc.o:this.state=t.State.OP_PLUS_O;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_PLUS_O:switch(w){case t.cc.K:case t.cc.k:this.state=t.State.OP_PLUS_OK;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_PLUS_OK:switch(w){case t.cc.NL:this.dispatcher.push({kind:t.Kind.OK}),this.drop=0,this.state=t.State.OP_START;break}break;case t.State.OP_MINUS:switch(w){case t.cc.E:case t.cc.e:this.state=t.State.OP_MINUS_E;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_MINUS_E:switch(w){case t.cc.R:case t.cc.r:this.state=t.State.OP_MINUS_ER;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_MINUS_ER:switch(w){case t.cc.R:case t.cc.r:this.state=t.State.OP_MINUS_ERR;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_MINUS_ERR:switch(w){case t.cc.SPACE:case t.cc.TAB:this.state=t.State.OP_MINUS_ERR_SPC;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_MINUS_ERR_SPC:switch(w){case t.cc.SPACE:case t.cc.TAB:continue;default:this.state=t.State.MINUS_ERR_ARG,this.as=E}break;case t.State.MINUS_ERR_ARG:switch(w){case t.cc.CR:this.drop=1;break;case t.cc.NL:{let b;this.argBuf?(b=this.argBuf.bytes(),this.argBuf=void 0):b=g.subarray(this.as,E-this.drop),this.dispatcher.push({kind:t.Kind.ERR,data:b}),this.drop=0,this.as=E+1,this.state=t.State.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(w))}break;case t.State.OP_P:switch(w){case t.cc.I:case t.cc.i:this.state=t.State.OP_PI;break;case t.cc.O:case t.cc.o:this.state=t.State.OP_PO;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_PO:switch(w){case t.cc.N:case t.cc.n:this.state=t.State.OP_PON;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_PON:switch(w){case t.cc.G:case t.cc.g:this.state=t.State.OP_PONG;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_PONG:switch(w){case t.cc.NL:this.dispatcher.push({kind:t.Kind.PONG}),this.drop=0,this.state=t.State.OP_START;break}break;case t.State.OP_PI:switch(w){case t.cc.N:case t.cc.n:this.state=t.State.OP_PIN;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_PIN:switch(w){case t.cc.G:case t.cc.g:this.state=t.State.OP_PING;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_PING:switch(w){case t.cc.NL:this.dispatcher.push({kind:t.Kind.PING}),this.drop=0,this.state=t.State.OP_START;break}break;case t.State.OP_I:switch(w){case t.cc.N:case t.cc.n:this.state=t.State.OP_IN;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_IN:switch(w){case t.cc.F:case t.cc.f:this.state=t.State.OP_INF;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_INF:switch(w){case t.cc.O:case t.cc.o:this.state=t.State.OP_INFO;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_INFO:switch(w){case t.cc.SPACE:case t.cc.TAB:this.state=t.State.OP_INFO_SPC;break;default:throw this.fail(g.subarray(E))}break;case t.State.OP_INFO_SPC:switch(w){case t.cc.SPACE:case t.cc.TAB:continue;default:this.state=t.State.INFO_ARG,this.as=E}break;case t.State.INFO_ARG:switch(w){case t.cc.CR:this.drop=1;break;case t.cc.NL:{let b;this.argBuf?(b=this.argBuf.bytes(),this.argBuf=void 0):b=g.subarray(this.as,E-this.drop),this.dispatcher.push({kind:t.Kind.INFO,data:b}),this.drop=0,this.as=E+1,this.state=t.State.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(w)}break;default:throw this.fail(g.subarray(E))}}(this.state===t.State.MSG_ARG||this.state===t.State.MINUS_ERR_ARG||this.state===t.State.INFO_ARG)&&!this.argBuf&&(this.argBuf=new e.DenoBuffer(g.subarray(this.as,E-this.drop))),this.state===t.State.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new e.DenoBuffer(g.subarray(this.as)))}cloneMsgArg(){const g=this.ma.subject.length,E=this.ma.reply?this.ma.reply.length:0,w=new Uint8Array(g+E);w.set(this.ma.subject),this.ma.reply&&w.set(this.ma.reply,g),this.argBuf=new e.DenoBuffer(w),this.ma.subject=w.subarray(0,g),this.ma.reply&&(this.ma.reply=w.subarray(g))}processMsgArgs(g){if(this.hdr>=0)return this.processHeaderMsgArgs(g);const E=[];let w=-1;for(let b=0;b<g.length;b++)switch(g[b]){case t.cc.SPACE:case t.cc.TAB:case t.cc.CR:case t.cc.NL:w>=0&&(E.push(g.subarray(w,b)),w=-1);break;default:w<0&&(w=b)}switch(w>=0&&E.push(g.subarray(w)),E.length){case 3:this.ma.subject=E[0],this.ma.sid=this.protoParseInt(E[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(E[2]);break;case 4:this.ma.subject=E[0],this.ma.sid=this.protoParseInt(E[1]),this.ma.reply=E[2],this.ma.size=this.protoParseInt(E[3]);break;default:throw this.fail(g,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(g,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail(g,"processMsgArgs Bad or Missing Size Error")}fail(g,E=""){return E?E=`${E} [${this.state}]`:E=`parse error [${this.state}]`,new Error(`${E}: ${r.TD.decode(g)}`)}processHeaderMsgArgs(g){const E=[];let w=-1;for(let b=0;b<g.length;b++)switch(g[b]){case t.cc.SPACE:case t.cc.TAB:case t.cc.CR:case t.cc.NL:w>=0&&(E.push(g.subarray(w,b)),w=-1);break;default:w<0&&(w=b)}switch(w>=0&&E.push(g.subarray(w)),E.length){case 4:this.ma.subject=E[0],this.ma.sid=this.protoParseInt(E[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(E[2]),this.ma.size=this.protoParseInt(E[3]);break;case 5:this.ma.subject=E[0],this.ma.sid=this.protoParseInt(E[1]),this.ma.reply=E[2],this.ma.hdr=this.protoParseInt(E[3]),this.ma.size=this.protoParseInt(E[4]);break;default:throw this.fail(g,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(g,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(g,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(g,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt(g){if(g.length===0)return-1;let E=0;for(let w=0;w<g.length;w++){if(g[w]<u||g[w]>l)return-1;E=E*10+(g[w]-u)}return E}}t.Parser=m,t.State={OP_START:0,OP_PLUS:1,OP_PLUS_O:2,OP_PLUS_OK:3,OP_MINUS:4,OP_MINUS_E:5,OP_MINUS_ER:6,OP_MINUS_ERR:7,OP_MINUS_ERR_SPC:8,MINUS_ERR_ARG:9,OP_M:10,OP_MS:11,OP_MSG:12,OP_MSG_SPC:13,MSG_ARG:14,MSG_PAYLOAD:15,MSG_END:16,OP_H:17,OP_P:18,OP_PI:19,OP_PIN:20,OP_PING:21,OP_PO:22,OP_PON:23,OP_PONG:24,OP_I:25,OP_IN:26,OP_INF:27,OP_INFO:28,OP_INFO_SPC:29,INFO_ARG:30},t.cc={CR:13,E:69,e:101,F:70,f:102,G:71,g:103,H:72,h:104,I:73,i:105,K:75,k:107,M:77,m:109,MINUS:45,N:78,n:110,NL:10,O:79,o:111,P:80,p:112,PLUS:43,R:82,r:114,S:83,s:115,SPACE:32,TAB:9}}(xr);var Ct={},Qe={};Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.MsgHdrsImpl=void 0,Qe.canonicalMIMEHeaderKey=wr,Qe.headers=zi;const En=ke,Be=Ae,Er=te;function wr(t){let E=!0;const w=new Array(t.length);for(let b=0;b<t.length;b++){let x=t.charCodeAt(b);if(x===58||x<33||x>126)throw Er.InvalidArgumentError.format("header",`'${t[b]}' is not a valid character in a header name`);E&&97<=x&&x<=122?x-=32:!E&&65<=x&&x<=90&&(x+=32),w[b]=x,E=x==45}return String.fromCharCode(...w)}function zi(t=0,e=""){if(t===0&&e!==""||t>0&&e==="")throw Er.InvalidArgumentError.format("description","is required");return new dt(t,e)}const Pr="NATS/1.0";class dt{constructor(e=0,r=""){d(this,"_code");d(this,"headers");d(this,"_description");this._code=e,this._description=r,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[r,i]of this.headers){const a=e.values(r);if(i.length!==a.length)return!1;const u=[...i].sort(),l=[...a].sort();for(let m=0;m<u.length;m++)if(u[m]!==l[m])return!1}return!0}return!1}static decode(e){const r=new dt,a=En.TD.decode(e).split(`\r
|
|
3
|
+
`),u=a[0];if(u!==Pr){let l=u.replace(Pr,"").trim();if(l.length>0){r._code=parseInt(l,10),isNaN(r._code)&&(r._code=0);const m=r._code.toString();l=l.replace(m,""),r._description=l.trim()}}return a.length>=1&&a.slice(1).map(l=>{if(l){const m=l.indexOf(":");if(m>-1){const P=l.slice(0,m),g=l.slice(m+1).trim();r.append(P,g)}}}),r}toString(){if(this.headers.size===0&&this._code===0)return"";let e=Pr;this._code>0&&this._description!==""&&(e+=` ${this._code} ${this._description}`);for(const[r,i]of this.headers)for(let a=0;a<i.length;a++)e=`${e}\r
|
|
4
|
+
${r}: ${i[a]}`;return`${e}\r
|
|
5
|
+
\r
|
|
6
|
+
`}encode(){return En.TE.encode(this.toString())}static validHeaderValue(e){if(/[\r\n]/.test(e))throw Er.InvalidArgumentError.format("header","values cannot contain \\r or \\n");return e.trim()}keys(){const e=[];for(const r of this.headers.keys())e.push(r);return e}findKeys(e,r=Be.Match.Exact){const i=this.keys();switch(r){case Be.Match.Exact:return i.filter(a=>a===e);case Be.Match.CanonicalMIME:return e=wr(e),i.filter(a=>a===e);default:{const a=e.toLowerCase();return i.filter(u=>a===u.toLowerCase())}}}get(e,r=Be.Match.Exact){const i=this.findKeys(e,r);if(i.length){const a=this.headers.get(i[0]);if(a)return Array.isArray(a)?a[0]:a}return""}last(e,r=Be.Match.Exact){const i=this.findKeys(e,r);if(i.length){const a=this.headers.get(i[0]);if(a)return Array.isArray(a)?a[a.length-1]:a}return""}has(e,r=Be.Match.Exact){return this.findKeys(e,r).length>0}set(e,r,i=Be.Match.Exact){this.delete(e,i),this.append(e,r,i)}append(e,r,i=Be.Match.Exact){const a=wr(e);i===Be.Match.CanonicalMIME&&(e=a);const u=this.findKeys(e,i);e=u.length>0?u[0]:e;const l=dt.validHeaderValue(r);let m=this.headers.get(e);m||(m=[],this.headers.set(e,m)),m.push(l)}values(e,r=Be.Match.Exact){const i=[];return this.findKeys(e,r).forEach(u=>{const l=this.headers.get(u);l&&i.push(...l)}),i}delete(e,r=Be.Match.Exact){this.findKeys(e,r).forEach(a=>{this.headers.delete(a)})}get hasError(){return this._code>=300}get status(){return`${this._code} ${this._description}`.trim()}toRecord(){const e={};return this.keys().forEach(r=>{e[r]=this.values(r)}),e}get code(){return this._code}get description(){return this._description}static fromRecord(e){const r=new dt;for(const i in e)r.headers.set(i,e[i]);return r}}Qe.MsgHdrsImpl=dt,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.MsgImpl=void 0;const Gi=Qe,Wt=ke;class Hi{constructor(e,r,i){d(this,"_headers");d(this,"_msg");d(this,"_rdata");d(this,"_reply");d(this,"_subject");d(this,"publisher");this._msg=e,this._rdata=r,this.publisher=i}get subject(){return this._subject?this._subject:(this._subject=Wt.TD.decode(this._msg.subject),this._subject)}get reply(){return this._reply?this._reply:(this._reply=Wt.TD.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=Gi.MsgHdrsImpl.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=Wt.Empty,r){return this.reply?(this.publisher.publish(this.reply,e,r),!0):!1}size(){var a;const e=this._msg.subject.length,r=((a=this._msg.reply)==null?void 0:a.length)||0,i=this._msg.size===-1?0:this._msg.size;return e+r+i}json(e){return JSON.parse(this.string(),e)}string(){return Wt.TD.decode(this.data)}requestInfo(){var r;const e=(r=this.headers)==null?void 0:r.get("Nats-Request-Info");return e?JSON.parse(e,function(i,a){return(i==="start"||i==="stop")&&a!==""?new Date(Date.parse(a)):a}):null}}Ct.MsgImpl=Hi;var Xt={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Features=t.Feature=void 0,t.parseSemVer=e,t.compare=r;function e(a=""){const u=a.match(/(\d+).(\d+).(\d+)/);if(u)return{major:parseInt(u[1]),minor:parseInt(u[2]),micro:parseInt(u[3])};throw new Error(`'${a}' is not a semver value`)}function r(a,u){return a.major<u.major?-1:a.major>u.major?1:a.minor<u.minor?-1:a.minor>u.minor?1:a.micro<u.micro?-1:a.micro>u.micro?1:0}t.Feature={JS_KV:"js_kv",JS_OBJECTSTORE:"js_objectstore",JS_PULL_MAX_BYTES:"js_pull_max_bytes",JS_NEW_CONSUMER_CREATE_API:"js_new_consumer_create",JS_ALLOW_DIRECT:"js_allow_direct",JS_MULTIPLE_CONSUMER_FILTER:"js_multiple_consumer_filter",JS_SIMPLIFICATION:"js_simplification",JS_STREAM_CONSUMER_METADATA:"js_stream_consumer_metadata",JS_CONSUMER_FILTER_SUBJECTS:"js_consumer_filter_subjects",JS_STREAM_FIRST_SEQ:"js_stream_first_seq",JS_STREAM_SUBJECT_TRANSFORM:"js_stream_subject_transform",JS_STREAM_SOURCE_SUBJECT_TRANSFORM:"js_stream_source_subject_transform",JS_STREAM_COMPRESSION:"js_stream_compression",JS_DEFAULT_CONSUMER_LIMITS:"js_default_consumer_limits",JS_BATCH_DIRECT_GET:"js_batch_direct_get",JS_PRIORITY_GROUPS:"js_priority_groups"};class i{constructor(u){d(this,"server");d(this,"features");d(this,"disabled");this.features=new Map,this.disabled=[],this.update(u)}resetDisabled(){this.disabled.length=0,this.update(this.server)}disable(u){this.disabled.push(u),this.update(this.server)}isDisabled(u){return this.disabled.indexOf(u)!==-1}update(u){typeof u=="string"&&(u=e(u)),this.server=u,this.set(t.Feature.JS_KV,"2.6.2"),this.set(t.Feature.JS_OBJECTSTORE,"2.6.3"),this.set(t.Feature.JS_PULL_MAX_BYTES,"2.8.3"),this.set(t.Feature.JS_NEW_CONSUMER_CREATE_API,"2.9.0"),this.set(t.Feature.JS_ALLOW_DIRECT,"2.9.0"),this.set(t.Feature.JS_MULTIPLE_CONSUMER_FILTER,"2.10.0"),this.set(t.Feature.JS_SIMPLIFICATION,"2.9.4"),this.set(t.Feature.JS_STREAM_CONSUMER_METADATA,"2.10.0"),this.set(t.Feature.JS_CONSUMER_FILTER_SUBJECTS,"2.10.0"),this.set(t.Feature.JS_STREAM_FIRST_SEQ,"2.10.0"),this.set(t.Feature.JS_STREAM_SUBJECT_TRANSFORM,"2.10.0"),this.set(t.Feature.JS_STREAM_SOURCE_SUBJECT_TRANSFORM,"2.10.0"),this.set(t.Feature.JS_STREAM_COMPRESSION,"2.10.0"),this.set(t.Feature.JS_DEFAULT_CONSUMER_LIMITS,"2.10.0"),this.set(t.Feature.JS_BATCH_DIRECT_GET,"2.11.0"),this.set(t.Feature.JS_PRIORITY_GROUPS,"2.11.0"),this.disabled.forEach(l=>{this.features.delete(l)})}set(u,l){this.features.set(u,{min:l,ok:r(this.server,e(l))>=0})}get(u){return this.features.get(u)||{min:"unknown",ok:!1}}supports(u){var l;return((l=this.get(u))==null?void 0:l.ok)||!1}require(u){return typeof u=="string"&&(u=e(u)),r(this.server,u)>=0}}t.Features=i})(Xt);var Mt={},qe={},It={},wn={},xe={},jt={},Tt={},Nt={};Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.crc16=void 0;const Vi=new Uint16Array([0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920]);class Sr{static checksum(e){let r=0;for(let i=0;i<e.byteLength;i++){const a=e[i];r=r<<8&65535^Vi[(r>>8^a)&255]}return r}static validate(e,r){return Sr.checksum(e)==r}}Nt.crc16=Sr;var Rt={};Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.base32=void 0;const Or="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";class Ji{static encode(e){let r=0,i=0;const a=new Uint8Array(e),u=new Uint8Array(e.byteLength*2);let l=0;for(let m=0;m<a.byteLength;m++)for(i=i<<8|a[m],r+=8;r>=5;){const P=i>>>r-5&31;u[l++]=Or.charAt(P).charCodeAt(0),r-=5}if(r>0){const m=i<<5-r&31;u[l++]=Or.charAt(m).charCodeAt(0)}return u.slice(0,l)}static decode(e){let r=0,i=0,a=0;const u=new Uint8Array(e),l=new Uint8Array(u.byteLength*5/8|0);for(let m=0;m<u.byteLength;m++){const P=String.fromCharCode(u[m]),g=Or.indexOf(P);if(g===-1)throw new Error("Illegal Base32 character: "+u[m]);i=i<<5|g,r+=5,r>=8&&(l[a++]=i>>>r-8&255,r-=8)}return l.slice(0,a)}}Rt.base32=Ji;var Pn;function Zt(){if(Pn)return Tt;Pn=1,Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.Codec=void 0;const t=Nt,e=yt(),r=Rt;class i{static encode(u,l){if(!l||!(l instanceof Uint8Array))throw new e.NKeysError(e.NKeysErrorCode.SerializationError);if(!e.Prefixes.isValidPrefix(u))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);return i._encode(!1,u,l)}static encodeSeed(u,l){if(!l)throw new e.NKeysError(e.NKeysErrorCode.ApiError);if(!e.Prefixes.isValidPublicPrefix(u))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);if(l.byteLength!==32)throw new e.NKeysError(e.NKeysErrorCode.InvalidSeedLen);return i._encode(!0,u,l)}static decode(u,l){if(!e.Prefixes.isValidPrefix(u))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);const m=i._decode(l);if(m[0]!==u)throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);return m.slice(1)}static decodeSeed(u){const l=i._decode(u),m=i._decodePrefix(l);if(m[0]!=e.Prefix.Seed)throw new e.NKeysError(e.NKeysErrorCode.InvalidSeed);if(!e.Prefixes.isValidPublicPrefix(m[1]))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);return{buf:l.slice(2),prefix:m[1]}}static _encode(u,l,m){const P=u?2:1,g=m.byteLength,w=P+g+2,b=P+g,x=new Uint8Array(w);if(u){const U=i._encodePrefix(e.Prefix.Seed,l);x.set(U)}else x[0]=l;x.set(m,P);const R=t.crc16.checksum(x.slice(0,b));return new DataView(x.buffer).setUint16(b,R,!0),r.base32.encode(x)}static _decode(u){if(u.byteLength<4)throw new e.NKeysError(e.NKeysErrorCode.InvalidEncoding);let l;try{l=r.base32.decode(u)}catch(w){throw new e.NKeysError(e.NKeysErrorCode.InvalidEncoding,{cause:w})}const m=l.byteLength-2,g=new DataView(l.buffer).getUint16(m,!0),E=l.slice(0,m);if(!t.crc16.validate(E,g))throw new e.NKeysError(e.NKeysErrorCode.InvalidChecksum);return E}static _encodePrefix(u,l){const m=u|l>>5,P=(l&31)<<3;return new Uint8Array([m,P])}static _decodePrefix(u){const l=u[0]&248,m=(u[0]&7)<<5|(u[1]&248)>>3;return new Uint8Array([l,m])}}return Tt.Codec=i,Tt}var bt={};function Yi(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Sn={exports:{}};const Wi=tt(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(t){(function(e){var r=function(s){var c,o=new Float64Array(16);if(s)for(c=0;c<s.length;c++)o[c]=s[c];return o},i=function(){throw new Error("no PRNG")},a=new Uint8Array(16),u=new Uint8Array(32);u[0]=9;var l=r(),m=r([1]),P=r([56129,1]),g=r([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),E=r([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),w=r([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),b=r([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),x=r([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function R(s,c,o,n){s[c]=o>>24&255,s[c+1]=o>>16&255,s[c+2]=o>>8&255,s[c+3]=o&255,s[c+4]=n>>24&255,s[c+5]=n>>16&255,s[c+6]=n>>8&255,s[c+7]=n&255}function j(s,c,o,n,f){var y,_=0;for(y=0;y<f;y++)_|=s[c+y]^o[n+y];return(1&_-1>>>8)-1}function U(s,c,o,n){return j(s,c,o,n,16)}function ie(s,c,o,n){return j(s,c,o,n,32)}function _e(s,c,o,n){for(var f=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,y=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,_=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,O=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,I=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,$=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,N=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,ce=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,F=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,G=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,H=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,X=o[16]&255|(o[17]&255)<<8|(o[18]&255)<<16|(o[19]&255)<<24,W=o[20]&255|(o[21]&255)<<8|(o[22]&255)<<16|(o[23]&255)<<24,V=o[24]&255|(o[25]&255)<<8|(o[26]&255)<<16|(o[27]&255)<<24,Y=o[28]&255|(o[29]&255)<<8|(o[30]&255)<<16|(o[31]&255)<<24,J=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,K=f,q=y,k=_,B=O,D=I,T=$,v=N,p=ce,C=F,S=G,A=H,M=X,z=W,Z=V,ee=Y,Q=J,h,ne=0;ne<20;ne+=2)h=K+z|0,D^=h<<7|h>>>25,h=D+K|0,C^=h<<9|h>>>23,h=C+D|0,z^=h<<13|h>>>19,h=z+C|0,K^=h<<18|h>>>14,h=T+q|0,S^=h<<7|h>>>25,h=S+T|0,Z^=h<<9|h>>>23,h=Z+S|0,q^=h<<13|h>>>19,h=q+Z|0,T^=h<<18|h>>>14,h=A+v|0,ee^=h<<7|h>>>25,h=ee+A|0,k^=h<<9|h>>>23,h=k+ee|0,v^=h<<13|h>>>19,h=v+k|0,A^=h<<18|h>>>14,h=Q+M|0,B^=h<<7|h>>>25,h=B+Q|0,p^=h<<9|h>>>23,h=p+B|0,M^=h<<13|h>>>19,h=M+p|0,Q^=h<<18|h>>>14,h=K+B|0,q^=h<<7|h>>>25,h=q+K|0,k^=h<<9|h>>>23,h=k+q|0,B^=h<<13|h>>>19,h=B+k|0,K^=h<<18|h>>>14,h=T+D|0,v^=h<<7|h>>>25,h=v+T|0,p^=h<<9|h>>>23,h=p+v|0,D^=h<<13|h>>>19,h=D+p|0,T^=h<<18|h>>>14,h=A+S|0,M^=h<<7|h>>>25,h=M+A|0,C^=h<<9|h>>>23,h=C+M|0,S^=h<<13|h>>>19,h=S+C|0,A^=h<<18|h>>>14,h=Q+ee|0,z^=h<<7|h>>>25,h=z+Q|0,Z^=h<<9|h>>>23,h=Z+z|0,ee^=h<<13|h>>>19,h=ee+Z|0,Q^=h<<18|h>>>14;K=K+f|0,q=q+y|0,k=k+_|0,B=B+O|0,D=D+I|0,T=T+$|0,v=v+N|0,p=p+ce|0,C=C+F|0,S=S+G|0,A=A+H|0,M=M+X|0,z=z+W|0,Z=Z+V|0,ee=ee+Y|0,Q=Q+J|0,s[0]=K>>>0&255,s[1]=K>>>8&255,s[2]=K>>>16&255,s[3]=K>>>24&255,s[4]=q>>>0&255,s[5]=q>>>8&255,s[6]=q>>>16&255,s[7]=q>>>24&255,s[8]=k>>>0&255,s[9]=k>>>8&255,s[10]=k>>>16&255,s[11]=k>>>24&255,s[12]=B>>>0&255,s[13]=B>>>8&255,s[14]=B>>>16&255,s[15]=B>>>24&255,s[16]=D>>>0&255,s[17]=D>>>8&255,s[18]=D>>>16&255,s[19]=D>>>24&255,s[20]=T>>>0&255,s[21]=T>>>8&255,s[22]=T>>>16&255,s[23]=T>>>24&255,s[24]=v>>>0&255,s[25]=v>>>8&255,s[26]=v>>>16&255,s[27]=v>>>24&255,s[28]=p>>>0&255,s[29]=p>>>8&255,s[30]=p>>>16&255,s[31]=p>>>24&255,s[32]=C>>>0&255,s[33]=C>>>8&255,s[34]=C>>>16&255,s[35]=C>>>24&255,s[36]=S>>>0&255,s[37]=S>>>8&255,s[38]=S>>>16&255,s[39]=S>>>24&255,s[40]=A>>>0&255,s[41]=A>>>8&255,s[42]=A>>>16&255,s[43]=A>>>24&255,s[44]=M>>>0&255,s[45]=M>>>8&255,s[46]=M>>>16&255,s[47]=M>>>24&255,s[48]=z>>>0&255,s[49]=z>>>8&255,s[50]=z>>>16&255,s[51]=z>>>24&255,s[52]=Z>>>0&255,s[53]=Z>>>8&255,s[54]=Z>>>16&255,s[55]=Z>>>24&255,s[56]=ee>>>0&255,s[57]=ee>>>8&255,s[58]=ee>>>16&255,s[59]=ee>>>24&255,s[60]=Q>>>0&255,s[61]=Q>>>8&255,s[62]=Q>>>16&255,s[63]=Q>>>24&255}function Fe(s,c,o,n){for(var f=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,y=o[0]&255|(o[1]&255)<<8|(o[2]&255)<<16|(o[3]&255)<<24,_=o[4]&255|(o[5]&255)<<8|(o[6]&255)<<16|(o[7]&255)<<24,O=o[8]&255|(o[9]&255)<<8|(o[10]&255)<<16|(o[11]&255)<<24,I=o[12]&255|(o[13]&255)<<8|(o[14]&255)<<16|(o[15]&255)<<24,$=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,N=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,ce=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,F=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,G=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,H=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,X=o[16]&255|(o[17]&255)<<8|(o[18]&255)<<16|(o[19]&255)<<24,W=o[20]&255|(o[21]&255)<<8|(o[22]&255)<<16|(o[23]&255)<<24,V=o[24]&255|(o[25]&255)<<8|(o[26]&255)<<16|(o[27]&255)<<24,Y=o[28]&255|(o[29]&255)<<8|(o[30]&255)<<16|(o[31]&255)<<24,J=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,K=f,q=y,k=_,B=O,D=I,T=$,v=N,p=ce,C=F,S=G,A=H,M=X,z=W,Z=V,ee=Y,Q=J,h,ne=0;ne<20;ne+=2)h=K+z|0,D^=h<<7|h>>>25,h=D+K|0,C^=h<<9|h>>>23,h=C+D|0,z^=h<<13|h>>>19,h=z+C|0,K^=h<<18|h>>>14,h=T+q|0,S^=h<<7|h>>>25,h=S+T|0,Z^=h<<9|h>>>23,h=Z+S|0,q^=h<<13|h>>>19,h=q+Z|0,T^=h<<18|h>>>14,h=A+v|0,ee^=h<<7|h>>>25,h=ee+A|0,k^=h<<9|h>>>23,h=k+ee|0,v^=h<<13|h>>>19,h=v+k|0,A^=h<<18|h>>>14,h=Q+M|0,B^=h<<7|h>>>25,h=B+Q|0,p^=h<<9|h>>>23,h=p+B|0,M^=h<<13|h>>>19,h=M+p|0,Q^=h<<18|h>>>14,h=K+B|0,q^=h<<7|h>>>25,h=q+K|0,k^=h<<9|h>>>23,h=k+q|0,B^=h<<13|h>>>19,h=B+k|0,K^=h<<18|h>>>14,h=T+D|0,v^=h<<7|h>>>25,h=v+T|0,p^=h<<9|h>>>23,h=p+v|0,D^=h<<13|h>>>19,h=D+p|0,T^=h<<18|h>>>14,h=A+S|0,M^=h<<7|h>>>25,h=M+A|0,C^=h<<9|h>>>23,h=C+M|0,S^=h<<13|h>>>19,h=S+C|0,A^=h<<18|h>>>14,h=Q+ee|0,z^=h<<7|h>>>25,h=z+Q|0,Z^=h<<9|h>>>23,h=Z+z|0,ee^=h<<13|h>>>19,h=ee+Z|0,Q^=h<<18|h>>>14;s[0]=K>>>0&255,s[1]=K>>>8&255,s[2]=K>>>16&255,s[3]=K>>>24&255,s[4]=T>>>0&255,s[5]=T>>>8&255,s[6]=T>>>16&255,s[7]=T>>>24&255,s[8]=A>>>0&255,s[9]=A>>>8&255,s[10]=A>>>16&255,s[11]=A>>>24&255,s[12]=Q>>>0&255,s[13]=Q>>>8&255,s[14]=Q>>>16&255,s[15]=Q>>>24&255,s[16]=v>>>0&255,s[17]=v>>>8&255,s[18]=v>>>16&255,s[19]=v>>>24&255,s[20]=p>>>0&255,s[21]=p>>>8&255,s[22]=p>>>16&255,s[23]=p>>>24&255,s[24]=C>>>0&255,s[25]=C>>>8&255,s[26]=C>>>16&255,s[27]=C>>>24&255,s[28]=S>>>0&255,s[29]=S>>>8&255,s[30]=S>>>16&255,s[31]=S>>>24&255}function L(s,c,o,n){_e(s,c,o,n)}function le(s,c,o,n){Fe(s,c,o,n)}var de=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function He(s,c,o,n,f,y,_){var O=new Uint8Array(16),I=new Uint8Array(64),$,N;for(N=0;N<16;N++)O[N]=0;for(N=0;N<8;N++)O[N]=y[N];for(;f>=64;){for(L(I,O,_,de),N=0;N<64;N++)s[c+N]=o[n+N]^I[N];for($=1,N=8;N<16;N++)$=$+(O[N]&255)|0,O[N]=$&255,$>>>=8;f-=64,c+=64,n+=64}if(f>0)for(L(I,O,_,de),N=0;N<f;N++)s[c+N]=o[n+N]^I[N];return 0}function Lt(s,c,o,n,f){var y=new Uint8Array(16),_=new Uint8Array(64),O,I;for(I=0;I<16;I++)y[I]=0;for(I=0;I<8;I++)y[I]=n[I];for(;o>=64;){for(L(_,y,f,de),I=0;I<64;I++)s[c+I]=_[I];for(O=1,I=8;I<16;I++)O=O+(y[I]&255)|0,y[I]=O&255,O>>>=8;o-=64,c+=64}if(o>0)for(L(_,y,f,de),I=0;I<o;I++)s[c+I]=_[I];return 0}function gt(s,c,o,n,f){var y=new Uint8Array(32);le(y,n,f,de);for(var _=new Uint8Array(8),O=0;O<8;O++)_[O]=n[O+16];return Lt(s,c,o,_,y)}function mt(s,c,o,n,f,y,_){var O=new Uint8Array(32);le(O,y,_,de);for(var I=new Uint8Array(8),$=0;$<8;$++)I[$]=y[$+16];return He(s,c,o,n,f,I,O)}var vt=function(s){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var c,o,n,f,y,_,O,I;c=s[0]&255|(s[1]&255)<<8,this.r[0]=c&8191,o=s[2]&255|(s[3]&255)<<8,this.r[1]=(c>>>13|o<<3)&8191,n=s[4]&255|(s[5]&255)<<8,this.r[2]=(o>>>10|n<<6)&7939,f=s[6]&255|(s[7]&255)<<8,this.r[3]=(n>>>7|f<<9)&8191,y=s[8]&255|(s[9]&255)<<8,this.r[4]=(f>>>4|y<<12)&255,this.r[5]=y>>>1&8190,_=s[10]&255|(s[11]&255)<<8,this.r[6]=(y>>>14|_<<2)&8191,O=s[12]&255|(s[13]&255)<<8,this.r[7]=(_>>>11|O<<5)&8065,I=s[14]&255|(s[15]&255)<<8,this.r[8]=(O>>>8|I<<8)&8191,this.r[9]=I>>>5&127,this.pad[0]=s[16]&255|(s[17]&255)<<8,this.pad[1]=s[18]&255|(s[19]&255)<<8,this.pad[2]=s[20]&255|(s[21]&255)<<8,this.pad[3]=s[22]&255|(s[23]&255)<<8,this.pad[4]=s[24]&255|(s[25]&255)<<8,this.pad[5]=s[26]&255|(s[27]&255)<<8,this.pad[6]=s[28]&255|(s[29]&255)<<8,this.pad[7]=s[30]&255|(s[31]&255)<<8};vt.prototype.blocks=function(s,c,o){for(var n=this.fin?0:2048,f,y,_,O,I,$,N,ce,F,G,H,X,W,V,Y,J,K,q,k,B=this.h[0],D=this.h[1],T=this.h[2],v=this.h[3],p=this.h[4],C=this.h[5],S=this.h[6],A=this.h[7],M=this.h[8],z=this.h[9],Z=this.r[0],ee=this.r[1],Q=this.r[2],h=this.r[3],ne=this.r[4],fe=this.r[5],ue=this.r[6],re=this.r[7],oe=this.r[8],ae=this.r[9];o>=16;)f=s[c+0]&255|(s[c+1]&255)<<8,B+=f&8191,y=s[c+2]&255|(s[c+3]&255)<<8,D+=(f>>>13|y<<3)&8191,_=s[c+4]&255|(s[c+5]&255)<<8,T+=(y>>>10|_<<6)&8191,O=s[c+6]&255|(s[c+7]&255)<<8,v+=(_>>>7|O<<9)&8191,I=s[c+8]&255|(s[c+9]&255)<<8,p+=(O>>>4|I<<12)&8191,C+=I>>>1&8191,$=s[c+10]&255|(s[c+11]&255)<<8,S+=(I>>>14|$<<2)&8191,N=s[c+12]&255|(s[c+13]&255)<<8,A+=($>>>11|N<<5)&8191,ce=s[c+14]&255|(s[c+15]&255)<<8,M+=(N>>>8|ce<<8)&8191,z+=ce>>>5|n,F=0,G=F,G+=B*Z,G+=D*(5*ae),G+=T*(5*oe),G+=v*(5*re),G+=p*(5*ue),F=G>>>13,G&=8191,G+=C*(5*fe),G+=S*(5*ne),G+=A*(5*h),G+=M*(5*Q),G+=z*(5*ee),F+=G>>>13,G&=8191,H=F,H+=B*ee,H+=D*Z,H+=T*(5*ae),H+=v*(5*oe),H+=p*(5*re),F=H>>>13,H&=8191,H+=C*(5*ue),H+=S*(5*fe),H+=A*(5*ne),H+=M*(5*h),H+=z*(5*Q),F+=H>>>13,H&=8191,X=F,X+=B*Q,X+=D*ee,X+=T*Z,X+=v*(5*ae),X+=p*(5*oe),F=X>>>13,X&=8191,X+=C*(5*re),X+=S*(5*ue),X+=A*(5*fe),X+=M*(5*ne),X+=z*(5*h),F+=X>>>13,X&=8191,W=F,W+=B*h,W+=D*Q,W+=T*ee,W+=v*Z,W+=p*(5*ae),F=W>>>13,W&=8191,W+=C*(5*oe),W+=S*(5*re),W+=A*(5*ue),W+=M*(5*fe),W+=z*(5*ne),F+=W>>>13,W&=8191,V=F,V+=B*ne,V+=D*h,V+=T*Q,V+=v*ee,V+=p*Z,F=V>>>13,V&=8191,V+=C*(5*ae),V+=S*(5*oe),V+=A*(5*re),V+=M*(5*ue),V+=z*(5*fe),F+=V>>>13,V&=8191,Y=F,Y+=B*fe,Y+=D*ne,Y+=T*h,Y+=v*Q,Y+=p*ee,F=Y>>>13,Y&=8191,Y+=C*Z,Y+=S*(5*ae),Y+=A*(5*oe),Y+=M*(5*re),Y+=z*(5*ue),F+=Y>>>13,Y&=8191,J=F,J+=B*ue,J+=D*fe,J+=T*ne,J+=v*h,J+=p*Q,F=J>>>13,J&=8191,J+=C*ee,J+=S*Z,J+=A*(5*ae),J+=M*(5*oe),J+=z*(5*re),F+=J>>>13,J&=8191,K=F,K+=B*re,K+=D*ue,K+=T*fe,K+=v*ne,K+=p*h,F=K>>>13,K&=8191,K+=C*Q,K+=S*ee,K+=A*Z,K+=M*(5*ae),K+=z*(5*oe),F+=K>>>13,K&=8191,q=F,q+=B*oe,q+=D*re,q+=T*ue,q+=v*fe,q+=p*ne,F=q>>>13,q&=8191,q+=C*h,q+=S*Q,q+=A*ee,q+=M*Z,q+=z*(5*ae),F+=q>>>13,q&=8191,k=F,k+=B*ae,k+=D*oe,k+=T*re,k+=v*ue,k+=p*fe,F=k>>>13,k&=8191,k+=C*ne,k+=S*h,k+=A*Q,k+=M*ee,k+=z*Z,F+=k>>>13,k&=8191,F=(F<<2)+F|0,F=F+G|0,G=F&8191,F=F>>>13,H+=F,B=G,D=H,T=X,v=W,p=V,C=Y,S=J,A=K,M=q,z=k,c+=16,o-=16;this.h[0]=B,this.h[1]=D,this.h[2]=T,this.h[3]=v,this.h[4]=p,this.h[5]=C,this.h[6]=S,this.h[7]=A,this.h[8]=M,this.h[9]=z},vt.prototype.finish=function(s,c){var o=new Uint16Array(10),n,f,y,_;if(this.leftover){for(_=this.leftover,this.buffer[_++]=1;_<16;_++)this.buffer[_]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,_=2;_<10;_++)this.h[_]+=n,n=this.h[_]>>>13,this.h[_]&=8191;for(this.h[0]+=n*5,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,o[0]=this.h[0]+5,n=o[0]>>>13,o[0]&=8191,_=1;_<10;_++)o[_]=this.h[_]+n,n=o[_]>>>13,o[_]&=8191;for(o[9]-=8192,f=(n^1)-1,_=0;_<10;_++)o[_]&=f;for(f=~f,_=0;_<10;_++)this.h[_]=this.h[_]&f|o[_];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,y=this.h[0]+this.pad[0],this.h[0]=y&65535,_=1;_<8;_++)y=(this.h[_]+this.pad[_]|0)+(y>>>16)|0,this.h[_]=y&65535;s[c+0]=this.h[0]>>>0&255,s[c+1]=this.h[0]>>>8&255,s[c+2]=this.h[1]>>>0&255,s[c+3]=this.h[1]>>>8&255,s[c+4]=this.h[2]>>>0&255,s[c+5]=this.h[2]>>>8&255,s[c+6]=this.h[3]>>>0&255,s[c+7]=this.h[3]>>>8&255,s[c+8]=this.h[4]>>>0&255,s[c+9]=this.h[4]>>>8&255,s[c+10]=this.h[5]>>>0&255,s[c+11]=this.h[5]>>>8&255,s[c+12]=this.h[6]>>>0&255,s[c+13]=this.h[6]>>>8&255,s[c+14]=this.h[7]>>>0&255,s[c+15]=this.h[7]>>>8&255},vt.prototype.update=function(s,c,o){var n,f;if(this.leftover){for(f=16-this.leftover,f>o&&(f=o),n=0;n<f;n++)this.buffer[this.leftover+n]=s[c+n];if(o-=f,c+=f,this.leftover+=f,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(o>=16&&(f=o-o%16,this.blocks(s,c,f),c+=f,o-=f),o){for(n=0;n<o;n++)this.buffer[this.leftover+n]=s[c+n];this.leftover+=o}};function xt(s,c,o,n,f,y){var _=new vt(y);return _.update(o,n,f),_.finish(s,c),0}function Ft(s,c,o,n,f,y){var _=new Uint8Array(16);return xt(_,0,o,n,f,y),U(s,c,_,0)}function Pe(s,c,o,n,f){var y;if(o<32)return-1;for(mt(s,0,c,0,o,n,f),xt(s,16,s,32,o-32,s),y=0;y<16;y++)s[y]=0;return 0}function Ve(s,c,o,n,f){var y,_=new Uint8Array(32);if(o<32||(gt(_,0,32,n,f),Ft(c,16,c,32,o-32,_)!==0))return-1;for(mt(s,0,c,0,o,n,f),y=0;y<32;y++)s[y]=0;return 0}function Se(s,c){var o;for(o=0;o<16;o++)s[o]=c[o]|0}function Ne(s){var c,o,n=1;for(c=0;c<16;c++)o=s[c]+n+65535,n=Math.floor(o/65536),s[c]=o-n*65536;s[0]+=n-1+37*(n-1)}function Re(s,c,o){for(var n,f=~(o-1),y=0;y<16;y++)n=f&(s[y]^c[y]),s[y]^=n,c[y]^=n}function Ue(s,c){var o,n,f,y=r(),_=r();for(o=0;o<16;o++)_[o]=c[o];for(Ne(_),Ne(_),Ne(_),n=0;n<2;n++){for(y[0]=_[0]-65517,o=1;o<15;o++)y[o]=_[o]-65535-(y[o-1]>>16&1),y[o-1]&=65535;y[15]=_[15]-32767-(y[14]>>16&1),f=y[15]>>16&1,y[14]&=65535,Re(_,y,1-f)}for(o=0;o<16;o++)s[2*o]=_[o]&255,s[2*o+1]=_[o]>>8}function Yn(s,c){var o=new Uint8Array(32),n=new Uint8Array(32);return Ue(o,s),Ue(n,c),ie(o,0,n,0)}function Wn(s){var c=new Uint8Array(32);return Ue(c,s),c[0]&1}function kr(s,c){var o;for(o=0;o<16;o++)s[o]=c[2*o]+(c[2*o+1]<<8);s[15]&=32767}function De(s,c,o){for(var n=0;n<16;n++)s[n]=c[n]+o[n]}function $e(s,c,o){for(var n=0;n<16;n++)s[n]=c[n]-o[n]}function se(s,c,o){var n,f,y=0,_=0,O=0,I=0,$=0,N=0,ce=0,F=0,G=0,H=0,X=0,W=0,V=0,Y=0,J=0,K=0,q=0,k=0,B=0,D=0,T=0,v=0,p=0,C=0,S=0,A=0,M=0,z=0,Z=0,ee=0,Q=0,h=o[0],ne=o[1],fe=o[2],ue=o[3],re=o[4],oe=o[5],ae=o[6],pe=o[7],be=o[8],ge=o[9],me=o[10],ve=o[11],we=o[12],Ce=o[13],Me=o[14],Ie=o[15];n=c[0],y+=n*h,_+=n*ne,O+=n*fe,I+=n*ue,$+=n*re,N+=n*oe,ce+=n*ae,F+=n*pe,G+=n*be,H+=n*ge,X+=n*me,W+=n*ve,V+=n*we,Y+=n*Ce,J+=n*Me,K+=n*Ie,n=c[1],_+=n*h,O+=n*ne,I+=n*fe,$+=n*ue,N+=n*re,ce+=n*oe,F+=n*ae,G+=n*pe,H+=n*be,X+=n*ge,W+=n*me,V+=n*ve,Y+=n*we,J+=n*Ce,K+=n*Me,q+=n*Ie,n=c[2],O+=n*h,I+=n*ne,$+=n*fe,N+=n*ue,ce+=n*re,F+=n*oe,G+=n*ae,H+=n*pe,X+=n*be,W+=n*ge,V+=n*me,Y+=n*ve,J+=n*we,K+=n*Ce,q+=n*Me,k+=n*Ie,n=c[3],I+=n*h,$+=n*ne,N+=n*fe,ce+=n*ue,F+=n*re,G+=n*oe,H+=n*ae,X+=n*pe,W+=n*be,V+=n*ge,Y+=n*me,J+=n*ve,K+=n*we,q+=n*Ce,k+=n*Me,B+=n*Ie,n=c[4],$+=n*h,N+=n*ne,ce+=n*fe,F+=n*ue,G+=n*re,H+=n*oe,X+=n*ae,W+=n*pe,V+=n*be,Y+=n*ge,J+=n*me,K+=n*ve,q+=n*we,k+=n*Ce,B+=n*Me,D+=n*Ie,n=c[5],N+=n*h,ce+=n*ne,F+=n*fe,G+=n*ue,H+=n*re,X+=n*oe,W+=n*ae,V+=n*pe,Y+=n*be,J+=n*ge,K+=n*me,q+=n*ve,k+=n*we,B+=n*Ce,D+=n*Me,T+=n*Ie,n=c[6],ce+=n*h,F+=n*ne,G+=n*fe,H+=n*ue,X+=n*re,W+=n*oe,V+=n*ae,Y+=n*pe,J+=n*be,K+=n*ge,q+=n*me,k+=n*ve,B+=n*we,D+=n*Ce,T+=n*Me,v+=n*Ie,n=c[7],F+=n*h,G+=n*ne,H+=n*fe,X+=n*ue,W+=n*re,V+=n*oe,Y+=n*ae,J+=n*pe,K+=n*be,q+=n*ge,k+=n*me,B+=n*ve,D+=n*we,T+=n*Ce,v+=n*Me,p+=n*Ie,n=c[8],G+=n*h,H+=n*ne,X+=n*fe,W+=n*ue,V+=n*re,Y+=n*oe,J+=n*ae,K+=n*pe,q+=n*be,k+=n*ge,B+=n*me,D+=n*ve,T+=n*we,v+=n*Ce,p+=n*Me,C+=n*Ie,n=c[9],H+=n*h,X+=n*ne,W+=n*fe,V+=n*ue,Y+=n*re,J+=n*oe,K+=n*ae,q+=n*pe,k+=n*be,B+=n*ge,D+=n*me,T+=n*ve,v+=n*we,p+=n*Ce,C+=n*Me,S+=n*Ie,n=c[10],X+=n*h,W+=n*ne,V+=n*fe,Y+=n*ue,J+=n*re,K+=n*oe,q+=n*ae,k+=n*pe,B+=n*be,D+=n*ge,T+=n*me,v+=n*ve,p+=n*we,C+=n*Ce,S+=n*Me,A+=n*Ie,n=c[11],W+=n*h,V+=n*ne,Y+=n*fe,J+=n*ue,K+=n*re,q+=n*oe,k+=n*ae,B+=n*pe,D+=n*be,T+=n*ge,v+=n*me,p+=n*ve,C+=n*we,S+=n*Ce,A+=n*Me,M+=n*Ie,n=c[12],V+=n*h,Y+=n*ne,J+=n*fe,K+=n*ue,q+=n*re,k+=n*oe,B+=n*ae,D+=n*pe,T+=n*be,v+=n*ge,p+=n*me,C+=n*ve,S+=n*we,A+=n*Ce,M+=n*Me,z+=n*Ie,n=c[13],Y+=n*h,J+=n*ne,K+=n*fe,q+=n*ue,k+=n*re,B+=n*oe,D+=n*ae,T+=n*pe,v+=n*be,p+=n*ge,C+=n*me,S+=n*ve,A+=n*we,M+=n*Ce,z+=n*Me,Z+=n*Ie,n=c[14],J+=n*h,K+=n*ne,q+=n*fe,k+=n*ue,B+=n*re,D+=n*oe,T+=n*ae,v+=n*pe,p+=n*be,C+=n*ge,S+=n*me,A+=n*ve,M+=n*we,z+=n*Ce,Z+=n*Me,ee+=n*Ie,n=c[15],K+=n*h,q+=n*ne,k+=n*fe,B+=n*ue,D+=n*re,T+=n*oe,v+=n*ae,p+=n*pe,C+=n*be,S+=n*ge,A+=n*me,M+=n*ve,z+=n*we,Z+=n*Ce,ee+=n*Me,Q+=n*Ie,y+=38*q,_+=38*k,O+=38*B,I+=38*D,$+=38*T,N+=38*v,ce+=38*p,F+=38*C,G+=38*S,H+=38*A,X+=38*M,W+=38*z,V+=38*Z,Y+=38*ee,J+=38*Q,f=1,n=y+f+65535,f=Math.floor(n/65536),y=n-f*65536,n=_+f+65535,f=Math.floor(n/65536),_=n-f*65536,n=O+f+65535,f=Math.floor(n/65536),O=n-f*65536,n=I+f+65535,f=Math.floor(n/65536),I=n-f*65536,n=$+f+65535,f=Math.floor(n/65536),$=n-f*65536,n=N+f+65535,f=Math.floor(n/65536),N=n-f*65536,n=ce+f+65535,f=Math.floor(n/65536),ce=n-f*65536,n=F+f+65535,f=Math.floor(n/65536),F=n-f*65536,n=G+f+65535,f=Math.floor(n/65536),G=n-f*65536,n=H+f+65535,f=Math.floor(n/65536),H=n-f*65536,n=X+f+65535,f=Math.floor(n/65536),X=n-f*65536,n=W+f+65535,f=Math.floor(n/65536),W=n-f*65536,n=V+f+65535,f=Math.floor(n/65536),V=n-f*65536,n=Y+f+65535,f=Math.floor(n/65536),Y=n-f*65536,n=J+f+65535,f=Math.floor(n/65536),J=n-f*65536,n=K+f+65535,f=Math.floor(n/65536),K=n-f*65536,y+=f-1+37*(f-1),f=1,n=y+f+65535,f=Math.floor(n/65536),y=n-f*65536,n=_+f+65535,f=Math.floor(n/65536),_=n-f*65536,n=O+f+65535,f=Math.floor(n/65536),O=n-f*65536,n=I+f+65535,f=Math.floor(n/65536),I=n-f*65536,n=$+f+65535,f=Math.floor(n/65536),$=n-f*65536,n=N+f+65535,f=Math.floor(n/65536),N=n-f*65536,n=ce+f+65535,f=Math.floor(n/65536),ce=n-f*65536,n=F+f+65535,f=Math.floor(n/65536),F=n-f*65536,n=G+f+65535,f=Math.floor(n/65536),G=n-f*65536,n=H+f+65535,f=Math.floor(n/65536),H=n-f*65536,n=X+f+65535,f=Math.floor(n/65536),X=n-f*65536,n=W+f+65535,f=Math.floor(n/65536),W=n-f*65536,n=V+f+65535,f=Math.floor(n/65536),V=n-f*65536,n=Y+f+65535,f=Math.floor(n/65536),Y=n-f*65536,n=J+f+65535,f=Math.floor(n/65536),J=n-f*65536,n=K+f+65535,f=Math.floor(n/65536),K=n-f*65536,y+=f-1+37*(f-1),s[0]=y,s[1]=_,s[2]=O,s[3]=I,s[4]=$,s[5]=N,s[6]=ce,s[7]=F,s[8]=G,s[9]=H,s[10]=X,s[11]=W,s[12]=V,s[13]=Y,s[14]=J,s[15]=K}function Ke(s,c){se(s,c,c)}function Xn(s,c){var o=r(),n;for(n=0;n<16;n++)o[n]=c[n];for(n=253;n>=0;n--)Ke(o,o),n!==2&&n!==4&&se(o,o,c);for(n=0;n<16;n++)s[n]=o[n]}function Zn(s,c){var o=r(),n;for(n=0;n<16;n++)o[n]=c[n];for(n=250;n>=0;n--)Ke(o,o),n!==1&&se(o,o,c);for(n=0;n<16;n++)s[n]=o[n]}function ir(s,c,o){var n=new Uint8Array(32),f=new Float64Array(80),y,_,O=r(),I=r(),$=r(),N=r(),ce=r(),F=r();for(_=0;_<31;_++)n[_]=c[_];for(n[31]=c[31]&127|64,n[0]&=248,kr(f,o),_=0;_<16;_++)I[_]=f[_],N[_]=O[_]=$[_]=0;for(O[0]=N[0]=1,_=254;_>=0;--_)y=n[_>>>3]>>>(_&7)&1,Re(O,I,y),Re($,N,y),De(ce,O,$),$e(O,O,$),De($,I,N),$e(I,I,N),Ke(N,ce),Ke(F,O),se(O,$,O),se($,I,ce),De(ce,O,$),$e(O,O,$),Ke(I,O),$e($,N,F),se(O,$,P),De(O,O,N),se($,$,O),se(O,N,F),se(N,I,f),Ke(I,ce),Re(O,I,y),Re($,N,y);for(_=0;_<16;_++)f[_+16]=O[_],f[_+32]=$[_],f[_+48]=I[_],f[_+64]=N[_];var G=f.subarray(32),H=f.subarray(16);return Xn(G,G),se(H,H,G),Ue(s,H),0}function sr(s,c){return ir(s,c,u)}function Qn(s,c){return i(c,32),sr(s,c)}function or(s,c,o){var n=new Uint8Array(32);return ir(n,o,c),le(s,a,n,de)}var ei=Pe,Hs=Ve;function Vs(s,c,o,n,f,y){var _=new Uint8Array(32);return or(_,f,y),ei(s,c,o,n,_)}function Js(s,c,o,n,f,y){var _=new Uint8Array(32);return or(_,f,y),Hs(s,c,o,n,_)}var ti=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function ri(s,c,o,n){for(var f=new Int32Array(16),y=new Int32Array(16),_,O,I,$,N,ce,F,G,H,X,W,V,Y,J,K,q,k,B,D,T,v,p,C,S,A,M,z=s[0],Z=s[1],ee=s[2],Q=s[3],h=s[4],ne=s[5],fe=s[6],ue=s[7],re=c[0],oe=c[1],ae=c[2],pe=c[3],be=c[4],ge=c[5],me=c[6],ve=c[7],we=0;n>=128;){for(D=0;D<16;D++)T=8*D+we,f[D]=o[T+0]<<24|o[T+1]<<16|o[T+2]<<8|o[T+3],y[D]=o[T+4]<<24|o[T+5]<<16|o[T+6]<<8|o[T+7];for(D=0;D<80;D++)if(_=z,O=Z,I=ee,$=Q,N=h,ce=ne,F=fe,G=ue,H=re,X=oe,W=ae,V=pe,Y=be,J=ge,K=me,q=ve,v=ue,p=ve,C=p&65535,S=p>>>16,A=v&65535,M=v>>>16,v=(h>>>14|be<<18)^(h>>>18|be<<14)^(be>>>9|h<<23),p=(be>>>14|h<<18)^(be>>>18|h<<14)^(h>>>9|be<<23),C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,v=h&ne^~h&fe,p=be&ge^~be&me,C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,v=ti[D*2],p=ti[D*2+1],C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,v=f[D%16],p=y[D%16],C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,S+=C>>>16,A+=S>>>16,M+=A>>>16,k=A&65535|M<<16,B=C&65535|S<<16,v=k,p=B,C=p&65535,S=p>>>16,A=v&65535,M=v>>>16,v=(z>>>28|re<<4)^(re>>>2|z<<30)^(re>>>7|z<<25),p=(re>>>28|z<<4)^(z>>>2|re<<30)^(z>>>7|re<<25),C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,v=z&Z^z&ee^Z&ee,p=re&oe^re&ae^oe&ae,C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,S+=C>>>16,A+=S>>>16,M+=A>>>16,G=A&65535|M<<16,q=C&65535|S<<16,v=$,p=V,C=p&65535,S=p>>>16,A=v&65535,M=v>>>16,v=k,p=B,C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,S+=C>>>16,A+=S>>>16,M+=A>>>16,$=A&65535|M<<16,V=C&65535|S<<16,Z=_,ee=O,Q=I,h=$,ne=N,fe=ce,ue=F,z=G,oe=H,ae=X,pe=W,be=V,ge=Y,me=J,ve=K,re=q,D%16===15)for(T=0;T<16;T++)v=f[T],p=y[T],C=p&65535,S=p>>>16,A=v&65535,M=v>>>16,v=f[(T+9)%16],p=y[(T+9)%16],C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,k=f[(T+1)%16],B=y[(T+1)%16],v=(k>>>1|B<<31)^(k>>>8|B<<24)^k>>>7,p=(B>>>1|k<<31)^(B>>>8|k<<24)^(B>>>7|k<<25),C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,k=f[(T+14)%16],B=y[(T+14)%16],v=(k>>>19|B<<13)^(B>>>29|k<<3)^k>>>6,p=(B>>>19|k<<13)^(k>>>29|B<<3)^(B>>>6|k<<26),C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,S+=C>>>16,A+=S>>>16,M+=A>>>16,f[T]=A&65535|M<<16,y[T]=C&65535|S<<16;v=z,p=re,C=p&65535,S=p>>>16,A=v&65535,M=v>>>16,v=s[0],p=c[0],C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,S+=C>>>16,A+=S>>>16,M+=A>>>16,s[0]=z=A&65535|M<<16,c[0]=re=C&65535|S<<16,v=Z,p=oe,C=p&65535,S=p>>>16,A=v&65535,M=v>>>16,v=s[1],p=c[1],C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,S+=C>>>16,A+=S>>>16,M+=A>>>16,s[1]=Z=A&65535|M<<16,c[1]=oe=C&65535|S<<16,v=ee,p=ae,C=p&65535,S=p>>>16,A=v&65535,M=v>>>16,v=s[2],p=c[2],C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,S+=C>>>16,A+=S>>>16,M+=A>>>16,s[2]=ee=A&65535|M<<16,c[2]=ae=C&65535|S<<16,v=Q,p=pe,C=p&65535,S=p>>>16,A=v&65535,M=v>>>16,v=s[3],p=c[3],C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,S+=C>>>16,A+=S>>>16,M+=A>>>16,s[3]=Q=A&65535|M<<16,c[3]=pe=C&65535|S<<16,v=h,p=be,C=p&65535,S=p>>>16,A=v&65535,M=v>>>16,v=s[4],p=c[4],C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,S+=C>>>16,A+=S>>>16,M+=A>>>16,s[4]=h=A&65535|M<<16,c[4]=be=C&65535|S<<16,v=ne,p=ge,C=p&65535,S=p>>>16,A=v&65535,M=v>>>16,v=s[5],p=c[5],C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,S+=C>>>16,A+=S>>>16,M+=A>>>16,s[5]=ne=A&65535|M<<16,c[5]=ge=C&65535|S<<16,v=fe,p=me,C=p&65535,S=p>>>16,A=v&65535,M=v>>>16,v=s[6],p=c[6],C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,S+=C>>>16,A+=S>>>16,M+=A>>>16,s[6]=fe=A&65535|M<<16,c[6]=me=C&65535|S<<16,v=ue,p=ve,C=p&65535,S=p>>>16,A=v&65535,M=v>>>16,v=s[7],p=c[7],C+=p&65535,S+=p>>>16,A+=v&65535,M+=v>>>16,S+=C>>>16,A+=S>>>16,M+=A>>>16,s[7]=ue=A&65535|M<<16,c[7]=ve=C&65535|S<<16,we+=128,n-=128}return n}function at(s,c,o){var n=new Int32Array(8),f=new Int32Array(8),y=new Uint8Array(256),_,O=o;for(n[0]=1779033703,n[1]=3144134277,n[2]=1013904242,n[3]=2773480762,n[4]=1359893119,n[5]=2600822924,n[6]=528734635,n[7]=1541459225,f[0]=4089235720,f[1]=2227873595,f[2]=4271175723,f[3]=1595750129,f[4]=2917565137,f[5]=725511199,f[6]=4215389547,f[7]=327033209,ri(n,f,c,o),o%=128,_=0;_<o;_++)y[_]=c[O-o+_];for(y[o]=128,o=256-128*(o<112?1:0),y[o-9]=0,R(y,o-8,O/536870912|0,O<<3),ri(n,f,y,o),_=0;_<8;_++)R(s,8*_,n[_],f[_]);return 0}function ar(s,c){var o=r(),n=r(),f=r(),y=r(),_=r(),O=r(),I=r(),$=r(),N=r();$e(o,s[1],s[0]),$e(N,c[1],c[0]),se(o,o,N),De(n,s[0],s[1]),De(N,c[0],c[1]),se(n,n,N),se(f,s[3],c[3]),se(f,f,E),se(y,s[2],c[2]),De(y,y,y),$e(_,n,o),$e(O,y,f),De(I,y,f),De($,n,o),se(s[0],_,O),se(s[1],$,I),se(s[2],I,O),se(s[3],_,$)}function ni(s,c,o){var n;for(n=0;n<4;n++)Re(s[n],c[n],o)}function Ur(s,c){var o=r(),n=r(),f=r();Xn(f,c[2]),se(o,c[0],f),se(n,c[1],f),Ue(s,n),s[31]^=Wn(o)<<7}function Lr(s,c,o){var n,f;for(Se(s[0],l),Se(s[1],m),Se(s[2],m),Se(s[3],l),f=255;f>=0;--f)n=o[f/8|0]>>(f&7)&1,ni(s,c,n),ar(c,s),ar(s,s),ni(s,c,n)}function cr(s,c){var o=[r(),r(),r(),r()];Se(o[0],w),Se(o[1],b),Se(o[2],m),se(o[3],w,b),Lr(s,o,c)}function Fr(s,c,o){var n=new Uint8Array(64),f=[r(),r(),r(),r()],y;for(o||i(c,32),at(n,c,32),n[0]&=248,n[31]&=127,n[31]|=64,cr(f,n),Ur(s,f),y=0;y<32;y++)c[y+32]=s[y];return 0}var fr=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 Kr(s,c){var o,n,f,y;for(n=63;n>=32;--n){for(o=0,f=n-32,y=n-12;f<y;++f)c[f]+=o-16*c[n]*fr[f-(n-32)],o=Math.floor((c[f]+128)/256),c[f]-=o*256;c[f]+=o,c[n]=0}for(o=0,f=0;f<32;f++)c[f]+=o-(c[31]>>4)*fr[f],o=c[f]>>8,c[f]&=255;for(f=0;f<32;f++)c[f]-=o*fr[f];for(n=0;n<32;n++)c[n+1]+=c[n]>>8,s[n]=c[n]&255}function Br(s){var c=new Float64Array(64),o;for(o=0;o<64;o++)c[o]=s[o];for(o=0;o<64;o++)s[o]=0;Kr(s,c)}function ii(s,c,o,n){var f=new Uint8Array(64),y=new Uint8Array(64),_=new Uint8Array(64),O,I,$=new Float64Array(64),N=[r(),r(),r(),r()];at(f,n,32),f[0]&=248,f[31]&=127,f[31]|=64;var ce=o+64;for(O=0;O<o;O++)s[64+O]=c[O];for(O=0;O<32;O++)s[32+O]=f[32+O];for(at(_,s.subarray(32),o+32),Br(_),cr(N,_),Ur(s,N),O=32;O<64;O++)s[O]=n[O];for(at(y,s,o+64),Br(y),O=0;O<64;O++)$[O]=0;for(O=0;O<32;O++)$[O]=_[O];for(O=0;O<32;O++)for(I=0;I<32;I++)$[O+I]+=y[O]*f[I];return Kr(s.subarray(32),$),ce}function Ys(s,c){var o=r(),n=r(),f=r(),y=r(),_=r(),O=r(),I=r();return Se(s[2],m),kr(s[1],c),Ke(f,s[1]),se(y,f,g),$e(f,f,s[2]),De(y,s[2],y),Ke(_,y),Ke(O,_),se(I,O,_),se(o,I,f),se(o,o,y),Zn(o,o),se(o,o,f),se(o,o,y),se(o,o,y),se(s[0],o,y),Ke(n,s[0]),se(n,n,y),Yn(n,f)&&se(s[0],s[0],x),Ke(n,s[0]),se(n,n,y),Yn(n,f)?-1:(Wn(s[0])===c[31]>>7&&$e(s[0],l,s[0]),se(s[3],s[0],s[1]),0)}function Dr(s,c,o,n){var f,y=new Uint8Array(32),_=new Uint8Array(64),O=[r(),r(),r(),r()],I=[r(),r(),r(),r()];if(o<64||Ys(I,n))return-1;for(f=0;f<o;f++)s[f]=c[f];for(f=0;f<32;f++)s[f+32]=n[f];if(at(_,s,o),Br(_),Lr(O,I,_),cr(I,c.subarray(32)),ar(O,I),Ur(y,O),o-=64,ie(c,0,y,0)){for(f=0;f<o;f++)s[f]=0;return-1}for(f=0;f<o;f++)s[f]=c[f+64];return o}var $r=32,ur=24,Kt=32,pt=16,Bt=32,hr=32,Dt=32,$t=32,qr=32,si=ur,Ws=Kt,Xs=pt,Ze=64,ct=32,Et=64,zr=32,Gr=64;e.lowlevel={crypto_core_hsalsa20:le,crypto_stream_xor:mt,crypto_stream:gt,crypto_stream_salsa20_xor:He,crypto_stream_salsa20:Lt,crypto_onetimeauth:xt,crypto_onetimeauth_verify:Ft,crypto_verify_16:U,crypto_verify_32:ie,crypto_secretbox:Pe,crypto_secretbox_open:Ve,crypto_scalarmult:ir,crypto_scalarmult_base:sr,crypto_box_beforenm:or,crypto_box_afternm:ei,crypto_box:Vs,crypto_box_open:Js,crypto_box_keypair:Qn,crypto_hash:at,crypto_sign:ii,crypto_sign_keypair:Fr,crypto_sign_open:Dr,crypto_secretbox_KEYBYTES:$r,crypto_secretbox_NONCEBYTES:ur,crypto_secretbox_ZEROBYTES:Kt,crypto_secretbox_BOXZEROBYTES:pt,crypto_scalarmult_BYTES:Bt,crypto_scalarmult_SCALARBYTES:hr,crypto_box_PUBLICKEYBYTES:Dt,crypto_box_SECRETKEYBYTES:$t,crypto_box_BEFORENMBYTES:qr,crypto_box_NONCEBYTES:si,crypto_box_ZEROBYTES:Ws,crypto_box_BOXZEROBYTES:Xs,crypto_sign_BYTES:Ze,crypto_sign_PUBLICKEYBYTES:ct,crypto_sign_SECRETKEYBYTES:Et,crypto_sign_SEEDBYTES:zr,crypto_hash_BYTES:Gr,gf:r,D:g,L:fr,pack25519:Ue,unpack25519:kr,M:se,A:De,S:Ke,Z:$e,pow2523:Zn,add:ar,set25519:Se,modL:Kr,scalarmult:Lr,scalarbase:cr};function oi(s,c){if(s.length!==$r)throw new Error("bad key size");if(c.length!==ur)throw new Error("bad nonce size")}function Zs(s,c){if(s.length!==Dt)throw new Error("bad public key size");if(c.length!==$t)throw new Error("bad secret key size")}function Le(){for(var s=0;s<arguments.length;s++)if(!(arguments[s]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function ai(s){for(var c=0;c<s.length;c++)s[c]=0}e.randomBytes=function(s){var c=new Uint8Array(s);return i(c,s),c},e.secretbox=function(s,c,o){Le(s,c,o),oi(o,c);for(var n=new Uint8Array(Kt+s.length),f=new Uint8Array(n.length),y=0;y<s.length;y++)n[y+Kt]=s[y];return Pe(f,n,n.length,c,o),f.subarray(pt)},e.secretbox.open=function(s,c,o){Le(s,c,o),oi(o,c);for(var n=new Uint8Array(pt+s.length),f=new Uint8Array(n.length),y=0;y<s.length;y++)n[y+pt]=s[y];return n.length<32||Ve(f,n,n.length,c,o)!==0?null:f.subarray(Kt)},e.secretbox.keyLength=$r,e.secretbox.nonceLength=ur,e.secretbox.overheadLength=pt,e.scalarMult=function(s,c){if(Le(s,c),s.length!==hr)throw new Error("bad n size");if(c.length!==Bt)throw new Error("bad p size");var o=new Uint8Array(Bt);return ir(o,s,c),o},e.scalarMult.base=function(s){if(Le(s),s.length!==hr)throw new Error("bad n size");var c=new Uint8Array(Bt);return sr(c,s),c},e.scalarMult.scalarLength=hr,e.scalarMult.groupElementLength=Bt,e.box=function(s,c,o,n){var f=e.box.before(o,n);return e.secretbox(s,c,f)},e.box.before=function(s,c){Le(s,c),Zs(s,c);var o=new Uint8Array(qr);return or(o,s,c),o},e.box.after=e.secretbox,e.box.open=function(s,c,o,n){var f=e.box.before(o,n);return e.secretbox.open(s,c,f)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var s=new Uint8Array(Dt),c=new Uint8Array($t);return Qn(s,c),{publicKey:s,secretKey:c}},e.box.keyPair.fromSecretKey=function(s){if(Le(s),s.length!==$t)throw new Error("bad secret key size");var c=new Uint8Array(Dt);return sr(c,s),{publicKey:c,secretKey:new Uint8Array(s)}},e.box.publicKeyLength=Dt,e.box.secretKeyLength=$t,e.box.sharedKeyLength=qr,e.box.nonceLength=si,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(s,c){if(Le(s,c),c.length!==Et)throw new Error("bad secret key size");var o=new Uint8Array(Ze+s.length);return ii(o,s,s.length,c),o},e.sign.open=function(s,c){if(Le(s,c),c.length!==ct)throw new Error("bad public key size");var o=new Uint8Array(s.length),n=Dr(o,s,s.length,c);if(n<0)return null;for(var f=new Uint8Array(n),y=0;y<f.length;y++)f[y]=o[y];return f},e.sign.detached=function(s,c){for(var o=e.sign(s,c),n=new Uint8Array(Ze),f=0;f<n.length;f++)n[f]=o[f];return n},e.sign.detached.verify=function(s,c,o){if(Le(s,c,o),c.length!==Ze)throw new Error("bad signature size");if(o.length!==ct)throw new Error("bad public key size");var n=new Uint8Array(Ze+s.length),f=new Uint8Array(Ze+s.length),y;for(y=0;y<Ze;y++)n[y]=c[y];for(y=0;y<s.length;y++)n[y+Ze]=s[y];return Dr(f,n,n.length,o)>=0},e.sign.keyPair=function(){var s=new Uint8Array(ct),c=new Uint8Array(Et);return Fr(s,c),{publicKey:s,secretKey:c}},e.sign.keyPair.fromSecretKey=function(s){if(Le(s),s.length!==Et)throw new Error("bad secret key size");for(var c=new Uint8Array(ct),o=0;o<c.length;o++)c[o]=s[32+o];return{publicKey:c,secretKey:new Uint8Array(s)}},e.sign.keyPair.fromSeed=function(s){if(Le(s),s.length!==zr)throw new Error("bad seed size");for(var c=new Uint8Array(ct),o=new Uint8Array(Et),n=0;n<32;n++)o[n]=s[n];return Fr(c,o,!0),{publicKey:c,secretKey:o}},e.sign.publicKeyLength=ct,e.sign.secretKeyLength=Et,e.sign.seedLength=zr,e.sign.signatureLength=Ze,e.hash=function(s){Le(s);var c=new Uint8Array(Gr);return at(c,s,s.length),c},e.hash.hashLength=Gr,e.verify=function(s,c){return Le(s,c),s.length===0||c.length===0||s.length!==c.length?!1:j(s,0,c,0,s.length)===0},e.setPRNG=function(s){i=s},function(){var s=typeof self<"u"?self.crypto||self.msCrypto:null;if(s&&s.getRandomValues){var c=65536;e.setPRNG(function(o,n){var f,y=new Uint8Array(n);for(f=0;f<n;f+=c)s.getRandomValues(y.subarray(f,f+Math.min(n-f,c)));for(f=0;f<n;f++)o[f]=y[f];ai(y)})}else typeof Yi<"u"&&(s=Wi,s&&s.randomBytes&&e.setPRNG(function(o,n){var f,y=s.randomBytes(n);for(f=0;f<n;f++)o[f]=y[f];ai(y)}))}()})(t.exports?t.exports:self.nacl=self.nacl||{})})(Sn);var Xi=Sn.exports,Zi=he&&he.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bt,"__esModule",{value:!0});const Qi=Zi(Xi);bt.default=Qi.default;var On;function es(){if(On)return jt;On=1;var t=he&&he.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(jt,"__esModule",{value:!0}),jt.KP=void 0;const e=Zt(),r=yt(),i=t(bt);class a{constructor(l){d(this,"seed");this.seed=l}getRawSeed(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return e.Codec.decodeSeed(this.seed).buf}getSeed(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return this.seed}getPublicKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const l=e.Codec.decodeSeed(this.seed),m=i.default.sign.keyPair.fromSeed(this.getRawSeed()),P=e.Codec.encode(l.prefix,m.publicKey);return new TextDecoder().decode(P)}getPrivateKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const l=i.default.sign.keyPair.fromSeed(this.getRawSeed());return e.Codec.encode(r.Prefix.Private,l.secretKey)}sign(l){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const m=i.default.sign.keyPair.fromSeed(this.getRawSeed());return i.default.sign.detached(l,m.secretKey)}verify(l,m){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const P=i.default.sign.keyPair.fromSeed(this.getRawSeed());return i.default.sign.detached.verify(l,m,P.publicKey)}clear(){this.seed&&(this.seed.fill(0),this.seed=void 0)}seal(l,m,P){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}open(l,m){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}}return jt.KP=a,jt}var kt={},An;function ts(){if(An)return kt;An=1;var t=he&&he.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(kt,"__esModule",{value:!0}),kt.PublicKey=void 0;const e=Zt(),r=yt(),i=t(bt);class a{constructor(l){d(this,"publicKey");this.publicKey=l}getPublicKey(){if(!this.publicKey)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return new TextDecoder().decode(this.publicKey)}getPrivateKey(){throw this.publicKey?new r.NKeysError(r.NKeysErrorCode.PublicKeyOnly):new r.NKeysError(r.NKeysErrorCode.ClearedPair)}getSeed(){throw this.publicKey?new r.NKeysError(r.NKeysErrorCode.PublicKeyOnly):new r.NKeysError(r.NKeysErrorCode.ClearedPair)}sign(l){throw this.publicKey?new r.NKeysError(r.NKeysErrorCode.CannotSign):new r.NKeysError(r.NKeysErrorCode.ClearedPair)}verify(l,m){if(!this.publicKey)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const P=e.Codec._decode(this.publicKey);return i.default.sign.detached.verify(l,m,P.slice(1))}clear(){this.publicKey&&(this.publicKey.fill(0),this.publicKey=void 0)}seal(l,m,P){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}open(l,m){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}}return kt.PublicKey=a,kt}var Ar={},Cn;function rs(){return Cn||(Cn=1,function(t){var e=he&&he.__importDefault||function(w){return w&&w.__esModule?w:{default:w}};Object.defineProperty(t,"__esModule",{value:!0}),t.CurveKP=t.curveNonceLen=t.curveKeyLen=void 0;const r=yt(),i=e(bt),a=Zt(),u=yt(),l=Rt,m=Nt;t.curveKeyLen=32;const P=35;t.curveNonceLen=24;const g=[120,107,118,49];class E{constructor(b){d(this,"seed");this.seed=b}clear(){this.seed&&(this.seed.fill(0),this.seed=void 0)}getPrivateKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return a.Codec.encode(u.Prefix.Private,this.seed)}getPublicKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const b=i.default.scalarMult.base(this.seed),x=a.Codec.encode(u.Prefix.Curve,b);return new TextDecoder().decode(x)}getSeed(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return a.Codec.encodeSeed(u.Prefix.Curve,this.seed)}sign(){throw new r.NKeysError(r.NKeysErrorCode.InvalidCurveOperation)}verify(){throw new r.NKeysError(r.NKeysErrorCode.InvalidCurveOperation)}decodePubCurveKey(b){try{const x=l.base32.decode(new TextEncoder().encode(b));if(x.byteLength!==P)throw new r.NKeysError(r.NKeysErrorCode.InvalidCurveKey);if(x[0]!==u.Prefix.Curve)throw new r.NKeysError(r.NKeysErrorCode.InvalidPublicKey);const R=x.byteLength-2,U=new DataView(x.buffer).getUint16(R,!0),ie=x.slice(0,R);if(!m.crc16.validate(ie,U))throw new r.NKeysError(r.NKeysErrorCode.InvalidChecksum);return ie.slice(1)}catch(x){throw new r.NKeysError(r.NKeysErrorCode.InvalidRecipient,{cause:x})}}seal(b,x,R){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);R||(R=i.default.randomBytes(t.curveNonceLen));const j=this.decodePubCurveKey(x),U=new Uint8Array(g.length+t.curveNonceLen);U.set(g,0),U.set(R,g.length);const ie=i.default.box(b,R,j,this.seed),_e=new Uint8Array(U.length+ie.length);return _e.set(U),_e.set(ie,U.length),_e}open(b,x){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);if(b.length<=t.curveNonceLen+g.length)throw new r.NKeysError(r.NKeysErrorCode.InvalidEncrypted);for(let U=0;U<g.length;U++)if(b[U]!==g[U])throw new r.NKeysError(r.NKeysErrorCode.InvalidEncrypted);const R=this.decodePubCurveKey(x);b=b.slice(g.length);const j=b.slice(0,t.curveNonceLen);return b=b.slice(t.curveNonceLen),i.default.box.open(b,j,R,this.seed)}}t.CurveKP=E}(Ar)),Ar}var Mn;function yt(){if(Mn)return xe;Mn=1;var t=he&&he.__importDefault||function(L){return L&&L.__esModule?L:{default:L}};Object.defineProperty(xe,"__esModule",{value:!0}),xe.NKeysError=xe.NKeysErrorCode=xe.Prefixes=xe.Prefix=void 0,xe.createPair=l,xe.createOperator=m,xe.createAccount=P,xe.createUser=g,xe.createCluster=E,xe.createServer=w,xe.createCurve=b,xe.fromPublic=x,xe.fromCurveSeed=R,xe.fromSeed=j;const e=es(),r=ts(),i=Zt(),a=rs(),u=t(bt);function l(L){const le=L===U.Curve?a.curveKeyLen:32,de=u.default.randomBytes(le),He=i.Codec.encodeSeed(L,new Uint8Array(de));return L===U.Curve?new a.CurveKP(new Uint8Array(de)):new e.KP(He)}function m(){return l(U.Operator)}function P(){return l(U.Account)}function g(){return l(U.User)}function E(){return l(U.Cluster)}function w(){return l(U.Server)}function b(){return l(U.Curve)}function x(L){const le=new TextEncoder().encode(L),de=i.Codec._decode(le),He=ie.parsePrefix(de[0]);if(ie.isValidPublicPrefix(He))return new r.PublicKey(le);throw new Fe(_e.InvalidPublicKey)}function R(L){const le=i.Codec.decodeSeed(L);if(le.prefix!==U.Curve)throw new Fe(_e.InvalidCurveSeed);if(le.buf.byteLength!==a.curveKeyLen)throw new Fe(_e.InvalidSeedLen);return new a.CurveKP(le.buf)}function j(L){return i.Codec.decodeSeed(L).prefix===U.Curve?R(L):new e.KP(L)}var U;(function(L){L[L.Unknown=-1]="Unknown",L[L.Seed=144]="Seed",L[L.Private=120]="Private",L[L.Operator=112]="Operator",L[L.Server=104]="Server",L[L.Cluster=16]="Cluster",L[L.Account=0]="Account",L[L.User=160]="User",L[L.Curve=184]="Curve"})(U||(xe.Prefix=U={}));class ie{static isValidPublicPrefix(le){return le==U.Server||le==U.Operator||le==U.Cluster||le==U.Account||le==U.User||le==U.Curve}static startsWithValidPrefix(le){const de=le[0];return de=="S"||de=="P"||de=="O"||de=="N"||de=="C"||de=="A"||de=="U"||de=="X"}static isValidPrefix(le){return this.parsePrefix(le)!==U.Unknown}static parsePrefix(le){switch(le){case U.Seed:return U.Seed;case U.Private:return U.Private;case U.Operator:return U.Operator;case U.Server:return U.Server;case U.Cluster:return U.Cluster;case U.Account:return U.Account;case U.User:return U.User;case U.Curve:return U.Curve;default:return U.Unknown}}}xe.Prefixes=ie;var _e;(function(L){L.InvalidPrefixByte="nkeys: invalid prefix byte",L.InvalidKey="nkeys: invalid key",L.InvalidPublicKey="nkeys: invalid public key",L.InvalidSeedLen="nkeys: invalid seed length",L.InvalidSeed="nkeys: invalid seed",L.InvalidCurveSeed="nkeys: invalid curve seed",L.InvalidCurveKey="nkeys: not a valid curve key",L.InvalidCurveOperation="nkeys: curve key is not valid for sign/verify",L.InvalidNKeyOperation="keys: only curve key can seal/open",L.InvalidEncoding="nkeys: invalid encoded key",L.InvalidRecipient="nkeys: not a valid recipient public curve key",L.InvalidEncrypted="nkeys: encrypted input is not valid",L.CannotSign="nkeys: cannot sign, no private key available",L.PublicKeyOnly="nkeys: no seed or private key available",L.InvalidChecksum="nkeys: invalid checksum",L.SerializationError="nkeys: serialization error",L.ApiError="nkeys: api error",L.ClearedPair="nkeys: pair is cleared"})(_e||(xe.NKeysErrorCode=_e={}));class Fe extends Error{constructor(de,He){super(de,He);d(this,"code");this.code=de}}return xe.NKeysError=Fe,xe}var Ut={};Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.encode=ns,Ut.decode=is,Ut.dump=ss;function ns(t){return btoa(String.fromCharCode(...t))}function is(t){const e=atob(t),r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i);return r}function ss(t,e){e&&console.log(e);const r=[];for(let i=0;i<t.byteLength;i++){i%8===0&&r.push(`
|
|
7
|
+
`);let a=t[i].toString(16);a.length===1&&(a="0"+a),r.push(a)}console.log(r.join(" "))}var Qt={};Object.defineProperty(Qt,"__esModule",{value:!0}),Qt.version=void 0,Qt.version="2.0.3",function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.version=t.encode=t.decode=t.Prefixes=t.Prefix=t.NKeysErrorCode=t.NKeysError=t.fromSeed=t.fromPublic=t.fromCurveSeed=t.createUser=t.createServer=t.createPair=t.createOperator=t.createCurve=t.createCluster=t.createAccount=void 0;var e=yt();Object.defineProperty(t,"createAccount",{enumerable:!0,get:function(){return e.createAccount}}),Object.defineProperty(t,"createCluster",{enumerable:!0,get:function(){return e.createCluster}}),Object.defineProperty(t,"createCurve",{enumerable:!0,get:function(){return e.createCurve}}),Object.defineProperty(t,"createOperator",{enumerable:!0,get:function(){return e.createOperator}}),Object.defineProperty(t,"createPair",{enumerable:!0,get:function(){return e.createPair}}),Object.defineProperty(t,"createServer",{enumerable:!0,get:function(){return e.createServer}}),Object.defineProperty(t,"createUser",{enumerable:!0,get:function(){return e.createUser}}),Object.defineProperty(t,"fromCurveSeed",{enumerable:!0,get:function(){return e.fromCurveSeed}}),Object.defineProperty(t,"fromPublic",{enumerable:!0,get:function(){return e.fromPublic}}),Object.defineProperty(t,"fromSeed",{enumerable:!0,get:function(){return e.fromSeed}}),Object.defineProperty(t,"NKeysError",{enumerable:!0,get:function(){return e.NKeysError}}),Object.defineProperty(t,"NKeysErrorCode",{enumerable:!0,get:function(){return e.NKeysErrorCode}}),Object.defineProperty(t,"Prefix",{enumerable:!0,get:function(){return e.Prefix}}),Object.defineProperty(t,"Prefixes",{enumerable:!0,get:function(){return e.Prefixes}});var r=Ut;Object.defineProperty(t,"decode",{enumerable:!0,get:function(){return r.decode}}),Object.defineProperty(t,"encode",{enumerable:!0,get:function(){return r.encode}});var i=Qt;Object.defineProperty(t,"version",{enumerable:!0,get:function(){return i.version}})}(wn);var os=he&&he.__createBinding||(Object.create?function(t,e,r,i){i===void 0&&(i=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,i,a)}:function(t,e,r,i){i===void 0&&(i=r),t[i]=e[r]}),as=he&&he.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),cs=he&&he.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var i=[];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(i[i.length]=a);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i=t(e),a=0;a<i.length;a++)i[a]!=="default"&&os(r,e,i[a]);return as(r,e),r}}();Object.defineProperty(It,"__esModule",{value:!0}),It.nkeys=void 0,It.nkeys=cs(wn),Object.defineProperty(qe,"__esModule",{value:!0}),qe.multiAuthenticator=fs,qe.noAuthFn=us,qe.usernamePasswordAuthenticator=hs,qe.tokenAuthenticator=ls,qe.nkeyAuthenticator=jn,qe.jwtAuthenticator=Tn,qe.credsAuthenticator=ds;const In=It,Cr=ke;function fs(t){return e=>{let r={};return t.forEach(i=>{const a=i(e)||{};r=Object.assign(r,a)}),r}}function us(){return()=>{}}function hs(t,e){return()=>{const r=typeof t=="function"?t():t,i=typeof e=="function"?e():e;return{user:r,pass:i}}}function ls(t){return()=>({auth_token:typeof t=="function"?t():t})}function jn(t){return e=>{const r=typeof t=="function"?t():t,i=r?In.nkeys.fromSeed(r):void 0,a=i?i.getPublicKey():"",u=Cr.TE.encode(e||""),l=i!==void 0&&e?i.sign(u):void 0,m=l?In.nkeys.encode(l):"";return{nkey:a,sig:m}}}function Tn(t,e){return r=>{const i=typeof t=="function"?t():t,a=jn(e),{nkey:u,sig:l}=a(r);return{jwt:i,nkey:u,sig:l}}}function ds(t){const e=typeof t!="function"?()=>t:t,r=()=>{const u=/\s*(?:(?:[-]{3,}[^\n]*[-]{3,}\n)(.+)(?:\n\s*[-]{3,}[^\n]*[-]{3,}\n))/ig,l=Cr.TD.decode(e());let m=u.exec(l);if(!m)throw new Error("unable to parse credentials");const P=m[1].trim();if(m=u.exec(l),!m)throw new Error("unable to parse credentials");const g=Cr.TE.encode(m[1].trim());return{jwt:P,seed:g}};return Tn(()=>{const{jwt:u}=r();return u},()=>{const{seed:u}=r();return u})}(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_RECONNECT_TIME_WAIT=t.DEFAULT_MAX_PING_OUT=t.DEFAULT_PING_INTERVAL=t.DEFAULT_JITTER_TLS=t.DEFAULT_JITTER=t.DEFAULT_MAX_RECONNECT_ATTEMPTS=void 0,t.defaultOptions=l,t.hasWsProtocol=m,t.buildAuthenticator=P,t.parseOptions=g,t.checkOptions=E,t.checkUnsupportedOption=w;const e=ye,r=rt,i=Ae,a=qe,u=te;t.DEFAULT_MAX_RECONNECT_ATTEMPTS=10,t.DEFAULT_JITTER=100,t.DEFAULT_JITTER_TLS=1e3,t.DEFAULT_PING_INTERVAL=2*60*1e3,t.DEFAULT_MAX_PING_OUT=2,t.DEFAULT_RECONNECT_TIME_WAIT=2*1e3;function l(){return{maxPingOut:t.DEFAULT_MAX_PING_OUT,maxReconnectAttempts:t.DEFAULT_MAX_RECONNECT_ATTEMPTS,noRandomize:!1,pedantic:!1,pingInterval:t.DEFAULT_PING_INTERVAL,reconnect:!0,reconnectJitter:t.DEFAULT_JITTER,reconnectJitterTLS:t.DEFAULT_JITTER_TLS,reconnectTimeWait:t.DEFAULT_RECONNECT_TIME_WAIT,tls:void 0,verbose:!1,waitOnFirstConnect:!1,ignoreAuthErrorAbort:!1}}function m(b){if(b){let{servers:x}=b;if(typeof x=="string"&&(x=[x]),x)for(let R=0;R<x.length;R++){const j=x[R].toLowerCase();if(j.startsWith("ws://")||j.startsWith("wss://"))return!0}}return!1}function P(b){const x=[];return typeof b.authenticator=="function"&&x.push(b.authenticator),Array.isArray(b.authenticator)&&x.push(...b.authenticator),b.token&&x.push((0,a.tokenAuthenticator)(b.token)),b.user&&x.push((0,a.usernamePasswordAuthenticator)(b.user,b.pass)),x.length===0?(0,a.noAuthFn)():(0,a.multiAuthenticator)(x)}function g(b){const x=`${i.DEFAULT_HOST}:${(0,r.defaultPort)()}`;if(b=b||{servers:[x]},b.servers=b.servers||[],typeof b.servers=="string"&&(b.servers=[b.servers]),b.servers.length>0&&b.port)throw u.InvalidArgumentError.format(["servers","port"],"are mutually exclusive");b.servers.length===0&&b.port&&(b.servers=[`${i.DEFAULT_HOST}:${b.port}`]),b.servers&&b.servers.length===0&&(b.servers=[x]);const R=(0,e.extend)(l(),b);if(R.authenticator=P(R),["reconnectDelayHandler","authenticator"].forEach(j=>{if(R[j]&&typeof R[j]!="function")throw TypeError(`'${j}' must be a function`)}),R.reconnectDelayHandler||(R.reconnectDelayHandler=()=>{let j=R.tls?R.reconnectJitterTLS:R.reconnectJitter;return j&&(j++,j=Math.floor(Math.random()*j)),R.reconnectTimeWait+j}),R.inboxPrefix&&(0,i.createInbox)(R.inboxPrefix),R.resolve===void 0&&(R.resolve=typeof(0,r.getResolveFn)()=="function"),R.resolve&&typeof(0,r.getResolveFn)()!="function")throw u.InvalidArgumentError.format("resolve","is not supported in the current runtime");return R}function E(b,x){const{proto:R,tls_required:j,tls_available:U}=b;if((R===void 0||R<1)&&x.noEcho)throw new u.errors.ConnectionError("server does not support 'noEcho'");const ie=j||U||!1;if(x.tls&&!ie)throw new u.errors.ConnectionError("server does not support 'tls'")}function w(b,x){if(x)throw u.InvalidArgumentError.format(b,"is not supported")}})(Mt),Object.defineProperty(je,"__esModule",{value:!0}),je.ProtocolHandler=je.Subscriptions=je.SubscriptionImpl=je.Connect=je.INFO=void 0;const ze=ke,st=rt,Ge=ye,bs=nt,ys=Je,_s=lt,gs=Ot,ms=At,et=xr,vs=Ct,Nn=Xt,Mr=Mt,Oe=te,xs=1024*32;je.INFO=/^INFO\s+([^\r\n]+)\r\n/i;const ps=(0,ze.encode)(`PONG\r
|
|
8
|
+
`),Rn=(0,ze.encode)(`PING\r
|
|
9
|
+
`);class kn{constructor(e,r,i){d(this,"echo");d(this,"no_responders");d(this,"protocol");d(this,"verbose");d(this,"pedantic");d(this,"jwt");d(this,"nkey");d(this,"sig");d(this,"user");d(this,"pass");d(this,"auth_token");d(this,"tls_required");d(this,"name");d(this,"lang");d(this,"version");d(this,"headers");this.protocol=1,this.version=e.version,this.lang=e.lang,this.echo=r.noEcho?!1:void 0,this.verbose=r.verbose,this.pedantic=r.pedantic,this.tls_required=r.tls?!0:void 0,this.name=r.name;const a=(r&&typeof r.authenticator=="function"?r.authenticator(i):{})||{};(0,Ge.extend)(this,a)}}je.Connect=kn;class Es{constructor(e,r){d(this,"slow");d(this,"cb");d(this,"notified");this.slow=e,this.cb=r,this.notified=!1}maybeNotify(e){e<=this.slow?this.notified=!1:this.notified||(this.cb(e),this.notified=!0)}}class Un extends _s.QueuedIteratorImpl{constructor(r,i,a={}){var l;super();d(this,"sid");d(this,"queue");d(this,"draining");d(this,"max");d(this,"subject");d(this,"drained");d(this,"protocol");d(this,"timer");d(this,"info");d(this,"cleanupFn");d(this,"closed");d(this,"requestSubject");d(this,"slow");(0,Ge.extend)(this,a),this.protocol=r,this.subject=i,this.draining=!1,this.noIterator=typeof a.callback=="function",this.closed=(0,Ge.deferred)();const u=!((l=r.options)!=null&&l.noAsyncTraces);a.timeout&&(this.timer=(0,Ge.timeout)(a.timeout,u),this.timer.then(()=>{this.timer=void 0}).catch(m=>{this.stop(m),this.noIterator&&this.callback(m,{})})),this.noIterator||this.iterClosed.then(m=>{this.closed.resolve(m),this.unsubscribe()})}setSlowNotificationFn(r,i){if(this.slow=void 0,i){if(this.noIterator)throw new Error("callbacks don't support slow notifications");this.slow=new Es(r,i)}}callback(r,i){this.cancelTimeout(),r?this.stop(r):this.push(i),!r&&this.slow&&this.slow.maybeNotify(this.getPending())}close(r){if(!this.isClosed()){this.cancelTimeout();const i=()=>{if(this.stop(),this.cleanupFn)try{this.cleanupFn(this,this.info)}catch{}this.closed.resolve(r)};this.noIterator?i():this.push(i)}}unsubscribe(r){this.protocol.unsubscribe(this,r)}cancelTimeout(){this.timer&&(this.timer.cancel(),this.timer=void 0)}drain(){return this.protocol.isClosed()?Promise.reject(new Oe.errors.ClosedConnectionError):this.isClosed()?Promise.reject(new Oe.errors.InvalidOperationError("subscription is already closed")):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush((0,Ge.deferred)()).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}}je.SubscriptionImpl=Un;class Ln{constructor(){d(this,"mux");d(this,"subs");d(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){const r=this.all();let i;return e.operation==="subscription"?i=r.find(a=>a.subject===e.subject&&a.queue===e.queue):e.operation==="publish"&&(i=r.find(a=>a.requestSubject===e.subject)),i?(i.callback(e,{}),i.close(e),this.subs.delete(i.sid),i!==this.mux):!1}close(){this.subs.forEach(e=>{e.close()})}}je.Subscriptions=Ln;class er{constructor(e,r){d(this,"connected");d(this,"connectedOnce");d(this,"infoReceived");d(this,"info");d(this,"muxSubscriptions");d(this,"options");d(this,"outbound");d(this,"pongs");d(this,"subscriptions");d(this,"transport");d(this,"noMorePublishing");d(this,"connectError");d(this,"publisher");d(this,"_closed");d(this,"closed");d(this,"listeners");d(this,"heartbeats");d(this,"parser");d(this,"outMsgs");d(this,"inMsgs");d(this,"outBytes");d(this,"inBytes");d(this,"pendingLimit");d(this,"lastError");d(this,"abortReconnect");d(this,"whyClosed");d(this,"servers");d(this,"server");d(this,"features");d(this,"connectPromise");d(this,"dialDelay");d(this,"raceTimer");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=xs,this.outMsgs=0,this.inMsgs=0,this.outBytes=0,this.inBytes=0,this.options=e,this.publisher=r,this.subscriptions=new Ln,this.muxSubscriptions=new gs.MuxSubscription,this.outbound=new bs.DataBuffer,this.pongs=[],this.whyClosed="",this.pendingLimit=e.pendingLimit||this.pendingLimit,this.features=new Nn.Features({major:0,minor:0,micro:0}),this.connectPromise=null,this.dialDelay=null;const i=typeof e.servers=="string"?[e.servers]:e.servers;this.servers=new ys.Servers(i,{randomize:!e.noRandomize}),this.closed=(0,Ge.deferred)(),this.parser=new et.Parser(this),this.heartbeats=new ms.Heartbeat(this,this.options.pingInterval||Mr.DEFAULT_PING_INTERVAL,this.options.maxPingOut||Mr.DEFAULT_MAX_PING_OUT)}resetOutbound(){this.outbound.reset();const e=this.pongs;this.pongs=[];const r=new Oe.errors.RequestError("connection disconnected");r.stack="",e.forEach(i=>{i.reject(r)}),this.parser=new et.Parser(this),this.infoReceived=!1}dispatchStatus(e){this.listeners.forEach(r=>{r.push(e)})}prepare(){this.transport&&this.transport.discard(),this.info=void 0,this.resetOutbound();const e=(0,Ge.deferred)();return e.catch(()=>{}),this.pongs.unshift(e),this.connectError=r=>{e.reject(r)},this.transport=(0,st.newTransport)(),this.transport.closed().then(async r=>{if(this.connected=!1,!this.isClosed()){await this.disconnected(this.transport.closeError||this.lastError);return}}),e}disconnect(){this.dispatchStatus({type:"staleConnection"}),this.transport.disconnect()}reconnect(){return this.connected&&(this.dispatchStatus({type:"forceReconnect"}),this.transport.disconnect()),Promise.resolve()}async disconnected(e){this.dispatchStatus({type:"disconnect",server:this.servers.getCurrentServer().toString()}),this.options.reconnect?await this.dialLoop().then(()=>{this.dispatchStatus({type:"reconnect",server:this.servers.getCurrentServer().toString()}),this.lastError instanceof Oe.errors.UserAuthenticationExpiredError&&(this.lastError=void 0)}).catch(r=>{this.close(r).catch()}):await this.close(e).catch()}async dial(e){var i,a;const r=this.prepare();try{this.raceTimer=(0,Ge.timeout)(this.options.timeout||2e4);const u=this.transport.connect(e,this.options);await Promise.race([u,this.raceTimer]),(async()=>{try{for await(const l of this.transport)this.parser.parse(l)}catch(l){console.log("reader closed",l)}})().then()}catch(u){r.reject(u)}try{await Promise.race([this.raceTimer,r]),(i=this.raceTimer)==null||i.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(u){throw(a=this.raceTimer)==null||a.cancel(),await this.transport.close(u),u}}async _doDial(e){const{resolve:r}=this.options,i=await e.resolve({fn:(0,st.getResolveFn)(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:r});let a=null;for(const u of i)try{a=null,this.dispatchStatus({type:"reconnecting"}),await this.dial(u);return}catch(l){a=l}throw a}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 r=this.options.reconnectDelayHandler?this.options.reconnectDelayHandler():Mr.DEFAULT_RECONNECT_TIME_WAIT;let i=r;const a=this.selectServer();if(!a||this.abortReconnect)throw e||(this.lastError?this.lastError:new Oe.errors.ConnectionError("connection refused"));const u=Date.now();if(a.lastConnect===0||a.lastConnect+r<=u){a.lastConnect=Date.now();try{await this._doDial(a);break}catch(l){if(e=l,!this.connectedOnce){if(this.options.waitOnFirstConnect)continue;this.servers.removeCurrentServer()}a.reconnects++;const m=this.options.maxReconnectAttempts||0;m!==-1&&a.reconnects>=m&&this.servers.removeCurrentServer()}}else i=Math.min(i,a.lastConnect+r-u),this.dialDelay=(0,Ge.delay)(i),await this.dialDelay}}static async connect(e,r){const i=new er(e,r);return await i.dialLoop(),i}static toError(e){let r=Oe.errors.PermissionViolationError.parse(e);return r||(r=Oe.errors.UserAuthenticationExpiredError.parse(e),r)||(r=Oe.errors.AuthorizationError.parse(e),r)?r:new Oe.errors.ProtocolError(e)}processMsg(e,r){if(this.inMsgs++,this.inBytes+=r.length,!this.subscriptions.sidCounter)return;const i=this.subscriptions.get(e.sid);i&&(i.received+=1,i.callback&&i.callback(null,new vs.MsgImpl(e,r,this)),i.max!==void 0&&i.received>=i.max&&i.unsubscribe())}processError(e){let r=(0,ze.decode)(e);r.startsWith("'")&&r.endsWith("'")&&(r=r.slice(1,r.length-1));const i=er.toError(r);switch(i.constructor){case Oe.errors.PermissionViolationError:{const a=i,u=this.subscriptions.getMux(),l=u?a.subject===u.subject:!1;this.subscriptions.handleError(a),this.muxSubscriptions.handleError(l,a),l&&this.subscriptions.setMux(null)}}this.dispatchStatus({type:"error",error:i}),this.handleError(i)}handleError(e){(e instanceof Oe.errors.UserAuthenticationExpiredError||e instanceof Oe.errors.AuthorizationError)&&this.handleAuthError(e),e instanceof Oe.errors.PermissionViolationError||(this.lastError=e)}handleAuthError(e){(this.lastError instanceof Oe.errors.UserAuthenticationExpiredError||this.lastError instanceof Oe.errors.AuthorizationError)&&this.options.ignoreAuthErrorAbort===!1&&(this.abortReconnect=!0),this.connectError?this.connectError(e):this.disconnect()}processPing(){this.transport.send(ps)}processPong(){const e=this.pongs.shift();e&&e.resolve()}processInfo(e){const r=JSON.parse((0,ze.decode)(e));this.info=r;const i=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(r,this.transport.isEncrypted());if(!this.infoReceived){this.features.update((0,Nn.parseSemVer)(r.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:u,lang:l}=this.transport;try{const m=new kn({version:u,lang:l},this.options,r.nonce);r.headers&&(m.headers=!0,m.no_responders=!0);const P=JSON.stringify(m);this.transport.send((0,ze.encode)(`CONNECT ${P}${st.CR_LF}`)),this.transport.send(Rn)}catch(m){this.close(m).catch()}}if(i){const{added:u,deleted:l}=i;this.dispatchStatus({type:"update",added:u,deleted:l})}(r.ldm!==void 0?r.ldm:!1)&&this.dispatchStatus({type:"ldm",server:this.servers.getCurrentServer().toString()})}push(e){switch(e.kind){case et.Kind.MSG:{const{msg:r,data:i}=e;this.processMsg(r,i);break}case et.Kind.OK:break;case et.Kind.ERR:this.processError(e.data);break;case et.Kind.PING:this.processPing();break;case et.Kind.PONG:this.processPong();break;case et.Kind.INFO:this.processInfo(e.data);break}}sendCommand(e,...r){const i=this.outbound.length();let a;typeof e=="string"?a=(0,ze.encode)(e):a=e,this.outbound.fill(a,...r),i===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(e,r=ze.Empty,i){let a;if(r instanceof Uint8Array)a=r;else if(typeof r=="string")a=ze.TE.encode(r);else throw new TypeError("payload types can be strings or Uint8Array");let u=a.length;i=i||{},i.reply=i.reply||"";let l=ze.Empty,m=0;if(i.headers&&(this.info&&!this.info.headers&&Oe.InvalidArgumentError.format("headers","are not available on this server"),l=i.headers.encode(),m=l.length,u=a.length+m),this.info&&u>this.info.max_payload)throw Oe.InvalidArgumentError.format("payload","max_payload size exceeded");this.outBytes+=u,this.outMsgs++;let P;i.headers?(i.reply?P=`HPUB ${e} ${i.reply} ${m} ${u}\r
|
|
10
|
+
`:P=`HPUB ${e} ${m} ${u}\r
|
|
11
|
+
`,this.sendCommand(P,l,a,st.CRLF)):(i.reply?P=`PUB ${e} ${i.reply} ${u}\r
|
|
12
|
+
`:P=`PUB ${e} ${u}\r
|
|
13
|
+
`,this.sendCommand(P,a,st.CRLF))}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
|
|
14
|
+
`):this.sendCommand(`SUB ${e.subject} ${e.sid}\r
|
|
15
|
+
`)}_subunsub(e){return this._sub(e),e.max&&this.unsubscribe(e,e.max),e}unsubscribe(e,r){this.unsub(e,r),(e.max===void 0||e.received>=e.max)&&this.subscriptions.cancel(e)}unsub(e,r){!e||this.isClosed()||(r?this.sendCommand(`UNSUB ${e.sid} ${r}\r
|
|
16
|
+
`):this.sendCommand(`UNSUB ${e.sid}\r
|
|
17
|
+
`),e.max=r)}resub(e,r){!e||this.isClosed()||(this.unsub(e),e.subject=r,this.subscriptions.resub(e),this._sub(e))}flush(e){return e||(e=(0,Ge.deferred)()),this.pongs.push(e),this.outbound.fill(Rn),this.flushPending(),e}sendSubscriptions(){const e=[];this.subscriptions.all().forEach(r=>{const i=r;i.queue?e.push(`SUB ${i.subject} ${i.queue} ${i.sid}${st.CR_LF}`):e.push(`SUB ${i.subject} ${i.sid}${st.CR_LF}`)}),e.length&&this.transport.send((0,ze.encode)(e.join("")))}async close(e){var i,a;if(this._closed)return;this.whyClosed=new Error("close trace").stack||"",this.heartbeats.cancel(),this.connectError&&(this.connectError(e),this.connectError=void 0),this.muxSubscriptions.close(),this.subscriptions.close();const r=[];for(let u=0;u<this.listeners.length;u++){const l=this.listeners[u];l&&(l.push({type:"close"}),l.stop(),r.push(l.iterClosed))}r.length&&await Promise.all(r),this._closed=!0,await this.transport.close(e),(i=this.raceTimer)==null||i.cancel(),(a=this.dialDelay)==null||a.cancel(),this.closed.resolve(e)}isClosed(){return this._closed}async drain(){const e=this.subscriptions.all(),r=[];e.forEach(i=>{r.push(i.drain())});try{await Promise.allSettled(r)}catch{}finally{this.noMorePublishing=!0,await this.flush()}return this.close()}flushPending(){if(!(!this.infoReceived||!this.connected)&&this.outbound.size()){const e=this.outbound.drain();this.transport.send(e)}}initMux(){if(!this.subscriptions.getMux()){const r=this.muxSubscriptions.init(this.options.inboxPrefix),i=new Un(this,`${r}*`);i.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(i),this.subscribe(i)}}selectServer(){const e=this.servers.selectServer();if(e!==void 0)return this.server=e,this.server}getServer(){return this.server}}je.ProtocolHandler=er;var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.RequestOne=Ye.RequestMany=Ye.BaseRequest=void 0;const Ir=ye,ws=Pt,tr=te;class jr{constructor(e,r,i=!0){d(this,"token");d(this,"received");d(this,"ctx");d(this,"requestSubject");d(this,"mux");this.mux=e,this.requestSubject=r,this.received=0,this.token=ws.nuid.next(),i&&(this.ctx=new tr.RequestError)}}Ye.BaseRequest=jr;class Ps extends jr{constructor(r,i,a={maxWait:1e3}){super(r,i);d(this,"callback");d(this,"done");d(this,"timer");d(this,"max");d(this,"opts");if(this.opts=a,typeof this.opts.callback!="function")throw new TypeError("callback must be a function");this.callback=this.opts.callback,this.max=typeof a.maxMessages=="number"&&a.maxMessages>0?a.maxMessages:-1,this.done=(0,Ir.deferred)(),this.done.then(()=>{this.callback(null,null)}),this.timer=setTimeout(()=>{this.cancel()},a.maxWait)}cancel(r){r&&this.callback(r,null),clearTimeout(this.timer),this.mux.cancel(this),this.done.resolve()}resolver(r,i){r?(this.ctx&&(r.stack+=`
|
|
18
|
+
|
|
19
|
+
${this.ctx.stack}`),this.cancel(r)):(this.callback(null,i),this.opts.strategy==="count"&&(this.max--,this.max===0&&this.cancel()),this.opts.strategy==="stall"&&(clearTimeout(this.timer),this.timer=setTimeout(()=>{this.cancel()},this.opts.stall||300)),this.opts.strategy==="sentinel"&&i&&i.data.length===0&&this.cancel())}}Ye.RequestMany=Ps;class Ss extends jr{constructor(r,i,a={timeout:1e3},u=!0){super(r,i,u);d(this,"deferred");d(this,"timer");this.deferred=(0,Ir.deferred)(),this.timer=(0,Ir.timeout)(a.timeout,u)}resolver(r,i){this.timer&&this.timer.cancel(),r?(r instanceof tr.TimeoutError||(this.ctx?(this.ctx.message=r.message,this.ctx.cause=r,r=this.ctx):r=new tr.errors.RequestError(r.message,{cause:r})),this.deferred.reject(r)):this.deferred.resolve(i),this.cancel()}cancel(r){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(r||new tr.RequestError("cancelled"))}}Ye.RequestOne=Ss,Object.defineProperty(wt,"__esModule",{value:!0}),wt.NatsConnectionImpl=void 0;const Os=ye,Fn=je,As=ke,Kn=Qe,Cs=Xt,Ms=Mt,Bn=lt,Dn=Ye,$n=Ae,Ee=te;class Tr{constructor(e){d(this,"options");d(this,"protocol");d(this,"draining");d(this,"closeListeners");this.draining=!1,this.options=(0,Ms.parseOptions)(e)}static connect(e={}){return new Promise((r,i)=>{const a=new Tr(e);Fn.ProtocolHandler.connect(a.options,a).then(u=>{a.protocol=u,r(a)}).catch(u=>{i(u)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}_check(e,r,i){if(this.isClosed())throw new Ee.errors.ClosedConnectionError;if(r&&this.isDraining())throw new Ee.errors.DrainingConnectionError;if(i&&this.protocol.noMorePublishing)throw new Ee.errors.DrainingConnectionError;if(e=e||"",e.length===0)throw new Ee.errors.InvalidSubjectError(e)}publish(e,r,i){if(this._check(e,!1,!0),i!=null&&i.reply&&this._check(i.reply,!1,!0),typeof(i==null?void 0:i.traceOnly)=="boolean"){const a=i.headers||(0,Kn.headers)();a.set("Nats-Trace-Only","true"),i.headers=a}if(typeof(i==null?void 0:i.traceDestination)=="string"){const a=i.headers||(0,Kn.headers)();a.set("Nats-Trace-Dest",i.traceDestination),i.headers=a}this.protocol.publish(e,r,i)}publishMessage(e){return this.publish(e.subject,e.data,{reply:e.reply,headers:e.headers})}respondMessage(e){return e.reply?(this.publish(e.reply,e.data,{reply:e.reply,headers:e.headers}),!0):!1}subscribe(e,r={}){this._check(e,!0,!1);const i=new Fn.SubscriptionImpl(this.protocol,e,r);return typeof r.callback!="function"&&typeof r.slow=="number"&&i.setSlowNotificationFn(r.slow,a=>{this.protocol.dispatchStatus({type:"slowConsumer",sub:i,pending:a})}),this.protocol.subscribe(i),i}_resub(e,r,i){this._check(r,!0,!1);const a=e;a.max=i,i&&(a.max=i+a.received),this.protocol.resub(a,r)}requestMany(e,r=As.Empty,i={maxWait:1e3,maxMessages:-1}){const a=!this.protocol.options.noAsyncTraces;try{this._check(e,!0,!0)}catch(P){return Promise.reject(P)}if(i.strategy=i.strategy||"timer",i.maxWait=i.maxWait||1e3,i.maxWait<1)return Promise.reject(Ee.InvalidArgumentError.format("timeout","must be greater than 0"));const u=new Bn.QueuedIteratorImpl;function l(P){u.push(()=>{u.stop(P)})}function m(P,g){P||g===null?l(P===null?void 0:P):u.push(g)}if(i.noMux){const P=a?new Error().stack:null;let g=typeof i.maxMessages=="number"&&i.maxMessages>0?i.maxMessages:-1;const E=this.subscribe((0,$n.createInbox)(this.options.inboxPrefix),{callback:(ie,_e)=>{var Fe,L;if(((Fe=_e==null?void 0:_e.data)==null?void 0:Fe.length)===0&&((L=_e==null?void 0:_e.headers)==null?void 0:L.status)==="503"&&(ie=new Ee.errors.NoRespondersError(e)),ie){P&&(ie.stack+=`
|
|
20
|
+
|
|
21
|
+
${P}`),w(ie);return}m(null,_e),i.strategy==="count"&&(g--,g===0&&w()),i.strategy==="stall"&&(U(),j=setTimeout(()=>{w()},300)),i.strategy==="sentinel"&&_e&&_e.data.length===0&&w()}});E.requestSubject=e,E.closed.then(()=>{l()}).catch(ie=>{u.stop(ie)});const w=ie=>{ie&&u.push(()=>{throw ie}),U(),E.drain().then(()=>{l()}).catch(_e=>{l()})};u.iterClosed.then(()=>{U(),E==null||E.unsubscribe()}).catch(ie=>{U(),E==null||E.unsubscribe()});const{headers:b,traceDestination:x,traceOnly:R}=i;try{this.publish(e,r,{reply:E.getSubject(),headers:b,traceDestination:x,traceOnly:R})}catch(ie){w(ie)}let j=setTimeout(()=>{w()},i.maxWait);const U=()=>{j&&clearTimeout(j)}}else{const P=i;P.callback=m,u.iterClosed.then(()=>{g.cancel()}).catch(x=>{g.cancel(x)});const g=new Dn.RequestMany(this.protocol.muxSubscriptions,e,P);this.protocol.request(g);const{headers:E,traceDestination:w,traceOnly:b}=i;try{this.publish(e,r,{reply:`${this.protocol.muxSubscriptions.baseInbox}${g.token}`,headers:E,traceDestination:w,traceOnly:b})}catch(x){g.cancel(x)}}return Promise.resolve(u)}request(e,r,i={timeout:1e3,noMux:!1}){try{this._check(e,!0,!0)}catch(u){return Promise.reject(u)}const a=!this.protocol.options.noAsyncTraces;if(i.timeout=i.timeout||1e3,i.timeout<1)return Promise.reject(Ee.InvalidArgumentError.format("timeout","must be greater than 0"));if(!i.noMux&&i.reply)return Promise.reject(Ee.InvalidArgumentError.format(["reply","noMux"],"are mutually exclusive"));if(i.noMux){const u=i.reply?i.reply:(0,$n.createInbox)(this.options.inboxPrefix),l=(0,Os.deferred)(),m=a?new Ee.errors.RequestError(""):null,P=this.subscribe(u,{max:1,timeout:i.timeout,callback:(g,E)=>{var w,b;E&&((w=E.data)==null?void 0:w.length)===0&&((b=E.headers)==null?void 0:b.code)===503&&(g=new Ee.errors.NoRespondersError(e)),g?(g instanceof Ee.TimeoutError||(m?(m.message=g.message,m.cause=g,g=m):g=new Ee.errors.RequestError(g.message,{cause:g})),l.reject(g),P.unsubscribe()):l.resolve(E)}});return P.requestSubject=e,this.protocol.publish(e,r,{reply:u,headers:i.headers}),l}else{const u=new Dn.RequestOne(this.protocol.muxSubscriptions,e,i,a);this.protocol.request(u);const{headers:l,traceDestination:m,traceOnly:P}=i;try{this.publish(e,r,{reply:`${this.protocol.muxSubscriptions.baseInbox}${u.token}`,headers:l,traceDestination:m,traceOnly:P})}catch(E){u.cancel(E)}const g=Promise.race([u.timer,u.deferred]);return g.catch(()=>{u.cancel()}),g}}flush(){return this.isClosed()?Promise.reject(new Ee.errors.ClosedConnectionError):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(new Ee.errors.ClosedConnectionError):this.isDraining()?Promise.reject(new Ee.errors.DrainingConnectionError):(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 Bn.QueuedIteratorImpl;return e.iterClosed.then(()=>{const r=this.protocol.listeners.indexOf(e);r>-1&&this.protocol.listeners.splice(r,1)}),this.protocol.listeners.push(e),e}get info(){return this.protocol.isClosed()?void 0:this.protocol.info}async context(){return(await this.request("$SYS.REQ.USER.INFO")).json((r,i)=>r==="time"?new Date(Date.parse(i)):i)}stats(){return{inBytes:this.protocol.inBytes,outBytes:this.protocol.outBytes,inMsgs:this.protocol.inMsgs,outMsgs:this.protocol.outMsgs}}getServerVersion(){const e=this.info;return e?(0,Cs.parseSemVer)(e.version):void 0}async rtt(){if(this.isClosed())throw new Ee.errors.ClosedConnectionError;if(!this.protocol.connected)throw new Ee.errors.RequestError("connection disconnected");const e=Date.now();return await this.flush(),Date.now()-e}get features(){return this.protocol.features}reconnect(){return this.isClosed()?Promise.reject(new Ee.errors.ClosedConnectionError):this.isDraining()?Promise.reject(new Ee.errors.DrainingConnectionError):this.protocol.reconnect()}addCloseListener(e){this.closeListeners===void 0&&(this.closeListeners=new Is(this.closed())),this.closeListeners.add(e)}removeCloseListener(e){this.closeListeners&&this.closeListeners.remove(e)}}wt.NatsConnectionImpl=Tr;class Is{constructor(e){d(this,"listeners");this.listeners=[],e.then(r=>{this.notify(r)})}add(e){this.listeners.push(e)}remove(e){this.listeners=this.listeners.filter(r=>r!==e)}notify(e){this.listeners.forEach(r=>{if(typeof r.connectionClosedCallback=="function")try{r.connectionClosedCallback(e)}catch{}}),this.listeners=[]}}var We={},Nr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Empty=void 0;var e=ke;Object.defineProperty(t,"Empty",{enumerable:!0,get:function(){return e.Empty}})})(Nr),Object.defineProperty(We,"__esModule",{value:!0}),We.Bench=We.Metric=void 0,We.throughput=qn,We.msgThroughput=Rs,We.humanizeBytes=zn;const js=Nr,Ts=Pt,Rr=ye;class ot{constructor(e,r){d(this,"name");d(this,"duration");d(this,"date");d(this,"payload");d(this,"msgs");d(this,"lang");d(this,"version");d(this,"bytes");d(this,"asyncRequests");d(this,"min");d(this,"max");this.name=e,this.duration=r,this.date=Date.now(),this.payload=0,this.msgs=0,this.bytes=0}toString(){const e=this.duration/1e3,r=Math.round(this.msgs/e),i=this.asyncRequests?"asyncRequests":"";let a="";return this.max&&(a=`${this.min}/${this.max}`),`${this.name}${i?" [asyncRequests]":""} ${ks(r)} msgs/sec - [${e.toFixed(2)} secs] ~ ${qn(this.bytes,e)} ${a}`}toCsv(){return`"${this.name}",${new Date(this.date).toISOString()},${this.lang},${this.version},${this.msgs},${this.payload},${this.bytes},${this.duration},${this.asyncRequests?this.asyncRequests:!1}
|
|
22
|
+
`}static header(){return`Test,Date,Lang,Version,Count,MsgPayload,Bytes,Millis,Async
|
|
23
|
+
`}}We.Metric=ot;class Ns{constructor(e,r={msgs:1e5,size:128,subject:"",asyncRequests:!1,pub:!1,sub:!1,req:!1,rep:!1}){d(this,"nc");d(this,"callbacks");d(this,"msgs");d(this,"size");d(this,"subject");d(this,"asyncRequests");d(this,"pub");d(this,"sub");d(this,"req");d(this,"rep");d(this,"perf");d(this,"payload");if(this.nc=e,this.callbacks=r.callbacks||!1,this.msgs=r.msgs||0,this.size=r.size||0,this.subject=r.subject||Ts.nuid.next(),this.asyncRequests=r.asyncRequests||!1,this.pub=r.pub||!1,this.sub=r.sub||!1,this.req=r.req||!1,this.rep=r.rep||!1,this.perf=new Rr.Perf,this.payload=this.size?new Uint8Array(this.size):js.Empty,!this.pub&&!this.sub&&!this.req&&!this.rep)throw new Error("no options selected")}async run(){return this.nc.closed().then(e=>{if(e)throw e}),this.callbacks?await this.runCallbacks():await this.runAsync(),this.processMetrics()}processMetrics(){const e=this.nc,{lang:r,version:i}=e.protocol.transport;this.pub&&this.sub&&this.perf.measure("pubsub","pubStart","subStop"),this.req&&this.rep&&this.perf.measure("reqrep","reqStart","reqStop");const a=this.perf.getEntries(),u=a.find(x=>x.name==="pubsub"),l=a.find(x=>x.name==="reqrep"),m=a.find(x=>x.name==="req"),P=a.find(x=>x.name==="rep"),g=a.find(x=>x.name==="pub"),E=a.find(x=>x.name==="sub"),w=this.nc.stats(),b=[];if(u){const{name:x,duration:R}=u,j=new ot(x,R);j.msgs=this.msgs*2,j.bytes=w.inBytes+w.outBytes,j.lang=r,j.version=i,j.payload=this.payload.length,b.push(j)}if(l){const{name:x,duration:R}=l,j=new ot(x,R);j.msgs=this.msgs*2,j.bytes=w.inBytes+w.outBytes,j.lang=r,j.version=i,j.payload=this.payload.length,b.push(j)}if(g){const{name:x,duration:R}=g,j=new ot(x,R);j.msgs=this.msgs,j.bytes=w.outBytes,j.lang=r,j.version=i,j.payload=this.payload.length,b.push(j)}if(E){const{name:x,duration:R}=E,j=new ot(x,R);j.msgs=this.msgs,j.bytes=w.inBytes,j.lang=r,j.version=i,j.payload=this.payload.length,b.push(j)}if(P){const{name:x,duration:R}=P,j=new ot(x,R);j.msgs=this.msgs,j.bytes=w.inBytes+w.outBytes,j.lang=r,j.version=i,j.payload=this.payload.length,b.push(j)}if(m){const{name:x,duration:R}=m,j=new ot(x,R);j.msgs=this.msgs,j.bytes=w.inBytes+w.outBytes,j.lang=r,j.version=i,j.payload=this.payload.length,b.push(j)}return b}async runCallbacks(){const e=[];if(this.sub){const r=(0,Rr.deferred)();e.push(r);let i=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:()=>{i++,i===1&&this.perf.mark("subStart"),i===this.msgs&&(this.perf.mark("subStop"),this.perf.measure("sub","subStart","subStop"),r.resolve())}})}if(this.rep){const r=(0,Rr.deferred)();e.push(r);let i=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:(a,u)=>{u.respond(this.payload),i++,i===1&&this.perf.mark("repStart"),i===this.msgs&&(this.perf.mark("repStop"),this.perf.measure("rep","repStart","repStop"),r.resolve())}})}if(this.pub){const r=(async()=>{this.perf.mark("pubStart");for(let i=0;i<this.msgs;i++)this.nc.publish(this.subject,this.payload);await this.nc.flush(),this.perf.mark("pubStop"),this.perf.measure("pub","pubStart","pubStop")})();e.push(r)}if(this.req){const r=(async()=>{if(this.asyncRequests){this.perf.mark("reqStart");const i=[];for(let a=0;a<this.msgs;a++)i.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(i),this.perf.mark("reqStop"),this.perf.measure("req","reqStart","reqStop")}else{this.perf.mark("reqStart");for(let i=0;i<this.msgs;i++)await this.nc.request(this.subject);this.perf.mark("reqStop"),this.perf.measure("req","reqStart","reqStop")}})();e.push(r)}await Promise.all(e)}async runAsync(){const e=[];if(this.rep){let r=!1;const i=this.nc.subscribe(this.subject,{max:this.msgs}),a=(async()=>{for await(const u of i)r||(this.perf.mark("repStart"),r=!0),u.respond(this.payload);await this.nc.flush(),this.perf.mark("repStop"),this.perf.measure("rep","repStart","repStop")})();e.push(a)}if(this.sub){let r=!1;const i=this.nc.subscribe(this.subject,{max:this.msgs}),a=(async()=>{for await(const u of i)r||(this.perf.mark("subStart"),r=!0);this.perf.mark("subStop"),this.perf.measure("sub","subStart","subStop")})();e.push(a)}if(this.pub){const r=(async()=>{this.perf.mark("pubStart");for(let i=0;i<this.msgs;i++)this.nc.publish(this.subject,this.payload);await this.nc.flush(),this.perf.mark("pubStop"),this.perf.measure("pub","pubStart","pubStop")})();e.push(r)}if(this.req){const r=(async()=>{if(this.asyncRequests){this.perf.mark("reqStart");const i=[];for(let a=0;a<this.msgs;a++)i.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(i),this.perf.mark("reqStop"),this.perf.measure("req","reqStart","reqStop")}else{this.perf.mark("reqStart");for(let i=0;i<this.msgs;i++)await this.nc.request(this.subject);this.perf.mark("reqStop"),this.perf.measure("req","reqStart","reqStop")}})();e.push(r)}await Promise.all(e)}}We.Bench=Ns;function qn(t,e){return`${zn(t/e)}/sec`}function Rs(t,e){return`${Math.floor(t/e)} msgs/sec`}function zn(t,e=!1){const r=e?1e3:1024,i=e?["k","M","G","T","P","E"]:["K","M","G","T","P","E"],a=e?"iB":"B";if(t<r)return`${t.toFixed(2)} ${a}`;const u=parseInt(Math.log(t)/Math.log(r)+""),l=parseInt(u-1+"");return`${(t/Math.pow(r,u)).toFixed(2)} ${i[l]}${a}`}function ks(t){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}var rr={};Object.defineProperty(rr,"__esModule",{value:!0}),rr.IdleHeartbeatMonitor=void 0;class Us{constructor(e,r,i={maxOut:2}){d(this,"interval");d(this,"maxOut");d(this,"cancelAfter");d(this,"timer");d(this,"autoCancelTimer");d(this,"last");d(this,"missed");d(this,"count");d(this,"callback");this.interval=e,this.maxOut=(i==null?void 0:i.maxOut)||2,this.cancelAfter=(i==null?void 0:i.cancelAfter)||0,this.last=Date.now(),this.missed=0,this.count=0,this.callback=r,this._schedule()}cancel(){this.autoCancelTimer&&clearTimeout(this.autoCancelTimer),this.timer&&clearInterval(this.timer),this.timer=0,this.autoCancelTimer=0,this.missed=0}work(){this.last=Date.now(),this.missed=0}_change(e,r=0,i=2){this.interval=e,this.maxOut=i,this.cancelAfter=r,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)}}rr.IdleHeartbeatMonitor=Us;var _t={},nr={};Object.defineProperty(nr,"__esModule",{value:!0}),nr.version=void 0,nr.version="3.2.0",Object.defineProperty(_t,"__esModule",{value:!0}),_t.WsTransport=void 0,_t.wsUrlParseFn=Jn,_t.wsconnect=zs;const Xe=ye,Gn=rt,Ls=Mt,Fs=nt,Ks=je,Bs=wt,Ds=nr,Hn=te,$s=Ds.version,qs="nats.ws";class Vn{constructor(){d(this,"version");d(this,"lang");d(this,"closeError");d(this,"connected");d(this,"done");d(this,"socket");d(this,"options");d(this,"socketClosed");d(this,"encrypted");d(this,"peeked");d(this,"yields");d(this,"signal");d(this,"closedNotification");this.version=$s,this.lang=qs,this.connected=!1,this.done=!1,this.socketClosed=!1,this.encrypted=!1,this.peeked=!1,this.yields=[],this.signal=(0,Xe.deferred)(),this.closedNotification=(0,Xe.deferred)()}async connect(e,r){const i=(0,Xe.deferred)();this.options=r;const a=e.src;if(r.wsFactory){const{socket:u,encrypted:l}=await r.wsFactory(e.src,r);this.socket=u,this.encrypted=l}else this.encrypted=a.indexOf("wss://")===0,this.socket=new WebSocket(a);return this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{this.done&&this._closed(new Error("aborted"))},this.socket.onmessage=u=>{if(this.done)return;if(this.yields.push(new Uint8Array(u.data)),this.peeked){this.signal.resolve();return}const l=Fs.DataBuffer.concat(...this.yields),m=(0,Gn.extractProtocolMessage)(l);if(m!==""){const P=Ks.INFO.exec(m);if(!P){r.debug&&console.error("!!!",(0,Xe.render)(l)),i.reject(new Error("unexpected response from server"));return}try{const g=JSON.parse(P[1]);(0,Ls.checkOptions)(g,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),i.resolve()}catch(g){i.reject(g);return}}},this.socket.onclose=u=>{let l;!u.wasClean&&u.reason!==""&&(l=new Error(u.reason)),this._closed(l),this._cleanup()},this.socket.onerror=u=>{if(this.done)return;const l=u,m=new Hn.errors.ConnectionError(l.message);i.reject(m),this._cleanup()},i}_cleanup(){this.socketClosed===!1&&(this.socketClosed=!0,this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,this.closedNotification.resolve(this.closeError))}disconnect(){this._closed(void 0,!0)}async _closed(e,r=!0){if(this.done){try{this.socket.close()}catch{}return}if(this.closeError=e,!e)for(;!this.socketClosed&&this.socket.bufferedAmount>0;)await(0,Xe.delay)(100);this.done=!0;try{this.socket.close()}catch{}return this.closedNotification}get isClosed(){return this.done}[Symbol.asyncIterator](){return this.iterate()}async*iterate(){for(;;){if(this.done)return;this.yields.length===0&&await this.signal;const e=this.yields;this.yields=[];for(let r=0;r<e.length;r++)this.options.debug&&console.info(`> ${(0,Xe.render)(e[r])}`),yield e[r];if(this.done)break;this.yields.length===0&&(e.length=0,this.yields=e,this.signal=(0,Xe.deferred)())}}isEncrypted(){return this.connected&&this.encrypted}send(e){if(!this.done)try{this.socket.send(e.buffer),this.options.debug&&console.info(`< ${(0,Xe.render)(e)}`);return}catch(r){this.options.debug&&console.error(`!!! ${(0,Xe.render)(e)}: ${r}`)}}close(e){return this._closed(e,!1)}closed(){return this.closedNotification}discard(){var e;(e=this.socket)==null||e.close()}}_t.WsTransport=Vn;function Jn(t,e){/^(.*:\/\/)(.*)/.test(t)||(typeof e=="boolean"?t=`${e===!0?"https":"http"}://${t}`:t=`https://${t}`);let i=new URL(t);const a=i.protocol.toLowerCase();a==="ws:"&&(e=!1),a==="wss:"&&(e=!0),a!=="https:"&&a!=="http"&&(t=t.replace(/^(.*:\/\/)(.*)/gm,"$2"),i=new URL(`http://${t}`));let u,l;const m=i.hostname,P=i.pathname,g=i.search||"";switch(a){case"http:":case"ws:":case"nats:":l=i.port||"80",u="ws:";break;case"https:":case"wss:":case"tls:":l=i.port||"443",u="wss:";break;default:l=i.port||e===!0?"443":"80",u=e===!0?"wss:":"ws:";break}return`${u}//${m}:${l}${P}${g}`}function zs(t={}){return(0,Gn.setTransportFactory)({defaultPort:443,urlParseFn:Jn,factory:()=>{if(t.tls)throw Hn.InvalidArgumentError.format("tls","is not configurable on w3c websocket connections");return new Vn}}),Bs.NatsConnectionImpl.connect(t)}(function(t){var e=he&&he.__createBinding||(Object.create?function(Ve,Se,Ne,Re){Re===void 0&&(Re=Ne);var Ue=Object.getOwnPropertyDescriptor(Se,Ne);(!Ue||("get"in Ue?!Se.__esModule:Ue.writable||Ue.configurable))&&(Ue={enumerable:!0,get:function(){return Se[Ne]}}),Object.defineProperty(Ve,Re,Ue)}:function(Ve,Se,Ne,Re){Re===void 0&&(Re=Ne),Ve[Re]=Se[Ne]}),r=he&&he.__exportStar||function(Ve,Se){for(var Ne in Ve)Ne!=="default"&&!Object.prototype.hasOwnProperty.call(Se,Ne)&&e(Se,Ve,Ne)};Object.defineProperty(t,"__esModule",{value:!0}),t.TD=t.Metric=t.Bench=t.writeAll=t.readAll=t.MAX_SIZE=t.DenoBuffer=t.State=t.Parser=t.Kind=t.QueuedIteratorImpl=t.usernamePasswordAuthenticator=t.tokenAuthenticator=t.nkeyAuthenticator=t.jwtAuthenticator=t.credsAuthenticator=t.RequestOne=t.parseOptions=t.hasWsProtocol=t.defaultOptions=t.DEFAULT_MAX_RECONNECT_ATTEMPTS=t.checkUnsupportedOption=t.checkOptions=t.buildAuthenticator=t.DataBuffer=t.MuxSubscription=t.Heartbeat=t.MsgHdrsImpl=t.headers=t.canonicalMIMEHeaderKey=t.timeout=t.SimpleMutex=t.render=t.nanos=t.millis=t.extend=t.delay=t.deferred=t.deadline=t.collect=t.backoff=t.ProtocolHandler=t.INFO=t.Connect=t.setTransportFactory=t.getResolveFn=t.MsgImpl=t.nuid=t.Nuid=t.NatsConnectionImpl=void 0,t.UserAuthenticationExpiredError=t.TimeoutError=t.RequestError=t.ProtocolError=t.PermissionViolationError=t.NoRespondersError=t.InvalidSubjectError=t.InvalidOperationError=t.InvalidArgumentError=t.errors=t.DrainingConnectionError=t.ConnectionError=t.ClosedConnectionError=t.AuthorizationError=t.wsUrlParseFn=t.wsconnect=t.Servers=t.isIPV4OrHostname=t.IdleHeartbeatMonitor=t.Subscriptions=t.SubscriptionImpl=t.syncIterator=t.Match=t.createInbox=t.protoLen=t.extractProtocolMessage=t.Empty=t.parseSemVer=t.Features=t.Feature=t.compare=t.parseIP=t.isIP=t.ipV4=t.TE=void 0;var i=wt;Object.defineProperty(t,"NatsConnectionImpl",{enumerable:!0,get:function(){return i.NatsConnectionImpl}});var a=Pt;Object.defineProperty(t,"Nuid",{enumerable:!0,get:function(){return a.Nuid}}),Object.defineProperty(t,"nuid",{enumerable:!0,get:function(){return a.nuid}});var u=Ct;Object.defineProperty(t,"MsgImpl",{enumerable:!0,get:function(){return u.MsgImpl}});var l=rt;Object.defineProperty(t,"getResolveFn",{enumerable:!0,get:function(){return l.getResolveFn}}),Object.defineProperty(t,"setTransportFactory",{enumerable:!0,get:function(){return l.setTransportFactory}});var m=je;Object.defineProperty(t,"Connect",{enumerable:!0,get:function(){return m.Connect}}),Object.defineProperty(t,"INFO",{enumerable:!0,get:function(){return m.INFO}}),Object.defineProperty(t,"ProtocolHandler",{enumerable:!0,get:function(){return m.ProtocolHandler}});var P=ye;Object.defineProperty(t,"backoff",{enumerable:!0,get:function(){return P.backoff}}),Object.defineProperty(t,"collect",{enumerable:!0,get:function(){return P.collect}}),Object.defineProperty(t,"deadline",{enumerable:!0,get:function(){return P.deadline}}),Object.defineProperty(t,"deferred",{enumerable:!0,get:function(){return P.deferred}}),Object.defineProperty(t,"delay",{enumerable:!0,get:function(){return P.delay}}),Object.defineProperty(t,"extend",{enumerable:!0,get:function(){return P.extend}}),Object.defineProperty(t,"millis",{enumerable:!0,get:function(){return P.millis}}),Object.defineProperty(t,"nanos",{enumerable:!0,get:function(){return P.nanos}}),Object.defineProperty(t,"render",{enumerable:!0,get:function(){return P.render}}),Object.defineProperty(t,"SimpleMutex",{enumerable:!0,get:function(){return P.SimpleMutex}}),Object.defineProperty(t,"timeout",{enumerable:!0,get:function(){return P.timeout}});var g=Qe;Object.defineProperty(t,"canonicalMIMEHeaderKey",{enumerable:!0,get:function(){return g.canonicalMIMEHeaderKey}}),Object.defineProperty(t,"headers",{enumerable:!0,get:function(){return g.headers}}),Object.defineProperty(t,"MsgHdrsImpl",{enumerable:!0,get:function(){return g.MsgHdrsImpl}});var E=At;Object.defineProperty(t,"Heartbeat",{enumerable:!0,get:function(){return E.Heartbeat}});var w=Ot;Object.defineProperty(t,"MuxSubscription",{enumerable:!0,get:function(){return w.MuxSubscription}});var b=nt;Object.defineProperty(t,"DataBuffer",{enumerable:!0,get:function(){return b.DataBuffer}});var x=Mt;Object.defineProperty(t,"buildAuthenticator",{enumerable:!0,get:function(){return x.buildAuthenticator}}),Object.defineProperty(t,"checkOptions",{enumerable:!0,get:function(){return x.checkOptions}}),Object.defineProperty(t,"checkUnsupportedOption",{enumerable:!0,get:function(){return x.checkUnsupportedOption}}),Object.defineProperty(t,"DEFAULT_MAX_RECONNECT_ATTEMPTS",{enumerable:!0,get:function(){return x.DEFAULT_MAX_RECONNECT_ATTEMPTS}}),Object.defineProperty(t,"defaultOptions",{enumerable:!0,get:function(){return x.defaultOptions}}),Object.defineProperty(t,"hasWsProtocol",{enumerable:!0,get:function(){return x.hasWsProtocol}}),Object.defineProperty(t,"parseOptions",{enumerable:!0,get:function(){return x.parseOptions}});var R=Ye;Object.defineProperty(t,"RequestOne",{enumerable:!0,get:function(){return R.RequestOne}});var j=qe;Object.defineProperty(t,"credsAuthenticator",{enumerable:!0,get:function(){return j.credsAuthenticator}}),Object.defineProperty(t,"jwtAuthenticator",{enumerable:!0,get:function(){return j.jwtAuthenticator}}),Object.defineProperty(t,"nkeyAuthenticator",{enumerable:!0,get:function(){return j.nkeyAuthenticator}}),Object.defineProperty(t,"tokenAuthenticator",{enumerable:!0,get:function(){return j.tokenAuthenticator}}),Object.defineProperty(t,"usernamePasswordAuthenticator",{enumerable:!0,get:function(){return j.usernamePasswordAuthenticator}}),r(It,t);var U=lt;Object.defineProperty(t,"QueuedIteratorImpl",{enumerable:!0,get:function(){return U.QueuedIteratorImpl}});var ie=xr;Object.defineProperty(t,"Kind",{enumerable:!0,get:function(){return ie.Kind}}),Object.defineProperty(t,"Parser",{enumerable:!0,get:function(){return ie.Parser}}),Object.defineProperty(t,"State",{enumerable:!0,get:function(){return ie.State}});var _e=pr;Object.defineProperty(t,"DenoBuffer",{enumerable:!0,get:function(){return _e.DenoBuffer}}),Object.defineProperty(t,"MAX_SIZE",{enumerable:!0,get:function(){return _e.MAX_SIZE}}),Object.defineProperty(t,"readAll",{enumerable:!0,get:function(){return _e.readAll}}),Object.defineProperty(t,"writeAll",{enumerable:!0,get:function(){return _e.writeAll}});var Fe=We;Object.defineProperty(t,"Bench",{enumerable:!0,get:function(){return Fe.Bench}}),Object.defineProperty(t,"Metric",{enumerable:!0,get:function(){return Fe.Metric}});var L=ke;Object.defineProperty(t,"TD",{enumerable:!0,get:function(){return L.TD}}),Object.defineProperty(t,"TE",{enumerable:!0,get:function(){return L.TE}});var le=ut;Object.defineProperty(t,"ipV4",{enumerable:!0,get:function(){return le.ipV4}}),Object.defineProperty(t,"isIP",{enumerable:!0,get:function(){return le.isIP}}),Object.defineProperty(t,"parseIP",{enumerable:!0,get:function(){return le.parseIP}});var de=Xt;Object.defineProperty(t,"compare",{enumerable:!0,get:function(){return de.compare}}),Object.defineProperty(t,"Feature",{enumerable:!0,get:function(){return de.Feature}}),Object.defineProperty(t,"Features",{enumerable:!0,get:function(){return de.Features}}),Object.defineProperty(t,"parseSemVer",{enumerable:!0,get:function(){return de.parseSemVer}});var He=Nr;Object.defineProperty(t,"Empty",{enumerable:!0,get:function(){return He.Empty}});var Lt=rt;Object.defineProperty(t,"extractProtocolMessage",{enumerable:!0,get:function(){return Lt.extractProtocolMessage}}),Object.defineProperty(t,"protoLen",{enumerable:!0,get:function(){return Lt.protoLen}});var gt=Ae;Object.defineProperty(t,"createInbox",{enumerable:!0,get:function(){return gt.createInbox}}),Object.defineProperty(t,"Match",{enumerable:!0,get:function(){return gt.Match}}),Object.defineProperty(t,"syncIterator",{enumerable:!0,get:function(){return gt.syncIterator}});var mt=je;Object.defineProperty(t,"SubscriptionImpl",{enumerable:!0,get:function(){return mt.SubscriptionImpl}}),Object.defineProperty(t,"Subscriptions",{enumerable:!0,get:function(){return mt.Subscriptions}});var vt=rr;Object.defineProperty(t,"IdleHeartbeatMonitor",{enumerable:!0,get:function(){return vt.IdleHeartbeatMonitor}});var xt=Je;Object.defineProperty(t,"isIPV4OrHostname",{enumerable:!0,get:function(){return xt.isIPV4OrHostname}}),Object.defineProperty(t,"Servers",{enumerable:!0,get:function(){return xt.Servers}});var Ft=_t;Object.defineProperty(t,"wsconnect",{enumerable:!0,get:function(){return Ft.wsconnect}}),Object.defineProperty(t,"wsUrlParseFn",{enumerable:!0,get:function(){return Ft.wsUrlParseFn}});var Pe=te;Object.defineProperty(t,"AuthorizationError",{enumerable:!0,get:function(){return Pe.AuthorizationError}}),Object.defineProperty(t,"ClosedConnectionError",{enumerable:!0,get:function(){return Pe.ClosedConnectionError}}),Object.defineProperty(t,"ConnectionError",{enumerable:!0,get:function(){return Pe.ConnectionError}}),Object.defineProperty(t,"DrainingConnectionError",{enumerable:!0,get:function(){return Pe.DrainingConnectionError}}),Object.defineProperty(t,"errors",{enumerable:!0,get:function(){return Pe.errors}}),Object.defineProperty(t,"InvalidArgumentError",{enumerable:!0,get:function(){return Pe.InvalidArgumentError}}),Object.defineProperty(t,"InvalidOperationError",{enumerable:!0,get:function(){return Pe.InvalidOperationError}}),Object.defineProperty(t,"InvalidSubjectError",{enumerable:!0,get:function(){return Pe.InvalidSubjectError}}),Object.defineProperty(t,"NoRespondersError",{enumerable:!0,get:function(){return Pe.NoRespondersError}}),Object.defineProperty(t,"PermissionViolationError",{enumerable:!0,get:function(){return Pe.PermissionViolationError}}),Object.defineProperty(t,"ProtocolError",{enumerable:!0,get:function(){return Pe.ProtocolError}}),Object.defineProperty(t,"RequestError",{enumerable:!0,get:function(){return Pe.RequestError}}),Object.defineProperty(t,"TimeoutError",{enumerable:!0,get:function(){return Pe.TimeoutError}}),Object.defineProperty(t,"UserAuthenticationExpiredError",{enumerable:!0,get:function(){return Pe.UserAuthenticationExpiredError}})})(Vr),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.wsconnect=t.usernamePasswordAuthenticator=t.UserAuthenticationExpiredError=t.tokenAuthenticator=t.TimeoutError=t.syncIterator=t.RequestError=t.ProtocolError=t.PermissionViolationError=t.nuid=t.Nuid=t.NoRespondersError=t.nkeys=t.nkeyAuthenticator=t.nanos=t.MsgHdrsImpl=t.millis=t.Metric=t.Match=t.jwtAuthenticator=t.InvalidSubjectError=t.InvalidOperationError=t.InvalidArgumentError=t.headers=t.hasWsProtocol=t.errors=t.Empty=t.DrainingConnectionError=t.delay=t.deferred=t.deadline=t.credsAuthenticator=t.createInbox=t.ConnectionError=t.ClosedConnectionError=t.canonicalMIMEHeaderKey=t.buildAuthenticator=t.Bench=t.backoff=t.AuthorizationError=void 0;var e=Vr;Object.defineProperty(t,"AuthorizationError",{enumerable:!0,get:function(){return e.AuthorizationError}}),Object.defineProperty(t,"backoff",{enumerable:!0,get:function(){return e.backoff}}),Object.defineProperty(t,"Bench",{enumerable:!0,get:function(){return e.Bench}}),Object.defineProperty(t,"buildAuthenticator",{enumerable:!0,get:function(){return e.buildAuthenticator}}),Object.defineProperty(t,"canonicalMIMEHeaderKey",{enumerable:!0,get:function(){return e.canonicalMIMEHeaderKey}}),Object.defineProperty(t,"ClosedConnectionError",{enumerable:!0,get:function(){return e.ClosedConnectionError}}),Object.defineProperty(t,"ConnectionError",{enumerable:!0,get:function(){return e.ConnectionError}}),Object.defineProperty(t,"createInbox",{enumerable:!0,get:function(){return e.createInbox}}),Object.defineProperty(t,"credsAuthenticator",{enumerable:!0,get:function(){return e.credsAuthenticator}}),Object.defineProperty(t,"deadline",{enumerable:!0,get:function(){return e.deadline}}),Object.defineProperty(t,"deferred",{enumerable:!0,get:function(){return e.deferred}}),Object.defineProperty(t,"delay",{enumerable:!0,get:function(){return e.delay}}),Object.defineProperty(t,"DrainingConnectionError",{enumerable:!0,get:function(){return e.DrainingConnectionError}}),Object.defineProperty(t,"Empty",{enumerable:!0,get:function(){return e.Empty}}),Object.defineProperty(t,"errors",{enumerable:!0,get:function(){return e.errors}}),Object.defineProperty(t,"hasWsProtocol",{enumerable:!0,get:function(){return e.hasWsProtocol}}),Object.defineProperty(t,"headers",{enumerable:!0,get:function(){return e.headers}}),Object.defineProperty(t,"InvalidArgumentError",{enumerable:!0,get:function(){return e.InvalidArgumentError}}),Object.defineProperty(t,"InvalidOperationError",{enumerable:!0,get:function(){return e.InvalidOperationError}}),Object.defineProperty(t,"InvalidSubjectError",{enumerable:!0,get:function(){return e.InvalidSubjectError}}),Object.defineProperty(t,"jwtAuthenticator",{enumerable:!0,get:function(){return e.jwtAuthenticator}}),Object.defineProperty(t,"Match",{enumerable:!0,get:function(){return e.Match}}),Object.defineProperty(t,"Metric",{enumerable:!0,get:function(){return e.Metric}}),Object.defineProperty(t,"millis",{enumerable:!0,get:function(){return e.millis}}),Object.defineProperty(t,"MsgHdrsImpl",{enumerable:!0,get:function(){return e.MsgHdrsImpl}}),Object.defineProperty(t,"nanos",{enumerable:!0,get:function(){return e.nanos}}),Object.defineProperty(t,"nkeyAuthenticator",{enumerable:!0,get:function(){return e.nkeyAuthenticator}}),Object.defineProperty(t,"nkeys",{enumerable:!0,get:function(){return e.nkeys}}),Object.defineProperty(t,"NoRespondersError",{enumerable:!0,get:function(){return e.NoRespondersError}}),Object.defineProperty(t,"Nuid",{enumerable:!0,get:function(){return e.Nuid}}),Object.defineProperty(t,"nuid",{enumerable:!0,get:function(){return e.nuid}}),Object.defineProperty(t,"PermissionViolationError",{enumerable:!0,get:function(){return e.PermissionViolationError}}),Object.defineProperty(t,"ProtocolError",{enumerable:!0,get:function(){return e.ProtocolError}}),Object.defineProperty(t,"RequestError",{enumerable:!0,get:function(){return e.RequestError}}),Object.defineProperty(t,"syncIterator",{enumerable:!0,get:function(){return e.syncIterator}}),Object.defineProperty(t,"TimeoutError",{enumerable:!0,get:function(){return e.TimeoutError}}),Object.defineProperty(t,"tokenAuthenticator",{enumerable:!0,get:function(){return e.tokenAuthenticator}}),Object.defineProperty(t,"UserAuthenticationExpiredError",{enumerable:!0,get:function(){return e.UserAuthenticationExpiredError}}),Object.defineProperty(t,"usernamePasswordAuthenticator",{enumerable:!0,get:function(){return e.usernamePasswordAuthenticator}}),Object.defineProperty(t,"wsconnect",{enumerable:!0,get:function(){return e.wsconnect}})}(Hr);class Gs{constructor(e){d(this,"defaultTimeout");this.natsConnection=e,this.defaultTimeout=parseInt(process.env.NATS_REQUEST_TIMEOUT||"5000",10)}async removeGroupShares(e,r,i="",a){let u="share.group.remove."+r;i&&(u=`${i}.${u}`),console.debug("Sending request to NATS subject",{messageAddress:u});const l=await this.natsConnection.request(u,JSON.stringify(e),this.toNatsOptions(a));if(!l)throw console.warn("No reply received for subject",{messageAddress:u}),new Error("No reply received");return this.extractResponse(l.json())}async upsertGroupShares(e,r,i="",a){let u="share.group.upsert."+r;i&&(u=`${i}.${u}`),console.debug("Sending request to NATS subject",{messageAddress:u});const l=await this.natsConnection.request(u,JSON.stringify(e),this.toNatsOptions(a));if(!l)throw console.warn("No reply received for subject",{messageAddress:u}),new Error("No reply received");return this.extractResponse(l.json())}extractResponse(e){return e.response||e}toNatsOptions(e){const i={timeout:(e==null?void 0:e.timeout)??this.defaultTimeout};if(e!=null&&e.headers){const a=Hr.headers();for(const[u,l]of Object.entries(e.headers))Array.isArray(l)?l.forEach(m=>a.append(u,m)):a.set(u,l);i.headers=a}return i}}Te.ShareNatsServiceClient=Gs,Object.defineProperty(Te,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RemoveGroupSharesRequest, RemoveGroupSharesResponse, UpsertGroupSharesRequest, UpsertGroupSharesResponse } from '@edifice.io/share-node-api';
|
|
2
|
+
import { NatsConnection } from '@nats-io/nats-core';
|
|
3
|
+
export interface RequestOptions {
|
|
4
|
+
timeout?: number;
|
|
5
|
+
headers?: Record<string, string[] | string>;
|
|
6
|
+
}
|
|
7
|
+
export declare class ShareNatsServiceClient {
|
|
8
|
+
private readonly natsConnection;
|
|
9
|
+
private readonly defaultTimeout;
|
|
10
|
+
constructor(natsConnection: NatsConnection);
|
|
11
|
+
/**
|
|
12
|
+
* Removes shares of a group.
|
|
13
|
+
* The 'application' parameter of the subject is provided when the client is instantiated.
|
|
14
|
+
*/
|
|
15
|
+
removeGroupShares(request: RemoveGroupSharesRequest, application: string, platformId?: string, options?: RequestOptions): Promise<RemoveGroupSharesResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Upserts shares of a group.
|
|
18
|
+
* The 'application' parameter of the subject is provided when the client is instantiated.
|
|
19
|
+
*/
|
|
20
|
+
upsertGroupShares(request: UpsertGroupSharesRequest, application: string, platformId?: string, options?: RequestOptions): Promise<UpsertGroupSharesResponse>;
|
|
21
|
+
private extractResponse;
|
|
22
|
+
private toNatsOptions;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/nats/client.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE3E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAE3E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAG5E,OAAO,KAAK,EAAE,cAAc,EAA6C,MAAM,oBAAoB,CAAC;AAGpG,MAAM,WAAW,cAAc;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC,CAAA;CAC9C;AAED,qBAAa,sBAAsB;IAIrB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAF3C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;gBAEX,cAAc,EAAE,cAAc;IAM3D;;;OAGG;IACG,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAgBtK;;;OAGG;IACG,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,GAAE,MAAW,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,yBAAyB,CAAC;IAgBtK,OAAO,CAAC,eAAe;IAKvB,OAAO,CAAC,aAAa;CAmBtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,59 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/share-node-client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0-snapshot.20261112145213",
|
|
4
|
+
"description": "Clients to interact with share-nats-service",
|
|
5
|
+
"private": false,
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "Edifice",
|
|
11
|
+
"license": "AGPL-3.0",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": "22"
|
|
14
|
+
},
|
|
15
|
+
"engineStrict": true,
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"require": "./dist/index.umd.cjs",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"types": "./dist/index.d.ts"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"main": "dist/index.umd.cjs",
|
|
25
|
+
"module": "dist/index.js",
|
|
26
|
+
"types": "dist/index.d.ts",
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@edifice.io/share-node-api": "0.1.0-snapshot.20261112145213",
|
|
32
|
+
"@nats-io/transport-node": "3.2.0",
|
|
33
|
+
"@nats-io/nats-core": "3.2.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "25.2.0",
|
|
37
|
+
"husky": "9.0.11",
|
|
38
|
+
"prettier": "3.2.5",
|
|
39
|
+
"semantic-release": "23.0.2",
|
|
40
|
+
"typescript": "5.2.2",
|
|
41
|
+
"vite": "5.1.4",
|
|
42
|
+
"vite-plugin-dts": "4.3.0",
|
|
43
|
+
"rxjs": "7.8.1"
|
|
44
|
+
},
|
|
45
|
+
"lint-staged": {
|
|
46
|
+
"*.{js,ts,jsx,tsx,json,css,md}": "pnpm format"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"dev": "vite",
|
|
50
|
+
"build": "tsc && vite build",
|
|
51
|
+
"build:types": "tsc --build",
|
|
52
|
+
"preview": "vite preview",
|
|
53
|
+
"clean": "rm -Rf dist",
|
|
54
|
+
"format": "pnpm run format:write && pnpm run format:check",
|
|
55
|
+
"format:check": "npx prettier --check \"src/**/*.ts\"",
|
|
56
|
+
"format:write": "npx prettier --write \"src/**/*.ts\"",
|
|
57
|
+
"pre-commit": "pnpm run format"
|
|
58
|
+
}
|
|
6
59
|
}
|
package/README.md
DELETED