flagmint-js-sdk 1.2.16 → 1.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flagmint.cjs.js +2 -2
- package/dist/flagmint.es.js +3 -3
- package/dist/flagmint.umd.js +2 -2
- package/package.json +1 -1
package/dist/flagmint.umd.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
5
5
|
* @license MIT
|
|
6
|
-
*/(function(h){const n=hi,o=vf,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;h.Buffer=y,h.SlowBuffer=$,h.INSPECT_MAX_BYTES=50;const m=2147483647;h.kMaxLength=m,y.TYPED_ARRAY_SUPPORT=f(),!y.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function f(){try{const E=new Uint8Array(1),w={foo:function(){return 42}};return Object.setPrototypeOf(w,Uint8Array.prototype),Object.setPrototypeOf(E,w),E.foo()===42}catch(E){return!1}}Object.defineProperty(y.prototype,"parent",{enumerable:!0,get:function(){if(y.isBuffer(this))return this.buffer}}),Object.defineProperty(y.prototype,"offset",{enumerable:!0,get:function(){if(y.isBuffer(this))return this.byteOffset}});function g(E){if(E>m)throw new RangeError('The value "'+E+'" is invalid for option "size"');const w=new Uint8Array(E);return Object.setPrototypeOf(w,y.prototype),w}function y(E,w,A){if(typeof E=="number"){if(typeof w=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return x(E)}return S(E,w,A)}y.poolSize=8192;function S(E,w,A){if(typeof E=="string")return I(E,w);if(ArrayBuffer.isView(E))return D(E);if(E==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof E);if(dt(E,ArrayBuffer)||E&&dt(E.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(dt(E,SharedArrayBuffer)||E&&dt(E.buffer,SharedArrayBuffer)))return L(E,w,A);if(typeof E=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const T=E.valueOf&&E.valueOf();if(T!=null&&T!==E)return y.from(T,w,A);const F=W(E);if(F)return F;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof E[Symbol.toPrimitive]=="function")return y.from(E[Symbol.toPrimitive]("string"),w,A);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof E)}y.from=function(E,w,A){return S(E,w,A)},Object.setPrototypeOf(y.prototype,Uint8Array.prototype),Object.setPrototypeOf(y,Uint8Array);function B(E){if(typeof E!="number")throw new TypeError('"size" argument must be of type number');if(E<0)throw new RangeError('The value "'+E+'" is invalid for option "size"')}function M(E,w,A){return B(E),E<=0?g(E):w!==void 0?typeof A=="string"?g(E).fill(w,A):g(E).fill(w):g(E)}y.alloc=function(E,w,A){return M(E,w,A)};function x(E){return B(E),g(E<0?0:z(E)|0)}y.allocUnsafe=function(E){return x(E)},y.allocUnsafeSlow=function(E){return x(E)};function I(E,w){if((typeof w!="string"||w==="")&&(w="utf8"),!y.isEncoding(w))throw new TypeError("Unknown encoding: "+w);const A=lt(E,w)|0;let T=g(A);const F=T.write(E,w);return F!==A&&(T=T.slice(0,F)),T}function k(E){const w=E.length<0?0:z(E.length)|0,A=g(w);for(let T=0;T<w;T+=1)A[T]=E[T]&255;return A}function D(E){if(dt(E,Uint8Array)){const w=new Uint8Array(E);return L(w.buffer,w.byteOffset,w.byteLength)}return k(E)}function L(E,w,A){if(w<0||E.byteLength<w)throw new RangeError('"offset" is outside of buffer bounds');if(E.byteLength<w+(A||0))throw new RangeError('"length" is outside of buffer bounds');let T;return w===void 0&&A===void 0?T=new Uint8Array(E):A===void 0?T=new Uint8Array(E,w):T=new Uint8Array(E,w,A),Object.setPrototypeOf(T,y.prototype),T}function W(E){if(y.isBuffer(E)){const w=z(E.length)|0,A=g(w);return A.length===0||E.copy(A,0,0,w),A}if(E.length!==void 0)return typeof E.length!="number"||Pt(E.length)?g(0):k(E);if(E.type==="Buffer"&&Array.isArray(E.data))return k(E.data)}function z(E){if(E>=m)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+m.toString(16)+" bytes");return E|0}function $(E){return+E!=E&&(E=0),y.alloc(+E)}y.isBuffer=function(w){return w!=null&&w._isBuffer===!0&&w!==y.prototype},y.compare=function(w,A){if(dt(w,Uint8Array)&&(w=y.from(w,w.offset,w.byteLength)),dt(A,Uint8Array)&&(A=y.from(A,A.offset,A.byteLength)),!y.isBuffer(w)||!y.isBuffer(A))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(w===A)return 0;let T=w.length,F=A.length;for(let V=0,U=Math.min(T,F);V<U;++V)if(w[V]!==A[V]){T=w[V],F=A[V];break}return T<F?-1:F<T?1:0},y.isEncoding=function(w){switch(String(w).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},y.concat=function(w,A){if(!Array.isArray(w))throw new TypeError('"list" argument must be an Array of Buffers');if(w.length===0)return y.alloc(0);let T;if(A===void 0)for(A=0,T=0;T<w.length;++T)A+=w[T].length;const F=y.allocUnsafe(A);let V=0;for(T=0;T<w.length;++T){let U=w[T];if(dt(U,Uint8Array))V+U.length>F.length?(y.isBuffer(U)||(U=y.from(U)),U.copy(F,V)):Uint8Array.prototype.set.call(F,U,V);else if(y.isBuffer(U))U.copy(F,V);else throw new TypeError('"list" argument must be an Array of Buffers');V+=U.length}return F};function lt(E,w){if(y.isBuffer(E))return E.length;if(ArrayBuffer.isView(E)||dt(E,ArrayBuffer))return E.byteLength;if(typeof E!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof E);const A=E.length,T=arguments.length>2&&arguments[2]===!0;if(!T&&A===0)return 0;let F=!1;for(;;)switch(w){case"ascii":case"latin1":case"binary":return A;case"utf8":case"utf-8":return Nt(E).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A*2;case"hex":return A>>>1;case"base64":return Dt(E).length;default:if(F)return T?-1:Nt(E).length;w=(""+w).toLowerCase(),F=!0}}y.byteLength=lt;function H(E,w,A){let T=!1;if((w===void 0||w<0)&&(w=0),w>this.length||((A===void 0||A>this.length)&&(A=this.length),A<=0)||(A>>>=0,w>>>=0,A<=w))return"";for(E||(E="utf8");;)switch(E){case"hex":return u(this,w,A);case"utf8":case"utf-8":return i(this,w,A);case"ascii":return c(this,w,A);case"latin1":case"binary":return v(this,w,A);case"base64":return r(this,w,A);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e(this,w,A);default:if(T)throw new TypeError("Unknown encoding: "+E);E=(E+"").toLowerCase(),T=!0}}y.prototype._isBuffer=!0;function At(E,w,A){const T=E[w];E[w]=E[A],E[A]=T}y.prototype.swap16=function(){const w=this.length;if(w%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let A=0;A<w;A+=2)At(this,A,A+1);return this},y.prototype.swap32=function(){const w=this.length;if(w%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let A=0;A<w;A+=4)At(this,A,A+3),At(this,A+1,A+2);return this},y.prototype.swap64=function(){const w=this.length;if(w%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let A=0;A<w;A+=8)At(this,A,A+7),At(this,A+1,A+6),At(this,A+2,A+5),At(this,A+3,A+4);return this},y.prototype.toString=function(){const w=this.length;return w===0?"":arguments.length===0?i(this,0,w):H.apply(this,arguments)},y.prototype.toLocaleString=y.prototype.toString,y.prototype.equals=function(w){if(!y.isBuffer(w))throw new TypeError("Argument must be a Buffer");return this===w?!0:y.compare(this,w)===0},y.prototype.inspect=function(){let w="";const A=h.INSPECT_MAX_BYTES;return w=this.toString("hex",0,A).replace(/(.{2})/g,"$1 ").trim(),this.length>A&&(w+=" ... "),"<Buffer "+w+">"},s&&(y.prototype[s]=y.prototype.inspect),y.prototype.compare=function(w,A,T,F,V){if(dt(w,Uint8Array)&&(w=y.from(w,w.offset,w.byteLength)),!y.isBuffer(w))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof w);if(A===void 0&&(A=0),T===void 0&&(T=w?w.length:0),F===void 0&&(F=0),V===void 0&&(V=this.length),A<0||T>w.length||F<0||V>this.length)throw new RangeError("out of range index");if(F>=V&&A>=T)return 0;if(F>=V)return-1;if(A>=T)return 1;if(A>>>=0,T>>>=0,F>>>=0,V>>>=0,this===w)return 0;let U=V-F,X=T-A;const Tt=Math.min(U,X),G=this.slice(F,V),rt=w.slice(A,T);for(let Rt=0;Rt<Tt;++Rt)if(G[Rt]!==rt[Rt]){U=G[Rt],X=rt[Rt];break}return U<X?-1:X<U?1:0};function Bt(E,w,A,T,F){if(E.length===0)return-1;if(typeof A=="string"?(T=A,A=0):A>2147483647?A=2147483647:A<-2147483648&&(A=-2147483648),A=+A,Pt(A)&&(A=F?0:E.length-1),A<0&&(A=E.length+A),A>=E.length){if(F)return-1;A=E.length-1}else if(A<0)if(F)A=0;else return-1;if(typeof w=="string"&&(w=y.from(w,T)),y.isBuffer(w))return w.length===0?-1:Ct(E,w,A,T,F);if(typeof w=="number")return w=w&255,typeof Uint8Array.prototype.indexOf=="function"?F?Uint8Array.prototype.indexOf.call(E,w,A):Uint8Array.prototype.lastIndexOf.call(E,w,A):Ct(E,[w],A,T,F);throw new TypeError("val must be string, number or Buffer")}function Ct(E,w,A,T,F){let V=1,U=E.length,X=w.length;if(T!==void 0&&(T=String(T).toLowerCase(),T==="ucs2"||T==="ucs-2"||T==="utf16le"||T==="utf-16le")){if(E.length<2||w.length<2)return-1;V=2,U/=2,X/=2,A/=2}function Tt(rt,Rt){return V===1?rt[Rt]:rt.readUInt16BE(Rt*V)}let G;if(F){let rt=-1;for(G=A;G<U;G++)if(Tt(E,G)===Tt(w,rt===-1?0:G-rt)){if(rt===-1&&(rt=G),G-rt+1===X)return rt*V}else rt!==-1&&(G-=G-rt),rt=-1}else for(A+X>U&&(A=U-X),G=A;G>=0;G--){let rt=!0;for(let Rt=0;Rt<X;Rt++)if(Tt(E,G+Rt)!==Tt(w,Rt)){rt=!1;break}if(rt)return G}return-1}y.prototype.includes=function(w,A,T){return this.indexOf(w,A,T)!==-1},y.prototype.indexOf=function(w,A,T){return Bt(this,w,A,T,!0)},y.prototype.lastIndexOf=function(w,A,T){return Bt(this,w,A,T,!1)};function Et(E,w,A,T){A=Number(A)||0;const F=E.length-A;T?(T=Number(T),T>F&&(T=F)):T=F;const V=w.length;T>V/2&&(T=V/2);let U;for(U=0;U<T;++U){const X=parseInt(w.substr(U*2,2),16);if(Pt(X))return U;E[A+U]=X}return U}function Y(E,w,A,T){return j(Nt(w,E.length-A),E,A,T)}function It(E,w,A,T){return j(et(w),E,A,T)}function p(E,w,A,T){return j(Dt(w),E,A,T)}function t(E,w,A,T){return j(pt(w,E.length-A),E,A,T)}y.prototype.write=function(w,A,T,F){if(A===void 0)F="utf8",T=this.length,A=0;else if(T===void 0&&typeof A=="string")F=A,T=this.length,A=0;else if(isFinite(A))A=A>>>0,isFinite(T)?(T=T>>>0,F===void 0&&(F="utf8")):(F=T,T=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const V=this.length-A;if((T===void 0||T>V)&&(T=V),w.length>0&&(T<0||A<0)||A>this.length)throw new RangeError("Attempt to write outside buffer bounds");F||(F="utf8");let U=!1;for(;;)switch(F){case"hex":return Et(this,w,A,T);case"utf8":case"utf-8":return Y(this,w,A,T);case"ascii":case"latin1":case"binary":return It(this,w,A,T);case"base64":return p(this,w,A,T);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t(this,w,A,T);default:if(U)throw new TypeError("Unknown encoding: "+F);F=(""+F).toLowerCase(),U=!0}},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function r(E,w,A){return w===0&&A===E.length?n.fromByteArray(E):n.fromByteArray(E.slice(w,A))}function i(E,w,A){A=Math.min(E.length,A);const T=[];let F=w;for(;F<A;){const V=E[F];let U=null,X=V>239?4:V>223?3:V>191?2:1;if(F+X<=A){let Tt,G,rt,Rt;switch(X){case 1:V<128&&(U=V);break;case 2:Tt=E[F+1],(Tt&192)===128&&(Rt=(V&31)<<6|Tt&63,Rt>127&&(U=Rt));break;case 3:Tt=E[F+1],G=E[F+2],(Tt&192)===128&&(G&192)===128&&(Rt=(V&15)<<12|(Tt&63)<<6|G&63,Rt>2047&&(Rt<55296||Rt>57343)&&(U=Rt));break;case 4:Tt=E[F+1],G=E[F+2],rt=E[F+3],(Tt&192)===128&&(G&192)===128&&(rt&192)===128&&(Rt=(V&15)<<18|(Tt&63)<<12|(G&63)<<6|rt&63,Rt>65535&&Rt<1114112&&(U=Rt))}}U===null?(U=65533,X=1):U>65535&&(U-=65536,T.push(U>>>10&1023|55296),U=56320|U&1023),T.push(U),F+=X}return d(T)}const a=4096;function d(E){const w=E.length;if(w<=a)return String.fromCharCode.apply(String,E);let A="",T=0;for(;T<w;)A+=String.fromCharCode.apply(String,E.slice(T,T+=a));return A}function c(E,w,A){let T="";A=Math.min(E.length,A);for(let F=w;F<A;++F)T+=String.fromCharCode(E[F]&127);return T}function v(E,w,A){let T="";A=Math.min(E.length,A);for(let F=w;F<A;++F)T+=String.fromCharCode(E[F]);return T}function u(E,w,A){const T=E.length;(!w||w<0)&&(w=0),(!A||A<0||A>T)&&(A=T);let F="";for(let V=w;V<A;++V)F+=Q[E[V]];return F}function e(E,w,A){const T=E.slice(w,A);let F="";for(let V=0;V<T.length-1;V+=2)F+=String.fromCharCode(T[V]+T[V+1]*256);return F}y.prototype.slice=function(w,A){const T=this.length;w=~~w,A=A===void 0?T:~~A,w<0?(w+=T,w<0&&(w=0)):w>T&&(w=T),A<0?(A+=T,A<0&&(A=0)):A>T&&(A=T),A<w&&(A=w);const F=this.subarray(w,A);return Object.setPrototypeOf(F,y.prototype),F};function l(E,w,A){if(E%1!==0||E<0)throw new RangeError("offset is not uint");if(E+w>A)throw new RangeError("Trying to access beyond buffer length")}y.prototype.readUintLE=y.prototype.readUIntLE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let F=this[w],V=1,U=0;for(;++U<A&&(V*=256);)F+=this[w+U]*V;return F},y.prototype.readUintBE=y.prototype.readUIntBE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let F=this[w+--A],V=1;for(;A>0&&(V*=256);)F+=this[w+--A]*V;return F},y.prototype.readUint8=y.prototype.readUInt8=function(w,A){return w=w>>>0,A||l(w,1,this.length),this[w]},y.prototype.readUint16LE=y.prototype.readUInt16LE=function(w,A){return w=w>>>0,A||l(w,2,this.length),this[w]|this[w+1]<<8},y.prototype.readUint16BE=y.prototype.readUInt16BE=function(w,A){return w=w>>>0,A||l(w,2,this.length),this[w]<<8|this[w+1]},y.prototype.readUint32LE=y.prototype.readUInt32LE=function(w,A){return w=w>>>0,A||l(w,4,this.length),(this[w]|this[w+1]<<8|this[w+2]<<16)+this[w+3]*16777216},y.prototype.readUint32BE=y.prototype.readUInt32BE=function(w,A){return w=w>>>0,A||l(w,4,this.length),this[w]*16777216+(this[w+1]<<16|this[w+2]<<8|this[w+3])},y.prototype.readBigUInt64LE=ct(function(w){w=w>>>0,J(w,"offset");const A=this[w],T=this[w+7];(A===void 0||T===void 0)&&qt(w,this.length-8);const F=A+this[++w]*me(2,8)+this[++w]*me(2,16)+this[++w]*me(2,24),V=this[++w]+this[++w]*me(2,8)+this[++w]*me(2,16)+T*me(2,24);return BigInt(F)+(BigInt(V)<<BigInt(32))}),y.prototype.readBigUInt64BE=ct(function(w){w=w>>>0,J(w,"offset");const A=this[w],T=this[w+7];(A===void 0||T===void 0)&&qt(w,this.length-8);const F=A*me(2,24)+this[++w]*me(2,16)+this[++w]*me(2,8)+this[++w],V=this[++w]*me(2,24)+this[++w]*me(2,16)+this[++w]*me(2,8)+T;return(BigInt(F)<<BigInt(32))+BigInt(V)}),y.prototype.readIntLE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let F=this[w],V=1,U=0;for(;++U<A&&(V*=256);)F+=this[w+U]*V;return V*=128,F>=V&&(F-=Math.pow(2,8*A)),F},y.prototype.readIntBE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let F=A,V=1,U=this[w+--F];for(;F>0&&(V*=256);)U+=this[w+--F]*V;return V*=128,U>=V&&(U-=Math.pow(2,8*A)),U},y.prototype.readInt8=function(w,A){return w=w>>>0,A||l(w,1,this.length),this[w]&128?(255-this[w]+1)*-1:this[w]},y.prototype.readInt16LE=function(w,A){w=w>>>0,A||l(w,2,this.length);const T=this[w]|this[w+1]<<8;return T&32768?T|4294901760:T},y.prototype.readInt16BE=function(w,A){w=w>>>0,A||l(w,2,this.length);const T=this[w+1]|this[w]<<8;return T&32768?T|4294901760:T},y.prototype.readInt32LE=function(w,A){return w=w>>>0,A||l(w,4,this.length),this[w]|this[w+1]<<8|this[w+2]<<16|this[w+3]<<24},y.prototype.readInt32BE=function(w,A){return w=w>>>0,A||l(w,4,this.length),this[w]<<24|this[w+1]<<16|this[w+2]<<8|this[w+3]},y.prototype.readBigInt64LE=ct(function(w){w=w>>>0,J(w,"offset");const A=this[w],T=this[w+7];(A===void 0||T===void 0)&&qt(w,this.length-8);const F=this[w+4]+this[w+5]*me(2,8)+this[w+6]*me(2,16)+(T<<24);return(BigInt(F)<<BigInt(32))+BigInt(A+this[++w]*me(2,8)+this[++w]*me(2,16)+this[++w]*me(2,24))}),y.prototype.readBigInt64BE=ct(function(w){w=w>>>0,J(w,"offset");const A=this[w],T=this[w+7];(A===void 0||T===void 0)&&qt(w,this.length-8);const F=(A<<24)+this[++w]*me(2,16)+this[++w]*me(2,8)+this[++w];return(BigInt(F)<<BigInt(32))+BigInt(this[++w]*me(2,24)+this[++w]*me(2,16)+this[++w]*me(2,8)+T)}),y.prototype.readFloatLE=function(w,A){return w=w>>>0,A||l(w,4,this.length),o.read(this,w,!0,23,4)},y.prototype.readFloatBE=function(w,A){return w=w>>>0,A||l(w,4,this.length),o.read(this,w,!1,23,4)},y.prototype.readDoubleLE=function(w,A){return w=w>>>0,A||l(w,8,this.length),o.read(this,w,!0,52,8)},y.prototype.readDoubleBE=function(w,A){return w=w>>>0,A||l(w,8,this.length),o.read(this,w,!1,52,8)};function b(E,w,A,T,F,V){if(!y.isBuffer(E))throw new TypeError('"buffer" argument must be a Buffer instance');if(w>F||w<V)throw new RangeError('"value" argument is out of bounds');if(A+T>E.length)throw new RangeError("Index out of range")}y.prototype.writeUintLE=y.prototype.writeUIntLE=function(w,A,T,F){if(w=+w,A=A>>>0,T=T>>>0,!F){const X=Math.pow(2,8*T)-1;b(this,w,A,T,X,0)}let V=1,U=0;for(this[A]=w&255;++U<T&&(V*=256);)this[A+U]=w/V&255;return A+T},y.prototype.writeUintBE=y.prototype.writeUIntBE=function(w,A,T,F){if(w=+w,A=A>>>0,T=T>>>0,!F){const X=Math.pow(2,8*T)-1;b(this,w,A,T,X,0)}let V=T-1,U=1;for(this[A+V]=w&255;--V>=0&&(U*=256);)this[A+V]=w/U&255;return A+T},y.prototype.writeUint8=y.prototype.writeUInt8=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,1,255,0),this[A]=w&255,A+1},y.prototype.writeUint16LE=y.prototype.writeUInt16LE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,2,65535,0),this[A]=w&255,this[A+1]=w>>>8,A+2},y.prototype.writeUint16BE=y.prototype.writeUInt16BE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,2,65535,0),this[A]=w>>>8,this[A+1]=w&255,A+2},y.prototype.writeUint32LE=y.prototype.writeUInt32LE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,4,4294967295,0),this[A+3]=w>>>24,this[A+2]=w>>>16,this[A+1]=w>>>8,this[A]=w&255,A+4},y.prototype.writeUint32BE=y.prototype.writeUInt32BE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,4,4294967295,0),this[A]=w>>>24,this[A+1]=w>>>16,this[A+2]=w>>>8,this[A+3]=w&255,A+4};function _(E,w,A,T,F){Z(w,T,F,E,A,7);let V=Number(w&BigInt(4294967295));E[A++]=V,V=V>>8,E[A++]=V,V=V>>8,E[A++]=V,V=V>>8,E[A++]=V;let U=Number(w>>BigInt(32)&BigInt(4294967295));return E[A++]=U,U=U>>8,E[A++]=U,U=U>>8,E[A++]=U,U=U>>8,E[A++]=U,A}function C(E,w,A,T,F){Z(w,T,F,E,A,7);let V=Number(w&BigInt(4294967295));E[A+7]=V,V=V>>8,E[A+6]=V,V=V>>8,E[A+5]=V,V=V>>8,E[A+4]=V;let U=Number(w>>BigInt(32)&BigInt(4294967295));return E[A+3]=U,U=U>>8,E[A+2]=U,U=U>>8,E[A+1]=U,U=U>>8,E[A]=U,A+8}y.prototype.writeBigUInt64LE=ct(function(w,A=0){return _(this,w,A,BigInt(0),BigInt("0xffffffffffffffff"))}),y.prototype.writeBigUInt64BE=ct(function(w,A=0){return C(this,w,A,BigInt(0),BigInt("0xffffffffffffffff"))}),y.prototype.writeIntLE=function(w,A,T,F){if(w=+w,A=A>>>0,!F){const Tt=Math.pow(2,8*T-1);b(this,w,A,T,Tt-1,-Tt)}let V=0,U=1,X=0;for(this[A]=w&255;++V<T&&(U*=256);)w<0&&X===0&&this[A+V-1]!==0&&(X=1),this[A+V]=(w/U>>0)-X&255;return A+T},y.prototype.writeIntBE=function(w,A,T,F){if(w=+w,A=A>>>0,!F){const Tt=Math.pow(2,8*T-1);b(this,w,A,T,Tt-1,-Tt)}let V=T-1,U=1,X=0;for(this[A+V]=w&255;--V>=0&&(U*=256);)w<0&&X===0&&this[A+V+1]!==0&&(X=1),this[A+V]=(w/U>>0)-X&255;return A+T},y.prototype.writeInt8=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,1,127,-128),w<0&&(w=255+w+1),this[A]=w&255,A+1},y.prototype.writeInt16LE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,2,32767,-32768),this[A]=w&255,this[A+1]=w>>>8,A+2},y.prototype.writeInt16BE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,2,32767,-32768),this[A]=w>>>8,this[A+1]=w&255,A+2},y.prototype.writeInt32LE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,4,2147483647,-2147483648),this[A]=w&255,this[A+1]=w>>>8,this[A+2]=w>>>16,this[A+3]=w>>>24,A+4},y.prototype.writeInt32BE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,4,2147483647,-2147483648),w<0&&(w=4294967295+w+1),this[A]=w>>>24,this[A+1]=w>>>16,this[A+2]=w>>>8,this[A+3]=w&255,A+4},y.prototype.writeBigInt64LE=ct(function(w,A=0){return _(this,w,A,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),y.prototype.writeBigInt64BE=ct(function(w,A=0){return C(this,w,A,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function q(E,w,A,T,F,V){if(A+T>E.length)throw new RangeError("Index out of range");if(A<0)throw new RangeError("Index out of range")}function O(E,w,A,T,F){return w=+w,A=A>>>0,F||q(E,w,A,4),o.write(E,w,A,T,23,4),A+4}y.prototype.writeFloatLE=function(w,A,T){return O(this,w,A,!0,T)},y.prototype.writeFloatBE=function(w,A,T){return O(this,w,A,!1,T)};function R(E,w,A,T,F){return w=+w,A=A>>>0,F||q(E,w,A,8),o.write(E,w,A,T,52,8),A+8}y.prototype.writeDoubleLE=function(w,A,T){return R(this,w,A,!0,T)},y.prototype.writeDoubleBE=function(w,A,T){return R(this,w,A,!1,T)},y.prototype.copy=function(w,A,T,F){if(!y.isBuffer(w))throw new TypeError("argument should be a Buffer");if(T||(T=0),!F&&F!==0&&(F=this.length),A>=w.length&&(A=w.length),A||(A=0),F>0&&F<T&&(F=T),F===T||w.length===0||this.length===0)return 0;if(A<0)throw new RangeError("targetStart out of bounds");if(T<0||T>=this.length)throw new RangeError("Index out of range");if(F<0)throw new RangeError("sourceEnd out of bounds");F>this.length&&(F=this.length),w.length-A<F-T&&(F=w.length-A+T);const V=F-T;return this===w&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(A,T,F):Uint8Array.prototype.set.call(w,this.subarray(T,F),A),V},y.prototype.fill=function(w,A,T,F){if(typeof w=="string"){if(typeof A=="string"?(F=A,A=0,T=this.length):typeof T=="string"&&(F=T,T=this.length),F!==void 0&&typeof F!="string")throw new TypeError("encoding must be a string");if(typeof F=="string"&&!y.isEncoding(F))throw new TypeError("Unknown encoding: "+F);if(w.length===1){const U=w.charCodeAt(0);(F==="utf8"&&U<128||F==="latin1")&&(w=U)}}else typeof w=="number"?w=w&255:typeof w=="boolean"&&(w=Number(w));if(A<0||this.length<A||this.length<T)throw new RangeError("Out of range index");if(T<=A)return this;A=A>>>0,T=T===void 0?this.length:T>>>0,w||(w=0);let V;if(typeof w=="number")for(V=A;V<T;++V)this[V]=w;else{const U=y.isBuffer(w)?w:y.from(w,F),X=U.length;if(X===0)throw new TypeError('The value "'+w+'" is invalid for argument "value"');for(V=0;V<T-A;++V)this[V+A]=U[V%X]}return this};const P={};function N(E,w,A){P[E]=class extends A{constructor(){super(),Object.defineProperty(this,"message",{value:w.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${E}]`,this.stack,delete this.name}get code(){return E}set code(F){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:F,writable:!0})}toString(){return`${this.name} [${E}]: ${this.message}`}}}N("ERR_BUFFER_OUT_OF_BOUNDS",function(E){return E?`${E} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),N("ERR_INVALID_ARG_TYPE",function(E,w){return`The "${E}" argument must be of type number. Received type ${typeof w}`},TypeError),N("ERR_OUT_OF_RANGE",function(E,w,A){let T=`The value of "${E}" is out of range.`,F=A;return Number.isInteger(A)&&Math.abs(A)>me(2,32)?F=K(String(A)):typeof A=="bigint"&&(F=String(A),(A>me(BigInt(2),BigInt(32))||A<-me(BigInt(2),BigInt(32)))&&(F=K(F)),F+="n"),T+=` It must be ${w}. Received ${F}`,T},RangeError);function K(E){let w="",A=E.length;const T=E[0]==="-"?1:0;for(;A>=T+4;A-=3)w=`_${E.slice(A-3,A)}${w}`;return`${E.slice(0,A)}${w}`}function kt(E,w,A){J(w,"offset"),(E[w]===void 0||E[w+A]===void 0)&&qt(w,E.length-(A+1))}function Z(E,w,A,T,F,V){if(E>A||E<w){const U=typeof w=="bigint"?"n":"";let X;throw V>3?w===0||w===BigInt(0)?X=`>= 0${U} and < 2${U} ** ${(V+1)*8}${U}`:X=`>= -(2${U} ** ${(V+1)*8-1}${U}) and < 2 ** ${(V+1)*8-1}${U}`:X=`>= ${w}${U} and <= ${A}${U}`,new P.ERR_OUT_OF_RANGE("value",X,E)}kt(T,F,V)}function J(E,w){if(typeof E!="number")throw new P.ERR_INVALID_ARG_TYPE(w,"number",E)}function qt(E,w,A){throw Math.floor(E)!==E?(J(E,A),new P.ERR_OUT_OF_RANGE(A||"offset","an integer",E)):w<0?new P.ERR_BUFFER_OUT_OF_BOUNDS:new P.ERR_OUT_OF_RANGE(A||"offset",`>= ${A?1:0} and <= ${w}`,E)}const tt=/[^+/0-9A-Za-z-_]/g;function vt(E){if(E=E.split("=")[0],E=E.trim().replace(tt,""),E.length<2)return"";for(;E.length%4!==0;)E=E+"=";return E}function Nt(E,w){w=w||1/0;let A;const T=E.length;let F=null;const V=[];for(let U=0;U<T;++U){if(A=E.charCodeAt(U),A>55295&&A<57344){if(!F){if(A>56319){(w-=3)>-1&&V.push(239,191,189);continue}else if(U+1===T){(w-=3)>-1&&V.push(239,191,189);continue}F=A;continue}if(A<56320){(w-=3)>-1&&V.push(239,191,189),F=A;continue}A=(F-55296<<10|A-56320)+65536}else F&&(w-=3)>-1&&V.push(239,191,189);if(F=null,A<128){if((w-=1)<0)break;V.push(A)}else if(A<2048){if((w-=2)<0)break;V.push(A>>6|192,A&63|128)}else if(A<65536){if((w-=3)<0)break;V.push(A>>12|224,A>>6&63|128,A&63|128)}else if(A<1114112){if((w-=4)<0)break;V.push(A>>18|240,A>>12&63|128,A>>6&63|128,A&63|128)}else throw new Error("Invalid code point")}return V}function et(E){const w=[];for(let A=0;A<E.length;++A)w.push(E.charCodeAt(A)&255);return w}function pt(E,w){let A,T,F;const V=[];for(let U=0;U<E.length&&!((w-=2)<0);++U)A=E.charCodeAt(U),T=A>>8,F=A%256,V.push(F),V.push(T);return V}function Dt(E){return n.toByteArray(vt(E))}function j(E,w,A,T){let F;for(F=0;F<T&&!(F+A>=w.length||F>=E.length);++F)w[F+A]=E[F];return F}function dt(E,w){return E instanceof w||E!=null&&E.constructor!=null&&E.constructor.name!=null&&E.constructor.name===w.name}function Pt(E){return E!==E}const Q=function(){const E="0123456789abcdef",w=new Array(256);for(let A=0;A<16;++A){const T=A*16;for(let F=0;F<16;++F)w[T+F]=E[A]+E[F]}return w}();function ct(E){return typeof BigInt=="undefined"?Ot:E}function Ot(){throw new Error("BigInt not supported")}})(Ke);class na{constructor(n,o,s,m={}){this.endpoint=n,this.apiKey=o,this.isStopped=!1,this.pollTimeoutId=null,this.currentFlags={},this.consecutiveErrors=0,this.currentBackoffMs=0,this.pollIntervalMs=m.pollIntervalMs||1e4,this.maxBackoffMs=m.maxBackoffMs||6e4,this.backoffMultiplier=m.backoffMultiplier||2,this.currentContext=s}init(){return De(this,null,function*(){try{this.currentFlags=yield this.fetchFlags(this.currentContext),this.consecutiveErrors=0,console.log("[LongPollingTransport] Initial fetch complete")}catch(n){console.error("[LongPollingTransport] Initial fetch failed:",n)}this.scheduleNextPoll()})}scheduleNextPoll(){if(this.isStopped)return;const n=this.pollIntervalMs+this.currentBackoffMs;console.log(`[LongPollingTransport] Next poll in ${n}ms`+(this.currentBackoffMs>0?` (backoff: ${this.currentBackoffMs}ms)`:"")),this.pollTimeoutId=setTimeout(()=>De(this,null,function*(){yield this.poll(),this.scheduleNextPoll()}),n)}poll(){return De(this,null,function*(){var n;try{const o=yield this.fetchFlags(this.currentContext);this.consecutiveErrors>0&&(console.log("[LongPollingTransport] ✅ Recovered from errors"),this.consecutiveErrors=0,this.currentBackoffMs=0),this.flagsChanged(o)&&(console.log("[LongPollingTransport] Flags changed, notifying..."),this.currentFlags=o,(n=this.onUpdateCallback)==null||n.call(this,o))}catch(o){console.error("[LongPollingTransport] ❌ Poll error:",o),this.consecutiveErrors++,this.applyBackoff()}})}applyBackoff(){if(this.consecutiveErrors===1)this.currentBackoffMs=0;else{const n=this.pollIntervalMs*Math.pow(this.backoffMultiplier,this.consecutiveErrors-2);this.currentBackoffMs=Math.min(n,this.maxBackoffMs),console.warn(`[LongPollingTransport] Backing off ${this.currentBackoffMs}ms (${this.consecutiveErrors} consecutive errors)`)}}flagsChanged(n){return JSON.stringify(n)!==JSON.stringify(this.currentFlags)}fetchFlags(n){return De(this,null,function*(){this.currentContext=n;const o=yield fetch(this.endpoint,{method:"POST",headers:{"x-api-key":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify({context:n})});if(o.status===401||o.status===403)throw new Error("Unauthorized: Invalid API key");if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);return(yield o.json()).data})}onFlagsUpdated(n){this.onUpdateCallback=n}destroy(){console.log("[LongPollingTransport] Destroying..."),this.isStopped=!0,this.pollTimeoutId!==null&&(clearTimeout(this.pollTimeoutId),this.pollTimeoutId=null),this.onUpdateCallback=void 0}}class fa{constructor(n,o,s=5,m=1e3){this.wsUrl=n,this.apiKey=o,this.maxRetries=s,this.initialBackoffMs=m,this.socket=null,this.flags={},this.context=null,this.isReady=!1,this.initialFlagsReceived=!1,this.initialFlagsPromise=null,this.retries=0,this.reconnectTimeoutId=null}init(){return De(this,null,function*(){yield this.connectWithRetry(),yield this.waitForInitialFlags()})}waitForInitialFlags(){return this.initialFlagsReceived?Promise.resolve():(this.initialFlagsPromise||(this.initialFlagsPromise=new Promise(n=>{const o=setInterval(()=>{this.initialFlagsReceived&&(clearInterval(o),n())},50);setTimeout(()=>{clearInterval(o),console.warn("[WebSocketTransport] Initial flags timeout"),n()},5e3)})),this.initialFlagsPromise)}connectWithRetry(){return new Promise((n,o)=>{const s=()=>{try{this.cleanupSocket(),this.setConnectionState("connecting");const m=this.getWebSocketImplementation();this.socket=new m(`${this.wsUrl}?apiKey=${this.apiKey}`),this.socket.onopen=()=>{console.log("[WebSocketTransport] Connected"),this.isReady=!0,this.retries=0,this.setConnectionState("connected"),this.context&&this.sendContext(this.context),n()},this.socket.onmessage=f=>{var g;try{const y=JSON.parse(f.data);if(console.log("[WebSocketTransport] Message received:",y),y.type==="ping"){this.socket&&this.socket.readyState===1&&this.socket.send(JSON.stringify({type:"pong"}));return}if(y.type==="pong"){console.log("[WebSocketTransport] Pong received");return}y.type==="flags"&&(console.log("[WebSocketTransport] Flags update received"),this.flags=y.flags,this.initialFlagsReceived=!0,(g=this.onFlagsUpdatedCallback)==null||g.call(this,this.flags))}catch(y){console.warn("[WebSocketTransport] Failed to parse message:",y)}},this.socket.onerror=f=>{console.error("[WebSocketTransport] Error:",f)},this.socket.onclose=f=>{if(console.log("[WebSocketTransport] Connection closed:",f.code),this.isReady=!1,this.setConnectionState("disconnected"),f.code===1008||f.code===4001){this.setConnectionState("failed"),o(new Error("Unauthorized: Invalid API key"));return}if(this.retries<this.maxRetries){const g=this.initialBackoffMs*Math.pow(2,this.retries);console.warn(`[WebSocketTransport] Reconnecting in ${g}ms (attempt ${this.retries+1})`),this.setConnectionState("reconnecting"),this.reconnectTimeoutId=setTimeout(s,g),this.retries++}else this.setConnectionState("failed"),o(new Error(`WebSocket failed after ${this.retries} retries`))}}catch(m){console.error("[WebSocketTransport] Failed to create socket:",m),this.setConnectionState("failed"),o(m)}};s()})}cleanupSocket(){this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,this.socket.readyState===1&&this.socket.close(),this.socket=null)}setConnectionState(n){var o;(o=this.onConnectionStateCallback)==null||o.call(this,n)}getWebSocketImplementation(){if(typeof WebSocket!="undefined")return WebSocket;try{const n=require("ws");return n.default||n}catch(n){throw new Error('WebSocket not available. Install "ws" package for Node.js: npm install ws')}}fetchFlags(n){return De(this,null,function*(){var o;return this.context=n,this.isReady&&((o=this.socket)==null?void 0:o.readyState)===1&&this.sendContext(n),this.flags})}onFlagsUpdated(n){this.onFlagsUpdatedCallback=n}onConnectionStateChanged(n){this.onConnectionStateCallback=n}destroy(){console.log("[WebSocketTransport] Destroying..."),this.reconnectTimeoutId!==null&&(clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=null),this.cleanupSocket(),this.flags={},this.context=null,this.isReady=!1,this.initialFlagsReceived=!1,this.initialFlagsPromise=null,this.onFlagsUpdatedCallback=void 0,this.onConnectionStateCallback=void 0,this.retries=0}sendContext(n){if(!this.socket||this.socket.readyState!==1){console.warn("[WebSocketTransport] Socket not ready, cannot send context");return}const o=JSON.stringify({type:"context",context:n});this.socket.send(o)}}function aa(h,n){if(h.type!=="rule")return!1;const o=h.attribute.split(".").reduce((s,m)=>s==null?void 0:s[m],n);switch(h.operator){case"eq":return o===h.value;case"neq":return o!==h.value;case"in":return Array.isArray(h.value)&&h.value.includes(o);case"nin":return Array.isArray(h.value)&&!h.value.includes(o);case"gt":return typeof o=="number"&&typeof h.value=="number"&&o>h.value;case"lt":return typeof o=="number"&&typeof h.value=="number"&&o<h.value;case"exists":return o!=null;case"not_exists":return o==null;default:return!1}}function Mu(h,n){return h.rules.every(o=>aa(o,n))}var Lt={};const Ti=typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{};function ha(){throw new Error("setTimeout has not been defined")}function sa(){throw new Error("clearTimeout has not been defined")}var qr=ha,Pr=sa;typeof Ti.setTimeout=="function"&&(qr=setTimeout),typeof Ti.clearTimeout=="function"&&(Pr=clearTimeout);function oa(h){if(qr===setTimeout)return setTimeout(h,0);if((qr===ha||!qr)&&setTimeout)return qr=setTimeout,setTimeout(h,0);try{return qr(h,0)}catch(n){try{return qr.call(null,h,0)}catch(o){return qr.call(this,h,0)}}}function xu(h){if(Pr===clearTimeout)return clearTimeout(h);if((Pr===sa||!Pr)&&clearTimeout)return Pr=clearTimeout,clearTimeout(h);try{return Pr(h)}catch(n){try{return Pr.call(null,h)}catch(o){return Pr.call(this,h)}}}var _r=[],oi=!1,Hr,dn=-1;function _u(){!oi||!Hr||(oi=!1,Hr.length?_r=Hr.concat(_r):dn=-1,_r.length&&ua())}function ua(){if(!oi){var h=oa(_u);oi=!0;for(var n=_r.length;n;){for(Hr=_r,_r=[];++dn<n;)Hr&&Hr[dn].run();dn=-1,n=_r.length}Hr=null,oi=!1,xu(h)}}function Su(h){var n=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)n[o-1]=arguments[o];_r.push(new la(h,n)),_r.length===1&&!oi&&oa(ua)}function la(h,n){this.fun=h,this.array=n}la.prototype.run=function(){this.fun.apply(null,this.array)};var Au="browser",Bu="browser",Eu=!0,ku={},Iu=[],Ru="",Tu={},Cu={},Fu={};function Zr(){}var qu=Zr,Pu=Zr,Du=Zr,Nu=Zr,$u=Zr,Uu=Zr,Lu=Zr;function Ou(h){throw new Error("process.binding is not supported")}function zu(){return"/"}function Ku(h){throw new Error("process.chdir is not supported")}function Hu(){return 0}var ui=Ti.performance||{},Zu=ui.now||ui.mozNow||ui.msNow||ui.oNow||ui.webkitNow||function(){return new Date().getTime()};function Wu(h){var n=Zu.call(ui)*.001,o=Math.floor(n),s=Math.floor(n%1*1e9);return h&&(o=o-h[0],s=s-h[1],s<0&&(o--,s+=1e9)),[o,s]}var Vu=new Date;function Yu(){var h=new Date,n=h-Vu;return n/1e3}var ye={nextTick:Su,title:Au,browser:Eu,env:ku,argv:Iu,version:Ru,versions:Tu,on:qu,addListener:Pu,once:Du,off:Nu,removeListener:$u,removeAllListeners:Uu,emit:Lu,binding:Ou,cwd:zu,chdir:Ku,umask:Hu,hrtime:Wu,platform:Bu,release:Cu,config:Fu,uptime:Yu},pf={exports:{}},mf={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(h,n){var o=Ke,s=o.Buffer;function m(g,y){for(var S in g)y[S]=g[S]}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?h.exports=o:(m(o,n),n.Buffer=f);function f(g,y,S){return s(g,y,S)}f.prototype=Object.create(s.prototype),m(s,f),f.from=function(g,y,S){if(typeof g=="number")throw new TypeError("Argument must not be a number");return s(g,y,S)},f.alloc=function(g,y,S){if(typeof g!="number")throw new TypeError("Argument must be a number");var B=s(g);return y!==void 0?typeof S=="string"?B.fill(y,S):B.fill(y):B.fill(0),B},f.allocUnsafe=function(g){if(typeof g!="number")throw new TypeError("Argument must be a number");return s(g)},f.allocUnsafeSlow=function(g){if(typeof g!="number")throw new TypeError("Argument must be a number");return o.SlowBuffer(g)}})(mf,mf.exports);var zt=mf.exports,gf=65536,Ju=4294967295;function Gu(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
6
|
+
*/(function(h){const n=hi,o=vf,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;h.Buffer=y,h.SlowBuffer=$,h.INSPECT_MAX_BYTES=50;const m=2147483647;h.kMaxLength=m,y.TYPED_ARRAY_SUPPORT=f(),!y.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function f(){try{const E=new Uint8Array(1),w={foo:function(){return 42}};return Object.setPrototypeOf(w,Uint8Array.prototype),Object.setPrototypeOf(E,w),E.foo()===42}catch(E){return!1}}Object.defineProperty(y.prototype,"parent",{enumerable:!0,get:function(){if(y.isBuffer(this))return this.buffer}}),Object.defineProperty(y.prototype,"offset",{enumerable:!0,get:function(){if(y.isBuffer(this))return this.byteOffset}});function g(E){if(E>m)throw new RangeError('The value "'+E+'" is invalid for option "size"');const w=new Uint8Array(E);return Object.setPrototypeOf(w,y.prototype),w}function y(E,w,A){if(typeof E=="number"){if(typeof w=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return x(E)}return S(E,w,A)}y.poolSize=8192;function S(E,w,A){if(typeof E=="string")return I(E,w);if(ArrayBuffer.isView(E))return D(E);if(E==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof E);if(dt(E,ArrayBuffer)||E&&dt(E.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(dt(E,SharedArrayBuffer)||E&&dt(E.buffer,SharedArrayBuffer)))return L(E,w,A);if(typeof E=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const T=E.valueOf&&E.valueOf();if(T!=null&&T!==E)return y.from(T,w,A);const F=W(E);if(F)return F;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof E[Symbol.toPrimitive]=="function")return y.from(E[Symbol.toPrimitive]("string"),w,A);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof E)}y.from=function(E,w,A){return S(E,w,A)},Object.setPrototypeOf(y.prototype,Uint8Array.prototype),Object.setPrototypeOf(y,Uint8Array);function B(E){if(typeof E!="number")throw new TypeError('"size" argument must be of type number');if(E<0)throw new RangeError('The value "'+E+'" is invalid for option "size"')}function M(E,w,A){return B(E),E<=0?g(E):w!==void 0?typeof A=="string"?g(E).fill(w,A):g(E).fill(w):g(E)}y.alloc=function(E,w,A){return M(E,w,A)};function x(E){return B(E),g(E<0?0:z(E)|0)}y.allocUnsafe=function(E){return x(E)},y.allocUnsafeSlow=function(E){return x(E)};function I(E,w){if((typeof w!="string"||w==="")&&(w="utf8"),!y.isEncoding(w))throw new TypeError("Unknown encoding: "+w);const A=lt(E,w)|0;let T=g(A);const F=T.write(E,w);return F!==A&&(T=T.slice(0,F)),T}function k(E){const w=E.length<0?0:z(E.length)|0,A=g(w);for(let T=0;T<w;T+=1)A[T]=E[T]&255;return A}function D(E){if(dt(E,Uint8Array)){const w=new Uint8Array(E);return L(w.buffer,w.byteOffset,w.byteLength)}return k(E)}function L(E,w,A){if(w<0||E.byteLength<w)throw new RangeError('"offset" is outside of buffer bounds');if(E.byteLength<w+(A||0))throw new RangeError('"length" is outside of buffer bounds');let T;return w===void 0&&A===void 0?T=new Uint8Array(E):A===void 0?T=new Uint8Array(E,w):T=new Uint8Array(E,w,A),Object.setPrototypeOf(T,y.prototype),T}function W(E){if(y.isBuffer(E)){const w=z(E.length)|0,A=g(w);return A.length===0||E.copy(A,0,0,w),A}if(E.length!==void 0)return typeof E.length!="number"||Pt(E.length)?g(0):k(E);if(E.type==="Buffer"&&Array.isArray(E.data))return k(E.data)}function z(E){if(E>=m)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+m.toString(16)+" bytes");return E|0}function $(E){return+E!=E&&(E=0),y.alloc(+E)}y.isBuffer=function(w){return w!=null&&w._isBuffer===!0&&w!==y.prototype},y.compare=function(w,A){if(dt(w,Uint8Array)&&(w=y.from(w,w.offset,w.byteLength)),dt(A,Uint8Array)&&(A=y.from(A,A.offset,A.byteLength)),!y.isBuffer(w)||!y.isBuffer(A))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(w===A)return 0;let T=w.length,F=A.length;for(let V=0,U=Math.min(T,F);V<U;++V)if(w[V]!==A[V]){T=w[V],F=A[V];break}return T<F?-1:F<T?1:0},y.isEncoding=function(w){switch(String(w).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},y.concat=function(w,A){if(!Array.isArray(w))throw new TypeError('"list" argument must be an Array of Buffers');if(w.length===0)return y.alloc(0);let T;if(A===void 0)for(A=0,T=0;T<w.length;++T)A+=w[T].length;const F=y.allocUnsafe(A);let V=0;for(T=0;T<w.length;++T){let U=w[T];if(dt(U,Uint8Array))V+U.length>F.length?(y.isBuffer(U)||(U=y.from(U)),U.copy(F,V)):Uint8Array.prototype.set.call(F,U,V);else if(y.isBuffer(U))U.copy(F,V);else throw new TypeError('"list" argument must be an Array of Buffers');V+=U.length}return F};function lt(E,w){if(y.isBuffer(E))return E.length;if(ArrayBuffer.isView(E)||dt(E,ArrayBuffer))return E.byteLength;if(typeof E!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof E);const A=E.length,T=arguments.length>2&&arguments[2]===!0;if(!T&&A===0)return 0;let F=!1;for(;;)switch(w){case"ascii":case"latin1":case"binary":return A;case"utf8":case"utf-8":return Nt(E).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A*2;case"hex":return A>>>1;case"base64":return Dt(E).length;default:if(F)return T?-1:Nt(E).length;w=(""+w).toLowerCase(),F=!0}}y.byteLength=lt;function H(E,w,A){let T=!1;if((w===void 0||w<0)&&(w=0),w>this.length||((A===void 0||A>this.length)&&(A=this.length),A<=0)||(A>>>=0,w>>>=0,A<=w))return"";for(E||(E="utf8");;)switch(E){case"hex":return u(this,w,A);case"utf8":case"utf-8":return i(this,w,A);case"ascii":return c(this,w,A);case"latin1":case"binary":return v(this,w,A);case"base64":return r(this,w,A);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e(this,w,A);default:if(T)throw new TypeError("Unknown encoding: "+E);E=(E+"").toLowerCase(),T=!0}}y.prototype._isBuffer=!0;function At(E,w,A){const T=E[w];E[w]=E[A],E[A]=T}y.prototype.swap16=function(){const w=this.length;if(w%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let A=0;A<w;A+=2)At(this,A,A+1);return this},y.prototype.swap32=function(){const w=this.length;if(w%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let A=0;A<w;A+=4)At(this,A,A+3),At(this,A+1,A+2);return this},y.prototype.swap64=function(){const w=this.length;if(w%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let A=0;A<w;A+=8)At(this,A,A+7),At(this,A+1,A+6),At(this,A+2,A+5),At(this,A+3,A+4);return this},y.prototype.toString=function(){const w=this.length;return w===0?"":arguments.length===0?i(this,0,w):H.apply(this,arguments)},y.prototype.toLocaleString=y.prototype.toString,y.prototype.equals=function(w){if(!y.isBuffer(w))throw new TypeError("Argument must be a Buffer");return this===w?!0:y.compare(this,w)===0},y.prototype.inspect=function(){let w="";const A=h.INSPECT_MAX_BYTES;return w=this.toString("hex",0,A).replace(/(.{2})/g,"$1 ").trim(),this.length>A&&(w+=" ... "),"<Buffer "+w+">"},s&&(y.prototype[s]=y.prototype.inspect),y.prototype.compare=function(w,A,T,F,V){if(dt(w,Uint8Array)&&(w=y.from(w,w.offset,w.byteLength)),!y.isBuffer(w))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof w);if(A===void 0&&(A=0),T===void 0&&(T=w?w.length:0),F===void 0&&(F=0),V===void 0&&(V=this.length),A<0||T>w.length||F<0||V>this.length)throw new RangeError("out of range index");if(F>=V&&A>=T)return 0;if(F>=V)return-1;if(A>=T)return 1;if(A>>>=0,T>>>=0,F>>>=0,V>>>=0,this===w)return 0;let U=V-F,X=T-A;const Tt=Math.min(U,X),G=this.slice(F,V),rt=w.slice(A,T);for(let Rt=0;Rt<Tt;++Rt)if(G[Rt]!==rt[Rt]){U=G[Rt],X=rt[Rt];break}return U<X?-1:X<U?1:0};function Bt(E,w,A,T,F){if(E.length===0)return-1;if(typeof A=="string"?(T=A,A=0):A>2147483647?A=2147483647:A<-2147483648&&(A=-2147483648),A=+A,Pt(A)&&(A=F?0:E.length-1),A<0&&(A=E.length+A),A>=E.length){if(F)return-1;A=E.length-1}else if(A<0)if(F)A=0;else return-1;if(typeof w=="string"&&(w=y.from(w,T)),y.isBuffer(w))return w.length===0?-1:Ct(E,w,A,T,F);if(typeof w=="number")return w=w&255,typeof Uint8Array.prototype.indexOf=="function"?F?Uint8Array.prototype.indexOf.call(E,w,A):Uint8Array.prototype.lastIndexOf.call(E,w,A):Ct(E,[w],A,T,F);throw new TypeError("val must be string, number or Buffer")}function Ct(E,w,A,T,F){let V=1,U=E.length,X=w.length;if(T!==void 0&&(T=String(T).toLowerCase(),T==="ucs2"||T==="ucs-2"||T==="utf16le"||T==="utf-16le")){if(E.length<2||w.length<2)return-1;V=2,U/=2,X/=2,A/=2}function Tt(rt,Rt){return V===1?rt[Rt]:rt.readUInt16BE(Rt*V)}let G;if(F){let rt=-1;for(G=A;G<U;G++)if(Tt(E,G)===Tt(w,rt===-1?0:G-rt)){if(rt===-1&&(rt=G),G-rt+1===X)return rt*V}else rt!==-1&&(G-=G-rt),rt=-1}else for(A+X>U&&(A=U-X),G=A;G>=0;G--){let rt=!0;for(let Rt=0;Rt<X;Rt++)if(Tt(E,G+Rt)!==Tt(w,Rt)){rt=!1;break}if(rt)return G}return-1}y.prototype.includes=function(w,A,T){return this.indexOf(w,A,T)!==-1},y.prototype.indexOf=function(w,A,T){return Bt(this,w,A,T,!0)},y.prototype.lastIndexOf=function(w,A,T){return Bt(this,w,A,T,!1)};function Et(E,w,A,T){A=Number(A)||0;const F=E.length-A;T?(T=Number(T),T>F&&(T=F)):T=F;const V=w.length;T>V/2&&(T=V/2);let U;for(U=0;U<T;++U){const X=parseInt(w.substr(U*2,2),16);if(Pt(X))return U;E[A+U]=X}return U}function Y(E,w,A,T){return j(Nt(w,E.length-A),E,A,T)}function It(E,w,A,T){return j(et(w),E,A,T)}function p(E,w,A,T){return j(Dt(w),E,A,T)}function t(E,w,A,T){return j(pt(w,E.length-A),E,A,T)}y.prototype.write=function(w,A,T,F){if(A===void 0)F="utf8",T=this.length,A=0;else if(T===void 0&&typeof A=="string")F=A,T=this.length,A=0;else if(isFinite(A))A=A>>>0,isFinite(T)?(T=T>>>0,F===void 0&&(F="utf8")):(F=T,T=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const V=this.length-A;if((T===void 0||T>V)&&(T=V),w.length>0&&(T<0||A<0)||A>this.length)throw new RangeError("Attempt to write outside buffer bounds");F||(F="utf8");let U=!1;for(;;)switch(F){case"hex":return Et(this,w,A,T);case"utf8":case"utf-8":return Y(this,w,A,T);case"ascii":case"latin1":case"binary":return It(this,w,A,T);case"base64":return p(this,w,A,T);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return t(this,w,A,T);default:if(U)throw new TypeError("Unknown encoding: "+F);F=(""+F).toLowerCase(),U=!0}},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function r(E,w,A){return w===0&&A===E.length?n.fromByteArray(E):n.fromByteArray(E.slice(w,A))}function i(E,w,A){A=Math.min(E.length,A);const T=[];let F=w;for(;F<A;){const V=E[F];let U=null,X=V>239?4:V>223?3:V>191?2:1;if(F+X<=A){let Tt,G,rt,Rt;switch(X){case 1:V<128&&(U=V);break;case 2:Tt=E[F+1],(Tt&192)===128&&(Rt=(V&31)<<6|Tt&63,Rt>127&&(U=Rt));break;case 3:Tt=E[F+1],G=E[F+2],(Tt&192)===128&&(G&192)===128&&(Rt=(V&15)<<12|(Tt&63)<<6|G&63,Rt>2047&&(Rt<55296||Rt>57343)&&(U=Rt));break;case 4:Tt=E[F+1],G=E[F+2],rt=E[F+3],(Tt&192)===128&&(G&192)===128&&(rt&192)===128&&(Rt=(V&15)<<18|(Tt&63)<<12|(G&63)<<6|rt&63,Rt>65535&&Rt<1114112&&(U=Rt))}}U===null?(U=65533,X=1):U>65535&&(U-=65536,T.push(U>>>10&1023|55296),U=56320|U&1023),T.push(U),F+=X}return d(T)}const a=4096;function d(E){const w=E.length;if(w<=a)return String.fromCharCode.apply(String,E);let A="",T=0;for(;T<w;)A+=String.fromCharCode.apply(String,E.slice(T,T+=a));return A}function c(E,w,A){let T="";A=Math.min(E.length,A);for(let F=w;F<A;++F)T+=String.fromCharCode(E[F]&127);return T}function v(E,w,A){let T="";A=Math.min(E.length,A);for(let F=w;F<A;++F)T+=String.fromCharCode(E[F]);return T}function u(E,w,A){const T=E.length;(!w||w<0)&&(w=0),(!A||A<0||A>T)&&(A=T);let F="";for(let V=w;V<A;++V)F+=Q[E[V]];return F}function e(E,w,A){const T=E.slice(w,A);let F="";for(let V=0;V<T.length-1;V+=2)F+=String.fromCharCode(T[V]+T[V+1]*256);return F}y.prototype.slice=function(w,A){const T=this.length;w=~~w,A=A===void 0?T:~~A,w<0?(w+=T,w<0&&(w=0)):w>T&&(w=T),A<0?(A+=T,A<0&&(A=0)):A>T&&(A=T),A<w&&(A=w);const F=this.subarray(w,A);return Object.setPrototypeOf(F,y.prototype),F};function l(E,w,A){if(E%1!==0||E<0)throw new RangeError("offset is not uint");if(E+w>A)throw new RangeError("Trying to access beyond buffer length")}y.prototype.readUintLE=y.prototype.readUIntLE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let F=this[w],V=1,U=0;for(;++U<A&&(V*=256);)F+=this[w+U]*V;return F},y.prototype.readUintBE=y.prototype.readUIntBE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let F=this[w+--A],V=1;for(;A>0&&(V*=256);)F+=this[w+--A]*V;return F},y.prototype.readUint8=y.prototype.readUInt8=function(w,A){return w=w>>>0,A||l(w,1,this.length),this[w]},y.prototype.readUint16LE=y.prototype.readUInt16LE=function(w,A){return w=w>>>0,A||l(w,2,this.length),this[w]|this[w+1]<<8},y.prototype.readUint16BE=y.prototype.readUInt16BE=function(w,A){return w=w>>>0,A||l(w,2,this.length),this[w]<<8|this[w+1]},y.prototype.readUint32LE=y.prototype.readUInt32LE=function(w,A){return w=w>>>0,A||l(w,4,this.length),(this[w]|this[w+1]<<8|this[w+2]<<16)+this[w+3]*16777216},y.prototype.readUint32BE=y.prototype.readUInt32BE=function(w,A){return w=w>>>0,A||l(w,4,this.length),this[w]*16777216+(this[w+1]<<16|this[w+2]<<8|this[w+3])},y.prototype.readBigUInt64LE=ct(function(w){w=w>>>0,J(w,"offset");const A=this[w],T=this[w+7];(A===void 0||T===void 0)&&qt(w,this.length-8);const F=A+this[++w]*me(2,8)+this[++w]*me(2,16)+this[++w]*me(2,24),V=this[++w]+this[++w]*me(2,8)+this[++w]*me(2,16)+T*me(2,24);return BigInt(F)+(BigInt(V)<<BigInt(32))}),y.prototype.readBigUInt64BE=ct(function(w){w=w>>>0,J(w,"offset");const A=this[w],T=this[w+7];(A===void 0||T===void 0)&&qt(w,this.length-8);const F=A*me(2,24)+this[++w]*me(2,16)+this[++w]*me(2,8)+this[++w],V=this[++w]*me(2,24)+this[++w]*me(2,16)+this[++w]*me(2,8)+T;return(BigInt(F)<<BigInt(32))+BigInt(V)}),y.prototype.readIntLE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let F=this[w],V=1,U=0;for(;++U<A&&(V*=256);)F+=this[w+U]*V;return V*=128,F>=V&&(F-=Math.pow(2,8*A)),F},y.prototype.readIntBE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let F=A,V=1,U=this[w+--F];for(;F>0&&(V*=256);)U+=this[w+--F]*V;return V*=128,U>=V&&(U-=Math.pow(2,8*A)),U},y.prototype.readInt8=function(w,A){return w=w>>>0,A||l(w,1,this.length),this[w]&128?(255-this[w]+1)*-1:this[w]},y.prototype.readInt16LE=function(w,A){w=w>>>0,A||l(w,2,this.length);const T=this[w]|this[w+1]<<8;return T&32768?T|4294901760:T},y.prototype.readInt16BE=function(w,A){w=w>>>0,A||l(w,2,this.length);const T=this[w+1]|this[w]<<8;return T&32768?T|4294901760:T},y.prototype.readInt32LE=function(w,A){return w=w>>>0,A||l(w,4,this.length),this[w]|this[w+1]<<8|this[w+2]<<16|this[w+3]<<24},y.prototype.readInt32BE=function(w,A){return w=w>>>0,A||l(w,4,this.length),this[w]<<24|this[w+1]<<16|this[w+2]<<8|this[w+3]},y.prototype.readBigInt64LE=ct(function(w){w=w>>>0,J(w,"offset");const A=this[w],T=this[w+7];(A===void 0||T===void 0)&&qt(w,this.length-8);const F=this[w+4]+this[w+5]*me(2,8)+this[w+6]*me(2,16)+(T<<24);return(BigInt(F)<<BigInt(32))+BigInt(A+this[++w]*me(2,8)+this[++w]*me(2,16)+this[++w]*me(2,24))}),y.prototype.readBigInt64BE=ct(function(w){w=w>>>0,J(w,"offset");const A=this[w],T=this[w+7];(A===void 0||T===void 0)&&qt(w,this.length-8);const F=(A<<24)+this[++w]*me(2,16)+this[++w]*me(2,8)+this[++w];return(BigInt(F)<<BigInt(32))+BigInt(this[++w]*me(2,24)+this[++w]*me(2,16)+this[++w]*me(2,8)+T)}),y.prototype.readFloatLE=function(w,A){return w=w>>>0,A||l(w,4,this.length),o.read(this,w,!0,23,4)},y.prototype.readFloatBE=function(w,A){return w=w>>>0,A||l(w,4,this.length),o.read(this,w,!1,23,4)},y.prototype.readDoubleLE=function(w,A){return w=w>>>0,A||l(w,8,this.length),o.read(this,w,!0,52,8)},y.prototype.readDoubleBE=function(w,A){return w=w>>>0,A||l(w,8,this.length),o.read(this,w,!1,52,8)};function b(E,w,A,T,F,V){if(!y.isBuffer(E))throw new TypeError('"buffer" argument must be a Buffer instance');if(w>F||w<V)throw new RangeError('"value" argument is out of bounds');if(A+T>E.length)throw new RangeError("Index out of range")}y.prototype.writeUintLE=y.prototype.writeUIntLE=function(w,A,T,F){if(w=+w,A=A>>>0,T=T>>>0,!F){const X=Math.pow(2,8*T)-1;b(this,w,A,T,X,0)}let V=1,U=0;for(this[A]=w&255;++U<T&&(V*=256);)this[A+U]=w/V&255;return A+T},y.prototype.writeUintBE=y.prototype.writeUIntBE=function(w,A,T,F){if(w=+w,A=A>>>0,T=T>>>0,!F){const X=Math.pow(2,8*T)-1;b(this,w,A,T,X,0)}let V=T-1,U=1;for(this[A+V]=w&255;--V>=0&&(U*=256);)this[A+V]=w/U&255;return A+T},y.prototype.writeUint8=y.prototype.writeUInt8=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,1,255,0),this[A]=w&255,A+1},y.prototype.writeUint16LE=y.prototype.writeUInt16LE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,2,65535,0),this[A]=w&255,this[A+1]=w>>>8,A+2},y.prototype.writeUint16BE=y.prototype.writeUInt16BE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,2,65535,0),this[A]=w>>>8,this[A+1]=w&255,A+2},y.prototype.writeUint32LE=y.prototype.writeUInt32LE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,4,4294967295,0),this[A+3]=w>>>24,this[A+2]=w>>>16,this[A+1]=w>>>8,this[A]=w&255,A+4},y.prototype.writeUint32BE=y.prototype.writeUInt32BE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,4,4294967295,0),this[A]=w>>>24,this[A+1]=w>>>16,this[A+2]=w>>>8,this[A+3]=w&255,A+4};function _(E,w,A,T,F){Z(w,T,F,E,A,7);let V=Number(w&BigInt(4294967295));E[A++]=V,V=V>>8,E[A++]=V,V=V>>8,E[A++]=V,V=V>>8,E[A++]=V;let U=Number(w>>BigInt(32)&BigInt(4294967295));return E[A++]=U,U=U>>8,E[A++]=U,U=U>>8,E[A++]=U,U=U>>8,E[A++]=U,A}function C(E,w,A,T,F){Z(w,T,F,E,A,7);let V=Number(w&BigInt(4294967295));E[A+7]=V,V=V>>8,E[A+6]=V,V=V>>8,E[A+5]=V,V=V>>8,E[A+4]=V;let U=Number(w>>BigInt(32)&BigInt(4294967295));return E[A+3]=U,U=U>>8,E[A+2]=U,U=U>>8,E[A+1]=U,U=U>>8,E[A]=U,A+8}y.prototype.writeBigUInt64LE=ct(function(w,A=0){return _(this,w,A,BigInt(0),BigInt("0xffffffffffffffff"))}),y.prototype.writeBigUInt64BE=ct(function(w,A=0){return C(this,w,A,BigInt(0),BigInt("0xffffffffffffffff"))}),y.prototype.writeIntLE=function(w,A,T,F){if(w=+w,A=A>>>0,!F){const Tt=Math.pow(2,8*T-1);b(this,w,A,T,Tt-1,-Tt)}let V=0,U=1,X=0;for(this[A]=w&255;++V<T&&(U*=256);)w<0&&X===0&&this[A+V-1]!==0&&(X=1),this[A+V]=(w/U>>0)-X&255;return A+T},y.prototype.writeIntBE=function(w,A,T,F){if(w=+w,A=A>>>0,!F){const Tt=Math.pow(2,8*T-1);b(this,w,A,T,Tt-1,-Tt)}let V=T-1,U=1,X=0;for(this[A+V]=w&255;--V>=0&&(U*=256);)w<0&&X===0&&this[A+V+1]!==0&&(X=1),this[A+V]=(w/U>>0)-X&255;return A+T},y.prototype.writeInt8=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,1,127,-128),w<0&&(w=255+w+1),this[A]=w&255,A+1},y.prototype.writeInt16LE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,2,32767,-32768),this[A]=w&255,this[A+1]=w>>>8,A+2},y.prototype.writeInt16BE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,2,32767,-32768),this[A]=w>>>8,this[A+1]=w&255,A+2},y.prototype.writeInt32LE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,4,2147483647,-2147483648),this[A]=w&255,this[A+1]=w>>>8,this[A+2]=w>>>16,this[A+3]=w>>>24,A+4},y.prototype.writeInt32BE=function(w,A,T){return w=+w,A=A>>>0,T||b(this,w,A,4,2147483647,-2147483648),w<0&&(w=4294967295+w+1),this[A]=w>>>24,this[A+1]=w>>>16,this[A+2]=w>>>8,this[A+3]=w&255,A+4},y.prototype.writeBigInt64LE=ct(function(w,A=0){return _(this,w,A,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),y.prototype.writeBigInt64BE=ct(function(w,A=0){return C(this,w,A,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function q(E,w,A,T,F,V){if(A+T>E.length)throw new RangeError("Index out of range");if(A<0)throw new RangeError("Index out of range")}function O(E,w,A,T,F){return w=+w,A=A>>>0,F||q(E,w,A,4),o.write(E,w,A,T,23,4),A+4}y.prototype.writeFloatLE=function(w,A,T){return O(this,w,A,!0,T)},y.prototype.writeFloatBE=function(w,A,T){return O(this,w,A,!1,T)};function R(E,w,A,T,F){return w=+w,A=A>>>0,F||q(E,w,A,8),o.write(E,w,A,T,52,8),A+8}y.prototype.writeDoubleLE=function(w,A,T){return R(this,w,A,!0,T)},y.prototype.writeDoubleBE=function(w,A,T){return R(this,w,A,!1,T)},y.prototype.copy=function(w,A,T,F){if(!y.isBuffer(w))throw new TypeError("argument should be a Buffer");if(T||(T=0),!F&&F!==0&&(F=this.length),A>=w.length&&(A=w.length),A||(A=0),F>0&&F<T&&(F=T),F===T||w.length===0||this.length===0)return 0;if(A<0)throw new RangeError("targetStart out of bounds");if(T<0||T>=this.length)throw new RangeError("Index out of range");if(F<0)throw new RangeError("sourceEnd out of bounds");F>this.length&&(F=this.length),w.length-A<F-T&&(F=w.length-A+T);const V=F-T;return this===w&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(A,T,F):Uint8Array.prototype.set.call(w,this.subarray(T,F),A),V},y.prototype.fill=function(w,A,T,F){if(typeof w=="string"){if(typeof A=="string"?(F=A,A=0,T=this.length):typeof T=="string"&&(F=T,T=this.length),F!==void 0&&typeof F!="string")throw new TypeError("encoding must be a string");if(typeof F=="string"&&!y.isEncoding(F))throw new TypeError("Unknown encoding: "+F);if(w.length===1){const U=w.charCodeAt(0);(F==="utf8"&&U<128||F==="latin1")&&(w=U)}}else typeof w=="number"?w=w&255:typeof w=="boolean"&&(w=Number(w));if(A<0||this.length<A||this.length<T)throw new RangeError("Out of range index");if(T<=A)return this;A=A>>>0,T=T===void 0?this.length:T>>>0,w||(w=0);let V;if(typeof w=="number")for(V=A;V<T;++V)this[V]=w;else{const U=y.isBuffer(w)?w:y.from(w,F),X=U.length;if(X===0)throw new TypeError('The value "'+w+'" is invalid for argument "value"');for(V=0;V<T-A;++V)this[V+A]=U[V%X]}return this};const P={};function N(E,w,A){P[E]=class extends A{constructor(){super(),Object.defineProperty(this,"message",{value:w.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${E}]`,this.stack,delete this.name}get code(){return E}set code(F){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:F,writable:!0})}toString(){return`${this.name} [${E}]: ${this.message}`}}}N("ERR_BUFFER_OUT_OF_BOUNDS",function(E){return E?`${E} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),N("ERR_INVALID_ARG_TYPE",function(E,w){return`The "${E}" argument must be of type number. Received type ${typeof w}`},TypeError),N("ERR_OUT_OF_RANGE",function(E,w,A){let T=`The value of "${E}" is out of range.`,F=A;return Number.isInteger(A)&&Math.abs(A)>me(2,32)?F=K(String(A)):typeof A=="bigint"&&(F=String(A),(A>me(BigInt(2),BigInt(32))||A<-me(BigInt(2),BigInt(32)))&&(F=K(F)),F+="n"),T+=` It must be ${w}. Received ${F}`,T},RangeError);function K(E){let w="",A=E.length;const T=E[0]==="-"?1:0;for(;A>=T+4;A-=3)w=`_${E.slice(A-3,A)}${w}`;return`${E.slice(0,A)}${w}`}function kt(E,w,A){J(w,"offset"),(E[w]===void 0||E[w+A]===void 0)&&qt(w,E.length-(A+1))}function Z(E,w,A,T,F,V){if(E>A||E<w){const U=typeof w=="bigint"?"n":"";let X;throw V>3?w===0||w===BigInt(0)?X=`>= 0${U} and < 2${U} ** ${(V+1)*8}${U}`:X=`>= -(2${U} ** ${(V+1)*8-1}${U}) and < 2 ** ${(V+1)*8-1}${U}`:X=`>= ${w}${U} and <= ${A}${U}`,new P.ERR_OUT_OF_RANGE("value",X,E)}kt(T,F,V)}function J(E,w){if(typeof E!="number")throw new P.ERR_INVALID_ARG_TYPE(w,"number",E)}function qt(E,w,A){throw Math.floor(E)!==E?(J(E,A),new P.ERR_OUT_OF_RANGE(A||"offset","an integer",E)):w<0?new P.ERR_BUFFER_OUT_OF_BOUNDS:new P.ERR_OUT_OF_RANGE(A||"offset",`>= ${A?1:0} and <= ${w}`,E)}const tt=/[^+/0-9A-Za-z-_]/g;function vt(E){if(E=E.split("=")[0],E=E.trim().replace(tt,""),E.length<2)return"";for(;E.length%4!==0;)E=E+"=";return E}function Nt(E,w){w=w||1/0;let A;const T=E.length;let F=null;const V=[];for(let U=0;U<T;++U){if(A=E.charCodeAt(U),A>55295&&A<57344){if(!F){if(A>56319){(w-=3)>-1&&V.push(239,191,189);continue}else if(U+1===T){(w-=3)>-1&&V.push(239,191,189);continue}F=A;continue}if(A<56320){(w-=3)>-1&&V.push(239,191,189),F=A;continue}A=(F-55296<<10|A-56320)+65536}else F&&(w-=3)>-1&&V.push(239,191,189);if(F=null,A<128){if((w-=1)<0)break;V.push(A)}else if(A<2048){if((w-=2)<0)break;V.push(A>>6|192,A&63|128)}else if(A<65536){if((w-=3)<0)break;V.push(A>>12|224,A>>6&63|128,A&63|128)}else if(A<1114112){if((w-=4)<0)break;V.push(A>>18|240,A>>12&63|128,A>>6&63|128,A&63|128)}else throw new Error("Invalid code point")}return V}function et(E){const w=[];for(let A=0;A<E.length;++A)w.push(E.charCodeAt(A)&255);return w}function pt(E,w){let A,T,F;const V=[];for(let U=0;U<E.length&&!((w-=2)<0);++U)A=E.charCodeAt(U),T=A>>8,F=A%256,V.push(F),V.push(T);return V}function Dt(E){return n.toByteArray(vt(E))}function j(E,w,A,T){let F;for(F=0;F<T&&!(F+A>=w.length||F>=E.length);++F)w[F+A]=E[F];return F}function dt(E,w){return E instanceof w||E!=null&&E.constructor!=null&&E.constructor.name!=null&&E.constructor.name===w.name}function Pt(E){return E!==E}const Q=function(){const E="0123456789abcdef",w=new Array(256);for(let A=0;A<16;++A){const T=A*16;for(let F=0;F<16;++F)w[T+F]=E[A]+E[F]}return w}();function ct(E){return typeof BigInt=="undefined"?Ot:E}function Ot(){throw new Error("BigInt not supported")}})(Ke);class na{constructor(n,o,s,m={}){this.endpoint=n,this.apiKey=o,this.isStopped=!1,this.pollTimeoutId=null,this.currentFlags={},this.consecutiveErrors=0,this.currentBackoffMs=0,this.pollIntervalMs=m.pollIntervalMs||1e4,this.maxBackoffMs=m.maxBackoffMs||6e4,this.backoffMultiplier=m.backoffMultiplier||2,this.currentContext=s}init(){return De(this,null,function*(){try{this.currentFlags=yield this.fetchFlags(this.currentContext),this.consecutiveErrors=0,console.log("[LongPollingTransport] Initial fetch complete")}catch(n){console.error("[LongPollingTransport] Initial fetch failed:",n)}this.scheduleNextPoll()})}scheduleNextPoll(){if(this.isStopped)return;const n=this.pollIntervalMs+this.currentBackoffMs;console.log(`[LongPollingTransport] Next poll in ${n}ms`+(this.currentBackoffMs>0?` (backoff: ${this.currentBackoffMs}ms)`:"")),this.pollTimeoutId=setTimeout(()=>De(this,null,function*(){yield this.poll(),this.scheduleNextPoll()}),n)}poll(){return De(this,null,function*(){var n;try{const o=yield this.fetchFlags(this.currentContext);this.consecutiveErrors>0&&(console.log("[LongPollingTransport] ✅ Recovered from errors"),this.consecutiveErrors=0,this.currentBackoffMs=0),this.flagsChanged(o)&&(console.log("[LongPollingTransport] Flags changed, notifying..."),this.currentFlags=o,(n=this.onUpdateCallback)==null||n.call(this,o))}catch(o){console.error("[LongPollingTransport] ❌ Poll error:",o),this.consecutiveErrors++,this.applyBackoff()}})}applyBackoff(){if(this.consecutiveErrors===1)this.currentBackoffMs=0;else{const n=this.pollIntervalMs*Math.pow(this.backoffMultiplier,this.consecutiveErrors-2);this.currentBackoffMs=Math.min(n,this.maxBackoffMs),console.warn(`[LongPollingTransport] Backing off ${this.currentBackoffMs}ms (${this.consecutiveErrors} consecutive errors)`)}}flagsChanged(n){return JSON.stringify(n)!==JSON.stringify(this.currentFlags)}fetchFlags(n){return De(this,null,function*(){this.currentContext=n;const o=yield fetch(this.endpoint,{method:"POST",headers:{"x-api-key":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify({context:n})});if(o.status===401||o.status===403)throw new Error("Unauthorized: Invalid API key");if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);return(yield o.json()).data})}onFlagsUpdated(n){this.onUpdateCallback=n}destroy(){console.log("[LongPollingTransport] Destroying..."),this.isStopped=!0,this.pollTimeoutId!==null&&(clearTimeout(this.pollTimeoutId),this.pollTimeoutId=null),this.onUpdateCallback=void 0}}class fa{constructor(n,o,s=5,m=1e3){this.wsUrl=n,this.apiKey=o,this.maxRetries=s,this.initialBackoffMs=m,this.socket=null,this.flags={},this.context=null,this.isReady=!1,this.initialFlagsReceived=!1,this.initialFlagsPromise=null,this.retries=0,this.reconnectTimeoutId=null}init(){return De(this,null,function*(){yield this.connectWithRetry(),yield this.waitForInitialFlags()})}waitForInitialFlags(){return this.initialFlagsReceived?Promise.resolve():(this.initialFlagsPromise||(this.initialFlagsPromise=new Promise(n=>{const o=setInterval(()=>{this.initialFlagsReceived&&(clearInterval(o),n())},50);setTimeout(()=>{clearInterval(o),console.warn("[WebSocketTransport] Initial flags timeout"),n()},5e3)})),this.initialFlagsPromise)}connectWithRetry(){return new Promise((n,o)=>{const s=()=>{try{this.cleanupSocket(),this.setConnectionState("connecting");const m=this.getWebSocketImplementation();this.socket=new m(`${this.wsUrl}?apiKey=${this.apiKey}`),this.socket.onopen=()=>{console.log("[WebSocketTransport] Connected"),this.isReady=!0,this.retries=0,this.setConnectionState("connected"),this.context&&this.sendContext(this.context),n()},this.socket.onmessage=f=>{var g;try{const y=JSON.parse(f.data);if(console.log("[WebSocketTransport] Message received:",y),y.type==="ping"){this.socket&&this.socket.readyState===1&&this.socket.send(JSON.stringify({type:"pong"}));return}if(y.type==="pong"){console.log("[WebSocketTransport] Pong received");return}y.type==="flags"&&(console.log("[WebSocketTransport] Flags update received"),this.flags=y.flags,this.initialFlagsReceived=!0,(g=this.onFlagsUpdatedCallback)==null||g.call(this,this.flags))}catch(y){console.warn("[WebSocketTransport] Failed to parse message:",y)}},this.socket.onerror=f=>{console.error("[WebSocketTransport] Error:",f)},this.socket.onclose=f=>{if(console.log("[WebSocketTransport] Connection closed:",f.code),this.isReady=!1,this.setConnectionState("disconnected"),f.code===1008||f.code===4001){this.setConnectionState("failed"),o(new Error("Unauthorized: Invalid API key"));return}if(this.retries<this.maxRetries){const g=this.initialBackoffMs*Math.pow(2,this.retries);console.warn(`[WebSocketTransport] Reconnecting in ${g}ms (attempt ${this.retries+1})`),this.setConnectionState("reconnecting"),this.reconnectTimeoutId=setTimeout(s,g),this.retries++}else this.setConnectionState("failed"),o(new Error(`WebSocket failed after ${this.retries} retries`))}}catch(m){console.error("[WebSocketTransport] Failed to create socket:",m),this.setConnectionState("failed"),o(m)}};s()})}cleanupSocket(){this.socket&&(this.socket.onopen=null,this.socket.onmessage=null,this.socket.onerror=null,this.socket.onclose=null,this.socket.readyState===1&&this.socket.close(),this.socket=null)}setConnectionState(n){var o;(o=this.onConnectionStateCallback)==null||o.call(this,n)}getWebSocketImplementation(){if(typeof WebSocket!="undefined")return WebSocket;try{const n=require("ws");return n.default||n}catch(n){throw new Error('WebSocket not available. Install "ws" package for Node.js: npm install ws')}}fetchFlags(n){return De(this,null,function*(){var o;return this.context=n,this.isReady&&((o=this.socket)==null?void 0:o.readyState)===1&&(this.sendContext(n),this.initialFlagsReceived?yield new Promise(s=>setTimeout(s,200)):yield this.waitForInitialFlags()),this.flags})}onFlagsUpdated(n){this.onFlagsUpdatedCallback=n}onConnectionStateChanged(n){this.onConnectionStateCallback=n}destroy(){console.log("[WebSocketTransport] Destroying..."),this.reconnectTimeoutId!==null&&(clearTimeout(this.reconnectTimeoutId),this.reconnectTimeoutId=null),this.cleanupSocket(),this.flags={},this.context=null,this.isReady=!1,this.initialFlagsReceived=!1,this.initialFlagsPromise=null,this.onFlagsUpdatedCallback=void 0,this.onConnectionStateCallback=void 0,this.retries=0}sendContext(n){if(!this.socket||this.socket.readyState!==1){console.warn("[WebSocketTransport] Socket not ready, cannot send context");return}const o=JSON.stringify({type:"context",context:n});this.socket.send(o)}}function aa(h,n){if(h.type!=="rule")return!1;const o=h.attribute.split(".").reduce((s,m)=>s==null?void 0:s[m],n);switch(h.operator){case"eq":return o===h.value;case"neq":return o!==h.value;case"in":return Array.isArray(h.value)&&h.value.includes(o);case"nin":return Array.isArray(h.value)&&!h.value.includes(o);case"gt":return typeof o=="number"&&typeof h.value=="number"&&o>h.value;case"lt":return typeof o=="number"&&typeof h.value=="number"&&o<h.value;case"exists":return o!=null;case"not_exists":return o==null;default:return!1}}function Mu(h,n){return h.rules.every(o=>aa(o,n))}var Lt={};const Ti=typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{};function ha(){throw new Error("setTimeout has not been defined")}function sa(){throw new Error("clearTimeout has not been defined")}var qr=ha,Pr=sa;typeof Ti.setTimeout=="function"&&(qr=setTimeout),typeof Ti.clearTimeout=="function"&&(Pr=clearTimeout);function oa(h){if(qr===setTimeout)return setTimeout(h,0);if((qr===ha||!qr)&&setTimeout)return qr=setTimeout,setTimeout(h,0);try{return qr(h,0)}catch(n){try{return qr.call(null,h,0)}catch(o){return qr.call(this,h,0)}}}function xu(h){if(Pr===clearTimeout)return clearTimeout(h);if((Pr===sa||!Pr)&&clearTimeout)return Pr=clearTimeout,clearTimeout(h);try{return Pr(h)}catch(n){try{return Pr.call(null,h)}catch(o){return Pr.call(this,h)}}}var _r=[],oi=!1,Hr,dn=-1;function _u(){!oi||!Hr||(oi=!1,Hr.length?_r=Hr.concat(_r):dn=-1,_r.length&&ua())}function ua(){if(!oi){var h=oa(_u);oi=!0;for(var n=_r.length;n;){for(Hr=_r,_r=[];++dn<n;)Hr&&Hr[dn].run();dn=-1,n=_r.length}Hr=null,oi=!1,xu(h)}}function Su(h){var n=new Array(arguments.length-1);if(arguments.length>1)for(var o=1;o<arguments.length;o++)n[o-1]=arguments[o];_r.push(new la(h,n)),_r.length===1&&!oi&&oa(ua)}function la(h,n){this.fun=h,this.array=n}la.prototype.run=function(){this.fun.apply(null,this.array)};var Au="browser",Bu="browser",Eu=!0,ku={},Iu=[],Ru="",Tu={},Cu={},Fu={};function Zr(){}var qu=Zr,Pu=Zr,Du=Zr,Nu=Zr,$u=Zr,Uu=Zr,Lu=Zr;function Ou(h){throw new Error("process.binding is not supported")}function zu(){return"/"}function Ku(h){throw new Error("process.chdir is not supported")}function Hu(){return 0}var ui=Ti.performance||{},Zu=ui.now||ui.mozNow||ui.msNow||ui.oNow||ui.webkitNow||function(){return new Date().getTime()};function Wu(h){var n=Zu.call(ui)*.001,o=Math.floor(n),s=Math.floor(n%1*1e9);return h&&(o=o-h[0],s=s-h[1],s<0&&(o--,s+=1e9)),[o,s]}var Vu=new Date;function Yu(){var h=new Date,n=h-Vu;return n/1e3}var ye={nextTick:Su,title:Au,browser:Eu,env:ku,argv:Iu,version:Ru,versions:Tu,on:qu,addListener:Pu,once:Du,off:Nu,removeListener:$u,removeAllListeners:Uu,emit:Lu,binding:Ou,cwd:zu,chdir:Ku,umask:Hu,hrtime:Wu,platform:Bu,release:Cu,config:Fu,uptime:Yu},pf={exports:{}},mf={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(h,n){var o=Ke,s=o.Buffer;function m(g,y){for(var S in g)y[S]=g[S]}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?h.exports=o:(m(o,n),n.Buffer=f);function f(g,y,S){return s(g,y,S)}f.prototype=Object.create(s.prototype),m(s,f),f.from=function(g,y,S){if(typeof g=="number")throw new TypeError("Argument must not be a number");return s(g,y,S)},f.alloc=function(g,y,S){if(typeof g!="number")throw new TypeError("Argument must be a number");var B=s(g);return y!==void 0?typeof S=="string"?B.fill(y,S):B.fill(y):B.fill(0),B},f.allocUnsafe=function(g){if(typeof g!="number")throw new TypeError("Argument must be a number");return s(g)},f.allocUnsafeSlow=function(g){if(typeof g!="number")throw new TypeError("Argument must be a number");return o.SlowBuffer(g)}})(mf,mf.exports);var zt=mf.exports,gf=65536,Ju=4294967295;function Gu(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
7
7
|
Use Chrome, Firefox or Internet Explorer 11`)}var Xu=zt.Buffer,cn=Ft.crypto||Ft.msCrypto;cn&&cn.getRandomValues?pf.exports=ju:pf.exports=Gu;function ju(h,n){if(h>Ju)throw new RangeError("requested too many random bytes");var o=Xu.allocUnsafe(h);if(h>0)if(h>gf)for(var s=0;s<h;s+=gf)cn.getRandomValues(o.slice(s,s+gf));else cn.getRandomValues(o);return typeof n=="function"?ye.nextTick(function(){n(null,o)}):o}var li=pf.exports,bf={exports:{}};typeof Object.create=="function"?bf.exports=function(n,o){o&&(n.super_=o,n.prototype=Object.create(o.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}:bf.exports=function(n,o){if(o){n.super_=o;var s=function(){};s.prototype=o.prototype,n.prototype=new s,n.prototype.constructor=n}};var Kt=bf.exports;const Ne=cf(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var or=zt.Buffer,da=Ne.Transform,Qu=Kt;function Dr(h){da.call(this),this._block=or.allocUnsafe(h),this._blockSize=h,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}Qu(Dr,da),Dr.prototype._transform=function(h,n,o){var s=null;try{this.update(h,n)}catch(m){s=m}o(s)},Dr.prototype._flush=function(h){var n=null;try{this.push(this.digest())}catch(o){n=o}h(n)};var tl=typeof Uint8Array!="undefined",el=typeof ArrayBuffer!="undefined"&&typeof Uint8Array!="undefined"&&ArrayBuffer.isView&&(or.prototype instanceof Uint8Array||or.TYPED_ARRAY_SUPPORT);function rl(h,n){if(h instanceof or)return h;if(typeof h=="string")return or.from(h,n);if(el&&ArrayBuffer.isView(h)){if(h.byteLength===0)return or.alloc(0);var o=or.from(h.buffer,h.byteOffset,h.byteLength);if(o.byteLength===h.byteLength)return o}if(tl&&h instanceof Uint8Array||or.isBuffer(h)&&h.constructor&&typeof h.constructor.isBuffer=="function"&&h.constructor.isBuffer(h))return or.from(h);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}Dr.prototype.update=function(h,n){if(this._finalized)throw new Error("Digest already called");h=rl(h,n);for(var o=this._block,s=0;this._blockOffset+h.length-s>=this._blockSize;){for(var m=this._blockOffset;m<this._blockSize;)o[m++]=h[s++];this._update(),this._blockOffset=0}for(;s<h.length;)o[this._blockOffset++]=h[s++];for(var f=0,g=h.length*8;g>0;++f)this._length[f]+=g,g=this._length[f]/4294967296|0,g>0&&(this._length[f]-=4294967296*g);return this},Dr.prototype._update=function(){throw new Error("_update is not implemented")},Dr.prototype.digest=function(h){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var n=this._digest();h!==void 0&&(n=n.toString(h)),this._block.fill(0),this._blockOffset=0;for(var o=0;o<4;++o)this._length[o]=0;return n},Dr.prototype._digest=function(){throw new Error("_digest is not implemented")};var ca=Dr,il=Kt,va=ca,nl=zt.Buffer,fl=new Array(16);function vn(){va.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}il(vn,va),vn.prototype._update=function(){for(var h=fl,n=0;n<16;++n)h[n]=this._block.readInt32LE(n*4);var o=this._a,s=this._b,m=this._c,f=this._d;o=Te(o,s,m,f,h[0],3614090360,7),f=Te(f,o,s,m,h[1],3905402710,12),m=Te(m,f,o,s,h[2],606105819,17),s=Te(s,m,f,o,h[3],3250441966,22),o=Te(o,s,m,f,h[4],4118548399,7),f=Te(f,o,s,m,h[5],1200080426,12),m=Te(m,f,o,s,h[6],2821735955,17),s=Te(s,m,f,o,h[7],4249261313,22),o=Te(o,s,m,f,h[8],1770035416,7),f=Te(f,o,s,m,h[9],2336552879,12),m=Te(m,f,o,s,h[10],4294925233,17),s=Te(s,m,f,o,h[11],2304563134,22),o=Te(o,s,m,f,h[12],1804603682,7),f=Te(f,o,s,m,h[13],4254626195,12),m=Te(m,f,o,s,h[14],2792965006,17),s=Te(s,m,f,o,h[15],1236535329,22),o=Ce(o,s,m,f,h[1],4129170786,5),f=Ce(f,o,s,m,h[6],3225465664,9),m=Ce(m,f,o,s,h[11],643717713,14),s=Ce(s,m,f,o,h[0],3921069994,20),o=Ce(o,s,m,f,h[5],3593408605,5),f=Ce(f,o,s,m,h[10],38016083,9),m=Ce(m,f,o,s,h[15],3634488961,14),s=Ce(s,m,f,o,h[4],3889429448,20),o=Ce(o,s,m,f,h[9],568446438,5),f=Ce(f,o,s,m,h[14],3275163606,9),m=Ce(m,f,o,s,h[3],4107603335,14),s=Ce(s,m,f,o,h[8],1163531501,20),o=Ce(o,s,m,f,h[13],2850285829,5),f=Ce(f,o,s,m,h[2],4243563512,9),m=Ce(m,f,o,s,h[7],1735328473,14),s=Ce(s,m,f,o,h[12],2368359562,20),o=Fe(o,s,m,f,h[5],4294588738,4),f=Fe(f,o,s,m,h[8],2272392833,11),m=Fe(m,f,o,s,h[11],1839030562,16),s=Fe(s,m,f,o,h[14],4259657740,23),o=Fe(o,s,m,f,h[1],2763975236,4),f=Fe(f,o,s,m,h[4],1272893353,11),m=Fe(m,f,o,s,h[7],4139469664,16),s=Fe(s,m,f,o,h[10],3200236656,23),o=Fe(o,s,m,f,h[13],681279174,4),f=Fe(f,o,s,m,h[0],3936430074,11),m=Fe(m,f,o,s,h[3],3572445317,16),s=Fe(s,m,f,o,h[6],76029189,23),o=Fe(o,s,m,f,h[9],3654602809,4),f=Fe(f,o,s,m,h[12],3873151461,11),m=Fe(m,f,o,s,h[15],530742520,16),s=Fe(s,m,f,o,h[2],3299628645,23),o=qe(o,s,m,f,h[0],4096336452,6),f=qe(f,o,s,m,h[7],1126891415,10),m=qe(m,f,o,s,h[14],2878612391,15),s=qe(s,m,f,o,h[5],4237533241,21),o=qe(o,s,m,f,h[12],1700485571,6),f=qe(f,o,s,m,h[3],2399980690,10),m=qe(m,f,o,s,h[10],4293915773,15),s=qe(s,m,f,o,h[1],2240044497,21),o=qe(o,s,m,f,h[8],1873313359,6),f=qe(f,o,s,m,h[15],4264355552,10),m=qe(m,f,o,s,h[6],2734768916,15),s=qe(s,m,f,o,h[13],1309151649,21),o=qe(o,s,m,f,h[4],4149444226,6),f=qe(f,o,s,m,h[11],3174756917,10),m=qe(m,f,o,s,h[2],718787259,15),s=qe(s,m,f,o,h[9],3951481745,21),this._a=this._a+o|0,this._b=this._b+s|0,this._c=this._c+m|0,this._d=this._d+f|0},vn.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var h=nl.allocUnsafe(16);return h.writeInt32LE(this._a,0),h.writeInt32LE(this._b,4),h.writeInt32LE(this._c,8),h.writeInt32LE(this._d,12),h};function pn(h,n){return h<<n|h>>>32-n}function Te(h,n,o,s,m,f,g){return pn(h+(n&o|~n&s)+m+f|0,g)+n|0}function Ce(h,n,o,s,m,f,g){return pn(h+(n&s|o&~s)+m+f|0,g)+n|0}function Fe(h,n,o,s,m,f,g){return pn(h+(n^o^s)+m+f|0,g)+n|0}function qe(h,n,o,s,m,f,g){return pn(h+(o^(n|~s))+m+f|0,g)+n|0}var yf=vn,wf=Ke.Buffer,al=Kt,pa=ca,hl=new Array(16),Ci=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],Fi=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],qi=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],Pi=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],Di=[0,1518500249,1859775393,2400959708,2840853838],Ni=[1352829926,1548603684,1836072691,2053994217,0];function mn(){pa.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}al(mn,pa),mn.prototype._update=function(){for(var h=hl,n=0;n<16;++n)h[n]=this._block.readInt32LE(n*4);for(var o=this._a|0,s=this._b|0,m=this._c|0,f=this._d|0,g=this._e|0,y=this._a|0,S=this._b|0,B=this._c|0,M=this._d|0,x=this._e|0,I=0;I<80;I+=1){var k,D;I<16?(k=ma(o,s,m,f,g,h[Ci[I]],Di[0],qi[I]),D=wa(y,S,B,M,x,h[Fi[I]],Ni[0],Pi[I])):I<32?(k=ga(o,s,m,f,g,h[Ci[I]],Di[1],qi[I]),D=ya(y,S,B,M,x,h[Fi[I]],Ni[1],Pi[I])):I<48?(k=ba(o,s,m,f,g,h[Ci[I]],Di[2],qi[I]),D=ba(y,S,B,M,x,h[Fi[I]],Ni[2],Pi[I])):I<64?(k=ya(o,s,m,f,g,h[Ci[I]],Di[3],qi[I]),D=ga(y,S,B,M,x,h[Fi[I]],Ni[3],Pi[I])):(k=wa(o,s,m,f,g,h[Ci[I]],Di[4],qi[I]),D=ma(y,S,B,M,x,h[Fi[I]],Ni[4],Pi[I])),o=g,g=f,f=Wr(m,10),m=s,s=k,y=x,x=M,M=Wr(B,10),B=S,S=D}var L=this._b+m+M|0;this._b=this._c+f+x|0,this._c=this._d+g+y|0,this._d=this._e+o+S|0,this._e=this._a+s+B|0,this._a=L},mn.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var h=wf.alloc?wf.alloc(20):new wf(20);return h.writeInt32LE(this._a,0),h.writeInt32LE(this._b,4),h.writeInt32LE(this._c,8),h.writeInt32LE(this._d,12),h.writeInt32LE(this._e,16),h};function Wr(h,n){return h<<n|h>>>32-n}function ma(h,n,o,s,m,f,g,y){return Wr(h+(n^o^s)+f+g|0,y)+m|0}function ga(h,n,o,s,m,f,g,y){return Wr(h+(n&o|~n&s)+f+g|0,y)+m|0}function ba(h,n,o,s,m,f,g,y){return Wr(h+((n|~o)^s)+f+g|0,y)+m|0}function ya(h,n,o,s,m,f,g,y){return Wr(h+(n&s|o&~s)+f+g|0,y)+m|0}function wa(h,n,o,s,m,f,g,y){return Wr(h+(n^(o|~s))+f+g|0,y)+m|0}var Mf=mn,Ma={exports:{}},xa=zt.Buffer;function gn(h,n){this._block=xa.alloc(h),this._finalSize=n,this._blockSize=h,this._len=0}gn.prototype.update=function(h,n){typeof h=="string"&&(n=n||"utf8",h=xa.from(h,n));for(var o=this._block,s=this._blockSize,m=h.length,f=this._len,g=0;g<m;){for(var y=f%s,S=Math.min(m-g,s-y),B=0;B<S;B++)o[y+B]=h[g+B];f+=S,g+=S,f%s===0&&this._update(o)}return this._len+=m,this},gn.prototype.digest=function(h){var n=this._len%this._blockSize;this._block[n]=128,this._block.fill(0,n+1),n>=this._finalSize&&(this._update(this._block),this._block.fill(0));var o=this._len*8;if(o<=4294967295)this._block.writeUInt32BE(o,this._blockSize-4);else{var s=(o&4294967295)>>>0,m=(o-s)/4294967296;this._block.writeUInt32BE(m,this._blockSize-8),this._block.writeUInt32BE(s,this._blockSize-4)}this._update(this._block);var f=this._hash();return h?f.toString(h):f},gn.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var di=gn,sl=Kt,_a=di,ol=zt.Buffer,ul=[1518500249,1859775393,-1894007588,-899497514],ll=new Array(80);function $i(){this.init(),this._w=ll,_a.call(this,64,56)}sl($i,_a),$i.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function dl(h){return h<<5|h>>>27}function cl(h){return h<<30|h>>>2}function vl(h,n,o,s){return h===0?n&o|~n&s:h===2?n&o|n&s|o&s:n^o^s}$i.prototype._update=function(h){for(var n=this._w,o=this._a|0,s=this._b|0,m=this._c|0,f=this._d|0,g=this._e|0,y=0;y<16;++y)n[y]=h.readInt32BE(y*4);for(;y<80;++y)n[y]=n[y-3]^n[y-8]^n[y-14]^n[y-16];for(var S=0;S<80;++S){var B=~~(S/20),M=dl(o)+vl(B,s,m,f)+g+n[S]+ul[B]|0;g=f,f=m,m=cl(s),s=o,o=M}this._a=o+this._a|0,this._b=s+this._b|0,this._c=m+this._c|0,this._d=f+this._d|0,this._e=g+this._e|0},$i.prototype._hash=function(){var h=ol.allocUnsafe(20);return h.writeInt32BE(this._a|0,0),h.writeInt32BE(this._b|0,4),h.writeInt32BE(this._c|0,8),h.writeInt32BE(this._d|0,12),h.writeInt32BE(this._e|0,16),h};var pl=$i,ml=Kt,Sa=di,gl=zt.Buffer,bl=[1518500249,1859775393,-1894007588,-899497514],yl=new Array(80);function Ui(){this.init(),this._w=yl,Sa.call(this,64,56)}ml(Ui,Sa),Ui.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function wl(h){return h<<1|h>>>31}function Ml(h){return h<<5|h>>>27}function xl(h){return h<<30|h>>>2}function _l(h,n,o,s){return h===0?n&o|~n&s:h===2?n&o|n&s|o&s:n^o^s}Ui.prototype._update=function(h){for(var n=this._w,o=this._a|0,s=this._b|0,m=this._c|0,f=this._d|0,g=this._e|0,y=0;y<16;++y)n[y]=h.readInt32BE(y*4);for(;y<80;++y)n[y]=wl(n[y-3]^n[y-8]^n[y-14]^n[y-16]);for(var S=0;S<80;++S){var B=~~(S/20),M=Ml(o)+_l(B,s,m,f)+g+n[S]+bl[B]|0;g=f,f=m,m=xl(s),s=o,o=M}this._a=o+this._a|0,this._b=s+this._b|0,this._c=m+this._c|0,this._d=f+this._d|0,this._e=g+this._e|0},Ui.prototype._hash=function(){var h=gl.allocUnsafe(20);return h.writeInt32BE(this._a|0,0),h.writeInt32BE(this._b|0,4),h.writeInt32BE(this._c|0,8),h.writeInt32BE(this._d|0,12),h.writeInt32BE(this._e|0,16),h};var Sl=Ui,Al=Kt,Aa=di,Bl=zt.Buffer,El=[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],kl=new Array(64);function Li(){this.init(),this._w=kl,Aa.call(this,64,56)}Al(Li,Aa),Li.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function Il(h,n,o){return o^h&(n^o)}function Rl(h,n,o){return h&n|o&(h|n)}function Tl(h){return(h>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10)}function Cl(h){return(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7)}function Fl(h){return(h>>>7|h<<25)^(h>>>18|h<<14)^h>>>3}function ql(h){return(h>>>17|h<<15)^(h>>>19|h<<13)^h>>>10}Li.prototype._update=function(h){for(var n=this._w,o=this._a|0,s=this._b|0,m=this._c|0,f=this._d|0,g=this._e|0,y=this._f|0,S=this._g|0,B=this._h|0,M=0;M<16;++M)n[M]=h.readInt32BE(M*4);for(;M<64;++M)n[M]=ql(n[M-2])+n[M-7]+Fl(n[M-15])+n[M-16]|0;for(var x=0;x<64;++x){var I=B+Cl(g)+Il(g,y,S)+El[x]+n[x]|0,k=Tl(o)+Rl(o,s,m)|0;B=S,S=y,y=g,g=f+I|0,f=m,m=s,s=o,o=I+k|0}this._a=o+this._a|0,this._b=s+this._b|0,this._c=m+this._c|0,this._d=f+this._d|0,this._e=g+this._e|0,this._f=y+this._f|0,this._g=S+this._g|0,this._h=B+this._h|0},Li.prototype._hash=function(){var h=Bl.allocUnsafe(32);return h.writeInt32BE(this._a,0),h.writeInt32BE(this._b,4),h.writeInt32BE(this._c,8),h.writeInt32BE(this._d,12),h.writeInt32BE(this._e,16),h.writeInt32BE(this._f,20),h.writeInt32BE(this._g,24),h.writeInt32BE(this._h,28),h};var Ba=Li,Pl=Kt,Dl=Ba,Nl=di,$l=zt.Buffer,Ul=new Array(64);function bn(){this.init(),this._w=Ul,Nl.call(this,64,56)}Pl(bn,Dl),bn.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},bn.prototype._hash=function(){var h=$l.allocUnsafe(28);return h.writeInt32BE(this._a,0),h.writeInt32BE(this._b,4),h.writeInt32BE(this._c,8),h.writeInt32BE(this._d,12),h.writeInt32BE(this._e,16),h.writeInt32BE(this._f,20),h.writeInt32BE(this._g,24),h};var Ll=bn,Ol=Kt,Ea=di,zl=zt.Buffer,ka=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],Kl=new Array(160);function Oi(){this.init(),this._w=Kl,Ea.call(this,128,112)}Ol(Oi,Ea),Oi.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function Ia(h,n,o){return o^h&(n^o)}function Ra(h,n,o){return h&n|o&(h|n)}function Ta(h,n){return(h>>>28|n<<4)^(n>>>2|h<<30)^(n>>>7|h<<25)}function Ca(h,n){return(h>>>14|n<<18)^(h>>>18|n<<14)^(n>>>9|h<<23)}function Hl(h,n){return(h>>>1|n<<31)^(h>>>8|n<<24)^h>>>7}function Zl(h,n){return(h>>>1|n<<31)^(h>>>8|n<<24)^(h>>>7|n<<25)}function Wl(h,n){return(h>>>19|n<<13)^(n>>>29|h<<3)^h>>>6}function Vl(h,n){return(h>>>19|n<<13)^(n>>>29|h<<3)^(h>>>6|n<<26)}function _e(h,n){return h>>>0<n>>>0?1:0}Oi.prototype._update=function(h){for(var n=this._w,o=this._ah|0,s=this._bh|0,m=this._ch|0,f=this._dh|0,g=this._eh|0,y=this._fh|0,S=this._gh|0,B=this._hh|0,M=this._al|0,x=this._bl|0,I=this._cl|0,k=this._dl|0,D=this._el|0,L=this._fl|0,W=this._gl|0,z=this._hl|0,$=0;$<32;$+=2)n[$]=h.readInt32BE($*4),n[$+1]=h.readInt32BE($*4+4);for(;$<160;$+=2){var lt=n[$-30],H=n[$-15*2+1],At=Hl(lt,H),Bt=Zl(H,lt);lt=n[$-2*2],H=n[$-2*2+1];var Ct=Wl(lt,H),Et=Vl(H,lt),Y=n[$-7*2],It=n[$-7*2+1],p=n[$-16*2],t=n[$-16*2+1],r=Bt+It|0,i=At+Y+_e(r,Bt)|0;r=r+Et|0,i=i+Ct+_e(r,Et)|0,r=r+t|0,i=i+p+_e(r,t)|0,n[$]=i,n[$+1]=r}for(var a=0;a<160;a+=2){i=n[a],r=n[a+1];var d=Ra(o,s,m),c=Ra(M,x,I),v=Ta(o,M),u=Ta(M,o),e=Ca(g,D),l=Ca(D,g),b=ka[a],_=ka[a+1],C=Ia(g,y,S),q=Ia(D,L,W),O=z+l|0,R=B+e+_e(O,z)|0;O=O+q|0,R=R+C+_e(O,q)|0,O=O+_|0,R=R+b+_e(O,_)|0,O=O+r|0,R=R+i+_e(O,r)|0;var P=u+c|0,N=v+d+_e(P,u)|0;B=S,z=W,S=y,W=L,y=g,L=D,D=k+O|0,g=f+R+_e(D,k)|0,f=m,k=I,m=s,I=x,s=o,x=M,M=O+P|0,o=R+N+_e(M,O)|0}this._al=this._al+M|0,this._bl=this._bl+x|0,this._cl=this._cl+I|0,this._dl=this._dl+k|0,this._el=this._el+D|0,this._fl=this._fl+L|0,this._gl=this._gl+W|0,this._hl=this._hl+z|0,this._ah=this._ah+o+_e(this._al,M)|0,this._bh=this._bh+s+_e(this._bl,x)|0,this._ch=this._ch+m+_e(this._cl,I)|0,this._dh=this._dh+f+_e(this._dl,k)|0,this._eh=this._eh+g+_e(this._el,D)|0,this._fh=this._fh+y+_e(this._fl,L)|0,this._gh=this._gh+S+_e(this._gl,W)|0,this._hh=this._hh+B+_e(this._hl,z)|0},Oi.prototype._hash=function(){var h=zl.allocUnsafe(64);function n(o,s,m){h.writeInt32BE(o,m),h.writeInt32BE(s,m+4)}return n(this._ah,this._al,0),n(this._bh,this._bl,8),n(this._ch,this._cl,16),n(this._dh,this._dl,24),n(this._eh,this._el,32),n(this._fh,this._fl,40),n(this._gh,this._gl,48),n(this._hh,this._hl,56),h};var Fa=Oi,Yl=Kt,Jl=Fa,Gl=di,Xl=zt.Buffer,jl=new Array(160);function yn(){this.init(),this._w=jl,Gl.call(this,128,112)}Yl(yn,Jl),yn.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},yn.prototype._hash=function(){var h=Xl.allocUnsafe(48);function n(o,s,m){h.writeInt32BE(o,m),h.writeInt32BE(s,m+4)}return n(this._ah,this._al,0),n(this._bh,this._bl,8),n(this._ch,this._cl,16),n(this._dh,this._dl,24),n(this._eh,this._el,32),n(this._fh,this._fl,40),h};var Ql=yn,Vr=Ma.exports=function(n){n=n.toLowerCase();var o=Vr[n];if(!o)throw new Error(n+" is not supported (we accept pull requests)");return new o};Vr.sha=pl,Vr.sha1=Sl,Vr.sha224=Ll,Vr.sha256=Ba,Vr.sha384=Ql,Vr.sha512=Fa;var xf=Ma.exports,wn={},_f={exports:{}};(function(h,n){var o=Ke,s=o.Buffer;function m(g,y){for(var S in g)y[S]=g[S]}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?h.exports=o:(m(o,n),n.Buffer=f);function f(g,y,S){return s(g,y,S)}m(s,f),f.from=function(g,y,S){if(typeof g=="number")throw new TypeError("Argument must not be a number");return s(g,y,S)},f.alloc=function(g,y,S){if(typeof g!="number")throw new TypeError("Argument must be a number");var B=s(g);return y!==void 0?typeof S=="string"?B.fill(y,S):B.fill(y):B.fill(0),B},f.allocUnsafe=function(g){if(typeof g!="number")throw new TypeError("Argument must be a number");return s(g)},f.allocUnsafeSlow=function(g){if(typeof g!="number")throw new TypeError("Argument must be a number");return o.SlowBuffer(g)}})(_f,_f.exports);var td=_f.exports,Sf=td.Buffer,qa=Sf.isEncoding||function(h){switch(h=""+h,h&&h.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function ed(h){if(!h)return"utf8";for(var n;;)switch(h){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return h;default:if(n)return;h=(""+h).toLowerCase(),n=!0}}function rd(h){var n=ed(h);if(typeof n!="string"&&(Sf.isEncoding===qa||!qa(h)))throw new Error("Unknown encoding: "+h);return n||h}wn.StringDecoder=zi;function zi(h){this.encoding=rd(h);var n;switch(this.encoding){case"utf16le":this.text=sd,this.end=od,n=4;break;case"utf8":this.fillLast=fd,n=4;break;case"base64":this.text=ud,this.end=ld,n=3;break;default:this.write=dd,this.end=cd;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Sf.allocUnsafe(n)}zi.prototype.write=function(h){if(h.length===0)return"";var n,o;if(this.lastNeed){if(n=this.fillLast(h),n===void 0)return"";o=this.lastNeed,this.lastNeed=0}else o=0;return o<h.length?n?n+this.text(h,o):this.text(h,o):n||""},zi.prototype.end=hd,zi.prototype.text=ad,zi.prototype.fillLast=function(h){if(this.lastNeed<=h.length)return h.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);h.copy(this.lastChar,this.lastTotal-this.lastNeed,0,h.length),this.lastNeed-=h.length};function Af(h){return h<=127?0:h>>5===6?2:h>>4===14?3:h>>3===30?4:h>>6===2?-1:-2}function id(h,n,o){var s=n.length-1;if(s<o)return 0;var m=Af(n[s]);return m>=0?(m>0&&(h.lastNeed=m-1),m):--s<o||m===-2?0:(m=Af(n[s]),m>=0?(m>0&&(h.lastNeed=m-2),m):--s<o||m===-2?0:(m=Af(n[s]),m>=0?(m>0&&(m===2?m=0:h.lastNeed=m-3),m):0))}function nd(h,n,o){if((n[0]&192)!==128)return h.lastNeed=0,"�";if(h.lastNeed>1&&n.length>1){if((n[1]&192)!==128)return h.lastNeed=1,"�";if(h.lastNeed>2&&n.length>2&&(n[2]&192)!==128)return h.lastNeed=2,"�"}}function fd(h){var n=this.lastTotal-this.lastNeed,o=nd(this,h);if(o!==void 0)return o;if(this.lastNeed<=h.length)return h.copy(this.lastChar,n,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);h.copy(this.lastChar,n,0,h.length),this.lastNeed-=h.length}function ad(h,n){var o=id(this,h,n);if(!this.lastNeed)return h.toString("utf8",n);this.lastTotal=o;var s=h.length-(o-this.lastNeed);return h.copy(this.lastChar,0,s),h.toString("utf8",n,s)}function hd(h){var n=h&&h.length?this.write(h):"";return this.lastNeed?n+"�":n}function sd(h,n){if((h.length-n)%2===0){var o=h.toString("utf16le",n);if(o){var s=o.charCodeAt(o.length-1);if(s>=55296&&s<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=h[h.length-2],this.lastChar[1]=h[h.length-1],o.slice(0,-1)}return o}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=h[h.length-1],h.toString("utf16le",n,h.length-1)}function od(h){var n=h&&h.length?this.write(h):"";if(this.lastNeed){var o=this.lastTotal-this.lastNeed;return n+this.lastChar.toString("utf16le",0,o)}return n}function ud(h,n){var o=(h.length-n)%3;return o===0?h.toString("base64",n):(this.lastNeed=3-o,this.lastTotal=3,o===1?this.lastChar[0]=h[h.length-1]:(this.lastChar[0]=h[h.length-2],this.lastChar[1]=h[h.length-1]),h.toString("base64",n,h.length-o))}function ld(h){var n=h&&h.length?this.write(h):"";return this.lastNeed?n+this.lastChar.toString("base64",0,3-this.lastNeed):n}function dd(h){return h.toString(this.encoding)}function cd(h){return h&&h.length?this.write(h):""}var ur=zt.Buffer,Pa=Ne.Transform,vd=wn.StringDecoder,pd=Kt;function er(h){Pa.call(this),this.hashMode=typeof h=="string",this.hashMode?this[h]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}pd(er,Pa);var md=typeof Uint8Array!="undefined",gd=typeof ArrayBuffer!="undefined"&&typeof Uint8Array!="undefined"&&ArrayBuffer.isView&&(ur.prototype instanceof Uint8Array||ur.TYPED_ARRAY_SUPPORT);function bd(h,n){if(h instanceof ur)return h;if(typeof h=="string")return ur.from(h,n);if(gd&&ArrayBuffer.isView(h)){if(h.byteLength===0)return ur.alloc(0);var o=ur.from(h.buffer,h.byteOffset,h.byteLength);if(o.byteLength===h.byteLength)return o}if(md&&h instanceof Uint8Array||ur.isBuffer(h)&&h.constructor&&typeof h.constructor.isBuffer=="function"&&h.constructor.isBuffer(h))return ur.from(h);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}er.prototype.update=function(h,n,o){var s=bd(h,n),m=this._update(s);return this.hashMode?this:(o&&(m=this._toString(m,o)),m)},er.prototype.setAutoPadding=function(){},er.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},er.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},er.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},er.prototype._transform=function(h,n,o){var s;try{this.hashMode?this._update(h):this.push(this._update(h))}catch(m){s=m}finally{o(s)}},er.prototype._flush=function(h){var n;try{this.push(this.__final())}catch(o){n=o}h(n)},er.prototype._finalOrDigest=function(h){var n=this.__final()||ur.alloc(0);return h&&(n=this._toString(n,h,!0)),n},er.prototype._toString=function(h,n,o){if(this._decoder||(this._decoder=new vd(n),this._encoding=n),this._encoding!==n)throw new Error("can’t switch encodings");var s=this._decoder.write(h);return o&&(s+=this._decoder.end()),s};var Nr=er,yd=Kt,wd=yf,Md=Mf,xd=xf,Da=Nr;function Mn(h){Da.call(this,"digest"),this._hash=h}yd(Mn,Da),Mn.prototype._update=function(h){this._hash.update(h)},Mn.prototype._final=function(){return this._hash.digest()};var Ki=function(n){return n=n.toLowerCase(),n==="md5"?new wd:n==="rmd160"||n==="ripemd160"?new Md:new Mn(xd(n))},_d=Kt,Yr=zt.Buffer,Na=Nr,Sd=Yr.alloc(128),ci=64;function xn(h,n){Na.call(this,"digest"),typeof n=="string"&&(n=Yr.from(n)),this._alg=h,this._key=n,n.length>ci?n=h(n):n.length<ci&&(n=Yr.concat([n,Sd],ci));for(var o=this._ipad=Yr.allocUnsafe(ci),s=this._opad=Yr.allocUnsafe(ci),m=0;m<ci;m++)o[m]=n[m]^54,s[m]=n[m]^92;this._hash=[o]}_d(xn,Na),xn.prototype._update=function(h){this._hash.push(h)},xn.prototype._final=function(){var h=this._alg(Yr.concat(this._hash));return this._alg(Yr.concat([this._opad,h]))};var Ad=xn,Bd=yf,$a=function(h){return new Bd().update(h).digest()},Ed=Kt,kd=Ad,Ua=Nr,Hi=zt.Buffer,Id=$a,Bf=Mf,Ef=xf,Rd=Hi.alloc(128);function Zi(h,n){Ua.call(this,"digest"),typeof n=="string"&&(n=Hi.from(n));var o=h==="sha512"||h==="sha384"?128:64;if(this._alg=h,this._key=n,n.length>o){var s=h==="rmd160"?new Bf:Ef(h);n=s.update(n).digest()}else n.length<o&&(n=Hi.concat([n,Rd],o));for(var m=this._ipad=Hi.allocUnsafe(o),f=this._opad=Hi.allocUnsafe(o),g=0;g<o;g++)m[g]=n[g]^54,f[g]=n[g]^92;this._hash=h==="rmd160"?new Bf:Ef(h),this._hash.update(m)}Ed(Zi,Ua),Zi.prototype._update=function(h){this._hash.update(h)},Zi.prototype._final=function(){var h=this._hash.digest(),n=this._alg==="rmd160"?new Bf:Ef(this._alg);return n.update(this._opad).update(h).digest()};var La=function(n,o){return n=n.toLowerCase(),n==="rmd160"||n==="ripemd160"?new Zi("rmd160",o):n==="md5"?new kd(Id,o):new Zi(n,o)};const Oa={sha224WithRSAEncryption:{sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:{sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:{sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:{sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA512":{sign:"ecdsa/rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},"RSA-SHA1":{sign:"rsa",hash:"sha1",id:"3021300906052b0e03021a05000414"},"ecdsa-with-SHA1":{sign:"ecdsa",hash:"sha1",id:""},sha256:{sign:"ecdsa",hash:"sha256",id:""},sha224:{sign:"ecdsa",hash:"sha224",id:""},sha384:{sign:"ecdsa",hash:"sha384",id:""},sha512:{sign:"ecdsa",hash:"sha512",id:""},"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:{sign:"dsa",hash:"sha1",id:""},"DSA-WITH-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-SHA224":{sign:"dsa",hash:"sha224",id:""},"DSA-WITH-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-SHA256":{sign:"dsa",hash:"sha256",id:""},"DSA-WITH-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-SHA384":{sign:"dsa",hash:"sha384",id:""},"DSA-WITH-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-SHA512":{sign:"dsa",hash:"sha512",id:""},"DSA-RIPEMD160":{sign:"dsa",hash:"rmd160",id:""},ripemd160WithRSA:{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}};var Td=Oa,_n={},Cd=Math.pow(2,30)-1,za=function(h,n){if(typeof h!="number")throw new TypeError("Iterations not a number");if(h<0)throw new TypeError("Bad iterations");if(typeof n!="number")throw new TypeError("Key length not a number");if(n<0||n>Cd||n!==n)throw new TypeError("Bad key length")},Sn;if(Ft.process&&Ft.process.browser)Sn="utf-8";else if(Ft.process&&Ft.process.version){var Fd=parseInt(ye.version.split(".")[0].slice(1),10);Sn=Fd>=6?"utf-8":"binary"}else Sn="utf-8";var Ka=Sn,kf=zt.Buffer,Ha=function(h,n,o){if(kf.isBuffer(h))return h;if(typeof h=="string")return kf.from(h,n);if(ArrayBuffer.isView(h))return kf.from(h.buffer);throw new TypeError(o+" must be a string, a Buffer, a typed array or a DataView")},qd=$a,Pd=Mf,Dd=xf,Jr=zt.Buffer,Nd=za,Za=Ka,Wa=Ha,$d=Jr.alloc(128),An={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function Va(h,n,o){var s=Ud(h),m=h==="sha512"||h==="sha384"?128:64;n.length>m?n=s(n):n.length<m&&(n=Jr.concat([n,$d],m));for(var f=Jr.allocUnsafe(m+An[h]),g=Jr.allocUnsafe(m+An[h]),y=0;y<m;y++)f[y]=n[y]^54,g[y]=n[y]^92;var S=Jr.allocUnsafe(m+o+4);f.copy(S,0,0,m),this.ipad1=S,this.ipad2=f,this.opad=g,this.alg=h,this.blocksize=m,this.hash=s,this.size=An[h]}Va.prototype.run=function(h,n){h.copy(n,this.blocksize);var o=this.hash(n);return o.copy(this.opad,this.blocksize),this.hash(this.opad)};function Ud(h){function n(s){return Dd(h).update(s).digest()}function o(s){return new Pd().update(s).digest()}return h==="rmd160"||h==="ripemd160"?o:h==="md5"?qd:n}function Ld(h,n,o,s,m){Nd(o,s),h=Wa(h,Za,"Password"),n=Wa(n,Za,"Salt"),m=m||"sha1";var f=new Va(m,h,n.length),g=Jr.allocUnsafe(s),y=Jr.allocUnsafe(n.length+4);n.copy(y,0,0,n.length);for(var S=0,B=An[m],M=Math.ceil(s/B),x=1;x<=M;x++){y.writeUInt32BE(x,n.length);for(var I=f.run(y,f.ipad1),k=I,D=1;D<o;D++){k=f.run(k,f.ipad2);for(var L=0;L<B;L++)I[L]^=k[L]}I.copy(g,S),S+=B}return g}var Ya=Ld,Ja=zt.Buffer,Od=za,Ga=Ka,Xa=Ya,ja=Ha,Bn,Wi=Ft.crypto&&Ft.crypto.subtle,zd={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},If=[];function Kd(h){if(Ft.process&&!Ft.process.browser||!Wi||!Wi.importKey||!Wi.deriveBits)return Promise.resolve(!1);if(If[h]!==void 0)return If[h];Bn=Bn||Ja.alloc(8);var n=Qa(Bn,Bn,10,128,h).then(function(){return!0}).catch(function(){return!1});return If[h]=n,n}var Gr;function Rf(){return Gr||(Ft.process&&Ft.process.nextTick?Gr=Ft.process.nextTick:Ft.queueMicrotask?Gr=Ft.queueMicrotask:Ft.setImmediate?Gr=Ft.setImmediate:Gr=Ft.setTimeout,Gr)}function Qa(h,n,o,s,m){return Wi.importKey("raw",h,{name:"PBKDF2"},!1,["deriveBits"]).then(function(f){return Wi.deriveBits({name:"PBKDF2",salt:n,iterations:o,hash:{name:m}},f,s<<3)}).then(function(f){return Ja.from(f)})}function Hd(h,n){h.then(function(o){Rf()(function(){n(null,o)})},function(o){Rf()(function(){n(o)})})}var Zd=function(h,n,o,s,m,f){typeof m=="function"&&(f=m,m=void 0),m=m||"sha1";var g=zd[m.toLowerCase()];if(!g||typeof Ft.Promise!="function"){Rf()(function(){var y;try{y=Xa(h,n,o,s,m)}catch(S){return f(S)}f(null,y)});return}if(Od(o,s),h=ja(h,Ga,"Password"),n=ja(n,Ga,"Salt"),typeof f!="function")throw new Error("No callback provided to pbkdf2");Hd(Kd(g).then(function(y){return y?Qa(h,n,o,s,g):Xa(h,n,o,s,m)}),f)};_n.pbkdf2=Zd,_n.pbkdf2Sync=Ya;var rr={},vi={},He={};He.readUInt32BE=function(n,o){var s=n[0+o]<<24|n[1+o]<<16|n[2+o]<<8|n[3+o];return s>>>0},He.writeUInt32BE=function(n,o,s){n[0+s]=o>>>24,n[1+s]=o>>>16&255,n[2+s]=o>>>8&255,n[3+s]=o&255},He.ip=function(n,o,s,m){for(var f=0,g=0,y=6;y>=0;y-=2){for(var S=0;S<=24;S+=8)f<<=1,f|=o>>>S+y&1;for(var S=0;S<=24;S+=8)f<<=1,f|=n>>>S+y&1}for(var y=6;y>=0;y-=2){for(var S=1;S<=25;S+=8)g<<=1,g|=o>>>S+y&1;for(var S=1;S<=25;S+=8)g<<=1,g|=n>>>S+y&1}s[m+0]=f>>>0,s[m+1]=g>>>0},He.rip=function(n,o,s,m){for(var f=0,g=0,y=0;y<4;y++)for(var S=24;S>=0;S-=8)f<<=1,f|=o>>>S+y&1,f<<=1,f|=n>>>S+y&1;for(var y=4;y<8;y++)for(var S=24;S>=0;S-=8)g<<=1,g|=o>>>S+y&1,g<<=1,g|=n>>>S+y&1;s[m+0]=f>>>0,s[m+1]=g>>>0},He.pc1=function(n,o,s,m){for(var f=0,g=0,y=7;y>=5;y--){for(var S=0;S<=24;S+=8)f<<=1,f|=o>>S+y&1;for(var S=0;S<=24;S+=8)f<<=1,f|=n>>S+y&1}for(var S=0;S<=24;S+=8)f<<=1,f|=o>>S+y&1;for(var y=1;y<=3;y++){for(var S=0;S<=24;S+=8)g<<=1,g|=o>>S+y&1;for(var S=0;S<=24;S+=8)g<<=1,g|=n>>S+y&1}for(var S=0;S<=24;S+=8)g<<=1,g|=n>>S+y&1;s[m+0]=f>>>0,s[m+1]=g>>>0},He.r28shl=function(n,o){return n<<o&268435455|n>>>28-o};var En=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];He.pc2=function(n,o,s,m){for(var f=0,g=0,y=En.length>>>1,S=0;S<y;S++)f<<=1,f|=n>>>En[S]&1;for(var S=y;S<En.length;S++)g<<=1,g|=o>>>En[S]&1;s[m+0]=f>>>0,s[m+1]=g>>>0},He.expand=function(n,o,s){var m=0,f=0;m=(n&1)<<5|n>>>27;for(var g=23;g>=15;g-=4)m<<=6,m|=n>>>g&63;for(var g=11;g>=3;g-=4)f|=n>>>g&63,f<<=6;f|=(n&31)<<1|n>>>31,o[s+0]=m>>>0,o[s+1]=f>>>0};var th=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];He.substitute=function(n,o){for(var s=0,m=0;m<4;m++){var f=n>>>18-m*6&63,g=th[m*64+f];s<<=4,s|=g}for(var m=0;m<4;m++){var f=o>>>18-m*6&63,g=th[4*64+m*64+f];s<<=4,s|=g}return s>>>0};var eh=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];He.permute=function(n){for(var o=0,s=0;s<eh.length;s++)o<<=1,o|=n>>>eh[s]&1;return o>>>0},He.padSplit=function(n,o,s){for(var m=n.toString(2);m.length<o;)m="0"+m;for(var f=[],g=0;g<o;g+=s)f.push(m.slice(g,g+s));return f.join(" ")};var Ye=rh;function rh(h,n){if(!h)throw new Error(n||"Assertion failed")}rh.equal=function(n,o,s){if(n!=o)throw new Error(s||"Assertion failed: "+n+" != "+o)};var Wd=Ye;function Je(h){this.options=h,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0,this.padding=h.padding!==!1}var Tf=Je;Je.prototype._init=function(){},Je.prototype.update=function(n){return n.length===0?[]:this.type==="decrypt"?this._updateDecrypt(n):this._updateEncrypt(n)},Je.prototype._buffer=function(n,o){for(var s=Math.min(this.buffer.length-this.bufferOff,n.length-o),m=0;m<s;m++)this.buffer[this.bufferOff+m]=n[o+m];return this.bufferOff+=s,s},Je.prototype._flushBuffer=function(n,o){return this._update(this.buffer,0,n,o),this.bufferOff=0,this.blockSize},Je.prototype._updateEncrypt=function(n){var o=0,s=0,m=(this.bufferOff+n.length)/this.blockSize|0,f=new Array(m*this.blockSize);this.bufferOff!==0&&(o+=this._buffer(n,o),this.bufferOff===this.buffer.length&&(s+=this._flushBuffer(f,s)));for(var g=n.length-(n.length-o)%this.blockSize;o<g;o+=this.blockSize)this._update(n,o,f,s),s+=this.blockSize;for(;o<n.length;o++,this.bufferOff++)this.buffer[this.bufferOff]=n[o];return f},Je.prototype._updateDecrypt=function(n){for(var o=0,s=0,m=Math.ceil((this.bufferOff+n.length)/this.blockSize)-1,f=new Array(m*this.blockSize);m>0;m--)o+=this._buffer(n,o),s+=this._flushBuffer(f,s);return o+=this._buffer(n,o),f},Je.prototype.final=function(n){var o;n&&(o=this.update(n));var s;return this.type==="encrypt"?s=this._finalEncrypt():s=this._finalDecrypt(),o?o.concat(s):s},Je.prototype._pad=function(n,o){if(o===0)return!1;for(;o<n.length;)n[o++]=0;return!0},Je.prototype._finalEncrypt=function(){if(!this._pad(this.buffer,this.bufferOff))return[];var n=new Array(this.blockSize);return this._update(this.buffer,0,n,0),n},Je.prototype._unpad=function(n){return n},Je.prototype._finalDecrypt=function(){Wd.equal(this.bufferOff,this.blockSize,"Not enough data to decrypt");var n=new Array(this.blockSize);return this._flushBuffer(n,0),this._unpad(n)};var ih=Ye,Vd=Kt,xe=He,nh=Tf;function Yd(){this.tmp=new Array(2),this.keys=null}function lr(h){nh.call(this,h);var n=new Yd;this._desState=n,this.deriveKeys(n,h.key)}Vd(lr,nh);var fh=lr;lr.create=function(n){return new lr(n)};var Jd=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];lr.prototype.deriveKeys=function(n,o){n.keys=new Array(16*2),ih.equal(o.length,this.blockSize,"Invalid key length");var s=xe.readUInt32BE(o,0),m=xe.readUInt32BE(o,4);xe.pc1(s,m,n.tmp,0),s=n.tmp[0],m=n.tmp[1];for(var f=0;f<n.keys.length;f+=2){var g=Jd[f>>>1];s=xe.r28shl(s,g),m=xe.r28shl(m,g),xe.pc2(s,m,n.keys,f)}},lr.prototype._update=function(n,o,s,m){var f=this._desState,g=xe.readUInt32BE(n,o),y=xe.readUInt32BE(n,o+4);xe.ip(g,y,f.tmp,0),g=f.tmp[0],y=f.tmp[1],this.type==="encrypt"?this._encrypt(f,g,y,f.tmp,0):this._decrypt(f,g,y,f.tmp,0),g=f.tmp[0],y=f.tmp[1],xe.writeUInt32BE(s,g,m),xe.writeUInt32BE(s,y,m+4)},lr.prototype._pad=function(n,o){if(this.padding===!1)return!1;for(var s=n.length-o,m=o;m<n.length;m++)n[m]=s;return!0},lr.prototype._unpad=function(n){if(this.padding===!1)return n;for(var o=n[n.length-1],s=n.length-o;s<n.length;s++)ih.equal(n[s],o);return n.slice(0,n.length-o)},lr.prototype._encrypt=function(n,o,s,m,f){for(var g=o,y=s,S=0;S<n.keys.length;S+=2){var B=n.keys[S],M=n.keys[S+1];xe.expand(y,n.tmp,0),B^=n.tmp[0],M^=n.tmp[1];var x=xe.substitute(B,M),I=xe.permute(x),k=y;y=(g^I)>>>0,g=k}xe.rip(y,g,m,f)},lr.prototype._decrypt=function(n,o,s,m,f){for(var g=s,y=o,S=n.keys.length-2;S>=0;S-=2){var B=n.keys[S],M=n.keys[S+1];xe.expand(g,n.tmp,0),B^=n.tmp[0],M^=n.tmp[1];var x=xe.substitute(B,M),I=xe.permute(x),k=g;g=(y^I)>>>0,y=k}xe.rip(g,y,m,f)};var ah={},Gd=Ye,Xd=Kt,kn={};function jd(h){Gd.equal(h.length,8,"Invalid IV length"),this.iv=new Array(8);for(var n=0;n<this.iv.length;n++)this.iv[n]=h[n]}function Qd(h){function n(f){h.call(this,f),this._cbcInit()}Xd(n,h);for(var o=Object.keys(kn),s=0;s<o.length;s++){var m=o[s];n.prototype[m]=kn[m]}return n.create=function(g){return new n(g)},n}ah.instantiate=Qd,kn._cbcInit=function(){var n=new jd(this.options.iv);this._cbcState=n},kn._update=function(n,o,s,m){var f=this._cbcState,g=this.constructor.super_.prototype,y=f.iv;if(this.type==="encrypt"){for(var S=0;S<this.blockSize;S++)y[S]^=n[o+S];g._update.call(this,y,0,s,m);for(var S=0;S<this.blockSize;S++)y[S]=s[m+S]}else{g._update.call(this,n,o,s,m);for(var S=0;S<this.blockSize;S++)s[m+S]^=y[S];for(var S=0;S<this.blockSize;S++)y[S]=n[o+S]}};var tc=Ye,ec=Kt,hh=Tf,$r=fh;function rc(h,n){tc.equal(n.length,24,"Invalid key length");var o=n.slice(0,8),s=n.slice(8,16),m=n.slice(16,24);h==="encrypt"?this.ciphers=[$r.create({type:"encrypt",key:o}),$r.create({type:"decrypt",key:s}),$r.create({type:"encrypt",key:m})]:this.ciphers=[$r.create({type:"decrypt",key:m}),$r.create({type:"encrypt",key:s}),$r.create({type:"decrypt",key:o})]}function Xr(h){hh.call(this,h);var n=new rc(this.type,this.options.key);this._edeState=n}ec(Xr,hh);var ic=Xr;Xr.create=function(n){return new Xr(n)},Xr.prototype._update=function(n,o,s,m){var f=this._edeState;f.ciphers[0]._update(n,o,s,m),f.ciphers[1]._update(s,m,s,m),f.ciphers[2]._update(s,m,s,m)},Xr.prototype._pad=$r.prototype._pad,Xr.prototype._unpad=$r.prototype._unpad,vi.utils=He,vi.Cipher=Tf,vi.DES=fh,vi.CBC=ah,vi.EDE=ic;var sh=Nr,Sr=vi,nc=Kt,jr=zt.Buffer,Vi={"des-ede3-cbc":Sr.CBC.instantiate(Sr.EDE),"des-ede3":Sr.EDE,"des-ede-cbc":Sr.CBC.instantiate(Sr.EDE),"des-ede":Sr.EDE,"des-cbc":Sr.CBC.instantiate(Sr.DES),"des-ecb":Sr.DES};Vi.des=Vi["des-cbc"],Vi.des3=Vi["des-ede3-cbc"];var fc=In;nc(In,sh);function In(h){sh.call(this);var n=h.mode.toLowerCase(),o=Vi[n],s;h.decrypt?s="decrypt":s="encrypt";var m=h.key;jr.isBuffer(m)||(m=jr.from(m)),(n==="des-ede"||n==="des-ede-cbc")&&(m=jr.concat([m,m.slice(0,8)]));var f=h.iv;jr.isBuffer(f)||(f=jr.from(f)),this._des=o.create({key:m,iv:f,type:s})}In.prototype._update=function(h){return jr.from(this._des.update(h))},In.prototype._final=function(){return jr.from(this._des.final())};var Ze={},Cf={},Ff={};Ff.encrypt=function(h,n){return h._cipher.encryptBlock(n)},Ff.decrypt=function(h,n){return h._cipher.decryptBlock(n)};var qf={},dr=[],Ge=[],ac=typeof Uint8Array!="undefined"?Uint8Array:Array,Pf=!1;function oh(){Pf=!0;for(var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,o=h.length;n<o;++n)dr[n]=h[n],Ge[h.charCodeAt(n)]=n;Ge["-".charCodeAt(0)]=62,Ge["_".charCodeAt(0)]=63}function hc(h){Pf||oh();var n,o,s,m,f,g,y=h.length;if(y%4>0)throw new Error("Invalid string. Length must be a multiple of 4");f=h[y-2]==="="?2:h[y-1]==="="?1:0,g=new ac(y*3/4-f),s=f>0?y-4:y;var S=0;for(n=0,o=0;n<s;n+=4,o+=3)m=Ge[h.charCodeAt(n)]<<18|Ge[h.charCodeAt(n+1)]<<12|Ge[h.charCodeAt(n+2)]<<6|Ge[h.charCodeAt(n+3)],g[S++]=m>>16&255,g[S++]=m>>8&255,g[S++]=m&255;return f===2?(m=Ge[h.charCodeAt(n)]<<2|Ge[h.charCodeAt(n+1)]>>4,g[S++]=m&255):f===1&&(m=Ge[h.charCodeAt(n)]<<10|Ge[h.charCodeAt(n+1)]<<4|Ge[h.charCodeAt(n+2)]>>2,g[S++]=m>>8&255,g[S++]=m&255),g}function sc(h){return dr[h>>18&63]+dr[h>>12&63]+dr[h>>6&63]+dr[h&63]}function oc(h,n,o){for(var s,m=[],f=n;f<o;f+=3)s=(h[f]<<16)+(h[f+1]<<8)+h[f+2],m.push(sc(s));return m.join("")}function uh(h){Pf||oh();for(var n,o=h.length,s=o%3,m="",f=[],g=16383,y=0,S=o-s;y<S;y+=g)f.push(oc(h,y,y+g>S?S:y+g));return s===1?(n=h[o-1],m+=dr[n>>2],m+=dr[n<<4&63],m+="=="):s===2&&(n=(h[o-2]<<8)+h[o-1],m+=dr[n>>10],m+=dr[n>>4&63],m+=dr[n<<2&63],m+="="),f.push(m),f.join("")}function Rn(h,n,o,s,m){var f,g,y=m*8-s-1,S=(1<<y)-1,B=S>>1,M=-7,x=o?m-1:0,I=o?-1:1,k=h[n+x];for(x+=I,f=k&(1<<-M)-1,k>>=-M,M+=y;M>0;f=f*256+h[n+x],x+=I,M-=8);for(g=f&(1<<-M)-1,f>>=-M,M+=s;M>0;g=g*256+h[n+x],x+=I,M-=8);if(f===0)f=1-B;else{if(f===S)return g?NaN:(k?-1:1)*(1/0);g=g+Math.pow(2,s),f=f-B}return(k?-1:1)*g*Math.pow(2,f-s)}function lh(h,n,o,s,m,f){var g,y,S,B=f*8-m-1,M=(1<<B)-1,x=M>>1,I=m===23?Math.pow(2,-24)-Math.pow(2,-77):0,k=s?0:f-1,D=s?1:-1,L=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(y=isNaN(n)?1:0,g=M):(g=Math.floor(Math.log(n)/Math.LN2),n*(S=Math.pow(2,-g))<1&&(g--,S*=2),g+x>=1?n+=I/S:n+=I*Math.pow(2,1-x),n*S>=2&&(g++,S/=2),g+x>=M?(y=0,g=M):g+x>=1?(y=(n*S-1)*Math.pow(2,m),g=g+x):(y=n*Math.pow(2,x-1)*Math.pow(2,m),g=0));m>=8;h[o+k]=y&255,k+=D,y/=256,m-=8);for(g=g<<m|y,B+=m;B>0;h[o+k]=g&255,k+=D,g/=256,B-=8);h[o+k-D]|=L*128}var uc={}.toString,dh=Array.isArray||function(h){return uc.call(h)=="[object Array]"};/*!
|
|
8
8
|
* The buffer module from node.js, for the browser.
|
|
9
9
|
*
|
|
@@ -15,4 +15,4 @@ Use Chrome, Firefox or Internet Explorer 11`)}var Xu=zt.Buffer,cn=Ft.crypto||Ft.
|
|
|
15
15
|
`)},O0}var xo;function vm(){return xo||(xo=1,function(h){var n=h;n.der=wo(),n.pem=cm()}(U0)),U0}var _o;function sn(){return _o||(_o=1,function(h){var n=h;n.bignum=am,n.define=hm().define,n.base=hn(),n.constants=vo(),n.decoders=dm(),n.encoders=vm()}(I0)),I0}var ar=sn(),So=ar.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),pm=ar.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),z0=ar.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),mm=ar.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(z0),this.key("subjectPublicKey").bitstr())}),gm=ar.define("RelativeDistinguishedName",function(){this.setof(pm)}),bm=ar.define("RDNSequence",function(){this.seqof(gm)}),Ao=ar.define("Name",function(){this.choice({rdnSequence:this.use(bm)})}),ym=ar.define("Validity",function(){this.seq().obj(this.key("notBefore").use(So),this.key("notAfter").use(So))}),wm=ar.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),Mm=ar.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(z0),this.key("issuer").use(Ao),this.key("validity").use(ym),this.key("subject").use(Ao),this.key("subjectPublicKeyInfo").use(mm),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(wm).optional())}),xm=ar.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(Mm),this.key("signatureAlgorithm").use(z0),this.key("signatureValue").bitstr())}),_m=xm,hr=sn();fr.certificate=_m;var Sm=hr.define("RSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("modulus").int(),this.key("publicExponent").int(),this.key("privateExponent").int(),this.key("prime1").int(),this.key("prime2").int(),this.key("exponent1").int(),this.key("exponent2").int(),this.key("coefficient").int())});fr.RSAPrivateKey=Sm;var Am=hr.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});fr.RSAPublicKey=Am;var Bo=hr.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("none").null_().optional(),this.key("curve").objid().optional(),this.key("params").seq().obj(this.key("p").int(),this.key("q").int(),this.key("g").int()).optional())}),Bm=hr.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(Bo),this.key("subjectPublicKey").bitstr())});fr.PublicKey=Bm;var Em=hr.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use(Bo),this.key("subjectPrivateKey").octstr())});fr.PrivateKey=Em;var km=hr.define("EncryptedPrivateKeyInfo",function(){this.seq().obj(this.key("algorithm").seq().obj(this.key("id").objid(),this.key("decrypt").seq().obj(this.key("kde").seq().obj(this.key("id").objid(),this.key("kdeparams").seq().obj(this.key("salt").octstr(),this.key("iters").int())),this.key("cipher").seq().obj(this.key("algo").objid(),this.key("iv").octstr()))),this.key("subjectPrivateKey").octstr())});fr.EncryptedPrivateKey=km;var Im=hr.define("DSAPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("p").int(),this.key("q").int(),this.key("g").int(),this.key("pub_key").int(),this.key("priv_key").int())});fr.DSAPrivateKey=Im,fr.DSAparam=hr.define("DSAparam",function(){this.int()});var Rm=hr.define("ECParameters",function(){this.choice({namedCurve:this.objid()})}),Tm=hr.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(Rm),this.key("publicKey").optional().explicit(1).bitstr())});fr.ECPrivateKey=Tm,fr.signature=hr.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())});const Cm={"2.16.840.1.101.3.4.1.1":"aes-128-ecb","2.16.840.1.101.3.4.1.2":"aes-128-cbc","2.16.840.1.101.3.4.1.3":"aes-128-ofb","2.16.840.1.101.3.4.1.4":"aes-128-cfb","2.16.840.1.101.3.4.1.21":"aes-192-ecb","2.16.840.1.101.3.4.1.22":"aes-192-cbc","2.16.840.1.101.3.4.1.23":"aes-192-ofb","2.16.840.1.101.3.4.1.24":"aes-192-cfb","2.16.840.1.101.3.4.1.41":"aes-256-ecb","2.16.840.1.101.3.4.1.42":"aes-256-cbc","2.16.840.1.101.3.4.1.43":"aes-256-ofb","2.16.840.1.101.3.4.1.44":"aes-256-cfb"};var Fm=/Proc-Type: 4,ENCRYPTED[\n\r]+DEK-Info: AES-((?:128)|(?:192)|(?:256))-CBC,([0-9A-H]+)[\n\r]+([0-9A-z\n\r+/=]+)[\n\r]+/m,qm=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,Pm=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,Dm=Ln,Nm=Ze,uf=zt.Buffer,$m=function(h,n){var o=h.toString(),s=o.match(Fm),m;if(s){var g="aes"+s[1],y=uf.from(s[2],"hex"),S=uf.from(s[3].replace(/[\r\n]/g,""),"base64"),B=Dm(n,y.slice(0,8),parseInt(s[1],10)).key,M=[],x=Nm.createDecipheriv(g,B,y);M.push(x.update(S)),M.push(x.final()),m=uf.concat(M)}else{var f=o.match(Pm);m=uf.from(f[2].replace(/[\r\n]/g,""),"base64")}var I=o.match(qm)[1];return{tag:I,data:m}},ze=fr,Um=Cm,Lm=$m,Om=Ze,zm=_n,K0=zt.Buffer;function Km(h,n){var o=h.algorithm.decrypt.kde.kdeparams.salt,s=parseInt(h.algorithm.decrypt.kde.kdeparams.iters.toString(),10),m=Um[h.algorithm.decrypt.cipher.algo.join(".")],f=h.algorithm.decrypt.cipher.iv,g=h.subjectPrivateKey,y=parseInt(m.split("-")[1],10)/8,S=zm.pbkdf2Sync(n,o,s,y,"sha1"),B=Om.createDecipheriv(m,S,f),M=[];return M.push(B.update(g)),M.push(B.final()),K0.concat(M)}function Eo(h){var n;typeof h=="object"&&!K0.isBuffer(h)&&(n=h.passphrase,h=h.key),typeof h=="string"&&(h=K0.from(h));var o=Lm(h,n),s=o.tag,m=o.data,f,g;switch(s){case"CERTIFICATE":g=ze.certificate.decode(m,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(g||(g=ze.PublicKey.decode(m,"der")),f=g.algorithm.algorithm.join("."),f){case"1.2.840.113549.1.1.1":return ze.RSAPublicKey.decode(g.subjectPublicKey.data,"der");case"1.2.840.10045.2.1":return g.subjectPrivateKey=g.subjectPublicKey,{type:"ec",data:g};case"1.2.840.10040.4.1":return g.algorithm.params.pub_key=ze.DSAparam.decode(g.subjectPublicKey.data,"der"),{type:"dsa",data:g.algorithm.params};default:throw new Error("unknown key id "+f)}case"ENCRYPTED PRIVATE KEY":m=ze.EncryptedPrivateKey.decode(m,"der"),m=Km(m,n);case"PRIVATE KEY":switch(g=ze.PrivateKey.decode(m,"der"),f=g.algorithm.algorithm.join("."),f){case"1.2.840.113549.1.1.1":return ze.RSAPrivateKey.decode(g.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:g.algorithm.curve,privateKey:ze.ECPrivateKey.decode(g.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return g.algorithm.params.priv_key=ze.DSAparam.decode(g.subjectPrivateKey,"der"),{type:"dsa",params:g.algorithm.params};default:throw new Error("unknown key id "+f)}case"RSA PUBLIC KEY":return ze.RSAPublicKey.decode(m,"der");case"RSA PRIVATE KEY":return ze.RSAPrivateKey.decode(m,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:ze.DSAPrivateKey.decode(m,"der")};case"EC PRIVATE KEY":return m=ze.ECPrivateKey.decode(m,"der"),{curve:m.parameters.value,privateKey:m.privateKey};default:throw new Error("unknown key type "+s)}}Eo.signature=ze.signature;var lf=Eo;const ko={"1.3.132.0.10":"secp256k1","1.3.132.0.33":"p224","1.2.840.10045.3.1.1":"p192","1.2.840.10045.3.1.7":"p256","1.3.132.0.34":"p384","1.3.132.0.35":"p521"};var Io;function Hm(){if(Io)return en.exports;Io=1;var h=zt.Buffer,n=La,o=l0,s=k0().ec,m=u0,f=lf,g=ko,y=1;function S(z,$,lt,H,At){var Bt=f($);if(Bt.curve){if(H!=="ecdsa"&&H!=="ecdsa/rsa")throw new Error("wrong private key type");return B(z,Bt)}else if(Bt.type==="dsa"){if(H!=="dsa")throw new Error("wrong private key type");return M(z,Bt,lt)}if(H!=="rsa"&&H!=="ecdsa/rsa")throw new Error("wrong private key type");if($.padding!==void 0&&$.padding!==y)throw new Error("illegal or unsupported padding mode");z=h.concat([At,z]);for(var Ct=Bt.modulus.byteLength(),Et=[0,1];z.length+Et.length+1<Ct;)Et.push(255);Et.push(0);for(var Y=-1;++Y<z.length;)Et.push(z[Y]);var It=o(Et,Bt);return It}function B(z,$){var lt=g[$.curve.join(".")];if(!lt)throw new Error("unknown curve "+$.curve.join("."));var H=new s(lt),At=H.keyFromPrivate($.privateKey),Bt=At.sign(z);return h.from(Bt.toDER())}function M(z,$,lt){for(var H=$.params.priv_key,At=$.params.p,Bt=$.params.q,Ct=$.params.g,Et=new m(0),Y,It=k(z,Bt).mod(Bt),p=!1,t=I(H,Bt,z,lt);p===!1;)Y=L(Bt,t,lt),Et=W(Ct,Y,At,Bt),p=Y.invm(Bt).imul(It.add(H.mul(Et))).mod(Bt),p.cmpn(0)===0&&(p=!1,Et=new m(0));return x(Et,p)}function x(z,$){z=z.toArray(),$=$.toArray(),z[0]&128&&(z=[0].concat(z)),$[0]&128&&($=[0].concat($));var lt=z.length+$.length+4,H=[48,lt,2,z.length];return H=H.concat(z,[2,$.length],$),h.from(H)}function I(z,$,lt,H){if(z=h.from(z.toArray()),z.length<$.byteLength()){var At=h.alloc($.byteLength()-z.length);z=h.concat([At,z])}var Bt=lt.length,Ct=D(lt,$),Et=h.alloc(Bt);Et.fill(1);var Y=h.alloc(Bt);return Y=n(H,Y).update(Et).update(h.from([0])).update(z).update(Ct).digest(),Et=n(H,Y).update(Et).digest(),Y=n(H,Y).update(Et).update(h.from([1])).update(z).update(Ct).digest(),Et=n(H,Y).update(Et).digest(),{k:Y,v:Et}}function k(z,$){var lt=new m(z),H=(z.length<<3)-$.bitLength();return H>0&<.ishrn(H),lt}function D(z,$){z=k(z,$),z=z.mod($);var lt=h.from(z.toArray());if(lt.length<$.byteLength()){var H=h.alloc($.byteLength()-lt.length);lt=h.concat([H,lt])}return lt}function L(z,$,lt){var H,At;do{for(H=h.alloc(0);H.length*8<z.bitLength();)$.v=n(lt,$.k).update($.v).digest(),H=h.concat([H,$.v]);At=k(H,z),$.k=n(lt,$.k).update($.v).update(h.from([0])).digest(),$.v=n(lt,$.k).update($.v).digest()}while(At.cmp(z)!==-1);return At}function W(z,$,lt,H){return z.toRed(m.mont(lt)).redPow($).fromRed().mod(H)}return en.exports=S,en.exports.getKey=I,en.exports.makeKey=L,en.exports}var H0,Ro;function Zm(){if(Ro)return H0;Ro=1;var h=zt.Buffer,n=u0,o=k0().ec,s=lf,m=ko;function f(B,M,x,I,k){var D=s(x);if(D.type==="ec"){if(I!=="ecdsa"&&I!=="ecdsa/rsa")throw new Error("wrong public key type");return g(B,M,D)}else if(D.type==="dsa"){if(I!=="dsa")throw new Error("wrong public key type");return y(B,M,D)}if(I!=="rsa"&&I!=="ecdsa/rsa")throw new Error("wrong public key type");M=h.concat([k,M]);for(var L=D.modulus.byteLength(),W=[1],z=0;M.length+W.length+2<L;)W.push(255),z+=1;W.push(0);for(var $=-1;++$<M.length;)W.push(M[$]);W=h.from(W);var lt=n.mont(D.modulus);B=new n(B).toRed(lt),B=B.redPow(new n(D.publicExponent)),B=h.from(B.fromRed().toArray());var H=z<8?1:0;for(L=Math.min(B.length,W.length),B.length!==W.length&&(H=1),$=-1;++$<L;)H|=B[$]^W[$];return H===0}function g(B,M,x){var I=m[x.data.algorithm.curve.join(".")];if(!I)throw new Error("unknown curve "+x.data.algorithm.curve.join("."));var k=new o(I),D=x.data.subjectPrivateKey.data;return k.verify(M,B,D)}function y(B,M,x){var I=x.data.p,k=x.data.q,D=x.data.g,L=x.data.pub_key,W=s.signature.decode(B,"der"),z=W.s,$=W.r;S(z,k),S($,k);var lt=n.mont(I),H=z.invm(k),At=D.toRed(lt).redPow(new n(M).mul(H).mod(k)).fromRed().mul(L.toRed(lt).redPow($.mul(H).mod(k)).fromRed()).mod(I).mod(k);return At.cmp($)===0}function S(B,M){if(B.cmpn(0)<=0)throw new Error("invalid sig");if(B.cmp(M)>=0)throw new Error("invalid sig")}return H0=f,H0}var Z0,To;function Wm(){if(To)return Z0;To=1;var h=zt.Buffer,n=Ki,o=rv,s=Kt,m=Hm(),f=Zm(),g=Oa;Object.keys(g).forEach(function(x){g[x].id=h.from(g[x].id,"hex"),g[x.toLowerCase()]=g[x]});function y(x){o.Writable.call(this);var I=g[x];if(!I)throw new Error("Unknown message digest");this._hashType=I.hash,this._hash=n(I.hash),this._tag=I.id,this._signType=I.sign}s(y,o.Writable),y.prototype._write=function(I,k,D){this._hash.update(I),D()},y.prototype.update=function(I,k){return this._hash.update(typeof I=="string"?h.from(I,k):I),this},y.prototype.sign=function(I,k){this.end();var D=this._hash.digest(),L=m(D,I,this._hashType,this._signType,this._tag);return k?L.toString(k):L};function S(x){o.Writable.call(this);var I=g[x];if(!I)throw new Error("Unknown message digest");this._hash=n(I.hash),this._tag=I.id,this._signType=I.sign}s(S,o.Writable),S.prototype._write=function(I,k,D){this._hash.update(I),D()},S.prototype.update=function(I,k){return this._hash.update(typeof I=="string"?h.from(I,k):I),this},S.prototype.verify=function(I,k,D){var L=typeof k=="string"?h.from(k,D):k;this.end();var W=this._hash.digest();return f(L,W,I,this._signType,this._tag)};function B(x){return new y(x)}function M(x){return new S(x)}return Z0={Sign:B,Verify:M,createSign:B,createVerify:M},Z0}var W0={exports:{}};W0.exports,function(h){(function(n,o){function s(p,t){if(!p)throw new Error(t||"Assertion failed")}function m(p,t){p.super_=t;var r=function(){};r.prototype=t.prototype,p.prototype=new r,p.prototype.constructor=p}function f(p,t,r){if(f.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((t==="le"||t==="be")&&(r=t,t=10),this._init(p||0,t||10,r||"be"))}typeof n=="object"?n.exports=f:o.BN=f,f.BN=f,f.wordSize=26;var g;try{typeof window!="undefined"&&typeof window.Buffer!="undefined"?g=window.Buffer:g=Ne.Buffer}catch(p){}f.isBN=function(t){return t instanceof f?!0:t!==null&&typeof t=="object"&&t.constructor.wordSize===f.wordSize&&Array.isArray(t.words)},f.max=function(t,r){return t.cmp(r)>0?t:r},f.min=function(t,r){return t.cmp(r)<0?t:r},f.prototype._init=function(t,r,i){if(typeof t=="number")return this._initNumber(t,r,i);if(typeof t=="object")return this._initArray(t,r,i);r==="hex"&&(r=16),s(r===(r|0)&&r>=2&&r<=36),t=t.toString().replace(/\s+/g,"");var a=0;t[0]==="-"&&(a++,this.negative=1),a<t.length&&(r===16?this._parseHex(t,a,i):(this._parseBase(t,r,a),i==="le"&&this._initArray(this.toArray(),r,i)))},f.prototype._initNumber=function(t,r,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[t&67108863],this.length=1):t<4503599627370496?(this.words=[t&67108863,t/67108864&67108863],this.length=2):(s(t<9007199254740992),this.words=[t&67108863,t/67108864&67108863,1],this.length=3),i==="le"&&this._initArray(this.toArray(),r,i)},f.prototype._initArray=function(t,r,i){if(s(typeof t.length=="number"),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var a=0;a<this.length;a++)this.words[a]=0;var d,c,v=0;if(i==="be")for(a=t.length-1,d=0;a>=0;a-=3)c=t[a]|t[a-1]<<8|t[a-2]<<16,this.words[d]|=c<<v&67108863,this.words[d+1]=c>>>26-v&67108863,v+=24,v>=26&&(v-=26,d++);else if(i==="le")for(a=0,d=0;a<t.length;a+=3)c=t[a]|t[a+1]<<8|t[a+2]<<16,this.words[d]|=c<<v&67108863,this.words[d+1]=c>>>26-v&67108863,v+=24,v>=26&&(v-=26,d++);return this.strip()};function y(p,t){var r=p.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function S(p,t,r){var i=y(p,r);return r-1>=t&&(i|=y(p,r-1)<<4),i}f.prototype._parseHex=function(t,r,i){this.length=Math.ceil((t.length-r)/6),this.words=new Array(this.length);for(var a=0;a<this.length;a++)this.words[a]=0;var d=0,c=0,v;if(i==="be")for(a=t.length-1;a>=r;a-=2)v=S(t,r,a)<<d,this.words[c]|=v&67108863,d>=18?(d-=18,c+=1,this.words[c]|=v>>>26):d+=8;else{var u=t.length-r;for(a=u%2===0?r+1:r;a<t.length;a+=2)v=S(t,r,a)<<d,this.words[c]|=v&67108863,d>=18?(d-=18,c+=1,this.words[c]|=v>>>26):d+=8}this.strip()};function B(p,t,r,i){for(var a=0,d=Math.min(p.length,r),c=t;c<d;c++){var v=p.charCodeAt(c)-48;a*=i,v>=49?a+=v-49+10:v>=17?a+=v-17+10:a+=v}return a}f.prototype._parseBase=function(t,r,i){this.words=[0],this.length=1;for(var a=0,d=1;d<=67108863;d*=r)a++;a--,d=d/r|0;for(var c=t.length-i,v=c%a,u=Math.min(c,c-v)+i,e=0,l=i;l<u;l+=a)e=B(t,l,l+a,r),this.imuln(d),this.words[0]+e<67108864?this.words[0]+=e:this._iaddn(e);if(v!==0){var b=1;for(e=B(t,l,t.length,r),l=0;l<v;l++)b*=r;this.imuln(b),this.words[0]+e<67108864?this.words[0]+=e:this._iaddn(e)}this.strip()},f.prototype.copy=function(t){t.words=new Array(this.length);for(var r=0;r<this.length;r++)t.words[r]=this.words[r];t.length=this.length,t.negative=this.negative,t.red=this.red},f.prototype.clone=function(){var t=new f(null);return this.copy(t),t},f.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},f.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},f.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},f.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var M=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],x=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];f.prototype.toString=function(t,r){t=t||10,r=r|0||1;var i;if(t===16||t==="hex"){i="";for(var a=0,d=0,c=0;c<this.length;c++){var v=this.words[c],u=((v<<a|d)&16777215).toString(16);d=v>>>24-a&16777215,a+=2,a>=26&&(a-=26,c--),d!==0||c!==this.length-1?i=M[6-u.length]+u+i:i=u+i}for(d!==0&&(i=d.toString(16)+i);i.length%r!==0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}if(t===(t|0)&&t>=2&&t<=36){var e=x[t],l=I[t];i="";var b=this.clone();for(b.negative=0;!b.isZero();){var _=b.modn(l).toString(t);b=b.idivn(l),b.isZero()?i=_+i:i=M[e-_.length]+_+i}for(this.isZero()&&(i="0"+i);i.length%r!==0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}s(!1,"Base should be between 2 and 36")},f.prototype.toNumber=function(){var t=this.words[0];return this.length===2?t+=this.words[1]*67108864:this.length===3&&this.words[2]===1?t+=4503599627370496+this.words[1]*67108864:this.length>2&&s(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-t:t},f.prototype.toJSON=function(){return this.toString(16)},f.prototype.toBuffer=function(t,r){return s(typeof g!="undefined"),this.toArrayLike(g,t,r)},f.prototype.toArray=function(t,r){return this.toArrayLike(Array,t,r)},f.prototype.toArrayLike=function(t,r,i){var a=this.byteLength(),d=i||Math.max(1,a);s(a<=d,"byte array longer than desired length"),s(d>0,"Requested array length <= 0"),this.strip();var c=r==="le",v=new t(d),u,e,l=this.clone();if(c){for(e=0;!l.isZero();e++)u=l.andln(255),l.iushrn(8),v[e]=u;for(;e<d;e++)v[e]=0}else{for(e=0;e<d-a;e++)v[e]=0;for(e=0;!l.isZero();e++)u=l.andln(255),l.iushrn(8),v[d-e-1]=u}return v},Math.clz32?f.prototype._countBits=function(t){return 32-Math.clz32(t)}:f.prototype._countBits=function(t){var r=t,i=0;return r>=4096&&(i+=13,r>>>=13),r>=64&&(i+=7,r>>>=7),r>=8&&(i+=4,r>>>=4),r>=2&&(i+=2,r>>>=2),i+r},f.prototype._zeroBits=function(t){if(t===0)return 26;var r=t,i=0;return r&8191||(i+=13,r>>>=13),r&127||(i+=7,r>>>=7),r&15||(i+=4,r>>>=4),r&3||(i+=2,r>>>=2),r&1||i++,i},f.prototype.bitLength=function(){var t=this.words[this.length-1],r=this._countBits(t);return(this.length-1)*26+r};function k(p){for(var t=new Array(p.bitLength()),r=0;r<t.length;r++){var i=r/26|0,a=r%26;t[r]=(p.words[i]&1<<a)>>>a}return t}f.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,r=0;r<this.length;r++){var i=this._zeroBits(this.words[r]);if(t+=i,i!==26)break}return t},f.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},f.prototype.toTwos=function(t){return this.negative!==0?this.abs().inotn(t).iaddn(1):this.clone()},f.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},f.prototype.isNeg=function(){return this.negative!==0},f.prototype.neg=function(){return this.clone().ineg()},f.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},f.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]|t.words[r];return this.strip()},f.prototype.ior=function(t){return s((this.negative|t.negative)===0),this.iuor(t)},f.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},f.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},f.prototype.iuand=function(t){var r;this.length>t.length?r=t:r=this;for(var i=0;i<r.length;i++)this.words[i]=this.words[i]&t.words[i];return this.length=r.length,this.strip()},f.prototype.iand=function(t){return s((this.negative|t.negative)===0),this.iuand(t)},f.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},f.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},f.prototype.iuxor=function(t){var r,i;this.length>t.length?(r=this,i=t):(r=t,i=this);for(var a=0;a<i.length;a++)this.words[a]=r.words[a]^i.words[a];if(this!==r)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=r.length,this.strip()},f.prototype.ixor=function(t){return s((this.negative|t.negative)===0),this.iuxor(t)},f.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},f.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},f.prototype.inotn=function(t){s(typeof t=="number"&&t>=0);var r=Math.ceil(t/26)|0,i=t%26;this._expand(r),i>0&&r--;for(var a=0;a<r;a++)this.words[a]=~this.words[a]&67108863;return i>0&&(this.words[a]=~this.words[a]&67108863>>26-i),this.strip()},f.prototype.notn=function(t){return this.clone().inotn(t)},f.prototype.setn=function(t,r){s(typeof t=="number"&&t>=0);var i=t/26|0,a=t%26;return this._expand(i+1),r?this.words[i]=this.words[i]|1<<a:this.words[i]=this.words[i]&~(1<<a),this.strip()},f.prototype.iadd=function(t){var r;if(this.negative!==0&&t.negative===0)return this.negative=0,r=this.isub(t),this.negative^=1,this._normSign();if(this.negative===0&&t.negative!==0)return t.negative=0,r=this.isub(t),t.negative=1,r._normSign();var i,a;this.length>t.length?(i=this,a=t):(i=t,a=this);for(var d=0,c=0;c<a.length;c++)r=(i.words[c]|0)+(a.words[c]|0)+d,this.words[c]=r&67108863,d=r>>>26;for(;d!==0&&c<i.length;c++)r=(i.words[c]|0)+d,this.words[c]=r&67108863,d=r>>>26;if(this.length=i.length,d!==0)this.words[this.length]=d,this.length++;else if(i!==this)for(;c<i.length;c++)this.words[c]=i.words[c];return this},f.prototype.add=function(t){var r;return t.negative!==0&&this.negative===0?(t.negative=0,r=this.sub(t),t.negative^=1,r):t.negative===0&&this.negative!==0?(this.negative=0,r=t.sub(this),this.negative=1,r):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},f.prototype.isub=function(t){if(t.negative!==0){t.negative=0;var r=this.iadd(t);return t.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i=this.cmp(t);if(i===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,d;i>0?(a=this,d=t):(a=t,d=this);for(var c=0,v=0;v<d.length;v++)r=(a.words[v]|0)-(d.words[v]|0)+c,c=r>>26,this.words[v]=r&67108863;for(;c!==0&&v<a.length;v++)r=(a.words[v]|0)+c,c=r>>26,this.words[v]=r&67108863;if(c===0&&v<a.length&&a!==this)for(;v<a.length;v++)this.words[v]=a.words[v];return this.length=Math.max(this.length,v),a!==this&&(this.negative=1),this.strip()},f.prototype.sub=function(t){return this.clone().isub(t)};function D(p,t,r){r.negative=t.negative^p.negative;var i=p.length+t.length|0;r.length=i,i=i-1|0;var a=p.words[0]|0,d=t.words[0]|0,c=a*d,v=c&67108863,u=c/67108864|0;r.words[0]=v;for(var e=1;e<i;e++){for(var l=u>>>26,b=u&67108863,_=Math.min(e,t.length-1),C=Math.max(0,e-p.length+1);C<=_;C++){var q=e-C|0;a=p.words[q]|0,d=t.words[C]|0,c=a*d+b,l+=c/67108864|0,b=c&67108863}r.words[e]=b|0,u=l|0}return u!==0?r.words[e]=u|0:r.length--,r.strip()}var L=function(t,r,i){var a=t.words,d=r.words,c=i.words,v=0,u,e,l,b=a[0]|0,_=b&8191,C=b>>>13,q=a[1]|0,O=q&8191,R=q>>>13,P=a[2]|0,N=P&8191,K=P>>>13,kt=a[3]|0,Z=kt&8191,J=kt>>>13,qt=a[4]|0,tt=qt&8191,vt=qt>>>13,Nt=a[5]|0,et=Nt&8191,pt=Nt>>>13,Dt=a[6]|0,j=Dt&8191,dt=Dt>>>13,Pt=a[7]|0,Q=Pt&8191,ct=Pt>>>13,Ot=a[8]|0,E=Ot&8191,w=Ot>>>13,A=a[9]|0,T=A&8191,F=A>>>13,V=d[0]|0,U=V&8191,X=V>>>13,Tt=d[1]|0,G=Tt&8191,rt=Tt>>>13,Rt=d[2]|0,it=Rt&8191,gt=Rt>>>13,Ht=d[3]|0,nt=Ht&8191,bt=Ht>>>13,Zt=d[4]|0,ft=Zt&8191,yt=Zt>>>13,Wt=d[5]|0,at=Wt&8191,wt=Wt>>>13,Vt=d[6]|0,ht=Vt&8191,Mt=Vt>>>13,Yt=d[7]|0,st=Yt&8191,xt=Yt>>>13,Jt=d[8]|0,ot=Jt&8191,_t=Jt>>>13,Gt=d[9]|0,ut=Gt&8191,St=Gt>>>13;i.negative=t.negative^r.negative,i.length=19,u=Math.imul(_,U),e=Math.imul(_,X),e=e+Math.imul(C,U)|0,l=Math.imul(C,X);var $t=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+($t>>>26)|0,$t&=67108863,u=Math.imul(O,U),e=Math.imul(O,X),e=e+Math.imul(R,U)|0,l=Math.imul(R,X),u=u+Math.imul(_,G)|0,e=e+Math.imul(_,rt)|0,e=e+Math.imul(C,G)|0,l=l+Math.imul(C,rt)|0;var Ut=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,u=Math.imul(N,U),e=Math.imul(N,X),e=e+Math.imul(K,U)|0,l=Math.imul(K,X),u=u+Math.imul(O,G)|0,e=e+Math.imul(O,rt)|0,e=e+Math.imul(R,G)|0,l=l+Math.imul(R,rt)|0,u=u+Math.imul(_,it)|0,e=e+Math.imul(_,gt)|0,e=e+Math.imul(C,it)|0,l=l+Math.imul(C,gt)|0;var jt=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(jt>>>26)|0,jt&=67108863,u=Math.imul(Z,U),e=Math.imul(Z,X),e=e+Math.imul(J,U)|0,l=Math.imul(J,X),u=u+Math.imul(N,G)|0,e=e+Math.imul(N,rt)|0,e=e+Math.imul(K,G)|0,l=l+Math.imul(K,rt)|0,u=u+Math.imul(O,it)|0,e=e+Math.imul(O,gt)|0,e=e+Math.imul(R,it)|0,l=l+Math.imul(R,gt)|0,u=u+Math.imul(_,nt)|0,e=e+Math.imul(_,bt)|0,e=e+Math.imul(C,nt)|0,l=l+Math.imul(C,bt)|0;var Qt=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Qt>>>26)|0,Qt&=67108863,u=Math.imul(tt,U),e=Math.imul(tt,X),e=e+Math.imul(vt,U)|0,l=Math.imul(vt,X),u=u+Math.imul(Z,G)|0,e=e+Math.imul(Z,rt)|0,e=e+Math.imul(J,G)|0,l=l+Math.imul(J,rt)|0,u=u+Math.imul(N,it)|0,e=e+Math.imul(N,gt)|0,e=e+Math.imul(K,it)|0,l=l+Math.imul(K,gt)|0,u=u+Math.imul(O,nt)|0,e=e+Math.imul(O,bt)|0,e=e+Math.imul(R,nt)|0,l=l+Math.imul(R,bt)|0,u=u+Math.imul(_,ft)|0,e=e+Math.imul(_,yt)|0,e=e+Math.imul(C,ft)|0,l=l+Math.imul(C,yt)|0;var te=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(te>>>26)|0,te&=67108863,u=Math.imul(et,U),e=Math.imul(et,X),e=e+Math.imul(pt,U)|0,l=Math.imul(pt,X),u=u+Math.imul(tt,G)|0,e=e+Math.imul(tt,rt)|0,e=e+Math.imul(vt,G)|0,l=l+Math.imul(vt,rt)|0,u=u+Math.imul(Z,it)|0,e=e+Math.imul(Z,gt)|0,e=e+Math.imul(J,it)|0,l=l+Math.imul(J,gt)|0,u=u+Math.imul(N,nt)|0,e=e+Math.imul(N,bt)|0,e=e+Math.imul(K,nt)|0,l=l+Math.imul(K,bt)|0,u=u+Math.imul(O,ft)|0,e=e+Math.imul(O,yt)|0,e=e+Math.imul(R,ft)|0,l=l+Math.imul(R,yt)|0,u=u+Math.imul(_,at)|0,e=e+Math.imul(_,wt)|0,e=e+Math.imul(C,at)|0,l=l+Math.imul(C,wt)|0;var ee=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ee>>>26)|0,ee&=67108863,u=Math.imul(j,U),e=Math.imul(j,X),e=e+Math.imul(dt,U)|0,l=Math.imul(dt,X),u=u+Math.imul(et,G)|0,e=e+Math.imul(et,rt)|0,e=e+Math.imul(pt,G)|0,l=l+Math.imul(pt,rt)|0,u=u+Math.imul(tt,it)|0,e=e+Math.imul(tt,gt)|0,e=e+Math.imul(vt,it)|0,l=l+Math.imul(vt,gt)|0,u=u+Math.imul(Z,nt)|0,e=e+Math.imul(Z,bt)|0,e=e+Math.imul(J,nt)|0,l=l+Math.imul(J,bt)|0,u=u+Math.imul(N,ft)|0,e=e+Math.imul(N,yt)|0,e=e+Math.imul(K,ft)|0,l=l+Math.imul(K,yt)|0,u=u+Math.imul(O,at)|0,e=e+Math.imul(O,wt)|0,e=e+Math.imul(R,at)|0,l=l+Math.imul(R,wt)|0,u=u+Math.imul(_,ht)|0,e=e+Math.imul(_,Mt)|0,e=e+Math.imul(C,ht)|0,l=l+Math.imul(C,Mt)|0;var re=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(re>>>26)|0,re&=67108863,u=Math.imul(Q,U),e=Math.imul(Q,X),e=e+Math.imul(ct,U)|0,l=Math.imul(ct,X),u=u+Math.imul(j,G)|0,e=e+Math.imul(j,rt)|0,e=e+Math.imul(dt,G)|0,l=l+Math.imul(dt,rt)|0,u=u+Math.imul(et,it)|0,e=e+Math.imul(et,gt)|0,e=e+Math.imul(pt,it)|0,l=l+Math.imul(pt,gt)|0,u=u+Math.imul(tt,nt)|0,e=e+Math.imul(tt,bt)|0,e=e+Math.imul(vt,nt)|0,l=l+Math.imul(vt,bt)|0,u=u+Math.imul(Z,ft)|0,e=e+Math.imul(Z,yt)|0,e=e+Math.imul(J,ft)|0,l=l+Math.imul(J,yt)|0,u=u+Math.imul(N,at)|0,e=e+Math.imul(N,wt)|0,e=e+Math.imul(K,at)|0,l=l+Math.imul(K,wt)|0,u=u+Math.imul(O,ht)|0,e=e+Math.imul(O,Mt)|0,e=e+Math.imul(R,ht)|0,l=l+Math.imul(R,Mt)|0,u=u+Math.imul(_,st)|0,e=e+Math.imul(_,xt)|0,e=e+Math.imul(C,st)|0,l=l+Math.imul(C,xt)|0;var ie=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ie>>>26)|0,ie&=67108863,u=Math.imul(E,U),e=Math.imul(E,X),e=e+Math.imul(w,U)|0,l=Math.imul(w,X),u=u+Math.imul(Q,G)|0,e=e+Math.imul(Q,rt)|0,e=e+Math.imul(ct,G)|0,l=l+Math.imul(ct,rt)|0,u=u+Math.imul(j,it)|0,e=e+Math.imul(j,gt)|0,e=e+Math.imul(dt,it)|0,l=l+Math.imul(dt,gt)|0,u=u+Math.imul(et,nt)|0,e=e+Math.imul(et,bt)|0,e=e+Math.imul(pt,nt)|0,l=l+Math.imul(pt,bt)|0,u=u+Math.imul(tt,ft)|0,e=e+Math.imul(tt,yt)|0,e=e+Math.imul(vt,ft)|0,l=l+Math.imul(vt,yt)|0,u=u+Math.imul(Z,at)|0,e=e+Math.imul(Z,wt)|0,e=e+Math.imul(J,at)|0,l=l+Math.imul(J,wt)|0,u=u+Math.imul(N,ht)|0,e=e+Math.imul(N,Mt)|0,e=e+Math.imul(K,ht)|0,l=l+Math.imul(K,Mt)|0,u=u+Math.imul(O,st)|0,e=e+Math.imul(O,xt)|0,e=e+Math.imul(R,st)|0,l=l+Math.imul(R,xt)|0,u=u+Math.imul(_,ot)|0,e=e+Math.imul(_,_t)|0,e=e+Math.imul(C,ot)|0,l=l+Math.imul(C,_t)|0;var ne=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ne>>>26)|0,ne&=67108863,u=Math.imul(T,U),e=Math.imul(T,X),e=e+Math.imul(F,U)|0,l=Math.imul(F,X),u=u+Math.imul(E,G)|0,e=e+Math.imul(E,rt)|0,e=e+Math.imul(w,G)|0,l=l+Math.imul(w,rt)|0,u=u+Math.imul(Q,it)|0,e=e+Math.imul(Q,gt)|0,e=e+Math.imul(ct,it)|0,l=l+Math.imul(ct,gt)|0,u=u+Math.imul(j,nt)|0,e=e+Math.imul(j,bt)|0,e=e+Math.imul(dt,nt)|0,l=l+Math.imul(dt,bt)|0,u=u+Math.imul(et,ft)|0,e=e+Math.imul(et,yt)|0,e=e+Math.imul(pt,ft)|0,l=l+Math.imul(pt,yt)|0,u=u+Math.imul(tt,at)|0,e=e+Math.imul(tt,wt)|0,e=e+Math.imul(vt,at)|0,l=l+Math.imul(vt,wt)|0,u=u+Math.imul(Z,ht)|0,e=e+Math.imul(Z,Mt)|0,e=e+Math.imul(J,ht)|0,l=l+Math.imul(J,Mt)|0,u=u+Math.imul(N,st)|0,e=e+Math.imul(N,xt)|0,e=e+Math.imul(K,st)|0,l=l+Math.imul(K,xt)|0,u=u+Math.imul(O,ot)|0,e=e+Math.imul(O,_t)|0,e=e+Math.imul(R,ot)|0,l=l+Math.imul(R,_t)|0,u=u+Math.imul(_,ut)|0,e=e+Math.imul(_,St)|0,e=e+Math.imul(C,ut)|0,l=l+Math.imul(C,St)|0;var fe=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(fe>>>26)|0,fe&=67108863,u=Math.imul(T,G),e=Math.imul(T,rt),e=e+Math.imul(F,G)|0,l=Math.imul(F,rt),u=u+Math.imul(E,it)|0,e=e+Math.imul(E,gt)|0,e=e+Math.imul(w,it)|0,l=l+Math.imul(w,gt)|0,u=u+Math.imul(Q,nt)|0,e=e+Math.imul(Q,bt)|0,e=e+Math.imul(ct,nt)|0,l=l+Math.imul(ct,bt)|0,u=u+Math.imul(j,ft)|0,e=e+Math.imul(j,yt)|0,e=e+Math.imul(dt,ft)|0,l=l+Math.imul(dt,yt)|0,u=u+Math.imul(et,at)|0,e=e+Math.imul(et,wt)|0,e=e+Math.imul(pt,at)|0,l=l+Math.imul(pt,wt)|0,u=u+Math.imul(tt,ht)|0,e=e+Math.imul(tt,Mt)|0,e=e+Math.imul(vt,ht)|0,l=l+Math.imul(vt,Mt)|0,u=u+Math.imul(Z,st)|0,e=e+Math.imul(Z,xt)|0,e=e+Math.imul(J,st)|0,l=l+Math.imul(J,xt)|0,u=u+Math.imul(N,ot)|0,e=e+Math.imul(N,_t)|0,e=e+Math.imul(K,ot)|0,l=l+Math.imul(K,_t)|0,u=u+Math.imul(O,ut)|0,e=e+Math.imul(O,St)|0,e=e+Math.imul(R,ut)|0,l=l+Math.imul(R,St)|0;var ae=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ae>>>26)|0,ae&=67108863,u=Math.imul(T,it),e=Math.imul(T,gt),e=e+Math.imul(F,it)|0,l=Math.imul(F,gt),u=u+Math.imul(E,nt)|0,e=e+Math.imul(E,bt)|0,e=e+Math.imul(w,nt)|0,l=l+Math.imul(w,bt)|0,u=u+Math.imul(Q,ft)|0,e=e+Math.imul(Q,yt)|0,e=e+Math.imul(ct,ft)|0,l=l+Math.imul(ct,yt)|0,u=u+Math.imul(j,at)|0,e=e+Math.imul(j,wt)|0,e=e+Math.imul(dt,at)|0,l=l+Math.imul(dt,wt)|0,u=u+Math.imul(et,ht)|0,e=e+Math.imul(et,Mt)|0,e=e+Math.imul(pt,ht)|0,l=l+Math.imul(pt,Mt)|0,u=u+Math.imul(tt,st)|0,e=e+Math.imul(tt,xt)|0,e=e+Math.imul(vt,st)|0,l=l+Math.imul(vt,xt)|0,u=u+Math.imul(Z,ot)|0,e=e+Math.imul(Z,_t)|0,e=e+Math.imul(J,ot)|0,l=l+Math.imul(J,_t)|0,u=u+Math.imul(N,ut)|0,e=e+Math.imul(N,St)|0,e=e+Math.imul(K,ut)|0,l=l+Math.imul(K,St)|0;var he=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(he>>>26)|0,he&=67108863,u=Math.imul(T,nt),e=Math.imul(T,bt),e=e+Math.imul(F,nt)|0,l=Math.imul(F,bt),u=u+Math.imul(E,ft)|0,e=e+Math.imul(E,yt)|0,e=e+Math.imul(w,ft)|0,l=l+Math.imul(w,yt)|0,u=u+Math.imul(Q,at)|0,e=e+Math.imul(Q,wt)|0,e=e+Math.imul(ct,at)|0,l=l+Math.imul(ct,wt)|0,u=u+Math.imul(j,ht)|0,e=e+Math.imul(j,Mt)|0,e=e+Math.imul(dt,ht)|0,l=l+Math.imul(dt,Mt)|0,u=u+Math.imul(et,st)|0,e=e+Math.imul(et,xt)|0,e=e+Math.imul(pt,st)|0,l=l+Math.imul(pt,xt)|0,u=u+Math.imul(tt,ot)|0,e=e+Math.imul(tt,_t)|0,e=e+Math.imul(vt,ot)|0,l=l+Math.imul(vt,_t)|0,u=u+Math.imul(Z,ut)|0,e=e+Math.imul(Z,St)|0,e=e+Math.imul(J,ut)|0,l=l+Math.imul(J,St)|0;var se=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(se>>>26)|0,se&=67108863,u=Math.imul(T,ft),e=Math.imul(T,yt),e=e+Math.imul(F,ft)|0,l=Math.imul(F,yt),u=u+Math.imul(E,at)|0,e=e+Math.imul(E,wt)|0,e=e+Math.imul(w,at)|0,l=l+Math.imul(w,wt)|0,u=u+Math.imul(Q,ht)|0,e=e+Math.imul(Q,Mt)|0,e=e+Math.imul(ct,ht)|0,l=l+Math.imul(ct,Mt)|0,u=u+Math.imul(j,st)|0,e=e+Math.imul(j,xt)|0,e=e+Math.imul(dt,st)|0,l=l+Math.imul(dt,xt)|0,u=u+Math.imul(et,ot)|0,e=e+Math.imul(et,_t)|0,e=e+Math.imul(pt,ot)|0,l=l+Math.imul(pt,_t)|0,u=u+Math.imul(tt,ut)|0,e=e+Math.imul(tt,St)|0,e=e+Math.imul(vt,ut)|0,l=l+Math.imul(vt,St)|0;var oe=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(oe>>>26)|0,oe&=67108863,u=Math.imul(T,at),e=Math.imul(T,wt),e=e+Math.imul(F,at)|0,l=Math.imul(F,wt),u=u+Math.imul(E,ht)|0,e=e+Math.imul(E,Mt)|0,e=e+Math.imul(w,ht)|0,l=l+Math.imul(w,Mt)|0,u=u+Math.imul(Q,st)|0,e=e+Math.imul(Q,xt)|0,e=e+Math.imul(ct,st)|0,l=l+Math.imul(ct,xt)|0,u=u+Math.imul(j,ot)|0,e=e+Math.imul(j,_t)|0,e=e+Math.imul(dt,ot)|0,l=l+Math.imul(dt,_t)|0,u=u+Math.imul(et,ut)|0,e=e+Math.imul(et,St)|0,e=e+Math.imul(pt,ut)|0,l=l+Math.imul(pt,St)|0;var ue=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ue>>>26)|0,ue&=67108863,u=Math.imul(T,ht),e=Math.imul(T,Mt),e=e+Math.imul(F,ht)|0,l=Math.imul(F,Mt),u=u+Math.imul(E,st)|0,e=e+Math.imul(E,xt)|0,e=e+Math.imul(w,st)|0,l=l+Math.imul(w,xt)|0,u=u+Math.imul(Q,ot)|0,e=e+Math.imul(Q,_t)|0,e=e+Math.imul(ct,ot)|0,l=l+Math.imul(ct,_t)|0,u=u+Math.imul(j,ut)|0,e=e+Math.imul(j,St)|0,e=e+Math.imul(dt,ut)|0,l=l+Math.imul(dt,St)|0;var le=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(le>>>26)|0,le&=67108863,u=Math.imul(T,st),e=Math.imul(T,xt),e=e+Math.imul(F,st)|0,l=Math.imul(F,xt),u=u+Math.imul(E,ot)|0,e=e+Math.imul(E,_t)|0,e=e+Math.imul(w,ot)|0,l=l+Math.imul(w,_t)|0,u=u+Math.imul(Q,ut)|0,e=e+Math.imul(Q,St)|0,e=e+Math.imul(ct,ut)|0,l=l+Math.imul(ct,St)|0;var de=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(de>>>26)|0,de&=67108863,u=Math.imul(T,ot),e=Math.imul(T,_t),e=e+Math.imul(F,ot)|0,l=Math.imul(F,_t),u=u+Math.imul(E,ut)|0,e=e+Math.imul(E,St)|0,e=e+Math.imul(w,ut)|0,l=l+Math.imul(w,St)|0;var ce=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ce>>>26)|0,ce&=67108863,u=Math.imul(T,ut),e=Math.imul(T,St),e=e+Math.imul(F,ut)|0,l=Math.imul(F,St);var ve=(v+u|0)+((e&8191)<<13)|0;return v=(l+(e>>>13)|0)+(ve>>>26)|0,ve&=67108863,c[0]=$t,c[1]=Ut,c[2]=jt,c[3]=Qt,c[4]=te,c[5]=ee,c[6]=re,c[7]=ie,c[8]=ne,c[9]=fe,c[10]=ae,c[11]=he,c[12]=se,c[13]=oe,c[14]=ue,c[15]=le,c[16]=de,c[17]=ce,c[18]=ve,v!==0&&(c[19]=v,i.length++),i};Math.imul||(L=D);function W(p,t,r){r.negative=t.negative^p.negative,r.length=p.length+t.length;for(var i=0,a=0,d=0;d<r.length-1;d++){var c=a;a=0;for(var v=i&67108863,u=Math.min(d,t.length-1),e=Math.max(0,d-p.length+1);e<=u;e++){var l=d-e,b=p.words[l]|0,_=t.words[e]|0,C=b*_,q=C&67108863;c=c+(C/67108864|0)|0,q=q+v|0,v=q&67108863,c=c+(q>>>26)|0,a+=c>>>26,c&=67108863}r.words[d]=v,i=c,c=a}return i!==0?r.words[d]=i:r.length--,r.strip()}function z(p,t,r){var i=new $;return i.mulp(p,t,r)}f.prototype.mulTo=function(t,r){var i,a=this.length+t.length;return this.length===10&&t.length===10?i=L(this,t,r):a<63?i=D(this,t,r):a<1024?i=W(this,t,r):i=z(this,t,r),i};function $(p,t){this.x=p,this.y=t}$.prototype.makeRBT=function(t){for(var r=new Array(t),i=f.prototype._countBits(t)-1,a=0;a<t;a++)r[a]=this.revBin(a,i,t);return r},$.prototype.revBin=function(t,r,i){if(t===0||t===i-1)return t;for(var a=0,d=0;d<r;d++)a|=(t&1)<<r-d-1,t>>=1;return a},$.prototype.permute=function(t,r,i,a,d,c){for(var v=0;v<c;v++)a[v]=r[t[v]],d[v]=i[t[v]]},$.prototype.transform=function(t,r,i,a,d,c){this.permute(c,t,r,i,a,d);for(var v=1;v<d;v<<=1)for(var u=v<<1,e=Math.cos(2*Math.PI/u),l=Math.sin(2*Math.PI/u),b=0;b<d;b+=u)for(var _=e,C=l,q=0;q<v;q++){var O=i[b+q],R=a[b+q],P=i[b+q+v],N=a[b+q+v],K=_*P-C*N;N=_*N+C*P,P=K,i[b+q]=O+P,a[b+q]=R+N,i[b+q+v]=O-P,a[b+q+v]=R-N,q!==u&&(K=e*_-l*C,C=e*C+l*_,_=K)}},$.prototype.guessLen13b=function(t,r){var i=Math.max(r,t)|1,a=i&1,d=0;for(i=i/2|0;i;i=i>>>1)d++;return 1<<d+1+a},$.prototype.conjugate=function(t,r,i){if(!(i<=1))for(var a=0;a<i/2;a++){var d=t[a];t[a]=t[i-a-1],t[i-a-1]=d,d=r[a],r[a]=-r[i-a-1],r[i-a-1]=-d}},$.prototype.normalize13b=function(t,r){for(var i=0,a=0;a<r/2;a++){var d=Math.round(t[2*a+1]/r)*8192+Math.round(t[2*a]/r)+i;t[a]=d&67108863,d<67108864?i=0:i=d/67108864|0}return t},$.prototype.convert13b=function(t,r,i,a){for(var d=0,c=0;c<r;c++)d=d+(t[c]|0),i[2*c]=d&8191,d=d>>>13,i[2*c+1]=d&8191,d=d>>>13;for(c=2*r;c<a;++c)i[c]=0;s(d===0),s((d&-8192)===0)},$.prototype.stub=function(t){for(var r=new Array(t),i=0;i<t;i++)r[i]=0;return r},$.prototype.mulp=function(t,r,i){var a=2*this.guessLen13b(t.length,r.length),d=this.makeRBT(a),c=this.stub(a),v=new Array(a),u=new Array(a),e=new Array(a),l=new Array(a),b=new Array(a),_=new Array(a),C=i.words;C.length=a,this.convert13b(t.words,t.length,v,a),this.convert13b(r.words,r.length,l,a),this.transform(v,c,u,e,a,d),this.transform(l,c,b,_,a,d);for(var q=0;q<a;q++){var O=u[q]*b[q]-e[q]*_[q];e[q]=u[q]*_[q]+e[q]*b[q],u[q]=O}return this.conjugate(u,e,a),this.transform(u,e,C,c,a,d),this.conjugate(C,c,a),this.normalize13b(C,a),i.negative=t.negative^r.negative,i.length=t.length+r.length,i.strip()},f.prototype.mul=function(t){var r=new f(null);return r.words=new Array(this.length+t.length),this.mulTo(t,r)},f.prototype.mulf=function(t){var r=new f(null);return r.words=new Array(this.length+t.length),z(this,t,r)},f.prototype.imul=function(t){return this.clone().mulTo(t,this)},f.prototype.imuln=function(t){s(typeof t=="number"),s(t<67108864);for(var r=0,i=0;i<this.length;i++){var a=(this.words[i]|0)*t,d=(a&67108863)+(r&67108863);r>>=26,r+=a/67108864|0,r+=d>>>26,this.words[i]=d&67108863}return r!==0&&(this.words[i]=r,this.length++),this.length=t===0?1:this.length,this},f.prototype.muln=function(t){return this.clone().imuln(t)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(t){var r=k(t);if(r.length===0)return new f(1);for(var i=this,a=0;a<r.length&&r[a]===0;a++,i=i.sqr());if(++a<r.length)for(var d=i.sqr();a<r.length;a++,d=d.sqr())r[a]!==0&&(i=i.mul(d));return i},f.prototype.iushln=function(t){s(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26,a=67108863>>>26-r<<26-r,d;if(r!==0){var c=0;for(d=0;d<this.length;d++){var v=this.words[d]&a,u=(this.words[d]|0)-v<<r;this.words[d]=u|c,c=v>>>26-r}c&&(this.words[d]=c,this.length++)}if(i!==0){for(d=this.length-1;d>=0;d--)this.words[d+i]=this.words[d];for(d=0;d<i;d++)this.words[d]=0;this.length+=i}return this.strip()},f.prototype.ishln=function(t){return s(this.negative===0),this.iushln(t)},f.prototype.iushrn=function(t,r,i){s(typeof t=="number"&&t>=0);var a;r?a=(r-r%26)/26:a=0;var d=t%26,c=Math.min((t-d)/26,this.length),v=67108863^67108863>>>d<<d,u=i;if(a-=c,a=Math.max(0,a),u){for(var e=0;e<c;e++)u.words[e]=this.words[e];u.length=c}if(c!==0)if(this.length>c)for(this.length-=c,e=0;e<this.length;e++)this.words[e]=this.words[e+c];else this.words[0]=0,this.length=1;var l=0;for(e=this.length-1;e>=0&&(l!==0||e>=a);e--){var b=this.words[e]|0;this.words[e]=l<<26-d|b>>>d,l=b&v}return u&&l!==0&&(u.words[u.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},f.prototype.ishrn=function(t,r,i){return s(this.negative===0),this.iushrn(t,r,i)},f.prototype.shln=function(t){return this.clone().ishln(t)},f.prototype.ushln=function(t){return this.clone().iushln(t)},f.prototype.shrn=function(t){return this.clone().ishrn(t)},f.prototype.ushrn=function(t){return this.clone().iushrn(t)},f.prototype.testn=function(t){s(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26,a=1<<r;if(this.length<=i)return!1;var d=this.words[i];return!!(d&a)},f.prototype.imaskn=function(t){s(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26;if(s(this.negative===0,"imaskn works only with positive numbers"),this.length<=i)return this;if(r!==0&&i++,this.length=Math.min(i,this.length),r!==0){var a=67108863^67108863>>>r<<r;this.words[this.length-1]&=a}return this.strip()},f.prototype.maskn=function(t){return this.clone().imaskn(t)},f.prototype.iaddn=function(t){return s(typeof t=="number"),s(t<67108864),t<0?this.isubn(-t):this.negative!==0?this.length===1&&(this.words[0]|0)<t?(this.words[0]=t-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},f.prototype._iaddn=function(t){this.words[0]+=t;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},f.prototype.isubn=function(t){if(s(typeof t=="number"),s(t<67108864),t<0)return this.iaddn(-t);if(this.negative!==0)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this.strip()},f.prototype.addn=function(t){return this.clone().iaddn(t)},f.prototype.subn=function(t){return this.clone().isubn(t)},f.prototype.iabs=function(){return this.negative=0,this},f.prototype.abs=function(){return this.clone().iabs()},f.prototype._ishlnsubmul=function(t,r,i){var a=t.length+i,d;this._expand(a);var c,v=0;for(d=0;d<t.length;d++){c=(this.words[d+i]|0)+v;var u=(t.words[d]|0)*r;c-=u&67108863,v=(c>>26)-(u/67108864|0),this.words[d+i]=c&67108863}for(;d<this.length-i;d++)c=(this.words[d+i]|0)+v,v=c>>26,this.words[d+i]=c&67108863;if(v===0)return this.strip();for(s(v===-1),v=0,d=0;d<this.length;d++)c=-(this.words[d]|0)+v,v=c>>26,this.words[d]=c&67108863;return this.negative=1,this.strip()},f.prototype._wordDiv=function(t,r){var i=this.length-t.length,a=this.clone(),d=t,c=d.words[d.length-1]|0,v=this._countBits(c);i=26-v,i!==0&&(d=d.ushln(i),a.iushln(i),c=d.words[d.length-1]|0);var u=a.length-d.length,e;if(r!=="mod"){e=new f(null),e.length=u+1,e.words=new Array(e.length);for(var l=0;l<e.length;l++)e.words[l]=0}var b=a.clone()._ishlnsubmul(d,1,u);b.negative===0&&(a=b,e&&(e.words[u]=1));for(var _=u-1;_>=0;_--){var C=(a.words[d.length+_]|0)*67108864+(a.words[d.length+_-1]|0);for(C=Math.min(C/c|0,67108863),a._ishlnsubmul(d,C,_);a.negative!==0;)C--,a.negative=0,a._ishlnsubmul(d,1,_),a.isZero()||(a.negative^=1);e&&(e.words[_]=C)}return e&&e.strip(),a.strip(),r!=="div"&&i!==0&&a.iushrn(i),{div:e||null,mod:a}},f.prototype.divmod=function(t,r,i){if(s(!t.isZero()),this.isZero())return{div:new f(0),mod:new f(0)};var a,d,c;return this.negative!==0&&t.negative===0?(c=this.neg().divmod(t,r),r!=="mod"&&(a=c.div.neg()),r!=="div"&&(d=c.mod.neg(),i&&d.negative!==0&&d.iadd(t)),{div:a,mod:d}):this.negative===0&&t.negative!==0?(c=this.divmod(t.neg(),r),r!=="mod"&&(a=c.div.neg()),{div:a,mod:c.mod}):this.negative&t.negative?(c=this.neg().divmod(t.neg(),r),r!=="div"&&(d=c.mod.neg(),i&&d.negative!==0&&d.isub(t)),{div:c.div,mod:d}):t.length>this.length||this.cmp(t)<0?{div:new f(0),mod:this}:t.length===1?r==="div"?{div:this.divn(t.words[0]),mod:null}:r==="mod"?{div:null,mod:new f(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new f(this.modn(t.words[0]))}:this._wordDiv(t,r)},f.prototype.div=function(t){return this.divmod(t,"div",!1).div},f.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},f.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},f.prototype.divRound=function(t){var r=this.divmod(t);if(r.mod.isZero())return r.div;var i=r.div.negative!==0?r.mod.isub(t):r.mod,a=t.ushrn(1),d=t.andln(1),c=i.cmp(a);return c<0||d===1&&c===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},f.prototype.modn=function(t){s(t<=67108863);for(var r=(1<<26)%t,i=0,a=this.length-1;a>=0;a--)i=(r*i+(this.words[a]|0))%t;return i},f.prototype.idivn=function(t){s(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var a=(this.words[i]|0)+r*67108864;this.words[i]=a/t|0,r=a%t}return this.strip()},f.prototype.divn=function(t){return this.clone().idivn(t)},f.prototype.egcd=function(t){s(t.negative===0),s(!t.isZero());var r=this,i=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var a=new f(1),d=new f(0),c=new f(0),v=new f(1),u=0;r.isEven()&&i.isEven();)r.iushrn(1),i.iushrn(1),++u;for(var e=i.clone(),l=r.clone();!r.isZero();){for(var b=0,_=1;!(r.words[0]&_)&&b<26;++b,_<<=1);if(b>0)for(r.iushrn(b);b-- >0;)(a.isOdd()||d.isOdd())&&(a.iadd(e),d.isub(l)),a.iushrn(1),d.iushrn(1);for(var C=0,q=1;!(i.words[0]&q)&&C<26;++C,q<<=1);if(C>0)for(i.iushrn(C);C-- >0;)(c.isOdd()||v.isOdd())&&(c.iadd(e),v.isub(l)),c.iushrn(1),v.iushrn(1);r.cmp(i)>=0?(r.isub(i),a.isub(c),d.isub(v)):(i.isub(r),c.isub(a),v.isub(d))}return{a:c,b:v,gcd:i.iushln(u)}},f.prototype._invmp=function(t){s(t.negative===0),s(!t.isZero());var r=this,i=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var a=new f(1),d=new f(0),c=i.clone();r.cmpn(1)>0&&i.cmpn(1)>0;){for(var v=0,u=1;!(r.words[0]&u)&&v<26;++v,u<<=1);if(v>0)for(r.iushrn(v);v-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);for(var e=0,l=1;!(i.words[0]&l)&&e<26;++e,l<<=1);if(e>0)for(i.iushrn(e);e-- >0;)d.isOdd()&&d.iadd(c),d.iushrn(1);r.cmp(i)>=0?(r.isub(i),a.isub(d)):(i.isub(r),d.isub(a))}var b;return r.cmpn(1)===0?b=a:b=d,b.cmpn(0)<0&&b.iadd(t),b},f.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var r=this.clone(),i=t.clone();r.negative=0,i.negative=0;for(var a=0;r.isEven()&&i.isEven();a++)r.iushrn(1),i.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;i.isEven();)i.iushrn(1);var d=r.cmp(i);if(d<0){var c=r;r=i,i=c}else if(d===0||i.cmpn(1)===0)break;r.isub(i)}while(!0);return i.iushln(a)},f.prototype.invm=function(t){return this.egcd(t).a.umod(t)},f.prototype.isEven=function(){return(this.words[0]&1)===0},f.prototype.isOdd=function(){return(this.words[0]&1)===1},f.prototype.andln=function(t){return this.words[0]&t},f.prototype.bincn=function(t){s(typeof t=="number");var r=t%26,i=(t-r)/26,a=1<<r;if(this.length<=i)return this._expand(i+1),this.words[i]|=a,this;for(var d=a,c=i;d!==0&&c<this.length;c++){var v=this.words[c]|0;v+=d,d=v>>>26,v&=67108863,this.words[c]=v}return d!==0&&(this.words[c]=d,this.length++),this},f.prototype.isZero=function(){return this.length===1&&this.words[0]===0},f.prototype.cmpn=function(t){var r=t<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this.strip();var i;if(this.length>1)i=1;else{r&&(t=-t),s(t<=67108863,"Number is too big");var a=this.words[0]|0;i=a===t?0:a<t?-1:1}return this.negative!==0?-i|0:i},f.prototype.cmp=function(t){if(this.negative!==0&&t.negative===0)return-1;if(this.negative===0&&t.negative!==0)return 1;var r=this.ucmp(t);return this.negative!==0?-r|0:r},f.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var r=0,i=this.length-1;i>=0;i--){var a=this.words[i]|0,d=t.words[i]|0;if(a!==d){a<d?r=-1:a>d&&(r=1);break}}return r},f.prototype.gtn=function(t){return this.cmpn(t)===1},f.prototype.gt=function(t){return this.cmp(t)===1},f.prototype.gten=function(t){return this.cmpn(t)>=0},f.prototype.gte=function(t){return this.cmp(t)>=0},f.prototype.ltn=function(t){return this.cmpn(t)===-1},f.prototype.lt=function(t){return this.cmp(t)===-1},f.prototype.lten=function(t){return this.cmpn(t)<=0},f.prototype.lte=function(t){return this.cmp(t)<=0},f.prototype.eqn=function(t){return this.cmpn(t)===0},f.prototype.eq=function(t){return this.cmp(t)===0},f.red=function(t){return new Y(t)},f.prototype.toRed=function(t){return s(!this.red,"Already a number in reduction context"),s(this.negative===0,"red works only with positives"),t.convertTo(this)._forceRed(t)},f.prototype.fromRed=function(){return s(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},f.prototype._forceRed=function(t){return this.red=t,this},f.prototype.forceRed=function(t){return s(!this.red,"Already a number in reduction context"),this._forceRed(t)},f.prototype.redAdd=function(t){return s(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},f.prototype.redIAdd=function(t){return s(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},f.prototype.redSub=function(t){return s(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},f.prototype.redISub=function(t){return s(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},f.prototype.redShl=function(t){return s(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},f.prototype.redMul=function(t){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},f.prototype.redIMul=function(t){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},f.prototype.redSqr=function(){return s(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},f.prototype.redISqr=function(){return s(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},f.prototype.redSqrt=function(){return s(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},f.prototype.redInvm=function(){return s(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},f.prototype.redNeg=function(){return s(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},f.prototype.redPow=function(t){return s(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var lt={k256:null,p224:null,p192:null,p25519:null};function H(p,t){this.name=p,this.p=new f(t,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var t=new f(null);return t.words=new Array(Math.ceil(this.n/13)),t},H.prototype.ireduce=function(t){var r=t,i;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),i=r.bitLength();while(i>this.n);var a=i<this.n?-1:r.ucmp(this.p);return a===0?(r.words[0]=0,r.length=1):a>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},H.prototype.split=function(t,r){t.iushrn(this.n,0,r)},H.prototype.imulK=function(t){return t.imul(this.k)};function At(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}m(At,H),At.prototype.split=function(t,r){for(var i=4194303,a=Math.min(t.length,9),d=0;d<a;d++)r.words[d]=t.words[d];if(r.length=a,t.length<=9){t.words[0]=0,t.length=1;return}var c=t.words[9];for(r.words[r.length++]=c&i,d=10;d<t.length;d++){var v=t.words[d]|0;t.words[d-10]=(v&i)<<4|c>>>22,c=v}c>>>=22,t.words[d-10]=c,c===0&&t.length>10?t.length-=10:t.length-=9},At.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var r=0,i=0;i<t.length;i++){var a=t.words[i]|0;r+=a*977,t.words[i]=r&67108863,r=a*64+(r/67108864|0)}return t.words[t.length-1]===0&&(t.length--,t.words[t.length-1]===0&&t.length--),t};function Bt(){H.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}m(Bt,H);function Ct(){H.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}m(Ct,H);function Et(){H.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}m(Et,H),Et.prototype.imulK=function(t){for(var r=0,i=0;i<t.length;i++){var a=(t.words[i]|0)*19+r,d=a&67108863;a>>>=26,t.words[i]=d,r=a}return r!==0&&(t.words[t.length++]=r),t},f._prime=function(t){if(lt[t])return lt[t];var r;if(t==="k256")r=new At;else if(t==="p224")r=new Bt;else if(t==="p192")r=new Ct;else if(t==="p25519")r=new Et;else throw new Error("Unknown prime "+t);return lt[t]=r,r};function Y(p){if(typeof p=="string"){var t=f._prime(p);this.m=t.p,this.prime=t}else s(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}Y.prototype._verify1=function(t){s(t.negative===0,"red works only with positives"),s(t.red,"red works only with red numbers")},Y.prototype._verify2=function(t,r){s((t.negative|r.negative)===0,"red works only with positives"),s(t.red&&t.red===r.red,"red works only with red numbers")},Y.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},Y.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},Y.prototype.add=function(t,r){this._verify2(t,r);var i=t.add(r);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},Y.prototype.iadd=function(t,r){this._verify2(t,r);var i=t.iadd(r);return i.cmp(this.m)>=0&&i.isub(this.m),i},Y.prototype.sub=function(t,r){this._verify2(t,r);var i=t.sub(r);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},Y.prototype.isub=function(t,r){this._verify2(t,r);var i=t.isub(r);return i.cmpn(0)<0&&i.iadd(this.m),i},Y.prototype.shl=function(t,r){return this._verify1(t),this.imod(t.ushln(r))},Y.prototype.imul=function(t,r){return this._verify2(t,r),this.imod(t.imul(r))},Y.prototype.mul=function(t,r){return this._verify2(t,r),this.imod(t.mul(r))},Y.prototype.isqr=function(t){return this.imul(t,t.clone())},Y.prototype.sqr=function(t){return this.mul(t,t)},Y.prototype.sqrt=function(t){if(t.isZero())return t.clone();var r=this.m.andln(3);if(s(r%2===1),r===3){var i=this.m.add(new f(1)).iushrn(2);return this.pow(t,i)}for(var a=this.m.subn(1),d=0;!a.isZero()&&a.andln(1)===0;)d++,a.iushrn(1);s(!a.isZero());var c=new f(1).toRed(this),v=c.redNeg(),u=this.m.subn(1).iushrn(1),e=this.m.bitLength();for(e=new f(2*e*e).toRed(this);this.pow(e,u).cmp(v)!==0;)e.redIAdd(v);for(var l=this.pow(e,a),b=this.pow(t,a.addn(1).iushrn(1)),_=this.pow(t,a),C=d;_.cmp(c)!==0;){for(var q=_,O=0;q.cmp(c)!==0;O++)q=q.redSqr();s(O<C);var R=this.pow(l,new f(1).iushln(C-O-1));b=b.redMul(R),l=R.redSqr(),_=_.redMul(l),C=O}return b},Y.prototype.invm=function(t){var r=t._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},Y.prototype.pow=function(t,r){if(r.isZero())return new f(1).toRed(this);if(r.cmpn(1)===0)return t.clone();var i=4,a=new Array(1<<i);a[0]=new f(1).toRed(this),a[1]=t;for(var d=2;d<a.length;d++)a[d]=this.mul(a[d-1],t);var c=a[0],v=0,u=0,e=r.bitLength()%26;for(e===0&&(e=26),d=r.length-1;d>=0;d--){for(var l=r.words[d],b=e-1;b>=0;b--){var _=l>>b&1;if(c!==a[0]&&(c=this.sqr(c)),_===0&&v===0){u=0;continue}v<<=1,v|=_,u++,!(u!==i&&(d!==0||b!==0))&&(c=this.mul(c,a[v]),u=0,v=0)}e=26}return c},Y.prototype.convertTo=function(t){var r=t.umod(this.m);return r===t?r.clone():r},Y.prototype.convertFrom=function(t){var r=t.clone();return r.red=null,r},f.mont=function(t){return new It(t)};function It(p){Y.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new f(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m(It,Y),It.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},It.prototype.convertFrom=function(t){var r=this.imod(t.mul(this.rinv));return r.red=null,r},It.prototype.imul=function(t,r){if(t.isZero()||r.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(r),a=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=i.isub(a).iushrn(this.shift),c=d;return d.cmp(this.m)>=0?c=d.isub(this.m):d.cmpn(0)<0&&(c=d.iadd(this.m)),c._forceRed(this)},It.prototype.mul=function(t,r){if(t.isZero()||r.isZero())return new f(0)._forceRed(this);var i=t.mul(r),a=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=i.isub(a).iushrn(this.shift),c=d;return d.cmp(this.m)>=0?c=d.isub(this.m):d.cmpn(0)<0&&(c=d.iadd(this.m)),c._forceRed(this)},It.prototype.invm=function(t){var r=this.imod(t._invmp(this.m).mul(this.r2));return r._forceRed(this)}})(h,Ft)}(W0);var Vm=W0.exports,V0,Co;function Ym(){if(Co)return V0;Co=1;var h=k0(),n=Vm;V0=function(g){return new s(g)};var o={secp256k1:{name:"secp256k1",byteLength:32},secp224r1:{name:"p224",byteLength:28},prime256v1:{name:"p256",byteLength:32},prime192v1:{name:"p192",byteLength:24},ed25519:{name:"ed25519",byteLength:32},secp384r1:{name:"p384",byteLength:48},secp521r1:{name:"p521",byteLength:66}};o.p224=o.secp224r1,o.p256=o.secp256r1=o.prime256v1,o.p192=o.secp192r1=o.prime192v1,o.p384=o.secp384r1,o.p521=o.secp521r1;function s(f){this.curveType=o[f],this.curveType||(this.curveType={name:f}),this.curve=new h.ec(this.curveType.name),this.keys=void 0}s.prototype.generateKeys=function(f,g){return this.keys=this.curve.genKeyPair(),this.getPublicKey(f,g)},s.prototype.computeSecret=function(f,g,y){g=g||"utf8",mt.isBuffer(f)||(f=new mt(f,g));var S=this.curve.keyFromPublic(f).getPublic(),B=S.mul(this.keys.getPrivate()).getX();return m(B,y,this.curveType.byteLength)},s.prototype.getPublicKey=function(f,g){var y=this.keys.getPublic(g==="compressed",!0);return g==="hybrid"&&(y[y.length-1]%2?y[0]=7:y[0]=6),m(y,f)},s.prototype.getPrivateKey=function(f){return m(this.keys.getPrivate(),f)},s.prototype.setPublicKey=function(f,g){return g=g||"utf8",mt.isBuffer(f)||(f=new mt(f,g)),this.keys._importPublic(f),this},s.prototype.setPrivateKey=function(f,g){g=g||"utf8",mt.isBuffer(f)||(f=new mt(f,g));var y=new n(f);return y=y.toString(16),this.keys=this.curve.genKeyPair(),this.keys._importPrivate(y),this};function m(f,g,y){Array.isArray(f)||(f=f.toArray());var S=new mt(f);if(y&&S.length<y){var B=new mt(y-S.length);B.fill(0),S=mt.concat([B,S])}return g?S.toString(g):S}return V0}var Fo={},Jm=Ki,Y0=zt.Buffer,qo=function(h,n){for(var o=Y0.alloc(0),s=0,m;o.length<n;)m=Gm(s++),o=Y0.concat([o,Jm("sha1").update(h).update(m).digest()]);return o.slice(0,n)};function Gm(h){var n=Y0.allocUnsafe(4);return n.writeUInt32BE(h,0),n}var Po=function(n,o){for(var s=n.length,m=-1;++m<s;)n[m]^=o[m];return n},J0={exports:{}};J0.exports,function(h){(function(n,o){function s(p,t){if(!p)throw new Error(t||"Assertion failed")}function m(p,t){p.super_=t;var r=function(){};r.prototype=t.prototype,p.prototype=new r,p.prototype.constructor=p}function f(p,t,r){if(f.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((t==="le"||t==="be")&&(r=t,t=10),this._init(p||0,t||10,r||"be"))}typeof n=="object"?n.exports=f:o.BN=f,f.BN=f,f.wordSize=26;var g;try{typeof window!="undefined"&&typeof window.Buffer!="undefined"?g=window.Buffer:g=Ne.Buffer}catch(p){}f.isBN=function(t){return t instanceof f?!0:t!==null&&typeof t=="object"&&t.constructor.wordSize===f.wordSize&&Array.isArray(t.words)},f.max=function(t,r){return t.cmp(r)>0?t:r},f.min=function(t,r){return t.cmp(r)<0?t:r},f.prototype._init=function(t,r,i){if(typeof t=="number")return this._initNumber(t,r,i);if(typeof t=="object")return this._initArray(t,r,i);r==="hex"&&(r=16),s(r===(r|0)&&r>=2&&r<=36),t=t.toString().replace(/\s+/g,"");var a=0;t[0]==="-"&&(a++,this.negative=1),a<t.length&&(r===16?this._parseHex(t,a,i):(this._parseBase(t,r,a),i==="le"&&this._initArray(this.toArray(),r,i)))},f.prototype._initNumber=function(t,r,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[t&67108863],this.length=1):t<4503599627370496?(this.words=[t&67108863,t/67108864&67108863],this.length=2):(s(t<9007199254740992),this.words=[t&67108863,t/67108864&67108863,1],this.length=3),i==="le"&&this._initArray(this.toArray(),r,i)},f.prototype._initArray=function(t,r,i){if(s(typeof t.length=="number"),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var a=0;a<this.length;a++)this.words[a]=0;var d,c,v=0;if(i==="be")for(a=t.length-1,d=0;a>=0;a-=3)c=t[a]|t[a-1]<<8|t[a-2]<<16,this.words[d]|=c<<v&67108863,this.words[d+1]=c>>>26-v&67108863,v+=24,v>=26&&(v-=26,d++);else if(i==="le")for(a=0,d=0;a<t.length;a+=3)c=t[a]|t[a+1]<<8|t[a+2]<<16,this.words[d]|=c<<v&67108863,this.words[d+1]=c>>>26-v&67108863,v+=24,v>=26&&(v-=26,d++);return this.strip()};function y(p,t){var r=p.charCodeAt(t);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function S(p,t,r){var i=y(p,r);return r-1>=t&&(i|=y(p,r-1)<<4),i}f.prototype._parseHex=function(t,r,i){this.length=Math.ceil((t.length-r)/6),this.words=new Array(this.length);for(var a=0;a<this.length;a++)this.words[a]=0;var d=0,c=0,v;if(i==="be")for(a=t.length-1;a>=r;a-=2)v=S(t,r,a)<<d,this.words[c]|=v&67108863,d>=18?(d-=18,c+=1,this.words[c]|=v>>>26):d+=8;else{var u=t.length-r;for(a=u%2===0?r+1:r;a<t.length;a+=2)v=S(t,r,a)<<d,this.words[c]|=v&67108863,d>=18?(d-=18,c+=1,this.words[c]|=v>>>26):d+=8}this.strip()};function B(p,t,r,i){for(var a=0,d=Math.min(p.length,r),c=t;c<d;c++){var v=p.charCodeAt(c)-48;a*=i,v>=49?a+=v-49+10:v>=17?a+=v-17+10:a+=v}return a}f.prototype._parseBase=function(t,r,i){this.words=[0],this.length=1;for(var a=0,d=1;d<=67108863;d*=r)a++;a--,d=d/r|0;for(var c=t.length-i,v=c%a,u=Math.min(c,c-v)+i,e=0,l=i;l<u;l+=a)e=B(t,l,l+a,r),this.imuln(d),this.words[0]+e<67108864?this.words[0]+=e:this._iaddn(e);if(v!==0){var b=1;for(e=B(t,l,t.length,r),l=0;l<v;l++)b*=r;this.imuln(b),this.words[0]+e<67108864?this.words[0]+=e:this._iaddn(e)}this.strip()},f.prototype.copy=function(t){t.words=new Array(this.length);for(var r=0;r<this.length;r++)t.words[r]=this.words[r];t.length=this.length,t.negative=this.negative,t.red=this.red},f.prototype.clone=function(){var t=new f(null);return this.copy(t),t},f.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},f.prototype.strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},f.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},f.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var M=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],x=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];f.prototype.toString=function(t,r){t=t||10,r=r|0||1;var i;if(t===16||t==="hex"){i="";for(var a=0,d=0,c=0;c<this.length;c++){var v=this.words[c],u=((v<<a|d)&16777215).toString(16);d=v>>>24-a&16777215,a+=2,a>=26&&(a-=26,c--),d!==0||c!==this.length-1?i=M[6-u.length]+u+i:i=u+i}for(d!==0&&(i=d.toString(16)+i);i.length%r!==0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}if(t===(t|0)&&t>=2&&t<=36){var e=x[t],l=I[t];i="";var b=this.clone();for(b.negative=0;!b.isZero();){var _=b.modn(l).toString(t);b=b.idivn(l),b.isZero()?i=_+i:i=M[e-_.length]+_+i}for(this.isZero()&&(i="0"+i);i.length%r!==0;)i="0"+i;return this.negative!==0&&(i="-"+i),i}s(!1,"Base should be between 2 and 36")},f.prototype.toNumber=function(){var t=this.words[0];return this.length===2?t+=this.words[1]*67108864:this.length===3&&this.words[2]===1?t+=4503599627370496+this.words[1]*67108864:this.length>2&&s(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-t:t},f.prototype.toJSON=function(){return this.toString(16)},f.prototype.toBuffer=function(t,r){return s(typeof g!="undefined"),this.toArrayLike(g,t,r)},f.prototype.toArray=function(t,r){return this.toArrayLike(Array,t,r)},f.prototype.toArrayLike=function(t,r,i){var a=this.byteLength(),d=i||Math.max(1,a);s(a<=d,"byte array longer than desired length"),s(d>0,"Requested array length <= 0"),this.strip();var c=r==="le",v=new t(d),u,e,l=this.clone();if(c){for(e=0;!l.isZero();e++)u=l.andln(255),l.iushrn(8),v[e]=u;for(;e<d;e++)v[e]=0}else{for(e=0;e<d-a;e++)v[e]=0;for(e=0;!l.isZero();e++)u=l.andln(255),l.iushrn(8),v[d-e-1]=u}return v},Math.clz32?f.prototype._countBits=function(t){return 32-Math.clz32(t)}:f.prototype._countBits=function(t){var r=t,i=0;return r>=4096&&(i+=13,r>>>=13),r>=64&&(i+=7,r>>>=7),r>=8&&(i+=4,r>>>=4),r>=2&&(i+=2,r>>>=2),i+r},f.prototype._zeroBits=function(t){if(t===0)return 26;var r=t,i=0;return r&8191||(i+=13,r>>>=13),r&127||(i+=7,r>>>=7),r&15||(i+=4,r>>>=4),r&3||(i+=2,r>>>=2),r&1||i++,i},f.prototype.bitLength=function(){var t=this.words[this.length-1],r=this._countBits(t);return(this.length-1)*26+r};function k(p){for(var t=new Array(p.bitLength()),r=0;r<t.length;r++){var i=r/26|0,a=r%26;t[r]=(p.words[i]&1<<a)>>>a}return t}f.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,r=0;r<this.length;r++){var i=this._zeroBits(this.words[r]);if(t+=i,i!==26)break}return t},f.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},f.prototype.toTwos=function(t){return this.negative!==0?this.abs().inotn(t).iaddn(1):this.clone()},f.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},f.prototype.isNeg=function(){return this.negative!==0},f.prototype.neg=function(){return this.clone().ineg()},f.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},f.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]|t.words[r];return this.strip()},f.prototype.ior=function(t){return s((this.negative|t.negative)===0),this.iuor(t)},f.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},f.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},f.prototype.iuand=function(t){var r;this.length>t.length?r=t:r=this;for(var i=0;i<r.length;i++)this.words[i]=this.words[i]&t.words[i];return this.length=r.length,this.strip()},f.prototype.iand=function(t){return s((this.negative|t.negative)===0),this.iuand(t)},f.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},f.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},f.prototype.iuxor=function(t){var r,i;this.length>t.length?(r=this,i=t):(r=t,i=this);for(var a=0;a<i.length;a++)this.words[a]=r.words[a]^i.words[a];if(this!==r)for(;a<r.length;a++)this.words[a]=r.words[a];return this.length=r.length,this.strip()},f.prototype.ixor=function(t){return s((this.negative|t.negative)===0),this.iuxor(t)},f.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},f.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},f.prototype.inotn=function(t){s(typeof t=="number"&&t>=0);var r=Math.ceil(t/26)|0,i=t%26;this._expand(r),i>0&&r--;for(var a=0;a<r;a++)this.words[a]=~this.words[a]&67108863;return i>0&&(this.words[a]=~this.words[a]&67108863>>26-i),this.strip()},f.prototype.notn=function(t){return this.clone().inotn(t)},f.prototype.setn=function(t,r){s(typeof t=="number"&&t>=0);var i=t/26|0,a=t%26;return this._expand(i+1),r?this.words[i]=this.words[i]|1<<a:this.words[i]=this.words[i]&~(1<<a),this.strip()},f.prototype.iadd=function(t){var r;if(this.negative!==0&&t.negative===0)return this.negative=0,r=this.isub(t),this.negative^=1,this._normSign();if(this.negative===0&&t.negative!==0)return t.negative=0,r=this.isub(t),t.negative=1,r._normSign();var i,a;this.length>t.length?(i=this,a=t):(i=t,a=this);for(var d=0,c=0;c<a.length;c++)r=(i.words[c]|0)+(a.words[c]|0)+d,this.words[c]=r&67108863,d=r>>>26;for(;d!==0&&c<i.length;c++)r=(i.words[c]|0)+d,this.words[c]=r&67108863,d=r>>>26;if(this.length=i.length,d!==0)this.words[this.length]=d,this.length++;else if(i!==this)for(;c<i.length;c++)this.words[c]=i.words[c];return this},f.prototype.add=function(t){var r;return t.negative!==0&&this.negative===0?(t.negative=0,r=this.sub(t),t.negative^=1,r):t.negative===0&&this.negative!==0?(this.negative=0,r=t.sub(this),this.negative=1,r):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},f.prototype.isub=function(t){if(t.negative!==0){t.negative=0;var r=this.iadd(t);return t.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i=this.cmp(t);if(i===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,d;i>0?(a=this,d=t):(a=t,d=this);for(var c=0,v=0;v<d.length;v++)r=(a.words[v]|0)-(d.words[v]|0)+c,c=r>>26,this.words[v]=r&67108863;for(;c!==0&&v<a.length;v++)r=(a.words[v]|0)+c,c=r>>26,this.words[v]=r&67108863;if(c===0&&v<a.length&&a!==this)for(;v<a.length;v++)this.words[v]=a.words[v];return this.length=Math.max(this.length,v),a!==this&&(this.negative=1),this.strip()},f.prototype.sub=function(t){return this.clone().isub(t)};function D(p,t,r){r.negative=t.negative^p.negative;var i=p.length+t.length|0;r.length=i,i=i-1|0;var a=p.words[0]|0,d=t.words[0]|0,c=a*d,v=c&67108863,u=c/67108864|0;r.words[0]=v;for(var e=1;e<i;e++){for(var l=u>>>26,b=u&67108863,_=Math.min(e,t.length-1),C=Math.max(0,e-p.length+1);C<=_;C++){var q=e-C|0;a=p.words[q]|0,d=t.words[C]|0,c=a*d+b,l+=c/67108864|0,b=c&67108863}r.words[e]=b|0,u=l|0}return u!==0?r.words[e]=u|0:r.length--,r.strip()}var L=function(t,r,i){var a=t.words,d=r.words,c=i.words,v=0,u,e,l,b=a[0]|0,_=b&8191,C=b>>>13,q=a[1]|0,O=q&8191,R=q>>>13,P=a[2]|0,N=P&8191,K=P>>>13,kt=a[3]|0,Z=kt&8191,J=kt>>>13,qt=a[4]|0,tt=qt&8191,vt=qt>>>13,Nt=a[5]|0,et=Nt&8191,pt=Nt>>>13,Dt=a[6]|0,j=Dt&8191,dt=Dt>>>13,Pt=a[7]|0,Q=Pt&8191,ct=Pt>>>13,Ot=a[8]|0,E=Ot&8191,w=Ot>>>13,A=a[9]|0,T=A&8191,F=A>>>13,V=d[0]|0,U=V&8191,X=V>>>13,Tt=d[1]|0,G=Tt&8191,rt=Tt>>>13,Rt=d[2]|0,it=Rt&8191,gt=Rt>>>13,Ht=d[3]|0,nt=Ht&8191,bt=Ht>>>13,Zt=d[4]|0,ft=Zt&8191,yt=Zt>>>13,Wt=d[5]|0,at=Wt&8191,wt=Wt>>>13,Vt=d[6]|0,ht=Vt&8191,Mt=Vt>>>13,Yt=d[7]|0,st=Yt&8191,xt=Yt>>>13,Jt=d[8]|0,ot=Jt&8191,_t=Jt>>>13,Gt=d[9]|0,ut=Gt&8191,St=Gt>>>13;i.negative=t.negative^r.negative,i.length=19,u=Math.imul(_,U),e=Math.imul(_,X),e=e+Math.imul(C,U)|0,l=Math.imul(C,X);var $t=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+($t>>>26)|0,$t&=67108863,u=Math.imul(O,U),e=Math.imul(O,X),e=e+Math.imul(R,U)|0,l=Math.imul(R,X),u=u+Math.imul(_,G)|0,e=e+Math.imul(_,rt)|0,e=e+Math.imul(C,G)|0,l=l+Math.imul(C,rt)|0;var Ut=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,u=Math.imul(N,U),e=Math.imul(N,X),e=e+Math.imul(K,U)|0,l=Math.imul(K,X),u=u+Math.imul(O,G)|0,e=e+Math.imul(O,rt)|0,e=e+Math.imul(R,G)|0,l=l+Math.imul(R,rt)|0,u=u+Math.imul(_,it)|0,e=e+Math.imul(_,gt)|0,e=e+Math.imul(C,it)|0,l=l+Math.imul(C,gt)|0;var jt=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(jt>>>26)|0,jt&=67108863,u=Math.imul(Z,U),e=Math.imul(Z,X),e=e+Math.imul(J,U)|0,l=Math.imul(J,X),u=u+Math.imul(N,G)|0,e=e+Math.imul(N,rt)|0,e=e+Math.imul(K,G)|0,l=l+Math.imul(K,rt)|0,u=u+Math.imul(O,it)|0,e=e+Math.imul(O,gt)|0,e=e+Math.imul(R,it)|0,l=l+Math.imul(R,gt)|0,u=u+Math.imul(_,nt)|0,e=e+Math.imul(_,bt)|0,e=e+Math.imul(C,nt)|0,l=l+Math.imul(C,bt)|0;var Qt=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Qt>>>26)|0,Qt&=67108863,u=Math.imul(tt,U),e=Math.imul(tt,X),e=e+Math.imul(vt,U)|0,l=Math.imul(vt,X),u=u+Math.imul(Z,G)|0,e=e+Math.imul(Z,rt)|0,e=e+Math.imul(J,G)|0,l=l+Math.imul(J,rt)|0,u=u+Math.imul(N,it)|0,e=e+Math.imul(N,gt)|0,e=e+Math.imul(K,it)|0,l=l+Math.imul(K,gt)|0,u=u+Math.imul(O,nt)|0,e=e+Math.imul(O,bt)|0,e=e+Math.imul(R,nt)|0,l=l+Math.imul(R,bt)|0,u=u+Math.imul(_,ft)|0,e=e+Math.imul(_,yt)|0,e=e+Math.imul(C,ft)|0,l=l+Math.imul(C,yt)|0;var te=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(te>>>26)|0,te&=67108863,u=Math.imul(et,U),e=Math.imul(et,X),e=e+Math.imul(pt,U)|0,l=Math.imul(pt,X),u=u+Math.imul(tt,G)|0,e=e+Math.imul(tt,rt)|0,e=e+Math.imul(vt,G)|0,l=l+Math.imul(vt,rt)|0,u=u+Math.imul(Z,it)|0,e=e+Math.imul(Z,gt)|0,e=e+Math.imul(J,it)|0,l=l+Math.imul(J,gt)|0,u=u+Math.imul(N,nt)|0,e=e+Math.imul(N,bt)|0,e=e+Math.imul(K,nt)|0,l=l+Math.imul(K,bt)|0,u=u+Math.imul(O,ft)|0,e=e+Math.imul(O,yt)|0,e=e+Math.imul(R,ft)|0,l=l+Math.imul(R,yt)|0,u=u+Math.imul(_,at)|0,e=e+Math.imul(_,wt)|0,e=e+Math.imul(C,at)|0,l=l+Math.imul(C,wt)|0;var ee=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ee>>>26)|0,ee&=67108863,u=Math.imul(j,U),e=Math.imul(j,X),e=e+Math.imul(dt,U)|0,l=Math.imul(dt,X),u=u+Math.imul(et,G)|0,e=e+Math.imul(et,rt)|0,e=e+Math.imul(pt,G)|0,l=l+Math.imul(pt,rt)|0,u=u+Math.imul(tt,it)|0,e=e+Math.imul(tt,gt)|0,e=e+Math.imul(vt,it)|0,l=l+Math.imul(vt,gt)|0,u=u+Math.imul(Z,nt)|0,e=e+Math.imul(Z,bt)|0,e=e+Math.imul(J,nt)|0,l=l+Math.imul(J,bt)|0,u=u+Math.imul(N,ft)|0,e=e+Math.imul(N,yt)|0,e=e+Math.imul(K,ft)|0,l=l+Math.imul(K,yt)|0,u=u+Math.imul(O,at)|0,e=e+Math.imul(O,wt)|0,e=e+Math.imul(R,at)|0,l=l+Math.imul(R,wt)|0,u=u+Math.imul(_,ht)|0,e=e+Math.imul(_,Mt)|0,e=e+Math.imul(C,ht)|0,l=l+Math.imul(C,Mt)|0;var re=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(re>>>26)|0,re&=67108863,u=Math.imul(Q,U),e=Math.imul(Q,X),e=e+Math.imul(ct,U)|0,l=Math.imul(ct,X),u=u+Math.imul(j,G)|0,e=e+Math.imul(j,rt)|0,e=e+Math.imul(dt,G)|0,l=l+Math.imul(dt,rt)|0,u=u+Math.imul(et,it)|0,e=e+Math.imul(et,gt)|0,e=e+Math.imul(pt,it)|0,l=l+Math.imul(pt,gt)|0,u=u+Math.imul(tt,nt)|0,e=e+Math.imul(tt,bt)|0,e=e+Math.imul(vt,nt)|0,l=l+Math.imul(vt,bt)|0,u=u+Math.imul(Z,ft)|0,e=e+Math.imul(Z,yt)|0,e=e+Math.imul(J,ft)|0,l=l+Math.imul(J,yt)|0,u=u+Math.imul(N,at)|0,e=e+Math.imul(N,wt)|0,e=e+Math.imul(K,at)|0,l=l+Math.imul(K,wt)|0,u=u+Math.imul(O,ht)|0,e=e+Math.imul(O,Mt)|0,e=e+Math.imul(R,ht)|0,l=l+Math.imul(R,Mt)|0,u=u+Math.imul(_,st)|0,e=e+Math.imul(_,xt)|0,e=e+Math.imul(C,st)|0,l=l+Math.imul(C,xt)|0;var ie=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ie>>>26)|0,ie&=67108863,u=Math.imul(E,U),e=Math.imul(E,X),e=e+Math.imul(w,U)|0,l=Math.imul(w,X),u=u+Math.imul(Q,G)|0,e=e+Math.imul(Q,rt)|0,e=e+Math.imul(ct,G)|0,l=l+Math.imul(ct,rt)|0,u=u+Math.imul(j,it)|0,e=e+Math.imul(j,gt)|0,e=e+Math.imul(dt,it)|0,l=l+Math.imul(dt,gt)|0,u=u+Math.imul(et,nt)|0,e=e+Math.imul(et,bt)|0,e=e+Math.imul(pt,nt)|0,l=l+Math.imul(pt,bt)|0,u=u+Math.imul(tt,ft)|0,e=e+Math.imul(tt,yt)|0,e=e+Math.imul(vt,ft)|0,l=l+Math.imul(vt,yt)|0,u=u+Math.imul(Z,at)|0,e=e+Math.imul(Z,wt)|0,e=e+Math.imul(J,at)|0,l=l+Math.imul(J,wt)|0,u=u+Math.imul(N,ht)|0,e=e+Math.imul(N,Mt)|0,e=e+Math.imul(K,ht)|0,l=l+Math.imul(K,Mt)|0,u=u+Math.imul(O,st)|0,e=e+Math.imul(O,xt)|0,e=e+Math.imul(R,st)|0,l=l+Math.imul(R,xt)|0,u=u+Math.imul(_,ot)|0,e=e+Math.imul(_,_t)|0,e=e+Math.imul(C,ot)|0,l=l+Math.imul(C,_t)|0;var ne=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ne>>>26)|0,ne&=67108863,u=Math.imul(T,U),e=Math.imul(T,X),e=e+Math.imul(F,U)|0,l=Math.imul(F,X),u=u+Math.imul(E,G)|0,e=e+Math.imul(E,rt)|0,e=e+Math.imul(w,G)|0,l=l+Math.imul(w,rt)|0,u=u+Math.imul(Q,it)|0,e=e+Math.imul(Q,gt)|0,e=e+Math.imul(ct,it)|0,l=l+Math.imul(ct,gt)|0,u=u+Math.imul(j,nt)|0,e=e+Math.imul(j,bt)|0,e=e+Math.imul(dt,nt)|0,l=l+Math.imul(dt,bt)|0,u=u+Math.imul(et,ft)|0,e=e+Math.imul(et,yt)|0,e=e+Math.imul(pt,ft)|0,l=l+Math.imul(pt,yt)|0,u=u+Math.imul(tt,at)|0,e=e+Math.imul(tt,wt)|0,e=e+Math.imul(vt,at)|0,l=l+Math.imul(vt,wt)|0,u=u+Math.imul(Z,ht)|0,e=e+Math.imul(Z,Mt)|0,e=e+Math.imul(J,ht)|0,l=l+Math.imul(J,Mt)|0,u=u+Math.imul(N,st)|0,e=e+Math.imul(N,xt)|0,e=e+Math.imul(K,st)|0,l=l+Math.imul(K,xt)|0,u=u+Math.imul(O,ot)|0,e=e+Math.imul(O,_t)|0,e=e+Math.imul(R,ot)|0,l=l+Math.imul(R,_t)|0,u=u+Math.imul(_,ut)|0,e=e+Math.imul(_,St)|0,e=e+Math.imul(C,ut)|0,l=l+Math.imul(C,St)|0;var fe=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(fe>>>26)|0,fe&=67108863,u=Math.imul(T,G),e=Math.imul(T,rt),e=e+Math.imul(F,G)|0,l=Math.imul(F,rt),u=u+Math.imul(E,it)|0,e=e+Math.imul(E,gt)|0,e=e+Math.imul(w,it)|0,l=l+Math.imul(w,gt)|0,u=u+Math.imul(Q,nt)|0,e=e+Math.imul(Q,bt)|0,e=e+Math.imul(ct,nt)|0,l=l+Math.imul(ct,bt)|0,u=u+Math.imul(j,ft)|0,e=e+Math.imul(j,yt)|0,e=e+Math.imul(dt,ft)|0,l=l+Math.imul(dt,yt)|0,u=u+Math.imul(et,at)|0,e=e+Math.imul(et,wt)|0,e=e+Math.imul(pt,at)|0,l=l+Math.imul(pt,wt)|0,u=u+Math.imul(tt,ht)|0,e=e+Math.imul(tt,Mt)|0,e=e+Math.imul(vt,ht)|0,l=l+Math.imul(vt,Mt)|0,u=u+Math.imul(Z,st)|0,e=e+Math.imul(Z,xt)|0,e=e+Math.imul(J,st)|0,l=l+Math.imul(J,xt)|0,u=u+Math.imul(N,ot)|0,e=e+Math.imul(N,_t)|0,e=e+Math.imul(K,ot)|0,l=l+Math.imul(K,_t)|0,u=u+Math.imul(O,ut)|0,e=e+Math.imul(O,St)|0,e=e+Math.imul(R,ut)|0,l=l+Math.imul(R,St)|0;var ae=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ae>>>26)|0,ae&=67108863,u=Math.imul(T,it),e=Math.imul(T,gt),e=e+Math.imul(F,it)|0,l=Math.imul(F,gt),u=u+Math.imul(E,nt)|0,e=e+Math.imul(E,bt)|0,e=e+Math.imul(w,nt)|0,l=l+Math.imul(w,bt)|0,u=u+Math.imul(Q,ft)|0,e=e+Math.imul(Q,yt)|0,e=e+Math.imul(ct,ft)|0,l=l+Math.imul(ct,yt)|0,u=u+Math.imul(j,at)|0,e=e+Math.imul(j,wt)|0,e=e+Math.imul(dt,at)|0,l=l+Math.imul(dt,wt)|0,u=u+Math.imul(et,ht)|0,e=e+Math.imul(et,Mt)|0,e=e+Math.imul(pt,ht)|0,l=l+Math.imul(pt,Mt)|0,u=u+Math.imul(tt,st)|0,e=e+Math.imul(tt,xt)|0,e=e+Math.imul(vt,st)|0,l=l+Math.imul(vt,xt)|0,u=u+Math.imul(Z,ot)|0,e=e+Math.imul(Z,_t)|0,e=e+Math.imul(J,ot)|0,l=l+Math.imul(J,_t)|0,u=u+Math.imul(N,ut)|0,e=e+Math.imul(N,St)|0,e=e+Math.imul(K,ut)|0,l=l+Math.imul(K,St)|0;var he=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(he>>>26)|0,he&=67108863,u=Math.imul(T,nt),e=Math.imul(T,bt),e=e+Math.imul(F,nt)|0,l=Math.imul(F,bt),u=u+Math.imul(E,ft)|0,e=e+Math.imul(E,yt)|0,e=e+Math.imul(w,ft)|0,l=l+Math.imul(w,yt)|0,u=u+Math.imul(Q,at)|0,e=e+Math.imul(Q,wt)|0,e=e+Math.imul(ct,at)|0,l=l+Math.imul(ct,wt)|0,u=u+Math.imul(j,ht)|0,e=e+Math.imul(j,Mt)|0,e=e+Math.imul(dt,ht)|0,l=l+Math.imul(dt,Mt)|0,u=u+Math.imul(et,st)|0,e=e+Math.imul(et,xt)|0,e=e+Math.imul(pt,st)|0,l=l+Math.imul(pt,xt)|0,u=u+Math.imul(tt,ot)|0,e=e+Math.imul(tt,_t)|0,e=e+Math.imul(vt,ot)|0,l=l+Math.imul(vt,_t)|0,u=u+Math.imul(Z,ut)|0,e=e+Math.imul(Z,St)|0,e=e+Math.imul(J,ut)|0,l=l+Math.imul(J,St)|0;var se=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(se>>>26)|0,se&=67108863,u=Math.imul(T,ft),e=Math.imul(T,yt),e=e+Math.imul(F,ft)|0,l=Math.imul(F,yt),u=u+Math.imul(E,at)|0,e=e+Math.imul(E,wt)|0,e=e+Math.imul(w,at)|0,l=l+Math.imul(w,wt)|0,u=u+Math.imul(Q,ht)|0,e=e+Math.imul(Q,Mt)|0,e=e+Math.imul(ct,ht)|0,l=l+Math.imul(ct,Mt)|0,u=u+Math.imul(j,st)|0,e=e+Math.imul(j,xt)|0,e=e+Math.imul(dt,st)|0,l=l+Math.imul(dt,xt)|0,u=u+Math.imul(et,ot)|0,e=e+Math.imul(et,_t)|0,e=e+Math.imul(pt,ot)|0,l=l+Math.imul(pt,_t)|0,u=u+Math.imul(tt,ut)|0,e=e+Math.imul(tt,St)|0,e=e+Math.imul(vt,ut)|0,l=l+Math.imul(vt,St)|0;var oe=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(oe>>>26)|0,oe&=67108863,u=Math.imul(T,at),e=Math.imul(T,wt),e=e+Math.imul(F,at)|0,l=Math.imul(F,wt),u=u+Math.imul(E,ht)|0,e=e+Math.imul(E,Mt)|0,e=e+Math.imul(w,ht)|0,l=l+Math.imul(w,Mt)|0,u=u+Math.imul(Q,st)|0,e=e+Math.imul(Q,xt)|0,e=e+Math.imul(ct,st)|0,l=l+Math.imul(ct,xt)|0,u=u+Math.imul(j,ot)|0,e=e+Math.imul(j,_t)|0,e=e+Math.imul(dt,ot)|0,l=l+Math.imul(dt,_t)|0,u=u+Math.imul(et,ut)|0,e=e+Math.imul(et,St)|0,e=e+Math.imul(pt,ut)|0,l=l+Math.imul(pt,St)|0;var ue=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ue>>>26)|0,ue&=67108863,u=Math.imul(T,ht),e=Math.imul(T,Mt),e=e+Math.imul(F,ht)|0,l=Math.imul(F,Mt),u=u+Math.imul(E,st)|0,e=e+Math.imul(E,xt)|0,e=e+Math.imul(w,st)|0,l=l+Math.imul(w,xt)|0,u=u+Math.imul(Q,ot)|0,e=e+Math.imul(Q,_t)|0,e=e+Math.imul(ct,ot)|0,l=l+Math.imul(ct,_t)|0,u=u+Math.imul(j,ut)|0,e=e+Math.imul(j,St)|0,e=e+Math.imul(dt,ut)|0,l=l+Math.imul(dt,St)|0;var le=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(le>>>26)|0,le&=67108863,u=Math.imul(T,st),e=Math.imul(T,xt),e=e+Math.imul(F,st)|0,l=Math.imul(F,xt),u=u+Math.imul(E,ot)|0,e=e+Math.imul(E,_t)|0,e=e+Math.imul(w,ot)|0,l=l+Math.imul(w,_t)|0,u=u+Math.imul(Q,ut)|0,e=e+Math.imul(Q,St)|0,e=e+Math.imul(ct,ut)|0,l=l+Math.imul(ct,St)|0;var de=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(de>>>26)|0,de&=67108863,u=Math.imul(T,ot),e=Math.imul(T,_t),e=e+Math.imul(F,ot)|0,l=Math.imul(F,_t),u=u+Math.imul(E,ut)|0,e=e+Math.imul(E,St)|0,e=e+Math.imul(w,ut)|0,l=l+Math.imul(w,St)|0;var ce=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(ce>>>26)|0,ce&=67108863,u=Math.imul(T,ut),e=Math.imul(T,St),e=e+Math.imul(F,ut)|0,l=Math.imul(F,St);var ve=(v+u|0)+((e&8191)<<13)|0;return v=(l+(e>>>13)|0)+(ve>>>26)|0,ve&=67108863,c[0]=$t,c[1]=Ut,c[2]=jt,c[3]=Qt,c[4]=te,c[5]=ee,c[6]=re,c[7]=ie,c[8]=ne,c[9]=fe,c[10]=ae,c[11]=he,c[12]=se,c[13]=oe,c[14]=ue,c[15]=le,c[16]=de,c[17]=ce,c[18]=ve,v!==0&&(c[19]=v,i.length++),i};Math.imul||(L=D);function W(p,t,r){r.negative=t.negative^p.negative,r.length=p.length+t.length;for(var i=0,a=0,d=0;d<r.length-1;d++){var c=a;a=0;for(var v=i&67108863,u=Math.min(d,t.length-1),e=Math.max(0,d-p.length+1);e<=u;e++){var l=d-e,b=p.words[l]|0,_=t.words[e]|0,C=b*_,q=C&67108863;c=c+(C/67108864|0)|0,q=q+v|0,v=q&67108863,c=c+(q>>>26)|0,a+=c>>>26,c&=67108863}r.words[d]=v,i=c,c=a}return i!==0?r.words[d]=i:r.length--,r.strip()}function z(p,t,r){var i=new $;return i.mulp(p,t,r)}f.prototype.mulTo=function(t,r){var i,a=this.length+t.length;return this.length===10&&t.length===10?i=L(this,t,r):a<63?i=D(this,t,r):a<1024?i=W(this,t,r):i=z(this,t,r),i};function $(p,t){this.x=p,this.y=t}$.prototype.makeRBT=function(t){for(var r=new Array(t),i=f.prototype._countBits(t)-1,a=0;a<t;a++)r[a]=this.revBin(a,i,t);return r},$.prototype.revBin=function(t,r,i){if(t===0||t===i-1)return t;for(var a=0,d=0;d<r;d++)a|=(t&1)<<r-d-1,t>>=1;return a},$.prototype.permute=function(t,r,i,a,d,c){for(var v=0;v<c;v++)a[v]=r[t[v]],d[v]=i[t[v]]},$.prototype.transform=function(t,r,i,a,d,c){this.permute(c,t,r,i,a,d);for(var v=1;v<d;v<<=1)for(var u=v<<1,e=Math.cos(2*Math.PI/u),l=Math.sin(2*Math.PI/u),b=0;b<d;b+=u)for(var _=e,C=l,q=0;q<v;q++){var O=i[b+q],R=a[b+q],P=i[b+q+v],N=a[b+q+v],K=_*P-C*N;N=_*N+C*P,P=K,i[b+q]=O+P,a[b+q]=R+N,i[b+q+v]=O-P,a[b+q+v]=R-N,q!==u&&(K=e*_-l*C,C=e*C+l*_,_=K)}},$.prototype.guessLen13b=function(t,r){var i=Math.max(r,t)|1,a=i&1,d=0;for(i=i/2|0;i;i=i>>>1)d++;return 1<<d+1+a},$.prototype.conjugate=function(t,r,i){if(!(i<=1))for(var a=0;a<i/2;a++){var d=t[a];t[a]=t[i-a-1],t[i-a-1]=d,d=r[a],r[a]=-r[i-a-1],r[i-a-1]=-d}},$.prototype.normalize13b=function(t,r){for(var i=0,a=0;a<r/2;a++){var d=Math.round(t[2*a+1]/r)*8192+Math.round(t[2*a]/r)+i;t[a]=d&67108863,d<67108864?i=0:i=d/67108864|0}return t},$.prototype.convert13b=function(t,r,i,a){for(var d=0,c=0;c<r;c++)d=d+(t[c]|0),i[2*c]=d&8191,d=d>>>13,i[2*c+1]=d&8191,d=d>>>13;for(c=2*r;c<a;++c)i[c]=0;s(d===0),s((d&-8192)===0)},$.prototype.stub=function(t){for(var r=new Array(t),i=0;i<t;i++)r[i]=0;return r},$.prototype.mulp=function(t,r,i){var a=2*this.guessLen13b(t.length,r.length),d=this.makeRBT(a),c=this.stub(a),v=new Array(a),u=new Array(a),e=new Array(a),l=new Array(a),b=new Array(a),_=new Array(a),C=i.words;C.length=a,this.convert13b(t.words,t.length,v,a),this.convert13b(r.words,r.length,l,a),this.transform(v,c,u,e,a,d),this.transform(l,c,b,_,a,d);for(var q=0;q<a;q++){var O=u[q]*b[q]-e[q]*_[q];e[q]=u[q]*_[q]+e[q]*b[q],u[q]=O}return this.conjugate(u,e,a),this.transform(u,e,C,c,a,d),this.conjugate(C,c,a),this.normalize13b(C,a),i.negative=t.negative^r.negative,i.length=t.length+r.length,i.strip()},f.prototype.mul=function(t){var r=new f(null);return r.words=new Array(this.length+t.length),this.mulTo(t,r)},f.prototype.mulf=function(t){var r=new f(null);return r.words=new Array(this.length+t.length),z(this,t,r)},f.prototype.imul=function(t){return this.clone().mulTo(t,this)},f.prototype.imuln=function(t){s(typeof t=="number"),s(t<67108864);for(var r=0,i=0;i<this.length;i++){var a=(this.words[i]|0)*t,d=(a&67108863)+(r&67108863);r>>=26,r+=a/67108864|0,r+=d>>>26,this.words[i]=d&67108863}return r!==0&&(this.words[i]=r,this.length++),this.length=t===0?1:this.length,this},f.prototype.muln=function(t){return this.clone().imuln(t)},f.prototype.sqr=function(){return this.mul(this)},f.prototype.isqr=function(){return this.imul(this.clone())},f.prototype.pow=function(t){var r=k(t);if(r.length===0)return new f(1);for(var i=this,a=0;a<r.length&&r[a]===0;a++,i=i.sqr());if(++a<r.length)for(var d=i.sqr();a<r.length;a++,d=d.sqr())r[a]!==0&&(i=i.mul(d));return i},f.prototype.iushln=function(t){s(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26,a=67108863>>>26-r<<26-r,d;if(r!==0){var c=0;for(d=0;d<this.length;d++){var v=this.words[d]&a,u=(this.words[d]|0)-v<<r;this.words[d]=u|c,c=v>>>26-r}c&&(this.words[d]=c,this.length++)}if(i!==0){for(d=this.length-1;d>=0;d--)this.words[d+i]=this.words[d];for(d=0;d<i;d++)this.words[d]=0;this.length+=i}return this.strip()},f.prototype.ishln=function(t){return s(this.negative===0),this.iushln(t)},f.prototype.iushrn=function(t,r,i){s(typeof t=="number"&&t>=0);var a;r?a=(r-r%26)/26:a=0;var d=t%26,c=Math.min((t-d)/26,this.length),v=67108863^67108863>>>d<<d,u=i;if(a-=c,a=Math.max(0,a),u){for(var e=0;e<c;e++)u.words[e]=this.words[e];u.length=c}if(c!==0)if(this.length>c)for(this.length-=c,e=0;e<this.length;e++)this.words[e]=this.words[e+c];else this.words[0]=0,this.length=1;var l=0;for(e=this.length-1;e>=0&&(l!==0||e>=a);e--){var b=this.words[e]|0;this.words[e]=l<<26-d|b>>>d,l=b&v}return u&&l!==0&&(u.words[u.length++]=l),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},f.prototype.ishrn=function(t,r,i){return s(this.negative===0),this.iushrn(t,r,i)},f.prototype.shln=function(t){return this.clone().ishln(t)},f.prototype.ushln=function(t){return this.clone().iushln(t)},f.prototype.shrn=function(t){return this.clone().ishrn(t)},f.prototype.ushrn=function(t){return this.clone().iushrn(t)},f.prototype.testn=function(t){s(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26,a=1<<r;if(this.length<=i)return!1;var d=this.words[i];return!!(d&a)},f.prototype.imaskn=function(t){s(typeof t=="number"&&t>=0);var r=t%26,i=(t-r)/26;if(s(this.negative===0,"imaskn works only with positive numbers"),this.length<=i)return this;if(r!==0&&i++,this.length=Math.min(i,this.length),r!==0){var a=67108863^67108863>>>r<<r;this.words[this.length-1]&=a}return this.strip()},f.prototype.maskn=function(t){return this.clone().imaskn(t)},f.prototype.iaddn=function(t){return s(typeof t=="number"),s(t<67108864),t<0?this.isubn(-t):this.negative!==0?this.length===1&&(this.words[0]|0)<t?(this.words[0]=t-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},f.prototype._iaddn=function(t){this.words[0]+=t;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},f.prototype.isubn=function(t){if(s(typeof t=="number"),s(t<67108864),t<0)return this.iaddn(-t);if(this.negative!==0)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this.strip()},f.prototype.addn=function(t){return this.clone().iaddn(t)},f.prototype.subn=function(t){return this.clone().isubn(t)},f.prototype.iabs=function(){return this.negative=0,this},f.prototype.abs=function(){return this.clone().iabs()},f.prototype._ishlnsubmul=function(t,r,i){var a=t.length+i,d;this._expand(a);var c,v=0;for(d=0;d<t.length;d++){c=(this.words[d+i]|0)+v;var u=(t.words[d]|0)*r;c-=u&67108863,v=(c>>26)-(u/67108864|0),this.words[d+i]=c&67108863}for(;d<this.length-i;d++)c=(this.words[d+i]|0)+v,v=c>>26,this.words[d+i]=c&67108863;if(v===0)return this.strip();for(s(v===-1),v=0,d=0;d<this.length;d++)c=-(this.words[d]|0)+v,v=c>>26,this.words[d]=c&67108863;return this.negative=1,this.strip()},f.prototype._wordDiv=function(t,r){var i=this.length-t.length,a=this.clone(),d=t,c=d.words[d.length-1]|0,v=this._countBits(c);i=26-v,i!==0&&(d=d.ushln(i),a.iushln(i),c=d.words[d.length-1]|0);var u=a.length-d.length,e;if(r!=="mod"){e=new f(null),e.length=u+1,e.words=new Array(e.length);for(var l=0;l<e.length;l++)e.words[l]=0}var b=a.clone()._ishlnsubmul(d,1,u);b.negative===0&&(a=b,e&&(e.words[u]=1));for(var _=u-1;_>=0;_--){var C=(a.words[d.length+_]|0)*67108864+(a.words[d.length+_-1]|0);for(C=Math.min(C/c|0,67108863),a._ishlnsubmul(d,C,_);a.negative!==0;)C--,a.negative=0,a._ishlnsubmul(d,1,_),a.isZero()||(a.negative^=1);e&&(e.words[_]=C)}return e&&e.strip(),a.strip(),r!=="div"&&i!==0&&a.iushrn(i),{div:e||null,mod:a}},f.prototype.divmod=function(t,r,i){if(s(!t.isZero()),this.isZero())return{div:new f(0),mod:new f(0)};var a,d,c;return this.negative!==0&&t.negative===0?(c=this.neg().divmod(t,r),r!=="mod"&&(a=c.div.neg()),r!=="div"&&(d=c.mod.neg(),i&&d.negative!==0&&d.iadd(t)),{div:a,mod:d}):this.negative===0&&t.negative!==0?(c=this.divmod(t.neg(),r),r!=="mod"&&(a=c.div.neg()),{div:a,mod:c.mod}):this.negative&t.negative?(c=this.neg().divmod(t.neg(),r),r!=="div"&&(d=c.mod.neg(),i&&d.negative!==0&&d.isub(t)),{div:c.div,mod:d}):t.length>this.length||this.cmp(t)<0?{div:new f(0),mod:this}:t.length===1?r==="div"?{div:this.divn(t.words[0]),mod:null}:r==="mod"?{div:null,mod:new f(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new f(this.modn(t.words[0]))}:this._wordDiv(t,r)},f.prototype.div=function(t){return this.divmod(t,"div",!1).div},f.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},f.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},f.prototype.divRound=function(t){var r=this.divmod(t);if(r.mod.isZero())return r.div;var i=r.div.negative!==0?r.mod.isub(t):r.mod,a=t.ushrn(1),d=t.andln(1),c=i.cmp(a);return c<0||d===1&&c===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},f.prototype.modn=function(t){s(t<=67108863);for(var r=(1<<26)%t,i=0,a=this.length-1;a>=0;a--)i=(r*i+(this.words[a]|0))%t;return i},f.prototype.idivn=function(t){s(t<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var a=(this.words[i]|0)+r*67108864;this.words[i]=a/t|0,r=a%t}return this.strip()},f.prototype.divn=function(t){return this.clone().idivn(t)},f.prototype.egcd=function(t){s(t.negative===0),s(!t.isZero());var r=this,i=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var a=new f(1),d=new f(0),c=new f(0),v=new f(1),u=0;r.isEven()&&i.isEven();)r.iushrn(1),i.iushrn(1),++u;for(var e=i.clone(),l=r.clone();!r.isZero();){for(var b=0,_=1;!(r.words[0]&_)&&b<26;++b,_<<=1);if(b>0)for(r.iushrn(b);b-- >0;)(a.isOdd()||d.isOdd())&&(a.iadd(e),d.isub(l)),a.iushrn(1),d.iushrn(1);for(var C=0,q=1;!(i.words[0]&q)&&C<26;++C,q<<=1);if(C>0)for(i.iushrn(C);C-- >0;)(c.isOdd()||v.isOdd())&&(c.iadd(e),v.isub(l)),c.iushrn(1),v.iushrn(1);r.cmp(i)>=0?(r.isub(i),a.isub(c),d.isub(v)):(i.isub(r),c.isub(a),v.isub(d))}return{a:c,b:v,gcd:i.iushln(u)}},f.prototype._invmp=function(t){s(t.negative===0),s(!t.isZero());var r=this,i=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var a=new f(1),d=new f(0),c=i.clone();r.cmpn(1)>0&&i.cmpn(1)>0;){for(var v=0,u=1;!(r.words[0]&u)&&v<26;++v,u<<=1);if(v>0)for(r.iushrn(v);v-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);for(var e=0,l=1;!(i.words[0]&l)&&e<26;++e,l<<=1);if(e>0)for(i.iushrn(e);e-- >0;)d.isOdd()&&d.iadd(c),d.iushrn(1);r.cmp(i)>=0?(r.isub(i),a.isub(d)):(i.isub(r),d.isub(a))}var b;return r.cmpn(1)===0?b=a:b=d,b.cmpn(0)<0&&b.iadd(t),b},f.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var r=this.clone(),i=t.clone();r.negative=0,i.negative=0;for(var a=0;r.isEven()&&i.isEven();a++)r.iushrn(1),i.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;i.isEven();)i.iushrn(1);var d=r.cmp(i);if(d<0){var c=r;r=i,i=c}else if(d===0||i.cmpn(1)===0)break;r.isub(i)}while(!0);return i.iushln(a)},f.prototype.invm=function(t){return this.egcd(t).a.umod(t)},f.prototype.isEven=function(){return(this.words[0]&1)===0},f.prototype.isOdd=function(){return(this.words[0]&1)===1},f.prototype.andln=function(t){return this.words[0]&t},f.prototype.bincn=function(t){s(typeof t=="number");var r=t%26,i=(t-r)/26,a=1<<r;if(this.length<=i)return this._expand(i+1),this.words[i]|=a,this;for(var d=a,c=i;d!==0&&c<this.length;c++){var v=this.words[c]|0;v+=d,d=v>>>26,v&=67108863,this.words[c]=v}return d!==0&&(this.words[c]=d,this.length++),this},f.prototype.isZero=function(){return this.length===1&&this.words[0]===0},f.prototype.cmpn=function(t){var r=t<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this.strip();var i;if(this.length>1)i=1;else{r&&(t=-t),s(t<=67108863,"Number is too big");var a=this.words[0]|0;i=a===t?0:a<t?-1:1}return this.negative!==0?-i|0:i},f.prototype.cmp=function(t){if(this.negative!==0&&t.negative===0)return-1;if(this.negative===0&&t.negative!==0)return 1;var r=this.ucmp(t);return this.negative!==0?-r|0:r},f.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var r=0,i=this.length-1;i>=0;i--){var a=this.words[i]|0,d=t.words[i]|0;if(a!==d){a<d?r=-1:a>d&&(r=1);break}}return r},f.prototype.gtn=function(t){return this.cmpn(t)===1},f.prototype.gt=function(t){return this.cmp(t)===1},f.prototype.gten=function(t){return this.cmpn(t)>=0},f.prototype.gte=function(t){return this.cmp(t)>=0},f.prototype.ltn=function(t){return this.cmpn(t)===-1},f.prototype.lt=function(t){return this.cmp(t)===-1},f.prototype.lten=function(t){return this.cmpn(t)<=0},f.prototype.lte=function(t){return this.cmp(t)<=0},f.prototype.eqn=function(t){return this.cmpn(t)===0},f.prototype.eq=function(t){return this.cmp(t)===0},f.red=function(t){return new Y(t)},f.prototype.toRed=function(t){return s(!this.red,"Already a number in reduction context"),s(this.negative===0,"red works only with positives"),t.convertTo(this)._forceRed(t)},f.prototype.fromRed=function(){return s(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},f.prototype._forceRed=function(t){return this.red=t,this},f.prototype.forceRed=function(t){return s(!this.red,"Already a number in reduction context"),this._forceRed(t)},f.prototype.redAdd=function(t){return s(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},f.prototype.redIAdd=function(t){return s(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},f.prototype.redSub=function(t){return s(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},f.prototype.redISub=function(t){return s(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},f.prototype.redShl=function(t){return s(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},f.prototype.redMul=function(t){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},f.prototype.redIMul=function(t){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},f.prototype.redSqr=function(){return s(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},f.prototype.redISqr=function(){return s(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},f.prototype.redSqrt=function(){return s(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},f.prototype.redInvm=function(){return s(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},f.prototype.redNeg=function(){return s(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},f.prototype.redPow=function(t){return s(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var lt={k256:null,p224:null,p192:null,p25519:null};function H(p,t){this.name=p,this.p=new f(t,16),this.n=this.p.bitLength(),this.k=new f(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var t=new f(null);return t.words=new Array(Math.ceil(this.n/13)),t},H.prototype.ireduce=function(t){var r=t,i;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),i=r.bitLength();while(i>this.n);var a=i<this.n?-1:r.ucmp(this.p);return a===0?(r.words[0]=0,r.length=1):a>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},H.prototype.split=function(t,r){t.iushrn(this.n,0,r)},H.prototype.imulK=function(t){return t.imul(this.k)};function At(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}m(At,H),At.prototype.split=function(t,r){for(var i=4194303,a=Math.min(t.length,9),d=0;d<a;d++)r.words[d]=t.words[d];if(r.length=a,t.length<=9){t.words[0]=0,t.length=1;return}var c=t.words[9];for(r.words[r.length++]=c&i,d=10;d<t.length;d++){var v=t.words[d]|0;t.words[d-10]=(v&i)<<4|c>>>22,c=v}c>>>=22,t.words[d-10]=c,c===0&&t.length>10?t.length-=10:t.length-=9},At.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var r=0,i=0;i<t.length;i++){var a=t.words[i]|0;r+=a*977,t.words[i]=r&67108863,r=a*64+(r/67108864|0)}return t.words[t.length-1]===0&&(t.length--,t.words[t.length-1]===0&&t.length--),t};function Bt(){H.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}m(Bt,H);function Ct(){H.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}m(Ct,H);function Et(){H.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}m(Et,H),Et.prototype.imulK=function(t){for(var r=0,i=0;i<t.length;i++){var a=(t.words[i]|0)*19+r,d=a&67108863;a>>>=26,t.words[i]=d,r=a}return r!==0&&(t.words[t.length++]=r),t},f._prime=function(t){if(lt[t])return lt[t];var r;if(t==="k256")r=new At;else if(t==="p224")r=new Bt;else if(t==="p192")r=new Ct;else if(t==="p25519")r=new Et;else throw new Error("Unknown prime "+t);return lt[t]=r,r};function Y(p){if(typeof p=="string"){var t=f._prime(p);this.m=t.p,this.prime=t}else s(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}Y.prototype._verify1=function(t){s(t.negative===0,"red works only with positives"),s(t.red,"red works only with red numbers")},Y.prototype._verify2=function(t,r){s((t.negative|r.negative)===0,"red works only with positives"),s(t.red&&t.red===r.red,"red works only with red numbers")},Y.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},Y.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},Y.prototype.add=function(t,r){this._verify2(t,r);var i=t.add(r);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},Y.prototype.iadd=function(t,r){this._verify2(t,r);var i=t.iadd(r);return i.cmp(this.m)>=0&&i.isub(this.m),i},Y.prototype.sub=function(t,r){this._verify2(t,r);var i=t.sub(r);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},Y.prototype.isub=function(t,r){this._verify2(t,r);var i=t.isub(r);return i.cmpn(0)<0&&i.iadd(this.m),i},Y.prototype.shl=function(t,r){return this._verify1(t),this.imod(t.ushln(r))},Y.prototype.imul=function(t,r){return this._verify2(t,r),this.imod(t.imul(r))},Y.prototype.mul=function(t,r){return this._verify2(t,r),this.imod(t.mul(r))},Y.prototype.isqr=function(t){return this.imul(t,t.clone())},Y.prototype.sqr=function(t){return this.mul(t,t)},Y.prototype.sqrt=function(t){if(t.isZero())return t.clone();var r=this.m.andln(3);if(s(r%2===1),r===3){var i=this.m.add(new f(1)).iushrn(2);return this.pow(t,i)}for(var a=this.m.subn(1),d=0;!a.isZero()&&a.andln(1)===0;)d++,a.iushrn(1);s(!a.isZero());var c=new f(1).toRed(this),v=c.redNeg(),u=this.m.subn(1).iushrn(1),e=this.m.bitLength();for(e=new f(2*e*e).toRed(this);this.pow(e,u).cmp(v)!==0;)e.redIAdd(v);for(var l=this.pow(e,a),b=this.pow(t,a.addn(1).iushrn(1)),_=this.pow(t,a),C=d;_.cmp(c)!==0;){for(var q=_,O=0;q.cmp(c)!==0;O++)q=q.redSqr();s(O<C);var R=this.pow(l,new f(1).iushln(C-O-1));b=b.redMul(R),l=R.redSqr(),_=_.redMul(l),C=O}return b},Y.prototype.invm=function(t){var r=t._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},Y.prototype.pow=function(t,r){if(r.isZero())return new f(1).toRed(this);if(r.cmpn(1)===0)return t.clone();var i=4,a=new Array(1<<i);a[0]=new f(1).toRed(this),a[1]=t;for(var d=2;d<a.length;d++)a[d]=this.mul(a[d-1],t);var c=a[0],v=0,u=0,e=r.bitLength()%26;for(e===0&&(e=26),d=r.length-1;d>=0;d--){for(var l=r.words[d],b=e-1;b>=0;b--){var _=l>>b&1;if(c!==a[0]&&(c=this.sqr(c)),_===0&&v===0){u=0;continue}v<<=1,v|=_,u++,!(u!==i&&(d!==0||b!==0))&&(c=this.mul(c,a[v]),u=0,v=0)}e=26}return c},Y.prototype.convertTo=function(t){var r=t.umod(this.m);return r===t?r.clone():r},Y.prototype.convertFrom=function(t){var r=t.clone();return r.red=null,r},f.mont=function(t){return new It(t)};function It(p){Y.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new f(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m(It,Y),It.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},It.prototype.convertFrom=function(t){var r=this.imod(t.mul(this.rinv));return r.red=null,r},It.prototype.imul=function(t,r){if(t.isZero()||r.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(r),a=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=i.isub(a).iushrn(this.shift),c=d;return d.cmp(this.m)>=0?c=d.isub(this.m):d.cmpn(0)<0&&(c=d.iadd(this.m)),c._forceRed(this)},It.prototype.mul=function(t,r){if(t.isZero()||r.isZero())return new f(0)._forceRed(this);var i=t.mul(r),a=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=i.isub(a).iushrn(this.shift),c=d;return d.cmp(this.m)>=0?c=d.isub(this.m):d.cmpn(0)<0&&(c=d.iadd(this.m)),c._forceRed(this)},It.prototype.invm=function(t){var r=this.imod(t._invmp(this.m).mul(this.r2));return r._forceRed(this)}})(h,Ft)}(J0);var G0=J0.exports,Do=G0,Xm=zt.Buffer;function jm(h,n){return Xm.from(h.toRed(Do.mont(n.modulus)).redPow(new Do(n.publicExponent)).fromRed().toArray())}var No=jm,Qm=lf,X0=li,t2=Ki,$o=qo,Uo=Po,j0=G0,e2=No,r2=l0,sr=zt.Buffer,i2=function(n,o,s){var m;n.padding?m=n.padding:s?m=1:m=4;var f=Qm(n),g;if(m===4)g=n2(f,o);else if(m===1)g=f2(f,o,s);else if(m===3){if(g=new j0(o),g.cmp(f.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return s?r2(g,f):e2(g,f)};function n2(h,n){var o=h.modulus.byteLength(),s=n.length,m=t2("sha1").update(sr.alloc(0)).digest(),f=m.length,g=2*f;if(s>o-g-2)throw new Error("message too long");var y=sr.alloc(o-s-g-2),S=o-f-1,B=X0(f),M=Uo(sr.concat([m,y,sr.alloc(1,1),n],S),$o(B,S)),x=Uo(B,$o(M,f));return new j0(sr.concat([sr.alloc(1),x,M],o))}function f2(h,n,o){var s=n.length,m=h.modulus.byteLength();if(s>m-11)throw new Error("message too long");var f;return o?f=sr.alloc(m-s-3,255):f=a2(m-s-3),new j0(sr.concat([sr.from([0,o?1:2]),f,sr.alloc(1),n],m))}function a2(h){for(var n=sr.allocUnsafe(h),o=0,s=X0(h*2),m=0,f;o<h;)m===s.length&&(s=X0(h*2),m=0),f=s[m++],f&&(n[o++]=f);return n}var h2=lf,Lo=qo,Oo=Po,zo=G0,s2=l0,o2=Ki,u2=No,on=zt.Buffer,l2=function(n,o,s){var m;n.padding?m=n.padding:s?m=1:m=4;var f=h2(n),g=f.modulus.byteLength();if(o.length>g||new zo(o).cmp(f.modulus)>=0)throw new Error("decryption error");var y;s?y=u2(new zo(o),f):y=s2(o,f);var S=on.alloc(g-y.length);if(y=on.concat([S,y],g),m===4)return d2(f,y);if(m===1)return c2(f,y,s);if(m===3)return y;throw new Error("unknown padding")};function d2(h,n){var o=h.modulus.byteLength(),s=o2("sha1").update(on.alloc(0)).digest(),m=s.length;if(n[0]!==0)throw new Error("decryption error");var f=n.slice(1,m+1),g=n.slice(m+1),y=Oo(f,Lo(g,m)),S=Oo(g,Lo(y,o-m-1));if(v2(s,S.slice(0,m)))throw new Error("decryption error");for(var B=m;S[B]===0;)B++;if(S[B++]!==1)throw new Error("decryption error");return S.slice(B)}function c2(h,n,o){for(var s=n.slice(0,2),m=2,f=0;n[m++]!==0;)if(m>=n.length){f++;break}var g=n.slice(2,m-1);if((s.toString("hex")!=="0002"&&!o||s.toString("hex")!=="0001"&&o)&&f++,g.length<8&&f++,f)throw new Error("decryption error");return n.slice(m)}function v2(h,n){h=on.from(h),n=on.from(n);var o=0,s=h.length;h.length!==n.length&&(o++,s=Math.min(h.length,n.length));for(var m=-1;++m<s;)o+=h[m]^n[m];return o}(function(h){h.publicEncrypt=i2,h.privateDecrypt=l2,h.privateEncrypt=function(o,s){return h.publicEncrypt(o,s,!0)},h.publicDecrypt=function(o,s){return h.privateDecrypt(o,s,!0)}})(Fo);var un={};function Ko(){throw new Error(`secure random number generation not supported by this browser
|
|
16
16
|
use chrome, FireFox or Internet Explorer 11`)}var Ho=zt,Zo=li,Wo=Ho.Buffer,Vo=Ho.kMaxLength,Q0=Ft.crypto||Ft.msCrypto,Yo=Math.pow(2,32)-1;function Jo(h,n){if(typeof h!="number"||h!==h)throw new TypeError("offset must be a number");if(h>Yo||h<0)throw new TypeError("offset must be a uint32");if(h>Vo||h>n)throw new RangeError("offset out of range")}function Go(h,n,o){if(typeof h!="number"||h!==h)throw new TypeError("size must be a number");if(h>Yo||h<0)throw new TypeError("size must be a uint32");if(h+n>o||h>Vo)throw new RangeError("buffer too small")}Q0&&Q0.getRandomValues||!ye.browser?(un.randomFill=p2,un.randomFillSync=m2):(un.randomFill=Ko,un.randomFillSync=Ko);function p2(h,n,o,s){if(!Wo.isBuffer(h)&&!(h instanceof Ft.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if(typeof n=="function")s=n,n=0,o=h.length;else if(typeof o=="function")s=o,o=h.length-n;else if(typeof s!="function")throw new TypeError('"cb" argument must be a function');return Jo(n,h.length),Go(o,n,h.length),Xo(h,n,o,s)}function Xo(h,n,o,s){if(ye.browser){var m=h.buffer,f=new Uint8Array(m,n,o);if(Q0.getRandomValues(f),s){ye.nextTick(function(){s(null,h)});return}return h}if(s){Zo(o,function(y,S){if(y)return s(y);S.copy(h,n),s(null,h)});return}var g=Zo(o);return g.copy(h,n),h}function m2(h,n,o){if(typeof n=="undefined"&&(n=0),!Wo.isBuffer(h)&&!(h instanceof Ft.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return Jo(n,h.length),o===void 0&&(o=h.length-n),Go(o,n,h.length),Xo(h,n,o)}var jo;function Qo(){if(jo)return Lt;jo=1,Lt.randomBytes=Lt.rng=Lt.pseudoRandomBytes=Lt.prng=li,Lt.createHash=Lt.Hash=Ki,Lt.createHmac=Lt.Hmac=La;var h=Td,n=Object.keys(h),o=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(n);Lt.getHashes=function(){return o};var s=_n;Lt.pbkdf2=s.pbkdf2,Lt.pbkdf2Sync=s.pbkdf2Sync;var m=rr;Lt.Cipher=m.Cipher,Lt.createCipher=m.createCipher,Lt.Cipheriv=m.Cipheriv,Lt.createCipheriv=m.createCipheriv,Lt.Decipher=m.Decipher,Lt.createDecipher=m.createDecipher,Lt.Decipheriv=m.Decipheriv,Lt.createDecipheriv=m.createDecipheriv,Lt.getCiphers=m.getCiphers,Lt.listCiphers=m.listCiphers;var f=R1();Lt.DiffieHellmanGroup=f.DiffieHellmanGroup,Lt.createDiffieHellmanGroup=f.createDiffieHellmanGroup,Lt.getDiffieHellman=f.getDiffieHellman,Lt.createDiffieHellman=f.createDiffieHellman,Lt.DiffieHellman=f.DiffieHellman;var g=Wm();Lt.createSign=g.createSign,Lt.Sign=g.Sign,Lt.createVerify=g.createVerify,Lt.Verify=g.Verify,Lt.createECDH=Ym();var y=Fo;Lt.publicEncrypt=y.publicEncrypt,Lt.privateEncrypt=y.privateEncrypt,Lt.publicDecrypt=y.publicDecrypt,Lt.privateDecrypt=y.privateDecrypt;var S=un;return Lt.randomFill=S.randomFill,Lt.randomFillSync=S.randomFillSync,Lt.createCredentials=function(){throw new Error(`sorry, createCredentials is not implemented yet
|
|
17
17
|
we accept pull requests
|
|
18
|
-
https://github.com/browserify/crypto-browserify`)},Lt.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6},Lt}var g2=Qo();const b2=ke(g2);function ta(h){const n=b2.createHash("sha256").update(h).digest("hex");return parseInt(n.slice(0,8),16)%1e4/100}function tu(h,n){const o=ta(h);let s=0;for(const m of n.variants)if(s+=m.weight,o<s)return m.value;return null}function eu(h,n){const o=n.user_id||n.id||n.email;if(!h||typeof h!="object"||!o)return null;switch(h.strategy){case"percentage":{if(!("percentage"in h)||!("salt"in h))return null;const{percentage:s,salt:m}=h;return ta(`${o}.${m}`)<s?!0:null}case"variant":{if(!("variants"in h))return null;const{salt:s,variants:m}=h;return tu(`${o}.${s}`,m)}default:return null}}function ru(h,n){var f;if(!(h.targeting_rules||[]).every(g=>{var y;if(g.type==="segment"){const S=(y=h.segmentsById)==null?void 0:y[g.segment_id];return S?Mu(S,n):!1}else return aa(g,n)}))return null;const m=h.rollout?eu(h.rollout,n):null;return(f=m!=null?m:h.value)!=null?f:null}let ln={getItem:h=>typeof localStorage!="undefined"?localStorage.getItem(h):null,setItem:(h,n)=>{typeof localStorage!="undefined"&&localStorage.setItem(h,n)}};function y2(h){ln=h}function iu(h){return`flagmint_${h}_flags`}function nu(h){return`flagmint_${h}_context`}function fu(h,n){try{const o=ln.getItem(iu(h));if(!o)return null;const s=JSON.parse(o);return Date.now()-s.ts>n?null:s.data}catch(o){return null}}function au(h,n){try{ln.setItem(iu(h),JSON.stringify({ts:Date.now(),data:n}))}catch(o){}}function hu(h){try{const n=ln.getItem(nu(h));return n?JSON.parse(n):null}catch(n){return null}}function su(h,n){try{ln.setItem(nu(h),JSON.stringify(n))}catch(o){}}const w2=Object.freeze(Object.defineProperty({__proto__:null,loadCachedContext:hu,loadCachedFlags:fu,saveCachedContext:su,saveCachedFlags:au,setCacheStorage:y2},Symbol.toStringTag,{value:"Module"})),M2=24*60*60*1e3;function ou(){switch(typeof process!="undefined"?process.env.NEXT_PUBLIC_NODE_ENV||process.env.NODE_ENV:"development"){case"production":return{rest:"https://api.flagmint.com/evaluator/evaluate",ws:"wss://api.flagmint.com/ws/sdk"};case"staging":return{rest:"https://staging-api.flagmint.com/evaluator/evaluate",ws:"wss://staging-api.flagmint.com/ws/sdk"};case"development":default:return{rest:"http://localhost:3000/evaluator/evaluate",ws:"ws://localhost:3000/ws/sdk"}}}const x2=ou().rest,_2=ou().ws;class S2{constructor(n){var o,s,m,f,g,y,S;if(this.flags={},this.refreshIntervalId=null,this.rawFlags={},this.isInitialized=!1,this.subscribers=new Set,this.apiKey=n.apiKey,this.enableOfflineCache=(o=n.enableOfflineCache)!=null?o:!0,this.persistContext=(s=n.persistContext)!=null?s:!1,this.cacheTTL=M2,this.onError=n.onError,this.restEndpoint=(m=n.restEndpoint)!=null?m:x2,this.wsEndpoint=(f=n.wsEndpoint)!=null?f:_2,this.cacheAdapter=(g=n.cacheAdapter)!=null?g:{loadFlags:fu,saveFlags:au,loadContext:hu,saveContext:su},this.context=n.context||{},this.rawFlags=(y=n.rawFlags)!=null?y:{},this.previewMode=n.previewMode||!1,this.deferInitialization=(S=n.deferInitialization)!=null?S:!1,this.previewMode&&this.rawFlags&&Object.keys(this.rawFlags).length>0){this.flags=this.evaluateLocally(this.rawFlags,this.context),this.readyPromise=Promise.resolve(),this.resolveReady=()=>{},this.rejectReady=()=>{},this.isInitialized=!0;return}else this.previewMode&&!this.rawFlags&&console.error("[FlagClient] No raw flags provided for preview mode. Defaulting to remote fetch.");this.readyPromise=new Promise((B,M)=>{this.resolveReady=B,this.rejectReady=M}),console.log("[FlagClient] Constructor called with options:",n,this.deferInitialization),this.deferInitialization?(console.log("[FlagClient] Initialization deferred. Call ready() to initialize."),this.initializationOptions=n):this.initialize(n)}initialize(n){return De(this,null,function*(){var o;if(console.log("[FlagClient] Initialization started with options:",n),this.isInitialized){console.log("[FlagClient] Already initialized, skipping.");return}try{if(this.persistContext){const s=yield Promise.resolve(this.cacheAdapter.loadContext(this.apiKey));s&&(this.context=s)}if(this.enableOfflineCache){const s=yield Promise.resolve(this.cacheAdapter.loadFlags(this.apiKey,this.cacheTTL));s&&(this.flags=s,this.notifySubscribers())}yield this.setupTransport(n),this.isInitialized=!0,this.resolveReady()}catch(s){this.rejectReady(s),(o=this.onError)==null||o.call(this,s)}})}setupTransport(n){return De(this,null,function*(){var f;console.log("[FlagClient] setupTransport() started");const o=(f=n.transportMode)!=null?f:"auto",s=()=>De(this,null,function*(){console.log("[FlagClient] Initializing WebSocket transport...");const g=new fa(this.wsEndpoint,this.apiKey);return yield g.init(),console.log("[FlagClient] WebSocket transport initialized"),g}),m=()=>{const g=new na(this.restEndpoint,this.apiKey,this.context,{pollIntervalMs:12e5,maxBackoffMs:6e4,backoffMultiplier:2});return g.onFlagsUpdated(y=>{console.log("[FlagClient] Flags updated via long polling:",y),this.updateFlags(y)}),g.init(),g};try{if(o==="websocket")this.transport=yield s();else if(o==="long-polling")this.transport=m();else try{this.transport=yield s()}catch(y){console.warn("[FlagClient] WebSocket failed, falling back to long polling"),this.transport=m()}typeof this.transport.onFlagsUpdated=="function"&&this.transport.onFlagsUpdated(y=>{console.log("[FlagClient] Flags updated via transport:",y),this.updateFlags(y)}),console.log("[FlagClient] Fetching flags...",this.context);const g=yield this.transport.fetchFlags(this.context);console.log("[FlagClient] Initial flags fetched:",g),this.updateFlags(g),this.resolveReady()}catch(g){throw console.error("[FlagClient] setupTransport error:",g),this.rejectReady(g),this.onError&&this.onError(g instanceof Error?g:new Error(String(g))),g}})}updateFlags(n){this.flags=n,this.enableOfflineCache&&Promise.resolve(this.cacheAdapter.saveFlags(this.apiKey,n)),this.notifySubscribers()}notifySubscribers(){this.subscribers.forEach(n=>{try{n(this.flags)}catch(o){console.error("[FlagClient] Error in subscriber callback:",o)}})}subscribe(n){return this.subscribers.add(n),n(this.flags),()=>{this.subscribers.delete(n)}}getFlags(){return df({},this.flags)}getFlag(n,o){var s;return(s=this.flags[n])!=null?s:o}updateContext(n){return De(this,null,function*(){var o;if(this.context=df(df({},this.context),n),this.initializationOptions&&(this.initializationOptions.context=this.context),console.log("[FlagClient] Context updated:",this.context),this.persistContext&&(yield Promise.resolve(this.cacheAdapter.saveContext(this.apiKey,this.context))),this.transport&&typeof this.transport.fetchFlags=="function")try{const s=yield this.transport.fetchFlags(this.context);console.log("[FlagClient] Context persisted:",this.context,s,typeof this.transport.onFlagsUpdated),typeof this.transport.onFlagsUpdated=="function"&&this.transport.onFlagsUpdated(m=>{console.log("[FlagClient] Flags updated via transport:",m),this.updateFlags(m)})}catch(s){console.error("[FlagClient] Error updating flags after context change:",s),(o=this.onError)==null||o.call(this,s)}})}destroy(){this.refreshIntervalId&&clearInterval(this.refreshIntervalId),this.subscribers.clear(),this.transport&&this.transport.destroy()}ready(n=5e3){return De(this,null,function*(){if(console.log("[FlagClient] Waiting for client to be ready...",this.initializationOptions),this.deferInitialization&&!this.isInitialized&&this.initializationOptions&&(console.log("[FlagClient] Deferred initialization triggered by ready() call",this.initializationOptions),yield this.initialize(this.initializationOptions)),
|
|
18
|
+
https://github.com/browserify/crypto-browserify`)},Lt.constants={DH_CHECK_P_NOT_SAFE_PRIME:2,DH_CHECK_P_NOT_PRIME:1,DH_UNABLE_TO_CHECK_GENERATOR:4,DH_NOT_SUITABLE_GENERATOR:8,NPN_ENABLED:1,ALPN_ENABLED:1,RSA_PKCS1_PADDING:1,RSA_SSLV23_PADDING:2,RSA_NO_PADDING:3,RSA_PKCS1_OAEP_PADDING:4,RSA_X931_PADDING:5,RSA_PKCS1_PSS_PADDING:6,POINT_CONVERSION_COMPRESSED:2,POINT_CONVERSION_UNCOMPRESSED:4,POINT_CONVERSION_HYBRID:6},Lt}var g2=Qo();const b2=ke(g2);function ta(h){const n=b2.createHash("sha256").update(h).digest("hex");return parseInt(n.slice(0,8),16)%1e4/100}function tu(h,n){const o=ta(h);let s=0;for(const m of n.variants)if(s+=m.weight,o<s)return m.value;return null}function eu(h,n){const o=n.user_id||n.id||n.email;if(!h||typeof h!="object"||!o)return null;switch(h.strategy){case"percentage":{if(!("percentage"in h)||!("salt"in h))return null;const{percentage:s,salt:m}=h;return ta(`${o}.${m}`)<s?!0:null}case"variant":{if(!("variants"in h))return null;const{salt:s,variants:m}=h;return tu(`${o}.${s}`,m)}default:return null}}function ru(h,n){var f;if(!(h.targeting_rules||[]).every(g=>{var y;if(g.type==="segment"){const S=(y=h.segmentsById)==null?void 0:y[g.segment_id];return S?Mu(S,n):!1}else return aa(g,n)}))return null;const m=h.rollout?eu(h.rollout,n):null;return(f=m!=null?m:h.value)!=null?f:null}let ln={getItem:h=>typeof localStorage!="undefined"?localStorage.getItem(h):null,setItem:(h,n)=>{typeof localStorage!="undefined"&&localStorage.setItem(h,n)}};function y2(h){ln=h}function iu(h){return`flagmint_${h}_flags`}function nu(h){return`flagmint_${h}_context`}function fu(h,n){try{const o=ln.getItem(iu(h));if(!o)return null;const s=JSON.parse(o);return Date.now()-s.ts>n?null:s.data}catch(o){return null}}function au(h,n){try{ln.setItem(iu(h),JSON.stringify({ts:Date.now(),data:n}))}catch(o){}}function hu(h){try{const n=ln.getItem(nu(h));return n?JSON.parse(n):null}catch(n){return null}}function su(h,n){try{ln.setItem(nu(h),JSON.stringify(n))}catch(o){}}const w2=Object.freeze(Object.defineProperty({__proto__:null,loadCachedContext:hu,loadCachedFlags:fu,saveCachedContext:su,saveCachedFlags:au,setCacheStorage:y2},Symbol.toStringTag,{value:"Module"})),M2=24*60*60*1e3;function ou(){switch(typeof process!="undefined"?process.env.NEXT_PUBLIC_NODE_ENV||process.env.NODE_ENV:"development"){case"production":return{rest:"https://api.flagmint.com/evaluator/evaluate",ws:"wss://api.flagmint.com/ws/sdk"};case"staging":return{rest:"https://staging-api.flagmint.com/evaluator/evaluate",ws:"wss://staging-api.flagmint.com/ws/sdk"};case"development":default:return{rest:"http://localhost:3000/evaluator/evaluate",ws:"ws://localhost:3000/ws/sdk"}}}const x2=ou().rest,_2=ou().ws;class S2{constructor(n){var o,s,m,f,g,y,S;if(this.flags={},this.refreshIntervalId=null,this.rawFlags={},this.isInitialized=!1,this.subscribers=new Set,this.apiKey=n.apiKey,this.enableOfflineCache=(o=n.enableOfflineCache)!=null?o:!0,this.persistContext=(s=n.persistContext)!=null?s:!1,this.cacheTTL=M2,this.onError=n.onError,this.restEndpoint=(m=n.restEndpoint)!=null?m:x2,this.wsEndpoint=(f=n.wsEndpoint)!=null?f:_2,this.cacheAdapter=(g=n.cacheAdapter)!=null?g:{loadFlags:fu,saveFlags:au,loadContext:hu,saveContext:su},this.context=n.context||{},this.rawFlags=(y=n.rawFlags)!=null?y:{},this.previewMode=n.previewMode||!1,this.deferInitialization=(S=n.deferInitialization)!=null?S:!1,this.previewMode&&this.rawFlags&&Object.keys(this.rawFlags).length>0){this.flags=this.evaluateLocally(this.rawFlags,this.context),this.readyPromise=Promise.resolve(),this.resolveReady=()=>{},this.rejectReady=()=>{},this.isInitialized=!0;return}else this.previewMode&&!this.rawFlags&&console.error("[FlagClient] No raw flags provided for preview mode. Defaulting to remote fetch.");this.readyPromise=new Promise((B,M)=>{this.resolveReady=B,this.rejectReady=M}),console.log("[FlagClient] Constructor called with options:",n,this.deferInitialization),this.deferInitialization?(console.log("[FlagClient] Initialization deferred. Call ready() to initialize."),this.initializationOptions=n):this.initialize(n)}initialize(n){return De(this,null,function*(){var o;if(console.log("[FlagClient] Initialization started with options:",n),this.isInitialized){console.log("[FlagClient] Already initialized, skipping.");return}try{if(this.persistContext){const s=yield Promise.resolve(this.cacheAdapter.loadContext(this.apiKey));s&&(this.context=s)}if(this.enableOfflineCache){const s=yield Promise.resolve(this.cacheAdapter.loadFlags(this.apiKey,this.cacheTTL));s&&(this.flags=s,this.notifySubscribers())}yield this.setupTransport(n),this.isInitialized=!0,this.resolveReady()}catch(s){this.rejectReady(s),(o=this.onError)==null||o.call(this,s)}})}setupTransport(n){return De(this,null,function*(){var f;console.log("[FlagClient] setupTransport() started");const o=(f=n.transportMode)!=null?f:"auto",s=()=>De(this,null,function*(){console.log("[FlagClient] Initializing WebSocket transport...");const g=new fa(this.wsEndpoint,this.apiKey);return yield g.init(),console.log("[FlagClient] WebSocket transport initialized"),g}),m=()=>{const g=new na(this.restEndpoint,this.apiKey,this.context,{pollIntervalMs:12e5,maxBackoffMs:6e4,backoffMultiplier:2});return g.onFlagsUpdated(y=>{console.log("[FlagClient] Flags updated via long polling:",y),this.updateFlags(y)}),g.init(),g};try{if(o==="websocket")this.transport=yield s();else if(o==="long-polling")this.transport=m();else try{this.transport=yield s()}catch(y){console.warn("[FlagClient] WebSocket failed, falling back to long polling"),this.transport=m()}typeof this.transport.onFlagsUpdated=="function"&&this.transport.onFlagsUpdated(y=>{console.log("[FlagClient] Flags updated via transport:",y),this.updateFlags(y)}),console.log("[FlagClient] Fetching flags...",this.context);const g=yield this.transport.fetchFlags(this.context);console.log("[FlagClient] Initial flags fetched:",g),this.updateFlags(g),this.resolveReady()}catch(g){throw console.error("[FlagClient] setupTransport error:",g),this.rejectReady(g),this.onError&&this.onError(g instanceof Error?g:new Error(String(g))),g}})}updateFlags(n){this.flags=n,this.enableOfflineCache&&Promise.resolve(this.cacheAdapter.saveFlags(this.apiKey,n)),this.notifySubscribers()}notifySubscribers(){this.subscribers.forEach(n=>{try{n(this.flags)}catch(o){console.error("[FlagClient] Error in subscriber callback:",o)}})}subscribe(n){return this.subscribers.add(n),n(this.flags),()=>{this.subscribers.delete(n)}}getFlags(){return df({},this.flags)}getFlag(n,o){var s;return(s=this.flags[n])!=null?s:o}updateContext(n){return De(this,null,function*(){var o;if(this.context=df(df({},this.context),n),this.initializationOptions&&(this.initializationOptions.context=this.context),console.log("[FlagClient] Context updated:",this.context),this.persistContext&&(yield Promise.resolve(this.cacheAdapter.saveContext(this.apiKey,this.context))),this.transport&&typeof this.transport.fetchFlags=="function")try{const s=yield this.transport.fetchFlags(this.context);console.log("[FlagClient] Context persisted:",this.context,s,typeof this.transport.onFlagsUpdated),typeof this.transport.onFlagsUpdated=="function"&&this.transport.onFlagsUpdated(m=>{console.log("[FlagClient] Flags updated via transport:",m),this.updateFlags(m)})}catch(s){console.error("[FlagClient] Error updating flags after context change:",s),(o=this.onError)==null||o.call(this,s)}})}destroy(){this.refreshIntervalId&&clearInterval(this.refreshIntervalId),this.subscribers.clear(),this.transport&&this.transport.destroy()}ready(n=5e3){return De(this,null,function*(){if(console.log("[FlagClient] Waiting for client to be ready...",this.initializationOptions),this.deferInitialization&&!this.isInitialized&&this.initializationOptions&&(console.log("[FlagClient] Deferred initialization triggered by ready() call",this.initializationOptions),yield this.initialize(this.initializationOptions)),Object.keys(this.flags).length>0){console.log("[FlagClient] Ready with cached flags");return}yield this.waitForFlags(n),yield this.readyPromise})}evaluateLocally(n,o){const s={};for(const m in n){const f=ru(n[m],o);f!==null&&(s[m]=f)}return s}waitForFlags(n){return new Promise(o=>{const s=setTimeout(()=>{console.warn("[FlagClient] Flag fetch timeout after",n,"ms"),m(),o()},n),m=this.subscribe(f=>{Object.keys(f).length>0&&(clearTimeout(s),m(),console.log("[FlagClient] Flags received"),o())})})}}function uu(h){return`flagmint_${h}_flags`}function lu(h){return`flagmint_${h}_context`}let Fr=null;function A2(h){Fr=h}function B2(h,n){return De(this,null,function*(){if(!Fr)throw new Error("Async storage not set");try{const o=yield Fr.getItem(uu(h));if(!o)return null;const s=JSON.parse(o);return Date.now()-s.ts>n?null:s.data}catch(o){return null}})}function E2(h,n){return De(this,null,function*(){if(!Fr)throw new Error("Async storage not set");try{yield Fr.setItem(uu(h),JSON.stringify({ts:Date.now(),data:n}))}catch(o){}})}function k2(h){return De(this,null,function*(){if(!Fr)throw new Error("Async storage not set");try{const n=yield Fr.getItem(lu(h));return n?JSON.parse(n):null}catch(n){return null}})}function I2(h,n){return De(this,null,function*(){if(!Fr)throw new Error("Async storage not set");try{yield Fr.setItem(lu(h),JSON.stringify(n))}catch(o){}})}const R2=Object.freeze(Object.defineProperty({__proto__:null,loadCachedContext:k2,loadCachedFlags:B2,saveCachedContext:I2,saveCachedFlags:E2,setAsyncCacheStorage:A2},Symbol.toStringTag,{value:"Module"}));typeof globalThis.Buffer=="undefined"&&(globalThis.Buffer=Ke.Buffer),ge.FlagClient=S2,ge.LongPollingTransport=na,ge.WebSocketTransport=fa,ge.asyncCache=R2,ge.evaluateFlagValue=ru,ge.evaluateRollout=eu,ge.hashToPercentage=ta,ge.pickVariant=tu,ge.syncCache=w2,Object.defineProperty(ge,Symbol.toStringTag,{value:"Module"})});
|