@edifice.io/edifice-ent-client-node 6.15.0-develop-b2school.1780935759652 → 6.15.0-develop-enabling.1781278840956
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.js +68 -44
- package/dist/index.umd.cjs +8 -8
- package/dist/nats/client.d.ts +4 -1
- package/dist/nats/client.d.ts.map +1 -1
- package/dist/nats/types.d.ts +127 -0
- package/dist/nats/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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/edifice-ent-client-node"]={})))})(this,function(Te){"use strict";var Qi=Object.defineProperty;var eo=(Te,he,tt)=>he in Te?Qi(Te,he,{enumerable:!0,configurable:!0,writable:!0,value:tt}):Te[he]=tt;var l=(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 s(){return this instanceof s?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(s){var i=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(r,s,i.get?i:{enumerable:!0,get:function(){return t[s]}})}),r}var zr={},Hr={},Et={},ye={},ke={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.TD=t.TE=t.Empty=void 0,t.encode=r,t.decode=s,t.Empty=new Uint8Array(0),t.TE=new TextEncoder,t.TD=new TextDecoder;function e(...i){let a=0;for(let S=0;S<i.length;S++)a+=i[S].length;const d=new Uint8Array(a);let m=0;for(let S=0;S<i.length;S++)d.set(i[S],m),m+=i[S].length;return d}function r(...i){const a=[];for(let d=0;d<i.length;d++)a.push(t.TE.encode(i[d]));return a.length===0?t.Empty:a.length===1?a[0]:e(...a)}function s(i){return!i||i.length===0?"":t.TD.decode(i)}})(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 Vr extends Error{constructor(e,r){super(`illegal subject: '${e}'`,r),this.name="InvalidSubjectError"}}te.InvalidSubjectError=Vr;class Dt extends Error{constructor(e,r){super(e,r),this.name="InvalidArgumentError"}static format(e,r,s){return Array.isArray(r)&&r.length>1&&(r=r[0]),Array.isArray(e)?(e=e.map(i=>`'${i}'`),e=e.join(",")):e=`'${e}'`,new Dt(`${e} ${r}`,s)}}te.InvalidArgumentError=Dt;class Yr extends Error{constructor(e,r){super(e,r),this.name="InvalidOperationError"}}te.InvalidOperationError=Yr;class Gt extends Error{constructor(e,r){super(e,r),this.name="UserAuthenticationExpiredError"}static parse(e){return e.toLowerCase().indexOf("user authentication expired")!==-1?new Gt(e):null}}te.UserAuthenticationExpiredError=Gt;class Jt extends Error{constructor(e,r){super(e,r),this.name="AuthorizationError"}static parse(e){const r=["authorization violation","account authentication expired","authentication timeout"],s=e.toLowerCase();for(let i=0;i<r.length;i++)if(s.indexOf(r[i])!==-1)return new Jt(e);return null}}te.AuthorizationError=Jt;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 dr}}te.RequestError=en;class tn extends Error{constructor(e){super("timeout",e),this.name="TimeoutError"}}te.TimeoutError=tn;class dr extends Error{constructor(r,s){super(`no responders: '${r}'`,s);l(this,"subject");this.subject=r,this.name="NoResponders"}}te.NoRespondersError=dr;class zt extends Error{constructor(r,s,i,a,d){super(r,d);l(this,"operation");l(this,"subject");l(this,"queue");this.name="PermissionViolationError",this.operation=s,this.subject=i,this.queue=a}static parse(r){if((r?r.toLowerCase():"").indexOf("permissions violation")===-1)return null;let i="publish",a="",d;const m=r.match(/(Publish|Subscription) to "(\S+)"/);if(m&&(i=m[1].toLowerCase(),a=m[2],i==="subscription")){const S=r.match(/using queue "(\S+)"/);S&&(d=S[1])}return new zt(r,i,a,d)}}te.PermissionViolationError=zt,te.errors={AuthorizationError:Jt,ClosedConnectionError:Wr,ConnectionError:Zr,DrainingConnectionError:Xr,InvalidArgumentError:Dt,InvalidOperationError:Yr,InvalidSubjectError:Vr,NoRespondersError:dr,PermissionViolationError:zt,ProtocolError:Qr,RequestError:en,TimeoutError:tn,UserAuthenticationExpiredError:Gt},Object.defineProperty(ye,"__esModule",{value:!0}),ye.SimpleMutex=ye.Perf=void 0,ye.extend=fs,ye.render=us,ye.timeout=hs,ye.delay=ds,ye.deadline=ls,ye.deferred=br,ye.debugDeferred=bs,ye.shuffle=ys,ye.collect=gs,ye.jitter=rn,ye.backoff=vs,ye.nanos=ps,ye.millis=ws;const cs=ke,lr=te;function fs(t,...e){for(let r=0;r<e.length;r++){const s=e[r];Object.keys(s).forEach(function(i){t[i]=s[i]})}return t}function us(t){return cs.TD.decode(t).replace(/\n/g,"␊").replace(/\r/g,"␍")}function hs(t,e=!0){const r=e?new lr.TimeoutError:null;let s,i;const a=new Promise((d,m)=>{s={cancel:()=>{i&&clearTimeout(i)}},i=setTimeout(()=>{m(r===null?new lr.TimeoutError:r)},t)});return Object.assign(a,s)}function ds(t=0){let e;const r=new Promise(s=>{const i=setTimeout(()=>{s()},t);e={cancel:()=>{i&&(clearTimeout(i),s())}}});return Object.assign(r,e)}async function ls(t,e=1e3){const r=br(),s=setTimeout(()=>{r.reject(new lr.TimeoutError)},e);try{return await Promise.race([t,r])}finally{clearTimeout(s)}}function br(){let t={};const e=new Promise((r,s)=>{t={resolve:r,reject:s}});return Object.assign(e,t)}function bs(){let t={};const e=new Promise((r,s)=>{t={resolve:i=>{console.trace("resolve",i),r(i)},reject:i=>{console.trace("reject"),s(i)}}});return Object.assign(e,t)}function ys(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 gs(t){const e=[];for await(const r of t)e.push(r);return e}class ms{constructor(){l(this,"timers");l(this,"measures");this.timers=new Map,this.measures=new Map}mark(e){this.timers.set(e,performance.now())}measure(e,r,s){const i=this.timers.get(r);if(i===void 0)throw new Error(`${r} is not defined`);const a=this.timers.get(s);if(a===void 0)throw new Error(`${s} is not defined`);this.measures.set(e,a-i)}getEntries(){const e=[];return this.measures.forEach((r,s)=>{e.push({name:s,duration:r})}),e}}ye.Perf=ms;class _s{constructor(e=1){l(this,"max");l(this,"current");l(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=_s;function rn(t){return t===0?0:Math.floor(t/2+Math.random()*t)}function vs(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 ps(t){return t*1e6}function ws(t){return Math.floor(t/1e6)}var Me={},rt={},Oe={},St={},ft={};Object.defineProperty(ft,"__esModule",{value:!0}),ft.nuid=ft.Nuid=void 0;const nn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",yr=36,Ht=12,xs=10,sn=0xcfd41b9100000,on=33,Es=333,an=Ht+xs;function Ss(t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*255)}function Ps(t){var e;(e=globalThis==null?void 0:globalThis.crypto)!=null&&e.getRandomValues?globalThis.crypto.getRandomValues(t):Ss(t)}class cn{constructor(){l(this,"buf");l(this,"seq");l(this,"inc");l(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()*(Es-on)+on)}setPre(){const e=new Uint8Array(Ht);Ps(e);for(let r=0;r<Ht;r++){const s=e[r]%yr;this.buf[r]=nn.charCodeAt(s)}}fillSeq(){let e=this.seq;for(let r=an-1;r>=Ht;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}})}(St),Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.DEFAULT_HOST=Oe.DEFAULT_PORT=Oe.Match=void 0,Oe.syncIterator=Cs,Oe.createInbox=Ns;const As=St,Os=te;Oe.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function Cs(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 Ns(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 Os.InvalidArgumentError.format("prefix",`cannot have wildcards ('${t}')`)}),`${t}.${As.nuid.next()}`}Oe.DEFAULT_PORT=4222,Oe.DEFAULT_HOST="127.0.0.1";var nt={};Object.defineProperty(nt,"__esModule",{value:!0}),nt.DataBuffer=void 0;const fn=ke;class js{constructor(){l(this,"buffers");l(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...e){let r=0;for(let a=0;a<e.length;a++)r+=e[a].length;const s=new Uint8Array(r);let i=0;for(let a=0;a<e.length;a++)s.set(e[a],i),i+=e[a].length;return s}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 s=0;s<this.buffers.length;s++)e.set(this.buffers[s],r),r+=this.buffers[s].length;this.buffers.length=0,this.buffers.push(e)}}shift(){if(this.buffers.length){const e=this.buffers.shift();if(e)return this.byteLength-=e.length,e}return new Uint8Array(0)}drain(e){if(this.buffers.length){this.pack();const r=this.buffers.pop();if(r){const s=this.byteLength;(e===void 0||e>s)&&(e=s);const i=r.subarray(0,e);return s>e&&this.buffers.push(r.subarray(e)),this.byteLength=s-e,i}}return new Uint8Array(0)}fill(e,...r){e&&(this.buffers.push(e),this.byteLength+=e.length);for(let s=0;s<r.length;s++)r[s]&&r[s].length&&(this.buffers.push(r[s]),this.byteLength+=r[s].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=js,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=a,t.defaultPort=d,t.getUrlParseFn=m,t.newTransport=S,t.getResolveFn=_,t.protoLen=x,t.extractProtocolMessage=E;const e=ke,r=Oe,s=nt;let i;function a(b){i=b}function d(){return i!==void 0&&i.defaultPort!==void 0?i.defaultPort:r.DEFAULT_PORT}function m(){return i!==void 0&&i.urlParseFn?i.urlParseFn:void 0}function S(){if(!i||typeof i.factory!="function")throw new Error("transport fn is not set");return i.factory()}function _(){return i!==void 0&&i.dnsResolveFn?i.dnsResolveFn:void 0}t.CR_LF=`\r
|
|
2
|
-
`,t.CR_LF_LEN=t.CR_LF.length,t.CRLF=s.DataBuffer.fromAscii(t.CR_LF),t.CR=new Uint8Array(t.CRLF)[0],t.LF=new Uint8Array(t.CRLF)[1];function x(b){for(let p=0;p<b.length;p++){const R=p+1;if(b.byteLength>R&&b[p]===t.CR&&b[R]===t.LF)return R+1}return 0}function E(b){const p=x(b);if(p>0){const M=new Uint8Array(b).slice(0,p);return e.TD.decode(M)}return""}}(rt);var Ve={},ut={};Object.defineProperty(ut,"__esModule",{value:!0}),ut.ipV4=ln,ut.isIP=Is,ut.parseIP=bn;const Pt=4,st=16,Vt=48,un=57,hn=65,Ms=70,dn=97,Ts=102,gr=16777215;function ln(t,e,r,s){const i=new Uint8Array(st);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((d,m)=>{i[m]=d}),i[12]=t,i[13]=e,i[14]=r,i[15]=s,i}function Is(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 Rs(t)}}function yn(t){const e=new Uint8Array(Pt);for(let r=0;r<Pt;r++){if(t.length===0)return;if(r>0){if(t[0]!==".")return;t=t.substring(1)}const{n:s,c:i,ok:a}=ks(t);if(!a||s>255)return;t=t.substring(i),e[r]=s}return ln(e[0],e[1],e[2],e[3])}function Rs(t){const e=new Uint8Array(st);let r=-1;if(t.length>=2&&t[0]===":"&&t[1]===":"&&(r=0,t=t.substring(2),t.length===0))return e;let s=0;for(;s<st;){const{n:i,c:a,ok:d}=Us(t);if(!d||i>65535)return;if(a<t.length&&t[a]==="."){if(r<0&&s!=st-Pt||s+Pt>st)return;const m=yn(t);if(m===void 0)return;e[s]=m[12],e[s+1]=m[13],e[s+2]=m[14],e[s+3]=m[15],t="",s+=Pt;break}if(e[s]=i>>8,e[s+1]=i,s+=2,t=t.substring(a),t.length===0)break;if(t[0]!==":"||t.length==1)return;if(t=t.substring(1),t[0]===":"){if(r>=0)return;if(r=s,t=t.substring(1),t.length===0)break}}if(t.length===0){if(s<st){if(r<0)return;const i=st-s;for(let a=s-1;a>=r;a--)e[a+i]=e[a];for(let a=r+i-1;a>=r;a--)e[a]=0}else if(r>=0)return;return e}}function ks(t){let e=0,r=0;for(e=0;e<t.length&&Vt<=t.charCodeAt(e)&&t.charCodeAt(e)<=un;e++)if(r=r*10+(t.charCodeAt(e)-Vt),r>=gr)return{n:gr,c:e,ok:!1};return e===0?{n:0,c:0,ok:!1}:{n:r,c:e,ok:!0}}function Us(t){let e=0,r=0;for(r=0;r<t.length;r++){if(Vt<=t.charCodeAt(r)&&t.charCodeAt(r)<=un)e*=16,e+=t.charCodeAt(r)-Vt;else if(dn<=t.charCodeAt(r)&&t.charCodeAt(r)<=Ts)e*=16,e+=t.charCodeAt(r)-dn+10;else if(hn<=t.charCodeAt(r)&&t.charCodeAt(r)<=Ms)e*=16,e+=t.charCodeAt(r)-hn+10;else break;if(e>=gr)return{n:0,c:r,ok:!1}}return r===0?{n:0,c:r,ok:!1}:{n:e,c:r,ok:!0}}Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.Servers=Ve.ServerImpl=void 0,Ve.isIPV4OrHostname=_n,Ve.hostPort=vn;const Yt=rt,gn=ye,mr=ut,mn=Oe;function _n(t){return t.indexOf("[")!==-1||t.indexOf("::")!==-1?!1:t.indexOf(".")!==-1||t.split(":").length<=2}function _r(t){return!_n(t)}function Ls(t){const e="::FFFF:",r=t.toUpperCase().indexOf(e);if(r!==-1&&t.indexOf(".")!==-1){let s=t.substring(r+e.length);return s=s.replace("[",""),s.replace("]","")}return t}function vn(t){t=t.trim(),t.match(/^(.*:\/\/)(.*)/m)&&(t=t.replace(/^(.*:\/\/)(.*)/gm,"$2")),t=Ls(t),_r(t)&&t.indexOf("[")===-1&&(t=`[${t}]`);const e=_r(t)?t.match(/(]:)(\d+)/):t.match(/(:)(\d+)/),r=e&&e.length===3&&e[1]&&e[2]?parseInt(e[2]):mn.DEFAULT_PORT,s=r===80?"https":"http",i=new URL(`${s}://${t}`);i.port=`${r}`;let a=i.hostname;return a.charAt(0)==="["&&(a=a.substring(1,a.length-1)),{listen:i.host,hostname:a,port:r}}class ht{constructor(e,r=!1){l(this,"src");l(this,"listen");l(this,"hostname");l(this,"port");l(this,"didConnect");l(this,"reconnects");l(this,"lastConnect");l(this,"gossiped");l(this,"tlsName");l(this,"resolves");this.src=e,this.tlsName="";const s=vn(e);this.listen=s.listen,this.hostname=s.hostname,this.port=s.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,mr.isIP)(this.hostname))return[this];{const s=await e.fn(this.hostname);e.debug&&console.log(`resolve ${this.hostname} = ${s.join(",")}`);for(const i of s){const a=this.port===80?"https":"http",d=new URL(`${a}://${_r(i)?"["+i+"]":i}`);d.port=`${this.port}`;const m=new ht(d.host,!1);m.tlsName=this.hostname,r.push(m)}}return e.randomize&&(0,gn.shuffle)(r),this.resolves=r,r}}Ve.ServerImpl=ht;class $s{constructor(e=[],r={}){l(this,"firstSelect");l(this,"servers");l(this,"currentServer");l(this,"tlsName");l(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=r.randomize||!1;const s=(0,Yt.getUrlParseFn)();e&&(e.forEach(i=>{i=s?s(i):i,this.servers.push(new ht(i))}),this.randomize&&(this.servers=(0,gn.shuffle)(this.servers))),this.servers.length===0&&this.addServer(`${mn.DEFAULT_HOST}:${(0,Yt.defaultPort)()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const e=this.getCurrentServer();(0,mr.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 s=(0,Yt.getUrlParseFn)();e=s?s(e):e;const i=new ht(e,r);(0,mr.isIP)(i.hostname)&&(i.tlsName=this.tlsName),this.servers.push(i)}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 s=[];let i=[];const a=(0,Yt.getUrlParseFn)(),d=new Map;e.connect_urls&&e.connect_urls.length>0&&e.connect_urls.forEach(S=>{S=a?a(S,r):S;const _=new ht(S,!0);d.set(S,_)});const m=[];return this.servers.forEach((S,_)=>{const x=S.listen;S.gossiped&&this.currentServer.listen!==x&&d.get(x)===void 0&&m.push(_),d.delete(x)}),m.reverse(),m.forEach(S=>{const _=this.servers.splice(S,1);i=i.concat(_[0].listen)}),d.forEach((S,_)=>{this.servers.push(S),s.push(_)}),{added:s,deleted:i}}}Ve.Servers=$s;var dt={};Object.defineProperty(dt,"__esModule",{value:!0}),dt.QueuedIteratorImpl=void 0;const vr=ye,pn=te;class qs{constructor(){l(this,"inflight");l(this,"processed");l(this,"received");l(this,"noIterator");l(this,"iterClosed");l(this,"done");l(this,"signal");l(this,"yields");l(this,"filtered");l(this,"pendingFiltered");l(this,"ctx");l(this,"_data");l(this,"err");l(this,"time");l(this,"profile");l(this,"yielding");l(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 pn.InvalidOperationError("iterator cannot be used when a callback is registered");if(this.yielding)throw new pn.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 i=e[r];try{i()}catch(a){throw a}if(this.err)throw this.err;continue}this.processed++,this.inflight--;const s=this.profile?Date.now():0;yield e[r],this.time=this.profile?Date.now()-s: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}}dt.QueuedIteratorImpl=qs;var At={};Object.defineProperty(At,"__esModule",{value:!0}),At.MuxSubscription=void 0;const Fs=Oe,wn=te;class Bs{constructor(){l(this,"baseInbox");l(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(e){return this.baseInbox=`${(0,Fs.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(s=>{s.resolver(r,{})}),!0;if(r.operation==="publish"){const s=this.all().find(i=>i.requestSubject===r.subject);if(s)return s.resolver(r,{}),!0}return!1}dispatcher(){return(e,r)=>{var i,a;const s=this.getToken(r);if(s){const d=this.get(s);d&&(e===null&&(e=((i=r==null?void 0:r.data)==null?void 0:i.length)===0&&((a=r.headers)==null?void 0:a.code)===503?new wn.NoRespondersError(d.requestSubject):null),d.resolver(e,r))}}}close(){const e=new wn.RequestError("connection closed");this.reqs.forEach(r=>{r.resolver(e,{})})}}At.MuxSubscription=Bs;var Ot={};Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.Heartbeat=void 0;const Ks=ye;class Ds{constructor(e,r,s){l(this,"ph");l(this,"interval");l(this,"maxOut");l(this,"timer");l(this,"pendings");this.ph=e,this.interval=r,this.maxOut=s,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel(e){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this._reset(),e&&this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:"ping",pendingPings:this.pendings.length+1}),this.pendings.length===this.maxOut){this.cancel(!0);return}const e=(0,Ks.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))}}Ot.Heartbeat=Ds;var pr={},wr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DenoBuffer=t.MAX_SIZE=t.AssertionError=void 0,t.assert=s,t.concat=d,t.append=m,t.readAll=_,t.writeAll=x;const e=ke;class r extends Error{constructor(b){super(b),this.name="AssertionError"}}t.AssertionError=r;function s(E,b="Assertion failed."){if(!E)throw new r(b)}const i=32*1024;t.MAX_SIZE=2**32-2;function a(E,b,p=0){const R=b.byteLength-p;return E.byteLength>R&&(E=E.subarray(0,R)),b.set(E,p),E.byteLength}function d(E,b){if(E===void 0&&b===void 0)return new Uint8Array(0);if(E===void 0)return b;if(b===void 0)return E;const p=new Uint8Array(E.length+b.length);return p.set(E,0),p.set(b,E.length),p}function m(E,b){return d(E,Uint8Array.of(b))}class S{constructor(b){l(this,"_buf");l(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 p=this._buf.byteLength;return b<=this.capacity-p?(this._reslice(p+b),p):-1}_reslice(b){s(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 p=a(this._buf.subarray(this._off),b);return this._off+=p,p}writeByte(b){return this.write(Uint8Array.of(b))}writeString(b){return this.write(e.TE.encode(b))}write(b){const p=this._grow(b.byteLength);return a(b,this._buf,p)}_grow(b){const p=this.length;p===0&&this._off!==0&&this.reset();const R=this._tryGrowByReslice(b);if(R>=0)return R;const M=this.capacity;if(b<=Math.floor(M/2)-p)a(this._buf.subarray(this._off),this._buf);else{if(M+b>t.MAX_SIZE)throw new Error("The buffer cannot be grown beyond the maximum size.");{const U=new Uint8Array(Math.min(2*M+b,t.MAX_SIZE));a(this._buf.subarray(this._off),U),this._buf=U}}return this._off=0,this._reslice(Math.min(p+b,t.MAX_SIZE)),p}grow(b){if(b<0)throw Error("Buffer._grow: negative count");const p=this._grow(b);this._reslice(p)}readFrom(b){let p=0;const R=new Uint8Array(i);for(;;){const M=this.capacity-this.length<i,U=M?R:new Uint8Array(this._buf.buffer,this.length),se=b.read(U);if(se===null)return p;M?this.write(U.subarray(0,se)):this._reslice(this.length+se),p+=se}}}t.DenoBuffer=S;function _(E){const b=new S;return b.readFrom(E),b.bytes()}function x(E,b){let p=0;for(;p<b.length;)p+=E.write(b.subarray(p))}})(wr),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.cc=t.State=t.Parser=t.Kind=void 0,t.describe=s;const e=wr,r=ke;t.Kind={OK:0,ERR:1,MSG:2,INFO:3,PING:4,PONG:5};function s(S){let _,x="";switch(S.kind){case t.Kind.MSG:_="MSG";break;case t.Kind.OK:_="OK";break;case t.Kind.ERR:_="ERR",x=r.TD.decode(S.data);break;case t.Kind.PING:_="PING";break;case t.Kind.PONG:_="PONG";break;case t.Kind.INFO:_="INFO",x=r.TD.decode(S.data)}return`${_}: ${x}`}function i(){const S={};return S.sid=-1,S.hdr=-1,S.size=-1,S}const a=48,d=57;class m{constructor(_){l(this,"dispatcher");l(this,"state");l(this,"as");l(this,"drop");l(this,"hdr");l(this,"ma");l(this,"argBuf");l(this,"msgBuf");this.dispatcher=_,this.state=t.State.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(_){let x;for(x=0;x<_.length;x++){const E=_[x];switch(this.state){case t.State.OP_START:switch(E){case t.cc.M:case t.cc.m:this.state=t.State.OP_M,this.hdr=-1,this.ma=i();break;case t.cc.H:case t.cc.h:this.state=t.State.OP_H,this.hdr=0,this.ma=i();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(_.subarray(x))}break;case t.State.OP_H:switch(E){case t.cc.M:case t.cc.m:this.state=t.State.OP_M;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_M:switch(E){case t.cc.S:case t.cc.s:this.state=t.State.OP_MS;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MS:switch(E){case t.cc.G:case t.cc.g:this.state=t.State.OP_MSG;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MSG:switch(E){case t.cc.SPACE:case t.cc.TAB:this.state=t.State.OP_MSG_SPC;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MSG_SPC:switch(E){case t.cc.SPACE:case t.cc.TAB:continue;default:this.state=t.State.MSG_ARG,this.as=x}break;case t.State.MSG_ARG:switch(E){case t.cc.CR:this.drop=1;break;case t.cc.NL:{const b=this.argBuf?this.argBuf.bytes():_.subarray(this.as,x-this.drop);this.processMsgArgs(b),this.drop=0,this.as=x+1,this.state=t.State.MSG_PAYLOAD,x=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(E)}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 p=_.length-x;p<b&&(b=p),b>0?(this.msgBuf.write(_.subarray(x,x+b)),x=x+b-1):this.msgBuf.writeByte(E)}else x-this.as>=this.ma.size&&(this.dispatcher.push({kind:t.Kind.MSG,msg:this.ma,data:_.subarray(this.as,x)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=t.State.MSG_END);break;case t.State.MSG_END:switch(E){case t.cc.NL:this.drop=0,this.as=x+1,this.state=t.State.OP_START;break;default:continue}break;case t.State.OP_PLUS:switch(E){case t.cc.O:case t.cc.o:this.state=t.State.OP_PLUS_O;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_PLUS_O:switch(E){case t.cc.K:case t.cc.k:this.state=t.State.OP_PLUS_OK;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_PLUS_OK:switch(E){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(E){case t.cc.E:case t.cc.e:this.state=t.State.OP_MINUS_E;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MINUS_E:switch(E){case t.cc.R:case t.cc.r:this.state=t.State.OP_MINUS_ER;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MINUS_ER:switch(E){case t.cc.R:case t.cc.r:this.state=t.State.OP_MINUS_ERR;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MINUS_ERR:switch(E){case t.cc.SPACE:case t.cc.TAB:this.state=t.State.OP_MINUS_ERR_SPC;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MINUS_ERR_SPC:switch(E){case t.cc.SPACE:case t.cc.TAB:continue;default:this.state=t.State.MINUS_ERR_ARG,this.as=x}break;case t.State.MINUS_ERR_ARG:switch(E){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=_.subarray(this.as,x-this.drop),this.dispatcher.push({kind:t.Kind.ERR,data:b}),this.drop=0,this.as=x+1,this.state=t.State.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(E))}break;case t.State.OP_P:switch(E){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(_.subarray(x))}break;case t.State.OP_PO:switch(E){case t.cc.N:case t.cc.n:this.state=t.State.OP_PON;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_PON:switch(E){case t.cc.G:case t.cc.g:this.state=t.State.OP_PONG;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_PONG:switch(E){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(E){case t.cc.N:case t.cc.n:this.state=t.State.OP_PIN;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_PIN:switch(E){case t.cc.G:case t.cc.g:this.state=t.State.OP_PING;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_PING:switch(E){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(E){case t.cc.N:case t.cc.n:this.state=t.State.OP_IN;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_IN:switch(E){case t.cc.F:case t.cc.f:this.state=t.State.OP_INF;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_INF:switch(E){case t.cc.O:case t.cc.o:this.state=t.State.OP_INFO;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_INFO:switch(E){case t.cc.SPACE:case t.cc.TAB:this.state=t.State.OP_INFO_SPC;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_INFO_SPC:switch(E){case t.cc.SPACE:case t.cc.TAB:continue;default:this.state=t.State.INFO_ARG,this.as=x}break;case t.State.INFO_ARG:switch(E){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=_.subarray(this.as,x-this.drop),this.dispatcher.push({kind:t.Kind.INFO,data:b}),this.drop=0,this.as=x+1,this.state=t.State.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(E)}break;default:throw this.fail(_.subarray(x))}}(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(_.subarray(this.as,x-this.drop))),this.state===t.State.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new e.DenoBuffer(_.subarray(this.as)))}cloneMsgArg(){const _=this.ma.subject.length,x=this.ma.reply?this.ma.reply.length:0,E=new Uint8Array(_+x);E.set(this.ma.subject),this.ma.reply&&E.set(this.ma.reply,_),this.argBuf=new e.DenoBuffer(E),this.ma.subject=E.subarray(0,_),this.ma.reply&&(this.ma.reply=E.subarray(_))}processMsgArgs(_){if(this.hdr>=0)return this.processHeaderMsgArgs(_);const x=[];let E=-1;for(let b=0;b<_.length;b++)switch(_[b]){case t.cc.SPACE:case t.cc.TAB:case t.cc.CR:case t.cc.NL:E>=0&&(x.push(_.subarray(E,b)),E=-1);break;default:E<0&&(E=b)}switch(E>=0&&x.push(_.subarray(E)),x.length){case 3:this.ma.subject=x[0],this.ma.sid=this.protoParseInt(x[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(x[2]);break;case 4:this.ma.subject=x[0],this.ma.sid=this.protoParseInt(x[1]),this.ma.reply=x[2],this.ma.size=this.protoParseInt(x[3]);break;default:throw this.fail(_,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(_,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail(_,"processMsgArgs Bad or Missing Size Error")}fail(_,x=""){return x?x=`${x} [${this.state}]`:x=`parse error [${this.state}]`,new Error(`${x}: ${r.TD.decode(_)}`)}processHeaderMsgArgs(_){const x=[];let E=-1;for(let b=0;b<_.length;b++)switch(_[b]){case t.cc.SPACE:case t.cc.TAB:case t.cc.CR:case t.cc.NL:E>=0&&(x.push(_.subarray(E,b)),E=-1);break;default:E<0&&(E=b)}switch(E>=0&&x.push(_.subarray(E)),x.length){case 4:this.ma.subject=x[0],this.ma.sid=this.protoParseInt(x[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(x[2]),this.ma.size=this.protoParseInt(x[3]);break;case 5:this.ma.subject=x[0],this.ma.sid=this.protoParseInt(x[1]),this.ma.reply=x[2],this.ma.hdr=this.protoParseInt(x[3]),this.ma.size=this.protoParseInt(x[4]);break;default:throw this.fail(_,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(_,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(_,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(_,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt(_){if(_.length===0)return-1;let x=0;for(let E=0;E<_.length;E++){if(_[E]<a||_[E]>d)return-1;x=x*10+(_[E]-a)}return x}}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}}(pr);var Ct={},Qe={};Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.MsgHdrsImpl=void 0,Qe.canonicalMIMEHeaderKey=Er,Qe.headers=Gs;const xn=ke,Fe=Oe,xr=te;function Er(t){let x=!0;const E=new Array(t.length);for(let b=0;b<t.length;b++){let p=t.charCodeAt(b);if(p===58||p<33||p>126)throw xr.InvalidArgumentError.format("header",`'${t[b]}' is not a valid character in a header name`);x&&97<=p&&p<=122?p-=32:!x&&65<=p&&p<=90&&(p+=32),E[b]=p,x=p==45}return String.fromCharCode(...E)}function Gs(t=0,e=""){if(t===0&&e!==""||t>0&&e==="")throw xr.InvalidArgumentError.format("description","is required");return new lt(t,e)}const Sr="NATS/1.0";class lt{constructor(e=0,r=""){l(this,"_code");l(this,"headers");l(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,s]of this.headers){const i=e.values(r);if(s.length!==i.length)return!1;const a=[...s].sort(),d=[...i].sort();for(let m=0;m<a.length;m++)if(a[m]!==d[m])return!1}return!0}return!1}static decode(e){const r=new lt,i=xn.TD.decode(e).split(`\r
|
|
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/edifice-ent-client-node"]={})))})(this,function(Te){"use strict";var Qi=Object.defineProperty;var eo=(Te,he,tt)=>he in Te?Qi(Te,he,{enumerable:!0,configurable:!0,writable:!0,value:tt}):Te[he]=tt;var l=(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 s(){return this instanceof s?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(s){var i=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(r,s,i.get?i:{enumerable:!0,get:function(){return t[s]}})}),r}var zr={},Hr={},Et={},ye={},ke={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.TD=t.TE=t.Empty=void 0,t.encode=r,t.decode=s,t.Empty=new Uint8Array(0),t.TE=new TextEncoder,t.TD=new TextDecoder;function e(...i){let a=0;for(let S=0;S<i.length;S++)a+=i[S].length;const d=new Uint8Array(a);let m=0;for(let S=0;S<i.length;S++)d.set(i[S],m),m+=i[S].length;return d}function r(...i){const a=[];for(let d=0;d<i.length;d++)a.push(t.TE.encode(i[d]));return a.length===0?t.Empty:a.length===1?a[0]:e(...a)}function s(i){return!i||i.length===0?"":t.TD.decode(i)}})(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 Vr extends Error{constructor(e,r){super(`illegal subject: '${e}'`,r),this.name="InvalidSubjectError"}}te.InvalidSubjectError=Vr;class Dt extends Error{constructor(e,r){super(e,r),this.name="InvalidArgumentError"}static format(e,r,s){return Array.isArray(r)&&r.length>1&&(r=r[0]),Array.isArray(e)?(e=e.map(i=>`'${i}'`),e=e.join(",")):e=`'${e}'`,new Dt(`${e} ${r}`,s)}}te.InvalidArgumentError=Dt;class Yr extends Error{constructor(e,r){super(e,r),this.name="InvalidOperationError"}}te.InvalidOperationError=Yr;class Gt extends Error{constructor(e,r){super(e,r),this.name="UserAuthenticationExpiredError"}static parse(e){return e.toLowerCase().indexOf("user authentication expired")!==-1?new Gt(e):null}}te.UserAuthenticationExpiredError=Gt;class Jt extends Error{constructor(e,r){super(e,r),this.name="AuthorizationError"}static parse(e){const r=["authorization violation","account authentication expired","authentication timeout"],s=e.toLowerCase();for(let i=0;i<r.length;i++)if(s.indexOf(r[i])!==-1)return new Jt(e);return null}}te.AuthorizationError=Jt;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 dr}}te.RequestError=en;class tn extends Error{constructor(e){super("timeout",e),this.name="TimeoutError"}}te.TimeoutError=tn;class dr extends Error{constructor(r,s){super(`no responders: '${r}'`,s);l(this,"subject");this.subject=r,this.name="NoResponders"}}te.NoRespondersError=dr;class zt extends Error{constructor(r,s,i,a,d){super(r,d);l(this,"operation");l(this,"subject");l(this,"queue");this.name="PermissionViolationError",this.operation=s,this.subject=i,this.queue=a}static parse(r){if((r?r.toLowerCase():"").indexOf("permissions violation")===-1)return null;let i="publish",a="",d;const m=r.match(/(Publish|Subscription) to "(\S+)"/);if(m&&(i=m[1].toLowerCase(),a=m[2],i==="subscription")){const S=r.match(/using queue "(\S+)"/);S&&(d=S[1])}return new zt(r,i,a,d)}}te.PermissionViolationError=zt,te.errors={AuthorizationError:Jt,ClosedConnectionError:Wr,ConnectionError:Zr,DrainingConnectionError:Xr,InvalidArgumentError:Dt,InvalidOperationError:Yr,InvalidSubjectError:Vr,NoRespondersError:dr,PermissionViolationError:zt,ProtocolError:Qr,RequestError:en,TimeoutError:tn,UserAuthenticationExpiredError:Gt},Object.defineProperty(ye,"__esModule",{value:!0}),ye.SimpleMutex=ye.Perf=void 0,ye.extend=fs,ye.render=us,ye.timeout=hs,ye.delay=ds,ye.deadline=ls,ye.deferred=br,ye.debugDeferred=bs,ye.shuffle=ys,ye.collect=gs,ye.jitter=rn,ye.backoff=vs,ye.nanos=ps,ye.millis=ws;const cs=ke,lr=te;function fs(t,...e){for(let r=0;r<e.length;r++){const s=e[r];Object.keys(s).forEach(function(i){t[i]=s[i]})}return t}function us(t){return cs.TD.decode(t).replace(/\n/g,"␊").replace(/\r/g,"␍")}function hs(t,e=!0){const r=e?new lr.TimeoutError:null;let s,i;const a=new Promise((d,m)=>{s={cancel:()=>{i&&clearTimeout(i)}},i=setTimeout(()=>{m(r===null?new lr.TimeoutError:r)},t)});return Object.assign(a,s)}function ds(t=0){let e;const r=new Promise(s=>{const i=setTimeout(()=>{s()},t);e={cancel:()=>{i&&(clearTimeout(i),s())}}});return Object.assign(r,e)}async function ls(t,e=1e3){const r=br(),s=setTimeout(()=>{r.reject(new lr.TimeoutError)},e);try{return await Promise.race([t,r])}finally{clearTimeout(s)}}function br(){let t={};const e=new Promise((r,s)=>{t={resolve:r,reject:s}});return Object.assign(e,t)}function bs(){let t={};const e=new Promise((r,s)=>{t={resolve:i=>{console.trace("resolve",i),r(i)},reject:i=>{console.trace("reject"),s(i)}}});return Object.assign(e,t)}function ys(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 gs(t){const e=[];for await(const r of t)e.push(r);return e}class ms{constructor(){l(this,"timers");l(this,"measures");this.timers=new Map,this.measures=new Map}mark(e){this.timers.set(e,performance.now())}measure(e,r,s){const i=this.timers.get(r);if(i===void 0)throw new Error(`${r} is not defined`);const a=this.timers.get(s);if(a===void 0)throw new Error(`${s} is not defined`);this.measures.set(e,a-i)}getEntries(){const e=[];return this.measures.forEach((r,s)=>{e.push({name:s,duration:r})}),e}}ye.Perf=ms;class _s{constructor(e=1){l(this,"max");l(this,"current");l(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=_s;function rn(t){return t===0?0:Math.floor(t/2+Math.random()*t)}function vs(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 ps(t){return t*1e6}function ws(t){return Math.floor(t/1e6)}var Me={},rt={},Oe={},St={},ft={};Object.defineProperty(ft,"__esModule",{value:!0}),ft.nuid=ft.Nuid=void 0;const nn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",yr=36,Ht=12,xs=10,sn=0xcfd41b9100000,on=33,Es=333,an=Ht+xs;function Ss(t){for(let e=0;e<t.length;e++)t[e]=Math.floor(Math.random()*255)}function Ps(t){var e;(e=globalThis==null?void 0:globalThis.crypto)!=null&&e.getRandomValues?globalThis.crypto.getRandomValues(t):Ss(t)}class cn{constructor(){l(this,"buf");l(this,"seq");l(this,"inc");l(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()*(Es-on)+on)}setPre(){const e=new Uint8Array(Ht);Ps(e);for(let r=0;r<Ht;r++){const s=e[r]%yr;this.buf[r]=nn.charCodeAt(s)}}fillSeq(){let e=this.seq;for(let r=an-1;r>=Ht;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}})}(St),Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.DEFAULT_HOST=Oe.DEFAULT_PORT=Oe.Match=void 0,Oe.syncIterator=Ns,Oe.createInbox=Cs;const As=St,Os=te;Oe.Match={Exact:"exact",CanonicalMIME:"canonical",IgnoreCase:"insensitive"};function Ns(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 Cs(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 Os.InvalidArgumentError.format("prefix",`cannot have wildcards ('${t}')`)}),`${t}.${As.nuid.next()}`}Oe.DEFAULT_PORT=4222,Oe.DEFAULT_HOST="127.0.0.1";var nt={};Object.defineProperty(nt,"__esModule",{value:!0}),nt.DataBuffer=void 0;const fn=ke;class js{constructor(){l(this,"buffers");l(this,"byteLength");this.buffers=[],this.byteLength=0}static concat(...e){let r=0;for(let a=0;a<e.length;a++)r+=e[a].length;const s=new Uint8Array(r);let i=0;for(let a=0;a<e.length;a++)s.set(e[a],i),i+=e[a].length;return s}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 s=0;s<this.buffers.length;s++)e.set(this.buffers[s],r),r+=this.buffers[s].length;this.buffers.length=0,this.buffers.push(e)}}shift(){if(this.buffers.length){const e=this.buffers.shift();if(e)return this.byteLength-=e.length,e}return new Uint8Array(0)}drain(e){if(this.buffers.length){this.pack();const r=this.buffers.pop();if(r){const s=this.byteLength;(e===void 0||e>s)&&(e=s);const i=r.subarray(0,e);return s>e&&this.buffers.push(r.subarray(e)),this.byteLength=s-e,i}}return new Uint8Array(0)}fill(e,...r){e&&(this.buffers.push(e),this.byteLength+=e.length);for(let s=0;s<r.length;s++)r[s]&&r[s].length&&(this.buffers.push(r[s]),this.byteLength+=r[s].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=js,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=a,t.defaultPort=d,t.getUrlParseFn=m,t.newTransport=S,t.getResolveFn=_,t.protoLen=x,t.extractProtocolMessage=E;const e=ke,r=Oe,s=nt;let i;function a(b){i=b}function d(){return i!==void 0&&i.defaultPort!==void 0?i.defaultPort:r.DEFAULT_PORT}function m(){return i!==void 0&&i.urlParseFn?i.urlParseFn:void 0}function S(){if(!i||typeof i.factory!="function")throw new Error("transport fn is not set");return i.factory()}function _(){return i!==void 0&&i.dnsResolveFn?i.dnsResolveFn:void 0}t.CR_LF=`\r
|
|
2
|
+
`,t.CR_LF_LEN=t.CR_LF.length,t.CRLF=s.DataBuffer.fromAscii(t.CR_LF),t.CR=new Uint8Array(t.CRLF)[0],t.LF=new Uint8Array(t.CRLF)[1];function x(b){for(let p=0;p<b.length;p++){const R=p+1;if(b.byteLength>R&&b[p]===t.CR&&b[R]===t.LF)return R+1}return 0}function E(b){const p=x(b);if(p>0){const M=new Uint8Array(b).slice(0,p);return e.TD.decode(M)}return""}}(rt);var Ve={},ut={};Object.defineProperty(ut,"__esModule",{value:!0}),ut.ipV4=ln,ut.isIP=Is,ut.parseIP=bn;const Pt=4,st=16,Vt=48,un=57,hn=65,Ms=70,dn=97,Ts=102,gr=16777215;function ln(t,e,r,s){const i=new Uint8Array(st);return[0,0,0,0,0,0,0,0,0,0,255,255].forEach((d,m)=>{i[m]=d}),i[12]=t,i[13]=e,i[14]=r,i[15]=s,i}function Is(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 Rs(t)}}function yn(t){const e=new Uint8Array(Pt);for(let r=0;r<Pt;r++){if(t.length===0)return;if(r>0){if(t[0]!==".")return;t=t.substring(1)}const{n:s,c:i,ok:a}=ks(t);if(!a||s>255)return;t=t.substring(i),e[r]=s}return ln(e[0],e[1],e[2],e[3])}function Rs(t){const e=new Uint8Array(st);let r=-1;if(t.length>=2&&t[0]===":"&&t[1]===":"&&(r=0,t=t.substring(2),t.length===0))return e;let s=0;for(;s<st;){const{n:i,c:a,ok:d}=Us(t);if(!d||i>65535)return;if(a<t.length&&t[a]==="."){if(r<0&&s!=st-Pt||s+Pt>st)return;const m=yn(t);if(m===void 0)return;e[s]=m[12],e[s+1]=m[13],e[s+2]=m[14],e[s+3]=m[15],t="",s+=Pt;break}if(e[s]=i>>8,e[s+1]=i,s+=2,t=t.substring(a),t.length===0)break;if(t[0]!==":"||t.length==1)return;if(t=t.substring(1),t[0]===":"){if(r>=0)return;if(r=s,t=t.substring(1),t.length===0)break}}if(t.length===0){if(s<st){if(r<0)return;const i=st-s;for(let a=s-1;a>=r;a--)e[a+i]=e[a];for(let a=r+i-1;a>=r;a--)e[a]=0}else if(r>=0)return;return e}}function ks(t){let e=0,r=0;for(e=0;e<t.length&&Vt<=t.charCodeAt(e)&&t.charCodeAt(e)<=un;e++)if(r=r*10+(t.charCodeAt(e)-Vt),r>=gr)return{n:gr,c:e,ok:!1};return e===0?{n:0,c:0,ok:!1}:{n:r,c:e,ok:!0}}function Us(t){let e=0,r=0;for(r=0;r<t.length;r++){if(Vt<=t.charCodeAt(r)&&t.charCodeAt(r)<=un)e*=16,e+=t.charCodeAt(r)-Vt;else if(dn<=t.charCodeAt(r)&&t.charCodeAt(r)<=Ts)e*=16,e+=t.charCodeAt(r)-dn+10;else if(hn<=t.charCodeAt(r)&&t.charCodeAt(r)<=Ms)e*=16,e+=t.charCodeAt(r)-hn+10;else break;if(e>=gr)return{n:0,c:r,ok:!1}}return r===0?{n:0,c:r,ok:!1}:{n:e,c:r,ok:!0}}Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.Servers=Ve.ServerImpl=void 0,Ve.isIPV4OrHostname=_n,Ve.hostPort=vn;const Yt=rt,gn=ye,mr=ut,mn=Oe;function _n(t){return t.indexOf("[")!==-1||t.indexOf("::")!==-1?!1:t.indexOf(".")!==-1||t.split(":").length<=2}function _r(t){return!_n(t)}function Ls(t){const e="::FFFF:",r=t.toUpperCase().indexOf(e);if(r!==-1&&t.indexOf(".")!==-1){let s=t.substring(r+e.length);return s=s.replace("[",""),s.replace("]","")}return t}function vn(t){t=t.trim(),t.match(/^(.*:\/\/)(.*)/m)&&(t=t.replace(/^(.*:\/\/)(.*)/gm,"$2")),t=Ls(t),_r(t)&&t.indexOf("[")===-1&&(t=`[${t}]`);const e=_r(t)?t.match(/(]:)(\d+)/):t.match(/(:)(\d+)/),r=e&&e.length===3&&e[1]&&e[2]?parseInt(e[2]):mn.DEFAULT_PORT,s=r===80?"https":"http",i=new URL(`${s}://${t}`);i.port=`${r}`;let a=i.hostname;return a.charAt(0)==="["&&(a=a.substring(1,a.length-1)),{listen:i.host,hostname:a,port:r}}class ht{constructor(e,r=!1){l(this,"src");l(this,"listen");l(this,"hostname");l(this,"port");l(this,"didConnect");l(this,"reconnects");l(this,"lastConnect");l(this,"gossiped");l(this,"tlsName");l(this,"resolves");this.src=e,this.tlsName="";const s=vn(e);this.listen=s.listen,this.hostname=s.hostname,this.port=s.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,mr.isIP)(this.hostname))return[this];{const s=await e.fn(this.hostname);e.debug&&console.log(`resolve ${this.hostname} = ${s.join(",")}`);for(const i of s){const a=this.port===80?"https":"http",d=new URL(`${a}://${_r(i)?"["+i+"]":i}`);d.port=`${this.port}`;const m=new ht(d.host,!1);m.tlsName=this.hostname,r.push(m)}}return e.randomize&&(0,gn.shuffle)(r),this.resolves=r,r}}Ve.ServerImpl=ht;class $s{constructor(e=[],r={}){l(this,"firstSelect");l(this,"servers");l(this,"currentServer");l(this,"tlsName");l(this,"randomize");this.firstSelect=!0,this.servers=[],this.tlsName="",this.randomize=r.randomize||!1;const s=(0,Yt.getUrlParseFn)();e&&(e.forEach(i=>{i=s?s(i):i,this.servers.push(new ht(i))}),this.randomize&&(this.servers=(0,gn.shuffle)(this.servers))),this.servers.length===0&&this.addServer(`${mn.DEFAULT_HOST}:${(0,Yt.defaultPort)()}`,!1),this.currentServer=this.servers[0]}clear(){this.servers.length=0}updateTLSName(){const e=this.getCurrentServer();(0,mr.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 s=(0,Yt.getUrlParseFn)();e=s?s(e):e;const i=new ht(e,r);(0,mr.isIP)(i.hostname)&&(i.tlsName=this.tlsName),this.servers.push(i)}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 s=[];let i=[];const a=(0,Yt.getUrlParseFn)(),d=new Map;e.connect_urls&&e.connect_urls.length>0&&e.connect_urls.forEach(S=>{S=a?a(S,r):S;const _=new ht(S,!0);d.set(S,_)});const m=[];return this.servers.forEach((S,_)=>{const x=S.listen;S.gossiped&&this.currentServer.listen!==x&&d.get(x)===void 0&&m.push(_),d.delete(x)}),m.reverse(),m.forEach(S=>{const _=this.servers.splice(S,1);i=i.concat(_[0].listen)}),d.forEach((S,_)=>{this.servers.push(S),s.push(_)}),{added:s,deleted:i}}}Ve.Servers=$s;var dt={};Object.defineProperty(dt,"__esModule",{value:!0}),dt.QueuedIteratorImpl=void 0;const vr=ye,pn=te;class qs{constructor(){l(this,"inflight");l(this,"processed");l(this,"received");l(this,"noIterator");l(this,"iterClosed");l(this,"done");l(this,"signal");l(this,"yields");l(this,"filtered");l(this,"pendingFiltered");l(this,"ctx");l(this,"_data");l(this,"err");l(this,"time");l(this,"profile");l(this,"yielding");l(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 pn.InvalidOperationError("iterator cannot be used when a callback is registered");if(this.yielding)throw new pn.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 i=e[r];try{i()}catch(a){throw a}if(this.err)throw this.err;continue}this.processed++,this.inflight--;const s=this.profile?Date.now():0;yield e[r],this.time=this.profile?Date.now()-s: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}}dt.QueuedIteratorImpl=qs;var At={};Object.defineProperty(At,"__esModule",{value:!0}),At.MuxSubscription=void 0;const Fs=Oe,wn=te;class Bs{constructor(){l(this,"baseInbox");l(this,"reqs");this.reqs=new Map}size(){return this.reqs.size}init(e){return this.baseInbox=`${(0,Fs.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(s=>{s.resolver(r,{})}),!0;if(r.operation==="publish"){const s=this.all().find(i=>i.requestSubject===r.subject);if(s)return s.resolver(r,{}),!0}return!1}dispatcher(){return(e,r)=>{var i,a;const s=this.getToken(r);if(s){const d=this.get(s);d&&(e===null&&(e=((i=r==null?void 0:r.data)==null?void 0:i.length)===0&&((a=r.headers)==null?void 0:a.code)===503?new wn.NoRespondersError(d.requestSubject):null),d.resolver(e,r))}}}close(){const e=new wn.RequestError("connection closed");this.reqs.forEach(r=>{r.resolver(e,{})})}}At.MuxSubscription=Bs;var Ot={};Object.defineProperty(Ot,"__esModule",{value:!0}),Ot.Heartbeat=void 0;const Ks=ye;class Ds{constructor(e,r,s){l(this,"ph");l(this,"interval");l(this,"maxOut");l(this,"timer");l(this,"pendings");this.ph=e,this.interval=r,this.maxOut=s,this.pendings=[]}start(){this.cancel(),this._schedule()}cancel(e){this.timer&&(clearTimeout(this.timer),this.timer=void 0),this._reset(),e&&this.ph.disconnect()}_schedule(){this.timer=setTimeout(()=>{if(this.ph.dispatchStatus({type:"ping",pendingPings:this.pendings.length+1}),this.pendings.length===this.maxOut){this.cancel(!0);return}const e=(0,Ks.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))}}Ot.Heartbeat=Ds;var pr={},wr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.DenoBuffer=t.MAX_SIZE=t.AssertionError=void 0,t.assert=s,t.concat=d,t.append=m,t.readAll=_,t.writeAll=x;const e=ke;class r extends Error{constructor(b){super(b),this.name="AssertionError"}}t.AssertionError=r;function s(E,b="Assertion failed."){if(!E)throw new r(b)}const i=32*1024;t.MAX_SIZE=2**32-2;function a(E,b,p=0){const R=b.byteLength-p;return E.byteLength>R&&(E=E.subarray(0,R)),b.set(E,p),E.byteLength}function d(E,b){if(E===void 0&&b===void 0)return new Uint8Array(0);if(E===void 0)return b;if(b===void 0)return E;const p=new Uint8Array(E.length+b.length);return p.set(E,0),p.set(b,E.length),p}function m(E,b){return d(E,Uint8Array.of(b))}class S{constructor(b){l(this,"_buf");l(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 p=this._buf.byteLength;return b<=this.capacity-p?(this._reslice(p+b),p):-1}_reslice(b){s(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 p=a(this._buf.subarray(this._off),b);return this._off+=p,p}writeByte(b){return this.write(Uint8Array.of(b))}writeString(b){return this.write(e.TE.encode(b))}write(b){const p=this._grow(b.byteLength);return a(b,this._buf,p)}_grow(b){const p=this.length;p===0&&this._off!==0&&this.reset();const R=this._tryGrowByReslice(b);if(R>=0)return R;const M=this.capacity;if(b<=Math.floor(M/2)-p)a(this._buf.subarray(this._off),this._buf);else{if(M+b>t.MAX_SIZE)throw new Error("The buffer cannot be grown beyond the maximum size.");{const U=new Uint8Array(Math.min(2*M+b,t.MAX_SIZE));a(this._buf.subarray(this._off),U),this._buf=U}}return this._off=0,this._reslice(Math.min(p+b,t.MAX_SIZE)),p}grow(b){if(b<0)throw Error("Buffer._grow: negative count");const p=this._grow(b);this._reslice(p)}readFrom(b){let p=0;const R=new Uint8Array(i);for(;;){const M=this.capacity-this.length<i,U=M?R:new Uint8Array(this._buf.buffer,this.length),se=b.read(U);if(se===null)return p;M?this.write(U.subarray(0,se)):this._reslice(this.length+se),p+=se}}}t.DenoBuffer=S;function _(E){const b=new S;return b.readFrom(E),b.bytes()}function x(E,b){let p=0;for(;p<b.length;)p+=E.write(b.subarray(p))}})(wr),function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.cc=t.State=t.Parser=t.Kind=void 0,t.describe=s;const e=wr,r=ke;t.Kind={OK:0,ERR:1,MSG:2,INFO:3,PING:4,PONG:5};function s(S){let _,x="";switch(S.kind){case t.Kind.MSG:_="MSG";break;case t.Kind.OK:_="OK";break;case t.Kind.ERR:_="ERR",x=r.TD.decode(S.data);break;case t.Kind.PING:_="PING";break;case t.Kind.PONG:_="PONG";break;case t.Kind.INFO:_="INFO",x=r.TD.decode(S.data)}return`${_}: ${x}`}function i(){const S={};return S.sid=-1,S.hdr=-1,S.size=-1,S}const a=48,d=57;class m{constructor(_){l(this,"dispatcher");l(this,"state");l(this,"as");l(this,"drop");l(this,"hdr");l(this,"ma");l(this,"argBuf");l(this,"msgBuf");this.dispatcher=_,this.state=t.State.OP_START,this.as=0,this.drop=0,this.hdr=0}parse(_){let x;for(x=0;x<_.length;x++){const E=_[x];switch(this.state){case t.State.OP_START:switch(E){case t.cc.M:case t.cc.m:this.state=t.State.OP_M,this.hdr=-1,this.ma=i();break;case t.cc.H:case t.cc.h:this.state=t.State.OP_H,this.hdr=0,this.ma=i();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(_.subarray(x))}break;case t.State.OP_H:switch(E){case t.cc.M:case t.cc.m:this.state=t.State.OP_M;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_M:switch(E){case t.cc.S:case t.cc.s:this.state=t.State.OP_MS;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MS:switch(E){case t.cc.G:case t.cc.g:this.state=t.State.OP_MSG;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MSG:switch(E){case t.cc.SPACE:case t.cc.TAB:this.state=t.State.OP_MSG_SPC;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MSG_SPC:switch(E){case t.cc.SPACE:case t.cc.TAB:continue;default:this.state=t.State.MSG_ARG,this.as=x}break;case t.State.MSG_ARG:switch(E){case t.cc.CR:this.drop=1;break;case t.cc.NL:{const b=this.argBuf?this.argBuf.bytes():_.subarray(this.as,x-this.drop);this.processMsgArgs(b),this.drop=0,this.as=x+1,this.state=t.State.MSG_PAYLOAD,x=this.as+this.ma.size-1;break}default:this.argBuf&&this.argBuf.writeByte(E)}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 p=_.length-x;p<b&&(b=p),b>0?(this.msgBuf.write(_.subarray(x,x+b)),x=x+b-1):this.msgBuf.writeByte(E)}else x-this.as>=this.ma.size&&(this.dispatcher.push({kind:t.Kind.MSG,msg:this.ma,data:_.subarray(this.as,x)}),this.argBuf=void 0,this.msgBuf=void 0,this.state=t.State.MSG_END);break;case t.State.MSG_END:switch(E){case t.cc.NL:this.drop=0,this.as=x+1,this.state=t.State.OP_START;break;default:continue}break;case t.State.OP_PLUS:switch(E){case t.cc.O:case t.cc.o:this.state=t.State.OP_PLUS_O;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_PLUS_O:switch(E){case t.cc.K:case t.cc.k:this.state=t.State.OP_PLUS_OK;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_PLUS_OK:switch(E){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(E){case t.cc.E:case t.cc.e:this.state=t.State.OP_MINUS_E;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MINUS_E:switch(E){case t.cc.R:case t.cc.r:this.state=t.State.OP_MINUS_ER;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MINUS_ER:switch(E){case t.cc.R:case t.cc.r:this.state=t.State.OP_MINUS_ERR;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MINUS_ERR:switch(E){case t.cc.SPACE:case t.cc.TAB:this.state=t.State.OP_MINUS_ERR_SPC;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_MINUS_ERR_SPC:switch(E){case t.cc.SPACE:case t.cc.TAB:continue;default:this.state=t.State.MINUS_ERR_ARG,this.as=x}break;case t.State.MINUS_ERR_ARG:switch(E){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=_.subarray(this.as,x-this.drop),this.dispatcher.push({kind:t.Kind.ERR,data:b}),this.drop=0,this.as=x+1,this.state=t.State.OP_START;break}default:this.argBuf&&this.argBuf.write(Uint8Array.of(E))}break;case t.State.OP_P:switch(E){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(_.subarray(x))}break;case t.State.OP_PO:switch(E){case t.cc.N:case t.cc.n:this.state=t.State.OP_PON;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_PON:switch(E){case t.cc.G:case t.cc.g:this.state=t.State.OP_PONG;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_PONG:switch(E){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(E){case t.cc.N:case t.cc.n:this.state=t.State.OP_PIN;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_PIN:switch(E){case t.cc.G:case t.cc.g:this.state=t.State.OP_PING;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_PING:switch(E){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(E){case t.cc.N:case t.cc.n:this.state=t.State.OP_IN;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_IN:switch(E){case t.cc.F:case t.cc.f:this.state=t.State.OP_INF;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_INF:switch(E){case t.cc.O:case t.cc.o:this.state=t.State.OP_INFO;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_INFO:switch(E){case t.cc.SPACE:case t.cc.TAB:this.state=t.State.OP_INFO_SPC;break;default:throw this.fail(_.subarray(x))}break;case t.State.OP_INFO_SPC:switch(E){case t.cc.SPACE:case t.cc.TAB:continue;default:this.state=t.State.INFO_ARG,this.as=x}break;case t.State.INFO_ARG:switch(E){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=_.subarray(this.as,x-this.drop),this.dispatcher.push({kind:t.Kind.INFO,data:b}),this.drop=0,this.as=x+1,this.state=t.State.OP_START;break}default:this.argBuf&&this.argBuf.writeByte(E)}break;default:throw this.fail(_.subarray(x))}}(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(_.subarray(this.as,x-this.drop))),this.state===t.State.MSG_PAYLOAD&&!this.msgBuf&&(this.argBuf||this.cloneMsgArg(),this.msgBuf=new e.DenoBuffer(_.subarray(this.as)))}cloneMsgArg(){const _=this.ma.subject.length,x=this.ma.reply?this.ma.reply.length:0,E=new Uint8Array(_+x);E.set(this.ma.subject),this.ma.reply&&E.set(this.ma.reply,_),this.argBuf=new e.DenoBuffer(E),this.ma.subject=E.subarray(0,_),this.ma.reply&&(this.ma.reply=E.subarray(_))}processMsgArgs(_){if(this.hdr>=0)return this.processHeaderMsgArgs(_);const x=[];let E=-1;for(let b=0;b<_.length;b++)switch(_[b]){case t.cc.SPACE:case t.cc.TAB:case t.cc.CR:case t.cc.NL:E>=0&&(x.push(_.subarray(E,b)),E=-1);break;default:E<0&&(E=b)}switch(E>=0&&x.push(_.subarray(E)),x.length){case 3:this.ma.subject=x[0],this.ma.sid=this.protoParseInt(x[1]),this.ma.reply=void 0,this.ma.size=this.protoParseInt(x[2]);break;case 4:this.ma.subject=x[0],this.ma.sid=this.protoParseInt(x[1]),this.ma.reply=x[2],this.ma.size=this.protoParseInt(x[3]);break;default:throw this.fail(_,"processMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(_,"processMsgArgs Bad or Missing Sid Error");if(this.ma.size<0)throw this.fail(_,"processMsgArgs Bad or Missing Size Error")}fail(_,x=""){return x?x=`${x} [${this.state}]`:x=`parse error [${this.state}]`,new Error(`${x}: ${r.TD.decode(_)}`)}processHeaderMsgArgs(_){const x=[];let E=-1;for(let b=0;b<_.length;b++)switch(_[b]){case t.cc.SPACE:case t.cc.TAB:case t.cc.CR:case t.cc.NL:E>=0&&(x.push(_.subarray(E,b)),E=-1);break;default:E<0&&(E=b)}switch(E>=0&&x.push(_.subarray(E)),x.length){case 4:this.ma.subject=x[0],this.ma.sid=this.protoParseInt(x[1]),this.ma.reply=void 0,this.ma.hdr=this.protoParseInt(x[2]),this.ma.size=this.protoParseInt(x[3]);break;case 5:this.ma.subject=x[0],this.ma.sid=this.protoParseInt(x[1]),this.ma.reply=x[2],this.ma.hdr=this.protoParseInt(x[3]),this.ma.size=this.protoParseInt(x[4]);break;default:throw this.fail(_,"processHeaderMsgArgs Parse Error")}if(this.ma.sid<0)throw this.fail(_,"processHeaderMsgArgs Bad or Missing Sid Error");if(this.ma.hdr<0||this.ma.hdr>this.ma.size)throw this.fail(_,"processHeaderMsgArgs Bad or Missing Header Size Error");if(this.ma.size<0)throw this.fail(_,"processHeaderMsgArgs Bad or Missing Size Error")}protoParseInt(_){if(_.length===0)return-1;let x=0;for(let E=0;E<_.length;E++){if(_[E]<a||_[E]>d)return-1;x=x*10+(_[E]-a)}return x}}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}}(pr);var Nt={},Qe={};Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.MsgHdrsImpl=void 0,Qe.canonicalMIMEHeaderKey=Er,Qe.headers=Gs;const xn=ke,Fe=Oe,xr=te;function Er(t){let x=!0;const E=new Array(t.length);for(let b=0;b<t.length;b++){let p=t.charCodeAt(b);if(p===58||p<33||p>126)throw xr.InvalidArgumentError.format("header",`'${t[b]}' is not a valid character in a header name`);x&&97<=p&&p<=122?p-=32:!x&&65<=p&&p<=90&&(p+=32),E[b]=p,x=p==45}return String.fromCharCode(...E)}function Gs(t=0,e=""){if(t===0&&e!==""||t>0&&e==="")throw xr.InvalidArgumentError.format("description","is required");return new lt(t,e)}const Sr="NATS/1.0";class lt{constructor(e=0,r=""){l(this,"_code");l(this,"headers");l(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,s]of this.headers){const i=e.values(r);if(s.length!==i.length)return!1;const a=[...s].sort(),d=[...i].sort();for(let m=0;m<a.length;m++)if(a[m]!==d[m])return!1}return!0}return!1}static decode(e){const r=new lt,i=xn.TD.decode(e).split(`\r
|
|
3
3
|
`),a=i[0];if(a!==Sr){let d=a.replace(Sr,"").trim();if(d.length>0){r._code=parseInt(d,10),isNaN(r._code)&&(r._code=0);const m=r._code.toString();d=d.replace(m,""),r._description=d.trim()}}return i.length>=1&&i.slice(1).map(d=>{if(d){const m=d.indexOf(":");if(m>-1){const S=d.slice(0,m),_=d.slice(m+1).trim();r.append(S,_)}}}),r}toString(){if(this.headers.size===0&&this._code===0)return"";let e=Sr;this._code>0&&this._description!==""&&(e+=` ${this._code} ${this._description}`);for(const[r,s]of this.headers)for(let i=0;i<s.length;i++)e=`${e}\r
|
|
4
4
|
${r}: ${s[i]}`;return`${e}\r
|
|
5
5
|
\r
|
|
6
|
-
`}encode(){return xn.TE.encode(this.toString())}static validHeaderValue(e){if(/[\r\n]/.test(e))throw xr.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=Fe.Match.Exact){const s=this.keys();switch(r){case Fe.Match.Exact:return s.filter(i=>i===e);case Fe.Match.CanonicalMIME:return e=Er(e),s.filter(i=>i===e);default:{const i=e.toLowerCase();return s.filter(a=>i===a.toLowerCase())}}}get(e,r=Fe.Match.Exact){const s=this.findKeys(e,r);if(s.length){const i=this.headers.get(s[0]);if(i)return Array.isArray(i)?i[0]:i}return""}last(e,r=Fe.Match.Exact){const s=this.findKeys(e,r);if(s.length){const i=this.headers.get(s[0]);if(i)return Array.isArray(i)?i[i.length-1]:i}return""}has(e,r=Fe.Match.Exact){return this.findKeys(e,r).length>0}set(e,r,s=Fe.Match.Exact){this.delete(e,s),this.append(e,r,s)}append(e,r,s=Fe.Match.Exact){const i=Er(e);s===Fe.Match.CanonicalMIME&&(e=i);const a=this.findKeys(e,s);e=a.length>0?a[0]:e;const d=lt.validHeaderValue(r);let m=this.headers.get(e);m||(m=[],this.headers.set(e,m)),m.push(d)}values(e,r=Fe.Match.Exact){const s=[];return this.findKeys(e,r).forEach(a=>{const d=this.headers.get(a);d&&s.push(...d)}),s}delete(e,r=Fe.Match.Exact){this.findKeys(e,r).forEach(i=>{this.headers.delete(i)})}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 lt;for(const s in e)r.headers.set(s,e[s]);return r}}Qe.MsgHdrsImpl=lt,Object.defineProperty(Ct,"__esModule",{value:!0}),Ct.MsgImpl=void 0;const Js=Qe,Wt=ke;class zs{constructor(e,r,s){l(this,"_headers");l(this,"_msg");l(this,"_rdata");l(this,"_reply");l(this,"_subject");l(this,"publisher");this._msg=e,this._rdata=r,this.publisher=s}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=Js.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 i;const e=this._msg.subject.length,r=((i=this._msg.reply)==null?void 0:i.length)||0,s=this._msg.size===-1?0:this._msg.size;return e+r+s}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(s,i){return(s==="start"||s==="stop")&&i!==""?new Date(Date.parse(i)):i}):null}}Ct.MsgImpl=zs;var Xt={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Features=t.Feature=void 0,t.parseSemVer=e,t.compare=r;function e(i=""){const a=i.match(/(\d+).(\d+).(\d+)/);if(a)return{major:parseInt(a[1]),minor:parseInt(a[2]),micro:parseInt(a[3])};throw new Error(`'${i}' is not a semver value`)}function r(i,a){return i.major<a.major?-1:i.major>a.major?1:i.minor<a.minor?-1:i.minor>a.minor?1:i.micro<a.micro?-1:i.micro>a.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 s{constructor(a){l(this,"server");l(this,"features");l(this,"disabled");this.features=new Map,this.disabled=[],this.update(a)}resetDisabled(){this.disabled.length=0,this.update(this.server)}disable(a){this.disabled.push(a),this.update(this.server)}isDisabled(a){return this.disabled.indexOf(a)!==-1}update(a){typeof a=="string"&&(a=e(a)),this.server=a,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(d=>{this.features.delete(d)})}set(a,d){this.features.set(a,{min:d,ok:r(this.server,e(d))>=0})}get(a){return this.features.get(a)||{min:"unknown",ok:!1}}supports(a){var d;return((d=this.get(a))==null?void 0:d.ok)||!1}require(a){return typeof a=="string"&&(a=e(a)),r(this.server,a)>=0}}t.Features=s})(Xt);var Nt={},De={},jt={},En={},pe={},Mt={},Tt={},It={};Object.defineProperty(It,"__esModule",{value:!0}),It.crc16=void 0;const Hs=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 Pr{static checksum(e){let r=0;for(let s=0;s<e.byteLength;s++){const i=e[s];r=r<<8&65535^Hs[(r>>8^i)&255]}return r}static validate(e,r){return Pr.checksum(e)==r}}It.crc16=Pr;var Rt={};Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.base32=void 0;const Ar="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";class Vs{static encode(e){let r=0,s=0;const i=new Uint8Array(e),a=new Uint8Array(e.byteLength*2);let d=0;for(let m=0;m<i.byteLength;m++)for(s=s<<8|i[m],r+=8;r>=5;){const S=s>>>r-5&31;a[d++]=Ar.charAt(S).charCodeAt(0),r-=5}if(r>0){const m=s<<5-r&31;a[d++]=Ar.charAt(m).charCodeAt(0)}return a.slice(0,d)}static decode(e){let r=0,s=0,i=0;const a=new Uint8Array(e),d=new Uint8Array(a.byteLength*5/8|0);for(let m=0;m<a.byteLength;m++){const S=String.fromCharCode(a[m]),_=Ar.indexOf(S);if(_===-1)throw new Error("Illegal Base32 character: "+a[m]);s=s<<5|_,r+=5,r>=8&&(d[i++]=s>>>r-8&255,r-=8)}return d.slice(0,i)}}Rt.base32=Vs;var Sn;function Zt(){if(Sn)return Tt;Sn=1,Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.Codec=void 0;const t=It,e=yt(),r=Rt;class s{static encode(a,d){if(!d||!(d instanceof Uint8Array))throw new e.NKeysError(e.NKeysErrorCode.SerializationError);if(!e.Prefixes.isValidPrefix(a))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);return s._encode(!1,a,d)}static encodeSeed(a,d){if(!d)throw new e.NKeysError(e.NKeysErrorCode.ApiError);if(!e.Prefixes.isValidPublicPrefix(a))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);if(d.byteLength!==32)throw new e.NKeysError(e.NKeysErrorCode.InvalidSeedLen);return s._encode(!0,a,d)}static decode(a,d){if(!e.Prefixes.isValidPrefix(a))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);const m=s._decode(d);if(m[0]!==a)throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);return m.slice(1)}static decodeSeed(a){const d=s._decode(a),m=s._decodePrefix(d);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:d.slice(2),prefix:m[1]}}static _encode(a,d,m){const S=a?2:1,_=m.byteLength,E=S+_+2,b=S+_,p=new Uint8Array(E);if(a){const U=s._encodePrefix(e.Prefix.Seed,d);p.set(U)}else p[0]=d;p.set(m,S);const R=t.crc16.checksum(p.slice(0,b));return new DataView(p.buffer).setUint16(b,R,!0),r.base32.encode(p)}static _decode(a){if(a.byteLength<4)throw new e.NKeysError(e.NKeysErrorCode.InvalidEncoding);let d;try{d=r.base32.decode(a)}catch(E){throw new e.NKeysError(e.NKeysErrorCode.InvalidEncoding,{cause:E})}const m=d.byteLength-2,_=new DataView(d.buffer).getUint16(m,!0),x=d.slice(0,m);if(!t.crc16.validate(x,_))throw new e.NKeysError(e.NKeysErrorCode.InvalidChecksum);return x}static _encodePrefix(a,d){const m=a|d>>5,S=(d&31)<<3;return new Uint8Array([m,S])}static _decodePrefix(a){const d=a[0]&248,m=(a[0]&7)<<5|(a[1]&248)>>3;return new Uint8Array([d,m])}}return Tt.Codec=s,Tt}var bt={};function Ys(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 Pn={exports:{}};const Ws=tt(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(t){(function(e){var r=function(o){var f,c=new Float64Array(16);if(o)for(f=0;f<o.length;f++)c[f]=o[f];return c},s=function(){throw new Error("no PRNG")},i=new Uint8Array(16),a=new Uint8Array(32);a[0]=9;var d=r(),m=r([1]),S=r([56129,1]),_=r([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),x=r([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),E=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]),p=r([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function R(o,f,c,n){o[f]=c>>24&255,o[f+1]=c>>16&255,o[f+2]=c>>8&255,o[f+3]=c&255,o[f+4]=n>>24&255,o[f+5]=n>>16&255,o[f+6]=n>>8&255,o[f+7]=n&255}function M(o,f,c,n,u){var y,g=0;for(y=0;y<u;y++)g|=o[f+y]^c[n+y];return(1&g-1>>>8)-1}function U(o,f,c,n){return M(o,f,c,n,16)}function se(o,f,c,n){return M(o,f,c,n,32)}function ge(o,f,c,n){for(var u=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,y=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,g=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,A=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,j=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,K=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,I=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,ce=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,$=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,J=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,z=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,X=c[16]&255|(c[17]&255)<<8|(c[18]&255)<<16|(c[19]&255)<<24,W=c[20]&255|(c[21]&255)<<8|(c[22]&255)<<16|(c[23]&255)<<24,H=c[24]&255|(c[25]&255)<<8|(c[26]&255)<<16|(c[27]&255)<<24,Y=c[28]&255|(c[29]&255)<<8|(c[30]&255)<<16|(c[31]&255)<<24,V=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,q=u,D=y,k=g,F=A,B=j,T=K,v=I,w=ce,C=$,P=J,O=z,N=X,G=W,Z=H,ee=Y,Q=V,h,ne=0;ne<20;ne+=2)h=q+G|0,B^=h<<7|h>>>25,h=B+q|0,C^=h<<9|h>>>23,h=C+B|0,G^=h<<13|h>>>19,h=G+C|0,q^=h<<18|h>>>14,h=T+D|0,P^=h<<7|h>>>25,h=P+T|0,Z^=h<<9|h>>>23,h=Z+P|0,D^=h<<13|h>>>19,h=D+Z|0,T^=h<<18|h>>>14,h=O+v|0,ee^=h<<7|h>>>25,h=ee+O|0,k^=h<<9|h>>>23,h=k+ee|0,v^=h<<13|h>>>19,h=v+k|0,O^=h<<18|h>>>14,h=Q+N|0,F^=h<<7|h>>>25,h=F+Q|0,w^=h<<9|h>>>23,h=w+F|0,N^=h<<13|h>>>19,h=N+w|0,Q^=h<<18|h>>>14,h=q+F|0,D^=h<<7|h>>>25,h=D+q|0,k^=h<<9|h>>>23,h=k+D|0,F^=h<<13|h>>>19,h=F+k|0,q^=h<<18|h>>>14,h=T+B|0,v^=h<<7|h>>>25,h=v+T|0,w^=h<<9|h>>>23,h=w+v|0,B^=h<<13|h>>>19,h=B+w|0,T^=h<<18|h>>>14,h=O+P|0,N^=h<<7|h>>>25,h=N+O|0,C^=h<<9|h>>>23,h=C+N|0,P^=h<<13|h>>>19,h=P+C|0,O^=h<<18|h>>>14,h=Q+ee|0,G^=h<<7|h>>>25,h=G+Q|0,Z^=h<<9|h>>>23,h=Z+G|0,ee^=h<<13|h>>>19,h=ee+Z|0,Q^=h<<18|h>>>14;q=q+u|0,D=D+y|0,k=k+g|0,F=F+A|0,B=B+j|0,T=T+K|0,v=v+I|0,w=w+ce|0,C=C+$|0,P=P+J|0,O=O+z|0,N=N+X|0,G=G+W|0,Z=Z+H|0,ee=ee+Y|0,Q=Q+V|0,o[0]=q>>>0&255,o[1]=q>>>8&255,o[2]=q>>>16&255,o[3]=q>>>24&255,o[4]=D>>>0&255,o[5]=D>>>8&255,o[6]=D>>>16&255,o[7]=D>>>24&255,o[8]=k>>>0&255,o[9]=k>>>8&255,o[10]=k>>>16&255,o[11]=k>>>24&255,o[12]=F>>>0&255,o[13]=F>>>8&255,o[14]=F>>>16&255,o[15]=F>>>24&255,o[16]=B>>>0&255,o[17]=B>>>8&255,o[18]=B>>>16&255,o[19]=B>>>24&255,o[20]=T>>>0&255,o[21]=T>>>8&255,o[22]=T>>>16&255,o[23]=T>>>24&255,o[24]=v>>>0&255,o[25]=v>>>8&255,o[26]=v>>>16&255,o[27]=v>>>24&255,o[28]=w>>>0&255,o[29]=w>>>8&255,o[30]=w>>>16&255,o[31]=w>>>24&255,o[32]=C>>>0&255,o[33]=C>>>8&255,o[34]=C>>>16&255,o[35]=C>>>24&255,o[36]=P>>>0&255,o[37]=P>>>8&255,o[38]=P>>>16&255,o[39]=P>>>24&255,o[40]=O>>>0&255,o[41]=O>>>8&255,o[42]=O>>>16&255,o[43]=O>>>24&255,o[44]=N>>>0&255,o[45]=N>>>8&255,o[46]=N>>>16&255,o[47]=N>>>24&255,o[48]=G>>>0&255,o[49]=G>>>8&255,o[50]=G>>>16&255,o[51]=G>>>24&255,o[52]=Z>>>0&255,o[53]=Z>>>8&255,o[54]=Z>>>16&255,o[55]=Z>>>24&255,o[56]=ee>>>0&255,o[57]=ee>>>8&255,o[58]=ee>>>16&255,o[59]=ee>>>24&255,o[60]=Q>>>0&255,o[61]=Q>>>8&255,o[62]=Q>>>16&255,o[63]=Q>>>24&255}function $e(o,f,c,n){for(var u=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,y=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,g=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,A=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,j=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,K=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,I=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,ce=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,$=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,J=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,z=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,X=c[16]&255|(c[17]&255)<<8|(c[18]&255)<<16|(c[19]&255)<<24,W=c[20]&255|(c[21]&255)<<8|(c[22]&255)<<16|(c[23]&255)<<24,H=c[24]&255|(c[25]&255)<<8|(c[26]&255)<<16|(c[27]&255)<<24,Y=c[28]&255|(c[29]&255)<<8|(c[30]&255)<<16|(c[31]&255)<<24,V=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,q=u,D=y,k=g,F=A,B=j,T=K,v=I,w=ce,C=$,P=J,O=z,N=X,G=W,Z=H,ee=Y,Q=V,h,ne=0;ne<20;ne+=2)h=q+G|0,B^=h<<7|h>>>25,h=B+q|0,C^=h<<9|h>>>23,h=C+B|0,G^=h<<13|h>>>19,h=G+C|0,q^=h<<18|h>>>14,h=T+D|0,P^=h<<7|h>>>25,h=P+T|0,Z^=h<<9|h>>>23,h=Z+P|0,D^=h<<13|h>>>19,h=D+Z|0,T^=h<<18|h>>>14,h=O+v|0,ee^=h<<7|h>>>25,h=ee+O|0,k^=h<<9|h>>>23,h=k+ee|0,v^=h<<13|h>>>19,h=v+k|0,O^=h<<18|h>>>14,h=Q+N|0,F^=h<<7|h>>>25,h=F+Q|0,w^=h<<9|h>>>23,h=w+F|0,N^=h<<13|h>>>19,h=N+w|0,Q^=h<<18|h>>>14,h=q+F|0,D^=h<<7|h>>>25,h=D+q|0,k^=h<<9|h>>>23,h=k+D|0,F^=h<<13|h>>>19,h=F+k|0,q^=h<<18|h>>>14,h=T+B|0,v^=h<<7|h>>>25,h=v+T|0,w^=h<<9|h>>>23,h=w+v|0,B^=h<<13|h>>>19,h=B+w|0,T^=h<<18|h>>>14,h=O+P|0,N^=h<<7|h>>>25,h=N+O|0,C^=h<<9|h>>>23,h=C+N|0,P^=h<<13|h>>>19,h=P+C|0,O^=h<<18|h>>>14,h=Q+ee|0,G^=h<<7|h>>>25,h=G+Q|0,Z^=h<<9|h>>>23,h=Z+G|0,ee^=h<<13|h>>>19,h=ee+Z|0,Q^=h<<18|h>>>14;o[0]=q>>>0&255,o[1]=q>>>8&255,o[2]=q>>>16&255,o[3]=q>>>24&255,o[4]=T>>>0&255,o[5]=T>>>8&255,o[6]=T>>>16&255,o[7]=T>>>24&255,o[8]=O>>>0&255,o[9]=O>>>8&255,o[10]=O>>>16&255,o[11]=O>>>24&255,o[12]=Q>>>0&255,o[13]=Q>>>8&255,o[14]=Q>>>16&255,o[15]=Q>>>24&255,o[16]=v>>>0&255,o[17]=v>>>8&255,o[18]=v>>>16&255,o[19]=v>>>24&255,o[20]=w>>>0&255,o[21]=w>>>8&255,o[22]=w>>>16&255,o[23]=w>>>24&255,o[24]=C>>>0&255,o[25]=C>>>8&255,o[26]=C>>>16&255,o[27]=C>>>24&255,o[28]=P>>>0&255,o[29]=P>>>8&255,o[30]=P>>>16&255,o[31]=P>>>24&255}function L(o,f,c,n){ge(o,f,c,n)}function de(o,f,c,n){$e(o,f,c,n)}var le=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function ze(o,f,c,n,u,y,g){var A=new Uint8Array(16),j=new Uint8Array(64),K,I;for(I=0;I<16;I++)A[I]=0;for(I=0;I<8;I++)A[I]=y[I];for(;u>=64;){for(L(j,A,g,le),I=0;I<64;I++)o[f+I]=c[n+I]^j[I];for(K=1,I=8;I<16;I++)K=K+(A[I]&255)|0,A[I]=K&255,K>>>=8;u-=64,f+=64,n+=64}if(u>0)for(L(j,A,g,le),I=0;I<u;I++)o[f+I]=c[n+I]^j[I];return 0}function Lt(o,f,c,n,u){var y=new Uint8Array(16),g=new Uint8Array(64),A,j;for(j=0;j<16;j++)y[j]=0;for(j=0;j<8;j++)y[j]=n[j];for(;c>=64;){for(L(g,y,u,le),j=0;j<64;j++)o[f+j]=g[j];for(A=1,j=8;j<16;j++)A=A+(y[j]&255)|0,y[j]=A&255,A>>>=8;c-=64,f+=64}if(c>0)for(L(g,y,u,le),j=0;j<c;j++)o[f+j]=g[j];return 0}function mt(o,f,c,n,u){var y=new Uint8Array(32);de(y,n,u,le);for(var g=new Uint8Array(8),A=0;A<8;A++)g[A]=n[A+16];return Lt(o,f,c,g,y)}function _t(o,f,c,n,u,y,g){var A=new Uint8Array(32);de(A,y,g,le);for(var j=new Uint8Array(8),K=0;K<8;K++)j[K]=y[K+16];return ze(o,f,c,n,u,j,A)}var vt=function(o){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 f,c,n,u,y,g,A,j;f=o[0]&255|(o[1]&255)<<8,this.r[0]=f&8191,c=o[2]&255|(o[3]&255)<<8,this.r[1]=(f>>>13|c<<3)&8191,n=o[4]&255|(o[5]&255)<<8,this.r[2]=(c>>>10|n<<6)&7939,u=o[6]&255|(o[7]&255)<<8,this.r[3]=(n>>>7|u<<9)&8191,y=o[8]&255|(o[9]&255)<<8,this.r[4]=(u>>>4|y<<12)&255,this.r[5]=y>>>1&8190,g=o[10]&255|(o[11]&255)<<8,this.r[6]=(y>>>14|g<<2)&8191,A=o[12]&255|(o[13]&255)<<8,this.r[7]=(g>>>11|A<<5)&8065,j=o[14]&255|(o[15]&255)<<8,this.r[8]=(A>>>8|j<<8)&8191,this.r[9]=j>>>5&127,this.pad[0]=o[16]&255|(o[17]&255)<<8,this.pad[1]=o[18]&255|(o[19]&255)<<8,this.pad[2]=o[20]&255|(o[21]&255)<<8,this.pad[3]=o[22]&255|(o[23]&255)<<8,this.pad[4]=o[24]&255|(o[25]&255)<<8,this.pad[5]=o[26]&255|(o[27]&255)<<8,this.pad[6]=o[28]&255|(o[29]&255)<<8,this.pad[7]=o[30]&255|(o[31]&255)<<8};vt.prototype.blocks=function(o,f,c){for(var n=this.fin?0:2048,u,y,g,A,j,K,I,ce,$,J,z,X,W,H,Y,V,q,D,k,F=this.h[0],B=this.h[1],T=this.h[2],v=this.h[3],w=this.h[4],C=this.h[5],P=this.h[6],O=this.h[7],N=this.h[8],G=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];c>=16;)u=o[f+0]&255|(o[f+1]&255)<<8,F+=u&8191,y=o[f+2]&255|(o[f+3]&255)<<8,B+=(u>>>13|y<<3)&8191,g=o[f+4]&255|(o[f+5]&255)<<8,T+=(y>>>10|g<<6)&8191,A=o[f+6]&255|(o[f+7]&255)<<8,v+=(g>>>7|A<<9)&8191,j=o[f+8]&255|(o[f+9]&255)<<8,w+=(A>>>4|j<<12)&8191,C+=j>>>1&8191,K=o[f+10]&255|(o[f+11]&255)<<8,P+=(j>>>14|K<<2)&8191,I=o[f+12]&255|(o[f+13]&255)<<8,O+=(K>>>11|I<<5)&8191,ce=o[f+14]&255|(o[f+15]&255)<<8,N+=(I>>>8|ce<<8)&8191,G+=ce>>>5|n,$=0,J=$,J+=F*Z,J+=B*(5*ae),J+=T*(5*oe),J+=v*(5*re),J+=w*(5*ue),$=J>>>13,J&=8191,J+=C*(5*fe),J+=P*(5*ne),J+=O*(5*h),J+=N*(5*Q),J+=G*(5*ee),$+=J>>>13,J&=8191,z=$,z+=F*ee,z+=B*Z,z+=T*(5*ae),z+=v*(5*oe),z+=w*(5*re),$=z>>>13,z&=8191,z+=C*(5*ue),z+=P*(5*fe),z+=O*(5*ne),z+=N*(5*h),z+=G*(5*Q),$+=z>>>13,z&=8191,X=$,X+=F*Q,X+=B*ee,X+=T*Z,X+=v*(5*ae),X+=w*(5*oe),$=X>>>13,X&=8191,X+=C*(5*re),X+=P*(5*ue),X+=O*(5*fe),X+=N*(5*ne),X+=G*(5*h),$+=X>>>13,X&=8191,W=$,W+=F*h,W+=B*Q,W+=T*ee,W+=v*Z,W+=w*(5*ae),$=W>>>13,W&=8191,W+=C*(5*oe),W+=P*(5*re),W+=O*(5*ue),W+=N*(5*fe),W+=G*(5*ne),$+=W>>>13,W&=8191,H=$,H+=F*ne,H+=B*h,H+=T*Q,H+=v*ee,H+=w*Z,$=H>>>13,H&=8191,H+=C*(5*ae),H+=P*(5*oe),H+=O*(5*re),H+=N*(5*ue),H+=G*(5*fe),$+=H>>>13,H&=8191,Y=$,Y+=F*fe,Y+=B*ne,Y+=T*h,Y+=v*Q,Y+=w*ee,$=Y>>>13,Y&=8191,Y+=C*Z,Y+=P*(5*ae),Y+=O*(5*oe),Y+=N*(5*re),Y+=G*(5*ue),$+=Y>>>13,Y&=8191,V=$,V+=F*ue,V+=B*fe,V+=T*ne,V+=v*h,V+=w*Q,$=V>>>13,V&=8191,V+=C*ee,V+=P*Z,V+=O*(5*ae),V+=N*(5*oe),V+=G*(5*re),$+=V>>>13,V&=8191,q=$,q+=F*re,q+=B*ue,q+=T*fe,q+=v*ne,q+=w*h,$=q>>>13,q&=8191,q+=C*Q,q+=P*ee,q+=O*Z,q+=N*(5*ae),q+=G*(5*oe),$+=q>>>13,q&=8191,D=$,D+=F*oe,D+=B*re,D+=T*ue,D+=v*fe,D+=w*ne,$=D>>>13,D&=8191,D+=C*h,D+=P*Q,D+=O*ee,D+=N*Z,D+=G*(5*ae),$+=D>>>13,D&=8191,k=$,k+=F*ae,k+=B*oe,k+=T*re,k+=v*ue,k+=w*fe,$=k>>>13,k&=8191,k+=C*ne,k+=P*h,k+=O*Q,k+=N*ee,k+=G*Z,$+=k>>>13,k&=8191,$=($<<2)+$|0,$=$+J|0,J=$&8191,$=$>>>13,z+=$,F=J,B=z,T=X,v=W,w=H,C=Y,P=V,O=q,N=D,G=k,f+=16,c-=16;this.h[0]=F,this.h[1]=B,this.h[2]=T,this.h[3]=v,this.h[4]=w,this.h[5]=C,this.h[6]=P,this.h[7]=O,this.h[8]=N,this.h[9]=G},vt.prototype.finish=function(o,f){var c=new Uint16Array(10),n,u,y,g;if(this.leftover){for(g=this.leftover,this.buffer[g++]=1;g<16;g++)this.buffer[g]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,g=2;g<10;g++)this.h[g]+=n,n=this.h[g]>>>13,this.h[g]&=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,c[0]=this.h[0]+5,n=c[0]>>>13,c[0]&=8191,g=1;g<10;g++)c[g]=this.h[g]+n,n=c[g]>>>13,c[g]&=8191;for(c[9]-=8192,u=(n^1)-1,g=0;g<10;g++)c[g]&=u;for(u=~u,g=0;g<10;g++)this.h[g]=this.h[g]&u|c[g];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,g=1;g<8;g++)y=(this.h[g]+this.pad[g]|0)+(y>>>16)|0,this.h[g]=y&65535;o[f+0]=this.h[0]>>>0&255,o[f+1]=this.h[0]>>>8&255,o[f+2]=this.h[1]>>>0&255,o[f+3]=this.h[1]>>>8&255,o[f+4]=this.h[2]>>>0&255,o[f+5]=this.h[2]>>>8&255,o[f+6]=this.h[3]>>>0&255,o[f+7]=this.h[3]>>>8&255,o[f+8]=this.h[4]>>>0&255,o[f+9]=this.h[4]>>>8&255,o[f+10]=this.h[5]>>>0&255,o[f+11]=this.h[5]>>>8&255,o[f+12]=this.h[6]>>>0&255,o[f+13]=this.h[6]>>>8&255,o[f+14]=this.h[7]>>>0&255,o[f+15]=this.h[7]>>>8&255},vt.prototype.update=function(o,f,c){var n,u;if(this.leftover){for(u=16-this.leftover,u>c&&(u=c),n=0;n<u;n++)this.buffer[this.leftover+n]=o[f+n];if(c-=u,f+=u,this.leftover+=u,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(c>=16&&(u=c-c%16,this.blocks(o,f,u),f+=u,c-=u),c){for(n=0;n<c;n++)this.buffer[this.leftover+n]=o[f+n];this.leftover+=c}};function pt(o,f,c,n,u,y){var g=new vt(y);return g.update(c,n,u),g.finish(o,f),0}function $t(o,f,c,n,u,y){var g=new Uint8Array(16);return pt(g,0,c,n,u,y),U(o,f,g,0)}function Se(o,f,c,n,u){var y;if(c<32)return-1;for(_t(o,0,f,0,c,n,u),pt(o,16,o,32,c-32,o),y=0;y<16;y++)o[y]=0;return 0}function He(o,f,c,n,u){var y,g=new Uint8Array(32);if(c<32||(mt(g,0,32,n,u),$t(f,16,f,32,c-32,g)!==0))return-1;for(_t(o,0,f,0,c,n,u),y=0;y<32;y++)o[y]=0;return 0}function Pe(o,f){var c;for(c=0;c<16;c++)o[c]=f[c]|0}function Ie(o){var f,c,n=1;for(f=0;f<16;f++)c=o[f]+n+65535,n=Math.floor(c/65536),o[f]=c-n*65536;o[0]+=n-1+37*(n-1)}function Re(o,f,c){for(var n,u=~(c-1),y=0;y<16;y++)n=u&(o[y]^f[y]),o[y]^=n,f[y]^=n}function Ue(o,f){var c,n,u,y=r(),g=r();for(c=0;c<16;c++)g[c]=f[c];for(Ie(g),Ie(g),Ie(g),n=0;n<2;n++){for(y[0]=g[0]-65517,c=1;c<15;c++)y[c]=g[c]-65535-(y[c-1]>>16&1),y[c-1]&=65535;y[15]=g[15]-32767-(y[14]>>16&1),u=y[15]>>16&1,y[14]&=65535,Re(g,y,1-u)}for(c=0;c<16;c++)o[2*c]=g[c]&255,o[2*c+1]=g[c]>>8}function Yn(o,f){var c=new Uint8Array(32),n=new Uint8Array(32);return Ue(c,o),Ue(n,f),se(c,0,n,0)}function Wn(o){var f=new Uint8Array(32);return Ue(f,o),f[0]&1}function kr(o,f){var c;for(c=0;c<16;c++)o[c]=f[2*c]+(f[2*c+1]<<8);o[15]&=32767}function Be(o,f,c){for(var n=0;n<16;n++)o[n]=f[n]+c[n]}function Ke(o,f,c){for(var n=0;n<16;n++)o[n]=f[n]-c[n]}function ie(o,f,c){var n,u,y=0,g=0,A=0,j=0,K=0,I=0,ce=0,$=0,J=0,z=0,X=0,W=0,H=0,Y=0,V=0,q=0,D=0,k=0,F=0,B=0,T=0,v=0,w=0,C=0,P=0,O=0,N=0,G=0,Z=0,ee=0,Q=0,h=c[0],ne=c[1],fe=c[2],ue=c[3],re=c[4],oe=c[5],ae=c[6],we=c[7],be=c[8],me=c[9],_e=c[10],ve=c[11],Ee=c[12],Ce=c[13],Ne=c[14],je=c[15];n=f[0],y+=n*h,g+=n*ne,A+=n*fe,j+=n*ue,K+=n*re,I+=n*oe,ce+=n*ae,$+=n*we,J+=n*be,z+=n*me,X+=n*_e,W+=n*ve,H+=n*Ee,Y+=n*Ce,V+=n*Ne,q+=n*je,n=f[1],g+=n*h,A+=n*ne,j+=n*fe,K+=n*ue,I+=n*re,ce+=n*oe,$+=n*ae,J+=n*we,z+=n*be,X+=n*me,W+=n*_e,H+=n*ve,Y+=n*Ee,V+=n*Ce,q+=n*Ne,D+=n*je,n=f[2],A+=n*h,j+=n*ne,K+=n*fe,I+=n*ue,ce+=n*re,$+=n*oe,J+=n*ae,z+=n*we,X+=n*be,W+=n*me,H+=n*_e,Y+=n*ve,V+=n*Ee,q+=n*Ce,D+=n*Ne,k+=n*je,n=f[3],j+=n*h,K+=n*ne,I+=n*fe,ce+=n*ue,$+=n*re,J+=n*oe,z+=n*ae,X+=n*we,W+=n*be,H+=n*me,Y+=n*_e,V+=n*ve,q+=n*Ee,D+=n*Ce,k+=n*Ne,F+=n*je,n=f[4],K+=n*h,I+=n*ne,ce+=n*fe,$+=n*ue,J+=n*re,z+=n*oe,X+=n*ae,W+=n*we,H+=n*be,Y+=n*me,V+=n*_e,q+=n*ve,D+=n*Ee,k+=n*Ce,F+=n*Ne,B+=n*je,n=f[5],I+=n*h,ce+=n*ne,$+=n*fe,J+=n*ue,z+=n*re,X+=n*oe,W+=n*ae,H+=n*we,Y+=n*be,V+=n*me,q+=n*_e,D+=n*ve,k+=n*Ee,F+=n*Ce,B+=n*Ne,T+=n*je,n=f[6],ce+=n*h,$+=n*ne,J+=n*fe,z+=n*ue,X+=n*re,W+=n*oe,H+=n*ae,Y+=n*we,V+=n*be,q+=n*me,D+=n*_e,k+=n*ve,F+=n*Ee,B+=n*Ce,T+=n*Ne,v+=n*je,n=f[7],$+=n*h,J+=n*ne,z+=n*fe,X+=n*ue,W+=n*re,H+=n*oe,Y+=n*ae,V+=n*we,q+=n*be,D+=n*me,k+=n*_e,F+=n*ve,B+=n*Ee,T+=n*Ce,v+=n*Ne,w+=n*je,n=f[8],J+=n*h,z+=n*ne,X+=n*fe,W+=n*ue,H+=n*re,Y+=n*oe,V+=n*ae,q+=n*we,D+=n*be,k+=n*me,F+=n*_e,B+=n*ve,T+=n*Ee,v+=n*Ce,w+=n*Ne,C+=n*je,n=f[9],z+=n*h,X+=n*ne,W+=n*fe,H+=n*ue,Y+=n*re,V+=n*oe,q+=n*ae,D+=n*we,k+=n*be,F+=n*me,B+=n*_e,T+=n*ve,v+=n*Ee,w+=n*Ce,C+=n*Ne,P+=n*je,n=f[10],X+=n*h,W+=n*ne,H+=n*fe,Y+=n*ue,V+=n*re,q+=n*oe,D+=n*ae,k+=n*we,F+=n*be,B+=n*me,T+=n*_e,v+=n*ve,w+=n*Ee,C+=n*Ce,P+=n*Ne,O+=n*je,n=f[11],W+=n*h,H+=n*ne,Y+=n*fe,V+=n*ue,q+=n*re,D+=n*oe,k+=n*ae,F+=n*we,B+=n*be,T+=n*me,v+=n*_e,w+=n*ve,C+=n*Ee,P+=n*Ce,O+=n*Ne,N+=n*je,n=f[12],H+=n*h,Y+=n*ne,V+=n*fe,q+=n*ue,D+=n*re,k+=n*oe,F+=n*ae,B+=n*we,T+=n*be,v+=n*me,w+=n*_e,C+=n*ve,P+=n*Ee,O+=n*Ce,N+=n*Ne,G+=n*je,n=f[13],Y+=n*h,V+=n*ne,q+=n*fe,D+=n*ue,k+=n*re,F+=n*oe,B+=n*ae,T+=n*we,v+=n*be,w+=n*me,C+=n*_e,P+=n*ve,O+=n*Ee,N+=n*Ce,G+=n*Ne,Z+=n*je,n=f[14],V+=n*h,q+=n*ne,D+=n*fe,k+=n*ue,F+=n*re,B+=n*oe,T+=n*ae,v+=n*we,w+=n*be,C+=n*me,P+=n*_e,O+=n*ve,N+=n*Ee,G+=n*Ce,Z+=n*Ne,ee+=n*je,n=f[15],q+=n*h,D+=n*ne,k+=n*fe,F+=n*ue,B+=n*re,T+=n*oe,v+=n*ae,w+=n*we,C+=n*be,P+=n*me,O+=n*_e,N+=n*ve,G+=n*Ee,Z+=n*Ce,ee+=n*Ne,Q+=n*je,y+=38*D,g+=38*k,A+=38*F,j+=38*B,K+=38*T,I+=38*v,ce+=38*w,$+=38*C,J+=38*P,z+=38*O,X+=38*N,W+=38*G,H+=38*Z,Y+=38*ee,V+=38*Q,u=1,n=y+u+65535,u=Math.floor(n/65536),y=n-u*65536,n=g+u+65535,u=Math.floor(n/65536),g=n-u*65536,n=A+u+65535,u=Math.floor(n/65536),A=n-u*65536,n=j+u+65535,u=Math.floor(n/65536),j=n-u*65536,n=K+u+65535,u=Math.floor(n/65536),K=n-u*65536,n=I+u+65535,u=Math.floor(n/65536),I=n-u*65536,n=ce+u+65535,u=Math.floor(n/65536),ce=n-u*65536,n=$+u+65535,u=Math.floor(n/65536),$=n-u*65536,n=J+u+65535,u=Math.floor(n/65536),J=n-u*65536,n=z+u+65535,u=Math.floor(n/65536),z=n-u*65536,n=X+u+65535,u=Math.floor(n/65536),X=n-u*65536,n=W+u+65535,u=Math.floor(n/65536),W=n-u*65536,n=H+u+65535,u=Math.floor(n/65536),H=n-u*65536,n=Y+u+65535,u=Math.floor(n/65536),Y=n-u*65536,n=V+u+65535,u=Math.floor(n/65536),V=n-u*65536,n=q+u+65535,u=Math.floor(n/65536),q=n-u*65536,y+=u-1+37*(u-1),u=1,n=y+u+65535,u=Math.floor(n/65536),y=n-u*65536,n=g+u+65535,u=Math.floor(n/65536),g=n-u*65536,n=A+u+65535,u=Math.floor(n/65536),A=n-u*65536,n=j+u+65535,u=Math.floor(n/65536),j=n-u*65536,n=K+u+65535,u=Math.floor(n/65536),K=n-u*65536,n=I+u+65535,u=Math.floor(n/65536),I=n-u*65536,n=ce+u+65535,u=Math.floor(n/65536),ce=n-u*65536,n=$+u+65535,u=Math.floor(n/65536),$=n-u*65536,n=J+u+65535,u=Math.floor(n/65536),J=n-u*65536,n=z+u+65535,u=Math.floor(n/65536),z=n-u*65536,n=X+u+65535,u=Math.floor(n/65536),X=n-u*65536,n=W+u+65535,u=Math.floor(n/65536),W=n-u*65536,n=H+u+65535,u=Math.floor(n/65536),H=n-u*65536,n=Y+u+65535,u=Math.floor(n/65536),Y=n-u*65536,n=V+u+65535,u=Math.floor(n/65536),V=n-u*65536,n=q+u+65535,u=Math.floor(n/65536),q=n-u*65536,y+=u-1+37*(u-1),o[0]=y,o[1]=g,o[2]=A,o[3]=j,o[4]=K,o[5]=I,o[6]=ce,o[7]=$,o[8]=J,o[9]=z,o[10]=X,o[11]=W,o[12]=H,o[13]=Y,o[14]=V,o[15]=q}function qe(o,f){ie(o,f,f)}function Xn(o,f){var c=r(),n;for(n=0;n<16;n++)c[n]=f[n];for(n=253;n>=0;n--)qe(c,c),n!==2&&n!==4&&ie(c,c,f);for(n=0;n<16;n++)o[n]=c[n]}function Zn(o,f){var c=r(),n;for(n=0;n<16;n++)c[n]=f[n];for(n=250;n>=0;n--)qe(c,c),n!==1&&ie(c,c,f);for(n=0;n<16;n++)o[n]=c[n]}function sr(o,f,c){var n=new Uint8Array(32),u=new Float64Array(80),y,g,A=r(),j=r(),K=r(),I=r(),ce=r(),$=r();for(g=0;g<31;g++)n[g]=f[g];for(n[31]=f[31]&127|64,n[0]&=248,kr(u,c),g=0;g<16;g++)j[g]=u[g],I[g]=A[g]=K[g]=0;for(A[0]=I[0]=1,g=254;g>=0;--g)y=n[g>>>3]>>>(g&7)&1,Re(A,j,y),Re(K,I,y),Be(ce,A,K),Ke(A,A,K),Be(K,j,I),Ke(j,j,I),qe(I,ce),qe($,A),ie(A,K,A),ie(K,j,ce),Be(ce,A,K),Ke(A,A,K),qe(j,A),Ke(K,I,$),ie(A,K,S),Be(A,A,I),ie(K,K,A),ie(A,I,$),ie(I,j,u),qe(j,ce),Re(A,j,y),Re(K,I,y);for(g=0;g<16;g++)u[g+16]=A[g],u[g+32]=K[g],u[g+48]=j[g],u[g+64]=I[g];var J=u.subarray(32),z=u.subarray(16);return Xn(J,J),ie(z,z,J),Ue(o,z),0}function ir(o,f){return sr(o,f,a)}function Qn(o,f){return s(f,32),ir(o,f)}function or(o,f,c){var n=new Uint8Array(32);return sr(n,c,f),de(o,i,n,le)}var es=Se,zi=He;function Hi(o,f,c,n,u,y){var g=new Uint8Array(32);return or(g,u,y),es(o,f,c,n,g)}function Vi(o,f,c,n,u,y){var g=new Uint8Array(32);return or(g,u,y),zi(o,f,c,n,g)}var ts=[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 rs(o,f,c,n){for(var u=new Int32Array(16),y=new Int32Array(16),g,A,j,K,I,ce,$,J,z,X,W,H,Y,V,q,D,k,F,B,T,v,w,C,P,O,N,G=o[0],Z=o[1],ee=o[2],Q=o[3],h=o[4],ne=o[5],fe=o[6],ue=o[7],re=f[0],oe=f[1],ae=f[2],we=f[3],be=f[4],me=f[5],_e=f[6],ve=f[7],Ee=0;n>=128;){for(B=0;B<16;B++)T=8*B+Ee,u[B]=c[T+0]<<24|c[T+1]<<16|c[T+2]<<8|c[T+3],y[B]=c[T+4]<<24|c[T+5]<<16|c[T+6]<<8|c[T+7];for(B=0;B<80;B++)if(g=G,A=Z,j=ee,K=Q,I=h,ce=ne,$=fe,J=ue,z=re,X=oe,W=ae,H=we,Y=be,V=me,q=_e,D=ve,v=ue,w=ve,C=w&65535,P=w>>>16,O=v&65535,N=v>>>16,v=(h>>>14|be<<18)^(h>>>18|be<<14)^(be>>>9|h<<23),w=(be>>>14|h<<18)^(be>>>18|h<<14)^(h>>>9|be<<23),C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,v=h&ne^~h&fe,w=be&me^~be&_e,C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,v=ts[B*2],w=ts[B*2+1],C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,v=u[B%16],w=y[B%16],C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,P+=C>>>16,O+=P>>>16,N+=O>>>16,k=O&65535|N<<16,F=C&65535|P<<16,v=k,w=F,C=w&65535,P=w>>>16,O=v&65535,N=v>>>16,v=(G>>>28|re<<4)^(re>>>2|G<<30)^(re>>>7|G<<25),w=(re>>>28|G<<4)^(G>>>2|re<<30)^(G>>>7|re<<25),C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,v=G&Z^G&ee^Z&ee,w=re&oe^re&ae^oe&ae,C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,P+=C>>>16,O+=P>>>16,N+=O>>>16,J=O&65535|N<<16,D=C&65535|P<<16,v=K,w=H,C=w&65535,P=w>>>16,O=v&65535,N=v>>>16,v=k,w=F,C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,P+=C>>>16,O+=P>>>16,N+=O>>>16,K=O&65535|N<<16,H=C&65535|P<<16,Z=g,ee=A,Q=j,h=K,ne=I,fe=ce,ue=$,G=J,oe=z,ae=X,we=W,be=H,me=Y,_e=V,ve=q,re=D,B%16===15)for(T=0;T<16;T++)v=u[T],w=y[T],C=w&65535,P=w>>>16,O=v&65535,N=v>>>16,v=u[(T+9)%16],w=y[(T+9)%16],C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,k=u[(T+1)%16],F=y[(T+1)%16],v=(k>>>1|F<<31)^(k>>>8|F<<24)^k>>>7,w=(F>>>1|k<<31)^(F>>>8|k<<24)^(F>>>7|k<<25),C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,k=u[(T+14)%16],F=y[(T+14)%16],v=(k>>>19|F<<13)^(F>>>29|k<<3)^k>>>6,w=(F>>>19|k<<13)^(k>>>29|F<<3)^(F>>>6|k<<26),C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,P+=C>>>16,O+=P>>>16,N+=O>>>16,u[T]=O&65535|N<<16,y[T]=C&65535|P<<16;v=G,w=re,C=w&65535,P=w>>>16,O=v&65535,N=v>>>16,v=o[0],w=f[0],C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,P+=C>>>16,O+=P>>>16,N+=O>>>16,o[0]=G=O&65535|N<<16,f[0]=re=C&65535|P<<16,v=Z,w=oe,C=w&65535,P=w>>>16,O=v&65535,N=v>>>16,v=o[1],w=f[1],C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,P+=C>>>16,O+=P>>>16,N+=O>>>16,o[1]=Z=O&65535|N<<16,f[1]=oe=C&65535|P<<16,v=ee,w=ae,C=w&65535,P=w>>>16,O=v&65535,N=v>>>16,v=o[2],w=f[2],C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,P+=C>>>16,O+=P>>>16,N+=O>>>16,o[2]=ee=O&65535|N<<16,f[2]=ae=C&65535|P<<16,v=Q,w=we,C=w&65535,P=w>>>16,O=v&65535,N=v>>>16,v=o[3],w=f[3],C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,P+=C>>>16,O+=P>>>16,N+=O>>>16,o[3]=Q=O&65535|N<<16,f[3]=we=C&65535|P<<16,v=h,w=be,C=w&65535,P=w>>>16,O=v&65535,N=v>>>16,v=o[4],w=f[4],C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,P+=C>>>16,O+=P>>>16,N+=O>>>16,o[4]=h=O&65535|N<<16,f[4]=be=C&65535|P<<16,v=ne,w=me,C=w&65535,P=w>>>16,O=v&65535,N=v>>>16,v=o[5],w=f[5],C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,P+=C>>>16,O+=P>>>16,N+=O>>>16,o[5]=ne=O&65535|N<<16,f[5]=me=C&65535|P<<16,v=fe,w=_e,C=w&65535,P=w>>>16,O=v&65535,N=v>>>16,v=o[6],w=f[6],C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,P+=C>>>16,O+=P>>>16,N+=O>>>16,o[6]=fe=O&65535|N<<16,f[6]=_e=C&65535|P<<16,v=ue,w=ve,C=w&65535,P=w>>>16,O=v&65535,N=v>>>16,v=o[7],w=f[7],C+=w&65535,P+=w>>>16,O+=v&65535,N+=v>>>16,P+=C>>>16,O+=P>>>16,N+=O>>>16,o[7]=ue=O&65535|N<<16,f[7]=ve=C&65535|P<<16,Ee+=128,n-=128}return n}function at(o,f,c){var n=new Int32Array(8),u=new Int32Array(8),y=new Uint8Array(256),g,A=c;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,u[0]=4089235720,u[1]=2227873595,u[2]=4271175723,u[3]=1595750129,u[4]=2917565137,u[5]=725511199,u[6]=4215389547,u[7]=327033209,rs(n,u,f,c),c%=128,g=0;g<c;g++)y[g]=f[A-c+g];for(y[c]=128,c=256-128*(c<112?1:0),y[c-9]=0,R(y,c-8,A/536870912|0,A<<3),rs(n,u,y,c),g=0;g<8;g++)R(o,8*g,n[g],u[g]);return 0}function ar(o,f){var c=r(),n=r(),u=r(),y=r(),g=r(),A=r(),j=r(),K=r(),I=r();Ke(c,o[1],o[0]),Ke(I,f[1],f[0]),ie(c,c,I),Be(n,o[0],o[1]),Be(I,f[0],f[1]),ie(n,n,I),ie(u,o[3],f[3]),ie(u,u,x),ie(y,o[2],f[2]),Be(y,y,y),Ke(g,n,c),Ke(A,y,u),Be(j,y,u),Be(K,n,c),ie(o[0],g,A),ie(o[1],K,j),ie(o[2],j,A),ie(o[3],g,K)}function ns(o,f,c){var n;for(n=0;n<4;n++)Re(o[n],f[n],c)}function Ur(o,f){var c=r(),n=r(),u=r();Xn(u,f[2]),ie(c,f[0],u),ie(n,f[1],u),Ue(o,n),o[31]^=Wn(c)<<7}function Lr(o,f,c){var n,u;for(Pe(o[0],d),Pe(o[1],m),Pe(o[2],m),Pe(o[3],d),u=255;u>=0;--u)n=c[u/8|0]>>(u&7)&1,ns(o,f,n),ar(f,o),ar(o,o),ns(o,f,n)}function cr(o,f){var c=[r(),r(),r(),r()];Pe(c[0],E),Pe(c[1],b),Pe(c[2],m),ie(c[3],E,b),Lr(o,c,f)}function $r(o,f,c){var n=new Uint8Array(64),u=[r(),r(),r(),r()],y;for(c||s(f,32),at(n,f,32),n[0]&=248,n[31]&=127,n[31]|=64,cr(u,n),Ur(o,u),y=0;y<32;y++)f[y+32]=o[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 qr(o,f){var c,n,u,y;for(n=63;n>=32;--n){for(c=0,u=n-32,y=n-12;u<y;++u)f[u]+=c-16*f[n]*fr[u-(n-32)],c=Math.floor((f[u]+128)/256),f[u]-=c*256;f[u]+=c,f[n]=0}for(c=0,u=0;u<32;u++)f[u]+=c-(f[31]>>4)*fr[u],c=f[u]>>8,f[u]&=255;for(u=0;u<32;u++)f[u]-=c*fr[u];for(n=0;n<32;n++)f[n+1]+=f[n]>>8,o[n]=f[n]&255}function Fr(o){var f=new Float64Array(64),c;for(c=0;c<64;c++)f[c]=o[c];for(c=0;c<64;c++)o[c]=0;qr(o,f)}function ss(o,f,c,n){var u=new Uint8Array(64),y=new Uint8Array(64),g=new Uint8Array(64),A,j,K=new Float64Array(64),I=[r(),r(),r(),r()];at(u,n,32),u[0]&=248,u[31]&=127,u[31]|=64;var ce=c+64;for(A=0;A<c;A++)o[64+A]=f[A];for(A=0;A<32;A++)o[32+A]=u[32+A];for(at(g,o.subarray(32),c+32),Fr(g),cr(I,g),Ur(o,I),A=32;A<64;A++)o[A]=n[A];for(at(y,o,c+64),Fr(y),A=0;A<64;A++)K[A]=0;for(A=0;A<32;A++)K[A]=g[A];for(A=0;A<32;A++)for(j=0;j<32;j++)K[A+j]+=y[A]*u[j];return qr(o.subarray(32),K),ce}function Yi(o,f){var c=r(),n=r(),u=r(),y=r(),g=r(),A=r(),j=r();return Pe(o[2],m),kr(o[1],f),qe(u,o[1]),ie(y,u,_),Ke(u,u,o[2]),Be(y,o[2],y),qe(g,y),qe(A,g),ie(j,A,g),ie(c,j,u),ie(c,c,y),Zn(c,c),ie(c,c,u),ie(c,c,y),ie(c,c,y),ie(o[0],c,y),qe(n,o[0]),ie(n,n,y),Yn(n,u)&&ie(o[0],o[0],p),qe(n,o[0]),ie(n,n,y),Yn(n,u)?-1:(Wn(o[0])===f[31]>>7&&Ke(o[0],d,o[0]),ie(o[3],o[0],o[1]),0)}function Br(o,f,c,n){var u,y=new Uint8Array(32),g=new Uint8Array(64),A=[r(),r(),r(),r()],j=[r(),r(),r(),r()];if(c<64||Yi(j,n))return-1;for(u=0;u<c;u++)o[u]=f[u];for(u=0;u<32;u++)o[u+32]=n[u];if(at(g,o,c),Fr(g),Lr(A,j,g),cr(j,f.subarray(32)),ar(A,j),Ur(y,A),c-=64,se(f,0,y,0)){for(u=0;u<c;u++)o[u]=0;return-1}for(u=0;u<c;u++)o[u]=f[u+64];return c}var Kr=32,ur=24,qt=32,wt=16,Ft=32,hr=32,Bt=32,Kt=32,Dr=32,is=ur,Wi=qt,Xi=wt,Ze=64,ct=32,xt=64,Gr=32,Jr=64;e.lowlevel={crypto_core_hsalsa20:de,crypto_stream_xor:_t,crypto_stream:mt,crypto_stream_salsa20_xor:ze,crypto_stream_salsa20:Lt,crypto_onetimeauth:pt,crypto_onetimeauth_verify:$t,crypto_verify_16:U,crypto_verify_32:se,crypto_secretbox:Se,crypto_secretbox_open:He,crypto_scalarmult:sr,crypto_scalarmult_base:ir,crypto_box_beforenm:or,crypto_box_afternm:es,crypto_box:Hi,crypto_box_open:Vi,crypto_box_keypair:Qn,crypto_hash:at,crypto_sign:ss,crypto_sign_keypair:$r,crypto_sign_open:Br,crypto_secretbox_KEYBYTES:Kr,crypto_secretbox_NONCEBYTES:ur,crypto_secretbox_ZEROBYTES:qt,crypto_secretbox_BOXZEROBYTES:wt,crypto_scalarmult_BYTES:Ft,crypto_scalarmult_SCALARBYTES:hr,crypto_box_PUBLICKEYBYTES:Bt,crypto_box_SECRETKEYBYTES:Kt,crypto_box_BEFORENMBYTES:Dr,crypto_box_NONCEBYTES:is,crypto_box_ZEROBYTES:Wi,crypto_box_BOXZEROBYTES:Xi,crypto_sign_BYTES:Ze,crypto_sign_PUBLICKEYBYTES:ct,crypto_sign_SECRETKEYBYTES:xt,crypto_sign_SEEDBYTES:Gr,crypto_hash_BYTES:Jr,gf:r,D:_,L:fr,pack25519:Ue,unpack25519:kr,M:ie,A:Be,S:qe,Z:Ke,pow2523:Zn,add:ar,set25519:Pe,modL:qr,scalarmult:Lr,scalarbase:cr};function os(o,f){if(o.length!==Kr)throw new Error("bad key size");if(f.length!==ur)throw new Error("bad nonce size")}function Zi(o,f){if(o.length!==Bt)throw new Error("bad public key size");if(f.length!==Kt)throw new Error("bad secret key size")}function Le(){for(var o=0;o<arguments.length;o++)if(!(arguments[o]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function as(o){for(var f=0;f<o.length;f++)o[f]=0}e.randomBytes=function(o){var f=new Uint8Array(o);return s(f,o),f},e.secretbox=function(o,f,c){Le(o,f,c),os(c,f);for(var n=new Uint8Array(qt+o.length),u=new Uint8Array(n.length),y=0;y<o.length;y++)n[y+qt]=o[y];return Se(u,n,n.length,f,c),u.subarray(wt)},e.secretbox.open=function(o,f,c){Le(o,f,c),os(c,f);for(var n=new Uint8Array(wt+o.length),u=new Uint8Array(n.length),y=0;y<o.length;y++)n[y+wt]=o[y];return n.length<32||He(u,n,n.length,f,c)!==0?null:u.subarray(qt)},e.secretbox.keyLength=Kr,e.secretbox.nonceLength=ur,e.secretbox.overheadLength=wt,e.scalarMult=function(o,f){if(Le(o,f),o.length!==hr)throw new Error("bad n size");if(f.length!==Ft)throw new Error("bad p size");var c=new Uint8Array(Ft);return sr(c,o,f),c},e.scalarMult.base=function(o){if(Le(o),o.length!==hr)throw new Error("bad n size");var f=new Uint8Array(Ft);return ir(f,o),f},e.scalarMult.scalarLength=hr,e.scalarMult.groupElementLength=Ft,e.box=function(o,f,c,n){var u=e.box.before(c,n);return e.secretbox(o,f,u)},e.box.before=function(o,f){Le(o,f),Zi(o,f);var c=new Uint8Array(Dr);return or(c,o,f),c},e.box.after=e.secretbox,e.box.open=function(o,f,c,n){var u=e.box.before(c,n);return e.secretbox.open(o,f,u)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var o=new Uint8Array(Bt),f=new Uint8Array(Kt);return Qn(o,f),{publicKey:o,secretKey:f}},e.box.keyPair.fromSecretKey=function(o){if(Le(o),o.length!==Kt)throw new Error("bad secret key size");var f=new Uint8Array(Bt);return ir(f,o),{publicKey:f,secretKey:new Uint8Array(o)}},e.box.publicKeyLength=Bt,e.box.secretKeyLength=Kt,e.box.sharedKeyLength=Dr,e.box.nonceLength=is,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(o,f){if(Le(o,f),f.length!==xt)throw new Error("bad secret key size");var c=new Uint8Array(Ze+o.length);return ss(c,o,o.length,f),c},e.sign.open=function(o,f){if(Le(o,f),f.length!==ct)throw new Error("bad public key size");var c=new Uint8Array(o.length),n=Br(c,o,o.length,f);if(n<0)return null;for(var u=new Uint8Array(n),y=0;y<u.length;y++)u[y]=c[y];return u},e.sign.detached=function(o,f){for(var c=e.sign(o,f),n=new Uint8Array(Ze),u=0;u<n.length;u++)n[u]=c[u];return n},e.sign.detached.verify=function(o,f,c){if(Le(o,f,c),f.length!==Ze)throw new Error("bad signature size");if(c.length!==ct)throw new Error("bad public key size");var n=new Uint8Array(Ze+o.length),u=new Uint8Array(Ze+o.length),y;for(y=0;y<Ze;y++)n[y]=f[y];for(y=0;y<o.length;y++)n[y+Ze]=o[y];return Br(u,n,n.length,c)>=0},e.sign.keyPair=function(){var o=new Uint8Array(ct),f=new Uint8Array(xt);return $r(o,f),{publicKey:o,secretKey:f}},e.sign.keyPair.fromSecretKey=function(o){if(Le(o),o.length!==xt)throw new Error("bad secret key size");for(var f=new Uint8Array(ct),c=0;c<f.length;c++)f[c]=o[32+c];return{publicKey:f,secretKey:new Uint8Array(o)}},e.sign.keyPair.fromSeed=function(o){if(Le(o),o.length!==Gr)throw new Error("bad seed size");for(var f=new Uint8Array(ct),c=new Uint8Array(xt),n=0;n<32;n++)c[n]=o[n];return $r(f,c,!0),{publicKey:f,secretKey:c}},e.sign.publicKeyLength=ct,e.sign.secretKeyLength=xt,e.sign.seedLength=Gr,e.sign.signatureLength=Ze,e.hash=function(o){Le(o);var f=new Uint8Array(Jr);return at(f,o,o.length),f},e.hash.hashLength=Jr,e.verify=function(o,f){return Le(o,f),o.length===0||f.length===0||o.length!==f.length?!1:M(o,0,f,0,o.length)===0},e.setPRNG=function(o){s=o},function(){var o=typeof self<"u"?self.crypto||self.msCrypto:null;if(o&&o.getRandomValues){var f=65536;e.setPRNG(function(c,n){var u,y=new Uint8Array(n);for(u=0;u<n;u+=f)o.getRandomValues(y.subarray(u,u+Math.min(n-u,f)));for(u=0;u<n;u++)c[u]=y[u];as(y)})}else typeof Ys<"u"&&(o=Ws,o&&o.randomBytes&&e.setPRNG(function(c,n){var u,y=o.randomBytes(n);for(u=0;u<n;u++)c[u]=y[u];as(y)}))}()})(t.exports?t.exports:self.nacl=self.nacl||{})})(Pn);var Xs=Pn.exports,Zs=he&&he.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bt,"__esModule",{value:!0});const Qs=Zs(Xs);bt.default=Qs.default;var An;function ei(){if(An)return Mt;An=1;var t=he&&he.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.KP=void 0;const e=Zt(),r=yt(),s=t(bt);class i{constructor(d){l(this,"seed");this.seed=d}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 d=e.Codec.decodeSeed(this.seed),m=s.default.sign.keyPair.fromSeed(this.getRawSeed()),S=e.Codec.encode(d.prefix,m.publicKey);return new TextDecoder().decode(S)}getPrivateKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const d=s.default.sign.keyPair.fromSeed(this.getRawSeed());return e.Codec.encode(r.Prefix.Private,d.secretKey)}sign(d){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const m=s.default.sign.keyPair.fromSeed(this.getRawSeed());return s.default.sign.detached(d,m.secretKey)}verify(d,m){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const S=s.default.sign.keyPair.fromSeed(this.getRawSeed());return s.default.sign.detached.verify(d,m,S.publicKey)}clear(){this.seed&&(this.seed.fill(0),this.seed=void 0)}seal(d,m,S){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}open(d,m){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}}return Mt.KP=i,Mt}var kt={},On;function ti(){if(On)return kt;On=1;var t=he&&he.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(kt,"__esModule",{value:!0}),kt.PublicKey=void 0;const e=Zt(),r=yt(),s=t(bt);class i{constructor(d){l(this,"publicKey");this.publicKey=d}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(d){throw this.publicKey?new r.NKeysError(r.NKeysErrorCode.CannotSign):new r.NKeysError(r.NKeysErrorCode.ClearedPair)}verify(d,m){if(!this.publicKey)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const S=e.Codec._decode(this.publicKey);return s.default.sign.detached.verify(d,m,S.slice(1))}clear(){this.publicKey&&(this.publicKey.fill(0),this.publicKey=void 0)}seal(d,m,S){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}open(d,m){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}}return kt.PublicKey=i,kt}var Or={},Cn;function ri(){return Cn||(Cn=1,function(t){var e=he&&he.__importDefault||function(E){return E&&E.__esModule?E:{default:E}};Object.defineProperty(t,"__esModule",{value:!0}),t.CurveKP=t.curveNonceLen=t.curveKeyLen=void 0;const r=yt(),s=e(bt),i=Zt(),a=yt(),d=Rt,m=It;t.curveKeyLen=32;const S=35;t.curveNonceLen=24;const _=[120,107,118,49];class x{constructor(b){l(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 i.Codec.encode(a.Prefix.Private,this.seed)}getPublicKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const b=s.default.scalarMult.base(this.seed),p=i.Codec.encode(a.Prefix.Curve,b);return new TextDecoder().decode(p)}getSeed(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return i.Codec.encodeSeed(a.Prefix.Curve,this.seed)}sign(){throw new r.NKeysError(r.NKeysErrorCode.InvalidCurveOperation)}verify(){throw new r.NKeysError(r.NKeysErrorCode.InvalidCurveOperation)}decodePubCurveKey(b){try{const p=d.base32.decode(new TextEncoder().encode(b));if(p.byteLength!==S)throw new r.NKeysError(r.NKeysErrorCode.InvalidCurveKey);if(p[0]!==a.Prefix.Curve)throw new r.NKeysError(r.NKeysErrorCode.InvalidPublicKey);const R=p.byteLength-2,U=new DataView(p.buffer).getUint16(R,!0),se=p.slice(0,R);if(!m.crc16.validate(se,U))throw new r.NKeysError(r.NKeysErrorCode.InvalidChecksum);return se.slice(1)}catch(p){throw new r.NKeysError(r.NKeysErrorCode.InvalidRecipient,{cause:p})}}seal(b,p,R){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);R||(R=s.default.randomBytes(t.curveNonceLen));const M=this.decodePubCurveKey(p),U=new Uint8Array(_.length+t.curveNonceLen);U.set(_,0),U.set(R,_.length);const se=s.default.box(b,R,M,this.seed),ge=new Uint8Array(U.length+se.length);return ge.set(U),ge.set(se,U.length),ge}open(b,p){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);if(b.length<=t.curveNonceLen+_.length)throw new r.NKeysError(r.NKeysErrorCode.InvalidEncrypted);for(let U=0;U<_.length;U++)if(b[U]!==_[U])throw new r.NKeysError(r.NKeysErrorCode.InvalidEncrypted);const R=this.decodePubCurveKey(p);b=b.slice(_.length);const M=b.slice(0,t.curveNonceLen);return b=b.slice(t.curveNonceLen),s.default.box.open(b,M,R,this.seed)}}t.CurveKP=x}(Or)),Or}var Nn;function yt(){if(Nn)return pe;Nn=1;var t=he&&he.__importDefault||function(L){return L&&L.__esModule?L:{default:L}};Object.defineProperty(pe,"__esModule",{value:!0}),pe.NKeysError=pe.NKeysErrorCode=pe.Prefixes=pe.Prefix=void 0,pe.createPair=d,pe.createOperator=m,pe.createAccount=S,pe.createUser=_,pe.createCluster=x,pe.createServer=E,pe.createCurve=b,pe.fromPublic=p,pe.fromCurveSeed=R,pe.fromSeed=M;const e=ei(),r=ti(),s=Zt(),i=ri(),a=t(bt);function d(L){const de=L===U.Curve?i.curveKeyLen:32,le=a.default.randomBytes(de),ze=s.Codec.encodeSeed(L,new Uint8Array(le));return L===U.Curve?new i.CurveKP(new Uint8Array(le)):new e.KP(ze)}function m(){return d(U.Operator)}function S(){return d(U.Account)}function _(){return d(U.User)}function x(){return d(U.Cluster)}function E(){return d(U.Server)}function b(){return d(U.Curve)}function p(L){const de=new TextEncoder().encode(L),le=s.Codec._decode(de),ze=se.parsePrefix(le[0]);if(se.isValidPublicPrefix(ze))return new r.PublicKey(de);throw new $e(ge.InvalidPublicKey)}function R(L){const de=s.Codec.decodeSeed(L);if(de.prefix!==U.Curve)throw new $e(ge.InvalidCurveSeed);if(de.buf.byteLength!==i.curveKeyLen)throw new $e(ge.InvalidSeedLen);return new i.CurveKP(de.buf)}function M(L){return s.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||(pe.Prefix=U={}));class se{static isValidPublicPrefix(de){return de==U.Server||de==U.Operator||de==U.Cluster||de==U.Account||de==U.User||de==U.Curve}static startsWithValidPrefix(de){const le=de[0];return le=="S"||le=="P"||le=="O"||le=="N"||le=="C"||le=="A"||le=="U"||le=="X"}static isValidPrefix(de){return this.parsePrefix(de)!==U.Unknown}static parsePrefix(de){switch(de){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}}}pe.Prefixes=se;var ge;(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"})(ge||(pe.NKeysErrorCode=ge={}));class $e extends Error{constructor(le,ze){super(le,ze);l(this,"code");this.code=le}}return pe.NKeysError=$e,pe}var Ut={};Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.encode=ni,Ut.decode=si,Ut.dump=ii;function ni(t){return btoa(String.fromCharCode(...t))}function si(t){const e=atob(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r}function ii(t,e){e&&console.log(e);const r=[];for(let s=0;s<t.byteLength;s++){s%8===0&&r.push(`
|
|
7
|
-
`);let i=t[s].toString(16);i.length===1&&(i="0"+i),r.push(i)}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 s=Qt;Object.defineProperty(t,"version",{enumerable:!0,get:function(){return s.version}})}(En);var oi=he&&he.__createBinding||(Object.create?function(t,e,r,s){s===void 0&&(s=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,i)}:function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]}),ai=he&&he.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),ci=he&&he.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var s=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(s[s.length]=i);return s},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var s=t(e),i=0;i<s.length;i++)s[i]!=="default"&&oi(r,e,s[i]);return ai(r,e),r}}();Object.defineProperty(jt,"__esModule",{value:!0}),jt.nkeys=void 0,jt.nkeys=ci(En),Object.defineProperty(De,"__esModule",{value:!0}),De.multiAuthenticator=fi,De.noAuthFn=ui,De.usernamePasswordAuthenticator=hi,De.tokenAuthenticator=di,De.nkeyAuthenticator=Mn,De.jwtAuthenticator=Tn,De.credsAuthenticator=li;const jn=jt,
|
|
6
|
+
`}encode(){return xn.TE.encode(this.toString())}static validHeaderValue(e){if(/[\r\n]/.test(e))throw xr.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=Fe.Match.Exact){const s=this.keys();switch(r){case Fe.Match.Exact:return s.filter(i=>i===e);case Fe.Match.CanonicalMIME:return e=Er(e),s.filter(i=>i===e);default:{const i=e.toLowerCase();return s.filter(a=>i===a.toLowerCase())}}}get(e,r=Fe.Match.Exact){const s=this.findKeys(e,r);if(s.length){const i=this.headers.get(s[0]);if(i)return Array.isArray(i)?i[0]:i}return""}last(e,r=Fe.Match.Exact){const s=this.findKeys(e,r);if(s.length){const i=this.headers.get(s[0]);if(i)return Array.isArray(i)?i[i.length-1]:i}return""}has(e,r=Fe.Match.Exact){return this.findKeys(e,r).length>0}set(e,r,s=Fe.Match.Exact){this.delete(e,s),this.append(e,r,s)}append(e,r,s=Fe.Match.Exact){const i=Er(e);s===Fe.Match.CanonicalMIME&&(e=i);const a=this.findKeys(e,s);e=a.length>0?a[0]:e;const d=lt.validHeaderValue(r);let m=this.headers.get(e);m||(m=[],this.headers.set(e,m)),m.push(d)}values(e,r=Fe.Match.Exact){const s=[];return this.findKeys(e,r).forEach(a=>{const d=this.headers.get(a);d&&s.push(...d)}),s}delete(e,r=Fe.Match.Exact){this.findKeys(e,r).forEach(i=>{this.headers.delete(i)})}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 lt;for(const s in e)r.headers.set(s,e[s]);return r}}Qe.MsgHdrsImpl=lt,Object.defineProperty(Nt,"__esModule",{value:!0}),Nt.MsgImpl=void 0;const Js=Qe,Wt=ke;class zs{constructor(e,r,s){l(this,"_headers");l(this,"_msg");l(this,"_rdata");l(this,"_reply");l(this,"_subject");l(this,"publisher");this._msg=e,this._rdata=r,this.publisher=s}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=Js.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 i;const e=this._msg.subject.length,r=((i=this._msg.reply)==null?void 0:i.length)||0,s=this._msg.size===-1?0:this._msg.size;return e+r+s}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(s,i){return(s==="start"||s==="stop")&&i!==""?new Date(Date.parse(i)):i}):null}}Nt.MsgImpl=zs;var Xt={};(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.Features=t.Feature=void 0,t.parseSemVer=e,t.compare=r;function e(i=""){const a=i.match(/(\d+).(\d+).(\d+)/);if(a)return{major:parseInt(a[1]),minor:parseInt(a[2]),micro:parseInt(a[3])};throw new Error(`'${i}' is not a semver value`)}function r(i,a){return i.major<a.major?-1:i.major>a.major?1:i.minor<a.minor?-1:i.minor>a.minor?1:i.micro<a.micro?-1:i.micro>a.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 s{constructor(a){l(this,"server");l(this,"features");l(this,"disabled");this.features=new Map,this.disabled=[],this.update(a)}resetDisabled(){this.disabled.length=0,this.update(this.server)}disable(a){this.disabled.push(a),this.update(this.server)}isDisabled(a){return this.disabled.indexOf(a)!==-1}update(a){typeof a=="string"&&(a=e(a)),this.server=a,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(d=>{this.features.delete(d)})}set(a,d){this.features.set(a,{min:d,ok:r(this.server,e(d))>=0})}get(a){return this.features.get(a)||{min:"unknown",ok:!1}}supports(a){var d;return((d=this.get(a))==null?void 0:d.ok)||!1}require(a){return typeof a=="string"&&(a=e(a)),r(this.server,a)>=0}}t.Features=s})(Xt);var Ct={},De={},jt={},En={},pe={},Mt={},Tt={},It={};Object.defineProperty(It,"__esModule",{value:!0}),It.crc16=void 0;const Hs=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 Pr{static checksum(e){let r=0;for(let s=0;s<e.byteLength;s++){const i=e[s];r=r<<8&65535^Hs[(r>>8^i)&255]}return r}static validate(e,r){return Pr.checksum(e)==r}}It.crc16=Pr;var Rt={};Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.base32=void 0;const Ar="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";class Vs{static encode(e){let r=0,s=0;const i=new Uint8Array(e),a=new Uint8Array(e.byteLength*2);let d=0;for(let m=0;m<i.byteLength;m++)for(s=s<<8|i[m],r+=8;r>=5;){const S=s>>>r-5&31;a[d++]=Ar.charAt(S).charCodeAt(0),r-=5}if(r>0){const m=s<<5-r&31;a[d++]=Ar.charAt(m).charCodeAt(0)}return a.slice(0,d)}static decode(e){let r=0,s=0,i=0;const a=new Uint8Array(e),d=new Uint8Array(a.byteLength*5/8|0);for(let m=0;m<a.byteLength;m++){const S=String.fromCharCode(a[m]),_=Ar.indexOf(S);if(_===-1)throw new Error("Illegal Base32 character: "+a[m]);s=s<<5|_,r+=5,r>=8&&(d[i++]=s>>>r-8&255,r-=8)}return d.slice(0,i)}}Rt.base32=Vs;var Sn;function Zt(){if(Sn)return Tt;Sn=1,Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.Codec=void 0;const t=It,e=yt(),r=Rt;class s{static encode(a,d){if(!d||!(d instanceof Uint8Array))throw new e.NKeysError(e.NKeysErrorCode.SerializationError);if(!e.Prefixes.isValidPrefix(a))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);return s._encode(!1,a,d)}static encodeSeed(a,d){if(!d)throw new e.NKeysError(e.NKeysErrorCode.ApiError);if(!e.Prefixes.isValidPublicPrefix(a))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);if(d.byteLength!==32)throw new e.NKeysError(e.NKeysErrorCode.InvalidSeedLen);return s._encode(!0,a,d)}static decode(a,d){if(!e.Prefixes.isValidPrefix(a))throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);const m=s._decode(d);if(m[0]!==a)throw new e.NKeysError(e.NKeysErrorCode.InvalidPrefixByte);return m.slice(1)}static decodeSeed(a){const d=s._decode(a),m=s._decodePrefix(d);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:d.slice(2),prefix:m[1]}}static _encode(a,d,m){const S=a?2:1,_=m.byteLength,E=S+_+2,b=S+_,p=new Uint8Array(E);if(a){const U=s._encodePrefix(e.Prefix.Seed,d);p.set(U)}else p[0]=d;p.set(m,S);const R=t.crc16.checksum(p.slice(0,b));return new DataView(p.buffer).setUint16(b,R,!0),r.base32.encode(p)}static _decode(a){if(a.byteLength<4)throw new e.NKeysError(e.NKeysErrorCode.InvalidEncoding);let d;try{d=r.base32.decode(a)}catch(E){throw new e.NKeysError(e.NKeysErrorCode.InvalidEncoding,{cause:E})}const m=d.byteLength-2,_=new DataView(d.buffer).getUint16(m,!0),x=d.slice(0,m);if(!t.crc16.validate(x,_))throw new e.NKeysError(e.NKeysErrorCode.InvalidChecksum);return x}static _encodePrefix(a,d){const m=a|d>>5,S=(d&31)<<3;return new Uint8Array([m,S])}static _decodePrefix(a){const d=a[0]&248,m=(a[0]&7)<<5|(a[1]&248)>>3;return new Uint8Array([d,m])}}return Tt.Codec=s,Tt}var bt={};function Ys(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 Pn={exports:{}};const Ws=tt(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));(function(t){(function(e){var r=function(o){var f,c=new Float64Array(16);if(o)for(f=0;f<o.length;f++)c[f]=o[f];return c},s=function(){throw new Error("no PRNG")},i=new Uint8Array(16),a=new Uint8Array(32);a[0]=9;var d=r(),m=r([1]),S=r([56129,1]),_=r([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),x=r([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),E=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]),p=r([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function R(o,f,c,n){o[f]=c>>24&255,o[f+1]=c>>16&255,o[f+2]=c>>8&255,o[f+3]=c&255,o[f+4]=n>>24&255,o[f+5]=n>>16&255,o[f+6]=n>>8&255,o[f+7]=n&255}function M(o,f,c,n,u){var y,g=0;for(y=0;y<u;y++)g|=o[f+y]^c[n+y];return(1&g-1>>>8)-1}function U(o,f,c,n){return M(o,f,c,n,16)}function se(o,f,c,n){return M(o,f,c,n,32)}function ge(o,f,c,n){for(var u=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,y=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,g=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,A=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,j=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,K=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,I=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,ce=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,$=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,J=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,z=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,X=c[16]&255|(c[17]&255)<<8|(c[18]&255)<<16|(c[19]&255)<<24,W=c[20]&255|(c[21]&255)<<8|(c[22]&255)<<16|(c[23]&255)<<24,H=c[24]&255|(c[25]&255)<<8|(c[26]&255)<<16|(c[27]&255)<<24,Y=c[28]&255|(c[29]&255)<<8|(c[30]&255)<<16|(c[31]&255)<<24,V=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,q=u,D=y,k=g,F=A,B=j,T=K,v=I,w=ce,N=$,P=J,O=z,C=X,G=W,Z=H,ee=Y,Q=V,h,ne=0;ne<20;ne+=2)h=q+G|0,B^=h<<7|h>>>25,h=B+q|0,N^=h<<9|h>>>23,h=N+B|0,G^=h<<13|h>>>19,h=G+N|0,q^=h<<18|h>>>14,h=T+D|0,P^=h<<7|h>>>25,h=P+T|0,Z^=h<<9|h>>>23,h=Z+P|0,D^=h<<13|h>>>19,h=D+Z|0,T^=h<<18|h>>>14,h=O+v|0,ee^=h<<7|h>>>25,h=ee+O|0,k^=h<<9|h>>>23,h=k+ee|0,v^=h<<13|h>>>19,h=v+k|0,O^=h<<18|h>>>14,h=Q+C|0,F^=h<<7|h>>>25,h=F+Q|0,w^=h<<9|h>>>23,h=w+F|0,C^=h<<13|h>>>19,h=C+w|0,Q^=h<<18|h>>>14,h=q+F|0,D^=h<<7|h>>>25,h=D+q|0,k^=h<<9|h>>>23,h=k+D|0,F^=h<<13|h>>>19,h=F+k|0,q^=h<<18|h>>>14,h=T+B|0,v^=h<<7|h>>>25,h=v+T|0,w^=h<<9|h>>>23,h=w+v|0,B^=h<<13|h>>>19,h=B+w|0,T^=h<<18|h>>>14,h=O+P|0,C^=h<<7|h>>>25,h=C+O|0,N^=h<<9|h>>>23,h=N+C|0,P^=h<<13|h>>>19,h=P+N|0,O^=h<<18|h>>>14,h=Q+ee|0,G^=h<<7|h>>>25,h=G+Q|0,Z^=h<<9|h>>>23,h=Z+G|0,ee^=h<<13|h>>>19,h=ee+Z|0,Q^=h<<18|h>>>14;q=q+u|0,D=D+y|0,k=k+g|0,F=F+A|0,B=B+j|0,T=T+K|0,v=v+I|0,w=w+ce|0,N=N+$|0,P=P+J|0,O=O+z|0,C=C+X|0,G=G+W|0,Z=Z+H|0,ee=ee+Y|0,Q=Q+V|0,o[0]=q>>>0&255,o[1]=q>>>8&255,o[2]=q>>>16&255,o[3]=q>>>24&255,o[4]=D>>>0&255,o[5]=D>>>8&255,o[6]=D>>>16&255,o[7]=D>>>24&255,o[8]=k>>>0&255,o[9]=k>>>8&255,o[10]=k>>>16&255,o[11]=k>>>24&255,o[12]=F>>>0&255,o[13]=F>>>8&255,o[14]=F>>>16&255,o[15]=F>>>24&255,o[16]=B>>>0&255,o[17]=B>>>8&255,o[18]=B>>>16&255,o[19]=B>>>24&255,o[20]=T>>>0&255,o[21]=T>>>8&255,o[22]=T>>>16&255,o[23]=T>>>24&255,o[24]=v>>>0&255,o[25]=v>>>8&255,o[26]=v>>>16&255,o[27]=v>>>24&255,o[28]=w>>>0&255,o[29]=w>>>8&255,o[30]=w>>>16&255,o[31]=w>>>24&255,o[32]=N>>>0&255,o[33]=N>>>8&255,o[34]=N>>>16&255,o[35]=N>>>24&255,o[36]=P>>>0&255,o[37]=P>>>8&255,o[38]=P>>>16&255,o[39]=P>>>24&255,o[40]=O>>>0&255,o[41]=O>>>8&255,o[42]=O>>>16&255,o[43]=O>>>24&255,o[44]=C>>>0&255,o[45]=C>>>8&255,o[46]=C>>>16&255,o[47]=C>>>24&255,o[48]=G>>>0&255,o[49]=G>>>8&255,o[50]=G>>>16&255,o[51]=G>>>24&255,o[52]=Z>>>0&255,o[53]=Z>>>8&255,o[54]=Z>>>16&255,o[55]=Z>>>24&255,o[56]=ee>>>0&255,o[57]=ee>>>8&255,o[58]=ee>>>16&255,o[59]=ee>>>24&255,o[60]=Q>>>0&255,o[61]=Q>>>8&255,o[62]=Q>>>16&255,o[63]=Q>>>24&255}function $e(o,f,c,n){for(var u=n[0]&255|(n[1]&255)<<8|(n[2]&255)<<16|(n[3]&255)<<24,y=c[0]&255|(c[1]&255)<<8|(c[2]&255)<<16|(c[3]&255)<<24,g=c[4]&255|(c[5]&255)<<8|(c[6]&255)<<16|(c[7]&255)<<24,A=c[8]&255|(c[9]&255)<<8|(c[10]&255)<<16|(c[11]&255)<<24,j=c[12]&255|(c[13]&255)<<8|(c[14]&255)<<16|(c[15]&255)<<24,K=n[4]&255|(n[5]&255)<<8|(n[6]&255)<<16|(n[7]&255)<<24,I=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,ce=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,$=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,J=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,z=n[8]&255|(n[9]&255)<<8|(n[10]&255)<<16|(n[11]&255)<<24,X=c[16]&255|(c[17]&255)<<8|(c[18]&255)<<16|(c[19]&255)<<24,W=c[20]&255|(c[21]&255)<<8|(c[22]&255)<<16|(c[23]&255)<<24,H=c[24]&255|(c[25]&255)<<8|(c[26]&255)<<16|(c[27]&255)<<24,Y=c[28]&255|(c[29]&255)<<8|(c[30]&255)<<16|(c[31]&255)<<24,V=n[12]&255|(n[13]&255)<<8|(n[14]&255)<<16|(n[15]&255)<<24,q=u,D=y,k=g,F=A,B=j,T=K,v=I,w=ce,N=$,P=J,O=z,C=X,G=W,Z=H,ee=Y,Q=V,h,ne=0;ne<20;ne+=2)h=q+G|0,B^=h<<7|h>>>25,h=B+q|0,N^=h<<9|h>>>23,h=N+B|0,G^=h<<13|h>>>19,h=G+N|0,q^=h<<18|h>>>14,h=T+D|0,P^=h<<7|h>>>25,h=P+T|0,Z^=h<<9|h>>>23,h=Z+P|0,D^=h<<13|h>>>19,h=D+Z|0,T^=h<<18|h>>>14,h=O+v|0,ee^=h<<7|h>>>25,h=ee+O|0,k^=h<<9|h>>>23,h=k+ee|0,v^=h<<13|h>>>19,h=v+k|0,O^=h<<18|h>>>14,h=Q+C|0,F^=h<<7|h>>>25,h=F+Q|0,w^=h<<9|h>>>23,h=w+F|0,C^=h<<13|h>>>19,h=C+w|0,Q^=h<<18|h>>>14,h=q+F|0,D^=h<<7|h>>>25,h=D+q|0,k^=h<<9|h>>>23,h=k+D|0,F^=h<<13|h>>>19,h=F+k|0,q^=h<<18|h>>>14,h=T+B|0,v^=h<<7|h>>>25,h=v+T|0,w^=h<<9|h>>>23,h=w+v|0,B^=h<<13|h>>>19,h=B+w|0,T^=h<<18|h>>>14,h=O+P|0,C^=h<<7|h>>>25,h=C+O|0,N^=h<<9|h>>>23,h=N+C|0,P^=h<<13|h>>>19,h=P+N|0,O^=h<<18|h>>>14,h=Q+ee|0,G^=h<<7|h>>>25,h=G+Q|0,Z^=h<<9|h>>>23,h=Z+G|0,ee^=h<<13|h>>>19,h=ee+Z|0,Q^=h<<18|h>>>14;o[0]=q>>>0&255,o[1]=q>>>8&255,o[2]=q>>>16&255,o[3]=q>>>24&255,o[4]=T>>>0&255,o[5]=T>>>8&255,o[6]=T>>>16&255,o[7]=T>>>24&255,o[8]=O>>>0&255,o[9]=O>>>8&255,o[10]=O>>>16&255,o[11]=O>>>24&255,o[12]=Q>>>0&255,o[13]=Q>>>8&255,o[14]=Q>>>16&255,o[15]=Q>>>24&255,o[16]=v>>>0&255,o[17]=v>>>8&255,o[18]=v>>>16&255,o[19]=v>>>24&255,o[20]=w>>>0&255,o[21]=w>>>8&255,o[22]=w>>>16&255,o[23]=w>>>24&255,o[24]=N>>>0&255,o[25]=N>>>8&255,o[26]=N>>>16&255,o[27]=N>>>24&255,o[28]=P>>>0&255,o[29]=P>>>8&255,o[30]=P>>>16&255,o[31]=P>>>24&255}function L(o,f,c,n){ge(o,f,c,n)}function de(o,f,c,n){$e(o,f,c,n)}var le=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function ze(o,f,c,n,u,y,g){var A=new Uint8Array(16),j=new Uint8Array(64),K,I;for(I=0;I<16;I++)A[I]=0;for(I=0;I<8;I++)A[I]=y[I];for(;u>=64;){for(L(j,A,g,le),I=0;I<64;I++)o[f+I]=c[n+I]^j[I];for(K=1,I=8;I<16;I++)K=K+(A[I]&255)|0,A[I]=K&255,K>>>=8;u-=64,f+=64,n+=64}if(u>0)for(L(j,A,g,le),I=0;I<u;I++)o[f+I]=c[n+I]^j[I];return 0}function Lt(o,f,c,n,u){var y=new Uint8Array(16),g=new Uint8Array(64),A,j;for(j=0;j<16;j++)y[j]=0;for(j=0;j<8;j++)y[j]=n[j];for(;c>=64;){for(L(g,y,u,le),j=0;j<64;j++)o[f+j]=g[j];for(A=1,j=8;j<16;j++)A=A+(y[j]&255)|0,y[j]=A&255,A>>>=8;c-=64,f+=64}if(c>0)for(L(g,y,u,le),j=0;j<c;j++)o[f+j]=g[j];return 0}function mt(o,f,c,n,u){var y=new Uint8Array(32);de(y,n,u,le);for(var g=new Uint8Array(8),A=0;A<8;A++)g[A]=n[A+16];return Lt(o,f,c,g,y)}function _t(o,f,c,n,u,y,g){var A=new Uint8Array(32);de(A,y,g,le);for(var j=new Uint8Array(8),K=0;K<8;K++)j[K]=y[K+16];return ze(o,f,c,n,u,j,A)}var vt=function(o){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 f,c,n,u,y,g,A,j;f=o[0]&255|(o[1]&255)<<8,this.r[0]=f&8191,c=o[2]&255|(o[3]&255)<<8,this.r[1]=(f>>>13|c<<3)&8191,n=o[4]&255|(o[5]&255)<<8,this.r[2]=(c>>>10|n<<6)&7939,u=o[6]&255|(o[7]&255)<<8,this.r[3]=(n>>>7|u<<9)&8191,y=o[8]&255|(o[9]&255)<<8,this.r[4]=(u>>>4|y<<12)&255,this.r[5]=y>>>1&8190,g=o[10]&255|(o[11]&255)<<8,this.r[6]=(y>>>14|g<<2)&8191,A=o[12]&255|(o[13]&255)<<8,this.r[7]=(g>>>11|A<<5)&8065,j=o[14]&255|(o[15]&255)<<8,this.r[8]=(A>>>8|j<<8)&8191,this.r[9]=j>>>5&127,this.pad[0]=o[16]&255|(o[17]&255)<<8,this.pad[1]=o[18]&255|(o[19]&255)<<8,this.pad[2]=o[20]&255|(o[21]&255)<<8,this.pad[3]=o[22]&255|(o[23]&255)<<8,this.pad[4]=o[24]&255|(o[25]&255)<<8,this.pad[5]=o[26]&255|(o[27]&255)<<8,this.pad[6]=o[28]&255|(o[29]&255)<<8,this.pad[7]=o[30]&255|(o[31]&255)<<8};vt.prototype.blocks=function(o,f,c){for(var n=this.fin?0:2048,u,y,g,A,j,K,I,ce,$,J,z,X,W,H,Y,V,q,D,k,F=this.h[0],B=this.h[1],T=this.h[2],v=this.h[3],w=this.h[4],N=this.h[5],P=this.h[6],O=this.h[7],C=this.h[8],G=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];c>=16;)u=o[f+0]&255|(o[f+1]&255)<<8,F+=u&8191,y=o[f+2]&255|(o[f+3]&255)<<8,B+=(u>>>13|y<<3)&8191,g=o[f+4]&255|(o[f+5]&255)<<8,T+=(y>>>10|g<<6)&8191,A=o[f+6]&255|(o[f+7]&255)<<8,v+=(g>>>7|A<<9)&8191,j=o[f+8]&255|(o[f+9]&255)<<8,w+=(A>>>4|j<<12)&8191,N+=j>>>1&8191,K=o[f+10]&255|(o[f+11]&255)<<8,P+=(j>>>14|K<<2)&8191,I=o[f+12]&255|(o[f+13]&255)<<8,O+=(K>>>11|I<<5)&8191,ce=o[f+14]&255|(o[f+15]&255)<<8,C+=(I>>>8|ce<<8)&8191,G+=ce>>>5|n,$=0,J=$,J+=F*Z,J+=B*(5*ae),J+=T*(5*oe),J+=v*(5*re),J+=w*(5*ue),$=J>>>13,J&=8191,J+=N*(5*fe),J+=P*(5*ne),J+=O*(5*h),J+=C*(5*Q),J+=G*(5*ee),$+=J>>>13,J&=8191,z=$,z+=F*ee,z+=B*Z,z+=T*(5*ae),z+=v*(5*oe),z+=w*(5*re),$=z>>>13,z&=8191,z+=N*(5*ue),z+=P*(5*fe),z+=O*(5*ne),z+=C*(5*h),z+=G*(5*Q),$+=z>>>13,z&=8191,X=$,X+=F*Q,X+=B*ee,X+=T*Z,X+=v*(5*ae),X+=w*(5*oe),$=X>>>13,X&=8191,X+=N*(5*re),X+=P*(5*ue),X+=O*(5*fe),X+=C*(5*ne),X+=G*(5*h),$+=X>>>13,X&=8191,W=$,W+=F*h,W+=B*Q,W+=T*ee,W+=v*Z,W+=w*(5*ae),$=W>>>13,W&=8191,W+=N*(5*oe),W+=P*(5*re),W+=O*(5*ue),W+=C*(5*fe),W+=G*(5*ne),$+=W>>>13,W&=8191,H=$,H+=F*ne,H+=B*h,H+=T*Q,H+=v*ee,H+=w*Z,$=H>>>13,H&=8191,H+=N*(5*ae),H+=P*(5*oe),H+=O*(5*re),H+=C*(5*ue),H+=G*(5*fe),$+=H>>>13,H&=8191,Y=$,Y+=F*fe,Y+=B*ne,Y+=T*h,Y+=v*Q,Y+=w*ee,$=Y>>>13,Y&=8191,Y+=N*Z,Y+=P*(5*ae),Y+=O*(5*oe),Y+=C*(5*re),Y+=G*(5*ue),$+=Y>>>13,Y&=8191,V=$,V+=F*ue,V+=B*fe,V+=T*ne,V+=v*h,V+=w*Q,$=V>>>13,V&=8191,V+=N*ee,V+=P*Z,V+=O*(5*ae),V+=C*(5*oe),V+=G*(5*re),$+=V>>>13,V&=8191,q=$,q+=F*re,q+=B*ue,q+=T*fe,q+=v*ne,q+=w*h,$=q>>>13,q&=8191,q+=N*Q,q+=P*ee,q+=O*Z,q+=C*(5*ae),q+=G*(5*oe),$+=q>>>13,q&=8191,D=$,D+=F*oe,D+=B*re,D+=T*ue,D+=v*fe,D+=w*ne,$=D>>>13,D&=8191,D+=N*h,D+=P*Q,D+=O*ee,D+=C*Z,D+=G*(5*ae),$+=D>>>13,D&=8191,k=$,k+=F*ae,k+=B*oe,k+=T*re,k+=v*ue,k+=w*fe,$=k>>>13,k&=8191,k+=N*ne,k+=P*h,k+=O*Q,k+=C*ee,k+=G*Z,$+=k>>>13,k&=8191,$=($<<2)+$|0,$=$+J|0,J=$&8191,$=$>>>13,z+=$,F=J,B=z,T=X,v=W,w=H,N=Y,P=V,O=q,C=D,G=k,f+=16,c-=16;this.h[0]=F,this.h[1]=B,this.h[2]=T,this.h[3]=v,this.h[4]=w,this.h[5]=N,this.h[6]=P,this.h[7]=O,this.h[8]=C,this.h[9]=G},vt.prototype.finish=function(o,f){var c=new Uint16Array(10),n,u,y,g;if(this.leftover){for(g=this.leftover,this.buffer[g++]=1;g<16;g++)this.buffer[g]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,g=2;g<10;g++)this.h[g]+=n,n=this.h[g]>>>13,this.h[g]&=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,c[0]=this.h[0]+5,n=c[0]>>>13,c[0]&=8191,g=1;g<10;g++)c[g]=this.h[g]+n,n=c[g]>>>13,c[g]&=8191;for(c[9]-=8192,u=(n^1)-1,g=0;g<10;g++)c[g]&=u;for(u=~u,g=0;g<10;g++)this.h[g]=this.h[g]&u|c[g];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,g=1;g<8;g++)y=(this.h[g]+this.pad[g]|0)+(y>>>16)|0,this.h[g]=y&65535;o[f+0]=this.h[0]>>>0&255,o[f+1]=this.h[0]>>>8&255,o[f+2]=this.h[1]>>>0&255,o[f+3]=this.h[1]>>>8&255,o[f+4]=this.h[2]>>>0&255,o[f+5]=this.h[2]>>>8&255,o[f+6]=this.h[3]>>>0&255,o[f+7]=this.h[3]>>>8&255,o[f+8]=this.h[4]>>>0&255,o[f+9]=this.h[4]>>>8&255,o[f+10]=this.h[5]>>>0&255,o[f+11]=this.h[5]>>>8&255,o[f+12]=this.h[6]>>>0&255,o[f+13]=this.h[6]>>>8&255,o[f+14]=this.h[7]>>>0&255,o[f+15]=this.h[7]>>>8&255},vt.prototype.update=function(o,f,c){var n,u;if(this.leftover){for(u=16-this.leftover,u>c&&(u=c),n=0;n<u;n++)this.buffer[this.leftover+n]=o[f+n];if(c-=u,f+=u,this.leftover+=u,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(c>=16&&(u=c-c%16,this.blocks(o,f,u),f+=u,c-=u),c){for(n=0;n<c;n++)this.buffer[this.leftover+n]=o[f+n];this.leftover+=c}};function pt(o,f,c,n,u,y){var g=new vt(y);return g.update(c,n,u),g.finish(o,f),0}function $t(o,f,c,n,u,y){var g=new Uint8Array(16);return pt(g,0,c,n,u,y),U(o,f,g,0)}function Se(o,f,c,n,u){var y;if(c<32)return-1;for(_t(o,0,f,0,c,n,u),pt(o,16,o,32,c-32,o),y=0;y<16;y++)o[y]=0;return 0}function He(o,f,c,n,u){var y,g=new Uint8Array(32);if(c<32||(mt(g,0,32,n,u),$t(f,16,f,32,c-32,g)!==0))return-1;for(_t(o,0,f,0,c,n,u),y=0;y<32;y++)o[y]=0;return 0}function Pe(o,f){var c;for(c=0;c<16;c++)o[c]=f[c]|0}function Ie(o){var f,c,n=1;for(f=0;f<16;f++)c=o[f]+n+65535,n=Math.floor(c/65536),o[f]=c-n*65536;o[0]+=n-1+37*(n-1)}function Re(o,f,c){for(var n,u=~(c-1),y=0;y<16;y++)n=u&(o[y]^f[y]),o[y]^=n,f[y]^=n}function Ue(o,f){var c,n,u,y=r(),g=r();for(c=0;c<16;c++)g[c]=f[c];for(Ie(g),Ie(g),Ie(g),n=0;n<2;n++){for(y[0]=g[0]-65517,c=1;c<15;c++)y[c]=g[c]-65535-(y[c-1]>>16&1),y[c-1]&=65535;y[15]=g[15]-32767-(y[14]>>16&1),u=y[15]>>16&1,y[14]&=65535,Re(g,y,1-u)}for(c=0;c<16;c++)o[2*c]=g[c]&255,o[2*c+1]=g[c]>>8}function Yn(o,f){var c=new Uint8Array(32),n=new Uint8Array(32);return Ue(c,o),Ue(n,f),se(c,0,n,0)}function Wn(o){var f=new Uint8Array(32);return Ue(f,o),f[0]&1}function kr(o,f){var c;for(c=0;c<16;c++)o[c]=f[2*c]+(f[2*c+1]<<8);o[15]&=32767}function Be(o,f,c){for(var n=0;n<16;n++)o[n]=f[n]+c[n]}function Ke(o,f,c){for(var n=0;n<16;n++)o[n]=f[n]-c[n]}function ie(o,f,c){var n,u,y=0,g=0,A=0,j=0,K=0,I=0,ce=0,$=0,J=0,z=0,X=0,W=0,H=0,Y=0,V=0,q=0,D=0,k=0,F=0,B=0,T=0,v=0,w=0,N=0,P=0,O=0,C=0,G=0,Z=0,ee=0,Q=0,h=c[0],ne=c[1],fe=c[2],ue=c[3],re=c[4],oe=c[5],ae=c[6],we=c[7],be=c[8],me=c[9],_e=c[10],ve=c[11],Ee=c[12],Ne=c[13],Ce=c[14],je=c[15];n=f[0],y+=n*h,g+=n*ne,A+=n*fe,j+=n*ue,K+=n*re,I+=n*oe,ce+=n*ae,$+=n*we,J+=n*be,z+=n*me,X+=n*_e,W+=n*ve,H+=n*Ee,Y+=n*Ne,V+=n*Ce,q+=n*je,n=f[1],g+=n*h,A+=n*ne,j+=n*fe,K+=n*ue,I+=n*re,ce+=n*oe,$+=n*ae,J+=n*we,z+=n*be,X+=n*me,W+=n*_e,H+=n*ve,Y+=n*Ee,V+=n*Ne,q+=n*Ce,D+=n*je,n=f[2],A+=n*h,j+=n*ne,K+=n*fe,I+=n*ue,ce+=n*re,$+=n*oe,J+=n*ae,z+=n*we,X+=n*be,W+=n*me,H+=n*_e,Y+=n*ve,V+=n*Ee,q+=n*Ne,D+=n*Ce,k+=n*je,n=f[3],j+=n*h,K+=n*ne,I+=n*fe,ce+=n*ue,$+=n*re,J+=n*oe,z+=n*ae,X+=n*we,W+=n*be,H+=n*me,Y+=n*_e,V+=n*ve,q+=n*Ee,D+=n*Ne,k+=n*Ce,F+=n*je,n=f[4],K+=n*h,I+=n*ne,ce+=n*fe,$+=n*ue,J+=n*re,z+=n*oe,X+=n*ae,W+=n*we,H+=n*be,Y+=n*me,V+=n*_e,q+=n*ve,D+=n*Ee,k+=n*Ne,F+=n*Ce,B+=n*je,n=f[5],I+=n*h,ce+=n*ne,$+=n*fe,J+=n*ue,z+=n*re,X+=n*oe,W+=n*ae,H+=n*we,Y+=n*be,V+=n*me,q+=n*_e,D+=n*ve,k+=n*Ee,F+=n*Ne,B+=n*Ce,T+=n*je,n=f[6],ce+=n*h,$+=n*ne,J+=n*fe,z+=n*ue,X+=n*re,W+=n*oe,H+=n*ae,Y+=n*we,V+=n*be,q+=n*me,D+=n*_e,k+=n*ve,F+=n*Ee,B+=n*Ne,T+=n*Ce,v+=n*je,n=f[7],$+=n*h,J+=n*ne,z+=n*fe,X+=n*ue,W+=n*re,H+=n*oe,Y+=n*ae,V+=n*we,q+=n*be,D+=n*me,k+=n*_e,F+=n*ve,B+=n*Ee,T+=n*Ne,v+=n*Ce,w+=n*je,n=f[8],J+=n*h,z+=n*ne,X+=n*fe,W+=n*ue,H+=n*re,Y+=n*oe,V+=n*ae,q+=n*we,D+=n*be,k+=n*me,F+=n*_e,B+=n*ve,T+=n*Ee,v+=n*Ne,w+=n*Ce,N+=n*je,n=f[9],z+=n*h,X+=n*ne,W+=n*fe,H+=n*ue,Y+=n*re,V+=n*oe,q+=n*ae,D+=n*we,k+=n*be,F+=n*me,B+=n*_e,T+=n*ve,v+=n*Ee,w+=n*Ne,N+=n*Ce,P+=n*je,n=f[10],X+=n*h,W+=n*ne,H+=n*fe,Y+=n*ue,V+=n*re,q+=n*oe,D+=n*ae,k+=n*we,F+=n*be,B+=n*me,T+=n*_e,v+=n*ve,w+=n*Ee,N+=n*Ne,P+=n*Ce,O+=n*je,n=f[11],W+=n*h,H+=n*ne,Y+=n*fe,V+=n*ue,q+=n*re,D+=n*oe,k+=n*ae,F+=n*we,B+=n*be,T+=n*me,v+=n*_e,w+=n*ve,N+=n*Ee,P+=n*Ne,O+=n*Ce,C+=n*je,n=f[12],H+=n*h,Y+=n*ne,V+=n*fe,q+=n*ue,D+=n*re,k+=n*oe,F+=n*ae,B+=n*we,T+=n*be,v+=n*me,w+=n*_e,N+=n*ve,P+=n*Ee,O+=n*Ne,C+=n*Ce,G+=n*je,n=f[13],Y+=n*h,V+=n*ne,q+=n*fe,D+=n*ue,k+=n*re,F+=n*oe,B+=n*ae,T+=n*we,v+=n*be,w+=n*me,N+=n*_e,P+=n*ve,O+=n*Ee,C+=n*Ne,G+=n*Ce,Z+=n*je,n=f[14],V+=n*h,q+=n*ne,D+=n*fe,k+=n*ue,F+=n*re,B+=n*oe,T+=n*ae,v+=n*we,w+=n*be,N+=n*me,P+=n*_e,O+=n*ve,C+=n*Ee,G+=n*Ne,Z+=n*Ce,ee+=n*je,n=f[15],q+=n*h,D+=n*ne,k+=n*fe,F+=n*ue,B+=n*re,T+=n*oe,v+=n*ae,w+=n*we,N+=n*be,P+=n*me,O+=n*_e,C+=n*ve,G+=n*Ee,Z+=n*Ne,ee+=n*Ce,Q+=n*je,y+=38*D,g+=38*k,A+=38*F,j+=38*B,K+=38*T,I+=38*v,ce+=38*w,$+=38*N,J+=38*P,z+=38*O,X+=38*C,W+=38*G,H+=38*Z,Y+=38*ee,V+=38*Q,u=1,n=y+u+65535,u=Math.floor(n/65536),y=n-u*65536,n=g+u+65535,u=Math.floor(n/65536),g=n-u*65536,n=A+u+65535,u=Math.floor(n/65536),A=n-u*65536,n=j+u+65535,u=Math.floor(n/65536),j=n-u*65536,n=K+u+65535,u=Math.floor(n/65536),K=n-u*65536,n=I+u+65535,u=Math.floor(n/65536),I=n-u*65536,n=ce+u+65535,u=Math.floor(n/65536),ce=n-u*65536,n=$+u+65535,u=Math.floor(n/65536),$=n-u*65536,n=J+u+65535,u=Math.floor(n/65536),J=n-u*65536,n=z+u+65535,u=Math.floor(n/65536),z=n-u*65536,n=X+u+65535,u=Math.floor(n/65536),X=n-u*65536,n=W+u+65535,u=Math.floor(n/65536),W=n-u*65536,n=H+u+65535,u=Math.floor(n/65536),H=n-u*65536,n=Y+u+65535,u=Math.floor(n/65536),Y=n-u*65536,n=V+u+65535,u=Math.floor(n/65536),V=n-u*65536,n=q+u+65535,u=Math.floor(n/65536),q=n-u*65536,y+=u-1+37*(u-1),u=1,n=y+u+65535,u=Math.floor(n/65536),y=n-u*65536,n=g+u+65535,u=Math.floor(n/65536),g=n-u*65536,n=A+u+65535,u=Math.floor(n/65536),A=n-u*65536,n=j+u+65535,u=Math.floor(n/65536),j=n-u*65536,n=K+u+65535,u=Math.floor(n/65536),K=n-u*65536,n=I+u+65535,u=Math.floor(n/65536),I=n-u*65536,n=ce+u+65535,u=Math.floor(n/65536),ce=n-u*65536,n=$+u+65535,u=Math.floor(n/65536),$=n-u*65536,n=J+u+65535,u=Math.floor(n/65536),J=n-u*65536,n=z+u+65535,u=Math.floor(n/65536),z=n-u*65536,n=X+u+65535,u=Math.floor(n/65536),X=n-u*65536,n=W+u+65535,u=Math.floor(n/65536),W=n-u*65536,n=H+u+65535,u=Math.floor(n/65536),H=n-u*65536,n=Y+u+65535,u=Math.floor(n/65536),Y=n-u*65536,n=V+u+65535,u=Math.floor(n/65536),V=n-u*65536,n=q+u+65535,u=Math.floor(n/65536),q=n-u*65536,y+=u-1+37*(u-1),o[0]=y,o[1]=g,o[2]=A,o[3]=j,o[4]=K,o[5]=I,o[6]=ce,o[7]=$,o[8]=J,o[9]=z,o[10]=X,o[11]=W,o[12]=H,o[13]=Y,o[14]=V,o[15]=q}function qe(o,f){ie(o,f,f)}function Xn(o,f){var c=r(),n;for(n=0;n<16;n++)c[n]=f[n];for(n=253;n>=0;n--)qe(c,c),n!==2&&n!==4&&ie(c,c,f);for(n=0;n<16;n++)o[n]=c[n]}function Zn(o,f){var c=r(),n;for(n=0;n<16;n++)c[n]=f[n];for(n=250;n>=0;n--)qe(c,c),n!==1&&ie(c,c,f);for(n=0;n<16;n++)o[n]=c[n]}function sr(o,f,c){var n=new Uint8Array(32),u=new Float64Array(80),y,g,A=r(),j=r(),K=r(),I=r(),ce=r(),$=r();for(g=0;g<31;g++)n[g]=f[g];for(n[31]=f[31]&127|64,n[0]&=248,kr(u,c),g=0;g<16;g++)j[g]=u[g],I[g]=A[g]=K[g]=0;for(A[0]=I[0]=1,g=254;g>=0;--g)y=n[g>>>3]>>>(g&7)&1,Re(A,j,y),Re(K,I,y),Be(ce,A,K),Ke(A,A,K),Be(K,j,I),Ke(j,j,I),qe(I,ce),qe($,A),ie(A,K,A),ie(K,j,ce),Be(ce,A,K),Ke(A,A,K),qe(j,A),Ke(K,I,$),ie(A,K,S),Be(A,A,I),ie(K,K,A),ie(A,I,$),ie(I,j,u),qe(j,ce),Re(A,j,y),Re(K,I,y);for(g=0;g<16;g++)u[g+16]=A[g],u[g+32]=K[g],u[g+48]=j[g],u[g+64]=I[g];var J=u.subarray(32),z=u.subarray(16);return Xn(J,J),ie(z,z,J),Ue(o,z),0}function ir(o,f){return sr(o,f,a)}function Qn(o,f){return s(f,32),ir(o,f)}function or(o,f,c){var n=new Uint8Array(32);return sr(n,c,f),de(o,i,n,le)}var es=Se,zi=He;function Hi(o,f,c,n,u,y){var g=new Uint8Array(32);return or(g,u,y),es(o,f,c,n,g)}function Vi(o,f,c,n,u,y){var g=new Uint8Array(32);return or(g,u,y),zi(o,f,c,n,g)}var ts=[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 rs(o,f,c,n){for(var u=new Int32Array(16),y=new Int32Array(16),g,A,j,K,I,ce,$,J,z,X,W,H,Y,V,q,D,k,F,B,T,v,w,N,P,O,C,G=o[0],Z=o[1],ee=o[2],Q=o[3],h=o[4],ne=o[5],fe=o[6],ue=o[7],re=f[0],oe=f[1],ae=f[2],we=f[3],be=f[4],me=f[5],_e=f[6],ve=f[7],Ee=0;n>=128;){for(B=0;B<16;B++)T=8*B+Ee,u[B]=c[T+0]<<24|c[T+1]<<16|c[T+2]<<8|c[T+3],y[B]=c[T+4]<<24|c[T+5]<<16|c[T+6]<<8|c[T+7];for(B=0;B<80;B++)if(g=G,A=Z,j=ee,K=Q,I=h,ce=ne,$=fe,J=ue,z=re,X=oe,W=ae,H=we,Y=be,V=me,q=_e,D=ve,v=ue,w=ve,N=w&65535,P=w>>>16,O=v&65535,C=v>>>16,v=(h>>>14|be<<18)^(h>>>18|be<<14)^(be>>>9|h<<23),w=(be>>>14|h<<18)^(be>>>18|h<<14)^(h>>>9|be<<23),N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,v=h&ne^~h&fe,w=be&me^~be&_e,N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,v=ts[B*2],w=ts[B*2+1],N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,v=u[B%16],w=y[B%16],N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,P+=N>>>16,O+=P>>>16,C+=O>>>16,k=O&65535|C<<16,F=N&65535|P<<16,v=k,w=F,N=w&65535,P=w>>>16,O=v&65535,C=v>>>16,v=(G>>>28|re<<4)^(re>>>2|G<<30)^(re>>>7|G<<25),w=(re>>>28|G<<4)^(G>>>2|re<<30)^(G>>>7|re<<25),N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,v=G&Z^G&ee^Z&ee,w=re&oe^re&ae^oe&ae,N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,P+=N>>>16,O+=P>>>16,C+=O>>>16,J=O&65535|C<<16,D=N&65535|P<<16,v=K,w=H,N=w&65535,P=w>>>16,O=v&65535,C=v>>>16,v=k,w=F,N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,P+=N>>>16,O+=P>>>16,C+=O>>>16,K=O&65535|C<<16,H=N&65535|P<<16,Z=g,ee=A,Q=j,h=K,ne=I,fe=ce,ue=$,G=J,oe=z,ae=X,we=W,be=H,me=Y,_e=V,ve=q,re=D,B%16===15)for(T=0;T<16;T++)v=u[T],w=y[T],N=w&65535,P=w>>>16,O=v&65535,C=v>>>16,v=u[(T+9)%16],w=y[(T+9)%16],N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,k=u[(T+1)%16],F=y[(T+1)%16],v=(k>>>1|F<<31)^(k>>>8|F<<24)^k>>>7,w=(F>>>1|k<<31)^(F>>>8|k<<24)^(F>>>7|k<<25),N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,k=u[(T+14)%16],F=y[(T+14)%16],v=(k>>>19|F<<13)^(F>>>29|k<<3)^k>>>6,w=(F>>>19|k<<13)^(k>>>29|F<<3)^(F>>>6|k<<26),N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,P+=N>>>16,O+=P>>>16,C+=O>>>16,u[T]=O&65535|C<<16,y[T]=N&65535|P<<16;v=G,w=re,N=w&65535,P=w>>>16,O=v&65535,C=v>>>16,v=o[0],w=f[0],N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,P+=N>>>16,O+=P>>>16,C+=O>>>16,o[0]=G=O&65535|C<<16,f[0]=re=N&65535|P<<16,v=Z,w=oe,N=w&65535,P=w>>>16,O=v&65535,C=v>>>16,v=o[1],w=f[1],N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,P+=N>>>16,O+=P>>>16,C+=O>>>16,o[1]=Z=O&65535|C<<16,f[1]=oe=N&65535|P<<16,v=ee,w=ae,N=w&65535,P=w>>>16,O=v&65535,C=v>>>16,v=o[2],w=f[2],N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,P+=N>>>16,O+=P>>>16,C+=O>>>16,o[2]=ee=O&65535|C<<16,f[2]=ae=N&65535|P<<16,v=Q,w=we,N=w&65535,P=w>>>16,O=v&65535,C=v>>>16,v=o[3],w=f[3],N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,P+=N>>>16,O+=P>>>16,C+=O>>>16,o[3]=Q=O&65535|C<<16,f[3]=we=N&65535|P<<16,v=h,w=be,N=w&65535,P=w>>>16,O=v&65535,C=v>>>16,v=o[4],w=f[4],N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,P+=N>>>16,O+=P>>>16,C+=O>>>16,o[4]=h=O&65535|C<<16,f[4]=be=N&65535|P<<16,v=ne,w=me,N=w&65535,P=w>>>16,O=v&65535,C=v>>>16,v=o[5],w=f[5],N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,P+=N>>>16,O+=P>>>16,C+=O>>>16,o[5]=ne=O&65535|C<<16,f[5]=me=N&65535|P<<16,v=fe,w=_e,N=w&65535,P=w>>>16,O=v&65535,C=v>>>16,v=o[6],w=f[6],N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,P+=N>>>16,O+=P>>>16,C+=O>>>16,o[6]=fe=O&65535|C<<16,f[6]=_e=N&65535|P<<16,v=ue,w=ve,N=w&65535,P=w>>>16,O=v&65535,C=v>>>16,v=o[7],w=f[7],N+=w&65535,P+=w>>>16,O+=v&65535,C+=v>>>16,P+=N>>>16,O+=P>>>16,C+=O>>>16,o[7]=ue=O&65535|C<<16,f[7]=ve=N&65535|P<<16,Ee+=128,n-=128}return n}function at(o,f,c){var n=new Int32Array(8),u=new Int32Array(8),y=new Uint8Array(256),g,A=c;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,u[0]=4089235720,u[1]=2227873595,u[2]=4271175723,u[3]=1595750129,u[4]=2917565137,u[5]=725511199,u[6]=4215389547,u[7]=327033209,rs(n,u,f,c),c%=128,g=0;g<c;g++)y[g]=f[A-c+g];for(y[c]=128,c=256-128*(c<112?1:0),y[c-9]=0,R(y,c-8,A/536870912|0,A<<3),rs(n,u,y,c),g=0;g<8;g++)R(o,8*g,n[g],u[g]);return 0}function ar(o,f){var c=r(),n=r(),u=r(),y=r(),g=r(),A=r(),j=r(),K=r(),I=r();Ke(c,o[1],o[0]),Ke(I,f[1],f[0]),ie(c,c,I),Be(n,o[0],o[1]),Be(I,f[0],f[1]),ie(n,n,I),ie(u,o[3],f[3]),ie(u,u,x),ie(y,o[2],f[2]),Be(y,y,y),Ke(g,n,c),Ke(A,y,u),Be(j,y,u),Be(K,n,c),ie(o[0],g,A),ie(o[1],K,j),ie(o[2],j,A),ie(o[3],g,K)}function ns(o,f,c){var n;for(n=0;n<4;n++)Re(o[n],f[n],c)}function Ur(o,f){var c=r(),n=r(),u=r();Xn(u,f[2]),ie(c,f[0],u),ie(n,f[1],u),Ue(o,n),o[31]^=Wn(c)<<7}function Lr(o,f,c){var n,u;for(Pe(o[0],d),Pe(o[1],m),Pe(o[2],m),Pe(o[3],d),u=255;u>=0;--u)n=c[u/8|0]>>(u&7)&1,ns(o,f,n),ar(f,o),ar(o,o),ns(o,f,n)}function cr(o,f){var c=[r(),r(),r(),r()];Pe(c[0],E),Pe(c[1],b),Pe(c[2],m),ie(c[3],E,b),Lr(o,c,f)}function $r(o,f,c){var n=new Uint8Array(64),u=[r(),r(),r(),r()],y;for(c||s(f,32),at(n,f,32),n[0]&=248,n[31]&=127,n[31]|=64,cr(u,n),Ur(o,u),y=0;y<32;y++)f[y+32]=o[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 qr(o,f){var c,n,u,y;for(n=63;n>=32;--n){for(c=0,u=n-32,y=n-12;u<y;++u)f[u]+=c-16*f[n]*fr[u-(n-32)],c=Math.floor((f[u]+128)/256),f[u]-=c*256;f[u]+=c,f[n]=0}for(c=0,u=0;u<32;u++)f[u]+=c-(f[31]>>4)*fr[u],c=f[u]>>8,f[u]&=255;for(u=0;u<32;u++)f[u]-=c*fr[u];for(n=0;n<32;n++)f[n+1]+=f[n]>>8,o[n]=f[n]&255}function Fr(o){var f=new Float64Array(64),c;for(c=0;c<64;c++)f[c]=o[c];for(c=0;c<64;c++)o[c]=0;qr(o,f)}function ss(o,f,c,n){var u=new Uint8Array(64),y=new Uint8Array(64),g=new Uint8Array(64),A,j,K=new Float64Array(64),I=[r(),r(),r(),r()];at(u,n,32),u[0]&=248,u[31]&=127,u[31]|=64;var ce=c+64;for(A=0;A<c;A++)o[64+A]=f[A];for(A=0;A<32;A++)o[32+A]=u[32+A];for(at(g,o.subarray(32),c+32),Fr(g),cr(I,g),Ur(o,I),A=32;A<64;A++)o[A]=n[A];for(at(y,o,c+64),Fr(y),A=0;A<64;A++)K[A]=0;for(A=0;A<32;A++)K[A]=g[A];for(A=0;A<32;A++)for(j=0;j<32;j++)K[A+j]+=y[A]*u[j];return qr(o.subarray(32),K),ce}function Yi(o,f){var c=r(),n=r(),u=r(),y=r(),g=r(),A=r(),j=r();return Pe(o[2],m),kr(o[1],f),qe(u,o[1]),ie(y,u,_),Ke(u,u,o[2]),Be(y,o[2],y),qe(g,y),qe(A,g),ie(j,A,g),ie(c,j,u),ie(c,c,y),Zn(c,c),ie(c,c,u),ie(c,c,y),ie(c,c,y),ie(o[0],c,y),qe(n,o[0]),ie(n,n,y),Yn(n,u)&&ie(o[0],o[0],p),qe(n,o[0]),ie(n,n,y),Yn(n,u)?-1:(Wn(o[0])===f[31]>>7&&Ke(o[0],d,o[0]),ie(o[3],o[0],o[1]),0)}function Br(o,f,c,n){var u,y=new Uint8Array(32),g=new Uint8Array(64),A=[r(),r(),r(),r()],j=[r(),r(),r(),r()];if(c<64||Yi(j,n))return-1;for(u=0;u<c;u++)o[u]=f[u];for(u=0;u<32;u++)o[u+32]=n[u];if(at(g,o,c),Fr(g),Lr(A,j,g),cr(j,f.subarray(32)),ar(A,j),Ur(y,A),c-=64,se(f,0,y,0)){for(u=0;u<c;u++)o[u]=0;return-1}for(u=0;u<c;u++)o[u]=f[u+64];return c}var Kr=32,ur=24,qt=32,wt=16,Ft=32,hr=32,Bt=32,Kt=32,Dr=32,is=ur,Wi=qt,Xi=wt,Ze=64,ct=32,xt=64,Gr=32,Jr=64;e.lowlevel={crypto_core_hsalsa20:de,crypto_stream_xor:_t,crypto_stream:mt,crypto_stream_salsa20_xor:ze,crypto_stream_salsa20:Lt,crypto_onetimeauth:pt,crypto_onetimeauth_verify:$t,crypto_verify_16:U,crypto_verify_32:se,crypto_secretbox:Se,crypto_secretbox_open:He,crypto_scalarmult:sr,crypto_scalarmult_base:ir,crypto_box_beforenm:or,crypto_box_afternm:es,crypto_box:Hi,crypto_box_open:Vi,crypto_box_keypair:Qn,crypto_hash:at,crypto_sign:ss,crypto_sign_keypair:$r,crypto_sign_open:Br,crypto_secretbox_KEYBYTES:Kr,crypto_secretbox_NONCEBYTES:ur,crypto_secretbox_ZEROBYTES:qt,crypto_secretbox_BOXZEROBYTES:wt,crypto_scalarmult_BYTES:Ft,crypto_scalarmult_SCALARBYTES:hr,crypto_box_PUBLICKEYBYTES:Bt,crypto_box_SECRETKEYBYTES:Kt,crypto_box_BEFORENMBYTES:Dr,crypto_box_NONCEBYTES:is,crypto_box_ZEROBYTES:Wi,crypto_box_BOXZEROBYTES:Xi,crypto_sign_BYTES:Ze,crypto_sign_PUBLICKEYBYTES:ct,crypto_sign_SECRETKEYBYTES:xt,crypto_sign_SEEDBYTES:Gr,crypto_hash_BYTES:Jr,gf:r,D:_,L:fr,pack25519:Ue,unpack25519:kr,M:ie,A:Be,S:qe,Z:Ke,pow2523:Zn,add:ar,set25519:Pe,modL:qr,scalarmult:Lr,scalarbase:cr};function os(o,f){if(o.length!==Kr)throw new Error("bad key size");if(f.length!==ur)throw new Error("bad nonce size")}function Zi(o,f){if(o.length!==Bt)throw new Error("bad public key size");if(f.length!==Kt)throw new Error("bad secret key size")}function Le(){for(var o=0;o<arguments.length;o++)if(!(arguments[o]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function as(o){for(var f=0;f<o.length;f++)o[f]=0}e.randomBytes=function(o){var f=new Uint8Array(o);return s(f,o),f},e.secretbox=function(o,f,c){Le(o,f,c),os(c,f);for(var n=new Uint8Array(qt+o.length),u=new Uint8Array(n.length),y=0;y<o.length;y++)n[y+qt]=o[y];return Se(u,n,n.length,f,c),u.subarray(wt)},e.secretbox.open=function(o,f,c){Le(o,f,c),os(c,f);for(var n=new Uint8Array(wt+o.length),u=new Uint8Array(n.length),y=0;y<o.length;y++)n[y+wt]=o[y];return n.length<32||He(u,n,n.length,f,c)!==0?null:u.subarray(qt)},e.secretbox.keyLength=Kr,e.secretbox.nonceLength=ur,e.secretbox.overheadLength=wt,e.scalarMult=function(o,f){if(Le(o,f),o.length!==hr)throw new Error("bad n size");if(f.length!==Ft)throw new Error("bad p size");var c=new Uint8Array(Ft);return sr(c,o,f),c},e.scalarMult.base=function(o){if(Le(o),o.length!==hr)throw new Error("bad n size");var f=new Uint8Array(Ft);return ir(f,o),f},e.scalarMult.scalarLength=hr,e.scalarMult.groupElementLength=Ft,e.box=function(o,f,c,n){var u=e.box.before(c,n);return e.secretbox(o,f,u)},e.box.before=function(o,f){Le(o,f),Zi(o,f);var c=new Uint8Array(Dr);return or(c,o,f),c},e.box.after=e.secretbox,e.box.open=function(o,f,c,n){var u=e.box.before(c,n);return e.secretbox.open(o,f,u)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var o=new Uint8Array(Bt),f=new Uint8Array(Kt);return Qn(o,f),{publicKey:o,secretKey:f}},e.box.keyPair.fromSecretKey=function(o){if(Le(o),o.length!==Kt)throw new Error("bad secret key size");var f=new Uint8Array(Bt);return ir(f,o),{publicKey:f,secretKey:new Uint8Array(o)}},e.box.publicKeyLength=Bt,e.box.secretKeyLength=Kt,e.box.sharedKeyLength=Dr,e.box.nonceLength=is,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(o,f){if(Le(o,f),f.length!==xt)throw new Error("bad secret key size");var c=new Uint8Array(Ze+o.length);return ss(c,o,o.length,f),c},e.sign.open=function(o,f){if(Le(o,f),f.length!==ct)throw new Error("bad public key size");var c=new Uint8Array(o.length),n=Br(c,o,o.length,f);if(n<0)return null;for(var u=new Uint8Array(n),y=0;y<u.length;y++)u[y]=c[y];return u},e.sign.detached=function(o,f){for(var c=e.sign(o,f),n=new Uint8Array(Ze),u=0;u<n.length;u++)n[u]=c[u];return n},e.sign.detached.verify=function(o,f,c){if(Le(o,f,c),f.length!==Ze)throw new Error("bad signature size");if(c.length!==ct)throw new Error("bad public key size");var n=new Uint8Array(Ze+o.length),u=new Uint8Array(Ze+o.length),y;for(y=0;y<Ze;y++)n[y]=f[y];for(y=0;y<o.length;y++)n[y+Ze]=o[y];return Br(u,n,n.length,c)>=0},e.sign.keyPair=function(){var o=new Uint8Array(ct),f=new Uint8Array(xt);return $r(o,f),{publicKey:o,secretKey:f}},e.sign.keyPair.fromSecretKey=function(o){if(Le(o),o.length!==xt)throw new Error("bad secret key size");for(var f=new Uint8Array(ct),c=0;c<f.length;c++)f[c]=o[32+c];return{publicKey:f,secretKey:new Uint8Array(o)}},e.sign.keyPair.fromSeed=function(o){if(Le(o),o.length!==Gr)throw new Error("bad seed size");for(var f=new Uint8Array(ct),c=new Uint8Array(xt),n=0;n<32;n++)c[n]=o[n];return $r(f,c,!0),{publicKey:f,secretKey:c}},e.sign.publicKeyLength=ct,e.sign.secretKeyLength=xt,e.sign.seedLength=Gr,e.sign.signatureLength=Ze,e.hash=function(o){Le(o);var f=new Uint8Array(Jr);return at(f,o,o.length),f},e.hash.hashLength=Jr,e.verify=function(o,f){return Le(o,f),o.length===0||f.length===0||o.length!==f.length?!1:M(o,0,f,0,o.length)===0},e.setPRNG=function(o){s=o},function(){var o=typeof self<"u"?self.crypto||self.msCrypto:null;if(o&&o.getRandomValues){var f=65536;e.setPRNG(function(c,n){var u,y=new Uint8Array(n);for(u=0;u<n;u+=f)o.getRandomValues(y.subarray(u,u+Math.min(n-u,f)));for(u=0;u<n;u++)c[u]=y[u];as(y)})}else typeof Ys<"u"&&(o=Ws,o&&o.randomBytes&&e.setPRNG(function(c,n){var u,y=o.randomBytes(n);for(u=0;u<n;u++)c[u]=y[u];as(y)}))}()})(t.exports?t.exports:self.nacl=self.nacl||{})})(Pn);var Xs=Pn.exports,Zs=he&&he.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(bt,"__esModule",{value:!0});const Qs=Zs(Xs);bt.default=Qs.default;var An;function ei(){if(An)return Mt;An=1;var t=he&&he.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(Mt,"__esModule",{value:!0}),Mt.KP=void 0;const e=Zt(),r=yt(),s=t(bt);class i{constructor(d){l(this,"seed");this.seed=d}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 d=e.Codec.decodeSeed(this.seed),m=s.default.sign.keyPair.fromSeed(this.getRawSeed()),S=e.Codec.encode(d.prefix,m.publicKey);return new TextDecoder().decode(S)}getPrivateKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const d=s.default.sign.keyPair.fromSeed(this.getRawSeed());return e.Codec.encode(r.Prefix.Private,d.secretKey)}sign(d){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const m=s.default.sign.keyPair.fromSeed(this.getRawSeed());return s.default.sign.detached(d,m.secretKey)}verify(d,m){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const S=s.default.sign.keyPair.fromSeed(this.getRawSeed());return s.default.sign.detached.verify(d,m,S.publicKey)}clear(){this.seed&&(this.seed.fill(0),this.seed=void 0)}seal(d,m,S){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}open(d,m){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}}return Mt.KP=i,Mt}var kt={},On;function ti(){if(On)return kt;On=1;var t=he&&he.__importDefault||function(a){return a&&a.__esModule?a:{default:a}};Object.defineProperty(kt,"__esModule",{value:!0}),kt.PublicKey=void 0;const e=Zt(),r=yt(),s=t(bt);class i{constructor(d){l(this,"publicKey");this.publicKey=d}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(d){throw this.publicKey?new r.NKeysError(r.NKeysErrorCode.CannotSign):new r.NKeysError(r.NKeysErrorCode.ClearedPair)}verify(d,m){if(!this.publicKey)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const S=e.Codec._decode(this.publicKey);return s.default.sign.detached.verify(d,m,S.slice(1))}clear(){this.publicKey&&(this.publicKey.fill(0),this.publicKey=void 0)}seal(d,m,S){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}open(d,m){throw new r.NKeysError(r.NKeysErrorCode.InvalidNKeyOperation)}}return kt.PublicKey=i,kt}var Or={},Nn;function ri(){return Nn||(Nn=1,function(t){var e=he&&he.__importDefault||function(E){return E&&E.__esModule?E:{default:E}};Object.defineProperty(t,"__esModule",{value:!0}),t.CurveKP=t.curveNonceLen=t.curveKeyLen=void 0;const r=yt(),s=e(bt),i=Zt(),a=yt(),d=Rt,m=It;t.curveKeyLen=32;const S=35;t.curveNonceLen=24;const _=[120,107,118,49];class x{constructor(b){l(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 i.Codec.encode(a.Prefix.Private,this.seed)}getPublicKey(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);const b=s.default.scalarMult.base(this.seed),p=i.Codec.encode(a.Prefix.Curve,b);return new TextDecoder().decode(p)}getSeed(){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);return i.Codec.encodeSeed(a.Prefix.Curve,this.seed)}sign(){throw new r.NKeysError(r.NKeysErrorCode.InvalidCurveOperation)}verify(){throw new r.NKeysError(r.NKeysErrorCode.InvalidCurveOperation)}decodePubCurveKey(b){try{const p=d.base32.decode(new TextEncoder().encode(b));if(p.byteLength!==S)throw new r.NKeysError(r.NKeysErrorCode.InvalidCurveKey);if(p[0]!==a.Prefix.Curve)throw new r.NKeysError(r.NKeysErrorCode.InvalidPublicKey);const R=p.byteLength-2,U=new DataView(p.buffer).getUint16(R,!0),se=p.slice(0,R);if(!m.crc16.validate(se,U))throw new r.NKeysError(r.NKeysErrorCode.InvalidChecksum);return se.slice(1)}catch(p){throw new r.NKeysError(r.NKeysErrorCode.InvalidRecipient,{cause:p})}}seal(b,p,R){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);R||(R=s.default.randomBytes(t.curveNonceLen));const M=this.decodePubCurveKey(p),U=new Uint8Array(_.length+t.curveNonceLen);U.set(_,0),U.set(R,_.length);const se=s.default.box(b,R,M,this.seed),ge=new Uint8Array(U.length+se.length);return ge.set(U),ge.set(se,U.length),ge}open(b,p){if(!this.seed)throw new r.NKeysError(r.NKeysErrorCode.ClearedPair);if(b.length<=t.curveNonceLen+_.length)throw new r.NKeysError(r.NKeysErrorCode.InvalidEncrypted);for(let U=0;U<_.length;U++)if(b[U]!==_[U])throw new r.NKeysError(r.NKeysErrorCode.InvalidEncrypted);const R=this.decodePubCurveKey(p);b=b.slice(_.length);const M=b.slice(0,t.curveNonceLen);return b=b.slice(t.curveNonceLen),s.default.box.open(b,M,R,this.seed)}}t.CurveKP=x}(Or)),Or}var Cn;function yt(){if(Cn)return pe;Cn=1;var t=he&&he.__importDefault||function(L){return L&&L.__esModule?L:{default:L}};Object.defineProperty(pe,"__esModule",{value:!0}),pe.NKeysError=pe.NKeysErrorCode=pe.Prefixes=pe.Prefix=void 0,pe.createPair=d,pe.createOperator=m,pe.createAccount=S,pe.createUser=_,pe.createCluster=x,pe.createServer=E,pe.createCurve=b,pe.fromPublic=p,pe.fromCurveSeed=R,pe.fromSeed=M;const e=ei(),r=ti(),s=Zt(),i=ri(),a=t(bt);function d(L){const de=L===U.Curve?i.curveKeyLen:32,le=a.default.randomBytes(de),ze=s.Codec.encodeSeed(L,new Uint8Array(le));return L===U.Curve?new i.CurveKP(new Uint8Array(le)):new e.KP(ze)}function m(){return d(U.Operator)}function S(){return d(U.Account)}function _(){return d(U.User)}function x(){return d(U.Cluster)}function E(){return d(U.Server)}function b(){return d(U.Curve)}function p(L){const de=new TextEncoder().encode(L),le=s.Codec._decode(de),ze=se.parsePrefix(le[0]);if(se.isValidPublicPrefix(ze))return new r.PublicKey(de);throw new $e(ge.InvalidPublicKey)}function R(L){const de=s.Codec.decodeSeed(L);if(de.prefix!==U.Curve)throw new $e(ge.InvalidCurveSeed);if(de.buf.byteLength!==i.curveKeyLen)throw new $e(ge.InvalidSeedLen);return new i.CurveKP(de.buf)}function M(L){return s.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||(pe.Prefix=U={}));class se{static isValidPublicPrefix(de){return de==U.Server||de==U.Operator||de==U.Cluster||de==U.Account||de==U.User||de==U.Curve}static startsWithValidPrefix(de){const le=de[0];return le=="S"||le=="P"||le=="O"||le=="N"||le=="C"||le=="A"||le=="U"||le=="X"}static isValidPrefix(de){return this.parsePrefix(de)!==U.Unknown}static parsePrefix(de){switch(de){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}}}pe.Prefixes=se;var ge;(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"})(ge||(pe.NKeysErrorCode=ge={}));class $e extends Error{constructor(le,ze){super(le,ze);l(this,"code");this.code=le}}return pe.NKeysError=$e,pe}var Ut={};Object.defineProperty(Ut,"__esModule",{value:!0}),Ut.encode=ni,Ut.decode=si,Ut.dump=ii;function ni(t){return btoa(String.fromCharCode(...t))}function si(t){const e=atob(t),r=new Uint8Array(e.length);for(let s=0;s<e.length;s++)r[s]=e.charCodeAt(s);return r}function ii(t,e){e&&console.log(e);const r=[];for(let s=0;s<t.byteLength;s++){s%8===0&&r.push(`
|
|
7
|
+
`);let i=t[s].toString(16);i.length===1&&(i="0"+i),r.push(i)}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 s=Qt;Object.defineProperty(t,"version",{enumerable:!0,get:function(){return s.version}})}(En);var oi=he&&he.__createBinding||(Object.create?function(t,e,r,s){s===void 0&&(s=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,i)}:function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]}),ai=he&&he.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),ci=he&&he.__importStar||function(){var t=function(e){return t=Object.getOwnPropertyNames||function(r){var s=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(s[s.length]=i);return s},t(e)};return function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var s=t(e),i=0;i<s.length;i++)s[i]!=="default"&&oi(r,e,s[i]);return ai(r,e),r}}();Object.defineProperty(jt,"__esModule",{value:!0}),jt.nkeys=void 0,jt.nkeys=ci(En),Object.defineProperty(De,"__esModule",{value:!0}),De.multiAuthenticator=fi,De.noAuthFn=ui,De.usernamePasswordAuthenticator=hi,De.tokenAuthenticator=di,De.nkeyAuthenticator=Mn,De.jwtAuthenticator=Tn,De.credsAuthenticator=li;const jn=jt,Nr=ke;function fi(t){return e=>{let r={};return t.forEach(s=>{const i=s(e)||{};r=Object.assign(r,i)}),r}}function ui(){return()=>{}}function hi(t,e){return()=>{const r=typeof t=="function"?t():t,s=typeof e=="function"?e():e;return{user:r,pass:s}}}function di(t){return()=>({auth_token:typeof t=="function"?t():t})}function Mn(t){return e=>{const r=typeof t=="function"?t():t,s=r?jn.nkeys.fromSeed(r):void 0,i=s?s.getPublicKey():"",a=Nr.TE.encode(e||""),d=s!==void 0&&e?s.sign(a):void 0,m=d?jn.nkeys.encode(d):"";return{nkey:i,sig:m}}}function Tn(t,e){return r=>{const s=typeof t=="function"?t():t,i=Mn(e),{nkey:a,sig:d}=i(r);return{jwt:s,nkey:a,sig:d}}}function li(t){const e=typeof t!="function"?()=>t:t,r=()=>{const a=/\s*(?:(?:[-]{3,}[^\n]*[-]{3,}\n)(.+)(?:\n\s*[-]{3,}[^\n]*[-]{3,}\n))/ig,d=Nr.TD.decode(e());let m=a.exec(d);if(!m)throw new Error("unable to parse credentials");const S=m[1].trim();if(m=a.exec(d),!m)throw new Error("unable to parse credentials");const _=Nr.TE.encode(m[1].trim());return{jwt:S,seed:_}};return Tn(()=>{const{jwt:a}=r();return a},()=>{const{seed:a}=r();return a})}(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=d,t.hasWsProtocol=m,t.buildAuthenticator=S,t.parseOptions=_,t.checkOptions=x,t.checkUnsupportedOption=E;const e=ye,r=rt,s=Oe,i=De,a=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 d(){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:p}=b;if(typeof p=="string"&&(p=[p]),p)for(let R=0;R<p.length;R++){const M=p[R].toLowerCase();if(M.startsWith("ws://")||M.startsWith("wss://"))return!0}}return!1}function S(b){const p=[];return typeof b.authenticator=="function"&&p.push(b.authenticator),Array.isArray(b.authenticator)&&p.push(...b.authenticator),b.token&&p.push((0,i.tokenAuthenticator)(b.token)),b.user&&p.push((0,i.usernamePasswordAuthenticator)(b.user,b.pass)),p.length===0?(0,i.noAuthFn)():(0,i.multiAuthenticator)(p)}function _(b){const p=`${s.DEFAULT_HOST}:${(0,r.defaultPort)()}`;if(b=b||{servers:[p]},b.servers=b.servers||[],typeof b.servers=="string"&&(b.servers=[b.servers]),b.servers.length>0&&b.port)throw a.InvalidArgumentError.format(["servers","port"],"are mutually exclusive");b.servers.length===0&&b.port&&(b.servers=[`${s.DEFAULT_HOST}:${b.port}`]),b.servers&&b.servers.length===0&&(b.servers=[p]);const R=(0,e.extend)(d(),b);if(R.authenticator=S(R),["reconnectDelayHandler","authenticator"].forEach(M=>{if(R[M]&&typeof R[M]!="function")throw TypeError(`'${M}' must be a function`)}),R.reconnectDelayHandler||(R.reconnectDelayHandler=()=>{let M=R.tls?R.reconnectJitterTLS:R.reconnectJitter;return M&&(M++,M=Math.floor(Math.random()*M)),R.reconnectTimeWait+M}),R.inboxPrefix&&(0,s.createInbox)(R.inboxPrefix),R.resolve===void 0&&(R.resolve=typeof(0,r.getResolveFn)()=="function"),R.resolve&&typeof(0,r.getResolveFn)()!="function")throw a.InvalidArgumentError.format("resolve","is not supported in the current runtime");return R}function x(b,p){const{proto:R,tls_required:M,tls_available:U}=b;if((R===void 0||R<1)&&p.noEcho)throw new a.errors.ConnectionError("server does not support 'noEcho'");const se=M||U||!1;if(p.tls&&!se)throw new a.errors.ConnectionError("server does not support 'tls'")}function E(b,p){if(p)throw a.InvalidArgumentError.format(b,"is not supported")}})(Ct),Object.defineProperty(Me,"__esModule",{value:!0}),Me.ProtocolHandler=Me.Subscriptions=Me.SubscriptionImpl=Me.Connect=Me.INFO=void 0;const Ge=ke,it=rt,Je=ye,bi=nt,yi=Ve,gi=dt,mi=At,_i=Ot,et=pr,vi=Nt,In=Xt,Cr=Ct,Ae=te,pi=1024*32;Me.INFO=/^INFO\s+([^\r\n]+)\r\n/i;const wi=(0,Ge.encode)(`PONG\r
|
|
8
8
|
`),Rn=(0,Ge.encode)(`PING\r
|
|
9
|
-
`);class kn{constructor(e,r,s){l(this,"echo");l(this,"no_responders");l(this,"protocol");l(this,"verbose");l(this,"pedantic");l(this,"jwt");l(this,"nkey");l(this,"sig");l(this,"user");l(this,"pass");l(this,"auth_token");l(this,"tls_required");l(this,"name");l(this,"lang");l(this,"version");l(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 i=(r&&typeof r.authenticator=="function"?r.authenticator(s):{})||{};(0,Je.extend)(this,i)}}Me.Connect=kn;class xi{constructor(e,r){l(this,"slow");l(this,"cb");l(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 gi.QueuedIteratorImpl{constructor(r,s,i={}){var d;super();l(this,"sid");l(this,"queue");l(this,"draining");l(this,"max");l(this,"subject");l(this,"drained");l(this,"protocol");l(this,"timer");l(this,"info");l(this,"cleanupFn");l(this,"closed");l(this,"requestSubject");l(this,"slow");(0,Je.extend)(this,i),this.protocol=r,this.subject=s,this.draining=!1,this.noIterator=typeof i.callback=="function",this.closed=(0,Je.deferred)();const a=!((d=r.options)!=null&&d.noAsyncTraces);i.timeout&&(this.timer=(0,Je.timeout)(i.timeout,a),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,s){if(this.slow=void 0,s){if(this.noIterator)throw new Error("callbacks don't support slow notifications");this.slow=new xi(r,s)}}callback(r,s){this.cancelTimeout(),r?this.stop(r):this.push(s),!r&&this.slow&&this.slow.maybeNotify(this.getPending())}close(r){if(!this.isClosed()){this.cancelTimeout();const s=()=>{if(this.stop(),this.cleanupFn)try{this.cleanupFn(this,this.info)}catch{}this.closed.resolve(r)};this.noIterator?s():this.push(s)}}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 Ae.errors.ClosedConnectionError):this.isClosed()?Promise.reject(new Ae.errors.InvalidOperationError("subscription is already closed")):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush((0,Je.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}}Me.SubscriptionImpl=Un;class Ln{constructor(){l(this,"mux");l(this,"subs");l(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 s;return e.operation==="subscription"?s=r.find(i=>i.subject===e.subject&&i.queue===e.queue):e.operation==="publish"&&(s=r.find(i=>i.requestSubject===e.subject)),s?(s.callback(e,{}),s.close(e),this.subs.delete(s.sid),s!==this.mux):!1}close(){this.subs.forEach(e=>{e.close()})}}Me.Subscriptions=Ln;class er{constructor(e,r){l(this,"connected");l(this,"connectedOnce");l(this,"infoReceived");l(this,"info");l(this,"muxSubscriptions");l(this,"options");l(this,"outbound");l(this,"pongs");l(this,"subscriptions");l(this,"transport");l(this,"noMorePublishing");l(this,"connectError");l(this,"publisher");l(this,"_closed");l(this,"closed");l(this,"listeners");l(this,"heartbeats");l(this,"parser");l(this,"outMsgs");l(this,"inMsgs");l(this,"outBytes");l(this,"inBytes");l(this,"pendingLimit");l(this,"lastError");l(this,"abortReconnect");l(this,"whyClosed");l(this,"servers");l(this,"server");l(this,"features");l(this,"connectPromise");l(this,"dialDelay");l(this,"raceTimer");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=pi,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 mi.MuxSubscription,this.outbound=new bi.DataBuffer,this.pongs=[],this.whyClosed="",this.pendingLimit=e.pendingLimit||this.pendingLimit,this.features=new In.Features({major:0,minor:0,micro:0}),this.connectPromise=null,this.dialDelay=null;const s=typeof e.servers=="string"?[e.servers]:e.servers;this.servers=new yi.Servers(s,{randomize:!e.noRandomize}),this.closed=(0,Je.deferred)(),this.parser=new et.Parser(this),this.heartbeats=new _i.Heartbeat(this,this.options.pingInterval||Nr.DEFAULT_PING_INTERVAL,this.options.maxPingOut||Nr.DEFAULT_MAX_PING_OUT)}resetOutbound(){this.outbound.reset();const e=this.pongs;this.pongs=[];const r=new Ae.errors.RequestError("connection disconnected");r.stack="",e.forEach(s=>{s.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,Je.deferred)();return e.catch(()=>{}),this.pongs.unshift(e),this.connectError=r=>{e.reject(r)},this.transport=(0,it.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 Ae.errors.UserAuthenticationExpiredError&&(this.lastError=void 0)}).catch(r=>{this.close(r).catch()}):await this.close(e).catch()}async dial(e){var s,i;const r=this.prepare();try{this.raceTimer=(0,Je.timeout)(this.options.timeout||2e4);const a=this.transport.connect(e,this.options);await Promise.race([a,this.raceTimer]),(async()=>{try{for await(const d of this.transport)this.parser.parse(d)}catch(d){console.log("reader closed",d)}})().then()}catch(a){r.reject(a)}try{await Promise.race([this.raceTimer,r]),(s=this.raceTimer)==null||s.cancel(),this.connected=!0,this.connectError=void 0,this.sendSubscriptions(),this.connectedOnce=!0,this.server.didConnect=!0,this.server.reconnects=0,this.flushPending(),this.heartbeats.start()}catch(a){throw(i=this.raceTimer)==null||i.cancel(),await this.transport.close(a),a}}async _doDial(e){const{resolve:r}=this.options,s=await e.resolve({fn:(0,it.getResolveFn)(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:r});let i=null;for(const a of s)try{i=null,this.dispatchStatus({type:"reconnecting"}),await this.dial(a);return}catch(d){i=d}throw i}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():Nr.DEFAULT_RECONNECT_TIME_WAIT;let s=r;const i=this.selectServer();if(!i||this.abortReconnect)throw e||(this.lastError?this.lastError:new Ae.errors.ConnectionError("connection refused"));const a=Date.now();if(i.lastConnect===0||i.lastConnect+r<=a){i.lastConnect=Date.now();try{await this._doDial(i);break}catch(d){if(e=d,!this.connectedOnce){if(this.options.waitOnFirstConnect)continue;this.servers.removeCurrentServer()}i.reconnects++;const m=this.options.maxReconnectAttempts||0;m!==-1&&i.reconnects>=m&&this.servers.removeCurrentServer()}}else s=Math.min(s,i.lastConnect+r-a),this.dialDelay=(0,Je.delay)(s),await this.dialDelay}}static async connect(e,r){const s=new er(e,r);return await s.dialLoop(),s}static toError(e){let r=Ae.errors.PermissionViolationError.parse(e);return r||(r=Ae.errors.UserAuthenticationExpiredError.parse(e),r)||(r=Ae.errors.AuthorizationError.parse(e),r)?r:new Ae.errors.ProtocolError(e)}processMsg(e,r){if(this.inMsgs++,this.inBytes+=r.length,!this.subscriptions.sidCounter)return;const s=this.subscriptions.get(e.sid);s&&(s.received+=1,s.callback&&s.callback(null,new vi.MsgImpl(e,r,this)),s.max!==void 0&&s.received>=s.max&&s.unsubscribe())}processError(e){let r=(0,Ge.decode)(e);r.startsWith("'")&&r.endsWith("'")&&(r=r.slice(1,r.length-1));const s=er.toError(r);switch(s.constructor){case Ae.errors.PermissionViolationError:{const i=s,a=this.subscriptions.getMux(),d=a?i.subject===a.subject:!1;this.subscriptions.handleError(i),this.muxSubscriptions.handleError(d,i),d&&this.subscriptions.setMux(null)}}this.dispatchStatus({type:"error",error:s}),this.handleError(s)}handleError(e){(e instanceof Ae.errors.UserAuthenticationExpiredError||e instanceof Ae.errors.AuthorizationError)&&this.handleAuthError(e),e instanceof Ae.errors.PermissionViolationError||(this.lastError=e)}handleAuthError(e){(this.lastError instanceof Ae.errors.UserAuthenticationExpiredError||this.lastError instanceof Ae.errors.AuthorizationError)&&this.options.ignoreAuthErrorAbort===!1&&(this.abortReconnect=!0),this.connectError?this.connectError(e):this.disconnect()}processPing(){this.transport.send(wi)}processPong(){const e=this.pongs.shift();e&&e.resolve()}processInfo(e){const r=JSON.parse((0,Ge.decode)(e));this.info=r;const s=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(r,this.transport.isEncrypted());if(!this.infoReceived){this.features.update((0,In.parseSemVer)(r.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:a,lang:d}=this.transport;try{const m=new kn({version:a,lang:d},this.options,r.nonce);r.headers&&(m.headers=!0,m.no_responders=!0);const S=JSON.stringify(m);this.transport.send((0,Ge.encode)(`CONNECT ${S}${it.CR_LF}`)),this.transport.send(Rn)}catch(m){this.close(m).catch()}}if(s){const{added:a,deleted:d}=s;this.dispatchStatus({type:"update",added:a,deleted:d})}(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:s}=e;this.processMsg(r,s);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 s=this.outbound.length();let i;typeof e=="string"?i=(0,Ge.encode)(e):i=e,this.outbound.fill(i,...r),s===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(e,r=Ge.Empty,s){let i;if(r instanceof Uint8Array)i=r;else if(typeof r=="string")i=Ge.TE.encode(r);else throw new TypeError("payload types can be strings or Uint8Array");let a=i.length;s=s||{},s.reply=s.reply||"";let d=Ge.Empty,m=0;if(s.headers&&(this.info&&!this.info.headers&&Ae.InvalidArgumentError.format("headers","are not available on this server"),d=s.headers.encode(),m=d.length,a=i.length+m),this.info&&a>this.info.max_payload)throw Ae.InvalidArgumentError.format("payload","max_payload size exceeded");this.outBytes+=a,this.outMsgs++;let S;s.headers?(s.reply?S=`HPUB ${e} ${s.reply} ${m} ${a}\r
|
|
9
|
+
`);class kn{constructor(e,r,s){l(this,"echo");l(this,"no_responders");l(this,"protocol");l(this,"verbose");l(this,"pedantic");l(this,"jwt");l(this,"nkey");l(this,"sig");l(this,"user");l(this,"pass");l(this,"auth_token");l(this,"tls_required");l(this,"name");l(this,"lang");l(this,"version");l(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 i=(r&&typeof r.authenticator=="function"?r.authenticator(s):{})||{};(0,Je.extend)(this,i)}}Me.Connect=kn;class xi{constructor(e,r){l(this,"slow");l(this,"cb");l(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 gi.QueuedIteratorImpl{constructor(r,s,i={}){var d;super();l(this,"sid");l(this,"queue");l(this,"draining");l(this,"max");l(this,"subject");l(this,"drained");l(this,"protocol");l(this,"timer");l(this,"info");l(this,"cleanupFn");l(this,"closed");l(this,"requestSubject");l(this,"slow");(0,Je.extend)(this,i),this.protocol=r,this.subject=s,this.draining=!1,this.noIterator=typeof i.callback=="function",this.closed=(0,Je.deferred)();const a=!((d=r.options)!=null&&d.noAsyncTraces);i.timeout&&(this.timer=(0,Je.timeout)(i.timeout,a),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,s){if(this.slow=void 0,s){if(this.noIterator)throw new Error("callbacks don't support slow notifications");this.slow=new xi(r,s)}}callback(r,s){this.cancelTimeout(),r?this.stop(r):this.push(s),!r&&this.slow&&this.slow.maybeNotify(this.getPending())}close(r){if(!this.isClosed()){this.cancelTimeout();const s=()=>{if(this.stop(),this.cleanupFn)try{this.cleanupFn(this,this.info)}catch{}this.closed.resolve(r)};this.noIterator?s():this.push(s)}}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 Ae.errors.ClosedConnectionError):this.isClosed()?Promise.reject(new Ae.errors.InvalidOperationError("subscription is already closed")):(this.drained||(this.draining=!0,this.protocol.unsub(this),this.drained=this.protocol.flush((0,Je.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}}Me.SubscriptionImpl=Un;class Ln{constructor(){l(this,"mux");l(this,"subs");l(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 s;return e.operation==="subscription"?s=r.find(i=>i.subject===e.subject&&i.queue===e.queue):e.operation==="publish"&&(s=r.find(i=>i.requestSubject===e.subject)),s?(s.callback(e,{}),s.close(e),this.subs.delete(s.sid),s!==this.mux):!1}close(){this.subs.forEach(e=>{e.close()})}}Me.Subscriptions=Ln;class er{constructor(e,r){l(this,"connected");l(this,"connectedOnce");l(this,"infoReceived");l(this,"info");l(this,"muxSubscriptions");l(this,"options");l(this,"outbound");l(this,"pongs");l(this,"subscriptions");l(this,"transport");l(this,"noMorePublishing");l(this,"connectError");l(this,"publisher");l(this,"_closed");l(this,"closed");l(this,"listeners");l(this,"heartbeats");l(this,"parser");l(this,"outMsgs");l(this,"inMsgs");l(this,"outBytes");l(this,"inBytes");l(this,"pendingLimit");l(this,"lastError");l(this,"abortReconnect");l(this,"whyClosed");l(this,"servers");l(this,"server");l(this,"features");l(this,"connectPromise");l(this,"dialDelay");l(this,"raceTimer");this._closed=!1,this.connected=!1,this.connectedOnce=!1,this.infoReceived=!1,this.noMorePublishing=!1,this.abortReconnect=!1,this.listeners=[],this.pendingLimit=pi,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 mi.MuxSubscription,this.outbound=new bi.DataBuffer,this.pongs=[],this.whyClosed="",this.pendingLimit=e.pendingLimit||this.pendingLimit,this.features=new In.Features({major:0,minor:0,micro:0}),this.connectPromise=null,this.dialDelay=null;const s=typeof e.servers=="string"?[e.servers]:e.servers;this.servers=new yi.Servers(s,{randomize:!e.noRandomize}),this.closed=(0,Je.deferred)(),this.parser=new et.Parser(this),this.heartbeats=new _i.Heartbeat(this,this.options.pingInterval||Cr.DEFAULT_PING_INTERVAL,this.options.maxPingOut||Cr.DEFAULT_MAX_PING_OUT)}resetOutbound(){this.outbound.reset();const e=this.pongs;this.pongs=[];const r=new Ae.errors.RequestError("connection disconnected");r.stack="",e.forEach(s=>{s.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,Je.deferred)();return e.catch(()=>{}),this.pongs.unshift(e),this.connectError=r=>{e.reject(r)},this.transport=(0,it.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 Ae.errors.UserAuthenticationExpiredError&&(this.lastError=void 0)}).catch(r=>{this.close(r).catch()}):await this.close(e).catch()}async dial(e){var s,i;const r=this.prepare();try{this.raceTimer=(0,Je.timeout)(this.options.timeout||2e4);const a=this.transport.connect(e,this.options);await Promise.race([a,this.raceTimer]),(async()=>{try{for await(const d of this.transport)this.parser.parse(d)}catch(d){console.log("reader closed",d)}})().then()}catch(a){r.reject(a)}try{await Promise.race([this.raceTimer,r]),(s=this.raceTimer)==null||s.cancel(),this.connected=!0,this.connectError=void 0,this.sendSubscriptions(),this.connectedOnce=!0,this.server.didConnect=!0,this.server.reconnects=0,this.flushPending(),this.heartbeats.start()}catch(a){throw(i=this.raceTimer)==null||i.cancel(),await this.transport.close(a),a}}async _doDial(e){const{resolve:r}=this.options,s=await e.resolve({fn:(0,it.getResolveFn)(),debug:this.options.debug,randomize:!this.options.noRandomize,resolve:r});let i=null;for(const a of s)try{i=null,this.dispatchStatus({type:"reconnecting"}),await this.dial(a);return}catch(d){i=d}throw i}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():Cr.DEFAULT_RECONNECT_TIME_WAIT;let s=r;const i=this.selectServer();if(!i||this.abortReconnect)throw e||(this.lastError?this.lastError:new Ae.errors.ConnectionError("connection refused"));const a=Date.now();if(i.lastConnect===0||i.lastConnect+r<=a){i.lastConnect=Date.now();try{await this._doDial(i);break}catch(d){if(e=d,!this.connectedOnce){if(this.options.waitOnFirstConnect)continue;this.servers.removeCurrentServer()}i.reconnects++;const m=this.options.maxReconnectAttempts||0;m!==-1&&i.reconnects>=m&&this.servers.removeCurrentServer()}}else s=Math.min(s,i.lastConnect+r-a),this.dialDelay=(0,Je.delay)(s),await this.dialDelay}}static async connect(e,r){const s=new er(e,r);return await s.dialLoop(),s}static toError(e){let r=Ae.errors.PermissionViolationError.parse(e);return r||(r=Ae.errors.UserAuthenticationExpiredError.parse(e),r)||(r=Ae.errors.AuthorizationError.parse(e),r)?r:new Ae.errors.ProtocolError(e)}processMsg(e,r){if(this.inMsgs++,this.inBytes+=r.length,!this.subscriptions.sidCounter)return;const s=this.subscriptions.get(e.sid);s&&(s.received+=1,s.callback&&s.callback(null,new vi.MsgImpl(e,r,this)),s.max!==void 0&&s.received>=s.max&&s.unsubscribe())}processError(e){let r=(0,Ge.decode)(e);r.startsWith("'")&&r.endsWith("'")&&(r=r.slice(1,r.length-1));const s=er.toError(r);switch(s.constructor){case Ae.errors.PermissionViolationError:{const i=s,a=this.subscriptions.getMux(),d=a?i.subject===a.subject:!1;this.subscriptions.handleError(i),this.muxSubscriptions.handleError(d,i),d&&this.subscriptions.setMux(null)}}this.dispatchStatus({type:"error",error:s}),this.handleError(s)}handleError(e){(e instanceof Ae.errors.UserAuthenticationExpiredError||e instanceof Ae.errors.AuthorizationError)&&this.handleAuthError(e),e instanceof Ae.errors.PermissionViolationError||(this.lastError=e)}handleAuthError(e){(this.lastError instanceof Ae.errors.UserAuthenticationExpiredError||this.lastError instanceof Ae.errors.AuthorizationError)&&this.options.ignoreAuthErrorAbort===!1&&(this.abortReconnect=!0),this.connectError?this.connectError(e):this.disconnect()}processPing(){this.transport.send(wi)}processPong(){const e=this.pongs.shift();e&&e.resolve()}processInfo(e){const r=JSON.parse((0,Ge.decode)(e));this.info=r;const s=this.options&&this.options.ignoreClusterUpdates?void 0:this.servers.update(r,this.transport.isEncrypted());if(!this.infoReceived){this.features.update((0,In.parseSemVer)(r.version)),this.infoReceived=!0,this.transport.isEncrypted()&&this.servers.updateTLSName();const{version:a,lang:d}=this.transport;try{const m=new kn({version:a,lang:d},this.options,r.nonce);r.headers&&(m.headers=!0,m.no_responders=!0);const S=JSON.stringify(m);this.transport.send((0,Ge.encode)(`CONNECT ${S}${it.CR_LF}`)),this.transport.send(Rn)}catch(m){this.close(m).catch()}}if(s){const{added:a,deleted:d}=s;this.dispatchStatus({type:"update",added:a,deleted:d})}(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:s}=e;this.processMsg(r,s);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 s=this.outbound.length();let i;typeof e=="string"?i=(0,Ge.encode)(e):i=e,this.outbound.fill(i,...r),s===0?queueMicrotask(()=>{this.flushPending()}):this.outbound.size()>=this.pendingLimit&&this.flushPending()}publish(e,r=Ge.Empty,s){let i;if(r instanceof Uint8Array)i=r;else if(typeof r=="string")i=Ge.TE.encode(r);else throw new TypeError("payload types can be strings or Uint8Array");let a=i.length;s=s||{},s.reply=s.reply||"";let d=Ge.Empty,m=0;if(s.headers&&(this.info&&!this.info.headers&&Ae.InvalidArgumentError.format("headers","are not available on this server"),d=s.headers.encode(),m=d.length,a=i.length+m),this.info&&a>this.info.max_payload)throw Ae.InvalidArgumentError.format("payload","max_payload size exceeded");this.outBytes+=a,this.outMsgs++;let S;s.headers?(s.reply?S=`HPUB ${e} ${s.reply} ${m} ${a}\r
|
|
10
10
|
`:S=`HPUB ${e} ${m} ${a}\r
|
|
11
11
|
`,this.sendCommand(S,d,i,it.CRLF)):(s.reply?S=`PUB ${e} ${s.reply} ${a}\r
|
|
12
12
|
`:S=`PUB ${e} ${a}\r
|
|
@@ -16,8 +16,8 @@ ${r}: ${s[i]}`;return`${e}\r
|
|
|
16
16
|
`):this.sendCommand(`UNSUB ${e.sid}\r
|
|
17
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,Je.deferred)()),this.pongs.push(e),this.outbound.fill(Rn),this.flushPending(),e}sendSubscriptions(){const e=[];this.subscriptions.all().forEach(r=>{const s=r;s.queue?e.push(`SUB ${s.subject} ${s.queue} ${s.sid}${it.CR_LF}`):e.push(`SUB ${s.subject} ${s.sid}${it.CR_LF}`)}),e.length&&this.transport.send((0,Ge.encode)(e.join("")))}async close(e){var s,i;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 a=0;a<this.listeners.length;a++){const d=this.listeners[a];d&&(d.push({type:"close"}),d.stop(),r.push(d.iterClosed))}r.length&&await Promise.all(r),this._closed=!0,await this.transport.close(e),(s=this.raceTimer)==null||s.cancel(),(i=this.dialDelay)==null||i.cancel(),this.closed.resolve(e)}isClosed(){return this._closed}async drain(){const e=this.subscriptions.all(),r=[];e.forEach(s=>{r.push(s.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),s=new Un(this,`${r}*`);s.callback=this.muxSubscriptions.dispatcher(),this.subscriptions.setMux(s),this.subscribe(s)}}selectServer(){const e=this.servers.selectServer();if(e!==void 0)return this.server=e,this.server}getServer(){return this.server}}Me.ProtocolHandler=er;var Ye={};Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.RequestOne=Ye.RequestMany=Ye.BaseRequest=void 0;const jr=ye,Ei=St,tr=te;class Mr{constructor(e,r,s=!0){l(this,"token");l(this,"received");l(this,"ctx");l(this,"requestSubject");l(this,"mux");this.mux=e,this.requestSubject=r,this.received=0,this.token=Ei.nuid.next(),s&&(this.ctx=new tr.RequestError)}}Ye.BaseRequest=Mr;class Si extends Mr{constructor(r,s,i={maxWait:1e3}){super(r,s);l(this,"callback");l(this,"done");l(this,"timer");l(this,"max");l(this,"opts");if(this.opts=i,typeof this.opts.callback!="function")throw new TypeError("callback must be a function");this.callback=this.opts.callback,this.max=typeof i.maxMessages=="number"&&i.maxMessages>0?i.maxMessages:-1,this.done=(0,jr.deferred)(),this.done.then(()=>{this.callback(null,null)}),this.timer=setTimeout(()=>{this.cancel()},i.maxWait)}cancel(r){r&&this.callback(r,null),clearTimeout(this.timer),this.mux.cancel(this),this.done.resolve()}resolver(r,s){r?(this.ctx&&(r.stack+=`
|
|
18
18
|
|
|
19
|
-
${this.ctx.stack}`),this.cancel(r)):(this.callback(null,s),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"&&s&&s.data.length===0&&this.cancel())}}Ye.RequestMany=Si;class Pi extends Mr{constructor(r,s,i={timeout:1e3},a=!0){super(r,s,a);l(this,"deferred");l(this,"timer");this.deferred=(0,jr.deferred)(),this.timer=(0,jr.timeout)(i.timeout,a)}resolver(r,s){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(s),this.cancel()}cancel(r){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(r||new tr.RequestError("cancelled"))}}Ye.RequestOne=Pi,Object.defineProperty(Et,"__esModule",{value:!0}),Et.NatsConnectionImpl=void 0;const Ai=ye,$n=Me,Oi=ke,qn=Qe,
|
|
19
|
+
${this.ctx.stack}`),this.cancel(r)):(this.callback(null,s),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"&&s&&s.data.length===0&&this.cancel())}}Ye.RequestMany=Si;class Pi extends Mr{constructor(r,s,i={timeout:1e3},a=!0){super(r,s,a);l(this,"deferred");l(this,"timer");this.deferred=(0,jr.deferred)(),this.timer=(0,jr.timeout)(i.timeout,a)}resolver(r,s){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(s),this.cancel()}cancel(r){this.timer&&this.timer.cancel(),this.mux.cancel(this),this.deferred.reject(r||new tr.RequestError("cancelled"))}}Ye.RequestOne=Pi,Object.defineProperty(Et,"__esModule",{value:!0}),Et.NatsConnectionImpl=void 0;const Ai=ye,$n=Me,Oi=ke,qn=Qe,Ni=Xt,Ci=Ct,Fn=dt,Bn=Ye,Kn=Oe,xe=te;class Tr{constructor(e){l(this,"options");l(this,"protocol");l(this,"draining");l(this,"closeListeners");this.draining=!1,this.options=(0,Ci.parseOptions)(e)}static connect(e={}){return new Promise((r,s)=>{const i=new Tr(e);$n.ProtocolHandler.connect(i.options,i).then(a=>{i.protocol=a,r(i)}).catch(a=>{s(a)})})}closed(){return this.protocol.closed}async close(){await this.protocol.close()}_check(e,r,s){if(this.isClosed())throw new xe.errors.ClosedConnectionError;if(r&&this.isDraining())throw new xe.errors.DrainingConnectionError;if(s&&this.protocol.noMorePublishing)throw new xe.errors.DrainingConnectionError;if(e=e||"",e.length===0)throw new xe.errors.InvalidSubjectError(e)}publish(e,r,s){if(this._check(e,!1,!0),s!=null&&s.reply&&this._check(s.reply,!1,!0),typeof(s==null?void 0:s.traceOnly)=="boolean"){const i=s.headers||(0,qn.headers)();i.set("Nats-Trace-Only","true"),s.headers=i}if(typeof(s==null?void 0:s.traceDestination)=="string"){const i=s.headers||(0,qn.headers)();i.set("Nats-Trace-Dest",s.traceDestination),s.headers=i}this.protocol.publish(e,r,s)}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 s=new $n.SubscriptionImpl(this.protocol,e,r);return typeof r.callback!="function"&&typeof r.slow=="number"&&s.setSlowNotificationFn(r.slow,i=>{this.protocol.dispatchStatus({type:"slowConsumer",sub:s,pending:i})}),this.protocol.subscribe(s),s}_resub(e,r,s){this._check(r,!0,!1);const i=e;i.max=s,s&&(i.max=s+i.received),this.protocol.resub(i,r)}requestMany(e,r=Oi.Empty,s={maxWait:1e3,maxMessages:-1}){const i=!this.protocol.options.noAsyncTraces;try{this._check(e,!0,!0)}catch(S){return Promise.reject(S)}if(s.strategy=s.strategy||"timer",s.maxWait=s.maxWait||1e3,s.maxWait<1)return Promise.reject(xe.InvalidArgumentError.format("timeout","must be greater than 0"));const a=new Fn.QueuedIteratorImpl;function d(S){a.push(()=>{a.stop(S)})}function m(S,_){S||_===null?d(S===null?void 0:S):a.push(_)}if(s.noMux){const S=i?new Error().stack:null;let _=typeof s.maxMessages=="number"&&s.maxMessages>0?s.maxMessages:-1;const x=this.subscribe((0,Kn.createInbox)(this.options.inboxPrefix),{callback:(se,ge)=>{var $e,L;if((($e=ge==null?void 0:ge.data)==null?void 0:$e.length)===0&&((L=ge==null?void 0:ge.headers)==null?void 0:L.status)==="503"&&(se=new xe.errors.NoRespondersError(e)),se){S&&(se.stack+=`
|
|
20
20
|
|
|
21
|
-
${S}`),E(se);return}m(null,ge),s.strategy==="count"&&(_--,_===0&&E()),s.strategy==="stall"&&(U(),M=setTimeout(()=>{E()},300)),s.strategy==="sentinel"&&ge&&ge.data.length===0&&E()}});x.requestSubject=e,x.closed.then(()=>{d()}).catch(se=>{a.stop(se)});const E=se=>{se&&a.push(()=>{throw se}),U(),x.drain().then(()=>{d()}).catch(ge=>{d()})};a.iterClosed.then(()=>{U(),x==null||x.unsubscribe()}).catch(se=>{U(),x==null||x.unsubscribe()});const{headers:b,traceDestination:p,traceOnly:R}=s;try{this.publish(e,r,{reply:x.getSubject(),headers:b,traceDestination:p,traceOnly:R})}catch(se){E(se)}let M=setTimeout(()=>{E()},s.maxWait);const U=()=>{M&&clearTimeout(M)}}else{const S=s;S.callback=m,a.iterClosed.then(()=>{_.cancel()}).catch(p=>{_.cancel(p)});const _=new Bn.RequestMany(this.protocol.muxSubscriptions,e,S);this.protocol.request(_);const{headers:x,traceDestination:E,traceOnly:b}=s;try{this.publish(e,r,{reply:`${this.protocol.muxSubscriptions.baseInbox}${_.token}`,headers:x,traceDestination:E,traceOnly:b})}catch(p){_.cancel(p)}}return Promise.resolve(a)}request(e,r,s={timeout:1e3,noMux:!1}){try{this._check(e,!0,!0)}catch(a){return Promise.reject(a)}const i=!this.protocol.options.noAsyncTraces;if(s.timeout=s.timeout||1e3,s.timeout<1)return Promise.reject(xe.InvalidArgumentError.format("timeout","must be greater than 0"));if(!s.noMux&&s.reply)return Promise.reject(xe.InvalidArgumentError.format(["reply","noMux"],"are mutually exclusive"));if(s.noMux){const a=s.reply?s.reply:(0,Kn.createInbox)(this.options.inboxPrefix),d=(0,Ai.deferred)(),m=i?new xe.errors.RequestError(""):null,S=this.subscribe(a,{max:1,timeout:s.timeout,callback:(_,x)=>{var E,b;x&&((E=x.data)==null?void 0:E.length)===0&&((b=x.headers)==null?void 0:b.code)===503&&(_=new xe.errors.NoRespondersError(e)),_?(_ instanceof xe.TimeoutError||(m?(m.message=_.message,m.cause=_,_=m):_=new xe.errors.RequestError(_.message,{cause:_})),d.reject(_),S.unsubscribe()):d.resolve(x)}});return S.requestSubject=e,this.protocol.publish(e,r,{reply:a,headers:s.headers}),d}else{const a=new Bn.RequestOne(this.protocol.muxSubscriptions,e,s,i);this.protocol.request(a);const{headers:d,traceDestination:m,traceOnly:S}=s;try{this.publish(e,r,{reply:`${this.protocol.muxSubscriptions.baseInbox}${a.token}`,headers:d,traceDestination:m,traceOnly:S})}catch(x){a.cancel(x)}const _=Promise.race([a.timer,a.deferred]);return _.catch(()=>{a.cancel()}),_}}flush(){return this.isClosed()?Promise.reject(new xe.errors.ClosedConnectionError):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(new xe.errors.ClosedConnectionError):this.isDraining()?Promise.reject(new xe.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 Fn.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,s)=>r==="time"?new Date(Date.parse(s)):s)}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,
|
|
21
|
+
${S}`),E(se);return}m(null,ge),s.strategy==="count"&&(_--,_===0&&E()),s.strategy==="stall"&&(U(),M=setTimeout(()=>{E()},300)),s.strategy==="sentinel"&&ge&&ge.data.length===0&&E()}});x.requestSubject=e,x.closed.then(()=>{d()}).catch(se=>{a.stop(se)});const E=se=>{se&&a.push(()=>{throw se}),U(),x.drain().then(()=>{d()}).catch(ge=>{d()})};a.iterClosed.then(()=>{U(),x==null||x.unsubscribe()}).catch(se=>{U(),x==null||x.unsubscribe()});const{headers:b,traceDestination:p,traceOnly:R}=s;try{this.publish(e,r,{reply:x.getSubject(),headers:b,traceDestination:p,traceOnly:R})}catch(se){E(se)}let M=setTimeout(()=>{E()},s.maxWait);const U=()=>{M&&clearTimeout(M)}}else{const S=s;S.callback=m,a.iterClosed.then(()=>{_.cancel()}).catch(p=>{_.cancel(p)});const _=new Bn.RequestMany(this.protocol.muxSubscriptions,e,S);this.protocol.request(_);const{headers:x,traceDestination:E,traceOnly:b}=s;try{this.publish(e,r,{reply:`${this.protocol.muxSubscriptions.baseInbox}${_.token}`,headers:x,traceDestination:E,traceOnly:b})}catch(p){_.cancel(p)}}return Promise.resolve(a)}request(e,r,s={timeout:1e3,noMux:!1}){try{this._check(e,!0,!0)}catch(a){return Promise.reject(a)}const i=!this.protocol.options.noAsyncTraces;if(s.timeout=s.timeout||1e3,s.timeout<1)return Promise.reject(xe.InvalidArgumentError.format("timeout","must be greater than 0"));if(!s.noMux&&s.reply)return Promise.reject(xe.InvalidArgumentError.format(["reply","noMux"],"are mutually exclusive"));if(s.noMux){const a=s.reply?s.reply:(0,Kn.createInbox)(this.options.inboxPrefix),d=(0,Ai.deferred)(),m=i?new xe.errors.RequestError(""):null,S=this.subscribe(a,{max:1,timeout:s.timeout,callback:(_,x)=>{var E,b;x&&((E=x.data)==null?void 0:E.length)===0&&((b=x.headers)==null?void 0:b.code)===503&&(_=new xe.errors.NoRespondersError(e)),_?(_ instanceof xe.TimeoutError||(m?(m.message=_.message,m.cause=_,_=m):_=new xe.errors.RequestError(_.message,{cause:_})),d.reject(_),S.unsubscribe()):d.resolve(x)}});return S.requestSubject=e,this.protocol.publish(e,r,{reply:a,headers:s.headers}),d}else{const a=new Bn.RequestOne(this.protocol.muxSubscriptions,e,s,i);this.protocol.request(a);const{headers:d,traceDestination:m,traceOnly:S}=s;try{this.publish(e,r,{reply:`${this.protocol.muxSubscriptions.baseInbox}${a.token}`,headers:d,traceDestination:m,traceOnly:S})}catch(x){a.cancel(x)}const _=Promise.race([a.timer,a.deferred]);return _.catch(()=>{a.cancel()}),_}}flush(){return this.isClosed()?Promise.reject(new xe.errors.ClosedConnectionError):this.protocol.flush()}drain(){return this.isClosed()?Promise.reject(new xe.errors.ClosedConnectionError):this.isDraining()?Promise.reject(new xe.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 Fn.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,s)=>r==="time"?new Date(Date.parse(s)):s)}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,Ni.parseSemVer)(e.version):void 0}async rtt(){if(this.isClosed())throw new xe.errors.ClosedConnectionError;if(!this.protocol.connected)throw new xe.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 xe.errors.ClosedConnectionError):this.isDraining()?Promise.reject(new xe.errors.DrainingConnectionError):this.protocol.reconnect()}addCloseListener(e){this.closeListeners===void 0&&(this.closeListeners=new ji(this.closed())),this.closeListeners.add(e)}removeCloseListener(e){this.closeListeners&&this.closeListeners.remove(e)}}Et.NatsConnectionImpl=Tr;class ji{constructor(e){l(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={},Ir={};(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}})})(Ir),Object.defineProperty(We,"__esModule",{value:!0}),We.Bench=We.Metric=void 0,We.throughput=Dn,We.msgThroughput=Ri,We.humanizeBytes=Gn;const Mi=Ir,Ti=St,Rr=ye;class ot{constructor(e,r){l(this,"name");l(this,"duration");l(this,"date");l(this,"payload");l(this,"msgs");l(this,"lang");l(this,"version");l(this,"bytes");l(this,"asyncRequests");l(this,"min");l(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),s=this.asyncRequests?"asyncRequests":"";let i="";return this.max&&(i=`${this.min}/${this.max}`),`${this.name}${s?" [asyncRequests]":""} ${ki(r)} msgs/sec - [${e.toFixed(2)} secs] ~ ${Dn(this.bytes,e)} ${i}`}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
22
|
`}static header(){return`Test,Date,Lang,Version,Count,MsgPayload,Bytes,Millis,Async
|
|
23
|
-
`}}We.Metric=ot;class Ii{constructor(e,r={msgs:1e5,size:128,subject:"",asyncRequests:!1,pub:!1,sub:!1,req:!1,rep:!1}){l(this,"nc");l(this,"callbacks");l(this,"msgs");l(this,"size");l(this,"subject");l(this,"asyncRequests");l(this,"pub");l(this,"sub");l(this,"req");l(this,"rep");l(this,"perf");l(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||Ti.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):Mi.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:s}=e.protocol.transport;this.pub&&this.sub&&this.perf.measure("pubsub","pubStart","subStop"),this.req&&this.rep&&this.perf.measure("reqrep","reqStart","reqStop");const i=this.perf.getEntries(),a=i.find(p=>p.name==="pubsub"),d=i.find(p=>p.name==="reqrep"),m=i.find(p=>p.name==="req"),S=i.find(p=>p.name==="rep"),_=i.find(p=>p.name==="pub"),x=i.find(p=>p.name==="sub"),E=this.nc.stats(),b=[];if(a){const{name:p,duration:R}=a,M=new ot(p,R);M.msgs=this.msgs*2,M.bytes=E.inBytes+E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(d){const{name:p,duration:R}=d,M=new ot(p,R);M.msgs=this.msgs*2,M.bytes=E.inBytes+E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(_){const{name:p,duration:R}=_,M=new ot(p,R);M.msgs=this.msgs,M.bytes=E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(x){const{name:p,duration:R}=x,M=new ot(p,R);M.msgs=this.msgs,M.bytes=E.inBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(S){const{name:p,duration:R}=S,M=new ot(p,R);M.msgs=this.msgs,M.bytes=E.inBytes+E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(m){const{name:p,duration:R}=m,M=new ot(p,R);M.msgs=this.msgs,M.bytes=E.inBytes+E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}return b}async runCallbacks(){const e=[];if(this.sub){const r=(0,Rr.deferred)();e.push(r);let s=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:()=>{s++,s===1&&this.perf.mark("subStart"),s===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 s=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:(i,a)=>{a.respond(this.payload),s++,s===1&&this.perf.mark("repStart"),s===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 s=0;s<this.msgs;s++)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 s=[];for(let i=0;i<this.msgs;i++)s.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(s),this.perf.mark("reqStop"),this.perf.measure("req","reqStart","reqStop")}else{this.perf.mark("reqStart");for(let s=0;s<this.msgs;s++)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 s=this.nc.subscribe(this.subject,{max:this.msgs}),i=(async()=>{for await(const a of s)r||(this.perf.mark("repStart"),r=!0),a.respond(this.payload);await this.nc.flush(),this.perf.mark("repStop"),this.perf.measure("rep","repStart","repStop")})();e.push(i)}if(this.sub){let r=!1;const s=this.nc.subscribe(this.subject,{max:this.msgs}),i=(async()=>{for await(const a of s)r||(this.perf.mark("subStart"),r=!0);this.perf.mark("subStop"),this.perf.measure("sub","subStart","subStop")})();e.push(i)}if(this.pub){const r=(async()=>{this.perf.mark("pubStart");for(let s=0;s<this.msgs;s++)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 s=[];for(let i=0;i<this.msgs;i++)s.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(s),this.perf.mark("reqStop"),this.perf.measure("req","reqStart","reqStop")}else{this.perf.mark("reqStart");for(let s=0;s<this.msgs;s++)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=Ii;function Dn(t,e){return`${Gn(t/e)}/sec`}function Ri(t,e){return`${Math.floor(t/e)} msgs/sec`}function Gn(t,e=!1){const r=e?1e3:1024,s=e?["k","M","G","T","P","E"]:["K","M","G","T","P","E"],i=e?"iB":"B";if(t<r)return`${t.toFixed(2)} ${i}`;const a=parseInt(Math.log(t)/Math.log(r)+""),d=parseInt(a-1+"");return`${(t/Math.pow(r,a)).toFixed(2)} ${s[d]}${i}`}function ki(t){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}var rr={};Object.defineProperty(rr,"__esModule",{value:!0}),rr.IdleHeartbeatMonitor=void 0;class Ui{constructor(e,r,s={maxOut:2}){l(this,"interval");l(this,"maxOut");l(this,"cancelAfter");l(this,"timer");l(this,"autoCancelTimer");l(this,"last");l(this,"missed");l(this,"count");l(this,"callback");this.interval=e,this.maxOut=(s==null?void 0:s.maxOut)||2,this.cancelAfter=(s==null?void 0:s.cancelAfter)||0,this.last=Date.now(),this.missed=0,this.count=0,this.callback=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,s=2){this.interval=e,this.maxOut=s,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=Ui;var gt={},nr={};Object.defineProperty(nr,"__esModule",{value:!0}),nr.version=void 0,nr.version="3.2.0",Object.defineProperty(gt,"__esModule",{value:!0}),gt.WsTransport=void 0,gt.wsUrlParseFn=Vn,gt.wsconnect=Gi;const Xe=ye,Jn=rt,Li=Nt,$i=nt,qi=Me,Fi=Et,Bi=nr,zn=te,Ki=Bi.version,Di="nats.ws";class Hn{constructor(){l(this,"version");l(this,"lang");l(this,"closeError");l(this,"connected");l(this,"done");l(this,"socket");l(this,"options");l(this,"socketClosed");l(this,"encrypted");l(this,"peeked");l(this,"yields");l(this,"signal");l(this,"closedNotification");this.version=Ki,this.lang=Di,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 s=(0,Xe.deferred)();this.options=r;const i=e.src;if(r.wsFactory){const{socket:a,encrypted:d}=await r.wsFactory(e.src,r);this.socket=a,this.encrypted=d}else this.encrypted=i.indexOf("wss://")===0,this.socket=new WebSocket(i);return this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{this.done&&this._closed(new Error("aborted"))},this.socket.onmessage=a=>{if(this.done)return;if(this.yields.push(new Uint8Array(a.data)),this.peeked){this.signal.resolve();return}const d=$i.DataBuffer.concat(...this.yields),m=(0,Jn.extractProtocolMessage)(d);if(m!==""){const S=qi.INFO.exec(m);if(!S){r.debug&&console.error("!!!",(0,Xe.render)(d)),s.reject(new Error("unexpected response from server"));return}try{const _=JSON.parse(S[1]);(0,Li.checkOptions)(_,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),s.resolve()}catch(_){s.reject(_);return}}},this.socket.onclose=a=>{let d;!a.wasClean&&a.reason!==""&&(d=new Error(a.reason)),this._closed(d),this._cleanup()},this.socket.onerror=a=>{if(this.done)return;const d=a,m=new zn.errors.ConnectionError(d.message);s.reject(m),this._cleanup()},s}_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()}}gt.WsTransport=Hn;function Vn(t,e){/^(.*:\/\/)(.*)/.test(t)||(typeof e=="boolean"?t=`${e===!0?"https":"http"}://${t}`:t=`https://${t}`);let s=new URL(t);const i=s.protocol.toLowerCase();i==="ws:"&&(e=!1),i==="wss:"&&(e=!0),i!=="https:"&&i!=="http"&&(t=t.replace(/^(.*:\/\/)(.*)/gm,"$2"),s=new URL(`http://${t}`));let a,d;const m=s.hostname,S=s.pathname,_=s.search||"";switch(i){case"http:":case"ws:":case"nats:":d=s.port||"80",a="ws:";break;case"https:":case"wss:":case"tls:":d=s.port||"443",a="wss:";break;default:d=s.port||e===!0?"443":"80",a=e===!0?"wss:":"ws:";break}return`${a}//${m}:${d}${S}${_}`}function Gi(t={}){return(0,Jn.setTransportFactory)({defaultPort:443,urlParseFn:Vn,factory:()=>{if(t.tls)throw zn.InvalidArgumentError.format("tls","is not configurable on w3c websocket connections");return new Hn}}),Fi.NatsConnectionImpl.connect(t)}(function(t){var e=he&&he.__createBinding||(Object.create?function(He,Pe,Ie,Re){Re===void 0&&(Re=Ie);var Ue=Object.getOwnPropertyDescriptor(Pe,Ie);(!Ue||("get"in Ue?!Pe.__esModule:Ue.writable||Ue.configurable))&&(Ue={enumerable:!0,get:function(){return Pe[Ie]}}),Object.defineProperty(He,Re,Ue)}:function(He,Pe,Ie,Re){Re===void 0&&(Re=Ie),He[Re]=Pe[Ie]}),r=he&&he.__exportStar||function(He,Pe){for(var Ie in He)Ie!=="default"&&!Object.prototype.hasOwnProperty.call(Pe,Ie)&&e(Pe,He,Ie)};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 s=Et;Object.defineProperty(t,"NatsConnectionImpl",{enumerable:!0,get:function(){return s.NatsConnectionImpl}});var i=St;Object.defineProperty(t,"Nuid",{enumerable:!0,get:function(){return i.Nuid}}),Object.defineProperty(t,"nuid",{enumerable:!0,get:function(){return i.nuid}});var a=Ct;Object.defineProperty(t,"MsgImpl",{enumerable:!0,get:function(){return a.MsgImpl}});var d=rt;Object.defineProperty(t,"getResolveFn",{enumerable:!0,get:function(){return d.getResolveFn}}),Object.defineProperty(t,"setTransportFactory",{enumerable:!0,get:function(){return d.setTransportFactory}});var m=Me;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 S=ye;Object.defineProperty(t,"backoff",{enumerable:!0,get:function(){return S.backoff}}),Object.defineProperty(t,"collect",{enumerable:!0,get:function(){return S.collect}}),Object.defineProperty(t,"deadline",{enumerable:!0,get:function(){return S.deadline}}),Object.defineProperty(t,"deferred",{enumerable:!0,get:function(){return S.deferred}}),Object.defineProperty(t,"delay",{enumerable:!0,get:function(){return S.delay}}),Object.defineProperty(t,"extend",{enumerable:!0,get:function(){return S.extend}}),Object.defineProperty(t,"millis",{enumerable:!0,get:function(){return S.millis}}),Object.defineProperty(t,"nanos",{enumerable:!0,get:function(){return S.nanos}}),Object.defineProperty(t,"render",{enumerable:!0,get:function(){return S.render}}),Object.defineProperty(t,"SimpleMutex",{enumerable:!0,get:function(){return S.SimpleMutex}}),Object.defineProperty(t,"timeout",{enumerable:!0,get:function(){return S.timeout}});var _=Qe;Object.defineProperty(t,"canonicalMIMEHeaderKey",{enumerable:!0,get:function(){return _.canonicalMIMEHeaderKey}}),Object.defineProperty(t,"headers",{enumerable:!0,get:function(){return _.headers}}),Object.defineProperty(t,"MsgHdrsImpl",{enumerable:!0,get:function(){return _.MsgHdrsImpl}});var x=Ot;Object.defineProperty(t,"Heartbeat",{enumerable:!0,get:function(){return x.Heartbeat}});var E=At;Object.defineProperty(t,"MuxSubscription",{enumerable:!0,get:function(){return E.MuxSubscription}});var b=nt;Object.defineProperty(t,"DataBuffer",{enumerable:!0,get:function(){return b.DataBuffer}});var p=Nt;Object.defineProperty(t,"buildAuthenticator",{enumerable:!0,get:function(){return p.buildAuthenticator}}),Object.defineProperty(t,"checkOptions",{enumerable:!0,get:function(){return p.checkOptions}}),Object.defineProperty(t,"checkUnsupportedOption",{enumerable:!0,get:function(){return p.checkUnsupportedOption}}),Object.defineProperty(t,"DEFAULT_MAX_RECONNECT_ATTEMPTS",{enumerable:!0,get:function(){return p.DEFAULT_MAX_RECONNECT_ATTEMPTS}}),Object.defineProperty(t,"defaultOptions",{enumerable:!0,get:function(){return p.defaultOptions}}),Object.defineProperty(t,"hasWsProtocol",{enumerable:!0,get:function(){return p.hasWsProtocol}}),Object.defineProperty(t,"parseOptions",{enumerable:!0,get:function(){return p.parseOptions}});var R=Ye;Object.defineProperty(t,"RequestOne",{enumerable:!0,get:function(){return R.RequestOne}});var M=De;Object.defineProperty(t,"credsAuthenticator",{enumerable:!0,get:function(){return M.credsAuthenticator}}),Object.defineProperty(t,"jwtAuthenticator",{enumerable:!0,get:function(){return M.jwtAuthenticator}}),Object.defineProperty(t,"nkeyAuthenticator",{enumerable:!0,get:function(){return M.nkeyAuthenticator}}),Object.defineProperty(t,"tokenAuthenticator",{enumerable:!0,get:function(){return M.tokenAuthenticator}}),Object.defineProperty(t,"usernamePasswordAuthenticator",{enumerable:!0,get:function(){return M.usernamePasswordAuthenticator}}),r(jt,t);var U=dt;Object.defineProperty(t,"QueuedIteratorImpl",{enumerable:!0,get:function(){return U.QueuedIteratorImpl}});var se=pr;Object.defineProperty(t,"Kind",{enumerable:!0,get:function(){return se.Kind}}),Object.defineProperty(t,"Parser",{enumerable:!0,get:function(){return se.Parser}}),Object.defineProperty(t,"State",{enumerable:!0,get:function(){return se.State}});var ge=wr;Object.defineProperty(t,"DenoBuffer",{enumerable:!0,get:function(){return ge.DenoBuffer}}),Object.defineProperty(t,"MAX_SIZE",{enumerable:!0,get:function(){return ge.MAX_SIZE}}),Object.defineProperty(t,"readAll",{enumerable:!0,get:function(){return ge.readAll}}),Object.defineProperty(t,"writeAll",{enumerable:!0,get:function(){return ge.writeAll}});var $e=We;Object.defineProperty(t,"Bench",{enumerable:!0,get:function(){return $e.Bench}}),Object.defineProperty(t,"Metric",{enumerable:!0,get:function(){return $e.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 de=ut;Object.defineProperty(t,"ipV4",{enumerable:!0,get:function(){return de.ipV4}}),Object.defineProperty(t,"isIP",{enumerable:!0,get:function(){return de.isIP}}),Object.defineProperty(t,"parseIP",{enumerable:!0,get:function(){return de.parseIP}});var le=Xt;Object.defineProperty(t,"compare",{enumerable:!0,get:function(){return le.compare}}),Object.defineProperty(t,"Feature",{enumerable:!0,get:function(){return le.Feature}}),Object.defineProperty(t,"Features",{enumerable:!0,get:function(){return le.Features}}),Object.defineProperty(t,"parseSemVer",{enumerable:!0,get:function(){return le.parseSemVer}});var ze=Ir;Object.defineProperty(t,"Empty",{enumerable:!0,get:function(){return ze.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 mt=Oe;Object.defineProperty(t,"createInbox",{enumerable:!0,get:function(){return mt.createInbox}}),Object.defineProperty(t,"Match",{enumerable:!0,get:function(){return mt.Match}}),Object.defineProperty(t,"syncIterator",{enumerable:!0,get:function(){return mt.syncIterator}});var _t=Me;Object.defineProperty(t,"SubscriptionImpl",{enumerable:!0,get:function(){return _t.SubscriptionImpl}}),Object.defineProperty(t,"Subscriptions",{enumerable:!0,get:function(){return _t.Subscriptions}});var vt=rr;Object.defineProperty(t,"IdleHeartbeatMonitor",{enumerable:!0,get:function(){return vt.IdleHeartbeatMonitor}});var pt=Ve;Object.defineProperty(t,"isIPV4OrHostname",{enumerable:!0,get:function(){return pt.isIPV4OrHostname}}),Object.defineProperty(t,"Servers",{enumerable:!0,get:function(){return pt.Servers}});var $t=gt;Object.defineProperty(t,"wsconnect",{enumerable:!0,get:function(){return $t.wsconnect}}),Object.defineProperty(t,"wsUrlParseFn",{enumerable:!0,get:function(){return $t.wsUrlParseFn}});var Se=te;Object.defineProperty(t,"AuthorizationError",{enumerable:!0,get:function(){return Se.AuthorizationError}}),Object.defineProperty(t,"ClosedConnectionError",{enumerable:!0,get:function(){return Se.ClosedConnectionError}}),Object.defineProperty(t,"ConnectionError",{enumerable:!0,get:function(){return Se.ConnectionError}}),Object.defineProperty(t,"DrainingConnectionError",{enumerable:!0,get:function(){return Se.DrainingConnectionError}}),Object.defineProperty(t,"errors",{enumerable:!0,get:function(){return Se.errors}}),Object.defineProperty(t,"InvalidArgumentError",{enumerable:!0,get:function(){return Se.InvalidArgumentError}}),Object.defineProperty(t,"InvalidOperationError",{enumerable:!0,get:function(){return Se.InvalidOperationError}}),Object.defineProperty(t,"InvalidSubjectError",{enumerable:!0,get:function(){return Se.InvalidSubjectError}}),Object.defineProperty(t,"NoRespondersError",{enumerable:!0,get:function(){return Se.NoRespondersError}}),Object.defineProperty(t,"PermissionViolationError",{enumerable:!0,get:function(){return Se.PermissionViolationError}}),Object.defineProperty(t,"ProtocolError",{enumerable:!0,get:function(){return Se.ProtocolError}}),Object.defineProperty(t,"RequestError",{enumerable:!0,get:function(){return Se.RequestError}}),Object.defineProperty(t,"TimeoutError",{enumerable:!0,get:function(){return Se.TimeoutError}}),Object.defineProperty(t,"UserAuthenticationExpiredError",{enumerable:!0,get:function(){return Se.UserAuthenticationExpiredError}})})(Hr),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=Hr;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}})}(zr);class Ji{constructor(e){l(this,"defaultTimeout");this.natsConnection=e,this.defaultTimeout=parseInt(process.env.NATS_REQUEST_TIMEOUT||"5000",10)}async addCommunicationLinks(e,r="",s){let i="communication.link.users.add";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async addGroupMember(e,r="",s){let i="directory.group.member.add";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async addLinkBetweenGroups(e,r="",s){let i="communication.link.groups.add";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async checkResourceAccess(e,r,s,i="",a){let d="audience.check.right."+r+"."+s;i&&(d=`${i}.${d}`),console.debug("Sending request to NATS subject",{messageAddress:d});const m=await this.natsConnection.request(d,JSON.stringify(e),this.toNatsOptions(a));if(!m)throw console.warn("No reply received for subject",{messageAddress:d}),new Error("No reply received");return this.extractResponse(m.json())}async createAndStoreEvent(e,r="",s){let i="event.store.create";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async createManualGroup(e,r="",s){let i="directory.group.manual.create";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async deleteManualGroup(e,r="",s){let i="directory.group.manual.delete";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async fetchTranslations(e,r,s="",i){let a="i18n."+r+".fetch";s&&(a=`${s}.${a}`),console.debug("Sending request to NATS subject",{messageAddress:a});const d=await this.natsConnection.request(a,JSON.stringify(e),this.toNatsOptions(i));if(!d)throw console.warn("No reply received for subject",{messageAddress:a}),new Error("No reply received");return this.extractResponse(d.json())}async findGroupByExternalId(e,r="",s){let i="directory.group.find.byexternalid";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async findSession(e,r="",s){let i="session.find";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async getRedirectConfig(e,r="",s){let i="config.redirect";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async getResources(e,r,s="",i){let a="resource.get."+r;s&&(a=`${s}.${a}`),console.debug("Sending request to NATS subject",{messageAddress:a});const d=await this.natsConnection.request(a,JSON.stringify(e),this.toNatsOptions(i));if(!d)throw console.warn("No reply received for subject",{messageAddress:a}),new Error("No reply received");return this.extractResponse(d.json())}async getUserDisplayNames(e,r="",s){let i="directory.users.get.displaynames";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async getUsersByIds(e,r="",s){let i="directory.users.get.byids";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async getUsersFromGroups(e,r="",s){let i="directory.users.get.bygroupids";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async listenAndReplyExample(e,r="",s){let i="ent.test.listen.reply";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async listenOnlyExample(e,r="",s){let i="ent.test.listen";r&&(i=`${r}.${i}`),console.debug("Publishing to NATS subject",{messageAddress:i}),this.natsConnection.publish(i,JSON.stringify(e),this.toNatsOptions(s))}async loadTest(e,r="",s){let i="ent.loadtest";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async recreateCommunicationLinks(e,r="",s){let i="communication.link.users.recreate";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async refreshSession(e,r="",s){let i="session.refresh";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async registerApp(e,r="",s){let i="ent.appregistry.app.register";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async registerI18nFiles(e,r,s="",i){let a="i18n."+r+".register";s&&(a=`${s}.${a}`),console.debug("Sending request to NATS subject",{messageAddress:a});const d=await this.natsConnection.request(a,JSON.stringify(e),this.toNatsOptions(i));if(!d)throw console.warn("No reply received for subject",{messageAddress:a}),new Error("No reply received");return this.extractResponse(d.json())}async registerNotification(e,r="",s){let i="timeline.notification.register";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async registerNotifications(e,r="",s){let i="timeline.notification.register.batch";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async registerTimelineI18n(e,r="",s){let i="timeline.i18n.register";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async removeCommunicationLinks(e,r="",s){let i="communication.link.users.remove";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async removeGroupMember(e,r="",s){let i="directory.group.member.delete";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async removeGroupShares(e,r,s="",i){let a="share.group.remove."+r;s&&(a=`${s}.${a}`),console.debug("Sending request to NATS subject",{messageAddress:a});const d=await this.natsConnection.request(a,JSON.stringify(e),this.toNatsOptions(i));if(!d)throw console.warn("No reply received for subject",{messageAddress:a}),new Error("No reply received");return this.extractResponse(d.json())}async sendNotification(e,r="",s){let i="timeline.notification.send";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async updateManualGroup(e,r="",s){let i="directory.group.manual.update";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async updateWikiContent(e,r="",s){let i="ai.wiki.content.updated";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async updateWikiStructure(e,r="",s){let i="ai.wiki.structure.updated";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async upsertGroupShares(e,r,s="",i){let a="share.group.upsert."+r;s&&(a=`${s}.${a}`),console.debug("Sending request to NATS subject",{messageAddress:a});const d=await this.natsConnection.request(a,JSON.stringify(e),this.toNatsOptions(i));if(!d)throw console.warn("No reply received for subject",{messageAddress:a}),new Error("No reply received");return this.extractResponse(d.json())}extractResponse(e){return e.response||e}toNatsOptions(e){const s={timeout:(e==null?void 0:e.timeout)??this.defaultTimeout};if(e!=null&&e.headers){const i=zr.headers();for(const[a,d]of Object.entries(e.headers))Array.isArray(d)?d.forEach(m=>i.append(a,m)):i.set(a,d);s.headers=i}return s}}Te.EntNatsServiceClient=Ji,Object.defineProperty(Te,Symbol.toStringTag,{value:"Module"})});
|
|
23
|
+
`}}We.Metric=ot;class Ii{constructor(e,r={msgs:1e5,size:128,subject:"",asyncRequests:!1,pub:!1,sub:!1,req:!1,rep:!1}){l(this,"nc");l(this,"callbacks");l(this,"msgs");l(this,"size");l(this,"subject");l(this,"asyncRequests");l(this,"pub");l(this,"sub");l(this,"req");l(this,"rep");l(this,"perf");l(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||Ti.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):Mi.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:s}=e.protocol.transport;this.pub&&this.sub&&this.perf.measure("pubsub","pubStart","subStop"),this.req&&this.rep&&this.perf.measure("reqrep","reqStart","reqStop");const i=this.perf.getEntries(),a=i.find(p=>p.name==="pubsub"),d=i.find(p=>p.name==="reqrep"),m=i.find(p=>p.name==="req"),S=i.find(p=>p.name==="rep"),_=i.find(p=>p.name==="pub"),x=i.find(p=>p.name==="sub"),E=this.nc.stats(),b=[];if(a){const{name:p,duration:R}=a,M=new ot(p,R);M.msgs=this.msgs*2,M.bytes=E.inBytes+E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(d){const{name:p,duration:R}=d,M=new ot(p,R);M.msgs=this.msgs*2,M.bytes=E.inBytes+E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(_){const{name:p,duration:R}=_,M=new ot(p,R);M.msgs=this.msgs,M.bytes=E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(x){const{name:p,duration:R}=x,M=new ot(p,R);M.msgs=this.msgs,M.bytes=E.inBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(S){const{name:p,duration:R}=S,M=new ot(p,R);M.msgs=this.msgs,M.bytes=E.inBytes+E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}if(m){const{name:p,duration:R}=m,M=new ot(p,R);M.msgs=this.msgs,M.bytes=E.inBytes+E.outBytes,M.lang=r,M.version=s,M.payload=this.payload.length,b.push(M)}return b}async runCallbacks(){const e=[];if(this.sub){const r=(0,Rr.deferred)();e.push(r);let s=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:()=>{s++,s===1&&this.perf.mark("subStart"),s===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 s=0;this.nc.subscribe(this.subject,{max:this.msgs,callback:(i,a)=>{a.respond(this.payload),s++,s===1&&this.perf.mark("repStart"),s===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 s=0;s<this.msgs;s++)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 s=[];for(let i=0;i<this.msgs;i++)s.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(s),this.perf.mark("reqStop"),this.perf.measure("req","reqStart","reqStop")}else{this.perf.mark("reqStart");for(let s=0;s<this.msgs;s++)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 s=this.nc.subscribe(this.subject,{max:this.msgs}),i=(async()=>{for await(const a of s)r||(this.perf.mark("repStart"),r=!0),a.respond(this.payload);await this.nc.flush(),this.perf.mark("repStop"),this.perf.measure("rep","repStart","repStop")})();e.push(i)}if(this.sub){let r=!1;const s=this.nc.subscribe(this.subject,{max:this.msgs}),i=(async()=>{for await(const a of s)r||(this.perf.mark("subStart"),r=!0);this.perf.mark("subStop"),this.perf.measure("sub","subStart","subStop")})();e.push(i)}if(this.pub){const r=(async()=>{this.perf.mark("pubStart");for(let s=0;s<this.msgs;s++)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 s=[];for(let i=0;i<this.msgs;i++)s.push(this.nc.request(this.subject,this.payload,{timeout:2e4}));await Promise.all(s),this.perf.mark("reqStop"),this.perf.measure("req","reqStart","reqStop")}else{this.perf.mark("reqStart");for(let s=0;s<this.msgs;s++)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=Ii;function Dn(t,e){return`${Gn(t/e)}/sec`}function Ri(t,e){return`${Math.floor(t/e)} msgs/sec`}function Gn(t,e=!1){const r=e?1e3:1024,s=e?["k","M","G","T","P","E"]:["K","M","G","T","P","E"],i=e?"iB":"B";if(t<r)return`${t.toFixed(2)} ${i}`;const a=parseInt(Math.log(t)/Math.log(r)+""),d=parseInt(a-1+"");return`${(t/Math.pow(r,a)).toFixed(2)} ${s[d]}${i}`}function ki(t){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}var rr={};Object.defineProperty(rr,"__esModule",{value:!0}),rr.IdleHeartbeatMonitor=void 0;class Ui{constructor(e,r,s={maxOut:2}){l(this,"interval");l(this,"maxOut");l(this,"cancelAfter");l(this,"timer");l(this,"autoCancelTimer");l(this,"last");l(this,"missed");l(this,"count");l(this,"callback");this.interval=e,this.maxOut=(s==null?void 0:s.maxOut)||2,this.cancelAfter=(s==null?void 0:s.cancelAfter)||0,this.last=Date.now(),this.missed=0,this.count=0,this.callback=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,s=2){this.interval=e,this.maxOut=s,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=Ui;var gt={},nr={};Object.defineProperty(nr,"__esModule",{value:!0}),nr.version=void 0,nr.version="3.2.0",Object.defineProperty(gt,"__esModule",{value:!0}),gt.WsTransport=void 0,gt.wsUrlParseFn=Vn,gt.wsconnect=Gi;const Xe=ye,Jn=rt,Li=Ct,$i=nt,qi=Me,Fi=Et,Bi=nr,zn=te,Ki=Bi.version,Di="nats.ws";class Hn{constructor(){l(this,"version");l(this,"lang");l(this,"closeError");l(this,"connected");l(this,"done");l(this,"socket");l(this,"options");l(this,"socketClosed");l(this,"encrypted");l(this,"peeked");l(this,"yields");l(this,"signal");l(this,"closedNotification");this.version=Ki,this.lang=Di,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 s=(0,Xe.deferred)();this.options=r;const i=e.src;if(r.wsFactory){const{socket:a,encrypted:d}=await r.wsFactory(e.src,r);this.socket=a,this.encrypted=d}else this.encrypted=i.indexOf("wss://")===0,this.socket=new WebSocket(i);return this.socket.binaryType="arraybuffer",this.socket.onopen=()=>{this.done&&this._closed(new Error("aborted"))},this.socket.onmessage=a=>{if(this.done)return;if(this.yields.push(new Uint8Array(a.data)),this.peeked){this.signal.resolve();return}const d=$i.DataBuffer.concat(...this.yields),m=(0,Jn.extractProtocolMessage)(d);if(m!==""){const S=qi.INFO.exec(m);if(!S){r.debug&&console.error("!!!",(0,Xe.render)(d)),s.reject(new Error("unexpected response from server"));return}try{const _=JSON.parse(S[1]);(0,Li.checkOptions)(_,this.options),this.peeked=!0,this.connected=!0,this.signal.resolve(),s.resolve()}catch(_){s.reject(_);return}}},this.socket.onclose=a=>{let d;!a.wasClean&&a.reason!==""&&(d=new Error(a.reason)),this._closed(d),this._cleanup()},this.socket.onerror=a=>{if(this.done)return;const d=a,m=new zn.errors.ConnectionError(d.message);s.reject(m),this._cleanup()},s}_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()}}gt.WsTransport=Hn;function Vn(t,e){/^(.*:\/\/)(.*)/.test(t)||(typeof e=="boolean"?t=`${e===!0?"https":"http"}://${t}`:t=`https://${t}`);let s=new URL(t);const i=s.protocol.toLowerCase();i==="ws:"&&(e=!1),i==="wss:"&&(e=!0),i!=="https:"&&i!=="http"&&(t=t.replace(/^(.*:\/\/)(.*)/gm,"$2"),s=new URL(`http://${t}`));let a,d;const m=s.hostname,S=s.pathname,_=s.search||"";switch(i){case"http:":case"ws:":case"nats:":d=s.port||"80",a="ws:";break;case"https:":case"wss:":case"tls:":d=s.port||"443",a="wss:";break;default:d=s.port||e===!0?"443":"80",a=e===!0?"wss:":"ws:";break}return`${a}//${m}:${d}${S}${_}`}function Gi(t={}){return(0,Jn.setTransportFactory)({defaultPort:443,urlParseFn:Vn,factory:()=>{if(t.tls)throw zn.InvalidArgumentError.format("tls","is not configurable on w3c websocket connections");return new Hn}}),Fi.NatsConnectionImpl.connect(t)}(function(t){var e=he&&he.__createBinding||(Object.create?function(He,Pe,Ie,Re){Re===void 0&&(Re=Ie);var Ue=Object.getOwnPropertyDescriptor(Pe,Ie);(!Ue||("get"in Ue?!Pe.__esModule:Ue.writable||Ue.configurable))&&(Ue={enumerable:!0,get:function(){return Pe[Ie]}}),Object.defineProperty(He,Re,Ue)}:function(He,Pe,Ie,Re){Re===void 0&&(Re=Ie),He[Re]=Pe[Ie]}),r=he&&he.__exportStar||function(He,Pe){for(var Ie in He)Ie!=="default"&&!Object.prototype.hasOwnProperty.call(Pe,Ie)&&e(Pe,He,Ie)};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 s=Et;Object.defineProperty(t,"NatsConnectionImpl",{enumerable:!0,get:function(){return s.NatsConnectionImpl}});var i=St;Object.defineProperty(t,"Nuid",{enumerable:!0,get:function(){return i.Nuid}}),Object.defineProperty(t,"nuid",{enumerable:!0,get:function(){return i.nuid}});var a=Nt;Object.defineProperty(t,"MsgImpl",{enumerable:!0,get:function(){return a.MsgImpl}});var d=rt;Object.defineProperty(t,"getResolveFn",{enumerable:!0,get:function(){return d.getResolveFn}}),Object.defineProperty(t,"setTransportFactory",{enumerable:!0,get:function(){return d.setTransportFactory}});var m=Me;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 S=ye;Object.defineProperty(t,"backoff",{enumerable:!0,get:function(){return S.backoff}}),Object.defineProperty(t,"collect",{enumerable:!0,get:function(){return S.collect}}),Object.defineProperty(t,"deadline",{enumerable:!0,get:function(){return S.deadline}}),Object.defineProperty(t,"deferred",{enumerable:!0,get:function(){return S.deferred}}),Object.defineProperty(t,"delay",{enumerable:!0,get:function(){return S.delay}}),Object.defineProperty(t,"extend",{enumerable:!0,get:function(){return S.extend}}),Object.defineProperty(t,"millis",{enumerable:!0,get:function(){return S.millis}}),Object.defineProperty(t,"nanos",{enumerable:!0,get:function(){return S.nanos}}),Object.defineProperty(t,"render",{enumerable:!0,get:function(){return S.render}}),Object.defineProperty(t,"SimpleMutex",{enumerable:!0,get:function(){return S.SimpleMutex}}),Object.defineProperty(t,"timeout",{enumerable:!0,get:function(){return S.timeout}});var _=Qe;Object.defineProperty(t,"canonicalMIMEHeaderKey",{enumerable:!0,get:function(){return _.canonicalMIMEHeaderKey}}),Object.defineProperty(t,"headers",{enumerable:!0,get:function(){return _.headers}}),Object.defineProperty(t,"MsgHdrsImpl",{enumerable:!0,get:function(){return _.MsgHdrsImpl}});var x=Ot;Object.defineProperty(t,"Heartbeat",{enumerable:!0,get:function(){return x.Heartbeat}});var E=At;Object.defineProperty(t,"MuxSubscription",{enumerable:!0,get:function(){return E.MuxSubscription}});var b=nt;Object.defineProperty(t,"DataBuffer",{enumerable:!0,get:function(){return b.DataBuffer}});var p=Ct;Object.defineProperty(t,"buildAuthenticator",{enumerable:!0,get:function(){return p.buildAuthenticator}}),Object.defineProperty(t,"checkOptions",{enumerable:!0,get:function(){return p.checkOptions}}),Object.defineProperty(t,"checkUnsupportedOption",{enumerable:!0,get:function(){return p.checkUnsupportedOption}}),Object.defineProperty(t,"DEFAULT_MAX_RECONNECT_ATTEMPTS",{enumerable:!0,get:function(){return p.DEFAULT_MAX_RECONNECT_ATTEMPTS}}),Object.defineProperty(t,"defaultOptions",{enumerable:!0,get:function(){return p.defaultOptions}}),Object.defineProperty(t,"hasWsProtocol",{enumerable:!0,get:function(){return p.hasWsProtocol}}),Object.defineProperty(t,"parseOptions",{enumerable:!0,get:function(){return p.parseOptions}});var R=Ye;Object.defineProperty(t,"RequestOne",{enumerable:!0,get:function(){return R.RequestOne}});var M=De;Object.defineProperty(t,"credsAuthenticator",{enumerable:!0,get:function(){return M.credsAuthenticator}}),Object.defineProperty(t,"jwtAuthenticator",{enumerable:!0,get:function(){return M.jwtAuthenticator}}),Object.defineProperty(t,"nkeyAuthenticator",{enumerable:!0,get:function(){return M.nkeyAuthenticator}}),Object.defineProperty(t,"tokenAuthenticator",{enumerable:!0,get:function(){return M.tokenAuthenticator}}),Object.defineProperty(t,"usernamePasswordAuthenticator",{enumerable:!0,get:function(){return M.usernamePasswordAuthenticator}}),r(jt,t);var U=dt;Object.defineProperty(t,"QueuedIteratorImpl",{enumerable:!0,get:function(){return U.QueuedIteratorImpl}});var se=pr;Object.defineProperty(t,"Kind",{enumerable:!0,get:function(){return se.Kind}}),Object.defineProperty(t,"Parser",{enumerable:!0,get:function(){return se.Parser}}),Object.defineProperty(t,"State",{enumerable:!0,get:function(){return se.State}});var ge=wr;Object.defineProperty(t,"DenoBuffer",{enumerable:!0,get:function(){return ge.DenoBuffer}}),Object.defineProperty(t,"MAX_SIZE",{enumerable:!0,get:function(){return ge.MAX_SIZE}}),Object.defineProperty(t,"readAll",{enumerable:!0,get:function(){return ge.readAll}}),Object.defineProperty(t,"writeAll",{enumerable:!0,get:function(){return ge.writeAll}});var $e=We;Object.defineProperty(t,"Bench",{enumerable:!0,get:function(){return $e.Bench}}),Object.defineProperty(t,"Metric",{enumerable:!0,get:function(){return $e.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 de=ut;Object.defineProperty(t,"ipV4",{enumerable:!0,get:function(){return de.ipV4}}),Object.defineProperty(t,"isIP",{enumerable:!0,get:function(){return de.isIP}}),Object.defineProperty(t,"parseIP",{enumerable:!0,get:function(){return de.parseIP}});var le=Xt;Object.defineProperty(t,"compare",{enumerable:!0,get:function(){return le.compare}}),Object.defineProperty(t,"Feature",{enumerable:!0,get:function(){return le.Feature}}),Object.defineProperty(t,"Features",{enumerable:!0,get:function(){return le.Features}}),Object.defineProperty(t,"parseSemVer",{enumerable:!0,get:function(){return le.parseSemVer}});var ze=Ir;Object.defineProperty(t,"Empty",{enumerable:!0,get:function(){return ze.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 mt=Oe;Object.defineProperty(t,"createInbox",{enumerable:!0,get:function(){return mt.createInbox}}),Object.defineProperty(t,"Match",{enumerable:!0,get:function(){return mt.Match}}),Object.defineProperty(t,"syncIterator",{enumerable:!0,get:function(){return mt.syncIterator}});var _t=Me;Object.defineProperty(t,"SubscriptionImpl",{enumerable:!0,get:function(){return _t.SubscriptionImpl}}),Object.defineProperty(t,"Subscriptions",{enumerable:!0,get:function(){return _t.Subscriptions}});var vt=rr;Object.defineProperty(t,"IdleHeartbeatMonitor",{enumerable:!0,get:function(){return vt.IdleHeartbeatMonitor}});var pt=Ve;Object.defineProperty(t,"isIPV4OrHostname",{enumerable:!0,get:function(){return pt.isIPV4OrHostname}}),Object.defineProperty(t,"Servers",{enumerable:!0,get:function(){return pt.Servers}});var $t=gt;Object.defineProperty(t,"wsconnect",{enumerable:!0,get:function(){return $t.wsconnect}}),Object.defineProperty(t,"wsUrlParseFn",{enumerable:!0,get:function(){return $t.wsUrlParseFn}});var Se=te;Object.defineProperty(t,"AuthorizationError",{enumerable:!0,get:function(){return Se.AuthorizationError}}),Object.defineProperty(t,"ClosedConnectionError",{enumerable:!0,get:function(){return Se.ClosedConnectionError}}),Object.defineProperty(t,"ConnectionError",{enumerable:!0,get:function(){return Se.ConnectionError}}),Object.defineProperty(t,"DrainingConnectionError",{enumerable:!0,get:function(){return Se.DrainingConnectionError}}),Object.defineProperty(t,"errors",{enumerable:!0,get:function(){return Se.errors}}),Object.defineProperty(t,"InvalidArgumentError",{enumerable:!0,get:function(){return Se.InvalidArgumentError}}),Object.defineProperty(t,"InvalidOperationError",{enumerable:!0,get:function(){return Se.InvalidOperationError}}),Object.defineProperty(t,"InvalidSubjectError",{enumerable:!0,get:function(){return Se.InvalidSubjectError}}),Object.defineProperty(t,"NoRespondersError",{enumerable:!0,get:function(){return Se.NoRespondersError}}),Object.defineProperty(t,"PermissionViolationError",{enumerable:!0,get:function(){return Se.PermissionViolationError}}),Object.defineProperty(t,"ProtocolError",{enumerable:!0,get:function(){return Se.ProtocolError}}),Object.defineProperty(t,"RequestError",{enumerable:!0,get:function(){return Se.RequestError}}),Object.defineProperty(t,"TimeoutError",{enumerable:!0,get:function(){return Se.TimeoutError}}),Object.defineProperty(t,"UserAuthenticationExpiredError",{enumerable:!0,get:function(){return Se.UserAuthenticationExpiredError}})})(Hr),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=Hr;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}})}(zr);class Ji{constructor(e){l(this,"defaultTimeout");this.natsConnection=e,this.defaultTimeout=parseInt(process.env.NATS_REQUEST_TIMEOUT||"5000",10)}async addCommunicationLinks(e,r="",s){let i="communication.link.users.add";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async addGroupMember(e,r="",s){let i="directory.group.member.add";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async addLinkBetweenGroups(e,r="",s){let i="communication.link.groups.add";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async checkResourceAccess(e,r,s,i="",a){let d="audience.check.right."+r+"."+s;i&&(d=`${i}.${d}`),console.debug("Sending request to NATS subject",{messageAddress:d});const m=await this.natsConnection.request(d,JSON.stringify(e),this.toNatsOptions(a));if(!m)throw console.warn("No reply received for subject",{messageAddress:d}),new Error("No reply received");return this.extractResponse(m.json())}async createAndStoreEvent(e,r="",s){let i="event.store.create";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async createManualGroup(e,r="",s){let i="directory.group.manual.create";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async deleteManualGroup(e,r="",s){let i="directory.group.manual.delete";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async fetchTranslations(e,r,s="",i){let a="i18n."+r+".fetch";s&&(a=`${s}.${a}`),console.debug("Sending request to NATS subject",{messageAddress:a});const d=await this.natsConnection.request(a,JSON.stringify(e),this.toNatsOptions(i));if(!d)throw console.warn("No reply received for subject",{messageAddress:a}),new Error("No reply received");return this.extractResponse(d.json())}async findGroupByExternalId(e,r="",s){let i="directory.group.find.byexternalid";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async findSession(e,r="",s){let i="session.find";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async getClassAdminUsers(e,r="",s){let i="directory.class.admin.by.id";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async getRedirectConfig(e,r="",s){let i="config.redirect";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async getResources(e,r,s="",i){let a="resource.get."+r;s&&(a=`${s}.${a}`),console.debug("Sending request to NATS subject",{messageAddress:a});const d=await this.natsConnection.request(a,JSON.stringify(e),this.toNatsOptions(i));if(!d)throw console.warn("No reply received for subject",{messageAddress:a}),new Error("No reply received");return this.extractResponse(d.json())}async getStructureUsers(e,r="",s){let i="directory.structure.users.by.id";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async getUserDisplayNames(e,r="",s){let i="directory.users.get.displaynames";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async getUserInClassWithParams(e,r="",s){let i="directory.class.by.id.with.params";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async getUsersByIds(e,r="",s){let i="directory.users.get.byids";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async getUsersFromGroups(e,r="",s){let i="directory.users.get.bygroupids";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async listenAndReplyExample(e,r="",s){let i="ent.test.listen.reply";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async listenOnlyExample(e,r="",s){let i="ent.test.listen";r&&(i=`${r}.${i}`),console.debug("Publishing to NATS subject",{messageAddress:i}),this.natsConnection.publish(i,JSON.stringify(e),this.toNatsOptions(s))}async loadTest(e,r="",s){let i="ent.loadtest";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async recreateCommunicationLinks(e,r="",s){let i="communication.link.users.recreate";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async refreshSession(e,r="",s){let i="session.refresh";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async registerApp(e,r="",s){let i="ent.appregistry.app.register";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async registerI18nFiles(e,r,s="",i){let a="i18n."+r+".register";s&&(a=`${s}.${a}`),console.debug("Sending request to NATS subject",{messageAddress:a});const d=await this.natsConnection.request(a,JSON.stringify(e),this.toNatsOptions(i));if(!d)throw console.warn("No reply received for subject",{messageAddress:a}),new Error("No reply received");return this.extractResponse(d.json())}async registerNotification(e,r="",s){let i="timeline.notification.register";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async registerNotifications(e,r="",s){let i="timeline.notification.register.batch";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async registerTimelineI18n(e,r="",s){let i="timeline.i18n.register";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async removeCommunicationLinks(e,r="",s){let i="communication.link.users.remove";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async removeGroupMember(e,r="",s){let i="directory.group.member.delete";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async removeGroupShares(e,r,s="",i){let a="share.group.remove."+r;s&&(a=`${s}.${a}`),console.debug("Sending request to NATS subject",{messageAddress:a});const d=await this.natsConnection.request(a,JSON.stringify(e),this.toNatsOptions(i));if(!d)throw console.warn("No reply received for subject",{messageAddress:a}),new Error("No reply received");return this.extractResponse(d.json())}async sendNotification(e,r="",s){let i="timeline.notification.send";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async updateManualGroup(e,r="",s){let i="directory.group.manual.update";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async updateWikiContent(e,r="",s){let i="ai.wiki.content.updated";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async updateWikiStructure(e,r="",s){let i="ai.wiki.structure.updated";r&&(i=`${r}.${i}`),console.debug("Sending request to NATS subject",{messageAddress:i});const a=await this.natsConnection.request(i,JSON.stringify(e),this.toNatsOptions(s));if(!a)throw console.warn("No reply received for subject",{messageAddress:i}),new Error("No reply received");return this.extractResponse(a.json())}async upsertGroupShares(e,r,s="",i){let a="share.group.upsert."+r;s&&(a=`${s}.${a}`),console.debug("Sending request to NATS subject",{messageAddress:a});const d=await this.natsConnection.request(a,JSON.stringify(e),this.toNatsOptions(i));if(!d)throw console.warn("No reply received for subject",{messageAddress:a}),new Error("No reply received");return this.extractResponse(d.json())}extractResponse(e){return e.response||e}toNatsOptions(e){const s={timeout:(e==null?void 0:e.timeout)??this.defaultTimeout};if(e!=null&&e.headers){const i=zr.headers();for(const[a,d]of Object.entries(e.headers))Array.isArray(d)?d.forEach(m=>i.append(a,m)):i.set(a,d);s.headers=i}return s}}Te.EntNatsServiceClient=Ji,Object.defineProperty(Te,Symbol.toStringTag,{value:"Module"})});
|