@interncom/diplomatic 0.14.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var pQ=Object.create;var{getPrototypeOf:uQ,defineProperty:BZ,getOwnPropertyNames:dQ}=Object;var nQ=Object.prototype.hasOwnProperty;function cQ($){return this[$]}var rQ,oQ,aQ=($,Z,J)=>{var Q=$!=null&&typeof $==="object";if(Q){var X=Z?rQ??=new WeakMap:oQ??=new WeakMap,Y=X.get($);if(Y)return Y}J=$!=null?pQ(uQ($)):{};let V=Z||!$||!$.__esModule?BZ(J,"default",{value:$,enumerable:!0}):J;for(let W of dQ($))if(!nQ.call(V,W))BZ(V,W,{get:cQ.bind($,W),enumerable:!0});if(Q)X.set($,V);return V};var r=($,Z)=>()=>(Z||$((Z={exports:{}}).exports,Z),Z.exports);var D$=r((hJ)=>{Object.defineProperty(hJ,"__esModule",{value:!0});hJ.utf8Count=uX;hJ.utf8EncodeJs=vJ;hJ.utf8EncodeTE=yJ;hJ.utf8Encode=cX;hJ.utf8DecodeJs=lJ;hJ.utf8DecodeTD=bJ;hJ.utf8Decode=sX;function uX($){let Z=$.length,J=0,Q=0;while(Q<Z){let X=$.charCodeAt(Q++);if((X&4294967168)===0){J++;continue}else if((X&4294965248)===0)J+=2;else{if(X>=55296&&X<=56319){if(Q<Z){let Y=$.charCodeAt(Q);if((Y&64512)===56320)++Q,X=((X&1023)<<10)+(Y&1023)+65536}}if((X&4294901760)===0)J+=3;else J+=4}}return J}function vJ($,Z,J){let Q=$.length,X=J,Y=0;while(Y<Q){let V=$.charCodeAt(Y++);if((V&4294967168)===0){Z[X++]=V;continue}else if((V&4294965248)===0)Z[X++]=V>>6&31|192;else{if(V>=55296&&V<=56319){if(Y<Q){let W=$.charCodeAt(Y);if((W&64512)===56320)++Y,V=((V&1023)<<10)+(W&1023)+65536}}if((V&4294901760)===0)Z[X++]=V>>12&15|224,Z[X++]=V>>6&63|128;else Z[X++]=V>>18&7|240,Z[X++]=V>>12&63|128,Z[X++]=V>>6&63|128}Z[X++]=V&63|128}}var dX=new TextEncoder,nX=50;function yJ($,Z,J){dX.encodeInto($,Z.subarray(J))}function cX($,Z,J){if($.length>nX)yJ($,Z,J);else vJ($,Z,J)}var rX=4096;function lJ($,Z,J){let Q=Z,X=Q+J,Y=[],V="";while(Q<X){let W=$[Q++];if((W&128)===0)Y.push(W);else if((W&224)===192){let q=$[Q++]&63;Y.push((W&31)<<6|q)}else if((W&240)===224){let q=$[Q++]&63,z=$[Q++]&63;Y.push((W&31)<<12|q<<6|z)}else if((W&248)===240){let q=$[Q++]&63,z=$[Q++]&63,M=$[Q++]&63,N=(W&7)<<18|q<<12|z<<6|M;if(N>65535)N-=65536,Y.push(N>>>10&1023|55296),N=56320|N&1023;Y.push(N)}else Y.push(W);if(Y.length>=rX)V+=String.fromCharCode(...Y),Y.length=0}if(Y.length>0)V+=String.fromCharCode(...Y);return V}var oX=new TextDecoder,aX=200;function bJ($,Z,J){let Q=$.subarray(Z,Z+J);return oX.decode(Q)}function sX($,Z,J){if(J>aX)return bJ($,Z,J);else return lJ($,Z,J)}});var RZ=r((pJ)=>{Object.defineProperty(pJ,"__esModule",{value:!0});pJ.ExtData=void 0;class iJ{type;data;constructor($,Z){this.type=$,this.data=Z}}pJ.ExtData=iJ});var j$=r((dJ)=>{Object.defineProperty(dJ,"__esModule",{value:!0});dJ.DecodeError=void 0;class A$ extends Error{constructor($){super($);let Z=Object.create(A$.prototype);Object.setPrototypeOf(this,Z),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:A$.name})}}dJ.DecodeError=A$});var L$=r((cJ)=>{Object.defineProperty(cJ,"__esModule",{value:!0});cJ.UINT32_MAX=void 0;cJ.setUint64=YY;cJ.setInt64=VY;cJ.getInt64=GY;cJ.getUint64=WY;cJ.UINT32_MAX=4294967295;function YY($,Z,J){let Q=J/4294967296,X=J;$.setUint32(Z,Q),$.setUint32(Z+4,X)}function VY($,Z,J){let Q=Math.floor(J/4294967296),X=J;$.setUint32(Z,Q),$.setUint32(Z+4,X)}function GY($,Z){let J=$.getInt32(Z),Q=$.getUint32(Z+4);return J*4294967296+Q}function WY($,Z){let J=$.getUint32(Z),Q=$.getUint32(Z+4);return J*4294967296+Q}});var IZ=r((ZQ)=>{Object.defineProperty(ZQ,"__esModule",{value:!0});ZQ.timestampExtension=ZQ.EXT_TIMESTAMP=void 0;ZQ.encodeTimeSpecToTimestamp=aJ;ZQ.encodeDateToTimeSpec=sJ;ZQ.encodeTimestampExtension=tJ;ZQ.decodeTimestampToTimeSpec=eJ;ZQ.decodeTimestampExtension=$Q;var OY=j$(),oJ=L$();ZQ.EXT_TIMESTAMP=-1;var KY=4294967295,HY=17179869183;function aJ({sec:$,nsec:Z}){if($>=0&&Z>=0&&$<=HY)if(Z===0&&$<=KY){let J=new Uint8Array(4);return new DataView(J.buffer).setUint32(0,$),J}else{let J=$/4294967296,Q=$&4294967295,X=new Uint8Array(8),Y=new DataView(X.buffer);return Y.setUint32(0,Z<<2|J&3),Y.setUint32(4,Q),X}else{let J=new Uint8Array(12),Q=new DataView(J.buffer);return Q.setUint32(0,Z),(0,oJ.setInt64)(Q,4,$),J}}function sJ($){let Z=$.getTime(),J=Math.floor(Z/1000),Q=(Z-J*1000)*1e6,X=Math.floor(Q/1e9);return{sec:J+X,nsec:Q-X*1e9}}function tJ($){if($ instanceof Date){let Z=sJ($);return aJ(Z)}else return null}function eJ($){let Z=new DataView($.buffer,$.byteOffset,$.byteLength);switch($.byteLength){case 4:{let J=Z.getUint32(0),Q=0;return{sec:J,nsec:0}}case 8:{let J=Z.getUint32(0),Q=Z.getUint32(4),X=(J&3)*4294967296+Q,Y=J>>>2;return{sec:X,nsec:Y}}case 12:{let J=(0,oJ.getInt64)(Z,4),Q=Z.getUint32(0);return{sec:J,nsec:Q}}default:throw new OY.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${$.length}`)}}function $Q($){let Z=eJ($);return new Date(Z.sec*1000+Z.nsec/1e6)}ZQ.timestampExtension={type:ZQ.EXT_TIMESTAMP,encode:tJ,decode:$Q}});var m$=r((XQ)=>{Object.defineProperty(XQ,"__esModule",{value:!0});XQ.ExtensionCodec=void 0;var E$=RZ(),CY=IZ();class PZ{static defaultCodec=new PZ;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(CY.timestampExtension)}register({type:$,encode:Z,decode:J}){if($>=0)this.encoders[$]=Z,this.decoders[$]=J;else{let Q=-1-$;this.builtInEncoders[Q]=Z,this.builtInDecoders[Q]=J}}tryToEncode($,Z){for(let J=0;J<this.builtInEncoders.length;J++){let Q=this.builtInEncoders[J];if(Q!=null){let X=Q($,Z);if(X!=null){let Y=-1-J;return new E$.ExtData(Y,X)}}}for(let J=0;J<this.encoders.length;J++){let Q=this.encoders[J];if(Q!=null){let X=Q($,Z);if(X!=null){let Y=J;return new E$.ExtData(Y,X)}}}if($ instanceof E$.ExtData)return $;return null}decode($,Z,J){let Q=Z<0?this.builtInDecoders[-1-Z]:this.decoders[Z];if(Q)return Q($,Z,J);else return new E$.ExtData(Z,$)}}XQ.ExtensionCodec=PZ});var UZ=r((VQ)=>{Object.defineProperty(VQ,"__esModule",{value:!0});VQ.ensureUint8Array=TY;function wY($){return $ instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&$ instanceof SharedArrayBuffer}function TY($){if($ instanceof Uint8Array)return $;else if(ArrayBuffer.isView($))return new Uint8Array($.buffer,$.byteOffset,$.byteLength);else if(wY($))return new Uint8Array($);else return Uint8Array.from($)}});var wZ=r((qQ)=>{Object.defineProperty(qQ,"__esModule",{value:!0});qQ.Encoder=qQ.DEFAULT_INITIAL_BUFFER_SIZE=qQ.DEFAULT_MAX_DEPTH=void 0;var GQ=D$(),AY=m$(),WQ=L$(),jY=UZ();qQ.DEFAULT_MAX_DEPTH=100;qQ.DEFAULT_INITIAL_BUFFER_SIZE=2048;class CZ{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor($){this.extensionCodec=$?.extensionCodec??AY.ExtensionCodec.defaultCodec,this.context=$?.context,this.useBigInt64=$?.useBigInt64??!1,this.maxDepth=$?.maxDepth??qQ.DEFAULT_MAX_DEPTH,this.initialBufferSize=$?.initialBufferSize??qQ.DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=$?.sortKeys??!1,this.forceFloat32=$?.forceFloat32??!1,this.ignoreUndefined=$?.ignoreUndefined??!1,this.forceIntegerToFloat=$?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new CZ({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef($){if(this.entered)return this.clone().encodeSharedRef($);try{return this.entered=!0,this.reinitializeState(),this.doEncode($,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode($){if(this.entered)return this.clone().encode($);try{return this.entered=!0,this.reinitializeState(),this.doEncode($,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode($,Z){if(Z>this.maxDepth)throw Error(`Too deep objects in depth ${Z}`);if($==null)this.encodeNil();else if(typeof $==="boolean")this.encodeBoolean($);else if(typeof $==="number")if(!this.forceIntegerToFloat)this.encodeNumber($);else this.encodeNumberAsFloat($);else if(typeof $==="string")this.encodeString($);else if(this.useBigInt64&&typeof $==="bigint")this.encodeBigInt64($);else this.encodeObject($,Z)}ensureBufferSizeToWrite($){let Z=this.pos+$;if(this.view.byteLength<Z)this.resizeBuffer(Z*2)}resizeBuffer($){let Z=new ArrayBuffer($),J=new Uint8Array(Z),Q=new DataView(Z);J.set(this.bytes),this.view=Q,this.bytes=J}encodeNil(){this.writeU8(192)}encodeBoolean($){if($===!1)this.writeU8(194);else this.writeU8(195)}encodeNumber($){if(!this.forceIntegerToFloat&&Number.isSafeInteger($))if($>=0)if($<128)this.writeU8($);else if($<256)this.writeU8(204),this.writeU8($);else if($<65536)this.writeU8(205),this.writeU16($);else if($<4294967296)this.writeU8(206),this.writeU32($);else if(!this.useBigInt64)this.writeU8(207),this.writeU64($);else this.encodeNumberAsFloat($);else if($>=-32)this.writeU8(224|$+32);else if($>=-128)this.writeU8(208),this.writeI8($);else if($>=-32768)this.writeU8(209),this.writeI16($);else if($>=-2147483648)this.writeU8(210),this.writeI32($);else if(!this.useBigInt64)this.writeU8(211),this.writeI64($);else this.encodeNumberAsFloat($);else this.encodeNumberAsFloat($)}encodeNumberAsFloat($){if(this.forceFloat32)this.writeU8(202),this.writeF32($);else this.writeU8(203),this.writeF64($)}encodeBigInt64($){if($>=BigInt(0))this.writeU8(207),this.writeBigUint64($);else this.writeU8(211),this.writeBigInt64($)}writeStringHeader($){if($<32)this.writeU8(160+$);else if($<256)this.writeU8(217),this.writeU8($);else if($<65536)this.writeU8(218),this.writeU16($);else if($<4294967296)this.writeU8(219),this.writeU32($);else throw Error(`Too long string: ${$} bytes in UTF-8`)}encodeString($){let J=(0,GQ.utf8Count)($);this.ensureBufferSizeToWrite(5+J),this.writeStringHeader(J),(0,GQ.utf8Encode)($,this.bytes,this.pos),this.pos+=J}encodeObject($,Z){let J=this.extensionCodec.tryToEncode($,this.context);if(J!=null)this.encodeExtension(J);else if(Array.isArray($))this.encodeArray($,Z);else if(ArrayBuffer.isView($))this.encodeBinary($);else if(typeof $==="object")this.encodeMap($,Z);else throw Error(`Unrecognized object: ${Object.prototype.toString.apply($)}`)}encodeBinary($){let Z=$.byteLength;if(Z<256)this.writeU8(196),this.writeU8(Z);else if(Z<65536)this.writeU8(197),this.writeU16(Z);else if(Z<4294967296)this.writeU8(198),this.writeU32(Z);else throw Error(`Too large binary: ${Z}`);let J=(0,jY.ensureUint8Array)($);this.writeU8a(J)}encodeArray($,Z){let J=$.length;if(J<16)this.writeU8(144+J);else if(J<65536)this.writeU8(220),this.writeU16(J);else if(J<4294967296)this.writeU8(221),this.writeU32(J);else throw Error(`Too large array: ${J}`);for(let Q of $)this.doEncode(Q,Z+1)}countWithoutUndefined($,Z){let J=0;for(let Q of Z)if($[Q]!==void 0)J++;return J}encodeMap($,Z){let J=Object.keys($);if(this.sortKeys)J.sort();let Q=this.ignoreUndefined?this.countWithoutUndefined($,J):J.length;if(Q<16)this.writeU8(128+Q);else if(Q<65536)this.writeU8(222),this.writeU16(Q);else if(Q<4294967296)this.writeU8(223),this.writeU32(Q);else throw Error(`Too large map object: ${Q}`);for(let X of J){let Y=$[X];if(!(this.ignoreUndefined&&Y===void 0))this.encodeString(X),this.doEncode(Y,Z+1)}}encodeExtension($){if(typeof $.data==="function"){let J=$.data(this.pos+6),Q=J.length;if(Q>=4294967296)throw Error(`Too large extension object: ${Q}`);this.writeU8(201),this.writeU32(Q),this.writeI8($.type),this.writeU8a(J);return}let Z=$.data.length;if(Z===1)this.writeU8(212);else if(Z===2)this.writeU8(213);else if(Z===4)this.writeU8(214);else if(Z===8)this.writeU8(215);else if(Z===16)this.writeU8(216);else if(Z<256)this.writeU8(199),this.writeU8(Z);else if(Z<65536)this.writeU8(200),this.writeU16(Z);else if(Z<4294967296)this.writeU8(201),this.writeU32(Z);else throw Error(`Too large extension object: ${Z}`);this.writeI8($.type),this.writeU8a($.data)}writeU8($){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,$),this.pos++}writeU8a($){let Z=$.length;this.ensureBufferSizeToWrite(Z),this.bytes.set($,this.pos),this.pos+=Z}writeI8($){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,$),this.pos++}writeU16($){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,$),this.pos+=2}writeI16($){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,$),this.pos+=2}writeU32($){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,$),this.pos+=4}writeI32($){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,$),this.pos+=4}writeF32($){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,$),this.pos+=4}writeF64($){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,$),this.pos+=8}writeU64($){this.ensureBufferSizeToWrite(8),(0,WQ.setUint64)(this.view,this.pos,$),this.pos+=8}writeI64($){this.ensureBufferSizeToWrite(8),(0,WQ.setInt64)(this.view,this.pos,$),this.pos+=8}writeBigUint64($){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,$),this.pos+=8}writeBigInt64($){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,$),this.pos+=8}}qQ.Encoder=CZ});var KQ=r((OQ)=>{Object.defineProperty(OQ,"__esModule",{value:!0});OQ.encode=EY;var LY=wZ();function EY($,Z){return new LY.Encoder(Z).encodeSharedRef($)}});var FQ=r((HQ)=>{Object.defineProperty(HQ,"__esModule",{value:!0});HQ.prettyByte=_Y;function _Y($){return`${$<0?"-":""}0x${Math.abs($).toString(16).padStart(2,"0")}`}});var UQ=r((IQ)=>{Object.defineProperty(IQ,"__esModule",{value:!0});IQ.CachedKeyDecoder=void 0;var kY=D$(),xY=16,SY=16;class RQ{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor($=xY,Z=SY){this.maxKeyLength=$,this.maxLengthPerKey=Z,this.caches=[];for(let J=0;J<this.maxKeyLength;J++)this.caches.push([])}canBeCached($){return $>0&&$<=this.maxKeyLength}find($,Z,J){let Q=this.caches[J-1];$:for(let X of Q){let Y=X.bytes;for(let V=0;V<J;V++)if(Y[V]!==$[Z+V])continue $;return X.str}return null}store($,Z){let J=this.caches[$.length-1],Q={bytes:$,str:Z};if(J.length>=this.maxLengthPerKey)J[Math.random()*J.length|0]=Q;else J.push(Q)}decode($,Z,J){let Q=this.find($,Z,J);if(Q!=null)return this.hit++,Q;this.miss++;let X=(0,kY.utf8DecodeJs)($,Z,J),Y=Uint8Array.prototype.slice.call($,Z,Z+J);return this.store(Y,X),X}}IQ.CachedKeyDecoder=RQ});var _$=r((AQ)=>{Object.defineProperty(AQ,"__esModule",{value:!0});AQ.Decoder=void 0;var TZ=FQ(),gY=m$(),m0=L$(),fY=D$(),CQ=UZ(),vY=UQ(),I0=j$(),DZ="array",J$="map_key",TQ="map_value",yY=($)=>{if(typeof $==="string"||typeof $==="number")return $;throw new I0.DecodeError("The type of key must be string or number but "+typeof $)};class DQ{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState($){let Z=this.getUninitializedStateFromPool();Z.type=DZ,Z.position=0,Z.size=$,Z.array=Array($)}pushMapState($){let Z=this.getUninitializedStateFromPool();Z.type=J$,Z.readCount=0,Z.size=$,Z.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let $={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push($)}return this.stack[this.stackHeadPosition]}release($){if(this.stack[this.stackHeadPosition]!==$)throw Error("Invalid stack state. Released state is not on top of the stack.");if($.type===DZ){let J=$;J.size=0,J.array=void 0,J.position=0,J.type=void 0}if($.type===J$||$.type===TQ){let J=$;J.size=0,J.map=void 0,J.readCount=0,J.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}var Z$=-1,AZ=new DataView(new ArrayBuffer(0)),lY=new Uint8Array(AZ.buffer);try{AZ.getInt8(0)}catch($){if(!($ instanceof RangeError))throw Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var wQ=RangeError("Insufficient data"),bY=new vY.CachedKeyDecoder;class jZ{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=AZ;bytes=lY;headByte=Z$;stack=new DQ;entered=!1;constructor($){this.extensionCodec=$?.extensionCodec??gY.ExtensionCodec.defaultCodec,this.context=$?.context,this.useBigInt64=$?.useBigInt64??!1,this.rawStrings=$?.rawStrings??!1,this.maxStrLength=$?.maxStrLength??m0.UINT32_MAX,this.maxBinLength=$?.maxBinLength??m0.UINT32_MAX,this.maxArrayLength=$?.maxArrayLength??m0.UINT32_MAX,this.maxMapLength=$?.maxMapLength??m0.UINT32_MAX,this.maxExtLength=$?.maxExtLength??m0.UINT32_MAX,this.keyDecoder=$?.keyDecoder!==void 0?$.keyDecoder:bY,this.mapKeyConverter=$?.mapKeyConverter??yY}clone(){return new jZ({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=Z$,this.stack.reset()}setBuffer($){let Z=(0,CQ.ensureUint8Array)($);this.bytes=Z,this.view=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),this.pos=0}appendBuffer($){if(this.headByte===Z$&&!this.hasRemaining(1))this.setBuffer($);else{let Z=this.bytes.subarray(this.pos),J=(0,CQ.ensureUint8Array)($),Q=new Uint8Array(Z.length+J.length);Q.set(Z),Q.set(J,Z.length),this.setBuffer(Q)}}hasRemaining($){return this.view.byteLength-this.pos>=$}createExtraByteError($){let{view:Z,pos:J}=this;return RangeError(`Extra ${Z.byteLength-J} of ${Z.byteLength} byte(s) found at buffer[${$}]`)}decode($){if(this.entered)return this.clone().decode($);try{this.entered=!0,this.reinitializeState(),this.setBuffer($);let Z=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return Z}finally{this.entered=!1}}*decodeMulti($){if(this.entered){yield*this.clone().decodeMulti($);return}try{this.entered=!0,this.reinitializeState(),this.setBuffer($);while(this.hasRemaining(1))yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync($){if(this.entered)return this.clone().decodeAsync($);try{this.entered=!0;let Z=!1,J;for await(let V of $){if(Z)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(V);try{J=this.doDecodeSync(),Z=!0}catch(W){if(!(W instanceof RangeError))throw W}this.totalPos+=this.pos}if(Z){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return J}let{headByte:Q,pos:X,totalPos:Y}=this;throw RangeError(`Insufficient data in parsing ${(0,TZ.prettyByte)(Q)} at ${Y} (${X} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream($){return this.decodeMultiAsync($,!0)}decodeStream($){return this.decodeMultiAsync($,!1)}async*decodeMultiAsync($,Z){if(this.entered){yield*this.clone().decodeMultiAsync($,Z);return}try{this.entered=!0;let J=Z,Q=-1;for await(let X of $){if(Z&&Q===0)throw this.createExtraByteError(this.totalPos);if(this.appendBuffer(X),J)Q=this.readArraySize(),J=!1,this.complete();try{while(!0)if(yield this.doDecodeSync(),--Q===0)break}catch(Y){if(!(Y instanceof RangeError))throw Y}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){$:while(!0){let $=this.readHeadByte(),Z;if($>=224)Z=$-256;else if($<192)if($<128)Z=$;else if($<144){let Q=$-128;if(Q!==0){this.pushMapState(Q),this.complete();continue $}else Z={}}else if($<160){let Q=$-144;if(Q!==0){this.pushArrayState(Q),this.complete();continue $}else Z=[]}else{let Q=$-160;Z=this.decodeString(Q,0)}else if($===192)Z=null;else if($===194)Z=!1;else if($===195)Z=!0;else if($===202)Z=this.readF32();else if($===203)Z=this.readF64();else if($===204)Z=this.readU8();else if($===205)Z=this.readU16();else if($===206)Z=this.readU32();else if($===207)if(this.useBigInt64)Z=this.readU64AsBigInt();else Z=this.readU64();else if($===208)Z=this.readI8();else if($===209)Z=this.readI16();else if($===210)Z=this.readI32();else if($===211)if(this.useBigInt64)Z=this.readI64AsBigInt();else Z=this.readI64();else if($===217){let Q=this.lookU8();Z=this.decodeString(Q,1)}else if($===218){let Q=this.lookU16();Z=this.decodeString(Q,2)}else if($===219){let Q=this.lookU32();Z=this.decodeString(Q,4)}else if($===220){let Q=this.readU16();if(Q!==0){this.pushArrayState(Q),this.complete();continue $}else Z=[]}else if($===221){let Q=this.readU32();if(Q!==0){this.pushArrayState(Q),this.complete();continue $}else Z=[]}else if($===222){let Q=this.readU16();if(Q!==0){this.pushMapState(Q),this.complete();continue $}else Z={}}else if($===223){let Q=this.readU32();if(Q!==0){this.pushMapState(Q),this.complete();continue $}else Z={}}else if($===196){let Q=this.lookU8();Z=this.decodeBinary(Q,1)}else if($===197){let Q=this.lookU16();Z=this.decodeBinary(Q,2)}else if($===198){let Q=this.lookU32();Z=this.decodeBinary(Q,4)}else if($===212)Z=this.decodeExtension(1,0);else if($===213)Z=this.decodeExtension(2,0);else if($===214)Z=this.decodeExtension(4,0);else if($===215)Z=this.decodeExtension(8,0);else if($===216)Z=this.decodeExtension(16,0);else if($===199){let Q=this.lookU8();Z=this.decodeExtension(Q,1)}else if($===200){let Q=this.lookU16();Z=this.decodeExtension(Q,2)}else if($===201){let Q=this.lookU32();Z=this.decodeExtension(Q,4)}else throw new I0.DecodeError(`Unrecognized type byte: ${(0,TZ.prettyByte)($)}`);this.complete();let J=this.stack;while(J.length>0){let Q=J.top();if(Q.type===DZ)if(Q.array[Q.position]=Z,Q.position++,Q.position===Q.size)Z=Q.array,J.release(Q);else continue $;else if(Q.type===J$){if(Z==="__proto__")throw new I0.DecodeError("The key __proto__ is not allowed");Q.key=this.mapKeyConverter(Z),Q.type=TQ;continue $}else if(Q.map[Q.key]=Z,Q.readCount++,Q.readCount===Q.size)Z=Q.map,J.release(Q);else{Q.key=null,Q.type=J$;continue $}}return Z}}readHeadByte(){if(this.headByte===Z$)this.headByte=this.readU8();return this.headByte}complete(){this.headByte=Z$}readArraySize(){let $=this.readHeadByte();switch($){case 220:return this.readU16();case 221:return this.readU32();default:if($<160)return $-144;else throw new I0.DecodeError(`Unrecognized array type byte: ${(0,TZ.prettyByte)($)}`)}}pushMapState($){if($>this.maxMapLength)throw new I0.DecodeError(`Max length exceeded: map length (${$}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState($)}pushArrayState($){if($>this.maxArrayLength)throw new I0.DecodeError(`Max length exceeded: array length (${$}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState($)}decodeString($,Z){if(!this.rawStrings||this.stateIsMapKey())return this.decodeUtf8String($,Z);return this.decodeBinary($,Z)}decodeUtf8String($,Z){if($>this.maxStrLength)throw new I0.DecodeError(`Max length exceeded: UTF-8 byte length (${$}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+Z+$)throw wQ;let J=this.pos+Z,Q;if(this.stateIsMapKey()&&this.keyDecoder?.canBeCached($))Q=this.keyDecoder.decode(this.bytes,J,$);else Q=(0,fY.utf8Decode)(this.bytes,J,$);return this.pos+=Z+$,Q}stateIsMapKey(){if(this.stack.length>0)return this.stack.top().type===J$;return!1}decodeBinary($,Z){if($>this.maxBinLength)throw new I0.DecodeError(`Max length exceeded: bin length (${$}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining($+Z))throw wQ;let J=this.pos+Z,Q=this.bytes.subarray(J,J+$);return this.pos+=Z+$,Q}decodeExtension($,Z){if($>this.maxExtLength)throw new I0.DecodeError(`Max length exceeded: ext length (${$}) > maxExtLength (${this.maxExtLength})`);let J=this.view.getInt8(this.pos+Z),Q=this.decodeBinary($,Z+1);return this.extensionCodec.decode(Q,J,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let $=this.view.getUint8(this.pos);return this.pos++,$}readI8(){let $=this.view.getInt8(this.pos);return this.pos++,$}readU16(){let $=this.view.getUint16(this.pos);return this.pos+=2,$}readI16(){let $=this.view.getInt16(this.pos);return this.pos+=2,$}readU32(){let $=this.view.getUint32(this.pos);return this.pos+=4,$}readI32(){let $=this.view.getInt32(this.pos);return this.pos+=4,$}readU64(){let $=(0,m0.getUint64)(this.view,this.pos);return this.pos+=8,$}readI64(){let $=(0,m0.getInt64)(this.view,this.pos);return this.pos+=8,$}readU64AsBigInt(){let $=this.view.getBigUint64(this.pos);return this.pos+=8,$}readI64AsBigInt(){let $=this.view.getBigInt64(this.pos);return this.pos+=8,$}readF32(){let $=this.view.getFloat32(this.pos);return this.pos+=4,$}readF64(){let $=this.view.getFloat64(this.pos);return this.pos+=8,$}}AQ.Decoder=jZ});var mQ=r((EQ)=>{Object.defineProperty(EQ,"__esModule",{value:!0});EQ.decode=hY;EQ.decodeMulti=iY;var LQ=_$();function hY($,Z){return new LQ.Decoder(Z).decode($)}function iY($,Z){return new LQ.Decoder(Z).decodeMulti($)}});var xQ=r((kQ)=>{Object.defineProperty(kQ,"__esModule",{value:!0});kQ.isAsyncIterable=_Q;kQ.asyncIterableFromStream=BQ;kQ.ensureAsyncIterable=dY;function _Q($){return $[Symbol.asyncIterator]!=null}async function*BQ($){let Z=$.getReader();try{while(!0){let{done:J,value:Q}=await Z.read();if(J)return;yield Q}}finally{Z.releaseLock()}}function dY($){if(_Q($))return $;else return BQ($)}});var gQ=r((SQ)=>{Object.defineProperty(SQ,"__esModule",{value:!0});SQ.decodeAsync=oY;SQ.decodeArrayStream=aY;SQ.decodeMultiStream=sY;var LZ=_$(),EZ=xQ();async function oY($,Z){let J=(0,EZ.ensureAsyncIterable)($);return new LZ.Decoder(Z).decodeAsync(J)}function aY($,Z){let J=(0,EZ.ensureAsyncIterable)($);return new LZ.Decoder(Z).decodeArrayStream(J)}function sY($,Z){let J=(0,EZ.ensureAsyncIterable)($);return new LZ.Decoder(Z).decodeStream(J)}});var vQ=r((y)=>{Object.defineProperty(y,"__esModule",{value:!0});y.decodeTimestampExtension=y.encodeTimestampExtension=y.decodeTimestampToTimeSpec=y.encodeTimeSpecToTimestamp=y.encodeDateToTimeSpec=y.EXT_TIMESTAMP=y.ExtData=y.ExtensionCodec=y.Encoder=y.DecodeError=y.Decoder=y.decodeMultiStream=y.decodeArrayStream=y.decodeAsync=y.decodeMulti=y.decode=y.encode=void 0;var ZV=KQ();Object.defineProperty(y,"encode",{enumerable:!0,get:function(){return ZV.encode}});var fQ=mQ();Object.defineProperty(y,"decode",{enumerable:!0,get:function(){return fQ.decode}});Object.defineProperty(y,"decodeMulti",{enumerable:!0,get:function(){return fQ.decodeMulti}});var mZ=gQ();Object.defineProperty(y,"decodeAsync",{enumerable:!0,get:function(){return mZ.decodeAsync}});Object.defineProperty(y,"decodeArrayStream",{enumerable:!0,get:function(){return mZ.decodeArrayStream}});Object.defineProperty(y,"decodeMultiStream",{enumerable:!0,get:function(){return mZ.decodeMultiStream}});var JV=_$();Object.defineProperty(y,"Decoder",{enumerable:!0,get:function(){return JV.Decoder}});var QV=j$();Object.defineProperty(y,"DecodeError",{enumerable:!0,get:function(){return QV.DecodeError}});var XV=wZ();Object.defineProperty(y,"Encoder",{enumerable:!0,get:function(){return XV.Encoder}});var YV=m$();Object.defineProperty(y,"ExtensionCodec",{enumerable:!0,get:function(){return YV.ExtensionCodec}});var VV=RZ();Object.defineProperty(y,"ExtData",{enumerable:!0,get:function(){return VV.ExtData}});var n0=IZ();Object.defineProperty(y,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return n0.EXT_TIMESTAMP}});Object.defineProperty(y,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return n0.encodeDateToTimeSpec}});Object.defineProperty(y,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return n0.encodeTimeSpecToTimestamp}});Object.defineProperty(y,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return n0.decodeTimestampToTimeSpec}});Object.defineProperty(y,"encodeTimestampExtension",{enumerable:!0,get:function(){return n0.encodeTimestampExtension}});Object.defineProperty(y,"decodeTimestampExtension",{enumerable:!0,get:function(){return n0.decodeTimestampExtension}})});import*as q0 from"node:crypto";var C0=q0&&typeof q0==="object"&&"webcrypto"in q0?q0.webcrypto:q0&&typeof q0==="object"&&("randomBytes"in q0)?q0:void 0;function Q$($){if(!Number.isSafeInteger($)||$<0)throw Error("positive integer expected, got "+$)}function B$($){return $ instanceof Uint8Array||ArrayBuffer.isView($)&&$.constructor.name==="Uint8Array"}function p($,...Z){if(!B$($))throw Error("Uint8Array expected");if(Z.length>0&&!Z.includes($.length))throw Error("Uint8Array expected of length "+Z+", got length="+$.length)}function k$($,Z=!0){if($.destroyed)throw Error("Hash instance has been destroyed");if(Z&&$.finished)throw Error("Hash#digest() has already been called")}function kZ($,Z){p($);let J=Z.outputLen;if($.length<J)throw Error("digestInto() expects output buffer of length at least "+J)}function x$($){if(typeof $!=="boolean")throw Error(`boolean expected, not ${$}`)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */var z0=($)=>new Uint32Array($.buffer,$.byteOffset,Math.floor($.byteLength/4));var sQ=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!sQ)throw Error("Non little-endian hardware is not supported");function tQ($){if(typeof $!=="string")throw Error("string expected");return new Uint8Array(new TextEncoder().encode($))}function X$($){if(typeof $==="string")$=tQ($);else if(B$($))$=Y$($);else throw Error("Uint8Array expected, got "+typeof $);return $}function xZ($,Z){if(Z==null||typeof Z!=="object")throw Error("options must be defined");return Object.assign($,Z)}function SZ($,Z){if($.length!==Z.length)return!1;let J=0;for(let Q=0;Q<$.length;Q++)J|=$[Q]^Z[Q];return J===0}var gZ=($,Z)=>{function J(Q,...X){if(p(Q),$.nonceLength!==void 0){let M=X[0];if(!M)throw Error("nonce / iv required");if($.varSizeNonce)p(M);else p(M,$.nonceLength)}let Y=$.tagLength;if(Y&&X[1]!==void 0)p(X[1]);let V=Z(Q,...X),W=(M,N)=>{if(N!==void 0){if(M!==2)throw Error("cipher output not supported");p(N)}},q=!1;return{encrypt(M,N){if(q)throw Error("cannot encrypt() twice with same key + nonce");return q=!0,p(M),W(V.encrypt.length,N),V.encrypt(M,N)},decrypt(M,N){if(p(M),Y&&M.length<Y)throw Error("invalid ciphertext length: smaller than tagLength="+Y);return W(V.decrypt.length,N),V.decrypt(M,N)}}}return Object.assign(J,$),J};function S$($,Z,J=!0){if(Z===void 0)return new Uint8Array($);if(Z.length!==$)throw Error("invalid output length, expected "+$+", got: "+Z.length);if(J&&!eQ(Z))throw Error("invalid output, must be aligned");return Z}function eQ($){return $.byteOffset%4===0}function Y$($){return Uint8Array.from($)}function X0(...$){for(let Z=0;Z<$.length;Z++)$[Z].fill(0)}function r0($=32){if(C0&&typeof C0.getRandomValues==="function")return C0.getRandomValues(new Uint8Array($));if(C0&&typeof C0.randomBytes==="function")return C0.randomBytes($);throw Error("crypto.getRandomValues must be defined")}var vZ=($)=>Uint8Array.from($.split("").map((Z)=>Z.charCodeAt(0))),$X=vZ("expand 16-byte k"),ZX=vZ("expand 32-byte k"),JX=z0($X),QX=z0(ZX);function U($,Z){return $<<Z|$>>>32-Z}function g$($){return $.byteOffset%4===0}var V$=64,XX=16,yZ=4294967295,fZ=new Uint32Array;function YX($,Z,J,Q,X,Y,V,W){let q=X.length,z=new Uint8Array(V$),M=z0(z),N=g$(X)&&g$(Y),K=N?z0(X):fZ,H=N?z0(Y):fZ;for(let I=0;I<q;V++){if($(Z,J,Q,M,V,W),V>=yZ)throw Error("arx: counter overflow");let R=Math.min(V$,q-I);if(N&&R===V$){let P=I/4;if(I%4!==0)throw Error("arx: invalid block position");for(let w=0,T;w<XX;w++)T=P+w,H[T]=K[T]^M[w];I+=V$;continue}for(let P=0,w;P<R;P++)w=I+P,Y[w]=X[w]^z[P];I+=R}}function lZ($,Z){let{allowShortKeys:J,extendNonceFn:Q,counterLength:X,counterRight:Y,rounds:V}=xZ({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},Z);if(typeof $!=="function")throw Error("core must be a function");return Q$(X),Q$(V),x$(Y),x$(J),(W,q,z,M,N=0)=>{p(W),p(q),p(z);let K=z.length;if(M===void 0)M=new Uint8Array(K);if(p(M),Q$(N),N<0||N>=yZ)throw Error("arx: counter overflow");if(M.length<K)throw Error(`arx: output (${M.length}) is shorter than data (${K})`);let H=[],I=W.length,R,P;if(I===32)H.push(R=Y$(W)),P=QX;else if(I===16&&J)R=new Uint8Array(32),R.set(W),R.set(W,16),P=JX,H.push(R);else throw Error(`arx: invalid 32-byte key, got length=${I}`);if(!g$(q))H.push(q=Y$(q));let w=z0(R);if(Q){if(q.length!==24)throw Error("arx: extended nonce must be 24 bytes");Q(P,w,z0(q.subarray(0,16)),w),q=q.subarray(16)}let T=16-X;if(T!==q.length)throw Error(`arx: nonce must be ${T} or 16 bytes`);if(T!==12){let C=new Uint8Array(12);C.set(q,Y?0:12-q.length),q=C,H.push(q)}let j=z0(q);return YX($,P,w,j,z,M,N,V),X0(...H),M}}var d=($,Z)=>$[Z++]&255|($[Z++]&255)<<8;class bZ{constructor($){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,$=X$($),p($,32);let Z=d($,0),J=d($,2),Q=d($,4),X=d($,6),Y=d($,8),V=d($,10),W=d($,12),q=d($,14);this.r[0]=Z&8191,this.r[1]=(Z>>>13|J<<3)&8191,this.r[2]=(J>>>10|Q<<6)&7939,this.r[3]=(Q>>>7|X<<9)&8191,this.r[4]=(X>>>4|Y<<12)&255,this.r[5]=Y>>>1&8190,this.r[6]=(Y>>>14|V<<2)&8191,this.r[7]=(V>>>11|W<<5)&8065,this.r[8]=(W>>>8|q<<8)&8191,this.r[9]=q>>>5&127;for(let z=0;z<8;z++)this.pad[z]=d($,16+2*z)}process($,Z,J=!1){let Q=J?0:2048,{h:X,r:Y}=this,V=Y[0],W=Y[1],q=Y[2],z=Y[3],M=Y[4],N=Y[5],K=Y[6],H=Y[7],I=Y[8],R=Y[9],P=d($,Z+0),w=d($,Z+2),T=d($,Z+4),j=d($,Z+6),C=d($,Z+8),L=d($,Z+10),B=d($,Z+12),u=d($,Z+14),_=X[0]+(P&8191),x=X[1]+((P>>>13|w<<3)&8191),g=X[2]+((w>>>10|T<<6)&8191),S=X[3]+((T>>>7|j<<9)&8191),f=X[4]+((j>>>4|C<<12)&8191),F=X[5]+(C>>>1&8191),l=X[6]+((C>>>14|L<<2)&8191),b=X[7]+((L>>>11|B<<5)&8191),h=X[8]+((B>>>8|u<<8)&8191),i=X[9]+(u>>>5|Q),D=0,c=D+_*V+x*(5*R)+g*(5*I)+S*(5*H)+f*(5*K);D=c>>>13,c&=8191,c+=F*(5*N)+l*(5*M)+b*(5*z)+h*(5*q)+i*(5*W),D+=c>>>13,c&=8191;let a=D+_*W+x*V+g*(5*R)+S*(5*I)+f*(5*H);D=a>>>13,a&=8191,a+=F*(5*K)+l*(5*N)+b*(5*M)+h*(5*z)+i*(5*q),D+=a>>>13,a&=8191;let e=D+_*q+x*W+g*V+S*(5*R)+f*(5*I);D=e>>>13,e&=8191,e+=F*(5*H)+l*(5*K)+b*(5*N)+h*(5*M)+i*(5*z),D+=e>>>13,e&=8191;let k=D+_*z+x*q+g*W+S*V+f*(5*R);D=k>>>13,k&=8191,k+=F*(5*I)+l*(5*H)+b*(5*K)+h*(5*N)+i*(5*M),D+=k>>>13,k&=8191;let W0=D+_*M+x*z+g*q+S*W+f*V;D=W0>>>13,W0&=8191,W0+=F*(5*R)+l*(5*I)+b*(5*H)+h*(5*K)+i*(5*N),D+=W0>>>13,W0&=8191;let _0=D+_*N+x*M+g*z+S*q+f*W;D=_0>>>13,_0&=8191,_0+=F*V+l*(5*R)+b*(5*I)+h*(5*H)+i*(5*K),D+=_0>>>13,_0&=8191;let B0=D+_*K+x*N+g*M+S*z+f*q;D=B0>>>13,B0&=8191,B0+=F*W+l*V+b*(5*R)+h*(5*I)+i*(5*H),D+=B0>>>13,B0&=8191;let k0=D+_*H+x*K+g*N+S*M+f*z;D=k0>>>13,k0&=8191,k0+=F*q+l*W+b*V+h*(5*R)+i*(5*I),D+=k0>>>13,k0&=8191;let x0=D+_*I+x*H+g*K+S*N+f*M;D=x0>>>13,x0&=8191,x0+=F*z+l*q+b*W+h*V+i*(5*R),D+=x0>>>13,x0&=8191;let S0=D+_*R+x*I+g*H+S*K+f*N;D=S0>>>13,S0&=8191,S0+=F*M+l*z+b*q+h*W+i*V,D+=S0>>>13,S0&=8191,D=(D<<2)+D|0,D=D+c|0,c=D&8191,D=D>>>13,a+=D,X[0]=c,X[1]=a,X[2]=e,X[3]=k,X[4]=W0,X[5]=_0,X[6]=B0,X[7]=k0,X[8]=x0,X[9]=S0}finalize(){let{h:$,pad:Z}=this,J=new Uint16Array(10),Q=$[1]>>>13;$[1]&=8191;for(let V=2;V<10;V++)$[V]+=Q,Q=$[V]>>>13,$[V]&=8191;$[0]+=Q*5,Q=$[0]>>>13,$[0]&=8191,$[1]+=Q,Q=$[1]>>>13,$[1]&=8191,$[2]+=Q,J[0]=$[0]+5,Q=J[0]>>>13,J[0]&=8191;for(let V=1;V<10;V++)J[V]=$[V]+Q,Q=J[V]>>>13,J[V]&=8191;J[9]-=8192;let X=(Q^1)-1;for(let V=0;V<10;V++)J[V]&=X;X=~X;for(let V=0;V<10;V++)$[V]=$[V]&X|J[V];$[0]=($[0]|$[1]<<13)&65535,$[1]=($[1]>>>3|$[2]<<10)&65535,$[2]=($[2]>>>6|$[3]<<7)&65535,$[3]=($[3]>>>9|$[4]<<4)&65535,$[4]=($[4]>>>12|$[5]<<1|$[6]<<14)&65535,$[5]=($[6]>>>2|$[7]<<11)&65535,$[6]=($[7]>>>5|$[8]<<8)&65535,$[7]=($[8]>>>8|$[9]<<5)&65535;let Y=$[0]+Z[0];$[0]=Y&65535;for(let V=1;V<8;V++)Y=($[V]+Z[V]|0)+(Y>>>16)|0,$[V]=Y&65535;X0(J)}update($){k$(this);let{buffer:Z,blockLen:J}=this;$=X$($);let Q=$.length;for(let X=0;X<Q;){let Y=Math.min(J-this.pos,Q-X);if(Y===J){for(;J<=Q-X;X+=J)this.process($,X);continue}if(Z.set($.subarray(X,X+Y),this.pos),this.pos+=Y,X+=Y,this.pos===J)this.process(Z,0,!1),this.pos=0}return this}destroy(){X0(this.h,this.r,this.buffer,this.pad)}digestInto($){k$(this),kZ($,this),this.finished=!0;let{buffer:Z,h:J}=this,{pos:Q}=this;if(Q){Z[Q++]=1;for(;Q<16;Q++)Z[Q]=0;this.process(Z,0,!0)}this.finalize();let X=0;for(let Y=0;Y<8;Y++)$[X++]=J[Y]>>>0,$[X++]=J[Y]>>>8;return $}digest(){let{buffer:$,outputLen:Z}=this;this.digestInto($);let J=$.slice(0,Z);return this.destroy(),J}}function VX($){let Z=(Q,X)=>$(X).update(X$(Q)).digest(),J=$(new Uint8Array(32));return Z.outputLen=J.outputLen,Z.blockLen=J.blockLen,Z.create=(Q)=>$(Q),Z}var f$=VX(($)=>new bZ($));function GX($,Z,J,Q,X,Y=20){let V=$[0],W=Z[0],q=Z[1],z=Z[2],M=Z[3],N=$[1],K=J[0],H=J[1],I=X,R=0,P=$[2],w=Z[4],T=Z[5],j=Z[6],C=Z[7],L=$[3],B=V,u=W,_=q,x=z,g=M,S=N,f=K,F=H,l=I,b=R,h=P,i=w,D=T,c=j,a=C,e=L;for(let W0=0;W0<Y;W0+=2)g^=U(B+D|0,7),l^=U(g+B|0,9),D^=U(l+g|0,13),B^=U(D+l|0,18),b^=U(S+u|0,7),c^=U(b+S|0,9),u^=U(c+b|0,13),S^=U(u+c|0,18),a^=U(h+f|0,7),_^=U(a+h|0,9),f^=U(_+a|0,13),h^=U(f+_|0,18),x^=U(e+i|0,7),F^=U(x+e|0,9),i^=U(F+x|0,13),e^=U(i+F|0,18),u^=U(B+x|0,7),_^=U(u+B|0,9),x^=U(_+u|0,13),B^=U(x+_|0,18),f^=U(S+g|0,7),F^=U(f+S|0,9),g^=U(F+f|0,13),S^=U(g+F|0,18),i^=U(h+b|0,7),l^=U(i+h|0,9),b^=U(l+i|0,13),h^=U(b+l|0,18),D^=U(e+a|0,7),c^=U(D+e|0,9),a^=U(c+D|0,13),e^=U(a+c|0,18);let k=0;Q[k++]=V+B|0,Q[k++]=W+u|0,Q[k++]=q+_|0,Q[k++]=z+x|0,Q[k++]=M+g|0,Q[k++]=N+S|0,Q[k++]=K+f|0,Q[k++]=H+F|0,Q[k++]=I+l|0,Q[k++]=R+b|0,Q[k++]=P+h|0,Q[k++]=w+i|0,Q[k++]=T+D|0,Q[k++]=j+c|0,Q[k++]=C+a|0,Q[k++]=L+e|0}function WX($,Z,J,Q){let X=$[0],Y=Z[0],V=Z[1],W=Z[2],q=Z[3],z=$[1],M=J[0],N=J[1],K=J[2],H=J[3],I=$[2],R=Z[4],P=Z[5],w=Z[6],T=Z[7],j=$[3];for(let L=0;L<20;L+=2)q^=U(X+P|0,7),K^=U(q+X|0,9),P^=U(K+q|0,13),X^=U(P+K|0,18),H^=U(z+Y|0,7),w^=U(H+z|0,9),Y^=U(w+H|0,13),z^=U(Y+w|0,18),T^=U(I+M|0,7),V^=U(T+I|0,9),M^=U(V+T|0,13),I^=U(M+V|0,18),W^=U(j+R|0,7),N^=U(W+j|0,9),R^=U(N+W|0,13),j^=U(R+N|0,18),Y^=U(X+W|0,7),V^=U(Y+X|0,9),W^=U(V+Y|0,13),X^=U(W+V|0,18),M^=U(z+q|0,7),N^=U(M+z|0,9),q^=U(N+M|0,13),z^=U(q+N|0,18),R^=U(I+H|0,7),K^=U(R+I|0,9),H^=U(K+R|0,13),I^=U(H+K|0,18),P^=U(j+T|0,7),w^=U(P+j|0,9),T^=U(w+P|0,13),j^=U(T+w|0,18);let C=0;Q[C++]=X,Q[C++]=z,Q[C++]=I,Q[C++]=j,Q[C++]=M,Q[C++]=N,Q[C++]=K,Q[C++]=H}var v$=lZ(GX,{counterRight:!0,extendNonceFn:WX}),y$=gZ({blockSize:64,nonceLength:24,tagLength:16},($,Z)=>{return{encrypt(J,Q){Q=S$(J.length+32,Q,!1);let X=Q.subarray(0,32),Y=Q.subarray(32);Q.set(J,32),X0(X),v$($,Z,Q,Q);let V=f$(Y,X);return Q.set(V,16),X0(Q.subarray(0,16),V),Q.subarray(16)},decrypt(J,Q){p(J),Q=S$(J.length+32,Q,!1);let X=Q.subarray(0,32),Y=Q.subarray(32,48),V=Q.subarray(48);Q.set(J,32),X0(X);let W=v$($,Z,X,X),q=f$(V,W);if(!SZ(Y,q))throw Error("invalid tag");return v$($,Z,Q.subarray(16),Q.subarray(16)),X0(X,Y,q),V}}});/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function qX($){return $ instanceof Uint8Array||ArrayBuffer.isView($)&&$.constructor.name==="Uint8Array"}function o0($){if(!Number.isSafeInteger($)||$<0)throw Error("positive integer expected, got "+$)}function w0($,...Z){if(!qX($))throw Error("Uint8Array expected");if(Z.length>0&&!Z.includes($.length))throw Error("Uint8Array expected of length "+Z+", got length="+$.length)}function a0($,Z=!0){if($.destroyed)throw Error("Hash instance has been destroyed");if(Z&&$.finished)throw Error("Hash#digest() has already been called")}function G$($,Z){w0($);let J=Z.outputLen;if($.length<J)throw Error("digestInto() expects output buffer of length at least "+J)}function hZ($){return new Uint8Array($.buffer,$.byteOffset,$.byteLength)}function g0($){return new Uint32Array($.buffer,$.byteOffset,Math.floor($.byteLength/4))}function f0(...$){for(let Z=0;Z<$.length;Z++)$[Z].fill(0)}function s0($,Z){return $<<32-Z|$>>>Z}var iZ=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function pZ($){return $<<24&4278190080|$<<8&16711680|$>>>8&65280|$>>>24&255}var uZ=iZ?($)=>$:($)=>pZ($);function zX($){for(let Z=0;Z<$.length;Z++)$[Z]=pZ($[Z]);return $}var s=iZ?($)=>$:zX;function MX($){if(typeof $!=="string")throw Error("string expected");return new Uint8Array(new TextEncoder().encode($))}function v0($){if(typeof $==="string")$=MX($);return w0($),$}class l${}function dZ($){let Z=(Q,X)=>$(X).update(v0(Q)).digest(),J=$({});return Z.outputLen=J.outputLen,Z.blockLen=J.blockLen,Z.create=(Q)=>$(Q),Z}var nZ=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var W$=BigInt(4294967295),cZ=BigInt(32);function b$($,Z=!1){if(Z)return{h:Number($&W$),l:Number($>>cZ&W$)};return{h:Number($>>cZ&W$)|0,l:Number($&W$)|0}}function M0($,Z,J,Q,X){return $=$+Z+X|0,Q=s0(Q^$,16),J=J+Q|0,Z=s0(Z^J,12),{a:$,b:Z,c:J,d:Q}}function N0($,Z,J,Q,X){return $=$+Z+X|0,Q=s0(Q^$,8),J=J+Q|0,Z=s0(Z^J,7),{a:$,b:Z,c:J,d:Q}}class h$ extends l${constructor($,Z){super();this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,o0($),o0(Z),this.blockLen=$,this.outputLen=Z,this.buffer=new Uint8Array($),this.buffer32=g0(this.buffer)}update($){a0(this),$=v0($),w0($);let{blockLen:Z,buffer:J,buffer32:Q}=this,X=$.length,Y=$.byteOffset,V=$.buffer;for(let W=0;W<X;){if(this.pos===Z)s(Q),this.compress(Q,0,!1),s(Q),this.pos=0;let q=Math.min(Z-this.pos,X-W),z=Y+W;if(q===Z&&!(z%4)&&W+q<X){let M=new Uint32Array(V,z,Math.floor((X-W)/4));s(M);for(let N=0;W+Z<X;N+=Q.length,W+=Z)this.length+=Z,this.compress(M,N,!1);s(M);continue}J.set($.subarray(W,W+q),this.pos),this.pos+=q,this.length+=q,W+=q}return this}digestInto($){a0(this),G$($,this);let{pos:Z,buffer32:J}=this;this.finished=!0,f0(this.buffer.subarray(Z)),s(J),this.compress(J,0,!0),s(J);let Q=g0($);this.get().forEach((X,Y)=>Q[Y]=uZ(X))}digest(){let{buffer:$,outputLen:Z}=this;this.digestInto($);let J=$.slice(0,Z);return this.destroy(),J}_cloneInto($){let{buffer:Z,length:J,finished:Q,destroyed:X,outputLen:Y,pos:V}=this;return $||($=new this.constructor({dkLen:Y})),$.set(...this.get()),$.buffer.set(Z),$.destroyed=X,$.finished=Q,$.length=J,$.pos=V,$.outputLen=Y,$}clone(){return this._cloneInto()}}function i$($,Z,J,Q,X,Y,V,W,q,z,M,N,K,H,I,R,P,w,T,j){let C=0;for(let L=0;L<Q;L++)({a:X,b:q,c:K,d:P}=M0(X,q,K,P,J[Z+$[C++]])),{a:X,b:q,c:K,d:P}=N0(X,q,K,P,J[Z+$[C++]]),{a:Y,b:z,c:H,d:w}=M0(Y,z,H,w,J[Z+$[C++]]),{a:Y,b:z,c:H,d:w}=N0(Y,z,H,w,J[Z+$[C++]]),{a:V,b:M,c:I,d:T}=M0(V,M,I,T,J[Z+$[C++]]),{a:V,b:M,c:I,d:T}=N0(V,M,I,T,J[Z+$[C++]]),{a:W,b:N,c:R,d:j}=M0(W,N,R,j,J[Z+$[C++]]),{a:W,b:N,c:R,d:j}=N0(W,N,R,j,J[Z+$[C++]]),{a:X,b:z,c:I,d:j}=M0(X,z,I,j,J[Z+$[C++]]),{a:X,b:z,c:I,d:j}=N0(X,z,I,j,J[Z+$[C++]]),{a:Y,b:M,c:R,d:P}=M0(Y,M,R,P,J[Z+$[C++]]),{a:Y,b:M,c:R,d:P}=N0(Y,M,R,P,J[Z+$[C++]]),{a:V,b:N,c:K,d:w}=M0(V,N,K,w,J[Z+$[C++]]),{a:V,b:N,c:K,d:w}=N0(V,N,K,w,J[Z+$[C++]]),{a:W,b:q,c:H,d:T}=M0(W,q,H,T,J[Z+$[C++]]),{a:W,b:q,c:H,d:T}=N0(W,q,H,T,J[Z+$[C++]]);return{v0:X,v1:Y,v2:V,v3:W,v4:q,v5:z,v6:M,v7:N,v8:K,v9:H,v10:I,v11:R,v12:P,v13:w,v14:T,v15:j}}var Y0={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},O0=nZ.slice(),rZ=(()=>{let $=Array.from({length:16},(Q,X)=>X),Z=(Q)=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map((X)=>Q[X]),J=[];for(let Q=0,X=$;Q<7;Q++,X=Z(X))J.push(...X);return Uint8Array.from(J)})();class p$ extends h${constructor($={},Z=0){super(64,$.dkLen===void 0?32:$.dkLen);this.chunkPos=0,this.chunksDone=0,this.flags=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0;let{key:J,context:Q}=$,X=Q!==void 0;if(J!==void 0){if(X)throw Error('Only "key" or "context" can be specified at same time');let Y=v0(J).slice();w0(Y,32),this.IV=g0(Y),s(this.IV),this.flags=Z|Y0.KEYED_HASH}else if(X){let Y=v0(Q),V=new p$({dkLen:32},Y0.DERIVE_KEY_CONTEXT).update(Y).digest();this.IV=g0(V),s(this.IV),this.flags=Z|Y0.DERIVE_KEY_MATERIAL}else this.IV=O0.slice(),this.flags=Z;this.state=this.IV.slice(),this.bufferOut=hZ(this.bufferOut32)}get(){return[]}set(){}b2Compress($,Z,J,Q=0){let{state:X,pos:Y}=this,{h:V,l:W}=b$(BigInt($),!0),{v0:q,v1:z,v2:M,v3:N,v4:K,v5:H,v6:I,v7:R,v8:P,v9:w,v10:T,v11:j,v12:C,v13:L,v14:B,v15:u}=i$(rZ,Q,J,7,X[0],X[1],X[2],X[3],X[4],X[5],X[6],X[7],O0[0],O0[1],O0[2],O0[3],V,W,Y,Z);X[0]=q^P,X[1]=z^w,X[2]=M^T,X[3]=N^j,X[4]=K^C,X[5]=H^L,X[6]=I^B,X[7]=R^u}compress($,Z=0,J=!1){let Q=this.flags;if(!this.chunkPos)Q|=Y0.CHUNK_START;if(this.chunkPos===15||J)Q|=Y0.CHUNK_END;if(!J)this.pos=this.blockLen;if(this.b2Compress(this.chunksDone,Q,$,Z),this.chunkPos+=1,this.chunkPos===16||J){let X=this.state;this.state=this.IV.slice();for(let Y,V=this.chunksDone+1;J||!(V&1);V>>=1){if(!(Y=this.stack.pop()))break;this.buffer32.set(Y,0),this.buffer32.set(X,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|Y0.PARENT,this.buffer32,0),X=this.state,this.state=this.IV.slice()}this.chunksDone++,this.chunkPos=0,this.stack.push(X)}this.pos=0}_cloneInto($){$=super._cloneInto($);let{IV:Z,flags:J,state:Q,chunkPos:X,posOut:Y,chunkOut:V,stack:W,chunksDone:q}=this;return $.state.set(Q.slice()),$.stack=W.map((z)=>Uint32Array.from(z)),$.IV.set(Z),$.flags=J,$.chunkPos=X,$.chunksDone=q,$.posOut=Y,$.chunkOut=V,$.enableXOF=this.enableXOF,$.bufferOut32.set(this.bufferOut32),$}destroy(){this.destroyed=!0,f0(this.state,this.buffer32,this.IV,this.bufferOut32),f0(...this.stack)}b2CompressOut(){let{state:$,pos:Z,flags:J,buffer32:Q,bufferOut32:X}=this,{h:Y,l:V}=b$(BigInt(this.chunkOut++));s(Q);let{v0:W,v1:q,v2:z,v3:M,v4:N,v5:K,v6:H,v7:I,v8:R,v9:P,v10:w,v11:T,v12:j,v13:C,v14:L,v15:B}=i$(rZ,0,Q,7,$[0],$[1],$[2],$[3],$[4],$[5],$[6],$[7],O0[0],O0[1],O0[2],O0[3],V,Y,Z,J);X[0]=W^R,X[1]=q^P,X[2]=z^w,X[3]=M^T,X[4]=N^j,X[5]=K^C,X[6]=H^L,X[7]=I^B,X[8]=$[0]^R,X[9]=$[1]^P,X[10]=$[2]^w,X[11]=$[3]^T,X[12]=$[4]^j,X[13]=$[5]^C,X[14]=$[6]^L,X[15]=$[7]^B,s(Q),s(X),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,f0(this.buffer.subarray(this.pos));let $=this.flags|Y0.ROOT;if(this.stack.length)$|=Y0.PARENT,s(this.buffer32),this.compress(this.buffer32,0,!0),s(this.buffer32),this.chunksDone=0,this.pos=this.blockLen;else $|=(!this.chunkPos?Y0.CHUNK_START:0)|Y0.CHUNK_END;this.flags=$,this.b2CompressOut()}writeInto($){a0(this,!1),w0($),this.finish();let{blockLen:Z,bufferOut:J}=this;for(let Q=0,X=$.length;Q<X;){if(this.posOut>=Z)this.b2CompressOut();let Y=Math.min(Z-this.posOut,X-Q);$.set(J.subarray(this.posOut,this.posOut+Y),Q),this.posOut+=Y,Q+=Y}return $}xofInto($){if(!this.enableXOF)throw Error("XOF is not possible after digest call");return this.writeInto($)}xof($){return o0($),this.xofInto(new Uint8Array($))}digestInto($){if(G$($,this),this.finished)throw Error("digest() was already called");return this.enableXOF=!1,this.writeInto($),this.destroy(),$}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}var oZ=dZ(($)=>new p$($));function $0($){return Array.from($).map((J)=>J.toString(16).padStart(2,"0")).join("")}function q$($){if($.length%2!==0)throw Error("Invalid hex string");let Z=new Uint8Array($.length/2);for(let J=0;J<$.length;J+=2)Z[J/2]=Number.parseInt($.substr(J,2),16);return Z}function y0($,Z){if($===Z)return!0;if($.byteLength!==Z.byteLength)return!1;return $.every((J,Q)=>J===Z[Q])}var aZ;if(typeof Uint8Array.prototype.toBase64==="function")aZ=($)=>$.toBase64();else aZ=($)=>btoa(String.fromCharCode(...$));var u$;if(typeof Uint8Array.fromBase64==="function")u$=($)=>Uint8Array.fromBase64($);else u$=($)=>Uint8Array.from(atob($),(Z)=>Z.charCodeAt(0));function sZ($){let Z=$.length%4===0?"":"=".repeat(4-$.length%4),J=$.replace(/-/g,"+").replace(/_/g,"/")+Z;return u$(J)}function K0($,Z){let J=new Uint8Array($.length+Z.length);return J.set($,0),J.set(Z,$.length),J}var l0=64;var tZ=32,b0=8;var eZ=32;var $J=30000,ZJ=512,A;((F)=>{F[F.Success=0]="Success";F[F.InvalidSignature=3]="InvalidSignature";F[F.ClockOutOfSync=4]="ClockOutOfSync";F[F.UserNotRegistered=5]="UserNotRegistered";F[F.ServerMisconfigured=6]="ServerMisconfigured";F[F.MissingBody=7]="MissingBody";F[F.ExtraBodyContent=8]="ExtraBodyContent";F[F.MissingParam=9]="MissingParam";F[F.InvalidParam=10]="InvalidParam";F[F.InvalidRequest=11]="InvalidRequest";F[F.InternalError=12]="InternalError";F[F.NotFound=13]="NotFound";F[F.InvalidMessage=14]="InvalidMessage";F[F.NoChange=15]="NoChange";F[F.DatabaseClosed=16]="DatabaseClosed";F[F.StorageError=17]="StorageError";F[F.DatabaseError=18]="DatabaseError";F[F.HashMismatch=19]="HashMismatch";F[F.DecryptionError=20]="DecryptionError";F[F.NotImplemented=21]="NotImplemented";F[F.MissingSeed=22]="MissingSeed";F[F.OutOfBounds=23]="OutOfBounds";F[F.HostError=24]="HostError";F[F.CommunicationError=25]="CommunicationError";F[F.VarLimitExceeded=26]="VarLimitExceeded";F[F.InvalidResponse=27]="InvalidResponse";F[F.ConnectionClosed=28]="ConnectionClosed";F[F.CryptoError=29]="CryptoError";F[F.WebAuthnError=30]="WebAuthnError"})(A||={});var JJ="t";function O($){return[$,0]}function G($){return[void 0,$]}var NX=32,$G=Symbol("X25519Sk");function QJ($){if($.byteLength!==NX)return G(10);return O($)}var E=(1n<<255n)-19n,OX=121665n,XJ=new Uint8Array(32);XJ[0]=9;function YJ($){let Z=0n;for(let J=$.length-1;J>=0;J--)Z=Z<<8n|BigInt($[J]);return Z}function KX($){let Z=new Uint8Array(32),J=($%E+E)%E;for(let Q=0;Q<32;Q++)Z[Q]=Number(J&0xffn),J>>=8n;return Z}function HX($){let Z=$.slice();return Z[31]&=127,YJ(Z)}function FX($){let Z=$.slice();return Z[0]&=248,Z[31]&=127,Z[31]|=64,Z}function z$($,Z,J){let Q=-$,X=(Z^J)&Q;return[Z^X,J^X]}function RX($){let Z=E-2n,J=($%E+E)%E,Q=1n;while(Z>0n){if(Z&1n)Q=Q*J%E;J=J*J%E,Z>>=1n}return Q}function IX($,Z){let J=FX($),Q=HX(Z),X=1n,Y=0n,V=Q,W=1n,q=0n,z=YJ(J);for(let M=254;M>=0;M--){let N=z>>BigInt(M)&1n;q^=N,[X,V]=z$(q,X,V),[Y,W]=z$(q,Y,W),q=N;let K=(X+Y)%E,H=K*K%E,I=(X-Y+E)%E,R=I*I%E,P=(H-R+E)%E,w=(V+W)%E,j=(V-W+E)%E*K%E,C=w*I%E,L=(j+C)%E,B=(j-C+E)%E;V=L*L%E,W=Q*B*B%E,X=H*R%E,Y=P*(H+OX*P)%E}return[X,V]=z$(q,X,V),[Y,W]=z$(q,Y,W),J.fill(0),KX(X*RX(Y)%E)}function VJ($){return IX($,XJ)}var d$=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32]);function GJ($){let Z=new Uint8Array(d$.length+32);return Z.set(d$),Z.set($.subarray(0,32),d$.length),Z}var n$=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);function WJ($){let Z=new Uint8Array(n$.length+32);return Z.set(n$),Z.set($.subarray(0,32),n$.length),Z}function qJ($){return typeof $==="string"?new TextEncoder().encode($):$}function H0($){let Z=new ArrayBuffer($.byteLength);return new Uint8Array(Z).set($),Z}class T0{verifyKeys=new Map;async genRandomBytes($){return r0($)}async gen256BitSecureRandomSeed(){return r0(32)}async encryptXSalsa20Poly1305Combined($,Z){let J=r0(24),X=y$(Z,J).encrypt($);return new Uint8Array([...J,...X])}async decryptXSalsa20Poly1305Combined($,Z){let J=$.slice(0,24),Q=$.slice(24);return y$(Z,J).decrypt(Q)}async deriveEd25519KeyPair($){let Z=$,J=GJ(Z),Q=H0(J),X;try{let z=await globalThis.crypto.subtle.importKey("pkcs8",Q,{name:"Ed25519"},!0,["sign"]);X=await globalThis.crypto.subtle.exportKey("jwk",z)}finally{J.fill(0),new Uint8Array(Q).fill(0)}if(typeof X.x!=="string")throw Error("Ed25519 JWK missing x");let Y=X.x;X.d=void 0;let V=await globalThis.crypto.subtle.importKey("jwk",{kty:"OKP",crv:"Ed25519",x:Y},{name:"Ed25519"},!0,["verify"]),W=new Uint8Array(await globalThis.crypto.subtle.exportKey("raw",V));this.verifyKeys.set($0(W),V);let q=new Uint8Array(64);return q.set(Z,0),q.set(W,32),{keyType:"ed25519",privateKey:q,publicKey:W}}async importSignKey($){let Z=$.subarray(0,32),J=GJ(Z),Q=H0(J);try{return await globalThis.crypto.subtle.importKey("pkcs8",Q,{name:"Ed25519"},!1,["sign"])}finally{J.fill(0),new Uint8Array(Q).fill(0)}}async importVerifyKey($){let Z=$0($),J=this.verifyKeys.get(Z);if(J)return J;let Q=await globalThis.crypto.subtle.importKey("raw",H0($),{name:"Ed25519"},!1,["verify"]);return this.verifyKeys.set(Z,Q),Q}async signEd25519($,Z){let J=qJ($),Q=await this.importSignKey(Z),X=await globalThis.crypto.subtle.sign({name:"Ed25519"},Q,H0(J));return new Uint8Array(X)}async checkSigEd25519($,Z,J){let Q=qJ(Z);try{let X=await this.importVerifyKey(J);return await globalThis.crypto.subtle.verify({name:"Ed25519"},X,H0($),H0(Q))}catch{return!1}}async blake3($){return oZ($)}async genX25519(){let $=await r0(32);$[0]&=248,$[31]&=127,$[31]|=64;let[Z,J]=QJ($);if(J!==0||Z===void 0)throw $.fill(0),Error("X25519 scalar brand failed");let Q=VJ(Z),X=WJ(Z),Y=H0(X);try{let V=await globalThis.crypto.subtle.importKey("pkcs8",Y,{name:"X25519"},!0,["deriveBits"]),W=await globalThis.crypto.subtle.exportKey("jwk",V);if(typeof W.x!=="string")throw Error("X25519 JWK missing x");let q=sZ(W.x);if(W.d=void 0,!y0(q,Q))throw Error("X25519 WebCrypto pub != RFC 7748");return{priv:Z,pub:Q}}catch(V){throw Z.fill(0),V}finally{X.fill(0),new Uint8Array(Y).fill(0)}}async x25519Shared($,Z){let J=WJ($),Q=H0(J);try{let X=await globalThis.crypto.subtle.importKey("pkcs8",Q,{name:"X25519"},!1,["deriveBits"]),Y=await globalThis.crypto.subtle.importKey("raw",H0(Z),{name:"X25519"},!1,[]),V=await globalThis.crypto.subtle.deriveBits({name:"X25519",public:Y},X,256);return new Uint8Array(V)}finally{J.fill(0),new Uint8Array(Q).fill(0)}}}var PX=new T0,h0=PX;function UX($){if($<0)console.info("N",$),console.trace();if(typeof $!=="bigint")$=BigInt($);if($<0n)return G(10);let Z=[];while($>0n){let J=Number($&0x7fn);if($>>=7n,$>0n)Z.push(J|128);else Z.push(J)}if(Z.length===0)return O(new Uint8Array([0]));if(Z.length>8)return G(26);return O(new Uint8Array(Z))}function CX($,Z=0){let J=0n,Q=0,X=Z;while(!0){if(X>=$.length)return G(14);let Y=$[X++];if(Y===void 0)return G(14);if(J|=BigInt(Y&127)<<BigInt(Q),(Y&128)===0){if(X-Z>8)return G(26);return O({value:J>0x1fffffffffffffn?J:Number(J),bytesRead:X-Z})}if(Q+=7,Q>=56)return G(26)}}class v{data;pos=0;constructor($){this.data=$}static async fromResponse($){let Z=await $.arrayBuffer(),J=new Uint8Array(Z);return new v(J)}readBigInt(){if(this.pos+8>this.data.length)return G(7);let $=new DataView(this.data.buffer,this.data.byteOffset+this.pos).getBigUint64(0,!1);return this.pos+=8,O($)}readDate(){let[$,Z]=this.readVarInt();if(Z!==0)return G(Z);return O(new Date($))}readVarInt(){let[$,Z]=CX(this.data,this.pos);if(Z!==0)return G(Z);this.pos+=$.bytesRead;let J=$.value;return O(typeof J==="bigint"?Number(J):J)}readVarString(){let[$,Z]=this.readVarInt();if(Z!==0)return G(Z);let[J,Q]=this.readBytes($);if(Q!==0)return G(Q);let X=new TextDecoder().decode(J);return O(X)}readBytes($){if($<0)return G(10);if(this.pos+$>this.data.length)return G(23);let Z=this.data.slice(this.pos,this.pos+$);return this.pos+=$,O(Z)}readVarBytes(){let[$,Z]=this.readVarInt();if(Z!==0)return G(Z);return this.readBytes($)}readStruct($){return $.decode(this)}readStructs($){let Z=[];while(!this.done()){let[J,Q]=this.readStruct($);if(Q!==0)return G(Q);Z.push(J)}return O(Z)}readBytesSeq($){let Z=[];while(!this.done()){let[J,Q]=this.readBytes($);if(Q!==0)return G(Q);Z.push(J)}return O(Z)}done(){return this.pos>=this.data.length}consumed(){return this.pos}}class m{parts=[];writeBigInt($){let Z=new Uint8Array(8);new DataView(Z.buffer).setBigUint64(0,$,!1),this.parts.push(Z)}writeDate($){let Z=$.getTime();return this.writeVarInt(Z)}writeVarInt($){let[Z,J]=UX($);if(J!==0)return J;return this.parts.push(Z),0}writeVarString($){let Z=new TextEncoder().encode($),J=this.writeVarInt(Z.length);if(J!==0)return J;return this.writeBytes(Z),0}prependBytes($){this.parts.unshift($.slice())}writeBytes($){this.parts.push($.slice())}writeVarBytes($){let Z=this.writeVarInt($.length);if(Z!==0)return Z;return this.writeBytes($),0}writeStruct($,Z){return $.encode(this,Z)}writeStructs($,Z){for(let J of Z){let Q=this.writeStruct($,J);if(Q!==0)return Q}return 0}writeBytesSeq($){for(let Z of $)this.writeBytes(Z)}result(){let $=this.parts.reduce((Q,X)=>Q+X.length,0),Z=new Uint8Array($),J=0;for(let Q of this.parts)Z.set(Q,J),J+=Q.length;return Z}wipe(){for(let $ of this.parts)$.fill(0);this.parts.length=0}*scan(){for(let $ of this.parts)yield $}}var t0={encode($,Z){let J=$.writeVarBytes(Z.id);if(J!==0)return J;let Q=$.writeDate(Z.ts);if(Q!==0)return Q;return 0},decode($){let[Z,J]=$.readVarBytes();if(J!==0)return G(J);let[Q,X]=$.readDate();if(X!==0)return G(X);return O({id:Z,ts:Q})}};function zJ($){let Z=new m,J=Z.writeStruct(t0,$);if(J!==0)return G(J);let Q=Z.result();return O(Q)}var c$={encode($,Z){let J=$.writeVarBytes(Z.eid);if(J!==0)return J;let Q=$.writeVarInt(Z.off);if(Q!==0)return Q;let X=$.writeVarInt(Z.ctr);if(X!==0)return X;let Y=$.writeVarInt(Z.len);if(Y!==0)return Y;if(Z.hsh)$.writeBytes(Z.hsh);return 0},decode($){let[Z,J]=$.readVarBytes();if(J!==0)return G(J);let Q=new v(Z),[,X]=t0.decode(Q);if(X!==0)return G(X);let[Y,V]=$.readVarInt();if(V!==0)return G(V);let[W,q]=$.readVarInt();if(q!==0)return G(q);let[z,M]=$.readVarInt();if(M!==0)return G(M);let N;if(z>0){let[K,H]=$.readBytes(eZ);if(H!==0)return G(H);N=K}return O({eid:Z,off:Y,ctr:W,len:z,hsh:N})}};function MJ($,Z,J){return J.checkSigEd25519($.sig,$.headCph,Z)}async function NJ($,Z,J,Q){let X;if($.bod&&$.len>0)X=await J.blake3($.bod);let Y=new m,V=c$.encode(Y,{...$,hsh:X});if(V!==0)return G(V);let W=Y.result(),q=await Z.kdmFor(W),z=Q.deriveCipher(q,"encrypt"),M=await z.encrypt(W),N=$.bod?await z.encrypt($.bod):new Uint8Array(0),K=await Z.sign(M);return O({sig:K,kdm:q,headCph:M,bodyCph:N})}async function OJ($,Z,J,Q,X){let Y=new v($),[V,W]=c$.decode(Y);if(W!==0)return G(14);let q;try{q=Z&&Z.length>0?await J.decrypt(Z):void 0}catch{return G(20)}let z=V.hsh&&q===void 0,M=V.hsh===void 0&&q!==void 0;if(z||M)return G(19);if(V.hsh&&q){let K=await Q.blake3(q);if(!y0(K,V.hsh))return G(19)}let N=X??await Q.blake3($);return O({msgHead:V,bod:q,headHash:N})}async function r$($,Z){let J=new m,Q=J.writeDate(Z);if(Q!==0)return G(Q);let X=J.result(),Y=await $.sign(X);return O({pubKey:$.publicKey,sig:Y,timestamp:Z})}async function J0($,Z,J){let Q=J.now().getTime(),X=$.timestamp.getTime();if(Math.abs(Q-X)>$J)return 4;let V=new m;V.writeDate($.timestamp);let W=V.result();if(!await Z.checkSigEd25519($.sig,W,$.pubKey))return 3;return 0}class i0{now(){return new Date}}function KJ($,Z,J,Q){let X=Z.getTime()-$.getTime(),Y=J.getTime()-Q.getTime();return(X+Y)/2}var e0={encode($,Z){if($.writeVarInt(Z.quota),Z.quota>0){if(Z.usage===void 0)return 9;$.writeVarInt(Z.usage)}return 0},decode($){let[Z,J]=$.readVarInt();if(J!==0)return G(J);let Q;if(Z>0){let[X,Y]=$.readVarInt();if(Y!==0)return G(Y);Q=X}return O({quota:Z,usage:Q})}};var p0={encode($,Z){$.writeBytes(new Uint8Array([Z.status]));let J=$.writeDate(Z.timeRcvd);if(J!==0)return J;let Q=$.writeDate(Z.timeSent);if(Q!==0)return Q;let X=$.writeVarInt(Z.subscription.term);if(X!==0)return X;let Y=$.writeVarInt(Z.subscription.elapsed);if(Y!==0)return Y;let V=$.writeStruct(e0,Z.subscription.stat);if(V!==0)return V;let W=$.writeStruct(e0,Z.subscription.dyn);if(W!==0)return W;return 0},decode($){let[Z,J]=$.readBytes(1);if(J!==0)return G(J);let Q=Z[0],[X,Y]=$.readDate();if(Y!==0)return G(Y);let[V,W]=$.readDate();if(W!==0)return G(W);let[q,z]=$.readVarInt();if(z!==0)return G(z);let[M,N]=$.readVarInt();if(N!==0)return G(N);let[K,H]=$.readStruct(e0);if(H!==0)return G(H);let[I,R]=$.readStruct(e0);if(R!==0)return G(R);return O({status:Q,timeRcvd:X,timeSent:V,subscription:{term:q,elapsed:M,stat:K,dyn:I}})}};var o$={encode($,Z){let J=$.writeVarBytes(Z.headCph);if(J!==0)return J;let Q=$.writeVarInt(Z.seq);if(Q!==0)return Q;return 0},decode($){let[Z,J]=$.readVarBytes();if(J!==0)return G(J);let[Q,X]=$.readVarInt();if(X!==0)return G(X);return O({headCph:Z,seq:Q})}};var o={encode($,Z){$.writeBytes(Z.pubKey),$.writeBytes(Z.sig);let J=$.writeDate(Z.timestamp);if(J!==0)return J;return 0},decode($){let[Z,J]=$.readBytes(tZ);if(J!==0)return G(J);let[Q,X]=$.readBytes(l0);if(X!==0)return G(X);let[Y,V]=$.readDate();if(V!==0)return G(V);return O({pubKey:Z,sig:Q,timestamp:Y})}};var HJ={async encodeReq($,Z,J,Q,X){let Y=X.writeStruct(o,J);if(Y!==0)return Y;for(let V of Q)X.writeVarInt(V);return 0},async handleReq($,Z,J){let{clock:Q,crypto:X,storage:Y}=$,[V,W]=Z.readStruct(o);if(W!==0)return W;let q=await J0(V,X,Q);if(q!==0)return q;let{pubKey:z}=V,[M,N]=await Y.hasUser(z);if(N!==0)return N;if(!M)return 5;let[K,H]=Z.readVarInt();if(H!==0)return H;if(!Z.done())return 8;let[I,R]=await Y.listHeads(z,K);if(R!==0)return R;return J.writeStructs(o$,I)},decodeResp($){return $.readStructs(o$)}};var a$={encode($,Z){$.writeVarInt(Z.seq);let J=$.writeVarBytes(Z.bodyCph);if(J!==0)return J;return 0},decode($){let[Z,J]=$.readVarInt();if(J!==0)return G(J);let[Q,X]=$.readVarBytes();if(X!==0)return G(X);return O({seq:Z,bodyCph:Q})}};var FJ={async encodeReq($,Z,J,Q,X){let Y=X.writeStruct(o,J);if(Y!==0)return Y;for(let V of Q){let W=X.writeVarInt(V);if(W!==0)return W}return 0},async handleReq($,Z,J){let{clock:Q,crypto:X,storage:Y}=$,[V,W]=Z.readStruct(o);if(W!==0)return W;let q=await J0(V,X,Q);if(q!==0)return q;let{pubKey:z}=V,[M,N]=await Y.hasUser(z);if(N!==0)return N;if(!M)return 5;let K=[];while(!Z.done()){let[R,P]=Z.readVarInt();if(P!==0)return P;K.push(R)}console.info(`PULL: ${K.length} bags`);let[H,I]=await Y.getBodies(z,K);if(I!==0)return I;if(!H)return 17;for(let{seq:R,bodyCph:P}of H){let w={seq:R,bodyCph:P},T=J.writeStruct(a$,w);if(T!==0)return T}return 0},decodeResp($){return $.readStructs(a$)}};var s$={encode($,Z){$.writeBytes(Z.sig),$.writeBytes(Z.kdm);let J=$.writeVarBytes(Z.headCph);if(J!==0)return J;let Q=$.writeVarBytes(Z.bodyCph);if(Q!==0)return Q;return 0},decode($){let[Z,J]=$.readBytes(l0);if(J!==0)return G(J);let[Q,X]=$.readBytes(b0);if(X!==0)return G(X);let[Y,V]=$.readVarBytes();if(V!==0)return G(V);let[W,q]=$.readVarBytes();if(q!==0)return G(q);return O({sig:Z,kdm:Q,headCph:Y,bodyCph:W})}};var t$={encode($,Z){let J=$.writeVarInt(Z.seq);if(J!==0)return J;let Q=$.writeVarBytes(Z.headCph);if(Q!==0)return Q;let X=Z.bodyCph?Z.bodyCph.length:0,Y=$.writeVarInt(X);if(Y!==0)return Y;if(X>0){if(!Z.bodyCph)return 10;$.writeBytes(Z.bodyCph)}return 0},decode($){let[Z,J]=$.readVarInt();if(J!==0)return G(J);let[Q,X]=$.readVarBytes();if(X!==0)return G(X);let[Y,V]=$.readVarInt();if(V!==0)return G(V);let W;if(Y>0){let[q,z]=$.readBytes(Y);if(z!==0)return G(z);W=q}return O({seq:Z,headCph:Q,bodyCph:W})}};var u0={encode($,Z){$.writeBytes(Z.sig),$.writeBytes(Z.kdm);let J=$.writeVarBytes(Z.headCph);if(J!==0)return J;return 0},decode($){let[Z,J]=$.readBytes(l0);if(J!==0)return G(J);let[Q,X]=$.readBytes(b0);if(X!==0)return G(X);let[Y,V]=$.readVarBytes();if(V!==0)return G(V);return O({sig:Z,kdm:Q,headCph:Y})}};var M$={encode($,Z){if($.writeVarInt(Z.idx),$.writeBytes(new Uint8Array([Z.status])),Z.status===0)$.writeVarInt(Z.seq);return 0},decode($){let[Z,J]=$.readVarInt();if(J!==0)return G(J);let[Q,X]=$.readBytes(1);if(X!==0)return G(X);let Y=Q[0];if(Y!==0)return O({idx:Z,status:Y});let[V,W]=$.readVarInt();if(W!==0)return G(W);return O({idx:Z,status:Y,seq:V})}};var RJ={async encodeReq($,Z,J,Q,X){let Y=X.writeStruct(o,J);if(Y!==0)return Y;let V=X.writeStructs(s$,Q);if(V!==0)return V;return 0},async handleReq($,Z,J){let{clock:Q,crypto:X,storage:Y,notifier:V}=$,[W,q]=Z.readStruct(o);if(q!==0)return q;let z=await J0(W,X,Q);if(z!==0)return z;let{pubKey:M}=W,[N,K]=await Y.hasUser(M);if(K!==0)return K;if(!N)return 5;let[H,I]=Z.readStructs(s$);if(I!==0)return I;console.info(`PUSH: ${H.length} bags`);let R=[],P=[];for(let C=0;C<H.length;C++){let L=H[C];if(!await MJ(L,M,X)){let u={idx:C,status:3},_=J.writeStruct(M$,u);if(_!==0)return _;continue}R.push(C),P.push(L)}let[w,T]=await Y.setBags(M,P);if(T!==0)return T;if(!w||w.length!==P.length)return 17;let j=[];for(let C=0;C<P.length;C++){let L=P[C],B=R[C],u=w[C],_=new m,x=_.writeStruct(u0,L);if(x!==0)return x;let g=_.result(),S={seq:u,headCph:g};if(H.length===1&&L.bodyCph.length<=ZJ)S.bodyCph=L.bodyCph;j.push(S);let f={idx:B,status:0,seq:u},F=J.writeStruct(M$,f);if(F!==0)return F}if(j.length>0){let C=new m,L=C.writeStructs(t$,j);if(L!==0)return L;let B=C.result();await Promise.resolve(V.push(M,B))}return 0},decodeResp($){return $.readStructs(M$)}};var IJ={async encodeReq($,Z,J,Q,X){return X.writeStruct(o,J)},async handleReq($,Z,J){let{clock:Q,crypto:X,storage:Y}=$,[V,W]=Z.readStruct(o);if(W!==0)return W;let q=await J0(V,X,Q);if(q!==0)return q;let{pubKey:z}=V;if(!Z.done())return 8;let[M,N]=await Y.addUser(z);if(N!==0)return N;return 0},decodeResp($){return O(void 0)}};class e${url;websocket;constructor($){this.url=$}connected(){return this.websocket!==void 0&&this.websocket.readyState===WebSocket.OPEN}async connect($,Z,J=()=>{},Q=()=>{}){let{url:X}=this;if(this.websocket)this.websocket.close(),this.websocket=void 0;let Y=new m;Y.writeStruct(o,$);let V=Y.result(),W=$0(V);return X.searchParams.set("t",W),this.websocket=new WebSocket(X),this.websocket.binaryType="arraybuffer",this.websocket.onopen=()=>{console.log("CONNECTED"),Q()},this.websocket.onclose=()=>{console.log("DISCONNECTED"),this.websocket=void 0,J()},this.websocket.onmessage=(q)=>{let z=new Uint8Array(q.data);Z(z)},this.websocket.onerror=(q)=>{console.log(`ERROR: ${JSON.stringify(q)}`),this.websocket=void 0,J()},Promise.resolve(0)}disconnect(){this.websocket?.close(),this.websocket=void 0}}var n={user:{path:"/user",endpoint:IJ,name:0},push:{path:"/push",endpoint:RJ,name:2},peek:{path:"/peek",endpoint:HJ,name:1},pull:{path:"/pull",endpoint:FJ,name:3}},wX={0:n.user,2:n.push,1:n.peek,3:n.pull},PJ={[n.user.path]:n.user,[n.push.path]:n.push,[n.peek.path]:n.peek,[n.pull.path]:n.pull};class UJ{url;listener;constructor($){this.url=$;this.listener=new e$($)}async call($,Z){let{path:J}=wX[$],Q=new URL(J,this.url);try{return await DX(Q,Z)}catch{return G(25)}}}var $Z=($)=>{return new UJ($.handle)};function d0($){let Z=new m;if(Z.writeStruct(p0,$)!==0)return new Response(null,{status:500});return ZZ(Z)}function ZZ($){let Z=$.result().slice();return new Response(Z,{status:200,headers:{"content-type":"application/octet-stream"}})}var TX={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,POST,OPTIONS"};function JZ($){return new Response($.body,{headers:{...$.headers,...TX},status:$.status,statusText:$.statusText})}async function DX($,Z){let J=await fetch($,{method:"POST",body:Z.result().slice()});if(!J.ok)return G(24);let Q=await v.fromResponse(J);return O(Q)}class N${enclave;crypto;host;clock;transport;updateHostMeta;constructor($,Z,J,Q,X,Y){this.enclave=$;this.crypto=Z;this.host=J;this.clock=Q;this.transport=X;this.updateHostMeta=Y}async call($,Z){let{clock:J,transport:Q}=this,{endpoint:X,name:Y}=$,V=await this.identity(),W=J.now(),[q,z]=await r$(V,W);if(z!==0)return G(z);let M=new m,N=await X.encodeReq(this,V,q,Z,M);if(N!==0)return G(N);let K=J.now(),[H,I]=await Q.call(Y,M),R=J.now();if(I!==0)return G(I);let[P,w]=H.readStruct(p0);if(w!==0)return G(w);if(P.status!==0)return G(P.status);let j={clockOffset:KJ(K,P.timeRcvd,P.timeSent,R),subscription:P.subscription},C=await this.updateHostMeta(j);if(C!==0)return G(C);return X.decodeResp(H)}identity=()=>{let{host:$,enclave:Z}=this;return Z.deriveIdentity($.label,$.idx??0)};seal=async($)=>{let{crypto:Z,enclave:J}=this,Q=await this.identity();return NJ($,Q,Z,J)};register=()=>this.call(n.user,[]);peek=($)=>this.call(n.peek,[$]);push=($)=>this.call(n.push,$);pull=($)=>this.call(n.pull,$);listen=async($,Z,J)=>{let{clock:Q,transport:X}=this,{listener:Y}=X,V=await this.identity(),W=Q.now(),[q,z]=await r$(V,W);if(z!==0)return z;return await Y.connect(q,$,Z,J)};isConnected(){let $=this.transport?.listener;if($&&typeof $.connected==="function")return $.connected();return!0}closeListener(){this.transport?.listener?.disconnect()}}var C8=Symbol("MasterSeed"),w8=Symbol("SealedMasterKey"),V0=32,CJ=24+V0+16;function t($){if($.byteLength!==V0)return G(10);return O($)}function O$($){if($.byteLength!==CJ)return G(10);return O($)}var D0={encode($,Z){let J=$.writeVarString(Z.handle);if(J!==0)return J;let Q=$.writeVarString(Z.label);if(Q!==0)return Q;return $.writeVarInt(Z.idx??0)},decode($){let[Z,J]=$.readVarString();if(J!==0)return G(J);let[Q,X]=$.readVarString();if(X!==0)return G(X);let[Y,V]=$.readVarInt();if(V!==0)return G(V);return O({handle:Z,label:Q,idx:Y})}};var K$=1,QZ={encode($,Z){if(Z.v!==K$)return 10;let[,J]=t(Z.masterSeed);if(J!==0)return J;let Q=$.writeVarInt(Z.v);if(Q!==0)return Q;$.writeBytes(Z.masterSeed);let X=$.writeVarInt(Z.hosts.length);if(X!==0)return X;for(let Y of Z.hosts){let V=$.writeStruct(D0,Y);if(V!==0)return V}return 0},decode($){let[Z,J]=$.readVarInt();if(J!==0)return G(J);if(Z!==K$)return G(14);let[Q,X]=$.readBytes(V0);if(X!==0)return G(X);if(Q===void 0)return G(14);let[Y,V]=t(Q);if(V!==0)return G(V);if(Y===void 0)return G(14);let[W,q]=$.readVarInt();if(q!==0)return G(q);if(W===void 0||W<0)return G(10);let z=[];for(let M=0;M<W;M++){let[N,K]=$.readStruct(D0);if(K!==0)return G(K);if(N===void 0)return G(14);z.push(N)}return O({v:K$,masterSeed:Y,hosts:z})}};function wJ($,Z){let[J,Q]=t($);if(Q!==0)return G(Q);if(J===void 0)return G(10);let[X,Y]=t(J.slice());if(Y!==0)return G(Y);if(X===void 0)return G(10);return O({v:K$,masterSeed:X,hosts:Z.map((V)=>({handle:V.handle,label:V.label,idx:V.idx??0}))})}var H$={encode($,Z){let[,J]=t(Z.masterSeed);if(J!==0)return J;$.writeBytes(Z.masterSeed);let Q=$.writeVarInt(Z.hosts.length);if(Q!==0)return Q;for(let X of Z.hosts){let Y=$.writeStruct(D0,X);if(Y!==0)return Y}return 0},decode($){let[Z,J]=$.readBytes(V0);if(J!==0)return G(J);if(Z===void 0)return G(14);let[Q,X]=t(Z);if(X!==0)return G(X);if(Q===void 0)return G(14);let[Y,V]=$.readVarInt();if(V!==0)return G(V);if(Y===void 0||Y<0)return G(10);let W=[];for(let q=0;q<Y;q++){let[z,M]=$.readStruct(D0);if(M!==0)return G(M);if(z===void 0)return G(14);W.push(z)}return O({masterSeed:Q,hosts:W})}};var AX=new TextEncoder().encode("diplomatic.qrpair.v1"),$$=32,jX=$$+24+16,LX=32,d8=Symbol("DHKEReq"),n8=Symbol("DHKEResp");function TJ($){if($.byteLength!==$$)return G(10);return O($)}function DJ($){if($.byteLength<jX)return G(10);return O($)}var F$=new T0;async function XZ($,Z,J,Q){let X;try{X=await F$.x25519Shared($,Z)}catch{return G(29)}try{if(X.byteLength!==$$||X.every((W)=>W===0))return G(10);let Y=K0(X,AX),V=K0(Y,K0(J,Q));try{let W=await F$.blake3(V);return O(W.slice(0,LX))}finally{Y.fill(0),V.fill(0)}}finally{X.fill(0)}}class R${#$;#Z;constructor($,Z){this.#$=$,this.#Z=Z}static async create(){let $;try{let Z=await F$.genX25519();$=Z.priv;let[J,Q]=TJ(Z.pub);if(Q!==0)return G(Q);if(J===void 0)return G(10);let X=new R$($,J);return $=void 0,O(X)}catch{return G(29)}finally{$?.fill(0)}}wipe(){this.#$.fill(0)}get dhkeReq(){let[$,Z]=TJ(this.#Z.slice());if($===void 0)throw Error(`dhkeReq ${Z}`);return $}async finish($){let Z=$.subarray(0,$$),J=$.subarray($$),[Q,X]=await XZ(this.#$,Z,this.#Z,Z);if(X!==0)return G(X);if(Q===void 0)return G(12);let Y;try{try{Y=await F$.decryptXSalsa20Poly1305Combined(J,Q)}catch{return G(20)}let V=new v(Y),[W,q]=V.readStruct(H$);if(q!==0)return G(q);if(W===void 0)return G(14);try{let[z,M]=Q0.fromBytes(W.masterSeed);if(M!==0)return G(M);if(z===void 0)return G(12);return this.wipe(),O({enclave:z,hosts:W.hosts.map((N)=>({...N}))})}finally{W.masterSeed.fill(0)}}finally{Q.fill(0),Y?.fill(0)}}}function F0($){let Z=new Uint8Array($);if($>0)crypto.getRandomValues(Z);return Z}var A0=32,I$="DIPLOMATIC",G0="public-key",EX=-7,mX=-8,_X=-257,P$=[{type:G0,alg:EX},{type:G0,alg:mX},{type:G0,alg:_X}];function BX($){return $.trim().toLowerCase().replace(/\.$/,"")||"localhost"}function R0($){let Z=new Uint8Array($.byteLength);return Z.set($),Z.buffer}function U$($){if($ instanceof ArrayBuffer)return new Uint8Array($).slice();return new Uint8Array($.buffer,$.byteOffset,$.byteLength).slice()}function j0($){if($?.rpId!==void 0)return O($.rpId);if(typeof location>"u")return G(9);return O(BX(location.hostname))}var AJ="";function U0($){if($ instanceof Error){AJ=$.message===""?$.name:`${$.name}: ${$.message}`;return}AJ=String($)}function L0(){if(typeof navigator>"u"||!navigator.credentials||typeof PublicKeyCredential>"u")return 24;return 0}function E0($){if($===null||$.type!==G0||!("rawId"in $)||typeof $.getClientExtensionResults!=="function")return G(27);return O($)}function VZ($){if($==="platform"||$==="cross-platform")return $;return}function GZ($){let Z=$.response;if(!("getTransports"in Z))return;let J=Z.getTransports;if(typeof J!=="function")return;let Q=J.call(Z);if(!Array.isArray(Q))return;let X=[];for(let Y of Q)if(typeof Y==="string"&&Y.length>0)X.push(Y);return X.length===0?void 0:X}var kX=32,xX=64,YZ=37,jJ=16;function LJ($){let Z=$.response;if(!("getAuthenticatorData"in Z))return;let J=Z.getAuthenticatorData;if(typeof J!=="function")return;let Q=J.call(Z);if(!(Q instanceof ArrayBuffer))return;let X=new Uint8Array(Q);if(X.byteLength<YZ+jJ)return;let Y=X[kX];if(Y===void 0||(Y&xX)===0)return;return X.slice(YZ,YZ+jJ)}async function EJ($){let Z=L0();if(Z!==0)return G(Z);let[J,Q]=j0($);if(Q!==0)return G(Q);if(J===void 0)return G(9);let X=$?.userName??"diplomatic-seed",Y={residentKey:"required",requireResidentKey:!0,userVerification:"required"};if($?.authenticatorAttachment!==void 0)Y.authenticatorAttachment=$.authenticatorAttachment;let V={largeBlob:{support:"required"}},W;try{W=await navigator.credentials.create({publicKey:{challenge:F0(A0),rp:{id:J,name:$?.rpName??I$},user:{id:F0(16),name:X,displayName:X},pubKeyCredParams:P$,authenticatorSelection:Y,extensions:V,...$?.hints!==void 0?{hints:$.hints}:{}}})}catch(N){return U0(N),G(30)}let[q,z]=E0(W);if(z!==0)return G(z);if(q===void 0)return G(27);if(q.getClientExtensionResults().largeBlob?.supported!==!0)return G(30);return O(new Uint8Array(q.rawId))}async function qZ($,Z,J){let Q=L0();if(Q!==0)return Q;let[X,Y]=j0(J);if(Y!==0)return Y;if(X===void 0)return 9;let V={largeBlob:{write:R0(Z)}},W;try{W=await navigator.credentials.get({publicKey:{challenge:F0(A0),rpId:X,allowCredentials:[{type:G0,id:R0($)}],userVerification:"required",extensions:V,...J?.hints!==void 0?{hints:J.hints}:{}}})}catch(N){return U0(N),30}let[q,z]=E0(W);if(z!==0)return z;if(q===void 0)return 27;if(q.getClientExtensionResults().largeBlob?.written!==!0)return 30;return 0}async function WZ($,Z,J,Q){let X={challenge:F0(A0),rpId:$,userVerification:"preferred"};if(Z?.hints!==void 0)X.hints=Z.hints;if(J!==void 0)X.allowCredentials=[{type:G0,id:R0(J)}];if(Q!==void 0)X.extensions=Q;let Y;try{Y=await navigator.credentials.get({publicKey:X})}catch(q){return U0(q),G(30)}let[V,W]=E0(Y);if(W!==0)return G(W);if(V===void 0)return G(27);return O(V)}async function mJ($,Z){let J=L0();if(J!==0)return G(J);let[Q,X]=j0(Z);if(X!==0)return G(X);if(Q===void 0)return G(9);let Y=$;if(Y===void 0){let[N,K]=await WZ(Q,Z);if(K!==0&&Z?.hints!==void 0)[N,K]=await WZ(Q,{rpId:Z.rpId,rpName:Z.rpName});if(K!==0)return G(K);if(N===void 0)return G(27);Y=new Uint8Array(N.rawId)}let[V,W]=await WZ(Q,Z,Y,{largeBlob:{read:!0}});if(W!==0)return G(W);if(V===void 0)return G(27);let z=V.getClientExtensionResults().largeBlob;if(z===void 0||z.blob===void 0)return G(7);let M=U$(z.blob);if(M.byteLength===0)return G(7);return O({blob:M,credId:new Uint8Array(V.rawId)})}var MZ=new TextEncoder().encode("diplomatic.prf.v1"),NZ="diplomatic-prf",zZ=32;function gX($){if($===void 0)return[];if($ instanceof Uint8Array)return[$];return $.filter((Z)=>Z.byteLength>0)}async function _J($){let Z=L0();if(Z!==0)return G(Z);let[J,Q]=j0($);if(Q!==0)return G(Q);if(J===void 0)return G(9);let X=$?.userName??NZ,Y=$?.displayName??X,V=F0(16),W=$?.authenticatorAttachment==="cross-platform",q={residentKey:W?"discouraged":"required",requireResidentKey:!W,userVerification:W?"preferred":"required"};if($?.authenticatorAttachment!==void 0)q.authenticatorAttachment=$.authenticatorAttachment;let z={challenge:F0(A0),rp:{id:J,name:$?.rpName??I$},user:{id:V,name:X,displayName:Y},pubKeyCredParams:P$,authenticatorSelection:q,...$?.hints!==void 0?{hints:$.hints}:{},...$?.excludeCredentials!==void 0&&$.excludeCredentials.length>0?{excludeCredentials:$.excludeCredentials.map((T)=>({type:G0,id:R0(T)}))}:{}},M=$?.salt!==void 0?R0($.salt):void 0,N=(T)=>navigator.credentials.create({publicKey:{...z,extensions:T&&M!==void 0?{prf:{eval:{first:M}}}:{prf:{}}}}),K;try{K=await N(M!==void 0)}catch(T){if(M===void 0||!fX(T))return U0(T),G(30);try{K=await N(!1)}catch(j){return U0(j),G(30)}}let[H,I]=E0(K);if(I!==0)return G(I);if(H===void 0)return G(27);let R=H.getClientExtensionResults(),P=BJ(R.prf?.results?.first),w=R.prf?.enabled===!0||P!==void 0;if(W&&P!==void 0)P.fill(0);return O({credId:new Uint8Array(H.rawId),userId:new Uint8Array(V),prfEnabled:w,prf:W?void 0:P,attachment:VZ(H.authenticatorAttachment),transports:GZ(H),aaguid:LJ(H)})}function fX($){if(!($ instanceof Error))return!1;return $.name==="NotSupportedError"||$.name==="TypeError"}function BJ($){if($===void 0)return;let Z=U$($);if(Z.byteLength<zZ){Z.fill(0);return}if(Z.byteLength===zZ)return Z;let J=Z.slice(0,zZ);return Z.fill(0),J}async function OZ($){let Z=L0();if(Z!==0)return G(Z);let[J,Q]=j0($);if(Q!==0)return G(Q);if(J===void 0)return G(9);let X=$?.salt??MZ,Y=R0(X),V={challenge:F0(A0),rpId:J,userVerification:"preferred",extensions:{prf:{eval:{first:Y}}}};if($?.hints!==void 0)V.hints=$.hints;let W=gX($?.credId);if(W.length>0)V.allowCredentials=W.map((H)=>({type:G0,id:R0(H)}));let q;try{q=await navigator.credentials.get({publicKey:V})}catch(H){return U0(H),G(30)}let[z,M]=E0(q);if(M!==0)return G(M);if(z===void 0)return G(27);let N=z.getClientExtensionResults().prf?.results;if(N?.first===void 0)return G(7);let K=BJ(N.first);if(K===void 0)return G(27);return O({prf:K,credId:new Uint8Array(z.rawId),attachment:VZ(z.authenticatorAttachment),transports:GZ(z)})}var C$="";var T$=typeof globalThis.Worker==="function"?globalThis.Worker:void 0,KZ=T$===void 0?void 0:T$.prototype.postMessage,w$;function vX(){if(typeof C$!=="string"||C$.length===0)throw Error("[DIPLOMATIC] worker source not embedded; run pkg build before spawn");return atob(C$)}function yX(){if(w$!==void 0)return w$;let $=new Blob([vX()],{type:"text/javascript"});return w$=URL.createObjectURL($),w$}function kJ(){if(T$===void 0)throw Error("[DIPLOMATIC] Worker API unavailable; cannot spawn sync worker");return new T$(yX(),{type:"module"})}function xJ($,Z,J){if(KZ===void 0)throw Error("[DIPLOMATIC] Worker API unavailable; cannot post to sync worker");if(J!==void 0&&J.length>0)KZ.call($,Z,{transfer:J});else KZ.call($,Z)}var lX=new TextEncoder().encode("diplomatic.bind.v1"),HZ=new TextEncoder().encode("diplomatic.bindtag.v1"),bX=32,hX=32,iX=16,Z0=new T0;class Q0{#$;constructor($){this.#$=$}static async fromRandom(){let $=await Z0.gen256BitSecureRandomSeed(),[Z,J]=t($);if(J!==0||Z===void 0)throw Error(`enclave: invalid random seed (${J})`);return new Q0(Z)}static fromBytes($){let[Z,J]=t($);if(J!==0)return G(J);if(Z===void 0)return G(10);let[Q,X]=t(Z.slice());if(X!==0)return G(X);if(Q===void 0)return G(10);return O(new Q0(Q))}async sealWithPasskey($){let Z=$?.salt??MZ,J=$?.credId,Q=J,X=$?.createCredIfNeeded===!0&&(J===void 0||!(J instanceof Uint8Array)&&J.length===0),Y,V;if(X){let[M,N]=await _J({rpId:$?.rpId,rpName:$?.rpName,userName:$?.userName??NZ,displayName:$?.displayName,authenticatorAttachment:$?.authenticatorAttachment,hints:$?.hints,excludeCredentials:$?.excludeCredentials,salt:Z});if(N!==0)return G(N);if(M===void 0)return G(30);if(!M.prfEnabled)return G(30);Q=M.credId,Y=M,V=M.prf}let W=async(M,N,K,H)=>{try{let[I,R]=await this.#V(M);if(R!==0)return G(R);if(I===void 0)return G(12);return O({sealedMaster:I,salt:Z.slice(),credId:N.slice(),userId:Y?.userId===void 0?void 0:Y.userId.slice(),attachment:K??Y?.attachment,transports:H??Y?.transports,aaguid:Y?.aaguid===void 0?void 0:Y.aaguid.slice()})}finally{M.fill(0)}};if(V!==void 0&&Y!==void 0)return W(V,Y.credId,Y.attachment,Y.transports);let[q,z]=await OZ({rpId:$?.rpId,rpName:$?.rpName,credId:Q,salt:Z,hints:$?.hints});if(z!==0)return G(z);if(q===void 0)return G(7);return W(q.prf,q.credId,q.attachment,q.transports)}async bind($,Z){if(Z!==void 0){for(let Y of Z)if(!await this.#Y(Y.credId,Y.tag))return G(10)}let[J,Q]=await this.sealWithPasskey($);if(Q!==0)return G(Q);if(J===void 0)return G(12);let X=await this.#X(J.credId);return O({...J,tag:X})}static async unsealWithPasskey($,Z){if($.length===0)return G(22);let J=[];for(let W of $)if(W.credId.byteLength>0)J.push(W.credId);let[Q,X]=await OZ({rpId:Z.rpId,rpName:Z.rpName,hints:Z.hints,credId:J.length>0?J:void 0,salt:Z.salt});if(X!==0)return G(X);if(Q===void 0)return G(7);let Y=$.find((W)=>y0(W.credId,Q.credId)),V=Y===void 0?$:[Y,...$.filter((W)=>W!==Y)];try{for(let W of V){let[q]=await Q0.#G(W.sealedMaster,Q.prf);if(q!==void 0)return O({enclave:q,credId:Q.credId.slice()})}return G(20)}finally{Q.prf.fill(0)}}async persistToLargeBlob($=[],Z){let J=Z?.credId;if(J===void 0){let[Y,V]=await EJ(Z);if(V!==0)return G(V);if(Y===void 0)return G(30);J=Y}let[Q,X]=this.#W($);if(X!==0)return G(X);if(Q===void 0)return G(12);try{let Y=await qZ(J,Q,Z);if(Y!==0)return G(Y);return O(J)}finally{Q.fill(0)}}static async fromLargeBlob($){let[Z,J]=await mJ($?.credId,$);if(J!==0)return G(J);if(Z===void 0)return G(7);try{return Q0.#q(Z.blob,Z.credId)}finally{Z.blob.fill(0)}}static async clearLargeBlob($,Z){return qZ($,new Uint8Array(V0),Z)}static pairRequest(){return R$.create()}async pairAccept($,Z){let J;try{J=await Z0.genX25519()}catch{return G(29)}try{let[Q,X]=await XZ(J.priv,$,$,J.pub);if(X!==0)return G(X);if(Q===void 0)return G(12);try{let[Y,V]=this.#Z(Z);if(V!==0)return G(V);if(Y===void 0)return G(12);try{let W=await Z0.encryptXSalsa20Poly1305Combined(Y,Q);return DJ(K0(J.pub,W))}catch{return G(12)}finally{Y.fill(0)}}finally{Q.fill(0)}}finally{J.priv.fill(0)}}#Z($){let Z=this.#$.slice(),[J,Q]=t(Z);if(Q!==0)return Z.fill(0),G(Q);if(J===void 0)return Z.fill(0),G(10);try{let X={masterSeed:J,hosts:$.map((V)=>({handle:V.handle,label:V.label,idx:V.idx??0}))},Y=new m;try{let V=Y.writeStruct(H$,X);if(V!==0)return G(V);return O(Y.result())}finally{Y.wipe()}}finally{J.fill(0)}}spawnSyncWorker($){let Z=kJ(),J=this.#$.slice();return xJ(Z,{id:$.id,op:"setSeed",seed:J,persist:$.persist},[J.buffer]),Z}deriveCipher($,Z){let J=$.slice(),Q=(V)=>this.#z(J,V),X=(V)=>this.#M(J,V);return{encrypt:Object.freeze({encrypt:Q}),decrypt:Object.freeze({decrypt:X}),both:Object.freeze({encrypt:Q,decrypt:X})}[Z]}async deriveIdentity($,Z=0){let J=$,Q=Z,X=await this.#Q(J,Q),Y=X.publicKey;return X.privateKey.fill(0),Object.freeze({publicKey:Y,sign:(V)=>this.#O(J,Q,V),kdmFor:(V)=>this.#K(J,Q,V)})}async#X($){let Z=new Uint8Array(this.#$.byteLength+HZ.byteLength+$.byteLength);Z.set(this.#$,0),Z.set(HZ,this.#$.byteLength),Z.set($,this.#$.byteLength+HZ.byteLength);try{return await Z0.blake3(Z)}finally{Z.fill(0)}}async#Y($,Z){if(Z.byteLength!==bX)return!1;let J=await this.#X($);try{if(J.byteLength!==Z.byteLength)return!1;let Q=0;for(let X=0;X<J.byteLength;X++){let Y=J[X],V=Z[X];if(Y===void 0||V===void 0)return!1;Q|=Y^V}return Q===0}finally{J.fill(0)}}async#V($){let[Z,J]=await SJ(Z0,$);if(J!==0)return G(J);if(Z===void 0)return G(12);try{let Q=await Z0.encryptXSalsa20Poly1305Combined(this.#$,Z);return O$(Q)}catch{return G(12)}finally{Z.fill(0)}}static async#G($,Z){let[,J]=O$($);if(J!==0)return G(J);let[Q,X]=await SJ(Z0,Z);if(X!==0)return G(X);if(Q===void 0)return G(12);let Y;try{try{Y=await Z0.decryptXSalsa20Poly1305Combined($,Q)}catch{return G(20)}return Q0.fromBytes(Y)}finally{Q.fill(0),Y?.fill(0)}}#W($){let Z=this.#$.slice(),[J,Q]=t(Z);if(Q!==0)return Z.fill(0),G(Q);if(J===void 0)return Z.fill(0),G(10);try{let[X,Y]=wJ(J,$);if(Y!==0)return G(Y);if(X===void 0)return G(12);try{let V=new m,W=V.writeStruct(QZ,X);if(W!==0)return G(W);return O(V.result())}finally{X.masterSeed.fill(0)}}finally{J.fill(0)}}static#q($,Z){if($.byteLength===0||$.every((Y)=>Y===0))return G(22);if($.byteLength===V0){if($.every((W)=>W===0))return G(22);let[Y,V]=Q0.fromBytes($);if(V!==0)return G(V);if(Y===void 0)return G(12);return O({enclave:Y,hosts:[],credId:Z})}let J=new v($),[Q,X]=J.readStruct(QZ);if(X!==0)return G(X);if(Q===void 0)return G(14);try{if(Q.masterSeed.every((W)=>W===0))return G(22);let[Y,V]=Q0.fromBytes(Q.masterSeed);if(V!==0)return G(V);if(Y===void 0)return G(12);return O({enclave:Y,hosts:Q.hosts.map((W)=>({...W})),credId:Z})}finally{Q.masterSeed.fill(0)}}async#z($,Z){let J=await this.#J($);try{return await Z0.encryptXSalsa20Poly1305Combined(Z,J)}finally{J.fill(0)}}async#M($,Z){let J=await this.#J($);try{return await Z0.decryptXSalsa20Poly1305Combined(Z,J)}finally{J.fill(0)}}async#J($){let Z=new Uint8Array(this.#$.byteLength+$.byteLength);Z.set(this.#$,0),Z.set($,this.#$.byteLength);try{return await Z0.blake3(Z)}finally{Z.fill(0)}}async#N($,Z){let J=new TextEncoder().encode($),Q=new Uint8Array(8);return new DataView(Q.buffer).setBigUint64(0,BigInt(Z),!1),await this.#J(K0(J,Q))}async#Q($,Z){let J=await this.#N($,Z);try{return await Z0.deriveEd25519KeyPair(J)}finally{J.fill(0)}}async#O($,Z,J){let Q=await this.#Q($,Z);try{return await Z0.signEd25519(J,Q.privateKey)}finally{Q.privateKey.fill(0)}}async#K($,Z,J){let Q=await this.#Q($,Z),X=K0(Q.privateKey,J);Q.privateKey.fill(0);try{return(await Z0.blake3(X)).slice(0,b0)}finally{X.fill(0)}}}async function SJ($,Z,J=lX){if(Z.byteLength<iX)return G(10);let Q=await $.blake3(K0(Z,J));return O(Q.slice(0,hX))}class FZ{listeners=new Map;addEventListener($,Z){let J=this.listeners.get($);if(!J)J=new Set,this.listeners.set($,J);return J.add(Z),()=>{this.removeEventListener($,Z)}}removeEventListener($,Z){let J=this.listeners.get($);if(J){if(J.delete(Z),J.size===0)this.listeners.delete($)}}emit($,Z){let J=this.listeners.get($);if(J){let Q=Array.from(J);for(let X of Q)X(Z)}}emitAll($){let Z=Array.from(this.listeners.keys());for(let J of Z)this.emit(J,$)}}async function gJ($,Z,J,Q=0){let X=Z.now(),Y=new m,V=Y.writeVarString($);if(V!==0)return G(V);let q={id:Y.result(),ts:new Date(0)},[z,M]=zJ(q);if(M!==0)return G(M);let N=X.getTime()-q.ts.getTime();return O({eid:z,off:N,ctr:Q,len:J.length,bod:J})}class pX{singletonType;latest;latestOff=-1;emitter=new FZ;constructor($){this.singletonType=$}async apply($){for(let Z of $){let J=new v(Z.eid),[Q,X]=J.readStruct(t0);if(X!==0)continue;let Y=new m;Y.writeVarString(this.singletonType);let V=Y.result();if(Q.id.length===V.length&&Q.id.every((W,q)=>W===V[q])){if(this.latest===void 0||Z.off>this.latestOff)this.latestOff=Z.off,this.latest=Z.bod,this.emitter.emit(this.singletonType,null)}}return $.map(()=>0)}clear=async()=>{return this.latest=void 0,this.latestOff=-1,this.emitter.emit(this.singletonType,null),0};notify=($)=>{for(let Z of $)if(Z===this.singletonType)this.emitter.emit(this.singletonType,null)};refresh=async($)=>{this.notify([this.singletonType])};on=($,Z)=>{this.emitter.addEventListener($,Z)};off=($,Z)=>{this.emitter.removeEventListener($,Z)}}async function fJ($,Z,J,Q){let X=new v($.headCph),[Y,V]=X.readStruct(u0);if(V!==0)return G(V);let{sig:W,kdm:q,headCph:z}=Y;if(!await Q.checkSigEd25519(W,z,Z))return G(3);let N=J.deriveCipher(q,"decrypt"),K;try{K=await N.decrypt(z)}catch{return G(20)}return O({kdm:q,headEnc:K})}var c0=aQ(vQ(),1),WV={encode:c0.encode,decode:c0.decode,decodeAsync:c0.decodeAsync},qV=WV;import{Database as zV}from"bun:sqlite";var Iz=Symbol("EntityID");var Pz=Symbol("DerivationSeed"),Uz=Symbol("PublicKey"),Cz=Symbol("PrivateKey"),wz=Symbol("HostSpecificKeyPair"),Tz=Symbol("Hash"),P0={term:0,elapsed:0,stat:{quota:0},dyn:{quota:0}};function MV($="diplomatic.db"){let Z=new zV($);return Z.exec("PRAGMA journal_mode=WAL;"),Z.exec("PRAGMA synchronous=NORMAL;"),Z.exec(`
1
+ var hQ=Object.create;var{getPrototypeOf:iQ,defineProperty:LZ,getOwnPropertyNames:pQ}=Object;var uQ=Object.prototype.hasOwnProperty;function dQ($){return this[$]}var nQ,cQ,rQ=($,Z,J)=>{var Q=$!=null&&typeof $==="object";if(Q){var X=Z?nQ??=new WeakMap:cQ??=new WeakMap,Y=X.get($);if(Y)return Y}J=$!=null?hQ(iQ($)):{};let V=Z||!$||!$.__esModule?LZ(J,"default",{value:$,enumerable:!0}):J;for(let W of pQ($))if(!uQ.call(V,W))LZ(V,W,{get:dQ.bind($,W),enumerable:!0});if(Q)X.set($,V);return V};var r=($,Z)=>()=>(Z||$((Z={exports:{}}).exports,Z),Z.exports);var w$=r((lJ)=>{Object.defineProperty(lJ,"__esModule",{value:!0});lJ.utf8Count=dX;lJ.utf8EncodeJs=gJ;lJ.utf8EncodeTE=fJ;lJ.utf8Encode=rX;lJ.utf8DecodeJs=vJ;lJ.utf8DecodeTD=yJ;lJ.utf8Decode=eX;function dX($){let Z=$.length,J=0,Q=0;while(Q<Z){let X=$.charCodeAt(Q++);if((X&4294967168)===0){J++;continue}else if((X&4294965248)===0)J+=2;else{if(X>=55296&&X<=56319){if(Q<Z){let Y=$.charCodeAt(Q);if((Y&64512)===56320)++Q,X=((X&1023)<<10)+(Y&1023)+65536}}if((X&4294901760)===0)J+=3;else J+=4}}return J}function gJ($,Z,J){let Q=$.length,X=J,Y=0;while(Y<Q){let V=$.charCodeAt(Y++);if((V&4294967168)===0){Z[X++]=V;continue}else if((V&4294965248)===0)Z[X++]=V>>6&31|192;else{if(V>=55296&&V<=56319){if(Y<Q){let W=$.charCodeAt(Y);if((W&64512)===56320)++Y,V=((V&1023)<<10)+(W&1023)+65536}}if((V&4294901760)===0)Z[X++]=V>>12&15|224,Z[X++]=V>>6&63|128;else Z[X++]=V>>18&7|240,Z[X++]=V>>12&63|128,Z[X++]=V>>6&63|128}Z[X++]=V&63|128}}var nX=new TextEncoder,cX=50;function fJ($,Z,J){nX.encodeInto($,Z.subarray(J))}function rX($,Z,J){if($.length>cX)fJ($,Z,J);else gJ($,Z,J)}var oX=4096;function vJ($,Z,J){let Q=Z,X=Q+J,Y=[],V="";while(Q<X){let W=$[Q++];if((W&128)===0)Y.push(W);else if((W&224)===192){let q=$[Q++]&63;Y.push((W&31)<<6|q)}else if((W&240)===224){let q=$[Q++]&63,M=$[Q++]&63;Y.push((W&31)<<12|q<<6|M)}else if((W&248)===240){let q=$[Q++]&63,M=$[Q++]&63,z=$[Q++]&63,N=(W&7)<<18|q<<12|M<<6|z;if(N>65535)N-=65536,Y.push(N>>>10&1023|55296),N=56320|N&1023;Y.push(N)}else Y.push(W);if(Y.length>=oX)V+=String.fromCharCode(...Y),Y.length=0}if(Y.length>0)V+=String.fromCharCode(...Y);return V}var aX=new TextDecoder,sX=200;function yJ($,Z,J){let Q=$.subarray(Z,Z+J);return aX.decode(Q)}function eX($,Z,J){if(J>sX)return yJ($,Z,J);else return vJ($,Z,J)}});var OZ=r((hJ)=>{Object.defineProperty(hJ,"__esModule",{value:!0});hJ.ExtData=void 0;class bJ{type;data;constructor($,Z){this.type=$,this.data=Z}}hJ.ExtData=bJ});var D$=r((pJ)=>{Object.defineProperty(pJ,"__esModule",{value:!0});pJ.DecodeError=void 0;class T$ extends Error{constructor($){super($);let Z=Object.create(T$.prototype);Object.setPrototypeOf(this,Z),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:T$.name})}}pJ.DecodeError=T$});var A$=r((dJ)=>{Object.defineProperty(dJ,"__esModule",{value:!0});dJ.UINT32_MAX=void 0;dJ.setUint64=VY;dJ.setInt64=GY;dJ.getInt64=WY;dJ.getUint64=qY;dJ.UINT32_MAX=4294967295;function VY($,Z,J){let Q=J/4294967296,X=J;$.setUint32(Z,Q),$.setUint32(Z+4,X)}function GY($,Z,J){let Q=Math.floor(J/4294967296),X=J;$.setUint32(Z,Q),$.setUint32(Z+4,X)}function WY($,Z){let J=$.getInt32(Z),Q=$.getUint32(Z+4);return J*4294967296+Q}function qY($,Z){let J=$.getUint32(Z),Q=$.getUint32(Z+4);return J*4294967296+Q}});var KZ=r((tJ)=>{Object.defineProperty(tJ,"__esModule",{value:!0});tJ.timestampExtension=tJ.EXT_TIMESTAMP=void 0;tJ.encodeTimeSpecToTimestamp=rJ;tJ.encodeDateToTimeSpec=oJ;tJ.encodeTimestampExtension=aJ;tJ.decodeTimestampToTimeSpec=sJ;tJ.decodeTimestampExtension=eJ;var KY=D$(),cJ=A$();tJ.EXT_TIMESTAMP=-1;var FY=4294967295,HY=17179869183;function rJ({sec:$,nsec:Z}){if($>=0&&Z>=0&&$<=HY)if(Z===0&&$<=FY){let J=new Uint8Array(4);return new DataView(J.buffer).setUint32(0,$),J}else{let J=$/4294967296,Q=$&4294967295,X=new Uint8Array(8),Y=new DataView(X.buffer);return Y.setUint32(0,Z<<2|J&3),Y.setUint32(4,Q),X}else{let J=new Uint8Array(12),Q=new DataView(J.buffer);return Q.setUint32(0,Z),(0,cJ.setInt64)(Q,4,$),J}}function oJ($){let Z=$.getTime(),J=Math.floor(Z/1000),Q=(Z-J*1000)*1e6,X=Math.floor(Q/1e9);return{sec:J+X,nsec:Q-X*1e9}}function aJ($){if($ instanceof Date){let Z=oJ($);return rJ(Z)}else return null}function sJ($){let Z=new DataView($.buffer,$.byteOffset,$.byteLength);switch($.byteLength){case 4:{let J=Z.getUint32(0),Q=0;return{sec:J,nsec:0}}case 8:{let J=Z.getUint32(0),Q=Z.getUint32(4),X=(J&3)*4294967296+Q,Y=J>>>2;return{sec:X,nsec:Y}}case 12:{let J=(0,cJ.getInt64)(Z,4),Q=Z.getUint32(0);return{sec:J,nsec:Q}}default:throw new KY.DecodeError(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${$.length}`)}}function eJ($){let Z=sJ($);return new Date(Z.sec*1000+Z.nsec/1e6)}tJ.timestampExtension={type:tJ.EXT_TIMESTAMP,encode:aJ,decode:eJ}});var L$=r((JQ)=>{Object.defineProperty(JQ,"__esModule",{value:!0});JQ.ExtensionCodec=void 0;var j$=OZ(),wY=KZ();class FZ{static defaultCodec=new FZ;__brand;builtInEncoders=[];builtInDecoders=[];encoders=[];decoders=[];constructor(){this.register(wY.timestampExtension)}register({type:$,encode:Z,decode:J}){if($>=0)this.encoders[$]=Z,this.decoders[$]=J;else{let Q=-1-$;this.builtInEncoders[Q]=Z,this.builtInDecoders[Q]=J}}tryToEncode($,Z){for(let J=0;J<this.builtInEncoders.length;J++){let Q=this.builtInEncoders[J];if(Q!=null){let X=Q($,Z);if(X!=null){let Y=-1-J;return new j$.ExtData(Y,X)}}}for(let J=0;J<this.encoders.length;J++){let Q=this.encoders[J];if(Q!=null){let X=Q($,Z);if(X!=null){let Y=J;return new j$.ExtData(Y,X)}}}if($ instanceof j$.ExtData)return $;return null}decode($,Z,J){let Q=Z<0?this.builtInDecoders[-1-Z]:this.decoders[Z];if(Q)return Q($,Z,J);else return new j$.ExtData(Z,$)}}JQ.ExtensionCodec=FZ});var HZ=r((XQ)=>{Object.defineProperty(XQ,"__esModule",{value:!0});XQ.ensureUint8Array=DY;function TY($){return $ instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&$ instanceof SharedArrayBuffer}function DY($){if($ instanceof Uint8Array)return $;else if(ArrayBuffer.isView($))return new Uint8Array($.buffer,$.byteOffset,$.byteLength);else if(TY($))return new Uint8Array($);else return Uint8Array.from($)}});var RZ=r((GQ)=>{Object.defineProperty(GQ,"__esModule",{value:!0});GQ.Encoder=GQ.DEFAULT_INITIAL_BUFFER_SIZE=GQ.DEFAULT_MAX_DEPTH=void 0;var YQ=w$(),jY=L$(),VQ=A$(),LY=HZ();GQ.DEFAULT_MAX_DEPTH=100;GQ.DEFAULT_INITIAL_BUFFER_SIZE=2048;class IZ{extensionCodec;context;useBigInt64;maxDepth;initialBufferSize;sortKeys;forceFloat32;ignoreUndefined;forceIntegerToFloat;pos;view;bytes;entered=!1;constructor($){this.extensionCodec=$?.extensionCodec??jY.ExtensionCodec.defaultCodec,this.context=$?.context,this.useBigInt64=$?.useBigInt64??!1,this.maxDepth=$?.maxDepth??GQ.DEFAULT_MAX_DEPTH,this.initialBufferSize=$?.initialBufferSize??GQ.DEFAULT_INITIAL_BUFFER_SIZE,this.sortKeys=$?.sortKeys??!1,this.forceFloat32=$?.forceFloat32??!1,this.ignoreUndefined=$?.ignoreUndefined??!1,this.forceIntegerToFloat=$?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new IZ({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef($){if(this.entered)return this.clone().encodeSharedRef($);try{return this.entered=!0,this.reinitializeState(),this.doEncode($,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode($){if(this.entered)return this.clone().encode($);try{return this.entered=!0,this.reinitializeState(),this.doEncode($,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode($,Z){if(Z>this.maxDepth)throw Error(`Too deep objects in depth ${Z}`);if($==null)this.encodeNil();else if(typeof $==="boolean")this.encodeBoolean($);else if(typeof $==="number")if(!this.forceIntegerToFloat)this.encodeNumber($);else this.encodeNumberAsFloat($);else if(typeof $==="string")this.encodeString($);else if(this.useBigInt64&&typeof $==="bigint")this.encodeBigInt64($);else this.encodeObject($,Z)}ensureBufferSizeToWrite($){let Z=this.pos+$;if(this.view.byteLength<Z)this.resizeBuffer(Z*2)}resizeBuffer($){let Z=new ArrayBuffer($),J=new Uint8Array(Z),Q=new DataView(Z);J.set(this.bytes),this.view=Q,this.bytes=J}encodeNil(){this.writeU8(192)}encodeBoolean($){if($===!1)this.writeU8(194);else this.writeU8(195)}encodeNumber($){if(!this.forceIntegerToFloat&&Number.isSafeInteger($))if($>=0)if($<128)this.writeU8($);else if($<256)this.writeU8(204),this.writeU8($);else if($<65536)this.writeU8(205),this.writeU16($);else if($<4294967296)this.writeU8(206),this.writeU32($);else if(!this.useBigInt64)this.writeU8(207),this.writeU64($);else this.encodeNumberAsFloat($);else if($>=-32)this.writeU8(224|$+32);else if($>=-128)this.writeU8(208),this.writeI8($);else if($>=-32768)this.writeU8(209),this.writeI16($);else if($>=-2147483648)this.writeU8(210),this.writeI32($);else if(!this.useBigInt64)this.writeU8(211),this.writeI64($);else this.encodeNumberAsFloat($);else this.encodeNumberAsFloat($)}encodeNumberAsFloat($){if(this.forceFloat32)this.writeU8(202),this.writeF32($);else this.writeU8(203),this.writeF64($)}encodeBigInt64($){if($>=BigInt(0))this.writeU8(207),this.writeBigUint64($);else this.writeU8(211),this.writeBigInt64($)}writeStringHeader($){if($<32)this.writeU8(160+$);else if($<256)this.writeU8(217),this.writeU8($);else if($<65536)this.writeU8(218),this.writeU16($);else if($<4294967296)this.writeU8(219),this.writeU32($);else throw Error(`Too long string: ${$} bytes in UTF-8`)}encodeString($){let J=(0,YQ.utf8Count)($);this.ensureBufferSizeToWrite(5+J),this.writeStringHeader(J),(0,YQ.utf8Encode)($,this.bytes,this.pos),this.pos+=J}encodeObject($,Z){let J=this.extensionCodec.tryToEncode($,this.context);if(J!=null)this.encodeExtension(J);else if(Array.isArray($))this.encodeArray($,Z);else if(ArrayBuffer.isView($))this.encodeBinary($);else if(typeof $==="object")this.encodeMap($,Z);else throw Error(`Unrecognized object: ${Object.prototype.toString.apply($)}`)}encodeBinary($){let Z=$.byteLength;if(Z<256)this.writeU8(196),this.writeU8(Z);else if(Z<65536)this.writeU8(197),this.writeU16(Z);else if(Z<4294967296)this.writeU8(198),this.writeU32(Z);else throw Error(`Too large binary: ${Z}`);let J=(0,LY.ensureUint8Array)($);this.writeU8a(J)}encodeArray($,Z){let J=$.length;if(J<16)this.writeU8(144+J);else if(J<65536)this.writeU8(220),this.writeU16(J);else if(J<4294967296)this.writeU8(221),this.writeU32(J);else throw Error(`Too large array: ${J}`);for(let Q of $)this.doEncode(Q,Z+1)}countWithoutUndefined($,Z){let J=0;for(let Q of Z)if($[Q]!==void 0)J++;return J}encodeMap($,Z){let J=Object.keys($);if(this.sortKeys)J.sort();let Q=this.ignoreUndefined?this.countWithoutUndefined($,J):J.length;if(Q<16)this.writeU8(128+Q);else if(Q<65536)this.writeU8(222),this.writeU16(Q);else if(Q<4294967296)this.writeU8(223),this.writeU32(Q);else throw Error(`Too large map object: ${Q}`);for(let X of J){let Y=$[X];if(!(this.ignoreUndefined&&Y===void 0))this.encodeString(X),this.doEncode(Y,Z+1)}}encodeExtension($){if(typeof $.data==="function"){let J=$.data(this.pos+6),Q=J.length;if(Q>=4294967296)throw Error(`Too large extension object: ${Q}`);this.writeU8(201),this.writeU32(Q),this.writeI8($.type),this.writeU8a(J);return}let Z=$.data.length;if(Z===1)this.writeU8(212);else if(Z===2)this.writeU8(213);else if(Z===4)this.writeU8(214);else if(Z===8)this.writeU8(215);else if(Z===16)this.writeU8(216);else if(Z<256)this.writeU8(199),this.writeU8(Z);else if(Z<65536)this.writeU8(200),this.writeU16(Z);else if(Z<4294967296)this.writeU8(201),this.writeU32(Z);else throw Error(`Too large extension object: ${Z}`);this.writeI8($.type),this.writeU8a($.data)}writeU8($){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,$),this.pos++}writeU8a($){let Z=$.length;this.ensureBufferSizeToWrite(Z),this.bytes.set($,this.pos),this.pos+=Z}writeI8($){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,$),this.pos++}writeU16($){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,$),this.pos+=2}writeI16($){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,$),this.pos+=2}writeU32($){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,$),this.pos+=4}writeI32($){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,$),this.pos+=4}writeF32($){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,$),this.pos+=4}writeF64($){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,$),this.pos+=8}writeU64($){this.ensureBufferSizeToWrite(8),(0,VQ.setUint64)(this.view,this.pos,$),this.pos+=8}writeI64($){this.ensureBufferSizeToWrite(8),(0,VQ.setInt64)(this.view,this.pos,$),this.pos+=8}writeBigUint64($){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,$),this.pos+=8}writeBigInt64($){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,$),this.pos+=8}}GQ.Encoder=IZ});var NQ=r((zQ)=>{Object.defineProperty(zQ,"__esModule",{value:!0});zQ.encode=mY;var EY=RZ();function mY($,Z){return new EY.Encoder(Z).encodeSharedRef($)}});var KQ=r((OQ)=>{Object.defineProperty(OQ,"__esModule",{value:!0});OQ.prettyByte=BY;function BY($){return`${$<0?"-":""}0x${Math.abs($).toString(16).padStart(2,"0")}`}});var RQ=r((HQ)=>{Object.defineProperty(HQ,"__esModule",{value:!0});HQ.CachedKeyDecoder=void 0;var kY=w$(),xY=16,gY=16;class FQ{hit=0;miss=0;caches;maxKeyLength;maxLengthPerKey;constructor($=xY,Z=gY){this.maxKeyLength=$,this.maxLengthPerKey=Z,this.caches=[];for(let J=0;J<this.maxKeyLength;J++)this.caches.push([])}canBeCached($){return $>0&&$<=this.maxKeyLength}find($,Z,J){let Q=this.caches[J-1];$:for(let X of Q){let Y=X.bytes;for(let V=0;V<J;V++)if(Y[V]!==$[Z+V])continue $;return X.str}return null}store($,Z){let J=this.caches[$.length-1],Q={bytes:$,str:Z};if(J.length>=this.maxLengthPerKey)J[Math.random()*J.length|0]=Q;else J.push(Q)}decode($,Z,J){let Q=this.find($,Z,J);if(Q!=null)return this.hit++,Q;this.miss++;let X=(0,kY.utf8DecodeJs)($,Z,J),Y=Uint8Array.prototype.slice.call($,Z,Z+J);return this.store(Y,X),X}}HQ.CachedKeyDecoder=FQ});var E$=r((TQ)=>{Object.defineProperty(TQ,"__esModule",{value:!0});TQ.Decoder=void 0;var PZ=KQ(),fY=L$(),L0=A$(),vY=w$(),PQ=HZ(),yY=RQ(),H0=D$(),UZ="array",Z$="map_key",CQ="map_value",lY=($)=>{if(typeof $==="string"||typeof $==="number")return $;throw new H0.DecodeError("The type of key must be string or number but "+typeof $)};class wQ{stack=[];stackHeadPosition=-1;get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState($){let Z=this.getUninitializedStateFromPool();Z.type=UZ,Z.position=0,Z.size=$,Z.array=Array($)}pushMapState($){let Z=this.getUninitializedStateFromPool();Z.type=Z$,Z.readCount=0,Z.size=$,Z.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){let $={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push($)}return this.stack[this.stackHeadPosition]}release($){if(this.stack[this.stackHeadPosition]!==$)throw Error("Invalid stack state. Released state is not on top of the stack.");if($.type===UZ){let J=$;J.size=0,J.array=void 0,J.position=0,J.type=void 0}if($.type===Z$||$.type===CQ){let J=$;J.size=0,J.map=void 0,J.readCount=0,J.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}var $$=-1,CZ=new DataView(new ArrayBuffer(0)),bY=new Uint8Array(CZ.buffer);try{CZ.getInt8(0)}catch($){if(!($ instanceof RangeError))throw Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var UQ=RangeError("Insufficient data"),hY=new yY.CachedKeyDecoder;class wZ{extensionCodec;context;useBigInt64;rawStrings;maxStrLength;maxBinLength;maxArrayLength;maxMapLength;maxExtLength;keyDecoder;mapKeyConverter;totalPos=0;pos=0;view=CZ;bytes=bY;headByte=$$;stack=new wQ;entered=!1;constructor($){this.extensionCodec=$?.extensionCodec??fY.ExtensionCodec.defaultCodec,this.context=$?.context,this.useBigInt64=$?.useBigInt64??!1,this.rawStrings=$?.rawStrings??!1,this.maxStrLength=$?.maxStrLength??L0.UINT32_MAX,this.maxBinLength=$?.maxBinLength??L0.UINT32_MAX,this.maxArrayLength=$?.maxArrayLength??L0.UINT32_MAX,this.maxMapLength=$?.maxMapLength??L0.UINT32_MAX,this.maxExtLength=$?.maxExtLength??L0.UINT32_MAX,this.keyDecoder=$?.keyDecoder!==void 0?$.keyDecoder:hY,this.mapKeyConverter=$?.mapKeyConverter??lY}clone(){return new wZ({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=$$,this.stack.reset()}setBuffer($){let Z=(0,PQ.ensureUint8Array)($);this.bytes=Z,this.view=new DataView(Z.buffer,Z.byteOffset,Z.byteLength),this.pos=0}appendBuffer($){if(this.headByte===$$&&!this.hasRemaining(1))this.setBuffer($);else{let Z=this.bytes.subarray(this.pos),J=(0,PQ.ensureUint8Array)($),Q=new Uint8Array(Z.length+J.length);Q.set(Z),Q.set(J,Z.length),this.setBuffer(Q)}}hasRemaining($){return this.view.byteLength-this.pos>=$}createExtraByteError($){let{view:Z,pos:J}=this;return RangeError(`Extra ${Z.byteLength-J} of ${Z.byteLength} byte(s) found at buffer[${$}]`)}decode($){if(this.entered)return this.clone().decode($);try{this.entered=!0,this.reinitializeState(),this.setBuffer($);let Z=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return Z}finally{this.entered=!1}}*decodeMulti($){if(this.entered){yield*this.clone().decodeMulti($);return}try{this.entered=!0,this.reinitializeState(),this.setBuffer($);while(this.hasRemaining(1))yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync($){if(this.entered)return this.clone().decodeAsync($);try{this.entered=!0;let Z=!1,J;for await(let V of $){if(Z)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(V);try{J=this.doDecodeSync(),Z=!0}catch(W){if(!(W instanceof RangeError))throw W}this.totalPos+=this.pos}if(Z){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return J}let{headByte:Q,pos:X,totalPos:Y}=this;throw RangeError(`Insufficient data in parsing ${(0,PZ.prettyByte)(Q)} at ${Y} (${X} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream($){return this.decodeMultiAsync($,!0)}decodeStream($){return this.decodeMultiAsync($,!1)}async*decodeMultiAsync($,Z){if(this.entered){yield*this.clone().decodeMultiAsync($,Z);return}try{this.entered=!0;let J=Z,Q=-1;for await(let X of $){if(Z&&Q===0)throw this.createExtraByteError(this.totalPos);if(this.appendBuffer(X),J)Q=this.readArraySize(),J=!1,this.complete();try{while(!0)if(yield this.doDecodeSync(),--Q===0)break}catch(Y){if(!(Y instanceof RangeError))throw Y}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){$:while(!0){let $=this.readHeadByte(),Z;if($>=224)Z=$-256;else if($<192)if($<128)Z=$;else if($<144){let Q=$-128;if(Q!==0){this.pushMapState(Q),this.complete();continue $}else Z={}}else if($<160){let Q=$-144;if(Q!==0){this.pushArrayState(Q),this.complete();continue $}else Z=[]}else{let Q=$-160;Z=this.decodeString(Q,0)}else if($===192)Z=null;else if($===194)Z=!1;else if($===195)Z=!0;else if($===202)Z=this.readF32();else if($===203)Z=this.readF64();else if($===204)Z=this.readU8();else if($===205)Z=this.readU16();else if($===206)Z=this.readU32();else if($===207)if(this.useBigInt64)Z=this.readU64AsBigInt();else Z=this.readU64();else if($===208)Z=this.readI8();else if($===209)Z=this.readI16();else if($===210)Z=this.readI32();else if($===211)if(this.useBigInt64)Z=this.readI64AsBigInt();else Z=this.readI64();else if($===217){let Q=this.lookU8();Z=this.decodeString(Q,1)}else if($===218){let Q=this.lookU16();Z=this.decodeString(Q,2)}else if($===219){let Q=this.lookU32();Z=this.decodeString(Q,4)}else if($===220){let Q=this.readU16();if(Q!==0){this.pushArrayState(Q),this.complete();continue $}else Z=[]}else if($===221){let Q=this.readU32();if(Q!==0){this.pushArrayState(Q),this.complete();continue $}else Z=[]}else if($===222){let Q=this.readU16();if(Q!==0){this.pushMapState(Q),this.complete();continue $}else Z={}}else if($===223){let Q=this.readU32();if(Q!==0){this.pushMapState(Q),this.complete();continue $}else Z={}}else if($===196){let Q=this.lookU8();Z=this.decodeBinary(Q,1)}else if($===197){let Q=this.lookU16();Z=this.decodeBinary(Q,2)}else if($===198){let Q=this.lookU32();Z=this.decodeBinary(Q,4)}else if($===212)Z=this.decodeExtension(1,0);else if($===213)Z=this.decodeExtension(2,0);else if($===214)Z=this.decodeExtension(4,0);else if($===215)Z=this.decodeExtension(8,0);else if($===216)Z=this.decodeExtension(16,0);else if($===199){let Q=this.lookU8();Z=this.decodeExtension(Q,1)}else if($===200){let Q=this.lookU16();Z=this.decodeExtension(Q,2)}else if($===201){let Q=this.lookU32();Z=this.decodeExtension(Q,4)}else throw new H0.DecodeError(`Unrecognized type byte: ${(0,PZ.prettyByte)($)}`);this.complete();let J=this.stack;while(J.length>0){let Q=J.top();if(Q.type===UZ)if(Q.array[Q.position]=Z,Q.position++,Q.position===Q.size)Z=Q.array,J.release(Q);else continue $;else if(Q.type===Z$){if(Z==="__proto__")throw new H0.DecodeError("The key __proto__ is not allowed");Q.key=this.mapKeyConverter(Z),Q.type=CQ;continue $}else if(Q.map[Q.key]=Z,Q.readCount++,Q.readCount===Q.size)Z=Q.map,J.release(Q);else{Q.key=null,Q.type=Z$;continue $}}return Z}}readHeadByte(){if(this.headByte===$$)this.headByte=this.readU8();return this.headByte}complete(){this.headByte=$$}readArraySize(){let $=this.readHeadByte();switch($){case 220:return this.readU16();case 221:return this.readU32();default:if($<160)return $-144;else throw new H0.DecodeError(`Unrecognized array type byte: ${(0,PZ.prettyByte)($)}`)}}pushMapState($){if($>this.maxMapLength)throw new H0.DecodeError(`Max length exceeded: map length (${$}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState($)}pushArrayState($){if($>this.maxArrayLength)throw new H0.DecodeError(`Max length exceeded: array length (${$}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState($)}decodeString($,Z){if(!this.rawStrings||this.stateIsMapKey())return this.decodeUtf8String($,Z);return this.decodeBinary($,Z)}decodeUtf8String($,Z){if($>this.maxStrLength)throw new H0.DecodeError(`Max length exceeded: UTF-8 byte length (${$}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+Z+$)throw UQ;let J=this.pos+Z,Q;if(this.stateIsMapKey()&&this.keyDecoder?.canBeCached($))Q=this.keyDecoder.decode(this.bytes,J,$);else Q=(0,vY.utf8Decode)(this.bytes,J,$);return this.pos+=Z+$,Q}stateIsMapKey(){if(this.stack.length>0)return this.stack.top().type===Z$;return!1}decodeBinary($,Z){if($>this.maxBinLength)throw new H0.DecodeError(`Max length exceeded: bin length (${$}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining($+Z))throw UQ;let J=this.pos+Z,Q=this.bytes.subarray(J,J+$);return this.pos+=Z+$,Q}decodeExtension($,Z){if($>this.maxExtLength)throw new H0.DecodeError(`Max length exceeded: ext length (${$}) > maxExtLength (${this.maxExtLength})`);let J=this.view.getInt8(this.pos+Z),Q=this.decodeBinary($,Z+1);return this.extensionCodec.decode(Q,J,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){let $=this.view.getUint8(this.pos);return this.pos++,$}readI8(){let $=this.view.getInt8(this.pos);return this.pos++,$}readU16(){let $=this.view.getUint16(this.pos);return this.pos+=2,$}readI16(){let $=this.view.getInt16(this.pos);return this.pos+=2,$}readU32(){let $=this.view.getUint32(this.pos);return this.pos+=4,$}readI32(){let $=this.view.getInt32(this.pos);return this.pos+=4,$}readU64(){let $=(0,L0.getUint64)(this.view,this.pos);return this.pos+=8,$}readI64(){let $=(0,L0.getInt64)(this.view,this.pos);return this.pos+=8,$}readU64AsBigInt(){let $=this.view.getBigUint64(this.pos);return this.pos+=8,$}readI64AsBigInt(){let $=this.view.getBigInt64(this.pos);return this.pos+=8,$}readF32(){let $=this.view.getFloat32(this.pos);return this.pos+=4,$}readF64(){let $=this.view.getFloat64(this.pos);return this.pos+=8,$}}TQ.Decoder=wZ});var LQ=r((jQ)=>{Object.defineProperty(jQ,"__esModule",{value:!0});jQ.decode=iY;jQ.decodeMulti=pY;var AQ=E$();function iY($,Z){return new AQ.Decoder(Z).decode($)}function pY($,Z){return new AQ.Decoder(Z).decodeMulti($)}});var BQ=r((SQ)=>{Object.defineProperty(SQ,"__esModule",{value:!0});SQ.isAsyncIterable=EQ;SQ.asyncIterableFromStream=mQ;SQ.ensureAsyncIterable=nY;function EQ($){return $[Symbol.asyncIterator]!=null}async function*mQ($){let Z=$.getReader();try{while(!0){let{done:J,value:Q}=await Z.read();if(J)return;yield Q}}finally{Z.releaseLock()}}function nY($){if(EQ($))return $;else return mQ($)}});var kQ=r((_Q)=>{Object.defineProperty(_Q,"__esModule",{value:!0});_Q.decodeAsync=aY;_Q.decodeArrayStream=sY;_Q.decodeMultiStream=eY;var TZ=E$(),DZ=BQ();async function aY($,Z){let J=(0,DZ.ensureAsyncIterable)($);return new TZ.Decoder(Z).decodeAsync(J)}function sY($,Z){let J=(0,DZ.ensureAsyncIterable)($);return new TZ.Decoder(Z).decodeArrayStream(J)}function eY($,Z){let J=(0,DZ.ensureAsyncIterable)($);return new TZ.Decoder(Z).decodeStream(J)}});var gQ=r((v)=>{Object.defineProperty(v,"__esModule",{value:!0});v.decodeTimestampExtension=v.encodeTimestampExtension=v.decodeTimestampToTimeSpec=v.encodeTimeSpecToTimestamp=v.encodeDateToTimeSpec=v.EXT_TIMESTAMP=v.ExtData=v.ExtensionCodec=v.Encoder=v.DecodeError=v.Decoder=v.decodeMultiStream=v.decodeArrayStream=v.decodeAsync=v.decodeMulti=v.decode=v.encode=void 0;var JV=NQ();Object.defineProperty(v,"encode",{enumerable:!0,get:function(){return JV.encode}});var xQ=LQ();Object.defineProperty(v,"decode",{enumerable:!0,get:function(){return xQ.decode}});Object.defineProperty(v,"decodeMulti",{enumerable:!0,get:function(){return xQ.decodeMulti}});var AZ=kQ();Object.defineProperty(v,"decodeAsync",{enumerable:!0,get:function(){return AZ.decodeAsync}});Object.defineProperty(v,"decodeArrayStream",{enumerable:!0,get:function(){return AZ.decodeArrayStream}});Object.defineProperty(v,"decodeMultiStream",{enumerable:!0,get:function(){return AZ.decodeMultiStream}});var QV=E$();Object.defineProperty(v,"Decoder",{enumerable:!0,get:function(){return QV.Decoder}});var XV=D$();Object.defineProperty(v,"DecodeError",{enumerable:!0,get:function(){return XV.DecodeError}});var YV=RZ();Object.defineProperty(v,"Encoder",{enumerable:!0,get:function(){return YV.Encoder}});var VV=L$();Object.defineProperty(v,"ExtensionCodec",{enumerable:!0,get:function(){return VV.ExtensionCodec}});var GV=OZ();Object.defineProperty(v,"ExtData",{enumerable:!0,get:function(){return GV.ExtData}});var u0=KZ();Object.defineProperty(v,"EXT_TIMESTAMP",{enumerable:!0,get:function(){return u0.EXT_TIMESTAMP}});Object.defineProperty(v,"encodeDateToTimeSpec",{enumerable:!0,get:function(){return u0.encodeDateToTimeSpec}});Object.defineProperty(v,"encodeTimeSpecToTimestamp",{enumerable:!0,get:function(){return u0.encodeTimeSpecToTimestamp}});Object.defineProperty(v,"decodeTimestampToTimeSpec",{enumerable:!0,get:function(){return u0.decodeTimestampToTimeSpec}});Object.defineProperty(v,"encodeTimestampExtension",{enumerable:!0,get:function(){return u0.encodeTimestampExtension}});Object.defineProperty(v,"decodeTimestampExtension",{enumerable:!0,get:function(){return u0.decodeTimestampExtension}})});import*as W0 from"node:crypto";var U0=W0&&typeof W0==="object"&&"webcrypto"in W0?W0.webcrypto:W0&&typeof W0==="object"&&("randomBytes"in W0)?W0:void 0;function J$($){if(!Number.isSafeInteger($)||$<0)throw Error("positive integer expected, got "+$)}function m$($){return $ instanceof Uint8Array||ArrayBuffer.isView($)&&$.constructor.name==="Uint8Array"}function i($,...Z){if(!m$($))throw Error("Uint8Array expected");if(Z.length>0&&!Z.includes($.length))throw Error("Uint8Array expected of length "+Z+", got length="+$.length)}function S$($,Z=!0){if($.destroyed)throw Error("Hash instance has been destroyed");if(Z&&$.finished)throw Error("Hash#digest() has already been called")}function EZ($,Z){i($);let J=Z.outputLen;if($.length<J)throw Error("digestInto() expects output buffer of length at least "+J)}function B$($){if(typeof $!=="boolean")throw Error(`boolean expected, not ${$}`)}/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */var q0=($)=>new Uint32Array($.buffer,$.byteOffset,Math.floor($.byteLength/4));var oQ=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!oQ)throw Error("Non little-endian hardware is not supported");function aQ($){if(typeof $!=="string")throw Error("string expected");return new Uint8Array(new TextEncoder().encode($))}function Q$($){if(typeof $==="string")$=aQ($);else if(m$($))$=X$($);else throw Error("Uint8Array expected, got "+typeof $);return $}function mZ($,Z){if(Z==null||typeof Z!=="object")throw Error("options must be defined");return Object.assign($,Z)}function SZ($,Z){if($.length!==Z.length)return!1;let J=0;for(let Q=0;Q<$.length;Q++)J|=$[Q]^Z[Q];return J===0}var BZ=($,Z)=>{function J(Q,...X){if(i(Q),$.nonceLength!==void 0){let z=X[0];if(!z)throw Error("nonce / iv required");if($.varSizeNonce)i(z);else i(z,$.nonceLength)}let Y=$.tagLength;if(Y&&X[1]!==void 0)i(X[1]);let V=Z(Q,...X),W=(z,N)=>{if(N!==void 0){if(z!==2)throw Error("cipher output not supported");i(N)}},q=!1;return{encrypt(z,N){if(q)throw Error("cannot encrypt() twice with same key + nonce");return q=!0,i(z),W(V.encrypt.length,N),V.encrypt(z,N)},decrypt(z,N){if(i(z),Y&&z.length<Y)throw Error("invalid ciphertext length: smaller than tagLength="+Y);return W(V.decrypt.length,N),V.decrypt(z,N)}}}return Object.assign(J,$),J};function _$($,Z,J=!0){if(Z===void 0)return new Uint8Array($);if(Z.length!==$)throw Error("invalid output length, expected "+$+", got: "+Z.length);if(J&&!sQ(Z))throw Error("invalid output, must be aligned");return Z}function sQ($){return $.byteOffset%4===0}function X$($){return Uint8Array.from($)}function Q0(...$){for(let Z=0;Z<$.length;Z++)$[Z].fill(0)}function n0($=32){if(U0&&typeof U0.getRandomValues==="function")return U0.getRandomValues(new Uint8Array($));if(U0&&typeof U0.randomBytes==="function")return U0.randomBytes($);throw Error("crypto.getRandomValues must be defined")}var kZ=($)=>Uint8Array.from($.split("").map((Z)=>Z.charCodeAt(0))),eQ=kZ("expand 16-byte k"),tQ=kZ("expand 32-byte k"),$X=q0(eQ),ZX=q0(tQ);function U($,Z){return $<<Z|$>>>32-Z}function k$($){return $.byteOffset%4===0}var Y$=64,JX=16,xZ=4294967295,_Z=new Uint32Array;function QX($,Z,J,Q,X,Y,V,W){let q=X.length,M=new Uint8Array(Y$),z=q0(M),N=k$(X)&&k$(Y),K=N?q0(X):_Z,F=N?q0(Y):_Z;for(let R=0;R<q;V++){if($(Z,J,Q,z,V,W),V>=xZ)throw Error("arx: counter overflow");let I=Math.min(Y$,q-R);if(N&&I===Y$){let P=R/4;if(R%4!==0)throw Error("arx: invalid block position");for(let w=0,T;w<JX;w++)T=P+w,F[T]=K[T]^z[w];R+=Y$;continue}for(let P=0,w;P<I;P++)w=R+P,Y[w]=X[w]^M[P];R+=I}}function gZ($,Z){let{allowShortKeys:J,extendNonceFn:Q,counterLength:X,counterRight:Y,rounds:V}=mZ({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},Z);if(typeof $!=="function")throw Error("core must be a function");return J$(X),J$(V),B$(Y),B$(J),(W,q,M,z,N=0)=>{i(W),i(q),i(M);let K=M.length;if(z===void 0)z=new Uint8Array(K);if(i(z),J$(N),N<0||N>=xZ)throw Error("arx: counter overflow");if(z.length<K)throw Error(`arx: output (${z.length}) is shorter than data (${K})`);let F=[],R=W.length,I,P;if(R===32)F.push(I=X$(W)),P=ZX;else if(R===16&&J)I=new Uint8Array(32),I.set(W),I.set(W,16),P=$X,F.push(I);else throw Error(`arx: invalid 32-byte key, got length=${R}`);if(!k$(q))F.push(q=X$(q));let w=q0(I);if(Q){if(q.length!==24)throw Error("arx: extended nonce must be 24 bytes");Q(P,w,q0(q.subarray(0,16)),w),q=q.subarray(16)}let T=16-X;if(T!==q.length)throw Error(`arx: nonce must be ${T} or 16 bytes`);if(T!==12){let C=new Uint8Array(12);C.set(q,Y?0:12-q.length),q=C,F.push(q)}let A=q0(q);return QX($,P,w,A,M,z,N,V),Q0(...F),z}}var d=($,Z)=>$[Z++]&255|($[Z++]&255)<<8;class fZ{constructor($){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,$=Q$($),i($,32);let Z=d($,0),J=d($,2),Q=d($,4),X=d($,6),Y=d($,8),V=d($,10),W=d($,12),q=d($,14);this.r[0]=Z&8191,this.r[1]=(Z>>>13|J<<3)&8191,this.r[2]=(J>>>10|Q<<6)&7939,this.r[3]=(Q>>>7|X<<9)&8191,this.r[4]=(X>>>4|Y<<12)&255,this.r[5]=Y>>>1&8190,this.r[6]=(Y>>>14|V<<2)&8191,this.r[7]=(V>>>11|W<<5)&8065,this.r[8]=(W>>>8|q<<8)&8191,this.r[9]=q>>>5&127;for(let M=0;M<8;M++)this.pad[M]=d($,16+2*M)}process($,Z,J=!1){let Q=J?0:2048,{h:X,r:Y}=this,V=Y[0],W=Y[1],q=Y[2],M=Y[3],z=Y[4],N=Y[5],K=Y[6],F=Y[7],R=Y[8],I=Y[9],P=d($,Z+0),w=d($,Z+2),T=d($,Z+4),A=d($,Z+6),C=d($,Z+8),L=d($,Z+10),B=d($,Z+12),u=d($,Z+14),S=X[0]+(P&8191),k=X[1]+((P>>>13|w<<3)&8191),g=X[2]+((w>>>10|T<<6)&8191),x=X[3]+((T>>>7|A<<9)&8191),f=X[4]+((A>>>4|C<<12)&8191),H=X[5]+(C>>>1&8191),y=X[6]+((C>>>14|L<<2)&8191),l=X[7]+((L>>>11|B<<5)&8191),b=X[8]+((B>>>8|u<<8)&8191),h=X[9]+(u>>>5|Q),D=0,c=D+S*V+k*(5*I)+g*(5*R)+x*(5*F)+f*(5*K);D=c>>>13,c&=8191,c+=H*(5*N)+y*(5*z)+l*(5*M)+b*(5*q)+h*(5*W),D+=c>>>13,c&=8191;let a=D+S*W+k*V+g*(5*I)+x*(5*R)+f*(5*F);D=a>>>13,a&=8191,a+=H*(5*K)+y*(5*N)+l*(5*z)+b*(5*M)+h*(5*q),D+=a>>>13,a&=8191;let e=D+S*q+k*W+g*V+x*(5*I)+f*(5*R);D=e>>>13,e&=8191,e+=H*(5*F)+y*(5*K)+l*(5*N)+b*(5*z)+h*(5*M),D+=e>>>13,e&=8191;let _=D+S*M+k*q+g*W+x*V+f*(5*I);D=_>>>13,_&=8191,_+=H*(5*R)+y*(5*F)+l*(5*K)+b*(5*N)+h*(5*z),D+=_>>>13,_&=8191;let G0=D+S*z+k*M+g*q+x*W+f*V;D=G0>>>13,G0&=8191,G0+=H*(5*I)+y*(5*R)+l*(5*F)+b*(5*K)+h*(5*N),D+=G0>>>13,G0&=8191;let E0=D+S*N+k*z+g*M+x*q+f*W;D=E0>>>13,E0&=8191,E0+=H*V+y*(5*I)+l*(5*R)+b*(5*F)+h*(5*K),D+=E0>>>13,E0&=8191;let m0=D+S*K+k*N+g*z+x*M+f*q;D=m0>>>13,m0&=8191,m0+=H*W+y*V+l*(5*I)+b*(5*R)+h*(5*F),D+=m0>>>13,m0&=8191;let S0=D+S*F+k*K+g*N+x*z+f*M;D=S0>>>13,S0&=8191,S0+=H*q+y*W+l*V+b*(5*I)+h*(5*R),D+=S0>>>13,S0&=8191;let B0=D+S*R+k*F+g*K+x*N+f*z;D=B0>>>13,B0&=8191,B0+=H*M+y*q+l*W+b*V+h*(5*I),D+=B0>>>13,B0&=8191;let _0=D+S*I+k*R+g*F+x*K+f*N;D=_0>>>13,_0&=8191,_0+=H*z+y*M+l*q+b*W+h*V,D+=_0>>>13,_0&=8191,D=(D<<2)+D|0,D=D+c|0,c=D&8191,D=D>>>13,a+=D,X[0]=c,X[1]=a,X[2]=e,X[3]=_,X[4]=G0,X[5]=E0,X[6]=m0,X[7]=S0,X[8]=B0,X[9]=_0}finalize(){let{h:$,pad:Z}=this,J=new Uint16Array(10),Q=$[1]>>>13;$[1]&=8191;for(let V=2;V<10;V++)$[V]+=Q,Q=$[V]>>>13,$[V]&=8191;$[0]+=Q*5,Q=$[0]>>>13,$[0]&=8191,$[1]+=Q,Q=$[1]>>>13,$[1]&=8191,$[2]+=Q,J[0]=$[0]+5,Q=J[0]>>>13,J[0]&=8191;for(let V=1;V<10;V++)J[V]=$[V]+Q,Q=J[V]>>>13,J[V]&=8191;J[9]-=8192;let X=(Q^1)-1;for(let V=0;V<10;V++)J[V]&=X;X=~X;for(let V=0;V<10;V++)$[V]=$[V]&X|J[V];$[0]=($[0]|$[1]<<13)&65535,$[1]=($[1]>>>3|$[2]<<10)&65535,$[2]=($[2]>>>6|$[3]<<7)&65535,$[3]=($[3]>>>9|$[4]<<4)&65535,$[4]=($[4]>>>12|$[5]<<1|$[6]<<14)&65535,$[5]=($[6]>>>2|$[7]<<11)&65535,$[6]=($[7]>>>5|$[8]<<8)&65535,$[7]=($[8]>>>8|$[9]<<5)&65535;let Y=$[0]+Z[0];$[0]=Y&65535;for(let V=1;V<8;V++)Y=($[V]+Z[V]|0)+(Y>>>16)|0,$[V]=Y&65535;Q0(J)}update($){S$(this);let{buffer:Z,blockLen:J}=this;$=Q$($);let Q=$.length;for(let X=0;X<Q;){let Y=Math.min(J-this.pos,Q-X);if(Y===J){for(;J<=Q-X;X+=J)this.process($,X);continue}if(Z.set($.subarray(X,X+Y),this.pos),this.pos+=Y,X+=Y,this.pos===J)this.process(Z,0,!1),this.pos=0}return this}destroy(){Q0(this.h,this.r,this.buffer,this.pad)}digestInto($){S$(this),EZ($,this),this.finished=!0;let{buffer:Z,h:J}=this,{pos:Q}=this;if(Q){Z[Q++]=1;for(;Q<16;Q++)Z[Q]=0;this.process(Z,0,!0)}this.finalize();let X=0;for(let Y=0;Y<8;Y++)$[X++]=J[Y]>>>0,$[X++]=J[Y]>>>8;return $}digest(){let{buffer:$,outputLen:Z}=this;this.digestInto($);let J=$.slice(0,Z);return this.destroy(),J}}function XX($){let Z=(Q,X)=>$(X).update(Q$(Q)).digest(),J=$(new Uint8Array(32));return Z.outputLen=J.outputLen,Z.blockLen=J.blockLen,Z.create=(Q)=>$(Q),Z}var x$=XX(($)=>new fZ($));function YX($,Z,J,Q,X,Y=20){let V=$[0],W=Z[0],q=Z[1],M=Z[2],z=Z[3],N=$[1],K=J[0],F=J[1],R=X,I=0,P=$[2],w=Z[4],T=Z[5],A=Z[6],C=Z[7],L=$[3],B=V,u=W,S=q,k=M,g=z,x=N,f=K,H=F,y=R,l=I,b=P,h=w,D=T,c=A,a=C,e=L;for(let G0=0;G0<Y;G0+=2)g^=U(B+D|0,7),y^=U(g+B|0,9),D^=U(y+g|0,13),B^=U(D+y|0,18),l^=U(x+u|0,7),c^=U(l+x|0,9),u^=U(c+l|0,13),x^=U(u+c|0,18),a^=U(b+f|0,7),S^=U(a+b|0,9),f^=U(S+a|0,13),b^=U(f+S|0,18),k^=U(e+h|0,7),H^=U(k+e|0,9),h^=U(H+k|0,13),e^=U(h+H|0,18),u^=U(B+k|0,7),S^=U(u+B|0,9),k^=U(S+u|0,13),B^=U(k+S|0,18),f^=U(x+g|0,7),H^=U(f+x|0,9),g^=U(H+f|0,13),x^=U(g+H|0,18),h^=U(b+l|0,7),y^=U(h+b|0,9),l^=U(y+h|0,13),b^=U(l+y|0,18),D^=U(e+a|0,7),c^=U(D+e|0,9),a^=U(c+D|0,13),e^=U(a+c|0,18);let _=0;Q[_++]=V+B|0,Q[_++]=W+u|0,Q[_++]=q+S|0,Q[_++]=M+k|0,Q[_++]=z+g|0,Q[_++]=N+x|0,Q[_++]=K+f|0,Q[_++]=F+H|0,Q[_++]=R+y|0,Q[_++]=I+l|0,Q[_++]=P+b|0,Q[_++]=w+h|0,Q[_++]=T+D|0,Q[_++]=A+c|0,Q[_++]=C+a|0,Q[_++]=L+e|0}function VX($,Z,J,Q){let X=$[0],Y=Z[0],V=Z[1],W=Z[2],q=Z[3],M=$[1],z=J[0],N=J[1],K=J[2],F=J[3],R=$[2],I=Z[4],P=Z[5],w=Z[6],T=Z[7],A=$[3];for(let L=0;L<20;L+=2)q^=U(X+P|0,7),K^=U(q+X|0,9),P^=U(K+q|0,13),X^=U(P+K|0,18),F^=U(M+Y|0,7),w^=U(F+M|0,9),Y^=U(w+F|0,13),M^=U(Y+w|0,18),T^=U(R+z|0,7),V^=U(T+R|0,9),z^=U(V+T|0,13),R^=U(z+V|0,18),W^=U(A+I|0,7),N^=U(W+A|0,9),I^=U(N+W|0,13),A^=U(I+N|0,18),Y^=U(X+W|0,7),V^=U(Y+X|0,9),W^=U(V+Y|0,13),X^=U(W+V|0,18),z^=U(M+q|0,7),N^=U(z+M|0,9),q^=U(N+z|0,13),M^=U(q+N|0,18),I^=U(R+F|0,7),K^=U(I+R|0,9),F^=U(K+I|0,13),R^=U(F+K|0,18),P^=U(A+T|0,7),w^=U(P+A|0,9),T^=U(w+P|0,13),A^=U(T+w|0,18);let C=0;Q[C++]=X,Q[C++]=M,Q[C++]=R,Q[C++]=A,Q[C++]=z,Q[C++]=N,Q[C++]=K,Q[C++]=F}var g$=gZ(YX,{counterRight:!0,extendNonceFn:VX}),f$=BZ({blockSize:64,nonceLength:24,tagLength:16},($,Z)=>{return{encrypt(J,Q){Q=_$(J.length+32,Q,!1);let X=Q.subarray(0,32),Y=Q.subarray(32);Q.set(J,32),Q0(X),g$($,Z,Q,Q);let V=x$(Y,X);return Q.set(V,16),Q0(Q.subarray(0,16),V),Q.subarray(16)},decrypt(J,Q){i(J),Q=_$(J.length+32,Q,!1);let X=Q.subarray(0,32),Y=Q.subarray(32,48),V=Q.subarray(48);Q.set(J,32),Q0(X);let W=g$($,Z,X,X),q=x$(V,W);if(!SZ(Y,q))throw Error("invalid tag");return g$($,Z,Q.subarray(16),Q.subarray(16)),Q0(X,Y,q),V}}});/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function GX($){return $ instanceof Uint8Array||ArrayBuffer.isView($)&&$.constructor.name==="Uint8Array"}function c0($){if(!Number.isSafeInteger($)||$<0)throw Error("positive integer expected, got "+$)}function C0($,...Z){if(!GX($))throw Error("Uint8Array expected");if(Z.length>0&&!Z.includes($.length))throw Error("Uint8Array expected of length "+Z+", got length="+$.length)}function r0($,Z=!0){if($.destroyed)throw Error("Hash instance has been destroyed");if(Z&&$.finished)throw Error("Hash#digest() has already been called")}function V$($,Z){C0($);let J=Z.outputLen;if($.length<J)throw Error("digestInto() expects output buffer of length at least "+J)}function vZ($){return new Uint8Array($.buffer,$.byteOffset,$.byteLength)}function k0($){return new Uint32Array($.buffer,$.byteOffset,Math.floor($.byteLength/4))}function x0(...$){for(let Z=0;Z<$.length;Z++)$[Z].fill(0)}function o0($,Z){return $<<32-Z|$>>>Z}var yZ=(()=>new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68)();function lZ($){return $<<24&4278190080|$<<8&16711680|$>>>8&65280|$>>>24&255}var bZ=yZ?($)=>$:($)=>lZ($);function WX($){for(let Z=0;Z<$.length;Z++)$[Z]=lZ($[Z]);return $}var s=yZ?($)=>$:WX;function qX($){if(typeof $!=="string")throw Error("string expected");return new Uint8Array(new TextEncoder().encode($))}function g0($){if(typeof $==="string")$=qX($);return C0($),$}class v${}function hZ($){let Z=(Q,X)=>$(X).update(g0(Q)).digest(),J=$({});return Z.outputLen=J.outputLen,Z.blockLen=J.blockLen,Z.create=(Q)=>$(Q),Z}var iZ=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var G$=BigInt(4294967295),pZ=BigInt(32);function y$($,Z=!1){if(Z)return{h:Number($&G$),l:Number($>>pZ&G$)};return{h:Number($>>pZ&G$)|0,l:Number($&G$)|0}}function M0($,Z,J,Q,X){return $=$+Z+X|0,Q=o0(Q^$,16),J=J+Q|0,Z=o0(Z^J,12),{a:$,b:Z,c:J,d:Q}}function z0($,Z,J,Q,X){return $=$+Z+X|0,Q=o0(Q^$,8),J=J+Q|0,Z=o0(Z^J,7),{a:$,b:Z,c:J,d:Q}}class l$ extends v${constructor($,Z){super();this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,c0($),c0(Z),this.blockLen=$,this.outputLen=Z,this.buffer=new Uint8Array($),this.buffer32=k0(this.buffer)}update($){r0(this),$=g0($),C0($);let{blockLen:Z,buffer:J,buffer32:Q}=this,X=$.length,Y=$.byteOffset,V=$.buffer;for(let W=0;W<X;){if(this.pos===Z)s(Q),this.compress(Q,0,!1),s(Q),this.pos=0;let q=Math.min(Z-this.pos,X-W),M=Y+W;if(q===Z&&!(M%4)&&W+q<X){let z=new Uint32Array(V,M,Math.floor((X-W)/4));s(z);for(let N=0;W+Z<X;N+=Q.length,W+=Z)this.length+=Z,this.compress(z,N,!1);s(z);continue}J.set($.subarray(W,W+q),this.pos),this.pos+=q,this.length+=q,W+=q}return this}digestInto($){r0(this),V$($,this);let{pos:Z,buffer32:J}=this;this.finished=!0,x0(this.buffer.subarray(Z)),s(J),this.compress(J,0,!0),s(J);let Q=k0($);this.get().forEach((X,Y)=>Q[Y]=bZ(X))}digest(){let{buffer:$,outputLen:Z}=this;this.digestInto($);let J=$.slice(0,Z);return this.destroy(),J}_cloneInto($){let{buffer:Z,length:J,finished:Q,destroyed:X,outputLen:Y,pos:V}=this;return $||($=new this.constructor({dkLen:Y})),$.set(...this.get()),$.buffer.set(Z),$.destroyed=X,$.finished=Q,$.length=J,$.pos=V,$.outputLen=Y,$}clone(){return this._cloneInto()}}function b$($,Z,J,Q,X,Y,V,W,q,M,z,N,K,F,R,I,P,w,T,A){let C=0;for(let L=0;L<Q;L++)({a:X,b:q,c:K,d:P}=M0(X,q,K,P,J[Z+$[C++]])),{a:X,b:q,c:K,d:P}=z0(X,q,K,P,J[Z+$[C++]]),{a:Y,b:M,c:F,d:w}=M0(Y,M,F,w,J[Z+$[C++]]),{a:Y,b:M,c:F,d:w}=z0(Y,M,F,w,J[Z+$[C++]]),{a:V,b:z,c:R,d:T}=M0(V,z,R,T,J[Z+$[C++]]),{a:V,b:z,c:R,d:T}=z0(V,z,R,T,J[Z+$[C++]]),{a:W,b:N,c:I,d:A}=M0(W,N,I,A,J[Z+$[C++]]),{a:W,b:N,c:I,d:A}=z0(W,N,I,A,J[Z+$[C++]]),{a:X,b:M,c:R,d:A}=M0(X,M,R,A,J[Z+$[C++]]),{a:X,b:M,c:R,d:A}=z0(X,M,R,A,J[Z+$[C++]]),{a:Y,b:z,c:I,d:P}=M0(Y,z,I,P,J[Z+$[C++]]),{a:Y,b:z,c:I,d:P}=z0(Y,z,I,P,J[Z+$[C++]]),{a:V,b:N,c:K,d:w}=M0(V,N,K,w,J[Z+$[C++]]),{a:V,b:N,c:K,d:w}=z0(V,N,K,w,J[Z+$[C++]]),{a:W,b:q,c:F,d:T}=M0(W,q,F,T,J[Z+$[C++]]),{a:W,b:q,c:F,d:T}=z0(W,q,F,T,J[Z+$[C++]]);return{v0:X,v1:Y,v2:V,v3:W,v4:q,v5:M,v6:z,v7:N,v8:K,v9:F,v10:R,v11:I,v12:P,v13:w,v14:T,v15:A}}var X0={CHUNK_START:1,CHUNK_END:2,PARENT:4,ROOT:8,KEYED_HASH:16,DERIVE_KEY_CONTEXT:32,DERIVE_KEY_MATERIAL:64},N0=iZ.slice(),uZ=(()=>{let $=Array.from({length:16},(Q,X)=>X),Z=(Q)=>[2,6,3,10,7,0,4,13,1,11,12,5,9,14,15,8].map((X)=>Q[X]),J=[];for(let Q=0,X=$;Q<7;Q++,X=Z(X))J.push(...X);return Uint8Array.from(J)})();class h$ extends l${constructor($={},Z=0){super(64,$.dkLen===void 0?32:$.dkLen);this.chunkPos=0,this.chunksDone=0,this.flags=0,this.stack=[],this.posOut=0,this.bufferOut32=new Uint32Array(16),this.chunkOut=0,this.enableXOF=!0;let{key:J,context:Q}=$,X=Q!==void 0;if(J!==void 0){if(X)throw Error('Only "key" or "context" can be specified at same time');let Y=g0(J).slice();C0(Y,32),this.IV=k0(Y),s(this.IV),this.flags=Z|X0.KEYED_HASH}else if(X){let Y=g0(Q),V=new h$({dkLen:32},X0.DERIVE_KEY_CONTEXT).update(Y).digest();this.IV=k0(V),s(this.IV),this.flags=Z|X0.DERIVE_KEY_MATERIAL}else this.IV=N0.slice(),this.flags=Z;this.state=this.IV.slice(),this.bufferOut=vZ(this.bufferOut32)}get(){return[]}set(){}b2Compress($,Z,J,Q=0){let{state:X,pos:Y}=this,{h:V,l:W}=y$(BigInt($),!0),{v0:q,v1:M,v2:z,v3:N,v4:K,v5:F,v6:R,v7:I,v8:P,v9:w,v10:T,v11:A,v12:C,v13:L,v14:B,v15:u}=b$(uZ,Q,J,7,X[0],X[1],X[2],X[3],X[4],X[5],X[6],X[7],N0[0],N0[1],N0[2],N0[3],V,W,Y,Z);X[0]=q^P,X[1]=M^w,X[2]=z^T,X[3]=N^A,X[4]=K^C,X[5]=F^L,X[6]=R^B,X[7]=I^u}compress($,Z=0,J=!1){let Q=this.flags;if(!this.chunkPos)Q|=X0.CHUNK_START;if(this.chunkPos===15||J)Q|=X0.CHUNK_END;if(!J)this.pos=this.blockLen;if(this.b2Compress(this.chunksDone,Q,$,Z),this.chunkPos+=1,this.chunkPos===16||J){let X=this.state;this.state=this.IV.slice();for(let Y,V=this.chunksDone+1;J||!(V&1);V>>=1){if(!(Y=this.stack.pop()))break;this.buffer32.set(Y,0),this.buffer32.set(X,8),this.pos=this.blockLen,this.b2Compress(0,this.flags|X0.PARENT,this.buffer32,0),X=this.state,this.state=this.IV.slice()}this.chunksDone++,this.chunkPos=0,this.stack.push(X)}this.pos=0}_cloneInto($){$=super._cloneInto($);let{IV:Z,flags:J,state:Q,chunkPos:X,posOut:Y,chunkOut:V,stack:W,chunksDone:q}=this;return $.state.set(Q.slice()),$.stack=W.map((M)=>Uint32Array.from(M)),$.IV.set(Z),$.flags=J,$.chunkPos=X,$.chunksDone=q,$.posOut=Y,$.chunkOut=V,$.enableXOF=this.enableXOF,$.bufferOut32.set(this.bufferOut32),$}destroy(){this.destroyed=!0,x0(this.state,this.buffer32,this.IV,this.bufferOut32),x0(...this.stack)}b2CompressOut(){let{state:$,pos:Z,flags:J,buffer32:Q,bufferOut32:X}=this,{h:Y,l:V}=y$(BigInt(this.chunkOut++));s(Q);let{v0:W,v1:q,v2:M,v3:z,v4:N,v5:K,v6:F,v7:R,v8:I,v9:P,v10:w,v11:T,v12:A,v13:C,v14:L,v15:B}=b$(uZ,0,Q,7,$[0],$[1],$[2],$[3],$[4],$[5],$[6],$[7],N0[0],N0[1],N0[2],N0[3],V,Y,Z,J);X[0]=W^I,X[1]=q^P,X[2]=M^w,X[3]=z^T,X[4]=N^A,X[5]=K^C,X[6]=F^L,X[7]=R^B,X[8]=$[0]^I,X[9]=$[1]^P,X[10]=$[2]^w,X[11]=$[3]^T,X[12]=$[4]^A,X[13]=$[5]^C,X[14]=$[6]^L,X[15]=$[7]^B,s(Q),s(X),this.posOut=0}finish(){if(this.finished)return;this.finished=!0,x0(this.buffer.subarray(this.pos));let $=this.flags|X0.ROOT;if(this.stack.length)$|=X0.PARENT,s(this.buffer32),this.compress(this.buffer32,0,!0),s(this.buffer32),this.chunksDone=0,this.pos=this.blockLen;else $|=(!this.chunkPos?X0.CHUNK_START:0)|X0.CHUNK_END;this.flags=$,this.b2CompressOut()}writeInto($){r0(this,!1),C0($),this.finish();let{blockLen:Z,bufferOut:J}=this;for(let Q=0,X=$.length;Q<X;){if(this.posOut>=Z)this.b2CompressOut();let Y=Math.min(Z-this.posOut,X-Q);$.set(J.subarray(this.posOut,this.posOut+Y),Q),this.posOut+=Y,Q+=Y}return $}xofInto($){if(!this.enableXOF)throw Error("XOF is not possible after digest call");return this.writeInto($)}xof($){return c0($),this.xofInto(new Uint8Array($))}digestInto($){if(V$($,this),this.finished)throw Error("digest() was already called");return this.enableXOF=!1,this.writeInto($),this.destroy(),$}digest(){return this.digestInto(new Uint8Array(this.outputLen))}}var dZ=hZ(($)=>new h$($));function t($){return Array.from($).map((J)=>J.toString(16).padStart(2,"0")).join("")}function W$($){if($.length%2!==0)throw Error("Invalid hex string");let Z=new Uint8Array($.length/2);for(let J=0;J<$.length;J+=2)Z[J/2]=Number.parseInt($.substr(J,2),16);return Z}function f0($,Z){if($===Z)return!0;if($.byteLength!==Z.byteLength)return!1;return $.every((J,Q)=>J===Z[Q])}var nZ;if(typeof Uint8Array.prototype.toBase64==="function")nZ=($)=>$.toBase64();else nZ=($)=>btoa(String.fromCharCode(...$));var i$;if(typeof Uint8Array.fromBase64==="function")i$=($)=>Uint8Array.fromBase64($);else i$=($)=>Uint8Array.from(atob($),(Z)=>Z.charCodeAt(0));function cZ($){let Z=$.length%4===0?"":"=".repeat(4-$.length%4),J=$.replace(/-/g,"+").replace(/_/g,"/")+Z;return i$(J)}function O0($,Z){let J=new Uint8Array($.length+Z.length);return J.set($,0),J.set(Z,$.length),J}var v0=64;var rZ=32,y0=8;var oZ=32;var aZ=30000,sZ=512,j;((H)=>{H[H.Success=0]="Success";H[H.InvalidSignature=3]="InvalidSignature";H[H.ClockOutOfSync=4]="ClockOutOfSync";H[H.UserNotRegistered=5]="UserNotRegistered";H[H.ServerMisconfigured=6]="ServerMisconfigured";H[H.MissingBody=7]="MissingBody";H[H.ExtraBodyContent=8]="ExtraBodyContent";H[H.MissingParam=9]="MissingParam";H[H.InvalidParam=10]="InvalidParam";H[H.InvalidRequest=11]="InvalidRequest";H[H.InternalError=12]="InternalError";H[H.NotFound=13]="NotFound";H[H.InvalidMessage=14]="InvalidMessage";H[H.NoChange=15]="NoChange";H[H.DatabaseClosed=16]="DatabaseClosed";H[H.StorageError=17]="StorageError";H[H.DatabaseError=18]="DatabaseError";H[H.HashMismatch=19]="HashMismatch";H[H.DecryptionError=20]="DecryptionError";H[H.NotImplemented=21]="NotImplemented";H[H.MissingSeed=22]="MissingSeed";H[H.OutOfBounds=23]="OutOfBounds";H[H.HostError=24]="HostError";H[H.CommunicationError=25]="CommunicationError";H[H.VarLimitExceeded=26]="VarLimitExceeded";H[H.InvalidResponse=27]="InvalidResponse";H[H.ConnectionClosed=28]="ConnectionClosed";H[H.CryptoError=29]="CryptoError";H[H.WebAuthnError=30]="WebAuthnError"})(j||={});var eZ="t";function O($){return[$,0]}function G($){return[void 0,$]}var MX=32,ZG=Symbol("X25519Sk");function tZ($){if($.byteLength!==MX)return G(10);return O($)}var E=(1n<<255n)-19n,zX=121665n,$J=new Uint8Array(32);$J[0]=9;function ZJ($){let Z=0n;for(let J=$.length-1;J>=0;J--)Z=Z<<8n|BigInt($[J]);return Z}function NX($){let Z=new Uint8Array(32),J=($%E+E)%E;for(let Q=0;Q<32;Q++)Z[Q]=Number(J&0xffn),J>>=8n;return Z}function OX($){let Z=$.slice();return Z[31]&=127,ZJ(Z)}function KX($){let Z=$.slice();return Z[0]&=248,Z[31]&=127,Z[31]|=64,Z}function q$($,Z,J){let Q=-$,X=(Z^J)&Q;return[Z^X,J^X]}function FX($){let Z=E-2n,J=($%E+E)%E,Q=1n;while(Z>0n){if(Z&1n)Q=Q*J%E;J=J*J%E,Z>>=1n}return Q}function HX($,Z){let J=KX($),Q=OX(Z),X=1n,Y=0n,V=Q,W=1n,q=0n,M=ZJ(J);for(let z=254;z>=0;z--){let N=M>>BigInt(z)&1n;q^=N,[X,V]=q$(q,X,V),[Y,W]=q$(q,Y,W),q=N;let K=(X+Y)%E,F=K*K%E,R=(X-Y+E)%E,I=R*R%E,P=(F-I+E)%E,w=(V+W)%E,A=(V-W+E)%E*K%E,C=w*R%E,L=(A+C)%E,B=(A-C+E)%E;V=L*L%E,W=Q*B*B%E,X=F*I%E,Y=P*(F+zX*P)%E}return[X,V]=q$(q,X,V),[Y,W]=q$(q,Y,W),J.fill(0),NX(X*FX(Y)%E)}function JJ($){return HX($,$J)}var p$=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,112,4,34,4,32]);function QJ($){let Z=new Uint8Array(p$.length+32);return Z.set(p$),Z.set($.subarray(0,32),p$.length),Z}var u$=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]);function XJ($){let Z=new Uint8Array(u$.length+32);return Z.set(u$),Z.set($.subarray(0,32),u$.length),Z}function YJ($){return typeof $==="string"?new TextEncoder().encode($):$}function K0($){let Z=new ArrayBuffer($.byteLength);return new Uint8Array(Z).set($),Z}class w0{verifyKeys=new Map;async genRandomBytes($){return n0($)}async gen256BitSecureRandomSeed(){return n0(32)}async encryptXSalsa20Poly1305Combined($,Z){let J=n0(24),X=f$(Z,J).encrypt($);return new Uint8Array([...J,...X])}async decryptXSalsa20Poly1305Combined($,Z){let J=$.slice(0,24),Q=$.slice(24);return f$(Z,J).decrypt(Q)}async deriveEd25519KeyPair($){let Z=$,J=QJ(Z),Q=K0(J),X;try{let M=await globalThis.crypto.subtle.importKey("pkcs8",Q,{name:"Ed25519"},!0,["sign"]);X=await globalThis.crypto.subtle.exportKey("jwk",M)}finally{J.fill(0),new Uint8Array(Q).fill(0)}if(typeof X.x!=="string")throw Error("Ed25519 JWK missing x");let Y=X.x;X.d=void 0;let V=await globalThis.crypto.subtle.importKey("jwk",{kty:"OKP",crv:"Ed25519",x:Y},{name:"Ed25519"},!0,["verify"]),W=new Uint8Array(await globalThis.crypto.subtle.exportKey("raw",V));this.verifyKeys.set(t(W),V);let q=new Uint8Array(64);return q.set(Z,0),q.set(W,32),{keyType:"ed25519",privateKey:q,publicKey:W}}async importSignKey($){let Z=$.subarray(0,32),J=QJ(Z),Q=K0(J);try{return await globalThis.crypto.subtle.importKey("pkcs8",Q,{name:"Ed25519"},!1,["sign"])}finally{J.fill(0),new Uint8Array(Q).fill(0)}}async importVerifyKey($){let Z=t($),J=this.verifyKeys.get(Z);if(J)return J;let Q=await globalThis.crypto.subtle.importKey("raw",K0($),{name:"Ed25519"},!1,["verify"]);return this.verifyKeys.set(Z,Q),Q}async signEd25519($,Z){let J=YJ($),Q=await this.importSignKey(Z),X=await globalThis.crypto.subtle.sign({name:"Ed25519"},Q,K0(J));return new Uint8Array(X)}async checkSigEd25519($,Z,J){let Q=YJ(Z);try{let X=await this.importVerifyKey(J);return await globalThis.crypto.subtle.verify({name:"Ed25519"},X,K0($),K0(Q))}catch{return!1}}async blake3($){return dZ($)}async genX25519(){let $=await n0(32);$[0]&=248,$[31]&=127,$[31]|=64;let[Z,J]=tZ($);if(J!==0||Z===void 0)throw $.fill(0),Error("X25519 scalar brand failed");let Q=JJ(Z),X=XJ(Z),Y=K0(X);try{let V=await globalThis.crypto.subtle.importKey("pkcs8",Y,{name:"X25519"},!0,["deriveBits"]),W=await globalThis.crypto.subtle.exportKey("jwk",V);if(typeof W.x!=="string")throw Error("X25519 JWK missing x");let q=cZ(W.x);if(W.d=void 0,!f0(q,Q))throw Error("X25519 WebCrypto pub != RFC 7748");return{priv:Z,pub:Q}}catch(V){throw Z.fill(0),V}finally{X.fill(0),new Uint8Array(Y).fill(0)}}async x25519Shared($,Z){let J=XJ($),Q=K0(J);try{let X=await globalThis.crypto.subtle.importKey("pkcs8",Q,{name:"X25519"},!1,["deriveBits"]),Y=await globalThis.crypto.subtle.importKey("raw",K0(Z),{name:"X25519"},!1,[]),V=await globalThis.crypto.subtle.deriveBits({name:"X25519",public:Y},X,256);return new Uint8Array(V)}finally{J.fill(0),new Uint8Array(Q).fill(0)}}}var IX=new w0,l0=IX;function RX($){if($<0)console.info("N",$),console.trace();if(typeof $!=="bigint")$=BigInt($);if($<0n)return G(10);let Z=[];while($>0n){let J=Number($&0x7fn);if($>>=7n,$>0n)Z.push(J|128);else Z.push(J)}if(Z.length===0)return O(new Uint8Array([0]));if(Z.length>8)return G(26);return O(new Uint8Array(Z))}function PX($,Z=0){let J=0n,Q=0,X=Z;while(!0){if(X>=$.length)return G(14);let Y=$[X++];if(Y===void 0)return G(14);if(J|=BigInt(Y&127)<<BigInt(Q),(Y&128)===0){if(X-Z>8)return G(26);return O({value:J>0x1fffffffffffffn?J:Number(J),bytesRead:X-Z})}if(Q+=7,Q>=56)return G(26)}}class p{data;pos=0;constructor($){this.data=$}static async fromResponse($){let Z=await $.arrayBuffer(),J=new Uint8Array(Z);return new p(J)}readBigInt(){if(this.pos+8>this.data.length)return G(7);let $=new DataView(this.data.buffer,this.data.byteOffset+this.pos).getBigUint64(0,!1);return this.pos+=8,O($)}readDate(){let[$,Z]=this.readVarInt();if(Z!==0)return G(Z);return O(new Date($))}readVarInt(){let[$,Z]=PX(this.data,this.pos);if(Z!==0)return G(Z);this.pos+=$.bytesRead;let J=$.value;return O(typeof J==="bigint"?Number(J):J)}readVarString(){let[$,Z]=this.readVarInt();if(Z!==0)return G(Z);let[J,Q]=this.readBytes($);if(Q!==0)return G(Q);let X=new TextDecoder().decode(J);return O(X)}readBytes($){if($<0)return G(10);if(this.pos+$>this.data.length)return G(23);let Z=this.data.slice(this.pos,this.pos+$);return this.pos+=$,O(Z)}readVarBytes(){let[$,Z]=this.readVarInt();if(Z!==0)return G(Z);return this.readBytes($)}readStruct($){return $.decode(this)}readStructs($){let Z=[];while(!this.done()){let[J,Q]=this.readStruct($);if(Q!==0)return G(Q);Z.push(J)}return O(Z)}readBytesSeq($){let Z=[];while(!this.done()){let[J,Q]=this.readBytes($);if(Q!==0)return G(Q);Z.push(J)}return O(Z)}done(){return this.pos>=this.data.length}consumed(){return this.pos}}class m{parts=[];writeBigInt($){let Z=new Uint8Array(8);new DataView(Z.buffer).setBigUint64(0,$,!1),this.parts.push(Z)}writeDate($){let Z=$.getTime();return this.writeVarInt(Z)}writeVarInt($){let[Z,J]=RX($);if(J!==0)return J;return this.parts.push(Z),0}writeVarString($){let Z=new TextEncoder().encode($),J=this.writeVarInt(Z.length);if(J!==0)return J;return this.writeBytes(Z),0}prependBytes($){this.parts.unshift($.slice())}writeBytes($){this.parts.push($.slice())}writeVarBytes($){let Z=this.writeVarInt($.length);if(Z!==0)return Z;return this.writeBytes($),0}writeStruct($,Z){return $.encode(this,Z)}writeStructs($,Z){for(let J of Z){let Q=this.writeStruct($,J);if(Q!==0)return Q}return 0}writeBytesSeq($){for(let Z of $)this.writeBytes(Z)}result(){let $=this.parts.reduce((Q,X)=>Q+X.length,0),Z=new Uint8Array($),J=0;for(let Q of this.parts)Z.set(Q,J),J+=Q.length;return Z}wipe(){for(let $ of this.parts)$.fill(0);this.parts.length=0}*scan(){for(let $ of this.parts)yield $}}var a0={encode($,Z){let J=$.writeVarBytes(Z.id);if(J!==0)return J;let Q=$.writeDate(Z.ts);if(Q!==0)return Q;return 0},decode($){let[Z,J]=$.readVarBytes();if(J!==0)return G(J);let[Q,X]=$.readDate();if(X!==0)return G(X);return O({id:Z,ts:Q})}};function VJ($){let Z=new m,J=Z.writeStruct(a0,$);if(J!==0)return G(J);let Q=Z.result();return O(Q)}var d$={encode($,Z){let J=$.writeVarBytes(Z.eid);if(J!==0)return J;let Q=$.writeVarInt(Z.off);if(Q!==0)return Q;let X=$.writeVarInt(Z.ctr);if(X!==0)return X;let Y=$.writeVarInt(Z.len);if(Y!==0)return Y;if(Z.hsh)$.writeBytes(Z.hsh);return 0},decode($){let[Z,J]=$.readVarBytes();if(J!==0)return G(J);let Q=new p(Z),[,X]=a0.decode(Q);if(X!==0)return G(X);let[Y,V]=$.readVarInt();if(V!==0)return G(V);let[W,q]=$.readVarInt();if(q!==0)return G(q);let[M,z]=$.readVarInt();if(z!==0)return G(z);let N;if(M>0){let[K,F]=$.readBytes(oZ);if(F!==0)return G(F);N=K}return O({eid:Z,off:Y,ctr:W,len:M,hsh:N})}};function GJ($,Z,J){return J.checkSigEd25519($.sig,$.headCph,Z)}async function WJ($,Z,J,Q){let X;if($.bod&&$.len>0)X=await J.blake3($.bod);let Y=new m,V=d$.encode(Y,{...$,hsh:X});if(V!==0)return G(V);let W=Y.result(),q=await Z.kdmFor(W),M=Q.deriveCipher(q,"encrypt"),z=await M.encrypt(W),N=$.bod?await M.encrypt($.bod):new Uint8Array(0),K=await Z.sign(z);return O({sig:K,kdm:q,headCph:z,bodyCph:N})}async function qJ($,Z,J,Q,X){let Y=new p($),[V,W]=d$.decode(Y);if(W!==0)return G(14);let q;try{q=Z&&Z.length>0?await J.decrypt(Z):void 0}catch{return G(20)}let M=V.hsh&&q===void 0,z=V.hsh===void 0&&q!==void 0;if(M||z)return G(19);if(V.hsh&&q){let K=await Q.blake3(q);if(!f0(K,V.hsh))return G(19)}let N=X??await Q.blake3($);return O({msgHead:V,bod:q,headHash:N})}async function n$($,Z){let J=new m,Q=J.writeDate(Z);if(Q!==0)return G(Q);let X=J.result(),Y=await $.sign(X);return O({pubKey:$.publicKey,sig:Y,timestamp:Z})}async function Z0($,Z,J){let Q=J.now().getTime(),X=$.timestamp.getTime();if(Math.abs(Q-X)>aZ)return 4;let V=new m;V.writeDate($.timestamp);let W=V.result();if(!await Z.checkSigEd25519($.sig,W,$.pubKey))return 3;return 0}class b0{now(){return new Date}}function MJ($,Z,J,Q){let X=Z.getTime()-$.getTime(),Y=J.getTime()-Q.getTime();return(X+Y)/2}var s0={encode($,Z){if($.writeVarInt(Z.quota),Z.quota>0){if(Z.usage===void 0)return 9;$.writeVarInt(Z.usage)}return 0},decode($){let[Z,J]=$.readVarInt();if(J!==0)return G(J);let Q;if(Z>0){let[X,Y]=$.readVarInt();if(Y!==0)return G(Y);Q=X}return O({quota:Z,usage:Q})}};var h0={encode($,Z){$.writeBytes(new Uint8Array([Z.status]));let J=$.writeDate(Z.timeRcvd);if(J!==0)return J;let Q=$.writeDate(Z.timeSent);if(Q!==0)return Q;let X=$.writeVarInt(Z.subscription.term);if(X!==0)return X;let Y=$.writeVarInt(Z.subscription.elapsed);if(Y!==0)return Y;let V=$.writeStruct(s0,Z.subscription.stat);if(V!==0)return V;let W=$.writeStruct(s0,Z.subscription.dyn);if(W!==0)return W;return 0},decode($){let[Z,J]=$.readBytes(1);if(J!==0)return G(J);let Q=Z[0],[X,Y]=$.readDate();if(Y!==0)return G(Y);let[V,W]=$.readDate();if(W!==0)return G(W);let[q,M]=$.readVarInt();if(M!==0)return G(M);let[z,N]=$.readVarInt();if(N!==0)return G(N);let[K,F]=$.readStruct(s0);if(F!==0)return G(F);let[R,I]=$.readStruct(s0);if(I!==0)return G(I);return O({status:Q,timeRcvd:X,timeSent:V,subscription:{term:q,elapsed:z,stat:K,dyn:R}})}};var c$={encode($,Z){let J=$.writeVarBytes(Z.headCph);if(J!==0)return J;let Q=$.writeVarInt(Z.seq);if(Q!==0)return Q;return 0},decode($){let[Z,J]=$.readVarBytes();if(J!==0)return G(J);let[Q,X]=$.readVarInt();if(X!==0)return G(X);return O({headCph:Z,seq:Q})}};var o={encode($,Z){$.writeBytes(Z.pubKey),$.writeBytes(Z.sig);let J=$.writeDate(Z.timestamp);if(J!==0)return J;return 0},decode($){let[Z,J]=$.readBytes(rZ);if(J!==0)return G(J);let[Q,X]=$.readBytes(v0);if(X!==0)return G(X);let[Y,V]=$.readDate();if(V!==0)return G(V);return O({pubKey:Z,sig:Q,timestamp:Y})}};var zJ={async encodeReq($,Z,J,Q,X){let Y=X.writeStruct(o,J);if(Y!==0)return Y;for(let V of Q)X.writeVarInt(V);return 0},async handleReq($,Z,J){let{clock:Q,crypto:X,storage:Y}=$,[V,W]=Z.readStruct(o);if(W!==0)return W;let q=await Z0(V,X,Q);if(q!==0)return q;let{pubKey:M}=V,[z,N]=await Y.hasUser(M);if(N!==0)return N;if(!z)return 5;let[K,F]=Z.readVarInt();if(F!==0)return F;if(!Z.done())return 8;let[R,I]=await Y.listHeads(M,K);if(I!==0)return I;return J.writeStructs(c$,R)},decodeResp($){return $.readStructs(c$)}};var r$={encode($,Z){$.writeVarInt(Z.seq);let J=$.writeVarBytes(Z.bodyCph);if(J!==0)return J;return 0},decode($){let[Z,J]=$.readVarInt();if(J!==0)return G(J);let[Q,X]=$.readVarBytes();if(X!==0)return G(X);return O({seq:Z,bodyCph:Q})}};var NJ={async encodeReq($,Z,J,Q,X){let Y=X.writeStruct(o,J);if(Y!==0)return Y;for(let V of Q){let W=X.writeVarInt(V);if(W!==0)return W}return 0},async handleReq($,Z,J){let{clock:Q,crypto:X,storage:Y}=$,[V,W]=Z.readStruct(o);if(W!==0)return W;let q=await Z0(V,X,Q);if(q!==0)return q;let{pubKey:M}=V,[z,N]=await Y.hasUser(M);if(N!==0)return N;if(!z)return 5;let K=[];while(!Z.done()){let[I,P]=Z.readVarInt();if(P!==0)return P;K.push(I)}console.info(`PULL: ${K.length} bags`);let[F,R]=await Y.getBodies(M,K);if(R!==0)return R;if(!F)return 17;for(let{seq:I,bodyCph:P}of F){let w={seq:I,bodyCph:P},T=J.writeStruct(r$,w);if(T!==0)return T}return 0},decodeResp($){return $.readStructs(r$)}};var o$={encode($,Z){$.writeBytes(Z.sig),$.writeBytes(Z.kdm);let J=$.writeVarBytes(Z.headCph);if(J!==0)return J;let Q=$.writeVarBytes(Z.bodyCph);if(Q!==0)return Q;return 0},decode($){let[Z,J]=$.readBytes(v0);if(J!==0)return G(J);let[Q,X]=$.readBytes(y0);if(X!==0)return G(X);let[Y,V]=$.readVarBytes();if(V!==0)return G(V);let[W,q]=$.readVarBytes();if(q!==0)return G(q);return O({sig:Z,kdm:Q,headCph:Y,bodyCph:W})}};var a$={encode($,Z){let J=$.writeVarInt(Z.seq);if(J!==0)return J;let Q=$.writeVarBytes(Z.headCph);if(Q!==0)return Q;let X=Z.bodyCph?Z.bodyCph.length:0,Y=$.writeVarInt(X);if(Y!==0)return Y;if(X>0){if(!Z.bodyCph)return 10;$.writeBytes(Z.bodyCph)}return 0},decode($){let[Z,J]=$.readVarInt();if(J!==0)return G(J);let[Q,X]=$.readVarBytes();if(X!==0)return G(X);let[Y,V]=$.readVarInt();if(V!==0)return G(V);let W;if(Y>0){let[q,M]=$.readBytes(Y);if(M!==0)return G(M);W=q}return O({seq:Z,headCph:Q,bodyCph:W})}};var i0={encode($,Z){$.writeBytes(Z.sig),$.writeBytes(Z.kdm);let J=$.writeVarBytes(Z.headCph);if(J!==0)return J;return 0},decode($){let[Z,J]=$.readBytes(v0);if(J!==0)return G(J);let[Q,X]=$.readBytes(y0);if(X!==0)return G(X);let[Y,V]=$.readVarBytes();if(V!==0)return G(V);return O({sig:Z,kdm:Q,headCph:Y})}};var M$={encode($,Z){if($.writeVarInt(Z.idx),$.writeBytes(new Uint8Array([Z.status])),Z.status===0)$.writeVarInt(Z.seq);return 0},decode($){let[Z,J]=$.readVarInt();if(J!==0)return G(J);let[Q,X]=$.readBytes(1);if(X!==0)return G(X);let Y=Q[0];if(Y!==0)return O({idx:Z,status:Y});let[V,W]=$.readVarInt();if(W!==0)return G(W);return O({idx:Z,status:Y,seq:V})}};var OJ={async encodeReq($,Z,J,Q,X){let Y=X.writeStruct(o,J);if(Y!==0)return Y;let V=X.writeStructs(o$,Q);if(V!==0)return V;return 0},async handleReq($,Z,J){let{clock:Q,crypto:X,storage:Y,notifier:V}=$,[W,q]=Z.readStruct(o);if(q!==0)return q;let M=await Z0(W,X,Q);if(M!==0)return M;let{pubKey:z}=W,[N,K]=await Y.hasUser(z);if(K!==0)return K;if(!N)return 5;let[F,R]=Z.readStructs(o$);if(R!==0)return R;console.info(`PUSH: ${F.length} bags`);let I=[],P=[];for(let C=0;C<F.length;C++){let L=F[C];if(!await GJ(L,z,X)){let u={idx:C,status:3},S=J.writeStruct(M$,u);if(S!==0)return S;continue}I.push(C),P.push(L)}let[w,T]=await Y.setBags(z,P);if(T!==0)return T;if(!w||w.length!==P.length)return 17;let A=[];for(let C=0;C<P.length;C++){let L=P[C],B=I[C],u=w[C],S=new m,k=S.writeStruct(i0,L);if(k!==0)return k;let g=S.result(),x={seq:u,headCph:g};if(F.length===1&&L.bodyCph.length<=sZ)x.bodyCph=L.bodyCph;A.push(x);let f={idx:B,status:0,seq:u},H=J.writeStruct(M$,f);if(H!==0)return H}if(A.length>0){let C=new m,L=C.writeStructs(a$,A);if(L!==0)return L;let B=C.result();await Promise.resolve(V.push(z,B))}return 0},decodeResp($){return $.readStructs(M$)}};var KJ={async encodeReq($,Z,J,Q,X){return X.writeStruct(o,J)},async handleReq($,Z,J){let{clock:Q,crypto:X,storage:Y}=$,[V,W]=Z.readStruct(o);if(W!==0)return W;let q=await Z0(V,X,Q);if(q!==0)return q;let{pubKey:M}=V;if(!Z.done())return 8;let[z,N]=await Y.addUser(M);if(N!==0)return N;return 0},decodeResp($){return O(void 0)}};class s${url;websocket;constructor($){this.url=$}connected(){return this.websocket!==void 0&&this.websocket.readyState===WebSocket.OPEN}async connect($,Z,J=()=>{},Q=()=>{}){let{url:X}=this;if(this.websocket)this.websocket.close(),this.websocket=void 0;let Y=new m;Y.writeStruct(o,$);let V=Y.result(),W=t(V);return X.searchParams.set("t",W),this.websocket=new WebSocket(X),this.websocket.binaryType="arraybuffer",this.websocket.onopen=()=>{console.log("CONNECTED"),Q()},this.websocket.onclose=()=>{console.log("DISCONNECTED"),this.websocket=void 0,J()},this.websocket.onmessage=(q)=>{let M=new Uint8Array(q.data);Z(M)},this.websocket.onerror=(q)=>{console.log(`ERROR: ${JSON.stringify(q)}`),this.websocket=void 0,J()},Promise.resolve(0)}disconnect(){this.websocket?.close(),this.websocket=void 0}}var n={user:{path:"/user",endpoint:KJ,name:0},push:{path:"/push",endpoint:OJ,name:2},peek:{path:"/peek",endpoint:zJ,name:1},pull:{path:"/pull",endpoint:NJ,name:3}},UX={0:n.user,2:n.push,1:n.peek,3:n.pull},FJ={[n.user.path]:n.user,[n.push.path]:n.push,[n.peek.path]:n.peek,[n.pull.path]:n.pull};class HJ{url;listener;constructor($){this.url=$;this.listener=new s$($)}async call($,Z){let{path:J}=UX[$],Q=new URL(J,this.url);try{return await wX(Q,Z)}catch{return G(25)}}}var e$=($)=>{return new HJ($.handle)};function p0($){let Z=new m;if(Z.writeStruct(h0,$)!==0)return new Response(null,{status:500});return t$(Z)}function t$($){let Z=$.result().slice();return new Response(Z,{status:200,headers:{"content-type":"application/octet-stream"}})}var CX={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"GET,POST,OPTIONS"};function $Z($){return new Response($.body,{headers:{...$.headers,...CX},status:$.status,statusText:$.statusText})}async function wX($,Z){let J=await fetch($,{method:"POST",body:Z.result().slice()});if(!J.ok)return G(24);let Q=await p.fromResponse(J);return O(Q)}class z${enclave;crypto;host;clock;transport;updateHostMeta;constructor($,Z,J,Q,X,Y){this.enclave=$;this.crypto=Z;this.host=J;this.clock=Q;this.transport=X;this.updateHostMeta=Y}async call($,Z){let{clock:J,transport:Q}=this,{endpoint:X,name:Y}=$,V=await this.identity(),W=J.now(),[q,M]=await n$(V,W);if(M!==0)return G(M);let z=new m,N=await X.encodeReq(this,V,q,Z,z);if(N!==0)return G(N);let K=J.now(),[F,R]=await Q.call(Y,z),I=J.now();if(R!==0)return G(R);let[P,w]=F.readStruct(h0);if(w!==0)return G(w);if(P.status!==0)return G(P.status);let A={clockOffset:MJ(K,P.timeRcvd,P.timeSent,I),subscription:P.subscription},C=await this.updateHostMeta(A);if(C!==0)return G(C);return X.decodeResp(F)}identity=()=>{let{host:$,enclave:Z}=this;return Z.deriveIdentity($.label,$.idx??0)};seal=async($)=>{let{crypto:Z,enclave:J}=this,Q=await this.identity();return WJ($,Q,Z,J)};register=()=>this.call(n.user,[]);peek=($)=>this.call(n.peek,[$]);push=($)=>this.call(n.push,$);pull=($)=>this.call(n.pull,$);listen=async($,Z,J)=>{let{clock:Q,transport:X}=this,{listener:Y}=X,V=await this.identity(),W=Q.now(),[q,M]=await n$(V,W);if(M!==0)return M;return await Y.connect(q,$,Z,J)};isConnected(){let $=this.transport?.listener;if($&&typeof $.connected==="function")return $.connected();return!0}closeListener(){this.transport?.listener?.disconnect()}}var N$={encode($,Z){let J=$.writeVarString(Z.handle);if(J!==0)return J;let Q=$.writeVarString(Z.label);if(Q!==0)return Q;return $.writeVarInt(Z.idx??0)},decode($){let[Z,J]=$.readVarString();if(J!==0)return G(J);let[Q,X]=$.readVarString();if(X!==0)return G(X);let[Y,V]=$.readVarInt();if(V!==0)return G(V);return O({handle:Z,label:Q,idx:Y})}};var ZZ={encode($,Z){let J=$.writeVarInt(Z.hosts.length);if(J!==0)return J;for(let Q of Z.hosts){let X=$.writeStruct(N$,Q);if(X!==0)return X}return 0},decode($){let[Z,J]=$.readVarInt();if(J!==0)return G(J);if(Z===void 0||Z<0)return G(10);let Q=[];for(let X=0;X<Z;X++){let[Y,V]=$.readStruct(N$);if(V!==0)return G(V);if(Y===void 0)return G(14);Q.push(Y)}return O({hosts:Q})}};var S8=Symbol("MasterSeed"),B8=Symbol("SealedMasterKey"),Y0=32,IJ=24+Y0+16;function e0($){if($.byteLength!==Y0)return G(10);return O($)}function O$($){if($.byteLength!==IJ)return G(10);return O($)}var TX=new TextEncoder().encode("diplomatic.qrpair.v1"),t0=32,DX=t0+24+16,AX=32,y8=Symbol("DHKEReq"),l8=Symbol("DHKEResp");function RJ($){if($.byteLength!==t0)return G(10);return O($)}function PJ($){if($.byteLength<DX)return G(10);return O($)}var K$=new w0;async function JZ($,Z,J,Q){let X;try{X=await K$.x25519Shared($,Z)}catch{return G(29)}try{if(X.byteLength!==t0||X.every((W)=>W===0))return G(10);let Y=O0(X,TX),V=O0(Y,O0(J,Q));try{let W=await K$.blake3(V);return O(W.slice(0,AX))}finally{Y.fill(0),V.fill(0)}}finally{X.fill(0)}}class F${#$;#Z;constructor($,Z){this.#$=$,this.#Z=Z}static async create(){let $;try{let Z=await K$.genX25519();$=Z.priv;let[J,Q]=RJ(Z.pub);if(Q!==0)return G(Q);if(J===void 0)return G(10);let X=new F$($,J);return $=void 0,O(X)}catch{return G(29)}finally{$?.fill(0)}}wipe(){this.#$.fill(0)}get dhkeReq(){let[$,Z]=RJ(this.#Z.slice());if($===void 0)throw Error(`dhkeReq ${Z}`);return $}async finish($){let Z=$.subarray(0,t0),J=$.subarray(t0),[Q,X]=await JZ(this.#$,Z,this.#Z,Z);if(X!==0)return G(X);if(Q===void 0)return G(12);let Y;try{try{Y=await K$.decryptXSalsa20Poly1305Combined(J,Q)}catch{return G(20)}let[V,W]=J0.fromPairPlain(Y);if(W!==0)return G(W);if(V===void 0)return G(12);return this.wipe(),O(V)}finally{Q.fill(0),Y?.fill(0)}}}function F0($){let Z=new Uint8Array($);if($>0)crypto.getRandomValues(Z);return Z}var T0=32,H$="DIPLOMATIC",V0="public-key",jX=-7,LX=-8,EX=-257,I$=[{type:V0,alg:jX},{type:V0,alg:LX},{type:V0,alg:EX}];function mX($){return $.trim().toLowerCase().replace(/\.$/,"")||"localhost"}function R0($){let Z=new Uint8Array($.byteLength);return Z.set($),Z.buffer}function R$($){if($ instanceof ArrayBuffer)return new Uint8Array($).slice();return new Uint8Array($.buffer,$.byteOffset,$.byteLength).slice()}function D0($){if($?.rpId!==void 0)return O($.rpId);if(typeof location>"u")return G(9);return O(mX(location.hostname))}var UJ="";function P0($){if($ instanceof Error){UJ=$.message===""?$.name:`${$.name}: ${$.message}`;return}UJ=String($)}function A0(){if(typeof navigator>"u"||!navigator.credentials||typeof PublicKeyCredential>"u")return 24;return 0}function j0($){if($===null||$.type!==V0||!("rawId"in $)||typeof $.getClientExtensionResults!=="function")return G(27);return O($)}function XZ($){if($==="platform"||$==="cross-platform")return $;return}function YZ($){let Z=$.response;if(!("getTransports"in Z))return;let J=Z.getTransports;if(typeof J!=="function")return;let Q=J.call(Z);if(!Array.isArray(Q))return;let X=[];for(let Y of Q)if(typeof Y==="string"&&Y.length>0)X.push(Y);return X.length===0?void 0:X}var SX=32,BX=64,QZ=37,CJ=16;function wJ($){let Z=$.response;if(!("getAuthenticatorData"in Z))return;let J=Z.getAuthenticatorData;if(typeof J!=="function")return;let Q=J.call(Z);if(!(Q instanceof ArrayBuffer))return;let X=new Uint8Array(Q);if(X.byteLength<QZ+CJ)return;let Y=X[SX];if(Y===void 0||(Y&BX)===0)return;return X.slice(QZ,QZ+CJ)}async function TJ($){let Z=A0();if(Z!==0)return G(Z);let[J,Q]=D0($);if(Q!==0)return G(Q);if(J===void 0)return G(9);let X=$?.userName??"diplomatic-seed",Y={residentKey:"required",requireResidentKey:!0,userVerification:"required"};if($?.authenticatorAttachment!==void 0)Y.authenticatorAttachment=$.authenticatorAttachment;let V={largeBlob:{support:"required"}},W;try{W=await navigator.credentials.create({publicKey:{challenge:F0(T0),rp:{id:J,name:$?.rpName??H$},user:{id:F0(16),name:X,displayName:X},pubKeyCredParams:I$,authenticatorSelection:Y,extensions:V,...$?.hints!==void 0?{hints:$.hints}:{}}})}catch(N){return P0(N),G(30)}let[q,M]=j0(W);if(M!==0)return G(M);if(q===void 0)return G(27);if(q.getClientExtensionResults().largeBlob?.supported!==!0)return G(30);return O(new Uint8Array(q.rawId))}async function VZ($,Z,J,Q){let X={challenge:F0(T0),rpId:$,userVerification:"preferred"};if(Z?.hints!==void 0)X.hints=Z.hints;if(J!==void 0)X.allowCredentials=[{type:V0,id:R0(J)}];if(Q!==void 0)X.extensions=Q;let Y;try{Y=await navigator.credentials.get({publicKey:X})}catch(q){return P0(q),G(30)}let[V,W]=j0(Y);if(W!==0)return G(W);if(V===void 0)return G(27);return O(V)}async function DJ($,Z){let J=A0();if(J!==0)return G(J);let[Q,X]=D0(Z);if(X!==0)return G(X);if(Q===void 0)return G(9);let Y=$;if(Y===void 0){let[N,K]=await VZ(Q,Z);if(K!==0&&Z?.hints!==void 0)[N,K]=await VZ(Q,{rpId:Z.rpId,rpName:Z.rpName});if(K!==0)return G(K);if(N===void 0)return G(27);Y=new Uint8Array(N.rawId)}let[V,W]=await VZ(Q,Z,Y,{largeBlob:{read:!0}});if(W!==0)return G(W);if(V===void 0)return G(27);let M=V.getClientExtensionResults().largeBlob;if(M===void 0||M.blob===void 0)return G(7);let z=R$(M.blob);if(z.byteLength===0)return G(7);return O({blob:z,credId:new Uint8Array(V.rawId)})}var GZ=new TextEncoder().encode("diplomatic.prf.v1"),WZ="diplomatic-prf";var P$="";var C$=typeof globalThis.Worker==="function"?globalThis.Worker:void 0,qZ=C$===void 0?void 0:C$.prototype.postMessage,U$;function kX(){if(typeof P$!=="string"||P$.length===0)throw Error("[DIPLOMATIC] worker source not embedded; run pkg build before spawn");return atob(P$)}function xX(){if(U$!==void 0)return U$;let $=new Blob([kX()],{type:"text/javascript"});return U$=URL.createObjectURL($),U$}function AJ(){if(C$===void 0)throw Error("[DIPLOMATIC] Worker API unavailable; cannot spawn sync worker");return new C$(xX(),{type:"module"})}function jJ($,Z,J){if(qZ===void 0)throw Error("[DIPLOMATIC] Worker API unavailable; cannot post to sync worker");if(J!==void 0&&J.length>0)qZ.call($,Z,{transfer:J});else qZ.call($,Z)}var gX=new TextEncoder().encode("diplomatic.bind.v1"),MZ=new TextEncoder().encode("diplomatic.bindtag.v1"),fX=32,vX=32,yX=16,$0=new w0;function lX($){return $.map((Z)=>({handle:Z.handle,label:Z.label,idx:Z.idx??0}))}function LJ($){if($.byteLength===0||$.every((W)=>W===0))return G(22);if($.byteLength<Y0+1)return G(14);let Z=$.subarray(0,Y0);if(Z.every((W)=>W===0))return G(22);let J=new p($.subarray(Y0)),[Q,X]=J.readStruct(ZZ);if(X!==0)return G(X);if(Q===void 0)return G(14);if(!J.done())return G(14);let[Y,V]=J0.fromBytes(Z);if(V!==0)return G(V);if(Y===void 0)return G(12);return O({enclave:Y,hosts:Q.hosts.map((W)=>({...W}))})}async function EJ($,Z,J){let Q=A0();if(Q!==0)return Q;let[X,Y]=D0(J);if(Y!==0)return Y;if(X===void 0)return 9;let V=new Uint8Array(Z.byteLength);V.set(Z);let W;try{W=await navigator.credentials.get({publicKey:{challenge:F0(T0),rpId:X,allowCredentials:[{type:V0,id:R0($)}],userVerification:"required",extensions:{largeBlob:{write:V.buffer}},...J?.hints!==void 0?{hints:J.hints}:{}}})}catch(N){return P0(N),30}finally{V.fill(0)}let[q,M]=j0(W);if(M!==0)return M;if(q===void 0)return 27;if(q.getClientExtensionResults().largeBlob?.written!==!0)return 30;return 0}var zZ=32;function bX($){if($===void 0)return[];if($ instanceof Uint8Array)return[$];return $.filter((Z)=>Z.byteLength>0)}function hX($){if(!($ instanceof Error))return!1;return $.name==="NotSupportedError"||$.name==="TypeError"}function BJ($){if($===void 0)return;let Z=R$($);if(Z.byteLength<zZ){Z.fill(0);return}if(Z.byteLength===zZ)return Z;let J=Z.slice(0,zZ);return Z.fill(0),J}async function iX($){let Z=A0();if(Z!==0)return G(Z);let[J,Q]=D0($);if(Q!==0)return G(Q);if(J===void 0)return G(9);let X=$?.userName??WZ,Y=$?.displayName??X,V=F0(16),W=$?.authenticatorAttachment==="cross-platform",q={residentKey:W?"discouraged":"required",requireResidentKey:!W,userVerification:W?"preferred":"required"};if($?.authenticatorAttachment!==void 0)q.authenticatorAttachment=$.authenticatorAttachment;let M={challenge:F0(T0),rp:{id:J,name:$?.rpName??H$},user:{id:V,name:X,displayName:Y},pubKeyCredParams:I$,authenticatorSelection:q,...$?.hints!==void 0?{hints:$.hints}:{},...$?.excludeCredentials!==void 0&&$.excludeCredentials.length>0?{excludeCredentials:$.excludeCredentials.map((T)=>({type:V0,id:R0(T)}))}:{}},z=$?.salt!==void 0?R0($.salt):void 0,N=(T)=>navigator.credentials.create({publicKey:{...M,extensions:T&&z!==void 0?{prf:{eval:{first:z}}}:{prf:{}}}}),K;try{K=await N(z!==void 0)}catch(T){if(z===void 0||!hX(T))return P0(T),G(30);try{K=await N(!1)}catch(A){return P0(A),G(30)}}let[F,R]=j0(K);if(R!==0)return G(R);if(F===void 0)return G(27);let I=F.getClientExtensionResults(),P=BJ(I.prf?.results?.first),w=I.prf?.enabled===!0||P!==void 0;if(W&&P!==void 0)P.fill(0);return O({credId:new Uint8Array(F.rawId),userId:new Uint8Array(V),prfEnabled:w,prf:W?void 0:P,attachment:XZ(F.authenticatorAttachment),transports:YZ(F),aaguid:wJ(F)})}async function mJ($){let Z=A0();if(Z!==0)return G(Z);let[J,Q]=D0($);if(Q!==0)return G(Q);if(J===void 0)return G(9);let X=$?.salt??GZ,Y=R0(X),V={challenge:F0(T0),rpId:J,userVerification:"preferred",extensions:{prf:{eval:{first:Y}}}};if($?.hints!==void 0)V.hints=$.hints;let W=bX($?.credId);if(W.length>0)V.allowCredentials=W.map((F)=>({type:V0,id:R0(F)}));let q;try{q=await navigator.credentials.get({publicKey:V})}catch(F){return P0(F),G(30)}let[M,z]=j0(q);if(z!==0)return G(z);if(M===void 0)return G(27);let N=M.getClientExtensionResults().prf?.results;if(N?.first===void 0)return G(7);let K=BJ(N.first);if(K===void 0)return G(27);return O({prf:K,credId:new Uint8Array(M.rawId),attachment:XZ(M.authenticatorAttachment),transports:YZ(M)})}class J0{#$;constructor($){this.#$=$}static async fromRandom(){let $=await $0.gen256BitSecureRandomSeed(),[Z,J]=e0($);if(J!==0||Z===void 0)throw Error(`enclave: invalid random seed (${J})`);return new J0(Z)}static fromBytes($){let[Z,J]=e0($);if(J!==0)return G(J);if(Z===void 0)return G(10);let[Q,X]=e0(Z.slice());if(X!==0)return G(X);if(Q===void 0)return G(10);return O(new J0(Q))}async sealWithPasskey($){let Z=$?.salt??GZ,J=$?.credId,Q=J,X=$?.createCredIfNeeded===!0&&(J===void 0||!(J instanceof Uint8Array)&&J.length===0),Y,V;if(X){let[z,N]=await iX({rpId:$?.rpId,rpName:$?.rpName,userName:$?.userName??WZ,displayName:$?.displayName,authenticatorAttachment:$?.authenticatorAttachment,hints:$?.hints,excludeCredentials:$?.excludeCredentials,salt:Z});if(N!==0)return G(N);if(z===void 0)return G(30);if(!z.prfEnabled)return G(30);Q=z.credId,Y=z,V=z.prf}let W=async(z,N,K,F)=>{try{let[R,I]=await this.#V(z);if(I!==0)return G(I);if(R===void 0)return G(12);return O({sealedMaster:R,salt:Z.slice(),credId:N.slice(),userId:Y?.userId===void 0?void 0:Y.userId.slice(),attachment:K??Y?.attachment,transports:F??Y?.transports,aaguid:Y?.aaguid===void 0?void 0:Y.aaguid.slice()})}finally{z.fill(0)}};if(V!==void 0&&Y!==void 0)return W(V,Y.credId,Y.attachment,Y.transports);let[q,M]=await mJ({rpId:$?.rpId,rpName:$?.rpName,credId:Q,salt:Z,hints:$?.hints});if(M!==0)return G(M);if(q===void 0)return G(7);return W(q.prf,q.credId,q.attachment,q.transports)}async bind($,Z){if(Z!==void 0){for(let Y of Z)if(!await this.#Y(Y.credId,Y.tag))return G(10)}let[J,Q]=await this.sealWithPasskey($);if(Q!==0)return G(Q);if(J===void 0)return G(12);let X=await this.#Z(J.credId);return O({...J,tag:X})}static async unsealWithPasskey($,Z){if($.length===0)return G(22);let J=[];for(let W of $)if(W.credId.byteLength>0)J.push(W.credId);let[Q,X]=await mJ({rpId:Z.rpId,rpName:Z.rpName,hints:Z.hints,credId:J.length>0?J:void 0,salt:Z.salt});if(X!==0)return G(X);if(Q===void 0)return G(7);let Y=$.find((W)=>f0(W.credId,Q.credId)),V=Y===void 0?$:[Y,...$.filter((W)=>W!==Y)];try{for(let W of V){let[q]=await J0.#G(W.sealedMaster,Q.prf);if(q!==void 0)return O({enclave:q,credId:Q.credId.slice()})}return G(20)}finally{Q.prf.fill(0)}}async persistToLargeBlob($=[],Z){let J=Z?.credId;if(J===void 0){let[Y,V]=await TJ(Z);if(V!==0)return G(V);if(Y===void 0)return G(30);J=Y}let[Q,X]=this.#X($);if(X!==0)return G(X);if(Q===void 0)return G(12);try{let Y=await EJ(J,Q,Z);if(Y!==0)return G(Y);return O(J)}finally{Q.fill(0)}}static async fromLargeBlob($){let[Z,J]=await DJ($?.credId,$);if(J!==0)return G(J);if(Z===void 0)return G(7);try{let[Q,X]=LJ(Z.blob);if(X!==0)return G(X);if(Q===void 0)return G(12);return O({...Q,credId:Z.credId})}finally{Z.blob.fill(0)}}static async clearLargeBlob($,Z){return EJ($,new Uint8Array(Y0),Z)}static fromPairPlain($){return LJ($)}static pairRequest(){return F$.create()}async pairAccept($,Z){let J;try{J=await $0.genX25519()}catch{return G(29)}try{let[Q,X]=await JZ(J.priv,$,$,J.pub);if(X!==0)return G(X);if(Q===void 0)return G(12);try{let[Y,V]=this.#X(Z);if(V!==0)return G(V);if(Y===void 0)return G(12);try{let W=await $0.encryptXSalsa20Poly1305Combined(Y,Q);return PJ(O0(J.pub,W))}catch{return G(12)}finally{Y.fill(0)}}finally{Q.fill(0)}}finally{J.priv.fill(0)}}spawnSyncWorker($){let Z=AJ(),J=this.#$.slice();return jJ(Z,{id:$.id,op:"setSeed",seed:J,persist:$.persist},[J.buffer]),Z}deriveCipher($,Z){let J=$.slice(),Q=(V)=>this.#W(J,V),X=(V)=>this.#q(J,V);return{encrypt:Object.freeze({encrypt:Q}),decrypt:Object.freeze({decrypt:X}),both:Object.freeze({encrypt:Q,decrypt:X})}[Z]}async deriveIdentity($,Z=0){let J=$,Q=Z,X=await this.#Q(J,Q),Y=X.publicKey;return X.privateKey.fill(0),Object.freeze({publicKey:Y,sign:(V)=>this.#z(J,Q,V),kdmFor:(V)=>this.#N(J,Q,V)})}async#Z($){let Z=new Uint8Array(this.#$.byteLength+MZ.byteLength+$.byteLength);Z.set(this.#$,0),Z.set(MZ,this.#$.byteLength),Z.set($,this.#$.byteLength+MZ.byteLength);try{return await $0.blake3(Z)}finally{Z.fill(0)}}async#Y($,Z){if(Z.byteLength!==fX)return!1;let J=await this.#Z($);try{if(J.byteLength!==Z.byteLength)return!1;let Q=0;for(let X=0;X<J.byteLength;X++){let Y=J[X],V=Z[X];if(Y===void 0||V===void 0)return!1;Q|=Y^V}return Q===0}finally{J.fill(0)}}async#V($){let[Z,J]=await SJ($0,$);if(J!==0)return G(J);if(Z===void 0)return G(12);try{let Q=await $0.encryptXSalsa20Poly1305Combined(this.#$,Z);return O$(Q)}catch{return G(12)}finally{Z.fill(0)}}static async#G($,Z){let[,J]=O$($);if(J!==0)return G(J);let[Q,X]=await SJ($0,Z);if(X!==0)return G(X);if(Q===void 0)return G(12);let Y;try{try{Y=await $0.decryptXSalsa20Poly1305Combined($,Q)}catch{return G(20)}return J0.fromBytes(Y)}finally{Q.fill(0),Y?.fill(0)}}#X($){let Z=new m,J=Z.writeStruct(ZZ,{hosts:lX($)});if(J!==0)return G(J);let Q=Z.result(),X=new Uint8Array(Y0+Q.byteLength);return X.set(this.#$,0),X.set(Q,Y0),O(X)}async#W($,Z){let J=await this.#J($);try{return await $0.encryptXSalsa20Poly1305Combined(Z,J)}finally{J.fill(0)}}async#q($,Z){let J=await this.#J($);try{return await $0.decryptXSalsa20Poly1305Combined(Z,J)}finally{J.fill(0)}}async#J($){let Z=new Uint8Array(this.#$.byteLength+$.byteLength);Z.set(this.#$,0),Z.set($,this.#$.byteLength);try{return await $0.blake3(Z)}finally{Z.fill(0)}}async#M($,Z){let J=new TextEncoder().encode($),Q=new Uint8Array(8);return new DataView(Q.buffer).setBigUint64(0,BigInt(Z),!1),await this.#J(O0(J,Q))}async#Q($,Z){let J=await this.#M($,Z);try{return await $0.deriveEd25519KeyPair(J)}finally{J.fill(0)}}async#z($,Z,J){let Q=await this.#Q($,Z);try{return await $0.signEd25519(J,Q.privateKey)}finally{Q.privateKey.fill(0)}}async#N($,Z,J){let Q=await this.#Q($,Z),X=O0(Q.privateKey,J);Q.privateKey.fill(0);try{return(await $0.blake3(X)).slice(0,y0)}finally{X.fill(0)}}}async function SJ($,Z,J=gX){if(Z.byteLength<yX)return G(10);let Q=await $.blake3(O0(Z,J));return O(Q.slice(0,vX))}var pX=new Set(["constructor","prototype","length","name"]);function _J($){for(let Z of Object.getOwnPropertyNames($)){if(pX.has(Z))continue;let J=Object.getOwnPropertyDescriptor($,Z);if(J===void 0||typeof J.value!=="function")continue;Object.defineProperty($,Z,{value:J.value,writable:!1,configurable:!1})}}_J(J0);_J(J0.prototype);class NZ{listeners=new Map;addEventListener($,Z){let J=this.listeners.get($);if(!J)J=new Set,this.listeners.set($,J);return J.add(Z),()=>{this.removeEventListener($,Z)}}removeEventListener($,Z){let J=this.listeners.get($);if(J){if(J.delete(Z),J.size===0)this.listeners.delete($)}}emit($,Z){let J=this.listeners.get($);if(J){let Q=Array.from(J);for(let X of Q)X(Z)}}emitAll($){let Z=Array.from(this.listeners.keys());for(let J of Z)this.emit(J,$)}}async function kJ($,Z,J,Q=0){let X=Z.now(),Y=new m,V=Y.writeVarString($);if(V!==0)return G(V);let q={id:Y.result(),ts:new Date(0)},[M,z]=VJ(q);if(z!==0)return G(z);let N=X.getTime()-q.ts.getTime();return O({eid:M,off:N,ctr:Q,len:J.length,bod:J})}class uX{singletonType;latest;latestOff=-1;emitter=new NZ;constructor($){this.singletonType=$}async apply($){for(let Z of $){let J=new p(Z.eid),[Q,X]=J.readStruct(a0);if(X!==0)continue;let Y=new m;Y.writeVarString(this.singletonType);let V=Y.result();if(Q.id.length===V.length&&Q.id.every((W,q)=>W===V[q])){if(this.latest===void 0||Z.off>this.latestOff)this.latestOff=Z.off,this.latest=Z.bod,this.emitter.emit(this.singletonType,null)}}return $.map(()=>0)}clear=async()=>{return this.latest=void 0,this.latestOff=-1,this.emitter.emit(this.singletonType,null),0};notify=($)=>{for(let Z of $)if(Z===this.singletonType)this.emitter.emit(this.singletonType,null)};refresh=async($)=>{this.notify([this.singletonType])};on=($,Z)=>{this.emitter.addEventListener($,Z)};off=($,Z)=>{this.emitter.removeEventListener($,Z)}}async function xJ($,Z,J,Q){let X=new p($.headCph),[Y,V]=X.readStruct(i0);if(V!==0)return G(V);let{sig:W,kdm:q,headCph:M}=Y;if(!await Q.checkSigEd25519(W,M,Z))return G(3);let N=J.deriveCipher(q,"decrypt"),K;try{K=await N.decrypt(M)}catch{return G(20)}return O({kdm:q,headEnc:K})}var d0=rQ(gQ(),1),qV={encode:d0.encode,decode:d0.decode,decodeAsync:d0.decodeAsync},MV=qV;import{Database as zV}from"bun:sqlite";var qM=Symbol("EntityID");var MM=Symbol("DerivationSeed"),zM=Symbol("PublicKey"),NM=Symbol("PrivateKey"),OM=Symbol("HostSpecificKeyPair"),KM=Symbol("Hash"),I0={term:0,elapsed:0,stat:{quota:0},dyn:{quota:0}};function NV($="diplomatic.db"){let Z=new zV($);return Z.exec("PRAGMA journal_mode=WAL;"),Z.exec("PRAGMA synchronous=NORMAL;"),Z.exec(`
2
2
  CREATE TABLE IF NOT EXISTS users (
3
3
  pubKey TEXT PRIMARY KEY
4
4
  );
@@ -11,4 +11,4 @@ var pQ=Object.create;var{getPrototypeOf:uQ,defineProperty:BZ,getOwnPropertyNames
11
11
  PRIMARY KEY (userPubKey, seq),
12
12
  UNIQUE (userPubKey, seq)
13
13
  );
14
- `),{async addUser(J){try{let Q=$0(J);return Z.exec("INSERT INTO users (pubKey) VALUES (?) ON CONFLICT DO NOTHING",[Q]),O(void 0)}catch{return G(17)}},async hasUser(J){try{let Q=$0(J),X=Z.prepare("SELECT EXISTS (SELECT 1 FROM users WHERE pubKey = ?) AS ok").get(Q);return O(Boolean(X?.ok))}catch{return G(17)}},async subMeta(J){return O(P0)},async setBags(J,Q){if(Q.length<1)return O([]);try{let X=$0(J);Z.exec("BEGIN IMMEDIATE");try{let Y=Z.prepare("SELECT MAX(seq) AS m FROM bags WHERE userPubKey = ?").get(X),V=Y?Y.m||0:0,W=[],q=Z.prepare("INSERT INTO bags (userPubKey, seq, headCph, bodyCph) VALUES (?, ?, ?, ?)");for(let z of Q){V+=1;let M=new m;M.writeStruct(u0,z),q.run(X,V,M.result(),z.bodyCph),W.push(V)}return Z.exec("COMMIT"),O(W)}catch(Y){try{Z.exec("ROLLBACK")}catch{}throw Y}}catch{return G(17)}},async getBodies(J,Q){if(Q.length<1)return O([]);try{let X=$0(J),Y=[],V=100,W=99;for(let q=0;q<Q.length;q+=99){let z=Q.slice(q,q+99),M=z.map(()=>"?").join(","),N=Z.prepare(`SELECT seq, bodyCph FROM bags WHERE userPubKey = ? AND seq IN (${M})`).all(X,...z);for(let K of N)if(K.bodyCph)Y.push({seq:K.seq,bodyCph:new Uint8Array(K.bodyCph)})}return O(Y)}catch{return G(17)}},async listHeads(J,Q){try{let X=$0(J),Y=Z.prepare("SELECT seq, headCph FROM bags WHERE userPubKey = ? AND seq > ? ORDER BY seq").all(X,Q);return O(Y.map((V)=>({seq:V.seq,headCph:new Uint8Array(V.headCph)})))}catch{return G(17)}}}}var NV=MV(),yQ=NV;class _Z{storage;crypto;notifier;clock;constructor($,Z,J,Q){this.storage=$;this.crypto=Z;this.notifier=J;this.clock=Q}corsHandler=async($)=>{if($.method==="OPTIONS")return JZ(new Response(null));let Z=`${$.method} ${$.url}`;console.time(Z);let J=await this.handler($);return console.timeEnd(Z),JZ(J)};handler=async($)=>{let{clock:Z}=this,J=Z.now(),Q=new URL($.url);if($.method!=="POST"){let z=Z.now();return d0({status:13,timeRcvd:J,timeSent:z,subscription:P0})}if(!$.body){let z=Z.now();return d0({status:7,timeRcvd:J,timeSent:z,subscription:P0})}let Y=new Uint8Array(await $.arrayBuffer()),V=new v(Y),W=Q.pathname,q=PJ[W]?.endpoint;if(!q){let z=Z.now();return d0({status:13,timeRcvd:J,timeSent:z,subscription:P0})}try{let z=new m,M=await q.handleReq(this,V,z),N=P0,K={status:M,timeRcvd:J,timeSent:this.clock.now(),subscription:N},H=new m;if(H.writeStruct(p0,K)!==0)return new Response(null,{status:500});if(M!==0){let R=Z.now();return d0({status:M,timeRcvd:J,timeSent:R,subscription:P0})}return z.prependBytes(H.result()),ZZ(z)}catch(z){let M=Z.now();return console.error(z),console.trace(),d0({status:12,timeRcvd:J,timeSent:M,subscription:P0})}}}async function lQ($,Z){let Q=new URL($.url).searchParams.get(JJ);if(!Q)return G(11);let X=q$(Q),Y=new v(X),[V,W]=Y.readStruct(o);if(W!==0)return G(11);let q=await J0(V,Z.crypto,Z.clock);if(q!==0)return G(q);return O(V)}class hQ{recvs=new Map;async open($,Z,J,Q){let X=await J0($,J,Q);if(X!==0)return{send:()=>X,shut:()=>X,status:X};let Y=$0($.pubKey);if(!this.recvs.has(Y))this.recvs.set(Y,new Set);return this.recvs.get(Y)?.add(Z),{send:(V)=>{return Z(V),0},shut:()=>{return this.recvs.get(Y)?.delete(Z),0},status:0}}async push($,Z){let J=$0($),Q=this.recvs.get(J);if(Q)for(let X of Q)X(Z)}}var bQ=new hQ;async function OV($=Number.parseInt(process.env.DIPLOMATIC_HOST_PORT||"31337")){let Z=new _Z(yQ,h0,bQ,new i0);console.log(`DIPLOMATIC PARCEL SERVICE ACTIVE on http://localhost:${$}`),Bun.serve({port:$,fetch:async(J,Q)=>{if(J.headers.get("upgrade")==="websocket"){let[X,Y]=await lQ(J,Z);if(Y!==0)return new Response("Unauthorized",{status:401});return Q.upgrade(J,{data:{authTS:X}})?void 0:new Response("Upgrade failed",{status:400})}return Z.corsHandler(J)},websocket:{data:{},open:(J)=>{let Q=J.data.authTS;bQ.open(Q,(X)=>J.send(X),Z.crypto,Z.clock).then((X)=>{if(X.status!==0){J.close();return}J.channel=X})},message:(J,Q)=>{},close:(J)=>{J.channel?.shut()}}})}class iQ{enclave;conn;clock;constructor({enclave:$,clock:Z=new i0}){this.enclave=$,this.clock=Z}async connect($,Z){let J=new i0,Q=()=>Promise.resolve(0);this.conn=new N$(this.enclave,h0,$,J,Z,Q);let[,X]=await this.conn.register();return X}async push($){if(!this.conn)return G(28);let Z=[];for(let X of $){let[Y,V]=await this.conn.seal(X);if(V!==0)return G(V);Z.push(Y)}let[J,Q]=await this.conn.push(Z);if(Q!==0)return G(Q);return O(J)}async peek($){if(!this.conn)return G(28);return this.conn.peek($)}async pull($){if(!this.conn)return G(28);return this.conn.pull($)}async open($,Z){if(!this.conn)return G(28);let J=await this.conn.identity(),[Q,X]=await fJ($,J.publicKey,this.enclave,h0);if(X!==0)return G(X);let Y=this.enclave.deriveCipher(Q.kdm,"decrypt");return OJ(Q.headEnc,Z.bodyCph,Y,h0)}async upsertSingletonSync($,Z){let[J,Q]=await gJ($,this.clock,Z);if(Q!==0)return Q;let[,X]=await this.push([J]);return X}async listen($,Z,J){if(!this.conn)return 28;return this.conn.listen($,Z,J)}isConnected(){return this.conn?.isConnected()??!1}}async function KV({enclave:$,host:Z,transport:J}){let Q=new iQ({enclave:$}),X=await Q.connect(Z,J);return[Q,X]}async function HM({enclave:$,host:Z,transport:J}){let Q=J??$Z(Z),[X,Y]=await KV({enclave:$,host:Z,transport:Q});if(Y!==0)console.error(`Failed to initialize CLI: ${A[Y]}`),process.exit(1);return X}function FM($){let Z=process.env[$];if(!Z)console.error(`${$} env var missing`),process.exit(1);let J=q$(Z),[Q,X]=Q0.fromBytes(J);if(J.fill(0),X!==0||Q===void 0)console.error(`${$} must be 64 hex chars (32-byte master seed)`),process.exit(1);return Q}function RM($){let Z=process.env[$];if(!Z)console.error(`${$} env var missing`),process.exit(1);return{handle:new URL(Z),label:"host"}}export{OV as runBunHost,t$ as notifItemCodec,qV as msgpack,RM as loadHostOrPanic,FM as loadEnclaveOrPanic,HM as initCLIOrPanic,KV as initCLI,$Z as hostHTTPTransport,A as Status,v as Decoder,iQ as CLIClient};
14
+ `),{async addUser(J){try{let Q=t(J);return Z.exec("INSERT INTO users (pubKey) VALUES (?) ON CONFLICT DO NOTHING",[Q]),O(void 0)}catch{return G(17)}},async hasUser(J){try{let Q=t(J),X=Z.prepare("SELECT EXISTS (SELECT 1 FROM users WHERE pubKey = ?) AS ok").get(Q);return O(Boolean(X?.ok))}catch{return G(17)}},async subMeta(J){return O(I0)},async setBags(J,Q){if(Q.length<1)return O([]);try{let X=t(J);Z.exec("BEGIN IMMEDIATE");try{let Y=Z.prepare("SELECT MAX(seq) AS m FROM bags WHERE userPubKey = ?").get(X),V=Y?Y.m||0:0,W=[],q=Z.prepare("INSERT INTO bags (userPubKey, seq, headCph, bodyCph) VALUES (?, ?, ?, ?)");for(let M of Q){V+=1;let z=new m;z.writeStruct(i0,M),q.run(X,V,z.result(),M.bodyCph),W.push(V)}return Z.exec("COMMIT"),O(W)}catch(Y){try{Z.exec("ROLLBACK")}catch{}throw Y}}catch{return G(17)}},async getBodies(J,Q){if(Q.length<1)return O([]);try{let X=t(J),Y=[],V=100,W=99;for(let q=0;q<Q.length;q+=99){let M=Q.slice(q,q+99),z=M.map(()=>"?").join(","),N=Z.prepare(`SELECT seq, bodyCph FROM bags WHERE userPubKey = ? AND seq IN (${z})`).all(X,...M);for(let K of N)if(K.bodyCph)Y.push({seq:K.seq,bodyCph:new Uint8Array(K.bodyCph)})}return O(Y)}catch{return G(17)}},async listHeads(J,Q){try{let X=t(J),Y=Z.prepare("SELECT seq, headCph FROM bags WHERE userPubKey = ? AND seq > ? ORDER BY seq").all(X,Q);return O(Y.map((V)=>({seq:V.seq,headCph:new Uint8Array(V.headCph)})))}catch{return G(17)}}}}var OV=NV(),fQ=OV;class jZ{storage;crypto;notifier;clock;constructor($,Z,J,Q){this.storage=$;this.crypto=Z;this.notifier=J;this.clock=Q}corsHandler=async($)=>{if($.method==="OPTIONS")return $Z(new Response(null));let Z=`${$.method} ${$.url}`;console.time(Z);let J=await this.handler($);return console.timeEnd(Z),$Z(J)};handler=async($)=>{let{clock:Z}=this,J=Z.now(),Q=new URL($.url);if($.method!=="POST"){let M=Z.now();return p0({status:13,timeRcvd:J,timeSent:M,subscription:I0})}if(!$.body){let M=Z.now();return p0({status:7,timeRcvd:J,timeSent:M,subscription:I0})}let Y=new Uint8Array(await $.arrayBuffer()),V=new p(Y),W=Q.pathname,q=FJ[W]?.endpoint;if(!q){let M=Z.now();return p0({status:13,timeRcvd:J,timeSent:M,subscription:I0})}try{let M=new m,z=await q.handleReq(this,V,M),N=I0,K={status:z,timeRcvd:J,timeSent:this.clock.now(),subscription:N},F=new m;if(F.writeStruct(h0,K)!==0)return new Response(null,{status:500});if(z!==0){let I=Z.now();return p0({status:z,timeRcvd:J,timeSent:I,subscription:I0})}return M.prependBytes(F.result()),t$(M)}catch(M){let z=Z.now();return console.error(M),console.trace(),p0({status:12,timeRcvd:J,timeSent:z,subscription:I0})}}}async function vQ($,Z){let Q=new URL($.url).searchParams.get(eZ);if(!Q)return G(11);let X=W$(Q),Y=new p(X),[V,W]=Y.readStruct(o);if(W!==0)return G(11);let q=await Z0(V,Z.crypto,Z.clock);if(q!==0)return G(q);return O(V)}class lQ{recvs=new Map;async open($,Z,J,Q){let X=await Z0($,J,Q);if(X!==0)return{send:()=>X,shut:()=>X,status:X};let Y=t($.pubKey);if(!this.recvs.has(Y))this.recvs.set(Y,new Set);return this.recvs.get(Y)?.add(Z),{send:(V)=>{return Z(V),0},shut:()=>{return this.recvs.get(Y)?.delete(Z),0},status:0}}async push($,Z){let J=t($),Q=this.recvs.get(J);if(Q)for(let X of Q)X(Z)}}var yQ=new lQ;async function KV($=Number.parseInt(process.env.DIPLOMATIC_HOST_PORT||"31337")){let Z=new jZ(fQ,l0,yQ,new b0);console.log(`DIPLOMATIC PARCEL SERVICE ACTIVE on http://localhost:${$}`),Bun.serve({port:$,fetch:async(J,Q)=>{if(J.headers.get("upgrade")==="websocket"){let[X,Y]=await vQ(J,Z);if(Y!==0)return new Response("Unauthorized",{status:401});return Q.upgrade(J,{data:{authTS:X}})?void 0:new Response("Upgrade failed",{status:400})}return Z.corsHandler(J)},websocket:{data:{},open:(J)=>{let Q=J.data.authTS;yQ.open(Q,(X)=>J.send(X),Z.crypto,Z.clock).then((X)=>{if(X.status!==0){J.close();return}J.channel=X})},message:(J,Q)=>{},close:(J)=>{J.channel?.shut()}}})}class bQ{enclave;conn;clock;constructor({enclave:$,clock:Z=new b0}){this.enclave=$,this.clock=Z}async connect($,Z){let J=new b0,Q=()=>Promise.resolve(0);this.conn=new z$(this.enclave,l0,$,J,Z,Q);let[,X]=await this.conn.register();return X}async push($){if(!this.conn)return G(28);let Z=[];for(let X of $){let[Y,V]=await this.conn.seal(X);if(V!==0)return G(V);Z.push(Y)}let[J,Q]=await this.conn.push(Z);if(Q!==0)return G(Q);return O(J)}async peek($){if(!this.conn)return G(28);return this.conn.peek($)}async pull($){if(!this.conn)return G(28);return this.conn.pull($)}async open($,Z){if(!this.conn)return G(28);let J=await this.conn.identity(),[Q,X]=await xJ($,J.publicKey,this.enclave,l0);if(X!==0)return G(X);let Y=this.enclave.deriveCipher(Q.kdm,"decrypt");return qJ(Q.headEnc,Z.bodyCph,Y,l0)}async upsertSingletonSync($,Z){let[J,Q]=await kJ($,this.clock,Z);if(Q!==0)return Q;let[,X]=await this.push([J]);return X}async listen($,Z,J){if(!this.conn)return 28;return this.conn.listen($,Z,J)}isConnected(){return this.conn?.isConnected()??!1}}async function FV({enclave:$,host:Z,transport:J}){let Q=new bQ({enclave:$}),X=await Q.connect(Z,J);return[Q,X]}async function Vz({enclave:$,host:Z,transport:J}){let Q=J??e$(Z),[X,Y]=await FV({enclave:$,host:Z,transport:Q});if(Y!==0)console.error(`Failed to initialize CLI: ${j[Y]}`),process.exit(1);return X}function Gz($){let Z=process.env[$];if(!Z)console.error(`${$} env var missing`),process.exit(1);let J=W$(Z),[Q,X]=J0.fromBytes(J);if(J.fill(0),X!==0||Q===void 0)console.error(`${$} must be 64 hex chars (32-byte master seed)`),process.exit(1);return Q}function Wz($){let Z=process.env[$];if(!Z)console.error(`${$} env var missing`),process.exit(1);return{handle:new URL(Z),label:"host"}}export{KV as runBunHost,a$ as notifItemCodec,MV as msgpack,Wz as loadHostOrPanic,Gz as loadEnclaveOrPanic,Vz as initCLIOrPanic,FV as initCLI,e$ as hostHTTPTransport,j as Status,p as Decoder,bQ as CLIClient};
@@ -1,25 +1,12 @@
1
1
  import { ICodecStruct } from "../codec.ts";
2
- import { type MasterSeed } from "../seed.ts";
3
- import { type ValStat } from "../valstat.ts";
4
2
  import { type BundleHost } from "./bundleHost.ts";
5
3
  export { type BundleHost, bundleHostCodec } from "./bundleHost.ts";
6
- export declare const IDENTITY_BUNDLE_VERSION = 1;
7
- export type IdentityBundle = {
8
- v: number;
9
- masterSeed: MasterSeed;
4
+ export type IdentityHosts = {
10
5
  hosts: BundleHost[];
11
6
  };
12
7
  /**
13
- * IdentityBundle wire layout:
14
- * v: varint
15
- * masterSeed: 32 fixed bytes
8
+ * Host list on the IdentityBundle wire:
16
9
  * hostsLen: varint
17
10
  * hosts: hostsLen × BundleHost
18
11
  */
19
- export declare const identityBundleCodec: ICodecStruct<IdentityBundle>;
20
- /**
21
- * Build a wire-format identity bundle from a branded {@link MasterSeed} + hosts.
22
- * Codec/tests only. Runtime seed I/O must go through Enclave.persistToLargeBlob
23
- * — never encode then hand seed-bearing bytes to outer layers.
24
- */
25
- export declare function createIdentityBundle(masterSeed: MasterSeed, hosts: BundleHost[]): ValStat<IdentityBundle>;
12
+ export declare const identityHostsCodec: ICodecStruct<IdentityHosts>;
@@ -125,6 +125,14 @@ export declare class Enclave {
125
125
  }>>;
126
126
  /** UV + overwrite largeBlob with zeros (destroys stored seed material). */
127
127
  static clearLargeBlob(credId: Uint8Array, opts?: LargeBlobRp): Promise<Status>;
128
+ /**
129
+ * Absorb seed‖hosts plaintext (pair AEAD inner).
130
+ * Encoder/Decoder never see the seed.
131
+ */
132
+ static fromPairPlain(plain: Uint8Array): ValStat<{
133
+ enclave: Enclave;
134
+ hosts: BundleHost[];
135
+ }>;
128
136
  static pairRequest(): Promise<ValStat<PairRequest>>;
129
137
  pairAccept(dhkeReq: DHKEReq, hosts: BundleHost[]): Promise<ValStat<DHKEResp>>;
130
138
  /**
@@ -1,4 +1,3 @@
1
- import { Status } from "../consts.ts";
2
1
  import { type ValStat } from "../valstat.ts";
3
2
  import { type WebAuthnRp } from "./common.ts";
4
3
  export type LargeBlobRp = WebAuthnRp;
@@ -10,8 +9,6 @@ export type LargeBlobCreateOpts = LargeBlobRp & {
10
9
  export declare function largeBlobCapable(): Promise<boolean>;
11
10
  /** Create discoverable largeBlob-capable credential; returns credential id. */
12
11
  export declare function largeBlobCreateCred(opts?: LargeBlobCreateOpts): Promise<ValStat<Uint8Array>>;
13
- /** UV write of opaque bytes to largeBlob. */
14
- export declare function largeBlobWrite(credId: Uint8Array, data: Uint8Array, opts?: LargeBlobRp): Promise<Status>;
15
12
  /** UV read from largeBlob; `credId` undefined = discoverable then targeted read. */
16
13
  export declare function largeBlobRead(credId: Uint8Array | undefined, opts?: LargeBlobRp): Promise<ValStat<{
17
14
  blob: Uint8Array;
@@ -1,4 +1,3 @@
1
- import { type ValStat } from "../valstat.ts";
2
1
  import { type AuthenticatorAttachmentName, type WebAuthnRp } from "./common.ts";
3
2
  export type PrfRp = WebAuthnRp;
4
3
  export type PrfCreateOpts = PrfRp & {
@@ -17,8 +16,6 @@ export type PrfCreateOpts = PrfRp & {
17
16
  export declare const DEFAULT_PRF_SALT: Uint8Array<ArrayBufferLike>;
18
17
  /** Default WebAuthn user.name / displayName when none is supplied. */
19
18
  export declare const DEFAULT_PRF_USER_NAME = "diplomatic-prf";
20
- /** Bytes of PRF output we consume (first N of `results.first`). */
21
- export declare const PRF_OUTPUT_LEN = 32;
22
19
  /** Public ceremony facts (no PRF bytes). */
23
20
  export type PrfCeremony = {
24
21
  credId: Uint8Array;
@@ -27,15 +24,6 @@ export type PrfCeremony = {
27
24
  transports?: string[];
28
25
  aaguid?: Uint8Array;
29
26
  };
30
- export type PrfCreateResult = PrfCeremony & {
31
- prfEnabled: boolean;
32
- /** Present when the UA evaluated PRF during create (no second get). */
33
- prf?: Uint8Array;
34
- };
35
- /** Internal: PRF output + cred id. For Enclave only — do not re-export to apps. */
36
- export type PrfEvalResult = PrfCeremony & {
37
- prf: Uint8Array;
38
- };
39
27
  export type PrfEvalOpts = PrfRp & {
40
28
  /** One id, or every bound id so a spare key can assert in one get(). */
41
29
  credId?: Uint8Array | readonly Uint8Array[];
@@ -43,10 +31,3 @@ export type PrfEvalOpts = PrfRp & {
43
31
  };
44
32
  /** Best-effort: client advertises PRF extension. */
45
33
  export declare function prfCapable(): Promise<boolean>;
46
- /** Create a discoverable credential that enables PRF. */
47
- export declare function createPrfCred(opts?: PrfCreateOpts): Promise<ValStat<PrfCreateResult>>;
48
- /**
49
- * Evaluate PRF (UV). Returns PRF bytes — only Enclave should call this and must
50
- * zero/drop PRF after seal/unseal. Apps must not hold PRF alongside sealed meta.
51
- */
52
- export declare function evalPrf(opts?: PrfEvalOpts): Promise<ValStat<PrfEvalResult>>;
@@ -25,7 +25,8 @@ import type { ApldState, Applier, HostStatsUpdate, IClient, IDiplomaticClientSta
25
25
  import { APLD_APPLIED, APLD_ERROR, APLD_PENDING, apldFromStored, isApldState, isPendingApply, isTerminalApplyFailure, setApld } from "./types";
26
26
  import type { SyncProgressEvent } from "./progress";
27
27
  import { defaultPeekProgressEvery, idleProgress, shouldEmitItemProgress } from "./progress";
28
- import { defaultWebAuthnRpId, PasskeySeedStore } from "./passkey/seed";
28
+ import { PasskeySeedStore } from "./passkey/seed";
29
+ import { defaultWebAuthnRpId } from "./shared/webauthn/common";
29
30
  import { DEFAULT_PRF_SALT, prfCapable, type PrfRp } from "./shared/webauthn/prf";
30
31
  import { KEYRING_MAX, keyringCredIds, keyringKind, keyringLabel, PrfSeedStore } from "./passkey/prf-store";
31
32
  import type { Keyring, KeyringEntry, KeyringRow, PersistKeyring, PrfSeedStoreOpts } from "./passkey/prf-store";
@@ -33,14 +34,13 @@ import type { PasskeySeedStoreOpts } from "./passkey/seed";
33
34
  import { type BundleHost } from "./shared/codecs/bundleHost";
34
35
  import { asDHKEReq, asDHKEResp, PairRequest } from "./shared/crypto/pairing";
35
36
  import type { DHKEReq, DHKEResp } from "./shared/crypto/pairing";
36
- import type { PairPackagePlain } from "./shared/codecs/pairPackage";
37
37
  import { checksumEntRevs, checksumSet, cmpBytes, encodeEntRev } from "./shared/checksum";
38
38
  import { openDiplomaticClient, type OpenDiplomaticClientMainOptions, type OpenDiplomaticClientOptions, type OpenDiplomaticClientWorkerOptions, type OpenedDiplomaticClient } from "./openClient";
39
39
  import { WorkerClient } from "./worker/client";
40
40
  import type { WorkerClientOptions } from "./worker/client";
41
41
  import type { WipeOpts } from "./types";
42
42
  /** Platform advertises largeBlob (not a guarantee the binding key has it). */
43
- export declare function largeBlobCapable(): Promise<boolean>;
43
+ export { largeBlobCapable } from "./shared/webauthn/largeBlob";
44
44
  export { webAuthnLastError } from "./shared/webauthn/common";
45
45
  export { APLD_APPLIED, APLD_ERROR, APLD_PENDING, apldFromStored, asDHKEReq, asDHKEResp, asSealedMasterKey, b64tob, b64urltob, btob64, btob64url, btoh, CachedEntDB, checksumEntRevs, checksumSet, Clock, cmpBytes, crypto, Decoder, DEFAULT_PRF_SALT, defaultPeekProgressEvery, defaultWebAuthnRpId, eidCodec, Enclave, encodeEntRev, Encoder, EntDBMemory, EntIDB, EntitiesQuery, EntityID, entStateManager, genSingletonEID, GroupID, hostHTTPTransport, htob, HTTPTransport, IDBSeedStore, IDBStore, idleProgress, IEntDB, IEntity, isApldState, isLiveEnt, isPendingApply, isTerminalApplyFailure, isTombstone, IStore, KEYRING_MAX, keyringCredIds, keyringKind, keyringLabel, MASTER_SEED_LEN, MemoryStore, normalizeTags, nullEntDB, nullStateManager, openDiplomaticClient, openEntDB, openIDBStore, PairRequest, PasskeySeedStore, prfCapable, PrfSeedStore, revFromEntity, revFromHead, SEALED_MASTER_KEY_LEN, setApld, shouldEmitItemProgress, SingletonStateManager, StateManager, Status, SyncClient, TypedEventEmitter, useClient, useClientState, useClientXferState, useStateWatcher, useStateWatcherSuspense, useSyncOnResume, WorkerClient, };
46
- export type { ApldState, Applier, BundleHost, CachedEntDBOptions, DHKEReq, DHKEResp, EntDBMemoryOptions, HostHandle, HostStatsUpdate, IClient, ICrypto, IDeleteParams, IDiplomaticClientState, IEntRev, IEntRow, IHostConnectionInfo, IHostRow, IMessage, IMutateOp, IOp, IStateManager, IStoredMessage, IStoredMessageData, IStoredMessageWrite, ITombstone, ITransport, IUpdateParams, Keyring, KeyringEntry, KeyringRow, ListMsgsOpts, OpenDiplomaticClientMainOptions, OpenDiplomaticClientOptions, OpenDiplomaticClientWorkerOptions, OpenedDiplomaticClient, OpenEntDBOptions, PairPackagePlain, PasskeySeedStoreOpts, PersistKeyring, PrfRp, PrfSeedStoreOpts, ReconcileOpts, ReconcileReport, SealedMasterKey, SetSeedOpts, SyncProgressEvent, WipeOpts, WorkerClientOptions, };
46
+ export type { ApldState, Applier, BundleHost, CachedEntDBOptions, DHKEReq, DHKEResp, EntDBMemoryOptions, HostHandle, HostStatsUpdate, IClient, ICrypto, IDeleteParams, IDiplomaticClientState, IEntRev, IEntRow, IHostConnectionInfo, IHostRow, IMessage, IMutateOp, IOp, IStateManager, IStoredMessage, IStoredMessageData, IStoredMessageWrite, ITombstone, ITransport, IUpdateParams, Keyring, KeyringEntry, KeyringRow, ListMsgsOpts, OpenDiplomaticClientMainOptions, OpenDiplomaticClientOptions, OpenDiplomaticClientWorkerOptions, OpenedDiplomaticClient, OpenEntDBOptions, PasskeySeedStoreOpts, PersistKeyring, PrfRp, PrfSeedStoreOpts, ReconcileOpts, ReconcileReport, SealedMasterKey, SetSeedOpts, SyncProgressEvent, WipeOpts, WorkerClientOptions, };