@dodoex/wallet-web3 0.0.38-2 → 0.0.38

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 (74) hide show
  1. package/dist/{DefaultJsonRpcProvider-4ffae6e9.js → DefaultJsonRpcProvider-41a80d3a.js} +1 -1
  2. package/dist/__node-resolve_empty-a0130b67.js +1 -0
  3. package/dist/__tslib-b5652ed0.js +1 -0
  4. package/dist/{blocto-bd2a365c.js → blocto-081dacf0.js} +1 -1
  5. package/dist/{bn-6c6a0d37.js → bn-2e9efe69.js} +1 -1
  6. package/dist/{browser-ponyfill-bfbf8d78.js → browser-ponyfill-3c048113.js} +1 -1
  7. package/dist/cjs/{DefaultJsonRpcProvider-54a9cd36.cjs → DefaultJsonRpcProvider-555947be.cjs} +1 -1
  8. package/dist/cjs/{__node-resolve_empty-5af9fabb.cjs → __node-resolve_empty-0fd10698.cjs} +1 -1
  9. package/dist/cjs/__tslib-56d4e80d.cjs +1 -0
  10. package/dist/cjs/{blocto-fa6b2293.cjs → blocto-fd2dbc87.cjs} +1 -1
  11. package/dist/cjs/{bn-e73bc23c.cjs → bn-b868bc58.cjs} +1 -1
  12. package/dist/cjs/{browser-ponyfill-f06979ce.cjs → browser-ponyfill-0e08ae60.cjs} +1 -1
  13. package/dist/cjs/{draggabilly-ddfd6109.cjs → draggabilly-9f84752c.cjs} +1 -1
  14. package/dist/cjs/{ethers-0a0a2762.cjs → ethers-3720c0d4.cjs} +1 -1
  15. package/dist/cjs/{id-8d3d0368.cjs → id-d282cc40.cjs} +1 -1
  16. package/dist/cjs/{index-c4ed347d.cjs → index-2e69c315.cjs} +1 -1
  17. package/dist/cjs/{index-514b5101.cjs → index-3f84dbd8.cjs} +2 -2
  18. package/dist/cjs/{index-eb8dc6ae.cjs → index-4d74d511.cjs} +1 -1
  19. package/dist/cjs/{index-e8fd7f3a.cjs → index-5616ac1f.cjs} +1 -1
  20. package/dist/cjs/index-94f8e007.cjs +9 -0
  21. package/dist/cjs/{index-8c5c26a7.cjs → index-9e2e0483.cjs} +1 -1
  22. package/dist/cjs/{index-7ba9ef03.cjs → index-aa73a457.cjs} +1 -1
  23. package/dist/cjs/{index-da6e7d13.cjs → index-c076fc61.cjs} +1 -1
  24. package/dist/cjs/{index-31879c88.cjs → index-d63adac7.cjs} +1 -1
  25. package/dist/cjs/{index-666d50b7.cjs → index-fc6b12bf.cjs} +1 -1
  26. package/dist/cjs/{index-5d95eb4a.cjs → index-ff4de501.cjs} +1 -1
  27. package/dist/cjs/index.cjs +1 -1
  28. package/dist/cjs/{index.es-9a7e91a9.cjs → index.es-e4d75037.cjs} +1 -1
  29. package/dist/cjs/{interface-53b4cedb.cjs → interface-a83766a7.cjs} +1 -1
  30. package/dist/cjs/{lib-typedarrays-305cbd75.cjs → lib-typedarrays-9767ea13.cjs} +1 -1
  31. package/dist/cjs/{portis-1428ba46.cjs → portis-9ebeee9a.cjs} +1 -1
  32. package/dist/cjs/{provider-d9677dbd.cjs → provider-0b2a9755.cjs} +1 -1
  33. package/dist/cjs/{rainbow-e1a7a0e9.cjs → rainbow-820152a6.cjs} +1 -1
  34. package/dist/cjs/{sha224-6e7192b0.cjs → sha224-15ae3459.cjs} +1 -1
  35. package/dist/cjs/{sha256-81079d3a.cjs → sha256-52e85bcc.cjs} +1 -1
  36. package/dist/cjs/{uAuth-b0cd8cad.cjs → uAuth-5cc8f23b.cjs} +1 -1
  37. package/dist/cjs/{walletConnect-0608b5aa.cjs → walletConnect-6c212713.cjs} +1 -1
  38. package/dist/cjs/walletLink-f8a2b601.cjs +3 -0
  39. package/dist/{draggabilly-4bb0c531.js → draggabilly-2398d387.js} +1 -1
  40. package/dist/{ethers-73e9b28a.js → ethers-a414e384.js} +1 -1
  41. package/dist/{id-7b3d9726.js → id-2343dc26.js} +1 -1
  42. package/dist/{index-4908ab44.js → index-07cb8806.js} +1 -1
  43. package/dist/{index-f9193421.js → index-403af4a8.js} +1 -1
  44. package/dist/{index-0665bb36.js → index-68ac5cb8.js} +1 -1
  45. package/dist/{index-d995bba9.js → index-6d05c923.js} +1 -1
  46. package/dist/index-7141d21e.js +9 -0
  47. package/dist/{index-707995d1.js → index-a2d5c236.js} +1 -1
  48. package/dist/{index-c1d37201.js → index-aac337ec.js} +2 -2
  49. package/dist/index-aea7cc41.js +1 -0
  50. package/dist/{index-8c24e0a2.js → index-b35f4170.js} +1 -1
  51. package/dist/{index-84a2fd78.js → index-c49d9c37.js} +1 -1
  52. package/dist/{index-bf7f2e5b.js → index-e5f9d1a3.js} +1 -1
  53. package/dist/{index.es-07e50b72.js → index.es-349fdb95.js} +1 -1
  54. package/dist/index.js +1 -1
  55. package/dist/{interface-d627b1d1.js → interface-1266ecba.js} +1 -1
  56. package/dist/{lib-typedarrays-dd873a99.js → lib-typedarrays-af3f4c8d.js} +1 -1
  57. package/dist/{portis-1b8e9755.js → portis-0bf2badd.js} +1 -1
  58. package/dist/{provider-00c8df34.js → provider-d169a966.js} +1 -1
  59. package/dist/rainbow-342e8d1b.js +1 -0
  60. package/dist/{sha224-ed2e24c0.js → sha224-c7e1991f.js} +1 -1
  61. package/dist/{sha256-619fd06c.js → sha256-46fd7765.js} +1 -1
  62. package/dist/{uAuth-10e22192.js → uAuth-42779605.js} +1 -1
  63. package/dist/{walletConnect-bafc3cd4.js → walletConnect-2aee4421.js} +1 -1
  64. package/dist/walletLink-ad28896e.js +3 -0
  65. package/package.json +1 -1
  66. package/dist/__node-resolve_empty-e266fbe6.js +0 -1
  67. package/dist/__tslib-ec00e137.js +0 -1
  68. package/dist/cjs/__tslib-89bc46c4.cjs +0 -1
  69. package/dist/cjs/index-3481a260.cjs +0 -9
  70. package/dist/cjs/walletLink-c3c61a73.cjs +0 -3
  71. package/dist/index-213eb86a.js +0 -9
  72. package/dist/index-c37b1e5f.js +0 -1
  73. package/dist/rainbow-d3884769.js +0 -1
  74. package/dist/walletLink-aabdeee4.js +0 -3
@@ -1 +1 @@
1
- "use strict";var t=require("./index-3481a260.cjs"),r=require("./__node-resolve_empty-5af9fabb.cjs"),i=require("@ethersproject/bytes");let e=!1,n=!1;const o={debug:1,default:2,info:2,warning:3,error:4,off:5};let h=o.default,s=null;const u=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((r=>{try{if("test"!=="test".normalize(r))throw new Error("bad normalize")}catch(i){t.push(r)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var a,l;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(a||(a={})),exports.ErrorCode=void 0,(l=exports.ErrorCode||(exports.ErrorCode={})).UNKNOWN_ERROR="UNKNOWN_ERROR",l.NOT_IMPLEMENTED="NOT_IMPLEMENTED",l.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",l.NETWORK_ERROR="NETWORK_ERROR",l.SERVER_ERROR="SERVER_ERROR",l.TIMEOUT="TIMEOUT",l.BUFFER_OVERRUN="BUFFER_OVERRUN",l.NUMERIC_FAULT="NUMERIC_FAULT",l.MISSING_NEW="MISSING_NEW",l.INVALID_ARGUMENT="INVALID_ARGUMENT",l.MISSING_ARGUMENT="MISSING_ARGUMENT",l.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",l.CALL_EXCEPTION="CALL_EXCEPTION",l.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",l.NONCE_EXPIRED="NONCE_EXPIRED",l.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",l.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",l.TRANSACTION_REPLACED="TRANSACTION_REPLACED",l.ACTION_REJECTED="ACTION_REJECTED";const m="0123456789abcdef";class f{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,r){const i=t.toLowerCase();null==o[i]&&this.throwArgumentError("invalid log level name","logLevel",t),h>o[i]||console.log.apply(console,r)}debug(...t){this._log(f.levels.DEBUG,t)}info(...t){this._log(f.levels.INFO,t)}warn(...t){this._log(f.levels.WARNING,t)}makeError(t,r,i){if(n)return this.makeError("censored error",r,{});r||(r=f.errors.UNKNOWN_ERROR),i||(i={});const e=[];Object.keys(i).forEach((t=>{const r=i[t];try{if(r instanceof Uint8Array){let i="";for(let t=0;t<r.length;t++)i+=m[r[t]>>4],i+=m[15&r[t]];e.push(t+"=Uint8Array(0x"+i+")")}else e.push(t+"="+JSON.stringify(r))}catch(r){e.push(t+"="+JSON.stringify(i[t].toString()))}})),e.push(`code=${r}`),e.push(`version=${this.version}`);const o=t;let h="";switch(r){case exports.ErrorCode.NUMERIC_FAULT:{h="NUMERIC_FAULT";const r=t;switch(r){case"overflow":case"underflow":case"division-by-zero":h+="-"+r;break;case"negative-power":case"negative-width":h+="-unsupported";break;case"unbound-bitwise-result":h+="-unbound-result"}break}case exports.ErrorCode.CALL_EXCEPTION:case exports.ErrorCode.INSUFFICIENT_FUNDS:case exports.ErrorCode.MISSING_NEW:case exports.ErrorCode.NONCE_EXPIRED:case exports.ErrorCode.REPLACEMENT_UNDERPRICED:case exports.ErrorCode.TRANSACTION_REPLACED:case exports.ErrorCode.UNPREDICTABLE_GAS_LIMIT:h=r}h&&(t+=" [ See: https://links.ethers.org/v5-errors-"+h+" ]"),e.length&&(t+=" ("+e.join(", ")+")");const s=new Error(t);return s.reason=o,s.code=r,Object.keys(i).forEach((function(t){s[t]=i[t]})),s}throwError(t,r,i){throw this.makeError(t,r,i)}throwArgumentError(t,r,i){return this.throwError(t,f.errors.INVALID_ARGUMENT,{argument:r,value:i})}assert(t,r,i,e){t||this.throwError(r,i,e)}assertArgument(t,r,i,e){t||this.throwArgumentError(r,i,e)}checkNormalize(t){u&&this.throwError("platform missing String.prototype.normalize",f.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:u})}checkSafeUint53(t,r){"number"==typeof t&&(null==r&&(r="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(r,f.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,f.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,r,i){i=i?": "+i:"",t<r&&this.throwError("missing argument"+i,f.errors.MISSING_ARGUMENT,{count:t,expectedCount:r}),t>r&&this.throwError("too many arguments"+i,f.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})}checkNew(t,r){t!==Object&&null!=t||this.throwError("missing new",f.errors.MISSING_NEW,{name:r.name})}checkAbstract(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",f.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",f.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return s||(s=new f("logger/5.7.0")),s}static setCensorship(t,r){if(!t&&r&&this.globalLogger().throwError("cannot permanently disable censorship",f.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),e){if(!t)return;this.globalLogger().throwError("error censorship permanent",f.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}n=!!t,e=!!r}static setLogLevel(t){const r=o[t.toLowerCase()];null!=r?h=r:f.globalLogger().warn("invalid log level - "+t)}static from(t){return new f(t)}}f.errors=exports.ErrorCode,f.levels=a;var d=Object.freeze({__proto__:null,get LogLevel(){return a},get ErrorCode(){return exports.ErrorCode},Logger:f}),p={exports:{}};!function(t,i){function e(t,r){if(!t)throw new Error(r||"Assertion failed")}function n(t,r){t.super_=r;var i=function(){};i.prototype=r.prototype,t.prototype=new i,t.prototype.constructor=t}function o(t,r,i){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==r&&"be"!==r||(i=r,r=10),this._init(t||0,r||10,i||"be"))}var h;"object"==typeof t?t.exports=o:i.BN=o,o.BN=o,o.wordSize=26;try{h="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r.require$$1.Buffer}catch(t){}function s(t,r){var i=t.charCodeAt(r);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void e(!1,"Invalid character in "+t)}function u(t,r,i){var e=s(t,i);return i-1>=r&&(e|=s(t,i-1)<<4),e}function a(t,r,i,n){for(var o=0,h=0,s=Math.min(t.length,i),u=r;u<s;u++){var a=t.charCodeAt(u)-48;o*=n,h=a>=49?a-49+10:a>=17?a-17+10:a,e(a>=0&&h<n,"Invalid character"),o+=h}return o}function l(t,r){t.words=r.words,t.length=r.length,t.negative=r.negative,t.red=r.red}if(o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,r){return t.cmp(r)>0?t:r},o.min=function(t,r){return t.cmp(r)<0?t:r},o.prototype._init=function(t,r,i){if("number"==typeof t)return this._initNumber(t,r,i);if("object"==typeof t)return this._initArray(t,r,i);"hex"===r&&(r=16),e(r===(0|r)&&r>=2&&r<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===r?this._parseHex(t,n,i):(this._parseBase(t,r,n),"le"===i&&this._initArray(this.toArray(),r,i)))},o.prototype._initNumber=function(t,r,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(e(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),r,i)},o.prototype._initArray=function(t,r,i){if(e("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,h,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)h=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=h<<s&67108863,this.words[o+1]=h>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)h=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=h<<s&67108863,this.words[o+1]=h>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},o.prototype._parseHex=function(t,r,i){this.length=Math.ceil((t.length-r)/6),this.words=new Array(this.length);for(var e=0;e<this.length;e++)this.words[e]=0;var n,o=0,h=0;if("be"===i)for(e=t.length-1;e>=r;e-=2)n=u(t,r,e)<<o,this.words[h]|=67108863&n,o>=18?(o-=18,h+=1,this.words[h]|=n>>>26):o+=8;else for(e=(t.length-r)%2==0?r+1:r;e<t.length;e+=2)n=u(t,r,e)<<o,this.words[h]|=67108863&n,o>=18?(o-=18,h+=1,this.words[h]|=n>>>26):o+=8;this._strip()},o.prototype._parseBase=function(t,r,i){this.words=[0],this.length=1;for(var e=0,n=1;n<=67108863;n*=r)e++;e--,n=n/r|0;for(var o=t.length-i,h=o%e,s=Math.min(o,o-h)+i,u=0,l=i;l<s;l+=e)u=a(t,l,l+e,r),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==h){var m=1;for(u=a(t,l,t.length,r),l=0;l<h;l++)m*=r;this.imuln(m),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},o.prototype.copy=function(t){t.words=new Array(this.length);for(var r=0;r<this.length;r++)t.words[r]=this.words[r];t.length=this.length,t.negative=this.negative,t.red=this.red},o.prototype._move=function(t){l(t,this)},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=m}catch(t){o.prototype.inspect=m}else o.prototype.inspect=m;function m(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function g(t,r,i){i.negative=r.negative^t.negative;var e=t.length+r.length|0;i.length=e,e=e-1|0;var n=0|t.words[0],o=0|r.words[0],h=n*o,s=67108863&h,u=h/67108864|0;i.words[0]=s;for(var a=1;a<e;a++){for(var l=u>>>26,m=67108863&u,f=Math.min(a,r.length-1),d=Math.max(0,a-t.length+1);d<=f;d++){var p=a-d|0;l+=(h=(n=0|t.words[p])*(o=0|r.words[d])+m)/67108864|0,m=67108863&h}i.words[a]=0|m,u=0|l}return 0!==u?i.words[a]=0|u:i.length--,i._strip()}o.prototype.toString=function(t,r){var i;if(r=0|r||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,h=0;h<this.length;h++){var s=this.words[h],u=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,h--),i=0!==o||h!==this.length-1?f[6-u.length]+u+i:u+i}for(0!==o&&(i=o.toString(16)+i);i.length%r!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var a=d[t],l=p[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var g=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?g+i:f[a-g.length]+g+i}for(this.isZero()&&(i="0"+i);i.length%r!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}e(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&e(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16,2)},h&&(o.prototype.toBuffer=function(t,r){return this.toArrayLike(h,t,r)}),o.prototype.toArray=function(t,r){return this.toArrayLike(Array,t,r)},o.prototype.toArrayLike=function(t,r,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);e(n<=o,"byte array longer than desired length"),e(o>0,"Requested array length <= 0");var h=function(t,r){return t.allocUnsafe?t.allocUnsafe(r):new t(r)}(t,o);return this["_toArrayLike"+("le"===r?"LE":"BE")](h,n),h},o.prototype._toArrayLikeLE=function(t,r){for(var i=0,e=0,n=0,o=0;n<this.length;n++){var h=this.words[n]<<o|e;t[i++]=255&h,i<t.length&&(t[i++]=h>>8&255),i<t.length&&(t[i++]=h>>16&255),6===o?(i<t.length&&(t[i++]=h>>24&255),e=0,o=0):(e=h>>>24,o+=2)}if(i<t.length)for(t[i++]=e;i<t.length;)t[i++]=0},o.prototype._toArrayLikeBE=function(t,r){for(var i=t.length-1,e=0,n=0,o=0;n<this.length;n++){var h=this.words[n]<<o|e;t[i--]=255&h,i>=0&&(t[i--]=h>>8&255),i>=0&&(t[i--]=h>>16&255),6===o?(i>=0&&(t[i--]=h>>24&255),e=0,o=0):(e=h>>>24,o+=2)}if(i>=0)for(t[i--]=e;i>=0;)t[i--]=0},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var r=t,i=0;return r>=4096&&(i+=13,r>>>=13),r>=64&&(i+=7,r>>>=7),r>=8&&(i+=4,r>>>=4),r>=2&&(i+=2,r>>>=2),i+r},o.prototype._zeroBits=function(t){if(0===t)return 26;var r=t,i=0;return 0==(8191&r)&&(i+=13,r>>>=13),0==(127&r)&&(i+=7,r>>>=7),0==(15&r)&&(i+=4,r>>>=4),0==(3&r)&&(i+=2,r>>>=2),0==(1&r)&&i++,i},o.prototype.bitLength=function(){var t=this.words[this.length-1],r=this._countBits(t);return 26*(this.length-1)+r},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,r=0;r<this.length;r++){var i=this._zeroBits(this.words[r]);if(t+=i,26!==i)break}return t},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]|t.words[r];return this._strip()},o.prototype.ior=function(t){return e(0==(this.negative|t.negative)),this.iuor(t)},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var r;r=this.length>t.length?t:this;for(var i=0;i<r.length;i++)this.words[i]=this.words[i]&t.words[i];return this.length=r.length,this._strip()},o.prototype.iand=function(t){return e(0==(this.negative|t.negative)),this.iuand(t)},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var r,i;this.length>t.length?(r=this,i=t):(r=t,i=this);for(var e=0;e<i.length;e++)this.words[e]=r.words[e]^i.words[e];if(this!==r)for(;e<r.length;e++)this.words[e]=r.words[e];return this.length=r.length,this._strip()},o.prototype.ixor=function(t){return e(0==(this.negative|t.negative)),this.iuxor(t)},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){e("number"==typeof t&&t>=0);var r=0|Math.ceil(t/26),i=t%26;this._expand(r),i>0&&r--;for(var n=0;n<r;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,r){e("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=r?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},o.prototype.iadd=function(t){var r,i,e;if(0!==this.negative&&0===t.negative)return this.negative=0,r=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,r=this.isub(t),t.negative=1,r._normSign();this.length>t.length?(i=this,e=t):(i=t,e=this);for(var n=0,o=0;o<e.length;o++)r=(0|i.words[o])+(0|e.words[o])+n,this.words[o]=67108863&r,n=r>>>26;for(;0!==n&&o<i.length;o++)r=(0|i.words[o])+n,this.words[o]=67108863&r,n=r>>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;o<i.length;o++)this.words[o]=i.words[o];return this},o.prototype.add=function(t){var r;return 0!==t.negative&&0===this.negative?(t.negative=0,r=this.sub(t),t.negative^=1,r):0===t.negative&&0!==this.negative?(this.negative=0,r=t.sub(this),this.negative=1,r):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var r=this.iadd(t);return t.negative=1,r._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,e,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,e=t):(i=t,e=this);for(var o=0,h=0;h<e.length;h++)o=(r=(0|i.words[h])-(0|e.words[h])+o)>>26,this.words[h]=67108863&r;for(;0!==o&&h<i.length;h++)o=(r=(0|i.words[h])+o)>>26,this.words[h]=67108863&r;if(0===o&&h<i.length&&i!==this)for(;h<i.length;h++)this.words[h]=i.words[h];return this.length=Math.max(this.length,h),i!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var c=function(t,r,i){var e,n,o,h=t.words,s=r.words,u=i.words,a=0,l=0|h[0],m=8191&l,f=l>>>13,d=0|h[1],p=8191&d,g=d>>>13,c=0|h[2],M=8191&c,v=c>>>13,w=0|h[3],y=8191&w,E=w>>>13,b=0|h[4],N=8191&b,_=b>>>13,R=0|h[5],U=8191&R,S=R>>>13,x=0|h[6],A=8191&x,I=x>>>13,T=0|h[7],O=8191&T,C=T>>>13,k=0|h[8],L=8191&k,F=k>>>13,P=0|h[9],B=8191&P,D=P>>>13,G=0|s[0],q=8191&G,z=G>>>13,Z=0|s[1],j=8191&Z,X=Z>>>13,K=0|s[2],V=8191&K,W=K>>>13,H=0|s[3],$=8191&H,J=H>>>13,Q=0|s[4],Y=8191&Q,tt=Q>>>13,rt=0|s[5],it=8191&rt,et=rt>>>13,nt=0|s[6],ot=8191&nt,ht=nt>>>13,st=0|s[7],ut=8191&st,at=st>>>13,lt=0|s[8],mt=8191&lt,ft=lt>>>13,dt=0|s[9],pt=8191&dt,gt=dt>>>13;i.negative=t.negative^r.negative,i.length=19;var ct=(a+(e=Math.imul(m,q))|0)+((8191&(n=(n=Math.imul(m,z))+Math.imul(f,q)|0))<<13)|0;a=((o=Math.imul(f,z))+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,e=Math.imul(p,q),n=(n=Math.imul(p,z))+Math.imul(g,q)|0,o=Math.imul(g,z);var Mt=(a+(e=e+Math.imul(m,j)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,j)|0))<<13)|0;a=((o=o+Math.imul(f,X)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,e=Math.imul(M,q),n=(n=Math.imul(M,z))+Math.imul(v,q)|0,o=Math.imul(v,z),e=e+Math.imul(p,j)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(g,j)|0,o=o+Math.imul(g,X)|0;var vt=(a+(e=e+Math.imul(m,V)|0)|0)+((8191&(n=(n=n+Math.imul(m,W)|0)+Math.imul(f,V)|0))<<13)|0;a=((o=o+Math.imul(f,W)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,e=Math.imul(y,q),n=(n=Math.imul(y,z))+Math.imul(E,q)|0,o=Math.imul(E,z),e=e+Math.imul(M,j)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(v,j)|0,o=o+Math.imul(v,X)|0,e=e+Math.imul(p,V)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(g,V)|0,o=o+Math.imul(g,W)|0;var wt=(a+(e=e+Math.imul(m,$)|0)|0)+((8191&(n=(n=n+Math.imul(m,J)|0)+Math.imul(f,$)|0))<<13)|0;a=((o=o+Math.imul(f,J)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,e=Math.imul(N,q),n=(n=Math.imul(N,z))+Math.imul(_,q)|0,o=Math.imul(_,z),e=e+Math.imul(y,j)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(E,j)|0,o=o+Math.imul(E,X)|0,e=e+Math.imul(M,V)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,W)|0,e=e+Math.imul(p,$)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,J)|0;var yt=(a+(e=e+Math.imul(m,Y)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,Y)|0))<<13)|0;a=((o=o+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,e=Math.imul(U,q),n=(n=Math.imul(U,z))+Math.imul(S,q)|0,o=Math.imul(S,z),e=e+Math.imul(N,j)|0,n=(n=n+Math.imul(N,X)|0)+Math.imul(_,j)|0,o=o+Math.imul(_,X)|0,e=e+Math.imul(y,V)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,W)|0,e=e+Math.imul(M,$)|0,n=(n=n+Math.imul(M,J)|0)+Math.imul(v,$)|0,o=o+Math.imul(v,J)|0,e=e+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,tt)|0;var Et=(a+(e=e+Math.imul(m,it)|0)|0)+((8191&(n=(n=n+Math.imul(m,et)|0)+Math.imul(f,it)|0))<<13)|0;a=((o=o+Math.imul(f,et)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,e=Math.imul(A,q),n=(n=Math.imul(A,z))+Math.imul(I,q)|0,o=Math.imul(I,z),e=e+Math.imul(U,j)|0,n=(n=n+Math.imul(U,X)|0)+Math.imul(S,j)|0,o=o+Math.imul(S,X)|0,e=e+Math.imul(N,V)|0,n=(n=n+Math.imul(N,W)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,W)|0,e=e+Math.imul(y,$)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(E,$)|0,o=o+Math.imul(E,J)|0,e=e+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,tt)|0,e=e+Math.imul(p,it)|0,n=(n=n+Math.imul(p,et)|0)+Math.imul(g,it)|0,o=o+Math.imul(g,et)|0;var bt=(a+(e=e+Math.imul(m,ot)|0)|0)+((8191&(n=(n=n+Math.imul(m,ht)|0)+Math.imul(f,ot)|0))<<13)|0;a=((o=o+Math.imul(f,ht)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,e=Math.imul(O,q),n=(n=Math.imul(O,z))+Math.imul(C,q)|0,o=Math.imul(C,z),e=e+Math.imul(A,j)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(I,j)|0,o=o+Math.imul(I,X)|0,e=e+Math.imul(U,V)|0,n=(n=n+Math.imul(U,W)|0)+Math.imul(S,V)|0,o=o+Math.imul(S,W)|0,e=e+Math.imul(N,$)|0,n=(n=n+Math.imul(N,J)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,J)|0,e=e+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(E,Y)|0,o=o+Math.imul(E,tt)|0,e=e+Math.imul(M,it)|0,n=(n=n+Math.imul(M,et)|0)+Math.imul(v,it)|0,o=o+Math.imul(v,et)|0,e=e+Math.imul(p,ot)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,ht)|0;var Nt=(a+(e=e+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,at)|0)+Math.imul(f,ut)|0))<<13)|0;a=((o=o+Math.imul(f,at)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,e=Math.imul(L,q),n=(n=Math.imul(L,z))+Math.imul(F,q)|0,o=Math.imul(F,z),e=e+Math.imul(O,j)|0,n=(n=n+Math.imul(O,X)|0)+Math.imul(C,j)|0,o=o+Math.imul(C,X)|0,e=e+Math.imul(A,V)|0,n=(n=n+Math.imul(A,W)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,W)|0,e=e+Math.imul(U,$)|0,n=(n=n+Math.imul(U,J)|0)+Math.imul(S,$)|0,o=o+Math.imul(S,J)|0,e=e+Math.imul(N,Y)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,tt)|0,e=e+Math.imul(y,it)|0,n=(n=n+Math.imul(y,et)|0)+Math.imul(E,it)|0,o=o+Math.imul(E,et)|0,e=e+Math.imul(M,ot)|0,n=(n=n+Math.imul(M,ht)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,ht)|0,e=e+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(g,ut)|0,o=o+Math.imul(g,at)|0;var _t=(a+(e=e+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;a=((o=o+Math.imul(f,ft)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,e=Math.imul(B,q),n=(n=Math.imul(B,z))+Math.imul(D,q)|0,o=Math.imul(D,z),e=e+Math.imul(L,j)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(F,j)|0,o=o+Math.imul(F,X)|0,e=e+Math.imul(O,V)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,W)|0,e=e+Math.imul(A,$)|0,n=(n=n+Math.imul(A,J)|0)+Math.imul(I,$)|0,o=o+Math.imul(I,J)|0,e=e+Math.imul(U,Y)|0,n=(n=n+Math.imul(U,tt)|0)+Math.imul(S,Y)|0,o=o+Math.imul(S,tt)|0,e=e+Math.imul(N,it)|0,n=(n=n+Math.imul(N,et)|0)+Math.imul(_,it)|0,o=o+Math.imul(_,et)|0,e=e+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,ht)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,ht)|0,e=e+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,at)|0)+Math.imul(v,ut)|0,o=o+Math.imul(v,at)|0,e=e+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(g,mt)|0,o=o+Math.imul(g,ft)|0;var Rt=(a+(e=e+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,gt)|0)+Math.imul(f,pt)|0))<<13)|0;a=((o=o+Math.imul(f,gt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,e=Math.imul(B,j),n=(n=Math.imul(B,X))+Math.imul(D,j)|0,o=Math.imul(D,X),e=e+Math.imul(L,V)|0,n=(n=n+Math.imul(L,W)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,W)|0,e=e+Math.imul(O,$)|0,n=(n=n+Math.imul(O,J)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,J)|0,e=e+Math.imul(A,Y)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(I,Y)|0,o=o+Math.imul(I,tt)|0,e=e+Math.imul(U,it)|0,n=(n=n+Math.imul(U,et)|0)+Math.imul(S,it)|0,o=o+Math.imul(S,et)|0,e=e+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,ht)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,ht)|0,e=e+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(E,ut)|0,o=o+Math.imul(E,at)|0,e=e+Math.imul(M,mt)|0,n=(n=n+Math.imul(M,ft)|0)+Math.imul(v,mt)|0,o=o+Math.imul(v,ft)|0;var Ut=(a+(e=e+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;a=((o=o+Math.imul(g,gt)|0)+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,e=Math.imul(B,V),n=(n=Math.imul(B,W))+Math.imul(D,V)|0,o=Math.imul(D,W),e=e+Math.imul(L,$)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(F,$)|0,o=o+Math.imul(F,J)|0,e=e+Math.imul(O,Y)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,tt)|0,e=e+Math.imul(A,it)|0,n=(n=n+Math.imul(A,et)|0)+Math.imul(I,it)|0,o=o+Math.imul(I,et)|0,e=e+Math.imul(U,ot)|0,n=(n=n+Math.imul(U,ht)|0)+Math.imul(S,ot)|0,o=o+Math.imul(S,ht)|0,e=e+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,at)|0,e=e+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(E,mt)|0,o=o+Math.imul(E,ft)|0;var St=(a+(e=e+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,gt)|0)+Math.imul(v,pt)|0))<<13)|0;a=((o=o+Math.imul(v,gt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,e=Math.imul(B,$),n=(n=Math.imul(B,J))+Math.imul(D,$)|0,o=Math.imul(D,J),e=e+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,tt)|0,e=e+Math.imul(O,it)|0,n=(n=n+Math.imul(O,et)|0)+Math.imul(C,it)|0,o=o+Math.imul(C,et)|0,e=e+Math.imul(A,ot)|0,n=(n=n+Math.imul(A,ht)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,ht)|0,e=e+Math.imul(U,ut)|0,n=(n=n+Math.imul(U,at)|0)+Math.imul(S,ut)|0,o=o+Math.imul(S,at)|0,e=e+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,ft)|0)+Math.imul(_,mt)|0,o=o+Math.imul(_,ft)|0;var xt=(a+(e=e+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,gt)|0)+Math.imul(E,pt)|0))<<13)|0;a=((o=o+Math.imul(E,gt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,e=Math.imul(B,Y),n=(n=Math.imul(B,tt))+Math.imul(D,Y)|0,o=Math.imul(D,tt),e=e+Math.imul(L,it)|0,n=(n=n+Math.imul(L,et)|0)+Math.imul(F,it)|0,o=o+Math.imul(F,et)|0,e=e+Math.imul(O,ot)|0,n=(n=n+Math.imul(O,ht)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,ht)|0,e=e+Math.imul(A,ut)|0,n=(n=n+Math.imul(A,at)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,at)|0,e=e+Math.imul(U,mt)|0,n=(n=n+Math.imul(U,ft)|0)+Math.imul(S,mt)|0,o=o+Math.imul(S,ft)|0;var At=(a+(e=e+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,gt)|0)+Math.imul(_,pt)|0))<<13)|0;a=((o=o+Math.imul(_,gt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,e=Math.imul(B,it),n=(n=Math.imul(B,et))+Math.imul(D,it)|0,o=Math.imul(D,et),e=e+Math.imul(L,ot)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,ht)|0,e=e+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,at)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,at)|0,e=e+Math.imul(A,mt)|0,n=(n=n+Math.imul(A,ft)|0)+Math.imul(I,mt)|0,o=o+Math.imul(I,ft)|0;var It=(a+(e=e+Math.imul(U,pt)|0)|0)+((8191&(n=(n=n+Math.imul(U,gt)|0)+Math.imul(S,pt)|0))<<13)|0;a=((o=o+Math.imul(S,gt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,e=Math.imul(B,ot),n=(n=Math.imul(B,ht))+Math.imul(D,ot)|0,o=Math.imul(D,ht),e=e+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,at)|0)+Math.imul(F,ut)|0,o=o+Math.imul(F,at)|0,e=e+Math.imul(O,mt)|0,n=(n=n+Math.imul(O,ft)|0)+Math.imul(C,mt)|0,o=o+Math.imul(C,ft)|0;var Tt=(a+(e=e+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,gt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((o=o+Math.imul(I,gt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,e=Math.imul(B,ut),n=(n=Math.imul(B,at))+Math.imul(D,ut)|0,o=Math.imul(D,at),e=e+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,ft)|0)+Math.imul(F,mt)|0,o=o+Math.imul(F,ft)|0;var Ot=(a+(e=e+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,gt)|0)+Math.imul(C,pt)|0))<<13)|0;a=((o=o+Math.imul(C,gt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,e=Math.imul(B,mt),n=(n=Math.imul(B,ft))+Math.imul(D,mt)|0,o=Math.imul(D,ft);var Ct=(a+(e=e+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,gt)|0)+Math.imul(F,pt)|0))<<13)|0;a=((o=o+Math.imul(F,gt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var kt=(a+(e=Math.imul(B,pt))|0)+((8191&(n=(n=Math.imul(B,gt))+Math.imul(D,pt)|0))<<13)|0;return a=((o=Math.imul(D,gt))+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,u[0]=ct,u[1]=Mt,u[2]=vt,u[3]=wt,u[4]=yt,u[5]=Et,u[6]=bt,u[7]=Nt,u[8]=_t,u[9]=Rt,u[10]=Ut,u[11]=St,u[12]=xt,u[13]=At,u[14]=It,u[15]=Tt,u[16]=Ot,u[17]=Ct,u[18]=kt,0!==a&&(u[19]=a,i.length++),i};function M(t,r,i){i.negative=r.negative^t.negative,i.length=t.length+r.length;for(var e=0,n=0,o=0;o<i.length-1;o++){var h=n;n=0;for(var s=67108863&e,u=Math.min(o,r.length-1),a=Math.max(0,o-t.length+1);a<=u;a++){var l=o-a,m=(0|t.words[l])*(0|r.words[a]),f=67108863&m;s=67108863&(f=f+s|0),n+=(h=(h=h+(m/67108864|0)|0)+(f>>>26)|0)>>>26,h&=67108863}i.words[o]=s,e=h,h=n}return 0!==e?i.words[o]=e:i.length--,i._strip()}function v(t,r,i){return M(t,r,i)}Math.imul||(c=g),o.prototype.mulTo=function(t,r){var i=this.length+t.length;return 10===this.length&&10===t.length?c(this,t,r):i<63?g(this,t,r):i<1024?M(this,t,r):v(this,t,r)},o.prototype.mul=function(t){var r=new o(null);return r.words=new Array(this.length+t.length),this.mulTo(t,r)},o.prototype.mulf=function(t){var r=new o(null);return r.words=new Array(this.length+t.length),v(this,t,r)},o.prototype.imul=function(t){return this.clone().mulTo(t,this)},o.prototype.imuln=function(t){var r=t<0;r&&(t=-t),e("number"==typeof t),e(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,h=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=h>>>26,this.words[n]=67108863&h}return 0!==i&&(this.words[n]=i,this.length++),r?this.ineg():this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var r=function(t){for(var r=new Array(t.bitLength()),i=0;i<r.length;i++){var e=i/26|0,n=i%26;r[i]=t.words[e]>>>n&1}return r}(t);if(0===r.length)return new o(1);for(var i=this,e=0;e<r.length&&0===r[e];e++,i=i.sqr());if(++e<r.length)for(var n=i.sqr();e<r.length;e++,n=n.sqr())0!==r[e]&&(i=i.mul(n));return i},o.prototype.iushln=function(t){e("number"==typeof t&&t>=0);var r,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var h=0;for(r=0;r<this.length;r++){var s=this.words[r]&o,u=(0|this.words[r])-s<<i;this.words[r]=u|h,h=s>>>26-i}h&&(this.words[r]=h,this.length++)}if(0!==n){for(r=this.length-1;r>=0;r--)this.words[r+n]=this.words[r];for(r=0;r<n;r++)this.words[r]=0;this.length+=n}return this._strip()},o.prototype.ishln=function(t){return e(0===this.negative),this.iushln(t)},o.prototype.iushrn=function(t,r,i){var n;e("number"==typeof t&&t>=0),n=r?(r-r%26)/26:0;var o=t%26,h=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,u=i;if(n-=h,n=Math.max(0,n),u){for(var a=0;a<h;a++)u.words[a]=this.words[a];u.length=h}if(0===h);else if(this.length>h)for(this.length-=h,a=0;a<this.length;a++)this.words[a]=this.words[a+h];else this.words[0]=0,this.length=1;var l=0;for(a=this.length-1;a>=0&&(0!==l||a>=n);a--){var m=0|this.words[a];this.words[a]=l<<26-o|m>>>o,l=m&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(t,r,i){return e(0===this.negative),this.iushrn(t,r,i)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){e("number"==typeof t&&t>=0);var r=t%26,i=(t-r)/26,n=1<<r;return!(this.length<=i||!(this.words[i]&n))},o.prototype.imaskn=function(t){e("number"==typeof t&&t>=0);var r=t%26,i=(t-r)/26;if(e(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==r&&i++,this.length=Math.min(i,this.length),0!==r){var n=67108863^67108863>>>r<<r;this.words[this.length-1]&=n}return this._strip()},o.prototype.maskn=function(t){return this.clone().imaskn(t)},o.prototype.iaddn=function(t){return e("number"==typeof t),e(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},o.prototype._iaddn=function(t){this.words[0]+=t;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},o.prototype.isubn=function(t){if(e("number"==typeof t),e(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this._strip()},o.prototype.addn=function(t){return this.clone().iaddn(t)},o.prototype.subn=function(t){return this.clone().isubn(t)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(t,r,i){var n,o,h=t.length+i;this._expand(h);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var u=(0|t.words[n])*r;s=((o-=67108863&u)>>26)-(u/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(e(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(t,r){var i=(this.length,t.length),e=this.clone(),n=t,h=0|n.words[n.length-1];0!=(i=26-this._countBits(h))&&(n=n.ushln(i),e.iushln(i),h=0|n.words[n.length-1]);var s,u=e.length-n.length;if("mod"!==r){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var a=0;a<s.length;a++)s.words[a]=0}var l=e.clone()._ishlnsubmul(n,1,u);0===l.negative&&(e=l,s&&(s.words[u]=1));for(var m=u-1;m>=0;m--){var f=67108864*(0|e.words[n.length+m])+(0|e.words[n.length+m-1]);for(f=Math.min(f/h|0,67108863),e._ishlnsubmul(n,f,m);0!==e.negative;)f--,e.negative=0,e._ishlnsubmul(n,1,m),e.isZero()||(e.negative^=1);s&&(s.words[m]=f)}return s&&s._strip(),e._strip(),"div"!==r&&0!==i&&e.iushrn(i),{div:s||null,mod:e}},o.prototype.divmod=function(t,r,i){return e(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,r),"mod"!==r&&(n=s.div.neg()),"div"!==r&&(h=s.mod.neg(),i&&0!==h.negative&&h.iadd(t)),{div:n,mod:h}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),r),"mod"!==r&&(n=s.div.neg()),{div:n,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),r),"div"!==r&&(h=s.mod.neg(),i&&0!==h.negative&&h.isub(t)),{div:s.div,mod:h}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===r?{div:this.divn(t.words[0]),mod:null}:"mod"===r?{div:null,mod:new o(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,r);var n,h,s},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var r=this.divmod(t);if(r.mod.isZero())return r.div;var i=0!==r.div.negative?r.mod.isub(t):r.mod,e=t.ushrn(1),n=t.andln(1),o=i.cmp(e);return o<0||1===n&&0===o?r.div:0!==r.div.negative?r.div.isubn(1):r.div.iaddn(1)},o.prototype.modrn=function(t){var r=t<0;r&&(t=-t),e(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return r?-n:n},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var r=t<0;r&&(t=-t),e(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),r?this.ineg():this},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){e(0===t.negative),e(!t.isZero());var r=this,i=t.clone();r=0!==r.negative?r.umod(t):r.clone();for(var n=new o(1),h=new o(0),s=new o(0),u=new o(1),a=0;r.isEven()&&i.isEven();)r.iushrn(1),i.iushrn(1),++a;for(var l=i.clone(),m=r.clone();!r.isZero();){for(var f=0,d=1;0==(r.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(r.iushrn(f);f-- >0;)(n.isOdd()||h.isOdd())&&(n.iadd(l),h.isub(m)),n.iushrn(1),h.iushrn(1);for(var p=0,g=1;0==(i.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(m)),s.iushrn(1),u.iushrn(1);r.cmp(i)>=0?(r.isub(i),n.isub(s),h.isub(u)):(i.isub(r),s.isub(n),u.isub(h))}return{a:s,b:u,gcd:i.iushln(a)}},o.prototype._invmp=function(t){e(0===t.negative),e(!t.isZero());var r=this,i=t.clone();r=0!==r.negative?r.umod(t):r.clone();for(var n,h=new o(1),s=new o(0),u=i.clone();r.cmpn(1)>0&&i.cmpn(1)>0;){for(var a=0,l=1;0==(r.words[0]&l)&&a<26;++a,l<<=1);if(a>0)for(r.iushrn(a);a-- >0;)h.isOdd()&&h.iadd(u),h.iushrn(1);for(var m=0,f=1;0==(i.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(i.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);r.cmp(i)>=0?(r.isub(i),h.isub(s)):(i.isub(r),s.isub(h))}return(n=0===r.cmpn(1)?h:s).cmpn(0)<0&&n.iadd(t),n},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var r=this.clone(),i=t.clone();r.negative=0,i.negative=0;for(var e=0;r.isEven()&&i.isEven();e++)r.iushrn(1),i.iushrn(1);for(;;){for(;r.isEven();)r.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=r.cmp(i);if(n<0){var o=r;r=i,i=o}else if(0===n||0===i.cmpn(1))break;r.isub(i)}return i.iushln(e)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){e("number"==typeof t);var r=t%26,i=(t-r)/26,n=1<<r;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,h=i;0!==o&&h<this.length;h++){var s=0|this.words[h];o=(s+=o)>>>26,s&=67108863,this.words[h]=s}return 0!==o&&(this.words[h]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var r,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)r=1;else{i&&(t=-t),e(t<=67108863,"Number is too big");var n=0|this.words[0];r=n===t?0:n<t?-1:1}return 0!==this.negative?0|-r:r},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var r=this.ucmp(t);return 0!==this.negative?0|-r:r},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var r=0,i=this.length-1;i>=0;i--){var e=0|this.words[i],n=0|t.words[i];if(e!==n){e<n?r=-1:e>n&&(r=1);break}}return r},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new R(t)},o.prototype.toRed=function(t){return e(!this.red,"Already a number in reduction context"),e(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return e(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return e(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return e(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return e(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return e(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return e(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return e(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return e(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return e(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return e(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return e(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return e(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return e(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function y(t,r){this.name=t,this.p=new o(r,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function E(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function N(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function R(t){if("string"==typeof t){var r=o._prime(t);this.m=r.p,this.prime=r}else e(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function U(t){R.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var r,i=t;do{this.split(i,this.tmp),r=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(r>this.n);var e=r<this.n?-1:i.ucmp(this.p);return 0===e?(i.words[0]=0,i.length=1):e>0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},y.prototype.split=function(t,r){t.iushrn(this.n,0,r)},y.prototype.imulK=function(t){return t.imul(this.k)},n(E,y),E.prototype.split=function(t,r){for(var i=4194303,e=Math.min(t.length,9),n=0;n<e;n++)r.words[n]=t.words[n];if(r.length=e,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(r.words[r.length++]=o&i,n=10;n<t.length;n++){var h=0|t.words[n];t.words[n-10]=(h&i)<<4|o>>>22,o=h}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},E.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var r=0,i=0;i<t.length;i++){var e=0|t.words[i];r+=977*e,t.words[i]=67108863&r,r=64*e+(r/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(b,y),n(N,y),n(_,y),_.prototype.imulK=function(t){for(var r=0,i=0;i<t.length;i++){var e=19*(0|t.words[i])+r,n=67108863&e;e>>>=26,t.words[i]=n,r=e}return 0!==r&&(t.words[t.length++]=r),t},o._prime=function(t){if(w[t])return w[t];var r;if("k256"===t)r=new E;else if("p224"===t)r=new b;else if("p192"===t)r=new N;else{if("p25519"!==t)throw new Error("Unknown prime "+t);r=new _}return w[t]=r,r},R.prototype._verify1=function(t){e(0===t.negative,"red works only with positives"),e(t.red,"red works only with red numbers")},R.prototype._verify2=function(t,r){e(0==(t.negative|r.negative),"red works only with positives"),e(t.red&&t.red===r.red,"red works only with red numbers")},R.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(l(t,t.umod(this.m)._forceRed(this)),t)},R.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},R.prototype.add=function(t,r){this._verify2(t,r);var i=t.add(r);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},R.prototype.iadd=function(t,r){this._verify2(t,r);var i=t.iadd(r);return i.cmp(this.m)>=0&&i.isub(this.m),i},R.prototype.sub=function(t,r){this._verify2(t,r);var i=t.sub(r);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},R.prototype.isub=function(t,r){this._verify2(t,r);var i=t.isub(r);return i.cmpn(0)<0&&i.iadd(this.m),i},R.prototype.shl=function(t,r){return this._verify1(t),this.imod(t.ushln(r))},R.prototype.imul=function(t,r){return this._verify2(t,r),this.imod(t.imul(r))},R.prototype.mul=function(t,r){return this._verify2(t,r),this.imod(t.mul(r))},R.prototype.isqr=function(t){return this.imul(t,t.clone())},R.prototype.sqr=function(t){return this.mul(t,t)},R.prototype.sqrt=function(t){if(t.isZero())return t.clone();var r=this.m.andln(3);if(e(r%2==1),3===r){var i=this.m.add(new o(1)).iushrn(2);return this.pow(t,i)}for(var n=this.m.subn(1),h=0;!n.isZero()&&0===n.andln(1);)h++,n.iushrn(1);e(!n.isZero());var s=new o(1).toRed(this),u=s.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=h;0!==d.cmp(s);){for(var g=d,c=0;0!==g.cmp(s);c++)g=g.redSqr();e(c<p);var M=this.pow(m,new o(1).iushln(p-c-1));f=f.redMul(M),m=M.redSqr(),d=d.redMul(m),p=c}return f},R.prototype.invm=function(t){var r=t._invmp(this.m);return 0!==r.negative?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},R.prototype.pow=function(t,r){if(r.isZero())return new o(1).toRed(this);if(0===r.cmpn(1))return t.clone();var i=new Array(16);i[0]=new o(1).toRed(this),i[1]=t;for(var e=2;e<i.length;e++)i[e]=this.mul(i[e-1],t);var n=i[0],h=0,s=0,u=r.bitLength()%26;for(0===u&&(u=26),e=r.length-1;e>=0;e--){for(var a=r.words[e],l=u-1;l>=0;l--){var m=a>>l&1;n!==i[0]&&(n=this.sqr(n)),0!==m||0!==h?(h<<=1,h|=m,(4==++s||0===e&&0===l)&&(n=this.mul(n,i[h]),s=0,h=0)):s=0}u=26}return n},R.prototype.convertTo=function(t){var r=t.umod(this.m);return r===t?r.clone():r},R.prototype.convertFrom=function(t){var r=t.clone();return r.red=null,r},o.mont=function(t){return new U(t)},n(U,R),U.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},U.prototype.convertFrom=function(t){var r=this.imod(t.mul(this.rinv));return r.red=null,r},U.prototype.imul=function(t,r){if(t.isZero()||r.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(r),e=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(e).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},U.prototype.mul=function(t,r){if(t.isZero()||r.isZero())return new o(0)._forceRed(this);var i=t.mul(r),e=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(e).iushrn(this.shift),h=n;return n.cmp(this.m)>=0?h=n.isub(this.m):n.cmpn(0)<0&&(h=n.iadd(this.m)),h._forceRed(this)},U.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(p,t.commonjsGlobal);const g="bignumber/5.7.0";var c=p.exports.BN;const M=new f(g),v={},w=9007199254740991;let y=!1;class E{constructor(t,r){t!==v&&M.throwError("cannot call constructor directly; use BigNumber.from",f.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return N(_(this).fromTwos(t))}toTwos(t){return N(_(this).toTwos(t))}abs(){return"-"===this._hex[0]?E.from(this._hex.substring(1)):this}add(t){return N(_(this).add(_(t)))}sub(t){return N(_(this).sub(_(t)))}div(t){return E.from(t).isZero()&&R("division-by-zero","div"),N(_(this).div(_(t)))}mul(t){return N(_(this).mul(_(t)))}mod(t){const r=_(t);return r.isNeg()&&R("division-by-zero","mod"),N(_(this).umod(r))}pow(t){const r=_(t);return r.isNeg()&&R("negative-power","pow"),N(_(this).pow(r))}and(t){const r=_(t);return(this.isNegative()||r.isNeg())&&R("unbound-bitwise-result","and"),N(_(this).and(r))}or(t){const r=_(t);return(this.isNegative()||r.isNeg())&&R("unbound-bitwise-result","or"),N(_(this).or(r))}xor(t){const r=_(t);return(this.isNegative()||r.isNeg())&&R("unbound-bitwise-result","xor"),N(_(this).xor(r))}mask(t){return(this.isNegative()||t<0)&&R("negative-width","mask"),N(_(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&R("negative-width","shl"),N(_(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&R("negative-width","shr"),N(_(this).shrn(t))}eq(t){return _(this).eq(_(t))}lt(t){return _(this).lt(_(t))}lte(t){return _(this).lte(_(t))}gt(t){return _(this).gt(_(t))}gte(t){return _(this).gte(_(t))}isNegative(){return"-"===this._hex[0]}isZero(){return _(this).isZero()}toNumber(){try{return _(this).toNumber()}catch(t){R("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return M.throwError("this platform does not support BigInt",f.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?y||(y=!0,M.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?M.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",f.errors.UNEXPECTED_ARGUMENT,{}):M.throwError("BigNumber.toString does not accept parameters",f.errors.UNEXPECTED_ARGUMENT,{})),_(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof E)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new E(v,b(t)):t.match(/^-?[0-9]+$/)?new E(v,b(new c(t))):M.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&R("underflow","BigNumber.from",t),(t>=w||t<=-w)&&R("overflow","BigNumber.from",t),E.from(String(t));const r=t;if("bigint"==typeof r)return E.from(r.toString());if(i.isBytes(r))return E.from(i.hexlify(r));if(r)if(r.toHexString){const t=r.toHexString();if("string"==typeof t)return E.from(t)}else{let t=r._hex;if(null==t&&"BigNumber"===r.type&&(t=r.hex),"string"==typeof t&&(i.isHexString(t)||"-"===t[0]&&i.isHexString(t.substring(1))))return E.from(t)}return M.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function b(t){if("string"!=typeof t)return b(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&M.throwArgumentError("invalid hex","value",t),"0x00"===(t=b(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function N(t){return E.from(b(t))}function _(t){const r=E.from(t).toHexString();return"-"===r[0]?new c("-"+r.substring(3),16):new c(r.substring(2),16)}function R(t,r,i){const e={fault:t,operation:r};return null!=i&&(e.value=i),M.throwError(t,f.errors.NUMERIC_FAULT,e)}const U=new f("strings/5.7.0");var S,x;function A(t,r,i,e,n){if(t===exports.Utf8ErrorReason.BAD_PREFIX||t===exports.Utf8ErrorReason.UNEXPECTED_CONTINUE){let t=0;for(let e=r+1;e<i.length&&i[e]>>6==2;e++)t++;return t}return t===exports.Utf8ErrorReason.OVERRUN?i.length-r-1:0}exports.UnicodeNormalizationForm=void 0,(S=exports.UnicodeNormalizationForm||(exports.UnicodeNormalizationForm={})).current="",S.NFC="NFC",S.NFD="NFD",S.NFKC="NFKC",S.NFKD="NFKD",exports.Utf8ErrorReason=void 0,(x=exports.Utf8ErrorReason||(exports.Utf8ErrorReason={})).UNEXPECTED_CONTINUE="unexpected continuation byte",x.BAD_PREFIX="bad codepoint prefix",x.OVERRUN="string overrun",x.MISSING_CONTINUE="missing continuation byte",x.OUT_OF_RANGE="out of UTF-8 range",x.UTF16_SURROGATE="UTF-16 surrogate",x.OVERLONG="overlong representation";const I=Object.freeze({error:function(t,r,i,e,n){return U.throwArgumentError(`invalid codepoint at offset ${r}; ${t}`,"bytes",i)},ignore:A,replace:function(t,r,i,e,n){return t===exports.Utf8ErrorReason.OVERLONG?(e.push(n),0):(e.push(65533),A(t,r,i))}});function T(t,r){null==r&&(r=I.error),t=i.arrayify(t);const e=[];let n=0;for(;n<t.length;){const i=t[n++];if(i>>7==0){e.push(i);continue}let o=null,h=null;if(192==(224&i))o=1,h=127;else if(224==(240&i))o=2,h=2047;else{if(240!=(248&i)){n+=r(128==(192&i)?exports.Utf8ErrorReason.UNEXPECTED_CONTINUE:exports.Utf8ErrorReason.BAD_PREFIX,n-1,t,e);continue}o=3,h=65535}if(n-1+o>=t.length){n+=r(exports.Utf8ErrorReason.OVERRUN,n-1,t,e);continue}let s=i&(1<<8-o-1)-1;for(let i=0;i<o;i++){let i=t[n];if(128!=(192&i)){n+=r(exports.Utf8ErrorReason.MISSING_CONTINUE,n,t,e),s=null;break}s=s<<6|63&i,n++}null!==s&&(s>1114111?n+=r(exports.Utf8ErrorReason.OUT_OF_RANGE,n-1-o,t,e,s):s>=55296&&s<=57343?n+=r(exports.Utf8ErrorReason.UTF16_SURROGATE,n-1-o,t,e,s):s<=h?n+=r(exports.Utf8ErrorReason.OVERLONG,n-1-o,t,e,s):e.push(s))}return e}function O(t,r=exports.UnicodeNormalizationForm.current){r!=exports.UnicodeNormalizationForm.current&&(U.checkNormalize(),t=t.normalize(r));let e=[];for(let r=0;r<t.length;r++){const i=t.charCodeAt(r);if(i<128)e.push(i);else if(i<2048)e.push(i>>6|192),e.push(63&i|128);else if(55296==(64512&i)){r++;const n=t.charCodeAt(r);if(r>=t.length||56320!=(64512&n))throw new Error("invalid utf-8 string");const o=65536+((1023&i)<<10)+(1023&n);e.push(o>>18|240),e.push(o>>12&63|128),e.push(o>>6&63|128),e.push(63&o|128)}else e.push(i>>12|224),e.push(i>>6&63|128),e.push(63&i|128)}return i.arrayify(e)}function C(t){const r="0000"+t.toString(16);return"\\u"+r.substring(r.length-4)}function k(t){return t.map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("")}exports.BigNumber=E,exports.Logger=f,exports.Utf8ErrorFuncs=I,exports._toEscapedUtf8String=function(t,r){return'"'+T(t,r).map((t=>{if(t<256){switch(t){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(t>=32&&t<127)return String.fromCharCode(t)}return t<=65535?C(t):C(55296+((t-=65536)>>10&1023))+C(56320+(1023&t))})).join("")+'"'},exports._toUtf8String=k,exports.id=function(r){return t.keccak256(O(r))},exports.isBigNumberish=function(t){return null!=t&&(E.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||i.isHexString(t)||"bigint"==typeof t||i.isBytes(t))},exports.lib_esm=d,exports.toUtf8Bytes=O,exports.toUtf8CodePoints=function(t,r=exports.UnicodeNormalizationForm.current){return T(O(t,r))},exports.toUtf8String=function(t,r){return k(T(t,r))},exports.version=g;
1
+ "use strict";var t=require("./index-94f8e007.cjs"),r=require("./__node-resolve_empty-0fd10698.cjs"),i=require("@ethersproject/bytes");let e=!1,n=!1;const o={debug:1,default:2,info:2,warning:3,error:4,off:5};let h=o.default,s=null;const u=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach((r=>{try{if("test"!=="test".normalize(r))throw new Error("bad normalize")}catch(i){t.push(r)}})),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();var a,l;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(a||(a={})),exports.ErrorCode=void 0,(l=exports.ErrorCode||(exports.ErrorCode={})).UNKNOWN_ERROR="UNKNOWN_ERROR",l.NOT_IMPLEMENTED="NOT_IMPLEMENTED",l.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",l.NETWORK_ERROR="NETWORK_ERROR",l.SERVER_ERROR="SERVER_ERROR",l.TIMEOUT="TIMEOUT",l.BUFFER_OVERRUN="BUFFER_OVERRUN",l.NUMERIC_FAULT="NUMERIC_FAULT",l.MISSING_NEW="MISSING_NEW",l.INVALID_ARGUMENT="INVALID_ARGUMENT",l.MISSING_ARGUMENT="MISSING_ARGUMENT",l.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",l.CALL_EXCEPTION="CALL_EXCEPTION",l.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",l.NONCE_EXPIRED="NONCE_EXPIRED",l.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",l.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",l.TRANSACTION_REPLACED="TRANSACTION_REPLACED",l.ACTION_REJECTED="ACTION_REJECTED";const m="0123456789abcdef";class f{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,r){const i=t.toLowerCase();null==o[i]&&this.throwArgumentError("invalid log level name","logLevel",t),h>o[i]||console.log.apply(console,r)}debug(...t){this._log(f.levels.DEBUG,t)}info(...t){this._log(f.levels.INFO,t)}warn(...t){this._log(f.levels.WARNING,t)}makeError(t,r,i){if(n)return this.makeError("censored error",r,{});r||(r=f.errors.UNKNOWN_ERROR),i||(i={});const e=[];Object.keys(i).forEach((t=>{const r=i[t];try{if(r instanceof Uint8Array){let i="";for(let t=0;t<r.length;t++)i+=m[r[t]>>4],i+=m[15&r[t]];e.push(t+"=Uint8Array(0x"+i+")")}else e.push(t+"="+JSON.stringify(r))}catch(r){e.push(t+"="+JSON.stringify(i[t].toString()))}})),e.push(`code=${r}`),e.push(`version=${this.version}`);const o=t;let h="";switch(r){case exports.ErrorCode.NUMERIC_FAULT:{h="NUMERIC_FAULT";const r=t;switch(r){case"overflow":case"underflow":case"division-by-zero":h+="-"+r;break;case"negative-power":case"negative-width":h+="-unsupported";break;case"unbound-bitwise-result":h+="-unbound-result"}break}case exports.ErrorCode.CALL_EXCEPTION:case exports.ErrorCode.INSUFFICIENT_FUNDS:case exports.ErrorCode.MISSING_NEW:case exports.ErrorCode.NONCE_EXPIRED:case exports.ErrorCode.REPLACEMENT_UNDERPRICED:case exports.ErrorCode.TRANSACTION_REPLACED:case exports.ErrorCode.UNPREDICTABLE_GAS_LIMIT:h=r}h&&(t+=" [ See: https://links.ethers.org/v5-errors-"+h+" ]"),e.length&&(t+=" ("+e.join(", ")+")");const s=new Error(t);return s.reason=o,s.code=r,Object.keys(i).forEach((function(t){s[t]=i[t]})),s}throwError(t,r,i){throw this.makeError(t,r,i)}throwArgumentError(t,r,i){return this.throwError(t,f.errors.INVALID_ARGUMENT,{argument:r,value:i})}assert(t,r,i,e){t||this.throwError(r,i,e)}assertArgument(t,r,i,e){t||this.throwArgumentError(r,i,e)}checkNormalize(t){u&&this.throwError("platform missing String.prototype.normalize",f.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:u})}checkSafeUint53(t,r){"number"==typeof t&&(null==r&&(r="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(r,f.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,f.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,r,i){i=i?": "+i:"",t<r&&this.throwError("missing argument"+i,f.errors.MISSING_ARGUMENT,{count:t,expectedCount:r}),t>r&&this.throwError("too many arguments"+i,f.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})}checkNew(t,r){t!==Object&&null!=t||this.throwError("missing new",f.errors.MISSING_NEW,{name:r.name})}checkAbstract(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",f.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",f.errors.MISSING_NEW,{name:r.name})}static globalLogger(){return s||(s=new f("logger/5.7.0")),s}static setCensorship(t,r){if(!t&&r&&this.globalLogger().throwError("cannot permanently disable censorship",f.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),e){if(!t)return;this.globalLogger().throwError("error censorship permanent",f.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}n=!!t,e=!!r}static setLogLevel(t){const r=o[t.toLowerCase()];null!=r?h=r:f.globalLogger().warn("invalid log level - "+t)}static from(t){return new f(t)}}f.errors=exports.ErrorCode,f.levels=a;var d=Object.freeze({__proto__:null,get LogLevel(){return a},get ErrorCode(){return exports.ErrorCode},Logger:f}),p={exports:{}};!function(t,i){function e(t,r){if(!t)throw new Error(r||"Assertion failed")}function n(t,r){t.super_=r;var i=function(){};i.prototype=r.prototype,t.prototype=new i,t.prototype.constructor=t}function o(t,r,i){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==r&&"be"!==r||(i=r,r=10),this._init(t||0,r||10,i||"be"))}var h;"object"==typeof t?t.exports=o:i.BN=o,o.BN=o,o.wordSize=26;try{h="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:r.require$$1.Buffer}catch(t){}function s(t,r){var i=t.charCodeAt(r);return i>=48&&i<=57?i-48:i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:void e(!1,"Invalid character in "+t)}function u(t,r,i){var e=s(t,i);return i-1>=r&&(e|=s(t,i-1)<<4),e}function a(t,r,i,n){for(var o=0,h=0,s=Math.min(t.length,i),u=r;u<s;u++){var a=t.charCodeAt(u)-48;o*=n,h=a>=49?a-49+10:a>=17?a-17+10:a,e(a>=0&&h<n,"Invalid character"),o+=h}return o}function l(t,r){t.words=r.words,t.length=r.length,t.negative=r.negative,t.red=r.red}if(o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,r){return t.cmp(r)>0?t:r},o.min=function(t,r){return t.cmp(r)<0?t:r},o.prototype._init=function(t,r,i){if("number"==typeof t)return this._initNumber(t,r,i);if("object"==typeof t)return this._initArray(t,r,i);"hex"===r&&(r=16),e(r===(0|r)&&r>=2&&r<=36);var n=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(n++,this.negative=1),n<t.length&&(16===r?this._parseHex(t,n,i):(this._parseBase(t,r,n),"le"===i&&this._initArray(this.toArray(),r,i)))},o.prototype._initNumber=function(t,r,i){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(e(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),r,i)},o.prototype._initArray=function(t,r,i){if(e("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var o,h,s=0;if("be"===i)for(n=t.length-1,o=0;n>=0;n-=3)h=t[n]|t[n-1]<<8|t[n-2]<<16,this.words[o]|=h<<s&67108863,this.words[o+1]=h>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===i)for(n=0,o=0;n<t.length;n+=3)h=t[n]|t[n+1]<<8|t[n+2]<<16,this.words[o]|=h<<s&67108863,this.words[o+1]=h>>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},o.prototype._parseHex=function(t,r,i){this.length=Math.ceil((t.length-r)/6),this.words=new Array(this.length);for(var e=0;e<this.length;e++)this.words[e]=0;var n,o=0,h=0;if("be"===i)for(e=t.length-1;e>=r;e-=2)n=u(t,r,e)<<o,this.words[h]|=67108863&n,o>=18?(o-=18,h+=1,this.words[h]|=n>>>26):o+=8;else for(e=(t.length-r)%2==0?r+1:r;e<t.length;e+=2)n=u(t,r,e)<<o,this.words[h]|=67108863&n,o>=18?(o-=18,h+=1,this.words[h]|=n>>>26):o+=8;this._strip()},o.prototype._parseBase=function(t,r,i){this.words=[0],this.length=1;for(var e=0,n=1;n<=67108863;n*=r)e++;e--,n=n/r|0;for(var o=t.length-i,h=o%e,s=Math.min(o,o-h)+i,u=0,l=i;l<s;l+=e)u=a(t,l,l+e,r),this.imuln(n),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==h){var m=1;for(u=a(t,l,t.length,r),l=0;l<h;l++)m*=r;this.imuln(m),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},o.prototype.copy=function(t){t.words=new Array(this.length);for(var r=0;r<this.length;r++)t.words[r]=this.words[r];t.length=this.length,t.negative=this.negative,t.red=this.red},o.prototype._move=function(t){l(t,this)},o.prototype.clone=function(){var t=new o(null);return this.copy(t),t},o.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=m}catch(t){o.prototype.inspect=m}else o.prototype.inspect=m;function m(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function g(t,r,i){i.negative=r.negative^t.negative;var e=t.length+r.length|0;i.length=e,e=e-1|0;var n=0|t.words[0],o=0|r.words[0],h=n*o,s=67108863&h,u=h/67108864|0;i.words[0]=s;for(var a=1;a<e;a++){for(var l=u>>>26,m=67108863&u,f=Math.min(a,r.length-1),d=Math.max(0,a-t.length+1);d<=f;d++){var p=a-d|0;l+=(h=(n=0|t.words[p])*(o=0|r.words[d])+m)/67108864|0,m=67108863&h}i.words[a]=0|m,u=0|l}return 0!==u?i.words[a]=0|u:i.length--,i._strip()}o.prototype.toString=function(t,r){var i;if(r=0|r||1,16===(t=t||10)||"hex"===t){i="";for(var n=0,o=0,h=0;h<this.length;h++){var s=this.words[h],u=(16777215&(s<<n|o)).toString(16);o=s>>>24-n&16777215,(n+=2)>=26&&(n-=26,h--),i=0!==o||h!==this.length-1?f[6-u.length]+u+i:u+i}for(0!==o&&(i=o.toString(16)+i);i.length%r!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(t===(0|t)&&t>=2&&t<=36){var a=d[t],l=p[t];i="";var m=this.clone();for(m.negative=0;!m.isZero();){var g=m.modrn(l).toString(t);i=(m=m.idivn(l)).isZero()?g+i:f[a-g.length]+g+i}for(this.isZero()&&(i="0"+i);i.length%r!=0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}e(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&e(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16,2)},h&&(o.prototype.toBuffer=function(t,r){return this.toArrayLike(h,t,r)}),o.prototype.toArray=function(t,r){return this.toArrayLike(Array,t,r)},o.prototype.toArrayLike=function(t,r,i){this._strip();var n=this.byteLength(),o=i||Math.max(1,n);e(n<=o,"byte array longer than desired length"),e(o>0,"Requested array length <= 0");var h=function(t,r){return t.allocUnsafe?t.allocUnsafe(r):new t(r)}(t,o);return this["_toArrayLike"+("le"===r?"LE":"BE")](h,n),h},o.prototype._toArrayLikeLE=function(t,r){for(var i=0,e=0,n=0,o=0;n<this.length;n++){var h=this.words[n]<<o|e;t[i++]=255&h,i<t.length&&(t[i++]=h>>8&255),i<t.length&&(t[i++]=h>>16&255),6===o?(i<t.length&&(t[i++]=h>>24&255),e=0,o=0):(e=h>>>24,o+=2)}if(i<t.length)for(t[i++]=e;i<t.length;)t[i++]=0},o.prototype._toArrayLikeBE=function(t,r){for(var i=t.length-1,e=0,n=0,o=0;n<this.length;n++){var h=this.words[n]<<o|e;t[i--]=255&h,i>=0&&(t[i--]=h>>8&255),i>=0&&(t[i--]=h>>16&255),6===o?(i>=0&&(t[i--]=h>>24&255),e=0,o=0):(e=h>>>24,o+=2)}if(i>=0)for(t[i--]=e;i>=0;)t[i--]=0},Math.clz32?o.prototype._countBits=function(t){return 32-Math.clz32(t)}:o.prototype._countBits=function(t){var r=t,i=0;return r>=4096&&(i+=13,r>>>=13),r>=64&&(i+=7,r>>>=7),r>=8&&(i+=4,r>>>=4),r>=2&&(i+=2,r>>>=2),i+r},o.prototype._zeroBits=function(t){if(0===t)return 26;var r=t,i=0;return 0==(8191&r)&&(i+=13,r>>>=13),0==(127&r)&&(i+=7,r>>>=7),0==(15&r)&&(i+=4,r>>>=4),0==(3&r)&&(i+=2,r>>>=2),0==(1&r)&&i++,i},o.prototype.bitLength=function(){var t=this.words[this.length-1],r=this._countBits(t);return 26*(this.length-1)+r},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,r=0;r<this.length;r++){var i=this._zeroBits(this.words[r]);if(t+=i,26!==i)break}return t},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},o.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return 0!==this.negative},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]|t.words[r];return this._strip()},o.prototype.ior=function(t){return e(0==(this.negative|t.negative)),this.iuor(t)},o.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var r;r=this.length>t.length?t:this;for(var i=0;i<r.length;i++)this.words[i]=this.words[i]&t.words[i];return this.length=r.length,this._strip()},o.prototype.iand=function(t){return e(0==(this.negative|t.negative)),this.iuand(t)},o.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var r,i;this.length>t.length?(r=this,i=t):(r=t,i=this);for(var e=0;e<i.length;e++)this.words[e]=r.words[e]^i.words[e];if(this!==r)for(;e<r.length;e++)this.words[e]=r.words[e];return this.length=r.length,this._strip()},o.prototype.ixor=function(t){return e(0==(this.negative|t.negative)),this.iuxor(t)},o.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){e("number"==typeof t&&t>=0);var r=0|Math.ceil(t/26),i=t%26;this._expand(r),i>0&&r--;for(var n=0;n<r;n++)this.words[n]=67108863&~this.words[n];return i>0&&(this.words[n]=~this.words[n]&67108863>>26-i),this._strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,r){e("number"==typeof t&&t>=0);var i=t/26|0,n=t%26;return this._expand(i+1),this.words[i]=r?this.words[i]|1<<n:this.words[i]&~(1<<n),this._strip()},o.prototype.iadd=function(t){var r,i,e;if(0!==this.negative&&0===t.negative)return this.negative=0,r=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,r=this.isub(t),t.negative=1,r._normSign();this.length>t.length?(i=this,e=t):(i=t,e=this);for(var n=0,o=0;o<e.length;o++)r=(0|i.words[o])+(0|e.words[o])+n,this.words[o]=67108863&r,n=r>>>26;for(;0!==n&&o<i.length;o++)r=(0|i.words[o])+n,this.words[o]=67108863&r,n=r>>>26;if(this.length=i.length,0!==n)this.words[this.length]=n,this.length++;else if(i!==this)for(;o<i.length;o++)this.words[o]=i.words[o];return this},o.prototype.add=function(t){var r;return 0!==t.negative&&0===this.negative?(t.negative=0,r=this.sub(t),t.negative^=1,r):0===t.negative&&0!==this.negative?(this.negative=0,r=t.sub(this),this.negative=1,r):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var r=this.iadd(t);return t.negative=1,r._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var i,e,n=this.cmp(t);if(0===n)return this.negative=0,this.length=1,this.words[0]=0,this;n>0?(i=this,e=t):(i=t,e=this);for(var o=0,h=0;h<e.length;h++)o=(r=(0|i.words[h])-(0|e.words[h])+o)>>26,this.words[h]=67108863&r;for(;0!==o&&h<i.length;h++)o=(r=(0|i.words[h])+o)>>26,this.words[h]=67108863&r;if(0===o&&h<i.length&&i!==this)for(;h<i.length;h++)this.words[h]=i.words[h];return this.length=Math.max(this.length,h),i!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(t){return this.clone().isub(t)};var c=function(t,r,i){var e,n,o,h=t.words,s=r.words,u=i.words,a=0,l=0|h[0],m=8191&l,f=l>>>13,d=0|h[1],p=8191&d,g=d>>>13,c=0|h[2],M=8191&c,v=c>>>13,w=0|h[3],y=8191&w,E=w>>>13,b=0|h[4],N=8191&b,_=b>>>13,R=0|h[5],U=8191&R,S=R>>>13,x=0|h[6],A=8191&x,I=x>>>13,T=0|h[7],O=8191&T,C=T>>>13,k=0|h[8],L=8191&k,F=k>>>13,P=0|h[9],B=8191&P,D=P>>>13,G=0|s[0],q=8191&G,z=G>>>13,Z=0|s[1],j=8191&Z,X=Z>>>13,K=0|s[2],V=8191&K,W=K>>>13,H=0|s[3],$=8191&H,J=H>>>13,Q=0|s[4],Y=8191&Q,tt=Q>>>13,rt=0|s[5],it=8191&rt,et=rt>>>13,nt=0|s[6],ot=8191&nt,ht=nt>>>13,st=0|s[7],ut=8191&st,at=st>>>13,lt=0|s[8],mt=8191&lt,ft=lt>>>13,dt=0|s[9],pt=8191&dt,gt=dt>>>13;i.negative=t.negative^r.negative,i.length=19;var ct=(a+(e=Math.imul(m,q))|0)+((8191&(n=(n=Math.imul(m,z))+Math.imul(f,q)|0))<<13)|0;a=((o=Math.imul(f,z))+(n>>>13)|0)+(ct>>>26)|0,ct&=67108863,e=Math.imul(p,q),n=(n=Math.imul(p,z))+Math.imul(g,q)|0,o=Math.imul(g,z);var Mt=(a+(e=e+Math.imul(m,j)|0)|0)+((8191&(n=(n=n+Math.imul(m,X)|0)+Math.imul(f,j)|0))<<13)|0;a=((o=o+Math.imul(f,X)|0)+(n>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,e=Math.imul(M,q),n=(n=Math.imul(M,z))+Math.imul(v,q)|0,o=Math.imul(v,z),e=e+Math.imul(p,j)|0,n=(n=n+Math.imul(p,X)|0)+Math.imul(g,j)|0,o=o+Math.imul(g,X)|0;var vt=(a+(e=e+Math.imul(m,V)|0)|0)+((8191&(n=(n=n+Math.imul(m,W)|0)+Math.imul(f,V)|0))<<13)|0;a=((o=o+Math.imul(f,W)|0)+(n>>>13)|0)+(vt>>>26)|0,vt&=67108863,e=Math.imul(y,q),n=(n=Math.imul(y,z))+Math.imul(E,q)|0,o=Math.imul(E,z),e=e+Math.imul(M,j)|0,n=(n=n+Math.imul(M,X)|0)+Math.imul(v,j)|0,o=o+Math.imul(v,X)|0,e=e+Math.imul(p,V)|0,n=(n=n+Math.imul(p,W)|0)+Math.imul(g,V)|0,o=o+Math.imul(g,W)|0;var wt=(a+(e=e+Math.imul(m,$)|0)|0)+((8191&(n=(n=n+Math.imul(m,J)|0)+Math.imul(f,$)|0))<<13)|0;a=((o=o+Math.imul(f,J)|0)+(n>>>13)|0)+(wt>>>26)|0,wt&=67108863,e=Math.imul(N,q),n=(n=Math.imul(N,z))+Math.imul(_,q)|0,o=Math.imul(_,z),e=e+Math.imul(y,j)|0,n=(n=n+Math.imul(y,X)|0)+Math.imul(E,j)|0,o=o+Math.imul(E,X)|0,e=e+Math.imul(M,V)|0,n=(n=n+Math.imul(M,W)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,W)|0,e=e+Math.imul(p,$)|0,n=(n=n+Math.imul(p,J)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,J)|0;var yt=(a+(e=e+Math.imul(m,Y)|0)|0)+((8191&(n=(n=n+Math.imul(m,tt)|0)+Math.imul(f,Y)|0))<<13)|0;a=((o=o+Math.imul(f,tt)|0)+(n>>>13)|0)+(yt>>>26)|0,yt&=67108863,e=Math.imul(U,q),n=(n=Math.imul(U,z))+Math.imul(S,q)|0,o=Math.imul(S,z),e=e+Math.imul(N,j)|0,n=(n=n+Math.imul(N,X)|0)+Math.imul(_,j)|0,o=o+Math.imul(_,X)|0,e=e+Math.imul(y,V)|0,n=(n=n+Math.imul(y,W)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,W)|0,e=e+Math.imul(M,$)|0,n=(n=n+Math.imul(M,J)|0)+Math.imul(v,$)|0,o=o+Math.imul(v,J)|0,e=e+Math.imul(p,Y)|0,n=(n=n+Math.imul(p,tt)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,tt)|0;var Et=(a+(e=e+Math.imul(m,it)|0)|0)+((8191&(n=(n=n+Math.imul(m,et)|0)+Math.imul(f,it)|0))<<13)|0;a=((o=o+Math.imul(f,et)|0)+(n>>>13)|0)+(Et>>>26)|0,Et&=67108863,e=Math.imul(A,q),n=(n=Math.imul(A,z))+Math.imul(I,q)|0,o=Math.imul(I,z),e=e+Math.imul(U,j)|0,n=(n=n+Math.imul(U,X)|0)+Math.imul(S,j)|0,o=o+Math.imul(S,X)|0,e=e+Math.imul(N,V)|0,n=(n=n+Math.imul(N,W)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,W)|0,e=e+Math.imul(y,$)|0,n=(n=n+Math.imul(y,J)|0)+Math.imul(E,$)|0,o=o+Math.imul(E,J)|0,e=e+Math.imul(M,Y)|0,n=(n=n+Math.imul(M,tt)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,tt)|0,e=e+Math.imul(p,it)|0,n=(n=n+Math.imul(p,et)|0)+Math.imul(g,it)|0,o=o+Math.imul(g,et)|0;var bt=(a+(e=e+Math.imul(m,ot)|0)|0)+((8191&(n=(n=n+Math.imul(m,ht)|0)+Math.imul(f,ot)|0))<<13)|0;a=((o=o+Math.imul(f,ht)|0)+(n>>>13)|0)+(bt>>>26)|0,bt&=67108863,e=Math.imul(O,q),n=(n=Math.imul(O,z))+Math.imul(C,q)|0,o=Math.imul(C,z),e=e+Math.imul(A,j)|0,n=(n=n+Math.imul(A,X)|0)+Math.imul(I,j)|0,o=o+Math.imul(I,X)|0,e=e+Math.imul(U,V)|0,n=(n=n+Math.imul(U,W)|0)+Math.imul(S,V)|0,o=o+Math.imul(S,W)|0,e=e+Math.imul(N,$)|0,n=(n=n+Math.imul(N,J)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,J)|0,e=e+Math.imul(y,Y)|0,n=(n=n+Math.imul(y,tt)|0)+Math.imul(E,Y)|0,o=o+Math.imul(E,tt)|0,e=e+Math.imul(M,it)|0,n=(n=n+Math.imul(M,et)|0)+Math.imul(v,it)|0,o=o+Math.imul(v,et)|0,e=e+Math.imul(p,ot)|0,n=(n=n+Math.imul(p,ht)|0)+Math.imul(g,ot)|0,o=o+Math.imul(g,ht)|0;var Nt=(a+(e=e+Math.imul(m,ut)|0)|0)+((8191&(n=(n=n+Math.imul(m,at)|0)+Math.imul(f,ut)|0))<<13)|0;a=((o=o+Math.imul(f,at)|0)+(n>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,e=Math.imul(L,q),n=(n=Math.imul(L,z))+Math.imul(F,q)|0,o=Math.imul(F,z),e=e+Math.imul(O,j)|0,n=(n=n+Math.imul(O,X)|0)+Math.imul(C,j)|0,o=o+Math.imul(C,X)|0,e=e+Math.imul(A,V)|0,n=(n=n+Math.imul(A,W)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,W)|0,e=e+Math.imul(U,$)|0,n=(n=n+Math.imul(U,J)|0)+Math.imul(S,$)|0,o=o+Math.imul(S,J)|0,e=e+Math.imul(N,Y)|0,n=(n=n+Math.imul(N,tt)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,tt)|0,e=e+Math.imul(y,it)|0,n=(n=n+Math.imul(y,et)|0)+Math.imul(E,it)|0,o=o+Math.imul(E,et)|0,e=e+Math.imul(M,ot)|0,n=(n=n+Math.imul(M,ht)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,ht)|0,e=e+Math.imul(p,ut)|0,n=(n=n+Math.imul(p,at)|0)+Math.imul(g,ut)|0,o=o+Math.imul(g,at)|0;var _t=(a+(e=e+Math.imul(m,mt)|0)|0)+((8191&(n=(n=n+Math.imul(m,ft)|0)+Math.imul(f,mt)|0))<<13)|0;a=((o=o+Math.imul(f,ft)|0)+(n>>>13)|0)+(_t>>>26)|0,_t&=67108863,e=Math.imul(B,q),n=(n=Math.imul(B,z))+Math.imul(D,q)|0,o=Math.imul(D,z),e=e+Math.imul(L,j)|0,n=(n=n+Math.imul(L,X)|0)+Math.imul(F,j)|0,o=o+Math.imul(F,X)|0,e=e+Math.imul(O,V)|0,n=(n=n+Math.imul(O,W)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,W)|0,e=e+Math.imul(A,$)|0,n=(n=n+Math.imul(A,J)|0)+Math.imul(I,$)|0,o=o+Math.imul(I,J)|0,e=e+Math.imul(U,Y)|0,n=(n=n+Math.imul(U,tt)|0)+Math.imul(S,Y)|0,o=o+Math.imul(S,tt)|0,e=e+Math.imul(N,it)|0,n=(n=n+Math.imul(N,et)|0)+Math.imul(_,it)|0,o=o+Math.imul(_,et)|0,e=e+Math.imul(y,ot)|0,n=(n=n+Math.imul(y,ht)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,ht)|0,e=e+Math.imul(M,ut)|0,n=(n=n+Math.imul(M,at)|0)+Math.imul(v,ut)|0,o=o+Math.imul(v,at)|0,e=e+Math.imul(p,mt)|0,n=(n=n+Math.imul(p,ft)|0)+Math.imul(g,mt)|0,o=o+Math.imul(g,ft)|0;var Rt=(a+(e=e+Math.imul(m,pt)|0)|0)+((8191&(n=(n=n+Math.imul(m,gt)|0)+Math.imul(f,pt)|0))<<13)|0;a=((o=o+Math.imul(f,gt)|0)+(n>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,e=Math.imul(B,j),n=(n=Math.imul(B,X))+Math.imul(D,j)|0,o=Math.imul(D,X),e=e+Math.imul(L,V)|0,n=(n=n+Math.imul(L,W)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,W)|0,e=e+Math.imul(O,$)|0,n=(n=n+Math.imul(O,J)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,J)|0,e=e+Math.imul(A,Y)|0,n=(n=n+Math.imul(A,tt)|0)+Math.imul(I,Y)|0,o=o+Math.imul(I,tt)|0,e=e+Math.imul(U,it)|0,n=(n=n+Math.imul(U,et)|0)+Math.imul(S,it)|0,o=o+Math.imul(S,et)|0,e=e+Math.imul(N,ot)|0,n=(n=n+Math.imul(N,ht)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,ht)|0,e=e+Math.imul(y,ut)|0,n=(n=n+Math.imul(y,at)|0)+Math.imul(E,ut)|0,o=o+Math.imul(E,at)|0,e=e+Math.imul(M,mt)|0,n=(n=n+Math.imul(M,ft)|0)+Math.imul(v,mt)|0,o=o+Math.imul(v,ft)|0;var Ut=(a+(e=e+Math.imul(p,pt)|0)|0)+((8191&(n=(n=n+Math.imul(p,gt)|0)+Math.imul(g,pt)|0))<<13)|0;a=((o=o+Math.imul(g,gt)|0)+(n>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,e=Math.imul(B,V),n=(n=Math.imul(B,W))+Math.imul(D,V)|0,o=Math.imul(D,W),e=e+Math.imul(L,$)|0,n=(n=n+Math.imul(L,J)|0)+Math.imul(F,$)|0,o=o+Math.imul(F,J)|0,e=e+Math.imul(O,Y)|0,n=(n=n+Math.imul(O,tt)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,tt)|0,e=e+Math.imul(A,it)|0,n=(n=n+Math.imul(A,et)|0)+Math.imul(I,it)|0,o=o+Math.imul(I,et)|0,e=e+Math.imul(U,ot)|0,n=(n=n+Math.imul(U,ht)|0)+Math.imul(S,ot)|0,o=o+Math.imul(S,ht)|0,e=e+Math.imul(N,ut)|0,n=(n=n+Math.imul(N,at)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,at)|0,e=e+Math.imul(y,mt)|0,n=(n=n+Math.imul(y,ft)|0)+Math.imul(E,mt)|0,o=o+Math.imul(E,ft)|0;var St=(a+(e=e+Math.imul(M,pt)|0)|0)+((8191&(n=(n=n+Math.imul(M,gt)|0)+Math.imul(v,pt)|0))<<13)|0;a=((o=o+Math.imul(v,gt)|0)+(n>>>13)|0)+(St>>>26)|0,St&=67108863,e=Math.imul(B,$),n=(n=Math.imul(B,J))+Math.imul(D,$)|0,o=Math.imul(D,J),e=e+Math.imul(L,Y)|0,n=(n=n+Math.imul(L,tt)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,tt)|0,e=e+Math.imul(O,it)|0,n=(n=n+Math.imul(O,et)|0)+Math.imul(C,it)|0,o=o+Math.imul(C,et)|0,e=e+Math.imul(A,ot)|0,n=(n=n+Math.imul(A,ht)|0)+Math.imul(I,ot)|0,o=o+Math.imul(I,ht)|0,e=e+Math.imul(U,ut)|0,n=(n=n+Math.imul(U,at)|0)+Math.imul(S,ut)|0,o=o+Math.imul(S,at)|0,e=e+Math.imul(N,mt)|0,n=(n=n+Math.imul(N,ft)|0)+Math.imul(_,mt)|0,o=o+Math.imul(_,ft)|0;var xt=(a+(e=e+Math.imul(y,pt)|0)|0)+((8191&(n=(n=n+Math.imul(y,gt)|0)+Math.imul(E,pt)|0))<<13)|0;a=((o=o+Math.imul(E,gt)|0)+(n>>>13)|0)+(xt>>>26)|0,xt&=67108863,e=Math.imul(B,Y),n=(n=Math.imul(B,tt))+Math.imul(D,Y)|0,o=Math.imul(D,tt),e=e+Math.imul(L,it)|0,n=(n=n+Math.imul(L,et)|0)+Math.imul(F,it)|0,o=o+Math.imul(F,et)|0,e=e+Math.imul(O,ot)|0,n=(n=n+Math.imul(O,ht)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,ht)|0,e=e+Math.imul(A,ut)|0,n=(n=n+Math.imul(A,at)|0)+Math.imul(I,ut)|0,o=o+Math.imul(I,at)|0,e=e+Math.imul(U,mt)|0,n=(n=n+Math.imul(U,ft)|0)+Math.imul(S,mt)|0,o=o+Math.imul(S,ft)|0;var At=(a+(e=e+Math.imul(N,pt)|0)|0)+((8191&(n=(n=n+Math.imul(N,gt)|0)+Math.imul(_,pt)|0))<<13)|0;a=((o=o+Math.imul(_,gt)|0)+(n>>>13)|0)+(At>>>26)|0,At&=67108863,e=Math.imul(B,it),n=(n=Math.imul(B,et))+Math.imul(D,it)|0,o=Math.imul(D,et),e=e+Math.imul(L,ot)|0,n=(n=n+Math.imul(L,ht)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,ht)|0,e=e+Math.imul(O,ut)|0,n=(n=n+Math.imul(O,at)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,at)|0,e=e+Math.imul(A,mt)|0,n=(n=n+Math.imul(A,ft)|0)+Math.imul(I,mt)|0,o=o+Math.imul(I,ft)|0;var It=(a+(e=e+Math.imul(U,pt)|0)|0)+((8191&(n=(n=n+Math.imul(U,gt)|0)+Math.imul(S,pt)|0))<<13)|0;a=((o=o+Math.imul(S,gt)|0)+(n>>>13)|0)+(It>>>26)|0,It&=67108863,e=Math.imul(B,ot),n=(n=Math.imul(B,ht))+Math.imul(D,ot)|0,o=Math.imul(D,ht),e=e+Math.imul(L,ut)|0,n=(n=n+Math.imul(L,at)|0)+Math.imul(F,ut)|0,o=o+Math.imul(F,at)|0,e=e+Math.imul(O,mt)|0,n=(n=n+Math.imul(O,ft)|0)+Math.imul(C,mt)|0,o=o+Math.imul(C,ft)|0;var Tt=(a+(e=e+Math.imul(A,pt)|0)|0)+((8191&(n=(n=n+Math.imul(A,gt)|0)+Math.imul(I,pt)|0))<<13)|0;a=((o=o+Math.imul(I,gt)|0)+(n>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,e=Math.imul(B,ut),n=(n=Math.imul(B,at))+Math.imul(D,ut)|0,o=Math.imul(D,at),e=e+Math.imul(L,mt)|0,n=(n=n+Math.imul(L,ft)|0)+Math.imul(F,mt)|0,o=o+Math.imul(F,ft)|0;var Ot=(a+(e=e+Math.imul(O,pt)|0)|0)+((8191&(n=(n=n+Math.imul(O,gt)|0)+Math.imul(C,pt)|0))<<13)|0;a=((o=o+Math.imul(C,gt)|0)+(n>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,e=Math.imul(B,mt),n=(n=Math.imul(B,ft))+Math.imul(D,mt)|0,o=Math.imul(D,ft);var Ct=(a+(e=e+Math.imul(L,pt)|0)|0)+((8191&(n=(n=n+Math.imul(L,gt)|0)+Math.imul(F,pt)|0))<<13)|0;a=((o=o+Math.imul(F,gt)|0)+(n>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var kt=(a+(e=Math.imul(B,pt))|0)+((8191&(n=(n=Math.imul(B,gt))+Math.imul(D,pt)|0))<<13)|0;return a=((o=Math.imul(D,gt))+(n>>>13)|0)+(kt>>>26)|0,kt&=67108863,u[0]=ct,u[1]=Mt,u[2]=vt,u[3]=wt,u[4]=yt,u[5]=Et,u[6]=bt,u[7]=Nt,u[8]=_t,u[9]=Rt,u[10]=Ut,u[11]=St,u[12]=xt,u[13]=At,u[14]=It,u[15]=Tt,u[16]=Ot,u[17]=Ct,u[18]=kt,0!==a&&(u[19]=a,i.length++),i};function M(t,r,i){i.negative=r.negative^t.negative,i.length=t.length+r.length;for(var e=0,n=0,o=0;o<i.length-1;o++){var h=n;n=0;for(var s=67108863&e,u=Math.min(o,r.length-1),a=Math.max(0,o-t.length+1);a<=u;a++){var l=o-a,m=(0|t.words[l])*(0|r.words[a]),f=67108863&m;s=67108863&(f=f+s|0),n+=(h=(h=h+(m/67108864|0)|0)+(f>>>26)|0)>>>26,h&=67108863}i.words[o]=s,e=h,h=n}return 0!==e?i.words[o]=e:i.length--,i._strip()}function v(t,r,i){return M(t,r,i)}Math.imul||(c=g),o.prototype.mulTo=function(t,r){var i=this.length+t.length;return 10===this.length&&10===t.length?c(this,t,r):i<63?g(this,t,r):i<1024?M(this,t,r):v(this,t,r)},o.prototype.mul=function(t){var r=new o(null);return r.words=new Array(this.length+t.length),this.mulTo(t,r)},o.prototype.mulf=function(t){var r=new o(null);return r.words=new Array(this.length+t.length),v(this,t,r)},o.prototype.imul=function(t){return this.clone().mulTo(t,this)},o.prototype.imuln=function(t){var r=t<0;r&&(t=-t),e("number"==typeof t),e(t<67108864);for(var i=0,n=0;n<this.length;n++){var o=(0|this.words[n])*t,h=(67108863&o)+(67108863&i);i>>=26,i+=o/67108864|0,i+=h>>>26,this.words[n]=67108863&h}return 0!==i&&(this.words[n]=i,this.length++),r?this.ineg():this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var r=function(t){for(var r=new Array(t.bitLength()),i=0;i<r.length;i++){var e=i/26|0,n=i%26;r[i]=t.words[e]>>>n&1}return r}(t);if(0===r.length)return new o(1);for(var i=this,e=0;e<r.length&&0===r[e];e++,i=i.sqr());if(++e<r.length)for(var n=i.sqr();e<r.length;e++,n=n.sqr())0!==r[e]&&(i=i.mul(n));return i},o.prototype.iushln=function(t){e("number"==typeof t&&t>=0);var r,i=t%26,n=(t-i)/26,o=67108863>>>26-i<<26-i;if(0!==i){var h=0;for(r=0;r<this.length;r++){var s=this.words[r]&o,u=(0|this.words[r])-s<<i;this.words[r]=u|h,h=s>>>26-i}h&&(this.words[r]=h,this.length++)}if(0!==n){for(r=this.length-1;r>=0;r--)this.words[r+n]=this.words[r];for(r=0;r<n;r++)this.words[r]=0;this.length+=n}return this._strip()},o.prototype.ishln=function(t){return e(0===this.negative),this.iushln(t)},o.prototype.iushrn=function(t,r,i){var n;e("number"==typeof t&&t>=0),n=r?(r-r%26)/26:0;var o=t%26,h=Math.min((t-o)/26,this.length),s=67108863^67108863>>>o<<o,u=i;if(n-=h,n=Math.max(0,n),u){for(var a=0;a<h;a++)u.words[a]=this.words[a];u.length=h}if(0===h);else if(this.length>h)for(this.length-=h,a=0;a<this.length;a++)this.words[a]=this.words[a+h];else this.words[0]=0,this.length=1;var l=0;for(a=this.length-1;a>=0&&(0!==l||a>=n);a--){var m=0|this.words[a];this.words[a]=l<<26-o|m>>>o,l=m&s}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(t,r,i){return e(0===this.negative),this.iushrn(t,r,i)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){e("number"==typeof t&&t>=0);var r=t%26,i=(t-r)/26,n=1<<r;return!(this.length<=i||!(this.words[i]&n))},o.prototype.imaskn=function(t){e("number"==typeof t&&t>=0);var r=t%26,i=(t-r)/26;if(e(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==r&&i++,this.length=Math.min(i,this.length),0!==r){var n=67108863^67108863>>>r<<r;this.words[this.length-1]&=n}return this._strip()},o.prototype.maskn=function(t){return this.clone().imaskn(t)},o.prototype.iaddn=function(t){return e("number"==typeof t),e(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},o.prototype._iaddn=function(t){this.words[0]+=t;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},o.prototype.isubn=function(t){if(e("number"==typeof t),e(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this._strip()},o.prototype.addn=function(t){return this.clone().iaddn(t)},o.prototype.subn=function(t){return this.clone().isubn(t)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(t,r,i){var n,o,h=t.length+i;this._expand(h);var s=0;for(n=0;n<t.length;n++){o=(0|this.words[n+i])+s;var u=(0|t.words[n])*r;s=((o-=67108863&u)>>26)-(u/67108864|0),this.words[n+i]=67108863&o}for(;n<this.length-i;n++)s=(o=(0|this.words[n+i])+s)>>26,this.words[n+i]=67108863&o;if(0===s)return this._strip();for(e(-1===s),s=0,n=0;n<this.length;n++)s=(o=-(0|this.words[n])+s)>>26,this.words[n]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(t,r){var i=(this.length,t.length),e=this.clone(),n=t,h=0|n.words[n.length-1];0!=(i=26-this._countBits(h))&&(n=n.ushln(i),e.iushln(i),h=0|n.words[n.length-1]);var s,u=e.length-n.length;if("mod"!==r){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var a=0;a<s.length;a++)s.words[a]=0}var l=e.clone()._ishlnsubmul(n,1,u);0===l.negative&&(e=l,s&&(s.words[u]=1));for(var m=u-1;m>=0;m--){var f=67108864*(0|e.words[n.length+m])+(0|e.words[n.length+m-1]);for(f=Math.min(f/h|0,67108863),e._ishlnsubmul(n,f,m);0!==e.negative;)f--,e.negative=0,e._ishlnsubmul(n,1,m),e.isZero()||(e.negative^=1);s&&(s.words[m]=f)}return s&&s._strip(),e._strip(),"div"!==r&&0!==i&&e.iushrn(i),{div:s||null,mod:e}},o.prototype.divmod=function(t,r,i){return e(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(s=this.neg().divmod(t,r),"mod"!==r&&(n=s.div.neg()),"div"!==r&&(h=s.mod.neg(),i&&0!==h.negative&&h.iadd(t)),{div:n,mod:h}):0===this.negative&&0!==t.negative?(s=this.divmod(t.neg(),r),"mod"!==r&&(n=s.div.neg()),{div:n,mod:s.mod}):0!=(this.negative&t.negative)?(s=this.neg().divmod(t.neg(),r),"div"!==r&&(h=s.mod.neg(),i&&0!==h.negative&&h.isub(t)),{div:s.div,mod:h}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===r?{div:this.divn(t.words[0]),mod:null}:"mod"===r?{div:null,mod:new o(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modrn(t.words[0]))}:this._wordDiv(t,r);var n,h,s},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var r=this.divmod(t);if(r.mod.isZero())return r.div;var i=0!==r.div.negative?r.mod.isub(t):r.mod,e=t.ushrn(1),n=t.andln(1),o=i.cmp(e);return o<0||1===n&&0===o?r.div:0!==r.div.negative?r.div.isubn(1):r.div.iaddn(1)},o.prototype.modrn=function(t){var r=t<0;r&&(t=-t),e(t<=67108863);for(var i=(1<<26)%t,n=0,o=this.length-1;o>=0;o--)n=(i*n+(0|this.words[o]))%t;return r?-n:n},o.prototype.modn=function(t){return this.modrn(t)},o.prototype.idivn=function(t){var r=t<0;r&&(t=-t),e(t<=67108863);for(var i=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*i;this.words[n]=o/t|0,i=o%t}return this._strip(),r?this.ineg():this},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){e(0===t.negative),e(!t.isZero());var r=this,i=t.clone();r=0!==r.negative?r.umod(t):r.clone();for(var n=new o(1),h=new o(0),s=new o(0),u=new o(1),a=0;r.isEven()&&i.isEven();)r.iushrn(1),i.iushrn(1),++a;for(var l=i.clone(),m=r.clone();!r.isZero();){for(var f=0,d=1;0==(r.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(r.iushrn(f);f-- >0;)(n.isOdd()||h.isOdd())&&(n.iadd(l),h.isub(m)),n.iushrn(1),h.iushrn(1);for(var p=0,g=1;0==(i.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(i.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(l),u.isub(m)),s.iushrn(1),u.iushrn(1);r.cmp(i)>=0?(r.isub(i),n.isub(s),h.isub(u)):(i.isub(r),s.isub(n),u.isub(h))}return{a:s,b:u,gcd:i.iushln(a)}},o.prototype._invmp=function(t){e(0===t.negative),e(!t.isZero());var r=this,i=t.clone();r=0!==r.negative?r.umod(t):r.clone();for(var n,h=new o(1),s=new o(0),u=i.clone();r.cmpn(1)>0&&i.cmpn(1)>0;){for(var a=0,l=1;0==(r.words[0]&l)&&a<26;++a,l<<=1);if(a>0)for(r.iushrn(a);a-- >0;)h.isOdd()&&h.iadd(u),h.iushrn(1);for(var m=0,f=1;0==(i.words[0]&f)&&m<26;++m,f<<=1);if(m>0)for(i.iushrn(m);m-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);r.cmp(i)>=0?(r.isub(i),h.isub(s)):(i.isub(r),s.isub(h))}return(n=0===r.cmpn(1)?h:s).cmpn(0)<0&&n.iadd(t),n},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var r=this.clone(),i=t.clone();r.negative=0,i.negative=0;for(var e=0;r.isEven()&&i.isEven();e++)r.iushrn(1),i.iushrn(1);for(;;){for(;r.isEven();)r.iushrn(1);for(;i.isEven();)i.iushrn(1);var n=r.cmp(i);if(n<0){var o=r;r=i,i=o}else if(0===n||0===i.cmpn(1))break;r.isub(i)}return i.iushln(e)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){e("number"==typeof t);var r=t%26,i=(t-r)/26,n=1<<r;if(this.length<=i)return this._expand(i+1),this.words[i]|=n,this;for(var o=n,h=i;0!==o&&h<this.length;h++){var s=0|this.words[h];o=(s+=o)>>>26,s&=67108863,this.words[h]=s}return 0!==o&&(this.words[h]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var r,i=t<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this._strip(),this.length>1)r=1;else{i&&(t=-t),e(t<=67108863,"Number is too big");var n=0|this.words[0];r=n===t?0:n<t?-1:1}return 0!==this.negative?0|-r:r},o.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var r=this.ucmp(t);return 0!==this.negative?0|-r:r},o.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var r=0,i=this.length-1;i>=0;i--){var e=0|this.words[i],n=0|t.words[i];if(e!==n){e<n?r=-1:e>n&&(r=1);break}}return r},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new R(t)},o.prototype.toRed=function(t){return e(!this.red,"Already a number in reduction context"),e(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return e(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return e(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return e(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return e(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return e(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return e(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return e(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return e(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return e(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return e(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return e(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return e(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return e(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return e(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var w={k256:null,p224:null,p192:null,p25519:null};function y(t,r){this.name=t,this.p=new o(r,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function E(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function N(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function R(t){if("string"==typeof t){var r=o._prime(t);this.m=r.p,this.prime=r}else e(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function U(t){R.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var r,i=t;do{this.split(i,this.tmp),r=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(r>this.n);var e=r<this.n?-1:i.ucmp(this.p);return 0===e?(i.words[0]=0,i.length=1):e>0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},y.prototype.split=function(t,r){t.iushrn(this.n,0,r)},y.prototype.imulK=function(t){return t.imul(this.k)},n(E,y),E.prototype.split=function(t,r){for(var i=4194303,e=Math.min(t.length,9),n=0;n<e;n++)r.words[n]=t.words[n];if(r.length=e,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(r.words[r.length++]=o&i,n=10;n<t.length;n++){var h=0|t.words[n];t.words[n-10]=(h&i)<<4|o>>>22,o=h}o>>>=22,t.words[n-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},E.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var r=0,i=0;i<t.length;i++){var e=0|t.words[i];r+=977*e,t.words[i]=67108863&r,r=64*e+(r/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(b,y),n(N,y),n(_,y),_.prototype.imulK=function(t){for(var r=0,i=0;i<t.length;i++){var e=19*(0|t.words[i])+r,n=67108863&e;e>>>=26,t.words[i]=n,r=e}return 0!==r&&(t.words[t.length++]=r),t},o._prime=function(t){if(w[t])return w[t];var r;if("k256"===t)r=new E;else if("p224"===t)r=new b;else if("p192"===t)r=new N;else{if("p25519"!==t)throw new Error("Unknown prime "+t);r=new _}return w[t]=r,r},R.prototype._verify1=function(t){e(0===t.negative,"red works only with positives"),e(t.red,"red works only with red numbers")},R.prototype._verify2=function(t,r){e(0==(t.negative|r.negative),"red works only with positives"),e(t.red&&t.red===r.red,"red works only with red numbers")},R.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(l(t,t.umod(this.m)._forceRed(this)),t)},R.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},R.prototype.add=function(t,r){this._verify2(t,r);var i=t.add(r);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},R.prototype.iadd=function(t,r){this._verify2(t,r);var i=t.iadd(r);return i.cmp(this.m)>=0&&i.isub(this.m),i},R.prototype.sub=function(t,r){this._verify2(t,r);var i=t.sub(r);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},R.prototype.isub=function(t,r){this._verify2(t,r);var i=t.isub(r);return i.cmpn(0)<0&&i.iadd(this.m),i},R.prototype.shl=function(t,r){return this._verify1(t),this.imod(t.ushln(r))},R.prototype.imul=function(t,r){return this._verify2(t,r),this.imod(t.imul(r))},R.prototype.mul=function(t,r){return this._verify2(t,r),this.imod(t.mul(r))},R.prototype.isqr=function(t){return this.imul(t,t.clone())},R.prototype.sqr=function(t){return this.mul(t,t)},R.prototype.sqrt=function(t){if(t.isZero())return t.clone();var r=this.m.andln(3);if(e(r%2==1),3===r){var i=this.m.add(new o(1)).iushrn(2);return this.pow(t,i)}for(var n=this.m.subn(1),h=0;!n.isZero()&&0===n.andln(1);)h++,n.iushrn(1);e(!n.isZero());var s=new o(1).toRed(this),u=s.redNeg(),a=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,a).cmp(u);)l.redIAdd(u);for(var m=this.pow(l,n),f=this.pow(t,n.addn(1).iushrn(1)),d=this.pow(t,n),p=h;0!==d.cmp(s);){for(var g=d,c=0;0!==g.cmp(s);c++)g=g.redSqr();e(c<p);var M=this.pow(m,new o(1).iushln(p-c-1));f=f.redMul(M),m=M.redSqr(),d=d.redMul(m),p=c}return f},R.prototype.invm=function(t){var r=t._invmp(this.m);return 0!==r.negative?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},R.prototype.pow=function(t,r){if(r.isZero())return new o(1).toRed(this);if(0===r.cmpn(1))return t.clone();var i=new Array(16);i[0]=new o(1).toRed(this),i[1]=t;for(var e=2;e<i.length;e++)i[e]=this.mul(i[e-1],t);var n=i[0],h=0,s=0,u=r.bitLength()%26;for(0===u&&(u=26),e=r.length-1;e>=0;e--){for(var a=r.words[e],l=u-1;l>=0;l--){var m=a>>l&1;n!==i[0]&&(n=this.sqr(n)),0!==m||0!==h?(h<<=1,h|=m,(4==++s||0===e&&0===l)&&(n=this.mul(n,i[h]),s=0,h=0)):s=0}u=26}return n},R.prototype.convertTo=function(t){var r=t.umod(this.m);return r===t?r.clone():r},R.prototype.convertFrom=function(t){var r=t.clone();return r.red=null,r},o.mont=function(t){return new U(t)},n(U,R),U.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},U.prototype.convertFrom=function(t){var r=this.imod(t.mul(this.rinv));return r.red=null,r},U.prototype.imul=function(t,r){if(t.isZero()||r.isZero())return t.words[0]=0,t.length=1,t;var i=t.imul(r),e=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(e).iushrn(this.shift),o=n;return n.cmp(this.m)>=0?o=n.isub(this.m):n.cmpn(0)<0&&(o=n.iadd(this.m)),o._forceRed(this)},U.prototype.mul=function(t,r){if(t.isZero()||r.isZero())return new o(0)._forceRed(this);var i=t.mul(r),e=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),n=i.isub(e).iushrn(this.shift),h=n;return n.cmp(this.m)>=0?h=n.isub(this.m):n.cmpn(0)<0&&(h=n.iadd(this.m)),h._forceRed(this)},U.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(p,t.commonjsGlobal);const g="bignumber/5.7.0";var c=p.exports.BN;const M=new f(g),v={},w=9007199254740991;let y=!1;class E{constructor(t,r){t!==v&&M.throwError("cannot call constructor directly; use BigNumber.from",f.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return N(_(this).fromTwos(t))}toTwos(t){return N(_(this).toTwos(t))}abs(){return"-"===this._hex[0]?E.from(this._hex.substring(1)):this}add(t){return N(_(this).add(_(t)))}sub(t){return N(_(this).sub(_(t)))}div(t){return E.from(t).isZero()&&R("division-by-zero","div"),N(_(this).div(_(t)))}mul(t){return N(_(this).mul(_(t)))}mod(t){const r=_(t);return r.isNeg()&&R("division-by-zero","mod"),N(_(this).umod(r))}pow(t){const r=_(t);return r.isNeg()&&R("negative-power","pow"),N(_(this).pow(r))}and(t){const r=_(t);return(this.isNegative()||r.isNeg())&&R("unbound-bitwise-result","and"),N(_(this).and(r))}or(t){const r=_(t);return(this.isNegative()||r.isNeg())&&R("unbound-bitwise-result","or"),N(_(this).or(r))}xor(t){const r=_(t);return(this.isNegative()||r.isNeg())&&R("unbound-bitwise-result","xor"),N(_(this).xor(r))}mask(t){return(this.isNegative()||t<0)&&R("negative-width","mask"),N(_(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&R("negative-width","shl"),N(_(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&R("negative-width","shr"),N(_(this).shrn(t))}eq(t){return _(this).eq(_(t))}lt(t){return _(this).lt(_(t))}lte(t){return _(this).lte(_(t))}gt(t){return _(this).gt(_(t))}gte(t){return _(this).gte(_(t))}isNegative(){return"-"===this._hex[0]}isZero(){return _(this).isZero()}toNumber(){try{return _(this).toNumber()}catch(t){R("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return M.throwError("this platform does not support BigInt",f.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?y||(y=!0,M.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?M.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",f.errors.UNEXPECTED_ARGUMENT,{}):M.throwError("BigNumber.toString does not accept parameters",f.errors.UNEXPECTED_ARGUMENT,{})),_(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof E)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new E(v,b(t)):t.match(/^-?[0-9]+$/)?new E(v,b(new c(t))):M.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&R("underflow","BigNumber.from",t),(t>=w||t<=-w)&&R("overflow","BigNumber.from",t),E.from(String(t));const r=t;if("bigint"==typeof r)return E.from(r.toString());if(i.isBytes(r))return E.from(i.hexlify(r));if(r)if(r.toHexString){const t=r.toHexString();if("string"==typeof t)return E.from(t)}else{let t=r._hex;if(null==t&&"BigNumber"===r.type&&(t=r.hex),"string"==typeof t&&(i.isHexString(t)||"-"===t[0]&&i.isHexString(t.substring(1))))return E.from(t)}return M.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function b(t){if("string"!=typeof t)return b(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&M.throwArgumentError("invalid hex","value",t),"0x00"===(t=b(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function N(t){return E.from(b(t))}function _(t){const r=E.from(t).toHexString();return"-"===r[0]?new c("-"+r.substring(3),16):new c(r.substring(2),16)}function R(t,r,i){const e={fault:t,operation:r};return null!=i&&(e.value=i),M.throwError(t,f.errors.NUMERIC_FAULT,e)}const U=new f("strings/5.7.0");var S,x;function A(t,r,i,e,n){if(t===exports.Utf8ErrorReason.BAD_PREFIX||t===exports.Utf8ErrorReason.UNEXPECTED_CONTINUE){let t=0;for(let e=r+1;e<i.length&&i[e]>>6==2;e++)t++;return t}return t===exports.Utf8ErrorReason.OVERRUN?i.length-r-1:0}exports.UnicodeNormalizationForm=void 0,(S=exports.UnicodeNormalizationForm||(exports.UnicodeNormalizationForm={})).current="",S.NFC="NFC",S.NFD="NFD",S.NFKC="NFKC",S.NFKD="NFKD",exports.Utf8ErrorReason=void 0,(x=exports.Utf8ErrorReason||(exports.Utf8ErrorReason={})).UNEXPECTED_CONTINUE="unexpected continuation byte",x.BAD_PREFIX="bad codepoint prefix",x.OVERRUN="string overrun",x.MISSING_CONTINUE="missing continuation byte",x.OUT_OF_RANGE="out of UTF-8 range",x.UTF16_SURROGATE="UTF-16 surrogate",x.OVERLONG="overlong representation";const I=Object.freeze({error:function(t,r,i,e,n){return U.throwArgumentError(`invalid codepoint at offset ${r}; ${t}`,"bytes",i)},ignore:A,replace:function(t,r,i,e,n){return t===exports.Utf8ErrorReason.OVERLONG?(e.push(n),0):(e.push(65533),A(t,r,i))}});function T(t,r){null==r&&(r=I.error),t=i.arrayify(t);const e=[];let n=0;for(;n<t.length;){const i=t[n++];if(i>>7==0){e.push(i);continue}let o=null,h=null;if(192==(224&i))o=1,h=127;else if(224==(240&i))o=2,h=2047;else{if(240!=(248&i)){n+=r(128==(192&i)?exports.Utf8ErrorReason.UNEXPECTED_CONTINUE:exports.Utf8ErrorReason.BAD_PREFIX,n-1,t,e);continue}o=3,h=65535}if(n-1+o>=t.length){n+=r(exports.Utf8ErrorReason.OVERRUN,n-1,t,e);continue}let s=i&(1<<8-o-1)-1;for(let i=0;i<o;i++){let i=t[n];if(128!=(192&i)){n+=r(exports.Utf8ErrorReason.MISSING_CONTINUE,n,t,e),s=null;break}s=s<<6|63&i,n++}null!==s&&(s>1114111?n+=r(exports.Utf8ErrorReason.OUT_OF_RANGE,n-1-o,t,e,s):s>=55296&&s<=57343?n+=r(exports.Utf8ErrorReason.UTF16_SURROGATE,n-1-o,t,e,s):s<=h?n+=r(exports.Utf8ErrorReason.OVERLONG,n-1-o,t,e,s):e.push(s))}return e}function O(t,r=exports.UnicodeNormalizationForm.current){r!=exports.UnicodeNormalizationForm.current&&(U.checkNormalize(),t=t.normalize(r));let e=[];for(let r=0;r<t.length;r++){const i=t.charCodeAt(r);if(i<128)e.push(i);else if(i<2048)e.push(i>>6|192),e.push(63&i|128);else if(55296==(64512&i)){r++;const n=t.charCodeAt(r);if(r>=t.length||56320!=(64512&n))throw new Error("invalid utf-8 string");const o=65536+((1023&i)<<10)+(1023&n);e.push(o>>18|240),e.push(o>>12&63|128),e.push(o>>6&63|128),e.push(63&o|128)}else e.push(i>>12|224),e.push(i>>6&63|128),e.push(63&i|128)}return i.arrayify(e)}function C(t){const r="0000"+t.toString(16);return"\\u"+r.substring(r.length-4)}function k(t){return t.map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("")}exports.BigNumber=E,exports.Logger=f,exports.Utf8ErrorFuncs=I,exports._toEscapedUtf8String=function(t,r){return'"'+T(t,r).map((t=>{if(t<256){switch(t){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(t>=32&&t<127)return String.fromCharCode(t)}return t<=65535?C(t):C(55296+((t-=65536)>>10&1023))+C(56320+(1023&t))})).join("")+'"'},exports._toUtf8String=k,exports.id=function(r){return t.keccak256(O(r))},exports.isBigNumberish=function(t){return null!=t&&(E.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||i.isHexString(t)||"bigint"==typeof t||i.isBytes(t))},exports.lib_esm=d,exports.toUtf8Bytes=O,exports.toUtf8CodePoints=function(t,r=exports.UnicodeNormalizationForm.current){return T(O(t,r))},exports.toUtf8String=function(t,r){return k(T(t,r))},exports.version=g;
@@ -1 +1 @@
1
- "use strict";var e=require("./index-3481a260.cjs"),t=require("./browser-ponyfill-f06979ce.cjs"),s=require("./ethers-0a0a2762.cjs"),a=require("@ethersproject/abstract-signer"),r=require("@ethersproject/providers"),n=require("@ethersproject/contracts"),o=require("./id-8d3d0368.cjs"),i=require("@ethersproject/constants"),d=require("events");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var a=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,a.get?a:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}require("zustand"),require("@ethersproject/address"),require("@ethersproject/properties"),require("@ethersproject/transactions"),require("@ethersproject/bytes"),require("@ethersproject/abstract-provider"),require("./index-5d95eb4a.cjs"),require("./__node-resolve_empty-5af9fabb.cjs"),require("./hash-7ce6fed5.cjs"),require("./inherits_browser-50deae74.cjs"),require("@ethersproject/json-wallets"),require("./interface-53b4cedb.cjs"),require("./index-7ba9ef03.cjs");var u=l(r),f=l(i),h=c(d),g={},p={},m={},_={},E={},v={name:"@safe-global/safe-apps-sdk",version:"7.10.1",description:"SDK developed to integrate third-party apps with Safe app.",main:"dist/src/index.js",typings:"dist/src/index.d.ts",_files:["dist/**/*","src/**/*","CHANGELOG.md","README.md"],keywords:["Safe","sdk","apps"],scripts:{test:"jest","format-dist":"sed -i '' 's/\"files\":/\"_files\":/' dist/package.json",build:"yarn rimraf dist && tsc && yarn format-dist"},author:"Safe (https://safe.global)",license:"MIT",dependencies:{"@safe-global/safe-gateway-typescript-sdk":"^3.5.3",ethers:"^5.7.2"},devDependencies:{rimraf:"^3.0.2"},repository:{type:"git",url:"git+https://github.com/safe-global/safe-apps-sdk.git"},bugs:{url:"https://github.com/safe-global/safe-apps-sdk/issues"},homepage:"https://github.com/safe-global/safe-apps-sdk#readme",publishConfig:{access:"public"}},T=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(E,"__esModule",{value:!0}),E.getSDKVersion=void 0;const y=T(v);E.getSDKVersion=()=>y.default.version.split("-")[0];var w={};Object.defineProperty(w,"__esModule",{value:!0}),w.generateRequestId=void 0;const b=e=>e.toString(16).padStart(2,"0");w.generateRequestId=()=>"undefined"!=typeof window?(e=>{const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,b).join("")})(10):(new Date).getTime().toString(36),Object.defineProperty(_,"__esModule",{value:!0}),_.MessageFormatter=void 0;const S=E,I=w;class A{}_.MessageFormatter=A,A.makeRequest=(e,t)=>({id:(0,I.generateRequestId)(),method:e,params:t,env:{sdkVersion:(0,S.getSDKVersion)()}}),A.makeResponse=(e,t,s)=>({id:e,success:!0,version:s,data:t}),A.makeErrorResponse=(e,t,s)=>({id:e,success:!1,error:t,version:s});var P={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.RestrictedMethods=e.Methods=void 0,(t=e.Methods||(e.Methods={})).sendTransactions="sendTransactions",t.rpcCall="rpcCall",t.getChainInfo="getChainInfo",t.getSafeInfo="getSafeInfo",t.getTxBySafeTxHash="getTxBySafeTxHash",t.getSafeBalances="getSafeBalances",t.signMessage="signMessage",t.signTypedMessage="signTypedMessage",t.getEnvironmentInfo="getEnvironmentInfo",t.getOffChainSignature="getOffChainSignature",t.requestAddressBook="requestAddressBook",t.wallet_getPermissions="wallet_getPermissions",t.wallet_requestPermissions="wallet_requestPermissions",(e.RestrictedMethods||(e.RestrictedMethods={})).requestAddressBook="requestAddressBook"}(P),function(t){var s=e.commonjsGlobal&&e.commonjsGlobal.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e.commonjsGlobal&&e.commonjsGlobal.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0});const r=_;t.default=class{constructor(e=null,t=!1){this.allowedOrigins=null,this.callbacks=new Map,this.debugMode=!1,this.isServer="undefined"==typeof window,this.isValidMessage=({origin:e,data:t,source:s})=>{const a=!t,r=!this.isServer&&s===window.parent,n=(void 0!==t.version&&parseInt(t.version.split(".")[0]))>=1;let o=!0;return Array.isArray(this.allowedOrigins)&&(o=void 0!==this.allowedOrigins.find((t=>t.test(e)))),!a&&r&&n&&o},this.logIncomingMessage=e=>{console.info(`Safe Apps SDK v1: A message was received from origin ${e.origin}. `,e.data)},this.onParentMessage=e=>{this.isValidMessage(e)&&(this.debugMode&&this.logIncomingMessage(e),this.handleIncomingMessage(e.data))},this.handleIncomingMessage=e=>{const{id:t}=e,s=this.callbacks.get(t);s&&(s(e),this.callbacks.delete(t))},this.send=(e,t)=>{const s=r.MessageFormatter.makeRequest(e,t);if(this.isServer)throw new Error("Window doesn't exist");return window.parent.postMessage(s,"*"),new Promise(((e,t)=>{this.callbacks.set(s.id,(s=>{s.success?e(s):t(new Error(s.error))}))}))},this.allowedOrigins=e,this.debugMode=t,this.isServer||window.addEventListener("message",this.onParentMessage)}},a(P,t)}(m);var O={},C={},M={};Object.defineProperty(M,"__esModule",{value:!0}),M.isObjectEIP712TypedData=void 0;M.isObjectEIP712TypedData=e=>"object"==typeof e&&null!=e&&"domain"in e&&"types"in e&&"message"in e;var j={};Object.defineProperty(j,"__esModule",{value:!0});var R={},N={},L={},D={},x=e.commonjsGlobal&&e.commonjsGlobal.__awaiter||function(e,t,s,a){return new(s||(s=Promise))((function(r,n){function o(e){try{d(a.next(e))}catch(e){n(e)}}function i(e){try{d(a.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,i)}d((a=a.apply(e,t||[])).next())}))},G=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(D,"__esModule",{value:!0}),D.fetchData=D.stringifyQuery=D.insertParams=void 0;const H=G(t.browserPonyfill.exports);D.insertParams=function(e,t){return t?Object.keys(t).reduce(((e,s)=>function(e,t,s){return e.replace(new RegExp(`\\{${t}\\}`,"g"),s)}(e,s,String(t[s]))),e):e},D.stringifyQuery=function(e){if(!e)return"";const t=new URLSearchParams;Object.keys(e).forEach((s=>{null!=e[s]&&t.append(s,String(e[s]))}));const s=t.toString();return s?`?${s}`:""},D.fetchData=function(e,t){return x(this,void 0,void 0,(function*(){let s;null!=t&&(s={method:"POST",body:"string"==typeof t?t:JSON.stringify(t),headers:{"Content-Type":"application/json"}});const a=yield(0,H.default)(e,s);let r;try{r=yield a.json()}catch(e){if(a.headers&&"0"!==a.headers.get("content-length"))throw new Error(`Invalid response content: ${a.statusText}`)}if(!a.ok){const e="object"==typeof(n=r)&&null!==n&&"code"in n&&"message"in n?`${r.code}: ${r.message}`:a.statusText;throw new Error(e)}var n;return r}))},Object.defineProperty(L,"__esModule",{value:!0}),L.getEndpoint=L.postEndpoint=void 0;const B=D;function q(e,t,s,a){return`${e}${(0,B.insertParams)(t,s)}${(0,B.stringifyQuery)(a)}`}L.postEndpoint=function(e,t,s){const a=q(e,t,null==s?void 0:s.path,null==s?void 0:s.query);return(0,B.fetchData)(a,null==s?void 0:s.body)},L.getEndpoint=function(e,t,s,a){if(a)return(0,B.fetchData)(a);const r=q(e,t,null==s?void 0:s.path,null==s?void 0:s.query);return(0,B.fetchData)(r)};var k={};Object.defineProperty(k,"__esModule",{value:!0}),k.DEFAULT_BASE_URL=void 0,k.DEFAULT_BASE_URL="https://safe-client.safe.global";var U={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.ImplementationVersionState=void 0,(t=e.ImplementationVersionState||(e.ImplementationVersionState={})).UP_TO_DATE="UP_TO_DATE",t.OUTDATED="OUTDATED",t.UNKNOWN="UNKNOWN"}(U);var $={};!function(e){var t,s;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppSocialPlatforms=e.SafeAppFeatures=e.SafeAppAccessPolicyTypes=void 0,(t=e.SafeAppAccessPolicyTypes||(e.SafeAppAccessPolicyTypes={})).NoRestrictions="NO_RESTRICTIONS",t.DomainAllowlist="DOMAIN_ALLOWLIST",(e.SafeAppFeatures||(e.SafeAppFeatures={})).BATCHED_TRANSACTIONS="BATCHED_TRANSACTIONS",(s=e.SafeAppSocialPlatforms||(e.SafeAppSocialPlatforms={})).TWITTER="TWITTER",s.GITHUB="GITHUB",s.DISCORD="DISCORD"}($);var F={};!function(e){var t,s,a,r,n,o,i,d,c,l;Object.defineProperty(e,"__esModule",{value:!0}),e.LabelValue=e.DetailedExecutionInfoType=e.TransactionListItemType=e.ConflictType=e.TransactionInfoType=e.SettingsInfoType=e.TransactionTokenType=e.TransferDirection=e.TransactionStatus=e.Operation=void 0,(t=e.Operation||(e.Operation={}))[t.CALL=0]="CALL",t[t.DELEGATE=1]="DELEGATE",(s=e.TransactionStatus||(e.TransactionStatus={})).AWAITING_CONFIRMATIONS="AWAITING_CONFIRMATIONS",s.AWAITING_EXECUTION="AWAITING_EXECUTION",s.CANCELLED="CANCELLED",s.FAILED="FAILED",s.SUCCESS="SUCCESS",(a=e.TransferDirection||(e.TransferDirection={})).INCOMING="INCOMING",a.OUTGOING="OUTGOING",a.UNKNOWN="UNKNOWN",(r=e.TransactionTokenType||(e.TransactionTokenType={})).ERC20="ERC20",r.ERC721="ERC721",r.NATIVE_COIN="NATIVE_COIN",(n=e.SettingsInfoType||(e.SettingsInfoType={})).SET_FALLBACK_HANDLER="SET_FALLBACK_HANDLER",n.ADD_OWNER="ADD_OWNER",n.REMOVE_OWNER="REMOVE_OWNER",n.SWAP_OWNER="SWAP_OWNER",n.CHANGE_THRESHOLD="CHANGE_THRESHOLD",n.CHANGE_IMPLEMENTATION="CHANGE_IMPLEMENTATION",n.ENABLE_MODULE="ENABLE_MODULE",n.DISABLE_MODULE="DISABLE_MODULE",n.SET_GUARD="SET_GUARD",n.DELETE_GUARD="DELETE_GUARD",(o=e.TransactionInfoType||(e.TransactionInfoType={})).TRANSFER="Transfer",o.SETTINGS_CHANGE="SettingsChange",o.CUSTOM="Custom",o.CREATION="Creation",(i=e.ConflictType||(e.ConflictType={})).NONE="None",i.HAS_NEXT="HasNext",i.END="End",(d=e.TransactionListItemType||(e.TransactionListItemType={})).TRANSACTION="TRANSACTION",d.LABEL="LABEL",d.CONFLICT_HEADER="CONFLICT_HEADER",d.DATE_LABEL="DATE_LABEL",(c=e.DetailedExecutionInfoType||(e.DetailedExecutionInfoType={})).MULTISIG="MULTISIG",c.MODULE="MODULE",(l=e.LabelValue||(e.LabelValue={})).Queued="Queued",l.Next="Next"}(F);var W={};!function(e){var t,s,a;Object.defineProperty(e,"__esModule",{value:!0}),e.FEATURES=e.GAS_PRICE_TYPE=e.RPC_AUTHENTICATION=void 0,(t=e.RPC_AUTHENTICATION||(e.RPC_AUTHENTICATION={})).API_KEY_PATH="API_KEY_PATH",t.NO_AUTHENTICATION="NO_AUTHENTICATION",t.UNKNOWN="UNKNOWN",(s=e.GAS_PRICE_TYPE||(e.GAS_PRICE_TYPE={})).ORACLE="ORACLE",s.FIXED="FIXED",s.UNKNOWN="UNKNOWN",(a=e.FEATURES||(e.FEATURES={})).ERC721="ERC721",a.SAFE_APPS="SAFE_APPS",a.CONTRACT_INTERACTION="CONTRACT_INTERACTION",a.DOMAIN_LOOKUP="DOMAIN_LOOKUP",a.SPENDING_LIMIT="SPENDING_LIMIT",a.EIP1559="EIP1559",a.SAFE_TX_GAS_OPTIONAL="SAFE_TX_GAS_OPTIONAL",a.TX_SIMULATION="TX_SIMULATION",a.EIP1271="EIP1271"}(W);var V={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.TokenType=void 0,(t=e.TokenType||(e.TokenType={})).ERC20="ERC20",t.ERC721="ERC721",t.NATIVE_TOKEN="NATIVE_TOKEN"}(V);var K={};Object.defineProperty(K,"__esModule",{value:!0});var Q={};Object.defineProperty(Q,"__esModule",{value:!0});var X={};!function(e){var t,s;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeMessageStatus=e.SafeMessageListItemType=void 0,(t=e.SafeMessageListItemType||(e.SafeMessageListItemType={})).DATE_LABEL="DATE_LABEL",t.MESSAGE="MESSAGE",(s=e.SafeMessageStatus||(e.SafeMessageStatus={})).NEEDS_CONFIRMATION="NEEDS_CONFIRMATION",s.CONFIRMED="CONFIRMED"}(X),function(t){var s=e.commonjsGlobal&&e.commonjsGlobal.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e.commonjsGlobal&&e.commonjsGlobal.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.confirmSafeMessage=t.proposeSafeMessage=t.getSafeMessage=t.getSafeMessages=t.getDecodedData=t.getMasterCopies=t.getSafeApps=t.getChainConfig=t.getChainsConfig=t.proposeTransaction=t.postSafeGasEstimation=t.getTransactionDetails=t.getTransactionQueue=t.getTransactionHistory=t.getCollectiblesPage=t.getCollectibles=t.getOwnedSafes=t.getFiatCurrencies=t.getBalances=t.getMultisigTransactions=t.getModuleTransactions=t.getIncomingTransfers=t.getSafeInfo=t.setBaseUrl=void 0;const r=L,n=k;a(U,t),a($,t),a(F,t),a(W,t),a(V,t),a(K,t),a(Q,t),a(X,t);let o=n.DEFAULT_BASE_URL;t.setBaseUrl=e=>{o=e},t.getSafeInfo=function(e,t){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{address}",{path:{chainId:e,address:t}})},t.getIncomingTransfers=function(e,t,s,a){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{address}/incoming-transfers/",{path:{chainId:e,address:t},query:s},a)},t.getModuleTransactions=function(e,t,s,a){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{address}/module-transactions/",{path:{chainId:e,address:t},query:s},a)},t.getMultisigTransactions=function(e,t,s,a){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{address}/multisig-transactions/",{path:{chainId:e,address:t},query:s},a)},t.getBalances=function(e,t,s="usd",a={}){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{address}/balances/{currency}",{path:{chainId:e,address:t,currency:s},query:a})},t.getFiatCurrencies=function(){return(0,r.getEndpoint)(o,"/v1/balances/supported-fiat-codes")},t.getOwnedSafes=function(e,t){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/owners/{address}/safes",{path:{chainId:e,address:t}})},t.getCollectibles=function(e,t,s={}){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:e,address:t},query:s})},t.getCollectiblesPage=function(e,t,s={},a){return(0,r.getEndpoint)(o,"/v2/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:e,address:t},query:s},a)},t.getTransactionHistory=function(e,t,s){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{safe_address}/transactions/history",{path:{chainId:e,safe_address:t},query:{}},s)},t.getTransactionQueue=function(e,t,s,a){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{safe_address}/transactions/queued",{path:{chainId:e,safe_address:t},query:{trusted:a}},s)},t.getTransactionDetails=function(e,t){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/transactions/{transactionId}",{path:{chainId:e,transactionId:t}})},t.postSafeGasEstimation=function(e,t,s){return(0,r.postEndpoint)(o,"/v2/chains/{chainId}/safes/{safe_address}/multisig-transactions/estimations",{path:{chainId:e,safe_address:t},body:s})},t.proposeTransaction=function(e,t,s){return(0,r.postEndpoint)(o,"/v1/chains/{chainId}/transactions/{safe_address}/propose",{path:{chainId:e,safe_address:t},body:s})},t.getChainsConfig=function(e){return(0,r.getEndpoint)(o,"/v1/chains",{query:e})},t.getChainConfig=function(e){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}",{path:{chainId:e}})},t.getSafeApps=function(e,t={}){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safe-apps",{path:{chainId:e},query:t})},t.getMasterCopies=function(e){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/about/master-copies",{path:{chainId:e}})},t.getDecodedData=function(e,t){return(0,r.postEndpoint)(o,"/v1/chains/{chainId}/data-decoder",{path:{chainId:e},body:{data:t}})},t.getSafeMessages=function(e,t,s){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:e,safe_address:t},query:{}},s)},t.getSafeMessage=function(e,t){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/messages/{message_hash}",{path:{chainId:e,message_hash:t}})},t.proposeSafeMessage=function(e,t,s){return(0,r.postEndpoint)(o,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:e,safe_address:t},body:s})},t.confirmSafeMessage=function(e,t,s){return(0,r.postEndpoint)(o,"/v1/chains/{chainId}/messages/{message_hash}/signatures",{path:{chainId:e,message_hash:t},body:s})}}(N),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TransferDirection=e.TransactionStatus=e.TokenType=e.Operation=void 0;var t=N;Object.defineProperty(e,"Operation",{enumerable:!0,get:function(){return t.Operation}}),Object.defineProperty(e,"TokenType",{enumerable:!0,get:function(){return t.TokenType}}),Object.defineProperty(e,"TransactionStatus",{enumerable:!0,get:function(){return t.TransactionStatus}}),Object.defineProperty(e,"TransferDirection",{enumerable:!0,get:function(){return t.TransferDirection}})}(R);var Y={};Object.defineProperty(Y,"__esModule",{value:!0}),function(t){var s=e.commonjsGlobal&&e.commonjsGlobal.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e.commonjsGlobal&&e.commonjsGlobal.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),a(M,t),a(j,t),a(R,t),a(Y,t)}(C),Object.defineProperty(O,"__esModule",{value:!0}),O.TXs=void 0;const J=P,z=C;O.TXs=class{constructor(e){this.communicator=e}async getBySafeTxHash(e){if(!e)throw new Error("Invalid safeTxHash");return(await this.communicator.send(J.Methods.getTxBySafeTxHash,{safeTxHash:e})).data}async signMessage(e){const t={message:e};return(await this.communicator.send(J.Methods.signMessage,t)).data}async signTypedMessage(e){if(!(0,z.isObjectEIP712TypedData)(e))throw new Error("Invalid typed data");return(await this.communicator.send(J.Methods.signTypedMessage,{typedData:e})).data}async send({txs:e,params:t}){if(!e||!e.length)throw new Error("No transactions were passed");const s={txs:e,params:t};return(await this.communicator.send(J.Methods.sendTransactions,s)).data}};var Z={},ee={};Object.defineProperty(ee,"__esModule",{value:!0}),ee.RPC_CALLS=void 0,ee.RPC_CALLS={eth_call:"eth_call",eth_gasPrice:"eth_gasPrice",eth_getLogs:"eth_getLogs",eth_getBalance:"eth_getBalance",eth_getCode:"eth_getCode",eth_getBlockByHash:"eth_getBlockByHash",eth_getBlockByNumber:"eth_getBlockByNumber",eth_getStorageAt:"eth_getStorageAt",eth_getTransactionByHash:"eth_getTransactionByHash",eth_getTransactionReceipt:"eth_getTransactionReceipt",eth_getTransactionCount:"eth_getTransactionCount",eth_estimateGas:"eth_estimateGas",safe_setSettings:"safe_setSettings"},Object.defineProperty(Z,"__esModule",{value:!0}),Z.Eth=void 0;const te=ee,se=P,ae={defaultBlockParam:(e="latest")=>e,returnFullTxObjectParam:(e=!1)=>e,blockNumberToHex:e=>Number.isInteger(e)?`0x${e.toString(16)}`:e};Z.Eth=class{constructor(e){this.communicator=e,this.call=this.buildRequest({call:te.RPC_CALLS.eth_call,formatters:[null,ae.defaultBlockParam]}),this.getBalance=this.buildRequest({call:te.RPC_CALLS.eth_getBalance,formatters:[null,ae.defaultBlockParam]}),this.getCode=this.buildRequest({call:te.RPC_CALLS.eth_getCode,formatters:[null,ae.defaultBlockParam]}),this.getStorageAt=this.buildRequest({call:te.RPC_CALLS.eth_getStorageAt,formatters:[null,ae.blockNumberToHex,ae.defaultBlockParam]}),this.getPastLogs=this.buildRequest({call:te.RPC_CALLS.eth_getLogs}),this.getBlockByHash=this.buildRequest({call:te.RPC_CALLS.eth_getBlockByHash,formatters:[null,ae.returnFullTxObjectParam]}),this.getBlockByNumber=this.buildRequest({call:te.RPC_CALLS.eth_getBlockByNumber,formatters:[ae.blockNumberToHex,ae.returnFullTxObjectParam]}),this.getTransactionByHash=this.buildRequest({call:te.RPC_CALLS.eth_getTransactionByHash}),this.getTransactionReceipt=this.buildRequest({call:te.RPC_CALLS.eth_getTransactionReceipt}),this.getTransactionCount=this.buildRequest({call:te.RPC_CALLS.eth_getTransactionCount,formatters:[null,ae.defaultBlockParam]}),this.getGasPrice=this.buildRequest({call:te.RPC_CALLS.eth_gasPrice}),this.getEstimateGas=e=>this.buildRequest({call:te.RPC_CALLS.eth_estimateGas})([e]),this.setSafeSettings=this.buildRequest({call:te.RPC_CALLS.safe_setSettings})}buildRequest(e){const{call:t,formatters:s}=e;return async e=>{s&&Array.isArray(e)&&s.forEach(((t,s)=>{t&&(e[s]=t(e[s]))}));const a={call:t,params:e||[]};return(await this.communicator.send(se.Methods.rpcCall,a)).data}}};var re={};try{const e=window;null==e._ethers&&(e._ethers=s.ethers)}catch(e){}var ne=Object.freeze({__proto__:null,ethers:s.ethers,Signer:a.Signer,Wallet:s.Wallet,VoidSigner:a.VoidSigner,getDefaultProvider:r.getDefaultProvider,providers:u,BaseContract:n.BaseContract,Contract:n.Contract,ContractFactory:n.ContractFactory,BigNumber:o.BigNumber,FixedNumber:s.FixedNumber,constants:f,get errors(){return o.ErrorCode},logger:s.logger,utils:s.utils,wordlists:s.wordlists,version:s.version,Wordlist:s.Wordlist}),oe=e.getAugmentedNamespace(ne),ie={};Object.defineProperty(ie,"__esModule",{value:!0}),ie.MAGIC_VALUE_BYTES=ie.MAGIC_VALUE=ie.EIP_1271_BYTES_INTERFACE=ie.EIP_1271_INTERFACE=void 0;const de=oe;ie.MAGIC_VALUE="0x1626ba7e";ie.MAGIC_VALUE_BYTES="0x20c13b0b";const ce=new de.ethers.utils.Interface(["function isValidSignature(bytes32 _dataHash, bytes calldata _signature) external view"]);ie.EIP_1271_INTERFACE=ce;const le=new de.ethers.utils.Interface(["function isValidSignature(bytes calldata _data, bytes calldata _signature) public view"]);ie.EIP_1271_BYTES_INTERFACE=le;var ue={},fe={},he={};Object.defineProperty(he,"__esModule",{value:!0}),he.PermissionsError=he.PERMISSIONS_REQUEST_REJECTED=void 0,he.PERMISSIONS_REQUEST_REJECTED=4001;class ge extends Error{constructor(e,t,s){super(e),this.code=t,this.data=s,Object.setPrototypeOf(this,ge.prototype)}}he.PermissionsError=ge,Object.defineProperty(fe,"__esModule",{value:!0}),fe.Wallet=void 0;const pe=P,me=he;fe.Wallet=class{constructor(e){this.communicator=e}async getPermissions(){return(await this.communicator.send(pe.Methods.wallet_getPermissions,void 0)).data}async requestPermissions(e){if(!this.isPermissionRequestValid(e))throw new me.PermissionsError("Permissions request is invalid",me.PERMISSIONS_REQUEST_REJECTED);try{return(await this.communicator.send(pe.Methods.wallet_requestPermissions,e)).data}catch(e){throw new me.PermissionsError("Permissions rejected",me.PERMISSIONS_REQUEST_REJECTED)}}isPermissionRequestValid(e){return e.every((e=>"object"==typeof e&&Object.keys(e).every((e=>!!Object.values(pe.RestrictedMethods).includes(e)))))}},Object.defineProperty(ue,"__esModule",{value:!0});const _e=fe,Ee=he,ve=(e,t)=>t.some((t=>t.parentCapability===e));ue.default=()=>(e,t,s)=>{const a=s.value;return s.value=async function(){const e=new _e.Wallet(this.communicator);let s=await e.getPermissions();if(ve(t,s)||(s=await e.requestPermissions([{[t]:{}}])),!ve(t,s))throw new Ee.PermissionsError("Permissions rejected",Ee.PERMISSIONS_REQUEST_REJECTED);return a.apply(this)},s};var Te=e.commonjsGlobal&&e.commonjsGlobal.__decorate||function(e,t,s,a){var r,n=arguments.length,o=n<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,s):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,s,a);else for(var i=e.length-1;i>=0;i--)(r=e[i])&&(o=(n<3?r(o):n>3?r(t,s,o):r(t,s))||o);return n>3&&o&&Object.defineProperty(t,s,o),o},ye=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(re,"__esModule",{value:!0}),re.Safe=void 0;const we=oe,be=ie,Se=P,Ie=ee,Ae=C,Pe=ye(ue);class Oe{constructor(e){this.communicator=e}async getChainInfo(){return(await this.communicator.send(Se.Methods.getChainInfo,void 0)).data}async getInfo(){return(await this.communicator.send(Se.Methods.getSafeInfo,void 0)).data}async experimental_getBalances({currency:e="usd"}={}){return(await this.communicator.send(Se.Methods.getSafeBalances,{currency:e})).data}async check1271Signature(e,t="0x"){const s=await this.getInfo(),a=be.EIP_1271_INTERFACE.encodeFunctionData("isValidSignature",[e,t]),r={call:Ie.RPC_CALLS.eth_call,params:[{to:s.safeAddress,data:a},"latest"]};try{return(await this.communicator.send(Se.Methods.rpcCall,r)).data.slice(0,10).toLowerCase()===be.MAGIC_VALUE}catch(e){return!1}}async check1271SignatureBytes(e,t="0x"){const s=await this.getInfo(),a=we.ethers.utils.arrayify(e),r=be.EIP_1271_BYTES_INTERFACE.encodeFunctionData("isValidSignature",[a,t]),n={call:Ie.RPC_CALLS.eth_call,params:[{to:s.safeAddress,data:r},"latest"]};try{return(await this.communicator.send(Se.Methods.rpcCall,n)).data.slice(0,10).toLowerCase()===be.MAGIC_VALUE_BYTES}catch(e){return!1}}calculateMessageHash(e){return we.ethers.utils.hashMessage(e)}calculateTypedMessageHash(e){return we.ethers.utils._TypedDataEncoder.hash(e.domain,e.types,e.message)}async getOffChainSignature(e){return(await this.communicator.send(Se.Methods.getOffChainSignature,e)).data}async isMessageSigned(e,t="0x"){let s;if("string"==typeof e&&(s=async()=>{const s=this.calculateMessageHash(e);return await this.isMessageHashSigned(s,t)}),(0,Ae.isObjectEIP712TypedData)(e)&&(s=async()=>{const s=this.calculateTypedMessageHash(e);return await this.isMessageHashSigned(s,t)}),s){return await s()}throw new Error("Invalid message type")}async isMessageHashSigned(e,t="0x"){const s=[this.check1271Signature.bind(this),this.check1271SignatureBytes.bind(this)];for(const a of s){if(await a(e,t))return!0}return!1}async getEnvironmentInfo(){return(await this.communicator.send(Se.Methods.getEnvironmentInfo,void 0)).data}async requestAddressBook(){return(await this.communicator.send(Se.Methods.requestAddressBook,void 0)).data}}Te([(0,Pe.default)()],Oe.prototype,"requestAddressBook",null),re.Safe=Oe;var Ce=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(p,"__esModule",{value:!0});const Me=Ce(m),je=O,Re=Z,Ne=re,Le=fe;p.default=class{constructor(e={}){const{allowedDomains:t=null,debug:s=!1}=e;this.communicator=new Me.default(t,s),this.eth=new Re.Eth(this.communicator),this.txs=new je.TXs(this.communicator),this.safe=new Ne.Safe(this.communicator),this.wallet=new Le.Wallet(this.communicator)}},function(t){var s=e.commonjsGlobal&&e.commonjsGlobal.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e.commonjsGlobal&&e.commonjsGlobal.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)},r=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSDKVersion=void 0;const n=r(p);t.default=n.default,a(p,t),a(C,t),a(P,t),a(_,t);var o=E;Object.defineProperty(t,"getSDKVersion",{enumerable:!0,get:function(){return o.getSDKVersion}})}(g);var De=e.getDefaultExportFromCjs(g),xe={},Ge={},He={};Object.defineProperty(He,"__esModule",{value:!0}),He.getLowerCase=void 0,He.getLowerCase=function(e){return e?e.toLowerCase():e},Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.SafeAppProvider=void 0;const Be=h.default,qe=He;class ke extends Be.EventEmitter{constructor(e,t){super(),this.submittedTxs=new Map,this.safe=e,this.sdk=t}async connect(){this.emit("connect",{chainId:this.chainId})}async disconnect(){}get chainId(){return this.safe.chainId}async request(e){const{method:t,params:s=[]}=e;switch(t){case"eth_accounts":return[this.safe.safeAddress];case"net_version":case"eth_chainId":return`0x${this.chainId.toString(16)}`;case"personal_sign":{const[e,t]=s;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase())throw new Error("The address or message hash is invalid");return await this.sdk.txs.signMessage(e),"0x"}case"eth_sign":{const[e,t]=s;if(this.safe.safeAddress.toLowerCase()!==e.toLowerCase()||!t.startsWith("0x"))throw new Error("The address or message hash is invalid");return await this.sdk.txs.signMessage(t),"0x"}case"eth_signTypedData":case"eth_signTypedData_v4":{const[e,t]=s,a="string"==typeof t?JSON.parse(t):t;if(this.safe.safeAddress.toLowerCase()!==e.toLowerCase())throw new Error("The address is invalid");return await this.sdk.txs.signTypedMessage(a),"0x"}case"eth_sendTransaction":const t=Object.assign({value:"0",data:"0x"},s[0]);"string"==typeof t.gas&&t.gas.startsWith("0x")&&(t.gas=parseInt(t.gas,16));const a=await this.sdk.txs.send({txs:[t],params:{safeTxGas:t.gas}});return this.submittedTxs.set(a.safeTxHash,{from:this.safe.safeAddress,hash:a.safeTxHash,gas:0,gasPrice:"0x00",nonce:0,input:t.data,value:t.value,to:t.to,blockHash:null,blockNumber:null,transactionIndex:null}),a.safeTxHash;case"eth_blockNumber":return(await this.sdk.eth.getBlockByNumber(["latest"])).number;case"eth_getBalance":return this.sdk.eth.getBalance([(0,qe.getLowerCase)(s[0]),s[1]]);case"eth_getCode":return this.sdk.eth.getCode([(0,qe.getLowerCase)(s[0]),s[1]]);case"eth_getTransactionCount":return this.sdk.eth.getTransactionCount([(0,qe.getLowerCase)(s[0]),s[1]]);case"eth_getStorageAt":return this.sdk.eth.getStorageAt([(0,qe.getLowerCase)(s[0]),s[1],s[2]]);case"eth_getBlockByNumber":return this.sdk.eth.getBlockByNumber([s[0],s[1]]);case"eth_getBlockByHash":return this.sdk.eth.getBlockByHash([s[0],s[1]]);case"eth_getTransactionByHash":let r=s[0];try{r=(await this.sdk.txs.getBySafeTxHash(r)).txHash||r}catch(e){}return this.submittedTxs.has(r)?this.submittedTxs.get(r):this.sdk.eth.getTransactionByHash([r]).then((e=>(e&&(e.hash=s[0]),e)));case"eth_getTransactionReceipt":{let e=s[0];try{e=(await this.sdk.txs.getBySafeTxHash(e)).txHash||e}catch(e){}return this.sdk.eth.getTransactionReceipt([e]).then((e=>(e&&(e.transactionHash=s[0]),e)))}case"eth_estimateGas":return this.sdk.eth.getEstimateGas(s[0]);case"eth_call":return this.sdk.eth.call([s[0],s[1]]);case"eth_getLogs":return this.sdk.eth.getPastLogs([s[0]]);case"eth_gasPrice":return this.sdk.eth.getGasPrice();case"wallet_getPermissions":return this.sdk.wallet.getPermissions();case"wallet_requestPermissions":return this.sdk.wallet.requestPermissions(s[0]);case"safe_setSettings":return this.sdk.eth.setSafeSettings([s[0]]);default:throw Error(`"${e.method}" not implemented`)}}send(e,t){e||t("Undefined request"),this.request(e).then((s=>t(null,{jsonrpc:"2.0",id:e.id,result:s}))).catch((e=>t(e,null)))}}let Ue,$e;function Fe(){return e.__awaiter(this,void 0,void 0,(function*(){return $e||($e=new De),void 0===Ue&&(Ue=yield Promise.race([$e.safe.getInfo(),new Promise((e=>setTimeout(e,200)))])),Ue}))}Ge.SafeAppProvider=ke,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppProvider=void 0;var t=Ge;Object.defineProperty(e,"SafeAppProvider",{enumerable:!0,get:function(){return t.SafeAppProvider}})}(xe);var We={},Ve={},Ke={};Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.getTxServiceBaseUrl=void 0,Ke.getTxServiceBaseUrl=function(e){return`${e}/api`};var Qe={},Xe={exports:{}};!function(t,s){var a=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e.commonjsGlobal)return e.commonjsGlobal;throw new Error("unable to locate global object")}();t.exports=s=a.fetch,a.fetch&&(s.default=a.fetch.bind(a)),s.Headers=a.Headers,s.Request=a.Request,s.Response=a.Response}(Xe,Xe.exports),function(t){var s=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendRequest=t.HttpMethod=void 0;const a=s(Xe.exports);var r;(r=t.HttpMethod||(t.HttpMethod={})).Get="get",r.Post="post",r.Delete="delete",t.sendRequest=async function({url:e,method:t,body:s}){const r=await(0,a.default)(e,{method:t,headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)});let n;try{n=await r.json()}catch(e){if(!r.ok)throw new Error(r.statusText)}if(r.ok)return n;if(n.data)throw new Error(n.data);if(n.detail)throw new Error(n.detail);if(n.message)throw new Error(n.message);if(n.nonFieldErrors)throw new Error(n.nonFieldErrors);if(n.delegate)throw new Error(n.delegate);if(n.safe)throw new Error(n.safe);if(n.delegator)throw new Error(n.delegator);throw new Error(r.statusText)}}(Qe);var Ye,Je,ze=e.commonjsGlobal&&e.commonjsGlobal.__classPrivateFieldSet||function(e,t,s,a,r){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?r.call(e,s):r?r.value=s:t.set(e,s),s},Ze=e.commonjsGlobal&&e.commonjsGlobal.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(Ve,"__esModule",{value:!0});const et=Ke,tt=Qe;Ye=new WeakMap,Je=new WeakMap,Ve.default=class{constructor({txServiceUrl:e,ethAdapter:t}){Ye.set(this,void 0),Je.set(this,void 0),ze(this,Ye,(0,et.getTxServiceBaseUrl)(e),"f"),ze(this,Je,t,"f")}async getServiceInfo(){return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/about`,method:tt.HttpMethod.Get})}async getServiceMasterCopiesInfo(){return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/about/master-copies`,method:tt.HttpMethod.Get})}async decodeData(e){if(""===e)throw new Error("Invalid data");return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/data-decoder/`,method:tt.HttpMethod.Post,body:{data:e}})}async getSafesByOwner(e){if(""===e)throw new Error("Invalid owner address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/owners/${t}/safes/`,method:tt.HttpMethod.Get})}async getSafesByModule(e){if(""===e)throw new Error("Invalid module address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/modules/${t}/safes/`,method:tt.HttpMethod.Get})}async getTransaction(e){if(""===e)throw new Error("Invalid safeTxHash");return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/multisig-transactions/${e}/`,method:tt.HttpMethod.Get})}async getTransactionConfirmations(e){if(""===e)throw new Error("Invalid safeTxHash");return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/multisig-transactions/${e}/confirmations/`,method:tt.HttpMethod.Get})}async confirmTransaction(e,t){if(""===e)throw new Error("Invalid safeTxHash");if(""===t)throw new Error("Invalid signature");return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/multisig-transactions/${e}/confirmations/`,method:tt.HttpMethod.Post,body:{signature:t}})}async getSafeInfo(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${t}/`,method:tt.HttpMethod.Get})}async getSafeDelegates({safeAddress:e,delegateAddress:t,delegatorAddress:s,label:a,limit:r,offset:n}){const o=new URL(`${Ze(this,Ye,"f")}/v1/delegates`);if(e){const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);o.searchParams.set("safe",t)}if(t){const{address:e}=await Ze(this,Je,"f").getEip3770Address(t);o.searchParams.set("delegate",e)}if(s){const{address:e}=await Ze(this,Je,"f").getEip3770Address(s);o.searchParams.set("delegator",e)}return a&&o.searchParams.set("label",a),r&&o.searchParams.set("limit",r),n&&o.searchParams.set("offset",n),(0,tt.sendRequest)({url:o.toString(),method:tt.HttpMethod.Get})}async addSafeDelegate({safeAddress:e,delegateAddress:t,delegatorAddress:s,label:a,signer:r}){if(""===t)throw new Error("Invalid Safe delegate address");if(""===s)throw new Error("Invalid Safe delegator address");if(""===a)throw new Error("Invalid label");const{address:n}=await Ze(this,Je,"f").getEip3770Address(t),{address:o}=await Ze(this,Je,"f").getEip3770Address(s),i=n+Math.floor(Date.now()/1e3/3600),d=await r.signMessage(i),c={safe:e?(await Ze(this,Je,"f").getEip3770Address(e)).address:null,delegate:n,delegator:o,label:a,signature:d};return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/delegates/`,method:tt.HttpMethod.Post,body:c})}async removeSafeDelegate({delegateAddress:e,delegatorAddress:t,signer:s}){if(""===e)throw new Error("Invalid Safe delegate address");if(""===t)throw new Error("Invalid Safe delegator address");const{address:a}=await Ze(this,Je,"f").getEip3770Address(e),{address:r}=await Ze(this,Je,"f").getEip3770Address(t),n=a+Math.floor(Date.now()/1e3/3600),o=await s.signMessage(n);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/delegates/${a}`,method:tt.HttpMethod.Delete,body:{delegate:a,delegator:r,signature:o}})}async getSafeCreationInfo(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${t}/creation/`,method:tt.HttpMethod.Get})}async estimateSafeTransaction(e,t){if(""===e)throw new Error("Invalid Safe address");const{address:s}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${s}/multisig-transactions/estimations/`,method:tt.HttpMethod.Post,body:t})}async proposeTransaction({safeAddress:e,safeTransactionData:t,safeTxHash:s,senderAddress:a,senderSignature:r,origin:n}){if(""===e)throw new Error("Invalid Safe address");const{address:o}=await Ze(this,Je,"f").getEip3770Address(e),{address:i}=await Ze(this,Je,"f").getEip3770Address(a);if(""===s)throw new Error("Invalid safeTxHash");return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${o}/multisig-transactions/`,method:tt.HttpMethod.Post,body:{...t,contractTransactionHash:s,sender:i,signature:r,origin:n}})}async getIncomingTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${t}/incoming-transfers?executed=true`,method:tt.HttpMethod.Get})}async getModuleTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${t}/module-transactions/`,method:tt.HttpMethod.Get})}async getMultisigTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${t}/multisig-transactions/`,method:tt.HttpMethod.Get})}async getPendingTransactions(e,t){if(""===e)throw new Error("Invalid Safe address");const{address:s}=await Ze(this,Je,"f").getEip3770Address(e),a=t||(await this.getSafeInfo(s)).nonce;return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${s}/multisig-transactions/?executed=false&nonce__gte=${a}`,method:tt.HttpMethod.Get})}async getAllTransactions(e,t){var s,a,r;if(""===e)throw new Error("Invalid Safe address");const{address:n}=await Ze(this,Je,"f").getEip3770Address(e),o=new URL(`${Ze(this,Ye,"f")}/v1/safes/${n}/all-transactions/`),i=(null===(s=null==t?void 0:t.trusted)||void 0===s?void 0:s.toString())||"true";o.searchParams.set("trusted",i);const d=(null===(a=null==t?void 0:t.queued)||void 0===a?void 0:a.toString())||"true";o.searchParams.set("queued",d);const c=(null===(r=null==t?void 0:t.executed)||void 0===r?void 0:r.toString())||"false";return o.searchParams.set("executed",c),(0,tt.sendRequest)({url:o.toString(),method:tt.HttpMethod.Get})}async getNextNonce(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e),s=await this.getPendingTransactions(t);if(s.results.length>0){const e=s.results.map((e=>e.nonce));return Math.max(...e)+1}return(await this.getSafeInfo(t)).nonce}async getTokenList(){return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/tokens/`,method:tt.HttpMethod.Get})}async getToken(e){if(""===e)throw new Error("Invalid token address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/tokens/${t}/`,method:tt.HttpMethod.Get})}};var st={};Object.defineProperty(st,"__esModule",{value:!0}),function(t){var s=e.commonjsGlobal&&e.commonjsGlobal.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e.commonjsGlobal&&e.commonjsGlobal.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)},r=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(Ve);a(st,t),t.default=n.default}(We);var at=e.getDefaultExportFromCjs(We);const rt={1:"https://safe-transaction-mainnet.safe.global/",5:"https://safe-transaction-goerli.safe.global/",42161:"https://safe-transaction-arbitrum.safe.global/",43114:"https://safe-transaction-avalanche.safe.global/",1313161554:"https://safe-transaction-aurora.safe.global/",56:"https://safe-transaction-bsc.safe.global/",10:"https://safe-transaction-optimism.safe.global/",137:"https://safe-transaction-polygon.safe.global/"};let nt;function ot(t){return e.__awaiter(this,void 0,void 0,(function*(){if((null==nt?void 0:nt.chainId)===t)return nt.safeService;if(!e.useWalletStore.getState().provider)throw new Error("provider is undefined");const s=function(){return{getEip3770Address:t=>e.__awaiter(this,void 0,void 0,(function*(){const{address:e,prefix:s}=function(e){const t=e.split(":"),s=t.length>1?t[1]:t[0];return{prefix:t.length>1?t[0]:"",address:s}}(t);return{address:e,prefix:s}}))}}(),a=rt[t];if(!a)return;const r=new at({txServiceUrl:a,ethAdapter:s});return nt={safeService:r,chainId:t},nt.safeService}))}exports.default=function(t){return e.__awaiter(this,void 0,void 0,(function*(){const s=yield Fe();if(!s)throw Error("Could not load Safe information");const a=new xe.SafeAppProvider(s,$e);return a.on("connect",t.connect),a.on("disconnect",t.disconnect),a.on("accountsChanged",t.accountsChanged),a.on("chainChanged",t.chainChanged),a.on("message",t.message),e.convertWeb3Provider(a)}))},exports.getAccountIsSafe=function(t,s){return e.__awaiter(this,void 0,void 0,(function*(){if(!s)return!1;const e=yield ot(t);if(!e)return!1;try{return!!(yield e.getSafeInfo(s))}catch(e){return console.error(e),!1}}))},exports.getConnectedSafe=Fe,exports.getIsSafe=function(){return e.__awaiter(this,void 0,void 0,(function*(){return!!(yield Fe())}))},exports.getSafeHashDetailUrl=function(e,t,s){const a={1:"eth",5:"gor",137:"matic",56:"bnb",42161:"arb1",10:"oeth",43114:"avax",1313161554:"aurora"}[t];if(!a)throw new Error(`Not Supported network: ${t}`);return`https://app.safe.global/transactions/tx?id=multisig_${s}_${e}&safe=${a}%3A${s}`},exports.getSafeTxHash=function(t,s,a){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield ot(t);if(!e)return console.error(`chainId: ${t} is not supported safe`),a;if(a!==s)return a;const r=yield e.getMultisigTransactions(a),[n]=r.results;return n.safeTxHash}))},exports.getSafeTxStatus=function(t,s,a){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield ot(t);if(!e)throw new Error(`chainId: ${t} is not supported safe`);try{const{results:t}=yield e.getMultisigTransactions(a),r=t.find((e=>e.safeTxHash.toLocaleLowerCase()===s.toLocaleLowerCase()));if(!r)return null;if(t.some((e=>!(e.nonce!==r.nonce||e.safeTxHash.toLocaleLowerCase()===s.toLocaleLowerCase()||!e.isExecuted||!e.isSuccessful))))return"rejected";if(null===r.isExecuted||null===r.isSuccessful)return null;return{status:r.isExecuted&&r.isSuccessful||!1,transactionHash:r.transactionHash,blockNumber:r.blockNumber||null}}catch(e){throw console.error(e),new Error(`safeTxHash: ${s} is not valid.`)}}))};
1
+ "use strict";var e=require("./index-94f8e007.cjs"),t=require("./browser-ponyfill-0e08ae60.cjs"),s=require("./ethers-3720c0d4.cjs"),a=require("@ethersproject/abstract-signer"),r=require("@ethersproject/providers"),n=require("@ethersproject/contracts"),o=require("./id-d282cc40.cjs"),i=require("@ethersproject/constants"),d=require("events");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var a=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,a.get?a:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}require("zustand"),require("@ethersproject/address"),require("@ethersproject/properties"),require("@ethersproject/transactions"),require("@ethersproject/bytes"),require("@ethersproject/abstract-provider"),require("./index-ff4de501.cjs"),require("./__node-resolve_empty-0fd10698.cjs"),require("./hash-7ce6fed5.cjs"),require("./inherits_browser-50deae74.cjs"),require("@ethersproject/json-wallets"),require("./interface-a83766a7.cjs"),require("./index-aa73a457.cjs");var u=l(r),f=l(i),h=c(d),g={},p={},m={},_={},E={},v={name:"@safe-global/safe-apps-sdk",version:"7.10.1",description:"SDK developed to integrate third-party apps with Safe app.",main:"dist/src/index.js",typings:"dist/src/index.d.ts",_files:["dist/**/*","src/**/*","CHANGELOG.md","README.md"],keywords:["Safe","sdk","apps"],scripts:{test:"jest","format-dist":"sed -i '' 's/\"files\":/\"_files\":/' dist/package.json",build:"yarn rimraf dist && tsc && yarn format-dist"},author:"Safe (https://safe.global)",license:"MIT",dependencies:{"@safe-global/safe-gateway-typescript-sdk":"^3.5.3",ethers:"^5.7.2"},devDependencies:{rimraf:"^3.0.2"},repository:{type:"git",url:"git+https://github.com/safe-global/safe-apps-sdk.git"},bugs:{url:"https://github.com/safe-global/safe-apps-sdk/issues"},homepage:"https://github.com/safe-global/safe-apps-sdk#readme",publishConfig:{access:"public"}},T=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(E,"__esModule",{value:!0}),E.getSDKVersion=void 0;const y=T(v);E.getSDKVersion=()=>y.default.version.split("-")[0];var w={};Object.defineProperty(w,"__esModule",{value:!0}),w.generateRequestId=void 0;const b=e=>e.toString(16).padStart(2,"0");w.generateRequestId=()=>"undefined"!=typeof window?(e=>{const t=new Uint8Array((e||40)/2);return window.crypto.getRandomValues(t),Array.from(t,b).join("")})(10):(new Date).getTime().toString(36),Object.defineProperty(_,"__esModule",{value:!0}),_.MessageFormatter=void 0;const S=E,I=w;class A{}_.MessageFormatter=A,A.makeRequest=(e,t)=>({id:(0,I.generateRequestId)(),method:e,params:t,env:{sdkVersion:(0,S.getSDKVersion)()}}),A.makeResponse=(e,t,s)=>({id:e,success:!0,version:s,data:t}),A.makeErrorResponse=(e,t,s)=>({id:e,success:!1,error:t,version:s});var P={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.RestrictedMethods=e.Methods=void 0,(t=e.Methods||(e.Methods={})).sendTransactions="sendTransactions",t.rpcCall="rpcCall",t.getChainInfo="getChainInfo",t.getSafeInfo="getSafeInfo",t.getTxBySafeTxHash="getTxBySafeTxHash",t.getSafeBalances="getSafeBalances",t.signMessage="signMessage",t.signTypedMessage="signTypedMessage",t.getEnvironmentInfo="getEnvironmentInfo",t.getOffChainSignature="getOffChainSignature",t.requestAddressBook="requestAddressBook",t.wallet_getPermissions="wallet_getPermissions",t.wallet_requestPermissions="wallet_requestPermissions",(e.RestrictedMethods||(e.RestrictedMethods={})).requestAddressBook="requestAddressBook"}(P),function(t){var s=e.commonjsGlobal&&e.commonjsGlobal.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e.commonjsGlobal&&e.commonjsGlobal.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0});const r=_;t.default=class{constructor(e=null,t=!1){this.allowedOrigins=null,this.callbacks=new Map,this.debugMode=!1,this.isServer="undefined"==typeof window,this.isValidMessage=({origin:e,data:t,source:s})=>{const a=!t,r=!this.isServer&&s===window.parent,n=(void 0!==t.version&&parseInt(t.version.split(".")[0]))>=1;let o=!0;return Array.isArray(this.allowedOrigins)&&(o=void 0!==this.allowedOrigins.find((t=>t.test(e)))),!a&&r&&n&&o},this.logIncomingMessage=e=>{console.info(`Safe Apps SDK v1: A message was received from origin ${e.origin}. `,e.data)},this.onParentMessage=e=>{this.isValidMessage(e)&&(this.debugMode&&this.logIncomingMessage(e),this.handleIncomingMessage(e.data))},this.handleIncomingMessage=e=>{const{id:t}=e,s=this.callbacks.get(t);s&&(s(e),this.callbacks.delete(t))},this.send=(e,t)=>{const s=r.MessageFormatter.makeRequest(e,t);if(this.isServer)throw new Error("Window doesn't exist");return window.parent.postMessage(s,"*"),new Promise(((e,t)=>{this.callbacks.set(s.id,(s=>{s.success?e(s):t(new Error(s.error))}))}))},this.allowedOrigins=e,this.debugMode=t,this.isServer||window.addEventListener("message",this.onParentMessage)}},a(P,t)}(m);var O={},C={},M={};Object.defineProperty(M,"__esModule",{value:!0}),M.isObjectEIP712TypedData=void 0;M.isObjectEIP712TypedData=e=>"object"==typeof e&&null!=e&&"domain"in e&&"types"in e&&"message"in e;var j={};Object.defineProperty(j,"__esModule",{value:!0});var R={},N={},L={},D={},x=e.commonjsGlobal&&e.commonjsGlobal.__awaiter||function(e,t,s,a){return new(s||(s=Promise))((function(r,n){function o(e){try{d(a.next(e))}catch(e){n(e)}}function i(e){try{d(a.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,i)}d((a=a.apply(e,t||[])).next())}))},G=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(D,"__esModule",{value:!0}),D.fetchData=D.stringifyQuery=D.insertParams=void 0;const H=G(t.browserPonyfill.exports);D.insertParams=function(e,t){return t?Object.keys(t).reduce(((e,s)=>function(e,t,s){return e.replace(new RegExp(`\\{${t}\\}`,"g"),s)}(e,s,String(t[s]))),e):e},D.stringifyQuery=function(e){if(!e)return"";const t=new URLSearchParams;Object.keys(e).forEach((s=>{null!=e[s]&&t.append(s,String(e[s]))}));const s=t.toString();return s?`?${s}`:""},D.fetchData=function(e,t){return x(this,void 0,void 0,(function*(){let s;null!=t&&(s={method:"POST",body:"string"==typeof t?t:JSON.stringify(t),headers:{"Content-Type":"application/json"}});const a=yield(0,H.default)(e,s);let r;try{r=yield a.json()}catch(e){if(a.headers&&"0"!==a.headers.get("content-length"))throw new Error(`Invalid response content: ${a.statusText}`)}if(!a.ok){const e="object"==typeof(n=r)&&null!==n&&"code"in n&&"message"in n?`${r.code}: ${r.message}`:a.statusText;throw new Error(e)}var n;return r}))},Object.defineProperty(L,"__esModule",{value:!0}),L.getEndpoint=L.postEndpoint=void 0;const B=D;function q(e,t,s,a){return`${e}${(0,B.insertParams)(t,s)}${(0,B.stringifyQuery)(a)}`}L.postEndpoint=function(e,t,s){const a=q(e,t,null==s?void 0:s.path,null==s?void 0:s.query);return(0,B.fetchData)(a,null==s?void 0:s.body)},L.getEndpoint=function(e,t,s,a){if(a)return(0,B.fetchData)(a);const r=q(e,t,null==s?void 0:s.path,null==s?void 0:s.query);return(0,B.fetchData)(r)};var k={};Object.defineProperty(k,"__esModule",{value:!0}),k.DEFAULT_BASE_URL=void 0,k.DEFAULT_BASE_URL="https://safe-client.safe.global";var U={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.ImplementationVersionState=void 0,(t=e.ImplementationVersionState||(e.ImplementationVersionState={})).UP_TO_DATE="UP_TO_DATE",t.OUTDATED="OUTDATED",t.UNKNOWN="UNKNOWN"}(U);var $={};!function(e){var t,s;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppSocialPlatforms=e.SafeAppFeatures=e.SafeAppAccessPolicyTypes=void 0,(t=e.SafeAppAccessPolicyTypes||(e.SafeAppAccessPolicyTypes={})).NoRestrictions="NO_RESTRICTIONS",t.DomainAllowlist="DOMAIN_ALLOWLIST",(e.SafeAppFeatures||(e.SafeAppFeatures={})).BATCHED_TRANSACTIONS="BATCHED_TRANSACTIONS",(s=e.SafeAppSocialPlatforms||(e.SafeAppSocialPlatforms={})).TWITTER="TWITTER",s.GITHUB="GITHUB",s.DISCORD="DISCORD"}($);var F={};!function(e){var t,s,a,r,n,o,i,d,c,l;Object.defineProperty(e,"__esModule",{value:!0}),e.LabelValue=e.DetailedExecutionInfoType=e.TransactionListItemType=e.ConflictType=e.TransactionInfoType=e.SettingsInfoType=e.TransactionTokenType=e.TransferDirection=e.TransactionStatus=e.Operation=void 0,(t=e.Operation||(e.Operation={}))[t.CALL=0]="CALL",t[t.DELEGATE=1]="DELEGATE",(s=e.TransactionStatus||(e.TransactionStatus={})).AWAITING_CONFIRMATIONS="AWAITING_CONFIRMATIONS",s.AWAITING_EXECUTION="AWAITING_EXECUTION",s.CANCELLED="CANCELLED",s.FAILED="FAILED",s.SUCCESS="SUCCESS",(a=e.TransferDirection||(e.TransferDirection={})).INCOMING="INCOMING",a.OUTGOING="OUTGOING",a.UNKNOWN="UNKNOWN",(r=e.TransactionTokenType||(e.TransactionTokenType={})).ERC20="ERC20",r.ERC721="ERC721",r.NATIVE_COIN="NATIVE_COIN",(n=e.SettingsInfoType||(e.SettingsInfoType={})).SET_FALLBACK_HANDLER="SET_FALLBACK_HANDLER",n.ADD_OWNER="ADD_OWNER",n.REMOVE_OWNER="REMOVE_OWNER",n.SWAP_OWNER="SWAP_OWNER",n.CHANGE_THRESHOLD="CHANGE_THRESHOLD",n.CHANGE_IMPLEMENTATION="CHANGE_IMPLEMENTATION",n.ENABLE_MODULE="ENABLE_MODULE",n.DISABLE_MODULE="DISABLE_MODULE",n.SET_GUARD="SET_GUARD",n.DELETE_GUARD="DELETE_GUARD",(o=e.TransactionInfoType||(e.TransactionInfoType={})).TRANSFER="Transfer",o.SETTINGS_CHANGE="SettingsChange",o.CUSTOM="Custom",o.CREATION="Creation",(i=e.ConflictType||(e.ConflictType={})).NONE="None",i.HAS_NEXT="HasNext",i.END="End",(d=e.TransactionListItemType||(e.TransactionListItemType={})).TRANSACTION="TRANSACTION",d.LABEL="LABEL",d.CONFLICT_HEADER="CONFLICT_HEADER",d.DATE_LABEL="DATE_LABEL",(c=e.DetailedExecutionInfoType||(e.DetailedExecutionInfoType={})).MULTISIG="MULTISIG",c.MODULE="MODULE",(l=e.LabelValue||(e.LabelValue={})).Queued="Queued",l.Next="Next"}(F);var W={};!function(e){var t,s,a;Object.defineProperty(e,"__esModule",{value:!0}),e.FEATURES=e.GAS_PRICE_TYPE=e.RPC_AUTHENTICATION=void 0,(t=e.RPC_AUTHENTICATION||(e.RPC_AUTHENTICATION={})).API_KEY_PATH="API_KEY_PATH",t.NO_AUTHENTICATION="NO_AUTHENTICATION",t.UNKNOWN="UNKNOWN",(s=e.GAS_PRICE_TYPE||(e.GAS_PRICE_TYPE={})).ORACLE="ORACLE",s.FIXED="FIXED",s.UNKNOWN="UNKNOWN",(a=e.FEATURES||(e.FEATURES={})).ERC721="ERC721",a.SAFE_APPS="SAFE_APPS",a.CONTRACT_INTERACTION="CONTRACT_INTERACTION",a.DOMAIN_LOOKUP="DOMAIN_LOOKUP",a.SPENDING_LIMIT="SPENDING_LIMIT",a.EIP1559="EIP1559",a.SAFE_TX_GAS_OPTIONAL="SAFE_TX_GAS_OPTIONAL",a.TX_SIMULATION="TX_SIMULATION",a.EIP1271="EIP1271"}(W);var V={};!function(e){var t;Object.defineProperty(e,"__esModule",{value:!0}),e.TokenType=void 0,(t=e.TokenType||(e.TokenType={})).ERC20="ERC20",t.ERC721="ERC721",t.NATIVE_TOKEN="NATIVE_TOKEN"}(V);var K={};Object.defineProperty(K,"__esModule",{value:!0});var Q={};Object.defineProperty(Q,"__esModule",{value:!0});var X={};!function(e){var t,s;Object.defineProperty(e,"__esModule",{value:!0}),e.SafeMessageStatus=e.SafeMessageListItemType=void 0,(t=e.SafeMessageListItemType||(e.SafeMessageListItemType={})).DATE_LABEL="DATE_LABEL",t.MESSAGE="MESSAGE",(s=e.SafeMessageStatus||(e.SafeMessageStatus={})).NEEDS_CONFIRMATION="NEEDS_CONFIRMATION",s.CONFIRMED="CONFIRMED"}(X),function(t){var s=e.commonjsGlobal&&e.commonjsGlobal.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e.commonjsGlobal&&e.commonjsGlobal.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),t.confirmSafeMessage=t.proposeSafeMessage=t.getSafeMessage=t.getSafeMessages=t.getDecodedData=t.getMasterCopies=t.getSafeApps=t.getChainConfig=t.getChainsConfig=t.proposeTransaction=t.postSafeGasEstimation=t.getTransactionDetails=t.getTransactionQueue=t.getTransactionHistory=t.getCollectiblesPage=t.getCollectibles=t.getOwnedSafes=t.getFiatCurrencies=t.getBalances=t.getMultisigTransactions=t.getModuleTransactions=t.getIncomingTransfers=t.getSafeInfo=t.setBaseUrl=void 0;const r=L,n=k;a(U,t),a($,t),a(F,t),a(W,t),a(V,t),a(K,t),a(Q,t),a(X,t);let o=n.DEFAULT_BASE_URL;t.setBaseUrl=e=>{o=e},t.getSafeInfo=function(e,t){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{address}",{path:{chainId:e,address:t}})},t.getIncomingTransfers=function(e,t,s,a){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{address}/incoming-transfers/",{path:{chainId:e,address:t},query:s},a)},t.getModuleTransactions=function(e,t,s,a){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{address}/module-transactions/",{path:{chainId:e,address:t},query:s},a)},t.getMultisigTransactions=function(e,t,s,a){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{address}/multisig-transactions/",{path:{chainId:e,address:t},query:s},a)},t.getBalances=function(e,t,s="usd",a={}){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{address}/balances/{currency}",{path:{chainId:e,address:t,currency:s},query:a})},t.getFiatCurrencies=function(){return(0,r.getEndpoint)(o,"/v1/balances/supported-fiat-codes")},t.getOwnedSafes=function(e,t){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/owners/{address}/safes",{path:{chainId:e,address:t}})},t.getCollectibles=function(e,t,s={}){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:e,address:t},query:s})},t.getCollectiblesPage=function(e,t,s={},a){return(0,r.getEndpoint)(o,"/v2/chains/{chainId}/safes/{address}/collectibles",{path:{chainId:e,address:t},query:s},a)},t.getTransactionHistory=function(e,t,s){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{safe_address}/transactions/history",{path:{chainId:e,safe_address:t},query:{}},s)},t.getTransactionQueue=function(e,t,s,a){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{safe_address}/transactions/queued",{path:{chainId:e,safe_address:t},query:{trusted:a}},s)},t.getTransactionDetails=function(e,t){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/transactions/{transactionId}",{path:{chainId:e,transactionId:t}})},t.postSafeGasEstimation=function(e,t,s){return(0,r.postEndpoint)(o,"/v2/chains/{chainId}/safes/{safe_address}/multisig-transactions/estimations",{path:{chainId:e,safe_address:t},body:s})},t.proposeTransaction=function(e,t,s){return(0,r.postEndpoint)(o,"/v1/chains/{chainId}/transactions/{safe_address}/propose",{path:{chainId:e,safe_address:t},body:s})},t.getChainsConfig=function(e){return(0,r.getEndpoint)(o,"/v1/chains",{query:e})},t.getChainConfig=function(e){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}",{path:{chainId:e}})},t.getSafeApps=function(e,t={}){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safe-apps",{path:{chainId:e},query:t})},t.getMasterCopies=function(e){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/about/master-copies",{path:{chainId:e}})},t.getDecodedData=function(e,t){return(0,r.postEndpoint)(o,"/v1/chains/{chainId}/data-decoder",{path:{chainId:e},body:{data:t}})},t.getSafeMessages=function(e,t,s){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:e,safe_address:t},query:{}},s)},t.getSafeMessage=function(e,t){return(0,r.getEndpoint)(o,"/v1/chains/{chainId}/messages/{message_hash}",{path:{chainId:e,message_hash:t}})},t.proposeSafeMessage=function(e,t,s){return(0,r.postEndpoint)(o,"/v1/chains/{chainId}/safes/{safe_address}/messages",{path:{chainId:e,safe_address:t},body:s})},t.confirmSafeMessage=function(e,t,s){return(0,r.postEndpoint)(o,"/v1/chains/{chainId}/messages/{message_hash}/signatures",{path:{chainId:e,message_hash:t},body:s})}}(N),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.TransferDirection=e.TransactionStatus=e.TokenType=e.Operation=void 0;var t=N;Object.defineProperty(e,"Operation",{enumerable:!0,get:function(){return t.Operation}}),Object.defineProperty(e,"TokenType",{enumerable:!0,get:function(){return t.TokenType}}),Object.defineProperty(e,"TransactionStatus",{enumerable:!0,get:function(){return t.TransactionStatus}}),Object.defineProperty(e,"TransferDirection",{enumerable:!0,get:function(){return t.TransferDirection}})}(R);var Y={};Object.defineProperty(Y,"__esModule",{value:!0}),function(t){var s=e.commonjsGlobal&&e.commonjsGlobal.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e.commonjsGlobal&&e.commonjsGlobal.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)};Object.defineProperty(t,"__esModule",{value:!0}),a(M,t),a(j,t),a(R,t),a(Y,t)}(C),Object.defineProperty(O,"__esModule",{value:!0}),O.TXs=void 0;const J=P,z=C;O.TXs=class{constructor(e){this.communicator=e}async getBySafeTxHash(e){if(!e)throw new Error("Invalid safeTxHash");return(await this.communicator.send(J.Methods.getTxBySafeTxHash,{safeTxHash:e})).data}async signMessage(e){const t={message:e};return(await this.communicator.send(J.Methods.signMessage,t)).data}async signTypedMessage(e){if(!(0,z.isObjectEIP712TypedData)(e))throw new Error("Invalid typed data");return(await this.communicator.send(J.Methods.signTypedMessage,{typedData:e})).data}async send({txs:e,params:t}){if(!e||!e.length)throw new Error("No transactions were passed");const s={txs:e,params:t};return(await this.communicator.send(J.Methods.sendTransactions,s)).data}};var Z={},ee={};Object.defineProperty(ee,"__esModule",{value:!0}),ee.RPC_CALLS=void 0,ee.RPC_CALLS={eth_call:"eth_call",eth_gasPrice:"eth_gasPrice",eth_getLogs:"eth_getLogs",eth_getBalance:"eth_getBalance",eth_getCode:"eth_getCode",eth_getBlockByHash:"eth_getBlockByHash",eth_getBlockByNumber:"eth_getBlockByNumber",eth_getStorageAt:"eth_getStorageAt",eth_getTransactionByHash:"eth_getTransactionByHash",eth_getTransactionReceipt:"eth_getTransactionReceipt",eth_getTransactionCount:"eth_getTransactionCount",eth_estimateGas:"eth_estimateGas",safe_setSettings:"safe_setSettings"},Object.defineProperty(Z,"__esModule",{value:!0}),Z.Eth=void 0;const te=ee,se=P,ae={defaultBlockParam:(e="latest")=>e,returnFullTxObjectParam:(e=!1)=>e,blockNumberToHex:e=>Number.isInteger(e)?`0x${e.toString(16)}`:e};Z.Eth=class{constructor(e){this.communicator=e,this.call=this.buildRequest({call:te.RPC_CALLS.eth_call,formatters:[null,ae.defaultBlockParam]}),this.getBalance=this.buildRequest({call:te.RPC_CALLS.eth_getBalance,formatters:[null,ae.defaultBlockParam]}),this.getCode=this.buildRequest({call:te.RPC_CALLS.eth_getCode,formatters:[null,ae.defaultBlockParam]}),this.getStorageAt=this.buildRequest({call:te.RPC_CALLS.eth_getStorageAt,formatters:[null,ae.blockNumberToHex,ae.defaultBlockParam]}),this.getPastLogs=this.buildRequest({call:te.RPC_CALLS.eth_getLogs}),this.getBlockByHash=this.buildRequest({call:te.RPC_CALLS.eth_getBlockByHash,formatters:[null,ae.returnFullTxObjectParam]}),this.getBlockByNumber=this.buildRequest({call:te.RPC_CALLS.eth_getBlockByNumber,formatters:[ae.blockNumberToHex,ae.returnFullTxObjectParam]}),this.getTransactionByHash=this.buildRequest({call:te.RPC_CALLS.eth_getTransactionByHash}),this.getTransactionReceipt=this.buildRequest({call:te.RPC_CALLS.eth_getTransactionReceipt}),this.getTransactionCount=this.buildRequest({call:te.RPC_CALLS.eth_getTransactionCount,formatters:[null,ae.defaultBlockParam]}),this.getGasPrice=this.buildRequest({call:te.RPC_CALLS.eth_gasPrice}),this.getEstimateGas=e=>this.buildRequest({call:te.RPC_CALLS.eth_estimateGas})([e]),this.setSafeSettings=this.buildRequest({call:te.RPC_CALLS.safe_setSettings})}buildRequest(e){const{call:t,formatters:s}=e;return async e=>{s&&Array.isArray(e)&&s.forEach(((t,s)=>{t&&(e[s]=t(e[s]))}));const a={call:t,params:e||[]};return(await this.communicator.send(se.Methods.rpcCall,a)).data}}};var re={};try{const e=window;null==e._ethers&&(e._ethers=s.ethers)}catch(e){}var ne=Object.freeze({__proto__:null,ethers:s.ethers,Signer:a.Signer,Wallet:s.Wallet,VoidSigner:a.VoidSigner,getDefaultProvider:r.getDefaultProvider,providers:u,BaseContract:n.BaseContract,Contract:n.Contract,ContractFactory:n.ContractFactory,BigNumber:o.BigNumber,FixedNumber:s.FixedNumber,constants:f,get errors(){return o.ErrorCode},logger:s.logger,utils:s.utils,wordlists:s.wordlists,version:s.version,Wordlist:s.Wordlist}),oe=e.getAugmentedNamespace(ne),ie={};Object.defineProperty(ie,"__esModule",{value:!0}),ie.MAGIC_VALUE_BYTES=ie.MAGIC_VALUE=ie.EIP_1271_BYTES_INTERFACE=ie.EIP_1271_INTERFACE=void 0;const de=oe;ie.MAGIC_VALUE="0x1626ba7e";ie.MAGIC_VALUE_BYTES="0x20c13b0b";const ce=new de.ethers.utils.Interface(["function isValidSignature(bytes32 _dataHash, bytes calldata _signature) external view"]);ie.EIP_1271_INTERFACE=ce;const le=new de.ethers.utils.Interface(["function isValidSignature(bytes calldata _data, bytes calldata _signature) public view"]);ie.EIP_1271_BYTES_INTERFACE=le;var ue={},fe={},he={};Object.defineProperty(he,"__esModule",{value:!0}),he.PermissionsError=he.PERMISSIONS_REQUEST_REJECTED=void 0,he.PERMISSIONS_REQUEST_REJECTED=4001;class ge extends Error{constructor(e,t,s){super(e),this.code=t,this.data=s,Object.setPrototypeOf(this,ge.prototype)}}he.PermissionsError=ge,Object.defineProperty(fe,"__esModule",{value:!0}),fe.Wallet=void 0;const pe=P,me=he;fe.Wallet=class{constructor(e){this.communicator=e}async getPermissions(){return(await this.communicator.send(pe.Methods.wallet_getPermissions,void 0)).data}async requestPermissions(e){if(!this.isPermissionRequestValid(e))throw new me.PermissionsError("Permissions request is invalid",me.PERMISSIONS_REQUEST_REJECTED);try{return(await this.communicator.send(pe.Methods.wallet_requestPermissions,e)).data}catch(e){throw new me.PermissionsError("Permissions rejected",me.PERMISSIONS_REQUEST_REJECTED)}}isPermissionRequestValid(e){return e.every((e=>"object"==typeof e&&Object.keys(e).every((e=>!!Object.values(pe.RestrictedMethods).includes(e)))))}},Object.defineProperty(ue,"__esModule",{value:!0});const _e=fe,Ee=he,ve=(e,t)=>t.some((t=>t.parentCapability===e));ue.default=()=>(e,t,s)=>{const a=s.value;return s.value=async function(){const e=new _e.Wallet(this.communicator);let s=await e.getPermissions();if(ve(t,s)||(s=await e.requestPermissions([{[t]:{}}])),!ve(t,s))throw new Ee.PermissionsError("Permissions rejected",Ee.PERMISSIONS_REQUEST_REJECTED);return a.apply(this)},s};var Te=e.commonjsGlobal&&e.commonjsGlobal.__decorate||function(e,t,s,a){var r,n=arguments.length,o=n<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,s):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,s,a);else for(var i=e.length-1;i>=0;i--)(r=e[i])&&(o=(n<3?r(o):n>3?r(t,s,o):r(t,s))||o);return n>3&&o&&Object.defineProperty(t,s,o),o},ye=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(re,"__esModule",{value:!0}),re.Safe=void 0;const we=oe,be=ie,Se=P,Ie=ee,Ae=C,Pe=ye(ue);class Oe{constructor(e){this.communicator=e}async getChainInfo(){return(await this.communicator.send(Se.Methods.getChainInfo,void 0)).data}async getInfo(){return(await this.communicator.send(Se.Methods.getSafeInfo,void 0)).data}async experimental_getBalances({currency:e="usd"}={}){return(await this.communicator.send(Se.Methods.getSafeBalances,{currency:e})).data}async check1271Signature(e,t="0x"){const s=await this.getInfo(),a=be.EIP_1271_INTERFACE.encodeFunctionData("isValidSignature",[e,t]),r={call:Ie.RPC_CALLS.eth_call,params:[{to:s.safeAddress,data:a},"latest"]};try{return(await this.communicator.send(Se.Methods.rpcCall,r)).data.slice(0,10).toLowerCase()===be.MAGIC_VALUE}catch(e){return!1}}async check1271SignatureBytes(e,t="0x"){const s=await this.getInfo(),a=we.ethers.utils.arrayify(e),r=be.EIP_1271_BYTES_INTERFACE.encodeFunctionData("isValidSignature",[a,t]),n={call:Ie.RPC_CALLS.eth_call,params:[{to:s.safeAddress,data:r},"latest"]};try{return(await this.communicator.send(Se.Methods.rpcCall,n)).data.slice(0,10).toLowerCase()===be.MAGIC_VALUE_BYTES}catch(e){return!1}}calculateMessageHash(e){return we.ethers.utils.hashMessage(e)}calculateTypedMessageHash(e){return we.ethers.utils._TypedDataEncoder.hash(e.domain,e.types,e.message)}async getOffChainSignature(e){return(await this.communicator.send(Se.Methods.getOffChainSignature,e)).data}async isMessageSigned(e,t="0x"){let s;if("string"==typeof e&&(s=async()=>{const s=this.calculateMessageHash(e);return await this.isMessageHashSigned(s,t)}),(0,Ae.isObjectEIP712TypedData)(e)&&(s=async()=>{const s=this.calculateTypedMessageHash(e);return await this.isMessageHashSigned(s,t)}),s){return await s()}throw new Error("Invalid message type")}async isMessageHashSigned(e,t="0x"){const s=[this.check1271Signature.bind(this),this.check1271SignatureBytes.bind(this)];for(const a of s){if(await a(e,t))return!0}return!1}async getEnvironmentInfo(){return(await this.communicator.send(Se.Methods.getEnvironmentInfo,void 0)).data}async requestAddressBook(){return(await this.communicator.send(Se.Methods.requestAddressBook,void 0)).data}}Te([(0,Pe.default)()],Oe.prototype,"requestAddressBook",null),re.Safe=Oe;var Ce=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(p,"__esModule",{value:!0});const Me=Ce(m),je=O,Re=Z,Ne=re,Le=fe;p.default=class{constructor(e={}){const{allowedDomains:t=null,debug:s=!1}=e;this.communicator=new Me.default(t,s),this.eth=new Re.Eth(this.communicator),this.txs=new je.TXs(this.communicator),this.safe=new Ne.Safe(this.communicator),this.wallet=new Le.Wallet(this.communicator)}},function(t){var s=e.commonjsGlobal&&e.commonjsGlobal.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e.commonjsGlobal&&e.commonjsGlobal.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)},r=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.getSDKVersion=void 0;const n=r(p);t.default=n.default,a(p,t),a(C,t),a(P,t),a(_,t);var o=E;Object.defineProperty(t,"getSDKVersion",{enumerable:!0,get:function(){return o.getSDKVersion}})}(g);var De=e.getDefaultExportFromCjs(g),xe={},Ge={},He={};Object.defineProperty(He,"__esModule",{value:!0}),He.getLowerCase=void 0,He.getLowerCase=function(e){return e?e.toLowerCase():e},Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.SafeAppProvider=void 0;const Be=h.default,qe=He;class ke extends Be.EventEmitter{constructor(e,t){super(),this.submittedTxs=new Map,this.safe=e,this.sdk=t}async connect(){this.emit("connect",{chainId:this.chainId})}async disconnect(){}get chainId(){return this.safe.chainId}async request(e){const{method:t,params:s=[]}=e;switch(t){case"eth_accounts":return[this.safe.safeAddress];case"net_version":case"eth_chainId":return`0x${this.chainId.toString(16)}`;case"personal_sign":{const[e,t]=s;if(this.safe.safeAddress.toLowerCase()!==t.toLowerCase())throw new Error("The address or message hash is invalid");return await this.sdk.txs.signMessage(e),"0x"}case"eth_sign":{const[e,t]=s;if(this.safe.safeAddress.toLowerCase()!==e.toLowerCase()||!t.startsWith("0x"))throw new Error("The address or message hash is invalid");return await this.sdk.txs.signMessage(t),"0x"}case"eth_signTypedData":case"eth_signTypedData_v4":{const[e,t]=s,a="string"==typeof t?JSON.parse(t):t;if(this.safe.safeAddress.toLowerCase()!==e.toLowerCase())throw new Error("The address is invalid");return await this.sdk.txs.signTypedMessage(a),"0x"}case"eth_sendTransaction":const t=Object.assign({value:"0",data:"0x"},s[0]);"string"==typeof t.gas&&t.gas.startsWith("0x")&&(t.gas=parseInt(t.gas,16));const a=await this.sdk.txs.send({txs:[t],params:{safeTxGas:t.gas}});return this.submittedTxs.set(a.safeTxHash,{from:this.safe.safeAddress,hash:a.safeTxHash,gas:0,gasPrice:"0x00",nonce:0,input:t.data,value:t.value,to:t.to,blockHash:null,blockNumber:null,transactionIndex:null}),a.safeTxHash;case"eth_blockNumber":return(await this.sdk.eth.getBlockByNumber(["latest"])).number;case"eth_getBalance":return this.sdk.eth.getBalance([(0,qe.getLowerCase)(s[0]),s[1]]);case"eth_getCode":return this.sdk.eth.getCode([(0,qe.getLowerCase)(s[0]),s[1]]);case"eth_getTransactionCount":return this.sdk.eth.getTransactionCount([(0,qe.getLowerCase)(s[0]),s[1]]);case"eth_getStorageAt":return this.sdk.eth.getStorageAt([(0,qe.getLowerCase)(s[0]),s[1],s[2]]);case"eth_getBlockByNumber":return this.sdk.eth.getBlockByNumber([s[0],s[1]]);case"eth_getBlockByHash":return this.sdk.eth.getBlockByHash([s[0],s[1]]);case"eth_getTransactionByHash":let r=s[0];try{r=(await this.sdk.txs.getBySafeTxHash(r)).txHash||r}catch(e){}return this.submittedTxs.has(r)?this.submittedTxs.get(r):this.sdk.eth.getTransactionByHash([r]).then((e=>(e&&(e.hash=s[0]),e)));case"eth_getTransactionReceipt":{let e=s[0];try{e=(await this.sdk.txs.getBySafeTxHash(e)).txHash||e}catch(e){}return this.sdk.eth.getTransactionReceipt([e]).then((e=>(e&&(e.transactionHash=s[0]),e)))}case"eth_estimateGas":return this.sdk.eth.getEstimateGas(s[0]);case"eth_call":return this.sdk.eth.call([s[0],s[1]]);case"eth_getLogs":return this.sdk.eth.getPastLogs([s[0]]);case"eth_gasPrice":return this.sdk.eth.getGasPrice();case"wallet_getPermissions":return this.sdk.wallet.getPermissions();case"wallet_requestPermissions":return this.sdk.wallet.requestPermissions(s[0]);case"safe_setSettings":return this.sdk.eth.setSafeSettings([s[0]]);default:throw Error(`"${e.method}" not implemented`)}}send(e,t){e||t("Undefined request"),this.request(e).then((s=>t(null,{jsonrpc:"2.0",id:e.id,result:s}))).catch((e=>t(e,null)))}}let Ue,$e;function Fe(){return e.__awaiter(this,void 0,void 0,(function*(){return $e||($e=new De),void 0===Ue&&(Ue=yield Promise.race([$e.safe.getInfo(),new Promise((e=>setTimeout(e,200)))])),Ue}))}Ge.SafeAppProvider=ke,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.SafeAppProvider=void 0;var t=Ge;Object.defineProperty(e,"SafeAppProvider",{enumerable:!0,get:function(){return t.SafeAppProvider}})}(xe);var We={},Ve={},Ke={};Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.getTxServiceBaseUrl=void 0,Ke.getTxServiceBaseUrl=function(e){return`${e}/api`};var Qe={},Xe={exports:{}};!function(t,s){var a=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e.commonjsGlobal)return e.commonjsGlobal;throw new Error("unable to locate global object")}();t.exports=s=a.fetch,a.fetch&&(s.default=a.fetch.bind(a)),s.Headers=a.Headers,s.Request=a.Request,s.Response=a.Response}(Xe,Xe.exports),function(t){var s=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.sendRequest=t.HttpMethod=void 0;const a=s(Xe.exports);var r;(r=t.HttpMethod||(t.HttpMethod={})).Get="get",r.Post="post",r.Delete="delete",t.sendRequest=async function({url:e,method:t,body:s}){const r=await(0,a.default)(e,{method:t,headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)});let n;try{n=await r.json()}catch(e){if(!r.ok)throw new Error(r.statusText)}if(r.ok)return n;if(n.data)throw new Error(n.data);if(n.detail)throw new Error(n.detail);if(n.message)throw new Error(n.message);if(n.nonFieldErrors)throw new Error(n.nonFieldErrors);if(n.delegate)throw new Error(n.delegate);if(n.safe)throw new Error(n.safe);if(n.delegator)throw new Error(n.delegator);throw new Error(r.statusText)}}(Qe);var Ye,Je,ze=e.commonjsGlobal&&e.commonjsGlobal.__classPrivateFieldSet||function(e,t,s,a,r){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?r.call(e,s):r?r.value=s:t.set(e,s),s},Ze=e.commonjsGlobal&&e.commonjsGlobal.__classPrivateFieldGet||function(e,t,s,a){if("a"===s&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?a:"a"===s?a.call(e):a?a.value:t.get(e)};Object.defineProperty(Ve,"__esModule",{value:!0});const et=Ke,tt=Qe;Ye=new WeakMap,Je=new WeakMap,Ve.default=class{constructor({txServiceUrl:e,ethAdapter:t}){Ye.set(this,void 0),Je.set(this,void 0),ze(this,Ye,(0,et.getTxServiceBaseUrl)(e),"f"),ze(this,Je,t,"f")}async getServiceInfo(){return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/about`,method:tt.HttpMethod.Get})}async getServiceMasterCopiesInfo(){return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/about/master-copies`,method:tt.HttpMethod.Get})}async decodeData(e){if(""===e)throw new Error("Invalid data");return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/data-decoder/`,method:tt.HttpMethod.Post,body:{data:e}})}async getSafesByOwner(e){if(""===e)throw new Error("Invalid owner address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/owners/${t}/safes/`,method:tt.HttpMethod.Get})}async getSafesByModule(e){if(""===e)throw new Error("Invalid module address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/modules/${t}/safes/`,method:tt.HttpMethod.Get})}async getTransaction(e){if(""===e)throw new Error("Invalid safeTxHash");return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/multisig-transactions/${e}/`,method:tt.HttpMethod.Get})}async getTransactionConfirmations(e){if(""===e)throw new Error("Invalid safeTxHash");return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/multisig-transactions/${e}/confirmations/`,method:tt.HttpMethod.Get})}async confirmTransaction(e,t){if(""===e)throw new Error("Invalid safeTxHash");if(""===t)throw new Error("Invalid signature");return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/multisig-transactions/${e}/confirmations/`,method:tt.HttpMethod.Post,body:{signature:t}})}async getSafeInfo(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${t}/`,method:tt.HttpMethod.Get})}async getSafeDelegates({safeAddress:e,delegateAddress:t,delegatorAddress:s,label:a,limit:r,offset:n}){const o=new URL(`${Ze(this,Ye,"f")}/v1/delegates`);if(e){const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);o.searchParams.set("safe",t)}if(t){const{address:e}=await Ze(this,Je,"f").getEip3770Address(t);o.searchParams.set("delegate",e)}if(s){const{address:e}=await Ze(this,Je,"f").getEip3770Address(s);o.searchParams.set("delegator",e)}return a&&o.searchParams.set("label",a),r&&o.searchParams.set("limit",r),n&&o.searchParams.set("offset",n),(0,tt.sendRequest)({url:o.toString(),method:tt.HttpMethod.Get})}async addSafeDelegate({safeAddress:e,delegateAddress:t,delegatorAddress:s,label:a,signer:r}){if(""===t)throw new Error("Invalid Safe delegate address");if(""===s)throw new Error("Invalid Safe delegator address");if(""===a)throw new Error("Invalid label");const{address:n}=await Ze(this,Je,"f").getEip3770Address(t),{address:o}=await Ze(this,Je,"f").getEip3770Address(s),i=n+Math.floor(Date.now()/1e3/3600),d=await r.signMessage(i),c={safe:e?(await Ze(this,Je,"f").getEip3770Address(e)).address:null,delegate:n,delegator:o,label:a,signature:d};return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/delegates/`,method:tt.HttpMethod.Post,body:c})}async removeSafeDelegate({delegateAddress:e,delegatorAddress:t,signer:s}){if(""===e)throw new Error("Invalid Safe delegate address");if(""===t)throw new Error("Invalid Safe delegator address");const{address:a}=await Ze(this,Je,"f").getEip3770Address(e),{address:r}=await Ze(this,Je,"f").getEip3770Address(t),n=a+Math.floor(Date.now()/1e3/3600),o=await s.signMessage(n);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/delegates/${a}`,method:tt.HttpMethod.Delete,body:{delegate:a,delegator:r,signature:o}})}async getSafeCreationInfo(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${t}/creation/`,method:tt.HttpMethod.Get})}async estimateSafeTransaction(e,t){if(""===e)throw new Error("Invalid Safe address");const{address:s}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${s}/multisig-transactions/estimations/`,method:tt.HttpMethod.Post,body:t})}async proposeTransaction({safeAddress:e,safeTransactionData:t,safeTxHash:s,senderAddress:a,senderSignature:r,origin:n}){if(""===e)throw new Error("Invalid Safe address");const{address:o}=await Ze(this,Je,"f").getEip3770Address(e),{address:i}=await Ze(this,Je,"f").getEip3770Address(a);if(""===s)throw new Error("Invalid safeTxHash");return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${o}/multisig-transactions/`,method:tt.HttpMethod.Post,body:{...t,contractTransactionHash:s,sender:i,signature:r,origin:n}})}async getIncomingTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${t}/incoming-transfers?executed=true`,method:tt.HttpMethod.Get})}async getModuleTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${t}/module-transactions/`,method:tt.HttpMethod.Get})}async getMultisigTransactions(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${t}/multisig-transactions/`,method:tt.HttpMethod.Get})}async getPendingTransactions(e,t){if(""===e)throw new Error("Invalid Safe address");const{address:s}=await Ze(this,Je,"f").getEip3770Address(e),a=t||(await this.getSafeInfo(s)).nonce;return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/safes/${s}/multisig-transactions/?executed=false&nonce__gte=${a}`,method:tt.HttpMethod.Get})}async getAllTransactions(e,t){var s,a,r;if(""===e)throw new Error("Invalid Safe address");const{address:n}=await Ze(this,Je,"f").getEip3770Address(e),o=new URL(`${Ze(this,Ye,"f")}/v1/safes/${n}/all-transactions/`),i=(null===(s=null==t?void 0:t.trusted)||void 0===s?void 0:s.toString())||"true";o.searchParams.set("trusted",i);const d=(null===(a=null==t?void 0:t.queued)||void 0===a?void 0:a.toString())||"true";o.searchParams.set("queued",d);const c=(null===(r=null==t?void 0:t.executed)||void 0===r?void 0:r.toString())||"false";return o.searchParams.set("executed",c),(0,tt.sendRequest)({url:o.toString(),method:tt.HttpMethod.Get})}async getNextNonce(e){if(""===e)throw new Error("Invalid Safe address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e),s=await this.getPendingTransactions(t);if(s.results.length>0){const e=s.results.map((e=>e.nonce));return Math.max(...e)+1}return(await this.getSafeInfo(t)).nonce}async getTokenList(){return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/tokens/`,method:tt.HttpMethod.Get})}async getToken(e){if(""===e)throw new Error("Invalid token address");const{address:t}=await Ze(this,Je,"f").getEip3770Address(e);return(0,tt.sendRequest)({url:`${Ze(this,Ye,"f")}/v1/tokens/${t}/`,method:tt.HttpMethod.Get})}};var st={};Object.defineProperty(st,"__esModule",{value:!0}),function(t){var s=e.commonjsGlobal&&e.commonjsGlobal.__createBinding||(Object.create?function(e,t,s,a){void 0===a&&(a=s);var r=Object.getOwnPropertyDescriptor(t,s);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[s]}}),Object.defineProperty(e,a,r)}:function(e,t,s,a){void 0===a&&(a=s),e[a]=t[s]}),a=e.commonjsGlobal&&e.commonjsGlobal.__exportStar||function(e,t){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(t,a)||s(t,e,a)},r=e.commonjsGlobal&&e.commonjsGlobal.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const n=r(Ve);a(st,t),t.default=n.default}(We);var at=e.getDefaultExportFromCjs(We);const rt={1:"https://safe-transaction-mainnet.safe.global/",5:"https://safe-transaction-goerli.safe.global/",42161:"https://safe-transaction-arbitrum.safe.global/",43114:"https://safe-transaction-avalanche.safe.global/",1313161554:"https://safe-transaction-aurora.safe.global/",56:"https://safe-transaction-bsc.safe.global/",10:"https://safe-transaction-optimism.safe.global/",137:"https://safe-transaction-polygon.safe.global/"};let nt;function ot(t){return e.__awaiter(this,void 0,void 0,(function*(){if((null==nt?void 0:nt.chainId)===t)return nt.safeService;if(!e.useWalletStore.getState().provider)throw new Error("provider is undefined");const s=function(){return{getEip3770Address:t=>e.__awaiter(this,void 0,void 0,(function*(){const{address:e,prefix:s}=function(e){const t=e.split(":"),s=t.length>1?t[1]:t[0];return{prefix:t.length>1?t[0]:"",address:s}}(t);return{address:e,prefix:s}}))}}(),a=rt[t];if(!a)return;const r=new at({txServiceUrl:a,ethAdapter:s});return nt={safeService:r,chainId:t},nt.safeService}))}exports.default=function(t){return e.__awaiter(this,void 0,void 0,(function*(){const s=yield Fe();if(!s)throw Error("Could not load Safe information");const a=new xe.SafeAppProvider(s,$e);return a.on("connect",t.connect),a.on("disconnect",t.disconnect),a.on("accountsChanged",t.accountsChanged),a.on("chainChanged",t.chainChanged),a.on("message",t.message),e.convertWeb3Provider(a)}))},exports.getAccountIsSafe=function(t,s){return e.__awaiter(this,void 0,void 0,(function*(){if(!s)return!1;const e=yield ot(t);if(!e)return!1;try{return!!(yield e.getSafeInfo(s))}catch(e){return console.error(e),!1}}))},exports.getConnectedSafe=Fe,exports.getIsSafe=function(){return e.__awaiter(this,void 0,void 0,(function*(){return!!(yield Fe())}))},exports.getSafeHashDetailUrl=function(e,t,s){const a={1:"eth",5:"gor",137:"matic",56:"bnb",42161:"arb1",10:"oeth",43114:"avax",1313161554:"aurora"}[t];if(!a)throw new Error(`Not Supported network: ${t}`);return`https://app.safe.global/transactions/tx?id=multisig_${s}_${e}&safe=${a}%3A${s}`},exports.getSafeTxHash=function(t,s,a){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield ot(t);if(!e)return console.error(`chainId: ${t} is not supported safe`),a;if(a!==s)return a;const r=yield e.getMultisigTransactions(a),[n]=r.results;return n.safeTxHash}))},exports.getSafeTxStatus=function(t,s,a){return e.__awaiter(this,void 0,void 0,(function*(){const e=yield ot(t);if(!e)throw new Error(`chainId: ${t} is not supported safe`);try{const{results:t}=yield e.getMultisigTransactions(a),r=t.find((e=>e.safeTxHash.toLocaleLowerCase()===s.toLocaleLowerCase()));if(!r)return null;if(t.some((e=>!(e.nonce!==r.nonce||e.safeTxHash.toLocaleLowerCase()===s.toLocaleLowerCase()||!e.isExecuted||!e.isSuccessful))))return"rejected";if(null===r.isExecuted||null===r.isSuccessful)return null;return{status:r.isExecuted&&r.isSuccessful||!1,transactionHash:r.transactionHash,blockNumber:r.blockNumber||null}}catch(e){throw console.error(e),new Error(`safeTxHash: ${s} is not valid.`)}}))};