genosdb 0.8.5 → 0.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -3
- package/dist/audit.min.js +15 -7
- package/dist/audit.min.js.gz +0 -0
- package/dist/gdb.min.js +1 -1
- package/dist/gdb.min.js.gz +0 -0
- package/dist/index.js +1 -1
- package/dist/index.js.gz +0 -0
- package/package.json +1 -1
package/dist/gdb.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function a6(W){const Q=W.length;let J=0,V=0;while(V<Q){let G=W.charCodeAt(V++);if((G&4294967168)===0){J++;continue}else if((G&4294965248)===0)J+=2;else{if(G>=55296&&G<=56319){if(V<Q){const X=W.charCodeAt(V);if((X&64512)===56320)++V,G=((G&1023)<<10)+(X&1023)+65536}}if((G&4294901760)===0)J+=3;else J+=4}}return J}function pW(W,Q,J){const V=W.length;let G=J,X=0;while(X<V){let Y=W.charCodeAt(X++);if((Y&4294967168)===0){Q[G++]=Y;continue}else if((Y&4294965248)===0)Q[G++]=Y>>6&31|192;else{if(Y>=55296&&Y<=56319){if(X<V){const q=W.charCodeAt(X);if((q&64512)===56320)++X,Y=((Y&1023)<<10)+(q&1023)+65536}}if((Y&4294901760)===0)Q[G++]=Y>>12&15|224,Q[G++]=Y>>6&63|128;else Q[G++]=Y>>18&7|240,Q[G++]=Y>>12&63|128,Q[G++]=Y>>6&63|128}Q[G++]=Y&63|128}}function uW(W,Q,J){bW.encodeInto(W,Q.subarray(J))}function s6(W,Q,J){if(W.length>hW)uW(W,Q,J);else pW(W,Q,J)}function f8(W,Q,J){let V=Q;const G=V+J,X=[];let Y="";while(V<G){const q=W[V++];if((q&128)===0)X.push(q);else if((q&224)===192){const F=W[V++]&63;X.push((q&31)<<6|F)}else if((q&240)===224){const F=W[V++]&63,U=W[V++]&63;X.push((q&31)<<12|F<<6|U)}else if((q&248)===240){const F=W[V++]&63,U=W[V++]&63,P=W[V++]&63;let C=(q&7)<<18|F<<12|U<<6|P;if(C>65535)C-=65536,X.push(C>>>10&1023|55296),C=56320|C&1023;X.push(C)}else X.push(q);if(X.length>=mW)Y+=String.fromCharCode(...X),X.length=0}if(X.length>0)Y+=String.fromCharCode(...X);return Y}function dW(W,Q,J){const V=W.subarray(Q,Q+J);return _W.decode(V)}function e6(W,Q,J){if(J>cW)return dW(W,Q,J);else return f8(W,Q,J)}var bW=new TextEncoder,hW=50,mW=4096,_W=new TextDecoder,cW=200;class V1{constructor(W,Q){this.type=W,this.data=Q}}class Y0 extends Error{constructor(W){super(W);const Q=Object.create(Y0.prototype);Object.setPrototypeOf(this,Q),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:Y0.name})}}function t6(W,Q,J){const V=J/4294967296,G=J;W.setUint32(Q,V),W.setUint32(Q+4,G)}function W8(W,Q,J){const V=Math.floor(J/4294967296),G=J;W.setUint32(Q,V),W.setUint32(Q+4,G)}function J8(W,Q){const J=W.getInt32(Q),V=W.getUint32(Q+4);return J*4294967296+V}function W5(W,Q){const J=W.getUint32(Q),V=W.getUint32(Q+4);return J*4294967296+V}var G1=4294967295;function nW({sec:W,nsec:Q}){if(W>=0&&Q>=0&&W<=rW)if(Q===0&&W<=iW){const J=new Uint8Array(4);return new DataView(J.buffer).setUint32(0,W),J}else{const J=W/4294967296,V=W&4294967295,G=new Uint8Array(8),X=new DataView(G.buffer);return X.setUint32(0,Q<<2|J&3),X.setUint32(4,V),G}else{const J=new Uint8Array(12),V=new DataView(J.buffer);return V.setUint32(0,Q),W8(V,4,W),J}}function oW(W){const Q=W.getTime(),J=Math.floor(Q/1000),V=(Q-J*1000)*1e6,G=Math.floor(V/1e9);return{sec:J+G,nsec:V-G*1e9}}function aW(W){if(W instanceof Date){const Q=oW(W);return nW(Q)}else return null}function sW(W){const Q=new DataView(W.buffer,W.byteOffset,W.byteLength);switch(W.byteLength){case 4:return{sec:Q.getUint32(0),nsec:0};case 8:{const J=Q.getUint32(0),V=Q.getUint32(4),G=(J&3)*4294967296+V,X=J>>>2;return{sec:G,nsec:X}}case 12:{const J=J8(Q,4),V=Q.getUint32(0);return{sec:J,nsec:V}}default:throw new Y0(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${W.length}`)}}function eW(W){const Q=sW(W);return new Date(Q.sec*1000+Q.nsec/1e6)}var lW=-1,iW=4294967295,rW=17179869183,J5={type:lW,encode:aW,decode:eW};class u0{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(J5)}register({type:W,encode:Q,decode:J}){if(W>=0)this.encoders[W]=Q,this.decoders[W]=J;else{const V=-1-W;this.builtInEncoders[V]=Q,this.builtInDecoders[V]=J}}tryToEncode(W,Q){for(let J=0;J<this.builtInEncoders.length;J++){const V=this.builtInEncoders[J];if(V!=null){const G=V(W,Q);if(G!=null){const X=-1-J;return new V1(X,G)}}}for(let J=0;J<this.encoders.length;J++){const V=this.encoders[J];if(V!=null){const G=V(W,Q);if(G!=null)return new V1(J,G)}}if(W instanceof V1)return W;return null}decode(W,Q,J){const V=Q<0?this.builtInDecoders[-1-Q]:this.decoders[Q];if(V)return V(W,Q,J);else return new V1(Q,W)}}u0.defaultCodec=new u0;var tW=function(W){return W instanceof ArrayBuffer||typeof SharedArrayBuffer!=="undefined"&&W instanceof SharedArrayBuffer};function O1(W){if(W instanceof Uint8Array)return W;else if(ArrayBuffer.isView(W))return new Uint8Array(W.buffer,W.byteOffset,W.byteLength);else if(tW(W))return new Uint8Array(W);else return Uint8Array.from(W)}var WJ=100,JJ=2048;class Q8{constructor(W){this.entered=!1,this.extensionCodec=W?.extensionCodec??u0.defaultCodec,this.context=W?.context,this.useBigInt64=W?.useBigInt64??!1,this.maxDepth=W?.maxDepth??WJ,this.initialBufferSize=W?.initialBufferSize??JJ,this.sortKeys=W?.sortKeys??!1,this.forceFloat32=W?.forceFloat32??!1,this.ignoreUndefined=W?.ignoreUndefined??!1,this.forceIntegerToFloat=W?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new Q8({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(W){if(this.entered)return this.clone().encodeSharedRef(W);try{return this.entered=!0,this.reinitializeState(),this.doEncode(W,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(W){if(this.entered)return this.clone().encode(W);try{return this.entered=!0,this.reinitializeState(),this.doEncode(W,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(W,Q){if(Q>this.maxDepth)throw new Error(`Too deep objects in depth ${Q}`);if(W==null)this.encodeNil();else if(typeof W==="boolean")this.encodeBoolean(W);else if(typeof W==="number")if(!this.forceIntegerToFloat)this.encodeNumber(W);else this.encodeNumberAsFloat(W);else if(typeof W==="string")this.encodeString(W);else if(this.useBigInt64&&typeof W==="bigint")this.encodeBigInt64(W);else this.encodeObject(W,Q)}ensureBufferSizeToWrite(W){const Q=this.pos+W;if(this.view.byteLength<Q)this.resizeBuffer(Q*2)}resizeBuffer(W){const Q=new ArrayBuffer(W),J=new Uint8Array(Q),V=new DataView(Q);J.set(this.bytes),this.view=V,this.bytes=J}encodeNil(){this.writeU8(192)}encodeBoolean(W){if(W===!1)this.writeU8(194);else this.writeU8(195)}encodeNumber(W){if(!this.forceIntegerToFloat&&Number.isSafeInteger(W))if(W>=0)if(W<128)this.writeU8(W);else if(W<256)this.writeU8(204),this.writeU8(W);else if(W<65536)this.writeU8(205),this.writeU16(W);else if(W<4294967296)this.writeU8(206),this.writeU32(W);else if(!this.useBigInt64)this.writeU8(207),this.writeU64(W);else this.encodeNumberAsFloat(W);else if(W>=-32)this.writeU8(224|W+32);else if(W>=-128)this.writeU8(208),this.writeI8(W);else if(W>=-32768)this.writeU8(209),this.writeI16(W);else if(W>=-2147483648)this.writeU8(210),this.writeI32(W);else if(!this.useBigInt64)this.writeU8(211),this.writeI64(W);else this.encodeNumberAsFloat(W);else this.encodeNumberAsFloat(W)}encodeNumberAsFloat(W){if(this.forceFloat32)this.writeU8(202),this.writeF32(W);else this.writeU8(203),this.writeF64(W)}encodeBigInt64(W){if(W>=BigInt(0))this.writeU8(207),this.writeBigUint64(W);else this.writeU8(211),this.writeBigInt64(W)}writeStringHeader(W){if(W<32)this.writeU8(160+W);else if(W<256)this.writeU8(217),this.writeU8(W);else if(W<65536)this.writeU8(218),this.writeU16(W);else if(W<4294967296)this.writeU8(219),this.writeU32(W);else throw new Error(`Too long string: ${W} bytes in UTF-8`)}encodeString(W){const J=a6(W);this.ensureBufferSizeToWrite(5+J),this.writeStringHeader(J),s6(W,this.bytes,this.pos),this.pos+=J}encodeObject(W,Q){const J=this.extensionCodec.tryToEncode(W,this.context);if(J!=null)this.encodeExtension(J);else if(Array.isArray(W))this.encodeArray(W,Q);else if(ArrayBuffer.isView(W))this.encodeBinary(W);else if(typeof W==="object")this.encodeMap(W,Q);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(W)}`)}encodeBinary(W){const Q=W.byteLength;if(Q<256)this.writeU8(196),this.writeU8(Q);else if(Q<65536)this.writeU8(197),this.writeU16(Q);else if(Q<4294967296)this.writeU8(198),this.writeU32(Q);else throw new Error(`Too large binary: ${Q}`);const J=O1(W);this.writeU8a(J)}encodeArray(W,Q){const J=W.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 new Error(`Too large array: ${J}`);for(let V of W)this.doEncode(V,Q+1)}countWithoutUndefined(W,Q){let J=0;for(let V of Q)if(W[V]!==void 0)J++;return J}encodeMap(W,Q){const J=Object.keys(W);if(this.sortKeys)J.sort();const V=this.ignoreUndefined?this.countWithoutUndefined(W,J):J.length;if(V<16)this.writeU8(128+V);else if(V<65536)this.writeU8(222),this.writeU16(V);else if(V<4294967296)this.writeU8(223),this.writeU32(V);else throw new Error(`Too large map object: ${V}`);for(let G of J){const X=W[G];if(!(this.ignoreUndefined&&X===void 0))this.encodeString(G),this.doEncode(X,Q+1)}}encodeExtension(W){if(typeof W.data==="function"){const J=W.data(this.pos+6),V=J.length;if(V>=4294967296)throw new Error(`Too large extension object: ${V}`);this.writeU8(201),this.writeU32(V),this.writeI8(W.type),this.writeU8a(J);return}const Q=W.data.length;if(Q===1)this.writeU8(212);else if(Q===2)this.writeU8(213);else if(Q===4)this.writeU8(214);else if(Q===8)this.writeU8(215);else if(Q===16)this.writeU8(216);else if(Q<256)this.writeU8(199),this.writeU8(Q);else if(Q<65536)this.writeU8(200),this.writeU16(Q);else if(Q<4294967296)this.writeU8(201),this.writeU32(Q);else throw new Error(`Too large extension object: ${Q}`);this.writeI8(W.type),this.writeU8a(W.data)}writeU8(W){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,W),this.pos++}writeU8a(W){const Q=W.length;this.ensureBufferSizeToWrite(Q),this.bytes.set(W,this.pos),this.pos+=Q}writeI8(W){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,W),this.pos++}writeU16(W){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,W),this.pos+=2}writeI16(W){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,W),this.pos+=2}writeU32(W){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,W),this.pos+=4}writeI32(W){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,W),this.pos+=4}writeF32(W){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,W),this.pos+=4}writeF64(W){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,W),this.pos+=8}writeU64(W){this.ensureBufferSizeToWrite(8),t6(this.view,this.pos,W),this.pos+=8}writeI64(W){this.ensureBufferSizeToWrite(8),W8(this.view,this.pos,W),this.pos+=8}writeBigUint64(W){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,W),this.pos+=8}writeBigInt64(W){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,W),this.pos+=8}}function X1(W,Q){return new Q8(Q).encodeSharedRef(W)}function V8(W){return`${W<0?"-":""}0x${Math.abs(W).toString(16).padStart(2,"0")}`}var QJ=16,VJ=16;class p8{constructor(W=QJ,Q=VJ){this.hit=0,this.miss=0,this.maxKeyLength=W,this.maxLengthPerKey=Q,this.caches=[];for(let J=0;J<this.maxKeyLength;J++)this.caches.push([])}canBeCached(W){return W>0&&W<=this.maxKeyLength}find(W,Q,J){const V=this.caches[J-1];W:for(let G of V){const X=G.bytes;for(let Y=0;Y<J;Y++)if(X[Y]!==W[Q+Y])continue W;return G.str}return null}store(W,Q){const J=this.caches[W.length-1],V={bytes:W,str:Q};if(J.length>=this.maxLengthPerKey)J[Math.random()*J.length|0]=V;else J.push(V)}decode(W,Q,J){const V=this.find(W,Q,J);if(V!=null)return this.hit++,V;this.miss++;const G=f8(W,Q,J),X=Uint8Array.prototype.slice.call(W,Q,Q+J);return this.store(X,G),G}}var b8="array",w1="map_key",V5="map_value",GJ=(W)=>{if(typeof W==="string"||typeof W==="number")return W;throw new Y0("The type of key must be string or number but "+typeof W)};class G5{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(W){const Q=this.getUninitializedStateFromPool();Q.type=b8,Q.position=0,Q.size=W,Q.array=new Array(W)}pushMapState(W){const Q=this.getUninitializedStateFromPool();Q.type=w1,Q.readCount=0,Q.size=W,Q.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const W={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(W)}return this.stack[this.stackHeadPosition]}release(W){if(this.stack[this.stackHeadPosition]!==W)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(W.type===b8){const J=W;J.size=0,J.array=void 0,J.position=0,J.type=void 0}if(W.type===w1||W.type===V5){const J=W;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 x1=-1,h8=new DataView(new ArrayBuffer(0)),XJ=new Uint8Array(h8.buffer);try{h8.getInt8(0)}catch(W){if(!(W instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var Q5=new RangeError("Insufficient data"),YJ=new p8;class G8{constructor(W){this.totalPos=0,this.pos=0,this.view=h8,this.bytes=XJ,this.headByte=x1,this.stack=new G5,this.entered=!1,this.extensionCodec=W?.extensionCodec??u0.defaultCodec,this.context=W?.context,this.useBigInt64=W?.useBigInt64??!1,this.rawStrings=W?.rawStrings??!1,this.maxStrLength=W?.maxStrLength??G1,this.maxBinLength=W?.maxBinLength??G1,this.maxArrayLength=W?.maxArrayLength??G1,this.maxMapLength=W?.maxMapLength??G1,this.maxExtLength=W?.maxExtLength??G1,this.keyDecoder=W?.keyDecoder!==void 0?W.keyDecoder:YJ,this.mapKeyConverter=W?.mapKeyConverter??GJ}clone(){return new G8({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=x1,this.stack.reset()}setBuffer(W){const Q=O1(W);this.bytes=Q,this.view=new DataView(Q.buffer,Q.byteOffset,Q.byteLength),this.pos=0}appendBuffer(W){if(this.headByte===x1&&!this.hasRemaining(1))this.setBuffer(W);else{const Q=this.bytes.subarray(this.pos),J=O1(W),V=new Uint8Array(Q.length+J.length);V.set(Q),V.set(J,Q.length),this.setBuffer(V)}}hasRemaining(W){return this.view.byteLength-this.pos>=W}createExtraByteError(W){const{view:Q,pos:J}=this;return new RangeError(`Extra ${Q.byteLength-J} of ${Q.byteLength} byte(s) found at buffer[${W}]`)}decode(W){if(this.entered)return this.clone().decode(W);try{this.entered=!0,this.reinitializeState(),this.setBuffer(W);const Q=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return Q}finally{this.entered=!1}}*decodeMulti(W){if(this.entered){yield*this.clone().decodeMulti(W);return}try{this.entered=!0,this.reinitializeState(),this.setBuffer(W);while(this.hasRemaining(1))yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(W){if(this.entered)return this.clone().decodeAsync(W);try{this.entered=!0;let Q=!1,J;for await(let Y of W){if(Q)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(Y);try{J=this.doDecodeSync(),Q=!0}catch(q){if(!(q instanceof RangeError))throw q}this.totalPos+=this.pos}if(Q){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return J}const{headByte:V,pos:G,totalPos:X}=this;throw new RangeError(`Insufficient data in parsing ${V8(V)} at ${X} (${G} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(W){return this.decodeMultiAsync(W,!0)}decodeStream(W){return this.decodeMultiAsync(W,!1)}async*decodeMultiAsync(W,Q){if(this.entered){yield*this.clone().decodeMultiAsync(W,Q);return}try{this.entered=!0;let J=Q,V=-1;for await(let G of W){if(Q&&V===0)throw this.createExtraByteError(this.totalPos);if(this.appendBuffer(G),J)V=this.readArraySize(),J=!1,this.complete();try{while(!0)if(yield this.doDecodeSync(),--V===0)break}catch(X){if(!(X instanceof RangeError))throw X}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){W:while(!0){const W=this.readHeadByte();let Q;if(W>=224)Q=W-256;else if(W<192)if(W<128)Q=W;else if(W<144){const V=W-128;if(V!==0){this.pushMapState(V),this.complete();continue W}else Q={}}else if(W<160){const V=W-144;if(V!==0){this.pushArrayState(V),this.complete();continue W}else Q=[]}else{const V=W-160;Q=this.decodeString(V,0)}else if(W===192)Q=null;else if(W===194)Q=!1;else if(W===195)Q=!0;else if(W===202)Q=this.readF32();else if(W===203)Q=this.readF64();else if(W===204)Q=this.readU8();else if(W===205)Q=this.readU16();else if(W===206)Q=this.readU32();else if(W===207)if(this.useBigInt64)Q=this.readU64AsBigInt();else Q=this.readU64();else if(W===208)Q=this.readI8();else if(W===209)Q=this.readI16();else if(W===210)Q=this.readI32();else if(W===211)if(this.useBigInt64)Q=this.readI64AsBigInt();else Q=this.readI64();else if(W===217){const V=this.lookU8();Q=this.decodeString(V,1)}else if(W===218){const V=this.lookU16();Q=this.decodeString(V,2)}else if(W===219){const V=this.lookU32();Q=this.decodeString(V,4)}else if(W===220){const V=this.readU16();if(V!==0){this.pushArrayState(V),this.complete();continue W}else Q=[]}else if(W===221){const V=this.readU32();if(V!==0){this.pushArrayState(V),this.complete();continue W}else Q=[]}else if(W===222){const V=this.readU16();if(V!==0){this.pushMapState(V),this.complete();continue W}else Q={}}else if(W===223){const V=this.readU32();if(V!==0){this.pushMapState(V),this.complete();continue W}else Q={}}else if(W===196){const V=this.lookU8();Q=this.decodeBinary(V,1)}else if(W===197){const V=this.lookU16();Q=this.decodeBinary(V,2)}else if(W===198){const V=this.lookU32();Q=this.decodeBinary(V,4)}else if(W===212)Q=this.decodeExtension(1,0);else if(W===213)Q=this.decodeExtension(2,0);else if(W===214)Q=this.decodeExtension(4,0);else if(W===215)Q=this.decodeExtension(8,0);else if(W===216)Q=this.decodeExtension(16,0);else if(W===199){const V=this.lookU8();Q=this.decodeExtension(V,1)}else if(W===200){const V=this.lookU16();Q=this.decodeExtension(V,2)}else if(W===201){const V=this.lookU32();Q=this.decodeExtension(V,4)}else throw new Y0(`Unrecognized type byte: ${V8(W)}`);this.complete();const J=this.stack;while(J.length>0){const V=J.top();if(V.type===b8)if(V.array[V.position]=Q,V.position++,V.position===V.size)Q=V.array,J.release(V);else continue W;else if(V.type===w1){if(Q==="__proto__")throw new Y0("The key __proto__ is not allowed");V.key=this.mapKeyConverter(Q),V.type=V5;continue W}else if(V.map[V.key]=Q,V.readCount++,V.readCount===V.size)Q=V.map,J.release(V);else{V.key=null,V.type=w1;continue W}}return Q}}readHeadByte(){if(this.headByte===x1)this.headByte=this.readU8();return this.headByte}complete(){this.headByte=x1}readArraySize(){const W=this.readHeadByte();switch(W){case 220:return this.readU16();case 221:return this.readU32();default:if(W<160)return W-144;else throw new Y0(`Unrecognized array type byte: ${V8(W)}`)}}pushMapState(W){if(W>this.maxMapLength)throw new Y0(`Max length exceeded: map length (${W}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(W)}pushArrayState(W){if(W>this.maxArrayLength)throw new Y0(`Max length exceeded: array length (${W}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(W)}decodeString(W,Q){if(!this.rawStrings||this.stateIsMapKey())return this.decodeUtf8String(W,Q);return this.decodeBinary(W,Q)}decodeUtf8String(W,Q){if(W>this.maxStrLength)throw new Y0(`Max length exceeded: UTF-8 byte length (${W}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+Q+W)throw Q5;const J=this.pos+Q;let V;if(this.stateIsMapKey()&&this.keyDecoder?.canBeCached(W))V=this.keyDecoder.decode(this.bytes,J,W);else V=e6(this.bytes,J,W);return this.pos+=Q+W,V}stateIsMapKey(){if(this.stack.length>0)return this.stack.top().type===w1;return!1}decodeBinary(W,Q){if(W>this.maxBinLength)throw new Y0(`Max length exceeded: bin length (${W}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(W+Q))throw Q5;const J=this.pos+Q,V=this.bytes.subarray(J,J+W);return this.pos+=Q+W,V}decodeExtension(W,Q){if(W>this.maxExtLength)throw new Y0(`Max length exceeded: ext length (${W}) > maxExtLength (${this.maxExtLength})`);const J=this.view.getInt8(this.pos+Q),V=this.decodeBinary(W,Q+1);return this.extensionCodec.decode(V,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(){const W=this.view.getUint8(this.pos);return this.pos++,W}readI8(){const W=this.view.getInt8(this.pos);return this.pos++,W}readU16(){const W=this.view.getUint16(this.pos);return this.pos+=2,W}readI16(){const W=this.view.getInt16(this.pos);return this.pos+=2,W}readU32(){const W=this.view.getUint32(this.pos);return this.pos+=4,W}readI32(){const W=this.view.getInt32(this.pos);return this.pos+=4,W}readU64(){const W=W5(this.view,this.pos);return this.pos+=8,W}readI64(){const W=J8(this.view,this.pos);return this.pos+=8,W}readU64AsBigInt(){const W=this.view.getBigUint64(this.pos);return this.pos+=8,W}readI64AsBigInt(){const W=this.view.getBigInt64(this.pos);return this.pos+=8,W}readF32(){const W=this.view.getFloat32(this.pos);return this.pos+=4,W}readF64(){const W=this.view.getFloat64(this.pos);return this.pos+=8,W}}function N1(W,Q){return new G8(Q).decode(W)}var F1=function(W){let Q=W.length;while(--Q>=0)W[Q]=0},m8=function(W,Q,J,V,G){this.static_tree=W,this.extra_bits=Q,this.extra_base=J,this.elems=V,this.max_length=G,this.has_stree=W&&W.length},_8=function(W,Q){this.dyn_tree=W,this.max_code=0,this.stat_desc=Q},B0=function(W,Q,J,V,G){this.good_length=W,this.max_lazy=Q,this.nice_length=J,this.max_chain=V,this.func=G},U9=function(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=H8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(tJ*2),this.dyn_dtree=new Uint16Array((2*sJ+1)*2),this.bl_tree=new Uint16Array((2*eJ+1)*2),g0(this.dyn_ltree),g0(this.dyn_dtree),g0(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(W9+1),this.heap=new Uint16Array(2*V6+1),g0(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*V6+1),g0(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0},v9=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},l1=function(W){this.options=k8.assign({level:f9,method:b9,chunkSize:16384,windowBits:15,memLevel:8,strategy:p9},W||{});let Q=this.options;if(Q.raw&&Q.windowBits>0)Q.windowBits=-Q.windowBits;else if(Q.gzip&&Q.windowBits>0&&Q.windowBits<16)Q.windowBits+=16;this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new K7,this.strm.avail_out=0;let J=g1.deflateInit2(this.strm,Q.level,Q.method,Q.windowBits,Q.memLevel,Q.strategy);if(J!==z8)throw new Error(d0[J]);if(Q.header)g1.deflateSetHeader(this.strm,Q.header);if(Q.dictionary){let V;if(typeof Q.dictionary==="string")V=m1.string2buf(Q.dictionary);else if(F7.call(Q.dictionary)==="[object ArrayBuffer]")V=new Uint8Array(Q.dictionary);else V=Q.dictionary;if(J=g1.deflateSetDictionary(this.strm,V),J!==z8)throw new Error(d0[J]);this._dict_set=!0}},H6=function(W,Q){const J=new l1(Q);if(J.push(W,!0),J.err)throw J.msg||d0[J.err];return J.result},h9=function(W,Q){return Q=Q||{},Q.raw=!0,H6(W,Q)},u9=function(W,Q){return Q=Q||{},Q.gzip=!0,H6(W,Q)},PQ=function(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0},xQ=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},i1=function(W){this.options=k8.assign({chunkSize:65536,windowBits:15,to:""},W||{});const Q=this.options;if(Q.raw&&Q.windowBits>=0&&Q.windowBits<16){if(Q.windowBits=-Q.windowBits,Q.windowBits===0)Q.windowBits=-15}if(Q.windowBits>=0&&Q.windowBits<16&&!(W&&W.windowBits))Q.windowBits+=32;if(Q.windowBits>15&&Q.windowBits<48){if((Q.windowBits&15)===0)Q.windowBits|=15}this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new K7,this.strm.avail_out=0;let J=w0.inflateInit2(this.strm,Q.windowBits);if(J!==_1)throw new Error(d0[J]);if(this.header=new wQ,w0.inflateGetHeader(this.strm,this.header),Q.dictionary){if(typeof Q.dictionary==="string")Q.dictionary=m1.string2buf(Q.dictionary);else if(I7.call(Q.dictionary)==="[object ArrayBuffer]")Q.dictionary=new Uint8Array(Q.dictionary);if(Q.raw){if(J=w0.inflateSetDictionary(this.strm,Q.dictionary),J!==_1)throw new Error(d0[J])}}},k6=function(W,Q){const J=new i1(Q);if(J.push(W),J.err)throw J.msg||d0[J.err];return J.result},TQ=function(W,Q){return Q=Q||{},Q.raw=!0,k6(W,Q)};/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */var qJ=0,c5=1,UJ=2,PJ=3,KJ=258,P6=29,c1=256,y1=c1+1+P6,U1=30,K6=19,d5=2*y1+1,m0=15,u8=16,FJ=7,F6=256,l5=16,i5=17,r5=18,W6=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),K8=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),zJ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),n5=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ZJ=512,x0=new Array((y1+2)*2);F1(x0);var T1=new Array(U1*2);F1(T1);var f1=new Array(ZJ);F1(f1);var p1=new Array(KJ-PJ+1);F1(p1);var z6=new Array(P6);F1(z6);var F8=new Array(U1);F1(F8);var o5,a5,s5,e5=(W)=>{return W<256?f1[W]:f1[256+(W>>>7)]},b1=(W,Q)=>{W.pending_buf[W.pending++]=Q&255,W.pending_buf[W.pending++]=Q>>>8&255},P0=(W,Q,J)=>{if(W.bi_valid>u8-J)W.bi_buf|=Q<<W.bi_valid&65535,b1(W,W.bi_buf),W.bi_buf=Q>>u8-W.bi_valid,W.bi_valid+=J-u8;else W.bi_buf|=Q<<W.bi_valid&65535,W.bi_valid+=J},R0=(W,Q,J)=>{P0(W,J[Q*2],J[Q*2+1])},t5=(W,Q)=>{let J=0;do J|=W&1,W>>>=1,J<<=1;while(--Q>0);return J>>>1},HJ=(W)=>{if(W.bi_valid===16)b1(W,W.bi_buf),W.bi_buf=0,W.bi_valid=0;else if(W.bi_valid>=8)W.pending_buf[W.pending++]=W.bi_buf&255,W.bi_buf>>=8,W.bi_valid-=8},kJ=(W,Q)=>{const{dyn_tree:J,max_code:V}=Q,G=Q.stat_desc.static_tree,X=Q.stat_desc.has_stree,Y=Q.stat_desc.extra_bits,q=Q.stat_desc.extra_base,F=Q.stat_desc.max_length;let U,P,C,K,z,$,N=0;for(K=0;K<=m0;K++)W.bl_count[K]=0;J[W.heap[W.heap_max]*2+1]=0;for(U=W.heap_max+1;U<d5;U++){if(P=W.heap[U],K=J[J[P*2+1]*2+1]+1,K>F)K=F,N++;if(J[P*2+1]=K,P>V)continue;if(W.bl_count[K]++,z=0,P>=q)z=Y[P-q];if($=J[P*2],W.opt_len+=$*(K+z),X)W.static_len+=$*(G[P*2+1]+z)}if(N===0)return;do{K=F-1;while(W.bl_count[K]===0)K--;W.bl_count[K]--,W.bl_count[K+1]+=2,W.bl_count[F]--,N-=2}while(N>0);for(K=F;K!==0;K--){P=W.bl_count[K];while(P!==0){if(C=W.heap[--U],C>V)continue;if(J[C*2+1]!==K)W.opt_len+=(K-J[C*2+1])*J[C*2],J[C*2+1]=K;P--}}},W7=(W,Q,J)=>{const V=new Array(m0+1);let G=0,X,Y;for(X=1;X<=m0;X++)G=G+J[X-1]<<1,V[X]=G;for(Y=0;Y<=Q;Y++){let q=W[Y*2+1];if(q===0)continue;W[Y*2]=t5(V[q]++,q)}},$J=()=>{let W,Q,J,V,G;const X=new Array(m0+1);J=0;for(V=0;V<P6-1;V++){z6[V]=J;for(W=0;W<1<<W6[V];W++)p1[J++]=V}p1[J-1]=V,G=0;for(V=0;V<16;V++){F8[V]=G;for(W=0;W<1<<K8[V];W++)f1[G++]=V}G>>=7;for(;V<U1;V++){F8[V]=G<<7;for(W=0;W<1<<K8[V]-7;W++)f1[256+G++]=V}for(Q=0;Q<=m0;Q++)X[Q]=0;W=0;while(W<=143)x0[W*2+1]=8,W++,X[8]++;while(W<=255)x0[W*2+1]=9,W++,X[9]++;while(W<=279)x0[W*2+1]=7,W++,X[7]++;while(W<=287)x0[W*2+1]=8,W++,X[8]++;W7(x0,y1+1,X);for(W=0;W<U1;W++)T1[W*2+1]=5,T1[W*2]=t5(W,5);o5=new m8(x0,W6,c1+1,y1,m0),a5=new m8(T1,K8,0,U1,m0),s5=new m8(new Array(0),zJ,0,K6,FJ)},J7=(W)=>{let Q;for(Q=0;Q<y1;Q++)W.dyn_ltree[Q*2]=0;for(Q=0;Q<U1;Q++)W.dyn_dtree[Q*2]=0;for(Q=0;Q<K6;Q++)W.bl_tree[Q*2]=0;W.dyn_ltree[F6*2]=1,W.opt_len=W.static_len=0,W.sym_next=W.matches=0},Q7=(W)=>{if(W.bi_valid>8)b1(W,W.bi_buf);else if(W.bi_valid>0)W.pending_buf[W.pending++]=W.bi_buf;W.bi_buf=0,W.bi_valid=0},X5=(W,Q,J,V)=>{const G=Q*2,X=J*2;return W[G]<W[X]||W[G]===W[X]&&V[Q]<=V[J]},c8=(W,Q,J)=>{const V=W.heap[J];let G=J<<1;while(G<=W.heap_len){if(G<W.heap_len&&X5(Q,W.heap[G+1],W.heap[G],W.depth))G++;if(X5(Q,V,W.heap[G],W.depth))break;W.heap[J]=W.heap[G],J=G,G<<=1}W.heap[J]=V},Y5=(W,Q,J)=>{let V,G,X=0,Y,q;if(W.sym_next!==0)do if(V=W.pending_buf[W.sym_buf+X++]&255,V+=(W.pending_buf[W.sym_buf+X++]&255)<<8,G=W.pending_buf[W.sym_buf+X++],V===0)R0(W,G,Q);else{if(Y=p1[G],R0(W,Y+c1+1,Q),q=W6[Y],q!==0)G-=z6[Y],P0(W,G,q);if(V--,Y=e5(V),R0(W,Y,J),q=K8[Y],q!==0)V-=F8[Y],P0(W,V,q)}while(X<W.sym_next);R0(W,F6,Q)},J6=(W,Q)=>{const J=Q.dyn_tree,V=Q.stat_desc.static_tree,G=Q.stat_desc.has_stree,X=Q.stat_desc.elems;let Y,q,F=-1,U;W.heap_len=0,W.heap_max=d5;for(Y=0;Y<X;Y++)if(J[Y*2]!==0)W.heap[++W.heap_len]=F=Y,W.depth[Y]=0;else J[Y*2+1]=0;while(W.heap_len<2)if(U=W.heap[++W.heap_len]=F<2?++F:0,J[U*2]=1,W.depth[U]=0,W.opt_len--,G)W.static_len-=V[U*2+1];Q.max_code=F;for(Y=W.heap_len>>1;Y>=1;Y--)c8(W,J,Y);U=X;do Y=W.heap[1],W.heap[1]=W.heap[W.heap_len--],c8(W,J,1),q=W.heap[1],W.heap[--W.heap_max]=Y,W.heap[--W.heap_max]=q,J[U*2]=J[Y*2]+J[q*2],W.depth[U]=(W.depth[Y]>=W.depth[q]?W.depth[Y]:W.depth[q])+1,J[Y*2+1]=J[q*2+1]=U,W.heap[1]=U++,c8(W,J,1);while(W.heap_len>=2);W.heap[--W.heap_max]=W.heap[1],kJ(W,Q),W7(J,F,W.bl_count)},q5=(W,Q,J)=>{let V,G=-1,X,Y=Q[1],q=0,F=7,U=4;if(Y===0)F=138,U=3;Q[(J+1)*2+1]=65535;for(V=0;V<=J;V++){if(X=Y,Y=Q[(V+1)*2+1],++q<F&&X===Y)continue;else if(q<U)W.bl_tree[X*2]+=q;else if(X!==0){if(X!==G)W.bl_tree[X*2]++;W.bl_tree[l5*2]++}else if(q<=10)W.bl_tree[i5*2]++;else W.bl_tree[r5*2]++;if(q=0,G=X,Y===0)F=138,U=3;else if(X===Y)F=6,U=3;else F=7,U=4}},U5=(W,Q,J)=>{let V,G=-1,X,Y=Q[1],q=0,F=7,U=4;if(Y===0)F=138,U=3;for(V=0;V<=J;V++){if(X=Y,Y=Q[(V+1)*2+1],++q<F&&X===Y)continue;else if(q<U)do R0(W,X,W.bl_tree);while(--q!==0);else if(X!==0){if(X!==G)R0(W,X,W.bl_tree),q--;R0(W,l5,W.bl_tree),P0(W,q-3,2)}else if(q<=10)R0(W,i5,W.bl_tree),P0(W,q-3,3);else R0(W,r5,W.bl_tree),P0(W,q-11,7);if(q=0,G=X,Y===0)F=138,U=3;else if(X===Y)F=6,U=3;else F=7,U=4}},CJ=(W)=>{let Q;q5(W,W.dyn_ltree,W.l_desc.max_code),q5(W,W.dyn_dtree,W.d_desc.max_code),J6(W,W.bl_desc);for(Q=K6-1;Q>=3;Q--)if(W.bl_tree[n5[Q]*2+1]!==0)break;return W.opt_len+=3*(Q+1)+5+5+4,Q},jJ=(W,Q,J,V)=>{let G;P0(W,Q-257,5),P0(W,J-1,5),P0(W,V-4,4);for(G=0;G<V;G++)P0(W,W.bl_tree[n5[G]*2+1],3);U5(W,W.dyn_ltree,Q-1),U5(W,W.dyn_dtree,J-1)},BJ=(W)=>{let Q=4093624447,J;for(J=0;J<=31;J++,Q>>>=1)if(Q&1&&W.dyn_ltree[J*2]!==0)return 0;if(W.dyn_ltree[18]!==0||W.dyn_ltree[20]!==0||W.dyn_ltree[26]!==0)return 1;for(J=32;J<c1;J++)if(W.dyn_ltree[J*2]!==0)return 1;return 0},P5=!1,RJ=(W)=>{if(!P5)$J(),P5=!0;W.l_desc=new _8(W.dyn_ltree,o5),W.d_desc=new _8(W.dyn_dtree,a5),W.bl_desc=new _8(W.bl_tree,s5),W.bi_buf=0,W.bi_valid=0,J7(W)},V7=(W,Q,J,V)=>{if(P0(W,(qJ<<1)+(V?1:0),3),Q7(W),b1(W,J),b1(W,~J),J)W.pending_buf.set(W.window.subarray(Q,Q+J),W.pending);W.pending+=J},MJ=(W)=>{P0(W,c5<<1,3),R0(W,F6,x0),HJ(W)},LJ=(W,Q,J,V)=>{let G,X,Y=0;if(W.level>0){if(W.strm.data_type===2)W.strm.data_type=BJ(W);if(J6(W,W.l_desc),J6(W,W.d_desc),Y=CJ(W),G=W.opt_len+3+7>>>3,X=W.static_len+3+7>>>3,X<=G)G=X}else G=X=J+5;if(J+4<=G&&Q!==-1)V7(W,Q,J,V);else if(W.strategy===4||X===G)P0(W,(c5<<1)+(V?1:0),3),Y5(W,x0,T1);else P0(W,(UJ<<1)+(V?1:0),3),jJ(W,W.l_desc.max_code+1,W.d_desc.max_code+1,Y+1),Y5(W,W.dyn_ltree,W.dyn_dtree);if(J7(W),V)Q7(W)},IJ=(W,Q,J)=>{if(W.pending_buf[W.sym_buf+W.sym_next++]=Q,W.pending_buf[W.sym_buf+W.sym_next++]=Q>>8,W.pending_buf[W.sym_buf+W.sym_next++]=J,Q===0)W.dyn_ltree[J*2]++;else W.matches++,Q--,W.dyn_ltree[(p1[J]+c1+1)*2]++,W.dyn_dtree[e5(Q)*2]++;return W.sym_next===W.sym_end},DJ=RJ,OJ=V7,xJ=LJ,wJ=IJ,NJ=MJ,SJ={_tr_init:DJ,_tr_stored_block:OJ,_tr_flush_block:xJ,_tr_tally:wJ,_tr_align:NJ},vJ=(W,Q,J,V)=>{let G=W&65535|0,X=W>>>16&65535|0,Y=0;while(J!==0){Y=J>2000?2000:J,J-=Y;do G=G+Q[V++]|0,X=X+G|0;while(--Y);G%=65521,X%=65521}return G|X<<16|0},h1=vJ,AJ=()=>{let W,Q=[];for(var J=0;J<256;J++){W=J;for(var V=0;V<8;V++)W=W&1?3988292384^W>>>1:W>>>1;Q[J]=W}return Q},TJ=new Uint32Array(AJ()),gJ=(W,Q,J,V)=>{const G=TJ,X=V+J;W^=-1;for(let Y=V;Y<X;Y++)W=W>>>8^G[(W^Q[Y])&255];return W^-1},V0=gJ,d0={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},r0={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:EJ,_tr_stored_block:Q6,_tr_flush_block:yJ,_tr_tally:y0,_tr_align:fJ}=SJ,{Z_NO_FLUSH:f0,Z_PARTIAL_FLUSH:pJ,Z_FULL_FLUSH:bJ,Z_FINISH:H0,Z_BLOCK:K5,Z_OK:X0,Z_STREAM_END:F5,Z_STREAM_ERROR:M0,Z_DATA_ERROR:hJ,Z_BUF_ERROR:d8,Z_DEFAULT_COMPRESSION:uJ,Z_FILTERED:mJ,Z_HUFFMAN_ONLY:X8,Z_RLE:_J,Z_FIXED:cJ,Z_DEFAULT_STRATEGY:dJ,Z_UNKNOWN:lJ,Z_DEFLATED:H8}=r0,iJ=9,rJ=15,nJ=8,oJ=29,aJ=256,V6=aJ+1+oJ,sJ=30,eJ=19,tJ=2*V6+1,W9=15,s=3,E0=258,L0=E0+s+1,J9=32,P1=42,Z6=57,G6=69,X6=73,Y6=91,q6=103,_0=113,v1=666,q0=1,z1=2,l0=3,Z1=4,Q9=3,c0=(W,Q)=>{return W.msg=d0[Q],Q},z5=(W)=>{return W*2-(W>4?9:0)},g0=(W)=>{let Q=W.length;while(--Q>=0)W[Q]=0},V9=(W)=>{let Q,J,V,G=W.w_size;Q=W.hash_size,V=Q;do J=W.head[--V],W.head[V]=J>=G?J-G:0;while(--Q);Q=G,V=Q;do J=W.prev[--V],W.prev[V]=J>=G?J-G:0;while(--Q)},G9=(W,Q,J)=>(Q<<W.hash_shift^J)&W.hash_mask,p0=G9,F0=(W)=>{const Q=W.state;let J=Q.pending;if(J>W.avail_out)J=W.avail_out;if(J===0)return;if(W.output.set(Q.pending_buf.subarray(Q.pending_out,Q.pending_out+J),W.next_out),W.next_out+=J,Q.pending_out+=J,W.total_out+=J,W.avail_out-=J,Q.pending-=J,Q.pending===0)Q.pending_out=0},z0=(W,Q)=>{yJ(W,W.block_start>=0?W.block_start:-1,W.strstart-W.block_start,Q),W.block_start=W.strstart,F0(W.strm)},e=(W,Q)=>{W.pending_buf[W.pending++]=Q},S1=(W,Q)=>{W.pending_buf[W.pending++]=Q>>>8&255,W.pending_buf[W.pending++]=Q&255},U6=(W,Q,J,V)=>{let G=W.avail_in;if(G>V)G=V;if(G===0)return 0;if(W.avail_in-=G,Q.set(W.input.subarray(W.next_in,W.next_in+G),J),W.state.wrap===1)W.adler=h1(W.adler,Q,G,J);else if(W.state.wrap===2)W.adler=V0(W.adler,Q,G,J);return W.next_in+=G,W.total_in+=G,G},G7=(W,Q)=>{let{max_chain_length:J,strstart:V}=W,G,X,Y=W.prev_length,q=W.nice_match;const F=W.strstart>W.w_size-L0?W.strstart-(W.w_size-L0):0,U=W.window,P=W.w_mask,C=W.prev,K=W.strstart+E0;let z=U[V+Y-1],$=U[V+Y];if(W.prev_length>=W.good_match)J>>=2;if(q>W.lookahead)q=W.lookahead;do{if(G=Q,U[G+Y]!==$||U[G+Y-1]!==z||U[G]!==U[V]||U[++G]!==U[V+1])continue;V+=2,G++;do;while(U[++V]===U[++G]&&U[++V]===U[++G]&&U[++V]===U[++G]&&U[++V]===U[++G]&&U[++V]===U[++G]&&U[++V]===U[++G]&&U[++V]===U[++G]&&U[++V]===U[++G]&&V<K);if(X=E0-(K-V),V=K-E0,X>Y){if(W.match_start=Q,Y=X,X>=q)break;z=U[V+Y-1],$=U[V+Y]}}while((Q=C[Q&P])>F&&--J!==0);if(Y<=W.lookahead)return Y;return W.lookahead},K1=(W)=>{const Q=W.w_size;let J,V,G;do{if(V=W.window_size-W.lookahead-W.strstart,W.strstart>=Q+(Q-L0)){if(W.window.set(W.window.subarray(Q,Q+Q-V),0),W.match_start-=Q,W.strstart-=Q,W.block_start-=Q,W.insert>W.strstart)W.insert=W.strstart;V9(W),V+=Q}if(W.strm.avail_in===0)break;if(J=U6(W.strm,W.window,W.strstart+W.lookahead,V),W.lookahead+=J,W.lookahead+W.insert>=s){G=W.strstart-W.insert,W.ins_h=W.window[G],W.ins_h=p0(W,W.ins_h,W.window[G+1]);while(W.insert)if(W.ins_h=p0(W,W.ins_h,W.window[G+s-1]),W.prev[G&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=G,G++,W.insert--,W.lookahead+W.insert<s)break}}while(W.lookahead<L0&&W.strm.avail_in!==0)},X7=(W,Q)=>{let J=W.pending_buf_size-5>W.w_size?W.w_size:W.pending_buf_size-5,V,G,X,Y=0,q=W.strm.avail_in;do{if(V=65535,X=W.bi_valid+42>>3,W.strm.avail_out<X)break;if(X=W.strm.avail_out-X,G=W.strstart-W.block_start,V>G+W.strm.avail_in)V=G+W.strm.avail_in;if(V>X)V=X;if(V<J&&(V===0&&Q!==H0||Q===f0||V!==G+W.strm.avail_in))break;if(Y=Q===H0&&V===G+W.strm.avail_in?1:0,Q6(W,0,0,Y),W.pending_buf[W.pending-4]=V,W.pending_buf[W.pending-3]=V>>8,W.pending_buf[W.pending-2]=~V,W.pending_buf[W.pending-1]=~V>>8,F0(W.strm),G){if(G>V)G=V;W.strm.output.set(W.window.subarray(W.block_start,W.block_start+G),W.strm.next_out),W.strm.next_out+=G,W.strm.avail_out-=G,W.strm.total_out+=G,W.block_start+=G,V-=G}if(V)U6(W.strm,W.strm.output,W.strm.next_out,V),W.strm.next_out+=V,W.strm.avail_out-=V,W.strm.total_out+=V}while(Y===0);if(q-=W.strm.avail_in,q){if(q>=W.w_size)W.matches=2,W.window.set(W.strm.input.subarray(W.strm.next_in-W.w_size,W.strm.next_in),0),W.strstart=W.w_size,W.insert=W.strstart;else{if(W.window_size-W.strstart<=q){if(W.strstart-=W.w_size,W.window.set(W.window.subarray(W.w_size,W.w_size+W.strstart),0),W.matches<2)W.matches++;if(W.insert>W.strstart)W.insert=W.strstart}W.window.set(W.strm.input.subarray(W.strm.next_in-q,W.strm.next_in),W.strstart),W.strstart+=q,W.insert+=q>W.w_size-W.insert?W.w_size-W.insert:q}W.block_start=W.strstart}if(W.high_water<W.strstart)W.high_water=W.strstart;if(Y)return Z1;if(Q!==f0&&Q!==H0&&W.strm.avail_in===0&&W.strstart===W.block_start)return z1;if(X=W.window_size-W.strstart,W.strm.avail_in>X&&W.block_start>=W.w_size){if(W.block_start-=W.w_size,W.strstart-=W.w_size,W.window.set(W.window.subarray(W.w_size,W.w_size+W.strstart),0),W.matches<2)W.matches++;if(X+=W.w_size,W.insert>W.strstart)W.insert=W.strstart}if(X>W.strm.avail_in)X=W.strm.avail_in;if(X)U6(W.strm,W.window,W.strstart,X),W.strstart+=X,W.insert+=X>W.w_size-W.insert?W.w_size-W.insert:X;if(W.high_water<W.strstart)W.high_water=W.strstart;if(X=W.bi_valid+42>>3,X=W.pending_buf_size-X>65535?65535:W.pending_buf_size-X,J=X>W.w_size?W.w_size:X,G=W.strstart-W.block_start,G>=J||(G||Q===H0)&&Q!==f0&&W.strm.avail_in===0&&G<=X)V=G>X?X:G,Y=Q===H0&&W.strm.avail_in===0&&V===G?1:0,Q6(W,W.block_start,V,Y),W.block_start+=V,F0(W.strm);return Y?l0:q0},l8=(W,Q)=>{let J,V;for(;;){if(W.lookahead<L0){if(K1(W),W.lookahead<L0&&Q===f0)return q0;if(W.lookahead===0)break}if(J=0,W.lookahead>=s)W.ins_h=p0(W,W.ins_h,W.window[W.strstart+s-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;if(J!==0&&W.strstart-J<=W.w_size-L0)W.match_length=G7(W,J);if(W.match_length>=s)if(V=y0(W,W.strstart-W.match_start,W.match_length-s),W.lookahead-=W.match_length,W.match_length<=W.max_lazy_match&&W.lookahead>=s){W.match_length--;do W.strstart++,W.ins_h=p0(W,W.ins_h,W.window[W.strstart+s-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;while(--W.match_length!==0);W.strstart++}else W.strstart+=W.match_length,W.match_length=0,W.ins_h=W.window[W.strstart],W.ins_h=p0(W,W.ins_h,W.window[W.strstart+1]);else V=y0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++;if(V){if(z0(W,!1),W.strm.avail_out===0)return q0}}if(W.insert=W.strstart<s-1?W.strstart:s-1,Q===H0){if(z0(W,!0),W.strm.avail_out===0)return l0;return Z1}if(W.sym_next){if(z0(W,!1),W.strm.avail_out===0)return q0}return z1},Y1=(W,Q)=>{let J,V,G;for(;;){if(W.lookahead<L0){if(K1(W),W.lookahead<L0&&Q===f0)return q0;if(W.lookahead===0)break}if(J=0,W.lookahead>=s)W.ins_h=p0(W,W.ins_h,W.window[W.strstart+s-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;if(W.prev_length=W.match_length,W.prev_match=W.match_start,W.match_length=s-1,J!==0&&W.prev_length<W.max_lazy_match&&W.strstart-J<=W.w_size-L0){if(W.match_length=G7(W,J),W.match_length<=5&&(W.strategy===mJ||W.match_length===s&&W.strstart-W.match_start>4096))W.match_length=s-1}if(W.prev_length>=s&&W.match_length<=W.prev_length){G=W.strstart+W.lookahead-s,V=y0(W,W.strstart-1-W.prev_match,W.prev_length-s),W.lookahead-=W.prev_length-1,W.prev_length-=2;do if(++W.strstart<=G)W.ins_h=p0(W,W.ins_h,W.window[W.strstart+s-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;while(--W.prev_length!==0);if(W.match_available=0,W.match_length=s-1,W.strstart++,V){if(z0(W,!1),W.strm.avail_out===0)return q0}}else if(W.match_available){if(V=y0(W,0,W.window[W.strstart-1]),V)z0(W,!1);if(W.strstart++,W.lookahead--,W.strm.avail_out===0)return q0}else W.match_available=1,W.strstart++,W.lookahead--}if(W.match_available)V=y0(W,0,W.window[W.strstart-1]),W.match_available=0;if(W.insert=W.strstart<s-1?W.strstart:s-1,Q===H0){if(z0(W,!0),W.strm.avail_out===0)return l0;return Z1}if(W.sym_next){if(z0(W,!1),W.strm.avail_out===0)return q0}return z1},X9=(W,Q)=>{let J,V,G,X;const Y=W.window;for(;;){if(W.lookahead<=E0){if(K1(W),W.lookahead<=E0&&Q===f0)return q0;if(W.lookahead===0)break}if(W.match_length=0,W.lookahead>=s&&W.strstart>0){if(G=W.strstart-1,V=Y[G],V===Y[++G]&&V===Y[++G]&&V===Y[++G]){X=W.strstart+E0;do;while(V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&G<X);if(W.match_length=E0-(X-G),W.match_length>W.lookahead)W.match_length=W.lookahead}}if(W.match_length>=s)J=y0(W,1,W.match_length-s),W.lookahead-=W.match_length,W.strstart+=W.match_length,W.match_length=0;else J=y0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++;if(J){if(z0(W,!1),W.strm.avail_out===0)return q0}}if(W.insert=0,Q===H0){if(z0(W,!0),W.strm.avail_out===0)return l0;return Z1}if(W.sym_next){if(z0(W,!1),W.strm.avail_out===0)return q0}return z1},Y9=(W,Q)=>{let J;for(;;){if(W.lookahead===0){if(K1(W),W.lookahead===0){if(Q===f0)return q0;break}}if(W.match_length=0,J=y0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++,J){if(z0(W,!1),W.strm.avail_out===0)return q0}}if(W.insert=0,Q===H0){if(z0(W,!0),W.strm.avail_out===0)return l0;return Z1}if(W.sym_next){if(z0(W,!1),W.strm.avail_out===0)return q0}return z1},A1=[new B0(0,0,0,0,X7),new B0(4,4,8,4,l8),new B0(4,5,16,8,l8),new B0(4,6,32,32,l8),new B0(4,4,16,16,Y1),new B0(8,16,32,32,Y1),new B0(8,16,128,128,Y1),new B0(8,32,128,256,Y1),new B0(32,128,258,1024,Y1),new B0(32,258,258,4096,Y1)],q9=(W)=>{W.window_size=2*W.w_size,g0(W.head),W.max_lazy_match=A1[W.level].max_lazy,W.good_match=A1[W.level].good_length,W.nice_match=A1[W.level].nice_length,W.max_chain_length=A1[W.level].max_chain,W.strstart=0,W.block_start=0,W.lookahead=0,W.insert=0,W.match_length=W.prev_length=s-1,W.match_available=0,W.ins_h=0},d1=(W)=>{if(!W)return 1;const Q=W.state;if(!Q||Q.strm!==W||Q.status!==P1&&Q.status!==Z6&&Q.status!==G6&&Q.status!==X6&&Q.status!==Y6&&Q.status!==q6&&Q.status!==_0&&Q.status!==v1)return 1;return 0},Y7=(W)=>{if(d1(W))return c0(W,M0);W.total_in=W.total_out=0,W.data_type=lJ;const Q=W.state;if(Q.pending=0,Q.pending_out=0,Q.wrap<0)Q.wrap=-Q.wrap;return Q.status=Q.wrap===2?Z6:Q.wrap?P1:_0,W.adler=Q.wrap===2?0:1,Q.last_flush=-2,EJ(Q),X0},q7=(W)=>{const Q=Y7(W);if(Q===X0)q9(W.state);return Q},P9=(W,Q)=>{if(d1(W)||W.state.wrap!==2)return M0;return W.state.gzhead=Q,X0},U7=(W,Q,J,V,G,X)=>{if(!W)return M0;let Y=1;if(Q===uJ)Q=6;if(V<0)Y=0,V=-V;else if(V>15)Y=2,V-=16;if(G<1||G>iJ||J!==H8||V<8||V>15||Q<0||Q>9||X<0||X>cJ||V===8&&Y!==1)return c0(W,M0);if(V===8)V=9;const q=new U9;return W.state=q,q.strm=W,q.status=P1,q.wrap=Y,q.gzhead=null,q.w_bits=V,q.w_size=1<<q.w_bits,q.w_mask=q.w_size-1,q.hash_bits=G+7,q.hash_size=1<<q.hash_bits,q.hash_mask=q.hash_size-1,q.hash_shift=~~((q.hash_bits+s-1)/s),q.window=new Uint8Array(q.w_size*2),q.head=new Uint16Array(q.hash_size),q.prev=new Uint16Array(q.w_size),q.lit_bufsize=1<<G+6,q.pending_buf_size=q.lit_bufsize*4,q.pending_buf=new Uint8Array(q.pending_buf_size),q.sym_buf=q.lit_bufsize,q.sym_end=(q.lit_bufsize-1)*3,q.level=Q,q.strategy=X,q.method=J,q7(W)},K9=(W,Q)=>{return U7(W,Q,H8,rJ,nJ,dJ)},F9=(W,Q)=>{if(d1(W)||Q>K5||Q<0)return W?c0(W,M0):M0;const J=W.state;if(!W.output||W.avail_in!==0&&!W.input||J.status===v1&&Q!==H0)return c0(W,W.avail_out===0?d8:M0);const V=J.last_flush;if(J.last_flush=Q,J.pending!==0){if(F0(W),W.avail_out===0)return J.last_flush=-1,X0}else if(W.avail_in===0&&z5(Q)<=z5(V)&&Q!==H0)return c0(W,d8);if(J.status===v1&&W.avail_in!==0)return c0(W,d8);if(J.status===P1&&J.wrap===0)J.status=_0;if(J.status===P1){let G=H8+(J.w_bits-8<<4)<<8,X=-1;if(J.strategy>=X8||J.level<2)X=0;else if(J.level<6)X=1;else if(J.level===6)X=2;else X=3;if(G|=X<<6,J.strstart!==0)G|=J9;if(G+=31-G%31,S1(J,G),J.strstart!==0)S1(J,W.adler>>>16),S1(J,W.adler&65535);if(W.adler=1,J.status=_0,F0(W),J.pending!==0)return J.last_flush=-1,X0}if(J.status===Z6)if(W.adler=0,e(J,31),e(J,139),e(J,8),!J.gzhead){if(e(J,0),e(J,0),e(J,0),e(J,0),e(J,0),e(J,J.level===9?2:J.strategy>=X8||J.level<2?4:0),e(J,Q9),J.status=_0,F0(W),J.pending!==0)return J.last_flush=-1,X0}else{if(e(J,(J.gzhead.text?1:0)+(J.gzhead.hcrc?2:0)+(!J.gzhead.extra?0:4)+(!J.gzhead.name?0:8)+(!J.gzhead.comment?0:16)),e(J,J.gzhead.time&255),e(J,J.gzhead.time>>8&255),e(J,J.gzhead.time>>16&255),e(J,J.gzhead.time>>24&255),e(J,J.level===9?2:J.strategy>=X8||J.level<2?4:0),e(J,J.gzhead.os&255),J.gzhead.extra&&J.gzhead.extra.length)e(J,J.gzhead.extra.length&255),e(J,J.gzhead.extra.length>>8&255);if(J.gzhead.hcrc)W.adler=V0(W.adler,J.pending_buf,J.pending,0);J.gzindex=0,J.status=G6}if(J.status===G6){if(J.gzhead.extra){let G=J.pending,X=(J.gzhead.extra.length&65535)-J.gzindex;while(J.pending+X>J.pending_buf_size){let q=J.pending_buf_size-J.pending;if(J.pending_buf.set(J.gzhead.extra.subarray(J.gzindex,J.gzindex+q),J.pending),J.pending=J.pending_buf_size,J.gzhead.hcrc&&J.pending>G)W.adler=V0(W.adler,J.pending_buf,J.pending-G,G);if(J.gzindex+=q,F0(W),J.pending!==0)return J.last_flush=-1,X0;G=0,X-=q}let Y=new Uint8Array(J.gzhead.extra);if(J.pending_buf.set(Y.subarray(J.gzindex,J.gzindex+X),J.pending),J.pending+=X,J.gzhead.hcrc&&J.pending>G)W.adler=V0(W.adler,J.pending_buf,J.pending-G,G);J.gzindex=0}J.status=X6}if(J.status===X6){if(J.gzhead.name){let G=J.pending,X;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>G)W.adler=V0(W.adler,J.pending_buf,J.pending-G,G);if(F0(W),J.pending!==0)return J.last_flush=-1,X0;G=0}if(J.gzindex<J.gzhead.name.length)X=J.gzhead.name.charCodeAt(J.gzindex++)&255;else X=0;e(J,X)}while(X!==0);if(J.gzhead.hcrc&&J.pending>G)W.adler=V0(W.adler,J.pending_buf,J.pending-G,G);J.gzindex=0}J.status=Y6}if(J.status===Y6){if(J.gzhead.comment){let G=J.pending,X;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>G)W.adler=V0(W.adler,J.pending_buf,J.pending-G,G);if(F0(W),J.pending!==0)return J.last_flush=-1,X0;G=0}if(J.gzindex<J.gzhead.comment.length)X=J.gzhead.comment.charCodeAt(J.gzindex++)&255;else X=0;e(J,X)}while(X!==0);if(J.gzhead.hcrc&&J.pending>G)W.adler=V0(W.adler,J.pending_buf,J.pending-G,G)}J.status=q6}if(J.status===q6){if(J.gzhead.hcrc){if(J.pending+2>J.pending_buf_size){if(F0(W),J.pending!==0)return J.last_flush=-1,X0}e(J,W.adler&255),e(J,W.adler>>8&255),W.adler=0}if(J.status=_0,F0(W),J.pending!==0)return J.last_flush=-1,X0}if(W.avail_in!==0||J.lookahead!==0||Q!==f0&&J.status!==v1){let G=J.level===0?X7(J,Q):J.strategy===X8?Y9(J,Q):J.strategy===_J?X9(J,Q):A1[J.level].func(J,Q);if(G===l0||G===Z1)J.status=v1;if(G===q0||G===l0){if(W.avail_out===0)J.last_flush=-1;return X0}if(G===z1){if(Q===pJ)fJ(J);else if(Q!==K5){if(Q6(J,0,0,!1),Q===bJ){if(g0(J.head),J.lookahead===0)J.strstart=0,J.block_start=0,J.insert=0}}if(F0(W),W.avail_out===0)return J.last_flush=-1,X0}}if(Q!==H0)return X0;if(J.wrap<=0)return F5;if(J.wrap===2)e(J,W.adler&255),e(J,W.adler>>8&255),e(J,W.adler>>16&255),e(J,W.adler>>24&255),e(J,W.total_in&255),e(J,W.total_in>>8&255),e(J,W.total_in>>16&255),e(J,W.total_in>>24&255);else S1(J,W.adler>>>16),S1(J,W.adler&65535);if(F0(W),J.wrap>0)J.wrap=-J.wrap;return J.pending!==0?X0:F5},z9=(W)=>{if(d1(W))return M0;const Q=W.state.status;return W.state=null,Q===_0?c0(W,hJ):X0},Z9=(W,Q)=>{let J=Q.length;if(d1(W))return M0;const V=W.state,G=V.wrap;if(G===2||G===1&&V.status!==P1||V.lookahead)return M0;if(G===1)W.adler=h1(W.adler,Q,J,0);if(V.wrap=0,J>=V.w_size){if(G===0)g0(V.head),V.strstart=0,V.block_start=0,V.insert=0;let F=new Uint8Array(V.w_size);F.set(Q.subarray(J-V.w_size,J),0),Q=F,J=V.w_size}const{avail_in:X,next_in:Y,input:q}=W;W.avail_in=J,W.next_in=0,W.input=Q,K1(V);while(V.lookahead>=s){let F=V.strstart,U=V.lookahead-(s-1);do V.ins_h=p0(V,V.ins_h,V.window[F+s-1]),V.prev[F&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=F,F++;while(--U);V.strstart=F,V.lookahead=s-1,K1(V)}return V.strstart+=V.lookahead,V.block_start=V.strstart,V.insert=V.lookahead,V.lookahead=0,V.match_length=V.prev_length=s-1,V.match_available=0,W.next_in=Y,W.input=q,W.avail_in=X,V.wrap=G,X0},H9=K9,k9=U7,$9=q7,C9=Y7,j9=P9,B9=F9,R9=z9,M9=Z9,L9="pako deflate (from Nodeca project)",g1={deflateInit:H9,deflateInit2:k9,deflateReset:$9,deflateResetKeep:C9,deflateSetHeader:j9,deflate:B9,deflateEnd:R9,deflateSetDictionary:M9,deflateInfo:L9},I9=(W,Q)=>{return Object.prototype.hasOwnProperty.call(W,Q)},D9=function(W){const Q=Array.prototype.slice.call(arguments,1);while(Q.length){const J=Q.shift();if(!J)continue;if(typeof J!=="object")throw new TypeError(J+"must be non-object");for(let V in J)if(I9(J,V))W[V]=J[V]}return W},O9=(W)=>{let Q=0;for(let V=0,G=W.length;V<G;V++)Q+=W[V].length;const J=new Uint8Array(Q);for(let V=0,G=0,X=W.length;V<X;V++){let Y=W[V];J.set(Y,G),G+=Y.length}return J},k8={assign:D9,flattenChunks:O9},P7=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(W){P7=!1}var u1=new Uint8Array(256);for(let W=0;W<256;W++)u1[W]=W>=252?6:W>=248?5:W>=240?4:W>=224?3:W>=192?2:1;u1[254]=u1[254]=1;var x9=(W)=>{if(typeof TextEncoder==="function"&&TextEncoder.prototype.encode)return(new TextEncoder()).encode(W);let Q,J,V,G,X,Y=W.length,q=0;for(G=0;G<Y;G++){if(J=W.charCodeAt(G),(J&64512)===55296&&G+1<Y){if(V=W.charCodeAt(G+1),(V&64512)===56320)J=65536+(J-55296<<10)+(V-56320),G++}q+=J<128?1:J<2048?2:J<65536?3:4}Q=new Uint8Array(q);for(X=0,G=0;X<q;G++){if(J=W.charCodeAt(G),(J&64512)===55296&&G+1<Y){if(V=W.charCodeAt(G+1),(V&64512)===56320)J=65536+(J-55296<<10)+(V-56320),G++}if(J<128)Q[X++]=J;else if(J<2048)Q[X++]=192|J>>>6,Q[X++]=128|J&63;else if(J<65536)Q[X++]=224|J>>>12,Q[X++]=128|J>>>6&63,Q[X++]=128|J&63;else Q[X++]=240|J>>>18,Q[X++]=128|J>>>12&63,Q[X++]=128|J>>>6&63,Q[X++]=128|J&63}return Q},w9=(W,Q)=>{if(Q<65534){if(W.subarray&&P7)return String.fromCharCode.apply(null,W.length===Q?W:W.subarray(0,Q))}let J="";for(let V=0;V<Q;V++)J+=String.fromCharCode(W[V]);return J},N9=(W,Q)=>{const J=Q||W.length;if(typeof TextDecoder==="function"&&TextDecoder.prototype.decode)return(new TextDecoder()).decode(W.subarray(0,Q));let V,G;const X=new Array(J*2);for(G=0,V=0;V<J;){let Y=W[V++];if(Y<128){X[G++]=Y;continue}let q=u1[Y];if(q>4){X[G++]=65533,V+=q-1;continue}Y&=q===2?31:q===3?15:7;while(q>1&&V<J)Y=Y<<6|W[V++]&63,q--;if(q>1){X[G++]=65533;continue}if(Y<65536)X[G++]=Y;else Y-=65536,X[G++]=55296|Y>>10&1023,X[G++]=56320|Y&1023}return w9(X,G)},S9=(W,Q)=>{if(Q=Q||W.length,Q>W.length)Q=W.length;let J=Q-1;while(J>=0&&(W[J]&192)===128)J--;if(J<0)return Q;if(J===0)return Q;return J+u1[W[J]]>Q?J:Q},m1={string2buf:x9,buf2string:N9,utf8border:S9},K7=v9,F7=Object.prototype.toString,{Z_NO_FLUSH:A9,Z_SYNC_FLUSH:T9,Z_FULL_FLUSH:g9,Z_FINISH:E9,Z_OK:z8,Z_STREAM_END:y9,Z_DEFAULT_COMPRESSION:f9,Z_DEFAULT_STRATEGY:p9,Z_DEFLATED:b9}=r0;l1.prototype.push=function(W,Q){const J=this.strm,V=this.options.chunkSize;let G,X;if(this.ended)return!1;if(Q===~~Q)X=Q;else X=Q===!0?E9:A9;if(typeof W==="string")J.input=m1.string2buf(W);else if(F7.call(W)==="[object ArrayBuffer]")J.input=new Uint8Array(W);else J.input=W;J.next_in=0,J.avail_in=J.input.length;for(;;){if(J.avail_out===0)J.output=new Uint8Array(V),J.next_out=0,J.avail_out=V;if((X===T9||X===g9)&&J.avail_out<=6){this.onData(J.output.subarray(0,J.next_out)),J.avail_out=0;continue}if(G=g1.deflate(J,X),G===y9){if(J.next_out>0)this.onData(J.output.subarray(0,J.next_out));return G=g1.deflateEnd(this.strm),this.onEnd(G),this.ended=!0,G===z8}if(J.avail_out===0){this.onData(J.output);continue}if(X>0&&J.next_out>0){this.onData(J.output.subarray(0,J.next_out)),J.avail_out=0;continue}if(J.avail_in===0)break}return!0};l1.prototype.onData=function(W){this.chunks.push(W)};l1.prototype.onEnd=function(W){if(W===z8)this.result=k8.flattenChunks(this.chunks);this.chunks=[],this.err=W,this.msg=this.strm.msg};var m9=l1,_9=H6,c9=h9,d9=u9,l9=r0,i9={Deflate:m9,deflate:_9,deflateRaw:c9,gzip:d9,constants:l9},Y8=16209,r9=16191,n9=function W(Q,J){let V,G,X,Y,q,F,U,P,C,K,z,$,N,g,p,f,u,x,c,a,I,M,w,Z;const H=Q.state;V=Q.next_in,w=Q.input,G=V+(Q.avail_in-5),X=Q.next_out,Z=Q.output,Y=X-(J-Q.avail_out),q=X+(Q.avail_out-257),F=H.dmax,U=H.wsize,P=H.whave,C=H.wnext,K=H.window,z=H.hold,$=H.bits,N=H.lencode,g=H.distcode,p=(1<<H.lenbits)-1,f=(1<<H.distbits)-1;W:do{if($<15)z+=w[V++]<<$,$+=8,z+=w[V++]<<$,$+=8;u=N[z&p];J:for(;;){if(x=u>>>24,z>>>=x,$-=x,x=u>>>16&255,x===0)Z[X++]=u&65535;else if(x&16){if(c=u&65535,x&=15,x){if($<x)z+=w[V++]<<$,$+=8;c+=z&(1<<x)-1,z>>>=x,$-=x}if($<15)z+=w[V++]<<$,$+=8,z+=w[V++]<<$,$+=8;u=g[z&f];Q:for(;;){if(x=u>>>24,z>>>=x,$-=x,x=u>>>16&255,x&16){if(a=u&65535,x&=15,$<x){if(z+=w[V++]<<$,$+=8,$<x)z+=w[V++]<<$,$+=8}if(a+=z&(1<<x)-1,a>F){Q.msg="invalid distance too far back",H.mode=Y8;break W}if(z>>>=x,$-=x,x=X-Y,a>x){if(x=a-x,x>P){if(H.sane){Q.msg="invalid distance too far back",H.mode=Y8;break W}}if(I=0,M=K,C===0){if(I+=U-x,x<c){c-=x;do Z[X++]=K[I++];while(--x);I=X-a,M=Z}}else if(C<x){if(I+=U+C-x,x-=C,x<c){c-=x;do Z[X++]=K[I++];while(--x);if(I=0,C<c){x=C,c-=x;do Z[X++]=K[I++];while(--x);I=X-a,M=Z}}}else if(I+=C-x,x<c){c-=x;do Z[X++]=K[I++];while(--x);I=X-a,M=Z}while(c>2)Z[X++]=M[I++],Z[X++]=M[I++],Z[X++]=M[I++],c-=3;if(c){if(Z[X++]=M[I++],c>1)Z[X++]=M[I++]}}else{I=X-a;do Z[X++]=Z[I++],Z[X++]=Z[I++],Z[X++]=Z[I++],c-=3;while(c>2);if(c){if(Z[X++]=Z[I++],c>1)Z[X++]=Z[I++]}}}else if((x&64)===0){u=g[(u&65535)+(z&(1<<x)-1)];continue Q}else{Q.msg="invalid distance code",H.mode=Y8;break W}break}}else if((x&64)===0){u=N[(u&65535)+(z&(1<<x)-1)];continue J}else if(x&32){H.mode=r9;break W}else{Q.msg="invalid literal/length code",H.mode=Y8;break W}break}}while(V<G&&X<q);c=$>>3,V-=c,$-=c<<3,z&=(1<<$)-1,Q.next_in=V,Q.next_out=X,Q.avail_in=V<G?5+(G-V):5-(V-G),Q.avail_out=X<q?257+(q-X):257-(X-q),H.hold=z,H.bits=$;return},q1=15,Z5=852,H5=592,k5=0,i8=1,$5=2,o9=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),a9=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),s9=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),e9=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),t9=(W,Q,J,V,G,X,Y,q)=>{const F=q.bits;let U=0,P=0,C=0,K=0,z=0,$=0,N=0,g=0,p=0,f=0,u,x,c,a,I,M=null,w;const Z=new Uint16Array(q1+1),H=new Uint16Array(q1+1);let R=null,k,j,D;for(U=0;U<=q1;U++)Z[U]=0;for(P=0;P<V;P++)Z[Q[J+P]]++;z=F;for(K=q1;K>=1;K--)if(Z[K]!==0)break;if(z>K)z=K;if(K===0)return G[X++]=1<<24|64<<16|0,G[X++]=1<<24|64<<16|0,q.bits=1,0;for(C=1;C<K;C++)if(Z[C]!==0)break;if(z<C)z=C;g=1;for(U=1;U<=q1;U++)if(g<<=1,g-=Z[U],g<0)return-1;if(g>0&&(W===k5||K!==1))return-1;H[1]=0;for(U=1;U<q1;U++)H[U+1]=H[U]+Z[U];for(P=0;P<V;P++)if(Q[J+P]!==0)Y[H[Q[J+P]]++]=P;if(W===k5)M=R=Y,w=20;else if(W===i8)M=o9,R=a9,w=257;else M=s9,R=e9,w=0;if(f=0,P=0,U=C,I=X,$=z,N=0,c=-1,p=1<<z,a=p-1,W===i8&&p>Z5||W===$5&&p>H5)return 1;for(;;){if(k=U-N,Y[P]+1<w)j=0,D=Y[P];else if(Y[P]>=w)j=R[Y[P]-w],D=M[Y[P]-w];else j=96,D=0;u=1<<U-N,x=1<<$,C=x;do x-=u,G[I+(f>>N)+x]=k<<24|j<<16|D|0;while(x!==0);u=1<<U-1;while(f&u)u>>=1;if(u!==0)f&=u-1,f+=u;else f=0;if(P++,--Z[U]===0){if(U===K)break;U=Q[J+Y[P]]}if(U>z&&(f&a)!==c){if(N===0)N=z;I+=C,$=U-N,g=1<<$;while($+N<K){if(g-=Z[$+N],g<=0)break;$++,g<<=1}if(p+=1<<$,W===i8&&p>Z5||W===$5&&p>H5)return 1;c=f&a,G[c]=z<<24|$<<16|I-X|0}}if(f!==0)G[I+f]=U-N<<24|64<<16|0;return q.bits=z,0},E1=t9,WQ=0,z7=1,Z7=2,{Z_FINISH:C5,Z_BLOCK:JQ,Z_TREES:q8,Z_OK:i0,Z_STREAM_END:QQ,Z_NEED_DICT:VQ,Z_STREAM_ERROR:k0,Z_DATA_ERROR:H7,Z_MEM_ERROR:k7,Z_BUF_ERROR:GQ,Z_DEFLATED:j5}=r0,$8=16180,B5=16181,R5=16182,M5=16183,L5=16184,I5=16185,D5=16186,O5=16187,x5=16188,w5=16189,Z8=16190,O0=16191,r8=16192,N5=16193,n8=16194,S5=16195,v5=16196,A5=16197,T5=16198,U8=16199,P8=16200,g5=16201,E5=16202,y5=16203,f5=16204,p5=16205,o8=16206,b5=16207,h5=16208,W0=16209,$7=16210,C7=16211,XQ=852,YQ=592,qQ=15,UQ=qQ,u5=(W)=>{return(W>>>24&255)+(W>>>8&65280)+((W&65280)<<8)+((W&255)<<24)},n0=(W)=>{if(!W)return 1;const Q=W.state;if(!Q||Q.strm!==W||Q.mode<$8||Q.mode>C7)return 1;return 0},j7=(W)=>{if(n0(W))return k0;const Q=W.state;if(W.total_in=W.total_out=Q.total=0,W.msg="",Q.wrap)W.adler=Q.wrap&1;return Q.mode=$8,Q.last=0,Q.havedict=0,Q.flags=-1,Q.dmax=32768,Q.head=null,Q.hold=0,Q.bits=0,Q.lencode=Q.lendyn=new Int32Array(XQ),Q.distcode=Q.distdyn=new Int32Array(YQ),Q.sane=1,Q.back=-1,i0},B7=(W)=>{if(n0(W))return k0;const Q=W.state;return Q.wsize=0,Q.whave=0,Q.wnext=0,j7(W)},R7=(W,Q)=>{let J;if(n0(W))return k0;const V=W.state;if(Q<0)J=0,Q=-Q;else if(J=(Q>>4)+5,Q<48)Q&=15;if(Q&&(Q<8||Q>15))return k0;if(V.window!==null&&V.wbits!==Q)V.window=null;return V.wrap=J,V.wbits=Q,B7(W)},M7=(W,Q)=>{if(!W)return k0;const J=new PQ;W.state=J,J.strm=W,J.window=null,J.mode=$8;const V=R7(W,Q);if(V!==i0)W.state=null;return V},KQ=(W)=>{return M7(W,UQ)},m5=!0,a8,s8,FQ=(W)=>{if(m5){a8=new Int32Array(512),s8=new Int32Array(32);let Q=0;while(Q<144)W.lens[Q++]=8;while(Q<256)W.lens[Q++]=9;while(Q<280)W.lens[Q++]=7;while(Q<288)W.lens[Q++]=8;E1(z7,W.lens,0,288,a8,0,W.work,{bits:9}),Q=0;while(Q<32)W.lens[Q++]=5;E1(Z7,W.lens,0,32,s8,0,W.work,{bits:5}),m5=!1}W.lencode=a8,W.lenbits=9,W.distcode=s8,W.distbits=5},L7=(W,Q,J,V)=>{let G;const X=W.state;if(X.window===null)X.wsize=1<<X.wbits,X.wnext=0,X.whave=0,X.window=new Uint8Array(X.wsize);if(V>=X.wsize)X.window.set(Q.subarray(J-X.wsize,J),0),X.wnext=0,X.whave=X.wsize;else{if(G=X.wsize-X.wnext,G>V)G=V;if(X.window.set(Q.subarray(J-V,J-V+G),X.wnext),V-=G,V)X.window.set(Q.subarray(J-V,J),0),X.wnext=V,X.whave=X.wsize;else{if(X.wnext+=G,X.wnext===X.wsize)X.wnext=0;if(X.whave<X.wsize)X.whave+=G}}return 0},zQ=(W,Q)=>{let J,V,G,X,Y,q,F,U,P,C,K,z,$,N,g=0,p,f,u,x,c,a,I,M;const w=new Uint8Array(4);let Z,H;const R=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(n0(W)||!W.output||!W.input&&W.avail_in!==0)return k0;if(J=W.state,J.mode===O0)J.mode=r8;Y=W.next_out,G=W.output,F=W.avail_out,X=W.next_in,V=W.input,q=W.avail_in,U=J.hold,P=J.bits,C=q,K=F,M=i0;W:for(;;)switch(J.mode){case $8:if(J.wrap===0){J.mode=r8;break}while(P<16){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.wrap&2&&U===35615){if(J.wbits===0)J.wbits=15;J.check=0,w[0]=U&255,w[1]=U>>>8&255,J.check=V0(J.check,w,2,0),U=0,P=0,J.mode=B5;break}if(J.head)J.head.done=!1;if(!(J.wrap&1)||(((U&255)<<8)+(U>>8))%31){W.msg="incorrect header check",J.mode=W0;break}if((U&15)!==j5){W.msg="unknown compression method",J.mode=W0;break}if(U>>>=4,P-=4,I=(U&15)+8,J.wbits===0)J.wbits=I;if(I>15||I>J.wbits){W.msg="invalid window size",J.mode=W0;break}J.dmax=1<<J.wbits,J.flags=0,W.adler=J.check=1,J.mode=U&512?w5:O0,U=0,P=0;break;case B5:while(P<16){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.flags=U,(J.flags&255)!==j5){W.msg="unknown compression method",J.mode=W0;break}if(J.flags&57344){W.msg="unknown header flags set",J.mode=W0;break}if(J.head)J.head.text=U>>8&1;if(J.flags&512&&J.wrap&4)w[0]=U&255,w[1]=U>>>8&255,J.check=V0(J.check,w,2,0);U=0,P=0,J.mode=R5;case R5:while(P<32){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.head)J.head.time=U;if(J.flags&512&&J.wrap&4)w[0]=U&255,w[1]=U>>>8&255,w[2]=U>>>16&255,w[3]=U>>>24&255,J.check=V0(J.check,w,4,0);U=0,P=0,J.mode=M5;case M5:while(P<16){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.head)J.head.xflags=U&255,J.head.os=U>>8;if(J.flags&512&&J.wrap&4)w[0]=U&255,w[1]=U>>>8&255,J.check=V0(J.check,w,2,0);U=0,P=0,J.mode=L5;case L5:if(J.flags&1024){while(P<16){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.length=U,J.head)J.head.extra_len=U;if(J.flags&512&&J.wrap&4)w[0]=U&255,w[1]=U>>>8&255,J.check=V0(J.check,w,2,0);U=0,P=0}else if(J.head)J.head.extra=null;J.mode=I5;case I5:if(J.flags&1024){if(z=J.length,z>q)z=q;if(z){if(J.head){if(I=J.head.extra_len-J.length,!J.head.extra)J.head.extra=new Uint8Array(J.head.extra_len);J.head.extra.set(V.subarray(X,X+z),I)}if(J.flags&512&&J.wrap&4)J.check=V0(J.check,V,z,X);q-=z,X+=z,J.length-=z}if(J.length)break W}J.length=0,J.mode=D5;case D5:if(J.flags&2048){if(q===0)break W;z=0;do if(I=V[X+z++],J.head&&I&&J.length<65536)J.head.name+=String.fromCharCode(I);while(I&&z<q);if(J.flags&512&&J.wrap&4)J.check=V0(J.check,V,z,X);if(q-=z,X+=z,I)break W}else if(J.head)J.head.name=null;J.length=0,J.mode=O5;case O5:if(J.flags&4096){if(q===0)break W;z=0;do if(I=V[X+z++],J.head&&I&&J.length<65536)J.head.comment+=String.fromCharCode(I);while(I&&z<q);if(J.flags&512&&J.wrap&4)J.check=V0(J.check,V,z,X);if(q-=z,X+=z,I)break W}else if(J.head)J.head.comment=null;J.mode=x5;case x5:if(J.flags&512){while(P<16){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.wrap&4&&U!==(J.check&65535)){W.msg="header crc mismatch",J.mode=W0;break}U=0,P=0}if(J.head)J.head.hcrc=J.flags>>9&1,J.head.done=!0;W.adler=J.check=0,J.mode=O0;break;case w5:while(P<32){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}W.adler=J.check=u5(U),U=0,P=0,J.mode=Z8;case Z8:if(J.havedict===0)return W.next_out=Y,W.avail_out=F,W.next_in=X,W.avail_in=q,J.hold=U,J.bits=P,VQ;W.adler=J.check=1,J.mode=O0;case O0:if(Q===JQ||Q===q8)break W;case r8:if(J.last){U>>>=P&7,P-=P&7,J.mode=o8;break}while(P<3){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}switch(J.last=U&1,U>>>=1,P-=1,U&3){case 0:J.mode=N5;break;case 1:if(FQ(J),J.mode=U8,Q===q8){U>>>=2,P-=2;break W}break;case 2:J.mode=v5;break;case 3:W.msg="invalid block type",J.mode=W0}U>>>=2,P-=2;break;case N5:U>>>=P&7,P-=P&7;while(P<32){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if((U&65535)!==(U>>>16^65535)){W.msg="invalid stored block lengths",J.mode=W0;break}if(J.length=U&65535,U=0,P=0,J.mode=n8,Q===q8)break W;case n8:J.mode=S5;case S5:if(z=J.length,z){if(z>q)z=q;if(z>F)z=F;if(z===0)break W;G.set(V.subarray(X,X+z),Y),q-=z,X+=z,F-=z,Y+=z,J.length-=z;break}J.mode=O0;break;case v5:while(P<14){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.nlen=(U&31)+257,U>>>=5,P-=5,J.ndist=(U&31)+1,U>>>=5,P-=5,J.ncode=(U&15)+4,U>>>=4,P-=4,J.nlen>286||J.ndist>30){W.msg="too many length or distance symbols",J.mode=W0;break}J.have=0,J.mode=A5;case A5:while(J.have<J.ncode){while(P<3){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}J.lens[R[J.have++]]=U&7,U>>>=3,P-=3}while(J.have<19)J.lens[R[J.have++]]=0;if(J.lencode=J.lendyn,J.lenbits=7,Z={bits:J.lenbits},M=E1(WQ,J.lens,0,19,J.lencode,0,J.work,Z),J.lenbits=Z.bits,M){W.msg="invalid code lengths set",J.mode=W0;break}J.have=0,J.mode=T5;case T5:while(J.have<J.nlen+J.ndist){for(;;){if(g=J.lencode[U&(1<<J.lenbits)-1],p=g>>>24,f=g>>>16&255,u=g&65535,p<=P)break;if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(u<16)U>>>=p,P-=p,J.lens[J.have++]=u;else{if(u===16){H=p+2;while(P<H){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(U>>>=p,P-=p,J.have===0){W.msg="invalid bit length repeat",J.mode=W0;break}I=J.lens[J.have-1],z=3+(U&3),U>>>=2,P-=2}else if(u===17){H=p+3;while(P<H){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}U>>>=p,P-=p,I=0,z=3+(U&7),U>>>=3,P-=3}else{H=p+7;while(P<H){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}U>>>=p,P-=p,I=0,z=11+(U&127),U>>>=7,P-=7}if(J.have+z>J.nlen+J.ndist){W.msg="invalid bit length repeat",J.mode=W0;break}while(z--)J.lens[J.have++]=I}}if(J.mode===W0)break;if(J.lens[256]===0){W.msg="invalid code -- missing end-of-block",J.mode=W0;break}if(J.lenbits=9,Z={bits:J.lenbits},M=E1(z7,J.lens,0,J.nlen,J.lencode,0,J.work,Z),J.lenbits=Z.bits,M){W.msg="invalid literal/lengths set",J.mode=W0;break}if(J.distbits=6,J.distcode=J.distdyn,Z={bits:J.distbits},M=E1(Z7,J.lens,J.nlen,J.ndist,J.distcode,0,J.work,Z),J.distbits=Z.bits,M){W.msg="invalid distances set",J.mode=W0;break}if(J.mode=U8,Q===q8)break W;case U8:J.mode=P8;case P8:if(q>=6&&F>=258){if(W.next_out=Y,W.avail_out=F,W.next_in=X,W.avail_in=q,J.hold=U,J.bits=P,n9(W,K),Y=W.next_out,G=W.output,F=W.avail_out,X=W.next_in,V=W.input,q=W.avail_in,U=J.hold,P=J.bits,J.mode===O0)J.back=-1;break}J.back=0;for(;;){if(g=J.lencode[U&(1<<J.lenbits)-1],p=g>>>24,f=g>>>16&255,u=g&65535,p<=P)break;if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(f&&(f&240)===0){x=p,c=f,a=u;for(;;){if(g=J.lencode[a+((U&(1<<x+c)-1)>>x)],p=g>>>24,f=g>>>16&255,u=g&65535,x+p<=P)break;if(q===0)break W;q--,U+=V[X++]<<P,P+=8}U>>>=x,P-=x,J.back+=x}if(U>>>=p,P-=p,J.back+=p,J.length=u,f===0){J.mode=p5;break}if(f&32){J.back=-1,J.mode=O0;break}if(f&64){W.msg="invalid literal/length code",J.mode=W0;break}J.extra=f&15,J.mode=g5;case g5:if(J.extra){H=J.extra;while(P<H){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}J.length+=U&(1<<J.extra)-1,U>>>=J.extra,P-=J.extra,J.back+=J.extra}J.was=J.length,J.mode=E5;case E5:for(;;){if(g=J.distcode[U&(1<<J.distbits)-1],p=g>>>24,f=g>>>16&255,u=g&65535,p<=P)break;if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if((f&240)===0){x=p,c=f,a=u;for(;;){if(g=J.distcode[a+((U&(1<<x+c)-1)>>x)],p=g>>>24,f=g>>>16&255,u=g&65535,x+p<=P)break;if(q===0)break W;q--,U+=V[X++]<<P,P+=8}U>>>=x,P-=x,J.back+=x}if(U>>>=p,P-=p,J.back+=p,f&64){W.msg="invalid distance code",J.mode=W0;break}J.offset=u,J.extra=f&15,J.mode=y5;case y5:if(J.extra){H=J.extra;while(P<H){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}J.offset+=U&(1<<J.extra)-1,U>>>=J.extra,P-=J.extra,J.back+=J.extra}if(J.offset>J.dmax){W.msg="invalid distance too far back",J.mode=W0;break}J.mode=f5;case f5:if(F===0)break W;if(z=K-F,J.offset>z){if(z=J.offset-z,z>J.whave){if(J.sane){W.msg="invalid distance too far back",J.mode=W0;break}}if(z>J.wnext)z-=J.wnext,$=J.wsize-z;else $=J.wnext-z;if(z>J.length)z=J.length;N=J.window}else N=G,$=Y-J.offset,z=J.length;if(z>F)z=F;F-=z,J.length-=z;do G[Y++]=N[$++];while(--z);if(J.length===0)J.mode=P8;break;case p5:if(F===0)break W;G[Y++]=J.length,F--,J.mode=P8;break;case o8:if(J.wrap){while(P<32){if(q===0)break W;q--,U|=V[X++]<<P,P+=8}if(K-=F,W.total_out+=K,J.total+=K,J.wrap&4&&K)W.adler=J.check=J.flags?V0(J.check,G,K,Y-K):h1(J.check,G,K,Y-K);if(K=F,J.wrap&4&&(J.flags?U:u5(U))!==J.check){W.msg="incorrect data check",J.mode=W0;break}U=0,P=0}J.mode=b5;case b5:if(J.wrap&&J.flags){while(P<32){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.wrap&4&&U!==(J.total&4294967295)){W.msg="incorrect length check",J.mode=W0;break}U=0,P=0}J.mode=h5;case h5:M=QQ;break W;case W0:M=H7;break W;case $7:return k7;case C7:default:return k0}if(W.next_out=Y,W.avail_out=F,W.next_in=X,W.avail_in=q,J.hold=U,J.bits=P,J.wsize||K!==W.avail_out&&J.mode<W0&&(J.mode<o8||Q!==C5)){if(L7(W,W.output,W.next_out,K-W.avail_out));}if(C-=W.avail_in,K-=W.avail_out,W.total_in+=C,W.total_out+=K,J.total+=K,J.wrap&4&&K)W.adler=J.check=J.flags?V0(J.check,G,K,W.next_out-K):h1(J.check,G,K,W.next_out-K);if(W.data_type=J.bits+(J.last?64:0)+(J.mode===O0?128:0)+(J.mode===U8||J.mode===n8?256:0),(C===0&&K===0||Q===C5)&&M===i0)M=GQ;return M},ZQ=(W)=>{if(n0(W))return k0;let Q=W.state;if(Q.window)Q.window=null;return W.state=null,i0},HQ=(W,Q)=>{if(n0(W))return k0;const J=W.state;if((J.wrap&2)===0)return k0;return J.head=Q,Q.done=!1,i0},kQ=(W,Q)=>{const J=Q.length;let V,G,X;if(n0(W))return k0;if(V=W.state,V.wrap!==0&&V.mode!==Z8)return k0;if(V.mode===Z8){if(G=1,G=h1(G,Q,J,0),G!==V.check)return H7}if(X=L7(W,Q,J,J),X)return V.mode=$7,k7;return V.havedict=1,i0},$Q=B7,CQ=R7,jQ=j7,BQ=KQ,RQ=M7,MQ=zQ,LQ=ZQ,IQ=HQ,DQ=kQ,OQ="pako inflate (from Nodeca project)",w0={inflateReset:$Q,inflateReset2:CQ,inflateResetKeep:jQ,inflateInit:BQ,inflateInit2:RQ,inflate:MQ,inflateEnd:LQ,inflateGetHeader:IQ,inflateSetDictionary:DQ,inflateInfo:OQ},wQ=xQ,I7=Object.prototype.toString,{Z_NO_FLUSH:NQ,Z_FINISH:SQ,Z_OK:_1,Z_STREAM_END:e8,Z_NEED_DICT:t8,Z_STREAM_ERROR:vQ,Z_DATA_ERROR:_5,Z_MEM_ERROR:AQ}=r0;i1.prototype.push=function(W,Q){const J=this.strm,V=this.options.chunkSize,G=this.options.dictionary;let X,Y,q;if(this.ended)return!1;if(Q===~~Q)Y=Q;else Y=Q===!0?SQ:NQ;if(I7.call(W)==="[object ArrayBuffer]")J.input=new Uint8Array(W);else J.input=W;J.next_in=0,J.avail_in=J.input.length;for(;;){if(J.avail_out===0)J.output=new Uint8Array(V),J.next_out=0,J.avail_out=V;if(X=w0.inflate(J,Y),X===t8&&G){if(X=w0.inflateSetDictionary(J,G),X===_1)X=w0.inflate(J,Y);else if(X===_5)X=t8}while(J.avail_in>0&&X===e8&&J.state.wrap>0&&W[J.next_in]!==0)w0.inflateReset(J),X=w0.inflate(J,Y);switch(X){case vQ:case _5:case t8:case AQ:return this.onEnd(X),this.ended=!0,!1}if(q=J.avail_out,J.next_out){if(J.avail_out===0||X===e8)if(this.options.to==="string"){let F=m1.utf8border(J.output,J.next_out),U=J.next_out-F,P=m1.buf2string(J.output,F);if(J.next_out=U,J.avail_out=V-U,U)J.output.set(J.output.subarray(F,F+U),0);this.onData(P)}else this.onData(J.output.length===J.next_out?J.output:J.output.subarray(0,J.next_out))}if(X===_1&&q===0)continue;if(X===e8)return X=w0.inflateEnd(this.strm),this.onEnd(X),this.ended=!0,!0;if(J.avail_in===0)break}return!0};i1.prototype.onData=function(W){this.chunks.push(W)};i1.prototype.onEnd=function(W){if(W===_1)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=k8.flattenChunks(this.chunks);this.chunks=[],this.err=W,this.msg=this.strm.msg};var gQ=i1,EQ=k6,yQ=TQ,fQ=k6,pQ=r0,bQ={Inflate:gQ,inflate:EQ,inflateRaw:yQ,ungzip:fQ,constants:pQ},{Deflate:hQ,deflate:uQ,deflateRaw:mQ,gzip:_Q}=i9,{Inflate:cQ,inflate:dQ,inflateRaw:lQ,ungzip:iQ}=bQ,rQ=hQ,nQ=uQ,oQ=mQ,aQ=_Q,sQ=cQ,eQ=dQ,tQ=lQ,WV=iQ,JV=r0,H1={Deflate:rQ,deflate:nQ,deflateRaw:oQ,gzip:aQ,Inflate:sQ,inflate:eQ,inflateRaw:tQ,ungzip:WV,constants:JV};var T8=function(W){return W instanceof Uint8Array||ArrayBuffer.isView(W)&&W.constructor.name==="Uint8Array"},O6=function(W){if(!Number.isSafeInteger(W)||W<0)throw Error("positive integer expected, got "+W)},W1=function(W,...Q){if(!T8(W))throw Error("Uint8Array expected");if(Q.length>0&&!Q.includes(W.length))throw Error("Uint8Array expected of length "+Q+", got length="+W.length)},i7=function(W){if(typeof W!="function"||typeof W.create!="function")throw Error("Hash should be wrapped by utils.createHasher");O6(W.outputLen),O6(W.blockLen)},I8=function(W,Q=!0){if(W.destroyed)throw Error("Hash instance has been destroyed");if(Q&&W.finished)throw Error("Hash#digest() has already been called")},D8=function(...W){for(let Q=0;Q<W.length;Q++)W[Q].fill(0)},$6=function(W){return new DataView(W.buffer,W.byteOffset,W.byteLength)},I0=function(W,Q){return W<<32-Q|W>>>Q},R1=function(W){if(W1(W),r7)return W.toHex();let Q="";for(let J=0;J<W.length;J++)Q+=QV[W[J]];return Q},w7=function(W){return W>=D7&&W<=VV?W-D7:W>=O7&&W<=GV?W-(O7-10):W>=x7&&W<=XV?W-(x7-10):void 0},O8=function(W){if(typeof W!="string")throw Error("hex string expected, got "+typeof W);if(r7)return Uint8Array.fromHex(W);const Q=W.length,J=Q/2;if(Q%2)throw Error("hex string expected, got unpadded hex of length "+Q);const V=new Uint8Array(J);for(let G=0,X=0;G<J;G++,X+=2){const Y=w7(W.charCodeAt(X)),q=w7(W.charCodeAt(X+1));if(Y===void 0||q===void 0){const F=W[X]+W[X+1];throw Error('hex string expected, got non-hex character "'+F+'" at index '+X)}V[G]=16*Y+q}return V},n7=function(W){if(typeof W!="string")throw Error("string expected");return new Uint8Array((new TextEncoder()).encode(W))},E6=function(W){return typeof W=="string"&&(W=n7(W)),W1(W),W},D0=function(...W){let Q=0;for(let V=0;V<W.length;V++){const G=W[V];W1(G),Q+=G.length}const J=new Uint8Array(Q);for(let V=0,G=0;V<W.length;V++){const X=W[V];J.set(X,G),G+=X.length}return J},YV=function(W){const Q=(V)=>W().update(E6(V)).digest(),J=W();return Q.outputLen=J.outputLen,Q.blockLen=J.blockLen,Q.create=()=>W(),Q},x8=function(W=32){if(k1&&typeof k1.getRandomValues=="function")return k1.getRandomValues(new Uint8Array(W));if(k1&&typeof k1.randomBytes=="function")return Uint8Array.from(k1.randomBytes(W));throw Error("crypto.getRandomValues must be defined")},qV=function(W,Q,J){return W&Q^W&J^Q&J},w8=function(W,Q=""){if(typeof W!="boolean")throw Error((Q&&`"${Q}"`)+"expected boolean, got type="+typeof W);return W},o0=function(W,Q,J=""){const V=T8(W),G=W?.length,X=Q!==void 0;if(!V||X&&G!==Q)throw Error((J&&`"${J}" `)+"expected Uint8Array"+(X?" of length "+Q:"")+", got "+(V?"length="+G:"type="+typeof W));return W},C8=function(W){const Q=W.toString(16);return 1&Q.length?"0"+Q:Q},e7=function(W){if(typeof W!="string")throw Error("hex string expected, got "+typeof W);return W===""?p6:BigInt("0x"+W)},I1=function(W){return e7(R1(W))},t7=function(W){return W1(W),e7(R1(Uint8Array.from(W).reverse()))},g8=function(W,Q){return O8(W.toString(16).padStart(2*Q,"0"))},WW=function(W,Q){return g8(W,Q).reverse()},Q0=function(W,Q,J){let V;if(typeof Q=="string")try{V=O8(Q)}catch(X){throw Error(W+" must be hex string or Uint8Array, cause: "+X)}else{if(!T8(Q))throw Error(W+" must be hex string or Uint8Array");V=Uint8Array.from(Q)}const G=V.length;if(typeof J=="number"&&G!==J)throw Error(W+" of length "+J+" expected, got "+G);return V},N6=function(W,Q,J){return C6(W)&&C6(Q)&&C6(J)&&Q<=W&&W<J},JW=function(W){let Q;for(Q=0;W>p6;W>>=w6,Q+=1);return Q},b6=function(W,Q,J={}){if(!W||typeof W!="object")throw Error("expected valid options object");function V(G,X,Y){const q=W[G];if(Y&&q===void 0)return;const F=typeof q;if(F!==X||q===null)throw Error(`param "${G}" is invalid: expected ${X}, got ${F}`)}Object.entries(Q).forEach(([G,X])=>V(G,X,!1)),Object.entries(J).forEach(([G,X])=>V(G,X,!0))},N7=function(W){const Q=new WeakMap;return(J,...V)=>{const G=Q.get(J);if(G!==void 0)return G;const X=W(J,...V);return Q.set(J,X),X}},C0=function(W,Q){const J=W%Q;return J>=K0?J:Q+J},$0=function(W,Q,J){let V=W;for(;Q-- >K0;)V*=V,V%=J;return V},v7=function(W,Q){if(W===K0)throw Error("invert: expected non-zero number");if(Q<=K0)throw Error("invert: expected positive modulus, got "+Q);let J=C0(W,Q),V=Q,G=K0,X=U0;for(;J!==K0;){const Y=V%J,q=G-X*(V/J);V=J,J=Y,G=X,X=q}if(V!==U0)throw Error("invert: does not exist");return C0(G,Q)},h6=function(W,Q,J){if(!W.eql(W.sqr(Q),J))throw Error("Cannot find square root")},YW=function(W,Q){const J=(W.ORDER+U0)/VW,V=W.pow(Q,J);return h6(W,V,Q),V},FV=function(W,Q){const J=(W.ORDER-GW)/XW,V=W.mul(Q,s0),G=W.pow(V,J),X=W.mul(Q,G),Y=W.mul(W.mul(X,s0),G),q=W.mul(X,W.sub(Y,W.ONE));return h6(W,q,Q),q},A7=function(W){if(W<QW)throw Error("sqrt is not defined for small field");let Q=W-U0,J=0;for(;Q%s0===K0;)Q/=s0,J++;let V=s0;const G=e1(W);for(;T7(G,V)===1;)if(V++>1000)throw Error("Cannot find square root: probably non-prime P");if(J===1)return YW;let X=G.pow(V,Q);const Y=(Q+U0)/s0;return function(q,F){if(q.is0(F))return F;if(T7(q,F)!==1)throw Error("Cannot find square root");let U=J,P=q.mul(q.ONE,X),C=q.pow(F,Q),K=q.pow(F,Y);for(;!q.eql(C,q.ONE);){if(q.is0(C))return q.ZERO;let z=1,$=q.sqr(C);for(;!q.eql($,q.ONE);)if(z++,$=q.sqr($),z===U)throw Error("Cannot find square root");const N=U0<<BigInt(U-z-1),g=q.pow(P,N);U=z,P=q.sqr(g),C=q.mul(C,P),K=q.mul(K,g)}return K}},zV=function(W){return W%VW===QW?YW:W%XW===GW?FV:W%S7===KV?function(Q){const J=e1(Q),V=A7(Q),G=V(J,J.neg(J.ONE)),X=V(J,G),Y=V(J,J.neg(G)),q=(Q+PV)/S7;return(F,U)=>{let P=F.pow(U,q),C=F.mul(P,G);const K=F.mul(P,X),z=F.mul(P,Y),$=F.eql(F.sqr(C),U),N=F.eql(F.sqr(K),U);P=F.cmov(P,C,$),C=F.cmov(z,K,N);const g=F.eql(F.sqr(C),U),p=F.cmov(P,C,g);return h6(F,p,U),p}}(W):A7(W)},qW=function(W,Q,J=!1){const V=Array(Q.length).fill(J?W.ZERO:void 0),G=Q.reduce((Y,q,F)=>W.is0(q)?Y:(V[F]=Y,W.mul(Y,q)),W.ONE),X=W.inv(G);return Q.reduceRight((Y,q,F)=>W.is0(q)?Y:(V[F]=W.mul(Y,V[F]),W.mul(Y,q)),X),V},T7=function(W,Q){const J=(W.ORDER-U0)/s0,V=W.pow(Q,J),G=W.eql(V,W.ONE),X=W.eql(V,W.ZERO),Y=W.eql(V,W.neg(W.ONE));if(!G&&!X&&!Y)throw Error("invalid Legendre symbol result");return G?1:X?0:-1},UW=function(W,Q){Q!==void 0&&O6(Q);const J=Q!==void 0?Q:W.toString(2).length;return{nBitLength:J,nByteLength:Math.ceil(J/8)}},e1=function(W,Q,J=!1,V={}){if(W<=K0)throw Error("invalid field: expected ORDER > 0, got "+W);let G,X,Y,q=!1;if(typeof Q=="object"&&Q!=null){if(V.sqrt||J)throw Error("cannot specify opts in two arguments");const K=Q;K.BITS&&(G=K.BITS),K.sqrt&&(X=K.sqrt),typeof K.isLE=="boolean"&&(J=K.isLE),typeof K.modFromBytes=="boolean"&&(q=K.modFromBytes),Y=K.allowedLengths}else typeof Q=="number"&&(G=Q),V.sqrt&&(X=V.sqrt);const{nBitLength:F,nByteLength:U}=UW(W,G);if(U>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let P;const C=Object.freeze({ORDER:W,isLE:J,BITS:F,BYTES:U,MASK:s1(F),ZERO:K0,ONE:U0,allowedLengths:Y,create(K){return C0(K,W)},isValid(K){if(typeof K!="bigint")throw Error("invalid field element: expected bigint, got "+typeof K);return K0<=K&&K<W},is0(K){return K===K0},isValidNot0(K){return!C.is0(K)&&C.isValid(K)},isOdd(K){return(K&U0)===U0},neg(K){return C0(-K,W)},eql(K,z){return K===z},sqr(K){return C0(K*K,W)},add(K,z){return C0(K+z,W)},sub(K,z){return C0(K-z,W)},mul(K,z){return C0(K*z,W)},pow(K,z){return function($,N,g){if(g<K0)throw Error("invalid exponent, negatives unsupported");if(g===K0)return $.ONE;if(g===U0)return N;let p=$.ONE,f=N;for(;g>K0;)g&U0&&(p=$.mul(p,f)),f=$.sqr(f),g>>=U0;return p}(C,K,z)},div(K,z){return C0(K*v7(z,W),W)},sqrN(K){return K*K},addN(K,z){return K+z},subN(K,z){return K-z},mulN(K,z){return K*z},inv(K){return v7(K,W)},sqrt:X||((K)=>(P||(P=zV(W)),P(C,K))),toBytes(K){return J?WW(K,U):g8(K,U)},fromBytes(K,z=!0){if(Y){if(!Y.includes(K.length)||K.length>U)throw Error("Field.fromBytes: expected "+Y+" bytes, got "+K.length);const N=new Uint8Array(U);N.set(K,J?0:N.length-K.length),K=N}if(K.length!==U)throw Error("Field.fromBytes: expected "+U+" bytes, got "+K.length);let $=J?t7(K):I1(K);if(q&&($=C0($,W)),!z&&!C.isValid($))throw Error("invalid field element: outside of range 0..ORDER");return $},invertBatch(K){return qW(C,K)},cmov(K,z,$){return $?z:K}});return Object.freeze(C)},PW=function(W){if(typeof W!="bigint")throw Error("field order must be bigint");const Q=W.toString(2).length;return Math.ceil(Q/8)},KW=function(W){const Q=PW(W);return Q+Math.ceil(Q/2)},FW=function(W,Q,J=!1){const V=W.length,G=PW(Q),X=KW(Q);if(V<16||V<X||V>1024)throw Error("expected "+X+"-1024 bytes of input, got "+V);const Y=C0(J?t7(W):I1(W),Q-U0)+U0;return J?WW(Y,G):g8(Y,G)},N8=function(W,Q){const J=Q.negate();return W?J:Q},j6=function(W,Q){const J=qW(W.Fp,Q.map((V)=>V.Z));return Q.map((V,G)=>W.fromAffine(V.toAffine(J[G])))},zW=function(W,Q){if(!Number.isSafeInteger(W)||W<=0||W>Q)throw Error("invalid window size, expected [1.."+Q+"], got W="+W)},B6=function(W,Q){zW(W,Q);const J=2**W;return{windows:Math.ceil(Q/W)+1,windowSize:2**(W-1),mask:s1(W),maxNumber:J,shiftBy:BigInt(W)}},g7=function(W,Q,J){const{windowSize:V,mask:G,maxNumber:X,shiftBy:Y}=J;let q=Number(W&G),F=W>>Y;q>V&&(q-=X,F+=e0);const U=Q*V;return{nextN:F,offset:U+Math.abs(q)-1,isZero:q===0,isNeg:q<0,isNegF:Q%2!=0,offsetF:U}},M6=function(W){return ZW.get(W)||1},E7=function(W){if(W!==M1)throw Error("invalid wNAF")},HV=function(W,Q,J,V){(function(K,z){if(!Array.isArray(K))throw Error("array expected");K.forEach(($,N)=>{if(!($ instanceof z))throw Error("invalid point at index "+N)})})(J,W),function(K,z){if(!Array.isArray(K))throw Error("array of scalars expected");K.forEach(($,N)=>{if(!z.isValid($))throw Error("invalid scalar at index "+N)})}(V,Q);const G=J.length,X=V.length;if(G!==X)throw Error("arrays of points and scalars must have equal length");const Y=W.ZERO,q=JW(BigInt(G));let F=1;q>12?F=q-3:q>4?F=q-2:q>0&&(F=2);const U=s1(F),P=Array(Number(U)+1).fill(Y);let C=Y;for(let K=Math.floor((Q.BITS-1)/F)*F;K>=0;K-=F){P.fill(Y);for(let $=0;$<X;$++){const N=V[$],g=Number(N>>BigInt(K)&U);P[g]=P[g].add(J[$])}let z=Y;for(let $=P.length-1,N=Y;$>0;$--)N=N.add(P[$]),z=z.add(N);if(C=C.add(z),K!==0)for(let $=0;$<F;$++)C=C.double()}return C},y7=function(W,Q,J){if(Q){if(Q.ORDER!==W)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return function(V){b6(V,ZV.reduce((G,X)=>(G[X]="function",G),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"}))}(Q),Q}return e1(W,{isLE:J})},S6=function(W){if(!["compact","recovered","der"].includes(W))throw Error('Signature format must be "compact", "recovered", or "der"');return W},L6=function(W,Q){const J={};for(let V of Object.keys(Q))J[V]=W[V]===void 0?Q[V]:W[V];return w8(J.lowS,"lowS"),w8(J.prehash,"prehash"),J.format!==void 0&&S6(J.format),J},a0=function(W,Q){const{BYTES:J}=W;let V;if(typeof Q=="bigint")V=Q;else{let G=Q0("private key",Q);try{V=W.fromBytes(G)}catch(X){throw Error(`invalid private key: expected ui8a of size ${J}, got ${typeof Q}`)}}if(!W.isValidNot0(V))throw Error("invalid private key: out of range [1..N-1]");return V},$V=function(W,Q={}){const J=function(Z,H,R={},k){if(k===void 0&&(k=Z==="edwards"),!H||typeof H!="object")throw Error(`expected valid ${Z} CURVE object`);for(let S of["p","n","h"]){const B=H[S];if(!(typeof B=="bigint"&&B>M1))throw Error(`CURVE.${S} must be positive bigint`)}const j=y7(H.p,R.Fp,k),D=y7(H.n,R.Fn,k),L=["Gx","Gy","a","b"];for(let S of L)if(!j.isValid(H[S]))throw Error(`CURVE.${S} must be valid field element of CURVE.Fp`);return{CURVE:H=Object.freeze(Object.assign({},H)),Fp:j,Fn:D}}("weierstrass",W,Q),{Fp:V,Fn:G}=J;let X=J.CURVE;const{h:Y,n:q}=X;b6(Q,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:F}=Q;if(F&&(!V.is0(X.a)||typeof F.beta!="bigint"||!Array.isArray(F.basises)))throw Error('invalid endo: expected "beta": bigint and "basises": array');const U=CW(V,G);function P(){if(!V.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}const C=Q.toBytes||function(Z,H,R){const{x:k,y:j}=H.toAffine(),D=V.toBytes(k);if(w8(R,"isCompressed"),R)return P(),D0($W(!V.isOdd(j)),D);return D0(Uint8Array.of(4),D,V.toBytes(j))},K=Q.fromBytes||function(Z){o0(Z,void 0,"Point");const{publicKey:H,publicKeyUncompressed:R}=U,k=Z.length,j=Z[0],D=Z.subarray(1);if(k!==H||j!==2&&j!==3){if(k===R&&j===4){const L=V.BYTES,S=V.fromBytes(D.subarray(0,L)),B=V.fromBytes(D.subarray(L,2*L));if(!$(S,B))throw Error("bad point: is not on curve");return{x:S,y:B}}throw Error(`bad point: got length ${k}, expected compressed=${H} or uncompressed=${R}`)}{const L=V.fromBytes(D);if(!V.isValid(L))throw Error("bad point: is not on curve, wrong x");const S=z(L);let B;try{B=V.sqrt(S)}catch(v){const b=v instanceof Error?": "+v.message:"";throw Error("bad point: is not on curve, sqrt error"+b)}return P(),!(1&~j)!==V.isOdd(B)&&(B=V.neg(B)),{x:L,y:B}}};function z(Z){const H=V.sqr(Z),R=V.mul(H,Z);return V.add(V.add(R,V.mul(Z,X.a)),X.b)}function $(Z,H){const R=V.sqr(H),k=z(Z);return V.eql(R,k)}if(!$(X.Gx,X.Gy))throw Error("bad curve params: generator point");const N=V.mul(V.pow(X.a,j8),kV),g=V.mul(V.sqr(X.b),BigInt(27));if(V.is0(V.add(N,g)))throw Error("bad curve params: a or b");function p(Z,H,R=!1){if(!V.isValid(H)||R&&V.is0(H))throw Error("bad point coordinate "+Z);return H}function f(Z){if(!(Z instanceof I))throw Error("ProjectivePoint expected")}function u(Z){if(!F||!F.basises)throw Error("no endo");return function(H,R,k){const[[j,D],[L,S]]=R,B=f7(S*H,k),v=f7(-D*H,k);let b=H-B*j-v*L,A=-B*D-v*S;const E=b<v0,o=A<v0;E&&(b=-b),o&&(A=-A);const i=s1(Math.ceil(JW(k)/2))+j1;if(b<v0||b>=i||A<v0||A>=i)throw Error("splitScalar (endomorphism): failed, k="+H);return{k1neg:E,k1:b,k2neg:o,k2:A}}(Z,F.basises,G.ORDER)}const x=N7((Z,H)=>{const{X:R,Y:k,Z:j}=Z;if(V.eql(j,V.ONE))return{x:R,y:k};const D=Z.is0();H==null&&(H=D?V.ONE:V.inv(j));const L=V.mul(R,H),S=V.mul(k,H),B=V.mul(j,H);if(D)return{x:V.ZERO,y:V.ZERO};if(!V.eql(B,V.ONE))throw Error("invZ was invalid");return{x:L,y:S}}),c=N7((Z)=>{if(Z.is0()){if(Q.allowInfinityPoint&&!V.is0(Z.Y))return;throw Error("bad point: ZERO")}const{x:H,y:R}=Z.toAffine();if(!V.isValid(H)||!V.isValid(R))throw Error("bad point: x or y not field elements");if(!$(H,R))throw Error("bad point: equation left != right");if(!Z.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function a(Z,H,R,k,j){return R=new I(V.mul(R.X,Z),R.Y,R.Z),H=N8(k,H),R=N8(j,R),H.add(R)}class I{constructor(Z,H,R){this.X=p("x",Z),this.Y=p("y",H,!0),this.Z=p("z",R),Object.freeze(this)}static CURVE(){return X}static fromAffine(Z){const{x:H,y:R}=Z||{};if(!Z||!V.isValid(H)||!V.isValid(R))throw Error("invalid affine point");if(Z instanceof I)throw Error("projective point not allowed");return V.is0(H)&&V.is0(R)?I.ZERO:new I(H,R,V.ONE)}static fromBytes(Z){const H=I.fromAffine(K(o0(Z,void 0,"point")));return H.assertValidity(),H}static fromHex(Z){return I.fromBytes(Q0("pointHex",Z))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(Z=8,H=!0){return w.createCache(this,Z),H||this.multiply(j8),this}assertValidity(){c(this)}hasEvenY(){const{y:Z}=this.toAffine();if(!V.isOdd)throw Error("Field doesn't support isOdd");return!V.isOdd(Z)}equals(Z){f(Z);const{X:H,Y:R,Z:k}=this,{X:j,Y:D,Z:L}=Z,S=V.eql(V.mul(H,L),V.mul(j,k)),B=V.eql(V.mul(R,L),V.mul(D,k));return S&&B}negate(){return new I(this.X,V.neg(this.Y),this.Z)}double(){const{a:Z,b:H}=X,R=V.mul(H,j8),{X:k,Y:j,Z:D}=this;let{ZERO:L,ZERO:S,ZERO:B}=V,v=V.mul(k,k),b=V.mul(j,j),A=V.mul(D,D),E=V.mul(k,j);return E=V.add(E,E),B=V.mul(k,D),B=V.add(B,B),L=V.mul(Z,B),S=V.mul(R,A),S=V.add(L,S),L=V.sub(b,S),S=V.add(b,S),S=V.mul(L,S),L=V.mul(E,L),B=V.mul(R,B),A=V.mul(Z,A),E=V.sub(v,A),E=V.mul(Z,E),E=V.add(E,B),B=V.add(v,v),v=V.add(B,v),v=V.add(v,A),v=V.mul(v,E),S=V.add(S,v),A=V.mul(j,D),A=V.add(A,A),v=V.mul(A,E),L=V.sub(L,v),B=V.mul(A,b),B=V.add(B,B),B=V.add(B,B),new I(L,S,B)}add(Z){f(Z);const{X:H,Y:R,Z:k}=this,{X:j,Y:D,Z:L}=Z;let{ZERO:S,ZERO:B,ZERO:v}=V;const b=X.a,A=V.mul(X.b,j8);let E=V.mul(H,j),o=V.mul(R,D),i=V.mul(k,L),r=V.add(H,R),O=V.add(j,D);r=V.mul(r,O),O=V.add(E,o),r=V.sub(r,O),O=V.add(H,k);let y=V.add(j,L);return O=V.mul(O,y),y=V.add(E,i),O=V.sub(O,y),y=V.add(R,k),S=V.add(D,L),y=V.mul(y,S),S=V.add(o,i),y=V.sub(y,S),v=V.mul(b,O),S=V.mul(A,i),v=V.add(S,v),S=V.sub(o,v),v=V.add(o,v),B=V.mul(S,v),o=V.add(E,E),o=V.add(o,E),i=V.mul(b,i),O=V.mul(A,O),o=V.add(o,i),i=V.sub(E,i),i=V.mul(b,i),O=V.add(O,i),E=V.mul(o,O),B=V.add(B,E),E=V.mul(y,O),S=V.mul(r,S),S=V.sub(S,E),E=V.mul(r,o),v=V.mul(y,v),v=V.add(v,E),new I(S,B,v)}subtract(Z){return this.add(Z.negate())}is0(){return this.equals(I.ZERO)}multiply(Z){const{endo:H}=Q;if(!G.isValidNot0(Z))throw Error("invalid scalar: out of range");let R,k;const j=(D)=>w.cached(this,D,(L)=>j6(I,L));if(H){const{k1neg:D,k1:L,k2neg:S,k2:B}=u(Z),{p:v,f:b}=j(L),{p:A,f:E}=j(B);k=b.add(E),R=a(H.beta,v,A,D,S)}else{const{p:D,f:L}=j(Z);R=D,k=L}return j6(I,[R,k])[0]}multiplyUnsafe(Z){const{endo:H}=Q,R=this;if(!G.isValid(Z))throw Error("invalid scalar: out of range");if(Z===v0||R.is0())return I.ZERO;if(Z===j1)return R;if(w.hasCache(this))return this.multiply(Z);if(H){const{k1neg:k,k1:j,k2neg:D,k2:L}=u(Z),{p1:S,p2:B}=function(v,b,A,E){let o=b,i=v.ZERO,r=v.ZERO;for(;A>M1||E>M1;)A&e0&&(i=i.add(o)),E&e0&&(r=r.add(o)),o=o.double(),A>>=e0,E>>=e0;return{p1:i,p2:r}}(I,R,j,L);return a(H.beta,S,B,k,D)}return w.unsafe(R,Z)}multiplyAndAddUnsafe(Z,H,R){const k=this.multiplyUnsafe(H).add(Z.multiplyUnsafe(R));return k.is0()?void 0:k}toAffine(Z){return x(this,Z)}isTorsionFree(){const{isTorsionFree:Z}=Q;return Y===j1||(Z?Z(I,this):w.unsafe(this,q).is0())}clearCofactor(){const{clearCofactor:Z}=Q;return Y===j1?this:Z?Z(I,this):this.multiplyUnsafe(Y)}isSmallOrder(){return this.multiplyUnsafe(Y).is0()}toBytes(Z=!0){return w8(Z,"isCompressed"),this.assertValidity(),C(I,this,Z)}toHex(Z=!0){return R1(this.toBytes(Z))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(Z=!0){return this.toBytes(Z)}_setWindowSize(Z){this.precompute(Z)}static normalizeZ(Z){return j6(I,Z)}static msm(Z,H){return HV(I,G,Z,H)}static fromPrivateKey(Z){return I.BASE.multiply(a0(G,Z))}}I.BASE=new I(X.Gx,X.Gy,V.ONE),I.ZERO=new I(V.ZERO,V.ONE,V.ZERO),I.Fp=V,I.Fn=G;const M=G.BITS,w=new HW(I,Q.endo?Math.ceil(M/2):M);return I.BASE.precompute(8),I},$W=function(W){return Uint8Array.of(W?2:3)},CW=function(W,Q){return{secretKey:Q.BYTES,publicKey:1+W.BYTES,publicKeyUncompressed:1+2*W.BYTES,publicKeyHasPrefix:!0,signature:2*Q.BYTES}},CV=function(W,Q,J={}){i7(Q),b6(J,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const V=J.randomBytes||x8,G=J.hmac||((M,...w)=>s7(Q,M,D0(...w))),{Fp:X,Fn:Y}=W,{ORDER:q,BITS:F}=Y,{keygen:U,getPublicKey:P,getSharedSecret:C,utils:K,lengths:z}=function(M,w={}){const{Fn:Z}=M,H=w.randomBytes||x8,R=Object.assign(CW(M.Fp,Z),{seed:KW(Z.ORDER)});function k(B){try{return!!a0(Z,B)}catch(v){return!1}}function j(B=H(R.seed)){return FW(o0(B,R.seed,"seed"),Z.ORDER)}function D(B,v=!0){return M.BASE.multiply(a0(Z,B)).toBytes(v)}function L(B){if(typeof B=="bigint")return!1;if(B instanceof M)return!0;const{secretKey:v,publicKey:b,publicKeyUncompressed:A}=R;if(Z.allowedLengths||v===b)return;const E=Q0("key",B).length;return E===b||E===A}return Object.freeze({getPublicKey:D,getSharedSecret(B,v,b=!0){if(L(B)===!0)throw Error("first arg must be private key");if(L(v)===!1)throw Error("second arg must be public key");const A=a0(Z,B);return M.fromHex(v).multiply(A).toBytes(b)},keygen(B){const v=j(B);return{secretKey:v,publicKey:D(v)}},Point:M,utils:{isValidSecretKey:k,isValidPublicKey(B,v){const{publicKey:b,publicKeyUncompressed:A}=R;try{const E=B.length;return!(v===!0&&E!==b||v===!1&&E!==A||!M.fromBytes(B))}catch(E){return!1}},randomSecretKey:j,isValidPrivateKey:k,randomPrivateKey:j,normPrivateKeyToScalar:(B)=>a0(Z,B),precompute(B=8,v=M.BASE){return v.precompute(B,!1)}},lengths:R})}(W,J),$={prehash:!1,lowS:typeof J.lowS=="boolean"&&J.lowS,format:void 0,extraEntropy:!1},N="compact";function g(M){return M>q>>j1}function p(M,w){if(!Y.isValidNot0(w))throw Error(`invalid signature ${M}: out of range 1..Point.Fn.ORDER`);return w}class f{constructor(M,w,Z){this.r=p("r",M),this.s=p("s",w),Z!=null&&(this.recovery=Z),Object.freeze(this)}static fromBytes(M,w=N){let Z;if(function(j,D){S6(D);const L=z.signature;o0(j,D==="compact"?L:D==="recovered"?L+1:void 0,D+" signature")}(M,w),w==="der"){const{r:j,s:D}=S0.toSig(o0(M));return new f(j,D)}w==="recovered"&&(Z=M[0],w="compact",M=M.subarray(1));const H=Y.BYTES,R=M.subarray(0,H),k=M.subarray(H,2*H);return new f(Y.fromBytes(R),Y.fromBytes(k),Z)}static fromHex(M,w){return this.fromBytes(O8(M),w)}addRecoveryBit(M){return new f(this.r,this.s,M)}recoverPublicKey(M){const w=X.ORDER,{r:Z,s:H,recovery:R}=this;if(R==null||![0,1,2,3].includes(R))throw Error("recovery id invalid");if(q*kW<w&&R>1)throw Error("recovery id is ambiguous for h>1 curve");const k=R===2||R===3?Z+q:Z;if(!X.isValid(k))throw Error("recovery id 2 or 3 invalid");const j=X.toBytes(k),D=W.fromBytes(D0($W(!(1&R)),j)),L=Y.inv(k),S=x(Q0("msgHash",M)),B=Y.create(-S*L),v=Y.create(H*L),b=W.BASE.multiplyUnsafe(B).add(D.multiplyUnsafe(v));if(b.is0())throw Error("point at infinify");return b.assertValidity(),b}hasHighS(){return g(this.s)}toBytes(M=N){if(S6(M),M==="der")return O8(S0.hexFromSig(this));const w=Y.toBytes(this.r),Z=Y.toBytes(this.s);if(M==="recovered"){if(this.recovery==null)throw Error("recovery bit must be present");return D0(Uint8Array.of(this.recovery),w,Z)}return D0(w,Z)}toHex(M){return R1(this.toBytes(M))}assertValidity(){}static fromCompact(M){return f.fromBytes(Q0("sig",M),"compact")}static fromDER(M){return f.fromBytes(Q0("sig",M),"der")}normalizeS(){return this.hasHighS()?new f(this.r,Y.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return R1(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return R1(this.toBytes("compact"))}}const u=J.bits2int||function(M){if(M.length>8192)throw Error("input is too large");const w=I1(M),Z=8*M.length-F;return Z>0?w>>BigInt(Z):w},x=J.bits2int_modN||function(M){return Y.create(u(M))},c=s1(F);function a(M){return function(w,Z,H,R){if(!N6(Z,H,R))throw Error("expected valid "+w+": "+H+" <= n < "+R+", got "+Z)}("num < 2^"+F,M,v0,c),Y.toBytes(M)}function I(M,w){return o0(M,void 0,"message"),w?o0(Q(M),void 0,"prehashed message"):M}return Object.freeze({keygen:U,getPublicKey:P,getSharedSecret:C,utils:K,lengths:z,Point:W,sign(M,w,Z={}){M=Q0("message",M);const{seed:H,k2sig:R}=function(k,j,D){if(["recovered","canonical"].some((i)=>(i in D)))throw Error("sign() legacy options not supported");const{lowS:L,prehash:S,extraEntropy:B}=L6(D,$);k=I(k,S);const v=x(k),b=a0(Y,j),A=[a(b),a(v)];if(B!=null&&B!==!1){const i=B===!0?V(z.secretKey):B;A.push(Q0("extraEntropy",i))}const E=D0(...A),o=v;return{seed:E,k2sig(i){const r=u(i);if(!Y.isValidNot0(r))return;const O=Y.inv(r),y=W.BASE.multiply(r).toAffine(),m=Y.create(y.x);if(m===v0)return;const d=Y.create(O*Y.create(o+m*b));if(d===v0)return;let T=(y.x===m?0:2)|Number(y.y&j1),_=d;return L&&g(d)&&(_=Y.neg(d),T^=1),new f(m,_,T)}}}(M,w,Z);return function(k,j,D){if(typeof k!="number"||k<2)throw Error("hashLen must be a number");if(typeof j!="number"||j<2)throw Error("qByteLen must be a number");if(typeof D!="function")throw Error("hmacFn must be a function");const L=(r)=>new Uint8Array(r),S=(r)=>Uint8Array.of(r);let B=L(k),v=L(k),b=0;const A=()=>{B.fill(1),v.fill(0),b=0},E=(...r)=>D(v,B,...r),o=(r=L(0))=>{v=E(S(0),r),B=E(),r.length!==0&&(v=E(S(1),r),B=E())},i=()=>{if(b++>=1000)throw Error("drbg: tried 1000 values");let r=0;const O=[];for(;r<j;){B=E();const y=B.slice();O.push(y),r+=B.length}return D0(...O)};return(r,O)=>{let y;for(A(),o(r);!(y=O(i()));)o();return A(),y}}(Q.outputLen,Y.BYTES,G)(H,R)},verify(M,w,Z,H={}){const{lowS:R,prehash:k,format:j}=L6(H,$);if(Z=Q0("publicKey",Z),w=I(Q0("message",w),k),("strict"in H))throw Error("options.strict was renamed to lowS");const D=j===void 0?function(L){let S;const B=typeof L=="string"||T8(L),v=!B&&L!==null&&typeof L=="object"&&typeof L.r=="bigint"&&typeof L.s=="bigint";if(!B&&!v)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(v)S=new f(L.r,L.s);else if(B){try{S=f.fromBytes(Q0("sig",L),"der")}catch(b){if(!(b instanceof S0.Err))throw b}if(!S)try{S=f.fromBytes(Q0("sig",L),"compact")}catch(b){return!1}}return S||!1}(M):f.fromBytes(Q0("sig",M),j);if(D===!1)return!1;try{const L=W.fromBytes(Z);if(R&&D.hasHighS())return!1;const{r:S,s:B}=D,v=x(w),b=Y.inv(B),A=Y.create(v*b),E=Y.create(S*b),o=W.BASE.multiplyUnsafe(A).add(L.multiplyUnsafe(E));if(o.is0())return!1;return Y.create(o.x)===S}catch(L){return!1}},recoverPublicKey(M,w,Z={}){const{prehash:H}=L6(Z,$);return w=I(w,H),f.fromBytes(M,"recovered").recoverPublicKey(w).toBytes()},Signature:f,hash:Q})},jV=function(W){const{CURVE:Q,curveOpts:J}=function(G){const X={a:G.a,b:G.b,p:G.Fp.ORDER,n:G.n,h:G.h,Gx:G.Gx,Gy:G.Gy},Y=G.Fp;let q=G.allowedPrivateKeyLengths?Array.from(new Set(G.allowedPrivateKeyLengths.map((F)=>Math.ceil(F/2)))):void 0;return{CURVE:X,curveOpts:{Fp:Y,Fn:e1(X.n,{BITS:G.nBitLength,allowedLengths:q,modFromBytes:G.wrapPrivateKey}),allowInfinityPoint:G.allowInfinityPoint,endo:G.endo,isTorsionFree:G.isTorsionFree,clearCofactor:G.clearCofactor,fromBytes:G.fromBytes,toBytes:G.toBytes}}}(W),V={hmac:W.hmac,randomBytes:W.randomBytes,lowS:W.lowS,bits2int:W.bits2int,bits2int_modN:W.bits2int_modN};return{CURVE:Q,curveOpts:J,hash:W.hash,ecdsaOpts:V}},BV=function(W){const{CURVE:Q,curveOpts:J,hash:V,ecdsaOpts:G}=jV(W);return function(X,Y){const q=Y.Point;return Object.assign({},Y,{ProjectivePoint:q,CURVE:Object.assign({},X,UW(q.Fn.ORDER,q.Fn.BITS))})}(W,CV($V(Q,J),V,G))},v8=function(W,...Q){let J=b7[W];if(J===void 0){const V=x6(n7(W));J=D0(V,V),b7[W]=J}return x6(D0(J,...Q))},A6=function(W){const{Fn:Q,BASE:J}=D1,V=a0(Q,W),G=J.multiply(V);return{scalar:m6(G.y)?V:Q.neg(V),bytes:u6(G)}},BW=function(W){const Q=S8;if(!Q.isValidNot0(W))throw Error("invalid x: Fail if x \u2265 p");const J=Q.create(W*W),V=Q.create(J*W+BigInt(7));let G=Q.sqrt(V);m6(G)||(G=Q.neg(G));const X=D1.fromAffine({x:W,y:G});return X.assertValidity(),X},RW=function(...W){return D1.Fn.create(a1(v8("BIP0340/challenge",...W)))},h7=function(W){return A6(W).bytes},LV=function(W,Q,J=x8(32)){const{Fn:V}=D1,G=Q0("message",W),{bytes:X,scalar:Y}=A6(Q),q=Q0("auxRand",J,32),F=V.toBytes(Y^a1(v8("BIP0340/aux",q))),U=v8("BIP0340/nonce",F,X,G),{bytes:P,scalar:C}=A6(U),K=RW(P,X,G),z=new Uint8Array(64);if(z.set(P,0),z.set(V.toBytes(V.create(C+K*Y)),32),!MW(z,G,X))throw Error("sign: Invalid signature produced");return z},MW=function(W,Q,J){const{Fn:V,BASE:G}=D1,X=Q0("signature",W,64),Y=Q0("message",Q),q=Q0("publicKey",J,32);try{const F=BW(a1(q)),U=a1(X.subarray(0,32));if(!N6(U,p7,L1.p))return!1;const P=a1(X.subarray(32,64));if(!N6(P,p7,L1.n))return!1;const C=RW(V.toBytes(U),u6(F),Y),K=G.multiplyUnsafe(P).add(F.multiplyUnsafe(V.neg(C))),{x:z,y:$}=K.toAffine();return!(K.is0()||!m6($)||z!==U)}catch(F){return!1}},k1=typeof globalThis=="object"&&("crypto"in globalThis)?globalThis.crypto:void 0,r7=(()=>typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function")(),QV=Array.from({length:256},(W,Q)=>Q.toString(16).padStart(2,"0")),D7=48,VV=57,O7=65,GV=70,x7=97,XV=102;class y6{}class o7 extends y6{constructor(W,Q,J,V){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=W,this.outputLen=Q,this.padOffset=J,this.isLE=V,this.buffer=new Uint8Array(W),this.view=$6(this.buffer)}update(W){I8(this),W1(W=E6(W));const{view:Q,buffer:J,blockLen:V}=this,G=W.length;for(let X=0;X<G;){const Y=Math.min(V-this.pos,G-X);if(Y!==V)J.set(W.subarray(X,X+Y),this.pos),this.pos+=Y,X+=Y,this.pos===V&&(this.process(Q,0),this.pos=0);else{const q=$6(W);for(;V<=G-X;X+=V)this.process(q,X)}}return this.length+=W.length,this.roundClean(),this}digestInto(W){I8(this),function(P,C){W1(P);const K=C.outputLen;if(P.length<K)throw Error("digestInto() expects output buffer of length at least "+K)}(W,this),this.finished=!0;const{buffer:Q,view:J,blockLen:V,isLE:G}=this;let{pos:X}=this;Q[X++]=128,D8(this.buffer.subarray(X)),this.padOffset>V-X&&(this.process(J,0),X=0);for(let P=X;P<V;P++)Q[P]=0;(function(P,C,K,z){if(typeof P.setBigUint64=="function")return P.setBigUint64(C,K,z);const $=BigInt(32),N=BigInt(4294967295),g=Number(K>>$&N),p=Number(K&N),f=z?4:0,u=z?0:4;P.setUint32(C+f,g,z),P.setUint32(C+u,p,z)})(J,V-8,BigInt(8*this.length),G),this.process(J,0);const Y=$6(W),q=this.outputLen;if(q%4)throw Error("_sha2: outputLen should be aligned to 32bit");const F=q/4,U=this.get();if(F>U.length)throw Error("_sha2: outputLen bigger than state");for(let P=0;P<F;P++)Y.setUint32(4*P,U[P],G)}digest(){const{buffer:W,outputLen:Q}=this;this.digestInto(W);const J=W.slice(0,Q);return this.destroy(),J}_cloneInto(W){W||(W=new this.constructor),W.set(...this.get());const{blockLen:Q,buffer:J,length:V,finished:G,destroyed:X,pos:Y}=this;return W.destroyed=X,W.finished=G,W.length=V,W.pos=Y,V%Q&&W.buffer.set(J),W}clone(){return this._cloneInto()}}var b0=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),UV=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),h0=new Uint32Array(64);class a7 extends o7{constructor(W=32){super(64,W,8,!1),this.A=0|b0[0],this.B=0|b0[1],this.C=0|b0[2],this.D=0|b0[3],this.E=0|b0[4],this.F=0|b0[5],this.G=0|b0[6],this.H=0|b0[7]}get(){const{A:W,B:Q,C:J,D:V,E:G,F:X,G:Y,H:q}=this;return[W,Q,J,V,G,X,Y,q]}set(W,Q,J,V,G,X,Y,q){this.A=0|W,this.B=0|Q,this.C=0|J,this.D=0|V,this.E=0|G,this.F=0|X,this.G=0|Y,this.H=0|q}process(W,Q){for(let C=0;C<16;C++,Q+=4)h0[C]=W.getUint32(Q,!1);for(let C=16;C<64;C++){const K=h0[C-15],z=h0[C-2],$=I0(K,7)^I0(K,18)^K>>>3,N=I0(z,17)^I0(z,19)^z>>>10;h0[C]=N+h0[C-7]+$+h0[C-16]|0}let{A:J,B:V,C:G,D:X,E:Y,F:q,G:F,H:U}=this;for(let C=0;C<64;C++){const K=U+(I0(Y,6)^I0(Y,11)^I0(Y,25))+((P=Y)&q^~P&F)+UV[C]+h0[C]|0,z=(I0(J,2)^I0(J,13)^I0(J,22))+qV(J,V,G)|0;U=F,F=q,q=Y,Y=X+K|0,X=G,G=V,V=J,J=K+z|0}var P;J=J+this.A|0,V=V+this.B|0,G=G+this.C|0,X=X+this.D|0,Y=Y+this.E|0,q=q+this.F|0,F=F+this.G|0,U=U+this.H|0,this.set(J,V,G,X,Y,q,F,U)}roundClean(){D8(h0)}destroy(){this.set(0,0,0,0,0,0,0,0),D8(this.buffer)}}var x6=YV(()=>new a7);class f6 extends y6{constructor(W,Q){super(),this.finished=!1,this.destroyed=!1,i7(W);const J=E6(Q);if(this.iHash=W.create(),typeof this.iHash.update!="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const V=this.blockLen,G=new Uint8Array(V);G.set(J.length>V?W.create().update(J).digest():J);for(let X=0;X<G.length;X++)G[X]^=54;this.iHash.update(G),this.oHash=W.create();for(let X=0;X<G.length;X++)G[X]^=106;this.oHash.update(G),D8(G)}update(W){return I8(this),this.iHash.update(W),this}digestInto(W){I8(this),W1(W,this.outputLen),this.finished=!0,this.iHash.digestInto(W),this.oHash.update(W),this.oHash.digestInto(W),this.destroy()}digest(){const W=new Uint8Array(this.oHash.outputLen);return this.digestInto(W),W}_cloneInto(W){W||(W=Object.create(Object.getPrototypeOf(this),{}));const{oHash:Q,iHash:J,finished:V,destroyed:G,blockLen:X,outputLen:Y}=this;return W.finished=V,W.destroyed=G,W.blockLen=X,W.outputLen=Y,W.oHash=Q._cloneInto(W.oHash),W.iHash=J._cloneInto(W.iHash),W}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var s7=(W,Q,J)=>new f6(W,Q).update(J).digest();s7.create=(W,Q)=>new f6(W,Q);var p6=BigInt(0),w6=BigInt(1),C6=(W)=>typeof W=="bigint"&&p6<=W,s1=(W)=>(w6<<BigInt(W))-w6,K0=BigInt(0),U0=BigInt(1),s0=BigInt(2),QW=BigInt(3),VW=BigInt(4),GW=BigInt(5),PV=BigInt(7),XW=BigInt(8),KV=BigInt(9),S7=BigInt(16),ZV=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"],M1=BigInt(0),e0=BigInt(1),R6=new WeakMap,ZW=new WeakMap;class HW{constructor(W,Q){this.BASE=W.BASE,this.ZERO=W.ZERO,this.Fn=W.Fn,this.bits=Q}_unsafeLadder(W,Q,J=this.ZERO){let V=W;for(;Q>M1;)Q&e0&&(J=J.add(V)),V=V.double(),Q>>=e0;return J}precomputeWindow(W,Q){const{windows:J,windowSize:V}=B6(Q,this.bits),G=[];let X=W,Y=X;for(let q=0;q<J;q++){Y=X,G.push(Y);for(let F=1;F<V;F++)Y=Y.add(X),G.push(Y);X=Y.double()}return G}wNAF(W,Q,J){if(!this.Fn.isValid(J))throw Error("invalid scalar");let V=this.ZERO,G=this.BASE;const X=B6(W,this.bits);for(let Y=0;Y<X.windows;Y++){const{nextN:q,offset:F,isZero:U,isNeg:P,isNegF:C,offsetF:K}=g7(J,Y,X);J=q,U?G=G.add(N8(C,Q[K])):V=V.add(N8(P,Q[F]))}return E7(J),{p:V,f:G}}wNAFUnsafe(W,Q,J,V=this.ZERO){const G=B6(W,this.bits);for(let X=0;X<G.windows&&J!==M1;X++){const{nextN:Y,offset:q,isZero:F,isNeg:U}=g7(J,X,G);if(J=Y,!F){const P=Q[q];V=V.add(U?P.negate():P)}}return E7(J),V}getPrecomputes(W,Q,J){let V=R6.get(Q);return V||(V=this.precomputeWindow(Q,W),W!==1&&(typeof J=="function"&&(V=J(V)),R6.set(Q,V))),V}cached(W,Q,J){const V=M6(W);return this.wNAF(V,this.getPrecomputes(V,W,J),Q)}unsafe(W,Q,J,V){const G=M6(W);return G===1?this._unsafeLadder(W,Q,V):this.wNAFUnsafe(G,this.getPrecomputes(G,W,J),Q,V)}createCache(W,Q){zW(Q,this.bits),ZW.set(W,Q),R6.delete(W)}hasCache(W){return M6(W)!==1}}var f7=(W,Q)=>(W+(W>=0?Q:-Q)/kW)/Q,S0={Err:class extends Error{constructor(W=""){super(W)}},_tlv:{encode(W,Q){const{Err:J}=S0;if(W<0||W>256)throw new J("tlv.encode: wrong tag");if(1&Q.length)throw new J("tlv.encode: unpadded data");const V=Q.length/2,G=C8(V);if(G.length/2&128)throw new J("tlv.encode: long form length too big");const X=V>127?C8(G.length/2|128):"";return C8(W)+X+G+Q},decode(W,Q){const{Err:J}=S0;let V=0;if(W<0||W>256)throw new J("tlv.encode: wrong tag");if(Q.length<2||Q[V++]!==W)throw new J("tlv.decode: wrong tlv");const G=Q[V++];let X=0;if(128&G){const q=127&G;if(!q)throw new J("tlv.decode(long): indefinite length not supported");if(q>4)throw new J("tlv.decode(long): byte length is too big");const F=Q.subarray(V,V+q);if(F.length!==q)throw new J("tlv.decode: length bytes not complete");if(F[0]===0)throw new J("tlv.decode(long): zero leftmost byte");for(let U of F)X=X<<8|U;if(V+=q,X<128)throw new J("tlv.decode(long): not minimal encoding")}else X=G;const Y=Q.subarray(V,V+X);if(Y.length!==X)throw new J("tlv.decode: wrong value length");return{v:Y,l:Q.subarray(V+X)}}},_int:{encode(W){const{Err:Q}=S0;if(W<v0)throw new Q("integer: negative integers are not allowed");let J=C8(W);if(8&Number.parseInt(J[0],16)&&(J="00"+J),1&J.length)throw new Q("unexpected DER parsing assertion: unpadded hex");return J},decode(W){const{Err:Q}=S0;if(128&W[0])throw new Q("invalid signature integer: negative");if(W[0]===0&&!(128&W[1]))throw new Q("invalid signature integer: unnecessary leading zero");return I1(W)}},toSig(W){const{Err:Q,_int:J,_tlv:V}=S0,G=Q0("signature",W),{v:X,l:Y}=V.decode(48,G);if(Y.length)throw new Q("invalid signature: left bytes after parsing");const{v:q,l:F}=V.decode(2,X),{v:U,l:P}=V.decode(2,F);if(P.length)throw new Q("invalid signature: left bytes after parsing");return{r:J.decode(q),s:J.decode(U)}},hexFromSig(W){const{_tlv:Q,_int:J}=S0,V=Q.encode(2,J.encode(W.r))+Q.encode(2,J.encode(W.s));return Q.encode(48,V)}},v0=BigInt(0),j1=BigInt(1),kW=BigInt(2),j8=BigInt(3),kV=BigInt(4),L1={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},RV={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},MV=BigInt(0),p7=BigInt(1),v6=BigInt(2),S8=e1(L1.p,{sqrt(W){const Q=L1.p,J=BigInt(3),V=BigInt(6),G=BigInt(11),X=BigInt(22),Y=BigInt(23),q=BigInt(44),F=BigInt(88),U=W*W*W%Q,P=U*U*W%Q,C=$0(P,J,Q)*P%Q,K=$0(C,J,Q)*P%Q,z=$0(K,v6,Q)*U%Q,$=$0(z,G,Q)*z%Q,N=$0($,X,Q)*$%Q,g=$0(N,q,Q)*N%Q,p=$0(g,F,Q)*g%Q,f=$0(p,q,Q)*N%Q,u=$0(f,J,Q)*P%Q,x=$0(u,Y,Q)*$%Q,c=$0(x,V,Q)*U%Q,a=$0(c,v6,Q);if(!S8.eql(S8.sqr(a),W))throw Error("Cannot find square root");return a}}),jW=function(W,Q){const J=(V)=>BV({...W,hash:V});return{...J(Q),create:J}}({...L1,Fp:S8,lowS:!0,endo:RV},x6),b7={},u6=(W)=>W.toBytes(!0).slice(1),D1=(()=>jW.Point)(),m6=(W)=>W%v6===MV,a1=I1,_6=(()=>{const W=(Q=x8(48))=>FW(Q,L1.n);return jW.utils.randomSecretKey,{keygen(Q){const J=W(Q);return{secretKey:J,publicKey:h7(J)}},getPublicKey:h7,sign:LV,verify:MW,Point:D1,utils:{randomSecretKey:W,randomPrivateKey:W,taggedHash:v8,lift_x:BW,pointToBytes:u6,numberToBytesBE:g8,bytesToNumberBE:I1,mod:C0},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),IV=new TextEncoder,DV=new TextDecoder,t0=(W)=>IV.encode(W),o1=(W)=>DV.decode(W),T6=(W)=>Array.from(W,(Q)=>Q.toString(16).padStart(2,"0")).join(""),A0=JSON.stringify,A8=JSON.parse,LW=(W,Q=Number.MAX_SAFE_INTEGER)=>W.split("").reduce((J,V)=>J+V.charCodeAt(0),0)%Q,c6="AES-GCM",OV={},B8=(W)=>OV[W]??=crypto.subtle.digest("SHA-1",t0(W)).then((Q)=>{const J=new Uint8Array(Q);let V="";for(let G of J)V+=G.toString(36);return V}),xV=async(W,Q)=>{const J=crypto.getRandomValues(new Uint8Array(12)),V=await W,G=await crypto.subtle.encrypt({name:c6,iv:J},V,t0(Q));return`${J.join(",")}\$${((X)=>{const Y=new Uint8Array(X);let q="";for(let F=0;F<Y.length;F+=32768)q+=String.fromCharCode(...Y.subarray(F,F+32768));return btoa(q)})(G)}`},wV=async(W,Q)=>{const[J,V]=Q.split("$");if(!J||!V)throw Error("Invalid encrypted payload format");const G=Uint8Array.from(J.split(","),Number),X=await W,Y=await crypto.subtle.decrypt({name:c6,iv:G},X,(q=V,Uint8Array.from(atob(q),(F)=>F.charCodeAt(0)).buffer));var q;return o1(Y)},Z0="GenosRTC",d6=(W,Q)=>Array.from({length:W},Q),NV="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz",g6=(W)=>Array.from(crypto.getRandomValues(new Uint8Array(W)),(Q)=>NV[Q%62]).join(""),$1=g6(20),B1=Promise.all.bind(Promise),SV=typeof window!="undefined",{entries:vV,fromEntries:IW}=Object,AV=()=>{},N0=(W)=>Error(`${Z0}: ${W}`),R8=(...W)=>W.join("@"),u7="icegatheringstatechange",m7="offer",TV=[...d6(3,(W,Q)=>`stun:stun${Q||""}.l.google.com:19302`),"stun:stun.cloudflare.com:3478"].map((W)=>({urls:W})),I6=(W,{rtcConfig:Q,rtcPolyfill:J,turnConfig:V})=>{const G=new(J||RTCPeerConnection)({iceServers:[...TV,...V||[]],...Q}),X={};let Y,q=!1,F=!1;const U=(K)=>Object.assign(K,{binaryType:"arraybuffer",bufferedAmountLowThreshold:65535,onmessage(z){return X.data?.(z.data)},onopen(){return X.connect?.()},onclose(){return X.close?.()},onerror(z){return!z?.error?.message?.includes("User-Initiated Abort")&&X.error?.(z)}}),P=()=>Promise.race([new Promise((K)=>{const z=()=>{G.iceGatheringState==="complete"&&(G.removeEventListener(u7,z),K())};G.addEventListener(u7,z),z()}),new Promise((K)=>setTimeout(K,5000))]).then(()=>({type:G.localDescription.type,sdp:G.localDescription.sdp.replace(/a=ice-options:trickle\s\n/g,"")}));W?U(Y=G.createDataChannel("data")):G.ondatachannel=({channel:K})=>U(Y=K),G.onnegotiationneeded=async()=>{try{q=!0,await G.setLocalDescription(),X.signal?.(await P())}catch(K){X.error?.(K)}finally{q=!1}},G.onconnectionstatechange=()=>{["disconnected","failed","closed"].includes(G.connectionState)&&X.close?.()},G.ontrack=(K)=>{X.track?.(K.track,K.streams[0]),X.stream?.(K.streams[0])},G.onremovestream=(K)=>X.stream?.(K.stream),W&&!G.canTrickleIceCandidates&&G.onnegotiationneeded();const C=()=>G.getSenders();return{created:Date.now(),connection:G,get channel(){return Y},get isDead(){return G.connectionState==="closed"},async signal(K){if(Y?.readyState!=="open"||K.sdp?.includes("a=rtpmap"))try{if(K.type===m7){if(q||G.signalingState!=="stable"&&!F){if(W)return;await B1([G.setLocalDescription({type:"rollback"}),G.setRemoteDescription(K)])}else await G.setRemoteDescription(K);await G.setLocalDescription();const z=await P();return X.signal?.(z),z}if(K.type==="answer"){F=!0;try{await G.setRemoteDescription(K)}finally{F=!1}}}catch(z){X.error?.(z)}},sendData(K){return Y.send(K)},destroy(){Y?.close(),G.close(),q=F=!1},setHandlers(K){return Object.assign(X,K)},offerPromise:W?new Promise((K)=>X.signal=(z)=>z.type===m7&&K(z)):Promise.resolve(),addStream(K){return K.getTracks().forEach((z)=>G.addTrack(z,K))},removeStream(K){return C().filter((z)=>K.getTracks().includes(z.track)).forEach((z)=>G.removeTrack(z))},addTrack(K,z){return G.addTrack(K,z)},removeTrack(K){const z=C().find(($)=>$.track===K);z&&G.removeTrack(z)},replaceTrack(K,z){return C().find(($)=>$.track===K)?.replaceTrack(z)}}},gV=Object.getPrototypeOf(Uint8Array),r1=16369,M8=255,D6="bufferedamountlow",C1=(W)=>"@_"+W,EV=(W,Q,J)=>{const V=new Map,G=new Map,X=new Map,Y={},q={},F={},U={},P=new Map,C=(k,...j)=>P.get(k)?.forEach((D)=>D(...j)),K=(k,j)=>{const D=k?Array.isArray(k)?k:[k]:V.keys();return Array.from(D,(L)=>{const S=V.get(L);return S?j(L,S):(console.warn(`${Z0}: no peer with id ${L}`),null)}).filter(Boolean)},z=(k)=>{V.has(k)&&(V.delete(k),delete Y[k],delete q[k],delete F[k],delete U[k],C("peer:leave",k),Q(k))},$=(k)=>new Promise((j,D)=>{let L=setTimeout(()=>{k.removeEventListener(D6,S),D(Error(Z0+": bufferLow timeout"))},5000);function S(){clearTimeout(L),k.removeEventListener(D6,S),j()}k.addEventListener(D6,S)}),N=(k)=>{if(X.has(k))return X.get(k);if(!k)throw N0("action type is required");const j=t0(k);if(j.byteLength>12)throw N0(`"${k}" exceeds 12 bytes`);const D=new Uint8Array(12).map((b,A)=>j[A]||0);let L=0;const S=new Map([["message",new Set],["progress",new Set]]),B=async(b,A,E,o)=>{if(E&&typeof E!="object")throw N0("meta must be object");if(b===void 0)throw N0("data cannot be undefined");const i=b instanceof Blob,r=i||b instanceof ArrayBuffer||b instanceof gV,O=typeof b!="string";if(E&&!r)throw N0("meta only allowed with binary");const y=r?new Uint8Array(i?await b.arrayBuffer():b):t0(O?A0(b):b),m=E?t0(A0(E)):null,d=Math.ceil(y.byteLength/r1)+(E?1:0)||1;if(d>100)throw N0("Message too large, exceeds max chunks 100");const T=d6(d,(_,h)=>{const n=h===d-1,l=E&&h===0,G0=l?m:y.subarray(E?(h-1)*r1:h*r1,E?h*r1:(h+1)*r1),t=new Uint8Array(15+G0.byteLength);return t.set(D),t.set([L],12),t.set([n|l<<1|r<<2|O<<3],13),t.set([Math.round((h+1)/d*M8)],14),t.set(G0,15),t});return L=L+1&M8,B1(K(A,async(_,h)=>{const{channel:n}=h;for(let l=0;l<d;l++){let G0=0;for(;n.bufferedAmount>n.bufferedAmountLowThreshold;){if(G0++>3)throw N0(`${Z0}: send buffer full, max retries reached for peer ${_}`);try{await $(n)}catch(t){console.warn(t.message),await new Promise((j0)=>setTimeout(j0,200))}}if(!V.has(_))break;h.sendData(T[l]),o?.(T[l][14]/M8,_,E)}}))};G.set(k,{listeners:S,send:B});const v={send:B,on(b,A){return S.get(b)?.add(A)},off(b,A){return S.get(b)?.delete(A)}};return X.set(k,v),v},g=async()=>{try{await H(""),await new Promise((k)=>setTimeout(k,99))}catch(k){console.warn(Z0+": error sending leave",k)}for(let[k,j]of V){try{j.destroy()}catch{}V.delete(k)}J()},{send:p,on:f}=N(C1("ping")),{send:u,on:x}=N(C1("pong")),{send:c,on:a}=N(C1("signal")),{send:I,on:M}=N(C1("stream")),{send:w,on:Z}=N(C1("track")),{send:H,on:R}=N(C1("leave"));return W((k,j)=>{V.has(j)||(V.set(j,k),k.setHandlers({data(D){return((L,S)=>{try{const B=new Uint8Array(S),v=o1(B.subarray(0,12)).replace(/\0/g,"");if(!G.has(v))return console.warn(`${Z0}: unregistered type (${v})`);const[b]=B.subarray(12,13),[A]=B.subarray(13,14),[E]=B.subarray(14,15),o=B.subarray(15),i=!!(1&A),r=!!(2&A),O=!!(4&A),y=!!(8&A),m=G.get(v),d=(Y[L]||={})[v]||={};if(d[b]?.chunks?.length>100)return void console.warn(`${Z0}: peer ${L} sent too many chunks for nonce ${b}, ignoring.`);const T=d[b]||={chunks:[]};if(r)try{T.meta=A8(o1(o))}catch{return void console.warn(`${Z0}: failed to parse meta from peer ${L} for type ${v}`)}else T.chunks.push(o);if(m.listeners.get("progress").forEach((n)=>{try{n(E/M8,L,T.meta)}catch(l){console.error(l)}}),!i)return;const _=new Uint8Array(T.chunks.reduce((n,l)=>n+l.byteLength,0));let h;if(T.chunks.reduce((n,l)=>(_.set(l,n),n+l.byteLength),0),delete d[b],O)h=_;else if(y)try{h=A8(o1(_))}catch{return void console.warn(`${Z0}: failed to parse JSON message data from peer ${L} for type ${v}`)}else h=o1(_);m.listeners.get("message").forEach((n)=>{try{n(h,L,T.meta)}catch(l){console.error(l)}})}catch(B){console.error(`${Z0}: error handling data from peer ${L}:`,B)}})(j,D)},stream(D){C("stream:add",D,j,F[j]),delete F[j]},track(D,L){C("track:add",D,L,j,U[j]),delete U[j]},signal(D){return c(D,j)},close(){return z(j)},error(D){console.error(`${Z0}: peer error for ${j}`,D),z(j)}}),C("peer:join",j))}),f("message",(k,j)=>u("",j)),x("message",(k,j)=>{q[j]?.(),delete q[j]}),a("message",(k,j)=>V.get(j)?.signal(k)),M("message",(k,j)=>F[j]=k),Z("message",(k,j)=>U[j]=k),R("message",(k,j)=>z(j)),SV&&addEventListener("beforeunload",g),{on(k,j){P.has(k)||P.set(k,new Set),P.get(k).add(j)},off(k,j){return P.get(k)?.delete(j)},channel:N,leave:g,async ping(k){if(!k)throw N0("ping() requires target peer ID");const j=Date.now();return p("",k),await new Promise((D)=>q[k]=D),Date.now()-j},getPeers(){return IW(Array.from(V,([k,j])=>[k,j.connection]))},addStream(k,j,D){return K(j,async(L,S)=>{D&&await I(D,L),S.addStream(k)})},removeStream(k,j){return K(j,(D,L)=>L.removeStream(k))},addTrack(k,j,D,L){return K(D,async(S,B)=>{L&&await w(L,S),B.addTrack(k,j)})},removeTrack(k,j){return K(j,(D,L)=>L.removeTrack(k))},replaceTrack(k,j,D,L){return K(D,async(S,B)=>{L&&await w(L,S),B.replaceTrack(k,j)})}}},L8={},DW={};if(typeof window!="undefined"){const W=()=>{console.info("\u26A1 [GenosRTC] Network event detected. Forcing reconnection\u2026"),Object.values(DW).forEach((Q)=>{Q.socket&&Q.socket.readyState!==WebSocket.OPEN&&Q.socket.readyState!==WebSocket.CONNECTING&&Q.forceReconnect()})};window.addEventListener("online",()=>{console.info("\u2705 Reconnected to the network."),W()}),window.addEventListener("offline",async()=>{console.info("\u274C Disconnected from the network.")}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&W()})}var yV=(W,Q,J,V)=>(W.relayUrls??(V?((G,X)=>{const Y=[...G];let q=Y.length;const F=()=>{const U=1e4*Math.sin(X++);return U-Math.floor(U)};for(;q;){const U=Math.floor(F()*q--);[Y[q],Y[U]]=[Y[U],Y[q]]}return Y})(Q,LW(W.appId)):Q)).slice(0,W.relayUrls?.length??W.relayRedundancy??J),OW={},xW="EVENT",wW=_6.utils.randomSecretKey(),fV=T6(_6.getPublicKey(wW)),l6={},n1={},pV={},NW=()=>Math.floor(Date.now()/1000),SW=(W)=>pV[W]??=LW(W,1e4)+20000,_7=async(W,Q)=>{const J={kind:SW(W),content:Q,pubkey:fV,created_at:NW(),tags:[["x",W]]},V=new Uint8Array(await crypto.subtle.digest("SHA-256",t0(A0([0,J.pubkey,J.created_at,J.kind,J.tags,J.content])))),G=_6.sign(V,wW);return A0([xW,{...J,id:T6(V),sig:T6(G)}])},c7=(W,Q)=>(l6[W]=Q,A0(["REQ",W,{kinds:[SW(Q)],since:NW(),"#x":[Q]}])),d7=(W)=>(delete l6[W],A0(["CLOSE",W])),i6=(({init:W,subscribe:Q,announce:J})=>{const V={};let G,X,Y=!1;return(q,F,U)=>{const{appId:P}=q;if(V[P]?.[F])return V[P][F];if(!q||!F||!P&&!q.firebaseApp)throw N0(q?F?"appId missing":"roomId required":"config required");let C=AV;if(!Y){const Z=W(q);X=d6(20,()=>I6(!0,q)),G=Array.isArray(Z)?Z:[Z];const H=setInterval(()=>{X=X.filter((R)=>{const k=Date.now()-R.created<57333;return k||R.destroy(),k})},57333);V.offerCleanupTimer||=H,Y=!0}const K={},z={},$=R8(Z0,P,F),N=B8($),g=B8(R8($,$1)),p=(async(Z,H,R)=>{const k=await crypto.subtle.digest("SHA-256",t0(`${Z}:${H}:${R}`));return crypto.subtle.importKey("raw",k,{name:c6},!1,["encrypt","decrypt"])})(q.password||"",P,F),f=(Z)=>async(H)=>({type:H.type,sdp:await Z(p,H.sdp)}),u=f(wV),x=f(xV),c=(Z,H)=>{z[H]!==Z&&(z[H]?.destroy(),z[H]=Z,C(Z,H),K[H]?.forEach((R)=>R!==Z&&R.destroy()),delete K[H])},a=(Z,H)=>{z[H]===Z&&delete z[H]},I=B1(G.map(async(Z,H)=>{return Q(await Z,await N,await g,(R=H,async(k,j,D)=>{const[L,S]=await B1([N,g]);if(k!==L&&k!==S)return;const{peerId:B,offer:v,answer:b}=typeof j=="string"?A8(j):j;if(B!==$1&&!z[B])if(v){if(K[B]?.[R]&&$1>B)return;const A=I6(!1,q);A.setHandlers({connect(){return c(A,B)},close(){return a(A,B)}});try{const E=await u(v);if(A.isDead)return;const[o,i]=await B1([B8(R8($,B)),A.signal(E).then(x)]);D(o,A0({peerId:$1,answer:i}))}catch{U?.({error:"decryption failed (offer)",appId:P,peerId:B,roomId:F})}}else if(b){const A=K[B]?.[R];if(!A||A.isDead)return;A.setHandlers({connect(){return c(A,B)},close(){return a(A,B)}});try{A.signal(await u(b))}catch{U?.({error:"decryption failed (answer)",appId:P,peerId:B,roomId:F})}}else{if(K[B]?.[R])return;const A=X.pop()||I6(!0,q),[E,{offer:o}]=await B1([B8(R8($,B)),A.offerPromise.then(x).then((i)=>({offer:i}))]);K[B]||=[],K[B][R]=A,A.setHandlers({connect(){return c(A,B)},close(){return a(A,B)}}),D(E,A0({peerId:$1,offer:o,peer:A}))}}));var R})),M=[];I.then((Z)=>{G.forEach((H,R)=>{const k=async()=>{const j=await J(await H,await N,await g);M[R]=setTimeout(k,typeof j=="number"?j:5333)};k()}),V[P][F].onCleanup=()=>{delete V[P][F],M.forEach(clearTimeout),Z.forEach((H)=>H()),Object.keys(V).length===0&&(clearInterval(V.offerCleanupTimer),delete V.offerCleanupTimer)}}),V[P]||={};const w=EV((Z)=>C=Z,(Z)=>delete z[Z],()=>w.onCleanup?.());return V[P][F]=w}})({init(W){return yV(W,bV,5,!0).map((Q)=>{const J=((V,G)=>{const X={};let Y=null;const q=()=>{Y&&(clearTimeout(Y),Y=null);const F=new WebSocket(V);F.onclose=()=>{L8[V]??=3333,Y=setTimeout(q,L8[V]),L8[V]*=2},F.onmessage=(U)=>G(U.data),X.socket=F,X.url=F.url,X.ready=new Promise((U)=>{F.onopen=()=>{L8[V]=3333,U(X)}}),X.send=(U)=>{F.readyState===1&&F.send(U)}};return X.forceReconnect=q,q(),DW[V]=X,X})(Q,(V)=>{const[G,X,Y,q]=A8(V);if(G===xW)n1[X]?.(l6[X],Y.content);else{const F=`${Z0}: relay failure from ${J.url} - `;G==="NOTICE"?console.warn(F+X):G!=="OK"||Y||console.warn(F+q)}});return OW[Q]=J,J.ready})},subscribe(W,Q,J,V){const G=g6(64),X=g6(64);return n1[G]=n1[X]=(Y,q)=>V(Y,q,async(F,U)=>W.send(await _7(F,U))),W.send(c7(G,Q)),W.send(c7(X,J)),()=>{W.send(d7(G)),W.send(d7(X)),delete n1[G],delete n1[X]}},async announce(W,Q){return W.send(await _7(Q,A0({peerId:$1})))}}),OG=(l7=OW,()=>IW(vV(l7).map(([W,Q])=>[W,Q.socket]))),l7,bV=["black.nostrcity.club","eu.purplerelay.com","ftp.halifax.rwth-aachen.de/nostr","nostr.cool110.xyz","nostr.data.haus","nostr.mom","nostr.oxtr.dev","nostr.sathoarder.com","nostr.vulpem.com","playground.nostrcheck.me/relay","relay.agorist.space","relay.binaryrobot.com","relay.fountain.fm","relay.mostro.network","relay.nostraddress.com","relay.nostrdice.com","relay.nostromo.social","relay.oldenburg.cool","relay.snort.social","relay.verified-nostr.com","sendit.nosflare.com","yabu.me/v2","relay.damus.io"].map((W)=>"wss://"+W);function vW(W,Q,J){let V=Q.timestamp;if(V?.physical>Date.now()+7200000)V={physical:Date.now()+7200000,logical:V.logical};if(!W?.timestamp)return{resolved:!0,value:Q.value,timestamp:V};if(J.compare(V,W.timestamp)<=0)return{resolved:!1};return{resolved:!0,value:Q.value,timestamp:V}}function AW(W,Q=50){const J=`gdb_oplog_${W}`;let V=[];function G(){try{const Y=localStorage.getItem(J);V=Y?JSON.parse(Y):[]}catch(Y){console.error("\u274C GDB: Failed to load oplog from localStorage:",Y),V=[]}}function X(){try{localStorage.setItem(J,JSON.stringify(V))}catch(Y){console.error("\u274C GDB: Failed to save oplog to localStorage:",Y)}}return G(),{remove(Y){V=V.filter((q)=>q.id!==Y),X()},add(Y){if(V.push(Y),V.length>Q)V.shift();X()},getDelta(Y,q){if(!Y)return[...V];return V.filter((F)=>q(F.timestamp,Y)>0)},getOldest(){return V[0]},clear(){V=[],localStorage.removeItem(J)}}}var hV=()=>{const W=new Map,Q=async()=>{try{const F=await navigator.storage.getDirectory(),P=await(await F.getFileHandle("~opfs-sync-test",{create:!0})).createSyncAccessHandle?.();return await P?.close(),await F.removeEntry("~opfs-sync-test"),!!P}catch{return!1}};let J="idb";const V=(async()=>{if(await Q())J="sync";else try{const F=await navigator.storage.getDirectory(),P=await(await F.getFileHandle("~opfs-async-test",{create:!0})).createWritable?.();if(await P?.close(),await F.removeEntry("~opfs-async-test"),P)J="async";else J="idb"}catch{J="idb"}})(),G=async(F,U)=>{if(!W.has(F))W.set(F,[]);const P=W.get(F),C=P[P.length-1]||Promise.resolve();let K;const z=new Promise(($)=>K=$);P.push(z);try{return await C,await U()}finally{if(P.shift(),K(),P.length===0)W.delete(F)}},X=(()=>{let F;const U=async()=>{if(!F)F=new Promise((P,C)=>{const K=indexedDB.open("opfs-fallback-db",1);K.onupgradeneeded=()=>K.result.createObjectStore("files"),K.onsuccess=()=>P(K.result),K.onerror=()=>C(K.error)});return F};return{getDB:U,get:async(P)=>{const C=await U();return new Promise((K,z)=>{const N=C.transaction("files","readonly").objectStore("files").get(P);N.onsuccess=()=>K(N.result||new Uint8Array),N.onerror=()=>z(N.error)})},set:async(P,C)=>{const K=await U();return new Promise((z,$)=>{const g=K.transaction("files","readwrite").objectStore("files").put(C,P);g.onsuccess=()=>z(),g.onerror=()=>$(g.error)})}}})(),Y=async(F)=>{await V;try{if(J==="idb"){const z=await X.get(F);return{type:"loaded",name:F,data:z}}const P=await(await navigator.storage.getDirectory()).getFileHandle(F);if(J==="sync"){let z;try{z=await P.createSyncAccessHandle();const $=z.getSize(),N=new Uint8Array($),g=z.read(N,{at:0});return{type:"loaded",name:F,data:N.slice(0,g)}}finally{z?.close()}}const C=await P.getFile(),K=new Uint8Array(await C.arrayBuffer());return{type:"loaded",name:F,data:K}}catch(U){const P=U.name==="NotFoundError"?"File not found":U.message||"Error reading file";return{type:"error",name:F,message:P}}},q=async(F,U)=>{if(await V,!(U instanceof Uint8Array))return{type:"error",name:F,message:"Content must be a Uint8Array"};return G(F,async()=>{try{if(J==="idb")return await X.set(F,U),{type:"saved",name:F};const C=await(await navigator.storage.getDirectory()).getFileHandle(F,{create:!0});if(J==="sync"){let K;try{K=await C.createSyncAccessHandle(),K.truncate(0),K.write(U,{at:0}),K.flush()}finally{K?.close()}}else{let K;try{K=await C.createWritable(),await K.write(U)}finally{await K?.close()}}return{type:"saved",name:F}}catch(P){return{type:"error",name:F,message:P.message||"Error saving file"}}})};self.onmessage=async({data:F})=>{const{type:U,name:P,content:C}=F;await V;const K={load:()=>Y(P),save:()=>q(P,C)};try{const z=K[U],$=z?await z():{type:"error",message:`Unrecognized action type: ${U}`};self.postMessage($)}catch(z){console.error("\u274C Worker unexpected error:",z),self.postMessage({type:"error",name:P,message:z.message||"Unexpected worker error"})}}},TW=hV;var J1={$eq:(W,Q)=>W===Q,$ne:(W,Q)=>W!==Q,$gt:(W,Q)=>W>Q,$gte:(W,Q)=>W>=Q,$lt:(W,Q)=>W<Q,$lte:(W,Q)=>W<=Q,$in:(W,Q)=>Array.isArray(Q)&&(Array.isArray(W)?W.some((J)=>Q.includes(J)):Q.includes(W)),$between:(W,[Q,J])=>W>=Q&&W<=J,$exists:(W,Q)=>Q?W!==void 0:W===void 0,$text:{global:(W,Q)=>{const J=(G)=>String(G).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\w\s]/g,""),V=J(Q);return Object.values(W).some((G)=>typeof G==="object"?null.fieldSearch(G,V):J(G).includes(V))},field:(W,Q)=>{const J=(G)=>String(G).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\w\s]/g,""),V=J(Q);return Array.isArray(W)?W.some((G)=>J(G).includes(V)):J(W).includes(V)}},$like:(W,Q)=>typeof W==="string"&&typeof Q==="string"&&new RegExp(`^${Q.replace(/%/g,".*").replace(/_/g,".")}\$`,"i").test(W),$regex:(W,Q)=>typeof W==="string"&&new RegExp(Q.$regex||Q,"i").test(W),$and:(W,Q,J)=>Q.every((V)=>J.createFilter(V,J.allNodes)(W)),$or:(W,Q,J)=>Q.some((V)=>J.createFilter(V,J.allNodes)(W)),$not:(W,Q,J)=>!J.createFilter(Q,J.allNodes)(W),$edge:(W,Q,J)=>{if(!W.edges?.length||typeof Q!=="object"||Q===null)return!1;const V=J.createFilter(Q,J.allNodes),G=[...W.edges],X=new Set(G).add(W.id),Y=[];while(G.length){const q=G.shift(),F=J.allNodes[q];if(!F)continue;if(V(F))Y.push(F);F.edges?.forEach((U)=>!X.has(U)&&X.add(U)&&G.push(U))}if(Y.length)W._edgeResult=Y;return Y.length>0}},r6=(W,Q)=>Q.split(".").reduce((J,V)=>J&&typeof J==="object"&&(V in J)?J[V]:void 0,W),E8=(W,Q)=>{if(Object.keys(W).length===0)return()=>!0;return(J)=>Object.entries(W).every(([V,G])=>{if(V.startsWith("$"))return J1[V](J,G,{createFilter:E8,allNodes:Q});const X=r6(J.value,V);if(typeof G!=="object"||G===null)return J1.$eq(X,G);return Object.entries(G).every(([Y,q])=>{if(Y==="$text")return J1.$text.field(X,q);if(Y==="$between"&&q.every((F)=>F instanceof Date))return J1.$between(new Date(X),q);return J1[Y]?.(X,q,{createFilter:E8,allNodes:Q})??!1})})},n6=(W,Q)=>{const{$edge:J,...V}=Q.query||{},G=E8(V,W),X=Object.values(W).filter(G);let q=[...J?(()=>{const F=E8({$edge:J},W);X.forEach((P)=>F(P));const U=new Map;return X.forEach((P)=>{if(P._edgeResult)P._edgeResult.forEach((C)=>U.set(C.id,C)),delete P._edgeResult}),Array.from(U.values())})():X];if(Q.field){const F=Q.order==="asc"?1:-1;q.sort((U,P)=>{const C=r6(U.value,Q.field),K=r6(P.value,Q.field);if(typeof C==="string"&&typeof K==="string")return C.localeCompare(K)*F;return((C??0)-(K??0))*F})}if(Q.$after){const F=q.findIndex((U)=>U.id===Q.$after);q=F>=0?q.slice(F+1):[]}if(Q.$before){const F=q.findIndex((U)=>U.id===Q.$before);q=F>=0?q.slice(0,F):[]}if(Q.$limit)q=q.slice(0,Q.$limit);return q};function gW(){let W=Date.now(),Q=0;return{now(){const J=Date.now();return W=Math.max(W,J),Q++,{physical:W,logical:Q}},update(J){if(!J||typeof J.physical!=="number"||typeof J.logical!=="number"){console.warn("\u26A0\uFE0F HybridClock.update received an invalid remote timestamp.",J);return}W=Math.max(W,J.physical),Q=Math.max(Q,J.logical)+1},compare(J,V){if(!J&&!V)return 0;if(!J)return-1;if(!V)return 1;if(J.physical>V.physical)return 1;if(J.physical<V.physical)return-1;if(J.logical>V.logical)return 1;if(J.logical<V.logical)return-1;return 0}}}var EW=function(W,Q){return W.length===Q.length&&W.every((J,V)=>J===Q[V])};async function mV(){if(console.info(navigator?.storage?.getDirectory?"\u2705 OPFS is enabled.":"\uD83D\uDEAB OPFS is not available."),navigator?.storage?.getDirectory)await navigator.storage.getDirectory()}var _V=function(){const W={nodes:{}};return{get nodes(){return W.nodes},set nodes(J){W.nodes=J||{}},upsert(J,V,G){const X=W.nodes[J];W.nodes[J]={id:J,value:V&&typeof V==="object"?fW(V):V,edges:X?.edges?[...X.edges]:[],timestamp:G}},get(J){return W.nodes[J]||null},link(J,V,G){const X=W.nodes[J],Y=W.nodes[V];if(X&&Y&&!X.edges.includes(V))W.nodes[J]={...X,edges:[...X.edges,V],timestamp:G}},getAllNodes(){return Object.values(W.nodes)},serialize(){return H1.deflate(X1(W.nodes))},deserialize(J){W.nodes=N1(H1.inflate(new Uint8Array(J)))}}};async function mG(W,Q={}){const{password:J,sm:V=!1,audit:G=!1,ii:X=!1,rx:Y=!1,ai:q=!1,geo:F=!1,relayUrls:U=null,turnConfig:P=null,saveDelay:C=200,oplogSize:K=20}=Q,z=_V(),$=gW(),N=AW(W,K),g=[];let p=null,f=[],u=null,x=null,c=null,a=null;const I=[],M={};Object.defineProperties(M,{hybridClock:{get:()=>$},graph:{get:()=>z},syncChannel:{get:()=>x},worker:{get:()=>u},oplog:{get:()=>N},broadcastChannel:{get:()=>c},options:{get:()=>Q},pako:{get:()=>H1},encode:{get:()=>X1},decode:{get:()=>N1},operators:{get:()=>J1},deepClone:{get:()=>fW},generateHash:{get:()=>L}});async function w(O,y){const m=new URL(`./${O}.min.js`,import.meta.url).href,d=`https://cdn.jsdelivr.net/npm/genosdb@latest/dist/${O}.min.js`;try{const T=await import(m).catch(()=>{return console.warn(`\u26A0\uFE0F ${O} not found locally, loading from CDN...`),import(d)}),_=y&&typeof y==="object"?y:{},h=typeof T.init==="function"?T.init(M,T,_):null;if(h)Object.assign(M,h);return T}catch(T){throw console.error(`\u274C Initialization of ${O} failed:`,T),T}}function Z(){const O=localStorage.getItem(`${W}_time`);p=O?JSON.parse(O):null}function H(O){p=O,localStorage.setItem(`${W}_time`,JSON.stringify(O))}function R(){try{const O=URL.createObjectURL(new Blob([`(${TW.toString()})()`],{type:"application/javascript"}));u=new Worker(O),URL.revokeObjectURL(O),u.addEventListener("message",({data:y})=>{console.info(`\uD83D\uDCBE ${y.name} ${y.type}`)}),console.info("\u2699\uFE0F Worker initialized successfully.")}catch({message:O}){console.error("\u274C Failed to initialize worker:",O)}}function k(){const O={...z.nodes};f.forEach((y)=>y(O))}const j=uV(()=>k()),D=yW(async()=>{const O=I.splice(0,I.length);if(!O.length)return!1;return await x.send(O),!0},16);async function L(){return crypto.randomUUID()}async function S(){try{const y=await((m)=>new Promise((d,T)=>{const _=async({data:h})=>{if(h.type==="loaded"&&h.name===m)u.removeEventListener("message",_),d(new Uint8Array(h.data));else if(h.type==="error")u.removeEventListener("message",_),T(new Error(h.message||"Unknown error"))};u.addEventListener("message",_),u.postMessage({type:"load",name:m})}))(`${W}_graph.msgpack`).catch(()=>new Uint8Array);y.byteLength>0?z.deserialize(y):console.warn("\u26A0\uFE0F The file '_graph.msgpack' is empty or could not be loaded."),console.info(`\u2705 Graph loaded: [ ${z.getAllNodes().length} nodes ]`)}catch({message:O}){console.error("\u274C Error loading the graph:",O)}}async function B(){try{const O=z.serialize();return await((m,d)=>new Promise((T,_)=>{const h=({data:n})=>{if(n.type==="saved"&&n.name===m)u.removeEventListener("message",h),T();else if(n.type==="error")u.removeEventListener("message",h),_(new Error(n.message||"Save error"))};u.addEventListener("message",h),u.postMessage({type:"save",name:m,content:d})}))(`${W}_graph.msgpack`,O),c.postMessage("update"),!0}catch({message:O}){throw console.error("\u274C Save error:",O),new Error("Save failed")}}const v=yW(()=>B(),C);async function b(O){try{console.info("\uD83D\uDD04 Applying full graph from remote..."),z.nodes={...O.nodes},await B()}catch({message:y}){console.error(`\u274C Error applying the full graph: ${y}`)}}async function A(O){let y=!1,m=null;const d={upsert:(T)=>{const _=z.get(T.id),h=vW(_,T,$);if(h.resolved){if(z.upsert(T.id,h.value,h.timestamp),$.update(h.timestamp),N.add({type:"upsert",id:T.id,timestamp:h.timestamp}),y=!0,!m||$.compare(h.timestamp,m)>0)m=h.timestamp}},remove:(T)=>{const _=z.get(T.id);if(_&&$.compare(_.timestamp,T.timestamp)<0){if(delete z.nodes[T.id],$.update(T.timestamp),N.add({type:"remove",id:T.id,timestamp:T.timestamp}),y=!0,!m||$.compare(T.timestamp,m)>0)m=T.timestamp}},link:(T)=>{const _=z.get(T.sourceId),h=z.get(T.targetId);if(_&&h&&$.compare(_.timestamp,T.timestamp)<0){if(z.link(T.sourceId,T.targetId,T.timestamp),$.update(T.timestamp),N.add({type:"link",sourceId:T.sourceId,targetId:T.targetId,timestamp:T.timestamp}),y=!0,!m||$.compare(T.timestamp,m)>0)m=T.timestamp}},sync:async(T)=>{const _=T.timestamp;if(_===null){console.info("\uD83D\uDCEC [SYNC REQUEST] from new peer (no timestamp). Sending full graph."),await x.send([{type:"syncReceive",graph:z}]);return}console.info("\uD83D\uDCEC [SYNC REQUEST] since:",new Date(_.physical).toLocaleString());const h=N.getOldest();if(h&&$.compare(_,h.timestamp)<0){console.info("\uD83D\uDCA5 [FALLBACK TRIGGERED] Peer is too far behind. Sending FULL graph state."),await x.send([{type:"syncReceive",graph:z}]);return}const n=N.getDelta(_,$.compare);if(n.length>0){const l=n.map((t)=>{if(t.type==="upsert"){const j0=z.get(t.id);return{...t,value:j0?j0.value:null}}return t}),G0=H1.deflate(X1(l));console.info(`\uD83D\uDE80 [DELTA SYNC SENDING] Found ${n.length} new operations to send.`),await x.send([{type:"deltaSync",operations:G0}])}else console.info("\u2705 [ALREADY SYNCED] Peer is up-to-date. Nothing to send.")},deltaSync:(T)=>{const _=T.operations.byteLength,h=N1(H1.inflate(T.operations)),n=X1(h).byteLength;console.info(`\uD83D\uDEF0\uFE0F [DELTA SYNC RECEIVED] Applying ${h.length} operations from a peer.`),console.info(` Compressed: ${_} bytes, Decompressed: ${n} bytes.`);for(let l of h)d[l.type]?.(l)},syncReceive:async(T)=>{if(console.info("\uD83D\uDCE6 [FULL SYNC RECEIVED] Overwriting local state with full graph from a peer."),T.graph&&T.graph.nodes){await b(T.graph),N.clear(),console.info("\uD83D\uDD12 Oplog has been cleared due to full sync."),y=!0;let _=null;for(let h in T.graph.nodes){const n=T.graph.nodes[h];if(n.timestamp&&(!_||$.compare(n.timestamp,_)>0))_=n.timestamp}if(_)console.info("\uD83D\uDCC8 [GLOBAL TIMESTAMP] Updated from full sync."),m=_,$.update(_)}else console.error("\u274C Full sync failed: received graph data is invalid.",T.graph)}};for(let T of O)if(d[T.type])await d[T.type](T);else console.warn(`\uD83E\uDD37\u200D\u2640\uFE0F [UNKNOWN MESSAGE TYPE] Received unhandled message type: "${T.type}"`);if(m){if(!p||$.compare(m,p)>0)console.info(`\uD83D\uDCC8 [GLOBAL TIMESTAMP] Advanced from ${p?.logical} to ${m.logical}.`),H(m)}if(y)console.info("\uD83D\uDCBE [STATE CHANGED] Saving state and emitting update."),await B(),k()}Object.assign(M,{use(O){if(typeof O==="function")g.push(O)},async put(O,y){const m=$.now();H(m),y??=await L(),z.upsert(y,O,m),N.add({type:"upsert",id:y,timestamp:m}),v();try{I.push({type:"upsert",id:y,value:O,timestamp:m}),D().catch(()=>{})}finally{j()}return y},async link(O,y){const m=$.now();if(!z.nodes[O]||!z.nodes[y]){console.warn(`\u26A0\uFE0F One or both nodes (${O}, ${y}) do not exist.`);return}z.link(O,y,m),N.add({type:"link",sourceId:O,targetId:y,timestamp:m}),v(),H(m);try{I.push({type:"link",sourceId:O,targetId:y,timestamp:m}),D().catch(()=>{})}finally{j()}},async remove(O){const y=$.now(),m=z.get(O);if(!m)return console.warn(`\u26A0\uFE0F Node with ID '${O}' not found.`);delete z.nodes[O],N.add({type:"remove",id:O,timestamp:y}),Object.values(z.nodes).forEach((d)=>d.edges=d.edges.filter((T)=>T!==O)),v(),H(y);try{I.push({type:"remove",id:O,value:m.value,timestamp:y}),D().catch(()=>{})}finally{j()}},async get(O,y=null){if(typeof O!=="string")return{result:null};const m=z.get(O);if(!m){if(y)y(null);return{result:null}}const d=(h)=>{if(!h)return null;const n=h.value!==null&&typeof h.value==="object"?{...h.value}:h.value;return{...h,value:n}};if(!y)return{result:d(m)};let T=m.timestamp;y(d(m));const _=(h)=>{const n=h[O];if(n){if($.compare(n.timestamp,T)>0)T=n.timestamp,y(d(n))}else y(null),f.splice(f.indexOf(_),1)};return f.push(_),{result:d(m),unsubscribe:()=>{const h=f.indexOf(_);if(h>-1)f.splice(h,1)}}},async map(...O){let m={...{realtime:!1,query:{},field:null,order:"asc",$limit:null,$after:null,$before:null}},d=null,T=!1;O.forEach((l)=>typeof l==="function"?d=l:l&&typeof l==="object"&&(T||=("realtime"in l),Object.assign(m,l))),d&&!T&&(m.realtime=!0);let _=n6(z.nodes,m),h=null;const n=(l)=>{const G0=new Map(_.map((J0)=>[J0.id,J0])),t=new Map(l.map((J0)=>[J0.id,J0])),j0=[],Q1=[],o6=[];for(let[J0,T0]of t){const t1=G0.get(J0);if(!t1)j0.push(T0);else if((T0.timestamp?.physical||0)!==(t1.timestamp?.physical||0)||(T0.timestamp?.logical||0)!==(t1.timestamp?.logical||0)||!EW(T0.edges||[],t1.edges||[]))Q1.push(T0)}for(let[J0]of G0)if(!t.has(J0))o6.push(G0.get(J0));const y8=(J0,T0)=>d({id:J0.id,value:T0==="removed"?null:J0.value,edges:J0.edges||[],timestamp:J0.timestamp||null,action:T0});j0.forEach((J0)=>y8(J0,"added")),o6.forEach((J0)=>y8(J0,"removed")),Q1.forEach((J0)=>y8(J0,"updated"))};if(d){if(_.forEach((l)=>{d({id:l.id,value:l.value,edges:l.edges,timestamp:l.timestamp,action:"initial"})}),m.realtime){const l=(G0)=>{const t=G0.timestamp?.physical||0,j0=G0.timestamp?.logical||0,Q1=(G0.edges||[]).join(",");return`${G0.id}:${t}:${j0}:${Q1}`};h=(G0)=>{const t=n6(G0,m);if(t.length!==_.length)n(t),_=t;else{const j0=t.map(l),Q1=_.map(l);if(!EW(j0,Q1))n(t),_=t}},f.push(h)}}return{results:_,...m.realtime&&d&&h&&{unsubscribe:()=>{const l=f.indexOf(h);l>-1&&f.splice(l,1)}}}},async clear(){z.nodes={};try{await(await navigator.storage.getDirectory()).removeEntry(`${W}_graph.msgpack`)}catch({message:O}){console.warn(`\u26A0\uFE0F Error deleting _graph.msgpack: ${O}`)}k(),console.info("\u2705 All data has been deleted.")}}),R(),Z(),await mV(),await S();const E=[];if(V)E.push(w("sm",V));if(q)E.push(w("AIQuery",q));if(Y)E.push(w("radixindex",Y));if(X)E.push(w("invertedindex",X));if(G)E.push(w("audit",G));if(F)E.push(w("geo",F));await Promise.all(E);const o=`graph-sync-room-${W}`,i={appId:"1234",...J&&{password:J}};if(U)i.relayUrls=U;if(P)i.turnConfig=P;const r=i6(i,o);return x=r.channel("syncGraph"),a=i6(i,`app-sync-${W}`),M.room=a,r.on("peer:join",async(O)=>{console.info("\u26A1 New peer connected:",O),x.send([{type:"sync",timestamp:p}])}),r.on("peer:leave",(O)=>{console.info("\u26A1 Peer disconnected:",O)}),x.on("message",async(O)=>{let y=O;for(let m of g)try{if(y=await m(y),!y||y.length===0)return}catch(d){console.error("\u274C GDB: Middleware error, discarding message.",d);return}await A(y)}),c=new BroadcastChannel(`graphdb_sync_${W}`),c.onmessage=async(O)=>{if(O.data==="update")console.info("\uD83D\uDD04 Update received from another tab..."),await S(),Z(),j()},console.info(`\u2705 GenosDB [ ${W} ] instance is ready.`),M}var fW=(W)=>{if(W===null||typeof W!=="object")return W;if(typeof structuredClone==="function")return structuredClone(W);return JSON.parse(JSON.stringify(W))},yW=(W,Q=16)=>{let J=null,V=null;return(...G)=>{if(!V)V={},V.promise=new Promise((Y,q)=>(V.resolve=Y,V.reject=q));if(J)("cancelIdleCallback"in window?cancelIdleCallback:clearTimeout)(J);const X=async()=>{J=null;try{V.resolve(await W(...G))}catch(Y){V.reject(Y)}finally{V=null}};return J=("requestIdleCallback"in window)?requestIdleCallback(X,{timeout:Q}):setTimeout(X,Q),V.promise}},uV=(W)=>{let Q=null;return()=>{if(Q!==null)return;Q=requestAnimationFrame(()=>{Q=null,W()})}};export{mG as gdb};
|
|
1
|
+
function a6(W){const Q=W.length;let J=0,V=0;while(V<Q){let G=W.charCodeAt(V++);if((G&4294967168)===0){J++;continue}else if((G&4294965248)===0)J+=2;else{if(G>=55296&&G<=56319){if(V<Q){const X=W.charCodeAt(V);if((X&64512)===56320)++V,G=((G&1023)<<10)+(X&1023)+65536}}if((G&4294901760)===0)J+=3;else J+=4}}return J}function pW(W,Q,J){const V=W.length;let G=J,X=0;while(X<V){let Y=W.charCodeAt(X++);if((Y&4294967168)===0){Q[G++]=Y;continue}else if((Y&4294965248)===0)Q[G++]=Y>>6&31|192;else{if(Y>=55296&&Y<=56319){if(X<V){const q=W.charCodeAt(X);if((q&64512)===56320)++X,Y=((Y&1023)<<10)+(q&1023)+65536}}if((Y&4294901760)===0)Q[G++]=Y>>12&15|224,Q[G++]=Y>>6&63|128;else Q[G++]=Y>>18&7|240,Q[G++]=Y>>12&63|128,Q[G++]=Y>>6&63|128}Q[G++]=Y&63|128}}function uW(W,Q,J){bW.encodeInto(W,Q.subarray(J))}function s6(W,Q,J){if(W.length>hW)uW(W,Q,J);else pW(W,Q,J)}function f8(W,Q,J){let V=Q;const G=V+J,X=[];let Y="";while(V<G){const q=W[V++];if((q&128)===0)X.push(q);else if((q&224)===192){const F=W[V++]&63;X.push((q&31)<<6|F)}else if((q&240)===224){const F=W[V++]&63,U=W[V++]&63;X.push((q&31)<<12|F<<6|U)}else if((q&248)===240){const F=W[V++]&63,U=W[V++]&63,P=W[V++]&63;let C=(q&7)<<18|F<<12|U<<6|P;if(C>65535)C-=65536,X.push(C>>>10&1023|55296),C=56320|C&1023;X.push(C)}else X.push(q);if(X.length>=mW)Y+=String.fromCharCode(...X),X.length=0}if(X.length>0)Y+=String.fromCharCode(...X);return Y}function dW(W,Q,J){const V=W.subarray(Q,Q+J);return _W.decode(V)}function e6(W,Q,J){if(J>cW)return dW(W,Q,J);else return f8(W,Q,J)}var bW=new TextEncoder,hW=50,mW=4096,_W=new TextDecoder,cW=200;class V1{constructor(W,Q){this.type=W,this.data=Q}}class Y0 extends Error{constructor(W){super(W);const Q=Object.create(Y0.prototype);Object.setPrototypeOf(this,Q),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:Y0.name})}}function t6(W,Q,J){const V=J/4294967296,G=J;W.setUint32(Q,V),W.setUint32(Q+4,G)}function W8(W,Q,J){const V=Math.floor(J/4294967296),G=J;W.setUint32(Q,V),W.setUint32(Q+4,G)}function J8(W,Q){const J=W.getInt32(Q),V=W.getUint32(Q+4);return J*4294967296+V}function W5(W,Q){const J=W.getUint32(Q),V=W.getUint32(Q+4);return J*4294967296+V}var G1=4294967295;function nW({sec:W,nsec:Q}){if(W>=0&&Q>=0&&W<=rW)if(Q===0&&W<=iW){const J=new Uint8Array(4);return new DataView(J.buffer).setUint32(0,W),J}else{const J=W/4294967296,V=W&4294967295,G=new Uint8Array(8),X=new DataView(G.buffer);return X.setUint32(0,Q<<2|J&3),X.setUint32(4,V),G}else{const J=new Uint8Array(12),V=new DataView(J.buffer);return V.setUint32(0,Q),W8(V,4,W),J}}function oW(W){const Q=W.getTime(),J=Math.floor(Q/1000),V=(Q-J*1000)*1e6,G=Math.floor(V/1e9);return{sec:J+G,nsec:V-G*1e9}}function aW(W){if(W instanceof Date){const Q=oW(W);return nW(Q)}else return null}function sW(W){const Q=new DataView(W.buffer,W.byteOffset,W.byteLength);switch(W.byteLength){case 4:return{sec:Q.getUint32(0),nsec:0};case 8:{const J=Q.getUint32(0),V=Q.getUint32(4),G=(J&3)*4294967296+V,X=J>>>2;return{sec:G,nsec:X}}case 12:{const J=J8(Q,4),V=Q.getUint32(0);return{sec:J,nsec:V}}default:throw new Y0(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${W.length}`)}}function eW(W){const Q=sW(W);return new Date(Q.sec*1000+Q.nsec/1e6)}var lW=-1,iW=4294967295,rW=17179869183,J5={type:lW,encode:aW,decode:eW};class u0{constructor(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(J5)}register({type:W,encode:Q,decode:J}){if(W>=0)this.encoders[W]=Q,this.decoders[W]=J;else{const V=-1-W;this.builtInEncoders[V]=Q,this.builtInDecoders[V]=J}}tryToEncode(W,Q){for(let J=0;J<this.builtInEncoders.length;J++){const V=this.builtInEncoders[J];if(V!=null){const G=V(W,Q);if(G!=null){const X=-1-J;return new V1(X,G)}}}for(let J=0;J<this.encoders.length;J++){const V=this.encoders[J];if(V!=null){const G=V(W,Q);if(G!=null)return new V1(J,G)}}if(W instanceof V1)return W;return null}decode(W,Q,J){const V=Q<0?this.builtInDecoders[-1-Q]:this.decoders[Q];if(V)return V(W,Q,J);else return new V1(Q,W)}}u0.defaultCodec=new u0;var tW=function(W){return W instanceof ArrayBuffer||typeof SharedArrayBuffer!=="undefined"&&W instanceof SharedArrayBuffer};function O1(W){if(W instanceof Uint8Array)return W;else if(ArrayBuffer.isView(W))return new Uint8Array(W.buffer,W.byteOffset,W.byteLength);else if(tW(W))return new Uint8Array(W);else return Uint8Array.from(W)}var WJ=100,JJ=2048;class Q8{constructor(W){this.entered=!1,this.extensionCodec=W?.extensionCodec??u0.defaultCodec,this.context=W?.context,this.useBigInt64=W?.useBigInt64??!1,this.maxDepth=W?.maxDepth??WJ,this.initialBufferSize=W?.initialBufferSize??JJ,this.sortKeys=W?.sortKeys??!1,this.forceFloat32=W?.forceFloat32??!1,this.ignoreUndefined=W?.ignoreUndefined??!1,this.forceIntegerToFloat=W?.forceIntegerToFloat??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new Q8({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(W){if(this.entered)return this.clone().encodeSharedRef(W);try{return this.entered=!0,this.reinitializeState(),this.doEncode(W,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(W){if(this.entered)return this.clone().encode(W);try{return this.entered=!0,this.reinitializeState(),this.doEncode(W,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(W,Q){if(Q>this.maxDepth)throw new Error(`Too deep objects in depth ${Q}`);if(W==null)this.encodeNil();else if(typeof W==="boolean")this.encodeBoolean(W);else if(typeof W==="number")if(!this.forceIntegerToFloat)this.encodeNumber(W);else this.encodeNumberAsFloat(W);else if(typeof W==="string")this.encodeString(W);else if(this.useBigInt64&&typeof W==="bigint")this.encodeBigInt64(W);else this.encodeObject(W,Q)}ensureBufferSizeToWrite(W){const Q=this.pos+W;if(this.view.byteLength<Q)this.resizeBuffer(Q*2)}resizeBuffer(W){const Q=new ArrayBuffer(W),J=new Uint8Array(Q),V=new DataView(Q);J.set(this.bytes),this.view=V,this.bytes=J}encodeNil(){this.writeU8(192)}encodeBoolean(W){if(W===!1)this.writeU8(194);else this.writeU8(195)}encodeNumber(W){if(!this.forceIntegerToFloat&&Number.isSafeInteger(W))if(W>=0)if(W<128)this.writeU8(W);else if(W<256)this.writeU8(204),this.writeU8(W);else if(W<65536)this.writeU8(205),this.writeU16(W);else if(W<4294967296)this.writeU8(206),this.writeU32(W);else if(!this.useBigInt64)this.writeU8(207),this.writeU64(W);else this.encodeNumberAsFloat(W);else if(W>=-32)this.writeU8(224|W+32);else if(W>=-128)this.writeU8(208),this.writeI8(W);else if(W>=-32768)this.writeU8(209),this.writeI16(W);else if(W>=-2147483648)this.writeU8(210),this.writeI32(W);else if(!this.useBigInt64)this.writeU8(211),this.writeI64(W);else this.encodeNumberAsFloat(W);else this.encodeNumberAsFloat(W)}encodeNumberAsFloat(W){if(this.forceFloat32)this.writeU8(202),this.writeF32(W);else this.writeU8(203),this.writeF64(W)}encodeBigInt64(W){if(W>=BigInt(0))this.writeU8(207),this.writeBigUint64(W);else this.writeU8(211),this.writeBigInt64(W)}writeStringHeader(W){if(W<32)this.writeU8(160+W);else if(W<256)this.writeU8(217),this.writeU8(W);else if(W<65536)this.writeU8(218),this.writeU16(W);else if(W<4294967296)this.writeU8(219),this.writeU32(W);else throw new Error(`Too long string: ${W} bytes in UTF-8`)}encodeString(W){const J=a6(W);this.ensureBufferSizeToWrite(5+J),this.writeStringHeader(J),s6(W,this.bytes,this.pos),this.pos+=J}encodeObject(W,Q){const J=this.extensionCodec.tryToEncode(W,this.context);if(J!=null)this.encodeExtension(J);else if(Array.isArray(W))this.encodeArray(W,Q);else if(ArrayBuffer.isView(W))this.encodeBinary(W);else if(typeof W==="object")this.encodeMap(W,Q);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(W)}`)}encodeBinary(W){const Q=W.byteLength;if(Q<256)this.writeU8(196),this.writeU8(Q);else if(Q<65536)this.writeU8(197),this.writeU16(Q);else if(Q<4294967296)this.writeU8(198),this.writeU32(Q);else throw new Error(`Too large binary: ${Q}`);const J=O1(W);this.writeU8a(J)}encodeArray(W,Q){const J=W.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 new Error(`Too large array: ${J}`);for(let V of W)this.doEncode(V,Q+1)}countWithoutUndefined(W,Q){let J=0;for(let V of Q)if(W[V]!==void 0)J++;return J}encodeMap(W,Q){const J=Object.keys(W);if(this.sortKeys)J.sort();const V=this.ignoreUndefined?this.countWithoutUndefined(W,J):J.length;if(V<16)this.writeU8(128+V);else if(V<65536)this.writeU8(222),this.writeU16(V);else if(V<4294967296)this.writeU8(223),this.writeU32(V);else throw new Error(`Too large map object: ${V}`);for(let G of J){const X=W[G];if(!(this.ignoreUndefined&&X===void 0))this.encodeString(G),this.doEncode(X,Q+1)}}encodeExtension(W){if(typeof W.data==="function"){const J=W.data(this.pos+6),V=J.length;if(V>=4294967296)throw new Error(`Too large extension object: ${V}`);this.writeU8(201),this.writeU32(V),this.writeI8(W.type),this.writeU8a(J);return}const Q=W.data.length;if(Q===1)this.writeU8(212);else if(Q===2)this.writeU8(213);else if(Q===4)this.writeU8(214);else if(Q===8)this.writeU8(215);else if(Q===16)this.writeU8(216);else if(Q<256)this.writeU8(199),this.writeU8(Q);else if(Q<65536)this.writeU8(200),this.writeU16(Q);else if(Q<4294967296)this.writeU8(201),this.writeU32(Q);else throw new Error(`Too large extension object: ${Q}`);this.writeI8(W.type),this.writeU8a(W.data)}writeU8(W){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,W),this.pos++}writeU8a(W){const Q=W.length;this.ensureBufferSizeToWrite(Q),this.bytes.set(W,this.pos),this.pos+=Q}writeI8(W){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,W),this.pos++}writeU16(W){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,W),this.pos+=2}writeI16(W){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,W),this.pos+=2}writeU32(W){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,W),this.pos+=4}writeI32(W){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,W),this.pos+=4}writeF32(W){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,W),this.pos+=4}writeF64(W){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,W),this.pos+=8}writeU64(W){this.ensureBufferSizeToWrite(8),t6(this.view,this.pos,W),this.pos+=8}writeI64(W){this.ensureBufferSizeToWrite(8),W8(this.view,this.pos,W),this.pos+=8}writeBigUint64(W){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,W),this.pos+=8}writeBigInt64(W){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,W),this.pos+=8}}function X1(W,Q){return new Q8(Q).encodeSharedRef(W)}function V8(W){return`${W<0?"-":""}0x${Math.abs(W).toString(16).padStart(2,"0")}`}var QJ=16,VJ=16;class p8{constructor(W=QJ,Q=VJ){this.hit=0,this.miss=0,this.maxKeyLength=W,this.maxLengthPerKey=Q,this.caches=[];for(let J=0;J<this.maxKeyLength;J++)this.caches.push([])}canBeCached(W){return W>0&&W<=this.maxKeyLength}find(W,Q,J){const V=this.caches[J-1];W:for(let G of V){const X=G.bytes;for(let Y=0;Y<J;Y++)if(X[Y]!==W[Q+Y])continue W;return G.str}return null}store(W,Q){const J=this.caches[W.length-1],V={bytes:W,str:Q};if(J.length>=this.maxLengthPerKey)J[Math.random()*J.length|0]=V;else J.push(V)}decode(W,Q,J){const V=this.find(W,Q,J);if(V!=null)return this.hit++,V;this.miss++;const G=f8(W,Q,J),X=Uint8Array.prototype.slice.call(W,Q,Q+J);return this.store(X,G),G}}var b8="array",w1="map_key",V5="map_value",GJ=(W)=>{if(typeof W==="string"||typeof W==="number")return W;throw new Y0("The type of key must be string or number but "+typeof W)};class G5{constructor(){this.stack=[],this.stackHeadPosition=-1}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(W){const Q=this.getUninitializedStateFromPool();Q.type=b8,Q.position=0,Q.size=W,Q.array=new Array(W)}pushMapState(W){const Q=this.getUninitializedStateFromPool();Q.type=w1,Q.readCount=0,Q.size=W,Q.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const W={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(W)}return this.stack[this.stackHeadPosition]}release(W){if(this.stack[this.stackHeadPosition]!==W)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(W.type===b8){const J=W;J.size=0,J.array=void 0,J.position=0,J.type=void 0}if(W.type===w1||W.type===V5){const J=W;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 x1=-1,h8=new DataView(new ArrayBuffer(0)),XJ=new Uint8Array(h8.buffer);try{h8.getInt8(0)}catch(W){if(!(W instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var Q5=new RangeError("Insufficient data"),YJ=new p8;class G8{constructor(W){this.totalPos=0,this.pos=0,this.view=h8,this.bytes=XJ,this.headByte=x1,this.stack=new G5,this.entered=!1,this.extensionCodec=W?.extensionCodec??u0.defaultCodec,this.context=W?.context,this.useBigInt64=W?.useBigInt64??!1,this.rawStrings=W?.rawStrings??!1,this.maxStrLength=W?.maxStrLength??G1,this.maxBinLength=W?.maxBinLength??G1,this.maxArrayLength=W?.maxArrayLength??G1,this.maxMapLength=W?.maxMapLength??G1,this.maxExtLength=W?.maxExtLength??G1,this.keyDecoder=W?.keyDecoder!==void 0?W.keyDecoder:YJ,this.mapKeyConverter=W?.mapKeyConverter??GJ}clone(){return new G8({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=x1,this.stack.reset()}setBuffer(W){const Q=O1(W);this.bytes=Q,this.view=new DataView(Q.buffer,Q.byteOffset,Q.byteLength),this.pos=0}appendBuffer(W){if(this.headByte===x1&&!this.hasRemaining(1))this.setBuffer(W);else{const Q=this.bytes.subarray(this.pos),J=O1(W),V=new Uint8Array(Q.length+J.length);V.set(Q),V.set(J,Q.length),this.setBuffer(V)}}hasRemaining(W){return this.view.byteLength-this.pos>=W}createExtraByteError(W){const{view:Q,pos:J}=this;return new RangeError(`Extra ${Q.byteLength-J} of ${Q.byteLength} byte(s) found at buffer[${W}]`)}decode(W){if(this.entered)return this.clone().decode(W);try{this.entered=!0,this.reinitializeState(),this.setBuffer(W);const Q=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return Q}finally{this.entered=!1}}*decodeMulti(W){if(this.entered){yield*this.clone().decodeMulti(W);return}try{this.entered=!0,this.reinitializeState(),this.setBuffer(W);while(this.hasRemaining(1))yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(W){if(this.entered)return this.clone().decodeAsync(W);try{this.entered=!0;let Q=!1,J;for await(let Y of W){if(Q)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(Y);try{J=this.doDecodeSync(),Q=!0}catch(q){if(!(q instanceof RangeError))throw q}this.totalPos+=this.pos}if(Q){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return J}const{headByte:V,pos:G,totalPos:X}=this;throw new RangeError(`Insufficient data in parsing ${V8(V)} at ${X} (${G} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(W){return this.decodeMultiAsync(W,!0)}decodeStream(W){return this.decodeMultiAsync(W,!1)}async*decodeMultiAsync(W,Q){if(this.entered){yield*this.clone().decodeMultiAsync(W,Q);return}try{this.entered=!0;let J=Q,V=-1;for await(let G of W){if(Q&&V===0)throw this.createExtraByteError(this.totalPos);if(this.appendBuffer(G),J)V=this.readArraySize(),J=!1,this.complete();try{while(!0)if(yield this.doDecodeSync(),--V===0)break}catch(X){if(!(X instanceof RangeError))throw X}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){W:while(!0){const W=this.readHeadByte();let Q;if(W>=224)Q=W-256;else if(W<192)if(W<128)Q=W;else if(W<144){const V=W-128;if(V!==0){this.pushMapState(V),this.complete();continue W}else Q={}}else if(W<160){const V=W-144;if(V!==0){this.pushArrayState(V),this.complete();continue W}else Q=[]}else{const V=W-160;Q=this.decodeString(V,0)}else if(W===192)Q=null;else if(W===194)Q=!1;else if(W===195)Q=!0;else if(W===202)Q=this.readF32();else if(W===203)Q=this.readF64();else if(W===204)Q=this.readU8();else if(W===205)Q=this.readU16();else if(W===206)Q=this.readU32();else if(W===207)if(this.useBigInt64)Q=this.readU64AsBigInt();else Q=this.readU64();else if(W===208)Q=this.readI8();else if(W===209)Q=this.readI16();else if(W===210)Q=this.readI32();else if(W===211)if(this.useBigInt64)Q=this.readI64AsBigInt();else Q=this.readI64();else if(W===217){const V=this.lookU8();Q=this.decodeString(V,1)}else if(W===218){const V=this.lookU16();Q=this.decodeString(V,2)}else if(W===219){const V=this.lookU32();Q=this.decodeString(V,4)}else if(W===220){const V=this.readU16();if(V!==0){this.pushArrayState(V),this.complete();continue W}else Q=[]}else if(W===221){const V=this.readU32();if(V!==0){this.pushArrayState(V),this.complete();continue W}else Q=[]}else if(W===222){const V=this.readU16();if(V!==0){this.pushMapState(V),this.complete();continue W}else Q={}}else if(W===223){const V=this.readU32();if(V!==0){this.pushMapState(V),this.complete();continue W}else Q={}}else if(W===196){const V=this.lookU8();Q=this.decodeBinary(V,1)}else if(W===197){const V=this.lookU16();Q=this.decodeBinary(V,2)}else if(W===198){const V=this.lookU32();Q=this.decodeBinary(V,4)}else if(W===212)Q=this.decodeExtension(1,0);else if(W===213)Q=this.decodeExtension(2,0);else if(W===214)Q=this.decodeExtension(4,0);else if(W===215)Q=this.decodeExtension(8,0);else if(W===216)Q=this.decodeExtension(16,0);else if(W===199){const V=this.lookU8();Q=this.decodeExtension(V,1)}else if(W===200){const V=this.lookU16();Q=this.decodeExtension(V,2)}else if(W===201){const V=this.lookU32();Q=this.decodeExtension(V,4)}else throw new Y0(`Unrecognized type byte: ${V8(W)}`);this.complete();const J=this.stack;while(J.length>0){const V=J.top();if(V.type===b8)if(V.array[V.position]=Q,V.position++,V.position===V.size)Q=V.array,J.release(V);else continue W;else if(V.type===w1){if(Q==="__proto__")throw new Y0("The key __proto__ is not allowed");V.key=this.mapKeyConverter(Q),V.type=V5;continue W}else if(V.map[V.key]=Q,V.readCount++,V.readCount===V.size)Q=V.map,J.release(V);else{V.key=null,V.type=w1;continue W}}return Q}}readHeadByte(){if(this.headByte===x1)this.headByte=this.readU8();return this.headByte}complete(){this.headByte=x1}readArraySize(){const W=this.readHeadByte();switch(W){case 220:return this.readU16();case 221:return this.readU32();default:if(W<160)return W-144;else throw new Y0(`Unrecognized array type byte: ${V8(W)}`)}}pushMapState(W){if(W>this.maxMapLength)throw new Y0(`Max length exceeded: map length (${W}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(W)}pushArrayState(W){if(W>this.maxArrayLength)throw new Y0(`Max length exceeded: array length (${W}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(W)}decodeString(W,Q){if(!this.rawStrings||this.stateIsMapKey())return this.decodeUtf8String(W,Q);return this.decodeBinary(W,Q)}decodeUtf8String(W,Q){if(W>this.maxStrLength)throw new Y0(`Max length exceeded: UTF-8 byte length (${W}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+Q+W)throw Q5;const J=this.pos+Q;let V;if(this.stateIsMapKey()&&this.keyDecoder?.canBeCached(W))V=this.keyDecoder.decode(this.bytes,J,W);else V=e6(this.bytes,J,W);return this.pos+=Q+W,V}stateIsMapKey(){if(this.stack.length>0)return this.stack.top().type===w1;return!1}decodeBinary(W,Q){if(W>this.maxBinLength)throw new Y0(`Max length exceeded: bin length (${W}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(W+Q))throw Q5;const J=this.pos+Q,V=this.bytes.subarray(J,J+W);return this.pos+=Q+W,V}decodeExtension(W,Q){if(W>this.maxExtLength)throw new Y0(`Max length exceeded: ext length (${W}) > maxExtLength (${this.maxExtLength})`);const J=this.view.getInt8(this.pos+Q),V=this.decodeBinary(W,Q+1);return this.extensionCodec.decode(V,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(){const W=this.view.getUint8(this.pos);return this.pos++,W}readI8(){const W=this.view.getInt8(this.pos);return this.pos++,W}readU16(){const W=this.view.getUint16(this.pos);return this.pos+=2,W}readI16(){const W=this.view.getInt16(this.pos);return this.pos+=2,W}readU32(){const W=this.view.getUint32(this.pos);return this.pos+=4,W}readI32(){const W=this.view.getInt32(this.pos);return this.pos+=4,W}readU64(){const W=W5(this.view,this.pos);return this.pos+=8,W}readI64(){const W=J8(this.view,this.pos);return this.pos+=8,W}readU64AsBigInt(){const W=this.view.getBigUint64(this.pos);return this.pos+=8,W}readI64AsBigInt(){const W=this.view.getBigInt64(this.pos);return this.pos+=8,W}readF32(){const W=this.view.getFloat32(this.pos);return this.pos+=4,W}readF64(){const W=this.view.getFloat64(this.pos);return this.pos+=8,W}}function N1(W,Q){return new G8(Q).decode(W)}var F1=function(W){let Q=W.length;while(--Q>=0)W[Q]=0},m8=function(W,Q,J,V,G){this.static_tree=W,this.extra_bits=Q,this.extra_base=J,this.elems=V,this.max_length=G,this.has_stree=W&&W.length},_8=function(W,Q){this.dyn_tree=W,this.max_code=0,this.stat_desc=Q},B0=function(W,Q,J,V,G){this.good_length=W,this.max_lazy=Q,this.nice_length=J,this.max_chain=V,this.func=G},U9=function(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=H8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(tJ*2),this.dyn_dtree=new Uint16Array((2*sJ+1)*2),this.bl_tree=new Uint16Array((2*eJ+1)*2),g0(this.dyn_ltree),g0(this.dyn_dtree),g0(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(W9+1),this.heap=new Uint16Array(2*V6+1),g0(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*V6+1),g0(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0},v9=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},l1=function(W){this.options=k8.assign({level:f9,method:b9,chunkSize:16384,windowBits:15,memLevel:8,strategy:p9},W||{});let Q=this.options;if(Q.raw&&Q.windowBits>0)Q.windowBits=-Q.windowBits;else if(Q.gzip&&Q.windowBits>0&&Q.windowBits<16)Q.windowBits+=16;this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new K7,this.strm.avail_out=0;let J=g1.deflateInit2(this.strm,Q.level,Q.method,Q.windowBits,Q.memLevel,Q.strategy);if(J!==z8)throw new Error(d0[J]);if(Q.header)g1.deflateSetHeader(this.strm,Q.header);if(Q.dictionary){let V;if(typeof Q.dictionary==="string")V=m1.string2buf(Q.dictionary);else if(F7.call(Q.dictionary)==="[object ArrayBuffer]")V=new Uint8Array(Q.dictionary);else V=Q.dictionary;if(J=g1.deflateSetDictionary(this.strm,V),J!==z8)throw new Error(d0[J]);this._dict_set=!0}},H6=function(W,Q){const J=new l1(Q);if(J.push(W,!0),J.err)throw J.msg||d0[J.err];return J.result},h9=function(W,Q){return Q=Q||{},Q.raw=!0,H6(W,Q)},u9=function(W,Q){return Q=Q||{},Q.gzip=!0,H6(W,Q)},PQ=function(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0},xQ=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},i1=function(W){this.options=k8.assign({chunkSize:65536,windowBits:15,to:""},W||{});const Q=this.options;if(Q.raw&&Q.windowBits>=0&&Q.windowBits<16){if(Q.windowBits=-Q.windowBits,Q.windowBits===0)Q.windowBits=-15}if(Q.windowBits>=0&&Q.windowBits<16&&!(W&&W.windowBits))Q.windowBits+=32;if(Q.windowBits>15&&Q.windowBits<48){if((Q.windowBits&15)===0)Q.windowBits|=15}this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new K7,this.strm.avail_out=0;let J=w0.inflateInit2(this.strm,Q.windowBits);if(J!==_1)throw new Error(d0[J]);if(this.header=new wQ,w0.inflateGetHeader(this.strm,this.header),Q.dictionary){if(typeof Q.dictionary==="string")Q.dictionary=m1.string2buf(Q.dictionary);else if(I7.call(Q.dictionary)==="[object ArrayBuffer]")Q.dictionary=new Uint8Array(Q.dictionary);if(Q.raw){if(J=w0.inflateSetDictionary(this.strm,Q.dictionary),J!==_1)throw new Error(d0[J])}}},k6=function(W,Q){const J=new i1(Q);if(J.push(W),J.err)throw J.msg||d0[J.err];return J.result},TQ=function(W,Q){return Q=Q||{},Q.raw=!0,k6(W,Q)};/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */var qJ=0,c5=1,UJ=2,PJ=3,KJ=258,P6=29,c1=256,y1=c1+1+P6,U1=30,K6=19,d5=2*y1+1,m0=15,u8=16,FJ=7,F6=256,l5=16,i5=17,r5=18,W6=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),K8=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),zJ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),n5=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ZJ=512,x0=new Array((y1+2)*2);F1(x0);var T1=new Array(U1*2);F1(T1);var f1=new Array(ZJ);F1(f1);var p1=new Array(KJ-PJ+1);F1(p1);var z6=new Array(P6);F1(z6);var F8=new Array(U1);F1(F8);var o5,a5,s5,e5=(W)=>{return W<256?f1[W]:f1[256+(W>>>7)]},b1=(W,Q)=>{W.pending_buf[W.pending++]=Q&255,W.pending_buf[W.pending++]=Q>>>8&255},P0=(W,Q,J)=>{if(W.bi_valid>u8-J)W.bi_buf|=Q<<W.bi_valid&65535,b1(W,W.bi_buf),W.bi_buf=Q>>u8-W.bi_valid,W.bi_valid+=J-u8;else W.bi_buf|=Q<<W.bi_valid&65535,W.bi_valid+=J},R0=(W,Q,J)=>{P0(W,J[Q*2],J[Q*2+1])},t5=(W,Q)=>{let J=0;do J|=W&1,W>>>=1,J<<=1;while(--Q>0);return J>>>1},HJ=(W)=>{if(W.bi_valid===16)b1(W,W.bi_buf),W.bi_buf=0,W.bi_valid=0;else if(W.bi_valid>=8)W.pending_buf[W.pending++]=W.bi_buf&255,W.bi_buf>>=8,W.bi_valid-=8},kJ=(W,Q)=>{const{dyn_tree:J,max_code:V}=Q,G=Q.stat_desc.static_tree,X=Q.stat_desc.has_stree,Y=Q.stat_desc.extra_bits,q=Q.stat_desc.extra_base,F=Q.stat_desc.max_length;let U,P,C,K,z,$,N=0;for(K=0;K<=m0;K++)W.bl_count[K]=0;J[W.heap[W.heap_max]*2+1]=0;for(U=W.heap_max+1;U<d5;U++){if(P=W.heap[U],K=J[J[P*2+1]*2+1]+1,K>F)K=F,N++;if(J[P*2+1]=K,P>V)continue;if(W.bl_count[K]++,z=0,P>=q)z=Y[P-q];if($=J[P*2],W.opt_len+=$*(K+z),X)W.static_len+=$*(G[P*2+1]+z)}if(N===0)return;do{K=F-1;while(W.bl_count[K]===0)K--;W.bl_count[K]--,W.bl_count[K+1]+=2,W.bl_count[F]--,N-=2}while(N>0);for(K=F;K!==0;K--){P=W.bl_count[K];while(P!==0){if(C=W.heap[--U],C>V)continue;if(J[C*2+1]!==K)W.opt_len+=(K-J[C*2+1])*J[C*2],J[C*2+1]=K;P--}}},W7=(W,Q,J)=>{const V=new Array(m0+1);let G=0,X,Y;for(X=1;X<=m0;X++)G=G+J[X-1]<<1,V[X]=G;for(Y=0;Y<=Q;Y++){let q=W[Y*2+1];if(q===0)continue;W[Y*2]=t5(V[q]++,q)}},$J=()=>{let W,Q,J,V,G;const X=new Array(m0+1);J=0;for(V=0;V<P6-1;V++){z6[V]=J;for(W=0;W<1<<W6[V];W++)p1[J++]=V}p1[J-1]=V,G=0;for(V=0;V<16;V++){F8[V]=G;for(W=0;W<1<<K8[V];W++)f1[G++]=V}G>>=7;for(;V<U1;V++){F8[V]=G<<7;for(W=0;W<1<<K8[V]-7;W++)f1[256+G++]=V}for(Q=0;Q<=m0;Q++)X[Q]=0;W=0;while(W<=143)x0[W*2+1]=8,W++,X[8]++;while(W<=255)x0[W*2+1]=9,W++,X[9]++;while(W<=279)x0[W*2+1]=7,W++,X[7]++;while(W<=287)x0[W*2+1]=8,W++,X[8]++;W7(x0,y1+1,X);for(W=0;W<U1;W++)T1[W*2+1]=5,T1[W*2]=t5(W,5);o5=new m8(x0,W6,c1+1,y1,m0),a5=new m8(T1,K8,0,U1,m0),s5=new m8(new Array(0),zJ,0,K6,FJ)},J7=(W)=>{let Q;for(Q=0;Q<y1;Q++)W.dyn_ltree[Q*2]=0;for(Q=0;Q<U1;Q++)W.dyn_dtree[Q*2]=0;for(Q=0;Q<K6;Q++)W.bl_tree[Q*2]=0;W.dyn_ltree[F6*2]=1,W.opt_len=W.static_len=0,W.sym_next=W.matches=0},Q7=(W)=>{if(W.bi_valid>8)b1(W,W.bi_buf);else if(W.bi_valid>0)W.pending_buf[W.pending++]=W.bi_buf;W.bi_buf=0,W.bi_valid=0},X5=(W,Q,J,V)=>{const G=Q*2,X=J*2;return W[G]<W[X]||W[G]===W[X]&&V[Q]<=V[J]},c8=(W,Q,J)=>{const V=W.heap[J];let G=J<<1;while(G<=W.heap_len){if(G<W.heap_len&&X5(Q,W.heap[G+1],W.heap[G],W.depth))G++;if(X5(Q,V,W.heap[G],W.depth))break;W.heap[J]=W.heap[G],J=G,G<<=1}W.heap[J]=V},Y5=(W,Q,J)=>{let V,G,X=0,Y,q;if(W.sym_next!==0)do if(V=W.pending_buf[W.sym_buf+X++]&255,V+=(W.pending_buf[W.sym_buf+X++]&255)<<8,G=W.pending_buf[W.sym_buf+X++],V===0)R0(W,G,Q);else{if(Y=p1[G],R0(W,Y+c1+1,Q),q=W6[Y],q!==0)G-=z6[Y],P0(W,G,q);if(V--,Y=e5(V),R0(W,Y,J),q=K8[Y],q!==0)V-=F8[Y],P0(W,V,q)}while(X<W.sym_next);R0(W,F6,Q)},J6=(W,Q)=>{const J=Q.dyn_tree,V=Q.stat_desc.static_tree,G=Q.stat_desc.has_stree,X=Q.stat_desc.elems;let Y,q,F=-1,U;W.heap_len=0,W.heap_max=d5;for(Y=0;Y<X;Y++)if(J[Y*2]!==0)W.heap[++W.heap_len]=F=Y,W.depth[Y]=0;else J[Y*2+1]=0;while(W.heap_len<2)if(U=W.heap[++W.heap_len]=F<2?++F:0,J[U*2]=1,W.depth[U]=0,W.opt_len--,G)W.static_len-=V[U*2+1];Q.max_code=F;for(Y=W.heap_len>>1;Y>=1;Y--)c8(W,J,Y);U=X;do Y=W.heap[1],W.heap[1]=W.heap[W.heap_len--],c8(W,J,1),q=W.heap[1],W.heap[--W.heap_max]=Y,W.heap[--W.heap_max]=q,J[U*2]=J[Y*2]+J[q*2],W.depth[U]=(W.depth[Y]>=W.depth[q]?W.depth[Y]:W.depth[q])+1,J[Y*2+1]=J[q*2+1]=U,W.heap[1]=U++,c8(W,J,1);while(W.heap_len>=2);W.heap[--W.heap_max]=W.heap[1],kJ(W,Q),W7(J,F,W.bl_count)},q5=(W,Q,J)=>{let V,G=-1,X,Y=Q[1],q=0,F=7,U=4;if(Y===0)F=138,U=3;Q[(J+1)*2+1]=65535;for(V=0;V<=J;V++){if(X=Y,Y=Q[(V+1)*2+1],++q<F&&X===Y)continue;else if(q<U)W.bl_tree[X*2]+=q;else if(X!==0){if(X!==G)W.bl_tree[X*2]++;W.bl_tree[l5*2]++}else if(q<=10)W.bl_tree[i5*2]++;else W.bl_tree[r5*2]++;if(q=0,G=X,Y===0)F=138,U=3;else if(X===Y)F=6,U=3;else F=7,U=4}},U5=(W,Q,J)=>{let V,G=-1,X,Y=Q[1],q=0,F=7,U=4;if(Y===0)F=138,U=3;for(V=0;V<=J;V++){if(X=Y,Y=Q[(V+1)*2+1],++q<F&&X===Y)continue;else if(q<U)do R0(W,X,W.bl_tree);while(--q!==0);else if(X!==0){if(X!==G)R0(W,X,W.bl_tree),q--;R0(W,l5,W.bl_tree),P0(W,q-3,2)}else if(q<=10)R0(W,i5,W.bl_tree),P0(W,q-3,3);else R0(W,r5,W.bl_tree),P0(W,q-11,7);if(q=0,G=X,Y===0)F=138,U=3;else if(X===Y)F=6,U=3;else F=7,U=4}},CJ=(W)=>{let Q;q5(W,W.dyn_ltree,W.l_desc.max_code),q5(W,W.dyn_dtree,W.d_desc.max_code),J6(W,W.bl_desc);for(Q=K6-1;Q>=3;Q--)if(W.bl_tree[n5[Q]*2+1]!==0)break;return W.opt_len+=3*(Q+1)+5+5+4,Q},jJ=(W,Q,J,V)=>{let G;P0(W,Q-257,5),P0(W,J-1,5),P0(W,V-4,4);for(G=0;G<V;G++)P0(W,W.bl_tree[n5[G]*2+1],3);U5(W,W.dyn_ltree,Q-1),U5(W,W.dyn_dtree,J-1)},BJ=(W)=>{let Q=4093624447,J;for(J=0;J<=31;J++,Q>>>=1)if(Q&1&&W.dyn_ltree[J*2]!==0)return 0;if(W.dyn_ltree[18]!==0||W.dyn_ltree[20]!==0||W.dyn_ltree[26]!==0)return 1;for(J=32;J<c1;J++)if(W.dyn_ltree[J*2]!==0)return 1;return 0},P5=!1,RJ=(W)=>{if(!P5)$J(),P5=!0;W.l_desc=new _8(W.dyn_ltree,o5),W.d_desc=new _8(W.dyn_dtree,a5),W.bl_desc=new _8(W.bl_tree,s5),W.bi_buf=0,W.bi_valid=0,J7(W)},V7=(W,Q,J,V)=>{if(P0(W,(qJ<<1)+(V?1:0),3),Q7(W),b1(W,J),b1(W,~J),J)W.pending_buf.set(W.window.subarray(Q,Q+J),W.pending);W.pending+=J},MJ=(W)=>{P0(W,c5<<1,3),R0(W,F6,x0),HJ(W)},LJ=(W,Q,J,V)=>{let G,X,Y=0;if(W.level>0){if(W.strm.data_type===2)W.strm.data_type=BJ(W);if(J6(W,W.l_desc),J6(W,W.d_desc),Y=CJ(W),G=W.opt_len+3+7>>>3,X=W.static_len+3+7>>>3,X<=G)G=X}else G=X=J+5;if(J+4<=G&&Q!==-1)V7(W,Q,J,V);else if(W.strategy===4||X===G)P0(W,(c5<<1)+(V?1:0),3),Y5(W,x0,T1);else P0(W,(UJ<<1)+(V?1:0),3),jJ(W,W.l_desc.max_code+1,W.d_desc.max_code+1,Y+1),Y5(W,W.dyn_ltree,W.dyn_dtree);if(J7(W),V)Q7(W)},IJ=(W,Q,J)=>{if(W.pending_buf[W.sym_buf+W.sym_next++]=Q,W.pending_buf[W.sym_buf+W.sym_next++]=Q>>8,W.pending_buf[W.sym_buf+W.sym_next++]=J,Q===0)W.dyn_ltree[J*2]++;else W.matches++,Q--,W.dyn_ltree[(p1[J]+c1+1)*2]++,W.dyn_dtree[e5(Q)*2]++;return W.sym_next===W.sym_end},DJ=RJ,OJ=V7,xJ=LJ,wJ=IJ,NJ=MJ,SJ={_tr_init:DJ,_tr_stored_block:OJ,_tr_flush_block:xJ,_tr_tally:wJ,_tr_align:NJ},vJ=(W,Q,J,V)=>{let G=W&65535|0,X=W>>>16&65535|0,Y=0;while(J!==0){Y=J>2000?2000:J,J-=Y;do G=G+Q[V++]|0,X=X+G|0;while(--Y);G%=65521,X%=65521}return G|X<<16|0},h1=vJ,AJ=()=>{let W,Q=[];for(var J=0;J<256;J++){W=J;for(var V=0;V<8;V++)W=W&1?3988292384^W>>>1:W>>>1;Q[J]=W}return Q},TJ=new Uint32Array(AJ()),gJ=(W,Q,J,V)=>{const G=TJ,X=V+J;W^=-1;for(let Y=V;Y<X;Y++)W=W>>>8^G[(W^Q[Y])&255];return W^-1},V0=gJ,d0={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},r0={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:EJ,_tr_stored_block:Q6,_tr_flush_block:yJ,_tr_tally:y0,_tr_align:fJ}=SJ,{Z_NO_FLUSH:f0,Z_PARTIAL_FLUSH:pJ,Z_FULL_FLUSH:bJ,Z_FINISH:H0,Z_BLOCK:K5,Z_OK:X0,Z_STREAM_END:F5,Z_STREAM_ERROR:M0,Z_DATA_ERROR:hJ,Z_BUF_ERROR:d8,Z_DEFAULT_COMPRESSION:uJ,Z_FILTERED:mJ,Z_HUFFMAN_ONLY:X8,Z_RLE:_J,Z_FIXED:cJ,Z_DEFAULT_STRATEGY:dJ,Z_UNKNOWN:lJ,Z_DEFLATED:H8}=r0,iJ=9,rJ=15,nJ=8,oJ=29,aJ=256,V6=aJ+1+oJ,sJ=30,eJ=19,tJ=2*V6+1,W9=15,s=3,E0=258,L0=E0+s+1,J9=32,P1=42,Z6=57,G6=69,X6=73,Y6=91,q6=103,_0=113,v1=666,q0=1,z1=2,l0=3,Z1=4,Q9=3,c0=(W,Q)=>{return W.msg=d0[Q],Q},z5=(W)=>{return W*2-(W>4?9:0)},g0=(W)=>{let Q=W.length;while(--Q>=0)W[Q]=0},V9=(W)=>{let Q,J,V,G=W.w_size;Q=W.hash_size,V=Q;do J=W.head[--V],W.head[V]=J>=G?J-G:0;while(--Q);Q=G,V=Q;do J=W.prev[--V],W.prev[V]=J>=G?J-G:0;while(--Q)},G9=(W,Q,J)=>(Q<<W.hash_shift^J)&W.hash_mask,p0=G9,F0=(W)=>{const Q=W.state;let J=Q.pending;if(J>W.avail_out)J=W.avail_out;if(J===0)return;if(W.output.set(Q.pending_buf.subarray(Q.pending_out,Q.pending_out+J),W.next_out),W.next_out+=J,Q.pending_out+=J,W.total_out+=J,W.avail_out-=J,Q.pending-=J,Q.pending===0)Q.pending_out=0},z0=(W,Q)=>{yJ(W,W.block_start>=0?W.block_start:-1,W.strstart-W.block_start,Q),W.block_start=W.strstart,F0(W.strm)},e=(W,Q)=>{W.pending_buf[W.pending++]=Q},S1=(W,Q)=>{W.pending_buf[W.pending++]=Q>>>8&255,W.pending_buf[W.pending++]=Q&255},U6=(W,Q,J,V)=>{let G=W.avail_in;if(G>V)G=V;if(G===0)return 0;if(W.avail_in-=G,Q.set(W.input.subarray(W.next_in,W.next_in+G),J),W.state.wrap===1)W.adler=h1(W.adler,Q,G,J);else if(W.state.wrap===2)W.adler=V0(W.adler,Q,G,J);return W.next_in+=G,W.total_in+=G,G},G7=(W,Q)=>{let{max_chain_length:J,strstart:V}=W,G,X,Y=W.prev_length,q=W.nice_match;const F=W.strstart>W.w_size-L0?W.strstart-(W.w_size-L0):0,U=W.window,P=W.w_mask,C=W.prev,K=W.strstart+E0;let z=U[V+Y-1],$=U[V+Y];if(W.prev_length>=W.good_match)J>>=2;if(q>W.lookahead)q=W.lookahead;do{if(G=Q,U[G+Y]!==$||U[G+Y-1]!==z||U[G]!==U[V]||U[++G]!==U[V+1])continue;V+=2,G++;do;while(U[++V]===U[++G]&&U[++V]===U[++G]&&U[++V]===U[++G]&&U[++V]===U[++G]&&U[++V]===U[++G]&&U[++V]===U[++G]&&U[++V]===U[++G]&&U[++V]===U[++G]&&V<K);if(X=E0-(K-V),V=K-E0,X>Y){if(W.match_start=Q,Y=X,X>=q)break;z=U[V+Y-1],$=U[V+Y]}}while((Q=C[Q&P])>F&&--J!==0);if(Y<=W.lookahead)return Y;return W.lookahead},K1=(W)=>{const Q=W.w_size;let J,V,G;do{if(V=W.window_size-W.lookahead-W.strstart,W.strstart>=Q+(Q-L0)){if(W.window.set(W.window.subarray(Q,Q+Q-V),0),W.match_start-=Q,W.strstart-=Q,W.block_start-=Q,W.insert>W.strstart)W.insert=W.strstart;V9(W),V+=Q}if(W.strm.avail_in===0)break;if(J=U6(W.strm,W.window,W.strstart+W.lookahead,V),W.lookahead+=J,W.lookahead+W.insert>=s){G=W.strstart-W.insert,W.ins_h=W.window[G],W.ins_h=p0(W,W.ins_h,W.window[G+1]);while(W.insert)if(W.ins_h=p0(W,W.ins_h,W.window[G+s-1]),W.prev[G&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=G,G++,W.insert--,W.lookahead+W.insert<s)break}}while(W.lookahead<L0&&W.strm.avail_in!==0)},X7=(W,Q)=>{let J=W.pending_buf_size-5>W.w_size?W.w_size:W.pending_buf_size-5,V,G,X,Y=0,q=W.strm.avail_in;do{if(V=65535,X=W.bi_valid+42>>3,W.strm.avail_out<X)break;if(X=W.strm.avail_out-X,G=W.strstart-W.block_start,V>G+W.strm.avail_in)V=G+W.strm.avail_in;if(V>X)V=X;if(V<J&&(V===0&&Q!==H0||Q===f0||V!==G+W.strm.avail_in))break;if(Y=Q===H0&&V===G+W.strm.avail_in?1:0,Q6(W,0,0,Y),W.pending_buf[W.pending-4]=V,W.pending_buf[W.pending-3]=V>>8,W.pending_buf[W.pending-2]=~V,W.pending_buf[W.pending-1]=~V>>8,F0(W.strm),G){if(G>V)G=V;W.strm.output.set(W.window.subarray(W.block_start,W.block_start+G),W.strm.next_out),W.strm.next_out+=G,W.strm.avail_out-=G,W.strm.total_out+=G,W.block_start+=G,V-=G}if(V)U6(W.strm,W.strm.output,W.strm.next_out,V),W.strm.next_out+=V,W.strm.avail_out-=V,W.strm.total_out+=V}while(Y===0);if(q-=W.strm.avail_in,q){if(q>=W.w_size)W.matches=2,W.window.set(W.strm.input.subarray(W.strm.next_in-W.w_size,W.strm.next_in),0),W.strstart=W.w_size,W.insert=W.strstart;else{if(W.window_size-W.strstart<=q){if(W.strstart-=W.w_size,W.window.set(W.window.subarray(W.w_size,W.w_size+W.strstart),0),W.matches<2)W.matches++;if(W.insert>W.strstart)W.insert=W.strstart}W.window.set(W.strm.input.subarray(W.strm.next_in-q,W.strm.next_in),W.strstart),W.strstart+=q,W.insert+=q>W.w_size-W.insert?W.w_size-W.insert:q}W.block_start=W.strstart}if(W.high_water<W.strstart)W.high_water=W.strstart;if(Y)return Z1;if(Q!==f0&&Q!==H0&&W.strm.avail_in===0&&W.strstart===W.block_start)return z1;if(X=W.window_size-W.strstart,W.strm.avail_in>X&&W.block_start>=W.w_size){if(W.block_start-=W.w_size,W.strstart-=W.w_size,W.window.set(W.window.subarray(W.w_size,W.w_size+W.strstart),0),W.matches<2)W.matches++;if(X+=W.w_size,W.insert>W.strstart)W.insert=W.strstart}if(X>W.strm.avail_in)X=W.strm.avail_in;if(X)U6(W.strm,W.window,W.strstart,X),W.strstart+=X,W.insert+=X>W.w_size-W.insert?W.w_size-W.insert:X;if(W.high_water<W.strstart)W.high_water=W.strstart;if(X=W.bi_valid+42>>3,X=W.pending_buf_size-X>65535?65535:W.pending_buf_size-X,J=X>W.w_size?W.w_size:X,G=W.strstart-W.block_start,G>=J||(G||Q===H0)&&Q!==f0&&W.strm.avail_in===0&&G<=X)V=G>X?X:G,Y=Q===H0&&W.strm.avail_in===0&&V===G?1:0,Q6(W,W.block_start,V,Y),W.block_start+=V,F0(W.strm);return Y?l0:q0},l8=(W,Q)=>{let J,V;for(;;){if(W.lookahead<L0){if(K1(W),W.lookahead<L0&&Q===f0)return q0;if(W.lookahead===0)break}if(J=0,W.lookahead>=s)W.ins_h=p0(W,W.ins_h,W.window[W.strstart+s-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;if(J!==0&&W.strstart-J<=W.w_size-L0)W.match_length=G7(W,J);if(W.match_length>=s)if(V=y0(W,W.strstart-W.match_start,W.match_length-s),W.lookahead-=W.match_length,W.match_length<=W.max_lazy_match&&W.lookahead>=s){W.match_length--;do W.strstart++,W.ins_h=p0(W,W.ins_h,W.window[W.strstart+s-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;while(--W.match_length!==0);W.strstart++}else W.strstart+=W.match_length,W.match_length=0,W.ins_h=W.window[W.strstart],W.ins_h=p0(W,W.ins_h,W.window[W.strstart+1]);else V=y0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++;if(V){if(z0(W,!1),W.strm.avail_out===0)return q0}}if(W.insert=W.strstart<s-1?W.strstart:s-1,Q===H0){if(z0(W,!0),W.strm.avail_out===0)return l0;return Z1}if(W.sym_next){if(z0(W,!1),W.strm.avail_out===0)return q0}return z1},Y1=(W,Q)=>{let J,V,G;for(;;){if(W.lookahead<L0){if(K1(W),W.lookahead<L0&&Q===f0)return q0;if(W.lookahead===0)break}if(J=0,W.lookahead>=s)W.ins_h=p0(W,W.ins_h,W.window[W.strstart+s-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;if(W.prev_length=W.match_length,W.prev_match=W.match_start,W.match_length=s-1,J!==0&&W.prev_length<W.max_lazy_match&&W.strstart-J<=W.w_size-L0){if(W.match_length=G7(W,J),W.match_length<=5&&(W.strategy===mJ||W.match_length===s&&W.strstart-W.match_start>4096))W.match_length=s-1}if(W.prev_length>=s&&W.match_length<=W.prev_length){G=W.strstart+W.lookahead-s,V=y0(W,W.strstart-1-W.prev_match,W.prev_length-s),W.lookahead-=W.prev_length-1,W.prev_length-=2;do if(++W.strstart<=G)W.ins_h=p0(W,W.ins_h,W.window[W.strstart+s-1]),J=W.prev[W.strstart&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=W.strstart;while(--W.prev_length!==0);if(W.match_available=0,W.match_length=s-1,W.strstart++,V){if(z0(W,!1),W.strm.avail_out===0)return q0}}else if(W.match_available){if(V=y0(W,0,W.window[W.strstart-1]),V)z0(W,!1);if(W.strstart++,W.lookahead--,W.strm.avail_out===0)return q0}else W.match_available=1,W.strstart++,W.lookahead--}if(W.match_available)V=y0(W,0,W.window[W.strstart-1]),W.match_available=0;if(W.insert=W.strstart<s-1?W.strstart:s-1,Q===H0){if(z0(W,!0),W.strm.avail_out===0)return l0;return Z1}if(W.sym_next){if(z0(W,!1),W.strm.avail_out===0)return q0}return z1},X9=(W,Q)=>{let J,V,G,X;const Y=W.window;for(;;){if(W.lookahead<=E0){if(K1(W),W.lookahead<=E0&&Q===f0)return q0;if(W.lookahead===0)break}if(W.match_length=0,W.lookahead>=s&&W.strstart>0){if(G=W.strstart-1,V=Y[G],V===Y[++G]&&V===Y[++G]&&V===Y[++G]){X=W.strstart+E0;do;while(V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&V===Y[++G]&&G<X);if(W.match_length=E0-(X-G),W.match_length>W.lookahead)W.match_length=W.lookahead}}if(W.match_length>=s)J=y0(W,1,W.match_length-s),W.lookahead-=W.match_length,W.strstart+=W.match_length,W.match_length=0;else J=y0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++;if(J){if(z0(W,!1),W.strm.avail_out===0)return q0}}if(W.insert=0,Q===H0){if(z0(W,!0),W.strm.avail_out===0)return l0;return Z1}if(W.sym_next){if(z0(W,!1),W.strm.avail_out===0)return q0}return z1},Y9=(W,Q)=>{let J;for(;;){if(W.lookahead===0){if(K1(W),W.lookahead===0){if(Q===f0)return q0;break}}if(W.match_length=0,J=y0(W,0,W.window[W.strstart]),W.lookahead--,W.strstart++,J){if(z0(W,!1),W.strm.avail_out===0)return q0}}if(W.insert=0,Q===H0){if(z0(W,!0),W.strm.avail_out===0)return l0;return Z1}if(W.sym_next){if(z0(W,!1),W.strm.avail_out===0)return q0}return z1},A1=[new B0(0,0,0,0,X7),new B0(4,4,8,4,l8),new B0(4,5,16,8,l8),new B0(4,6,32,32,l8),new B0(4,4,16,16,Y1),new B0(8,16,32,32,Y1),new B0(8,16,128,128,Y1),new B0(8,32,128,256,Y1),new B0(32,128,258,1024,Y1),new B0(32,258,258,4096,Y1)],q9=(W)=>{W.window_size=2*W.w_size,g0(W.head),W.max_lazy_match=A1[W.level].max_lazy,W.good_match=A1[W.level].good_length,W.nice_match=A1[W.level].nice_length,W.max_chain_length=A1[W.level].max_chain,W.strstart=0,W.block_start=0,W.lookahead=0,W.insert=0,W.match_length=W.prev_length=s-1,W.match_available=0,W.ins_h=0},d1=(W)=>{if(!W)return 1;const Q=W.state;if(!Q||Q.strm!==W||Q.status!==P1&&Q.status!==Z6&&Q.status!==G6&&Q.status!==X6&&Q.status!==Y6&&Q.status!==q6&&Q.status!==_0&&Q.status!==v1)return 1;return 0},Y7=(W)=>{if(d1(W))return c0(W,M0);W.total_in=W.total_out=0,W.data_type=lJ;const Q=W.state;if(Q.pending=0,Q.pending_out=0,Q.wrap<0)Q.wrap=-Q.wrap;return Q.status=Q.wrap===2?Z6:Q.wrap?P1:_0,W.adler=Q.wrap===2?0:1,Q.last_flush=-2,EJ(Q),X0},q7=(W)=>{const Q=Y7(W);if(Q===X0)q9(W.state);return Q},P9=(W,Q)=>{if(d1(W)||W.state.wrap!==2)return M0;return W.state.gzhead=Q,X0},U7=(W,Q,J,V,G,X)=>{if(!W)return M0;let Y=1;if(Q===uJ)Q=6;if(V<0)Y=0,V=-V;else if(V>15)Y=2,V-=16;if(G<1||G>iJ||J!==H8||V<8||V>15||Q<0||Q>9||X<0||X>cJ||V===8&&Y!==1)return c0(W,M0);if(V===8)V=9;const q=new U9;return W.state=q,q.strm=W,q.status=P1,q.wrap=Y,q.gzhead=null,q.w_bits=V,q.w_size=1<<q.w_bits,q.w_mask=q.w_size-1,q.hash_bits=G+7,q.hash_size=1<<q.hash_bits,q.hash_mask=q.hash_size-1,q.hash_shift=~~((q.hash_bits+s-1)/s),q.window=new Uint8Array(q.w_size*2),q.head=new Uint16Array(q.hash_size),q.prev=new Uint16Array(q.w_size),q.lit_bufsize=1<<G+6,q.pending_buf_size=q.lit_bufsize*4,q.pending_buf=new Uint8Array(q.pending_buf_size),q.sym_buf=q.lit_bufsize,q.sym_end=(q.lit_bufsize-1)*3,q.level=Q,q.strategy=X,q.method=J,q7(W)},K9=(W,Q)=>{return U7(W,Q,H8,rJ,nJ,dJ)},F9=(W,Q)=>{if(d1(W)||Q>K5||Q<0)return W?c0(W,M0):M0;const J=W.state;if(!W.output||W.avail_in!==0&&!W.input||J.status===v1&&Q!==H0)return c0(W,W.avail_out===0?d8:M0);const V=J.last_flush;if(J.last_flush=Q,J.pending!==0){if(F0(W),W.avail_out===0)return J.last_flush=-1,X0}else if(W.avail_in===0&&z5(Q)<=z5(V)&&Q!==H0)return c0(W,d8);if(J.status===v1&&W.avail_in!==0)return c0(W,d8);if(J.status===P1&&J.wrap===0)J.status=_0;if(J.status===P1){let G=H8+(J.w_bits-8<<4)<<8,X=-1;if(J.strategy>=X8||J.level<2)X=0;else if(J.level<6)X=1;else if(J.level===6)X=2;else X=3;if(G|=X<<6,J.strstart!==0)G|=J9;if(G+=31-G%31,S1(J,G),J.strstart!==0)S1(J,W.adler>>>16),S1(J,W.adler&65535);if(W.adler=1,J.status=_0,F0(W),J.pending!==0)return J.last_flush=-1,X0}if(J.status===Z6)if(W.adler=0,e(J,31),e(J,139),e(J,8),!J.gzhead){if(e(J,0),e(J,0),e(J,0),e(J,0),e(J,0),e(J,J.level===9?2:J.strategy>=X8||J.level<2?4:0),e(J,Q9),J.status=_0,F0(W),J.pending!==0)return J.last_flush=-1,X0}else{if(e(J,(J.gzhead.text?1:0)+(J.gzhead.hcrc?2:0)+(!J.gzhead.extra?0:4)+(!J.gzhead.name?0:8)+(!J.gzhead.comment?0:16)),e(J,J.gzhead.time&255),e(J,J.gzhead.time>>8&255),e(J,J.gzhead.time>>16&255),e(J,J.gzhead.time>>24&255),e(J,J.level===9?2:J.strategy>=X8||J.level<2?4:0),e(J,J.gzhead.os&255),J.gzhead.extra&&J.gzhead.extra.length)e(J,J.gzhead.extra.length&255),e(J,J.gzhead.extra.length>>8&255);if(J.gzhead.hcrc)W.adler=V0(W.adler,J.pending_buf,J.pending,0);J.gzindex=0,J.status=G6}if(J.status===G6){if(J.gzhead.extra){let G=J.pending,X=(J.gzhead.extra.length&65535)-J.gzindex;while(J.pending+X>J.pending_buf_size){let q=J.pending_buf_size-J.pending;if(J.pending_buf.set(J.gzhead.extra.subarray(J.gzindex,J.gzindex+q),J.pending),J.pending=J.pending_buf_size,J.gzhead.hcrc&&J.pending>G)W.adler=V0(W.adler,J.pending_buf,J.pending-G,G);if(J.gzindex+=q,F0(W),J.pending!==0)return J.last_flush=-1,X0;G=0,X-=q}let Y=new Uint8Array(J.gzhead.extra);if(J.pending_buf.set(Y.subarray(J.gzindex,J.gzindex+X),J.pending),J.pending+=X,J.gzhead.hcrc&&J.pending>G)W.adler=V0(W.adler,J.pending_buf,J.pending-G,G);J.gzindex=0}J.status=X6}if(J.status===X6){if(J.gzhead.name){let G=J.pending,X;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>G)W.adler=V0(W.adler,J.pending_buf,J.pending-G,G);if(F0(W),J.pending!==0)return J.last_flush=-1,X0;G=0}if(J.gzindex<J.gzhead.name.length)X=J.gzhead.name.charCodeAt(J.gzindex++)&255;else X=0;e(J,X)}while(X!==0);if(J.gzhead.hcrc&&J.pending>G)W.adler=V0(W.adler,J.pending_buf,J.pending-G,G);J.gzindex=0}J.status=Y6}if(J.status===Y6){if(J.gzhead.comment){let G=J.pending,X;do{if(J.pending===J.pending_buf_size){if(J.gzhead.hcrc&&J.pending>G)W.adler=V0(W.adler,J.pending_buf,J.pending-G,G);if(F0(W),J.pending!==0)return J.last_flush=-1,X0;G=0}if(J.gzindex<J.gzhead.comment.length)X=J.gzhead.comment.charCodeAt(J.gzindex++)&255;else X=0;e(J,X)}while(X!==0);if(J.gzhead.hcrc&&J.pending>G)W.adler=V0(W.adler,J.pending_buf,J.pending-G,G)}J.status=q6}if(J.status===q6){if(J.gzhead.hcrc){if(J.pending+2>J.pending_buf_size){if(F0(W),J.pending!==0)return J.last_flush=-1,X0}e(J,W.adler&255),e(J,W.adler>>8&255),W.adler=0}if(J.status=_0,F0(W),J.pending!==0)return J.last_flush=-1,X0}if(W.avail_in!==0||J.lookahead!==0||Q!==f0&&J.status!==v1){let G=J.level===0?X7(J,Q):J.strategy===X8?Y9(J,Q):J.strategy===_J?X9(J,Q):A1[J.level].func(J,Q);if(G===l0||G===Z1)J.status=v1;if(G===q0||G===l0){if(W.avail_out===0)J.last_flush=-1;return X0}if(G===z1){if(Q===pJ)fJ(J);else if(Q!==K5){if(Q6(J,0,0,!1),Q===bJ){if(g0(J.head),J.lookahead===0)J.strstart=0,J.block_start=0,J.insert=0}}if(F0(W),W.avail_out===0)return J.last_flush=-1,X0}}if(Q!==H0)return X0;if(J.wrap<=0)return F5;if(J.wrap===2)e(J,W.adler&255),e(J,W.adler>>8&255),e(J,W.adler>>16&255),e(J,W.adler>>24&255),e(J,W.total_in&255),e(J,W.total_in>>8&255),e(J,W.total_in>>16&255),e(J,W.total_in>>24&255);else S1(J,W.adler>>>16),S1(J,W.adler&65535);if(F0(W),J.wrap>0)J.wrap=-J.wrap;return J.pending!==0?X0:F5},z9=(W)=>{if(d1(W))return M0;const Q=W.state.status;return W.state=null,Q===_0?c0(W,hJ):X0},Z9=(W,Q)=>{let J=Q.length;if(d1(W))return M0;const V=W.state,G=V.wrap;if(G===2||G===1&&V.status!==P1||V.lookahead)return M0;if(G===1)W.adler=h1(W.adler,Q,J,0);if(V.wrap=0,J>=V.w_size){if(G===0)g0(V.head),V.strstart=0,V.block_start=0,V.insert=0;let F=new Uint8Array(V.w_size);F.set(Q.subarray(J-V.w_size,J),0),Q=F,J=V.w_size}const{avail_in:X,next_in:Y,input:q}=W;W.avail_in=J,W.next_in=0,W.input=Q,K1(V);while(V.lookahead>=s){let F=V.strstart,U=V.lookahead-(s-1);do V.ins_h=p0(V,V.ins_h,V.window[F+s-1]),V.prev[F&V.w_mask]=V.head[V.ins_h],V.head[V.ins_h]=F,F++;while(--U);V.strstart=F,V.lookahead=s-1,K1(V)}return V.strstart+=V.lookahead,V.block_start=V.strstart,V.insert=V.lookahead,V.lookahead=0,V.match_length=V.prev_length=s-1,V.match_available=0,W.next_in=Y,W.input=q,W.avail_in=X,V.wrap=G,X0},H9=K9,k9=U7,$9=q7,C9=Y7,j9=P9,B9=F9,R9=z9,M9=Z9,L9="pako deflate (from Nodeca project)",g1={deflateInit:H9,deflateInit2:k9,deflateReset:$9,deflateResetKeep:C9,deflateSetHeader:j9,deflate:B9,deflateEnd:R9,deflateSetDictionary:M9,deflateInfo:L9},I9=(W,Q)=>{return Object.prototype.hasOwnProperty.call(W,Q)},D9=function(W){const Q=Array.prototype.slice.call(arguments,1);while(Q.length){const J=Q.shift();if(!J)continue;if(typeof J!=="object")throw new TypeError(J+"must be non-object");for(let V in J)if(I9(J,V))W[V]=J[V]}return W},O9=(W)=>{let Q=0;for(let V=0,G=W.length;V<G;V++)Q+=W[V].length;const J=new Uint8Array(Q);for(let V=0,G=0,X=W.length;V<X;V++){let Y=W[V];J.set(Y,G),G+=Y.length}return J},k8={assign:D9,flattenChunks:O9},P7=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(W){P7=!1}var u1=new Uint8Array(256);for(let W=0;W<256;W++)u1[W]=W>=252?6:W>=248?5:W>=240?4:W>=224?3:W>=192?2:1;u1[254]=u1[254]=1;var x9=(W)=>{if(typeof TextEncoder==="function"&&TextEncoder.prototype.encode)return(new TextEncoder()).encode(W);let Q,J,V,G,X,Y=W.length,q=0;for(G=0;G<Y;G++){if(J=W.charCodeAt(G),(J&64512)===55296&&G+1<Y){if(V=W.charCodeAt(G+1),(V&64512)===56320)J=65536+(J-55296<<10)+(V-56320),G++}q+=J<128?1:J<2048?2:J<65536?3:4}Q=new Uint8Array(q);for(X=0,G=0;X<q;G++){if(J=W.charCodeAt(G),(J&64512)===55296&&G+1<Y){if(V=W.charCodeAt(G+1),(V&64512)===56320)J=65536+(J-55296<<10)+(V-56320),G++}if(J<128)Q[X++]=J;else if(J<2048)Q[X++]=192|J>>>6,Q[X++]=128|J&63;else if(J<65536)Q[X++]=224|J>>>12,Q[X++]=128|J>>>6&63,Q[X++]=128|J&63;else Q[X++]=240|J>>>18,Q[X++]=128|J>>>12&63,Q[X++]=128|J>>>6&63,Q[X++]=128|J&63}return Q},w9=(W,Q)=>{if(Q<65534){if(W.subarray&&P7)return String.fromCharCode.apply(null,W.length===Q?W:W.subarray(0,Q))}let J="";for(let V=0;V<Q;V++)J+=String.fromCharCode(W[V]);return J},N9=(W,Q)=>{const J=Q||W.length;if(typeof TextDecoder==="function"&&TextDecoder.prototype.decode)return(new TextDecoder()).decode(W.subarray(0,Q));let V,G;const X=new Array(J*2);for(G=0,V=0;V<J;){let Y=W[V++];if(Y<128){X[G++]=Y;continue}let q=u1[Y];if(q>4){X[G++]=65533,V+=q-1;continue}Y&=q===2?31:q===3?15:7;while(q>1&&V<J)Y=Y<<6|W[V++]&63,q--;if(q>1){X[G++]=65533;continue}if(Y<65536)X[G++]=Y;else Y-=65536,X[G++]=55296|Y>>10&1023,X[G++]=56320|Y&1023}return w9(X,G)},S9=(W,Q)=>{if(Q=Q||W.length,Q>W.length)Q=W.length;let J=Q-1;while(J>=0&&(W[J]&192)===128)J--;if(J<0)return Q;if(J===0)return Q;return J+u1[W[J]]>Q?J:Q},m1={string2buf:x9,buf2string:N9,utf8border:S9},K7=v9,F7=Object.prototype.toString,{Z_NO_FLUSH:A9,Z_SYNC_FLUSH:T9,Z_FULL_FLUSH:g9,Z_FINISH:E9,Z_OK:z8,Z_STREAM_END:y9,Z_DEFAULT_COMPRESSION:f9,Z_DEFAULT_STRATEGY:p9,Z_DEFLATED:b9}=r0;l1.prototype.push=function(W,Q){const J=this.strm,V=this.options.chunkSize;let G,X;if(this.ended)return!1;if(Q===~~Q)X=Q;else X=Q===!0?E9:A9;if(typeof W==="string")J.input=m1.string2buf(W);else if(F7.call(W)==="[object ArrayBuffer]")J.input=new Uint8Array(W);else J.input=W;J.next_in=0,J.avail_in=J.input.length;for(;;){if(J.avail_out===0)J.output=new Uint8Array(V),J.next_out=0,J.avail_out=V;if((X===T9||X===g9)&&J.avail_out<=6){this.onData(J.output.subarray(0,J.next_out)),J.avail_out=0;continue}if(G=g1.deflate(J,X),G===y9){if(J.next_out>0)this.onData(J.output.subarray(0,J.next_out));return G=g1.deflateEnd(this.strm),this.onEnd(G),this.ended=!0,G===z8}if(J.avail_out===0){this.onData(J.output);continue}if(X>0&&J.next_out>0){this.onData(J.output.subarray(0,J.next_out)),J.avail_out=0;continue}if(J.avail_in===0)break}return!0};l1.prototype.onData=function(W){this.chunks.push(W)};l1.prototype.onEnd=function(W){if(W===z8)this.result=k8.flattenChunks(this.chunks);this.chunks=[],this.err=W,this.msg=this.strm.msg};var m9=l1,_9=H6,c9=h9,d9=u9,l9=r0,i9={Deflate:m9,deflate:_9,deflateRaw:c9,gzip:d9,constants:l9},Y8=16209,r9=16191,n9=function W(Q,J){let V,G,X,Y,q,F,U,P,C,K,z,$,N,g,p,f,u,x,c,a,I,M,w,Z;const H=Q.state;V=Q.next_in,w=Q.input,G=V+(Q.avail_in-5),X=Q.next_out,Z=Q.output,Y=X-(J-Q.avail_out),q=X+(Q.avail_out-257),F=H.dmax,U=H.wsize,P=H.whave,C=H.wnext,K=H.window,z=H.hold,$=H.bits,N=H.lencode,g=H.distcode,p=(1<<H.lenbits)-1,f=(1<<H.distbits)-1;W:do{if($<15)z+=w[V++]<<$,$+=8,z+=w[V++]<<$,$+=8;u=N[z&p];J:for(;;){if(x=u>>>24,z>>>=x,$-=x,x=u>>>16&255,x===0)Z[X++]=u&65535;else if(x&16){if(c=u&65535,x&=15,x){if($<x)z+=w[V++]<<$,$+=8;c+=z&(1<<x)-1,z>>>=x,$-=x}if($<15)z+=w[V++]<<$,$+=8,z+=w[V++]<<$,$+=8;u=g[z&f];Q:for(;;){if(x=u>>>24,z>>>=x,$-=x,x=u>>>16&255,x&16){if(a=u&65535,x&=15,$<x){if(z+=w[V++]<<$,$+=8,$<x)z+=w[V++]<<$,$+=8}if(a+=z&(1<<x)-1,a>F){Q.msg="invalid distance too far back",H.mode=Y8;break W}if(z>>>=x,$-=x,x=X-Y,a>x){if(x=a-x,x>P){if(H.sane){Q.msg="invalid distance too far back",H.mode=Y8;break W}}if(I=0,M=K,C===0){if(I+=U-x,x<c){c-=x;do Z[X++]=K[I++];while(--x);I=X-a,M=Z}}else if(C<x){if(I+=U+C-x,x-=C,x<c){c-=x;do Z[X++]=K[I++];while(--x);if(I=0,C<c){x=C,c-=x;do Z[X++]=K[I++];while(--x);I=X-a,M=Z}}}else if(I+=C-x,x<c){c-=x;do Z[X++]=K[I++];while(--x);I=X-a,M=Z}while(c>2)Z[X++]=M[I++],Z[X++]=M[I++],Z[X++]=M[I++],c-=3;if(c){if(Z[X++]=M[I++],c>1)Z[X++]=M[I++]}}else{I=X-a;do Z[X++]=Z[I++],Z[X++]=Z[I++],Z[X++]=Z[I++],c-=3;while(c>2);if(c){if(Z[X++]=Z[I++],c>1)Z[X++]=Z[I++]}}}else if((x&64)===0){u=g[(u&65535)+(z&(1<<x)-1)];continue Q}else{Q.msg="invalid distance code",H.mode=Y8;break W}break}}else if((x&64)===0){u=N[(u&65535)+(z&(1<<x)-1)];continue J}else if(x&32){H.mode=r9;break W}else{Q.msg="invalid literal/length code",H.mode=Y8;break W}break}}while(V<G&&X<q);c=$>>3,V-=c,$-=c<<3,z&=(1<<$)-1,Q.next_in=V,Q.next_out=X,Q.avail_in=V<G?5+(G-V):5-(V-G),Q.avail_out=X<q?257+(q-X):257-(X-q),H.hold=z,H.bits=$;return},q1=15,Z5=852,H5=592,k5=0,i8=1,$5=2,o9=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),a9=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),s9=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),e9=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]),t9=(W,Q,J,V,G,X,Y,q)=>{const F=q.bits;let U=0,P=0,C=0,K=0,z=0,$=0,N=0,g=0,p=0,f=0,u,x,c,a,I,M=null,w;const Z=new Uint16Array(q1+1),H=new Uint16Array(q1+1);let R=null,k,j,D;for(U=0;U<=q1;U++)Z[U]=0;for(P=0;P<V;P++)Z[Q[J+P]]++;z=F;for(K=q1;K>=1;K--)if(Z[K]!==0)break;if(z>K)z=K;if(K===0)return G[X++]=1<<24|64<<16|0,G[X++]=1<<24|64<<16|0,q.bits=1,0;for(C=1;C<K;C++)if(Z[C]!==0)break;if(z<C)z=C;g=1;for(U=1;U<=q1;U++)if(g<<=1,g-=Z[U],g<0)return-1;if(g>0&&(W===k5||K!==1))return-1;H[1]=0;for(U=1;U<q1;U++)H[U+1]=H[U]+Z[U];for(P=0;P<V;P++)if(Q[J+P]!==0)Y[H[Q[J+P]]++]=P;if(W===k5)M=R=Y,w=20;else if(W===i8)M=o9,R=a9,w=257;else M=s9,R=e9,w=0;if(f=0,P=0,U=C,I=X,$=z,N=0,c=-1,p=1<<z,a=p-1,W===i8&&p>Z5||W===$5&&p>H5)return 1;for(;;){if(k=U-N,Y[P]+1<w)j=0,D=Y[P];else if(Y[P]>=w)j=R[Y[P]-w],D=M[Y[P]-w];else j=96,D=0;u=1<<U-N,x=1<<$,C=x;do x-=u,G[I+(f>>N)+x]=k<<24|j<<16|D|0;while(x!==0);u=1<<U-1;while(f&u)u>>=1;if(u!==0)f&=u-1,f+=u;else f=0;if(P++,--Z[U]===0){if(U===K)break;U=Q[J+Y[P]]}if(U>z&&(f&a)!==c){if(N===0)N=z;I+=C,$=U-N,g=1<<$;while($+N<K){if(g-=Z[$+N],g<=0)break;$++,g<<=1}if(p+=1<<$,W===i8&&p>Z5||W===$5&&p>H5)return 1;c=f&a,G[c]=z<<24|$<<16|I-X|0}}if(f!==0)G[I+f]=U-N<<24|64<<16|0;return q.bits=z,0},E1=t9,WQ=0,z7=1,Z7=2,{Z_FINISH:C5,Z_BLOCK:JQ,Z_TREES:q8,Z_OK:i0,Z_STREAM_END:QQ,Z_NEED_DICT:VQ,Z_STREAM_ERROR:k0,Z_DATA_ERROR:H7,Z_MEM_ERROR:k7,Z_BUF_ERROR:GQ,Z_DEFLATED:j5}=r0,$8=16180,B5=16181,R5=16182,M5=16183,L5=16184,I5=16185,D5=16186,O5=16187,x5=16188,w5=16189,Z8=16190,O0=16191,r8=16192,N5=16193,n8=16194,S5=16195,v5=16196,A5=16197,T5=16198,U8=16199,P8=16200,g5=16201,E5=16202,y5=16203,f5=16204,p5=16205,o8=16206,b5=16207,h5=16208,W0=16209,$7=16210,C7=16211,XQ=852,YQ=592,qQ=15,UQ=qQ,u5=(W)=>{return(W>>>24&255)+(W>>>8&65280)+((W&65280)<<8)+((W&255)<<24)},n0=(W)=>{if(!W)return 1;const Q=W.state;if(!Q||Q.strm!==W||Q.mode<$8||Q.mode>C7)return 1;return 0},j7=(W)=>{if(n0(W))return k0;const Q=W.state;if(W.total_in=W.total_out=Q.total=0,W.msg="",Q.wrap)W.adler=Q.wrap&1;return Q.mode=$8,Q.last=0,Q.havedict=0,Q.flags=-1,Q.dmax=32768,Q.head=null,Q.hold=0,Q.bits=0,Q.lencode=Q.lendyn=new Int32Array(XQ),Q.distcode=Q.distdyn=new Int32Array(YQ),Q.sane=1,Q.back=-1,i0},B7=(W)=>{if(n0(W))return k0;const Q=W.state;return Q.wsize=0,Q.whave=0,Q.wnext=0,j7(W)},R7=(W,Q)=>{let J;if(n0(W))return k0;const V=W.state;if(Q<0)J=0,Q=-Q;else if(J=(Q>>4)+5,Q<48)Q&=15;if(Q&&(Q<8||Q>15))return k0;if(V.window!==null&&V.wbits!==Q)V.window=null;return V.wrap=J,V.wbits=Q,B7(W)},M7=(W,Q)=>{if(!W)return k0;const J=new PQ;W.state=J,J.strm=W,J.window=null,J.mode=$8;const V=R7(W,Q);if(V!==i0)W.state=null;return V},KQ=(W)=>{return M7(W,UQ)},m5=!0,a8,s8,FQ=(W)=>{if(m5){a8=new Int32Array(512),s8=new Int32Array(32);let Q=0;while(Q<144)W.lens[Q++]=8;while(Q<256)W.lens[Q++]=9;while(Q<280)W.lens[Q++]=7;while(Q<288)W.lens[Q++]=8;E1(z7,W.lens,0,288,a8,0,W.work,{bits:9}),Q=0;while(Q<32)W.lens[Q++]=5;E1(Z7,W.lens,0,32,s8,0,W.work,{bits:5}),m5=!1}W.lencode=a8,W.lenbits=9,W.distcode=s8,W.distbits=5},L7=(W,Q,J,V)=>{let G;const X=W.state;if(X.window===null)X.wsize=1<<X.wbits,X.wnext=0,X.whave=0,X.window=new Uint8Array(X.wsize);if(V>=X.wsize)X.window.set(Q.subarray(J-X.wsize,J),0),X.wnext=0,X.whave=X.wsize;else{if(G=X.wsize-X.wnext,G>V)G=V;if(X.window.set(Q.subarray(J-V,J-V+G),X.wnext),V-=G,V)X.window.set(Q.subarray(J-V,J),0),X.wnext=V,X.whave=X.wsize;else{if(X.wnext+=G,X.wnext===X.wsize)X.wnext=0;if(X.whave<X.wsize)X.whave+=G}}return 0},zQ=(W,Q)=>{let J,V,G,X,Y,q,F,U,P,C,K,z,$,N,g=0,p,f,u,x,c,a,I,M;const w=new Uint8Array(4);let Z,H;const R=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(n0(W)||!W.output||!W.input&&W.avail_in!==0)return k0;if(J=W.state,J.mode===O0)J.mode=r8;Y=W.next_out,G=W.output,F=W.avail_out,X=W.next_in,V=W.input,q=W.avail_in,U=J.hold,P=J.bits,C=q,K=F,M=i0;W:for(;;)switch(J.mode){case $8:if(J.wrap===0){J.mode=r8;break}while(P<16){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.wrap&2&&U===35615){if(J.wbits===0)J.wbits=15;J.check=0,w[0]=U&255,w[1]=U>>>8&255,J.check=V0(J.check,w,2,0),U=0,P=0,J.mode=B5;break}if(J.head)J.head.done=!1;if(!(J.wrap&1)||(((U&255)<<8)+(U>>8))%31){W.msg="incorrect header check",J.mode=W0;break}if((U&15)!==j5){W.msg="unknown compression method",J.mode=W0;break}if(U>>>=4,P-=4,I=(U&15)+8,J.wbits===0)J.wbits=I;if(I>15||I>J.wbits){W.msg="invalid window size",J.mode=W0;break}J.dmax=1<<J.wbits,J.flags=0,W.adler=J.check=1,J.mode=U&512?w5:O0,U=0,P=0;break;case B5:while(P<16){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.flags=U,(J.flags&255)!==j5){W.msg="unknown compression method",J.mode=W0;break}if(J.flags&57344){W.msg="unknown header flags set",J.mode=W0;break}if(J.head)J.head.text=U>>8&1;if(J.flags&512&&J.wrap&4)w[0]=U&255,w[1]=U>>>8&255,J.check=V0(J.check,w,2,0);U=0,P=0,J.mode=R5;case R5:while(P<32){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.head)J.head.time=U;if(J.flags&512&&J.wrap&4)w[0]=U&255,w[1]=U>>>8&255,w[2]=U>>>16&255,w[3]=U>>>24&255,J.check=V0(J.check,w,4,0);U=0,P=0,J.mode=M5;case M5:while(P<16){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.head)J.head.xflags=U&255,J.head.os=U>>8;if(J.flags&512&&J.wrap&4)w[0]=U&255,w[1]=U>>>8&255,J.check=V0(J.check,w,2,0);U=0,P=0,J.mode=L5;case L5:if(J.flags&1024){while(P<16){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.length=U,J.head)J.head.extra_len=U;if(J.flags&512&&J.wrap&4)w[0]=U&255,w[1]=U>>>8&255,J.check=V0(J.check,w,2,0);U=0,P=0}else if(J.head)J.head.extra=null;J.mode=I5;case I5:if(J.flags&1024){if(z=J.length,z>q)z=q;if(z){if(J.head){if(I=J.head.extra_len-J.length,!J.head.extra)J.head.extra=new Uint8Array(J.head.extra_len);J.head.extra.set(V.subarray(X,X+z),I)}if(J.flags&512&&J.wrap&4)J.check=V0(J.check,V,z,X);q-=z,X+=z,J.length-=z}if(J.length)break W}J.length=0,J.mode=D5;case D5:if(J.flags&2048){if(q===0)break W;z=0;do if(I=V[X+z++],J.head&&I&&J.length<65536)J.head.name+=String.fromCharCode(I);while(I&&z<q);if(J.flags&512&&J.wrap&4)J.check=V0(J.check,V,z,X);if(q-=z,X+=z,I)break W}else if(J.head)J.head.name=null;J.length=0,J.mode=O5;case O5:if(J.flags&4096){if(q===0)break W;z=0;do if(I=V[X+z++],J.head&&I&&J.length<65536)J.head.comment+=String.fromCharCode(I);while(I&&z<q);if(J.flags&512&&J.wrap&4)J.check=V0(J.check,V,z,X);if(q-=z,X+=z,I)break W}else if(J.head)J.head.comment=null;J.mode=x5;case x5:if(J.flags&512){while(P<16){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.wrap&4&&U!==(J.check&65535)){W.msg="header crc mismatch",J.mode=W0;break}U=0,P=0}if(J.head)J.head.hcrc=J.flags>>9&1,J.head.done=!0;W.adler=J.check=0,J.mode=O0;break;case w5:while(P<32){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}W.adler=J.check=u5(U),U=0,P=0,J.mode=Z8;case Z8:if(J.havedict===0)return W.next_out=Y,W.avail_out=F,W.next_in=X,W.avail_in=q,J.hold=U,J.bits=P,VQ;W.adler=J.check=1,J.mode=O0;case O0:if(Q===JQ||Q===q8)break W;case r8:if(J.last){U>>>=P&7,P-=P&7,J.mode=o8;break}while(P<3){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}switch(J.last=U&1,U>>>=1,P-=1,U&3){case 0:J.mode=N5;break;case 1:if(FQ(J),J.mode=U8,Q===q8){U>>>=2,P-=2;break W}break;case 2:J.mode=v5;break;case 3:W.msg="invalid block type",J.mode=W0}U>>>=2,P-=2;break;case N5:U>>>=P&7,P-=P&7;while(P<32){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if((U&65535)!==(U>>>16^65535)){W.msg="invalid stored block lengths",J.mode=W0;break}if(J.length=U&65535,U=0,P=0,J.mode=n8,Q===q8)break W;case n8:J.mode=S5;case S5:if(z=J.length,z){if(z>q)z=q;if(z>F)z=F;if(z===0)break W;G.set(V.subarray(X,X+z),Y),q-=z,X+=z,F-=z,Y+=z,J.length-=z;break}J.mode=O0;break;case v5:while(P<14){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.nlen=(U&31)+257,U>>>=5,P-=5,J.ndist=(U&31)+1,U>>>=5,P-=5,J.ncode=(U&15)+4,U>>>=4,P-=4,J.nlen>286||J.ndist>30){W.msg="too many length or distance symbols",J.mode=W0;break}J.have=0,J.mode=A5;case A5:while(J.have<J.ncode){while(P<3){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}J.lens[R[J.have++]]=U&7,U>>>=3,P-=3}while(J.have<19)J.lens[R[J.have++]]=0;if(J.lencode=J.lendyn,J.lenbits=7,Z={bits:J.lenbits},M=E1(WQ,J.lens,0,19,J.lencode,0,J.work,Z),J.lenbits=Z.bits,M){W.msg="invalid code lengths set",J.mode=W0;break}J.have=0,J.mode=T5;case T5:while(J.have<J.nlen+J.ndist){for(;;){if(g=J.lencode[U&(1<<J.lenbits)-1],p=g>>>24,f=g>>>16&255,u=g&65535,p<=P)break;if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(u<16)U>>>=p,P-=p,J.lens[J.have++]=u;else{if(u===16){H=p+2;while(P<H){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(U>>>=p,P-=p,J.have===0){W.msg="invalid bit length repeat",J.mode=W0;break}I=J.lens[J.have-1],z=3+(U&3),U>>>=2,P-=2}else if(u===17){H=p+3;while(P<H){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}U>>>=p,P-=p,I=0,z=3+(U&7),U>>>=3,P-=3}else{H=p+7;while(P<H){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}U>>>=p,P-=p,I=0,z=11+(U&127),U>>>=7,P-=7}if(J.have+z>J.nlen+J.ndist){W.msg="invalid bit length repeat",J.mode=W0;break}while(z--)J.lens[J.have++]=I}}if(J.mode===W0)break;if(J.lens[256]===0){W.msg="invalid code -- missing end-of-block",J.mode=W0;break}if(J.lenbits=9,Z={bits:J.lenbits},M=E1(z7,J.lens,0,J.nlen,J.lencode,0,J.work,Z),J.lenbits=Z.bits,M){W.msg="invalid literal/lengths set",J.mode=W0;break}if(J.distbits=6,J.distcode=J.distdyn,Z={bits:J.distbits},M=E1(Z7,J.lens,J.nlen,J.ndist,J.distcode,0,J.work,Z),J.distbits=Z.bits,M){W.msg="invalid distances set",J.mode=W0;break}if(J.mode=U8,Q===q8)break W;case U8:J.mode=P8;case P8:if(q>=6&&F>=258){if(W.next_out=Y,W.avail_out=F,W.next_in=X,W.avail_in=q,J.hold=U,J.bits=P,n9(W,K),Y=W.next_out,G=W.output,F=W.avail_out,X=W.next_in,V=W.input,q=W.avail_in,U=J.hold,P=J.bits,J.mode===O0)J.back=-1;break}J.back=0;for(;;){if(g=J.lencode[U&(1<<J.lenbits)-1],p=g>>>24,f=g>>>16&255,u=g&65535,p<=P)break;if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(f&&(f&240)===0){x=p,c=f,a=u;for(;;){if(g=J.lencode[a+((U&(1<<x+c)-1)>>x)],p=g>>>24,f=g>>>16&255,u=g&65535,x+p<=P)break;if(q===0)break W;q--,U+=V[X++]<<P,P+=8}U>>>=x,P-=x,J.back+=x}if(U>>>=p,P-=p,J.back+=p,J.length=u,f===0){J.mode=p5;break}if(f&32){J.back=-1,J.mode=O0;break}if(f&64){W.msg="invalid literal/length code",J.mode=W0;break}J.extra=f&15,J.mode=g5;case g5:if(J.extra){H=J.extra;while(P<H){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}J.length+=U&(1<<J.extra)-1,U>>>=J.extra,P-=J.extra,J.back+=J.extra}J.was=J.length,J.mode=E5;case E5:for(;;){if(g=J.distcode[U&(1<<J.distbits)-1],p=g>>>24,f=g>>>16&255,u=g&65535,p<=P)break;if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if((f&240)===0){x=p,c=f,a=u;for(;;){if(g=J.distcode[a+((U&(1<<x+c)-1)>>x)],p=g>>>24,f=g>>>16&255,u=g&65535,x+p<=P)break;if(q===0)break W;q--,U+=V[X++]<<P,P+=8}U>>>=x,P-=x,J.back+=x}if(U>>>=p,P-=p,J.back+=p,f&64){W.msg="invalid distance code",J.mode=W0;break}J.offset=u,J.extra=f&15,J.mode=y5;case y5:if(J.extra){H=J.extra;while(P<H){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}J.offset+=U&(1<<J.extra)-1,U>>>=J.extra,P-=J.extra,J.back+=J.extra}if(J.offset>J.dmax){W.msg="invalid distance too far back",J.mode=W0;break}J.mode=f5;case f5:if(F===0)break W;if(z=K-F,J.offset>z){if(z=J.offset-z,z>J.whave){if(J.sane){W.msg="invalid distance too far back",J.mode=W0;break}}if(z>J.wnext)z-=J.wnext,$=J.wsize-z;else $=J.wnext-z;if(z>J.length)z=J.length;N=J.window}else N=G,$=Y-J.offset,z=J.length;if(z>F)z=F;F-=z,J.length-=z;do G[Y++]=N[$++];while(--z);if(J.length===0)J.mode=P8;break;case p5:if(F===0)break W;G[Y++]=J.length,F--,J.mode=P8;break;case o8:if(J.wrap){while(P<32){if(q===0)break W;q--,U|=V[X++]<<P,P+=8}if(K-=F,W.total_out+=K,J.total+=K,J.wrap&4&&K)W.adler=J.check=J.flags?V0(J.check,G,K,Y-K):h1(J.check,G,K,Y-K);if(K=F,J.wrap&4&&(J.flags?U:u5(U))!==J.check){W.msg="incorrect data check",J.mode=W0;break}U=0,P=0}J.mode=b5;case b5:if(J.wrap&&J.flags){while(P<32){if(q===0)break W;q--,U+=V[X++]<<P,P+=8}if(J.wrap&4&&U!==(J.total&4294967295)){W.msg="incorrect length check",J.mode=W0;break}U=0,P=0}J.mode=h5;case h5:M=QQ;break W;case W0:M=H7;break W;case $7:return k7;case C7:default:return k0}if(W.next_out=Y,W.avail_out=F,W.next_in=X,W.avail_in=q,J.hold=U,J.bits=P,J.wsize||K!==W.avail_out&&J.mode<W0&&(J.mode<o8||Q!==C5)){if(L7(W,W.output,W.next_out,K-W.avail_out));}if(C-=W.avail_in,K-=W.avail_out,W.total_in+=C,W.total_out+=K,J.total+=K,J.wrap&4&&K)W.adler=J.check=J.flags?V0(J.check,G,K,W.next_out-K):h1(J.check,G,K,W.next_out-K);if(W.data_type=J.bits+(J.last?64:0)+(J.mode===O0?128:0)+(J.mode===U8||J.mode===n8?256:0),(C===0&&K===0||Q===C5)&&M===i0)M=GQ;return M},ZQ=(W)=>{if(n0(W))return k0;let Q=W.state;if(Q.window)Q.window=null;return W.state=null,i0},HQ=(W,Q)=>{if(n0(W))return k0;const J=W.state;if((J.wrap&2)===0)return k0;return J.head=Q,Q.done=!1,i0},kQ=(W,Q)=>{const J=Q.length;let V,G,X;if(n0(W))return k0;if(V=W.state,V.wrap!==0&&V.mode!==Z8)return k0;if(V.mode===Z8){if(G=1,G=h1(G,Q,J,0),G!==V.check)return H7}if(X=L7(W,Q,J,J),X)return V.mode=$7,k7;return V.havedict=1,i0},$Q=B7,CQ=R7,jQ=j7,BQ=KQ,RQ=M7,MQ=zQ,LQ=ZQ,IQ=HQ,DQ=kQ,OQ="pako inflate (from Nodeca project)",w0={inflateReset:$Q,inflateReset2:CQ,inflateResetKeep:jQ,inflateInit:BQ,inflateInit2:RQ,inflate:MQ,inflateEnd:LQ,inflateGetHeader:IQ,inflateSetDictionary:DQ,inflateInfo:OQ},wQ=xQ,I7=Object.prototype.toString,{Z_NO_FLUSH:NQ,Z_FINISH:SQ,Z_OK:_1,Z_STREAM_END:e8,Z_NEED_DICT:t8,Z_STREAM_ERROR:vQ,Z_DATA_ERROR:_5,Z_MEM_ERROR:AQ}=r0;i1.prototype.push=function(W,Q){const J=this.strm,V=this.options.chunkSize,G=this.options.dictionary;let X,Y,q;if(this.ended)return!1;if(Q===~~Q)Y=Q;else Y=Q===!0?SQ:NQ;if(I7.call(W)==="[object ArrayBuffer]")J.input=new Uint8Array(W);else J.input=W;J.next_in=0,J.avail_in=J.input.length;for(;;){if(J.avail_out===0)J.output=new Uint8Array(V),J.next_out=0,J.avail_out=V;if(X=w0.inflate(J,Y),X===t8&&G){if(X=w0.inflateSetDictionary(J,G),X===_1)X=w0.inflate(J,Y);else if(X===_5)X=t8}while(J.avail_in>0&&X===e8&&J.state.wrap>0&&W[J.next_in]!==0)w0.inflateReset(J),X=w0.inflate(J,Y);switch(X){case vQ:case _5:case t8:case AQ:return this.onEnd(X),this.ended=!0,!1}if(q=J.avail_out,J.next_out){if(J.avail_out===0||X===e8)if(this.options.to==="string"){let F=m1.utf8border(J.output,J.next_out),U=J.next_out-F,P=m1.buf2string(J.output,F);if(J.next_out=U,J.avail_out=V-U,U)J.output.set(J.output.subarray(F,F+U),0);this.onData(P)}else this.onData(J.output.length===J.next_out?J.output:J.output.subarray(0,J.next_out))}if(X===_1&&q===0)continue;if(X===e8)return X=w0.inflateEnd(this.strm),this.onEnd(X),this.ended=!0,!0;if(J.avail_in===0)break}return!0};i1.prototype.onData=function(W){this.chunks.push(W)};i1.prototype.onEnd=function(W){if(W===_1)if(this.options.to==="string")this.result=this.chunks.join("");else this.result=k8.flattenChunks(this.chunks);this.chunks=[],this.err=W,this.msg=this.strm.msg};var gQ=i1,EQ=k6,yQ=TQ,fQ=k6,pQ=r0,bQ={Inflate:gQ,inflate:EQ,inflateRaw:yQ,ungzip:fQ,constants:pQ},{Deflate:hQ,deflate:uQ,deflateRaw:mQ,gzip:_Q}=i9,{Inflate:cQ,inflate:dQ,inflateRaw:lQ,ungzip:iQ}=bQ,rQ=hQ,nQ=uQ,oQ=mQ,aQ=_Q,sQ=cQ,eQ=dQ,tQ=lQ,WV=iQ,JV=r0,H1={Deflate:rQ,deflate:nQ,deflateRaw:oQ,gzip:aQ,Inflate:sQ,inflate:eQ,inflateRaw:tQ,ungzip:WV,constants:JV};var T8=function(W){return W instanceof Uint8Array||ArrayBuffer.isView(W)&&W.constructor.name==="Uint8Array"},O6=function(W){if(!Number.isSafeInteger(W)||W<0)throw Error("positive integer expected, got "+W)},W1=function(W,...Q){if(!T8(W))throw Error("Uint8Array expected");if(Q.length>0&&!Q.includes(W.length))throw Error("Uint8Array expected of length "+Q+", got length="+W.length)},i7=function(W){if(typeof W!="function"||typeof W.create!="function")throw Error("Hash should be wrapped by utils.createHasher");O6(W.outputLen),O6(W.blockLen)},I8=function(W,Q=!0){if(W.destroyed)throw Error("Hash instance has been destroyed");if(Q&&W.finished)throw Error("Hash#digest() has already been called")},D8=function(...W){for(let Q=0;Q<W.length;Q++)W[Q].fill(0)},$6=function(W){return new DataView(W.buffer,W.byteOffset,W.byteLength)},I0=function(W,Q){return W<<32-Q|W>>>Q},R1=function(W){if(W1(W),r7)return W.toHex();let Q="";for(let J=0;J<W.length;J++)Q+=QV[W[J]];return Q},w7=function(W){return W>=D7&&W<=VV?W-D7:W>=O7&&W<=GV?W-(O7-10):W>=x7&&W<=XV?W-(x7-10):void 0},O8=function(W){if(typeof W!="string")throw Error("hex string expected, got "+typeof W);if(r7)return Uint8Array.fromHex(W);const Q=W.length,J=Q/2;if(Q%2)throw Error("hex string expected, got unpadded hex of length "+Q);const V=new Uint8Array(J);for(let G=0,X=0;G<J;G++,X+=2){const Y=w7(W.charCodeAt(X)),q=w7(W.charCodeAt(X+1));if(Y===void 0||q===void 0){const F=W[X]+W[X+1];throw Error('hex string expected, got non-hex character "'+F+'" at index '+X)}V[G]=16*Y+q}return V},n7=function(W){if(typeof W!="string")throw Error("string expected");return new Uint8Array((new TextEncoder()).encode(W))},E6=function(W){return typeof W=="string"&&(W=n7(W)),W1(W),W},D0=function(...W){let Q=0;for(let V=0;V<W.length;V++){const G=W[V];W1(G),Q+=G.length}const J=new Uint8Array(Q);for(let V=0,G=0;V<W.length;V++){const X=W[V];J.set(X,G),G+=X.length}return J},YV=function(W){const Q=(V)=>W().update(E6(V)).digest(),J=W();return Q.outputLen=J.outputLen,Q.blockLen=J.blockLen,Q.create=()=>W(),Q},x8=function(W=32){if(k1&&typeof k1.getRandomValues=="function")return k1.getRandomValues(new Uint8Array(W));if(k1&&typeof k1.randomBytes=="function")return Uint8Array.from(k1.randomBytes(W));throw Error("crypto.getRandomValues must be defined")},qV=function(W,Q,J){return W&Q^W&J^Q&J},w8=function(W,Q=""){if(typeof W!="boolean")throw Error((Q&&`"${Q}"`)+"expected boolean, got type="+typeof W);return W},o0=function(W,Q,J=""){const V=T8(W),G=W?.length,X=Q!==void 0;if(!V||X&&G!==Q)throw Error((J&&`"${J}" `)+"expected Uint8Array"+(X?" of length "+Q:"")+", got "+(V?"length="+G:"type="+typeof W));return W},C8=function(W){const Q=W.toString(16);return 1&Q.length?"0"+Q:Q},e7=function(W){if(typeof W!="string")throw Error("hex string expected, got "+typeof W);return W===""?p6:BigInt("0x"+W)},I1=function(W){return e7(R1(W))},t7=function(W){return W1(W),e7(R1(Uint8Array.from(W).reverse()))},g8=function(W,Q){return O8(W.toString(16).padStart(2*Q,"0"))},WW=function(W,Q){return g8(W,Q).reverse()},Q0=function(W,Q,J){let V;if(typeof Q=="string")try{V=O8(Q)}catch(X){throw Error(W+" must be hex string or Uint8Array, cause: "+X)}else{if(!T8(Q))throw Error(W+" must be hex string or Uint8Array");V=Uint8Array.from(Q)}const G=V.length;if(typeof J=="number"&&G!==J)throw Error(W+" of length "+J+" expected, got "+G);return V},N6=function(W,Q,J){return C6(W)&&C6(Q)&&C6(J)&&Q<=W&&W<J},JW=function(W){let Q;for(Q=0;W>p6;W>>=w6,Q+=1);return Q},b6=function(W,Q,J={}){if(!W||typeof W!="object")throw Error("expected valid options object");function V(G,X,Y){const q=W[G];if(Y&&q===void 0)return;const F=typeof q;if(F!==X||q===null)throw Error(`param "${G}" is invalid: expected ${X}, got ${F}`)}Object.entries(Q).forEach(([G,X])=>V(G,X,!1)),Object.entries(J).forEach(([G,X])=>V(G,X,!0))},N7=function(W){const Q=new WeakMap;return(J,...V)=>{const G=Q.get(J);if(G!==void 0)return G;const X=W(J,...V);return Q.set(J,X),X}},C0=function(W,Q){const J=W%Q;return J>=K0?J:Q+J},$0=function(W,Q,J){let V=W;for(;Q-- >K0;)V*=V,V%=J;return V},v7=function(W,Q){if(W===K0)throw Error("invert: expected non-zero number");if(Q<=K0)throw Error("invert: expected positive modulus, got "+Q);let J=C0(W,Q),V=Q,G=K0,X=U0;for(;J!==K0;){const Y=V%J,q=G-X*(V/J);V=J,J=Y,G=X,X=q}if(V!==U0)throw Error("invert: does not exist");return C0(G,Q)},h6=function(W,Q,J){if(!W.eql(W.sqr(Q),J))throw Error("Cannot find square root")},YW=function(W,Q){const J=(W.ORDER+U0)/VW,V=W.pow(Q,J);return h6(W,V,Q),V},FV=function(W,Q){const J=(W.ORDER-GW)/XW,V=W.mul(Q,s0),G=W.pow(V,J),X=W.mul(Q,G),Y=W.mul(W.mul(X,s0),G),q=W.mul(X,W.sub(Y,W.ONE));return h6(W,q,Q),q},A7=function(W){if(W<QW)throw Error("sqrt is not defined for small field");let Q=W-U0,J=0;for(;Q%s0===K0;)Q/=s0,J++;let V=s0;const G=e1(W);for(;T7(G,V)===1;)if(V++>1000)throw Error("Cannot find square root: probably non-prime P");if(J===1)return YW;let X=G.pow(V,Q);const Y=(Q+U0)/s0;return function(q,F){if(q.is0(F))return F;if(T7(q,F)!==1)throw Error("Cannot find square root");let U=J,P=q.mul(q.ONE,X),C=q.pow(F,Q),K=q.pow(F,Y);for(;!q.eql(C,q.ONE);){if(q.is0(C))return q.ZERO;let z=1,$=q.sqr(C);for(;!q.eql($,q.ONE);)if(z++,$=q.sqr($),z===U)throw Error("Cannot find square root");const N=U0<<BigInt(U-z-1),g=q.pow(P,N);U=z,P=q.sqr(g),C=q.mul(C,P),K=q.mul(K,g)}return K}},zV=function(W){return W%VW===QW?YW:W%XW===GW?FV:W%S7===KV?function(Q){const J=e1(Q),V=A7(Q),G=V(J,J.neg(J.ONE)),X=V(J,G),Y=V(J,J.neg(G)),q=(Q+PV)/S7;return(F,U)=>{let P=F.pow(U,q),C=F.mul(P,G);const K=F.mul(P,X),z=F.mul(P,Y),$=F.eql(F.sqr(C),U),N=F.eql(F.sqr(K),U);P=F.cmov(P,C,$),C=F.cmov(z,K,N);const g=F.eql(F.sqr(C),U),p=F.cmov(P,C,g);return h6(F,p,U),p}}(W):A7(W)},qW=function(W,Q,J=!1){const V=Array(Q.length).fill(J?W.ZERO:void 0),G=Q.reduce((Y,q,F)=>W.is0(q)?Y:(V[F]=Y,W.mul(Y,q)),W.ONE),X=W.inv(G);return Q.reduceRight((Y,q,F)=>W.is0(q)?Y:(V[F]=W.mul(Y,V[F]),W.mul(Y,q)),X),V},T7=function(W,Q){const J=(W.ORDER-U0)/s0,V=W.pow(Q,J),G=W.eql(V,W.ONE),X=W.eql(V,W.ZERO),Y=W.eql(V,W.neg(W.ONE));if(!G&&!X&&!Y)throw Error("invalid Legendre symbol result");return G?1:X?0:-1},UW=function(W,Q){Q!==void 0&&O6(Q);const J=Q!==void 0?Q:W.toString(2).length;return{nBitLength:J,nByteLength:Math.ceil(J/8)}},e1=function(W,Q,J=!1,V={}){if(W<=K0)throw Error("invalid field: expected ORDER > 0, got "+W);let G,X,Y,q=!1;if(typeof Q=="object"&&Q!=null){if(V.sqrt||J)throw Error("cannot specify opts in two arguments");const K=Q;K.BITS&&(G=K.BITS),K.sqrt&&(X=K.sqrt),typeof K.isLE=="boolean"&&(J=K.isLE),typeof K.modFromBytes=="boolean"&&(q=K.modFromBytes),Y=K.allowedLengths}else typeof Q=="number"&&(G=Q),V.sqrt&&(X=V.sqrt);const{nBitLength:F,nByteLength:U}=UW(W,G);if(U>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let P;const C=Object.freeze({ORDER:W,isLE:J,BITS:F,BYTES:U,MASK:s1(F),ZERO:K0,ONE:U0,allowedLengths:Y,create(K){return C0(K,W)},isValid(K){if(typeof K!="bigint")throw Error("invalid field element: expected bigint, got "+typeof K);return K0<=K&&K<W},is0(K){return K===K0},isValidNot0(K){return!C.is0(K)&&C.isValid(K)},isOdd(K){return(K&U0)===U0},neg(K){return C0(-K,W)},eql(K,z){return K===z},sqr(K){return C0(K*K,W)},add(K,z){return C0(K+z,W)},sub(K,z){return C0(K-z,W)},mul(K,z){return C0(K*z,W)},pow(K,z){return function($,N,g){if(g<K0)throw Error("invalid exponent, negatives unsupported");if(g===K0)return $.ONE;if(g===U0)return N;let p=$.ONE,f=N;for(;g>K0;)g&U0&&(p=$.mul(p,f)),f=$.sqr(f),g>>=U0;return p}(C,K,z)},div(K,z){return C0(K*v7(z,W),W)},sqrN(K){return K*K},addN(K,z){return K+z},subN(K,z){return K-z},mulN(K,z){return K*z},inv(K){return v7(K,W)},sqrt:X||((K)=>(P||(P=zV(W)),P(C,K))),toBytes(K){return J?WW(K,U):g8(K,U)},fromBytes(K,z=!0){if(Y){if(!Y.includes(K.length)||K.length>U)throw Error("Field.fromBytes: expected "+Y+" bytes, got "+K.length);const N=new Uint8Array(U);N.set(K,J?0:N.length-K.length),K=N}if(K.length!==U)throw Error("Field.fromBytes: expected "+U+" bytes, got "+K.length);let $=J?t7(K):I1(K);if(q&&($=C0($,W)),!z&&!C.isValid($))throw Error("invalid field element: outside of range 0..ORDER");return $},invertBatch(K){return qW(C,K)},cmov(K,z,$){return $?z:K}});return Object.freeze(C)},PW=function(W){if(typeof W!="bigint")throw Error("field order must be bigint");const Q=W.toString(2).length;return Math.ceil(Q/8)},KW=function(W){const Q=PW(W);return Q+Math.ceil(Q/2)},FW=function(W,Q,J=!1){const V=W.length,G=PW(Q),X=KW(Q);if(V<16||V<X||V>1024)throw Error("expected "+X+"-1024 bytes of input, got "+V);const Y=C0(J?t7(W):I1(W),Q-U0)+U0;return J?WW(Y,G):g8(Y,G)},N8=function(W,Q){const J=Q.negate();return W?J:Q},j6=function(W,Q){const J=qW(W.Fp,Q.map((V)=>V.Z));return Q.map((V,G)=>W.fromAffine(V.toAffine(J[G])))},zW=function(W,Q){if(!Number.isSafeInteger(W)||W<=0||W>Q)throw Error("invalid window size, expected [1.."+Q+"], got W="+W)},B6=function(W,Q){zW(W,Q);const J=2**W;return{windows:Math.ceil(Q/W)+1,windowSize:2**(W-1),mask:s1(W),maxNumber:J,shiftBy:BigInt(W)}},g7=function(W,Q,J){const{windowSize:V,mask:G,maxNumber:X,shiftBy:Y}=J;let q=Number(W&G),F=W>>Y;q>V&&(q-=X,F+=e0);const U=Q*V;return{nextN:F,offset:U+Math.abs(q)-1,isZero:q===0,isNeg:q<0,isNegF:Q%2!=0,offsetF:U}},M6=function(W){return ZW.get(W)||1},E7=function(W){if(W!==M1)throw Error("invalid wNAF")},HV=function(W,Q,J,V){(function(K,z){if(!Array.isArray(K))throw Error("array expected");K.forEach(($,N)=>{if(!($ instanceof z))throw Error("invalid point at index "+N)})})(J,W),function(K,z){if(!Array.isArray(K))throw Error("array of scalars expected");K.forEach(($,N)=>{if(!z.isValid($))throw Error("invalid scalar at index "+N)})}(V,Q);const G=J.length,X=V.length;if(G!==X)throw Error("arrays of points and scalars must have equal length");const Y=W.ZERO,q=JW(BigInt(G));let F=1;q>12?F=q-3:q>4?F=q-2:q>0&&(F=2);const U=s1(F),P=Array(Number(U)+1).fill(Y);let C=Y;for(let K=Math.floor((Q.BITS-1)/F)*F;K>=0;K-=F){P.fill(Y);for(let $=0;$<X;$++){const N=V[$],g=Number(N>>BigInt(K)&U);P[g]=P[g].add(J[$])}let z=Y;for(let $=P.length-1,N=Y;$>0;$--)N=N.add(P[$]),z=z.add(N);if(C=C.add(z),K!==0)for(let $=0;$<F;$++)C=C.double()}return C},y7=function(W,Q,J){if(Q){if(Q.ORDER!==W)throw Error("Field.ORDER must match order: Fp == p, Fn == n");return function(V){b6(V,ZV.reduce((G,X)=>(G[X]="function",G),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"}))}(Q),Q}return e1(W,{isLE:J})},S6=function(W){if(!["compact","recovered","der"].includes(W))throw Error('Signature format must be "compact", "recovered", or "der"');return W},L6=function(W,Q){const J={};for(let V of Object.keys(Q))J[V]=W[V]===void 0?Q[V]:W[V];return w8(J.lowS,"lowS"),w8(J.prehash,"prehash"),J.format!==void 0&&S6(J.format),J},a0=function(W,Q){const{BYTES:J}=W;let V;if(typeof Q=="bigint")V=Q;else{let G=Q0("private key",Q);try{V=W.fromBytes(G)}catch(X){throw Error(`invalid private key: expected ui8a of size ${J}, got ${typeof Q}`)}}if(!W.isValidNot0(V))throw Error("invalid private key: out of range [1..N-1]");return V},$V=function(W,Q={}){const J=function(Z,H,R={},k){if(k===void 0&&(k=Z==="edwards"),!H||typeof H!="object")throw Error(`expected valid ${Z} CURVE object`);for(let S of["p","n","h"]){const B=H[S];if(!(typeof B=="bigint"&&B>M1))throw Error(`CURVE.${S} must be positive bigint`)}const j=y7(H.p,R.Fp,k),D=y7(H.n,R.Fn,k),L=["Gx","Gy","a","b"];for(let S of L)if(!j.isValid(H[S]))throw Error(`CURVE.${S} must be valid field element of CURVE.Fp`);return{CURVE:H=Object.freeze(Object.assign({},H)),Fp:j,Fn:D}}("weierstrass",W,Q),{Fp:V,Fn:G}=J;let X=J.CURVE;const{h:Y,n:q}=X;b6(Q,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:F}=Q;if(F&&(!V.is0(X.a)||typeof F.beta!="bigint"||!Array.isArray(F.basises)))throw Error('invalid endo: expected "beta": bigint and "basises": array');const U=CW(V,G);function P(){if(!V.isOdd)throw Error("compression is not supported: Field does not have .isOdd()")}const C=Q.toBytes||function(Z,H,R){const{x:k,y:j}=H.toAffine(),D=V.toBytes(k);if(w8(R,"isCompressed"),R)return P(),D0($W(!V.isOdd(j)),D);return D0(Uint8Array.of(4),D,V.toBytes(j))},K=Q.fromBytes||function(Z){o0(Z,void 0,"Point");const{publicKey:H,publicKeyUncompressed:R}=U,k=Z.length,j=Z[0],D=Z.subarray(1);if(k!==H||j!==2&&j!==3){if(k===R&&j===4){const L=V.BYTES,S=V.fromBytes(D.subarray(0,L)),B=V.fromBytes(D.subarray(L,2*L));if(!$(S,B))throw Error("bad point: is not on curve");return{x:S,y:B}}throw Error(`bad point: got length ${k}, expected compressed=${H} or uncompressed=${R}`)}{const L=V.fromBytes(D);if(!V.isValid(L))throw Error("bad point: is not on curve, wrong x");const S=z(L);let B;try{B=V.sqrt(S)}catch(v){const b=v instanceof Error?": "+v.message:"";throw Error("bad point: is not on curve, sqrt error"+b)}return P(),!(1&~j)!==V.isOdd(B)&&(B=V.neg(B)),{x:L,y:B}}};function z(Z){const H=V.sqr(Z),R=V.mul(H,Z);return V.add(V.add(R,V.mul(Z,X.a)),X.b)}function $(Z,H){const R=V.sqr(H),k=z(Z);return V.eql(R,k)}if(!$(X.Gx,X.Gy))throw Error("bad curve params: generator point");const N=V.mul(V.pow(X.a,j8),kV),g=V.mul(V.sqr(X.b),BigInt(27));if(V.is0(V.add(N,g)))throw Error("bad curve params: a or b");function p(Z,H,R=!1){if(!V.isValid(H)||R&&V.is0(H))throw Error("bad point coordinate "+Z);return H}function f(Z){if(!(Z instanceof I))throw Error("ProjectivePoint expected")}function u(Z){if(!F||!F.basises)throw Error("no endo");return function(H,R,k){const[[j,D],[L,S]]=R,B=f7(S*H,k),v=f7(-D*H,k);let b=H-B*j-v*L,A=-B*D-v*S;const E=b<v0,o=A<v0;E&&(b=-b),o&&(A=-A);const i=s1(Math.ceil(JW(k)/2))+j1;if(b<v0||b>=i||A<v0||A>=i)throw Error("splitScalar (endomorphism): failed, k="+H);return{k1neg:E,k1:b,k2neg:o,k2:A}}(Z,F.basises,G.ORDER)}const x=N7((Z,H)=>{const{X:R,Y:k,Z:j}=Z;if(V.eql(j,V.ONE))return{x:R,y:k};const D=Z.is0();H==null&&(H=D?V.ONE:V.inv(j));const L=V.mul(R,H),S=V.mul(k,H),B=V.mul(j,H);if(D)return{x:V.ZERO,y:V.ZERO};if(!V.eql(B,V.ONE))throw Error("invZ was invalid");return{x:L,y:S}}),c=N7((Z)=>{if(Z.is0()){if(Q.allowInfinityPoint&&!V.is0(Z.Y))return;throw Error("bad point: ZERO")}const{x:H,y:R}=Z.toAffine();if(!V.isValid(H)||!V.isValid(R))throw Error("bad point: x or y not field elements");if(!$(H,R))throw Error("bad point: equation left != right");if(!Z.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0});function a(Z,H,R,k,j){return R=new I(V.mul(R.X,Z),R.Y,R.Z),H=N8(k,H),R=N8(j,R),H.add(R)}class I{constructor(Z,H,R){this.X=p("x",Z),this.Y=p("y",H,!0),this.Z=p("z",R),Object.freeze(this)}static CURVE(){return X}static fromAffine(Z){const{x:H,y:R}=Z||{};if(!Z||!V.isValid(H)||!V.isValid(R))throw Error("invalid affine point");if(Z instanceof I)throw Error("projective point not allowed");return V.is0(H)&&V.is0(R)?I.ZERO:new I(H,R,V.ONE)}static fromBytes(Z){const H=I.fromAffine(K(o0(Z,void 0,"point")));return H.assertValidity(),H}static fromHex(Z){return I.fromBytes(Q0("pointHex",Z))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(Z=8,H=!0){return w.createCache(this,Z),H||this.multiply(j8),this}assertValidity(){c(this)}hasEvenY(){const{y:Z}=this.toAffine();if(!V.isOdd)throw Error("Field doesn't support isOdd");return!V.isOdd(Z)}equals(Z){f(Z);const{X:H,Y:R,Z:k}=this,{X:j,Y:D,Z:L}=Z,S=V.eql(V.mul(H,L),V.mul(j,k)),B=V.eql(V.mul(R,L),V.mul(D,k));return S&&B}negate(){return new I(this.X,V.neg(this.Y),this.Z)}double(){const{a:Z,b:H}=X,R=V.mul(H,j8),{X:k,Y:j,Z:D}=this;let{ZERO:L,ZERO:S,ZERO:B}=V,v=V.mul(k,k),b=V.mul(j,j),A=V.mul(D,D),E=V.mul(k,j);return E=V.add(E,E),B=V.mul(k,D),B=V.add(B,B),L=V.mul(Z,B),S=V.mul(R,A),S=V.add(L,S),L=V.sub(b,S),S=V.add(b,S),S=V.mul(L,S),L=V.mul(E,L),B=V.mul(R,B),A=V.mul(Z,A),E=V.sub(v,A),E=V.mul(Z,E),E=V.add(E,B),B=V.add(v,v),v=V.add(B,v),v=V.add(v,A),v=V.mul(v,E),S=V.add(S,v),A=V.mul(j,D),A=V.add(A,A),v=V.mul(A,E),L=V.sub(L,v),B=V.mul(A,b),B=V.add(B,B),B=V.add(B,B),new I(L,S,B)}add(Z){f(Z);const{X:H,Y:R,Z:k}=this,{X:j,Y:D,Z:L}=Z;let{ZERO:S,ZERO:B,ZERO:v}=V;const b=X.a,A=V.mul(X.b,j8);let E=V.mul(H,j),o=V.mul(R,D),i=V.mul(k,L),r=V.add(H,R),O=V.add(j,D);r=V.mul(r,O),O=V.add(E,o),r=V.sub(r,O),O=V.add(H,k);let y=V.add(j,L);return O=V.mul(O,y),y=V.add(E,i),O=V.sub(O,y),y=V.add(R,k),S=V.add(D,L),y=V.mul(y,S),S=V.add(o,i),y=V.sub(y,S),v=V.mul(b,O),S=V.mul(A,i),v=V.add(S,v),S=V.sub(o,v),v=V.add(o,v),B=V.mul(S,v),o=V.add(E,E),o=V.add(o,E),i=V.mul(b,i),O=V.mul(A,O),o=V.add(o,i),i=V.sub(E,i),i=V.mul(b,i),O=V.add(O,i),E=V.mul(o,O),B=V.add(B,E),E=V.mul(y,O),S=V.mul(r,S),S=V.sub(S,E),E=V.mul(r,o),v=V.mul(y,v),v=V.add(v,E),new I(S,B,v)}subtract(Z){return this.add(Z.negate())}is0(){return this.equals(I.ZERO)}multiply(Z){const{endo:H}=Q;if(!G.isValidNot0(Z))throw Error("invalid scalar: out of range");let R,k;const j=(D)=>w.cached(this,D,(L)=>j6(I,L));if(H){const{k1neg:D,k1:L,k2neg:S,k2:B}=u(Z),{p:v,f:b}=j(L),{p:A,f:E}=j(B);k=b.add(E),R=a(H.beta,v,A,D,S)}else{const{p:D,f:L}=j(Z);R=D,k=L}return j6(I,[R,k])[0]}multiplyUnsafe(Z){const{endo:H}=Q,R=this;if(!G.isValid(Z))throw Error("invalid scalar: out of range");if(Z===v0||R.is0())return I.ZERO;if(Z===j1)return R;if(w.hasCache(this))return this.multiply(Z);if(H){const{k1neg:k,k1:j,k2neg:D,k2:L}=u(Z),{p1:S,p2:B}=function(v,b,A,E){let o=b,i=v.ZERO,r=v.ZERO;for(;A>M1||E>M1;)A&e0&&(i=i.add(o)),E&e0&&(r=r.add(o)),o=o.double(),A>>=e0,E>>=e0;return{p1:i,p2:r}}(I,R,j,L);return a(H.beta,S,B,k,D)}return w.unsafe(R,Z)}multiplyAndAddUnsafe(Z,H,R){const k=this.multiplyUnsafe(H).add(Z.multiplyUnsafe(R));return k.is0()?void 0:k}toAffine(Z){return x(this,Z)}isTorsionFree(){const{isTorsionFree:Z}=Q;return Y===j1||(Z?Z(I,this):w.unsafe(this,q).is0())}clearCofactor(){const{clearCofactor:Z}=Q;return Y===j1?this:Z?Z(I,this):this.multiplyUnsafe(Y)}isSmallOrder(){return this.multiplyUnsafe(Y).is0()}toBytes(Z=!0){return w8(Z,"isCompressed"),this.assertValidity(),C(I,this,Z)}toHex(Z=!0){return R1(this.toBytes(Z))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(Z=!0){return this.toBytes(Z)}_setWindowSize(Z){this.precompute(Z)}static normalizeZ(Z){return j6(I,Z)}static msm(Z,H){return HV(I,G,Z,H)}static fromPrivateKey(Z){return I.BASE.multiply(a0(G,Z))}}I.BASE=new I(X.Gx,X.Gy,V.ONE),I.ZERO=new I(V.ZERO,V.ONE,V.ZERO),I.Fp=V,I.Fn=G;const M=G.BITS,w=new HW(I,Q.endo?Math.ceil(M/2):M);return I.BASE.precompute(8),I},$W=function(W){return Uint8Array.of(W?2:3)},CW=function(W,Q){return{secretKey:Q.BYTES,publicKey:1+W.BYTES,publicKeyUncompressed:1+2*W.BYTES,publicKeyHasPrefix:!0,signature:2*Q.BYTES}},CV=function(W,Q,J={}){i7(Q),b6(J,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const V=J.randomBytes||x8,G=J.hmac||((M,...w)=>s7(Q,M,D0(...w))),{Fp:X,Fn:Y}=W,{ORDER:q,BITS:F}=Y,{keygen:U,getPublicKey:P,getSharedSecret:C,utils:K,lengths:z}=function(M,w={}){const{Fn:Z}=M,H=w.randomBytes||x8,R=Object.assign(CW(M.Fp,Z),{seed:KW(Z.ORDER)});function k(B){try{return!!a0(Z,B)}catch(v){return!1}}function j(B=H(R.seed)){return FW(o0(B,R.seed,"seed"),Z.ORDER)}function D(B,v=!0){return M.BASE.multiply(a0(Z,B)).toBytes(v)}function L(B){if(typeof B=="bigint")return!1;if(B instanceof M)return!0;const{secretKey:v,publicKey:b,publicKeyUncompressed:A}=R;if(Z.allowedLengths||v===b)return;const E=Q0("key",B).length;return E===b||E===A}return Object.freeze({getPublicKey:D,getSharedSecret(B,v,b=!0){if(L(B)===!0)throw Error("first arg must be private key");if(L(v)===!1)throw Error("second arg must be public key");const A=a0(Z,B);return M.fromHex(v).multiply(A).toBytes(b)},keygen(B){const v=j(B);return{secretKey:v,publicKey:D(v)}},Point:M,utils:{isValidSecretKey:k,isValidPublicKey(B,v){const{publicKey:b,publicKeyUncompressed:A}=R;try{const E=B.length;return!(v===!0&&E!==b||v===!1&&E!==A||!M.fromBytes(B))}catch(E){return!1}},randomSecretKey:j,isValidPrivateKey:k,randomPrivateKey:j,normPrivateKeyToScalar:(B)=>a0(Z,B),precompute(B=8,v=M.BASE){return v.precompute(B,!1)}},lengths:R})}(W,J),$={prehash:!1,lowS:typeof J.lowS=="boolean"&&J.lowS,format:void 0,extraEntropy:!1},N="compact";function g(M){return M>q>>j1}function p(M,w){if(!Y.isValidNot0(w))throw Error(`invalid signature ${M}: out of range 1..Point.Fn.ORDER`);return w}class f{constructor(M,w,Z){this.r=p("r",M),this.s=p("s",w),Z!=null&&(this.recovery=Z),Object.freeze(this)}static fromBytes(M,w=N){let Z;if(function(j,D){S6(D);const L=z.signature;o0(j,D==="compact"?L:D==="recovered"?L+1:void 0,D+" signature")}(M,w),w==="der"){const{r:j,s:D}=S0.toSig(o0(M));return new f(j,D)}w==="recovered"&&(Z=M[0],w="compact",M=M.subarray(1));const H=Y.BYTES,R=M.subarray(0,H),k=M.subarray(H,2*H);return new f(Y.fromBytes(R),Y.fromBytes(k),Z)}static fromHex(M,w){return this.fromBytes(O8(M),w)}addRecoveryBit(M){return new f(this.r,this.s,M)}recoverPublicKey(M){const w=X.ORDER,{r:Z,s:H,recovery:R}=this;if(R==null||![0,1,2,3].includes(R))throw Error("recovery id invalid");if(q*kW<w&&R>1)throw Error("recovery id is ambiguous for h>1 curve");const k=R===2||R===3?Z+q:Z;if(!X.isValid(k))throw Error("recovery id 2 or 3 invalid");const j=X.toBytes(k),D=W.fromBytes(D0($W(!(1&R)),j)),L=Y.inv(k),S=x(Q0("msgHash",M)),B=Y.create(-S*L),v=Y.create(H*L),b=W.BASE.multiplyUnsafe(B).add(D.multiplyUnsafe(v));if(b.is0())throw Error("point at infinify");return b.assertValidity(),b}hasHighS(){return g(this.s)}toBytes(M=N){if(S6(M),M==="der")return O8(S0.hexFromSig(this));const w=Y.toBytes(this.r),Z=Y.toBytes(this.s);if(M==="recovered"){if(this.recovery==null)throw Error("recovery bit must be present");return D0(Uint8Array.of(this.recovery),w,Z)}return D0(w,Z)}toHex(M){return R1(this.toBytes(M))}assertValidity(){}static fromCompact(M){return f.fromBytes(Q0("sig",M),"compact")}static fromDER(M){return f.fromBytes(Q0("sig",M),"der")}normalizeS(){return this.hasHighS()?new f(this.r,Y.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return R1(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return R1(this.toBytes("compact"))}}const u=J.bits2int||function(M){if(M.length>8192)throw Error("input is too large");const w=I1(M),Z=8*M.length-F;return Z>0?w>>BigInt(Z):w},x=J.bits2int_modN||function(M){return Y.create(u(M))},c=s1(F);function a(M){return function(w,Z,H,R){if(!N6(Z,H,R))throw Error("expected valid "+w+": "+H+" <= n < "+R+", got "+Z)}("num < 2^"+F,M,v0,c),Y.toBytes(M)}function I(M,w){return o0(M,void 0,"message"),w?o0(Q(M),void 0,"prehashed message"):M}return Object.freeze({keygen:U,getPublicKey:P,getSharedSecret:C,utils:K,lengths:z,Point:W,sign(M,w,Z={}){M=Q0("message",M);const{seed:H,k2sig:R}=function(k,j,D){if(["recovered","canonical"].some((i)=>(i in D)))throw Error("sign() legacy options not supported");const{lowS:L,prehash:S,extraEntropy:B}=L6(D,$);k=I(k,S);const v=x(k),b=a0(Y,j),A=[a(b),a(v)];if(B!=null&&B!==!1){const i=B===!0?V(z.secretKey):B;A.push(Q0("extraEntropy",i))}const E=D0(...A),o=v;return{seed:E,k2sig(i){const r=u(i);if(!Y.isValidNot0(r))return;const O=Y.inv(r),y=W.BASE.multiply(r).toAffine(),m=Y.create(y.x);if(m===v0)return;const d=Y.create(O*Y.create(o+m*b));if(d===v0)return;let T=(y.x===m?0:2)|Number(y.y&j1),_=d;return L&&g(d)&&(_=Y.neg(d),T^=1),new f(m,_,T)}}}(M,w,Z);return function(k,j,D){if(typeof k!="number"||k<2)throw Error("hashLen must be a number");if(typeof j!="number"||j<2)throw Error("qByteLen must be a number");if(typeof D!="function")throw Error("hmacFn must be a function");const L=(r)=>new Uint8Array(r),S=(r)=>Uint8Array.of(r);let B=L(k),v=L(k),b=0;const A=()=>{B.fill(1),v.fill(0),b=0},E=(...r)=>D(v,B,...r),o=(r=L(0))=>{v=E(S(0),r),B=E(),r.length!==0&&(v=E(S(1),r),B=E())},i=()=>{if(b++>=1000)throw Error("drbg: tried 1000 values");let r=0;const O=[];for(;r<j;){B=E();const y=B.slice();O.push(y),r+=B.length}return D0(...O)};return(r,O)=>{let y;for(A(),o(r);!(y=O(i()));)o();return A(),y}}(Q.outputLen,Y.BYTES,G)(H,R)},verify(M,w,Z,H={}){const{lowS:R,prehash:k,format:j}=L6(H,$);if(Z=Q0("publicKey",Z),w=I(Q0("message",w),k),("strict"in H))throw Error("options.strict was renamed to lowS");const D=j===void 0?function(L){let S;const B=typeof L=="string"||T8(L),v=!B&&L!==null&&typeof L=="object"&&typeof L.r=="bigint"&&typeof L.s=="bigint";if(!B&&!v)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(v)S=new f(L.r,L.s);else if(B){try{S=f.fromBytes(Q0("sig",L),"der")}catch(b){if(!(b instanceof S0.Err))throw b}if(!S)try{S=f.fromBytes(Q0("sig",L),"compact")}catch(b){return!1}}return S||!1}(M):f.fromBytes(Q0("sig",M),j);if(D===!1)return!1;try{const L=W.fromBytes(Z);if(R&&D.hasHighS())return!1;const{r:S,s:B}=D,v=x(w),b=Y.inv(B),A=Y.create(v*b),E=Y.create(S*b),o=W.BASE.multiplyUnsafe(A).add(L.multiplyUnsafe(E));if(o.is0())return!1;return Y.create(o.x)===S}catch(L){return!1}},recoverPublicKey(M,w,Z={}){const{prehash:H}=L6(Z,$);return w=I(w,H),f.fromBytes(M,"recovered").recoverPublicKey(w).toBytes()},Signature:f,hash:Q})},jV=function(W){const{CURVE:Q,curveOpts:J}=function(G){const X={a:G.a,b:G.b,p:G.Fp.ORDER,n:G.n,h:G.h,Gx:G.Gx,Gy:G.Gy},Y=G.Fp;let q=G.allowedPrivateKeyLengths?Array.from(new Set(G.allowedPrivateKeyLengths.map((F)=>Math.ceil(F/2)))):void 0;return{CURVE:X,curveOpts:{Fp:Y,Fn:e1(X.n,{BITS:G.nBitLength,allowedLengths:q,modFromBytes:G.wrapPrivateKey}),allowInfinityPoint:G.allowInfinityPoint,endo:G.endo,isTorsionFree:G.isTorsionFree,clearCofactor:G.clearCofactor,fromBytes:G.fromBytes,toBytes:G.toBytes}}}(W),V={hmac:W.hmac,randomBytes:W.randomBytes,lowS:W.lowS,bits2int:W.bits2int,bits2int_modN:W.bits2int_modN};return{CURVE:Q,curveOpts:J,hash:W.hash,ecdsaOpts:V}},BV=function(W){const{CURVE:Q,curveOpts:J,hash:V,ecdsaOpts:G}=jV(W);return function(X,Y){const q=Y.Point;return Object.assign({},Y,{ProjectivePoint:q,CURVE:Object.assign({},X,UW(q.Fn.ORDER,q.Fn.BITS))})}(W,CV($V(Q,J),V,G))},v8=function(W,...Q){let J=b7[W];if(J===void 0){const V=x6(n7(W));J=D0(V,V),b7[W]=J}return x6(D0(J,...Q))},A6=function(W){const{Fn:Q,BASE:J}=D1,V=a0(Q,W),G=J.multiply(V);return{scalar:m6(G.y)?V:Q.neg(V),bytes:u6(G)}},BW=function(W){const Q=S8;if(!Q.isValidNot0(W))throw Error("invalid x: Fail if x \u2265 p");const J=Q.create(W*W),V=Q.create(J*W+BigInt(7));let G=Q.sqrt(V);m6(G)||(G=Q.neg(G));const X=D1.fromAffine({x:W,y:G});return X.assertValidity(),X},RW=function(...W){return D1.Fn.create(a1(v8("BIP0340/challenge",...W)))},h7=function(W){return A6(W).bytes},LV=function(W,Q,J=x8(32)){const{Fn:V}=D1,G=Q0("message",W),{bytes:X,scalar:Y}=A6(Q),q=Q0("auxRand",J,32),F=V.toBytes(Y^a1(v8("BIP0340/aux",q))),U=v8("BIP0340/nonce",F,X,G),{bytes:P,scalar:C}=A6(U),K=RW(P,X,G),z=new Uint8Array(64);if(z.set(P,0),z.set(V.toBytes(V.create(C+K*Y)),32),!MW(z,G,X))throw Error("sign: Invalid signature produced");return z},MW=function(W,Q,J){const{Fn:V,BASE:G}=D1,X=Q0("signature",W,64),Y=Q0("message",Q),q=Q0("publicKey",J,32);try{const F=BW(a1(q)),U=a1(X.subarray(0,32));if(!N6(U,p7,L1.p))return!1;const P=a1(X.subarray(32,64));if(!N6(P,p7,L1.n))return!1;const C=RW(V.toBytes(U),u6(F),Y),K=G.multiplyUnsafe(P).add(F.multiplyUnsafe(V.neg(C))),{x:z,y:$}=K.toAffine();return!(K.is0()||!m6($)||z!==U)}catch(F){return!1}},k1=typeof globalThis=="object"&&("crypto"in globalThis)?globalThis.crypto:void 0,r7=(()=>typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function")(),QV=Array.from({length:256},(W,Q)=>Q.toString(16).padStart(2,"0")),D7=48,VV=57,O7=65,GV=70,x7=97,XV=102;class y6{}class o7 extends y6{constructor(W,Q,J,V){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=W,this.outputLen=Q,this.padOffset=J,this.isLE=V,this.buffer=new Uint8Array(W),this.view=$6(this.buffer)}update(W){I8(this),W1(W=E6(W));const{view:Q,buffer:J,blockLen:V}=this,G=W.length;for(let X=0;X<G;){const Y=Math.min(V-this.pos,G-X);if(Y!==V)J.set(W.subarray(X,X+Y),this.pos),this.pos+=Y,X+=Y,this.pos===V&&(this.process(Q,0),this.pos=0);else{const q=$6(W);for(;V<=G-X;X+=V)this.process(q,X)}}return this.length+=W.length,this.roundClean(),this}digestInto(W){I8(this),function(P,C){W1(P);const K=C.outputLen;if(P.length<K)throw Error("digestInto() expects output buffer of length at least "+K)}(W,this),this.finished=!0;const{buffer:Q,view:J,blockLen:V,isLE:G}=this;let{pos:X}=this;Q[X++]=128,D8(this.buffer.subarray(X)),this.padOffset>V-X&&(this.process(J,0),X=0);for(let P=X;P<V;P++)Q[P]=0;(function(P,C,K,z){if(typeof P.setBigUint64=="function")return P.setBigUint64(C,K,z);const $=BigInt(32),N=BigInt(4294967295),g=Number(K>>$&N),p=Number(K&N),f=z?4:0,u=z?0:4;P.setUint32(C+f,g,z),P.setUint32(C+u,p,z)})(J,V-8,BigInt(8*this.length),G),this.process(J,0);const Y=$6(W),q=this.outputLen;if(q%4)throw Error("_sha2: outputLen should be aligned to 32bit");const F=q/4,U=this.get();if(F>U.length)throw Error("_sha2: outputLen bigger than state");for(let P=0;P<F;P++)Y.setUint32(4*P,U[P],G)}digest(){const{buffer:W,outputLen:Q}=this;this.digestInto(W);const J=W.slice(0,Q);return this.destroy(),J}_cloneInto(W){W||(W=new this.constructor),W.set(...this.get());const{blockLen:Q,buffer:J,length:V,finished:G,destroyed:X,pos:Y}=this;return W.destroyed=X,W.finished=G,W.length=V,W.pos=Y,V%Q&&W.buffer.set(J),W}clone(){return this._cloneInto()}}var b0=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),UV=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),h0=new Uint32Array(64);class a7 extends o7{constructor(W=32){super(64,W,8,!1),this.A=0|b0[0],this.B=0|b0[1],this.C=0|b0[2],this.D=0|b0[3],this.E=0|b0[4],this.F=0|b0[5],this.G=0|b0[6],this.H=0|b0[7]}get(){const{A:W,B:Q,C:J,D:V,E:G,F:X,G:Y,H:q}=this;return[W,Q,J,V,G,X,Y,q]}set(W,Q,J,V,G,X,Y,q){this.A=0|W,this.B=0|Q,this.C=0|J,this.D=0|V,this.E=0|G,this.F=0|X,this.G=0|Y,this.H=0|q}process(W,Q){for(let C=0;C<16;C++,Q+=4)h0[C]=W.getUint32(Q,!1);for(let C=16;C<64;C++){const K=h0[C-15],z=h0[C-2],$=I0(K,7)^I0(K,18)^K>>>3,N=I0(z,17)^I0(z,19)^z>>>10;h0[C]=N+h0[C-7]+$+h0[C-16]|0}let{A:J,B:V,C:G,D:X,E:Y,F:q,G:F,H:U}=this;for(let C=0;C<64;C++){const K=U+(I0(Y,6)^I0(Y,11)^I0(Y,25))+((P=Y)&q^~P&F)+UV[C]+h0[C]|0,z=(I0(J,2)^I0(J,13)^I0(J,22))+qV(J,V,G)|0;U=F,F=q,q=Y,Y=X+K|0,X=G,G=V,V=J,J=K+z|0}var P;J=J+this.A|0,V=V+this.B|0,G=G+this.C|0,X=X+this.D|0,Y=Y+this.E|0,q=q+this.F|0,F=F+this.G|0,U=U+this.H|0,this.set(J,V,G,X,Y,q,F,U)}roundClean(){D8(h0)}destroy(){this.set(0,0,0,0,0,0,0,0),D8(this.buffer)}}var x6=YV(()=>new a7);class f6 extends y6{constructor(W,Q){super(),this.finished=!1,this.destroyed=!1,i7(W);const J=E6(Q);if(this.iHash=W.create(),typeof this.iHash.update!="function")throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const V=this.blockLen,G=new Uint8Array(V);G.set(J.length>V?W.create().update(J).digest():J);for(let X=0;X<G.length;X++)G[X]^=54;this.iHash.update(G),this.oHash=W.create();for(let X=0;X<G.length;X++)G[X]^=106;this.oHash.update(G),D8(G)}update(W){return I8(this),this.iHash.update(W),this}digestInto(W){I8(this),W1(W,this.outputLen),this.finished=!0,this.iHash.digestInto(W),this.oHash.update(W),this.oHash.digestInto(W),this.destroy()}digest(){const W=new Uint8Array(this.oHash.outputLen);return this.digestInto(W),W}_cloneInto(W){W||(W=Object.create(Object.getPrototypeOf(this),{}));const{oHash:Q,iHash:J,finished:V,destroyed:G,blockLen:X,outputLen:Y}=this;return W.finished=V,W.destroyed=G,W.blockLen=X,W.outputLen=Y,W.oHash=Q._cloneInto(W.oHash),W.iHash=J._cloneInto(W.iHash),W}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}var s7=(W,Q,J)=>new f6(W,Q).update(J).digest();s7.create=(W,Q)=>new f6(W,Q);var p6=BigInt(0),w6=BigInt(1),C6=(W)=>typeof W=="bigint"&&p6<=W,s1=(W)=>(w6<<BigInt(W))-w6,K0=BigInt(0),U0=BigInt(1),s0=BigInt(2),QW=BigInt(3),VW=BigInt(4),GW=BigInt(5),PV=BigInt(7),XW=BigInt(8),KV=BigInt(9),S7=BigInt(16),ZV=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"],M1=BigInt(0),e0=BigInt(1),R6=new WeakMap,ZW=new WeakMap;class HW{constructor(W,Q){this.BASE=W.BASE,this.ZERO=W.ZERO,this.Fn=W.Fn,this.bits=Q}_unsafeLadder(W,Q,J=this.ZERO){let V=W;for(;Q>M1;)Q&e0&&(J=J.add(V)),V=V.double(),Q>>=e0;return J}precomputeWindow(W,Q){const{windows:J,windowSize:V}=B6(Q,this.bits),G=[];let X=W,Y=X;for(let q=0;q<J;q++){Y=X,G.push(Y);for(let F=1;F<V;F++)Y=Y.add(X),G.push(Y);X=Y.double()}return G}wNAF(W,Q,J){if(!this.Fn.isValid(J))throw Error("invalid scalar");let V=this.ZERO,G=this.BASE;const X=B6(W,this.bits);for(let Y=0;Y<X.windows;Y++){const{nextN:q,offset:F,isZero:U,isNeg:P,isNegF:C,offsetF:K}=g7(J,Y,X);J=q,U?G=G.add(N8(C,Q[K])):V=V.add(N8(P,Q[F]))}return E7(J),{p:V,f:G}}wNAFUnsafe(W,Q,J,V=this.ZERO){const G=B6(W,this.bits);for(let X=0;X<G.windows&&J!==M1;X++){const{nextN:Y,offset:q,isZero:F,isNeg:U}=g7(J,X,G);if(J=Y,!F){const P=Q[q];V=V.add(U?P.negate():P)}}return E7(J),V}getPrecomputes(W,Q,J){let V=R6.get(Q);return V||(V=this.precomputeWindow(Q,W),W!==1&&(typeof J=="function"&&(V=J(V)),R6.set(Q,V))),V}cached(W,Q,J){const V=M6(W);return this.wNAF(V,this.getPrecomputes(V,W,J),Q)}unsafe(W,Q,J,V){const G=M6(W);return G===1?this._unsafeLadder(W,Q,V):this.wNAFUnsafe(G,this.getPrecomputes(G,W,J),Q,V)}createCache(W,Q){zW(Q,this.bits),ZW.set(W,Q),R6.delete(W)}hasCache(W){return M6(W)!==1}}var f7=(W,Q)=>(W+(W>=0?Q:-Q)/kW)/Q,S0={Err:class extends Error{constructor(W=""){super(W)}},_tlv:{encode(W,Q){const{Err:J}=S0;if(W<0||W>256)throw new J("tlv.encode: wrong tag");if(1&Q.length)throw new J("tlv.encode: unpadded data");const V=Q.length/2,G=C8(V);if(G.length/2&128)throw new J("tlv.encode: long form length too big");const X=V>127?C8(G.length/2|128):"";return C8(W)+X+G+Q},decode(W,Q){const{Err:J}=S0;let V=0;if(W<0||W>256)throw new J("tlv.encode: wrong tag");if(Q.length<2||Q[V++]!==W)throw new J("tlv.decode: wrong tlv");const G=Q[V++];let X=0;if(128&G){const q=127&G;if(!q)throw new J("tlv.decode(long): indefinite length not supported");if(q>4)throw new J("tlv.decode(long): byte length is too big");const F=Q.subarray(V,V+q);if(F.length!==q)throw new J("tlv.decode: length bytes not complete");if(F[0]===0)throw new J("tlv.decode(long): zero leftmost byte");for(let U of F)X=X<<8|U;if(V+=q,X<128)throw new J("tlv.decode(long): not minimal encoding")}else X=G;const Y=Q.subarray(V,V+X);if(Y.length!==X)throw new J("tlv.decode: wrong value length");return{v:Y,l:Q.subarray(V+X)}}},_int:{encode(W){const{Err:Q}=S0;if(W<v0)throw new Q("integer: negative integers are not allowed");let J=C8(W);if(8&Number.parseInt(J[0],16)&&(J="00"+J),1&J.length)throw new Q("unexpected DER parsing assertion: unpadded hex");return J},decode(W){const{Err:Q}=S0;if(128&W[0])throw new Q("invalid signature integer: negative");if(W[0]===0&&!(128&W[1]))throw new Q("invalid signature integer: unnecessary leading zero");return I1(W)}},toSig(W){const{Err:Q,_int:J,_tlv:V}=S0,G=Q0("signature",W),{v:X,l:Y}=V.decode(48,G);if(Y.length)throw new Q("invalid signature: left bytes after parsing");const{v:q,l:F}=V.decode(2,X),{v:U,l:P}=V.decode(2,F);if(P.length)throw new Q("invalid signature: left bytes after parsing");return{r:J.decode(q),s:J.decode(U)}},hexFromSig(W){const{_tlv:Q,_int:J}=S0,V=Q.encode(2,J.encode(W.r))+Q.encode(2,J.encode(W.s));return Q.encode(48,V)}},v0=BigInt(0),j1=BigInt(1),kW=BigInt(2),j8=BigInt(3),kV=BigInt(4),L1={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},RV={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},MV=BigInt(0),p7=BigInt(1),v6=BigInt(2),S8=e1(L1.p,{sqrt(W){const Q=L1.p,J=BigInt(3),V=BigInt(6),G=BigInt(11),X=BigInt(22),Y=BigInt(23),q=BigInt(44),F=BigInt(88),U=W*W*W%Q,P=U*U*W%Q,C=$0(P,J,Q)*P%Q,K=$0(C,J,Q)*P%Q,z=$0(K,v6,Q)*U%Q,$=$0(z,G,Q)*z%Q,N=$0($,X,Q)*$%Q,g=$0(N,q,Q)*N%Q,p=$0(g,F,Q)*g%Q,f=$0(p,q,Q)*N%Q,u=$0(f,J,Q)*P%Q,x=$0(u,Y,Q)*$%Q,c=$0(x,V,Q)*U%Q,a=$0(c,v6,Q);if(!S8.eql(S8.sqr(a),W))throw Error("Cannot find square root");return a}}),jW=function(W,Q){const J=(V)=>BV({...W,hash:V});return{...J(Q),create:J}}({...L1,Fp:S8,lowS:!0,endo:RV},x6),b7={},u6=(W)=>W.toBytes(!0).slice(1),D1=(()=>jW.Point)(),m6=(W)=>W%v6===MV,a1=I1,_6=(()=>{const W=(Q=x8(48))=>FW(Q,L1.n);return jW.utils.randomSecretKey,{keygen(Q){const J=W(Q);return{secretKey:J,publicKey:h7(J)}},getPublicKey:h7,sign:LV,verify:MW,Point:D1,utils:{randomSecretKey:W,randomPrivateKey:W,taggedHash:v8,lift_x:BW,pointToBytes:u6,numberToBytesBE:g8,bytesToNumberBE:I1,mod:C0},lengths:{secretKey:32,publicKey:32,publicKeyHasPrefix:!1,signature:64,seed:48}}})(),IV=new TextEncoder,DV=new TextDecoder,t0=(W)=>IV.encode(W),o1=(W)=>DV.decode(W),T6=(W)=>Array.from(W,(Q)=>Q.toString(16).padStart(2,"0")).join(""),A0=JSON.stringify,A8=JSON.parse,LW=(W,Q=Number.MAX_SAFE_INTEGER)=>W.split("").reduce((J,V)=>J+V.charCodeAt(0),0)%Q,c6="AES-GCM",OV={},B8=(W)=>OV[W]??=crypto.subtle.digest("SHA-1",t0(W)).then((Q)=>{const J=new Uint8Array(Q);let V="";for(let G of J)V+=G.toString(36);return V}),xV=async(W,Q)=>{const J=crypto.getRandomValues(new Uint8Array(12)),V=await W,G=await crypto.subtle.encrypt({name:c6,iv:J},V,t0(Q));return`${J.join(",")}\$${((X)=>{const Y=new Uint8Array(X);let q="";for(let F=0;F<Y.length;F+=32768)q+=String.fromCharCode(...Y.subarray(F,F+32768));return btoa(q)})(G)}`},wV=async(W,Q)=>{const[J,V]=Q.split("$");if(!J||!V)throw Error("Invalid encrypted payload format");const G=Uint8Array.from(J.split(","),Number),X=await W,Y=await crypto.subtle.decrypt({name:c6,iv:G},X,(q=V,Uint8Array.from(atob(q),(F)=>F.charCodeAt(0)).buffer));var q;return o1(Y)},Z0="GenosRTC",d6=(W,Q)=>Array.from({length:W},Q),NV="0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz",g6=(W)=>Array.from(crypto.getRandomValues(new Uint8Array(W)),(Q)=>NV[Q%62]).join(""),$1=g6(20),B1=Promise.all.bind(Promise),SV=typeof window!="undefined",{entries:vV,fromEntries:IW}=Object,AV=()=>{},N0=(W)=>Error(`${Z0}: ${W}`),R8=(...W)=>W.join("@"),u7="icegatheringstatechange",m7="offer",TV=[...d6(3,(W,Q)=>`stun:stun${Q||""}.l.google.com:19302`),"stun:stun.cloudflare.com:3478"].map((W)=>({urls:W})),I6=(W,{rtcConfig:Q,rtcPolyfill:J,turnConfig:V})=>{const G=new(J||RTCPeerConnection)({iceServers:[...TV,...V||[]],...Q}),X={};let Y,q=!1,F=!1;const U=(K)=>Object.assign(K,{binaryType:"arraybuffer",bufferedAmountLowThreshold:65535,onmessage(z){return X.data?.(z.data)},onopen(){return X.connect?.()},onclose(){return X.close?.()},onerror(z){return!z?.error?.message?.includes("User-Initiated Abort")&&X.error?.(z)}}),P=()=>Promise.race([new Promise((K)=>{const z=()=>{G.iceGatheringState==="complete"&&(G.removeEventListener(u7,z),K())};G.addEventListener(u7,z),z()}),new Promise((K)=>setTimeout(K,5000))]).then(()=>({type:G.localDescription.type,sdp:G.localDescription.sdp.replace(/a=ice-options:trickle\s\n/g,"")}));W?U(Y=G.createDataChannel("data")):G.ondatachannel=({channel:K})=>U(Y=K),G.onnegotiationneeded=async()=>{try{q=!0,await G.setLocalDescription(),X.signal?.(await P())}catch(K){X.error?.(K)}finally{q=!1}},G.onconnectionstatechange=()=>{["disconnected","failed","closed"].includes(G.connectionState)&&X.close?.()},G.ontrack=(K)=>{X.track?.(K.track,K.streams[0]),X.stream?.(K.streams[0])},G.onremovestream=(K)=>X.stream?.(K.stream),W&&!G.canTrickleIceCandidates&&G.onnegotiationneeded();const C=()=>G.getSenders();return{created:Date.now(),connection:G,get channel(){return Y},get isDead(){return G.connectionState==="closed"},async signal(K){if(Y?.readyState!=="open"||K.sdp?.includes("a=rtpmap"))try{if(K.type===m7){if(q||G.signalingState!=="stable"&&!F){if(W)return;await B1([G.setLocalDescription({type:"rollback"}),G.setRemoteDescription(K)])}else await G.setRemoteDescription(K);await G.setLocalDescription();const z=await P();return X.signal?.(z),z}if(K.type==="answer"){F=!0;try{await G.setRemoteDescription(K)}finally{F=!1}}}catch(z){X.error?.(z)}},sendData(K){return Y.send(K)},destroy(){Y?.close(),G.close(),q=F=!1},setHandlers(K){return Object.assign(X,K)},offerPromise:W?new Promise((K)=>X.signal=(z)=>z.type===m7&&K(z)):Promise.resolve(),addStream(K){return K.getTracks().forEach((z)=>G.addTrack(z,K))},removeStream(K){return C().filter((z)=>K.getTracks().includes(z.track)).forEach((z)=>G.removeTrack(z))},addTrack(K,z){return G.addTrack(K,z)},removeTrack(K){const z=C().find(($)=>$.track===K);z&&G.removeTrack(z)},replaceTrack(K,z){return C().find(($)=>$.track===K)?.replaceTrack(z)}}},gV=Object.getPrototypeOf(Uint8Array),r1=16369,M8=255,D6="bufferedamountlow",C1=(W)=>"@_"+W,EV=(W,Q,J)=>{const V=new Map,G=new Map,X=new Map,Y={},q={},F={},U={},P=new Map,C=(k,...j)=>P.get(k)?.forEach((D)=>D(...j)),K=(k,j)=>{const D=k?Array.isArray(k)?k:[k]:V.keys();return Array.from(D,(L)=>{const S=V.get(L);return S?j(L,S):(console.warn(`${Z0}: no peer with id ${L}`),null)}).filter(Boolean)},z=(k)=>{V.has(k)&&(V.delete(k),delete Y[k],delete q[k],delete F[k],delete U[k],C("peer:leave",k),Q(k))},$=(k)=>new Promise((j,D)=>{let L=setTimeout(()=>{k.removeEventListener(D6,S),D(Error(Z0+": bufferLow timeout"))},5000);function S(){clearTimeout(L),k.removeEventListener(D6,S),j()}k.addEventListener(D6,S)}),N=(k)=>{if(X.has(k))return X.get(k);if(!k)throw N0("action type is required");const j=t0(k);if(j.byteLength>12)throw N0(`"${k}" exceeds 12 bytes`);const D=new Uint8Array(12).map((b,A)=>j[A]||0);let L=0;const S=new Map([["message",new Set],["progress",new Set]]),B=async(b,A,E,o)=>{if(E&&typeof E!="object")throw N0("meta must be object");if(b===void 0)throw N0("data cannot be undefined");const i=b instanceof Blob,r=i||b instanceof ArrayBuffer||b instanceof gV,O=typeof b!="string";if(E&&!r)throw N0("meta only allowed with binary");const y=r?new Uint8Array(i?await b.arrayBuffer():b):t0(O?A0(b):b),m=E?t0(A0(E)):null,d=Math.ceil(y.byteLength/r1)+(E?1:0)||1;if(d>100)throw N0("Message too large, exceeds max chunks 100");const T=d6(d,(_,h)=>{const n=h===d-1,l=E&&h===0,G0=l?m:y.subarray(E?(h-1)*r1:h*r1,E?h*r1:(h+1)*r1),t=new Uint8Array(15+G0.byteLength);return t.set(D),t.set([L],12),t.set([n|l<<1|r<<2|O<<3],13),t.set([Math.round((h+1)/d*M8)],14),t.set(G0,15),t});return L=L+1&M8,B1(K(A,async(_,h)=>{const{channel:n}=h;for(let l=0;l<d;l++){let G0=0;for(;n.bufferedAmount>n.bufferedAmountLowThreshold;){if(G0++>3)throw N0(`${Z0}: send buffer full, max retries reached for peer ${_}`);try{await $(n)}catch(t){console.warn(t.message),await new Promise((j0)=>setTimeout(j0,200))}}if(!V.has(_))break;h.sendData(T[l]),o?.(T[l][14]/M8,_,E)}}))};G.set(k,{listeners:S,send:B});const v={send:B,on(b,A){return S.get(b)?.add(A)},off(b,A){return S.get(b)?.delete(A)}};return X.set(k,v),v},g=async()=>{try{await H(""),await new Promise((k)=>setTimeout(k,99))}catch(k){console.warn(Z0+": error sending leave",k)}for(let[k,j]of V){try{j.destroy()}catch{}V.delete(k)}J()},{send:p,on:f}=N(C1("ping")),{send:u,on:x}=N(C1("pong")),{send:c,on:a}=N(C1("signal")),{send:I,on:M}=N(C1("stream")),{send:w,on:Z}=N(C1("track")),{send:H,on:R}=N(C1("leave"));return W((k,j)=>{V.has(j)||(V.set(j,k),k.setHandlers({data(D){return((L,S)=>{try{const B=new Uint8Array(S),v=o1(B.subarray(0,12)).replace(/\0/g,"");if(!G.has(v))return console.warn(`${Z0}: unregistered type (${v})`);const[b]=B.subarray(12,13),[A]=B.subarray(13,14),[E]=B.subarray(14,15),o=B.subarray(15),i=!!(1&A),r=!!(2&A),O=!!(4&A),y=!!(8&A),m=G.get(v),d=(Y[L]||={})[v]||={};if(d[b]?.chunks?.length>100)return void console.warn(`${Z0}: peer ${L} sent too many chunks for nonce ${b}, ignoring.`);const T=d[b]||={chunks:[]};if(r)try{T.meta=A8(o1(o))}catch{return void console.warn(`${Z0}: failed to parse meta from peer ${L} for type ${v}`)}else T.chunks.push(o);if(m.listeners.get("progress").forEach((n)=>{try{n(E/M8,L,T.meta)}catch(l){console.error(l)}}),!i)return;const _=new Uint8Array(T.chunks.reduce((n,l)=>n+l.byteLength,0));let h;if(T.chunks.reduce((n,l)=>(_.set(l,n),n+l.byteLength),0),delete d[b],O)h=_;else if(y)try{h=A8(o1(_))}catch{return void console.warn(`${Z0}: failed to parse JSON message data from peer ${L} for type ${v}`)}else h=o1(_);m.listeners.get("message").forEach((n)=>{try{n(h,L,T.meta)}catch(l){console.error(l)}})}catch(B){console.error(`${Z0}: error handling data from peer ${L}:`,B)}})(j,D)},stream(D){C("stream:add",D,j,F[j]),delete F[j]},track(D,L){C("track:add",D,L,j,U[j]),delete U[j]},signal(D){return c(D,j)},close(){return z(j)},error(D){console.error(`${Z0}: peer error for ${j}`,D),z(j)}}),C("peer:join",j))}),f("message",(k,j)=>u("",j)),x("message",(k,j)=>{q[j]?.(),delete q[j]}),a("message",(k,j)=>V.get(j)?.signal(k)),M("message",(k,j)=>F[j]=k),Z("message",(k,j)=>U[j]=k),R("message",(k,j)=>z(j)),SV&&addEventListener("beforeunload",g),{on(k,j){P.has(k)||P.set(k,new Set),P.get(k).add(j)},off(k,j){return P.get(k)?.delete(j)},channel:N,leave:g,async ping(k){if(!k)throw N0("ping() requires target peer ID");const j=Date.now();return p("",k),await new Promise((D)=>q[k]=D),Date.now()-j},getPeers(){return IW(Array.from(V,([k,j])=>[k,j.connection]))},addStream(k,j,D){return K(j,async(L,S)=>{D&&await I(D,L),S.addStream(k)})},removeStream(k,j){return K(j,(D,L)=>L.removeStream(k))},addTrack(k,j,D,L){return K(D,async(S,B)=>{L&&await w(L,S),B.addTrack(k,j)})},removeTrack(k,j){return K(j,(D,L)=>L.removeTrack(k))},replaceTrack(k,j,D,L){return K(D,async(S,B)=>{L&&await w(L,S),B.replaceTrack(k,j)})}}},L8={},DW={};if(typeof window!="undefined"){const W=()=>{console.info("\u26A1 [GenosRTC] Network event detected. Forcing reconnection\u2026"),Object.values(DW).forEach((Q)=>{Q.socket&&Q.socket.readyState!==WebSocket.OPEN&&Q.socket.readyState!==WebSocket.CONNECTING&&Q.forceReconnect()})};window.addEventListener("online",()=>{console.info("\u2705 Reconnected to the network."),W()}),window.addEventListener("offline",async()=>{console.info("\u274C Disconnected from the network.")}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&W()})}var yV=(W,Q,J,V)=>(W.relayUrls??(V?((G,X)=>{const Y=[...G];let q=Y.length;const F=()=>{const U=1e4*Math.sin(X++);return U-Math.floor(U)};for(;q;){const U=Math.floor(F()*q--);[Y[q],Y[U]]=[Y[U],Y[q]]}return Y})(Q,LW(W.appId)):Q)).slice(0,W.relayUrls?.length??W.relayRedundancy??J),OW={},xW="EVENT",wW=_6.utils.randomSecretKey(),fV=T6(_6.getPublicKey(wW)),l6={},n1={},pV={},NW=()=>Math.floor(Date.now()/1000),SW=(W)=>pV[W]??=LW(W,1e4)+20000,_7=async(W,Q)=>{const J={kind:SW(W),content:Q,pubkey:fV,created_at:NW(),tags:[["x",W]]},V=new Uint8Array(await crypto.subtle.digest("SHA-256",t0(A0([0,J.pubkey,J.created_at,J.kind,J.tags,J.content])))),G=_6.sign(V,wW);return A0([xW,{...J,id:T6(V),sig:T6(G)}])},c7=(W,Q)=>(l6[W]=Q,A0(["REQ",W,{kinds:[SW(Q)],since:NW(),"#x":[Q]}])),d7=(W)=>(delete l6[W],A0(["CLOSE",W])),i6=(({init:W,subscribe:Q,announce:J})=>{const V={};let G,X,Y=!1;return(q,F,U)=>{const{appId:P}=q;if(V[P]?.[F])return V[P][F];if(!q||!F||!P&&!q.firebaseApp)throw N0(q?F?"appId missing":"roomId required":"config required");let C=AV;if(!Y){const Z=W(q);X=d6(20,()=>I6(!0,q)),G=Array.isArray(Z)?Z:[Z];const H=setInterval(()=>{X=X.filter((R)=>{const k=Date.now()-R.created<57333;return k||R.destroy(),k})},57333);V.offerCleanupTimer||=H,Y=!0}const K={},z={},$=R8(Z0,P,F),N=B8($),g=B8(R8($,$1)),p=(async(Z,H,R)=>{const k=await crypto.subtle.digest("SHA-256",t0(`${Z}:${H}:${R}`));return crypto.subtle.importKey("raw",k,{name:c6},!1,["encrypt","decrypt"])})(q.password||"",P,F),f=(Z)=>async(H)=>({type:H.type,sdp:await Z(p,H.sdp)}),u=f(wV),x=f(xV),c=(Z,H)=>{z[H]!==Z&&(z[H]?.destroy(),z[H]=Z,C(Z,H),K[H]?.forEach((R)=>R!==Z&&R.destroy()),delete K[H])},a=(Z,H)=>{z[H]===Z&&delete z[H]},I=B1(G.map(async(Z,H)=>{return Q(await Z,await N,await g,(R=H,async(k,j,D)=>{const[L,S]=await B1([N,g]);if(k!==L&&k!==S)return;const{peerId:B,offer:v,answer:b}=typeof j=="string"?A8(j):j;if(B!==$1&&!z[B])if(v){if(K[B]?.[R]&&$1>B)return;const A=I6(!1,q);A.setHandlers({connect(){return c(A,B)},close(){return a(A,B)}});try{const E=await u(v);if(A.isDead)return;const[o,i]=await B1([B8(R8($,B)),A.signal(E).then(x)]);D(o,A0({peerId:$1,answer:i}))}catch{U?.({error:"decryption failed (offer)",appId:P,peerId:B,roomId:F})}}else if(b){const A=K[B]?.[R];if(!A||A.isDead)return;A.setHandlers({connect(){return c(A,B)},close(){return a(A,B)}});try{A.signal(await u(b))}catch{U?.({error:"decryption failed (answer)",appId:P,peerId:B,roomId:F})}}else{if(K[B]?.[R])return;const A=X.pop()||I6(!0,q),[E,{offer:o}]=await B1([B8(R8($,B)),A.offerPromise.then(x).then((i)=>({offer:i}))]);K[B]||=[],K[B][R]=A,A.setHandlers({connect(){return c(A,B)},close(){return a(A,B)}}),D(E,A0({peerId:$1,offer:o,peer:A}))}}));var R})),M=[];I.then((Z)=>{G.forEach((H,R)=>{const k=async()=>{const j=await J(await H,await N,await g);M[R]=setTimeout(k,typeof j=="number"?j:5333)};k()}),V[P][F].onCleanup=()=>{delete V[P][F],M.forEach(clearTimeout),Z.forEach((H)=>H()),Object.keys(V).length===0&&(clearInterval(V.offerCleanupTimer),delete V.offerCleanupTimer)}}),V[P]||={};const w=EV((Z)=>C=Z,(Z)=>delete z[Z],()=>w.onCleanup?.());return V[P][F]=w}})({init(W){return yV(W,bV,5,!0).map((Q)=>{const J=((V,G)=>{const X={};let Y=null;const q=()=>{Y&&(clearTimeout(Y),Y=null);const F=new WebSocket(V);F.onclose=()=>{L8[V]??=3333,Y=setTimeout(q,L8[V]),L8[V]*=2},F.onmessage=(U)=>G(U.data),X.socket=F,X.url=F.url,X.ready=new Promise((U)=>{F.onopen=()=>{L8[V]=3333,U(X)}}),X.send=(U)=>{F.readyState===1&&F.send(U)}};return X.forceReconnect=q,q(),DW[V]=X,X})(Q,(V)=>{const[G,X,Y,q]=A8(V);if(G===xW)n1[X]?.(l6[X],Y.content);else{const F=`${Z0}: relay failure from ${J.url} - `;G==="NOTICE"?console.warn(F+X):G!=="OK"||Y||console.warn(F+q)}});return OW[Q]=J,J.ready})},subscribe(W,Q,J,V){const G=g6(64),X=g6(64);return n1[G]=n1[X]=(Y,q)=>V(Y,q,async(F,U)=>W.send(await _7(F,U))),W.send(c7(G,Q)),W.send(c7(X,J)),()=>{W.send(d7(G)),W.send(d7(X)),delete n1[G],delete n1[X]}},async announce(W,Q){return W.send(await _7(Q,A0({peerId:$1})))}}),OG=(l7=OW,()=>IW(vV(l7).map(([W,Q])=>[W,Q.socket]))),l7,bV=["black.nostrcity.club","eu.purplerelay.com","ftp.halifax.rwth-aachen.de/nostr","nostr.cool110.xyz","nostr.data.haus","nostr.mom","nostr.oxtr.dev","nostr.sathoarder.com","nostr.vulpem.com","playground.nostrcheck.me/relay","relay.agorist.space","relay.binaryrobot.com","relay.fountain.fm","relay.mostro.network","relay.nostraddress.com","relay.nostrdice.com","relay.nostromo.social","relay.oldenburg.cool","relay.snort.social","relay.verified-nostr.com","sendit.nosflare.com","yabu.me/v2","relay.damus.io"].map((W)=>"wss://"+W);function vW(W,Q,J){let V=Q.timestamp;if(V?.physical>Date.now()+7200000)V={physical:Date.now()+7200000,logical:V.logical};if(!W?.timestamp)return{resolved:!0,value:Q.value,timestamp:V};if(J.compare(V,W.timestamp)<=0)return{resolved:!1};return{resolved:!0,value:Q.value,timestamp:V}}function AW(W,Q=50){const J=`gdb_oplog_${W}`;let V=[];function G(){try{const Y=localStorage.getItem(J);V=Y?JSON.parse(Y):[]}catch(Y){console.error("\u274C GDB: Failed to load oplog from localStorage:",Y),V=[]}}function X(){try{localStorage.setItem(J,JSON.stringify(V))}catch(Y){console.error("\u274C GDB: Failed to save oplog to localStorage:",Y)}}return G(),{remove(Y){V=V.filter((q)=>q.id!==Y),X()},add(Y){if(V.push(Y),V.length>Q)V.shift();X()},getDelta(Y,q){if(!Y)return[...V];return V.filter((F)=>q(F.timestamp,Y)>0)},getOldest(){return V[0]},clear(){V=[],localStorage.removeItem(J)}}}var hV=()=>{const W=new Map,Q=async()=>{try{const F=await navigator.storage.getDirectory(),P=await(await F.getFileHandle("~opfs-sync-test",{create:!0})).createSyncAccessHandle?.();return await P?.close(),await F.removeEntry("~opfs-sync-test"),!!P}catch{return!1}};let J="idb";const V=(async()=>{if(await Q())J="sync";else try{const F=await navigator.storage.getDirectory(),P=await(await F.getFileHandle("~opfs-async-test",{create:!0})).createWritable?.();if(await P?.close(),await F.removeEntry("~opfs-async-test"),P)J="async";else J="idb"}catch{J="idb"}})(),G=async(F,U)=>{if(!W.has(F))W.set(F,[]);const P=W.get(F),C=P[P.length-1]||Promise.resolve();let K;const z=new Promise(($)=>K=$);P.push(z);try{return await C,await U()}finally{if(P.shift(),K(),P.length===0)W.delete(F)}},X=(()=>{let F;const U=async()=>{if(!F)F=new Promise((P,C)=>{const K=indexedDB.open("opfs-fallback-db",1);K.onupgradeneeded=()=>K.result.createObjectStore("files"),K.onsuccess=()=>P(K.result),K.onerror=()=>C(K.error)});return F};return{getDB:U,get:async(P)=>{const C=await U();return new Promise((K,z)=>{const N=C.transaction("files","readonly").objectStore("files").get(P);N.onsuccess=()=>K(N.result||new Uint8Array),N.onerror=()=>z(N.error)})},set:async(P,C)=>{const K=await U();return new Promise((z,$)=>{const g=K.transaction("files","readwrite").objectStore("files").put(C,P);g.onsuccess=()=>z(),g.onerror=()=>$(g.error)})}}})(),Y=async(F)=>{await V;try{if(J==="idb"){const z=await X.get(F);return{type:"loaded",name:F,data:z}}const P=await(await navigator.storage.getDirectory()).getFileHandle(F);if(J==="sync"){let z;try{z=await P.createSyncAccessHandle();const $=z.getSize(),N=new Uint8Array($),g=z.read(N,{at:0});return{type:"loaded",name:F,data:N.slice(0,g)}}finally{z?.close()}}const C=await P.getFile(),K=new Uint8Array(await C.arrayBuffer());return{type:"loaded",name:F,data:K}}catch(U){const P=U.name==="NotFoundError"?"File not found":U.message||"Error reading file";return{type:"error",name:F,message:P}}},q=async(F,U)=>{if(await V,!(U instanceof Uint8Array))return{type:"error",name:F,message:"Content must be a Uint8Array"};return G(F,async()=>{try{if(J==="idb")return await X.set(F,U),{type:"saved",name:F};const C=await(await navigator.storage.getDirectory()).getFileHandle(F,{create:!0});if(J==="sync"){let K;try{K=await C.createSyncAccessHandle(),K.truncate(0),K.write(U,{at:0}),K.flush()}finally{K?.close()}}else{let K;try{K=await C.createWritable(),await K.write(U)}finally{await K?.close()}}return{type:"saved",name:F}}catch(P){return{type:"error",name:F,message:P.message||"Error saving file"}}})};self.onmessage=async({data:F})=>{const{type:U,name:P,content:C}=F;await V;const K={load:()=>Y(P),save:()=>q(P,C)};try{const z=K[U],$=z?await z():{type:"error",message:`Unrecognized action type: ${U}`};self.postMessage($)}catch(z){console.error("\u274C Worker unexpected error:",z),self.postMessage({type:"error",name:P,message:z.message||"Unexpected worker error"})}}},TW=hV;var J1={$eq:(W,Q)=>W===Q,$ne:(W,Q)=>W!==Q,$gt:(W,Q)=>W>Q,$gte:(W,Q)=>W>=Q,$lt:(W,Q)=>W<Q,$lte:(W,Q)=>W<=Q,$in:(W,Q)=>Array.isArray(Q)&&(Array.isArray(W)?W.some((J)=>Q.includes(J)):Q.includes(W)),$between:(W,[Q,J])=>W>=Q&&W<=J,$exists:(W,Q)=>Q?W!==void 0:W===void 0,$text:{global:(W,Q)=>{const J=(G)=>String(G).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\w\s]/g,""),V=J(Q);return Object.values(W).some((G)=>typeof G==="object"?null.fieldSearch(G,V):J(G).includes(V))},field:(W,Q)=>{const J=(G)=>String(G).normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^\w\s]/g,""),V=J(Q);return Array.isArray(W)?W.some((G)=>J(G).includes(V)):J(W).includes(V)}},$like:(W,Q)=>typeof W==="string"&&typeof Q==="string"&&new RegExp(`^${Q.replace(/%/g,".*").replace(/_/g,".")}\$`,"i").test(W),$regex:(W,Q)=>typeof W==="string"&&new RegExp(Q.$regex||Q,"i").test(W),$and:(W,Q,J)=>Q.every((V)=>J.createFilter(V,J.allNodes)(W)),$or:(W,Q,J)=>Q.some((V)=>J.createFilter(V,J.allNodes)(W)),$not:(W,Q,J)=>!J.createFilter(Q,J.allNodes)(W),$edge:(W,Q,J)=>{if(!W.edges?.length||typeof Q!=="object"||Q===null)return!1;const V=J.createFilter(Q,J.allNodes),G=[...W.edges],X=new Set(G).add(W.id),Y=[];while(G.length){const q=G.shift(),F=J.allNodes[q];if(!F)continue;if(V(F))Y.push(F);F.edges?.forEach((U)=>!X.has(U)&&X.add(U)&&G.push(U))}if(Y.length)W._edgeResult=Y;return Y.length>0}},r6=(W,Q)=>Q.split(".").reduce((J,V)=>J&&typeof J==="object"&&(V in J)?J[V]:void 0,W),E8=(W,Q)=>{if(Object.keys(W).length===0)return()=>!0;return(J)=>Object.entries(W).every(([V,G])=>{if(V.startsWith("$"))return J1[V](J,G,{createFilter:E8,allNodes:Q});const X=r6(J.value,V);if(typeof G!=="object"||G===null)return J1.$eq(X,G);return Object.entries(G).every(([Y,q])=>{if(Y==="$text")return J1.$text.field(X,q);if(Y==="$between"&&q.every((F)=>F instanceof Date))return J1.$between(new Date(X),q);return J1[Y]?.(X,q,{createFilter:E8,allNodes:Q})??!1})})},n6=(W,Q)=>{const{$edge:J,...V}=Q.query||{},G=E8(V,W),X=Object.values(W).filter(G);let q=[...J?(()=>{const F=E8({$edge:J},W);X.forEach((P)=>F(P));const U=new Map;return X.forEach((P)=>{if(P._edgeResult)P._edgeResult.forEach((C)=>U.set(C.id,C)),delete P._edgeResult}),Array.from(U.values())})():X];if(Q.field){const F=Q.order==="asc"?1:-1;q.sort((U,P)=>{const C=r6(U.value,Q.field),K=r6(P.value,Q.field);if(typeof C==="string"&&typeof K==="string")return C.localeCompare(K)*F;return((C??0)-(K??0))*F})}if(Q.$after){const F=q.findIndex((U)=>U.id===Q.$after);q=F>=0?q.slice(F+1):[]}if(Q.$before){const F=q.findIndex((U)=>U.id===Q.$before);q=F>=0?q.slice(0,F):[]}if(Q.$limit)q=q.slice(0,Q.$limit);return q};function gW(){let W=Date.now(),Q=0;return{now(){const J=Date.now();return W=Math.max(W,J),Q++,{physical:W,logical:Q}},update(J){if(!J||typeof J.physical!=="number"||typeof J.logical!=="number"){console.warn("\u26A0\uFE0F HybridClock.update received an invalid remote timestamp.",J);return}W=Math.max(W,J.physical),Q=Math.max(Q,J.logical)+1},compare(J,V){if(!J&&!V)return 0;if(!J)return-1;if(!V)return 1;if(J.physical>V.physical)return 1;if(J.physical<V.physical)return-1;if(J.logical>V.logical)return 1;if(J.logical<V.logical)return-1;return 0}}}var EW=function(W,Q){return W.length===Q.length&&W.every((J,V)=>J===Q[V])};async function mV(){if(console.info(navigator?.storage?.getDirectory?"\u2705 OPFS is enabled.":"\uD83D\uDEAB OPFS is not available."),navigator?.storage?.getDirectory)await navigator.storage.getDirectory()}var _V=function(){const W={nodes:{}};return{get nodes(){return W.nodes},set nodes(J){W.nodes=J||{}},upsert(J,V,G){const X=W.nodes[J];W.nodes[J]={id:J,value:V&&typeof V==="object"?fW(V):V,edges:X?.edges?[...X.edges]:[],timestamp:G}},get(J){return W.nodes[J]||null},link(J,V,G){const X=W.nodes[J],Y=W.nodes[V];if(X&&Y&&!X.edges.includes(V))W.nodes[J]={...X,edges:[...X.edges,V],timestamp:G}},getAllNodes(){return Object.values(W.nodes)},serialize(){return H1.deflate(X1(W.nodes))},deserialize(J){W.nodes=N1(H1.inflate(new Uint8Array(J)))}}};async function mG(W,Q={}){console.info("\x1B[36m\u26A1 GenosDB: Empowering distributed graph databases with real-time synchronization and scalability. Learn more: https://github.com/estebanrfp/gdb \u26A1\x1B[0m");const{password:J,sm:V=!1,audit:G=!1,ii:X=!1,rx:Y=!1,ai:q=!1,geo:F=!1,relayUrls:U=null,turnConfig:P=null,saveDelay:C=200,oplogSize:K=20}=Q,z=_V(),$=gW(),N=AW(W,K),g=[];let p=null,f=[],u=null,x=null,c=null,a=null;const I=[],M={};Object.defineProperties(M,{hybridClock:{get:()=>$},graph:{get:()=>z},syncChannel:{get:()=>x},worker:{get:()=>u},oplog:{get:()=>N},broadcastChannel:{get:()=>c},options:{get:()=>Q},pako:{get:()=>H1},encode:{get:()=>X1},decode:{get:()=>N1},operators:{get:()=>J1},deepClone:{get:()=>fW},generateHash:{get:()=>L}});async function w(O,y){const m=new URL(`./${O}.min.js`,import.meta.url).href,d=`https://cdn.jsdelivr.net/npm/genosdb@latest/dist/${O}.min.js`;try{const T=await import(m).catch(()=>{return console.warn(`\u26A0\uFE0F ${O} not found locally, loading from CDN...`),import(d)}),_=y&&typeof y==="object"?y:{},h=typeof T.init==="function"?T.init(M,T,_):null;if(h)Object.assign(M,h);return T}catch(T){throw console.error(`\u274C Initialization of ${O} failed:`,T),T}}function Z(){const O=localStorage.getItem(`${W}_time`);p=O?JSON.parse(O):null}function H(O){p=O,localStorage.setItem(`${W}_time`,JSON.stringify(O))}function R(){try{const O=URL.createObjectURL(new Blob([`(${TW.toString()})()`],{type:"application/javascript"}));u=new Worker(O),URL.revokeObjectURL(O),u.addEventListener("message",({data:y})=>{console.info(`\uD83D\uDCBE ${y.name} ${y.type}`)}),console.info("\u2699\uFE0F Worker initialized successfully.")}catch({message:O}){console.error("\u274C Failed to initialize worker:",O)}}function k(){const O={...z.nodes};f.forEach((y)=>y(O))}const j=uV(()=>k()),D=yW(async()=>{const O=I.splice(0,I.length);if(!O.length)return!1;return await x.send(O),!0},16);async function L(){return crypto.randomUUID()}async function S(){try{const y=await((m)=>new Promise((d,T)=>{const _=async({data:h})=>{if(h.type==="loaded"&&h.name===m)u.removeEventListener("message",_),d(new Uint8Array(h.data));else if(h.type==="error")u.removeEventListener("message",_),T(new Error(h.message||"Unknown error"))};u.addEventListener("message",_),u.postMessage({type:"load",name:m})}))(`${W}_graph.msgpack`).catch(()=>new Uint8Array);y.byteLength>0?z.deserialize(y):console.warn("\u26A0\uFE0F The file '_graph.msgpack' is empty or could not be loaded."),console.info(`\u2705 Graph loaded: [ ${z.getAllNodes().length} nodes ]`)}catch({message:O}){console.error("\u274C Error loading the graph:",O)}}async function B(){try{const O=z.serialize();return await((m,d)=>new Promise((T,_)=>{const h=({data:n})=>{if(n.type==="saved"&&n.name===m)u.removeEventListener("message",h),T();else if(n.type==="error")u.removeEventListener("message",h),_(new Error(n.message||"Save error"))};u.addEventListener("message",h),u.postMessage({type:"save",name:m,content:d})}))(`${W}_graph.msgpack`,O),c.postMessage("update"),!0}catch({message:O}){throw console.error("\u274C Save error:",O),new Error("Save failed")}}const v=yW(()=>B(),C);async function b(O){try{console.info("\uD83D\uDD04 Applying full graph from remote..."),z.nodes={...O.nodes},await B()}catch({message:y}){console.error(`\u274C Error applying the full graph: ${y}`)}}async function A(O){let y=!1,m=null;const d={upsert:(T)=>{const _=z.get(T.id),h=vW(_,T,$);if(h.resolved){if(z.upsert(T.id,h.value,h.timestamp),$.update(h.timestamp),N.add({type:"upsert",id:T.id,timestamp:h.timestamp}),y=!0,!m||$.compare(h.timestamp,m)>0)m=h.timestamp}},remove:(T)=>{const _=z.get(T.id);if(_&&$.compare(_.timestamp,T.timestamp)<0){if(delete z.nodes[T.id],$.update(T.timestamp),N.add({type:"remove",id:T.id,timestamp:T.timestamp}),y=!0,!m||$.compare(T.timestamp,m)>0)m=T.timestamp}},link:(T)=>{const _=z.get(T.sourceId),h=z.get(T.targetId);if(_&&h&&$.compare(_.timestamp,T.timestamp)<0){if(z.link(T.sourceId,T.targetId,T.timestamp),$.update(T.timestamp),N.add({type:"link",sourceId:T.sourceId,targetId:T.targetId,timestamp:T.timestamp}),y=!0,!m||$.compare(T.timestamp,m)>0)m=T.timestamp}},sync:async(T)=>{const _=T.timestamp;if(_===null){console.info("\uD83D\uDCEC [SYNC REQUEST] from new peer (no timestamp). Sending full graph."),await x.send([{type:"syncReceive",graph:z}]);return}console.info("\uD83D\uDCEC [SYNC REQUEST] since:",new Date(_.physical).toLocaleString());const h=N.getOldest();if(h&&$.compare(_,h.timestamp)<0){console.info("\uD83D\uDCA5 [FALLBACK TRIGGERED] Peer is too far behind. Sending FULL graph state."),await x.send([{type:"syncReceive",graph:z}]);return}const n=N.getDelta(_,$.compare);if(n.length>0){const l=n.map((t)=>{if(t.type==="upsert"){const j0=z.get(t.id);return{...t,value:j0?j0.value:null}}return t}),G0=H1.deflate(X1(l));console.info(`\uD83D\uDE80 [DELTA SYNC SENDING] Found ${n.length} new operations to send.`),await x.send([{type:"deltaSync",operations:G0}])}else console.info("\u2705 [ALREADY SYNCED] Peer is up-to-date. Nothing to send.")},deltaSync:(T)=>{const _=T.operations.byteLength,h=N1(H1.inflate(T.operations)),n=X1(h).byteLength;console.info(`\uD83D\uDEF0\uFE0F [DELTA SYNC RECEIVED] Applying ${h.length} operations from a peer.`),console.info(` Compressed: ${_} bytes, Decompressed: ${n} bytes.`);for(let l of h)d[l.type]?.(l)},syncReceive:async(T)=>{if(console.info("\uD83D\uDCE6 [FULL SYNC RECEIVED] Overwriting local state with full graph from a peer."),T.graph&&T.graph.nodes){await b(T.graph),N.clear(),console.info("\uD83D\uDD12 Oplog has been cleared due to full sync."),y=!0;let _=null;for(let h in T.graph.nodes){const n=T.graph.nodes[h];if(n.timestamp&&(!_||$.compare(n.timestamp,_)>0))_=n.timestamp}if(_)console.info("\uD83D\uDCC8 [GLOBAL TIMESTAMP] Updated from full sync."),m=_,$.update(_)}else console.error("\u274C Full sync failed: received graph data is invalid.",T.graph)}};for(let T of O)if(d[T.type])await d[T.type](T);else console.warn(`\uD83E\uDD37\u200D\u2640\uFE0F [UNKNOWN MESSAGE TYPE] Received unhandled message type: "${T.type}"`);if(m){if(!p||$.compare(m,p)>0)console.info(`\uD83D\uDCC8 [GLOBAL TIMESTAMP] Advanced from ${p?.logical} to ${m.logical}.`),H(m)}if(y)console.info("\uD83D\uDCBE [STATE CHANGED] Saving state and emitting update."),await B(),k()}Object.assign(M,{use(O){if(typeof O==="function")g.push(O)},async put(O,y){const m=$.now();H(m),y??=await L(),z.upsert(y,O,m),N.add({type:"upsert",id:y,timestamp:m}),v();try{I.push({type:"upsert",id:y,value:O,timestamp:m}),D().catch(()=>{})}finally{j()}return y},async link(O,y){const m=$.now();if(!z.nodes[O]||!z.nodes[y]){console.warn(`\u26A0\uFE0F One or both nodes (${O}, ${y}) do not exist.`);return}z.link(O,y,m),N.add({type:"link",sourceId:O,targetId:y,timestamp:m}),v(),H(m);try{I.push({type:"link",sourceId:O,targetId:y,timestamp:m}),D().catch(()=>{})}finally{j()}},async remove(O){const y=$.now(),m=z.get(O);if(!m)return console.warn(`\u26A0\uFE0F Node with ID '${O}' not found.`);delete z.nodes[O],N.add({type:"remove",id:O,timestamp:y}),Object.values(z.nodes).forEach((d)=>d.edges=d.edges.filter((T)=>T!==O)),v(),H(y);try{I.push({type:"remove",id:O,value:m.value,timestamp:y}),D().catch(()=>{})}finally{j()}},async get(O,y=null){if(typeof O!=="string")return{result:null};const m=z.get(O);if(!m){if(y)y(null);return{result:null}}const d=(h)=>{if(!h)return null;const n=h.value!==null&&typeof h.value==="object"?{...h.value}:h.value;return{...h,value:n}};if(!y)return{result:d(m)};let T=m.timestamp;y(d(m));const _=(h)=>{const n=h[O];if(n){if($.compare(n.timestamp,T)>0)T=n.timestamp,y(d(n))}else y(null),f.splice(f.indexOf(_),1)};return f.push(_),{result:d(m),unsubscribe:()=>{const h=f.indexOf(_);if(h>-1)f.splice(h,1)}}},async map(...O){let m={...{realtime:!1,query:{},field:null,order:"asc",$limit:null,$after:null,$before:null}},d=null,T=!1;O.forEach((l)=>typeof l==="function"?d=l:l&&typeof l==="object"&&(T||=("realtime"in l),Object.assign(m,l))),d&&!T&&(m.realtime=!0);let _=n6(z.nodes,m),h=null;const n=(l)=>{const G0=new Map(_.map((J0)=>[J0.id,J0])),t=new Map(l.map((J0)=>[J0.id,J0])),j0=[],Q1=[],o6=[];for(let[J0,T0]of t){const t1=G0.get(J0);if(!t1)j0.push(T0);else if((T0.timestamp?.physical||0)!==(t1.timestamp?.physical||0)||(T0.timestamp?.logical||0)!==(t1.timestamp?.logical||0)||!EW(T0.edges||[],t1.edges||[]))Q1.push(T0)}for(let[J0]of G0)if(!t.has(J0))o6.push(G0.get(J0));const y8=(J0,T0)=>d({id:J0.id,value:T0==="removed"?null:J0.value,edges:J0.edges||[],timestamp:J0.timestamp||null,action:T0});j0.forEach((J0)=>y8(J0,"added")),o6.forEach((J0)=>y8(J0,"removed")),Q1.forEach((J0)=>y8(J0,"updated"))};if(d){if(_.forEach((l)=>{d({id:l.id,value:l.value,edges:l.edges,timestamp:l.timestamp,action:"initial"})}),m.realtime){const l=(G0)=>{const t=G0.timestamp?.physical||0,j0=G0.timestamp?.logical||0,Q1=(G0.edges||[]).join(",");return`${G0.id}:${t}:${j0}:${Q1}`};h=(G0)=>{const t=n6(G0,m);if(t.length!==_.length)n(t),_=t;else{const j0=t.map(l),Q1=_.map(l);if(!EW(j0,Q1))n(t),_=t}},f.push(h)}}return{results:_,...m.realtime&&d&&h&&{unsubscribe:()=>{const l=f.indexOf(h);l>-1&&f.splice(l,1)}}}},async clear(){z.nodes={};try{await(await navigator.storage.getDirectory()).removeEntry(`${W}_graph.msgpack`)}catch({message:O}){console.warn(`\u26A0\uFE0F Error deleting _graph.msgpack: ${O}`)}k(),console.info("\u2705 All data has been deleted.")}}),R(),Z(),await mV(),await S();const E=[];if(V)E.push(w("sm",V));if(q)E.push(w("AIQuery",q));if(Y)E.push(w("radixindex",Y));if(X)E.push(w("invertedindex",X));if(G)E.push(w("audit",G));if(F)E.push(w("geo",F));await Promise.all(E);const o=`graph-sync-room-${W}`,i={appId:"1234",...J&&{password:J}};if(U)i.relayUrls=U;if(P)i.turnConfig=P;const r=i6(i,o);return x=r.channel("syncGraph"),a=i6(i,`app-sync-${W}`),M.room=a,r.on("peer:join",async(O)=>{console.info("\u26A1 New peer connected:",O),x.send([{type:"sync",timestamp:p}])}),r.on("peer:leave",(O)=>{console.info("\u26A1 Peer disconnected:",O)}),x.on("message",async(O)=>{let y=O;for(let m of g)try{if(y=await m(y),!y||y.length===0)return}catch(d){console.error("\u274C GDB: Middleware error, discarding message.",d);return}await A(y)}),c=new BroadcastChannel(`graphdb_sync_${W}`),c.onmessage=async(O)=>{if(O.data==="update")console.info("\uD83D\uDD04 Update received from another tab..."),await S(),Z(),j()},console.info(`\u2705 GenosDB [ ${W} ] instance is ready.`),M}var fW=(W)=>{if(W===null||typeof W!=="object")return W;if(typeof structuredClone==="function")return structuredClone(W);return JSON.parse(JSON.stringify(W))},yW=(W,Q=16)=>{let J=null,V=null;return(...G)=>{if(!V)V={},V.promise=new Promise((Y,q)=>(V.resolve=Y,V.reject=q));if(J)("cancelIdleCallback"in window?cancelIdleCallback:clearTimeout)(J);const X=async()=>{J=null;try{V.resolve(await W(...G))}catch(Y){V.reject(Y)}finally{V=null}};return J=("requestIdleCallback"in window)?requestIdleCallback(X,{timeout:Q}):setTimeout(X,Q),V.promise}},uV=(W)=>{let Q=null;return()=>{if(Q!==null)return;Q=requestAnimationFrame(()=>{Q=null,W()})}};export{mG as gdb};
|