@snapshot-labs/snapshot.js 0.3.57-beta1 → 0.3.57-beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/snapshot.cjs.js +1 -1
- package/dist/snapshot.esm.js +1 -1
- package/dist/snapshot.min.js +1 -1
- package/package.json +1 -1
- package/src/dist/utils.js +1 -1
- package/src/utils.ts +1 -1
package/dist/snapshot.min.js
CHANGED
|
@@ -28,4 +28,4 @@
|
|
|
28
28
|
|| ${u} === "boolean" || ${o} === null`).assign(l,du._`[${o}]`)}}n.else(),h(t),n.endIf(),n.if(du._`${l} !== undefined`,()=>{n.assign(o,l),function({gen:t,parentData:e,parentDataProperty:r},n){t.if(du._`${e} !== undefined`,()=>t.assign(du._`${e}[${r}]`,n))}(t,l)})}(t,e,u):h(t)})}return l};const i=new Set(["string","number","integer","boolean","null"]);function o(t,e,n,i=r.Correct){const o=i===r.Correct?du.operators.EQ:du.operators.NEQ;let s;switch(t){case"null":return du._`${e} ${o} null`;case"array":s=du._`Array.isArray(${e})`;break;case"object":s=du._`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=a(du._`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=a();break;default:return du._`typeof ${e} ${o} ${t}`}return i===r.Correct?s:du.not(s);function a(t=du.nil){return du.and(du._`typeof ${e} == "number"`,t,n?du._`isFinite(${e})`:du.nil)}}function s(t,e,r,n){if(1===t.length)return o(t[0],e,r,n);let i;const s=mu.toHash(t);if(s.array&&s.object){const t=du._`typeof ${e} != "object"`;i=s.null?t:du._`!${e} || ${t}`,delete s.null,delete s.array,delete s.object}else i=du.nil;s.number&&delete s.integer;for(const t in s)i=du.and(i,o(t,e,r,n));return i}e.checkDataType=o,e.checkDataTypes=s;const a={message:({schema:t})=>"must be "+t,params:({schema:t,schemaValue:e})=>"string"==typeof t?du._`{type: ${t}}`:du._`{type: ${e}}`};function h(t){const e=function(t){const{gen:e,data:r,schema:n}=t,i=mu.schemaRefOrVal(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:i,schemaValue:i,parentSchema:n,params:{},it:t}}(t);yu.reportError(e,a)}e.reportTypeError=h})),Mu=h((function(t,e){function r(t,e,r){const{gen:n,compositeRule:i,data:o,opts:s}=t;if(void 0===r)return;const a=du._`${o}${du.getProperty(e)}`;if(i)return void mu.checkStrictMode(t,"default is ignored for: "+a);let h=du._`${a} === undefined`;"empty"===s.useDefaults&&(h=du._`${h} || ${a} === null || ${a} === ""`),n.if(h,du._`${a} = ${du.stringify(r)}`)}Object.defineProperty(e,"__esModule",{value:!0}),e.assignDefaults=void 0,e.assignDefaults=function(t,e){const{properties:n,items:i}=t.schema;if("object"===e&&n)for(const e in n)r(t,e,n[e].default);else"array"===e&&Array.isArray(i)&&i.forEach((e,n)=>r(t,n,e.default))}})),_u=h((function(t,e){function r(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:du._`Object.prototype.hasOwnProperty`})}function n(t,e,n){return du._`${r(t)}.call(${e}, ${n})`}function i(t,e,r,i){const o=du._`${e}${du.getProperty(r)} === undefined`;return i?du.or(o,du.not(n(t,e,r))):o}function o(t){return t?Object.keys(t).filter(t=>"__proto__"!==t):[]}Object.defineProperty(e,"__esModule",{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0,e.checkReportMissingProp=function(t,e){const{gen:r,data:n,it:o}=t;r.if(i(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:du._`${e}`},!0),t.error()})},e.checkMissingProp=function({gen:t,data:e,it:{opts:r}},n,o){return du.or(...n.map(n=>du.and(i(t,e,n,r.ownProperties),du._`${o} = ${n}`)))},e.reportMissingProp=function(t,e){t.setParams({missingProperty:e},!0),t.error()},e.hasPropFunc=r,e.isOwnProperty=n,e.propertyInData=function(t,e,r,i){const o=du._`${e}${du.getProperty(r)} !== undefined`;return i?du._`${o} && ${n(t,e,r)}`:o},e.noPropertyInData=i,e.allSchemaProperties=o,e.schemaProperties=function(t,e){return o(e).filter(r=>!mu.alwaysValidSchema(t,e[r]))},e.callValidateCode=function({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:i,errorPath:o},it:s},a,h,u){const l=u?du._`${t}, ${e}, ${n}${i}`:e,f=[[gu.default.instancePath,du.strConcat(gu.default.instancePath,o)],[gu.default.parentData,s.parentData],[gu.default.parentDataProperty,s.parentDataProperty],[gu.default.rootData,gu.default.rootData]];s.opts.dynamicRef&&f.push([gu.default.dynamicAnchors,gu.default.dynamicAnchors]);const c=du._`${l}, ${r.object(...f)}`;return h!==du.nil?du._`${a}.call(${h}, ${c})`:du._`${a}(${c})`},e.usePattern=function({gen:t,it:{opts:e}},r){const n=e.unicodeRegExp?"u":"";return t.scopeValue("pattern",{key:r,ref:new RegExp(r,n),code:du._`new RegExp(${r}, ${n})`})},e.validateArray=function(t){const{gen:e,data:r,keyword:n,it:i}=t,o=e.name("valid");if(i.allErrors){const t=e.let("valid",!0);return s(()=>e.assign(t,!1)),t}return e.var(o,!0),s(()=>e.break()),o;function s(i){const s=e.const("len",du._`${r}.length`);e.forRange("i",0,s,r=>{t.subschema({keyword:n,dataProp:r,dataPropType:mu.Type.Num},o),e.if(du.not(o),i)})}},e.validateUnion=function(t){const{gen:e,schema:r,keyword:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(t=>mu.alwaysValidSchema(i,t))&&!i.opts.unevaluated)return;const o=e.let("valid",!1),s=e.name("_valid");e.block(()=>r.forEach((r,i)=>{const a=t.subschema({keyword:n,schemaProp:i,compositeRule:!0},s);e.assign(o,du._`${o} || ${s}`);t.mergeValidEvaluated(a,s)||e.if(du.not(o))})),t.result(o,()=>t.reset(),()=>t.error(!0))}})),Au=h((function(t,e){function r(t){const{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,du._`${n.parentData}[${n.parentDataProperty}]`))}function n(t,e,r){if(void 0===r)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword","function"==typeof r?{ref:r}:{ref:r,code:du.stringify(r)})}Object.defineProperty(e,"__esModule",{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0,e.macroKeywordCode=function(t,e){const{gen:r,keyword:i,schema:o,parentSchema:s,it:a}=t,h=e.macro.call(a.self,o,s,a),u=n(r,i,h);!1!==a.opts.validateSchema&&a.self.validateSchema(h,!0);const l=r.name("valid");t.subschema({schema:h,schemaPath:du.nil,errSchemaPath:`${a.errSchemaPath}/${i}`,topSchemaRef:u,compositeRule:!0},l),t.pass(l,()=>t.error(!0))},e.funcKeywordCode=function(t,e){var i;const{gen:o,keyword:s,schema:a,parentSchema:h,$data:u,it:l}=t;!function({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}(l,e);const f=!u&&e.compile?e.compile.call(l.self,a,h,l):e.validate,c=n(o,s,f),d=o.let("valid");function m(r=(e.async?du._`await `:du.nil)){const n=l.opts.passContext?gu.default.this:gu.default.self,i=!("compile"in e&&!u||!1===e.schema);o.assign(d,du._`${r}${_u.callValidateCode(t,c,n,i)}`,e.modifying)}function p(t){var r;o.if(du.not(null!==(r=e.valid)&&void 0!==r?r:d),t)}t.block$data(d,(function(){if(!1===e.errors)m(),e.modifying&&r(t),p(()=>t.error());else{const n=e.async?function(){const t=o.let("ruleErrs",null);return o.try(()=>m(du._`await `),e=>o.assign(d,!1).if(du._`${e} instanceof ${l.ValidationError}`,()=>o.assign(t,du._`${e}.errors`),()=>o.throw(e))),t}():function(){const t=du._`${c}.errors`;return o.assign(t,null),m(du.nil),t}();e.modifying&&r(t),p(()=>function(t,e){const{gen:r}=t;r.if(du._`Array.isArray(${e})`,()=>{r.assign(gu.default.vErrors,du._`${gu.default.vErrors} === null ? ${e} : ${gu.default.vErrors}.concat(${e})`).assign(gu.default.errors,du._`${gu.default.vErrors}.length`),yu.extendErrors(t)},()=>t.error())}(t,n))}})),t.ok(null!==(i=e.valid)&&void 0!==i?i:d)},e.validSchemaType=function(t,e,r=!1){return!e.length||e.some(e=>"array"===e?Array.isArray(t):"object"===e?t&&"object"==typeof t&&!Array.isArray(t):typeof t==e||r&&void 0===t)},e.validateKeywordUsage=function({schema:t,opts:e,self:r,errSchemaPath:n},i,o){if(Array.isArray(i.keyword)?!i.keyword.includes(o):i.keyword!==o)throw new Error("ajv implementation error");const s=i.dependencies;if(null==s?void 0:s.some(e=>!Object.prototype.hasOwnProperty.call(t,e)))throw new Error(`parent schema must have dependencies of ${o}: ${s.join(",")}`);if(i.validateSchema){if(!i.validateSchema(t[o])){const t=`keyword "${o}" value is invalid at path "${n}": `+r.errorsText(i.validateSchema.errors);if("log"!==e.validateSchema)throw new Error(t);r.logger.error(t)}}}})),Nu=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0,e.getSubschema=function(t,{keyword:e,schemaProp:r,schema:n,schemaPath:i,errSchemaPath:o,topSchemaRef:s}){if(void 0!==e&&void 0!==n)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==e){const n=t.schema[e];return void 0===r?{schema:n,schemaPath:du._`${t.schemaPath}${du.getProperty(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:n[r],schemaPath:du._`${t.schemaPath}${du.getProperty(e)}${du.getProperty(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${mu.escapeFragment(r)}`}}if(void 0!==n){if(void 0===i||void 0===o||void 0===s)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:i,topSchemaRef:s,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')},e.extendSubschemaData=function(t,e,{dataProp:r,dataPropType:n,data:i,dataTypes:o,propertyName:s}){if(void 0!==i&&void 0!==r)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:a}=e;if(void 0!==r){const{errorPath:i,dataPathArr:o,opts:s}=e;h(a.let("data",du._`${e.data}${du.getProperty(r)}`,!0)),t.errorPath=du.str`${i}${mu.getErrorPath(r,n,s.jsPropertySyntax)}`,t.parentDataProperty=du._`${r}`,t.dataPathArr=[...o,t.parentDataProperty]}if(void 0!==i){h(i instanceof du.Name?i:a.let("data",i,!0)),void 0!==s&&(t.propertyName=s)}function h(r){t.data=r,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,r]}o&&(t.dataTypes=o)},e.extendSubschemaMode=function(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:i,allErrors:o}){void 0!==n&&(t.compositeRule=n),void 0!==i&&(t.createErrors=i),void 0!==o&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}})),Su=function t(e,r){if(e===r)return!0;if(e&&r&&"object"==typeof e&&"object"==typeof r){if(e.constructor!==r.constructor)return!1;var n,i,o;if(Array.isArray(e)){if((n=e.length)!=r.length)return!1;for(i=n;0!=i--;)if(!t(e[i],r[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if((n=(o=Object.keys(e)).length)!==Object.keys(r).length)return!1;for(i=n;0!=i--;)if(!Object.prototype.hasOwnProperty.call(r,o[i]))return!1;for(i=n;0!=i--;){var s=o[i];if(!t(e[s],r[s]))return!1}return!0}return e!=e&&r!=r},Ru=h((function(t){var e=t.exports=function(t,n,i){"function"==typeof n&&(i=n,n={}),function t(n,i,o,s,a,h,u,l,f,c){if(s&&"object"==typeof s&&!Array.isArray(s)){for(var d in i(s,a,h,u,l,f,c),s){var m=s[d];if(Array.isArray(m)){if(d in e.arrayKeywords)for(var p=0;p<m.length;p++)t(n,i,o,m[p],a+"/"+d+"/"+p,h,a,d,s,p)}else if(d in e.propsKeywords){if(m&&"object"==typeof m)for(var g in m)t(n,i,o,m[g],a+"/"+d+"/"+r(g),h,a,d,s,g)}else(d in e.keywords||n.allKeys&&!(d in e.skipKeywords))&&t(n,i,o,m,a+"/"+d,h,a,d,s)}o(s,a,h,u,l,f,c)}}(n,"function"==typeof(i=n.cb||i)?i:i.pre||function(){},i.post||function(){},t,"",t)};function r(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}e.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},e.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},e.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},e.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0}})),Uu=h((function(t,e){!function(t){function e(){for(var t=arguments.length,e=Array(t),r=0;r<t;r++)e[r]=arguments[r];if(e.length>1){e[0]=e[0].slice(0,-1);for(var n=e.length-1,i=1;i<n;++i)e[i]=e[i].slice(1,-1);return e[n]=e[n].slice(1),e.join("")}return e[0]}function r(t){return"(?:"+t+")"}function n(t){return void 0===t?"undefined":null===t?"null":Object.prototype.toString.call(t).split(" ").pop().split("]").shift().toLowerCase()}function i(t){return t.toUpperCase()}function o(t){return null!=t?t instanceof Array?t:"number"!=typeof t.length||t.split||t.setInterval||t.call?[t]:Array.prototype.slice.call(t):[]}function s(t,e){var r=t;if(e)for(var n in e)r[n]=e[n];return r}function a(t){var n="[A-Za-z]",i="[0-9]",o=e(i,"[A-Fa-f]"),s=r(r("%[EFef]"+o+"%"+o+o+"%"+o+o)+"|"+r("%[89A-Fa-f]"+o+"%"+o+o)+"|"+r("%"+o+o)),a="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",h=e("[\\:\\/\\?\\#\\[\\]\\@]",a),u=t?"[\\uE000-\\uF8FF]":"[]",l=e(n,i,"[\\-\\.\\_\\~]",t?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]"),f=(r(n+e(n,i,"[\\+\\-\\.]")+"*"),r(r(s+"|"+e(l,a,"[\\:]"))+"*"),r(r("25[0-5]")+"|"+r("2[0-4]"+i)+"|"+r("1"+i+i)+"|"+r("0?[1-9]"+i)+"|0?0?"+i)),c=r(f+"\\."+f+"\\."+f+"\\."+f),d=r(o+"{1,4}"),m=r(r(d+"\\:"+d)+"|"+c),p=r(r(d+"\\:")+"{6}"+m),g=r("\\:\\:"+r(d+"\\:")+"{5}"+m),y=r(r(d)+"?\\:\\:"+r(d+"\\:")+"{4}"+m),v=r(r(r(d+"\\:")+"{0,1}"+d)+"?\\:\\:"+r(d+"\\:")+"{3}"+m),w=r(r(r(d+"\\:")+"{0,2}"+d)+"?\\:\\:"+r(d+"\\:")+"{2}"+m),b=r(r(r(d+"\\:")+"{0,3}"+d)+"?\\:\\:"+d+"\\:"+m),E=r(r(r(d+"\\:")+"{0,4}"+d)+"?\\:\\:"+m),M=r(r(r(d+"\\:")+"{0,5}"+d)+"?\\:\\:"+d),_=r(r(r(d+"\\:")+"{0,6}"+d)+"?\\:\\:"),A=r([p,g,y,v,w,b,E,M,_].join("|")),N=r(r(l+"|"+s)+"+"),S=(r("[vV]"+o+"+\\."+e(l,a,"[\\:]")+"+"),r(r(s+"|"+e(l,a))+"*"),r(s+"|"+e(l,a,"[\\:\\@]")));return r(r(s+"|"+e(l,a,"[\\@]"))+"+"),r(r(S+"|"+e("[\\/\\?]",u))+"*"),{NOT_SCHEME:new RegExp(e("[^]",n,i,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(e("[^\\%\\:]",l,a),"g"),NOT_HOST:new RegExp(e("[^\\%\\[\\]\\:]",l,a),"g"),NOT_PATH:new RegExp(e("[^\\%\\/\\:\\@]",l,a),"g"),NOT_PATH_NOSCHEME:new RegExp(e("[^\\%\\/\\@]",l,a),"g"),NOT_QUERY:new RegExp(e("[^\\%]",l,a,"[\\:\\@\\/\\?]",u),"g"),NOT_FRAGMENT:new RegExp(e("[^\\%]",l,a,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(e("[^]",l,a),"g"),UNRESERVED:new RegExp(l,"g"),OTHER_CHARS:new RegExp(e("[^\\%]",l,h),"g"),PCT_ENCODED:new RegExp(s,"g"),IPV4ADDRESS:new RegExp("^("+c+")$"),IPV6ADDRESS:new RegExp("^\\[?("+A+")"+r(r("\\%25|\\%(?!"+o+"{2})")+"("+N+")")+"?\\]?$")}}var h=a(!1),u=a(!0),l=function(){function t(t,e){var r=[],n=!0,i=!1,o=void 0;try{for(var s,a=t[Symbol.iterator]();!(n=(s=a.next()).done)&&(r.push(s.value),!e||r.length!==e);n=!0);}catch(t){i=!0,o=t}finally{try{!n&&a.return&&a.return()}finally{if(i)throw o}}return r}return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),f=function(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)},c=2147483647,d=36,m=1,p=26,g=38,y=700,v=72,w=128,b="-",E=/^xn--/,M=/[^\0-\x7E]/,_=/[\x2E\u3002\uFF0E\uFF61]/g,A={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},N=d-m,S=Math.floor,R=String.fromCharCode;function U(t){throw new RangeError(A[t])}function I(t,e){for(var r=[],n=t.length;n--;)r[n]=e(t[n]);return r}function P(t,e){var r=t.split("@"),n="";return r.length>1&&(n=r[0]+"@",t=r[1]),n+I((t=t.replace(_,".")).split("."),e).join(".")}function x(t){for(var e=[],r=0,n=t.length;r<n;){var i=t.charCodeAt(r++);if(i>=55296&&i<=56319&&r<n){var o=t.charCodeAt(r++);56320==(64512&o)?e.push(((1023&i)<<10)+(1023&o)+65536):(e.push(i),r--)}else e.push(i)}return e}var k=function(t){return t-48<10?t-22:t-65<26?t-65:t-97<26?t-97:d},T=function(t,e){return t+22+75*(t<26)-((0!=e)<<5)},O=function(t,e,r){var n=0;for(t=r?S(t/y):t>>1,t+=S(t/e);t>N*p>>1;n+=d)t=S(t/N);return S(n+(N+1)*t/(t+g))},C=function(t){var e=[],r=t.length,n=0,i=w,o=v,s=t.lastIndexOf(b);s<0&&(s=0);for(var a=0;a<s;++a)t.charCodeAt(a)>=128&&U("not-basic"),e.push(t.charCodeAt(a));for(var h=s>0?s+1:0;h<r;){for(var u=n,l=1,f=d;;f+=d){h>=r&&U("invalid-input");var g=k(t.charCodeAt(h++));(g>=d||g>S((c-n)/l))&&U("overflow"),n+=g*l;var y=f<=o?m:f>=o+p?p:f-o;if(g<y)break;var E=d-y;l>S(c/E)&&U("overflow"),l*=E}var M=e.length+1;o=O(n-u,M,0==u),S(n/M)>c-i&&U("overflow"),i+=S(n/M),n%=M,e.splice(n++,0,i)}return String.fromCodePoint.apply(String,e)},F=function(t){var e=[],r=(t=x(t)).length,n=w,i=0,o=v,s=!0,a=!1,h=void 0;try{for(var u,l=t[Symbol.iterator]();!(s=(u=l.next()).done);s=!0){var f=u.value;f<128&&e.push(R(f))}}catch(t){a=!0,h=t}finally{try{!s&&l.return&&l.return()}finally{if(a)throw h}}var g=e.length,y=g;for(g&&e.push(b);y<r;){var E=c,M=!0,_=!1,A=void 0;try{for(var N,I=t[Symbol.iterator]();!(M=(N=I.next()).done);M=!0){var P=N.value;P>=n&&P<E&&(E=P)}}catch(t){_=!0,A=t}finally{try{!M&&I.return&&I.return()}finally{if(_)throw A}}var k=y+1;E-n>S((c-i)/k)&&U("overflow"),i+=(E-n)*k,n=E;var C=!0,F=!1,D=void 0;try{for(var L,$=t[Symbol.iterator]();!(C=(L=$.next()).done);C=!0){var B=L.value;if(B<n&&++i>c&&U("overflow"),B==n){for(var j=i,z=d;;z+=d){var G=z<=o?m:z>=o+p?p:z-o;if(j<G)break;var q=j-G,V=d-G;e.push(R(T(G+q%V,0))),j=S(q/V)}e.push(R(T(j,0))),o=O(i,k,y==g),i=0,++y}}}catch(t){F=!0,D=t}finally{try{!C&&$.return&&$.return()}finally{if(F)throw D}}++i,++n}return e.join("")},D=function(t){return P(t,(function(t){return E.test(t)?C(t.slice(4).toLowerCase()):t}))},L=function(t){return P(t,(function(t){return M.test(t)?"xn--"+F(t):t}))},$={version:"2.1.0",ucs2:{decode:x,encode:function(t){return String.fromCodePoint.apply(String,f(t))}},decode:C,encode:F,toASCII:L,toUnicode:D},B={};function j(t){var e=t.charCodeAt(0);return e<16?"%0"+e.toString(16).toUpperCase():e<128?"%"+e.toString(16).toUpperCase():e<2048?"%"+(e>>6|192).toString(16).toUpperCase()+"%"+(63&e|128).toString(16).toUpperCase():"%"+(e>>12|224).toString(16).toUpperCase()+"%"+(e>>6&63|128).toString(16).toUpperCase()+"%"+(63&e|128).toString(16).toUpperCase()}function z(t){for(var e="",r=0,n=t.length;r<n;){var i=parseInt(t.substr(r+1,2),16);if(i<128)e+=String.fromCharCode(i),r+=3;else if(i>=194&&i<224){if(n-r>=6){var o=parseInt(t.substr(r+4,2),16);e+=String.fromCharCode((31&i)<<6|63&o)}else e+=t.substr(r,6);r+=6}else if(i>=224){if(n-r>=9){var s=parseInt(t.substr(r+4,2),16),a=parseInt(t.substr(r+7,2),16);e+=String.fromCharCode((15&i)<<12|(63&s)<<6|63&a)}else e+=t.substr(r,9);r+=9}else e+=t.substr(r,3),r+=3}return e}function G(t,e){function r(t){var r=z(t);return r.match(e.UNRESERVED)?r:t}return t.scheme&&(t.scheme=String(t.scheme).replace(e.PCT_ENCODED,r).toLowerCase().replace(e.NOT_SCHEME,"")),void 0!==t.userinfo&&(t.userinfo=String(t.userinfo).replace(e.PCT_ENCODED,r).replace(e.NOT_USERINFO,j).replace(e.PCT_ENCODED,i)),void 0!==t.host&&(t.host=String(t.host).replace(e.PCT_ENCODED,r).toLowerCase().replace(e.NOT_HOST,j).replace(e.PCT_ENCODED,i)),void 0!==t.path&&(t.path=String(t.path).replace(e.PCT_ENCODED,r).replace(t.scheme?e.NOT_PATH:e.NOT_PATH_NOSCHEME,j).replace(e.PCT_ENCODED,i)),void 0!==t.query&&(t.query=String(t.query).replace(e.PCT_ENCODED,r).replace(e.NOT_QUERY,j).replace(e.PCT_ENCODED,i)),void 0!==t.fragment&&(t.fragment=String(t.fragment).replace(e.PCT_ENCODED,r).replace(e.NOT_FRAGMENT,j).replace(e.PCT_ENCODED,i)),t}function q(t){return t.replace(/^0*(.*)/,"$1")||"0"}function V(t,e){var r=t.match(e.IPV4ADDRESS)||[],n=l(r,2)[1];return n?n.split(".").map(q).join("."):t}function K(t,e){var r=t.match(e.IPV6ADDRESS)||[],n=l(r,3),i=n[1],o=n[2];if(i){for(var s=i.toLowerCase().split("::").reverse(),a=l(s,2),h=a[0],u=a[1],f=u?u.split(":").map(q):[],c=h.split(":").map(q),d=e.IPV4ADDRESS.test(c[c.length-1]),m=d?7:8,p=c.length-m,g=Array(m),y=0;y<m;++y)g[y]=f[y]||c[p+y]||"";d&&(g[m-1]=V(g[m-1],e));var v=g.reduce((function(t,e,r){if(!e||"0"===e){var n=t[t.length-1];n&&n.index+n.length===r?n.length++:t.push({index:r,length:1})}return t}),[]).sort((function(t,e){return e.length-t.length}))[0],w=void 0;if(v&&v.length>1){var b=g.slice(0,v.index),E=g.slice(v.index+v.length);w=b.join(":")+"::"+E.join(":")}else w=g.join(":");return o&&(w+="%"+o),w}return t}var W=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,H=void 0==="".match(/(){0}/)[1];function Z(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={},n=!1!==e.iri?u:h;"suffix"===e.reference&&(t=(e.scheme?e.scheme+":":"")+"//"+t);var i=t.match(W);if(i){H?(r.scheme=i[1],r.userinfo=i[3],r.host=i[4],r.port=parseInt(i[5],10),r.path=i[6]||"",r.query=i[7],r.fragment=i[8],isNaN(r.port)&&(r.port=i[5])):(r.scheme=i[1]||void 0,r.userinfo=-1!==t.indexOf("@")?i[3]:void 0,r.host=-1!==t.indexOf("//")?i[4]:void 0,r.port=parseInt(i[5],10),r.path=i[6]||"",r.query=-1!==t.indexOf("?")?i[7]:void 0,r.fragment=-1!==t.indexOf("#")?i[8]:void 0,isNaN(r.port)&&(r.port=t.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?i[4]:void 0)),r.host&&(r.host=K(V(r.host,n),n)),void 0!==r.scheme||void 0!==r.userinfo||void 0!==r.host||void 0!==r.port||r.path||void 0!==r.query?void 0===r.scheme?r.reference="relative":void 0===r.fragment?r.reference="absolute":r.reference="uri":r.reference="same-document",e.reference&&"suffix"!==e.reference&&e.reference!==r.reference&&(r.error=r.error||"URI is not a "+e.reference+" reference.");var o=B[(e.scheme||r.scheme||"").toLowerCase()];if(e.unicodeSupport||o&&o.unicodeSupport)G(r,n);else{if(r.host&&(e.domainHost||o&&o.domainHost))try{r.host=$.toASCII(r.host.replace(n.PCT_ENCODED,z).toLowerCase())}catch(t){r.error=r.error||"Host's domain name can not be converted to ASCII via punycode: "+t}G(r,h)}o&&o.parse&&o.parse(r,e)}else r.error=r.error||"URI can not be parsed.";return r}function X(t,e){var r=!1!==e.iri?u:h,n=[];return void 0!==t.userinfo&&(n.push(t.userinfo),n.push("@")),void 0!==t.host&&n.push(K(V(String(t.host),r),r).replace(r.IPV6ADDRESS,(function(t,e,r){return"["+e+(r?"%25"+r:"")+"]"}))),"number"!=typeof t.port&&"string"!=typeof t.port||(n.push(":"),n.push(String(t.port))),n.length?n.join(""):void 0}var J=/^\.\.?\//,Y=/^\/\.(\/|$)/,Q=/^\/\.\.(\/|$)/,tt=/^\/?(?:.|\n)*?(?=\/|$)/;function et(t){for(var e=[];t.length;)if(t.match(J))t=t.replace(J,"");else if(t.match(Y))t=t.replace(Y,"/");else if(t.match(Q))t=t.replace(Q,"/"),e.pop();else if("."===t||".."===t)t="";else{var r=t.match(tt);if(!r)throw new Error("Unexpected dot segment condition");var n=r[0];t=t.slice(n.length),e.push(n)}return e.join("")}function rt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.iri?u:h,n=[],i=B[(e.scheme||t.scheme||"").toLowerCase()];if(i&&i.serialize&&i.serialize(t,e),t.host)if(r.IPV6ADDRESS.test(t.host));else if(e.domainHost||i&&i.domainHost)try{t.host=e.iri?$.toUnicode(t.host):$.toASCII(t.host.replace(r.PCT_ENCODED,z).toLowerCase())}catch(r){t.error=t.error||"Host's domain name can not be converted to "+(e.iri?"Unicode":"ASCII")+" via punycode: "+r}G(t,r),"suffix"!==e.reference&&t.scheme&&(n.push(t.scheme),n.push(":"));var o=X(t,e);if(void 0!==o&&("suffix"!==e.reference&&n.push("//"),n.push(o),t.path&&"/"!==t.path.charAt(0)&&n.push("/")),void 0!==t.path){var s=t.path;e.absolutePath||i&&i.absolutePath||(s=et(s)),void 0===o&&(s=s.replace(/^\/\//,"/%2F")),n.push(s)}return void 0!==t.query&&(n.push("?"),n.push(t.query)),void 0!==t.fragment&&(n.push("#"),n.push(t.fragment)),n.join("")}function nt(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n={};return arguments[3]||(t=Z(rt(t,r),r),e=Z(rt(e,r),r)),!(r=r||{}).tolerant&&e.scheme?(n.scheme=e.scheme,n.userinfo=e.userinfo,n.host=e.host,n.port=e.port,n.path=et(e.path||""),n.query=e.query):(void 0!==e.userinfo||void 0!==e.host||void 0!==e.port?(n.userinfo=e.userinfo,n.host=e.host,n.port=e.port,n.path=et(e.path||""),n.query=e.query):(e.path?("/"===e.path.charAt(0)?n.path=et(e.path):(void 0===t.userinfo&&void 0===t.host&&void 0===t.port||t.path?t.path?n.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:n.path=e.path:n.path="/"+e.path,n.path=et(n.path)),n.query=e.query):(n.path=t.path,void 0!==e.query?n.query=e.query:n.query=t.query),n.userinfo=t.userinfo,n.host=t.host,n.port=t.port),n.scheme=t.scheme),n.fragment=e.fragment,n}function it(t,e,r){var n=s({scheme:"null"},r);return rt(nt(Z(t,n),Z(e,n),n,!0),n)}function ot(t,e){return"string"==typeof t?t=rt(Z(t,e),e):"object"===n(t)&&(t=Z(rt(t,e),e)),t}function st(t,e,r){return"string"==typeof t?t=rt(Z(t,r),r):"object"===n(t)&&(t=rt(t,r)),"string"==typeof e?e=rt(Z(e,r),r):"object"===n(e)&&(e=rt(e,r)),t===e}function at(t,e){return t&&t.toString().replace(e&&e.iri?u.ESCAPE:h.ESCAPE,j)}function ht(t,e){return t&&t.toString().replace(e&&e.iri?u.PCT_ENCODED:h.PCT_ENCODED,z)}var ut={scheme:"http",domainHost:!0,parse:function(t,e){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t},serialize:function(t,e){var r="https"===String(t.scheme).toLowerCase();return t.port!==(r?443:80)&&""!==t.port||(t.port=void 0),t.path||(t.path="/"),t}},lt={scheme:"https",domainHost:ut.domainHost,parse:ut.parse,serialize:ut.serialize};function ft(t){return"boolean"==typeof t.secure?t.secure:"wss"===String(t.scheme).toLowerCase()}var ct={scheme:"ws",domainHost:!0,parse:function(t,e){var r=t;return r.secure=ft(r),r.resourceName=(r.path||"/")+(r.query?"?"+r.query:""),r.path=void 0,r.query=void 0,r},serialize:function(t,e){if(t.port!==(ft(t)?443:80)&&""!==t.port||(t.port=void 0),"boolean"==typeof t.secure&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){var r=t.resourceName.split("?"),n=l(r,2),i=n[0],o=n[1];t.path=i&&"/"!==i?i:void 0,t.query=o,t.resourceName=void 0}return t.fragment=void 0,t}},dt={scheme:"wss",domainHost:ct.domainHost,parse:ct.parse,serialize:ct.serialize},mt={},pt="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",gt="[0-9A-Fa-f]",yt=r(r("%[EFef]"+gt+"%"+gt+gt+"%"+gt+gt)+"|"+r("%[89A-Fa-f]"+gt+"%"+gt+gt)+"|"+r("%"+gt+gt)),vt="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",wt=e("[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",'[\\"\\\\]'),bt="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",Et=new RegExp(pt,"g"),Mt=new RegExp(yt,"g"),_t=new RegExp(e("[^]",vt,"[\\.]",'[\\"]',wt),"g"),At=new RegExp(e("[^]",pt,bt),"g"),Nt=At;function St(t){var e=z(t);return e.match(Et)?e:t}var Rt={scheme:"mailto",parse:function(t,e){var r=t,n=r.to=r.path?r.path.split(","):[];if(r.path=void 0,r.query){for(var i=!1,o={},s=r.query.split("&"),a=0,h=s.length;a<h;++a){var u=s[a].split("=");switch(u[0]){case"to":for(var l=u[1].split(","),f=0,c=l.length;f<c;++f)n.push(l[f]);break;case"subject":r.subject=ht(u[1],e);break;case"body":r.body=ht(u[1],e);break;default:i=!0,o[ht(u[0],e)]=ht(u[1],e)}}i&&(r.headers=o)}r.query=void 0;for(var d=0,m=n.length;d<m;++d){var p=n[d].split("@");if(p[0]=ht(p[0]),e.unicodeSupport)p[1]=ht(p[1],e).toLowerCase();else try{p[1]=$.toASCII(ht(p[1],e).toLowerCase())}catch(t){r.error=r.error||"Email address's domain name can not be converted to ASCII via punycode: "+t}n[d]=p.join("@")}return r},serialize:function(t,e){var r=t,n=o(t.to);if(n){for(var s=0,a=n.length;s<a;++s){var h=String(n[s]),u=h.lastIndexOf("@"),l=h.slice(0,u).replace(Mt,St).replace(Mt,i).replace(_t,j),f=h.slice(u+1);try{f=e.iri?$.toUnicode(f):$.toASCII(ht(f,e).toLowerCase())}catch(t){r.error=r.error||"Email address's domain name can not be converted to "+(e.iri?"Unicode":"ASCII")+" via punycode: "+t}n[s]=l+"@"+f}r.path=n.join(",")}var c=t.headers=t.headers||{};t.subject&&(c.subject=t.subject),t.body&&(c.body=t.body);var d=[];for(var m in c)c[m]!==mt[m]&&d.push(m.replace(Mt,St).replace(Mt,i).replace(At,j)+"="+c[m].replace(Mt,St).replace(Mt,i).replace(Nt,j));return d.length&&(r.query=d.join("&")),r}},Ut=/^([^\:]+)\:(.*)/,It={scheme:"urn",parse:function(t,e){var r=t.path&&t.path.match(Ut),n=t;if(r){var i=e.scheme||n.scheme||"urn",o=r[1].toLowerCase(),s=r[2],a=i+":"+(e.nid||o),h=B[a];n.nid=o,n.nss=s,n.path=void 0,h&&(n=h.parse(n,e))}else n.error=n.error||"URN can not be parsed.";return n},serialize:function(t,e){var r=e.scheme||t.scheme||"urn",n=t.nid,i=r+":"+(e.nid||n),o=B[i];o&&(t=o.serialize(t,e));var s=t,a=t.nss;return s.path=(n||e.nid)+":"+a,s}},Pt=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,xt={scheme:"urn:uuid",parse:function(t,e){var r=t;return r.uuid=r.nss,r.nss=void 0,e.tolerant||r.uuid&&r.uuid.match(Pt)||(r.error=r.error||"UUID is not valid."),r},serialize:function(t,e){var r=t;return r.nss=(t.uuid||"").toLowerCase(),r}};B[ut.scheme]=ut,B[lt.scheme]=lt,B[ct.scheme]=ct,B[dt.scheme]=dt,B[Rt.scheme]=Rt,B[It.scheme]=It,B[xt.scheme]=xt,t.SCHEMES=B,t.pctEncChar=j,t.pctDecChars=z,t.parse=Z,t.removeDotSegments=et,t.serialize=rt,t.resolveComponents=nt,t.resolve=it,t.normalize=ot,t.equal=st,t.escapeComponent=at,t.unescapeComponent=ht,Object.defineProperty(t,"__esModule",{value:!0})}(e)})),Iu=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;const r=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);e.inlineRef=function(t,e=!0){return"boolean"==typeof t||(!0===e?!i(t):!!e&&function t(e){let n=0;for(const i in e){if("$ref"===i)return 1/0;if(n++,!r.has(i)&&("object"==typeof e[i]&&mu.eachItem(e[i],e=>n+=t(e)),n===1/0))return 1/0}return n}(t)<=e)};const n=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function i(t){for(const e in t){if(n.has(e))return!0;const r=t[e];if(Array.isArray(r)&&r.some(i))return!0;if("object"==typeof r&&i(r))return!0}return!1}function o(t="",e){!1!==e&&(t=h(t));return s(Uu.parse(t))}function s(t){return Uu.serialize(t).split("#")[0]+"#"}e.getFullPath=o,e._getFullPath=s;const a=/#\/?$/;function h(t){return t?t.replace(a,""):""}e.normalizeId=h,e.resolveUrl=function(t,e){return e=h(e),Uu.resolve(t,e)};const u=/^[a-z_][-a-z0-9._]*$/i;e.getSchemaRefs=function(t){if("boolean"==typeof t)return{};const{schemaId:e}=this.opts,r=h(t[e]),n={"":r},i=o(r,!1),s={},a=new Set;return Ru(t,{allKeys:!0},(t,r,o,c)=>{if(void 0===c)return;const d=i+r;let m=n[c];function p(e){if(e=h(m?Uu.resolve(m,e):e),a.has(e))throw f(e);a.add(e);let r=this.refs[e];return"string"==typeof r&&(r=this.refs[r]),"object"==typeof r?l(t,r.schema,e):e!==h(d)&&("#"===e[0]?(l(t,s[e],e),s[e]=t):this.refs[e]=d),e}function g(t){if("string"==typeof t){if(!u.test(t))throw new Error(`invalid anchor "${t}"`);p.call(this,"#"+t)}}"string"==typeof t[e]&&(m=p.call(this,t[e])),g.call(this,t.$anchor),g.call(this,t.$dynamicAnchor),n[r]=m}),s;function l(t,e,r){if(void 0!==e&&!Su(t,e))throw f(r)}function f(t){return new Error(`reference "${t}" resolves to more than one schema`)}}})),Pu=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;const r=Eu;function n({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,du._`${gu.default.data}, ${gu.default.valCxt}`,n.$async,()=>{t.code(du._`"use strict"; ${i(r,o)}`),function(t,e){t.if(gu.default.valCxt,()=>{t.var(gu.default.instancePath,du._`${gu.default.valCxt}.${gu.default.instancePath}`),t.var(gu.default.parentData,du._`${gu.default.valCxt}.${gu.default.parentData}`),t.var(gu.default.parentDataProperty,du._`${gu.default.valCxt}.${gu.default.parentDataProperty}`),t.var(gu.default.rootData,du._`${gu.default.valCxt}.${gu.default.rootData}`),e.dynamicRef&&t.var(gu.default.dynamicAnchors,du._`${gu.default.valCxt}.${gu.default.dynamicAnchors}`)},()=>{t.var(gu.default.instancePath,du._`""`),t.var(gu.default.parentData,du._`undefined`),t.var(gu.default.parentDataProperty,du._`undefined`),t.var(gu.default.rootData,gu.default.data),e.dynamicRef&&t.var(gu.default.dynamicAnchors,du._`{}`)})}(t,o),t.code(s)}):t.func(e,du._`${gu.default.data}, ${function(t){return du._`{${gu.default.instancePath}="", ${gu.default.parentData}, ${gu.default.parentDataProperty}, ${gu.default.rootData}=${gu.default.data}${t.dynamicRef?du._`, ${gu.default.dynamicAnchors}={}`:du.nil}}={}`}(o)}`,n.$async,()=>t.code(i(r,o)).code(s))}function i(t,e){const r="object"==typeof t&&t[e.schemaId];return r&&(e.code.source||e.code.process)?du._`/*# sourceURL=${r} */`:du.nil}function o(t,e){a(t)&&(h(t),s(t))?function(t,e){const{schema:r,gen:n,opts:i}=t;i.$comment&&r.$comment&&l(t);(function(t){const e=t.schema[t.opts.schemaId];e&&(t.baseId=Iu.resolveUrl(t.baseId,e))})(t),function(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}(t);const o=n.const("_errs",gu.default.errors);u(t,o),n.var(e,du._`${o} === ${gu.default.errors}`)}(t,e):vu.boolOrEmptySchema(t,e)}function s({schema:t,self:e}){if("boolean"==typeof t)return!t;for(const r in t)if(e.RULES.all[r])return!0;return!1}function a(t){return"boolean"!=typeof t.schema}function h(t){mu.checkUnknownRules(t),function(t){const{schema:e,errSchemaPath:r,opts:n,self:i}=t;e.$ref&&n.ignoreKeywordsWithRef&&mu.schemaHasRulesButRef(e,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}(t)}function u(t,e){if(t.opts.jtd)return f(t,[],!1,e);const r=Eu.getSchemaTypes(t.schema);f(t,r,!Eu.coerceAndCheckDataType(t,r),e)}function l({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:i}){const o=r.$comment;if(!0===i.$comment)t.code(du._`${gu.default.self}.logger.log(${o})`);else if("function"==typeof i.$comment){const r=du.str`${n}/$comment`,i=t.scopeValue("root",{ref:e.root});t.code(du._`${gu.default.self}.opts.$comment(${o}, ${r}, ${i}.schema)`)}}function f(t,e,n,i){const{gen:o,schema:s,data:a,allErrors:h,opts:u,self:l}=t,{RULES:f}=l;function g(l){bu.shouldUseGroup(s,l)&&(l.type?(o.if(r.checkDataType(l.type,a,u.strictNumbers)),c(t,l),1===e.length&&e[0]===l.type&&n&&(o.else(),r.reportTypeError(t)),o.endIf()):c(t,l),h||o.if(du._`${gu.default.errors} === ${i||0}`))}!s.$ref||!u.ignoreKeywordsWithRef&&mu.schemaHasRulesButRef(s,f)?(u.jtd||function(t,e){if(t.schemaEnv.meta||!t.opts.strictTypes)return;(function(t,e){if(!e.length)return;if(!t.dataTypes.length)return void(t.dataTypes=e);e.forEach(e=>{m(t.dataTypes,e)||p(t,`type "${e}" not allowed by context "${t.dataTypes.join(",")}"`)}),t.dataTypes=t.dataTypes.filter(t=>m(e,t))})(t,e),t.opts.allowUnionTypes||function(t,e){e.length>1&&(2!==e.length||!e.includes("null"))&&p(t,"use allowUnionTypes to allow union type keyword")}(t,e);!function(t,e){const r=t.self.RULES.all;for(const n in r){const i=r[n];if("object"==typeof i&&bu.shouldUseRule(t.schema,i)){const{type:r}=i.definition;r.length&&!r.some(t=>d(e,t))&&p(t,`missing type "${r.join(",")}" for keyword "${n}"`)}}}(t,t.dataTypes)}(t,e),o.block(()=>{for(const t of f.rules)g(t);g(f.post)})):o.block(()=>y(t,"$ref",f.all.$ref.definition))}function c(t,e){const{gen:r,schema:n,opts:{useDefaults:i}}=t;i&&Mu.assignDefaults(t,e.type),r.block(()=>{for(const r of e.rules)bu.shouldUseRule(n,r)&&y(t,r.keyword,r.definition,e.type)})}function d(t,e){return t.includes(e)||"number"===e&&t.includes("integer")}function m(t,e){return t.includes(e)||"integer"===e&&t.includes("number")}function p(t,e){e+=` at "${t.schemaEnv.baseId+t.errSchemaPath}" (strictTypes)`,mu.checkStrictMode(t,e,t.opts.strictTypes)}e.validateFunctionCode=function(t){a(t)&&(h(t),s(t))?function(t){const{schema:e,opts:r,gen:i}=t;n(t,()=>{r.$comment&&e.$comment&&l(t),function(t){const{schema:e,opts:r}=t;void 0!==e.default&&r.useDefaults&&r.strictSchema&&mu.checkStrictMode(t,"default is ignored in the schema root")}(t),i.let(gu.default.vErrors,null),i.let(gu.default.errors,0),r.unevaluated&&function(t){const{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",du._`${r}.evaluated`),e.if(du._`${t.evaluated}.dynamicProps`,()=>e.assign(du._`${t.evaluated}.props`,du._`undefined`)),e.if(du._`${t.evaluated}.dynamicItems`,()=>e.assign(du._`${t.evaluated}.items`,du._`undefined`))}(t),u(t),function(t){const{gen:e,schemaEnv:r,validateName:n,ValidationError:i,opts:o}=t;r.$async?e.if(du._`${gu.default.errors} === 0`,()=>e.return(gu.default.data),()=>e.throw(du._`new ${i}(${gu.default.vErrors})`)):(e.assign(du._`${n}.errors`,gu.default.vErrors),o.unevaluated&&function({gen:t,evaluated:e,props:r,items:n}){r instanceof du.Name&&t.assign(du._`${e}.props`,r);n instanceof du.Name&&t.assign(du._`${e}.items`,n)}(t),e.return(du._`${gu.default.errors} === 0`))}(t)})}(t):n(t,()=>vu.topBoolOrEmptySchema(t))};class g{constructor(t,e,r){if(Au.validateKeywordUsage(t,e,r),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=r,this.data=t.data,this.schema=t.schema[r],this.$data=e.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=mu.schemaRefOrVal(t,this.schema,r,this.$data),this.schemaType=e.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=e,this.$data)this.schemaCode=t.gen.const("vSchema",b(this.$data,t));else if(this.schemaCode=this.schemaValue,!Au.validSchemaType(this.schema,e.schemaType,e.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(e.schemaType)}`);("code"in e?e.trackErrors:!1!==e.errors)&&(this.errsCount=t.gen.const("_errs",gu.default.errors))}result(t,e,r){this.gen.if(du.not(t)),r?r():this.error(),e?(this.gen.else(),e(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,e){this.result(t,void 0,e)}fail(t){if(void 0===t)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:e}=this;this.fail(du._`${e} !== undefined && (${du.or(this.invalid$data(),t)})`)}error(t,e,r){if(e)return this.setParams(e),this._error(t,r),void this.setParams({});this._error(t,r)}_error(t,e){(t?yu.reportExtraError:yu.reportError)(this,this.def.error,e)}$dataError(){yu.reportError(this,this.def.$dataError||yu.keyword$DataError)}reset(){if(void 0===this.errsCount)throw new Error('add "trackErrors" to keyword definition');yu.resetErrorsCount(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,e){e?Object.assign(this.params,t):this.params=t}block$data(t,e,r=du.nil){this.gen.block(()=>{this.check$data(t,r),e()})}check$data(t=du.nil,e=du.nil){if(!this.$data)return;const{gen:r,schemaCode:n,schemaType:i,def:o}=this;r.if(du.or(du._`${n} === undefined`,e)),t!==du.nil&&r.assign(t,!0),(i.length||o.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),t!==du.nil&&r.assign(t,!1)),r.else()}invalid$data(){const{gen:t,schemaCode:e,schemaType:n,def:i,it:o}=this;return du.or(function(){if(n.length){if(!(e instanceof du.Name))throw new Error("ajv implementation error");const t=Array.isArray(n)?n:[n];return du._`${r.checkDataTypes(t,e,o.opts.strictNumbers,r.DataType.Wrong)}`}return du.nil}(),function(){if(i.validateSchema){const r=t.scopeValue("validate$data",{ref:i.validateSchema});return du._`!${r}(${e})`}return du.nil}())}subschema(t,e){const r=Nu.getSubschema(this.it,t);Nu.extendSubschemaData(r,this.it,t),Nu.extendSubschemaMode(r,t);const n={...this.it,...r,items:void 0,props:void 0};return o(n,e),n}mergeEvaluated(t,e){const{it:r,gen:n}=this;r.opts.unevaluated&&(!0!==r.props&&void 0!==t.props&&(r.props=mu.mergeEvaluated.props(n,t.props,r.props,e)),!0!==r.items&&void 0!==t.items&&(r.items=mu.mergeEvaluated.items(n,t.items,r.items,e)))}mergeValidEvaluated(t,e){const{it:r,gen:n}=this;if(r.opts.unevaluated&&(!0!==r.props||!0!==r.items))return n.if(e,()=>this.mergeEvaluated(t,du.Name)),!0}}function y(t,e,r,n){const i=new g(t,r,e);"code"in r?r.code(i,n):i.$data&&r.validate?Au.funcKeywordCode(i,r):"macro"in r?Au.macroKeywordCode(i,r):(r.compile||r.validate)&&Au.funcKeywordCode(i,r)}e.KeywordCxt=g;const v=/^\/(?:[^~]|~0|~1)*$/,w=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function b(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let i,o;if(""===t)return gu.default.rootData;if("/"===t[0]){if(!v.test(t))throw new Error("Invalid JSON-pointer: "+t);i=t,o=gu.default.rootData}else{const s=w.exec(t);if(!s)throw new Error("Invalid JSON-pointer: "+t);const a=+s[1];if(i=s[2],"#"===i){if(a>=e)throw new Error(h("property/index",a));return n[e-a]}if(a>e)throw new Error(h("data",a));if(o=r[e-a],!i)return o}let s=o;const a=i.split("/");for(const t of a)t&&(o=du._`${o}${du.getProperty(mu.unescapeJsonPointer(t))}`,s=du._`${s} && ${o}`);return s;function h(t,r){return`Cannot access ${t} ${r} levels up, current level is ${e}`}}e.getData=b}));class xu extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}}var ku=xu,Tu=Object.defineProperty({default:ku},"__esModule",{value:!0});class Ou extends Error{constructor(t,e,r){super(r||`can't resolve reference ${e} from id ${t}`),this.missingRef=Iu.resolveUrl(t,e),this.missingSchema=Iu.normalizeId(Iu.getFullPath(this.missingRef))}}var Cu=Ou,Fu=Object.defineProperty({default:Cu},"__esModule",{value:!0}),Du=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;class r{constructor(t){var e;let r;this.refs={},this.dynamicAnchors={},"object"==typeof t.schema&&(r=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=null!==(e=t.baseId)&&void 0!==e?e:Iu.normalizeId(null==r?void 0:r[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=null==r?void 0:r.$async,this.refs={}}}function n(t){const e=o.call(this,t);if(e)return e;const r=Iu.getFullPath(t.root.baseId),{es5:n,lines:i}=this.opts.code,{ownProperties:s}=this.opts,a=new du.CodeGen(this.scope,{es5:n,lines:i,ownProperties:s});let h;t.$async&&(h=a.scopeValue("Error",{ref:Tu.default,code:du._`require("ajv/dist/runtime/validation_error").default`}));const u=a.scopeName("validate");t.validateName=u;const l={gen:a,allErrors:this.opts.allErrors,data:gu.default.data,parentData:gu.default.parentData,parentDataProperty:gu.default.parentDataProperty,dataNames:[gu.default.data],dataPathArr:[du.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",!0===this.opts.code.source?{ref:t.schema,code:du.stringify(t.schema)}:{ref:t.schema}),validateName:u,ValidationError:h,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:du.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:du._`""`,opts:this.opts,self:this};let f;try{this._compilations.add(t),Pu.validateFunctionCode(l),a.optimize(this.opts.code.optimize);const e=a.toString();f=`${a.scopeRefs(gu.default.scope)}return ${e}`,this.opts.code.process&&(f=this.opts.code.process(f,t));const r=new Function(""+gu.default.self,""+gu.default.scope,f)(this,this.scope.get());if(this.scope.value(u,{ref:r}),r.errors=null,r.schema=t.schema,r.schemaEnv=t,t.$async&&(r.$async=!0),!0===this.opts.code.source&&(r.source={validateName:u,validateCode:e,scopeValues:a._values}),this.opts.unevaluated){const{props:t,items:e}=l;r.evaluated={props:t instanceof du.Name?void 0:t,items:e instanceof du.Name?void 0:e,dynamicProps:t instanceof du.Name,dynamicItems:e instanceof du.Name},r.source&&(r.source.evaluated=du.stringify(r.evaluated))}return t.validate=r,t}catch(e){throw delete t.validate,delete t.validateName,f&&this.logger.error("Error compiling schema, function code:",f),e}finally{this._compilations.delete(t)}}function i(t){return Iu.inlineRef(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:n.call(this,t)}function o(t){for(const n of this._compilations)if(r=t,(e=n).schema===r.schema&&e.root===r.root&&e.baseId===r.baseId)return n;var e,r}function s(t,e){let r;for(;"string"==typeof(r=this.refs[e]);)e=r;return r||this.schemas[e]||a.call(this,t,e)}function a(t,e){const i=Uu.parse(e),o=Iu._getFullPath(i);let s=Iu.getFullPath(t.baseId);if(Object.keys(t.schema).length>0&&o===s)return u.call(this,i,t);const h=Iu.normalizeId(o),l=this.refs[h]||this.schemas[h];if("string"==typeof l){const e=a.call(this,t,l);if("object"!=typeof(null==e?void 0:e.schema))return;return u.call(this,i,e)}if("object"==typeof(null==l?void 0:l.schema)){if(l.validate||n.call(this,l),h===Iu.normalizeId(e)){const{schema:e}=l,{schemaId:n}=this.opts,i=e[n];return i&&(s=Iu.resolveUrl(s,i)),new r({schema:e,schemaId:n,root:t,baseId:s})}return u.call(this,i,l)}}e.SchemaEnv=r,e.compileSchema=n,e.resolveRef=function(t,e,n){var o;n=Iu.resolveUrl(e,n);const a=t.refs[n];if(a)return a;let h=s.call(this,t,n);if(void 0===h){const i=null===(o=t.localRefs)||void 0===o?void 0:o[n],{schemaId:s}=this.opts;i&&(h=new r({schema:i,schemaId:s,root:t,baseId:e}))}return void 0!==h?t.refs[n]=i.call(this,h):void 0},e.getCompilingSchema=o,e.resolveSchema=a;const h=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function u(t,{baseId:e,schema:n,root:i}){var o;if("/"!==(null===(o=t.fragment)||void 0===o?void 0:o[0]))return;for(const r of t.fragment.slice(1).split("/")){if("boolean"==typeof n)return;if(void 0===(n=n[mu.unescapeFragment(r)]))return;const t="object"==typeof n&&n[this.opts.schemaId];!h.has(r)&&t&&(e=Iu.resolveUrl(e,t))}let s;if("boolean"!=typeof n&&n.$ref&&!mu.schemaHasRulesButRef(n,this.RULES)){const t=Iu.resolveUrl(e,n.$ref);s=a.call(this,i,t)}const{schemaId:u}=this.opts;return s=s||new r({schema:n,schemaId:u,root:i,baseId:e}),s.schema!==s.root.schema?s:void 0}})),Lu={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1},$u=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0,Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return Pu.KeywordCxt}}),Object.defineProperty(e,"_",{enumerable:!0,get:function(){return du._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return du.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return du.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return du.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return du.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return du.CodeGen}});const r=du,n=["removeAdditional","useDefaults","coerceTypes"],i=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),o={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},s={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function a(t){var e,r,n,i,o,s,a,h,u,l,f,c,d,m,p,g,y,v,w,b,E,M;const _=t.strict,A=null===(e=t.code)||void 0===e?void 0:e.optimize,N=!0===A||void 0===A?1:A||0;return{strictSchema:null===(n=null!==(r=t.strictSchema)&&void 0!==r?r:_)||void 0===n||n,strictNumbers:null===(o=null!==(i=t.strictNumbers)&&void 0!==i?i:_)||void 0===o||o,strictTypes:null!==(a=null!==(s=t.strictTypes)&&void 0!==s?s:_)&&void 0!==a?a:"log",strictTuples:null!==(u=null!==(h=t.strictTuples)&&void 0!==h?h:_)&&void 0!==u?u:"log",strictRequired:null!==(f=null!==(l=t.strictRequired)&&void 0!==l?l:_)&&void 0!==f&&f,code:t.code?{...t.code,optimize:N}:{optimize:N},loopRequired:null!==(c=t.loopRequired)&&void 0!==c?c:200,loopEnum:null!==(d=t.loopEnum)&&void 0!==d?d:200,meta:null===(m=t.meta)||void 0===m||m,messages:null===(p=t.messages)||void 0===p||p,inlineRefs:null===(g=t.inlineRefs)||void 0===g||g,schemaId:null!==(y=t.schemaId)&&void 0!==y?y:"$id",addUsedSchema:null===(v=t.addUsedSchema)||void 0===v||v,validateSchema:null===(w=t.validateSchema)||void 0===w||w,validateFormats:null===(b=t.validateFormats)||void 0===b||b,unicodeRegExp:null===(E=t.unicodeRegExp)||void 0===E||E,int32range:null===(M=t.int32range)||void 0===M||M}}class h{constructor(t={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...a(t)};const{es5:e,lines:n}=this.opts.code;this.scope=new r.ValueScope({scope:{},prefixes:i,es5:e,lines:n}),this.logger=function(t){if(!1===t)return p;if(void 0===t)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}(t.logger);const h=t.validateFormats;t.validateFormats=!1,this.RULES=wu.getRules(),u.call(this,o,t,"NOT SUPPORTED"),u.call(this,s,t,"DEPRECATED","warn"),this._metaOpts=m.call(this),t.formats&&c.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&d.call(this,t.keywords),"object"==typeof t.meta&&this.addMetaSchema(t.meta),f.call(this),t.validateFormats=h}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:t,meta:e,schemaId:r}=this.opts;let n=Lu;"id"===r&&(n={...Lu},n.id=n.$id,delete n.$id),e&&t&&this.addMetaSchema(n,n[r],!1)}defaultMeta(){const{meta:t,schemaId:e}=this.opts;return this.opts.defaultMeta="object"==typeof t?t[e]||t:void 0}validate(t,e){let r;if("string"==typeof t){if(r=this.getSchema(t),!r)throw new Error(`no schema with key or ref "${t}"`)}else r=this.compile(t);const n=r(e);return"$async"in r||(this.errors=r.errors),n}compile(t,e){const r=this._addSchema(t,e);return r.validate||this._compileSchemaEnv(r)}compileAsync(t,e){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:r}=this.opts;return n.call(this,t,e);async function n(t,e){await i.call(this,t.$schema);const r=this._addSchema(t,e);return r.validate||o.call(this,r)}async function i(t){t&&!this.getSchema(t)&&await n.call(this,{$ref:t},!0)}async function o(t){try{return this._compileSchemaEnv(t)}catch(e){if(!(e instanceof Fu.default))throw e;return s.call(this,e),await a.call(this,e.missingSchema),o.call(this,t)}}function s({missingSchema:t,missingRef:e}){if(this.refs[t])throw new Error(`AnySchema ${t} is loaded but ${e} cannot be resolved`)}async function a(t){const r=await h.call(this,t);this.refs[t]||await i.call(this,r.$schema),this.refs[t]||this.addSchema(r,t,e)}async function h(t){const e=this._loading[t];if(e)return e;try{return await(this._loading[t]=r(t))}finally{delete this._loading[t]}}}addSchema(t,e,r,n=this.opts.validateSchema){if(Array.isArray(t)){for(const e of t)this.addSchema(e,void 0,r,n);return this}let i;if("object"==typeof t){const{schemaId:e}=this.opts;if(i=t[e],void 0!==i&&"string"!=typeof i)throw new Error(`schema ${e} must be string`)}return e=Iu.normalizeId(e||i),this._checkUnique(e),this.schemas[e]=this._addSchema(t,r,e,n,!0),this}addMetaSchema(t,e,r=this.opts.validateSchema){return this.addSchema(t,e,!0,r),this}validateSchema(t,e){if("boolean"==typeof t)return!0;let r;if(r=t.$schema,void 0!==r&&"string"!=typeof r)throw new Error("$schema must be a string");if(r=r||this.opts.defaultMeta||this.defaultMeta(),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const n=this.validate(r,t);if(!n&&e){const t="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(t);this.logger.error(t)}return n}getSchema(t){let e;for(;"string"==typeof(e=l.call(this,t));)t=e;if(void 0===e){const{schemaId:r}=this.opts,n=new Du.SchemaEnv({schema:{},schemaId:r});if(e=Du.resolveSchema.call(this,n,t),!e)return;this.refs[t]=e}return e.validate||this._compileSchemaEnv(e)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const e=l.call(this,t);return"object"==typeof e&&this._cache.delete(e.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{const e=t;this._cache.delete(e);let r=t[this.opts.schemaId];return r&&(r=Iu.normalizeId(r),delete this.schemas[r],delete this.refs[r]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(const e of t)this.addKeyword(e);return this}addKeyword(t,e){let r;if("string"==typeof t)r=t,"object"==typeof e&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),e.keyword=r);else{if("object"!=typeof t||void 0!==e)throw new Error("invalid addKeywords parameters");if(r=(e=t).keyword,Array.isArray(r)&&!r.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(y.call(this,r,e),!e)return mu.eachItem(r,t=>v.call(this,t)),this;b.call(this,e);const n={...e,type:Eu.getJSONTypes(e.type),schemaType:Eu.getJSONTypes(e.schemaType)};return mu.eachItem(r,0===n.type.length?t=>v.call(this,t,n):t=>n.type.forEach(e=>v.call(this,t,n,e))),this}getKeyword(t){const e=this.RULES.all[t];return"object"==typeof e?e.definition:!!e}removeKeyword(t){const{RULES:e}=this;delete e.keywords[t],delete e.all[t];for(const r of e.rules){const e=r.rules.findIndex(e=>e.keyword===t);e>=0&&r.rules.splice(e,1)}return this}addFormat(t,e){return"string"==typeof e&&(e=new RegExp(e)),this.formats[t]=e,this}errorsText(t=this.errors,{separator:e=", ",dataVar:r="data"}={}){return t&&0!==t.length?t.map(t=>`${r}${t.instancePath} ${t.message}`).reduce((t,r)=>t+e+r):"No errors"}$dataMetaSchema(t,e){const r=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(const n of e){const e=n.split("/").slice(1);let i=t;for(const t of e)i=i[t];for(const t in r){const e=r[t];if("object"!=typeof e)continue;const{$data:n}=e.definition,o=i[t];n&&o&&(i[t]=M(o))}}return t}_removeAllSchemas(t,e){for(const r in t){const n=t[r];e&&!e.test(r)||("string"==typeof n?delete t[r]:n&&!n.meta&&(this._cache.delete(n.schema),delete t[r]))}}_addSchema(t,e,r,n=this.opts.validateSchema,i=this.opts.addUsedSchema){let o;const{schemaId:s}=this.opts;if("object"==typeof t)o=t[s];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof t)throw new Error("schema must be object or boolean")}let a=this._cache.get(t);if(void 0!==a)return a;const h=Iu.getSchemaRefs.call(this,t);return r=Iu.normalizeId(o||r),a=new Du.SchemaEnv({schema:t,schemaId:s,meta:e,baseId:r,localRefs:h}),this._cache.set(a.schema,a),i&&!r.startsWith("#")&&(r&&this._checkUnique(r),this.refs[r]=a),n&&this.validateSchema(t,!0),a}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):Du.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){const e=this.opts;this.opts=this._metaOpts;try{Du.compileSchema.call(this,t)}finally{this.opts=e}}}function u(t,e,r,n="error"){for(const i in t){const o=i;o in e&&this.logger[n](`${r}: option ${i}. ${t[o]}`)}}function l(t){return t=Iu.normalizeId(t),this.schemas[t]||this.refs[t]}function f(){const t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(const e in t)this.addSchema(t[e],e)}function c(){for(const t in this.opts.formats){const e=this.opts.formats[t];e&&this.addFormat(t,e)}}function d(t){if(Array.isArray(t))this.addVocabulary(t);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const e in t){const r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}}function m(){const t={...this.opts};for(const e of n)delete t[e];return t}e.default=h,h.ValidationError=Tu.default,h.MissingRefError=Fu.default;const p={log(){},warn(){},error(){}};const g=/^[a-z_$][a-z0-9_$:-]*$/i;function y(t,e){const{RULES:r}=this;if(mu.eachItem(t,t=>{if(r.keywords[t])throw new Error(`Keyword ${t} is already defined`);if(!g.test(t))throw new Error(`Keyword ${t} has invalid name`)}),e&&e.$data&&!("code"in e)&&!("validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function v(t,e,r){var n;const i=null==e?void 0:e.post;if(r&&i)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:o}=this;let s=i?o.post:o.rules.find(({type:t})=>t===r);if(s||(s={type:r,rules:[]},o.rules.push(s)),o.keywords[t]=!0,!e)return;const a={keyword:t,definition:{...e,type:Eu.getJSONTypes(e.type),schemaType:Eu.getJSONTypes(e.schemaType)}};e.before?w.call(this,s,a,e.before):s.rules.push(a),o.all[t]=a,null===(n=e.implements)||void 0===n||n.forEach(t=>this.addKeyword(t))}function w(t,e,r){const n=t.rules.findIndex(t=>t.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function b(t){let{metaSchema:e}=t;void 0!==e&&(t.$data&&this.opts.$data&&(e=M(e)),t.validateSchema=this.compile(e,!0))}const E={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function M(t){return{anyOf:[t,E]}}}));var Bu={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}},ju=Object.defineProperty({default:Bu},"__esModule",{value:!0}),zu=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.callRef=e.getValidate=void 0;const r={keyword:"$ref",schemaType:"string",code(t){const{gen:e,schema:r,it:o}=t,{baseId:s,schemaEnv:a,validateName:h,opts:u,self:l}=o,{root:f}=a;if(("#"===r||"#/"===r)&&s===f.baseId)return function(){if(a===f)return i(t,h,a,a.$async);const r=e.scopeValue("root",{ref:f});return i(t,du._`${r}.validate`,f,f.$async)}();const c=Du.resolveRef.call(l,f,s,r);if(void 0===c)throw new Fu.default(s,r);return c instanceof Du.SchemaEnv?function(e){const r=n(t,e);i(t,r,e,e.$async)}(c):function(n){const i=e.scopeValue("schema",!0===u.code.source?{ref:n,code:du.stringify(n)}:{ref:n}),o=e.name("valid"),s=t.subschema({schema:n,dataTypes:[],schemaPath:du.nil,topSchemaRef:i,errSchemaPath:r},o);t.mergeEvaluated(s),t.ok(o)}(c)}};function n(t,e){const{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):du._`${r.scopeValue("wrapper",{ref:e})}.validate`}function i(t,e,r,n){const{gen:i,it:o}=t,{allErrors:s,schemaEnv:a,opts:h}=o,u=h.passContext?gu.default.this:du.nil;function l(t){const e=du._`${t}.errors`;i.assign(gu.default.vErrors,du._`${gu.default.vErrors} === null ? ${e} : ${gu.default.vErrors}.concat(${e})`),i.assign(gu.default.errors,du._`${gu.default.vErrors}.length`)}function f(t){var e;if(!o.opts.unevaluated)return;const n=null===(e=null==r?void 0:r.validate)||void 0===e?void 0:e.evaluated;if(!0!==o.props)if(n&&!n.dynamicProps)void 0!==n.props&&(o.props=mu.mergeEvaluated.props(i,n.props,o.props));else{const e=i.var("props",du._`${t}.evaluated.props`);o.props=mu.mergeEvaluated.props(i,e,o.props,du.Name)}if(!0!==o.items)if(n&&!n.dynamicItems)void 0!==n.items&&(o.items=mu.mergeEvaluated.items(i,n.items,o.items));else{const e=i.var("items",du._`${t}.evaluated.items`);o.items=mu.mergeEvaluated.items(i,e,o.items,du.Name)}}n?function(){if(!a.$async)throw new Error("async schema referenced by sync schema");const r=i.let("valid");i.try(()=>{i.code(du._`await ${_u.callValidateCode(t,e,u)}`),f(e),s||i.assign(r,!0)},t=>{i.if(du._`!(${t} instanceof ${o.ValidationError})`,()=>i.throw(t)),l(t),s||i.assign(r,!1)}),t.ok(r)}():t.result(_u.callValidateCode(t,e,u),()=>f(e),()=>l(e))}e.getValidate=n,e.callRef=i,e.default=r}));var Gu=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",ju.default,zu.default],qu=Object.defineProperty({default:Gu},"__esModule",{value:!0});const Vu=du.operators,Ku={maximum:{okStr:"<=",ok:Vu.LTE,fail:Vu.GT},minimum:{okStr:">=",ok:Vu.GTE,fail:Vu.LT},exclusiveMaximum:{okStr:"<",ok:Vu.LT,fail:Vu.GTE},exclusiveMinimum:{okStr:">",ok:Vu.GT,fail:Vu.LTE}},Wu={message:({keyword:t,schemaCode:e})=>du.str`must be ${Ku[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>du._`{comparison: ${Ku[t].okStr}, limit: ${e}}`};var Hu={keyword:Object.keys(Ku),type:"number",schemaType:"number",$data:!0,error:Wu,code(t){const{keyword:e,data:r,schemaCode:n}=t;t.fail$data(du._`${r} ${Ku[e].fail} ${n} || isNaN(${r})`)}},Zu=Object.defineProperty({default:Hu},"__esModule",{value:!0});var Xu={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:t})=>du.str`must be multiple of ${t}`,params:({schemaCode:t})=>du._`{multipleOf: ${t}}`},code(t){const{gen:e,data:r,schemaCode:n,it:i}=t,o=i.opts.multipleOfPrecision,s=e.let("res"),a=o?du._`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:du._`${s} !== parseInt(${s})`;t.fail$data(du._`(${n} === 0 || (${s} = ${r}/${n}, ${a}))`)}},Ju=Object.defineProperty({default:Xu},"__esModule",{value:!0});function Yu(t){const e=t.length;let r,n=0,i=0;for(;i<e;)n++,r=t.charCodeAt(i++),r>=55296&&r<=56319&&i<e&&(r=t.charCodeAt(i),56320==(64512&r)&&i++);return n}var Qu=Yu;Yu.code='require("ajv/dist/runtime/ucs2length").default';var tl=Object.defineProperty({default:Qu},"__esModule",{value:!0});var el={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:{message({keyword:t,schemaCode:e}){const r="maxLength"===t?"more":"fewer";return du.str`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>du._`{limit: ${t}}`},code(t){const{keyword:e,data:r,schemaCode:n,it:i}=t,o="maxLength"===e?du.operators.GT:du.operators.LT,s=!1===i.opts.unicode?du._`${r}.length`:du._`${mu.useFunc(t.gen,tl.default)}(${r})`;t.fail$data(du._`${s} ${o} ${n}`)}},rl=Object.defineProperty({default:el},"__esModule",{value:!0});var nl={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>du.str`must match pattern "${t}"`,params:({schemaCode:t})=>du._`{pattern: ${t}}`},code(t){const{data:e,$data:r,schema:n,schemaCode:i,it:o}=t,s=o.opts.unicodeRegExp?"u":"",a=r?du._`(new RegExp(${i}, ${s}))`:_u.usePattern(t,n);t.fail$data(du._`!${a}.test(${e})`)}},il=Object.defineProperty({default:nl},"__esModule",{value:!0});var ol={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:{message({keyword:t,schemaCode:e}){const r="maxProperties"===t?"more":"fewer";return du.str`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>du._`{limit: ${t}}`},code(t){const{keyword:e,data:r,schemaCode:n}=t,i="maxProperties"===e?du.operators.GT:du.operators.LT;t.fail$data(du._`Object.keys(${r}).length ${i} ${n}`)}},sl=Object.defineProperty({default:ol},"__esModule",{value:!0});var al={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:t}})=>du.str`must have required property '${t}'`,params:({params:{missingProperty:t}})=>du._`{missingProperty: ${t}}`},code(t){const{gen:e,schema:r,schemaCode:n,data:i,$data:o,it:s}=t,{opts:a}=s;if(!o&&0===r.length)return;const h=r.length>=a.loopRequired;if(s.allErrors?function(){if(h||o)t.block$data(du.nil,u);else for(const e of r)_u.checkReportMissingProp(t,e)}():function(){const s=e.let("missing");if(h||o){const r=e.let("valid",!0);t.block$data(r,()=>function(r,o){t.setParams({missingProperty:r}),e.forOf(r,n,()=>{e.assign(o,_u.propertyInData(e,i,r,a.ownProperties)),e.if(du.not(o),()=>{t.error(),e.break()})},du.nil)}(s,r)),t.ok(r)}else e.if(_u.checkMissingProp(t,r,s)),_u.reportMissingProp(t,s),e.else()}(),a.strictRequired){const e=t.parentSchema.properties,{definedProperties:n}=t.it;for(const t of r)if(void 0===(null==e?void 0:e[t])&&!n.has(t)){const e=`required property "${t}" is not defined at "${s.schemaEnv.baseId+s.errSchemaPath}" (strictRequired)`;mu.checkStrictMode(s,e,s.opts.strictRequired)}}function u(){e.forOf("prop",n,r=>{t.setParams({missingProperty:r}),e.if(_u.noPropertyInData(e,i,r,a.ownProperties),()=>t.error())})}}},hl=Object.defineProperty({default:al},"__esModule",{value:!0});var ul={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:{message({keyword:t,schemaCode:e}){const r="maxItems"===t?"more":"fewer";return du.str`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>du._`{limit: ${t}}`},code(t){const{keyword:e,data:r,schemaCode:n}=t,i="maxItems"===e?du.operators.GT:du.operators.LT;t.fail$data(du._`${r}.length ${i} ${n}`)}},ll=Object.defineProperty({default:ul},"__esModule",{value:!0});Su.code='require("ajv/dist/runtime/equal").default';var fl=Su,cl=Object.defineProperty({default:fl},"__esModule",{value:!0});var dl={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:t,j:e}})=>du.str`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>du._`{i: ${t}, j: ${e}}`},code(t){const{gen:e,data:r,$data:n,schema:i,parentSchema:o,schemaCode:s,it:a}=t;if(!n&&!i)return;const h=e.let("valid"),u=o.items?Eu.getSchemaTypes(o.items):[];function l(n,i){const o=e.name("item"),s=Eu.checkDataTypes(u,o,a.opts.strictNumbers,Eu.DataType.Wrong),l=e.const("indices",du._`{}`);e.for(du._`;${n}--;`,()=>{e.let(o,du._`${r}[${n}]`),e.if(s,du._`continue`),u.length>1&&e.if(du._`typeof ${o} == "string"`,du._`${o} += "_"`),e.if(du._`typeof ${l}[${o}] == "number"`,()=>{e.assign(i,du._`${l}[${o}]`),t.error(),e.assign(h,!1).break()}).code(du._`${l}[${o}] = ${n}`)})}function f(n,i){const o=mu.useFunc(e,cl.default),s=e.name("outer");e.label(s).for(du._`;${n}--;`,()=>e.for(du._`${i} = ${n}; ${i}--;`,()=>e.if(du._`${o}(${r}[${n}], ${r}[${i}])`,()=>{t.error(),e.assign(h,!1).break(s)})))}t.block$data(h,(function(){const n=e.let("i",du._`${r}.length`),i=e.let("j");t.setParams({i:n,j:i}),e.assign(h,!0),e.if(du._`${n} > 1`,()=>(u.length>0&&!u.some(t=>"object"===t||"array"===t)?l:f)(n,i))}),du._`${s} === false`),t.ok(h)}},ml=Object.defineProperty({default:dl},"__esModule",{value:!0});var pl={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:t})=>du._`{allowedValue: ${t}}`},code(t){const{gen:e,data:r,$data:n,schemaCode:i,schema:o}=t;n||o&&"object"==typeof o?t.fail$data(du._`!${mu.useFunc(e,cl.default)}(${r}, ${i})`):t.fail(du._`${o} !== ${r}`)}},gl=Object.defineProperty({default:pl},"__esModule",{value:!0});var yl={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:t})=>du._`{allowedValues: ${t}}`},code(t){const{gen:e,data:r,$data:n,schema:i,schemaCode:o,it:s}=t;if(!n&&0===i.length)throw new Error("enum must have non-empty array");const a=i.length>=s.opts.loopEnum,h=mu.useFunc(e,cl.default);let u;if(a||n)u=e.let("valid"),t.block$data(u,(function(){e.assign(u,!1),e.forOf("v",o,t=>e.if(du._`${h}(${r}, ${t})`,()=>e.assign(u,!0).break()))}));else{if(!Array.isArray(i))throw new Error("ajv implementation error");const t=e.const("vSchema",o);u=du.or(...i.map((e,n)=>function(t,e){const n=i[e];return"object"==typeof n&&null!==n?du._`${h}(${r}, ${t}[${e}])`:du._`${r} === ${n}`}(t,n)))}t.pass(u)}},vl=Object.defineProperty({default:yl},"__esModule",{value:!0});var wl=[Zu.default,Ju.default,rl.default,il.default,sl.default,hl.default,ll.default,ml.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},gl.default,vl.default],bl=Object.defineProperty({default:wl},"__esModule",{value:!0}),El=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateAdditionalItems=void 0;const r={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:t}})=>du.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>du._`{limit: ${t}}`},code(t){const{parentSchema:e,it:r}=t,{items:i}=e;Array.isArray(i)?n(t,i):mu.checkStrictMode(r,'"additionalItems" is ignored when "items" is not an array of schemas')}};function n(t,e){const{gen:r,schema:n,data:i,keyword:o,it:s}=t;s.items=!0;const a=r.const("len",du._`${i}.length`);if(!1===n)t.setParams({len:e.length}),t.pass(du._`${a} <= ${e.length}`);else if("object"==typeof n&&!mu.alwaysValidSchema(s,n)){const n=r.var("valid",du._`${a} <= ${e.length}`);r.if(du.not(n),()=>function(n){r.forRange("i",e.length,a,e=>{t.subschema({keyword:o,dataProp:e,dataPropType:mu.Type.Num},n),s.allErrors||r.if(du.not(n),()=>r.break())})}(n)),t.ok(n)}}e.validateAdditionalItems=n,e.default=r})),Ml=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateTuple=void 0;const r={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){const{schema:e,it:r}=t;if(Array.isArray(e))return n(t,"additionalItems",e);r.items=!0,mu.alwaysValidSchema(r,e)||t.ok(_u.validateArray(t))}};function n(t,e,r=t.schema){const{gen:n,parentSchema:i,data:o,keyword:s,it:a}=t;!function(t){const{opts:n,errSchemaPath:i}=a,o=r.length,h=o===t.minItems&&(o===t.maxItems||!1===t[e]);if(n.strictTuples&&!h){const t=`"${s}" is ${o}-tuple, but minItems or maxItems/${e} are not specified or different at path "${i}"`;mu.checkStrictMode(a,t,n.strictTuples)}}(i),a.opts.unevaluated&&r.length&&!0!==a.items&&(a.items=mu.mergeEvaluated.items(n,r.length,a.items));const h=n.name("valid"),u=n.const("len",du._`${o}.length`);r.forEach((e,r)=>{mu.alwaysValidSchema(a,e)||(n.if(du._`${u} > ${r}`,()=>t.subschema({keyword:s,schemaProp:r,dataProp:r},h)),t.ok(h))})}e.validateTuple=n,e.default=r}));var _l={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>Ml.validateTuple(t,"items")},Al=Object.defineProperty({default:_l},"__esModule",{value:!0});var Nl={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:t}})=>du.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>du._`{limit: ${t}}`},code(t){const{schema:e,parentSchema:r,it:n}=t,{prefixItems:i}=r;n.items=!0,mu.alwaysValidSchema(n,e)||(i?El.validateAdditionalItems(t,i):t.ok(_u.validateArray(t)))}},Sl=Object.defineProperty({default:Nl},"__esModule",{value:!0});var Rl={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:t,max:e}})=>void 0===e?du.str`must contain at least ${t} valid item(s)`:du.str`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>void 0===e?du._`{minContains: ${t}}`:du._`{minContains: ${t}, maxContains: ${e}}`},code(t){const{gen:e,schema:r,parentSchema:n,data:i,it:o}=t;let s,a;const{minContains:h,maxContains:u}=n;o.opts.next?(s=void 0===h?1:h,a=u):s=1;const l=e.const("len",du._`${i}.length`);if(t.setParams({min:s,max:a}),void 0===a&&0===s)return void mu.checkStrictMode(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==a&&s>a)return mu.checkStrictMode(o,'"minContains" > "maxContains" is always invalid'),void t.fail();if(mu.alwaysValidSchema(o,r)){let e=du._`${l} >= ${s}`;return void 0!==a&&(e=du._`${e} && ${l} <= ${a}`),void t.pass(e)}o.items=!0;const f=e.name("valid");if(void 0===a&&1===s)c(f,()=>e.if(f,()=>e.break()));else{e.let(f,!1);const t=e.name("_valid"),r=e.let("count",0);c(t,()=>e.if(t,()=>function(t){e.code(du._`${t}++`),void 0===a?e.if(du._`${t} >= ${s}`,()=>e.assign(f,!0).break()):(e.if(du._`${t} > ${a}`,()=>e.assign(f,!1).break()),1===s?e.assign(f,!0):e.if(du._`${t} >= ${s}`,()=>e.assign(f,!0)))}(r)))}function c(r,n){e.forRange("i",0,l,e=>{t.subschema({keyword:"contains",dataProp:e,dataPropType:mu.Type.Num,compositeRule:!0},r),n()})}t.result(f,()=>t.reset())}},Ul=Object.defineProperty({default:Rl},"__esModule",{value:!0}),Il=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0,e.error={message:({params:{property:t,depsCount:e,deps:r}})=>{const n=1===e?"property":"properties";return du.str`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>du._`{property: ${t},
|
|
29
29
|
missingProperty: ${n},
|
|
30
30
|
depsCount: ${e},
|
|
31
|
-
deps: ${r}}`};const r={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(t){const[e,r]=function({schema:t}){const e={},r={};for(const n in t){if("__proto__"===n)continue;(Array.isArray(t[n])?e:r)[n]=t[n]}return[e,r]}(t);n(t,e),i(t,r)}};function n(t,e=t.schema){const{gen:r,data:n,it:i}=t;if(0===Object.keys(e).length)return;const o=r.let("missing");for(const s in e){const a=e[s];if(0===a.length)continue;const h=_u.propertyInData(r,n,s,i.opts.ownProperties);t.setParams({property:s,depsCount:a.length,deps:a.join(", ")}),i.allErrors?r.if(h,()=>{for(const e of a)_u.checkReportMissingProp(t,e)}):(r.if(du._`${h} && (${_u.checkMissingProp(t,a,o)})`),_u.reportMissingProp(t,o),r.else())}}function i(t,e=t.schema){const{gen:r,data:n,keyword:i,it:o}=t,s=r.name("valid");for(const a in e)mu.alwaysValidSchema(o,e[a])||(r.if(_u.propertyInData(r,n,a,o.opts.ownProperties),()=>{const e=t.subschema({keyword:i,schemaProp:a},s);t.mergeValidEvaluated(e,s)},()=>r.var(s,!0)),t.ok(s))}e.validatePropertyDeps=n,e.validateSchemaDeps=i,e.default=r}));var Pl={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:t})=>du._`{propertyName: ${t.propertyName}}`},code(t){const{gen:e,schema:r,data:n,it:i}=t;if(mu.alwaysValidSchema(i,r))return;const o=e.name("valid");e.forIn("key",n,r=>{t.setParams({propertyName:r}),t.subschema({keyword:"propertyNames",data:r,dataTypes:["string"],propertyName:r,compositeRule:!0},o),e.if(du.not(o),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(o)}},xl=Object.defineProperty({default:Pl},"__esModule",{value:!0});var kl={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:t})=>du._`{additionalProperty: ${t.additionalProperty}}`},code(t){const{gen:e,schema:r,parentSchema:n,data:i,errsCount:o,it:s}=t;if(!o)throw new Error("ajv implementation error");const{allErrors:a,opts:h}=s;if(s.props=!0,"all"!==h.removeAdditional&&mu.alwaysValidSchema(s,r))return;const u=_u.allSchemaProperties(n.properties),l=_u.allSchemaProperties(n.patternProperties);function f(t){e.code(du._`delete ${i}[${t}]`)}function c(n){if("all"===h.removeAdditional||h.removeAdditional&&!1===r)f(n);else{if(!1===r)return t.setParams({additionalProperty:n}),t.error(),void(a||e.break());if("object"==typeof r&&!mu.alwaysValidSchema(s,r)){const r=e.name("valid");"failing"===h.removeAdditional?(d(n,r,!1),e.if(du.not(r),()=>{t.reset(),f(n)})):(d(n,r),a||e.if(du.not(r),()=>e.break()))}}}function d(e,r,n){const i={keyword:"additionalProperties",dataProp:e,dataPropType:mu.Type.Str};!1===n&&Object.assign(i,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(i,r)}e.forIn("key",i,r=>{u.length||l.length?e.if(function(r){let i;if(u.length>8){const t=mu.schemaRefOrVal(s,n.properties,"properties");i=_u.isOwnProperty(e,t,r)}else i=u.length?du.or(...u.map(t=>du._`${r} === ${t}`)):du.nil;return l.length&&(i=du.or(i,...l.map(e=>du._`${_u.usePattern(t,e)}.test(${r})`))),du.not(i)}(r),()=>c(r)):c(r)}),t.ok(du._`${o} === ${gu.default.errors}`)}},Tl=Object.defineProperty({default:kl},"__esModule",{value:!0});var Ol={keyword:"properties",type:"object",schemaType:"object",code(t){const{gen:e,schema:r,parentSchema:n,data:i,it:o}=t;"all"===o.opts.removeAdditional&&void 0===n.additionalProperties&&Tl.default.code(new Pu.KeywordCxt(o,Tl.default,"additionalProperties"));const s=_u.allSchemaProperties(r);for(const t of s)o.definedProperties.add(t);o.opts.unevaluated&&s.length&&!0!==o.props&&(o.props=mu.mergeEvaluated.props(e,mu.toHash(s),o.props));const a=s.filter(t=>!mu.alwaysValidSchema(o,r[t]));if(0===a.length)return;const h=e.name("valid");for(const r of a)u(r)?l(r):(e.if(_u.propertyInData(e,i,r,o.opts.ownProperties)),l(r),o.allErrors||e.else().var(h,!0),e.endIf()),t.it.definedProperties.add(r),t.ok(h);function u(t){return o.opts.useDefaults&&!o.compositeRule&&void 0!==r[t].default}function l(e){t.subschema({keyword:"properties",schemaProp:e,dataProp:e},h)}}},Cl=Object.defineProperty({default:Ol},"__esModule",{value:!0});const Fl=mu;var Dl={keyword:"patternProperties",type:"object",schemaType:"object",code(t){const{gen:e,schema:r,data:n,parentSchema:i,it:o}=t,{opts:s}=o,a=_u.allSchemaProperties(r),h=a.filter(t=>mu.alwaysValidSchema(o,r[t]));if(0===a.length||h.length===a.length&&(!o.opts.unevaluated||!0===o.props))return;const u=s.strictSchema&&!s.allowMatchingProperties&&i.properties,l=e.name("valid");!0===o.props||o.props instanceof du.Name||(o.props=Fl.evaluatedPropsToName(e,o.props));const{props:f}=o;function c(t){for(const e in u)new RegExp(t).test(e)&&mu.checkStrictMode(o,`property ${e} matches pattern ${t} (use allowMatchingProperties)`)}function d(r){e.forIn("key",n,n=>{e.if(du._`${_u.usePattern(t,r)}.test(${n})`,()=>{const i=h.includes(r);i||t.subschema({keyword:"patternProperties",schemaProp:r,dataProp:n,dataPropType:Fl.Type.Str},l),o.opts.unevaluated&&!0!==f?e.assign(du._`${f}[${n}]`,!0):i||o.allErrors||e.if(du.not(l),()=>e.break())})})}!function(){for(const t of a)u&&c(t),o.allErrors?d(t):(e.var(l,!0),d(t),e.if(l))}()}},Ll=Object.defineProperty({default:Dl},"__esModule",{value:!0});var $l={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){const{gen:e,schema:r,it:n}=t;if(mu.alwaysValidSchema(n,r))return void t.fail();const i=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),t.result(i,()=>t.error(),()=>t.reset())},error:{message:"must NOT be valid"}},Bl=Object.defineProperty({default:$l},"__esModule",{value:!0});var jl={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:_u.validateUnion,error:{message:"must match a schema in anyOf"}},zl=Object.defineProperty({default:jl},"__esModule",{value:!0});var Gl={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:t})=>du._`{passingSchemas: ${t.passing}}`},code(t){const{gen:e,schema:r,parentSchema:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;const o=r,s=e.let("valid",!1),a=e.let("passing",null),h=e.name("_valid");t.setParams({passing:a}),e.block((function(){o.forEach((r,n)=>{let o;mu.alwaysValidSchema(i,r)?e.var(h,!0):o=t.subschema({keyword:"oneOf",schemaProp:n,compositeRule:!0},h),n>0&&e.if(du._`${h} && ${s}`).assign(s,!1).assign(a,du._`[${a}, ${n}]`).else(),e.if(h,()=>{e.assign(s,!0),e.assign(a,n),o&&t.mergeEvaluated(o,du.Name)})})})),t.result(s,()=>t.reset(),()=>t.error(!0))}},ql=Object.defineProperty({default:Gl},"__esModule",{value:!0});var Vl={keyword:"allOf",schemaType:"array",code(t){const{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");const i=e.name("valid");r.forEach((e,r)=>{if(mu.alwaysValidSchema(n,e))return;const o=t.subschema({keyword:"allOf",schemaProp:r},i);t.ok(i),t.mergeEvaluated(o)})}},Kl=Object.defineProperty({default:Vl},"__esModule",{value:!0});function Wl(t,e){const r=t.schema[e];return void 0!==r&&!mu.alwaysValidSchema(t,r)}var Hl={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:t})=>du.str`must match "${t.ifClause}" schema`,params:({params:t})=>du._`{failingKeyword: ${t.ifClause}}`},code(t){const{gen:e,parentSchema:r,it:n}=t;void 0===r.then&&void 0===r.else&&mu.checkStrictMode(n,'"if" without "then" and "else" is ignored');const i=Wl(n,"then"),o=Wl(n,"else");if(!i&&!o)return;const s=e.let("valid",!0),a=e.name("_valid");if(function(){const e=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(e)}(),t.reset(),i&&o){const r=e.let("ifClause");t.setParams({ifClause:r}),e.if(a,h("then",r),h("else",r))}else i?e.if(a,h("then")):e.if(du.not(a),h("else"));function h(r,n){return()=>{const i=t.subschema({keyword:r},a);e.assign(s,a),t.mergeValidEvaluated(i,s),n?e.assign(n,du._`${r}`):t.setParams({ifClause:r})}}t.pass(s,()=>t.error(!0))}},Zl=Object.defineProperty({default:Hl},"__esModule",{value:!0});var Xl={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){void 0===e.if&&mu.checkStrictMode(r,`"${t}" without "if" is ignored`)}},Jl=Object.defineProperty({default:Xl},"__esModule",{value:!0});var Yl=function(t=!1){const e=[Bl.default,zl.default,ql.default,Kl.default,Zl.default,Jl.default,xl.default,Tl.default,Il.default,Cl.default,Ll.default];return t?e.push(Al.default,Sl.default):e.push(El.default,Ml.default),e.push(Ul.default),e},Ql=Object.defineProperty({default:Yl},"__esModule",{value:!0});var tf={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>du.str`must match format "${t}"`,params:({schemaCode:t})=>du._`{format: ${t}}`},code(t,e){const{gen:r,data:n,$data:i,schema:o,schemaCode:s,it:a}=t,{opts:h,errSchemaPath:u,schemaEnv:l,self:f}=a;h.validateFormats&&(i?function(){const i=r.scopeValue("formats",{ref:f.formats,code:h.code.formats}),o=r.const("fDef",du._`${i}[${s}]`),a=r.let("fType"),u=r.let("format");r.if(du._`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(a,du._`${o}.type || "string"`).assign(u,du._`${o}.validate`),()=>r.assign(a,du._`"string"`).assign(u,o)),t.fail$data(du.or(!1===h.strictSchema?du.nil:du._`${s} && !${u}`,function(){const t=l.$async?du._`(${o}.async ? await ${u}(${n}) : ${u}(${n}))`:du._`${u}(${n})`,r=du._`(typeof ${u} == "function" ? ${t} : ${u}.test(${n}))`;return du._`${u} && ${u} !== true && ${a} === ${e} && !${r}`}()))}():function(){const i=f.formats[o];if(!i)return void function(){if(!1===h.strictSchema)return void f.logger.warn(t());throw new Error(t());function t(){return`unknown format "${o}" ignored in schema at path "${u}"`}}();if(!0===i)return;const[s,a,c]=function(t){const e=t instanceof RegExp?du.regexpCode(t):h.code.formats?du._`${h.code.formats}${du.getProperty(o)}`:void 0,n=r.scopeValue("formats",{key:o,ref:t,code:e});if("object"==typeof t&&!(t instanceof RegExp))return[t.type||"string",t.validate,du._`${n}.validate`];return["string",t,n]}(i);s===e&&t.pass(function(){if("object"==typeof i&&!(i instanceof RegExp)&&i.async){if(!l.$async)throw new Error("async format in sync schema");return du._`await ${c}(${n})`}return"function"==typeof a?du._`${c}(${n})`:du._`${c}.test(${n})`}())}())}};var ef=[Object.defineProperty({default:tf},"__esModule",{value:!0}).default],rf=Object.defineProperty({default:ef},"__esModule",{value:!0}),nf=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],e.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]}));var of=[qu.default,bl.default,Ql.default(),rf.default,nf.metadataVocabulary,nf.contentVocabulary],sf=Object.defineProperty({default:of},"__esModule",{value:!0}),af=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0,function(t){t.Tag="tag",t.Mapping="mapping"}(e.DiscrError||(e.DiscrError={}))}));var hf={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:t,tagName:e}})=>t===af.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>du._`{error: ${t}, tag: ${r}, tagValue: ${e}}`},code(t){const{gen:e,data:r,schema:n,parentSchema:i,it:o}=t,{oneOf:s}=i;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");const a=n.propertyName;if("string"!=typeof a)throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");const h=e.let("valid",!1),u=e.const("tag",du._`${r}${du.getProperty(a)}`);function l(r){const n=e.name("valid"),i=t.subschema({keyword:"oneOf",schemaProp:r},n);return t.mergeEvaluated(i,du.Name),n}e.if(du._`typeof ${u} == "string"`,()=>function(){const r=function(){var t;const e={},r=o(i);let n=!0;for(let e=0;e<s.length;e++){const i=s[e],u=null===(t=i.properties)||void 0===t?void 0:t[a];if("object"!=typeof u)throw new Error(`discriminator: oneOf schemas must have "properties/${a}"`);n=n&&(r||o(i)),h(u,e)}if(!n)throw new Error(`discriminator: "${a}" must be required`);return e;function o({required:t}){return Array.isArray(t)&&t.includes(a)}function h(t,e){if(t.const)u(t.const,e);else{if(!t.enum)throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`);for(const r of t.enum)u(r,e)}}function u(t,r){if("string"!=typeof t||t in e)throw new Error(`discriminator: "${a}" values must be unique strings`);e[t]=r}}();e.if(!1);for(const t in r)e.elseIf(du._`${u} === ${t}`),e.assign(h,l(r[t]));e.else(),t.error(!1,{discrError:af.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}(),()=>t.error(!1,{discrError:af.DiscrError.Tag,tag:u,tagName:a})),t.ok(h)}},uf=Object.defineProperty({default:hf},"__esModule",{value:!0}),lf={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0},ff=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;const r=["/properties"],n="http://json-schema.org/draft-07/schema";class i extends $u.default{_addVocabularies(){super._addVocabularies(),sf.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(uf.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const t=this.opts.$data?this.$dataMetaSchema(lf,r):lf;this.addMetaSchema(t,n,!1),this.refs["http://json-schema.org/schema"]=n}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(n)?n:void 0)}}t.exports=e=i,Object.defineProperty(e,"__esModule",{value:!0}),e.default=i,Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return Pu.KeywordCxt}}),Object.defineProperty(e,"_",{enumerable:!0,get:function(){return du._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return du.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return du.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return du.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return du.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return du.CodeGen}})})),cf=s(ff),df=h((function(t,e){function r(t,e){return{validate:t,compare:e}}Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0,e.fullFormats={date:r(o,s),time:r(h,u),"date-time":r((function(t){const e=t.split(l);return 2===e.length&&o(e[0])&&h(e[1],!0)}),f),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:function(t){return c.test(t)&&d.test(t)},"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:function(t){if(p.test(t))return!1;try{return new RegExp(t),!0}catch(t){return!1}},uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm,int32:{type:"number",validate:function(t){return Number.isInteger(t)&&t<=2147483647&&t>=-2147483648}},int64:{type:"number",validate:function(t){return Number.isInteger(t)}},float:{type:"number",validate:m},double:{type:"number",validate:m},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:r(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,s),time:r(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"date-time":r(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,f),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);const n=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function o(t){const e=n.exec(t);if(!e)return!1;const r=+e[1],o=+e[2],s=+e[3];return o>=1&&o<=12&&s>=1&&s<=(2===o&&function(t){return t%4==0&&(t%100!=0||t%400==0)}(r)?29:i[o])}function s(t,e){if(t&&e)return t>e?1:t<e?-1:0}const a=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function h(t,e){const r=a.exec(t);if(!r)return!1;const n=+r[1],i=+r[2],o=+r[3],s=r[5];return(n<=23&&i<=59&&o<=59||23===n&&59===i&&60===o)&&(!e||""!==s)}function u(t,e){if(!t||!e)return;const r=a.exec(t),n=a.exec(e);return r&&n?(t=r[1]+r[2]+r[3]+(r[4]||""))>(e=n[1]+n[2]+n[3]+(n[4]||""))?1:t<e?-1:0:void 0}const l=/t|\s/i;function f(t,e){if(!t||!e)return;const[r,n]=t.split(l),[i,o]=e.split(l),a=s(r,i);return void 0!==a?a||u(n,o):void 0}const c=/\/|:/,d=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function m(){return!0}const p=/[^\\]\\Z/})),mf=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const r=du.operators,n={formatMaximum:{okStr:"<=",ok:r.LTE,fail:r.GT},formatMinimum:{okStr:">=",ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:"<",ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:">",ok:r.GT,fail:r.LTE}},i={message:({keyword:t,schemaCode:e})=>du.str`should be ${n[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>du._`{comparison: ${n[t].okStr}, limit: ${e}}`};e.formatLimitDefinition={keyword:Object.keys(n),type:"string",schemaType:"string",$data:!0,error:i,code(t){const{gen:e,data:r,schemaCode:i,keyword:o,it:s}=t,{opts:a,self:h}=s;if(!a.validateFormats)return;const u=new ff.KeywordCxt(s,h.RULES.all.format.definition,"format");function l(t){return du._`${t}.compare(${r}, ${i}) ${n[o].fail} 0`}u.$data?function(){const r=e.scopeValue("formats",{ref:h.formats,code:a.code.formats}),n=e.const("fmt",du._`${r}[${u.schemaCode}]`);t.fail$data(du.or(du._`typeof ${n} != "object"`,du._`${n} instanceof RegExp`,du._`typeof ${n}.compare != "function"`,l(n)))}():function(){const r=u.schema,n=h.formats[r];if(!n||!0===n)return;if("object"!=typeof n||n instanceof RegExp||"function"!=typeof n.compare)throw new Error(`"${o}": format "${r}" does not define "compare" function`);const i=e.scopeValue("formats",{key:r,ref:n,code:a.code.formats?du._`${a.code.formats}${du.getProperty(r)}`:void 0});t.fail$data(l(i))}()},dependencies:["format"]};e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)})),pf=s(h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=new du.Name("fullFormats"),n=new du.Name("fastFormats"),i=(t,e={keywords:!0})=>{if(Array.isArray(e))return o(t,e,df.fullFormats,r),t;const[i,s]="fast"===e.mode?[df.fastFormats,n]:[df.fullFormats,r];return o(t,e.formats||df.formatNames,i,s),e.keywords&&mf.default(t),t};function o(t,e,r,n){var i,o;null!==(i=(o=t.opts.code).formats)&&void 0!==i||(o.formats=du._`require("ajv-formats/dist/formats").${n}`);for(const n of e)t.addFormat(n,r[n])}i.get=(t,e="full")=>{const r=("fast"===e?df.fastFormats:df.fullFormats)[t];if(!r)throw new Error(`Unknown format "${t}"`);return r},t.exports=e=i,Object.defineProperty(e,"__esModule",{value:!0}),e.default=i}))),gf="[object GeneratorFunction]",yf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,vf=/^\w*$/,wf=/^\./,bf=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ef=/\\(\\)?/g,Mf=/^\[object .+?Constructor\]$/,_f=/^(?:0|[1-9]\d*)$/,Af="object"==typeof o&&o&&o.Object===Object&&o,Nf="object"==typeof self&&self&&self.Object===Object&&self,Sf=Af||Nf||Function("return this")();var Rf,Uf=Array.prototype,If=Function.prototype,Pf=Object.prototype,xf=Sf["__core-js_shared__"],kf=(Rf=/[^.]+$/.exec(xf&&xf.keys&&xf.keys.IE_PROTO||""))?"Symbol(src)_1."+Rf:"",Tf=If.toString,Of=Pf.hasOwnProperty,Cf=Pf.toString,Ff=RegExp("^"+Tf.call(Of).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Df=Sf.Symbol,Lf=Uf.splice,$f=Jf(Sf,"Map"),Bf=Jf(Object,"create"),jf=Df?Df.prototype:void 0,zf=jf?jf.toString:void 0;function Gf(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function qf(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Vf(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Kf(t,e,r){var n=t[e];Of.call(t,e)&&rc(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function Wf(t,e){for(var r=t.length;r--;)if(rc(t[r][0],e))return r;return-1}function Hf(t){return!(!ic(t)||(e=t,kf&&kf in e))&&(function(t){var e=ic(t)?Cf.call(t):"";return"[object Function]"==e||e==gf}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?Ff:Mf).test(function(t){if(null!=t){try{return Tf.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function Zf(t,e,r,n){if(!ic(t))return t;for(var i=-1,o=(e=function(t,e){if(nc(t))return!1;var r=typeof t;if("number"==r||"symbol"==r||"boolean"==r||null==t||oc(t))return!0;return vf.test(t)||!yf.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:function(t){return nc(t)?t:Qf(t)}(e)).length,s=o-1,a=t;null!=a&&++i<o;){var h=tc(e[i]),u=r;if(i!=s){var l=a[h];void 0===(u=n?n(l,h,a):void 0)&&(u=ic(l)?l:Yf(e[i+1])?[]:{})}Kf(a,h,u),a=a[h]}return t}function Xf(t,e){var r=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?r["string"==typeof e?"string":"hash"]:r.map}function Jf(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Hf(r)?r:void 0}function Yf(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||_f.test(t))&&t>-1&&t%1==0&&t<e}Gf.prototype.clear=function(){this.__data__=Bf?Bf(null):{}},Gf.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Gf.prototype.get=function(t){var e=this.__data__;if(Bf){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return Of.call(e,t)?e[t]:void 0},Gf.prototype.has=function(t){var e=this.__data__;return Bf?void 0!==e[t]:Of.call(e,t)},Gf.prototype.set=function(t,e){return this.__data__[t]=Bf&&void 0===e?"__lodash_hash_undefined__":e,this},qf.prototype.clear=function(){this.__data__=[]},qf.prototype.delete=function(t){var e=this.__data__,r=Wf(e,t);return!(r<0)&&(r==e.length-1?e.pop():Lf.call(e,r,1),!0)},qf.prototype.get=function(t){var e=this.__data__,r=Wf(e,t);return r<0?void 0:e[r][1]},qf.prototype.has=function(t){return Wf(this.__data__,t)>-1},qf.prototype.set=function(t,e){var r=this.__data__,n=Wf(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},Vf.prototype.clear=function(){this.__data__={hash:new Gf,map:new($f||qf),string:new Gf}},Vf.prototype.delete=function(t){return Xf(this,t).delete(t)},Vf.prototype.get=function(t){return Xf(this,t).get(t)},Vf.prototype.has=function(t){return Xf(this,t).has(t)},Vf.prototype.set=function(t,e){return Xf(this,t).set(t,e),this};var Qf=ec((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(oc(t))return zf?zf.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var r=[];return wf.test(t)&&r.push(""),t.replace(bf,(function(t,e,n,i){r.push(n?i.replace(Ef,"$1"):e||t)})),r}));function tc(t){if("string"==typeof t||oc(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e}function ec(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=t.apply(this,n);return r.cache=o.set(i,s),s};return r.cache=new(ec.Cache||Vf),r}function rc(t,e){return t===e||t!=t&&e!=e}ec.Cache=Vf;var nc=Array.isArray;function ic(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function oc(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==Cf.call(t)}var sc=function(t,e,r){return null==t?t:Zf(t,e,r)},ac=function(){function t(t,e,r,n){this.options={},this.calls=[],this.paths=[],this.network=t,this.provider=e,this.abi=r,this.options=n||{}}return t.prototype.call=function(t,e,r,n){return this.calls.push([e,r,n]),this.paths.push(t),this},t.prototype.execute=function(t){return e(this,void 0,void 0,(function(){var e,n=this;return r(this,(function(r){switch(r.label){case 0:return e=t||{},[4,xb(this.network,this.provider,this.abi,this.calls,this.options)];case 1:return r.sent().forEach((function(t,r){return sc(e,n.paths[r],t.length>1?t:t[0])})),this.calls=[],this.paths=[],[2,e]}}))}))},t}();let hc=!1,uc=!1;const lc={debug:1,default:2,info:2,warning:3,error:4,off:5};let fc=lc.default,cc=null;const dc=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),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 mc,pc;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(mc||(mc={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(pc||(pc={}));class gc{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==lc[r]&&this.throwArgumentError("invalid log level name","logLevel",t),fc>lc[r]||console.log.apply(console,e)}debug(...t){this._log(gc.levels.DEBUG,t)}info(...t){this._log(gc.levels.INFO,t)}warn(...t){this._log(gc.levels.WARNING,t)}makeError(t,e,r){if(uc)return this.makeError("censored error",e,{});e||(e=gc.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;n.length&&(t+=" ("+n.join(", ")+")");const o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,gc.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){dc&&this.throwError("platform missing String.prototype.normalize",gc.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:dc})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,gc.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,gc.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,gc.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,gc.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",gc.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",gc.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",gc.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return cc||(cc=new gc("logger/5.3.0")),cc}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",gc.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),hc){if(!t)return;this.globalLogger().throwError("error censorship permanent",gc.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}uc=!!t,hc=!!e}static setLogLevel(t){const e=lc[t.toLowerCase()];null!=e?fc=e:gc.globalLogger().warn("invalid log level - "+t)}static from(t){return new gc(t)}}gc.errors=pc,gc.levels=mc;const yc=new gc("networks/5.3.1");function vc(t){const e=function(e,r){null==r&&(r={});const n=[];if(e.InfuraProvider)try{n.push(new e.InfuraProvider(t,r.infura))}catch(t){}if(e.EtherscanProvider)try{n.push(new e.EtherscanProvider(t,r.etherscan))}catch(t){}if(e.AlchemyProvider)try{n.push(new e.AlchemyProvider(t,r.alchemy))}catch(t){}if(e.CloudflareProvider)try{n.push(new e.CloudflareProvider(t))}catch(t){}if(0===n.length)return null;if(e.FallbackProvider){let i=1;return null!=r.quorum?i=r.quorum:"homestead"===t&&(i=2),new e.FallbackProvider(n,i)}return n[0]};return e.renetwork=function(t){return vc(t)},e}function wc(t,e){const r=function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(t,e):null};return r.renetwork=function(e){return wc(t,e)},r}const bc={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:vc("homestead")},Ec={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:vc("ropsten")},Mc={chainId:63,name:"classicMordor",_defaultProvider:wc("https://www.ethercluster.com/mordor","classicMordor")},_c={unspecified:{chainId:0,name:"unspecified"},homestead:bc,mainnet:bc,morden:{chainId:2,name:"morden"},ropsten:Ec,testnet:Ec,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:vc("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:vc("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:vc("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:wc("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:Mc,classicTestnet:Mc,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:wc("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic"},maticmum:{chainId:80001,name:"maticmum"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};let Ac=!1,Nc=!1;const Sc={debug:1,default:2,info:2,warning:3,error:4,off:5};let Rc=Sc.default,Uc=null;const Ic=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),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 Pc,xc;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(Pc||(Pc={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(xc||(xc={}));class kc{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==Sc[r]&&this.throwArgumentError("invalid log level name","logLevel",t),Rc>Sc[r]||console.log.apply(console,e)}debug(...t){this._log(kc.levels.DEBUG,t)}info(...t){this._log(kc.levels.INFO,t)}warn(...t){this._log(kc.levels.WARNING,t)}makeError(t,e,r){if(Nc)return this.makeError("censored error",e,{});e||(e=kc.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;n.length&&(t+=" ("+n.join(", ")+")");const o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,kc.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){Ic&&this.throwError("platform missing String.prototype.normalize",kc.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Ic})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,kc.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,kc.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,kc.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,kc.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",kc.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",kc.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",kc.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Uc||(Uc=new kc("logger/5.3.0")),Uc}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",kc.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Ac){if(!t)return;this.globalLogger().throwError("error censorship permanent",kc.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Nc=!!t,Ac=!!e}static setLogLevel(t){const e=Sc[t.toLowerCase()];null!=e?Rc=e:kc.globalLogger().warn("invalid log level - "+t)}static from(t){return new kc(t)}}kc.errors=xc,kc.levels=Pc;const Tc=new kc("bytes/5.3.0");function Oc(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Oc(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Cc(t,e){if(e||(e={}),"number"==typeof t){Tc.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),Oc(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){if("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))return!1;if(e&&t.length!==2+2*e)return!1;return!0}(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":Tc.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return Oc(new Uint8Array(n))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}(t)?Oc(new Uint8Array(t)):Tc.throwArgumentError("invalid arrayify value","value",t)}window&&window.__awaiter;new kc("properties/5.3.0");function Fc(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}class Dc{constructor(t){Fc(this,"alphabet",t),Fc(this,"base",t.length),Fc(this,"_alphabetMap",{}),Fc(this,"_leader",t.charAt(0));for(let e=0;e<t.length;e++)this._alphabetMap[t.charAt(e)]=e}encode(t){let e=Cc(t);if(0===e.length)return"";let r=[0];for(let t=0;t<e.length;++t){let n=e[t];for(let t=0;t<r.length;++t)n+=r[t]<<8,r[t]=n%this.base,n=n/this.base|0;for(;n>0;)r.push(n%this.base),n=n/this.base|0}let n="";for(let t=0;0===e[t]&&t<e.length-1;++t)n+=this._leader;for(let t=r.length-1;t>=0;--t)n+=this.alphabet[r[t]];return n}decode(t){if("string"!=typeof t)throw new TypeError("Expected String");let e=[];if(0===t.length)return new Uint8Array(e);e.push(0);for(let r=0;r<t.length;r++){let n=this._alphabetMap[t[r]];if(void 0===n)throw new Error("Non-base"+this.base+" character");let i=n;for(let t=0;t<e.length;++t)i+=e[t]*this.base,e[t]=255&i,i>>=8;for(;i>0;)e.push(255&i),i>>=8}for(let r=0;t[r]===this._leader&&r<t.length-1;++r)e.push(0);return Cc(new Uint8Array(e.reverse()))}}new Dc("abcdefghijklmnopqrstuvwxyz234567");const Lc=new Dc("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");let $c=!1,Bc=!1;const jc={debug:1,default:2,info:2,warning:3,error:4,off:5};let zc=jc.default,Gc=null;const qc=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),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 Vc,Kc;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(Vc||(Vc={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(Kc||(Kc={}));class Wc{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==jc[r]&&this.throwArgumentError("invalid log level name","logLevel",t),zc>jc[r]||console.log.apply(console,e)}debug(...t){this._log(Wc.levels.DEBUG,t)}info(...t){this._log(Wc.levels.INFO,t)}warn(...t){this._log(Wc.levels.WARNING,t)}makeError(t,e,r){if(Bc)return this.makeError("censored error",e,{});e||(e=Wc.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;n.length&&(t+=" ("+n.join(", ")+")");const o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Wc.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){qc&&this.throwError("platform missing String.prototype.normalize",Wc.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:qc})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Wc.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Wc.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,Wc.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Wc.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",Wc.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Wc.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",Wc.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Gc||(Gc=new Wc("logger/5.3.0")),Gc}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Wc.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),$c){if(!t)return;this.globalLogger().throwError("error censorship permanent",Wc.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Bc=!!t,$c=!!e}static setLogLevel(t){const e=jc[t.toLowerCase()];null!=e?zc=e:Wc.globalLogger().warn("invalid log level - "+t)}static from(t){return new Wc(t)}}Wc.errors=Kc,Wc.levels=Vc;const Hc=new Wc("bytes/5.3.0");function Zc(t){return!!t.toHexString}function Xc(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Xc(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Jc(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}function Yc(t,e){if(e||(e={}),"number"==typeof t){Hc.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),Xc(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Zc(t)&&(t=t.toHexString()),ed(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":Hc.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return Xc(new Uint8Array(n))}return Jc(t)?Xc(new Uint8Array(t)):Hc.throwArgumentError("invalid arrayify value","value",t)}function Qc(t){const e=t.map(t=>Yc(t)),r=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(r);return e.reduce((t,e)=>(n.set(e,t),t+e.length),0),Xc(n)}function td(t){let e=Yc(t);if(0===e.length)return e;let r=0;for(;r<e.length&&0===e[r];)r++;return r&&(e=e.slice(r)),e}function ed(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}function rd(t,e){if(e||(e={}),"number"==typeof t){Hc.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Zc(t))return t.toHexString();if(ed(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":Hc.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(Jc(t)){let e="0x";for(let r=0;r<t.length;r++){let n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return Hc.throwArgumentError("invalid hexlify value","value",t)}function nd(t){if("string"!=typeof t)t=rd(t);else if(!ed(t)||t.length%2)return null;return(t.length-2)/2}function id(t,e,r){return"string"!=typeof t?t=rd(t):(!ed(t)||t.length%2)&&Hc.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function od(t){let e="0x";return t.forEach(t=>{e+=rd(t).substring(2)}),e}function sd(t){const e=function(t){"string"!=typeof t&&(t=rd(t));ed(t)||Hc.throwArgumentError("invalid hex string","value",t);t=t.substring(2);let e=0;for(;e<t.length&&"0"===t[e];)e++;return"0x"+t.substring(e)}(rd(t,{hexPad:"left"}));return"0x"===e?"0x0":e}function ad(t,e){for("string"!=typeof t?t=rd(t):ed(t)||Hc.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&Hc.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function hd(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(ed(r=t)&&!(r.length%2)||Jc(r)){const r=Yc(t);65!==r.length&&Hc.throwArgumentError("invalid signature string; must be 65 bytes","signature",t),e.r=rd(r.slice(0,32)),e.s=rd(r.slice(32,64)),e.v=r[64],e.v<27&&(0===e.v||1===e.v?e.v+=27:Hc.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=rd(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e._vs){const r=function(t,e){(t=Yc(t)).length>e&&Hc.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),Xc(r)}(Yc(e._vs),32);e._vs=rd(r);const n=r[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=n:e.recoveryParam!==n&&Hc.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),r[0]&=127;const i=rd(r);null==e.s?e.s=i:e.s!==i&&Hc.throwArgumentError("signature v mismatch _vs","signature",t)}null==e.recoveryParam?null==e.v?Hc.throwArgumentError("signature missing v and recoveryParam","signature",t):0===e.v||1===e.v?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2:null==e.v?e.v=27+e.recoveryParam:e.recoveryParam!==1-e.v%2&&Hc.throwArgumentError("signature recoveryParam mismatch v","signature",t),null!=e.r&&ed(e.r)?e.r=ad(e.r,32):Hc.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&ed(e.s)?e.s=ad(e.s,32):Hc.throwArgumentError("signature missing or invalid s","signature",t);const r=Yc(e.s);r[0]>=128&&Hc.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const n=rd(r);e._vs&&(ed(e._vs)||Hc.throwArgumentError("signature invalid _vs","signature",t),e._vs=ad(e._vs,32)),null==e._vs?e._vs=n:e._vs!==n&&Hc.throwArgumentError("signature _vs mismatch v and s","signature",t)}var r;return e}var ud=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const ld=new Wc("properties/5.3.0");function fd(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function cd(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||"object"!=typeof t.prototype)break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function dd(t){return ud(this,void 0,void 0,(function*(){const e=Object.keys(t).map(e=>{const r=t[e];return Promise.resolve(r).then(t=>({key:e,value:t}))});return(yield Promise.all(e)).reduce((t,e)=>(t[e.key]=e.value,t),{})}))}function md(t){const e={};for(const r in t)e[r]=t[r];return e}const pd={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function gd(t){if(function t(e){if(null==e||pd[typeof e])return!0;if(Array.isArray(e)||"object"==typeof e){if(!Object.isFrozen(e))return!1;const r=Object.keys(e);for(let n=0;n<r.length;n++)if(!t(e[r[n]]))return!1;return!0}return ld.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}(t))return t;if(Array.isArray(t))return Object.freeze(t.map(t=>yd(t)));if("object"==typeof t){const e={};for(const r in t){const n=t[r];void 0!==n&&fd(e,r,yd(n))}return e}return ld.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function yd(t){return gd(t)}var vd=wd;function wd(t,e){if(!t)throw new Error(e||"Assertion failed")}function bd(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function Ed(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function Md(t){return 1===t.length?"0"+t:t}function _d(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}wd.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var Ad={inherits:h((function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}})),toArray:function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(var n=0,i=0;i<t.length;i++){var o=t.charCodeAt(i);o<128?r[n++]=o:o<2048?(r[n++]=o>>6|192,r[n++]=63&o|128):bd(t,i)?(o=65536+((1023&o)<<10)+(1023&t.charCodeAt(++i)),r[n++]=o>>18|240,r[n++]=o>>12&63|128,r[n++]=o>>6&63|128,r[n++]=63&o|128):(r[n++]=o>>12|224,r[n++]=o>>6&63|128,r[n++]=63&o|128)}else for(i=0;i<t.length;i++)r[i]=0|t[i];return r},toHex:function(t){for(var e="",r=0;r<t.length;r++)e+=Md(t[r].toString(16));return e},htonl:Ed,toHex32:function(t,e){for(var r="",n=0;n<t.length;n++){var i=t[n];"little"===e&&(i=Ed(i)),r+=_d(i.toString(16))}return r},zero2:Md,zero8:_d,join32:function(t,e,r,n){var i=r-e;vd(i%4==0);for(var o=new Array(i/4),s=0,a=e;s<o.length;s++,a+=4){var h;h="big"===n?t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]:t[a+3]<<24|t[a+2]<<16|t[a+1]<<8|t[a],o[s]=h>>>0}return o},split32:function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n<t.length;n++,i+=4){var o=t[n];"big"===e?(r[i]=o>>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},rotr32:function(t,e){return t>>>e|t<<32-e},rotl32:function(t,e){return t<<e|t>>>32-e},sum32:function(t,e){return t+e>>>0},sum32_3:function(t,e,r){return t+e+r>>>0},sum32_4:function(t,e,r,n){return t+e+r+n>>>0},sum32_5:function(t,e,r,n,i){return t+e+r+n+i>>>0},sum64:function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o<n?1:0)+r+i;t[e]=s>>>0,t[e+1]=o},sum64_hi:function(t,e,r,n){return(e+n>>>0<e?1:0)+t+r>>>0},sum64_lo:function(t,e,r,n){return e+n>>>0},sum64_4_hi:function(t,e,r,n,i,o,s,a){var h=0,u=e;return h+=(u=u+n>>>0)<e?1:0,h+=(u=u+o>>>0)<o?1:0,t+r+i+s+(h+=(u=u+a>>>0)<a?1:0)>>>0},sum64_4_lo:function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},sum64_5_hi:function(t,e,r,n,i,o,s,a,h,u){var l=0,f=e;return l+=(f=f+n>>>0)<e?1:0,l+=(f=f+o>>>0)<o?1:0,l+=(f=f+a>>>0)<a?1:0,t+r+i+s+h+(l+=(f=f+u>>>0)<u?1:0)>>>0},sum64_5_lo:function(t,e,r,n,i,o,s,a,h,u){return e+n+o+a+u>>>0},rotr64_hi:function(t,e,r){return(e<<32-r|t>>>r)>>>0},rotr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0},shr64_hi:function(t,e,r){return t>>>r},shr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0}};function Nd(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var Sd=Nd;Nd.prototype.update=function(t,e){if(t=Ad.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=Ad.join32(t,0,t.length-r,this.endian);for(var n=0;n<t.length;n+=this._delta32)this._update(t,n,n+this._delta32)}return this},Nd.prototype.digest=function(t){return this.update(this._pad()),vd(null===this.pending),this._digest(t)},Nd.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,n=new Array(r+this.padLength);n[0]=128;for(var i=1;i<r;i++)n[i]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)n[i++]=0;n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=t>>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o<this.padLength;o++)n[i++]=0;return n};var Rd={BlockHash:Sd},Ud=Ad.rotr32;function Id(t,e,r){return t&e^~t&r}function Pd(t,e,r){return t&e^t&r^e&r}function xd(t,e,r){return t^e^r}var kd={ft_1:function(t,e,r,n){return 0===t?Id(e,r,n):1===t||3===t?xd(e,r,n):2===t?Pd(e,r,n):void 0},ch32:Id,maj32:Pd,p32:xd,s0_256:function(t){return Ud(t,2)^Ud(t,13)^Ud(t,22)},s1_256:function(t){return Ud(t,6)^Ud(t,11)^Ud(t,25)},g0_256:function(t){return Ud(t,7)^Ud(t,18)^t>>>3},g1_256:function(t){return Ud(t,17)^Ud(t,19)^t>>>10}},Td=Ad.rotl32,Od=Ad.sum32,Cd=Ad.sum32_5,Fd=kd.ft_1,Dd=Rd.BlockHash,Ld=[1518500249,1859775393,2400959708,3395469782];function $d(){if(!(this instanceof $d))return new $d;Dd.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Ad.inherits($d,Dd);var Bd=$d;$d.blockSize=512,$d.outSize=160,$d.hmacStrength=80,$d.padLength=64,$d.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n<r.length;n++)r[n]=Td(r[n-3]^r[n-8]^r[n-14]^r[n-16],1);var i=this.h[0],o=this.h[1],s=this.h[2],a=this.h[3],h=this.h[4];for(n=0;n<r.length;n++){var u=~~(n/20),l=Cd(Td(i,5),Fd(u,o,s,a),h,r[n],Ld[u]);h=a,a=s,s=Td(o,30),o=i,i=l}this.h[0]=Od(this.h[0],i),this.h[1]=Od(this.h[1],o),this.h[2]=Od(this.h[2],s),this.h[3]=Od(this.h[3],a),this.h[4]=Od(this.h[4],h)},$d.prototype._digest=function(t){return"hex"===t?Ad.toHex32(this.h,"big"):Ad.split32(this.h,"big")};var jd=Ad.sum32,zd=Ad.sum32_4,Gd=Ad.sum32_5,qd=kd.ch32,Vd=kd.maj32,Kd=kd.s0_256,Wd=kd.s1_256,Hd=kd.g0_256,Zd=kd.g1_256,Xd=Rd.BlockHash,Jd=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Yd(){if(!(this instanceof Yd))return new Yd;Xd.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Jd,this.W=new Array(64)}Ad.inherits(Yd,Xd);var Qd=Yd;function tm(){if(!(this instanceof tm))return new tm;Qd.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Yd.blockSize=512,Yd.outSize=256,Yd.hmacStrength=192,Yd.padLength=64,Yd.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n<r.length;n++)r[n]=zd(Zd(r[n-2]),r[n-7],Hd(r[n-15]),r[n-16]);var i=this.h[0],o=this.h[1],s=this.h[2],a=this.h[3],h=this.h[4],u=this.h[5],l=this.h[6],f=this.h[7];for(vd(this.k.length===r.length),n=0;n<r.length;n++){var c=Gd(f,Wd(h),qd(h,u,l),this.k[n],r[n]),d=jd(Kd(i),Vd(i,o,s));f=l,l=u,u=h,h=jd(a,c),a=s,s=o,o=i,i=jd(c,d)}this.h[0]=jd(this.h[0],i),this.h[1]=jd(this.h[1],o),this.h[2]=jd(this.h[2],s),this.h[3]=jd(this.h[3],a),this.h[4]=jd(this.h[4],h),this.h[5]=jd(this.h[5],u),this.h[6]=jd(this.h[6],l),this.h[7]=jd(this.h[7],f)},Yd.prototype._digest=function(t){return"hex"===t?Ad.toHex32(this.h,"big"):Ad.split32(this.h,"big")},Ad.inherits(tm,Qd);var em=tm;tm.blockSize=512,tm.outSize=224,tm.hmacStrength=192,tm.padLength=64,tm.prototype._digest=function(t){return"hex"===t?Ad.toHex32(this.h.slice(0,7),"big"):Ad.split32(this.h.slice(0,7),"big")};var rm=Ad.rotr64_hi,nm=Ad.rotr64_lo,im=Ad.shr64_hi,om=Ad.shr64_lo,sm=Ad.sum64,am=Ad.sum64_hi,hm=Ad.sum64_lo,um=Ad.sum64_4_hi,lm=Ad.sum64_4_lo,fm=Ad.sum64_5_hi,cm=Ad.sum64_5_lo,dm=Rd.BlockHash,mm=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function pm(){if(!(this instanceof pm))return new pm;dm.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=mm,this.W=new Array(160)}Ad.inherits(pm,dm);var gm=pm;function ym(t,e,r,n,i){var o=t&r^~t&i;return o<0&&(o+=4294967296),o}function vm(t,e,r,n,i,o){var s=e&n^~e&o;return s<0&&(s+=4294967296),s}function wm(t,e,r,n,i){var o=t&r^t&i^r&i;return o<0&&(o+=4294967296),o}function bm(t,e,r,n,i,o){var s=e&n^e&o^n&o;return s<0&&(s+=4294967296),s}function Em(t,e){var r=rm(t,e,28)^rm(e,t,2)^rm(e,t,7);return r<0&&(r+=4294967296),r}function Mm(t,e){var r=nm(t,e,28)^nm(e,t,2)^nm(e,t,7);return r<0&&(r+=4294967296),r}function _m(t,e){var r=rm(t,e,14)^rm(t,e,18)^rm(e,t,9);return r<0&&(r+=4294967296),r}function Am(t,e){var r=nm(t,e,14)^nm(t,e,18)^nm(e,t,9);return r<0&&(r+=4294967296),r}function Nm(t,e){var r=rm(t,e,1)^rm(t,e,8)^im(t,e,7);return r<0&&(r+=4294967296),r}function Sm(t,e){var r=nm(t,e,1)^nm(t,e,8)^om(t,e,7);return r<0&&(r+=4294967296),r}function Rm(t,e){var r=rm(t,e,19)^rm(e,t,29)^im(t,e,6);return r<0&&(r+=4294967296),r}function Um(t,e){var r=nm(t,e,19)^nm(e,t,29)^om(t,e,6);return r<0&&(r+=4294967296),r}function Im(){if(!(this instanceof Im))return new Im;gm.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}pm.blockSize=1024,pm.outSize=512,pm.hmacStrength=192,pm.padLength=128,pm.prototype._prepareBlock=function(t,e){for(var r=this.W,n=0;n<32;n++)r[n]=t[e+n];for(;n<r.length;n+=2){var i=Rm(r[n-4],r[n-3]),o=Um(r[n-4],r[n-3]),s=r[n-14],a=r[n-13],h=Nm(r[n-30],r[n-29]),u=Sm(r[n-30],r[n-29]),l=r[n-32],f=r[n-31];r[n]=um(i,o,s,a,h,u,l,f),r[n+1]=lm(i,o,s,a,h,u,l,f)}},pm.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,n=this.h[0],i=this.h[1],o=this.h[2],s=this.h[3],a=this.h[4],h=this.h[5],u=this.h[6],l=this.h[7],f=this.h[8],c=this.h[9],d=this.h[10],m=this.h[11],p=this.h[12],g=this.h[13],y=this.h[14],v=this.h[15];vd(this.k.length===r.length);for(var w=0;w<r.length;w+=2){var b=y,E=v,M=_m(f,c),_=Am(f,c),A=ym(f,c,d,m,p),N=vm(f,c,d,m,p,g),S=this.k[w],R=this.k[w+1],U=r[w],I=r[w+1],P=fm(b,E,M,_,A,N,S,R,U,I),x=cm(b,E,M,_,A,N,S,R,U,I);b=Em(n,i),E=Mm(n,i),M=wm(n,i,o,s,a),_=bm(n,i,o,s,a,h);var k=am(b,E,M,_),T=hm(b,E,M,_);y=p,v=g,p=d,g=m,d=f,m=c,f=am(u,l,P,x),c=hm(l,l,P,x),u=a,l=h,a=o,h=s,o=n,s=i,n=am(P,x,k,T),i=hm(P,x,k,T)}sm(this.h,0,n,i),sm(this.h,2,o,s),sm(this.h,4,a,h),sm(this.h,6,u,l),sm(this.h,8,f,c),sm(this.h,10,d,m),sm(this.h,12,p,g),sm(this.h,14,y,v)},pm.prototype._digest=function(t){return"hex"===t?Ad.toHex32(this.h,"big"):Ad.split32(this.h,"big")},Ad.inherits(Im,gm);var Pm=Im;Im.blockSize=1024,Im.outSize=384,Im.hmacStrength=192,Im.padLength=128,Im.prototype._digest=function(t){return"hex"===t?Ad.toHex32(this.h.slice(0,12),"big"):Ad.split32(this.h.slice(0,12),"big")};var xm={sha1:Bd,sha224:em,sha256:Qd,sha384:Pm,sha512:gm},km=Ad.rotl32,Tm=Ad.sum32,Om=Ad.sum32_3,Cm=Ad.sum32_4,Fm=Rd.BlockHash;function Dm(){if(!(this instanceof Dm))return new Dm;Fm.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Ad.inherits(Dm,Fm);var Lm=Dm;function $m(t,e,r,n){return t<=15?e^r^n:t<=31?e&r|~e&n:t<=47?(e|~r)^n:t<=63?e&n|r&~n:e^(r|~n)}function Bm(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function jm(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}Dm.blockSize=512,Dm.outSize=160,Dm.hmacStrength=192,Dm.padLength=64,Dm.prototype._update=function(t,e){for(var r=this.h[0],n=this.h[1],i=this.h[2],o=this.h[3],s=this.h[4],a=r,h=n,u=i,l=o,f=s,c=0;c<80;c++){var d=Tm(km(Cm(r,$m(c,n,i,o),t[zm[c]+e],Bm(c)),qm[c]),s);r=s,s=o,o=km(i,10),i=n,n=d,d=Tm(km(Cm(a,$m(79-c,h,u,l),t[Gm[c]+e],jm(c)),Vm[c]),f),a=f,f=l,l=km(u,10),u=h,h=d}d=Om(this.h[1],i,l),this.h[1]=Om(this.h[2],o,f),this.h[2]=Om(this.h[3],s,a),this.h[3]=Om(this.h[4],r,h),this.h[4]=Om(this.h[0],n,u),this.h[0]=d},Dm.prototype._digest=function(t){return"hex"===t?Ad.toHex32(this.h,"little"):Ad.split32(this.h,"little")};var zm=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],Gm=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],qm=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],Vm=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],Km={ripemd160:Lm};function Wm(t,e,r){if(!(this instanceof Wm))return new Wm(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(Ad.toArray(e,r))}var Hm=Wm;Wm.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),vd(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},Wm.prototype.update=function(t,e){return this.inner.update(t,e),this},Wm.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)};var Zm=h((function(t,e){var r=e;r.utils=Ad,r.common=Rd,r.sha=xm,r.ripemd=Km,r.hmac=Hm,r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160}));new Wc("sha2/5.3.0");function Xm(t){return"0x"+Zm.sha256().update(Yc(t)).digest("hex")}const Jm=new Wc("strings/5.3.0");var Ym,Qm;function tp(t,e,r,n,i){if(t===Qm.BAD_PREFIX||t===Qm.UNEXPECTED_CONTINUE){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return t===Qm.OVERRUN?r.length-e-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(Ym||(Ym={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(Qm||(Qm={}));const ep=Object.freeze({error:function(t,e,r,n,i){return Jm.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:tp,replace:function(t,e,r,n,i){return t===Qm.OVERLONG?(n.push(i),0):(n.push(65533),tp(t,e,r))}});function rp(t,e=Ym.current){e!=Ym.current&&(Jm.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;const i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");const o=65536+((1023&n)<<10)+(1023&i);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return Yc(r)}function np(t,e){return function(t,e){null==e&&(e=ep.error),t=Yc(t);const r=[];let n=0;for(;n<t.length;){const i=t[n++];if(i>>7==0){r.push(i);continue}let o=null,s=null;if(192==(224&i))o=1,s=127;else if(224==(240&i))o=2,s=2047;else{if(240!=(248&i)){n+=e(128==(192&i)?Qm.UNEXPECTED_CONTINUE:Qm.BAD_PREFIX,n-1,t,r);continue}o=3,s=65535}if(n-1+o>=t.length){n+=e(Qm.OVERRUN,n-1,t,r);continue}let a=i&(1<<8-o-1)-1;for(let i=0;i<o;i++){let i=t[n];if(128!=(192&i)){n+=e(Qm.MISSING_CONTINUE,n,t,r),a=null;break}a=a<<6|63&i,n++}null!==a&&(a>1114111?n+=e(Qm.OUT_OF_RANGE,n-1-o,t,r,a):a>=55296&&a<=57343?n+=e(Qm.UTF16_SURROGATE,n-1-o,t,r,a):a<=s?n+=e(Qm.OVERLONG,n-1-o,t,r,a):r.push(a))}return r}(t,e).map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t)))).join("")}let ip=!1,op=!1;const sp={debug:1,default:2,info:2,warning:3,error:4,off:5};let ap=sp.default,hp=null;const up=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),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 lp,fp;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(lp||(lp={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(fp||(fp={}));class cp{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==sp[r]&&this.throwArgumentError("invalid log level name","logLevel",t),ap>sp[r]||console.log.apply(console,e)}debug(...t){this._log(cp.levels.DEBUG,t)}info(...t){this._log(cp.levels.INFO,t)}warn(...t){this._log(cp.levels.WARNING,t)}makeError(t,e,r){if(op)return this.makeError("censored error",e,{});e||(e=cp.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;n.length&&(t+=" ("+n.join(", ")+")");const o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,cp.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){up&&this.throwError("platform missing String.prototype.normalize",cp.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:up})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,cp.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,cp.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,cp.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,cp.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",cp.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",cp.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",cp.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return hp||(hp=new cp("logger/5.3.0")),hp}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",cp.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),ip){if(!t)return;this.globalLogger().throwError("error censorship permanent",cp.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}op=!!t,ip=!!e}static setLogLevel(t){const e=sp[t.toLowerCase()];null!=e?ap=e:cp.globalLogger().warn("invalid log level - "+t)}static from(t){return new cp(t)}}cp.errors=fp,cp.levels=lp;const dp=new cp("bytes/5.3.0");function mp(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return mp(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function pp(t,e){if(e||(e={}),"number"==typeof t){dp.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),mp(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){if("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))return!1;if(e&&t.length!==2+2*e)return!1;return!0}(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":dp.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return mp(new Uint8Array(n))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}(t)?mp(new Uint8Array(t)):dp.throwArgumentError("invalid arrayify value","value",t)}function gp(t){t=pp(t);let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}let yp=!1,vp=!1;const wp={debug:1,default:2,info:2,warning:3,error:4,off:5};let bp=wp.default,Ep=null;const Mp=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),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 _p,Ap;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(_p||(_p={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(Ap||(Ap={}));class Np{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==wp[r]&&this.throwArgumentError("invalid log level name","logLevel",t),bp>wp[r]||console.log.apply(console,e)}debug(...t){this._log(Np.levels.DEBUG,t)}info(...t){this._log(Np.levels.INFO,t)}warn(...t){this._log(Np.levels.WARNING,t)}makeError(t,e,r){if(vp)return this.makeError("censored error",e,{});e||(e=Np.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;n.length&&(t+=" ("+n.join(", ")+")");const o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Np.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){Mp&&this.throwError("platform missing String.prototype.normalize",Np.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Mp})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Np.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Np.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,Np.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Np.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",Np.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Np.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",Np.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Ep||(Ep=new Np("logger/5.3.0")),Ep}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Np.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),yp){if(!t)return;this.globalLogger().throwError("error censorship permanent",Np.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}vp=!!t,yp=!!e}static setLogLevel(t){const e=wp[t.toLowerCase()];null!=e?bp=e:Np.globalLogger().warn("invalid log level - "+t)}static from(t){return new Np(t)}}Np.errors=Ap,Np.levels=_p;const Sp=new Np("bytes/5.3.0");function Rp(t){return!!t.toHexString}function Up(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Up(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Ip(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}function Pp(t,e){if(e||(e={}),"number"==typeof t){Sp.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),Up(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Rp(t)&&(t=t.toHexString()),xp(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":Sp.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return Up(new Uint8Array(n))}return Ip(t)?Up(new Uint8Array(t)):Sp.throwArgumentError("invalid arrayify value","value",t)}function xp(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}window&&window.__awaiter;new Np("properties/5.3.0");function kp(t){const e={};for(const r in t)e[r]=t[r];return e}const Tp=new Np("strings/5.3.0");var Op,Cp;function Fp(t,e,r,n,i){if(t===Cp.BAD_PREFIX||t===Cp.UNEXPECTED_CONTINUE){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return t===Cp.OVERRUN?r.length-e-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(Op||(Op={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(Cp||(Cp={}));const Dp=Object.freeze({error:function(t,e,r,n,i){return Tp.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:Fp,replace:function(t,e,r,n,i){return t===Cp.OVERLONG?(n.push(i),0):(n.push(65533),Fp(t,e,r))}});function Lp(t,e=Op.current){e!=Op.current&&(Tp.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;const i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");const o=65536+((1023&n)<<10)+(1023&i);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return Pp(r)}function $p(t,e){return function(t,e){null==e&&(e=Dp.error),t=Pp(t);const r=[];let n=0;for(;n<t.length;){const i=t[n++];if(i>>7==0){r.push(i);continue}let o=null,s=null;if(192==(224&i))o=1,s=127;else if(224==(240&i))o=2,s=2047;else{if(240!=(248&i)){n+=e(128==(192&i)?Cp.UNEXPECTED_CONTINUE:Cp.BAD_PREFIX,n-1,t,r);continue}o=3,s=65535}if(n-1+o>=t.length){n+=e(Cp.OVERRUN,n-1,t,r);continue}let a=i&(1<<8-o-1)-1;for(let i=0;i<o;i++){let i=t[n];if(128!=(192&i)){n+=e(Cp.MISSING_CONTINUE,n,t,r),a=null;break}a=a<<6|63&i,n++}null!==a&&(a>1114111?n+=e(Cp.OUT_OF_RANGE,n-1-o,t,r,a):a>=55296&&a<=57343?n+=e(Cp.UTF16_SURROGATE,n-1-o,t,r,a):a<=s?n+=e(Cp.OVERLONG,n-1-o,t,r,a):r.push(a))}return r}(t,e).map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t)))).join("")}var Bp=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};function jp(t,e){return Bp(this,void 0,void 0,(function*(){null==e&&(e={});const r={method:e.method||"GET",headers:e.headers||{},body:e.body||void 0,mode:"cors",cache:"no-cache",credentials:"same-origin",redirect:"follow",referrer:"client"},n=yield fetch(t,r),i=yield n.arrayBuffer(),o={};return n.headers.forEach?n.headers.forEach((t,e)=>{o[e.toLowerCase()]=t}):n.headers.keys().forEach(t=>{o[t.toLowerCase()]=n.headers.get(t)}),{headers:o,statusCode:n.status,statusMessage:n.statusText,body:Pp(new Uint8Array(i))}}))}var zp=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const Gp=new Np("web/5.3.0");function qp(t){return new Promise(e=>{setTimeout(e,t)})}function Vp(t,e){if(null==t)return null;if("string"==typeof t)return t;if(function(t){return xp(t)&&!(t.length%2)||Ip(t)}(t)){if(e&&("text"===e.split("/")[0]||"application/json"===e.split(";")[0].trim()))try{return $p(t)}catch(t){}return function(t,e){if(e||(e={}),"number"==typeof t){Sp.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Rp(t))return t.toHexString();if(xp(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":Sp.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(Ip(t)){let e="0x";for(let r=0;r<t.length;r++){let n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return Sp.throwArgumentError("invalid hexlify value","value",t)}(t)}return t}function Kp(t,e,r){let n=null;if(null!=e){n=Lp(e);const r="string"==typeof t?{url:t}:kp(t);if(r.headers){0!==Object.keys(r.headers).filter(t=>"content-type"===t.toLowerCase()).length||(r.headers=kp(r.headers),r.headers["content-type"]="application/json")}else r.headers={"content-type":"application/json"};t=r}return function(t,e,r){const n="object"==typeof t&&null!=t.throttleLimit?t.throttleLimit:12;Gp.assertArgument(n>0&&n%1==0,"invalid connection throttle limit","connection.throttleLimit",n);const i="object"==typeof t?t.throttleCallback:null,o="object"==typeof t&&"number"==typeof t.throttleSlotInterval?t.throttleSlotInterval:100;Gp.assertArgument(o>0&&o%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",o);const s={};let a=null;const h={method:"GET"};let u=!1,l=12e4;if("string"==typeof t)a=t;else if("object"==typeof t){if(null!=t&&null!=t.url||Gp.throwArgumentError("missing URL","connection.url",t),a=t.url,"number"==typeof t.timeout&&t.timeout>0&&(l=t.timeout),t.headers)for(const e in t.headers)s[e.toLowerCase()]={key:e,value:String(t.headers[e])},["if-none-match","if-modified-since"].indexOf(e.toLowerCase())>=0&&(u=!0);if(h.allowGzip=!!t.allowGzip,null!=t.user&&null!=t.password){"https:"!==a.substring(0,6)&&!0!==t.allowInsecureAuthentication&&Gp.throwError("basic authentication requires a secure https url",Np.errors.INVALID_ARGUMENT,{argument:"url",url:a,user:t.user,password:"[REDACTED]"});const e=t.user+":"+t.password;s.authorization={key:"Authorization",value:"Basic "+gp(Lp(e))}}}e&&(h.method="POST",h.body=e,null==s["content-type"]&&(s["content-type"]={key:"Content-Type",value:"application/octet-stream"}),null==s["content-length"]&&(s["content-length"]={key:"Content-Length",value:String(e.length)}));const f={};Object.keys(s).forEach(t=>{const e=s[t];f[e.key]=e.value}),h.headers=f;const c=function(){let t=null;return{promise:new Promise((function(e,r){l&&(t=setTimeout(()=>{null!=t&&(t=null,r(Gp.makeError("timeout",Np.errors.TIMEOUT,{requestBody:Vp(h.body,f["content-type"]),requestMethod:h.method,timeout:l,url:a})))},l))})),cancel:function(){null!=t&&(clearTimeout(t),t=null)}}}(),d=function(){return zp(this,void 0,void 0,(function*(){for(let t=0;t<n;t++){let e=null;try{if(e=yield jp(a,h),429===e.statusCode&&t<n){let r=!0;if(i&&(r=yield i(t,a)),r){let r=0;const n=e.headers["retry-after"];r="string"==typeof n&&n.match(/^[1-9][0-9]*$/)?1e3*parseInt(n):o*parseInt(String(Math.random()*Math.pow(2,t))),yield qp(r);continue}}}catch(t){e=t.response,null==e&&(c.cancel(),Gp.throwError("missing response",Np.errors.SERVER_ERROR,{requestBody:Vp(h.body,f["content-type"]),requestMethod:h.method,serverError:t,url:a}))}let s=e.body;if(u&&304===e.statusCode?s=null:(e.statusCode<200||e.statusCode>=300)&&(c.cancel(),Gp.throwError("bad response",Np.errors.SERVER_ERROR,{status:e.statusCode,headers:e.headers,body:Vp(s,e.headers?e.headers["content-type"]:null),requestBody:Vp(h.body,f["content-type"]),requestMethod:h.method,url:a})),r)try{const t=yield r(s,e);return c.cancel(),t}catch(r){if(r.throttleRetry&&t<n){let e=!0;if(i&&(e=yield i(t,a)),e){const e=o*parseInt(String(Math.random()*Math.pow(2,t)));yield qp(e);continue}}c.cancel(),Gp.throwError("processing response error",Np.errors.SERVER_ERROR,{body:Vp(s,e.headers?e.headers["content-type"]:null),error:r,requestBody:Vp(h.body,f["content-type"]),requestMethod:h.method,url:a})}return c.cancel(),s}return Gp.throwError("failed response",Np.errors.SERVER_ERROR,{requestBody:Vp(h.body,f["content-type"]),requestMethod:h.method,url:a})}))}();return Promise.race([c.promise,d])}(t,n,(t,e)=>{let n=null;if(null!=t)try{n=JSON.parse($p(t))}catch(e){Gp.throwError("invalid JSON",Np.errors.SERVER_ERROR,{body:t,error:e})}return r&&(n=r(n,e)),n})}function Wp(t,e){return e||(e={}),null==(e=kp(e)).floor&&(e.floor=0),null==e.ceiling&&(e.ceiling=1e4),null==e.interval&&(e.interval=250),new Promise((function(r,n){let i=null,o=!1;const s=()=>!o&&(o=!0,i&&clearTimeout(i),!0);e.timeout&&(i=setTimeout(()=>{s()&&n(new Error("timeout"))},e.timeout));const a=e.retryLimit;let h=0;!function i(){return t().then((function(t){if(void 0!==t)s()&&r(t);else if(e.oncePoll)e.oncePoll.once("poll",i);else if(e.onceBlock)e.onceBlock.once("block",i);else if(!o){if(h++,h>a)return void(s()&&n(new Error("retry limit reached")));let t=e.interval*parseInt(String(Math.random()*Math.pow(2,h)));t<e.floor&&(t=e.floor),t>e.ceiling&&(t=e.ceiling),setTimeout(i,t)}return null}),(function(t){s()&&n(t)}))}()}))}for(var Hp="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Zp={},Xp=0;Xp<Hp.length;Xp++){var Jp=Hp.charAt(Xp);if(void 0!==Zp[Jp])throw new TypeError(Jp+" is ambiguous");Zp[Jp]=Xp}function Yp(t){var e=t>>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function Qp(t){for(var e=1,r=0;r<t.length;++r){var n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=Yp(e)^n>>5}for(e=Yp(e),r=0;r<t.length;++r){var i=t.charCodeAt(r);e=Yp(e)^31&i}return e}function tg(t,e){if(e=e||90,t.length<8)return t+" too short";if(t.length>e)return"Exceeds length limit";var r=t.toLowerCase(),n=t.toUpperCase();if(t!==r&&t!==n)return"Mixed-case string "+t;var i=(t=r).lastIndexOf("1");if(-1===i)return"No separator character for "+t;if(0===i)return"Missing prefix for "+t;var o=t.slice(0,i),s=t.slice(i+1);if(s.length<6)return"Data too short";var a=Qp(o);if("string"==typeof a)return a;for(var h=[],u=0;u<s.length;++u){var l=s.charAt(u),f=Zp[l];if(void 0===f)return"Unknown character "+l;a=Yp(a)^f,u+6>=s.length||h.push(f)}return 1!==a?"Invalid checksum for "+t:{prefix:o,words:h}}function eg(t,e,r,n){for(var i=0,o=0,s=(1<<r)-1,a=[],h=0;h<t.length;++h)for(i=i<<e|t[h],o+=e;o>=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<<r-o&s);else{if(o>=e)return"Excess padding";if(i<<r-o&s)return"Non-zero padding"}return a}var rg={decodeUnsafe:function(){var t=tg.apply(null,arguments);if("object"==typeof t)return t},decode:function(t){var e=tg.apply(null,arguments);if("object"==typeof e)return e;throw new Error(e)},encode:function(t,e,r){if(r=r||90,t.length+7+e.length>r)throw new TypeError("Exceeds length limit");var n=Qp(t=t.toLowerCase());if("string"==typeof n)throw new Error(n);for(var i=t+"1",o=0;o<e.length;++o){var s=e[o];if(s>>5!=0)throw new Error("Non 5-bit word");n=Yp(n)^s,i+=Hp.charAt(s)}for(o=0;o<6;++o)n=Yp(n);for(n^=1,o=0;o<6;++o){i+=Hp.charAt(n>>5*(5-o)&31)}return i},toWordsUnsafe:function(t){var e=eg(t,8,5,!0);if(Array.isArray(e))return e},toWords:function(t){var e=eg(t,8,5,!0);if(Array.isArray(e))return e;throw new Error(e)},fromWordsUnsafe:function(t){var e=eg(t,5,8,!1);if(Array.isArray(e))return e},fromWords:function(t){var e=eg(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}};const ng="providers/5.3.1";function ig(t){return"0x"+nn.keccak_256(Yc(t))}var og=h((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Xt.Buffer}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function h(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s<o;s++){var a=t.charCodeAt(s)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.prototype._initNumber=function(t,e,n){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):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("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 i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,u=0,l=r;l<a;l+=n)u=h(t,l,l+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var f=1;for(u=h(t,l,t.length,e),l=0;l<s;l++)f*=e;this.imuln(f),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this.strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","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"],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,h=s/67108864|0;r.words[0]=a;for(var u=1;u<n;u++){for(var l=h>>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var m=u-d|0;l+=(s=(i=0|t.words[m])*(o=0|e.words[d])+f)/67108864|0,f=67108863&s}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],h=(16777215&(a<<i|o)).toString(16);n=0!==(o=a>>>24-i&16777215)||s!==this.length-1?u[6-h.length]+h+n:h+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];n="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modn(d).toString(t);n=(m=m.idivn(d)).isZero()?p+n:u[c-p.length]+p+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.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&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(t,e){return r(void 0!==o),this.toArrayLike(o,t,e)},i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var s,a,h="le"===e,u=new t(o),l=this.clone();if(h){for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[a]=s;for(;a<o;a++)u[a]=0}else{for(a=0;a<o-i;a++)u[a]=0;for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[o-a-1]=s}return u},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this.strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,e,r){var n,i,o,s=t.words,a=e.words,h=r.words,u=0,l=0|s[0],f=8191&l,c=l>>>13,d=0|s[1],m=8191&d,p=d>>>13,g=0|s[2],y=8191&g,v=g>>>13,w=0|s[3],b=8191&w,E=w>>>13,M=0|s[4],_=8191&M,A=M>>>13,N=0|s[5],S=8191&N,R=N>>>13,U=0|s[6],I=8191&U,P=U>>>13,x=0|s[7],k=8191&x,T=x>>>13,O=0|s[8],C=8191&O,F=O>>>13,D=0|s[9],L=8191&D,$=D>>>13,B=0|a[0],j=8191&B,z=B>>>13,G=0|a[1],q=8191&G,V=G>>>13,K=0|a[2],W=8191&K,H=K>>>13,Z=0|a[3],X=8191&Z,J=Z>>>13,Y=0|a[4],Q=8191&Y,tt=Y>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ft=8191<,ct=lt>>>13,dt=0|a[9],mt=8191&dt,pt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,z))+Math.imul(c,j)|0))<<13)|0;u=((o=Math.imul(c,z))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(m,j),i=(i=Math.imul(m,z))+Math.imul(p,j)|0,o=Math.imul(p,z);var yt=(u+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,V)|0)+Math.imul(c,q)|0))<<13)|0;u=((o=o+Math.imul(c,V)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,j),i=(i=Math.imul(y,z))+Math.imul(v,j)|0,o=Math.imul(v,z),n=n+Math.imul(m,q)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(p,q)|0,o=o+Math.imul(p,V)|0;var vt=(u+(n=n+Math.imul(f,W)|0)|0)+((8191&(i=(i=i+Math.imul(f,H)|0)+Math.imul(c,W)|0))<<13)|0;u=((o=o+Math.imul(c,H)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(b,j),i=(i=Math.imul(b,z))+Math.imul(E,j)|0,o=Math.imul(E,z),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,V)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,H)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,H)|0;var wt=(u+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,X)|0))<<13)|0;u=((o=o+Math.imul(c,J)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(_,j),i=(i=Math.imul(_,z))+Math.imul(A,j)|0,o=Math.imul(A,z),n=n+Math.imul(b,q)|0,i=(i=i+Math.imul(b,V)|0)+Math.imul(E,q)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(y,W)|0,i=(i=i+Math.imul(y,H)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,H)|0,n=n+Math.imul(m,X)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,J)|0;var bt=(u+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(S,j),i=(i=Math.imul(S,z))+Math.imul(R,j)|0,o=Math.imul(R,z),n=n+Math.imul(_,q)|0,i=(i=i+Math.imul(_,V)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,V)|0,n=n+Math.imul(b,W)|0,i=(i=i+Math.imul(b,H)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,H)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(p,Q)|0,o=o+Math.imul(p,tt)|0;var Et=(u+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;u=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(I,j),i=(i=Math.imul(I,z))+Math.imul(P,j)|0,o=Math.imul(P,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(_,W)|0,i=(i=i+Math.imul(_,H)|0)+Math.imul(A,W)|0,o=o+Math.imul(A,H)|0,n=n+Math.imul(b,X)|0,i=(i=i+Math.imul(b,J)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,J)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,nt)|0;var Mt=(u+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(c,ot)|0))<<13)|0;u=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,z))+Math.imul(T,j)|0,o=Math.imul(T,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,V)|0)+Math.imul(P,q)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,H)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,H)|0,n=n+Math.imul(_,X)|0,i=(i=i+Math.imul(_,J)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,st)|0;var _t=(u+(n=n+Math.imul(f,ht)|0)|0)+((8191&(i=(i=i+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((o=o+Math.imul(c,ut)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(C,j),i=(i=Math.imul(C,z))+Math.imul(F,j)|0,o=Math.imul(F,z),n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(T,q)|0,o=o+Math.imul(T,V)|0,n=n+Math.imul(I,W)|0,i=(i=i+Math.imul(I,H)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,H)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(_,Q)|0,i=(i=i+Math.imul(_,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var At=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,z))+Math.imul($,j)|0,o=Math.imul($,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,V)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,V)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,H)|0)+Math.imul(T,W)|0,o=o+Math.imul(T,H)|0,n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(_,rt)|0,i=(i=i+Math.imul(_,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(b,ot)|0,i=(i=i+Math.imul(b,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(m,ft)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(p,ft)|0,o=o+Math.imul(p,ct)|0;var Nt=(u+(n=n+Math.imul(f,mt)|0)|0)+((8191&(i=(i=i+Math.imul(f,pt)|0)+Math.imul(c,mt)|0))<<13)|0;u=((o=o+Math.imul(c,pt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(L,q),i=(i=Math.imul(L,V))+Math.imul($,q)|0,o=Math.imul($,V),n=n+Math.imul(C,W)|0,i=(i=i+Math.imul(C,H)|0)+Math.imul(F,W)|0,o=o+Math.imul(F,H)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(_,ot)|0,i=(i=i+Math.imul(_,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,n=n+Math.imul(b,ht)|0,i=(i=i+Math.imul(b,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,o=o+Math.imul(v,ct)|0;var St=(u+(n=n+Math.imul(m,mt)|0)|0)+((8191&(i=(i=i+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,W),i=(i=Math.imul(L,H))+Math.imul($,W)|0,o=Math.imul($,H),n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(_,ht)|0,i=(i=i+Math.imul(_,ut)|0)+Math.imul(A,ht)|0,o=o+Math.imul(A,ut)|0,n=n+Math.imul(b,ft)|0,i=(i=i+Math.imul(b,ct)|0)+Math.imul(E,ft)|0,o=o+Math.imul(E,ct)|0;var Rt=(u+(n=n+Math.imul(y,mt)|0)|0)+((8191&(i=(i=i+Math.imul(y,pt)|0)+Math.imul(v,mt)|0))<<13)|0;u=((o=o+Math.imul(v,pt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,J))+Math.imul($,X)|0,o=Math.imul($,J),n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(F,Q)|0,o=o+Math.imul(F,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,ut)|0,n=n+Math.imul(_,ft)|0,i=(i=i+Math.imul(_,ct)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,ct)|0;var Ut=(u+(n=n+Math.imul(b,mt)|0)|0)+((8191&(i=(i=i+Math.imul(b,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(i>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,n=Math.imul(L,Q),i=(i=Math.imul(L,tt))+Math.imul($,Q)|0,o=Math.imul($,tt),n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(F,rt)|0,o=o+Math.imul(F,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(S,ft)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(R,ft)|0,o=o+Math.imul(R,ct)|0;var It=(u+(n=n+Math.imul(_,mt)|0)|0)+((8191&(i=(i=i+Math.imul(_,pt)|0)+Math.imul(A,mt)|0))<<13)|0;u=((o=o+Math.imul(A,pt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul($,rt)|0,o=Math.imul($,nt),n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,st)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,ut)|0)+Math.imul(T,ht)|0,o=o+Math.imul(T,ut)|0,n=n+Math.imul(I,ft)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(P,ft)|0,o=o+Math.imul(P,ct)|0;var Pt=(u+(n=n+Math.imul(S,mt)|0)|0)+((8191&(i=(i=i+Math.imul(S,pt)|0)+Math.imul(R,mt)|0))<<13)|0;u=((o=o+Math.imul(R,pt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,ot),i=(i=Math.imul(L,st))+Math.imul($,ot)|0,o=Math.imul($,st),n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,ut)|0)+Math.imul(F,ht)|0,o=o+Math.imul(F,ut)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,ct)|0;var xt=(u+(n=n+Math.imul(I,mt)|0)|0)+((8191&(i=(i=i+Math.imul(I,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),n=n+Math.imul(C,ft)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(F,ft)|0,o=o+Math.imul(F,ct)|0;var kt=(u+(n=n+Math.imul(k,mt)|0)|0)+((8191&(i=(i=i+Math.imul(k,pt)|0)+Math.imul(T,mt)|0))<<13)|0;u=((o=o+Math.imul(T,pt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,ft),i=(i=Math.imul(L,ct))+Math.imul($,ft)|0,o=Math.imul($,ct);var Tt=(u+(n=n+Math.imul(C,mt)|0)|0)+((8191&(i=(i=i+Math.imul(C,pt)|0)+Math.imul(F,mt)|0))<<13)|0;u=((o=o+Math.imul(F,pt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863;var Ot=(u+(n=Math.imul(L,mt))|0)+((8191&(i=(i=Math.imul(L,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=wt,h[4]=bt,h[5]=Et,h[6]=Mt,h[7]=_t,h[8]=At,h[9]=Nt,h[10]=St,h[11]=Rt,h[12]=Ut,h[13]=It,h[14]=Pt,h[15]=xt,h[16]=kt,h[17]=Tt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new p).mulp(t,e,r)}function p(t,e){this.x=t,this.y=e}Math.imul||(d=c),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,f=(0|t.words[l])*(0|e.words[u]),c=67108863&f;a=67108863&(c=c+a|0),i+=(s=(s=s+(f/67108864|0)|0)+(c>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):m(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),r=i.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e},p.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n},p.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s<o;s++)n[s]=e[t[s]],i[s]=r[t[s]]},p.prototype.transform=function(t,e,r,n,i,o){this.permute(o,t,e,r,n,i);for(var s=1;s<i;s<<=1)for(var a=s<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),l=0;l<i;l+=a)for(var f=h,c=u,d=0;d<s;d++){var m=r[l+d],p=n[l+d],g=r[l+d+s],y=n[l+d+s],v=f*g-c*y;y=f*y+c*g,g=v,r[l+d]=m+g,n[l+d]=p+y,r[l+d+s]=m-g,n[l+d+s]=p-y,d!==a&&(v=h*f-u*c,c=h*c+u*f,f=v)}},p.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},p.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},p.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0}return t},p.prototype.convert13b=function(t,e,n,i){for(var o=0,s=0;s<e;s++)o+=0|t[s],n[2*s]=8191&o,o>>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<i;++s)n[s]=0;r(0===o),r(0==(-8192&o))},p.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},p.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),o=this.stub(n),s=new Array(n),a=new Array(n),h=new Array(n),u=new Array(n),l=new Array(n),f=new Array(n),c=r.words;c.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(e.words,e.length,u,n),this.transform(s,o,a,h,n,i),this.transform(u,o,l,f,n,i);for(var d=0;d<n;d++){var m=a[d]*l[d]-h[d]*f[d];h[d]=a[d]*f[d]+h[d]*l[d],a[d]=m}return this.conjugate(a,h,n),this.transform(a,h,c,o,n,i),this.conjugate(c,o,n),this.normalize13b(c,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),m(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){r("number"==typeof t),r(t<67108864);for(var e=0,n=0;n<this.length;n++){var i=(0|this.words[n])*t,o=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=o>>>26,this.words[n]=67108863&o}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(t.words[n]&1<<i)>>>i}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,h=(0|this.words[e])-a<<n;this.words[e]=h|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this.strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,h=n;if(i-=s,i=Math.max(0,i),h){for(var u=0;u<s;u++)h.words[u]=this.words[u];h.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=i);u--){var f=0|this.words[u];this.words[u]=l<<26-o|f>>>o,l=f&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n)&&!!(this.words[n]&i)},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this.strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(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)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(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 e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var h=(0|t.words[i])*e;a=((o-=67108863&h)>>26)-(h/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!==(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,h=n.length-o.length;if("mod"!==e){(a=new i(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var l=n.clone()._ishlnsubmul(o,1,h);0===l.negative&&(n=l,a&&(a.words[h]=1));for(var f=h-1;f>=0;f--){var c=67108864*(0|n.words[o.length+f])+(0|n.words[o.length+f-1]);for(c=Math.min(c/s|0,67108863),n._ishlnsubmul(o,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(o,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},i.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),h=new i(1),u=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(f)),o.iushrn(1),s.iushrn(1);for(var m=0,p=1;0==(n.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(n.iushrn(m);m-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(f)),a.iushrn(1),h.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(h)):(n.isub(e),a.isub(o),h.isub(s))}return{a:a,b:h,gcd:n.iushln(u)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),h=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new M(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(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 i(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n<r;n++)e.words[n]=t.words[n];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=4194303&i,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(4194303&o)<<4|i>>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,y),n(b,y),n(E,y),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new w;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},M.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},M.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},M.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,o),c=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),m=s;0!==d.cmp(a);){for(var p=d,g=0;0!==p.cmp(a);g++)p=p.redSqr();r(g<m);var y=this.pow(f,new i(1).iushln(m-g-1));c=c.redMul(y),f=y.redSqr(),d=d.redMul(f),m=g}return c},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],l=h-1;l>=0;l--){var f=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===l)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}h=26}return o},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new _(t)},n(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,o)}));function sg(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}var ag=hg;function hg(t,e){if(!t)throw new Error(e||"Assertion failed")}hg.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var ug=sg((function(t,e){var r=e;function n(t){return 1===t.length?"0"+t:t}function i(t){for(var e="",r=0;r<t.length;r++)e+=n(t[r].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var n=0;n<t.length;n++)r[n]=0|t[n];return r}if("hex"===e){(t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t);for(n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(n=0;n<t.length;n++){var i=t.charCodeAt(n),o=i>>8,s=255&i;o?r.push(o,s):r.push(s)}return r},r.zero2=n,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}})),lg=sg((function(t,e){var r=e;r.assert=ag,r.toArray=ug.toArray,r.zero2=ug.zero2,r.toHex=ug.toHex,r.encode=ug.encode,r.getNAF=function(t,e,r){var n=new Array(Math.max(t.bitLength(),r)+1);n.fill(0);for(var i=1<<e+1,o=t.clone(),s=0;s<n.length;s++){var a,h=o.andln(i-1);o.isOdd()?(a=h>(i>>1)-1?(i>>1)-h:h,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},r.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,h=t.andln(3)+i&3,u=e.andln(3)+o&3;3===h&&(h=-1),3===u&&(u=-1),s=0==(1&h)?0:3!==(n=t.andln(7)+i&7)&&5!==n||2!==u?h:-h,r[0].push(s),a=0==(1&u)?0:3!==(n=e.andln(7)+o&7)&&5!==n||2!==h?u:-u,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new og(t,"hex","le")}})),fg=lg.getNAF,cg=lg.getJSF,dg=lg.assert;function mg(t,e){this.type=t,this.p=new og(e.p,16),this.red=e.prime?og.red(e.prime):og.mont(this.p),this.zero=new og(0).toRed(this.red),this.one=new og(1).toRed(this.red),this.two=new og(2).toRed(this.red),this.n=e.n&&new og(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var pg=mg;function gg(t,e){this.curve=t,this.type=e,this.precomputed=null}mg.prototype.point=function(){throw new Error("Not implemented")},mg.prototype.validate=function(){throw new Error("Not implemented")},mg.prototype._fixedNafMul=function(t,e){dg(t.precomputed);var r=t._getDoubles(),n=fg(e,1,this._bitLength),i=(1<<r.step+1)-(r.step%2==0?2:1);i/=3;var o,s,a=[];for(o=0;o<n.length;o+=r.step){s=0;for(var h=o+r.step-1;h>=o;h--)s=(s<<1)+n[h];a.push(s)}for(var u=this.jpoint(null,null,null),l=this.jpoint(null,null,null),f=i;f>0;f--){for(o=0;o<a.length;o++)(s=a[o])===f?l=l.mixedAdd(r.points[o]):s===-f&&(l=l.mixedAdd(r.points[o].neg()));u=u.add(l)}return u.toP()},mg.prototype._wnafMul=function(t,e){var r=4,n=t._getNAFPoints(r);r=n.wnd;for(var i=n.points,o=fg(e,r,this._bitLength),s=this.jpoint(null,null,null),a=o.length-1;a>=0;a--){for(var h=0;a>=0&&0===o[a];a--)h++;if(a>=0&&h++,s=s.dblp(h),a<0)break;var u=o[a];dg(0!==u),s="affine"===t.type?u>0?s.mixedAdd(i[u-1>>1]):s.mixedAdd(i[-u-1>>1].neg()):u>0?s.add(i[u-1>>1]):s.add(i[-u-1>>1].neg())}return"affine"===t.type?s.toP():s},mg.prototype._wnafMulAdd=function(t,e,r,n,i){var o,s,a,h=this._wnafT1,u=this._wnafT2,l=this._wnafT3,f=0;for(o=0;o<n;o++){var c=(a=e[o])._getNAFPoints(t);h[o]=c.wnd,u[o]=c.points}for(o=n-1;o>=1;o-=2){var d=o-1,m=o;if(1===h[d]&&1===h[m]){var p=[e[d],null,null,e[m]];0===e[d].y.cmp(e[m].y)?(p[1]=e[d].add(e[m]),p[2]=e[d].toJ().mixedAdd(e[m].neg())):0===e[d].y.cmp(e[m].y.redNeg())?(p[1]=e[d].toJ().mixedAdd(e[m]),p[2]=e[d].add(e[m].neg())):(p[1]=e[d].toJ().mixedAdd(e[m]),p[2]=e[d].toJ().mixedAdd(e[m].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],y=cg(r[d],r[m]);for(f=Math.max(y[0].length,f),l[d]=new Array(f),l[m]=new Array(f),s=0;s<f;s++){var v=0|y[0][s],w=0|y[1][s];l[d][s]=g[3*(v+1)+(w+1)],l[m][s]=0,u[d]=p}}else l[d]=fg(r[d],h[d],this._bitLength),l[m]=fg(r[m],h[m],this._bitLength),f=Math.max(l[d].length,f),f=Math.max(l[m].length,f)}var b=this.jpoint(null,null,null),E=this._wnafT4;for(o=f;o>=0;o--){for(var M=0;o>=0;){var _=!0;for(s=0;s<n;s++)E[s]=0|l[s][o],0!==E[s]&&(_=!1);if(!_)break;M++,o--}if(o>=0&&M++,b=b.dblp(M),o<0)break;for(s=0;s<n;s++){var A=E[s];0!==A&&(A>0?a=u[s][A-1>>1]:A<0&&(a=u[s][-A-1>>1].neg()),b="affine"===a.type?b.mixedAdd(a):b.add(a))}}for(o=0;o<n;o++)u[o]=null;return i?b:b.toP()},mg.BasePoint=gg,gg.prototype.eq=function(){throw new Error("Not implemented")},gg.prototype.validate=function(){return this.curve.validate(this)},mg.prototype.decodePoint=function(t,e){t=lg.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?dg(t[t.length-1]%2==0):7===t[0]&&dg(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},gg.prototype.encodeCompressed=function(t){return this.encode(t,!0)},gg.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},gg.prototype.encode=function(t,e){return lg.encode(this._encode(e),t)},gg.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},gg.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},gg.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i<e;i+=t){for(var o=0;o<t;o++)n=n.dbl();r.push(n)}return{step:t,points:r}},gg.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,n=1===r?null:this.dbl(),i=1;i<r;i++)e[i]=e[i-1].add(n);return{wnd:t,points:e}},gg.prototype._getBeta=function(){return null},gg.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e};var yg=sg((function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}})),vg=lg.assert;function wg(t){pg.call(this,"short",t),this.a=new og(t.a,16).toRed(this.red),this.b=new og(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}yg(wg,pg);var bg=wg;function Eg(t,e,r,n){pg.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new og(e,16),this.y=new og(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function Mg(t,e,r,n){pg.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new og(0)):(this.x=new og(e,16),this.y=new og(r,16),this.z=new og(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}wg.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new og(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new og(t.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(e))?r=i[0]:(r=i[1],vg(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map((function(t){return{a:new og(t.a,16),b:new og(t.b,16)}})):this._getEndoBasis(r)}}},wg.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:og.mont(t),r=new og(2).toRed(e).redInvm(),n=r.redNeg(),i=new og(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},wg.prototype._getEndoBasis=function(t){for(var e,r,n,i,o,s,a,h,u,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),f=t,c=this.n.clone(),d=new og(1),m=new og(0),p=new og(0),g=new og(1),y=0;0!==f.cmpn(0);){var v=c.div(f);h=c.sub(v.mul(f)),u=p.sub(v.mul(d));var w=g.sub(v.mul(m));if(!n&&h.cmp(l)<0)e=a.neg(),r=d,n=h.neg(),i=u;else if(n&&2==++y)break;a=h,c=f,f=h,p=d,d=u,g=m,m=w}o=h.neg(),s=u;var b=n.sqr().add(i.sqr());return o.sqr().add(s.sqr()).cmp(b)>=0&&(o=e,s=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),s=s.neg()),[{a:n,b:i},{a:o,b:s}]},wg.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),h=i.mul(r.b),u=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:h.add(u).neg()}},wg.prototype.pointFromX=function(t,e){(t=new og(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},wg.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},wg.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o<t.length;o++){var s=this._endoSplit(e[o]),a=t[o],h=a._getBeta();s.k1.negative&&(s.k1.ineg(),a=a.neg(!0)),s.k2.negative&&(s.k2.ineg(),h=h.neg(!0)),n[2*o]=a,n[2*o+1]=h,i[2*o]=s.k1,i[2*o+1]=s.k2}for(var u=this._wnafMulAdd(1,n,i,2*o,r),l=0;l<2*o;l++)n[l]=null,i[l]=null;return u},yg(Eg,pg.BasePoint),wg.prototype.point=function(t,e,r){return new Eg(this,t,e,r)},wg.prototype.pointFromJSON=function(t,e){return Eg.fromJSON(this,t,e)},Eg.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,n=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(n)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(n)}}}return e}},Eg.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},Eg.fromJSON=function(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var n=t.point(e[0],e[1],r);if(!e[2])return n;function i(e){return t.point(e[0],e[1],r)}var o=e[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(i))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(i))}},n},Eg.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},Eg.prototype.isInfinity=function(){return this.inf},Eg.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Eg.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Eg.prototype.getX=function(){return this.x.fromRed()},Eg.prototype.getY=function(){return this.y.fromRed()},Eg.prototype.mul=function(t){return t=new og(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Eg.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Eg.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Eg.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Eg.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},Eg.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},yg(Mg,pg.BasePoint),wg.prototype.jpoint=function(t,e,r){return new Mg(this,t,e,r)},Mg.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},Mg.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Mg.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),h=o.redSub(s);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),l=u.redMul(a),f=n.redMul(u),c=h.redSqr().redIAdd(l).redISub(f).redISub(f),d=h.redMul(f.redISub(c)).redISub(o.redMul(l)),m=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(c,d,m)},Mg.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=s.redSqr(),u=h.redMul(s),l=r.redMul(h),f=a.redSqr().redIAdd(u).redISub(l).redISub(l),c=a.redMul(l.redISub(f)).redISub(i.redMul(u)),d=this.z.redMul(s);return this.curve.jpoint(f,c,d)},Mg.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var n=this.curve.a,i=this.curve.tinv,o=this.x,s=this.y,a=this.z,h=a.redSqr().redSqr(),u=s.redAdd(s);for(e=0;e<t;e++){var l=o.redSqr(),f=u.redSqr(),c=f.redSqr(),d=l.redAdd(l).redIAdd(l).redIAdd(n.redMul(h)),m=o.redMul(f),p=d.redSqr().redISub(m.redAdd(m)),g=m.redISub(p),y=d.redMul(g);y=y.redIAdd(y).redISub(c);var v=u.redMul(a);e+1<t&&(h=h.redMul(c)),o=p,a=v,u=y}return this.curve.jpoint(o,u.redMul(i),a)},Mg.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Mg.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n),h=a.redSqr().redISub(s).redISub(s),u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),t=h,e=a.redMul(s.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var l=this.x.redSqr(),f=this.y.redSqr(),c=f.redSqr(),d=this.x.redAdd(f).redSqr().redISub(l).redISub(c);d=d.redIAdd(d);var m=l.redAdd(l).redIAdd(l),p=m.redSqr(),g=c.redIAdd(c);g=(g=g.redIAdd(g)).redIAdd(g),t=p.redISub(d).redISub(d),e=m.redMul(d.redISub(t)).redISub(g),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},Mg.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=a.redSqr().redISub(s).redISub(s);t=h;var u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),e=a.redMul(s.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var l=this.z.redSqr(),f=this.y.redSqr(),c=this.x.redMul(f),d=this.x.redSub(l).redMul(this.x.redAdd(l));d=d.redAdd(d).redIAdd(d);var m=c.redIAdd(c),p=(m=m.redIAdd(m)).redAdd(m);t=d.redSqr().redISub(p),r=this.y.redAdd(this.z).redSqr().redISub(f).redISub(l);var g=f.redSqr();g=(g=(g=g.redIAdd(g)).redIAdd(g)).redIAdd(g),e=d.redMul(m.redISub(t)).redISub(g)}return this.curve.jpoint(t,e,r)},Mg.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),o=e.redSqr(),s=r.redSqr(),a=o.redAdd(o).redIAdd(o).redIAdd(t.redMul(i)),h=e.redAdd(e),u=(h=h.redIAdd(h)).redMul(s),l=a.redSqr().redISub(u.redAdd(u)),f=u.redISub(l),c=s.redSqr();c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var d=a.redMul(f).redISub(c),m=r.redAdd(r).redMul(n);return this.curve.jpoint(l,d,m)},Mg.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),n=e.redSqr(),i=t.redAdd(t).redIAdd(t),o=i.redSqr(),s=this.x.redAdd(e).redSqr().redISub(t).redISub(n),a=(s=(s=(s=s.redIAdd(s)).redAdd(s).redIAdd(s)).redISub(o)).redSqr(),h=n.redIAdd(n);h=(h=(h=h.redIAdd(h)).redIAdd(h)).redIAdd(h);var u=i.redIAdd(s).redSqr().redISub(o).redISub(a).redISub(h),l=e.redMul(u);l=(l=l.redIAdd(l)).redIAdd(l);var f=this.x.redMul(a).redISub(l);f=(f=f.redIAdd(f)).redIAdd(f);var c=this.y.redMul(u.redMul(h.redISub(u)).redISub(s.redMul(a)));c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var d=this.z.redAdd(s).redSqr().redISub(r).redISub(a);return this.curve.jpoint(f,c,d)},Mg.prototype.mul=function(t,e){return t=new og(t,e),this.curve._wnafMul(this,t)},Mg.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var n=e.redMul(this.z),i=r.redMul(t.z);return 0===this.y.redMul(i).redISub(t.y.redMul(n)).cmpn(0)},Mg.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var n=t.clone(),i=this.curve.redN.redMul(e);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},Mg.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},Mg.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var _g=sg((function(t,e){var r=e;r.base=pg,r.short=bg,r.mont=null,r.edwards=null})),Ag=sg((function(t,e){var r,n=e,i=lg.assert;function o(t){"short"===t.type?this.curve=new _g.short(t):"edwards"===t.type?this.curve=new _g.edwards(t):this.curve=new _g.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function s(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new o(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Zm.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Zm.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Zm.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Zm.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Zm.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Zm.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Zm.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=null.crash()}catch(t){r=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Zm.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})}));function Ng(t){if(!(this instanceof Ng))return new Ng(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ug.toArray(t.entropy,t.entropyEnc||"hex"),r=ug.toArray(t.nonce,t.nonceEnc||"hex"),n=ug.toArray(t.pers,t.persEnc||"hex");ag(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var Sg=Ng;Ng.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},Ng.prototype._hmac=function(){return new Zm.hmac(this.hash,this.K)},Ng.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},Ng.prototype.reseed=function(t,e,r,n){"string"!=typeof e&&(n=r,r=e,e=null),t=ug.toArray(t,e),r=ug.toArray(r,n),ag(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},Ng.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=ug.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length<t;)this.V=this._hmac().update(this.V).digest(),i=i.concat(this.V);var o=i.slice(0,t);return this._update(r),this._reseed++,ug.encode(o,e)};var Rg=lg.assert;function Ug(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var Ig=Ug;Ug.fromPublic=function(t,e,r){return e instanceof Ug?e:new Ug(t,{pub:e,pubEnc:r})},Ug.fromPrivate=function(t,e,r){return e instanceof Ug?e:new Ug(t,{priv:e,privEnc:r})},Ug.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Ug.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},Ug.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},Ug.prototype._importPrivate=function(t,e){this.priv=new og(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},Ug.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?Rg(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||Rg(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},Ug.prototype.derive=function(t){return t.validate()||Rg(t.validate(),"public point not validated"),t.mul(this.priv).getX()},Ug.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},Ug.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},Ug.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Pg=lg.assert;function xg(t,e){if(t instanceof xg)return t;this._importDER(t,e)||(Pg(t.r&&t.s,"Signature without r or s"),this.r=new og(t.r,16),this.s=new og(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var kg=xg;function Tg(){this.place=0}function Og(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=e.place;o<n;o++,s++)i<<=8,i|=t[s],i>>>=0;return!(i<=127)&&(e.place=s,i)}function Cg(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function Fg(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}xg.prototype._importDER=function(t,e){t=lg.toArray(t,e);var r=new Tg;if(48!==t[r.place++])return!1;var n=Og(t,r);if(!1===n)return!1;if(n+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var i=Og(t,r);if(!1===i)return!1;var o=t.slice(r.place,i+r.place);if(r.place+=i,2!==t[r.place++])return!1;var s=Og(t,r);if(!1===s)return!1;if(t.length!==s+r.place)return!1;var a=t.slice(r.place,s+r.place);if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}if(0===a[0]){if(!(128&a[1]))return!1;a=a.slice(1)}return this.r=new og(o),this.s=new og(a),this.recoveryParam=null,!0},xg.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=Cg(e),r=Cg(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];Fg(n,e.length),(n=n.concat(e)).push(2),Fg(n,r.length);var i=n.concat(r),o=[48];return Fg(o,i.length),o=o.concat(i),lg.encode(o,t)};var Dg=function(){throw new Error("unsupported")},Lg=lg.assert;function $g(t){if(!(this instanceof $g))return new $g(t);"string"==typeof t&&(Lg(Object.prototype.hasOwnProperty.call(Ag,t),"Unknown curve "+t),t=Ag[t]),t instanceof Ag.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var Bg=$g;$g.prototype.keyPair=function(t){return new Ig(this,t)},$g.prototype.keyFromPrivate=function(t,e){return Ig.fromPrivate(this,t,e)},$g.prototype.keyFromPublic=function(t,e){return Ig.fromPublic(this,t,e)},$g.prototype.genKeyPair=function(t){t||(t={});for(var e=new Sg({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||Dg(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new og(2));;){var i=new og(e.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},$g.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},$g.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new og(t,16));for(var i=this.n.byteLength(),o=e.getPrivate().toArray("be",i),s=t.toArray("be",i),a=new Sg({hash:this.hash,entropy:o,nonce:s,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new og(1)),u=0;;u++){var l=n.k?n.k(u):new og(a.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(h)>=0)){var f=this.g.mul(l);if(!f.isInfinity()){var c=f.getX(),d=c.umod(this.n);if(0!==d.cmpn(0)){var m=l.invm(this.n).mul(d.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var p=(f.getY().isOdd()?1:0)|(0!==c.cmp(d)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),p^=1),new kg({r:d,s:m,recoveryParam:p})}}}}}},$g.prototype.verify=function(t,e,r,n){t=this._truncateToN(new og(t,16)),r=this.keyFromPublic(r,n);var i=(e=new kg(e,"hex")).r,o=e.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var s,a=o.invm(this.n),h=a.mul(t).umod(this.n),u=a.mul(i).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(h,r.getPublic(),u)).isInfinity()&&s.eqXToP(i):!(s=this.g.mulAdd(h,r.getPublic(),u)).isInfinity()&&0===s.getX().umod(this.n).cmp(i)},$g.prototype.recoverPubKey=function(t,e,r,n){Lg((3&r)===r,"The recovery param is more than two bits"),e=new kg(e,n);var i=this.n,o=new og(t),s=e.r,a=e.s,h=1&r,u=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");s=u?this.curve.pointFromX(s.add(this.curve.n),h):this.curve.pointFromX(s,h);var l=e.r.invm(i),f=i.sub(o).mul(l).umod(i),c=a.mul(l).umod(i);return this.g.mulAdd(f,s,c)},$g.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new kg(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var jg=sg((function(t,e){var r=e;r.version="6.5.4",r.utils=lg,r.rand=function(){throw new Error("unsupported")},r.curve=_g,r.curves=Ag,r.ec=Bg,r.eddsa=null})).ec;const zg=new Wc("signing-key/5.3.0");let Gg=null;function qg(){return Gg||(Gg=new jg("secp256k1")),Gg}class Vg{constructor(t){fd(this,"curve","secp256k1"),fd(this,"privateKey",rd(t));const e=qg().keyFromPrivate(Yc(this.privateKey));fd(this,"publicKey","0x"+e.getPublic(!1,"hex")),fd(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),fd(this,"_isSigningKey",!0)}_addPoint(t){const e=qg().keyFromPublic(Yc(this.publicKey)),r=qg().keyFromPublic(Yc(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){const e=qg().keyFromPrivate(Yc(this.privateKey)),r=Yc(t);32!==r.length&&zg.throwArgumentError("bad digest length","digest",t);const n=e.sign(r,{canonical:!0});return hd({recoveryParam:n.recoveryParam,r:ad("0x"+n.r.toString(16),32),s:ad("0x"+n.s.toString(16),32)})}computeSharedSecret(t){const e=qg().keyFromPrivate(Yc(this.privateKey)),r=qg().keyFromPublic(Yc(Kg(t)));return ad("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function Kg(t,e){const r=Yc(t);if(32===r.length){const t=new Vg(r);return e?"0x"+qg().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?rd(r):"0x"+qg().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+qg().keyFromPublic(r).getPublic(!0,"hex"):rd(r):zg.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Wg=new Wc("transactions/5.3.0");function Hg(t){return"0x"===t?null:On(t)}function Zg(t){return"0x"===t?Hn:me.from(t)}function Xg(t,e){return function(t){return On(id(ig(id(Kg(t),1)),12))}(function(t,e){const r=hd(e),n={r:Yc(r.r),s:Yc(r.s)};return"0x"+qg().recoverPubKey(Yc(t),n,r.recoveryParam).encode("hex",!1)}(Yc(t),e))}function Jg(t,e){const r=td(me.from(t).toHexString());return r.length>32&&Wg.throwArgumentError("invalid length for "+e,"transaction:"+e,t),r}function Yg(t,e){return{address:On(t),storageKeys:(e||[]).map((e,r)=>(32!==nd(e)&&Wg.throwArgumentError("invalid access list storageKey",`accessList[${t}:${r}]`,e),e.toLowerCase()))}}function Qg(t){if(Array.isArray(t))return t.map((t,e)=>Array.isArray(t)?(t.length>2&&Wg.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${e}]`,t),Yg(t[0],t[1])):Yg(t.address,t.storageKeys));const e=Object.keys(t).map(e=>{const r=t[e].reduce((t,e)=>(t[e]=!0,t),{});return Yg(e,Object.keys(r).sort())});return e.sort((t,e)=>t.address.localeCompare(e.address)),e}function ty(t){const e=In(t.slice(1));8!==e.length&&11!==e.length&&Wg.throwArgumentError("invalid component count for transaction type: 1","payload",rd(t));const r={type:1,chainId:Zg(e[0]).toNumber(),nonce:Zg(e[1]).toNumber(),gasPrice:Zg(e[2]),gasLimit:Zg(e[3]),to:Hg(e[4]),value:Zg(e[5]),data:e[6],accessList:Qg(e[7])};if(8===e.length)return r;try{const t=Zg(e[8]).toNumber();if(0!==t&&1!==t)throw new Error("bad recid");r.v=t}catch(t){Wg.throwArgumentError("invalid v for transaction type: 1","v",e[8])}r.r=ad(e[9],32),r.s=ad(e[10],32);try{const t=ig(function(t,e){const r=[Jg(t.chainId||0,"chainId"),Jg(t.nonce||0,"nonce"),Jg(t.gasPrice||0,"gasPrice"),Jg(t.gasLimit||0,"gasLimit"),null!=t.to?On(t.to):"0x",Jg(t.value||0,"value"),t.data||"0x",(n=t.accessList||[],Qg(n).map(t=>[t.address,t.storageKeys]))];var n;if(e){const t=hd(e);r.push(Jg(t.recoveryParam,"recoveryParam")),r.push(td(t.r)),r.push(td(t.s))}return od(["0x01",Sn(r)])}(r));r.from=Xg(t,{r:r.r,s:r.s,recoveryParam:r.v})}catch(t){console.log(t)}return r.hash=ig(t),r}function ey(t){const e=Yc(t);if(e[0]>127)return function(t){const e=In(t);9!==e.length&&6!==e.length&&Wg.throwArgumentError("invalid raw transaction","rawTransaction",t);const r={nonce:Zg(e[0]).toNumber(),gasPrice:Zg(e[1]),gasLimit:Zg(e[2]),to:Hg(e[3]),value:Zg(e[4]),data:e[5],chainId:0};if(6===e.length)return r;try{r.v=me.from(e[6]).toNumber()}catch(t){return console.log(t),r}if(r.r=ad(e[7],32),r.s=ad(e[8],32),me.from(r.r).isZero()&&me.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let n=r.v-27;const i=e.slice(0,6);0!==r.chainId&&(i.push(rd(r.chainId)),i.push("0x"),i.push("0x"),n-=2*r.chainId+8);const o=ig(Sn(i));try{r.from=Xg(o,{r:rd(r.r),s:rd(r.s),recoveryParam:n})}catch(t){console.log(t)}r.hash=ig(t)}return r.type=null,r}(e);switch(e[0]){case 1:return ty(e)}return Wg.throwError("unsupported transaction type: "+e[0],Wc.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:e[0]})}const ry=new Wc(ng);class ny{constructor(){ry.checkNew(new.target,ny),this.formats=this.getDefaultFormats()}getDefaultFormats(){const t={},e=this.address.bind(this),r=this.bigNumber.bind(this),n=this.blockTag.bind(this),i=this.data.bind(this),o=this.hash.bind(this),s=this.hex.bind(this),a=this.number.bind(this);return t.transaction={hash:o,type:ny.allowNull(a,null),accessList:ny.allowNull(this.accessList.bind(this),null),blockHash:ny.allowNull(o,null),blockNumber:ny.allowNull(a,null),transactionIndex:ny.allowNull(a,null),confirmations:ny.allowNull(a,null),from:e,gasPrice:r,gasLimit:r,to:ny.allowNull(e,null),value:r,nonce:a,data:i,r:ny.allowNull(this.uint256),s:ny.allowNull(this.uint256),v:ny.allowNull(a),creates:ny.allowNull(e,null),raw:ny.allowNull(i)},t.transactionRequest={from:ny.allowNull(e),nonce:ny.allowNull(a),gasLimit:ny.allowNull(r),gasPrice:ny.allowNull(r),to:ny.allowNull(e),value:ny.allowNull(r),data:ny.allowNull(t=>this.data(t,!0)),type:ny.allowNull(a),accessList:ny.allowNull(this.accessList.bind(this),null)},t.receiptLog={transactionIndex:a,blockNumber:a,transactionHash:o,address:e,topics:ny.arrayOf(o),data:i,logIndex:a,blockHash:o},t.receipt={to:ny.allowNull(this.address,null),from:ny.allowNull(this.address,null),contractAddress:ny.allowNull(e,null),transactionIndex:a,root:ny.allowNull(s),gasUsed:r,logsBloom:ny.allowNull(i),blockHash:o,transactionHash:o,logs:ny.arrayOf(this.receiptLog.bind(this)),blockNumber:a,confirmations:ny.allowNull(a,null),cumulativeGasUsed:r,status:ny.allowNull(a)},t.block={hash:o,parentHash:o,number:a,timestamp:a,nonce:ny.allowNull(s),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:e,extraData:i,transactions:ny.allowNull(ny.arrayOf(o))},t.blockWithTransactions=md(t.block),t.blockWithTransactions.transactions=ny.allowNull(ny.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:ny.allowNull(n,void 0),toBlock:ny.allowNull(n,void 0),blockHash:ny.allowNull(o,void 0),address:ny.allowNull(e,void 0),topics:ny.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:ny.allowNull(a),blockHash:ny.allowNull(o),transactionIndex:a,removed:ny.allowNull(this.boolean.bind(this)),address:e,data:ny.allowFalsish(i,"0x"),topics:ny.arrayOf(o),transactionHash:o,logIndex:a},t}accessList(t){return Qg(t||[])}number(t){return"0x"===t?0:me.from(t).toNumber()}bigNumber(t){return me.from(t)}boolean(t){if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===(t=t.toLowerCase()))return!0;if("false"===t)return!1}throw new Error("invalid boolean - "+t)}hex(t,e){return"string"==typeof t&&(e||"0x"===t.substring(0,2)||(t="0x"+t),ed(t))?t.toLowerCase():ry.throwArgumentError("invalid hash","value",t)}data(t,e){const r=this.hex(t,e);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+t);return r}address(t){return On(t)}callAddress(t){if(!ed(t,32))return null;const e=On(id(t,12));return"0x0000000000000000000000000000000000000000"===e?null:e}contractAddress(t){return Cn(t)}blockTag(t){if(null==t)return"latest";if("earliest"===t)return"0x0";if("latest"===t||"pending"===t)return t;if("number"==typeof t||ed(t))return sd(t);throw new Error("invalid blockTag")}hash(t,e){const r=this.hex(t,e);return 32!==nd(r)?ry.throwArgumentError("invalid hash","value",t):r}difficulty(t){if(null==t)return null;const e=me.from(t);try{return e.toNumber()}catch(t){}return null}uint256(t){if(!ed(t))throw new Error("invalid uint256");return ad(t,32)}_block(t,e){return null!=t.author&&null==t.miner&&(t.miner=t.author),ny.check(e,t)}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return ny.check(this.formats.transactionRequest,t)}transactionResponse(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&me.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t)),1===t.type&&null==t.accessList&&(t.accessList=[]);const e=ny.check(this.formats.transaction,t);if(null!=t.chainId){let r=t.chainId;ed(r)&&(r=me.from(r).toNumber()),e.chainId=r}else{let r=t.networkId;null==r&&null==e.v&&(r=t.chainId),ed(r)&&(r=me.from(r).toNumber()),"number"!=typeof r&&null!=e.v&&(r=(e.v-35)/2,r<0&&(r=0),r=parseInt(r)),"number"!=typeof r&&(r=0),e.chainId=r}return e.blockHash&&"x"===e.blockHash.replace(/0/g,"")&&(e.blockHash=null),e}transaction(t){return ey(t)}receiptLog(t){return ny.check(this.formats.receiptLog,t)}receipt(t){const e=ny.check(this.formats.receipt,t);if(null!=e.root)if(e.root.length<=4){const t=me.from(e.root).toNumber();0===t||1===t?(null!=e.status&&e.status!==t&&ry.throwArgumentError("alt-root-status/status mismatch","value",{root:e.root,status:e.status}),e.status=t,delete e.root):ry.throwArgumentError("invalid alt-root-status","value.root",e.root)}else 66!==e.root.length&&ry.throwArgumentError("invalid root hash","value.root",e.root);return null!=e.status&&(e.byzantium=!0),e}topics(t){return Array.isArray(t)?t.map(t=>this.topics(t)):null!=t?this.hash(t,!0):null}filter(t){return ny.check(this.formats.filter,t)}filterLog(t){return ny.check(this.formats.filterLog,t)}static check(t,e){const r={};for(const n in t)try{const i=t[n](e[n]);void 0!==i&&(r[n]=i)}catch(t){throw t.checkKey=n,t.checkValue=e[n],t}return r}static allowNull(t,e){return function(r){return null==r?e:t(r)}}static allowFalsish(t,e){return function(r){return r?t(r):e}}static arrayOf(t){return function(e){if(!Array.isArray(e))throw new Error("not an array");const r=[];return e.forEach((function(e){r.push(t(e))})),r}}}var iy=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const oy=new Wc(ng);function sy(t){return null==t?"null":(32!==nd(t)&&oy.throwArgumentError("invalid topic","topic",t),t.toLowerCase())}function ay(t){for(t=t.slice();t.length>0&&null==t[t.length-1];)t.pop();return t.map(t=>{if(Array.isArray(t)){const e={};t.forEach(t=>{e[sy(t)]=!0});const r=Object.keys(e);return r.sort(),r.join("|")}return sy(t)}).join("&")}function hy(t){if("string"==typeof t){if(32===nd(t=t.toLowerCase()))return"tx:"+t;if(-1===t.indexOf(":"))return t}else{if(Array.isArray(t))return"filter:*:"+ay(t);if(class extends class{constructor(t){for(const e in t)this[e]=Vo(t[e])}}{static isForkEvent(t){return!(!t||!t._isForkEvent)}}.isForkEvent(t))throw oy.warn("not implemented"),new Error("not implemented");if(t&&"object"==typeof t)return"filter:"+(t.address||"*")+":"+ay(t.topics||[])}throw new Error("invalid event - "+t)}function uy(){return(new Date).getTime()}function ly(t){return new Promise(e=>{setTimeout(e,t)})}const fy=["block","network","pending","poll"];class cy{constructor(t,e,r){fd(this,"tag",t),fd(this,"listener",e),fd(this,"once",r)}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const t=this.tag.split(":");return"tx"!==t[0]?null:t[1]}get filter(){const t=this.tag.split(":");if("filter"!==t[0])return null;const e=t[1],r=""===(n=t[2])?[]:n.split(/&/g).map(t=>{if(""===t)return[];const e=t.split("|").map(t=>"null"===t?null:t);return 1===e.length?e[0]:e});var n;const i={};return r.length>0&&(i.topics=r),e&&"*"!==e&&(i.address=e),i}pollable(){return this.tag.indexOf(":")>=0||fy.indexOf(this.tag)>=0}}const dy={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function my(t){return ad(me.from(t).toHexString(),32)}function py(t){return Lc.encode(Qc([t,id(Xm(Xm(t)),0,4)]))}class gy{constructor(t,e,r){fd(this,"provider",t),fd(this,"name",r),fd(this,"address",t.formatter.address(e))}_fetchBytes(t,e){return iy(this,void 0,void 0,(function*(){const r={to:this.address,data:od([t,to(this.name),e||"0x"])},n=yield this.provider.call(r);if("0x"===n)return null;const i=me.from(id(n,0,32)).toNumber(),o=me.from(id(n,i,i+32)).toNumber();return id(n,i+32,i+32+o)}))}_getAddress(t,e){const r=dy[String(t)];if(null==r&&oy.throwError("unsupported coin type: "+t,Wc.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`}),"eth"===r.ilk)return this.provider.formatter.address(e);const n=Yc(e);if(null!=r.p2pkh){const t=e.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(t){const e=parseInt(t[1],16);if(t[2].length===2*e&&e>=1&&e<=75)return py(Qc([[r.p2pkh],"0x"+t[2]]))}}if(null!=r.p2sh){const t=e.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(t){const e=parseInt(t[1],16);if(t[2].length===2*e&&e>=1&&e<=75)return py(Qc([[r.p2sh],"0x"+t[2]]))}}if(null!=r.prefix){const t=n[1];let e=n[0];if(0===e?20!==t&&32!==t&&(e=-1):e=-1,e>=0&&n.length===2+t&&t>=1&&t<=75){const t=rg.toWords(n.slice(2));return t.unshift(e),rg.encode(r.prefix,t)}}return null}getAddress(t){return iy(this,void 0,void 0,(function*(){if(null==t&&(t=60),60===t){const t={to:this.address,data:"0x3b3b57de"+to(this.name).substring(2)},e=yield this.provider.call(t);return"0x"===e||"0x0000000000000000000000000000000000000000000000000000000000000000"===e?null:this.provider.formatter.callAddress(e)}const e=yield this._fetchBytes("0xf1cb7e06",my(t));if(null==e||"0x"===e)return null;const r=this._getAddress(t,e);return null==r&&oy.throwError("invalid or unsupported coin data",Wc.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`,coinType:t,data:e}),r}))}getContentHash(){return iy(this,void 0,void 0,(function*(){const t=yield this._fetchBytes("0xbc1c58d1");if(null==t||"0x"===t)return null;const e=t.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const t=parseInt(e[3],16);if(e[4].length===2*t)return"ipfs://"+Lc.encode("0x"+e[1])}const r=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);return r&&64===r[1].length?"bzz://"+r[1]:oy.throwError("invalid or unsupported content hash data",Wc.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:t})}))}getText(t){return iy(this,void 0,void 0,(function*(){let e=rp(t);e=Qc([my(64),my(e.length),e]),e.length%32!=0&&(e=Qc([e,ad("0x",32-t.length%32)]));const r=yield this._fetchBytes("0x59d1d43c",rd(e));return null==r||"0x"===r?null:np(r)}))}}let yy=null,vy=1;class wy extends Wo{constructor(t){if(oy.checkNew(new.target,Wo),super(),this._events=[],this._emitted={block:-2},this.formatter=new.target.getFormatter(),fd(this,"anyNetwork","any"===t),this.anyNetwork&&(t=this.detectNetwork()),t instanceof Promise)this._networkPromise=t,t.catch(t=>{}),this._ready().catch(t=>{});else{const e=cd(new.target,"getNetwork")(t);e?(fd(this,"_network",e),this.emit("network",e,null)):oy.throwArgumentError("invalid network","network",t)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return iy(this,void 0,void 0,(function*(){if(null==this._network){let t=null;if(this._networkPromise)try{t=yield this._networkPromise}catch(t){}null==t&&(t=yield this.detectNetwork()),t||oy.throwError("no network detected",Wc.errors.UNKNOWN_ERROR,{}),null==this._network&&(this.anyNetwork?this._network=t:fd(this,"_network",t),this.emit("network",t,null))}return this._network}))}get ready(){return Wp(()=>this._ready().then(t=>t,t=>{if(t.code!==Wc.errors.NETWORK_ERROR||"noNetwork"!==t.event)throw t}))}static getFormatter(){return null==yy&&(yy=new ny),yy}static getNetwork(t){return function(t){if(null==t)return null;if("number"==typeof t){for(const e in _c){const r=_c[e];if(r.chainId===t)return{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress||null,_defaultProvider:r._defaultProvider||null}}return{chainId:t,name:"unknown"}}if("string"==typeof t){const e=_c[t];return null==e?null:{name:e.name,chainId:e.chainId,ensAddress:e.ensAddress,_defaultProvider:e._defaultProvider||null}}const e=_c[t.name];if(!e)return"number"!=typeof t.chainId&&yc.throwArgumentError("invalid network chainId","network",t),t;0!==t.chainId&&t.chainId!==e.chainId&&yc.throwArgumentError("network chainId mismatch","network",t);let r=t._defaultProvider||null;var n;return null==r&&e._defaultProvider&&(r=(n=e._defaultProvider)&&"function"==typeof n.renetwork?e._defaultProvider.renetwork(t):e._defaultProvider),{name:t.name,chainId:e.chainId,ensAddress:t.ensAddress||e.ensAddress||null,_defaultProvider:r}}(null==t?"homestead":t)}_getInternalBlockNumber(t){return iy(this,void 0,void 0,(function*(){if(yield this._ready(),t>0)for(;this._internalBlockNumber;){const e=this._internalBlockNumber;try{const r=yield e;if(uy()-r.respTime<=t)return r.blockNumber;break}catch(t){if(this._internalBlockNumber===e)break}}const e=uy(),r=dd({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(t=>null,t=>t)}).then(({blockNumber:t,networkError:n})=>{if(n)throw this._internalBlockNumber===r&&(this._internalBlockNumber=null),n;const i=uy();return(t=me.from(t).toNumber())<this._maxInternalBlockNumber&&(t=this._maxInternalBlockNumber),this._maxInternalBlockNumber=t,this._setFastBlockNumber(t),{blockNumber:t,reqTime:e,respTime:i}});return this._internalBlockNumber=r,r.catch(t=>{this._internalBlockNumber===r&&(this._internalBlockNumber=null)}),(yield r).blockNumber}))}poll(){return iy(this,void 0,void 0,(function*(){const t=vy++,e=[];let r=null;try{r=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(t){return void this.emit("error",t)}if(this._setFastBlockNumber(r),this.emit("poll",t,r),r!==this._lastBlockNumber){if(-2===this._emitted.block&&(this._emitted.block=r-1),Math.abs(this._emitted.block-r)>1e3)oy.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${r})`),this.emit("error",oy.makeError("network block skew detected",Wc.errors.NETWORK_ERROR,{blockNumber:r,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",r);else for(let t=this._emitted.block+1;t<=r;t++)this.emit("block",t);this._emitted.block!==r&&(this._emitted.block=r,Object.keys(this._emitted).forEach(t=>{if("block"===t)return;const e=this._emitted[t];"pending"!==e&&r-e>12&&delete this._emitted[t]})),-2===this._lastBlockNumber&&(this._lastBlockNumber=r-1),this._events.forEach(t=>{switch(t.type){case"tx":{const r=t.hash;let n=this.getTransactionReceipt(r).then(t=>t&&null!=t.blockNumber?(this._emitted["t:"+r]=t.blockNumber,this.emit(r,t),null):null).catch(t=>{this.emit("error",t)});e.push(n);break}case"filter":{const n=t.filter;n.fromBlock=this._lastBlockNumber+1,n.toBlock=r;const i=this.getLogs(n).then(t=>{0!==t.length&&t.forEach(t=>{this._emitted["b:"+t.blockHash]=t.blockNumber,this._emitted["t:"+t.transactionHash]=t.blockNumber,this.emit(n,t)})}).catch(t=>{this.emit("error",t)});e.push(i);break}}}),this._lastBlockNumber=r,Promise.all(e).then(()=>{this.emit("didPoll",t)}).catch(t=>{this.emit("error",t)})}else this.emit("didPoll",t)}))}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return iy(this,void 0,void 0,(function*(){return oy.throwError("provider does not support network detection",Wc.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})}))}getNetwork(){return iy(this,void 0,void 0,(function*(){const t=yield this._ready(),e=yield this.detectNetwork();if(t.chainId!==e.chainId){if(this.anyNetwork)return this._network=e,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",e,t),yield ly(0),this._network;const r=oy.makeError("underlying network changed",Wc.errors.NETWORK_ERROR,{event:"changed",network:t,detectedNetwork:e});throw this.emit("error",r),r}return t}))}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(t=>{this._setFastBlockNumber(t)},t=>{}),null!=this._fastBlockNumber?this._fastBlockNumber:-1}get polling(){return null!=this._poller}set polling(t){t&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if("number"!=typeof t||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const t=uy();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(t=>((null==this._fastBlockNumber||t>this._fastBlockNumber)&&(this._fastBlockNumber=t),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){null!=this._fastBlockNumber&&t<this._fastBlockNumber||(this._fastQueryDate=uy(),(null==this._fastBlockNumber||t>this._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,e,r){return iy(this,void 0,void 0,(function*(){return this._waitForTransaction(t,null==e?1:e,r||0,null)}))}_waitForTransaction(t,e,r,n){return iy(this,void 0,void 0,(function*(){const i=yield this.getTransactionReceipt(t);return(i?i.confirmations:0)>=e?i:new Promise((i,o)=>{const s=[];let a=!1;const h=function(){return!!a||(a=!0,s.forEach(t=>{t()}),!1)},u=t=>{t.confirmations<e||h()||i(t)};if(this.on(t,u),s.push(()=>{this.removeListener(t,u)}),n){let r=n.startBlock,i=null;const u=s=>iy(this,void 0,void 0,(function*(){a||(yield ly(1e3),this.getTransactionCount(n.from).then(l=>iy(this,void 0,void 0,(function*(){if(!a){if(l<=n.nonce)r=s;else{{const e=yield this.getTransaction(t);if(e&&null!=e.blockNumber)return}for(null==i&&(i=r-3,i<n.startBlock&&(i=n.startBlock));i<=s;){if(a)return;const r=yield this.getBlockWithTransactions(i);for(let i=0;i<r.transactions.length;i++){const s=r.transactions[i];if(s.hash===t)return;if(s.from===n.from&&s.nonce===n.nonce){if(a)return;const r=yield this.waitForTransaction(s.hash,e);if(h())return;let i="replaced";return s.data===n.data&&s.to===n.to&&s.value.eq(n.value)?i="repriced":"0x"===s.data&&s.from===s.to&&s.value.isZero()&&(i="cancelled"),void o(oy.makeError("transaction was replaced",Wc.errors.TRANSACTION_REPLACED,{cancelled:"replaced"===i||"cancelled"===i,reason:i,replacement:this._wrapTransaction(s),hash:t,receipt:r}))}}i++}}a||this.once("block",u)}})),t=>{a||this.once("block",u)}))}));if(a)return;this.once("block",u),s.push(()=>{this.removeListener("block",u)})}if("number"==typeof r&&r>0){const t=setTimeout(()=>{h()||o(oy.makeError("timeout exceeded",Wc.errors.TIMEOUT,{timeout:r}))},r);t.unref&&t.unref(),s.push(()=>{clearTimeout(t)})}})}))}getBlockNumber(){return iy(this,void 0,void 0,(function*(){return this._getInternalBlockNumber(0)}))}getGasPrice(){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const t=yield this.perform("getGasPrice",{});try{return me.from(t)}catch(e){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"getGasPrice",result:t,error:e})}}))}getBalance(t,e){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield dd({address:this._getAddress(t),blockTag:this._getBlockTag(e)}),n=yield this.perform("getBalance",r);try{return me.from(n)}catch(t){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"getBalance",params:r,result:n,error:t})}}))}getTransactionCount(t,e){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield dd({address:this._getAddress(t),blockTag:this._getBlockTag(e)}),n=yield this.perform("getTransactionCount",r);try{return me.from(n).toNumber()}catch(t){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"getTransactionCount",params:r,result:n,error:t})}}))}getCode(t,e){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield dd({address:this._getAddress(t),blockTag:this._getBlockTag(e)}),n=yield this.perform("getCode",r);try{return rd(n)}catch(t){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"getCode",params:r,result:n,error:t})}}))}getStorageAt(t,e,r){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const n=yield dd({address:this._getAddress(t),blockTag:this._getBlockTag(r),position:Promise.resolve(e).then(t=>sd(t))}),i=yield this.perform("getStorageAt",n);try{return rd(i)}catch(t){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"getStorageAt",params:n,result:i,error:t})}}))}_wrapTransaction(t,e,r){if(null!=e&&32!==nd(e))throw new Error("invalid response - sendTransaction");const n=t;return null!=e&&t.hash!==e&&oy.throwError("Transaction hash mismatch from Provider.sendTransaction.",Wc.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:e}),n.wait=(e,n)=>iy(this,void 0,void 0,(function*(){null==e&&(e=1),null==n&&(n=0);let i=void 0;0!==e&&null!=r&&(i={data:t.data,from:t.from,nonce:t.nonce,to:t.to,value:t.value,startBlock:r});const o=yield this._waitForTransaction(t.hash,e,n,i);return null==o&&0===e?null:(this._emitted["t:"+t.hash]=o.blockNumber,0===o.status&&oy.throwError("transaction failed",Wc.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:o}),o)})),n}sendTransaction(t){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const e=yield Promise.resolve(t).then(t=>rd(t)),r=this.formatter.transaction(t),n=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const t=yield this.perform("sendTransaction",{signedTransaction:e});return this._wrapTransaction(r,t,n)}catch(t){throw t.transaction=r,t.transactionHash=r.hash,t}}))}_getTransactionRequest(t){return iy(this,void 0,void 0,(function*(){const e=yield t,r={};return["from","to"].forEach(t=>{null!=e[t]&&(r[t]=Promise.resolve(e[t]).then(t=>t?this._getAddress(t):null))}),["gasLimit","gasPrice","value"].forEach(t=>{null!=e[t]&&(r[t]=Promise.resolve(e[t]).then(t=>t?me.from(t):null))}),["type"].forEach(t=>{null!=e[t]&&(r[t]=Promise.resolve(e[t]).then(t=>null!=t?t:null))}),e.accessList&&(r.accessList=this.formatter.accessList(e.accessList)),["data"].forEach(t=>{null!=e[t]&&(r[t]=Promise.resolve(e[t]).then(t=>t?rd(t):null))}),this.formatter.transactionRequest(yield dd(r))}))}_getFilter(t){return iy(this,void 0,void 0,(function*(){t=yield t;const e={};return null!=t.address&&(e.address=this._getAddress(t.address)),["blockHash","topics"].forEach(r=>{null!=t[r]&&(e[r]=t[r])}),["fromBlock","toBlock"].forEach(r=>{null!=t[r]&&(e[r]=this._getBlockTag(t[r]))}),this.formatter.filter(yield dd(e))}))}call(t,e){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield dd({transaction:this._getTransactionRequest(t),blockTag:this._getBlockTag(e)}),n=yield this.perform("call",r);try{return rd(n)}catch(t){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"call",params:r,result:n,error:t})}}))}estimateGas(t){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const e=yield dd({transaction:this._getTransactionRequest(t)}),r=yield this.perform("estimateGas",e);try{return me.from(r)}catch(t){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"estimateGas",params:e,result:r,error:t})}}))}_getAddress(t){return iy(this,void 0,void 0,(function*(){const e=yield this.resolveName(t);return null==e&&oy.throwError("ENS name not configured",Wc.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),e}))}_getBlock(t,e){return iy(this,void 0,void 0,(function*(){yield this.getNetwork(),t=yield t;let r=-128;const n={includeTransactions:!!e};if(ed(t,32))n.blockHash=t;else try{n.blockTag=this.formatter.blockTag(yield this._getBlockTag(t)),ed(n.blockTag)&&(r=parseInt(n.blockTag.substring(2),16))}catch(e){oy.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return Wp(()=>iy(this,void 0,void 0,(function*(){const t=yield this.perform("getBlock",n);if(null==t)return null!=n.blockHash&&null==this._emitted["b:"+n.blockHash]||null!=n.blockTag&&r>this._emitted.block?null:void 0;if(e){let e=null;for(let r=0;r<t.transactions.length;r++){const n=t.transactions[r];if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){null==e&&(e=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let t=e-n.blockNumber+1;t<=0&&(t=1),n.confirmations=t}}return this.formatter.blockWithTransactions(t)}return this.formatter.block(t)})),{oncePoll:this})}))}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return iy(this,void 0,void 0,(function*(){yield this.getNetwork(),t=yield t;const e={transactionHash:this.formatter.hash(t,!0)};return Wp(()=>iy(this,void 0,void 0,(function*(){const r=yield this.perform("getTransaction",e);if(null==r)return null==this._emitted["t:"+t]?null:void 0;const n=this.formatter.transactionResponse(r);if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){let t=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-n.blockNumber+1;t<=0&&(t=1),n.confirmations=t}return this._wrapTransaction(n)})),{oncePoll:this})}))}getTransactionReceipt(t){return iy(this,void 0,void 0,(function*(){yield this.getNetwork(),t=yield t;const e={transactionHash:this.formatter.hash(t,!0)};return Wp(()=>iy(this,void 0,void 0,(function*(){const r=yield this.perform("getTransactionReceipt",e);if(null==r)return null==this._emitted["t:"+t]?null:void 0;if(null==r.blockHash)return;const n=this.formatter.receipt(r);if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){let t=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-n.blockNumber+1;t<=0&&(t=1),n.confirmations=t}return n})),{oncePoll:this})}))}getLogs(t){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const e=yield dd({filter:this._getFilter(t)}),r=yield this.perform("getLogs",e);return r.forEach(t=>{null==t.removed&&(t.removed=!1)}),ny.arrayOf(this.formatter.filterLog.bind(this.formatter))(r)}))}getEtherPrice(){return iy(this,void 0,void 0,(function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})}))}_getBlockTag(t){return iy(this,void 0,void 0,(function*(){if("number"==typeof(t=yield t)&&t<0){t%1&&oy.throwArgumentError("invalid BlockTag","blockTag",t);let e=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return e+=t,e<0&&(e=0),this.formatter.blockTag(e)}return this.formatter.blockTag(t)}))}getResolver(t){return iy(this,void 0,void 0,(function*(){const e=yield this._getResolver(t);return null==e?null:new gy(this,e,t)}))}_getResolver(t){return iy(this,void 0,void 0,(function*(){const e=yield this.getNetwork();e.ensAddress||oy.throwError("network does not support ENS",Wc.errors.UNSUPPORTED_OPERATION,{operation:"ENS",network:e.name});const r={to:e.ensAddress,data:"0x0178b8bf"+to(t).substring(2)};return this.formatter.callAddress(yield this.call(r))}))}resolveName(t){return iy(this,void 0,void 0,(function*(){t=yield t;try{return Promise.resolve(this.formatter.address(t))}catch(e){if(ed(t))throw e}"string"!=typeof t&&oy.throwArgumentError("invalid ENS name","name",t);const e=yield this.getResolver(t);return e?yield e.getAddress():null}))}lookupAddress(t){return iy(this,void 0,void 0,(function*(){t=yield t;const e=(t=this.formatter.address(t)).substring(2).toLowerCase()+".addr.reverse",r=yield this._getResolver(e);if(!r)return null;let n=Yc(yield this.call({to:r,data:"0x691f3431"+to(e).substring(2)}));if(n.length<32||!me.from(n.slice(0,32)).eq(32))return null;if(n=n.slice(32),n.length<32)return null;const i=me.from(n.slice(0,32)).toNumber();if(n=n.slice(32),i>n.length)return null;const o=np(n.slice(0,i));return(yield this.resolveName(o))!=t?null:o}))}perform(t,e){return oy.throwError(t+" not implemented",Wc.errors.NOT_IMPLEMENTED,{operation:t})}_startEvent(t){this.polling=this._events.filter(t=>t.pollable()).length>0}_stopEvent(t){this.polling=this._events.filter(t=>t.pollable()).length>0}_addEventListener(t,e,r){const n=new cy(hy(t),e,r);return this._events.push(n),this._startEvent(n),this}on(t,e){return this._addEventListener(t,e,!1)}once(t,e){return this._addEventListener(t,e,!0)}emit(t,...e){let r=!1,n=[],i=hy(t);return this._events=this._events.filter(t=>t.tag!==i||(setTimeout(()=>{t.listener.apply(this,e)},0),r=!0,!t.once||(n.push(t),!1))),n.forEach(t=>{this._stopEvent(t)}),r}listenerCount(t){if(!t)return this._events.length;let e=hy(t);return this._events.filter(t=>t.tag===e).length}listeners(t){if(null==t)return this._events.map(t=>t.listener);let e=hy(t);return this._events.filter(t=>t.tag===e).map(t=>t.listener)}off(t,e){if(null==e)return this.removeAllListeners(t);const r=[];let n=!1,i=hy(t);return this._events=this._events.filter(t=>t.tag!==i||t.listener!=e||(!!n||(n=!0,r.push(t),!1))),r.forEach(t=>{this._stopEvent(t)}),this}removeAllListeners(t){let e=[];if(null==t)e=this._events,this._events=[];else{const r=hy(t);this._events=this._events.filter(t=>t.tag!==r||(e.push(t),!1))}return e.forEach(t=>{this._stopEvent(t)}),this}}var by=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const Ey=new Wc("abstract-signer/5.3.0"),My=["accessList","chainId","data","from","gasLimit","gasPrice","nonce","to","type","value"],_y=[Wc.errors.INSUFFICIENT_FUNDS,Wc.errors.NONCE_EXPIRED,Wc.errors.REPLACEMENT_UNDERPRICED];class Ay{constructor(){Ey.checkAbstract(new.target,Ay),fd(this,"_isSigner",!0)}getBalance(t){return by(this,void 0,void 0,(function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),t)}))}getTransactionCount(t){return by(this,void 0,void 0,(function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),t)}))}estimateGas(t){return by(this,void 0,void 0,(function*(){this._checkProvider("estimateGas");const e=yield dd(this.checkTransaction(t));return yield this.provider.estimateGas(e)}))}call(t,e){return by(this,void 0,void 0,(function*(){this._checkProvider("call");const r=yield dd(this.checkTransaction(t));return yield this.provider.call(r,e)}))}sendTransaction(t){return this._checkProvider("sendTransaction"),this.populateTransaction(t).then(t=>this.signTransaction(t).then(t=>this.provider.sendTransaction(t)))}getChainId(){return by(this,void 0,void 0,(function*(){this._checkProvider("getChainId");return(yield this.provider.getNetwork()).chainId}))}getGasPrice(){return by(this,void 0,void 0,(function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()}))}resolveName(t){return by(this,void 0,void 0,(function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(t)}))}checkTransaction(t){for(const e in t)-1===My.indexOf(e)&&Ey.throwArgumentError("invalid transaction key: "+e,"transaction",t);const e=md(t);return null==e.from?e.from=this.getAddress():e.from=Promise.all([Promise.resolve(e.from),this.getAddress()]).then(e=>(e[0].toLowerCase()!==e[1].toLowerCase()&&Ey.throwArgumentError("from address mismatch","transaction",t),e[0])),e}populateTransaction(t){return by(this,void 0,void 0,(function*(){const e=yield dd(this.checkTransaction(t));return null!=e.to&&(e.to=Promise.resolve(e.to).then(t=>by(this,void 0,void 0,(function*(){if(null==t)return null;const e=yield this.resolveName(t);return null==e&&Ey.throwArgumentError("provided ENS name resolves to null","tx.to",t),e})))),null==e.gasPrice&&(e.gasPrice=this.getGasPrice()),null==e.nonce&&(e.nonce=this.getTransactionCount("pending")),null==e.gasLimit&&(e.gasLimit=this.estimateGas(e).catch(t=>{if(_y.indexOf(t.code)>=0)throw t;return Ey.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Wc.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,tx:e})})),null==e.chainId?e.chainId=this.getChainId():e.chainId=Promise.all([Promise.resolve(e.chainId),this.getChainId()]).then(e=>(0!==e[1]&&e[0]!==e[1]&&Ey.throwArgumentError("chainId address mismatch","transaction",t),e[0])),yield dd(e)}))}_checkProvider(t){this.provider||Ey.throwError("missing provider",Wc.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!(!t||!t._isSigner)}}var Ny=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const Sy=new Wc(ng),Ry=["call","estimateGas"];function Uy(t,e,r){if("call"===t&&e.code===Wc.errors.SERVER_ERROR){const t=e.error;if(t&&t.message.match("reverted")&&ed(t.data))return t.data}let n=e.message;e.code===Wc.errors.SERVER_ERROR&&e.error&&"string"==typeof e.error.message?n=e.error.message:"string"==typeof e.body?n=e.body:"string"==typeof e.responseText&&(n=e.responseText),n=(n||"").toLowerCase();const i=r.transaction||r.signedTransaction;throw n.match(/insufficient funds/)&&Sy.throwError("insufficient funds for intrinsic transaction cost",Wc.errors.INSUFFICIENT_FUNDS,{error:e,method:t,transaction:i}),n.match(/nonce too low/)&&Sy.throwError("nonce has already been used",Wc.errors.NONCE_EXPIRED,{error:e,method:t,transaction:i}),n.match(/replacement transaction underpriced/)&&Sy.throwError("replacement fee too low",Wc.errors.REPLACEMENT_UNDERPRICED,{error:e,method:t,transaction:i}),n.match(/only replay-protected/)&&Sy.throwError("legacy pre-eip-155 transactions not supported",Wc.errors.UNSUPPORTED_OPERATION,{error:e,method:t,transaction:i}),Ry.indexOf(t)>=0&&n.match(/gas required exceeds allowance|always failing transaction|execution reverted/)&&Sy.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Wc.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:t,transaction:i}),e}function Iy(t){return new Promise((function(e){setTimeout(e,t)}))}function Py(t){if(t.error){const e=new Error(t.error.message);throw e.code=t.error.code,e.data=t.error.data,e}return t.result}function xy(t){return t?t.toLowerCase():t}const ky={};class Ty extends Ay{constructor(t,e,r){if(Sy.checkNew(new.target,Ty),super(),t!==ky)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");fd(this,"provider",e),null==r&&(r=0),"string"==typeof r?(fd(this,"_address",this.provider.formatter.address(r)),fd(this,"_index",null)):"number"==typeof r?(fd(this,"_index",r),fd(this,"_address",null)):Sy.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(t){return Sy.throwError("cannot alter JSON-RPC Signer connection",Wc.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new Oy(ky,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&Sy.throwError("unknown account #"+this._index,Wc.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=md(t);const e=this.getAddress().then(t=>(t&&(t=t.toLowerCase()),t));if(null==t.gasLimit){const r=md(t);r.from=e,t.gasLimit=this.provider.estimateGas(r)}return dd({tx:dd(t),sender:e}).then(({tx:e,sender:r})=>{null!=e.from?e.from.toLowerCase()!==r&&Sy.throwArgumentError("from address mismatch","transaction",t):e.from=r;const n=this.provider.constructor.hexlifyTransaction(e,{from:!0});return this.provider.send("eth_sendTransaction",[n]).then(t=>t,t=>Uy("sendTransaction",t,n))})}signTransaction(t){return Sy.throwError("signing transactions is unsupported",Wc.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return Ny(this,void 0,void 0,(function*(){const e=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),r=yield this.sendUncheckedTransaction(t);try{return yield Wp(()=>Ny(this,void 0,void 0,(function*(){const t=yield this.provider.getTransaction(r);if(null!==t)return this.provider._wrapTransaction(t,r,e)})),{oncePoll:this.provider})}catch(t){throw t.transactionHash=r,t}}))}signMessage(t){return Ny(this,void 0,void 0,(function*(){const e="string"==typeof t?rp(t):t,r=yield this.getAddress();return yield this.provider.send("eth_sign",[r.toLowerCase(),rd(e)])}))}_signTypedData(t,e,r){return Ny(this,void 0,void 0,(function*(){const n=yield _o.resolveNames(t,e,r,t=>this.provider.resolveName(t)),i=yield this.getAddress();return yield this.provider.send("eth_signTypedData_v4",[i.toLowerCase(),JSON.stringify(_o.getPayload(n.domain,e,n.value))])}))}unlock(t){return Ny(this,void 0,void 0,(function*(){const e=this.provider,r=yield this.getAddress();return e.send("personal_unlockAccount",[r.toLowerCase(),t,null])}))}}class Oy extends Ty{sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>({hash:t,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:e=>this.provider.waitForTransaction(t,e)}))}}const Cy={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0};class Fy extends wy{constructor(t,e){Sy.checkNew(new.target,Fy);let r=e;null==r&&(r=new Promise((t,e)=>{setTimeout(()=>{this.detectNetwork().then(e=>{t(e)},t=>{e(t)})},0)})),super(r),t||(t=cd(this.constructor,"defaultUrl")()),fd(this,"connection","string"==typeof t?Object.freeze({url:t}):Object.freeze(md(t))),this._nextId=42}get _cache(){return null==this._eventLoopCache&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return Ny(this,void 0,void 0,(function*(){yield Iy(0);let t=null;try{t=yield this.send("eth_chainId",[])}catch(e){try{t=yield this.send("net_version",[])}catch(t){}}if(null!=t){const e=cd(this.constructor,"getNetwork");try{return e(me.from(t).toNumber())}catch(e){return Sy.throwError("could not detect network",Wc.errors.NETWORK_ERROR,{chainId:t,event:"invalidNetwork",serverError:e})}}return Sy.throwError("could not detect network",Wc.errors.NETWORK_ERROR,{event:"noNetwork"})}))}getSigner(t){return new Ty(ky,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(t=>this.formatter.address(t)))}send(t,e){const r={method:t,params:e,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:yd(r),provider:this});const n=["eth_chainId","eth_blockNumber"].indexOf(t)>=0;if(n&&this._cache[t])return this._cache[t];const i=Kp(this.connection,JSON.stringify(r),Py).then(t=>(this.emit("debug",{action:"response",request:r,response:t,provider:this}),t),t=>{throw this.emit("debug",{action:"response",error:t,request:r,provider:this}),t});return n&&(this._cache[t]=i,setTimeout(()=>{this._cache[t]=null},0)),i}prepareRequest(t,e){switch(t){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[xy(e.address),e.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[xy(e.address),e.blockTag]];case"getCode":return["eth_getCode",[xy(e.address),e.blockTag]];case"getStorageAt":return["eth_getStorageAt",[xy(e.address),e.position,e.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[e.signedTransaction]];case"getBlock":return e.blockTag?["eth_getBlockByNumber",[e.blockTag,!!e.includeTransactions]]:e.blockHash?["eth_getBlockByHash",[e.blockHash,!!e.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[e.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[e.transactionHash]];case"call":return["eth_call",[cd(this.constructor,"hexlifyTransaction")(e.transaction,{from:!0}),e.blockTag]];case"estimateGas":return["eth_estimateGas",[cd(this.constructor,"hexlifyTransaction")(e.transaction,{from:!0})]];case"getLogs":return e.filter&&null!=e.filter.address&&(e.filter.address=xy(e.filter.address)),["eth_getLogs",[e.filter]]}return null}perform(t,e){return Ny(this,void 0,void 0,(function*(){const r=this.prepareRequest(t,e);null==r&&Sy.throwError(t+" not implemented",Wc.errors.NOT_IMPLEMENTED,{operation:t});try{return yield this.send(r[0],r[1])}catch(r){return Uy(t,r,e)}}))}_startEvent(t){"pending"===t.tag&&this._startPending(),super._startEvent(t)}_startPending(){if(null!=this._pendingFilter)return;const t=this,e=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=e,e.then((function(r){return function n(){t.send("eth_getFilterChanges",[r]).then((function(r){if(t._pendingFilter!=e)return null;let n=Promise.resolve();return r.forEach((function(e){t._emitted["t:"+e.toLowerCase()]="pending",n=n.then((function(){return t.getTransaction(e).then((function(e){return t.emit("pending",e),null}))}))})),n.then((function(){return Iy(1e3)}))})).then((function(){if(t._pendingFilter==e)return setTimeout((function(){n()}),0),null;t.send("eth_uninstallFilter",[r])})).catch(t=>{})}(),r})).catch(t=>{})}_stopEvent(t){"pending"===t.tag&&0===this.listenerCount("pending")&&(this._pendingFilter=null),super._stopEvent(t)}static hexlifyTransaction(t,e){const r=md(Cy);if(e)for(const t in e)e[t]&&(r[t]=!0);!function(t,e){t&&"object"==typeof t||ld.throwArgumentError("invalid object","object",t),Object.keys(t).forEach(r=>{e[r]||ld.throwArgumentError("invalid object key - "+r,"transaction:"+r,t)})}(t,r);const n={};return["gasLimit","gasPrice","type","nonce","value"].forEach((function(e){if(null==t[e])return;const r=sd(t[e]);"gasLimit"===e&&(e="gas"),n[e]=r})),["from","to","data"].forEach((function(e){null!=t[e]&&(n[e]=rd(t[e]))})),t.accessList&&(n.accessList=Qg(t.accessList)),n}}var Dy=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const Ly=new Wc(ng);class $y extends Fy{detectNetwork(){const t=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return Dy(this,void 0,void 0,(function*(){let e=this.network;return null==e&&(e=yield t.detectNetwork.call(this),e||Ly.throwError("no network detected",Wc.errors.UNKNOWN_ERROR,{}),null==this._network&&(fd(this,"_network",e),this.emit("network",e,null))),e}))}}var By={1:{key:"1",name:"Ethereum Mainnet",chainId:1,network:"homestead",multicall:"0xeefba1e63905ef1d7acba5a8513c70307c1ce441",ensResolver:"0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41",rpc:[{url:"https://api-geth-archive.ankr.com",user:"balancer_user",password:"balancerAnkr20201015"},"https://rpc.ankr.com/eth","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/eth/mainnet/archive","https://apis.ankr.com/e62bc219f9c9462b8749defe472d2dc5/6106d4a3ec1d1bcc87ec72158f8fd089/eth/archive/main","https://eth-archival.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://eth-mainnet.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv","https://cloudflare-eth.com"],ws:["wss://eth-mainnet.ws.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],explorer:"https://etherscan.io",start:7929876,imageIPFS:"QmR2UYZczmYa4s8mr9HZHci5AQwyAnwUW7tSUZz7KWF3sA"},3:{key:"3",name:"Ethereum Testnet Ropsten",shortName:"Ropsten",chainId:3,network:"ropsten",testnet:!0,multicall:"0x53c43764255c17bd724f74c4ef150724ac50a3ed",rpc:["https://eth-ropsten.alchemyapi.io/v2/QzGz6gdkpTyDzebi3PjxIaKO7bDTGnSy"],explorer:"https://ropsten.etherscan.io",start:7980811,imageIPFS:"QmR2UYZczmYa4s8mr9HZHci5AQwyAnwUW7tSUZz7KWF3sA"},4:{key:"4",name:"Ethereum Testnet Rinkeby",shortName:"Rinkeby",chainId:4,network:"rinkeby",testnet:!0,multicall:"0x42ad527de7d4e9d9d011ac45b31d8551f8fe9821",ensResolver:"0xf6305c19e814d2a75429fd637d01f7ee0e77d615",rpc:["https://eth-rinkeby.alchemyapi.io/v2/ugiPEBqMebLQbjro42kalZ1h4StpW_fR","https://eth-rinkeby.gateway.pokt.network/v1/5f76124fb90218002e9ce985"],ws:["wss://eth-rinkeby.ws.alchemyapi.io/v2/twReQE9Px03E-E_N_Fbb3OVF7YgHxoGq"],explorer:"https://rinkeby.etherscan.io",start:4534725,imageIPFS:"QmR2UYZczmYa4s8mr9HZHci5AQwyAnwUW7tSUZz7KWF3sA"},5:{key:"5",name:"Ethereum Testnet Görli",shortName:"Görli",chainId:5,network:"goerli",testnet:!0,multicall:"0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e",rpc:["https://eth-goerli.alchemyapi.io/v2/v4nqH_J-J3STit45Mm07TxuYexMHQsYZ"],explorer:"https://goerli.etherscan.io",start:743550,imageIPFS:"QmR2UYZczmYa4s8mr9HZHci5AQwyAnwUW7tSUZz7KWF3sA"},7:{key:"7",name:"ThaiChain",chainId:7,network:"mainnet",multicall:"0xB9cb900E526e7Ad32A2f26f1fF6Dee63350fcDc5",rpc:["https://rpc.dome.cloud"],ws:["wss://ws.dome.cloud"],explorer:"https://exp.tch.in.th",imageIPFS:"QmUcNN6ZMFEPLUw5WCknisSgs7nhWC5p992jSSsJVq34Eo"},8:{key:"8",name:"Ubiq Mainnet",chainId:8,network:"Ubiq mainnet",multicall:"0x6668750957e4083725926B71C41bDF1434C73262",rpc:["https://rpc.octano.dev"],ws:["wss://ws.octano.dev"],explorer:"https://ubiqscan.io",imageIPFS:"Qmec3HLoN4QhwZAhw4XTi2aN8Wwmcko5hHN22sHARzb9tw"},10:{key:"10",name:"Optimism Mainnet",chainId:10,network:"Optimism mainnet",multicall:"0x35A6Cdb2C9AD4a45112df4a04147EB07dFA01aB7",rpc:["https://opt-mainnet.g.alchemy.com/v2/JzmIL4Q3jBj7it2duxLFeuCa9Wobmm7D"],explorer:"https://optimistic.etherscan.io",start:657806,imageIPFS:"QmfF4kwhGL8QosUXvgq2KWCmavhKBvwD6kbhs7L4p5ZAWb"},20:{key:"20",name:"Elastos Smart Chain",shortName:"ESC",chainId:20,network:"mainnet",multicall:"0x20205D3b6008bea1411bd4CaEA2D923FE231B6E5",rpc:["https://rpc.glidefinance.io","https://escrpc.elaphant.app"],explorer:"https://esc.elastos.io",start:7826070,imageIPFS:"Qmd2muU2UHo5WsTxE9EpZZJeatimTT9GD4sEnHQe6i9wiA"},25:{key:"25",name:"Cronos Mainnet",shortName:"Cronos",chainId:25,network:"mainnet",multicall:"0x6F522a3982e8F9A50A2EDc9E46ed1A3aE2B3FD3a",rpc:["https://evm-cronos.crypto.org"],explorer:"https://cronos.crypto.org/explorer",start:4067,imageIPFS:"QmfSJbtirJoa3Pt7o5Fdm85wbyw9V1hpzqLr5PQbdnfsAj"},30:{key:"30",name:"RSK Mainnet",chainId:30,network:"rsk mainnet",multicall:"0x4eeebb5580769ba6d26bfd07be636300076d1831",rpc:["https://public-node.rsk.co"],explorer:"https://explorer.rsk.co",start:2516442,imageIPFS:"QmXTwpE1SqoNZmyY4c3fYWy6qUgQELsyWKbgJo2Pg6K6V9"},31:{key:"31",name:"RSK Testnet",chainId:31,network:"rsk testnet",testnet:!0,multicall:"0x4eeebb5580769ba6d26bfd07be636300076d1831",rpc:["https://public-node.testnet.rsk.co"],explorer:"https://explorer.testnet.rsk.co",start:1002369,imageIPFS:"QmbpnJowePd9sDy8hrJv7LsTBkxksuJauw56Y7BqdMdzec"},42:{key:"42",name:"Ethereum Testnet Kovan",shortName:"Kovan",chainId:42,network:"kovan",testnet:!0,multicall:"0x2cc8688c5f75e365aaeeb4ea8d6a480405a48d2a",rpc:["https://eth-kovan.alchemyapi.io/v2/sR9qngOH3w78GAaTtlTe8GwEnij0SnEa","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/eth/kovan/archive","https://eth-kovan.alchemyapi.io/v2/s96TIUFYg0LuddgpmafA040ZyUaZbrpM","https://poa-kovan.gateway.pokt.network/v1/5f76124fb90218002e9ce985"],ws:["wss://eth-kovan.ws.alchemyapi.io/v2/QCsM2iU0bQ49eGDmZ7-Y--Wpu0lVWXSO"],explorer:"https://kovan.etherscan.io",start:11482433,imageIPFS:"QmR2UYZczmYa4s8mr9HZHci5AQwyAnwUW7tSUZz7KWF3sA"},44:{key:"44",name:"Crab Network",shortName:"Crab",chainId:44,network:"mainnet",multicall:"0x4617D470F847Ce166019d19a7944049ebB017400",rpc:["https://crab-rpc.darwinia.network"],explorer:"https://crab.subscan.io",imageIPFS:"QmTpySsG7rjLwuZX1Ep4ewGyVAyGrvCRC1oqEvU6oP1huf"},50:{key:"50",name:"XDC.Network",shortName:"XDC",chainId:50,network:"mainnet",multicall:"0xc8160deb19559d93eadb82798ededce696ebcaf5",rpc:["https://snapshotrpc.blocksscan.io/","https://rpc.xinfin.network"],ws:["wss://ws.blocksscan.io"],explorer:"http://xdc.blocksscan.io",imageIPFS:"QmaX3pqjWGg97bR6jjxvTopRkJVxrvwp6VB4jf1Lknq111"},51:{key:"51",name:"XDC Apothem.network",shortName:"XDC",chainId:51,network:"testnet",multicall:"0x3b353b02a8b42ee4222ea4be0836629b1f40c8db",rpc:["https://apothemrpc.blocksscan.io"],ws:["wss://apothemws.blocksscan.io"],explorer:"http://apothem.blocksscan.io",imageIPFS:"QmaX3pqjWGg97bR6jjxvTopRkJVxrvwp6VB4jf1Lknq111"},56:{key:"56",name:"Binance Smart Chain Mainnet",shortName:"BSC",chainId:56,network:"mainnet",multicall:"0x1ee38d535d541c55c9dae27b12edf090c608e6fb",rpc:["https://apis.ankr.com/c0d871dd3c6d4529b01c9362a9b79e89/6106d4a3ec1d1bcc87ec72158f8fd089/binance/archive/main","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/bsc/mainnet/archive","https://bsc.getblock.io/mainnet/?api_key=91f8195f-bf46-488f-846a-73d6853790e7","https://bsc-private-dataseed1.nariox.org","https://bsc-private-dataseed2.nariox.org","https://bsc-dataseed1.ninicoin.io","https://bsc-dataseed1.binance.org","https://bsc-dataseed2.binance.org","https://bsc-dataseed3.binance.org"],explorer:"https://bscscan.com",start:461230,imageIPFS:"QmWQaQ4Tv28DwA4DRKjSDJFWY9mZboGvuu77J8nh7kucxv"},61:{key:"61",name:"Ethereum Classic Mainnet",shortName:"Ethereum Classic",chainId:61,network:"mainnet",multicall:"",rpc:["https://ethereumclassic.network"],explorer:"https://blockscout.com/etc/mainnet",imageIPFS:"QmVegc28DvA7LjKUFysab81c9BSuN4wQVDQkRXyAtuEBis"},65:{key:"65",name:"OKExChain Testnet",shortName:"OEC Testnet",chainId:65,network:"oec testnet",testnet:!0,multicall:"0x04c68A7fB750ca0Ba232105B3b094926a0f77645",rpc:["https://exchaintestrpc.okex.org"],ws:["wss://exchaintestws.okex.org:8443"],explorer:"https://www.oklink.com/okexchain-test",start:5320359,imageIPFS:"Qmd7dKnNwHRZ4HRCbCXUbkNV7gP28fGqPdjbHtjRtT9sQF"},66:{key:"66",name:"OKExChain Mainnet",shortName:"OEC Mainnet",chainId:66,network:"oec mainnet",multicall:"0x6EB187d8197Ac265c945b69f3c3064A6f3831866",rpc:["https://exchainrpc.okex.org"],ws:["wss://exchainws.okex.org:8443"],explorer:"https://www.oklink.com/okexchain",start:5076543,imageIPFS:"Qmd7dKnNwHRZ4HRCbCXUbkNV7gP28fGqPdjbHtjRtT9sQF"},69:{key:"69",name:"Optimism Kovan",chainId:69,network:"Optimism testnet",testnet:!0,multicall:"0x28e9a2329aa6b675ca251a2ccaa7fb029c1e9bfb",rpc:["https://opt-kovan.g.alchemy.com/v2/JzmIL4Q3jBj7it2duxLFeuCa9Wobmm7D"],explorer:"https://kovan-optimistic.etherscan.io",start:882942,imageIPFS:"QmfF4kwhGL8QosUXvgq2KWCmavhKBvwD6kbhs7L4p5ZAWb"},70:{key:"70",name:"Hoo Smart Chain Mainnet",shortName:"hsc",chainId:70,network:"Mainnet",multicall:"0xd4b794b89baccb70ef851830099bee4d69f19ebc",rpc:["https://http-mainnet2.hoosmartchain.com"],ws:["wss://ws-mainnet2.hoosmartchain.com"],explorer:"https://hooscan.com",start:404118,imageIPFS:"QmNhFCVw5GDsu86sGchoRNvQjcr5GL79UJQ3xCHzdFbZYk"},74:{key:"74",name:"IDChain",shortName:"IDChain",chainId:74,network:"mainnet",multicall:"0x41d289c966D51342A515A19dE9c27d16079c94E0",rpc:["https://idchain.one/archive/rpc/","https://idchain.songadao.org/rpc"],explorer:"https://explorer.idchain.one",start:10780012,imageIPFS:"QmXAKaNsyv6ctuRenYRJuZ1V4kn1eFwkUtjrjzX6jiKTqe"},80:{key:"80",name:"GeneChain",chainId:80,network:"Mainnet",multicall:"0x9e6ed491171A0D9089892aA5F14800f9f32038eb",rpc:["https://rpc.genechain.io"],explorer:"https://scan.genechain.io",imageIPFS:"QmSV3LTGzE4159zLK4xJVDH5t8iKhY4peh7VAkjefawr2q"},81:{key:"81",name:"Shibuya Network",shortName:"Shibuya",chainId:81,network:"testnet",testnet:!0,multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shibuya.astar.network:8545"],explorer:"https://blockscout.com/shibuya",start:856303,imageIPFS:"QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},82:{key:"82",name:"Meter Mainnet",shortName:"Meter",chainId:82,network:"mainnet",multicall:"0x579De77CAEd0614e3b158cb738fcD5131B9719Ae",rpc:["https://rpc.meter.io"],explorer:"https://scan.meter.io",start:4992871,imageIPFS:"QmSZvT9w9eUDvV1YVaq3BKKEbubtNVqu1Rin44FuN4wz11"},97:{key:"97",name:"Binance Smart Chain Testnet",shortName:"BSC Testnet",chainId:97,network:"testnet",testnet:!0,multicall:"0x8b54247c6BAe96A6ccAFa468ebae96c4D7445e46",rpc:["https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/bsc/testnet/archive","https://data-seed-prebsc-1-s1.binance.org:8545"],explorer:"https://testnet.bscscan.com",start:3599656,imageIPFS:"QmWQaQ4Tv28DwA4DRKjSDJFWY9mZboGvuu77J8nh7kucxv"},99:{key:"99",name:"POA Core",shortName:"POA",chainId:99,network:"mainnet",multicall:"0x2754BB10580dFc6d8Ce6d6CA2939021A06923394",rpc:["https://core.poa.network"],explorer:"https://blockscout.com/poa/core",start:22543252,imageIPFS:"QmZNFCQGA7qT4XJnPSH5NNYrqK6aFsfzZ1NzJwp5D4Tdjr"},100:{key:"100",name:"Gnosis Chain",shortName:"xDAI",chainId:100,network:"mainnet",multicall:"0xb5b692a88bdfc81ca69dcb1d924f59f0413a602a",rpc:["https://xdai-archive.blockscout.com","https://poa-xdai.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://rpc.gnosischain.com"],ws:["wss://rpc.xdaichain.com/wss"],explorer:"https://blockscout.com/poa/xdai",start:4108192,imageIPFS:"QmZeiy8Ax4133wzxUQM9ky8z5XFVf6YLFjJMmTWbWVniZR"},106:{key:"106",name:"Velas EVM Mainnet",shortName:"Velas",chainId:106,network:"mainnet",multicall:"0x597Cc7c49a8e0041d3A43ec8D7dc651b47879108",rpc:["https://evmexplorer.velas.com/rpc","https://explorer.velas.com/rpc"],ws:["wss://api.velas.com"],explorer:"https://evmexplorer.velas.com",start:141800,imageIPFS:"QmNXiCXJxEeBd7ZYGYjPSMTSdbDd2nfodLC677gUfk9ku5"},108:{key:"108",name:"Thundercore Mainnet",chainId:108,network:"mainnet",multicall:"",rpc:["https://mainnet-rpc.thundercore.com"],explorer:"https://scan.thundercore.com",imageIPFS:"QmbEsmMPZALcfvNnGDg8F2ABCJM3T2UFBiVBaRsMdkjefG"},111:{key:"111",name:"Velas EVM Testnet",shortName:"Velas Testnet",chainId:111,network:"testnet",testnet:!0,multicall:"0x55a827538FbF41b7334Dd49001220597898Ad954",rpc:["https://evmexplorer.testnet.velas.com/rpc","https://explorer.testnet.velas.com/rpc"],ws:["wss://api.testnet.velas.com"],explorer:"https://evmexplorer.testnet.velas.com",start:1195129,imageIPFS:"QmQFWn7JJLigUPvvp6uKg6EWikx7QeNxQ2vaCngU3Uthho"},122:{key:"122",name:"Fuse Mainnet",shortName:"Fuse",chainId:122,network:"mainnet",multicall:"0x7a59441fb06666F6d2D766393d876945D06a169c",rpc:["https://oefusefull1.liquify.info/"],explorer:"https://explorer.fuse.io",start:11923459,imageIPFS:"QmXjWb64nako7voaVEifgdjAbDbswpTY8bghsiHpv8yWtb"},128:{key:"128",name:"Huobi Eco Chain Mainnet",shortName:"heco",chainId:128,network:"Mainnet",multicall:"0x37ab26db3df780e7026f3e767f65efb739f48d8e",rpc:["https://pub001.hg.network/rpc"],ws:["wss://pub001.hg.network/ws"],explorer:"https://hecoinfo.com",start:403225,imageIPFS:"QmSJEdToMvmjqoPvVq7awwdMeYKhXUYZMBiax9yHtFGMSq"},137:{key:"137",name:"Polygon Mainnet",shortName:"Polygon",chainId:137,network:"mainnet",multicall:"0xCBca837161be50EfA5925bB9Cc77406468e76751",rpc:["https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/polygon/mainnet/archive","https://rpc-mainnet.maticvigil.com/v1/1cfd7598e5ba6dcf0b4db58e8be484badc6ea08e","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/polygon/mainnet/archive"],ws:["wss://ws-mainnet.matic.network"],explorer:"https://polygonscan.com",start:9834491,imageIPFS:"QmaGokGqgjknfa4xnXKnnwC5ZyXzUjQ7p6KEe4D8G5uFFE"},246:{key:"246",name:"Energy Web Chain",shortName:"EWC",chainId:246,network:"mainnet",multicall:"0x0767F26d0D568aB61A98b279C0b28a4164A6f05e",rpc:["https://voting-rpc.carbonswap.exchange"],explorer:"https://explorer.energyweb.org",start:12086501,imageIPFS:"Qmai7AGHgs8NpeGeXgbMZz7pS2i4kw44qubCJYGrZW2f3a"},250:{key:"250",name:"Fantom Opera",shortName:"fantom",chainId:250,network:"Mainnet",multicall:"0x7f6A10218264a22B4309F3896745687E712962a0",rpc:["https://rpc.ftm.tools","https://rpcapi.fantom.network"],explorer:"https://ftmscan.com",start:2497732,imageIPFS:"QmVEgNeQDKnXygeGxfY9FywZpNGQu98ktZtRJ9bToYF6g7"},256:{key:"256",name:"Huobi Eco Chain Testnet",shortName:"heco",chainId:256,network:"testnet",testnet:!0,multicall:"0xC33994Eb943c61a8a59a918E2de65e03e4e385E0",rpc:["https://http-testnet.hecochain.com"],ws:["wss://ws-testnet.hecochain.com"],explorer:"https://testnet.hecoinfo.com",start:379560,imageIPFS:"QmSJEdToMvmjqoPvVq7awwdMeYKhXUYZMBiax9yHtFGMSq"},269:{key:"269",name:"High Performance Blockchain Mainnet",shortName:"HPB",chainId:269,network:"mainnet",testnet:!1,multicall:"0x67D0f263aef2F6167FA77353695D75b582Ff4Bca",rpc:["https://hpbnode.com"],ws:["wss://ws.hpbnode.com"],explorer:"https://hscan.org",start:13960096,imageIPFS:"QmU7f1MyRz8rLELFfypnWZQjGbDGYgZtC9rjw47jYMYrnu"},288:{key:"288",name:"Boba Mainnet",shortName:"Boba",chainId:288,network:"mainnet",multicall:"0xfb91c019D9F12A0f9c23B4762fa64A34F8daDb4A",rpc:["https://mainnet.boba.network/"],explorer:"https://blockexplorer.boba.network",start:74,imageIPFS:"QmNc7QZFpPDue3Ef4SsuX55RHkqXxUxSyTCpoASeg2hW6d"},321:{key:"321",name:"KCC Mainnet",shortName:"KCC",chainId:321,network:"mainnet",multicall:"0xa64D6AFb48225BDA3259246cfb418c0b91de6D7a",rpc:["https://rpc-mainnet.kcc.network"],ws:["wss://rpc-ws-mainnet.kcc.network"],explorer:"https://explorer.kcc.io",start:1487453,imageIPFS:"QmRdzYGhFRG8QLzMJahHrw3vETE2YZ9sywQbEkenSjKEvb"},336:{key:"336",name:"Shiden Network",shortName:"Shiden",chainId:336,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shiden.astar.network:8545","https://shiden.api.onfinality.io/public"],explorer:"https://blockscout.com/shiden",start:1170016,imageIPFS:"QmcqGQE4Sk73zXc3e91TUFFefKBVeaNgbxV141XkSNE4xj"},361:{key:"361",name:"Theta Mainnet",shortName:"Theta",chainId:361,network:"mainnet",multicall:"0xB48BbAD564Ceb6fB30cCea2Af248ccF6398aEab5",rpc:["https://eth-rpc-api.thetatoken.org/rpc"],explorer:"https://explorer.thetatoken.org",start:12559216,imageIPFS:"QmcMP9s9mUqfT2SCiP75sZgAVVev7H7RQAKiSx9xWEDKwe"},499:{key:"499",name:"Rupaya",shortName:"RUPX",chainId:499,network:"mainnet",multicall:"0x7955FF653FfDBf13056FeAe227f655CfF5C194D5",rpc:["https://rpc.rupx.io"],ws:["wss://ws.rupx.io"],explorer:"http://scan.rupx.io",start:2762929,imageIPFS:"QmXLZyAr6UNFQ4tkNwSyeNByFvzwYpwiNgV5vHuoxn74Rg"},592:{key:"592",name:"Astar Network",shortName:"Astar",chainId:592,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.astar.network:8545","https://astar.api.onfinality.io/public"],explorer:"https://blockscout.com/astar",start:366482,imageIPFS:"QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},888:{key:"888",name:"Wanchain",chainId:888,network:"mainnet",multicall:"0xba5934ab3056fca1fa458d30fbb3810c3eb5145f",rpc:["https://gwan-ssl.wandevs.org:56891"],ws:["wss://api.wanchain.org:8443/ws/v3/ddd16770c68f30350a21114802d5418eafe039b722de52b488e7eee1ee2cd73f"],explorer:"https://www.wanscan.org",start:11302663,imageIPFS:"QmewFFN44rkxESFsHG8edaLt1znr62hjvZhGynfXqruzX3"},940:{key:"940",name:"PulseChain Testnet",shortName:"pulsechain",chainId:940,network:"Testnet",multicall:"0x5e67901C2Dd1915E9Ef49aF39B62C28DF8C2c529",rpc:["https://rpc.testnet.pulsedisco.net"],ws:["wss://ws.rpc.testnet.pulsedisco.net"],explorer:"https://scan.v2.testnet.pulsechain.com",start:15123138,imageIPFS:"QmYqkn8pJUaV9KcEPYEvRPwgbfeozLEvcQ9aEwKNRUL3cR"},1088:{key:"1088",name:"Metis",shortName:"metis",chainId:1088,network:"mainnet",multicall:"0xc39aBB6c4451089dE48Cffb013c39d3110530e5C",rpc:["https://andromeda.metis.io/?owner=1088"],explorer:"https://andromeda-explorer.metis.io",start:451,imageIPFS:"QmYeskHqrEvWHqeAuqett64LxfH52HUXZi2T9BAMmgKvBF"},1284:{key:"1284",name:"Moonbeam",shortName:"GLMR",chainId:1284,network:"mainnet",multicall:"0x83e3b61886770de2F64AAcaD2724ED4f08F7f36B",rpc:["https://rpc.api.moonbeam.network"],explorer:"https://blockscout.moonbeam.network",start:171135,imageIPFS:"QmWKTEK2pj5sBBbHnMHQbWgw6euVdBrk2Ligpi2chrWASk"},1285:{key:"1285",name:"Moonriver (Kusama)",shortName:"Moonriver",chainId:1285,network:"mainnet",multicall:"0x537004440ffFE1D4AE9F009031Fc2b0385FCA9F1",rpc:["https://rpc.api.moonriver.moonbeam.network"],explorer:"https://blockscout.moonriver.moonbeam.network",start:413539,imageIPFS:"QmXtgPesL87Ejhq2Y7yxsaPYpf4RcnoTYPJWPcv6iiYhoi"},1287:{key:"1287",name:"Moonbase Alpha TestNet",shortName:"Moonbase",chainId:1287,network:"testnet",testnet:!0,multicall:"0xf09FD6B6FF3f41614b9d6be2166A0D07045A3A97",rpc:["https://rpc.testnet.moonbeam.network"],explorer:"https://moonbase-blockscout.testnet.moonbeam.network",start:859041,imageIPFS:"QmeGbNTU2Jqwg8qLTMGW8n8HSi2VdgCncAaeGzLx6gYnD7"},4689:{key:"4689",name:"IoTeX Mainnet",shortName:"IoTeX",chainId:4689,network:"mainnet",multicall:"0x9c8B105c94282CDB0F3ecF27e3cfA96A35c07be6",rpc:["https://babel-api.mainnet.iotex.io"],explorer:"https://iotexscan.io",start:11533283,imageIPFS:"QmNkr1UPcBYbvLp7d7Pk4eF3YCsHpaNkfusKZNtykL2EQC"},4690:{key:"4690",name:"IoTeX Testnet",shortName:"IoTeX",chainId:4690,network:"testnet",testnet:!0,multicall:"0x30aE8783d26aBE7Fbb9d83549CCb7430AE4A301F",rpc:["https://babel-api.testnet.iotex.io"],explorer:"https://testnet.iotexscan.io",start:8821493,imageIPFS:"QmNkr1UPcBYbvLp7d7Pk4eF3YCsHpaNkfusKZNtykL2EQC"},5551:{key:"5551",name:"Nahmii Mainnet",shortName:"Nahmii",chainId:5551,network:"mainnet",multicall:"0x05911151467b9F42eD14f10ddE0c057347Fff714",rpc:["https://l2.nahmii.io"],explorer:"https://explorer.nahmii.io",start:4364,imageIPFS:"QmPXPCBho3kGLt5rhG9JGkKmzdtLvqZmJqGzzijVCuggWY"},5553:{key:"5553",name:"Nahmii Testnet",shortName:"Nahmii",chainId:5553,network:"testnet",testnet:!0,multicall:"0x0e157d2E45af27564edFAaCcD68f2f0458F3D96c",rpc:["https://l2.testnet.nahmii.io"],explorer:"https://explorer.testnet.nahmii.io",start:53370,imageIPFS:"QmPXPCBho3kGLt5rhG9JGkKmzdtLvqZmJqGzzijVCuggWY"},7341:{key:"7341",name:"Shyft",shortName:"Shyft",chainId:7341,network:"mainnet",testnet:!1,multicall:"0xceb10e9133D771cA93c8002Be527A465E85381a2",rpc:["https://rpc.shyft.network"],explorer:"https://bx.shyft.network",start:3673983,imageIPFS:"QmUkFZC2ZmoYPTKf7AHdjwRPZoV2h1MCuHaGM4iu8SNFpi"},1e4:{key:"10000",name:"smartBCH",shortName:"BCH",chainId:1e4,network:"mainnet",multicall:"0x1b38EBAd553f218e2962Cb1C0539Abb5d6A37774",rpc:["https://smartbch.greyh.at/"],explorer:"https://www.smartscan.cash",imageIPFS:"QmWG1p7om4hZ4Yi4uQvDpxg4si7qVYhtppGbcDGrhVFvMd"},11437:{key:"11437",name:"Shyft Testnet",shortName:"Shyft_",chainId:11437,network:"testnet",testnet:!0,multicall:"0x407159bAA564dA0c3b14D1215d8E2654cEEE73F4",rpc:["https://rpc.testnet.shyft.network"],explorer:"https://bx.testnet.shyft.network",start:2446296,imageIPFS:"QmUkFZC2ZmoYPTKf7AHdjwRPZoV2h1MCuHaGM4iu8SNFpi"},12357:{key:"12357",name:"REI Testnet",shortName:"REI",chainId:12357,network:"testnet",testnet:!0,multicall:"0x9eE9904815B80C39C1a27294E69a8626EAa7952d",rpc:["https://rpc-testnet.rei.network"],explorer:"https://scan-test.rei.network/",start:79516,imageIPFS:"QmTogMDLmDgJjDjUKDHDuc2KVTVDbXf8bXJLFiVe8PRxgo"},32659:{key:"32659",name:"Fusion Mainnet",chainId:32659,network:"mainnet",multicall:"",rpc:["https://vote.anyswap.exchange/mainnet"],ws:["wss://mainnetpublicgateway1.fusionnetwork.io:10001"],explorer:"https://fsnex.com",imageIPFS:"QmRb6YCGdpQTQcdNTnBb5DUixGpjDp1wz6zoADJwQ7hyFq"},42161:{key:"42161",name:"Arbitrum One",chainId:42161,network:"Arbitrum mainnet",multicall:"0x7A7443F8c577d537f1d8cD4a629d40a3148Dd7ee",rpc:["https://arb-mainnet.g.alchemy.com/v2/JDvtNGwnHhTltIwfnxQocKwKkCTKA1DL"],explorer:"https://arbiscan.io",start:256508,imageIPFS:"QmWZ5SMRfvcK8tycsDqojQaSiKedgtVkS7CkZdxPgeCVsZ"},42220:{key:"42220",name:"Celo Mainnet",shortName:"Celo",chainId:42220,network:"mainnet",multicall:"0xb8d0d2C1391eeB350d2Cd39EfABBaaEC297368D9",rpc:["https://celo.snapshot.org","https://forno.celo.org","https://celo-mainnet--rpc.datahub.figment.io/apikey/e892a66dc36e4d2d98a5d6406d609796/"],explorer:"https://explorer.celo.org",start:6599803,imageIPFS:"QmS2tVJ7rdJRe1NHXAi2L86yCbUwVVrmB2mHQeNdJxvQti"},42262:{key:"42262",name:"Emerald",shortName:"Emerald",chainId:42262,network:"mainnet",multicall:"0xBD46A7DCD1fefA63A7746a5762A71635Ee0843A1",rpc:["https://emerald.oasis.dev"],explorer:"https://explorer.emerald.oasis.dev",start:176517,imageIPFS:"QmQrZjZZyAcQmPXJM2cUh1KaaDeM8Sfcg3HnvZpBj8wTnG"},43114:{key:"43114",name:"Avalanche",chainId:43114,network:"mainnet",multicall:"0x7E9985aE4C8248fdB07607648406a48C76e9e7eD",rpc:["https://nd-784-543-849.p2pify.com/aa7b29fc5fed65b34f0ee6b8de33f8c0/ext/bc/C/rpc","https://rpc.ankr.com/avalanche","https://api.avax.network/ext/bc/C/rpc"],explorer:"https://snowtrace.io",start:536483,imageIPFS:"QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},47805:{key:"47805",name:"REI Mainnet",chainId:47805,network:"mainnet",multicall:"0x9eE9904815B80C39C1a27294E69a8626EAa7952d",rpc:["https://rpc.rei.network"],explorer:"https://scan.rei.network/",start:1715902,imageIPFS:"QmTogMDLmDgJjDjUKDHDuc2KVTVDbXf8bXJLFiVe8PRxgo"},80001:{key:"80001",name:"Matic Mumbai",chainId:80001,network:"testnet",testnet:!0,multicall:"0x08411ADd0b5AA8ee47563b146743C13b3556c9Cc",rpc:["https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/polygon/mumbai/archive","https://rpc-mumbai.matic.today"],ws:["wss://ws-mumbai.matic.today"],explorer:"https://mumbai.polygonscan.com",start:12011090,imageIPFS:"QmaGokGqgjknfa4xnXKnnwC5ZyXzUjQ7p6KEe4D8G5uFFE"},333888:{key:"333888",name:"Polis Sparta",shortName:"Sparta",chainId:333888,network:"testnet",testnet:!0,multicall:"0xA4c03972023d5f684d35eF1C541752490975383e",rpc:["https://sparta-rpc.polis.tech"],explorer:"https://sparta-explorer.polis.tech",imageIPFS:"QmSiCni2Jn58WN74SyGNY1Aw5mSh9ypEfFULhjKxA7Tbpg"},333999:{key:"333999",name:"Polis Olympus",shortName:"Olympus",chainId:333999,network:"mainnet",multicall:"0x34b99C2a4a4620F10ac779c36b8c61F90FD61732",rpc:["https://rpc.polis.tech"],explorer:"https://explorer.polis.tech",start:1971,imageIPFS:"QmSiCni2Jn58WN74SyGNY1Aw5mSh9ypEfFULhjKxA7Tbpg"},1313161554:{key:"1313161554",name:"Aurora Mainnet",shortName:"Aurora",chainId:1313161554,network:"mainnet",multicall:"0x32b50c286DEFd2932a0247b8bb940b78c063F16c",rpc:["https://mainnet.aurora.dev"],explorer:"https://explorer.mainnet.aurora.dev",start:57190533,imageIPFS:"QmeRhsR1UPRTQCizdhmgr2XxphXebVKU5di97uCV2UMFpa"},16666e5:{key:"1666600000",name:"Harmony Mainnet",shortName:"HarmonyMainnet",chainId:16666e5,network:"mainnet",multicall:"0x9c31392D2e0229dC4Aa250F043d46B9E82074BF8",rpc:["https://a.api.s0.t.hmny.io"],ws:["wss://ws.s0.t.hmny.io"],explorer:"https://explorer.harmony.one",start:10911984,imageIPFS:"QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"},16667e5:{key:"1666700000",name:"Harmony Testnet",shortName:"HarmonyTestnet",chainId:16667e5,network:"testnet",testnet:!0,multicall:"0x9923589503Fd205feE3d367DDFF2378f0F7dD2d4",rpc:["https://api.s0.b.hmny.io"],ws:["wss://ws.s0.b.hmny.io"],explorer:"https://explorer.pops.one",start:7521509,imageIPFS:"QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"},11297108109:{key:"11297108109",name:"Palm Mainnet",shortName:"Palm",chainId:11297108109,network:"mainnet",multicall:"0xfFE2FF36c5b8D948f788a34f867784828aa7415D",rpc:["https://palm-mainnet.infura.io/v3/3a961d6501e54add9a41aa53f15de99b"],explorer:"https://explorer.palm.io",start:1172267,imageIPFS:"QmaYQfjLfQpyRWZZZU1BE8X352rXEjNaNeahjvf1aHZrKY"}},jy={};function zy(e){var r=By[e].rpc[0],n="object"==typeof r?t(t({},r),{timeout:25e3}):{url:r,timeout:25e3};return jy[e]||(jy[e]=new $y(n)),jy[e]}var Gy={basic:function(t,n,i,o){var s,a;return e(this,void 0,void 0,(function(){var e,i,h,u;return r(this,(function(r){switch(r.label){case 0:return e=o.strategies||n.strategies,i=o.onlyMembers||(null===(s=n.filters)||void 0===s?void 0:s.onlyMembers),h=o.minScore||(null===(a=n.filters)||void 0===a?void 0:a.minScore),(n.members||[]).map((function(t){return t.toLowerCase()})).includes(t.toLowerCase())?[2,!0]:i?[2,!1]:h?[4,Tb(n.id||n.key,e,n.network,[t])]:[3,2];case 1:if(u=r.sent(),u.map((function(t){return Object.values(t).reduce((function(t,e){return t+e}),0)})).reduce((function(t,e){return t+e}),0)<h)return[2,!1];r.label=2;case 2:return[2,!0]}}))}))},aave:function(t,n,o,s){var a,h;return e(this,void 0,void 0,(function(){var e,o,u,l,f,c;return r(this,(function(r){switch(r.label){case 0:return e=s.onlyMembers||(null===(a=n.filters)||void 0===a?void 0:a.onlyMembers),o=s.minScore||(null===(h=n.filters)||void 0===h?void 0:h.minScore),u=(n.members||[]).map((function(t){return t.toLowerCase()})),l=i(n.strategies),(f=l.findIndex((function(t){return"aave-governance-power"===t.name})))>=0&&(l[f].params.powerType="proposition"),u.includes(t.toLowerCase())?[2,!0]:e?[2,!1]:o?[4,Tb(n.id||n.key,l,n.network,[t])]:[3,2];case 1:if(c=r.sent(),c.map((function(t){return Object.values(t).reduce((function(t,e){return t+e}),0)})).reduce((function(t,e){return t+e}),0)<o)return[2,!1];r.label=2;case 2:return[2,!0]}}))}))},nouns:function(t,n,o,s){var a,h;return e(this,void 0,void 0,(function(){var e,o,u,l,f,c;return r(this,(function(r){switch(r.label){case 0:return e=s.onlyMembers||(null===(a=n.filters)||void 0===a?void 0:a.onlyMembers),o=s.minScore||(null===(h=n.filters)||void 0===h?void 0:h.minScore),u=(n.members||[]).map((function(t){return t.toLowerCase()})),l=i(n.strategies),(f=l.findIndex((function(t){return"nouns-rfp-power"===t.name})))>=0&&(l[f].params.powerType="proposition"),u.includes(t.toLowerCase())?[2,!0]:e?[2,!1]:o?[4,Tb(n.id||n.key,l,n.network,[t])]:[3,2];case 1:if(c=r.sent(),c.map((function(t){return Object.values(t).reduce((function(t,e){return t+e}),0)})).reduce((function(t,e){return t+e}),0)<o)return[2,!1];r.label=2;case 2:return[2,!0]}}))}))}};let qy=!1,Vy=!1;const Ky={debug:1,default:2,info:2,warning:3,error:4,off:5};let Wy=Ky.default,Hy=null;const Zy=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),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 Xy,Jy;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(Xy||(Xy={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(Jy||(Jy={}));class Yy{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==Ky[r]&&this.throwArgumentError("invalid log level name","logLevel",t),Wy>Ky[r]||console.log.apply(console,e)}debug(...t){this._log(Yy.levels.DEBUG,t)}info(...t){this._log(Yy.levels.INFO,t)}warn(...t){this._log(Yy.levels.WARNING,t)}makeError(t,e,r){if(Vy)return this.makeError("censored error",e,{});e||(e=Yy.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;n.length&&(t+=" ("+n.join(", ")+")");const o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Yy.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){Zy&&this.throwError("platform missing String.prototype.normalize",Yy.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Zy})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Yy.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Yy.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,Yy.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Yy.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",Yy.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Yy.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",Yy.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Hy||(Hy=new Yy("logger/5.4.0")),Hy}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Yy.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),qy){if(!t)return;this.globalLogger().throwError("error censorship permanent",Yy.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Vy=!!t,qy=!!e}static setLogLevel(t){const e=Ky[t.toLowerCase()];null!=e?Wy=e:Yy.globalLogger().warn("invalid log level - "+t)}static from(t){return new Yy(t)}}Yy.errors=Jy,Yy.levels=Xy;const Qy=new Yy("bytes/5.4.0");function tv(t){return!!t.toHexString}function ev(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return ev(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function rv(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}function nv(t,e){if(e||(e={}),"number"==typeof t){Qy.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),ev(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),tv(t)&&(t=t.toHexString()),iv(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":Qy.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return ev(new Uint8Array(n))}return rv(t)?ev(new Uint8Array(t)):Qy.throwArgumentError("invalid arrayify value","value",t)}function iv(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}function ov(t,e){if(e||(e={}),"number"==typeof t){Qy.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),tv(t))return t.toHexString();if(iv(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":Qy.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(rv(t)){let e="0x";for(let r=0;r<t.length;r++){let n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return Qy.throwArgumentError("invalid hexlify value","value",t)}function sv(t){let e="0x";return t.forEach(t=>{e+=ov(t).substring(2)}),e}function av(t,e){for("string"!=typeof t?t=ov(t):iv(t)||Qy.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&Qy.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}var hv=h((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Xt.Buffer}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function h(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s<o;s++){var a=t.charCodeAt(s)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.prototype._initNumber=function(t,e,n){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):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("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 i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,u=0,l=r;l<a;l+=n)u=h(t,l,l+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var f=1;for(u=h(t,l,t.length,e),l=0;l<s;l++)f*=e;this.imuln(f),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this.strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","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"],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,h=s/67108864|0;r.words[0]=a;for(var u=1;u<n;u++){for(var l=h>>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var m=u-d|0;l+=(s=(i=0|t.words[m])*(o=0|e.words[d])+f)/67108864|0,f=67108863&s}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],h=(16777215&(a<<i|o)).toString(16);n=0!==(o=a>>>24-i&16777215)||s!==this.length-1?u[6-h.length]+h+n:h+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];n="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modn(d).toString(t);n=(m=m.idivn(d)).isZero()?p+n:u[c-p.length]+p+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.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&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(t,e){return r(void 0!==o),this.toArrayLike(o,t,e)},i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var s,a,h="le"===e,u=new t(o),l=this.clone();if(h){for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[a]=s;for(;a<o;a++)u[a]=0}else{for(a=0;a<o-i;a++)u[a]=0;for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[o-a-1]=s}return u},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this.strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,e,r){var n,i,o,s=t.words,a=e.words,h=r.words,u=0,l=0|s[0],f=8191&l,c=l>>>13,d=0|s[1],m=8191&d,p=d>>>13,g=0|s[2],y=8191&g,v=g>>>13,w=0|s[3],b=8191&w,E=w>>>13,M=0|s[4],_=8191&M,A=M>>>13,N=0|s[5],S=8191&N,R=N>>>13,U=0|s[6],I=8191&U,P=U>>>13,x=0|s[7],k=8191&x,T=x>>>13,O=0|s[8],C=8191&O,F=O>>>13,D=0|s[9],L=8191&D,$=D>>>13,B=0|a[0],j=8191&B,z=B>>>13,G=0|a[1],q=8191&G,V=G>>>13,K=0|a[2],W=8191&K,H=K>>>13,Z=0|a[3],X=8191&Z,J=Z>>>13,Y=0|a[4],Q=8191&Y,tt=Y>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ft=8191<,ct=lt>>>13,dt=0|a[9],mt=8191&dt,pt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,z))+Math.imul(c,j)|0))<<13)|0;u=((o=Math.imul(c,z))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(m,j),i=(i=Math.imul(m,z))+Math.imul(p,j)|0,o=Math.imul(p,z);var yt=(u+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,V)|0)+Math.imul(c,q)|0))<<13)|0;u=((o=o+Math.imul(c,V)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,j),i=(i=Math.imul(y,z))+Math.imul(v,j)|0,o=Math.imul(v,z),n=n+Math.imul(m,q)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(p,q)|0,o=o+Math.imul(p,V)|0;var vt=(u+(n=n+Math.imul(f,W)|0)|0)+((8191&(i=(i=i+Math.imul(f,H)|0)+Math.imul(c,W)|0))<<13)|0;u=((o=o+Math.imul(c,H)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(b,j),i=(i=Math.imul(b,z))+Math.imul(E,j)|0,o=Math.imul(E,z),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,V)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,H)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,H)|0;var wt=(u+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,X)|0))<<13)|0;u=((o=o+Math.imul(c,J)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(_,j),i=(i=Math.imul(_,z))+Math.imul(A,j)|0,o=Math.imul(A,z),n=n+Math.imul(b,q)|0,i=(i=i+Math.imul(b,V)|0)+Math.imul(E,q)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(y,W)|0,i=(i=i+Math.imul(y,H)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,H)|0,n=n+Math.imul(m,X)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,J)|0;var bt=(u+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(S,j),i=(i=Math.imul(S,z))+Math.imul(R,j)|0,o=Math.imul(R,z),n=n+Math.imul(_,q)|0,i=(i=i+Math.imul(_,V)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,V)|0,n=n+Math.imul(b,W)|0,i=(i=i+Math.imul(b,H)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,H)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(p,Q)|0,o=o+Math.imul(p,tt)|0;var Et=(u+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;u=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(I,j),i=(i=Math.imul(I,z))+Math.imul(P,j)|0,o=Math.imul(P,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(_,W)|0,i=(i=i+Math.imul(_,H)|0)+Math.imul(A,W)|0,o=o+Math.imul(A,H)|0,n=n+Math.imul(b,X)|0,i=(i=i+Math.imul(b,J)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,J)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,nt)|0;var Mt=(u+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(c,ot)|0))<<13)|0;u=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,z))+Math.imul(T,j)|0,o=Math.imul(T,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,V)|0)+Math.imul(P,q)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,H)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,H)|0,n=n+Math.imul(_,X)|0,i=(i=i+Math.imul(_,J)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,st)|0;var _t=(u+(n=n+Math.imul(f,ht)|0)|0)+((8191&(i=(i=i+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((o=o+Math.imul(c,ut)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(C,j),i=(i=Math.imul(C,z))+Math.imul(F,j)|0,o=Math.imul(F,z),n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(T,q)|0,o=o+Math.imul(T,V)|0,n=n+Math.imul(I,W)|0,i=(i=i+Math.imul(I,H)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,H)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(_,Q)|0,i=(i=i+Math.imul(_,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var At=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,z))+Math.imul($,j)|0,o=Math.imul($,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,V)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,V)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,H)|0)+Math.imul(T,W)|0,o=o+Math.imul(T,H)|0,n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(_,rt)|0,i=(i=i+Math.imul(_,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(b,ot)|0,i=(i=i+Math.imul(b,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(m,ft)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(p,ft)|0,o=o+Math.imul(p,ct)|0;var Nt=(u+(n=n+Math.imul(f,mt)|0)|0)+((8191&(i=(i=i+Math.imul(f,pt)|0)+Math.imul(c,mt)|0))<<13)|0;u=((o=o+Math.imul(c,pt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(L,q),i=(i=Math.imul(L,V))+Math.imul($,q)|0,o=Math.imul($,V),n=n+Math.imul(C,W)|0,i=(i=i+Math.imul(C,H)|0)+Math.imul(F,W)|0,o=o+Math.imul(F,H)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(_,ot)|0,i=(i=i+Math.imul(_,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,n=n+Math.imul(b,ht)|0,i=(i=i+Math.imul(b,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,o=o+Math.imul(v,ct)|0;var St=(u+(n=n+Math.imul(m,mt)|0)|0)+((8191&(i=(i=i+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,W),i=(i=Math.imul(L,H))+Math.imul($,W)|0,o=Math.imul($,H),n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(_,ht)|0,i=(i=i+Math.imul(_,ut)|0)+Math.imul(A,ht)|0,o=o+Math.imul(A,ut)|0,n=n+Math.imul(b,ft)|0,i=(i=i+Math.imul(b,ct)|0)+Math.imul(E,ft)|0,o=o+Math.imul(E,ct)|0;var Rt=(u+(n=n+Math.imul(y,mt)|0)|0)+((8191&(i=(i=i+Math.imul(y,pt)|0)+Math.imul(v,mt)|0))<<13)|0;u=((o=o+Math.imul(v,pt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,J))+Math.imul($,X)|0,o=Math.imul($,J),n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(F,Q)|0,o=o+Math.imul(F,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,ut)|0,n=n+Math.imul(_,ft)|0,i=(i=i+Math.imul(_,ct)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,ct)|0;var Ut=(u+(n=n+Math.imul(b,mt)|0)|0)+((8191&(i=(i=i+Math.imul(b,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(i>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,n=Math.imul(L,Q),i=(i=Math.imul(L,tt))+Math.imul($,Q)|0,o=Math.imul($,tt),n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(F,rt)|0,o=o+Math.imul(F,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(S,ft)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(R,ft)|0,o=o+Math.imul(R,ct)|0;var It=(u+(n=n+Math.imul(_,mt)|0)|0)+((8191&(i=(i=i+Math.imul(_,pt)|0)+Math.imul(A,mt)|0))<<13)|0;u=((o=o+Math.imul(A,pt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul($,rt)|0,o=Math.imul($,nt),n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,st)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,ut)|0)+Math.imul(T,ht)|0,o=o+Math.imul(T,ut)|0,n=n+Math.imul(I,ft)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(P,ft)|0,o=o+Math.imul(P,ct)|0;var Pt=(u+(n=n+Math.imul(S,mt)|0)|0)+((8191&(i=(i=i+Math.imul(S,pt)|0)+Math.imul(R,mt)|0))<<13)|0;u=((o=o+Math.imul(R,pt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,ot),i=(i=Math.imul(L,st))+Math.imul($,ot)|0,o=Math.imul($,st),n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,ut)|0)+Math.imul(F,ht)|0,o=o+Math.imul(F,ut)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,ct)|0;var xt=(u+(n=n+Math.imul(I,mt)|0)|0)+((8191&(i=(i=i+Math.imul(I,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),n=n+Math.imul(C,ft)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(F,ft)|0,o=o+Math.imul(F,ct)|0;var kt=(u+(n=n+Math.imul(k,mt)|0)|0)+((8191&(i=(i=i+Math.imul(k,pt)|0)+Math.imul(T,mt)|0))<<13)|0;u=((o=o+Math.imul(T,pt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,ft),i=(i=Math.imul(L,ct))+Math.imul($,ft)|0,o=Math.imul($,ct);var Tt=(u+(n=n+Math.imul(C,mt)|0)|0)+((8191&(i=(i=i+Math.imul(C,pt)|0)+Math.imul(F,mt)|0))<<13)|0;u=((o=o+Math.imul(F,pt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863;var Ot=(u+(n=Math.imul(L,mt))|0)+((8191&(i=(i=Math.imul(L,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=wt,h[4]=bt,h[5]=Et,h[6]=Mt,h[7]=_t,h[8]=At,h[9]=Nt,h[10]=St,h[11]=Rt,h[12]=Ut,h[13]=It,h[14]=Pt,h[15]=xt,h[16]=kt,h[17]=Tt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new p).mulp(t,e,r)}function p(t,e){this.x=t,this.y=e}Math.imul||(d=c),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,f=(0|t.words[l])*(0|e.words[u]),c=67108863&f;a=67108863&(c=c+a|0),i+=(s=(s=s+(f/67108864|0)|0)+(c>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):m(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),r=i.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e},p.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n},p.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s<o;s++)n[s]=e[t[s]],i[s]=r[t[s]]},p.prototype.transform=function(t,e,r,n,i,o){this.permute(o,t,e,r,n,i);for(var s=1;s<i;s<<=1)for(var a=s<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),l=0;l<i;l+=a)for(var f=h,c=u,d=0;d<s;d++){var m=r[l+d],p=n[l+d],g=r[l+d+s],y=n[l+d+s],v=f*g-c*y;y=f*y+c*g,g=v,r[l+d]=m+g,n[l+d]=p+y,r[l+d+s]=m-g,n[l+d+s]=p-y,d!==a&&(v=h*f-u*c,c=h*c+u*f,f=v)}},p.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},p.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},p.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0}return t},p.prototype.convert13b=function(t,e,n,i){for(var o=0,s=0;s<e;s++)o+=0|t[s],n[2*s]=8191&o,o>>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<i;++s)n[s]=0;r(0===o),r(0==(-8192&o))},p.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},p.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),o=this.stub(n),s=new Array(n),a=new Array(n),h=new Array(n),u=new Array(n),l=new Array(n),f=new Array(n),c=r.words;c.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(e.words,e.length,u,n),this.transform(s,o,a,h,n,i),this.transform(u,o,l,f,n,i);for(var d=0;d<n;d++){var m=a[d]*l[d]-h[d]*f[d];h[d]=a[d]*f[d]+h[d]*l[d],a[d]=m}return this.conjugate(a,h,n),this.transform(a,h,c,o,n,i),this.conjugate(c,o,n),this.normalize13b(c,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),m(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){r("number"==typeof t),r(t<67108864);for(var e=0,n=0;n<this.length;n++){var i=(0|this.words[n])*t,o=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=o>>>26,this.words[n]=67108863&o}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(t.words[n]&1<<i)>>>i}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,h=(0|this.words[e])-a<<n;this.words[e]=h|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this.strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,h=n;if(i-=s,i=Math.max(0,i),h){for(var u=0;u<s;u++)h.words[u]=this.words[u];h.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=i);u--){var f=0|this.words[u];this.words[u]=l<<26-o|f>>>o,l=f&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n)&&!!(this.words[n]&i)},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this.strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(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)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(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 e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var h=(0|t.words[i])*e;a=((o-=67108863&h)>>26)-(h/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!==(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,h=n.length-o.length;if("mod"!==e){(a=new i(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var l=n.clone()._ishlnsubmul(o,1,h);0===l.negative&&(n=l,a&&(a.words[h]=1));for(var f=h-1;f>=0;f--){var c=67108864*(0|n.words[o.length+f])+(0|n.words[o.length+f-1]);for(c=Math.min(c/s|0,67108863),n._ishlnsubmul(o,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(o,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},i.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),h=new i(1),u=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(f)),o.iushrn(1),s.iushrn(1);for(var m=0,p=1;0==(n.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(n.iushrn(m);m-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(f)),a.iushrn(1),h.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(h)):(n.isub(e),a.isub(o),h.isub(s))}return{a:a,b:h,gcd:n.iushln(u)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),h=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new M(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(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 i(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n<r;n++)e.words[n]=t.words[n];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=4194303&i,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(4194303&o)<<4|i>>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,y),n(b,y),n(E,y),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new w;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},M.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},M.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},M.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,o),c=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),m=s;0!==d.cmp(a);){for(var p=d,g=0;0!==p.cmp(a);g++)p=p.redSqr();r(g<m);var y=this.pow(f,new i(1).iushln(m-g-1));c=c.redMul(y),f=y.redSqr(),d=d.redMul(f),m=g}return c},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],l=h-1;l>=0;l--){var f=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===l)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}h=26}return o},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new _(t)},n(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,o)})).BN;const uv=new Yy("bignumber/5.4.0"),lv={};let fv=!1;class cv{constructor(t,e){uv.checkNew(new.target,cv),t!==lv&&uv.throwError("cannot call constructor directly; use BigNumber.from",Yy.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return mv(pv(this).fromTwos(t))}toTwos(t){return mv(pv(this).toTwos(t))}abs(){return"-"===this._hex[0]?cv.from(this._hex.substring(1)):this}add(t){return mv(pv(this).add(pv(t)))}sub(t){return mv(pv(this).sub(pv(t)))}div(t){return cv.from(t).isZero()&&gv("division by zero","div"),mv(pv(this).div(pv(t)))}mul(t){return mv(pv(this).mul(pv(t)))}mod(t){const e=pv(t);return e.isNeg()&&gv("cannot modulo negative values","mod"),mv(pv(this).umod(e))}pow(t){const e=pv(t);return e.isNeg()&&gv("cannot raise to negative values","pow"),mv(pv(this).pow(e))}and(t){const e=pv(t);return(this.isNegative()||e.isNeg())&&gv("cannot 'and' negative values","and"),mv(pv(this).and(e))}or(t){const e=pv(t);return(this.isNegative()||e.isNeg())&&gv("cannot 'or' negative values","or"),mv(pv(this).or(e))}xor(t){const e=pv(t);return(this.isNegative()||e.isNeg())&&gv("cannot 'xor' negative values","xor"),mv(pv(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&gv("cannot mask negative values","mask"),mv(pv(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&gv("cannot shift negative values","shl"),mv(pv(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&gv("cannot shift negative values","shr"),mv(pv(this).shrn(t))}eq(t){return pv(this).eq(pv(t))}lt(t){return pv(this).lt(pv(t))}lte(t){return pv(this).lte(pv(t))}gt(t){return pv(this).gt(pv(t))}gte(t){return pv(this).gte(pv(t))}isNegative(){return"-"===this._hex[0]}isZero(){return pv(this).isZero()}toNumber(){try{return pv(this).toNumber()}catch(t){gv("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return uv.throwError("this platform does not support BigInt",Yy.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?fv||(fv=!0,uv.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?uv.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Yy.errors.UNEXPECTED_ARGUMENT,{}):uv.throwError("BigNumber.toString does not accept parameters",Yy.errors.UNEXPECTED_ARGUMENT,{})),pv(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof cv)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new cv(lv,dv(t)):t.match(/^-?[0-9]+$/)?new cv(lv,dv(new hv(t))):uv.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&gv("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&gv("overflow","BigNumber.from",t),cv.from(String(t));const e=t;if("bigint"==typeof e)return cv.from(e.toString());if(rv(e))return cv.from(ov(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return cv.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(iv(t)||"-"===t[0]&&iv(t.substring(1))))return cv.from(t)}return uv.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function dv(t){if("string"!=typeof t)return dv(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&uv.throwArgumentError("invalid hex","value",t),"0x00"===(t=dv(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 mv(t){return cv.from(dv(t))}function pv(t){const e=cv.from(t).toHexString();return"-"===e[0]?new hv("-"+e.substring(3),16):new hv(e.substring(2),16)}function gv(t,e,r){const n={fault:t,operation:e};return null!=r&&(n.value=r),uv.throwError(t,Yy.errors.NUMERIC_FAULT,n)}const yv=new Yy("bytes/5.4.0");function vv(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return vv(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function wv(t,e){if(e||(e={}),"number"==typeof t){yv.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),vv(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){if("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))return!1;if(e&&t.length!==2+2*e)return!1;return!0}(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":yv.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return vv(new Uint8Array(n))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}(t)?vv(new Uint8Array(t)):yv.throwArgumentError("invalid arrayify value","value",t)}function bv(t){return"0x"+nn.keccak_256(wv(t))}const Ev=new Yy("address/5.4.0");function Mv(t){iv(t,20)||Ev.throwArgumentError("invalid address","address",t);const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const n=nv(bv(r));for(let t=0;t<40;t+=2)n[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&n[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const _v={};for(let t=0;t<10;t++)_v[String(t)]=String(t);for(let t=0;t<26;t++)_v[String.fromCharCode(65+t)]=String(10+t);const Av=Math.floor(function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}(9007199254740991));function Nv(t){let e=null;if("string"!=typeof t&&Ev.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Mv(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Ev.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map(t=>_v[t]).join("");for(;e.length>=Av;){let t=e.substring(0,Av);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t)&&Ev.throwArgumentError("bad icap checksum","address",t),r=t.substring(4),e=new hv(r,36).toString(16);e.length<40;)e="0"+e;e=Mv("0x"+e)}else Ev.throwArgumentError("invalid address","address",t);var r;return e}window&&window.__awaiter;const Sv=new Yy("properties/5.4.0");function Rv(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function Uv(t){const e={};for(const r in t)e[r]=t[r];return e}const Iv={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function Pv(t){if(function t(e){if(null==e||Iv[typeof e])return!0;if(Array.isArray(e)||"object"==typeof e){if(!Object.isFrozen(e))return!1;const r=Object.keys(e);for(let n=0;n<r.length;n++)if(!t(e[r[n]]))return!1;return!0}return Sv.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}(t))return t;if(Array.isArray(t))return Object.freeze(t.map(t=>xv(t)));if("object"==typeof t){const e={};for(const r in t){const n=t[r];void 0!==n&&Rv(e,r,xv(n))}return e}return Sv.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function xv(t){return Pv(t)}const kv=new Yy("bytes/5.4.0");function Tv(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Tv(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Ov(t,e){if(e||(e={}),"number"==typeof t){kv.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),Tv(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){if("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))return!1;if(e&&t.length!==2+2*e)return!1;return!0}(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":kv.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return Tv(new Uint8Array(n))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}(t)?Tv(new Uint8Array(t)):kv.throwArgumentError("invalid arrayify value","value",t)}const Cv=new Yy("strings/5.4.0");var Fv,Dv;function Lv(t,e,r,n,i){if(t===Dv.BAD_PREFIX||t===Dv.UNEXPECTED_CONTINUE){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return t===Dv.OVERRUN?r.length-e-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(Fv||(Fv={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(Dv||(Dv={}));Object.freeze({error:function(t,e,r,n,i){return Cv.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:Lv,replace:function(t,e,r,n,i){return t===Dv.OVERLONG?(n.push(i),0):(n.push(65533),Lv(t,e,r))}});function $v(t){return bv(function(t,e=Fv.current){e!=Fv.current&&(Cv.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;const i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");const o=65536+((1023&n)<<10)+(1023&i);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return Ov(r)}(t))}var Bv=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const jv=new Yy("hash/5.4.0"),zv=new Uint8Array(32);zv.fill(0);const Gv=cv.from(-1),qv=cv.from(0),Vv=cv.from(1),Kv=cv.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const Wv=av(Vv.toHexString(),32),Hv=av(qv.toHexString(),32),Zv={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Xv=["name","version","chainId","verifyingContract","salt"];function Jv(t){return function(e){return"string"!=typeof e&&jv.throwArgumentError("invalid domain value for "+JSON.stringify(t),"domain."+t,e),e}}const Yv={name:Jv("name"),version:Jv("version"),chainId:function(t){try{return cv.from(t).toString()}catch(t){}return jv.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return Nv(t).toLowerCase()}catch(t){}return jv.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=nv(t);if(32!==e.length)throw new Error("bad length");return ov(e)}catch(t){}return jv.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function Qv(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=""===e[1],n=parseInt(e[2]||"256");(n%8!=0||n>256||e[2]&&e[2]!==String(n))&&jv.throwArgumentError("invalid numeric width","type",t);const i=Kv.mask(r?n-1:n),o=r?i.add(Vv).mul(Gv):qv;return function(e){const r=cv.from(e);return(r.lt(o)||r.gt(i))&&jv.throwArgumentError("value out-of-bounds for "+t,"value",e),av(r.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(0===r||r>32||e[1]!==String(r))&&jv.throwArgumentError("invalid bytes width","type",t),function(e){return nv(e).length!==r&&jv.throwArgumentError("invalid length for "+t,"value",e),function(t){const e=nv(t),r=e.length%32;return r?sv([e,zv.slice(r)]):ov(e)}(e)}}}switch(t){case"address":return function(t){return av(Nv(t),32)};case"bool":return function(t){return t?Wv:Hv};case"bytes":return function(t){return bv(t)};case"string":return function(t){return $v(t)}}return null}function tw(t,e){return`${t}(${e.map(({name:t,type:e})=>e+" "+t).join(",")})`}class ew{constructor(t){Rv(this,"types",Object.freeze(xv(t))),Rv(this,"_encoderCache",{}),Rv(this,"_types",{});const e={},r={},n={};Object.keys(t).forEach(t=>{e[t]={},r[t]=[],n[t]={}});for(const n in t){const i={};t[n].forEach(o=>{i[o.name]&&jv.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(n)}`,"types",t),i[o.name]=!0;const s=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&jv.throwArgumentError("circular type reference to "+JSON.stringify(s),"types",t);Qv(s)||(r[s]||jv.throwArgumentError("unknown type "+JSON.stringify(s),"types",t),r[s].push(n),e[n][s]=!0)})}const i=Object.keys(r).filter(t=>0===r[t].length);0===i.length?jv.throwArgumentError("missing primary type","types",t):i.length>1&&jv.throwArgumentError("ambiguous primary types or unused types: "+i.map(t=>JSON.stringify(t)).join(", "),"types",t),Rv(this,"primaryType",i[0]),function i(o,s){s[o]&&jv.throwArgumentError("circular type reference to "+JSON.stringify(o),"types",t),s[o]=!0,Object.keys(e[o]).forEach(t=>{r[t]&&(i(t,s),Object.keys(s).forEach(e=>{n[e][t]=!0}))}),delete s[o]}(this.primaryType,{});for(const e in n){const r=Object.keys(n[e]);r.sort(),this._types[e]=tw(e,t[e])+r.map(e=>tw(e,t[e])).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=Qv(t);if(e)return e}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const t=e[1],r=this.getEncoder(t),n=parseInt(e[3]);return e=>{n>=0&&e.length!==n&&jv.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);let i=e.map(r);return this._types[t]&&(i=i.map(bv)),bv(sv(i))}}const r=this.types[t];if(r){const e=$v(this._types[t]);return t=>{const n=r.map(({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return this._types[r]?bv(n):n});return n.unshift(e),sv(n)}}return jv.throwArgumentError("unknown type: "+t,"type",t)}encodeType(t){const e=this._types[t];return e||jv.throwArgumentError("unknown type: "+JSON.stringify(t),"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return bv(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(Qv(t))return r(t,e);const n=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const t=n[1],i=parseInt(n[3]);return i>=0&&e.length!==i&&jv.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map(e=>this._visit(t,e,r))}const i=this.types[t];return i?i.reduce((t,{name:n,type:i})=>(t[n]=this._visit(i,e[n],r),t),{}):jv.throwArgumentError("unknown type: "+t,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new ew(t)}static getPrimaryType(t){return ew.from(t).primaryType}static hashStruct(t,e,r){return ew.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const n=Zv[r];n||jv.throwArgumentError("invalid typed-data domain key: "+JSON.stringify(r),"domain",t),e.push({name:r,type:n})}return e.sort((t,e)=>Xv.indexOf(t.name)-Xv.indexOf(e.name)),ew.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return sv(["0x1901",ew.hashDomain(t),ew.from(e).hash(r)])}static hash(t,e,r){return bv(ew.encode(t,e,r))}static resolveNames(t,e,r,n){return Bv(this,void 0,void 0,(function*(){t=Uv(t);const i={};t.verifyingContract&&!iv(t.verifyingContract,20)&&(i[t.verifyingContract]="0x");const o=ew.from(e);o.visit(r,(t,e)=>("address"!==t||iv(e,20)||(i[e]="0x"),e));for(const t in i)i[t]=yield n(t);return t.verifyingContract&&i[t.verifyingContract]&&(t.verifyingContract=i[t.verifyingContract]),r=o.visit(r,(t,e)=>"address"===t&&i[e]?i[e]:e),{domain:t,value:r}}))}static getPayload(t,e,r){ew.hashDomain(t);const n={},i=[];Xv.forEach(e=>{const r=t[e];null!=r&&(n[e]=Yv[e](r),i.push({name:e,type:Zv[e]}))});const o=ew.from(e),s=Uv(e);return s.EIP712Domain?jv.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",e):s.EIP712Domain=i,o.encode(r),{types:s,domain:n,primaryType:o.primaryType,message:o.visit(r,(t,e)=>{if(t.match(/^bytes(\d*)/))return ov(nv(e));if(t.match(/^u?int/))return cv.from(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return"string"!=typeof e&&jv.throwArgumentError("invalid string","value",e),e}return jv.throwArgumentError("unsupported type","type",t)})}}}var rw=h((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Xt.Buffer}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function h(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s<o;s++){var a=t.charCodeAt(s)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.prototype._initNumber=function(t,e,n){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):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("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 i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,u=0,l=r;l<a;l+=n)u=h(t,l,l+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var f=1;for(u=h(t,l,t.length,e),l=0;l<s;l++)f*=e;this.imuln(f),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this.strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","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"],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,h=s/67108864|0;r.words[0]=a;for(var u=1;u<n;u++){for(var l=h>>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var m=u-d|0;l+=(s=(i=0|t.words[m])*(o=0|e.words[d])+f)/67108864|0,f=67108863&s}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],h=(16777215&(a<<i|o)).toString(16);n=0!==(o=a>>>24-i&16777215)||s!==this.length-1?u[6-h.length]+h+n:h+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];n="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modn(d).toString(t);n=(m=m.idivn(d)).isZero()?p+n:u[c-p.length]+p+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.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&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(t,e){return r(void 0!==o),this.toArrayLike(o,t,e)},i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var s,a,h="le"===e,u=new t(o),l=this.clone();if(h){for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[a]=s;for(;a<o;a++)u[a]=0}else{for(a=0;a<o-i;a++)u[a]=0;for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[o-a-1]=s}return u},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this.strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,e,r){var n,i,o,s=t.words,a=e.words,h=r.words,u=0,l=0|s[0],f=8191&l,c=l>>>13,d=0|s[1],m=8191&d,p=d>>>13,g=0|s[2],y=8191&g,v=g>>>13,w=0|s[3],b=8191&w,E=w>>>13,M=0|s[4],_=8191&M,A=M>>>13,N=0|s[5],S=8191&N,R=N>>>13,U=0|s[6],I=8191&U,P=U>>>13,x=0|s[7],k=8191&x,T=x>>>13,O=0|s[8],C=8191&O,F=O>>>13,D=0|s[9],L=8191&D,$=D>>>13,B=0|a[0],j=8191&B,z=B>>>13,G=0|a[1],q=8191&G,V=G>>>13,K=0|a[2],W=8191&K,H=K>>>13,Z=0|a[3],X=8191&Z,J=Z>>>13,Y=0|a[4],Q=8191&Y,tt=Y>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ft=8191<,ct=lt>>>13,dt=0|a[9],mt=8191&dt,pt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,z))+Math.imul(c,j)|0))<<13)|0;u=((o=Math.imul(c,z))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(m,j),i=(i=Math.imul(m,z))+Math.imul(p,j)|0,o=Math.imul(p,z);var yt=(u+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,V)|0)+Math.imul(c,q)|0))<<13)|0;u=((o=o+Math.imul(c,V)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,j),i=(i=Math.imul(y,z))+Math.imul(v,j)|0,o=Math.imul(v,z),n=n+Math.imul(m,q)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(p,q)|0,o=o+Math.imul(p,V)|0;var vt=(u+(n=n+Math.imul(f,W)|0)|0)+((8191&(i=(i=i+Math.imul(f,H)|0)+Math.imul(c,W)|0))<<13)|0;u=((o=o+Math.imul(c,H)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(b,j),i=(i=Math.imul(b,z))+Math.imul(E,j)|0,o=Math.imul(E,z),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,V)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,H)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,H)|0;var wt=(u+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,X)|0))<<13)|0;u=((o=o+Math.imul(c,J)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(_,j),i=(i=Math.imul(_,z))+Math.imul(A,j)|0,o=Math.imul(A,z),n=n+Math.imul(b,q)|0,i=(i=i+Math.imul(b,V)|0)+Math.imul(E,q)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(y,W)|0,i=(i=i+Math.imul(y,H)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,H)|0,n=n+Math.imul(m,X)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,J)|0;var bt=(u+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(S,j),i=(i=Math.imul(S,z))+Math.imul(R,j)|0,o=Math.imul(R,z),n=n+Math.imul(_,q)|0,i=(i=i+Math.imul(_,V)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,V)|0,n=n+Math.imul(b,W)|0,i=(i=i+Math.imul(b,H)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,H)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(p,Q)|0,o=o+Math.imul(p,tt)|0;var Et=(u+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;u=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(I,j),i=(i=Math.imul(I,z))+Math.imul(P,j)|0,o=Math.imul(P,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(_,W)|0,i=(i=i+Math.imul(_,H)|0)+Math.imul(A,W)|0,o=o+Math.imul(A,H)|0,n=n+Math.imul(b,X)|0,i=(i=i+Math.imul(b,J)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,J)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,nt)|0;var Mt=(u+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(c,ot)|0))<<13)|0;u=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,z))+Math.imul(T,j)|0,o=Math.imul(T,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,V)|0)+Math.imul(P,q)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,H)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,H)|0,n=n+Math.imul(_,X)|0,i=(i=i+Math.imul(_,J)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,st)|0;var _t=(u+(n=n+Math.imul(f,ht)|0)|0)+((8191&(i=(i=i+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((o=o+Math.imul(c,ut)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(C,j),i=(i=Math.imul(C,z))+Math.imul(F,j)|0,o=Math.imul(F,z),n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(T,q)|0,o=o+Math.imul(T,V)|0,n=n+Math.imul(I,W)|0,i=(i=i+Math.imul(I,H)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,H)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(_,Q)|0,i=(i=i+Math.imul(_,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var At=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,z))+Math.imul($,j)|0,o=Math.imul($,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,V)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,V)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,H)|0)+Math.imul(T,W)|0,o=o+Math.imul(T,H)|0,n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(_,rt)|0,i=(i=i+Math.imul(_,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(b,ot)|0,i=(i=i+Math.imul(b,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(m,ft)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(p,ft)|0,o=o+Math.imul(p,ct)|0;var Nt=(u+(n=n+Math.imul(f,mt)|0)|0)+((8191&(i=(i=i+Math.imul(f,pt)|0)+Math.imul(c,mt)|0))<<13)|0;u=((o=o+Math.imul(c,pt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(L,q),i=(i=Math.imul(L,V))+Math.imul($,q)|0,o=Math.imul($,V),n=n+Math.imul(C,W)|0,i=(i=i+Math.imul(C,H)|0)+Math.imul(F,W)|0,o=o+Math.imul(F,H)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(_,ot)|0,i=(i=i+Math.imul(_,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,n=n+Math.imul(b,ht)|0,i=(i=i+Math.imul(b,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,o=o+Math.imul(v,ct)|0;var St=(u+(n=n+Math.imul(m,mt)|0)|0)+((8191&(i=(i=i+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,W),i=(i=Math.imul(L,H))+Math.imul($,W)|0,o=Math.imul($,H),n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(_,ht)|0,i=(i=i+Math.imul(_,ut)|0)+Math.imul(A,ht)|0,o=o+Math.imul(A,ut)|0,n=n+Math.imul(b,ft)|0,i=(i=i+Math.imul(b,ct)|0)+Math.imul(E,ft)|0,o=o+Math.imul(E,ct)|0;var Rt=(u+(n=n+Math.imul(y,mt)|0)|0)+((8191&(i=(i=i+Math.imul(y,pt)|0)+Math.imul(v,mt)|0))<<13)|0;u=((o=o+Math.imul(v,pt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,J))+Math.imul($,X)|0,o=Math.imul($,J),n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(F,Q)|0,o=o+Math.imul(F,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,ut)|0,n=n+Math.imul(_,ft)|0,i=(i=i+Math.imul(_,ct)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,ct)|0;var Ut=(u+(n=n+Math.imul(b,mt)|0)|0)+((8191&(i=(i=i+Math.imul(b,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(i>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,n=Math.imul(L,Q),i=(i=Math.imul(L,tt))+Math.imul($,Q)|0,o=Math.imul($,tt),n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(F,rt)|0,o=o+Math.imul(F,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(S,ft)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(R,ft)|0,o=o+Math.imul(R,ct)|0;var It=(u+(n=n+Math.imul(_,mt)|0)|0)+((8191&(i=(i=i+Math.imul(_,pt)|0)+Math.imul(A,mt)|0))<<13)|0;u=((o=o+Math.imul(A,pt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul($,rt)|0,o=Math.imul($,nt),n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,st)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,ut)|0)+Math.imul(T,ht)|0,o=o+Math.imul(T,ut)|0,n=n+Math.imul(I,ft)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(P,ft)|0,o=o+Math.imul(P,ct)|0;var Pt=(u+(n=n+Math.imul(S,mt)|0)|0)+((8191&(i=(i=i+Math.imul(S,pt)|0)+Math.imul(R,mt)|0))<<13)|0;u=((o=o+Math.imul(R,pt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,ot),i=(i=Math.imul(L,st))+Math.imul($,ot)|0,o=Math.imul($,st),n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,ut)|0)+Math.imul(F,ht)|0,o=o+Math.imul(F,ut)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,ct)|0;var xt=(u+(n=n+Math.imul(I,mt)|0)|0)+((8191&(i=(i=i+Math.imul(I,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),n=n+Math.imul(C,ft)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(F,ft)|0,o=o+Math.imul(F,ct)|0;var kt=(u+(n=n+Math.imul(k,mt)|0)|0)+((8191&(i=(i=i+Math.imul(k,pt)|0)+Math.imul(T,mt)|0))<<13)|0;u=((o=o+Math.imul(T,pt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,ft),i=(i=Math.imul(L,ct))+Math.imul($,ft)|0,o=Math.imul($,ct);var Tt=(u+(n=n+Math.imul(C,mt)|0)|0)+((8191&(i=(i=i+Math.imul(C,pt)|0)+Math.imul(F,mt)|0))<<13)|0;u=((o=o+Math.imul(F,pt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863;var Ot=(u+(n=Math.imul(L,mt))|0)+((8191&(i=(i=Math.imul(L,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=wt,h[4]=bt,h[5]=Et,h[6]=Mt,h[7]=_t,h[8]=At,h[9]=Nt,h[10]=St,h[11]=Rt,h[12]=Ut,h[13]=It,h[14]=Pt,h[15]=xt,h[16]=kt,h[17]=Tt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new p).mulp(t,e,r)}function p(t,e){this.x=t,this.y=e}Math.imul||(d=c),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,f=(0|t.words[l])*(0|e.words[u]),c=67108863&f;a=67108863&(c=c+a|0),i+=(s=(s=s+(f/67108864|0)|0)+(c>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):m(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),r=i.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e},p.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n},p.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s<o;s++)n[s]=e[t[s]],i[s]=r[t[s]]},p.prototype.transform=function(t,e,r,n,i,o){this.permute(o,t,e,r,n,i);for(var s=1;s<i;s<<=1)for(var a=s<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),l=0;l<i;l+=a)for(var f=h,c=u,d=0;d<s;d++){var m=r[l+d],p=n[l+d],g=r[l+d+s],y=n[l+d+s],v=f*g-c*y;y=f*y+c*g,g=v,r[l+d]=m+g,n[l+d]=p+y,r[l+d+s]=m-g,n[l+d+s]=p-y,d!==a&&(v=h*f-u*c,c=h*c+u*f,f=v)}},p.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},p.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},p.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0}return t},p.prototype.convert13b=function(t,e,n,i){for(var o=0,s=0;s<e;s++)o+=0|t[s],n[2*s]=8191&o,o>>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<i;++s)n[s]=0;r(0===o),r(0==(-8192&o))},p.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},p.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),o=this.stub(n),s=new Array(n),a=new Array(n),h=new Array(n),u=new Array(n),l=new Array(n),f=new Array(n),c=r.words;c.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(e.words,e.length,u,n),this.transform(s,o,a,h,n,i),this.transform(u,o,l,f,n,i);for(var d=0;d<n;d++){var m=a[d]*l[d]-h[d]*f[d];h[d]=a[d]*f[d]+h[d]*l[d],a[d]=m}return this.conjugate(a,h,n),this.transform(a,h,c,o,n,i),this.conjugate(c,o,n),this.normalize13b(c,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),m(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){r("number"==typeof t),r(t<67108864);for(var e=0,n=0;n<this.length;n++){var i=(0|this.words[n])*t,o=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=o>>>26,this.words[n]=67108863&o}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(t.words[n]&1<<i)>>>i}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,h=(0|this.words[e])-a<<n;this.words[e]=h|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this.strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,h=n;if(i-=s,i=Math.max(0,i),h){for(var u=0;u<s;u++)h.words[u]=this.words[u];h.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=i);u--){var f=0|this.words[u];this.words[u]=l<<26-o|f>>>o,l=f&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n)&&!!(this.words[n]&i)},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this.strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(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)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(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 e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var h=(0|t.words[i])*e;a=((o-=67108863&h)>>26)-(h/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!==(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,h=n.length-o.length;if("mod"!==e){(a=new i(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var l=n.clone()._ishlnsubmul(o,1,h);0===l.negative&&(n=l,a&&(a.words[h]=1));for(var f=h-1;f>=0;f--){var c=67108864*(0|n.words[o.length+f])+(0|n.words[o.length+f-1]);for(c=Math.min(c/s|0,67108863),n._ishlnsubmul(o,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(o,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},i.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),h=new i(1),u=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(f)),o.iushrn(1),s.iushrn(1);for(var m=0,p=1;0==(n.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(n.iushrn(m);m-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(f)),a.iushrn(1),h.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(h)):(n.isub(e),a.isub(o),h.isub(s))}return{a:a,b:h,gcd:n.iushln(u)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),h=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new M(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(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 i(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n<r;n++)e.words[n]=t.words[n];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=4194303&i,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(4194303&o)<<4|i>>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,y),n(b,y),n(E,y),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new w;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},M.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},M.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},M.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,o),c=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),m=s;0!==d.cmp(a);){for(var p=d,g=0;0!==p.cmp(a);g++)p=p.redSqr();r(g<m);var y=this.pow(f,new i(1).iushln(m-g-1));c=c.redMul(y),f=y.redSqr(),d=d.redMul(f),m=g}return c},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],l=h-1;l>=0;l--){var f=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===l)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}h=26}return o},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new _(t)},n(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,o)}));function nw(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}var iw=ow;function ow(t,e){if(!t)throw new Error(e||"Assertion failed")}ow.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var sw=nw((function(t,e){var r=e;function n(t){return 1===t.length?"0"+t:t}function i(t){for(var e="",r=0;r<t.length;r++)e+=n(t[r].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var n=0;n<t.length;n++)r[n]=0|t[n];return r}if("hex"===e){(t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t);for(n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(n=0;n<t.length;n++){var i=t.charCodeAt(n),o=i>>8,s=255&i;o?r.push(o,s):r.push(s)}return r},r.zero2=n,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}})),aw=nw((function(t,e){var r=e;r.assert=iw,r.toArray=sw.toArray,r.zero2=sw.zero2,r.toHex=sw.toHex,r.encode=sw.encode,r.getNAF=function(t,e,r){var n=new Array(Math.max(t.bitLength(),r)+1);n.fill(0);for(var i=1<<e+1,o=t.clone(),s=0;s<n.length;s++){var a,h=o.andln(i-1);o.isOdd()?(a=h>(i>>1)-1?(i>>1)-h:h,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},r.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,h=t.andln(3)+i&3,u=e.andln(3)+o&3;3===h&&(h=-1),3===u&&(u=-1),s=0==(1&h)?0:3!==(n=t.andln(7)+i&7)&&5!==n||2!==u?h:-h,r[0].push(s),a=0==(1&u)?0:3!==(n=e.andln(7)+o&7)&&5!==n||2!==h?u:-u,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new rw(t,"hex","le")}})),hw=aw.getNAF,uw=aw.getJSF,lw=aw.assert;function fw(t,e){this.type=t,this.p=new rw(e.p,16),this.red=e.prime?rw.red(e.prime):rw.mont(this.p),this.zero=new rw(0).toRed(this.red),this.one=new rw(1).toRed(this.red),this.two=new rw(2).toRed(this.red),this.n=e.n&&new rw(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var cw=fw;function dw(t,e){this.curve=t,this.type=e,this.precomputed=null}fw.prototype.point=function(){throw new Error("Not implemented")},fw.prototype.validate=function(){throw new Error("Not implemented")},fw.prototype._fixedNafMul=function(t,e){lw(t.precomputed);var r=t._getDoubles(),n=hw(e,1,this._bitLength),i=(1<<r.step+1)-(r.step%2==0?2:1);i/=3;var o,s,a=[];for(o=0;o<n.length;o+=r.step){s=0;for(var h=o+r.step-1;h>=o;h--)s=(s<<1)+n[h];a.push(s)}for(var u=this.jpoint(null,null,null),l=this.jpoint(null,null,null),f=i;f>0;f--){for(o=0;o<a.length;o++)(s=a[o])===f?l=l.mixedAdd(r.points[o]):s===-f&&(l=l.mixedAdd(r.points[o].neg()));u=u.add(l)}return u.toP()},fw.prototype._wnafMul=function(t,e){var r=4,n=t._getNAFPoints(r);r=n.wnd;for(var i=n.points,o=hw(e,r,this._bitLength),s=this.jpoint(null,null,null),a=o.length-1;a>=0;a--){for(var h=0;a>=0&&0===o[a];a--)h++;if(a>=0&&h++,s=s.dblp(h),a<0)break;var u=o[a];lw(0!==u),s="affine"===t.type?u>0?s.mixedAdd(i[u-1>>1]):s.mixedAdd(i[-u-1>>1].neg()):u>0?s.add(i[u-1>>1]):s.add(i[-u-1>>1].neg())}return"affine"===t.type?s.toP():s},fw.prototype._wnafMulAdd=function(t,e,r,n,i){var o,s,a,h=this._wnafT1,u=this._wnafT2,l=this._wnafT3,f=0;for(o=0;o<n;o++){var c=(a=e[o])._getNAFPoints(t);h[o]=c.wnd,u[o]=c.points}for(o=n-1;o>=1;o-=2){var d=o-1,m=o;if(1===h[d]&&1===h[m]){var p=[e[d],null,null,e[m]];0===e[d].y.cmp(e[m].y)?(p[1]=e[d].add(e[m]),p[2]=e[d].toJ().mixedAdd(e[m].neg())):0===e[d].y.cmp(e[m].y.redNeg())?(p[1]=e[d].toJ().mixedAdd(e[m]),p[2]=e[d].add(e[m].neg())):(p[1]=e[d].toJ().mixedAdd(e[m]),p[2]=e[d].toJ().mixedAdd(e[m].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],y=uw(r[d],r[m]);for(f=Math.max(y[0].length,f),l[d]=new Array(f),l[m]=new Array(f),s=0;s<f;s++){var v=0|y[0][s],w=0|y[1][s];l[d][s]=g[3*(v+1)+(w+1)],l[m][s]=0,u[d]=p}}else l[d]=hw(r[d],h[d],this._bitLength),l[m]=hw(r[m],h[m],this._bitLength),f=Math.max(l[d].length,f),f=Math.max(l[m].length,f)}var b=this.jpoint(null,null,null),E=this._wnafT4;for(o=f;o>=0;o--){for(var M=0;o>=0;){var _=!0;for(s=0;s<n;s++)E[s]=0|l[s][o],0!==E[s]&&(_=!1);if(!_)break;M++,o--}if(o>=0&&M++,b=b.dblp(M),o<0)break;for(s=0;s<n;s++){var A=E[s];0!==A&&(A>0?a=u[s][A-1>>1]:A<0&&(a=u[s][-A-1>>1].neg()),b="affine"===a.type?b.mixedAdd(a):b.add(a))}}for(o=0;o<n;o++)u[o]=null;return i?b:b.toP()},fw.BasePoint=dw,dw.prototype.eq=function(){throw new Error("Not implemented")},dw.prototype.validate=function(){return this.curve.validate(this)},fw.prototype.decodePoint=function(t,e){t=aw.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?lw(t[t.length-1]%2==0):7===t[0]&&lw(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},dw.prototype.encodeCompressed=function(t){return this.encode(t,!0)},dw.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},dw.prototype.encode=function(t,e){return aw.encode(this._encode(e),t)},dw.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},dw.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},dw.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i<e;i+=t){for(var o=0;o<t;o++)n=n.dbl();r.push(n)}return{step:t,points:r}},dw.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,n=1===r?null:this.dbl(),i=1;i<r;i++)e[i]=e[i-1].add(n);return{wnd:t,points:e}},dw.prototype._getBeta=function(){return null},dw.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e};var mw=nw((function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}})),pw=aw.assert;function gw(t){cw.call(this,"short",t),this.a=new rw(t.a,16).toRed(this.red),this.b=new rw(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}mw(gw,cw);var yw=gw;function vw(t,e,r,n){cw.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new rw(e,16),this.y=new rw(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function ww(t,e,r,n){cw.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new rw(0)):(this.x=new rw(e,16),this.y=new rw(r,16),this.z=new rw(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}gw.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new rw(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new rw(t.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(e))?r=i[0]:(r=i[1],pw(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map((function(t){return{a:new rw(t.a,16),b:new rw(t.b,16)}})):this._getEndoBasis(r)}}},gw.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:rw.mont(t),r=new rw(2).toRed(e).redInvm(),n=r.redNeg(),i=new rw(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},gw.prototype._getEndoBasis=function(t){for(var e,r,n,i,o,s,a,h,u,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),f=t,c=this.n.clone(),d=new rw(1),m=new rw(0),p=new rw(0),g=new rw(1),y=0;0!==f.cmpn(0);){var v=c.div(f);h=c.sub(v.mul(f)),u=p.sub(v.mul(d));var w=g.sub(v.mul(m));if(!n&&h.cmp(l)<0)e=a.neg(),r=d,n=h.neg(),i=u;else if(n&&2==++y)break;a=h,c=f,f=h,p=d,d=u,g=m,m=w}o=h.neg(),s=u;var b=n.sqr().add(i.sqr());return o.sqr().add(s.sqr()).cmp(b)>=0&&(o=e,s=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),s=s.neg()),[{a:n,b:i},{a:o,b:s}]},gw.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),h=i.mul(r.b),u=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:h.add(u).neg()}},gw.prototype.pointFromX=function(t,e){(t=new rw(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},gw.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},gw.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o<t.length;o++){var s=this._endoSplit(e[o]),a=t[o],h=a._getBeta();s.k1.negative&&(s.k1.ineg(),a=a.neg(!0)),s.k2.negative&&(s.k2.ineg(),h=h.neg(!0)),n[2*o]=a,n[2*o+1]=h,i[2*o]=s.k1,i[2*o+1]=s.k2}for(var u=this._wnafMulAdd(1,n,i,2*o,r),l=0;l<2*o;l++)n[l]=null,i[l]=null;return u},mw(vw,cw.BasePoint),gw.prototype.point=function(t,e,r){return new vw(this,t,e,r)},gw.prototype.pointFromJSON=function(t,e){return vw.fromJSON(this,t,e)},vw.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,n=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(n)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(n)}}}return e}},vw.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},vw.fromJSON=function(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var n=t.point(e[0],e[1],r);if(!e[2])return n;function i(e){return t.point(e[0],e[1],r)}var o=e[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(i))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(i))}},n},vw.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},vw.prototype.isInfinity=function(){return this.inf},vw.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},vw.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},vw.prototype.getX=function(){return this.x.fromRed()},vw.prototype.getY=function(){return this.y.fromRed()},vw.prototype.mul=function(t){return t=new rw(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},vw.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},vw.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},vw.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},vw.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},vw.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},mw(ww,cw.BasePoint),gw.prototype.jpoint=function(t,e,r){return new ww(this,t,e,r)},ww.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},ww.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},ww.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),h=o.redSub(s);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),l=u.redMul(a),f=n.redMul(u),c=h.redSqr().redIAdd(l).redISub(f).redISub(f),d=h.redMul(f.redISub(c)).redISub(o.redMul(l)),m=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(c,d,m)},ww.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=s.redSqr(),u=h.redMul(s),l=r.redMul(h),f=a.redSqr().redIAdd(u).redISub(l).redISub(l),c=a.redMul(l.redISub(f)).redISub(i.redMul(u)),d=this.z.redMul(s);return this.curve.jpoint(f,c,d)},ww.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var n=this.curve.a,i=this.curve.tinv,o=this.x,s=this.y,a=this.z,h=a.redSqr().redSqr(),u=s.redAdd(s);for(e=0;e<t;e++){var l=o.redSqr(),f=u.redSqr(),c=f.redSqr(),d=l.redAdd(l).redIAdd(l).redIAdd(n.redMul(h)),m=o.redMul(f),p=d.redSqr().redISub(m.redAdd(m)),g=m.redISub(p),y=d.redMul(g);y=y.redIAdd(y).redISub(c);var v=u.redMul(a);e+1<t&&(h=h.redMul(c)),o=p,a=v,u=y}return this.curve.jpoint(o,u.redMul(i),a)},ww.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},ww.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n),h=a.redSqr().redISub(s).redISub(s),u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),t=h,e=a.redMul(s.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var l=this.x.redSqr(),f=this.y.redSqr(),c=f.redSqr(),d=this.x.redAdd(f).redSqr().redISub(l).redISub(c);d=d.redIAdd(d);var m=l.redAdd(l).redIAdd(l),p=m.redSqr(),g=c.redIAdd(c);g=(g=g.redIAdd(g)).redIAdd(g),t=p.redISub(d).redISub(d),e=m.redMul(d.redISub(t)).redISub(g),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},ww.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=a.redSqr().redISub(s).redISub(s);t=h;var u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),e=a.redMul(s.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var l=this.z.redSqr(),f=this.y.redSqr(),c=this.x.redMul(f),d=this.x.redSub(l).redMul(this.x.redAdd(l));d=d.redAdd(d).redIAdd(d);var m=c.redIAdd(c),p=(m=m.redIAdd(m)).redAdd(m);t=d.redSqr().redISub(p),r=this.y.redAdd(this.z).redSqr().redISub(f).redISub(l);var g=f.redSqr();g=(g=(g=g.redIAdd(g)).redIAdd(g)).redIAdd(g),e=d.redMul(m.redISub(t)).redISub(g)}return this.curve.jpoint(t,e,r)},ww.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),o=e.redSqr(),s=r.redSqr(),a=o.redAdd(o).redIAdd(o).redIAdd(t.redMul(i)),h=e.redAdd(e),u=(h=h.redIAdd(h)).redMul(s),l=a.redSqr().redISub(u.redAdd(u)),f=u.redISub(l),c=s.redSqr();c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var d=a.redMul(f).redISub(c),m=r.redAdd(r).redMul(n);return this.curve.jpoint(l,d,m)},ww.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),n=e.redSqr(),i=t.redAdd(t).redIAdd(t),o=i.redSqr(),s=this.x.redAdd(e).redSqr().redISub(t).redISub(n),a=(s=(s=(s=s.redIAdd(s)).redAdd(s).redIAdd(s)).redISub(o)).redSqr(),h=n.redIAdd(n);h=(h=(h=h.redIAdd(h)).redIAdd(h)).redIAdd(h);var u=i.redIAdd(s).redSqr().redISub(o).redISub(a).redISub(h),l=e.redMul(u);l=(l=l.redIAdd(l)).redIAdd(l);var f=this.x.redMul(a).redISub(l);f=(f=f.redIAdd(f)).redIAdd(f);var c=this.y.redMul(u.redMul(h.redISub(u)).redISub(s.redMul(a)));c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var d=this.z.redAdd(s).redSqr().redISub(r).redISub(a);return this.curve.jpoint(f,c,d)},ww.prototype.mul=function(t,e){return t=new rw(t,e),this.curve._wnafMul(this,t)},ww.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var n=e.redMul(this.z),i=r.redMul(t.z);return 0===this.y.redMul(i).redISub(t.y.redMul(n)).cmpn(0)},ww.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var n=t.clone(),i=this.curve.redN.redMul(e);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},ww.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},ww.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var bw=nw((function(t,e){var r=e;r.base=cw,r.short=yw,r.mont=null,r.edwards=null})),Ew=nw((function(t,e){var r,n=e,i=aw.assert;function o(t){"short"===t.type?this.curve=new bw.short(t):"edwards"===t.type?this.curve=new bw.edwards(t):this.curve=new bw.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function s(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new o(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Zm.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Zm.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Zm.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Zm.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Zm.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Zm.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Zm.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=null.crash()}catch(t){r=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Zm.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})}));function Mw(t){if(!(this instanceof Mw))return new Mw(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=sw.toArray(t.entropy,t.entropyEnc||"hex"),r=sw.toArray(t.nonce,t.nonceEnc||"hex"),n=sw.toArray(t.pers,t.persEnc||"hex");iw(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var _w=Mw;Mw.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},Mw.prototype._hmac=function(){return new Zm.hmac(this.hash,this.K)},Mw.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},Mw.prototype.reseed=function(t,e,r,n){"string"!=typeof e&&(n=r,r=e,e=null),t=sw.toArray(t,e),r=sw.toArray(r,n),iw(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},Mw.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=sw.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length<t;)this.V=this._hmac().update(this.V).digest(),i=i.concat(this.V);var o=i.slice(0,t);return this._update(r),this._reseed++,sw.encode(o,e)};var Aw=aw.assert;function Nw(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var Sw=Nw;Nw.fromPublic=function(t,e,r){return e instanceof Nw?e:new Nw(t,{pub:e,pubEnc:r})},Nw.fromPrivate=function(t,e,r){return e instanceof Nw?e:new Nw(t,{priv:e,privEnc:r})},Nw.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Nw.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},Nw.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},Nw.prototype._importPrivate=function(t,e){this.priv=new rw(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},Nw.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?Aw(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||Aw(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},Nw.prototype.derive=function(t){return t.validate()||Aw(t.validate(),"public point not validated"),t.mul(this.priv).getX()},Nw.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},Nw.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},Nw.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Rw=aw.assert;function Uw(t,e){if(t instanceof Uw)return t;this._importDER(t,e)||(Rw(t.r&&t.s,"Signature without r or s"),this.r=new rw(t.r,16),this.s=new rw(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Iw=Uw;function Pw(){this.place=0}function xw(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=e.place;o<n;o++,s++)i<<=8,i|=t[s],i>>>=0;return!(i<=127)&&(e.place=s,i)}function kw(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function Tw(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}Uw.prototype._importDER=function(t,e){t=aw.toArray(t,e);var r=new Pw;if(48!==t[r.place++])return!1;var n=xw(t,r);if(!1===n)return!1;if(n+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var i=xw(t,r);if(!1===i)return!1;var o=t.slice(r.place,i+r.place);if(r.place+=i,2!==t[r.place++])return!1;var s=xw(t,r);if(!1===s)return!1;if(t.length!==s+r.place)return!1;var a=t.slice(r.place,s+r.place);if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}if(0===a[0]){if(!(128&a[1]))return!1;a=a.slice(1)}return this.r=new rw(o),this.s=new rw(a),this.recoveryParam=null,!0},Uw.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=kw(e),r=kw(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];Tw(n,e.length),(n=n.concat(e)).push(2),Tw(n,r.length);var i=n.concat(r),o=[48];return Tw(o,i.length),o=o.concat(i),aw.encode(o,t)};var Ow=function(){throw new Error("unsupported")},Cw=aw.assert;function Fw(t){if(!(this instanceof Fw))return new Fw(t);"string"==typeof t&&(Cw(Object.prototype.hasOwnProperty.call(Ew,t),"Unknown curve "+t),t=Ew[t]),t instanceof Ew.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var Dw=Fw;Fw.prototype.keyPair=function(t){return new Sw(this,t)},Fw.prototype.keyFromPrivate=function(t,e){return Sw.fromPrivate(this,t,e)},Fw.prototype.keyFromPublic=function(t,e){return Sw.fromPublic(this,t,e)},Fw.prototype.genKeyPair=function(t){t||(t={});for(var e=new _w({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||Ow(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new rw(2));;){var i=new rw(e.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},Fw.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Fw.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new rw(t,16));for(var i=this.n.byteLength(),o=e.getPrivate().toArray("be",i),s=t.toArray("be",i),a=new _w({hash:this.hash,entropy:o,nonce:s,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new rw(1)),u=0;;u++){var l=n.k?n.k(u):new rw(a.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(h)>=0)){var f=this.g.mul(l);if(!f.isInfinity()){var c=f.getX(),d=c.umod(this.n);if(0!==d.cmpn(0)){var m=l.invm(this.n).mul(d.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var p=(f.getY().isOdd()?1:0)|(0!==c.cmp(d)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),p^=1),new Iw({r:d,s:m,recoveryParam:p})}}}}}},Fw.prototype.verify=function(t,e,r,n){t=this._truncateToN(new rw(t,16)),r=this.keyFromPublic(r,n);var i=(e=new Iw(e,"hex")).r,o=e.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var s,a=o.invm(this.n),h=a.mul(t).umod(this.n),u=a.mul(i).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(h,r.getPublic(),u)).isInfinity()&&s.eqXToP(i):!(s=this.g.mulAdd(h,r.getPublic(),u)).isInfinity()&&0===s.getX().umod(this.n).cmp(i)},Fw.prototype.recoverPubKey=function(t,e,r,n){Cw((3&r)===r,"The recovery param is more than two bits"),e=new Iw(e,n);var i=this.n,o=new rw(t),s=e.r,a=e.s,h=1&r,u=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");s=u?this.curve.pointFromX(s.add(this.curve.n),h):this.curve.pointFromX(s,h);var l=e.r.invm(i),f=i.sub(o).mul(l).umod(i),c=a.mul(l).umod(i);return this.g.mulAdd(f,s,c)},Fw.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new Iw(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var Lw=nw((function(t,e){var r=e;r.version="6.5.4",r.utils=aw,r.rand=function(){throw new Error("unsupported")},r.curve=bw,r.curves=Ew,r.ec=Dw,r.eddsa=null})).ec;const $w=new Yy("bytes/5.4.0");function Bw(t){return!!t.toHexString}function jw(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return jw(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function zw(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}function Gw(t,e){if(e||(e={}),"number"==typeof t){$w.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),jw(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Bw(t)&&(t=t.toHexString()),qw(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":$w.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return jw(new Uint8Array(n))}return zw(t)?jw(new Uint8Array(t)):$w.throwArgumentError("invalid arrayify value","value",t)}function qw(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}function Vw(t,e){if(e||(e={}),"number"==typeof t){$w.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Bw(t))return t.toHexString();if(qw(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":$w.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(zw(t)){let e="0x";for(let r=0;r<t.length;r++){let n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return $w.throwArgumentError("invalid hexlify value","value",t)}function Kw(t,e){for("string"!=typeof t?t=Vw(t):qw(t)||$w.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&$w.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function Ww(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(qw(r=t)&&!(r.length%2)||zw(r)){const r=Gw(t);65!==r.length&&$w.throwArgumentError("invalid signature string; must be 65 bytes","signature",t),e.r=Vw(r.slice(0,32)),e.s=Vw(r.slice(32,64)),e.v=r[64],e.v<27&&(0===e.v||1===e.v?e.v+=27:$w.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=Vw(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e._vs){const r=function(t,e){(t=Gw(t)).length>e&&$w.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),jw(r)}(Gw(e._vs),32);e._vs=Vw(r);const n=r[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=n:e.recoveryParam!==n&&$w.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),r[0]&=127;const i=Vw(r);null==e.s?e.s=i:e.s!==i&&$w.throwArgumentError("signature v mismatch _vs","signature",t)}null==e.recoveryParam?null==e.v?$w.throwArgumentError("signature missing v and recoveryParam","signature",t):0===e.v||1===e.v?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2:null==e.v?e.v=27+e.recoveryParam:e.recoveryParam!==1-e.v%2&&$w.throwArgumentError("signature recoveryParam mismatch v","signature",t),null!=e.r&&qw(e.r)?e.r=Kw(e.r,32):$w.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&qw(e.s)?e.s=Kw(e.s,32):$w.throwArgumentError("signature missing or invalid s","signature",t);const r=Gw(e.s);r[0]>=128&&$w.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const n=Vw(r);e._vs&&(qw(e._vs)||$w.throwArgumentError("signature invalid _vs","signature",t),e._vs=Kw(e._vs,32)),null==e._vs?e._vs=n:e._vs!==n&&$w.throwArgumentError("signature _vs mismatch v and s","signature",t)}var r;return e}const Hw=new Yy("signing-key/5.4.0");let Zw=null;function Xw(){return Zw||(Zw=new Lw("secp256k1")),Zw}class Jw{constructor(t){Rv(this,"curve","secp256k1"),Rv(this,"privateKey",Vw(t));const e=Xw().keyFromPrivate(Gw(this.privateKey));Rv(this,"publicKey","0x"+e.getPublic(!1,"hex")),Rv(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),Rv(this,"_isSigningKey",!0)}_addPoint(t){const e=Xw().keyFromPublic(Gw(this.publicKey)),r=Xw().keyFromPublic(Gw(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){const e=Xw().keyFromPrivate(Gw(this.privateKey)),r=Gw(t);32!==r.length&&Hw.throwArgumentError("bad digest length","digest",t);const n=e.sign(r,{canonical:!0});return Ww({recoveryParam:n.recoveryParam,r:Kw("0x"+n.r.toString(16),32),s:Kw("0x"+n.s.toString(16),32)})}computeSharedSecret(t){const e=Xw().keyFromPrivate(Gw(this.privateKey)),r=Xw().keyFromPublic(Gw(Yw(t)));return Kw("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function Yw(t,e){const r=Gw(t);if(32===r.length){const t=new Jw(r);return e?"0x"+Xw().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?Vw(r):"0x"+Xw().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+Xw().keyFromPublic(r).getPublic(!0,"hex"):Vw(r):Hw.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Qw=new Yy("bytes/5.4.0");function tb(t){return!!t.toHexString}function eb(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return eb(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function rb(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}function nb(t,e){if(e||(e={}),"number"==typeof t){Qw.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),eb(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),tb(t)&&(t=t.toHexString()),ib(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":Qw.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return eb(new Uint8Array(n))}return rb(t)?eb(new Uint8Array(t)):Qw.throwArgumentError("invalid arrayify value","value",t)}function ib(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}function ob(t,e,r){return"string"!=typeof t?t=function(t,e){if(e||(e={}),"number"==typeof t){Qw.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),tb(t))return t.toHexString();if(ib(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":Qw.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(rb(t)){let e="0x";for(let r=0;r<t.length;r++){let n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return Qw.throwArgumentError("invalid hexlify value","value",t)}(t):(!ib(t)||t.length%2)&&Qw.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}var sb=h((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Xt.Buffer}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function h(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s<o;s++){var a=t.charCodeAt(s)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.prototype._initNumber=function(t,e,n){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):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("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 i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,u=0,l=r;l<a;l+=n)u=h(t,l,l+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var f=1;for(u=h(t,l,t.length,e),l=0;l<s;l++)f*=e;this.imuln(f),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this.strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","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"],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,h=s/67108864|0;r.words[0]=a;for(var u=1;u<n;u++){for(var l=h>>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var m=u-d|0;l+=(s=(i=0|t.words[m])*(o=0|e.words[d])+f)/67108864|0,f=67108863&s}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],h=(16777215&(a<<i|o)).toString(16);n=0!==(o=a>>>24-i&16777215)||s!==this.length-1?u[6-h.length]+h+n:h+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];n="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modn(d).toString(t);n=(m=m.idivn(d)).isZero()?p+n:u[c-p.length]+p+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.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&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(t,e){return r(void 0!==o),this.toArrayLike(o,t,e)},i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var s,a,h="le"===e,u=new t(o),l=this.clone();if(h){for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[a]=s;for(;a<o;a++)u[a]=0}else{for(a=0;a<o-i;a++)u[a]=0;for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[o-a-1]=s}return u},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this.strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,e,r){var n,i,o,s=t.words,a=e.words,h=r.words,u=0,l=0|s[0],f=8191&l,c=l>>>13,d=0|s[1],m=8191&d,p=d>>>13,g=0|s[2],y=8191&g,v=g>>>13,w=0|s[3],b=8191&w,E=w>>>13,M=0|s[4],_=8191&M,A=M>>>13,N=0|s[5],S=8191&N,R=N>>>13,U=0|s[6],I=8191&U,P=U>>>13,x=0|s[7],k=8191&x,T=x>>>13,O=0|s[8],C=8191&O,F=O>>>13,D=0|s[9],L=8191&D,$=D>>>13,B=0|a[0],j=8191&B,z=B>>>13,G=0|a[1],q=8191&G,V=G>>>13,K=0|a[2],W=8191&K,H=K>>>13,Z=0|a[3],X=8191&Z,J=Z>>>13,Y=0|a[4],Q=8191&Y,tt=Y>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ft=8191<,ct=lt>>>13,dt=0|a[9],mt=8191&dt,pt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,z))+Math.imul(c,j)|0))<<13)|0;u=((o=Math.imul(c,z))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(m,j),i=(i=Math.imul(m,z))+Math.imul(p,j)|0,o=Math.imul(p,z);var yt=(u+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,V)|0)+Math.imul(c,q)|0))<<13)|0;u=((o=o+Math.imul(c,V)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,j),i=(i=Math.imul(y,z))+Math.imul(v,j)|0,o=Math.imul(v,z),n=n+Math.imul(m,q)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(p,q)|0,o=o+Math.imul(p,V)|0;var vt=(u+(n=n+Math.imul(f,W)|0)|0)+((8191&(i=(i=i+Math.imul(f,H)|0)+Math.imul(c,W)|0))<<13)|0;u=((o=o+Math.imul(c,H)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(b,j),i=(i=Math.imul(b,z))+Math.imul(E,j)|0,o=Math.imul(E,z),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,V)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,H)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,H)|0;var wt=(u+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,X)|0))<<13)|0;u=((o=o+Math.imul(c,J)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(_,j),i=(i=Math.imul(_,z))+Math.imul(A,j)|0,o=Math.imul(A,z),n=n+Math.imul(b,q)|0,i=(i=i+Math.imul(b,V)|0)+Math.imul(E,q)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(y,W)|0,i=(i=i+Math.imul(y,H)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,H)|0,n=n+Math.imul(m,X)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,J)|0;var bt=(u+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(S,j),i=(i=Math.imul(S,z))+Math.imul(R,j)|0,o=Math.imul(R,z),n=n+Math.imul(_,q)|0,i=(i=i+Math.imul(_,V)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,V)|0,n=n+Math.imul(b,W)|0,i=(i=i+Math.imul(b,H)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,H)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(p,Q)|0,o=o+Math.imul(p,tt)|0;var Et=(u+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;u=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(I,j),i=(i=Math.imul(I,z))+Math.imul(P,j)|0,o=Math.imul(P,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(_,W)|0,i=(i=i+Math.imul(_,H)|0)+Math.imul(A,W)|0,o=o+Math.imul(A,H)|0,n=n+Math.imul(b,X)|0,i=(i=i+Math.imul(b,J)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,J)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,nt)|0;var Mt=(u+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(c,ot)|0))<<13)|0;u=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,z))+Math.imul(T,j)|0,o=Math.imul(T,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,V)|0)+Math.imul(P,q)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,H)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,H)|0,n=n+Math.imul(_,X)|0,i=(i=i+Math.imul(_,J)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,st)|0;var _t=(u+(n=n+Math.imul(f,ht)|0)|0)+((8191&(i=(i=i+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((o=o+Math.imul(c,ut)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(C,j),i=(i=Math.imul(C,z))+Math.imul(F,j)|0,o=Math.imul(F,z),n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(T,q)|0,o=o+Math.imul(T,V)|0,n=n+Math.imul(I,W)|0,i=(i=i+Math.imul(I,H)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,H)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(_,Q)|0,i=(i=i+Math.imul(_,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var At=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,z))+Math.imul($,j)|0,o=Math.imul($,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,V)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,V)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,H)|0)+Math.imul(T,W)|0,o=o+Math.imul(T,H)|0,n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(_,rt)|0,i=(i=i+Math.imul(_,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(b,ot)|0,i=(i=i+Math.imul(b,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(m,ft)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(p,ft)|0,o=o+Math.imul(p,ct)|0;var Nt=(u+(n=n+Math.imul(f,mt)|0)|0)+((8191&(i=(i=i+Math.imul(f,pt)|0)+Math.imul(c,mt)|0))<<13)|0;u=((o=o+Math.imul(c,pt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(L,q),i=(i=Math.imul(L,V))+Math.imul($,q)|0,o=Math.imul($,V),n=n+Math.imul(C,W)|0,i=(i=i+Math.imul(C,H)|0)+Math.imul(F,W)|0,o=o+Math.imul(F,H)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(_,ot)|0,i=(i=i+Math.imul(_,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,n=n+Math.imul(b,ht)|0,i=(i=i+Math.imul(b,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,o=o+Math.imul(v,ct)|0;var St=(u+(n=n+Math.imul(m,mt)|0)|0)+((8191&(i=(i=i+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,W),i=(i=Math.imul(L,H))+Math.imul($,W)|0,o=Math.imul($,H),n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(_,ht)|0,i=(i=i+Math.imul(_,ut)|0)+Math.imul(A,ht)|0,o=o+Math.imul(A,ut)|0,n=n+Math.imul(b,ft)|0,i=(i=i+Math.imul(b,ct)|0)+Math.imul(E,ft)|0,o=o+Math.imul(E,ct)|0;var Rt=(u+(n=n+Math.imul(y,mt)|0)|0)+((8191&(i=(i=i+Math.imul(y,pt)|0)+Math.imul(v,mt)|0))<<13)|0;u=((o=o+Math.imul(v,pt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,J))+Math.imul($,X)|0,o=Math.imul($,J),n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(F,Q)|0,o=o+Math.imul(F,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,ut)|0,n=n+Math.imul(_,ft)|0,i=(i=i+Math.imul(_,ct)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,ct)|0;var Ut=(u+(n=n+Math.imul(b,mt)|0)|0)+((8191&(i=(i=i+Math.imul(b,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(i>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,n=Math.imul(L,Q),i=(i=Math.imul(L,tt))+Math.imul($,Q)|0,o=Math.imul($,tt),n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(F,rt)|0,o=o+Math.imul(F,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(S,ft)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(R,ft)|0,o=o+Math.imul(R,ct)|0;var It=(u+(n=n+Math.imul(_,mt)|0)|0)+((8191&(i=(i=i+Math.imul(_,pt)|0)+Math.imul(A,mt)|0))<<13)|0;u=((o=o+Math.imul(A,pt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul($,rt)|0,o=Math.imul($,nt),n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,st)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,ut)|0)+Math.imul(T,ht)|0,o=o+Math.imul(T,ut)|0,n=n+Math.imul(I,ft)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(P,ft)|0,o=o+Math.imul(P,ct)|0;var Pt=(u+(n=n+Math.imul(S,mt)|0)|0)+((8191&(i=(i=i+Math.imul(S,pt)|0)+Math.imul(R,mt)|0))<<13)|0;u=((o=o+Math.imul(R,pt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,ot),i=(i=Math.imul(L,st))+Math.imul($,ot)|0,o=Math.imul($,st),n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,ut)|0)+Math.imul(F,ht)|0,o=o+Math.imul(F,ut)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,ct)|0;var xt=(u+(n=n+Math.imul(I,mt)|0)|0)+((8191&(i=(i=i+Math.imul(I,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),n=n+Math.imul(C,ft)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(F,ft)|0,o=o+Math.imul(F,ct)|0;var kt=(u+(n=n+Math.imul(k,mt)|0)|0)+((8191&(i=(i=i+Math.imul(k,pt)|0)+Math.imul(T,mt)|0))<<13)|0;u=((o=o+Math.imul(T,pt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,ft),i=(i=Math.imul(L,ct))+Math.imul($,ft)|0,o=Math.imul($,ct);var Tt=(u+(n=n+Math.imul(C,mt)|0)|0)+((8191&(i=(i=i+Math.imul(C,pt)|0)+Math.imul(F,mt)|0))<<13)|0;u=((o=o+Math.imul(F,pt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863;var Ot=(u+(n=Math.imul(L,mt))|0)+((8191&(i=(i=Math.imul(L,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=wt,h[4]=bt,h[5]=Et,h[6]=Mt,h[7]=_t,h[8]=At,h[9]=Nt,h[10]=St,h[11]=Rt,h[12]=Ut,h[13]=It,h[14]=Pt,h[15]=xt,h[16]=kt,h[17]=Tt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new p).mulp(t,e,r)}function p(t,e){this.x=t,this.y=e}Math.imul||(d=c),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,f=(0|t.words[l])*(0|e.words[u]),c=67108863&f;a=67108863&(c=c+a|0),i+=(s=(s=s+(f/67108864|0)|0)+(c>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):m(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),r=i.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e},p.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n},p.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s<o;s++)n[s]=e[t[s]],i[s]=r[t[s]]},p.prototype.transform=function(t,e,r,n,i,o){this.permute(o,t,e,r,n,i);for(var s=1;s<i;s<<=1)for(var a=s<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),l=0;l<i;l+=a)for(var f=h,c=u,d=0;d<s;d++){var m=r[l+d],p=n[l+d],g=r[l+d+s],y=n[l+d+s],v=f*g-c*y;y=f*y+c*g,g=v,r[l+d]=m+g,n[l+d]=p+y,r[l+d+s]=m-g,n[l+d+s]=p-y,d!==a&&(v=h*f-u*c,c=h*c+u*f,f=v)}},p.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},p.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},p.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0}return t},p.prototype.convert13b=function(t,e,n,i){for(var o=0,s=0;s<e;s++)o+=0|t[s],n[2*s]=8191&o,o>>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<i;++s)n[s]=0;r(0===o),r(0==(-8192&o))},p.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},p.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),o=this.stub(n),s=new Array(n),a=new Array(n),h=new Array(n),u=new Array(n),l=new Array(n),f=new Array(n),c=r.words;c.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(e.words,e.length,u,n),this.transform(s,o,a,h,n,i),this.transform(u,o,l,f,n,i);for(var d=0;d<n;d++){var m=a[d]*l[d]-h[d]*f[d];h[d]=a[d]*f[d]+h[d]*l[d],a[d]=m}return this.conjugate(a,h,n),this.transform(a,h,c,o,n,i),this.conjugate(c,o,n),this.normalize13b(c,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),m(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){r("number"==typeof t),r(t<67108864);for(var e=0,n=0;n<this.length;n++){var i=(0|this.words[n])*t,o=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=o>>>26,this.words[n]=67108863&o}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(t.words[n]&1<<i)>>>i}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,h=(0|this.words[e])-a<<n;this.words[e]=h|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this.strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,h=n;if(i-=s,i=Math.max(0,i),h){for(var u=0;u<s;u++)h.words[u]=this.words[u];h.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=i);u--){var f=0|this.words[u];this.words[u]=l<<26-o|f>>>o,l=f&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n)&&!!(this.words[n]&i)},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this.strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(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)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(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 e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var h=(0|t.words[i])*e;a=((o-=67108863&h)>>26)-(h/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!==(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,h=n.length-o.length;if("mod"!==e){(a=new i(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var l=n.clone()._ishlnsubmul(o,1,h);0===l.negative&&(n=l,a&&(a.words[h]=1));for(var f=h-1;f>=0;f--){var c=67108864*(0|n.words[o.length+f])+(0|n.words[o.length+f-1]);for(c=Math.min(c/s|0,67108863),n._ishlnsubmul(o,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(o,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},i.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),h=new i(1),u=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(f)),o.iushrn(1),s.iushrn(1);for(var m=0,p=1;0==(n.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(n.iushrn(m);m-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(f)),a.iushrn(1),h.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(h)):(n.isub(e),a.isub(o),h.isub(s))}return{a:a,b:h,gcd:n.iushln(u)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),h=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new M(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(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 i(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n<r;n++)e.words[n]=t.words[n];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=4194303&i,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(4194303&o)<<4|i>>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,y),n(b,y),n(E,y),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new w;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},M.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},M.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},M.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,o),c=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),m=s;0!==d.cmp(a);){for(var p=d,g=0;0!==p.cmp(a);g++)p=p.redSqr();r(g<m);var y=this.pow(f,new i(1).iushln(m-g-1));c=c.redMul(y),f=y.redSqr(),d=d.redMul(f),m=g}return c},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],l=h-1;l>=0;l--){var f=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===l)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}h=26}return o},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new _(t)},n(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,o)})).BN;new Yy("bignumber/5.4.0");const ab=new Yy("address/5.4.0");function hb(t){ib(t,20)||ab.throwArgumentError("invalid address","address",t);const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const n=nb(bv(r));for(let t=0;t<40;t+=2)n[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&n[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const ub={};for(let t=0;t<10;t++)ub[String(t)]=String(t);for(let t=0;t<26;t++)ub[String.fromCharCode(65+t)]=String(10+t);const lb=Math.floor(function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}(9007199254740991));function fb(t){let e=null;if("string"!=typeof t&&ab.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=hb(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&ab.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map(t=>ub[t]).join("");for(;e.length>=lb;){let t=e.substring(0,lb);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t)&&ab.throwArgumentError("bad icap checksum","address",t),r=t.substring(4),e=new sb(r,36).toString(16);e.length<40;)e="0"+e;e=hb("0x"+e)}else ab.throwArgumentError("invalid address","address",t);var r;return e}new Yy("transactions/5.4.0");var cb;function db(t,e){return function(t){return fb(ob(bv(ob(Yw(t),1)),12))}(function(t,e){const r=Ww(e),n={r:Gw(r.r),s:Gw(r.s)};return"0x"+Xw().recoverPubKey(Gw(t),n,r.recoveryParam).encode("hex",!1)}(nb(t),e))}!function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"}(cb||(cb={}));window&&window.__awaiter;new Yy("wallet/5.4.0");function mb(t,n,i,o){return e(this,void 0,void 0,(function(){var e,s,a,h;return r(this,(function(r){switch(r.label){case 0:s="0x1626ba7e",a="function isValidSignature(bytes32 _hash, bytes memory _signature) public view returns (bytes4 magicValue)",r.label=1;case 1:return r.trys.push([1,3,,4]),[4,Pb(o,[a],[t,"isValidSignature",[j(i),n]])];case 2:return e=r.sent(),[3,4];case 3:return h=r.sent(),console.log(h),[2,!1];case 4:return[2,e.toLowerCase()===s.toLowerCase()]}}))}))}function pb(t,n,i,o){return e(this,void 0,void 0,(function(){var e,s,a,h;return r(this,(function(r){switch(r.label){case 0:s="0x20c13b0b",a="function isValidSignature(bytes _hash, bytes memory _signature) public view returns (bytes4 magicValue)",r.label=1;case 1:return r.trys.push([1,3,,4]),[4,Pb(o,[a],[t,"isValidSignature",[j(i),n]])];case 2:return e=r.sent(),[3,4];case 3:return h=r.sent(),console.log(h),[2,!1];case 4:return[2,e.toLowerCase()===s.toLowerCase()]}}))}))}function gb(t,n,i,o){return void 0===o&&(o="1"),e(this,void 0,void 0,(function(){var e;return r(this,(function(r){switch(r.label){case 0:return e=zy(o),[4,mb(t,n,i,e)];case 1:return r.sent()?[2,!0]:[4,pb(t,n,i,e)];case 2:return[2,r.sent()]}}))}))}function yb(t){var e=t.domain,r=t.types,n=t.message;return _o.hash(e,r,n)}var vb=["cloudflare-ipfs.com","cf-ipfs.com","ipfs.io","ipfs.fleek.co","gateway.pinata.cloud","dweb.link","ipfs.infura.io"],wb=function(){function t(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}return t.prototype.resultsByVoteBalance=function(){var t=this;return this.proposal.choices.map((function(e,r){return t.votes.filter((function(t){return t.choice===r+1})).reduce((function(t,e){return t+e.balance}),0)}))},t.prototype.resultsByStrategyScore=function(){var t=this;return this.proposal.choices.map((function(e,r){return t.strategies.map((function(e,n){return t.votes.filter((function(t){return t.choice===r+1})).reduce((function(t,e){return t+e.scores[n]}),0)}))}))},t.prototype.sumOfResultsBalance=function(){return this.votes.reduce((function(t,e){return t+e.balance}),0)},t.prototype.getChoiceString=function(){return this.proposal.choices[this.selected-1]},t}(),bb=function(){function t(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}return t.prototype.resultsByVoteBalance=function(){var t=this;return this.proposal.choices.map((function(e,r){return t.votes.filter((function(t){return t.choice.includes(r+1)})).reduce((function(t,e){return t+e.balance}),0)}))},t.prototype.resultsByStrategyScore=function(){var t=this;return this.proposal.choices.map((function(e,r){return t.strategies.map((function(e,n){return t.votes.filter((function(t){return t.choice.includes(r+1)})).reduce((function(t,e){return t+e.scores[n]}),0)}))}))},t.prototype.sumOfResultsBalance=function(){return this.votes.reduce((function(t,e){return t+e.balance}),0)},t.prototype.getChoiceString=function(){var t=this;return this.selected?this.proposal.choices.filter((function(e,r){return t.selected.includes(r+1)})).join(", "):""},t}();function Eb(t,e,r){var n=r.reduce((function(t,e){return t+e}),0),i=e[t]/n*100;return isNaN(i)?0:i}function Mb(t,e,r){return Math.sqrt(Eb(t+1,e,Object.values(e))/100*r)}var _b=function(){function t(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}return t.prototype.resultsByVoteBalance=function(){var t=this,e=this.proposal.choices.map((function(e,r){return t.votes.map((function(t){return Mb(r,t.choice,t.balance)})).reduce((function(t,e){return t+e}),0)})).map((function(t){return t*t}));return e.map((function(t,r){return Eb(r,e,e)})).map((function(e){return t.sumOfResultsBalance()/100*e}))},t.prototype.resultsByStrategyScore=function(){var t=this,e=this.proposal.choices.map((function(e,r){return t.strategies.map((function(e,n){return t.votes.map((function(t){return Mb(r,t.choice,t.scores[n])})).reduce((function(t,e){return t+e}),0)}))})).map((function(t){return t.map((function(t){return[t*t]}))}));return e.map((function(r,n){return t.strategies.map((function(t,r){return[Eb(0,e[n][r],e.flat(2))]})).map((function(e){return[t.sumOfResultsBalance()/100*e]}))}))},t.prototype.sumOfResultsBalance=function(){return this.votes.reduce((function(t,e){return t+e.balance}),0)},t.prototype.getChoiceString=function(){var t=this;return this.proposal.choices.map((function(e,r){if(t.selected[r+1])return Math.round(10*Eb(r+1,t.selected,Object.values(t.selected)))/10+"% for "+e})).filter((function(t){return null!=t})).join(", ")},t}();function Ab(t,e){var r=function t(e,r){var o=i(new Set(e.map((function(t){return t[0]})).flat())),s=Object.entries(e.reduce((function(t,e,r,i){var o=n(e,1)[0];return t[o[0]][0]+=i[r][1],t[o[0]][1].length>1?t[o[0]][1]=t[o[0]][1].map((function(t,e){return t+i[r][2][e]})):t[o[0]][1]=[t[o[0]][1].concat(i[r][2]).reduce((function(t,e){return t+e}),0)],t}),Object.assign.apply(Object,i([{}],o.map((function(t){var e;return(e={})[t]=[0,[]],e})))))),a=s.map((function(t){return[t[0],t[1][0]]})),h=n(a.reduce((function(t,e){var r=n(t,2),i=r[0],o=r[1],s=n(e,2),a=s[0],h=s[1];return h>o?[a,h]:[i,o]}),["?",-1/0]),2),u=(h[0],h[1]),l=n(a.reduce((function(t,e){var r=n(t,2),i=r[0],o=r[1],s=n(e,2),a=s[0],h=s[1];return h<o?[a,h]:[i,o]}),["?",1/0]),2),f=l[0],c=(l[1],s.sort((function(t,e){return e[1][0]-t[1][0]}))),d=e.map((function(t){return t[1]})).reduce((function(t,e){return t+e}),0);return r.push({round:r.length+1,sortedByHighest:c}),u>d/2||c.length<3?r:t(e.map((function(t){return[t[0].filter((function(t){return t!=f})),t[1],t[2]]})).filter((function(t){return t[0].length>0})),r)}(e.map((function(t){return[t.choice,t.balance,t.scores]})),[]);return r[r.length-1].sortedByHighest.filter((function(e){return e[0]==t+1}))}var Nb=function(){function t(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}return t.prototype.resultsByVoteBalance=function(){var t=this;return this.proposal.choices.map((function(e,r){return Ab(r,t.votes).reduce((function(t,e){return t+e[1][0]}),0)}))},t.prototype.resultsByStrategyScore=function(){var t=this;return this.proposal.choices.map((function(e,r){return t.strategies.map((function(e,n){return Ab(r,t.votes).reduce((function(t,e){return t+e[1][1][n]}),0)}))}))},t.prototype.sumOfResultsBalance=function(){return this.resultsByVoteBalance().reduce((function(t,e){return t+e}))},t.prototype.getChoiceString=function(){var t=this;return this.selected.map((function(e){if(t.proposal.choices[e-1])return t.proposal.choices[e-1]})).map((function(t,e){return"("+Cb(e+1)+") "+t})).join(", ")},t}();function Sb(t,e,r){var n=r.reduce((function(t,e){return t+e}),0),i=e[t]/n*100;return isNaN(i)?0:i}function Rb(t,e,r){return Sb(t+1,e,Object.values(e))/100*r}var Ub=function(){function t(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}return t.prototype.resultsByVoteBalance=function(){var t=this,e=this.proposal.choices.map((function(e,r){return t.votes.map((function(t){return Rb(r,t.choice,t.balance)})).reduce((function(t,e){return t+e}),0)}));return e.map((function(t,r){return Sb(r,e,e)})).map((function(e){return t.sumOfResultsBalance()/100*e}))},t.prototype.resultsByStrategyScore=function(){var t=this,e=this.proposal.choices.map((function(e,r){return t.strategies.map((function(e,n){return t.votes.map((function(t){return Rb(r,t.choice,t.scores[n])})).reduce((function(t,e){return t+e}),0)}))})).map((function(t){return t.map((function(t){return[t]}))}));return e.map((function(r,n){return t.strategies.map((function(t,r){return[Sb(0,e[n][r],e.flat(2))]})).map((function(e){return[t.sumOfResultsBalance()/100*e]}))}))},t.prototype.sumOfResultsBalance=function(){return this.votes.reduce((function(t,e){return t+e.balance}),0)},t.prototype.getChoiceString=function(){var t=this;return this.proposal.choices.map((function(e,r){if(t.selected[r+1])return Math.round(10*Sb(r+1,t.selected,Object.values(t.selected)))/10+"% for "+e})).filter((function(t){return null!=t})).join(", ")},t}(),Ib=["function text(bytes32 node, string calldata key) external view returns (string memory)"];function Pb(t,n,o,s){return e(this,void 0,void 0,(function(){var e,a,h;return r(this,(function(r){switch(r.label){case 0:e=new Ra(o[0],n,t),r.label=1;case 1:return r.trys.push([1,3,,4]),a=o[2]||[],[4,e[o[1]].apply(e,i(a,[s||{}]))];case 2:return[2,r.sent()];case 3:return h=r.sent(),[2,Promise.reject(h)];case 4:return[2]}}))}))}function xb(t,i,o,s,a){return e(this,void 0,void 0,(function(){var e,h,u,l,f,c,d;return r(this,(function(r){switch(r.label){case 0:e=["function aggregate(tuple(address target, bytes callData)[] calls) view returns (uint256 blockNumber, bytes[] returnData)"],h=new Ra(By[t].multicall,e,i),u=new xo(o),r.label=1;case 1:return r.trys.push([1,3,,4]),l=(null==a?void 0:a.limit)||500,f=Math.ceil(s.length/l),c=[],Array.from(Array(f)).forEach((function(t,e){var r=s.slice(l*e,l*(e+1));c.push(h.aggregate(r.map((function(t){return[t[0].toLowerCase(),u.encodeFunctionData(t[1],t[2])]})),a||{}))})),[4,Promise.all(c)];case 2:return[2,r.sent().reduce((function(t,e){var r=n(e,2)[1];return t.concat(r)}),[]).map((function(t,e){return u.decodeFunctionResult(s[e][1],t)}))];case 3:return d=r.sent(),[2,Promise.reject(d)];case 4:return[2]}}))}))}function kb(t,e){void 0===e&&(e=vb[0]);var r="https://"+e;if(!t)return null;if(!(t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("https://")||t.startsWith("http://")))return r+"/ipfs/"+t;var n=t.split("://")[0];return"ipfs"===n?t.replace("ipfs://",r+"/ipfs/"):"ipns"===n?t.replace("ipns://",r+"/ipns/"):t}function Tb(t,n,i,o,s,a){return void 0===s&&(s="latest"),void 0===a&&(a="https://score.snapshot.org/api/scores"),e(this,void 0,void 0,(function(){var e,h;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),e={space:t,network:i,snapshot:s,strategies:n,addresses:o},[4,u(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({params:e})})];case 1:return[4,r.sent().json()];case 2:return[2,r.sent().result.scores];case 3:return h=r.sent(),[2,Promise.reject(h)];case 4:return[2]}}))}))}function Ob(t,e,r){void 0===r&&(r="1");var n=By[r].ensResolver||By[1].ensResolver,i=iu.hash(iu.normalize(t));return Pb(zy(r),Ib,[n,"text",[i,e]])}function Cb(t){var e=["th","st","nd","rd"],r=t%100;return t+(e[(r-20)%10]||e[r]||e[0])}return{Client:K,Client712:R,schemas:Z,utils:{call:Pb,multicall:xb,subgraphRequest:function(n,i,o){return void 0===o&&(o={}),e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,u(n,{method:"POST",headers:t({Accept:"application/json","Content-Type":"application/json"},null==o?void 0:o.headers),body:JSON.stringify({query:lu.jsonToGraphQLQuery({query:i})})})];case 1:return[4,e.sent().json()];case 2:return[2,e.sent().data||{}]}}))}))},ipfsGet:function(t,n,i){return void 0===i&&(i="ipfs"),e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,u("https://"+t+"/"+i+"/"+n).then((function(t){return t.json()}))]}))}))},getUrl:kb,getJSON:function(t){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){return e=kb(t),[2,u(e).then((function(t){return t.json()}))]}))}))},sendTransaction:function(t,n,o,s,a,h){return void 0===h&&(h={}),e(this,void 0,void 0,(function(){var e,u,l;return r(this,(function(r){switch(r.label){case 0:return e=t.getSigner(),u=new Ra(n,o,t),[4,(l=u.connect(e))[s].apply(l,i(a,[h]))];case 1:return[2,r.sent()]}}))}))},getScores:Tb,validateSchema:function(t,e){var r=new cf({allErrors:!0,allowUnionTypes:!0,$data:!0});pf(r);var n=r.compile(t),i=n(e);return i||n.errors},getEnsTextRecord:Ob,getSpaceUri:function(t,n){return void 0===n&&(n="1"),e(this,void 0,void 0,(function(){var e;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,Ob(t,"snapshot",n)];case 1:return[2,r.sent()];case 2:return e=r.sent(),console.log("getSpaceUriFromTextRecord failed",t,e),[3,3];case 3:return[2,!1]}}))}))},clone:function(t){return JSON.parse(JSON.stringify(t))},sleep:function(t){return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,new Promise((function(e){setTimeout(e,t)}))]}))}))},getNumberWithOrdinal:Cb,voting:{"single-choice":wb,approval:bb,quadratic:_b,"ranked-choice":Nb,weighted:Ub,basic:wb},getProvider:zy,signMessage:V,getBlockNumber:function(t){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t.getBlockNumber()];case 1:return e=r.sent(),[2,parseInt(e)];case 2:return r.sent(),[2,Promise.reject()];case 3:return[2]}}))}))},Multicaller:ac,validations:Gy,getHash:yb,verify:function(t,n,i){return e(this,void 0,void 0,(function(){var e,o,s,a,h;return r(this,(function(r){switch(r.label){case 0:return e=i.domain,o=i.types,s=i.message,a=function(t,e,r,n){return db(ew.hash(t,e,r),n)}(e,o,s,n),h=yb(i),console.log("Hash",h),console.log("Address",t),console.log("Recover address",a),t===a?[2,!0]:(console.log("Check EIP1271 signature"),[4,gb(t,n,h)]);case 1:return[2,r.sent()]}}))}))},SNAPSHOT_SUBGRAPH_URL:{1:"https://gateway.thegraph.com/api/3Q4vnuSqemXnSNHoiLD7wdBbGCXszUYnUbTz191kDMNn/subgraphs/id/3Q4vnuSqemXnSNHoiLD7wdBbGCXszUYnUbTz191kDMNn",4:"https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-rinkeby",42:"https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-kovan",97:"https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-binance-smart-chain",100:"https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-gnosis-chain",137:"https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-polygon",250:"https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-fantom"}}}}));
|
|
31
|
+
deps: ${r}}`};const r={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(t){const[e,r]=function({schema:t}){const e={},r={};for(const n in t){if("__proto__"===n)continue;(Array.isArray(t[n])?e:r)[n]=t[n]}return[e,r]}(t);n(t,e),i(t,r)}};function n(t,e=t.schema){const{gen:r,data:n,it:i}=t;if(0===Object.keys(e).length)return;const o=r.let("missing");for(const s in e){const a=e[s];if(0===a.length)continue;const h=_u.propertyInData(r,n,s,i.opts.ownProperties);t.setParams({property:s,depsCount:a.length,deps:a.join(", ")}),i.allErrors?r.if(h,()=>{for(const e of a)_u.checkReportMissingProp(t,e)}):(r.if(du._`${h} && (${_u.checkMissingProp(t,a,o)})`),_u.reportMissingProp(t,o),r.else())}}function i(t,e=t.schema){const{gen:r,data:n,keyword:i,it:o}=t,s=r.name("valid");for(const a in e)mu.alwaysValidSchema(o,e[a])||(r.if(_u.propertyInData(r,n,a,o.opts.ownProperties),()=>{const e=t.subschema({keyword:i,schemaProp:a},s);t.mergeValidEvaluated(e,s)},()=>r.var(s,!0)),t.ok(s))}e.validatePropertyDeps=n,e.validateSchemaDeps=i,e.default=r}));var Pl={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:t})=>du._`{propertyName: ${t.propertyName}}`},code(t){const{gen:e,schema:r,data:n,it:i}=t;if(mu.alwaysValidSchema(i,r))return;const o=e.name("valid");e.forIn("key",n,r=>{t.setParams({propertyName:r}),t.subschema({keyword:"propertyNames",data:r,dataTypes:["string"],propertyName:r,compositeRule:!0},o),e.if(du.not(o),()=>{t.error(!0),i.allErrors||e.break()})}),t.ok(o)}},xl=Object.defineProperty({default:Pl},"__esModule",{value:!0});var kl={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:t})=>du._`{additionalProperty: ${t.additionalProperty}}`},code(t){const{gen:e,schema:r,parentSchema:n,data:i,errsCount:o,it:s}=t;if(!o)throw new Error("ajv implementation error");const{allErrors:a,opts:h}=s;if(s.props=!0,"all"!==h.removeAdditional&&mu.alwaysValidSchema(s,r))return;const u=_u.allSchemaProperties(n.properties),l=_u.allSchemaProperties(n.patternProperties);function f(t){e.code(du._`delete ${i}[${t}]`)}function c(n){if("all"===h.removeAdditional||h.removeAdditional&&!1===r)f(n);else{if(!1===r)return t.setParams({additionalProperty:n}),t.error(),void(a||e.break());if("object"==typeof r&&!mu.alwaysValidSchema(s,r)){const r=e.name("valid");"failing"===h.removeAdditional?(d(n,r,!1),e.if(du.not(r),()=>{t.reset(),f(n)})):(d(n,r),a||e.if(du.not(r),()=>e.break()))}}}function d(e,r,n){const i={keyword:"additionalProperties",dataProp:e,dataPropType:mu.Type.Str};!1===n&&Object.assign(i,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(i,r)}e.forIn("key",i,r=>{u.length||l.length?e.if(function(r){let i;if(u.length>8){const t=mu.schemaRefOrVal(s,n.properties,"properties");i=_u.isOwnProperty(e,t,r)}else i=u.length?du.or(...u.map(t=>du._`${r} === ${t}`)):du.nil;return l.length&&(i=du.or(i,...l.map(e=>du._`${_u.usePattern(t,e)}.test(${r})`))),du.not(i)}(r),()=>c(r)):c(r)}),t.ok(du._`${o} === ${gu.default.errors}`)}},Tl=Object.defineProperty({default:kl},"__esModule",{value:!0});var Ol={keyword:"properties",type:"object",schemaType:"object",code(t){const{gen:e,schema:r,parentSchema:n,data:i,it:o}=t;"all"===o.opts.removeAdditional&&void 0===n.additionalProperties&&Tl.default.code(new Pu.KeywordCxt(o,Tl.default,"additionalProperties"));const s=_u.allSchemaProperties(r);for(const t of s)o.definedProperties.add(t);o.opts.unevaluated&&s.length&&!0!==o.props&&(o.props=mu.mergeEvaluated.props(e,mu.toHash(s),o.props));const a=s.filter(t=>!mu.alwaysValidSchema(o,r[t]));if(0===a.length)return;const h=e.name("valid");for(const r of a)u(r)?l(r):(e.if(_u.propertyInData(e,i,r,o.opts.ownProperties)),l(r),o.allErrors||e.else().var(h,!0),e.endIf()),t.it.definedProperties.add(r),t.ok(h);function u(t){return o.opts.useDefaults&&!o.compositeRule&&void 0!==r[t].default}function l(e){t.subschema({keyword:"properties",schemaProp:e,dataProp:e},h)}}},Cl=Object.defineProperty({default:Ol},"__esModule",{value:!0});const Fl=mu;var Dl={keyword:"patternProperties",type:"object",schemaType:"object",code(t){const{gen:e,schema:r,data:n,parentSchema:i,it:o}=t,{opts:s}=o,a=_u.allSchemaProperties(r),h=a.filter(t=>mu.alwaysValidSchema(o,r[t]));if(0===a.length||h.length===a.length&&(!o.opts.unevaluated||!0===o.props))return;const u=s.strictSchema&&!s.allowMatchingProperties&&i.properties,l=e.name("valid");!0===o.props||o.props instanceof du.Name||(o.props=Fl.evaluatedPropsToName(e,o.props));const{props:f}=o;function c(t){for(const e in u)new RegExp(t).test(e)&&mu.checkStrictMode(o,`property ${e} matches pattern ${t} (use allowMatchingProperties)`)}function d(r){e.forIn("key",n,n=>{e.if(du._`${_u.usePattern(t,r)}.test(${n})`,()=>{const i=h.includes(r);i||t.subschema({keyword:"patternProperties",schemaProp:r,dataProp:n,dataPropType:Fl.Type.Str},l),o.opts.unevaluated&&!0!==f?e.assign(du._`${f}[${n}]`,!0):i||o.allErrors||e.if(du.not(l),()=>e.break())})})}!function(){for(const t of a)u&&c(t),o.allErrors?d(t):(e.var(l,!0),d(t),e.if(l))}()}},Ll=Object.defineProperty({default:Dl},"__esModule",{value:!0});var $l={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){const{gen:e,schema:r,it:n}=t;if(mu.alwaysValidSchema(n,r))return void t.fail();const i=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},i),t.result(i,()=>t.error(),()=>t.reset())},error:{message:"must NOT be valid"}},Bl=Object.defineProperty({default:$l},"__esModule",{value:!0});var jl={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:_u.validateUnion,error:{message:"must match a schema in anyOf"}},zl=Object.defineProperty({default:jl},"__esModule",{value:!0});var Gl={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:t})=>du._`{passingSchemas: ${t.passing}}`},code(t){const{gen:e,schema:r,parentSchema:n,it:i}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(i.opts.discriminator&&n.discriminator)return;const o=r,s=e.let("valid",!1),a=e.let("passing",null),h=e.name("_valid");t.setParams({passing:a}),e.block((function(){o.forEach((r,n)=>{let o;mu.alwaysValidSchema(i,r)?e.var(h,!0):o=t.subschema({keyword:"oneOf",schemaProp:n,compositeRule:!0},h),n>0&&e.if(du._`${h} && ${s}`).assign(s,!1).assign(a,du._`[${a}, ${n}]`).else(),e.if(h,()=>{e.assign(s,!0),e.assign(a,n),o&&t.mergeEvaluated(o,du.Name)})})})),t.result(s,()=>t.reset(),()=>t.error(!0))}},ql=Object.defineProperty({default:Gl},"__esModule",{value:!0});var Vl={keyword:"allOf",schemaType:"array",code(t){const{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");const i=e.name("valid");r.forEach((e,r)=>{if(mu.alwaysValidSchema(n,e))return;const o=t.subschema({keyword:"allOf",schemaProp:r},i);t.ok(i),t.mergeEvaluated(o)})}},Kl=Object.defineProperty({default:Vl},"__esModule",{value:!0});function Wl(t,e){const r=t.schema[e];return void 0!==r&&!mu.alwaysValidSchema(t,r)}var Hl={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:t})=>du.str`must match "${t.ifClause}" schema`,params:({params:t})=>du._`{failingKeyword: ${t.ifClause}}`},code(t){const{gen:e,parentSchema:r,it:n}=t;void 0===r.then&&void 0===r.else&&mu.checkStrictMode(n,'"if" without "then" and "else" is ignored');const i=Wl(n,"then"),o=Wl(n,"else");if(!i&&!o)return;const s=e.let("valid",!0),a=e.name("_valid");if(function(){const e=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(e)}(),t.reset(),i&&o){const r=e.let("ifClause");t.setParams({ifClause:r}),e.if(a,h("then",r),h("else",r))}else i?e.if(a,h("then")):e.if(du.not(a),h("else"));function h(r,n){return()=>{const i=t.subschema({keyword:r},a);e.assign(s,a),t.mergeValidEvaluated(i,s),n?e.assign(n,du._`${r}`):t.setParams({ifClause:r})}}t.pass(s,()=>t.error(!0))}},Zl=Object.defineProperty({default:Hl},"__esModule",{value:!0});var Xl={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){void 0===e.if&&mu.checkStrictMode(r,`"${t}" without "if" is ignored`)}},Jl=Object.defineProperty({default:Xl},"__esModule",{value:!0});var Yl=function(t=!1){const e=[Bl.default,zl.default,ql.default,Kl.default,Zl.default,Jl.default,xl.default,Tl.default,Il.default,Cl.default,Ll.default];return t?e.push(Al.default,Sl.default):e.push(El.default,Ml.default),e.push(Ul.default),e},Ql=Object.defineProperty({default:Yl},"__esModule",{value:!0});var tf={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>du.str`must match format "${t}"`,params:({schemaCode:t})=>du._`{format: ${t}}`},code(t,e){const{gen:r,data:n,$data:i,schema:o,schemaCode:s,it:a}=t,{opts:h,errSchemaPath:u,schemaEnv:l,self:f}=a;h.validateFormats&&(i?function(){const i=r.scopeValue("formats",{ref:f.formats,code:h.code.formats}),o=r.const("fDef",du._`${i}[${s}]`),a=r.let("fType"),u=r.let("format");r.if(du._`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(a,du._`${o}.type || "string"`).assign(u,du._`${o}.validate`),()=>r.assign(a,du._`"string"`).assign(u,o)),t.fail$data(du.or(!1===h.strictSchema?du.nil:du._`${s} && !${u}`,function(){const t=l.$async?du._`(${o}.async ? await ${u}(${n}) : ${u}(${n}))`:du._`${u}(${n})`,r=du._`(typeof ${u} == "function" ? ${t} : ${u}.test(${n}))`;return du._`${u} && ${u} !== true && ${a} === ${e} && !${r}`}()))}():function(){const i=f.formats[o];if(!i)return void function(){if(!1===h.strictSchema)return void f.logger.warn(t());throw new Error(t());function t(){return`unknown format "${o}" ignored in schema at path "${u}"`}}();if(!0===i)return;const[s,a,c]=function(t){const e=t instanceof RegExp?du.regexpCode(t):h.code.formats?du._`${h.code.formats}${du.getProperty(o)}`:void 0,n=r.scopeValue("formats",{key:o,ref:t,code:e});if("object"==typeof t&&!(t instanceof RegExp))return[t.type||"string",t.validate,du._`${n}.validate`];return["string",t,n]}(i);s===e&&t.pass(function(){if("object"==typeof i&&!(i instanceof RegExp)&&i.async){if(!l.$async)throw new Error("async format in sync schema");return du._`await ${c}(${n})`}return"function"==typeof a?du._`${c}(${n})`:du._`${c}.test(${n})`}())}())}};var ef=[Object.defineProperty({default:tf},"__esModule",{value:!0}).default],rf=Object.defineProperty({default:ef},"__esModule",{value:!0}),nf=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],e.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]}));var of=[qu.default,bl.default,Ql.default(),rf.default,nf.metadataVocabulary,nf.contentVocabulary],sf=Object.defineProperty({default:of},"__esModule",{value:!0}),af=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.DiscrError=void 0,function(t){t.Tag="tag",t.Mapping="mapping"}(e.DiscrError||(e.DiscrError={}))}));var hf={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:t,tagName:e}})=>t===af.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>du._`{error: ${t}, tag: ${r}, tagValue: ${e}}`},code(t){const{gen:e,data:r,schema:n,parentSchema:i,it:o}=t,{oneOf:s}=i;if(!o.opts.discriminator)throw new Error("discriminator: requires discriminator option");const a=n.propertyName;if("string"!=typeof a)throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");const h=e.let("valid",!1),u=e.const("tag",du._`${r}${du.getProperty(a)}`);function l(r){const n=e.name("valid"),i=t.subschema({keyword:"oneOf",schemaProp:r},n);return t.mergeEvaluated(i,du.Name),n}e.if(du._`typeof ${u} == "string"`,()=>function(){const r=function(){var t;const e={},r=o(i);let n=!0;for(let e=0;e<s.length;e++){const i=s[e],u=null===(t=i.properties)||void 0===t?void 0:t[a];if("object"!=typeof u)throw new Error(`discriminator: oneOf schemas must have "properties/${a}"`);n=n&&(r||o(i)),h(u,e)}if(!n)throw new Error(`discriminator: "${a}" must be required`);return e;function o({required:t}){return Array.isArray(t)&&t.includes(a)}function h(t,e){if(t.const)u(t.const,e);else{if(!t.enum)throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`);for(const r of t.enum)u(r,e)}}function u(t,r){if("string"!=typeof t||t in e)throw new Error(`discriminator: "${a}" values must be unique strings`);e[t]=r}}();e.if(!1);for(const t in r)e.elseIf(du._`${u} === ${t}`),e.assign(h,l(r[t]));e.else(),t.error(!1,{discrError:af.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}(),()=>t.error(!1,{discrError:af.DiscrError.Tag,tag:u,tagName:a})),t.ok(h)}},uf=Object.defineProperty({default:hf},"__esModule",{value:!0}),lf={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0},ff=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;const r=["/properties"],n="http://json-schema.org/draft-07/schema";class i extends $u.default{_addVocabularies(){super._addVocabularies(),sf.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(uf.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const t=this.opts.$data?this.$dataMetaSchema(lf,r):lf;this.addMetaSchema(t,n,!1),this.refs["http://json-schema.org/schema"]=n}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(n)?n:void 0)}}t.exports=e=i,Object.defineProperty(e,"__esModule",{value:!0}),e.default=i,Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return Pu.KeywordCxt}}),Object.defineProperty(e,"_",{enumerable:!0,get:function(){return du._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return du.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return du.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return du.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return du.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return du.CodeGen}})})),cf=s(ff),df=h((function(t,e){function r(t,e){return{validate:t,compare:e}}Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0,e.fullFormats={date:r(o,s),time:r(h,u),"date-time":r((function(t){const e=t.split(l);return 2===e.length&&o(e[0])&&h(e[1],!0)}),f),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:function(t){return c.test(t)&&d.test(t)},"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:function(t){if(p.test(t))return!1;try{return new RegExp(t),!0}catch(t){return!1}},uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm,int32:{type:"number",validate:function(t){return Number.isInteger(t)&&t<=2147483647&&t>=-2147483648}},int64:{type:"number",validate:function(t){return Number.isInteger(t)}},float:{type:"number",validate:m},double:{type:"number",validate:m},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:r(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,s),time:r(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"date-time":r(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,f),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);const n=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31];function o(t){const e=n.exec(t);if(!e)return!1;const r=+e[1],o=+e[2],s=+e[3];return o>=1&&o<=12&&s>=1&&s<=(2===o&&function(t){return t%4==0&&(t%100!=0||t%400==0)}(r)?29:i[o])}function s(t,e){if(t&&e)return t>e?1:t<e?-1:0}const a=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;function h(t,e){const r=a.exec(t);if(!r)return!1;const n=+r[1],i=+r[2],o=+r[3],s=r[5];return(n<=23&&i<=59&&o<=59||23===n&&59===i&&60===o)&&(!e||""!==s)}function u(t,e){if(!t||!e)return;const r=a.exec(t),n=a.exec(e);return r&&n?(t=r[1]+r[2]+r[3]+(r[4]||""))>(e=n[1]+n[2]+n[3]+(n[4]||""))?1:t<e?-1:0:void 0}const l=/t|\s/i;function f(t,e){if(!t||!e)return;const[r,n]=t.split(l),[i,o]=e.split(l),a=s(r,i);return void 0!==a?a||u(n,o):void 0}const c=/\/|:/,d=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;function m(){return!0}const p=/[^\\]\\Z/})),mf=h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const r=du.operators,n={formatMaximum:{okStr:"<=",ok:r.LTE,fail:r.GT},formatMinimum:{okStr:">=",ok:r.GTE,fail:r.LT},formatExclusiveMaximum:{okStr:"<",ok:r.LT,fail:r.GTE},formatExclusiveMinimum:{okStr:">",ok:r.GT,fail:r.LTE}},i={message:({keyword:t,schemaCode:e})=>du.str`should be ${n[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>du._`{comparison: ${n[t].okStr}, limit: ${e}}`};e.formatLimitDefinition={keyword:Object.keys(n),type:"string",schemaType:"string",$data:!0,error:i,code(t){const{gen:e,data:r,schemaCode:i,keyword:o,it:s}=t,{opts:a,self:h}=s;if(!a.validateFormats)return;const u=new ff.KeywordCxt(s,h.RULES.all.format.definition,"format");function l(t){return du._`${t}.compare(${r}, ${i}) ${n[o].fail} 0`}u.$data?function(){const r=e.scopeValue("formats",{ref:h.formats,code:a.code.formats}),n=e.const("fmt",du._`${r}[${u.schemaCode}]`);t.fail$data(du.or(du._`typeof ${n} != "object"`,du._`${n} instanceof RegExp`,du._`typeof ${n}.compare != "function"`,l(n)))}():function(){const r=u.schema,n=h.formats[r];if(!n||!0===n)return;if("object"!=typeof n||n instanceof RegExp||"function"!=typeof n.compare)throw new Error(`"${o}": format "${r}" does not define "compare" function`);const i=e.scopeValue("formats",{key:r,ref:n,code:a.code.formats?du._`${a.code.formats}${du.getProperty(r)}`:void 0});t.fail$data(l(i))}()},dependencies:["format"]};e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)})),pf=s(h((function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=new du.Name("fullFormats"),n=new du.Name("fastFormats"),i=(t,e={keywords:!0})=>{if(Array.isArray(e))return o(t,e,df.fullFormats,r),t;const[i,s]="fast"===e.mode?[df.fastFormats,n]:[df.fullFormats,r];return o(t,e.formats||df.formatNames,i,s),e.keywords&&mf.default(t),t};function o(t,e,r,n){var i,o;null!==(i=(o=t.opts.code).formats)&&void 0!==i||(o.formats=du._`require("ajv-formats/dist/formats").${n}`);for(const n of e)t.addFormat(n,r[n])}i.get=(t,e="full")=>{const r=("fast"===e?df.fastFormats:df.fullFormats)[t];if(!r)throw new Error(`Unknown format "${t}"`);return r},t.exports=e=i,Object.defineProperty(e,"__esModule",{value:!0}),e.default=i}))),gf="[object GeneratorFunction]",yf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,vf=/^\w*$/,wf=/^\./,bf=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ef=/\\(\\)?/g,Mf=/^\[object .+?Constructor\]$/,_f=/^(?:0|[1-9]\d*)$/,Af="object"==typeof o&&o&&o.Object===Object&&o,Nf="object"==typeof self&&self&&self.Object===Object&&self,Sf=Af||Nf||Function("return this")();var Rf,Uf=Array.prototype,If=Function.prototype,Pf=Object.prototype,xf=Sf["__core-js_shared__"],kf=(Rf=/[^.]+$/.exec(xf&&xf.keys&&xf.keys.IE_PROTO||""))?"Symbol(src)_1."+Rf:"",Tf=If.toString,Of=Pf.hasOwnProperty,Cf=Pf.toString,Ff=RegExp("^"+Tf.call(Of).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Df=Sf.Symbol,Lf=Uf.splice,$f=Jf(Sf,"Map"),Bf=Jf(Object,"create"),jf=Df?Df.prototype:void 0,zf=jf?jf.toString:void 0;function Gf(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function qf(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Vf(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Kf(t,e,r){var n=t[e];Of.call(t,e)&&rc(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function Wf(t,e){for(var r=t.length;r--;)if(rc(t[r][0],e))return r;return-1}function Hf(t){return!(!ic(t)||(e=t,kf&&kf in e))&&(function(t){var e=ic(t)?Cf.call(t):"";return"[object Function]"==e||e==gf}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?Ff:Mf).test(function(t){if(null!=t){try{return Tf.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function Zf(t,e,r,n){if(!ic(t))return t;for(var i=-1,o=(e=function(t,e){if(nc(t))return!1;var r=typeof t;if("number"==r||"symbol"==r||"boolean"==r||null==t||oc(t))return!0;return vf.test(t)||!yf.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:function(t){return nc(t)?t:Qf(t)}(e)).length,s=o-1,a=t;null!=a&&++i<o;){var h=tc(e[i]),u=r;if(i!=s){var l=a[h];void 0===(u=n?n(l,h,a):void 0)&&(u=ic(l)?l:Yf(e[i+1])?[]:{})}Kf(a,h,u),a=a[h]}return t}function Xf(t,e){var r=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?r["string"==typeof e?"string":"hash"]:r.map}function Jf(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Hf(r)?r:void 0}function Yf(t,e){return!!(e=null==e?9007199254740991:e)&&("number"==typeof t||_f.test(t))&&t>-1&&t%1==0&&t<e}Gf.prototype.clear=function(){this.__data__=Bf?Bf(null):{}},Gf.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Gf.prototype.get=function(t){var e=this.__data__;if(Bf){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return Of.call(e,t)?e[t]:void 0},Gf.prototype.has=function(t){var e=this.__data__;return Bf?void 0!==e[t]:Of.call(e,t)},Gf.prototype.set=function(t,e){return this.__data__[t]=Bf&&void 0===e?"__lodash_hash_undefined__":e,this},qf.prototype.clear=function(){this.__data__=[]},qf.prototype.delete=function(t){var e=this.__data__,r=Wf(e,t);return!(r<0)&&(r==e.length-1?e.pop():Lf.call(e,r,1),!0)},qf.prototype.get=function(t){var e=this.__data__,r=Wf(e,t);return r<0?void 0:e[r][1]},qf.prototype.has=function(t){return Wf(this.__data__,t)>-1},qf.prototype.set=function(t,e){var r=this.__data__,n=Wf(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},Vf.prototype.clear=function(){this.__data__={hash:new Gf,map:new($f||qf),string:new Gf}},Vf.prototype.delete=function(t){return Xf(this,t).delete(t)},Vf.prototype.get=function(t){return Xf(this,t).get(t)},Vf.prototype.has=function(t){return Xf(this,t).has(t)},Vf.prototype.set=function(t,e){return Xf(this,t).set(t,e),this};var Qf=ec((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(oc(t))return zf?zf.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var r=[];return wf.test(t)&&r.push(""),t.replace(bf,(function(t,e,n,i){r.push(n?i.replace(Ef,"$1"):e||t)})),r}));function tc(t){if("string"==typeof t||oc(t))return t;var e=t+"";return"0"==e&&1/t==-Infinity?"-0":e}function ec(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var s=t.apply(this,n);return r.cache=o.set(i,s),s};return r.cache=new(ec.Cache||Vf),r}function rc(t,e){return t===e||t!=t&&e!=e}ec.Cache=Vf;var nc=Array.isArray;function ic(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function oc(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==Cf.call(t)}var sc=function(t,e,r){return null==t?t:Zf(t,e,r)},ac=function(){function t(t,e,r,n){this.options={},this.calls=[],this.paths=[],this.network=t,this.provider=e,this.abi=r,this.options=n||{}}return t.prototype.call=function(t,e,r,n){return this.calls.push([e,r,n]),this.paths.push(t),this},t.prototype.execute=function(t){return e(this,void 0,void 0,(function(){var e,n=this;return r(this,(function(r){switch(r.label){case 0:return e=t||{},[4,xb(this.network,this.provider,this.abi,this.calls,this.options)];case 1:return r.sent().forEach((function(t,r){return sc(e,n.paths[r],t.length>1?t:t[0])})),this.calls=[],this.paths=[],[2,e]}}))}))},t}();let hc=!1,uc=!1;const lc={debug:1,default:2,info:2,warning:3,error:4,off:5};let fc=lc.default,cc=null;const dc=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),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 mc,pc;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(mc||(mc={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(pc||(pc={}));class gc{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==lc[r]&&this.throwArgumentError("invalid log level name","logLevel",t),fc>lc[r]||console.log.apply(console,e)}debug(...t){this._log(gc.levels.DEBUG,t)}info(...t){this._log(gc.levels.INFO,t)}warn(...t){this._log(gc.levels.WARNING,t)}makeError(t,e,r){if(uc)return this.makeError("censored error",e,{});e||(e=gc.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;n.length&&(t+=" ("+n.join(", ")+")");const o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,gc.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){dc&&this.throwError("platform missing String.prototype.normalize",gc.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:dc})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,gc.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,gc.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,gc.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,gc.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",gc.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",gc.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",gc.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return cc||(cc=new gc("logger/5.3.0")),cc}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",gc.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),hc){if(!t)return;this.globalLogger().throwError("error censorship permanent",gc.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}uc=!!t,hc=!!e}static setLogLevel(t){const e=lc[t.toLowerCase()];null!=e?fc=e:gc.globalLogger().warn("invalid log level - "+t)}static from(t){return new gc(t)}}gc.errors=pc,gc.levels=mc;const yc=new gc("networks/5.3.1");function vc(t){const e=function(e,r){null==r&&(r={});const n=[];if(e.InfuraProvider)try{n.push(new e.InfuraProvider(t,r.infura))}catch(t){}if(e.EtherscanProvider)try{n.push(new e.EtherscanProvider(t,r.etherscan))}catch(t){}if(e.AlchemyProvider)try{n.push(new e.AlchemyProvider(t,r.alchemy))}catch(t){}if(e.CloudflareProvider)try{n.push(new e.CloudflareProvider(t))}catch(t){}if(0===n.length)return null;if(e.FallbackProvider){let i=1;return null!=r.quorum?i=r.quorum:"homestead"===t&&(i=2),new e.FallbackProvider(n,i)}return n[0]};return e.renetwork=function(t){return vc(t)},e}function wc(t,e){const r=function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(t,e):null};return r.renetwork=function(e){return wc(t,e)},r}const bc={chainId:1,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"homestead",_defaultProvider:vc("homestead")},Ec={chainId:3,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"ropsten",_defaultProvider:vc("ropsten")},Mc={chainId:63,name:"classicMordor",_defaultProvider:wc("https://www.ethercluster.com/mordor","classicMordor")},_c={unspecified:{chainId:0,name:"unspecified"},homestead:bc,mainnet:bc,morden:{chainId:2,name:"morden"},ropsten:Ec,testnet:Ec,rinkeby:{chainId:4,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"rinkeby",_defaultProvider:vc("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:vc("kovan")},goerli:{chainId:5,ensAddress:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",name:"goerli",_defaultProvider:vc("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:wc("https://www.ethercluster.com/etc","classic")},classicMorden:{chainId:62,name:"classicMorden"},classicMordor:Mc,classicTestnet:Mc,classicKotti:{chainId:6,name:"classicKotti",_defaultProvider:wc("https://www.ethercluster.com/kotti","classicKotti")},xdai:{chainId:100,name:"xdai"},matic:{chainId:137,name:"matic"},maticmum:{chainId:80001,name:"maticmum"},bnb:{chainId:56,name:"bnb"},bnbt:{chainId:97,name:"bnbt"}};let Ac=!1,Nc=!1;const Sc={debug:1,default:2,info:2,warning:3,error:4,off:5};let Rc=Sc.default,Uc=null;const Ic=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),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 Pc,xc;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(Pc||(Pc={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(xc||(xc={}));class kc{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==Sc[r]&&this.throwArgumentError("invalid log level name","logLevel",t),Rc>Sc[r]||console.log.apply(console,e)}debug(...t){this._log(kc.levels.DEBUG,t)}info(...t){this._log(kc.levels.INFO,t)}warn(...t){this._log(kc.levels.WARNING,t)}makeError(t,e,r){if(Nc)return this.makeError("censored error",e,{});e||(e=kc.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;n.length&&(t+=" ("+n.join(", ")+")");const o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,kc.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){Ic&&this.throwError("platform missing String.prototype.normalize",kc.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Ic})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,kc.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,kc.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,kc.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,kc.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",kc.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",kc.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",kc.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Uc||(Uc=new kc("logger/5.3.0")),Uc}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",kc.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Ac){if(!t)return;this.globalLogger().throwError("error censorship permanent",kc.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Nc=!!t,Ac=!!e}static setLogLevel(t){const e=Sc[t.toLowerCase()];null!=e?Rc=e:kc.globalLogger().warn("invalid log level - "+t)}static from(t){return new kc(t)}}kc.errors=xc,kc.levels=Pc;const Tc=new kc("bytes/5.3.0");function Oc(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Oc(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Cc(t,e){if(e||(e={}),"number"==typeof t){Tc.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),Oc(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){if("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))return!1;if(e&&t.length!==2+2*e)return!1;return!0}(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":Tc.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return Oc(new Uint8Array(n))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}(t)?Oc(new Uint8Array(t)):Tc.throwArgumentError("invalid arrayify value","value",t)}window&&window.__awaiter;new kc("properties/5.3.0");function Fc(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}class Dc{constructor(t){Fc(this,"alphabet",t),Fc(this,"base",t.length),Fc(this,"_alphabetMap",{}),Fc(this,"_leader",t.charAt(0));for(let e=0;e<t.length;e++)this._alphabetMap[t.charAt(e)]=e}encode(t){let e=Cc(t);if(0===e.length)return"";let r=[0];for(let t=0;t<e.length;++t){let n=e[t];for(let t=0;t<r.length;++t)n+=r[t]<<8,r[t]=n%this.base,n=n/this.base|0;for(;n>0;)r.push(n%this.base),n=n/this.base|0}let n="";for(let t=0;0===e[t]&&t<e.length-1;++t)n+=this._leader;for(let t=r.length-1;t>=0;--t)n+=this.alphabet[r[t]];return n}decode(t){if("string"!=typeof t)throw new TypeError("Expected String");let e=[];if(0===t.length)return new Uint8Array(e);e.push(0);for(let r=0;r<t.length;r++){let n=this._alphabetMap[t[r]];if(void 0===n)throw new Error("Non-base"+this.base+" character");let i=n;for(let t=0;t<e.length;++t)i+=e[t]*this.base,e[t]=255&i,i>>=8;for(;i>0;)e.push(255&i),i>>=8}for(let r=0;t[r]===this._leader&&r<t.length-1;++r)e.push(0);return Cc(new Uint8Array(e.reverse()))}}new Dc("abcdefghijklmnopqrstuvwxyz234567");const Lc=new Dc("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");let $c=!1,Bc=!1;const jc={debug:1,default:2,info:2,warning:3,error:4,off:5};let zc=jc.default,Gc=null;const qc=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),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 Vc,Kc;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(Vc||(Vc={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(Kc||(Kc={}));class Wc{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==jc[r]&&this.throwArgumentError("invalid log level name","logLevel",t),zc>jc[r]||console.log.apply(console,e)}debug(...t){this._log(Wc.levels.DEBUG,t)}info(...t){this._log(Wc.levels.INFO,t)}warn(...t){this._log(Wc.levels.WARNING,t)}makeError(t,e,r){if(Bc)return this.makeError("censored error",e,{});e||(e=Wc.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;n.length&&(t+=" ("+n.join(", ")+")");const o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Wc.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){qc&&this.throwError("platform missing String.prototype.normalize",Wc.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:qc})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Wc.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Wc.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,Wc.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Wc.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",Wc.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Wc.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",Wc.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Gc||(Gc=new Wc("logger/5.3.0")),Gc}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Wc.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),$c){if(!t)return;this.globalLogger().throwError("error censorship permanent",Wc.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Bc=!!t,$c=!!e}static setLogLevel(t){const e=jc[t.toLowerCase()];null!=e?zc=e:Wc.globalLogger().warn("invalid log level - "+t)}static from(t){return new Wc(t)}}Wc.errors=Kc,Wc.levels=Vc;const Hc=new Wc("bytes/5.3.0");function Zc(t){return!!t.toHexString}function Xc(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Xc(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Jc(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}function Yc(t,e){if(e||(e={}),"number"==typeof t){Hc.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),Xc(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Zc(t)&&(t=t.toHexString()),ed(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":Hc.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return Xc(new Uint8Array(n))}return Jc(t)?Xc(new Uint8Array(t)):Hc.throwArgumentError("invalid arrayify value","value",t)}function Qc(t){const e=t.map(t=>Yc(t)),r=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(r);return e.reduce((t,e)=>(n.set(e,t),t+e.length),0),Xc(n)}function td(t){let e=Yc(t);if(0===e.length)return e;let r=0;for(;r<e.length&&0===e[r];)r++;return r&&(e=e.slice(r)),e}function ed(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}function rd(t,e){if(e||(e={}),"number"==typeof t){Hc.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Zc(t))return t.toHexString();if(ed(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":Hc.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(Jc(t)){let e="0x";for(let r=0;r<t.length;r++){let n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return Hc.throwArgumentError("invalid hexlify value","value",t)}function nd(t){if("string"!=typeof t)t=rd(t);else if(!ed(t)||t.length%2)return null;return(t.length-2)/2}function id(t,e,r){return"string"!=typeof t?t=rd(t):(!ed(t)||t.length%2)&&Hc.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function od(t){let e="0x";return t.forEach(t=>{e+=rd(t).substring(2)}),e}function sd(t){const e=function(t){"string"!=typeof t&&(t=rd(t));ed(t)||Hc.throwArgumentError("invalid hex string","value",t);t=t.substring(2);let e=0;for(;e<t.length&&"0"===t[e];)e++;return"0x"+t.substring(e)}(rd(t,{hexPad:"left"}));return"0x"===e?"0x0":e}function ad(t,e){for("string"!=typeof t?t=rd(t):ed(t)||Hc.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&Hc.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function hd(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(ed(r=t)&&!(r.length%2)||Jc(r)){const r=Yc(t);65!==r.length&&Hc.throwArgumentError("invalid signature string; must be 65 bytes","signature",t),e.r=rd(r.slice(0,32)),e.s=rd(r.slice(32,64)),e.v=r[64],e.v<27&&(0===e.v||1===e.v?e.v+=27:Hc.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=rd(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e._vs){const r=function(t,e){(t=Yc(t)).length>e&&Hc.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),Xc(r)}(Yc(e._vs),32);e._vs=rd(r);const n=r[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=n:e.recoveryParam!==n&&Hc.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),r[0]&=127;const i=rd(r);null==e.s?e.s=i:e.s!==i&&Hc.throwArgumentError("signature v mismatch _vs","signature",t)}null==e.recoveryParam?null==e.v?Hc.throwArgumentError("signature missing v and recoveryParam","signature",t):0===e.v||1===e.v?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2:null==e.v?e.v=27+e.recoveryParam:e.recoveryParam!==1-e.v%2&&Hc.throwArgumentError("signature recoveryParam mismatch v","signature",t),null!=e.r&&ed(e.r)?e.r=ad(e.r,32):Hc.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&ed(e.s)?e.s=ad(e.s,32):Hc.throwArgumentError("signature missing or invalid s","signature",t);const r=Yc(e.s);r[0]>=128&&Hc.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const n=rd(r);e._vs&&(ed(e._vs)||Hc.throwArgumentError("signature invalid _vs","signature",t),e._vs=ad(e._vs,32)),null==e._vs?e._vs=n:e._vs!==n&&Hc.throwArgumentError("signature _vs mismatch v and s","signature",t)}var r;return e}var ud=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const ld=new Wc("properties/5.3.0");function fd(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function cd(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||"object"!=typeof t.prototype)break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function dd(t){return ud(this,void 0,void 0,(function*(){const e=Object.keys(t).map(e=>{const r=t[e];return Promise.resolve(r).then(t=>({key:e,value:t}))});return(yield Promise.all(e)).reduce((t,e)=>(t[e.key]=e.value,t),{})}))}function md(t){const e={};for(const r in t)e[r]=t[r];return e}const pd={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function gd(t){if(function t(e){if(null==e||pd[typeof e])return!0;if(Array.isArray(e)||"object"==typeof e){if(!Object.isFrozen(e))return!1;const r=Object.keys(e);for(let n=0;n<r.length;n++)if(!t(e[r[n]]))return!1;return!0}return ld.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}(t))return t;if(Array.isArray(t))return Object.freeze(t.map(t=>yd(t)));if("object"==typeof t){const e={};for(const r in t){const n=t[r];void 0!==n&&fd(e,r,yd(n))}return e}return ld.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function yd(t){return gd(t)}var vd=wd;function wd(t,e){if(!t)throw new Error(e||"Assertion failed")}function bd(t,e){return 55296==(64512&t.charCodeAt(e))&&(!(e<0||e+1>=t.length)&&56320==(64512&t.charCodeAt(e+1)))}function Ed(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function Md(t){return 1===t.length?"0"+t:t}function _d(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}wd.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var Ad={inherits:h((function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}})),toArray:function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i<t.length;i+=2)r.push(parseInt(t[i]+t[i+1],16))}else for(var n=0,i=0;i<t.length;i++){var o=t.charCodeAt(i);o<128?r[n++]=o:o<2048?(r[n++]=o>>6|192,r[n++]=63&o|128):bd(t,i)?(o=65536+((1023&o)<<10)+(1023&t.charCodeAt(++i)),r[n++]=o>>18|240,r[n++]=o>>12&63|128,r[n++]=o>>6&63|128,r[n++]=63&o|128):(r[n++]=o>>12|224,r[n++]=o>>6&63|128,r[n++]=63&o|128)}else for(i=0;i<t.length;i++)r[i]=0|t[i];return r},toHex:function(t){for(var e="",r=0;r<t.length;r++)e+=Md(t[r].toString(16));return e},htonl:Ed,toHex32:function(t,e){for(var r="",n=0;n<t.length;n++){var i=t[n];"little"===e&&(i=Ed(i)),r+=_d(i.toString(16))}return r},zero2:Md,zero8:_d,join32:function(t,e,r,n){var i=r-e;vd(i%4==0);for(var o=new Array(i/4),s=0,a=e;s<o.length;s++,a+=4){var h;h="big"===n?t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3]:t[a+3]<<24|t[a+2]<<16|t[a+1]<<8|t[a],o[s]=h>>>0}return o},split32:function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n<t.length;n++,i+=4){var o=t[n];"big"===e?(r[i]=o>>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},rotr32:function(t,e){return t>>>e|t<<32-e},rotl32:function(t,e){return t<<e|t>>>32-e},sum32:function(t,e){return t+e>>>0},sum32_3:function(t,e,r){return t+e+r>>>0},sum32_4:function(t,e,r,n){return t+e+r+n>>>0},sum32_5:function(t,e,r,n,i){return t+e+r+n+i>>>0},sum64:function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o<n?1:0)+r+i;t[e]=s>>>0,t[e+1]=o},sum64_hi:function(t,e,r,n){return(e+n>>>0<e?1:0)+t+r>>>0},sum64_lo:function(t,e,r,n){return e+n>>>0},sum64_4_hi:function(t,e,r,n,i,o,s,a){var h=0,u=e;return h+=(u=u+n>>>0)<e?1:0,h+=(u=u+o>>>0)<o?1:0,t+r+i+s+(h+=(u=u+a>>>0)<a?1:0)>>>0},sum64_4_lo:function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},sum64_5_hi:function(t,e,r,n,i,o,s,a,h,u){var l=0,f=e;return l+=(f=f+n>>>0)<e?1:0,l+=(f=f+o>>>0)<o?1:0,l+=(f=f+a>>>0)<a?1:0,t+r+i+s+h+(l+=(f=f+u>>>0)<u?1:0)>>>0},sum64_5_lo:function(t,e,r,n,i,o,s,a,h,u){return e+n+o+a+u>>>0},rotr64_hi:function(t,e,r){return(e<<32-r|t>>>r)>>>0},rotr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0},shr64_hi:function(t,e,r){return t>>>r},shr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0}};function Nd(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var Sd=Nd;Nd.prototype.update=function(t,e){if(t=Ad.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=Ad.join32(t,0,t.length-r,this.endian);for(var n=0;n<t.length;n+=this._delta32)this._update(t,n,n+this._delta32)}return this},Nd.prototype.digest=function(t){return this.update(this._pad()),vd(null===this.pending),this._digest(t)},Nd.prototype._pad=function(){var t=this.pendingTotal,e=this._delta8,r=e-(t+this.padLength)%e,n=new Array(r+this.padLength);n[0]=128;for(var i=1;i<r;i++)n[i]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)n[i++]=0;n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=t>>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o<this.padLength;o++)n[i++]=0;return n};var Rd={BlockHash:Sd},Ud=Ad.rotr32;function Id(t,e,r){return t&e^~t&r}function Pd(t,e,r){return t&e^t&r^e&r}function xd(t,e,r){return t^e^r}var kd={ft_1:function(t,e,r,n){return 0===t?Id(e,r,n):1===t||3===t?xd(e,r,n):2===t?Pd(e,r,n):void 0},ch32:Id,maj32:Pd,p32:xd,s0_256:function(t){return Ud(t,2)^Ud(t,13)^Ud(t,22)},s1_256:function(t){return Ud(t,6)^Ud(t,11)^Ud(t,25)},g0_256:function(t){return Ud(t,7)^Ud(t,18)^t>>>3},g1_256:function(t){return Ud(t,17)^Ud(t,19)^t>>>10}},Td=Ad.rotl32,Od=Ad.sum32,Cd=Ad.sum32_5,Fd=kd.ft_1,Dd=Rd.BlockHash,Ld=[1518500249,1859775393,2400959708,3395469782];function $d(){if(!(this instanceof $d))return new $d;Dd.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}Ad.inherits($d,Dd);var Bd=$d;$d.blockSize=512,$d.outSize=160,$d.hmacStrength=80,$d.padLength=64,$d.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n<r.length;n++)r[n]=Td(r[n-3]^r[n-8]^r[n-14]^r[n-16],1);var i=this.h[0],o=this.h[1],s=this.h[2],a=this.h[3],h=this.h[4];for(n=0;n<r.length;n++){var u=~~(n/20),l=Cd(Td(i,5),Fd(u,o,s,a),h,r[n],Ld[u]);h=a,a=s,s=Td(o,30),o=i,i=l}this.h[0]=Od(this.h[0],i),this.h[1]=Od(this.h[1],o),this.h[2]=Od(this.h[2],s),this.h[3]=Od(this.h[3],a),this.h[4]=Od(this.h[4],h)},$d.prototype._digest=function(t){return"hex"===t?Ad.toHex32(this.h,"big"):Ad.split32(this.h,"big")};var jd=Ad.sum32,zd=Ad.sum32_4,Gd=Ad.sum32_5,qd=kd.ch32,Vd=kd.maj32,Kd=kd.s0_256,Wd=kd.s1_256,Hd=kd.g0_256,Zd=kd.g1_256,Xd=Rd.BlockHash,Jd=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Yd(){if(!(this instanceof Yd))return new Yd;Xd.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Jd,this.W=new Array(64)}Ad.inherits(Yd,Xd);var Qd=Yd;function tm(){if(!(this instanceof tm))return new tm;Qd.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Yd.blockSize=512,Yd.outSize=256,Yd.hmacStrength=192,Yd.padLength=64,Yd.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;n<r.length;n++)r[n]=zd(Zd(r[n-2]),r[n-7],Hd(r[n-15]),r[n-16]);var i=this.h[0],o=this.h[1],s=this.h[2],a=this.h[3],h=this.h[4],u=this.h[5],l=this.h[6],f=this.h[7];for(vd(this.k.length===r.length),n=0;n<r.length;n++){var c=Gd(f,Wd(h),qd(h,u,l),this.k[n],r[n]),d=jd(Kd(i),Vd(i,o,s));f=l,l=u,u=h,h=jd(a,c),a=s,s=o,o=i,i=jd(c,d)}this.h[0]=jd(this.h[0],i),this.h[1]=jd(this.h[1],o),this.h[2]=jd(this.h[2],s),this.h[3]=jd(this.h[3],a),this.h[4]=jd(this.h[4],h),this.h[5]=jd(this.h[5],u),this.h[6]=jd(this.h[6],l),this.h[7]=jd(this.h[7],f)},Yd.prototype._digest=function(t){return"hex"===t?Ad.toHex32(this.h,"big"):Ad.split32(this.h,"big")},Ad.inherits(tm,Qd);var em=tm;tm.blockSize=512,tm.outSize=224,tm.hmacStrength=192,tm.padLength=64,tm.prototype._digest=function(t){return"hex"===t?Ad.toHex32(this.h.slice(0,7),"big"):Ad.split32(this.h.slice(0,7),"big")};var rm=Ad.rotr64_hi,nm=Ad.rotr64_lo,im=Ad.shr64_hi,om=Ad.shr64_lo,sm=Ad.sum64,am=Ad.sum64_hi,hm=Ad.sum64_lo,um=Ad.sum64_4_hi,lm=Ad.sum64_4_lo,fm=Ad.sum64_5_hi,cm=Ad.sum64_5_lo,dm=Rd.BlockHash,mm=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function pm(){if(!(this instanceof pm))return new pm;dm.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=mm,this.W=new Array(160)}Ad.inherits(pm,dm);var gm=pm;function ym(t,e,r,n,i){var o=t&r^~t&i;return o<0&&(o+=4294967296),o}function vm(t,e,r,n,i,o){var s=e&n^~e&o;return s<0&&(s+=4294967296),s}function wm(t,e,r,n,i){var o=t&r^t&i^r&i;return o<0&&(o+=4294967296),o}function bm(t,e,r,n,i,o){var s=e&n^e&o^n&o;return s<0&&(s+=4294967296),s}function Em(t,e){var r=rm(t,e,28)^rm(e,t,2)^rm(e,t,7);return r<0&&(r+=4294967296),r}function Mm(t,e){var r=nm(t,e,28)^nm(e,t,2)^nm(e,t,7);return r<0&&(r+=4294967296),r}function _m(t,e){var r=rm(t,e,14)^rm(t,e,18)^rm(e,t,9);return r<0&&(r+=4294967296),r}function Am(t,e){var r=nm(t,e,14)^nm(t,e,18)^nm(e,t,9);return r<0&&(r+=4294967296),r}function Nm(t,e){var r=rm(t,e,1)^rm(t,e,8)^im(t,e,7);return r<0&&(r+=4294967296),r}function Sm(t,e){var r=nm(t,e,1)^nm(t,e,8)^om(t,e,7);return r<0&&(r+=4294967296),r}function Rm(t,e){var r=rm(t,e,19)^rm(e,t,29)^im(t,e,6);return r<0&&(r+=4294967296),r}function Um(t,e){var r=nm(t,e,19)^nm(e,t,29)^om(t,e,6);return r<0&&(r+=4294967296),r}function Im(){if(!(this instanceof Im))return new Im;gm.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}pm.blockSize=1024,pm.outSize=512,pm.hmacStrength=192,pm.padLength=128,pm.prototype._prepareBlock=function(t,e){for(var r=this.W,n=0;n<32;n++)r[n]=t[e+n];for(;n<r.length;n+=2){var i=Rm(r[n-4],r[n-3]),o=Um(r[n-4],r[n-3]),s=r[n-14],a=r[n-13],h=Nm(r[n-30],r[n-29]),u=Sm(r[n-30],r[n-29]),l=r[n-32],f=r[n-31];r[n]=um(i,o,s,a,h,u,l,f),r[n+1]=lm(i,o,s,a,h,u,l,f)}},pm.prototype._update=function(t,e){this._prepareBlock(t,e);var r=this.W,n=this.h[0],i=this.h[1],o=this.h[2],s=this.h[3],a=this.h[4],h=this.h[5],u=this.h[6],l=this.h[7],f=this.h[8],c=this.h[9],d=this.h[10],m=this.h[11],p=this.h[12],g=this.h[13],y=this.h[14],v=this.h[15];vd(this.k.length===r.length);for(var w=0;w<r.length;w+=2){var b=y,E=v,M=_m(f,c),_=Am(f,c),A=ym(f,c,d,m,p),N=vm(f,c,d,m,p,g),S=this.k[w],R=this.k[w+1],U=r[w],I=r[w+1],P=fm(b,E,M,_,A,N,S,R,U,I),x=cm(b,E,M,_,A,N,S,R,U,I);b=Em(n,i),E=Mm(n,i),M=wm(n,i,o,s,a),_=bm(n,i,o,s,a,h);var k=am(b,E,M,_),T=hm(b,E,M,_);y=p,v=g,p=d,g=m,d=f,m=c,f=am(u,l,P,x),c=hm(l,l,P,x),u=a,l=h,a=o,h=s,o=n,s=i,n=am(P,x,k,T),i=hm(P,x,k,T)}sm(this.h,0,n,i),sm(this.h,2,o,s),sm(this.h,4,a,h),sm(this.h,6,u,l),sm(this.h,8,f,c),sm(this.h,10,d,m),sm(this.h,12,p,g),sm(this.h,14,y,v)},pm.prototype._digest=function(t){return"hex"===t?Ad.toHex32(this.h,"big"):Ad.split32(this.h,"big")},Ad.inherits(Im,gm);var Pm=Im;Im.blockSize=1024,Im.outSize=384,Im.hmacStrength=192,Im.padLength=128,Im.prototype._digest=function(t){return"hex"===t?Ad.toHex32(this.h.slice(0,12),"big"):Ad.split32(this.h.slice(0,12),"big")};var xm={sha1:Bd,sha224:em,sha256:Qd,sha384:Pm,sha512:gm},km=Ad.rotl32,Tm=Ad.sum32,Om=Ad.sum32_3,Cm=Ad.sum32_4,Fm=Rd.BlockHash;function Dm(){if(!(this instanceof Dm))return new Dm;Fm.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Ad.inherits(Dm,Fm);var Lm=Dm;function $m(t,e,r,n){return t<=15?e^r^n:t<=31?e&r|~e&n:t<=47?(e|~r)^n:t<=63?e&n|r&~n:e^(r|~n)}function Bm(t){return t<=15?0:t<=31?1518500249:t<=47?1859775393:t<=63?2400959708:2840853838}function jm(t){return t<=15?1352829926:t<=31?1548603684:t<=47?1836072691:t<=63?2053994217:0}Dm.blockSize=512,Dm.outSize=160,Dm.hmacStrength=192,Dm.padLength=64,Dm.prototype._update=function(t,e){for(var r=this.h[0],n=this.h[1],i=this.h[2],o=this.h[3],s=this.h[4],a=r,h=n,u=i,l=o,f=s,c=0;c<80;c++){var d=Tm(km(Cm(r,$m(c,n,i,o),t[zm[c]+e],Bm(c)),qm[c]),s);r=s,s=o,o=km(i,10),i=n,n=d,d=Tm(km(Cm(a,$m(79-c,h,u,l),t[Gm[c]+e],jm(c)),Vm[c]),f),a=f,f=l,l=km(u,10),u=h,h=d}d=Om(this.h[1],i,l),this.h[1]=Om(this.h[2],o,f),this.h[2]=Om(this.h[3],s,a),this.h[3]=Om(this.h[4],r,h),this.h[4]=Om(this.h[0],n,u),this.h[0]=d},Dm.prototype._digest=function(t){return"hex"===t?Ad.toHex32(this.h,"little"):Ad.split32(this.h,"little")};var zm=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],Gm=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],qm=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],Vm=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],Km={ripemd160:Lm};function Wm(t,e,r){if(!(this instanceof Wm))return new Wm(t,e,r);this.Hash=t,this.blockSize=t.blockSize/8,this.outSize=t.outSize/8,this.inner=null,this.outer=null,this._init(Ad.toArray(e,r))}var Hm=Wm;Wm.prototype._init=function(t){t.length>this.blockSize&&(t=(new this.Hash).update(t).digest()),vd(t.length<=this.blockSize);for(var e=t.length;e<this.blockSize;e++)t.push(0);for(e=0;e<t.length;e++)t[e]^=54;for(this.inner=(new this.Hash).update(t),e=0;e<t.length;e++)t[e]^=106;this.outer=(new this.Hash).update(t)},Wm.prototype.update=function(t,e){return this.inner.update(t,e),this},Wm.prototype.digest=function(t){return this.outer.update(this.inner.digest()),this.outer.digest(t)};var Zm=h((function(t,e){var r=e;r.utils=Ad,r.common=Rd,r.sha=xm,r.ripemd=Km,r.hmac=Hm,r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160}));new Wc("sha2/5.3.0");function Xm(t){return"0x"+Zm.sha256().update(Yc(t)).digest("hex")}const Jm=new Wc("strings/5.3.0");var Ym,Qm;function tp(t,e,r,n,i){if(t===Qm.BAD_PREFIX||t===Qm.UNEXPECTED_CONTINUE){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return t===Qm.OVERRUN?r.length-e-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(Ym||(Ym={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(Qm||(Qm={}));const ep=Object.freeze({error:function(t,e,r,n,i){return Jm.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:tp,replace:function(t,e,r,n,i){return t===Qm.OVERLONG?(n.push(i),0):(n.push(65533),tp(t,e,r))}});function rp(t,e=Ym.current){e!=Ym.current&&(Jm.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;const i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");const o=65536+((1023&n)<<10)+(1023&i);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return Yc(r)}function np(t,e){return function(t,e){null==e&&(e=ep.error),t=Yc(t);const r=[];let n=0;for(;n<t.length;){const i=t[n++];if(i>>7==0){r.push(i);continue}let o=null,s=null;if(192==(224&i))o=1,s=127;else if(224==(240&i))o=2,s=2047;else{if(240!=(248&i)){n+=e(128==(192&i)?Qm.UNEXPECTED_CONTINUE:Qm.BAD_PREFIX,n-1,t,r);continue}o=3,s=65535}if(n-1+o>=t.length){n+=e(Qm.OVERRUN,n-1,t,r);continue}let a=i&(1<<8-o-1)-1;for(let i=0;i<o;i++){let i=t[n];if(128!=(192&i)){n+=e(Qm.MISSING_CONTINUE,n,t,r),a=null;break}a=a<<6|63&i,n++}null!==a&&(a>1114111?n+=e(Qm.OUT_OF_RANGE,n-1-o,t,r,a):a>=55296&&a<=57343?n+=e(Qm.UTF16_SURROGATE,n-1-o,t,r,a):a<=s?n+=e(Qm.OVERLONG,n-1-o,t,r,a):r.push(a))}return r}(t,e).map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t)))).join("")}let ip=!1,op=!1;const sp={debug:1,default:2,info:2,warning:3,error:4,off:5};let ap=sp.default,hp=null;const up=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),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 lp,fp;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(lp||(lp={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(fp||(fp={}));class cp{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==sp[r]&&this.throwArgumentError("invalid log level name","logLevel",t),ap>sp[r]||console.log.apply(console,e)}debug(...t){this._log(cp.levels.DEBUG,t)}info(...t){this._log(cp.levels.INFO,t)}warn(...t){this._log(cp.levels.WARNING,t)}makeError(t,e,r){if(op)return this.makeError("censored error",e,{});e||(e=cp.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;n.length&&(t+=" ("+n.join(", ")+")");const o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,cp.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){up&&this.throwError("platform missing String.prototype.normalize",cp.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:up})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,cp.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,cp.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,cp.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,cp.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",cp.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",cp.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",cp.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return hp||(hp=new cp("logger/5.3.0")),hp}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",cp.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),ip){if(!t)return;this.globalLogger().throwError("error censorship permanent",cp.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}op=!!t,ip=!!e}static setLogLevel(t){const e=sp[t.toLowerCase()];null!=e?ap=e:cp.globalLogger().warn("invalid log level - "+t)}static from(t){return new cp(t)}}cp.errors=fp,cp.levels=lp;const dp=new cp("bytes/5.3.0");function mp(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return mp(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function pp(t,e){if(e||(e={}),"number"==typeof t){dp.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),mp(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){if("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))return!1;if(e&&t.length!==2+2*e)return!1;return!0}(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":dp.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return mp(new Uint8Array(n))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}(t)?mp(new Uint8Array(t)):dp.throwArgumentError("invalid arrayify value","value",t)}function gp(t){t=pp(t);let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}let yp=!1,vp=!1;const wp={debug:1,default:2,info:2,warning:3,error:4,off:5};let bp=wp.default,Ep=null;const Mp=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),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 _p,Ap;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(_p||(_p={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(Ap||(Ap={}));class Np{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==wp[r]&&this.throwArgumentError("invalid log level name","logLevel",t),bp>wp[r]||console.log.apply(console,e)}debug(...t){this._log(Np.levels.DEBUG,t)}info(...t){this._log(Np.levels.INFO,t)}warn(...t){this._log(Np.levels.WARNING,t)}makeError(t,e,r){if(vp)return this.makeError("censored error",e,{});e||(e=Np.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;n.length&&(t+=" ("+n.join(", ")+")");const o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Np.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){Mp&&this.throwError("platform missing String.prototype.normalize",Np.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Mp})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Np.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Np.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,Np.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Np.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",Np.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Np.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",Np.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Ep||(Ep=new Np("logger/5.3.0")),Ep}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Np.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),yp){if(!t)return;this.globalLogger().throwError("error censorship permanent",Np.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}vp=!!t,yp=!!e}static setLogLevel(t){const e=wp[t.toLowerCase()];null!=e?bp=e:Np.globalLogger().warn("invalid log level - "+t)}static from(t){return new Np(t)}}Np.errors=Ap,Np.levels=_p;const Sp=new Np("bytes/5.3.0");function Rp(t){return!!t.toHexString}function Up(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Up(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Ip(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}function Pp(t,e){if(e||(e={}),"number"==typeof t){Sp.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),Up(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Rp(t)&&(t=t.toHexString()),xp(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":Sp.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return Up(new Uint8Array(n))}return Ip(t)?Up(new Uint8Array(t)):Sp.throwArgumentError("invalid arrayify value","value",t)}function xp(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}window&&window.__awaiter;new Np("properties/5.3.0");function kp(t){const e={};for(const r in t)e[r]=t[r];return e}const Tp=new Np("strings/5.3.0");var Op,Cp;function Fp(t,e,r,n,i){if(t===Cp.BAD_PREFIX||t===Cp.UNEXPECTED_CONTINUE){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return t===Cp.OVERRUN?r.length-e-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(Op||(Op={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(Cp||(Cp={}));const Dp=Object.freeze({error:function(t,e,r,n,i){return Tp.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:Fp,replace:function(t,e,r,n,i){return t===Cp.OVERLONG?(n.push(i),0):(n.push(65533),Fp(t,e,r))}});function Lp(t,e=Op.current){e!=Op.current&&(Tp.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;const i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");const o=65536+((1023&n)<<10)+(1023&i);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return Pp(r)}function $p(t,e){return function(t,e){null==e&&(e=Dp.error),t=Pp(t);const r=[];let n=0;for(;n<t.length;){const i=t[n++];if(i>>7==0){r.push(i);continue}let o=null,s=null;if(192==(224&i))o=1,s=127;else if(224==(240&i))o=2,s=2047;else{if(240!=(248&i)){n+=e(128==(192&i)?Cp.UNEXPECTED_CONTINUE:Cp.BAD_PREFIX,n-1,t,r);continue}o=3,s=65535}if(n-1+o>=t.length){n+=e(Cp.OVERRUN,n-1,t,r);continue}let a=i&(1<<8-o-1)-1;for(let i=0;i<o;i++){let i=t[n];if(128!=(192&i)){n+=e(Cp.MISSING_CONTINUE,n,t,r),a=null;break}a=a<<6|63&i,n++}null!==a&&(a>1114111?n+=e(Cp.OUT_OF_RANGE,n-1-o,t,r,a):a>=55296&&a<=57343?n+=e(Cp.UTF16_SURROGATE,n-1-o,t,r,a):a<=s?n+=e(Cp.OVERLONG,n-1-o,t,r,a):r.push(a))}return r}(t,e).map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t)))).join("")}var Bp=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};function jp(t,e){return Bp(this,void 0,void 0,(function*(){null==e&&(e={});const r={method:e.method||"GET",headers:e.headers||{},body:e.body||void 0,mode:"cors",cache:"no-cache",credentials:"same-origin",redirect:"follow",referrer:"client"},n=yield fetch(t,r),i=yield n.arrayBuffer(),o={};return n.headers.forEach?n.headers.forEach((t,e)=>{o[e.toLowerCase()]=t}):n.headers.keys().forEach(t=>{o[t.toLowerCase()]=n.headers.get(t)}),{headers:o,statusCode:n.status,statusMessage:n.statusText,body:Pp(new Uint8Array(i))}}))}var zp=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const Gp=new Np("web/5.3.0");function qp(t){return new Promise(e=>{setTimeout(e,t)})}function Vp(t,e){if(null==t)return null;if("string"==typeof t)return t;if(function(t){return xp(t)&&!(t.length%2)||Ip(t)}(t)){if(e&&("text"===e.split("/")[0]||"application/json"===e.split(";")[0].trim()))try{return $p(t)}catch(t){}return function(t,e){if(e||(e={}),"number"==typeof t){Sp.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Rp(t))return t.toHexString();if(xp(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":Sp.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(Ip(t)){let e="0x";for(let r=0;r<t.length;r++){let n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return Sp.throwArgumentError("invalid hexlify value","value",t)}(t)}return t}function Kp(t,e,r){let n=null;if(null!=e){n=Lp(e);const r="string"==typeof t?{url:t}:kp(t);if(r.headers){0!==Object.keys(r.headers).filter(t=>"content-type"===t.toLowerCase()).length||(r.headers=kp(r.headers),r.headers["content-type"]="application/json")}else r.headers={"content-type":"application/json"};t=r}return function(t,e,r){const n="object"==typeof t&&null!=t.throttleLimit?t.throttleLimit:12;Gp.assertArgument(n>0&&n%1==0,"invalid connection throttle limit","connection.throttleLimit",n);const i="object"==typeof t?t.throttleCallback:null,o="object"==typeof t&&"number"==typeof t.throttleSlotInterval?t.throttleSlotInterval:100;Gp.assertArgument(o>0&&o%1==0,"invalid connection throttle slot interval","connection.throttleSlotInterval",o);const s={};let a=null;const h={method:"GET"};let u=!1,l=12e4;if("string"==typeof t)a=t;else if("object"==typeof t){if(null!=t&&null!=t.url||Gp.throwArgumentError("missing URL","connection.url",t),a=t.url,"number"==typeof t.timeout&&t.timeout>0&&(l=t.timeout),t.headers)for(const e in t.headers)s[e.toLowerCase()]={key:e,value:String(t.headers[e])},["if-none-match","if-modified-since"].indexOf(e.toLowerCase())>=0&&(u=!0);if(h.allowGzip=!!t.allowGzip,null!=t.user&&null!=t.password){"https:"!==a.substring(0,6)&&!0!==t.allowInsecureAuthentication&&Gp.throwError("basic authentication requires a secure https url",Np.errors.INVALID_ARGUMENT,{argument:"url",url:a,user:t.user,password:"[REDACTED]"});const e=t.user+":"+t.password;s.authorization={key:"Authorization",value:"Basic "+gp(Lp(e))}}}e&&(h.method="POST",h.body=e,null==s["content-type"]&&(s["content-type"]={key:"Content-Type",value:"application/octet-stream"}),null==s["content-length"]&&(s["content-length"]={key:"Content-Length",value:String(e.length)}));const f={};Object.keys(s).forEach(t=>{const e=s[t];f[e.key]=e.value}),h.headers=f;const c=function(){let t=null;return{promise:new Promise((function(e,r){l&&(t=setTimeout(()=>{null!=t&&(t=null,r(Gp.makeError("timeout",Np.errors.TIMEOUT,{requestBody:Vp(h.body,f["content-type"]),requestMethod:h.method,timeout:l,url:a})))},l))})),cancel:function(){null!=t&&(clearTimeout(t),t=null)}}}(),d=function(){return zp(this,void 0,void 0,(function*(){for(let t=0;t<n;t++){let e=null;try{if(e=yield jp(a,h),429===e.statusCode&&t<n){let r=!0;if(i&&(r=yield i(t,a)),r){let r=0;const n=e.headers["retry-after"];r="string"==typeof n&&n.match(/^[1-9][0-9]*$/)?1e3*parseInt(n):o*parseInt(String(Math.random()*Math.pow(2,t))),yield qp(r);continue}}}catch(t){e=t.response,null==e&&(c.cancel(),Gp.throwError("missing response",Np.errors.SERVER_ERROR,{requestBody:Vp(h.body,f["content-type"]),requestMethod:h.method,serverError:t,url:a}))}let s=e.body;if(u&&304===e.statusCode?s=null:(e.statusCode<200||e.statusCode>=300)&&(c.cancel(),Gp.throwError("bad response",Np.errors.SERVER_ERROR,{status:e.statusCode,headers:e.headers,body:Vp(s,e.headers?e.headers["content-type"]:null),requestBody:Vp(h.body,f["content-type"]),requestMethod:h.method,url:a})),r)try{const t=yield r(s,e);return c.cancel(),t}catch(r){if(r.throttleRetry&&t<n){let e=!0;if(i&&(e=yield i(t,a)),e){const e=o*parseInt(String(Math.random()*Math.pow(2,t)));yield qp(e);continue}}c.cancel(),Gp.throwError("processing response error",Np.errors.SERVER_ERROR,{body:Vp(s,e.headers?e.headers["content-type"]:null),error:r,requestBody:Vp(h.body,f["content-type"]),requestMethod:h.method,url:a})}return c.cancel(),s}return Gp.throwError("failed response",Np.errors.SERVER_ERROR,{requestBody:Vp(h.body,f["content-type"]),requestMethod:h.method,url:a})}))}();return Promise.race([c.promise,d])}(t,n,(t,e)=>{let n=null;if(null!=t)try{n=JSON.parse($p(t))}catch(e){Gp.throwError("invalid JSON",Np.errors.SERVER_ERROR,{body:t,error:e})}return r&&(n=r(n,e)),n})}function Wp(t,e){return e||(e={}),null==(e=kp(e)).floor&&(e.floor=0),null==e.ceiling&&(e.ceiling=1e4),null==e.interval&&(e.interval=250),new Promise((function(r,n){let i=null,o=!1;const s=()=>!o&&(o=!0,i&&clearTimeout(i),!0);e.timeout&&(i=setTimeout(()=>{s()&&n(new Error("timeout"))},e.timeout));const a=e.retryLimit;let h=0;!function i(){return t().then((function(t){if(void 0!==t)s()&&r(t);else if(e.oncePoll)e.oncePoll.once("poll",i);else if(e.onceBlock)e.onceBlock.once("block",i);else if(!o){if(h++,h>a)return void(s()&&n(new Error("retry limit reached")));let t=e.interval*parseInt(String(Math.random()*Math.pow(2,h)));t<e.floor&&(t=e.floor),t>e.ceiling&&(t=e.ceiling),setTimeout(i,t)}return null}),(function(t){s()&&n(t)}))}()}))}for(var Hp="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Zp={},Xp=0;Xp<Hp.length;Xp++){var Jp=Hp.charAt(Xp);if(void 0!==Zp[Jp])throw new TypeError(Jp+" is ambiguous");Zp[Jp]=Xp}function Yp(t){var e=t>>25;return(33554431&t)<<5^996825010&-(e>>0&1)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function Qp(t){for(var e=1,r=0;r<t.length;++r){var n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=Yp(e)^n>>5}for(e=Yp(e),r=0;r<t.length;++r){var i=t.charCodeAt(r);e=Yp(e)^31&i}return e}function tg(t,e){if(e=e||90,t.length<8)return t+" too short";if(t.length>e)return"Exceeds length limit";var r=t.toLowerCase(),n=t.toUpperCase();if(t!==r&&t!==n)return"Mixed-case string "+t;var i=(t=r).lastIndexOf("1");if(-1===i)return"No separator character for "+t;if(0===i)return"Missing prefix for "+t;var o=t.slice(0,i),s=t.slice(i+1);if(s.length<6)return"Data too short";var a=Qp(o);if("string"==typeof a)return a;for(var h=[],u=0;u<s.length;++u){var l=s.charAt(u),f=Zp[l];if(void 0===f)return"Unknown character "+l;a=Yp(a)^f,u+6>=s.length||h.push(f)}return 1!==a?"Invalid checksum for "+t:{prefix:o,words:h}}function eg(t,e,r,n){for(var i=0,o=0,s=(1<<r)-1,a=[],h=0;h<t.length;++h)for(i=i<<e|t[h],o+=e;o>=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<<r-o&s);else{if(o>=e)return"Excess padding";if(i<<r-o&s)return"Non-zero padding"}return a}var rg={decodeUnsafe:function(){var t=tg.apply(null,arguments);if("object"==typeof t)return t},decode:function(t){var e=tg.apply(null,arguments);if("object"==typeof e)return e;throw new Error(e)},encode:function(t,e,r){if(r=r||90,t.length+7+e.length>r)throw new TypeError("Exceeds length limit");var n=Qp(t=t.toLowerCase());if("string"==typeof n)throw new Error(n);for(var i=t+"1",o=0;o<e.length;++o){var s=e[o];if(s>>5!=0)throw new Error("Non 5-bit word");n=Yp(n)^s,i+=Hp.charAt(s)}for(o=0;o<6;++o)n=Yp(n);for(n^=1,o=0;o<6;++o){i+=Hp.charAt(n>>5*(5-o)&31)}return i},toWordsUnsafe:function(t){var e=eg(t,8,5,!0);if(Array.isArray(e))return e},toWords:function(t){var e=eg(t,8,5,!0);if(Array.isArray(e))return e;throw new Error(e)},fromWordsUnsafe:function(t){var e=eg(t,5,8,!1);if(Array.isArray(e))return e},fromWords:function(t){var e=eg(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}};const ng="providers/5.3.1";function ig(t){return"0x"+nn.keccak_256(Yc(t))}var og=h((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Xt.Buffer}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function h(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s<o;s++){var a=t.charCodeAt(s)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.prototype._initNumber=function(t,e,n){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):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("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 i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,u=0,l=r;l<a;l+=n)u=h(t,l,l+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var f=1;for(u=h(t,l,t.length,e),l=0;l<s;l++)f*=e;this.imuln(f),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this.strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","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"],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,h=s/67108864|0;r.words[0]=a;for(var u=1;u<n;u++){for(var l=h>>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var m=u-d|0;l+=(s=(i=0|t.words[m])*(o=0|e.words[d])+f)/67108864|0,f=67108863&s}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],h=(16777215&(a<<i|o)).toString(16);n=0!==(o=a>>>24-i&16777215)||s!==this.length-1?u[6-h.length]+h+n:h+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];n="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modn(d).toString(t);n=(m=m.idivn(d)).isZero()?p+n:u[c-p.length]+p+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.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&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(t,e){return r(void 0!==o),this.toArrayLike(o,t,e)},i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var s,a,h="le"===e,u=new t(o),l=this.clone();if(h){for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[a]=s;for(;a<o;a++)u[a]=0}else{for(a=0;a<o-i;a++)u[a]=0;for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[o-a-1]=s}return u},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this.strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,e,r){var n,i,o,s=t.words,a=e.words,h=r.words,u=0,l=0|s[0],f=8191&l,c=l>>>13,d=0|s[1],m=8191&d,p=d>>>13,g=0|s[2],y=8191&g,v=g>>>13,w=0|s[3],b=8191&w,E=w>>>13,M=0|s[4],_=8191&M,A=M>>>13,N=0|s[5],S=8191&N,R=N>>>13,U=0|s[6],I=8191&U,P=U>>>13,x=0|s[7],k=8191&x,T=x>>>13,O=0|s[8],C=8191&O,F=O>>>13,D=0|s[9],L=8191&D,$=D>>>13,B=0|a[0],j=8191&B,z=B>>>13,G=0|a[1],q=8191&G,V=G>>>13,K=0|a[2],W=8191&K,H=K>>>13,Z=0|a[3],X=8191&Z,J=Z>>>13,Y=0|a[4],Q=8191&Y,tt=Y>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ft=8191<,ct=lt>>>13,dt=0|a[9],mt=8191&dt,pt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,z))+Math.imul(c,j)|0))<<13)|0;u=((o=Math.imul(c,z))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(m,j),i=(i=Math.imul(m,z))+Math.imul(p,j)|0,o=Math.imul(p,z);var yt=(u+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,V)|0)+Math.imul(c,q)|0))<<13)|0;u=((o=o+Math.imul(c,V)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,j),i=(i=Math.imul(y,z))+Math.imul(v,j)|0,o=Math.imul(v,z),n=n+Math.imul(m,q)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(p,q)|0,o=o+Math.imul(p,V)|0;var vt=(u+(n=n+Math.imul(f,W)|0)|0)+((8191&(i=(i=i+Math.imul(f,H)|0)+Math.imul(c,W)|0))<<13)|0;u=((o=o+Math.imul(c,H)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(b,j),i=(i=Math.imul(b,z))+Math.imul(E,j)|0,o=Math.imul(E,z),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,V)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,H)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,H)|0;var wt=(u+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,X)|0))<<13)|0;u=((o=o+Math.imul(c,J)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(_,j),i=(i=Math.imul(_,z))+Math.imul(A,j)|0,o=Math.imul(A,z),n=n+Math.imul(b,q)|0,i=(i=i+Math.imul(b,V)|0)+Math.imul(E,q)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(y,W)|0,i=(i=i+Math.imul(y,H)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,H)|0,n=n+Math.imul(m,X)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,J)|0;var bt=(u+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(S,j),i=(i=Math.imul(S,z))+Math.imul(R,j)|0,o=Math.imul(R,z),n=n+Math.imul(_,q)|0,i=(i=i+Math.imul(_,V)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,V)|0,n=n+Math.imul(b,W)|0,i=(i=i+Math.imul(b,H)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,H)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(p,Q)|0,o=o+Math.imul(p,tt)|0;var Et=(u+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;u=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(I,j),i=(i=Math.imul(I,z))+Math.imul(P,j)|0,o=Math.imul(P,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(_,W)|0,i=(i=i+Math.imul(_,H)|0)+Math.imul(A,W)|0,o=o+Math.imul(A,H)|0,n=n+Math.imul(b,X)|0,i=(i=i+Math.imul(b,J)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,J)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,nt)|0;var Mt=(u+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(c,ot)|0))<<13)|0;u=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,z))+Math.imul(T,j)|0,o=Math.imul(T,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,V)|0)+Math.imul(P,q)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,H)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,H)|0,n=n+Math.imul(_,X)|0,i=(i=i+Math.imul(_,J)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,st)|0;var _t=(u+(n=n+Math.imul(f,ht)|0)|0)+((8191&(i=(i=i+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((o=o+Math.imul(c,ut)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(C,j),i=(i=Math.imul(C,z))+Math.imul(F,j)|0,o=Math.imul(F,z),n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(T,q)|0,o=o+Math.imul(T,V)|0,n=n+Math.imul(I,W)|0,i=(i=i+Math.imul(I,H)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,H)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(_,Q)|0,i=(i=i+Math.imul(_,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var At=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,z))+Math.imul($,j)|0,o=Math.imul($,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,V)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,V)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,H)|0)+Math.imul(T,W)|0,o=o+Math.imul(T,H)|0,n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(_,rt)|0,i=(i=i+Math.imul(_,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(b,ot)|0,i=(i=i+Math.imul(b,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(m,ft)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(p,ft)|0,o=o+Math.imul(p,ct)|0;var Nt=(u+(n=n+Math.imul(f,mt)|0)|0)+((8191&(i=(i=i+Math.imul(f,pt)|0)+Math.imul(c,mt)|0))<<13)|0;u=((o=o+Math.imul(c,pt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(L,q),i=(i=Math.imul(L,V))+Math.imul($,q)|0,o=Math.imul($,V),n=n+Math.imul(C,W)|0,i=(i=i+Math.imul(C,H)|0)+Math.imul(F,W)|0,o=o+Math.imul(F,H)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(_,ot)|0,i=(i=i+Math.imul(_,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,n=n+Math.imul(b,ht)|0,i=(i=i+Math.imul(b,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,o=o+Math.imul(v,ct)|0;var St=(u+(n=n+Math.imul(m,mt)|0)|0)+((8191&(i=(i=i+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,W),i=(i=Math.imul(L,H))+Math.imul($,W)|0,o=Math.imul($,H),n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(_,ht)|0,i=(i=i+Math.imul(_,ut)|0)+Math.imul(A,ht)|0,o=o+Math.imul(A,ut)|0,n=n+Math.imul(b,ft)|0,i=(i=i+Math.imul(b,ct)|0)+Math.imul(E,ft)|0,o=o+Math.imul(E,ct)|0;var Rt=(u+(n=n+Math.imul(y,mt)|0)|0)+((8191&(i=(i=i+Math.imul(y,pt)|0)+Math.imul(v,mt)|0))<<13)|0;u=((o=o+Math.imul(v,pt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,J))+Math.imul($,X)|0,o=Math.imul($,J),n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(F,Q)|0,o=o+Math.imul(F,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,ut)|0,n=n+Math.imul(_,ft)|0,i=(i=i+Math.imul(_,ct)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,ct)|0;var Ut=(u+(n=n+Math.imul(b,mt)|0)|0)+((8191&(i=(i=i+Math.imul(b,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(i>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,n=Math.imul(L,Q),i=(i=Math.imul(L,tt))+Math.imul($,Q)|0,o=Math.imul($,tt),n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(F,rt)|0,o=o+Math.imul(F,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(S,ft)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(R,ft)|0,o=o+Math.imul(R,ct)|0;var It=(u+(n=n+Math.imul(_,mt)|0)|0)+((8191&(i=(i=i+Math.imul(_,pt)|0)+Math.imul(A,mt)|0))<<13)|0;u=((o=o+Math.imul(A,pt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul($,rt)|0,o=Math.imul($,nt),n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,st)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,ut)|0)+Math.imul(T,ht)|0,o=o+Math.imul(T,ut)|0,n=n+Math.imul(I,ft)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(P,ft)|0,o=o+Math.imul(P,ct)|0;var Pt=(u+(n=n+Math.imul(S,mt)|0)|0)+((8191&(i=(i=i+Math.imul(S,pt)|0)+Math.imul(R,mt)|0))<<13)|0;u=((o=o+Math.imul(R,pt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,ot),i=(i=Math.imul(L,st))+Math.imul($,ot)|0,o=Math.imul($,st),n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,ut)|0)+Math.imul(F,ht)|0,o=o+Math.imul(F,ut)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,ct)|0;var xt=(u+(n=n+Math.imul(I,mt)|0)|0)+((8191&(i=(i=i+Math.imul(I,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),n=n+Math.imul(C,ft)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(F,ft)|0,o=o+Math.imul(F,ct)|0;var kt=(u+(n=n+Math.imul(k,mt)|0)|0)+((8191&(i=(i=i+Math.imul(k,pt)|0)+Math.imul(T,mt)|0))<<13)|0;u=((o=o+Math.imul(T,pt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,ft),i=(i=Math.imul(L,ct))+Math.imul($,ft)|0,o=Math.imul($,ct);var Tt=(u+(n=n+Math.imul(C,mt)|0)|0)+((8191&(i=(i=i+Math.imul(C,pt)|0)+Math.imul(F,mt)|0))<<13)|0;u=((o=o+Math.imul(F,pt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863;var Ot=(u+(n=Math.imul(L,mt))|0)+((8191&(i=(i=Math.imul(L,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=wt,h[4]=bt,h[5]=Et,h[6]=Mt,h[7]=_t,h[8]=At,h[9]=Nt,h[10]=St,h[11]=Rt,h[12]=Ut,h[13]=It,h[14]=Pt,h[15]=xt,h[16]=kt,h[17]=Tt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new p).mulp(t,e,r)}function p(t,e){this.x=t,this.y=e}Math.imul||(d=c),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,f=(0|t.words[l])*(0|e.words[u]),c=67108863&f;a=67108863&(c=c+a|0),i+=(s=(s=s+(f/67108864|0)|0)+(c>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):m(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),r=i.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e},p.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n},p.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s<o;s++)n[s]=e[t[s]],i[s]=r[t[s]]},p.prototype.transform=function(t,e,r,n,i,o){this.permute(o,t,e,r,n,i);for(var s=1;s<i;s<<=1)for(var a=s<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),l=0;l<i;l+=a)for(var f=h,c=u,d=0;d<s;d++){var m=r[l+d],p=n[l+d],g=r[l+d+s],y=n[l+d+s],v=f*g-c*y;y=f*y+c*g,g=v,r[l+d]=m+g,n[l+d]=p+y,r[l+d+s]=m-g,n[l+d+s]=p-y,d!==a&&(v=h*f-u*c,c=h*c+u*f,f=v)}},p.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},p.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},p.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0}return t},p.prototype.convert13b=function(t,e,n,i){for(var o=0,s=0;s<e;s++)o+=0|t[s],n[2*s]=8191&o,o>>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<i;++s)n[s]=0;r(0===o),r(0==(-8192&o))},p.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},p.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),o=this.stub(n),s=new Array(n),a=new Array(n),h=new Array(n),u=new Array(n),l=new Array(n),f=new Array(n),c=r.words;c.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(e.words,e.length,u,n),this.transform(s,o,a,h,n,i),this.transform(u,o,l,f,n,i);for(var d=0;d<n;d++){var m=a[d]*l[d]-h[d]*f[d];h[d]=a[d]*f[d]+h[d]*l[d],a[d]=m}return this.conjugate(a,h,n),this.transform(a,h,c,o,n,i),this.conjugate(c,o,n),this.normalize13b(c,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),m(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){r("number"==typeof t),r(t<67108864);for(var e=0,n=0;n<this.length;n++){var i=(0|this.words[n])*t,o=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=o>>>26,this.words[n]=67108863&o}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(t.words[n]&1<<i)>>>i}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,h=(0|this.words[e])-a<<n;this.words[e]=h|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this.strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,h=n;if(i-=s,i=Math.max(0,i),h){for(var u=0;u<s;u++)h.words[u]=this.words[u];h.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=i);u--){var f=0|this.words[u];this.words[u]=l<<26-o|f>>>o,l=f&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n)&&!!(this.words[n]&i)},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this.strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(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)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(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 e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var h=(0|t.words[i])*e;a=((o-=67108863&h)>>26)-(h/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!==(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,h=n.length-o.length;if("mod"!==e){(a=new i(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var l=n.clone()._ishlnsubmul(o,1,h);0===l.negative&&(n=l,a&&(a.words[h]=1));for(var f=h-1;f>=0;f--){var c=67108864*(0|n.words[o.length+f])+(0|n.words[o.length+f-1]);for(c=Math.min(c/s|0,67108863),n._ishlnsubmul(o,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(o,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},i.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),h=new i(1),u=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(f)),o.iushrn(1),s.iushrn(1);for(var m=0,p=1;0==(n.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(n.iushrn(m);m-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(f)),a.iushrn(1),h.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(h)):(n.isub(e),a.isub(o),h.isub(s))}return{a:a,b:h,gcd:n.iushln(u)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),h=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new M(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(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 i(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n<r;n++)e.words[n]=t.words[n];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=4194303&i,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(4194303&o)<<4|i>>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,y),n(b,y),n(E,y),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new w;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},M.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},M.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},M.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,o),c=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),m=s;0!==d.cmp(a);){for(var p=d,g=0;0!==p.cmp(a);g++)p=p.redSqr();r(g<m);var y=this.pow(f,new i(1).iushln(m-g-1));c=c.redMul(y),f=y.redSqr(),d=d.redMul(f),m=g}return c},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],l=h-1;l>=0;l--){var f=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===l)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}h=26}return o},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new _(t)},n(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,o)}));function sg(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}var ag=hg;function hg(t,e){if(!t)throw new Error(e||"Assertion failed")}hg.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var ug=sg((function(t,e){var r=e;function n(t){return 1===t.length?"0"+t:t}function i(t){for(var e="",r=0;r<t.length;r++)e+=n(t[r].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var n=0;n<t.length;n++)r[n]=0|t[n];return r}if("hex"===e){(t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t);for(n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(n=0;n<t.length;n++){var i=t.charCodeAt(n),o=i>>8,s=255&i;o?r.push(o,s):r.push(s)}return r},r.zero2=n,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}})),lg=sg((function(t,e){var r=e;r.assert=ag,r.toArray=ug.toArray,r.zero2=ug.zero2,r.toHex=ug.toHex,r.encode=ug.encode,r.getNAF=function(t,e,r){var n=new Array(Math.max(t.bitLength(),r)+1);n.fill(0);for(var i=1<<e+1,o=t.clone(),s=0;s<n.length;s++){var a,h=o.andln(i-1);o.isOdd()?(a=h>(i>>1)-1?(i>>1)-h:h,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},r.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,h=t.andln(3)+i&3,u=e.andln(3)+o&3;3===h&&(h=-1),3===u&&(u=-1),s=0==(1&h)?0:3!==(n=t.andln(7)+i&7)&&5!==n||2!==u?h:-h,r[0].push(s),a=0==(1&u)?0:3!==(n=e.andln(7)+o&7)&&5!==n||2!==h?u:-u,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new og(t,"hex","le")}})),fg=lg.getNAF,cg=lg.getJSF,dg=lg.assert;function mg(t,e){this.type=t,this.p=new og(e.p,16),this.red=e.prime?og.red(e.prime):og.mont(this.p),this.zero=new og(0).toRed(this.red),this.one=new og(1).toRed(this.red),this.two=new og(2).toRed(this.red),this.n=e.n&&new og(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var pg=mg;function gg(t,e){this.curve=t,this.type=e,this.precomputed=null}mg.prototype.point=function(){throw new Error("Not implemented")},mg.prototype.validate=function(){throw new Error("Not implemented")},mg.prototype._fixedNafMul=function(t,e){dg(t.precomputed);var r=t._getDoubles(),n=fg(e,1,this._bitLength),i=(1<<r.step+1)-(r.step%2==0?2:1);i/=3;var o,s,a=[];for(o=0;o<n.length;o+=r.step){s=0;for(var h=o+r.step-1;h>=o;h--)s=(s<<1)+n[h];a.push(s)}for(var u=this.jpoint(null,null,null),l=this.jpoint(null,null,null),f=i;f>0;f--){for(o=0;o<a.length;o++)(s=a[o])===f?l=l.mixedAdd(r.points[o]):s===-f&&(l=l.mixedAdd(r.points[o].neg()));u=u.add(l)}return u.toP()},mg.prototype._wnafMul=function(t,e){var r=4,n=t._getNAFPoints(r);r=n.wnd;for(var i=n.points,o=fg(e,r,this._bitLength),s=this.jpoint(null,null,null),a=o.length-1;a>=0;a--){for(var h=0;a>=0&&0===o[a];a--)h++;if(a>=0&&h++,s=s.dblp(h),a<0)break;var u=o[a];dg(0!==u),s="affine"===t.type?u>0?s.mixedAdd(i[u-1>>1]):s.mixedAdd(i[-u-1>>1].neg()):u>0?s.add(i[u-1>>1]):s.add(i[-u-1>>1].neg())}return"affine"===t.type?s.toP():s},mg.prototype._wnafMulAdd=function(t,e,r,n,i){var o,s,a,h=this._wnafT1,u=this._wnafT2,l=this._wnafT3,f=0;for(o=0;o<n;o++){var c=(a=e[o])._getNAFPoints(t);h[o]=c.wnd,u[o]=c.points}for(o=n-1;o>=1;o-=2){var d=o-1,m=o;if(1===h[d]&&1===h[m]){var p=[e[d],null,null,e[m]];0===e[d].y.cmp(e[m].y)?(p[1]=e[d].add(e[m]),p[2]=e[d].toJ().mixedAdd(e[m].neg())):0===e[d].y.cmp(e[m].y.redNeg())?(p[1]=e[d].toJ().mixedAdd(e[m]),p[2]=e[d].add(e[m].neg())):(p[1]=e[d].toJ().mixedAdd(e[m]),p[2]=e[d].toJ().mixedAdd(e[m].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],y=cg(r[d],r[m]);for(f=Math.max(y[0].length,f),l[d]=new Array(f),l[m]=new Array(f),s=0;s<f;s++){var v=0|y[0][s],w=0|y[1][s];l[d][s]=g[3*(v+1)+(w+1)],l[m][s]=0,u[d]=p}}else l[d]=fg(r[d],h[d],this._bitLength),l[m]=fg(r[m],h[m],this._bitLength),f=Math.max(l[d].length,f),f=Math.max(l[m].length,f)}var b=this.jpoint(null,null,null),E=this._wnafT4;for(o=f;o>=0;o--){for(var M=0;o>=0;){var _=!0;for(s=0;s<n;s++)E[s]=0|l[s][o],0!==E[s]&&(_=!1);if(!_)break;M++,o--}if(o>=0&&M++,b=b.dblp(M),o<0)break;for(s=0;s<n;s++){var A=E[s];0!==A&&(A>0?a=u[s][A-1>>1]:A<0&&(a=u[s][-A-1>>1].neg()),b="affine"===a.type?b.mixedAdd(a):b.add(a))}}for(o=0;o<n;o++)u[o]=null;return i?b:b.toP()},mg.BasePoint=gg,gg.prototype.eq=function(){throw new Error("Not implemented")},gg.prototype.validate=function(){return this.curve.validate(this)},mg.prototype.decodePoint=function(t,e){t=lg.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?dg(t[t.length-1]%2==0):7===t[0]&&dg(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},gg.prototype.encodeCompressed=function(t){return this.encode(t,!0)},gg.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},gg.prototype.encode=function(t,e){return lg.encode(this._encode(e),t)},gg.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},gg.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},gg.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i<e;i+=t){for(var o=0;o<t;o++)n=n.dbl();r.push(n)}return{step:t,points:r}},gg.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,n=1===r?null:this.dbl(),i=1;i<r;i++)e[i]=e[i-1].add(n);return{wnd:t,points:e}},gg.prototype._getBeta=function(){return null},gg.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e};var yg=sg((function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}})),vg=lg.assert;function wg(t){pg.call(this,"short",t),this.a=new og(t.a,16).toRed(this.red),this.b=new og(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}yg(wg,pg);var bg=wg;function Eg(t,e,r,n){pg.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new og(e,16),this.y=new og(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function Mg(t,e,r,n){pg.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new og(0)):(this.x=new og(e,16),this.y=new og(r,16),this.z=new og(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}wg.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new og(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new og(t.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(e))?r=i[0]:(r=i[1],vg(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map((function(t){return{a:new og(t.a,16),b:new og(t.b,16)}})):this._getEndoBasis(r)}}},wg.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:og.mont(t),r=new og(2).toRed(e).redInvm(),n=r.redNeg(),i=new og(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},wg.prototype._getEndoBasis=function(t){for(var e,r,n,i,o,s,a,h,u,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),f=t,c=this.n.clone(),d=new og(1),m=new og(0),p=new og(0),g=new og(1),y=0;0!==f.cmpn(0);){var v=c.div(f);h=c.sub(v.mul(f)),u=p.sub(v.mul(d));var w=g.sub(v.mul(m));if(!n&&h.cmp(l)<0)e=a.neg(),r=d,n=h.neg(),i=u;else if(n&&2==++y)break;a=h,c=f,f=h,p=d,d=u,g=m,m=w}o=h.neg(),s=u;var b=n.sqr().add(i.sqr());return o.sqr().add(s.sqr()).cmp(b)>=0&&(o=e,s=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),s=s.neg()),[{a:n,b:i},{a:o,b:s}]},wg.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),h=i.mul(r.b),u=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:h.add(u).neg()}},wg.prototype.pointFromX=function(t,e){(t=new og(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},wg.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},wg.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o<t.length;o++){var s=this._endoSplit(e[o]),a=t[o],h=a._getBeta();s.k1.negative&&(s.k1.ineg(),a=a.neg(!0)),s.k2.negative&&(s.k2.ineg(),h=h.neg(!0)),n[2*o]=a,n[2*o+1]=h,i[2*o]=s.k1,i[2*o+1]=s.k2}for(var u=this._wnafMulAdd(1,n,i,2*o,r),l=0;l<2*o;l++)n[l]=null,i[l]=null;return u},yg(Eg,pg.BasePoint),wg.prototype.point=function(t,e,r){return new Eg(this,t,e,r)},wg.prototype.pointFromJSON=function(t,e){return Eg.fromJSON(this,t,e)},Eg.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,n=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(n)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(n)}}}return e}},Eg.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},Eg.fromJSON=function(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var n=t.point(e[0],e[1],r);if(!e[2])return n;function i(e){return t.point(e[0],e[1],r)}var o=e[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(i))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(i))}},n},Eg.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},Eg.prototype.isInfinity=function(){return this.inf},Eg.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Eg.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},Eg.prototype.getX=function(){return this.x.fromRed()},Eg.prototype.getY=function(){return this.y.fromRed()},Eg.prototype.mul=function(t){return t=new og(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},Eg.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Eg.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Eg.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},Eg.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},Eg.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},yg(Mg,pg.BasePoint),wg.prototype.jpoint=function(t,e,r){return new Mg(this,t,e,r)},Mg.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},Mg.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},Mg.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),h=o.redSub(s);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),l=u.redMul(a),f=n.redMul(u),c=h.redSqr().redIAdd(l).redISub(f).redISub(f),d=h.redMul(f.redISub(c)).redISub(o.redMul(l)),m=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(c,d,m)},Mg.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=s.redSqr(),u=h.redMul(s),l=r.redMul(h),f=a.redSqr().redIAdd(u).redISub(l).redISub(l),c=a.redMul(l.redISub(f)).redISub(i.redMul(u)),d=this.z.redMul(s);return this.curve.jpoint(f,c,d)},Mg.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var n=this.curve.a,i=this.curve.tinv,o=this.x,s=this.y,a=this.z,h=a.redSqr().redSqr(),u=s.redAdd(s);for(e=0;e<t;e++){var l=o.redSqr(),f=u.redSqr(),c=f.redSqr(),d=l.redAdd(l).redIAdd(l).redIAdd(n.redMul(h)),m=o.redMul(f),p=d.redSqr().redISub(m.redAdd(m)),g=m.redISub(p),y=d.redMul(g);y=y.redIAdd(y).redISub(c);var v=u.redMul(a);e+1<t&&(h=h.redMul(c)),o=p,a=v,u=y}return this.curve.jpoint(o,u.redMul(i),a)},Mg.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},Mg.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n),h=a.redSqr().redISub(s).redISub(s),u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),t=h,e=a.redMul(s.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var l=this.x.redSqr(),f=this.y.redSqr(),c=f.redSqr(),d=this.x.redAdd(f).redSqr().redISub(l).redISub(c);d=d.redIAdd(d);var m=l.redAdd(l).redIAdd(l),p=m.redSqr(),g=c.redIAdd(c);g=(g=g.redIAdd(g)).redIAdd(g),t=p.redISub(d).redISub(d),e=m.redMul(d.redISub(t)).redISub(g),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},Mg.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=a.redSqr().redISub(s).redISub(s);t=h;var u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),e=a.redMul(s.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var l=this.z.redSqr(),f=this.y.redSqr(),c=this.x.redMul(f),d=this.x.redSub(l).redMul(this.x.redAdd(l));d=d.redAdd(d).redIAdd(d);var m=c.redIAdd(c),p=(m=m.redIAdd(m)).redAdd(m);t=d.redSqr().redISub(p),r=this.y.redAdd(this.z).redSqr().redISub(f).redISub(l);var g=f.redSqr();g=(g=(g=g.redIAdd(g)).redIAdd(g)).redIAdd(g),e=d.redMul(m.redISub(t)).redISub(g)}return this.curve.jpoint(t,e,r)},Mg.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),o=e.redSqr(),s=r.redSqr(),a=o.redAdd(o).redIAdd(o).redIAdd(t.redMul(i)),h=e.redAdd(e),u=(h=h.redIAdd(h)).redMul(s),l=a.redSqr().redISub(u.redAdd(u)),f=u.redISub(l),c=s.redSqr();c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var d=a.redMul(f).redISub(c),m=r.redAdd(r).redMul(n);return this.curve.jpoint(l,d,m)},Mg.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),n=e.redSqr(),i=t.redAdd(t).redIAdd(t),o=i.redSqr(),s=this.x.redAdd(e).redSqr().redISub(t).redISub(n),a=(s=(s=(s=s.redIAdd(s)).redAdd(s).redIAdd(s)).redISub(o)).redSqr(),h=n.redIAdd(n);h=(h=(h=h.redIAdd(h)).redIAdd(h)).redIAdd(h);var u=i.redIAdd(s).redSqr().redISub(o).redISub(a).redISub(h),l=e.redMul(u);l=(l=l.redIAdd(l)).redIAdd(l);var f=this.x.redMul(a).redISub(l);f=(f=f.redIAdd(f)).redIAdd(f);var c=this.y.redMul(u.redMul(h.redISub(u)).redISub(s.redMul(a)));c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var d=this.z.redAdd(s).redSqr().redISub(r).redISub(a);return this.curve.jpoint(f,c,d)},Mg.prototype.mul=function(t,e){return t=new og(t,e),this.curve._wnafMul(this,t)},Mg.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var n=e.redMul(this.z),i=r.redMul(t.z);return 0===this.y.redMul(i).redISub(t.y.redMul(n)).cmpn(0)},Mg.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var n=t.clone(),i=this.curve.redN.redMul(e);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},Mg.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},Mg.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var _g=sg((function(t,e){var r=e;r.base=pg,r.short=bg,r.mont=null,r.edwards=null})),Ag=sg((function(t,e){var r,n=e,i=lg.assert;function o(t){"short"===t.type?this.curve=new _g.short(t):"edwards"===t.type?this.curve=new _g.edwards(t):this.curve=new _g.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function s(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new o(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Zm.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Zm.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Zm.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Zm.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Zm.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Zm.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Zm.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=null.crash()}catch(t){r=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Zm.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})}));function Ng(t){if(!(this instanceof Ng))return new Ng(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ug.toArray(t.entropy,t.entropyEnc||"hex"),r=ug.toArray(t.nonce,t.nonceEnc||"hex"),n=ug.toArray(t.pers,t.persEnc||"hex");ag(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var Sg=Ng;Ng.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},Ng.prototype._hmac=function(){return new Zm.hmac(this.hash,this.K)},Ng.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},Ng.prototype.reseed=function(t,e,r,n){"string"!=typeof e&&(n=r,r=e,e=null),t=ug.toArray(t,e),r=ug.toArray(r,n),ag(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},Ng.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=ug.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length<t;)this.V=this._hmac().update(this.V).digest(),i=i.concat(this.V);var o=i.slice(0,t);return this._update(r),this._reseed++,ug.encode(o,e)};var Rg=lg.assert;function Ug(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var Ig=Ug;Ug.fromPublic=function(t,e,r){return e instanceof Ug?e:new Ug(t,{pub:e,pubEnc:r})},Ug.fromPrivate=function(t,e,r){return e instanceof Ug?e:new Ug(t,{priv:e,privEnc:r})},Ug.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Ug.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},Ug.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},Ug.prototype._importPrivate=function(t,e){this.priv=new og(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},Ug.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?Rg(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||Rg(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},Ug.prototype.derive=function(t){return t.validate()||Rg(t.validate(),"public point not validated"),t.mul(this.priv).getX()},Ug.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},Ug.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},Ug.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Pg=lg.assert;function xg(t,e){if(t instanceof xg)return t;this._importDER(t,e)||(Pg(t.r&&t.s,"Signature without r or s"),this.r=new og(t.r,16),this.s=new og(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var kg=xg;function Tg(){this.place=0}function Og(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=e.place;o<n;o++,s++)i<<=8,i|=t[s],i>>>=0;return!(i<=127)&&(e.place=s,i)}function Cg(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function Fg(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}xg.prototype._importDER=function(t,e){t=lg.toArray(t,e);var r=new Tg;if(48!==t[r.place++])return!1;var n=Og(t,r);if(!1===n)return!1;if(n+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var i=Og(t,r);if(!1===i)return!1;var o=t.slice(r.place,i+r.place);if(r.place+=i,2!==t[r.place++])return!1;var s=Og(t,r);if(!1===s)return!1;if(t.length!==s+r.place)return!1;var a=t.slice(r.place,s+r.place);if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}if(0===a[0]){if(!(128&a[1]))return!1;a=a.slice(1)}return this.r=new og(o),this.s=new og(a),this.recoveryParam=null,!0},xg.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=Cg(e),r=Cg(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];Fg(n,e.length),(n=n.concat(e)).push(2),Fg(n,r.length);var i=n.concat(r),o=[48];return Fg(o,i.length),o=o.concat(i),lg.encode(o,t)};var Dg=function(){throw new Error("unsupported")},Lg=lg.assert;function $g(t){if(!(this instanceof $g))return new $g(t);"string"==typeof t&&(Lg(Object.prototype.hasOwnProperty.call(Ag,t),"Unknown curve "+t),t=Ag[t]),t instanceof Ag.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var Bg=$g;$g.prototype.keyPair=function(t){return new Ig(this,t)},$g.prototype.keyFromPrivate=function(t,e){return Ig.fromPrivate(this,t,e)},$g.prototype.keyFromPublic=function(t,e){return Ig.fromPublic(this,t,e)},$g.prototype.genKeyPair=function(t){t||(t={});for(var e=new Sg({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||Dg(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new og(2));;){var i=new og(e.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},$g.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},$g.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new og(t,16));for(var i=this.n.byteLength(),o=e.getPrivate().toArray("be",i),s=t.toArray("be",i),a=new Sg({hash:this.hash,entropy:o,nonce:s,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new og(1)),u=0;;u++){var l=n.k?n.k(u):new og(a.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(h)>=0)){var f=this.g.mul(l);if(!f.isInfinity()){var c=f.getX(),d=c.umod(this.n);if(0!==d.cmpn(0)){var m=l.invm(this.n).mul(d.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var p=(f.getY().isOdd()?1:0)|(0!==c.cmp(d)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),p^=1),new kg({r:d,s:m,recoveryParam:p})}}}}}},$g.prototype.verify=function(t,e,r,n){t=this._truncateToN(new og(t,16)),r=this.keyFromPublic(r,n);var i=(e=new kg(e,"hex")).r,o=e.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var s,a=o.invm(this.n),h=a.mul(t).umod(this.n),u=a.mul(i).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(h,r.getPublic(),u)).isInfinity()&&s.eqXToP(i):!(s=this.g.mulAdd(h,r.getPublic(),u)).isInfinity()&&0===s.getX().umod(this.n).cmp(i)},$g.prototype.recoverPubKey=function(t,e,r,n){Lg((3&r)===r,"The recovery param is more than two bits"),e=new kg(e,n);var i=this.n,o=new og(t),s=e.r,a=e.s,h=1&r,u=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");s=u?this.curve.pointFromX(s.add(this.curve.n),h):this.curve.pointFromX(s,h);var l=e.r.invm(i),f=i.sub(o).mul(l).umod(i),c=a.mul(l).umod(i);return this.g.mulAdd(f,s,c)},$g.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new kg(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var jg=sg((function(t,e){var r=e;r.version="6.5.4",r.utils=lg,r.rand=function(){throw new Error("unsupported")},r.curve=_g,r.curves=Ag,r.ec=Bg,r.eddsa=null})).ec;const zg=new Wc("signing-key/5.3.0");let Gg=null;function qg(){return Gg||(Gg=new jg("secp256k1")),Gg}class Vg{constructor(t){fd(this,"curve","secp256k1"),fd(this,"privateKey",rd(t));const e=qg().keyFromPrivate(Yc(this.privateKey));fd(this,"publicKey","0x"+e.getPublic(!1,"hex")),fd(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),fd(this,"_isSigningKey",!0)}_addPoint(t){const e=qg().keyFromPublic(Yc(this.publicKey)),r=qg().keyFromPublic(Yc(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){const e=qg().keyFromPrivate(Yc(this.privateKey)),r=Yc(t);32!==r.length&&zg.throwArgumentError("bad digest length","digest",t);const n=e.sign(r,{canonical:!0});return hd({recoveryParam:n.recoveryParam,r:ad("0x"+n.r.toString(16),32),s:ad("0x"+n.s.toString(16),32)})}computeSharedSecret(t){const e=qg().keyFromPrivate(Yc(this.privateKey)),r=qg().keyFromPublic(Yc(Kg(t)));return ad("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function Kg(t,e){const r=Yc(t);if(32===r.length){const t=new Vg(r);return e?"0x"+qg().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?rd(r):"0x"+qg().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+qg().keyFromPublic(r).getPublic(!0,"hex"):rd(r):zg.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Wg=new Wc("transactions/5.3.0");function Hg(t){return"0x"===t?null:On(t)}function Zg(t){return"0x"===t?Hn:me.from(t)}function Xg(t,e){return function(t){return On(id(ig(id(Kg(t),1)),12))}(function(t,e){const r=hd(e),n={r:Yc(r.r),s:Yc(r.s)};return"0x"+qg().recoverPubKey(Yc(t),n,r.recoveryParam).encode("hex",!1)}(Yc(t),e))}function Jg(t,e){const r=td(me.from(t).toHexString());return r.length>32&&Wg.throwArgumentError("invalid length for "+e,"transaction:"+e,t),r}function Yg(t,e){return{address:On(t),storageKeys:(e||[]).map((e,r)=>(32!==nd(e)&&Wg.throwArgumentError("invalid access list storageKey",`accessList[${t}:${r}]`,e),e.toLowerCase()))}}function Qg(t){if(Array.isArray(t))return t.map((t,e)=>Array.isArray(t)?(t.length>2&&Wg.throwArgumentError("access list expected to be [ address, storageKeys[] ]",`value[${e}]`,t),Yg(t[0],t[1])):Yg(t.address,t.storageKeys));const e=Object.keys(t).map(e=>{const r=t[e].reduce((t,e)=>(t[e]=!0,t),{});return Yg(e,Object.keys(r).sort())});return e.sort((t,e)=>t.address.localeCompare(e.address)),e}function ty(t){const e=In(t.slice(1));8!==e.length&&11!==e.length&&Wg.throwArgumentError("invalid component count for transaction type: 1","payload",rd(t));const r={type:1,chainId:Zg(e[0]).toNumber(),nonce:Zg(e[1]).toNumber(),gasPrice:Zg(e[2]),gasLimit:Zg(e[3]),to:Hg(e[4]),value:Zg(e[5]),data:e[6],accessList:Qg(e[7])};if(8===e.length)return r;try{const t=Zg(e[8]).toNumber();if(0!==t&&1!==t)throw new Error("bad recid");r.v=t}catch(t){Wg.throwArgumentError("invalid v for transaction type: 1","v",e[8])}r.r=ad(e[9],32),r.s=ad(e[10],32);try{const t=ig(function(t,e){const r=[Jg(t.chainId||0,"chainId"),Jg(t.nonce||0,"nonce"),Jg(t.gasPrice||0,"gasPrice"),Jg(t.gasLimit||0,"gasLimit"),null!=t.to?On(t.to):"0x",Jg(t.value||0,"value"),t.data||"0x",(n=t.accessList||[],Qg(n).map(t=>[t.address,t.storageKeys]))];var n;if(e){const t=hd(e);r.push(Jg(t.recoveryParam,"recoveryParam")),r.push(td(t.r)),r.push(td(t.s))}return od(["0x01",Sn(r)])}(r));r.from=Xg(t,{r:r.r,s:r.s,recoveryParam:r.v})}catch(t){console.log(t)}return r.hash=ig(t),r}function ey(t){const e=Yc(t);if(e[0]>127)return function(t){const e=In(t);9!==e.length&&6!==e.length&&Wg.throwArgumentError("invalid raw transaction","rawTransaction",t);const r={nonce:Zg(e[0]).toNumber(),gasPrice:Zg(e[1]),gasLimit:Zg(e[2]),to:Hg(e[3]),value:Zg(e[4]),data:e[5],chainId:0};if(6===e.length)return r;try{r.v=me.from(e[6]).toNumber()}catch(t){return console.log(t),r}if(r.r=ad(e[7],32),r.s=ad(e[8],32),me.from(r.r).isZero()&&me.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let n=r.v-27;const i=e.slice(0,6);0!==r.chainId&&(i.push(rd(r.chainId)),i.push("0x"),i.push("0x"),n-=2*r.chainId+8);const o=ig(Sn(i));try{r.from=Xg(o,{r:rd(r.r),s:rd(r.s),recoveryParam:n})}catch(t){console.log(t)}r.hash=ig(t)}return r.type=null,r}(e);switch(e[0]){case 1:return ty(e)}return Wg.throwError("unsupported transaction type: "+e[0],Wc.errors.UNSUPPORTED_OPERATION,{operation:"parseTransaction",transactionType:e[0]})}const ry=new Wc(ng);class ny{constructor(){ry.checkNew(new.target,ny),this.formats=this.getDefaultFormats()}getDefaultFormats(){const t={},e=this.address.bind(this),r=this.bigNumber.bind(this),n=this.blockTag.bind(this),i=this.data.bind(this),o=this.hash.bind(this),s=this.hex.bind(this),a=this.number.bind(this);return t.transaction={hash:o,type:ny.allowNull(a,null),accessList:ny.allowNull(this.accessList.bind(this),null),blockHash:ny.allowNull(o,null),blockNumber:ny.allowNull(a,null),transactionIndex:ny.allowNull(a,null),confirmations:ny.allowNull(a,null),from:e,gasPrice:r,gasLimit:r,to:ny.allowNull(e,null),value:r,nonce:a,data:i,r:ny.allowNull(this.uint256),s:ny.allowNull(this.uint256),v:ny.allowNull(a),creates:ny.allowNull(e,null),raw:ny.allowNull(i)},t.transactionRequest={from:ny.allowNull(e),nonce:ny.allowNull(a),gasLimit:ny.allowNull(r),gasPrice:ny.allowNull(r),to:ny.allowNull(e),value:ny.allowNull(r),data:ny.allowNull(t=>this.data(t,!0)),type:ny.allowNull(a),accessList:ny.allowNull(this.accessList.bind(this),null)},t.receiptLog={transactionIndex:a,blockNumber:a,transactionHash:o,address:e,topics:ny.arrayOf(o),data:i,logIndex:a,blockHash:o},t.receipt={to:ny.allowNull(this.address,null),from:ny.allowNull(this.address,null),contractAddress:ny.allowNull(e,null),transactionIndex:a,root:ny.allowNull(s),gasUsed:r,logsBloom:ny.allowNull(i),blockHash:o,transactionHash:o,logs:ny.arrayOf(this.receiptLog.bind(this)),blockNumber:a,confirmations:ny.allowNull(a,null),cumulativeGasUsed:r,status:ny.allowNull(a)},t.block={hash:o,parentHash:o,number:a,timestamp:a,nonce:ny.allowNull(s),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:e,extraData:i,transactions:ny.allowNull(ny.arrayOf(o))},t.blockWithTransactions=md(t.block),t.blockWithTransactions.transactions=ny.allowNull(ny.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:ny.allowNull(n,void 0),toBlock:ny.allowNull(n,void 0),blockHash:ny.allowNull(o,void 0),address:ny.allowNull(e,void 0),topics:ny.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:ny.allowNull(a),blockHash:ny.allowNull(o),transactionIndex:a,removed:ny.allowNull(this.boolean.bind(this)),address:e,data:ny.allowFalsish(i,"0x"),topics:ny.arrayOf(o),transactionHash:o,logIndex:a},t}accessList(t){return Qg(t||[])}number(t){return"0x"===t?0:me.from(t).toNumber()}bigNumber(t){return me.from(t)}boolean(t){if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===(t=t.toLowerCase()))return!0;if("false"===t)return!1}throw new Error("invalid boolean - "+t)}hex(t,e){return"string"==typeof t&&(e||"0x"===t.substring(0,2)||(t="0x"+t),ed(t))?t.toLowerCase():ry.throwArgumentError("invalid hash","value",t)}data(t,e){const r=this.hex(t,e);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+t);return r}address(t){return On(t)}callAddress(t){if(!ed(t,32))return null;const e=On(id(t,12));return"0x0000000000000000000000000000000000000000"===e?null:e}contractAddress(t){return Cn(t)}blockTag(t){if(null==t)return"latest";if("earliest"===t)return"0x0";if("latest"===t||"pending"===t)return t;if("number"==typeof t||ed(t))return sd(t);throw new Error("invalid blockTag")}hash(t,e){const r=this.hex(t,e);return 32!==nd(r)?ry.throwArgumentError("invalid hash","value",t):r}difficulty(t){if(null==t)return null;const e=me.from(t);try{return e.toNumber()}catch(t){}return null}uint256(t){if(!ed(t))throw new Error("invalid uint256");return ad(t,32)}_block(t,e){return null!=t.author&&null==t.miner&&(t.miner=t.author),ny.check(e,t)}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return ny.check(this.formats.transactionRequest,t)}transactionResponse(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&me.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t)),1===t.type&&null==t.accessList&&(t.accessList=[]);const e=ny.check(this.formats.transaction,t);if(null!=t.chainId){let r=t.chainId;ed(r)&&(r=me.from(r).toNumber()),e.chainId=r}else{let r=t.networkId;null==r&&null==e.v&&(r=t.chainId),ed(r)&&(r=me.from(r).toNumber()),"number"!=typeof r&&null!=e.v&&(r=(e.v-35)/2,r<0&&(r=0),r=parseInt(r)),"number"!=typeof r&&(r=0),e.chainId=r}return e.blockHash&&"x"===e.blockHash.replace(/0/g,"")&&(e.blockHash=null),e}transaction(t){return ey(t)}receiptLog(t){return ny.check(this.formats.receiptLog,t)}receipt(t){const e=ny.check(this.formats.receipt,t);if(null!=e.root)if(e.root.length<=4){const t=me.from(e.root).toNumber();0===t||1===t?(null!=e.status&&e.status!==t&&ry.throwArgumentError("alt-root-status/status mismatch","value",{root:e.root,status:e.status}),e.status=t,delete e.root):ry.throwArgumentError("invalid alt-root-status","value.root",e.root)}else 66!==e.root.length&&ry.throwArgumentError("invalid root hash","value.root",e.root);return null!=e.status&&(e.byzantium=!0),e}topics(t){return Array.isArray(t)?t.map(t=>this.topics(t)):null!=t?this.hash(t,!0):null}filter(t){return ny.check(this.formats.filter,t)}filterLog(t){return ny.check(this.formats.filterLog,t)}static check(t,e){const r={};for(const n in t)try{const i=t[n](e[n]);void 0!==i&&(r[n]=i)}catch(t){throw t.checkKey=n,t.checkValue=e[n],t}return r}static allowNull(t,e){return function(r){return null==r?e:t(r)}}static allowFalsish(t,e){return function(r){return r?t(r):e}}static arrayOf(t){return function(e){if(!Array.isArray(e))throw new Error("not an array");const r=[];return e.forEach((function(e){r.push(t(e))})),r}}}var iy=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const oy=new Wc(ng);function sy(t){return null==t?"null":(32!==nd(t)&&oy.throwArgumentError("invalid topic","topic",t),t.toLowerCase())}function ay(t){for(t=t.slice();t.length>0&&null==t[t.length-1];)t.pop();return t.map(t=>{if(Array.isArray(t)){const e={};t.forEach(t=>{e[sy(t)]=!0});const r=Object.keys(e);return r.sort(),r.join("|")}return sy(t)}).join("&")}function hy(t){if("string"==typeof t){if(32===nd(t=t.toLowerCase()))return"tx:"+t;if(-1===t.indexOf(":"))return t}else{if(Array.isArray(t))return"filter:*:"+ay(t);if(class extends class{constructor(t){for(const e in t)this[e]=Vo(t[e])}}{static isForkEvent(t){return!(!t||!t._isForkEvent)}}.isForkEvent(t))throw oy.warn("not implemented"),new Error("not implemented");if(t&&"object"==typeof t)return"filter:"+(t.address||"*")+":"+ay(t.topics||[])}throw new Error("invalid event - "+t)}function uy(){return(new Date).getTime()}function ly(t){return new Promise(e=>{setTimeout(e,t)})}const fy=["block","network","pending","poll"];class cy{constructor(t,e,r){fd(this,"tag",t),fd(this,"listener",e),fd(this,"once",r)}get event(){switch(this.type){case"tx":return this.hash;case"filter":return this.filter}return this.tag}get type(){return this.tag.split(":")[0]}get hash(){const t=this.tag.split(":");return"tx"!==t[0]?null:t[1]}get filter(){const t=this.tag.split(":");if("filter"!==t[0])return null;const e=t[1],r=""===(n=t[2])?[]:n.split(/&/g).map(t=>{if(""===t)return[];const e=t.split("|").map(t=>"null"===t?null:t);return 1===e.length?e[0]:e});var n;const i={};return r.length>0&&(i.topics=r),e&&"*"!==e&&(i.address=e),i}pollable(){return this.tag.indexOf(":")>=0||fy.indexOf(this.tag)>=0}}const dy={0:{symbol:"btc",p2pkh:0,p2sh:5,prefix:"bc"},2:{symbol:"ltc",p2pkh:48,p2sh:50,prefix:"ltc"},3:{symbol:"doge",p2pkh:30,p2sh:22},60:{symbol:"eth",ilk:"eth"},61:{symbol:"etc",ilk:"eth"},700:{symbol:"xdai",ilk:"eth"}};function my(t){return ad(me.from(t).toHexString(),32)}function py(t){return Lc.encode(Qc([t,id(Xm(Xm(t)),0,4)]))}class gy{constructor(t,e,r){fd(this,"provider",t),fd(this,"name",r),fd(this,"address",t.formatter.address(e))}_fetchBytes(t,e){return iy(this,void 0,void 0,(function*(){const r={to:this.address,data:od([t,to(this.name),e||"0x"])},n=yield this.provider.call(r);if("0x"===n)return null;const i=me.from(id(n,0,32)).toNumber(),o=me.from(id(n,i,i+32)).toNumber();return id(n,i+32,i+32+o)}))}_getAddress(t,e){const r=dy[String(t)];if(null==r&&oy.throwError("unsupported coin type: "+t,Wc.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`}),"eth"===r.ilk)return this.provider.formatter.address(e);const n=Yc(e);if(null!=r.p2pkh){const t=e.match(/^0x76a9([0-9a-f][0-9a-f])([0-9a-f]*)88ac$/);if(t){const e=parseInt(t[1],16);if(t[2].length===2*e&&e>=1&&e<=75)return py(Qc([[r.p2pkh],"0x"+t[2]]))}}if(null!=r.p2sh){const t=e.match(/^0xa9([0-9a-f][0-9a-f])([0-9a-f]*)87$/);if(t){const e=parseInt(t[1],16);if(t[2].length===2*e&&e>=1&&e<=75)return py(Qc([[r.p2sh],"0x"+t[2]]))}}if(null!=r.prefix){const t=n[1];let e=n[0];if(0===e?20!==t&&32!==t&&(e=-1):e=-1,e>=0&&n.length===2+t&&t>=1&&t<=75){const t=rg.toWords(n.slice(2));return t.unshift(e),rg.encode(r.prefix,t)}}return null}getAddress(t){return iy(this,void 0,void 0,(function*(){if(null==t&&(t=60),60===t){const t={to:this.address,data:"0x3b3b57de"+to(this.name).substring(2)},e=yield this.provider.call(t);return"0x"===e||"0x0000000000000000000000000000000000000000000000000000000000000000"===e?null:this.provider.formatter.callAddress(e)}const e=yield this._fetchBytes("0xf1cb7e06",my(t));if(null==e||"0x"===e)return null;const r=this._getAddress(t,e);return null==r&&oy.throwError("invalid or unsupported coin data",Wc.errors.UNSUPPORTED_OPERATION,{operation:`getAddress(${t})`,coinType:t,data:e}),r}))}getContentHash(){return iy(this,void 0,void 0,(function*(){const t=yield this._fetchBytes("0xbc1c58d1");if(null==t||"0x"===t)return null;const e=t.match(/^0xe3010170(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const t=parseInt(e[3],16);if(e[4].length===2*t)return"ipfs://"+Lc.encode("0x"+e[1])}const r=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);return r&&64===r[1].length?"bzz://"+r[1]:oy.throwError("invalid or unsupported content hash data",Wc.errors.UNSUPPORTED_OPERATION,{operation:"getContentHash()",data:t})}))}getText(t){return iy(this,void 0,void 0,(function*(){let e=rp(t);e=Qc([my(64),my(e.length),e]),e.length%32!=0&&(e=Qc([e,ad("0x",32-t.length%32)]));const r=yield this._fetchBytes("0x59d1d43c",rd(e));return null==r||"0x"===r?null:np(r)}))}}let yy=null,vy=1;class wy extends Wo{constructor(t){if(oy.checkNew(new.target,Wo),super(),this._events=[],this._emitted={block:-2},this.formatter=new.target.getFormatter(),fd(this,"anyNetwork","any"===t),this.anyNetwork&&(t=this.detectNetwork()),t instanceof Promise)this._networkPromise=t,t.catch(t=>{}),this._ready().catch(t=>{});else{const e=cd(new.target,"getNetwork")(t);e?(fd(this,"_network",e),this.emit("network",e,null)):oy.throwArgumentError("invalid network","network",t)}this._maxInternalBlockNumber=-1024,this._lastBlockNumber=-2,this._pollingInterval=4e3,this._fastQueryDate=0}_ready(){return iy(this,void 0,void 0,(function*(){if(null==this._network){let t=null;if(this._networkPromise)try{t=yield this._networkPromise}catch(t){}null==t&&(t=yield this.detectNetwork()),t||oy.throwError("no network detected",Wc.errors.UNKNOWN_ERROR,{}),null==this._network&&(this.anyNetwork?this._network=t:fd(this,"_network",t),this.emit("network",t,null))}return this._network}))}get ready(){return Wp(()=>this._ready().then(t=>t,t=>{if(t.code!==Wc.errors.NETWORK_ERROR||"noNetwork"!==t.event)throw t}))}static getFormatter(){return null==yy&&(yy=new ny),yy}static getNetwork(t){return function(t){if(null==t)return null;if("number"==typeof t){for(const e in _c){const r=_c[e];if(r.chainId===t)return{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress||null,_defaultProvider:r._defaultProvider||null}}return{chainId:t,name:"unknown"}}if("string"==typeof t){const e=_c[t];return null==e?null:{name:e.name,chainId:e.chainId,ensAddress:e.ensAddress,_defaultProvider:e._defaultProvider||null}}const e=_c[t.name];if(!e)return"number"!=typeof t.chainId&&yc.throwArgumentError("invalid network chainId","network",t),t;0!==t.chainId&&t.chainId!==e.chainId&&yc.throwArgumentError("network chainId mismatch","network",t);let r=t._defaultProvider||null;var n;return null==r&&e._defaultProvider&&(r=(n=e._defaultProvider)&&"function"==typeof n.renetwork?e._defaultProvider.renetwork(t):e._defaultProvider),{name:t.name,chainId:e.chainId,ensAddress:t.ensAddress||e.ensAddress||null,_defaultProvider:r}}(null==t?"homestead":t)}_getInternalBlockNumber(t){return iy(this,void 0,void 0,(function*(){if(yield this._ready(),t>0)for(;this._internalBlockNumber;){const e=this._internalBlockNumber;try{const r=yield e;if(uy()-r.respTime<=t)return r.blockNumber;break}catch(t){if(this._internalBlockNumber===e)break}}const e=uy(),r=dd({blockNumber:this.perform("getBlockNumber",{}),networkError:this.getNetwork().then(t=>null,t=>t)}).then(({blockNumber:t,networkError:n})=>{if(n)throw this._internalBlockNumber===r&&(this._internalBlockNumber=null),n;const i=uy();return(t=me.from(t).toNumber())<this._maxInternalBlockNumber&&(t=this._maxInternalBlockNumber),this._maxInternalBlockNumber=t,this._setFastBlockNumber(t),{blockNumber:t,reqTime:e,respTime:i}});return this._internalBlockNumber=r,r.catch(t=>{this._internalBlockNumber===r&&(this._internalBlockNumber=null)}),(yield r).blockNumber}))}poll(){return iy(this,void 0,void 0,(function*(){const t=vy++,e=[];let r=null;try{r=yield this._getInternalBlockNumber(100+this.pollingInterval/2)}catch(t){return void this.emit("error",t)}if(this._setFastBlockNumber(r),this.emit("poll",t,r),r!==this._lastBlockNumber){if(-2===this._emitted.block&&(this._emitted.block=r-1),Math.abs(this._emitted.block-r)>1e3)oy.warn(`network block skew detected; skipping block events (emitted=${this._emitted.block} blockNumber${r})`),this.emit("error",oy.makeError("network block skew detected",Wc.errors.NETWORK_ERROR,{blockNumber:r,event:"blockSkew",previousBlockNumber:this._emitted.block})),this.emit("block",r);else for(let t=this._emitted.block+1;t<=r;t++)this.emit("block",t);this._emitted.block!==r&&(this._emitted.block=r,Object.keys(this._emitted).forEach(t=>{if("block"===t)return;const e=this._emitted[t];"pending"!==e&&r-e>12&&delete this._emitted[t]})),-2===this._lastBlockNumber&&(this._lastBlockNumber=r-1),this._events.forEach(t=>{switch(t.type){case"tx":{const r=t.hash;let n=this.getTransactionReceipt(r).then(t=>t&&null!=t.blockNumber?(this._emitted["t:"+r]=t.blockNumber,this.emit(r,t),null):null).catch(t=>{this.emit("error",t)});e.push(n);break}case"filter":{const n=t.filter;n.fromBlock=this._lastBlockNumber+1,n.toBlock=r;const i=this.getLogs(n).then(t=>{0!==t.length&&t.forEach(t=>{this._emitted["b:"+t.blockHash]=t.blockNumber,this._emitted["t:"+t.transactionHash]=t.blockNumber,this.emit(n,t)})}).catch(t=>{this.emit("error",t)});e.push(i);break}}}),this._lastBlockNumber=r,Promise.all(e).then(()=>{this.emit("didPoll",t)}).catch(t=>{this.emit("error",t)})}else this.emit("didPoll",t)}))}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}detectNetwork(){return iy(this,void 0,void 0,(function*(){return oy.throwError("provider does not support network detection",Wc.errors.UNSUPPORTED_OPERATION,{operation:"provider.detectNetwork"})}))}getNetwork(){return iy(this,void 0,void 0,(function*(){const t=yield this._ready(),e=yield this.detectNetwork();if(t.chainId!==e.chainId){if(this.anyNetwork)return this._network=e,this._lastBlockNumber=-2,this._fastBlockNumber=null,this._fastBlockNumberPromise=null,this._fastQueryDate=0,this._emitted.block=-2,this._maxInternalBlockNumber=-1024,this._internalBlockNumber=null,this.emit("network",e,t),yield ly(0),this._network;const r=oy.makeError("underlying network changed",Wc.errors.NETWORK_ERROR,{event:"changed",network:t,detectedNetwork:e});throw this.emit("error",r),r}return t}))}get blockNumber(){return this._getInternalBlockNumber(100+this.pollingInterval/2).then(t=>{this._setFastBlockNumber(t)},t=>{}),null!=this._fastBlockNumber?this._fastBlockNumber:-1}get polling(){return null!=this._poller}set polling(t){t&&!this._poller?(this._poller=setInterval(()=>{this.poll()},this.pollingInterval),this._bootstrapPoll||(this._bootstrapPoll=setTimeout(()=>{this.poll(),this._bootstrapPoll=setTimeout(()=>{this._poller||this.poll(),this._bootstrapPoll=null},this.pollingInterval)},0))):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if("number"!=typeof t||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){const t=uy();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(t=>((null==this._fastBlockNumber||t>this._fastBlockNumber)&&(this._fastBlockNumber=t),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){null!=this._fastBlockNumber&&t<this._fastBlockNumber||(this._fastQueryDate=uy(),(null==this._fastBlockNumber||t>this._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,e,r){return iy(this,void 0,void 0,(function*(){return this._waitForTransaction(t,null==e?1:e,r||0,null)}))}_waitForTransaction(t,e,r,n){return iy(this,void 0,void 0,(function*(){const i=yield this.getTransactionReceipt(t);return(i?i.confirmations:0)>=e?i:new Promise((i,o)=>{const s=[];let a=!1;const h=function(){return!!a||(a=!0,s.forEach(t=>{t()}),!1)},u=t=>{t.confirmations<e||h()||i(t)};if(this.on(t,u),s.push(()=>{this.removeListener(t,u)}),n){let r=n.startBlock,i=null;const u=s=>iy(this,void 0,void 0,(function*(){a||(yield ly(1e3),this.getTransactionCount(n.from).then(l=>iy(this,void 0,void 0,(function*(){if(!a){if(l<=n.nonce)r=s;else{{const e=yield this.getTransaction(t);if(e&&null!=e.blockNumber)return}for(null==i&&(i=r-3,i<n.startBlock&&(i=n.startBlock));i<=s;){if(a)return;const r=yield this.getBlockWithTransactions(i);for(let i=0;i<r.transactions.length;i++){const s=r.transactions[i];if(s.hash===t)return;if(s.from===n.from&&s.nonce===n.nonce){if(a)return;const r=yield this.waitForTransaction(s.hash,e);if(h())return;let i="replaced";return s.data===n.data&&s.to===n.to&&s.value.eq(n.value)?i="repriced":"0x"===s.data&&s.from===s.to&&s.value.isZero()&&(i="cancelled"),void o(oy.makeError("transaction was replaced",Wc.errors.TRANSACTION_REPLACED,{cancelled:"replaced"===i||"cancelled"===i,reason:i,replacement:this._wrapTransaction(s),hash:t,receipt:r}))}}i++}}a||this.once("block",u)}})),t=>{a||this.once("block",u)}))}));if(a)return;this.once("block",u),s.push(()=>{this.removeListener("block",u)})}if("number"==typeof r&&r>0){const t=setTimeout(()=>{h()||o(oy.makeError("timeout exceeded",Wc.errors.TIMEOUT,{timeout:r}))},r);t.unref&&t.unref(),s.push(()=>{clearTimeout(t)})}})}))}getBlockNumber(){return iy(this,void 0,void 0,(function*(){return this._getInternalBlockNumber(0)}))}getGasPrice(){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const t=yield this.perform("getGasPrice",{});try{return me.from(t)}catch(e){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"getGasPrice",result:t,error:e})}}))}getBalance(t,e){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield dd({address:this._getAddress(t),blockTag:this._getBlockTag(e)}),n=yield this.perform("getBalance",r);try{return me.from(n)}catch(t){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"getBalance",params:r,result:n,error:t})}}))}getTransactionCount(t,e){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield dd({address:this._getAddress(t),blockTag:this._getBlockTag(e)}),n=yield this.perform("getTransactionCount",r);try{return me.from(n).toNumber()}catch(t){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"getTransactionCount",params:r,result:n,error:t})}}))}getCode(t,e){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield dd({address:this._getAddress(t),blockTag:this._getBlockTag(e)}),n=yield this.perform("getCode",r);try{return rd(n)}catch(t){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"getCode",params:r,result:n,error:t})}}))}getStorageAt(t,e,r){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const n=yield dd({address:this._getAddress(t),blockTag:this._getBlockTag(r),position:Promise.resolve(e).then(t=>sd(t))}),i=yield this.perform("getStorageAt",n);try{return rd(i)}catch(t){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"getStorageAt",params:n,result:i,error:t})}}))}_wrapTransaction(t,e,r){if(null!=e&&32!==nd(e))throw new Error("invalid response - sendTransaction");const n=t;return null!=e&&t.hash!==e&&oy.throwError("Transaction hash mismatch from Provider.sendTransaction.",Wc.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:e}),n.wait=(e,n)=>iy(this,void 0,void 0,(function*(){null==e&&(e=1),null==n&&(n=0);let i=void 0;0!==e&&null!=r&&(i={data:t.data,from:t.from,nonce:t.nonce,to:t.to,value:t.value,startBlock:r});const o=yield this._waitForTransaction(t.hash,e,n,i);return null==o&&0===e?null:(this._emitted["t:"+t.hash]=o.blockNumber,0===o.status&&oy.throwError("transaction failed",Wc.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:o}),o)})),n}sendTransaction(t){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const e=yield Promise.resolve(t).then(t=>rd(t)),r=this.formatter.transaction(t),n=yield this._getInternalBlockNumber(100+2*this.pollingInterval);try{const t=yield this.perform("sendTransaction",{signedTransaction:e});return this._wrapTransaction(r,t,n)}catch(t){throw t.transaction=r,t.transactionHash=r.hash,t}}))}_getTransactionRequest(t){return iy(this,void 0,void 0,(function*(){const e=yield t,r={};return["from","to"].forEach(t=>{null!=e[t]&&(r[t]=Promise.resolve(e[t]).then(t=>t?this._getAddress(t):null))}),["gasLimit","gasPrice","value"].forEach(t=>{null!=e[t]&&(r[t]=Promise.resolve(e[t]).then(t=>t?me.from(t):null))}),["type"].forEach(t=>{null!=e[t]&&(r[t]=Promise.resolve(e[t]).then(t=>null!=t?t:null))}),e.accessList&&(r.accessList=this.formatter.accessList(e.accessList)),["data"].forEach(t=>{null!=e[t]&&(r[t]=Promise.resolve(e[t]).then(t=>t?rd(t):null))}),this.formatter.transactionRequest(yield dd(r))}))}_getFilter(t){return iy(this,void 0,void 0,(function*(){t=yield t;const e={};return null!=t.address&&(e.address=this._getAddress(t.address)),["blockHash","topics"].forEach(r=>{null!=t[r]&&(e[r]=t[r])}),["fromBlock","toBlock"].forEach(r=>{null!=t[r]&&(e[r]=this._getBlockTag(t[r]))}),this.formatter.filter(yield dd(e))}))}call(t,e){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const r=yield dd({transaction:this._getTransactionRequest(t),blockTag:this._getBlockTag(e)}),n=yield this.perform("call",r);try{return rd(n)}catch(t){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"call",params:r,result:n,error:t})}}))}estimateGas(t){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const e=yield dd({transaction:this._getTransactionRequest(t)}),r=yield this.perform("estimateGas",e);try{return me.from(r)}catch(t){return oy.throwError("bad result from backend",Wc.errors.SERVER_ERROR,{method:"estimateGas",params:e,result:r,error:t})}}))}_getAddress(t){return iy(this,void 0,void 0,(function*(){const e=yield this.resolveName(t);return null==e&&oy.throwError("ENS name not configured",Wc.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),e}))}_getBlock(t,e){return iy(this,void 0,void 0,(function*(){yield this.getNetwork(),t=yield t;let r=-128;const n={includeTransactions:!!e};if(ed(t,32))n.blockHash=t;else try{n.blockTag=this.formatter.blockTag(yield this._getBlockTag(t)),ed(n.blockTag)&&(r=parseInt(n.blockTag.substring(2),16))}catch(e){oy.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return Wp(()=>iy(this,void 0,void 0,(function*(){const t=yield this.perform("getBlock",n);if(null==t)return null!=n.blockHash&&null==this._emitted["b:"+n.blockHash]||null!=n.blockTag&&r>this._emitted.block?null:void 0;if(e){let e=null;for(let r=0;r<t.transactions.length;r++){const n=t.transactions[r];if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){null==e&&(e=yield this._getInternalBlockNumber(100+2*this.pollingInterval));let t=e-n.blockNumber+1;t<=0&&(t=1),n.confirmations=t}}return this.formatter.blockWithTransactions(t)}return this.formatter.block(t)})),{oncePoll:this})}))}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return iy(this,void 0,void 0,(function*(){yield this.getNetwork(),t=yield t;const e={transactionHash:this.formatter.hash(t,!0)};return Wp(()=>iy(this,void 0,void 0,(function*(){const r=yield this.perform("getTransaction",e);if(null==r)return null==this._emitted["t:"+t]?null:void 0;const n=this.formatter.transactionResponse(r);if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){let t=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-n.blockNumber+1;t<=0&&(t=1),n.confirmations=t}return this._wrapTransaction(n)})),{oncePoll:this})}))}getTransactionReceipt(t){return iy(this,void 0,void 0,(function*(){yield this.getNetwork(),t=yield t;const e={transactionHash:this.formatter.hash(t,!0)};return Wp(()=>iy(this,void 0,void 0,(function*(){const r=yield this.perform("getTransactionReceipt",e);if(null==r)return null==this._emitted["t:"+t]?null:void 0;if(null==r.blockHash)return;const n=this.formatter.receipt(r);if(null==n.blockNumber)n.confirmations=0;else if(null==n.confirmations){let t=(yield this._getInternalBlockNumber(100+2*this.pollingInterval))-n.blockNumber+1;t<=0&&(t=1),n.confirmations=t}return n})),{oncePoll:this})}))}getLogs(t){return iy(this,void 0,void 0,(function*(){yield this.getNetwork();const e=yield dd({filter:this._getFilter(t)}),r=yield this.perform("getLogs",e);return r.forEach(t=>{null==t.removed&&(t.removed=!1)}),ny.arrayOf(this.formatter.filterLog.bind(this.formatter))(r)}))}getEtherPrice(){return iy(this,void 0,void 0,(function*(){return yield this.getNetwork(),this.perform("getEtherPrice",{})}))}_getBlockTag(t){return iy(this,void 0,void 0,(function*(){if("number"==typeof(t=yield t)&&t<0){t%1&&oy.throwArgumentError("invalid BlockTag","blockTag",t);let e=yield this._getInternalBlockNumber(100+2*this.pollingInterval);return e+=t,e<0&&(e=0),this.formatter.blockTag(e)}return this.formatter.blockTag(t)}))}getResolver(t){return iy(this,void 0,void 0,(function*(){const e=yield this._getResolver(t);return null==e?null:new gy(this,e,t)}))}_getResolver(t){return iy(this,void 0,void 0,(function*(){const e=yield this.getNetwork();e.ensAddress||oy.throwError("network does not support ENS",Wc.errors.UNSUPPORTED_OPERATION,{operation:"ENS",network:e.name});const r={to:e.ensAddress,data:"0x0178b8bf"+to(t).substring(2)};return this.formatter.callAddress(yield this.call(r))}))}resolveName(t){return iy(this,void 0,void 0,(function*(){t=yield t;try{return Promise.resolve(this.formatter.address(t))}catch(e){if(ed(t))throw e}"string"!=typeof t&&oy.throwArgumentError("invalid ENS name","name",t);const e=yield this.getResolver(t);return e?yield e.getAddress():null}))}lookupAddress(t){return iy(this,void 0,void 0,(function*(){t=yield t;const e=(t=this.formatter.address(t)).substring(2).toLowerCase()+".addr.reverse",r=yield this._getResolver(e);if(!r)return null;let n=Yc(yield this.call({to:r,data:"0x691f3431"+to(e).substring(2)}));if(n.length<32||!me.from(n.slice(0,32)).eq(32))return null;if(n=n.slice(32),n.length<32)return null;const i=me.from(n.slice(0,32)).toNumber();if(n=n.slice(32),i>n.length)return null;const o=np(n.slice(0,i));return(yield this.resolveName(o))!=t?null:o}))}perform(t,e){return oy.throwError(t+" not implemented",Wc.errors.NOT_IMPLEMENTED,{operation:t})}_startEvent(t){this.polling=this._events.filter(t=>t.pollable()).length>0}_stopEvent(t){this.polling=this._events.filter(t=>t.pollable()).length>0}_addEventListener(t,e,r){const n=new cy(hy(t),e,r);return this._events.push(n),this._startEvent(n),this}on(t,e){return this._addEventListener(t,e,!1)}once(t,e){return this._addEventListener(t,e,!0)}emit(t,...e){let r=!1,n=[],i=hy(t);return this._events=this._events.filter(t=>t.tag!==i||(setTimeout(()=>{t.listener.apply(this,e)},0),r=!0,!t.once||(n.push(t),!1))),n.forEach(t=>{this._stopEvent(t)}),r}listenerCount(t){if(!t)return this._events.length;let e=hy(t);return this._events.filter(t=>t.tag===e).length}listeners(t){if(null==t)return this._events.map(t=>t.listener);let e=hy(t);return this._events.filter(t=>t.tag===e).map(t=>t.listener)}off(t,e){if(null==e)return this.removeAllListeners(t);const r=[];let n=!1,i=hy(t);return this._events=this._events.filter(t=>t.tag!==i||t.listener!=e||(!!n||(n=!0,r.push(t),!1))),r.forEach(t=>{this._stopEvent(t)}),this}removeAllListeners(t){let e=[];if(null==t)e=this._events,this._events=[];else{const r=hy(t);this._events=this._events.filter(t=>t.tag!==r||(e.push(t),!1))}return e.forEach(t=>{this._stopEvent(t)}),this}}var by=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const Ey=new Wc("abstract-signer/5.3.0"),My=["accessList","chainId","data","from","gasLimit","gasPrice","nonce","to","type","value"],_y=[Wc.errors.INSUFFICIENT_FUNDS,Wc.errors.NONCE_EXPIRED,Wc.errors.REPLACEMENT_UNDERPRICED];class Ay{constructor(){Ey.checkAbstract(new.target,Ay),fd(this,"_isSigner",!0)}getBalance(t){return by(this,void 0,void 0,(function*(){return this._checkProvider("getBalance"),yield this.provider.getBalance(this.getAddress(),t)}))}getTransactionCount(t){return by(this,void 0,void 0,(function*(){return this._checkProvider("getTransactionCount"),yield this.provider.getTransactionCount(this.getAddress(),t)}))}estimateGas(t){return by(this,void 0,void 0,(function*(){this._checkProvider("estimateGas");const e=yield dd(this.checkTransaction(t));return yield this.provider.estimateGas(e)}))}call(t,e){return by(this,void 0,void 0,(function*(){this._checkProvider("call");const r=yield dd(this.checkTransaction(t));return yield this.provider.call(r,e)}))}sendTransaction(t){return this._checkProvider("sendTransaction"),this.populateTransaction(t).then(t=>this.signTransaction(t).then(t=>this.provider.sendTransaction(t)))}getChainId(){return by(this,void 0,void 0,(function*(){this._checkProvider("getChainId");return(yield this.provider.getNetwork()).chainId}))}getGasPrice(){return by(this,void 0,void 0,(function*(){return this._checkProvider("getGasPrice"),yield this.provider.getGasPrice()}))}resolveName(t){return by(this,void 0,void 0,(function*(){return this._checkProvider("resolveName"),yield this.provider.resolveName(t)}))}checkTransaction(t){for(const e in t)-1===My.indexOf(e)&&Ey.throwArgumentError("invalid transaction key: "+e,"transaction",t);const e=md(t);return null==e.from?e.from=this.getAddress():e.from=Promise.all([Promise.resolve(e.from),this.getAddress()]).then(e=>(e[0].toLowerCase()!==e[1].toLowerCase()&&Ey.throwArgumentError("from address mismatch","transaction",t),e[0])),e}populateTransaction(t){return by(this,void 0,void 0,(function*(){const e=yield dd(this.checkTransaction(t));return null!=e.to&&(e.to=Promise.resolve(e.to).then(t=>by(this,void 0,void 0,(function*(){if(null==t)return null;const e=yield this.resolveName(t);return null==e&&Ey.throwArgumentError("provided ENS name resolves to null","tx.to",t),e})))),null==e.gasPrice&&(e.gasPrice=this.getGasPrice()),null==e.nonce&&(e.nonce=this.getTransactionCount("pending")),null==e.gasLimit&&(e.gasLimit=this.estimateGas(e).catch(t=>{if(_y.indexOf(t.code)>=0)throw t;return Ey.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Wc.errors.UNPREDICTABLE_GAS_LIMIT,{error:t,tx:e})})),null==e.chainId?e.chainId=this.getChainId():e.chainId=Promise.all([Promise.resolve(e.chainId),this.getChainId()]).then(e=>(0!==e[1]&&e[0]!==e[1]&&Ey.throwArgumentError("chainId address mismatch","transaction",t),e[0])),yield dd(e)}))}_checkProvider(t){this.provider||Ey.throwError("missing provider",Wc.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!(!t||!t._isSigner)}}var Ny=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const Sy=new Wc(ng),Ry=["call","estimateGas"];function Uy(t,e,r){if("call"===t&&e.code===Wc.errors.SERVER_ERROR){const t=e.error;if(t&&t.message.match("reverted")&&ed(t.data))return t.data}let n=e.message;e.code===Wc.errors.SERVER_ERROR&&e.error&&"string"==typeof e.error.message?n=e.error.message:"string"==typeof e.body?n=e.body:"string"==typeof e.responseText&&(n=e.responseText),n=(n||"").toLowerCase();const i=r.transaction||r.signedTransaction;throw n.match(/insufficient funds/)&&Sy.throwError("insufficient funds for intrinsic transaction cost",Wc.errors.INSUFFICIENT_FUNDS,{error:e,method:t,transaction:i}),n.match(/nonce too low/)&&Sy.throwError("nonce has already been used",Wc.errors.NONCE_EXPIRED,{error:e,method:t,transaction:i}),n.match(/replacement transaction underpriced/)&&Sy.throwError("replacement fee too low",Wc.errors.REPLACEMENT_UNDERPRICED,{error:e,method:t,transaction:i}),n.match(/only replay-protected/)&&Sy.throwError("legacy pre-eip-155 transactions not supported",Wc.errors.UNSUPPORTED_OPERATION,{error:e,method:t,transaction:i}),Ry.indexOf(t)>=0&&n.match(/gas required exceeds allowance|always failing transaction|execution reverted/)&&Sy.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",Wc.errors.UNPREDICTABLE_GAS_LIMIT,{error:e,method:t,transaction:i}),e}function Iy(t){return new Promise((function(e){setTimeout(e,t)}))}function Py(t){if(t.error){const e=new Error(t.error.message);throw e.code=t.error.code,e.data=t.error.data,e}return t.result}function xy(t){return t?t.toLowerCase():t}const ky={};class Ty extends Ay{constructor(t,e,r){if(Sy.checkNew(new.target,Ty),super(),t!==ky)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");fd(this,"provider",e),null==r&&(r=0),"string"==typeof r?(fd(this,"_address",this.provider.formatter.address(r)),fd(this,"_index",null)):"number"==typeof r?(fd(this,"_index",r),fd(this,"_address",null)):Sy.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(t){return Sy.throwError("cannot alter JSON-RPC Signer connection",Wc.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new Oy(ky,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&Sy.throwError("unknown account #"+this._index,Wc.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=md(t);const e=this.getAddress().then(t=>(t&&(t=t.toLowerCase()),t));if(null==t.gasLimit){const r=md(t);r.from=e,t.gasLimit=this.provider.estimateGas(r)}return dd({tx:dd(t),sender:e}).then(({tx:e,sender:r})=>{null!=e.from?e.from.toLowerCase()!==r&&Sy.throwArgumentError("from address mismatch","transaction",t):e.from=r;const n=this.provider.constructor.hexlifyTransaction(e,{from:!0});return this.provider.send("eth_sendTransaction",[n]).then(t=>t,t=>Uy("sendTransaction",t,n))})}signTransaction(t){return Sy.throwError("signing transactions is unsupported",Wc.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return Ny(this,void 0,void 0,(function*(){const e=yield this.provider._getInternalBlockNumber(100+2*this.provider.pollingInterval),r=yield this.sendUncheckedTransaction(t);try{return yield Wp(()=>Ny(this,void 0,void 0,(function*(){const t=yield this.provider.getTransaction(r);if(null!==t)return this.provider._wrapTransaction(t,r,e)})),{oncePoll:this.provider})}catch(t){throw t.transactionHash=r,t}}))}signMessage(t){return Ny(this,void 0,void 0,(function*(){const e="string"==typeof t?rp(t):t,r=yield this.getAddress();return yield this.provider.send("eth_sign",[r.toLowerCase(),rd(e)])}))}_signTypedData(t,e,r){return Ny(this,void 0,void 0,(function*(){const n=yield _o.resolveNames(t,e,r,t=>this.provider.resolveName(t)),i=yield this.getAddress();return yield this.provider.send("eth_signTypedData_v4",[i.toLowerCase(),JSON.stringify(_o.getPayload(n.domain,e,n.value))])}))}unlock(t){return Ny(this,void 0,void 0,(function*(){const e=this.provider,r=yield this.getAddress();return e.send("personal_unlockAccount",[r.toLowerCase(),t,null])}))}}class Oy extends Ty{sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>({hash:t,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:e=>this.provider.waitForTransaction(t,e)}))}}const Cy={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0,type:!0,accessList:!0};class Fy extends wy{constructor(t,e){Sy.checkNew(new.target,Fy);let r=e;null==r&&(r=new Promise((t,e)=>{setTimeout(()=>{this.detectNetwork().then(e=>{t(e)},t=>{e(t)})},0)})),super(r),t||(t=cd(this.constructor,"defaultUrl")()),fd(this,"connection","string"==typeof t?Object.freeze({url:t}):Object.freeze(md(t))),this._nextId=42}get _cache(){return null==this._eventLoopCache&&(this._eventLoopCache={}),this._eventLoopCache}static defaultUrl(){return"http://localhost:8545"}detectNetwork(){return this._cache.detectNetwork||(this._cache.detectNetwork=this._uncachedDetectNetwork(),setTimeout(()=>{this._cache.detectNetwork=null},0)),this._cache.detectNetwork}_uncachedDetectNetwork(){return Ny(this,void 0,void 0,(function*(){yield Iy(0);let t=null;try{t=yield this.send("eth_chainId",[])}catch(e){try{t=yield this.send("net_version",[])}catch(t){}}if(null!=t){const e=cd(this.constructor,"getNetwork");try{return e(me.from(t).toNumber())}catch(e){return Sy.throwError("could not detect network",Wc.errors.NETWORK_ERROR,{chainId:t,event:"invalidNetwork",serverError:e})}}return Sy.throwError("could not detect network",Wc.errors.NETWORK_ERROR,{event:"noNetwork"})}))}getSigner(t){return new Ty(ky,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(t=>this.formatter.address(t)))}send(t,e){const r={method:t,params:e,id:this._nextId++,jsonrpc:"2.0"};this.emit("debug",{action:"request",request:yd(r),provider:this});const n=["eth_chainId","eth_blockNumber"].indexOf(t)>=0;if(n&&this._cache[t])return this._cache[t];const i=Kp(this.connection,JSON.stringify(r),Py).then(t=>(this.emit("debug",{action:"response",request:r,response:t,provider:this}),t),t=>{throw this.emit("debug",{action:"response",error:t,request:r,provider:this}),t});return n&&(this._cache[t]=i,setTimeout(()=>{this._cache[t]=null},0)),i}prepareRequest(t,e){switch(t){case"getBlockNumber":return["eth_blockNumber",[]];case"getGasPrice":return["eth_gasPrice",[]];case"getBalance":return["eth_getBalance",[xy(e.address),e.blockTag]];case"getTransactionCount":return["eth_getTransactionCount",[xy(e.address),e.blockTag]];case"getCode":return["eth_getCode",[xy(e.address),e.blockTag]];case"getStorageAt":return["eth_getStorageAt",[xy(e.address),e.position,e.blockTag]];case"sendTransaction":return["eth_sendRawTransaction",[e.signedTransaction]];case"getBlock":return e.blockTag?["eth_getBlockByNumber",[e.blockTag,!!e.includeTransactions]]:e.blockHash?["eth_getBlockByHash",[e.blockHash,!!e.includeTransactions]]:null;case"getTransaction":return["eth_getTransactionByHash",[e.transactionHash]];case"getTransactionReceipt":return["eth_getTransactionReceipt",[e.transactionHash]];case"call":return["eth_call",[cd(this.constructor,"hexlifyTransaction")(e.transaction,{from:!0}),e.blockTag]];case"estimateGas":return["eth_estimateGas",[cd(this.constructor,"hexlifyTransaction")(e.transaction,{from:!0})]];case"getLogs":return e.filter&&null!=e.filter.address&&(e.filter.address=xy(e.filter.address)),["eth_getLogs",[e.filter]]}return null}perform(t,e){return Ny(this,void 0,void 0,(function*(){const r=this.prepareRequest(t,e);null==r&&Sy.throwError(t+" not implemented",Wc.errors.NOT_IMPLEMENTED,{operation:t});try{return yield this.send(r[0],r[1])}catch(r){return Uy(t,r,e)}}))}_startEvent(t){"pending"===t.tag&&this._startPending(),super._startEvent(t)}_startPending(){if(null!=this._pendingFilter)return;const t=this,e=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=e,e.then((function(r){return function n(){t.send("eth_getFilterChanges",[r]).then((function(r){if(t._pendingFilter!=e)return null;let n=Promise.resolve();return r.forEach((function(e){t._emitted["t:"+e.toLowerCase()]="pending",n=n.then((function(){return t.getTransaction(e).then((function(e){return t.emit("pending",e),null}))}))})),n.then((function(){return Iy(1e3)}))})).then((function(){if(t._pendingFilter==e)return setTimeout((function(){n()}),0),null;t.send("eth_uninstallFilter",[r])})).catch(t=>{})}(),r})).catch(t=>{})}_stopEvent(t){"pending"===t.tag&&0===this.listenerCount("pending")&&(this._pendingFilter=null),super._stopEvent(t)}static hexlifyTransaction(t,e){const r=md(Cy);if(e)for(const t in e)e[t]&&(r[t]=!0);!function(t,e){t&&"object"==typeof t||ld.throwArgumentError("invalid object","object",t),Object.keys(t).forEach(r=>{e[r]||ld.throwArgumentError("invalid object key - "+r,"transaction:"+r,t)})}(t,r);const n={};return["gasLimit","gasPrice","type","nonce","value"].forEach((function(e){if(null==t[e])return;const r=sd(t[e]);"gasLimit"===e&&(e="gas"),n[e]=r})),["from","to","data"].forEach((function(e){null!=t[e]&&(n[e]=rd(t[e]))})),t.accessList&&(n.accessList=Qg(t.accessList)),n}}var Dy=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const Ly=new Wc(ng);class $y extends Fy{detectNetwork(){const t=Object.create(null,{detectNetwork:{get:()=>super.detectNetwork}});return Dy(this,void 0,void 0,(function*(){let e=this.network;return null==e&&(e=yield t.detectNetwork.call(this),e||Ly.throwError("no network detected",Wc.errors.UNKNOWN_ERROR,{}),null==this._network&&(fd(this,"_network",e),this.emit("network",e,null))),e}))}}var By={1:{key:"1",name:"Ethereum Mainnet",chainId:1,network:"homestead",multicall:"0xeefba1e63905ef1d7acba5a8513c70307c1ce441",ensResolver:"0x4976fb03C32e5B8cfe2b6cCB31c09Ba78EBaBa41",rpc:[{url:"https://api-geth-archive.ankr.com",user:"balancer_user",password:"balancerAnkr20201015"},"https://rpc.ankr.com/eth","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/eth/mainnet/archive","https://apis.ankr.com/e62bc219f9c9462b8749defe472d2dc5/6106d4a3ec1d1bcc87ec72158f8fd089/eth/archive/main","https://eth-archival.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://eth-mainnet.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv","https://cloudflare-eth.com"],ws:["wss://eth-mainnet.ws.alchemyapi.io/v2/4bdDVB5QAaorY2UE-GBUbM2yQB3QJqzv"],explorer:"https://etherscan.io",start:7929876,imageIPFS:"QmR2UYZczmYa4s8mr9HZHci5AQwyAnwUW7tSUZz7KWF3sA"},3:{key:"3",name:"Ethereum Testnet Ropsten",shortName:"Ropsten",chainId:3,network:"ropsten",testnet:!0,multicall:"0x53c43764255c17bd724f74c4ef150724ac50a3ed",rpc:["https://eth-ropsten.alchemyapi.io/v2/QzGz6gdkpTyDzebi3PjxIaKO7bDTGnSy"],explorer:"https://ropsten.etherscan.io",start:7980811,imageIPFS:"QmR2UYZczmYa4s8mr9HZHci5AQwyAnwUW7tSUZz7KWF3sA"},4:{key:"4",name:"Ethereum Testnet Rinkeby",shortName:"Rinkeby",chainId:4,network:"rinkeby",testnet:!0,multicall:"0x42ad527de7d4e9d9d011ac45b31d8551f8fe9821",ensResolver:"0xf6305c19e814d2a75429fd637d01f7ee0e77d615",rpc:["https://eth-rinkeby.alchemyapi.io/v2/ugiPEBqMebLQbjro42kalZ1h4StpW_fR","https://eth-rinkeby.gateway.pokt.network/v1/5f76124fb90218002e9ce985"],ws:["wss://eth-rinkeby.ws.alchemyapi.io/v2/twReQE9Px03E-E_N_Fbb3OVF7YgHxoGq"],explorer:"https://rinkeby.etherscan.io",start:4534725,imageIPFS:"QmR2UYZczmYa4s8mr9HZHci5AQwyAnwUW7tSUZz7KWF3sA"},5:{key:"5",name:"Ethereum Testnet Görli",shortName:"Görli",chainId:5,network:"goerli",testnet:!0,multicall:"0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e",rpc:["https://eth-goerli.alchemyapi.io/v2/v4nqH_J-J3STit45Mm07TxuYexMHQsYZ"],explorer:"https://goerli.etherscan.io",start:743550,imageIPFS:"QmR2UYZczmYa4s8mr9HZHci5AQwyAnwUW7tSUZz7KWF3sA"},7:{key:"7",name:"ThaiChain",chainId:7,network:"mainnet",multicall:"0xB9cb900E526e7Ad32A2f26f1fF6Dee63350fcDc5",rpc:["https://rpc.dome.cloud"],ws:["wss://ws.dome.cloud"],explorer:"https://exp.tch.in.th",imageIPFS:"QmUcNN6ZMFEPLUw5WCknisSgs7nhWC5p992jSSsJVq34Eo"},8:{key:"8",name:"Ubiq Mainnet",chainId:8,network:"Ubiq mainnet",multicall:"0x6668750957e4083725926B71C41bDF1434C73262",rpc:["https://rpc.octano.dev"],ws:["wss://ws.octano.dev"],explorer:"https://ubiqscan.io",imageIPFS:"Qmec3HLoN4QhwZAhw4XTi2aN8Wwmcko5hHN22sHARzb9tw"},10:{key:"10",name:"Optimism Mainnet",chainId:10,network:"Optimism mainnet",multicall:"0x35A6Cdb2C9AD4a45112df4a04147EB07dFA01aB7",rpc:["https://opt-mainnet.g.alchemy.com/v2/JzmIL4Q3jBj7it2duxLFeuCa9Wobmm7D"],explorer:"https://optimistic.etherscan.io",start:657806,imageIPFS:"QmfF4kwhGL8QosUXvgq2KWCmavhKBvwD6kbhs7L4p5ZAWb"},20:{key:"20",name:"Elastos Smart Chain",shortName:"ESC",chainId:20,network:"mainnet",multicall:"0x20205D3b6008bea1411bd4CaEA2D923FE231B6E5",rpc:["https://rpc.glidefinance.io","https://escrpc.elaphant.app"],explorer:"https://esc.elastos.io",start:7826070,imageIPFS:"Qmd2muU2UHo5WsTxE9EpZZJeatimTT9GD4sEnHQe6i9wiA"},25:{key:"25",name:"Cronos Mainnet",shortName:"Cronos",chainId:25,network:"mainnet",multicall:"0x6F522a3982e8F9A50A2EDc9E46ed1A3aE2B3FD3a",rpc:["https://evm-cronos.crypto.org"],explorer:"https://cronos.crypto.org/explorer",start:4067,imageIPFS:"QmfSJbtirJoa3Pt7o5Fdm85wbyw9V1hpzqLr5PQbdnfsAj"},30:{key:"30",name:"RSK Mainnet",chainId:30,network:"rsk mainnet",multicall:"0x4eeebb5580769ba6d26bfd07be636300076d1831",rpc:["https://public-node.rsk.co"],explorer:"https://explorer.rsk.co",start:2516442,imageIPFS:"QmXTwpE1SqoNZmyY4c3fYWy6qUgQELsyWKbgJo2Pg6K6V9"},31:{key:"31",name:"RSK Testnet",chainId:31,network:"rsk testnet",testnet:!0,multicall:"0x4eeebb5580769ba6d26bfd07be636300076d1831",rpc:["https://public-node.testnet.rsk.co"],explorer:"https://explorer.testnet.rsk.co",start:1002369,imageIPFS:"QmbpnJowePd9sDy8hrJv7LsTBkxksuJauw56Y7BqdMdzec"},42:{key:"42",name:"Ethereum Testnet Kovan",shortName:"Kovan",chainId:42,network:"kovan",testnet:!0,multicall:"0x2cc8688c5f75e365aaeeb4ea8d6a480405a48d2a",rpc:["https://eth-kovan.alchemyapi.io/v2/sR9qngOH3w78GAaTtlTe8GwEnij0SnEa","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/eth/kovan/archive","https://eth-kovan.alchemyapi.io/v2/s96TIUFYg0LuddgpmafA040ZyUaZbrpM","https://poa-kovan.gateway.pokt.network/v1/5f76124fb90218002e9ce985"],ws:["wss://eth-kovan.ws.alchemyapi.io/v2/QCsM2iU0bQ49eGDmZ7-Y--Wpu0lVWXSO"],explorer:"https://kovan.etherscan.io",start:11482433,imageIPFS:"QmR2UYZczmYa4s8mr9HZHci5AQwyAnwUW7tSUZz7KWF3sA"},44:{key:"44",name:"Crab Network",shortName:"Crab",chainId:44,network:"mainnet",multicall:"0x4617D470F847Ce166019d19a7944049ebB017400",rpc:["https://crab-rpc.darwinia.network"],explorer:"https://crab.subscan.io",imageIPFS:"QmTpySsG7rjLwuZX1Ep4ewGyVAyGrvCRC1oqEvU6oP1huf"},50:{key:"50",name:"XDC.Network",shortName:"XDC",chainId:50,network:"mainnet",multicall:"0xc8160deb19559d93eadb82798ededce696ebcaf5",rpc:["https://snapshotrpc.blocksscan.io/","https://rpc.xinfin.network"],ws:["wss://ws.blocksscan.io"],explorer:"http://xdc.blocksscan.io",imageIPFS:"QmaX3pqjWGg97bR6jjxvTopRkJVxrvwp6VB4jf1Lknq111"},51:{key:"51",name:"XDC Apothem.network",shortName:"XDC",chainId:51,network:"testnet",multicall:"0x3b353b02a8b42ee4222ea4be0836629b1f40c8db",rpc:["https://apothemrpc.blocksscan.io"],ws:["wss://apothemws.blocksscan.io"],explorer:"http://apothem.blocksscan.io",imageIPFS:"QmaX3pqjWGg97bR6jjxvTopRkJVxrvwp6VB4jf1Lknq111"},56:{key:"56",name:"Binance Smart Chain Mainnet",shortName:"BSC",chainId:56,network:"mainnet",multicall:"0x1ee38d535d541c55c9dae27b12edf090c608e6fb",rpc:["https://apis.ankr.com/c0d871dd3c6d4529b01c9362a9b79e89/6106d4a3ec1d1bcc87ec72158f8fd089/binance/archive/main","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/bsc/mainnet/archive","https://bsc.getblock.io/mainnet/?api_key=91f8195f-bf46-488f-846a-73d6853790e7","https://bsc-private-dataseed1.nariox.org","https://bsc-private-dataseed2.nariox.org","https://bsc-dataseed1.ninicoin.io","https://bsc-dataseed1.binance.org","https://bsc-dataseed2.binance.org","https://bsc-dataseed3.binance.org"],explorer:"https://bscscan.com",start:461230,imageIPFS:"QmWQaQ4Tv28DwA4DRKjSDJFWY9mZboGvuu77J8nh7kucxv"},61:{key:"61",name:"Ethereum Classic Mainnet",shortName:"Ethereum Classic",chainId:61,network:"mainnet",multicall:"",rpc:["https://ethereumclassic.network"],explorer:"https://blockscout.com/etc/mainnet",imageIPFS:"QmVegc28DvA7LjKUFysab81c9BSuN4wQVDQkRXyAtuEBis"},65:{key:"65",name:"OKExChain Testnet",shortName:"OEC Testnet",chainId:65,network:"oec testnet",testnet:!0,multicall:"0x04c68A7fB750ca0Ba232105B3b094926a0f77645",rpc:["https://exchaintestrpc.okex.org"],ws:["wss://exchaintestws.okex.org:8443"],explorer:"https://www.oklink.com/okexchain-test",start:5320359,imageIPFS:"Qmd7dKnNwHRZ4HRCbCXUbkNV7gP28fGqPdjbHtjRtT9sQF"},66:{key:"66",name:"OKExChain Mainnet",shortName:"OEC Mainnet",chainId:66,network:"oec mainnet",multicall:"0x6EB187d8197Ac265c945b69f3c3064A6f3831866",rpc:["https://exchainrpc.okex.org"],ws:["wss://exchainws.okex.org:8443"],explorer:"https://www.oklink.com/okexchain",start:5076543,imageIPFS:"Qmd7dKnNwHRZ4HRCbCXUbkNV7gP28fGqPdjbHtjRtT9sQF"},69:{key:"69",name:"Optimism Kovan",chainId:69,network:"Optimism testnet",testnet:!0,multicall:"0x28e9a2329aa6b675ca251a2ccaa7fb029c1e9bfb",rpc:["https://opt-kovan.g.alchemy.com/v2/JzmIL4Q3jBj7it2duxLFeuCa9Wobmm7D"],explorer:"https://kovan-optimistic.etherscan.io",start:882942,imageIPFS:"QmfF4kwhGL8QosUXvgq2KWCmavhKBvwD6kbhs7L4p5ZAWb"},70:{key:"70",name:"Hoo Smart Chain Mainnet",shortName:"hsc",chainId:70,network:"Mainnet",multicall:"0xd4b794b89baccb70ef851830099bee4d69f19ebc",rpc:["https://http-mainnet2.hoosmartchain.com"],ws:["wss://ws-mainnet2.hoosmartchain.com"],explorer:"https://hooscan.com",start:404118,imageIPFS:"QmNhFCVw5GDsu86sGchoRNvQjcr5GL79UJQ3xCHzdFbZYk"},74:{key:"74",name:"IDChain",shortName:"IDChain",chainId:74,network:"mainnet",multicall:"0x41d289c966D51342A515A19dE9c27d16079c94E0",rpc:["https://idchain.one/archive/rpc/","https://idchain.songadao.org/rpc"],explorer:"https://explorer.idchain.one",start:10780012,imageIPFS:"QmXAKaNsyv6ctuRenYRJuZ1V4kn1eFwkUtjrjzX6jiKTqe"},80:{key:"80",name:"GeneChain",chainId:80,network:"Mainnet",multicall:"0x9e6ed491171A0D9089892aA5F14800f9f32038eb",rpc:["https://rpc.genechain.io"],explorer:"https://scan.genechain.io",imageIPFS:"QmSV3LTGzE4159zLK4xJVDH5t8iKhY4peh7VAkjefawr2q"},81:{key:"81",name:"Shibuya Network",shortName:"Shibuya",chainId:81,network:"testnet",testnet:!0,multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shibuya.astar.network:8545"],explorer:"https://blockscout.com/shibuya",start:856303,imageIPFS:"QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},82:{key:"82",name:"Meter Mainnet",shortName:"Meter",chainId:82,network:"mainnet",multicall:"0x579De77CAEd0614e3b158cb738fcD5131B9719Ae",rpc:["https://rpc.meter.io"],explorer:"https://scan.meter.io",start:4992871,imageIPFS:"QmSZvT9w9eUDvV1YVaq3BKKEbubtNVqu1Rin44FuN4wz11"},97:{key:"97",name:"Binance Smart Chain Testnet",shortName:"BSC Testnet",chainId:97,network:"testnet",testnet:!0,multicall:"0x8b54247c6BAe96A6ccAFa468ebae96c4D7445e46",rpc:["https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/bsc/testnet/archive","https://data-seed-prebsc-1-s1.binance.org:8545"],explorer:"https://testnet.bscscan.com",start:3599656,imageIPFS:"QmWQaQ4Tv28DwA4DRKjSDJFWY9mZboGvuu77J8nh7kucxv"},99:{key:"99",name:"POA Core",shortName:"POA",chainId:99,network:"mainnet",multicall:"0x2754BB10580dFc6d8Ce6d6CA2939021A06923394",rpc:["https://core.poa.network"],explorer:"https://blockscout.com/poa/core",start:22543252,imageIPFS:"QmZNFCQGA7qT4XJnPSH5NNYrqK6aFsfzZ1NzJwp5D4Tdjr"},100:{key:"100",name:"Gnosis Chain",shortName:"xDAI",chainId:100,network:"mainnet",multicall:"0xb5b692a88bdfc81ca69dcb1d924f59f0413a602a",rpc:["https://xdai-archive.blockscout.com","https://poa-xdai.gateway.pokt.network/v1/5f76124fb90218002e9ce985","https://rpc.gnosischain.com"],ws:["wss://rpc.xdaichain.com/wss"],explorer:"https://blockscout.com/poa/xdai",start:4108192,imageIPFS:"QmZeiy8Ax4133wzxUQM9ky8z5XFVf6YLFjJMmTWbWVniZR"},106:{key:"106",name:"Velas EVM Mainnet",shortName:"Velas",chainId:106,network:"mainnet",multicall:"0x597Cc7c49a8e0041d3A43ec8D7dc651b47879108",rpc:["https://evmexplorer.velas.com/rpc","https://explorer.velas.com/rpc"],ws:["wss://api.velas.com"],explorer:"https://evmexplorer.velas.com",start:141800,imageIPFS:"QmNXiCXJxEeBd7ZYGYjPSMTSdbDd2nfodLC677gUfk9ku5"},108:{key:"108",name:"Thundercore Mainnet",chainId:108,network:"mainnet",multicall:"",rpc:["https://mainnet-rpc.thundercore.com"],explorer:"https://scan.thundercore.com",imageIPFS:"QmbEsmMPZALcfvNnGDg8F2ABCJM3T2UFBiVBaRsMdkjefG"},111:{key:"111",name:"Velas EVM Testnet",shortName:"Velas Testnet",chainId:111,network:"testnet",testnet:!0,multicall:"0x55a827538FbF41b7334Dd49001220597898Ad954",rpc:["https://evmexplorer.testnet.velas.com/rpc","https://explorer.testnet.velas.com/rpc"],ws:["wss://api.testnet.velas.com"],explorer:"https://evmexplorer.testnet.velas.com",start:1195129,imageIPFS:"QmQFWn7JJLigUPvvp6uKg6EWikx7QeNxQ2vaCngU3Uthho"},122:{key:"122",name:"Fuse Mainnet",shortName:"Fuse",chainId:122,network:"mainnet",multicall:"0x7a59441fb06666F6d2D766393d876945D06a169c",rpc:["https://oefusefull1.liquify.info/"],explorer:"https://explorer.fuse.io",start:11923459,imageIPFS:"QmXjWb64nako7voaVEifgdjAbDbswpTY8bghsiHpv8yWtb"},128:{key:"128",name:"Huobi Eco Chain Mainnet",shortName:"heco",chainId:128,network:"Mainnet",multicall:"0x37ab26db3df780e7026f3e767f65efb739f48d8e",rpc:["https://pub001.hg.network/rpc"],ws:["wss://pub001.hg.network/ws"],explorer:"https://hecoinfo.com",start:403225,imageIPFS:"QmSJEdToMvmjqoPvVq7awwdMeYKhXUYZMBiax9yHtFGMSq"},137:{key:"137",name:"Polygon Mainnet",shortName:"Polygon",chainId:137,network:"mainnet",multicall:"0xCBca837161be50EfA5925bB9Cc77406468e76751",rpc:["https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/polygon/mainnet/archive","https://rpc-mainnet.maticvigil.com/v1/1cfd7598e5ba6dcf0b4db58e8be484badc6ea08e","https://speedy-nodes-nyc.moralis.io/b9aed21e7bb7bdeb35972c9a/polygon/mainnet/archive"],ws:["wss://ws-mainnet.matic.network"],explorer:"https://polygonscan.com",start:9834491,imageIPFS:"QmaGokGqgjknfa4xnXKnnwC5ZyXzUjQ7p6KEe4D8G5uFFE"},246:{key:"246",name:"Energy Web Chain",shortName:"EWC",chainId:246,network:"mainnet",multicall:"0x0767F26d0D568aB61A98b279C0b28a4164A6f05e",rpc:["https://voting-rpc.carbonswap.exchange"],explorer:"https://explorer.energyweb.org",start:12086501,imageIPFS:"Qmai7AGHgs8NpeGeXgbMZz7pS2i4kw44qubCJYGrZW2f3a"},250:{key:"250",name:"Fantom Opera",shortName:"fantom",chainId:250,network:"Mainnet",multicall:"0x7f6A10218264a22B4309F3896745687E712962a0",rpc:["https://rpc.ftm.tools","https://rpcapi.fantom.network"],explorer:"https://ftmscan.com",start:2497732,imageIPFS:"QmVEgNeQDKnXygeGxfY9FywZpNGQu98ktZtRJ9bToYF6g7"},256:{key:"256",name:"Huobi Eco Chain Testnet",shortName:"heco",chainId:256,network:"testnet",testnet:!0,multicall:"0xC33994Eb943c61a8a59a918E2de65e03e4e385E0",rpc:["https://http-testnet.hecochain.com"],ws:["wss://ws-testnet.hecochain.com"],explorer:"https://testnet.hecoinfo.com",start:379560,imageIPFS:"QmSJEdToMvmjqoPvVq7awwdMeYKhXUYZMBiax9yHtFGMSq"},269:{key:"269",name:"High Performance Blockchain Mainnet",shortName:"HPB",chainId:269,network:"mainnet",testnet:!1,multicall:"0x67D0f263aef2F6167FA77353695D75b582Ff4Bca",rpc:["https://hpbnode.com"],ws:["wss://ws.hpbnode.com"],explorer:"https://hscan.org",start:13960096,imageIPFS:"QmU7f1MyRz8rLELFfypnWZQjGbDGYgZtC9rjw47jYMYrnu"},288:{key:"288",name:"Boba Mainnet",shortName:"Boba",chainId:288,network:"mainnet",multicall:"0xfb91c019D9F12A0f9c23B4762fa64A34F8daDb4A",rpc:["https://mainnet.boba.network/"],explorer:"https://blockexplorer.boba.network",start:74,imageIPFS:"QmNc7QZFpPDue3Ef4SsuX55RHkqXxUxSyTCpoASeg2hW6d"},321:{key:"321",name:"KCC Mainnet",shortName:"KCC",chainId:321,network:"mainnet",multicall:"0xa64D6AFb48225BDA3259246cfb418c0b91de6D7a",rpc:["https://rpc-mainnet.kcc.network"],ws:["wss://rpc-ws-mainnet.kcc.network"],explorer:"https://explorer.kcc.io",start:1487453,imageIPFS:"QmRdzYGhFRG8QLzMJahHrw3vETE2YZ9sywQbEkenSjKEvb"},336:{key:"336",name:"Shiden Network",shortName:"Shiden",chainId:336,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.shiden.astar.network:8545","https://shiden.api.onfinality.io/public"],explorer:"https://blockscout.com/shiden",start:1170016,imageIPFS:"QmcqGQE4Sk73zXc3e91TUFFefKBVeaNgbxV141XkSNE4xj"},361:{key:"361",name:"Theta Mainnet",shortName:"Theta",chainId:361,network:"mainnet",multicall:"0xB48BbAD564Ceb6fB30cCea2Af248ccF6398aEab5",rpc:["https://eth-rpc-api.thetatoken.org/rpc"],explorer:"https://explorer.thetatoken.org",start:12559216,imageIPFS:"QmcMP9s9mUqfT2SCiP75sZgAVVev7H7RQAKiSx9xWEDKwe"},499:{key:"499",name:"Rupaya",shortName:"RUPX",chainId:499,network:"mainnet",multicall:"0x7955FF653FfDBf13056FeAe227f655CfF5C194D5",rpc:["https://rpc.rupx.io"],ws:["wss://ws.rupx.io"],explorer:"http://scan.rupx.io",start:2762929,imageIPFS:"QmXLZyAr6UNFQ4tkNwSyeNByFvzwYpwiNgV5vHuoxn74Rg"},592:{key:"592",name:"Astar Network",shortName:"Astar",chainId:592,network:"mainnet",multicall:"0x3E90A35839ff0Aa32992d33d861f24dC95BBf74d",rpc:["https://rpc.astar.network:8545","https://astar.api.onfinality.io/public"],explorer:"https://blockscout.com/astar",start:366482,imageIPFS:"QmZLQVsUqHBDXutu6ywTvcYXDZG2xBstMfHkfJSzUNpZsc"},888:{key:"888",name:"Wanchain",chainId:888,network:"mainnet",multicall:"0xba5934ab3056fca1fa458d30fbb3810c3eb5145f",rpc:["https://gwan-ssl.wandevs.org:56891"],ws:["wss://api.wanchain.org:8443/ws/v3/ddd16770c68f30350a21114802d5418eafe039b722de52b488e7eee1ee2cd73f"],explorer:"https://www.wanscan.org",start:11302663,imageIPFS:"QmewFFN44rkxESFsHG8edaLt1znr62hjvZhGynfXqruzX3"},940:{key:"940",name:"PulseChain Testnet",shortName:"pulsechain",chainId:940,network:"Testnet",multicall:"0x5e67901C2Dd1915E9Ef49aF39B62C28DF8C2c529",rpc:["https://rpc.testnet.pulsedisco.net"],ws:["wss://ws.rpc.testnet.pulsedisco.net"],explorer:"https://scan.v2.testnet.pulsechain.com",start:15123138,imageIPFS:"QmYqkn8pJUaV9KcEPYEvRPwgbfeozLEvcQ9aEwKNRUL3cR"},1088:{key:"1088",name:"Metis",shortName:"metis",chainId:1088,network:"mainnet",multicall:"0xc39aBB6c4451089dE48Cffb013c39d3110530e5C",rpc:["https://andromeda.metis.io/?owner=1088"],explorer:"https://andromeda-explorer.metis.io",start:451,imageIPFS:"QmYeskHqrEvWHqeAuqett64LxfH52HUXZi2T9BAMmgKvBF"},1284:{key:"1284",name:"Moonbeam",shortName:"GLMR",chainId:1284,network:"mainnet",multicall:"0x83e3b61886770de2F64AAcaD2724ED4f08F7f36B",rpc:["https://rpc.api.moonbeam.network"],explorer:"https://blockscout.moonbeam.network",start:171135,imageIPFS:"QmWKTEK2pj5sBBbHnMHQbWgw6euVdBrk2Ligpi2chrWASk"},1285:{key:"1285",name:"Moonriver (Kusama)",shortName:"Moonriver",chainId:1285,network:"mainnet",multicall:"0x537004440ffFE1D4AE9F009031Fc2b0385FCA9F1",rpc:["https://rpc.api.moonriver.moonbeam.network"],explorer:"https://blockscout.moonriver.moonbeam.network",start:413539,imageIPFS:"QmXtgPesL87Ejhq2Y7yxsaPYpf4RcnoTYPJWPcv6iiYhoi"},1287:{key:"1287",name:"Moonbase Alpha TestNet",shortName:"Moonbase",chainId:1287,network:"testnet",testnet:!0,multicall:"0xf09FD6B6FF3f41614b9d6be2166A0D07045A3A97",rpc:["https://rpc.testnet.moonbeam.network"],explorer:"https://moonbase-blockscout.testnet.moonbeam.network",start:859041,imageIPFS:"QmeGbNTU2Jqwg8qLTMGW8n8HSi2VdgCncAaeGzLx6gYnD7"},4689:{key:"4689",name:"IoTeX Mainnet",shortName:"IoTeX",chainId:4689,network:"mainnet",multicall:"0x9c8B105c94282CDB0F3ecF27e3cfA96A35c07be6",rpc:["https://babel-api.mainnet.iotex.io"],explorer:"https://iotexscan.io",start:11533283,imageIPFS:"QmNkr1UPcBYbvLp7d7Pk4eF3YCsHpaNkfusKZNtykL2EQC"},4690:{key:"4690",name:"IoTeX Testnet",shortName:"IoTeX",chainId:4690,network:"testnet",testnet:!0,multicall:"0x30aE8783d26aBE7Fbb9d83549CCb7430AE4A301F",rpc:["https://babel-api.testnet.iotex.io"],explorer:"https://testnet.iotexscan.io",start:8821493,imageIPFS:"QmNkr1UPcBYbvLp7d7Pk4eF3YCsHpaNkfusKZNtykL2EQC"},5551:{key:"5551",name:"Nahmii Mainnet",shortName:"Nahmii",chainId:5551,network:"mainnet",multicall:"0x05911151467b9F42eD14f10ddE0c057347Fff714",rpc:["https://l2.nahmii.io"],explorer:"https://explorer.nahmii.io",start:4364,imageIPFS:"QmPXPCBho3kGLt5rhG9JGkKmzdtLvqZmJqGzzijVCuggWY"},5553:{key:"5553",name:"Nahmii Testnet",shortName:"Nahmii",chainId:5553,network:"testnet",testnet:!0,multicall:"0x0e157d2E45af27564edFAaCcD68f2f0458F3D96c",rpc:["https://l2.testnet.nahmii.io"],explorer:"https://explorer.testnet.nahmii.io",start:53370,imageIPFS:"QmPXPCBho3kGLt5rhG9JGkKmzdtLvqZmJqGzzijVCuggWY"},7341:{key:"7341",name:"Shyft",shortName:"Shyft",chainId:7341,network:"mainnet",testnet:!1,multicall:"0xceb10e9133D771cA93c8002Be527A465E85381a2",rpc:["https://rpc.shyft.network"],explorer:"https://bx.shyft.network",start:3673983,imageIPFS:"QmUkFZC2ZmoYPTKf7AHdjwRPZoV2h1MCuHaGM4iu8SNFpi"},1e4:{key:"10000",name:"smartBCH",shortName:"BCH",chainId:1e4,network:"mainnet",multicall:"0x1b38EBAd553f218e2962Cb1C0539Abb5d6A37774",rpc:["https://smartbch.greyh.at/"],explorer:"https://www.smartscan.cash",imageIPFS:"QmWG1p7om4hZ4Yi4uQvDpxg4si7qVYhtppGbcDGrhVFvMd"},11437:{key:"11437",name:"Shyft Testnet",shortName:"Shyft_",chainId:11437,network:"testnet",testnet:!0,multicall:"0x407159bAA564dA0c3b14D1215d8E2654cEEE73F4",rpc:["https://rpc.testnet.shyft.network"],explorer:"https://bx.testnet.shyft.network",start:2446296,imageIPFS:"QmUkFZC2ZmoYPTKf7AHdjwRPZoV2h1MCuHaGM4iu8SNFpi"},12357:{key:"12357",name:"REI Testnet",shortName:"REI",chainId:12357,network:"testnet",testnet:!0,multicall:"0x9eE9904815B80C39C1a27294E69a8626EAa7952d",rpc:["https://rpc-testnet.rei.network"],explorer:"https://scan-test.rei.network/",start:79516,imageIPFS:"QmTogMDLmDgJjDjUKDHDuc2KVTVDbXf8bXJLFiVe8PRxgo"},32659:{key:"32659",name:"Fusion Mainnet",chainId:32659,network:"mainnet",multicall:"",rpc:["https://vote.anyswap.exchange/mainnet"],ws:["wss://mainnetpublicgateway1.fusionnetwork.io:10001"],explorer:"https://fsnex.com",imageIPFS:"QmRb6YCGdpQTQcdNTnBb5DUixGpjDp1wz6zoADJwQ7hyFq"},42161:{key:"42161",name:"Arbitrum One",chainId:42161,network:"Arbitrum mainnet",multicall:"0x7A7443F8c577d537f1d8cD4a629d40a3148Dd7ee",rpc:["https://arb-mainnet.g.alchemy.com/v2/JDvtNGwnHhTltIwfnxQocKwKkCTKA1DL"],explorer:"https://arbiscan.io",start:256508,imageIPFS:"QmWZ5SMRfvcK8tycsDqojQaSiKedgtVkS7CkZdxPgeCVsZ"},42220:{key:"42220",name:"Celo Mainnet",shortName:"Celo",chainId:42220,network:"mainnet",multicall:"0xb8d0d2C1391eeB350d2Cd39EfABBaaEC297368D9",rpc:["https://celo.snapshot.org","https://forno.celo.org","https://celo-mainnet--rpc.datahub.figment.io/apikey/e892a66dc36e4d2d98a5d6406d609796/"],explorer:"https://explorer.celo.org",start:6599803,imageIPFS:"QmS2tVJ7rdJRe1NHXAi2L86yCbUwVVrmB2mHQeNdJxvQti"},42262:{key:"42262",name:"Emerald",shortName:"Emerald",chainId:42262,network:"mainnet",multicall:"0xBD46A7DCD1fefA63A7746a5762A71635Ee0843A1",rpc:["https://emerald.oasis.dev"],explorer:"https://explorer.emerald.oasis.dev",start:176517,imageIPFS:"QmQrZjZZyAcQmPXJM2cUh1KaaDeM8Sfcg3HnvZpBj8wTnG"},43114:{key:"43114",name:"Avalanche",chainId:43114,network:"mainnet",multicall:"0x7E9985aE4C8248fdB07607648406a48C76e9e7eD",rpc:["https://nd-784-543-849.p2pify.com/aa7b29fc5fed65b34f0ee6b8de33f8c0/ext/bc/C/rpc","https://rpc.ankr.com/avalanche","https://api.avax.network/ext/bc/C/rpc"],explorer:"https://snowtrace.io",start:536483,imageIPFS:"QmeS75uS7XLR8o8uUzhLRVYPX9vMFf4DXgKxQeCzyy7vM2"},47805:{key:"47805",name:"REI Mainnet",chainId:47805,network:"mainnet",multicall:"0x9eE9904815B80C39C1a27294E69a8626EAa7952d",rpc:["https://rpc.rei.network"],explorer:"https://scan.rei.network/",start:1715902,imageIPFS:"QmTogMDLmDgJjDjUKDHDuc2KVTVDbXf8bXJLFiVe8PRxgo"},80001:{key:"80001",name:"Matic Mumbai",chainId:80001,network:"testnet",testnet:!0,multicall:"0x08411ADd0b5AA8ee47563b146743C13b3556c9Cc",rpc:["https://speedy-nodes-nyc.moralis.io/f2963e29bec0de5787da3164/polygon/mumbai/archive","https://rpc-mumbai.matic.today"],ws:["wss://ws-mumbai.matic.today"],explorer:"https://mumbai.polygonscan.com",start:12011090,imageIPFS:"QmaGokGqgjknfa4xnXKnnwC5ZyXzUjQ7p6KEe4D8G5uFFE"},333888:{key:"333888",name:"Polis Sparta",shortName:"Sparta",chainId:333888,network:"testnet",testnet:!0,multicall:"0xA4c03972023d5f684d35eF1C541752490975383e",rpc:["https://sparta-rpc.polis.tech"],explorer:"https://sparta-explorer.polis.tech",imageIPFS:"QmSiCni2Jn58WN74SyGNY1Aw5mSh9ypEfFULhjKxA7Tbpg"},333999:{key:"333999",name:"Polis Olympus",shortName:"Olympus",chainId:333999,network:"mainnet",multicall:"0x34b99C2a4a4620F10ac779c36b8c61F90FD61732",rpc:["https://rpc.polis.tech"],explorer:"https://explorer.polis.tech",start:1971,imageIPFS:"QmSiCni2Jn58WN74SyGNY1Aw5mSh9ypEfFULhjKxA7Tbpg"},1313161554:{key:"1313161554",name:"Aurora Mainnet",shortName:"Aurora",chainId:1313161554,network:"mainnet",multicall:"0x32b50c286DEFd2932a0247b8bb940b78c063F16c",rpc:["https://mainnet.aurora.dev"],explorer:"https://explorer.mainnet.aurora.dev",start:57190533,imageIPFS:"QmeRhsR1UPRTQCizdhmgr2XxphXebVKU5di97uCV2UMFpa"},16666e5:{key:"1666600000",name:"Harmony Mainnet",shortName:"HarmonyMainnet",chainId:16666e5,network:"mainnet",multicall:"0x9c31392D2e0229dC4Aa250F043d46B9E82074BF8",rpc:["https://a.api.s0.t.hmny.io"],ws:["wss://ws.s0.t.hmny.io"],explorer:"https://explorer.harmony.one",start:10911984,imageIPFS:"QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"},16667e5:{key:"1666700000",name:"Harmony Testnet",shortName:"HarmonyTestnet",chainId:16667e5,network:"testnet",testnet:!0,multicall:"0x9923589503Fd205feE3d367DDFF2378f0F7dD2d4",rpc:["https://api.s0.b.hmny.io"],ws:["wss://ws.s0.b.hmny.io"],explorer:"https://explorer.pops.one",start:7521509,imageIPFS:"QmNnGPr1CNvj12SSGzKARtUHv9FyEfE5nES73U4vBWQSJL"},11297108109:{key:"11297108109",name:"Palm Mainnet",shortName:"Palm",chainId:11297108109,network:"mainnet",multicall:"0xfFE2FF36c5b8D948f788a34f867784828aa7415D",rpc:["https://palm-mainnet.infura.io/v3/3a961d6501e54add9a41aa53f15de99b"],explorer:"https://explorer.palm.io",start:1172267,imageIPFS:"QmaYQfjLfQpyRWZZZU1BE8X352rXEjNaNeahjvf1aHZrKY"}},jy={};function zy(e){var r=By[e].rpc[0],n="object"==typeof r?t(t({},r),{timeout:25e3}):{url:r,timeout:25e3};return jy[e]||(jy[e]=new $y(n)),jy[e]}var Gy={basic:function(t,n,i,o){var s,a;return e(this,void 0,void 0,(function(){var e,i,h,u;return r(this,(function(r){switch(r.label){case 0:return e=o.strategies||n.strategies,i=o.onlyMembers||(null===(s=n.filters)||void 0===s?void 0:s.onlyMembers),h=o.minScore||(null===(a=n.filters)||void 0===a?void 0:a.minScore),(n.members||[]).map((function(t){return t.toLowerCase()})).includes(t.toLowerCase())?[2,!0]:i?[2,!1]:h?[4,Tb(n.id||n.key,e,n.network,[t])]:[3,2];case 1:if(u=r.sent(),u.map((function(t){return Object.values(t).reduce((function(t,e){return t+e}),0)})).reduce((function(t,e){return t+e}),0)<h)return[2,!1];r.label=2;case 2:return[2,!0]}}))}))},aave:function(t,n,o,s){var a,h;return e(this,void 0,void 0,(function(){var e,o,u,l,f,c;return r(this,(function(r){switch(r.label){case 0:return e=s.onlyMembers||(null===(a=n.filters)||void 0===a?void 0:a.onlyMembers),o=s.minScore||(null===(h=n.filters)||void 0===h?void 0:h.minScore),u=(n.members||[]).map((function(t){return t.toLowerCase()})),l=i(n.strategies),(f=l.findIndex((function(t){return"aave-governance-power"===t.name})))>=0&&(l[f].params.powerType="proposition"),u.includes(t.toLowerCase())?[2,!0]:e?[2,!1]:o?[4,Tb(n.id||n.key,l,n.network,[t])]:[3,2];case 1:if(c=r.sent(),c.map((function(t){return Object.values(t).reduce((function(t,e){return t+e}),0)})).reduce((function(t,e){return t+e}),0)<o)return[2,!1];r.label=2;case 2:return[2,!0]}}))}))},nouns:function(t,n,o,s){var a,h;return e(this,void 0,void 0,(function(){var e,o,u,l,f,c;return r(this,(function(r){switch(r.label){case 0:return e=s.onlyMembers||(null===(a=n.filters)||void 0===a?void 0:a.onlyMembers),o=s.minScore||(null===(h=n.filters)||void 0===h?void 0:h.minScore),u=(n.members||[]).map((function(t){return t.toLowerCase()})),l=i(n.strategies),(f=l.findIndex((function(t){return"nouns-rfp-power"===t.name})))>=0&&(l[f].params.powerType="proposition"),u.includes(t.toLowerCase())?[2,!0]:e?[2,!1]:o?[4,Tb(n.id||n.key,l,n.network,[t])]:[3,2];case 1:if(c=r.sent(),c.map((function(t){return Object.values(t).reduce((function(t,e){return t+e}),0)})).reduce((function(t,e){return t+e}),0)<o)return[2,!1];r.label=2;case 2:return[2,!0]}}))}))}};let qy=!1,Vy=!1;const Ky={debug:1,default:2,info:2,warning:3,error:4,off:5};let Wy=Ky.default,Hy=null;const Zy=function(){try{const t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),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 Xy,Jy;!function(t){t.DEBUG="DEBUG",t.INFO="INFO",t.WARNING="WARNING",t.ERROR="ERROR",t.OFF="OFF"}(Xy||(Xy={})),function(t){t.UNKNOWN_ERROR="UNKNOWN_ERROR",t.NOT_IMPLEMENTED="NOT_IMPLEMENTED",t.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",t.NETWORK_ERROR="NETWORK_ERROR",t.SERVER_ERROR="SERVER_ERROR",t.TIMEOUT="TIMEOUT",t.BUFFER_OVERRUN="BUFFER_OVERRUN",t.NUMERIC_FAULT="NUMERIC_FAULT",t.MISSING_NEW="MISSING_NEW",t.INVALID_ARGUMENT="INVALID_ARGUMENT",t.MISSING_ARGUMENT="MISSING_ARGUMENT",t.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",t.CALL_EXCEPTION="CALL_EXCEPTION",t.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",t.NONCE_EXPIRED="NONCE_EXPIRED",t.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",t.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",t.TRANSACTION_REPLACED="TRANSACTION_REPLACED"}(Jy||(Jy={}));class Yy{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}_log(t,e){const r=t.toLowerCase();null==Ky[r]&&this.throwArgumentError("invalid log level name","logLevel",t),Wy>Ky[r]||console.log.apply(console,e)}debug(...t){this._log(Yy.levels.DEBUG,t)}info(...t){this._log(Yy.levels.INFO,t)}warn(...t){this._log(Yy.levels.WARNING,t)}makeError(t,e,r){if(Vy)return this.makeError("censored error",e,{});e||(e=Yy.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("code="+e),n.push("version="+this.version);const i=t;n.length&&(t+=" ("+n.join(", ")+")");const o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach((function(t){o[t]=r[t]})),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,Yy.errors.INVALID_ARGUMENT,{argument:e,value:r})}assert(t,e,r,n){t||this.throwError(e,r,n)}assertArgument(t,e,r,n){t||this.throwArgumentError(e,r,n)}checkNormalize(t){Zy&&this.throwError("platform missing String.prototype.normalize",Yy.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Zy})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,Yy.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,Yy.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",t<e&&this.throwError("missing argument"+r,Yy.errors.MISSING_ARGUMENT,{count:t,expectedCount:e}),t>e&&this.throwError("too many arguments"+r,Yy.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",Yy.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",Yy.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",Yy.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return Hy||(Hy=new Yy("logger/5.4.0")),Hy}static setCensorship(t,e){if(!t&&e&&this.globalLogger().throwError("cannot permanently disable censorship",Yy.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),qy){if(!t)return;this.globalLogger().throwError("error censorship permanent",Yy.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Vy=!!t,qy=!!e}static setLogLevel(t){const e=Ky[t.toLowerCase()];null!=e?Wy=e:Yy.globalLogger().warn("invalid log level - "+t)}static from(t){return new Yy(t)}}Yy.errors=Jy,Yy.levels=Xy;const Qy=new Yy("bytes/5.4.0");function tv(t){return!!t.toHexString}function ev(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return ev(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function rv(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}function nv(t,e){if(e||(e={}),"number"==typeof t){Qy.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),ev(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),tv(t)&&(t=t.toHexString()),iv(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":Qy.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return ev(new Uint8Array(n))}return rv(t)?ev(new Uint8Array(t)):Qy.throwArgumentError("invalid arrayify value","value",t)}function iv(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}function ov(t,e){if(e||(e={}),"number"==typeof t){Qy.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),tv(t))return t.toHexString();if(iv(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":Qy.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(rv(t)){let e="0x";for(let r=0;r<t.length;r++){let n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return Qy.throwArgumentError("invalid hexlify value","value",t)}function sv(t){let e="0x";return t.forEach(t=>{e+=ov(t).substring(2)}),e}function av(t,e){for("string"!=typeof t?t=ov(t):iv(t)||Qy.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&Qy.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}var hv=h((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Xt.Buffer}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function h(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s<o;s++){var a=t.charCodeAt(s)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.prototype._initNumber=function(t,e,n){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):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("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 i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,u=0,l=r;l<a;l+=n)u=h(t,l,l+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var f=1;for(u=h(t,l,t.length,e),l=0;l<s;l++)f*=e;this.imuln(f),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this.strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","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"],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,h=s/67108864|0;r.words[0]=a;for(var u=1;u<n;u++){for(var l=h>>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var m=u-d|0;l+=(s=(i=0|t.words[m])*(o=0|e.words[d])+f)/67108864|0,f=67108863&s}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],h=(16777215&(a<<i|o)).toString(16);n=0!==(o=a>>>24-i&16777215)||s!==this.length-1?u[6-h.length]+h+n:h+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];n="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modn(d).toString(t);n=(m=m.idivn(d)).isZero()?p+n:u[c-p.length]+p+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.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&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(t,e){return r(void 0!==o),this.toArrayLike(o,t,e)},i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var s,a,h="le"===e,u=new t(o),l=this.clone();if(h){for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[a]=s;for(;a<o;a++)u[a]=0}else{for(a=0;a<o-i;a++)u[a]=0;for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[o-a-1]=s}return u},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this.strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,e,r){var n,i,o,s=t.words,a=e.words,h=r.words,u=0,l=0|s[0],f=8191&l,c=l>>>13,d=0|s[1],m=8191&d,p=d>>>13,g=0|s[2],y=8191&g,v=g>>>13,w=0|s[3],b=8191&w,E=w>>>13,M=0|s[4],_=8191&M,A=M>>>13,N=0|s[5],S=8191&N,R=N>>>13,U=0|s[6],I=8191&U,P=U>>>13,x=0|s[7],k=8191&x,T=x>>>13,O=0|s[8],C=8191&O,F=O>>>13,D=0|s[9],L=8191&D,$=D>>>13,B=0|a[0],j=8191&B,z=B>>>13,G=0|a[1],q=8191&G,V=G>>>13,K=0|a[2],W=8191&K,H=K>>>13,Z=0|a[3],X=8191&Z,J=Z>>>13,Y=0|a[4],Q=8191&Y,tt=Y>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ft=8191<,ct=lt>>>13,dt=0|a[9],mt=8191&dt,pt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,z))+Math.imul(c,j)|0))<<13)|0;u=((o=Math.imul(c,z))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(m,j),i=(i=Math.imul(m,z))+Math.imul(p,j)|0,o=Math.imul(p,z);var yt=(u+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,V)|0)+Math.imul(c,q)|0))<<13)|0;u=((o=o+Math.imul(c,V)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,j),i=(i=Math.imul(y,z))+Math.imul(v,j)|0,o=Math.imul(v,z),n=n+Math.imul(m,q)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(p,q)|0,o=o+Math.imul(p,V)|0;var vt=(u+(n=n+Math.imul(f,W)|0)|0)+((8191&(i=(i=i+Math.imul(f,H)|0)+Math.imul(c,W)|0))<<13)|0;u=((o=o+Math.imul(c,H)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(b,j),i=(i=Math.imul(b,z))+Math.imul(E,j)|0,o=Math.imul(E,z),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,V)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,H)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,H)|0;var wt=(u+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,X)|0))<<13)|0;u=((o=o+Math.imul(c,J)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(_,j),i=(i=Math.imul(_,z))+Math.imul(A,j)|0,o=Math.imul(A,z),n=n+Math.imul(b,q)|0,i=(i=i+Math.imul(b,V)|0)+Math.imul(E,q)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(y,W)|0,i=(i=i+Math.imul(y,H)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,H)|0,n=n+Math.imul(m,X)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,J)|0;var bt=(u+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(S,j),i=(i=Math.imul(S,z))+Math.imul(R,j)|0,o=Math.imul(R,z),n=n+Math.imul(_,q)|0,i=(i=i+Math.imul(_,V)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,V)|0,n=n+Math.imul(b,W)|0,i=(i=i+Math.imul(b,H)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,H)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(p,Q)|0,o=o+Math.imul(p,tt)|0;var Et=(u+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;u=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(I,j),i=(i=Math.imul(I,z))+Math.imul(P,j)|0,o=Math.imul(P,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(_,W)|0,i=(i=i+Math.imul(_,H)|0)+Math.imul(A,W)|0,o=o+Math.imul(A,H)|0,n=n+Math.imul(b,X)|0,i=(i=i+Math.imul(b,J)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,J)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,nt)|0;var Mt=(u+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(c,ot)|0))<<13)|0;u=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,z))+Math.imul(T,j)|0,o=Math.imul(T,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,V)|0)+Math.imul(P,q)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,H)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,H)|0,n=n+Math.imul(_,X)|0,i=(i=i+Math.imul(_,J)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,st)|0;var _t=(u+(n=n+Math.imul(f,ht)|0)|0)+((8191&(i=(i=i+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((o=o+Math.imul(c,ut)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(C,j),i=(i=Math.imul(C,z))+Math.imul(F,j)|0,o=Math.imul(F,z),n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(T,q)|0,o=o+Math.imul(T,V)|0,n=n+Math.imul(I,W)|0,i=(i=i+Math.imul(I,H)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,H)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(_,Q)|0,i=(i=i+Math.imul(_,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var At=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,z))+Math.imul($,j)|0,o=Math.imul($,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,V)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,V)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,H)|0)+Math.imul(T,W)|0,o=o+Math.imul(T,H)|0,n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(_,rt)|0,i=(i=i+Math.imul(_,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(b,ot)|0,i=(i=i+Math.imul(b,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(m,ft)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(p,ft)|0,o=o+Math.imul(p,ct)|0;var Nt=(u+(n=n+Math.imul(f,mt)|0)|0)+((8191&(i=(i=i+Math.imul(f,pt)|0)+Math.imul(c,mt)|0))<<13)|0;u=((o=o+Math.imul(c,pt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(L,q),i=(i=Math.imul(L,V))+Math.imul($,q)|0,o=Math.imul($,V),n=n+Math.imul(C,W)|0,i=(i=i+Math.imul(C,H)|0)+Math.imul(F,W)|0,o=o+Math.imul(F,H)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(_,ot)|0,i=(i=i+Math.imul(_,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,n=n+Math.imul(b,ht)|0,i=(i=i+Math.imul(b,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,o=o+Math.imul(v,ct)|0;var St=(u+(n=n+Math.imul(m,mt)|0)|0)+((8191&(i=(i=i+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,W),i=(i=Math.imul(L,H))+Math.imul($,W)|0,o=Math.imul($,H),n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(_,ht)|0,i=(i=i+Math.imul(_,ut)|0)+Math.imul(A,ht)|0,o=o+Math.imul(A,ut)|0,n=n+Math.imul(b,ft)|0,i=(i=i+Math.imul(b,ct)|0)+Math.imul(E,ft)|0,o=o+Math.imul(E,ct)|0;var Rt=(u+(n=n+Math.imul(y,mt)|0)|0)+((8191&(i=(i=i+Math.imul(y,pt)|0)+Math.imul(v,mt)|0))<<13)|0;u=((o=o+Math.imul(v,pt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,J))+Math.imul($,X)|0,o=Math.imul($,J),n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(F,Q)|0,o=o+Math.imul(F,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,ut)|0,n=n+Math.imul(_,ft)|0,i=(i=i+Math.imul(_,ct)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,ct)|0;var Ut=(u+(n=n+Math.imul(b,mt)|0)|0)+((8191&(i=(i=i+Math.imul(b,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(i>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,n=Math.imul(L,Q),i=(i=Math.imul(L,tt))+Math.imul($,Q)|0,o=Math.imul($,tt),n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(F,rt)|0,o=o+Math.imul(F,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(S,ft)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(R,ft)|0,o=o+Math.imul(R,ct)|0;var It=(u+(n=n+Math.imul(_,mt)|0)|0)+((8191&(i=(i=i+Math.imul(_,pt)|0)+Math.imul(A,mt)|0))<<13)|0;u=((o=o+Math.imul(A,pt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul($,rt)|0,o=Math.imul($,nt),n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,st)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,ut)|0)+Math.imul(T,ht)|0,o=o+Math.imul(T,ut)|0,n=n+Math.imul(I,ft)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(P,ft)|0,o=o+Math.imul(P,ct)|0;var Pt=(u+(n=n+Math.imul(S,mt)|0)|0)+((8191&(i=(i=i+Math.imul(S,pt)|0)+Math.imul(R,mt)|0))<<13)|0;u=((o=o+Math.imul(R,pt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,ot),i=(i=Math.imul(L,st))+Math.imul($,ot)|0,o=Math.imul($,st),n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,ut)|0)+Math.imul(F,ht)|0,o=o+Math.imul(F,ut)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,ct)|0;var xt=(u+(n=n+Math.imul(I,mt)|0)|0)+((8191&(i=(i=i+Math.imul(I,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),n=n+Math.imul(C,ft)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(F,ft)|0,o=o+Math.imul(F,ct)|0;var kt=(u+(n=n+Math.imul(k,mt)|0)|0)+((8191&(i=(i=i+Math.imul(k,pt)|0)+Math.imul(T,mt)|0))<<13)|0;u=((o=o+Math.imul(T,pt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,ft),i=(i=Math.imul(L,ct))+Math.imul($,ft)|0,o=Math.imul($,ct);var Tt=(u+(n=n+Math.imul(C,mt)|0)|0)+((8191&(i=(i=i+Math.imul(C,pt)|0)+Math.imul(F,mt)|0))<<13)|0;u=((o=o+Math.imul(F,pt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863;var Ot=(u+(n=Math.imul(L,mt))|0)+((8191&(i=(i=Math.imul(L,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=wt,h[4]=bt,h[5]=Et,h[6]=Mt,h[7]=_t,h[8]=At,h[9]=Nt,h[10]=St,h[11]=Rt,h[12]=Ut,h[13]=It,h[14]=Pt,h[15]=xt,h[16]=kt,h[17]=Tt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new p).mulp(t,e,r)}function p(t,e){this.x=t,this.y=e}Math.imul||(d=c),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,f=(0|t.words[l])*(0|e.words[u]),c=67108863&f;a=67108863&(c=c+a|0),i+=(s=(s=s+(f/67108864|0)|0)+(c>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):m(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),r=i.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e},p.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n},p.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s<o;s++)n[s]=e[t[s]],i[s]=r[t[s]]},p.prototype.transform=function(t,e,r,n,i,o){this.permute(o,t,e,r,n,i);for(var s=1;s<i;s<<=1)for(var a=s<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),l=0;l<i;l+=a)for(var f=h,c=u,d=0;d<s;d++){var m=r[l+d],p=n[l+d],g=r[l+d+s],y=n[l+d+s],v=f*g-c*y;y=f*y+c*g,g=v,r[l+d]=m+g,n[l+d]=p+y,r[l+d+s]=m-g,n[l+d+s]=p-y,d!==a&&(v=h*f-u*c,c=h*c+u*f,f=v)}},p.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},p.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},p.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0}return t},p.prototype.convert13b=function(t,e,n,i){for(var o=0,s=0;s<e;s++)o+=0|t[s],n[2*s]=8191&o,o>>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<i;++s)n[s]=0;r(0===o),r(0==(-8192&o))},p.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},p.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),o=this.stub(n),s=new Array(n),a=new Array(n),h=new Array(n),u=new Array(n),l=new Array(n),f=new Array(n),c=r.words;c.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(e.words,e.length,u,n),this.transform(s,o,a,h,n,i),this.transform(u,o,l,f,n,i);for(var d=0;d<n;d++){var m=a[d]*l[d]-h[d]*f[d];h[d]=a[d]*f[d]+h[d]*l[d],a[d]=m}return this.conjugate(a,h,n),this.transform(a,h,c,o,n,i),this.conjugate(c,o,n),this.normalize13b(c,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),m(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){r("number"==typeof t),r(t<67108864);for(var e=0,n=0;n<this.length;n++){var i=(0|this.words[n])*t,o=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=o>>>26,this.words[n]=67108863&o}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(t.words[n]&1<<i)>>>i}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,h=(0|this.words[e])-a<<n;this.words[e]=h|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this.strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,h=n;if(i-=s,i=Math.max(0,i),h){for(var u=0;u<s;u++)h.words[u]=this.words[u];h.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=i);u--){var f=0|this.words[u];this.words[u]=l<<26-o|f>>>o,l=f&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n)&&!!(this.words[n]&i)},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this.strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(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)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(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 e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var h=(0|t.words[i])*e;a=((o-=67108863&h)>>26)-(h/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!==(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,h=n.length-o.length;if("mod"!==e){(a=new i(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var l=n.clone()._ishlnsubmul(o,1,h);0===l.negative&&(n=l,a&&(a.words[h]=1));for(var f=h-1;f>=0;f--){var c=67108864*(0|n.words[o.length+f])+(0|n.words[o.length+f-1]);for(c=Math.min(c/s|0,67108863),n._ishlnsubmul(o,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(o,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},i.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),h=new i(1),u=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(f)),o.iushrn(1),s.iushrn(1);for(var m=0,p=1;0==(n.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(n.iushrn(m);m-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(f)),a.iushrn(1),h.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(h)):(n.isub(e),a.isub(o),h.isub(s))}return{a:a,b:h,gcd:n.iushln(u)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),h=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new M(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(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 i(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n<r;n++)e.words[n]=t.words[n];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=4194303&i,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(4194303&o)<<4|i>>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,y),n(b,y),n(E,y),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new w;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},M.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},M.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},M.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,o),c=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),m=s;0!==d.cmp(a);){for(var p=d,g=0;0!==p.cmp(a);g++)p=p.redSqr();r(g<m);var y=this.pow(f,new i(1).iushln(m-g-1));c=c.redMul(y),f=y.redSqr(),d=d.redMul(f),m=g}return c},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],l=h-1;l>=0;l--){var f=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===l)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}h=26}return o},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new _(t)},n(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,o)})).BN;const uv=new Yy("bignumber/5.4.0"),lv={};let fv=!1;class cv{constructor(t,e){uv.checkNew(new.target,cv),t!==lv&&uv.throwError("cannot call constructor directly; use BigNumber.from",Yy.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return mv(pv(this).fromTwos(t))}toTwos(t){return mv(pv(this).toTwos(t))}abs(){return"-"===this._hex[0]?cv.from(this._hex.substring(1)):this}add(t){return mv(pv(this).add(pv(t)))}sub(t){return mv(pv(this).sub(pv(t)))}div(t){return cv.from(t).isZero()&&gv("division by zero","div"),mv(pv(this).div(pv(t)))}mul(t){return mv(pv(this).mul(pv(t)))}mod(t){const e=pv(t);return e.isNeg()&&gv("cannot modulo negative values","mod"),mv(pv(this).umod(e))}pow(t){const e=pv(t);return e.isNeg()&&gv("cannot raise to negative values","pow"),mv(pv(this).pow(e))}and(t){const e=pv(t);return(this.isNegative()||e.isNeg())&&gv("cannot 'and' negative values","and"),mv(pv(this).and(e))}or(t){const e=pv(t);return(this.isNegative()||e.isNeg())&&gv("cannot 'or' negative values","or"),mv(pv(this).or(e))}xor(t){const e=pv(t);return(this.isNegative()||e.isNeg())&&gv("cannot 'xor' negative values","xor"),mv(pv(this).xor(e))}mask(t){return(this.isNegative()||t<0)&&gv("cannot mask negative values","mask"),mv(pv(this).maskn(t))}shl(t){return(this.isNegative()||t<0)&&gv("cannot shift negative values","shl"),mv(pv(this).shln(t))}shr(t){return(this.isNegative()||t<0)&&gv("cannot shift negative values","shr"),mv(pv(this).shrn(t))}eq(t){return pv(this).eq(pv(t))}lt(t){return pv(this).lt(pv(t))}lte(t){return pv(this).lte(pv(t))}gt(t){return pv(this).gt(pv(t))}gte(t){return pv(this).gte(pv(t))}isNegative(){return"-"===this._hex[0]}isZero(){return pv(this).isZero()}toNumber(){try{return pv(this).toNumber()}catch(t){gv("overflow","toNumber",this.toString())}return null}toBigInt(){try{return BigInt(this.toString())}catch(t){}return uv.throwError("this platform does not support BigInt",Yy.errors.UNSUPPORTED_OPERATION,{value:this.toString()})}toString(){return arguments.length>0&&(10===arguments[0]?fv||(fv=!0,uv.warn("BigNumber.toString does not accept any parameters; base-10 is assumed")):16===arguments[0]?uv.throwError("BigNumber.toString does not accept any parameters; use bigNumber.toHexString()",Yy.errors.UNEXPECTED_ARGUMENT,{}):uv.throwError("BigNumber.toString does not accept parameters",Yy.errors.UNEXPECTED_ARGUMENT,{})),pv(this).toString(10)}toHexString(){return this._hex}toJSON(t){return{type:"BigNumber",hex:this.toHexString()}}static from(t){if(t instanceof cv)return t;if("string"==typeof t)return t.match(/^-?0x[0-9a-f]+$/i)?new cv(lv,dv(t)):t.match(/^-?[0-9]+$/)?new cv(lv,dv(new hv(t))):uv.throwArgumentError("invalid BigNumber string","value",t);if("number"==typeof t)return t%1&&gv("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&gv("overflow","BigNumber.from",t),cv.from(String(t));const e=t;if("bigint"==typeof e)return cv.from(e.toString());if(rv(e))return cv.from(ov(e));if(e)if(e.toHexString){const t=e.toHexString();if("string"==typeof t)return cv.from(t)}else{let t=e._hex;if(null==t&&"BigNumber"===e.type&&(t=e.hex),"string"==typeof t&&(iv(t)||"-"===t[0]&&iv(t.substring(1))))return cv.from(t)}return uv.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function dv(t){if("string"!=typeof t)return dv(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&uv.throwArgumentError("invalid hex","value",t),"0x00"===(t=dv(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 mv(t){return cv.from(dv(t))}function pv(t){const e=cv.from(t).toHexString();return"-"===e[0]?new hv("-"+e.substring(3),16):new hv(e.substring(2),16)}function gv(t,e,r){const n={fault:t,operation:e};return null!=r&&(n.value=r),uv.throwError(t,Yy.errors.NUMERIC_FAULT,n)}const yv=new Yy("bytes/5.4.0");function vv(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return vv(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function wv(t,e){if(e||(e={}),"number"==typeof t){yv.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),vv(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){if("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))return!1;if(e&&t.length!==2+2*e)return!1;return!0}(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":yv.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return vv(new Uint8Array(n))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}(t)?vv(new Uint8Array(t)):yv.throwArgumentError("invalid arrayify value","value",t)}function bv(t){return"0x"+nn.keccak_256(wv(t))}const Ev=new Yy("address/5.4.0");function Mv(t){iv(t,20)||Ev.throwArgumentError("invalid address","address",t);const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const n=nv(bv(r));for(let t=0;t<40;t+=2)n[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&n[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const _v={};for(let t=0;t<10;t++)_v[String(t)]=String(t);for(let t=0;t<26;t++)_v[String.fromCharCode(65+t)]=String(10+t);const Av=Math.floor(function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}(9007199254740991));function Nv(t){let e=null;if("string"!=typeof t&&Ev.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Mv(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Ev.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map(t=>_v[t]).join("");for(;e.length>=Av;){let t=e.substring(0,Av);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t)&&Ev.throwArgumentError("bad icap checksum","address",t),r=t.substring(4),e=new hv(r,36).toString(16);e.length<40;)e="0"+e;e=Mv("0x"+e)}else Ev.throwArgumentError("invalid address","address",t);var r;return e}window&&window.__awaiter;const Sv=new Yy("properties/5.4.0");function Rv(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function Uv(t){const e={};for(const r in t)e[r]=t[r];return e}const Iv={bigint:!0,boolean:!0,function:!0,number:!0,string:!0};function Pv(t){if(function t(e){if(null==e||Iv[typeof e])return!0;if(Array.isArray(e)||"object"==typeof e){if(!Object.isFrozen(e))return!1;const r=Object.keys(e);for(let n=0;n<r.length;n++)if(!t(e[r[n]]))return!1;return!0}return Sv.throwArgumentError("Cannot deepCopy "+typeof e,"object",e)}(t))return t;if(Array.isArray(t))return Object.freeze(t.map(t=>xv(t)));if("object"==typeof t){const e={};for(const r in t){const n=t[r];void 0!==n&&Rv(e,r,xv(n))}return e}return Sv.throwArgumentError("Cannot deepCopy "+typeof t,"object",t)}function xv(t){return Pv(t)}const kv=new Yy("bytes/5.4.0");function Tv(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return Tv(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function Ov(t,e){if(e||(e={}),"number"==typeof t){kv.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),Tv(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),function(t){return!!t.toHexString}(t)&&(t=t.toHexString()),function(t,e){if("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))return!1;if(e&&t.length!==2+2*e)return!1;return!0}(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":kv.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return Tv(new Uint8Array(n))}return function(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}(t)?Tv(new Uint8Array(t)):kv.throwArgumentError("invalid arrayify value","value",t)}const Cv=new Yy("strings/5.4.0");var Fv,Dv;function Lv(t,e,r,n,i){if(t===Dv.BAD_PREFIX||t===Dv.UNEXPECTED_CONTINUE){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return t===Dv.OVERRUN?r.length-e-1:0}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(Fv||(Fv={})),function(t){t.UNEXPECTED_CONTINUE="unexpected continuation byte",t.BAD_PREFIX="bad codepoint prefix",t.OVERRUN="string overrun",t.MISSING_CONTINUE="missing continuation byte",t.OUT_OF_RANGE="out of UTF-8 range",t.UTF16_SURROGATE="UTF-16 surrogate",t.OVERLONG="overlong representation"}(Dv||(Dv={}));Object.freeze({error:function(t,e,r,n,i){return Cv.throwArgumentError(`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:Lv,replace:function(t,e,r,n,i){return t===Dv.OVERLONG?(n.push(i),0):(n.push(65533),Lv(t,e,r))}});function $v(t){return bv(function(t,e=Fv.current){e!=Fv.current&&(Cv.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;const i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");const o=65536+((1023&n)<<10)+(1023&i);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return Ov(r)}(t))}var Bv=window&&window.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}h((n=n.apply(t,e||[])).next())}))};const jv=new Yy("hash/5.4.0"),zv=new Uint8Array(32);zv.fill(0);const Gv=cv.from(-1),qv=cv.from(0),Vv=cv.from(1),Kv=cv.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");const Wv=av(Vv.toHexString(),32),Hv=av(qv.toHexString(),32),Zv={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},Xv=["name","version","chainId","verifyingContract","salt"];function Jv(t){return function(e){return"string"!=typeof e&&jv.throwArgumentError("invalid domain value for "+JSON.stringify(t),"domain."+t,e),e}}const Yv={name:Jv("name"),version:Jv("version"),chainId:function(t){try{return cv.from(t).toString()}catch(t){}return jv.throwArgumentError('invalid domain value for "chainId"',"domain.chainId",t)},verifyingContract:function(t){try{return Nv(t).toLowerCase()}catch(t){}return jv.throwArgumentError('invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){try{const e=nv(t);if(32!==e.length)throw new Error("bad length");return ov(e)}catch(t){}return jv.throwArgumentError('invalid domain value "salt"',"domain.salt",t)}};function Qv(t){{const e=t.match(/^(u?)int(\d*)$/);if(e){const r=""===e[1],n=parseInt(e[2]||"256");(n%8!=0||n>256||e[2]&&e[2]!==String(n))&&jv.throwArgumentError("invalid numeric width","type",t);const i=Kv.mask(r?n-1:n),o=r?i.add(Vv).mul(Gv):qv;return function(e){const r=cv.from(e);return(r.lt(o)||r.gt(i))&&jv.throwArgumentError("value out-of-bounds for "+t,"value",e),av(r.toTwos(256).toHexString(),32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return(0===r||r>32||e[1]!==String(r))&&jv.throwArgumentError("invalid bytes width","type",t),function(e){return nv(e).length!==r&&jv.throwArgumentError("invalid length for "+t,"value",e),function(t){const e=nv(t),r=e.length%32;return r?sv([e,zv.slice(r)]):ov(e)}(e)}}}switch(t){case"address":return function(t){return av(Nv(t),32)};case"bool":return function(t){return t?Wv:Hv};case"bytes":return function(t){return bv(t)};case"string":return function(t){return $v(t)}}return null}function tw(t,e){return`${t}(${e.map(({name:t,type:e})=>e+" "+t).join(",")})`}class ew{constructor(t){Rv(this,"types",Object.freeze(xv(t))),Rv(this,"_encoderCache",{}),Rv(this,"_types",{});const e={},r={},n={};Object.keys(t).forEach(t=>{e[t]={},r[t]=[],n[t]={}});for(const n in t){const i={};t[n].forEach(o=>{i[o.name]&&jv.throwArgumentError(`duplicate variable name ${JSON.stringify(o.name)} in ${JSON.stringify(n)}`,"types",t),i[o.name]=!0;const s=o.type.match(/^([^\x5b]*)(\x5b|$)/)[1];s===n&&jv.throwArgumentError("circular type reference to "+JSON.stringify(s),"types",t);Qv(s)||(r[s]||jv.throwArgumentError("unknown type "+JSON.stringify(s),"types",t),r[s].push(n),e[n][s]=!0)})}const i=Object.keys(r).filter(t=>0===r[t].length);0===i.length?jv.throwArgumentError("missing primary type","types",t):i.length>1&&jv.throwArgumentError("ambiguous primary types or unused types: "+i.map(t=>JSON.stringify(t)).join(", "),"types",t),Rv(this,"primaryType",i[0]),function i(o,s){s[o]&&jv.throwArgumentError("circular type reference to "+JSON.stringify(o),"types",t),s[o]=!0,Object.keys(e[o]).forEach(t=>{r[t]&&(i(t,s),Object.keys(s).forEach(e=>{n[e][t]=!0}))}),delete s[o]}(this.primaryType,{});for(const e in n){const r=Object.keys(n[e]);r.sort(),this._types[e]=tw(e,t[e])+r.map(e=>tw(e,t[e])).join("")}}getEncoder(t){let e=this._encoderCache[t];return e||(e=this._encoderCache[t]=this._getEncoder(t)),e}_getEncoder(t){{const e=Qv(t);if(e)return e}const e=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(e){const t=e[1],r=this.getEncoder(t),n=parseInt(e[3]);return e=>{n>=0&&e.length!==n&&jv.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e);let i=e.map(r);return this._types[t]&&(i=i.map(bv)),bv(sv(i))}}const r=this.types[t];if(r){const e=$v(this._types[t]);return t=>{const n=r.map(({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return this._types[r]?bv(n):n});return n.unshift(e),sv(n)}}return jv.throwArgumentError("unknown type: "+t,"type",t)}encodeType(t){const e=this._types[t];return e||jv.throwArgumentError("unknown type: "+JSON.stringify(t),"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return bv(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(Qv(t))return r(t,e);const n=t.match(/^(.*)(\x5b(\d*)\x5d)$/);if(n){const t=n[1],i=parseInt(n[3]);return i>=0&&e.length!==i&&jv.throwArgumentError("array length mismatch; expected length ${ arrayLength }","value",e),e.map(e=>this._visit(t,e,r))}const i=this.types[t];return i?i.reduce((t,{name:n,type:i})=>(t[n]=this._visit(i,e[n],r),t),{}):jv.throwArgumentError("unknown type: "+t,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new ew(t)}static getPrimaryType(t){return ew.from(t).primaryType}static hashStruct(t,e,r){return ew.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){const n=Zv[r];n||jv.throwArgumentError("invalid typed-data domain key: "+JSON.stringify(r),"domain",t),e.push({name:r,type:n})}return e.sort((t,e)=>Xv.indexOf(t.name)-Xv.indexOf(e.name)),ew.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return sv(["0x1901",ew.hashDomain(t),ew.from(e).hash(r)])}static hash(t,e,r){return bv(ew.encode(t,e,r))}static resolveNames(t,e,r,n){return Bv(this,void 0,void 0,(function*(){t=Uv(t);const i={};t.verifyingContract&&!iv(t.verifyingContract,20)&&(i[t.verifyingContract]="0x");const o=ew.from(e);o.visit(r,(t,e)=>("address"!==t||iv(e,20)||(i[e]="0x"),e));for(const t in i)i[t]=yield n(t);return t.verifyingContract&&i[t.verifyingContract]&&(t.verifyingContract=i[t.verifyingContract]),r=o.visit(r,(t,e)=>"address"===t&&i[e]?i[e]:e),{domain:t,value:r}}))}static getPayload(t,e,r){ew.hashDomain(t);const n={},i=[];Xv.forEach(e=>{const r=t[e];null!=r&&(n[e]=Yv[e](r),i.push({name:e,type:Zv[e]}))});const o=ew.from(e),s=Uv(e);return s.EIP712Domain?jv.throwArgumentError("types must not contain EIP712Domain type","types.EIP712Domain",e):s.EIP712Domain=i,o.encode(r),{types:s,domain:n,primaryType:o.primaryType,message:o.visit(r,(t,e)=>{if(t.match(/^bytes(\d*)/))return ov(nv(e));if(t.match(/^u?int/))return cv.from(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return"string"!=typeof e&&jv.throwArgumentError("invalid string","value",e),e}return jv.throwArgumentError("unsupported type","type",t)})}}}var rw=h((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Xt.Buffer}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function h(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s<o;s++){var a=t.charCodeAt(s)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.prototype._initNumber=function(t,e,n){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):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("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 i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,u=0,l=r;l<a;l+=n)u=h(t,l,l+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var f=1;for(u=h(t,l,t.length,e),l=0;l<s;l++)f*=e;this.imuln(f),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this.strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","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"],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,h=s/67108864|0;r.words[0]=a;for(var u=1;u<n;u++){for(var l=h>>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var m=u-d|0;l+=(s=(i=0|t.words[m])*(o=0|e.words[d])+f)/67108864|0,f=67108863&s}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],h=(16777215&(a<<i|o)).toString(16);n=0!==(o=a>>>24-i&16777215)||s!==this.length-1?u[6-h.length]+h+n:h+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];n="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modn(d).toString(t);n=(m=m.idivn(d)).isZero()?p+n:u[c-p.length]+p+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.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&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(t,e){return r(void 0!==o),this.toArrayLike(o,t,e)},i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var s,a,h="le"===e,u=new t(o),l=this.clone();if(h){for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[a]=s;for(;a<o;a++)u[a]=0}else{for(a=0;a<o-i;a++)u[a]=0;for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[o-a-1]=s}return u},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this.strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,e,r){var n,i,o,s=t.words,a=e.words,h=r.words,u=0,l=0|s[0],f=8191&l,c=l>>>13,d=0|s[1],m=8191&d,p=d>>>13,g=0|s[2],y=8191&g,v=g>>>13,w=0|s[3],b=8191&w,E=w>>>13,M=0|s[4],_=8191&M,A=M>>>13,N=0|s[5],S=8191&N,R=N>>>13,U=0|s[6],I=8191&U,P=U>>>13,x=0|s[7],k=8191&x,T=x>>>13,O=0|s[8],C=8191&O,F=O>>>13,D=0|s[9],L=8191&D,$=D>>>13,B=0|a[0],j=8191&B,z=B>>>13,G=0|a[1],q=8191&G,V=G>>>13,K=0|a[2],W=8191&K,H=K>>>13,Z=0|a[3],X=8191&Z,J=Z>>>13,Y=0|a[4],Q=8191&Y,tt=Y>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ft=8191<,ct=lt>>>13,dt=0|a[9],mt=8191&dt,pt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,z))+Math.imul(c,j)|0))<<13)|0;u=((o=Math.imul(c,z))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(m,j),i=(i=Math.imul(m,z))+Math.imul(p,j)|0,o=Math.imul(p,z);var yt=(u+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,V)|0)+Math.imul(c,q)|0))<<13)|0;u=((o=o+Math.imul(c,V)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,j),i=(i=Math.imul(y,z))+Math.imul(v,j)|0,o=Math.imul(v,z),n=n+Math.imul(m,q)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(p,q)|0,o=o+Math.imul(p,V)|0;var vt=(u+(n=n+Math.imul(f,W)|0)|0)+((8191&(i=(i=i+Math.imul(f,H)|0)+Math.imul(c,W)|0))<<13)|0;u=((o=o+Math.imul(c,H)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(b,j),i=(i=Math.imul(b,z))+Math.imul(E,j)|0,o=Math.imul(E,z),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,V)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,H)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,H)|0;var wt=(u+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,X)|0))<<13)|0;u=((o=o+Math.imul(c,J)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(_,j),i=(i=Math.imul(_,z))+Math.imul(A,j)|0,o=Math.imul(A,z),n=n+Math.imul(b,q)|0,i=(i=i+Math.imul(b,V)|0)+Math.imul(E,q)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(y,W)|0,i=(i=i+Math.imul(y,H)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,H)|0,n=n+Math.imul(m,X)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,J)|0;var bt=(u+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(S,j),i=(i=Math.imul(S,z))+Math.imul(R,j)|0,o=Math.imul(R,z),n=n+Math.imul(_,q)|0,i=(i=i+Math.imul(_,V)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,V)|0,n=n+Math.imul(b,W)|0,i=(i=i+Math.imul(b,H)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,H)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(p,Q)|0,o=o+Math.imul(p,tt)|0;var Et=(u+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;u=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(I,j),i=(i=Math.imul(I,z))+Math.imul(P,j)|0,o=Math.imul(P,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(_,W)|0,i=(i=i+Math.imul(_,H)|0)+Math.imul(A,W)|0,o=o+Math.imul(A,H)|0,n=n+Math.imul(b,X)|0,i=(i=i+Math.imul(b,J)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,J)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,nt)|0;var Mt=(u+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(c,ot)|0))<<13)|0;u=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,z))+Math.imul(T,j)|0,o=Math.imul(T,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,V)|0)+Math.imul(P,q)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,H)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,H)|0,n=n+Math.imul(_,X)|0,i=(i=i+Math.imul(_,J)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,st)|0;var _t=(u+(n=n+Math.imul(f,ht)|0)|0)+((8191&(i=(i=i+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((o=o+Math.imul(c,ut)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(C,j),i=(i=Math.imul(C,z))+Math.imul(F,j)|0,o=Math.imul(F,z),n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(T,q)|0,o=o+Math.imul(T,V)|0,n=n+Math.imul(I,W)|0,i=(i=i+Math.imul(I,H)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,H)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(_,Q)|0,i=(i=i+Math.imul(_,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var At=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,z))+Math.imul($,j)|0,o=Math.imul($,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,V)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,V)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,H)|0)+Math.imul(T,W)|0,o=o+Math.imul(T,H)|0,n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(_,rt)|0,i=(i=i+Math.imul(_,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(b,ot)|0,i=(i=i+Math.imul(b,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(m,ft)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(p,ft)|0,o=o+Math.imul(p,ct)|0;var Nt=(u+(n=n+Math.imul(f,mt)|0)|0)+((8191&(i=(i=i+Math.imul(f,pt)|0)+Math.imul(c,mt)|0))<<13)|0;u=((o=o+Math.imul(c,pt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(L,q),i=(i=Math.imul(L,V))+Math.imul($,q)|0,o=Math.imul($,V),n=n+Math.imul(C,W)|0,i=(i=i+Math.imul(C,H)|0)+Math.imul(F,W)|0,o=o+Math.imul(F,H)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(_,ot)|0,i=(i=i+Math.imul(_,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,n=n+Math.imul(b,ht)|0,i=(i=i+Math.imul(b,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,o=o+Math.imul(v,ct)|0;var St=(u+(n=n+Math.imul(m,mt)|0)|0)+((8191&(i=(i=i+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,W),i=(i=Math.imul(L,H))+Math.imul($,W)|0,o=Math.imul($,H),n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(_,ht)|0,i=(i=i+Math.imul(_,ut)|0)+Math.imul(A,ht)|0,o=o+Math.imul(A,ut)|0,n=n+Math.imul(b,ft)|0,i=(i=i+Math.imul(b,ct)|0)+Math.imul(E,ft)|0,o=o+Math.imul(E,ct)|0;var Rt=(u+(n=n+Math.imul(y,mt)|0)|0)+((8191&(i=(i=i+Math.imul(y,pt)|0)+Math.imul(v,mt)|0))<<13)|0;u=((o=o+Math.imul(v,pt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,J))+Math.imul($,X)|0,o=Math.imul($,J),n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(F,Q)|0,o=o+Math.imul(F,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,ut)|0,n=n+Math.imul(_,ft)|0,i=(i=i+Math.imul(_,ct)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,ct)|0;var Ut=(u+(n=n+Math.imul(b,mt)|0)|0)+((8191&(i=(i=i+Math.imul(b,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(i>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,n=Math.imul(L,Q),i=(i=Math.imul(L,tt))+Math.imul($,Q)|0,o=Math.imul($,tt),n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(F,rt)|0,o=o+Math.imul(F,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(S,ft)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(R,ft)|0,o=o+Math.imul(R,ct)|0;var It=(u+(n=n+Math.imul(_,mt)|0)|0)+((8191&(i=(i=i+Math.imul(_,pt)|0)+Math.imul(A,mt)|0))<<13)|0;u=((o=o+Math.imul(A,pt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul($,rt)|0,o=Math.imul($,nt),n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,st)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,ut)|0)+Math.imul(T,ht)|0,o=o+Math.imul(T,ut)|0,n=n+Math.imul(I,ft)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(P,ft)|0,o=o+Math.imul(P,ct)|0;var Pt=(u+(n=n+Math.imul(S,mt)|0)|0)+((8191&(i=(i=i+Math.imul(S,pt)|0)+Math.imul(R,mt)|0))<<13)|0;u=((o=o+Math.imul(R,pt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,ot),i=(i=Math.imul(L,st))+Math.imul($,ot)|0,o=Math.imul($,st),n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,ut)|0)+Math.imul(F,ht)|0,o=o+Math.imul(F,ut)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,ct)|0;var xt=(u+(n=n+Math.imul(I,mt)|0)|0)+((8191&(i=(i=i+Math.imul(I,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),n=n+Math.imul(C,ft)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(F,ft)|0,o=o+Math.imul(F,ct)|0;var kt=(u+(n=n+Math.imul(k,mt)|0)|0)+((8191&(i=(i=i+Math.imul(k,pt)|0)+Math.imul(T,mt)|0))<<13)|0;u=((o=o+Math.imul(T,pt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,ft),i=(i=Math.imul(L,ct))+Math.imul($,ft)|0,o=Math.imul($,ct);var Tt=(u+(n=n+Math.imul(C,mt)|0)|0)+((8191&(i=(i=i+Math.imul(C,pt)|0)+Math.imul(F,mt)|0))<<13)|0;u=((o=o+Math.imul(F,pt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863;var Ot=(u+(n=Math.imul(L,mt))|0)+((8191&(i=(i=Math.imul(L,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=wt,h[4]=bt,h[5]=Et,h[6]=Mt,h[7]=_t,h[8]=At,h[9]=Nt,h[10]=St,h[11]=Rt,h[12]=Ut,h[13]=It,h[14]=Pt,h[15]=xt,h[16]=kt,h[17]=Tt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new p).mulp(t,e,r)}function p(t,e){this.x=t,this.y=e}Math.imul||(d=c),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,f=(0|t.words[l])*(0|e.words[u]),c=67108863&f;a=67108863&(c=c+a|0),i+=(s=(s=s+(f/67108864|0)|0)+(c>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):m(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),r=i.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e},p.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n},p.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s<o;s++)n[s]=e[t[s]],i[s]=r[t[s]]},p.prototype.transform=function(t,e,r,n,i,o){this.permute(o,t,e,r,n,i);for(var s=1;s<i;s<<=1)for(var a=s<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),l=0;l<i;l+=a)for(var f=h,c=u,d=0;d<s;d++){var m=r[l+d],p=n[l+d],g=r[l+d+s],y=n[l+d+s],v=f*g-c*y;y=f*y+c*g,g=v,r[l+d]=m+g,n[l+d]=p+y,r[l+d+s]=m-g,n[l+d+s]=p-y,d!==a&&(v=h*f-u*c,c=h*c+u*f,f=v)}},p.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},p.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},p.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0}return t},p.prototype.convert13b=function(t,e,n,i){for(var o=0,s=0;s<e;s++)o+=0|t[s],n[2*s]=8191&o,o>>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<i;++s)n[s]=0;r(0===o),r(0==(-8192&o))},p.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},p.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),o=this.stub(n),s=new Array(n),a=new Array(n),h=new Array(n),u=new Array(n),l=new Array(n),f=new Array(n),c=r.words;c.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(e.words,e.length,u,n),this.transform(s,o,a,h,n,i),this.transform(u,o,l,f,n,i);for(var d=0;d<n;d++){var m=a[d]*l[d]-h[d]*f[d];h[d]=a[d]*f[d]+h[d]*l[d],a[d]=m}return this.conjugate(a,h,n),this.transform(a,h,c,o,n,i),this.conjugate(c,o,n),this.normalize13b(c,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),m(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){r("number"==typeof t),r(t<67108864);for(var e=0,n=0;n<this.length;n++){var i=(0|this.words[n])*t,o=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=o>>>26,this.words[n]=67108863&o}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(t.words[n]&1<<i)>>>i}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,h=(0|this.words[e])-a<<n;this.words[e]=h|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this.strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,h=n;if(i-=s,i=Math.max(0,i),h){for(var u=0;u<s;u++)h.words[u]=this.words[u];h.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=i);u--){var f=0|this.words[u];this.words[u]=l<<26-o|f>>>o,l=f&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n)&&!!(this.words[n]&i)},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this.strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(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)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(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 e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var h=(0|t.words[i])*e;a=((o-=67108863&h)>>26)-(h/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!==(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,h=n.length-o.length;if("mod"!==e){(a=new i(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var l=n.clone()._ishlnsubmul(o,1,h);0===l.negative&&(n=l,a&&(a.words[h]=1));for(var f=h-1;f>=0;f--){var c=67108864*(0|n.words[o.length+f])+(0|n.words[o.length+f-1]);for(c=Math.min(c/s|0,67108863),n._ishlnsubmul(o,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(o,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},i.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),h=new i(1),u=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(f)),o.iushrn(1),s.iushrn(1);for(var m=0,p=1;0==(n.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(n.iushrn(m);m-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(f)),a.iushrn(1),h.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(h)):(n.isub(e),a.isub(o),h.isub(s))}return{a:a,b:h,gcd:n.iushln(u)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),h=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new M(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(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 i(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n<r;n++)e.words[n]=t.words[n];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=4194303&i,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(4194303&o)<<4|i>>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,y),n(b,y),n(E,y),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new w;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},M.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},M.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},M.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,o),c=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),m=s;0!==d.cmp(a);){for(var p=d,g=0;0!==p.cmp(a);g++)p=p.redSqr();r(g<m);var y=this.pow(f,new i(1).iushln(m-g-1));c=c.redMul(y),f=y.redSqr(),d=d.redMul(f),m=g}return c},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],l=h-1;l>=0;l--){var f=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===l)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}h=26}return o},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new _(t)},n(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,o)}));function nw(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}var iw=ow;function ow(t,e){if(!t)throw new Error(e||"Assertion failed")}ow.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)};var sw=nw((function(t,e){var r=e;function n(t){return 1===t.length?"0"+t:t}function i(t){for(var e="",r=0;r<t.length;r++)e+=n(t[r].toString(16));return e}r.toArray=function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"!=typeof t){for(var n=0;n<t.length;n++)r[n]=0|t[n];return r}if("hex"===e){(t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t);for(n=0;n<t.length;n+=2)r.push(parseInt(t[n]+t[n+1],16))}else for(n=0;n<t.length;n++){var i=t.charCodeAt(n),o=i>>8,s=255&i;o?r.push(o,s):r.push(s)}return r},r.zero2=n,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}})),aw=nw((function(t,e){var r=e;r.assert=iw,r.toArray=sw.toArray,r.zero2=sw.zero2,r.toHex=sw.toHex,r.encode=sw.encode,r.getNAF=function(t,e,r){var n=new Array(Math.max(t.bitLength(),r)+1);n.fill(0);for(var i=1<<e+1,o=t.clone(),s=0;s<n.length;s++){var a,h=o.andln(i-1);o.isOdd()?(a=h>(i>>1)-1?(i>>1)-h:h,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},r.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,h=t.andln(3)+i&3,u=e.andln(3)+o&3;3===h&&(h=-1),3===u&&(u=-1),s=0==(1&h)?0:3!==(n=t.andln(7)+i&7)&&5!==n||2!==u?h:-h,r[0].push(s),a=0==(1&u)?0:3!==(n=e.andln(7)+o&7)&&5!==n||2!==h?u:-u,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new rw(t,"hex","le")}})),hw=aw.getNAF,uw=aw.getJSF,lw=aw.assert;function fw(t,e){this.type=t,this.p=new rw(e.p,16),this.red=e.prime?rw.red(e.prime):rw.mont(this.p),this.zero=new rw(0).toRed(this.red),this.one=new rw(1).toRed(this.red),this.two=new rw(2).toRed(this.red),this.n=e.n&&new rw(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var cw=fw;function dw(t,e){this.curve=t,this.type=e,this.precomputed=null}fw.prototype.point=function(){throw new Error("Not implemented")},fw.prototype.validate=function(){throw new Error("Not implemented")},fw.prototype._fixedNafMul=function(t,e){lw(t.precomputed);var r=t._getDoubles(),n=hw(e,1,this._bitLength),i=(1<<r.step+1)-(r.step%2==0?2:1);i/=3;var o,s,a=[];for(o=0;o<n.length;o+=r.step){s=0;for(var h=o+r.step-1;h>=o;h--)s=(s<<1)+n[h];a.push(s)}for(var u=this.jpoint(null,null,null),l=this.jpoint(null,null,null),f=i;f>0;f--){for(o=0;o<a.length;o++)(s=a[o])===f?l=l.mixedAdd(r.points[o]):s===-f&&(l=l.mixedAdd(r.points[o].neg()));u=u.add(l)}return u.toP()},fw.prototype._wnafMul=function(t,e){var r=4,n=t._getNAFPoints(r);r=n.wnd;for(var i=n.points,o=hw(e,r,this._bitLength),s=this.jpoint(null,null,null),a=o.length-1;a>=0;a--){for(var h=0;a>=0&&0===o[a];a--)h++;if(a>=0&&h++,s=s.dblp(h),a<0)break;var u=o[a];lw(0!==u),s="affine"===t.type?u>0?s.mixedAdd(i[u-1>>1]):s.mixedAdd(i[-u-1>>1].neg()):u>0?s.add(i[u-1>>1]):s.add(i[-u-1>>1].neg())}return"affine"===t.type?s.toP():s},fw.prototype._wnafMulAdd=function(t,e,r,n,i){var o,s,a,h=this._wnafT1,u=this._wnafT2,l=this._wnafT3,f=0;for(o=0;o<n;o++){var c=(a=e[o])._getNAFPoints(t);h[o]=c.wnd,u[o]=c.points}for(o=n-1;o>=1;o-=2){var d=o-1,m=o;if(1===h[d]&&1===h[m]){var p=[e[d],null,null,e[m]];0===e[d].y.cmp(e[m].y)?(p[1]=e[d].add(e[m]),p[2]=e[d].toJ().mixedAdd(e[m].neg())):0===e[d].y.cmp(e[m].y.redNeg())?(p[1]=e[d].toJ().mixedAdd(e[m]),p[2]=e[d].add(e[m].neg())):(p[1]=e[d].toJ().mixedAdd(e[m]),p[2]=e[d].toJ().mixedAdd(e[m].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],y=uw(r[d],r[m]);for(f=Math.max(y[0].length,f),l[d]=new Array(f),l[m]=new Array(f),s=0;s<f;s++){var v=0|y[0][s],w=0|y[1][s];l[d][s]=g[3*(v+1)+(w+1)],l[m][s]=0,u[d]=p}}else l[d]=hw(r[d],h[d],this._bitLength),l[m]=hw(r[m],h[m],this._bitLength),f=Math.max(l[d].length,f),f=Math.max(l[m].length,f)}var b=this.jpoint(null,null,null),E=this._wnafT4;for(o=f;o>=0;o--){for(var M=0;o>=0;){var _=!0;for(s=0;s<n;s++)E[s]=0|l[s][o],0!==E[s]&&(_=!1);if(!_)break;M++,o--}if(o>=0&&M++,b=b.dblp(M),o<0)break;for(s=0;s<n;s++){var A=E[s];0!==A&&(A>0?a=u[s][A-1>>1]:A<0&&(a=u[s][-A-1>>1].neg()),b="affine"===a.type?b.mixedAdd(a):b.add(a))}}for(o=0;o<n;o++)u[o]=null;return i?b:b.toP()},fw.BasePoint=dw,dw.prototype.eq=function(){throw new Error("Not implemented")},dw.prototype.validate=function(){return this.curve.validate(this)},fw.prototype.decodePoint=function(t,e){t=aw.toArray(t,e);var r=this.p.byteLength();if((4===t[0]||6===t[0]||7===t[0])&&t.length-1==2*r)return 6===t[0]?lw(t[t.length-1]%2==0):7===t[0]&&lw(t[t.length-1]%2==1),this.point(t.slice(1,1+r),t.slice(1+r,1+2*r));if((2===t[0]||3===t[0])&&t.length-1===r)return this.pointFromX(t.slice(1,1+r),3===t[0]);throw new Error("Unknown point format")},dw.prototype.encodeCompressed=function(t){return this.encode(t,!0)},dw.prototype._encode=function(t){var e=this.curve.p.byteLength(),r=this.getX().toArray("be",e);return t?[this.getY().isEven()?2:3].concat(r):[4].concat(r,this.getY().toArray("be",e))},dw.prototype.encode=function(t,e){return aw.encode(this._encode(e),t)},dw.prototype.precompute=function(t){if(this.precomputed)return this;var e={doubles:null,naf:null,beta:null};return e.naf=this._getNAFPoints(8),e.doubles=this._getDoubles(4,t),e.beta=this._getBeta(),this.precomputed=e,this},dw.prototype._hasDoubles=function(t){if(!this.precomputed)return!1;var e=this.precomputed.doubles;return!!e&&e.points.length>=Math.ceil((t.bitLength()+1)/e.step)},dw.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i<e;i+=t){for(var o=0;o<t;o++)n=n.dbl();r.push(n)}return{step:t,points:r}},dw.prototype._getNAFPoints=function(t){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var e=[this],r=(1<<t)-1,n=1===r?null:this.dbl(),i=1;i<r;i++)e[i]=e[i-1].add(n);return{wnd:t,points:e}},dw.prototype._getBeta=function(){return null},dw.prototype.dblp=function(t){for(var e=this,r=0;r<t;r++)e=e.dbl();return e};var mw=nw((function(t){"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}})),pw=aw.assert;function gw(t){cw.call(this,"short",t),this.a=new rw(t.a,16).toRed(this.red),this.b=new rw(t.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(t),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}mw(gw,cw);var yw=gw;function vw(t,e,r,n){cw.BasePoint.call(this,t,"affine"),null===e&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new rw(e,16),this.y=new rw(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function ww(t,e,r,n){cw.BasePoint.call(this,t,"jacobian"),null===e&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new rw(0)):(this.x=new rw(e,16),this.y=new rw(r,16),this.z=new rw(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}gw.prototype._getEndomorphism=function(t){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var e,r;if(t.beta)e=new rw(t.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);e=(e=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(t.lambda)r=new rw(t.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(e))?r=i[0]:(r=i[1],pw(0===this.g.mul(r).x.cmp(this.g.x.redMul(e))))}return{beta:e,lambda:r,basis:t.basis?t.basis.map((function(t){return{a:new rw(t.a,16),b:new rw(t.b,16)}})):this._getEndoBasis(r)}}},gw.prototype._getEndoRoots=function(t){var e=t===this.p?this.red:rw.mont(t),r=new rw(2).toRed(e).redInvm(),n=r.redNeg(),i=new rw(3).toRed(e).redNeg().redSqrt().redMul(r);return[n.redAdd(i).fromRed(),n.redSub(i).fromRed()]},gw.prototype._getEndoBasis=function(t){for(var e,r,n,i,o,s,a,h,u,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),f=t,c=this.n.clone(),d=new rw(1),m=new rw(0),p=new rw(0),g=new rw(1),y=0;0!==f.cmpn(0);){var v=c.div(f);h=c.sub(v.mul(f)),u=p.sub(v.mul(d));var w=g.sub(v.mul(m));if(!n&&h.cmp(l)<0)e=a.neg(),r=d,n=h.neg(),i=u;else if(n&&2==++y)break;a=h,c=f,f=h,p=d,d=u,g=m,m=w}o=h.neg(),s=u;var b=n.sqr().add(i.sqr());return o.sqr().add(s.sqr()).cmp(b)>=0&&(o=e,s=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),s=s.neg()),[{a:n,b:i},{a:o,b:s}]},gw.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),h=i.mul(r.b),u=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:h.add(u).neg()}},gw.prototype.pointFromX=function(t,e){(t=new rw(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},gw.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},gw.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o<t.length;o++){var s=this._endoSplit(e[o]),a=t[o],h=a._getBeta();s.k1.negative&&(s.k1.ineg(),a=a.neg(!0)),s.k2.negative&&(s.k2.ineg(),h=h.neg(!0)),n[2*o]=a,n[2*o+1]=h,i[2*o]=s.k1,i[2*o+1]=s.k2}for(var u=this._wnafMulAdd(1,n,i,2*o,r),l=0;l<2*o;l++)n[l]=null,i[l]=null;return u},mw(vw,cw.BasePoint),gw.prototype.point=function(t,e,r){return new vw(this,t,e,r)},gw.prototype.pointFromJSON=function(t,e){return vw.fromJSON(this,t,e)},vw.prototype._getBeta=function(){if(this.curve.endo){var t=this.precomputed;if(t&&t.beta)return t.beta;var e=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(t){var r=this.curve,n=function(t){return r.point(t.x.redMul(r.endo.beta),t.y)};t.beta=e,e.precomputed={beta:null,naf:t.naf&&{wnd:t.naf.wnd,points:t.naf.points.map(n)},doubles:t.doubles&&{step:t.doubles.step,points:t.doubles.points.map(n)}}}return e}},vw.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},vw.fromJSON=function(t,e,r){"string"==typeof e&&(e=JSON.parse(e));var n=t.point(e[0],e[1],r);if(!e[2])return n;function i(e){return t.point(e[0],e[1],r)}var o=e[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(i))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(i))}},n},vw.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},vw.prototype.isInfinity=function(){return this.inf},vw.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},vw.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},vw.prototype.getX=function(){return this.x.fromRed()},vw.prototype.getY=function(){return this.y.fromRed()},vw.prototype.mul=function(t){return t=new rw(t,16),this.isInfinity()?this:this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},vw.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},vw.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},vw.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},vw.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},vw.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},mw(ww,cw.BasePoint),gw.prototype.jpoint=function(t,e,r){return new ww(this,t,e,r)},ww.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},ww.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},ww.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),h=o.redSub(s);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),l=u.redMul(a),f=n.redMul(u),c=h.redSqr().redIAdd(l).redISub(f).redISub(f),d=h.redMul(f.redISub(c)).redISub(o.redMul(l)),m=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(c,d,m)},ww.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=s.redSqr(),u=h.redMul(s),l=r.redMul(h),f=a.redSqr().redIAdd(u).redISub(l).redISub(l),c=a.redMul(l.redISub(f)).redISub(i.redMul(u)),d=this.z.redMul(s);return this.curve.jpoint(f,c,d)},ww.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();var e;if(this.curve.zeroA||this.curve.threeA){var r=this;for(e=0;e<t;e++)r=r.dbl();return r}var n=this.curve.a,i=this.curve.tinv,o=this.x,s=this.y,a=this.z,h=a.redSqr().redSqr(),u=s.redAdd(s);for(e=0;e<t;e++){var l=o.redSqr(),f=u.redSqr(),c=f.redSqr(),d=l.redAdd(l).redIAdd(l).redIAdd(n.redMul(h)),m=o.redMul(f),p=d.redSqr().redISub(m.redAdd(m)),g=m.redISub(p),y=d.redMul(g);y=y.redIAdd(y).redISub(c);var v=u.redMul(a);e+1<t&&(h=h.redMul(c)),o=p,a=v,u=y}return this.curve.jpoint(o,u.redMul(i),a)},ww.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},ww.prototype._zeroDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n),h=a.redSqr().redISub(s).redISub(s),u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),t=h,e=a.redMul(s.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var l=this.x.redSqr(),f=this.y.redSqr(),c=f.redSqr(),d=this.x.redAdd(f).redSqr().redISub(l).redISub(c);d=d.redIAdd(d);var m=l.redAdd(l).redIAdd(l),p=m.redSqr(),g=c.redIAdd(c);g=(g=g.redIAdd(g)).redIAdd(g),t=p.redISub(d).redISub(d),e=m.redMul(d.redISub(t)).redISub(g),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(t,e,r)},ww.prototype._threeDbl=function(){var t,e,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),h=a.redSqr().redISub(s).redISub(s);t=h;var u=o.redIAdd(o);u=(u=u.redIAdd(u)).redIAdd(u),e=a.redMul(s.redISub(h)).redISub(u),r=this.y.redAdd(this.y)}else{var l=this.z.redSqr(),f=this.y.redSqr(),c=this.x.redMul(f),d=this.x.redSub(l).redMul(this.x.redAdd(l));d=d.redAdd(d).redIAdd(d);var m=c.redIAdd(c),p=(m=m.redIAdd(m)).redAdd(m);t=d.redSqr().redISub(p),r=this.y.redAdd(this.z).redSqr().redISub(f).redISub(l);var g=f.redSqr();g=(g=(g=g.redIAdd(g)).redIAdd(g)).redIAdd(g),e=d.redMul(m.redISub(t)).redISub(g)}return this.curve.jpoint(t,e,r)},ww.prototype._dbl=function(){var t=this.curve.a,e=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),o=e.redSqr(),s=r.redSqr(),a=o.redAdd(o).redIAdd(o).redIAdd(t.redMul(i)),h=e.redAdd(e),u=(h=h.redIAdd(h)).redMul(s),l=a.redSqr().redISub(u.redAdd(u)),f=u.redISub(l),c=s.redSqr();c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var d=a.redMul(f).redISub(c),m=r.redAdd(r).redMul(n);return this.curve.jpoint(l,d,m)},ww.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var t=this.x.redSqr(),e=this.y.redSqr(),r=this.z.redSqr(),n=e.redSqr(),i=t.redAdd(t).redIAdd(t),o=i.redSqr(),s=this.x.redAdd(e).redSqr().redISub(t).redISub(n),a=(s=(s=(s=s.redIAdd(s)).redAdd(s).redIAdd(s)).redISub(o)).redSqr(),h=n.redIAdd(n);h=(h=(h=h.redIAdd(h)).redIAdd(h)).redIAdd(h);var u=i.redIAdd(s).redSqr().redISub(o).redISub(a).redISub(h),l=e.redMul(u);l=(l=l.redIAdd(l)).redIAdd(l);var f=this.x.redMul(a).redISub(l);f=(f=f.redIAdd(f)).redIAdd(f);var c=this.y.redMul(u.redMul(h.redISub(u)).redISub(s.redMul(a)));c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var d=this.z.redAdd(s).redSqr().redISub(r).redISub(a);return this.curve.jpoint(f,c,d)},ww.prototype.mul=function(t,e){return t=new rw(t,e),this.curve._wnafMul(this,t)},ww.prototype.eq=function(t){if("affine"===t.type)return this.eq(t.toJ());if(this===t)return!0;var e=this.z.redSqr(),r=t.z.redSqr();if(0!==this.x.redMul(r).redISub(t.x.redMul(e)).cmpn(0))return!1;var n=e.redMul(this.z),i=r.redMul(t.z);return 0===this.y.redMul(i).redISub(t.y.redMul(n)).cmpn(0)},ww.prototype.eqXToP=function(t){var e=this.z.redSqr(),r=t.toRed(this.curve.red).redMul(e);if(0===this.x.cmp(r))return!0;for(var n=t.clone(),i=this.curve.redN.redMul(e);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},ww.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},ww.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var bw=nw((function(t,e){var r=e;r.base=cw,r.short=yw,r.mont=null,r.edwards=null})),Ew=nw((function(t,e){var r,n=e,i=aw.assert;function o(t){"short"===t.type?this.curve=new bw.short(t):"edwards"===t.type?this.curve=new bw.edwards(t):this.curve=new bw.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function s(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new o(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Zm.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Zm.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Zm.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Zm.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Zm.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Zm.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Zm.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=null.crash()}catch(t){r=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Zm.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})}));function Mw(t){if(!(this instanceof Mw))return new Mw(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=sw.toArray(t.entropy,t.entropyEnc||"hex"),r=sw.toArray(t.nonce,t.nonceEnc||"hex"),n=sw.toArray(t.pers,t.persEnc||"hex");iw(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var _w=Mw;Mw.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i<this.V.length;i++)this.K[i]=0,this.V[i]=1;this._update(n),this._reseed=1,this.reseedInterval=281474976710656},Mw.prototype._hmac=function(){return new Zm.hmac(this.hash,this.K)},Mw.prototype._update=function(t){var e=this._hmac().update(this.V).update([0]);t&&(e=e.update(t)),this.K=e.digest(),this.V=this._hmac().update(this.V).digest(),t&&(this.K=this._hmac().update(this.V).update([1]).update(t).digest(),this.V=this._hmac().update(this.V).digest())},Mw.prototype.reseed=function(t,e,r,n){"string"!=typeof e&&(n=r,r=e,e=null),t=sw.toArray(t,e),r=sw.toArray(r,n),iw(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},Mw.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=sw.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length<t;)this.V=this._hmac().update(this.V).digest(),i=i.concat(this.V);var o=i.slice(0,t);return this._update(r),this._reseed++,sw.encode(o,e)};var Aw=aw.assert;function Nw(t,e){this.ec=t,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}var Sw=Nw;Nw.fromPublic=function(t,e,r){return e instanceof Nw?e:new Nw(t,{pub:e,pubEnc:r})},Nw.fromPrivate=function(t,e,r){return e instanceof Nw?e:new Nw(t,{priv:e,privEnc:r})},Nw.prototype.validate=function(){var t=this.getPublic();return t.isInfinity()?{result:!1,reason:"Invalid public key"}:t.validate()?t.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},Nw.prototype.getPublic=function(t,e){return"string"==typeof t&&(e=t,t=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),e?this.pub.encode(e,t):this.pub},Nw.prototype.getPrivate=function(t){return"hex"===t?this.priv.toString(16,2):this.priv},Nw.prototype._importPrivate=function(t,e){this.priv=new rw(t,e||16),this.priv=this.priv.umod(this.ec.curve.n)},Nw.prototype._importPublic=function(t,e){if(t.x||t.y)return"mont"===this.ec.curve.type?Aw(t.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||Aw(t.x&&t.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(t.x,t.y));this.pub=this.ec.curve.decodePoint(t,e)},Nw.prototype.derive=function(t){return t.validate()||Aw(t.validate(),"public point not validated"),t.mul(this.priv).getX()},Nw.prototype.sign=function(t,e,r){return this.ec.sign(t,this,e,r)},Nw.prototype.verify=function(t,e){return this.ec.verify(t,e,this)},Nw.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"};var Rw=aw.assert;function Uw(t,e){if(t instanceof Uw)return t;this._importDER(t,e)||(Rw(t.r&&t.s,"Signature without r or s"),this.r=new rw(t.r,16),this.s=new rw(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Iw=Uw;function Pw(){this.place=0}function xw(t,e){var r=t[e.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,s=e.place;o<n;o++,s++)i<<=8,i|=t[s],i>>>=0;return!(i<=127)&&(e.place=s,i)}function kw(t){for(var e=0,r=t.length-1;!t[e]&&!(128&t[e+1])&&e<r;)e++;return 0===e?t:t.slice(e)}function Tw(t,e){if(e<128)t.push(e);else{var r=1+(Math.log(e)/Math.LN2>>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}Uw.prototype._importDER=function(t,e){t=aw.toArray(t,e);var r=new Pw;if(48!==t[r.place++])return!1;var n=xw(t,r);if(!1===n)return!1;if(n+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var i=xw(t,r);if(!1===i)return!1;var o=t.slice(r.place,i+r.place);if(r.place+=i,2!==t[r.place++])return!1;var s=xw(t,r);if(!1===s)return!1;if(t.length!==s+r.place)return!1;var a=t.slice(r.place,s+r.place);if(0===o[0]){if(!(128&o[1]))return!1;o=o.slice(1)}if(0===a[0]){if(!(128&a[1]))return!1;a=a.slice(1)}return this.r=new rw(o),this.s=new rw(a),this.recoveryParam=null,!0},Uw.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=kw(e),r=kw(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];Tw(n,e.length),(n=n.concat(e)).push(2),Tw(n,r.length);var i=n.concat(r),o=[48];return Tw(o,i.length),o=o.concat(i),aw.encode(o,t)};var Ow=function(){throw new Error("unsupported")},Cw=aw.assert;function Fw(t){if(!(this instanceof Fw))return new Fw(t);"string"==typeof t&&(Cw(Object.prototype.hasOwnProperty.call(Ew,t),"Unknown curve "+t),t=Ew[t]),t instanceof Ew.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var Dw=Fw;Fw.prototype.keyPair=function(t){return new Sw(this,t)},Fw.prototype.keyFromPrivate=function(t,e){return Sw.fromPrivate(this,t,e)},Fw.prototype.keyFromPublic=function(t,e){return Sw.fromPublic(this,t,e)},Fw.prototype.genKeyPair=function(t){t||(t={});for(var e=new _w({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||Ow(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new rw(2));;){var i=new rw(e.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},Fw.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Fw.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new rw(t,16));for(var i=this.n.byteLength(),o=e.getPrivate().toArray("be",i),s=t.toArray("be",i),a=new _w({hash:this.hash,entropy:o,nonce:s,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new rw(1)),u=0;;u++){var l=n.k?n.k(u):new rw(a.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(h)>=0)){var f=this.g.mul(l);if(!f.isInfinity()){var c=f.getX(),d=c.umod(this.n);if(0!==d.cmpn(0)){var m=l.invm(this.n).mul(d.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var p=(f.getY().isOdd()?1:0)|(0!==c.cmp(d)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),p^=1),new Iw({r:d,s:m,recoveryParam:p})}}}}}},Fw.prototype.verify=function(t,e,r,n){t=this._truncateToN(new rw(t,16)),r=this.keyFromPublic(r,n);var i=(e=new Iw(e,"hex")).r,o=e.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var s,a=o.invm(this.n),h=a.mul(t).umod(this.n),u=a.mul(i).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(h,r.getPublic(),u)).isInfinity()&&s.eqXToP(i):!(s=this.g.mulAdd(h,r.getPublic(),u)).isInfinity()&&0===s.getX().umod(this.n).cmp(i)},Fw.prototype.recoverPubKey=function(t,e,r,n){Cw((3&r)===r,"The recovery param is more than two bits"),e=new Iw(e,n);var i=this.n,o=new rw(t),s=e.r,a=e.s,h=1&r,u=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");s=u?this.curve.pointFromX(s.add(this.curve.n),h):this.curve.pointFromX(s,h);var l=e.r.invm(i),f=i.sub(o).mul(l).umod(i),c=a.mul(l).umod(i);return this.g.mulAdd(f,s,c)},Fw.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new Iw(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var Lw=nw((function(t,e){var r=e;r.version="6.5.4",r.utils=aw,r.rand=function(){throw new Error("unsupported")},r.curve=bw,r.curves=Ew,r.ec=Dw,r.eddsa=null})).ec;const $w=new Yy("bytes/5.4.0");function Bw(t){return!!t.toHexString}function jw(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return jw(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function zw(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}function Gw(t,e){if(e||(e={}),"number"==typeof t){$w.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),jw(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Bw(t)&&(t=t.toHexString()),qw(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":$w.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return jw(new Uint8Array(n))}return zw(t)?jw(new Uint8Array(t)):$w.throwArgumentError("invalid arrayify value","value",t)}function qw(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}function Vw(t,e){if(e||(e={}),"number"==typeof t){$w.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),Bw(t))return t.toHexString();if(qw(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":$w.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(zw(t)){let e="0x";for(let r=0;r<t.length;r++){let n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return $w.throwArgumentError("invalid hexlify value","value",t)}function Kw(t,e){for("string"!=typeof t?t=Vw(t):qw(t)||$w.throwArgumentError("invalid hex string","value",t),t.length>2*e+2&&$w.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function Ww(t){const e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(qw(r=t)&&!(r.length%2)||zw(r)){const r=Gw(t);65!==r.length&&$w.throwArgumentError("invalid signature string; must be 65 bytes","signature",t),e.r=Vw(r.slice(0,32)),e.s=Vw(r.slice(32,64)),e.v=r[64],e.v<27&&(0===e.v||1===e.v?e.v+=27:$w.throwArgumentError("signature invalid v byte","signature",t)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(r[32]|=128),e._vs=Vw(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e._vs){const r=function(t,e){(t=Gw(t)).length>e&&$w.throwArgumentError("value out of range","value",arguments[0]);const r=new Uint8Array(e);return r.set(t,e-t.length),jw(r)}(Gw(e._vs),32);e._vs=Vw(r);const n=r[0]>=128?1:0;null==e.recoveryParam?e.recoveryParam=n:e.recoveryParam!==n&&$w.throwArgumentError("signature recoveryParam mismatch _vs","signature",t),r[0]&=127;const i=Vw(r);null==e.s?e.s=i:e.s!==i&&$w.throwArgumentError("signature v mismatch _vs","signature",t)}null==e.recoveryParam?null==e.v?$w.throwArgumentError("signature missing v and recoveryParam","signature",t):0===e.v||1===e.v?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2:null==e.v?e.v=27+e.recoveryParam:e.recoveryParam!==1-e.v%2&&$w.throwArgumentError("signature recoveryParam mismatch v","signature",t),null!=e.r&&qw(e.r)?e.r=Kw(e.r,32):$w.throwArgumentError("signature missing or invalid r","signature",t),null!=e.s&&qw(e.s)?e.s=Kw(e.s,32):$w.throwArgumentError("signature missing or invalid s","signature",t);const r=Gw(e.s);r[0]>=128&&$w.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128);const n=Vw(r);e._vs&&(qw(e._vs)||$w.throwArgumentError("signature invalid _vs","signature",t),e._vs=Kw(e._vs,32)),null==e._vs?e._vs=n:e._vs!==n&&$w.throwArgumentError("signature _vs mismatch v and s","signature",t)}var r;return e}const Hw=new Yy("signing-key/5.4.0");let Zw=null;function Xw(){return Zw||(Zw=new Lw("secp256k1")),Zw}class Jw{constructor(t){Rv(this,"curve","secp256k1"),Rv(this,"privateKey",Vw(t));const e=Xw().keyFromPrivate(Gw(this.privateKey));Rv(this,"publicKey","0x"+e.getPublic(!1,"hex")),Rv(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),Rv(this,"_isSigningKey",!0)}_addPoint(t){const e=Xw().keyFromPublic(Gw(this.publicKey)),r=Xw().keyFromPublic(Gw(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){const e=Xw().keyFromPrivate(Gw(this.privateKey)),r=Gw(t);32!==r.length&&Hw.throwArgumentError("bad digest length","digest",t);const n=e.sign(r,{canonical:!0});return Ww({recoveryParam:n.recoveryParam,r:Kw("0x"+n.r.toString(16),32),s:Kw("0x"+n.s.toString(16),32)})}computeSharedSecret(t){const e=Xw().keyFromPrivate(Gw(this.privateKey)),r=Xw().keyFromPublic(Gw(Yw(t)));return Kw("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function Yw(t,e){const r=Gw(t);if(32===r.length){const t=new Jw(r);return e?"0x"+Xw().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?Vw(r):"0x"+Xw().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+Xw().keyFromPublic(r).getPublic(!0,"hex"):Vw(r):Hw.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Qw=new Yy("bytes/5.4.0");function tb(t){return!!t.toHexString}function eb(t){return t.slice||(t.slice=function(){const e=Array.prototype.slice.call(arguments);return eb(new Uint8Array(Array.prototype.slice.apply(t,e)))}),t}function rb(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e<t.length;e++){const r=t[e];if("number"!=typeof r||r<0||r>=256||r%1)return!1}return!0}function nb(t,e){if(e||(e={}),"number"==typeof t){Qw.checkSafeUint53(t,"invalid arrayify value");const e=[];for(;t;)e.unshift(255&t),t=parseInt(String(t/256));return 0===e.length&&e.push(0),eb(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),tb(t)&&(t=t.toHexString()),ib(t)){let r=t.substring(2);r.length%2&&("left"===e.hexPad?r="0x0"+r.substring(2):"right"===e.hexPad?r+="0":Qw.throwArgumentError("hex data is odd-length","value",t));const n=[];for(let t=0;t<r.length;t+=2)n.push(parseInt(r.substring(t,t+2),16));return eb(new Uint8Array(n))}return rb(t)?eb(new Uint8Array(t)):Qw.throwArgumentError("invalid arrayify value","value",t)}function ib(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}function ob(t,e,r){return"string"!=typeof t?t=function(t,e){if(e||(e={}),"number"==typeof t){Qw.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e="0123456789abcdef"[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if("bigint"==typeof t)return(t=t.toString(16)).length%2?"0x0"+t:"0x"+t;if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),tb(t))return t.toHexString();if(ib(t))return t.length%2&&("left"===e.hexPad?t="0x0"+t.substring(2):"right"===e.hexPad?t+="0":Qw.throwArgumentError("hex data is odd-length","value",t)),t.toLowerCase();if(rb(t)){let e="0x";for(let r=0;r<t.length;r++){let n=t[r];e+="0123456789abcdef"[(240&n)>>4]+"0123456789abcdef"[15&n]}return e}return Qw.throwArgumentError("invalid hexlify value","value",t)}(t):(!ib(t)||t.length%2)&&Qw.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}var sb=h((function(t){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function i(t,e,r){if(i.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Xt.Buffer}catch(t){}function s(t,e){var r=t.charCodeAt(e);return r>=65&&r<=70?r-55:r>=97&&r<=102?r-87:r-48&15}function a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function h(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s<o;s++){var a=t.charCodeAt(s)-48;i*=n,i+=a>=49?a-49+10:a>=17?a-17+10:a}return i}i.isBN=function(t){return t instanceof i||null!==t&&"object"==typeof t&&t.constructor.wordSize===i.wordSize&&Array.isArray(t.words)},i.max=function(t,e){return t.cmp(e)>0?t:e},i.min=function(t,e){return t.cmp(e)<0?t:e},i.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(i++,this.negative=1),i<t.length&&(16===e?this._parseHex(t,i,n):(this._parseBase(t,e,i),"le"===n&&this._initArray(this.toArray(),e,n)))},i.prototype._initNumber=function(t,e,n){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):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},i.prototype._initArray=function(t,e,n){if(r("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 i=0;i<this.length;i++)this.words[i]=0;var o,s,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this.strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,u=0,l=r;l<a;l+=n)u=h(t,l,l+n,e),this.imuln(i),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==s){var f=1;for(u=h(t,l,t.length,e),l=0;l<s;l++)f*=e;this.imuln(f),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this.strip()},i.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},i.prototype.clone=function(){var t=new i(null);return this.copy(t),t},i.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var u=["","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"],l=[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],f=[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 c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,h=s/67108864|0;r.words[0]=a;for(var u=1;u<n;u++){for(var l=h>>>26,f=67108863&h,c=Math.min(u,e.length-1),d=Math.max(0,u-t.length+1);d<=c;d++){var m=u-d|0;l+=(s=(i=0|t.words[m])*(o=0|e.words[d])+f)/67108864|0,f=67108863&s}r.words[u]=0|f,h=0|l}return 0!==h?r.words[u]=0|h:r.length--,r.strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],h=(16777215&(a<<i|o)).toString(16);n=0!==(o=a>>>24-i&16777215)||s!==this.length-1?u[6-h.length]+h+n:h+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];n="";var m=this.clone();for(m.negative=0;!m.isZero();){var p=m.modn(d).toString(t);n=(m=m.idivn(d)).isZero()?p+n:u[c-p.length]+p+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.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&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(t,e){return r(void 0!==o),this.toArrayLike(o,t,e)},i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var s,a,h="le"===e,u=new t(o),l=this.clone();if(h){for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[a]=s;for(;a<o;a++)u[a]=0}else{for(a=0;a<o-i;a++)u[a]=0;for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),u[o-a-1]=s}return u},Math.clz32?i.prototype._countBits=function(t){return 32-Math.clz32(t)}:i.prototype._countBits=function(t){var e=t,r=0;return e>=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},i.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},i.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var r=this._zeroBits(this.words[e]);if(t+=r,26!==r)break}return t},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},i.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this.strip()},i.prototype.ior=function(t){return r(0==(this.negative|t.negative)),this.iuor(t)},i.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},i.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},i.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;r<e.length;r++)this.words[r]=this.words[r]&t.words[r];return this.length=e.length,this.strip()},i.prototype.iand=function(t){return r(0==(this.negative|t.negative)),this.iuand(t)},i.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},i.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},i.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;n<r.length;n++)this.words[n]=e.words[n]^r.words[n];if(this!==e)for(;n<e.length;n++)this.words[n]=e.words[n];return this.length=e.length,this.strip()},i.prototype.ixor=function(t){return r(0==(this.negative|t.negative)),this.iuxor(t)},i.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},i.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},i.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i<e;i++)this.words[i]=67108863&~this.words[i];return n>0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(t){return this.clone().inotn(t)},i.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<i:this.words[n]&~(1<<i),this.strip()},i.prototype.iadd=function(t){var e,r,n;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o<n.length;o++)e=(0|r.words[o])+(0|n.words[o])+i,this.words[o]=67108863&e,i=e>>>26;for(;0!==i&&o<r.length;o++)e=(0|r.words[o])+i,this.words[o]=67108863&e,i=e>>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;o<r.length;o++)this.words[o]=r.words[o];return this},i.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},i.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s<n.length;s++)o=(e=(0|r.words[s])-(0|n.words[s])+o)>>26,this.words[s]=67108863&e;for(;0!==o&&s<r.length;s++)o=(e=(0|r.words[s])+o)>>26,this.words[s]=67108863&e;if(0===o&&s<r.length&&r!==this)for(;s<r.length;s++)this.words[s]=r.words[s];return this.length=Math.max(this.length,s),r!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(t){return this.clone().isub(t)};var d=function(t,e,r){var n,i,o,s=t.words,a=e.words,h=r.words,u=0,l=0|s[0],f=8191&l,c=l>>>13,d=0|s[1],m=8191&d,p=d>>>13,g=0|s[2],y=8191&g,v=g>>>13,w=0|s[3],b=8191&w,E=w>>>13,M=0|s[4],_=8191&M,A=M>>>13,N=0|s[5],S=8191&N,R=N>>>13,U=0|s[6],I=8191&U,P=U>>>13,x=0|s[7],k=8191&x,T=x>>>13,O=0|s[8],C=8191&O,F=O>>>13,D=0|s[9],L=8191&D,$=D>>>13,B=0|a[0],j=8191&B,z=B>>>13,G=0|a[1],q=8191&G,V=G>>>13,K=0|a[2],W=8191&K,H=K>>>13,Z=0|a[3],X=8191&Z,J=Z>>>13,Y=0|a[4],Q=8191&Y,tt=Y>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ht=8191&at,ut=at>>>13,lt=0|a[8],ft=8191<,ct=lt>>>13,dt=0|a[9],mt=8191&dt,pt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(u+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,z))+Math.imul(c,j)|0))<<13)|0;u=((o=Math.imul(c,z))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(m,j),i=(i=Math.imul(m,z))+Math.imul(p,j)|0,o=Math.imul(p,z);var yt=(u+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,V)|0)+Math.imul(c,q)|0))<<13)|0;u=((o=o+Math.imul(c,V)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,j),i=(i=Math.imul(y,z))+Math.imul(v,j)|0,o=Math.imul(v,z),n=n+Math.imul(m,q)|0,i=(i=i+Math.imul(m,V)|0)+Math.imul(p,q)|0,o=o+Math.imul(p,V)|0;var vt=(u+(n=n+Math.imul(f,W)|0)|0)+((8191&(i=(i=i+Math.imul(f,H)|0)+Math.imul(c,W)|0))<<13)|0;u=((o=o+Math.imul(c,H)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(b,j),i=(i=Math.imul(b,z))+Math.imul(E,j)|0,o=Math.imul(E,z),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,V)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,V)|0,n=n+Math.imul(m,W)|0,i=(i=i+Math.imul(m,H)|0)+Math.imul(p,W)|0,o=o+Math.imul(p,H)|0;var wt=(u+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,X)|0))<<13)|0;u=((o=o+Math.imul(c,J)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(_,j),i=(i=Math.imul(_,z))+Math.imul(A,j)|0,o=Math.imul(A,z),n=n+Math.imul(b,q)|0,i=(i=i+Math.imul(b,V)|0)+Math.imul(E,q)|0,o=o+Math.imul(E,V)|0,n=n+Math.imul(y,W)|0,i=(i=i+Math.imul(y,H)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,H)|0,n=n+Math.imul(m,X)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(p,X)|0,o=o+Math.imul(p,J)|0;var bt=(u+(n=n+Math.imul(f,Q)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Q)|0))<<13)|0;u=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(S,j),i=(i=Math.imul(S,z))+Math.imul(R,j)|0,o=Math.imul(R,z),n=n+Math.imul(_,q)|0,i=(i=i+Math.imul(_,V)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,V)|0,n=n+Math.imul(b,W)|0,i=(i=i+Math.imul(b,H)|0)+Math.imul(E,W)|0,o=o+Math.imul(E,H)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,tt)|0)+Math.imul(p,Q)|0,o=o+Math.imul(p,tt)|0;var Et=(u+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;u=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(I,j),i=(i=Math.imul(I,z))+Math.imul(P,j)|0,o=Math.imul(P,z),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,V)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,V)|0,n=n+Math.imul(_,W)|0,i=(i=i+Math.imul(_,H)|0)+Math.imul(A,W)|0,o=o+Math.imul(A,H)|0,n=n+Math.imul(b,X)|0,i=(i=i+Math.imul(b,J)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,J)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,Q)|0,o=o+Math.imul(v,tt)|0,n=n+Math.imul(m,rt)|0,i=(i=i+Math.imul(m,nt)|0)+Math.imul(p,rt)|0,o=o+Math.imul(p,nt)|0;var Mt=(u+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(c,ot)|0))<<13)|0;u=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,z))+Math.imul(T,j)|0,o=Math.imul(T,z),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,V)|0)+Math.imul(P,q)|0,o=o+Math.imul(P,V)|0,n=n+Math.imul(S,W)|0,i=(i=i+Math.imul(S,H)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,H)|0,n=n+Math.imul(_,X)|0,i=(i=i+Math.imul(_,J)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(b,Q)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(E,Q)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(m,ot)|0,i=(i=i+Math.imul(m,st)|0)+Math.imul(p,ot)|0,o=o+Math.imul(p,st)|0;var _t=(u+(n=n+Math.imul(f,ht)|0)|0)+((8191&(i=(i=i+Math.imul(f,ut)|0)+Math.imul(c,ht)|0))<<13)|0;u=((o=o+Math.imul(c,ut)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(C,j),i=(i=Math.imul(C,z))+Math.imul(F,j)|0,o=Math.imul(F,z),n=n+Math.imul(k,q)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(T,q)|0,o=o+Math.imul(T,V)|0,n=n+Math.imul(I,W)|0,i=(i=i+Math.imul(I,H)|0)+Math.imul(P,W)|0,o=o+Math.imul(P,H)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(_,Q)|0,i=(i=i+Math.imul(_,tt)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(b,rt)|0,i=(i=i+Math.imul(b,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(m,ht)|0,i=(i=i+Math.imul(m,ut)|0)+Math.imul(p,ht)|0,o=o+Math.imul(p,ut)|0;var At=(u+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;u=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,z))+Math.imul($,j)|0,o=Math.imul($,z),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,V)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,V)|0,n=n+Math.imul(k,W)|0,i=(i=i+Math.imul(k,H)|0)+Math.imul(T,W)|0,o=o+Math.imul(T,H)|0,n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(R,Q)|0,o=o+Math.imul(R,tt)|0,n=n+Math.imul(_,rt)|0,i=(i=i+Math.imul(_,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(b,ot)|0,i=(i=i+Math.imul(b,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,ut)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,ut)|0,n=n+Math.imul(m,ft)|0,i=(i=i+Math.imul(m,ct)|0)+Math.imul(p,ft)|0,o=o+Math.imul(p,ct)|0;var Nt=(u+(n=n+Math.imul(f,mt)|0)|0)+((8191&(i=(i=i+Math.imul(f,pt)|0)+Math.imul(c,mt)|0))<<13)|0;u=((o=o+Math.imul(c,pt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(L,q),i=(i=Math.imul(L,V))+Math.imul($,q)|0,o=Math.imul($,V),n=n+Math.imul(C,W)|0,i=(i=i+Math.imul(C,H)|0)+Math.imul(F,W)|0,o=o+Math.imul(F,H)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(I,Q)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(R,rt)|0,o=o+Math.imul(R,nt)|0,n=n+Math.imul(_,ot)|0,i=(i=i+Math.imul(_,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,n=n+Math.imul(b,ht)|0,i=(i=i+Math.imul(b,ut)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,ut)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,o=o+Math.imul(v,ct)|0;var St=(u+(n=n+Math.imul(m,mt)|0)|0)+((8191&(i=(i=i+Math.imul(m,pt)|0)+Math.imul(p,mt)|0))<<13)|0;u=((o=o+Math.imul(p,pt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,W),i=(i=Math.imul(L,H))+Math.imul($,W)|0,o=Math.imul($,H),n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(R,ot)|0,o=o+Math.imul(R,st)|0,n=n+Math.imul(_,ht)|0,i=(i=i+Math.imul(_,ut)|0)+Math.imul(A,ht)|0,o=o+Math.imul(A,ut)|0,n=n+Math.imul(b,ft)|0,i=(i=i+Math.imul(b,ct)|0)+Math.imul(E,ft)|0,o=o+Math.imul(E,ct)|0;var Rt=(u+(n=n+Math.imul(y,mt)|0)|0)+((8191&(i=(i=i+Math.imul(y,pt)|0)+Math.imul(v,mt)|0))<<13)|0;u=((o=o+Math.imul(v,pt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,J))+Math.imul($,X)|0,o=Math.imul($,J),n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,tt)|0)+Math.imul(F,Q)|0,o=o+Math.imul(F,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(S,ht)|0,i=(i=i+Math.imul(S,ut)|0)+Math.imul(R,ht)|0,o=o+Math.imul(R,ut)|0,n=n+Math.imul(_,ft)|0,i=(i=i+Math.imul(_,ct)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,ct)|0;var Ut=(u+(n=n+Math.imul(b,mt)|0)|0)+((8191&(i=(i=i+Math.imul(b,pt)|0)+Math.imul(E,mt)|0))<<13)|0;u=((o=o+Math.imul(E,pt)|0)+(i>>>13)|0)+(Ut>>>26)|0,Ut&=67108863,n=Math.imul(L,Q),i=(i=Math.imul(L,tt))+Math.imul($,Q)|0,o=Math.imul($,tt),n=n+Math.imul(C,rt)|0,i=(i=i+Math.imul(C,nt)|0)+Math.imul(F,rt)|0,o=o+Math.imul(F,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,n=n+Math.imul(I,ht)|0,i=(i=i+Math.imul(I,ut)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,ut)|0,n=n+Math.imul(S,ft)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(R,ft)|0,o=o+Math.imul(R,ct)|0;var It=(u+(n=n+Math.imul(_,mt)|0)|0)+((8191&(i=(i=i+Math.imul(_,pt)|0)+Math.imul(A,mt)|0))<<13)|0;u=((o=o+Math.imul(A,pt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul($,rt)|0,o=Math.imul($,nt),n=n+Math.imul(C,ot)|0,i=(i=i+Math.imul(C,st)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,st)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,ut)|0)+Math.imul(T,ht)|0,o=o+Math.imul(T,ut)|0,n=n+Math.imul(I,ft)|0,i=(i=i+Math.imul(I,ct)|0)+Math.imul(P,ft)|0,o=o+Math.imul(P,ct)|0;var Pt=(u+(n=n+Math.imul(S,mt)|0)|0)+((8191&(i=(i=i+Math.imul(S,pt)|0)+Math.imul(R,mt)|0))<<13)|0;u=((o=o+Math.imul(R,pt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,ot),i=(i=Math.imul(L,st))+Math.imul($,ot)|0,o=Math.imul($,st),n=n+Math.imul(C,ht)|0,i=(i=i+Math.imul(C,ut)|0)+Math.imul(F,ht)|0,o=o+Math.imul(F,ut)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,ct)|0;var xt=(u+(n=n+Math.imul(I,mt)|0)|0)+((8191&(i=(i=i+Math.imul(I,pt)|0)+Math.imul(P,mt)|0))<<13)|0;u=((o=o+Math.imul(P,pt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,ut))+Math.imul($,ht)|0,o=Math.imul($,ut),n=n+Math.imul(C,ft)|0,i=(i=i+Math.imul(C,ct)|0)+Math.imul(F,ft)|0,o=o+Math.imul(F,ct)|0;var kt=(u+(n=n+Math.imul(k,mt)|0)|0)+((8191&(i=(i=i+Math.imul(k,pt)|0)+Math.imul(T,mt)|0))<<13)|0;u=((o=o+Math.imul(T,pt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,ft),i=(i=Math.imul(L,ct))+Math.imul($,ft)|0,o=Math.imul($,ct);var Tt=(u+(n=n+Math.imul(C,mt)|0)|0)+((8191&(i=(i=i+Math.imul(C,pt)|0)+Math.imul(F,mt)|0))<<13)|0;u=((o=o+Math.imul(F,pt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863;var Ot=(u+(n=Math.imul(L,mt))|0)+((8191&(i=(i=Math.imul(L,pt))+Math.imul($,mt)|0))<<13)|0;return u=((o=Math.imul($,pt))+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=wt,h[4]=bt,h[5]=Et,h[6]=Mt,h[7]=_t,h[8]=At,h[9]=Nt,h[10]=St,h[11]=Rt,h[12]=Ut,h[13]=It,h[14]=Pt,h[15]=xt,h[16]=kt,h[17]=Tt,h[18]=Ot,0!==u&&(h[19]=u,r.length++),r};function m(t,e,r){return(new p).mulp(t,e,r)}function p(t,e){this.x=t,this.y=e}Math.imul||(d=c),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,h=Math.min(o,e.length-1),u=Math.max(0,o-t.length+1);u<=h;u++){var l=o-u,f=(0|t.words[l])*(0|e.words[u]),c=67108863&f;a=67108863&(c=c+a|0),i+=(s=(s=s+(f/67108864|0)|0)+(c>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):m(this,t,e)},p.prototype.makeRBT=function(t){for(var e=new Array(t),r=i.prototype._countBits(t)-1,n=0;n<t;n++)e[n]=this.revBin(n,r,t);return e},p.prototype.revBin=function(t,e,r){if(0===t||t===r-1)return t;for(var n=0,i=0;i<e;i++)n|=(1&t)<<e-i-1,t>>=1;return n},p.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s<o;s++)n[s]=e[t[s]],i[s]=r[t[s]]},p.prototype.transform=function(t,e,r,n,i,o){this.permute(o,t,e,r,n,i);for(var s=1;s<i;s<<=1)for(var a=s<<1,h=Math.cos(2*Math.PI/a),u=Math.sin(2*Math.PI/a),l=0;l<i;l+=a)for(var f=h,c=u,d=0;d<s;d++){var m=r[l+d],p=n[l+d],g=r[l+d+s],y=n[l+d+s],v=f*g-c*y;y=f*y+c*g,g=v,r[l+d]=m+g,n[l+d]=p+y,r[l+d+s]=m-g,n[l+d+s]=p-y,d!==a&&(v=h*f-u*c,c=h*c+u*f,f=v)}},p.prototype.guessLen13b=function(t,e){var r=1|Math.max(e,t),n=1&r,i=0;for(r=r/2|0;r;r>>>=1)i++;return 1<<i+1+n},p.prototype.conjugate=function(t,e,r){if(!(r<=1))for(var n=0;n<r/2;n++){var i=t[n];t[n]=t[r-n-1],t[r-n-1]=i,i=e[n],e[n]=-e[r-n-1],e[r-n-1]=-i}},p.prototype.normalize13b=function(t,e){for(var r=0,n=0;n<e/2;n++){var i=8192*Math.round(t[2*n+1]/e)+Math.round(t[2*n]/e)+r;t[n]=67108863&i,r=i<67108864?0:i/67108864|0}return t},p.prototype.convert13b=function(t,e,n,i){for(var o=0,s=0;s<e;s++)o+=0|t[s],n[2*s]=8191&o,o>>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*e;s<i;++s)n[s]=0;r(0===o),r(0==(-8192&o))},p.prototype.stub=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=0;return e},p.prototype.mulp=function(t,e,r){var n=2*this.guessLen13b(t.length,e.length),i=this.makeRBT(n),o=this.stub(n),s=new Array(n),a=new Array(n),h=new Array(n),u=new Array(n),l=new Array(n),f=new Array(n),c=r.words;c.length=n,this.convert13b(t.words,t.length,s,n),this.convert13b(e.words,e.length,u,n),this.transform(s,o,a,h,n,i),this.transform(u,o,l,f,n,i);for(var d=0;d<n;d++){var m=a[d]*l[d]-h[d]*f[d];h[d]=a[d]*f[d]+h[d]*l[d],a[d]=m}return this.conjugate(a,h,n),this.transform(a,h,c,o,n,i),this.conjugate(c,o,n),this.normalize13b(c,n),r.negative=t.negative^e.negative,r.length=t.length+e.length,r.strip()},i.prototype.mul=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},i.prototype.mulf=function(t){var e=new i(null);return e.words=new Array(this.length+t.length),m(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){r("number"==typeof t),r(t<67108864);for(var e=0,n=0;n<this.length;n++){var i=(0|this.words[n])*t,o=(67108863&i)+(67108863&e);e>>=26,e+=i/67108864|0,e+=o>>>26,this.words[n]=67108863&o}return 0!==e&&(this.words[n]=e,this.length++),this},i.prototype.muln=function(t){return this.clone().imuln(t)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r<e.length;r++){var n=r/26|0,i=r%26;e[r]=(t.words[n]&1<<i)>>>i}return e}(t);if(0===e.length)return new i(1);for(var r=this,n=0;n<e.length&&0===e[n];n++,r=r.sqr());if(++n<e.length)for(var o=r.sqr();n<e.length;n++,o=o.sqr())0!==e[n]&&(r=r.mul(o));return r},i.prototype.iushln=function(t){r("number"==typeof t&&t>=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e<this.length;e++){var a=this.words[e]&o,h=(0|this.words[e])-a<<n;this.words[e]=h|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this.strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,h=n;if(i-=s,i=Math.max(0,i),h){for(var u=0;u<s;u++)h.words[u]=this.words[u];h.length=s}if(0===s);else if(this.length>s)for(this.length-=s,u=0;u<this.length;u++)this.words[u]=this.words[u+s];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=i);u--){var f=0|this.words[u];this.words[u]=l<<26-o|f>>>o,l=f&a}return h&&0!==l&&(h.words[h.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},i.prototype.shln=function(t){return this.clone().ishln(t)},i.prototype.ushln=function(t){return this.clone().iushln(t)},i.prototype.shrn=function(t){return this.clone().ishrn(t)},i.prototype.ushrn=function(t){return this.clone().iushrn(t)},i.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<<e;return!(this.length<=n)&&!!(this.words[n]&i)},i.prototype.imaskn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<<e;this.words[this.length-1]&=i}return this.strip()},i.prototype.maskn=function(t){return this.clone().imaskn(t)},i.prototype.iaddn=function(t){return r("number"==typeof t),r(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)},i.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},i.prototype.isubn=function(t){if(r("number"==typeof t),r(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 e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this.strip()},i.prototype.addn=function(t){return this.clone().iaddn(t)},i.prototype.subn=function(t){return this.clone().isubn(t)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(t,e,n){var i,o,s=t.length+n;this._expand(s);var a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var h=(0|t.words[i])*e;a=((o-=67108863&h)>>26)-(h/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!==(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,h=n.length-o.length;if("mod"!==e){(a=new i(null)).length=h+1,a.words=new Array(a.length);for(var u=0;u<a.length;u++)a.words[u]=0}var l=n.clone()._ishlnsubmul(o,1,h);0===l.negative&&(n=l,a&&(a.words[h]=1));for(var f=h-1;f>=0;f--){var c=67108864*(0|n.words[o.length+f])+(0|n.words[o.length+f-1]);for(c=Math.min(c/s|0,67108863),n._ishlnsubmul(o,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(o,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modn(t.words[0]))}:this._wordDiv(t,e);var o,s,a},i.prototype.div=function(t){return this.divmod(t,"div",!1).div},i.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},i.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},i.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},i.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},i.prototype.divn=function(t){return this.clone().idivn(t)},i.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o=new i(1),s=new i(0),a=new i(0),h=new i(1),u=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(f)),o.iushrn(1),s.iushrn(1);for(var m=0,p=1;0==(n.words[0]&p)&&m<26;++m,p<<=1);if(m>0)for(n.iushrn(m);m-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(l),h.isub(f)),a.iushrn(1),h.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(h)):(n.isub(e),a.isub(o),h.isub(s))}return{a:a,b:h,gcd:n.iushln(u)}},i.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var o,s=new i(1),a=new i(0),h=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(e.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(e.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new M(t)},i.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(t){return this.red=t,this},i.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},i.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},i.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},i.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},i.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},i.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},i.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},i.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new i(e,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function w(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function b(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function M(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function _(t){M.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(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 i(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e<this.n?-1:r.ucmp(this.p);return 0===n?(r.words[0]=0,r.length=1):n>0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n<r;n++)e.words[n]=t.words[n];if(e.length=r,t.length<=9)return t.words[0]=0,void(t.length=1);var i=t.words[9];for(e.words[e.length++]=4194303&i,n=10;n<t.length;n++){var o=0|t.words[n];t.words[n-10]=(4194303&o)<<4|i>>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r<t.length;r++){var n=0|t.words[r];e+=977*n,t.words[r]=67108863&e,e=64*n+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},n(w,y),n(b,y),n(E,y),E.prototype.imulK=function(t){for(var e=0,r=0;r<t.length;r++){var n=19*(0|t.words[r])+e,i=67108863&n;n>>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},i._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new w;else if("p192"===t)e=new b;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},M.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},M.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},M.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},M.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},M.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},M.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},M.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},M.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},M.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},M.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},M.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},M.prototype.isqr=function(t){return this.imul(t,t.clone())},M.prototype.sqr=function(t){return this.mul(t,t)},M.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),h=a.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(h);)l.redIAdd(h);for(var f=this.pow(l,o),c=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),m=s;0!==d.cmp(a);){for(var p=d,g=0;0!==p.cmp(a);g++)p=p.redSqr();r(g<m);var y=this.pow(f,new i(1).iushln(m-g-1));c=c.redMul(y),f=y.redSqr(),d=d.redMul(f),m=g}return c},M.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},M.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,h=e.bitLength()%26;for(0===h&&(h=26),n=e.length-1;n>=0;n--){for(var u=e.words[n],l=h-1;l>=0;l--){var f=u>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===l)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}h=26}return o},M.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},M.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new _(t)},n(_,M),_.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},_.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},_.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},_.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new i(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),s=o;return o.cmp(this.m)>=0?s=o.isub(this.m):o.cmpn(0)<0&&(s=o.iadd(this.m)),s._forceRed(this)},_.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,o)})).BN;new Yy("bignumber/5.4.0");const ab=new Yy("address/5.4.0");function hb(t){ib(t,20)||ab.throwArgumentError("invalid address","address",t);const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const n=nb(bv(r));for(let t=0;t<40;t+=2)n[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&n[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const ub={};for(let t=0;t<10;t++)ub[String(t)]=String(t);for(let t=0;t<26;t++)ub[String.fromCharCode(65+t)]=String(10+t);const lb=Math.floor(function(t){return Math.log10?Math.log10(t):Math.log(t)/Math.LN10}(9007199254740991));function fb(t){let e=null;if("string"!=typeof t&&ab.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=hb(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&ab.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map(t=>ub[t]).join("");for(;e.length>=lb;){let t=e.substring(0,lb);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t)&&ab.throwArgumentError("bad icap checksum","address",t),r=t.substring(4),e=new sb(r,36).toString(16);e.length<40;)e="0"+e;e=hb("0x"+e)}else ab.throwArgumentError("invalid address","address",t);var r;return e}new Yy("transactions/5.4.0");var cb;function db(t,e){return function(t){return fb(ob(bv(ob(Yw(t),1)),12))}(function(t,e){const r=Ww(e),n={r:Gw(r.r),s:Gw(r.s)};return"0x"+Xw().recoverPubKey(Gw(t),n,r.recoveryParam).encode("hex",!1)}(nb(t),e))}!function(t){t[t.legacy=0]="legacy",t[t.eip2930=1]="eip2930",t[t.eip1559=2]="eip1559"}(cb||(cb={}));window&&window.__awaiter;new Yy("wallet/5.4.0");function mb(t,n,i,o){return e(this,void 0,void 0,(function(){var e,s,a,h;return r(this,(function(r){switch(r.label){case 0:s="0x1626ba7e",a="function isValidSignature(bytes32 _hash, bytes memory _signature) public view returns (bytes4 magicValue)",r.label=1;case 1:return r.trys.push([1,3,,4]),[4,Pb(o,[a],[t,"isValidSignature",[j(i),n]])];case 2:return e=r.sent(),[3,4];case 3:return h=r.sent(),console.log(h),[2,!1];case 4:return[2,e.toLowerCase()===s.toLowerCase()]}}))}))}function pb(t,n,i,o){return e(this,void 0,void 0,(function(){var e,s,a,h;return r(this,(function(r){switch(r.label){case 0:s="0x20c13b0b",a="function isValidSignature(bytes _hash, bytes memory _signature) public view returns (bytes4 magicValue)",r.label=1;case 1:return r.trys.push([1,3,,4]),[4,Pb(o,[a],[t,"isValidSignature",[j(i),n]])];case 2:return e=r.sent(),[3,4];case 3:return h=r.sent(),console.log(h),[2,!1];case 4:return[2,e.toLowerCase()===s.toLowerCase()]}}))}))}function gb(t,n,i,o){return void 0===o&&(o="1"),e(this,void 0,void 0,(function(){var e;return r(this,(function(r){switch(r.label){case 0:return e=zy(o),[4,mb(t,n,i,e)];case 1:return r.sent()?[2,!0]:[4,pb(t,n,i,e)];case 2:return[2,r.sent()]}}))}))}function yb(t){var e=t.domain,r=t.types,n=t.message;return _o.hash(e,r,n)}var vb=["cloudflare-ipfs.com","cf-ipfs.com","ipfs.io","ipfs.fleek.co","gateway.pinata.cloud","dweb.link","ipfs.infura.io"],wb=function(){function t(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}return t.prototype.resultsByVoteBalance=function(){var t=this;return this.proposal.choices.map((function(e,r){return t.votes.filter((function(t){return t.choice===r+1})).reduce((function(t,e){return t+e.balance}),0)}))},t.prototype.resultsByStrategyScore=function(){var t=this;return this.proposal.choices.map((function(e,r){return t.strategies.map((function(e,n){return t.votes.filter((function(t){return t.choice===r+1})).reduce((function(t,e){return t+e.scores[n]}),0)}))}))},t.prototype.sumOfResultsBalance=function(){return this.votes.reduce((function(t,e){return t+e.balance}),0)},t.prototype.getChoiceString=function(){return this.proposal.choices[this.selected-1]},t}(),bb=function(){function t(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}return t.prototype.resultsByVoteBalance=function(){var t=this;return this.proposal.choices.map((function(e,r){return t.votes.filter((function(t){return t.choice.includes(r+1)})).reduce((function(t,e){return t+e.balance}),0)}))},t.prototype.resultsByStrategyScore=function(){var t=this;return this.proposal.choices.map((function(e,r){return t.strategies.map((function(e,n){return t.votes.filter((function(t){return t.choice.includes(r+1)})).reduce((function(t,e){return t+e.scores[n]}),0)}))}))},t.prototype.sumOfResultsBalance=function(){return this.votes.reduce((function(t,e){return t+e.balance}),0)},t.prototype.getChoiceString=function(){var t=this;return this.selected?this.proposal.choices.filter((function(e,r){return t.selected.includes(r+1)})).join(", "):""},t}();function Eb(t,e,r){var n=r.reduce((function(t,e){return t+e}),0),i=e[t]/n*100;return isNaN(i)?0:i}function Mb(t,e,r){return Math.sqrt(Eb(t+1,e,Object.values(e))/100*r)}var _b=function(){function t(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}return t.prototype.resultsByVoteBalance=function(){var t=this,e=this.proposal.choices.map((function(e,r){return t.votes.map((function(t){return Mb(r,t.choice,t.balance)})).reduce((function(t,e){return t+e}),0)})).map((function(t){return t*t}));return e.map((function(t,r){return Eb(r,e,e)})).map((function(e){return t.sumOfResultsBalance()/100*e}))},t.prototype.resultsByStrategyScore=function(){var t=this,e=this.proposal.choices.map((function(e,r){return t.strategies.map((function(e,n){return t.votes.map((function(t){return Mb(r,t.choice,t.scores[n])})).reduce((function(t,e){return t+e}),0)}))})).map((function(t){return t.map((function(t){return[t*t]}))}));return e.map((function(r,n){return t.strategies.map((function(t,r){return[Eb(0,e[n][r],e.flat(2))]})).map((function(e){return[t.sumOfResultsBalance()/100*e]}))}))},t.prototype.sumOfResultsBalance=function(){return this.votes.reduce((function(t,e){return t+e.balance}),0)},t.prototype.getChoiceString=function(){var t=this;return this.proposal.choices.map((function(e,r){if(t.selected[r+1])return Math.round(10*Eb(r+1,t.selected,Object.values(t.selected)))/10+"% for "+e})).filter((function(t){return null!=t})).join(", ")},t}();function Ab(t,e){var r=function t(e,r){var o=i(new Set(e.map((function(t){return t[0]})).flat())),s=Object.entries(e.reduce((function(t,e,r,i){var o=n(e,1)[0];return t[o[0]][0]+=i[r][1],t[o[0]][1].length>1?t[o[0]][1]=t[o[0]][1].map((function(t,e){return t+i[r][2][e]})):t[o[0]][1]=[t[o[0]][1].concat(i[r][2]).reduce((function(t,e){return t+e}),0)],t}),Object.assign.apply(Object,i([{}],o.map((function(t){var e;return(e={})[t]=[0,[]],e})))))),a=s.map((function(t){return[t[0],t[1][0]]})),h=n(a.reduce((function(t,e){var r=n(t,2),i=r[0],o=r[1],s=n(e,2),a=s[0],h=s[1];return h>o?[a,h]:[i,o]}),["?",-1/0]),2),u=(h[0],h[1]),l=n(a.reduce((function(t,e){var r=n(t,2),i=r[0],o=r[1],s=n(e,2),a=s[0],h=s[1];return h<o?[a,h]:[i,o]}),["?",1/0]),2),f=l[0],c=(l[1],s.sort((function(t,e){return e[1][0]-t[1][0]}))),d=e.map((function(t){return t[1]})).reduce((function(t,e){return t+e}),0);return r.push({round:r.length+1,sortedByHighest:c}),u>d/2||c.length<3?r:t(e.map((function(t){return[t[0].filter((function(t){return t!=f})),t[1],t[2]]})).filter((function(t){return t[0].length>0})),r)}(e.map((function(t){return[t.choice,t.balance,t.scores]})),[]);return r[r.length-1].sortedByHighest.filter((function(e){return e[0]==t+1}))}var Nb=function(){function t(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}return t.prototype.resultsByVoteBalance=function(){var t=this;return this.proposal.choices.map((function(e,r){return Ab(r,t.votes).reduce((function(t,e){return t+e[1][0]}),0)}))},t.prototype.resultsByStrategyScore=function(){var t=this;return this.proposal.choices.map((function(e,r){return t.strategies.map((function(e,n){return Ab(r,t.votes).reduce((function(t,e){return t+e[1][1][n]}),0)}))}))},t.prototype.sumOfResultsBalance=function(){return this.resultsByVoteBalance().reduce((function(t,e){return t+e}))},t.prototype.getChoiceString=function(){var t=this;return this.selected.map((function(e){if(t.proposal.choices[e-1])return t.proposal.choices[e-1]})).map((function(t,e){return"("+Cb(e+1)+") "+t})).join(", ")},t}();function Sb(t,e,r){var n=r.reduce((function(t,e){return t+e}),0),i=e[t]/n*100;return isNaN(i)?0:i}function Rb(t,e,r){return Sb(t+1,e,Object.values(e))/100*r}var Ub=function(){function t(t,e,r,n){this.proposal=t,this.votes=e,this.strategies=r,this.selected=n}return t.prototype.resultsByVoteBalance=function(){var t=this,e=this.proposal.choices.map((function(e,r){return t.votes.map((function(t){return Rb(r,t.choice,t.balance)})).reduce((function(t,e){return t+e}),0)}));return e.map((function(t,r){return Sb(r,e,e)})).map((function(e){return t.sumOfResultsBalance()/100*e}))},t.prototype.resultsByStrategyScore=function(){var t=this,e=this.proposal.choices.map((function(e,r){return t.strategies.map((function(e,n){return t.votes.map((function(t){return Rb(r,t.choice,t.scores[n])})).reduce((function(t,e){return t+e}),0)}))})).map((function(t){return t.map((function(t){return[t]}))}));return e.map((function(r,n){return t.strategies.map((function(t,r){return[Sb(0,e[n][r],e.flat(2))]})).map((function(e){return[t.sumOfResultsBalance()/100*e]}))}))},t.prototype.sumOfResultsBalance=function(){return this.votes.reduce((function(t,e){return t+e.balance}),0)},t.prototype.getChoiceString=function(){var t=this;return this.proposal.choices.map((function(e,r){if(t.selected[r+1])return Math.round(10*Sb(r+1,t.selected,Object.values(t.selected)))/10+"% for "+e})).filter((function(t){return null!=t})).join(", ")},t}(),Ib=["function text(bytes32 node, string calldata key) external view returns (string memory)"];function Pb(t,n,o,s){return e(this,void 0,void 0,(function(){var e,a,h;return r(this,(function(r){switch(r.label){case 0:e=new Ra(o[0],n,t),r.label=1;case 1:return r.trys.push([1,3,,4]),a=o[2]||[],[4,e[o[1]].apply(e,i(a,[s||{}]))];case 2:return[2,r.sent()];case 3:return h=r.sent(),[2,Promise.reject(h)];case 4:return[2]}}))}))}function xb(t,i,o,s,a){return e(this,void 0,void 0,(function(){var e,h,u,l,f,c,d;return r(this,(function(r){switch(r.label){case 0:e=["function aggregate(tuple(address target, bytes callData)[] calls) view returns (uint256 blockNumber, bytes[] returnData)"],h=new Ra(By[t].multicall,e,i),u=new xo(o),r.label=1;case 1:return r.trys.push([1,3,,4]),l=(null==a?void 0:a.limit)||500,f=Math.ceil(s.length/l),c=[],Array.from(Array(f)).forEach((function(t,e){var r=s.slice(l*e,l*(e+1));c.push(h.aggregate(r.map((function(t){return[t[0].toLowerCase(),u.encodeFunctionData(t[1],t[2])]})),a||{}))})),[4,Promise.all(c)];case 2:return[2,r.sent().reduce((function(t,e){var r=n(e,2)[1];return t.concat(r)}),[]).map((function(t,e){return u.decodeFunctionResult(s[e][1],t)}))];case 3:return d=r.sent(),[2,Promise.reject(d)];case 4:return[2]}}))}))}function kb(t,e){void 0===e&&(e=vb[0]);var r="https://"+e;if(!t)return null;if(!(t.startsWith("ipfs://")||t.startsWith("ipns://")||t.startsWith("https://")||t.startsWith("http://")))return r+"/ipfs/"+t;var n=t.split("://")[0];return"ipfs"===n?t.replace("ipfs://",r+"/ipfs/"):"ipns"===n?t.replace("ipns://",r+"/ipns/"):t}function Tb(t,n,i,o,s,a){return void 0===s&&(s="latest"),void 0===a&&(a="https://score.snapshot.org/api/scores"),e(this,void 0,void 0,(function(){var e,h;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),e={space:t,network:i,snapshot:s,strategies:n,addresses:o},[4,u(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({params:e})})];case 1:return[4,r.sent().json()];case 2:return[2,r.sent().result.scores];case 3:return h=r.sent(),[2,Promise.reject(h)];case 4:return[2]}}))}))}function Ob(t,e,r){void 0===r&&(r="1");var n=By[r].ensResolver||By[1].ensResolver,i=iu.hash(iu.normalize(t));return Pb(zy(r),Ib,[n,"text",[i,e]])}function Cb(t){var e=["th","st","nd","rd"],r=t%100;return t+(e[(r-20)%10]||e[r]||e[0])}return{Client:K,Client712:R,schemas:Z,utils:{call:Pb,multicall:xb,subgraphRequest:function(n,i,o){return void 0===o&&(o={}),e(this,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return[4,u(n,{method:"POST",headers:t({Accept:"application/json","Content-Type":"application/json"},null==o?void 0:o.headers),body:JSON.stringify({query:lu.jsonToGraphQLQuery({query:i})})})];case 1:return[4,e.sent().json()];case 2:return[2,e.sent().data||{}]}}))}))},ipfsGet:function(t,n,i){return void 0===i&&(i="ipfs"),e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,u("https://"+t+"/"+i+"/"+n).then((function(t){return t.json()}))]}))}))},getUrl:kb,getJSON:function(t){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){return e=kb(t),[2,u(e).then((function(t){return t.json()}))]}))}))},sendTransaction:function(t,n,o,s,a,h){return void 0===h&&(h={}),e(this,void 0,void 0,(function(){var e,u,l;return r(this,(function(r){switch(r.label){case 0:return e=t.getSigner(),u=new Ra(n,o,t),[4,(l=u.connect(e))[s].apply(l,i(a,[h]))];case 1:return[2,r.sent()]}}))}))},getScores:Tb,validateSchema:function(t,e){var r=new cf({allErrors:!0,allowUnionTypes:!0,$data:!0});pf(r);var n=r.compile(t),i=n(e);return i||n.errors},getEnsTextRecord:Ob,getSpaceUri:function(t,n){return void 0===n&&(n="1"),e(this,void 0,void 0,(function(){var e;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,Ob(t,"snapshot",n)];case 1:return[2,r.sent()];case 2:return e=r.sent(),console.log("getSpaceUriFromTextRecord failed",t,e),[3,3];case 3:return[2,!1]}}))}))},clone:function(t){return JSON.parse(JSON.stringify(t))},sleep:function(t){return e(this,void 0,void 0,(function(){return r(this,(function(e){return[2,new Promise((function(e){setTimeout(e,t)}))]}))}))},getNumberWithOrdinal:Cb,voting:{"single-choice":wb,approval:bb,quadratic:_b,"ranked-choice":Nb,weighted:Ub,basic:wb},getProvider:zy,signMessage:V,getBlockNumber:function(t){return e(this,void 0,void 0,(function(){var e;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t.getBlockNumber()];case 1:return e=r.sent(),[2,parseInt(e)];case 2:return r.sent(),[2,Promise.reject()];case 3:return[2]}}))}))},Multicaller:ac,validations:Gy,getHash:yb,verify:function(t,n,i){return e(this,void 0,void 0,(function(){var e,o,s,a,h;return r(this,(function(r){switch(r.label){case 0:return e=i.domain,o=i.types,s=i.message,a=function(t,e,r,n){return db(ew.hash(t,e,r),n)}(e,o,s,n),h=yb(i),console.log("Hash",h),console.log("Address",t),console.log("Recover address",a),t===a?[2,!0]:(console.log("Check EIP1271 signature"),[4,gb(t,n,h)]);case 1:return[2,r.sent()]}}))}))},SNAPSHOT_SUBGRAPH_URL:{1:"https://gateway.thegraph.com/api/0f15b42bdeff7a063a4e1757d7e2f99e/subgraphs/id/3Q4vnuSqemXnSNHoiLD7wdBbGCXszUYnUbTz191kDMNn",4:"https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-rinkeby",42:"https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-kovan",97:"https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-binance-smart-chain",100:"https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-gnosis-chain",137:"https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-polygon",250:"https://api.thegraph.com/subgraphs/name/snapshot-labs/snapshot-fantom"}}}}));
|