var xl=Object.create;var Bs=Object.defineProperty;var Rl=Object.getOwnPropertyDescriptor;var Sl=Object.getOwnPropertyNames;var Tl=Object.getPrototypeOf,_l=Object.prototype.hasOwnProperty;var xs=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,o)=>(typeof require<"u"?require:t)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var me=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(o){throw t=0,o}};var Nl=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Sl(t))!_l.call(e,i)&&i!==o&&Bs(e,i,{get:()=>t[i],enumerable:!(r=Rl(t,i))||r.enumerable});return e};var Z=(e,t,o)=>(o=e!=null?xl(Tl(e)):{},Nl(t||!e||!e.__esModule?Bs(o,"default",{value:e,enumerable:!0}):o,e));var Ss=me((Rp,Rs)=>{function Dl(e){return e.length}function Ol(e){let t=e.byteLength,o="";for(let r=0;r<t;r++)o+=String.fromCharCode(e[r]&127);return o}function Ll(e,t){let o=e.byteLength;for(let r=0;r<o;r++)e[r]=t.charCodeAt(r);return o}Rs.exports={byteLength:Dl,toString:Ol,write:Ll}});var _s=me((Sp,Ts)=>{var Rr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",sr=new Uint8Array(256);for(let e=0;e<Rr.length;e++)sr[Rr.charCodeAt(e)]=e;sr[45]=62;sr[95]=63;function Pl(e){let t=e.length;return e.charCodeAt(t-1)===61&&t--,t>1&&e.charCodeAt(t-1)===61&&t--,t*3>>>2}function wl(e){let t=e.byteLength,o="";for(let r=0;r<t;r+=3)o+=Rr[e[r]>>2]+Rr[(e[r]&3)<<4|e[r+1]>>4]+Rr[(e[r+1]&15)<<2|e[r+2]>>6]+Rr[e[r+2]&63];return t%3===2?o=o.substring(0,o.length-1)+"=":t%3===1&&(o=o.substring(0,o.length-2)+"=="),o}function Kl(e,t){let o=e.byteLength;for(let r=0,i=0;i<o;r+=4){let n=sr[t.charCodeAt(r)],s=sr[t.charCodeAt(r+1)],a=sr[t.charCodeAt(r+2)],d=sr[t.charCodeAt(r+3)];e[i++]=n<<2|s>>4,e[i++]=(s&15)<<4|a>>2,e[i++]=(a&3)<<6|d&63}return o}Ts.exports={byteLength:Pl,toString:wl,write:Kl}});var Os=me((Tp,Ds)=>{function Ul(e){return e.length>>>1}function Ql(e){let t=e.byteLength;e=new DataView(e.buffer,e.byteOffset,t);let o="",r=0;for(let i=t-t%4;r<i;r+=4)o+=e.getUint32(r).toString(16).padStart(8,"0");for(;r<t;r++)o+=e.getUint8(r).toString(16).padStart(2,"0");return o}function Ml(e,t){let o=e.byteLength;for(let r=0;r<o;r++){let i=Ns(t.charCodeAt(r*2)),n=Ns(t.charCodeAt(r*2+1));if(i===void 0||n===void 0)return r;e[r]=i<<4|n}return o}Ds.exports={byteLength:Ul,toString:Ql,write:Ml};function Ns(e){if(e>=48&&e<=57)return e-48;if(e>=65&&e<=70)return e-65+10;if(e>=97&&e<=102)return e-97+10}});var Ps=me((_p,Ls)=>{function ql(e){return e.length}function Hl(e){let t=e.byteLength,o="";for(let r=0;r<t;r++)o+=String.fromCharCode(e[r]);return o}function Vl(e,t){let o=e.byteLength;for(let r=0;r<o;r++)e[r]=t.charCodeAt(r);return o}Ls.exports={byteLength:ql,toString:Hl,write:Vl}});var Ks=me((Np,ws)=>{function Fl(e){let t=0;for(let o=0,r=e.length;o<r;o++){let i=e.charCodeAt(o);if(i>=55296&&i<=56319&&o+1<r){let n=e.charCodeAt(o+1);if(n>=56320&&n<=57343){t+=4,o++;continue}}i<=127?t+=1:i<=2047?t+=2:t+=3}return t}var qi;if(typeof TextDecoder<"u"){let e=new TextDecoder;qi=function(o){return e.decode(o)}}else qi=function(t){let o=t.byteLength,r="",i=0;for(;i<o;){let n=t[i];if(n<=127){r+=String.fromCharCode(n),i++;continue}let s=0,a=0;if(n<=223?(s=1,a=n&31):n<=239?(s=2,a=n&15):n<=244&&(s=3,a=n&7),o-i-s>0){let d=0;for(;d<s;)n=t[i+d+1],a=a<<6|n&63,d+=1}else a=65533,s=o-i;r+=String.fromCodePoint(a),i+=s+1}return r};var Hi;if(typeof TextEncoder<"u"){let e=new TextEncoder;Hi=function(o,r){return e.encodeInto(r,o).written}}else Hi=function(t,o){let r=t.byteLength,i=0,n=0;for(;i<o.length;){let s=o.codePointAt(i);if(s<=127){if(n+1>r)break;t[n++]=s,i++;continue}let a=0,d=0;if(s<=2047?(a=6,d=192):s<=65535?(a=12,d=224):s<=2097151&&(a=18,d=240),n+a/6+1>r)break;for(t[n++]=d|s>>a,a-=6;a>=0;)t[n++]=128|s>>a&63,a-=6;i+=s>=65536?2:1}return n};ws.exports={byteLength:Fl,toString:qi,write:Hi}});var Qs=me((Dp,Us)=>{function Yl(e){return e.length*2}function Gl(e){let t=e.byteLength,o="";for(let r=0;r<t-1;r+=2)o+=String.fromCharCode(e[r]+e[r+1]*256);return o}function kl(e,t){let o=e.byteLength,r=o;for(let i=0;i<t.length&&!((r-=2)<0);++i){let n=t.charCodeAt(i),s=n>>8,a=n%256;e[i*2]=a,e[i*2+1]=s}return o}Us.exports={byteLength:Yl,toString:Gl,write:kl}});var ae=me((zr,Ys)=>{var vl=Ss(),Wl=_s(),jl=Os(),zl=Ps(),Vi=Ks(),Xl=Qs(),Ms=new Uint8Array(Uint16Array.of(255).buffer)[0]===255;function Sr(e){switch(e){case"ascii":return vl;case"base64":return Wl;case"hex":return jl;case"binary":case"latin1":return zl;case"utf8":case"utf-8":case void 0:case null:return Vi;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Xl;default:throw new Error(`Unknown encoding '${e}'`)}}function $l(e){return e instanceof Uint8Array}function Jl(e){try{return Sr(e),!0}catch{return!1}}function Zl(e,t,o){let r=new Uint8Array(e);return t!==void 0&&zr.fill(r,t,0,r.byteLength,o),r}function ef(e){return new Uint8Array(e)}function tf(e){return new Uint8Array(e)}function rf(e,t){return Sr(t).byteLength(e)}function qs(e,t){if(e===t)return 0;let o=Math.min(e.byteLength,t.byteLength);e=new DataView(e.buffer,e.byteOffset,e.byteLength),t=new DataView(t.buffer,t.byteOffset,t.byteLength);let r=0;for(let i=o-o%4;r<i;r+=4){let n=e.getUint32(r,Ms),s=t.getUint32(r,Ms);if(n!==s)break}for(;r<o;r++){let i=e.getUint8(r),n=t.getUint8(r);if(i<n)return-1;if(i>n)return 1}return e.byteLength>t.byteLength?1:e.byteLength<t.byteLength?-1:0}function of(e,t){t===void 0&&(t=e.reduce((i,n)=>i+n.byteLength,0));let o=new Uint8Array(t),r=0;for(let i of e){if(r+i.byteLength>o.byteLength)return o.set(i.subarray(0,o.byteLength-r),r),o;o.set(i,r),r+=i.byteLength}return o}function nf(e,t,o=0,r=0,i=e.byteLength){if(o<0&&(o=0),o>=t.byteLength)return 0;let n=t.byteLength-o;if(r<0&&(r=0),r>=e.byteLength||i<=r)return 0;i>e.byteLength&&(i=e.byteLength),i-r>n&&(i=r+n);let s=i-r;return e===t?t.copyWithin(o,r,i):((r!==0||i!==e.byteLength)&&(e=e.subarray(r,i)),t.set(e,o)),s}function sf(e,t){return e===t?!0:e.byteLength!==t.byteLength?!1:qs(e,t)===0}function af(e,t,o=0,r=e.byteLength,i="utf8"){if(typeof t=="string"?typeof o=="string"?(i=o,o=0,r=e.byteLength):typeof r=="string"&&(i=r,r=e.byteLength):typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=+t),o<0&&(o=0),o>=e.byteLength||r<=o)return e;if(r>e.byteLength&&(r=e.byteLength),typeof t=="number")return e.fill(t,o,r);typeof t=="string"&&(t=zr.from(t,i));let n=t.byteLength;for(let s=0,a=r-o;s<a;++s)e[s+o]=t[s%n];return e}function Hs(e,t,o){return typeof e=="string"?cf(e,t):Array.isArray(e)?df(e):ArrayBuffer.isView(e)?lf(e):ff(e,t,o)}function cf(e,t){let o=Sr(t),r=new Uint8Array(o.byteLength(e));return o.write(r,e),r}function df(e){let t=new Uint8Array(e.length);return t.set(e),t}function lf(e){let t=new Uint8Array(e.byteLength);return t.set(e),t}function ff(e,t,o){return new Uint8Array(e,t,o)}function If(e,t,o,r){return Vs(e,t,o,r)!==-1}function Vs(e,t,o,r){return Fs(e,t,o,r,!0)}function Af(e,t,o,r){return Fs(e,t,o,r,!1)}function Fs(e,t,o,r,i){if(e.byteLength===0)return-1;if(typeof o=="string"?(r=o,o=0):o===void 0?o=i?0:e.length-1:o<0&&(o+=e.byteLength),o>=e.byteLength){if(i)return-1;o=e.byteLength-1}else if(o<0)if(i)o=0;else return-1;if(typeof t=="string")t=Hs(t,r);else if(typeof t=="number")return t=t&255,i?e.indexOf(t,o):e.lastIndexOf(t,o);if(t.byteLength===0)return-1;if(i){let n=-1;for(let s=o;s<e.byteLength;s++)if(e[s]===t[n===-1?0:s-n]){if(n===-1&&(n=s),s-n+1===t.byteLength)return n}else n!==-1&&(s-=s-n),n=-1}else{o+t.byteLength>e.byteLength&&(o=e.byteLength-t.byteLength);for(let n=o;n>=0;n--){let s=!0;for(let a=0;a<t.byteLength;a++)if(e[n+a]!==t[a]){s=!1;break}if(s)return n}}return-1}function ar(e,t,o){let r=e[t];e[t]=e[o],e[o]=r}function uf(e){let t=e.byteLength;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let o=0;o<t;o+=2)ar(e,o,o+1);return e}function pf(e){let t=e.byteLength;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let o=0;o<t;o+=4)ar(e,o,o+3),ar(e,o+1,o+2);return e}function yf(e){let t=e.byteLength;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let o=0;o<t;o+=8)ar(e,o,o+7),ar(e,o+1,o+6),ar(e,o+2,o+5),ar(e,o+3,o+4);return e}function hf(e){return e}function mf(e,t="utf8",o=0,r=e.byteLength){return arguments.length===1?Vi.toString(e):arguments.length===2?Sr(t).toString(e):(o<0&&(o=0),o>=e.byteLength||r<=o?"":(r>e.byteLength&&(r=e.byteLength),(o!==0||r!==e.byteLength)&&(e=e.subarray(o,r)),Sr(t).toString(e)))}function Cf(e,t,o=0,r=e.byteLength,i){if(arguments.length===2)return Vi.write(e,t);typeof o=="string"?(i=o,o=0,r=e.byteLength):typeof r=="string"&&(i=r,r=e.byteLength-o),r=Math.min(r,zr.byteLength(t,i));let n=o;if(n<0&&(n=0),n>=e.byteLength)return 0;let s=o+r;return s<=n?0:(s>e.byteLength&&(s=e.byteLength),(n!==0||s!==e.byteLength)&&(e=e.subarray(n,s)),Sr(i).write(e,t))}function Ef(e,t=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t,!1)}function bf(e,t=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t,!0)}function gf(e,t=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t,!1)}function Bf(e,t=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t,!0)}function xf(e,t=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt32(t,!1)}function Rf(e,t=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt32(t,!0)}function Sf(e,t=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t,!1)}function Tf(e,t=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(t,!0)}function _f(e,t,o=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).setFloat64(o,t,!1),o+8}function Nf(e,t,o=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).setFloat64(o,t,!0),o+8}function Df(e,t,o=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).setFloat32(o,t,!1),o+4}function Of(e,t,o=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).setFloat32(o,t,!0),o+4}function Lf(e,t,o=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).setInt32(o,t,!1),o+4}function Pf(e,t,o=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).setInt32(o,t,!0),o+4}function wf(e,t,o=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).setUint32(o,t,!1),o+4}function Kf(e,t,o=0){return new DataView(e.buffer,e.byteOffset,e.byteLength).setUint32(o,t,!0),o+4}Ys.exports=zr={isBuffer:$l,isEncoding:Jl,alloc:Zl,allocUnsafe:ef,allocUnsafeSlow:tf,byteLength:rf,compare:qs,concat:of,copy:nf,equals:sf,fill:af,from:Hs,includes:If,indexOf:Vs,lastIndexOf:Af,swap16:uf,swap32:pf,swap64:yf,toBuffer:hf,toString:mf,write:Cf,readDoubleBE:Ef,readDoubleLE:bf,readFloatBE:gf,readFloatLE:Bf,readInt32BE:xf,readInt32LE:Rf,readUInt32BE:Sf,readUInt32LE:Tf,writeDoubleBE:_f,writeDoubleLE:Nf,writeFloatBE:Df,writeFloatLE:Of,writeInt32BE:Lf,writeInt32LE:Pf,writeUInt32BE:wf,writeUInt32LE:Kf}});var zt=me((Qp,ia)=>{ia.exports=oa;var wo=class extends Error{};wo.prototype.name="AssertionError";function oa(e,t){if(!e){var o=new wo(t);throw Error.captureStackTrace&&Error.captureStackTrace(o,oa),o}}});var sa=me((Mp,na)=>{var vf=(e,t)=>function(){return t||(0,e[Object.keys(e)[0]])((t={exports:{}}).exports,t),t.exports},Wf=(()=>{for(var e=new Uint8Array(128),t=0;t<64;t++)e[t<26?t+65:t<52?t+71:t<62?t-4:t*4-205]=t;return o=>{for(var r=o.length,i=new Uint8Array((r-(o[r-1]=="=")-(o[r-2]=="="))*3/4|0),n=0,s=0;n<r;){var a=e[o.charCodeAt(n++)],d=e[o.charCodeAt(n++)],f=e[o.charCodeAt(n++)],I=e[o.charCodeAt(n++)];i[s++]=a<<2|d>>4,i[s++]=d<<4|f>>2,i[s++]=f<<6|I}return i}})(),jf=vf({"wasm-binary:./blake2b.wat"(e,t){t.exports=Wf("AGFzbQEAAAABEANgAn9/AGADf39/AGABfwADBQQAAQICBQUBAQroBwdNBQZtZW1vcnkCAAxibGFrZTJiX2luaXQAAA5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WebAssembly.compile(zf);na.exports=async e=>(await WebAssembly.instantiate(await Xf,e)).exports});var ua=me((Vp,gt)=>{var ot=zt(),$f=ae(),wt=null,aa=typeof WebAssembly<"u"&&sa()().then(e=>{wt=e}),Pt=64,Ko=[];gt.exports=We;var ca=gt.exports.BYTES_MIN=16,da=gt.exports.BYTES_MAX=64,qp=gt.exports.BYTES=32,la=gt.exports.KEYBYTES_MIN=16,fa=gt.exports.KEYBYTES_MAX=64,Hp=gt.exports.KEYBYTES=32,Ia=gt.exports.SALTBYTES=16,Aa=gt.exports.PERSONALBYTES=16;function We(e,t,o,r,i){if(!(this instanceof We))return new We(e,t,o,r,i);if(!wt)throw new Error("WASM not loaded. Wait for Blake2b.ready(cb)");e||(e=32),i!==!0&&(ot(e>=ca,"digestLength must be at least "+ca+", was given "+e),ot(e<=da,"digestLength must be at most "+da+", was given "+e),t!=null&&(ot(t instanceof Uint8Array,"key must be Uint8Array or Buffer"),ot(t.length>=la,"key must be at least "+la+", was given "+t.length),ot(t.length<=fa,"key must be at least "+fa+", was given "+t.length)),o!=null&&(ot(o instanceof Uint8Array,"salt must be Uint8Array or Buffer"),ot(o.length===Ia,"salt must be exactly "+Ia+", was given "+o.length)),r!=null&&(ot(r instanceof Uint8Array,"personal must be Uint8Array or Buffer"),ot(r.length===Aa,"personal must be exactly "+Aa+", was given "+r.length))),Ko.length||(Ko.push(Pt),Pt+=216),this.digestLength=e,this.finalized=!1,this.pointer=Ko.pop(),this._memory=new Uint8Array(wt.memory.buffer),this._memory.fill(0,0,64),this._memory[0]=this.digestLength,this._memory[1]=t?t.length:0,this._memory[2]=1,this._memory[3]=1,o&&this._memory.set(o,32),r&&this._memory.set(r,48),this.pointer+216>this._memory.length&&this._realloc(this.pointer+216),wt.blake2b_init(this.pointer,this.digestLength),t&&(this.update(t),this._memory.fill(0,Pt,Pt+t.length),this._memory[this.pointer+200]=128)}We.prototype._realloc=function(e){wt.memory.grow(Math.max(0,Math.ceil(Math.abs(e-this._memory.length)/65536))),this._memory=new Uint8Array(wt.memory.buffer)};We.prototype.update=function(e){return ot(this.finalized===!1,"Hash instance finalized"),ot(e instanceof Uint8Array,"input must be Uint8Array or Buffer"),Pt+e.length>this._memory.length&&this._realloc(Pt+e.length),this._memory.set(e,Pt),wt.blake2b_update(this.pointer,Pt,Pt+e.length),this};We.prototype.digest=function(e){if(ot(this.finalized===!1,"Hash instance finalized"),this.finalized=!0,Ko.push(this.pointer),wt.blake2b_final(this.pointer),!e||e==="binary")return this._memory.slice(this.pointer+128,this.pointer+128+this.digestLength);if(typeof e=="string")return $f.toString(this._memory,e,this.pointer+128,this.pointer+128+this.digestLength);ot(e instanceof Uint8Array&&e.length>=this.digestLength,"input must be Uint8Array or Buffer");for(var t=0;t<this.digestLength;t++)e[t]=this._memory[this.pointer+128+t];return e};We.prototype.final=We.prototype.digest;We.WASM=wt;We.SUPPORTED=typeof WebAssembly<"u";We.ready=function(e){return e||(e=Jf),aa?aa.then(()=>e(),e):e(new Error("WebAssembly not supported"))};We.prototype.ready=We.ready;We.prototype.getPartialHash=function(){return this._memory.slice(this.pointer,this.pointer+216)};We.prototype.setPartialHash=function(e){this._memory.set(e,this.pointer)};function Jf(){}});var Sa=me((Gp,je)=>{var ct=zt(),to=ua();function Uo(e,t,o){var r=e[t]+e[o],i=e[t+1]+e[o+1];r>=4294967296&&i++,e[t]=r,e[t+1]=i}function pa(e,t,o,r){var i=e[t]+o;o<0&&(i+=4294967296);var n=e[t+1]+r;i>=4294967296&&n++,e[t]=i,e[t+1]=n}function ga(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function Xt(e,t,o,r,i,n){var s=eo[i],a=eo[i+1],d=eo[n],f=eo[n+1];Uo(M,e,t),pa(M,e,s,a);var I=M[r]^M[e],E=M[r+1]^M[e+1];M[r]=E,M[r+1]=I,Uo(M,o,r),I=M[t]^M[o],E=M[t+1]^M[o+1],M[t]=I>>>24^E<<8,M[t+1]=E>>>24^I<<8,Uo(M,e,t),pa(M,e,d,f),I=M[r]^M[e],E=M[r+1]^M[e+1],M[r]=I>>>16^E<<16,M[r+1]=E>>>16^I<<16,Uo(M,o,r),I=M[t]^M[o],E=M[t+1]^M[o+1],M[t]=E>>>31^I<<1,M[t+1]=I>>>31^E<<1}var Ba=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Zf=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],qe=new Uint8Array(Zf.map(function(e){return e*2})),M=new Uint32Array(32),eo=new Uint32Array(32);function xa(e,t){var o=0;for(o=0;o<16;o++)M[o]=e.h[o],M[o+16]=Ba[o];for(M[24]=M[24]^e.t,M[25]=M[25]^e.t/4294967296,t&&(M[28]=~M[28],M[29]=~M[29]),o=0;o<32;o++)eo[o]=ga(e.b,4*o);for(o=0;o<12;o++)Xt(0,8,16,24,qe[o*16+0],qe[o*16+1]),Xt(2,10,18,26,qe[o*16+2],qe[o*16+3]),Xt(4,12,20,28,qe[o*16+4],qe[o*16+5]),Xt(6,14,22,30,qe[o*16+6],qe[o*16+7]),Xt(0,10,20,30,qe[o*16+8],qe[o*16+9]),Xt(2,12,22,24,qe[o*16+10],qe[o*16+11]),Xt(4,14,16,26,qe[o*16+12],qe[o*16+13]),Xt(6,8,18,28,qe[o*16+14],qe[o*16+15]);for(o=0;o<16;o++)e.h[o]=e.h[o]^M[o]^M[o+16]}var $t=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function Dr(e,t,o,r){$t.fill(0),this.b=new Uint8Array(128),this.h=new Uint32Array(16),this.t=0,this.c=0,this.outlen=e,$t[0]=e,t&&($t[1]=t.length),$t[2]=1,$t[3]=1,o&&$t.set(o,32),r&&$t.set(r,48);for(var i=0;i<16;i++)this.h[i]=Ba[i]^ga($t,i*4);t&&(Ra(this,t),this.c=128)}Dr.prototype.update=function(e){return ct(e instanceof Uint8Array,"input must be Uint8Array or Buffer"),Ra(this,e),this};Dr.prototype.digest=function(e){var t=!e||e==="binary"||e==="hex"?new Uint8Array(this.outlen):e;return ct(t instanceof Uint8Array,'out must be "binary", "hex", Uint8Array, or Buffer'),ct(t.length>=this.outlen,"out must have at least outlen bytes of space"),eI(this,t),e==="hex"?tI(t):t};Dr.prototype.final=Dr.prototype.digest;Dr.ready=function(e){to.ready(function(){e()})};function Ra(e,t){for(var o=0;o<t.length;o++)e.c===128&&(e.t+=e.c,xa(e,!1),e.c=0),e.b[e.c++]=t[o]}function eI(e,t){for(e.t+=e.c;e.c<128;)e.b[e.c++]=0;xa(e,!0);for(var o=0;o<e.outlen;o++)t[o]=e.h[o>>2]>>8*(o&3);return t}function tI(e){for(var t="",o=0;o<e.length;o++)t+=rI(e[o]);return t}function rI(e){return e<16?"0"+e.toString(16):e.toString(16)}var oI=Dr;je.exports=function(t,o,r,i,n){return n!==!0&&(ct(t>=ya,"outlen must be at least "+ya+", was given "+t),ct(t<=ha,"outlen must be at most "+ha+", was given "+t),o!=null&&(ct(o instanceof Uint8Array,"key must be Uint8Array or Buffer"),ct(o.length>=ma,"key must be at least "+ma+", was given "+o.length),ct(o.length<=Ca,"key must be at most "+Ca+", was given "+o.length)),r!=null&&(ct(r instanceof Uint8Array,"salt must be Uint8Array or Buffer"),ct(r.length===Ea,"salt must be exactly "+Ea+", was given "+r.length)),i!=null&&(ct(i instanceof Uint8Array,"personal must be Uint8Array or Buffer"),ct(i.length===ba,"personal must be exactly "+ba+", was given "+i.length))),new oI(t,o,r,i)};je.exports.ready=function(e){to.ready(function(){e()})};je.exports.WASM_SUPPORTED=to.SUPPORTED;je.exports.WASM_LOADED=!1;var ya=je.exports.BYTES_MIN=16,ha=je.exports.BYTES_MAX=64,Fp=je.exports.BYTES=32,ma=je.exports.KEYBYTES_MIN=16,Ca=je.exports.KEYBYTES_MAX=64,Yp=je.exports.KEYBYTES=32,Ea=je.exports.SALTBYTES=16,ba=je.exports.PERSONALBYTES=16;to.ready(function(e){e||(je.exports.WASM_LOADED=!0,je.exports=to)})});var en=me((kp,He)=>{var it=Sa();if(new Uint16Array([1])[0]!==1)throw new Error("Big endian architecture is not supported.");He.exports.crypto_generichash_PRIMITIVE="blake2b";He.exports.crypto_generichash_BYTES_MIN=it.BYTES_MIN;He.exports.crypto_generichash_BYTES_MAX=it.BYTES_MAX;He.exports.crypto_generichash_BYTES=it.BYTES;He.exports.crypto_generichash_KEYBYTES_MIN=it.KEYBYTES_MIN;He.exports.crypto_generichash_KEYBYTES_MAX=it.KEYBYTES_MAX;He.exports.crypto_generichash_KEYBYTES=it.KEYBYTES;He.exports.crypto_generichash_WASM_SUPPORTED=it.WASM_SUPPORTED;He.exports.crypto_generichash_WASM_LOADED=!1;He.exports.crypto_generichash=function(e,t,o){it(e.length,o).update(t).final(e)};He.exports.crypto_generichash_ready=it.ready;He.exports.crypto_generichash_batch=function(e,t,o){for(var r=it(e.length,o),i=0;i<t.length;i++)r.update(t[i]);r.final(e)};He.exports.crypto_generichash_instance=function(e,t){return t==null&&(t=He.exports.crypto_generichash_BYTES),it(t,e)};it.ready(function(e){He.exports.crypto_generichash_WASM_LOADED=it.WASM_LOADED})});var Ta=me(()=>{});var Qo=me((jp,tn)=>{var iI=zt(),_a=(function(){var e=65536,t=globalThis.crypto||globalThis.msCrypto;function o(n,s){for(let a=0;a<s;a+=e)t.getRandomValues(new Uint8Array(n.buffer,a+n.byteOffset,Math.min(s-a,e)))}function r(n,s){new Uint8Array(n.buffer,n.byteOffset,s).set(t.randomBytes(s))}function i(){throw new Error("No secure random number generator available")}return t&&t.getRandomValues?o:xs!=null&&(t=Ta(),t&&t.randomBytes)?r:i})();Object.defineProperty(tn.exports,"randombytes",{value:_a});tn.exports.randombytes_buf=function(e){iI(e,"out must be given"),_a(e,e.byteLength)}});var Na=me((Xp,rn)=>{rn.exports={crypto_verify_16:nI,crypto_verify_32:sI,crypto_verify_64:aI};function Mo(e,t,o,r,i){var n=0;for(let s=0;s<i;s++)n|=e[t+s]^o[r+s];return(1&n-1>>>8)-1}Object.defineProperty(rn.exports,"vn",{value:Mo});function nI(e,t,o,r){return Mo(e,t,o,r,16)===0}function sI(e,t,o,r){return Mo(e,t,o,r,32)===0}function aI(e,t,o,r){return Mo(e,t,o,r,64)===0}});var Pa=me(($p,La)=>{var Oa=zt(),Ho=ae();La.exports=Kt;var qo=128,Da=[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 Kt(){return this instanceof Kt?(this.hh=new Int32Array(8),this.hl=new Int32Array(8),this.buffer=new Uint8Array(128),this.finalised=!1,this.bytesRead=0,this.pos=0,this.hh[0]=1779033703,this.hh[1]=3144134277,this.hh[2]=1013904242,this.hh[3]=2773480762,this.hh[4]=1359893119,this.hh[5]=2600822924,this.hh[6]=528734635,this.hh[7]=1541459225,this.hl[0]=4089235720,this.hl[1]=2227873595,this.hl[2]=4271175723,this.hl[3]=1595750129,this.hl[4]=2917565137,this.hl[5]=725511199,this.hl[6]=4215389547,this.hl[7]=327033209,this):new Kt}Kt.prototype.update=function(e,t){Oa(this.finalised===!1,"Hash instance finalised");var[o,r]=cI(e,t);this.bytesRead+=r;let i=r+this.pos&-128;this.buffer.set(o.subarray(0,qo-this.pos),this.pos);let n=this.pos;return r-=qo-this.pos,r>=0&&(Vo(this.hh,this.hl,this.buffer,128),this.pos=0),r>127&&(Vo(this.hh,this.hl,o.subarray(qo-n,i-n),i-qo),r%=128),this.buffer.set(o.subarray(o.byteLength-r)),this.pos=this.bytesRead&127,this.buffer.fill(0,this.pos),this};Kt.prototype.digest=function(e,t=0){if(Oa(this.finalised===!1,"Hash instance finalised"),this.finalised=!0,this.buffer.fill(0,this.pos),this.buffer[this.pos]=128,this.pos>111&&(Vo(this.hh,this.hl,this.buffer,128),this.buffer.fill(0),this.pos=0),on(this.buffer,120,this.bytesRead/536870912|0,this.bytesRead<<3),Vo(this.hh,this.hl,this.buffer,128),e instanceof Uint8Array&&e.byteLength>63){for(let r=0;r<8;r++)on(e,8*r+t,this.hh[r],this.hl[r]);return e}let o=new Uint8Array(64);for(let r=0;r<8;r++)on(o,8*r,this.hh[r],this.hl[r]);return typeof e=="string"?Ho.toString(o,e):o};function on(e,t,o,r){e[t]=o>>24&255,e[t+1]=o>>16&255,e[t+2]=o>>8&255,e[t+3]=o&255,e[t+4]=r>>24&255,e[t+5]=r>>16&255,e[t+6]=r>>8&255,e[t+7]=r&255}function cI(e,t){var o=Ho.from(e,t);return[o,o.byteLength]}function Vo(e,t,o,r){for(var i=new Int32Array(16),n=new Int32Array(16),s,a,d,f,I,E,_,K,j,W,re,de,pe,Ae,ue,Ne,v,J,se,F,u,p,T,B,x,N,Le=e[0],At=e[1],Ct=e[2],nr=e[3],oe=e[4],Ee=e[5],be=e[6],ge=e[7],ie=t[0],ye=t[1],he=t[2],Te=t[3],ne=t[4],Be=t[5],xe=t[6],Re=t[7],De=0;r>=128;){for(se=0;se<16;se++)F=8*se+De,i[se]=o[F+0]<<24|o[F+1]<<16|o[F+2]<<8|o[F+3],n[se]=o[F+4]<<24|o[F+5]<<16|o[F+6]<<8|o[F+7];for(se=0;se<80;se++)if(s=Le,a=At,d=Ct,f=nr,I=oe,E=Ee,_=be,K=ge,j=ie,W=ye,re=he,de=Te,pe=ne,Ae=Be,ue=xe,Ne=Re,u=ge,p=Re,T=p&65535,B=p>>>16,x=u&65535,N=u>>>16,u=(oe>>>14|ne<<18)^(oe>>>18|ne<<14)^(ne>>>9|oe<<23),p=(ne>>>14|oe<<18)^(ne>>>18|oe<<14)^(oe>>>9|ne<<23),T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,u=oe&Ee^~oe&be,p=ne&Be^~ne&xe,T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,u=Da[se*2],p=Da[se*2+1],T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,u=i[se%16],p=n[se%16],T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,B+=T>>>16,x+=B>>>16,N+=x>>>16,v=x&65535|N<<16,J=T&65535|B<<16,u=v,p=J,T=p&65535,B=p>>>16,x=u&65535,N=u>>>16,u=(Le>>>28|ie<<4)^(ie>>>2|Le<<30)^(ie>>>7|Le<<25),p=(ie>>>28|Le<<4)^(Le>>>2|ie<<30)^(Le>>>7|ie<<25),T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,u=Le&At^Le&Ct^At&Ct,p=ie&ye^ie&he^ye&he,T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,B+=T>>>16,x+=B>>>16,N+=x>>>16,K=x&65535|N<<16,Ne=T&65535|B<<16,u=f,p=de,T=p&65535,B=p>>>16,x=u&65535,N=u>>>16,u=v,p=J,T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,B+=T>>>16,x+=B>>>16,N+=x>>>16,f=x&65535|N<<16,de=T&65535|B<<16,At=s,Ct=a,nr=d,oe=f,Ee=I,be=E,ge=_,Le=K,ye=j,he=W,Te=re,ne=de,Be=pe,xe=Ae,Re=ue,ie=Ne,se%16===15)for(F=0;F<16;F++)u=i[F],p=n[F],T=p&65535,B=p>>>16,x=u&65535,N=u>>>16,u=i[(F+9)%16],p=n[(F+9)%16],T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,v=i[(F+1)%16],J=n[(F+1)%16],u=(v>>>1|J<<31)^(v>>>8|J<<24)^v>>>7,p=(J>>>1|v<<31)^(J>>>8|v<<24)^(J>>>7|v<<25),T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,v=i[(F+14)%16],J=n[(F+14)%16],u=(v>>>19|J<<13)^(J>>>29|v<<3)^v>>>6,p=(J>>>19|v<<13)^(v>>>29|J<<3)^(J>>>6|v<<26),T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,B+=T>>>16,x+=B>>>16,N+=x>>>16,i[F]=x&65535|N<<16,n[F]=T&65535|B<<16;u=Le,p=ie,T=p&65535,B=p>>>16,x=u&65535,N=u>>>16,u=e[0],p=t[0],T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,B+=T>>>16,x+=B>>>16,N+=x>>>16,e[0]=Le=x&65535|N<<16,t[0]=ie=T&65535|B<<16,u=At,p=ye,T=p&65535,B=p>>>16,x=u&65535,N=u>>>16,u=e[1],p=t[1],T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,B+=T>>>16,x+=B>>>16,N+=x>>>16,e[1]=At=x&65535|N<<16,t[1]=ye=T&65535|B<<16,u=Ct,p=he,T=p&65535,B=p>>>16,x=u&65535,N=u>>>16,u=e[2],p=t[2],T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,B+=T>>>16,x+=B>>>16,N+=x>>>16,e[2]=Ct=x&65535|N<<16,t[2]=he=T&65535|B<<16,u=nr,p=Te,T=p&65535,B=p>>>16,x=u&65535,N=u>>>16,u=e[3],p=t[3],T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,B+=T>>>16,x+=B>>>16,N+=x>>>16,e[3]=nr=x&65535|N<<16,t[3]=Te=T&65535|B<<16,u=oe,p=ne,T=p&65535,B=p>>>16,x=u&65535,N=u>>>16,u=e[4],p=t[4],T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,B+=T>>>16,x+=B>>>16,N+=x>>>16,e[4]=oe=x&65535|N<<16,t[4]=ne=T&65535|B<<16,u=Ee,p=Be,T=p&65535,B=p>>>16,x=u&65535,N=u>>>16,u=e[5],p=t[5],T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,B+=T>>>16,x+=B>>>16,N+=x>>>16,e[5]=Ee=x&65535|N<<16,t[5]=Be=T&65535|B<<16,u=be,p=xe,T=p&65535,B=p>>>16,x=u&65535,N=u>>>16,u=e[6],p=t[6],T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,B+=T>>>16,x+=B>>>16,N+=x>>>16,e[6]=be=x&65535|N<<16,t[6]=xe=T&65535|B<<16,u=ge,p=Re,T=p&65535,B=p>>>16,x=u&65535,N=u>>>16,u=e[7],p=t[7],T+=p&65535,B+=p>>>16,x+=u&65535,N+=u>>>16,B+=T>>>16,x+=B>>>16,N+=x>>>16,e[7]=ge=x&65535|N<<16,t[7]=Re=T&65535|B<<16,De+=128,r-=128}}function ro(e){if(!(this instanceof ro))return new ro(e);this.pad=Ho.alloc(128),this.inner=Kt(),this.outer=Kt();let t=Ho.alloc(64);e.byteLength>128&&(Kt().update(e).digest(t),e=t),this.pad.fill(54);for(let o=0;o<e.byteLength;o++)this.pad[o]^=e[o];this.inner.update(this.pad),this.pad.fill(92);for(let o=0;o<e.byteLength;o++)this.pad[o]^=e[o];this.outer.update(this.pad),this.pad.fill(0),t.fill(0)}ro.prototype.update=function(e,t){return this.inner.update(e,t),this};ro.prototype.digest=function(e,t=0){return this.outer.update(this.inner.digest()),this.outer.digest(e,t)};Kt.HMAC=ro});var Ka=me((Jp,wa)=>{var dI=(e,t)=>function(){return t||(0,e[Object.keys(e)[0]])((t={exports:{}}).exports,t),t.exports},lI=(()=>{for(var e=new Uint8Array(128),t=0;t<64;t++)e[t<26?t+65:t<52?t+71:t<62?t-4:t*4-205]=t;return o=>{for(var r=o.length,i=new Uint8Array((r-(o[r-1]=="=")-(o[r-2]=="="))*3/4|0),n=0,s=0;n<r;){var a=e[o.charCodeAt(n++)],d=e[o.charCodeAt(n++)],f=e[o.charCodeAt(n++)],I=e[o.charCodeAt(n++)];i[s++]=a<<2|d>>4,i[s++]=d<<4|f>>2,i[s++]=f<<6|I}return i}})(),fI=dI({"wasm-binary:./sha512.wat"(e,t){t.exports=lI("AGFzbQEAAAABNAVgAX4BfmAIfn5+fn5+fn4AYAR+fn5+AX5gEX9+fn5+fn5+fn5+fn5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ASAAIBQ3A6gBIAAgFTcDsAEgACAWNwO4ASAAIBc3A8ABIAAgGDcDyAEMAgsgACAJIAogCyAMIA0gDiAPIBAgESASIBMgFCAVIBYgFyAYEAMMAAsLIANBAUYEQCAEQv8AgyEIQoABIAhCB4NCA4aGIQcCQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkAgCKdBA3YODwMEBQYHCAkKCwwNDg8QAQILCyAHIBeEIRdCACEHCyAHIBiEIRhCACEHIAAgCSAKIAsgDCANIA4gDyAQIBEgEiATIBQgFSAWIBcgGBADIAAgBDcDQEIAIQlCACEKQgAhC0IAIQxCACENQgAhDkIAIQ9CACEQQgAhEUIAIRJCACETQgAhFEIAIRVCACEWQgAhF0IAIRgLIAcgCYQhCUIAIQcLIAcgCoQhCkIAIQcLIAcgC4QhC0IAIQcLIAcgDIQhDEIAIQcLIAcgDYQhDUIAIQcLIAcgDoQhDkIAIQcLIAcgD4QhD0IAIQcLIAcgEIQhEEIAIQcLIAcgEYQhEUIAIQcLIAcgEoQhEkIAIQcLIAcgE4QhE0IAIQcLIAcgFIQhFEIAIQcLIAcgFYQhFUIAIQcLIAcgFoQhFkIAIQcLIARCPYggBUIDiHwQACEXIARCCH4QACEYIAAgCSAKIAsgDCANIA4gDyAQIBEgEiATIBQgFSAWIBcgGBADIAAgACkDABAANwMAIAAgACkDCBAANwMIIAAgACkDEBAANwMQIAAgACkDGBAANwMYIAAgACkDIBAANwMgIAAgACkDKBAANwMoIAAgACkDMBAANwMwIAAgACkDOBAANwM4Cws=")}}),II=fI(),AI=new WebAssembly.Module(II);wa.exports=e=>new WebAssembly.Instance(AI,e).exports});var Ua=me((Zp,an)=>{var Or=zt(),Yo=ae(),Ut=typeof WebAssembly<"u"&&Ka()({imports:{debug:{log(...e){console.log(...e.map(t=>(t>>>0).toString(16).padStart(8,"0")))},log_tee(e){return console.log((e>>>0).toString(16).padStart(8,"0")),e}}}}),nt=0,Fo=[];an.exports=ze;var uI=an.exports.SHA512_BYTES=64,sn=80,nn=216,oo=128;function ze(){if(!(this instanceof ze))return new ze;if(!Ut)throw new Error("WASM not loaded. Wait for Sha512.ready(cb)");Fo.length||(Fo.push(nt),nt+=nn),this.finalized=!1,this.digestLength=uI,this.pointer=Fo.pop(),this.pos=0,this.wasm=Ut,this._memory=new Uint8Array(Ut.memory.buffer),this._memory.fill(0,this.pointer,this.pointer+nn),this.pointer+this.digestLength>this._memory.length&&this._realloc(this.pointer+nn)}ze.prototype._realloc=function(e){Ut.memory.grow(Math.max(0,Math.ceil(Math.abs(e-this._memory.length)/65536))),this._memory=new Uint8Array(Ut.memory.buffer)};ze.prototype.update=function(e,t){Or(this.finalized===!1,"Hash instance finalized"),nt%8!==0&&(nt+=8-nt%8),Or(nt%8===0,"input should be aligned for int64");let[o,r]=yI(e,t);return Or(o instanceof Uint8Array,"input must be Uint8Array or Buffer"),nt+e.length>this._memory.length&&this._realloc(nt+e.length),this._memory.fill(0,nt,nt+hI(r,oo)-oo),this._memory.set(o.subarray(0,oo-this.pos),this.pointer+sn+this.pos),this._memory.set(o.subarray(oo-this.pos),nt),this.pos=this.pos+r&127,Ut.sha512(this.pointer,nt,r,0),this};ze.prototype.digest=function(e,t=0){Or(this.finalized===!1,"Hash instance finalized"),this.finalized=!0,Fo.push(this.pointer);let o=this.pointer+sn+this.pos;this._memory.fill(0,o,this.pointer+sn+oo),Ut.sha512(this.pointer,nt,0,1);let r=this._memory.subarray(this.pointer,this.pointer+this.digestLength);if(!e)return r;if(typeof e=="string")return Yo.toString(r,e);Or(e instanceof Uint8Array,"output must be Uint8Array or Buffer"),Or(e.byteLength>=this.digestLength+t,"output must have at least 'SHA512_BYTES' bytes remaining");for(let i=0;i<this.digestLength;i++)e[i+t]=r[i];return e};ze.WASM=Ut;ze.WASM_SUPPORTED=typeof WebAssembly<"u";ze.ready=function(e){return e||(e=pI),Ut?(e(),Promise.resolve()):e(new Error("WebAssembly not supported"))};ze.prototype.ready=ze.ready;function io(e){if(!(this instanceof io))return new io(e);this.pad=Yo.alloc(128),this.inner=ze(),this.outer=ze();let t=Yo.alloc(64);e.byteLength>128&&(ze().update(e).digest(t),e=t),this.pad.fill(54);for(let o=0;o<e.byteLength;o++)this.pad[o]^=e[o];this.inner.update(this.pad),this.pad.fill(92);for(let o=0;o<e.byteLength;o++)this.pad[o]^=e[o];this.outer.update(this.pad),this.pad.fill(0),t.fill(0)}io.prototype.update=function(e,t){return this.inner.update(e,t),this};io.prototype.digest=function(e,t=0){return this.outer.update(this.inner.digest()),this.outer.digest(e,t)};ze.HMAC=io;function pI(){}function yI(e,t){var o=Yo.from(e,t);return[o,o.byteLength]}function hI(e,t){return e+t-1&-t}});var Ma=me((ty,Jt)=>{var mI=Pa(),Go=Ua(),Qa=mI;Jt.exports=function(){return new Qa};Jt.exports.ready=function(e){Go.ready(function(){e()})};Jt.exports.WASM_SUPPORTED=Go.SUPPORTED;Jt.exports.WASM_LOADED=!1;var ey=Jt.exports.SHA512_BYTES=64;Go.ready(function(e){e||(Jt.exports.WASM_LOADED=!0,Jt.exports=Qa=Go)})});var dn=me((ry,Ha)=>{var CI=Ma(),EI=zt();if(new Uint16Array([1])[0]!==1)throw new Error("Big endian architecture is not supported.");var cn=64,bI=cn;function qa(e,t,o){return EI(e.byteLength===cn,"out must be 'crypto_hash_sha512_BYTES' bytes long"),CI().update(t.subarray(0,o)).digest(e),0}function gI(e,t,o){return qa(e,t,o)}Ha.exports={crypto_hash:gI,crypto_hash_sha512:qa,crypto_hash_sha512_BYTES:cn,crypto_hash_BYTES:bI}});var In=me((iy,Ga)=>{if(new Uint16Array([1])[0]!==1)throw new Error("Big endian architecture is not supported.");var dt=function(e){var t,o=new Float64Array(16);if(e)for(t=0;t<e.length;t++)o[t]=e[t];return o},oy=new Uint8Array(16),Va=new Uint8Array(32);Va[0]=9;var BI=dt(),xI=dt([1]),RI=dt([56129,1]),SI=dt([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),TI=dt([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),_I=dt([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),NI=dt([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),DI=dt([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function OI(e,t,o){for(var r=0;r<16;r++)e[r]=t[r]+o[r]}function LI(e,t,o){for(var r=0;r<16;r++)e[r]=t[r]-o[r]}function fn(e,t,o){var r,i,n=0,s=0,a=0,d=0,f=0,I=0,E=0,_=0,K=0,j=0,W=0,re=0,de=0,pe=0,Ae=0,ue=0,Ne=0,v=0,J=0,se=0,F=0,u=0,p=0,T=0,B=0,x=0,N=0,Le=0,At=0,Ct=0,nr=0,oe=o[0],Ee=o[1],be=o[2],ge=o[3],ie=o[4],ye=o[5],he=o[6],Te=o[7],ne=o[8],Be=o[9],xe=o[10],Re=o[11],De=o[12],Ue=o[13],Qe=o[14],Me=o[15];r=t[0],n+=r*oe,s+=r*Ee,a+=r*be,d+=r*ge,f+=r*ie,I+=r*ye,E+=r*he,_+=r*Te,K+=r*ne,j+=r*Be,W+=r*xe,re+=r*Re,de+=r*De,pe+=r*Ue,Ae+=r*Qe,ue+=r*Me,r=t[1],s+=r*oe,a+=r*Ee,d+=r*be,f+=r*ge,I+=r*ie,E+=r*ye,_+=r*he,K+=r*Te,j+=r*ne,W+=r*Be,re+=r*xe,de+=r*Re,pe+=r*De,Ae+=r*Ue,ue+=r*Qe,Ne+=r*Me,r=t[2],a+=r*oe,d+=r*Ee,f+=r*be,I+=r*ge,E+=r*ie,_+=r*ye,K+=r*he,j+=r*Te,W+=r*ne,re+=r*Be,de+=r*xe,pe+=r*Re,Ae+=r*De,ue+=r*Ue,Ne+=r*Qe,v+=r*Me,r=t[3],d+=r*oe,f+=r*Ee,I+=r*be,E+=r*ge,_+=r*ie,K+=r*ye,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i+65535,i=Math.floor(r/65536),I=r-i*65536,r=E+i+65535,i=Math.floor(r/65536),E=r-i*65536,r=_+i+65535,i=Math.floor(r/65536),_=r-i*65536,r=K+i+65535,i=Math.floor(r/65536),K=r-i*65536,r=j+i+65535,i=Math.floor(r/65536),j=r-i*65536,r=W+i+65535,i=Math.floor(r/65536),W=r-i*65536,r=re+i+65535,i=Math.floor(r/65536),re=r-i*65536,r=de+i+65535,i=Math.floor(r/65536),de=r-i*65536,r=pe+i+65535,i=Math.floor(r/65536),pe=r-i*65536,r=Ae+i+65535,i=Math.floor(r/65536),Ae=r-i*65536,r=ue+i+65535,i=Math.floor(r/65536),ue=r-i*65536,n+=i-1+37*(i-1),i=1,r=n+i+65535,i=Math.floor(r/65536),n=r-i*65536,r=s+i+65535,i=Math.floor(r/65536),s=r-i*65536,r=a+i+65535,i=Math.floor(r/65536),a=r-i*65536,r=d+i+65535,i=Math.floor(r/65536),d=r-i*65536,r=f+i+65535,i=Math.floor(r/65536),f=r-i*65536,r=I+i+65535,i=Math.floor(r/65536),I=r-i*65536,r=E+i+65535,i=Math.floor(r/65536),E=r-i*65536,r=_+i+65535,i=Math.floor(r/65536),_=r-i*65536,r=K+i+65535,i=Math.floor(r/65536),K=r-i*65536,r=j+i+65535,i=Math.floor(r/65536),j=r-i*65536,r=W+i+65535,i=Math.floor(r/65536),W=r-i*65536,r=re+i+65535,i=Math.floor(r/65536),re=r-i*65536,r=de+i+65535,i=Math.floor(r/65536),de=r-i*65536,r=pe+i+65535,i=Math.floor(r/65536),pe=r-i*65536,r=Ae+i+65535,i=Math.floor(r/65536),Ae=r-i*65536,r=ue+i+65535,i=Math.floor(r/65536),ue=r-i*65536,n+=i-1+37*(i-1),e[0]=n,e[1]=s,e[2]=a,e[3]=d,e[4]=f,e[5]=I,e[6]=E,e[7]=_,e[8]=K,e[9]=j,e[10]=W,e[11]=re,e[12]=de,e[13]=pe,e[14]=Ae,e[15]=ue}function Fa(e,t){fn(e,t,t)}function Ya(e,t,o){for(var r,i=~(o-1),n=0;n<16;n++)r=i&(e[n]^t[n]),e[n]^=r,t[n]^=r}function PI(e,t){var o,r,i,n=dt(),s=dt();for(o=0;o<16;o++)s[o]=t[o];for(ln(s),ln(s),ln(s),r=0;r<2;r++){for(n[0]=s[0]-65517,o=1;o<15;o++)n[o]=s[o]-65535-(n[o-1]>>16&1),n[o-1]&=65535;n[15]=s[15]-32767-(n[14]>>16&1),i=n[15]>>16&1,n[14]&=65535,Ya(s,n,1-i)}for(o=0;o<16;o++)e[2*o]=s[o]&255,e[2*o+1]=s[o]>>8}function wI(e,t){var o;for(o=0;o<16;o++)e[o]=t[2*o]+(t[2*o+1]<<8);e[15]&=32767}function KI(e,t){var o=dt(),r;for(r=0;r<16;r++)o[r]=t[r];for(r=253;r>=0;r--)Fa(o,o),r!==2&&r!==4&&fn(o,o,t);for(r=0;r<16;r++)e[r]=o[r]}function ln(e){var t,o,r=1;for(t=0;t<16;t++)o=e[t]+r+65535,r=Math.floor(o/65536),e[t]=o-r*65536;e[0]+=r-1+37*(r-1)}Ga.exports={gf:dt,A:OI,Z:LI,M:fn,S:Fa,sel25519:Ya,pack25519:PI,unpack25519:wI,inv25519:KI,gf0:BI,gf1:xI,_9:Va,_121665:RI,D:SI,D2:TI,X:_I,Y:NI,I:DI}});var ja=me((ny,Wa)=>{var{_9:UI,_121665:QI,gf:Lr,inv25519:MI,pack25519:qI,unpack25519:HI,sel25519:ko,A:vo,M:Ar,Z:Wo,S:jo}=In(),un=32,ka=32;Wa.exports={crypto_scalarmult:va,crypto_scalarmult_base:VI,crypto_scalarmult_BYTES:un,crypto_scalarmult_SCALARBYTES:ka};function va(e,t,o){An(e,un),An(t,ka),An(o,un);var r=new Uint8Array(32),i=new Float64Array(80),n,s,a=Lr(),d=Lr(),f=Lr(),I=Lr(),E=Lr(),_=Lr();for(s=0;s<31;s++)r[s]=t[s];for(r[31]=t[31]&127|64,r[0]&=248,HI(i,o),s=0;s<16;s++)d[s]=i[s],I[s]=a[s]=f[s]=0;for(a[0]=I[0]=1,s=254;s>=0;--s)n=r[s>>>3]>>>(s&7)&1,ko(a,d,n),ko(f,I,n),vo(E,a,f),Wo(a,a,f),vo(f,d,I),Wo(d,d,I),jo(I,E),jo(_,a),Ar(a,f,a),Ar(f,d,E),vo(E,a,f),Wo(a,a,f),jo(d,a),Wo(f,I,_),Ar(a,f,QI),vo(a,a,I),Ar(f,f,a),Ar(a,I,_),Ar(I,d,i),jo(d,E),ko(a,d,n),ko(f,I,n);for(s=0;s<16;s++)i[s+16]=a[s],i[s+32]=f[s],i[s+48]=d[s],i[s+64]=I[s];var K=i.subarray(32),j=i.subarray(16);return MI(K,K),Ar(j,j,K),qI(e,j),0}function VI(e,t){return va(e,t,UI)}function An(e,t){if(!e||t&&e.length<t)throw new Error("Argument must be a buffer"+(t?" of length "+t:""))}});var xn=me((sy,lc)=>{var{crypto_verify_32:tc}=Na(),{crypto_hash:wr}=dn(),{gf:O,gf0:za,gf1:Xo,D:FI,D2:YI,X:Xa,Y:$a,I:GI,A:ur,Z:pr,M:le,S:Pr,sel25519:kI,pack25519:Kr,inv25519:rc,unpack25519:vI}=In(),{randombytes:WI}=Qo(),{crypto_scalarmult_BYTES:Ja}=ja(),{crypto_hash_sha512_BYTES:jI}=dn(),pn=zt(),$o=32,mn=64,Cn=32,oc=64,Bt=oc,Jo=$o,En=mn,ic=Cn;lc.exports={crypto_sign_keypair:nc,crypto_sign_seed_keypair:XI,crypto_sign:ac,crypto_sign_detached:$I,crypto_sign_open:cc,crypto_sign_verify_detached:JI,crypto_sign_BYTES:Bt,crypto_sign_PUBLICKEYBYTES:Jo,crypto_sign_SECRETKEYBYTES:En,crypto_sign_SEEDBYTES:ic,crypto_sign_ed25519_PUBLICKEYBYTES:$o,crypto_sign_ed25519_SECRETKEYBYTES:mn,crypto_sign_ed25519_SEEDBYTES:Cn,crypto_sign_ed25519_BYTES:oc,crypto_sign_ed25519_pk_to_curve25519:tA,crypto_sign_ed25519_sk_to_curve25519:iA,crypto_sign_ed25519_sk_to_pk:oA,unpackneg:Bn,pack:Zo};function Zt(e,t){for(let o=0;o<16;o++)e[o]=t[o]|0}function zI(e,t){var o=O(),r;for(r=0;r<16;r++)o[r]=t[r];for(r=250;r>=0;r--)Pr(o,o),r!==1&&le(o,o,t);for(r=0;r<16;r++)e[r]=o[r]}function yn(e,t){var o=O(),r=O(),i=O(),n=O(),s=O(),a=O(),d=O(),f=O(),I=O();pr(o,e[1],e[0]),pr(I,t[1],t[0]),le(o,o,I),ur(r,e[0],e[1]),ur(I,t[0],t[1]),le(r,r,I),le(i,e[3],t[3]),le(i,i,YI),le(n,e[2],t[2]),ur(n,n,n),pr(s,r,o),pr(a,n,i),ur(d,n,i),ur(f,r,o),le(e[0],s,a),le(e[1],f,d),le(e[2],d,a),le(e[3],s,f)}function Za(e,t,o){var r;for(r=0;r<4;r++)kI(e[r],t[r],o)}function Zo(e,t){var o=O(),r=O(),i=O();rc(i,t[2]),le(o,t[0],i),le(r,t[1],i),Kr(e,r),e[31]^=dc(o)<<7}function bn(e,t,o){var r=[O(t[0]),O(t[1]),O(t[2]),O(t[3])],i,n;for(Zt(e[0],za),Zt(e[1],Xo),Zt(e[2],Xo),Zt(e[3],za),n=255;n>=0;--n)i=o[n/8|0]>>(n&7)&1,Za(e,r,i),yn(r,e),yn(e,e),Za(e,r,i)}function gn(e,t){var o=[O(),O(),O(),O()];Zt(o[0],Xa),Zt(o[1],$a),Zt(o[2],Xo),le(o[3],Xa,$a),bn(e,o,t)}function nc(e,t,o){Je(e,Jo),Je(t,En);var r=new Uint8Array(64),i=[O(),O(),O(),O()],n;for(o||WI(t,32),wr(r,t,32),r[0]&=248,r[31]&=127,r[31]|=64,gn(i,r),Zo(e,i),n=0;n<32;n++)t[n+32]=e[n]}function XI(e,t,o){return Je(o,ic),t.set(o),nc(e,t,!0)}var zo=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 sc(e,t){var o,r,i,n;for(r=63;r>=32;--r){for(o=0,i=r-32,n=r-12;i<n;++i)t[i]+=o-16*t[r]*zo[i-(r-32)],o=t[i]+128>>8,t[i]-=o*256;t[i]+=o,t[r]=0}for(o=0,i=0;i<32;i++)t[i]+=o-(t[31]>>4)*zo[i],o=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=o*zo[i];for(r=0;r<32;r++)t[r+1]+=t[r]>>8,e[r]=t[r]&255}function hn(e){var t=new Float64Array(64);for(let o=0;o<64;o++)t[o]=e[o];for(let o=0;o<64;o++)e[o]=0;sc(e,t)}function ac(e,t,o){Je(e,Bt+t.length),Je(t,0),Je(o,En);var r=t.length,i=new Uint8Array(64),n=new Uint8Array(64),s=new Uint8Array(64),a,d,f=new Float64Array(64),I=[O(),O(),O(),O()];wr(i,o,32),i[0]&=248,i[31]&=127,i[31]|=64;var E=r+64;for(a=0;a<r;a++)e[64+a]=t[a];for(a=0;a<32;a++)e[32+a]=i[32+a];for(wr(s,e.subarray(32),r+32),hn(s),gn(I,s),Zo(e,I),a=32;a<64;a++)e[a]=o[a];for(wr(n,e,r+64),hn(n),a=0;a<64;a++)f[a]=0;for(a=0;a<32;a++)f[a]=s[a];for(a=0;a<32;a++)for(d=0;d<32;d++)f[a+d]+=n[a]*i[d];return sc(e.subarray(32),f),E}function $I(e,t,o){var r=new Uint8Array(t.length+Bt);ac(r,t,o);for(let i=0;i<Bt;i++)e[i]=r[i]}function Bn(e,t){var o=O(),r=O(),i=O(),n=O(),s=O(),a=O(),d=O();return Zt(e[2],Xo),vI(e[1],t),Pr(i,e[1]),le(n,i,FI),pr(i,i,e[2]),ur(n,e[2],n),Pr(s,n),Pr(a,s),le(d,a,s),le(o,d,i),le(o,o,n),zI(o,o),le(o,o,i),le(o,o,n),le(o,o,n),le(e[0],o,n),Pr(r,e[0]),le(r,r,n),ec(r,i)||le(e[0],e[0],GI),Pr(r,e[0]),le(r,r,n),ec(r,i)?(dc(e[0])===t[31]>>7&&pr(e[0],O(),e[0]),le(e[3],e[0],e[1]),!0):!1}function cc(e,t,o){Je(e,t.length-Bt),Je(t,Bt),Je(o,Jo);var r=t.length,i=new Uint8Array(t.length),n,s,a=new Uint8Array(32),d=new Uint8Array(64),f=[O(),O(),O(),O()],I=[O(),O(),O(),O()];if(s=-1,r<64||!Bn(I,o))return!1;for(n=0;n<r;n++)i[n]=t[n];for(n=0;n<32;n++)i[n+32]=o[n];if(wr(d,i,r),hn(d),bn(f,I,d),gn(I,t.subarray(32)),yn(f,I),Zo(a,f),r-=64,!tc(t,0,a,0)){for(n=0;n<r;n++)i[n]=0;return!1}for(n=0;n<r;n++)e[n]=t[n+64];return s=r,!0}function JI(e,t,o){Je(e,Bt);var r=new Uint8Array(t.length+Bt),i=0;for(i=0;i<Bt;i++)r[i]=e[i];for(i=0;i<t.length;i++)r[i+Bt]=t[i];return cc(t,r,o)}function dc(e){var t=new Uint8Array(32);return Kr(t,e),t[0]&1}function ec(e,t){var o=new Uint8Array(32),r=new Uint8Array(32);return Kr(o,e),Kr(r,t),tc(o,0,r,0)}function ZI(e,t){bn(e,t,zo)}function eA(e){var t=[O(),O(),O(),O()];ZI(t,e);var o=0;for(let r=0;r<16;r++)o|=t[0][r]&65535;return o===0}function tA(e,t){Je(e,Jo),Je(t,$o);var o=[O(),O(),O(),O()],r=O([1]),i=O([1]);pn(rA(t)&&Bn(o,t)&&eA(o),"Cannot convert key: bad point");for(let n=0;n<o.length;n++)Kr(e,o[n]);return pr(i,i,o[1]),ur(r,r,o[1]),rc(i,i),le(r,r,i),Kr(e,r),0}function rA(e){Uint8Array.from([]);var t=[Uint8Array.from([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Uint8Array.from([1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Uint8Array.from([38,232,149,143,194,178,39,176,69,195,244,137,242,239,152,240,213,223,172,5,211,198,51,57,177,56,2,136,109,83,252,5]),Uint8Array.from([199,23,106,112,61,77,216,79,186,60,11,118,13,16,103,15,42,32,83,250,44,57,204,198,78,199,253,119,146,172,3,122]),Uint8Array.from([236,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,127]),Uint8Array.from([237,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,127]),Uint8Array.from([238,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,127])],o=new Uint8Array(7),r;Je(t,7);for(let n=0;n<t.length;n++)for(r=0;r<31;r++)o[n]|=e[r]^t[n][r];for(let n=0;n<t.length;n++)o[n]|=e[r]&127^t[n][r];var i=0;for(let n=0;n<t.length;n++)i|=o[n]-1;return(i>>8&1)===0}function oA(e,t){return Je(e,$o),e.set(t.subarray(Cn)),e}function iA(e,t){pn(e&&e.byteLength===Ja,"curveSk must be 'crypto_sign_SECRETKEYBYTES' long"),pn(t&&t.byteLength===mn,"edSk must be 'crypto_sign_ed25519_SECRETKEYBYTES' long");var o=new Uint8Array(jI);return wr(o,t,32),o[0]&=248,o[31]&=127,o[31]|=64,e.set(o.subarray(0,Ja)),o.fill(0),e}function Je(e,t,o="Argument"){if(!e||t&&e.length<t)throw new Error(o+" must be a buffer"+(t?" of length "+t:""))}});var Si=Z(ae(),1);function U(e){if(!e||typeof e!="object"||Object.isFrozen(e))return e;for(let t of Object.values(e))U(t);return Object.freeze(e)}var Gt=U({family:"hiverelay-blind",major:1,minor:0,mediaType:"application/vnd.hiverelay.blind-v1"}),Oe=U({REQUEST:1,RESPONSE:2,ERROR:3,STREAM:4}),b=U({DESCRIBE:1,CELL:2,INBOX:3,CORE:4,FORWARD:5}),cr=U({1:"/api/blind/v1/describe",2:"/api/blind/v1/cell",3:"/api/blind/v1/inbox",4:"/api/blind/v1/core",5:"/api/blind/v1/forward"}),g=U({DESCRIBE:{GET:1,CHALLENGE:2,ADMISSION_PARAMETERS:3},CELL:{PUT:1,GET:2,RENEW:3,DROP:4,PROVE:5,BATCH_GET:6},INBOX:{CREATE:1,RENEW:2,CLOSE:3,APPEND:4,READ:5,WATCH:6},CORE:{MIRROR:1,PROVE:2,OPEN_REPLICATION:3},FORWARD:{OPEN:1,DATA:2,WINDOW:3,CLOSE:4}}),Tr=U({HTTPS_DIRECT:1,DIRECT_PROTOMUX_NOISE:2,OHTTP_INGRESS:3,OHTTP_GATEWAY:4,SPLIT_PROTOMUX_NOISE:5,HTTP3_MASQUE:6,TOR_V3_ONION:7,WEBTRANSPORT_WEBSOCKET_TUNNEL:8,MIX_PACKET_INGRESS:9}),rt=U({DIRECT_HTTP:1,DIRECT_NATIVE:2,OHTTP:4,TOR_HTTP:8,TOR_NATIVE:16,MASQUE_NATIVE:32}),Nt=U({ROLE_BITS_MASK:127,PRIVACY_PROFILE_BITS_MASK:255,ENVELOPE_CLASS_BITS_MASK:126,WIRE_CLASS_BITS_MASK:14}),$e=U({CELL_SIZE_CLASS_BITS_MASK:62,LEASE_CLASS_BITS_MASK:30,ENABLED_OPERATION_BITS_MASK:4194303,TRANSPORT_BITS_MASK:1022,MAX_DESCRIPTOR_BYTES:16384,MAX_DHT_POINTER_BYTES:1e3,MAX_RESPONSE_BYTES:4194304,MAX_BATCH_COUNT:64,MAX_ADMISSION_TOKEN_BYTES:4096,MAX_ADMISSION_RESOURCE_COST_ROWS:512,MAX_OHTTP_CONFIG_EPOCHS:120}),Fi=U({OPEN:1,PRIVATE:2}),Dt=U({STORED:1,SERVED:2,RENEWED:3,DROPPED:4}),Gs=U({RENEW:1,CLOSE:2}),ks=U({OPEN_CAPABILITY:0,SIGNATURE_REQUIRED:1}),dr=U({CREATED:1,RENEWED:2,CLOSED:3}),So=U({STORED:1}),lr=U({MIRROR_ACCEPTED:1,RECENTLY_SERVED:2}),Yi=U({FIN:1,ABORT:2}),kt=U({ACTIVE:1,DRAINING:2,RETIRED:3}),Xr=U({READY:1,UNSAFE:2,VERIFYING:3}),$r=U({VERIFIED:1,DEGRADED:2,FAILED:3}),Gi=U({STABLE:0,COPYING:1,CATCHING_UP:2,FENCED:3}),Jr=U({UNARY:0,CORE_CHILD:1,FORWARD_OPEN:2,FORWARD_ACTIVE:3}),Ot=U({REQUEST_COMMITMENT:1,RESULT_SIGNATURE:2,AUXILIARY_SIGNATURE:3}),vt=U({OPERATION_DEFINED_COMMITMENT_PREIMAGE:1,ED25519_DOMAIN_LEN64_PAYLOAD:2}),Fe=U({CELL_PUT:1,CELL_GET:2,CELL_RENEW:3,CELL_DROP:4,CELL_PROVE:5,CELL_BATCH_GET:6,INBOX_CREATE:7,INBOX_RENEW:8,INBOX_CLOSE:9,INBOX_APPEND:10,INBOX_READ:11,INBOX_WATCH:12,CORE_MIRROR:13,CORE_SERVE:14,CORE_OPEN_REPLICATION:15,FORWARD_OPEN:16}),Ye=U({DESCRIPTOR:101,HEALTH_RESULT:102,ADMISSION_PARAMETERS:103,CELL_RECEIPT:104,BATCH_GET_RESULT:105,INBOX_RECEIPT:106,INBOX_APPEND_ACK:107,INBOX_READ_RESULT:108,CORE_ACK:109,CORE_OPEN_RESULT:110,FORWARD_OPEN_RESULT:111}),To=U({OHTTP_KEY_CONFIG:201,IDENTITY_TRANSITION:202,DHT_POINTER:203,TRANSPORT_ROUTE:204,FORWARD_HOP_OPEN:205,FORWARD_HOP_ACCEPT:206,EXTERNAL_JOURNAL_TOPOLOGY:207,EXTERNAL_COMMIT_WITNESS:208,RESTORE_EVIDENCE_HEAD:209,BACKUP_MANIFEST:210,CLEAN_RESTORE_EVIDENCE:211,BACKUP_RETENTION_TRANSITION:212,FORWARD_ROUTE_SCOPE:213}),ki=U({CANONICAL_V1:1}),_o=U({MUST_BE_ABSENT:0,MUST_BE_PRESENT:1}),Uf=U([{domainId:1,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1cell-put"},{domainId:2,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1cell-get"},{domainId:3,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1cell-renew"},{domainId:4,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1cell-drop"},{domainId:5,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1cell-prove"},{domainId:6,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1cell-batch-get"},{domainId:7,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1inbox-create"},{domainId:8,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1inbox-renew"},{domainId:9,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1inbox-close"},{domainId:10,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1inbox-append"},{domainId:11,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1inbox-read"},{domainId:12,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1inbox-watch"},{domainId:13,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1core-mirror"},{domainId:14,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1core-serve"},{domainId:15,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.request.v1core-open-replication"},{domainId:16,purpose:1,recipeId:1,exactAsciiBytes:"hiverelay.blind.forward-open.v1"},{domainId:101,purpose:2,recipeId:2,exactAsciiBytes:"hiverelay.blind.descriptor.v1"},{domainId:102,purpose:2,recipeId:2,exactAsciiBytes:"hiverelay.blind.health-result.v1"},{domainId:103,purpose:2,recipeId:2,exactAsciiBytes:"hiverelay.blind.admission-parameters.v1"},{domainId:104,purpose:2,recipeId:2,exactAsciiBytes:"hiverelay.blind.cell-receipt.v1"},{domainId:105,purpose:2,recipeId:2,exactAsciiBytes:"hiverelay.blind.batch-get-result.v1"},{domainId:106,purpose:2,recipeId:2,exactAsciiBytes:"hiverelay.blind.inbox-receipt.v1"},{domainId:107,purpose:2,recipeId:2,exactAsciiBytes:"hiverelay.blind.inbox-append-ack.v1"},{domainId:108,purpose:2,recipeId:2,exactAsciiBytes:"hiverelay.blind.inbox-read-result.v1"},{domainId:109,purpose:2,recipeId:2,exactAsciiBytes:"hiverelay.blind.core-ack.v1"},{domainId:110,purpose:2,recipeId:2,exactAsciiBytes:"hiverelay.blind.core-open-result.v1"},{domainId:111,purpose:2,recipeId:2,exactAsciiBytes:"hiverelay.blind.forward-open-result.v1"},{domainId:201,purpose:3,recipeId:2,exactAsciiBytes:"hiverelay.blind.ohttp-key-config.v1"},{domainId:202,purpose:3,recipeId:2,exactAsciiBytes:"hiverelay.blind.identity-transition.v1"},{domainId:203,purpose:3,recipeId:2,exactAsciiBytes:"hiverelay.blind.dht-pointer.v1"},{domainId:204,purpose:3,recipeId:2,exactAsciiBytes:"hiverelay.blind.transport-route.v1"},{domainId:205,purpose:3,recipeId:2,exactAsciiBytes:"hiverelay.blind.forward-hop-open.v1"},{domainId:206,purpose:3,recipeId:2,exactAsciiBytes:"hiverelay.blind.forward-hop-accept.v1"},{domainId:207,purpose:3,recipeId:2,exactAsciiBytes:"hiverelay.blind.external-journal-topology.v1"},{domainId:208,purpose:3,recipeId:2,exactAsciiBytes:"hiverelay.blind.external-commit-witness.v1"},{domainId:209,purpose:3,recipeId:2,exactAsciiBytes:"hiverelay.blind.restore-evidence-head.v1"},{domainId:210,purpose:3,recipeId:2,exactAsciiBytes:"hiverelay.blind.backup-manifest.v1"},{domainId:211,purpose:3,recipeId:2,exactAsciiBytes:"hiverelay.blind.clean-restore-evidence.v1"},{domainId:212,purpose:3,recipeId:2,exactAsciiBytes:"hiverelay.blind.backup-retention-transition.v1"},{domainId:213,purpose:3,recipeId:2,exactAsciiBytes:"hiverelay.blind.forward-route-scope.v1"}]),Qf=U([{costClassRuleId:1,ruleKind:1},{costClassRuleId:2,ruleKind:2},{costClassRuleId:3,ruleKind:3},{costClassRuleId:4,ruleKind:4},{costClassRuleId:5,ruleKind:5},{costClassRuleId:6,ruleKind:6},{costClassRuleId:7,ruleKind:7},{costClassRuleId:8,ruleKind:8},{costClassRuleId:9,ruleKind:9},{costClassRuleId:10,ruleKind:10},{costClassRuleId:11,ruleKind:11}]),Mf=U([{errorProfileId:1,code:1,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:2,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:3,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:4,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:5,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:6,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:7,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:8,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:9,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:1,retryAfterMode:0},{errorProfileId:1,code:10,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:11,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:12,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:13,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:14,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:15,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:16,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:1,retryAfterMode:0},{errorProfileId:1,code:17,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:1,retryAfterMode:0},{errorProfileId:1,code:18,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:1,retryAfterMode:1},{errorProfileId:1,code:19,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0},{errorProfileId:1,code:20,directCorrelatedStatus:200,protectedInnerStatus:200,retryable:0,retryAfterMode:0}]),Et=U({1:4096,2:16384,3:65536,4:262144,5:1048576}),vs=U({1:4096,2:16384,3:65536}),Wt=U({1:4096,2:16384,3:65536,4:262144,5:1048576,6:8388608}),vi=U({1:4096,2:16384,3:65535}),Ws=U({1:{grantedInitialWindow:65536,maxCircuitBytes:16777216,idleMillis:3e4,lifetimeMillis:6e5},2:{grantedInitialWindow:262144,maxCircuitBytes:67108864,idleMillis:6e4,lifetimeMillis:18e5},3:{grantedInitialWindow:1048576,maxCircuitBytes:268435456,idleMillis:12e4,lifetimeMillis:36e5}}),js=U({1:{maxSessionBytes:16777216,idleMillis:3e4,lifetimeMillis:6e5},2:{maxSessionBytes:67108864,idleMillis:6e4,lifetimeMillis:18e5},3:{maxSessionBytes:268435456,idleMillis:12e4,lifetimeMillis:36e5}}),ee=U({PREFIX_BYTES:4,HEADER_BYTES:41,REQUEST_ID_BYTES:16,MAX_BODY_BYTES:4194304,MAX_FRAME_AFTER_PREFIX_BYTES:4194368,MAX_WIRE_BYTES:4194372,MAX_FORWARD_DATA_BYTES:65535,MAX_FORWARD_WINDOW_BYTES:1048576}),Zr=U([{familyId:1,operationId:1,requestSchemaId:16,resultSchemaId:39,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:0,costClassRuleId:0,requestCommitmentDomainId:0,resultSignatureDomainId:101,errorProfileId:1,transportSupportBits:31},{familyId:1,operationId:2,requestSchemaId:31,resultSchemaId:32,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:0,costClassRuleId:0,requestCommitmentDomainId:0,resultSignatureDomainId:102,errorProfileId:1,transportSupportBits:31},{familyId:1,operationId:3,requestSchemaId:9,resultSchemaId:2,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:0,costClassRuleId:0,requestCommitmentDomainId:0,resultSignatureDomainId:103,errorProfileId:1,transportSupportBits:31},{familyId:2,operationId:1,requestSchemaId:68,resultSchemaId:36,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:1056768,maxResultBodyBytes:16384,admissionMode:2,costClassRuleId:1,requestCommitmentDomainId:1,resultSignatureDomainId:104,errorProfileId:1,transportSupportBits:31},{familyId:2,operationId:2,requestSchemaId:54,resultSchemaId:53,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:1048832,admissionMode:1,costClassRuleId:2,requestCommitmentDomainId:2,resultSignatureDomainId:0,errorProfileId:1,transportSupportBits:31},{familyId:2,operationId:3,requestSchemaId:71,resultSchemaId:36,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:2,costClassRuleId:3,requestCommitmentDomainId:3,resultSignatureDomainId:104,errorProfileId:1,transportSupportBits:31},{familyId:2,operationId:4,requestSchemaId:49,resultSchemaId:36,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:0,costClassRuleId:0,requestCommitmentDomainId:4,resultSignatureDomainId:104,errorProfileId:1,transportSupportBits:31},{familyId:2,operationId:5,requestSchemaId:67,resultSchemaId:66,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:1049600,admissionMode:1,costClassRuleId:2,requestCommitmentDomainId:5,resultSignatureDomainId:104,errorProfileId:1,transportSupportBits:31},{familyId:2,operationId:6,requestSchemaId:8,resultSchemaId:6,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:4194304,admissionMode:1,costClassRuleId:4,requestCommitmentDomainId:6,resultSignatureDomainId:105,errorProfileId:1,transportSupportBits:31},{familyId:3,operationId:1,requestSchemaId:57,resultSchemaId:62,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:2,costClassRuleId:5,requestCommitmentDomainId:7,resultSignatureDomainId:106,errorProfileId:1,transportSupportBits:31},{familyId:3,operationId:2,requestSchemaId:58,resultSchemaId:62,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:2,costClassRuleId:6,requestCommitmentDomainId:8,resultSignatureDomainId:106,errorProfileId:1,transportSupportBits:31},{familyId:3,operationId:3,requestSchemaId:58,resultSchemaId:62,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:0,costClassRuleId:0,requestCommitmentDomainId:9,resultSignatureDomainId:106,errorProfileId:1,transportSupportBits:31},{familyId:3,operationId:4,requestSchemaId:56,resultSchemaId:55,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:70656,maxResultBodyBytes:16384,admissionMode:2,costClassRuleId:7,requestCommitmentDomainId:10,resultSignatureDomainId:107,errorProfileId:1,transportSupportBits:31},{familyId:3,operationId:5,requestSchemaId:61,resultSchemaId:59,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:4194304,admissionMode:1,costClassRuleId:4,requestCommitmentDomainId:11,resultSignatureDomainId:108,errorProfileId:1,transportSupportBits:31},{familyId:3,operationId:6,requestSchemaId:63,resultSchemaId:59,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:4194304,admissionMode:2,costClassRuleId:8,requestCommitmentDomainId:12,resultSignatureDomainId:108,errorProfileId:1,transportSupportBits:31},{familyId:4,operationId:1,requestSchemaId:43,resultSchemaId:15,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:2,costClassRuleId:9,requestCommitmentDomainId:13,resultSignatureDomainId:109,errorProfileId:1,transportSupportBits:31},{familyId:4,operationId:2,requestSchemaId:46,resultSchemaId:47,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:4194304,admissionMode:1,costClassRuleId:4,requestCommitmentDomainId:14,resultSignatureDomainId:109,errorProfileId:1,transportSupportBits:31},{familyId:4,operationId:3,requestSchemaId:45,resultSchemaId:44,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:1,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:2,costClassRuleId:10,requestCommitmentDomainId:15,resultSignatureDomainId:110,errorProfileId:1,transportSupportBits:18},{familyId:5,operationId:1,requestSchemaId:27,resultSchemaId:26,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:2,maxRequestBodyBytes:131072,maxResultBodyBytes:131072,admissionMode:2,costClassRuleId:11,requestCommitmentDomainId:16,resultSignatureDomainId:111,errorProfileId:1,transportSupportBits:50},{familyId:5,operationId:2,requestSchemaId:23,resultSchemaId:0,allowedRequestKindBits:8,allowedResultKindBits:8,streamTransition:3,maxRequestBodyBytes:66e3,maxResultBodyBytes:66e3,admissionMode:0,costClassRuleId:0,requestCommitmentDomainId:0,resultSignatureDomainId:0,errorProfileId:1,transportSupportBits:50},{familyId:5,operationId:3,requestSchemaId:30,resultSchemaId:0,allowedRequestKindBits:8,allowedResultKindBits:8,streamTransition:3,maxRequestBodyBytes:1024,maxResultBodyBytes:1024,admissionMode:0,costClassRuleId:0,requestCommitmentDomainId:0,resultSignatureDomainId:0,errorProfileId:1,transportSupportBits:50},{familyId:5,operationId:4,requestSchemaId:22,resultSchemaId:0,allowedRequestKindBits:8,allowedResultKindBits:12,streamTransition:3,maxRequestBodyBytes:1024,maxResultBodyBytes:16384,admissionMode:0,costClassRuleId:0,requestCommitmentDomainId:0,resultSignatureDomainId:0,errorProfileId:1,transportSupportBits:50}]),Op=U([{familyId:1,operationId:1,requestSchemaId:16,resultSchemaId:39,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:0,costClassRuleId:0,requestCommitmentDomainId:0,resultSignatureDomainId:101,errorProfileId:1,transportSupportBits:31},{familyId:1,operationId:2,requestSchemaId:31,resultSchemaId:32,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:0,costClassRuleId:0,requestCommitmentDomainId:0,resultSignatureDomainId:102,errorProfileId:1,transportSupportBits:31},{familyId:1,operationId:3,requestSchemaId:9,resultSchemaId:2,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:0,costClassRuleId:0,requestCommitmentDomainId:0,resultSignatureDomainId:103,errorProfileId:1,transportSupportBits:31},{familyId:2,operationId:1,requestSchemaId:68,resultSchemaId:36,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:1056768,maxResultBodyBytes:16384,admissionMode:2,costClassRuleId:1,requestCommitmentDomainId:1,resultSignatureDomainId:104,errorProfileId:1,transportSupportBits:31},{familyId:2,operationId:2,requestSchemaId:54,resultSchemaId:53,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:1048832,admissionMode:1,costClassRuleId:2,requestCommitmentDomainId:2,resultSignatureDomainId:0,errorProfileId:1,transportSupportBits:31},{familyId:2,operationId:3,requestSchemaId:71,resultSchemaId:36,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:2,costClassRuleId:3,requestCommitmentDomainId:3,resultSignatureDomainId:104,errorProfileId:1,transportSupportBits:31},{familyId:2,operationId:4,requestSchemaId:49,resultSchemaId:36,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:0,costClassRuleId:0,requestCommitmentDomainId:4,resultSignatureDomainId:104,errorProfileId:1,transportSupportBits:31},{familyId:2,operationId:5,requestSchemaId:67,resultSchemaId:66,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:1049600,admissionMode:1,costClassRuleId:2,requestCommitmentDomainId:5,resultSignatureDomainId:104,errorProfileId:1,transportSupportBits:31},{familyId:2,operationId:6,requestSchemaId:8,resultSchemaId:6,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:4194304,admissionMode:1,costClassRuleId:4,requestCommitmentDomainId:6,resultSignatureDomainId:105,errorProfileId:1,transportSupportBits:31},{familyId:3,operationId:1,requestSchemaId:57,resultSchemaId:62,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:2,costClassRuleId:5,requestCommitmentDomainId:7,resultSignatureDomainId:106,errorProfileId:1,transportSupportBits:31},{familyId:3,operationId:2,requestSchemaId:58,resultSchemaId:62,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:2,costClassRuleId:6,requestCommitmentDomainId:8,resultSignatureDomainId:106,errorProfileId:1,transportSupportBits:31},{familyId:3,operationId:3,requestSchemaId:58,resultSchemaId:62,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:0,costClassRuleId:0,requestCommitmentDomainId:9,resultSignatureDomainId:106,errorProfileId:1,transportSupportBits:31},{familyId:3,operationId:4,requestSchemaId:56,resultSchemaId:55,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:70656,maxResultBodyBytes:16384,admissionMode:2,costClassRuleId:7,requestCommitmentDomainId:10,resultSignatureDomainId:107,errorProfileId:1,transportSupportBits:31},{familyId:3,operationId:5,requestSchemaId:61,resultSchemaId:59,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:4194304,admissionMode:1,costClassRuleId:4,requestCommitmentDomainId:11,resultSignatureDomainId:108,errorProfileId:1,transportSupportBits:31},{familyId:3,operationId:6,requestSchemaId:63,resultSchemaId:59,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:4194304,admissionMode:2,costClassRuleId:8,requestCommitmentDomainId:12,resultSignatureDomainId:108,errorProfileId:1,transportSupportBits:31},{familyId:4,operationId:1,requestSchemaId:43,resultSchemaId:15,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:16384,admissionMode:2,costClassRuleId:9,requestCommitmentDomainId:13,resultSignatureDomainId:109,errorProfileId:1,transportSupportBits:31},{familyId:4,operationId:2,requestSchemaId:46,resultSchemaId:47,allowedRequestKindBits:1,allowedResultKindBits:6,streamTransition:0,maxRequestBodyBytes:16384,maxResultBodyBytes:4194304,admissionMode:1,costClassRuleId:4,requestCommitmentDomainId:14,resultSignatureDomainId:109,errorProfileId:1,transportSupportBits:31}]),qf=U([{familyId:4,operationId:3},{familyId:5,operationId:1},{familyId:5,operationId:2},{familyId:5,operationId:3},{familyId:5,operationId:4}]),Wi=131071;var zs=38440;function fr(e){return Uf.find(t=>t.domainId===e)||null}function ji(e){return Qf.find(t=>t.costClassRuleId===e)||null}function zi(e,t){return Mf.find(o=>o.errorProfileId===e&&o.code===t)||null}function Hf(e,t){return Zr.findIndex(o=>o.familyId===e&&o.operationId===t)}function No(e,t){let o=Hf(e,t);return o<0?0:1<<o}function Lt(e,t){return Zr.find(o=>o.familyId===e&&o.operationId===t)||null}function Ir(e,t){return Lt(e,t)!==null}function Xs(e,t){return qf.some(o=>o.familyId===e&&o.operationId===t)}function Do(e,t){return Ir(e,t)&&!Xs(e,t)}function $s(e,t){let o=Lt(e,t);if(o&&!Xs(e,t))return o;let r=new Error("operation is unknown or reserved by the active release profile");throw r.code="UNSUPPORTED_OPERATION",r}var tt=U({profile:"wire-authority-v1",protocolFamily:"hiverelay-blind",protocolMajor:1,protocolMinor:0,specArtifact:"docs/protocol/HIVERELAY-BLIND-WIRE-V1.md",abiArtifact:"packages/blind-protocol/hiverelay-blind-abi-v1.cenc",vectorManifestArtifact:"packages/blind-protocol/vector-manifest-v1.cenc",specHash:"c9ddd235c3963461174e3de13c25a4c995b53ff320be822d8304f870766b6592",abiHash:"199ba15d94d4d112cfac520a67055ce15ec870f0f6f7bd9adaaf47d552334567",vectorSetHash:"fa54012cd0d7e4e620878c67e61f435ecb31ddec05a6283917987cc84279ee05",wireSchemaCount:73,operationCount:22,advertisedOperationCount:17,reservedOperationCount:5,advertisedOperationBits:131071,reservedOperationBits:4063232,errorCount:20,domainCount:40,vectorCount:237}),Lp=U({profile:tt.profile,specHash:tt.specHash,abiHash:tt.abiHash,vectorSetHash:tt.vectorSetHash,wireSchemaCount:tt.wireSchemaCount,operationCount:tt.operationCount,advertisedOperationCount:tt.advertisedOperationCount,reservedOperationCount:tt.reservedOperationCount,advertisedOperationBits:tt.advertisedOperationBits,reservedOperationBits:tt.reservedOperationBits,errorCount:tt.errorCount,domainCount:tt.domainCount,vectorCount:tt.vectorCount,releaseBlockers:[],releaseReady:!0});var te=Z(ae(),1);var we=Z(ae(),1);var Xi=class extends Error{constructor(t,o){super(o),this.name="BlindProtocolError",this.code=t}};function y(e,t){throw new Xi(e,t)}var Vf=(1n<<64n)-1n;function P(e){y("BAD_ENCODING",e)}function ut(e,t){return(!e||typeof e.byteLength!="number")&&P(`${t} must be bytes`),we.default.isBuffer(e)?e:ArrayBuffer.isView(e)?we.default.from(e.buffer,e.byteOffset,e.byteLength):we.default.from(e)}function Ge(e,t,o){(!Number.isSafeInteger(t)||t<0||e.end-e.start<t)&&P(`truncated ${o}`)}function Lo(e,t,o){return(!Number.isSafeInteger(e)||e<0||e>t)&&P(`${o} is outside its unsigned range`),e}function Js(e,t){return typeof e=="number"&&((!Number.isSafeInteger(e)||e<0)&&P(`${t} must be an unsigned safe integer or bigint`),e=BigInt(e)),(typeof e!="bigint"||e<0n||e>Vf)&&P(`${t} is outside u64`),e}function Ff(e,t){return e[t]|e[t+1]<<8}function Yf(e,t){return e[t]+e[t+1]*256+e[t+2]*65536+e[t+3]*16777216}function Gf(e,t,o){e[o]=t,e[o+1]=t>>>8}function kf(e,t,o){e[o]=t,e[o+1]=t>>>8,e[o+2]=t>>>16,e[o+3]=t>>>24}function Zs(e,t,o){let r=0n;if(o)for(let i=7;i>=0;i--)r=r<<8n|BigInt(e[t+i]);else for(let i=0;i<8;i++)r=r<<8n|BigInt(e[t+i]);return r}function ea(e,t,o,r){if(r)for(let i=0;i<8;i++)e[o+i]=Number(t&0xffn),t>>=8n;else for(let i=7;i>=0;i--)e[o+i]=Number(t&0xffn),t>>=8n}function $i(e,t,o){return{preencode(r,i){Lo(i,t,o),r.end+=e},encode(r,i){i=Lo(i,t,o),Ge(r,e,o);for(let n=e-1;n>=0;n--)r.buffer[r.start+n]=i&255,i=Math.floor(i/256);r.start+=e},decode(r){Ge(r,e,o);let i=0;for(let n=0;n<e;n++)i=i*256+r.buffer[r.start++];return i}}}var h=$i(1,255,"u8"),q=$i(2,65535,"u16"),D=$i(4,4294967295,"u32"),S={preencode(e,t){Js(t,"u64"),e.end+=8},encode(e,t){t=Js(t,"u64"),Ge(e,8,"u64"),ea(e.buffer,t,e.start,!1),e.start+=8},decode(e){Ge(e,8,"u64");let t=Zs(e.buffer,e.start,!1);return e.start+=8,t}},_r={preencode(e,t){t=Lo(t,Number.MAX_SAFE_INTEGER,"compact uint"),e.end+=t<=252?1:t<=65535?3:t<=4294967295?5:9},encode(e,t){t=Lo(t,Number.MAX_SAFE_INTEGER,"compact uint");let o=t<=252?1:t<=65535?3:t<=4294967295?5:9;if(Ge(e,o,"compact uint"),o===1){e.buffer[e.start++]=t;return}if(o===3){e.buffer[e.start++]=253,Gf(e.buffer,t,e.start),e.start+=2;return}if(o===5){e.buffer[e.start++]=254,kf(e.buffer,t,e.start),e.start+=4;return}e.buffer[e.start++]=255,ea(e.buffer,BigInt(t),e.start,!0),e.start+=8},decode(e){Ge(e,1,"compact uint");let t=e.buffer[e.start++];if(t<=252)return t;if(t===253){Ge(e,2,"compact uint");let r=Ff(e.buffer,e.start);return e.start+=2,r<=252&&P("non-canonical compact uint"),r}if(t===254){Ge(e,4,"compact uint");let r=Yf(e.buffer,e.start);return e.start+=4,r<=65535&&P("non-canonical compact uint"),r}Ge(e,8,"compact uint");let o=Zs(e.buffer,e.start,!0);return e.start+=8,(o<=0xffffffffn||o>BigInt(Number.MAX_SAFE_INTEGER))&&P("non-canonical or unsupported compact uint"),Number(o)}};function _e(e,t=`bytes[${e}]`){if(!Number.isSafeInteger(e)||e<0)throw new TypeError("fixed byte length must be non-negative");return{preencode(o,r){r=ut(r,t),r.byteLength!==e&&P(`${t} must be exactly ${e} bytes`),o.end+=e},encode(o,r){r=ut(r,t),r.byteLength!==e&&P(`${t} must be exactly ${e} bytes`),Ge(o,e,t),we.default.copy(r,o.buffer,o.start),o.start+=e},decode(o){Ge(o,e,t);let r=o.buffer.subarray(o.start,o.start+e);return o.start+=e,o.copyBytes===!0?we.default.from(r):r}}}function ta(e,t="constant bytes"){e=ut(e,t);let o=_e(e.byteLength,t);return{preencode(r,i){i==null&&(i=e),i=ut(i,t),we.default.equals(i,e)||P(`${t} does not match its fixed value`),o.preencode(r,e)},encode(r,i){i==null&&(i=e),i=ut(i,t),we.default.equals(i,e)||P(`${t} does not match its fixed value`),o.encode(r,e)},decode(r){let i=o.decode(r);return we.default.equals(i,e)||P(`${t} does not match its fixed value`),i}}}function Ji(e,t,o="class-selected bytes"){function r(i){let n=i&&t[i[e]];return(!Number.isSafeInteger(n)||n<0)&&P(`${o} has an unknown ${e}`),n}return{preencode(i,n,s){n=ut(n,o);let a=r(s);n.byteLength!==a&&P(`${o} must be exactly ${a} bytes`),i.end+=a},encode(i,n,s){n=ut(n,o);let a=r(s);n.byteLength!==a&&P(`${o} must be exactly ${a} bytes`),Ge(i,a,o),we.default.copy(n,i.buffer,i.start),i.start+=a},decode(i,n){let s=r(n);Ge(i,s,o);let a=i.buffer.subarray(i.start,i.start+s);return i.start+=s,i.copyBytes===!0?we.default.from(a):a}}}function ke(e,t,o="bounded bytes"){if(!Number.isSafeInteger(e)||!Number.isSafeInteger(t)||e<0||t<e)throw new TypeError("invalid bounded byte range");return{preencode(r,i){i=ut(i,o),(i.byteLength<e||i.byteLength>t)&&P(`${o} length is outside ${e}..${t}`),_r.preencode(r,i.byteLength),r.end+=i.byteLength},encode(r,i){i=ut(i,o),(i.byteLength<e||i.byteLength>t)&&P(`${o} length is outside ${e}..${t}`),_r.encode(r,i.byteLength),Ge(r,i.byteLength,o),we.default.copy(i,r.buffer,r.start),r.start+=i.byteLength},decode(r){let i=_r.decode(r);(i<e||i>t)&&P(`${o} length is outside ${e}..${t}`),Ge(r,i,o);let n=r.buffer.subarray(r.start,r.start+i);return r.start+=i,r.copyBytes===!0?we.default.from(n):n}}}function Oo(e,t,o,r,i){e=ut(e,r),(e.byteLength<t||e.byteLength>o)&&P(`${r} length is outside ${t}..${o}`);for(let s=0;s<e.byteLength;s++)e[s]===0&&P(`${r} contains an embedded NUL`),i&&(e[s]<32||e[s]>126)&&P(`${r} must be printable ASCII`);let n=we.default.toString(e,"utf8");return we.default.equals(we.default.from(n,"utf8"),e)||P(`${r} is not strict UTF-8`),n!==n.normalize("NFC")&&P(`${r} must already be NFC`),{bytes:e,text:n}}function ra(e,t,o,r){let i=ke(e,t,o);return{preencode(n,s){i.preencode(n,Oo(s,e,t,o,r).bytes)},encode(n,s){i.encode(n,Oo(s,e,t,o,r).bytes)},decode(n){let s=i.decode(n);return Oo(s,e,t,o,r),s}}}function Zi(e,t,o="canonical UTF-8"){return ra(e,t,o,!1)}function Po(e,t,o="canonical ASCII"){return ra(e,t,o,!0)}function Nr(e,t={}){let o=t.name||"canonical URL",{text:r}=Oo(e,1,512,o,!1),i=/^(https?):\/\/([^/?#]+)(\/[^?#]*)$/.exec(r);i||P(`${o} must contain a canonical scheme, authority, and path`);let n=i[1],s=i[2],a=i[3];s.includes("@")&&P(`${o} must not contain userinfo`);let d,f;if(s.startsWith("[")){let K=s.indexOf("]");(K<0||s[K+1]!==":")&&P(`${o} requires an explicit port`),d=s.slice(0,K+1),f=s.slice(K+2)}else{let K=s.lastIndexOf(":");(K<=0||s.indexOf(":")!==K)&&P(`${o} requires an explicit port`),d=s.slice(0,K),f=s.slice(K+1)}d!==d.toLowerCase()&&P(`${o} host must be lowercase`),/^[1-9][0-9]{0,4}$/.test(f)||P(`${o} port must use shortest decimal form`),Number(f)>65535&&P(`${o} port is outside 1..65535`),/%(?![0-9A-F]{2})/.test(a)&&P(`${o} has a non-canonical percent escape`);let E;try{E=new URL(r)}catch{P(`${o} is not a valid URL`)}(E.username||E.password||E.search||E.hash||E.hostname!==d||E.pathname!==a)&&P(`${o} contains non-canonical components`);let _=/^[a-z2-7]{56}\.onion$/.test(d);return t.requireOnion===!0?(!_||n!=="http"&&n!=="https")&&P(`${o} must be a v3 onion URL`):(n!=="https"||_||d.endsWith(".onion"))&&P(`${o} must use HTTPS to a non-onion host`),e}function bt(e="canonical HTTPS URL"){let t=Zi(1,512,e);return{preencode(o,r){Nr(r,{name:e}),t.preencode(o,r)},encode(o,r){Nr(r,{name:e}),t.encode(o,r)},decode(o){let r=t.decode(o);return Nr(r,{name:e}),r}}}function z(e,t="optional value"){return{preencode(o,r){h.preencode(o,r==null?0:1),r!=null&&e.preencode(o,r)},encode(o,r){h.encode(o,r==null?0:1),r!=null&&e.encode(o,r)},decode(o){let r=h.decode(o);return r===0?null:(r!==1&&P(`${t} presence tag must be 0 or 1`),e.decode(o))}}}function ve(e,t,o,r="array"){if(!Number.isSafeInteger(t)||!Number.isSafeInteger(o)||t<0||o<t)throw new TypeError("invalid array bounds");return{preencode(i,n){(!Array.isArray(n)||n.length<t||n.length>o)&&P(`${r} count is outside ${t}..${o}`),_r.preencode(i,n.length);for(let s of n)e.preencode(i,s)},encode(i,n){(!Array.isArray(n)||n.length<t||n.length>o)&&P(`${r} count is outside ${t}..${o}`),_r.encode(i,n.length);for(let s of n)e.encode(i,s)},decode(i){let n=_r.decode(i);(n<t||n>o)&&P(`${r} count is outside ${t}..${o}`);let s=new Array(n);for(let a=0;a<n;a++)s[a]=e.decode(i);return s}}}function R(e,t={}){if(!Array.isArray(e)||e.length===0)throw new TypeError("struct requires fields");let o={preencode(r,i){(!i||typeof i!="object")&&P(`${t.name||"struct"} must be an object`);for(let[n,s]of e)s.preencode(r,i[n],i);t.validate&&t.validate(i)},encode(r,i){(!i||typeof i!="object")&&P(`${t.name||"struct"} must be an object`);for(let[n,s]of e)s.encode(r,i[n],i)},decode(r){let i={};for(let[n,s]of e)i[n]=s.decode(r,i);return t.validate&&t.validate(i),i}};return Object.defineProperties(o,{schemaName:{value:t.name||null},schemaFields:{value:Object.freeze(e.map(([r])=>r))}}),o}function pt(e,t,o){return{preencode(r,i){i==null&&(i=t),i!==t&&P(`${o} must be ${t}`),e.preencode(r,t)},encode(r,i){i==null&&(i=t),i!==t&&P(`${o} must be ${t}`),e.encode(r,t)},decode(r){let i=e.decode(r);return i!==t&&P(`${o} must be ${t}`),i}}}function C(e,t,o,r){return{preencode(i,n){(typeof n!="number"||n<t||n>o)&&P(`${r} is outside ${t}..${o}`),e.preencode(i,n)},encode(i,n){(typeof n!="number"||n<t||n>o)&&P(`${r} is outside ${t}..${o}`),e.encode(i,n)},decode(i){let n=e.decode(i);return(n<t||n>o)&&P(`${r} is outside ${t}..${o}`),n}}}function Se(e,t){let o={start:0,end:0,buffer:null,copyBytes:!1};return e.preencode(o,t),o.buffer=we.default.alloc(o.end),o.start=0,e.encode(o,t),o.start!==o.end&&P("encoder did not fill its canonical allocation"),o.buffer}function jt(e,t,o={}){t=ut(t,"canonical input");let r={start:0,end:t.byteLength,buffer:t,copyBytes:o.copyBytes===!0},i=e.decode(r);return r.start!==r.end&&P("trailing bytes after canonical value"),i}var X=Z(ae(),1);var fc=Z(en(),1),Ic=Z(Qo(),1),ei=Z(xn(),1),ti=Object.freeze({crypto_generichash:fc.default.crypto_generichash,crypto_sign_detached:ei.default.crypto_sign_detached,crypto_sign_seed_keypair:ei.default.crypto_sign_seed_keypair,crypto_sign_verify_detached:ei.default.crypto_sign_verify_detached,randombytes_buf:Ic.default.randombytes_buf});var nA=32,sA=(1n<<64n)-1n,no=Object.freeze({SPEC:"hiverelay.blind.spec-hash.v1",ABI:"hiverelay.blind.abi-hash.v1",VECTOR_SET:"hiverelay.blind.vector-set-hash.v1",EVIDENCE_FORMAT:"hiverelay.blind.evidence-format-hash.v1",EVIDENCE_VECTOR_SET:"hiverelay.blind.evidence-vector-set-hash.v1",STORE_FORMAT:"hiverelay.blind.store-format-hash.v1",STORE_VECTOR_SET:"hiverelay.blind.store-vector-set-hash.v1",IMPLEMENTATION_SPEC:"hiverelay.blind.implementation-spec-hash.v1",OWNER_DECISIONS:"hiverelay.blind.owner-decisions-hash.v1",RELEASE_CLOSURE:"hiverelay.blind.release-closure-hash.v1",CLIENT_COMPOSITION_FORMAT:"hiverelay.blind.client-composition-format-hash.v1",CLIENT_COMPOSITION_VECTOR_SET:"hiverelay.blind.client-composition-vector-set-hash.v1",LOCAL_CHECKPOINT:"hiverelay.blind.local-checkpoint-hash.v1",CONTROL_SNAPSHOT:"hiverelay.blind.control-snapshot.v1",BUILD_ARTIFACT:"hiverelay.blind.build-artifact-hash.v1",BUILD_MANIFEST:"hiverelay.blind.build-manifest-hash.v1",PROTOCOL_PROFILE:"hiverelay.blind.protocol-profile-hash.v1",TRANSPORT_PROFILE:"hiverelay.blind.transport-profile-hash.v1",DESCRIPTOR:"hiverelay.blind.descriptor-hash.v1",ADMISSION_PARAMETERS:"hiverelay.blind.admission-parameters-hash.v1",DURABILITY_PROFILE:"hiverelay.blind.durability-profile-hash.v1",DURABILITY_CONTINUITY:"hiverelay.blind.durability-continuity-hash.v1",PERSISTENT_RESULT:"hiverelay.blind.persistent-result.v1",REQUEST:"hiverelay.blind.request.v1",CORE_OPEN_RESULT:"hiverelay.blind.core-open-result.v1"});function yr(e,t){return typeof e=="string"?X.default.from(e,"utf8"):((!e||typeof e.byteLength!="number")&&y("BAD_ENCODING",`${t} must be bytes`),X.default.isBuffer(e)?e:ArrayBuffer.isView(e)?X.default.from(e.buffer,e.byteOffset,e.byteLength):X.default.from(e))}function st(e,t="u64 length"){typeof e=="number"&&((!Number.isSafeInteger(e)||e<0)&&y("BAD_ENCODING",`${t} is invalid`),e=BigInt(e)),(typeof e!="bigint"||e<0n||e>sA)&&y("BAD_ENCODING",`${t} is invalid`);let o=X.default.alloc(8);for(let r=7;r>=0;r--)o[r]=Number(e&0xffn),e>>=8n;return o}function Sn(e,t,o,r){(!Number.isSafeInteger(e)||e<0||e>o)&&y("BAD_ENCODING",`${r} is outside its unsigned range`);let i=X.default.alloc(t);for(let n=t-1;n>=0;n--)i[n]=e&255,e=Math.floor(e/256);return i}var lt=(e,t)=>Sn(e,1,255,t),Rn=(e,t)=>Sn(e,2,65535,t),Qr=(e,t)=>Sn(e,4,4294967295,t);function Q(e,t,o){return e=yr(e,o),e.byteLength!==t&&y("BAD_ENCODING",`${o} must be exactly ${t} bytes`),e}function Ur(e,t,o){return e=Q(e,t,o),Tn(e)&&y("BAD_ENCODING",`${o} must be nonzero`),e}function Tn(e){for(let t=0;t<e.byteLength;t++)if(e[t]!==0)return!1;return!0}function ce(e){e=yr(e,"hash input");let t=X.default.alloc(nA);return ti.crypto_generichash(t,e),t}function Ac(e,t){(typeof e!="string"||e.length===0||/[^\x20-\x7e]/.test(e))&&y("BAD_ENCODING","hash domain must be non-empty printable ASCII"),t=yr(t,"hash input");let o=X.default.concat([X.default.from(e,"ascii"),st(t.byteLength),t]);return ce(o)}function uc(e,t){return(typeof e!="string"||e.length===0||/[^\x20-\x7e]/.test(e))&&y("BAD_ENCODING","hash domain must be non-empty printable ASCII"),t=yr(t,"hash input"),ce(X.default.concat([X.default.from(e,"ascii"),t]))}var pc=e=>uc(no.DESCRIPTOR,e),yc=e=>uc(no.ADMISSION_PARAMETERS,e),hc=e=>Ac(no.DURABILITY_PROFILE,e),mc=e=>Ac(no.DURABILITY_CONTINUITY,e);function Cc(e,t,o){Ir(e,t)||y("BAD_ENCODING","persistent result references an unknown operation");let r=yr(o,"unsigned persistent result");return ce(X.default.concat([X.default.from(no.PERSISTENT_RESULT,"ascii"),lt(e,"persistent result familyId"),lt(t,"persistent result operationId"),st(r.byteLength,"unsigned persistent result length"),r]))}function Ec(e){(!e||typeof e!="object")&&y("BAD_ENCODING","core mirror commitment input must be an object"),(!Number.isSafeInteger(e.leaseClass)||e.leaseClass<1||e.leaseClass>4)&&y("BAD_ENCODING","leaseClass is outside 1..4");let t=st(e.length,"length");return Tn(t)&&y("BAD_ENCODING","length must be nonzero"),yt(Fe.CORE_MIRROR,[Ur(e.relayPublicKey,32,"relayPublicKey"),Ur(e.corePublicKey,32,"corePublicKey"),st(e.fork,"fork"),t,Ur(e.signedHeadHash,32,"signedHeadHash"),lt(e.leaseClass,"leaseClass"),Q(e.clientNonce,32,"clientNonce")])}var aA=ve({preencode(e,t){let o=st(t,"block index");e.end+=o.byteLength},encode(e,t){let o=st(t,"block index");X.default.copy(o,e.buffer,e.start),e.start+=o.byteLength},decode(){throw new Error("core commitment block-index encoding is encode-only")}},1,16,"core commitment block indices");function bc(e){(!e||typeof e!="object")&&y("BAD_ENCODING","core serve commitment input must be an object");let t=st(e.length,"length");Tn(t)&&y("BAD_ENCODING","length must be nonzero"),Array.isArray(e.blockIndices)||y("BAD_ENCODING","blockIndices must be an array");let o=-1n;for(let r of e.blockIndices){let i=st(r,"block index"),n=0n;for(let a of i)n=n<<8n|BigInt(a);n<=o&&y("BAD_ENCODING","blockIndices must be strictly sorted and duplicate-free");let s=0n;for(let a of t)s=s<<8n|BigInt(a);n>=s&&y("BAD_ENCODING","block index must be below length"),o=n}return yt(Fe.CORE_SERVE,[Ur(e.relayPublicKey,32,"relayPublicKey"),Ur(e.corePublicKey,32,"corePublicKey"),st(e.fork,"fork"),t,Ur(e.signedHeadHash,32,"signedHeadHash"),Se(aA,e.blockIndices),Q(e.clientNonce,32,"clientNonce")])}function yt(e,t){let o=fr(e);return(!o||o.purpose!==Ot.REQUEST_COMMITMENT||o.recipeId!==vt.OPERATION_DEFINED_COMMITMENT_PREIMAGE)&&y("BAD_ENCODING","unknown request commitment domain"),ce(X.default.concat([X.default.from(o.exactAsciiBytes,"ascii"),...t]))}function ri(e){return(!e||typeof e!="object")&&y("BAD_ENCODING","allocation commitment input must be an object"),(!Number.isSafeInteger(e.sizeClass)||e.sizeClass<1||e.sizeClass>5)&&y("BAD_ENCODING","sizeClass is outside 1..5"),(!Number.isSafeInteger(e.leaseClass)||e.leaseClass<1||e.leaseClass>4)&&y("BAD_ENCODING","leaseClass is outside 1..4"),X.default.equals(so(e),Q(e.storageSlot,32,"storageSlot"))||y("BAD_ENCODING","storageSlot is not self-certifying"),ce(X.default.concat([X.default.from("hiverelay.blind.allocate.v1","ascii"),Q(e.relayPublicKey,32,"relayPublicKey"),Q(e.storageSlot,32,"storageSlot"),Qr(e.allocationEpoch,"allocationEpoch"),lt(e.sizeClass,"sizeClass"),lt(e.leaseClass,"leaseClass"),Q(e.declaredCellBlobHash,32,"declaredCellBlobHash"),Q(e.createPublicKey,32,"createPublicKey"),Q(e.renewPublicKey,32,"renewPublicKey"),Q(e.dropPublicKey,32,"dropPublicKey")]))}function so(e){return ce(X.default.concat([X.default.from("hiverelay.blind.slot.v1","ascii"),Qr(e.allocationEpoch,"allocationEpoch"),Q(e.createPublicKey,32,"createPublicKey")]))}function oi(e){return yt(Fe.CELL_PUT,[Q(e.allocationCommitment,32,"allocationCommitment"),Q(e.clientNonce,32,"clientNonce")])}function ii(e){e.operation!=="cell-renew"&&e.operation!=="cell-drop"&&y("BAD_ENCODING","cell management operation is invalid"),(!Number.isSafeInteger(e.requestedLeaseClass)||e.requestedLeaseClass<0||e.requestedLeaseClass>4||e.operation==="cell-renew"&&e.requestedLeaseClass===0||e.operation==="cell-drop"&&e.requestedLeaseClass!==0)&&y("BAD_ENCODING","requestedLeaseClass does not match the cell management operation");let t=e.operation==="cell-renew"?Fe.CELL_RENEW:Fe.CELL_DROP;return yt(t,[Q(e.relayPublicKey,32,"relayPublicKey"),Q(e.storageSlot,32,"storageSlot"),st(e.expectedRevision,"expectedRevision"),Qr(e.expectedLeaseEpoch,"expectedLeaseEpoch"),lt(e.requestedLeaseClass,"requestedLeaseClass"),Q(e.clientNonce,32,"clientNonce")])}function gc(e,t){return yt(e,[Q(t.relayPublicKey,32,"relayPublicKey"),Q(t.storageSlot,32,"storageSlot"),Q(t.clientNonce,32,"clientNonce")])}var ni=e=>gc(Fe.CELL_GET,e),_n=e=>gc(Fe.CELL_PROVE,e),cA=ve(_e(32),1,64,"commitment slots");function Nn(e){let t=e&&e.slots;Array.isArray(t)||y("BAD_ENCODING","slots must be an array");let o=new Set;for(let r of t){let i=Q(r,32,"slot"),n=X.default.toString(i,"hex");o.has(n)&&y("BAD_ENCODING","slots contain a duplicate"),o.add(n)}return yt(Fe.CELL_BATCH_GET,[Q(e.relayPublicKey,32,"relayPublicKey"),Q(e.clientNonce,32,"clientNonce"),Se(cA,t)])}function Dn(e){return ce(X.default.concat([X.default.from("hiverelay.blind.inbox-topic.v1","ascii"),Qr(e.allocationEpoch,"allocationEpoch"),Q(e.createPublicKey,32,"createPublicKey")]))}function Bc(e){(!Number.isSafeInteger(e.frameClassBits)||e.frameClassBits===0||(e.frameClassBits&-8)!==0)&&y("BAD_ENCODING","frameClassBits must contain only advertised inbox classes"),(!Number.isSafeInteger(e.appendAuthMode)||e.appendAuthMode<0||e.appendAuthMode>1)&&y("BAD_ENCODING","appendAuthMode is outside 0..1"),(!Number.isSafeInteger(e.retentionClass)||e.retentionClass<1||e.retentionClass>4)&&y("BAD_ENCODING","retentionClass is outside 1..4"),(!Number.isSafeInteger(e.leaseClass)||e.leaseClass<1||e.leaseClass>4)&&y("BAD_ENCODING","leaseClass is outside 1..4"),X.default.equals(Dn(e),Q(e.physicalTopic,32,"physicalTopic"))||y("BAD_ENCODING","physicalTopic is not self-certifying");let t=e.appendPublicKey==null?X.default.alloc(32):Q(e.appendPublicKey,32,"appendPublicKey");return e.appendAuthMode===1!=(e.appendPublicKey!=null)&&y("BAD_ENCODING","appendPublicKey presence does not match appendAuthMode"),ce(X.default.concat([X.default.from("hiverelay.blind.inbox-create.v1","ascii"),Q(e.relayPublicKey,32,"relayPublicKey"),Q(e.physicalTopic,32,"physicalTopic"),Qr(e.allocationEpoch,"allocationEpoch"),lt(e.frameClassBits,"frameClassBits"),lt(e.appendAuthMode,"appendAuthMode"),t,Q(e.createPublicKey,32,"createPublicKey"),Q(e.renewPublicKey,32,"renewPublicKey"),Q(e.closePublicKey,32,"closePublicKey"),lt(e.retentionClass,"retentionClass"),lt(e.leaseClass,"leaseClass")]))}function xc(e){return yt(Fe.INBOX_CREATE,[Q(e.inboxCreateCommitment,32,"inboxCreateCommitment"),Q(e.clientNonce,32,"clientNonce")])}function Rc(e){e.operation!=="inbox-renew"&&e.operation!=="inbox-close"&&y("BAD_ENCODING","inbox management operation is invalid"),(!Number.isSafeInteger(e.requestedLeaseClass)||e.requestedLeaseClass<0||e.requestedLeaseClass>4||e.operation==="inbox-renew"&&e.requestedLeaseClass===0||e.operation==="inbox-close"&&e.requestedLeaseClass!==0)&&y("BAD_ENCODING","requestedLeaseClass does not match the inbox management operation");let t=e.operation==="inbox-renew"?Fe.INBOX_RENEW:Fe.INBOX_CLOSE;return yt(t,[Q(e.relayPublicKey,32,"relayPublicKey"),Q(e.physicalTopic,32,"physicalTopic"),st(e.expectedRevision,"expectedRevision"),Qr(e.expectedLeaseEpoch,"expectedLeaseEpoch"),lt(e.requestedLeaseClass,"requestedLeaseClass"),Q(e.clientNonce,32,"clientNonce")])}function Sc(e){return(!Number.isSafeInteger(e.frameClass)||e.frameClass<1||e.frameClass>3)&&y("BAD_ENCODING","frameClass is outside 1..3"),yt(Fe.INBOX_APPEND,[Q(e.relayPublicKey,32,"relayPublicKey"),Q(e.physicalTopic,32,"physicalTopic"),lt(e.frameClass,"frameClass"),Q(e.frameHash,32,"frameHash"),Q(e.clientNonce,32,"clientNonce")])}function Tc(e){let t=yr(e.cursor,"cursor");return t.byteLength>128&&y("BAD_ENCODING","cursor exceeds 128 bytes"),(!Number.isSafeInteger(e.limit)||e.limit<1||e.limit>64)&&y("BAD_ENCODING","limit is outside 1..64"),yt(Fe.INBOX_READ,[Q(e.relayPublicKey,32,"relayPublicKey"),Q(e.physicalTopic,32,"physicalTopic"),ce(t),Rn(e.limit,"limit"),Q(e.clientNonce,32,"clientNonce")])}function _c(e){return(!Number.isSafeInteger(e.limit)||e.limit<1||e.limit>64)&&y("BAD_ENCODING","limit is outside 1..64"),(!Number.isSafeInteger(e.maxWaitMillis)||e.maxWaitMillis<1||e.maxWaitMillis>3e4)&&y("BAD_ENCODING","maxWaitMillis is outside 1..30000"),yt(Fe.INBOX_WATCH,[Q(e.relayPublicKey,32,"relayPublicKey"),Q(e.physicalTopic,32,"physicalTopic"),st(e.afterRevision,"afterRevision"),Rn(e.limit,"limit"),Rn(e.maxWaitMillis,"maxWaitMillis"),Q(e.clientNonce,32,"clientNonce")])}function Nc(e,t){return Dc(e,t,Ot.RESULT_SIGNATURE,"result")}function si(e,t){return Dc(e,t,Ot.AUXILIARY_SIGNATURE,"auxiliary")}function Dc(e,t,o,r){let i=fr(e);(!i||i.purpose!==o||i.recipeId!==vt.ED25519_DOMAIN_LEN64_PAYLOAD)&&y("BAD_ENCODING",`unknown ${r} signature domain`);let n=yr(t,`unsigned ${r} bytes`);return X.default.concat([X.default.from(i.exactAsciiBytes,"ascii"),st(n.byteLength),n])}var Oc=Z(ae(),1);function ht(e){y("BAD_ENCODING",e)}function On(e){for(let t=0;t<e.byteLength;t++)if(e[t]!==0)return!1;return!0}function Lc(e,t){On(e)&&ht(`${t} must be nonzero`)}function xt(e,t){return typeof e=="number"&&((!Number.isSafeInteger(e)||e<0)&&ht(`${t} must be an unsigned integer`),e=BigInt(e)),(typeof e!="bigint"||e<0n||e>(1n<<64n)-1n)&&ht(`${t} is outside u64`),e}var Ie=_e(32),dA=_e(64),Ln=R([["version",C(h,1,1,"version")],["relayPublicKey",Ie],["storeId",Ie],["externalJournalId",Ie],["durabilityContinuityHash",Ie],["durabilityProfileHash",Ie],["restoreEvidenceHeadSequence",S],["restoreEvidenceHeadHash",Ie],["familyId",C(h,1,5,"familyId")],["operationId",C(h,1,255,"operationId")],["requestCommitment",Ie],["resultCommitment",Ie],["commitWalSequence",S],["commitWalHash",Ie],["coveringFloorRevision",S],["coveringFloorHash",Ie],["coveringFloorWalSequence",S],["coveringFloorWalHash",Ie],["writerEpoch",S],["writerFenceTokenHash",Ie],["externalLeaseRevision",S],["witnessedUnixMillis",S],["witnessPublicKey",Ie],["signature",dA]],{name:"BlindExternalCommitWitnessV1",validate(e){for(let o of["relayPublicKey","storeId","externalJournalId","durabilityContinuityHash","durabilityProfileHash","requestCommitment","resultCommitment","commitWalHash","coveringFloorHash","coveringFloorWalHash","writerFenceTokenHash","witnessPublicKey"])Lc(e[o],o);Ir(e.familyId,e.operationId)||ht("external witness references an unknown operation"),xt(e.coveringFloorWalSequence,"coveringFloorWalSequence")<xt(e.commitWalSequence,"commitWalSequence")&&ht("covering floor WAL sequence is below the committed result"),(xt(e.coveringFloorRevision,"coveringFloorRevision")===0n||xt(e.writerEpoch,"writerEpoch")===0n||xt(e.externalLeaseRevision,"externalLeaseRevision")===0n||xt(e.witnessedUnixMillis,"witnessedUnixMillis")===0n)&&ht("external witness revisions, writer epoch, lease, and time must be nonzero"),xt(e.restoreEvidenceHeadSequence,"restoreEvidenceHeadSequence")===0n!==On(e.restoreEvidenceHeadHash)&&ht("restore evidence head sequence/hash zero state does not match")}}),ft=R([["version",C(h,1,1,"version")],["relayPublicKey",Ie],["storeId",Ie],["descriptorSequence",S],["descriptorHash",Ie],["durabilityProfileId",C(h,1,2,"durabilityProfileId")],["durabilityContinuityHash",Ie],["durabilityProfileHash",Ie],["restoreEvidenceHeadSequence",S],["restoreEvidenceHeadHash",Ie],["externalCommitWitness",z(Ln,"externalCommitWitness")]],{name:"RelayResultBindingV1",validate(e){for(let r of["relayPublicKey","storeId","descriptorHash","durabilityContinuityHash","durabilityProfileHash"])Lc(e[r],r);let t=xt(e.restoreEvidenceHeadSequence,"restoreEvidenceHeadSequence");if(t===0n!==On(e.restoreEvidenceHeadHash)&&ht("restore evidence head sequence/hash zero state does not match"),e.durabilityProfileId===1){(t!==0n||e.externalCommitWitness!=null)&&ht("durability profile 1 forbids restore-head and external-witness state");return}let o=e.externalCommitWitness;if(o!=null){for(let r of["relayPublicKey","storeId","durabilityContinuityHash","durabilityProfileHash","restoreEvidenceHeadHash"])Oc.default.equals(e[r],o[r])||ht(`external witness ${r} does not match relay binding`);xt(e.restoreEvidenceHeadSequence,"restoreEvidenceHeadSequence")!==xt(o.restoreEvidenceHeadSequence,"witness restoreEvidenceHeadSequence")&&ht("external witness restore evidence sequence does not match relay binding")}}}),yy=R([["version",C(h,1,1,"version")],["relayBinding",ft],["requestNonce",Ie],["requestCommitment",Ie],["entriesCommitment",Ie]],{name:"BatchGetSignaturePayloadV1"}),hy=R([["version",C(h,1,1,"version")],["relayBinding",ft],["requestNonce",Ie],["requestCommitment",Ie],["snapshotRevision",S],["entriesCommitment",Ie],["nextCursor",z(ke(0,128,"nextCursor"),"nextCursor")]],{name:"InboxReadSignaturePayloadV1"});var Pc=Object.freeze(Object.fromEntries(Object.entries({1:["e6be8df975178fb7371c5d35b86f5419b127ede9b7975dae593c3b1c6c4ad76e","81d2ff674bf0d3c08ab5d631f454548f339203edae38a95348e8a089aea2961c","f0f89649d8ef417be5cc7b44a3950fef68cc605dfc23bdc8fff9b266ced45be1","6b6e2d9cb960890b97dbc10fce30ce6b0c462dc7cd8a7f1282a15dfef47d2a21","0825170b5213ce37aed2bcf4d7c11288151150d4b6047dc3fed556879aa6cda1","635cc44d0549778ddc14391b2ddb758b64a2c0b1d5e865eb8e72f1843fdea5b8","b33eec9f0f15db391e0b1c3940ba793fa018c51a005ec8ea9b1360b7b29fa236","6ff0cd22571bdf3b9fed2c9affc08bd24166255ee139f4254f4f1610d35ae535","56fc2cd57e00724180b8a3deda0f5d3610a179cad9c359873fd3fc0001e97732","7f2fa51fe068d14adf1bd0144012f05c9123897faa8c0115bdad8c4e0c3f1066","390602d14fd8105b1538a283b2dee3db5f4a43691fed70b0041e0a3c8c8c8ae9","89b404497d63603af8be9fc3b7a374dc1c7e7ce58a7577220842e95e1e7de76d","3b060f9e47a1047a806893cd94285933b143882105e50d83deac701f60beb10f","654a06af400247f78246969ec40a29e3c4c3f53478583d667d651c92d55d5e23","02d799921c66b4a1f3ae4b60de9d3ba0d1885aaf94b9e58690920591c732bb72","99b0ff2e1bd3f58c9def8064c110463f1dc536a760f16b87f65037ea4c3c7e34","fbad17adcbcb22563aaa8819f31ec0853ebf8ce1f712d9ab1e920350a4d9b82f","902436eba0557887bfc0c652fba3bcb24db5a73d4caae1f586de970ecd222872","4523de2fc2f08d935533116972fd9b23ae5451a7971ac35397516bbf1424aaab","c7ffbaebdd9d917bb238c959266951d120544d8db28c758c9535c7f24dbe0572","7f31640f28180175aa2d2a604298226f0837e725af89b678d8962328bfe9b3d3","c48a1e6bd54aacdad5a803dcdaab215a835a335f27493e4b09223cdd54f2fe24","a6d51b1f18c8456ae4175cffe8f4004a9c8c5a64e08bb546e3b5cff0ef1ef3e6","034704d596bbb182ae072167e98f8a49257ab544268d83f4de050a5cff0919be","f9a932c2017cd69387be7f1fdcde8e31a44473ec29762dbd442247267c7fdf45","0ec396609d37e22e91c15d34a89e21cb9f196ec8f4d4a0a211958bfef3d872ee","eda1ae1cf3fd63d80c69649d0c3ad9a022ec366919fee2e163a759ed8169d505","2d1a5ef1d2c764adfa03583027635864a2661a9ab92b86c7d6581040f123e5c2","6dbc1bd2e78a26198524c36ed4e16c197668359ea9882b7c8caf85100ff17f77","a9f5a17efc580e281ca92234f1e6b5713b7daedcb1548bad6d4917e702894731","05eee93faf2b7cb09fff3a4a8297cc333aa56ff53f9392108bdb40eb80329058","50c6bbe834627c1125773a3e9b988d0ece94952c297c98f33b37e00a31be8f68","2aca518d4952fa2306053210d0187171a88675680912beaee11c2b22b8aff6d4","8d3a5f93320236407062fec7f1976c5891d8dbe22b43d560f62fc38ea427b619","6e50fa5dc6f33ad86ced6d36b3fe9f239a7770c2da0f324e6ff72f16190eacd8","83c9224ba53f0cc6bce2af03cd749efde827ef3ee68384c6fc57d2148aff14cc","203ff33bac4c3b494b4452a919921bee00d7dbc7b36ce9e04df641020acfda1a","7111647f042ade5fd938070a83f31b933495e3d14cd0fa069e79d38a9ea84f09","a54594725fbb532cf7d49a75144da47179b9f9a8e49221a19a8ccd551203e114","61806e776baf19ee9fbd05da346c7def94645c6b8d3580fcda44419c2744fe04","9a65f79bfd3f959e9ad658074b4a252e4d795cf5db60b9a64c58dcb0c384948e","184d18b8b831098a24889714295ecfcca94202e0d547b0f34ff92a9732e60da5","40f7e370d90cb385053f48d2b89d57a8f181df5d2f0ba3709e17f817e05a0012","ea03db798b39eb9528fb9b439c3242fca3257f1864906a3f54cd9c456cbcd80d","e6e14d672094188920b32c42dd476e1607517fb2578cbbf025992c549239230a","a888656009db25ed24e4a65ec85697cbcd42b2dab808b17e65f5d2788ef34551","427462bc6fc06308ea53944c1874adc40916f939c303b873d56e41748f0d46ec","7f66d2c520bf1b7230cd2320ae0fb8e00e8ff1c27616720cc1549bc6898d6ea7","5fd74d0aae952cb396a911f0803f8972f8cf6ad786952887e224c9851911b087","75447368cb37ac7678eb9b5ef7b3be37391b5186f842eb2ad792df92af214f31","c269af17a3649c1fe6b2625785004660d83e4d7ab7a3b4f160641cb34f62f9c1","37e735473a073ecba72eed0d6c81b32d2c43ee9a60c7eeda5c500960c6c7e35e","55afcb72393aa11effb5332d437f73c6ca2b7eb3620070272f63fd27c2bbab86","4ceb3275a246c43e8bbecf58484502b3b636e62976fd64bb33dc563d30a65fb5","e15aef460924e1b47c41b2f71b1676dfecea9252e05a4797142a6659d7455f20","29f2df4d4feb367629cd543dc07ec007b5bf41728f4155a94283ac81909a8f06","59559046657b1ba8c31affff9bfd1dbba897746a5bef0d61ad18c5fcb387aaa9","3dd405218b1e1ffcac63a3c69b00f9239eaf0733715c4fd7ac4d16b13007e430","6bad548d978849e94d8f790d512abc3869cfa3afedca501c3c4fbbe952752106","a93e1d13eddccf526291f681d3ff6e28feee0108dd45500455944ad8bd97a67c","97a6de4eee5dfc0402bfc722346858852ef9cd202395dbebc1768bafe882fd02","0d97fc1ce79ed433cf745c285a0b311816d16bc0a17f541209a6042454eea4b9","1a00538a09d7ecdc29a5254f21ace1eb74872528dfaa7699d0f4179212e38ec7","add211de86434db239e869c2df5552356a5010f787b760a1c2e4da35e840d0cf","64c4fedabdb7ac653e3122fe4f5f0bffa01cbc6d25368c77221e5d81955d07b5","d9da185a15564ed6c0b1eca4cadeb1a39d4958fd7a11935b6021d6bb37c920d3","886b4c21061739ae9f95bacf82544b03127db37c757bb1782c77fee944b5ee32","c304489cbd22e4317bbc0d21338be0708081332c2da58353b858be0fdc8c741e","9cb8bdb6c4c46fea1bd73aa74128a2d8b12ffa7cfcff5ca029c02a74494933c6","99fad2405b268bcb1fde0843685717a69fd673212a53facc707b5e0206c0bade","5b46817cbdbd7b8e495f968330ab86ab14110e5b7da95d963b0522e2d11530c3","6f8eb6588419fca32da937ffb6e495a105aa988c0ef352e8bbb387ef4e8f0f5d","28cfdfa3bbc7f0e6dfc2aba3e502697319161665cd5bae3f18b9f51be44b53dc"],2:["9da12bbb637c0e030fec4f83de571ced1e6560d0b5759022cf5a456deb4ddae4","918dd1079c73c390d70d2b34d17f04e8802b7dc0bf1f82eda030e3a4c29cbc88","4a698bd134d9d428c0d4803205736f18cfdb86e2db9e69c0df991471b673c281","233421fc30b5ddc8de556233892364a8be553ca27196947ca6279e2d140582ce","0156e0a27c7e565da2db66f2d884b8f95b25e243375277651f96d434681d4caf","69055c5db70d6bb40cf962b34841a4a7ef4095edd4de5f97496aad6e2dd7fc7b","45f6bdd13522bc1667ad474e1a187a174e9956f18dcca6897c3e846531bbbe69","db6ac2f22375232acc3f2f831fd0438a1c78cd20a4bd750664a38b5d05f4b810","b887d63c6888467b9f6c6e6a7e4efbd33952e7f0fb09a17e0a22c3303f5e066b","fa832bf50a97260322d389c425e516d20e72ce50471bd8b5b380ff9f7e594fdb","824d570b120de9ee27756e31b5d740b5d305b6395ac675f94c5839ad7596c8ca","d06428c810673da5d6ab8706b8ad666759f3b9cf472c4bc3bb0efef0cb536520","672423d4175410c52f3d6df9fa890591da2c7b5497981ea23edbc6b7ddc5c16a","e2fa3fbf61dda4a1ed55914d2750b2f418e8fd49b6100784923d0d00666a0621","afa5ec7a42a9850a34d5f8a0be1483274ee5bc581fefdd7c84e5815de0f86e7d","c9d7348fd3a2d969ba9f0e56e1a33bb8983293a71bd01b48a62f2fd6708602eb","35b78f0da7fced5f818d2620969302c19c9eabcb1193a4071711135bff756e23","b8a6ffed594d4738173f342a6b265b09c94f6aa6025f142418142e49aaed3165","ee6394496f2a0bd5f82e940f8fb4dbb58b7edb79596135a71e1ba2424fded8b0","4cfa26cd59ed1af1b938b426bcd0e08b20cca30157c516572638caa09b30c314","ef49b9903d94aecd3409543a3356cd967607f398b6e45de6eb60d16eafc42bdf","5db20bf78bba0756995be87d4630bda68dea115f4b5eaf402019891949057fa3","eb7df41733428dff2f41f80b5ecbbd39a8485a600599a386457d5766cc13dad0","f84b5f8b70eaa029923b5cb4ef3b1780eafab2f1ca050a741c9e07046776cb27","2e0b1d99a91c2f3bb53acce0d09aeae0ff913cabaf2cac396ab059016d881c0c","401cb0f37dec794d93a7b5981ec99886ecffc30bfd99a130eb1b6d7bf1b6ef1b","357cc40d70ff632a14f134ff1148097aa49f4439f34ec72c499e0d3d0faba1f0","58d9ce5c9960befcfba28c39bdbfa91f855ffe3c2c41d5f3a9da638a777a8bba"],3:["6ebfffe50c4e86b7fd7111dd8b627b7846ae288a3884d074dd17394af163117b","5969aa2feaac7383e9a7bb35060984624690a815a7b8dd97b4fcd026949ee605","c4ccfca4de0939bad215b5148d8addbba5fa0128c292df047710512ffe71d55e","f0b1a8b21efe8b9059d2e850e7d64dd3b2c11e6bf610b81ad210d39bad246a15","c48184e1331c606f839e9f2928fe601ac363cd4a90c4f314267ae512270aa13a","5e874d86c074916d656443f003973d50385a9f6532276b80413c4b56c7e08a6f"],4:["3b72c6f0847c3035794c685d9ff87810e3a54e625690d164ef939c8971b9cb05","e185b4f1672a6519e8512898c2d1ee2a56d114f755a0e139485db5b09c974378","867291450e6b407f31fcd4b4bdcb982f6fd8921fa4444536f5afbaabd1a95d17","47a3e2eb62ca564c57720f719d4549e40d40ef7d0724cec9391bd57c6eb2fba2","1fda3b4580332bd9699f632f8ffe3179127dc9be40846a8b7c4bf7543f07af17","5a906253059aeb97d0df7541a911fcb16f2a522b31848951f4dbca4bce09ffa8","8968b25d1bac295ccbbd42fb5beb6729f268ed5e515f1829178b29b7cfd5b587","438824f529a8cf166ea71fbe82e33ed3c7788074d384d01bb5e636d0eaa1e298","4f85c468148e49c2fd914c970da1e3bc59ca306d6e144ac883aca4574b281cbf","679c5165e95470189ea1310ec538176082c86d6e78a878c5fb1aef1d0bfbf08e","c23bcff65f4116492215be87e5e0d59793bfd42dc191fd9fbfd542747c07239d","ba90d48c9325b0453ab2a9a71955c5b9b3d42f8f2df083eb14f119dc6941a4ea","44cf9c9c2f35234efb655e78cf6eba49e5d3b367098b1fae3c9a2259d520e0c4","1ce8315654c5c6b50c91c38b7995cd29b4d4d788ced25290d9479d5eca8fe152","2118a3b324d21eb14d6aa8f7e4970406cf56309367fabb761403f0c656162a6b","4d1ab1c6a98515945e5ccf9db21fde850c15d0f9fe1b8036d51478d36f58e692","5ec93277c174083dd25cc73e11cd4ffee15152a1bfda601d76f512980426b6a8","238ec0bb34d9b2f9d759eecf84a5562f921a2ef13c549de9e88f3455a2eaf705","b9455727477e7dc7cf0a96435c398fcbe7d08547f36abd2c5688c650c290a141","49ed02a1e69c488cad47c08d8a2405e6202409272cf3d2d7200082b60ed6ed7d","4b38d632b2fa532a2d25ffe5b9793b503aecf4ea8a89e760d8ddf57e0c498b66","17ccdf6a718b65dba39b13f80e9d27aecca9540757f100ba18fec47288e6088e","ea4169fe9fd93be72c69fbd443f94295fb18c3574115589ee82a8cd95be090a6","bfa15a1fe55427297fc217727fd0c92653e8ef0dd334c5b48868bbf8c6e45e61","30f006e67ffe1d30e926cca3250fd30f5a6b38fe90dbea92721db3bafc1abf18","051260e8fa2ad526d490b7a724e629add413fd6f542524b7f2e8369ce22d1f92","2590254cfc5459f9891f9d559093fc1fbbf5273a2c7af38f0cb53052a7cae285","e49837b647acacbd509554f8885f3b1ebe63daf1dc65424cce68c67299e849d0","0dd5ec87d00fe29d16fb36376855661eea8b6c9d22ca909efb1c8bca9ad0be20","119992d8a241968fd88851019230ed8ed9801c31c9834c8aaa02a7a689fca618","50bf7ee8510abba6e3519daf1f359e12c1b1c3de894bd7c0b1ac3cee804176a6","d0f85927b82c28c8a598f97a446a1c7a4e2250faff113d80d3c82058be4fa502","cf3e9db3739533accd90bc5c3149134c411f74975ffab7174b2707e31cf1bde9","76f742eea8e81578909f34f746cce19520a3a0a369464728bd87dabb85cc7c05","ffba11c56058daf2d46f9c91bcfeda991ce24639d753896c01a71463fd7ef926","4a18579de10d1cc5a4e21c291bc0777df73363de8164a28d76728bd9317d4c42","818e8f417f06559d6dfe1276c162ca4127f14eef5e80fc6bc4f141f230bb91a2","925ca5db403415f83e7df518a6cea09ee03ba4c7fe7e7d5cea5efafe32378559"],5:["97cceb00a35a91c091061cc00355be81aa7751e483a41ba31fc30e9b3ae68a37","14395517ef9f294c2c8cae3c75de191372c83dcdd61f03beb28641b1efcf4e72","82d36379e7d8df30b2934aba38989cdb377eae1ca75af3d5e5b24d41e47466d9","719c8c141831525893f054575f59a6ea0acffac376c61d4dc7bb38af8b14dcd3","27ed78552ba4d82cc9eaa2edc44a8d516d97a848e492c886a1f76fba6bd3038f","a8578e15e7a9478dd3e102983db66e86e9266259019d3ddbb1b53c65386cd205","4d502ad1a3f8b8ec2e10d105cea572b73007124a455d3ffd9613311e37aa4e48"]}).map(([e,t])=>[e,Object.freeze(t)])));var Un=1024,qr=1024*Un,Mc=(1n<<64n)-1n;function A(e){y("BAD_ENCODING",e)}function Y(e,t){return typeof e=="number"&&((!Number.isSafeInteger(e)||e<0)&&A(`${t} must be an unsigned safe integer or bigint`),e=BigInt(e)),(typeof e!="bigint"||e<0n||e>Mc)&&A(`${t} is outside u64`),e}function Qt(e){for(let t=0;t<e.byteLength;t++)if(e[t]!==0)return!1;return!0}function ai(e){(e.issuedEpoch>=e.expiresEpoch||e.expiresEpoch-e.issuedEpoch>4)&&A("route epoch window must satisfy issuedEpoch < expiresEpoch <= issuedEpoch + 4")}function Qn(e){let t=Ws[e.circuitClass];t||A("circuitClass is outside 1..3"),(e.grantedInitialWindow!==t.grantedInitialWindow||Y(e.maxCircuitBytes,"maxCircuitBytes")!==BigInt(t.maxCircuitBytes)||e.idleMillis!==t.idleMillis||e.lifetimeMillis!==t.lifetimeMillis)&&A("forward circuit limits do not match the frozen class tuple"),e.maxDataBytes!==vi[e.grantedWireClass==null?e.requestedWireClass:e.grantedWireClass]&&A("maxDataBytes does not match the selected wire class")}function lA(e){let t=js[e.sessionClass];t||A("sessionClass is outside 1..3"),(Y(e.maxSessionBytes,"maxSessionBytes")!==BigInt(t.maxSessionBytes)||e.idleMillis!==t.idleMillis||e.lifetimeMillis!==t.lifetimeMillis)&&A("core session limits do not match the frozen class tuple")}var fo=_e(16),l=_e(32),fe=_e(64),fA=_e(96),w=pt(h,1,"version"),Io=C(q,1,65535,"profileId"),ci=C(q,1,65535,"schemeId"),co=C(h,1,255,"endpointId"),qc=C(q,1,63,"transportSupportBit"),hr=C(h,1,3,"wireClass"),di=C(h,1,3,"circuitClass"),Hc=C(h,1,3,"sessionClass"),Vc=C(q,1,5,"protocolId"),Fc=C(h,1,9,"transportId"),Ao=C(h,1,5,"sizeClass"),Yc=C(h,1,3,"frameClass"),lo=C(h,1,4,"leaseClass"),li=C(h,0,4,"leaseClass"),fi=Ji("sizeClass",Et,"cellBlob"),Gc=Ji("frameClass",vs,"inbox frame"),IA=Po(1,64,"profileName"),wc=Zi(1,512,"endpoint URL"),AA=bt("buildManifestUrl"),uA=bt("buildArtifactUrl"),pA=bt("releaseEvidenceBundleUrl"),yA=bt("runtimeBoundaryEvidenceUrl"),hA=bt("externalJournalTopologyUrl"),mA=bt("restoreEvidenceFeedUrl"),CA=ta(te.default.from("hiverelay-blind-cell-v1","ascii"),"cell receipt protocol");function EA(e){return te.default.toString(e,"hex")}function Kn(e,t){let o=new Set;for(let r of e){let i=EA(r);o.has(i)&&A(`${t} contains a duplicate`),o.add(i)}}function ao(e,t){let o=Math.min(e.byteLength,t.byteLength);for(let r=0;r<o;r++)if(e[r]!==t[r])return e[r]<t[r]?-1:1;return e.byteLength===t.byteLength?0:e.byteLength<t.byteLength?-1:1}function Mr(e,t){return e===t?0:e<t?-1:1}function mr(e,t,o){for(let r=1;r<e.length;r++)t(e[r-1],e[r])>=0&&A(`${o} must be strictly sorted and duplicate-free`)}function k(e,t){Qt(e)&&A(`${t} must be nonzero`)}function Ii(e,t,o){let r={preencode(i,n){let s=i.end;e.preencode(i,n),i.end-s>t&&A(`${o} exceeds ${t} bytes`)},encode(i,n){e.encode(i,n)},decode(i){let n=i.start,s=e.decode(i);return i.start-n>t&&A(`${o} exceeds ${t} bytes`),s}};return Array.isArray(e.schemaFields)&&Object.defineProperties(r,{schemaName:{value:e.schemaName||o},schemaFields:{value:e.schemaFields}}),r}var Sy=R([["costClassRuleId",C(q,1,11,"costClassRuleId")],["ruleKind",C(h,1,11,"ruleKind")]],{name:"AdmissionCostRuleV1",validate(e){let t=ji(e.costClassRuleId);(!t||t.ruleKind!==e.ruleKind)&&A("admission cost rule is not in the frozen registry")}}),Ty=R([["domainId",C(q,1,65535,"domainId")],["purpose",C(h,Ot.REQUEST_COMMITMENT,Ot.AUXILIARY_SIGNATURE,"domain purpose")],["recipeId",C(h,vt.OPERATION_DEFINED_COMMITMENT_PREIMAGE,vt.ED25519_DOMAIN_LEN64_PAYLOAD,"domain recipe")],["exactAsciiBytes",Po(1,96,"exactAsciiBytes")]],{name:"DomainRegistryEntryV1",validate(e){let t=fr(e.domainId);(!t||t.purpose!==e.purpose||t.recipeId!==e.recipeId||!te.default.equals(te.default.from(t.exactAsciiBytes,"ascii"),e.exactAsciiBytes))&&A("domain entry is not in the frozen registry")}}),_y=R([["errorProfileId",pt(h,ki.CANONICAL_V1,"errorProfileId")],["code",C(h,1,20,"error code")],["directCorrelatedStatus",pt(q,200,"directCorrelatedStatus")],["protectedInnerStatus",pt(q,200,"protectedInnerStatus")],["retryable",C(h,0,1,"retryable")],["retryAfterMode",C(h,_o.MUST_BE_ABSENT,_o.MUST_BE_PRESENT,"retryAfterMode")]],{name:"ErrorProfileEntryV1",validate(e){let t=zi(e.errorProfileId,e.code);(!t||t.directCorrelatedStatus!==e.directCorrelatedStatus||t.protectedInnerStatus!==e.protectedInnerStatus||t.retryable!==e.retryable||t.retryAfterMode!==e.retryAfterMode)&&A("error profile entry is not in the frozen registry")}}),Ze=R([["profileId",Io],["schemeId",ci],["parameterHash",l],["token",ke(1,4096,"admission token")]],{name:"AdmissionV1"}),mt=R([["version",w],["protocol",CA],["relayBinding",ft],["slotCommitment",l],["cellBlobHash",l],["allocationCommitment",l],["requestCommitment",l],["sizeClass",Ao],["allocationEpoch",D],["leaseClass",li],["leaseEpoch",D],["stateRevision",S],["receiptEpoch",D],["requestNonce",l],["result",C(h,Dt.STORED,Dt.DROPPED,"cell receipt result")],["signature",fe]],{name:"BlindReceiptV1",validate(e){e.result===Dt.DROPPED?e.leaseClass!==0&&A("dropped cell receipt must use lease NONE"):e.leaseClass===0&&A("stored, served, or renewed cell receipt requires a lease")}}),Ai=R([["version",w],["storageSlot",l],["allocationEpoch",D],["sizeClass",Ao],["leaseClass",lo],["clientNonce",l],["createPublicKey",l],["renewPublicKey",l],["dropPublicKey",l],["declaredBlobHash",l],["createSignature",fe],["admission",Ze],["cellBlob",fi]],{name:"PutCellV1",validate(e){te.default.equals(so(e),e.storageSlot)||A("storageSlot is not self-certifying"),te.default.equals(ce(e.cellBlob),e.declaredBlobHash)||A("declaredBlobHash does not match cellBlob")}}),Mn=R([["version",w],["storageSlot",l],["expectedRevision",S],["expectedLeaseEpoch",D],["leaseClass",lo],["clientNonce",l],["admission",Ze],["signature",fe]],{name:"RenewCellV1"}),qn=R([["version",w],["storageSlot",l],["expectedRevision",S],["expectedLeaseEpoch",D],["clientNonce",l],["signature",fe]],{name:"DropCellV1"}),Hn=R([["version",w],["storageSlot",l],["clientNonce",l],["admission",z(Ze,"admission")]],{name:"ProveCellV1"}),ui=R([["version",w],["storageSlot",l],["clientNonce",l],["admission",z(Ze,"admission")]],{name:"GetCellV1"}),kc=R([["version",w],["sizeClass",Ao],["cellBlob",fi]],{name:"GetCellResultV1"}),vc=R([["version",w],["receipt",mt],["sizeClass",Ao],["cellBlob",fi]],{name:"ProveCellResultV1",validate(e){e.receipt.result!==Dt.SERVED&&A("proof receipt result must be SERVED"),e.receipt.sizeClass!==e.sizeClass&&A("proof sizeClass does not match receipt"),te.default.equals(ce(e.cellBlob),e.receipt.cellBlobHash)||A("proof cellBlob does not match receipt hash")}}),Pn=R([["sizeClass",Ao],["cellBlob",fi]],{name:"BatchGetEntryV1.found"}),bA={preencode(e,t){(!t||typeof t!="object")&&A("BatchGetEntryV1 must be an object"),h.preencode(e,t.status),t.status!==0&&(t.status!==1&&A("BatchGetEntryV1 status must be 0 or 1"),Pn.preencode(e,t))},encode(e,t){(!t||typeof t!="object")&&A("BatchGetEntryV1 must be an object"),h.encode(e,t.status),t.status!==0&&(t.status!==1&&A("BatchGetEntryV1 status must be 0 or 1"),Pn.encode(e,t))},decode(e){let t=h.decode(e);return t===0?{status:t}:(t!==1&&A("BatchGetEntryV1 status must be 0 or 1"),{status:t,...Pn.decode(e)})}},gA=ve(l,1,64,"batch slots"),Kc=ve(bA,1,64,"batch entries");var Vn=R([["version",w],["clientNonce",l],["slots",gA],["admission",z(Ze,"admission")]],{name:"BatchGetV1",validate(e){Kn(e.slots,"batch slots")}}),Fn=R([["version",w],["relayBinding",ft],["requestNonce",l],["requestCommitment",l],["entries",Kc],["entriesCommitment",l],["signature",fe]],{name:"BatchGetResultV1",validate(e){let t=Se(Kc,e.entries),o=ce(t);te.default.equals(o,e.entriesCommitment)||A("batch entriesCommitment does not match entries"),193+t.byteLength>4*qr&&A("batch result exceeds its operation cap")}}),Wc=R([["version",w],["allocationEpoch",D],["physicalTopic",l],["frameClassBits",h],["appendAuthMode",C(h,0,1,"appendAuthMode")],["createPublicKey",l],["appendPublicKey",z(l,"appendPublicKey")],["renewPublicKey",l],["closePublicKey",l],["retentionClass",lo],["leaseClass",lo],["clientNonce",l],["createSignature",fe],["admission",Ze]],{name:"InboxCreateV1",validate(e){te.default.equals(Dn(e),e.physicalTopic)||A("physicalTopic is not self-certifying"),(e.frameClassBits===0||(e.frameClassBits&-8)!==0)&&A("frameClassBits must contain only advertised inbox classes"),e.appendAuthMode===ks.SIGNATURE_REQUIRED!==(e.appendPublicKey!=null)&&A("appendPublicKey presence does not match appendAuthMode")}}),Yn=R([["version",w],["operation",C(h,1,2,"inbox management operation")],["physicalTopic",l],["expectedRevision",S],["expectedLeaseEpoch",D],["leaseClass",li],["clientNonce",l],["signature",fe],["admission",z(Ze,"admission")]],{name:"InboxManageV1",validate(e){e.operation===Gs.RENEW?(e.leaseClass===0||e.admission==null)&&A("inbox renew requires lease and admission"):(e.leaseClass!==0||e.admission!=null)&&A("inbox close requires lease NONE and no admission")}}),jc=R([["version",w],["physicalTopic",l],["frameClass",Yc],["frameHash",l],["clientNonce",l],["appendSignature",z(fe,"appendSignature")],["admission",Ze],["frame",Gc]],{name:"InboxAppendV1",validate(e){te.default.equals(ce(e.frame),e.frameHash)||A("frameHash does not match frame")}}),zc=R([["version",w],["physicalTopic",l],["cursor",ke(0,128,"inbox cursor")],["limit",C(q,1,64,"inbox read limit")],["clientNonce",l],["admission",z(Ze,"admission")]],{name:"InboxReadV1"}),Xc=R([["version",w],["physicalTopic",l],["afterRevision",S],["limit",C(q,1,64,"inbox watch limit")],["maxWaitMillis",C(q,1,3e4,"maxWaitMillis")],["clientNonce",l],["admission",Ze]],{name:"InboxWatchV1"}),uo=R([["version",w],["relayBinding",ft],["topicCommitment",l],["stateRevision",S],["leaseClass",li],["leaseEpoch",D],["requestNonce",l],["requestCommitment",l],["result",C(h,1,3,"inbox receipt result")],["signature",fe]],{name:"InboxReceiptV1",validate(e){e.result===dr.CLOSED?e.leaseClass!==0&&A("closed inbox receipt must use lease NONE"):e.leaseClass===0&&A("created or renewed inbox receipt requires a lease")}}),po=R([["version",w],["relayBinding",ft],["topicCommitment",l],["frameHash",l],["appendRevision",S],["storedAtEpoch",D],["expiresAtEpoch",D],["requestNonce",l],["requestCommitment",l],["result",pt(h,So.STORED,"result")],["signature",fe]],{name:"InboxAppendAckV1",validate(e){e.expiresAtEpoch<=e.storedAtEpoch&&A("expiresAtEpoch must be after storedAtEpoch")}}),BA=R([["appendRevision",S],["frameHash",l],["frameClass",Yc],["frame",Gc]],{name:"InboxReadResultV1.entry",validate(e){te.default.equals(ce(e.frame),e.frameHash)||A("entry frameHash does not match frame")}}),Uc=ve(BA,0,64,"inbox read entries"),Qc=z(ke(0,128,"nextCursor"),"nextCursor");var Gn=R([["version",w],["relayBinding",ft],["requestNonce",l],["requestCommitment",l],["snapshotRevision",S],["entries",Uc],["entriesCommitment",l],["nextCursor",Qc],["signature",fe]],{name:"InboxReadResultV1",validate(e){let t=-1n;for(let n of e.entries){let s=Y(n.appendRevision,"appendRevision");s<=t&&A("inbox entries must have strictly increasing appendRevision"),s>Y(e.snapshotRevision,"snapshotRevision")&&A("inbox entry revision exceeds snapshotRevision"),t=s}let o=Se(Uc,e.entries),r=ce(o);te.default.equals(r,e.entriesCommitment)||A("inbox entriesCommitment does not match entries"),105+o.byteLength+32+Se(Qc,e.nextCursor).byteLength+64>4*qr&&A("inbox read result exceeds its operation cap")}}),$c=R([["version",w],["code",C(h,1,20,"error code")],["retryable",C(h,0,1,"retryable")],["retryAfterEpoch",z(D,"retryAfterEpoch")]],{name:"BlindErrorV1",validate(e){let t=zi(ki.CANONICAL_V1,e.code),o=e.retryAfterEpoch!=null;(!t||t.retryable!==e.retryable||o!==(t.retryAfterMode===_o.MUST_BE_PRESENT))&&A("blind error body does not match error profile 1")}}),Ny=R([["version",w],["code",C(h,1,3,"OHTTP transport error code")]],{name:"BlindOhttpTransportErrorV1"}),pi=R([["version",w],["descriptorHash",z(l,"descriptorHash")],["clientNonce",l]],{name:"BlindDescribeGetV1"}),yi=R([["version",w],["profileId",Io],["schemeId",ci],["clientNonce",l]],{name:"BlindAdmissionParametersRequestV1"}),Dy=R([["familyId",C(h,1,5,"familyId")],["operationId",C(h,1,255,"operationId")],["requestSchemaId",C(q,1,65535,"requestSchemaId")],["resultSchemaId",q],["allowedRequestKindBits",C(h,1,15,"allowedRequestKindBits")],["allowedResultKindBits",C(h,0,15,"allowedResultKindBits")],["streamTransition",C(h,0,3,"streamTransition")],["maxRequestBodyBytes",C(D,1,4*qr,"maxRequestBodyBytes")],["maxResultBodyBytes",C(D,1,4*qr,"maxResultBodyBytes")],["admissionMode",C(h,0,2,"admissionMode")],["costClassRuleId",q],["requestCommitmentDomainId",q],["resultSignatureDomainId",q],["errorProfileId",pt(h,1,"errorProfileId")],["transportSupportBits",C(q,1,63,"transportSupportBits")]],{name:"OperationProfileV1",validate(e){let t=e.requestCommitmentDomainId===0?null:fr(e.requestCommitmentDomainId),o=e.resultSignatureDomainId===0?null:fr(e.resultSignatureDomainId);e.requestCommitmentDomainId!==0&&(!t||t.purpose!==Ot.REQUEST_COMMITMENT||t.recipeId!==vt.OPERATION_DEFINED_COMMITMENT_PREIMAGE)&&A("requestCommitmentDomainId is not a registered request domain"),e.resultSignatureDomainId!==0&&(!o||o.purpose!==Ot.RESULT_SIGNATURE||o.recipeId!==vt.ED25519_DOMAIN_LEN64_PAYLOAD)&&A("resultSignatureDomainId is not a registered result-signature domain"),e.admissionMode===0!=(e.costClassRuleId===0)&&A("costClassRuleId zero state does not match admissionMode"),e.costClassRuleId!==0&&!ji(e.costClassRuleId)&&A("costClassRuleId is not in the frozen registry"),e.admissionMode===2&&e.requestCommitmentDomainId===0&&A("required admission needs a request commitment domain"),e.resultSchemaId===0&&e.streamTransition!==3&&A("only forward-active operations may omit resultSchemaId");let r=1<<Oe.REQUEST-1,i=1<<Oe.RESPONSE-1|1<<Oe.ERROR-1,n=1<<Oe.STREAM-1,s=1<<Oe.ERROR-1;e.streamTransition===Jr.FORWARD_ACTIVE?(e.familyId!==b.FORWARD||e.resultSchemaId!==0||e.allowedRequestKindBits!==n||e.allowedResultKindBits!==n&&e.allowedResultKindBits!==(n|s)||e.admissionMode!==0||e.costClassRuleId!==0||e.requestCommitmentDomainId!==0||e.resultSignatureDomainId!==0)&&A("forward-active operation metadata is inconsistent"):(e.allowedRequestKindBits!==r||e.allowedResultKindBits!==i||e.resultSchemaId===0)&&A("unary/open operation metadata kind bits are inconsistent");let a=rt.DIRECT_NATIVE|rt.TOR_NATIVE,d=a|rt.MASQUE_NATIVE;(e.streamTransition===Jr.CORE_CHILD&&(e.familyId!==b.CORE||e.transportSupportBits!==a)||(e.streamTransition===Jr.FORWARD_OPEN||e.streamTransition===Jr.FORWARD_ACTIVE)&&(e.familyId!==b.FORWARD||e.transportSupportBits!==d))&&A("stream transition transport support is inconsistent");let f=Lt(e.familyId,e.operationId);(!f||Object.keys(f).some(I=>e[I]!==f[I]))&&A("operation profile is not in the frozen registry")}}),Oy=R([["version",w],["protocolId",Vc],["major",q],["minor",q],["featureBits",S],["wireSchemaSetHash",l],["dependencyManifestHash",l],["interoperabilityVectorSetHash",l]],{name:"ProtocolProfileArtifactV1"}),Ly=R([["version",w],["transportId",Fc],["profileName",IA],["major",q],["minor",q],["exporterId",C(h,0,1,"exporterId")],["controlChannelIdType",C(h,0,1,"controlChannelIdType")],["handshakeProfileHash",l],["dependencyManifestHash",l],["interoperabilityVectorSetHash",l]],{name:"TransportProfileArtifactV1"}),xA=R([["protocolId",Vc],["major",q],["minor",q],["featureBits",S],["profileHash",l]],{name:"ProtocolProfileV1"}),RA=R([["endpointId",co],["transportId",Fc],["transportProfileHash",l],["roleBits",q],["privacyProfileBits",q],["canonicalUrl",wc],["endpointKey",z(l,"endpointKey")],["envelopeClassBits",q],["wireClassBits",h],["maxStreams",q],["auxiliaryUrl",z(wc,"auxiliaryUrl")],["auxiliaryHash",z(l,"auxiliaryHash")]],{name:"TransportEndpointV1",validate(e){(e.roleBits&~Nt.ROLE_BITS_MASK)!==0&&A("roleBits contains a reserved bit"),(e.privacyProfileBits&~Nt.PRIVACY_PROFILE_BITS_MASK)!==0&&A("privacyProfileBits contains a reserved bit"),(e.envelopeClassBits&~Nt.ENVELOPE_CLASS_BITS_MASK)!==0&&A("envelopeClassBits contains a reserved bit"),(e.wireClassBits&~Nt.WIRE_CLASS_BITS_MASK)!==0&&A("wireClassBits contains a reserved bit"),e.wireClassBits===0!=(e.maxStreams===0)&&A("wireClassBits and maxStreams must both describe unary or streaming transport");let t=e.transportId===Tr.TOR_V3_ONION;Nr(e.canonicalUrl,{name:"canonicalUrl",requireOnion:t}),new URL(te.default.toString(e.canonicalUrl,"utf8")).pathname!==cr[b.DESCRIBE]&&A("canonicalUrl must use the generic listener authority anchor /api/blind/v1/describe"),e.auxiliaryUrl==null!=(e.auxiliaryHash==null)&&A("auxiliaryUrl and auxiliaryHash must be present together"),t&&e.auxiliaryUrl!=null&&A("Tor onion endpoints must not advertise an auxiliary URL"),e.auxiliaryUrl!=null&&Nr(e.auxiliaryUrl,{name:"auxiliaryUrl"})}}),kn=R([["profileId",C(h,1,2,"profileId")],["storeFormatMajor",q],["storeFormatMinor",q],["storeFormatHash",l],["externalJournalId",l],["externalWitnessPublicKey",l],["externalJournalReplicationClass",C(h,0,1,"externalJournalReplicationClass")],["externalJournalFailureGroupId",l],["externalCheckpointAgeBand",C(h,0,7,"externalCheckpointAgeBand")],["externalJournalTopologyUrl",z(hA,"externalJournalTopologyUrl")],["externalJournalTopologyHash",l],["restoreEvidenceFeedUrl",z(mA,"restoreEvidenceFeedUrl")],["restoreEvidenceFeedId",l],["restoreEvidenceCheckpointSequence",S],["restoreEvidenceCheckpointHash",l],["acknowledgedRpoBand",C(h,0,3,"acknowledgedRpoBand")],["targetRtoBand",C(h,0,3,"targetRtoBand")],["redundancyClass",C(h,0,2,"redundancyClass")],["restoreDrillAgeBand",C(h,0,7,"restoreDrillAgeBand")]],{name:"DurabilityProfileV1",validate(e){let t=[e.externalJournalId,e.externalWitnessPublicKey,e.externalJournalFailureGroupId,e.externalJournalTopologyHash],o=Y(e.restoreEvidenceCheckpointSequence,"restoreEvidenceCheckpointSequence"),r=Qt(e.restoreEvidenceFeedId),i=Qt(e.restoreEvidenceCheckpointHash);if(e.profileId===1){(t.some(s=>!Qt(s))||e.externalJournalReplicationClass!==0||e.externalCheckpointAgeBand!==0||e.externalJournalTopologyUrl!=null||e.restoreEvidenceFeedUrl!=null||!r||o!==0n||!i||e.acknowledgedRpoBand!==0||e.targetRtoBand!==0||e.redundancyClass!==0||e.restoreDrillAgeBand!==0)&&A("durability profile 1 requires the exact zero/absent external tuple");return}(t.some(Qt)||e.externalJournalReplicationClass!==1||e.externalJournalTopologyUrl==null)&&A("durability profile 2 requires its nonzero external journal topology tuple"),(e.restoreEvidenceFeedUrl==null!==r||o===0n!==i||r&&(o!==0n||!i))&&A("restore evidence feed URL, ID, sequence, and hash zero state is inconsistent"),(e.acknowledgedRpoBand!==0||e.targetRtoBand!==0||e.redundancyClass!==0||e.restoreDrillAgeBand!==0)&&r&&A("body recovery claims require a restore evidence feed")}}),SA=R([["specHash",l],["abiHash",l],["vectorSetHash",l],["evidenceFormatHash",l],["evidenceVectorSetHash",l],["storeFormatHash",l],["storeVectorSetHash",l],["privateIpcFormatHash",l],["privateIpcVectorSetHash",l],["buildArtifactHash",l],["buildArtifactUrl",uA],["buildManifestUrl",AA],["buildManifestHash",l],["releaseEvidenceBundleUrl",pA],["releaseEvidenceBundleHash",l],["releaseSupportHorizonHash",l],["runtimeBoundaryEvidenceUrl",yA],["runtimeBoundaryEvidenceHash",l]],{name:"BuildProfileV1"}),TA=R([["version",w],["routeKind",C(h,1,6,"routeKind")],["routeId",fo],["previousRelayKey",l],["previousEndpointId",co],["nextRelayKey",l],["nextDescriptorSequence",S],["nextDescriptorHash",l],["nextEndpointId",co],["envelopeClassBits",q],["wireClassBits",h],["maxCanonicalDispatchBytes",D],["maxEncapsulatedRequestBytes",D],["maxOpenBytes",D],["maxCircuitBytes",S],["maxConcurrentStreams",q],["maxRelayCount",C(h,2,4,"maxRelayCount")],["hopAdmissionProfileId",Io],["issuedEpoch",D],["expiresEpoch",D],["routeNonce",l],["previousSignature",fe]],{name:"BlindTransportRouteV1",validate(e){ai(e),(e.envelopeClassBits&-127)!==0&&A("envelopeClassBits contains a reserved bit"),(e.wireClassBits&-15)!==0&&A("wireClassBits contains a reserved bit"),e.maxCanonicalDispatchBytes>ee.MAX_WIRE_BYTES&&A("maxCanonicalDispatchBytes exceeds the absolute dispatch cap"),e.maxOpenBytes>128*Un&&A("maxOpenBytes exceeds 128 KiB"),e.maxConcurrentStreams>1024&&A("maxConcurrentStreams exceeds 1024"),e.routeKind===1?((e.envelopeClassBits===0||e.maxEncapsulatedRequestBytes===0)&&A("OHTTP routes require envelope classes and an encapsulated request cap"),(e.wireClassBits!==0||e.maxOpenBytes!==0||Y(e.maxCircuitBytes,"maxCircuitBytes")!==0n||e.maxConcurrentStreams!==0)&&A("OHTTP routes must zero streaming-only fields")):(e.maxEncapsulatedRequestBytes!==0&&A("non-OHTTP routes must zero maxEncapsulatedRequestBytes"),e.routeKind>=2&&e.routeKind<=5&&(e.wireClassBits===0||e.maxOpenBytes===0||Y(e.maxCircuitBytes,"maxCircuitBytes")===0n||e.maxConcurrentStreams===0)&&A("streaming routes require nonzero wire/open/circuit/stream caps"))}}),_A=R([["hopIndex",C(h,0,3,"hopIndex")],["relayPublicKey",l],["descriptorSequence",S],["descriptorHash",l],["previousScopeHash",l],["scopeHash",l],["relaySignature",fe]],{name:"BlindForwardRouteHopV1",validate(e){k(e.relayPublicKey,"relayPublicKey"),k(e.descriptorHash,"descriptorHash"),k(e.scopeHash,"scopeHash"),e.hopIndex===0&&!Qt(e.previousScopeHash)&&A("route-scope hop zero requires an all-zero previousScopeHash"),e.hopIndex!==0&&Qt(e.previousScopeHash)&&A("route-scope continuation requires a nonzero previousScopeHash")}}),NA=ve(_A,1,4,"forward route-scope hops"),DA=R([["version",w],["rootRouteId",fo],["rootCircuitNonce",l],["rootRequestCommitment",l],["maxRelayCount",C(h,2,4,"maxRelayCount")],["expiresEpoch",D],["hops",NA]],{name:"BlindForwardRouteScopeV1",validate(e){k(e.rootRouteId,"rootRouteId"),k(e.rootCircuitNonce,"rootCircuitNonce"),k(e.rootRequestCommitment,"rootRequestCommitment"),e.expiresEpoch===0&&A("route-scope expiresEpoch must be nonzero"),e.hops.length>e.maxRelayCount&&A("route-scope relay count exceeds maxRelayCount");let t=new Set;for(let o=0;o<e.hops.length;o++){let r=e.hops[o];r.hopIndex!==o&&A("route-scope hop indexes must be contiguous from zero"),o>0&&!te.default.equals(r.previousScopeHash,e.hops[o-1].scopeHash)&&A("route-scope previousScopeHash does not bind the complete prefix");let i=te.default.toString(r.relayPublicKey,"hex");t.has(i)&&A("route-scope repeats a relay public key"),t.add(i)}}}),Py=R([["version",w],["route",TA],["routeScope",DA],["previousDescriptorSequence",S],["previousDescriptorHash",l],["circuitNonce",l],["requestedWireClass",hr],["circuitClass",di],["grantedInitialWindow",D],["maxDataBytes",D],["maxCircuitBytes",S],["idleMillis",D],["lifetimeMillis",D],["clientRequestCommitment",l],["handshakeFlight1",l],["forwarderSignature",fe]],{name:"BlindForwardHopOpenV1",validate(e){Qn(e),(e.route.routeKind<2||e.route.routeKind>5)&&A("BlindForwardHopOpenV1 requires a streaming route"),(e.route.wireClassBits&1<<e.requestedWireClass)===0&&A("requestedWireClass is not admitted by the route"),Y(e.maxCircuitBytes,"maxCircuitBytes")>Y(e.route.maxCircuitBytes,"route.maxCircuitBytes")&&A("forward circuit exceeds the route byte cap");let t=e.routeScope.hops[e.routeScope.hops.length-1];(!te.default.equals(t.relayPublicKey,e.route.previousRelayKey)||Y(t.descriptorSequence,"routeScope descriptorSequence")!==Y(e.previousDescriptorSequence,"previousDescriptorSequence")||!te.default.equals(t.descriptorHash,e.previousDescriptorHash))&&A("BlindForwardHopOpenV1 route scope does not end at the forwarding relay descriptor"),e.routeScope.hops.length>e.route.maxRelayCount&&A("BlindForwardHopOpenV1 route scope exceeds the signed route relay bound")}}),OA=R([["version",w],["previousRelayKey",l],["previousDescriptorSequence",S],["previousDescriptorHash",l],["nextRelayKey",l],["nextDescriptorSequence",S],["nextDescriptorHash",l],["nextRelayBinding",ft],["routeId",fo],["circuitNonce",l],["nextStreamId",S],["grantedWireClass",hr],["circuitClass",di],["grantedInitialWindow",D],["maxDataBytes",D],["maxCircuitBytes",S],["idleMillis",D],["lifetimeMillis",D],["openedAtEpoch",D],["hopOpenCommitment",l],["acceptedRouteScopeHash",l],["acceptedRelayCount",C(h,1,4,"acceptedRelayCount")],["handshakeFlight2",fA],["nextSignature",fe]],{name:"BlindForwardHopAcceptV1",validate(e){Qn(e),Y(e.nextStreamId,"nextStreamId")===0n&&A("nextStreamId must be nonzero"),(!te.default.equals(e.nextRelayKey,e.nextRelayBinding.relayPublicKey)||Y(e.nextDescriptorSequence,"nextDescriptorSequence")!==Y(e.nextRelayBinding.descriptorSequence,"binding descriptorSequence")||!te.default.equals(e.nextDescriptorHash,e.nextRelayBinding.descriptorHash))&&A("nextRelayBinding does not match the accepted next relay descriptor")}}),wy=R([["version",w],["wireProfileHash",l],["sessionClass",Hc],["controlChannelId",S],["parentChannelBinding",l],["clientNonce",l],["admission",Ze]],{name:"CoreOpenReplicationV1",validate(e){Y(e.controlChannelId,"controlChannelId")===0n&&A("controlChannelId must be nonzero"),Qt(e.parentChannelBinding)&&A("parentChannelBinding must be nonzero")}}),Ky=R([["version",w],["relayBinding",ft],["wireProfileHash",l],["sessionClass",Hc],["controlChannelId",S],["parentChannelBinding",l],["streamId",S],["maxSessionBytes",S],["idleMillis",D],["lifetimeMillis",D],["openedAtEpoch",D],["requestNonce",l],["requestCommitment",l],["signature",fe]],{name:"CoreOpenReplicationResultV1",validate(e){lA(e),Y(e.controlChannelId,"controlChannelId")===0n&&A("controlChannelId must be nonzero"),Y(e.streamId,"streamId")===0n&&A("streamId must be nonzero"),Qt(e.parentChannelBinding)&&A("parentChannelBinding must be nonzero")}});var Jc=C(h,Fi.OPEN,Fi.PRIVATE,"conformanceClass"),hi=q,vn=D,LA=bt("parameterUrl"),PA=bt("issuanceUrl"),wA=bt("descriptorUrl"),Zc=R([["profileId",Io],["schemeId",ci],["conformanceClass",Jc],["roleBits",hi],["parameterUrl",z(LA,"parameterUrl")],["parameterHash",l]],{name:"AdmissionProfileV1",validate(e){(e.roleBits===0||(e.roleBits&~Nt.ROLE_BITS_MASK)!==0)&&A("admission roleBits must contain known nonzero bits")}}),KA=R([["familyId",C(h,1,5,"resource cost familyId")],["operationId",C(h,1,255,"resource cost operationId")],["resourceClass",h],["leaseClass",li],["costUnits",S]],{name:"AdmissionParametersV1.resourceCost",validate(e){Y(e.costUnits,"costUnits")===0n&&A("costUnits must be nonzero")}}),UA=ve(KA,1,$e.MAX_ADMISSION_RESOURCE_COST_ROWS,"admission resource costs");function QA(e,t){for(let o of["familyId","operationId","resourceClass","leaseClass"]){let r=Mr(e[o],t[o]);if(r!==0)return r}return 0}var MA=R([["version",w],["relayPublicKey",l],["profileId",Io],["schemeId",ci],["conformanceClass",Jc],["roleBits",hi],["verifierKey",ke(0,4096,"verifierKey")],["resourceCosts",UA],["tokenMaxBytes",C(q,1,$e.MAX_ADMISSION_TOKEN_BYTES,"tokenMaxBytes")],["issuanceUrl",z(PA,"issuanceUrl")],["issuerRelayKey",z(l,"issuerRelayKey")],["validFromEpoch",D],["expiresEpoch",D],["nonce",l],["signature",fe]],{name:"AdmissionParametersV1",validate(e){k(e.relayPublicKey,"relayPublicKey"),(e.roleBits===0||(e.roleBits&~Nt.ROLE_BITS_MASK)!==0)&&A("admission roleBits must contain known nonzero bits"),mr(e.resourceCosts,QA,"admission resource costs"),e.issuanceUrl==null!=(e.issuerRelayKey==null)&&A("issuanceUrl and issuerRelayKey must be present together"),e.issuerRelayKey!=null&&k(e.issuerRelayKey,"issuerRelayKey"),e.validFromEpoch>=e.expiresEpoch&&A("admission parameter validity window must be nonempty")}}),mi=Ii(MA,16*Un,"AdmissionParametersV1"),Ci=R([["version",w],["oldRelayKey",l],["newRelayKey",l],["oldIdentitySequence",S],["newIdentitySequence",S],["validFromEpoch",D],["reasonCode",C(h,1,3,"identity transition reasonCode")],["transitionNonce",l],["oldSignature",fe],["newSignature",fe]],{name:"RelayIdentityTransitionV1",validate(e){k(e.oldRelayKey,"oldRelayKey"),k(e.newRelayKey,"newRelayKey"),te.default.equals(e.oldRelayKey,e.newRelayKey)&&A("identity transition relay keys must differ"),(Y(e.oldIdentitySequence,"oldIdentitySequence")===Mc||Y(e.newIdentitySequence,"newIdentitySequence")!==Y(e.oldIdentitySequence,"oldIdentitySequence")+1n)&&A("newIdentitySequence must equal oldIdentitySequence + 1")}}),qA=R([["version",w],["relayPublicKey",l],["descriptorSequence",S],["descriptorHash",l],["descriptorUrl",wA],["transportBits",q],["issuedEpoch",D],["expiresEpoch",D],["nonce",l],["signature",fe]],{name:"BlindDhtPointerV1",validate(e){k(e.relayPublicKey,"relayPublicKey"),(e.transportBits===0||(e.transportBits&~$e.TRANSPORT_BITS_MASK)!==0)&&A("transportBits must contain known nonzero bits"),ai(e)}}),HA=Ii(qA,$e.MAX_DHT_POINTER_BYTES,"BlindDhtPointerV1"),VA=R([["version",w],["gatewayRelayKey",l],["gatewayDescriptorSequence",S],["configId",h],["kemId",C(q,1,65535,"kemId")],["kdfId",C(q,1,65535,"kdfId")],["aeadId",C(q,1,65535,"aeadId")],["encodedPublicKey",ke(1,256,"encodedPublicKey")],["notBeforeEpoch",D],["notAfterEpoch",D],["previousConfigHash",z(l,"previousConfigHash")],["signature",fe]],{name:"BlindOhttpKeyConfigV1",validate(e){k(e.gatewayRelayKey,"gatewayRelayKey"),(e.notBeforeEpoch>=e.notAfterEpoch||e.notAfterEpoch-e.notBeforeEpoch>$e.MAX_OHTTP_CONFIG_EPOCHS)&&A("OHTTP key validity must be within 1..120 epochs")}}),yo=R([["version",w],["descriptorSequence",S],["descriptorHash",l],["endpointId",co],["transportSupportBit",qc],["requestedRoleBits",hi],["requestedOperationBits",vn],["clientNonce",l]],{name:"BlindHealthChallengeV1",validate(e){(e.transportSupportBit&e.transportSupportBit-1)!==0&&A("transportSupportBit must be one frozen one-hot support bit"),(e.requestedRoleBits&~Nt.ROLE_BITS_MASK)!==0&&A("requestedRoleBits contains a reserved bit"),(e.requestedOperationBits&~$e.ENABLED_OPERATION_BITS_MASK)!==0&&A("requestedOperationBits contains a reserved bit"),(e.requestedRoleBits===0||e.requestedOperationBits===0)&&A("health challenge role and operation bitmaps must both be nonzero")}}),Ei=R([["version",w],["relayPublicKey",l],["storeId",l],["descriptorSequence",S],["descriptorHash",l],["endpointId",co],["transportSupportBit",qc],["durabilityContinuityHash",l],["durabilityProfileHash",l],["clientNonce",l],["readyRoleBits",hi],["readyOperationBits",vn],["clockState",C(h,Xr.READY,Xr.VERIFYING,"clockState")],["effectiveEpochFloor",D],["integrityState",C(h,$r.VERIFIED,$r.FAILED,"integrityState")],["checkpointAgeBand",C(h,0,7,"checkpointAgeBand")],["scrubAgeBand",C(h,0,7,"scrubAgeBand")],["rebalanceState",C(h,Gi.STABLE,Gi.FENCED,"rebalanceState")],["capacityBand",C(h,0,7,"capacityBand")],["challengeEpoch",D],["signature",fe]],{name:"BlindHealthResultV1",validate(e){k(e.relayPublicKey,"relayPublicKey"),k(e.storeId,"storeId"),(e.transportSupportBit&e.transportSupportBit-1)!==0&&A("transportSupportBit must be one frozen one-hot support bit"),(e.readyRoleBits&~Nt.ROLE_BITS_MASK)!==0&&A("readyRoleBits contains a reserved bit"),(e.readyOperationBits&~$e.ENABLED_OPERATION_BITS_MASK)!==0&&A("readyOperationBits contains a reserved bit")}}),FA=R([["backupFailureGroupId",l],["operatorGroupId",l]],{name:"BlindExternalJournalTopologyV1.backupFailureGroup",validate(e){k(e.backupFailureGroupId,"backupFailureGroupId"),k(e.operatorGroupId,"backup operatorGroupId")}}),YA=R([["nodePublicKey",l],["operatorGroupId",l],["failureDomainId",l],["roleConflictBits",q]],{name:"BlindExternalJournalTopologyV1.node",validate(e){k(e.nodePublicKey,"journal nodePublicKey"),k(e.operatorGroupId,"journal operatorGroupId"),k(e.failureDomainId,"journal failureDomainId")}}),GA=ve(FA,0,16,"external backup failure groups"),kA=ve(YA,3,3,"external journal nodes");function vA(e,t){return ao(e.backupFailureGroupId,t.backupFailureGroupId)||ao(e.operatorGroupId,t.operatorGroupId)}function WA(e,t){return ao(e.nodePublicKey,t.nodePublicKey)||ao(e.operatorGroupId,t.operatorGroupId)||ao(e.failureDomainId,t.failureDomainId)||Mr(e.roleConflictBits,t.roleConflictBits)}var jA=R([["version",w],["relayPublicKey",l],["storeId",l],["externalJournalId",l],["durabilityContinuityHash",l],["topologySequence",S],["previousTopologyHash",z(l,"previousTopologyHash")],["replicationClass",pt(h,1,"replicationClass")],["commitQuorum",pt(h,2,"commitQuorum")],["sharedFailureGroupId",l],["liveStoreFailureGroupId",l],["backupFailureGroups",GA],["nodes",kA],["issuedEpoch",D],["expiresEpoch",D],["witnessPublicKey",l],["signature",fe]],{name:"BlindExternalJournalTopologyV1",validate(e){for(let o of["relayPublicKey","storeId","externalJournalId","durabilityContinuityHash","sharedFailureGroupId","liveStoreFailureGroupId","witnessPublicKey"])k(e[o],o);Y(e.topologySequence,"topologySequence")===0n!=(e.previousTopologyHash==null)&&A("previousTopologyHash must be absent exactly for topology sequence zero"),mr(e.backupFailureGroups,vA,"backup failure groups"),mr(e.nodes,WA,"external journal nodes"),Kn(e.nodes.map(o=>o.operatorGroupId),"journal operator groups"),Kn(e.nodes.map(o=>o.failureDomainId),"journal failure domains"),ai(e)}}),er=R([["version",w],["relayBinding",ft],["corePublicKey",l],["fork",S],["length",S],["signedHeadHash",l],["observedAtEpoch",D],["leaseEpoch",D],["result",C(h,lr.MIRROR_ACCEPTED,lr.RECENTLY_SERVED,"core ack result")],["requestNonce",l],["requestCommitment",l],["signature",fe]],{name:"BlindCoreAckV1",validate(e){k(e.corePublicKey,"corePublicKey"),k(e.signedHeadHash,"signedHeadHash")}}),Wn=R([["version",w],["corePublicKey",l],["fork",S],["length",S],["signedHeadHash",l],["leaseClass",lo],["clientNonce",l],["admission",Ze]],{name:"CoreMirrorRequestV1",validate(e){k(e.corePublicKey,"corePublicKey"),k(e.signedHeadHash,"signedHeadHash"),Y(e.length,"length")===0n&&A("core mirror length must be nonzero")}}),zA=ve(S,1,16,"core block indices"),jn=R([["version",w],["corePublicKey",l],["fork",S],["length",S],["signedHeadHash",l],["blockIndices",zA],["clientNonce",l],["admission",z(Ze,"admission")]],{name:"CoreServeChallengeV1",validate(e){k(e.corePublicKey,"corePublicKey"),k(e.signedHeadHash,"signedHeadHash");let t=Y(e.length,"length");t===0n&&A("core serve length must be nonzero"),mr(e.blockIndices,(o,r)=>Mr(Y(o,"block index"),Y(r,"block index")),"core block indices"),e.blockIndices.some(o=>Y(o,"block index")>=t)&&A("core block index must be below length")}}),XA=R([["version",w],["acknowledgement",er],["proofsAndBlocks",ke(1,4*qr-256,"proofsAndBlocks")]],{name:"CoreServeResultV1",validate(e){e.acknowledgement.result!==lr.RECENTLY_SERVED&&A("core serve acknowledgement result must be RECENTLY_SERVED")}}),zn=Ii(XA,4*qr,"CoreServeResultV1"),$A=R([["version",w],["routeId",fo],["nextDescriptorSequence",S],["nextDescriptorHash",l],["requestedWireClass",hr],["circuitClass",di],["circuitNonce",l],["parentRouteScopeHash",l],["hopAdmission",Ze],["innerHandshake",ke(32,32,"innerHandshake")]],{name:"BlindForwardOpenV1",validate(e){k(e.routeId,"routeId"),k(e.nextDescriptorHash,"nextDescriptorHash"),k(e.circuitNonce,"circuitNonce")}}),JA=R([["version",w],["relayBinding",ft],["routeId",fo],["nextDescriptorSequence",S],["nextDescriptorHash",l],["circuitNonce",l],["grantedWireClass",hr],["circuitClass",di],["streamId",S],["grantedInitialWindow",D],["maxDataBytes",D],["maxCircuitBytes",S],["idleMillis",D],["lifetimeMillis",D],["openedAtEpoch",D],["requestCommitment",l],["acceptedRouteScopeHash",l],["acceptedRelayCount",C(h,1,4,"acceptedRelayCount")],["nextHopAccept",OA],["signature",fe]],{name:"BlindForwardOpenResultV1",validate(e){Qn(e),Y(e.streamId,"streamId")===0n&&A("streamId must be nonzero");for(let o of["routeId","nextDescriptorHash","circuitNonce","requestCommitment"])k(e[o],o);let t=e.nextHopAccept;(!te.default.equals(e.relayBinding.relayPublicKey,t.previousRelayKey)||!te.default.equals(e.routeId,t.routeId)||!te.default.equals(e.nextDescriptorHash,t.nextDescriptorHash)||!te.default.equals(e.circuitNonce,t.circuitNonce)||Y(e.nextDescriptorSequence,"nextDescriptorSequence")!==Y(t.nextDescriptorSequence,"nextDescriptorSequence")||e.grantedWireClass!==t.grantedWireClass||e.circuitClass!==t.circuitClass||e.grantedInitialWindow!==t.grantedInitialWindow||e.maxDataBytes!==t.maxDataBytes||Y(e.maxCircuitBytes,"maxCircuitBytes")!==Y(t.maxCircuitBytes,"next maxCircuitBytes")||e.idleMillis!==t.idleMillis||e.lifetimeMillis!==t.lifetimeMillis||e.openedAtEpoch!==t.openedAtEpoch||!te.default.equals(e.acceptedRouteScopeHash,t.acceptedRouteScopeHash)||e.acceptedRelayCount!==t.acceptedRelayCount)&&A("forward open result does not match nextHopAccept")}}),ZA=R([["version",w],["circuitNonce",l],["offset",S],["bytes",ke(1,ee.MAX_FORWARD_DATA_BYTES,"forward data bytes")]],{name:"BlindForwardDataV1",validate(e){k(e.circuitNonce,"circuitNonce")}}),eu=R([["version",w],["circuitNonce",l],["consumedThrough",S],["creditIncrement",C(D,1,ee.MAX_FORWARD_WINDOW_BYTES,"creditIncrement")]],{name:"BlindForwardWindowV1",validate(e){k(e.circuitNonce,"circuitNonce")}}),tu=R([["version",w],["circuitNonce",l],["closeKind",C(h,Yi.FIN,Yi.ABORT,"closeKind")],["finalSendOffset",S],["reasonCode",h]],{name:"BlindForwardCloseV1",validate(e){k(e.circuitNonce,"circuitNonce")}});function ed(e,t){let o=vi[e];o||A("stream chunk wireClass is outside 1..3"),(!Number.isSafeInteger(t)||t<0)&&A("contentLength is outside u32");let r=o-16,i=r-7-t;return i<0&&A("contentLength exceeds the selected stream wire class"),{plaintextLength:r,paddingLength:i}}function wn(e){(!e||typeof e!="object")&&A("BlindStreamChunkPlainV1 must be an object"),e.flags!==0&&e.flags!==1&&A("stream chunk flags contain a reserved bit");let t=ed(e.wireClass,e.contentLength);return _e(e.contentLength,"stream content").preencode({end:0},e.content),_e(t.paddingLength,"stream randomPadding").preencode({end:0},e.randomPadding),t}var ru={preencode(e,t){let{plaintextLength:o}=wn(t);w.preencode(e,t.version),hr.preencode(e,t.wireClass),h.preencode(e,t.flags),D.preencode(e,t.contentLength),_e(t.contentLength,"stream content").preencode(e,t.content),_e(o-7-t.contentLength,"stream randomPadding").preencode(e,t.randomPadding)},encode(e,t){let{paddingLength:o}=wn(t);w.encode(e,t.version),hr.encode(e,t.wireClass),h.encode(e,t.flags),D.encode(e,t.contentLength),_e(t.contentLength,"stream content").encode(e,t.content),_e(o,"stream randomPadding").encode(e,t.randomPadding)},decode(e){let t={version:w.decode(e),wireClass:hr.decode(e),flags:h.decode(e),contentLength:D.decode(e)},{paddingLength:o}=ed(t.wireClass,t.contentLength);return t.content=_e(t.contentLength,"stream content").decode(e),t.randomPadding=_e(o,"stream randomPadding").decode(e),wn(t),t}},ou=ve(xA,1,16,"descriptor protocols"),iu=ve(RA,1,16,"descriptor endpoints"),nu=ve(Zc,1,8,"descriptor admission profiles"),su=R([["version",w],["relayPublicKey",l],["storeId",l],["descriptorSequence",S],["previousDescriptorHash",z(l,"previousDescriptorHash")],["identitySequence",S],["previousRelayKey",z(l,"previousRelayKey")],["identityTransition",z(Ci,"identityTransition")],["build",SA],["protocols",ou],["endpoints",iu],["cellSizeClassBits",h],["leaseClassBits",h],["maxBatchCount",C(q,1,$e.MAX_BATCH_COUNT,"maxBatchCount")],["maxResponseBytes",C(D,1,$e.MAX_RESPONSE_BYTES,"maxResponseBytes")],["maxSponsoredCoreLength",S],["enabledOperationBits",vn],["admissionProfiles",nu],["durability",kn],["durabilityContinuityHash",l],["durabilityProfileHash",l],["storeLifecycleState",C(h,kt.ACTIVE,kt.RETIRED,"storeLifecycleState")],["drainStartedEpoch",z(D,"drainStartedEpoch")],["capacityBand",C(h,0,7,"capacityBand")],["issuedEpoch",D],["expiresEpoch",D],["descriptorNonce",l],["signature",fe]],{name:"BlindServiceDescriptorV1",validate(e){for(let n of["relayPublicKey","storeId","durabilityContinuityHash","durabilityProfileHash","descriptorNonce"])k(e[n],n);Y(e.descriptorSequence,"descriptorSequence")===0n!=(e.previousDescriptorHash==null)&&A("previousDescriptorHash must be absent exactly for descriptor sequence zero");let o=e.identityTransition!=null;if(o!==(e.previousRelayKey!=null)&&A("previousRelayKey and identityTransition must be present together"),o){let n=e.identityTransition;(!te.default.equals(e.previousRelayKey,n.oldRelayKey)||!te.default.equals(e.relayPublicKey,n.newRelayKey)||Y(e.identitySequence,"identitySequence")!==Y(n.newIdentitySequence,"newIdentitySequence"))&&A("descriptor identity transition does not bind its current and previous identity")}mr(e.protocols,(n,s)=>Mr(n.protocolId,s.protocolId),"descriptor protocols"),mr(e.endpoints,(n,s)=>Mr(n.endpointId,s.endpointId),"descriptor endpoints"),mr(e.admissionProfiles,(n,s)=>Mr(n.profileId,s.profileId),"descriptor admission profiles"),(e.cellSizeClassBits===0||(e.cellSizeClassBits&~$e.CELL_SIZE_CLASS_BITS_MASK)!==0)&&A("cellSizeClassBits must contain known nonzero bits"),(e.leaseClassBits===0||(e.leaseClassBits&~$e.LEASE_CLASS_BITS_MASK)!==0)&&A("leaseClassBits must contain known nonzero bits"),(e.enabledOperationBits&~$e.ENABLED_OPERATION_BITS_MASK)!==0&&A("enabledOperationBits contains a reserved bit");let r=e.storeLifecycleState===kt.DRAINING,i=e.storeLifecycleState===kt.RETIRED;e.storeLifecycleState===kt.ACTIVE!=(e.drainStartedEpoch==null)&&A("drainStartedEpoch presence does not match storeLifecycleState"),e.drainStartedEpoch!=null&&e.drainStartedEpoch>e.issuedEpoch&&A("drainStartedEpoch cannot be after descriptor issuance"),r&&e.enabledOperationBits!==76247&&A("DRAINING descriptor has the wrong enabled operation bitmap"),i&&e.enabledOperationBits!==0&&A("RETIRED descriptor must disable all operations"),ai(e)}}),bi=Ii(su,$e.MAX_DESCRIPTOR_BYTES,"BlindServiceDescriptorV1"),au=R([["category",C(h,1,5,"schema category")],["categoryLocalSchemaId",C(q,1,65535,"categoryLocalSchemaId")],["schemaName",Po(1,96,"schemaName")],["canonicalSchemaBytes",ke(1,65535,"canonicalSchemaBytes")]],{name:"SchemaCatalogEntryV1",validate(e){let t=Pc[e.category],o=t&&t[e.categoryLocalSchemaId-1];(!o||!te.default.equals(ce(e.schemaName),te.default.from(o,"hex")))&&A("schema catalog entry does not match the frozen category registry")}}),Uy=Object.freeze({AdmissionParametersV1:mi,AdmissionProfileV1:Zc,BlindCoreAckV1:er,BlindDhtPointerV1:HA,BlindExternalJournalTopologyV1:jA,BlindForwardCloseV1:tu,BlindForwardDataV1:ZA,BlindForwardOpenResultV1:JA,BlindForwardOpenV1:$A,BlindForwardWindowV1:eu,BlindHealthChallengeV1:yo,BlindHealthResultV1:Ei,BlindOhttpKeyConfigV1:VA,BlindServiceDescriptorV1:bi,BlindStreamChunkPlainV1:ru,CoreMirrorRequestV1:Wn,CoreServeChallengeV1:jn,CoreServeResultV1:zn,RelayIdentityTransitionV1:Ci,SchemaCatalogEntryV1:au});var Er=Z(ae(),1);var Cr=class extends Error{constructor(t,o,r){super(o,r),this.name="BlindClientError",this.code=t}};function c(e,t,o){throw new Cr(e,t,o)}function m(e,t,o=null){let r;return Er.default.isBuffer(e)?r=e:ArrayBuffer.isView(e)?r=Er.default.from(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?r=Er.default.from(e):c("BAD_CLIENT_INPUT",`${t} must be bytes`),o!=null&&r.byteLength!==o&&c("BAD_CLIENT_INPUT",`${t} must be exactly ${o} bytes`),r}function Ve(e,t,o="random bytes"){(!e||typeof e.randomBytes!="function")&&c("CRYPTO_UNAVAILABLE","runtime.randomBytes is required");let r=m(e.randomBytes(t),o,t);return Er.default.from(r)}function td(e,t){(!Number.isSafeInteger(e)||e<0||e>4294967295)&&c("BAD_CLIENT_INPUT",`${t} is outside u32`);let o=Er.default.alloc(4);return Er.default.writeUInt32BE(o,e,0),o}function Ce(e){e&&typeof e.fill=="function"&&e.fill(0)}var Ke=Z(ae(),1);var rd=Symbol("VerifiedEndpoint"),br=new WeakMap,gi=class{constructor(t,o){if(t!==rd)throw new TypeError("VerifiedEndpoint is not directly constructible");br.set(this,o),Object.freeze(this)}get relayPublicKey(){return Ke.default.from(br.get(this).relayPublicKey)}get descriptorHash(){return Ke.default.from(br.get(this).descriptorHash)}get familyId(){return br.get(this).familyId}get operationId(){return br.get(this).operationId}};function od(e){return new gi(rd,e)}function id(e){let t=br.get(e);if(!t)return null;let o=t.endpoint;return{...o,qualifiedFamilyId:t.familyId,qualifiedOperationId:t.operationId,transportSupportBit:t.transportSupportBit,transportProfileHash:Ke.default.from(o.transportProfileHash),canonicalUrl:Ke.default.from(o.canonicalUrl),endpointKey:o.endpointKey==null?null:Ke.default.from(o.endpointKey),auxiliaryUrl:o.auxiliaryUrl==null?null:Ke.default.from(o.auxiliaryUrl),auxiliaryHash:o.auxiliaryHash==null?null:Ke.default.from(o.auxiliaryHash)}}function Rt(e){let t=br.get(e);return t||c("BAD_CLIENT_INPUT","a VerifiedEndpoint is required"),Object.freeze({descriptorHash:Ke.default.from(t.descriptorHash),descriptorSequence:t.descriptorSequence,relayPublicKey:Ke.default.from(t.relayPublicKey),storeId:Ke.default.from(t.storeId),continuityRoot:Ke.default.from(t.continuityRoot),familyId:t.familyId,operationId:t.operationId,endpointId:t.endpoint.endpointId,transportId:t.endpoint.transportId,transportSupportBit:t.transportSupportBit,privacyProfileBit:t.privacyProfileBit,durabilityProfileId:t.durabilityProfileId,durabilityContinuityHash:Ke.default.from(t.durabilityContinuityHash),durabilityProfileHash:Ke.default.from(t.durabilityProfileHash),restoreEvidenceHeadSequence:t.restoreEvidenceHeadSequence,restoreEvidenceHeadHash:Ke.default.from(t.restoreEvidenceHeadHash),externalWitnessPublicKey:Ke.default.from(t.externalWitnessPublicKey),externalJournalId:Ke.default.from(t.externalJournalId)})}var V=Z(ae(),1);var fd=V.default.from("HRINT1","ascii"),Zn=1,tr=264,Id=4*1024*1024,Ad=4*1024*1024,cu=(1n<<64n)-1n,du=V.default.from("hiverelay.blind.client-intent-aead.v1","ascii"),L=Object.freeze({JOURNALED:1,TARGET_PREPARED:2,SENT:3,ACKNOWLEDGED:4,PENDING_UNKNOWN:5,RESULT_VERIFIED:6,RETRYABLE:7,TERMINAL:8}),lu=new Map([[L.JOURNALED,new Set([L.TARGET_PREPARED,L.TERMINAL])],[L.TARGET_PREPARED,new Set([L.SENT,L.RETRYABLE,L.TERMINAL])],[L.SENT,new Set([L.ACKNOWLEDGED,L.PENDING_UNKNOWN,L.RESULT_VERIFIED,L.RETRYABLE,L.TERMINAL])],[L.ACKNOWLEDGED,new Set([L.RESULT_VERIFIED,L.PENDING_UNKNOWN])],[L.PENDING_UNKNOWN,new Set([L.TARGET_PREPARED,L.RESULT_VERIFIED,L.TERMINAL])],[L.RESULT_VERIFIED,new Set([])],[L.RETRYABLE,new Set([L.TARGET_PREPARED,L.TERMINAL])],[L.TERMINAL,new Set([])]]);function ud(e,t){return typeof e=="number"&&((!Number.isSafeInteger(e)||e<0)&&c("BAD_CLIENT_INPUT",`${t} is outside u64`),e=BigInt(e)),(typeof e!="bigint"||e<0n||e>cu)&&c("BAD_CLIENT_INPUT",`${t} is outside u64`),e}function pd(e,t,o){o=ud(o,"u64 value");for(let r=7;r>=0;r--)e[t+r]=Number(o&0xffn),o>>=8n}function fu(e,t){let o=0n;for(let r=0;r<8;r++)o=o<<8n|BigInt(e[t+r]);return o}function nd(e,t,o){e[t]=o>>>8&255,e[t+1]=o&255}function sd(e,t){return e[t]*256+e[t+1]}function Hr(e,t,o=32){return e=V.default.from(m(e,t,o)),e.every(r=>r===0)&&c("BAD_CLIENT_INPUT",`${t} must be nonzero`),e}function ad(e,t,o,r=!1){return e=V.default.from(m(e,t)),(!r&&e.byteLength===0||e.byteLength>o)&&c("BAD_CLIENT_INPUT",`${t} is outside its byte bound`),e}function Mt(e,t,o,r){return(!Number.isSafeInteger(e)||e<t||e>o)&&c("BAD_CLIENT_INPUT",`${r} must be within ${t}..${o}`),e}function Vr(e){(!e||typeof e!="object")&&c("BAD_CLIENT_INPUT","client intent must be an object");let t=Mt(e.state,L.JOURNALED,L.TERMINAL,"intent state"),o=ad(e.operationBytes,"operationBytes",Id),r=e.resultBytes==null?null:ad(e.resultBytes,"resultBytes",Ad,!0),i=e.mayHaveCommitted===!0;t===L.JOURNALED&&i&&c("BAD_CLIENT_INPUT","newly journaled intent cannot be marked mayHaveCommitted"),t===L.RESULT_VERIFIED&&r==null&&c("BAD_CLIENT_INPUT","verified intent requires exact result bytes"),t!==L.RESULT_VERIFIED&&r!=null&&c("BAD_CLIENT_INPUT","result bytes are persisted only after complete verification");let n=Mt(e.transportSupportBit,1,65535,"transportSupportBit"),s=Mt(e.privacyProfileBit,1,65535,"privacyProfileBit");((n&n-1)!==0||(s&s-1)!==0)&&c("BAD_CLIENT_INPUT","transport and privacy profiles must each contain one bit");let a=Mt(e.familyId,1,5,"familyId"),d=Mt(e.operationId,1,255,"operationId");return Do(a,d)||c("BAD_CLIENT_INPUT","client intent operation is unknown or reserved by the active release profile"),{version:Zn,state:t,mayHaveCommitted:i,intentId:Hr(e.intentId,"intentId"),logicalId:Hr(e.logicalId,"logicalId"),continuityRoot:Hr(e.continuityRoot,"continuityRoot"),storeId:Hr(e.storeId,"storeId"),descriptorHash:Hr(e.descriptorHash,"descriptorHash"),descriptorSequence:ud(e.descriptorSequence,"descriptorSequence"),endpointId:Mt(e.endpointId,1,255,"endpointId"),transportId:Mt(e.transportId,1,255,"transportId"),transportSupportBit:n,privacyProfileBit:s,familyId:a,operationId:d,requestCommitment:Hr(e.requestCommitment,"requestCommitment"),clientNonce:V.default.from(m(e.clientNonce,"clientNonce",32)),operationBytes:o,resultBytes:r,attemptCount:Mt(e.attemptCount==null?0:e.attemptCount,0,4294967295,"attemptCount"),lastErrorCode:Mt(e.lastErrorCode==null?0:e.lastErrorCode,0,255,"lastErrorCode")}}function Xn(e){return Vr(e)}function cd(e){e=Vr(e);let t=e.resultBytes==null?4294967295:e.resultBytes.byteLength,o=V.default.alloc(tr+e.operationBytes.byteLength+(e.resultBytes==null?0:t));return V.default.copy(fd,o,0),o[6]=Zn,o[7]=e.state,o[8]=e.mayHaveCommitted?1:0,o[9]=e.familyId,o[10]=e.operationId,o[11]=e.endpointId,o[12]=e.transportId,nd(o,13,e.transportSupportBit),nd(o,15,e.privacyProfileBit),V.default.writeUInt32BE(o,e.attemptCount,17),o[21]=e.lastErrorCode,V.default.writeUInt32BE(o,e.operationBytes.byteLength,22),V.default.writeUInt32BE(o,t,26),pd(o,30,e.descriptorSequence),V.default.copy(e.intentId,o,38),V.default.copy(e.logicalId,o,70),V.default.copy(e.continuityRoot,o,102),V.default.copy(e.storeId,o,134),V.default.copy(e.descriptorHash,o,166),V.default.copy(e.requestCommitment,o,198),V.default.copy(e.clientNonce,o,230),V.default.copy(e.operationBytes,o,tr),e.resultBytes!=null&&V.default.copy(e.resultBytes,o,tr+e.operationBytes.byteLength),o}function Iu(e){e=V.default.from(m(e,"encoded client intent")),(e.byteLength<tr||!V.default.equals(e.subarray(0,6),fd)||e[6]!==Zn)&&c("INTENT_CORRUPT","client intent header is invalid"),(e[8]>1||e[262]!==0||e[263]!==0)&&c("INTENT_CORRUPT","client intent flags or reserved bytes are invalid");let t=V.default.readUInt32BE(e,22),o=V.default.readUInt32BE(e,26),r=o===4294967295?0:o;return(t===0||t>Id||r>Ad||e.byteLength!==tr+t+r)&&c("INTENT_CORRUPT","client intent lengths are invalid"),Vr({state:e[7],mayHaveCommitted:e[8]===1,familyId:e[9],operationId:e[10],endpointId:e[11],transportId:e[12],transportSupportBit:sd(e,13),privacyProfileBit:sd(e,15),attemptCount:V.default.readUInt32BE(e,17),lastErrorCode:e[21],descriptorSequence:fu(e,30),intentId:e.subarray(38,70),logicalId:e.subarray(70,102),continuityRoot:e.subarray(102,134),storeId:e.subarray(134,166),descriptorHash:e.subarray(166,198),requestCommitment:e.subarray(198,230),clientNonce:e.subarray(230,262),operationBytes:e.subarray(tr,tr+t),resultBytes:o===4294967295?null:e.subarray(tr+t)})}function Au(e,t){uu(e,t)||c("INTENT_TRANSITION_INVALID","immutable intent identity changed during CAS"),e.state!==t.state&&!lu.get(e.state).has(t.state)&&c("INTENT_TRANSITION_INVALID","intent state transition is not allowed"),(t.attemptCount<e.attemptCount||t.attemptCount>e.attemptCount+1)&&c("INTENT_TRANSITION_INVALID","intent attempt count must be monotonic and increment by at most one"),e.mayHaveCommitted&&!t.mayHaveCommitted&&c("INTENT_TRANSITION_INVALID","mayHaveCommitted cannot be cleared")}function uu(e,t){for(let o of["intentId","logicalId","continuityRoot","storeId","descriptorHash","requestCommitment","clientNonce","operationBytes"])if(!V.default.equals(e[o],t[o]))return!1;for(let o of["descriptorSequence","endpointId","transportId","transportSupportBit","privacyProfileBit","familyId","operationId"])if(BigInt(e[o])!==BigInt(t[o]))return!1;return!0}function $n(e){return`intent:${V.default.toString(m(e,"intentId",32),"hex")}`}function dd(e,t){let o=V.default.alloc(8);return pd(o,0,t),V.default.concat([du,m(e,"intentId",32),o])}function vy(e,t){return t=V.default.from(m(t,"intent encryption key",32)),(!e||typeof e.aes256GcmEncrypt!="function"||typeof e.aes256GcmDecrypt!="function")&&c("CRYPTO_UNAVAILABLE","intent sealer requires AES-256-GCM runtime methods"),Object.freeze({async seal({intentId:o,revision:r,plaintext:i}){let n=Ve(e,12,"intent encryption nonce"),s=await e.aes256GcmEncrypt({key:t,nonce:n,aad:dd(o,r),plaintext:i});return V.default.concat([n,V.default.from(s)])},async open({intentId:o,revision:r,ciphertext:i}){i=m(i,"intent ciphertext"),i.byteLength<28&&c("INTENT_CORRUPT","intent ciphertext is truncated");try{return V.default.from(await e.aes256GcmDecrypt({key:t,nonce:i.subarray(0,12),aad:dd(o,r),sealed:i.subarray(12)}))}catch(n){c("INTENT_CORRUPT","intent ciphertext authentication failed",{cause:n})}}})}var ld=class{constructor(){this.records=new Map}async read(t){let o=this.records.get(t);return o==null?{revision:0n,ciphertext:null}:{revision:o.revision,ciphertext:V.default.from(o.ciphertext)}}async compareAndSwap(t,o,r){let i=this.records.get(t),n=i==null?0n:i.revision;return n!==BigInt(o)?!1:(this.records.set(t,{revision:n+1n,ciphertext:V.default.from(r)}),!0)}async keys(){return[...this.records.keys()].sort()}},Jn=class{constructor(t){(!t||!t.backend||!t.sealer||typeof t.backend.read!="function"||typeof t.backend.compareAndSwap!="function"||typeof t.sealer.seal!="function"||typeof t.sealer.open!="function")&&c("BAD_CLIENT_INPUT","encrypted intent store requires a CAS backend and authenticated sealer"),this.backend=t.backend,this.sealer=t.sealer}async create(t){let o=Vr({...t,state:L.JOURNALED,mayHaveCommitted:!1,attemptCount:0,lastErrorCode:0,resultBytes:null}),r=$n(o.intentId),i=cd(o);try{let n=await this.sealer.seal({intentId:o.intentId,revision:1n,plaintext:i});return await this.backend.compareAndSwap(r,0n,n)||c("INTENT_CONFLICT","intent ID already exists"),Xn(o)}finally{Ce(i)}}async read(t){let o=await this.backend.read($n(t));if(o.ciphertext==null)return null;let r=await this.sealer.open({intentId:t,revision:o.revision,ciphertext:o.ciphertext});try{let i=Iu(r);return V.default.equals(i.intentId,m(t,"intentId",32))||c("INTENT_CORRUPT","intent key/body mismatch"),{revision:o.revision,value:i}}finally{Ce(r)}}async update(t,o){typeof o!="function"&&c("BAD_CLIENT_INPUT","intent CAS mutate callback is required");for(let r=0;r<8;r++){let i=await this.read(t);i==null&&c("INTENT_NOT_FOUND","intent does not exist");let n=Vr(await o(Xn(i.value)));Au(i.value,n);let s=cd(n);try{let a=i.revision+1n,d=await this.sealer.seal({intentId:t,revision:a,plaintext:s});if(await this.backend.compareAndSwap($n(t),i.revision,d))return{revision:a,value:Xn(n)}}finally{Ce(s)}}c("INTENT_BUSY","intent CAS did not converge")}};function Wy(e){return Vr({...e,intentId:e.intentId==null?Ve(e.runtime,32,"intentId"):e.intentId,state:L.JOURNALED,mayHaveCommitted:!1,attemptCount:0,lastErrorCode:0,resultBytes:null})}async function jy(e,t,o={}){e instanceof Jn||c("BAD_CLIENT_INPUT","EncryptedIntentStore is required");let r=o.ephemeralSecrets||[];Array.isArray(r)||c("BAD_CLIENT_INPUT","ephemeralSecrets must be an array");try{return await e.create(t)}finally{for(let i of r)Ce(i)}}var _t=Z(ae(),1);var Xe=Z(ae(),1);var Bi=1,rr=12,ts=16,Fr=4,es=32,pu=Xe.default.from("hiverelay.blind.cell.v1","ascii");function rs(e){return(!Number.isInteger(e)||Et[e]==null)&&c("BAD_CLIENT_INPUT","sizeClass is outside the frozen cell classes"),Et[e]}function yd(e,t){return Xe.default.concat([pu,Xe.default.from([Bi,t]),m(e,"storageSlot",32)])}function hd(e){(!e||typeof e.aes256GcmEncrypt!="function"||typeof e.aes256GcmDecrypt!="function")&&c("CRYPTO_UNAVAILABLE","runtime AES-256-GCM methods are required")}function yu(e){return rs(e)-Bi-rr-ts-Fr}async function md(e){(!e||typeof e!="object")&&c("BAD_CLIENT_INPUT","cell options are required");let t=e.runtime;hd(t);let o=m(e.storageSlot,"storageSlot",32),r=m(e.structuredContent,"structuredContent"),i=e.sizeClass,n=rs(i),s=yu(i);r.byteLength>s&&c("CELL_CONTENT_TOO_LARGE",`structuredContent exceeds sizeClass ${i}`);let a=e.cellKey==null?Ve(t,es,"cell key"):Xe.default.from(m(e.cellKey,"cellKey",es)),d=e.nonce==null?Ve(t,rr,"cell nonce"):Xe.default.from(m(e.nonce,"nonce",rr)),f=n-1-rr-ts,I=Xe.default.alloc(f);Xe.default.copy(td(r.byteLength,"structuredContent length"),I,0),Xe.default.copy(r,I,Fr);let E=I.subarray(Fr+r.byteLength);E.byteLength>0&&Xe.default.copy(Ve(t,E.byteLength,"cell padding"),E);try{let _=m(await t.aes256GcmEncrypt({key:a,nonce:d,aad:yd(o,i),plaintext:I}),"sealed cell");return _.byteLength!==n-1-rr&&c("CRYPTO_FAILURE","AES-256-GCM returned an unexpected length"),{cellKey:a,cellBlob:Xe.default.concat([Xe.default.from([Bi]),d,_])}}catch(_){if(e.cellKey==null&&Ce(a),_&&_.code)throw _;c("CRYPTO_FAILURE","cell encryption failed",{cause:_})}finally{Ce(I)}}async function Cd(e){(!e||typeof e!="object")&&c("BAD_CLIENT_INPUT","cell options are required");let t=e.runtime;hd(t);let o=m(e.storageSlot,"storageSlot",32),r=m(e.cellKey,"cellKey",es),i=e.sizeClass,n=rs(i),s=m(e.cellBlob,"cellBlob",n);if(e.expectedCellBlobHash!=null){let I=m(e.expectedCellBlobHash,"expectedCellBlobHash",32);Xe.default.equals(ce(s),I)||c("CELL_HASH_MISMATCH","cell blob does not match the read capability")}s[0]!==Bi&&c("BAD_CELL_BLOB","unsupported cell blob version");let a=s.subarray(1,1+rr),d=s.subarray(1+rr),f;try{f=m(await t.aes256GcmDecrypt({key:r,nonce:a,aad:yd(o,i),sealed:d}),"cell plaintext",n-1-rr-ts)}catch(I){c("CELL_AUTHENTICATION_FAILED","cell authentication failed",{cause:I})}try{let I=Xe.default.readUInt32BE(f,0);return I>f.byteLength-Fr&&c("BAD_CELL_BLOB","authenticated cell length exceeds its class"),Xe.default.from(f.subarray(Fr,Fr+I))}finally{Ce(f)}}var Ri=Z(ae(),1);var Ed=Z(en(),1),bd=Z(Qo(),1),xi=Z(xn(),1),qt=Object.freeze({crypto_generichash:Ed.default.crypto_generichash,crypto_sign_detached:xi.default.crypto_sign_detached,crypto_sign_seed_keypair:xi.default.crypto_sign_seed_keypair,crypto_sign_verify_detached:xi.default.crypto_sign_verify_detached,randombytes_buf:bd.default.randombytes_buf});function H(e,t){return e!=null&&t!=null&&e.byteLength===t.byteLength&&Ri.default.equals(e,t)}function Yr(e,t,o){let r,i;try{if(r=Ri.default.from(t),i=jt(e,r,{copyBytes:!0}),!Ri.default.equals(Se(e,i),r))throw new Error("canonical round-trip changed bytes")}catch(n){c("RELAY_PROTOCOL_VIOLATION",`${o} is not canonical`,{cause:n})}return{bytes:r,value:i}}function Gr(e,t,o,r,i,n=64){return Bd(e,t,o,r,i,n,Nc,t.signature)}function gd(e,t,o,r,i,n=64,s=t.signature){return Bd(e,t,o,r,i,n,si,s)}function Bd(e,t,o,r,i,n,s,a){let d=Se(e,t);(!Number.isSafeInteger(n)||n<64||d.byteLength<=n)&&c("RELAY_PROTOCOL_VIOLATION",`${i} has an invalid signature boundary`),(n!==64||a==null||a.byteLength!==64)&&c("RELAY_PROTOCOL_VIOLATION",`${i} has no canonical final signature`);let f=d.subarray(0,d.byteLength-n),I;try{I=s(o,f)}catch(E){c("RELAY_PROTOCOL_VIOLATION",`${i} uses an unknown signature domain`,{cause:E})}return qt.crypto_sign_verify_detached(a,I,r)||c("RELAY_PROTOCOL_VIOLATION",`${i} signature is invalid`),f}function os(e,t,o,r){qt.crypto_sign_verify_detached(o,t,e)||c("RELAY_PROTOCOL_VIOLATION",`${r} signature is invalid`)}var Rd=Symbol("VerifiedOperationResult"),ho=new WeakMap;function G(e,t){return`${e}:${t}`}function It(e,t,o){H(e,t)||c("RELAY_PROTOCOL_VIOLATION",`${o} does not match the attempted request`)}function hu(e){return m(e.clientNonce,"request clientNonce",32)}var mu=new Set([G(b.CELL,g.CELL.PROVE),G(b.CELL,g.CELL.BATCH_GET),G(b.INBOX,g.INBOX.READ),G(b.CORE,g.CORE.PROVE)]);function Cu(e,t){return e.durabilityProfileId!==2?!1:mu.has(G(e.familyId,e.operationId))?t!=null&&t.admission!=null:!0}function Eu(e,t,o,r){let i=[["descriptorSequence",t.descriptorSequence],["durabilityProfileId",t.durabilityProfileId],["restoreEvidenceHeadSequence",t.restoreEvidenceHeadSequence]];for(let[a,d]of i)BigInt(e[a])!==BigInt(d)&&c("RELAY_PROTOCOL_VIOLATION",`relay binding ${a} does not match the qualified descriptor`);for(let a of["relayPublicKey","storeId","descriptorHash","durabilityContinuityHash","durabilityProfileHash","restoreEvidenceHeadHash"])H(e[a],t[a])||c("RELAY_PROTOCOL_VIOLATION",`relay binding ${a} does not match the qualified descriptor`);let n=e.externalCommitWitness,s=Cu(t,o.request);if(n==null){s&&c("RELAY_PROTOCOL_VIOLATION","profile-2 result omitted its external commit witness");return}s||c("RELAY_PROTOCOL_VIOLATION","uncharged result carried an external commit witness"),(t.durabilityProfileId!==2||!H(n.witnessPublicKey,t.externalWitnessPublicKey))&&c("RELAY_PROTOCOL_VIOLATION","external commit witness is not bound to the descriptor witness key"),(n.familyId!==t.familyId||n.operationId!==t.operationId||!H(n.requestCommitment,o.requestCommitment)||!H(n.externalJournalId,t.externalJournalId)||!H(n.resultCommitment,r))&&c("RELAY_PROTOCOL_VIOLATION","external commit witness does not bind the attempted operation"),gd(Ln,n,To.EXTERNAL_COMMIT_WITNESS,t.externalWitnessPublicKey,"external commit witness"),(typeof o.externalWitnessVerifier!="function"||o.externalWitnessVerifier(Object.freeze({witness:n,context:t,resultCommitment:_t.default.from(r)}))!==!0)&&c("RELAY_PROTOCOL_VIOLATION","external commit witness policy verification failed")}function St(e,t,o,r,i,n,s){if(Gr(e,t,o,r.relayPublicKey,i),n!=null){let a=Se(e,{...t,relayBinding:{...n,externalCommitWitness:null}}),d=a.subarray(0,a.byteLength-64);Eu(n,r,s,Cc(r.familyId,r.operationId,d))}}function Tt(e,t,o){It(e.requestNonce,hu(t),"result requestNonce"),It(e.requestCommitment,o,"result requestCommitment")}function Sd(e,t){return ri({relayPublicKey:e.relayPublicKey,storageSlot:t.storageSlot,allocationEpoch:t.allocationEpoch,sizeClass:t.sizeClass,leaseClass:t.leaseClass,declaredCellBlobHash:t.declaredBlobHash,createPublicKey:t.createPublicKey,renewPublicKey:t.renewPublicKey,dropPublicKey:t.dropPublicKey})}function bu(e,t,o){let r=e.relayPublicKey;switch(G(e.familyId,e.operationId)){case G(b.CELL,g.CELL.PUT):{let i=Sd(e,t);return oi({allocationCommitment:i,clientNonce:t.clientNonce})}case G(b.CELL,g.CELL.GET):return ni({relayPublicKey:r,storageSlot:o,clientNonce:t.clientNonce});case G(b.CELL,g.CELL.RENEW):return ii({operation:"cell-renew",relayPublicKey:r,storageSlot:t.storageSlot,expectedRevision:t.expectedRevision,expectedLeaseEpoch:t.expectedLeaseEpoch,requestedLeaseClass:t.leaseClass,clientNonce:t.clientNonce});case G(b.CELL,g.CELL.DROP):return ii({operation:"cell-drop",relayPublicKey:r,storageSlot:t.storageSlot,expectedRevision:t.expectedRevision,expectedLeaseEpoch:t.expectedLeaseEpoch,requestedLeaseClass:0,clientNonce:t.clientNonce});case G(b.CELL,g.CELL.PROVE):return _n({relayPublicKey:r,storageSlot:t.storageSlot,clientNonce:t.clientNonce});case G(b.CELL,g.CELL.BATCH_GET):return Nn({relayPublicKey:r,slots:t.slots,clientNonce:t.clientNonce});case G(b.INBOX,g.INBOX.CREATE):{let i=Bc({...t,relayPublicKey:r});return xc({inboxCreateCommitment:i,clientNonce:t.clientNonce})}case G(b.INBOX,g.INBOX.RENEW):case G(b.INBOX,g.INBOX.CLOSE):return Rc({operation:e.operationId===g.INBOX.RENEW?"inbox-renew":"inbox-close",relayPublicKey:r,physicalTopic:t.physicalTopic,expectedRevision:t.expectedRevision,expectedLeaseEpoch:t.expectedLeaseEpoch,requestedLeaseClass:t.leaseClass,clientNonce:t.clientNonce});case G(b.INBOX,g.INBOX.APPEND):return Sc({relayPublicKey:r,physicalTopic:t.physicalTopic,frameClass:t.frameClass,frameHash:t.frameHash,clientNonce:t.clientNonce});case G(b.INBOX,g.INBOX.READ):return Tc({relayPublicKey:r,physicalTopic:t.physicalTopic,cursor:t.cursor,limit:t.limit,clientNonce:t.clientNonce});case G(b.INBOX,g.INBOX.WATCH):return _c({relayPublicKey:r,physicalTopic:t.physicalTopic,afterRevision:t.afterRevision,limit:t.limit,maxWaitMillis:t.maxWaitMillis,clientNonce:t.clientNonce});case G(b.CORE,g.CORE.MIRROR):return Ec({...t,relayPublicKey:r});case G(b.CORE,g.CORE.PROVE):return bc({...t,relayPublicKey:r});default:c("BAD_CLIENT_INPUT","operation has no closed request commitment verifier")}}var ns=new Map([[G(b.CELL,g.CELL.PUT),{encoding:mt,verify(e,t,o,r,i){St(mt,e,Ye.CELL_RECEIPT,r,"cell PUT receipt",e.relayBinding,i),Tt(e,t,o),It(e.slotCommitment,ce(t.storageSlot),"cell receipt slotCommitment"),It(e.cellBlobHash,t.declaredBlobHash,"cell receipt cellBlobHash"),It(e.allocationCommitment,Sd(r,t),"cell receipt allocationCommitment"),(e.sizeClass!==t.sizeClass||e.allocationEpoch!==t.allocationEpoch||e.leaseClass!==t.leaseClass||BigInt(e.stateRevision)!==0n||e.result!==Dt.STORED)&&c("RELAY_PROTOCOL_VIOLATION","cell PUT receipt shape does not match the request")}}],[G(b.CELL,g.CELL.GET),{encoding:kc,verify(){}}],[G(b.CELL,g.CELL.RENEW),{encoding:mt,verify(e,t,o,r,i){St(mt,e,Ye.CELL_RECEIPT,r,"cell RENEW receipt",e.relayBinding,i),Tt(e,t,o),It(e.slotCommitment,ce(t.storageSlot),"cell receipt slotCommitment"),(e.result!==Dt.RENEWED||e.leaseClass!==t.leaseClass||BigInt(e.stateRevision)!==BigInt(t.expectedRevision)+1n||e.leaseEpoch<=t.expectedLeaseEpoch)&&c("RELAY_PROTOCOL_VIOLATION","cell RENEW receipt shape does not match the request")}}],[G(b.CELL,g.CELL.DROP),{encoding:mt,verify(e,t,o,r,i){St(mt,e,Ye.CELL_RECEIPT,r,"cell DROP receipt",e.relayBinding,i),Tt(e,t,o),It(e.slotCommitment,ce(t.storageSlot),"cell receipt slotCommitment"),(e.result!==Dt.DROPPED||e.leaseClass!==0||BigInt(e.stateRevision)!==BigInt(t.expectedRevision)+1n)&&c("RELAY_PROTOCOL_VIOLATION","cell DROP receipt shape does not match the request")}}],[G(b.CELL,g.CELL.PROVE),{encoding:vc,verify(e,t,o,r,i){St(mt,e.receipt,Ye.CELL_RECEIPT,r,"cell PROVE receipt",e.receipt.relayBinding,i),Tt(e.receipt,t,o),It(e.receipt.slotCommitment,ce(t.storageSlot),"cell proof slotCommitment")}}],[G(b.CELL,g.CELL.BATCH_GET),{encoding:Fn,verify(e,t,o,r,i){St(Fn,e,Ye.BATCH_GET_RESULT,r,"batch GET result",e.relayBinding,i),Tt(e,t,o),e.entries.length!==t.slots.length&&c("RELAY_PROTOCOL_VIOLATION","batch GET result count does not match request slots")}}],[G(b.INBOX,g.INBOX.CREATE),is(dr.CREATED)],[G(b.INBOX,g.INBOX.RENEW),is(dr.RENEWED)],[G(b.INBOX,g.INBOX.CLOSE),is(dr.CLOSED)],[G(b.INBOX,g.INBOX.APPEND),{encoding:po,verify(e,t,o,r,i){St(po,e,Ye.INBOX_APPEND_ACK,r,"inbox APPEND acknowledgement",e.relayBinding,i),Tt(e,t,o),It(e.topicCommitment,ce(t.physicalTopic),"inbox topicCommitment"),It(e.frameHash,t.frameHash,"inbox frameHash"),e.result!==So.STORED&&c("RELAY_PROTOCOL_VIOLATION","inbox append was not stored")}}],[G(b.INBOX,g.INBOX.READ),xd()],[G(b.INBOX,g.INBOX.WATCH),xd()],[G(b.CORE,g.CORE.MIRROR),gu(lr.MIRROR_ACCEPTED)],[G(b.CORE,g.CORE.PROVE),{encoding:zn,verify(e,t,o,r,i){let n=e.acknowledgement;St(er,n,Ye.CORE_ACK,r,"core PROVE acknowledgement",n.relayBinding,i),Tt(n,t,o),Td(n,t),(n.result!==lr.RECENTLY_SERVED||typeof i.coreProofVerifier!="function"||i.coreProofVerifier(Object.freeze({request:t,acknowledgement:n,proofsAndBlocks:e.proofsAndBlocks}))!==!0)&&c("RELAY_PROTOCOL_VIOLATION","core proof verification failed")}}]]);function is(e){return{encoding:uo,verify(t,o,r,i,n){St(uo,t,Ye.INBOX_RECEIPT,i,"inbox management receipt",t.relayBinding,n),Tt(t,o,r),It(t.topicCommitment,ce(o.physicalTopic),"inbox topicCommitment");let s=e===dr.CREATED?0n:BigInt(o.expectedRevision)+1n;(t.result!==e||BigInt(t.stateRevision)!==s||t.leaseClass!==o.leaseClass)&&c("RELAY_PROTOCOL_VIOLATION","inbox receipt result does not match operation")}}}function xd(){return{encoding:Gn,verify(e,t,o,r,i){St(Gn,e,Ye.INBOX_READ_RESULT,r,"inbox read result",e.relayBinding,i),Tt(e,t,o)}}}function Td(e,t){for(let o of["corePublicKey","signedHeadHash"])It(e[o],t[o],`core result ${o}`);(BigInt(e.fork)!==BigInt(t.fork)||BigInt(e.length)!==BigInt(t.length))&&c("RELAY_PROTOCOL_VIOLATION","core result head does not match request")}function gu(e){return{encoding:er,verify(t,o,r,i,n){St(er,t,Ye.CORE_ACK,i,"core acknowledgement",t.relayBinding,n),Tt(t,o,r),Td(t,o),t.result!==e&&c("RELAY_PROTOCOL_VIOLATION","core acknowledgement result does not match operation")}}}var ss=class{constructor(t,o){if(t!==Rd)throw new TypeError("VerifiedOperationResult is not directly constructible");ho.set(this,o),Object.freeze(this)}get familyId(){return ho.get(this).context.familyId}get operationId(){return ho.get(this).context.operationId}snapshotBytes(){return _t.default.from(ho.get(this).bytes)}};async function h0(e){(!e||typeof e!="object")&&c("BAD_CLIENT_INPUT","verified CELL.GET result options are required");let t=ho.get(e.verifiedResult);t||c("BAD_CLIENT_INPUT","a package-owned VerifiedOperationResult is required"),(t.context.familyId!==b.CELL||t.context.operationId!==g.CELL.GET)&&c("BAD_CLIENT_INPUT","verifiedResult is not a CELL.GET result"),(!e.readCap||typeof e.readCap!="object")&&c("BAD_CLIENT_INPUT","readCap is required"),e.readCap.version!==1&&c("BAD_CLIENT_INPUT","readCap version must be 1");let o=_t.default.from(m(e.readCap.relayPublicKey,"readCap relayPublicKey",32)),r=_t.default.from(m(e.readCap.storageSlot,"readCap storageSlot",32)),i=_t.default.from(m(e.readCap.cellKey,"readCap cellKey",32));try{let n=e.readCap.sizeClass;(!Number.isInteger(n)||Et[n]==null)&&c("BAD_CLIENT_INPUT","readCap sizeClass is outside the frozen cell classes");let s=Et[n],a=_t.default.from(m(e.readCap.expectedCellBlobHash,"readCap expectedCellBlobHash",32));H(o,t.context.relayPublicKey)||c("BAD_CLIENT_INPUT","readCap relayPublicKey does not match the verified CELL.GET endpoint"),H(r,t.getStorageSlot)||c("BAD_CLIENT_INPUT","readCap storageSlot does not match the verified CELL.GET request"),t.value.sizeClass!==n&&c("RELAY_PROTOCOL_VIOLATION","CELL.GET result sizeClass does not match the read capability");let d=_t.default.from(m(t.value.cellBlob,"CELL.GET result cellBlob",s));return await Cd({runtime:e.runtime,storageSlot:r,cellKey:i,sizeClass:n,expectedCellBlobHash:a,cellBlob:d})}finally{i.fill(0)}}function as(e){(!e||typeof e!="object")&&c("BAD_CLIENT_INPUT","operation result verification options are required");let t=Rt(e.endpoint),o=ns.get(G(t.familyId,t.operationId));o||c("BAD_CLIENT_INPUT","qualified endpoint has no closed result verifier");let r=_t.default.from(m(e.requestCommitment,"requestCommitment",32)),i=t.familyId===b.CELL&&t.operationId===g.CELL.GET,n=null,s;try{i&&(n=_t.default.from(m(e.request.storageSlot,"CELL.GET request storageSlot",32))),s=bu(t,e.request,n)}catch(d){if(d&&d.code==="BAD_CLIENT_INPUT")throw d;c("BAD_CLIENT_INPUT","request cannot reproduce its frozen commitment",{cause:d})}H(r,s)||c("BAD_CLIENT_INPUT","requestCommitment does not match the canonical attempted request");let a=Yr(o.encoding,e.resultBytes,"operation result");return o.verify(a.value,e.request,r,t,{...e,requestCommitment:r}),new ss(Rd,{bytes:a.bytes,value:a.value,context:t,getStorageSlot:n})}var m0=Object.freeze({expectedOperationCount:14,implementedOperationCount:ns.size,reservedOperationCount:5,completeForAdvertisedOrdinary:ns.size===14});function or(e,t){try{return $s(e,t)}catch{c("BAD_CLIENT_INPUT","operation is unknown or reserved by the active release profile")}}function Pe(e,t){return`${e}:${t}`}var Bu=new Map([[Pe(b.DESCRIBE,g.DESCRIBE.GET),pi],[Pe(b.DESCRIBE,g.DESCRIBE.CHALLENGE),yo],[Pe(b.DESCRIBE,g.DESCRIBE.ADMISSION_PARAMETERS),yi],[Pe(b.CELL,g.CELL.PUT),Ai],[Pe(b.CELL,g.CELL.GET),ui],[Pe(b.CELL,g.CELL.RENEW),Mn],[Pe(b.CELL,g.CELL.DROP),qn],[Pe(b.CELL,g.CELL.PROVE),Hn],[Pe(b.CELL,g.CELL.BATCH_GET),Vn],[Pe(b.INBOX,g.INBOX.CREATE),Wc],[Pe(b.INBOX,g.INBOX.RENEW),Yn],[Pe(b.INBOX,g.INBOX.CLOSE),Yn],[Pe(b.INBOX,g.INBOX.APPEND),jc],[Pe(b.INBOX,g.INBOX.READ),zc],[Pe(b.INBOX,g.INBOX.WATCH),Xc],[Pe(b.CORE,g.CORE.MIRROR),Wn],[Pe(b.CORE,g.CORE.PROVE),jn]]);function xu(e,t){let o=Pe(e,t),r=Bu.get(o);return r||c("BAD_CLIENT_INPUT","intent operation has no closed request codec"),r}function Dd(e,t){return e.byteLength===t.byteLength&&Si.default.equals(e,t)}function Ru(e,t){for(let o of["continuityRoot","storeId","descriptorHash"])Dd(e[o],t[o])||c("INTENT_DESTINATION_DRIFT",`${o} changed after intent journaling`);for(let o of["descriptorSequence","endpointId","transportId","transportSupportBit","privacyProfileBit","familyId","operationId"])BigInt(e[o])!==BigInt(t[o])&&c("INTENT_DESTINATION_DRIFT",`${o} changed after intent journaling`)}function Su(e){try{return jt(xu(e.familyId,e.operationId),e.operationBytes,{copyBytes:!0})}catch(t){c("INTENT_CORRUPT","journaled operation bytes are not canonical for their frozen operation",{cause:t})}}async function gr(e,t,o,r={}){return e.update(t,i=>({...i,...r,state:o}))}function _d(e){if(e!=null&&(typeof e=="object"||typeof e=="function"))try{if(e.intentState=L.PENDING_UNKNOWN,e.intentState===L.PENDING_UNKNOWN)return e}catch{}let t=new Error(e instanceof Error?e.message:"durable attempt outcome is unknown",{cause:e});return e&&typeof e.name=="string"&&(t.name=e.name),e&&typeof e.code=="string"&&(t.code=e.code),t.intentState=L.PENDING_UNKNOWN,t}var Nd=class{constructor(t){(!t||!t.store||!t.transport||typeof t.transport.request!="function")&&c("BAD_CLIENT_INPUT","DurableAttempt requires an encrypted intent store and transport"),this.store=t.store,this.transport=t.transport}async execute(t){(!t||!t.intentId||!t.endpoint)&&c("BAD_CLIENT_INPUT","attempt intentId and VerifiedEndpoint are required");let o=Si.default.from(m(t.intentId,"intentId",32)),r=Rt(t.endpoint),i=await this.store.read(o);i==null&&c("INTENT_NOT_FOUND","intent does not exist");let n=or(i.value.familyId,i.value.operationId);Ru(i.value,r);let s=Su(i.value);if(Dd(m(s.clientNonce,"request clientNonce",32),i.value.clientNonce)||c("INTENT_CORRUPT","journaled client nonce does not match operation bytes"),i.value.state===L.RESULT_VERIFIED){let I=as({...t,endpoint:t.endpoint,request:s,requestCommitment:i.value.requestCommitment,resultBytes:i.value.resultBytes});return Object.freeze({intent:i.value,verifiedResult:I,replayed:!0})}i.value.state===L.TERMINAL&&c("INTENT_TERMINAL","terminal intent cannot be attempted"),(i.value.state===L.SENT||i.value.state===L.ACKNOWLEDGED)&&(i=await gr(this.store,o,L.PENDING_UNKNOWN,{mayHaveCommitted:!0})),(i.value.state===L.JOURNALED||i.value.state===L.RETRYABLE||i.value.state===L.PENDING_UNKNOWN)&&(i=await gr(this.store,o,L.TARGET_PREPARED)),i.value.state!==L.TARGET_PREPARED&&c("INTENT_TRANSITION_INVALID","intent is not sendable from its persisted state"),i=await gr(this.store,o,L.SENT,{mayHaveCommitted:!0,attemptCount:i.value.attemptCount+1,lastErrorCode:0});let a;try{a=await this.transport.request({endpoint:t.endpoint,familyId:i.value.familyId,operationId:i.value.operationId,expectedResultBodyBytes:n.maxResultBodyBytes,body:Si.default.from(i.value.operationBytes),signal:t.signal,timeoutMillis:t.timeoutMillis})}catch(I){throw await gr(this.store,o,L.PENDING_UNKNOWN,{mayHaveCommitted:!0}),_d(I)}if(!a||a.ok!==!0){let I=a&&a.error,_=I&&I.retryable===1?L.RETRYABLE:L.TERMINAL,K=await gr(this.store,o,_,{mayHaveCommitted:!0,lastErrorCode:I&&Number.isSafeInteger(I.code)?I.code:0});return Object.freeze({intent:K.value,remoteError:I||null,verifiedResult:null,replayed:!1})}let d;try{d=as({...t,endpoint:t.endpoint,request:s,requestCommitment:i.value.requestCommitment,resultBytes:a.body})}catch(I){throw await gr(this.store,o,L.PENDING_UNKNOWN,{mayHaveCommitted:!0}),_d(I)}let f=await gr(this.store,o,L.RESULT_VERIFIED,{mayHaveCommitted:!0,resultBytes:d.snapshotBytes(),lastErrorCode:0});return Object.freeze({intent:f.value,verifiedResult:d,replayed:!1})}};var bo=Z(ae(),1);var $=Z(ae(),1);var Ht=Z(ae(),1);var et=Z(ae(),1);var Tu=(1n<<64n)-1n,cs=ee.PREFIX_BYTES+ee.HEADER_BYTES;function Ti(e,t){return(!e||typeof e.byteLength!="number")&&y("BAD_ENCODING",`${t} must be bytes`),et.default.isBuffer(e)?e:ArrayBuffer.isView(e)?et.default.from(e.buffer,e.byteOffset,e.byteLength):et.default.from(e)}function Od(e,t){return typeof e=="number"&&((!Number.isSafeInteger(e)||e<0)&&y("BAD_ENCODING",`${t} must be an unsigned safe integer or bigint`),e=BigInt(e)),(typeof e!="bigint"||e<0n||e>Tu)&&y("BAD_ENCODING",`${t} is outside u64`),e}function Ld(e,t){let o=0n;for(let r=0;r<8;r++)o=o<<8n|BigInt(e[t+r]);return o}function Pd(e,t,o){for(let r=7;r>=0;r--)e[o+r]=Number(t&0xffn),t>>=8n}function _u(e){for(let t=0;t<e.byteLength;t++)if(e[t]!==0)return!1;return!0}function Nu(e,t){(!Number.isInteger(e)||e<1||e>255)&&y("BAD_ENCODING","familyId must be a nonzero u8"),(!Number.isInteger(t)||t<1||t>255)&&y("BAD_ENCODING","operationId must be a nonzero u8"),Ir(e,t)||y("BAD_ENCODING","unknown family/operation pair")}function Du(e,t){return e===b.FORWARD&&t===g.FORWARD.OPEN||e===b.CORE&&t===g.CORE.OPEN_REPLICATION}function wd(e,t){return e!==b.FORWARD?!1:t===g.FORWARD.DATA||t===g.FORWARD.WINDOW||t===g.FORWARD.CLOSE}function Kd(e){e.version!==1&&y("BAD_VERSION","dispatch version must be 1"),Object.values(Oe).includes(e.frameKind)||y("BAD_ENCODING","unknown frame kind"),Nu(e.familyId,e.operationId);let t=Lt(e.familyId,e.operationId);if(t){let s=1<<e.frameKind-1;((e.frameKind===Oe.REQUEST?t.allowedRequestKindBits:e.frameKind===Oe.STREAM?t.allowedRequestKindBits|t.allowedResultKindBits:t.allowedResultKindBits)&s)===0&&y("BAD_ENCODING","frame kind is not allowed for the operation")}e.flags!==0&&y("BAD_ENCODING","dispatch flags are reserved");let o=Ti(e.requestId,"requestId");o.byteLength!==ee.REQUEST_ID_BYTES&&y("BAD_ENCODING","requestId must be exactly 16 bytes");let r=_u(o),i=Od(e.streamId,"streamId"),n=Od(e.sequence,"sequence");if(e.frameKind===Oe.REQUEST)(r||i!==0n||n!==0n)&&y("BAD_ENCODING","request frame correlation fields are invalid");else if(e.frameKind===Oe.RESPONSE){(r||n!==0n)&&y("BAD_ENCODING","response frame correlation fields are invalid");let s=Du(e.familyId,e.operationId);(s&&i===0n||!s&&i!==0n)&&y("BAD_ENCODING","response streamId does not match the operation")}else if(e.frameKind===Oe.ERROR){let s=!r&&i===0n&&n===0n,a=r&&i!==0n&&wd(e.familyId,e.operationId);!s&&!a&&y("BAD_ENCODING","error correlation fields are invalid")}else(!r||i===0n||!wd(e.familyId,e.operationId))&&y("BAD_ENCODING","stream frame correlation fields are invalid");return{requestId:o,streamId:i,sequence:n}}function Ud(e,t,o,r){let i=Lt(t,o);if(!i)return;let n=e===Oe.REQUEST?i.maxRequestBodyBytes:e===Oe.STREAM?Math.max(i.maxRequestBodyBytes,i.maxResultBodyBytes):i.maxResultBodyBytes;r>n&&y("TOO_LARGE","dispatch body exceeds the operation cap")}function Ou(e){e=Ti(e,"dispatch length prefix"),e.byteLength<ee.PREFIX_BYTES&&y("BAD_ENCODING","truncated dispatch length prefix");let t=et.default.readUInt32BE(e,0);return t<ee.HEADER_BYTES&&y("BAD_ENCODING","declared dispatch frame is shorter than its header"),t>ee.MAX_FRAME_AFTER_PREFIX_BYTES&&y("TOO_LARGE","declared dispatch frame exceeds the absolute cap"),t}function Qd(e){(!e||typeof e!="object")&&y("BAD_ENCODING","dispatch frame must be an object");let t=e.body==null?et.default.alloc(0):Ti(e.body,"body");t.byteLength>ee.MAX_BODY_BYTES&&y("TOO_LARGE","dispatch body exceeds the absolute cap");let o={version:e.version==null?1:e.version,frameKind:e.frameKind,familyId:e.familyId,operationId:e.operationId,flags:e.flags==null?0:e.flags,requestId:e.requestId,streamId:e.streamId==null?0n:e.streamId,sequence:e.sequence==null?0n:e.sequence},r=Kd(o);Ud(o.frameKind,o.familyId,o.operationId,t.byteLength);let i=ee.HEADER_BYTES+t.byteLength;i>ee.MAX_FRAME_AFTER_PREFIX_BYTES&&y("TOO_LARGE","dispatch frame exceeds the absolute cap");let n=et.default.alloc(ee.PREFIX_BYTES+i);return et.default.writeUInt32BE(n,i,0),n[4]=o.version,n[5]=o.frameKind,n[6]=o.familyId,n[7]=o.operationId,n[8]=o.flags,et.default.copy(r.requestId,n,9),Pd(n,r.streamId,25),Pd(n,r.sequence,33),et.default.writeUInt32BE(n,t.byteLength,41),t.byteLength>0&&et.default.copy(t,n,cs),n}function ds(e,t={}){e=Ti(e,"dispatch frame"),e.byteLength<ee.PREFIX_BYTES&&y("BAD_ENCODING","truncated dispatch frame");let o=Ou(e);e.byteLength!==ee.PREFIX_BYTES+o&&y("BAD_ENCODING","dispatch frame length mismatch or trailing bytes");let r=et.default.readUInt32BE(e,41);r>ee.MAX_BODY_BYTES&&y("TOO_LARGE","dispatch body exceeds the absolute cap"),o!==ee.HEADER_BYTES+r&&y("BAD_ENCODING","dispatch body length mismatch");let i={version:e[4],frameKind:e[5],familyId:e[6],operationId:e[7],flags:e[8],requestId:et.default.from(e.subarray(9,25)),streamId:Ld(e,25),sequence:Ld(e,33)};return Kd(i),Ud(i.frameKind,i.familyId,i.operationId,r),i.body=t.copyBody===!0?et.default.from(e.subarray(cs)):e.subarray(cs),i}var ir=6;function Md(e,t){return(!e||typeof e.byteLength!="number")&&y("BAD_ENCODING",`${t} must be bytes`),Ht.default.isBuffer(e)?e:ArrayBuffer.isView(e)?Ht.default.from(e.buffer,e.byteOffset,e.byteLength):Ht.default.from(e)}function Lu(e){e.byteLength>0&&ti.randombytes_buf(e)}function mo(e){(!Number.isSafeInteger(e)||e<0)&&y("BAD_ENCODING","innerLength must be a non-negative safe integer");let t=ir+e;for(let[o,r]of Object.entries(Wt))if(t<=r)return Number(o);y("TOO_LARGE","dispatch does not fit an outer class")}function qd(e,t={}){(!e||typeof e!="object")&&y("BAD_ENCODING","outer envelope must be an object");let o=Md(e.innerDispatch,"innerDispatch");o.byteLength<ee.PREFIX_BYTES+ee.HEADER_BYTES&&y("BAD_ENCODING","inner dispatch is truncated"),ds(o);let r=e.outerClass==null?mo(o.byteLength):e.outerClass,i=Wt[r];i||y("BAD_ENCODING","unknown outer class"),ir+o.byteLength>i&&y("TOO_LARGE","dispatch does not fit the selected outer class");let n=Ht.default.alloc(i);n[0]=1,n[1]=r,Ht.default.writeUInt32BE(n,o.byteLength,2),Ht.default.copy(o,n,ir);let s=n.subarray(ir+o.byteLength),a=t.randomFill||Lu;return typeof a!="function"&&y("BAD_ENCODING","randomFill must be a function"),a(s),n}function Hd(e,t={}){e=Md(e,"outer envelope"),e.byteLength<ir&&y("BAD_ENCODING","outer envelope is truncated"),e[0]!==1&&y("BAD_VERSION","outer envelope version must be 1");let o=e[1],r=Wt[o];r||y("BAD_ENCODING","unknown outer class"),e.byteLength!==r&&y("BAD_ENCODING","outer envelope does not exactly match its class");let i=Ht.default.readUInt32BE(e,2);i<ee.PREFIX_BYTES+ee.HEADER_BYTES&&y("BAD_ENCODING","inner dispatch is truncated"),ir+i>r&&y("BAD_ENCODING","inner dispatch exceeds the outer class");let n=e.subarray(ir,ir+i),s=t.copyInner===!0?Ht.default.from(n):n,a=ds(s,{copyBody:t.copyBody===!0});return{version:1,outerClass:o,innerDispatch:s,frame:a}}var kd=Symbol("VerifiedDescriptor"),ls=Symbol("TrustedDescriptor"),vd=Symbol("VerifiedHealth"),Wd=Symbol("VerifiedAdmissionParameters"),Pu=4096,us=600*1e3,Br=new WeakMap,kr=new WeakMap,Co=new WeakMap,fs=new WeakMap;function Vd(e){return $.default.toString(e,"hex")}function Eo(e,t){return(!Number.isSafeInteger(e)||e<0||e>4294967295)&&c("BAD_CLIENT_INPUT",`${t} is outside u32`),e}function jd(e,t){return e==null&&(e=globalThis.performance&&typeof globalThis.performance.now=="function"?globalThis.performance.now():Date.now()),(typeof e!="number"||!Number.isFinite(e)||e<0)&&c("BAD_CLIENT_INPUT",`${t} must be a non-negative finite monotonic timestamp`),e}function zd(e,t){return(!Number.isSafeInteger(e)||e<=0||e>65535||(e&e-1)!==0)&&c("BAD_CLIENT_INPUT",`${t} must contain exactly one known support bit`),e}function Xd(e){let t=zd(e,"transportSupportBit");return _i(rt,t,"transportSupportBit"),t}function Fd(e,t,o,r,i){(!Array.isArray(e)||e.length===0)&&c("BAD_CLIENT_INPUT",`${r} cannot be empty`);let n=new Map;for(let s of e){(!s||!Number.isSafeInteger(s[t])||s[t]<1||s[t]>255)&&c("BAD_CLIENT_INPUT",`${r} has an invalid ID`),i(s);let a=$.default.from(m(s[o],`${r} hash`,32));n.has(s[t])&&c("BAD_CLIENT_INPUT",`${r} contains a duplicate ID`),n.set(s[t],Object.freeze({...s,[o]:a}))}return n}function Yd(e,t){return(!Number.isSafeInteger(e)||e<0||e>65535)&&c("BAD_CLIENT_INPUT",`${t} is outside u16`),e}function _i(e,t,o){Object.values(e).includes(t)||c("BAD_CLIENT_INPUT",`${o} is not in the closed registry`)}function wu(e){return $.default.concat([$.default.from([1,e.profileId]),e.externalJournalId,e.externalWitnessPublicKey,$.default.from([e.externalJournalReplicationClass]),e.externalJournalFailureGroupId,e.restoreEvidenceFeedId])}function Ku(e){let t=Se(kn,e.durability);H(hc(t),e.durabilityProfileHash)||c("RELAY_PROTOCOL_VIOLATION","descriptor durability profile hash is invalid");let o=wu(e.durability);H(mc(o),e.durabilityContinuityHash)||c("RELAY_PROTOCOL_VIOLATION","descriptor durability continuity hash is invalid")}function Uu(e,t,o){t=Eo(t,"nowEpoch"),(t<e.issuedEpoch||t>=e.expiresEpoch)&&c("RELAY_PROTOCOL_VIOLATION",`${o} is outside its signed epoch window`)}var Ni=class{constructor(t,o){if(t!==kd)throw new TypeError("VerifiedDescriptor is not directly constructible");Br.set(this,o),Object.freeze(this)}get descriptorHash(){return $.default.from(Br.get(this).hash)}get descriptorSequence(){return Br.get(this).value.descriptorSequence}get relayPublicKey(){return $.default.from(Br.get(this).value.relayPublicKey)}get storeId(){return $.default.from(Br.get(this).value.storeId)}snapshotBytes(){return $.default.from(Br.get(this).bytes)}};function Vt(e){let t=Br.get(e);return t||c("BAD_CLIENT_INPUT","a VerifiedDescriptor is required"),t}function $d(e,t={}){let o=Yr(bi,e,"service descriptor"),r=o.value;(r.enabledOperationBits&~Wi)!==0&&c("RELAY_PROTOCOL_VIOLATION","service descriptor enables an operation reserved by the active release profile");let i=pc(o.bytes);t.expectedDescriptorHash!=null&&!H(i,m(t.expectedDescriptorHash,"expectedDescriptorHash",32))&&c("RELAY_PROTOCOL_VIOLATION","service descriptor hash does not match the requested history object"),Ku(r),Gr(bi,r,Ye.DESCRIPTOR,r.relayPublicKey,"service descriptor"),t.history!==!0&&Uu(r,t.nowEpoch,"service descriptor");let n=Fd(t.supportedProtocolProfiles,"protocolId","profileHash","supported protocol profiles",d=>{_i(b,d.protocolId,"supported protocol ID"),Yd(d.major,"supported protocol major"),Yd(d.minimumMinor,"supported protocol minimumMinor")}),s=Fd(t.supportedTransportProfiles,"transportId","transportProfileHash","supported transport profiles",d=>{_i(Tr,d.transportId,"supported transport ID"),_i(rt,d.transportSupportBit,"supported transport support bit")}),a=new Map(r.protocols.map(d=>[d.protocolId,d]));for(let[d,f]of n){let I=a.get(d);I&&(I.major!==f.major||I.minor<f.minimumMinor||!H(I.profileHash,f.profileHash))&&c("RELAY_PROTOCOL_VIOLATION",`descriptor protocol ${d} contradicts the pinned profile`)}return new Ni(kd,{bytes:$.default.from(o.bytes),value:r,hash:i,supportedProtocols:n,supportedTransports:s})}function Qu(e,t,o){let r=Se(Ci,e),i=r.subarray(0,r.byteLength-128),n=si(To.IDENTITY_TRANSITION,i);os(t.relayPublicKey,n,e.oldSignature,"old identity transition"),os(e.newRelayKey,n,e.newSignature,"new identity transition"),(!H(e.oldRelayKey,t.relayPublicKey)||BigInt(e.oldIdentitySequence)!==BigInt(t.identitySequence)||BigInt(e.newIdentitySequence)!==BigInt(t.identitySequence)+1n||e.validFromEpoch!==o.issuedEpoch)&&c("DESCRIPTOR_CHAIN_INVALID","identity transition does not continue the trusted identity")}function Gd(e){return e==null?null:{rootRelayPublicKey:$.default.from(e.rootRelayPublicKey),storeId:$.default.from(e.storeId),currentBytes:$.default.from(e.currentBytes),currentHash:$.default.from(e.currentHash),sequence:BigInt(e.sequence),identitySequence:BigInt(e.identitySequence),relayPublicKey:$.default.from(e.relayPublicKey),durabilityProfileId:e.durabilityProfileId,durabilityContinuityHash:$.default.from(e.durabilityContinuityHash),history:e.history.map(t=>$.default.from(t)),quarantined:e.quarantined===!0}}var Is=class{constructor(){this.records=new Map}async read(t){let o=this.records.get(t);return o==null?{version:0,value:null}:{version:o.version,value:Gd(o.value)}}async compareAndSwap(t,o,r){let i=this.records.get(t),n=i==null?0:i.version;return n!==o?!1:(this.records.set(t,{version:n+1,value:Gd(r)}),!0)}},Ft=class{constructor(t,o,r,i){if(t!==ls)throw new TypeError("TrustedDescriptor is not directly constructible");kr.set(this,{verified:o,rootRelayPublicKey:$.default.from(r),trustVersion:i}),Object.freeze(this)}get descriptorHash(){return $.default.from(Vt(kr.get(this).verified).hash)}get descriptorSequence(){return Vt(kr.get(this).verified).value.descriptorSequence}get rootRelayPublicKey(){return $.default.from(kr.get(this).rootRelayPublicKey)}get trustVersion(){return kr.get(this).trustVersion}};function X0(e){let t=vr(e),o=Vt(t.verified).value;return Object.freeze({issuedEpoch:o.issuedEpoch,expiresEpoch:o.expiresEpoch})}function Mu(e){return Object.freeze({profileId:e.profileId,schemeId:e.schemeId,conformanceClass:e.conformanceClass,roleBits:e.roleBits,parameterUrl:e.parameterUrl==null?null:$.default.from(e.parameterUrl),parameterHash:$.default.from(e.parameterHash)})}function $0(e,t){e instanceof Ft||c("BAD_CLIENT_INPUT","a TrustedDescriptor is required"),(!Number.isSafeInteger(t)||t<1||t>65535)&&c("BAD_CLIENT_INPUT","admission profileId is outside u16");let o=vr(e),i=Vt(o.verified).value.admissionProfiles.find(n=>n.profileId===t);return i==null?null:Mu(i)}function vr(e){let t=kr.get(e);return t||c("BAD_CLIENT_INPUT","a TrustedDescriptor is required"),t}var Di=class{constructor(t=new Is){(!t||typeof t.read!="function"||typeof t.compareAndSwap!="function")&&c("BAD_CLIENT_INPUT","descriptor trust backend must implement read and compareAndSwap"),this.backend=t}async accept(t,o={}){t instanceof Ni||c("BAD_CLIENT_INPUT","a VerifiedDescriptor is required");let r=Vt(t),i=r.value,n=BigInt(i.descriptorSequence),s;n===0n?(s=$.default.from(i.relayPublicKey),o.continuityRootRelayPublicKey!=null&&!H(s,m(o.continuityRootRelayPublicKey,"continuityRootRelayPublicKey",32))&&c("UNTRUSTED_RELAY_IDENTITY","genesis continuity root does not match its relay key")):(o.continuityRootRelayPublicKey==null&&c("UNTRUSTED_RELAY_IDENTITY","descriptor continuation requires its persisted continuity root"),s=$.default.from(m(o.continuityRootRelayPublicKey,"continuityRootRelayPublicKey",32)));let a=`descriptor:${Vd(s)}:${Vd(i.storeId)}`;for(let d=0;d<8;d++){let f=await this.backend.read(a),I=f.value,E;if(I==null)(n!==0n||o.pinnedDescriptorHash==null||!H(r.hash,m(o.pinnedDescriptorHash,"pinnedDescriptorHash",32)))&&c("UNTRUSTED_RELAY_IDENTITY","descriptor genesis requires an exact authenticated pin"),E={rootRelayPublicKey:s,storeId:i.storeId,currentBytes:r.bytes,currentHash:r.hash,sequence:0n,identitySequence:BigInt(i.identitySequence),relayPublicKey:i.relayPublicKey,durabilityProfileId:i.durability.profileId,durabilityContinuityHash:i.durabilityContinuityHash,history:[r.bytes],quarantined:!1};else{I.quarantined&&c("DESCRIPTOR_FORK","relay continuity is quarantined"),H(I.rootRelayPublicKey,s)||c("DESCRIPTOR_CHAIN_INVALID","descriptor continuation changed its persisted continuity root");let _=BigInt(i.descriptorSequence);if(_===I.sequence){if(H(r.hash,I.currentHash))return new Ft(ls,t,I.rootRelayPublicKey,f.version);E={...I,quarantined:!0},await this.backend.compareAndSwap(a,f.version,E)&&c("DESCRIPTOR_FORK","same-sequence descriptor fork detected and quarantined");continue}(_!==I.sequence+1n||!H(i.previousDescriptorHash,I.currentHash))&&c("DESCRIPTOR_CHAIN_INVALID","descriptor does not exactly extend the trusted sequence/hash"),(i.durability.profileId!==I.durabilityProfileId||!H(i.durabilityContinuityHash,I.durabilityContinuityHash))&&c("DESCRIPTOR_CHAIN_INVALID","descriptor changed the trusted durability continuity"),H(i.relayPublicKey,I.relayPublicKey)?(BigInt(i.identitySequence)!==I.identitySequence||i.previousRelayKey!=null||i.identityTransition!=null)&&c("DESCRIPTOR_CHAIN_INVALID","same-key descriptor changed identity continuity"):((i.identityTransition==null||!H(i.previousRelayKey,I.relayPublicKey)||BigInt(i.identitySequence)!==I.identitySequence+1n)&&c("DESCRIPTOR_CHAIN_INVALID","relay-key rotation lacks exact dual-signed continuity"),Qu(i.identityTransition,I,i)),I.history.length>=Pu&&c("DESCRIPTOR_HISTORY_LIMIT","descriptor history exceeds 4096 linked objects"),E={...I,currentBytes:r.bytes,currentHash:r.hash,sequence:_,identitySequence:BigInt(i.identitySequence),relayPublicKey:i.relayPublicKey,history:[...I.history,r.bytes]}}if(await this.backend.compareAndSwap(a,f.version,E))return new Ft(ls,t,E.rootRelayPublicKey,f.version+1)}c("TRUST_STORE_BUSY","descriptor trust CAS did not converge")}},Oi=class{constructor(t,o){if(t!==vd)throw new TypeError("VerifiedHealth is not directly constructible");Co.set(this,o),Object.freeze(this)}get readyRoleBits(){return Co.get(this).value.readyRoleBits}get readyOperationBits(){return Co.get(this).value.readyOperationBits}};function J0(e){let t=Co.get(e);return t||c("BAD_CLIENT_INPUT","a VerifiedHealth is required"),Object.freeze({verifiedAtMonotonicMillis:t.verifiedAtMonotonicMillis,expiresAtMonotonicMillis:t.verifiedAtMonotonicMillis+us})}function Jd(e,t,o,r={}){t instanceof Ft||c("BAD_CLIENT_INPUT","a TrustedDescriptor is required");let i=vr(t),n=Vt(i.verified),a=Yr(Ei,e,"health result").value,d=n.value;Gr(Ei,a,Ye.HEALTH_RESULT,d.relayPublicKey,"health result");for(let I of["relayPublicKey","storeId","durabilityContinuityHash","durabilityProfileHash"])H(a[I],d[I])||c("RELAY_PROTOCOL_VIOLATION",`health ${I} does not match descriptor`);(BigInt(a.descriptorSequence)!==BigInt(d.descriptorSequence)||!H(a.descriptorHash,n.hash)||!H(a.clientNonce,o.clientNonce)||a.endpointId!==o.endpointId||a.transportSupportBit!==o.transportSupportBit)&&c("RELAY_PROTOCOL_VIOLATION","health result does not correlate to the descriptor challenge"),((a.readyRoleBits&~o.requestedRoleBits)!==0||(a.readyOperationBits&~o.requestedOperationBits)!==0||(a.readyOperationBits&~d.enabledOperationBits)!==0)&&c("RELAY_PROTOCOL_VIOLATION","health readiness exceeds the challenged or enabled subset");let f=Eo(r.nowEpoch,"nowEpoch");return(a.challengeEpoch>f||f-a.challengeEpoch>1)&&c("RELAY_PROTOCOL_VIOLATION","health result is stale or future-dated"),new Oi(vd,{value:a,descriptorHash:$.default.from(n.hash),descriptorSequence:d.descriptorSequence,relayPublicKey:$.default.from(d.relayPublicKey),storeId:$.default.from(d.storeId),verifiedAtMonotonicMillis:jd(r.observedMonotonicMillis,"observedMonotonicMillis")})}var As=class{constructor(t,o,r){if(t!==Wd)throw new TypeError("VerifiedAdmissionParameters is not directly constructible");fs.set(this,{value:o,hash:r}),Object.freeze(this)}get parameterHash(){return $.default.from(fs.get(this).hash)}};function Z0(e){let t=fs.get(e);return t||c("BAD_CLIENT_INPUT","VerifiedAdmissionParameters are required"),Object.freeze({validFromEpoch:t.value.validFromEpoch,expiresEpoch:t.value.expiresEpoch})}function eh(e,t,o,r={}){t instanceof Ft||c("BAD_CLIENT_INPUT","a TrustedDescriptor is required");let i=vr(t),n=Yr(mi,e,"admission parameters"),s=n.value,a=Vt(i.verified).value,d=yc(n.bytes);Gr(mi,s,Ye.ADMISSION_PARAMETERS,a.relayPublicKey,"admission parameters"),(!o||!Number.isSafeInteger(o.profileId))&&c("BAD_CLIENT_INPUT","requested admission profile is invalid");let f=a.admissionProfiles.find(_=>_.profileId===o.profileId),I=f!=null&&(f.parameterUrl==null&&o.parameterUrl==null||f.parameterUrl!=null&&o.parameterUrl!=null&&H(f.parameterUrl,o.parameterUrl));(!f||s.profileId!==f.profileId||s.schemeId!==f.schemeId||s.conformanceClass!==f.conformanceClass||s.roleBits!==f.roleBits||o.schemeId!==f.schemeId||o.conformanceClass!==f.conformanceClass||o.roleBits!==f.roleBits||!I||!H(o.parameterHash,f.parameterHash)||!H(s.relayPublicKey,a.relayPublicKey)||!H(d,f.parameterHash))&&c("RELAY_PROTOCOL_VIOLATION","admission parameters do not match the signed descriptor profile");let E=Eo(r.nowEpoch,"nowEpoch");return(E<s.validFromEpoch||E>=s.expiresEpoch)&&c("RELAY_PROTOCOL_VIOLATION","admission parameters are outside their signed epoch window"),new As(Wd,s,d)}function Zd(e){let t=e&&e.trustedDescriptor;t instanceof Ft||c("BAD_CLIENT_INPUT","a TrustedDescriptor is required");let o=vr(t),r=Vt(o.verified),i=r.value,n=Eo(e.nowEpoch,"nowEpoch");(n<i.issuedEpoch||n>=i.expiresEpoch||i.storeLifecycleState===kt.RETIRED)&&c("RELAY_NOT_QUALIFIED","descriptor is expired or retired");let s=Lt(e.familyId,e.operationId),a=No(e.familyId,e.operationId);(!s||!Do(e.familyId,e.operationId)||a===0||(i.enabledOperationBits&a)===0)&&c("RELAY_NOT_QUALIFIED","operation is not enabled by the trusted descriptor");let d=i.protocols.find(W=>W.protocolId===e.familyId),f=r.supportedProtocols.get(e.familyId);(!d||!f||d.major!==f.major||d.minor<f.minimumMinor||!H(d.profileHash,f.profileHash))&&c("RELAY_NOT_QUALIFIED","operation family has no pinned compatible protocol profile");let I=i.endpoints.find(W=>W.endpointId===e.endpointId);I||c("RELAY_NOT_QUALIFIED","endpoint is absent from the trusted descriptor");let E=r.supportedTransports.get(I.transportId),_=Xd(e.transportSupportBit);if((!E||!H(I.transportProfileHash,E.transportProfileHash)||E.transportSupportBit!==_||(s.transportSupportBits&_)===0)&&c("RELAY_NOT_QUALIFIED","endpoint transport profile is not pinned for this operation"),(_&(rt.DIRECT_HTTP|rt.OHTTP|rt.TOR_HTTP))!==0){let W=ee.PREFIX_BYTES+ee.HEADER_BYTES,re=mo(Math.max(W+s.maxRequestBodyBytes,W+s.maxResultBodyBytes));(I.envelopeClassBits&1<<re)===0&&c("RELAY_NOT_QUALIFIED","endpoint cannot carry the operation maximum in a signed outer class")}let K=e.requiredRoleBits,j=zd(e.privacyProfileBit,"privacyProfileBit");return(!Number.isSafeInteger(K)||K<=0||(I.roleBits&K)!==K||(I.privacyProfileBits&j)===0)&&c("RELAY_NOT_QUALIFIED","endpoint lacks the requested role or privacy profile"),{trust:o,descriptorState:r,descriptor:i,endpoint:I,bit:a,requiredRoleBits:K,transportSupportBit:_,privacyProfileBit:j}}function el(e,t){let{trust:o,descriptorState:r,descriptor:i,endpoint:n,transportSupportBit:s,privacyProfileBit:a}=t;return od({endpoint:n,descriptorHash:r.hash,descriptorSequence:i.descriptorSequence,relayPublicKey:i.relayPublicKey,storeId:i.storeId,continuityRoot:o.rootRelayPublicKey,familyId:e.familyId,operationId:e.operationId,transportSupportBit:s,privacyProfileBit:a,durabilityProfileId:i.durability.profileId,durabilityContinuityHash:i.durabilityContinuityHash,durabilityProfileHash:i.durabilityProfileHash,restoreEvidenceHeadSequence:i.durability.restoreEvidenceCheckpointSequence,restoreEvidenceHeadHash:i.durability.restoreEvidenceCheckpointHash,externalWitnessPublicKey:i.durability.externalWitnessPublicKey,externalJournalId:i.durability.externalJournalId})}function tl(e){return(!e||e.familyId!==b.DESCRIBE||![g.DESCRIBE.GET,g.DESCRIBE.CHALLENGE,g.DESCRIBE.ADMISSION_PARAMETERS].includes(e.operationId))&&c("BAD_CLIENT_INPUT","control qualification accepts only a DESCRIBE operation"),el(e,Zd(e))}function rl(e){let t=Zd(e),{descriptorState:o,descriptor:r,bit:i,requiredRoleBits:n}=t,s=Eo(e.nowEpoch,"nowEpoch"),a=e.health,d=Co.get(a),f=d&&d.value,I=jd(e.nowMonotonicMillis,"nowMonotonicMillis"),E=d==null?Number.POSITIVE_INFINITY:I-d.verifiedAtMonotonicMillis;return(!(a instanceof Oi)||E<0||E>us||!H(d.descriptorHash,o.hash)||BigInt(d.descriptorSequence)!==BigInt(r.descriptorSequence)||!H(d.relayPublicKey,r.relayPublicKey)||!H(d.storeId,r.storeId)||f.endpointId!==t.endpoint.endpointId||f.transportSupportBit!==t.transportSupportBit||(f.readyRoleBits&n)!==n||(f.readyOperationBits&i)!==i||f.clockState!==Xr.READY||f.integrityState!==$r.VERIFIED||(i&zs)!==0&&f.effectiveEpochFloor>s)&&c("RELAY_NOT_QUALIFIED","fresh health does not prove requested readiness"),el(e,t)}function ps(e,t,o){return t==null?Ve(e,32,o):$.default.from(m(t,o,32))}function ol(e={}){let t={version:1,descriptorHash:e.descriptorHash==null?null:$.default.from(m(e.descriptorHash,"descriptorHash",32)),clientNonce:ps(e.runtime,e.clientNonce,"describe client nonce")};return{request:t,requestBytes:Se(pi,t),wire:Object.freeze({familyId:b.DESCRIBE,operationId:g.DESCRIBE.GET,expectedResultBodyBytes:16384})}}function il(e){let t=e&&e.trustedDescriptor;t instanceof Ft||c("BAD_CLIENT_INPUT","a TrustedDescriptor is required");let o=Vt(vr(t).verified),r=o.value,i=e.endpointId;(!Number.isSafeInteger(i)||i<1||i>255)&&c("BAD_CLIENT_INPUT","endpointId is outside 1..255");let n=Xd(e.transportSupportBit),s=r.endpoints.find(f=>f.endpointId===i),a=s==null?null:o.supportedTransports.get(s.transportId);(!s||!a||!H(s.transportProfileHash,a.transportProfileHash)||a.transportSupportBit!==n)&&c("RELAY_NOT_QUALIFIED","health challenge endpoint transport is not pinned by the trusted descriptor"),(!Number.isSafeInteger(e.requestedRoleBits)||e.requestedRoleBits<=0||(e.requestedRoleBits&~s.roleBits)!==0||!Number.isSafeInteger(e.requestedOperationBits)||e.requestedOperationBits<=0||(e.requestedOperationBits&~Wi)!==0||(e.requestedOperationBits&~r.enabledOperationBits)!==0)&&c("RELAY_NOT_QUALIFIED","health challenge exceeds the endpoint role or descriptor operation set");for(let f=0;f<Zr.length;f++){let I=1<<f;(e.requestedOperationBits&I)!==0&&(Zr[f].transportSupportBits&n)===0&&c("RELAY_NOT_QUALIFIED","health challenge operation is unsupported by the bound endpoint transport")}let d={version:1,descriptorSequence:r.descriptorSequence,descriptorHash:o.hash,endpointId:i,transportSupportBit:n,requestedRoleBits:e.requestedRoleBits,requestedOperationBits:e.requestedOperationBits,clientNonce:ps(e.runtime,e.clientNonce,"health client nonce")};return{request:d,requestBytes:Se(yo,d),wire:Object.freeze({familyId:b.DESCRIBE,operationId:g.DESCRIBE.CHALLENGE,expectedResultBodyBytes:16384})}}function th(e){let t={version:1,profileId:e.profileId,schemeId:e.schemeId,clientNonce:ps(e.runtime,e.clientNonce,"admission client nonce")};return{request:t,requestBytes:Se(yi,t),wire:Object.freeze({familyId:b.DESCRIBE,operationId:g.DESCRIBE.ADMISSION_PARAMETERS,expectedResultBodyBytes:16384})}}var rh=Object.freeze({maximumAgeMillis:us});var Li=Z(ae(),1);function nl(e){for(let t of e)if(t!==0)return!1;return!0}function qu(e,t){if(t!=null){let o=Li.default.from(m(t,"requestId",16));return nl(o)&&c("BAD_CLIENT_INPUT","requestId must be nonzero"),o}for(let o=0;o<8;o++){let r=Ve(e,16,"requestId");if(!nl(r))return r}c("RNG_FAILURE","could not generate a nonzero requestId")}function Hu(e,t){return e.byteLength===t.byteLength&&Li.default.equals(e,t)}function Pi(e){(!e||typeof e!="object")&&c("BAD_CLIENT_INPUT","unary request options are required");let t=or(e.familyId,e.operationId),o=qu(e.runtime,e.requestId),r=m(e.body,"canonical operation body"),i=Qd({frameKind:Oe.REQUEST,familyId:e.familyId,operationId:e.operationId,requestId:o,body:r}),n=e.expectedResultBodyBytes==null?t.maxResultBodyBytes:e.expectedResultBodyBytes;(!Number.isSafeInteger(n)||n<0||n>t.maxResultBodyBytes)&&c("BAD_CLIENT_INPUT","expectedResultBodyBytes exceeds the operation profile");let s=ee.PREFIX_BYTES+ee.HEADER_BYTES+n,a=mo(Math.max(i.byteLength,s));e.outerClass!=null&&e.outerClass<a&&c("BAD_CLIENT_INPUT","selected outerClass cannot carry the expected response");let d=qd({innerDispatch:i,outerClass:e.outerClass==null?a:e.outerClass},{randomFill(f){f.byteLength>0&&Li.default.copy(Ve(e.runtime,f.byteLength,"outer padding"),f)}});return{mediaType:Gt.mediaType,familyId:e.familyId,operationId:e.operationId,requestId:o,outerClass:d[1],expectedResultBodyBytes:n,body:d}}function wi(e,t){(!t||typeof t!="object")&&c("BAD_CLIENT_INPUT","expected unary correlation is required");let o;try{o=Hd(m(e,"unary response"),{copyInner:!0,copyBody:!0})}catch(i){c("RELAY_PROTOCOL_VIOLATION","relay response envelope is invalid",{cause:i})}let r=o.frame;if(t.outerClass!=null&&o.outerClass!==t.outerClass&&c("RELAY_PROTOCOL_VIOLATION","relay changed the selected outer class"),(r.familyId!==t.familyId||r.operationId!==t.operationId||!Hu(r.requestId,m(t.requestId,"expected requestId",16)))&&c("RELAY_PROTOCOL_VIOLATION","relay response correlation does not match the request"),r.frameKind===Oe.ERROR){let i;try{i=jt($c,r.body,{copyBytes:!0})}catch(n){c("RELAY_PROTOCOL_VIOLATION","relay error body is invalid",{cause:n})}return{ok:!1,outerClass:o.outerClass,frame:r,error:i}}return r.frameKind!==Oe.RESPONSE&&c("RELAY_PROTOCOL_VIOLATION","unary relay response is not RESPONSE or ERROR"),(!Number.isSafeInteger(t.expectedResultBodyBytes)||t.expectedResultBodyBytes<0)&&c("BAD_CLIENT_INPUT","expected result body bound is required"),r.body.byteLength>t.expectedResultBodyBytes&&c("RELAY_PROTOCOL_VIOLATION","relay success body exceeds the operation-specific result bound"),{ok:!0,outerClass:o.outerClass,frame:r,body:r.body}}var ys=15e3;function Vu(e,t){let o=bo.default.toString(m(e,"bootstrap canonicalUrl"),"utf8"),r;try{r=new URL(o)}catch(n){c("BAD_CLIENT_INPUT","bootstrap canonicalUrl is invalid",{cause:n})}(r.pathname!==cr[b.DESCRIBE]||r.search||r.hash||r.username||r.password)&&c("TRANSPORT_MISMATCH","bootstrap URL is not the fixed DESCRIBE listener anchor");let i=r.hostname==="127.0.0.1"||r.hostname==="::1"||r.hostname==="[::1]";return r.protocol!=="https:"&&!(t&&i&&r.protocol==="http:")&&c("TRANSPORT_MISMATCH","descriptor bootstrap must use HTTPS"),r.href}function Fu(e){return e==null?ys:((!Number.isSafeInteger(e)||e<1||e>ys)&&c("BAD_CLIENT_INPUT",`timeoutMillis must be within 1..${ys}`),e)}function Yu(e,t){let o=new AbortController,r=()=>o.abort(e&&e.reason);e&&(e.aborted?r():e.addEventListener("abort",r,{once:!0}));let i=setTimeout(()=>o.abort(new Error("descriptor bootstrap deadline elapsed")),t);return{signal:o.signal,close(){clearTimeout(i),e&&e.removeEventListener("abort",r)}}}async function Gu(e,t,o){let r=e.headers&&e.headers.get?e.headers.get("content-length"):null,i=e.headers&&e.headers.get?e.headers.get("content-encoding"):null,n=e.headers&&e.headers.get?e.headers.get("transfer-encoding"):null;(i!=null||n!=null)&&c("RELAY_PROTOCOL_VIOLATION","encoded or transfer-framed bootstrap responses are forbidden"),(r==null||!/^(0|[1-9][0-9]*)$/.test(r)||Number(r)!==t)&&c("RELAY_PROTOCOL_VIOLATION","bootstrap response must declare the exact selected class"),(!e.body||typeof e.body.getReader!="function")&&c("TRANSPORT_UNAVAILABLE","a bounded streaming bootstrap response is required");let s=e.body.getReader(),a=bo.default.alloc(t),d=0,f=()=>Promise.resolve(s.cancel(o.reason)).catch(()=>{});o.aborted?f():o.addEventListener("abort",f,{once:!0});try{for(;;){let{done:I,value:E}=await s.read();if(I)break;let _=m(E,"bootstrap response chunk");d+=_.byteLength,d>t&&c("RELAY_PROTOCOL_VIOLATION","bootstrap response exceeds the selected class"),bo.default.copy(_,a,d-_.byteLength)}}finally{o.removeEventListener("abort",f),d>t&&typeof s.cancel=="function"&&await s.cancel().catch(()=>{}),typeof s.releaseLock=="function"&&s.releaseLock()}return d!==t&&c("RELAY_PROTOCOL_VIOLATION","bootstrap response is shorter than the selected class"),a}var Ki=class{constructor(t={}){this.runtime=t.runtime,this.fetch=t.fetch||globalThis.fetch,typeof this.fetch!="function"&&c("TRANSPORT_UNAVAILABLE","fetch implementation is required"),this.allowInsecureLoopback=t.allowInsecureLoopback===!0}async fetchVerifiedDescriptor(t){(!t||typeof t!="object")&&c("BAD_CLIENT_INPUT","descriptor bootstrap options are required");let o=bo.default.from(m(t.expectedDescriptorHash,"expectedDescriptorHash",32)),r=ol({runtime:this.runtime,descriptorHash:o,clientNonce:t.clientNonce}),i=Pi({runtime:this.runtime,requestId:t.requestId,familyId:b.DESCRIBE,operationId:g.DESCRIBE.GET,expectedResultBodyBytes:r.wire.expectedResultBodyBytes,body:r.requestBytes}),n=Yu(t.signal,Fu(t.timeoutMillis));try{let s=await this.fetch(Vu(t.canonicalUrl,this.allowInsecureLoopback),{method:"POST",headers:[["content-type",Gt.mediaType]],body:i.body,credentials:"omit",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",signal:n.signal});(!s||s.status!==200)&&c("TRANSPORT_FAILURE","descriptor bootstrap returned a non-protocol status"),(s.headers&&s.headers.get?s.headers.get("content-type"):null)!==Gt.mediaType&&c("RELAY_PROTOCOL_VIOLATION","bootstrap response media type is not the blind protocol");let d=await Gu(s,Wt[i.outerClass],n.signal),f=wi(d,i);return f.ok||c("TRANSPORT_FAILURE","descriptor bootstrap returned a canonical relay error"),$d(f.body,{expectedDescriptorHash:o,nowEpoch:t.nowEpoch,history:t.history===!0,supportedProtocolProfiles:t.supportedProtocolProfiles,supportedTransportProfiles:t.supportedTransportProfiles})}catch(s){if(s instanceof Cr)throw s;c("TRANSPORT_FAILURE","descriptor bootstrap failed",{cause:s})}finally{n.close()}}};var Bo=Z(ae(),1);var Ui=Z(ae(),1);function ku(e){let t=id(e);if(t)return t;c("UNVERIFIED_ENDPOINT","ordinary relay operations require an opaque VerifiedEndpoint")}function vu(e,t,o){(!e||typeof e!="object")&&c("BAD_CLIENT_INPUT","signed transport endpoint is required"),(!Number.isInteger(e.endpointId)||e.endpointId<1||e.endpointId>255)&&c("BAD_CLIENT_INPUT","endpointId must be within 1..255"),e.transportId!==Tr.HTTPS_DIRECT&&c("TRANSPORT_MISMATCH","endpoint is not HTTPS_DIRECT");let r=m(e.canonicalUrl,"endpoint canonicalUrl"),i=Ui.default.toString(r,"utf8"),n;try{n=new URL(i)}catch(d){c("BAD_CLIENT_INPUT","endpoint canonicalUrl is invalid",{cause:d})}let s=cr[t];(!s||n.pathname!==cr[b.DESCRIBE]||n.search||n.hash||n.username||n.password)&&c("TRANSPORT_MISMATCH","endpoint URL is not the signed generic listener-authority anchor");let a=n.hostname==="127.0.0.1"||n.hostname==="::1"||n.hostname==="[::1]";return n.protocol!=="https:"&&!(o&&a&&n.protocol==="http:")&&c("TRANSPORT_MISMATCH","direct endpoint must use HTTPS"),n.pathname=s,n.href}function Wu(e,t){(e.qualifiedFamilyId!==t.familyId||e.qualifiedOperationId!==t.operationId||e.transportSupportBit!==rt.DIRECT_HTTP)&&c("TRANSPORT_MISMATCH","VerifiedEndpoint was not qualified for this exact direct operation"),(!Number.isInteger(e.envelopeClassBits)||(e.envelopeClassBits&-127)!==0||(e.envelopeClassBits&1<<t.outerClass)===0)&&c("TRANSPORT_MISMATCH","endpoint did not advertise the selected outer class"),(or(t.familyId,t.operationId).transportSupportBits&rt.DIRECT_HTTP)===0&&c("TRANSPORT_MISMATCH","operation is not available over direct HTTP")}function ju(e,t){let o=e===b.INBOX?35e3:15e3;return t==null?o:((!Number.isSafeInteger(t)||t<1||t>o)&&c("BAD_CLIENT_INPUT",`timeoutMillis must be within 1..${o}`),t)}function zu(e,t){let o=new AbortController,r=()=>o.abort(e&&e.reason);e&&(e.aborted?r():e.addEventListener("abort",r,{once:!0}));let i=setTimeout(()=>o.abort(new Error("blind direct request deadline elapsed")),t);return{signal:o.signal,close(){clearTimeout(i),e&&e.removeEventListener("abort",r)}}}async function Xu(e,t,o){let r=e.headers&&e.headers.get?e.headers.get("content-length"):null,i=e.headers&&e.headers.get?e.headers.get("content-encoding"):null,n=e.headers&&e.headers.get?e.headers.get("transfer-encoding"):null;(i!=null||n!=null)&&c("RELAY_PROTOCOL_VIOLATION","encoded or transfer-framed response bodies are forbidden"),r==null&&c("RELAY_PROTOCOL_VIOLATION","response requires an exact content-length"),r!=null&&!/^(0|[1-9][0-9]*)$/.test(r)&&c("RELAY_PROTOCOL_VIOLATION","response content-length is not canonical"),r!=null&&Number(r)!==t&&c("RELAY_PROTOCOL_VIOLATION","response content-length changed the selected class"),(!e.body||typeof e.body.getReader!="function")&&c("TRANSPORT_UNAVAILABLE","a bounded streaming response is required");let s=e.body.getReader(),a=Ui.default.alloc(t),d=0,f=()=>Promise.resolve(s.cancel(o.reason)).catch(()=>{});o&&(o.aborted?f():o.addEventListener("abort",f,{once:!0}));try{for(;;){let{done:I,value:E}=await s.read();if(I)break;let _=m(E,"direct response chunk");d+=_.byteLength,d>t&&c("RELAY_PROTOCOL_VIOLATION","response exceeds the selected class"),Ui.default.copy(_,a,d-_.byteLength)}}finally{o&&o.removeEventListener("abort",f),d>t&&typeof s.cancel=="function"&&await s.cancel().catch(()=>{}),typeof s.releaseLock=="function"&&s.releaseLock()}return d!==t&&c("RELAY_PROTOCOL_VIOLATION","response is shorter than the selected class"),a}var go=class{constructor(t={}){this.runtime=t.runtime,this.fetch=t.fetch||globalThis.fetch,typeof this.fetch!="function"&&c("TRANSPORT_UNAVAILABLE","fetch implementation is required"),this.allowInsecureLoopback=t.allowInsecureLoopback===!0}async request(t){(!t||typeof t!="object")&&c("BAD_CLIENT_INPUT","direct request options are required");let o=Pi({...t,runtime:this.runtime}),r=ku(t.endpoint);Wu(r,o);let i=vu(r,o.familyId,this.allowInsecureLoopback),n=zu(t.signal,ju(o.familyId,t.timeoutMillis));try{let s=await this.fetch(i,{method:"POST",headers:[["content-type",Gt.mediaType]],body:o.body,credentials:"omit",cache:"no-store",redirect:"error",referrerPolicy:"no-referrer",signal:n.signal});(!s||s.status!==200)&&c("TRANSPORT_FAILURE","blind direct transport returned a non-protocol status"),(s.headers&&s.headers.get?s.headers.get("content-type"):null)!==Gt.mediaType&&c("RELAY_PROTOCOL_VIOLATION","response media type is not the blind protocol");let d=await Xu(s,Wt[o.outerClass],n.signal);return wi(d,o)}catch(s){if(s instanceof Cr)throw s;c("TRANSPORT_FAILURE","blind direct transport failed",{cause:s})}finally{n.close()}}};function $u(e){return(!Number.isSafeInteger(e)||e<0||e>4294967295)&&c("BAD_CLIENT_INPUT","nowEpoch is outside u32"),e}function Ju(e){(!e||typeof e!="object")&&c("BAD_CLIENT_INPUT","qualification requirement is required");let t=No(e.familyId,e.operationId);t===0&&c("BAD_CLIENT_INPUT","qualification operation is not registered");for(let o of["endpointId","requiredRoleBits","privacyProfileBit","transportSupportBit"])(!Number.isSafeInteger(e[o])||e[o]<=0)&&c("BAD_CLIENT_INPUT",`qualification ${o} is invalid`);return{...e,operationBit:t}}function sl(e,t,o){return Object.freeze(e.map((r,i)=>Object.freeze({...r,[t]:Bo.default.from(m(r&&r[t],`${o}[${i}].${t}`,32))})))}function Zu(){return globalThis.performance&&typeof globalThis.performance.now=="function"?globalThis.performance.now():Date.now()}var al=class{constructor(t={}){this.runtime=t.runtime,this.nowEpoch=typeof t.nowEpoch=="function"?t.nowEpoch:null,this.nowEpoch||c("BAD_CLIENT_INPUT","nowEpoch provider is required"),this.monotonicMillis=typeof t.monotonicMillis=="function"?t.monotonicMillis:Zu,(!Array.isArray(t.supportedProtocolProfiles)||!Array.isArray(t.supportedTransportProfiles))&&c("BAD_CLIENT_INPUT","supported protocol and transport profile pins are required"),this.supportedProtocolProfiles=sl(t.supportedProtocolProfiles,"profileHash","supportedProtocolProfiles"),this.supportedTransportProfiles=sl(t.supportedTransportProfiles,"transportProfileHash","supportedTransportProfiles"),this.trustStore=t.trustStore||new Di,this.bootstrapClient=t.bootstrapClient||new Ki({runtime:this.runtime,fetch:t.fetch,allowInsecureLoopback:t.allowInsecureLoopback}),this.directClient=t.directClient||new go({runtime:this.runtime,fetch:t.fetch,allowInsecureLoopback:t.allowInsecureLoopback})}async qualifyCandidate(t,o,r={}){(!t||typeof t!="object")&&c("BAD_CLIENT_INPUT","relay candidate is required");let i=Ju(o),n=$u(this.nowEpoch()),s=Bo.default.from(m(t.expectedDescriptorHash,"candidate expectedDescriptorHash",32)),a=Bo.default.from(m(t.canonicalUrl,"candidate canonicalUrl")),d=t.continuityRootRelayPublicKey==null?null:Bo.default.from(m(t.continuityRootRelayPublicKey,"candidate continuityRootRelayPublicKey",32)),f=await this.bootstrapClient.fetchVerifiedDescriptor({canonicalUrl:a,expectedDescriptorHash:s,nowEpoch:n,supportedProtocolProfiles:this.supportedProtocolProfiles,supportedTransportProfiles:this.supportedTransportProfiles,timeoutMillis:r.timeoutMillis,signal:r.signal}),I=f.descriptorSequence===0n?{pinnedDescriptorHash:s,continuityRootRelayPublicKey:d}:{continuityRootRelayPublicKey:d},E=await this.trustStore.accept(f,I),_=il({runtime:this.runtime,trustedDescriptor:E,endpointId:i.endpointId,transportSupportBit:i.transportSupportBit,requestedRoleBits:i.requiredRoleBits,requestedOperationBits:i.operationBit}),K=tl({trustedDescriptor:E,nowEpoch:n,familyId:b.DESCRIBE,operationId:g.DESCRIBE.CHALLENGE,endpointId:i.endpointId,requiredRoleBits:i.requiredRoleBits,privacyProfileBit:i.privacyProfileBit,transportSupportBit:i.transportSupportBit}),j=await this.directClient.request({endpoint:K,familyId:b.DESCRIBE,operationId:g.DESCRIBE.CHALLENGE,expectedResultBodyBytes:_.wire.expectedResultBodyBytes,body:_.requestBytes,timeoutMillis:r.timeoutMillis,signal:r.signal});j.ok||c("RELAY_NOT_QUALIFIED","relay rejected its signed health challenge");let W=this.monotonicMillis(),re=Jd(j.body,E,_.request,{nowEpoch:n,observedMonotonicMillis:W}),de=rl({trustedDescriptor:E,health:re,nowEpoch:n,nowMonotonicMillis:W,familyId:i.familyId,operationId:i.operationId,endpointId:i.endpointId,requiredRoleBits:i.requiredRoleBits,privacyProfileBit:i.privacyProfileBit,transportSupportBit:i.transportSupportBit});return Object.freeze({endpoint:de,trustedDescriptor:E,verifiedDescriptor:f,health:re,descriptorHash:f.descriptorHash,continuityRootRelayPublicKey:E.rootRelayPublicKey})}};var at=Z(ae(),1);var ll=64,hs=3,ms=2;function Yt(e){return at.default.toString(e,"hex")}function ep(e,t,o){let r=at.default.alloc(32);return qt.crypto_generichash(r,at.default.concat([t,o]),e),r}function tp(e,t){return-at.default.compare(e.score,t.score)||at.default.compare(e.context.continuityRoot,t.context.continuityRoot)}var cl=class{constructor(t){this.selectionKey=at.default.from(m(t&&t.selectionKey,"selectionKey",32)),this.familyId=t.familyId,this.operationId=t.operationId,this.transportSupportBit=t.transportSupportBit,this.privacyProfileBit=t.privacyProfileBit;for(let[o,r]of Object.entries({familyId:this.familyId,operationId:this.operationId,transportSupportBit:this.transportSupportBit,privacyProfileBit:this.privacyProfileBit}))(!Number.isSafeInteger(r)||r<=0)&&c("BAD_CLIENT_INPUT",`candidate pool ${o} is invalid`);this.candidates=new Map,this.breakers=new Map}add(t,o={}){let r=Rt(t);(r.familyId!==this.familyId||r.operationId!==this.operationId||r.transportSupportBit!==this.transportSupportBit||r.privacyProfileBit!==this.privacyProfileBit)&&c("BAD_CLIENT_INPUT","candidate endpoint does not match the pool qualification tuple");let i=Yt(r.continuityRoot),n=this.candidates.get(i);if(n&&n.context.descriptorSequence>r.descriptorSequence)return!1;let s=o.operatorGroupId==null?n?.operatorGroupId||null:at.default.from(m(o.operatorGroupId,"operatorGroupId",32));return n?.operatorGroupId!=null&&s!=null&&!at.default.equals(n.operatorGroupId,s)&&c("BAD_CLIENT_INPUT","candidate operator-group evidence changed for one continuity root"),!n&&this.candidates.size>=ll&&c("CANDIDATE_LIMIT","relay candidate reservoir is full"),this.candidates.set(i,Object.freeze({endpoint:t,context:r,operatorGroupId:s,externallyWitnessed:n?.externallyWitnessed===!0||o.externallyWitnessed===!0})),!0}recordFailure(t,o,r=4){let i=Rt(t);(!Number.isSafeInteger(o)||o<0||!Number.isSafeInteger(r)||r<1)&&c("BAD_CLIENT_INPUT","breaker ticks are invalid");let n=Yt(i.continuityRoot),s=this.breakers.get(n)||{failures:0,openUntil:0},a=Math.min(s.failures+1,16),d=Math.min(r*2**(a-1),1024);this.breakers.set(n,{failures:a,openUntil:o+d})}recordSuccess(t){this.breakers.delete(Yt(Rt(t).continuityRoot))}select(t,o={}){t=at.default.from(m(t,"destinationId",32));let r=o.targetCount==null?hs:o.targetCount,i=o.nowTick==null?0:o.nowTick;(!Number.isSafeInteger(r)||r<1||r>hs||!Number.isSafeInteger(i)||i<0)&&c("BAD_CLIENT_INPUT","selection targetCount/nowTick is invalid");let n=new Set((o.excludeContinuityRoots||[]).map(s=>Yt(m(s,"excluded continuity root",32))));return[...this.candidates.entries()].filter(([s])=>!n.has(s)&&(this.breakers.get(s)?.openUntil||0)<=i).map(([,s])=>({...s,score:ep(this.selectionKey,t,s.context.continuityRoot)})).sort(tp).slice(0,r).map(s=>s.endpoint)}},dl=class{constructor(){this.records=new Map}observe(t,o,r={}){t=Yt(m(t,"logicalId",32));let i=Rt(o),n=Yt(i.continuityRoot),s=this.records.get(t);s||(s={replicas:new Map},this.records.set(t,s));let a=s.replicas.get(n),d=r.operatorGroupId==null?a?.operatorGroupId||null:at.default.from(m(r.operatorGroupId,"operatorGroupId",32));a?.operatorGroupId!=null&&d!=null&&!at.default.equals(a.operatorGroupId,d)&&c("BAD_CLIENT_INPUT","durability operator-group evidence changed for one continuity root");let f=a?.readbackVerified===!0||r.readbackVerified===!0;return s.replicas.set(n,{continuityRoot:at.default.from(i.continuityRoot),acknowledged:a?.acknowledged===!0||r.acknowledged===!0||f,readbackVerified:f,externallyWitnessed:a?.externallyWitnessed===!0||r.externallyWitnessed===!0,operatorGroupId:d}),this.statusByKey(t)}status(t){return this.statusByKey(Yt(m(t,"logicalId",32)))}statusByKey(t){let o=[...this.records.get(t)?.replicas.values()||[]],r=o.filter(a=>a.acknowledged),i=o.filter(a=>a.readbackVerified),n=new Set(i.filter(a=>a.operatorGroupId).map(a=>Yt(a.operatorGroupId))),s=i.filter(a=>a.externallyWitnessed).length;return Object.freeze({remoteStored:r.length>=1,acknowledgedReplicas:r.length,readbackReplicas:i.length,qualifiedIndependentOperators:n.size,externallyWitnessedReplicas:s,label:i.length>=3&&n.size>=2?"resilient-multi-operator":i.length>=2?"replicated":i.length===1?"remote-readback-verified":r.length===1?"remote-stored":"local-queued"})}repairTargets(t,o,r={}){let i=Yt(m(t,"logicalId",32)),n=[...this.records.get(i)?.replicas.values()||[]].map(a=>a.continuityRoot),s=r.count==null?ms:r.count;return(!Number.isSafeInteger(s)||s<0||s>ms)&&c("BAD_CLIENT_INPUT","repair count must be within 0..2"),s===0?[]:o.select(m(t,"logicalId",32),{targetCount:s,nowTick:r.nowTick,excludeContinuityRoots:n})}},Qh=Object.freeze({maxCandidates:ll,defaultTargets:hs,maxRepairsPerRun:ms});var Ro=Z(ae(),1);var xr=Z(ae(),1);var fl=32,Cs=32,Il=64,rp=64;function op(e){e=m(e,"private seed",Cs);let t=xr.default.alloc(fl),o=xr.default.alloc(Il);try{return qt.crypto_sign_seed_keypair(t,o,e),t}finally{Ce(o)}}function ip(e){let t=Ve(e,Cs,"capability private seed");return{publicKey:op(t),privateSeed:t}}function Al(e,t){e=m(e,"private seed",Cs),t=m(t,"signature message");let o=xr.default.alloc(fl),r=xr.default.alloc(Il),i=xr.default.alloc(rp);try{return qt.crypto_sign_seed_keypair(o,r,e),qt.crypto_sign_detached(i,t,r),i}finally{Ce(r)}}function ul(e,t,o=[]){(!Array.isArray(t)||t.length===0||new Set(t).size!==t.length)&&c("BAD_CLIENT_INPUT","capability names must be a nonempty distinct array");let r={},i=o.map((n,s)=>m(n,`forbiddenPublicKeys[${s}]`,32));try{for(let n of t){(typeof n!="string"||n.length===0)&&c("BAD_CLIENT_INPUT","capability name must be nonempty");let s;for(let a=0;a<8&&(s=ip(e),!!i.some(d=>xr.default.equals(d,s.publicKey)));a++)Ce(s.privateSeed),s=null;s||c("RNG_COLLISION","could not generate distinct capability keys"),i.push(s.publicKey),r[n]=s}}catch(n){for(let s of Object.values(r))Ce(s.privateSeed);throw n}return r}function np(e){!e||typeof e!="object"||(Ce(e.createPrivateKey),Ce(e.renewPrivateKey),Ce(e.dropPrivateKey))}function sp(e){!e||typeof e!="object"||Ce(e.cellKey)}function pl(e){!e||typeof e!="object"||(np(e),sp(e.readCap))}var xo=Z(ae(),1);function Es(e){if(e==null||typeof e!="object")return e;if(xo.default.isBuffer(e)||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return xo.default.from(m(e,"provider context bytes"));if(Array.isArray(e))return Object.freeze(e.map(Es));let t={};for(let[o,r]of Object.entries(e))t[o]=Es(r);return Object.freeze(t)}function yl(e){return(!e||typeof e!="object")&&c("BAD_CLIENT_INPUT","admission must be an object"),Object.freeze({profileId:e.profileId,schemeId:e.schemeId,parameterHash:xo.default.from(m(e.parameterHash,"admission parameterHash",32)),token:xo.default.from(m(e.token,"admission token"))})}async function hl(e,t,o,r){if(e.admission!=null)return yl(e.admission);if(typeof e.admissionProvider=="function"){let i=await e.admissionProvider(Es(t));if(i!=null)return yl(i)}return o&&c("ADMISSION_REQUIRED",r),null}function ap(e,t){return(!Number.isSafeInteger(e)||e<0||e>4294967295)&&c("BAD_CLIENT_INPUT",`${t} is outside u32`),e}function ml(e,t){return t==null?Ve(e,32,"client nonce"):Ro.default.from(m(t,"clientNonce",32))}async function Cl(e,t,o){return hl(e,t,o,"this operation requires an admission provider or admission value")}function El(e,t,o,r,i,n=null){let s=or(r,i);return{request:t,requestBytes:Se(e,t),requestCommitment:o,wire:Object.freeze({familyId:r,operationId:i,expectedResultBodyBytes:n??s.maxResultBodyBytes})}}async function cp(e){(!e||typeof e!="object")&&c("BAD_CLIENT_INPUT","cell replica options are required");let t=e.runtime,o=m(e.relayPublicKey,"relayPublicKey",32),r=ap(e.allocationEpoch,"allocationEpoch"),i=e.sizeClass,n=e.leaseClass,s=ul(t,["create","renew","drop"],[o]),a=so({allocationEpoch:r,createPublicKey:s.create.publicKey}),d,f;try{d=await md({runtime:t,storageSlot:a,sizeClass:i,structuredContent:e.structuredContent});let I=ce(d.cellBlob),E=ri({relayPublicKey:o,storageSlot:a,allocationEpoch:r,sizeClass:i,leaseClass:n,declaredCellBlobHash:I,createPublicKey:s.create.publicKey,renewPublicKey:s.renew.publicKey,dropPublicKey:s.drop.publicKey}),_=ml(t,e.clientNonce),K=oi({allocationCommitment:E,clientNonce:_}),j=await Cl(e,{familyId:b.CELL,operationId:g.CELL.PUT,requestCommitment:K,relayPublicKey:o,sizeClass:i,leaseClass:n},!0),W={version:1,storageSlot:a,allocationEpoch:r,sizeClass:i,leaseClass:n,clientNonce:_,createPublicKey:s.create.publicKey,renewPublicKey:s.renew.publicKey,dropPublicKey:s.drop.publicKey,declaredBlobHash:I,createSignature:Al(s.create.privateSeed,E),admission:j,cellBlob:d.cellBlob},re={version:1,relayPublicKey:Ro.default.from(o),storageSlot:Ro.default.from(a),cellKey:d.cellKey,sizeClass:i,expectedCellBlobHash:Ro.default.from(I)};return f={readCap:re,allocationEpoch:r,createPrivateKey:s.create.privateSeed,renewPrivateKey:s.renew.privateSeed,dropPrivateKey:s.drop.privateSeed},{...El(Ai,W,K,b.CELL,g.CELL.PUT),allocationCommitment:E,readCap:re,writeCap:f}}catch(I){throw f?pl(f):(Ce(s.create.privateSeed),Ce(s.renew.privateSeed),Ce(s.drop.privateSeed),d&&Ce(d.cellKey)),I}}async function dp(e,t,o,r){(!e||typeof e!="object"||!e.readCap)&&c("BAD_CLIENT_INPUT","readCap is required");let i=e.runtime,n=m(e.readCap.relayPublicKey,"relayPublicKey",32),s=m(e.readCap.storageSlot,"storageSlot",32),a=ml(i,e.clientNonce),d=o({relayPublicKey:n,storageSlot:s,clientNonce:a}),f=await Cl(e,{familyId:b.CELL,operationId:t,requestCommitment:d,relayPublicKey:n},!1),I={version:1,storageSlot:s,clientNonce:a,admission:f},E=null;if(t===g.CELL.GET){let _=Et[e.readCap.sizeClass];_==null&&c("BAD_CLIENT_INPUT","readCap sizeClass is outside the frozen cell classes"),E=2+_}return El(r,I,d,b.CELL,t,E)}var lp=e=>dp(e,g.CELL.GET,ni,ui);var gs=Z(ae(),1);var Wr=_e(32),bl=pt(h,1,"version");function fp(e){y("BAD_ENCODING",e)}function Qi(e,t){for(let o of e)if(o!==0)return;fp(`${t} must be nonzero`)}var gl=R([["version",bl],["relayPublicKey",Wr],["storageSlot",Wr],["cellKey",Wr],["sizeClass",C(h,1,5,"sizeClass")],["expectedCellBlobHash",z(Wr,"expectedCellBlobHash")]],{name:"ReadCellCapV1",validate(e){for(let t of["relayPublicKey","storageSlot","cellKey"])Qi(e[t],t);e.expectedCellBlobHash!=null&&Qi(e.expectedCellBlobHash,"expectedCellBlobHash")}}),Bl=R([["version",bl],["corePublicKey",Wr],["blockEncryptionKey",Wr],["witnessedFork",S],["witnessedLength",S],["witnessedSignedHead",ke(1,4096,"witnessedSignedHead")]],{name:"BlindCoreReadCapV1",validate(e){Qi(e.corePublicKey,"corePublicKey"),Qi(e.blockEncryptionKey,"blockEncryptionKey")}});var Ip=Object.freeze({codec:er,minimum:1,maximum:16384}),Ap=Object.freeze({codec:Bl,minimum:1,maximum:8192}),up=Object.freeze({codec:mt,minimum:1,maximum:16384}),pp=Object.freeze({codec:po,minimum:1,maximum:16384}),yp=Object.freeze({codec:uo,minimum:1,maximum:16384}),hp=Object.freeze({codec:gl,minimum:99,maximum:131});function jr(e){y("BAD_ENCODING",e)}function mp(e){return typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer}function Cp(e){let t;e instanceof ArrayBuffer?t=new Uint8Array(e):ArrayBuffer.isView(e)?(mp(e.buffer)&&jr("external profile value cannot use shared memory"),t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)):jr("external profile value must be ArrayBuffer-backed bytes");let o=gs.default.alloc(t.byteLength);return o.set(t),o}function Ep(e){switch(e){case"BlindCoreAckV1":return Ip;case"BlindCoreReadCapV1":return Ap;case"BlindReceiptV1":return up;case"InboxAppendAckV1":return pp;case"InboxReceiptV1":return yp;case"ReadCellCapV1":return hp;default:jr("external profile decoder schema name is outside its closed inventory")}}function bs(e){if(e==null||typeof e!="object"||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)return e;if(Array.isArray(e))for(let t of e)bs(t);else for(let t of Object.values(e))bs(t);return Object.freeze(e)}function bp(e,t){(arguments.length!==2||typeof e!="string")&&jr("external profile decoder requires exactly a schema name and bytes");let o=Ep(e),r=Cp(t);(r.byteLength<o.minimum||r.byteLength>o.maximum)&&jr(`${e} length is outside ${o.minimum}..${o.maximum}`);let i=jt(o.codec,r,{copyBytes:!0});return gs.default.equals(Se(o.codec,i),r)||jr(`${e} is not canonically reproducible`),bs(i)}var Mi=Z(ae(),1);function gp(e){let t=e||globalThis.crypto;return(!t||!t.subtle||typeof t.getRandomValues!="function")&&c("CRYPTO_UNAVAILABLE","Web Crypto with AES-GCM is required"),t}function Bp(e){let t=gp(e);return Object.freeze({randomBytes(o){let r=new Uint8Array(o);for(let i=0;i<r.byteLength;i+=65536)t.getRandomValues(r.subarray(i,Math.min(r.byteLength,i+65536)));return Mi.default.from(r.buffer,r.byteOffset,r.byteLength)},async aes256GcmEncrypt({key:o,nonce:r,aad:i,plaintext:n}){o=m(o,"key",32),r=m(r,"nonce",12),i=m(i,"aad"),n=m(n,"plaintext");let s=await t.subtle.importKey("raw",o,"AES-GCM",!1,["encrypt"]),a=await t.subtle.encrypt({name:"AES-GCM",iv:r,additionalData:i,tagLength:128},s,n);return Mi.default.from(a)},async aes256GcmDecrypt({key:o,nonce:r,aad:i,sealed:n}){o=m(o,"key",32),r=m(r,"nonce",12),i=m(i,"aad"),n=m(n,"sealed");let s=await t.subtle.importKey("raw",o,"AES-GCM",!1,["decrypt"]),a=await t.subtle.decrypt({name:"AES-GCM",iv:r,additionalData:i,tagLength:128},s,n);return Mi.default.from(a)}})}export{Ki as BlindDescriptorBootstrapHttpClient,go as BlindDirectHttpClient,al as BlindRelayQualifier,Qh as CLIENT_SELECTION_LIMITS,Di as DescriptorTrustStore,dl as DurabilityTracker,Nd as DurableAttempt,Jn as EncryptedIntentStore,rh as HEALTH_QUALIFICATION_LIMITS,L as INTENT_STATE,Is as MemoryDescriptorTrustBackend,ld as MemoryIntentBackend,m0 as RESULT_VERIFIER_STATUS,cl as RelayCandidatePool,Ft as TrustedDescriptor,As as VerifiedAdmissionParameters,Ni as VerifiedDescriptor,gi as VerifiedEndpoint,Oi as VerifiedHealth,ss as VerifiedOperationResult,th as createAdmissionParametersRequest,vy as createAesGcmIntentSealer,Bp as createBrowserCryptoRuntime,cp as createCellReplica,Wy as createClientIntent,ol as createDescribeGetRequest,lp as createGetCellRequest,il as createHealthChallenge,bp as decodeBlindExternalProfileValueV1,Iu as decodeClientIntent,cd as encodeClientIntent,jy as journalSignedIntent,h0 as openVerifiedCellGetResult,tl as qualifyDescribeControlEndpoint,rl as qualifyRelay,$0 as trustedAdmissionProfile,X0 as trustedDescriptorValidity,Z0 as verifiedAdmissionParametersValidity,Rt as verifiedEndpointContext,J0 as verifiedHealthValidity,eh as verifyAdmissionParametersBytes,$d as verifyDescriptorBytes,Jd as verifyHealthResultBytes,as as verifyOperationResult};