@lightprotocol/compressed-token 0.17.2-alpha.0 → 0.17.2-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightprotocol/compressed-token",
3
- "version": "0.17.2-alpha.0",
3
+ "version": "0.17.2-alpha.2",
4
4
  "description": "JS client to interact with the compressed-token program",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/node/index.cjs",
@@ -29,16 +29,17 @@
29
29
  ],
30
30
  "license": "Apache-2.0",
31
31
  "peerDependencies": {
32
+ "@solana/spl-token": ">=0.3.9",
32
33
  "@solana/web3.js": ">=1.73.5",
33
- "@lightprotocol/stateless.js": "0.17.2-alpha.1"
34
+ "@lightprotocol/stateless.js": "0.17.2-alpha.2"
34
35
  },
35
36
  "dependencies": {
36
37
  "@coral-xyz/borsh": "^0.29.0",
37
- "@solana/spl-token": "0.4.8",
38
38
  "bn.js": "^5.2.1",
39
39
  "buffer": "6.0.3"
40
40
  },
41
41
  "devDependencies": {
42
+ "@coral-xyz/anchor": "^0.29.0",
42
43
  "@esbuild-plugins/node-globals-polyfill": "^0.2.3",
43
44
  "@lightprotocol/hasher.rs": "0.2.1",
44
45
  "@rollup/plugin-alias": "^5.1.0",
@@ -49,6 +50,7 @@
49
50
  "@rollup/plugin-replace": "^5.0.7",
50
51
  "@rollup/plugin-terser": "^0.4.4",
51
52
  "@rollup/plugin-typescript": "^11.1.6",
53
+ "@solana/spl-token": "0.4.8",
52
54
  "@solana/web3.js": "1.98.0",
53
55
  "@types/bn.js": "^5.1.5",
54
56
  "@types/node": "^22.5.5",
@@ -98,7 +100,7 @@
98
100
  "test:unit:all": "EXCLUDE_E2E=true vitest run",
99
101
  "test-all:verbose": "vitest run --reporter=verbose",
100
102
  "test-validator": "./../../cli/test_bin/run test-validator --prover-run-mode rpc",
101
- "test:e2e:create-mint": "pnpm test-validator && vitest run tests/e2e/create-mint.test.ts",
103
+ "test:e2e:create-mint": "pnpm test-validator && NODE_OPTIONS='--trace-deprecation' vitest run tests/e2e/create-mint.test.ts --reporter=verbose",
102
104
  "test:e2e:layout": "vitest run tests/e2e/layout.test.ts --reporter=verbose",
103
105
  "test:e2e:create-token-pool": "pnpm test-validator && vitest run tests/e2e/create-token-pool.test.ts",
104
106
  "test:e2e:mint-to": "pnpm test-validator && vitest run tests/e2e/mint-to.test.ts --reporter=verbose",
@@ -1,2 +0,0 @@
1
- import{getIndexOrAdd as t,bn as e,padOutputStateMerkleTrees as r,defaultStaticAccountsStruct as n,toArray as i,LightSystemProgram as o,defaultTestStateTreeAccounts as s,sumUpLamports as u,validateSufficientBalance as a,validateSameOwner as h,dedupeSigner as l,buildAndSignTx as c,sendAndConfirmTx as f}from"@lightprotocol/stateless.js";import d,{PublicKey as p,SystemProgram as m,TransactionInstruction as g,AddressLookupTableProgram as y,ComputeBudgetProgram as w,Keypair as v}from"@solana/web3.js";import{MINT_SIZE as b,createInitializeMint2Instruction as M,createMintToInstruction as P,TOKEN_PROGRAM_ID as k,TOKEN_2022_PROGRAM_ID as A,getOrCreateAssociatedTokenAccount as E}from"@solana/spl-token";function _(n){const{inputCompressedTokenAccounts:i,outputStateTrees:o,remainingAccounts:s=[],rootIndices:u,tokenTransferOutputs:a}=n,h=s.slice();let l=null;i.length>0&&i[0].parsed.delegate&&(l=t(h,i[0].parsed.delegate));const c=[];i.forEach(((r,n)=>{const i=t(h,r.compressedAccount.merkleTree),o=t(h,r.compressedAccount.nullifierQueue);c.push({amount:r.parsed.amount,delegateIndex:l,merkleContext:{merkleTreePubkeyIndex:i,nullifierQueuePubkeyIndex:o,leafIndex:r.compressedAccount.leafIndex,queueIndex:null},rootIndex:u[n],lamports:r.compressedAccount.lamports.eq(e(0))?null:r.compressedAccount.lamports,tlv:null})}));const f=r(o,a.length,i.map((t=>t.compressedAccount))),d=[];f.forEach(((r,n)=>{const i=t(h,r);d.push({owner:a[n].owner,amount:a[n].amount,lamports:a[n].lamports?.eq(e(0))?null:a[n].lamports,merkleTreeIndex:i,tlv:null})}));const p=h.map((t=>({pubkey:t,isWritable:1,isSigner:0})));return{inputTokenDataWithContext:c,remainingAccountMetas:p,packedOutputTokenData:d}}const S=Buffer.from("pool"),T=Buffer.from("cpi_authority"),I=1461600;var x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function B(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function L(t){if(t.__esModule)return t;var e=t.default;if("function"==typeof e){var r=function t(){return this instanceof t?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:1}),Object.keys(t).forEach((function(e){var n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:1,get:function(){return t[e]}})})),r}var C={exports:{}},R="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},O=[],U=[],D="undefined"!=typeof Uint8Array?Uint8Array:Array,W=0;function Y(){W=1;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)O[e]=t[e],U[t.charCodeAt(e)]=e;U["-".charCodeAt(0)]=62,U["_".charCodeAt(0)]=63}function N(t,e,r){for(var n,i,o=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],o.push(O[(i=n)>>18&63]+O[i>>12&63]+O[i>>6&63]+O[63&i]);return o.join("")}function q(t){var e;W||Y();for(var r=t.length,n=r%3,i="",o=[],s=16383,u=0,a=r-n;u<a;u+=s)o.push(N(t,u,u+s>a?a:u+s));return 1===n?(e=t[r-1],i+=O[e>>2],i+=O[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=O[e>>10],i+=O[e>>4&63],i+=O[e<<2&63],i+="="),o.push(i),o.join("")}function j(t,e,r,n,i){var o,s,u=8*i-n-1,a=(1<<u)-1,h=a>>1,l=-7,c=r?i-1:0,f=r?-1:1,d=t[e+c];for(c+=f,o=d&(1<<-l)-1,d>>=-l,l+=u;l>0;o=256*o+t[e+c],c+=f,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+t[e+c],c+=f,l-=8);if(0===o)o=1-h;else{if(o===a)return s?NaN:Infinity*(d?-1:1);s+=Math.pow(2,n),o-=h}return(d?-1:1)*s*Math.pow(2,o-n)}function K(t,e,r,n,i,o){var s,u,a,h=8*o-i-1,l=(1<<h)-1,c=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,m=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||Infinity===e?(u=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-s))<1&&(s--,a*=2),(e+=s+c>=1?f/a:f*Math.pow(2,1-c))*a>=2&&(s++,a/=2),s+c>=l?(u=0,s=l):s+c>=1?(u=(e*a-1)*Math.pow(2,i),s+=c):(u=e*Math.pow(2,c-1)*Math.pow(2,i),s=0));i>=8;t[r+d]=255&u,d+=p,u/=256,i-=8);for(s=s<<i|u,h+=i;h>0;t[r+d]=255&s,d+=p,s/=256,h-=8);t[r+d-p]|=128*m}var V={}.toString,Z=Array.isArray||function(t){return"[object Array]"==V.call(t)};Q.TYPED_ARRAY_SUPPORT=void 0!==R.TYPED_ARRAY_SUPPORT?R.TYPED_ARRAY_SUPPORT:1;var z=F();function F(){return Q.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function G(t,e){if(F()<e)throw new RangeError("Invalid typed array length");return Q.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=Q.prototype:(null===t&&(t=new Q(e)),t.length=e),t}function Q(t,e,r){if(!(Q.TYPED_ARRAY_SUPPORT||this instanceof Q))return new Q(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return J(this,t)}return $(this,t,e,r)}function $(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n),Q.TYPED_ARRAY_SUPPORT?(t=e).__proto__=Q.prototype:t=X(t,e),t}(t,e,r,n):"string"==typeof e?function(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!Q.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|rt(e,r),i=(t=G(t,n)).write(e,r);return i!==n&&(t=t.slice(0,i)),t}(t,e,r):function(t,e){if(et(e)){var r=0|tt(e.length);return 0===(t=G(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?G(t,0):X(t,e);if("Buffer"===e.type&&Z(e.data))return X(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function H(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function J(t,e){if(H(e),t=G(t,e<0?0:0|tt(e)),!Q.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function X(t,e){var r=e.length<0?0:0|tt(e.length);t=G(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function tt(t){if(t>=F())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+F().toString(16)+" bytes");return 0|t}function et(t){return!(null==t||!t._isBuffer)}function rt(t,e){if(et(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=0;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return Tt(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return It(t).length;default:if(n)return Tt(t).length;e=(""+e).toLowerCase(),n=1}}function nt(t,e,r){var n=0;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return wt(this,e,r);case"utf8":case"utf-8":return pt(this,e,r);case"ascii":return gt(this,e,r);case"latin1":case"binary":return yt(this,e,r);case"base64":return dt(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return vt(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=1}}function it(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function ot(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=Q.from(e,n)),et(e))return 0===e.length?-1:st(t,e,r,n,i);if("number"==typeof e)return e&=255,Q.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):st(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function st(t,e,r,n,i){var o,s=1,u=t.length,a=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,u/=2,a/=2,r/=2}function h(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var l=-1;for(o=r;o<u;o++)if(h(t,o)===h(e,-1===l?0:o-l)){if(-1===l&&(l=o),o-l+1===a)return l*s}else-1!==l&&(o-=o-l),l=-1}else for(r+a>u&&(r=u-a),o=r;o>=0;o--){for(var c=1,f=0;f<a;f++)if(h(t,o+f)!==h(e,f)){c=0;break}if(c)return o}return-1}function ut(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var o=e.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var u=parseInt(e.substr(2*s,2),16);if(isNaN(u))return s;t[r+s]=u}return s}function at(t,e,r,n){return xt(Tt(e,t.length-r),t,r,n)}function ht(t,e,r,n){return xt(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function lt(t,e,r,n){return ht(t,e,r,n)}function ct(t,e,r,n){return xt(It(e),t,r,n)}function ft(t,e,r,n){return xt(function(t,e){for(var r,n,i,o=[],s=0;s<t.length&&!((e-=2)<0);++s)n=(r=t.charCodeAt(s))>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function dt(t,e,r){return 0===e&&r===t.length?q(t):q(t.slice(e,r))}function pt(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o,s,u,a,h=t[i],l=null,c=h>239?4:h>223?3:h>191?2:1;if(i+c<=r)switch(c){case 1:h<128&&(l=h);break;case 2:128==(192&(o=t[i+1]))&&(a=(31&h)<<6|63&o)>127&&(l=a);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(a=(15&h)<<12|(63&o)<<6|63&s)>2047&&(a<55296||a>57343)&&(l=a);break;case 4:o=t[i+1],s=t[i+2],u=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&u)&&(a=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&u)>65535&&a<1114112&&(l=a)}null===l?(l=65533,c=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=c}return function(t){var e=t.length;if(e<=mt)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=mt));return r}(n)}Q.poolSize=8192,Q._augment=function(t){return t.__proto__=Q.prototype,t},Q.from=function(t,e,r){return $(null,t,e,r)},Q.TYPED_ARRAY_SUPPORT&&(Q.prototype.__proto__=Uint8Array.prototype,Q.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Q[Symbol.species]),Q.alloc=function(t,e,r){return function(t,e,r,n){return H(e),e<=0?G(t,e):void 0!==r?"string"==typeof n?G(t,e).fill(r,n):G(t,e).fill(r):G(t,e)}(null,t,e,r)},Q.allocUnsafe=function(t){return J(null,t)},Q.allocUnsafeSlow=function(t){return J(null,t)},Q.isBuffer=Bt,Q.compare=function(t,e){if(!et(t)||!et(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},Q.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 1;default:return 0}},Q.concat=function(t,e){if(!Z(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return Q.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=Q.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var o=t[r];if(!et(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},Q.byteLength=rt,Q.prototype._isBuffer=1,Q.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)it(this,e,e+1);return this},Q.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)it(this,e,e+3),it(this,e+1,e+2);return this},Q.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)it(this,e,e+7),it(this,e+1,e+6),it(this,e+2,e+5),it(this,e+3,e+4);return this},Q.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?pt(this,0,t):nt.apply(this,arguments)},Q.prototype.equals=function(t){if(!et(t))throw new TypeError("Argument must be a Buffer");return this===t?1:0===Q.compare(this,t)},Q.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},Q.prototype.compare=function(t,e,r,n,i){if(!et(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0),u=Math.min(o,s),a=this.slice(n,i),h=t.slice(e,r),l=0;l<u;++l)if(a[l]!==h[l]){o=a[l],s=h[l];break}return o<s?-1:s<o?1:0},Q.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},Q.prototype.indexOf=function(t,e,r){return ot(this,t,e,r,1)},Q.prototype.lastIndexOf=function(t,e,r){return ot(this,t,e,r,0)},Q.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=0;;)switch(n){case"hex":return ut(this,t,e,r);case"utf8":case"utf-8":return at(this,t,e,r);case"ascii":return ht(this,t,e,r);case"latin1":case"binary":return lt(this,t,e,r);case"base64":return ct(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ft(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=1}},Q.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var mt=4096;function gt(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function yt(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function wt(t,e,r){var n,i=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>i)&&(r=i);for(var o="",s=e;s<r;++s)o+=(n=t[s])<16?"0"+n.toString(16):n.toString(16);return o}function vt(t,e,r){for(var n=t.slice(e,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+256*n[o+1]);return i}function bt(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function Mt(t,e,r,n,i,o){if(!et(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function Pt(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,o=Math.min(t.length-r,2);i<o;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function kt(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,o=Math.min(t.length-r,4);i<o;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function At(t,e,r,n){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Et(t,e,r,n,i){return i||At(t,0,r,4),K(t,e,r,n,23,4),r+4}function _t(t,e,r,n,i){return i||At(t,0,r,8),K(t,e,r,n,52,8),r+8}Q.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),Q.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=Q.prototype;else{var i=e-t;r=new Q(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+t]}return r},Q.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||bt(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},Q.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||bt(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},Q.prototype.readUInt8=function(t,e){return e||bt(t,1,this.length),this[t]},Q.prototype.readUInt16LE=function(t,e){return e||bt(t,2,this.length),this[t]|this[t+1]<<8},Q.prototype.readUInt16BE=function(t,e){return e||bt(t,2,this.length),this[t]<<8|this[t+1]},Q.prototype.readUInt32LE=function(t,e){return e||bt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},Q.prototype.readUInt32BE=function(t,e){return e||bt(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},Q.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||bt(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},Q.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||bt(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},Q.prototype.readInt8=function(t,e){return e||bt(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},Q.prototype.readInt16LE=function(t,e){e||bt(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},Q.prototype.readInt16BE=function(t,e){e||bt(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},Q.prototype.readInt32LE=function(t,e){return e||bt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},Q.prototype.readInt32BE=function(t,e){return e||bt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},Q.prototype.readFloatLE=function(t,e){return e||bt(t,4,this.length),j(this,t,1,23,4)},Q.prototype.readFloatBE=function(t,e){return e||bt(t,4,this.length),j(this,t,0,23,4)},Q.prototype.readDoubleLE=function(t,e){return e||bt(t,8,this.length),j(this,t,1,52,8)},Q.prototype.readDoubleBE=function(t,e){return e||bt(t,8,this.length),j(this,t,0,52,8)},Q.prototype.writeUIntLE=function(t,e,r,n){t=+t,e|=0,r|=0,n||Mt(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},Q.prototype.writeUIntBE=function(t,e,r,n){t=+t,e|=0,r|=0,n||Mt(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},Q.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||Mt(this,t,e,1,255,0),Q.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},Q.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||Mt(this,t,e,2,65535,0),Q.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Pt(this,t,e,1),e+2},Q.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||Mt(this,t,e,2,65535,0),Q.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Pt(this,t,e,0),e+2},Q.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||Mt(this,t,e,4,4294967295,0),Q.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):kt(this,t,e,1),e+4},Q.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||Mt(this,t,e,4,4294967295,0),Q.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):kt(this,t,e,0),e+4},Q.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);Mt(this,t,e,r,i-1,-i)}var o=0,s=1,u=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===u&&0!==this[e+o-1]&&(u=1),this[e+o]=(t/s>>0)-u&255;return e+r},Q.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);Mt(this,t,e,r,i-1,-i)}var o=r-1,s=1,u=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===u&&0!==this[e+o+1]&&(u=1),this[e+o]=(t/s>>0)-u&255;return e+r},Q.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||Mt(this,t,e,1,127,-128),Q.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},Q.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||Mt(this,t,e,2,32767,-32768),Q.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):Pt(this,t,e,1),e+2},Q.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||Mt(this,t,e,2,32767,-32768),Q.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):Pt(this,t,e,0),e+2},Q.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||Mt(this,t,e,4,2147483647,-2147483648),Q.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):kt(this,t,e,1),e+4},Q.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||Mt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),Q.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):kt(this,t,e,0),e+4},Q.prototype.writeFloatLE=function(t,e,r){return Et(this,t,e,1,r)},Q.prototype.writeFloatBE=function(t,e,r){return Et(this,t,e,0,r)},Q.prototype.writeDoubleLE=function(t,e,r){return _t(this,t,e,1,r)},Q.prototype.writeDoubleBE=function(t,e,r){return _t(this,t,e,0,r)},Q.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i,o=n-r;if(this===t&&r<e&&e<n)for(i=o-1;i>=0;--i)t[i+e]=this[i+r];else if(o<1e3||!Q.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+o),e);return o},Q.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!Q.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var o;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o<r;++o)this[o]=t;else{var s=et(t)?t:Tt(new Q(t,n).toString()),u=s.length;for(o=0;o<r-e;++o)this[o+e]=s[o%u]}return this};var St=/[^+\/0-9A-Za-z-_]/g;function Tt(t,e){var r;e=e||Infinity;for(var n=t.length,i=null,o=[],s=0;s<n;++s){if((r=t.charCodeAt(s))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function It(t){return function(t){var e,r,n,i,o,s;W||Y();var u=t.length;if(u%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===t[u-2]?2:"="===t[u-1]?1:0,s=new D(3*u/4-o),n=o>0?u-4:u;var a=0;for(e=0,r=0;e<n;e+=4,r+=3)i=U[t.charCodeAt(e)]<<18|U[t.charCodeAt(e+1)]<<12|U[t.charCodeAt(e+2)]<<6|U[t.charCodeAt(e+3)],s[a++]=i>>16&255,s[a++]=i>>8&255,s[a++]=255&i;return 2===o?(i=U[t.charCodeAt(e)]<<2|U[t.charCodeAt(e+1)]>>4,s[a++]=255&i):1===o&&(i=U[t.charCodeAt(e)]<<10|U[t.charCodeAt(e+1)]<<4|U[t.charCodeAt(e+2)]>>2,s[a++]=i>>8&255,s[a++]=255&i),s}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(St,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function xt(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function Bt(t){return null!=t&&(!!t._isBuffer||Lt(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Lt(t.slice(0,0))}(t))}function Lt(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var Ct=L(Object.freeze({__proto__:null,Buffer:Q,INSPECT_MAX_BYTES:50,SlowBuffer:function(t){return+t!=t&&(t=0),Q.alloc(+t)},isBuffer:Bt,kMaxLength:z}));!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 C?C.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:Ct.Buffer}catch(t){}function s(t,e){var n=t.charCodeAt(e);return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void r(0,"Invalid character in "+t)}function u(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function a(t,e,n,i){for(var o=0,s=0,u=Math.min(t.length,n),a=e;a<u;a++){var h=t.charCodeAt(a)-48;o*=i,s=h>=49?h-49+10:h>=17?h-17+10:h,r(h>=0&&s<i,"Invalid character"),o+=s}return o}function h(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(i.isBN=function(t){return t instanceof i?1: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,u=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<<u&67108863,this.words[o+1]=s>>>26-u&67108863,(u+=24)>=26&&(u-=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<<u&67108863,this.words[o+1]=s>>>26-u&67108863,(u+=24)>=26&&(u-=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=u(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=u(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,u=Math.min(o,o-s)+r,h=0,l=r;l<u;l+=n)h=a(t,l,l+n,e),this.imuln(i),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==s){var c=1;for(h=a(t,l,t.length,e),l=0;l<s;l++)c*=e;this.imuln(c),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h)}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._move=function(t){h(t,this)},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},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{i.prototype[Symbol.for("nodejs.util.inspect.custom")]=l}catch(t){i.prototype.inspect=l}else i.prototype.inspect=l;function l(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var c=["","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"],f=[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],d=[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 p(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,u=67108863&s,a=s/67108864|0;r.words[0]=u;for(var h=1;h<n;h++){for(var l=a>>>26,c=67108863&a,f=Math.min(h,e.length-1),d=Math.max(0,h-t.length+1);d<=f;d++){var p=h-d|0;l+=(s=(i=0|t.words[p])*(o=0|e.words[d])+c)/67108864|0,c=67108863&s}r.words[h]=0|c,a=0|l}return 0!==a?r.words[h]=0|a: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 u=this.words[s],a=(16777215&(u<<i|o)).toString(16);o=u>>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),n=0!==o||s!==this.length-1?c[6-a.length]+a+n:a+n}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 h=f[t],l=d[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modrn(l).toString(t);n=(p=p.idivn(l)).isZero()?m+n:c[h-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(0,"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(0,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},i.prototype.toJSON=function(){return this.toString(16,2)},o&&(i.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),i.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},i.prototype.toArrayLike=function(t,e,n){this._strip();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");var s=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,o);return this["_toArrayLike"+("le"===e?"LE":"BE")](s,i),s},i.prototype._toArrayLikeLE=function(t){for(var e=0,r=0,n=0,i=0;n<this.length;n++){var o=this.words[n]<<i|r;t[e++]=255&o,e<t.length&&(t[e++]=o>>8&255),e<t.length&&(t[e++]=o>>16&255),6===i?(e<t.length&&(t[e++]=o>>24&255),r=0,i=0):(r=o>>>24,i+=2)}if(e<t.length)for(t[e++]=r;e<t.length;)t[e++]=0},i.prototype._toArrayLikeBE=function(t){for(var e=t.length-1,r=0,n=0,i=0;n<this.length;n++){var o=this.words[n]<<i|r;t[e--]=255&o,e>=0&&(t[e--]=o>>8&255),e>=0&&(t[e--]=o>>16&255),6===i?(e>=0&&(t[e--]=o>>24&255),r=0,i=0):(r=o>>>24,i+=2)}if(e>=0)for(t[e--]=r;e>=0;)t[e--]=0},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 m=function(t,e,r){var n,i,o,s=t.words,u=e.words,a=r.words,h=0,l=0|s[0],c=8191&l,f=l>>>13,d=0|s[1],p=8191&d,m=d>>>13,g=0|s[2],y=8191&g,w=g>>>13,v=0|s[3],b=8191&v,M=v>>>13,P=0|s[4],k=8191&P,A=P>>>13,E=0|s[5],_=8191&E,S=E>>>13,T=0|s[6],I=8191&T,x=T>>>13,B=0|s[7],L=8191&B,C=B>>>13,R=0|s[8],O=8191&R,U=R>>>13,D=0|s[9],W=8191&D,Y=D>>>13,N=0|u[0],q=8191&N,j=N>>>13,K=0|u[1],V=8191&K,Z=K>>>13,z=0|u[2],F=8191&z,G=z>>>13,Q=0|u[3],$=8191&Q,H=Q>>>13,J=0|u[4],X=8191&J,tt=J>>>13,et=0|u[5],rt=8191&et,nt=et>>>13,it=0|u[6],ot=8191&it,st=it>>>13,ut=0|u[7],at=8191&ut,ht=ut>>>13,lt=0|u[8],ct=8191&lt,ft=lt>>>13,dt=0|u[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(h+(n=Math.imul(c,q))|0)+((8191&(i=(i=Math.imul(c,j))+Math.imul(f,q)|0))<<13)|0;h=((o=Math.imul(f,j))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,q),i=(i=Math.imul(p,j))+Math.imul(m,q)|0,o=Math.imul(m,j);var yt=(h+(n=n+Math.imul(c,V)|0)|0)+((8191&(i=(i=i+Math.imul(c,Z)|0)+Math.imul(f,V)|0))<<13)|0;h=((o=o+Math.imul(f,Z)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,q),i=(i=Math.imul(y,j))+Math.imul(w,q)|0,o=Math.imul(w,j),n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,Z)|0;var wt=(h+(n=n+Math.imul(c,F)|0)|0)+((8191&(i=(i=i+Math.imul(c,G)|0)+Math.imul(f,F)|0))<<13)|0;h=((o=o+Math.imul(f,G)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(b,q),i=(i=Math.imul(b,j))+Math.imul(M,q)|0,o=Math.imul(M,j),n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,Z)|0)+Math.imul(w,V)|0,o=o+Math.imul(w,Z)|0,n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(m,F)|0,o=o+Math.imul(m,G)|0;var vt=(h+(n=n+Math.imul(c,$)|0)|0)+((8191&(i=(i=i+Math.imul(c,H)|0)+Math.imul(f,$)|0))<<13)|0;h=((o=o+Math.imul(f,H)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(k,q),i=(i=Math.imul(k,j))+Math.imul(A,q)|0,o=Math.imul(A,j),n=n+Math.imul(b,V)|0,i=(i=i+Math.imul(b,Z)|0)+Math.imul(M,V)|0,o=o+Math.imul(M,Z)|0,n=n+Math.imul(y,F)|0,i=(i=i+Math.imul(y,G)|0)+Math.imul(w,F)|0,o=o+Math.imul(w,G)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,H)|0)+Math.imul(m,$)|0,o=o+Math.imul(m,H)|0;var bt=(h+(n=n+Math.imul(c,X)|0)|0)+((8191&(i=(i=i+Math.imul(c,tt)|0)+Math.imul(f,X)|0))<<13)|0;h=((o=o+Math.imul(f,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(_,q),i=(i=Math.imul(_,j))+Math.imul(S,q)|0,o=Math.imul(S,j),n=n+Math.imul(k,V)|0,i=(i=i+Math.imul(k,Z)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,Z)|0,n=n+Math.imul(b,F)|0,i=(i=i+Math.imul(b,G)|0)+Math.imul(M,F)|0,o=o+Math.imul(M,G)|0,n=n+Math.imul(y,$)|0,i=(i=i+Math.imul(y,H)|0)+Math.imul(w,$)|0,o=o+Math.imul(w,H)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,tt)|0;var Mt=(h+(n=n+Math.imul(c,rt)|0)|0)+((8191&(i=(i=i+Math.imul(c,nt)|0)+Math.imul(f,rt)|0))<<13)|0;h=((o=o+Math.imul(f,nt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(I,q),i=(i=Math.imul(I,j))+Math.imul(x,q)|0,o=Math.imul(x,j),n=n+Math.imul(_,V)|0,i=(i=i+Math.imul(_,Z)|0)+Math.imul(S,V)|0,o=o+Math.imul(S,Z)|0,n=n+Math.imul(k,F)|0,i=(i=i+Math.imul(k,G)|0)+Math.imul(A,F)|0,o=o+Math.imul(A,G)|0,n=n+Math.imul(b,$)|0,i=(i=i+Math.imul(b,H)|0)+Math.imul(M,$)|0,o=o+Math.imul(M,H)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(w,X)|0,o=o+Math.imul(w,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,nt)|0;var Pt=(h+(n=n+Math.imul(c,ot)|0)|0)+((8191&(i=(i=i+Math.imul(c,st)|0)+Math.imul(f,ot)|0))<<13)|0;h=((o=o+Math.imul(f,st)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,q),i=(i=Math.imul(L,j))+Math.imul(C,q)|0,o=Math.imul(C,j),n=n+Math.imul(I,V)|0,i=(i=i+Math.imul(I,Z)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(_,F)|0,i=(i=i+Math.imul(_,G)|0)+Math.imul(S,F)|0,o=o+Math.imul(S,G)|0,n=n+Math.imul(k,$)|0,i=(i=i+Math.imul(k,H)|0)+Math.imul(A,$)|0,o=o+Math.imul(A,H)|0,n=n+Math.imul(b,X)|0,i=(i=i+Math.imul(b,tt)|0)+Math.imul(M,X)|0,o=o+Math.imul(M,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(w,rt)|0,o=o+Math.imul(w,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,st)|0;var kt=(h+(n=n+Math.imul(c,at)|0)|0)+((8191&(i=(i=i+Math.imul(c,ht)|0)+Math.imul(f,at)|0))<<13)|0;h=((o=o+Math.imul(f,ht)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(O,q),i=(i=Math.imul(O,j))+Math.imul(U,q)|0,o=Math.imul(U,j),n=n+Math.imul(L,V)|0,i=(i=i+Math.imul(L,Z)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,Z)|0,n=n+Math.imul(I,F)|0,i=(i=i+Math.imul(I,G)|0)+Math.imul(x,F)|0,o=o+Math.imul(x,G)|0,n=n+Math.imul(_,$)|0,i=(i=i+Math.imul(_,H)|0)+Math.imul(S,$)|0,o=o+Math.imul(S,H)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(A,X)|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(M,rt)|0,o=o+Math.imul(M,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(w,ot)|0,o=o+Math.imul(w,st)|0,n=n+Math.imul(p,at)|0,i=(i=i+Math.imul(p,ht)|0)+Math.imul(m,at)|0,o=o+Math.imul(m,ht)|0;var At=(h+(n=n+Math.imul(c,ct)|0)|0)+((8191&(i=(i=i+Math.imul(c,ft)|0)+Math.imul(f,ct)|0))<<13)|0;h=((o=o+Math.imul(f,ft)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(W,q),i=(i=Math.imul(W,j))+Math.imul(Y,q)|0,o=Math.imul(Y,j),n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,Z)|0)+Math.imul(U,V)|0,o=o+Math.imul(U,Z)|0,n=n+Math.imul(L,F)|0,i=(i=i+Math.imul(L,G)|0)+Math.imul(C,F)|0,o=o+Math.imul(C,G)|0,n=n+Math.imul(I,$)|0,i=(i=i+Math.imul(I,H)|0)+Math.imul(x,$)|0,o=o+Math.imul(x,H)|0,n=n+Math.imul(_,X)|0,i=(i=i+Math.imul(_,tt)|0)+Math.imul(S,X)|0,o=o+Math.imul(S,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,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(M,ot)|0,o=o+Math.imul(M,st)|0,n=n+Math.imul(y,at)|0,i=(i=i+Math.imul(y,ht)|0)+Math.imul(w,at)|0,o=o+Math.imul(w,ht)|0,n=n+Math.imul(p,ct)|0,i=(i=i+Math.imul(p,ft)|0)+Math.imul(m,ct)|0,o=o+Math.imul(m,ft)|0;var Et=(h+(n=n+Math.imul(c,pt)|0)|0)+((8191&(i=(i=i+Math.imul(c,mt)|0)+Math.imul(f,pt)|0))<<13)|0;h=((o=o+Math.imul(f,mt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(W,V),i=(i=Math.imul(W,Z))+Math.imul(Y,V)|0,o=Math.imul(Y,Z),n=n+Math.imul(O,F)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(U,F)|0,o=o+Math.imul(U,G)|0,n=n+Math.imul(L,$)|0,i=(i=i+Math.imul(L,H)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,H)|0,n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,tt)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(_,rt)|0,i=(i=i+Math.imul(_,nt)|0)+Math.imul(S,rt)|0,o=o+Math.imul(S,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,n=n+Math.imul(b,at)|0,i=(i=i+Math.imul(b,ht)|0)+Math.imul(M,at)|0,o=o+Math.imul(M,ht)|0,n=n+Math.imul(y,ct)|0,i=(i=i+Math.imul(y,ft)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,ft)|0;var _t=(h+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;h=((o=o+Math.imul(m,mt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(W,F),i=(i=Math.imul(W,G))+Math.imul(Y,F)|0,o=Math.imul(Y,G),n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,H)|0)+Math.imul(U,$)|0,o=o+Math.imul(U,H)|0,n=n+Math.imul(L,X)|0,i=(i=i+Math.imul(L,tt)|0)+Math.imul(C,X)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(I,rt)|0,i=(i=i+Math.imul(I,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(_,ot)|0,i=(i=i+Math.imul(_,st)|0)+Math.imul(S,ot)|0,o=o+Math.imul(S,st)|0,n=n+Math.imul(k,at)|0,i=(i=i+Math.imul(k,ht)|0)+Math.imul(A,at)|0,o=o+Math.imul(A,ht)|0,n=n+Math.imul(b,ct)|0,i=(i=i+Math.imul(b,ft)|0)+Math.imul(M,ct)|0,o=o+Math.imul(M,ft)|0;var St=(h+(n=n+Math.imul(y,pt)|0)|0)+((8191&(i=(i=i+Math.imul(y,mt)|0)+Math.imul(w,pt)|0))<<13)|0;h=((o=o+Math.imul(w,mt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(W,$),i=(i=Math.imul(W,H))+Math.imul(Y,$)|0,o=Math.imul(Y,H),n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(U,X)|0,o=o+Math.imul(U,tt)|0,n=n+Math.imul(L,rt)|0,i=(i=i+Math.imul(L,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(I,ot)|0,i=(i=i+Math.imul(I,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(_,at)|0,i=(i=i+Math.imul(_,ht)|0)+Math.imul(S,at)|0,o=o+Math.imul(S,ht)|0,n=n+Math.imul(k,ct)|0,i=(i=i+Math.imul(k,ft)|0)+Math.imul(A,ct)|0,o=o+Math.imul(A,ft)|0;var Tt=(h+(n=n+Math.imul(b,pt)|0)|0)+((8191&(i=(i=i+Math.imul(b,mt)|0)+Math.imul(M,pt)|0))<<13)|0;h=((o=o+Math.imul(M,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(W,X),i=(i=Math.imul(W,tt))+Math.imul(Y,X)|0,o=Math.imul(Y,tt),n=n+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,nt)|0)+Math.imul(U,rt)|0,o=o+Math.imul(U,nt)|0,n=n+Math.imul(L,ot)|0,i=(i=i+Math.imul(L,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(I,at)|0,i=(i=i+Math.imul(I,ht)|0)+Math.imul(x,at)|0,o=o+Math.imul(x,ht)|0,n=n+Math.imul(_,ct)|0,i=(i=i+Math.imul(_,ft)|0)+Math.imul(S,ct)|0,o=o+Math.imul(S,ft)|0;var It=(h+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,mt)|0)+Math.imul(A,pt)|0))<<13)|0;h=((o=o+Math.imul(A,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(W,rt),i=(i=Math.imul(W,nt))+Math.imul(Y,rt)|0,o=Math.imul(Y,nt),n=n+Math.imul(O,ot)|0,i=(i=i+Math.imul(O,st)|0)+Math.imul(U,ot)|0,o=o+Math.imul(U,st)|0,n=n+Math.imul(L,at)|0,i=(i=i+Math.imul(L,ht)|0)+Math.imul(C,at)|0,o=o+Math.imul(C,ht)|0,n=n+Math.imul(I,ct)|0,i=(i=i+Math.imul(I,ft)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,ft)|0;var xt=(h+(n=n+Math.imul(_,pt)|0)|0)+((8191&(i=(i=i+Math.imul(_,mt)|0)+Math.imul(S,pt)|0))<<13)|0;h=((o=o+Math.imul(S,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(W,ot),i=(i=Math.imul(W,st))+Math.imul(Y,ot)|0,o=Math.imul(Y,st),n=n+Math.imul(O,at)|0,i=(i=i+Math.imul(O,ht)|0)+Math.imul(U,at)|0,o=o+Math.imul(U,ht)|0,n=n+Math.imul(L,ct)|0,i=(i=i+Math.imul(L,ft)|0)+Math.imul(C,ct)|0,o=o+Math.imul(C,ft)|0;var Bt=(h+(n=n+Math.imul(I,pt)|0)|0)+((8191&(i=(i=i+Math.imul(I,mt)|0)+Math.imul(x,pt)|0))<<13)|0;h=((o=o+Math.imul(x,mt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(W,at),i=(i=Math.imul(W,ht))+Math.imul(Y,at)|0,o=Math.imul(Y,ht),n=n+Math.imul(O,ct)|0,i=(i=i+Math.imul(O,ft)|0)+Math.imul(U,ct)|0,o=o+Math.imul(U,ft)|0;var Lt=(h+(n=n+Math.imul(L,pt)|0)|0)+((8191&(i=(i=i+Math.imul(L,mt)|0)+Math.imul(C,pt)|0))<<13)|0;h=((o=o+Math.imul(C,mt)|0)+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,n=Math.imul(W,ct),i=(i=Math.imul(W,ft))+Math.imul(Y,ct)|0,o=Math.imul(Y,ft);var Ct=(h+(n=n+Math.imul(O,pt)|0)|0)+((8191&(i=(i=i+Math.imul(O,mt)|0)+Math.imul(U,pt)|0))<<13)|0;h=((o=o+Math.imul(U,mt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Rt=(h+(n=Math.imul(W,pt))|0)+((8191&(i=(i=Math.imul(W,mt))+Math.imul(Y,pt)|0))<<13)|0;return h=((o=Math.imul(Y,mt))+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,a[0]=gt,a[1]=yt,a[2]=wt,a[3]=vt,a[4]=bt,a[5]=Mt,a[6]=Pt,a[7]=kt,a[8]=At,a[9]=Et,a[10]=_t,a[11]=St,a[12]=Tt,a[13]=It,a[14]=xt,a[15]=Bt,a[16]=Lt,a[17]=Ct,a[18]=Rt,0!==h&&(a[19]=h,r.length++),r};function g(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 u=67108863&n,a=Math.min(o,e.length-1),h=Math.max(0,o-t.length+1);h<=a;h++){var l=o-h,c=(0|t.words[l])*(0|e.words[h]),f=67108863&c;u=67108863&(f=f+u|0),i+=(s=(s=s+(c/67108864|0)|0)+(f>>>26)|0)>>>26,s&=67108863}r.words[o]=u,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function y(t,e,r){return g(t,e,r)}Math.imul||(m=p),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?m(this,t,e):r<63?p(this,t,e):r<1024?g(this,t,e):y(this,t,e)},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),y(this,t,e)},i.prototype.imul=function(t){return this.clone().mulTo(t,this)},i.prototype.imuln=function(t){var e=t<0;e&&(t=-t),r("number"==typeof t),r(t<67108864);for(var n=0,i=0;i<this.length;i++){var o=(0|this.words[i])*t,s=(67108863&o)+(67108863&n);n>>=26,n+=o/67108864|0,n+=s>>>26,this.words[i]=67108863&s}return 0!==n&&(this.words[i]=n,this.length++),e?this.ineg():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]>>>i&1}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 u=this.words[e]&o,a=(0|this.words[e])-u<<n;this.words[e]=a|s,s=u>>>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),u=67108863^67108863>>>o<<o,a=n;if(i-=s,i=Math.max(0,i),a){for(var h=0;h<s;h++)a.words[h]=this.words[h];a.length=s}if(0===s);else if(this.length>s)for(this.length-=s,h=0;h<this.length;h++)this.words[h]=this.words[h+s];else this.words[0]=0,this.length=1;var l=0;for(h=this.length-1;h>=0&&(0!==l||h>=i);h--){var c=0|this.words[h];this.words[h]=l<<26-o|c>>>o,l=c&u}return a&&0!==l&&(a.words[a.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?0:!!(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 u=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+u;var a=(0|t.words[i])*e;u=((o-=67108863&a)>>26)-(a/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)u=(o=(0|this.words[i+n])+u)>>26,this.words[i+n]=67108863&o;if(0===u)return this._strip();for(r(-1===u),u=0,i=0;i<this.length;i++)u=(o=-(0|this.words[i])+u)>>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 u,a=n.length-o.length;if("mod"!==e){(u=new i(null)).length=a+1,u.words=new Array(u.length);for(var h=0;h<u.length;h++)u.words[h]=0}var l=n.clone()._ishlnsubmul(o,1,a);0===l.negative&&(n=l,u&&(u.words[a]=1));for(var c=a-1;c>=0;c--){var f=67108864*(0|n.words[o.length+c])+(0|n.words[o.length+c-1]);for(f=Math.min(f/s|0,67108863),n._ishlnsubmul(o,f,c);0!==n.negative;)f--,n.negative=0,n._ishlnsubmul(o,1,c),n.isZero()||(n.negative^=1);u&&(u.words[c]=f)}return u&&u._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:u||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?(u=this.neg().divmod(t,e),"mod"!==e&&(o=u.div.neg()),"div"!==e&&(s=u.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(u=this.divmod(t.neg(),e),"mod"!==e&&(o=u.div.neg()),{div:o,mod:u.mod}):0!=(this.negative&t.negative)?(u=this.neg().divmod(t.neg(),e),"div"!==e&&(s=u.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:u.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.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new i(this.modrn(t.words[0]))}:this._wordDiv(t,e);var o,s,u},i.prototype.div=function(t){return this.divmod(t,"div",0).div},i.prototype.mod=function(t){return this.divmod(t,"mod",0).mod},i.prototype.umod=function(t){return this.divmod(t,"mod",1).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.modrn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=(1<<26)%t,i=0,o=this.length-1;o>=0;o--)i=(n*i+(0|this.words[o]))%t;return e?-i:i},i.prototype.modn=function(t){return this.modrn(t)},i.prototype.idivn=function(t){var e=t<0;e&&(t=-t),r(t<=67108863);for(var n=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*n;this.words[i]=o/t|0,n=o%t}return this._strip(),e?this.ineg():this},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),u=new i(0),a=new i(1),h=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++h;for(var l=n.clone(),c=e.clone();!e.isZero();){for(var f=0,d=1;0==(e.words[0]&d)&&f<26;++f,d<<=1);if(f>0)for(e.iushrn(f);f-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(l),s.isub(c)),o.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(u.isOdd()||a.isOdd())&&(u.iadd(l),a.isub(c)),u.iushrn(1),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(u),s.isub(a)):(n.isub(e),u.isub(o),a.isub(s))}return{a:u,b:a,gcd:n.iushln(h)}},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),u=new i(0),a=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,l=1;0==(e.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);for(var c=0,f=1;0==(n.words[0]&f)&&c<26;++c,f<<=1);if(c>0)for(n.iushrn(c);c-- >0;)u.isOdd()&&u.iadd(a),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(u)):(n.isub(e),u.isub(s))}return(o=0===e.cmpn(1)?s:u).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 u=0|this.words[s];o=(u+=o)>>>26,u&=67108863,this.words[s]=u}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 A(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 w={k256:null,p224:null,p192:null,p25519:null};function v(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 b(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function M(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(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 E(t){A.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)}v.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.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},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},n(b,v),b.prototype.split=function(t,e){for(var r=4194303,n=Math.min(t.length,9),i=0;i<n;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var o=t.words[9];for(e.words[e.length++]=o&r,i=10;i<t.length;i++){var s=0|t.words[i];t.words[i-10]=(s&r)<<4|o>>>22,o=s}o>>>=22,t.words[i-10]=o,0===o&&t.length>10?t.length-=10:t.length-=9},b.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(M,v),n(P,v),n(k,v),k.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(w[t])return w[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new M;else if("p192"===t)e=new P;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new k}return w[t]=e,e},A.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},A.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")},A.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(h(t,t.umod(this.m)._forceRed(this)),t)},A.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},A.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)},A.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},A.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)},A.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},A.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},A.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},A.prototype.isqr=function(t){return this.imul(t,t.clone())},A.prototype.sqr=function(t){return this.mul(t,t)},A.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 u=new i(1).toRed(this),a=u.redNeg(),h=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,h).cmp(a);)l.redIAdd(a);for(var c=this.pow(l,o),f=this.pow(t,o.addn(1).iushrn(1)),d=this.pow(t,o),p=s;0!==d.cmp(u);){for(var m=d,g=0;0!==m.cmp(u);g++)m=m.redSqr();r(g<p);var y=this.pow(c,new i(1).iushln(p-g-1));f=f.redMul(y),c=y.redSqr(),d=d.redMul(c),p=g}return f},A.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},A.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,u=0,a=e.bitLength()%26;for(0===a&&(a=26),n=e.length-1;n>=0;n--){for(var h=e.words[n],l=a-1;l>=0;l--){var c=h>>l&1;o!==r[0]&&(o=this.sqr(o)),0!==c||0!==s?(s<<=1,s|=c,(4==++u||0===n&&0===l)&&(o=this.mul(o,r[s]),u=0,s=0)):u=0}a=26}return o},A.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},A.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new E(t)},n(E,A),E.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},E.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},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)},E.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)},E.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(0,x);var Rt=C.exports,Ot=B(Rt),Ut={},Dt={};class Wt{constructor(t,e){if(!Number.isInteger(t))throw new TypeError("span must be an integer");this.span=t,this.property=e}makeDestinationObject(){return{}}decode(t,e){throw new Error("Layout is abstract")}encode(t,e,r){throw new Error("Layout is abstract")}getSpan(t,e){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(t){const e=Object.create(this.constructor.prototype);return Object.assign(e,this),e.property=t,e}fromArray(t){}}function Yt(t,e){return e.property?t+"["+e.property+"]":t}Dt.Layout=Wt,Dt.nameWithProperty=Yt,Dt.bindConstructorLayout=function(t,e){if("function"!=typeof t)throw new TypeError("Class must be constructor");if(t.hasOwnProperty("layout_"))throw new Error("Class is already bound to a layout");if(!(e&&e instanceof Wt))throw new TypeError("layout must be a Layout");if(e.hasOwnProperty("boundConstructor_"))throw new Error("layout is already bound to a constructor");t.layout_=e,e.boundConstructor_=t,e.makeDestinationObject=()=>new t,Object.defineProperty(t.prototype,"encode",{value:function(t,r){return e.encode(this,t,r)},writable:1}),Object.defineProperty(t,"decode",{value:function(t,r){return e.decode(t,r)},writable:1})};class Nt extends Wt{isCount(){throw new Error("ExternalLayout is abstract")}}class qt extends Nt{constructor(t,e){if(void 0===t&&(t=1),!Number.isInteger(t)||0>=t)throw new TypeError("elementSpan must be a (positive) integer");super(-1,e),this.elementSpan=t}isCount(){return 1}decode(t,e){void 0===e&&(e=0);const r=t.length-e;return Math.floor(r/this.elementSpan)}encode(t,e,r){return 0}}class jt extends Nt{constructor(t,e,r){if(!(t instanceof Wt))throw new TypeError("layout must be a Layout");if(void 0===e)e=0;else if(!Number.isInteger(e))throw new TypeError("offset must be integer or undefined");super(t.span,r||t.property),this.layout=t,this.offset=e}isCount(){return this.layout instanceof Kt||this.layout instanceof Vt}decode(t,e){return void 0===e&&(e=0),this.layout.decode(t,e+this.offset)}encode(t,e,r){return void 0===r&&(r=0),this.layout.encode(t,e,r+this.offset)}}class Kt extends Wt{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntLE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntLE(t,r,this.span),this.span}}class Vt extends Wt{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readUIntBE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeUIntBE(t,r,this.span),this.span}}class Zt extends Wt{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readIntLE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeIntLE(t,r,this.span),this.span}}class zt extends Wt{constructor(t,e){if(super(t,e),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(t,e){return void 0===e&&(e=0),t.readIntBE(e,this.span)}encode(t,e,r){return void 0===r&&(r=0),e.writeIntBE(t,r,this.span),this.span}}const Ft=Math.pow(2,32);function Gt(t){const e=Math.floor(t/Ft);return{hi32:e,lo32:t-e*Ft}}function Qt(t,e){return t*Ft+e}class $t extends Wt{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return Qt(t.readUInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=Gt(t);return e.writeUInt32LE(n.lo32,r),e.writeUInt32LE(n.hi32,r+4),8}}class Ht extends Wt{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),Qt(t.readUInt32BE(e),t.readUInt32BE(e+4))}encode(t,e,r){void 0===r&&(r=0);const n=Gt(t);return e.writeUInt32BE(n.hi32,r),e.writeUInt32BE(n.lo32,r+4),8}}class Jt extends Wt{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return Qt(t.readInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=Gt(t);return e.writeUInt32LE(n.lo32,r),e.writeInt32LE(n.hi32,r+4),8}}class Xt extends Wt{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),Qt(t.readInt32BE(e),t.readUInt32BE(e+4))}encode(t,e,r){void 0===r&&(r=0);const n=Gt(t);return e.writeInt32BE(n.hi32,r),e.writeUInt32BE(n.lo32,r+4),8}}class te extends Wt{constructor(t){super(4,t)}decode(t,e){return void 0===e&&(e=0),t.readFloatLE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeFloatLE(t,r),4}}class ee extends Wt{constructor(t){super(4,t)}decode(t,e){return void 0===e&&(e=0),t.readFloatBE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeFloatBE(t,r),4}}class re extends Wt{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),t.readDoubleLE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeDoubleLE(t,r),8}}class ne extends Wt{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),t.readDoubleBE(e)}encode(t,e,r){return void 0===r&&(r=0),e.writeDoubleBE(t,r),8}}class ie extends Wt{constructor(t,e,r){if(!(t instanceof Wt))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof Nt&&e.isCount()||Number.isInteger(e)&&0<=e))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let n=-1;!(e instanceof Nt)&&0<t.span&&(n=e*t.span),super(n,r),this.elementLayout=t,this.count=e}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0,n=this.count;if(n instanceof Nt&&(n=n.decode(t,e)),0<this.elementLayout.span)r=n*this.elementLayout.span;else{let i=0;for(;i<n;)r+=this.elementLayout.getSpan(t,e+r),++i}return r}decode(t,e){void 0===e&&(e=0);const r=[];let n=0,i=this.count;for(i instanceof Nt&&(i=i.decode(t,e));n<i;)r.push(this.elementLayout.decode(t,e)),e+=this.elementLayout.getSpan(t,e),n+=1;return r}encode(t,e,r){void 0===r&&(r=0);const n=this.elementLayout,i=t.reduce(((t,i)=>t+n.encode(i,e,r+t)),0);return this.count instanceof Nt&&this.count.encode(t.length,e,r),i}}class oe extends Wt{constructor(t,e,r){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof Wt),1))throw new TypeError("fields must be array of Layout instances");"boolean"==typeof e&&void 0===r&&(r=e,e=void 0);for(const e of t)if(0>e.span&&void 0===e.property)throw new Error("fields cannot contain unnamed variable-length layout");let n=-1;try{n=t.reduce(((t,e)=>t+e.getSpan()),0)}catch(t){}super(n,e),this.fields=t,this.decodePrefixes=!!r}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;try{r=this.fields.reduce(((r,n)=>{const i=n.getSpan(t,e);return e+=i,r+i}),0)}catch(t){throw new RangeError("indeterminate span")}return r}decode(t,e){void 0===e&&(e=0);const r=this.makeDestinationObject();for(const n of this.fields)if(void 0!==n.property&&(r[n.property]=n.decode(t,e)),e+=n.getSpan(t,e),this.decodePrefixes&&t.length===e)break;return r}encode(t,e,r){void 0===r&&(r=0);const n=r;let i=0,o=0;for(const n of this.fields){let s=n.span;if(o=0<s?s:0,void 0!==n.property){const i=t[n.property];void 0!==i&&(o=n.encode(i,e,r),0>s&&(s=n.getSpan(e,r)))}i=r,r+=s}return i+o-n}fromArray(t){const e=this.makeDestinationObject();for(const r of this.fields)void 0!==r.property&&0<t.length&&(e[r.property]=t.shift());return e}layoutFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}offsetOf(t){if("string"!=typeof t)throw new TypeError("property must be string");let e=0;for(const r of this.fields){if(r.property===t)return e;0>r.span?e=-1:0<=e&&(e+=r.span)}}}class se{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class ue extends se{constructor(t,e){if(!(t instanceof Nt&&t.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(e||t.property||"variant"),this.layout=t}decode(t,e){return this.layout.decode(t,e)}encode(t,e,r){return this.layout.encode(t,e,r)}}class ae extends Wt{constructor(t,e,r){const n=t instanceof Kt||t instanceof Vt;if(n)t=new ue(new jt(t));else if(t instanceof Nt&&t.isCount())t=new ue(t);else if(!(t instanceof se))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(void 0===e&&(e=null),!(null===e||e instanceof Wt))throw new TypeError("defaultLayout must be null or a Layout");if(null!==e){if(0>e.span)throw new Error("defaultLayout must have constant span");void 0===e.property&&(e=e.replicate("content"))}let i=-1;e&&(i=e.span,0<=i&&n&&(i+=t.layout.span)),super(i,r),this.discriminator=t,this.usesPrefixDiscriminator=n,this.defaultLayout=e,this.registry={};let o=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(t){return o(t)},this.configGetSourceVariant=function(t){o=t.bind(this)}}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);const r=this.getVariant(t,e);if(!r)throw new Error("unable to determine span for unrecognized variant");return r.getSpan(t,e)}defaultGetSourceVariant(t){if(t.hasOwnProperty(this.discriminator.property)){if(this.defaultLayout&&t.hasOwnProperty(this.defaultLayout.property))return;const e=this.registry[t[this.discriminator.property]];if(e&&(!e.layout||t.hasOwnProperty(e.property)))return e}else for(const e in this.registry){const r=this.registry[e];if(t.hasOwnProperty(r.property))return r}throw new Error("unable to infer src variant")}decode(t,e){let r;void 0===e&&(e=0);const n=this.discriminator,i=n.decode(t,e);let o=this.registry[i];if(void 0===o){let s=0;o=this.defaultLayout,this.usesPrefixDiscriminator&&(s=n.layout.span),r=this.makeDestinationObject(),r[n.property]=i,r[o.property]=this.defaultLayout.decode(t,e+s)}else r=o.decode(t,e);return r}encode(t,e,r){void 0===r&&(r=0);const n=this.getSourceVariant(t);if(void 0===n){const n=this.discriminator,i=this.defaultLayout;let o=0;return this.usesPrefixDiscriminator&&(o=n.layout.span),n.encode(t[n.property],e,r),o+i.encode(t[i.property],e,r+o)}return n.encode(t,e,r)}addVariant(t,e,r){const n=new he(this,t,e,r);return this.registry[t]=n,n}getVariant(t,e){let r=t;return Buffer.isBuffer(t)&&(void 0===e&&(e=0),r=this.discriminator.decode(t,e)),this.registry[r]}}class he extends Wt{constructor(t,e,r,n){if(!(t instanceof ae))throw new TypeError("union must be a Union");if(!Number.isInteger(e)||0>e)throw new TypeError("variant must be a (non-negative) integer");if("string"==typeof r&&void 0===n&&(n=r,r=null),r){if(!(r instanceof Wt))throw new TypeError("layout must be a Layout");if(null!==t.defaultLayout&&0<=r.span&&r.span>t.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if("string"!=typeof n)throw new TypeError("variant must have a String property")}let i=t.span;0>t.span&&(i=r?r.span:0,0<=i&&t.usesPrefixDiscriminator&&(i+=t.discriminator.layout.span)),super(i,n),this.union=t,this.variant=e,this.layout=r||null}getSpan(t,e){if(0<=this.span)return this.span;void 0===e&&(e=0);let r=0;return this.union.usesPrefixDiscriminator&&(r=this.union.discriminator.layout.span),r+this.layout.getSpan(t,e+r)}decode(t,e){const r=this.makeDestinationObject();if(void 0===e&&(e=0),this!==this.union.getVariant(t,e))throw new Error("variant mismatch");let n=0;return this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout?r[this.property]=this.layout.decode(t,e+n):this.property?r[this.property]=1:this.union.usesPrefixDiscriminator&&(r[this.union.discriminator.property]=this.variant),r}encode(t,e,r){void 0===r&&(r=0);let n=0;if(this.union.usesPrefixDiscriminator&&(n=this.union.discriminator.layout.span),this.layout&&!t.hasOwnProperty(this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,e,r);let i=n;if(this.layout&&(this.layout.encode(t[this.property],e,r+n),i+=this.layout.getSpan(e,r+n),0<=this.union.span&&i>this.union.span))throw new Error("encoded variant overruns containing union");return i}fromArray(t){if(this.layout)return this.layout.fromArray(t)}}function le(t){return 0>t&&(t+=4294967296),t}class ce extends Wt{constructor(t,e,r){if(!(t instanceof Kt||t instanceof Vt))throw new TypeError("word must be a UInt or UIntBE layout");if("string"==typeof e&&void 0===r&&(r=e,e=void 0),4<t.span)throw new RangeError("word cannot exceed 32 bits");super(t.span,r),this.word=t,this.msb=!!e,this.fields=[];let n=0;this._packedSetValue=function(t){return n=le(t),this},this._packedGetValue=function(){return n}}decode(t,e){const r=this.makeDestinationObject();void 0===e&&(e=0);const n=this.word.decode(t,e);this._packedSetValue(n);for(const t of this.fields)void 0!==t.property&&(r[t.property]=t.decode(n));return r}encode(t,e,r){void 0===r&&(r=0);const n=this.word.decode(e,r);this._packedSetValue(n);for(const e of this.fields)if(void 0!==e.property){const r=t[e.property];void 0!==r&&e.encode(r)}return this.word.encode(this._packedGetValue(),e,r)}addField(t,e){const r=new fe(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new de(this,t);return this.fields.push(e),e}fieldFor(t){if("string"!=typeof t)throw new TypeError("property must be string");for(const e of this.fields)if(e.property===t)return e}}class fe{constructor(t,e,r){if(!(t instanceof ce))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(e)||0>=e)throw new TypeError("bits must be positive integer");const n=8*t.span,i=t.fields.reduce(((t,e)=>t+e.bits),0);if(e+i>n)throw new Error("bits too long for span remainder ("+(n-i)+" of "+n+" remain)");this.container=t,this.bits=e,this.valueMask=(1<<e)-1,32===e&&(this.valueMask=4294967295),this.start=i,this.container.msb&&(this.start=n-i-e),this.wordMask=le(this.valueMask<<this.start),this.property=r}decode(){return le(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if(!Number.isInteger(t)||t!==le(t&this.valueMask))throw new TypeError(Yt("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=le(t<<this.start);this.container._packedSetValue(le(e&~this.wordMask)|r)}}class de extends fe{constructor(t,e){super(t,1,e)}decode(t,e){return!!fe.prototype.decode.call(this,t,e)}encode(t){return"boolean"==typeof t&&(t=+t),fe.prototype.encode.call(this,t)}}class pe extends Wt{constructor(t,e){if(!(t instanceof Nt&&t.isCount()||Number.isInteger(t)&&0<=t))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let r=-1;t instanceof Nt||(r=t),super(r,e),this.length=t}getSpan(t,e){let r=this.span;return 0>r&&(r=this.length.decode(t,e)),r}decode(t,e){void 0===e&&(e=0);let r=this.span;return 0>r&&(r=this.length.decode(t,e)),t.slice(e,e+r)}encode(t,e,r){let n=this.length;if(this.length instanceof Nt&&(n=t.length),!Buffer.isBuffer(t)||n!==t.length)throw new TypeError(Yt("Blob.encode",this)+" requires (length "+n+") Buffer as src");if(r+n>e.length)throw new RangeError("encoding overruns Buffer");return e.write(t.toString("hex"),r,n,"hex"),this.length instanceof Nt&&this.length.encode(n,e,r),n}}class me extends Wt{constructor(t){super(-1,t)}getSpan(t,e){if(!Buffer.isBuffer(t))throw new TypeError("b must be a Buffer");void 0===e&&(e=0);let r=e;for(;r<t.length&&0!==t[r];)r+=1;return 1+r-e}decode(t,e,r){void 0===e&&(e=0);let n=this.getSpan(t,e);return t.slice(e,e+n-1).toString("utf-8")}encode(t,e,r){void 0===r&&(r=0),"string"!=typeof t&&(t=t.toString());const n=new Buffer(t,"utf8"),i=n.length;if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return n.copy(e,r),e[r+i]=0,i+1}}class ge extends Wt{constructor(t,e){if("string"==typeof t&&void 0===e&&(e=t,t=void 0),void 0===t)t=-1;else if(!Number.isInteger(t))throw new TypeError("maxSpan must be an integer");super(-1,e),this.maxSpan=t}getSpan(t,e){if(!Buffer.isBuffer(t))throw new TypeError("b must be a Buffer");return void 0===e&&(e=0),t.length-e}decode(t,e,r){void 0===e&&(e=0);let n=this.getSpan(t,e);if(0<=this.maxSpan&&this.maxSpan<n)throw new RangeError("text length exceeds maxSpan");return t.slice(e,e+n).toString("utf-8")}encode(t,e,r){void 0===r&&(r=0),"string"!=typeof t&&(t=t.toString());const n=new Buffer(t,"utf8"),i=n.length;if(0<=this.maxSpan&&this.maxSpan<i)throw new RangeError("text length exceeds maxSpan");if(r+i>e.length)throw new RangeError("encoding overruns Buffer");return n.copy(e,r),i}}class ye extends Wt{constructor(t,e){super(0,e),this.value=t}decode(t,e,r){return this.value}encode(t,e,r){return 0}}Dt.ExternalLayout=Nt,Dt.GreedyCount=qt,Dt.OffsetLayout=jt,Dt.UInt=Kt,Dt.UIntBE=Vt,Dt.Int=Zt,Dt.IntBE=zt,Dt.Float=te,Dt.FloatBE=ee,Dt.Double=re,Dt.DoubleBE=ne,Dt.Sequence=ie,Dt.Structure=oe,Dt.UnionDiscriminator=se,Dt.UnionLayoutDiscriminator=ue,Dt.Union=ae,Dt.VariantLayout=he,Dt.BitStructure=ce,Dt.BitField=fe,Dt.Boolean=de,Dt.Blob=pe,Dt.CString=me,Dt.UTF8=ge,Dt.Constant=ye,Dt.greedy=(t,e)=>new qt(t,e),Dt.offset=(t,e,r)=>new jt(t,e,r),Dt.u8=t=>new Kt(1,t),Dt.u16=t=>new Kt(2,t),Dt.u24=t=>new Kt(3,t),Dt.u32=t=>new Kt(4,t),Dt.u40=t=>new Kt(5,t),Dt.u48=t=>new Kt(6,t),Dt.nu64=t=>new $t(t),Dt.u16be=t=>new Vt(2,t),Dt.u24be=t=>new Vt(3,t),Dt.u32be=t=>new Vt(4,t),Dt.u40be=t=>new Vt(5,t),Dt.u48be=t=>new Vt(6,t),Dt.nu64be=t=>new Ht(t),Dt.s8=t=>new Zt(1,t),Dt.s16=t=>new Zt(2,t),Dt.s24=t=>new Zt(3,t),Dt.s32=t=>new Zt(4,t),Dt.s40=t=>new Zt(5,t),Dt.s48=t=>new Zt(6,t),Dt.ns64=t=>new Jt(t),Dt.s16be=t=>new zt(2,t),Dt.s24be=t=>new zt(3,t),Dt.s32be=t=>new zt(4,t),Dt.s40be=t=>new zt(5,t),Dt.s48be=t=>new zt(6,t),Dt.ns64be=t=>new Xt(t),Dt.f32=t=>new te(t),Dt.f32be=t=>new ee(t),Dt.f64=t=>new re(t),Dt.f64be=t=>new ne(t),Dt.struct=(t,e,r)=>new oe(t,e,r),Dt.bits=(t,e,r)=>new ce(t,e,r),Dt.seq=(t,e,r)=>new ie(t,e,r),Dt.union=(t,e,r)=>new ae(t,e,r),Dt.unionLayoutDiscriminator=(t,e)=>new ue(t,e),Dt.blob=(t,e)=>new pe(t,e),Dt.cstr=t=>new me(t),Dt.utf8=(t,e)=>new ge(t,e),Dt.const=(t,e)=>new ye(t,e),function(t){var e=x&&x.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(t,"__esModule",{value:1}),t.map=t.array=t.rustEnum=t.str=t.vecU8=t.tagged=t.vec=t.bool=t.option=t.publicKey=t.i256=t.u256=t.i128=t.u128=t.i64=t.u64=t.struct=t.f64=t.f32=t.i32=t.u32=t.i16=t.u16=t.i8=t.u8=void 0;const r=Dt,n=d,i=e(Rt);var o=Dt;Object.defineProperty(t,"u8",{enumerable:1,get:function(){return o.u8}}),Object.defineProperty(t,"i8",{enumerable:1,get:function(){return o.s8}}),Object.defineProperty(t,"u16",{enumerable:1,get:function(){return o.u16}}),Object.defineProperty(t,"i16",{enumerable:1,get:function(){return o.s16}}),Object.defineProperty(t,"u32",{enumerable:1,get:function(){return o.u32}}),Object.defineProperty(t,"i32",{enumerable:1,get:function(){return o.s32}}),Object.defineProperty(t,"f32",{enumerable:1,get:function(){return o.f32}}),Object.defineProperty(t,"f64",{enumerable:1,get:function(){return o.f64}}),Object.defineProperty(t,"struct",{enumerable:1,get:function(){return o.struct}});class s extends r.Layout{constructor(t,e,n){super(t,n),this.blob=(0,r.blob)(t),this.signed=e}decode(t,e=0){const r=new i.default(this.blob.decode(t,e),10,"le");return this.signed?r.fromTwos(8*this.span).clone():r}encode(t,e,r=0){return this.signed&&(t=t.toTwos(8*this.span)),this.blob.encode(t.toArrayLike(Buffer,"le",this.span),e,r)}}function u(t){return new s(8,0,t)}t.u64=u,t.i64=function(t){return new s(8,1,t)},t.u128=function(t){return new s(16,0,t)},t.i128=function(t){return new s(16,1,t)},t.u256=function(t){return new s(32,0,t)},t.i256=function(t){return new s(32,1,t)};class a extends r.Layout{constructor(t,e,r,n){super(t.span,n),this.layout=t,this.decoder=e,this.encoder=r}decode(t,e){return this.decoder(this.layout.decode(t,e))}encode(t,e,r){return this.layout.encode(this.encoder(t),e,r)}getSpan(t,e){return this.layout.getSpan(t,e)}}t.publicKey=function(t){return new a((0,r.blob)(32),(t=>new n.PublicKey(t)),(t=>t.toBuffer()),t)};class h extends r.Layout{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=(0,r.u8)()}encode(t,e,r=0){return null==t?this.discriminator.encode(0,e,r):(this.discriminator.encode(1,e,r),this.layout.encode(t,e,r+1)+1)}decode(t,e=0){const r=this.discriminator.decode(t,e);if(0===r)return null;if(1===r)return this.layout.decode(t,e+1);throw new Error("Invalid option "+this.property)}getSpan(t,e=0){const r=this.discriminator.decode(t,e);if(0===r)return 1;if(1===r)return this.layout.getSpan(t,e+1)+1;throw new Error("Invalid option "+this.property)}}function l(t){if(0===t)return 0;if(1===t)return 1;throw new Error("Invalid bool: "+t)}function c(t){return t?1:0}function f(t){const e=(0,r.u32)("length"),n=(0,r.struct)([e,(0,r.blob)((0,r.offset)(e,-e.span),"data")]);return new a(n,(({data:t})=>t),(t=>({data:t})),t)}t.option=function(t,e){return new h(t,e)},t.bool=function(t){return new a((0,r.u8)(),l,c,t)},t.vec=function(t,e){const n=(0,r.u32)("length"),i=(0,r.struct)([n,(0,r.seq)(t,(0,r.offset)(n,-n.span),"values")]);return new a(i,(({values:t})=>t),(t=>({values:t})),e)},t.tagged=function(t,e,n){const i=(0,r.struct)([u("tag"),e.replicate("data")]);return new a(i,(function({tag:e,data:r}){if(!e.eq(t))throw new Error("Invalid tag, expected: "+t.toString("hex")+", got: "+e.toString("hex"));return r}),(e=>({tag:t,data:e})),n)},t.vecU8=f,t.str=function(t){return new a(f(),(t=>t.toString("utf-8")),(t=>Buffer.from(t,"utf-8")),t)},t.rustEnum=function(t,e,n){const i=(0,r.union)(null!=n?n:(0,r.u8)(),e);return t.forEach(((t,e)=>i.addVariant(e,t,t.property))),i},t.array=function(t,e,n){const i=(0,r.struct)([(0,r.seq)(t,e,"values")]);return new a(i,(({values:t})=>t),(t=>({values:t})),n)};class p extends r.Layout{constructor(t,e,r){super(t.span+e.span,r),this.keyLayout=t,this.valueLayout=e}decode(t,e){return e=e||0,[this.keyLayout.decode(t,e),this.valueLayout.decode(t,e+this.keyLayout.getSpan(t,e))]}encode(t,e,r){r=r||0;const n=this.keyLayout.encode(t[0],e,r);return n+this.valueLayout.encode(t[1],e,r+n)}getSpan(t,e){return this.keyLayout.getSpan(t,e)+this.valueLayout.getSpan(t,e)}}t.map=function(t,e,n){const i=(0,r.u32)("length"),o=(0,r.struct)([i,(0,r.seq)(new p(t,e),(0,r.offset)(i,-i.span),"values")]);return new a(o,(({values:t})=>new Map(t)),(t=>({values:Array.from(t.entries())})),n)}}(Ut);const we=Q.from([23,169,27,122,147,169,209,152]),ve=Ut.struct([Ut.array(Ut.u8(),32,"a"),Ut.array(Ut.u8(),64,"b"),Ut.array(Ut.u8(),32,"c")]),be=Ut.struct([Ut.publicKey("owner"),Ut.u64("amount"),Ut.option(Ut.u64(),"lamports"),Ut.u8("merkleTreeIndex"),Ut.option(Ut.vecU8(),"tlv")]),Me=Ut.struct([Ut.u8("queueId"),Ut.u16("index")]),Pe=Ut.struct([Ut.u64("amount"),Ut.option(Ut.u8(),"delegateIndex"),Ut.struct([Ut.u8("merkleTreePubkeyIndex"),Ut.u8("nullifierQueuePubkeyIndex"),Ut.u32("leafIndex"),Ut.option(Me,"QueueIndex")],"merkleContext"),Ut.u16("rootIndex"),Ut.option(Ut.u64(),"lamports"),Ut.option(Ut.vecU8(),"tlv")]),ke=Ut.struct([Ut.publicKey("owner"),Ut.option(Ut.u8(),"delegateChangeAccountIndex")]),Ae=Ut.struct([Ut.bool("setContext"),Ut.bool("firstSetContext"),Ut.u8("cpiContextAccountIndex")]),Ee=Ut.struct([Ut.option(ve,"proof"),Ut.publicKey("mint"),Ut.option(ke,"delegatedTransfer"),Ut.vec(Pe,"inputTokenDataWithContext"),Ut.vec(be,"outputCompressedAccounts"),Ut.bool("isCompress"),Ut.option(Ut.u64(),"compressOrDecompressAmount"),Ut.option(Ae,"cpiContext"),Ut.option(Ut.u8(),"lamportsChangeAccountMerkleTreeIndex")]),_e=Ut.struct([Ut.vec(Ut.publicKey(),"recipients"),Ut.vec(Ut.u64(),"amounts"),Ut.option(Ut.u64(),"lamports")]),Se=Ut.struct([Ut.publicKey("owner"),Ut.option(Ut.u64(),"remainingAmount"),Ut.option(Ae,"cpiContext")]),Te=Q.from([241,34,48,186,37,179,123,192]),Ie=Q.from([163,52,200,231,140,3,69,186]),xe=Q.from([112,230,105,101,145,202,157,97]);function Be(t){const e=Q.alloc(1e3),r=Ee.encode(t,e),n=Q.alloc(4);return n.writeUInt32LE(r,0),Q.concat([Ie,n,e.slice(0,r)])}Ut.struct([Ut.publicKey("owner"),Ut.option(Ut.u64(),"remainingAmount"),Ut.option(Ut.struct([],"CompressedCpiContext"),"cpiContext")],"compressSplTokenAccountArgs");const Le=t=>{const e=We.programId,{feePayer:r,authority:n,cpiAuthorityPda:i,lightSystemProgram:o,registeredProgramPda:s,noopProgram:u,accountCompressionAuthority:a,accountCompressionProgram:h,selfProgram:l,tokenPoolPda:c,compressOrDecompressTokenAccount:f,tokenProgram:d,systemProgram:p}=t;return[{pubkey:r,isSigner:1,isWritable:1},{pubkey:n,isSigner:1,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:h,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0},{pubkey:c??e,isSigner:0,isWritable:1},{pubkey:f??e,isSigner:0,isWritable:1},{pubkey:d??e,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:0}]},Ce=t=>t.reduce(((t,e)=>t.add(e.parsed.amount)),e(0)),Re=t=>{const e=t[0].parsed.owner;t.forEach((t=>{if(!t.parsed.owner.equals(e))throw new Error("Token accounts must be owned by the same owner")}))},Oe=t=>({mint:t[0].parsed.mint,currentOwner:t[0].parsed.owner,delegate:t[0].parsed.delegate});function Ue(t,r,n){n=e(n);const i=Ce(t),o=u(t.map((t=>t.compressedAccount))),s=i.sub(n);return a(s),s.eq(e(0))&&o.eq(e(0))?[{owner:r,amount:n,lamports:o,tlv:null}]:(h(t.map((t=>t.compressedAccount))),Re(t),[{owner:t[0].parsed.owner,amount:s,lamports:o,tlv:null},{owner:r,amount:n,lamports:e(0),tlv:null}])}function De(t,r){r=e(r);const n=u(t.map((t=>t.compressedAccount))),i=Ce(t).sub(r);return a(i),i.eq(e(0))&&n.eq(e(0))?[]:(h(t.map((t=>t.compressedAccount))),Re(t),[{owner:t[0].parsed.owner,amount:i,lamports:n,tlv:null}])}class We{constructor(){}static programId=new p("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m");static setProgramId(t){this.programId="string"==typeof t?new p(t):t}static deriveTokenPoolPda(t){const e=[S,t.toBuffer()],[r,n]=p.findProgramAddressSync(e,this.programId);return r}static get deriveCpiAuthorityPda(){const[t,e]=p.findProgramAddressSync([T],this.programId);return t}static async createMint(t){const{mint:e,authority:r,feePayer:n,rentExemptBalance:i,tokenProgramId:o,freezeAuthority:s,mintSize:u}=t,a=o??k;return[m.createAccount({fromPubkey:n,lamports:i,newAccountPubkey:e,programId:a,space:u??b}),M(e,t.decimals,r,s,a),await this.createTokenPool({feePayer:n,mint:e,tokenProgramId:a})]}static async createTokenPool(t){const{mint:e,feePayer:r,tokenProgramId:n}=t,i=n??k,o=(t=>{const{feePayer:e,tokenPoolPda:r,systemProgram:n,mint:i,tokenProgram:o,cpiAuthorityPda:s}=t;return[{pubkey:e,isSigner:1,isWritable:1},{pubkey:r,isSigner:0,isWritable:1},{pubkey:n,isSigner:0,isWritable:0},{pubkey:i,isSigner:0,isWritable:1},{pubkey:o,isSigner:0,isWritable:0},{pubkey:s,isSigner:0,isWritable:0}]})({mint:e,feePayer:r,tokenPoolPda:this.deriveTokenPoolPda(e),tokenProgram:i,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:m.programId});return new g({programId:this.programId,keys:o,data:we})}static async mintTo(t){const r=n(),{mint:u,feePayer:a,authority:h,merkleTree:l,toPubkey:c,amount:f,tokenProgramId:d}=t,p=d??k,y=this.deriveTokenPoolPda(u),w=i(f).map((t=>e(t))),v=i(c);if(w.length!==v.length)throw new Error("Amount and toPubkey arrays must have the same length");const b=(t=>{const e=We.programId,{feePayer:r,authority:n,cpiAuthorityPda:i,mint:o,tokenPoolPda:s,tokenProgram:u,lightSystemProgram:a,registeredProgramPda:h,noopProgram:l,accountCompressionAuthority:c,accountCompressionProgram:f,merkleTree:d,selfProgram:p,systemProgram:m,solPoolPda:g}=t;return[{pubkey:r,isSigner:1,isWritable:1},{pubkey:n,isSigner:1,isWritable:0},{pubkey:i,isSigner:0,isWritable:0},{pubkey:o,isSigner:0,isWritable:1},{pubkey:s,isSigner:0,isWritable:1},{pubkey:u,isSigner:0,isWritable:0},{pubkey:a,isSigner:0,isWritable:0},{pubkey:h,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:f,isSigner:0,isWritable:0},{pubkey:d,isSigner:0,isWritable:1},{pubkey:p,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0},{pubkey:g??e,isSigner:0,isWritable:1}]})({mint:u,feePayer:a,authority:h,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:p,tokenPoolPda:y,lightSystemProgram:o.programId,registeredProgramPda:r.registeredProgramPda,noopProgram:r.noopProgram,accountCompressionAuthority:r.accountCompressionAuthority,accountCompressionProgram:r.accountCompressionProgram,merkleTree:l??s().merkleTree,selfProgram:this.programId,systemProgram:m.programId,solPoolPda:null}),M=function(t,e){const r=Q.alloc(1e3),n=_e.encode({recipients:t,amounts:e,lamports:null},r);return Q.concat([Te,r.slice(0,n)])}(v,w);return new g({programId:this.programId,keys:b,data:M})}static async approveAndMintTo(t){const{mint:e,feePayer:r,authorityTokenAccount:n,authority:i,merkleTree:o,toPubkey:s,tokenProgramId:u}=t,a=BigInt(t.amount.toString());return[P(e,n,i,a,[],u),await this.compress({payer:r,owner:i,source:n,toAddress:s,mint:e,amount:t.amount,outputStateTree:o,tokenProgramId:u})]}static async transfer(t){const{payer:e,inputCompressedTokenAccounts:r,recentInputStateRootIndices:i,recentValidityProof:s,amount:u,outputStateTrees:a,toAddress:h}=t,l=Ue(r,h,u),{inputTokenDataWithContext:c,packedOutputTokenData:f,remainingAccountMetas:d}=_({inputCompressedTokenAccounts:r,outputStateTrees:a,rootIndices:i,tokenTransferOutputs:l}),{mint:p,currentOwner:y}=Oe(r),w=Be({proof:s,mint:p,delegatedTransfer:null,inputTokenDataWithContext:c,outputCompressedAccounts:f,compressOrDecompressAmount:null,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),{accountCompressionAuthority:v,noopProgram:b,registeredProgramPda:M,accountCompressionProgram:P}=n(),k=Le({feePayer:e,authority:y,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:o.programId,registeredProgramPda:M,noopProgram:b,accountCompressionAuthority:v,accountCompressionProgram:P,selfProgram:this.programId,tokenPoolPda:void 0,compressOrDecompressTokenAccount:void 0,tokenProgram:void 0,systemProgram:m.programId});return k.push(...d),new g({programId:this.programId,keys:k,data:w})}static async createTokenProgramLookupTable(t){const{authority:e,mints:r,recentSlot:i,payer:u,remainingAccounts:a}=t,[h,l]=y.createLookupTable({authority:e,payer:e,recentSlot:i});let c=[];return r&&(c=[...r,...r.map((t=>this.deriveTokenPoolPda(t)))]),{instructions:[h,y.extendLookupTable({payer:u,authority:e,lookupTable:l,addresses:[this.deriveCpiAuthorityPda,o.programId,n().registeredProgramPda,n().noopProgram,n().accountCompressionAuthority,n().accountCompressionProgram,s().merkleTree,s().nullifierQueue,s().addressTree,s().addressQueue,this.programId,k,A,e,...c,...a??[]]})],address:l}}static async compress(t){const{payer:r,owner:i,source:s,toAddress:u,mint:a,outputStateTree:h,tokenProgramId:l}=t;if(Array.isArray(t.amount)!==Array.isArray(t.toAddress))throw new Error("Both amount and toAddress must be arrays or both must be single values");let c;if(Array.isArray(t.amount)&&Array.isArray(t.toAddress)){if(t.amount.length!==t.toAddress.length)throw new Error("Amount and toAddress arrays must have the same length");c=t.amount.map(((r,n)=>{const i=e(r);return{owner:t.toAddress[n],amount:i,lamports:e(0),tlv:null}}))}else c=[{owner:u,amount:e(t.amount),lamports:e(0),tlv:null}];const{inputTokenDataWithContext:f,packedOutputTokenData:d,remainingAccountMetas:p}=_({inputCompressedTokenAccounts:[],outputStateTrees:h,rootIndices:[],tokenTransferOutputs:c}),y=Be({proof:null,mint:a,delegatedTransfer:null,inputTokenDataWithContext:f,outputCompressedAccounts:d,compressOrDecompressAmount:Array.isArray(t.amount)?t.amount.map((t=>new Ot(t))).reduce(((t,e)=>t.add(e)),new Ot(0)):new Ot(t.amount),isCompress:1,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),w=l??k,v=Le({...n(),feePayer:r,authority:i,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:o.programId,selfProgram:this.programId,systemProgram:m.programId,tokenPoolPda:this.deriveTokenPoolPda(a),compressOrDecompressTokenAccount:s,tokenProgram:w});return v.push(...p),new g({programId:this.programId,keys:v,data:y})}static async decompress(t){const{payer:r,inputCompressedTokenAccounts:i,toAddress:s,outputStateTree:u,recentValidityProof:a,recentInputStateRootIndices:h,tokenProgramId:l}=t,c=e(t.amount),f=De(i,c),{inputTokenDataWithContext:d,packedOutputTokenData:p,remainingAccountMetas:y}=_({inputCompressedTokenAccounts:i,outputStateTrees:u,rootIndices:h,tokenTransferOutputs:f}),{mint:w,currentOwner:v}=Oe(i),b=Be({proof:a,mint:w,delegatedTransfer:null,inputTokenDataWithContext:d,outputCompressedAccounts:p,compressOrDecompressAmount:c,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),M=l??k,{accountCompressionAuthority:P,noopProgram:A,registeredProgramPda:E,accountCompressionProgram:S}=n(),T=Le({feePayer:r,authority:v,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:o.programId,registeredProgramPda:E,noopProgram:A,accountCompressionAuthority:P,accountCompressionProgram:S,selfProgram:this.programId,tokenPoolPda:this.deriveTokenPoolPda(w),compressOrDecompressTokenAccount:s,tokenProgram:M,systemProgram:m.programId});return T.push(...y),new g({programId:this.programId,keys:T,data:b})}static async mergeTokenAccounts(t){const{payer:e,owner:r,inputCompressedTokenAccounts:n,outputStateTree:i,recentValidityProof:o,recentInputStateRootIndices:s}=t;if(n.length>3)throw new Error("Cannot merge more than 3 token accounts at once");return[await this.transfer({payer:e,inputCompressedTokenAccounts:n,toAddress:r,amount:n.reduce(((t,e)=>t.add(e.parsed.amount)),new Ot(0)),outputStateTrees:i,recentInputStateRootIndices:s,recentValidityProof:o})]}static async compressSplTokenAccount(t){const{feePayer:e,authority:r,tokenAccount:i,mint:s,remainingAmount:u,outputStateTree:a,tokenProgramId:h}=t,l=h??k,c=[{pubkey:a,isSigner:0,isWritable:1}],f=function(t,e){const r=Q.alloc(1e3),n=Se.encode({owner:t,remainingAmount:e,cpiContext:null},r);return Q.concat([xe,r.slice(0,n)])}(r,u??null),{accountCompressionAuthority:d,noopProgram:p,registeredProgramPda:y,accountCompressionProgram:w}=n(),v=Le({feePayer:e,authority:r,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:o.programId,registeredProgramPda:y,noopProgram:p,accountCompressionAuthority:d,accountCompressionProgram:w,selfProgram:this.programId,tokenPoolPda:this.deriveTokenPoolPda(s),compressOrDecompressTokenAccount:i,tokenProgram:l,systemProgram:m.programId});return v.push(...c),new g({programId:this.programId,keys:v,data:f})}static async get_mint_program_id(t,e){return(await e.getAccountInfo(t))?.owner}}async function Ye(t,e,r,n,i,o,s,u,a){a=a||await We.get_mint_program_id(r,t);const h=await E(t,e,r,i.publicKey,void 0,void 0,u,a),d=await We.approveAndMintTo({feePayer:e.publicKey,mint:r,authority:i.publicKey,authorityTokenAccount:h.address,amount:o,toPubkey:n,merkleTree:s,tokenProgramId:a}),{blockhash:p}=await t.getLatestBlockhash(),m=l(e,[i]),g=c([w.setComputeUnitLimit({units:1e6}),...d],e,p,m);return await f(t,g,u)}async function Ne(t,e,r,n,i,o,s,u,a,h){h=h||await We.get_mint_program_id(r,t);const d=await We.compress({payer:e.publicKey,owner:i.publicKey,source:o,toAddress:s,amount:n,mint:r,outputStateTree:u,tokenProgramId:h}),p=await t.getLatestBlockhash(),m=l(e,[i]),g=c([w.setComputeUnitLimit({units:1e6}),d],e,p.blockhash,m);return await f(t,g,a,p)}async function qe(t,r,n,i,o,s,u,a){i=e(i);const h=await t.getCompressedTokenAccountsByOwner(o.publicKey,{mint:n}),[d]=je(h.items,i),p=await t.getValidityProof(d.map((t=>e(t.compressedAccount.hash)))),m=await We.transfer({payer:r.publicKey,inputCompressedTokenAccounts:d,toAddress:s,amount:i,recentInputStateRootIndices:p.rootIndices,recentValidityProof:p.compressedProof,outputStateTrees:u}),{blockhash:g}=await t.getLatestBlockhash(),y=l(r,[o]),v=c([w.setComputeUnitLimit({units:1e6}),m],r,g,y);return await f(t,v,a)}function je(t,r){let n=e(0),i=e(0);const o=[];t.sort(((t,e)=>e.parsed.amount.cmp(t.parsed.amount)));for(const s of t){if(n.gte(e(r)))break;n=n.add(s.parsed.amount),i=i.add(s.compressedAccount.lamports),o.push(s)}if(n.lt(e(r)))throw new Error(`Not enough balance for transfer. Required: ${r.toString()}, available: ${n.toString()}`);return[o,n,i.lt(e(0))?i:null]}async function Ke(t,r,n,i,o,s,u,a,h){h=h||await We.get_mint_program_id(n,t),i=e(i);const d=await t.getCompressedTokenAccountsByOwner(o.publicKey,{mint:n}),[p]=je(d.items,i),m=await t.getValidityProof(p.map((t=>e(t.compressedAccount.hash)))),g=await We.decompress({payer:r.publicKey,inputCompressedTokenAccounts:p,toAddress:s,amount:i,outputStateTree:u,recentInputStateRootIndices:m.rootIndices,recentValidityProof:m.compressedProof,tokenProgramId:h}),{blockhash:y}=await t.getLatestBlockhash(),v=l(r,[o]),b=c([w.setComputeUnitLimit({units:1e6}),g],r,y,v);return await f(t,b,a)}async function Ve(t,e,r,n,i=v.generate(),o,s=0){const u=await t.getMinimumBalanceForRentExemption(b),a=s?A:k,h=await We.createMint({feePayer:e.publicKey,mint:i.publicKey,decimals:n,authority:r,freezeAuthority:null,rentExemptBalance:u,tokenProgramId:a}),{blockhash:d}=await t.getLatestBlockhash(),p=l(e,[i]),m=c(h,e,d,p),g=await f(t,m,o);return{mint:i.publicKey,transactionSignature:g}}async function Ze(t,e,r,n,i,o,s,u,a){a=a||await We.get_mint_program_id(r,t);const h=l(e,[i]),d=await We.mintTo({feePayer:e.publicKey,mint:r,authority:i.publicKey,amount:o,toPubkey:n,merkleTree:s,tokenProgramId:a}),{blockhash:p}=await t.getLatestBlockhash(),m=c([w.setComputeUnitLimit({units:1e6}),d],e,p,h);return await f(t,m,u)}async function ze(t,r,n,i,o,s){const u=await t.getCompressedTokenAccountsByOwner(i.publicKey,{mint:n});if(0===u.items.length)throw new Error(`No compressed token accounts found for mint ${n.toBase58()}`);if(u.items.length>=6)throw new Error(`Too many compressed token accounts used for mint ${n.toBase58()}`);const a=[w.setComputeUnitLimit({units:1e6})];for(let s=0;s<u.items.slice(0,6).length;s+=3){const h=u.items.slice(s,s+3),l=await t.getValidityProof(h.map((t=>e(t.compressedAccount.hash)))),c=await We.mergeTokenAccounts({payer:r.publicKey,owner:i.publicKey,mint:n,inputCompressedTokenAccounts:h,outputStateTree:o,recentValidityProof:l.compressedProof,recentInputStateRootIndices:l.rootIndices});a.push(...c)}const{blockhash:h}=await t.getLatestBlockhash(),d=l(r,[i]),p=c(a,r,h,d);return await f(t,p,s)}async function Fe(t,e,r,n,i){i=i||await We.get_mint_program_id(r,t);const o=await We.createTokenPool({feePayer:e.publicKey,mint:r,tokenProgramId:i}),{blockhash:s}=await t.getLatestBlockhash(),u=c([o],e,s);return await f(t,u,n)}async function Ge(t,e,r,n,i){const o=await t.getSlot("finalized"),{instructions:s,address:u}=await We.createTokenProgramLookupTable({payer:e.publicKey,authority:r.publicKey,mints:n,remainingAccounts:i,recentSlot:o}),a=l(e,[r]),h=await t.getLatestBlockhash(),d=c([s[0]],e,h.blockhash,a),p=await f(t,d,{commitment:"finalized"},h),m=await t.getLatestBlockhash(),g=c([s[1]],e,m.blockhash,a);return{txIds:[p,await f(t,g,{commitment:"finalized"},m)],address:u}}async function Qe(t,e,r,n,i,o,s,u,a){a=a||await We.get_mint_program_id(r,t);const h=await We.compressSplTokenAccount({feePayer:e.publicKey,authority:n.publicKey,tokenAccount:i,mint:r,remainingAmount:s,outputStateTree:o,tokenProgramId:a}),d=await t.getLatestBlockhash(),p=l(e,[n]),m=c([w.setComputeUnitLimit({units:1e6}),h],e,d.blockhash,p);return await f(t,m,u,d)}export{T as CPI_AUTHORITY_SEED,We as CompressedTokenProgram,S as POOL_SEED,I as SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE,Ye as approveAndMintTo,Ne as compress,Qe as compressSplTokenAccount,De as createDecompressOutputState,Ve as createMint,Fe as createTokenPool,Ge as createTokenProgramLookupTable,Ue as createTransferOutputState,Ke as decompress,ze as mergeTokenAccounts,Ze as mintTo,_ as packCompressedTokenAccounts,Oe as parseTokenData,je as selectMinCompressedTokenAccountsForTransfer,Ce as sumUpTokenAmount,qe as transfer,Re as validateSameTokenOwner};
2
- //# sourceMappingURL=index.js.map