@liascript/exporter
Version:
A generic exporter for LiaScript
1 lines • 62.4 kB
JavaScript
!function(){var e=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).parcelRequire55a5;e.register("1UDrq",(function(t,r){var n,i;n=t.exports,i=function(){return Nr},Object.defineProperty(n,"joinRoom",{get:i,set:undefined,enumerable:!0,configurable:!0});var o,a,u,f,s,c,l,d,h,v,p,y,g,m,w,b,E=e("hnmIs"),B=e("9Klpk"),A=e("3bWnf"),k=e("eT7f3"),S=e("kb0qF"),x=e("bgoEC"),I=e("7j4mF"),T=e("1Qswt"),O=e("5ENmm"),P=e("6Wo7Q"),L=e("rJmE6"),_=e("fSF4h"),R=e("bWNdT"),U=e("32Euv");function N(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function q(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(!((i=e)instanceof Uint8Array||ArrayBuffer.isView(i)&&"Uint8Array"===i.constructor.name))throw Error("Uint8Array expected");var i;if(r.length>0&&!r.includes(e.length))throw Error("Uint8Array expected of length "+r+", got length="+e.length)}function H(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}var C="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function D(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function z(e,t){return e<<32-t|e>>>t}function F(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+(void 0===e?"undefined":(0,L.default)(e)));return new Uint8Array((new TextEncoder).encode(e))}(e)),q(e),e}var j=function(){"use strict";function e(){(0,B.default)(this,e)}return(0,A.default)(e,[{key:"clone",value:function(){return this._cloneInto()}}]),e}();function V(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(C&&"function"==typeof C.getRandomValues)return C.getRandomValues(new Uint8Array(e));if(C&&"function"==typeof C.randomBytes)return C.randomBytes(e);throw Error("crypto.getRandomValues must be defined")}function M(e,t,r){return e&t^e&r^t&r}var Z=function(e){"use strict";(0,S.default)(r,e);var t=(0,R.default)(r);function r(e,n,i,o){var a;return(0,B.default)(this,r),(a=t.call(this)).blockLen=e,a.outputLen=n,a.padOffset=i,a.isLE=o,a.finished=!1,a.length=0,a.pos=0,a.destroyed=!1,a.buffer=new Uint8Array(e),a.view=D(a.buffer),(0,T.default)(a)}return(0,A.default)(r,[{key:"update",value:function(e){H(this);for(var t=this,r=t.view,n=t.buffer,i=t.blockLen,o=(e=F(e)).length,a=0;a<o;){var u=Math.min(i-this.pos,o-a);if(u!==i)n.set(e.subarray(a,a+u),this.pos),this.pos+=u,a+=u,this.pos===i&&(this.process(r,0),this.pos=0);else for(var f=D(e);i<=o-a;a+=i)this.process(f,a)}return this.length+=e.length,this.roundClean(),this}},{key:"digestInto",value:function(e){H(this),function(e,t){q(e);var r=t.outputLen;if(e.length<r)throw Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished=!0;var t=this,r=t.buffer,n=t.view,i=t.blockLen,o=t.isLE,a=this.pos;r[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>i-a&&(this.process(n,0),a=0);for(var u=a;u<i;u++)r[u]=0;!function(e,t,r,n){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,n);var i=BigInt(32),o=BigInt(4294967295),a=Number(r>>i&o),u=Number(r&o),f=n?4:0,s=n?0:4;e.setUint32(t+f,a,n),e.setUint32(t+s,u,n)}(n,i-8,BigInt(8*this.length),o),this.process(n,0);var f=D(e),s=this.outputLen;if(s%4)throw Error("_sha2: outputLen should be aligned to 32bit");var c=s/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(var d=0;d<c;d++)f.setUint32(4*d,l[d],o)}},{key:"digest",value:function(){var e=this.buffer,t=this.outputLen;this.digestInto(e);var r=e.slice(0,t);return this.destroy(),r}},{key:"_cloneInto",value:function(e){var t;e||(e=new this.constructor),(t=e).set.apply(t,(0,P.default)(this.get()));var r=this,n=r.blockLen,i=r.buffer,o=r.length,a=r.finished,u=r.destroyed,f=r.pos;return e.length=o,e.pos=f,e.finished=a,e.destroyed=u,o%n&&e.buffer.set(i),e}}]),r}(j),K=new Uint32Array([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]),G=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),W=new Uint32Array(64),Y=function(e){"use strict";(0,S.default)(r,e);var t=(0,R.default)(r);function r(){var e;return(0,B.default)(this,r),(e=t.call(this,64,32,8,!1)).A=0|G[0],e.B=0|G[1],e.C=0|G[2],e.D=0|G[3],e.E=0|G[4],e.F=0|G[5],e.G=0|G[6],e.H=0|G[7],(0,T.default)(e)}return(0,A.default)(r,[{key:"get",value:function(){var e=this;return[e.A,e.B,e.C,e.D,e.E,e.F,e.G,e.H]}},{key:"set",value:function(e,t,r,n,i,o,a,u){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|a,this.H=0|u}},{key:"process",value:function(e,t){for(var r=0;r<16;r++,t+=4)W[r]=e.getUint32(t,!1);for(var n=16;n<64;n++){var i=W[n-15],o=W[n-2],a=z(i,7)^z(i,18)^i>>>3,u=z(o,17)^z(o,19)^o>>>10;W[n]=u+W[n-7]+a+W[n-16]|0}for(var f,s=this,c=s.A,l=s.B,d=s.C,h=s.D,v=s.E,p=s.F,y=s.G,g=s.H,m=0;m<64;m++){var w=g+(z(v,6)^z(v,11)^z(v,25))+((f=v)&p^~f&y)+K[m]+W[m]|0,b=(z(c,2)^z(c,13)^z(c,22))+M(c,l,d)|0;g=y,y=p,p=v,v=h+w|0,h=d,d=l,l=c,c=w+b|0}c=c+this.A|0,l=l+this.B|0,d=d+this.C|0,h=h+this.D|0,v=v+this.E|0,p=p+this.F|0,y=y+this.G|0,g=g+this.H|0,this.set(c,l,d,h,v,p,y,g)}},{key:"roundClean",value:function(){W.fill(0)}},{key:"destroy",value:function(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}]),r}(Z),J=function(e){var t=function(t){return e().update(F(t)).digest()},r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=function(){return e()},t}((function(){return new Y})),Q=function(e){"use strict";(0,S.default)(r,e);var t=(0,R.default)(r);function r(e,n){var i;(0,B.default)(this,r),(i=t.call(this)).finished=!1,i.destroyed=!1,function(e){if("function"!=typeof e||"function"!=typeof e.create)throw Error("Hash should be wrapped by utils.wrapConstructor");N(e.outputLen),N(e.blockLen)}(e);var o=F(n);if(i.iHash=e.create(),"function"!=typeof i.iHash.update)throw Error("Expected instance of class which extends utils.Hash");i.blockLen=i.iHash.blockLen,i.outputLen=i.iHash.outputLen;var a=i.blockLen,u=new Uint8Array(a);u.set(o.length>a?e.create().update(o).digest():o);for(var f=0;f<u.length;f++)u[f]^=54;i.iHash.update(u),i.oHash=e.create();for(var s=0;s<u.length;s++)u[s]^=106;return i.oHash.update(u),u.fill(0),(0,T.default)(i)}return(0,A.default)(r,[{key:"update",value:function(e){return H(this),this.iHash.update(e),this}},{key:"digestInto",value:function(e){H(this),q(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}},{key:"digest",value:function(){var e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}},{key:"_cloneInto",value:function(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));var t=this,r=t.oHash,n=t.iHash,i=t.finished,o=t.destroyed,a=t.blockLen,u=t.outputLen;return e.finished=i,e.destroyed=o,e.blockLen=a,e.outputLen=u,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}},{key:"destroy",value:function(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}]),r}(j),X=function(e,t,r){return new Q(e,t).update(r).digest()};X.create=function(e,t){return new Q(e,t)};var $=BigInt(0),ee=BigInt(1),te=BigInt(2);function re(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function ne(e){if(!re(e))throw Error("Uint8Array expected")}function ie(e,t){if("boolean"!=typeof t)throw Error(e+" boolean expected, got "+t)}var oe=Array.from({length:256},(function(e,t){return t.toString(16).padStart(2,"0")}));function ae(e){ne(e);for(var t="",r=0;r<e.length;r++)t+=oe[e[r]];return t}function ue(e){var t=e.toString(16);return 1&t.length?"0"+t:t}function fe(e){if("string"!=typeof e)throw Error("hex string expected, got "+(void 0===e?"undefined":(0,L.default)(e)));return""===e?$:BigInt("0x"+e)}var se=48,ce=57,le=65,de=70,he=97,ve=102;function pe(e){return e>=se&&e<=ce?e-se:e>=le&&e<=de?e-(le-10):e>=he&&e<=ve?e-(he-10):void 0}function ye(e){if("string"!=typeof e)throw Error("hex string expected, got "+(void 0===e?"undefined":(0,L.default)(e)));var t=e.length,r=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);for(var n=new Uint8Array(r),i=0,o=0;i<r;i++,o+=2){var a=pe(e.charCodeAt(o)),u=pe(e.charCodeAt(o+1));if(void 0===a||void 0===u){var f=e[o]+e[o+1];throw Error('hex string expected, got non-hex character "'+f+'" at index '+o)}n[i]=16*a+u}return n}function ge(e){return fe(ae(e))}function me(e){return ne(e),fe(ae(Uint8Array.from(e).reverse()))}function we(e,t){return ye(e.toString(16).padStart(2*t,"0"))}function be(e,t){return we(e,t).reverse()}function Ee(e,t,r){var n;if("string"==typeof t)try{n=ye(t)}catch(t){throw Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!re(t))throw Error(e+" must be hex string or Uint8Array");n=Uint8Array.from(t)}var i=n.length;if("number"==typeof r&&i!==r)throw Error(e+" of length "+r+" expected, got "+i);return n}function Be(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(var n=0,i=0;i<t.length;i++){var o=t[i];ne(o),n+=o.length}for(var a=new Uint8Array(n),u=0,f=0;u<t.length;u++){var s=t[u];a.set(s,f),f+=s.length}return a}var Ae=function(e){return"bigint"==(void 0===e?"undefined":(0,L.default)(e))&&$<=e};function ke(e,t,r){return Ae(e)&&Ae(t)&&Ae(r)&&t<=e&&e<r}function Se(e,t,r,n){if(!ke(t,r,n))throw Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function xe(e){var t;for(t=0;e>$;e>>=ee,t+=1);return t}var Ie=function(e){return(te<<BigInt(e-1))-ee},Te=function(e){return new Uint8Array(e)},Oe=function(e){return Uint8Array.from(e)};function Pe(e,t,r){if("number"!=typeof e||e<2)throw Error("hashLen must be a number");if("number"!=typeof t||t<2)throw Error("qByteLen must be a number");if("function"!=typeof r)throw Error("hmacFn must be a function");var n=Te(e),i=Te(e),o=0,a=function(){n.fill(1),i.fill(0),o=0},u=function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++)t[o]=arguments[o];return r.apply(void 0,[i,n].concat((0,P.default)(t)))},f=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Te();i=u(Oe([0]),e),n=u(),0!==e.length&&(i=u(Oe([1]),e),n=u())},s=function(){if(o++>=1e3)throw Error("drbg: tried 1000 values");for(var e=0,r=[];e<t;){var i=(n=u()).slice();r.push(i),e+=n.length}return Be.apply(void 0,(0,P.default)(r))};return function(e,t){var r;for(a(),f(e);!(r=t(s()));)f();return a(),r}}var Le={bigint:function(e){return"bigint"==(void 0===e?"undefined":(0,L.default)(e))},function:function(e){return"function"==typeof e},boolean:function(e){return"boolean"==typeof e},string:function(e){return"string"==typeof e},stringOrUint8Array:function(e){return"string"==typeof e||re(e)},isSafeInteger:function(e){return Number.isSafeInteger(e)},array:function(e){return Array.isArray(e)},field:function(e,t){return t.Fp.isValid(e)},hash:function(e){return"function"==typeof e&&Number.isSafeInteger(e.outputLen)}};function _e(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=function(t,r,n){var i=Le[r];if("function"!=typeof i)throw Error("invalid validator function");var o=e[t];if(!(n&&void 0===o||i(o,e)))throw Error("param "+t+" is invalid. Expected "+r+", got "+o)},i=!0,o=!1,a=void 0;try{for(var u,f=Object.entries(t)[Symbol.iterator]();!(i=(u=f.next()).done);i=!0){var s=(0,O.default)(u.value,2);n(s[0],s[1],!1)}}catch(e){o=!0,a=e}finally{try{i||null==f.return||f.return()}finally{if(o)throw a}}var c=!0,l=!1,d=void 0;try{for(var h,v=Object.entries(r)[Symbol.iterator]();!(c=(h=v.next()).done);c=!0){var p=(0,O.default)(h.value,2);n(p[0],p[1],!0)}}catch(e){l=!0,d=e}finally{try{c||null==v.return||v.return()}finally{if(l)throw d}}return e}function Re(e){var t=new WeakMap;return function(r){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];var a=t.get(r);if(void 0!==a)return a;var u=e.apply(void 0,[r].concat((0,P.default)(i)));return t.set(r,u),u}}var Ue=Object.freeze({__proto__:null,aInRange:Se,abool:ie,abytes:ne,bitGet:function(e,t){return e>>BigInt(t)&ee},bitLen:xe,bitMask:Ie,bitSet:function(e,t,r){return e|(r?ee:$)<<BigInt(t)},bytesToHex:ae,bytesToNumberBE:ge,bytesToNumberLE:me,concatBytes:Be,createHmacDrbg:Pe,ensureBytes:Ee,equalBytes:function(e,t){if(e.length!==t.length)return!1;for(var r=0,n=0;n<e.length;n++)r|=e[n]^t[n];return 0===r},hexToBytes:ye,hexToNumber:fe,inRange:ke,isBytes:re,memoized:Re,notImplemented:function(){throw Error("not implemented")},numberToBytesBE:we,numberToBytesLE:be,numberToHexUnpadded:ue,numberToVarBytesBE:function(e){return ye(ue(e))},utf8ToBytes:function(e){if("string"!=typeof e)throw Error("string expected");return new Uint8Array((new TextEncoder).encode(e))},validateObject:_e}),Ne=BigInt(0),qe=BigInt(1),He=BigInt(2),Ce=BigInt(3),De=BigInt(4),ze=BigInt(5),Fe=BigInt(8);function je(e,t){var r=e%t;return r>=Ne?r:t+r}function Ve(e,t,r){if(t<Ne)throw Error("invalid exponent, negatives unsupported");if(r<=Ne)throw Error("invalid modulus");if(r===qe)return Ne;for(var n=qe;t>Ne;)t&qe&&(n=n*e%r),e=e*e%r,t>>=qe;return n}function Me(e,t,r){for(var n=e;t-- >Ne;)n*=n,n%=r;return n}function Ze(e,t){if(e===Ne)throw Error("invert: expected non-zero number");if(t<=Ne)throw Error("invert: expected positive modulus, got "+t);for(var r=je(e,t),n=t,i=Ne,o=qe;r!==Ne;){var a=n%r,u=i-o*(n/r);n=r,r=a,i=o,o=u}if(n!==qe)throw Error("invert: does not exist");return je(i,t)}var Ke=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ge(e,t){var r=void 0!==t?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function We(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(e<=Ne)throw Error("invalid field: expected ORDER > 0, got "+e);var i,o=Ge(e,t),a=o.nBitLength,u=o.nByteLength;if(u>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");var f=Object.freeze({ORDER:e,isLE:r,BITS:a,BYTES:u,MASK:Ie(a),ZERO:Ne,ONE:qe,create:function(t){return je(t,e)},isValid:function(t){if("bigint"!=(void 0===t?"undefined":(0,L.default)(t)))throw Error("invalid field element: expected bigint, got "+(void 0===t?"undefined":(0,L.default)(t)));return Ne<=t&&t<e},is0:function(e){return e===Ne},isOdd:function(e){return(e&qe)===qe},neg:function(t){return je(-t,e)},eql:function(e,t){return e===t},sqr:function(t){return je(t*t,e)},add:function(t,r){return je(t+r,e)},sub:function(t,r){return je(t-r,e)},mul:function(t,r){return je(t*r,e)},pow:function(e,t){return function(e,t,r){if(r<Ne)throw Error("invalid exponent, negatives unsupported");if(r===Ne)return e.ONE;if(r===qe)return t;for(var n=e.ONE,i=t;r>Ne;)r&qe&&(n=e.mul(n,i)),i=e.sqr(i),r>>=qe;return n}(f,e,t)},div:function(t,r){return je(t*Ze(r,e),e)},sqrN:function(e){return e*e},addN:function(e,t){return e+t},subN:function(e,t){return e-t},mulN:function(e,t){return e*t},inv:function(t){return Ze(t,e)},sqrt:n.sqrt||function(t){return i||(i=function(e){if(e%De===Ce){var t=(e+qe)/De;return function(e,r){var n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw Error("Cannot find square root");return n}}if(e%Fe===ze){var r=(e-ze)/Fe;return function(e,t){var n=e.mul(t,He),i=e.pow(n,r),o=e.mul(t,i),a=e.mul(e.mul(o,He),i),u=e.mul(o,e.sub(a,e.ONE));if(!e.eql(e.sqr(u),t))throw Error("Cannot find square root");return u}}return function(e){var t,r,n,i=(e-qe)/He;for(t=e-qe,r=0;t%He===Ne;t/=He,r++);for(n=He;n<e&&Ve(n,i,e)!==e-qe;n++)if(n>1e3)throw Error("Cannot find square root: likely non-prime P");if(1===r){var o=(e+qe)/De;return function(e,t){var r=e.pow(t,o);if(!e.eql(e.sqr(r),t))throw Error("Cannot find square root");return r}}var a=(t+qe)/He;return function(e,o){if(e.pow(o,i)===e.neg(e.ONE))throw Error("Cannot find square root");for(var u=r,f=e.pow(e.mul(e.ONE,n),t),s=e.pow(o,a),c=e.pow(o,t);!e.eql(c,e.ONE);){if(e.eql(c,e.ZERO))return e.ZERO;for(var l=1,d=e.sqr(c);l<u&&!e.eql(d,e.ONE);l++)d=e.sqr(d);var h=e.pow(f,qe<<BigInt(u-l-1));f=e.sqr(h),s=e.mul(s,h),c=e.mul(c,f),u=l}return s}}(e)}(e)),i(f,t)},invertBatch:function(e){return function(e,t){var r=Array(t.length),n=t.reduce((function(t,n,i){return e.is0(n)?t:(r[i]=t,e.mul(t,n))}),e.ONE),i=e.inv(n);return t.reduceRight((function(t,n,i){return e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n))}),i),r}(f,e)},cmov:function(e,t,r){return r?t:e},toBytes:function(e){return r?be(e,u):we(e,u)},fromBytes:function(e){if(e.length!==u)throw Error("Field.fromBytes: expected "+u+" bytes, got "+e.length);return r?me(e):ge(e)}});return Object.freeze(f)}function Ye(e){if("bigint"!=(void 0===e?"undefined":(0,L.default)(e)))throw Error("field order must be bigint");var t=e.toString(2).length;return Math.ceil(t/8)}function Je(e){var t=Ye(e);return t+Math.ceil(t/2)}var Qe=BigInt(0),Xe=BigInt(1);function $e(e,t){var r=t.negate();return e?r:t}function et(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function tt(e,t){return et(e,t),{windows:Math.ceil(t/e)+1,windowSize:Math.pow(2,e-1)}}var rt=new WeakMap,nt=new WeakMap;function it(e){return nt.get(e)||1}function ot(e){return _e(e.Fp,Ke.reduce((function(e,t){return e[t]="function",e}),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),_e(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze((0,I.default)((0,x.default)({},Ge(e.n,e.nBitLength),e),{p:e.Fp.ORDER}))}function at(e){void 0!==e.lowS&&ie("lowS",e.lowS),void 0!==e.prehash&&ie("prehash",e.prehash)}var ut,ft=Ue.bytesToNumberBE,st=Ue.hexToBytes,ct=(ut={Err:function(e){"use strict";(0,S.default)(r,e);var t=(0,R.default)(r);function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(0,B.default)(this,r),t.call(this,e)}return r}((0,_.default)(Error))},(0,k.default)(ut,"_tlv",(0,k.default)({encode:function(e,t){var r=ct.Err;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(1&t.length)throw new r("tlv.encode: unpadded data");var n=t.length/2,i=ue(n);if(i.length/2&128)throw new r("tlv.encode: long form length too big");var o=n>127?ue(i.length/2|128):"";return ue(e)+o+i+t}},"decode",(function(e,t){var r=ct.Err,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");var i=t[n++],o=0;if(128&i){var a=127&i;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");var u=t.subarray(n,n+a);if(u.length!==a)throw new r("tlv.decode: length bytes not complete");if(0===u[0])throw new r("tlv.decode(long): zero leftmost byte");var f=!0,s=!1,c=void 0;try{for(var l,d=u[Symbol.iterator]();!(f=(l=d.next()).done);f=!0)o=o<<8|l.value}catch(e){s=!0,c=e}finally{try{f||null==d.return||d.return()}finally{if(s)throw c}}if(n+=a,o<128)throw new r("tlv.decode(long): not minimal encoding")}else o=i;var h=t.subarray(n,n+o);if(h.length!==o)throw new r("tlv.decode: wrong value length");return{v:h,l:t.subarray(n+o)}}))),(0,k.default)(ut,"_int",(0,k.default)({encode:function(e){var t=ct.Err;if(e<lt)throw new t("integer: negative integers are not allowed");var r=ue(e);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new t("unexpected DER parsing assertion: unpadded hex");return r}},"decode",(function(e){var t=ct.Err;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return ft(e)}))),(0,k.default)(ut,"toSig",(function(e){var t=ct.Err,r=ct._int,n=ct._tlv,i="string"==typeof e?st(e):e;ne(i);var o=n.decode(48,i),a=o.v;if(o.l.length)throw new t("invalid signature: left bytes after parsing");var u=n.decode(2,a),f=u.v,s=u.l,c=n.decode(2,s),l=c.v;if(c.l.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(f),s:r.decode(l)}})),(0,k.default)(ut,"hexFromSig",(function(e){var t=ct._tlv,r=ct._int,n=t.encode(2,r.encode(e.r))+t.encode(2,r.encode(e.s));return t.encode(48,n)})),ut),lt=BigInt(0),dt=BigInt(1);BigInt(2);var ht=BigInt(3);function vt(e){var t=function(e){var t=i.a,r=i.b,n=o.sqr(e),a=o.mul(n,e);return o.add(o.add(a,o.mul(e,t)),r)},r=function(e){var t,r=i.allowedPrivateKeyLengths,n=i.nByteLength,o=i.wrapPrivateKey,a=i.n;if(r&&"bigint"!=(void 0===e?"undefined":(0,L.default)(e))){if(re(e)&&(e=ae(e)),"string"!=typeof e||!r.includes(e.length))throw Error("invalid private key");e=e.padStart(2*n,"0")}try{t="bigint"==(void 0===e?"undefined":(0,L.default)(e))?e:ge(Ee("private key",e,n))}catch(t){throw Error("invalid private key, expected hex or "+n+" bytes, got "+(void 0===e?"undefined":(0,L.default)(e)))}return o&&(t=je(t,a)),Se("private key",t,dt,a),t},n=function(e){if(!(e instanceof d))throw Error("ProjectivePoint expected")},i=function(e){var t=ot(e);_e(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});var r=t.endo,n=t.Fp,i=t.a;if(r){if(!n.eql(i,n.ZERO))throw Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=(0,L.default)(r.beta)||"function"!=typeof r.splitScalar)throw Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze((0,x.default)({},t))}(e),o=i.Fp,a=We(i.n,i.nBitLength),u=i.toBytes||function(e,t){var r=t.toAffine();return Be(Uint8Array.from([4]),o.toBytes(r.x),o.toBytes(r.y))},f=i.fromBytes||function(e){var t=e.subarray(1);return{x:o.fromBytes(t.subarray(0,o.BYTES)),y:o.fromBytes(t.subarray(o.BYTES,2*o.BYTES))}};if(!o.eql(o.sqr(i.Gy),t(i.Gx)))throw Error("bad generator point: equation left != right");var s,c=Re((function(e,t){var r=e.px,n=e.py,i=e.pz;if(o.eql(i,o.ONE))return{x:r,y:n};var a=e.is0();null==t&&(t=a?o.ONE:o.inv(i));var u=o.mul(r,t),f=o.mul(n,t),s=o.mul(i,t);if(a)return{x:o.ZERO,y:o.ZERO};if(!o.eql(s,o.ONE))throw Error("invZ was invalid");return{x:u,y:f}})),l=Re((function(e){if(e.is0()){if(i.allowInfinityPoint&&!o.is0(e.py))return;throw Error("bad point: ZERO")}var r=e.toAffine(),n=r.x,a=r.y;if(!o.isValid(n)||!o.isValid(a))throw Error("bad point: x or y not FE");var u=o.sqr(a),f=t(n);if(!o.eql(u,f))throw Error("bad point: equation left != right");if(!e.isTorsionFree())throw Error("bad point: not in prime-order subgroup");return!0})),d=function(){"use strict";function e(t,r,n){if((0,B.default)(this,e),this.px=t,this.py=r,this.pz=n,null==t||!o.isValid(t))throw Error("x required");if(null==r||!o.isValid(r))throw Error("y required");if(null==n||!o.isValid(n))throw Error("z required");Object.freeze(this)}return(0,A.default)(e,[{key:"x",get:function(){return this.toAffine().x}},{key:"y",get:function(){return this.toAffine().y}},{key:"_setWindowSize",value:function(e){y.setWindowSize(this,e)}},{key:"assertValidity",value:function(){l(this)}},{key:"hasEvenY",value:function(){var e=this.toAffine().y;if(o.isOdd)return!o.isOdd(e);throw Error("Field doesn't support isOdd")}},{key:"equals",value:function(e){n(e);var t=this,r=t.px,i=t.py,a=t.pz,u=e.px,f=e.py,s=e.pz,c=o.eql(o.mul(r,s),o.mul(u,a)),l=o.eql(o.mul(i,s),o.mul(f,a));return c&&l}},{key:"negate",value:function(){return new e(this.px,o.neg(this.py),this.pz)}},{key:"double",value:function(){var t=i.a,r=i.b,n=o.mul(r,ht),a=this,u=a.px,f=a.py,s=a.pz,c=o.ZERO,l=o.ZERO,d=o.ZERO,h=o.mul(u,u),v=o.mul(f,f),p=o.mul(s,s),y=o.mul(u,f);return y=o.add(y,y),d=o.mul(u,s),d=o.add(d,d),c=o.mul(t,d),l=o.mul(n,p),l=o.add(c,l),c=o.sub(v,l),l=o.add(v,l),l=o.mul(c,l),c=o.mul(y,c),d=o.mul(n,d),p=o.mul(t,p),y=o.sub(h,p),y=o.mul(t,y),y=o.add(y,d),d=o.add(h,h),h=o.add(d,h),h=o.add(h,p),h=o.mul(h,y),l=o.add(l,h),p=o.mul(f,s),p=o.add(p,p),h=o.mul(p,y),c=o.sub(c,h),d=o.mul(p,v),d=o.add(d,d),new e(c,l,d=o.add(d,d))}},{key:"add",value:function(t){n(t);var r=this,a=r.px,u=r.py,f=r.pz,s=t.px,c=t.py,l=t.pz,d=o.ZERO,h=o.ZERO,v=o.ZERO,p=i.a,y=o.mul(i.b,ht),g=o.mul(a,s),m=o.mul(u,c),w=o.mul(f,l),b=o.add(a,u),E=o.add(s,c);b=o.mul(b,E),E=o.add(g,m),b=o.sub(b,E),E=o.add(a,f);var B=o.add(s,l);return E=o.mul(E,B),B=o.add(g,w),E=o.sub(E,B),B=o.add(u,f),d=o.add(c,l),B=o.mul(B,d),d=o.add(m,w),B=o.sub(B,d),v=o.mul(p,E),d=o.mul(y,w),v=o.add(d,v),d=o.sub(m,v),v=o.add(m,v),h=o.mul(d,v),m=o.add(g,g),m=o.add(m,g),w=o.mul(p,w),E=o.mul(y,E),m=o.add(m,w),w=o.sub(g,w),w=o.mul(p,w),E=o.add(E,w),g=o.mul(m,E),h=o.add(h,g),g=o.mul(B,E),d=o.mul(b,d),d=o.sub(d,g),g=o.mul(b,m),v=o.mul(B,v),new e(d,h,v=o.add(v,g))}},{key:"subtract",value:function(e){return this.add(e.negate())}},{key:"is0",value:function(){return this.equals(e.ZERO)}},{key:"wNAF",value:function(t){return y.wNAFCached(this,t,e.normalizeZ)}},{key:"multiplyUnsafe",value:function(t){var r=i.endo,n=i.n;Se("scalar",t,lt,n);var a=e.ZERO;if(t===lt)return a;if(this.is0()||t===dt)return this;if(!r||y.hasPrecomputes(this))return y.wNAFCachedUnsafe(this,t,e.normalizeZ);for(var u=r.splitScalar(t),f=u.k1neg,s=u.k1,c=u.k2neg,l=u.k2,d=a,h=a,v=this;s>lt||l>lt;)s&dt&&(d=d.add(v)),l&dt&&(h=h.add(v)),v=v.double(),s>>=dt,l>>=dt;return f&&(d=d.negate()),c&&(h=h.negate()),h=new e(o.mul(h.px,r.beta),h.py,h.pz),d.add(h)}},{key:"multiply",value:function(t){var r,n,a=i.endo,u=i.n;if(Se("scalar",t,dt,u),a){var f=a.splitScalar(t),s=f.k1neg,c=f.k1,l=f.k2neg,d=f.k2,h=this.wNAF(c),v=h.p,p=h.f,g=this.wNAF(d),m=g.p,w=g.f;v=y.constTimeNegate(s,v),m=y.constTimeNegate(l,m),m=new e(o.mul(m.px,a.beta),m.py,m.pz),r=v.add(m),n=p.add(w)}else{var b=this.wNAF(t);r=b.p,n=b.f}return e.normalizeZ([r,n])[0]}},{key:"multiplyAndAddUnsafe",value:function(t,r,n){var i=e.BASE,o=function(e,t){return t!==lt&&t!==dt&&e.equals(i)?e.multiply(t):e.multiplyUnsafe(t)},a=o(this,r).add(o(t,n));return a.is0()?void 0:a}},{key:"toAffine",value:function(e){return c(this,e)}},{key:"isTorsionFree",value:function(){var t=i.h,r=i.isTorsionFree;if(t===dt)return!0;if(r)return r(e,this);throw Error("isTorsionFree() has not been declared for the elliptic curve")}},{key:"clearCofactor",value:function(){var t=i.h,r=i.clearCofactor;return t===dt?this:r?r(e,this):this.multiplyUnsafe(i.h)}},{key:"toRawBytes",value:function(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return ie("isCompressed",t),this.assertValidity(),u(e,this,t)}},{key:"toHex",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return ie("isCompressed",e),ae(this.toRawBytes(e))}}],[{key:"fromAffine",value:function(t){var r=t||{},n=r.x,i=r.y;if(!t||!o.isValid(n)||!o.isValid(i))throw Error("invalid affine point");if(t instanceof e)throw Error("projective point not allowed");var a=function(e){return o.eql(e,o.ZERO)};return a(n)&&a(i)?e.ZERO:new e(n,i,o.ONE)}},{key:"normalizeZ",value:function(t){var r=o.invertBatch(t.map((function(e){return e.pz})));return t.map((function(e,t){return e.toAffine(r[t])})).map(e.fromAffine)}},{key:"fromHex",value:function(t){var r=e.fromAffine(f(Ee("pointHex",t)));return r.assertValidity(),r}},{key:"fromPrivateKey",value:function(t){return e.BASE.multiply(r(t))}},{key:"msm",value:function(t,r){return function(e,t,r,n){if(function(e,t){if(!Array.isArray(e))throw Error("array expected");e.forEach((function(e,r){if(!(e instanceof t))throw Error("invalid point at index "+r)}))}(r,e),function(e,t){if(!Array.isArray(e))throw Error("array of scalars expected");e.forEach((function(e,r){if(!t.isValid(e))throw Error("invalid scalar at index "+r)}))}(n,t),r.length!==n.length)throw Error("arrays of points and scalars must have equal length");for(var i=e.ZERO,o=xe(BigInt(r.length)),a=o>12?o-3:o>4?o-2:o?2:1,u=(1<<a)-1,f=Array(u+1).fill(i),s=i,c=Math.floor((t.BITS-1)/a)*a;c>=0;c-=a){f.fill(i);for(var l=0;l<n.length;l++){var d=n[l],h=Number(d>>BigInt(c)&BigInt(u));f[h]=f[h].add(r[l])}for(var v=i,p=f.length-1,y=i;p>0;p--)y=y.add(f[p]),v=v.add(y);if(s=s.add(v),0!==c)for(var g=0;g<a;g++)s=s.double()}return s}(e,a,t,r)}}]),e}();d.BASE=new d(i.Gx,i.Gy,o.ONE),d.ZERO=new d(o.ZERO,o.ONE,o.ZERO);var h,v,p=i.nBitLength,y=(h=d,v=i.endo?Math.ceil(p/2):p,s={constTimeNegate:$e,hasPrecomputes:function(e){return 1!==it(e)},unsafeLadder:function(e,t){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:h.ZERO,n=e;t>Qe;)t&Xe&&(r=r.add(n)),n=n.double(),t>>=Xe;return r},precomputeWindow:function(e,t){for(var r=tt(t,v),n=r.windows,i=r.windowSize,o=[],a=e,u=a,f=0;f<n;f++){u=a,o.push(u);for(var s=1;s<i;s++)u=u.add(a),o.push(u);a=u.double()}return o}},(0,k.default)(s,"wNAF",(function(e,t,r){for(var n=tt(e,v),i=n.windows,o=n.windowSize,a=h.ZERO,u=h.BASE,f=BigInt(Math.pow(2,e)-1),s=Math.pow(2,e),c=BigInt(e),l=0;l<i;l++){var d=l*o,p=Number(r&f);r>>=c,p>o&&(p-=s,r+=Xe);var y=d,g=d+Math.abs(p)-1,m=l%2!=0,w=p<0;0===p?u=u.add($e(m,t[y])):a=a.add($e(w,t[g]))}return{p:a,f:u}})),(0,k.default)(s,"wNAFUnsafe",(function(e,t,r){for(var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:h.ZERO,i=tt(e,v),o=i.windows,a=i.windowSize,u=BigInt(Math.pow(2,e)-1),f=Math.pow(2,e),s=BigInt(e),c=0;c<o;c++){var l=c*a;if(r===Qe)break;var d=Number(r&u);if(r>>=s,d>a&&(d-=f,r+=Xe),0!==d){var p=t[l+Math.abs(d)-1];d<0&&(p=p.negate()),n=n.add(p)}}return n})),(0,k.default)(s,"getPrecomputes",(function(e,t,r){var n=rt.get(t);return n||(n=this.precomputeWindow(t,e),1!==e&&rt.set(t,r(n))),n})),(0,k.default)(s,"wNAFCached",(function(e,t,r){var n=it(e);return this.wNAF(n,this.getPrecomputes(n,e,r),t)})),(0,k.default)(s,"wNAFCachedUnsafe",(function(e,t,r,n){var i=it(e);return 1===i?this.unsafeLadder(e,t,n):this.wNAFUnsafe(i,this.getPrecomputes(i,e,r),t,n)})),(0,k.default)(s,"setWindowSize",(function(e,t){et(t,v),nt.set(e,t),rt.delete(e)})),s);return{CURVE:i,ProjectivePoint:d,normPrivateKeyToScalar:r,weierstrassEquation:t,isWithinCurveOrder:function(e){return ke(e,dt,i.n)}}}BigInt(4);var pt=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),yt=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),gt=BigInt(1),mt=BigInt(2),wt=function(e,t){return(e+t/mt)/t};function bt(e){var t=pt,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),a=BigInt(23),u=BigInt(44),f=BigInt(88),s=e*e*e%t,c=s*s*e%t,l=Me(c,r,t)*c%t,d=Me(l,r,t)*c%t,h=Me(d,mt,t)*s%t,v=Me(h,i,t)*h%t,p=Me(v,o,t)*v%t,y=Me(p,u,t)*p%t,g=Me(y,f,t)*y%t,m=Me(g,u,t)*p%t,w=Me(m,r,t)*c%t,b=Me(w,a,t)*v%t,E=Me(b,n,t)*s%t,B=Me(E,mt,t);if(!Et.eql(Et.sqr(B),e))throw Error("Cannot find square root");return B}var Et=We(pt,void 0,void 0,{sqrt:bt}),Bt=function(e,t){var r=function(t){return function(e){var t=function(e){return je(e,s)},r=function(e){return Ze(e,s)},n=function(e){return e>s>>dt},i=function(e){var t=re(e),r="string"==typeof e,n=(t||r)&&e.length;return t?n===c||n===l:r?n===2*c||n===2*l:e instanceof h},o=function(e){return Se("num < 2^"+u.nBitLength,e,lt,S),we(e,u.nByteLength)},a=function(e,i){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:T;if(["recovered","canonical"].some((function(e){return e in a})))throw Error("sign() legacy options not supported");var s=u.hash,c=u.randomBytes,l=a.lowS,d=a.prehash,p=a.extraEntropy;null==l&&(l=!0),e=Ee("msgHash",e),at(a),d&&(e=Ee("prehashed msgHash",s(e)));var g=k(e),m=v(i),b=[o(m),o(g)];if(null!=p&&!1!==p){var B=!0===p?c(f.BYTES):p;b.push(Ee("extraEntropy",B))}var A=Be.apply(void 0,(0,P.default)(b)),S=g;return{seed:A,k2sig:function(e){var i=E(e);if(y(i)){var o=r(i),a=h.BASE.multiply(i).toAffine(),u=t(a.x);if(u!==lt){var f=t(o*t(S+u*m));if(f!==lt){var s=(a.x===u?0:2)|Number(a.y&dt),c=f;return l&&n(f)&&(c=function(e){return n(e)?t(-e):e}(f),s^=1),new w(u,c,s)}}}}}},u=function(e){var t=ot(e);return _e(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze((0,x.default)({lowS:!0},t))}(e),f=u.Fp,s=u.n,c=f.BYTES+1,l=2*f.BYTES+1,d=vt((0,I.default)((0,x.default)({},u),{toBytes:function(e,t,r){var n=t.toAffine(),i=f.toBytes(n.x),o=Be;return ie("isCompressed",r),r?o(Uint8Array.from([t.hasEvenY()?2:3]),i):o(Uint8Array.from([4]),i,f.toBytes(n.y))},fromBytes:function(e){var t=e.length,r=e[0],n=e.subarray(1);if(t!==c||2!==r&&3!==r){if(t===l&&4===r)return{x:f.fromBytes(n.subarray(0,f.BYTES)),y:f.fromBytes(n.subarray(f.BYTES,2*f.BYTES))};throw Error("invalid Point, expected length of "+c+", or uncompressed "+l+", got "+t)}var i=ge(n);if(!ke(i,dt,f.ORDER))throw Error("Point is not on curve");var o,a=p(i);try{o=f.sqrt(a)}catch(e){var u=e instanceof Error?": "+e.message:"";throw Error("Point is not on curve"+u)}return!(1&~r)!=((o&dt)===dt)&&(o=f.neg(o)),{x:i,y:o}}})),h=d.ProjectivePoint,v=d.normPrivateKeyToScalar,p=d.weierstrassEquation,y=d.isWithinCurveOrder,g=function(e){return ae(we(e,u.nByteLength))},m=function(e,t,r){return ge(e.slice(t,r))},w=function(){"use strict";function e(t,r,n){(0,B.default)(this,e),this.r=t,this.s=r,this.recovery=n,this.assertValidity()}return(0,A.default)(e,[{key:"assertValidity",value:function(){Se("r",this.r,dt,s),Se("s",this.s,dt,s)}},{key:"addRecoveryBit",value:function(t){return new e(this.r,this.s,t)}},{key:"recoverPublicKey",value:function(e){var n=this,i=n.r,o=n.s,a=n.recovery,s=k(Ee("msgHash",e));if(null==a||![0,1,2,3].includes(a))throw Error("recovery id invalid");var c=2===a||3===a?i+u.n:i;if(c>=f.ORDER)throw Error("recovery id 2 or 3 invalid");var l=1&a?"03":"02",d=h.fromHex(l+g(c)),v=r(c),p=t(-s*v),y=t(o*v),m=h.BASE.multiplyAndAddUnsafe(d,p,y);if(!m)throw Error("point at infinify");return m.assertValidity(),m}},{key:"hasHighS",value:function(){return n(this.s)}},{key:"normalizeS",value:function(){return this.hasHighS()?new e(this.r,t(-this.s),this.recovery):this}},{key:"toDERRawBytes",value:function(){return ye(this.toDERHex())}},{key:"toDERHex",value:function(){return ct.hexFromSig({r:this.r,s:this.s})}},{key:"toCompactRawBytes",value:function(){return ye(this.toCompactHex())}},{key:"toCompactHex",value:function(){return g(this.r)+g(this.s)}}],[{key:"fromCompact",value:function(t){var r=u.nByteLength;return t=Ee("compactSignature",t,2*r),new e(m(t,0,r),m(t,r,2*r))}},{key:"fromDER",value:function(t){var r=ct.toSig(Ee("DER",t));return new e(r.r,r.s)}}]),e}(),b={isValidPrivateKey:function(e){try{return v(e),!0}catch(e){return!1}},normPrivateKeyToScalar:v,randomPrivateKey:function(){var e=Je(u.n);return function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=e.length,i=Ye(t),o=Je(t);if(n<16||n<o||n>1024)throw Error("expected "+o+"-1024 bytes of input, got "+n);var a=je(r?me(e):ge(e),t-qe)+qe;return r?be(a,i):we(a,i)}(u.randomBytes(e),u.n)},precompute:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.BASE;return t._setWindowSize(e),t.multiply(BigInt(3)),t}},E=u.bits2int||function(e){if(e.length>8192)throw Error("input is too large");var t=ge(e),r=8*e.length-u.nBitLength;return r>0?t>>BigInt(r):t},k=u.bits2int_modN||function(e){return t(E(e))},S=Ie(u.nBitLength),T={lowS:u.lowS,prehash:!1},O={lowS:u.lowS,prehash:!1};return h.BASE._setWindowSize(8),{CURVE:u,getPublicKey:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return h.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(i(e))throw Error("first arg must be private key");if(!i(t))throw Error("second arg must be public key");return h.fromHex(t).multiply(v(e)).toRawBytes(r)},sign:function(e,t){var r=a(e,t,arguments.length>2&&void 0!==arguments[2]?arguments[2]:T),n=r.seed,i=r.k2sig,o=u;return Pe(o.hash.outputLen,o.nByteLength,o.hmac)(n,i)},verify:function(e,n,i){var o,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:O,f=e;n=Ee("msgHash",n),i=Ee("publicKey",i);var s=a.lowS,c=a.prehash,l=a.format;if(at(a),"strict"in a)throw Error("options.strict was renamed to lowS");if(void 0!==l&&"compact"!==l&&"der"!==l)throw Error("format must be compact or der");var d,v,p="string"==typeof f||re(f),y=!p&&!l&&"object"==typeof f&&null!==f&&"bigint"==(0,L.default)(f.r)&&"bigint"==(0,L.default)(f.s);if(!p&&!y)throw Error("invalid signature, expected Uint8Array, hex string or Signature instance");try{if(y&&(d=new w(f.r,f.s)),p){try{"compact"!==l&&(d=w.fromDER(f))}catch(e){if(!(e instanceof ct.Err))throw e}d||"der"===l||(d=w.fromCompact(f))}v=h.fromHex(i)}catch(e){return!1}if(!d)return!1;if(s&&d.hasHighS())return!1;c&&(n=u.hash(n));var g=d.r,m=d.s,b=k(n),E=r(m),B=t(b*E),A=t(g*E),S=null===(o=h.BASE.multiplyAndAddUnsafe(v,B,A))||void 0===o?void 0:o.toAffine();return!!S&&t(S.x)===g},ProjectivePoint:h,Signature:w,utils:b}}((0,x.default)({},e,function(e){return{hash:e,hmac:function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return X(e,t,function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(var n=0,i=0;i<t.length;i++){var o=t[i];q(o),n+=o.length}for(var a=new Uint8Array(n),u=0,f=0;u<t.length;u++){var s=t[u];a.set(s,f),f+=s.length}return a}.apply(this,(0,P.default)(n)))},randomBytes:V}}(t)))};return(0,I.default)((0,x.default)({},r(t)),{create:r})}({a:BigInt(0),b:BigInt(7),Fp:Et,n:yt,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:function(e){var t=yt,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-gt*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,a=BigInt("0x100000000000000000000000000000000"),u=wt(o*e,t),f=wt(-n*e,t),s=je(e-u*r-f*i,t),c=je(-u*n-f*o,t),l=s>a,d=c>a;if(l&&(s=t-s),d&&(c=t-c),s>a||c>a)throw Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:l,k1:s,k2neg:d,k2:c}}}},J),At=BigInt(0),kt={};function St(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];var i=kt[e];if(void 0===i){var o=J(Uint8Array.from(e,(function(e){return e.charCodeAt(0)})));i=Be(o,o),kt[e]=i}return J(Be.apply(void 0,[i].concat((0,P.default)(r))))}var xt=function(e){return e.toRawBytes(!0).slice(1)},It=function(e){return we(e,32)},Tt=function(e){return je(e,pt)},Ot=function(e){return je(e,yt)},Pt=Bt.ProjectivePoint;function Lt(e){var t=Bt.utils.normPrivateKeyToScalar(e),r=Pt.fromPrivateKey(t);return{scalar:r.hasEvenY()?t:Ot(-t),bytes:xt(r)}}function _t(e){Se("x",e,gt,pt);var t=Tt(e*e),r=bt(Tt(t*e+BigInt(7)));r%mt!==At&&(r=Tt(-r));var n=new Pt(e,r,gt);return n.assertValidity(),n}var Rt=ge;function Ut(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Ot(Rt(St.apply(void 0,["BIP0340/challenge"].concat((0,P.default)(t)))))}function Nt(e,t,r){var n,i,o,a=Ee("signature",e,64),u=Ee("message",t),f=Ee("publicKey",r,32);try{var s=_t(Rt(f)),c=Rt(a.subarray(0,32));if(!ke(c,gt,pt))return!1;var l=Rt(a.subarray(32,64));if(!ke(l,gt,yt))return!1;var d=Ut(It(c),xt(s),u),h=(n=s,i=l,o=Ot(-d),Pt.BASE.multiplyAndAddUnsafe(n,i,o));return!(!h||!h.hasEvenY()||h.toAffine().x!==c)}catch(e){return!1}}var qt,Ht,Ct={getPublicKey:function(e){return Lt(e).bytes},sign:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:V(32),n=Ee("message",e),i=Lt(t),o=i.bytes,a=i.scalar,u=Ee("auxRand",r,32),f=It(a^Rt(St("BIP0340/aux",u))),s=St("BIP0340/nonce",f,o,n),c=Ot(Rt(s));if(c===At)throw Error("sign failed: k is zero");var l=Lt(c),d=l.bytes,h=l.scalar,v=Ut(d,o,n),p=new Uint8Array(64);if(p.set(d,0),p.set(It(Ot(h+v*a)),32),!Nt(p,n,o))throw Error("sign: Invalid signature produced");return p},verify:Nt,utils:{randomPrivateKey:Bt.utils.randomPrivateKey,lift_x:_t,pointToBytes:xt,numberToBytesBE:we,bytesToNumberBE:ge,taggedHash:St,mod:je}},Dt=Math.floor,zt=Math.random,Ft=Math.sin,jt="Trystero",Vt=function(e,t){return Array(e).fill().map(t)},Mt=function(e){return Vt(e,(function(){return"0123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz"[Dt(62*zt())]})).join("")},Zt=Mt(20),Kt=Promise.all.bind(Promise),Gt="undefined"!=typeof window,Wt=Object.entries,Yt=Object.fromEntries,Jt=Object.keys,Qt=function(){},Xt=function(e){return Error("".concat(jt,": ").concat(e))},$t=new TextEncoder,er=new TextDecoder,tr=function(e){return $t.encode(e)},rr=function(e){return er.decode(e)},nr=function(e){return e.reduce((function(e,t){return e+t.toString(16).padStart(2,"0")}),"")},ir=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.join("@")},or=JSON.stringify,ar=JSON.parse,ur=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Number.MAX_SAFE_INTEGER;return e.split("").reduce((function(e,t){return e+t.charCodeAt(0)}),0)%t},fr={},sr="AES-GCM",cr={},lr=(qt=(0,E.default)((function(e){var t,r,n;return(0,U.__generator)(this,(function(i){switch(i.label){case 0:return(t=cr[e])?[3,2]:(r=Array.from,n=Uint8Array.bind,[4,crypto.subtle.digest("SHA-1",tr(e))]);case 1:t=cr[e]=r.apply(Array,[new(n.apply(Uint8Array,[void 0,i.sent()]))]).map((function(e){return e.toString(36)})).join(""),i.label=2;case 2:return[2,t]}}))})),function(e){return qt.apply(this,arguments)}),dr=function(){var e=(0,E.default)((function(e,t){var r,n,i,o,a,u;return(0,U.__generator)(this,(function(f){switch(f.label){case 0:return r=crypto.getRandomValues(new Uint8Array(16)),i=r.join(",")+"$",a=(o=crypto.subtle).encrypt,u=[{name:sr,iv:r}],[4,e];case 1:return[4,a.apply(o,u.concat([f.sent(),tr(t)]))];case 2:return[2,i+(n=f.sent(),btoa(String.fromCharCode.apply(null,new Uint8Array(n))))]}}))}));return function(t,r){return e.apply(this,arguments)}}(),hr=function(){var e=(0,E.default)((function(e,t){var r,n,i,o,a,u;return(0,U.__generator)(this,(function(f){switch(f.label){case 0:return r=(0,O.default)(t.split("$"),2),n=r[0],i=r[1],a=(o=crypto.subtle).decrypt,u=[{name:sr,iv:new Uint8Array(n.split(","))}],[4,e];case 1:return[4,a.apply(o,u.concat([f.sent(),function(e){var t=atob(e);return new Uint8Array(t.length).map((function(e,r){return t.charCodeAt(r)})).buffer}(i)]))];case 2:return[2,rr.apply(void 0,[f.sent()])]}}))}));return function(t,r){return e.apply(this,arguments)}}(),vr="icegatheringstatechange",pr=function(e){return e.replace(/a=ice-options:trickle\s\n/g,"")},yr=function(e,t){var r=t.rtcConfig,n=t.rtcPolyfill,i=t.turnConfig,o=new(n||RTCPeerConnection)((0,x.default)({iceServers:gr.concat(i||[])},r)),a={},u=function(e){e.binaryType="arraybuffer",e.bufferedAmountLowThreshold=65535,e.onmessage=function(e){var t;return null===(t=a.data)||void 0===t?void 0:t.call(a,e.data)},e.onopen=function(){var e;return null===(e=a.connect)||void 0===e?void 0:e.call(a)},e.onclose=function(){var e;return null===(e=a.close)||void 0===e?void 0:e.call(a)},e.onerror=function(e){var t;return null===(t=a.error)||void 0===t?void 0:t.call(a,e)}},f=function(){var e=(0,E.default)((function(e){return(0,U.__generator)(this,(function(t){switch(t.label){case 0:if(!e.localDescription)throw Error("No local description available");return[4,Promise.race([new Promise((function(t){var r=function(){"complete"===e.iceGatheringState&&(e.removeEventListener(vr,r),t())};e.addEventListener(vr,r),r()})),new Promise((function(e){return setTimeout(e,5e3)}))])];case 1:return[2,(t.sent(),{type:e.localDescription.type,sdp:pr(e.localDescription.sdp)})]}}))}));return function(t){return e.apply(this,arguments)}}(),s=!1,c=null;return e?(c=o.createDataChannel("data"),u(c)):o.ondatachannel=function(e){var t=e.channel;c=t,u(t)},o.onnegotiationneeded=(0,E.default)((function(){var e,t,r,n;return(0,U.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,4,5]),s=!0,[4,o.setLocalDescription()];case 1:return i.sent(),[4,f(o)];case 2:return t=i.sent(),null===(e=a.signal)||void 0===e||e.call(a,{type:t.type,sdp:pr(t.sdp)}),[3,5];case 3:return r=i.sent(),null===(n=a.error)||void 0===n||n.call(a,r),[3,5];case 4:return s=!1,[7];case 5:return[2]}}))})),o.onconnectionstatechange=function(){var e;["disconnected","failed","closed"].includes(o.connectionState)&&(null===(e=a.close)||void 0===e||e.call(a))},o.ontrack=function(e){var t,r;null===(t=a.track)||void 0===t||t.call(a,e.track,e.streams[0]),null===(r=a.stream)||void 0===r||r.call(a,e.streams[0])},o.onremovestream=function(e){var t;null===(t=a.stream)||void 0===t||t.call(a,e.stream,{removed:!0})},{created:Date.now(),connection:o,get channel(){return c},get isDead(){return"closed"===o.connectionState},signal:function(t){return(0,E.default)((function(){var r,n,i,u,l,d,h,v;return(0,U.__generator)(this,(function(p){switch(p.label){case 0:if("open"===(null==c?void 0:c.readyState))return[3,10];p.label=1;case 1:return p.trys.push([1,8,,9]),"offer"!==t.type?[3,5]:!s&&"stable"===o.signalingState||e?[4,o.setRemoteDescription(t)]:[2];case 2:return p.sent(),[4,o.setLocalDescription()];case 3:return p.sent(),[4,f(o)];case 4:return n=p.sent(),i=pr(n.sdp),[2,(null===(r=a.signal)||void 0===r||r.call(a,{type:n.type,sdp:i}),{type:n.type,sdp:i})];case 5:return"answer"!==t.type||"have-local-offer"!==o.signalingState&&"have-remote-offer"!==o.signalingState?[3,7]:[4,o.setRemoteDescription(t)];case 6:p.sent(),p.label=7;case 7:return[3,9];case 8:return u=p.sent(),null===(l=a.error)||void 0===l||l.call(a,u),[3,9];case 9:return[3,15];case 10:return(d="offer"===t.type||"stable"!==o.signalingState)?[4,o.setRemoteDescription(t)]:[3,12];case 11:p.sent(),d="offer"===t.type,p.label=12;case 12:return d?[4,o.setLocalDescription()]:[3,15];case 13:return p.sent(),[4,f(o)];case 14:return v=p.sent(),[2,(null===(h=a.signal)||void 0===h||h.call(a,{type:v.type,sdp:v.sdp}),{type:v.type,sdp:v.sdp})];case 15:return[2]}}))}))()},sendData:function(e){return c.send(e)},destroy:function(){c&&c.close(),o.close()},setHandlers:function(e){return Object.assign(a,e)},offerPromise:e?new Promise((function(e){a.signal=function(t){"offer"===t.type&&e(t)}})):Promise.resolve(),addStream:function(e){e.getTracks().forEach((function(t){return o.addTrack(t,e)}))},removeStream:function(e){o.getSenders().filter((function(t){return e.getTracks().includes(t.track)})).forEach((function(e){return o.removeTrack(e)}))},addTrack:function(e,t){return o.addTrack(e,t)},removeTrack:function(e){var t=o.getSenders().find((function(t){return t.track===e}));t&&o.removeTrack(t)},replaceTrack:function(e,t){return(0,E.default)((function(){var r;return(0,U.__generator)(this,(function(n){switch(n.label){case 0:return r=o.getSenders().find((function(t){return t.track===e})),r?[4,r.replaceTrack(t)]:[3,2];case 1:n.sent(),n.label=2;case 2:return[2]}}))}))()}}},gr=(0,P.default)(Vt(3,(function(e,t){return"stun:stun".concat(t||"",".l.google.com:19302")}))).concat(["stun:global.stun.twilio.com:3478"]).map((function(e){return{urls:e}})),mr=Object.getPrototypeOf(Uint8Array),wr=16369,br=255,Er="bufferedamountlow",Br=function(e){return"@_"+e},Ar={},kr="EVENT",Sr=Ct.utils.randomPrivateKey(),xr=nr(Ct.getPublicKey(Sr)),Ir={},Tr={},Or={},Pr=function(){return Math.floor(Date.now()/1e3)},Lr=function(e){return null!==(Ht=(o=Or)[a=e])&&void 0!==Ht?Ht:o[a]=ur(e,1e4)+2e4},_r=function(){var e=(0,E.default)((function(e,t){var r,n,i,o,a,u;return(0,U.__generator)(this,(function(f){switch(f.label){case 0:return r={kind:Lr(e),content:t,pubkey:xr,created_at:Pr(),tags:[["x",e]]},i=Uint8Array.bind,[4,crypto.subtle.digest("SHA-256",tr(or([0,r.pubkey,r.created_at,r.kind,r.tags,r.content])))];case 1:return n=nr.apply(void 0,[new(i.apply(Uint8Array,[void 0,f.sent()]))]),o=[kr],a=[(0,x.default)({},r)],u={id:n},[4,Ct.sign(n,Sr)];case 2:return[2,or.apply(void 0,[o.concat([I.default.apply(void 0,a.concat([(u.sig=nr.apply(void 0,[f.sent()]),u)]))])])]}}))}));return function(t,r){return e.apply(this,arguments)}}(),Rr=function(e,t){return Ir[e]=t,or(["REQ",e,{kinds:[Lr(t)],since:Pr(),"#x":[t]}])},Ur=function(e){return delete Ir[e],or(["CLOSE",e])},Nr=function(e){var t,r,n,i=e.init,o=e.subscribe,a=e.announce,w={},b=!1;return function(e,B,A){var k,S,T=e.appId;if(null===(S=w[T])||void 0===S?void 0:S[B])return w[T][B];var _={},R={},N=ir(jt,T,B),q=lr(N),H=lr(ir(N,Zt)),C=function(){var e=(0,E.default)((function(e,t,r){var n,i,o;return(0,U.__generator)(this,(function(a){switch(a.label){case 0:return i=(n=crypto.subtle).importKey,o=["raw"],[4,crypto.subtle.digest({name:"SHA-256"},tr("".concat(e,":").concat(t,":").concat(r)))];case 1:return[2,i.apply(n,o.concat([a.sent(),{name:sr},!1,["encrypt","decrypt"]]))]}}))}));return function(t,r,n){return e.apply(this,arguments)}}()(e.password||"",T,B),D=function(e){return function(){var t=(0,E.default)((function(t){var r;return(0,U.__generator)(this,(function(n){switch(n.label){case 0:return r={type:t.type},[4,e(C,t.sdp)];case 1:return[2,(r.sdp=n.sent(),r)]}}))}));return function(e){return t.apply(this,arguments)}}()},z=D(hr),F=D(dr),j=function(){return yr(!0,e)},V=function(e,t,r){var n;R[t]?R[t]!==e&&e.destroy():(R[t]=e,X(e,t),null===(n=_[t])||void 0===n||n.forEach((function(e,t){t!==r&&e.destroy()})),delete _[t])},M=function(e,t){R[t]===e&&delete R[t]},Z=function(e){return(k=r).push.apply(k,(0,P.default)(Vt(e,j))),Kt(r.splice(0,e).map((function(e){return e.offerPromise.then(F).then((function(t){return{peer:e,offer:t}}))})))},K=function(t,r){return null==A?void 0:A({error:"incorrect password (".concat(e.password,") when decrypting ").concat(r),appId:T,peerId:t,roomId:B})},G=function(t){return function(){var r=(0,E.default)((functio