@dodoex/wallet-web3 0.0.22-1 → 0.0.22-2

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.
Files changed (89) hide show
  1. package/dist/__tslib-dd22ed7d.js +1 -0
  2. package/dist/_commonjs-dynamic-modules-7cfc9805.js +1 -0
  3. package/dist/blocto-69a506f8.js +1 -0
  4. package/dist/bn-3e892825.js +1 -0
  5. package/dist/cjs/__tslib-8344f379.cjs +1 -0
  6. package/dist/cjs/_commonjs-dynamic-modules-f09a98c7.cjs +1 -0
  7. package/dist/cjs/blocto-bdab3cea.cjs +1 -0
  8. package/dist/cjs/bn-ce9dbccd.cjs +1 -0
  9. package/dist/cjs/ethers-767c2337.cjs +1 -0
  10. package/dist/cjs/id-6c4d97dd.cjs +1 -0
  11. package/dist/cjs/index-2428f0a6.cjs +1 -0
  12. package/dist/cjs/index-3d1a3da9.cjs +1 -0
  13. package/dist/cjs/index-4585c950.cjs +1 -0
  14. package/dist/cjs/index-47f3e61d.cjs +1 -0
  15. package/dist/cjs/index-4abb9db3.cjs +1 -0
  16. package/dist/cjs/index-5d7b94fd.cjs +1 -0
  17. package/dist/cjs/index-659dc842.cjs +61 -0
  18. package/dist/cjs/index-67e59d1a.cjs +1 -0
  19. package/dist/cjs/index-795ad993.cjs +46 -0
  20. package/dist/cjs/index-a5fa1e6e.cjs +15 -0
  21. package/dist/cjs/index-aa04e7a3.cjs +1 -0
  22. package/dist/cjs/index-cfe3e391.cjs +10 -0
  23. package/dist/cjs/index-d226aab9.cjs +8 -0
  24. package/dist/cjs/index-e875b498.cjs +1 -0
  25. package/dist/cjs/index-f2c04d55.cjs +1 -0
  26. package/dist/cjs/index.cjs +1 -1
  27. package/dist/cjs/index.es-a3704620.cjs +9 -0
  28. package/dist/cjs/interface-1b54eefa.cjs +1 -0
  29. package/dist/cjs/node-ponyfill-a7a0b431.cjs +1 -0
  30. package/dist/cjs/portis-ec0ce54d.cjs +1 -0
  31. package/dist/cjs/provider-403219c9.cjs +1 -0
  32. package/dist/cjs/rainbow-caa66e39.cjs +1 -0
  33. package/dist/cjs/uAuth-a2d2617a.cjs +1 -0
  34. package/dist/cjs/walletConnect-c57b3b5d.cjs +1 -0
  35. package/dist/cjs/walletLink-f0f9e2a7.cjs +3 -0
  36. package/dist/ethers-51e19435.js +1 -0
  37. package/dist/id-830e09aa.js +1 -0
  38. package/dist/index-0103e089.js +1 -0
  39. package/dist/index-235259d8.js +1 -0
  40. package/dist/index-3158e93a.js +46 -0
  41. package/dist/index-46c2059e.js +1 -0
  42. package/dist/index-5091218e.js +1 -0
  43. package/dist/index-5f9e8321.js +1 -0
  44. package/dist/index-650785ec.js +1 -0
  45. package/dist/index-6bf494b0.js +1 -0
  46. package/dist/index-80483be2.js +8 -0
  47. package/dist/index-82b4fd64.js +60 -0
  48. package/dist/index-88837567.js +1 -0
  49. package/dist/index-c699a924.js +1 -0
  50. package/dist/index-cc453bb1.js +10 -0
  51. package/dist/index-de37f6bb.js +1 -0
  52. package/dist/index-f3052552.js +15 -0
  53. package/dist/index.es-877101c5.js +9 -0
  54. package/dist/index.js +1 -1
  55. package/dist/interface-f97a878a.js +1 -0
  56. package/dist/node-ponyfill-55b945e1.js +1 -0
  57. package/dist/portis-7d46b7ed.js +1 -0
  58. package/dist/provider-453e2483.js +1 -0
  59. package/dist/rainbow-61a52379.js +1 -0
  60. package/dist/uAuth-40d8acab.js +1 -0
  61. package/dist/walletConnect-d6a9aa67.js +1 -0
  62. package/dist/walletLink-106461e6.js +3 -0
  63. package/package.json +1 -1
  64. package/dist/blocto-4a33d5ca.js +0 -1
  65. package/dist/cjs/blocto-c3de72cf.cjs +0 -1
  66. package/dist/cjs/index-00f30b53.cjs +0 -1
  67. package/dist/cjs/index-27eb8948.cjs +0 -1
  68. package/dist/cjs/index-34d28fe1.cjs +0 -1
  69. package/dist/cjs/index-6777aca7.cjs +0 -1
  70. package/dist/cjs/index-8fb559d0.cjs +0 -1
  71. package/dist/cjs/index-e29346ca.cjs +0 -1
  72. package/dist/cjs/portis-698618a3.cjs +0 -1
  73. package/dist/cjs/provider-9c8505bc.cjs +0 -1
  74. package/dist/cjs/rainbow-fa30e364.cjs +0 -1
  75. package/dist/cjs/uAuth-27f2257f.cjs +0 -1
  76. package/dist/cjs/walletConnect-63cd4764.cjs +0 -1
  77. package/dist/cjs/walletLink-6bf8d19c.cjs +0 -1
  78. package/dist/index-09ced70e.js +0 -1
  79. package/dist/index-1ca259fc.js +0 -1
  80. package/dist/index-4ee60b82.js +0 -1
  81. package/dist/index-775efe7e.js +0 -1
  82. package/dist/index-96419f54.js +0 -1
  83. package/dist/index-dec2384f.js +0 -1
  84. package/dist/portis-1fbfa428.js +0 -1
  85. package/dist/provider-df49c5bf.js +0 -1
  86. package/dist/rainbow-52844e55.js +0 -1
  87. package/dist/uAuth-9bf2390c.js +0 -1
  88. package/dist/walletConnect-eb49e4f6.js +0 -1
  89. package/dist/walletLink-103ec7de.js +0 -1
@@ -0,0 +1,9 @@
1
+ "use strict";var e=require("events"),t=require("./_commonjs-dynamic-modules-f09a98c7.cjs"),r=require("crypto"),n=require("./__tslib-8344f379.cjs"),i=require("./index-cfe3e391.cjs"),s=require("os"),o=require("fs"),a=require("util"),c=require("path"),u=require("worker_threads"),h=require("module"),l=require("url"),f=require("buffer"),p=require("assert"),d=require("./node-ponyfill-a7a0b431.cjs");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=g(e),m=g(r),v=g(s),b=g(o),w=g(a),_=g(c),E=g(u),S=g(h),I=g(l),O=g(f),P=g(p),A={},N={},x={},T={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.mul=Math.imul||function(e,t){var r=65535&e,n=65535&t;return r*n+((e>>>16&65535)*n+r*(t>>>16&65535)<<16>>>0)|0},e.add=function(e,t){return e+t|0},e.sub=function(e,t){return e-t|0},e.rotl=function(e,t){return e<<t|e>>>32-t},e.rotr=function(e,t){return e<<32-t|e>>>t},e.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},e.MAX_SAFE_INTEGER=9007199254740991,e.isSafeInteger=function(t){return e.isInteger(t)&&t>=-e.MAX_SAFE_INTEGER&&t<=e.MAX_SAFE_INTEGER}}(T),Object.defineProperty(x,"__esModule",{value:!0});var C=T;function j(e,t,r){return void 0===t&&(t=new Uint8Array(2)),void 0===r&&(r=0),t[r+0]=e>>>8,t[r+1]=e>>>0,t}function R(e,t,r){return void 0===t&&(t=new Uint8Array(2)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t}function L(e,t){return void 0===t&&(t=0),e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function k(e,t){return void 0===t&&(t=0),(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}function M(e,t){return void 0===t&&(t=0),e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}function U(e,t){return void 0===t&&(t=0),(e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t])>>>0}function $(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>24,t[r+1]=e>>>16,t[r+2]=e>>>8,t[r+3]=e>>>0,t}function D(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24,t}function z(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),$(e/4294967296>>>0,t,r),$(e>>>0,t,r+4),t}function q(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),D(e>>>0,t,r),D(e/4294967296>>>0,t,r+4),t}x.readInt16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])<<16>>16},x.readUint16BE=function(e,t){return void 0===t&&(t=0),(e[t+0]<<8|e[t+1])>>>0},x.readInt16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])<<16>>16},x.readUint16LE=function(e,t){return void 0===t&&(t=0),(e[t+1]<<8|e[t])>>>0},x.writeUint16BE=j,x.writeInt16BE=j,x.writeUint16LE=R,x.writeInt16LE=R,x.readInt32BE=L,x.readUint32BE=k,x.readInt32LE=M,x.readUint32LE=U,x.writeUint32BE=$,x.writeInt32BE=$,x.writeUint32LE=D,x.writeInt32LE=D,x.readInt64BE=function(e,t){void 0===t&&(t=0);var r=L(e,t),n=L(e,t+4);return 4294967296*r+n-4294967296*(n>>31)},x.readUint64BE=function(e,t){return void 0===t&&(t=0),4294967296*k(e,t)+k(e,t+4)},x.readInt64LE=function(e,t){void 0===t&&(t=0);var r=M(e,t);return 4294967296*M(e,t+4)+r-4294967296*(r>>31)},x.readUint64LE=function(e,t){void 0===t&&(t=0);var r=U(e,t);return 4294967296*U(e,t+4)+r},x.writeUint64BE=z,x.writeInt64BE=z,x.writeUint64LE=q,x.writeInt64LE=q,x.readUintBE=function(e,t,r){if(void 0===r&&(r=0),e%8!=0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=e/8+r-1;s>=r;s--)n+=t[s]*i,i*=256;return n},x.readUintLE=function(e,t,r){if(void 0===r&&(r=0),e%8!=0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+e/8;s++)n+=t[s]*i,i*=256;return n},x.writeUintBE=function(e,t,r,n){if(void 0===r&&(r=new Uint8Array(e/8)),void 0===n&&(n=0),e%8!=0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!C.isSafeInteger(t))throw new Error("writeUintBE value must be an integer");for(var i=1,s=e/8+n-1;s>=n;s--)r[s]=t/i&255,i*=256;return r},x.writeUintLE=function(e,t,r,n){if(void 0===r&&(r=new Uint8Array(e/8)),void 0===n&&(n=0),e%8!=0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!C.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s<n+e/8;s++)r[s]=t/i&255,i*=256;return r},x.readFloat32BE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t)},x.readFloat32LE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat32(t,!0)},x.readFloat64BE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t)},x.readFloat64LE=function(e,t){return void 0===t&&(t=0),new DataView(e.buffer,e.byteOffset,e.byteLength).getFloat64(t,!0)},x.writeFloat32BE=function(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat32(r,e),t},x.writeFloat32LE=function(e,t,r){return void 0===t&&(t=new Uint8Array(4)),void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat32(r,e,!0),t},x.writeFloat64BE=function(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat64(r,e),t},x.writeFloat64LE=function(e,t,r){return void 0===t&&(t=new Uint8Array(8)),void 0===r&&(r=0),new DataView(t.buffer,t.byteOffset,t.byteLength).setFloat64(r,e,!0),t};var H={};Object.defineProperty(H,"__esModule",{value:!0}),H.wipe=function(e){for(var t=0;t<e.length;t++)e[t]=0;return e},Object.defineProperty(N,"__esModule",{value:!0});var K=x,B=H,V=20;function F(e,t,r){for(var n=1634760805,i=857760878,s=2036477234,o=1797285236,a=r[3]<<24|r[2]<<16|r[1]<<8|r[0],c=r[7]<<24|r[6]<<16|r[5]<<8|r[4],u=r[11]<<24|r[10]<<16|r[9]<<8|r[8],h=r[15]<<24|r[14]<<16|r[13]<<8|r[12],l=r[19]<<24|r[18]<<16|r[17]<<8|r[16],f=r[23]<<24|r[22]<<16|r[21]<<8|r[20],p=r[27]<<24|r[26]<<16|r[25]<<8|r[24],d=r[31]<<24|r[30]<<16|r[29]<<8|r[28],g=t[3]<<24|t[2]<<16|t[1]<<8|t[0],y=t[7]<<24|t[6]<<16|t[5]<<8|t[4],m=t[11]<<24|t[10]<<16|t[9]<<8|t[8],v=t[15]<<24|t[14]<<16|t[13]<<8|t[12],b=n,w=i,_=s,E=o,S=a,I=c,O=u,P=h,A=l,N=f,x=p,T=d,C=g,j=y,R=m,L=v,k=0;k<V;k+=2)S=(S^=A=A+(C=(C^=b=b+S|0)>>>16|C<<16)|0)>>>20|S<<12,I=(I^=N=N+(j=(j^=w=w+I|0)>>>16|j<<16)|0)>>>20|I<<12,O=(O^=x=x+(R=(R^=_=_+O|0)>>>16|R<<16)|0)>>>20|O<<12,P=(P^=T=T+(L=(L^=E=E+P|0)>>>16|L<<16)|0)>>>20|P<<12,O=(O^=x=x+(R=(R^=_=_+O|0)>>>24|R<<8)|0)>>>25|O<<7,P=(P^=T=T+(L=(L^=E=E+P|0)>>>24|L<<8)|0)>>>25|P<<7,I=(I^=N=N+(j=(j^=w=w+I|0)>>>24|j<<8)|0)>>>25|I<<7,S=(S^=A=A+(C=(C^=b=b+S|0)>>>24|C<<8)|0)>>>25|S<<7,I=(I^=x=x+(L=(L^=b=b+I|0)>>>16|L<<16)|0)>>>20|I<<12,O=(O^=T=T+(C=(C^=w=w+O|0)>>>16|C<<16)|0)>>>20|O<<12,P=(P^=A=A+(j=(j^=_=_+P|0)>>>16|j<<16)|0)>>>20|P<<12,S=(S^=N=N+(R=(R^=E=E+S|0)>>>16|R<<16)|0)>>>20|S<<12,P=(P^=A=A+(j=(j^=_=_+P|0)>>>24|j<<8)|0)>>>25|P<<7,S=(S^=N=N+(R=(R^=E=E+S|0)>>>24|R<<8)|0)>>>25|S<<7,O=(O^=T=T+(C=(C^=w=w+O|0)>>>24|C<<8)|0)>>>25|O<<7,I=(I^=x=x+(L=(L^=b=b+I|0)>>>24|L<<8)|0)>>>25|I<<7;K.writeUint32LE(b+n|0,e,0),K.writeUint32LE(w+i|0,e,4),K.writeUint32LE(_+s|0,e,8),K.writeUint32LE(E+o|0,e,12),K.writeUint32LE(S+a|0,e,16),K.writeUint32LE(I+c|0,e,20),K.writeUint32LE(O+u|0,e,24),K.writeUint32LE(P+h|0,e,28),K.writeUint32LE(A+l|0,e,32),K.writeUint32LE(N+f|0,e,36),K.writeUint32LE(x+p|0,e,40),K.writeUint32LE(T+d|0,e,44),K.writeUint32LE(C+g|0,e,48),K.writeUint32LE(j+y|0,e,52),K.writeUint32LE(R+m|0,e,56),K.writeUint32LE(L+v|0,e,60)}function W(e,t,r,n,i){if(void 0===i&&(i=0),32!==e.length)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,o;if(0===i){if(8!==t.length&&12!==t.length)throw new Error("ChaCha nonce must be 8 or 12 bytes");o=(s=new Uint8Array(16)).length-t.length,s.set(t,o)}else{if(16!==t.length)throw new Error("ChaCha nonce with counter must be 16 bytes");s=t,o=i}for(var a=new Uint8Array(64),c=0;c<r.length;c+=64){F(a,s,e);for(var u=c;u<c+64&&u<r.length;u++)n[u]=r[u]^a[u-c];G(s,0,o)}return B.wipe(a),0===i&&B.wipe(s),n}function G(e,t,r){for(var n=1;r--;)n=n+(255&e[t])|0,e[t]=255&n,n>>>=8,t++;if(n>0)throw new Error("ChaCha: counter overflow")}N.streamXOR=W,N.stream=function(e,t,r,n){return void 0===n&&(n=0),B.wipe(r),W(e,t,r,r,n)};var Y={},J={};function X(e,t){if(e.length!==t.length)return 0;for(var r=0,n=0;n<e.length;n++)r|=e[n]^t[n];return 1&r-1>>>8}Object.defineProperty(J,"__esModule",{value:!0}),J.select=function(e,t,r){return~(e-1)&t|e-1&r},J.lessOrEqual=function(e,t){return(0|e)-(0|t)-1>>>31&1},J.compare=X,J.equal=function(e,t){return 0!==e.length&&0!==t.length&&0!==X(e,t)},function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=J,r=H;e.DIGEST_LENGTH=16;var n=function(){function t(t){this.digestLength=e.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var r=t[0]|t[1]<<8;this._r[0]=8191&r;var n=t[2]|t[3]<<8;this._r[1]=8191&(r>>>13|n<<3);var i=t[4]|t[5]<<8;this._r[2]=7939&(n>>>10|i<<6);var s=t[6]|t[7]<<8;this._r[3]=8191&(i>>>7|s<<9);var o=t[8]|t[9]<<8;this._r[4]=255&(s>>>4|o<<12),this._r[5]=o>>>1&8190;var a=t[10]|t[11]<<8;this._r[6]=8191&(o>>>14|a<<2);var c=t[12]|t[13]<<8;this._r[7]=8065&(a>>>11|c<<5);var u=t[14]|t[15]<<8;this._r[8]=8191&(c>>>8|u<<8),this._r[9]=u>>>5&127,this._pad[0]=t[16]|t[17]<<8,this._pad[1]=t[18]|t[19]<<8,this._pad[2]=t[20]|t[21]<<8,this._pad[3]=t[22]|t[23]<<8,this._pad[4]=t[24]|t[25]<<8,this._pad[5]=t[26]|t[27]<<8,this._pad[6]=t[28]|t[29]<<8,this._pad[7]=t[30]|t[31]<<8}return t.prototype._blocks=function(e,t,r){for(var n=this._fin?0:2048,i=this._h[0],s=this._h[1],o=this._h[2],a=this._h[3],c=this._h[4],u=this._h[5],h=this._h[6],l=this._h[7],f=this._h[8],p=this._h[9],d=this._r[0],g=this._r[1],y=this._r[2],m=this._r[3],v=this._r[4],b=this._r[5],w=this._r[6],_=this._r[7],E=this._r[8],S=this._r[9];r>=16;){var I=e[t+0]|e[t+1]<<8;i+=8191&I;var O=e[t+2]|e[t+3]<<8;s+=8191&(I>>>13|O<<3);var P=e[t+4]|e[t+5]<<8;o+=8191&(O>>>10|P<<6);var A=e[t+6]|e[t+7]<<8;a+=8191&(P>>>7|A<<9);var N=e[t+8]|e[t+9]<<8;c+=8191&(A>>>4|N<<12),u+=N>>>1&8191;var x=e[t+10]|e[t+11]<<8;h+=8191&(N>>>14|x<<2);var T=e[t+12]|e[t+13]<<8;l+=8191&(x>>>11|T<<5);var C=e[t+14]|e[t+15]<<8,j=0,R=j;R+=i*d,R+=s*(5*S),R+=o*(5*E),R+=a*(5*_),j=(R+=c*(5*w))>>>13,R&=8191,R+=u*(5*b),R+=h*(5*v),R+=l*(5*m),R+=(f+=8191&(T>>>8|C<<8))*(5*y);var L=j+=(R+=(p+=C>>>5|n)*(5*g))>>>13;L+=i*g,L+=s*d,L+=o*(5*S),L+=a*(5*E),j=(L+=c*(5*_))>>>13,L&=8191,L+=u*(5*w),L+=h*(5*b),L+=l*(5*v),L+=f*(5*m),j+=(L+=p*(5*y))>>>13,L&=8191;var k=j;k+=i*y,k+=s*g,k+=o*d,k+=a*(5*S),j=(k+=c*(5*E))>>>13,k&=8191,k+=u*(5*_),k+=h*(5*w),k+=l*(5*b),k+=f*(5*v);var M=j+=(k+=p*(5*m))>>>13;M+=i*m,M+=s*y,M+=o*g,M+=a*d,j=(M+=c*(5*S))>>>13,M&=8191,M+=u*(5*E),M+=h*(5*_),M+=l*(5*w),M+=f*(5*b);var U=j+=(M+=p*(5*v))>>>13;U+=i*v,U+=s*m,U+=o*y,U+=a*g,j=(U+=c*d)>>>13,U&=8191,U+=u*(5*S),U+=h*(5*E),U+=l*(5*_),U+=f*(5*w);var $=j+=(U+=p*(5*b))>>>13;$+=i*b,$+=s*v,$+=o*m,$+=a*y,j=($+=c*g)>>>13,$&=8191,$+=u*d,$+=h*(5*S),$+=l*(5*E),$+=f*(5*_);var D=j+=($+=p*(5*w))>>>13;D+=i*w,D+=s*b,D+=o*v,D+=a*m,j=(D+=c*y)>>>13,D&=8191,D+=u*g,D+=h*d,D+=l*(5*S),D+=f*(5*E);var z=j+=(D+=p*(5*_))>>>13;z+=i*_,z+=s*w,z+=o*b,z+=a*v,j=(z+=c*m)>>>13,z&=8191,z+=u*y,z+=h*g,z+=l*d,z+=f*(5*S);var q=j+=(z+=p*(5*E))>>>13;q+=i*E,q+=s*_,q+=o*w,q+=a*b,j=(q+=c*v)>>>13,q&=8191,q+=u*m,q+=h*y,q+=l*g,q+=f*d;var H=j+=(q+=p*(5*S))>>>13;H+=i*S,H+=s*E,H+=o*_,H+=a*w,j=(H+=c*b)>>>13,H&=8191,H+=u*v,H+=h*m,H+=l*y,H+=f*g,i=R=8191&(j=(j=((j+=(H+=p*d)>>>13)<<2)+j|0)+(R&=8191)|0),s=L+=j>>>=13,o=k&=8191,a=M&=8191,c=U&=8191,u=$&=8191,h=D&=8191,l=z&=8191,f=q&=8191,p=H&=8191,t+=16,r-=16}this._h[0]=i,this._h[1]=s,this._h[2]=o,this._h[3]=a,this._h[4]=c,this._h[5]=u,this._h[6]=h,this._h[7]=l,this._h[8]=f,this._h[9]=p},t.prototype.finish=function(e,t){void 0===t&&(t=0);var r,n,i,s,o=new Uint16Array(10);if(this._leftover){for(s=this._leftover,this._buffer[s++]=1;s<16;s++)this._buffer[s]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(r=this._h[1]>>>13,this._h[1]&=8191,s=2;s<10;s++)this._h[s]+=r,r=this._h[s]>>>13,this._h[s]&=8191;for(this._h[0]+=5*r,r=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=r,r=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=r,o[0]=this._h[0]+5,r=o[0]>>>13,o[0]&=8191,s=1;s<10;s++)o[s]=this._h[s]+r,r=o[s]>>>13,o[s]&=8191;for(o[9]-=8192,n=(1^r)-1,s=0;s<10;s++)o[s]&=n;for(n=~n,s=0;s<10;s++)this._h[s]=this._h[s]&n|o[s];for(this._h[0]=65535&(this._h[0]|this._h[1]<<13),this._h[1]=65535&(this._h[1]>>>3|this._h[2]<<10),this._h[2]=65535&(this._h[2]>>>6|this._h[3]<<7),this._h[3]=65535&(this._h[3]>>>9|this._h[4]<<4),this._h[4]=65535&(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14),this._h[5]=65535&(this._h[6]>>>2|this._h[7]<<11),this._h[6]=65535&(this._h[7]>>>5|this._h[8]<<8),this._h[7]=65535&(this._h[8]>>>8|this._h[9]<<5),i=this._h[0]+this._pad[0],this._h[0]=65535&i,s=1;s<8;s++)i=(this._h[s]+this._pad[s]|0)+(i>>>16)|0,this._h[s]=65535&i;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},t.prototype.update=function(e){var t,r=0,n=e.length;if(this._leftover){(t=16-this._leftover)>n&&(t=n);for(var i=0;i<t;i++)this._buffer[this._leftover+i]=e[r+i];if(n-=t,r+=t,this._leftover+=t,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(n>=16&&(t=n-n%16,this._blocks(e,r,t),r+=t,n-=t),n){for(i=0;i<n;i++)this._buffer[this._leftover+i]=e[r+i];this._leftover+=n}return this},t.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var e=new Uint8Array(16);return this.finish(e),e},t.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},t}();e.Poly1305=n,e.oneTimeAuth=function(e,t){var r=new n(e);r.update(t);var i=r.digest();return r.clean(),i},e.equal=function(r,n){return r.length===e.DIGEST_LENGTH&&n.length===e.DIGEST_LENGTH&&t.equal(r,n)}}(Y),function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=N,r=Y,n=H,i=x,s=J;e.KEY_LENGTH=32,e.NONCE_LENGTH=12,e.TAG_LENGTH=16;var o=new Uint8Array(16),a=function(){function a(t){if(this.nonceLength=e.NONCE_LENGTH,this.tagLength=e.TAG_LENGTH,t.length!==e.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(t)}return a.prototype.seal=function(e,r,i,s){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var o=new Uint8Array(16);o.set(e,o.length-e.length);var a=new Uint8Array(32);t.stream(this._key,o,a,4);var c,u=r.length+this.tagLength;if(s){if(s.length!==u)throw new Error("ChaCha20Poly1305: incorrect destination length");c=s}else c=new Uint8Array(u);return t.streamXOR(this._key,o,r,c,4),this._authenticate(c.subarray(c.length-this.tagLength,c.length),a,c.subarray(0,c.length-this.tagLength),i),n.wipe(o),c},a.prototype.open=function(e,r,i,o){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(r.length<this.tagLength)return null;var a=new Uint8Array(16);a.set(e,a.length-e.length);var c=new Uint8Array(32);t.stream(this._key,a,c,4);var u=new Uint8Array(this.tagLength);if(this._authenticate(u,c,r.subarray(0,r.length-this.tagLength),i),!s.equal(u,r.subarray(r.length-this.tagLength,r.length)))return null;var h,l=r.length-this.tagLength;if(o){if(o.length!==l)throw new Error("ChaCha20Poly1305: incorrect destination length");h=o}else h=new Uint8Array(l);return t.streamXOR(this._key,a,r.subarray(0,r.length-this.tagLength),h,4),n.wipe(a),h},a.prototype.clean=function(){return n.wipe(this._key),this},a.prototype._authenticate=function(e,t,s,a){var c=new r.Poly1305(t);a&&(c.update(a),a.length%16>0&&c.update(o.subarray(a.length%16))),c.update(s),s.length%16>0&&c.update(o.subarray(s.length%16));var u=new Uint8Array(8);a&&i.writeUint64LE(a.length,u),c.update(u),i.writeUint64LE(s.length,u),c.update(u);for(var h=c.digest(),l=0;l<h.length;l++)e[l]=h[l];c.clean(),n.wipe(h),n.wipe(u)},a}();e.ChaCha20Poly1305=a}(A);var Z={},Q={},ee={};Object.defineProperty(ee,"__esModule",{value:!0}),ee.isSerializableHash=function(e){return void 0!==e.saveState&&void 0!==e.restoreState&&void 0!==e.cleanSavedState},Object.defineProperty(Q,"__esModule",{value:!0});var te=ee,re=J,ne=H,ie=function(){function e(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var r=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(r).clean():r.set(t);for(var n=0;n<r.length;n++)r[n]^=54;this._inner.update(r);for(n=0;n<r.length;n++)r[n]^=106;this._outer.update(r),te.isSerializableHash(this._inner)&&te.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),ne.wipe(r)}return e.prototype.reset=function(){if(!te.isSerializableHash(this._inner)||!te.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},e.prototype.clean=function(){te.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),te.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},e.prototype.update=function(e){return this._inner.update(e),this},e.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},e.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},e.prototype.saveState=function(){if(!te.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},e.prototype.restoreState=function(e){if(!te.isSerializableHash(this._inner)||!te.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},e.prototype.cleanSavedState=function(e){if(!te.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},e}();Q.HMAC=ie,Q.hmac=function(e,t,r){var n=new ie(e,t);n.update(r);var i=n.digest();return n.clean(),i},Q.equal=re.equal,Object.defineProperty(Z,"__esModule",{value:!0});var se=Q,oe=H,ae=function(){function e(e,t,r,n){void 0===r&&(r=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var i=se.hmac(this._hash,r,t);this._hmac=new se.HMAC(e,i),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return e.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(0===e)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},e.prototype.expand=function(e){for(var t=new Uint8Array(e),r=0;r<t.length;r++)this._bufpos===this._buffer.length&&this._fillBuffer(),t[r]=this._buffer[this._bufpos++];return t},e.prototype.clean=function(){this._hmac.clean(),oe.wipe(this._buffer),oe.wipe(this._counter),this._bufpos=0},e}(),ce=Z.HKDF=ae,ue={},he={},le={};Object.defineProperty(le,"__esModule",{value:!0}),le.BrowserRandomSource=void 0;le.BrowserRandomSource=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e="undefined"!=typeof self?self.crypto||self.msCrypto:null;e&&void 0!==e.getRandomValues&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const t=new Uint8Array(e);for(let e=0;e<t.length;e+=65536)this._crypto.getRandomValues(t.subarray(e,e+Math.min(t.length-e,65536)));return t}};var fe={};Object.defineProperty(fe,"__esModule",{value:!0}),fe.NodeRandomSource=void 0;const pe=H;fe.NodeRandomSource=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,void 0!==t.commonjsRequire){const e=m.default;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const r=new Uint8Array(e);for(let e=0;e<r.length;e++)r[e]=t[e];return(0,pe.wipe)(t),r}},Object.defineProperty(he,"__esModule",{value:!0}),he.SystemRandomSource=void 0;const de=le,ge=fe;he.SystemRandomSource=class{constructor(){return this.isAvailable=!1,this.name="",this._source=new de.BrowserRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Browser")):(this._source=new ge.NodeRandomSource,this._source.isAvailable?(this.isAvailable=!0,void(this.name="Node")):void 0)}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.randomStringForEntropy=e.randomString=e.randomUint32=e.randomBytes=e.defaultRandomSource=void 0;const t=he,r=x,n=H;function i(t,r=e.defaultRandomSource){return r.randomBytes(t)}e.defaultRandomSource=new t.SystemRandomSource,e.randomBytes=i,e.randomUint32=function(t=e.defaultRandomSource){const s=i(4,t),o=(0,r.readUint32LE)(s);return(0,n.wipe)(s),o};const s="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function o(t,r=s,o=e.defaultRandomSource){if(r.length<2)throw new Error("randomString charset is too short");if(r.length>256)throw new Error("randomString charset is too long");let a="";const c=r.length,u=256-256%c;for(;t>0;){const e=i(Math.ceil(256*t/u),o);for(let n=0;n<e.length&&t>0;n++){const i=e[n];i<u&&(a+=r.charAt(i%c),t--)}(0,n.wipe)(e)}return a}e.randomString=o,e.randomStringForEntropy=function(t,r=s,n=e.defaultRandomSource){return o(Math.ceil(t/(Math.log(r.length)/Math.LN2)),r,n)}}(ue);var ye={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=x,r=H;e.DIGEST_LENGTH=32,e.BLOCK_SIZE=64;var n=function(){function n(){this.digestLength=e.DIGEST_LENGTH,this.blockSize=e.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return n.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},n.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},n.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},n.prototype.update=function(e,t){if(void 0===t&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var r=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&t>0;)this._buffer[this._bufferLength++]=e[r++],t--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(r=s(this._temp,this._state,e,r,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[r++],t--;return this},n.prototype.finish=function(e){if(!this._finished){var r=this._bytesHashed,n=this._bufferLength,i=r/536870912|0,o=r<<3,a=r%64<56?64:128;this._buffer[n]=128;for(var c=n+1;c<a-8;c++)this._buffer[c]=0;t.writeUint32BE(i,this._buffer,a-8),t.writeUint32BE(o,this._buffer,a-4),s(this._temp,this._state,this._buffer,0,a),this._finished=!0}for(c=0;c<this.digestLength/4;c++)t.writeUint32BE(this._state[c],e,4*c);return this},n.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},n.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},n.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},n.prototype.cleanSavedState=function(e){r.wipe(e.state),e.buffer&&r.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},n}();e.SHA256=n;var i=new Int32Array([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]);function s(e,r,n,s,o){for(;o>=64;){for(var a=r[0],c=r[1],u=r[2],h=r[3],l=r[4],f=r[5],p=r[6],d=r[7],g=0;g<16;g++){var y=s+4*g;e[g]=t.readUint32BE(n,y)}for(g=16;g<64;g++){var m=e[g-2],v=(m>>>17|m<<15)^(m>>>19|m<<13)^m>>>10,b=((m=e[g-15])>>>7|m<<25)^(m>>>18|m<<14)^m>>>3;e[g]=(v+e[g-7]|0)+(b+e[g-16]|0)}for(g=0;g<64;g++){v=(((l>>>6|l<<26)^(l>>>11|l<<21)^(l>>>25|l<<7))+(l&f^~l&p)|0)+(d+(i[g]+e[g]|0)|0)|0,b=((a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10))+(a&c^a&u^c&u)|0;d=p,p=f,f=l,l=h+v|0,h=u,u=c,c=a,a=v+b|0}r[0]+=a,r[1]+=c,r[2]+=u,r[3]+=h,r[4]+=l,r[5]+=f,r[6]+=p,r[7]+=d,s+=64,o-=64}return s}e.hash=function(e){var t=new n;t.update(e);var r=t.digest();return t.clean(),r}}(ye);var me={};function ve(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function be(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?ve(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function we(e,t){t||(t=e.reduce(((e,t)=>e+t.length),0));const r=be(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return ve(r)}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.sharedKey=e.generateKeyPair=e.generateKeyPairFromSeed=e.scalarMultBase=e.scalarMult=e.SHARED_KEY_LENGTH=e.SECRET_KEY_LENGTH=e.PUBLIC_KEY_LENGTH=void 0;const t=ue,r=H;function n(e){const t=new Float64Array(16);if(e)for(let r=0;r<e.length;r++)t[r]=e[r];return t}e.PUBLIC_KEY_LENGTH=32,e.SECRET_KEY_LENGTH=32,e.SHARED_KEY_LENGTH=32;const i=new Uint8Array(32);i[0]=9;const s=n([56129,1]);function o(e){let t=1;for(let r=0;r<16;r++){let n=e[r]+t+65535;t=Math.floor(n/65536),e[r]=n-65536*t}e[0]+=t-1+37*(t-1)}function a(e,t,r){const n=~(r-1);for(let r=0;r<16;r++){const i=n&(e[r]^t[r]);e[r]^=i,t[r]^=i}}function c(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]+r[n]}function u(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]-r[n]}function h(e,t,r){let n,i,s=0,o=0,a=0,c=0,u=0,h=0,l=0,f=0,p=0,d=0,g=0,y=0,m=0,v=0,b=0,w=0,_=0,E=0,S=0,I=0,O=0,P=0,A=0,N=0,x=0,T=0,C=0,j=0,R=0,L=0,k=0,M=r[0],U=r[1],$=r[2],D=r[3],z=r[4],q=r[5],H=r[6],K=r[7],B=r[8],V=r[9],F=r[10],W=r[11],G=r[12],Y=r[13],J=r[14],X=r[15];n=t[0],s+=n*M,o+=n*U,a+=n*$,c+=n*D,u+=n*z,h+=n*q,l+=n*H,f+=n*K,p+=n*B,d+=n*V,g+=n*F,y+=n*W,m+=n*G,v+=n*Y,b+=n*J,w+=n*X,n=t[1],o+=n*M,a+=n*U,c+=n*$,u+=n*D,h+=n*z,l+=n*q,f+=n*H,p+=n*K,d+=n*B,g+=n*V,y+=n*F,m+=n*W,v+=n*G,b+=n*Y,w+=n*J,_+=n*X,n=t[2],a+=n*M,c+=n*U,u+=n*$,h+=n*D,l+=n*z,f+=n*q,p+=n*H,d+=n*K,g+=n*B,y+=n*V,m+=n*F,v+=n*W,b+=n*G,w+=n*Y,_+=n*J,E+=n*X,n=t[3],c+=n*M,u+=n*U,h+=n*$,l+=n*D,f+=n*z,p+=n*q,d+=n*H,g+=n*K,y+=n*B,m+=n*V,v+=n*F,b+=n*W,w+=n*G,_+=n*Y,E+=n*J,S+=n*X,n=t[4],u+=n*M,h+=n*U,l+=n*$,f+=n*D,p+=n*z,d+=n*q,g+=n*H,y+=n*K,m+=n*B,v+=n*V,b+=n*F,w+=n*W,_+=n*G,E+=n*Y,S+=n*J,I+=n*X,n=t[5],h+=n*M,l+=n*U,f+=n*$,p+=n*D,d+=n*z,g+=n*q,y+=n*H,m+=n*K,v+=n*B,b+=n*V,w+=n*F,_+=n*W,E+=n*G,S+=n*Y,I+=n*J,O+=n*X,n=t[6],l+=n*M,f+=n*U,p+=n*$,d+=n*D,g+=n*z,y+=n*q,m+=n*H,v+=n*K,b+=n*B,w+=n*V,_+=n*F,E+=n*W,S+=n*G,I+=n*Y,O+=n*J,P+=n*X,n=t[7],f+=n*M,p+=n*U,d+=n*$,g+=n*D,y+=n*z,m+=n*q,v+=n*H,b+=n*K,w+=n*B,_+=n*V,E+=n*F,S+=n*W,I+=n*G,O+=n*Y,P+=n*J,A+=n*X,n=t[8],p+=n*M,d+=n*U,g+=n*$,y+=n*D,m+=n*z,v+=n*q,b+=n*H,w+=n*K,_+=n*B,E+=n*V,S+=n*F,I+=n*W,O+=n*G,P+=n*Y,A+=n*J,N+=n*X,n=t[9],d+=n*M,g+=n*U,y+=n*$,m+=n*D,v+=n*z,b+=n*q,w+=n*H,_+=n*K,E+=n*B,S+=n*V,I+=n*F,O+=n*W,P+=n*G,A+=n*Y,N+=n*J,x+=n*X,n=t[10],g+=n*M,y+=n*U,m+=n*$,v+=n*D,b+=n*z,w+=n*q,_+=n*H,E+=n*K,S+=n*B,I+=n*V,O+=n*F,P+=n*W,A+=n*G,N+=n*Y,x+=n*J,T+=n*X,n=t[11],y+=n*M,m+=n*U,v+=n*$,b+=n*D,w+=n*z,_+=n*q,E+=n*H,S+=n*K,I+=n*B,O+=n*V,P+=n*F,A+=n*W,N+=n*G,x+=n*Y,T+=n*J,C+=n*X,n=t[12],m+=n*M,v+=n*U,b+=n*$,w+=n*D,_+=n*z,E+=n*q,S+=n*H,I+=n*K,O+=n*B,P+=n*V,A+=n*F,N+=n*W,x+=n*G,T+=n*Y,C+=n*J,j+=n*X,n=t[13],v+=n*M,b+=n*U,w+=n*$,_+=n*D,E+=n*z,S+=n*q,I+=n*H,O+=n*K,P+=n*B,A+=n*V,N+=n*F,x+=n*W,T+=n*G,C+=n*Y,j+=n*J,R+=n*X,n=t[14],b+=n*M,w+=n*U,_+=n*$,E+=n*D,S+=n*z,I+=n*q,O+=n*H,P+=n*K,A+=n*B,N+=n*V,x+=n*F,T+=n*W,C+=n*G,j+=n*Y,R+=n*J,L+=n*X,n=t[15],w+=n*M,_+=n*U,E+=n*$,S+=n*D,I+=n*z,O+=n*q,P+=n*H,A+=n*K,N+=n*B,x+=n*V,T+=n*F,C+=n*W,j+=n*G,R+=n*Y,L+=n*J,k+=n*X,s+=38*_,o+=38*E,a+=38*S,c+=38*I,u+=38*O,h+=38*P,l+=38*A,f+=38*N,p+=38*x,d+=38*T,g+=38*C,y+=38*j,m+=38*R,v+=38*L,b+=38*k,i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-65536*i,n=o+i+65535,i=Math.floor(n/65536),o=n-65536*i,n=a+i+65535,i=Math.floor(n/65536),a=n-65536*i,n=c+i+65535,i=Math.floor(n/65536),c=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=n-65536*i,n=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=l+i+65535,i=Math.floor(n/65536),l=n-65536*i,n=f+i+65535,i=Math.floor(n/65536),f=n-65536*i,n=p+i+65535,i=Math.floor(n/65536),p=n-65536*i,n=d+i+65535,i=Math.floor(n/65536),d=n-65536*i,n=g+i+65535,i=Math.floor(n/65536),g=n-65536*i,n=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=b+i+65535,i=Math.floor(n/65536),b=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,s+=i-1+37*(i-1),i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-65536*i,n=o+i+65535,i=Math.floor(n/65536),o=n-65536*i,n=a+i+65535,i=Math.floor(n/65536),a=n-65536*i,n=c+i+65535,i=Math.floor(n/65536),c=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=n-65536*i,n=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=l+i+65535,i=Math.floor(n/65536),l=n-65536*i,n=f+i+65535,i=Math.floor(n/65536),f=n-65536*i,n=p+i+65535,i=Math.floor(n/65536),p=n-65536*i,n=d+i+65535,i=Math.floor(n/65536),d=n-65536*i,n=g+i+65535,i=Math.floor(n/65536),g=n-65536*i,n=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=b+i+65535,i=Math.floor(n/65536),b=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,s+=i-1+37*(i-1),e[0]=s,e[1]=o,e[2]=a,e[3]=c,e[4]=u,e[5]=h,e[6]=l,e[7]=f,e[8]=p,e[9]=d,e[10]=g,e[11]=y,e[12]=m,e[13]=v,e[14]=b,e[15]=w}function l(e,t){h(e,t,t)}function f(e,t){const r=new Uint8Array(32),i=new Float64Array(80),f=n(),p=n(),d=n(),g=n(),y=n(),m=n();for(let t=0;t<31;t++)r[t]=e[t];r[31]=127&e[31]|64,r[0]&=248,function(e,t){for(let r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(i,t);for(let e=0;e<16;e++)p[e]=i[e];f[0]=g[0]=1;for(let e=254;e>=0;--e){const t=r[e>>>3]>>>(7&e)&1;a(f,p,t),a(d,g,t),c(y,f,d),u(f,f,d),c(d,p,g),u(p,p,g),l(g,y),l(m,f),h(f,d,f),h(d,p,y),c(y,f,d),u(f,f,d),l(p,f),u(d,g,m),h(f,d,s),c(f,f,g),h(d,d,f),h(f,g,m),h(g,p,i),l(p,y),a(f,p,t),a(d,g,t)}for(let e=0;e<16;e++)i[e+16]=f[e],i[e+32]=d[e],i[e+48]=p[e],i[e+64]=g[e];const v=i.subarray(32),b=i.subarray(16);!function(e,t){const r=n();for(let e=0;e<16;e++)r[e]=t[e];for(let e=253;e>=0;e--)l(r,r),2!==e&&4!==e&&h(r,r,t);for(let t=0;t<16;t++)e[t]=r[t]}(v,v),h(b,b,v);const w=new Uint8Array(32);return function(e,t){const r=n(),i=n();for(let e=0;e<16;e++)i[e]=t[e];o(i),o(i),o(i);for(let e=0;e<2;e++){r[0]=i[0]-65517;for(let e=1;e<15;e++)r[e]=i[e]-65535-(r[e-1]>>16&1),r[e-1]&=65535;r[15]=i[15]-32767-(r[14]>>16&1);const e=r[15]>>16&1;r[14]&=65535,a(i,r,1-e)}for(let t=0;t<16;t++)e[2*t]=255&i[t],e[2*t+1]=i[t]>>8}(w,b),w}function p(e){return f(e,i)}function d(t){if(t.length!==e.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${e.SECRET_KEY_LENGTH} bytes`);const r=new Uint8Array(t);return{publicKey:p(r),secretKey:r}}e.scalarMult=f,e.scalarMultBase=p,e.generateKeyPairFromSeed=d,e.generateKeyPair=function(e){const n=(0,t.randomBytes)(32,e),i=d(n);return(0,r.wipe)(n),i},e.sharedKey=function(t,r,n=!1){if(t.length!==e.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(r.length!==e.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const i=f(t,r);if(n){let e=0;for(let t=0;t<i.length;t++)e|=i[t];if(0===e)throw new Error("X25519: invalid shared key")}return i}}(me);var _e=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var l=0,f=s-1;(0!==h||l<i)&&-1!==f;f--,l++)h+=a*o[f]>>>0,o[f]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,t++}if(" "!==e[t]){for(var p=s-i;p!==s&&0===o[p];)p++;for(var d=new Uint8Array(n+(s-p)),g=n;p!==s;)d[g++]=o[p++];return d}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*h+1>>>0,u=new Uint8Array(o);i!==s;){for(var l=t[i],f=0,p=o-1;(0!==l||f<n)&&-1!==p;p--,f++)l+=256*u[p]>>>0,u[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");n=f,i++}for(var d=o-n;d!==o&&0===u[d];)d++;for(var g=c.repeat(r);d<o;++d)g+=e.charAt(u[d]);return g},decodeUnsafe:l,decode:function(e){var r=l(e);if(r)return r;throw new Error(`Non-${t} character`)}}},Ee=_e;const Se=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class Ie{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Oe{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return Ae(this,e)}}class Pe{constructor(e){this.decoders=e}or(e){return Ae(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Ae=(e,t)=>new Pe({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class Ne{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Ie(e,t,r),this.decoder=new Oe(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const xe=({name:e,prefix:t,encode:r,decode:n})=>new Ne(e,t,r,n),Te=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:i}=Ee(r,t);return xe({prefix:e,name:t,encode:n,decode:e=>Se(i(e))})},Ce=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>xe({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let n=0;n<e.length;++n)for(a=a<<8|e[n],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(o&&(s+=t[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s})(e,n,r),decode:t=>((e,t,r,n)=>{const i={};for(let e=0;e<t.length;++e)i[t[e]]=e;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let t=0;t<s;++t){const s=i[e[t]];if(void 0===s)throw new SyntaxError(`Non-${n} character`);c=c<<r|s,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,n,r,e)}),je=xe({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var Re=Object.freeze({__proto__:null,identity:je});const Le=Ce({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ke=Object.freeze({__proto__:null,base2:Le});const Me=Ce({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ue=Object.freeze({__proto__:null,base8:Me});const $e=Te({prefix:"9",name:"base10",alphabet:"0123456789"});var De=Object.freeze({__proto__:null,base10:$e});const ze=Ce({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),qe=Ce({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var He=Object.freeze({__proto__:null,base16:ze,base16upper:qe});const Ke=Ce({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Be=Ce({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ve=Ce({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Fe=Ce({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),We=Ce({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ge=Ce({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ye=Ce({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Je=Ce({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Xe=Ce({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ze=Object.freeze({__proto__:null,base32:Ke,base32upper:Be,base32pad:Ve,base32padupper:Fe,base32hex:We,base32hexupper:Ge,base32hexpad:Ye,base32hexpadupper:Je,base32z:Xe});const Qe=Te({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),et=Te({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var tt=Object.freeze({__proto__:null,base36:Qe,base36upper:et});const rt=Te({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),nt=Te({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var it=Object.freeze({__proto__:null,base58btc:rt,base58flickr:nt});const st=Ce({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ot=Ce({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),at=Ce({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ct=Ce({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ut=Object.freeze({__proto__:null,base64:st,base64pad:ot,base64url:at,base64urlpad:ct});const ht=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),lt=ht.reduce(((e,t,r)=>(e[r]=t,e)),[]),ft=ht.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const pt=xe({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=lt[t]),"")},decode:function(e){const t=[];for(const r of e){const e=ft[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});var dt=Object.freeze({__proto__:null,base256emoji:pt}),gt=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=vt;)r[n++]=255&t|yt,t/=128;for(;t&mt;)r[n++]=255&t|yt,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},yt=128,mt=-128,vt=Math.pow(2,31);var bt=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&_t)<<s:(n&_t)*Math.pow(2,s),s+=7}while(n>=wt);return e.bytes=o-r,i},wt=128,_t=127;var Et=Math.pow(2,7),St=Math.pow(2,14),It=Math.pow(2,21),Ot=Math.pow(2,28),Pt=Math.pow(2,35),At=Math.pow(2,42),Nt=Math.pow(2,49),xt=Math.pow(2,56),Tt=Math.pow(2,63),Ct={encode:gt,decode:bt,encodingLength:function(e){return e<Et?1:e<St?2:e<It?3:e<Ot?4:e<Pt?5:e<At?6:e<Nt?7:e<xt?8:e<Tt?9:10}};const jt=(e,t,r=0)=>(Ct.encode(e,t,r),t),Rt=e=>Ct.encodingLength(e),Lt=(e,t)=>{const r=t.byteLength,n=Rt(e),i=n+Rt(r),s=new Uint8Array(i+r);return jt(e,s,0),jt(r,s,n),s.set(t,i),new kt(e,r,t,s)};class kt{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Mt=({name:e,code:t,encode:r})=>new Ut(e,t,r);class Ut{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Lt(this.code,t):t.then((e=>Lt(this.code,e)))}throw Error("Unknown type, must be binary type")}}Mt({name:"sha2-256",code:18,encode:e=>Se(m.default.createHash("sha256").update(e).digest())}),Mt({name:"sha2-512",code:19,encode:e=>Se(m.default.createHash("sha512").update(e).digest())});new TextEncoder,new TextDecoder;const $t={...Re,...ke,...Ue,...De,...He,...Ze,...tt,...it,...ut,...dt};function Dt(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const zt=Dt("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),qt=Dt("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=be((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Ht={utf8:zt,"utf-8":zt,hex:$t.base16,latin1:qt,ascii:qt,binary:qt,...$t};function Kt(e,t="utf8"){const r=Ht[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode(`${r.prefix}${e}`):ve(globalThis.Buffer.from(e,"utf-8"))}function Bt(e,t="utf8"){const r=Ht[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.encoder.encode(e).substring(1):globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8")}var Vt=function(e,t,r){if(r||2===arguments.length)for(var n,i=0,s=t.length;i<s;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))},Ft=function(e,t,r){this.name=e,this.version=t,this.os=r,this.type="browser"},Wt=function(e){this.version=e,this.type="node",this.name="node",this.os=process.platform},Gt=function(e,t,r,n){this.name=e,this.version=t,this.os=r,this.bot=n,this.type="bot-device"},Yt=function(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null},Jt=function(){this.type="react-native",this.name="react-native",this.version=null,this.os=null},Xt=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Zt=3,Qt=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/]],er=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function tr(e){return e?rr(e):"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product?new Jt:"undefined"!=typeof navigator?rr(navigator.userAgent):"undefined"!=typeof process&&process.version?new Wt(process.version.slice(1)):null}function rr(e){var t=function(e){return""!==e&&Qt.reduce((function(t,r){var n=r[0],i=r[1];if(t)return t;var s=i.exec(e);return!!s&&[n,s]}),!1)}(e);if(!t)return null;var r=t[0],n=t[1];if("searchbot"===r)return new Yt;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<Zt&&(i=Vt(Vt([],i,!0),function(e){for(var t=[],r=0;r<e;r++)t.push("0");return t}(Zt-i.length),!0)):i=[];var s=i.join("."),o=function(e){for(var t=0,r=er.length;t<r;t++){var n=er[t],i=n[0];if(n[1].exec(e))return i}return null}(e),a=Xt.exec(e);return a&&a[1]?new Gt(r,s,o,a[1]):new Ft(r,s,o)}var nr,ir={},sr={},or={};var ar,cr={},ur={},hr={};var lr,fr,pr,dr,gr={};function yr(){return fr||(fr=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=n.require$$0;t.__exportStar((ar||(ar=1,Object.defineProperty(hr,"__esModule",{value:!0}),hr.ONE_THOUSAND=hr.ONE_HUNDRED=void 0,hr.ONE_HUNDRED=100,hr.ONE_THOUSAND=1e3),hr),e),t.__exportStar((lr||(lr=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ONE_YEAR=e.FOUR_WEEKS=e.THREE_WEEKS=e.TWO_WEEKS=e.ONE_WEEK=e.THIRTY_DAYS=e.SEVEN_DAYS=e.FIVE_DAYS=e.THREE_DAYS=e.ONE_DAY=e.TWENTY_FOUR_HOURS=e.TWELVE_HOURS=e.SIX_HOURS=e.THREE_HOURS=e.ONE_HOUR=e.SIXTY_MINUTES=e.THIRTY_MINUTES=e.TEN_MINUTES=e.FIVE_MINUTES=e.ONE_MINUTE=e.SIXTY_SECONDS=e.THIRTY_SECONDS=e.TEN_SECONDS=e.FIVE_SECONDS=e.ONE_SECOND=void 0,e.ONE_SECOND=1,e.FIVE_SECONDS=5,e.TEN_SECONDS=10,e.THIRTY_SECONDS=30,e.SIXTY_SECONDS=60,e.ONE_MINUTE=e.SIXTY_SECONDS,e.FIVE_MINUTES=5*e.ONE_MINUTE,e.TEN_MINUTES=10*e.ONE_MINUTE,e.THIRTY_MINUTES=30*e.ONE_MINUTE,e.SIXTY_MINUTES=60*e.ONE_MINUTE,e.ONE_HOUR=e.SIXTY_MINUTES,e.THREE_HOURS=3*e.ONE_HOUR,e.SIX_HOURS=6*e.ONE_HOUR,e.TWELVE_HOURS=12*e.ONE_HOUR,e.TWENTY_FOUR_HOURS=24*e.ONE_HOUR,e.ONE_DAY=e.TWENTY_FOUR_HOURS,e.THREE_DAYS=3*e.ONE_DAY,e.FIVE_DAYS=5*e.ONE_DAY,e.SEVEN_DAYS=7*e.ONE_DAY,e.THIRTY_DAYS=30*e.ONE_DAY,e.ONE_WEEK=e.SEVEN_DAYS,e.TWO_WEEKS=2*e.ONE_WEEK,e.THREE_WEEKS=3*e.ONE_WEEK,e.FOUR_WEEKS=4*e.ONE_WEEK,e.ONE_YEAR=365*e.ONE_DAY}(gr)),gr),e)}(ur)),ur}function mr(){return dr||(dr=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=n.require$$0;t.__exportStar((nr||(nr=1,Object.defineProperty(or,"__esModule",{value:!0}),or.delay=void 0,or.delay=function(e){return new Promise((t=>{setTimeout((()=>{t(!0)}),e)}))}),or),e),t.__exportStar(function(){if(pr)return cr;pr=1,Object.defineProperty(cr,"__esModule",{value:!0}),cr.fromMiliseconds=cr.toMiliseconds=void 0;const e=yr();return cr.toMiliseconds=function(t){return t*e.ONE_THOUSAND},cr.fromMiliseconds=function(t){return Math.floor(t/e.ONE_THOUSAND)},cr}(),e)}(sr)),sr}var vr,br={};var wr,_r,Er={},Sr={};function Ir(){return _r||(_r=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});n.require$$0.__exportStar((wr||(wr=1,Object.defineProperty(Sr,"__esModule",{value:!0}),Sr.IWatch=void 0,Sr.IWatch=class{}),Sr),e)}(Er)),Er}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=n.require$$0;t.__exportStar(mr(),e),t.__exportStar(function(){if(vr)return br;vr=1,Object.defineProperty(br,"__esModule",{value:!0}),br.Watch=void 0;class e{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){const t=this.get(e);if(void 0!==t.elapsed)throw new Error(`Watch already stopped for label: ${e}`);const r=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:r})}get(e){const t=this.timestamps.get(e);if(void 0===t)throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){const t=this.get(e);return t.elapsed||Date.now()-t.started}}return br.Watch=e,br.default=e,br}(),e),t.__exportStar(Ir(),e),t.__exportStar(yr(),e)}(ir);var Or={};function Pr(e){let t;return"undefined"!=typeof window&&void 0!==window[e]&&(t=window[e]),t}function Ar(e){const t=Pr(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}Object.defineProperty(Or,"__esModule",{value:!0}),Or.getLocalStorage=Or.getLocalStorageOrThrow=Or.getCrypto=Or.getCryptoOrThrow=Tr=Or.getLocation=Or.getLocationOrThrow=xr=Or.getNavigator=Or.getNavigatorOrThrow=Nr=Or.getDocument=Or.getDocumentOrThrow=Or.getFromWindowOrThrow=Or.getFromWindow=void 0,Or.getFromWindow=Pr,Or.getFromWindowOrThrow=Ar,Or.getDocumentOrThrow=function(){return Ar("document")};var Nr=Or.getDocument=function(){return Pr("document")};Or.getNavigatorOrThrow=function(){return Ar("navigator")};var xr=Or.getNavigator=function(){return Pr("navigator")};Or.getLocationOrThrow=function(){return Ar("location")};var Tr=Or.getLocation=function(){return Pr("location")};Or.getCryptoOrThrow=function(){return Ar("crypto")},Or.getCrypto=function(){return Pr("crypto")},Or.getLocalStorageOrThrow=function(){return Ar("localStorage")},Or.getLocalStorage=function(){return Pr("localStorage")};var Cr={};Object.defineProperty(Cr,"__esModule",{value:!0});var jr=Cr.getWindowMetadata=void 0;const Rr=Or;jr=Cr.getWindowMetadata=function(){let e,t;try{e=Rr.getDocumentOrThrow(),t=Rr.getLocationOrThrow()}catch(e){return null}function r(...t){const r=e.getElementsByTagName("meta");for(let e=0;e<r.length;e++){const n=r[e],i=["itemprop","property","name"].map((e=>n.getAttribute(e))).filter((e=>!!e&&t.includes(e)));if(i.length&&i){const e=n.getAttribute("content");if(e)return e}}return""}const n=function(){let t=r("name","og:site_name","og:title","twitter:title");return t||(t=e.title),t}();return{description:r("description","og:description","twitter:description","keywords"),url:t.origin,icons:function(){const r=e.getElementsByTagName("link"),n=[];for(let e=0;e<r.length;e++){const i=r[e],s=i.getAttribute("rel");if(s&&s.toLowerCase().indexOf("icon")>-1){const e=i.getAttribute("href");if(e)if(-1===e.toLowerCase().indexOf("https:")&&-1===e.toLowerCase().indexOf("http:")&&0!==e.indexOf("//")){let r=t.protocol+"//"+t.host;if(0===e.indexOf("/"))r+=e;else{const n=t.pathname.split("/");n.pop();r+=n.join("/")+"/"+e}n.push(r)}else if(0===e.indexOf("//")){const r=t.protocol+e;n.push(r)}else n.push(e)}}return n}(),name:n}};var Lr={},kr=e=>encodeURIComponent(e).replace(/[!'()*]/g,(e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)),Mr="%[a-f0-9]{2}",Ur=new RegExp("("+Mr+")|([^%]+?)","gi"),$r=new RegExp("("+Mr+")+","gi");function Dr(e,t){try{return[decodeURIComponent(e.join(""))]}catch(e){}if(1===e.length)return e;t=t||1;var r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],Dr(r),Dr(n))}function zr(e){try{return decodeURIComponent(e)}catch(n){for(var t=e.match(Ur)||[],r=1;r<t.length;r++)t=(e=Dr(t,r).join("")).match(Ur)||[];return e}}var qr=function(e){if("string"!=typeof e)throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof e+"`");try{return e=e.replace(/\+/g," "),decodeURIComponent(e)}catch(t){return function(e){for(var t={"%FE%FF":"��","%FF%FE":"��"},r=$r.exec(e);r;){try{t[r[0]]=decodeURIComponent(r[0])}catch(e){var n=zr(r[0]);n!==r[0]&&(t[r[0]]=n)}r=$r.exec(e)}t["%C2"]="�";for(var i=Object.keys(t),s=0;s<i.length;s++){var o=i[s];e=e.replace(new RegExp(o,"g"),t[o])}return e}(e)}},Hr=(e,t)=>{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===t)return[e];const r=e.indexOf(t);return-1===r?[e]:[e.slice(0,r),e.slice(r+t.length)]},Kr=function(e,t){for(var r={},n=Object.keys(e),i=Array.isArray(t),s=0;s<n.length;s++){var o=n[s],a=e[o];(i?-1!==t.indexOf(o):t(o,a,e))&&(r[o]=a)}return r};!function(e){const t=kr,r=qr,n=Hr,i=Kr,s=Symbol("encodeFragmentIdentifier");function o(e){if("string"!=typeof e||1!==e.length)throw new TypeError("arrayFormatSeparator must be single character string")}function a(e,r){return r.encode?r.strict?t(e):encodeURIComponent(e):e}function c(e,t){return t.decode?r(e):e}function u(e){return Array.isArray(e)?e.sort():"object"==typeof e?u(Object.keys(e)).sort(((e,t)=>Number(e)-Number(t))).map((t=>e[t])):e}function h(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function l(e){const t=(e=h(e)).indexOf("?");return-1===t?"":e.slice(t+1)}function f(e,t){return t.parseNumbers&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?e=Number(e):!t.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(e="true"===e.toLowerCase()),e}function p(e,t){o((t=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},t)).arrayFormatSeparator);const r=function(e){let t;switch(e.arrayFormat){case"index":return(e,r,n)=>{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return(e,r,n)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};case"colon-list-separator":return(e,r,n)=>{t=/(:list)$/.exec(e),e=e.replace(/:list$/,""),t?void 0!==n[e]?n[e]=[].concat(n[e],r):n[e]=[r]:n[e]=r};case"comma":case"separator":return(t,r,n)=>{const i="string"==typeof r&&r.includes(e.arrayFormatSeparator),s="string"==typeof r&&!i&&c(r,e).includes(e.arrayFormatSeparator);r=s?c(r,e):r;const o=i||s?r.split(e.arrayFormatSeparator).map((t=>c(t,e))):null===r?r:c(r,e);n[t]=o};case"bracket-separator":return(t,r,n)=>{const i=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!i)return void(n[t]=r?c(r,e):r);const s=null===r?[]:r.split(e.arrayFormatSeparator).map((t=>c(t,e)));void 0!==n[t]?n[t]=[].concat(n[t],s):n[t]=s};default:return(e,t,r)=>{void 0!==r[e]?r[e]=[].concat(r[e],t):r[e]=t}}}(t),i=Object.create(null);if("string"!=typeof e)return i;if(!(e=e.trim().replace(/^[?#&]/,"")))return i;for(const s of e.split("&")){if(""===s)continue;let[e,o]=n(t.decode?s.replace(/\+/g," "):s,"=");o=void 0===o?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?o:c(o,t),r(c(e,t),o,i)}for(const e of Object.keys(i)){const r=i[e];if("object"==typeof r&&null!==r)for(const e of Object.keys(r))r[e]=f(r[e],t);else i[e]=f(r,t)}return!1===t.sort?i:(!0===t.sort?Object.keys(i).sort():Object.keys(i).sort(t.sort)).reduce(((e,t)=>{const r=i[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=u(r):e[t]=r,e}),Object.create(null))}e.extract=l,e.parse=p,e.stringify=(e,t)=>{if(!e)return"";o((t=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const r=r=>t.skipNull&&null==e[r]||t.skipEmptyString&&""===e[r],n=function(e){switch(e.arrayFormat){case"index":return t=>(r,n)=>{const i=r.length;return void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[a(t,e),"[",i,"]"].join("")]:[...r,[a(t,e),"[",a(i,e),"]=",a(n,e)].join("")]};case"bracket":return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[a(t,e),"[]"].join("")]:[...r,[a(t,e),"[]=",a(n,e)].join("")];case"colon-list-separator":return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[a(t,e),":list="].join("")]:[...r,[a(t,e),":list=",a(n,e)].join("")];case"comma":case"separator":case"bracket-separator":{const t="bracket-separator"===e.arrayFormat?"[]=":"=";return r=>(n,i)=>void 0===i||e.skipNull&&null===i||e.skipEmptyString&&""===i?n:(i=null===i?"":i,0===n.length?[[a(r,e),t,a(i,e)].join("")]:[[n,a(i,e)].join(e.arrayFormatSeparator)])}default:return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,a(t,e)]:[...r,[a(t,e),"=",a(n,e)].join("")]}}(t),i={};for(const t of Object.keys(e))r(t)||(i[t]=e[t]);const s=Object.keys(i);return!1!==t.sort&&s.sort(t.sort),s.map((r=>{const i=e[r];return void 0===i?"":null===i?a(r,t):Array.isArray(i)?0===i.length&&"bracket-separator"===t.arrayFormat?a(r,t)+"[]":i.reduce(n(r),[]).join("&"):a(r,t)+"="+a(i,t)})).filter((e=>e.length>0)).join("&")},e.parseUrl=(e,t)=>{t=Object.assign({decode:!0},t);const[r,i]=n(e,"#");return Object.assign({url:r.split("?")[0]||"",query:p(l(e),t)},t&&t.parseFragmentIdentifier&&i?{fragmentIdentifier:c(i,t)}:{})},e.stringifyUrl=(t,r)=>{r=Object.assign({encode:!0,strict:!0,[s]:!0},r);const n=h(t.url).split("?")[0]||"",i=e.extract(t.url),o=e.parse(i,{sort:!1}),c=Object.assign(o,t.query);let u=e.stringify(c,r);u&&(u=`?${u}`);let l=function(e){let t="";const r=e.indexOf("#");return-1!==r&&(t=e.slice(r)),t}(t.url);return t.fragmentIdentifier&&(l=`#${r[s]?a(t.fragmentIdentifier,r):t.fragmentIdentifier}`),`${n}${u}${l}`},e.pick=(t,r,n)=>{n=Object.assign({parseFragmentIdentifier:!0,[s]:!1},n);const{url:o,query:a,fragmentIdentifier:c}=e.parseUrl(t,n);return e.stringifyUrl({url:o,query:i(a,r),fragmentIdentifier:c},n)},e.exclude=(t,r,n)=>{const i=Array.isArray(r)?e=>!r.includes(e):(e,t)=>!r(e,t);return e.pick(t,i,n)}}(Lr);const Br={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe"}};function Vr(e,t){return e.includes(":")?[e]:t.chains||[]}const Fr="base10",Wr="base16",Gr="base64pad",Yr="utf8",Jr=0,Xr=1,Zr=0,Qr=1,en=12,tn=32;function rn(){return Bt(ue.randomBytes(tn),Wr)}function nn(e){return Bt(ye.hash(Kt(e,Yr)),Wr)}function sn(e){return Number(Bt(e,Fr))}function on(e){const t=function(e){return Kt(`${e}`,Fr)}(typeof e.type<"u"?e.type:Jr);if(sn(t)===Xr&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof e.senderPublicKey<"u"?Kt(e.senderPublicKey,Wr):void 0,n=typeof e.iv<"u"?Kt(e.iv,Wr):ue.randomBytes(en);return function(e){if(sn(e.type)===Xr){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Bt(we([e.type,e.senderPublicKey,e.iv,e.sealed]),Gr)}return Bt(we([e.type,e.iv,e.sealed]),Gr)}({type:t,sealed:new A.ChaCha20Poly1305(Kt(e.symKey,Wr)).seal(n,Kt(e.message,Yr)),iv:n,senderPublicKey:r})}function an(e){const t=Kt(e,Gr),r=t.slice(Zr,Qr),n=Qr;if(sn(r)===Xr){const e=n+tn,i=e+en,s=t.slice(n,e),o=t.slice(e,i);return{type:r,sealed:t.slice(i),iv:o,senderPublicKey:s}}const i=n+en,s=t.slice(n,i);return{type:r,sealed:t.slice(i),iv:s}}function cn(e){const t=e?.type||Jr;if(t===Xr){if(typeof e?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function un(e){return e.type===Xr&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}var hn=Object.defineProperty,ln=Object.getOwnPropertySymbols,fn=Object.prototype.hasOwnProperty,pn=Object.prototype.propertyIsEnumerable,dn=(e,t,r)=>t in e?hn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,gn=(e,t)=>{for(var r in t||(t={}))fn.call(t,r)&&dn(e,r,t[r]);if(ln)for(var r of ln(t))pn.call(t,r)&&dn(e,r,t[r]);return e};const yn="ReactNative",mn={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},vn="js";function bn(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function wn(){return!Nr()&&!!xr()&&navigator.product===yn}function _n(){return!bn()&&!!xr()}function En(){return wn()?mn.reactNative:bn()?mn.node:_n()?mn.browser:mn.unknown}function Sn(e,t,r){const n=function(){if(En()===mn.reactNative&&typeof global<"u"&&typeof(null==global?void 0:global.Platform)<"u"){const{OS:e,Version:t}=global.Platform;return[e,t].join("-")}const e=tr();if(null===e)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),i=function(){var e;const t=En();return t===mn.browser?[t,(null==(e=Tr())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[vn,r].join("-"),n,i].join("/")}function In({protocol:e,version:t,relayUrl:r,sdkVersion:n,auth:i,projectId:s,useOnCloseEvent:o}){const a=r.split("?"),c={auth:i,ua:Sn(e,t,n),projectId:s,useOnCloseEvent:o||void 0},u=function(e,t){let r=Lr.parse(e);return r=gn(gn({},r),t),Lr.stringify(r)}(a[1]||"",c);return a[0]+"?"+u}function On(e,t){return e.filter((e=>t.includes(e))).length===e.length}function Pn(e){return Object.fromEntries(e.entries())}function An(e){return new Map(Object.entries(e))}function Nn(e=ir.FIVE_MINUTES,t){const r=ir.toMiliseconds(e||ir.FIVE_MINUTES);let n,i,s;return{resolve:e=>{s&&n&&(clearTimeout(s),n(e))},reject:e=>{s&&i&&(clearTimeout(s),i(e))},done:()=>new Promise(((e,o)=>{s=setTimeout((()=>{o(new Error(t))}),r),n=e,i=o}))}}function xn(e,t,r){return new Promise((async(n,i)=>{const s=setTimeout((()=>i(new Error(r))),t);try{n(await e)}catch(e){i(e)}clearTimeout(s)}))}function Tn(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function Cn(e){const[t,r]=e.split(":"),n={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof r)n.topic=r;else{if("id"!==t||!Number.isInteger(Number(r)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${r}`);n.id=Number(r)}return n}function jn(e,t){return ir.fromMiliseconds((t||Date.now())+ir.toMiliseconds(e))}function Rn(e){return Date.now()>=ir.toMiliseconds(e)}function Ln(e,t){return`${e}${t?`:${t}`:""}`}function kn(e=[],t=[]){return[...new Set([...e,...t])]}function Mn(e){return e?.relay||{protocol:"irn"}}function Un(e){const t=Br[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}var $n=Object.defineProperty,Dn=Object.getOwnPropertySymbols,zn=Object.prototype.hasOwnProperty,qn=Object.prototype.propertyIsEnumerable,Hn=(e,t,r)=>t in e?$n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;function Kn(e,t="-"){const r={},n="relay"+t;return Object.keys(e).forEach((t=>{if(t.startsWith(n)){const i=t.replace(n,""),s=e[t];r[i]=s}})),r}function Bn(e){return e.startsWith("//")?e.substring(2):e}function Vn(e){return`${e.protocol}:${e.topic}@${e.version}?`+Lr.stringify(((e,t)=>{for(var r in t||(t={}))zn.call(t,r)&&Hn(e,r,t[r]);if(Dn)for(var r of Dn(t))qn.call(t,r)&&Hn(e,r,t[r]);return e})({symKey:e.symKey},function(e,t="-"){const r={};return Object.keys(e).forEach((n=>{const i="relay"+t+n;e[n]&&(r[i]=e[n])})),r}(e.relay)))}function Fn(e){const t=[];return e.forEach((e=>{const[r,n]=e.split(":");t.push(`${r}:${n}`)})),t}function Wn(e){return e.includes(":")}function Gn(e){return Wn(e)?e.split(":")[0]:e}const Yn={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},Jn={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Xn(e,t){const{message:r,code:n}=Jn[e];return{message:t?`${r} ${t}`:r,code:n}}function Zn(e,t){const{message:r,code:n}=Yn[e];return{message:t?`${r} ${t}`:r,code:n}}function Qn(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function ei(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function ti(e){return typeof e>"u"}function ri(e,t){return!(!t||!ti(e))||"string"==typeof e&&!!e.trim().length}function ni(e,t){return!(!t||!ti(e))||"number"==typeof e&&!isNaN(e)}function ii(e){return!(!ri(e,!1)||!e.includes(":"))&&2===e.split(":").length}function si(e){let t=!0;return Qn(e)?e.length&&(t=e.every((e=>ri(e,!1)))):t=!1,t}function oi(e,t,r){let n=null;return Object.entries(e).forEach((([e,i])=>{if(n)return;const s=function(e,t,r){let n=null;return Qn(t)&&t.length?t.forEach((e=>{n||ii(e)||(n=Zn("UNSUPPORTED_CHAINS",`${r}, chain ${e} should be a string and conform to "namespace:chainId" format`))})):ii(e)||(n=Zn("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),n}(e,Vr(e,i),`${t} ${r}`);s&&(n=s)})),n}function ai(e,t){let r=null;return Qn(e)?e.forEach((e=>{r||function(e){if(ri(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&ii(e)}}return!1}(e)||(r=Zn("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))})):r=Zn("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function ci(e,t){let r=null;return Object.values(e).forEach((e=>{if(r)return;const n=function(e,t){let r=null;return si(e?.methods)?si(e?.events)||(r=Zn("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):r=Zn("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),r}(e,`${t}, namespace`);n&&(r=n)})),r}function ui(e,t){let r=null;if(e&&ei(e)){const n=ci(e,t);n&&(r=n);const i=function(e,t){let r=null;return Object.values(e).forEach((e=>{if(r)return;const n=ai(e?.accounts,`${t} namespace`);n&&(r=n)})),r}(e,t);i&&(r=i)}else r=Xn("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return r}function hi(e){return ri(e.protocol,!0)}function li(e){return typeof e<"u"&&null!==typeof e}function fi(e,t){return!(!ii(t)||!function(e){const t=[];return Object.values(e).forEach((e=>{t.push(...Fn(e.accounts))})),t}(e).includes(t))}function pi(e,t,r){return!!ri(r,!1)&&function(e,t){const r=[];return Object.values(e).forEach((e=>{Fn(e.accounts).includes(t)&&r.push(...e.methods)})),r}(e,t).includes(r)}function di(e,t,r){return!!ri(r,!1)&&function(e,t){const r=[];return Object.values(e).forEach((e=>{Fn(e.accounts).includes(t)&&r.push(...e.events)})),r}(e,t).includes(r)}function gi(e,t,r){let n=null;const i=function(e){const t={};return Object.keys(e).forEach((r=>{var n;r.includes(":")?t[r]=e[r]:null==(n=e[r].chains)||n.forEach((n=>{t[n]={methods:e[r].methods,events:e[r].events}}))})),t}(e),s=function(e){const t={};return Object.keys(e).forEach((r=>{if(r.includes(":"))t[r]=e[r];else{const n=Fn(e[r].accounts);n?.forEach((n=>{t[n]={accounts:e[r].accounts.filter((e=>e.includes(`${n}:`))),methods:e[r].methods,events:e[r].events}}))}})),t}(t),o=Object.keys(i),a=Object.keys(s),c=yi(Object.keys(e)),u=yi(Object.keys(t)),h=c.filter((e=>!u.includes(e)));return h.length&&(n=Xn("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.\n Required: ${h.toString()}\n Received: ${Object.keys(t).toString()}`)),On(o,a)||(n=Xn("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(t).forEach((e=>{if(!e.includes(":")||n)return;const i=Fn(t[e].accounts);i.includes(e)||(n=Xn("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${e}\n Required: ${e}\n Approved: ${i.toString()}`))})),o.forEach((e=>{n||(On(i[e].methods,s[e].methods)?On(i[e].events,s[e].events)||(n=Xn("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${e}`)):n=Xn("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${e}`))})),n}function yi(e){return[...new Set(e.map((e=>e.includes(":")?e.split(":")[0]:e)))]}var mi,vi={},bi={},wi={};function _i(){if(mi)return wi;return mi=1,Object.defineProperty(wi,"__esModule",{value:!0}),wi.safeJsonParse=function(e){if("string"!=typeof e)throw new Error("Cannot safe json parse value of type "+typeof e);try{return JSON.parse(e)}catch(t){return e}},wi.safeJsonStringify=function(e){return"string"==typeof e?e:JSON.stringify(e,((e,t)=>void 0===t?null:t))},wi}var Ei,Si,Ii={};function Oi(){if(Ei)return Ii;let e;Ei=1,Object.defineProperty(Ii,"__esModule",{value:!0});class t{constructor(t){e||(e=function(){try{return require("lokijs")}catch(e){throw new Error('To use WalletConnect server side, you\'ll need to install the "lokijs" dependency. If you are seeing this error during a build / in an SSR environment, you can add "lokijs" as a devDependency to make this error go away.')}}()),":memory:"===(null==t?void 0:t.db)?this.database=new e(null==t?void 0:t.db,{}):this.database=new e(null==t?void 0:t.db,{autoload:!0,autoloadCallback:t.callback})}static create(e){const r=e.db;return":memory:"===r?new t(e):(t.instances[r]||(t.instances[r]=new t(e)),t.instances[r])}}return Ii.default=t,t.instances={},Ii}function Pi(){if(Si)return bi;Si=1,Object.defineProperty(bi,"__esModule",{value:!0}),bi.KeyValueStorage=void 0;const e=n.require$$0,t=_i(),r=e.__importDefault(Oi());class i{constructor(e){this.initialized=!1,this.inMemory=!1,this.databaseInitialize=e=>{e&&(this.db=e),this.database=this.db.getCollection("entries"),null===this.database&&(this.database=this.db.addCollection("entries",{unique:["id"]})),this.initialized=!0},":memory:"===(null==e?void 0:e.database)&&(this.inMemory=!0);const t=r.default.create({db:(null==e?void 0:e.database)||(null==e?void 0:e.table)||"walletconnect.db",callback:this.databaseInitialize});this.db=t.database,this.databaseInitialize(this.db)}getKeys(){return e.__awaiter(this,void 0,void 0,(function*(){yield this.initilization();return(yield this.database.find()).map((e=>e.id))}))}getEntries(){return e.__awaiter(this,void 0,void 0,(function*(){yield this.initilization();return(yield this.database.find()).map((e=>[e.id,t.safeJsonParse(e.value)]))}))}getItem(r){return e.__awaiter(this,void 0,void 0,(function*(){yield this.initilization();const e=this.database.findOne({id:{$eq:r}});if(null!==e)return t.safeJsonParse(e.value)}))}setItem(r,n){return e.__awaiter(this,void 0,void 0,(function*(){yield this.initilization();const e=this.database.findOne({id:{$eq:r}});e?(e.value=t.safeJsonStringify(n),this.database.update(e)):this.database.insert({id:r,value:t.safeJsonStringify(n)}),yield this.persist()}))}removeItem(t){return e.__awaiter(this,void 0,void 0,(function*(){yield this.initilization();const e=this.database.findOne({id:{$eq:t}});yield this.database.remove(e),yield this.persist()}))}initilization(){return e.__awaiter(this,void 0,void 0,(function*(){this.initialized||(yield new Promise((e=>{const t=setInterval((()=>{this.initialized&&(clearInterval(t),e())}),20)})))}))}persist(){return e.__awaiter(this,void 0,void 0,(function*(){this.inMemory||this.db.saveDatabase()}))}}return bi.KeyValueStorage=i,bi.default=i,bi}var Ai,Ni={},xi={};var Ti,Ci,ji={};function Ri(){return Ci||(Ci=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=n.require$$0;t.__exportStar((Ai||(Ai=1,Object.defineProperty(xi,"__esModule",{value:!0}),xi.IKeyValueStorage=void 0,xi.IKeyValueStorage=class{}),xi),e),t.__exportStar(function(){if(Ti)return ji;Ti=1,Object.defineProperty(ji,"__esModule",{value:!0}),ji.parseEntry=void 0;const e=_i();return ji.parseEntry=function(t){var r;return[t[0],e.safeJsonParse(null!==(r=t[1])&&void 0!==r?r:"")]},ji}(),e)}(Ni)),Ni}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=n.require$$0,r=t.__importDefault(Pi());t.__exportStar(Pi(),e),t.__exportStar(Ri(),e),e.default=r.default}(vi);var Li=i.getDefaultExportFromCjs(vi),ki={},Mi={},Ui={},$i={};class Di{}var zi,qi,Hi=Object.freeze({__proto__:null,IEvents:Di}),Ki=i.getAugmentedNamespace(Hi);function Bi(){return qi||(qi=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});n.require$$0.__exportStar(function(){if(zi)return $i;zi=1,Object.defineProperty($i,"__esModule",{value:!0}),$i.IHeartBeat=void 0;const e=Ki;class t extends e.IEvents{constructor(e){super()}}return $i.IHeartBeat=t,$i}(),e)}(Ui)),Ui}var Vi,Fi,Wi,Gi={},Yi={};function Ji(){return Fi||(Fi=1,function(e){Object.defineProperty(e,"__esModule",{value:!0});n.require$$0.__exportStar(function(){if(Vi)return Yi;Vi=1,Object.defineProperty(Yi,"__esModule",{value:!0}),Yi.HEARTBEAT_EVENTS=Yi.HEARTBEAT_INTERVAL=void 0;const e=ir;return Yi.HEARTBEAT_INTERVAL=e.FIVE_SECONDS,Yi.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},Yi}(),e)}(Gi)),Gi}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=n.require$$0;t.__exportStar(function(){if(Wi)return Mi;Wi=1,Object.defineProperty(Mi,"__esModule",{value:!0}),Mi.HeartBeat=void 0;const e=n.require$$0,t=y.default,r=ir,i=Bi(),s=Ji();class o extends i.IHeartBeat{constructor(e){super(e),this.events=new t.EventEmitter,this.interval=s.HEARTBEAT_INTERVAL,this.interval=(null==e?void 0:e.interval)||s.HEARTBEAT_INTERVAL}static init(t){return e.__awaiter(this,void 0,void 0,(function*(){const e=new o(t);return yield e.init(),e}))}init(){return e.__awaiter(this,void 0,void 0,(function*(){yield this.initialize()}))}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}initialize(){return e.__awaiter(this,void 0,void 0,(function*(){this.intervalRef=setInterval((()=>this.pulse()),r.toMiliseconds(this.interval))}))}pulse(){this.events.emit(s.HEARTBEAT_EVENTS.pulse)}}return Mi.HeartBeat=o,Mi}(),e),t.__exportStar(Bi(),e),t.__exportStar(Ji(),e)}(ki);var Xi,Zi,Qi,es,ts,rs,ns,is,ss,os,as,cs,us,hs,ls,fs,ps,ds,gs,ys,ms,vs,bs,ws,_s,Es,Ss,Is,Os,Ps,As,Ns,xs,Ts,Cs={},js={exports:{}};function Rs(){if(is)return ns;is=1;const e=function(){if(Zi)return Xi;Zi=1,Xi=function r(i){if(!(i instanceof Error))return i;i[t]=void 0;const s=Object.create(n);s.type="[object Function]"===e.call(i.constructor)?i.constructor.name:i.name,s.message=i.message,s.stack=i.stack;for(const e in i)if(void 0===s[e]){const n=i[e];n instanceof Error?n.hasOwnProperty(t)||(s[e]=r(n)):s[e]=n}return delete i[t],s.raw=i,s};const{toString:e}=Object.prototype,t=Symbol("circular-ref-tag"),r=Symbol("pino-raw-err-ref"),n=Object.create({},{type:{enumerable:!0,writable:!0,value:void 0},message:{enumerable:!0,writable:!0,value:void 0},stack:{enumerable:!0,writable:!0,value:void 0},raw:{enumerable:!1,get:function(){return this[r]},set:function(e){this[r]=e}}});return Object.defineProperty(n,r,{writable:!0,value:{}}),Xi}(),t=function(){if(es)return Qi;es=1,Qi={mapHttpRequest:function(e){return{req:r(e)}},reqSerializer:r};const e=Symbol("pino-raw-req-ref"),t=Object.create({},{id:{enumerable:!0,writable:!0,value:""},method:{enumerable:!0,writable:!0,value:""},url:{enumerable:!0,writable:!0,value:""},query:{enumerable:!0,writable:!0,value:""},params:{enumerable:!0,writable:!0,value:""},headers:{enumerable:!0,writable:!0,value:{}},remoteAddress:{enumerable:!0,writable:!0,value:""},remotePort:{enumerable:!0,writable:!0,value:""},raw:{enumerable:!1,get:function(){return this[e]},set:function(t){this[e]=t}}});function r(e){const r=e.info||e.socket,n=Object.create(t);return n.id="function"==typeof e.id?e.id():e.id||(e.info?e.info.id:void 0),n.method=e.method,e.originalUrl?(n.url=e.originalUrl,n.query=e.query,n.params=e.params):n.url=e.path||(e.url?e.url.path||e.url:void 0),n.headers=e.headers,n.remoteAddress=r&&r.remoteAddress,n.remotePort=r&&r.remotePort,n.raw=e.raw||e,n}return Object.defineProperty(t,e,{writable:!0,value:{}}),Qi}(),r=function(){if(rs)return ts;rs=1,ts={mapHttpResponse:function(e){return{res:r(e)}},resSerializer:r};const e=Symbol("pino-raw-res-ref"),t=Object.create({},{statusCode:{enumerable:!0,writable:!0,value:0},headers:{enumerable:!0,writable:!0,value:""},raw:{enumerable:!1,get:function(){return this[e]},set:function(t){this[e]=t}}});function r(e){const r=Object.create(t);return r.statusCode=e.statusCode,r.headers=e.getHeaders?e.getHeaders():e._headers,r.raw=e,r}return Object.defineProperty(t,e,{writable:!0,value:{}}),ts}();return ns={err:e,mapHttpRequest:t.mapHttpRequest,mapHttpResponse:r.mapHttpResponse,req:t.reqSerializer,res:r.resSerializer,wrapErrorSerializer:function(t){return t===e?t:function(r){return t(e(r))}},wrapRequestSerializer:function(e){return e===t.reqSerializer?e:function(r){return e(t.reqSerializer(r))}},wrapResponseSerializer:function(e){return e===r.resSerializer?e:function(t){return e(r.resSerializer(t))}}},ns}function Ls(){if(os)return ss;function e(e,t){return t}return os=1,ss=function(){const t=Error.prepareStackTrace;Error.prepareStackTrace=e;const r=(new Error).stack;if(Error.prepareStackTrace=t,!Array.isArray(r))return;const n=r.slice(2),i=[];for(const e of n)e&&i.push(e.getFileName());return i}}function ks(){return hs?us:(hs=1,us=/[^.[\]]+|\[((?:.)*?)\]/g)}function Ms(){if(ds)return ps;ds=1;const e=ks();return ps=function({secret:t,serialize:r,wcLen:n,strict:i,isCensorFct:s,censorFctTakesPath:o},a){const c=Function("o",`\n if (typeof o !== 'object' || o == null) {\n ${function(e,t){return!0===e?"throw Error('fast-redact: primitives cannot be redacted')":!1===t?"return o":"return this.serialize(o)"}(i,r)}\n }\n const { censor, secret } = this\n ${function(t,r,n){return Object.keys(t).map((i=>{const{escPath:s,leadingBracket:o,path:a}=t[i],c=o?1:0,u=o?"":".",h=[];for(var l;null!==(l=e.exec(i));){const[,e]=l,{index:t,input:r}=l;t>c&&h.push(r.substring(0,t-(e?0:1)))}var f=h.map((e=>`o${u}${e}`)).join(" && ");0===f.length?f+=`o${u}${i} != null`:f+=` && o${u}${i} != null`;const p=`\n switch (true) {\n ${h.reverse().map((e=>`\n case o${u}${e} === censor:\n secret[${s}].circle = ${JSON.stringify(e)}\n break\n `)).join("\n")}\n }\n `,d=n?`val, ${JSON.stringify(a)}`:"val";return`\n if (${f}) {\n const val = o${u}${i}\n if (val === censor) {\n secret[${s}].precensored = true\n } else {\n secret[${s}].val = val\n o${u}${i} = ${r?`censor(${d})`:"censor"}\n ${p}\n }\n }\n `})).join("\n")}(t,s,o)}\n this.compileRestore()\n ${function(e,t,r){return!0===e?`\n {\n const { wildcards, wcLen, groupRedact, nestedRedact } = this\n for (var i = 0; i < wcLen; i++) {\n const { before, beforeStr, after, nested } = wildcards[i]\n if (nested === true) {\n secret[beforeStr] = secret[beforeStr] || []\n nestedRedact(secret[beforeStr], o, before, after, censor, ${t}, ${r})\n } else secret[beforeStr] = groupRedact(o, before, censor, ${t}, ${r})\n }\n }\n `:""}(n>0,s,o)}\n ${function(e){return!1===e?"return o":"\n var s = this.serialize(o)\n this.restore(o)\n return s\n "}(r)}\n `).bind(a);!1===r&&(c.restore=e=>a.restore(e));return c},ps}function Us(){if(ys)return gs;function e(e,t){return null!=e&&("hasOwn"in Object?Object.hasOwn(e,t):Object.prototype.hasOwnProperty.call(e,t))}function t(t,r,i,s,o,a,c){const u=s.length,h=u-1,l=r;var f,p,d,g,y,m=-1,v=null,b=!0,w=null,_=!1,E=0;if(d=f=t[r],"object"!=typeof f)return{value:null,parent:null,exists:b};for(;null!=f&&++m<u;){if(v=d,!("*"===(r=s[m])||w||"object"==typeof f&&r in f)){b=!1;break}if("*"!==r||("*"===w&&(_=!0),w=r,m===h)){if(w){const t=Object.keys(f);for(var S=0;S<t.length;S++){const u=t[S];y=f[u],g="*"===r,_?d=n(y,(E=m)-1,r,i,s,o,a,c,l,f,p,d,g,u,m,h):(g||"object"==typeof y&&null!==y&&r in y)&&(d=g?y:y[r],p=m!==h?d:a?c?o(d,[...i,l,...s]):o(d):o,g?f[u]=p:y[r]===p?b=!1:y[r]=void 0===p&&void 0!==o||e(y,r)&&p===d?y[r]:p)}w=null}else d=f[r],p=m!==h?d:a?c?o(d,[...i,l,...s]):o(d):o,f[r]=e(f,r)&&p===d||void 0===p&&void 0!==o?f[r]:p,f=f[r];if("object"!=typeof f)break;d!==v&&void 0!==d||(b=!1)}}return{value:d,parent:v,exists:b,level:E}}function r(e,t){for(var r=-1,n=t.length,i=e;null!=i&&++r<n;)i=i[t[r]];return i}function n(t,r,i,s,o,a,c,u,h,l,f,p,d,g,y,m,v){if(0===r)return(d||"object"==typeof t&&null!==t&&i in t)&&(p=d?t:t[i],f=y!==m?p:c?u?a(p,[...s,h,...o]):a(p):a,d?l[g]=f:t[i]===f||(t[i]=void 0===f&&void 0!==a||e(t,i)&&f===p?t[i]:f)),p;for(const e in t){if("object"==typeof t[e])return n(t[e],r-1,i,s,o,a,c,u,h,l,f,p,d,g,y,m)}}function i(t,r,n,s){if(0!==s)for(const e in r)"object"==typeof r[e]&&i(t,r[e],n,s-1);else e(r,t)&&(r[t]=n)}return ys=1,gs={groupRedact:function(e,t,n,i,s){const o=r(e,t);if(null==o)return{keys:null,values:null,target:null,flat:!0};const a=Object.keys(o),c=a.length,u=t.length,h=s?[...t]:void 0,l=new Array(c);for(var f=0;f<c;f++){const e=a[f];l[f]=o[e],s?(h[u]=e,o[e]=n(o[e],h)):o[e]=i?n(o[e]):n}return{keys:a,values:l,target:o,flat:!0}},groupRestore:function({keys:e,values:t,target:r}){if(null==r)return;const n=e.length;for(var i=0;i<n;i++){r[e[i]]=t[i]}},nestedRedact:function(e,n,i,s,o,a,c){const u=r(n,i);if(null==u)return;const h=Object.keys(u),l=h.length;for(var f=0;f<l;f++){const r=h[f],{value:n,parent:l,exists:p,level:d}=t(u,r,i,s,o,a,c);!0===p&&null!==l&&e.push({key:s[s.length-1],target:l,value:n,level:d})}return e},nestedRestore:function(t){const r=t.length;for(var n=0;n<r;n++){const{key:r,target:o,value:a,level:c}=t[n];if(0===c||1===c){if(e(o,r)&&(o[r]=a),"object"==typeof o){const t=Object.keys(o);for(var s=0;s<t.length;s++){const n=o[t[s]];e(n,r)&&(n[r]=a)}}}else i(r,o,a,c)}}},gs}function $s(){if(Es)return _s;Es=1;const e=cs?as:(cs=1,as=function(e={}){const{ERR_PATHS_MUST_BE_STRINGS:t=(()=>"fast-redact - Paths must be (non-empty) strings"),ERR_INVALID_PATH:r=(e=>`fast-redact – Invalid path (${e})`)}=e;return function({paths:e}){e.forEach((e=>{if("string"!=typeof e)throw Error(t());try{if(/〇/.test(e))throw Error();const t=("["===e[0]?"":".")+e.replace(/^\*/,"〇").replace(/\.\*/g,".〇").replace(/\[\*\]/g,"[〇]");if(/\n|\r|;/.test(t))throw Error();if(/\/\*/.test(t))throw Error();Function(`\n 'use strict'\n const o = new Proxy({}, { get: () => o, set: () => { throw Error() } });\n const 〇 = null;\n o${t}\n if ([o${t}].length !== 1) throw Error()`)()}catch(t){throw Error(r(e))}}))}}),t=function(){if(fs)return ls;fs=1;const e=ks();return ls=function({paths:t}){const r=[];var n=0;const i=t.reduce((function(t,i,s){var o=i.match(e).map((e=>e.replace(/'|"|`/g,"")));const a="["===i[0];o=o.map((e=>"["===e[0]?e.substr(1,e.length-2):e));const c=o.indexOf("*");if(c>-1){const e=o.slice(0,c),t=e.join("."),i=o.slice(c+1,o.length),s=i.length>0;n++,r.push({before:e,beforeStr:t,after:i,nested:s})}else t[i]={path:o,val:void 0,precensored:!1,circle:"",escPath:JSON.stringify(i),leadingBracket:a};return t}),{});return{wildcards:r,wcLen:n,secret:i}},ls}(),r=Ms(),n=function(){if(vs)return ms;vs=1;const{groupRestore:e,nestedRestore:t}=Us();return ms=function({secret:r,wcLen:n}){return function(){if(this.restore)return;const i=Object.keys(r),s=function(e,t){return t.map((t=>{const{circle:r,escPath:n,leadingBracket:i}=e[t];return`\n if (secret[${n}].val !== undefined) {\n try { ${r?`o.${r} = secret[${n}].val`:`o${i?"":"."}${t} = secret[${n}].val`} } catch (e) {}\n secret[${n}].val = undefined\n }\n `})).join("")}(r,i),o=n>0,a=o?{secret:r,groupRestore:e,nestedRestore:t}:{secret:r};this.restore=Function("o",function(e,t,r){return`\n const secret = this.secret\n ${!0===r?`\n const keys = Object.keys(secret)\n const len = keys.length\n for (var i = len - 1; i >= ${t.length}; i--) {\n const k = keys[i]\n const o = secret[k]\n if (o.flat === true) this.groupRestore(o)\n else this.nestedRestore(o)\n secret[k] = null\n }\n `:""}\n ${e}\n return o\n `}(s,i,o)).bind(a)}}}(),{groupRedact:i,nestedRedact:s}=Us(),o=ws?bs:(ws=1,bs=function(e){const{secret:t,censor:r,compileRestore:n,serialize:i,groupRedact:s,nestedRedact:o,wildcards:a,wcLen:c}=e,u=[{secret:t,censor:r,compileRestore:n}];return!1!==i&&u.push({serialize:i}),c>0&&u.push({groupRedact:s,nestedRedact:o,wildcards:a,wcLen:c}),Object.assign(...u)}),a=ks(),c=e(),u=e=>e;u.restore=u;function h(e={}){const a=Array.from(new Set(e.paths||[])),h="serialize"in e&&(!1===e.serialize||"function"==typeof e.serialize)?e.serialize:JSON.stringify,l=e.remove;if(!0===l&&h!==JSON.stringify)throw Error("fast-redact – remove option may only be set when serializer is JSON.stringify");const f=!0===l?void 0:"censor"in e?e.censor:"[REDACTED]",p="function"==typeof f,d=p&&f.length>1;if(0===a.length)return h||u;c({paths:a,serialize:h,censor:f});const{wildcards:g,wcLen:y,secret:m}=t({paths:a,censor:f}),v=n({secret:m,wcLen:y}),b=!("strict"in e)||e.strict;return r({secret:m,wcLen:y,serialize:h,strict:b,isCensorFct:p,censorFctTakesPath:d},o({secret:m,censor:f,compileRestore:v,serialize:h,groupRedact:i,nestedRedact:s,wildcards:g,wcLen:y}))}return h.rx=a,h.validator=e,_s=h}function Ds(){if(Is)return Ss;Is=1;const e=Symbol("pino.setLevel"),t=Symbol("pino.getLevel"),r=Symbol("pino.levelVal"),n=Symbol("pino.useLevelLabels"),i=Symbol("pino.useOnlyCustomLevels"),s=Symbol("pino.mixin"),o=Symbol("pino.lsCache"),a=Symbol("pino.chindings"),c=Symbol("pino.parsedChindings"),u=Symbol("pino.asJson"),h=Symbol("pino.write"),l=Symbol("pino.redactFmt"),f=Symbol("pino.time"),p=Symbol("pino.timeSliceIndex"),d=Symbol("pino.stream"),g=Symbol("pino.stringify"),y=Symbol("pino.stringifySafe"),m=Symbol("pino.stringifiers"),v=Symbol("pino.end"),b=Symbol("pino.formatOpts"),w=Symbol("pino.messageKey"),_=Symbol("pino.nestedKey"),E=Symbol("pino.nestedKeyStr"),S=Symbol("pino.mixinMergeStrategy"),I=Symbol("pino.wildcardFirst"),O=Symbol.for("pino.serializers"),P=Symbol.for("pino.formatters"),A=Symbol.for("pino.hooks"),N=Symbol.for("pino.metadata");return Ss={setLevelSym:e,getLevelSym:t,levelValSym:r,useLevelLabelsSym:n,mixinSym:s,lsCacheSym:o,chindingsSym:a,parsedChindingsSym:c,asJsonSym:u,writeSym:h,serializersSym:O,redactFmtSym:l,timeSym:f,timeSliceIndexSym:p,streamSym:d,stringifySym:g,stringifySafeSym:y,stringifiersSym:m,endSym:v,formatOptsSym:b,messageKeySym:w,nestedKeySym:_,wildcardFirstSym:I,needsMetadataGsym:N,useOnlyCustomLevelsSym:i,formattersSym:P,hooksSym:A,nestedKeyStrSym:E,mixinMergeStrategySym:S}}function zs(){if(Ps)return Os;Ps=1;const e=$s(),{redactFmtSym:t,wildcardFirstSym:r}=Ds(),{rx:n,validator:i}=e,s=i({ERR_PATHS_MUST_BE_STRINGS:()=>"pino – redacted paths must be strings",ERR_INVALID_PATH:e=>`pino – redact paths array contains an invalid path (${e})`}),o="[Redacted]";return Os=function(i,a){const{paths:c,censor:u}=function(e){if(Array.isArray(e))return s(e={paths:e,censor:o}),e;let{paths:t,censor:r=o,remove:n}=e;if(!1===Array.isArray(t))throw Error("pino – redact must contain an array of strings");!0===n&&(r=void 0);return s({paths:t,censor:r}),{paths:t,censor:r}}(i),h=c.reduce(((e,t)=>{n.lastIndex=0;const i=n.exec(t),s=n.exec(t);let o=void 0!==i[1]?i[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,"$1"):i[0];if("*"===o&&(o=r),null===s)return e[o]=null,e;if(null===e[o])return e;const{index:a}=s,c=`${t.substr(a,t.length-1)}`;return e[o]=e[o]||[],o!==r&&0===e[o].length&&e[o].push(...e[r]||[]),o===r&&Object.keys(e).forEach((function(t){e[t]&&e[t].push(c)})),e[o].push(c),e}),{}),l={[t]:e({paths:c,censor:u,serialize:a,strict:false})};return[...Object.keys(h),...Object.getOwnPropertySymbols(h)].reduce(((t,r)=>{if(null===h[r])t[r]=e=>((...e)=>a("function"==typeof u?u(...e):u))(e,[r]);else{const n="function"==typeof u?(e,t)=>u(e,[r,...t]):u;t[r]=e({paths:h[r],censor:n,serialize:a,strict:false})}return t}),l)},Os}function qs(){if(Ns)return As;Ns=1;return As={nullTime:()=>"",epochTime:()=>`,"time":${Date.now()}`,unixTime:()=>`,"time":${Math.round(Date.now()/1e3)}`,isoTime:()=>`,"time":"${new Date(Date.now()).toISOString()}"`}}var Hs,Ks,Bs,Vs,Fs,Ws,Gs,Ys,Js,Xs,Zs,Qs,eo,to,ro,no,io,so,oo,ao,co,uo={exports:{}};function ho(){if(Hs)return uo.exports;if(Hs=1,"undefined"!=typeof SharedArrayBuffer&&"undefined"!=typeof Atomics){const e=new Int32Array(new SharedArrayBuffer(4));function t(t){if(!1===(t>0&&t<1/0)){if("number"!=typeof t&&"bigint"!=typeof t)throw TypeError("sleep: ms must be a number");throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity")}Atomics.wait(e,0,0,Number(t))}uo.exports=t}else{function r(e){if(!1===(e>0&&e<1/0)){if("number"!=typeof e&&"bigint"!=typeof e)throw TypeError("sleep: ms must be a number");throw RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity")}}uo.exports=r}return uo.exports}function lo(){if(Gs)return Ws;Gs=1;const e=function(){if(Fs)return Vs;Fs=1;const{format:e}=w.default;return Vs=function(){const t={},r=new Map;return{create:function(n,i,s){if(!n)throw new Error("Warning name must not be empty");if(!i)throw new Error("Warning code must not be empty");if(!s)throw new Error("Warning message must not be empty");if(i=i.toUpperCase(),void 0!==t[i])throw new Error(`The code '${i}' already exist`);return r.set(i,!1),t[i]=function(t,r,o){let a;return a=t&&r&&o?e(s,t,r,o):t&&r?e(s,t,r):t?e(s,t):s,{code:i,name:n,message:a}},t[i]},emit:function(e,n,i,s){if(void 0===t[e])throw new Error(`The code '${e}' does not exist`);if(!0===r.get(e))return;r.set(e,!0);const o=t[e](n,i,s);process.emitWarning(o.message,o.name,o.code)},emitted:r}},Vs}()();Ws=e;const t="PinoWarning";return e.create(t,"PINODEP008","prettyPrint is deprecated, look at https://github.com/pinojs/pino-pretty for alternatives."),e.create(t,"PINODEP009","The use of pino.final is discouraged in Node.js v14+ and not required. It will be removed in the next major version"),Ws}function fo(){if(Js)return Ys;function e(e,t,r,n){function i(){const e=t.deref();void 0!==e&&r(e,n)}e[n]=i,process.once(n,i)}Js=1;const t=new FinalizationRegistry(n),r=new WeakMap;function n(e){process.removeListener("exit",e.exit),process.removeListener("beforeExit",e.beforeExit)}return Ys={register:function(n,i){if(void 0===n)throw new Error("the object can't be undefined");const s=new WeakRef(n),o={};r.set(n,o),t.register(n,o),e(o,s,i,"exit"),e(o,s,i,"beforeExit")},unregister:function(e){const i=r.get(e);r.delete(e),i&&n(i),t.unregister(e)}}}function po(){if(ro)return to;ro=1;const{EventEmitter:e}=y.default,{Worker:t}=E.default,{join:r}=_.default,{pathToFileURL:n}=I.default,{wait:s}=function(){if(Zs)return Xs;Zs=1;const e=1e3;return Xs={wait:function(t,r,n,i,s){const o=Date.now()+i;let a=Atomics.load(t,r);if(a===n)return void s(null,"ok");let c=a;const u=i=>{Date.now()>o?s(null,"timed-out"):setTimeout((()=>{c=a,a=Atomics.load(t,r),a===c?u(i>=e?e:2*i):s(null,a===n?"ok":"not-equal")}),i)};u(1)},waitDiff:function(t,r,n,i,s){const o=Date.now()+i;let a=Atomics.load(t,r);if(a!==n)return void s(null,"ok");const c=i=>{Date.now()>o?s(null,"timed-out"):setTimeout((()=>{a=Atomics.load(t,r),a!==n?s(null,"ok"):c(i>=e?e:2*i)}),i)};c(1)}},Xs}(),{WRITE_INDEX:o,READ_INDEX:a}=eo?Qs:(eo=1,Qs={WRITE_INDEX:4,READ_INDEX:8}),c=O.default,u=P.default,h=Symbol("kImpl"),l=c.constants.MAX_STRING_LENGTH;class f{constructor(e){this._value=e}deref(){return this._value}}const p=i.commonjsGlobal.FinalizationRegistry||class{register(){}unregister(){}},d=i.commonjsGlobal.WeakRef||f,g=new p((e=>{e.exited||e.terminate()}));function m(e){u(!e[h].sync),e[h].needDrain&&(e[h].needDrain=!1,e.emit("drain"))}function v(e){const t=Atomics.load(e[h].state,o);let r=e[h].data.length-t;if(r>0){if(0===e[h].buf.length)return e[h].flushing=!1,void(e[h].ending?N(e):e[h].needDrain&&process.nextTick(m,e));let t=e[h].buf.slice(0,r),n=Buffer.byteLength(t);n<=r?(e[h].buf=e[h].buf.slice(r),A(e,t,v.bind(null,e))):e.flush((()=>{if(!e.destroyed){for(Atomics.store(e[h].state,a,0),Atomics.store(e[h].state,o,0);n>e[h].data.length;)r/=2,t=e[h].buf.slice(0,r),n=Buffer.byteLength(t);e[h].buf=e[h].buf.slice(r),A(e,t,v.bind(null,e))}}))}else{if(0!==r)throw new Error("overwritten");if(0===t&&0===e[h].buf.length)return;e.flush((()=>{Atomics.store(e[h].state,a,0),Atomics.store(e[h].state,o,0),v(e)}))}}function b(e){const t=this.stream.deref();if(void 0===t)return this.exited=!0,void this.terminate();switch(e.code){case"READY":this.stream=new d(t),t.flush((()=>{t[h].ready=!0,t.emit("ready")}));break;case"ERROR":S(t,e.err);break;default:throw new Error("this should not happen: "+e.code)}}function w(e){const t=this.stream.deref();void 0!==t&&(g.unregister(t),t.worker.exited=!0,t.worker.off("exit",w),S(t,0!==e?new Error("The worker thread exited"):null))}function S(e,t){e[h].destroyed||(e[h].destroyed=!0,t&&(e[h].errored=t,e.emit("error",t)),e.worker.exited?setImmediate((()=>{e[h].closed=!0,e.emit("close")})):e.worker.terminate().catch((()=>{})).then((()=>{e[h].closed=!0,e.emit("close")})))}function A(e,t,r){const n=Atomics.load(e[h].state,o),i=Buffer.byteLength(t);return e[h].data.write(t,n),Atomics.store(e[h].state,o,n+i),Atomics.notify(e[h].state,o),r(),!0}function N(e){if(!e[h].ended&&e[h].ending&&!e[h].flushing){e[h].ended=!0;try{e.flushSync();let t=Atomics.load(e[h].state,a);Atomics.store(e[h].state,o,-1),Atomics.notify(e[h].state,o);let r=0;for(;-1!==t;){if(Atomics.wait(e[h].state,a,t,1e3),t=Atomics.load(e[h].state,a),-2===t)throw new Error("end() failed");if(10==++r)throw new Error("end() took too long (10s)")}process.nextTick((()=>{e[h].finished=!0,e.emit("finish")}))}catch(t){S(e,t)}}}function x(e){const t=()=>{e[h].ending?N(e):e[h].needDrain&&process.nextTick(m,e)};for(e[h].flushing=!1;0!==e[h].buf.length;){const r=Atomics.load(e[h].state,o);let n=e[h].data.length-r;if(0===n){T(e),Atomics.store(e[h].state,a,0),Atomics.store(e[h].state,o,0);continue}if(n<0)throw new Error("overwritten");let i=e[h].buf.slice(0,n),s=Buffer.byteLength(i);if(s<=n)e[h].buf=e[h].buf.slice(n),A(e,i,t);else{for(T(e),Atomics.store(e[h].state,a,0),Atomics.store(e[h].state,o,0);s>e[h].buf.length;)n/=2,i=e[h].buf.slice(0,n),s=Buffer.byteLength(i);e[h].buf=e[h].buf.slice(n),A(e,i,t)}}}function T(e){if(e[h].flushing)throw new Error("unable to flush while flushing");const t=Atomics.load(e[h].state,o);let r=0;for(;;){const n=Atomics.load(e[h].state,a);if(-2===n)throw new Error("_flushSync failed");if(n===t)break;if(Atomics.wait(e[h].state,a,n,1e3),10==++r)throw new Error("_flushSync took too long (10s)")}}return to=class extends e{constructor(e={}){if(super(),e.bufferSize<4)throw new Error("bufferSize must at least fit a 4-byte utf-8 char");this[h]={},this[h].stateBuf=new SharedArrayBuffer(128),this[h].state=new Int32Array(this[h].stateBuf),this[h].dataBuf=new SharedArrayBuffer(e.bufferSize||4194304),this[h].data=Buffer.from(this[h].dataBuf),this[h].sync=e.sync||!1,this[h].ending=!1,this[h].ended=!1,this[h].needDrain=!1,this[h].destroyed=!1,this[h].flushing=!1,this[h].ready=!1,this[h].finished=!1,this[h].errored=null,this[h].closed=!1,this[h].buf="",this.worker=function(e,i){const{filename:s,workerData:o}=i,a=("__bundlerPathsOverrides"in globalThis?globalThis.__bundlerPathsOverrides:{})["thread-stream-worker"]||r(__dirname,"lib","worker.js"),c=new t(a,{...i.workerOpts,workerData:{filename:0===s.indexOf("file://")?s:n(s).href,dataBuf:e[h].dataBuf,stateBuf:e[h].stateBuf,workerData:o}});return c.stream=new f(e),c.on("message",b),c.on("exit",w),g.register(e,c),c}(this,e)}write(e){if(this[h].destroyed)throw new Error("the worker has exited");if(this[h].ending)throw new Error("the worker is ending");if(this[h].flushing&&this[h].buf.length+e.length>=l)try{x(this),this[h].flushing=!0}catch(e){return S(this,e),!1}if(this[h].buf+=e,this[h].sync)try{return x(this),!0}catch(e){return S(this,e),!1}return this[h].flushing||(this[h].flushing=!0,setImmediate(v,this)),this[h].needDrain=this[h].data.length-this[h].buf.length-Atomics.load(this[h].state,o)<=0,!this[h].needDrain}end(){this[h].destroyed||(this[h].ending=!0,N(this))}flush(e){if(this[h].destroyed)return void("function"==typeof e&&process.nextTick(e,new Error("the worker has exited")));const t=Atomics.load(this[h].state,o);s(this[h].state,a,t,1/0,((t,r)=>{if(t)return S(this,t),void process.nextTick(e,t);"not-equal"!==r?process.nextTick(e):this.flush(e)}))}flushSync(){this[h].destroyed||(x(this),T(this))}unref(){this.worker.unref()}ref(){this.worker.ref()}get ready(){return this[h].ready}get destroyed(){return this[h].destroyed}get closed(){return this[h].closed}get writable(){return!this[h].destroyed&&!this[h].ending}get writableEnded(){return this[h].ending}get writableFinished(){return this[h].finished}get writableNeedDrain(){return this[h].needDrain}get writableObjectMode(){return!1}get writableErrored(){return this[h].errored}},to}function go(){if(io)return no;io=1;const{createRequire:e}=S.default,t=Ls(),{join:r,isAbsolute:n}=_.default,s=ho();let o;i.commonjsGlobal.WeakRef&&i.commonjsGlobal.WeakMap&&i.commonjsGlobal.FinalizationRegistry&&(o=fo());const a=po();function c(e){if(o)o.register(e,u),e.on("close",(function(){o.unregister(e)}));else{const t=u.bind(null,e);process.once("beforeExit",t),process.once("exit",t),e.on("close",(function(){process.removeListener("beforeExit",t),process.removeListener("exit",t)}))}}function u(e){e.ref(),e.flushSync(),e.end(),e.once("close",(function(){e.unref()}))}return no=function(i){const{pipeline:o,targets:u,levels:h,options:l={},worker:f={},caller:p=t()}=i,d="string"==typeof p?[p]:p,g="__bundlerPathsOverrides"in globalThis?globalThis.__bundlerPathsOverrides:{};let y=i.target;if(y&&u)throw new Error("only one of target or targets can be specified");return u?(y=g["pino-worker"]||r(__dirname,"worker.js"),l.targets=u.map((e=>({...e,target:m(e.target)})))):o&&(y=g["pino-pipeline-worker"]||r(__dirname,"worker-pipeline.js"),l.targets=o.map((e=>({...e,target:m(e.target)})))),h&&(l.levels=h),function(e,t,r){const n=new a({filename:e,workerData:t,workerOpts:r});function i(){n.closed||(n.flushSync(),s(100),n.end())}return n.on("ready",(function(){process.removeListener("exit",i),n.unref(),!1!==r.autoEnd&&c(n)})),n.on("close",(function(){process.removeListener("exit",i)})),process.on("exit",i),n}(m(y),l,f);function m(t){if(t=g[t]||t,n(t)||0===t.indexOf("file://"))return t;if("pino/file"===t)return r(__dirname,"..","file.js");let i;for(const r of d)try{i=e(r).resolve(t);break}catch(e){continue}if(!i)throw new Error(`unable to determine transport target for "${t}"`);return i}},no}function yo(){if(oo)return so;oo=1;const e=function(){if(Ts)return xs;function e(e){try{return JSON.stringify(e)}catch(e){return'"[Circular]"'}}return Ts=1,xs=function(t,r,n){var i=n&&n.stringify||e;if("object"==typeof t&&null!==t){var s=r.length+1;if(1===s)return t;var o=new Array(s);o[0]=i(t);for(var a=1;a<s;a++)o[a]=i(r[a]);return o.join(" ")}if("string"!=typeof t)return t;var c=r.length;if(0===c)return t;for(var u="",h=0,l=-1,f=t&&t.length||0,p=0;p<f;){if(37===t.charCodeAt(p)&&p+1<f){switch(l=l>-1?l:0,t.charCodeAt(p+1)){case 100:case 102:if(h>=c)break;if(null==r[h])break;l<p&&(u+=t.slice(l,p)),u+=Number(r[h]),l=p+2,p++;break;case 105:if(h>=c)break;if(null==r[h])break;l<p&&(u+=t.slice(l,p)),u+=Math.floor(Number(r[h])),l=p+2,p++;break;case 79:case 111:case 106:if(h>=c)break;if(void 0===r[h])break;l<p&&(u+=t.slice(l,p));var d=typeof r[h];if("string"===d){u+="'"+r[h]+"'",l=p+2,p++;break}if("function"===d){u+=r[h].name||"<anonymous>",l=p+2,p++;break}u+=i(r[h]),l=p+2,p++;break;case 115:if(h>=c)break;l<p&&(u+=t.slice(l,p)),u+=String(r[h]),l=p+2,p++;break;case 37:l<p&&(u+=t.slice(l,p)),u+="%",l=p+2,p++,h--}++h}++p}return-1===l?t:(l<f&&(u+=t.slice(l)),u)},xs}(),{mapHttpRequest:t,mapHttpResponse:r}=Rs(),n=function(){if(Bs)return Ks;Bs=1;const e=b.default,t=y.default,r=w.default.inherits,n=_.default,i=ho(),s=100;function o(t,r){function i(e,n){if(e)return r._reopening=!1,r._writing=!1,r._opening=!1,void(r.sync?process.nextTick((()=>{r.listenerCount("error")>0&&r.emit("error",e)})):r.emit("error",e));r.fd=n,r.file=t,r._reopening=!1,r._opening=!1,r._writing=!1,r.sync?process.nextTick((()=>r.emit("ready"))):r.emit("ready"),r._reopening||!r._writing&&r._len>r.minLength&&!r.destroyed&&u(r)}r._opening=!0,r._writing=!0,r._asyncDrainScheduled=!1;const s=r.append?"a":"w",o=r.mode;if(r.sync)try{r.mkdir&&e.mkdirSync(n.dirname(t),{recursive:!0}),i(null,e.openSync(t,s,o))}catch(e){throw i(e),e}else r.mkdir?e.mkdir(n.dirname(t),{recursive:!0},(r=>{if(r)return i(r);e.open(t,s,o,i)})):e.open(t,s,o,i)}function a(t){if(!(this instanceof a))return new a(t);let{fd:r,dest:n,minLength:l,maxLength:f,maxWrite:p,sync:d,append:g=!0,mode:y,mkdir:m,retryEAGAIN:v}=t||{};if(r=r||n,this._bufs=[],this._len=0,this.fd=-1,this._writing=!1,this._writingBuf="",this._ending=!1,this._reopening=!1,this._asyncDrainScheduled=!1,this._hwm=Math.max(l||0,16387),this.file=null,this.destroyed=!1,this.minLength=l||0,this.maxLength=f||0,this.maxWrite=p||16384,this.sync=d||!1,this.append=g||!1,this.mode=y,this.retryEAGAIN=v||(()=>!0),this.mkdir=m||!1,"number"==typeof r)this.fd=r,process.nextTick((()=>this.emit("ready")));else{if("string"!=typeof r)throw new Error("SonicBoom supports only file descriptors and files");o(r,this)}if(this.minLength>=this.maxWrite)throw new Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);this.release=(t,r)=>{if(t){if("EAGAIN"===t.code&&this.retryEAGAIN(t,this._writingBuf.length,this._len-this._writingBuf.length))if(this.sync)try{i(s),this.release(void 0,0)}catch(t){this.release(t)}else setTimeout((()=>{e.write(this.fd,this._writingBuf,"utf8",this.release)}),s);else this._writing=!1,this.emit("error",t);return}if(this.emit("write",r),this._len-=r,this._writingBuf=this._writingBuf.slice(r),this._writingBuf.length){if(!this.sync)return void e.write(this.fd,this._writingBuf,"utf8",this.release);try{do{const t=e.writeSync(this.fd,this._writingBuf,"utf8");this._len-=t,this._writingBuf=this._writingBuf.slice(t)}while(this._writingBuf)}catch(t){return void this.release(t)}}const n=this._len;this._reopening?(this._writing=!1,this._reopening=!1,this.reopen()):n>this.minLength?u(this):this._ending?n>0?u(this):(this._writing=!1,h(this)):(this._writing=!1,this.sync?this._asyncDrainScheduled||(this._asyncDrainScheduled=!0,process.nextTick(c,this)):this.emit("drain"))},this.on("newListener",(function(e){"drain"===e&&(this._asyncDrainScheduled=!1)}))}function c(e){e.listenerCount("drain")>0&&(e._asyncDrainScheduled=!1,e.emit("drain"))}function u(t){const r=t.release;if(t._writing=!0,t._writingBuf=t._writingBuf||t._bufs.shift()||"",t.sync)try{r(null,e.writeSync(t.fd,t._writingBuf,"utf8"))}catch(e){r(e)}else e.write(t.fd,t._writingBuf,"utf8",r)}function h(t){function r(e){e?t.emit("error",e):(t._ending&&!t._writing&&t.emit("finish"),t.emit("close"))}-1!==t.fd?(t.destroyed=!0,t._bufs=[],1!==t.fd&&2!==t.fd?e.close(t.fd,r):setImmediate(r)):t.once("ready",h.bind(null,t))}return r(a,t),a.prototype.write=function(e){if(this.destroyed)throw new Error("SonicBoom destroyed");const t=this._len+e.length,r=this._bufs;return this.maxLength&&t>this.maxLength?(this.emit("drop",e),this._len<this._hwm):(0===r.length||r[r.length-1].length+e.length>this.maxWrite?r.push(""+e):r[r.length-1]+=e,this._len=t,!this._writing&&this._len>=this.minLength&&u(this),this._len<this._hwm)},a.prototype.flush=function(){if(this.destroyed)throw new Error("SonicBoom destroyed");this._writing||this.minLength<=0||(0===this._bufs.length&&this._bufs.push(""),u(this))},a.prototype.reopen=function(t){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this._opening)return void this.once("ready",(()=>{this.reopen(t)}));if(this._ending)return;if(!this.file)throw new Error("Unable to reopen a file descriptor, you must pass a file to SonicBoom");if(this._reopening=!0,this._writing)return;const r=this.fd;this.once("ready",(()=>{r!==this.fd&&e.close(r,(e=>{if(e)return this.emit("error",e)}))})),o(t||this.file,this)},a.prototype.end=function(){if(this.destroyed)throw new Error("SonicBoom destroyed");this._opening?this.once("ready",(()=>{this.end()})):this._ending||(this._ending=!0,this._writing||(this._len>0&&this.fd>=0?u(this):h(this)))},a.prototype.flushSync=function(){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this.fd<0)throw new Error("sonic boom is not ready yet");for(!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift(this._writingBuf),this._writingBuf="");this._bufs.length;){const t=this._bufs[0];try{this._len-=e.writeSync(this.fd,t,"utf8"),this._bufs.shift()}catch(e){if("EAGAIN"!==e.code||!this.retryEAGAIN(e,t.length,this._len-t.length))throw e;i(s)}}},a.prototype.destroy=function(){this.destroyed||h(this)},a.SonicBoom=a,a.default=a,Ks=a}(),s=lo(),{lsCacheSym:o,chindingsSym:a,parsedChindingsSym:c,writeSym:u,serializersSym:h,formatOptsSym:l,endSym:f,stringifiersSym:p,stringifySym:d,stringifySafeSym:g,wildcardFirstSym:m,needsMetadataGsym:v,redactFmtSym:S,streamSym:I,nestedKeySym:O,formattersSym:P,messageKeySym:A,nestedKeyStrSym:N}=Ds(),{isMainThread:x}=E.default,T=go();function C(){}function j(e){let t="",r=0,n=!1,i=255;const s=e.length;if(s>100)return JSON.stringify(e);for(var o=0;o<s&&i>=32;o++)i=e.charCodeAt(o),34!==i&&92!==i||(t+=e.slice(r,o)+"\\",r=o,n=!0);return n?t+=e.slice(r):t=e,i<32?JSON.stringify(e):'"'+t+'"'}function R(e,t,r,n){if(t&&"function"==typeof t)return L((t=t.bind(n))(e),r,e);try{const t=require("pino-pretty").prettyFactory;return t.asMetaWrapper=L,L(t(e),r,e)}catch(e){if(e.message.startsWith("Cannot find module 'pino-pretty'"))throw Error("Missing `pino-pretty` module: `pino-pretty` must be installed separately");throw e}}function L(e,t,r){r=Object.assign({suppressFlushSyncWarning:!1},r);let n=!1;return{[v]:!0,lastLevel:0,lastMsg:null,lastObj:null,lastLogger:null,flushSync(){r.suppressFlushSyncWarning||n||(n=!0,U(t,this),t.write(e(Object.assign({level:40,msg:"pino.final with prettyPrint does not support flushing",time:Date.now()},this.chindings()))))},chindings(){const e=this.lastLogger;let t=null;return e?(e.hasOwnProperty(c)?t=e[c]:(t=JSON.parse("{"+e[a].substr(1)+"}"),e[c]=t),t):null},write(r){const n=this.lastLogger,i=this.chindings();let s=this.lastTime;"number"==typeof s||(s=s.match(/^\d+/)?parseInt(s):s.slice(1,-1));const o=this.lastObj,a=this.lastMsg,c=n[P],u=c.log?c.log(o):o,l=n[A];a&&u&&!Object.prototype.hasOwnProperty.call(u,l)&&(u[l]=a);const f=Object.assign({level:this.lastLevel,time:s},u,null),d=n[h],g=Object.keys(d);for(var y=0;y<g.length;y++){const e=g[y];void 0!==f[e]&&(f[e]=d[e](f[e]))}for(const e in i)f.hasOwnProperty(e)||(f[e]=i[e]);const m=n[p][S],v=e("function"==typeof m?m(f):f);void 0!==v&&(U(t,this),t.write(v))}}}function k(e){const t=new n(e);return t.on("error",(function e(r){if("EPIPE"===r.code)return t.write=C,t.end=C,t.flushSync=C,void(t.destroy=C);t.removeListener("error",e),t.emit("error",r)})),!e.sync&&x&&function(e){if(i.commonjsGlobal.WeakRef&&i.commonjsGlobal.WeakMap&&i.commonjsGlobal.FinalizationRegistry){const t=fo();t.register(e,M),e.on("close",(function(){t.unregister(e)}))}}(t),t}function M(e,t){e.destroyed||("beforeExit"===t?(e.flush(),e.on("drain",(function(){e.end()}))):e.flushSync())}function U(e,t){!0===e[v]&&(e.lastLevel=t.lastLevel,e.lastMsg=t.lastMsg,e.lastObj=t.lastObj,e.lastTime=t.lastTime,e.lastLogger=t.lastLogger)}return so={noop:C,buildSafeSonicBoom:k,getPrettyStream:R,asChindings:function(e,t){let r,n=e[a];const i=e[d],s=e[g],o=e[p],c=o[m],u=e[h];t=(0,e[P].bindings)(t);for(const e in t){r=t[e];if(!0===("level"!==e&&"serializers"!==e&&"formatters"!==e&&"customLevels"!==e&&t.hasOwnProperty(e)&&void 0!==r)){if(r=u[e]?u[e](r):r,r=(o[e]||c||i)(r,s),void 0===r)continue;n+=',"'+e+'":'+r}}return n},asJson:function(e,t,r,n){const i=this[d],s=this[g],c=this[p],u=this[f],l=this[a],y=this[h],v=this[P],b=this[A];let w,_=this[o][r]+n;_+=l,v.log&&(e=v.log(e));const E=c[m];let S="";for(const t in e)if(w=e[t],Object.prototype.hasOwnProperty.call(e,t)&&void 0!==w){w=y[t]?y[t](w):w;const e=c[t]||E;switch(typeof w){case"undefined":case"function":continue;case"number":!1===Number.isFinite(w)&&(w=null);case"boolean":e&&(w=e(w));break;case"string":w=(e||j)(w);break;default:w=(e||i)(w,s)}if(void 0===w)continue;S+=',"'+t+'":'+w}let I="";if(void 0!==t){w=y[b]?y[b](t):t;const e=c[b]||E;switch(typeof w){case"function":break;case"number":!1===Number.isFinite(w)&&(w=null);case"boolean":e&&(w=e(w)),I=',"'+b+'":'+w;break;case"string":w=(e||j)(w),I=',"'+b+'":'+w;break;default:w=(e||i)(w,s),I=',"'+b+'":'+w}}return this[O]&&S?_+this[N]+S.slice(1)+"}"+I+u:_+S+I+u},genLog:function(n,i){return i?function(...e){i.call(this,e,s,n)}:s;function s(i,...s){if("object"==typeof i){let o,a=i;null!==i&&(i.method&&i.headers&&i.socket?i=t(i):"function"==typeof i.setHeader&&(i=r(i))),null===a&&0===s.length?o=[null]:(a=s.shift(),o=s),this[u](i,e(a,o,this[l]),n)}else this[u](null,e(i,s,this[l]),n)}},createArgsNormalizer:function(e){return function(t,r,i={},o){if("string"==typeof i)o=k({dest:i,sync:!0}),i={};else if("string"==typeof o){if(i&&i.transport)throw Error("only one of option.transport or stream can be specified");o=k({dest:o,sync:!0})}else if(i instanceof n||i.writable||i._writableState)o=i,i={};else if(i.transport){if(i.transport instanceof n||i.transport.writable||i.transport._writableState)throw Error("option.transport do not allow stream, please pass to option directly. e.g. pino(transport)");if(i.transport.targets&&i.transport.targets.length&&i.formatters&&"function"==typeof i.formatters.level)throw Error("option.transport.targets do not allow custom level formatters");let e;i.customLevels&&(e=i.useOnlyCustomLevels?i.customLevels:Object.assign({},i.levels,i.customLevels)),o=T({caller:r,...i.transport,levels:e})}if((i=Object.assign({},e,i)).serializers=Object.assign({},e.serializers,i.serializers),i.formatters=Object.assign({},e.formatters,i.formatters),"onTerminated"in i)throw Error("The onTerminated option has been removed, use pino.final instead");"changeLevelName"in i&&(process.emitWarning("The changeLevelName option is deprecated and will be removed in v7. Use levelKey instead.",{code:"changeLevelName_deprecation"}),i.levelKey=i.changeLevelName,delete i.changeLevelName);const{enabled:a,prettyPrint:c,prettifier:u,messageKey:h}=i;if(!1===a&&(i.level="silent"),(o=o||process.stdout)===process.stdout&&o.fd>=0&&!function(e){return e.write!==e.constructor.prototype.write}(o)&&(o=k({fd:o.fd,sync:!0})),c){s.emit("PINODEP008");o=R(Object.assign({messageKey:h},c),u,o,t)}return{opts:i,stream:o}}},final:function(e,t){if(Number(process.versions.node.split(".")[0])>=14&&s.emit("PINODEP009"),void 0===e||"function"!=typeof e.child)throw Error("expected a pino logger instance");const r=void 0!==t;if(r&&"function"!=typeof t)throw Error("if supplied, the handler parameter should be a function");const n=e[I];if("function"!=typeof n.flushSync)throw Error("final requires a stream that has a flushSync method, such as pino.destination");const i=new Proxy(e,{get:(e,t)=>t in e.levels.values?(...r)=>{e[t](...r),n.flushSync()}:e[t]});if(!r){try{n.flushSync()}catch{}return i}return(e=null,...r)=>{try{n.flushSync()}catch(e){}return t(e,i,...r)}},stringify:function(e,t){try{return JSON.stringify(e)}catch(r){try{return(t||this[g])(e)}catch(e){return'"[unable to serialize, circular reference is too complex to analyze]"'}}},buildFormatters:function(e,t,r){return{level:e,bindings:t,log:r}},normalizeDestFileDescriptor:function(e){const t=Number(e);return"string"==typeof e&&Number.isFinite(t)?t:e}},so}function mo(){if(co)return ao;co=1;const{lsCacheSym:e,levelValSym:t,useOnlyCustomLevelsSym:r,streamSym:n,formattersSym:i,hooksSym:s}=Ds(),{noop:o,genLog:a}=yo(),c={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},u={fatal:e=>{const t=a(c.fatal,e);return function(...e){const r=this[n];if(t.call(this,...e),"function"==typeof r.flushSync)try{r.flushSync()}catch(e){}}},error:e=>a(c.error,e),warn:e=>a(c.warn,e),info:e=>a(c.info,e),debug:e=>a(c.debug,e),trace:e=>a(c.trace,e)},h=Object.keys(c).reduce(((e,t)=>(e[c[t]]=t,e)),{}),l=Object.keys(h).reduce(((e,t)=>(e[t]='{"level":'+Number(t),e)),{});function f(e,t){if(t)return!1;switch(e){case"fatal":case"error":case"warn":case"info":case"debug":case"trace":return!0;default:return!1}}return ao={initialLsCache:l,genLsCache:function(t){const r=t[i].level,{labels:n}=t.levels,s={};for(const e in n){const t=r(n[e],Number(e));s[e]=JSON.stringify(t).slice(0,-1)}return t[e]=s,t},levelMethods:u,getLevel:function(e){const{levels:t,levelVal:r}=this;return t&&t.labels?t.labels[r]:""},setLevel:function(e){const{labels:n,values:i}=this.levels;if("number"==typeof e){if(void 0===n[e])throw Error("unknown level value"+e);e=n[e]}if(void 0===i[e])throw Error("unknown level "+e);const c=this[t],h=this[t]=i[e],l=this[r],p=this[s].logMethod;for(const e in i)h>i[e]?this[e]=o:this[e]=f(e,l)?u[e](p):a(i[e],p);this.emit("level-change",e,h,n[c],c)},isLevelEnabled:function(e){const{values:r}=this.levels,n=r[e];return void 0!==n&&n>=this[t]},mappings:function(e=null,t=!1){const r=e?Object.keys(e).reduce(((t,r)=>(t[e[r]]=r,t)),{}):null;return{labels:Object.assign(Object.create(Object.prototype,{Infinity:{value:"silent"}}),t?null:h,r),values:Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),t?null:c,e)}},levels:c,assertNoLevelCollisions:function(e,t){const{labels:r,values:n}=e;for(const e in t){if(e in n)throw Error("levels cannot be overridden");if(t[e]in r)throw Error("pre-existing level values cannot be used for new levels")}},assertDefaultLevelFound:function(e,t,r){if("number"==typeof e){if(![].concat(Object.keys(t||{}).map((e=>t[e])),r?[]:Object.keys(h).map((e=>+e)),1/0).includes(e))throw Error(`default level:${e} must be included in custom levels`);return}if(!(e in Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),r?null:c,t)))throw Error(`default level:${e} must be included in custom levels`)}},ao}var vo,bo,wo,_o,Eo={name:"pino",version:"7.11.0",description:"super fast, all natural json logger",main:"pino.js",type:"commonjs",types:"pino.d.ts",browser:"./browser.js",files:["pino.js","file.js","pino.d.ts","bin.js","browser.js","pretty.js","usage.txt","test","docs","example.js","lib"],scripts:{docs:"docsify serve","browser-test":"airtap --local 8080 test/browser*test.js",lint:"eslint .",test:"npm run lint && npm run transpile && tap --ts && jest test/jest && npm run test-types","test-ci":"npm run lint && npm run transpile && tap --ts --no-check-coverage --coverage-report=lcovonly && npm run test-types","test-ci-pnpm":"pnpm run lint && npm run transpile && tap --ts --no-coverage --no-check-coverage && pnpm run test-types","test-ci-yarn-pnp":"yarn run lint && npm run transpile && tap --ts --no-check-coverage --coverage-report=lcovonly","test-types":"tsc && tsd && ts-node test/types/pino.ts",transpile:"node ./test/fixtures/ts/transpile.cjs","cov-ui":"tap --ts --coverage-report=html",bench:"node benchmarks/utils/runbench all","bench-basic":"node benchmarks/utils/runbench basic","bench-object":"node benchmarks/utils/runbench object","bench-deep-object":"node benchmarks/utils/runbench deep-object","bench-multi-arg":"node benchmarks/utils/runbench multi-arg","bench-longs-tring":"node benchmarks/utils/runbench long-string","bench-child":"node benchmarks/utils/runbench child","bench-child-child":"node benchmarks/utils/runbench child-child","bench-child-creation":"node benchmarks/utils/runbench child-creation","bench-formatters":"node benchmarks/utils/runbench formatters","update-bench-doc":"node benchmarks/utils/generate-benchmark-doc > docs/benchmarks.md"},bin:{pino:"./bin.js"},precommit:"test",repository:{type:"git",url:"git+https://github.com/pinojs/pino.git"},keywords:["fast","logger","stream","json"],author:"Matteo Collina <hello@matteocollina.com>",contributors:["David Mark Clements <huperekchuno@googlemail.com>","James Sumners <james.sumners@gmail.com>","Thomas Watson Steen <w@tson.dk> (https://twitter.com/wa7son)"],license:"MIT",bugs:{url:"https://github.com/pinojs/pino/issues"},homepage:"http://getpino.io",devDependencies:{"@types/flush-write-stream":"^1.0.0","@types/node":"^17.0.0","@types/tap":"^15.0.6",airtap:"4.0.4",benchmark:"^2.1.4",bole:"^4.0.0",bunyan:"^1.8.14","docsify-cli":"^4.4.1",eslint:"^7.17.0","eslint-config-standard":"^16.0.3","eslint-plugin-import":"^2.22.1","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^5.1.0",execa:"^5.0.0",fastbench:"^1.0.1","flush-write-stream":"^2.0.0","import-fresh":"^3.2.1",jest:"^27.3.1",log:"^6.0.0",loglevel:"^1.6.7","pino-pretty":"^v7.6.0","pre-commit":"^1.2.2",proxyquire:"^2.1.3",pump:"^3.0.0",rimraf:"^3.0.2",semver:"^7.0.0",split2:"^4.0.0",steed:"^1.1.3","strip-ansi":"^6.0.0",tap:"^16.0.0",tape:"^5.0.0",through2:"^4.0.0","ts-node":"^10.7.0",tsd:"^0.20.0",typescript:"^4.4.4",winston:"^3.3.3"},dependencies:{"atomic-sleep":"^1.0.0","fast-redact":"^3.0.0","on-exit-leak-free":"^0.2.0","pino-abstract-transport":"v0.5.0","pino-std-serializers":"^4.0.0","process-warning":"^1.0.0","quick-format-unescaped":"^4.0.3","real-require":"^0.1.0","safe-stable-stringify":"^2.1.0","sonic-boom":"^2.2.1","thread-stream":"^0.15.1"},tsd:{directory:"test/types"}};function So(){if(bo)return vo;bo=1;const{version:e}=Eo;return vo={version:e}}function Io(){if(_o)return wo;_o=1;const{EventEmitter:e}=y.default,{lsCacheSym:t,levelValSym:r,setLevelSym:n,getLevelSym:i,chindingsSym:s,parsedChindingsSym:o,mixinSym:a,asJsonSym:c,writeSym:u,mixinMergeStrategySym:h,timeSym:l,timeSliceIndexSym:f,streamSym:p,serializersSym:d,formattersSym:g,useOnlyCustomLevelsSym:m,needsMetadataGsym:v,redactFmtSym:b,stringifySym:w,formatOptsSym:_,stringifiersSym:E}=Ds(),{getLevel:S,setLevel:I,isLevelEnabled:O,mappings:P,initialLsCache:A,genLsCache:N,assertNoLevelCollisions:x}=mo(),{asChindings:T,asJson:C,buildFormatters:j,stringify:R}=yo(),{version:L}=So(),k=zs(),M={constructor:class{},child:function(e,t){if(!e)throw Error("missing bindings for child Pino");t=t||{};const r=this[d],i=this[g],o=Object.create(this);if(!0===t.hasOwnProperty("serializers")){o[d]=Object.create(null);for(const e in r)o[d][e]=r[e];const e=Object.getOwnPropertySymbols(r);for(var a=0;a<e.length;a++){const t=e[a];o[d][t]=r[t]}for(const e in t.serializers)o[d][e]=t.serializers[e];const n=Object.getOwnPropertySymbols(t.serializers);for(var c=0;c<n.length;c++){const e=n[c];o[d][e]=t.serializers[e]}}else o[d]=r;if(t.hasOwnProperty("formatters")){const{level:e,bindings:r,log:n}=t.formatters;o[g]=j(e||i.level,r||U,n||i.log)}else o[g]=j(i.level,U,i.log);!0===t.hasOwnProperty("customLevels")&&(x(this.levels,t.customLevels),o.levels=P(t.customLevels,o[m]),N(o));if("object"==typeof t.redact&&null!==t.redact||Array.isArray(t.redact)){o.redact=t.redact;const e=k(o.redact,R),r={stringify:e[b]};o[w]=R,o[E]=e,o[_]=r}o[s]=T(o,e);const u=t.level||this.level;return o[n](u),o},bindings:function(){const e=`{${this[s].substr(1)}}`,t=JSON.parse(e);return delete t.pid,delete t.hostname,t},setBindings:function(e){const t=T(this,e);this[s]=t,delete this[o]},flush:function(){const e=this[p];"flush"in e&&e.flush(D)},isLevelEnabled:O,version:L,get level(){return this[i]()},set level(e){this[n](e)},get levelVal(){return this[r]},set levelVal(e){throw Error("levelVal is read-only")},[t]:A,[u]:function(e,t,r){const n=this[l](),i=this[a],s=this[h]||$;let o;null==e?o={}:e instanceof Error?(o={err:e},void 0===t&&(t=e.message)):(o=e,void 0===t&&e.err&&(t=e.err.message));i&&(o=s(o,i(o,r)));const u=this[c](o,t,r,n),d=this[p];!0===d[v]&&(d.lastLevel=r,d.lastObj=o,d.lastMsg=t,d.lastTime=n.slice(this[f]),d.lastLogger=this);d.write(u)},[c]:C,[i]:S,[n]:I};Object.setPrototypeOf(M,e.prototype);const U=e=>e;function $(e,t){return Object.assign(t,e)}function D(){}return wo=function(){return Object.create(M)}}var Oo,Po,Ao,No,xo={exports:{}};function To(){return Oo||(Oo=1,function(e,t){const{hasOwnProperty:r}=Object.prototype,n=p();n.configure=p,n.stringify=n,n.default=n,t.stringify=n,t.configure=p,e.exports=n;const i=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]|[\ud800-\udbff](?![\udc00-\udfff])|(?:[^\ud800-\udbff]|^)[\udc00-\udfff]/;function s(e){return e.length<5e3&&!i.test(e)?`"${e}"`:JSON.stringify(e)}function o(e){if(e.length>200)return e.sort();for(let t=1;t<e.length;t++){const r=e[t];let n=t;for(;0!==n&&e[n-1]>r;)e[n]=e[n-1],n--;e[n]=r}return e}const a=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function c(e){return void 0!==a.call(e)&&0!==e.length}function u(e,t,r){e.length<r&&(r=e.length);const n=","===t?"":" ";let i=`"0":${n}${e[0]}`;for(let s=1;s<r;s++)i+=`${t}"${s}":${n}${e[s]}`;return i}function h(e,t){let n;if(r.call(e,t)&&(n=e[t],"boolean"!=typeof n))throw new TypeError(`The "${t}" argument must be of type boolean`);return void 0===n||n}function l(e,t){let n;if(r.call(e,t)){if(n=e[t],"number"!=typeof n)throw new TypeError(`The "${t}" argument must be of type number`);if(!Number.isInteger(n))throw new TypeError(`The "${t}" argument must be an integer`);if(n<1)throw new RangeError(`The "${t}" argument must be >= 1`)}return void 0===n?1/0:n}function f(e){return 1===e?"1 item":`${e} items`}function p(e){const t=function(e){if(r.call(e,"strict")){const t=e.strict;if("boolean"!=typeof t)throw new TypeError('The "strict" argument must be of type boolean');if(t)return e=>{let t="Object can not safely be stringified. Received type "+typeof e;throw"function"!=typeof e&&(t+=` (${e.toString()})`),new Error(t)}}}(e={...e});t&&(void 0===e.bigint&&(e.bigint=!1),"circularValue"in e||(e.circularValue=Error));const n=function(e){if(r.call(e,"circularValue")){const t=e.circularValue;if("string"==typeof t)return`"${t}"`;if(null==t)return t;if(t===Error||t===TypeError)return{toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return'"[Circular]"'}(e),i=h(e,"bigint"),a=h(e,"deterministic"),p=l(e,"maximumDepth"),d=l(e,"maximumBreadth");function g(e,r,u,h,l,y){let m=r[e];switch("object"==typeof m&&null!==m&&"function"==typeof m.toJSON&&(m=m.toJSON(e)),m=h.call(r,e,m),typeof m){case"string":return s(m);case"object":{if(null===m)return"null";if(-1!==u.indexOf(m))return n;let e="",t=",";const r=y;if(Array.isArray(m)){if(0===m.length)return"[]";if(p<u.length+1)return'"[Array]"';u.push(m),""!==l&&(e+=`\n${y+=l}`,t=`,\n${y}`);const n=Math.min(m.length,d);let i=0;for(;i<n-1;i++){const r=g(String(i),m,u,h,l,y);e+=void 0!==r?r:"null",e+=t}const s=g(String(i),m,u,h,l,y);if(e+=void 0!==s?s:"null",m.length-1>d){e+=`${t}"... ${f(m.length-d-1)} not stringified"`}return""!==l&&(e+=`\n${r}`),u.pop(),`[${e}]`}let i=Object.keys(m);const v=i.length;if(0===v)return"{}";if(p<u.length+1)return'"[Object]"';let b="",w="";""!==l&&(t=`,\n${y+=l}`,b=" ");const _=Math.min(v,d);a&&!c(m)&&(i=o(i)),u.push(m);for(let r=0;r<_;r++){const n=i[r],o=g(n,m,u,h,l,y);void 0!==o&&(e+=`${w}${s(n)}:${b}${o}`,w=t)}if(v>d){e+=`${w}"...":${b}"${f(v-d)} not stringified"`,w=t}return""!==l&&w.length>1&&(e=`\n${y}${e}\n${r}`),u.pop(),`{${e}}`}case"number":return isFinite(m)?String(m):t?t(m):"null";case"boolean":return!0===m?"true":"false";case"undefined":return;case"bigint":if(i)return String(m);default:return t?t(m):void 0}}function y(e,r,o,a,c,u){switch("object"==typeof r&&null!==r&&"function"==typeof r.toJSON&&(r=r.toJSON(e)),typeof r){case"string":return s(r);case"object":{if(null===r)return"null";if(-1!==o.indexOf(r))return n;const e=u;let t="",i=",";if(Array.isArray(r)){if(0===r.length)return"[]";if(p<o.length+1)return'"[Array]"';o.push(r),""!==c&&(t+=`\n${u+=c}`,i=`,\n${u}`);const n=Math.min(r.length,d);let s=0;for(;s<n-1;s++){const e=y(String(s),r[s],o,a,c,u);t+=void 0!==e?e:"null",t+=i}const h=y(String(s),r[s],o,a,c,u);if(t+=void 0!==h?h:"null",r.length-1>d){t+=`${i}"... ${f(r.length-d-1)} not stringified"`}return""!==c&&(t+=`\n${e}`),o.pop(),`[${t}]`}o.push(r);let h="";""!==c&&(i=`,\n${u+=c}`,h=" ");let l="";for(const e of a){const n=y(e,r[e],o,a,c,u);void 0!==n&&(t+=`${l}${s(e)}:${h}${n}`,l=i)}return""!==c&&l.length>1&&(t=`\n${u}${t}\n${e}`),o.pop(),`{${t}}`}case"number":return isFinite(r)?String(r):t?t(r):"null";case"boolean":return!0===r?"true":"false";case"undefined":return;case"bigint":if(i)return String(r);default:return t?t(r):void 0}}function m(e,r,h,l,g){switch(typeof r){case"string":return s(r);case"object":{if(null===r)return"null";if("function"==typeof r.toJSON){if("object"!=typeof(r=r.toJSON(e)))return m(e,r,h,l,g);if(null===r)return"null"}if(-1!==h.indexOf(r))return n;const t=g;if(Array.isArray(r)){if(0===r.length)return"[]";if(p<h.length+1)return'"[Array]"';h.push(r);let e=`\n${g+=l}`;const n=`,\n${g}`,i=Math.min(r.length,d);let s=0;for(;s<i-1;s++){const t=m(String(s),r[s],h,l,g);e+=void 0!==t?t:"null",e+=n}const o=m(String(s),r[s],h,l,g);if(e+=void 0!==o?o:"null",r.length-1>d){e+=`${n}"... ${f(r.length-d-1)} not stringified"`}return e+=`\n${t}`,h.pop(),`[${e}]`}let i=Object.keys(r);const y=i.length;if(0===y)return"{}";if(p<h.length+1)return'"[Object]"';const v=`,\n${g+=l}`;let b="",w="",_=Math.min(y,d);c(r)&&(b+=u(r,v,d),i=i.slice(r.length),_-=r.length,w=v),a&&(i=o(i)),h.push(r);for(let e=0;e<_;e++){const t=i[e],n=m(t,r[t],h,l,g);void 0!==n&&(b+=`${w}${s(t)}: ${n}`,w=v)}if(y>d){b+=`${w}"...": "${f(y-d)} not stringified"`,w=v}return""!==w&&(b=`\n${g}${b}\n${t}`),h.pop(),`{${b}}`}case"number":return isFinite(r)?String(r):t?t(r):"null";case"boolean":return!0===r?"true":"false";case"undefined":return;case"bigint":if(i)return String(r);default:return t?t(r):void 0}}function v(e,r,h){switch(typeof r){case"string":return s(r);case"object":{if(null===r)return"null";if("function"==typeof r.toJSON){if("object"!=typeof(r=r.toJSON(e)))return v(e,r,h);if(null===r)return"null"}if(-1!==h.indexOf(r))return n;let t="";if(Array.isArray(r)){if(0===r.length)return"[]";if(p<h.length+1)return'"[Array]"';h.push(r);const e=Math.min(r.length,d);let n=0;for(;n<e-1;n++){const e=v(String(n),r[n],h);t+=void 0!==e?e:"null",t+=","}const i=v(String(n),r[n],h);if(t+=void 0!==i?i:"null",r.length-1>d){t+=`,"... ${f(r.length-d-1)} not stringified"`}return h.pop(),`[${t}]`}let i=Object.keys(r);const l=i.length;if(0===l)return"{}";if(p<h.length+1)return'"[Object]"';let g="",y=Math.min(l,d);c(r)&&(t+=u(r,",",d),i=i.slice(r.length),y-=r.length,g=","),a&&(i=o(i)),h.push(r);for(let e=0;e<y;e++){const n=i[e],o=v(n,r[n],h);void 0!==o&&(t+=`${g}${s(n)}:${o}`,g=",")}if(l>d){t+=`${g}"...":"${f(l-d)} not stringified"`}return h.pop(),`{${t}}`}case"number":return isFinite(r)?String(r):t?t(r):"null";case"boolean":return!0===r?"true":"false";case"undefined":return;case"bigint":if(i)return String(r);default:return t?t(r):void 0}}return function(e,t,r){if(arguments.length>1){let n="";if("number"==typeof r?n=" ".repeat(Math.min(r,10)):"string"==typeof r&&(n=r.slice(0,10)),null!=t){if("function"==typeof t)return g("",{"":e},[],t,n,"");if(Array.isArray(t))return y("",e,[],function(e){const t=new Set;for(const r of e)"string"!=typeof r&&"number"!=typeof r||t.add(String(r));return t}(t),n,"")}if(0!==n.length)return m("",e,[],n,"")}return v("",e,[])}}}(xo,xo.exports)),xo.exports}function Co(){if(No)return js.exports;No=1;const e=v.default,t=Rs(),r=Ls(),n=zs(),i=qs(),s=Io(),o=Ds(),{configure:a}=To(),{assertDefaultLevelFound:c,mappings:u,genLsCache:h,levels:l}=mo(),{createArgsNormalizer:f,asChindings:p,final:d,buildSafeSonicBoom:g,buildFormatters:y,stringify:m,normalizeDestFileDescriptor:b,noop:w}=yo(),{version:_}=So(),{chindingsSym:E,redactFmtSym:S,serializersSym:I,timeSym:O,timeSliceIndexSym:P,streamSym:A,stringifySym:N,stringifySafeSym:x,stringifiersSym:T,setLevelSym:C,endSym:j,formatOptsSym:R,messageKeySym:L,nestedKeySym:k,mixinSym:M,useOnlyCustomLevelsSym:U,formattersSym:$,hooksSym:D,nestedKeyStrSym:z,mixinMergeStrategySym:q}=o,{epochTime:H,nullTime:K}=i,{pid:B}=process,V=e.hostname(),F=t.err,W=f({level:"info",levels:l,messageKey:"msg",nestedKey:null,enabled:!0,prettyPrint:!1,base:{pid:B,hostname:V},serializers:Object.assign(Object.create(null),{err:F}),formatters:Object.assign(Object.create(null),{bindings:e=>e,level:(e,t)=>({level:t})}),hooks:{logMethod:void 0},timestamp:H,name:void 0,redact:null,customLevels:null,useOnlyCustomLevels:!1,depthLimit:5,edgeLimit:100}),G=Object.assign(Object.create(null),t);function Y(...e){const t={},{opts:i,stream:o}=W(t,r(),...e),{redact:l,crlf:f,serializers:d,timestamp:g,messageKey:v,nestedKey:b,base:_,name:B,level:V,customLevels:F,mixin:G,mixinMergeStrategy:Y,useOnlyCustomLevels:J,formatters:X,hooks:Z,depthLimit:Q,edgeLimit:ee}=i,te=a({maximumDepth:Q,maximumBreadth:ee}),re=y(X.level,X.bindings,X.log),ne=l?n(l,m):{},ie=m.bind({[x]:te}),se=l?{stringify:ne[S]}:{stringify:ie},oe="}"+(f?"\r\n":"\n"),ae=p.bind(null,{[E]:"",[I]:d,[T]:ne,[N]:m,[x]:te,[$]:re});let ce="";null!==_&&(ce=ae(void 0===B?_:Object.assign({},_,{name:B})));const ue=g instanceof Function?g:g?H:K,he=ue().indexOf(":")+1;if(J&&!F)throw Error("customLevels is required if useOnlyCustomLevels is set true");if(G&&"function"!=typeof G)throw Error(`Unknown mixin type "${typeof G}" - expected "function"`);c(V,F,J);const le=u(F,J);return Object.assign(t,{levels:le,[U]:J,[A]:o,[O]:ue,[P]:he,[N]:m,[x]:te,[T]:ne,[j]:oe,[R]:se,[L]:v,[k]:b,[z]:b?`,${JSON.stringify(b)}:{`:"",[I]:d,[M]:G,[q]:Y,[E]:ce,[$]:re,[D]:Z,silent:w}),Object.setPrototypeOf(t,s()),h(t),t[C](V),t}return js.exports=Y,js.exports.destination=(e=process.stdout.fd)=>"object"==typeof e?(e.dest=b(e.dest||process.stdout.fd),g(e)):g({dest:b(e),minLength:0,sync:!0}),js.exports.transport=go(),js.exports.multistream=function(){if(Ao)return Po;Ao=1;const e=Symbol.for("pino.metadata"),{levels:t}=mo(),r=Object.create(t);r.silent=1/0;const n=t.info;function i(e,t){return e.level-t.level}return Po=function(t,s){let o=0;t=t||[];let a=r;(s=s||{dedupe:!1}).levels&&"object"==typeof s.levels&&(a=s.levels);const c={write:u,add:l,flushSync:h,end:function(){for(const{stream:e}of this.streams)"function"==typeof e.flushSync&&e.flushSync(),e.end()},minLevel:0,streams:[],clone:function t(r){const n=new Array(this.streams.length);for(let e=0;e<n.length;e++)n[e]={level:r,stream:this.streams[e].stream};return{write:u,add:l,minLevel:r,streams:n,clone:t,flushSync:h,[e]:!0}},[e]:!0};return Array.isArray(t)?t.forEach(l,c):l.call(c,t),t=null,c;function u(t){let r;const n=this.lastLevel,{streams:i}=this;let o;for(let a=0;a<i.length&&(r=i[a],r.level<=n);a++){if(o=r.stream,o[e]){const{lastTime:e,lastMsg:t,lastObj:r,lastLogger:i}=this;o.lastLevel=n,o.lastTime=e,o.lastMsg=t,o.lastObj=r,o.lastLogger=i}s.dedupe&&r.level!==n||o.write(t)}}function h(){for(const{stream:e}of this.streams)"function"==typeof e.flushSync&&e.flushSync()}function l(e){if(!e)return c;const t="function"==typeof e.write||e.stream,r=e.write?e:e.stream;if(!t)throw Error("stream object needs to implement either StreamEntry or DestinationStream interface");const{streams:s}=this;let u;u="number"==typeof e.levelVal?e.levelVal:"string"==typeof e.level?a[e.level]:"number"==typeof e.level?e.level:n;const h={stream:r,level:u,levelVal:void 0,id:o++};return s.unshift(h),s.sort(i),this.minLevel=s[0].level,c}},Po}(),js.exports.final=d,js.exports.levels=u(),js.exports.stdSerializers=G,js.exports.stdTimeFunctions=Object.assign({},i),js.exports.symbols=o,js.exports.version=_,js.exports.default=Y,js.exports.pino=Y,js.exports}var jo,Ro={};function Lo(){return jo||(jo=1,Object.defineProperty(Ro,"__esModule",{value:!0}),Ro.PINO_CUSTOM_CONTEXT_KEY=Ro.PINO_LOGGER_DEFAULTS=void 0,Ro.PINO_LOGGER_DEFAULTS={level:"info"},Ro.PINO_CUSTOM_CONTEXT_KEY="custom_context"),Ro}var ko,Mo={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.pino=void 0;const t=n.require$$0,r=t.__importDefault(Co());Object.defineProperty(e,"pino",{enumerable:!0,get:function(){return r.default}}),t.__exportStar(Lo(),e),t.__exportStar(function(){if(ko)return Mo;ko=1,Object.defineProperty(Mo,"__esModule",{value:!0}),Mo.generateChildLogger=Mo.formatChildLoggerContext=Mo.getLoggerContext=Mo.setBrowserLoggerContext=Mo.getBrowserLoggerContext=Mo.getDefaultLoggerOptions=void 0;const e=Lo();function t(t,r=e.PINO_CUSTOM_CONTEXT_KEY){return t[r]||""}function r(t,r,n=e.PINO_CUSTOM_CONTEXT_KEY){return t[n]=r,t}function n(r,n=e.PINO_CUSTOM_CONTEXT_KEY){let i="";return i=void 0===r.bindings?t(r,n):r.bindings().context||"",i}function i(t,r,i=e.PINO_CUSTOM_CONTEXT_KEY){const s=n(t,i);return s.trim()?`${s}/${r}`:r}return Mo.getDefaultLoggerOptions=function(t){return Object.assign(Object.assign({},t),{level:(null==t?void 0:t.level)||e.PINO_LOGGER_DEFAULTS.level})},Mo.getBrowserLoggerContext=t,Mo.setBrowserLoggerContext=r,Mo.getLoggerContext=n,Mo.formatChildLoggerContext=i,Mo.generateChildLogger=function(t,n,s=e.PINO_CUSTOM_CONTEXT_KEY){const o=i(t,n,s);return r(t.child({context:o}),o,s)},Mo}(),e)}(Cs);class Uo extends Di{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class $o extends Di{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}}class Do{constructor(e,t){this.logger=e,this.core=t}}class zo extends Di{constructor(e,t){super(),this.relayer=e,this.logger=t}}class qo extends Di{constructor(e){super()}}class Ho{constructor(e,t,r,n){this.core=e,this.logger=t,this.name=r}}class Ko extends Di{constructor(e,t){super(),this.relayer=e,this.logger=t}}class Bo extends Di{constructor(e,t){super(),this.core=e,this.logger=t}}class Vo{constructor(e,t){this.projectId=e,this.logger=t}}class Fo{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class Wo{constructor(e){this.client=e}}const Go=e=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString()+"n":t));function Yo(e){if("string"!=typeof e)throw new Error("Cannot safe json parse value of type "+typeof e);try{return(e=>{const t=e.replace(/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,'$1"$2n"$3');return JSON.parse(t,((e,t)=>"string"==typeof t&&t.match(/^\d+n$/)?BigInt(t.substring(0,t.length-1)):t))})(e)}catch(t){return e}}function Jo(e){return"string"==typeof e?e:Go(e)||""}var Xo={},Zo={};!function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=x,r=H;e.DIGEST_LENGTH=64,e.BLOCK_SIZE=128;var n=function(){function n(){this.digestLength=e.DIGEST_LENGTH,this.blockSize=e.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return n.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},n.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},n.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},n.prototype.update=function(t,r){if(void 0===r&&(r=t.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var n=0;if(this._bytesHashed+=r,this._bufferLength>0){for(;this._bufferLength<e.BLOCK_SIZE&&r>0;)this._buffer[this._bufferLength++]=t[n++],r--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(r>=this.blockSize&&(n=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,t,n,r),r%=this.blockSize);r>0;)this._buffer[this._bufferLength++]=t[n++],r--;return this},n.prototype.finish=function(e){if(!this._finished){var r=this._bytesHashed,n=this._bufferLength,i=r/536870912|0,o=r<<3,a=r%128<112?128:256;this._buffer[n]=128;for(var c=n+1;c<a-8;c++)this._buffer[c]=0;t.writeUint32BE(i,this._buffer,a-8),t.writeUint32BE(o,this._buffer,a-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,a),this._finished=!0}for(c=0;c<this.digestLength/8;c++)t.writeUint32BE(this._stateHi[c],e,8*c),t.writeUint32BE(this._stateLo[c],e,8*c+4);return this},n.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},n.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},n.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},n.prototype.cleanSavedState=function(e){r.wipe(e.stateHi),r.wipe(e.stateLo),e.buffer&&r.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},n}();e.SHA512=n;var i=new Int32Array([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]);function s(e,r,n,s,o,a,c){for(var u,h,l,f,p,d,g,y,m=n[0],v=n[1],b=n[2],w=n[3],_=n[4],E=n[5],S=n[6],I=n[7],O=s[0],P=s[1],A=s[2],N=s[3],x=s[4],T=s[5],C=s[6],j=s[7];c>=128;){for(var R=0;R<16;R++){var L=8*R+a;e[R]=t.readUint32BE(o,L),r[R]=t.readUint32BE(o,L+4)}for(R=0;R<80;R++){var k,M,U=m,$=v,D=b,z=w,q=_,H=E,K=S,B=O,V=P,F=A,W=N,G=x,Y=T,J=C;if(p=65535&(h=j),d=h>>>16,g=65535&(u=I),y=u>>>16,p+=65535&(h=(x>>>14|_<<18)^(x>>>18|_<<14)^(_>>>9|x<<23)),d+=h>>>16,g+=65535&(u=(_>>>14|x<<18)^(_>>>18|x<<14)^(x>>>9|_<<23)),y+=u>>>16,p+=65535&(h=x&T^~x&C),d+=h>>>16,g+=65535&(u=_&E^~_&S),y+=u>>>16,u=i[2*R],p+=65535&(h=i[2*R+1]),d+=h>>>16,g+=65535&u,y+=u>>>16,u=e[R%16],d+=(h=r[R%16])>>>16,g+=65535&u,y+=u>>>16,g+=(d+=(p+=65535&h)>>>16)>>>16,p=65535&(h=f=65535&p|d<<16),d=h>>>16,g=65535&(u=l=65535&g|(y+=g>>>16)<<16),y=u>>>16,p+=65535&(h=(O>>>28|m<<4)^(m>>>2|O<<30)^(m>>>7|O<<25)),d+=h>>>16,g+=65535&(u=(m>>>28|O<<4)^(O>>>2|m<<30)^(O>>>7|m<<25)),y+=u>>>16,d+=(h=O&P^O&A^P&A)>>>16,g+=65535&(u=m&v^m&b^v&b),y+=u>>>16,k=65535&(g+=(d+=(p+=65535&h)>>>16)>>>16)|(y+=g>>>16)<<16,M=65535&p|d<<16,p=65535&(h=W),d=h>>>16,g=65535&(u=z),y=u>>>16,d+=(h=f)>>>16,g+=65535&(u=l),y+=u>>>16,v=U,b=$,w=D,_=z=65535&(g+=(d+=(p+=65535&h)>>>16)>>>16)|(y+=g>>>16)<<16,E=q,S=H,I=K,m=k,P=B,A=V,N=F,x=W=65535&p|d<<16,T=G,C=Y,j=J,O=M,R%16==15)for(L=0;L<16;L++)u=e[L],p=65535&(h=r[L]),d=h>>>16,g=65535&u,y=u>>>16,u=e[(L+9)%16],p+=65535&(h=r[(L+9)%16]),d+=h>>>16,g+=65535&u,y+=u>>>16,l=e[(L+1)%16],p+=65535&(h=((f=r[(L+1)%16])>>>1|l<<31)^(f>>>8|l<<24)^(f>>>7|l<<25)),d+=h>>>16,g+=65535&(u=(l>>>1|f<<31)^(l>>>8|f<<24)^l>>>7),y+=u>>>16,l=e[(L+14)%16],d+=(h=((f=r[(L+14)%16])>>>19|l<<13)^(l>>>29|f<<3)^(f>>>6|l<<26))>>>16,g+=65535&(u=(l>>>19|f<<13)^(f>>>29|l<<3)^l>>>6),y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,e[L]=65535&g|y<<16,r[L]=65535&p|d<<16}p=65535&(h=O),d=h>>>16,g=65535&(u=m),y=u>>>16,u=n[0],d+=(h=s[0])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[0]=m=65535&g|y<<16,s[0]=O=65535&p|d<<16,p=65535&(h=P),d=h>>>16,g=65535&(u=v),y=u>>>16,u=n[1],d+=(h=s[1])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[1]=v=65535&g|y<<16,s[1]=P=65535&p|d<<16,p=65535&(h=A),d=h>>>16,g=65535&(u=b),y=u>>>16,u=n[2],d+=(h=s[2])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[2]=b=65535&g|y<<16,s[2]=A=65535&p|d<<16,p=65535&(h=N),d=h>>>16,g=65535&(u=w),y=u>>>16,u=n[3],d+=(h=s[3])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[3]=w=65535&g|y<<16,s[3]=N=65535&p|d<<16,p=65535&(h=x),d=h>>>16,g=65535&(u=_),y=u>>>16,u=n[4],d+=(h=s[4])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[4]=_=65535&g|y<<16,s[4]=x=65535&p|d<<16,p=65535&(h=T),d=h>>>16,g=65535&(u=E),y=u>>>16,u=n[5],d+=(h=s[5])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[5]=E=65535&g|y<<16,s[5]=T=65535&p|d<<16,p=65535&(h=C),d=h>>>16,g=65535&(u=S),y=u>>>16,u=n[6],d+=(h=s[6])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[6]=S=65535&g|y<<16,s[6]=C=65535&p|d<<16,p=65535&(h=j),d=h>>>16,g=65535&(u=I),y=u>>>16,u=n[7],d+=(h=s[7])>>>16,g+=65535&u,y+=u>>>16,y+=(g+=(d+=(p+=65535&h)>>>16)>>>16)>>>16,n[7]=I=65535&g|y<<16,s[7]=j=65535&p|d<<16,a+=128,c-=128}return a}e.hash=function(e){var t=new n;t.update(e);var r=t.digest();return t.clean(),r}}(Zo),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.convertSecretKeyToX25519=e.convertPublicKeyToX25519=e.verify=e.sign=e.extractPublicKeyFromSecretKey=e.generateKeyPair=e.generateKeyPairFromSeed=e.SEED_LENGTH=e.SECRET_KEY_LENGTH=e.PUBLIC_KEY_LENGTH=e.SIGNATURE_LENGTH=void 0;const t=ue,r=Zo,n=H;function i(e){const t=new Float64Array(16);if(e)for(let r=0;r<e.length;r++)t[r]=e[r];return t}e.SIGNATURE_LENGTH=64,e.PUBLIC_KEY_LENGTH=32,e.SECRET_KEY_LENGTH=64,e.SEED_LENGTH=32;new Uint8Array(32)[0]=9;const s=i(),o=i([1]),a=i([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),c=i([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=i([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),h=i([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),l=i([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function f(e,t){for(let r=0;r<16;r++)e[r]=0|t[r]}function p(e){let t=1;for(let r=0;r<16;r++){let n=e[r]+t+65535;t=Math.floor(n/65536),e[r]=n-65536*t}e[0]+=t-1+37*(t-1)}function d(e,t,r){const n=~(r-1);for(let r=0;r<16;r++){const i=n&(e[r]^t[r]);e[r]^=i,t[r]^=i}}function g(e,t){const r=i(),n=i();for(let e=0;e<16;e++)n[e]=t[e];p(n),p(n),p(n);for(let e=0;e<2;e++){r[0]=n[0]-65517;for(let e=1;e<15;e++)r[e]=n[e]-65535-(r[e-1]>>16&1),r[e-1]&=65535;r[15]=n[15]-32767-(r[14]>>16&1);const e=r[15]>>16&1;r[14]&=65535,d(n,r,1-e)}for(let t=0;t<16;t++)e[2*t]=255&n[t],e[2*t+1]=n[t]>>8}function y(e,t){let r=0;for(let n=0;n<32;n++)r|=e[n]^t[n];return(1&r-1>>>8)-1}function m(e,t){const r=new Uint8Array(32),n=new Uint8Array(32);return g(r,e),g(n,t),y(r,n)}function v(e){const t=new Uint8Array(32);return g(t,e),1&t[0]}function b(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]+r[n]}function w(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]-r[n]}function _(e,t,r){let n,i,s=0,o=0,a=0,c=0,u=0,h=0,l=0,f=0,p=0,d=0,g=0,y=0,m=0,v=0,b=0,w=0,_=0,E=0,S=0,I=0,O=0,P=0,A=0,N=0,x=0,T=0,C=0,j=0,R=0,L=0,k=0,M=r[0],U=r[1],$=r[2],D=r[3],z=r[4],q=r[5],H=r[6],K=r[7],B=r[8],V=r[9],F=r[10],W=r[11],G=r[12],Y=r[13],J=r[14],X=r[15];n=t[0],s+=n*M,o+=n*U,a+=n*$,c+=n*D,u+=n*z,h+=n*q,l+=n*H,f+=n*K,p+=n*B,d+=n*V,g+=n*F,y+=n*W,m+=n*G,v+=n*Y,b+=n*J,w+=n*X,n=t[1],o+=n*M,a+=n*U,c+=n*$,u+=n*D,h+=n*z,l+=n*q,f+=n*H,p+=n*K,d+=n*B,g+=n*V,y+=n*F,m+=n*W,v+=n*G,b+=n*Y,w+=n*J,_+=n*X,n=t[2],a+=n*M,c+=n*U,u+=n*$,h+=n*D,l+=n*z,f+=n*q,p+=n*H,d+=n*K,g+=n*B,y+=n*V,m+=n*F,v+=n*W,b+=n*G,w+=n*Y,_+=n*J,E+=n*X,n=t[3],c+=n*M,u+=n*U,h+=n*$,l+=n*D,f+=n*z,p+=n*q,d+=n*H,g+=n*K,y+=n*B,m+=n*V,v+=n*F,b+=n*W,w+=n*G,_+=n*Y,E+=n*J,S+=n*X,n=t[4],u+=n*M,h+=n*U,l+=n*$,f+=n*D,p+=n*z,d+=n*q,g+=n*H,y+=n*K,m+=n*B,v+=n*V,b+=n*F,w+=n*W,_+=n*G,E+=n*Y,S+=n*J,I+=n*X,n=t[5],h+=n*M,l+=n*U,f+=n*$,p+=n*D,d+=n*z,g+=n*q,y+=n*H,m+=n*K,v+=n*B,b+=n*V,w+=n*F,_+=n*W,E+=n*G,S+=n*Y,I+=n*J,O+=n*X,n=t[6],l+=n*M,f+=n*U,p+=n*$,d+=n*D,g+=n*z,y+=n*q,m+=n*H,v+=n*K,b+=n*B,w+=n*V,_+=n*F,E+=n*W,S+=n*G,I+=n*Y,O+=n*J,P+=n*X,n=t[7],f+=n*M,p+=n*U,d+=n*$,g+=n*D,y+=n*z,m+=n*q,v+=n*H,b+=n*K,w+=n*B,_+=n*V,E+=n*F,S+=n*W,I+=n*G,O+=n*Y,P+=n*J,A+=n*X,n=t[8],p+=n*M,d+=n*U,g+=n*$,y+=n*D,m+=n*z,v+=n*q,b+=n*H,w+=n*K,_+=n*B,E+=n*V,S+=n*F,I+=n*W,O+=n*G,P+=n*Y,A+=n*J,N+=n*X,n=t[9],d+=n*M,g+=n*U,y+=n*$,m+=n*D,v+=n*z,b+=n*q,w+=n*H,_+=n*K,E+=n*B,S+=n*V,I+=n*F,O+=n*W,P+=n*G,A+=n*Y,N+=n*J,x+=n*X,n=t[10],g+=n*M,y+=n*U,m+=n*$,v+=n*D,b+=n*z,w+=n*q,_+=n*H,E+=n*K,S+=n*B,I+=n*V,O+=n*F,P+=n*W,A+=n*G,N+=n*Y,x+=n*J,T+=n*X,n=t[11],y+=n*M,m+=n*U,v+=n*$,b+=n*D,w+=n*z,_+=n*q,E+=n*H,S+=n*K,I+=n*B,O+=n*V,P+=n*F,A+=n*W,N+=n*G,x+=n*Y,T+=n*J,C+=n*X,n=t[12],m+=n*M,v+=n*U,b+=n*$,w+=n*D,_+=n*z,E+=n*q,S+=n*H,I+=n*K,O+=n*B,P+=n*V,A+=n*F,N+=n*W,x+=n*G,T+=n*Y,C+=n*J,j+=n*X,n=t[13],v+=n*M,b+=n*U,w+=n*$,_+=n*D,E+=n*z,S+=n*q,I+=n*H,O+=n*K,P+=n*B,A+=n*V,N+=n*F,x+=n*W,T+=n*G,C+=n*Y,j+=n*J,R+=n*X,n=t[14],b+=n*M,w+=n*U,_+=n*$,E+=n*D,S+=n*z,I+=n*q,O+=n*H,P+=n*K,A+=n*B,N+=n*V,x+=n*F,T+=n*W,C+=n*G,j+=n*Y,R+=n*J,L+=n*X,n=t[15],w+=n*M,_+=n*U,E+=n*$,S+=n*D,I+=n*z,O+=n*q,P+=n*H,A+=n*K,N+=n*B,x+=n*V,T+=n*F,C+=n*W,j+=n*G,R+=n*Y,L+=n*J,k+=n*X,s+=38*_,o+=38*E,a+=38*S,c+=38*I,u+=38*O,h+=38*P,l+=38*A,f+=38*N,p+=38*x,d+=38*T,g+=38*C,y+=38*j,m+=38*R,v+=38*L,b+=38*k,i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-65536*i,n=o+i+65535,i=Math.floor(n/65536),o=n-65536*i,n=a+i+65535,i=Math.floor(n/65536),a=n-65536*i,n=c+i+65535,i=Math.floor(n/65536),c=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=n-65536*i,n=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=l+i+65535,i=Math.floor(n/65536),l=n-65536*i,n=f+i+65535,i=Math.floor(n/65536),f=n-65536*i,n=p+i+65535,i=Math.floor(n/65536),p=n-65536*i,n=d+i+65535,i=Math.floor(n/65536),d=n-65536*i,n=g+i+65535,i=Math.floor(n/65536),g=n-65536*i,n=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=b+i+65535,i=Math.floor(n/65536),b=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,s+=i-1+37*(i-1),i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-65536*i,n=o+i+65535,i=Math.floor(n/65536),o=n-65536*i,n=a+i+65535,i=Math.floor(n/65536),a=n-65536*i,n=c+i+65535,i=Math.floor(n/65536),c=n-65536*i,n=u+i+65535,i=Math.floor(n/65536),u=n-65536*i,n=h+i+65535,i=Math.floor(n/65536),h=n-65536*i,n=l+i+65535,i=Math.floor(n/65536),l=n-65536*i,n=f+i+65535,i=Math.floor(n/65536),f=n-65536*i,n=p+i+65535,i=Math.floor(n/65536),p=n-65536*i,n=d+i+65535,i=Math.floor(n/65536),d=n-65536*i,n=g+i+65535,i=Math.floor(n/65536),g=n-65536*i,n=y+i+65535,i=Math.floor(n/65536),y=n-65536*i,n=m+i+65535,i=Math.floor(n/65536),m=n-65536*i,n=v+i+65535,i=Math.floor(n/65536),v=n-65536*i,n=b+i+65535,i=Math.floor(n/65536),b=n-65536*i,n=w+i+65535,i=Math.floor(n/65536),w=n-65536*i,s+=i-1+37*(i-1),e[0]=s,e[1]=o,e[2]=a,e[3]=c,e[4]=u,e[5]=h,e[6]=l,e[7]=f,e[8]=p,e[9]=d,e[10]=g,e[11]=y,e[12]=m,e[13]=v,e[14]=b,e[15]=w}function E(e,t){_(e,t,t)}function S(e,t){const r=i();let n;for(n=0;n<16;n++)r[n]=t[n];for(n=253;n>=0;n--)E(r,r),2!==n&&4!==n&&_(r,r,t);for(n=0;n<16;n++)e[n]=r[n]}function I(e,t){const r=i(),n=i(),s=i(),o=i(),a=i(),u=i(),h=i(),l=i(),f=i();w(r,e[1],e[0]),w(f,t[1],t[0]),_(r,r,f),b(n,e[0],e[1]),b(f,t[0],t[1]),_(n,n,f),_(s,e[3],t[3]),_(s,s,c),_(o,e[2],t[2]),b(o,o,o),w(a,n,r),w(u,o,s),b(h,o,s),b(l,n,r),_(e[0],a,u),_(e[1],l,h),_(e[2],h,u),_(e[3],a,l)}function O(e,t,r){for(let n=0;n<4;n++)d(e[n],t[n],r)}function P(e,t){const r=i(),n=i(),s=i();S(s,t[2]),_(r,t[0],s),_(n,t[1],s),g(e,n),e[31]^=v(r)<<7}function A(e,t,r){f(e[0],s),f(e[1],o),f(e[2],o),f(e[3],s);for(let n=255;n>=0;--n){const i=r[n/8|0]>>(7&n)&1;O(e,t,i),I(t,e),I(e,e),O(e,t,i)}}function N(e,t){const r=[i(),i(),i(),i()];f(r[0],u),f(r[1],h),f(r[2],o),_(r[3],u,h),A(e,r,t)}function x(t){if(t.length!==e.SEED_LENGTH)throw new Error(`ed25519: seed must be ${e.SEED_LENGTH} bytes`);const n=(0,r.hash)(t);n[0]&=248,n[31]&=127,n[31]|=64;const s=new Uint8Array(32),o=[i(),i(),i(),i()];N(o,n),P(s,o);const a=new Uint8Array(64);return a.set(t),a.set(s,32),{publicKey:s,secretKey:a}}e.generateKeyPairFromSeed=x,e.generateKeyPair=function(e){const r=(0,t.randomBytes)(32,e),i=x(r);return(0,n.wipe)(r),i},e.extractPublicKeyFromSecretKey=function(t){if(t.length!==e.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${e.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(t.subarray(32))};const T=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function C(e,t){let r,n,i,s;for(n=63;n>=32;--n){for(r=0,i=n-32,s=n-12;i<s;++i)t[i]+=r-16*t[n]*T[i-(n-32)],r=Math.floor((t[i]+128)/256),t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;i++)t[i]+=r-(t[31]>>4)*T[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*T[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function j(e){const t=new Float64Array(64);for(let r=0;r<64;r++)t[r]=e[r];for(let t=0;t<64;t++)e[t]=0;C(e,t)}function R(e,t){const r=i(),n=i(),c=i(),u=i(),h=i(),p=i(),d=i();return f(e[2],o),function(e,t){for(let r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(e[1],t),E(c,e[1]),_(u,c,a),w(c,c,e[2]),b(u,e[2],u),E(h,u),E(p,h),_(d,p,h),_(r,d,c),_(r,r,u),function(e,t){const r=i();let n;for(n=0;n<16;n++)r[n]=t[n];for(n=250;n>=0;n--)E(r,r),1!==n&&_(r,r,t);for(n=0;n<16;n++)e[n]=r[n]}(r,r),_(r,r,c),_(r,r,u),_(r,r,u),_(e[0],r,u),E(n,e[0]),_(n,n,u),m(n,c)&&_(e[0],e[0],l),E(n,e[0]),_(n,n,u),m(n,c)?-1:(v(e[0])===t[31]>>7&&w(e[0],s,e[0]),_(e[3],e[0],e[1]),0)}e.sign=function(e,t){const n=new Float64Array(64),s=[i(),i(),i(),i()],o=(0,r.hash)(e.subarray(0,32));o[0]&=248,o[31]&=127,o[31]|=64;const a=new Uint8Array(64);a.set(o.subarray(32),32);const c=new r.SHA512;c.update(a.subarray(32)),c.update(t);const u=c.digest();c.clean(),j(u),N(s,u),P(a,s),c.reset(),c.update(a.subarray(0,32)),c.update(e.subarray(32)),c.update(t);const h=c.digest();j(h);for(let e=0;e<32;e++)n[e]=u[e];for(let e=0;e<32;e++)for(let t=0;t<32;t++)n[e+t]+=h[e]*o[t];return C(a.subarray(32),n),a},e.verify=function(t,n,s){const o=new Uint8Array(32),a=[i(),i(),i(),i()],c=[i(),i(),i(),i()];if(s.length!==e.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${e.SIGNATURE_LENGTH} bytes`);if(R(c,t))return!1;const u=new r.SHA512;u.update(s.subarray(0,32)),u.update(t),u.update(n);const h=u.digest();return j(h),A(a,c,h),N(c,s.subarray(32)),I(a,c),P(o,a),!y(s,o)},e.convertPublicKeyToX25519=function(e){let t=[i(),i(),i(),i()];if(R(t,e))throw new Error("Ed25519: invalid public key");let r=i(),n=i(),s=t[1];b(r,o,s),w(n,o,s),S(n,n),_(r,r,n);let a=new Uint8Array(32);return g(a,r),a},e.convertSecretKeyToX25519=function(e){const t=(0,r.hash)(e.subarray(0,32));t[0]&=248,t[31]&=127,t[31]|=64;const i=new Uint8Array(t.subarray(0,32));return(0,n.wipe)(t),i}}(Xo);const Qo=".",ea="base64url",ta="utf8",ra="utf8",na=":",ia="did",sa="key",oa="base58btc",aa="z",ca="K36";function ua(e){return Bt(Kt(Jo(e),ta),ea)}function ha(e){const t=Kt(ca,oa),r=aa+Bt(we([t,e]),oa);return[ia,sa,r].join(na)}function la(e=ue.randomBytes(32)){return Xo.generateKeyPairFromSeed(e)}async function fa(e,t,r,n,i=ir.fromMiliseconds(Date.now())){const s={alg:"EdDSA",typ:"JWT"},o={iss:ha(n.publicKey),sub:e,aud:t,iat:i,exp:i+r},a=Kt([ua((c={header:s,payload:o}).header),ua(c.payload)].join(Qo),ra);var c;return function(e){return[ua(e.header),ua(e.payload),(t=e.signature,Bt(t,ea))].join(Qo);var t}({header:s,payload:o,signature:Xo.sign(n.secretKey,a)})}const pa="INTERNAL_ERROR",da="SERVER_ERROR",ga=[-32700,-32600,-32601,-32602,-32603],ya={PARSE_ERROR:{code:-32700,message:"Parse error"},INVALID_REQUEST:{code:-32600,message:"Invalid Request"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found"},INVALID_PARAMS:{code:-32602,message:"Invalid params"},[pa]:{code:-32603,message:"Internal error"},[da]:{code:-32e3,message:"Server error"}},ma=da;function va(e){return Object.keys(ya).includes(e)?ya[e]:ya[ma]}function ba(e,t,r){return e.message.includes("getaddrinfo ENOTFOUND")||e.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${t}`):e}var wa,_a={},Ea={};var Sa,Ia={};function Oa(e=3){return Date.now()*Math.pow(10,e)+Math.floor(Math.random()*Math.pow(10,e))}function Pa(e=6){return BigInt(Oa(e))}function Aa(e,t,r){return{id:r||Oa(),jsonrpc:"2.0",method:e,params:t}}function Na(e,t){return{id:e,jsonrpc:"2.0",result:t}}function xa(e,t,r){return{id:e,jsonrpc:"2.0",error:Ta(t,r)}}function Ta(e,t){return void 0===e?va(pa):("string"==typeof e&&(e=Object.assign(Object.assign({},va(da)),{message:e})),void 0!==t&&(e.data=t),function(e){return ga.includes(e)}(e.code)&&(e=function(e){const t=Object.values(ya).find((t=>t.code===e));return t||ya[ma]}(e.code)),e)}!function(e){Object.defineProperty(e,"__esModule",{value:!0});const t=n.require$$0;t.__exportStar(function(){if(wa)return Ea;function e(){return(null===i.commonjsGlobal||void 0===i.commonjsGlobal?void 0:i.commonjsGlobal.crypto)||(null===i.commonjsGlobal||void 0===i.commonjsGlobal?void 0:i.commonjsGlobal.msCrypto)||{}}function t(){const t=e();return t.subtle||t.webkitSubtle}return wa=1,Object.defineProperty(Ea,"__esModule",{value:!0}),Ea.isBrowserCryptoAvailable=Ea.getSubtleCrypto=Ea.getBrowerCrypto=void 0,Ea.getBrowerCrypto=e,Ea.getSubtleCrypto=t,Ea.isBrowserCryptoAvailable=function(){return!!e()&&!!t()},Ea}(),e),t.__exportStar(function(){if(Sa)return Ia;function e(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product}function t(){return"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node}return Sa=1,Object.defineProperty(Ia,"__esModule",{value:!0}),Ia.isBrowser=Ia.isNode=Ia.isReactNative=void 0,Ia.isReactNative=e,Ia.isNode=t,Ia.isBrowser=function(){return!e()&&!t()},Ia}(),e)}(_a);class Ca{}class ja extends Ca{constructor(){super()}}class Ra extends ja{constructor(e){super()}}function La(e,t){const r=function(e){const t=e.match(new RegExp(/^\w+:/,"gi"));if(t&&t.length)return t[0]}(e);return void 0!==r&&new RegExp(t).test(r)}function ka(e){return La(e,"^https?:")}function Ma(e){return La(e,"^wss?:")}function Ua(e){return new RegExp("wss?://localhost(:d{2,5})?").test(e)}function $a(e){return"object"==typeof e&&"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function Da(e){return $a(e)&&"method"in e}function za(e){return $a(e)&&(qa(e)||Ha(e))}function qa(e){return"result"in e}function Ha(e){return"error"in e}class Ka extends Ra{constructor(t){super(t),this.events=new e.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(Aa(e.method,e.params||[],e.id||Pa().toString()),t)}async requestStrict(e,t){return new Promise((async(r,n)=>{if(!this.connection.connected)try{await this.open()}catch(e){n(e)}this.events.on(`${e.id}`,(e=>{Ha(e)?n(e.error):r(e.result)}));try{await this.connection.send(e,t)}catch(e){n(e)}}))}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),za(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&3e3===e.code&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),"string"==typeof e&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",(e=>this.onPayload(e))),this.connection.on("close",(e=>this.onClose(e))),this.connection.on("error",(e=>this.events.emit("error",e))),this.connection.on("register_error",(e=>this.onClose())),this.hasRegisteredEventListeners=!0)}}const Ba=e=>e.split("?")[0],Va="undefined"!=typeof global&&void 0!==global.WebSocket?global.WebSocket:"undefined"!=typeof window&&void 0!==window.WebSocket?window.WebSocket:require("ws");class Fa{constructor(t){if(this.url=t,this.events=new e.EventEmitter,this.registering=!1,!Ma(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return void 0!==this.socket}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise(((e,t)=>{void 0!==this.socket?(this.socket.onclose=t=>{this.onClose(t),e()},this.socket.close()):t(new Error("Connection already closed"))}))}async send(e,t){void 0===this.socket&&(this.socket=await this.register());try{this.socket.send(Jo(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!Ma(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise(((e,t)=>{this.events.once("register_error",(e=>{this.resetMaxListeners(),t(e)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),void 0===this.socket)return t(new Error("WebSocket connection is missing or invalid"));e(this.socket)}))}))}return this.url=e,this.registering=!0,new Promise(((t,r)=>{const n=_a.isReactNative()?void 0:{rejectUnauthorized:!Ua(e)},i=new Va(e,[],n);"undefined"!=typeof window?i.onerror=e=>{const t=e;r(this.emitError(t.error))}:i.on("error",(e=>{r(this.emitError(e))})),i.onopen=()=>{this.onOpen(i),t(i)}}))}onOpen(e){e.onmessage=e=>this.onPayload(e),e.onclose=e=>this.onClose(e),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(void 0===e.data)return;const t="string"==typeof e.data?Yo(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const r=this.parseError(t),n=xa(e,r.message||r.toString());this.events.emit("payload",n)}parseError(e,t=this.url){return ba(e,Ba(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}emitError(e){const t=this.parseError(new Error((null==e?void 0:e.message)||`WebSocket connection failed for host: ${Ba(this.url)}`));return this.events.emit("register_error",t),t}}var Wa={exports:{}};!function(e,t){var r="__lodash_hash_undefined__",n=1,s=2,o=9007199254740991,a="[object Arguments]",c="[object Array]",u="[object AsyncFunction]",h="[object Boolean]",l="[object Date]",f="[object Error]",p="[object Function]",d="[object GeneratorFunction]",g="[object Map]",y="[object Number]",m="[object Null]",v="[object Object]",b="[object Promise]",w="[object Proxy]",_="[object RegExp]",E="[object Set]",S="[object String]",I="[object Symbol]",O="[object Undefined]",P="[object WeakMap]",A="[object ArrayBuffer]",N="[object DataView]",x=/^\[object .+?Constructor\]$/,T=/^(?:0|[1-9]\d*)$/,C={};C["[object Float32Array]"]=C["[object Float64Array]"]=C["[object Int8Array]"]=C["[object Int16Array]"]=C["[object Int32Array]"]=C["[object Uint8Array]"]=C["[object Uint8ClampedArray]"]=C["[object Uint16Array]"]=C["[object Uint32Array]"]=!0,C[a]=C[c]=C[A]=C[h]=C[N]=C[l]=C[f]=C[p]=C[g]=C[y]=C[v]=C[_]=C[E]=C[S]=C[P]=!1;var j="object"==typeof i.commonjsGlobal&&i.commonjsGlobal&&i.commonjsGlobal.Object===Object&&i.commonjsGlobal,R="object"==typeof self&&self&&self.Object===Object&&self,L=j||R||Function("return this")(),k=t&&!t.nodeType&&t,M=k&&e&&!e.nodeType&&e,U=M&&M.exports===k,$=U&&j.process,D=function(){try{return $&&$.binding&&$.binding("util")}catch(e){}}(),z=D&&D.isTypedArray;function q(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}function H(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function K(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var B,V,F,W=Array.prototype,G=Function.prototype,Y=Object.prototype,J=L["__core-js_shared__"],X=G.toString,Z=Y.hasOwnProperty,Q=(B=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||""))?"Symbol(src)_1."+B:"",ee=Y.toString,te=RegExp("^"+X.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),re=U?L.Buffer:void 0,ne=L.Symbol,ie=L.Uint8Array,se=Y.propertyIsEnumerable,oe=W.splice,ae=ne?ne.toStringTag:void 0,ce=Object.getOwnPropertySymbols,ue=re?re.isBuffer:void 0,he=(V=Object.keys,F=Object,function(e){return V(F(e))}),le=De(L,"DataView"),fe=De(L,"Map"),pe=De(L,"Promise"),de=De(L,"Set"),ge=De(L,"WeakMap"),ye=De(Object,"create"),me=Ke(le),ve=Ke(fe),be=Ke(pe),we=Ke(de),_e=Ke(ge),Ee=ne?ne.prototype:void 0,Se=Ee?Ee.valueOf:void 0;function Ie(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Oe(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Pe(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Ae(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new Pe;++t<r;)this.add(e[t])}function Ne(e){var t=this.__data__=new Oe(e);this.size=t.size}function xe(e,t){var r=Fe(e),n=!r&&Ve(e),i=!r&&!n&&We(e),s=!r&&!n&&!i&&Ze(e),o=r||n||i||s,a=o?function(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}(e.length,String):[],c=a.length;for(var u in e)!t&&!Z.call(e,u)||o&&("length"==u||i&&("offset"==u||"parent"==u)||s&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||He(u,c))||a.push(u);return a}function Te(e,t){for(var r=e.length;r--;)if(Be(e[r][0],t))return r;return-1}function Ce(e){return null==e?void 0===e?O:m:ae&&ae in Object(e)?function(e){var t=Z.call(e,ae),r=e[ae];try{e[ae]=void 0;var n=!0}catch(e){}var i=ee.call(e);n&&(t?e[ae]=r:delete e[ae]);return i}(e):function(e){return ee.call(e)}(e)}function je(e){return Xe(e)&&Ce(e)==a}function Re(e,t,r,i,o){return e===t||(null==e||null==t||!Xe(e)&&!Xe(t)?e!=e&&t!=t:function(e,t,r,i,o,u){var p=Fe(e),d=Fe(t),m=p?c:qe(e),b=d?c:qe(t),w=(m=m==a?v:m)==v,O=(b=b==a?v:b)==v,P=m==b;if(P&&We(e)){if(!We(t))return!1;p=!0,w=!1}if(P&&!w)return u||(u=new Ne),p||Ze(e)?Me(e,t,r,i,o,u):function(e,t,r,i,o,a,c){switch(r){case N:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case A:return!(e.byteLength!=t.byteLength||!a(new ie(e),new ie(t)));case h:case l:case y:return Be(+e,+t);case f:return e.name==t.name&&e.message==t.message;case _:case S:return e==t+"";case g:var u=H;case E:var p=i&n;if(u||(u=K),e.size!=t.size&&!p)return!1;var d=c.get(e);if(d)return d==t;i|=s,c.set(e,t);var m=Me(u(e),u(t),i,o,a,c);return c.delete(e),m;case I:if(Se)return Se.call(e)==Se.call(t)}return!1}(e,t,m,r,i,o,u);if(!(r&n)){var x=w&&Z.call(e,"__wrapped__"),T=O&&Z.call(t,"__wrapped__");if(x||T){var C=x?e.value():e,j=T?t.value():t;return u||(u=new Ne),o(C,j,r,i,u)}}if(!P)return!1;return u||(u=new Ne),function(e,t,r,i,s,o){var a=r&n,c=Ue(e),u=c.length,h=Ue(t),l=h.length;if(u!=l&&!a)return!1;var f=u;for(;f--;){var p=c[f];if(!(a?p in t:Z.call(t,p)))return!1}var d=o.get(e);if(d&&o.get(t))return d==t;var g=!0;o.set(e,t),o.set(t,e);var y=a;for(;++f<u;){var m=e[p=c[f]],v=t[p];if(i)var b=a?i(v,m,p,t,e,o):i(m,v,p,e,t,o);if(!(void 0===b?m===v||s(m,v,r,i,o):b)){g=!1;break}y||(y="constructor"==p)}if(g&&!y){var w=e.constructor,_=t.constructor;w==_||!("constructor"in e)||!("constructor"in t)||"function"==typeof w&&w instanceof w&&"function"==typeof _&&_ instanceof _||(g=!1)}return o.delete(e),o.delete(t),g}(e,t,r,i,o,u)}(e,t,r,i,Re,o))}function Le(e){return!(!Je(e)||function(e){return!!Q&&Q in e}(e))&&(Ge(e)?te:x).test(Ke(e))}function ke(e){if(!function(e){var t=e&&e.constructor,r="function"==typeof t&&t.prototype||Y;return e===r}(e))return he(e);var t=[];for(var r in Object(e))Z.call(e,r)&&"constructor"!=r&&t.push(r);return t}function Me(e,t,r,i,o,a){var c=r&n,u=e.length,h=t.length;if(u!=h&&!(c&&h>u))return!1;var l=a.get(e);if(l&&a.get(t))return l==t;var f=-1,p=!0,d=r&s?new Ae:void 0;for(a.set(e,t),a.set(t,e);++f<u;){var g=e[f],y=t[f];if(i)var m=c?i(y,g,f,t,e,a):i(g,y,f,e,t,a);if(void 0!==m){if(m)continue;p=!1;break}if(d){if(!q(t,(function(e,t){if(n=t,!d.has(n)&&(g===e||o(g,e,r,i,a)))return d.push(t);var n}))){p=!1;break}}else if(g!==y&&!o(g,y,r,i,a)){p=!1;break}}return a.delete(e),a.delete(t),p}function Ue(e){return function(e,t,r){var n=t(e);return Fe(e)?n:function(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}(n,r(e))}(e,Qe,ze)}function $e(e,t){var r=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?r["string"==typeof t?"string":"hash"]:r.map}function De(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return Le(r)?r:void 0}Ie.prototype.clear=function(){this.__data__=ye?ye(null):{},this.size=0},Ie.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Ie.prototype.get=function(e){var t=this.__data__;if(ye){var n=t[e];return n===r?void 0:n}return Z.call(t,e)?t[e]:void 0},Ie.prototype.has=function(e){var t=this.__data__;return ye?void 0!==t[e]:Z.call(t,e)},Ie.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=ye&&void 0===t?r:t,this},Oe.prototype.clear=function(){this.__data__=[],this.size=0},Oe.prototype.delete=function(e){var t=this.__data__,r=Te(t,e);return!(r<0)&&(r==t.length-1?t.pop():oe.call(t,r,1),--this.size,!0)},Oe.prototype.get=function(e){var t=this.__data__,r=Te(t,e);return r<0?void 0:t[r][1]},Oe.prototype.has=function(e){return Te(this.__data__,e)>-1},Oe.prototype.set=function(e,t){var r=this.__data__,n=Te(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},Pe.prototype.clear=function(){this.size=0,this.__data__={hash:new Ie,map:new(fe||Oe),string:new Ie}},Pe.prototype.delete=function(e){var t=$e(this,e).delete(e);return this.size-=t?1:0,t},Pe.prototype.get=function(e){return $e(this,e).get(e)},Pe.prototype.has=function(e){return $e(this,e).has(e)},Pe.prototype.set=function(e,t){var r=$e(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Ae.prototype.add=Ae.prototype.push=function(e){return this.__data__.set(e,r),this},Ae.prototype.has=function(e){return this.__data__.has(e)},Ne.prototype.clear=function(){this.__data__=new Oe,this.size=0},Ne.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Ne.prototype.get=function(e){return this.__data__.get(e)},Ne.prototype.has=function(e){return this.__data__.has(e)},Ne.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Oe){var n=r.__data__;if(!fe||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Pe(n)}return r.set(e,t),this.size=r.size,this};var ze=ce?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,s=[];++r<n;){var o=e[r];t(o,r,e)&&(s[i++]=o)}return s}(ce(e),(function(t){return se.call(e,t)})))}:function(){return[]},qe=Ce;function He(e,t){return!!(t=null==t?o:t)&&("number"==typeof e||T.test(e))&&e>-1&&e%1==0&&e<t}function Ke(e){if(null!=e){try{return X.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Be(e,t){return e===t||e!=e&&t!=t}(le&&qe(new le(new ArrayBuffer(1)))!=N||fe&&qe(new fe)!=g||pe&&qe(pe.resolve())!=b||de&&qe(new de)!=E||ge&&qe(new ge)!=P)&&(qe=function(e){var t=Ce(e),r=t==v?e.constructor:void 0,n=r?Ke(r):"";if(n)switch(n){case me:return N;case ve:return g;case be:return b;case we:return E;case _e:return P}return t});var Ve=je(function(){return arguments}())?je:function(e){return Xe(e)&&Z.call(e,"callee")&&!se.call(e,"callee")},Fe=Array.isArray;var We=ue||function(){return!1};function Ge(e){if(!Je(e))return!1;var t=Ce(e);return t==p||t==d||t==u||t==w}function Ye(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=o}function Je(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Xe(e){return null!=e&&"object"==typeof e}var Ze=z?function(e){return function(t){return e(t)}}(z):function(e){return Xe(e)&&Ye(e.length)&&!!C[Ce(e)]};function Qe(e){return null!=(t=e)&&Ye(t.length)&&!Ge(t)?xe(e):ke(e);var t}e.exports=function(e,t){return Re(e,t)}}(Wa,Wa.exports);var Ga=Wa.exports;var Ya=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var l=0,f=s-1;(0!==h||l<i)&&-1!==f;f--,l++)h+=a*o[f]>>>0,o[f]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=l,t++}if(" "!==e[t]){for(var p=s-i;p!==s&&0===o[p];)p++;for(var d=new Uint8Array(n+(s-p)),g=n;p!==s;)d[g++]=o[p++];return d}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*h+1>>>0,u=new Uint8Array(o);i!==s;){for(var l=t[i],f=0,p=o-1;(0!==l||f<n)&&-1!==p;p--,f++)l+=256*u[p]>>>0,u[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");n=f,i++}for(var d=o-n;d!==o&&0===u[d];)d++;for(var g=c.repeat(r);d<o;++d)g+=e.charAt(u[d]);return g},decodeUnsafe:l,decode:function(e){var r=l(e);if(r)return r;throw new Error(`Non-${t} character`)}}},Ja=Ya;const Xa=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class Za{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Qa{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return tc(this,e)}}class ec{constructor(e){this.decoders=e}or(e){return tc(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const tc=(e,t)=>new ec({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class rc{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Za(e,t,r),this.decoder=new Qa(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const nc=({name:e,prefix:t,encode:r,decode:n})=>new rc(e,t,r,n),ic=({prefix:e,name:t,alphabet:r})=>{const{encode:n,decode:i}=Ja(r,t);return nc({prefix:e,name:t,encode:n,decode:e=>Xa(i(e))})},sc=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>nc({prefix:t,name:e,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let n=0;n<e.length;++n)for(a=a<<8|e[n],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(o&&(s+=t[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s})(e,n,r),decode:t=>((e,t,r,n)=>{const i={};for(let e=0;e<t.length;++e)i[t[e]]=e;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let t=0;t<s;++t){const s=i[e[t]];if(void 0===s)throw new SyntaxError(`Non-${n} character`);c=c<<r|s,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,n,r,e)}),oc=nc({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var ac=Object.freeze({__proto__:null,identity:oc});const cc=sc({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var uc=Object.freeze({__proto__:null,base2:cc});const hc=sc({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var lc=Object.freeze({__proto__:null,base8:hc});const fc=ic({prefix:"9",name:"base10",alphabet:"0123456789"});var pc=Object.freeze({__proto__:null,base10:fc});const dc=sc({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),gc=sc({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var yc=Object.freeze({__proto__:null,base16:dc,base16upper:gc});const mc=sc({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),vc=sc({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bc=sc({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wc=sc({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_c=sc({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ec=sc({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Sc=sc({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ic=sc({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Oc=sc({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Pc=Object.freeze({__proto__:null,base32:mc,base32upper:vc,base32pad:bc,base32padupper:wc,base32hex:_c,base32hexupper:Ec,base32hexpad:Sc,base32hexpadupper:Ic,base32z:Oc});const Ac=ic({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Nc=ic({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xc=Object.freeze({__proto__:null,base36:Ac,base36upper:Nc});const Tc=ic({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Cc=ic({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var jc=Object.freeze({__proto__:null,base58btc:Tc,base58flickr:Cc});const Rc=sc({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Lc=sc({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),kc=sc({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Mc=sc({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Uc=Object.freeze({__proto__:null,base64:Rc,base64pad:Lc,base64url:kc,base64urlpad:Mc});const $c=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Dc=$c.reduce(((e,t,r)=>(e[r]=t,e)),[]),zc=$c.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const qc=nc({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Dc[t]),"")},decode:function(e){const t=[];for(const r of e){const e=zc[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});var Hc=Object.freeze({__proto__:null,base256emoji:qc}),Kc=function e(t,r,n){r=r||[];for(var i=n=n||0;t>=Fc;)r[n++]=255&t|Bc,t/=128;for(;t&Vc;)r[n++]=255&t|Bc,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Bc=128,Vc=-128,Fc=Math.pow(2,31);var Wc=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&Yc)<<s:(n&Yc)*Math.pow(2,s),s+=7}while(n>=Gc);return e.bytes=o-r,i},Gc=128,Yc=127;var Jc=Math.pow(2,7),Xc=Math.pow(2,14),Zc=Math.pow(2,21),Qc=Math.pow(2,28),eu=Math.pow(2,35),tu=Math.pow(2,42),ru=Math.pow(2,49),nu=Math.pow(2,56),iu=Math.pow(2,63),su={encode:Kc,decode:Wc,encodingLength:function(e){return e<Jc?1:e<Xc?2:e<Zc?3:e<Qc?4:e<eu?5:e<tu?6:e<ru?7:e<nu?8:e<iu?9:10}};const ou=(e,t,r=0)=>(su.encode(e,t,r),t),au=e=>su.encodingLength(e),cu=(e,t)=>{const r=t.byteLength,n=au(e),i=n+au(r),s=new Uint8Array(i+r);return ou(e,s,0),ou(r,s,n),s.set(t,i),new uu(e,r,t,s)};class uu{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const hu=({name:e,code:t,encode:r})=>new lu(e,t,r);class lu{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?cu(this.code,t):t.then((e=>cu(this.code,e)))}throw Error("Unknown type, must be binary type")}}const fu=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),pu=hu({name:"sha2-256",code:18,encode:fu("SHA-256")}),du=hu({name:"sha2-512",code:19,encode:fu("SHA-512")});Object.freeze({__proto__:null,sha256:pu,sha512:du});const gu=Xa,yu={code:0,name:"identity",encode:gu,digest:e=>cu(0,gu(e))};Object.freeze({__proto__:null,identity:yu});new TextEncoder,new TextDecoder;const mu={...ac,...uc,...lc,...pc,...yc,...Pc,...xc,...jc,...Uc,...Hc};function vu(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function bu(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const wu=bu("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),_u=bu("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?vu(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Eu={utf8:wu,"utf-8":wu,hex:mu.base16,latin1:_u,ascii:_u,binary:_u,...mu};const Su="core",Iu=`wc@2:${Su}:`,Ou="error",Pu={database:":memory:"},Au="client_ed25519_seed",Nu=ir.ONE_DAY,xu=ir.SIX_HOURS,Tu="wss://relay.walletconnect.com",Cu="wss://relay.walletconnect.org",ju="relayer_message",Ru="relayer_message_ack",Lu="relayer_connect",ku="relayer_disconnect",Mu="relayer_error",Uu="relayer_connection_stalled",$u="relayer_transport_closed",Du="relayer_publish",zu="payload",qu="connect",Hu="disconnect",Ku="error",Bu=ir.ONE_SECOND/2,Vu="subscription_created",Fu="subscription_deleted",Wu="subscription_sync",Gu="subscription_resubscribed",Yu=1e3*ir.FIVE_SECONDS,Ju={wc_pairingDelete:{req:{ttl:ir.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ir.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ir.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ir.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ir.ONE_DAY,prompt:!1,tag:0},res:{ttl:ir.ONE_DAY,prompt:!1,tag:0}}},Xu="history_created",Zu="history_updated",Qu="history_deleted",eh="history_sync",th="expirer_created",rh="expirer_deleted",nh="expirer_expired",ih="expirer_sync",sh="verify-api",oh="https://verify.walletconnect.com";class ah{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name="keychain",this.version="0.3",this.initialized=!1,this.storagePrefix=Iu,this.init=async()=>{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}},this.has=e=>(this.isInitialized(),this.keychain.has(e)),this.set=async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()},this.get=e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=Xn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t},this.del=async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()},this.core=e,this.logger=Cs.generateChildLogger(t,this.name)}get context(){return Cs.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Pn(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?An(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=Xn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class ch{constructor(e,t,r){this.core=e,this.logger=t,this.name="crypto",this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=e=>(this.isInitialized(),this.keychain.has(e)),this.getClientId=async()=>{this.isInitialized();return ha(la(await this.getClientSeed()).publicKey)},this.generateKeyPair=()=>{this.isInitialized();const e=function(){const e=me.generateKeyPair();return{privateKey:Bt(e.secretKey,Wr),publicKey:Bt(e.publicKey,Wr)}}();return this.setPrivateKey(e.publicKey,e.privateKey)},this.signJWT=async e=>{this.isInitialized();const t=la(await this.getClientSeed()),r=rn(),n=Nu;return await fa(r,e,n,t)},this.generateSharedKey=(e,t,r)=>{this.isInitialized();const n=function(e,t){const r=me.sharedKey(Kt(e,Wr),Kt(t,Wr));return Bt(new ce(ye.SHA256,r).expand(tn),Wr)}(this.getPrivateKey(e),t);return this.setSymKey(n,r)},this.setSymKey=async(e,t)=>{this.isInitialized();const r=t||function(e){return Bt(ye.hash(Kt(e,Wr)),Wr)}(e);return await this.keychain.set(r,e),r},this.deleteKeyPair=async e=>{this.isInitialized(),await this.keychain.del(e)},this.deleteSymKey=async e=>{this.isInitialized(),await this.keychain.del(e)},this.encode=async(e,t,r)=>{this.isInitialized();const n=cn(r),i=Jo(t);if(un(n)){const t=n.senderPublicKey,r=n.receiverPublicKey;e=await this.generateSharedKey(t,r)}const s=this.getSymKey(e),{type:o,senderPublicKey:a}=n;return on({type:o,symKey:s,message:i,senderPublicKey:a})},this.decode=async(e,t,r)=>{this.isInitialized();const n=function(e,t){const r=an(e);return cn({type:sn(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Bt(r.senderPublicKey,Wr):void 0,receiverPublicKey:t?.receiverPublicKey})}(t,r);if(un(n)){const t=n.receiverPublicKey,r=n.senderPublicKey;e=await this.generateSharedKey(t,r)}const i=function(e){const t=new A.ChaCha20Poly1305(Kt(e.symKey,Wr)),{sealed:r,iv:n}=an(e.encoded),i=t.open(n,r);if(null===i)throw new Error("Failed to decrypt");return Bt(i,Yr)}({symKey:this.getSymKey(e),encoded:t});return Yo(i)},this.getPayloadType=e=>sn(an(e).type),this.getPayloadSenderPublicKey=e=>{const t=an(e);return t.senderPublicKey?Bt(t.senderPublicKey,Wr):void 0},this.core=e,this.logger=Cs.generateChildLogger(t,this.name),this.keychain=r||new ah(this.core,this.logger)}get context(){return Cs.getLoggerContext(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Au)}catch{e=rn(),await this.keychain.set(Au,e)}return function(e,t="utf8"){const r=Eu[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode(`${r.prefix}${e}`):vu(globalThis.Buffer.from(e,"utf-8"))}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Xn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class uh extends Do{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name="messages",this.version="0.3",this.initialized=!1,this.storagePrefix=Iu,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}},this.set=async(e,t)=>{this.isInitialized();const r=nn(t);let n=this.messages.get(e);return typeof n>"u"&&(n={}),typeof n[r]<"u"||(n[r]=t,this.messages.set(e,n),await this.persist()),r},this.get=e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t},this.has=(e,t)=>{this.isInitialized();return typeof this.get(e)[nn(t)]<"u"},this.del=async e=>{this.isInitialized(),this.messages.delete(e),await this.persist()},this.logger=Cs.generateChildLogger(e,this.name),this.core=t}get context(){return Cs.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Pn(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?An(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=Xn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class hh extends zo{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.events=new e.EventEmitter,this.name="publisher",this.queue=new Map,this.publishTimeout=ir.toMiliseconds(ir.TEN_SECONDS),this.queueTimeout=ir.toMiliseconds(ir.FIVE_SECONDS),this.needsTransportRestart=!1,this.publish=async(e,t,r)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:r}});try{const n=r?.ttl||xu,i=Mn(r),s=r?.prompt||!1,o=r?.tag||0,a=r?.id||Pa().toString(),c={topic:e,message:t,opts:{ttl:n,relay:i,prompt:s,tag:o,id:a}},u=setTimeout((()=>this.queue.set(a,c)),this.queueTimeout);try{await await xn(this.rpcPublish(e,t,n,i,s,o,a),this.publishTimeout),clearTimeout(u),this.relayer.events.emit(Du,c)}catch{return this.logger.debug("Publishing Payload stalled"),void(this.needsTransportRestart=!0)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:r}})}catch(e){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(e),e}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.relayer=t,this.logger=Cs.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return Cs.getLoggerContext(this.logger)}rpcPublish(e,t,r,n,i,s,o){var a,c,u,h;const l={method:Un(n.protocol).publish,params:{topic:e,message:t,ttl:r,prompt:i,tag:s},id:o};return ti(null==(a=l.params)?void 0:a.prompt)&&(null==(c=l.params)||delete c.prompt),ti(null==(u=l.params)?void 0:u.tag)&&(null==(h=l.params)||delete h.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:l}),this.relayer.request(l)}onPublish(e){this.queue.delete(e)}checkQueue(){this.queue.forEach((async e=>{const{topic:t,message:r,opts:n}=e;await this.publish(t,r,n)}))}registerEventListeners(){this.relayer.core.heartbeat.on(ki.HEARTBEAT_EVENTS.pulse,(()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(Uu);this.checkQueue()})),this.relayer.on(Ru,(e=>{this.onPublish(e.id.toString())}))}}class lh{constructor(){this.map=new Map,this.set=(e,t)=>{const r=this.get(e);this.exists(e,t)||this.map.set(e,[...r,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const r=this.get(e);if(!this.exists(e,t))return;const n=r.filter((e=>e!==t));n.length?this.map.set(e,n):this.map.delete(e)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var fh=Object.defineProperty,ph=Object.defineProperties,dh=Object.getOwnPropertyDescriptors,gh=Object.getOwnPropertySymbols,yh=Object.prototype.hasOwnProperty,mh=Object.prototype.propertyIsEnumerable,vh=(e,t,r)=>t in e?fh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,bh=(e,t)=>{for(var r in t||(t={}))yh.call(t,r)&&vh(e,r,t[r]);if(gh)for(var r of gh(t))mh.call(t,r)&&vh(e,r,t[r]);return e},wh=(e,t)=>ph(e,dh(t));class _h extends Ko{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.subscriptions=new Map,this.topicMap=new lh,this.events=new e.EventEmitter,this.name="subscription",this.version="0.3",this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Iu,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const r=Mn(t),n={topic:e,relay:r};this.pending.set(e,n);const i=await this.rpcSubscribe(e,r);return this.onSubscribe(i,n),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}}),i}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}},this.unsubscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)},this.isSubscribed=async e=>!!this.topics.includes(e)||await new Promise(((t,r)=>{const n=new ir.Watch;n.start(this.pendingSubscriptionWatchLabel);const i=setInterval((()=>{!this.pending.has(e)&&this.topics.includes(e)&&(clearInterval(i),n.stop(this.pendingSubscriptionWatchLabel),t(!0)),n.elapsed(this.pendingSubscriptionWatchLabel)>=Yu&&(clearInterval(i),n.stop(this.pendingSubscriptionWatchLabel),r(new Error("Subscription resolution timeout")))}),this.pollingInterval)})).catch((()=>!1)),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=t,this.logger=Cs.generateChildLogger(r,this.name),this.clientId=""}get context(){return Cs.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let r=!1;try{r=this.getSubscription(e).topic===t}catch{}return r}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const r=this.topicMap.get(e);await Promise.all(r.map((async r=>await this.unsubscribeById(e,r,t))))}async unsubscribeById(e,t,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:r}});try{const n=Mn(r);await this.rpcUnsubscribe(e,t,n);const i=Zn("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,i),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:r}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t){const r={method:Un(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});try{await await xn(this.relayer.request(r),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Uu)}return nn(e+this.clientId)}async rpcBatchSubscribe(e){if(!e.length)return;const t={method:Un(e[0].relay.protocol).batchSubscribe,params:{topics:e.map((e=>e.topic))}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{return await await xn(this.relayer.request(t),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(Uu)}}rpcUnsubscribe(e,t,r){const n={method:Un(r.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,wh(bh({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach((e=>{this.setSubscription(e.id,bh({},e)),this.pending.delete(e.topic)}))}async onUnsubscribe(e,t,r){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,r),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t))}addSubscription(e,t){this.subscriptions.set(e,bh({},t)),this.topicMap.set(t.topic,e),this.events.emit(Vu,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:t}=Xn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const r=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(r.topic,e),this.events.emit(Fu,wh(bh({},r),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Wu)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t<e;t++){const e=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(e)}}this.events.emit(Gu)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=Xn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);Qn(t)&&this.onBatchSubscribe(t.map(((t,r)=>wh(bh({},e[r]),{id:t}))))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(this.relayer.transportExplicitlyClosed)return;const e=[];this.pending.forEach((t=>{e.push(t)})),await this.batchSubscribe(e)}registerEventListeners(){this.relayer.core.heartbeat.on(ki.HEARTBEAT_EVENTS.pulse,(async()=>{await this.checkPending()})),this.relayer.on(Lu,(async()=>{await this.onConnect()})),this.relayer.on(ku,(()=>{this.onDisconnect()})),this.events.on(Vu,(async e=>{const t=Vu;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})),this.events.on(Fu,(async e=>{const t=Fu;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=Xn("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){this.restartInProgress&&await new Promise((e=>{const t=setInterval((()=>{this.restartInProgress||(clearInterval(t),e())}),this.pollingInterval)}))}}var Eh=Object.defineProperty,Sh=Object.getOwnPropertySymbols,Ih=Object.prototype.hasOwnProperty,Oh=Object.prototype.propertyIsEnumerable,Ph=(e,t,r)=>t in e?Eh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;class Ah extends qo{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new e.EventEmitter,this.name="relayer",this.transportExplicitlyClosed=!1,this.initialized=!1,this.reconnecting=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.request=async e=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(e)}catch(e){throw this.logger.debug("Failed to Publish Request"),this.logger.error(e),e}},this.core=t.core,this.logger=typeof t.logger<"u"&&"string"!=typeof t.logger?Cs.generateChildLogger(t.logger,this.name):Cs.pino(Cs.getDefaultLoggerOptions({level:t.logger||"error"})),this.messages=new uh(this.logger,t.core),this.subscriber=new _h(this,this.logger),this.publisher=new hh(this,this.logger),this.relayUrl=t?.relayUrl||Tu,this.projectId=t.projectId,this.provider={}}async init(){this.logger.trace("Initialized"),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${Cu}...`),await this.restartTransport(Cu)}this.registerEventListeners(),this.initialized=!0,setTimeout((async()=>{0===this.subscriber.topics.length&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)}),1e4)}get context(){return Cs.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,t,r){this.isInitialized(),await this.publisher.publish(e,t,r),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now()})}async subscribe(e,t){var r;this.isInitialized();let n=(null==(r=this.subscriber.topicMap.get(e))?void 0:r[0])||"";return n||(await Promise.all([new Promise((t=>{this.subscriber.once(Vu,(r=>{r.topic===e&&t()}))})),new Promise((async r=>{n=await this.subscriber.subscribe(e,t),r()}))]),n)}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportClose(){this.transportExplicitlyClosed=!0,this.connected&&(await this.provider.disconnect(),this.events.emit($u))}async transportOpen(e){if(this.transportExplicitlyClosed=!1,!this.reconnecting){this.relayUrl=e||this.relayUrl,this.reconnecting=!0;try{await Promise.all([new Promise((e=>{this.initialized||e(),this.subscriber.once(Gu,(()=>{e()}))})),await Promise.race([new Promise((async(e,t)=>{await xn(this.provider.connect(),5e3,`Socket stalled when trying to connect to ${this.relayUrl}`).catch((e=>t(e))).then((()=>e())).finally((()=>this.removeListener($u,this.rejectTransportOpen)))})),new Promise((e=>this.once($u,this.rejectTransportOpen)))])])}catch(e){this.logger.error(e);const t=e;if(!this.isConnectionStalled(t.message))throw e;this.events.emit($u)}finally{this.reconnecting=!1}}}async restartTransport(e){this.transportExplicitlyClosed||this.reconnecting||(this.relayUrl=e||this.relayUrl,this.connected&&await Promise.all([new Promise((e=>{this.provider.once(Hu,(()=>{e()}))})),this.transportClose()]),await this.createProvider(),await this.transportOpen())}isConnectionStalled(e){return this.staleConnectionErrors.some((t=>e.includes(t)))}rejectTransportOpen(){throw new Error("Attempt to connect to relay via `transportOpen` has stalled. Retrying...")}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Ka(new Fa(In({sdkVersion:"2.9.0",protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:r}=e;await this.messages.set(t,r)}async shouldIgnoreMessageEvent(e){const{topic:t,message:r}=e;return!await this.subscriber.isSubscribed(t)||this.messages.has(t,r)}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Da(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:r,message:n,publishedAt:i}=t.data,s={topic:r,message:n,publishedAt:i};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(((e,t)=>{for(var r in t||(t={}))Ih.call(t,r)&&Ph(e,r,t[r]);if(Sh)for(var r of Sh(t))Oh.call(t,r)&&Ph(e,r,t[r]);return e})({type:"event",event:t.id},s)),this.events.emit(t.id,s),await this.acknowledgePayload(e),await this.onMessageEvent(s)}else za(e)&&this.events.emit(Ru,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(ju,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=Na(e.id,!0);await this.provider.connection.send(t)}registerProviderListeners(){this.provider.on(zu,(e=>this.onProviderPayload(e))),this.provider.on(qu,(()=>{this.events.emit(Lu)})),this.provider.on(Hu,(()=>{this.onProviderDisconnect()})),this.provider.on(Ku,(e=>{this.logger.error(e),this.events.emit(Mu,e)}))}registerEventListeners(){this.events.on(Uu,(async()=>{await this.restartTransport()}))}onProviderDisconnect(){this.events.emit(ku),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout((async()=>{await this.restartTransport()}),ir.toMiliseconds(Bu))}isInitialized(){if(!this.initialized){const{message:e}=Xn("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(!this.connected){if(this.connecting)return await new Promise((e=>{const t=setInterval((()=>{this.connected&&(clearInterval(t),e())}),this.connectionStatusPollingInterval)}));await this.restartTransport()}}}var Nh=Object.defineProperty,xh=Object.getOwnPropertySymbols,Th=Object.prototype.hasOwnProperty,Ch=Object.prototype.propertyIsEnumerable,jh=(e,t,r)=>t in e?Nh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Rh=(e,t)=>{for(var r in t||(t={}))Th.call(t,r)&&jh(e,r,t[r]);if(xh)for(var r of xh(t))Ch.call(t,r)&&jh(e,r,t[r]);return e};class Lh extends Ho{constructor(e,t,r,n=Iu,i=void 0){super(e,t,r,n),this.core=e,this.logger=t,this.name=r,this.map=new Map,this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Iu,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>{this.getKey&&null!==e&&!ti(e)?this.map.set(this.getKey(e),e):function(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}(e)?this.map.set(e.id,e):function(e){return e?.topic}(e)&&this.map.set(e.topic,e)})),this.cached=[],this.initialized=!0)},this.set=async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())},this.get=e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e)),this.getAll=e=>(this.isInitialized(),e?this.values.filter((t=>Object.keys(e).every((r=>Ga(t[r],e[r]))))):this.values),this.update=async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const r=Rh(Rh({},this.getData(e)),t);this.map.set(e,r),await this.persist()},this.delete=async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),await this.persist())},this.logger=Cs.generateChildLogger(t,this.name),this.storagePrefix=n,this.getKey=i}get context(){return Cs.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){const{message:t}=Xn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:e}=Xn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=Xn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class kh{constructor(e,t){this.core=e,this.logger=t,this.name="pairing",this.version="0.3",this.events=new y.default,this.initialized=!1,this.storagePrefix=Iu,this.ignoredPayloadTypes=[Xr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]},this.create=async()=>{this.isInitialized();const e=rn(),t=await this.core.crypto.setSymKey(e),r=jn(ir.FIVE_MINUTES),n={protocol:"irn"},i={topic:t,expiry:r,relay:n,active:!1},s=Vn({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:e,relay:n});return await this.pairings.set(t,i),await this.core.relayer.subscribe(t),this.core.expirer.set(t,r),{topic:t,uri:s}},this.pair=async e=>{this.isInitialized(),this.isValidPair(e);const{topic:t,symKey:r,relay:n}=function(e){const t=e.indexOf(":"),r=-1!==e.indexOf("?")?e.indexOf("?"):void 0,n=e.substring(0,t),i=e.substring(t+1,r).split("@"),s=typeof r<"u"?e.substring(r):"",o=Lr.parse(s);return{protocol:n,topic:Bn(i[0]),version:parseInt(i[1],10),symKey:o.symKey,relay:Kn(o)}}(e.uri);if(this.pairings.keys.includes(t))throw new Error(`Pairing already exists: ${t}`);if(this.core.crypto.hasKeys(t))throw new Error(`Keychain already exists: ${t}`);const i=jn(ir.FIVE_MINUTES),s={topic:t,relay:n,expiry:i,active:!1};return await this.pairings.set(t,s),await this.core.crypto.setSymKey(r,t),await this.core.relayer.subscribe(t,{relay:n}),this.core.expirer.set(t,i),e.activatePairing&&await this.activate({topic:t}),s},this.activate=async({topic:e})=>{this.isInitialized();const t=jn(ir.THIRTY_DAYS);await this.pairings.update(e,{active:!0,expiry:t}),this.core.expirer.set(e,t)},this.ping=async e=>{this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:r,resolve:n,reject:i}=Nn();this.events.once(Ln("pairing_ping",e),(({error:e})=>{e?i(e):n()})),await r()}},this.updateExpiry=async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})},this.updateMetadata=async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",Zn("USER_DISCONNECTED")),await this.deletePairing(t))},this.sendRequest=async(e,t,r)=>{const n=Aa(t,r),i=await this.core.crypto.encode(e,n),s=Ju[t].req;return this.core.history.set(e,n),this.core.relayer.publish(e,i,s),n.id},this.sendResult=async(e,t,r)=>{const n=Na(e,r),i=await this.core.crypto.encode(t,n),s=await this.core.history.get(t,e),o=Ju[s.request.method].res;await this.core.relayer.publish(t,i,o),await this.core.history.resolve(n)},this.sendError=async(e,t,r)=>{const n=xa(e,r),i=await this.core.crypto.encode(t,n),s=await this.core.history.get(t,e),o=Ju[s.request.method]?Ju[s.request.method].res:Ju.unregistered_method.res;await this.core.relayer.publish(t,i,o),await this.core.history.resolve(n)},this.deletePairing=async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,Zn("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])},this.cleanup=async()=>{const e=this.pairings.getAll().filter((e=>Rn(e.expiry)));await Promise.all(e.map((e=>this.deletePairing(e.topic))))},this.onRelayEventRequest=e=>{const{topic:t,payload:r}=e,n=r.method;if(this.pairings.keys.includes(t))switch(n){case"wc_pairingPing":return this.onPairingPingRequest(t,r);case"wc_pairingDelete":return this.onPairingDeleteRequest(t,r);default:return this.onUnknownRpcMethodRequest(t,r)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:r}=e,n=(await this.core.history.get(t,r.id)).request.method;if(this.pairings.keys.includes(t)){if("wc_pairingPing"===n)return this.onPairingPingResponse(t,r);return this.onUnknownRpcMethodResponse(n)}},this.onPairingPingRequest=async(e,t)=>{const{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult(r,e,!0),this.events.emit("pairing_ping",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}},this.onPairingPingResponse=(e,t)=>{const{id:r}=t;setTimeout((()=>{qa(t)?this.events.emit(Ln("pairing_ping",r),{}):Ha(t)&&this.events.emit(Ln("pairing_ping",r),{error:t.error})}),500)},this.onPairingDeleteRequest=async(e,t)=>{const{id:r}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit("pairing_delete",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}},this.onUnknownRpcMethodRequest=async(e,t)=>{const{id:r,method:n}=t;try{if(this.registeredMethods.includes(n))return;const t=Zn("WC_METHOD_UNSUPPORTED",n);await this.sendError(r,e,t),this.logger.error(t)}catch(t){await this.sendError(r,e,t),this.logger.error(t)}},this.onUnknownRpcMethodResponse=e=>{this.registeredMethods.includes(e)||this.logger.error(Zn("WC_METHOD_UNSUPPORTED",e))},this.isValidPair=e=>{if(!li(e)){const{message:t}=Xn("MISSING_OR_INVALID",`pair() params: ${e}`);throw new Error(t)}if(!function(e){if(ri(e,!1))try{return typeof new URL(e)<"u"}catch{return!1}return!1}(e.uri)){const{message:t}=Xn("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw new Error(t)}},this.isValidPing=async e=>{if(!li(e)){const{message:t}=Xn("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidDisconnect=async e=>{if(!li(e)){const{message:t}=Xn("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidPairingTopic=async e=>{if(!ri(e,!1)){const{message:t}=Xn("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=Xn("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Rn(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=Xn("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}},this.core=e,this.logger=Cs.generateChildLogger(t,this.name),this.pairings=new Lh(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Cs.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Xn("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(ju,(async e=>{const{topic:t,message:r}=e;if(this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))return;const n=await this.core.crypto.decode(t,r);Da(n)?(this.core.history.set(t,n),this.onRelayEventRequest({topic:t,payload:n})):za(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:t,payload:n}),this.core.history.delete(t,n.id))}))}registerExpirerEvents(){this.core.expirer.on(nh,(async e=>{const{topic:t}=Cn(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit("pairing_expire",{topic:t}))}))}}class Mh extends $o{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.records=new Map,this.events=new e.EventEmitter,this.name="history",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Iu,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.records.set(e.id,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(e,t,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:r}),this.records.has(t.id))return;const n={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:r,expiry:jn(ir.THIRTY_DAYS)};this.records.set(n.id,n),this.events.emit(Xu,n)},this.resolve=async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=Ha(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.events.emit(Zu,t))},this.get=async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t)),this.delete=(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach((r=>{if(r.topic===e){if(typeof t<"u"&&r.id!==t)return;this.records.delete(r.id),this.events.emit(Qu,r)}}))},this.exists=async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=Cs.generateChildLogger(r,this.name)}get context(){return Cs.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach((t=>{if(typeof t.response<"u")return;const r={topic:t.topic,request:Aa(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(r)})),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:t}=Xn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(eh)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=Xn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Xu,(e=>{const t=Xu;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(Zu,(e=>{const t=Zu;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(Qu,(e=>{const t=Qu;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.core.heartbeat.on(ki.HEARTBEAT_EVENTS.pulse,(()=>{this.cleanup()}))}cleanup(){try{this.records.forEach((e=>{ir.toMiliseconds(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.delete(e.topic,e.id))}))}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=Xn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Uh extends Bo{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.expirations=new Map,this.events=new e.EventEmitter,this.name="expirer",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Iu,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.expirations.set(e.target,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}},this.set=(e,t)=>{this.isInitialized();const r=this.formatTarget(e),n={target:r,expiry:t};this.expirations.set(r,n),this.checkExpiry(r,n),this.events.emit(th,{target:r,expiration:n})},this.get=e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)},this.del=e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),r=this.getExpiration(t);this.expirations.delete(t),this.events.emit(rh,{target:t,expiration:r})}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=Cs.generateChildLogger(r,this.name)}get context(){return Cs.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return function(e){return Tn("topic",e)}(e);if("number"==typeof e)return function(e){return Tn("id",e)}(e);const{message:t}=Xn("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(ih)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=Xn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=Xn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:r}=t;ir.toMiliseconds(r)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(nh,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach(((e,t)=>this.checkExpiry(t,e)))}registerEventListeners(){this.core.heartbeat.on(ki.HEARTBEAT_EVENTS.pulse,(()=>this.checkExpirations())),this.events.on(th,(e=>{const t=th;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(nh,(e=>{const t=nh;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(rh,(e=>{const t=rh;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=Xn("NOT_INITIALIZED",this.name);throw new Error(e)}}}class $h extends Vo{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.name=sh,this.initialized=!1,this.init=async e=>{wn()||!_n()||(this.verifyUrl=e?.verifyUrl||oh,await this.createIframe())},this.register=async e=>{var t;if(this.initialized||await this.init(),this.iframe)try{null==(t=this.iframe.contentWindow)||t.postMessage(e.attestationId,this.verifyUrl),this.logger.info(`postMessage sent: ${e.attestationId} ${this.verifyUrl}`)}catch{}},this.resolve=async e=>{var t;if(this.isDevEnv)return"";this.logger.info(`resolving attestation: ${e.attestationId}`);const r=this.startAbortTimer(ir.FIVE_SECONDS),n=await fetch(`${this.verifyUrl}/attestation/${e.attestationId}`,{signal:this.abortController.signal});return clearTimeout(r),200===n.status?null==(t=await n.json())?void 0:t.origin:""},this.createIframe=async()=>{try{await Promise.race([new Promise(((e,t)=>{if(document.getElementById(sh))return e();const r=document.createElement("iframe");r.setAttribute("id",sh),r.setAttribute("src",`${this.verifyUrl}/${this.projectId}`),r.style.display="none",r.addEventListener("load",(()=>{this.initialized=!0,e()})),r.addEventListener("error",(e=>{t(e)})),document.body.append(r),this.iframe=r})),new Promise((e=>{setTimeout((()=>e("iframe load timeout")),ir.toMiliseconds(ir.ONE_SECOND/2))}))])}catch(e){this.logger.error(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.error(e)}},this.logger=Cs.generateChildLogger(t,this.name),this.verifyUrl=oh,this.abortController=new AbortController,this.isDevEnv=bn()&&process.env.IS_VITEST}get context(){return Cs.getLoggerContext(this.logger)}startAbortTimer(e){return setTimeout((()=>this.abortController.abort()),ir.toMiliseconds(e))}}var Dh=Object.defineProperty,zh=Object.getOwnPropertySymbols,qh=Object.prototype.hasOwnProperty,Hh=Object.prototype.propertyIsEnumerable,Kh=(e,t,r)=>t in e?Dh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Bh=(e,t)=>{for(var r in t||(t={}))qh.call(t,r)&&Kh(e,r,t[r]);if(zh)for(var r of zh(t))Hh.call(t,r)&&Kh(e,r,t[r]);return e};class Vh extends Uo{constructor(t){super(t),this.protocol="wc",this.version=2,this.name=Su,this.events=new e.EventEmitter,this.initialized=!1,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.projectId=t?.projectId,this.relayUrl=t?.relayUrl||Tu;const r=typeof t?.logger<"u"&&"string"!=typeof t?.logger?t.logger:Cs.pino(Cs.getDefaultLoggerOptions({level:t?.logger||Ou}));this.logger=Cs.generateChildLogger(r,this.name),this.heartbeat=new ki.HeartBeat,this.crypto=new ch(this,this.logger,t?.keychain),this.history=new Mh(this,this.logger),this.expirer=new Uh(this,this.logger),this.storage=null!=t&&t.storage?t.storage:new Li(Bh(Bh({},Pu),t?.storageOptions)),this.relayer=new Ah({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new kh(this,this.logger),this.verify=new $h(this.projectId||"",this.logger)}static async init(e){const t=new Vh(e);await t.initialize();const r=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",r),t}get context(){return Cs.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const Fh=Vh,Wh="client",Gh=`wc@2:${Wh}:`,Yh=Wh,Jh="error",Xh="Proposal expired",Zh=ir.SEVEN_DAYS,Qh={wc_sessionPropose:{req:{ttl:ir.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:ir.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:ir.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:ir.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:ir.ONE_DAY,prompt:!1,tag:1104},res:{ttl:ir.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:ir.ONE_DAY,prompt:!1,tag:1106},res:{ttl:ir.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:ir.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:ir.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:ir.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:ir.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:ir.ONE_DAY,prompt:!1,tag:1112},res:{ttl:ir.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:ir.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:ir.THIRTY_SECONDS,prompt:!1,tag:1115}}},el={min:ir.FIVE_MINUTES,max:ir.SEVEN_DAYS},tl=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var rl=Object.defineProperty,nl=Object.defineProperties,il=Object.getOwnPropertyDescriptors,sl=Object.getOwnPropertySymbols,ol=Object.prototype.hasOwnProperty,al=Object.prototype.propertyIsEnumerable,cl=(e,t,r)=>t in e?rl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ul=(e,t)=>{for(var r in t||(t={}))ol.call(t,r)&&cl(e,r,t[r]);if(sl)for(var r of sl(t))al.call(t,r)&&cl(e,r,t[r]);return e},hl=(e,t)=>nl(e,il(t));class ll extends Wo{constructor(e){super(e),this.name="engine",this.events=new y.default,this.initialized=!1,this.ignoredPayloadTypes=[Xr],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(Qh)}),this.initialized=!0)},this.connect=async e=>{this.isInitialized();const t=hl(ul({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:r,requiredNamespaces:n,optionalNamespaces:i,sessionProperties:s,relays:o}=t;let a,c=r,u=!1;if(c&&(u=this.client.core.pairing.pairings.get(c).active),!c||!u){const{topic:e,uri:t}=await this.client.core.pairing.create();c=e,a=t}const h=await this.client.core.crypto.generateKeyPair(),l=ul({requiredNamespaces:n,optionalNamespaces:i,relays:o??[{protocol:"irn"}],proposer:{publicKey:h,metadata:this.client.metadata}},s&&{sessionProperties:s}),{reject:f,resolve:p,done:d}=Nn(ir.FIVE_MINUTES,Xh);if(this.events.once(Ln("session_connect"),(async({error:e,session:t})=>{if(e)f(e);else if(t){t.self.publicKey=h;const e=hl(ul({},t),{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces});await this.client.session.set(t.topic,e),await this.setExpiry(t.topic,t.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:t.peer.metadata}),p(e)}})),!c){const{message:e}=Xn("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(e)}const g=await this.sendRequest(c,"wc_sessionPropose",l),y=jn(ir.FIVE_MINUTES);return await this.setProposal(g,ul({id:g,expiry:y},l)),{uri:a,approval:d}},this.pair=async e=>(this.isInitialized(),await this.client.core.pairing.pair(e)),this.approve=async e=>{this.isInitialized(),await this.isValidApprove(e);const{id:t,relayProtocol:r,namespaces:n,sessionProperties:i}=e,s=this.client.proposal.get(t);let{pairingTopic:o,proposer:a,requiredNamespaces:c,optionalNamespaces:u}=s;o=o||"",ei(c)||(c=function(e,t){const r=ui(e,t);if(r)throw new Error(r.message);const n={};for(const[t,r]of Object.entries(e))n[t]={methods:r.methods,events:r.events,chains:r.accounts.map((e=>`${e.split(":")[0]}:${e.split(":")[1]}`))};return n}(n,"approve()"));const h=await this.client.core.crypto.generateKeyPair(),l=a.publicKey,f=await this.client.core.crypto.generateSharedKey(h,l);o&&t&&(await this.client.core.pairing.updateMetadata({topic:o,metadata:a.metadata}),await this.sendResult(t,o,{relay:{protocol:r??"irn"},responderPublicKey:h}),await this.client.proposal.delete(t,Zn("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:o}));const p=ul({relay:{protocol:r??"irn"},namespaces:n,requiredNamespaces:c,optionalNamespaces:u,pairingTopic:o,controller:{publicKey:h,metadata:this.client.metadata},expiry:jn(Zh)},i&&{sessionProperties:i});await this.client.core.relayer.subscribe(f),await this.sendRequest(f,"wc_sessionSettle",p);const d=hl(ul({},p),{topic:f,pairingTopic:o,acknowledged:!1,self:p.controller,peer:{publicKey:a.publicKey,metadata:a.metadata},controller:h});return await this.client.session.set(f,d),await this.setExpiry(f,jn(Zh)),{topic:f,acknowledged:()=>new Promise((e=>setTimeout((()=>e(this.client.session.get(f))),500)))}},this.reject=async e=>{this.isInitialized(),await this.isValidReject(e);const{id:t,reason:r}=e,{pairingTopic:n}=this.client.proposal.get(t);n&&(await this.sendError(t,n,r),await this.client.proposal.delete(t,Zn("USER_DISCONNECTED")))},this.update=async e=>{this.isInitialized(),await this.isValidUpdate(e);const{topic:t,namespaces:r}=e,n=await this.sendRequest(t,"wc_sessionUpdate",{namespaces:r}),{done:i,resolve:s,reject:o}=Nn();return this.events.once(Ln("session_update",n),(({error:e})=>{e?o(e):s()})),await this.client.session.update(t,{namespaces:r}),{acknowledged:i}},this.extend=async e=>{this.isInitialized(),await this.isValidExtend(e);const{topic:t}=e,r=await this.sendRequest(t,"wc_sessionExtend",{}),{done:n,resolve:i,reject:s}=Nn();return this.events.once(Ln("session_extend",r),(({error:e})=>{e?s(e):i()})),await this.setExpiry(t,jn(Zh)),{acknowledged:n}},this.request=async e=>{this.isInitialized(),await this.isValidRequest(e);const{chainId:t,request:r,topic:n,expiry:i}=e,s=await this.sendRequest(n,"wc_sessionRequest",{request:r,chainId:t},i),{done:o,resolve:a,reject:c}=Nn(i);this.events.once(Ln("session_request",s),(({error:e,result:t})=>{e?c(e):a(t)})),this.client.events.emit("session_request_sent",{topic:n,request:r,chainId:t,id:s});return async function({id:e,topic:t,wcDeepLink:r}){try{if(!r)return;const n="string"==typeof r?JSON.parse(r):r;let i=n?.href;if("string"!=typeof i)return;i.endsWith("/")&&(i=i.slice(0,-1));const s=`${i}/wc?requestId=${e}&sessionTopic=${t}`,o=En();o===mn.browser?s.startsWith("https://")?window.open(s,"_blank","noreferrer noopener"):window.open(s,"_self","noreferrer noopener"):o===mn.reactNative&&typeof(null==global?void 0:global.Linking)<"u"&&await global.Linking.openURL(s)}catch(e){console.error(e)}}({id:s,topic:n,wcDeepLink:await this.client.core.storage.getItem("WALLETCONNECT_DEEPLINK_CHOICE")}),await o()},this.respond=async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:r}=e,{id:n}=r;qa(r)?await this.sendResult(n,t,r.result):Ha(r)&&await this.sendError(n,t,r.error),this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0})},this.ping=async e=>{this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=await this.sendRequest(t,"wc_sessionPing",{}),{done:r,resolve:n,reject:i}=Nn();this.events.once(Ln("session_ping",e),(({error:e})=>{e?i(e):n()})),await r()}else this.client.core.pairing.pairings.keys.includes(t)&&await this.client.core.pairing.ping({topic:t})},this.emit=async e=>{this.isInitialized(),await this.isValidEmit(e);const{topic:t,event:r,chainId:n}=e;await this.sendRequest(t,"wc_sessionEvent",{event:r,chainId:n})},this.disconnect=async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=Pa().toString();let r;const n=t=>{t?.id.toString()===e&&(this.client.core.relayer.events.removeListener(Ru,n),r())};await Promise.all([new Promise((e=>{r=e,this.client.core.relayer.on(Ru,n)})),this.sendRequest(t,"wc_sessionDelete",Zn("USER_DISCONNECTED"),void 0,e)]),await this.deleteSession(t)}else await this.client.core.pairing.disconnect({topic:t})},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter((t=>function(e,t){const{requiredNamespaces:r}=t,n=Object.keys(e.namespaces),i=Object.keys(r);let s=!0;return!!On(i,n)&&(n.forEach((t=>{const{accounts:n,methods:i,events:o}=e.namespaces[t],a=Fn(n),c=r[t];On(Vr(t,c),a)&&On(c.methods,i)&&On(c.events,o)||(s=!1)})),s)}(t,e)))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),r=this.client.core.pairing.pairings.getAll().filter((r=>{var n,i;return(null==(n=r.peerMetadata)?void 0:n.url)&&(null==(i=r.peerMetadata)?void 0:i.url)===e.peer.metadata.url&&r.topic&&r.topic!==t.topic}));if(0===r.length)return;this.client.logger.info(`Cleaning up ${r.length} duplicate pairing(s)`),await Promise.all(r.map((e=>this.client.core.pairing.disconnect({topic:e.topic})))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}},this.deleteSession=async(e,t)=>{const{self:r}=this.client.session.get(e);await this.client.core.relayer.unsubscribe(e),this.client.session.delete(e,Zn("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(r.publicKey)&&await this.client.core.crypto.deleteKeyPair(r.publicKey),this.client.core.crypto.keychain.has(e)&&await this.client.core.crypto.deleteSymKey(e),t||this.client.core.expirer.del(e)},this.deleteProposal=async(e,t)=>{await Promise.all([this.client.proposal.delete(e,Zn("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)])},this.deletePendingSessionRequest=async(e,t,r=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),r?Promise.resolve():this.client.core.expirer.del(e)])},this.setExpiry=async(e,t)=>{this.client.session.keys.includes(e)&&await this.client.session.update(e,{expiry:t}),this.client.core.expirer.set(e,t)},this.setProposal=async(e,t)=>{await this.client.proposal.set(e,t),this.client.core.expirer.set(e,t.expiry)},this.setPendingSessionRequest=async e=>{const t=Qh.wc_sessionRequest.req.ttl,{id:r,topic:n,params:i}=e;await this.client.pendingRequest.set(r,{id:r,topic:n,params:i}),t&&this.client.core.expirer.set(r,jn(t))},this.sendRequest=async(e,t,r,n,i)=>{const s=Aa(t,r);if(_n()&&tl.includes(t)){const e=nn(JSON.stringify(s));await this.client.core.verify.register({attestationId:e})}const o=await this.client.core.crypto.encode(e,s),a=Qh[t].req;return n&&(a.ttl=n),i&&(a.id=i),this.client.core.history.set(e,s),this.client.core.relayer.publish(e,o,a),s.id},this.sendResult=async(e,t,r)=>{const n=Na(e,r),i=await this.client.core.crypto.encode(t,n),s=await this.client.core.history.get(t,e),o=Qh[s.request.method].res;this.client.core.relayer.publish(t,i,o),await this.client.core.history.resolve(n)},this.sendError=async(e,t,r)=>{const n=xa(e,r),i=await this.client.core.crypto.encode(t,n),s=await this.client.core.history.get(t,e),o=Qh[s.request.method].res;this.client.core.relayer.publish(t,i,o),await this.client.core.history.resolve(n)},this.cleanup=async()=>{const e=[],t=[];this.client.session.getAll().forEach((t=>{Rn(t.expiry)&&e.push(t.topic)})),this.client.proposal.getAll().forEach((e=>{Rn(e.expiry)&&t.push(e.id)})),await Promise.all([...e.map((e=>this.deleteSession(e))),...t.map((e=>this.deleteProposal(e)))])},this.onRelayEventRequest=e=>{const{topic:t,payload:r}=e,n=r.method;switch(n){case"wc_sessionPropose":return this.onSessionProposeRequest(t,r);case"wc_sessionSettle":return this.onSessionSettleRequest(t,r);case"wc_sessionUpdate":return this.onSessionUpdateRequest(t,r);case"wc_sessionExtend":return this.onSessionExtendRequest(t,r);case"wc_sessionPing":return this.onSessionPingRequest(t,r);case"wc_sessionDelete":return this.onSessionDeleteRequest(t,r);case"wc_sessionRequest":return this.onSessionRequest(t,r);case"wc_sessionEvent":return this.onSessionEventRequest(t,r);default:return this.client.logger.info(`Unsupported request method ${n}`)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:r}=e,n=(await this.client.core.history.get(t,r.id)).request.method;switch(n){case"wc_sessionPropose":return this.onSessionProposeResponse(t,r);case"wc_sessionSettle":return this.onSessionSettleResponse(t,r);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,r);case"wc_sessionExtend":return this.onSessionExtendResponse(t,r);case"wc_sessionPing":return this.onSessionPingResponse(t,r);case"wc_sessionRequest":return this.onSessionRequestResponse(t,r);default:return this.client.logger.info(`Unsupported response method ${n}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:t}=e,{message:r}=Xn("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(r)},this.onSessionProposeRequest=async(e,t)=>{const{params:r,id:n}=t;try{this.isValidConnect(ul({},t.params));const i=jn(ir.FIVE_MINUTES),s=ul({id:n,pairingTopic:e,expiry:i},r);await this.setProposal(n,s);const o=nn(JSON.stringify(t)),a=await this.getVerifyContext(o,s.proposer.metadata);this.client.events.emit("session_proposal",{id:n,params:s,verifyContext:a})}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionProposeResponse=async(e,t)=>{const{id:r}=t;if(qa(t)){const{result:n}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:n});const i=this.client.proposal.get(r);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:i});const s=i.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:s});const o=n.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:o});const a=await this.client.core.crypto.generateSharedKey(s,o);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:a});const c=await this.client.core.relayer.subscribe(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:c}),await this.client.core.pairing.activate({topic:e})}else Ha(t)&&(await this.client.proposal.delete(r,Zn("USER_DISCONNECTED")),this.events.emit(Ln("session_connect"),{error:t.error}))},this.onSessionSettleRequest=async(e,t)=>{const{id:r,params:n}=t;try{this.isValidSessionSettleRequest(n);const{relay:r,controller:i,expiry:s,namespaces:o,requiredNamespaces:a,optionalNamespaces:c,sessionProperties:u,pairingTopic:h}=t.params,l=ul({topic:e,relay:r,expiry:s,namespaces:o,acknowledged:!0,pairingTopic:h,requiredNamespaces:a,optionalNamespaces:c,controller:i.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:i.publicKey,metadata:i.metadata}},u&&{sessionProperties:u});await this.sendResult(t.id,e,!0),this.events.emit(Ln("session_connect"),{session:l}),this.cleanupDuplicatePairings(l)}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionSettleResponse=async(e,t)=>{const{id:r}=t;qa(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(Ln("session_approve",r),{})):Ha(t)&&(await this.client.session.delete(e,Zn("USER_DISCONNECTED")),this.events.emit(Ln("session_approve",r),{error:t.error}))},this.onSessionUpdateRequest=async(e,t)=>{const{params:r,id:n}=t;try{this.isValidUpdate(ul({topic:e},r)),await this.client.session.update(e,{namespaces:r.namespaces}),await this.sendResult(n,e,!0),this.client.events.emit("session_update",{id:n,topic:e,params:r})}catch(t){await this.sendError(n,e,t),this.client.logger.error(t)}},this.onSessionUpdateResponse=(e,t)=>{const{id:r}=t;qa(t)?this.events.emit(Ln("session_update",r),{}):Ha(t)&&this.events.emit(Ln("session_update",r),{error:t.error})},this.onSessionExtendRequest=async(e,t)=>{const{id:r}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,jn(Zh)),await this.sendResult(r,e,!0),this.client.events.emit("session_extend",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionExtendResponse=(e,t)=>{const{id:r}=t;qa(t)?this.events.emit(Ln("session_extend",r),{}):Ha(t)&&this.events.emit(Ln("session_extend",r),{error:t.error})},this.onSessionPingRequest=async(e,t)=>{const{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult(r,e,!0),this.client.events.emit("session_ping",{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionPingResponse=(e,t)=>{const{id:r}=t;setTimeout((()=>{qa(t)?this.events.emit(Ln("session_ping",r),{}):Ha(t)&&this.events.emit(Ln("session_ping",r),{error:t.error})}),500)},this.onSessionDeleteRequest=async(e,t)=>{const{id:r}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),await Promise.all([new Promise((t=>{this.client.core.relayer.once(Du,(async()=>{t(await this.deleteSession(e))}))})),this.sendResult(r,e,!0)]),this.client.events.emit("session_delete",{id:r,topic:e})}catch(e){this.client.logger.error(e)}},this.onSessionRequest=async(e,t)=>{const{id:r,params:n}=t;try{this.isValidRequest(ul({topic:e},n)),await this.setPendingSessionRequest({id:r,topic:e,params:n});const i=nn(JSON.stringify(t)),s=this.client.session.get(e),o=await this.getVerifyContext(i,s.peer.metadata);this.client.events.emit("session_request",{id:r,topic:e,params:n,verifyContext:o})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.onSessionRequestResponse=(e,t)=>{const{id:r}=t;qa(t)?this.events.emit(Ln("session_request",r),{result:t.result}):Ha(t)&&this.events.emit(Ln("session_request",r),{error:t.error})},this.onSessionEventRequest=async(e,t)=>{const{id:r,params:n}=t;try{this.isValidEmit(ul({topic:e},n)),this.client.events.emit("session_event",{id:r,topic:e,params:n})}catch(t){await this.sendError(r,e,t),this.client.logger.error(t)}},this.isValidConnect=async e=>{if(!li(e)){const{message:t}=Xn("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:i,relays:s}=e;if(ti(t)||await this.isValidPairingTopic(t),!function(e,t){let r=!1;return t&&!e?r=!0:e&&Qn(e)&&e.length&&e.forEach((e=>{r=hi(e)})),r}(s,!0)){const{message:e}=Xn("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(e)}!ti(r)&&0!==ei(r)&&this.validateNamespaces(r,"requiredNamespaces"),!ti(n)&&0!==ei(n)&&this.validateNamespaces(n,"optionalNamespaces"),ti(i)||this.validateSessionProps(i,"sessionProperties")},this.validateNamespaces=(e,t)=>{const r=function(e,t,r){let n=null;if(e&&ei(e)){const i=ci(e,t);i&&(n=i);const s=oi(e,t,r);s&&(n=s)}else n=Xn("MISSING_OR_INVALID",`${t}, ${r} should be an object with data`);return n}(e,"connect()",t);if(r)throw new Error(r.message)},this.isValidApprove=async e=>{if(!li(e))throw new Error(Xn("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:r,relayProtocol:n,sessionProperties:i}=e;await this.isValidProposalId(t);const s=this.client.proposal.get(t),o=ui(r,"approve()");if(o)throw new Error(o.message);const a=gi(s.requiredNamespaces,r,"approve()");if(a)throw new Error(a.message);if(!ri(n,!0)){const{message:e}=Xn("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(e)}ti(i)||this.validateSessionProps(i,"sessionProperties")},this.isValidReject=async e=>{if(!li(e)){const{message:t}=Xn("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:r}=e;if(await this.isValidProposalId(t),!function(e){return!!(e&&"object"==typeof e&&e.code&&ni(e.code,!1)&&e.message&&ri(e.message,!1))}(r)){const{message:e}=Xn("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidSessionSettleRequest=e=>{if(!li(e)){const{message:t}=Xn("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:r,namespaces:n,expiry:i}=e;if(!hi(t)){const{message:e}=Xn("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const s=function(e,t){let r=null;return ri(e?.publicKey,!1)||(r=Xn("MISSING_OR_INVALID",`${t} controller public key should be a string`)),r}(r,"onSessionSettleRequest()");if(s)throw new Error(s.message);const o=ui(n,"onSessionSettleRequest()");if(o)throw new Error(o.message);if(Rn(i)){const{message:e}=Xn("EXPIRED","onSessionSettleRequest()");throw new Error(e)}},this.isValidUpdate=async e=>{if(!li(e)){const{message:t}=Xn("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:r}=e;await this.isValidSessionTopic(t);const n=this.client.session.get(t),i=ui(r,"update()");if(i)throw new Error(i.message);const s=gi(n.requiredNamespaces,r,"update()");if(s)throw new Error(s.message)},this.isValidExtend=async e=>{if(!li(e)){const{message:t}=Xn("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionTopic(t)},this.isValidRequest=async e=>{if(!li(e)){const{message:t}=Xn("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:r,chainId:n,expiry:i}=e;await this.isValidSessionTopic(t);const{namespaces:s}=this.client.session.get(t);if(!fi(s,n)){const{message:e}=Xn("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(e)}if(!function(e){return!(ti(e)||!ri(e.method,!1))}(r)){const{message:e}=Xn("MISSING_OR_INVALID",`request() ${JSON.stringify(r)}`);throw new Error(e)}if(!pi(s,n,r.method)){const{message:e}=Xn("MISSING_OR_INVALID",`request() method: ${r.method}`);throw new Error(e)}if(i&&!function(e,t){return ni(e,!1)&&e<=t.max&&e>=t.min}(i,el)){const{message:e}=Xn("MISSING_OR_INVALID",`request() expiry: ${i}. Expiry must be a number (in seconds) between ${el.min} and ${el.max}`);throw new Error(e)}},this.isValidRespond=async e=>{if(!li(e)){const{message:t}=Xn("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:t,response:r}=e;if(await this.isValidSessionTopic(t),!function(e){return!(ti(e)||ti(e.result)&&ti(e.error)||!ni(e.id,!1)||!ri(e.jsonrpc,!1))}(r)){const{message:e}=Xn("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidPing=async e=>{if(!li(e)){const{message:t}=Xn("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.isValidEmit=async e=>{if(!li(e)){const{message:t}=Xn("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:r,chainId:n}=e;await this.isValidSessionTopic(t);const{namespaces:i}=this.client.session.get(t);if(!fi(i,n)){const{message:e}=Xn("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(e)}if(!function(e){return!(ti(e)||!ri(e.name,!1))}(r)){const{message:e}=Xn("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(e)}if(!di(i,n,r.name)){const{message:e}=Xn("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(e)}},this.isValidDisconnect=async e=>{if(!li(e)){const{message:t}=Xn("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.getVerifyContext=async(e,t)=>{const r={verified:{verifyUrl:t.verifyUrl||"",validation:"UNKNOWN",origin:t.url||""}};try{const n=await this.client.core.verify.resolve({attestationId:e,verifyUrl:t.verifyUrl});n&&(r.verified.origin=n,r.verified.validation=n===t.url?"VALID":"INVALID")}catch(e){this.client.logger.error(e)}return this.client.logger.info(`Verify context: ${JSON.stringify(r)}`),r},this.validateSessionProps=(e,t)=>{Object.values(e).forEach((e=>{if(!ri(e,!1)){const{message:r}=Xn("MISSING_OR_INVALID",`${t} must be in Record<string, string> format. Received: ${JSON.stringify(e)}`);throw new Error(r)}}))}}isInitialized(){if(!this.initialized){const{message:e}=Xn("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(ju,(async e=>{const{topic:t,message:r}=e;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(r)))return;const n=await this.client.core.crypto.decode(t,r);Da(n)?(this.client.core.history.set(t,n),this.onRelayEventRequest({topic:t,payload:n})):za(n)?(await this.client.core.history.resolve(n),await this.onRelayEventResponse({topic:t,payload:n}),this.client.core.history.delete(t,n.id)):this.onRelayEventUnknownPayload({topic:t,payload:n})}))}registerExpirerEvents(){this.client.core.expirer.on(nh,(async e=>{const{topic:t,id:r}=Cn(e.target);if(r&&this.client.pendingRequest.keys.includes(r))return await this.deletePendingSessionRequest(r,Xn("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession(t,!0),this.client.events.emit("session_expire",{topic:t})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r}))}))}isValidPairingTopic(e){if(!ri(e,!1)){const{message:t}=Xn("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=Xn("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Rn(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=Xn("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!ri(e,!1)){const{message:t}=Xn("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(!this.client.session.keys.includes(e)){const{message:t}=Xn("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Rn(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:t}=Xn("EXPIRED",`session topic: ${e}`);throw new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if(ri(e,!1)){const{message:t}=Xn("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=Xn("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if("number"!=typeof e){const{message:t}=Xn("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=Xn("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Rn(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:t}=Xn("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class fl extends Lh{constructor(e,t){super(e,t,"proposal",Gh),this.core=e,this.logger=t}}class pl extends Lh{constructor(e,t){super(e,t,"session",Gh),this.core=e,this.logger=t}}class dl extends Lh{constructor(e,t){super(e,t,"request",Gh,(e=>e.id)),this.core=e,this.logger=t}}class gl extends Fo{constructor(t){super(t),this.protocol="wc",this.version=2,this.name=Yh,this.events=new e.EventEmitter,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.removeAllListeners=e=>this.events.removeAllListeners(e),this.connect=async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}},this.pair=async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}},this.approve=async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}},this.reject=async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}},this.update=async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}},this.extend=async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}},this.request=async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}},this.respond=async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}},this.ping=async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}},this.emit=async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}},this.disconnect=async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}},this.find=e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.name=t?.name||Yh,this.metadata=t?.metadata||jr()||{name:"",description:"",url:"",icons:[""]};const r=typeof t?.logger<"u"&&"string"!=typeof t?.logger?t.logger:Cs.pino(Cs.getDefaultLoggerOptions({level:t?.logger||Jh}));this.core=t?.core||new Fh(t),this.logger=Cs.generateChildLogger(r,this.name),this.session=new pl(this.core,this.logger),this.proposal=new fl(this.core,this.logger),this.pendingRequest=new dl(this.core,this.logger),this.engine=new ll(this)}static async init(e){const t=new gl(e);return await t.initialize(),t}get context(){return Cs.getLoggerContext(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}const yl={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"};class ml{constructor(t,r=!1){if(this.url=t,this.disableProviderPing=r,this.events=new e.EventEmitter,this.isAvailable=!1,this.registering=!1,!ka(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e,t){this.isAvailable||await this.register();try{const t=Jo(e),r=await d.c(this.url,Object.assign(Object.assign({},yl),{body:t})),n=await r.json();this.onPayload({data:n})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!ka(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise(((e,t)=>{this.events.once("register_error",(e=>{this.resetMaxListeners(),t(e)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),void 0===this.isAvailable)return t(new Error("HTTP connection is missing or invalid"));e()}))}))}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const t=Jo({id:1,jsonrpc:"2.0",method:"test",params:[]});await d.c(e,Object.assign(Object.assign({},yl),{body:t}))}this.onOpen()}catch(e){const t=this.parseError(e);throw this.events.emit("register_error",t),this.onClose(),t}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(void 0===e.data)return;const t="string"==typeof e.data?Yo(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const r=this.parseError(t),n=xa(e,r.message||r.toString());this.events.emit("payload",n)}parseError(e,t=this.url){return ba(e,t,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}}const vl="error",bl="wc@2:universal_provider:",wl="default_chain_changed";var _l=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},El={exports:{}};
2
+ /**
3
+ * @license
4
+ * Lodash <https://lodash.com/>
5
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
6
+ * Released under MIT license <https://lodash.com/license>
7
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
8
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
9
+ */!function(e,t){(function(){var r,n="Expected a function",i="__lodash_hash_undefined__",s="__lodash_placeholder__",o=16,a=32,c=64,u=128,h=256,l=1/0,f=9007199254740991,p=NaN,d=4294967295,g=[["ary",u],["bind",1],["bindKey",2],["curry",8],["curryRight",o],["flip",512],["partial",a],["partialRight",c],["rearg",h]],y="[object Arguments]",m="[object Array]",v="[object Boolean]",b="[object Date]",w="[object Error]",_="[object Function]",E="[object GeneratorFunction]",S="[object Map]",I="[object Number]",O="[object Object]",P="[object Promise]",A="[object RegExp]",N="[object Set]",x="[object String]",T="[object Symbol]",C="[object WeakMap]",j="[object ArrayBuffer]",R="[object DataView]",L="[object Float32Array]",k="[object Float64Array]",M="[object Int8Array]",U="[object Int16Array]",$="[object Int32Array]",D="[object Uint8Array]",z="[object Uint8ClampedArray]",q="[object Uint16Array]",H="[object Uint32Array]",K=/\b__p \+= '';/g,B=/\b(__p \+=) '' \+/g,V=/(__e\(.*?\)|\b__t\)) \+\n'';/g,F=/&(?:amp|lt|gt|quot|#39);/g,W=/[&<>"']/g,G=RegExp(F.source),Y=RegExp(W.source),J=/<%-([\s\S]+?)%>/g,X=/<%([\s\S]+?)%>/g,Z=/<%=([\s\S]+?)%>/g,Q=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ee=/^\w*$/,te=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,re=/[\\^$.*+?()[\]{}|]/g,ne=RegExp(re.source),ie=/^\s+/,se=/\s/,oe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ae=/\{\n\/\* \[wrapped with (.+)\] \*/,ce=/,? & /,ue=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,he=/[()=,{}\[\]\/\s]/,le=/\\(\\)?/g,fe=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,pe=/\w*$/,de=/^[-+]0x[0-9a-f]+$/i,ge=/^0b[01]+$/i,ye=/^\[object .+?Constructor\]$/,me=/^0o[0-7]+$/i,ve=/^(?:0|[1-9]\d*)$/,be=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,we=/($^)/,_e=/['\n\r\u2028\u2029\\]/g,Ee="\\ud800-\\udfff",Se="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Ie="\\u2700-\\u27bf",Oe="a-z\\xdf-\\xf6\\xf8-\\xff",Pe="A-Z\\xc0-\\xd6\\xd8-\\xde",Ae="\\ufe0e\\ufe0f",Ne="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",xe="['’]",Te="["+Ee+"]",Ce="["+Ne+"]",je="["+Se+"]",Re="\\d+",Le="["+Ie+"]",ke="["+Oe+"]",Me="[^"+Ee+Ne+Re+Ie+Oe+Pe+"]",Ue="\\ud83c[\\udffb-\\udfff]",$e="[^"+Ee+"]",De="(?:\\ud83c[\\udde6-\\uddff]){2}",ze="[\\ud800-\\udbff][\\udc00-\\udfff]",qe="["+Pe+"]",He="\\u200d",Ke="(?:"+ke+"|"+Me+")",Be="(?:"+qe+"|"+Me+")",Ve="(?:['’](?:d|ll|m|re|s|t|ve))?",Fe="(?:['’](?:D|LL|M|RE|S|T|VE))?",We="(?:"+je+"|"+Ue+")"+"?",Ge="["+Ae+"]?",Ye=Ge+We+("(?:"+He+"(?:"+[$e,De,ze].join("|")+")"+Ge+We+")*"),Je="(?:"+[Le,De,ze].join("|")+")"+Ye,Xe="(?:"+[$e+je+"?",je,De,ze,Te].join("|")+")",Ze=RegExp(xe,"g"),Qe=RegExp(je,"g"),et=RegExp(Ue+"(?="+Ue+")|"+Xe+Ye,"g"),tt=RegExp([qe+"?"+ke+"+"+Ve+"(?="+[Ce,qe,"$"].join("|")+")",Be+"+"+Fe+"(?="+[Ce,qe+Ke,"$"].join("|")+")",qe+"?"+Ke+"+"+Ve,qe+"+"+Fe,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Re,Je].join("|"),"g"),rt=RegExp("["+He+Ee+Se+Ae+"]"),nt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,it=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],st=-1,ot={};ot[L]=ot[k]=ot[M]=ot[U]=ot[$]=ot[D]=ot[z]=ot[q]=ot[H]=!0,ot[y]=ot[m]=ot[j]=ot[v]=ot[R]=ot[b]=ot[w]=ot[_]=ot[S]=ot[I]=ot[O]=ot[A]=ot[N]=ot[x]=ot[C]=!1;var at={};at[y]=at[m]=at[j]=at[R]=at[v]=at[b]=at[L]=at[k]=at[M]=at[U]=at[$]=at[S]=at[I]=at[O]=at[A]=at[N]=at[x]=at[T]=at[D]=at[z]=at[q]=at[H]=!0,at[w]=at[_]=at[C]=!1;var ct={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ut=parseFloat,ht=parseInt,lt="object"==typeof _l&&_l&&_l.Object===Object&&_l,ft="object"==typeof self&&self&&self.Object===Object&&self,pt=lt||ft||Function("return this")(),dt=t&&!t.nodeType&&t,gt=dt&&e&&!e.nodeType&&e,yt=gt&&gt.exports===dt,mt=yt&&lt.process,vt=function(){try{return gt&&gt.require&&gt.require("util").types||mt&&mt.binding&&mt.binding("util")}catch{}}(),bt=vt&&vt.isArrayBuffer,wt=vt&&vt.isDate,_t=vt&&vt.isMap,Et=vt&&vt.isRegExp,St=vt&&vt.isSet,It=vt&&vt.isTypedArray;function Ot(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)}function Pt(e,t,r,n){for(var i=-1,s=null==e?0:e.length;++i<s;){var o=e[i];t(n,o,r(o),e)}return n}function At(e,t){for(var r=-1,n=null==e?0:e.length;++r<n&&!1!==t(e[r],r,e););return e}function Nt(e,t){for(var r=null==e?0:e.length;r--&&!1!==t(e[r],r,e););return e}function xt(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(!t(e[r],r,e))return!1;return!0}function Tt(e,t){for(var r=-1,n=null==e?0:e.length,i=0,s=[];++r<n;){var o=e[r];t(o,r,e)&&(s[i++]=o)}return s}function Ct(e,t){return!!(null==e?0:e.length)&&qt(e,t,0)>-1}function jt(e,t,r){for(var n=-1,i=null==e?0:e.length;++n<i;)if(r(t,e[n]))return!0;return!1}function Rt(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}function Lt(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}function kt(e,t,r,n){var i=-1,s=null==e?0:e.length;for(n&&s&&(r=e[++i]);++i<s;)r=t(r,e[i],i,e);return r}function Mt(e,t,r,n){var i=null==e?0:e.length;for(n&&i&&(r=e[--i]);i--;)r=t(r,e[i],i,e);return r}function Ut(e,t){for(var r=-1,n=null==e?0:e.length;++r<n;)if(t(e[r],r,e))return!0;return!1}var $t=Vt("length");function Dt(e,t,r){var n;return r(e,(function(e,r,i){if(t(e,r,i))return n=r,!1})),n}function zt(e,t,r,n){for(var i=e.length,s=r+(n?1:-1);n?s--:++s<i;)if(t(e[s],s,e))return s;return-1}function qt(e,t,r){return t==t?function(e,t,r){for(var n=r-1,i=e.length;++n<i;)if(e[n]===t)return n;return-1}(e,t,r):zt(e,Kt,r)}function Ht(e,t,r,n){for(var i=r-1,s=e.length;++i<s;)if(n(e[i],t))return i;return-1}function Kt(e){return e!=e}function Bt(e,t){var r=null==e?0:e.length;return r?Gt(e,t)/r:p}function Vt(e){return function(t){return null==t?r:t[e]}}function Ft(e){return function(t){return null==e?r:e[t]}}function Wt(e,t,r,n,i){return i(e,(function(e,i,s){r=n?(n=!1,e):t(r,e,i,s)})),r}function Gt(e,t){for(var n,i=-1,s=e.length;++i<s;){var o=t(e[i]);o!==r&&(n=n===r?o:n+o)}return n}function Yt(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}function Jt(e){return e&&e.slice(0,fr(e)+1).replace(ie,"")}function Xt(e){return function(t){return e(t)}}function Zt(e,t){return Rt(t,(function(t){return e[t]}))}function Qt(e,t){return e.has(t)}function er(e,t){for(var r=-1,n=e.length;++r<n&&qt(t,e[r],0)>-1;);return r}function tr(e,t){for(var r=e.length;r--&&qt(t,e[r],0)>-1;);return r}var rr=Ft({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),nr=Ft({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"});function ir(e){return"\\"+ct[e]}function sr(e){return rt.test(e)}function or(e){var t=-1,r=Array(e.size);return e.forEach((function(e,n){r[++t]=[n,e]})),r}function ar(e,t){return function(r){return e(t(r))}}function cr(e,t){for(var r=-1,n=e.length,i=0,o=[];++r<n;){var a=e[r];(a===t||a===s)&&(e[r]=s,o[i++]=r)}return o}function ur(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}function hr(e){return sr(e)?function(e){for(var t=et.lastIndex=0;et.test(e);)++t;return t}(e):$t(e)}function lr(e){return sr(e)?function(e){return e.match(et)||[]}(e):function(e){return e.split("")}(e)}function fr(e){for(var t=e.length;t--&&se.test(e.charAt(t)););return t}var pr=Ft({"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"});var dr=function e(t){var se=(t=null==t?pt:dr.defaults(pt.Object(),t,dr.pick(pt,it))).Array,Ee=t.Date,Se=t.Error,Ie=t.Function,Oe=t.Math,Pe=t.Object,Ae=t.RegExp,Ne=t.String,xe=t.TypeError,Te=se.prototype,Ce=Ie.prototype,je=Pe.prototype,Re=t["__core-js_shared__"],Le=Ce.toString,ke=je.hasOwnProperty,Me=0,Ue=function(){var e=/[^.]+$/.exec(Re&&Re.keys&&Re.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),$e=je.toString,De=Le.call(Pe),ze=pt._,qe=Ae("^"+Le.call(ke).replace(re,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),He=yt?t.Buffer:r,Ke=t.Symbol,Be=t.Uint8Array,Ve=He?He.allocUnsafe:r,Fe=ar(Pe.getPrototypeOf,Pe),We=Pe.create,Ge=je.propertyIsEnumerable,Ye=Te.splice,Je=Ke?Ke.isConcatSpreadable:r,Xe=Ke?Ke.iterator:r,et=Ke?Ke.toStringTag:r,rt=function(){try{var e=hs(Pe,"defineProperty");return e({},"",{}),e}catch{}}(),ct=t.clearTimeout!==pt.clearTimeout&&t.clearTimeout,lt=Ee&&Ee.now!==pt.Date.now&&Ee.now,ft=t.setTimeout!==pt.setTimeout&&t.setTimeout,dt=Oe.ceil,gt=Oe.floor,mt=Pe.getOwnPropertySymbols,vt=He?He.isBuffer:r,$t=t.isFinite,Ft=Te.join,gr=ar(Pe.keys,Pe),yr=Oe.max,mr=Oe.min,vr=Ee.now,br=t.parseInt,wr=Oe.random,_r=Te.reverse,Er=hs(t,"DataView"),Sr=hs(t,"Map"),Ir=hs(t,"Promise"),Or=hs(t,"Set"),Pr=hs(t,"WeakMap"),Ar=hs(Pe,"create"),Nr=Pr&&new Pr,xr={},Tr=Ms(Er),Cr=Ms(Sr),jr=Ms(Ir),Rr=Ms(Or),Lr=Ms(Pr),kr=Ke?Ke.prototype:r,Mr=kr?kr.valueOf:r,Ur=kr?kr.toString:r;function $r(e){if(ea(e)&&!Ko(e)&&!(e instanceof Hr)){if(e instanceof qr)return e;if(ke.call(e,"__wrapped__"))return Us(e)}return new qr(e)}var Dr=function(){function e(){}return function(t){if(!Qo(t))return{};if(We)return We(t);e.prototype=t;var n=new e;return e.prototype=r,n}}();function zr(){}function qr(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=r}function Hr(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=d,this.__views__=[]}function Kr(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Br(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Vr(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function Fr(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new Vr;++t<r;)this.add(e[t])}function Wr(e){var t=this.__data__=new Br(e);this.size=t.size}function Gr(e,t){var r=Ko(e),n=!r&&Ho(e),i=!r&&!n&&Wo(e),s=!r&&!n&&!i&&ca(e),o=r||n||i||s,a=o?Yt(e.length,Ne):[],c=a.length;for(var u in e)(t||ke.call(e,u))&&(!o||!("length"==u||i&&("offset"==u||"parent"==u)||s&&("buffer"==u||"byteLength"==u||"byteOffset"==u)||ms(u,c)))&&a.push(u);return a}function Yr(e){var t=e.length;return t?e[Wn(0,t-1)]:r}function Jr(e,t){return Rs(Ni(e),on(t,0,e.length))}function Xr(e){return Rs(Ni(e))}function Zr(e,t,n){(n!==r&&!Do(e[t],n)||n===r&&!(t in e))&&nn(e,t,n)}function Qr(e,t,n){var i=e[t];(!ke.call(e,t)||!Do(i,n)||n===r&&!(t in e))&&nn(e,t,n)}function en(e,t){for(var r=e.length;r--;)if(Do(e[r][0],t))return r;return-1}function tn(e,t,r,n){return ln(e,(function(e,i,s){t(n,e,r(e),s)})),n}function rn(e,t){return e&&xi(t,Ta(t),e)}function nn(e,t,r){"__proto__"==t&&rt?rt(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0}):e[t]=r}function sn(e,t){for(var n=-1,i=t.length,s=se(i),o=null==e;++n<i;)s[n]=o?r:Oa(e,t[n]);return s}function on(e,t,n){return e==e&&(n!==r&&(e=e<=n?e:n),t!==r&&(e=e>=t?e:t)),e}function an(e,t,n,i,s,o){var a,c=1&t,u=2&t,h=4&t;if(n&&(a=s?n(e,i,s,o):n(e)),a!==r)return a;if(!Qo(e))return e;var l=Ko(e);if(l){if(a=function(e){var t=e.length,r=new e.constructor(t);return t&&"string"==typeof e[0]&&ke.call(e,"index")&&(r.index=e.index,r.input=e.input),r}(e),!c)return Ni(e,a)}else{var f=ps(e),p=f==_||f==E;if(Wo(e))return Ei(e,c);if(f==O||f==y||p&&!s){if(a=u||p?{}:gs(e),!c)return u?function(e,t){return xi(e,fs(e),t)}(e,function(e,t){return e&&xi(t,Ca(t),e)}(a,e)):function(e,t){return xi(e,ls(e),t)}(e,rn(a,e))}else{if(!at[f])return s?e:{};a=function(e,t,r){var n=e.constructor;switch(t){case j:return Si(e);case v:case b:return new n(+e);case R:return function(e,t){var r=t?Si(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.byteLength)}(e,r);case L:case k:case M:case U:case $:case D:case z:case q:case H:return Ii(e,r);case S:return new n;case I:case x:return new n(e);case A:return function(e){var t=new e.constructor(e.source,pe.exec(e));return t.lastIndex=e.lastIndex,t}(e);case N:return new n;case T:return function(e){return Mr?Pe(Mr.call(e)):{}}(e)}}(e,f,c)}}o||(o=new Wr);var d=o.get(e);if(d)return d;o.set(e,a),sa(e)?e.forEach((function(r){a.add(an(r,t,n,r,e,o))})):ta(e)&&e.forEach((function(r,i){a.set(i,an(r,t,n,i,e,o))}));var g=l?r:(h?u?ns:rs:u?Ca:Ta)(e);return At(g||e,(function(r,i){g&&(r=e[i=r]),Qr(a,i,an(r,t,n,i,e,o))})),a}function cn(e,t,n){var i=n.length;if(null==e)return!i;for(e=Pe(e);i--;){var s=n[i],o=t[s],a=e[s];if(a===r&&!(s in e)||!o(a))return!1}return!0}function un(e,t,i){if("function"!=typeof e)throw new xe(n);return xs((function(){e.apply(r,i)}),t)}function hn(e,t,r,n){var i=-1,s=Ct,o=!0,a=e.length,c=[],u=t.length;if(!a)return c;r&&(t=Rt(t,Xt(r))),n?(s=jt,o=!1):t.length>=200&&(s=Qt,o=!1,t=new Fr(t));e:for(;++i<a;){var h=e[i],l=null==r?h:r(h);if(h=n||0!==h?h:0,o&&l==l){for(var f=u;f--;)if(t[f]===l)continue e;c.push(h)}else s(t,l,n)||c.push(h)}return c}$r.templateSettings={escape:J,evaluate:X,interpolate:Z,variable:"",imports:{_:$r}},$r.prototype=zr.prototype,$r.prototype.constructor=$r,qr.prototype=Dr(zr.prototype),qr.prototype.constructor=qr,Hr.prototype=Dr(zr.prototype),Hr.prototype.constructor=Hr,Kr.prototype.clear=function(){this.__data__=Ar?Ar(null):{},this.size=0},Kr.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Kr.prototype.get=function(e){var t=this.__data__;if(Ar){var n=t[e];return n===i?r:n}return ke.call(t,e)?t[e]:r},Kr.prototype.has=function(e){var t=this.__data__;return Ar?t[e]!==r:ke.call(t,e)},Kr.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=Ar&&t===r?i:t,this},Br.prototype.clear=function(){this.__data__=[],this.size=0},Br.prototype.delete=function(e){var t=this.__data__,r=en(t,e);return!(r<0)&&(r==t.length-1?t.pop():Ye.call(t,r,1),--this.size,!0)},Br.prototype.get=function(e){var t=this.__data__,n=en(t,e);return n<0?r:t[n][1]},Br.prototype.has=function(e){return en(this.__data__,e)>-1},Br.prototype.set=function(e,t){var r=this.__data__,n=en(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},Vr.prototype.clear=function(){this.size=0,this.__data__={hash:new Kr,map:new(Sr||Br),string:new Kr}},Vr.prototype.delete=function(e){var t=cs(this,e).delete(e);return this.size-=t?1:0,t},Vr.prototype.get=function(e){return cs(this,e).get(e)},Vr.prototype.has=function(e){return cs(this,e).has(e)},Vr.prototype.set=function(e,t){var r=cs(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Fr.prototype.add=Fr.prototype.push=function(e){return this.__data__.set(e,i),this},Fr.prototype.has=function(e){return this.__data__.has(e)},Wr.prototype.clear=function(){this.__data__=new Br,this.size=0},Wr.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Wr.prototype.get=function(e){return this.__data__.get(e)},Wr.prototype.has=function(e){return this.__data__.has(e)},Wr.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Br){var n=r.__data__;if(!Sr||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Vr(n)}return r.set(e,t),this.size=r.size,this};var ln=ji(bn),fn=ji(wn,!0);function pn(e,t){var r=!0;return ln(e,(function(e,n,i){return r=!!t(e,n,i)})),r}function dn(e,t,n){for(var i=-1,s=e.length;++i<s;){var o=e[i],a=t(o);if(null!=a&&(c===r?a==a&&!aa(a):n(a,c)))var c=a,u=o}return u}function gn(e,t){var r=[];return ln(e,(function(e,n,i){t(e,n,i)&&r.push(e)})),r}function yn(e,t,r,n,i){var s=-1,o=e.length;for(r||(r=ys),i||(i=[]);++s<o;){var a=e[s];t>0&&r(a)?t>1?yn(a,t-1,r,n,i):Lt(i,a):n||(i[i.length]=a)}return i}var mn=Ri(),vn=Ri(!0);function bn(e,t){return e&&mn(e,t,Ta)}function wn(e,t){return e&&vn(e,t,Ta)}function _n(e,t){return Tt(t,(function(t){return Jo(e[t])}))}function En(e,t){for(var n=0,i=(t=vi(t,e)).length;null!=e&&n<i;)e=e[ks(t[n++])];return n&&n==i?e:r}function Sn(e,t,r){var n=t(e);return Ko(e)?n:Lt(n,r(e))}function In(e){return null==e?e===r?"[object Undefined]":"[object Null]":et&&et in Pe(e)?function(e){var t=ke.call(e,et),n=e[et];try{e[et]=r;var i=!0}catch{}var s=$e.call(e);return i&&(t?e[et]=n:delete e[et]),s}(e):function(e){return $e.call(e)}(e)}function On(e,t){return e>t}function Pn(e,t){return null!=e&&ke.call(e,t)}function An(e,t){return null!=e&&t in Pe(e)}function Nn(e,t,n){for(var i=n?jt:Ct,s=e[0].length,o=e.length,a=o,c=se(o),u=1/0,h=[];a--;){var l=e[a];a&&t&&(l=Rt(l,Xt(t))),u=mr(l.length,u),c[a]=!n&&(t||s>=120&&l.length>=120)?new Fr(a&&l):r}l=e[0];var f=-1,p=c[0];e:for(;++f<s&&h.length<u;){var d=l[f],g=t?t(d):d;if(d=n||0!==d?d:0,!(p?Qt(p,g):i(h,g,n))){for(a=o;--a;){var y=c[a];if(!(y?Qt(y,g):i(e[a],g,n)))continue e}p&&p.push(g),h.push(d)}}return h}function xn(e,t,n){var i=null==(e=Ps(e,t=vi(t,e)))?e:e[ks(Gs(t))];return null==i?r:Ot(i,e,n)}function Tn(e){return ea(e)&&In(e)==y}function Cn(e,t,n,i,s){return e===t||(null==e||null==t||!ea(e)&&!ea(t)?e!=e&&t!=t:function(e,t,n,i,s,o){var a=Ko(e),c=Ko(t),u=a?m:ps(e),h=c?m:ps(t);h=h==y?O:h;var l=(u=u==y?O:u)==O,f=h==O,p=u==h;if(p&&Wo(e)){if(!Wo(t))return!1;a=!0,l=!1}if(p&&!l)return o||(o=new Wr),a||ca(e)?es(e,t,n,i,s,o):function(e,t,r,n,i,s,o){switch(r){case R:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case j:return!(e.byteLength!=t.byteLength||!s(new Be(e),new Be(t)));case v:case b:case I:return Do(+e,+t);case w:return e.name==t.name&&e.message==t.message;case A:case x:return e==t+"";case S:var a=or;case N:var c=1&n;if(a||(a=ur),e.size!=t.size&&!c)return!1;var u=o.get(e);if(u)return u==t;n|=2,o.set(e,t);var h=es(a(e),a(t),n,i,s,o);return o.delete(e),h;case T:if(Mr)return Mr.call(e)==Mr.call(t)}return!1}(e,t,u,n,i,s,o);if(!(1&n)){var d=l&&ke.call(e,"__wrapped__"),g=f&&ke.call(t,"__wrapped__");if(d||g){var _=d?e.value():e,E=g?t.value():t;return o||(o=new Wr),s(_,E,n,i,o)}}return!!p&&(o||(o=new Wr),function(e,t,n,i,s,o){var a=1&n,c=rs(e),u=c.length,h=rs(t),l=h.length;if(u!=l&&!a)return!1;for(var f=u;f--;){var p=c[f];if(!(a?p in t:ke.call(t,p)))return!1}var d=o.get(e),g=o.get(t);if(d&&g)return d==t&&g==e;var y=!0;o.set(e,t),o.set(t,e);for(var m=a;++f<u;){var v=e[p=c[f]],b=t[p];if(i)var w=a?i(b,v,p,t,e,o):i(v,b,p,e,t,o);if(!(w===r?v===b||s(v,b,n,i,o):w)){y=!1;break}m||(m="constructor"==p)}if(y&&!m){var _=e.constructor,E=t.constructor;_!=E&&"constructor"in e&&"constructor"in t&&!("function"==typeof _&&_ instanceof _&&"function"==typeof E&&E instanceof E)&&(y=!1)}return o.delete(e),o.delete(t),y}(e,t,n,i,s,o))}(e,t,n,i,Cn,s))}function jn(e,t,n,i){var s=n.length,o=s,a=!i;if(null==e)return!o;for(e=Pe(e);s--;){var c=n[s];if(a&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++s<o;){var u=(c=n[s])[0],h=e[u],l=c[1];if(a&&c[2]){if(h===r&&!(u in e))return!1}else{var f=new Wr;if(i)var p=i(h,l,u,e,t,f);if(!(p===r?Cn(l,h,3,i,f):p))return!1}}return!0}function Rn(e){return!(!Qo(e)||function(e){return!!Ue&&Ue in e}(e))&&(Jo(e)?qe:ye).test(Ms(e))}function Ln(e){return"function"==typeof e?e:null==e?rc:"object"==typeof e?Ko(e)?zn(e[0],e[1]):Dn(e):lc(e)}function kn(e){if(!Es(e))return gr(e);var t=[];for(var r in Pe(e))ke.call(e,r)&&"constructor"!=r&&t.push(r);return t}function Mn(e){if(!Qo(e))return function(e){var t=[];if(null!=e)for(var r in Pe(e))t.push(r);return t}(e);var t=Es(e),r=[];for(var n in e)"constructor"==n&&(t||!ke.call(e,n))||r.push(n);return r}function Un(e,t){return e<t}function $n(e,t){var r=-1,n=Vo(e)?se(e.length):[];return ln(e,(function(e,i,s){n[++r]=t(e,i,s)})),n}function Dn(e){var t=us(e);return 1==t.length&&t[0][2]?Is(t[0][0],t[0][1]):function(r){return r===e||jn(r,e,t)}}function zn(e,t){return bs(e)&&Ss(t)?Is(ks(e),t):function(n){var i=Oa(n,e);return i===r&&i===t?Pa(n,e):Cn(t,i,3)}}function qn(e,t,n,i,s){e!==t&&mn(t,(function(o,a){if(s||(s=new Wr),Qo(o))!function(e,t,n,i,s,o,a){var c=As(e,n),u=As(t,n),h=a.get(u);if(h)return void Zr(e,n,h);var l=o?o(c,u,n+"",e,t,a):r,f=l===r;if(f){var p=Ko(u),d=!p&&Wo(u),g=!p&&!d&&ca(u);l=u,p||d||g?Ko(c)?l=c:Fo(c)?l=Ni(c):d?(f=!1,l=Ei(u,!0)):g?(f=!1,l=Ii(u,!0)):l=[]:na(u)||Ho(u)?(l=c,Ho(c)?l=ya(c):(!Qo(c)||Jo(c))&&(l=gs(u))):f=!1}f&&(a.set(u,l),s(l,u,i,o,a),a.delete(u)),Zr(e,n,l)}(e,t,a,n,qn,i,s);else{var c=i?i(As(e,a),o,a+"",e,t,s):r;c===r&&(c=o),Zr(e,a,c)}}),Ca)}function Hn(e,t){var n=e.length;if(n)return ms(t+=t<0?n:0,n)?e[t]:r}function Kn(e,t,r){t=t.length?Rt(t,(function(e){return Ko(e)?function(t){return En(t,1===e.length?e[0]:e)}:e})):[rc];var n=-1;t=Rt(t,Xt(as()));var i=$n(e,(function(e,r,i){var s=Rt(t,(function(t){return t(e)}));return{criteria:s,index:++n,value:e}}));return function(e,t){var r=e.length;for(e.sort(t);r--;)e[r]=e[r].value;return e}(i,(function(e,t){return function(e,t,r){for(var n=-1,i=e.criteria,s=t.criteria,o=i.length,a=r.length;++n<o;){var c=Oi(i[n],s[n]);if(c)return n>=a?c:c*("desc"==r[n]?-1:1)}return e.index-t.index}(e,t,r)}))}function Bn(e,t,r){for(var n=-1,i=t.length,s={};++n<i;){var o=t[n],a=En(e,o);r(a,o)&&Zn(s,vi(o,e),a)}return s}function Vn(e,t,r,n){var i=n?Ht:qt,s=-1,o=t.length,a=e;for(e===t&&(t=Ni(t)),r&&(a=Rt(e,Xt(r)));++s<o;)for(var c=0,u=t[s],h=r?r(u):u;(c=i(a,h,c,n))>-1;)a!==e&&Ye.call(a,c,1),Ye.call(e,c,1);return e}function Fn(e,t){for(var r=e?t.length:0,n=r-1;r--;){var i=t[r];if(r==n||i!==s){var s=i;ms(i)?Ye.call(e,i,1):hi(e,i)}}return e}function Wn(e,t){return e+gt(wr()*(t-e+1))}function Gn(e,t){var r="";if(!e||t<1||t>f)return r;do{t%2&&(r+=e),(t=gt(t/2))&&(e+=e)}while(t);return r}function Yn(e,t){return Ts(Os(e,t,rc),e+"")}function Jn(e){return Yr(Da(e))}function Xn(e,t){var r=Da(e);return Rs(r,on(t,0,r.length))}function Zn(e,t,n,i){if(!Qo(e))return e;for(var s=-1,o=(t=vi(t,e)).length,a=o-1,c=e;null!=c&&++s<o;){var u=ks(t[s]),h=n;if("__proto__"===u||"constructor"===u||"prototype"===u)return e;if(s!=a){var l=c[u];(h=i?i(l,u,c):r)===r&&(h=Qo(l)?l:ms(t[s+1])?[]:{})}Qr(c,u,h),c=c[u]}return e}var Qn=Nr?function(e,t){return Nr.set(e,t),e}:rc,ei=rt?function(e,t){return rt(e,"toString",{configurable:!0,enumerable:!1,value:Qa(t),writable:!0})}:rc;function ti(e){return Rs(Da(e))}function ri(e,t,r){var n=-1,i=e.length;t<0&&(t=-t>i?0:i+t),(r=r>i?i:r)<0&&(r+=i),i=t>r?0:r-t>>>0,t>>>=0;for(var s=se(i);++n<i;)s[n]=e[n+t];return s}function ni(e,t){var r;return ln(e,(function(e,n,i){return!(r=t(e,n,i))})),!!r}function ii(e,t,r){var n=0,i=null==e?n:e.length;if("number"==typeof t&&t==t&&i<=2147483647){for(;n<i;){var s=n+i>>>1,o=e[s];null!==o&&!aa(o)&&(r?o<=t:o<t)?n=s+1:i=s}return i}return si(e,t,rc,r)}function si(e,t,n,i){var s=0,o=null==e?0:e.length;if(0===o)return 0;for(var a=(t=n(t))!=t,c=null===t,u=aa(t),h=t===r;s<o;){var l=gt((s+o)/2),f=n(e[l]),p=f!==r,d=null===f,g=f==f,y=aa(f);if(a)var m=i||g;else m=h?g&&(i||p):c?g&&p&&(i||!d):u?g&&p&&!d&&(i||!y):!d&&!y&&(i?f<=t:f<t);m?s=l+1:o=l}return mr(o,4294967294)}function oi(e,t){for(var r=-1,n=e.length,i=0,s=[];++r<n;){var o=e[r],a=t?t(o):o;if(!r||!Do(a,c)){var c=a;s[i++]=0===o?0:o}}return s}function ai(e){return"number"==typeof e?e:aa(e)?p:+e}function ci(e){if("string"==typeof e)return e;if(Ko(e))return Rt(e,ci)+"";if(aa(e))return Ur?Ur.call(e):"";var t=e+"";return"0"==t&&1/e==-l?"-0":t}function ui(e,t,r){var n=-1,i=Ct,s=e.length,o=!0,a=[],c=a;if(r)o=!1,i=jt;else if(s>=200){var u=t?null:Gi(e);if(u)return ur(u);o=!1,i=Qt,c=new Fr}else c=t?[]:a;e:for(;++n<s;){var h=e[n],l=t?t(h):h;if(h=r||0!==h?h:0,o&&l==l){for(var f=c.length;f--;)if(c[f]===l)continue e;t&&c.push(l),a.push(h)}else i(c,l,r)||(c!==a&&c.push(l),a.push(h))}return a}function hi(e,t){return null==(e=Ps(e,t=vi(t,e)))||delete e[ks(Gs(t))]}function li(e,t,r,n){return Zn(e,t,r(En(e,t)),n)}function fi(e,t,r,n){for(var i=e.length,s=n?i:-1;(n?s--:++s<i)&&t(e[s],s,e););return r?ri(e,n?0:s,n?s+1:i):ri(e,n?s+1:0,n?i:s)}function pi(e,t){var r=e;return r instanceof Hr&&(r=r.value()),kt(t,(function(e,t){return t.func.apply(t.thisArg,Lt([e],t.args))}),r)}function di(e,t,r){var n=e.length;if(n<2)return n?ui(e[0]):[];for(var i=-1,s=se(n);++i<n;)for(var o=e[i],a=-1;++a<n;)a!=i&&(s[i]=hn(s[i]||o,e[a],t,r));return ui(yn(s,1),t,r)}function gi(e,t,n){for(var i=-1,s=e.length,o=t.length,a={};++i<s;){var c=i<o?t[i]:r;n(a,e[i],c)}return a}function yi(e){return Fo(e)?e:[]}function mi(e){return"function"==typeof e?e:rc}function vi(e,t){return Ko(e)?e:bs(e,t)?[e]:Ls(ma(e))}var bi=Yn;function wi(e,t,n){var i=e.length;return n=n===r?i:n,!t&&n>=i?e:ri(e,t,n)}var _i=ct||function(e){return pt.clearTimeout(e)};function Ei(e,t){if(t)return e.slice();var r=e.length,n=Ve?Ve(r):new e.constructor(r);return e.copy(n),n}function Si(e){var t=new e.constructor(e.byteLength);return new Be(t).set(new Be(e)),t}function Ii(e,t){var r=t?Si(e.buffer):e.buffer;return new e.constructor(r,e.byteOffset,e.length)}function Oi(e,t){if(e!==t){var n=e!==r,i=null===e,s=e==e,o=aa(e),a=t!==r,c=null===t,u=t==t,h=aa(t);if(!c&&!h&&!o&&e>t||o&&a&&u&&!c&&!h||i&&a&&u||!n&&u||!s)return 1;if(!i&&!o&&!h&&e<t||h&&n&&s&&!i&&!o||c&&n&&s||!a&&s||!u)return-1}return 0}function Pi(e,t,r,n){for(var i=-1,s=e.length,o=r.length,a=-1,c=t.length,u=yr(s-o,0),h=se(c+u),l=!n;++a<c;)h[a]=t[a];for(;++i<o;)(l||i<s)&&(h[r[i]]=e[i]);for(;u--;)h[a++]=e[i++];return h}function Ai(e,t,r,n){for(var i=-1,s=e.length,o=-1,a=r.length,c=-1,u=t.length,h=yr(s-a,0),l=se(h+u),f=!n;++i<h;)l[i]=e[i];for(var p=i;++c<u;)l[p+c]=t[c];for(;++o<a;)(f||i<s)&&(l[p+r[o]]=e[i++]);return l}function Ni(e,t){var r=-1,n=e.length;for(t||(t=se(n));++r<n;)t[r]=e[r];return t}function xi(e,t,n,i){var s=!n;n||(n={});for(var o=-1,a=t.length;++o<a;){var c=t[o],u=i?i(n[c],e[c],c,n,e):r;u===r&&(u=e[c]),s?nn(n,c,u):Qr(n,c,u)}return n}function Ti(e,t){return function(r,n){var i=Ko(r)?Pt:tn,s=t?t():{};return i(r,e,as(n,2),s)}}function Ci(e){return Yn((function(t,n){var i=-1,s=n.length,o=s>1?n[s-1]:r,a=s>2?n[2]:r;for(o=e.length>3&&"function"==typeof o?(s--,o):r,a&&vs(n[0],n[1],a)&&(o=s<3?r:o,s=1),t=Pe(t);++i<s;){var c=n[i];c&&e(t,c,i,o)}return t}))}function ji(e,t){return function(r,n){if(null==r)return r;if(!Vo(r))return e(r,n);for(var i=r.length,s=t?i:-1,o=Pe(r);(t?s--:++s<i)&&!1!==n(o[s],s,o););return r}}function Ri(e){return function(t,r,n){for(var i=-1,s=Pe(t),o=n(t),a=o.length;a--;){var c=o[e?a:++i];if(!1===r(s[c],c,s))break}return t}}function Li(e){return function(t){var n=sr(t=ma(t))?lr(t):r,i=n?n[0]:t.charAt(0),s=n?wi(n,1).join(""):t.slice(1);return i[e]()+s}}function ki(e){return function(t){return kt(Ja(Ha(t).replace(Ze,"")),e,"")}}function Mi(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var r=Dr(e.prototype),n=e.apply(r,t);return Qo(n)?n:r}}function Ui(e){return function(t,n,i){var s=Pe(t);if(!Vo(t)){var o=as(n,3);t=Ta(t),n=function(e){return o(s[e],e,s)}}var a=e(t,n,i);return a>-1?s[o?t[a]:a]:r}}function $i(e){return ts((function(t){var i=t.length,s=i,o=qr.prototype.thru;for(e&&t.reverse();s--;){var a=t[s];if("function"!=typeof a)throw new xe(n);if(o&&!c&&"wrapper"==ss(a))var c=new qr([],!0)}for(s=c?s:i;++s<i;){var u=ss(a=t[s]),h="wrapper"==u?is(a):r;c=h&&ws(h[0])&&424==h[1]&&!h[4].length&&1==h[9]?c[ss(h[0])].apply(c,h[3]):1==a.length&&ws(a)?c[u]():c.thru(a)}return function(){var e=arguments,r=e[0];if(c&&1==e.length&&Ko(r))return c.plant(r).value();for(var n=0,s=i?t[n].apply(this,e):r;++n<i;)s=t[n].call(this,s);return s}}))}function Di(e,t,n,i,s,o,a,c,h,l){var f=t&u,p=1&t,d=2&t,g=24&t,y=512&t,m=d?r:Mi(e);return function u(){for(var v=arguments.length,b=se(v),w=v;w--;)b[w]=arguments[w];if(g)var _=os(u),E=function(e,t){for(var r=e.length,n=0;r--;)e[r]===t&&++n;return n}(b,_);if(i&&(b=Pi(b,i,s,g)),o&&(b=Ai(b,o,a,g)),v-=E,g&&v<l){var S=cr(b,_);return Fi(e,t,Di,u.placeholder,n,b,S,c,h,l-v)}var I=p?n:this,O=d?I[e]:e;return v=b.length,c?b=function(e,t){for(var n=e.length,i=mr(t.length,n),s=Ni(e);i--;){var o=t[i];e[i]=ms(o,n)?s[o]:r}return e}(b,c):y&&v>1&&b.reverse(),f&&h<v&&(b.length=h),this&&this!==pt&&this instanceof u&&(O=m||Mi(O)),O.apply(I,b)}}function zi(e,t){return function(r,n){return function(e,t,r,n){return bn(e,(function(e,i,s){t(n,r(e),i,s)})),n}(r,e,t(n),{})}}function qi(e,t){return function(n,i){var s;if(n===r&&i===r)return t;if(n!==r&&(s=n),i!==r){if(s===r)return i;"string"==typeof n||"string"==typeof i?(n=ci(n),i=ci(i)):(n=ai(n),i=ai(i)),s=e(n,i)}return s}}function Hi(e){return ts((function(t){return t=Rt(t,Xt(as())),Yn((function(r){var n=this;return e(t,(function(e){return Ot(e,n,r)}))}))}))}function Ki(e,t){var n=(t=t===r?" ":ci(t)).length;if(n<2)return n?Gn(t,e):t;var i=Gn(t,dt(e/hr(t)));return sr(t)?wi(lr(i),0,e).join(""):i.slice(0,e)}function Bi(e){return function(t,n,i){return i&&"number"!=typeof i&&vs(t,n,i)&&(n=i=r),t=fa(t),n===r?(n=t,t=0):n=fa(n),function(e,t,r,n){for(var i=-1,s=yr(dt((t-e)/(r||1)),0),o=se(s);s--;)o[n?s:++i]=e,e+=r;return o}(t,n,i=i===r?t<n?1:-1:fa(i),e)}}function Vi(e){return function(t,r){return"string"==typeof t&&"string"==typeof r||(t=ga(t),r=ga(r)),e(t,r)}}function Fi(e,t,n,i,s,o,u,h,l,f){var p=8&t;t|=p?a:c,4&(t&=~(p?c:a))||(t&=-4);var d=[e,t,s,p?o:r,p?u:r,p?r:o,p?r:u,h,l,f],g=n.apply(r,d);return ws(e)&&Ns(g,d),g.placeholder=i,Cs(g,e,t)}function Wi(e){var t=Oe[e];return function(e,r){if(e=ga(e),(r=null==r?0:mr(pa(r),292))&&$t(e)){var n=(ma(e)+"e").split("e");return+((n=(ma(t(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return t(e)}}var Gi=Or&&1/ur(new Or([,-0]))[1]==l?function(e){return new Or(e)}:ac;function Yi(e){return function(t){var r=ps(t);return r==S?or(t):r==N?function(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=[e,e]})),r}(t):function(e,t){return Rt(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Ji(e,t,i,l,f,p,d,g){var y=2&t;if(!y&&"function"!=typeof e)throw new xe(n);var m=l?l.length:0;if(m||(t&=-97,l=f=r),d=d===r?d:yr(pa(d),0),g=g===r?g:pa(g),m-=f?f.length:0,t&c){var v=l,b=f;l=f=r}var w=y?r:is(e),_=[e,t,i,l,f,v,b,p,d,g];if(w&&function(e,t){var r=e[1],n=t[1],i=r|n,o=i<131,a=n==u&&8==r||n==u&&r==h&&e[7].length<=t[8]||384==n&&t[7].length<=t[8]&&8==r;if(!o&&!a)return e;1&n&&(e[2]=t[2],i|=1&r?0:4);var c=t[3];if(c){var l=e[3];e[3]=l?Pi(l,c,t[4]):c,e[4]=l?cr(e[3],s):t[4]}c=t[5],c&&(l=e[5],e[5]=l?Ai(l,c,t[6]):c,e[6]=l?cr(e[5],s):t[6]),c=t[7],c&&(e[7]=c),n&u&&(e[8]=null==e[8]?t[8]:mr(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=i}(_,w),e=_[0],t=_[1],i=_[2],l=_[3],f=_[4],!(g=_[9]=_[9]===r?y?0:e.length:yr(_[9]-m,0))&&24&t&&(t&=-25),t&&1!=t)E=8==t||t==o?function(e,t,n){var i=Mi(e);return function s(){for(var o=arguments.length,a=se(o),c=o,u=os(s);c--;)a[c]=arguments[c];var h=o<3&&a[0]!==u&&a[o-1]!==u?[]:cr(a,u);return(o-=h.length)<n?Fi(e,t,Di,s.placeholder,r,a,h,r,r,n-o):Ot(this&&this!==pt&&this instanceof s?i:e,this,a)}}(e,t,g):t!=a&&33!=t||f.length?Di.apply(r,_):function(e,t,r,n){var i=1&t,s=Mi(e);return function t(){for(var o=-1,a=arguments.length,c=-1,u=n.length,h=se(u+a),l=this&&this!==pt&&this instanceof t?s:e;++c<u;)h[c]=n[c];for(;a--;)h[c++]=arguments[++o];return Ot(l,i?r:this,h)}}(e,t,i,l);else var E=function(e,t,r){var n=1&t,i=Mi(e);return function t(){return(this&&this!==pt&&this instanceof t?i:e).apply(n?r:this,arguments)}}(e,t,i);return Cs((w?Qn:Ns)(E,_),e,t)}function Xi(e,t,n,i){return e===r||Do(e,je[n])&&!ke.call(i,n)?t:e}function Zi(e,t,n,i,s,o){return Qo(e)&&Qo(t)&&(o.set(t,e),qn(e,t,r,Zi,o),o.delete(t)),e}function Qi(e){return na(e)?r:e}function es(e,t,n,i,s,o){var a=1&n,c=e.length,u=t.length;if(c!=u&&!(a&&u>c))return!1;var h=o.get(e),l=o.get(t);if(h&&l)return h==t&&l==e;var f=-1,p=!0,d=2&n?new Fr:r;for(o.set(e,t),o.set(t,e);++f<c;){var g=e[f],y=t[f];if(i)var m=a?i(y,g,f,t,e,o):i(g,y,f,e,t,o);if(m!==r){if(m)continue;p=!1;break}if(d){if(!Ut(t,(function(e,t){if(!Qt(d,t)&&(g===e||s(g,e,n,i,o)))return d.push(t)}))){p=!1;break}}else if(g!==y&&!s(g,y,n,i,o)){p=!1;break}}return o.delete(e),o.delete(t),p}function ts(e){return Ts(Os(e,r,Ks),e+"")}function rs(e){return Sn(e,Ta,ls)}function ns(e){return Sn(e,Ca,fs)}var is=Nr?function(e){return Nr.get(e)}:ac;function ss(e){for(var t=e.name+"",r=xr[t],n=ke.call(xr,t)?r.length:0;n--;){var i=r[n],s=i.func;if(null==s||s==e)return i.name}return t}function os(e){return(ke.call($r,"placeholder")?$r:e).placeholder}function as(){var e=$r.iteratee||nc;return e=e===nc?Ln:e,arguments.length?e(arguments[0],arguments[1]):e}function cs(e,t){var r=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?r["string"==typeof t?"string":"hash"]:r.map}function us(e){for(var t=Ta(e),r=t.length;r--;){var n=t[r],i=e[n];t[r]=[n,i,Ss(i)]}return t}function hs(e,t){var n=function(e,t){return null==e?r:e[t]}(e,t);return Rn(n)?n:r}var ls=mt?function(e){return null==e?[]:(e=Pe(e),Tt(mt(e),(function(t){return Ge.call(e,t)})))}:dc,fs=mt?function(e){for(var t=[];e;)Lt(t,ls(e)),e=Fe(e);return t}:dc,ps=In;function ds(e,t,r){for(var n=-1,i=(t=vi(t,e)).length,s=!1;++n<i;){var o=ks(t[n]);if(!(s=null!=e&&r(e,o)))break;e=e[o]}return s||++n!=i?s:!!(i=null==e?0:e.length)&&Zo(i)&&ms(o,i)&&(Ko(e)||Ho(e))}function gs(e){return"function"!=typeof e.constructor||Es(e)?{}:Dr(Fe(e))}function ys(e){return Ko(e)||Ho(e)||!!(Je&&e&&e[Je])}function ms(e,t){var r=typeof e;return!!(t=t??f)&&("number"==r||"symbol"!=r&&ve.test(e))&&e>-1&&e%1==0&&e<t}function vs(e,t,r){if(!Qo(r))return!1;var n=typeof t;return!!("number"==n?Vo(r)&&ms(t,r.length):"string"==n&&t in r)&&Do(r[t],e)}function bs(e,t){if(Ko(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!aa(e))||(ee.test(e)||!Q.test(e)||null!=t&&e in Pe(t))}function ws(e){var t=ss(e),r=$r[t];if("function"!=typeof r||!(t in Hr.prototype))return!1;if(e===r)return!0;var n=is(r);return!!n&&e===n[0]}(Er&&ps(new Er(new ArrayBuffer(1)))!=R||Sr&&ps(new Sr)!=S||Ir&&ps(Ir.resolve())!=P||Or&&ps(new Or)!=N||Pr&&ps(new Pr)!=C)&&(ps=function(e){var t=In(e),n=t==O?e.constructor:r,i=n?Ms(n):"";if(i)switch(i){case Tr:return R;case Cr:return S;case jr:return P;case Rr:return N;case Lr:return C}return t});var _s=Re?Jo:gc;function Es(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||je)}function Ss(e){return e==e&&!Qo(e)}function Is(e,t){return function(n){return null!=n&&(n[e]===t&&(t!==r||e in Pe(n)))}}function Os(e,t,n){return t=yr(t===r?e.length-1:t,0),function(){for(var r=arguments,i=-1,s=yr(r.length-t,0),o=se(s);++i<s;)o[i]=r[t+i];i=-1;for(var a=se(t+1);++i<t;)a[i]=r[i];return a[t]=n(o),Ot(e,this,a)}}function Ps(e,t){return t.length<2?e:En(e,ri(t,0,-1))}function As(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var Ns=js(Qn),xs=ft||function(e,t){return pt.setTimeout(e,t)},Ts=js(ei);function Cs(e,t,r){var n=t+"";return Ts(e,function(e,t){var r=t.length;if(!r)return e;var n=r-1;return t[n]=(r>1?"& ":"")+t[n],t=t.join(r>2?", ":" "),e.replace(oe,"{\n/* [wrapped with "+t+"] */\n")}(n,function(e,t){return At(g,(function(r){var n="_."+r[0];t&r[1]&&!Ct(e,n)&&e.push(n)})),e.sort()}(function(e){var t=e.match(ae);return t?t[1].split(ce):[]}(n),r)))}function js(e){var t=0,n=0;return function(){var i=vr(),s=16-(i-n);if(n=i,s>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(r,arguments)}}function Rs(e,t){var n=-1,i=e.length,s=i-1;for(t=t===r?i:t;++n<t;){var o=Wn(n,s),a=e[o];e[o]=e[n],e[n]=a}return e.length=t,e}var Ls=function(e){var t=Ro(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(te,(function(e,r,n,i){t.push(n?i.replace(le,"$1"):r||e)})),t}));function ks(e){if("string"==typeof e||aa(e))return e;var t=e+"";return"0"==t&&1/e==-l?"-0":t}function Ms(e){if(null!=e){try{return Le.call(e)}catch{}try{return e+""}catch{}}return""}function Us(e){if(e instanceof Hr)return e.clone();var t=new qr(e.__wrapped__,e.__chain__);return t.__actions__=Ni(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var $s=Yn((function(e,t){return Fo(e)?hn(e,yn(t,1,Fo,!0)):[]})),Ds=Yn((function(e,t){var n=Gs(t);return Fo(n)&&(n=r),Fo(e)?hn(e,yn(t,1,Fo,!0),as(n,2)):[]})),zs=Yn((function(e,t){var n=Gs(t);return Fo(n)&&(n=r),Fo(e)?hn(e,yn(t,1,Fo,!0),r,n):[]}));function qs(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:pa(r);return i<0&&(i=yr(n+i,0)),zt(e,as(t,3),i)}function Hs(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var s=i-1;return n!==r&&(s=pa(n),s=n<0?yr(i+s,0):mr(s,i-1)),zt(e,as(t,3),s,!0)}function Ks(e){return(null==e?0:e.length)?yn(e,1):[]}function Bs(e){return e&&e.length?e[0]:r}var Vs=Yn((function(e){var t=Rt(e,yi);return t.length&&t[0]===e[0]?Nn(t):[]})),Fs=Yn((function(e){var t=Gs(e),n=Rt(e,yi);return t===Gs(n)?t=r:n.pop(),n.length&&n[0]===e[0]?Nn(n,as(t,2)):[]})),Ws=Yn((function(e){var t=Gs(e),n=Rt(e,yi);return(t="function"==typeof t?t:r)&&n.pop(),n.length&&n[0]===e[0]?Nn(n,r,t):[]}));function Gs(e){var t=null==e?0:e.length;return t?e[t-1]:r}var Ys=Yn(Js);function Js(e,t){return e&&e.length&&t&&t.length?Vn(e,t):e}var Xs=ts((function(e,t){var r=null==e?0:e.length,n=sn(e,t);return Fn(e,Rt(t,(function(e){return ms(e,r)?+e:e})).sort(Oi)),n}));function Zs(e){return null==e?e:_r.call(e)}var Qs=Yn((function(e){return ui(yn(e,1,Fo,!0))})),eo=Yn((function(e){var t=Gs(e);return Fo(t)&&(t=r),ui(yn(e,1,Fo,!0),as(t,2))})),to=Yn((function(e){var t=Gs(e);return t="function"==typeof t?t:r,ui(yn(e,1,Fo,!0),r,t)}));function ro(e){if(!e||!e.length)return[];var t=0;return e=Tt(e,(function(e){if(Fo(e))return t=yr(e.length,t),!0})),Yt(t,(function(t){return Rt(e,Vt(t))}))}function no(e,t){if(!e||!e.length)return[];var n=ro(e);return null==t?n:Rt(n,(function(e){return Ot(t,r,e)}))}var io=Yn((function(e,t){return Fo(e)?hn(e,t):[]})),so=Yn((function(e){return di(Tt(e,Fo))})),oo=Yn((function(e){var t=Gs(e);return Fo(t)&&(t=r),di(Tt(e,Fo),as(t,2))})),ao=Yn((function(e){var t=Gs(e);return t="function"==typeof t?t:r,di(Tt(e,Fo),r,t)})),co=Yn(ro);var uo=Yn((function(e){var t=e.length,n=t>1?e[t-1]:r;return n="function"==typeof n?(e.pop(),n):r,no(e,n)}));function ho(e){var t=$r(e);return t.__chain__=!0,t}function lo(e,t){return t(e)}var fo=ts((function(e){var t=e.length,n=t?e[0]:0,i=this.__wrapped__,s=function(t){return sn(t,e)};return!(t>1||this.__actions__.length)&&i instanceof Hr&&ms(n)?((i=i.slice(n,+n+(t?1:0))).__actions__.push({func:lo,args:[s],thisArg:r}),new qr(i,this.__chain__).thru((function(e){return t&&!e.length&&e.push(r),e}))):this.thru(s)}));var po=Ti((function(e,t,r){ke.call(e,r)?++e[r]:nn(e,r,1)}));var go=Ui(qs),yo=Ui(Hs);function mo(e,t){return(Ko(e)?At:ln)(e,as(t,3))}function vo(e,t){return(Ko(e)?Nt:fn)(e,as(t,3))}var bo=Ti((function(e,t,r){ke.call(e,r)?e[r].push(t):nn(e,r,[t])}));var wo=Yn((function(e,t,r){var n=-1,i="function"==typeof t,s=Vo(e)?se(e.length):[];return ln(e,(function(e){s[++n]=i?Ot(t,e,r):xn(e,t,r)})),s})),_o=Ti((function(e,t,r){nn(e,r,t)}));function Eo(e,t){return(Ko(e)?Rt:$n)(e,as(t,3))}var So=Ti((function(e,t,r){e[r?0:1].push(t)}),(function(){return[[],[]]}));var Io=Yn((function(e,t){if(null==e)return[];var r=t.length;return r>1&&vs(e,t[0],t[1])?t=[]:r>2&&vs(t[0],t[1],t[2])&&(t=[t[0]]),Kn(e,yn(t,1),[])})),Oo=lt||function(){return pt.Date.now()};function Po(e,t,n){return t=n?r:t,t=e&&null==t?e.length:t,Ji(e,u,r,r,r,r,t)}function Ao(e,t){var i;if("function"!=typeof t)throw new xe(n);return e=pa(e),function(){return--e>0&&(i=t.apply(this,arguments)),e<=1&&(t=r),i}}var No=Yn((function(e,t,r){var n=1;if(r.length){var i=cr(r,os(No));n|=a}return Ji(e,n,t,r,i)})),xo=Yn((function(e,t,r){var n=3;if(r.length){var i=cr(r,os(xo));n|=a}return Ji(t,n,e,r,i)}));function To(e,t,i){var s,o,a,c,u,h,l=0,f=!1,p=!1,d=!0;if("function"!=typeof e)throw new xe(n);function g(t){var n=s,i=o;return s=o=r,l=t,c=e.apply(i,n)}function y(e){var n=e-h;return h===r||n>=t||n<0||p&&e-l>=a}function m(){var e=Oo();if(y(e))return v(e);u=xs(m,function(e){var r=t-(e-h);return p?mr(r,a-(e-l)):r}(e))}function v(e){return u=r,d&&s?g(e):(s=o=r,c)}function b(){var e=Oo(),n=y(e);if(s=arguments,o=this,h=e,n){if(u===r)return function(e){return l=e,u=xs(m,t),f?g(e):c}(h);if(p)return _i(u),u=xs(m,t),g(h)}return u===r&&(u=xs(m,t)),c}return t=ga(t)||0,Qo(i)&&(f=!!i.leading,a=(p="maxWait"in i)?yr(ga(i.maxWait)||0,t):a,d="trailing"in i?!!i.trailing:d),b.cancel=function(){u!==r&&_i(u),l=0,s=h=o=u=r},b.flush=function(){return u===r?c:v(Oo())},b}var Co=Yn((function(e,t){return un(e,1,t)})),jo=Yn((function(e,t,r){return un(e,ga(t)||0,r)}));function Ro(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new xe(n);var r=function(){var n=arguments,i=t?t.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var o=e.apply(this,n);return r.cache=s.set(i,o)||s,o};return r.cache=new(Ro.Cache||Vr),r}function Lo(e){if("function"!=typeof e)throw new xe(n);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Ro.Cache=Vr;var ko=bi((function(e,t){var r=(t=1==t.length&&Ko(t[0])?Rt(t[0],Xt(as())):Rt(yn(t,1),Xt(as()))).length;return Yn((function(n){for(var i=-1,s=mr(n.length,r);++i<s;)n[i]=t[i].call(this,n[i]);return Ot(e,this,n)}))})),Mo=Yn((function(e,t){var n=cr(t,os(Mo));return Ji(e,a,r,t,n)})),Uo=Yn((function(e,t){var n=cr(t,os(Uo));return Ji(e,c,r,t,n)})),$o=ts((function(e,t){return Ji(e,h,r,r,r,t)}));function Do(e,t){return e===t||e!=e&&t!=t}var zo=Vi(On),qo=Vi((function(e,t){return e>=t})),Ho=Tn(function(){return arguments}())?Tn:function(e){return ea(e)&&ke.call(e,"callee")&&!Ge.call(e,"callee")},Ko=se.isArray,Bo=bt?Xt(bt):function(e){return ea(e)&&In(e)==j};function Vo(e){return null!=e&&Zo(e.length)&&!Jo(e)}function Fo(e){return ea(e)&&Vo(e)}var Wo=vt||gc,Go=wt?Xt(wt):function(e){return ea(e)&&In(e)==b};function Yo(e){if(!ea(e))return!1;var t=In(e);return t==w||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!na(e)}function Jo(e){if(!Qo(e))return!1;var t=In(e);return t==_||t==E||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Xo(e){return"number"==typeof e&&e==pa(e)}function Zo(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=f}function Qo(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ea(e){return null!=e&&"object"==typeof e}var ta=_t?Xt(_t):function(e){return ea(e)&&ps(e)==S};function ra(e){return"number"==typeof e||ea(e)&&In(e)==I}function na(e){if(!ea(e)||In(e)!=O)return!1;var t=Fe(e);if(null===t)return!0;var r=ke.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&Le.call(r)==De}var ia=Et?Xt(Et):function(e){return ea(e)&&In(e)==A};var sa=St?Xt(St):function(e){return ea(e)&&ps(e)==N};function oa(e){return"string"==typeof e||!Ko(e)&&ea(e)&&In(e)==x}function aa(e){return"symbol"==typeof e||ea(e)&&In(e)==T}var ca=It?Xt(It):function(e){return ea(e)&&Zo(e.length)&&!!ot[In(e)]};var ua=Vi(Un),ha=Vi((function(e,t){return e<=t}));function la(e){if(!e)return[];if(Vo(e))return oa(e)?lr(e):Ni(e);if(Xe&&e[Xe])return function(e){for(var t,r=[];!(t=e.next()).done;)r.push(t.value);return r}(e[Xe]());var t=ps(e);return(t==S?or:t==N?ur:Da)(e)}function fa(e){return e?(e=ga(e))===l||e===-l?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function pa(e){var t=fa(e),r=t%1;return t==t?r?t-r:t:0}function da(e){return e?on(pa(e),0,d):0}function ga(e){if("number"==typeof e)return e;if(aa(e))return p;if(Qo(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Qo(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Jt(e);var r=ge.test(e);return r||me.test(e)?ht(e.slice(2),r?2:8):de.test(e)?p:+e}function ya(e){return xi(e,Ca(e))}function ma(e){return null==e?"":ci(e)}var va=Ci((function(e,t){if(Es(t)||Vo(t))xi(t,Ta(t),e);else for(var r in t)ke.call(t,r)&&Qr(e,r,t[r])})),ba=Ci((function(e,t){xi(t,Ca(t),e)})),wa=Ci((function(e,t,r,n){xi(t,Ca(t),e,n)})),_a=Ci((function(e,t,r,n){xi(t,Ta(t),e,n)})),Ea=ts(sn);var Sa=Yn((function(e,t){e=Pe(e);var n=-1,i=t.length,s=i>2?t[2]:r;for(s&&vs(t[0],t[1],s)&&(i=1);++n<i;)for(var o=t[n],a=Ca(o),c=-1,u=a.length;++c<u;){var h=a[c],l=e[h];(l===r||Do(l,je[h])&&!ke.call(e,h))&&(e[h]=o[h])}return e})),Ia=Yn((function(e){return e.push(r,Zi),Ot(Ra,r,e)}));function Oa(e,t,n){var i=null==e?r:En(e,t);return i===r?n:i}function Pa(e,t){return null!=e&&ds(e,t,An)}var Aa=zi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=$e.call(t)),e[t]=r}),Qa(rc)),Na=zi((function(e,t,r){null!=t&&"function"!=typeof t.toString&&(t=$e.call(t)),ke.call(e,t)?e[t].push(r):e[t]=[r]}),as),xa=Yn(xn);function Ta(e){return Vo(e)?Gr(e):kn(e)}function Ca(e){return Vo(e)?Gr(e,!0):Mn(e)}var ja=Ci((function(e,t,r){qn(e,t,r)})),Ra=Ci((function(e,t,r,n){qn(e,t,r,n)})),La=ts((function(e,t){var r={};if(null==e)return r;var n=!1;t=Rt(t,(function(t){return t=vi(t,e),n||(n=t.length>1),t})),xi(e,ns(e),r),n&&(r=an(r,7,Qi));for(var i=t.length;i--;)hi(r,t[i]);return r}));var ka=ts((function(e,t){return null==e?{}:function(e,t){return Bn(e,t,(function(t,r){return Pa(e,r)}))}(e,t)}));function Ma(e,t){if(null==e)return{};var r=Rt(ns(e),(function(e){return[e]}));return t=as(t),Bn(e,r,(function(e,r){return t(e,r[0])}))}var Ua=Yi(Ta),$a=Yi(Ca);function Da(e){return null==e?[]:Zt(e,Ta(e))}var za=ki((function(e,t,r){return t=t.toLowerCase(),e+(r?qa(t):t)}));function qa(e){return Ya(ma(e).toLowerCase())}function Ha(e){return(e=ma(e))&&e.replace(be,rr).replace(Qe,"")}var Ka=ki((function(e,t,r){return e+(r?"-":"")+t.toLowerCase()})),Ba=ki((function(e,t,r){return e+(r?" ":"")+t.toLowerCase()})),Va=Li("toLowerCase");var Fa=ki((function(e,t,r){return e+(r?"_":"")+t.toLowerCase()}));var Wa=ki((function(e,t,r){return e+(r?" ":"")+Ya(t)}));var Ga=ki((function(e,t,r){return e+(r?" ":"")+t.toUpperCase()})),Ya=Li("toUpperCase");function Ja(e,t,n){return e=ma(e),(t=n?r:t)===r?function(e){return nt.test(e)}(e)?function(e){return e.match(tt)||[]}(e):function(e){return e.match(ue)||[]}(e):e.match(t)||[]}var Xa=Yn((function(e,t){try{return Ot(e,r,t)}catch(e){return Yo(e)?e:new Se(e)}})),Za=ts((function(e,t){return At(t,(function(t){t=ks(t),nn(e,t,No(e[t],e))})),e}));function Qa(e){return function(){return e}}var ec=$i(),tc=$i(!0);function rc(e){return e}function nc(e){return Ln("function"==typeof e?e:an(e,1))}var ic=Yn((function(e,t){return function(r){return xn(r,e,t)}})),sc=Yn((function(e,t){return function(r){return xn(e,r,t)}}));function oc(e,t,r){var n=Ta(t),i=_n(t,n);null==r&&(!Qo(t)||!i.length&&n.length)&&(r=t,t=e,e=this,i=_n(t,Ta(t)));var s=!(Qo(r)&&"chain"in r&&!r.chain),o=Jo(e);return At(i,(function(r){var n=t[r];e[r]=n,o&&(e.prototype[r]=function(){var t=this.__chain__;if(s||t){var r=e(this.__wrapped__);return(r.__actions__=Ni(this.__actions__)).push({func:n,args:arguments,thisArg:e}),r.__chain__=t,r}return n.apply(e,Lt([this.value()],arguments))})})),e}function ac(){}var cc=Hi(Rt),uc=Hi(xt),hc=Hi(Ut);function lc(e){return bs(e)?Vt(ks(e)):function(e){return function(t){return En(t,e)}}(e)}var fc=Bi(),pc=Bi(!0);function dc(){return[]}function gc(){return!1}var yc=qi((function(e,t){return e+t}),0),mc=Wi("ceil"),vc=qi((function(e,t){return e/t}),1),bc=Wi("floor");var wc=qi((function(e,t){return e*t}),1),_c=Wi("round"),Ec=qi((function(e,t){return e-t}),0);return $r.after=function(e,t){if("function"!=typeof t)throw new xe(n);return e=pa(e),function(){if(--e<1)return t.apply(this,arguments)}},$r.ary=Po,$r.assign=va,$r.assignIn=ba,$r.assignInWith=wa,$r.assignWith=_a,$r.at=Ea,$r.before=Ao,$r.bind=No,$r.bindAll=Za,$r.bindKey=xo,$r.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Ko(e)?e:[e]},$r.chain=ho,$r.chunk=function(e,t,n){t=(n?vs(e,t,n):t===r)?1:yr(pa(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var s=0,o=0,a=se(dt(i/t));s<i;)a[o++]=ri(e,s,s+=t);return a},$r.compact=function(e){for(var t=-1,r=null==e?0:e.length,n=0,i=[];++t<r;){var s=e[t];s&&(i[n++]=s)}return i},$r.concat=function(){var e=arguments.length;if(!e)return[];for(var t=se(e-1),r=arguments[0],n=e;n--;)t[n-1]=arguments[n];return Lt(Ko(r)?Ni(r):[r],yn(t,1))},$r.cond=function(e){var t=null==e?0:e.length,r=as();return e=t?Rt(e,(function(e){if("function"!=typeof e[1])throw new xe(n);return[r(e[0]),e[1]]})):[],Yn((function(r){for(var n=-1;++n<t;){var i=e[n];if(Ot(i[0],this,r))return Ot(i[1],this,r)}}))},$r.conforms=function(e){return function(e){var t=Ta(e);return function(r){return cn(r,e,t)}}(an(e,1))},$r.constant=Qa,$r.countBy=po,$r.create=function(e,t){var r=Dr(e);return null==t?r:rn(r,t)},$r.curry=function e(t,n,i){var s=Ji(t,8,r,r,r,r,r,n=i?r:n);return s.placeholder=e.placeholder,s},$r.curryRight=function e(t,n,i){var s=Ji(t,o,r,r,r,r,r,n=i?r:n);return s.placeholder=e.placeholder,s},$r.debounce=To,$r.defaults=Sa,$r.defaultsDeep=Ia,$r.defer=Co,$r.delay=jo,$r.difference=$s,$r.differenceBy=Ds,$r.differenceWith=zs,$r.drop=function(e,t,n){var i=null==e?0:e.length;return i?ri(e,(t=n||t===r?1:pa(t))<0?0:t,i):[]},$r.dropRight=function(e,t,n){var i=null==e?0:e.length;return i?ri(e,0,(t=i-(t=n||t===r?1:pa(t)))<0?0:t):[]},$r.dropRightWhile=function(e,t){return e&&e.length?fi(e,as(t,3),!0,!0):[]},$r.dropWhile=function(e,t){return e&&e.length?fi(e,as(t,3),!0):[]},$r.fill=function(e,t,n,i){var s=null==e?0:e.length;return s?(n&&"number"!=typeof n&&vs(e,t,n)&&(n=0,i=s),function(e,t,n,i){var s=e.length;for((n=pa(n))<0&&(n=-n>s?0:s+n),(i=i===r||i>s?s:pa(i))<0&&(i+=s),i=n>i?0:da(i);n<i;)e[n++]=t;return e}(e,t,n,i)):[]},$r.filter=function(e,t){return(Ko(e)?Tt:gn)(e,as(t,3))},$r.flatMap=function(e,t){return yn(Eo(e,t),1)},$r.flatMapDeep=function(e,t){return yn(Eo(e,t),l)},$r.flatMapDepth=function(e,t,n){return n=n===r?1:pa(n),yn(Eo(e,t),n)},$r.flatten=Ks,$r.flattenDeep=function(e){return(null==e?0:e.length)?yn(e,l):[]},$r.flattenDepth=function(e,t){return(null==e?0:e.length)?yn(e,t=t===r?1:pa(t)):[]},$r.flip=function(e){return Ji(e,512)},$r.flow=ec,$r.flowRight=tc,$r.fromPairs=function(e){for(var t=-1,r=null==e?0:e.length,n={};++t<r;){var i=e[t];n[i[0]]=i[1]}return n},$r.functions=function(e){return null==e?[]:_n(e,Ta(e))},$r.functionsIn=function(e){return null==e?[]:_n(e,Ca(e))},$r.groupBy=bo,$r.initial=function(e){return(null==e?0:e.length)?ri(e,0,-1):[]},$r.intersection=Vs,$r.intersectionBy=Fs,$r.intersectionWith=Ws,$r.invert=Aa,$r.invertBy=Na,$r.invokeMap=wo,$r.iteratee=nc,$r.keyBy=_o,$r.keys=Ta,$r.keysIn=Ca,$r.map=Eo,$r.mapKeys=function(e,t){var r={};return t=as(t,3),bn(e,(function(e,n,i){nn(r,t(e,n,i),e)})),r},$r.mapValues=function(e,t){var r={};return t=as(t,3),bn(e,(function(e,n,i){nn(r,n,t(e,n,i))})),r},$r.matches=function(e){return Dn(an(e,1))},$r.matchesProperty=function(e,t){return zn(e,an(t,1))},$r.memoize=Ro,$r.merge=ja,$r.mergeWith=Ra,$r.method=ic,$r.methodOf=sc,$r.mixin=oc,$r.negate=Lo,$r.nthArg=function(e){return e=pa(e),Yn((function(t){return Hn(t,e)}))},$r.omit=La,$r.omitBy=function(e,t){return Ma(e,Lo(as(t)))},$r.once=function(e){return Ao(2,e)},$r.orderBy=function(e,t,n,i){return null==e?[]:(Ko(t)||(t=null==t?[]:[t]),Ko(n=i?r:n)||(n=null==n?[]:[n]),Kn(e,t,n))},$r.over=cc,$r.overArgs=ko,$r.overEvery=uc,$r.overSome=hc,$r.partial=Mo,$r.partialRight=Uo,$r.partition=So,$r.pick=ka,$r.pickBy=Ma,$r.property=lc,$r.propertyOf=function(e){return function(t){return null==e?r:En(e,t)}},$r.pull=Ys,$r.pullAll=Js,$r.pullAllBy=function(e,t,r){return e&&e.length&&t&&t.length?Vn(e,t,as(r,2)):e},$r.pullAllWith=function(e,t,n){return e&&e.length&&t&&t.length?Vn(e,t,r,n):e},$r.pullAt=Xs,$r.range=fc,$r.rangeRight=pc,$r.rearg=$o,$r.reject=function(e,t){return(Ko(e)?Tt:gn)(e,Lo(as(t,3)))},$r.remove=function(e,t){var r=[];if(!e||!e.length)return r;var n=-1,i=[],s=e.length;for(t=as(t,3);++n<s;){var o=e[n];t(o,n,e)&&(r.push(o),i.push(n))}return Fn(e,i),r},$r.rest=function(e,t){if("function"!=typeof e)throw new xe(n);return Yn(e,t=t===r?t:pa(t))},$r.reverse=Zs,$r.sampleSize=function(e,t,n){return t=(n?vs(e,t,n):t===r)?1:pa(t),(Ko(e)?Jr:Xn)(e,t)},$r.set=function(e,t,r){return null==e?e:Zn(e,t,r)},$r.setWith=function(e,t,n,i){return i="function"==typeof i?i:r,null==e?e:Zn(e,t,n,i)},$r.shuffle=function(e){return(Ko(e)?Xr:ti)(e)},$r.slice=function(e,t,n){var i=null==e?0:e.length;return i?(n&&"number"!=typeof n&&vs(e,t,n)?(t=0,n=i):(t=null==t?0:pa(t),n=n===r?i:pa(n)),ri(e,t,n)):[]},$r.sortBy=Io,$r.sortedUniq=function(e){return e&&e.length?oi(e):[]},$r.sortedUniqBy=function(e,t){return e&&e.length?oi(e,as(t,2)):[]},$r.split=function(e,t,n){return n&&"number"!=typeof n&&vs(e,t,n)&&(t=n=r),(n=n===r?d:n>>>0)?(e=ma(e))&&("string"==typeof t||null!=t&&!ia(t))&&(!(t=ci(t))&&sr(e))?wi(lr(e),0,n):e.split(t,n):[]},$r.spread=function(e,t){if("function"!=typeof e)throw new xe(n);return t=null==t?0:yr(pa(t),0),Yn((function(r){var n=r[t],i=wi(r,0,t);return n&&Lt(i,n),Ot(e,this,i)}))},$r.tail=function(e){var t=null==e?0:e.length;return t?ri(e,1,t):[]},$r.take=function(e,t,n){return e&&e.length?ri(e,0,(t=n||t===r?1:pa(t))<0?0:t):[]},$r.takeRight=function(e,t,n){var i=null==e?0:e.length;return i?ri(e,(t=i-(t=n||t===r?1:pa(t)))<0?0:t,i):[]},$r.takeRightWhile=function(e,t){return e&&e.length?fi(e,as(t,3),!1,!0):[]},$r.takeWhile=function(e,t){return e&&e.length?fi(e,as(t,3)):[]},$r.tap=function(e,t){return t(e),e},$r.throttle=function(e,t,r){var i=!0,s=!0;if("function"!=typeof e)throw new xe(n);return Qo(r)&&(i="leading"in r?!!r.leading:i,s="trailing"in r?!!r.trailing:s),To(e,t,{leading:i,maxWait:t,trailing:s})},$r.thru=lo,$r.toArray=la,$r.toPairs=Ua,$r.toPairsIn=$a,$r.toPath=function(e){return Ko(e)?Rt(e,ks):aa(e)?[e]:Ni(Ls(ma(e)))},$r.toPlainObject=ya,$r.transform=function(e,t,r){var n=Ko(e),i=n||Wo(e)||ca(e);if(t=as(t,4),null==r){var s=e&&e.constructor;r=i?n?new s:[]:Qo(e)&&Jo(s)?Dr(Fe(e)):{}}return(i?At:bn)(e,(function(e,n,i){return t(r,e,n,i)})),r},$r.unary=function(e){return Po(e,1)},$r.union=Qs,$r.unionBy=eo,$r.unionWith=to,$r.uniq=function(e){return e&&e.length?ui(e):[]},$r.uniqBy=function(e,t){return e&&e.length?ui(e,as(t,2)):[]},$r.uniqWith=function(e,t){return t="function"==typeof t?t:r,e&&e.length?ui(e,r,t):[]},$r.unset=function(e,t){return null==e||hi(e,t)},$r.unzip=ro,$r.unzipWith=no,$r.update=function(e,t,r){return null==e?e:li(e,t,mi(r))},$r.updateWith=function(e,t,n,i){return i="function"==typeof i?i:r,null==e?e:li(e,t,mi(n),i)},$r.values=Da,$r.valuesIn=function(e){return null==e?[]:Zt(e,Ca(e))},$r.without=io,$r.words=Ja,$r.wrap=function(e,t){return Mo(mi(t),e)},$r.xor=so,$r.xorBy=oo,$r.xorWith=ao,$r.zip=co,$r.zipObject=function(e,t){return gi(e||[],t||[],Qr)},$r.zipObjectDeep=function(e,t){return gi(e||[],t||[],Zn)},$r.zipWith=uo,$r.entries=Ua,$r.entriesIn=$a,$r.extend=ba,$r.extendWith=wa,oc($r,$r),$r.add=yc,$r.attempt=Xa,$r.camelCase=za,$r.capitalize=qa,$r.ceil=mc,$r.clamp=function(e,t,n){return n===r&&(n=t,t=r),n!==r&&(n=(n=ga(n))==n?n:0),t!==r&&(t=(t=ga(t))==t?t:0),on(ga(e),t,n)},$r.clone=function(e){return an(e,4)},$r.cloneDeep=function(e){return an(e,5)},$r.cloneDeepWith=function(e,t){return an(e,5,t="function"==typeof t?t:r)},$r.cloneWith=function(e,t){return an(e,4,t="function"==typeof t?t:r)},$r.conformsTo=function(e,t){return null==t||cn(e,t,Ta(t))},$r.deburr=Ha,$r.defaultTo=function(e,t){return null==e||e!=e?t:e},$r.divide=vc,$r.endsWith=function(e,t,n){e=ma(e),t=ci(t);var i=e.length,s=n=n===r?i:on(pa(n),0,i);return(n-=t.length)>=0&&e.slice(n,s)==t},$r.eq=Do,$r.escape=function(e){return(e=ma(e))&&Y.test(e)?e.replace(W,nr):e},$r.escapeRegExp=function(e){return(e=ma(e))&&ne.test(e)?e.replace(re,"\\$&"):e},$r.every=function(e,t,n){var i=Ko(e)?xt:pn;return n&&vs(e,t,n)&&(t=r),i(e,as(t,3))},$r.find=go,$r.findIndex=qs,$r.findKey=function(e,t){return Dt(e,as(t,3),bn)},$r.findLast=yo,$r.findLastIndex=Hs,$r.findLastKey=function(e,t){return Dt(e,as(t,3),wn)},$r.floor=bc,$r.forEach=mo,$r.forEachRight=vo,$r.forIn=function(e,t){return null==e?e:mn(e,as(t,3),Ca)},$r.forInRight=function(e,t){return null==e?e:vn(e,as(t,3),Ca)},$r.forOwn=function(e,t){return e&&bn(e,as(t,3))},$r.forOwnRight=function(e,t){return e&&wn(e,as(t,3))},$r.get=Oa,$r.gt=zo,$r.gte=qo,$r.has=function(e,t){return null!=e&&ds(e,t,Pn)},$r.hasIn=Pa,$r.head=Bs,$r.identity=rc,$r.includes=function(e,t,r,n){e=Vo(e)?e:Da(e),r=r&&!n?pa(r):0;var i=e.length;return r<0&&(r=yr(i+r,0)),oa(e)?r<=i&&e.indexOf(t,r)>-1:!!i&&qt(e,t,r)>-1},$r.indexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var i=null==r?0:pa(r);return i<0&&(i=yr(n+i,0)),qt(e,t,i)},$r.inRange=function(e,t,n){return t=fa(t),n===r?(n=t,t=0):n=fa(n),function(e,t,r){return e>=mr(t,r)&&e<yr(t,r)}(e=ga(e),t,n)},$r.invoke=xa,$r.isArguments=Ho,$r.isArray=Ko,$r.isArrayBuffer=Bo,$r.isArrayLike=Vo,$r.isArrayLikeObject=Fo,$r.isBoolean=function(e){return!0===e||!1===e||ea(e)&&In(e)==v},$r.isBuffer=Wo,$r.isDate=Go,$r.isElement=function(e){return ea(e)&&1===e.nodeType&&!na(e)},$r.isEmpty=function(e){if(null==e)return!0;if(Vo(e)&&(Ko(e)||"string"==typeof e||"function"==typeof e.splice||Wo(e)||ca(e)||Ho(e)))return!e.length;var t=ps(e);if(t==S||t==N)return!e.size;if(Es(e))return!kn(e).length;for(var r in e)if(ke.call(e,r))return!1;return!0},$r.isEqual=function(e,t){return Cn(e,t)},$r.isEqualWith=function(e,t,n){var i=(n="function"==typeof n?n:r)?n(e,t):r;return i===r?Cn(e,t,r,n):!!i},$r.isError=Yo,$r.isFinite=function(e){return"number"==typeof e&&$t(e)},$r.isFunction=Jo,$r.isInteger=Xo,$r.isLength=Zo,$r.isMap=ta,$r.isMatch=function(e,t){return e===t||jn(e,t,us(t))},$r.isMatchWith=function(e,t,n){return n="function"==typeof n?n:r,jn(e,t,us(t),n)},$r.isNaN=function(e){return ra(e)&&e!=+e},$r.isNative=function(e){if(_s(e))throw new Se("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Rn(e)},$r.isNil=function(e){return null==e},$r.isNull=function(e){return null===e},$r.isNumber=ra,$r.isObject=Qo,$r.isObjectLike=ea,$r.isPlainObject=na,$r.isRegExp=ia,$r.isSafeInteger=function(e){return Xo(e)&&e>=-f&&e<=f},$r.isSet=sa,$r.isString=oa,$r.isSymbol=aa,$r.isTypedArray=ca,$r.isUndefined=function(e){return e===r},$r.isWeakMap=function(e){return ea(e)&&ps(e)==C},$r.isWeakSet=function(e){return ea(e)&&"[object WeakSet]"==In(e)},$r.join=function(e,t){return null==e?"":Ft.call(e,t)},$r.kebabCase=Ka,$r.last=Gs,$r.lastIndexOf=function(e,t,n){var i=null==e?0:e.length;if(!i)return-1;var s=i;return n!==r&&(s=(s=pa(n))<0?yr(i+s,0):mr(s,i-1)),t==t?function(e,t,r){for(var n=r+1;n--;)if(e[n]===t)return n;return n}(e,t,s):zt(e,Kt,s,!0)},$r.lowerCase=Ba,$r.lowerFirst=Va,$r.lt=ua,$r.lte=ha,$r.max=function(e){return e&&e.length?dn(e,rc,On):r},$r.maxBy=function(e,t){return e&&e.length?dn(e,as(t,2),On):r},$r.mean=function(e){return Bt(e,rc)},$r.meanBy=function(e,t){return Bt(e,as(t,2))},$r.min=function(e){return e&&e.length?dn(e,rc,Un):r},$r.minBy=function(e,t){return e&&e.length?dn(e,as(t,2),Un):r},$r.stubArray=dc,$r.stubFalse=gc,$r.stubObject=function(){return{}},$r.stubString=function(){return""},$r.stubTrue=function(){return!0},$r.multiply=wc,$r.nth=function(e,t){return e&&e.length?Hn(e,pa(t)):r},$r.noConflict=function(){return pt._===this&&(pt._=ze),this},$r.noop=ac,$r.now=Oo,$r.pad=function(e,t,r){e=ma(e);var n=(t=pa(t))?hr(e):0;if(!t||n>=t)return e;var i=(t-n)/2;return Ki(gt(i),r)+e+Ki(dt(i),r)},$r.padEnd=function(e,t,r){e=ma(e);var n=(t=pa(t))?hr(e):0;return t&&n<t?e+Ki(t-n,r):e},$r.padStart=function(e,t,r){e=ma(e);var n=(t=pa(t))?hr(e):0;return t&&n<t?Ki(t-n,r)+e:e},$r.parseInt=function(e,t,r){return r||null==t?t=0:t&&(t=+t),br(ma(e).replace(ie,""),t||0)},$r.random=function(e,t,n){if(n&&"boolean"!=typeof n&&vs(e,t,n)&&(t=n=r),n===r&&("boolean"==typeof t?(n=t,t=r):"boolean"==typeof e&&(n=e,e=r)),e===r&&t===r?(e=0,t=1):(e=fa(e),t===r?(t=e,e=0):t=fa(t)),e>t){var i=e;e=t,t=i}if(n||e%1||t%1){var s=wr();return mr(e+s*(t-e+ut("1e-"+((s+"").length-1))),t)}return Wn(e,t)},$r.reduce=function(e,t,r){var n=Ko(e)?kt:Wt,i=arguments.length<3;return n(e,as(t,4),r,i,ln)},$r.reduceRight=function(e,t,r){var n=Ko(e)?Mt:Wt,i=arguments.length<3;return n(e,as(t,4),r,i,fn)},$r.repeat=function(e,t,n){return t=(n?vs(e,t,n):t===r)?1:pa(t),Gn(ma(e),t)},$r.replace=function(){var e=arguments,t=ma(e[0]);return e.length<3?t:t.replace(e[1],e[2])},$r.result=function(e,t,n){var i=-1,s=(t=vi(t,e)).length;for(s||(s=1,e=r);++i<s;){var o=null==e?r:e[ks(t[i])];o===r&&(i=s,o=n),e=Jo(o)?o.call(e):o}return e},$r.round=_c,$r.runInContext=e,$r.sample=function(e){return(Ko(e)?Yr:Jn)(e)},$r.size=function(e){if(null==e)return 0;if(Vo(e))return oa(e)?hr(e):e.length;var t=ps(e);return t==S||t==N?e.size:kn(e).length},$r.snakeCase=Fa,$r.some=function(e,t,n){var i=Ko(e)?Ut:ni;return n&&vs(e,t,n)&&(t=r),i(e,as(t,3))},$r.sortedIndex=function(e,t){return ii(e,t)},$r.sortedIndexBy=function(e,t,r){return si(e,t,as(r,2))},$r.sortedIndexOf=function(e,t){var r=null==e?0:e.length;if(r){var n=ii(e,t);if(n<r&&Do(e[n],t))return n}return-1},$r.sortedLastIndex=function(e,t){return ii(e,t,!0)},$r.sortedLastIndexBy=function(e,t,r){return si(e,t,as(r,2),!0)},$r.sortedLastIndexOf=function(e,t){if(null==e?0:e.length){var r=ii(e,t,!0)-1;if(Do(e[r],t))return r}return-1},$r.startCase=Wa,$r.startsWith=function(e,t,r){return e=ma(e),r=null==r?0:on(pa(r),0,e.length),t=ci(t),e.slice(r,r+t.length)==t},$r.subtract=Ec,$r.sum=function(e){return e&&e.length?Gt(e,rc):0},$r.sumBy=function(e,t){return e&&e.length?Gt(e,as(t,2)):0},$r.template=function(e,t,n){var i=$r.templateSettings;n&&vs(e,t,n)&&(t=r),e=ma(e),t=wa({},t,i,Xi);var s,o,a=wa({},t.imports,i.imports,Xi),c=Ta(a),u=Zt(a,c),h=0,l=t.interpolate||we,f="__p += '",p=Ae((t.escape||we).source+"|"+l.source+"|"+(l===Z?fe:we).source+"|"+(t.evaluate||we).source+"|$","g"),d="//# sourceURL="+(ke.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++st+"]")+"\n";e.replace(p,(function(t,r,n,i,a,c){return n||(n=i),f+=e.slice(h,c).replace(_e,ir),r&&(s=!0,f+="' +\n__e("+r+") +\n'"),a&&(o=!0,f+="';\n"+a+";\n__p += '"),n&&(f+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),h=c+t.length,t})),f+="';\n";var g=ke.call(t,"variable")&&t.variable;if(g){if(he.test(g))throw new Se("Invalid `variable` option passed into `_.template`")}else f="with (obj) {\n"+f+"\n}\n";f=(o?f.replace(K,""):f).replace(B,"$1").replace(V,"$1;"),f="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(s?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+f+"return __p\n}";var y=Xa((function(){return Ie(c,d+"return "+f).apply(r,u)}));if(y.source=f,Yo(y))throw y;return y},$r.times=function(e,t){if((e=pa(e))<1||e>f)return[];var r=d,n=mr(e,d);t=as(t),e-=d;for(var i=Yt(n,t);++r<e;)t(r);return i},$r.toFinite=fa,$r.toInteger=pa,$r.toLength=da,$r.toLower=function(e){return ma(e).toLowerCase()},$r.toNumber=ga,$r.toSafeInteger=function(e){return e?on(pa(e),-f,f):0===e?e:0},$r.toString=ma,$r.toUpper=function(e){return ma(e).toUpperCase()},$r.trim=function(e,t,n){if((e=ma(e))&&(n||t===r))return Jt(e);if(!e||!(t=ci(t)))return e;var i=lr(e),s=lr(t);return wi(i,er(i,s),tr(i,s)+1).join("")},$r.trimEnd=function(e,t,n){if((e=ma(e))&&(n||t===r))return e.slice(0,fr(e)+1);if(!e||!(t=ci(t)))return e;var i=lr(e);return wi(i,0,tr(i,lr(t))+1).join("")},$r.trimStart=function(e,t,n){if((e=ma(e))&&(n||t===r))return e.replace(ie,"");if(!e||!(t=ci(t)))return e;var i=lr(e);return wi(i,er(i,lr(t))).join("")},$r.truncate=function(e,t){var n=30,i="...";if(Qo(t)){var s="separator"in t?t.separator:s;n="length"in t?pa(t.length):n,i="omission"in t?ci(t.omission):i}var o=(e=ma(e)).length;if(sr(e)){var a=lr(e);o=a.length}if(n>=o)return e;var c=n-hr(i);if(c<1)return i;var u=a?wi(a,0,c).join(""):e.slice(0,c);if(s===r)return u+i;if(a&&(c+=u.length-c),ia(s)){if(e.slice(c).search(s)){var h,l=u;for(s.global||(s=Ae(s.source,ma(pe.exec(s))+"g")),s.lastIndex=0;h=s.exec(l);)var f=h.index;u=u.slice(0,f===r?c:f)}}else if(e.indexOf(ci(s),c)!=c){var p=u.lastIndexOf(s);p>-1&&(u=u.slice(0,p))}return u+i},$r.unescape=function(e){return(e=ma(e))&&G.test(e)?e.replace(F,pr):e},$r.uniqueId=function(e){var t=++Me;return ma(e)+t},$r.upperCase=Ga,$r.upperFirst=Ya,$r.each=mo,$r.eachRight=vo,$r.first=Bs,oc($r,function(){var e={};return bn($r,(function(t,r){ke.call($r.prototype,r)||(e[r]=t)})),e}(),{chain:!1}),$r.VERSION="4.17.21",At(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){$r[e].placeholder=$r})),At(["drop","take"],(function(e,t){Hr.prototype[e]=function(n){n=n===r?1:yr(pa(n),0);var i=this.__filtered__&&!t?new Hr(this):this.clone();return i.__filtered__?i.__takeCount__=mr(n,i.__takeCount__):i.__views__.push({size:mr(n,d),type:e+(i.__dir__<0?"Right":"")}),i},Hr.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),At(["filter","map","takeWhile"],(function(e,t){var r=t+1,n=1==r||3==r;Hr.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:as(e,3),type:r}),t.__filtered__=t.__filtered__||n,t}})),At(["head","last"],(function(e,t){var r="take"+(t?"Right":"");Hr.prototype[e]=function(){return this[r](1).value()[0]}})),At(["initial","tail"],(function(e,t){var r="drop"+(t?"":"Right");Hr.prototype[e]=function(){return this.__filtered__?new Hr(this):this[r](1)}})),Hr.prototype.compact=function(){return this.filter(rc)},Hr.prototype.find=function(e){return this.filter(e).head()},Hr.prototype.findLast=function(e){return this.reverse().find(e)},Hr.prototype.invokeMap=Yn((function(e,t){return"function"==typeof e?new Hr(this):this.map((function(r){return xn(r,e,t)}))})),Hr.prototype.reject=function(e){return this.filter(Lo(as(e)))},Hr.prototype.slice=function(e,t){e=pa(e);var n=this;return n.__filtered__&&(e>0||t<0)?new Hr(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),t!==r&&(n=(t=pa(t))<0?n.dropRight(-t):n.take(t-e)),n)},Hr.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Hr.prototype.toArray=function(){return this.take(d)},bn(Hr.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),i=/^(?:head|last)$/.test(t),s=$r[i?"take"+("last"==t?"Right":""):t],o=i||/^find/.test(t);s&&($r.prototype[t]=function(){var t=this.__wrapped__,a=i?[1]:arguments,c=t instanceof Hr,u=a[0],h=c||Ko(t),l=function(e){var t=s.apply($r,Lt([e],a));return i&&f?t[0]:t};h&&n&&"function"==typeof u&&1!=u.length&&(c=h=!1);var f=this.__chain__,p=!!this.__actions__.length,d=o&&!f,g=c&&!p;if(!o&&h){t=g?t:new Hr(this);var y=e.apply(t,a);return y.__actions__.push({func:lo,args:[l],thisArg:r}),new qr(y,f)}return d&&g?e.apply(this,a):(y=this.thru(l),d?i?y.value()[0]:y.value():y)})})),At(["pop","push","shift","sort","splice","unshift"],(function(e){var t=Te[e],r=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",n=/^(?:pop|shift)$/.test(e);$r.prototype[e]=function(){var e=arguments;if(n&&!this.__chain__){var i=this.value();return t.apply(Ko(i)?i:[],e)}return this[r]((function(r){return t.apply(Ko(r)?r:[],e)}))}})),bn(Hr.prototype,(function(e,t){var r=$r[t];if(r){var n=r.name+"";ke.call(xr,n)||(xr[n]=[]),xr[n].push({name:t,func:r})}})),xr[Di(r,2).name]=[{name:"wrapper",func:r}],Hr.prototype.clone=function(){var e=new Hr(this.__wrapped__);return e.__actions__=Ni(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Ni(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Ni(this.__views__),e},Hr.prototype.reverse=function(){if(this.__filtered__){var e=new Hr(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Hr.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,r=Ko(e),n=t<0,i=r?e.length:0,s=function(e,t,r){for(var n=-1,i=r.length;++n<i;){var s=r[n],o=s.size;switch(s.type){case"drop":e+=o;break;case"dropRight":t-=o;break;case"take":t=mr(t,e+o);break;case"takeRight":e=yr(e,t-o)}}return{start:e,end:t}}(0,i,this.__views__),o=s.start,a=s.end,c=a-o,u=n?a:o-1,h=this.__iteratees__,l=h.length,f=0,p=mr(c,this.__takeCount__);if(!r||!n&&i==c&&p==c)return pi(e,this.__actions__);var d=[];e:for(;c--&&f<p;){for(var g=-1,y=e[u+=t];++g<l;){var m=h[g],v=m.iteratee,b=m.type,w=v(y);if(2==b)y=w;else if(!w){if(1==b)continue e;break e}}d[f++]=y}return d},$r.prototype.at=fo,$r.prototype.chain=function(){return ho(this)},$r.prototype.commit=function(){return new qr(this.value(),this.__chain__)},$r.prototype.next=function(){this.__values__===r&&(this.__values__=la(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?r:this.__values__[this.__index__++]}},$r.prototype.plant=function(e){for(var t,n=this;n instanceof zr;){var i=Us(n);i.__index__=0,i.__values__=r,t?s.__wrapped__=i:t=i;var s=i;n=n.__wrapped__}return s.__wrapped__=e,t},$r.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Hr){var t=e;return this.__actions__.length&&(t=new Hr(this)),(t=t.reverse()).__actions__.push({func:lo,args:[Zs],thisArg:r}),new qr(t,this.__chain__)}return this.thru(Zs)},$r.prototype.toJSON=$r.prototype.valueOf=$r.prototype.value=function(){return pi(this.__wrapped__,this.__actions__)},$r.prototype.first=$r.prototype.head,Xe&&($r.prototype[Xe]=function(){return this}),$r}();gt?((gt.exports=dr)._=dr,dt._=dr):pt._=dr}).call(_l)}(El,El.exports);var Sl=Object.defineProperty,Il=Object.defineProperties,Ol=Object.getOwnPropertyDescriptors,Pl=Object.getOwnPropertySymbols,Al=Object.prototype.hasOwnProperty,Nl=Object.prototype.propertyIsEnumerable,xl=(e,t,r)=>t in e?Sl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Tl=(e,t)=>{for(var r in t||(t={}))Al.call(t,r)&&xl(e,r,t[r]);if(Pl)for(var r of Pl(t))Nl.call(t,r)&&xl(e,r,t[r]);return e},Cl=(e,t)=>Il(e,Ol(t));function jl(e,t,r){let n;const i=Rl(e);return t.rpcMap&&(n=t.rpcMap[i]),n||(n=`https://rpc.walletconnect.com/v1?chainId=eip155:${i}&projectId=${r}`),n}function Rl(e){return e.includes("eip155")?Number(e.split(":")[1]):Number(e)}function Ll(e){return e.map((e=>`${e.split(":")[0]}:${e.split(":")[1]}`))}function kl(e){var t,r,n,i;const s={};if(!ei(e))return s;for(const[o,a]of Object.entries(e)){const e=Wn(o)?[o]:a.chains,c=a.methods||[],u=a.events||[],h=a.rpcMap||{},l=Gn(o);s[l]=Cl(Tl(Tl({},s[l]),a),{chains:kn(e,null==(t=s[l])?void 0:t.chains),methods:kn(c,null==(r=s[l])?void 0:r.methods),events:kn(u,null==(n=s[l])?void 0:n.events),rpcMap:Tl(Tl({},h),null==(i=s[l])?void 0:i.rpcMap)})}return s}function Ml(e){return e.includes(":")?e.split(":")[2]:e}function Ul(e){const t={};for(const[r,n]of Object.entries(e)){const e=n.methods||[],i=n.events||[],s=n.accounts||[],o=Wn(r)?[r]:n.chains?n.chains:Ll(n.accounts);t[r]={chains:o,methods:e,events:i,accounts:s}}return t}const $l={},Dl=e=>$l[e],zl=(e,t)=>{$l[e]=t};class ql{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=Dl("events"),this.client=Dl("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const r=t||jl(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(wl,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2]))||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;e[t]=this.createHttpProvider(t,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||jl(e,this.namespace);return typeof r>"u"?void 0:new Ka(new ml(r,Dl("disableProviderPing")))}}class Hl{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=Dl("events"),this.client=Dl("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){const r=Rl(e);if(!this.httpProviders[r]){const e=t||jl(`${this.name}:${r}`,this.namespace,this.client.core.projectId);if(!e)throw new Error(`No RPC url provided for chainId: ${r}`);this.setHttpProvider(r,e)}this.chainId=r,this.events.emit(wl,`${this.name}:${r}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const r=t||jl(`${this.name}:${e}`,this.namespace,this.client.core.projectId);return typeof r>"u"?void 0:new Ka(new ml(r,Dl("disableProviderPing")))}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;const n=Rl(t);e[n]=this.createHttpProvider(n,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,r;let n=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0";n=n.startsWith("0x")?n:`0x${n}`;const i=parseInt(n,16);if(this.isChainApproved(i))this.setDefaultChain(`${i}`);else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${i}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:n}]},chainId:null==(r=this.namespace.chains)?void 0:r[0]}),this.setDefaultChain(`${i}`)}return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}}class Kl{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=Dl("events"),this.client=Dl("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const r=t||jl(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.chainId=e,this.events.emit(wl,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;e[t]=this.createHttpProvider(t,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||jl(e,this.namespace,this.client.core.projectId);return typeof r>"u"?void 0:new Ka(new ml(r,Dl("disableProviderPing")))}}class Bl{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=Dl("events"),this.client=Dl("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const r=t||jl(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(wl,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;e[t]=this.createHttpProvider(t,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||jl(e,this.namespace,this.client.core.projectId);return typeof r>"u"?void 0:new Ka(new ml(r,Dl("disableProviderPing")))}}class Vl{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=Dl("events"),this.client=Dl("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const r=t||this.getCardanoRPCUrl(e);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(wl,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{const r=this.getCardanoRPCUrl(t);e[t]=this.createHttpProvider(t,r)})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||this.getCardanoRPCUrl(e);return typeof r>"u"?void 0:new Ka(new ml(r,Dl("disableProviderPing")))}}class Fl{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=Dl("events"),this.client=Dl("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const r=t||jl(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.chainId=e,this.events.emit(wl,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;e[t]=this.createHttpProvider(t,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||jl(e,this.namespace,this.client.core.projectId);return typeof r>"u"?void 0:new Ka(new ml(r,Dl("disableProviderPing")))}}class Wl{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=Dl("events"),this.client=Dl("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const r=t||jl(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.chainId=e,this.events.emit(wl,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;e[t]=this.createHttpProvider(t,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||jl(e,this.namespace,this.client.core.projectId);return typeof r>"u"?void 0:new Ka(new ml(r,Dl("disableProviderPing")))}}var Gl=Object.defineProperty,Yl=Object.defineProperties,Jl=Object.getOwnPropertyDescriptors,Xl=Object.getOwnPropertySymbols,Zl=Object.prototype.hasOwnProperty,Ql=Object.prototype.propertyIsEnumerable,ef=(e,t,r)=>t in e?Gl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,tf=(e,t)=>{for(var r in t||(t={}))Zl.call(t,r)&&ef(e,r,t[r]);if(Xl)for(var r of Xl(t))Ql.call(t,r)&&ef(e,r,t[r]);return e},rf=(e,t)=>Yl(e,Jl(t));class nf{constructor(e){this.events=new y.default,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:Cs.pino(Cs.getDefaultLoggerOptions({level:e?.logger||vl})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const t=new nf(e);return await t.initialize(),t}async request(e,t){const[r,n]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(r).request({request:tf({},e),chainId:`${r}:${n}`,topic:this.session.topic})}sendAsync(e,t,r){this.request(e,r).then((e=>t(null,e))).catch((e=>t(e,void 0)))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(e=this.session)?void 0:e.topic,reason:Zn("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let t=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(t>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:r,approval:n}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});r&&(this.uri=r,this.events.emit("display_uri",r)),await n().then((e=>{this.session=e,this.namespaces||(this.namespaces=Ul(e.namespaces),this.persist("namespaces",this.namespaces))})).catch((e=>{if(e.message!==Xh)throw e;t++}))}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[r,n]=this.validateChain(e);this.getProvider(r).setDefaultChain(n,t)}catch(e){if(!/Please call connect/.test(e.message))throw e}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(Qn(t)){for(const r of t)e.deletePairings?this.client.core.expirer.set(r.topic,0):await this.client.core.relayer.subscriber.unsubscribe(r.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await gl.init({logger:this.providerOpts.logger||vl,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.com",projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map((e=>Gn(e))))];zl("client",this.client),zl("events",this.events),zl("disableProviderPing",this.disableProviderPing),e.forEach((e=>{if(!this.session)return;const t=function(e,t){const r=Object.keys(t.namespaces).filter((t=>t.includes(e)));if(!r.length)return[];const n=[];return r.forEach((e=>{const r=t.namespaces[e].accounts;n.push(...r)})),n}(e,this.session),r=Ll(t),n=function(e={},t={}){const r=kl(e),n=kl(t);return El.exports.merge(r,n)}(this.namespaces,this.optionalNamespaces),i=rf(tf({},n[e]),{accounts:t,chains:r});switch(e){case"eip155":this.rpcProviders[e]=new Hl({namespace:i});break;case"solana":this.rpcProviders[e]=new Kl({namespace:i});break;case"cosmos":this.rpcProviders[e]=new Bl({namespace:i});break;case"polkadot":this.rpcProviders[e]=new ql({namespace:i});break;case"cip34":this.rpcProviders[e]=new Vl({namespace:i});break;case"elrond":this.rpcProviders[e]=new Fl({namespace:i});break;case"multiversx":this.rpcProviders[e]=new Wl({namespace:i})}}))}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",(e=>{this.events.emit("session_ping",e)})),this.client.on("session_event",(e=>{const{params:t}=e,{event:r}=t;if("accountsChanged"===r.name){const e=r.data;e&&Qn(e)&&this.events.emit("accountsChanged",e.map(Ml))}else"chainChanged"===r.name?this.onChainChanged(t.chainId):this.events.emit(r.name,r.data);this.events.emit("session_event",e)})),this.client.on("session_update",(({topic:e,params:t})=>{var r;const{namespaces:n}=t,i=null==(r=this.client)?void 0:r.session.get(e);this.session=rf(tf({},i),{namespaces:n}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})})),this.client.on("session_delete",(async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",rf(tf({},Zn("USER_DISCONNECTED")),{data:e.topic}))})),this.on(wl,(e=>{this.onChainChanged(e,!0)}))}getProvider(e){if(!this.rpcProviders[e])throw new Error(`Provider not found: ${e}`);return this.rpcProviders[e]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach((e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])}))}setNamespaces(e){const{namespaces:t,optionalNamespaces:r,sessionProperties:n}=e;t&&Object.keys(t).length&&(this.namespaces=t),r&&Object.keys(r).length&&(this.optionalNamespaces=r),this.sessionProperties=n,this.persist("namespaces",t),this.persist("optionalNamespaces",r)}validateChain(e){const[t,r]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,r];if(t&&!Object.keys(this.namespaces||{}).map((e=>Gn(e))).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&r)return[t,r];const n=Gn(Object.keys(this.namespaces)[0]);return[n,this.rpcProviders[n].getDefaultChain()]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){var r;if(!this.namespaces)return;const[n,i]=this.validateChain(e);t||this.getProvider(n).setDefaultChain(i),(null!=(r=this.namespaces[n])?r:this.namespaces[`${n}:${i}`]).defaultChain=i,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",i)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${bl}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${bl}/${e}`)}}const sf=nf,of=["eth_sendTransaction","personal_sign"],af=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],cf=["chainChanged","accountsChanged"],uf=["message","disconnect","connect"];var hf=Object.defineProperty,lf=Object.defineProperties,ff=Object.getOwnPropertyDescriptors,pf=Object.getOwnPropertySymbols,df=Object.prototype.hasOwnProperty,gf=Object.prototype.propertyIsEnumerable,yf=(e,t,r)=>t in e?hf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,mf=(e,t)=>{for(var r in t||(t={}))df.call(t,r)&&yf(e,r,t[r]);if(pf)for(var r of pf(t))gf.call(t,r)&&yf(e,r,t[r]);return e},vf=(e,t)=>lf(e,ff(t));function bf(e){return Number(e[0].split(":")[1])}function wf(e){return`0x${e.toString(16)}`}class _f{constructor(){this.events=new e.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY="wc@2:ethereum_provider:",this.on=(e,t)=>(this.events.on(e,t),this),this.once=(e,t)=>(this.events.once(e,t),this),this.removeListener=(e,t)=>(this.events.removeListener(e,t),this),this.off=(e,t)=>(this.events.off(e,t),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const t=new _f;return await t.initialize(e),t}async request(e){return await this.signer.request(e,this.formatChainId(this.chainId))}sendAsync(e,t){this.signer.sendAsync(e,t,this.formatChainId(this.chainId))}get connected(){return!!this.signer.client&&this.signer.client.core.relayer.connected}get connecting(){return!!this.signer.client&&this.signer.client.core.relayer.connecting}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:t,optional:r}=function(e){const{chains:t,optionalChains:r,methods:n,optionalMethods:i,events:s,optionalEvents:o,rpcMap:a}=e;if(!Qn(t))throw new Error("Invalid chains");const c={chains:t,methods:n||of,events:s||cf,rpcMap:mf({},t.length?{[bf(t)]:a[bf(t)]}:{})},u=s?.filter((e=>!cf.includes(e))),h=n?.filter((e=>!of.includes(e)));if(!(r||o||i||null!=u&&u.length||null!=h&&h.length))return{required:t.length?c:void 0};const l={chains:[...new Set(u?.length&&h?.length||!r?c.chains.concat(r||[]):r)],methods:[...new Set(c.methods.concat(null!=i&&i.length?i:af))],events:[...new Set(c.events.concat(o||uf))],rpcMap:a};return{required:t.length?c:void 0,optional:r.length?l:void 0}}(this.rpc);try{const n=await new Promise((async(n,i)=>{var s;this.rpc.showQrModal&&(null==(s=this.modal)||s.subscribeModal((e=>{!e.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),i(new Error("Connection request reset. Please try again.")))}))),await this.signer.connect(vf(mf({namespaces:mf({},t&&{[this.namespace]:t})},r&&{optionalNamespaces:{[this.namespace]:r}}),{pairingTopic:e?.pairingTopic})).then((e=>{n(e)})).catch((e=>{i(new Error(e.message))}))}));if(!n)return;this.setChainIds(this.rpc.chains);const i=function(e,t=[]){const r=[];return Object.keys(e).forEach((n=>{if(t.length&&!t.includes(n))return;const i=e[n];r.push(...i.accounts)})),r}(n.namespaces,[this.namespace]);this.setAccounts(i),this.events.emit("connect",{chainId:wf(this.chainId)})}catch(e){throw this.signer.logger.error(e),e}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",(e=>{const{params:t}=e,{event:r}=t;"accountsChanged"===r.name?(this.accounts=this.parseAccounts(r.data),this.events.emit("accountsChanged",this.accounts)):"chainChanged"===r.name?this.setChainId(this.formatChainId(r.data)):this.events.emit(r.name,r.data),this.events.emit("session_event",e)})),this.signer.on("chainChanged",(e=>{const t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",wf(this.chainId)),this.persist()})),this.signer.on("session_update",(e=>{this.events.emit("session_update",e)})),this.signer.on("session_delete",(e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",vf(mf({},Zn("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))})),this.signer.on("display_uri",(e=>{var t,r;this.rpc.showQrModal&&(null==(t=this.modal)||t.closeModal(),null==(r=this.modal)||r.openModal({uri:e})),this.events.emit("display_uri",e)}))}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return"string"==typeof e&&e.startsWith(`${this.namespace}:`)}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const t=e.filter((e=>this.isCompatibleChainId(e))).map((e=>this.parseChainId(e)));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",wf(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){const[t,r,n]=e.split(":");return{chainId:`${t}:${r}`,address:n}}setAccounts(e){this.accounts=e.filter((e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId)).map((e=>this.parseAccountId(e).address)),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,r;const n=null!=(t=e?.chains)?t:[],i=null!=(r=e?.optionalChains)?r:[],s=n.concat(i);if(!s.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const o=n.length?e?.methods||of:[],a=n.length?e?.events||cf:[],c=e?.optionalMethods||[],u=e?.optionalEvents||[],h=e?.rpcMap||this.buildRpcMap(s,e.projectId),l=e?.qrModalOptions||void 0;return{chains:n?.map((e=>this.formatChainId(e))),optionalChains:i.map((e=>this.formatChainId(e))),methods:o,events:a,optionalMethods:c,optionalEvents:u,rpcMap:h,showQrModal:!(null==e||!e.showQrModal),qrModalOptions:l,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){const r={};return e.forEach((e=>{r[e]=this.getRpcUrl(e,t)})),r}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?bf(this.rpc.chains):bf(this.rpc.optionalChains),this.signer=await sf.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let e;try{const{WalletConnectModal:t}=await Promise.resolve().then((function(){return require("./index-3d1a3da9.cjs")})).then((function(e){return e.index}));e=t}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(e)try{this.modal=new e(mf({walletConnectVersion:2,projectId:this.rpc.projectId,standaloneChains:this.rpc.chains},this.rpc.qrModalOptions))}catch(e){throw this.signer.logger.error(e),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:t,optionalChains:r,rpcMap:n}=e;t&&Qn(t)&&(this.rpc.chains=t.map((e=>this.formatChainId(e))),t.forEach((e=>{this.rpc.rpcMap[e]=n?.[e]||this.getRpcUrl(e)}))),r&&Qn(r)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=r?.map((e=>this.formatChainId(e))),r.forEach((e=>{this.rpc.rpcMap[e]=n?.[e]||this.getRpcUrl(e)})))}getRpcUrl(e,t){var r;return(null==(r=this.rpc.rpcMap)?void 0:r[e])||`https://rpc.walletconnect.com/v1/?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t?.accounts),this.setAccounts(t?.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return"string"==typeof e||e instanceof String?[this.parseAccount(e)]:e.map((e=>this.parseAccount(e)))}}const Ef=_f;exports.G=Ef;