flagmint-js-sdk 1.0.6 → 1.0.8
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 +32 -5
- package/dist/flagmint.umd.js +2 -2
- package/dist/sdk/core/client.d.ts +35 -0
- package/package.json +1 -1
package/dist/flagmint.cjs.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=kn,o=g0,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;h.Buffer=y,h.SlowBuffer=N,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 k(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 q=W(E);if(q)return q;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 k(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 q=T.write(E,w);return q!==A&&(T=T.slice(0,q)),T}function I(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 I(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"||Ft(E.length)?g(0):I(E);if(E.type==="Buffer"&&Array.isArray(E.data))return I(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 N(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,q=A.length;for(let V=0,U=Math.min(T,q);V<U;++V)if(w[V]!==A[V]){T=w[V],q=A[V];break}return T<q?-1:q<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 q=y.allocUnsafe(A);let V=0;for(T=0;T<w.length;++T){let U=w[T];if(dt(U,Uint8Array))V+U.length>q.length?(y.isBuffer(U)||(U=y.from(U)),U.copy(q,V)):Uint8Array.prototype.set.call(q,U,V);else if(y.isBuffer(U))U.copy(q,V);else throw new TypeError('"list" argument must be an Array of Buffers');V+=U.length}return q};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 q=!1;for(;;)switch(w){case"ascii":case"latin1":case"binary":return A;case"utf8":case"utf-8":return Dt(E).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A*2;case"hex":return A>>>1;case"base64":return Pt(E).length;default:if(q)return T?-1:Dt(E).length;w=(""+w).toLowerCase(),q=!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,q,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),q===void 0&&(q=0),V===void 0&&(V=this.length),A<0||T>w.length||q<0||V>this.length)throw new RangeError("out of range index");if(q>=V&&A>=T)return 0;if(q>=V)return-1;if(A>=T)return 1;if(A>>>=0,T>>>=0,q>>>=0,V>>>=0,this===w)return 0;let U=V-q,X=T-A;const Tt=Math.min(U,X),G=this.slice(q,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,q){if(E.length===0)return-1;if(typeof A=="string"?(T=A,A=0):A>2147483647?A=2147483647:A<-2147483648&&(A=-2147483648),A=+A,Ft(A)&&(A=q?0:E.length-1),A<0&&(A=E.length+A),A>=E.length){if(q)return-1;A=E.length-1}else if(A<0)if(q)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,q);if(typeof w=="number")return w=w&255,typeof Uint8Array.prototype.indexOf=="function"?q?Uint8Array.prototype.indexOf.call(E,w,A):Uint8Array.prototype.lastIndexOf.call(E,w,A):Ct(E,[w],A,T,q);throw new TypeError("val must be string, number or Buffer")}function Ct(E,w,A,T,q){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(q){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 q=E.length-A;T?(T=Number(T),T>q&&(T=q)):T=q;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(Ft(X))return U;E[A+U]=X}return U}function Y(E,w,A,T){return j(Dt(w,E.length-A),E,A,T)}function kt(E,w,A,T){return j(et(w),E,A,T)}function p(E,w,A,T){return j(Pt(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,q){if(A===void 0)q="utf8",T=this.length,A=0;else if(T===void 0&&typeof A=="string")q=A,T=this.length,A=0;else if(isFinite(A))A=A>>>0,isFinite(T)?(T=T>>>0,q===void 0&&(q="utf8")):(q=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");q||(q="utf8");let U=!1;for(;;)switch(q){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 kt(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: "+q);q=(""+q).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 q=w;for(;q<A;){const V=E[q];let U=null,X=V>239?4:V>223?3:V>191?2:1;if(q+X<=A){let Tt,G,rt,Rt;switch(X){case 1:V<128&&(U=V);break;case 2:Tt=E[q+1],(Tt&192)===128&&(Rt=(V&31)<<6|Tt&63,Rt>127&&(U=Rt));break;case 3:Tt=E[q+1],G=E[q+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[q+1],G=E[q+2],rt=E[q+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),q+=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 q=w;q<A;++q)T+=String.fromCharCode(E[q]&127);return T}function v(E,w,A){let T="";A=Math.min(E.length,A);for(let q=w;q<A;++q)T+=String.fromCharCode(E[q]);return T}function u(E,w,A){const T=E.length;(!w||w<0)&&(w=0),(!A||A<0||A>T)&&(A=T);let q="";for(let V=w;V<A;++V)q+=Q[E[V]];return q}function e(E,w,A){const T=E.slice(w,A);let q="";for(let V=0;V<T.length-1;V+=2)q+=String.fromCharCode(T[V]+T[V+1]*256);return q}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 q=this.subarray(w,A);return Object.setPrototypeOf(q,y.prototype),q};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 q=this[w],V=1,U=0;for(;++U<A&&(V*=256);)q+=this[w+U]*V;return q},y.prototype.readUintBE=y.prototype.readUIntBE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let q=this[w+--A],V=1;for(;A>0&&(V*=256);)q+=this[w+--A]*V;return q},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 q=A+this[++w]*pe(2,8)+this[++w]*pe(2,16)+this[++w]*pe(2,24),V=this[++w]+this[++w]*pe(2,8)+this[++w]*pe(2,16)+T*pe(2,24);return BigInt(q)+(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 q=A*pe(2,24)+this[++w]*pe(2,16)+this[++w]*pe(2,8)+this[++w],V=this[++w]*pe(2,24)+this[++w]*pe(2,16)+this[++w]*pe(2,8)+T;return(BigInt(q)<<BigInt(32))+BigInt(V)}),y.prototype.readIntLE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let q=this[w],V=1,U=0;for(;++U<A&&(V*=256);)q+=this[w+U]*V;return V*=128,q>=V&&(q-=Math.pow(2,8*A)),q},y.prototype.readIntBE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let q=A,V=1,U=this[w+--q];for(;q>0&&(V*=256);)U+=this[w+--q]*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 q=this[w+4]+this[w+5]*pe(2,8)+this[w+6]*pe(2,16)+(T<<24);return(BigInt(q)<<BigInt(32))+BigInt(A+this[++w]*pe(2,8)+this[++w]*pe(2,16)+this[++w]*pe(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 q=(A<<24)+this[++w]*pe(2,16)+this[++w]*pe(2,8)+this[++w];return(BigInt(q)<<BigInt(32))+BigInt(this[++w]*pe(2,24)+this[++w]*pe(2,16)+this[++w]*pe(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,q,V){if(!y.isBuffer(E))throw new TypeError('"buffer" argument must be a Buffer instance');if(w>q||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,q){if(w=+w,A=A>>>0,T=T>>>0,!q){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,q){if(w=+w,A=A>>>0,T=T>>>0,!q){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,q){Z(w,T,q,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,q){Z(w,T,q,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,q){if(w=+w,A=A>>>0,!q){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,q){if(w=+w,A=A>>>0,!q){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 F(E,w,A,T,q,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,q){return w=+w,A=A>>>0,q||F(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,q){return w=+w,A=A>>>0,q||F(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,q){if(!y.isBuffer(w))throw new TypeError("argument should be a Buffer");if(T||(T=0),!q&&q!==0&&(q=this.length),A>=w.length&&(A=w.length),A||(A=0),q>0&&q<T&&(q=T),q===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(q<0)throw new RangeError("sourceEnd out of bounds");q>this.length&&(q=this.length),w.length-A<q-T&&(q=w.length-A+T);const V=q-T;return this===w&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(A,T,q):Uint8Array.prototype.set.call(w,this.subarray(T,q),A),V},y.prototype.fill=function(w,A,T,q){if(typeof w=="string"){if(typeof A=="string"?(q=A,A=0,T=this.length):typeof T=="string"&&(q=T,T=this.length),q!==void 0&&typeof q!="string")throw new TypeError("encoding must be a string");if(typeof q=="string"&&!y.isEncoding(q))throw new TypeError("Unknown encoding: "+q);if(w.length===1){const U=w.charCodeAt(0);(q==="utf8"&&U<128||q==="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,q),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 $(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(q){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:q,writable:!0})}toString(){return`${this.name} [${E}]: ${this.message}`}}}$("ERR_BUFFER_OUT_OF_BOUNDS",function(E){return E?`${E} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),$("ERR_INVALID_ARG_TYPE",function(E,w){return`The "${E}" argument must be of type number. Received type ${typeof w}`},TypeError),$("ERR_OUT_OF_RANGE",function(E,w,A){let T=`The value of "${E}" is out of range.`,q=A;return Number.isInteger(A)&&Math.abs(A)>pe(2,32)?q=K(String(A)):typeof A=="bigint"&&(q=String(A),(A>pe(BigInt(2),BigInt(32))||A<-pe(BigInt(2),BigInt(32)))&&(q=K(q)),q+="n"),T+=` It must be ${w}. Received ${q}`,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 It(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,q,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)}It(T,q,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 Dt(E,w){w=w||1/0;let A;const T=E.length;let q=null;const V=[];for(let U=0;U<T;++U){if(A=E.charCodeAt(U),A>55295&&A<57344){if(!q){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}q=A;continue}if(A<56320){(w-=3)>-1&&V.push(239,191,189),q=A;continue}A=(q-55296<<10|A-56320)+65536}else q&&(w-=3)>-1&&V.push(239,191,189);if(q=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,q;const V=[];for(let U=0;U<E.length&&!((w-=2)<0);++U)A=E.charCodeAt(U),T=A>>8,q=A%256,V.push(q),V.push(T);return V}function Pt(E){return n.toByteArray(vt(E))}function j(E,w,A,T){let q;for(q=0;q<T&&!(q+A>=w.length||q>=E.length);++q)w[q+A]=E[q];return q}function dt(E,w){return E instanceof w||E!=null&&E.constructor!=null&&E.constructor.name!=null&&E.constructor.name===w.name}function Ft(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 q=0;q<16;++q)w[T+q]=E[A]+E[q]}return w}();function ct(E){return typeof BigInt=="undefined"?Lt:E}function Lt(){throw new Error("BigInt not supported")}})(gr);class xh{constructor(n,o,s,m={}){this.endpoint=n,this.apiKey=o,this.context=s,this.isStopped=!1,this.pollIntervalMs=m.pollIntervalMs||2e3}init(n){return Ue(this,null,function*(){for(;!this.isStopped;){try{const o=yield this.fetchFlags(this.context);n(o)}catch(o){console.error("[LongPollingTransport] poll error",o)}this.pollIntervalMs>0&&(yield new Promise(o=>setTimeout(o,this.pollIntervalMs)))}})}fetchFlags(n){return Ue(this,null,function*(){const o=yield fetch(this.endpoint,{method:"POST",headers:{"x-api-key":`${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({context:n})});if(console.log(o,"response"),o.status===401||o.status===403)throw new Error("Unauthorized: Invalid API key");if(!o.ok)throw new Error(`Unexpected response: ${o.status}`);return(yield o.json()).data})}destroy(){this.isStopped=!0}}class _h{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.retries=0}init(){return Ue(this,null,function*(){return this.connectWithRetry()})}connectWithRetry(){return new Promise((n,o)=>{const s=()=>{this.socket=new WebSocket(`${this.wsUrl}?apiKey=${this.apiKey}`),this.socket.onopen=()=>{this.isReady=!0,this.retries=0,this.context&&this.sendContext(this.context),n()},this.socket.onmessage=m=>{var f;try{const g=JSON.parse(m.data);g.type==="flags"&&(this.flags=g.flags,(f=this.onFlagsUpdatedCallback)==null||f.call(this,this.flags))}catch(g){console.warn("Failed to parse WebSocket message:",g)}},this.socket.onerror=m=>{console.error("[WebSocketTransport] Error:",m)},this.socket.onclose=m=>{if(this.isReady=!1,m.code===1008||m.code===4001)o(new Error("Unauthorized: Invalid API key"));else if(this.retries<this.maxRetries){const f=this.initialBackoffMs*Math.pow(2,this.retries);console.warn(`[WebSocketTransport] Reconnecting in ${f}ms (attempt ${this.retries+1})`),setTimeout(s,f),this.retries++}else o(new Error(`WebSocket failed after ${this.retries} retries`))}};s()})}fetchFlags(n){return Ue(this,null,function*(){var o;return this.context=n,this.isReady&&((o=this.socket)==null?void 0:o.readyState)===WebSocket.OPEN&&this.sendContext(n),this.flags})}onFlagsUpdated(n){this.onFlagsUpdatedCallback=n}destroy(){this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.close(),this.socket=null,this.flags={},this.context=null,this.isReady=!1,this.onFlagsUpdatedCallback=void 0}sendContext(n){var s;const o=JSON.stringify({type:"context",context:n});(s=this.socket)==null||s.send(o)}}function Sh(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 xu(h,n){return h.rules.every(o=>Sh(o,n))}var Ut={};const Li=typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{};function Ah(){throw new Error("setTimeout has not been defined")}function Bh(){throw new Error("clearTimeout has not been defined")}var Cr=Ah,qr=Bh;typeof Li.setTimeout=="function"&&(Cr=setTimeout);typeof Li.clearTimeout=="function"&&(qr=clearTimeout);function Eh(h){if(Cr===setTimeout)return setTimeout(h,0);if((Cr===Ah||!Cr)&&setTimeout)return Cr=setTimeout,setTimeout(h,0);try{return Cr(h,0)}catch(n){try{return Cr.call(null,h,0)}catch(o){return Cr.call(this,h,0)}}}function _u(h){if(qr===clearTimeout)return clearTimeout(h);if((qr===Bh||!qr)&&clearTimeout)return qr=clearTimeout,clearTimeout(h);try{return qr(h)}catch(n){try{return qr.call(null,h)}catch(o){return qr.call(this,h)}}}var Mr=[],hi=!1,Zr,pn=-1;function Su(){!hi||!Zr||(hi=!1,Zr.length?Mr=Zr.concat(Mr):pn=-1,Mr.length&&Ih())}function Ih(){if(!hi){var h=Eh(Su);hi=!0;for(var n=Mr.length;n;){for(Zr=Mr,Mr=[];++pn<n;)Zr&&Zr[pn].run();pn=-1,n=Mr.length}Zr=null,hi=!1,_u(h)}}function Au(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];Mr.push(new kh(h,n)),Mr.length===1&&!hi&&Eh(Ih)}function kh(h,n){this.fun=h,this.array=n}kh.prototype.run=function(){this.fun.apply(null,this.array)};var Bu="browser",Eu="browser",Iu=!0,ku={},Ru=[],Tu="",Cu={},qu={},Fu={};function Qr(){}var Pu=Qr,Du=Qr,$u=Qr,Nu=Qr,Uu=Qr,Lu=Qr,Ou=Qr;function zu(h){throw new Error("process.binding is not supported")}function Ku(){return"/"}function Hu(h){throw new Error("process.chdir is not supported")}function Zu(){return 0}var fi=Li.performance||{},Wu=fi.now||fi.mozNow||fi.msNow||fi.oNow||fi.webkitNow||function(){return new Date().getTime()};function Vu(h){var n=Wu.call(fi)*.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 Yu=new Date;function Ju(){var h=new Date,n=h-Yu;return n/1e3}var ye={nextTick:Au,title:Bu,browser:Iu,env:ku,argv:Ru,version:Tu,versions:Cu,on:Pu,addListener:Du,once:$u,off:Nu,removeListener:Uu,removeAllListeners:Lu,emit:Ou,binding:zu,cwd:Ku,chdir:Hu,umask:Zu,hrtime:Vu,platform:Eu,release:qu,config:Fu,uptime:Ju},Xf={exports:{}},jf={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(h,n){var o=gr,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)}})(jf,jf.exports);var Ot=jf.exports,df=65536,Gu=4294967295;function Xu(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
6
|
+
*/(function(h){const n=kn,o=g0,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;h.Buffer=y,h.SlowBuffer=N,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 k(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 q=W(E);if(q)return q;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 k(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 q=T.write(E,w);return q!==A&&(T=T.slice(0,q)),T}function I(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 I(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"||Ft(E.length)?g(0):I(E);if(E.type==="Buffer"&&Array.isArray(E.data))return I(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 N(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,q=A.length;for(let V=0,U=Math.min(T,q);V<U;++V)if(w[V]!==A[V]){T=w[V],q=A[V];break}return T<q?-1:q<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 q=y.allocUnsafe(A);let V=0;for(T=0;T<w.length;++T){let U=w[T];if(dt(U,Uint8Array))V+U.length>q.length?(y.isBuffer(U)||(U=y.from(U)),U.copy(q,V)):Uint8Array.prototype.set.call(q,U,V);else if(y.isBuffer(U))U.copy(q,V);else throw new TypeError('"list" argument must be an Array of Buffers');V+=U.length}return q};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 q=!1;for(;;)switch(w){case"ascii":case"latin1":case"binary":return A;case"utf8":case"utf-8":return Dt(E).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A*2;case"hex":return A>>>1;case"base64":return Pt(E).length;default:if(q)return T?-1:Dt(E).length;w=(""+w).toLowerCase(),q=!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,q,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),q===void 0&&(q=0),V===void 0&&(V=this.length),A<0||T>w.length||q<0||V>this.length)throw new RangeError("out of range index");if(q>=V&&A>=T)return 0;if(q>=V)return-1;if(A>=T)return 1;if(A>>>=0,T>>>=0,q>>>=0,V>>>=0,this===w)return 0;let U=V-q,X=T-A;const Tt=Math.min(U,X),G=this.slice(q,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,q){if(E.length===0)return-1;if(typeof A=="string"?(T=A,A=0):A>2147483647?A=2147483647:A<-2147483648&&(A=-2147483648),A=+A,Ft(A)&&(A=q?0:E.length-1),A<0&&(A=E.length+A),A>=E.length){if(q)return-1;A=E.length-1}else if(A<0)if(q)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,q);if(typeof w=="number")return w=w&255,typeof Uint8Array.prototype.indexOf=="function"?q?Uint8Array.prototype.indexOf.call(E,w,A):Uint8Array.prototype.lastIndexOf.call(E,w,A):Ct(E,[w],A,T,q);throw new TypeError("val must be string, number or Buffer")}function Ct(E,w,A,T,q){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(q){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 q=E.length-A;T?(T=Number(T),T>q&&(T=q)):T=q;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(Ft(X))return U;E[A+U]=X}return U}function Y(E,w,A,T){return j(Dt(w,E.length-A),E,A,T)}function kt(E,w,A,T){return j(et(w),E,A,T)}function p(E,w,A,T){return j(Pt(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,q){if(A===void 0)q="utf8",T=this.length,A=0;else if(T===void 0&&typeof A=="string")q=A,T=this.length,A=0;else if(isFinite(A))A=A>>>0,isFinite(T)?(T=T>>>0,q===void 0&&(q="utf8")):(q=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");q||(q="utf8");let U=!1;for(;;)switch(q){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 kt(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: "+q);q=(""+q).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 q=w;for(;q<A;){const V=E[q];let U=null,X=V>239?4:V>223?3:V>191?2:1;if(q+X<=A){let Tt,G,rt,Rt;switch(X){case 1:V<128&&(U=V);break;case 2:Tt=E[q+1],(Tt&192)===128&&(Rt=(V&31)<<6|Tt&63,Rt>127&&(U=Rt));break;case 3:Tt=E[q+1],G=E[q+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[q+1],G=E[q+2],rt=E[q+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),q+=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 q=w;q<A;++q)T+=String.fromCharCode(E[q]&127);return T}function v(E,w,A){let T="";A=Math.min(E.length,A);for(let q=w;q<A;++q)T+=String.fromCharCode(E[q]);return T}function u(E,w,A){const T=E.length;(!w||w<0)&&(w=0),(!A||A<0||A>T)&&(A=T);let q="";for(let V=w;V<A;++V)q+=Q[E[V]];return q}function e(E,w,A){const T=E.slice(w,A);let q="";for(let V=0;V<T.length-1;V+=2)q+=String.fromCharCode(T[V]+T[V+1]*256);return q}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 q=this.subarray(w,A);return Object.setPrototypeOf(q,y.prototype),q};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 q=this[w],V=1,U=0;for(;++U<A&&(V*=256);)q+=this[w+U]*V;return q},y.prototype.readUintBE=y.prototype.readUIntBE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let q=this[w+--A],V=1;for(;A>0&&(V*=256);)q+=this[w+--A]*V;return q},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 q=A+this[++w]*pe(2,8)+this[++w]*pe(2,16)+this[++w]*pe(2,24),V=this[++w]+this[++w]*pe(2,8)+this[++w]*pe(2,16)+T*pe(2,24);return BigInt(q)+(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 q=A*pe(2,24)+this[++w]*pe(2,16)+this[++w]*pe(2,8)+this[++w],V=this[++w]*pe(2,24)+this[++w]*pe(2,16)+this[++w]*pe(2,8)+T;return(BigInt(q)<<BigInt(32))+BigInt(V)}),y.prototype.readIntLE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let q=this[w],V=1,U=0;for(;++U<A&&(V*=256);)q+=this[w+U]*V;return V*=128,q>=V&&(q-=Math.pow(2,8*A)),q},y.prototype.readIntBE=function(w,A,T){w=w>>>0,A=A>>>0,T||l(w,A,this.length);let q=A,V=1,U=this[w+--q];for(;q>0&&(V*=256);)U+=this[w+--q]*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 q=this[w+4]+this[w+5]*pe(2,8)+this[w+6]*pe(2,16)+(T<<24);return(BigInt(q)<<BigInt(32))+BigInt(A+this[++w]*pe(2,8)+this[++w]*pe(2,16)+this[++w]*pe(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 q=(A<<24)+this[++w]*pe(2,16)+this[++w]*pe(2,8)+this[++w];return(BigInt(q)<<BigInt(32))+BigInt(this[++w]*pe(2,24)+this[++w]*pe(2,16)+this[++w]*pe(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,q,V){if(!y.isBuffer(E))throw new TypeError('"buffer" argument must be a Buffer instance');if(w>q||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,q){if(w=+w,A=A>>>0,T=T>>>0,!q){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,q){if(w=+w,A=A>>>0,T=T>>>0,!q){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,q){Z(w,T,q,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,q){Z(w,T,q,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,q){if(w=+w,A=A>>>0,!q){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,q){if(w=+w,A=A>>>0,!q){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 F(E,w,A,T,q,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,q){return w=+w,A=A>>>0,q||F(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,q){return w=+w,A=A>>>0,q||F(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,q){if(!y.isBuffer(w))throw new TypeError("argument should be a Buffer");if(T||(T=0),!q&&q!==0&&(q=this.length),A>=w.length&&(A=w.length),A||(A=0),q>0&&q<T&&(q=T),q===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(q<0)throw new RangeError("sourceEnd out of bounds");q>this.length&&(q=this.length),w.length-A<q-T&&(q=w.length-A+T);const V=q-T;return this===w&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(A,T,q):Uint8Array.prototype.set.call(w,this.subarray(T,q),A),V},y.prototype.fill=function(w,A,T,q){if(typeof w=="string"){if(typeof A=="string"?(q=A,A=0,T=this.length):typeof T=="string"&&(q=T,T=this.length),q!==void 0&&typeof q!="string")throw new TypeError("encoding must be a string");if(typeof q=="string"&&!y.isEncoding(q))throw new TypeError("Unknown encoding: "+q);if(w.length===1){const U=w.charCodeAt(0);(q==="utf8"&&U<128||q==="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,q),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 $(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(q){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:q,writable:!0})}toString(){return`${this.name} [${E}]: ${this.message}`}}}$("ERR_BUFFER_OUT_OF_BOUNDS",function(E){return E?`${E} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),$("ERR_INVALID_ARG_TYPE",function(E,w){return`The "${E}" argument must be of type number. Received type ${typeof w}`},TypeError),$("ERR_OUT_OF_RANGE",function(E,w,A){let T=`The value of "${E}" is out of range.`,q=A;return Number.isInteger(A)&&Math.abs(A)>pe(2,32)?q=K(String(A)):typeof A=="bigint"&&(q=String(A),(A>pe(BigInt(2),BigInt(32))||A<-pe(BigInt(2),BigInt(32)))&&(q=K(q)),q+="n"),T+=` It must be ${w}. Received ${q}`,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 It(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,q,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)}It(T,q,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 Dt(E,w){w=w||1/0;let A;const T=E.length;let q=null;const V=[];for(let U=0;U<T;++U){if(A=E.charCodeAt(U),A>55295&&A<57344){if(!q){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}q=A;continue}if(A<56320){(w-=3)>-1&&V.push(239,191,189),q=A;continue}A=(q-55296<<10|A-56320)+65536}else q&&(w-=3)>-1&&V.push(239,191,189);if(q=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,q;const V=[];for(let U=0;U<E.length&&!((w-=2)<0);++U)A=E.charCodeAt(U),T=A>>8,q=A%256,V.push(q),V.push(T);return V}function Pt(E){return n.toByteArray(vt(E))}function j(E,w,A,T){let q;for(q=0;q<T&&!(q+A>=w.length||q>=E.length);++q)w[q+A]=E[q];return q}function dt(E,w){return E instanceof w||E!=null&&E.constructor!=null&&E.constructor.name!=null&&E.constructor.name===w.name}function Ft(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 q=0;q<16;++q)w[T+q]=E[A]+E[q]}return w}();function ct(E){return typeof BigInt=="undefined"?Lt:E}function Lt(){throw new Error("BigInt not supported")}})(gr);class xh{constructor(n,o,s,m={}){this.endpoint=n,this.apiKey=o,this.context=s,this.isStopped=!1,this.pollIntervalMs=m.pollIntervalMs||2e3}init(n){return Ue(this,null,function*(){for(;!this.isStopped;){try{const o=yield this.fetchFlags(this.context);n(o)}catch(o){console.error("[LongPollingTransport] poll error",o)}this.pollIntervalMs>0&&(yield new Promise(o=>setTimeout(o,this.pollIntervalMs)))}})}fetchFlags(n){return Ue(this,null,function*(){const o=yield fetch(this.endpoint,{method:"POST",headers:{"x-api-key":`${this.apiKey}`,"Content-Type":"application/json"},body:JSON.stringify({context:n})});if(console.info(`[LongPollingTransport] Response status: ${o.status}`),o.status===401||o.status===403)throw new Error("Unauthorized: Invalid API key");if(!o.ok)throw new Error(`Unexpected response: ${o.status}`);return(yield o.json()).data})}destroy(){this.isStopped=!0}}class _h{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.retries=0}init(){return Ue(this,null,function*(){return this.connectWithRetry()})}connectWithRetry(){return new Promise((n,o)=>{const s=()=>{this.socket=new WebSocket(`${this.wsUrl}?apiKey=${this.apiKey}`),this.socket.onopen=()=>{this.isReady=!0,this.retries=0,this.context&&this.sendContext(this.context),n()},this.socket.onmessage=m=>{var f;try{const g=JSON.parse(m.data);g.type==="flags"&&(this.flags=g.flags,(f=this.onFlagsUpdatedCallback)==null||f.call(this,this.flags))}catch(g){console.warn("Failed to parse WebSocket message:",g)}},this.socket.onerror=m=>{console.error("[WebSocketTransport] Error:",m)},this.socket.onclose=m=>{if(this.isReady=!1,m.code===1008||m.code===4001)o(new Error("Unauthorized: Invalid API key"));else if(this.retries<this.maxRetries){const f=this.initialBackoffMs*Math.pow(2,this.retries);console.warn(`[WebSocketTransport] Reconnecting in ${f}ms (attempt ${this.retries+1})`),setTimeout(s,f),this.retries++}else o(new Error(`WebSocket failed after ${this.retries} retries`))}};s()})}fetchFlags(n){return Ue(this,null,function*(){var o;return this.context=n,this.isReady&&((o=this.socket)==null?void 0:o.readyState)===WebSocket.OPEN&&this.sendContext(n),this.flags})}onFlagsUpdated(n){this.onFlagsUpdatedCallback=n}destroy(){this.socket&&this.socket.readyState===WebSocket.OPEN&&this.socket.close(),this.socket=null,this.flags={},this.context=null,this.isReady=!1,this.onFlagsUpdatedCallback=void 0}sendContext(n){var s;const o=JSON.stringify({type:"context",context:n});(s=this.socket)==null||s.send(o)}}function Sh(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 xu(h,n){return h.rules.every(o=>Sh(o,n))}var Ut={};const Li=typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{};function Ah(){throw new Error("setTimeout has not been defined")}function Bh(){throw new Error("clearTimeout has not been defined")}var Cr=Ah,qr=Bh;typeof Li.setTimeout=="function"&&(Cr=setTimeout);typeof Li.clearTimeout=="function"&&(qr=clearTimeout);function Eh(h){if(Cr===setTimeout)return setTimeout(h,0);if((Cr===Ah||!Cr)&&setTimeout)return Cr=setTimeout,setTimeout(h,0);try{return Cr(h,0)}catch(n){try{return Cr.call(null,h,0)}catch(o){return Cr.call(this,h,0)}}}function _u(h){if(qr===clearTimeout)return clearTimeout(h);if((qr===Bh||!qr)&&clearTimeout)return qr=clearTimeout,clearTimeout(h);try{return qr(h)}catch(n){try{return qr.call(null,h)}catch(o){return qr.call(this,h)}}}var Mr=[],hi=!1,Zr,pn=-1;function Su(){!hi||!Zr||(hi=!1,Zr.length?Mr=Zr.concat(Mr):pn=-1,Mr.length&&Ih())}function Ih(){if(!hi){var h=Eh(Su);hi=!0;for(var n=Mr.length;n;){for(Zr=Mr,Mr=[];++pn<n;)Zr&&Zr[pn].run();pn=-1,n=Mr.length}Zr=null,hi=!1,_u(h)}}function Au(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];Mr.push(new kh(h,n)),Mr.length===1&&!hi&&Eh(Ih)}function kh(h,n){this.fun=h,this.array=n}kh.prototype.run=function(){this.fun.apply(null,this.array)};var Bu="browser",Eu="browser",Iu=!0,ku={},Ru=[],Tu="",Cu={},qu={},Fu={};function Qr(){}var Pu=Qr,Du=Qr,$u=Qr,Nu=Qr,Uu=Qr,Lu=Qr,Ou=Qr;function zu(h){throw new Error("process.binding is not supported")}function Ku(){return"/"}function Hu(h){throw new Error("process.chdir is not supported")}function Zu(){return 0}var fi=Li.performance||{},Wu=fi.now||fi.mozNow||fi.msNow||fi.oNow||fi.webkitNow||function(){return new Date().getTime()};function Vu(h){var n=Wu.call(fi)*.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 Yu=new Date;function Ju(){var h=new Date,n=h-Yu;return n/1e3}var ye={nextTick:Au,title:Bu,browser:Iu,env:ku,argv:Ru,version:Tu,versions:Cu,on:Pu,addListener:Du,once:$u,off:Nu,removeListener:Uu,removeAllListeners:Lu,emit:Ou,binding:zu,cwd:Ku,chdir:Hu,umask:Zu,hrtime:Vu,platform:Eu,release:qu,config:Fu,uptime:Ju},Xf={exports:{}},jf={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(h,n){var o=gr,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)}})(jf,jf.exports);var Ot=jf.exports,df=65536,Gu=4294967295;function Xu(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
7
7
|
Use Chrome, Firefox or Internet Explorer 11`)}var ju=Ot.Buffer,wn=Gt.crypto||Gt.msCrypto;wn&&wn.getRandomValues?Xf.exports=Qu:Xf.exports=Xu;function Qu(h,n){if(h>Gu)throw new RangeError("requested too many random bytes");var o=ju.allocUnsafe(h);if(h>0)if(h>df)for(var s=0;s<h;s+=df)wn.getRandomValues(o.slice(s,s+df));else wn.getRandomValues(o);return typeof n=="function"?ye.nextTick(function(){n(null,o)}):o}var gi=Xf.exports,Qf={exports:{}};typeof Object.create=="function"?Qf.exports=function(n,o){o&&(n.super_=o,n.prototype=Object.create(o.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}))}:Qf.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 Jt=Qf.exports;const tl={},el=Object.freeze(Object.defineProperty({__proto__:null,default:tl},Symbol.toStringTag,{value:"Module"})),Pe=cu(el);var fr=Ot.Buffer,Rh=Pe.Transform,rl=Jt;function $r(h){Rh.call(this),this._block=fr.allocUnsafe(h),this._blockSize=h,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}rl($r,Rh);$r.prototype._transform=function(h,n,o){var s=null;try{this.update(h,n)}catch(m){s=m}o(s)};$r.prototype._flush=function(h){var n=null;try{this.push(this.digest())}catch(o){n=o}h(n)};var il=typeof Uint8Array!="undefined",nl=typeof ArrayBuffer!="undefined"&&typeof Uint8Array!="undefined"&&ArrayBuffer.isView&&(fr.prototype instanceof Uint8Array||fr.TYPED_ARRAY_SUPPORT);function fl(h,n){if(h instanceof fr)return h;if(typeof h=="string")return fr.from(h,n);if(nl&&ArrayBuffer.isView(h)){if(h.byteLength===0)return fr.alloc(0);var o=fr.from(h.buffer,h.byteOffset,h.byteLength);if(o.byteLength===h.byteLength)return o}if(il&&h instanceof Uint8Array||fr.isBuffer(h)&&h.constructor&&typeof h.constructor.isBuffer=="function"&&h.constructor.isBuffer(h))return fr.from(h);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}$r.prototype.update=function(h,n){if(this._finalized)throw new Error("Digest already called");h=fl(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};$r.prototype._update=function(){throw new Error("_update is not implemented")};$r.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};$r.prototype._digest=function(){throw new Error("_digest is not implemented")};var Th=$r,al=Jt,Ch=Th,hl=Ot.Buffer,sl=new Array(16);function Rn(){Ch.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}al(Rn,Ch);Rn.prototype._update=function(){for(var h=sl,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=Ie(o,s,m,f,h[0],3614090360,7),f=Ie(f,o,s,m,h[1],3905402710,12),m=Ie(m,f,o,s,h[2],606105819,17),s=Ie(s,m,f,o,h[3],3250441966,22),o=Ie(o,s,m,f,h[4],4118548399,7),f=Ie(f,o,s,m,h[5],1200080426,12),m=Ie(m,f,o,s,h[6],2821735955,17),s=Ie(s,m,f,o,h[7],4249261313,22),o=Ie(o,s,m,f,h[8],1770035416,7),f=Ie(f,o,s,m,h[9],2336552879,12),m=Ie(m,f,o,s,h[10],4294925233,17),s=Ie(s,m,f,o,h[11],2304563134,22),o=Ie(o,s,m,f,h[12],1804603682,7),f=Ie(f,o,s,m,h[13],4254626195,12),m=Ie(m,f,o,s,h[14],2792965006,17),s=Ie(s,m,f,o,h[15],1236535329,22),o=ke(o,s,m,f,h[1],4129170786,5),f=ke(f,o,s,m,h[6],3225465664,9),m=ke(m,f,o,s,h[11],643717713,14),s=ke(s,m,f,o,h[0],3921069994,20),o=ke(o,s,m,f,h[5],3593408605,5),f=ke(f,o,s,m,h[10],38016083,9),m=ke(m,f,o,s,h[15],3634488961,14),s=ke(s,m,f,o,h[4],3889429448,20),o=ke(o,s,m,f,h[9],568446438,5),f=ke(f,o,s,m,h[14],3275163606,9),m=ke(m,f,o,s,h[3],4107603335,14),s=ke(s,m,f,o,h[8],1163531501,20),o=ke(o,s,m,f,h[13],2850285829,5),f=ke(f,o,s,m,h[2],4243563512,9),m=ke(m,f,o,s,h[7],1735328473,14),s=ke(s,m,f,o,h[12],2368359562,20),o=Re(o,s,m,f,h[5],4294588738,4),f=Re(f,o,s,m,h[8],2272392833,11),m=Re(m,f,o,s,h[11],1839030562,16),s=Re(s,m,f,o,h[14],4259657740,23),o=Re(o,s,m,f,h[1],2763975236,4),f=Re(f,o,s,m,h[4],1272893353,11),m=Re(m,f,o,s,h[7],4139469664,16),s=Re(s,m,f,o,h[10],3200236656,23),o=Re(o,s,m,f,h[13],681279174,4),f=Re(f,o,s,m,h[0],3936430074,11),m=Re(m,f,o,s,h[3],3572445317,16),s=Re(s,m,f,o,h[6],76029189,23),o=Re(o,s,m,f,h[9],3654602809,4),f=Re(f,o,s,m,h[12],3873151461,11),m=Re(m,f,o,s,h[15],530742520,16),s=Re(s,m,f,o,h[2],3299628645,23),o=Te(o,s,m,f,h[0],4096336452,6),f=Te(f,o,s,m,h[7],1126891415,10),m=Te(m,f,o,s,h[14],2878612391,15),s=Te(s,m,f,o,h[5],4237533241,21),o=Te(o,s,m,f,h[12],1700485571,6),f=Te(f,o,s,m,h[3],2399980690,10),m=Te(m,f,o,s,h[10],4293915773,15),s=Te(s,m,f,o,h[1],2240044497,21),o=Te(o,s,m,f,h[8],1873313359,6),f=Te(f,o,s,m,h[15],4264355552,10),m=Te(m,f,o,s,h[6],2734768916,15),s=Te(s,m,f,o,h[13],1309151649,21),o=Te(o,s,m,f,h[4],4149444226,6),f=Te(f,o,s,m,h[11],3174756917,10),m=Te(m,f,o,s,h[2],718787259,15),s=Te(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};Rn.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=hl.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 Tn(h,n){return h<<n|h>>>32-n}function Ie(h,n,o,s,m,f,g){return Tn(h+(n&o|~n&s)+m+f|0,g)+n|0}function ke(h,n,o,s,m,f,g){return Tn(h+(n&s|o&~s)+m+f|0,g)+n|0}function Re(h,n,o,s,m,f,g){return Tn(h+(n^o^s)+m+f|0,g)+n|0}function Te(h,n,o,s,m,f,g){return Tn(h+(o^(n|~s))+m+f|0,g)+n|0}var b0=Rn,cf=gr.Buffer,ol=Jt,qh=Th,ul=new Array(16),Bi=[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],Ei=[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],Ii=[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],ki=[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],Ri=[0,1518500249,1859775393,2400959708,2840853838],Ti=[1352829926,1548603684,1836072691,2053994217,0];function Cn(){qh.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}ol(Cn,qh);Cn.prototype._update=function(){for(var h=ul,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,k=0;k<80;k+=1){var I,D;k<16?(I=ea(o,s,m,f,g,h[Bi[k]],Ri[0],Ii[k]),D=fa(y,S,B,M,x,h[Ei[k]],Ti[0],ki[k])):k<32?(I=ra(o,s,m,f,g,h[Bi[k]],Ri[1],Ii[k]),D=na(y,S,B,M,x,h[Ei[k]],Ti[1],ki[k])):k<48?(I=ia(o,s,m,f,g,h[Bi[k]],Ri[2],Ii[k]),D=ia(y,S,B,M,x,h[Ei[k]],Ti[2],ki[k])):k<64?(I=na(o,s,m,f,g,h[Bi[k]],Ri[3],Ii[k]),D=ra(y,S,B,M,x,h[Ei[k]],Ti[3],ki[k])):(I=fa(o,s,m,f,g,h[Bi[k]],Ri[4],Ii[k]),D=ea(y,S,B,M,x,h[Ei[k]],Ti[4],ki[k])),o=g,g=f,f=Gr(m,10),m=s,s=I,y=x,x=M,M=Gr(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};Cn.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=cf.alloc?cf.alloc(20):new cf(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 Gr(h,n){return h<<n|h>>>32-n}function ea(h,n,o,s,m,f,g,y){return Gr(h+(n^o^s)+f+g|0,y)+m|0}function ra(h,n,o,s,m,f,g,y){return Gr(h+(n&o|~n&s)+f+g|0,y)+m|0}function ia(h,n,o,s,m,f,g,y){return Gr(h+((n|~o)^s)+f+g|0,y)+m|0}function na(h,n,o,s,m,f,g,y){return Gr(h+(n&s|o&~s)+f+g|0,y)+m|0}function fa(h,n,o,s,m,f,g,y){return Gr(h+(n^(o|~s))+f+g|0,y)+m|0}var y0=Cn,Fh={exports:{}},Ph=Ot.Buffer;function qn(h,n){this._block=Ph.alloc(h),this._finalSize=n,this._blockSize=h,this._len=0}qn.prototype.update=function(h,n){typeof h=="string"&&(n=n||"utf8",h=Ph.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};qn.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};qn.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var bi=qn,ll=Jt,Dh=bi,dl=Ot.Buffer,cl=[1518500249,1859775393,-1894007588,-899497514],vl=new Array(80);function Zi(){this.init(),this._w=vl,Dh.call(this,64,56)}ll(Zi,Dh);Zi.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function pl(h){return h<<5|h>>>27}function ml(h){return h<<30|h>>>2}function gl(h,n,o,s){return h===0?n&o|~n&s:h===2?n&o|n&s|o&s:n^o^s}Zi.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=pl(o)+gl(B,s,m,f)+g+n[S]+cl[B]|0;g=f,f=m,m=ml(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};Zi.prototype._hash=function(){var h=dl.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 bl=Zi,yl=Jt,$h=bi,wl=Ot.Buffer,Ml=[1518500249,1859775393,-1894007588,-899497514],xl=new Array(80);function Wi(){this.init(),this._w=xl,$h.call(this,64,56)}yl(Wi,$h);Wi.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function _l(h){return h<<1|h>>>31}function Sl(h){return h<<5|h>>>27}function Al(h){return h<<30|h>>>2}function Bl(h,n,o,s){return h===0?n&o|~n&s:h===2?n&o|n&s|o&s:n^o^s}Wi.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]=_l(n[y-3]^n[y-8]^n[y-14]^n[y-16]);for(var S=0;S<80;++S){var B=~~(S/20),M=Sl(o)+Bl(B,s,m,f)+g+n[S]+Ml[B]|0;g=f,f=m,m=Al(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};Wi.prototype._hash=function(){var h=wl.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 El=Wi,Il=Jt,Nh=bi,kl=Ot.Buffer,Rl=[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],Tl=new Array(64);function Vi(){this.init(),this._w=Tl,Nh.call(this,64,56)}Il(Vi,Nh);Vi.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 Cl(h,n,o){return o^h&(n^o)}function ql(h,n,o){return h&n|o&(h|n)}function Fl(h){return(h>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10)}function Pl(h){return(h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7)}function Dl(h){return(h>>>7|h<<25)^(h>>>18|h<<14)^h>>>3}function $l(h){return(h>>>17|h<<15)^(h>>>19|h<<13)^h>>>10}Vi.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]=$l(n[M-2])+n[M-7]+Dl(n[M-15])+n[M-16]|0;for(var x=0;x<64;++x){var k=B+Pl(g)+Cl(g,y,S)+Rl[x]+n[x]|0,I=Fl(o)+ql(o,s,m)|0;B=S,S=y,y=g,g=f+k|0,f=m,m=s,s=o,o=k+I|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};Vi.prototype._hash=function(){var h=kl.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 Uh=Vi,Nl=Jt,Ul=Uh,Ll=bi,Ol=Ot.Buffer,zl=new Array(64);function Fn(){this.init(),this._w=zl,Ll.call(this,64,56)}Nl(Fn,Ul);Fn.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};Fn.prototype._hash=function(){var h=Ol.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 Kl=Fn,Hl=Jt,Lh=bi,Zl=Ot.Buffer,aa=[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],Wl=new Array(160);function Yi(){this.init(),this._w=Wl,Lh.call(this,128,112)}Hl(Yi,Lh);Yi.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 ha(h,n,o){return o^h&(n^o)}function sa(h,n,o){return h&n|o&(h|n)}function oa(h,n){return(h>>>28|n<<4)^(n>>>2|h<<30)^(n>>>7|h<<25)}function ua(h,n){return(h>>>14|n<<18)^(h>>>18|n<<14)^(n>>>9|h<<23)}function Vl(h,n){return(h>>>1|n<<31)^(h>>>8|n<<24)^h>>>7}function Yl(h,n){return(h>>>1|n<<31)^(h>>>8|n<<24)^(h>>>7|n<<25)}function Jl(h,n){return(h>>>19|n<<13)^(n>>>29|h<<3)^h>>>6}function Gl(h,n){return(h>>>19|n<<13)^(n>>>29|h<<3)^(h>>>6|n<<26)}function xe(h,n){return h>>>0<n>>>0?1:0}Yi.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,k=this._cl|0,I=this._dl|0,D=this._el|0,L=this._fl|0,W=this._gl|0,z=this._hl|0,N=0;N<32;N+=2)n[N]=h.readInt32BE(N*4),n[N+1]=h.readInt32BE(N*4+4);for(;N<160;N+=2){var lt=n[N-30],H=n[N-15*2+1],At=Vl(lt,H),Bt=Yl(H,lt);lt=n[N-2*2],H=n[N-2*2+1];var Ct=Jl(lt,H),Et=Gl(H,lt),Y=n[N-7*2],kt=n[N-7*2+1],p=n[N-16*2],t=n[N-16*2+1],r=Bt+kt|0,i=At+Y+xe(r,Bt)|0;r=r+Et|0,i=i+Ct+xe(r,Et)|0,r=r+t|0,i=i+p+xe(r,t)|0,n[N]=i,n[N+1]=r}for(var a=0;a<160;a+=2){i=n[a],r=n[a+1];var d=sa(o,s,m),c=sa(M,x,k),v=oa(o,M),u=oa(M,o),e=ua(g,D),l=ua(D,g),b=aa[a],_=aa[a+1],C=ha(g,y,S),F=ha(D,L,W),O=z+l|0,R=B+e+xe(O,z)|0;O=O+F|0,R=R+C+xe(O,F)|0,O=O+_|0,R=R+b+xe(O,_)|0,O=O+r|0,R=R+i+xe(O,r)|0;var P=u+c|0,$=v+d+xe(P,u)|0;B=S,z=W,S=y,W=L,y=g,L=D,D=I+O|0,g=f+R+xe(D,I)|0,f=m,I=k,m=s,k=x,s=o,x=M,M=O+P|0,o=R+$+xe(M,O)|0}this._al=this._al+M|0,this._bl=this._bl+x|0,this._cl=this._cl+k|0,this._dl=this._dl+I|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+xe(this._al,M)|0,this._bh=this._bh+s+xe(this._bl,x)|0,this._ch=this._ch+m+xe(this._cl,k)|0,this._dh=this._dh+f+xe(this._dl,I)|0,this._eh=this._eh+g+xe(this._el,D)|0,this._fh=this._fh+y+xe(this._fl,L)|0,this._gh=this._gh+S+xe(this._gl,W)|0,this._hh=this._hh+B+xe(this._hl,z)|0};Yi.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 Oh=Yi,Xl=Jt,jl=Oh,Ql=bi,td=Ot.Buffer,ed=new Array(160);function Pn(){this.init(),this._w=ed,Ql.call(this,128,112)}Xl(Pn,jl);Pn.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};Pn.prototype._hash=function(){var h=td.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 rd=Pn,ti=Fh.exports=function(n){n=n.toLowerCase();var o=ti[n];if(!o)throw new Error(n+" is not supported (we accept pull requests)");return new o};ti.sha=bl;ti.sha1=El;ti.sha224=Kl;ti.sha256=Uh;ti.sha384=rd;ti.sha512=Oh;var w0=Fh.exports,Mn={},t0={exports:{}};(function(h,n){var o=gr,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)}})(t0,t0.exports);var id=t0.exports,M0=id.Buffer,la=M0.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 nd(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 fd(h){var n=nd(h);if(typeof n!="string"&&(M0.isEncoding===la||!la(h)))throw new Error("Unknown encoding: "+h);return n||h}Mn.StringDecoder=Ji;function Ji(h){this.encoding=fd(h);var n;switch(this.encoding){case"utf16le":this.text=ld,this.end=dd,n=4;break;case"utf8":this.fillLast=sd,n=4;break;case"base64":this.text=cd,this.end=vd,n=3;break;default:this.write=pd,this.end=md;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=M0.allocUnsafe(n)}Ji.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||""};Ji.prototype.end=ud;Ji.prototype.text=od;Ji.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 vf(h){return h<=127?0:h>>5===6?2:h>>4===14?3:h>>3===30?4:h>>6===2?-1:-2}function ad(h,n,o){var s=n.length-1;if(s<o)return 0;var m=vf(n[s]);return m>=0?(m>0&&(h.lastNeed=m-1),m):--s<o||m===-2?0:(m=vf(n[s]),m>=0?(m>0&&(h.lastNeed=m-2),m):--s<o||m===-2?0:(m=vf(n[s]),m>=0?(m>0&&(m===2?m=0:h.lastNeed=m-3),m):0))}function hd(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 sd(h){var n=this.lastTotal-this.lastNeed,o=hd(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 od(h,n){var o=ad(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 ud(h){var n=h&&h.length?this.write(h):"";return this.lastNeed?n+"�":n}function ld(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 dd(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 cd(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 vd(h){var n=h&&h.length?this.write(h):"";return this.lastNeed?n+this.lastChar.toString("base64",0,3-this.lastNeed):n}function pd(h){return h.toString(this.encoding)}function md(h){return h&&h.length?this.write(h):""}var ar=Ot.Buffer,zh=Pe.Transform,gd=Mn.StringDecoder,bd=Jt;function er(h){zh.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}bd(er,zh);var yd=typeof Uint8Array!="undefined",wd=typeof ArrayBuffer!="undefined"&&typeof Uint8Array!="undefined"&&ArrayBuffer.isView&&(ar.prototype instanceof Uint8Array||ar.TYPED_ARRAY_SUPPORT);function Md(h,n){if(h instanceof ar)return h;if(typeof h=="string")return ar.from(h,n);if(wd&&ArrayBuffer.isView(h)){if(h.byteLength===0)return ar.alloc(0);var o=ar.from(h.buffer,h.byteOffset,h.byteLength);if(o.byteLength===h.byteLength)return o}if(yd&&h instanceof Uint8Array||ar.isBuffer(h)&&h.constructor&&typeof h.constructor.isBuffer=="function"&&h.constructor.isBuffer(h))return ar.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=Md(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()||ar.alloc(0);return h&&(n=this._toString(n,h,!0)),n};er.prototype._toString=function(h,n,o){if(this._decoder||(this._decoder=new gd(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,xd=Jt,_d=b0,Sd=y0,Ad=w0,Kh=Nr;function Dn(h){Kh.call(this,"digest"),this._hash=h}xd(Dn,Kh);Dn.prototype._update=function(h){this._hash.update(h)};Dn.prototype._final=function(){return this._hash.digest()};var Gi=function(n){return n=n.toLowerCase(),n==="md5"?new _d:n==="rmd160"||n==="ripemd160"?new Sd:new Dn(Ad(n))},Bd=Jt,Wr=Ot.Buffer,Hh=Nr,Ed=Wr.alloc(128),ni=64;function $n(h,n){Hh.call(this,"digest"),typeof n=="string"&&(n=Wr.from(n)),this._alg=h,this._key=n,n.length>ni?n=h(n):n.length<ni&&(n=Wr.concat([n,Ed],ni));for(var o=this._ipad=Wr.allocUnsafe(ni),s=this._opad=Wr.allocUnsafe(ni),m=0;m<ni;m++)o[m]=n[m]^54,s[m]=n[m]^92;this._hash=[o]}Bd($n,Hh);$n.prototype._update=function(h){this._hash.push(h)};$n.prototype._final=function(){var h=this._alg(Wr.concat(this._hash));return this._alg(Wr.concat([this._opad,h]))};var Id=$n,kd=b0,Zh=function(h){return new kd().update(h).digest()},Rd=Jt,Td=Id,Wh=Nr,Pi=Ot.Buffer,Cd=Zh,e0=y0,r0=w0,qd=Pi.alloc(128);function Oi(h,n){Wh.call(this,"digest"),typeof n=="string"&&(n=Pi.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 e0:r0(h);n=s.update(n).digest()}else n.length<o&&(n=Pi.concat([n,qd],o));for(var m=this._ipad=Pi.allocUnsafe(o),f=this._opad=Pi.allocUnsafe(o),g=0;g<o;g++)m[g]=n[g]^54,f[g]=n[g]^92;this._hash=h==="rmd160"?new e0:r0(h),this._hash.update(m)}Rd(Oi,Wh);Oi.prototype._update=function(h){this._hash.update(h)};Oi.prototype._final=function(){var h=this._hash.digest(),n=this._alg==="rmd160"?new e0:r0(this._alg);return n.update(this._opad).update(h).digest()};var Vh=function(n,o){return n=n.toLowerCase(),n==="rmd160"||n==="ripemd160"?new Oi("rmd160",o):n==="md5"?new Td(Cd,o):new Oi(n,o)};const Fd={sign:"rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},Pd={sign:"rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},Dd={sign:"rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},$d={sign:"rsa",hash:"sha512",id:"3051300d060960864801650304020305000440"},Nd={sign:"ecdsa",hash:"sha256",id:""},Ud={sign:"ecdsa",hash:"sha224",id:""},Ld={sign:"ecdsa",hash:"sha384",id:""},Od={sign:"ecdsa",hash:"sha512",id:""},zd={sign:"dsa",hash:"sha1",id:""},Kd={sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},Hd={sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"},Yh={sha224WithRSAEncryption:Fd,"RSA-SHA224":{sign:"ecdsa/rsa",hash:"sha224",id:"302d300d06096086480165030402040500041c"},sha256WithRSAEncryption:Pd,"RSA-SHA256":{sign:"ecdsa/rsa",hash:"sha256",id:"3031300d060960864801650304020105000420"},sha384WithRSAEncryption:Dd,"RSA-SHA384":{sign:"ecdsa/rsa",hash:"sha384",id:"3041300d060960864801650304020205000430"},sha512WithRSAEncryption:$d,"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:Nd,sha224:Ud,sha384:Ld,sha512:Od,"DSA-SHA":{sign:"dsa",hash:"sha1",id:""},"DSA-SHA1":{sign:"dsa",hash:"sha1",id:""},DSA:zd,"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:Kd,"RSA-RIPEMD160":{sign:"rsa",hash:"rmd160",id:"3021300906052b2403020105000414"},md5WithRSAEncryption:Hd,"RSA-MD5":{sign:"rsa",hash:"md5",id:"3020300c06082a864886f70d020505000410"}};var Zd=Yh,Nn={},Wd=Math.pow(2,30)-1,Jh=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>Wd||n!==n)throw new TypeError("Bad key length")},mn;if(Gt.process&&Gt.process.browser)mn="utf-8";else if(Gt.process&&Gt.process.version){var Vd=parseInt(ye.version.split(".")[0].slice(1),10);mn=Vd>=6?"utf-8":"binary"}else mn="utf-8";var Gh=mn,pf=Ot.Buffer,Xh=function(h,n,o){if(pf.isBuffer(h))return h;if(typeof h=="string")return pf.from(h,n);if(ArrayBuffer.isView(h))return pf.from(h.buffer);throw new TypeError(o+" must be a string, a Buffer, a typed array or a DataView")},Yd=Zh,Jd=y0,Gd=w0,Vr=Ot.Buffer,Xd=Jh,da=Gh,ca=Xh,jd=Vr.alloc(128),gn={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function jh(h,n,o){var s=Qd(h),m=h==="sha512"||h==="sha384"?128:64;n.length>m?n=s(n):n.length<m&&(n=Vr.concat([n,jd],m));for(var f=Vr.allocUnsafe(m+gn[h]),g=Vr.allocUnsafe(m+gn[h]),y=0;y<m;y++)f[y]=n[y]^54,g[y]=n[y]^92;var S=Vr.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=gn[h]}jh.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 Qd(h){function n(s){return Gd(h).update(s).digest()}function o(s){return new Jd().update(s).digest()}return h==="rmd160"||h==="ripemd160"?o:h==="md5"?Yd:n}function tc(h,n,o,s,m){Xd(o,s),h=ca(h,da,"Password"),n=ca(n,da,"Salt"),m=m||"sha1";var f=new jh(m,h,n.length),g=Vr.allocUnsafe(s),y=Vr.allocUnsafe(n.length+4);n.copy(y,0,0,n.length);for(var S=0,B=gn[m],M=Math.ceil(s/B),x=1;x<=M;x++){y.writeUInt32BE(x,n.length);for(var k=f.run(y,f.ipad1),I=k,D=1;D<o;D++){I=f.run(I,f.ipad2);for(var L=0;L<B;L++)k[L]^=I[L]}k.copy(g,S),S+=B}return g}var Qh=tc,ts=Ot.Buffer,ec=Jh,va=Gh,pa=Qh,ma=Xh,hn,Ni=Gt.crypto&&Gt.crypto.subtle,rc={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"},mf=[];function ic(h){if(Gt.process&&!Gt.process.browser||!Ni||!Ni.importKey||!Ni.deriveBits)return Promise.resolve(!1);if(mf[h]!==void 0)return mf[h];hn=hn||ts.alloc(8);var n=es(hn,hn,10,128,h).then(function(){return!0}).catch(function(){return!1});return mf[h]=n,n}var Lr;function i0(){return Lr||(Gt.process&&Gt.process.nextTick?Lr=Gt.process.nextTick:Gt.queueMicrotask?Lr=Gt.queueMicrotask:Gt.setImmediate?Lr=Gt.setImmediate:Lr=Gt.setTimeout,Lr)}function es(h,n,o,s,m){return Ni.importKey("raw",h,{name:"PBKDF2"},!1,["deriveBits"]).then(function(f){return Ni.deriveBits({name:"PBKDF2",salt:n,iterations:o,hash:{name:m}},f,s<<3)}).then(function(f){return ts.from(f)})}function nc(h,n){h.then(function(o){i0()(function(){n(null,o)})},function(o){i0()(function(){n(o)})})}var fc=function(h,n,o,s,m,f){typeof m=="function"&&(f=m,m=void 0),m=m||"sha1";var g=rc[m.toLowerCase()];if(!g||typeof Gt.Promise!="function"){i0()(function(){var y;try{y=pa(h,n,o,s,m)}catch(S){return f(S)}f(null,y)});return}if(ec(o,s),h=ma(h,va,"Password"),n=ma(n,va,"Salt"),typeof f!="function")throw new Error("No callback provided to pbkdf2");nc(ic(g).then(function(y){return y?es(h,n,o,s,g):pa(h,n,o,s,m)}),f)};Nn.pbkdf2=fc;Nn.pbkdf2Sync=Qh;var Qe={},yi={},Oe={};Oe.readUInt32BE=function(n,o){var s=n[0+o]<<24|n[1+o]<<16|n[2+o]<<8|n[3+o];return s>>>0};Oe.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};Oe.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};Oe.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};Oe.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};Oe.r28shl=function(n,o){return n<<o&268435455|n>>>28-o};var sn=[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];Oe.pc2=function(n,o,s,m){for(var f=0,g=0,y=sn.length>>>1,S=0;S<y;S++)f<<=1,f|=n>>>sn[S]&1;for(var S=y;S<sn.length;S++)g<<=1,g|=o>>>sn[S]&1;s[m+0]=f>>>0,s[m+1]=g>>>0};Oe.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 ga=[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];Oe.substitute=function(n,o){for(var s=0,m=0;m<4;m++){var f=n>>>18-m*6&63,g=ga[m*64+f];s<<=4,s|=g}for(var m=0;m<4;m++){var f=o>>>18-m*6&63,g=ga[4*64+m*64+f];s<<=4,s|=g}return s>>>0};var ba=[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];Oe.permute=function(n){for(var o=0,s=0;s<ba.length;s++)o<<=1,o|=n>>>ba[s]&1;return o>>>0};Oe.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 We=rs;function rs(h,n){if(!h)throw new Error(n||"Assertion failed")}rs.equal=function(n,o,s){if(n!=o)throw new Error(s||"Assertion failed: "+n+" != "+o)};var ac=We;function Ve(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 x0=Ve;Ve.prototype._init=function(){};Ve.prototype.update=function(n){return n.length===0?[]:this.type==="decrypt"?this._updateDecrypt(n):this._updateEncrypt(n)};Ve.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};Ve.prototype._flushBuffer=function(n,o){return this._update(this.buffer,0,n,o),this.bufferOff=0,this.blockSize};Ve.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};Ve.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};Ve.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};Ve.prototype._pad=function(n,o){if(o===0)return!1;for(;o<n.length;)n[o++]=0;return!0};Ve.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};Ve.prototype._unpad=function(n){return n};Ve.prototype._finalDecrypt=function(){ac.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 is=We,hc=Jt,Me=Oe,ns=x0;function sc(){this.tmp=new Array(2),this.keys=null}function dr(h){ns.call(this,h);var n=new sc;this._desState=n,this.deriveKeys(n,h.key)}hc(dr,ns);var fs=dr;dr.create=function(n){return new dr(n)};var oc=[1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1];dr.prototype.deriveKeys=function(n,o){n.keys=new Array(16*2),is.equal(o.length,this.blockSize,"Invalid key length");var s=Me.readUInt32BE(o,0),m=Me.readUInt32BE(o,4);Me.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=oc[f>>>1];s=Me.r28shl(s,g),m=Me.r28shl(m,g),Me.pc2(s,m,n.keys,f)}};dr.prototype._update=function(n,o,s,m){var f=this._desState,g=Me.readUInt32BE(n,o),y=Me.readUInt32BE(n,o+4);Me.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],Me.writeUInt32BE(s,g,m),Me.writeUInt32BE(s,y,m+4)};dr.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};dr.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++)is.equal(n[s],o);return n.slice(0,n.length-o)};dr.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];Me.expand(y,n.tmp,0),B^=n.tmp[0],M^=n.tmp[1];var x=Me.substitute(B,M),k=Me.permute(x),I=y;y=(g^k)>>>0,g=I}Me.rip(y,g,m,f)};dr.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];Me.expand(g,n.tmp,0),B^=n.tmp[0],M^=n.tmp[1];var x=Me.substitute(B,M),k=Me.permute(x),I=g;g=(y^k)>>>0,y=I}Me.rip(g,y,m,f)};var as={},uc=We,lc=Jt,xn={};function dc(h){uc.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 cc(h){function n(f){h.call(this,f),this._cbcInit()}lc(n,h);for(var o=Object.keys(xn),s=0;s<o.length;s++){var m=o[s];n.prototype[m]=xn[m]}return n.create=function(g){return new n(g)},n}as.instantiate=cc;xn._cbcInit=function(){var n=new dc(this.options.iv);this._cbcState=n};xn._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 vc=We,pc=Jt,hs=x0,Fr=fs;function mc(h,n){vc.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=[Fr.create({type:"encrypt",key:o}),Fr.create({type:"decrypt",key:s}),Fr.create({type:"encrypt",key:m})]:this.ciphers=[Fr.create({type:"decrypt",key:m}),Fr.create({type:"encrypt",key:s}),Fr.create({type:"decrypt",key:o})]}function Xr(h){hs.call(this,h);var n=new mc(this.type,this.options.key);this._edeState=n}pc(Xr,hs);var gc=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=Fr.prototype._pad;Xr.prototype._unpad=Fr.prototype._unpad;yi.utils=Oe;yi.Cipher=x0;yi.DES=fs;yi.CBC=as;yi.EDE=gc;var ss=Nr,wr=yi,bc=Jt,Hr=Ot.Buffer,zi={"des-ede3-cbc":wr.CBC.instantiate(wr.EDE),"des-ede3":wr.EDE,"des-ede-cbc":wr.CBC.instantiate(wr.EDE),"des-ede":wr.EDE,"des-cbc":wr.CBC.instantiate(wr.DES),"des-ecb":wr.DES};zi.des=zi["des-cbc"];zi.des3=zi["des-ede3-cbc"];var yc=Un;bc(Un,ss);function Un(h){ss.call(this);var n=h.mode.toLowerCase(),o=zi[n],s;h.decrypt?s="decrypt":s="encrypt";var m=h.key;Hr.isBuffer(m)||(m=Hr.from(m)),(n==="des-ede"||n==="des-ede-cbc")&&(m=Hr.concat([m,m.slice(0,8)]));var f=h.iv;Hr.isBuffer(f)||(f=Hr.from(f)),this._des=o.create({key:m,iv:f,type:s})}Un.prototype._update=function(h){return Hr.from(this._des.update(h))};Un.prototype._final=function(){return Hr.from(this._des.final())};var Le={},_0={},S0={};S0.encrypt=function(h,n){return h._cipher.encryptBlock(n)};S0.decrypt=function(h,n){return h._cipher.decryptBlock(n)};var A0={},sr=[],He=[],wc=typeof Uint8Array!="undefined"?Uint8Array:Array,B0=!1;function os(){B0=!0;for(var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,o=h.length;n<o;++n)sr[n]=h[n],He[h.charCodeAt(n)]=n;He["-".charCodeAt(0)]=62,He["_".charCodeAt(0)]=63}function Mc(h){B0||os();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 wc(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=He[h.charCodeAt(n)]<<18|He[h.charCodeAt(n+1)]<<12|He[h.charCodeAt(n+2)]<<6|He[h.charCodeAt(n+3)],g[S++]=m>>16&255,g[S++]=m>>8&255,g[S++]=m&255;return f===2?(m=He[h.charCodeAt(n)]<<2|He[h.charCodeAt(n+1)]>>4,g[S++]=m&255):f===1&&(m=He[h.charCodeAt(n)]<<10|He[h.charCodeAt(n+1)]<<4|He[h.charCodeAt(n+2)]>>2,g[S++]=m>>8&255,g[S++]=m&255),g}function xc(h){return sr[h>>18&63]+sr[h>>12&63]+sr[h>>6&63]+sr[h&63]}function _c(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(xc(s));return m.join("")}function ya(h){B0||os();for(var n,o=h.length,s=o%3,m="",f=[],g=16383,y=0,S=o-s;y<S;y+=g)f.push(_c(h,y,y+g>S?S:y+g));return s===1?(n=h[o-1],m+=sr[n>>2],m+=sr[n<<4&63],m+="=="):s===2&&(n=(h[o-2]<<8)+h[o-1],m+=sr[n>>10],m+=sr[n>>4&63],m+=sr[n<<2&63],m+="="),f.push(m),f.join("")}function Ln(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,k=o?-1:1,I=h[n+x];for(x+=k,f=I&(1<<-M)-1,I>>=-M,M+=y;M>0;f=f*256+h[n+x],x+=k,M-=8);for(g=f&(1<<-M)-1,f>>=-M,M+=s;M>0;g=g*256+h[n+x],x+=k,M-=8);if(f===0)f=1-B;else{if(f===S)return g?NaN:(I?-1:1)*(1/0);g=g+Math.pow(2,s),f=f-B}return(I?-1:1)*g*Math.pow(2,f-s)}function us(h,n,o,s,m,f){var g,y,S,B=f*8-m-1,M=(1<<B)-1,x=M>>1,k=m===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=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+=k/S:n+=k*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+I]=y&255,I+=D,y/=256,m-=8);for(g=g<<m|y,B+=m;B>0;h[o+I]=g&255,I+=D,g/=256,B-=8);h[o+I-D]|=L*128}var Sc={}.toString,ls=Array.isArray||function(h){return Sc.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 ju=Ot.Buffer,wn=Gt.crypto||Gt.
|
|
|
15
15
|
`)},Vf}var nh;function Q2(){return nh||(nh=1,function(h){var n=h;n.der=Do(),n.pem=j2()}(Zf)),Zf}var fh;function fn(){return fh||(fh=1,function(h){var n=h;n.bignum=Z2,n.define=W2().define,n.base=Ui(),n.constants=Fo(),n.decoders=X2(),n.encoders=Q2()}(Df)),Df}var ir=fn(),ah=ir.define("Time",function(){this.choice({utcTime:this.utctime(),generalTime:this.gentime()})}),tm=ir.define("AttributeTypeValue",function(){this.seq().obj(this.key("type").objid(),this.key("value").any())}),V0=ir.define("AlgorithmIdentifier",function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional(),this.key("curve").objid().optional())}),em=ir.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use(V0),this.key("subjectPublicKey").bitstr())}),rm=ir.define("RelativeDistinguishedName",function(){this.setof(tm)}),im=ir.define("RDNSequence",function(){this.seqof(rm)}),hh=ir.define("Name",function(){this.choice({rdnSequence:this.use(im)})}),nm=ir.define("Validity",function(){this.seq().obj(this.key("notBefore").use(ah),this.key("notAfter").use(ah))}),fm=ir.define("Extension",function(){this.seq().obj(this.key("extnID").objid(),this.key("critical").bool().def(!1),this.key("extnValue").octstr())}),am=ir.define("TBSCertificate",function(){this.seq().obj(this.key("version").explicit(0).int().optional(),this.key("serialNumber").int(),this.key("signature").use(V0),this.key("issuer").use(hh),this.key("validity").use(nm),this.key("subject").use(hh),this.key("subjectPublicKeyInfo").use(em),this.key("issuerUniqueID").implicit(1).bitstr().optional(),this.key("subjectUniqueID").implicit(2).bitstr().optional(),this.key("extensions").explicit(3).seqof(fm).optional())}),hm=ir.define("X509Certificate",function(){this.seq().obj(this.key("tbsCertificate").use(am),this.key("signatureAlgorithm").use(V0),this.key("signatureValue").bitstr())}),sm=hm,nr=fn();rr.certificate=sm;var om=nr.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())});rr.RSAPrivateKey=om;var um=nr.define("RSAPublicKey",function(){this.seq().obj(this.key("modulus").int(),this.key("publicExponent").int())});rr.RSAPublicKey=um;var $o=nr.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())}),lm=nr.define("SubjectPublicKeyInfo",function(){this.seq().obj(this.key("algorithm").use($o),this.key("subjectPublicKey").bitstr())});rr.PublicKey=lm;var dm=nr.define("PrivateKeyInfo",function(){this.seq().obj(this.key("version").int(),this.key("algorithm").use($o),this.key("subjectPrivateKey").octstr())});rr.PrivateKey=dm;var cm=nr.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())});rr.EncryptedPrivateKey=cm;var vm=nr.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())});rr.DSAPrivateKey=vm;rr.DSAparam=nr.define("DSAparam",function(){this.int()});var pm=nr.define("ECParameters",function(){this.choice({namedCurve:this.objid()})}),mm=nr.define("ECPrivateKey",function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").optional().explicit(0).use(pm),this.key("publicKey").optional().explicit(1).bitstr())});rr.ECPrivateKey=mm;rr.signature=nr.define("signature",function(){this.seq().obj(this.key("r").int(),this.key("s").int())});const gm={"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 bm=/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,ym=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----/m,wm=/^-----BEGIN ((?:.*? KEY)|CERTIFICATE)-----([0-9A-z\n\r+/=]+)-----END \1-----$/m,Mm=Zn,xm=Le,vn=Ot.Buffer,_m=function(h,n){var o=h.toString(),s=o.match(bm),m;if(s){var g="aes"+s[1],y=vn.from(s[2],"hex"),S=vn.from(s[3].replace(/[\r\n]/g,""),"base64"),B=Mm(n,y.slice(0,8),parseInt(s[1],10)).key,M=[],x=xm.createDecipheriv(g,B,y);M.push(x.update(S)),M.push(x.final()),m=vn.concat(M)}else{var f=o.match(wm);m=vn.from(f[2].replace(/[\r\n]/g,""),"base64")}var k=o.match(ym)[1];return{tag:k,data:m}},qe=rr,Sm=gm,Am=_m,Bm=Le,Em=Nn,c0=Ot.Buffer;function Im(h,n){var o=h.algorithm.decrypt.kde.kdeparams.salt,s=parseInt(h.algorithm.decrypt.kde.kdeparams.iters.toString(),10),m=Sm[h.algorithm.decrypt.cipher.algo.join(".")],f=h.algorithm.decrypt.cipher.iv,g=h.subjectPrivateKey,y=parseInt(m.split("-")[1],10)/8,S=Em.pbkdf2Sync(n,o,s,y,"sha1"),B=Bm.createDecipheriv(m,S,f),M=[];return M.push(B.update(g)),M.push(B.final()),c0.concat(M)}function No(h){var n;typeof h=="object"&&!c0.isBuffer(h)&&(n=h.passphrase,h=h.key),typeof h=="string"&&(h=c0.from(h));var o=Am(h,n),s=o.tag,m=o.data,f,g;switch(s){case"CERTIFICATE":g=qe.certificate.decode(m,"der").tbsCertificate.subjectPublicKeyInfo;case"PUBLIC KEY":switch(g||(g=qe.PublicKey.decode(m,"der")),f=g.algorithm.algorithm.join("."),f){case"1.2.840.113549.1.1.1":return qe.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=qe.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=qe.EncryptedPrivateKey.decode(m,"der"),m=Im(m,n);case"PRIVATE KEY":switch(g=qe.PrivateKey.decode(m,"der"),f=g.algorithm.algorithm.join("."),f){case"1.2.840.113549.1.1.1":return qe.RSAPrivateKey.decode(g.subjectPrivateKey,"der");case"1.2.840.10045.2.1":return{curve:g.algorithm.curve,privateKey:qe.ECPrivateKey.decode(g.subjectPrivateKey,"der").privateKey};case"1.2.840.10040.4.1":return g.algorithm.params.priv_key=qe.DSAparam.decode(g.subjectPrivateKey,"der"),{type:"dsa",params:g.algorithm.params};default:throw new Error("unknown key id "+f)}case"RSA PUBLIC KEY":return qe.RSAPublicKey.decode(m,"der");case"RSA PRIVATE KEY":return qe.RSAPrivateKey.decode(m,"der");case"DSA PRIVATE KEY":return{type:"dsa",params:qe.DSAPrivateKey.decode(m,"der")};case"EC PRIVATE KEY":return m=qe.ECPrivateKey.decode(m,"der"),{curve:m.parameters.value,privateKey:m.privateKey};default:throw new Error("unknown key type "+s)}}No.signature=qe.signature;var hf=No;const Uo={"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 sh;function km(){if(sh)return Ci.exports;sh=1;var h=Ot.Buffer,n=Vh,o=U0,s=Z0().ec,m=N0,f=hf,g=Uo,y=1;function S(z,N,lt,H,At){var Bt=f(N);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(N.padding!==void 0&&N.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 kt=o(Et,Bt);return kt}function B(z,N){var lt=g[N.curve.join(".")];if(!lt)throw new Error("unknown curve "+N.curve.join("."));var H=new s(lt),At=H.keyFromPrivate(N.privateKey),Bt=At.sign(z);return h.from(Bt.toDER())}function M(z,N,lt){for(var H=N.params.priv_key,At=N.params.p,Bt=N.params.q,Ct=N.params.g,Et=new m(0),Y,kt=I(z,Bt).mod(Bt),p=!1,t=k(H,Bt,z,lt);p===!1;)Y=L(Bt,t,lt),Et=W(Ct,Y,At,Bt),p=Y.invm(Bt).imul(kt.add(H.mul(Et))).mod(Bt),p.cmpn(0)===0&&(p=!1,Et=new m(0));return x(Et,p)}function x(z,N){z=z.toArray(),N=N.toArray(),z[0]&128&&(z=[0].concat(z)),N[0]&128&&(N=[0].concat(N));var lt=z.length+N.length+4,H=[48,lt,2,z.length];return H=H.concat(z,[2,N.length],N),h.from(H)}function k(z,N,lt,H){if(z=h.from(z.toArray()),z.length<N.byteLength()){var At=h.alloc(N.byteLength()-z.length);z=h.concat([At,z])}var Bt=lt.length,Ct=D(lt,N),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 I(z,N){var lt=new m(z),H=(z.length<<3)-N.bitLength();return H>0&<.ishrn(H),lt}function D(z,N){z=I(z,N),z=z.mod(N);var lt=h.from(z.toArray());if(lt.length<N.byteLength()){var H=h.alloc(N.byteLength()-lt.length);lt=h.concat([H,lt])}return lt}function L(z,N,lt){var H,At;do{for(H=h.alloc(0);H.length*8<z.bitLength();)N.v=n(lt,N.k).update(N.v).digest(),H=h.concat([H,N.v]);At=I(H,z),N.k=n(lt,N.k).update(N.v).update(h.from([0])).digest(),N.v=n(lt,N.k).update(N.v).digest()}while(At.cmp(z)!==-1);return At}function W(z,N,lt,H){return z.toRed(m.mont(lt)).redPow(N).fromRed().mod(H)}return Ci.exports=S,Ci.exports.getKey=k,Ci.exports.makeKey=L,Ci.exports}var Yf,oh;function Rm(){if(oh)return Yf;oh=1;var h=Ot.Buffer,n=N0,o=Z0().ec,s=hf,m=Uo;function f(B,M,x,k,I){var D=s(x);if(D.type==="ec"){if(k!=="ecdsa"&&k!=="ecdsa/rsa")throw new Error("wrong public key type");return g(B,M,D)}else if(D.type==="dsa"){if(k!=="dsa")throw new Error("wrong public key type");return y(B,M,D)}if(k!=="rsa"&&k!=="ecdsa/rsa")throw new Error("wrong public key type");M=h.concat([I,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 N=-1;++N<M.length;)W.push(M[N]);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),N=-1;++N<L;)H|=B[N]^W[N];return H===0}function g(B,M,x){var k=m[x.data.algorithm.curve.join(".")];if(!k)throw new Error("unknown curve "+x.data.algorithm.curve.join("."));var I=new o(k),D=x.data.subjectPrivateKey.data;return I.verify(M,B,D)}function y(B,M,x){var k=x.data.p,I=x.data.q,D=x.data.g,L=x.data.pub_key,W=s.signature.decode(B,"der"),z=W.s,N=W.r;S(z,I),S(N,I);var lt=n.mont(k),H=z.invm(I),At=D.toRed(lt).redPow(new n(M).mul(H).mod(I)).fromRed().mul(L.toRed(lt).redPow(N.mul(H).mod(I)).fromRed()).mod(k).mod(I);return At.cmp(N)===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 Yf=f,Yf}var Jf,uh;function Tm(){if(uh)return Jf;uh=1;var h=Ot.Buffer,n=Gi,o=Ev,s=Jt,m=km(),f=Rm(),g=Yh;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 k=g[x];if(!k)throw new Error("Unknown message digest");this._hashType=k.hash,this._hash=n(k.hash),this._tag=k.id,this._signType=k.sign}s(y,o.Writable),y.prototype._write=function(k,I,D){this._hash.update(k),D()},y.prototype.update=function(k,I){return this._hash.update(typeof k=="string"?h.from(k,I):k),this},y.prototype.sign=function(k,I){this.end();var D=this._hash.digest(),L=m(D,k,this._hashType,this._signType,this._tag);return I?L.toString(I):L};function S(x){o.Writable.call(this);var k=g[x];if(!k)throw new Error("Unknown message digest");this._hash=n(k.hash),this._tag=k.id,this._signType=k.sign}s(S,o.Writable),S.prototype._write=function(k,I,D){this._hash.update(k),D()},S.prototype.update=function(k,I){return this._hash.update(typeof k=="string"?h.from(k,I):k),this},S.prototype.verify=function(k,I,D){var L=typeof I=="string"?h.from(I,D):I;this.end();var W=this._hash.digest();return f(L,W,k,this._signType,this._tag)};function B(x){return new y(x)}function M(x){return new S(x)}return Jf={Sign:B,Verify:M,createSign:B,createVerify:M},Jf}var Y0={exports:{}};Y0.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=Pe.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],k=[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=k[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 I(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 F=e-C|0;a=p.words[F]|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,F=a[1]|0,O=F&8191,R=F>>>13,P=a[2]|0,$=P&8191,K=P>>>13,It=a[3]|0,Z=It&8191,J=It>>>13,qt=a[4]|0,tt=qt&8191,vt=qt>>>13,Dt=a[5]|0,et=Dt&8191,pt=Dt>>>13,Pt=a[6]|0,j=Pt&8191,dt=Pt>>>13,Ft=a[7]|0,Q=Ft&8191,ct=Ft>>>13,Lt=a[8]|0,E=Lt&8191,w=Lt>>>13,A=a[9]|0,T=A&8191,q=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,zt=d[3]|0,nt=zt&8191,bt=zt>>>13,Kt=d[4]|0,ft=Kt&8191,yt=Kt>>>13,Ht=d[5]|0,at=Ht&8191,wt=Ht>>>13,Zt=d[6]|0,ht=Zt&8191,Mt=Zt>>>13,Wt=d[7]|0,st=Wt&8191,xt=Wt>>>13,Vt=d[8]|0,ot=Vt&8191,_t=Vt>>>13,Yt=d[9]|0,ut=Yt&8191,St=Yt>>>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 Nt=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,u=Math.imul($,U),e=Math.imul($,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($,G)|0,e=e+Math.imul($,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($,it)|0,e=e+Math.imul($,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($,nt)|0,e=e+Math.imul($,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($,ft)|0,e=e+Math.imul($,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($,at)|0,e=e+Math.imul($,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($,ht)|0,e=e+Math.imul($,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(q,U)|0,l=Math.imul(q,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($,st)|0,e=e+Math.imul($,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(q,G)|0,l=Math.imul(q,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($,ot)|0,e=e+Math.imul($,_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(q,it)|0,l=Math.imul(q,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($,ut)|0,e=e+Math.imul($,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(q,nt)|0,l=Math.imul(q,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(q,ft)|0,l=Math.imul(q,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(q,at)|0,l=Math.imul(q,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(q,ht)|0,l=Math.imul(q,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(q,st)|0,l=Math.imul(q,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(q,ot)|0,l=Math.imul(q,_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(q,ut)|0,l=Math.imul(q,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]=Nt,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*_,F=C&67108863;c=c+(C/67108864|0)|0,F=F+v|0,v=F&67108863,c=c+(F>>>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 N;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 N(p,t){this.x=p,this.y=t}N.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},N.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},N.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]]},N.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,F=0;F<v;F++){var O=i[b+F],R=a[b+F],P=i[b+F+v],$=a[b+F+v],K=_*P-C*$;$=_*$+C*P,P=K,i[b+F]=O+P,a[b+F]=R+$,i[b+F+v]=O-P,a[b+F+v]=R-$,F!==u&&(K=e*_-l*C,C=e*C+l*_,_=K)}},N.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},N.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}},N.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},N.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)},N.prototype.stub=function(t){for(var r=new Array(t),i=0;i<t;i++)r[i]=0;return r},N.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 F=0;F<a;F++){var O=u[F]*b[F]-e[F]*_[F];e[F]=u[F]*_[F]+e[F]*b[F],u[F]=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=I(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,F=1;!(i.words[0]&F)&&C<26;++C,F<<=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 F=_,O=0;F.cmp(c)!==0;O++)F=F.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 kt(t)};function kt(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(kt,Y),kt.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},kt.prototype.convertFrom=function(t){var r=this.imod(t.mul(this.rinv));return r.red=null,r},kt.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)},kt.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)},kt.prototype.invm=function(t){var r=this.imod(t._invmp(this.m).mul(this.r2));return r._forceRed(this)}})(h,Gt)})(Y0);var Cm=Y0.exports,Gf,lh;function qm(){if(lh)return Gf;lh=1;var h=Z0(),n=Cm;Gf=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 Gf}var Lo={},Fm=Gi,v0=Ot.Buffer,Oo=function(h,n){for(var o=v0.alloc(0),s=0,m;o.length<n;)m=Pm(s++),o=v0.concat([o,Fm("sha1").update(h).update(m).digest()]);return o.slice(0,n)};function Pm(h){var n=v0.allocUnsafe(4);return n.writeUInt32BE(h,0),n}var zo=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=Pe.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],k=[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=k[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 I(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 F=e-C|0;a=p.words[F]|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,F=a[1]|0,O=F&8191,R=F>>>13,P=a[2]|0,$=P&8191,K=P>>>13,It=a[3]|0,Z=It&8191,J=It>>>13,qt=a[4]|0,tt=qt&8191,vt=qt>>>13,Dt=a[5]|0,et=Dt&8191,pt=Dt>>>13,Pt=a[6]|0,j=Pt&8191,dt=Pt>>>13,Ft=a[7]|0,Q=Ft&8191,ct=Ft>>>13,Lt=a[8]|0,E=Lt&8191,w=Lt>>>13,A=a[9]|0,T=A&8191,q=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,zt=d[3]|0,nt=zt&8191,bt=zt>>>13,Kt=d[4]|0,ft=Kt&8191,yt=Kt>>>13,Ht=d[5]|0,at=Ht&8191,wt=Ht>>>13,Zt=d[6]|0,ht=Zt&8191,Mt=Zt>>>13,Wt=d[7]|0,st=Wt&8191,xt=Wt>>>13,Vt=d[8]|0,ot=Vt&8191,_t=Vt>>>13,Yt=d[9]|0,ut=Yt&8191,St=Yt>>>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 Nt=(v+u|0)+((e&8191)<<13)|0;v=(l+(e>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,u=Math.imul($,U),e=Math.imul($,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($,G)|0,e=e+Math.imul($,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($,it)|0,e=e+Math.imul($,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($,nt)|0,e=e+Math.imul($,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($,ft)|0,e=e+Math.imul($,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($,at)|0,e=e+Math.imul($,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($,ht)|0,e=e+Math.imul($,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(q,U)|0,l=Math.imul(q,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($,st)|0,e=e+Math.imul($,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(q,G)|0,l=Math.imul(q,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($,ot)|0,e=e+Math.imul($,_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(q,it)|0,l=Math.imul(q,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($,ut)|0,e=e+Math.imul($,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(q,nt)|0,l=Math.imul(q,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(q,ft)|0,l=Math.imul(q,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(q,at)|0,l=Math.imul(q,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(q,ht)|0,l=Math.imul(q,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(q,st)|0,l=Math.imul(q,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(q,ot)|0,l=Math.imul(q,_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(q,ut)|0,l=Math.imul(q,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]=Nt,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*_,F=C&67108863;c=c+(C/67108864|0)|0,F=F+v|0,v=F&67108863,c=c+(F>>>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 N;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 N(p,t){this.x=p,this.y=t}N.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},N.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},N.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]]},N.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,F=0;F<v;F++){var O=i[b+F],R=a[b+F],P=i[b+F+v],$=a[b+F+v],K=_*P-C*$;$=_*$+C*P,P=K,i[b+F]=O+P,a[b+F]=R+$,i[b+F+v]=O-P,a[b+F+v]=R-$,F!==u&&(K=e*_-l*C,C=e*C+l*_,_=K)}},N.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},N.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}},N.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},N.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)},N.prototype.stub=function(t){for(var r=new Array(t),i=0;i<t;i++)r[i]=0;return r},N.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 F=0;F<a;F++){var O=u[F]*b[F]-e[F]*_[F];e[F]=u[F]*_[F]+e[F]*b[F],u[F]=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=I(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,F=1;!(i.words[0]&F)&&C<26;++C,F<<=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 F=_,O=0;F.cmp(c)!==0;O++)F=F.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 kt(t)};function kt(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(kt,Y),kt.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},kt.prototype.convertFrom=function(t){var r=this.imod(t.mul(this.rinv));return r.red=null,r},kt.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)},kt.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)},kt.prototype.invm=function(t){var r=this.imod(t._invmp(this.m).mul(this.r2));return r._forceRed(this)}})(h,Gt)})(J0);var G0=J0.exports,dh=G0,Dm=Ot.Buffer;function $m(h,n){return Dm.from(h.toRed(dh.mont(n.modulus)).redPow(new dh(n.publicExponent)).fromRed().toArray())}var Ko=$m,Nm=hf,p0=gi,Um=Gi,ch=Oo,vh=zo,X0=G0,Lm=Ko,Om=U0,je=Ot.Buffer,zm=function(n,o,s){var m;n.padding?m=n.padding:s?m=1:m=4;var f=Nm(n),g;if(m===4)g=Km(f,o);else if(m===1)g=Hm(f,o,s);else if(m===3){if(g=new X0(o),g.cmp(f.modulus)>=0)throw new Error("data too long for modulus")}else throw new Error("unknown padding");return s?Om(g,f):Lm(g,f)};function Km(h,n){var o=h.modulus.byteLength(),s=n.length,m=Um("sha1").update(je.alloc(0)).digest(),f=m.length,g=2*f;if(s>o-g-2)throw new Error("message too long");var y=je.alloc(o-s-g-2),S=o-f-1,B=p0(f),M=vh(je.concat([m,y,je.alloc(1,1),n],S),ch(B,S)),x=vh(B,ch(M,f));return new X0(je.concat([je.alloc(1),x,M],o))}function Hm(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=je.alloc(m-s-3,255):f=Zm(m-s-3),new X0(je.concat([je.from([0,o?1:2]),f,je.alloc(1),n],m))}function Zm(h){for(var n=je.allocUnsafe(h),o=0,s=p0(h*2),m=0,f;o<h;)m===s.length&&(s=p0(h*2),m=0),f=s[m++],f&&(n[o++]=f);return n}var Wm=hf,ph=Oo,mh=zo,gh=G0,Vm=U0,Ym=Gi,Jm=Ko,Hi=Ot.Buffer,Gm=function(n,o,s){var m;n.padding?m=n.padding:s?m=1:m=4;var f=Wm(n),g=f.modulus.byteLength();if(o.length>g||new gh(o).cmp(f.modulus)>=0)throw new Error("decryption error");var y;s?y=Jm(new gh(o),f):y=Vm(o,f);var S=Hi.alloc(g-y.length);if(y=Hi.concat([S,y],g),m===4)return Xm(f,y);if(m===1)return jm(f,y,s);if(m===3)return y;throw new Error("unknown padding")};function Xm(h,n){var o=h.modulus.byteLength(),s=Ym("sha1").update(Hi.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=mh(f,ph(g,m)),S=mh(g,ph(y,o-m-1));if(Qm(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 jm(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 Qm(h,n){h=Hi.from(h),n=Hi.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=zm,h.privateDecrypt=Gm,h.privateEncrypt=function(o,s){return h.publicEncrypt(o,s,!0)},h.publicDecrypt=function(o,s){return h.privateDecrypt(o,s,!0)}})(Lo);var $i={};function bh(){throw new Error(`secure random number generation not supported by this browser
|
|
16
16
|
use chrome, FireFox or Internet Explorer 11`)}var Ho=Ot,yh=gi,Zo=Ho.Buffer,Wo=Ho.kMaxLength,m0=Gt.crypto||Gt.msCrypto,Vo=Math.pow(2,32)-1;function Yo(h,n){if(typeof h!="number"||h!==h)throw new TypeError("offset must be a number");if(h>Vo||h<0)throw new TypeError("offset must be a uint32");if(h>Wo||h>n)throw new RangeError("offset out of range")}function Jo(h,n,o){if(typeof h!="number"||h!==h)throw new TypeError("size must be a number");if(h>Vo||h<0)throw new TypeError("size must be a uint32");if(h+n>o||h>Wo)throw new RangeError("buffer too small")}m0&&m0.getRandomValues||!ye.browser?($i.randomFill=t3,$i.randomFillSync=e3):($i.randomFill=bh,$i.randomFillSync=bh);function t3(h,n,o,s){if(!Zo.isBuffer(h)&&!(h instanceof Gt.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 Yo(n,h.length),Jo(o,n,h.length),Go(h,n,o,s)}function Go(h,n,o,s){if(ye.browser){var m=h.buffer,f=new Uint8Array(m,n,o);if(m0.getRandomValues(f),s){ye.nextTick(function(){s(null,h)});return}return h}if(s){yh(o,function(y,S){if(y)return s(y);S.copy(h,n),s(null,h)});return}var g=yh(o);return g.copy(h,n),h}function e3(h,n,o){if(typeof n=="undefined"&&(n=0),!Zo.isBuffer(h)&&!(h instanceof Gt.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');return Yo(n,h.length),o===void 0&&(o=h.length-n),Jo(o,n,h.length),Go(h,n,o)}var wh;function Xo(){if(wh)return Ut;wh=1,Ut.randomBytes=Ut.rng=Ut.pseudoRandomBytes=Ut.prng=gi,Ut.createHash=Ut.Hash=Gi,Ut.createHmac=Ut.Hmac=Vh;var h=Zd,n=Object.keys(h),o=["sha1","sha224","sha256","sha384","sha512","md5","rmd160"].concat(n);Ut.getHashes=function(){return o};var s=Nn;Ut.pbkdf2=s.pbkdf2,Ut.pbkdf2Sync=s.pbkdf2Sync;var m=Qe;Ut.Cipher=m.Cipher,Ut.createCipher=m.createCipher,Ut.Cipheriv=m.Cipheriv,Ut.createCipheriv=m.createCipheriv,Ut.Decipher=m.Decipher,Ut.createDecipher=m.createDecipher,Ut.Decipheriv=m.Decipheriv,Ut.createDecipheriv=m.createDecipheriv,Ut.getCiphers=m.getCiphers,Ut.listCiphers=m.listCiphers;var f=ev();Ut.DiffieHellmanGroup=f.DiffieHellmanGroup,Ut.createDiffieHellmanGroup=f.createDiffieHellmanGroup,Ut.getDiffieHellman=f.getDiffieHellman,Ut.createDiffieHellman=f.createDiffieHellman,Ut.DiffieHellman=f.DiffieHellman;var g=Tm();Ut.createSign=g.createSign,Ut.Sign=g.Sign,Ut.createVerify=g.createVerify,Ut.Verify=g.Verify,Ut.createECDH=qm();var y=Lo;Ut.publicEncrypt=y.publicEncrypt,Ut.privateEncrypt=y.privateEncrypt,Ut.publicDecrypt=y.publicDecrypt,Ut.privateDecrypt=y.privateDecrypt;var S=$i;return Ut.randomFill=S.randomFill,Ut.randomFillSync=S.randomFillSync,Ut.createCredentials=function(){throw new Error(`sorry, createCredentials is not implemented yet
|
|
17
17
|
we accept pull requests
|
|
18
|
-
https://github.com/browserify/crypto-browserify`)},Ut.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},Ut}var r3=Xo();const i3=du(r3);function j0(h){const n=i3.createHash("sha256").update(h).digest("hex");return parseInt(n.slice(0,8),16)%1e4/100}function jo(h,n){const o=j0(h);let s=0;for(const m of n.variants)if(s+=m.weight,o<s)return m.value;return null}function Qo(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 j0(`${o}.${m}`)<s?!0:null}case"variant":{if(!("variants"in h))return null;const{salt:s,variants:m}=h;return jo(`${o}.${s}`,m)}default:return null}}function tu(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?xu(S,n):!1}else return Sh(g,n)}))return null;const m=h.rollout?Qo(h.rollout,n):null;return(f=m!=null?m:h.value)!=null?f:null}let an={getItem:h=>typeof localStorage!="undefined"?localStorage.getItem(h):null,setItem:(h,n)=>{typeof localStorage!="undefined"&&localStorage.setItem(h,n)}};function n3(h){an=h}function eu(h){return`flagmint_${h}_flags`}function ru(h){return`flagmint_${h}_context`}function iu(h,n){try{const o=an.getItem(eu(h));if(!o)return null;const s=JSON.parse(o);return Date.now()-s.ts>n?null:s.data}catch(o){return null}}function nu(h,n){try{an.setItem(eu(h),JSON.stringify({ts:Date.now(),data:n}))}catch(o){}}function fu(h){try{const n=an.getItem(ru(h));return n?JSON.parse(n):null}catch(n){return null}}function au(h,n){try{an.setItem(ru(h),JSON.stringify(n))}catch(o){}}const f3=Object.freeze(Object.defineProperty({__proto__:null,loadCachedContext:fu,loadCachedFlags:iu,saveCachedContext:au,saveCachedFlags:nu,setCacheStorage:n3},Symbol.toStringTag,{value:"Module"})),a3=24*60*60*1e3,h3="http://localhost:3000/evaluator/evaluate",s3="wss://api.flagmint.io/flags/ws";class o3{constructor(n){var o,s,m,f;if(this.flags={},this.refreshIntervalId=null,this.rawFlags={},this.apiKey=n.apiKey,this.enableOfflineCache=(o=n.enableOfflineCache)!=null?o:!0,this.persistContext=(s=n.persistContext)!=null?s:!1,this.cacheTTL=a3,this.onError=n.onError,this.cacheAdapter=(m=n.cacheAdapter)!=null?m:{loadFlags:iu,saveFlags:nu,loadContext:fu,saveContext:au},this.context=n.context||{},this.rawFlags=(f=n.rawFlags)!=null?f:{},this.previewMode=n.previewMode||!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=()=>{};return}else this.previewMode&&!this.rawFlags&&console.error("[FlagClient] No raw flags provided for preview mode. Defaulting to remote fetch.");this.readyPromise=new Promise((g,y)=>{this.resolveReady=g,this.rejectReady=y}),this.initialize(n)}initialize(n){return Ue(this,null,function*(){var o;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)}yield this.setupTransport(n),this.resolveReady()}catch(s){this.rejectReady(s),(o=this.onError)==null||o.call(this,s)}})}setupTransport(n){return Ue(this,null,function*(){var f;
|
|
18
|
+
https://github.com/browserify/crypto-browserify`)},Ut.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},Ut}var r3=Xo();const i3=du(r3);function j0(h){const n=i3.createHash("sha256").update(h).digest("hex");return parseInt(n.slice(0,8),16)%1e4/100}function jo(h,n){const o=j0(h);let s=0;for(const m of n.variants)if(s+=m.weight,o<s)return m.value;return null}function Qo(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 j0(`${o}.${m}`)<s?!0:null}case"variant":{if(!("variants"in h))return null;const{salt:s,variants:m}=h;return jo(`${o}.${s}`,m)}default:return null}}function tu(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?xu(S,n):!1}else return Sh(g,n)}))return null;const m=h.rollout?Qo(h.rollout,n):null;return(f=m!=null?m:h.value)!=null?f:null}let an={getItem:h=>typeof localStorage!="undefined"?localStorage.getItem(h):null,setItem:(h,n)=>{typeof localStorage!="undefined"&&localStorage.setItem(h,n)}};function n3(h){an=h}function eu(h){return`flagmint_${h}_flags`}function ru(h){return`flagmint_${h}_context`}function iu(h,n){try{const o=an.getItem(eu(h));if(!o)return null;const s=JSON.parse(o);return Date.now()-s.ts>n?null:s.data}catch(o){return null}}function nu(h,n){try{an.setItem(eu(h),JSON.stringify({ts:Date.now(),data:n}))}catch(o){}}function fu(h){try{const n=an.getItem(ru(h));return n?JSON.parse(n):null}catch(n){return null}}function au(h,n){try{an.setItem(ru(h),JSON.stringify(n))}catch(o){}}const f3=Object.freeze(Object.defineProperty({__proto__:null,loadCachedContext:fu,loadCachedFlags:iu,saveCachedContext:au,saveCachedFlags:nu,setCacheStorage:n3},Symbol.toStringTag,{value:"Module"})),a3=24*60*60*1e3,h3="http://localhost:3000/evaluator/evaluate",s3="wss://api.flagmint.io/flags/ws";class o3{constructor(n){var o,s,m,f;if(this.flags={},this.refreshIntervalId=null,this.rawFlags={},this.apiKey=n.apiKey,this.enableOfflineCache=(o=n.enableOfflineCache)!=null?o:!0,this.persistContext=(s=n.persistContext)!=null?s:!1,this.cacheTTL=a3,this.onError=n.onError,this.cacheAdapter=(m=n.cacheAdapter)!=null?m:{loadFlags:iu,saveFlags:nu,loadContext:fu,saveContext:au},this.context=n.context||{},this.rawFlags=(f=n.rawFlags)!=null?f:{},this.previewMode=n.previewMode||!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=()=>{};return}else this.previewMode&&!this.rawFlags&&console.error("[FlagClient] No raw flags provided for preview mode. Defaulting to remote fetch.");this.readyPromise=new Promise((g,y)=>{this.resolveReady=g,this.rejectReady=y}),this.initialize(n)}initialize(n){return Ue(this,null,function*(){var o;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)}yield this.setupTransport(n),this.resolveReady()}catch(s){this.rejectReady(s),(o=this.onError)==null||o.call(this,s)}})}setupTransport(n){return Ue(this,null,function*(){var f;const o=(f=n.transportMode)!=null?f:"auto",s=()=>Ue(this,null,function*(){console.log("[FlagClient] Initializing WebSocket transport...");const g=new _h(s3,this.apiKey);return yield g.init(),console.log("[FlagClient] WebSocket transport initialized"),g}),m=()=>{console.log("[FlagClient] Using long polling transport...");const g=new xh(h3,this.apiKey,this.context,{pollIntervalMs:1e4});return g.init(y=>{console.log("[FlagClient] LongPolling update received:",y),this.flags=y,this.enableOfflineCache&&Promise.resolve(this.cacheAdapter.saveFlags(this.apiKey,y))}),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()}const g=yield this.transport.fetchFlags(this.context);this.flags=g,this.enableOfflineCache&&(yield Promise.resolve(this.cacheAdapter.saveFlags(this.apiKey,g))),typeof this.transport.onFlagsUpdated=="function"&&this.transport.onFlagsUpdated(y=>{this.flags=y,this.enableOfflineCache&&this.cacheAdapter.saveFlags(this.apiKey,y)}),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}})}getFlag(n,o){var s;return(s=this.flags[n])!=null?s:o}updateContext(n){this.context=uf(uf({},this.context),n),this.persistContext&&this.cacheAdapter.saveContext(this.apiKey,this.context)}destroy(){this.refreshIntervalId&&clearInterval(this.refreshIntervalId),this.transport.destroy()}ready(){return Ue(this,null,function*(){return this.readyPromise})}evaluateLocally(n,o){const s={};for(const m in n){const f=tu(n[m],o);f!==null&&(s[m]=f)}return s}}function hu(h){return`flagmint_${h}_flags`}function su(h){return`flagmint_${h}_context`}let kr=null;function u3(h){kr=h}function l3(h,n){return Ue(this,null,function*(){if(!kr)throw new Error("Async storage not set");try{const o=yield kr.getItem(hu(h));if(!o)return null;const s=JSON.parse(o);return Date.now()-s.ts>n?null:s.data}catch(o){return null}})}function d3(h,n){return Ue(this,null,function*(){if(!kr)throw new Error("Async storage not set");try{yield kr.setItem(hu(h),JSON.stringify({ts:Date.now(),data:n}))}catch(o){}})}function c3(h){return Ue(this,null,function*(){if(!kr)throw new Error("Async storage not set");try{const n=yield kr.getItem(su(h));return n?JSON.parse(n):null}catch(n){return null}})}function v3(h,n){return Ue(this,null,function*(){if(!kr)throw new Error("Async storage not set");try{yield kr.setItem(su(h),JSON.stringify(n))}catch(o){}})}const p3=Object.freeze(Object.defineProperty({__proto__:null,loadCachedContext:c3,loadCachedFlags:l3,saveCachedContext:v3,saveCachedFlags:d3,setAsyncCacheStorage:u3},Symbol.toStringTag,{value:"Module"}));typeof globalThis.Buffer=="undefined"&&(globalThis.Buffer=gr.Buffer);exports.FlagClient=o3;exports.LongPollingTransport=xh;exports.WebSocketTransport=_h;exports.asyncCache=p3;exports.evaluateFlagValue=tu;exports.evaluateRollout=Qo;exports.hashToPercentage=j0;exports.pickVariant=jo;exports.syncCache=f3;
|