@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/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/types/index.d.ts +1810 -1
- package/package.json +6 -4
- package/dist/es/browser/index.js +0 -2
- package/dist/es/browser/index.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("@lightprotocol/stateless.js"),e=require("@solana/web3.js"),r=require("@solana/spl-token");function n(e){const{inputCompressedTokenAccounts:r,outputStateTrees:n,remainingAccounts:i=[],rootIndices:o,tokenTransferOutputs:s}=e,u=i.slice();let a=null;r.length>0&&r[0].parsed.delegate&&(a=t.getIndexOrAdd(u,r[0].parsed.delegate));const h=[];r.forEach(((e,r)=>{const n=t.getIndexOrAdd(u,e.compressedAccount.merkleTree),i=t.getIndexOrAdd(u,e.compressedAccount.nullifierQueue);h.push({amount:e.parsed.amount,delegateIndex:a,merkleContext:{merkleTreePubkeyIndex:n,nullifierQueuePubkeyIndex:i,leafIndex:e.compressedAccount.leafIndex,queueIndex:null},rootIndex:o[r],lamports:e.compressedAccount.lamports.eq(t.bn(0))?null:e.compressedAccount.lamports,tlv:null})}));const l=t.padOutputStateMerkleTrees(n,s.length,r.map((t=>t.compressedAccount))),c=[];l.forEach(((e,r)=>{var n;const i=t.getIndexOrAdd(u,e);c.push({owner:s[r].owner,amount:s[r].amount,lamports:(null===(n=s[r].lamports)||void 0===n?void 0:n.eq(t.bn(0)))?null:s[r].lamports,merkleTreeIndex:i,tlv:null})}));const d=u.map((t=>({pubkey:t,isWritable:1,isSigner:0})));return{inputTokenDataWithContext:h,remainingAccountMetas:d,packedOutputTokenData:c}}const i=Buffer.from("pool"),o=Buffer.from("cpi_authority");var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function a(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 h={exports:{}},l="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},c=[],d=[],f="undefined"!=typeof Uint8Array?Uint8Array:Array,p=0;function m(){p=1;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)c[e]=t[e],d[t.charCodeAt(e)]=e;d["-".charCodeAt(0)]=62,d["_".charCodeAt(0)]=63}function g(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(c[(i=n)>>18&63]+c[i>>12&63]+c[i>>6&63]+c[63&i]);return o.join("")}function y(t){var e;p||m();for(var r=t.length,n=r%3,i="",o=[],s=16383,u=0,a=r-n;u<a;u+=s)o.push(g(t,u,u+s>a?a:u+s));return 1===n?(e=t[r-1],i+=c[e>>2],i+=c[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=c[e>>10],i+=c[e>>4&63],i+=c[e<<2&63],i+="="),o.push(i),o.join("")}function w(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,d=r?-1:1,f=t[e+c];for(c+=d,o=f&(1<<-l)-1,f>>=-l,l+=u;l>0;o=256*o+t[e+c],c+=d,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+t[e+c],c+=d,l-=8);if(0===o)o=1-h;else{if(o===a)return s?NaN:Infinity*(f?-1:1);s+=Math.pow(2,n),o-=h}return(f?-1:1)*s*Math.pow(2,o-n)}function v(t,e,r,n,i,o){var s,u,a,h=8*o-i-1,l=(1<<h)-1,c=l>>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=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?d/a:d*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+f]=255&u,f+=p,u/=256,i-=8);for(s=s<<i|u,h+=i;h>0;t[r+f]=255&s,f+=p,s/=256,h-=8);t[r+f-p]|=128*m}var b={}.toString,M=Array.isArray||function(t){return"[object Array]"==b.call(t)};S.TYPED_ARRAY_SUPPORT=void 0!==l.TYPED_ARRAY_SUPPORT?l.TYPED_ARRAY_SUPPORT:1;var P=A();function A(){return S.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function k(t,e){if(A()<e)throw new RangeError("Invalid typed array length");return S.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=S.prototype:(null===t&&(t=new S(e)),t.length=e),t}function S(t,e,r){if(!(S.TYPED_ARRAY_SUPPORT||this instanceof S))return new S(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 E(this,t)}return T(this,t,e,r)}function T(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),S.TYPED_ARRAY_SUPPORT?(t=e).__proto__=S.prototype:t=I(t,e),t}(t,e,r,n):"string"==typeof e?function(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!S.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|B(e,r),i=(t=k(t,n)).write(e,r);return i!==n&&(t=t.slice(0,i)),t}(t,e,r):function(t,e){if(C(e)){var r=0|x(e.length);return 0===(t=k(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?k(t,0):I(t,e);if("Buffer"===e.type&&M(e.data))return I(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function _(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 E(t,e){if(_(e),t=k(t,e<0?0:0|x(e)),!S.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function I(t,e){var r=e.length<0?0:0|x(e.length);t=k(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function x(t){if(t>=A())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+A().toString(16)+" bytes");return 0|t}function C(t){return!(null==t||!t._isBuffer)}function B(t,e){if(C(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 it(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return ot(t).length;default:if(n)return it(t).length;e=(""+e).toLowerCase(),n=1}}function L(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 G(this,e,r);case"utf8":case"utf-8":return V(this,e,r);case"ascii":return z(this,e,r);case"latin1":case"binary":return F(this,e,r);case"base64":return j(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Q(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=1}}function R(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function O(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=S.from(e,n)),C(e))return 0===e.length?-1:U(t,e,r,n,i);if("number"==typeof e)return e&=255,S.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):U(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function U(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,d=0;d<a;d++)if(h(t,o+d)!==h(e,d)){c=0;break}if(c)return o}return-1}function D(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 N(t,e,r,n){return st(it(e,t.length-r),t,r,n)}function K(t,e,r,n){return st(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function W(t,e,r,n){return K(t,e,r,n)}function Y(t,e,r,n){return st(ot(e),t,r,n)}function q(t,e,r,n){return st(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 j(t,e,r){return 0===e&&r===t.length?y(t):y(t.slice(e,r))}function V(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<=Z)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Z));return r}(n)}S.poolSize=8192,S._augment=function(t){return t.__proto__=S.prototype,t},S.from=function(t,e,r){return T(null,t,e,r)},S.TYPED_ARRAY_SUPPORT&&(S.prototype.__proto__=Uint8Array.prototype,S.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&S[Symbol.species]),S.alloc=function(t,e,r){return function(t,e,r,n){return _(e),e<=0?k(t,e):void 0!==r?"string"==typeof n?k(t,e).fill(r,n):k(t,e).fill(r):k(t,e)}(null,t,e,r)},S.allocUnsafe=function(t){return E(null,t)},S.allocUnsafeSlow=function(t){return E(null,t)},S.isBuffer=ut,S.compare=function(t,e){if(!C(t)||!C(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},S.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}},S.concat=function(t,e){if(!M(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return S.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=S.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var o=t[r];if(!C(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},S.byteLength=B,S.prototype._isBuffer=1,S.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)R(this,e,e+1);return this},S.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)R(this,e,e+3),R(this,e+1,e+2);return this},S.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)R(this,e,e+7),R(this,e+1,e+6),R(this,e+2,e+5),R(this,e+3,e+4);return this},S.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?V(this,0,t):L.apply(this,arguments)},S.prototype.equals=function(t){if(!C(t))throw new TypeError("Argument must be a Buffer");return this===t?1:0===S.compare(this,t)},S.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+">"},S.prototype.compare=function(t,e,r,n,i){if(!C(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},S.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},S.prototype.indexOf=function(t,e,r){return O(this,t,e,r,1)},S.prototype.lastIndexOf=function(t,e,r){return O(this,t,e,r,0)},S.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 D(this,t,e,r);case"utf8":case"utf-8":return N(this,t,e,r);case"ascii":return K(this,t,e,r);case"latin1":case"binary":return W(this,t,e,r);case"base64":return Y(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return q(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=1}},S.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Z=4096;function z(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 F(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 G(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 Q(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 $(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 H(t,e,r,n,i,o){if(!C(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 J(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 X(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 tt(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||tt(t,0,r,4),v(t,e,r,n,23,4),r+4}function rt(t,e,r,n,i){return i||tt(t,0,r,8),v(t,e,r,n,52,8),r+8}S.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),S.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=S.prototype;else{var i=e-t;r=new S(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+t]}return r},S.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||$(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},S.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||$(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},S.prototype.readUInt8=function(t,e){return e||$(t,1,this.length),this[t]},S.prototype.readUInt16LE=function(t,e){return e||$(t,2,this.length),this[t]|this[t+1]<<8},S.prototype.readUInt16BE=function(t,e){return e||$(t,2,this.length),this[t]<<8|this[t+1]},S.prototype.readUInt32LE=function(t,e){return e||$(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},S.prototype.readUInt32BE=function(t,e){return e||$(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},S.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||$(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},S.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||$(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},S.prototype.readInt8=function(t,e){return e||$(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},S.prototype.readInt16LE=function(t,e){e||$(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},S.prototype.readInt16BE=function(t,e){e||$(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},S.prototype.readInt32LE=function(t,e){return e||$(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},S.prototype.readInt32BE=function(t,e){return e||$(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},S.prototype.readFloatLE=function(t,e){return e||$(t,4,this.length),w(this,t,1,23,4)},S.prototype.readFloatBE=function(t,e){return e||$(t,4,this.length),w(this,t,0,23,4)},S.prototype.readDoubleLE=function(t,e){return e||$(t,8,this.length),w(this,t,1,52,8)},S.prototype.readDoubleBE=function(t,e){return e||$(t,8,this.length),w(this,t,0,52,8)},S.prototype.writeUIntLE=function(t,e,r,n){t=+t,e|=0,r|=0,n||H(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},S.prototype.writeUIntBE=function(t,e,r,n){t=+t,e|=0,r|=0,n||H(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},S.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||H(this,t,e,1,255,0),S.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},S.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||H(this,t,e,2,65535,0),S.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):J(this,t,e,1),e+2},S.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||H(this,t,e,2,65535,0),S.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):J(this,t,e,0),e+2},S.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||H(this,t,e,4,4294967295,0),S.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):X(this,t,e,1),e+4},S.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||H(this,t,e,4,4294967295,0),S.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):X(this,t,e,0),e+4},S.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);H(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},S.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);H(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},S.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||H(this,t,e,1,127,-128),S.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},S.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||H(this,t,e,2,32767,-32768),S.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):J(this,t,e,1),e+2},S.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||H(this,t,e,2,32767,-32768),S.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):J(this,t,e,0),e+2},S.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||H(this,t,e,4,2147483647,-2147483648),S.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):X(this,t,e,1),e+4},S.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||H(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),S.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):X(this,t,e,0),e+4},S.prototype.writeFloatLE=function(t,e,r){return et(this,t,e,1,r)},S.prototype.writeFloatBE=function(t,e,r){return et(this,t,e,0,r)},S.prototype.writeDoubleLE=function(t,e,r){return rt(this,t,e,1,r)},S.prototype.writeDoubleBE=function(t,e,r){return rt(this,t,e,0,r)},S.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||!S.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},S.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&&!S.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=C(t)?t:it(new S(t,n).toString()),u=s.length;for(o=0;o<r-e;++o)this[o+e]=s[o%u]}return this};var nt=/[^+\/0-9A-Za-z-_]/g;function it(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 ot(t){return function(t){var e,r,n,i,o,s;p||m();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 f(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=d[t.charCodeAt(e)]<<18|d[t.charCodeAt(e+1)]<<12|d[t.charCodeAt(e+2)]<<6|d[t.charCodeAt(e+3)],s[a++]=i>>16&255,s[a++]=i>>8&255,s[a++]=255&i;return 2===o?(i=d[t.charCodeAt(e)]<<2|d[t.charCodeAt(e+1)]>>4,s[a++]=255&i):1===o&&(i=d[t.charCodeAt(e)]<<10|d[t.charCodeAt(e+1)]<<4|d[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(nt,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function st(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 ut(t){return null!=t&&(!!t._isBuffer||at(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&at(t.slice(0,0))}(t))}function at(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var ht=a(Object.freeze({__proto__:null,Buffer:S,INSPECT_MAX_BYTES:50,SlowBuffer:function(t){return+t!=t&&(t=0),S.alloc(+t)},isBuffer:ut,kMaxLength:P}));!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 h?h.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:ht.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 l(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){l(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")]=c}catch(t){i.prototype.inspect=c}else i.prototype.inspect=c;function c(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var d=["","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],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function m(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,d=Math.min(h,e.length-1),f=Math.max(0,h-t.length+1);f<=d;f++){var p=h-f|0;l+=(s=(i=0|t.words[p])*(o=0|e.words[f])+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?d[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=p[t];n="";var c=this.clone();for(c.negative=0;!c.isZero();){var m=c.modrn(l).toString(t);n=(c=c.idivn(l)).isZero()?m+n:d[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 g=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,d=l>>>13,f=0|s[1],p=8191&f,m=f>>>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],A=8191&P,k=P>>>13,S=0|s[5],T=8191&S,_=S>>>13,E=0|s[6],I=8191&E,x=E>>>13,C=0|s[7],B=8191&C,L=C>>>13,R=0|s[8],O=8191&R,U=R>>>13,D=0|s[9],N=8191&D,K=D>>>13,W=0|u[0],Y=8191&W,q=W>>>13,j=0|u[1],V=8191&j,Z=j>>>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<,dt=lt>>>13,ft=0|u[9],pt=8191&ft,mt=ft>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(h+(n=Math.imul(c,Y))|0)+((8191&(i=(i=Math.imul(c,q))+Math.imul(d,Y)|0))<<13)|0;h=((o=Math.imul(d,q))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,Y),i=(i=Math.imul(p,q))+Math.imul(m,Y)|0,o=Math.imul(m,q);var yt=(h+(n=n+Math.imul(c,V)|0)|0)+((8191&(i=(i=i+Math.imul(c,Z)|0)+Math.imul(d,V)|0))<<13)|0;h=((o=o+Math.imul(d,Z)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,Y),i=(i=Math.imul(y,q))+Math.imul(w,Y)|0,o=Math.imul(w,q),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(d,F)|0))<<13)|0;h=((o=o+Math.imul(d,G)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(b,Y),i=(i=Math.imul(b,q))+Math.imul(M,Y)|0,o=Math.imul(M,q),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(d,$)|0))<<13)|0;h=((o=o+Math.imul(d,H)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(A,Y),i=(i=Math.imul(A,q))+Math.imul(k,Y)|0,o=Math.imul(k,q),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(d,X)|0))<<13)|0;h=((o=o+Math.imul(d,tt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(T,Y),i=(i=Math.imul(T,q))+Math.imul(_,Y)|0,o=Math.imul(_,q),n=n+Math.imul(A,V)|0,i=(i=i+Math.imul(A,Z)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,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(d,rt)|0))<<13)|0;h=((o=o+Math.imul(d,nt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(I,Y),i=(i=Math.imul(I,q))+Math.imul(x,Y)|0,o=Math.imul(x,q),n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,Z)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,Z)|0,n=n+Math.imul(A,F)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(k,F)|0,o=o+Math.imul(k,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(d,ot)|0))<<13)|0;h=((o=o+Math.imul(d,st)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(B,Y),i=(i=Math.imul(B,q))+Math.imul(L,Y)|0,o=Math.imul(L,q),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(T,F)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(_,F)|0,o=o+Math.imul(_,G)|0,n=n+Math.imul(A,$)|0,i=(i=i+Math.imul(A,H)|0)+Math.imul(k,$)|0,o=o+Math.imul(k,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 At=(h+(n=n+Math.imul(c,at)|0)|0)+((8191&(i=(i=i+Math.imul(c,ht)|0)+Math.imul(d,at)|0))<<13)|0;h=((o=o+Math.imul(d,ht)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(O,Y),i=(i=Math.imul(O,q))+Math.imul(U,Y)|0,o=Math.imul(U,q),n=n+Math.imul(B,V)|0,i=(i=i+Math.imul(B,Z)|0)+Math.imul(L,V)|0,o=o+Math.imul(L,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(T,$)|0,i=(i=i+Math.imul(T,H)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,H)|0,n=n+Math.imul(A,X)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,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 kt=(h+(n=n+Math.imul(c,ct)|0)|0)+((8191&(i=(i=i+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;h=((o=o+Math.imul(d,dt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(N,Y),i=(i=Math.imul(N,q))+Math.imul(K,Y)|0,o=Math.imul(K,q),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(B,F)|0,i=(i=i+Math.imul(B,G)|0)+Math.imul(L,F)|0,o=o+Math.imul(L,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(T,X)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(k,rt)|0,o=o+Math.imul(k,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,dt)|0)+Math.imul(m,ct)|0,o=o+Math.imul(m,dt)|0;var St=(h+(n=n+Math.imul(c,pt)|0)|0)+((8191&(i=(i=i+Math.imul(c,mt)|0)+Math.imul(d,pt)|0))<<13)|0;h=((o=o+Math.imul(d,mt)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(N,V),i=(i=Math.imul(N,Z))+Math.imul(K,V)|0,o=Math.imul(K,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(B,$)|0,i=(i=i+Math.imul(B,H)|0)+Math.imul(L,$)|0,o=o+Math.imul(L,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(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(A,ot)|0,i=(i=i+Math.imul(A,st)|0)+Math.imul(k,ot)|0,o=o+Math.imul(k,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,dt)|0)+Math.imul(w,ct)|0,o=o+Math.imul(w,dt)|0;var Tt=(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)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,F),i=(i=Math.imul(N,G))+Math.imul(K,F)|0,o=Math.imul(K,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(B,X)|0,i=(i=i+Math.imul(B,tt)|0)+Math.imul(L,X)|0,o=o+Math.imul(L,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(T,ot)|0,i=(i=i+Math.imul(T,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(A,at)|0,i=(i=i+Math.imul(A,ht)|0)+Math.imul(k,at)|0,o=o+Math.imul(k,ht)|0,n=n+Math.imul(b,ct)|0,i=(i=i+Math.imul(b,dt)|0)+Math.imul(M,ct)|0,o=o+Math.imul(M,dt)|0;var _t=(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)+(_t>>>26)|0,_t&=67108863,n=Math.imul(N,$),i=(i=Math.imul(N,H))+Math.imul(K,$)|0,o=Math.imul(K,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(B,rt)|0,i=(i=i+Math.imul(B,nt)|0)+Math.imul(L,rt)|0,o=o+Math.imul(L,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(T,at)|0,i=(i=i+Math.imul(T,ht)|0)+Math.imul(_,at)|0,o=o+Math.imul(_,ht)|0,n=n+Math.imul(A,ct)|0,i=(i=i+Math.imul(A,dt)|0)+Math.imul(k,ct)|0,o=o+Math.imul(k,dt)|0;var Et=(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)+(Et>>>26)|0,Et&=67108863,n=Math.imul(N,X),i=(i=Math.imul(N,tt))+Math.imul(K,X)|0,o=Math.imul(K,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(B,ot)|0,i=(i=i+Math.imul(B,st)|0)+Math.imul(L,ot)|0,o=o+Math.imul(L,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(T,ct)|0,i=(i=i+Math.imul(T,dt)|0)+Math.imul(_,ct)|0,o=o+Math.imul(_,dt)|0;var It=(h+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,mt)|0)+Math.imul(k,pt)|0))<<13)|0;h=((o=o+Math.imul(k,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(K,rt)|0,o=Math.imul(K,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(B,at)|0,i=(i=i+Math.imul(B,ht)|0)+Math.imul(L,at)|0,o=o+Math.imul(L,ht)|0,n=n+Math.imul(I,ct)|0,i=(i=i+Math.imul(I,dt)|0)+Math.imul(x,ct)|0,o=o+Math.imul(x,dt)|0;var xt=(h+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,mt)|0)+Math.imul(_,pt)|0))<<13)|0;h=((o=o+Math.imul(_,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(K,ot)|0,o=Math.imul(K,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(B,ct)|0,i=(i=i+Math.imul(B,dt)|0)+Math.imul(L,ct)|0,o=o+Math.imul(L,dt)|0;var Ct=(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)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,at),i=(i=Math.imul(N,ht))+Math.imul(K,at)|0,o=Math.imul(K,ht),n=n+Math.imul(O,ct)|0,i=(i=i+Math.imul(O,dt)|0)+Math.imul(U,ct)|0,o=o+Math.imul(U,dt)|0;var Bt=(h+(n=n+Math.imul(B,pt)|0)|0)+((8191&(i=(i=i+Math.imul(B,mt)|0)+Math.imul(L,pt)|0))<<13)|0;h=((o=o+Math.imul(L,mt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,n=Math.imul(N,ct),i=(i=Math.imul(N,dt))+Math.imul(K,ct)|0,o=Math.imul(K,dt);var Lt=(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)+(Lt>>>26)|0,Lt&=67108863;var Rt=(h+(n=Math.imul(N,pt))|0)+((8191&(i=(i=Math.imul(N,mt))+Math.imul(K,pt)|0))<<13)|0;return h=((o=Math.imul(K,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]=At,a[8]=kt,a[9]=St,a[10]=Tt,a[11]=_t,a[12]=Et,a[13]=It,a[14]=xt,a[15]=Ct,a[16]=Bt,a[17]=Lt,a[18]=Rt,0!==h&&(a[19]=h,r.length++),r};function y(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]),d=67108863&c;u=67108863&(d=d+u|0),i+=(s=(s=s+(c/67108864|0)|0)+(d>>>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 w(t,e,r){return y(t,e,r)}Math.imul||(g=m),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?g(this,t,e):r<63?m(this,t,e):r<1024?y(this,t,e):w(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),w(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 d=67108864*(0|n.words[o.length+c])+(0|n.words[o.length+c-1]);for(d=Math.min(d/s|0,67108863),n._ishlnsubmul(o,d,c);0!==n.negative;)d--,n.negative=0,n._ishlnsubmul(o,1,c),n.isZero()||(n.negative^=1);u&&(u.words[c]=d)}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 d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >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,d=1;0==(n.words[0]&d)&&c<26;++c,d<<=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 S(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 v={k256:null,p224:null,p192:null,p25519:null};function b(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 M(){b.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P(){b.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function A(){b.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function k(){b.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function T(t){S.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)}b.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},b.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},b.prototype.split=function(t,e){t.iushrn(this.n,0,e)},b.prototype.imulK=function(t){return t.imul(this.k)},n(M,b),M.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},M.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(P,b),n(A,b),n(k,b),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(v[t])return v[t];var e;if("k256"===t)e=new M;else if("p224"===t)e=new P;else if("p192"===t)e=new A;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new k}return v[t]=e,e},S.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},S.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")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(l(t,t.umod(this.m)._forceRed(this)),t)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.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)},S.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},S.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)},S.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},S.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},S.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.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),d=this.pow(t,o.addn(1).iushrn(1)),f=this.pow(t,o),p=s;0!==f.cmp(u);){for(var m=f,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));d=d.redMul(y),c=y.redSqr(),f=f.redMul(c),p=g}return d},S.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},S.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},S.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},S.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new T(t)},n(T,S),T.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},T.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},T.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)},T.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)},T.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(0,s);var lt=h.exports,ct=u(lt),dt={},ft={};class pt{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 mt(t,e){return e.property?t+"["+e.property+"]":t}ft.Layout=pt,ft.nameWithProperty=mt,ft.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 pt))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 gt extends pt{isCount(){throw new Error("ExternalLayout is abstract")}}class yt extends gt{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 wt extends gt{constructor(t,e,r){if(!(t instanceof pt))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 vt||this.layout instanceof bt}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 vt extends pt{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 bt extends pt{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 Mt extends pt{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 Pt extends pt{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 At=Math.pow(2,32);function kt(t){const e=Math.floor(t/At);return{hi32:e,lo32:t-e*At}}function St(t,e){return t*At+e}class Tt extends pt{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return St(t.readUInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=kt(t);return e.writeUInt32LE(n.lo32,r),e.writeUInt32LE(n.hi32,r+4),8}}class _t extends pt{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),St(t.readUInt32BE(e),t.readUInt32BE(e+4))}encode(t,e,r){void 0===r&&(r=0);const n=kt(t);return e.writeUInt32BE(n.hi32,r),e.writeUInt32BE(n.lo32,r+4),8}}class Et extends pt{constructor(t){super(8,t)}decode(t,e){void 0===e&&(e=0);const r=t.readUInt32LE(e);return St(t.readInt32LE(e+4),r)}encode(t,e,r){void 0===r&&(r=0);const n=kt(t);return e.writeUInt32LE(n.lo32,r),e.writeInt32LE(n.hi32,r+4),8}}class It extends pt{constructor(t){super(8,t)}decode(t,e){return void 0===e&&(e=0),St(t.readInt32BE(e),t.readUInt32BE(e+4))}encode(t,e,r){void 0===r&&(r=0);const n=kt(t);return e.writeInt32BE(n.hi32,r),e.writeUInt32BE(n.lo32,r+4),8}}class xt extends pt{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 Ct extends pt{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 Bt extends pt{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 Lt extends pt{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 Rt extends pt{constructor(t,e,r){if(!(t instanceof pt))throw new TypeError("elementLayout must be a Layout");if(!(e instanceof gt&&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 gt)&&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 gt&&(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 gt&&(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 gt&&this.count.encode(t.length,e,r),i}}class Ot extends pt{constructor(t,e,r){if(!Array.isArray(t)||!t.reduce(((t,e)=>t&&e instanceof pt),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 Ut{constructor(t){this.property=t}decode(){throw new Error("UnionDiscriminator is abstract")}encode(){throw new Error("UnionDiscriminator is abstract")}}class Dt extends Ut{constructor(t,e){if(!(t instanceof gt&&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 Nt extends pt{constructor(t,e,r){const n=t instanceof vt||t instanceof bt;if(n)t=new Dt(new wt(t));else if(t instanceof gt&&t.isCount())t=new Dt(t);else if(!(t instanceof Ut))throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(void 0===e&&(e=null),!(null===e||e instanceof pt))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 Kt(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 Kt extends pt{constructor(t,e,r,n){if(!(t instanceof Nt))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 pt))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 Wt(t){return 0>t&&(t+=4294967296),t}class Yt extends pt{constructor(t,e,r){if(!(t instanceof vt||t instanceof bt))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=Wt(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 qt(this,t,e);return this.fields.push(r),r}addBoolean(t){const e=new jt(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 qt{constructor(t,e,r){if(!(t instanceof Yt))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=Wt(this.valueMask<<this.start),this.property=r}decode(){return Wt(this.container._packedGetValue()&this.wordMask)>>>this.start}encode(t){if(!Number.isInteger(t)||t!==Wt(t&this.valueMask))throw new TypeError(mt("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const e=this.container._packedGetValue(),r=Wt(t<<this.start);this.container._packedSetValue(Wt(e&~this.wordMask)|r)}}class jt extends qt{constructor(t,e){super(t,1,e)}decode(t,e){return!!qt.prototype.decode.call(this,t,e)}encode(t){return"boolean"==typeof t&&(t=+t),qt.prototype.encode.call(this,t)}}class Vt extends pt{constructor(t,e){if(!(t instanceof gt&&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 gt||(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 gt&&(n=t.length),!Buffer.isBuffer(t)||n!==t.length)throw new TypeError(mt("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 gt&&this.length.encode(n,e,r),n}}class Zt extends pt{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 zt extends pt{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 Ft extends pt{constructor(t,e){super(0,e),this.value=t}decode(t,e,r){return this.value}encode(t,e,r){return 0}}ft.ExternalLayout=gt,ft.GreedyCount=yt,ft.OffsetLayout=wt,ft.UInt=vt,ft.UIntBE=bt,ft.Int=Mt,ft.IntBE=Pt,ft.Float=xt,ft.FloatBE=Ct,ft.Double=Bt,ft.DoubleBE=Lt,ft.Sequence=Rt,ft.Structure=Ot,ft.UnionDiscriminator=Ut,ft.UnionLayoutDiscriminator=Dt,ft.Union=Nt,ft.VariantLayout=Kt,ft.BitStructure=Yt,ft.BitField=qt,ft.Boolean=jt,ft.Blob=Vt,ft.CString=Zt,ft.UTF8=zt,ft.Constant=Ft,ft.greedy=(t,e)=>new yt(t,e),ft.offset=(t,e,r)=>new wt(t,e,r),ft.u8=t=>new vt(1,t),ft.u16=t=>new vt(2,t),ft.u24=t=>new vt(3,t),ft.u32=t=>new vt(4,t),ft.u40=t=>new vt(5,t),ft.u48=t=>new vt(6,t),ft.nu64=t=>new Tt(t),ft.u16be=t=>new bt(2,t),ft.u24be=t=>new bt(3,t),ft.u32be=t=>new bt(4,t),ft.u40be=t=>new bt(5,t),ft.u48be=t=>new bt(6,t),ft.nu64be=t=>new _t(t),ft.s8=t=>new Mt(1,t),ft.s16=t=>new Mt(2,t),ft.s24=t=>new Mt(3,t),ft.s32=t=>new Mt(4,t),ft.s40=t=>new Mt(5,t),ft.s48=t=>new Mt(6,t),ft.ns64=t=>new Et(t),ft.s16be=t=>new Pt(2,t),ft.s24be=t=>new Pt(3,t),ft.s32be=t=>new Pt(4,t),ft.s40be=t=>new Pt(5,t),ft.s48be=t=>new Pt(6,t),ft.ns64be=t=>new It(t),ft.f32=t=>new xt(t),ft.f32be=t=>new Ct(t),ft.f64=t=>new Bt(t),ft.f64be=t=>new Lt(t),ft.struct=(t,e,r)=>new Ot(t,e,r),ft.bits=(t,e,r)=>new Yt(t,e,r),ft.seq=(t,e,r)=>new Rt(t,e,r),ft.union=(t,e,r)=>new Nt(t,e,r),ft.unionLayoutDiscriminator=(t,e)=>new Dt(t,e),ft.blob=(t,e)=>new Vt(t,e),ft.cstr=t=>new Zt(t),ft.utf8=(t,e)=>new zt(t,e),ft.const=(t,e)=>new Ft(t,e),function(t){var r=s&&s.__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 n=ft,i=e,o=r(lt);var u=ft;Object.defineProperty(t,"u8",{enumerable:1,get:function(){return u.u8}}),Object.defineProperty(t,"i8",{enumerable:1,get:function(){return u.s8}}),Object.defineProperty(t,"u16",{enumerable:1,get:function(){return u.u16}}),Object.defineProperty(t,"i16",{enumerable:1,get:function(){return u.s16}}),Object.defineProperty(t,"u32",{enumerable:1,get:function(){return u.u32}}),Object.defineProperty(t,"i32",{enumerable:1,get:function(){return u.s32}}),Object.defineProperty(t,"f32",{enumerable:1,get:function(){return u.f32}}),Object.defineProperty(t,"f64",{enumerable:1,get:function(){return u.f64}}),Object.defineProperty(t,"struct",{enumerable:1,get:function(){return u.struct}});class a extends n.Layout{constructor(t,e,r){super(t,r),this.blob=(0,n.blob)(t),this.signed=e}decode(t,e=0){const r=new o.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 h(t){return new a(8,0,t)}t.u64=h,t.i64=function(t){return new a(8,1,t)},t.u128=function(t){return new a(16,0,t)},t.i128=function(t){return new a(16,1,t)},t.u256=function(t){return new a(32,0,t)},t.i256=function(t){return new a(32,1,t)};class l extends n.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 l((0,n.blob)(32),(t=>new i.PublicKey(t)),(t=>t.toBuffer()),t)};class c extends n.Layout{constructor(t,e){super(-1,e),this.layout=t,this.discriminator=(0,n.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 d(t){if(0===t)return 0;if(1===t)return 1;throw new Error("Invalid bool: "+t)}function f(t){return t?1:0}function p(t){const e=(0,n.u32)("length"),r=(0,n.struct)([e,(0,n.blob)((0,n.offset)(e,-e.span),"data")]);return new l(r,(({data:t})=>t),(t=>({data:t})),t)}t.option=function(t,e){return new c(t,e)},t.bool=function(t){return new l((0,n.u8)(),d,f,t)},t.vec=function(t,e){const r=(0,n.u32)("length"),i=(0,n.struct)([r,(0,n.seq)(t,(0,n.offset)(r,-r.span),"values")]);return new l(i,(({values:t})=>t),(t=>({values:t})),e)},t.tagged=function(t,e,r){const i=(0,n.struct)([h("tag"),e.replicate("data")]);return new l(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})),r)},t.vecU8=p,t.str=function(t){return new l(p(),(t=>t.toString("utf-8")),(t=>Buffer.from(t,"utf-8")),t)},t.rustEnum=function(t,e,r){const i=(0,n.union)(null!=r?r:(0,n.u8)(),e);return t.forEach(((t,e)=>i.addVariant(e,t,t.property))),i},t.array=function(t,e,r){const i=(0,n.struct)([(0,n.seq)(t,e,"values")]);return new l(i,(({values:t})=>t),(t=>({values:t})),r)};class m extends n.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,r){const i=(0,n.u32)("length"),o=(0,n.struct)([i,(0,n.seq)(new m(t,e),(0,n.offset)(i,-i.span),"values")]);return new l(o,(({values:t})=>new Map(t)),(t=>({values:Array.from(t.entries())})),r)}}(dt);const Gt=S.from([23,169,27,122,147,169,209,152]),Qt=dt.struct([dt.array(dt.u8(),32,"a"),dt.array(dt.u8(),64,"b"),dt.array(dt.u8(),32,"c")]),$t=dt.struct([dt.publicKey("owner"),dt.u64("amount"),dt.option(dt.u64(),"lamports"),dt.u8("merkleTreeIndex"),dt.option(dt.vecU8(),"tlv")]),Ht=dt.struct([dt.u8("queueId"),dt.u16("index")]),Jt=dt.struct([dt.u64("amount"),dt.option(dt.u8(),"delegateIndex"),dt.struct([dt.u8("merkleTreePubkeyIndex"),dt.u8("nullifierQueuePubkeyIndex"),dt.u32("leafIndex"),dt.option(Ht,"QueueIndex")],"merkleContext"),dt.u16("rootIndex"),dt.option(dt.u64(),"lamports"),dt.option(dt.vecU8(),"tlv")]),Xt=dt.struct([dt.publicKey("owner"),dt.option(dt.u8(),"delegateChangeAccountIndex")]),te=dt.struct([dt.bool("setContext"),dt.bool("firstSetContext"),dt.u8("cpiContextAccountIndex")]),ee=dt.struct([dt.option(Qt,"proof"),dt.publicKey("mint"),dt.option(Xt,"delegatedTransfer"),dt.vec(Jt,"inputTokenDataWithContext"),dt.vec($t,"outputCompressedAccounts"),dt.bool("isCompress"),dt.option(dt.u64(),"compressOrDecompressAmount"),dt.option(te,"cpiContext"),dt.option(dt.u8(),"lamportsChangeAccountMerkleTreeIndex")]),re=dt.struct([dt.vec(dt.publicKey(),"recipients"),dt.vec(dt.u64(),"amounts"),dt.option(dt.u64(),"lamports")]),ne=dt.struct([dt.publicKey("owner"),dt.option(dt.u64(),"remainingAmount"),dt.option(te,"cpiContext")]),ie=S.from([241,34,48,186,37,179,123,192]),oe=S.from([163,52,200,231,140,3,69,186]),se=S.from([112,230,105,101,145,202,157,97]);function ue(t){const e=S.alloc(1e3),r=ee.encode(t,e),n=S.alloc(4);return n.writeUInt32LE(r,0),S.concat([oe,n,e.slice(0,r)])}dt.struct([dt.publicKey("owner"),dt.option(dt.u64(),"remainingAmount"),dt.option(dt.struct([],"CompressedCpiContext"),"cpiContext")],"compressSplTokenAccountArgs");const ae=t=>{const e=pe.programId,{feePayer:r,authority:n,cpiAuthorityPda:i,lightSystemProgram:o,registeredProgramPda:s,noopProgram:u,accountCompressionAuthority:a,accountCompressionProgram:h,selfProgram:l,tokenPoolPda:c,compressOrDecompressTokenAccount:d,tokenProgram:f,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:null!=c?c:e,isSigner:0,isWritable:1},{pubkey:null!=d?d:e,isSigner:0,isWritable:1},{pubkey:null!=f?f:e,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:0}]},he=e=>e.reduce(((t,e)=>t.add(e.parsed.amount)),t.bn(0)),le=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")}))},ce=t=>({mint:t[0].parsed.mint,currentOwner:t[0].parsed.owner,delegate:t[0].parsed.delegate});function de(e,r,n){n=t.bn(n);const i=he(e),o=t.sumUpLamports(e.map((t=>t.compressedAccount))),s=i.sub(n);return t.validateSufficientBalance(s),s.eq(t.bn(0))&&o.eq(t.bn(0))?[{owner:r,amount:n,lamports:o,tlv:null}]:(t.validateSameOwner(e.map((t=>t.compressedAccount))),le(e),[{owner:e[0].parsed.owner,amount:s,lamports:o,tlv:null},{owner:r,amount:n,lamports:t.bn(0),tlv:null}])}function fe(e,r){r=t.bn(r);const n=t.sumUpLamports(e.map((t=>t.compressedAccount))),i=he(e).sub(r);return t.validateSufficientBalance(i),i.eq(t.bn(0))&&n.eq(t.bn(0))?[]:(t.validateSameOwner(e.map((t=>t.compressedAccount))),le(e),[{owner:e[0].parsed.owner,amount:i,lamports:n,tlv:null}])}class pe{constructor(){}static setProgramId(t){this.programId="string"==typeof t?new e.PublicKey(t):t}static deriveTokenPoolPda(t){const r=[i,t.toBuffer()],[n,o]=e.PublicKey.findProgramAddressSync(r,this.programId);return n}static get deriveCpiAuthorityPda(){const[t,r]=e.PublicKey.findProgramAddressSync([o],this.programId);return t}static async createMint(t){const{mint:n,authority:i,feePayer:o,rentExemptBalance:s,tokenProgramId:u,freezeAuthority:a,mintSize:h}=t,l=null!=u?u:r.TOKEN_PROGRAM_ID;return[e.SystemProgram.createAccount({fromPubkey:o,lamports:s,newAccountPubkey:n,programId:l,space:null!=h?h:r.MINT_SIZE}),r.createInitializeMint2Instruction(n,t.decimals,i,a,l),await this.createTokenPool({feePayer:o,mint:n,tokenProgramId:l})]}static async createTokenPool(t){const{mint:n,feePayer:i,tokenProgramId:o}=t,s=null!=o?o:r.TOKEN_PROGRAM_ID,u=(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:n,feePayer:i,tokenPoolPda:this.deriveTokenPoolPda(n),tokenProgram:s,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:e.SystemProgram.programId});return new e.TransactionInstruction({programId:this.programId,keys:u,data:Gt})}static async mintTo(n){const i=t.defaultStaticAccountsStruct(),{mint:o,feePayer:s,authority:u,merkleTree:a,toPubkey:h,amount:l,tokenProgramId:c}=n,d=null!=c?c:r.TOKEN_PROGRAM_ID,f=this.deriveTokenPoolPda(o),p=t.toArray(l).map((e=>t.bn(e))),m=t.toArray(h);if(p.length!==m.length)throw new Error("Amount and toPubkey arrays must have the same length");const g=(t=>{const e=pe.programId,{feePayer:r,authority:n,cpiAuthorityPda:i,mint:o,tokenPoolPda:s,tokenProgram:u,lightSystemProgram:a,registeredProgramPda:h,noopProgram:l,accountCompressionAuthority:c,accountCompressionProgram:d,merkleTree:f,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:d,isSigner:0,isWritable:0},{pubkey:f,isSigner:0,isWritable:1},{pubkey:p,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0},{pubkey:null!=g?g:e,isSigner:0,isWritable:1}]})({mint:o,feePayer:s,authority:u,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:d,tokenPoolPda:f,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:i.registeredProgramPda,noopProgram:i.noopProgram,accountCompressionAuthority:i.accountCompressionAuthority,accountCompressionProgram:i.accountCompressionProgram,merkleTree:null!=a?a:t.defaultTestStateTreeAccounts().merkleTree,selfProgram:this.programId,systemProgram:e.SystemProgram.programId,solPoolPda:null}),y=function(t,e){const r=S.alloc(1e3),n=re.encode({recipients:t,amounts:e,lamports:null},r);return S.concat([ie,r.slice(0,n)])}(m,p);return new e.TransactionInstruction({programId:this.programId,keys:g,data:y})}static async approveAndMintTo(t){const{mint:e,feePayer:n,authorityTokenAccount:i,authority:o,merkleTree:s,toPubkey:u,tokenProgramId:a}=t,h=BigInt(t.amount.toString());return[r.createMintToInstruction(e,i,o,h,[],a),await this.compress({payer:n,owner:o,source:i,toAddress:u,mint:e,amount:t.amount,outputStateTree:s,tokenProgramId:a})]}static async transfer(r){const{payer:i,inputCompressedTokenAccounts:o,recentInputStateRootIndices:s,recentValidityProof:u,amount:a,outputStateTrees:h,toAddress:l}=r,c=de(o,l,a),{inputTokenDataWithContext:d,packedOutputTokenData:f,remainingAccountMetas:p}=n({inputCompressedTokenAccounts:o,outputStateTrees:h,rootIndices:s,tokenTransferOutputs:c}),{mint:m,currentOwner:g}=ce(o),y=ue({proof:u,mint:m,delegatedTransfer:null,inputTokenDataWithContext:d,outputCompressedAccounts:f,compressOrDecompressAmount:null,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),{accountCompressionAuthority:w,noopProgram:v,registeredProgramPda:b,accountCompressionProgram:M}=t.defaultStaticAccountsStruct(),P=ae({feePayer:i,authority:g,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:b,noopProgram:v,accountCompressionAuthority:w,accountCompressionProgram:M,selfProgram:this.programId,tokenPoolPda:void 0,compressOrDecompressTokenAccount:void 0,tokenProgram:void 0,systemProgram:e.SystemProgram.programId});return P.push(...p),new e.TransactionInstruction({programId:this.programId,keys:P,data:y})}static async createTokenProgramLookupTable(n){const{authority:i,mints:o,recentSlot:s,payer:u,remainingAccounts:a}=n,[h,l]=e.AddressLookupTableProgram.createLookupTable({authority:i,payer:i,recentSlot:s});let c=[];return o&&(c=[...o,...o.map((t=>this.deriveTokenPoolPda(t)))]),{instructions:[h,e.AddressLookupTableProgram.extendLookupTable({payer:u,authority:i,lookupTable:l,addresses:[this.deriveCpiAuthorityPda,t.LightSystemProgram.programId,t.defaultStaticAccountsStruct().registeredProgramPda,t.defaultStaticAccountsStruct().noopProgram,t.defaultStaticAccountsStruct().accountCompressionAuthority,t.defaultStaticAccountsStruct().accountCompressionProgram,t.defaultTestStateTreeAccounts().merkleTree,t.defaultTestStateTreeAccounts().nullifierQueue,t.defaultTestStateTreeAccounts().addressTree,t.defaultTestStateTreeAccounts().addressQueue,this.programId,r.TOKEN_PROGRAM_ID,r.TOKEN_2022_PROGRAM_ID,i,...c,...null!=a?a:[]]})],address:l}}static async compress(i){const{payer:o,owner:s,source:u,toAddress:a,mint:h,outputStateTree:l,tokenProgramId:c}=i;if(Array.isArray(i.amount)!==Array.isArray(i.toAddress))throw new Error("Both amount and toAddress must be arrays or both must be single values");let d;if(Array.isArray(i.amount)&&Array.isArray(i.toAddress)){if(i.amount.length!==i.toAddress.length)throw new Error("Amount and toAddress arrays must have the same length");d=i.amount.map(((e,r)=>{const n=t.bn(e);return{owner:i.toAddress[r],amount:n,lamports:t.bn(0),tlv:null}}))}else d=[{owner:a,amount:t.bn(i.amount),lamports:t.bn(0),tlv:null}];const{inputTokenDataWithContext:f,packedOutputTokenData:p,remainingAccountMetas:m}=n({inputCompressedTokenAccounts:[],outputStateTrees:l,rootIndices:[],tokenTransferOutputs:d}),g=ue({proof:null,mint:h,delegatedTransfer:null,inputTokenDataWithContext:f,outputCompressedAccounts:p,compressOrDecompressAmount:Array.isArray(i.amount)?i.amount.map((t=>new ct(t))).reduce(((t,e)=>t.add(e)),new ct(0)):new ct(i.amount),isCompress:1,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),y=null!=c?c:r.TOKEN_PROGRAM_ID,w=ae(Object.assign(Object.assign({},t.defaultStaticAccountsStruct()),{feePayer:o,authority:s,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,selfProgram:this.programId,systemProgram:e.SystemProgram.programId,tokenPoolPda:this.deriveTokenPoolPda(h),compressOrDecompressTokenAccount:u,tokenProgram:y}));return w.push(...m),new e.TransactionInstruction({programId:this.programId,keys:w,data:g})}static async decompress(i){const{payer:o,inputCompressedTokenAccounts:s,toAddress:u,outputStateTree:a,recentValidityProof:h,recentInputStateRootIndices:l,tokenProgramId:c}=i,d=t.bn(i.amount),f=fe(s,d),{inputTokenDataWithContext:p,packedOutputTokenData:m,remainingAccountMetas:g}=n({inputCompressedTokenAccounts:s,outputStateTrees:a,rootIndices:l,tokenTransferOutputs:f}),{mint:y,currentOwner:w}=ce(s),v=ue({proof:h,mint:y,delegatedTransfer:null,inputTokenDataWithContext:p,outputCompressedAccounts:m,compressOrDecompressAmount:d,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),b=null!=c?c:r.TOKEN_PROGRAM_ID,{accountCompressionAuthority:M,noopProgram:P,registeredProgramPda:A,accountCompressionProgram:k}=t.defaultStaticAccountsStruct(),S=ae({feePayer:o,authority:w,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:A,noopProgram:P,accountCompressionAuthority:M,accountCompressionProgram:k,selfProgram:this.programId,tokenPoolPda:this.deriveTokenPoolPda(y),compressOrDecompressTokenAccount:u,tokenProgram:b,systemProgram:e.SystemProgram.programId});return S.push(...g),new e.TransactionInstruction({programId:this.programId,keys:S,data:v})}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 ct(0)),outputStateTrees:i,recentInputStateRootIndices:s,recentValidityProof:o})]}static async compressSplTokenAccount(n){const{feePayer:i,authority:o,tokenAccount:s,mint:u,remainingAmount:a,outputStateTree:h,tokenProgramId:l}=n,c=null!=l?l:r.TOKEN_PROGRAM_ID,d=[{pubkey:h,isSigner:0,isWritable:1}],f=function(t,e){const r=S.alloc(1e3),n=ne.encode({owner:t,remainingAmount:e,cpiContext:null},r);return S.concat([se,r.slice(0,n)])}(o,null!=a?a:null),{accountCompressionAuthority:p,noopProgram:m,registeredProgramPda:g,accountCompressionProgram:y}=t.defaultStaticAccountsStruct(),w=ae({feePayer:i,authority:o,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:g,noopProgram:m,accountCompressionAuthority:p,accountCompressionProgram:y,selfProgram:this.programId,tokenPoolPda:this.deriveTokenPoolPda(u),compressOrDecompressTokenAccount:s,tokenProgram:c,systemProgram:e.SystemProgram.programId});return w.push(...d),new e.TransactionInstruction({programId:this.programId,keys:w,data:f})}static async get_mint_program_id(t,e){var r;return null===(r=await e.getAccountInfo(t))||void 0===r?void 0:r.owner}}function me(e,r){let n=t.bn(0),i=t.bn(0);const o=[];e.sort(((t,e)=>e.parsed.amount.cmp(t.parsed.amount)));for(const s of e){if(n.gte(t.bn(r)))break;n=n.add(s.parsed.amount),i=i.add(s.compressedAccount.lamports),o.push(s)}if(n.lt(t.bn(r)))throw new Error(`Not enough balance for transfer. Required: ${r.toString()}, available: ${n.toString()}`);return[o,n,i.lt(t.bn(0))?i:null]}pe.programId=new e.PublicKey("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m"),exports.CPI_AUTHORITY_SEED=o,exports.CompressedTokenProgram=pe,exports.POOL_SEED=i,exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE=1461600,exports.approveAndMintTo=async function(n,i,o,s,u,a,h,l,c){c=c||await pe.get_mint_program_id(o,n);const d=await r.getOrCreateAssociatedTokenAccount(n,i,o,u.publicKey,void 0,void 0,l,c),f=await pe.approveAndMintTo({feePayer:i.publicKey,mint:o,authority:u.publicKey,authorityTokenAccount:d.address,amount:a,toPubkey:s,merkleTree:h,tokenProgramId:c}),{blockhash:p}=await n.getLatestBlockhash(),m=t.dedupeSigner(i,[u]),g=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),...f],i,p,m);return await t.sendAndConfirmTx(n,g,l)},exports.compress=async function(r,n,i,o,s,u,a,h,l,c){c=c||await pe.get_mint_program_id(i,r);const d=await pe.compress({payer:n.publicKey,owner:s.publicKey,source:u,toAddress:a,amount:o,mint:i,outputStateTree:h,tokenProgramId:c}),f=await r.getLatestBlockhash(),p=t.dedupeSigner(n,[s]),m=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),d],n,f.blockhash,p);return await t.sendAndConfirmTx(r,m,l,f)},exports.compressSplTokenAccount=async function(r,n,i,o,s,u,a,h,l){l=l||await pe.get_mint_program_id(i,r);const c=await pe.compressSplTokenAccount({feePayer:n.publicKey,authority:o.publicKey,tokenAccount:s,mint:i,remainingAmount:a,outputStateTree:u,tokenProgramId:l}),d=await r.getLatestBlockhash(),f=t.dedupeSigner(n,[o]),p=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),c],n,d.blockhash,f);return await t.sendAndConfirmTx(r,p,h,d)},exports.createDecompressOutputState=fe,exports.createMint=async function(n,i,o,s,u=e.Keypair.generate(),a,h=0){const l=await n.getMinimumBalanceForRentExemption(r.MINT_SIZE),c=h?r.TOKEN_2022_PROGRAM_ID:r.TOKEN_PROGRAM_ID,d=await pe.createMint({feePayer:i.publicKey,mint:u.publicKey,decimals:s,authority:o,freezeAuthority:null,rentExemptBalance:l,tokenProgramId:c}),{blockhash:f}=await n.getLatestBlockhash(),p=t.dedupeSigner(i,[u]),m=t.buildAndSignTx(d,i,f,p),g=await t.sendAndConfirmTx(n,m,a);return{mint:u.publicKey,transactionSignature:g}},exports.createTokenPool=async function(e,r,n,i,o){o=o||await pe.get_mint_program_id(n,e);const s=await pe.createTokenPool({feePayer:r.publicKey,mint:n,tokenProgramId:o}),{blockhash:u}=await e.getLatestBlockhash(),a=t.buildAndSignTx([s],r,u);return await t.sendAndConfirmTx(e,a,i)},exports.createTokenProgramLookupTable=async function(e,r,n,i,o){const s=await e.getSlot("finalized"),{instructions:u,address:a}=await pe.createTokenProgramLookupTable({payer:r.publicKey,authority:n.publicKey,mints:i,remainingAccounts:o,recentSlot:s}),h=t.dedupeSigner(r,[n]),l=await e.getLatestBlockhash(),c=t.buildAndSignTx([u[0]],r,l.blockhash,h),d=await t.sendAndConfirmTx(e,c,{commitment:"finalized"},l),f=await e.getLatestBlockhash(),p=t.buildAndSignTx([u[1]],r,f.blockhash,h);return{txIds:[d,await t.sendAndConfirmTx(e,p,{commitment:"finalized"},f)],address:a}},exports.createTransferOutputState=de,exports.decompress=async function(r,n,i,o,s,u,a,h,l){l=l||await pe.get_mint_program_id(i,r),o=t.bn(o);const c=await r.getCompressedTokenAccountsByOwner(s.publicKey,{mint:i}),[d]=me(c.items,o),f=await r.getValidityProof(d.map((e=>t.bn(e.compressedAccount.hash)))),p=await pe.decompress({payer:n.publicKey,inputCompressedTokenAccounts:d,toAddress:u,amount:o,outputStateTree:a,recentInputStateRootIndices:f.rootIndices,recentValidityProof:f.compressedProof,tokenProgramId:l}),{blockhash:m}=await r.getLatestBlockhash(),g=t.dedupeSigner(n,[s]),y=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),p],n,m,g);return await t.sendAndConfirmTx(r,y,h)},exports.mergeTokenAccounts=async function(r,n,i,o,s,u){const a=await r.getCompressedTokenAccountsByOwner(o.publicKey,{mint:i});if(0===a.items.length)throw new Error(`No compressed token accounts found for mint ${i.toBase58()}`);if(a.items.length>=6)throw new Error(`Too many compressed token accounts used for mint ${i.toBase58()}`);const h=[e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6})];for(let e=0;e<a.items.slice(0,6).length;e+=3){const u=a.items.slice(e,e+3),l=await r.getValidityProof(u.map((e=>t.bn(e.compressedAccount.hash)))),c=await pe.mergeTokenAccounts({payer:n.publicKey,owner:o.publicKey,mint:i,inputCompressedTokenAccounts:u,outputStateTree:s,recentValidityProof:l.compressedProof,recentInputStateRootIndices:l.rootIndices});h.push(...c)}const{blockhash:l}=await r.getLatestBlockhash(),c=t.dedupeSigner(n,[o]),d=t.buildAndSignTx(h,n,l,c);return await t.sendAndConfirmTx(r,d,u)},exports.mintTo=async function(r,n,i,o,s,u,a,h,l){l=l||await pe.get_mint_program_id(i,r);const c=t.dedupeSigner(n,[s]),d=await pe.mintTo({feePayer:n.publicKey,mint:i,authority:s.publicKey,amount:u,toPubkey:o,merkleTree:a,tokenProgramId:l}),{blockhash:f}=await r.getLatestBlockhash(),p=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),d],n,f,c);return await t.sendAndConfirmTx(r,p,h)},exports.packCompressedTokenAccounts=n,exports.parseTokenData=ce,exports.selectMinCompressedTokenAccountsForTransfer=me,exports.sumUpTokenAmount=he,exports.transfer=async function(r,n,i,o,s,u,a,h){o=t.bn(o);const l=await r.getCompressedTokenAccountsByOwner(s.publicKey,{mint:i}),[c]=me(l.items,o),d=await r.getValidityProof(c.map((e=>t.bn(e.compressedAccount.hash)))),f=await pe.transfer({payer:n.publicKey,inputCompressedTokenAccounts:c,toAddress:u,amount:o,recentInputStateRootIndices:d.rootIndices,recentValidityProof:d.compressedProof,outputStateTrees:a}),{blockhash:p}=await r.getLatestBlockhash(),m=t.dedupeSigner(n,[s]),g=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),f],n,p,m);return await t.sendAndConfirmTx(r,g,h)},exports.validateSameTokenOwner=le;
|
|
1
|
+
"use strict";var t=require("@lightprotocol/stateless.js"),e=require("@solana/web3.js"),r=require("@solana/spl-token"),n=require("@coral-xyz/borsh");function i(e){const{inputCompressedTokenAccounts:r,outputStateTrees:n,remainingAccounts:i=[],rootIndices:o,tokenTransferOutputs:s}=e,a=i.slice();let u=null;r.length>0&&r[0].parsed.delegate&&(u=t.getIndexOrAdd(a,r[0].parsed.delegate));const h=[];r.forEach(((e,r)=>{const n=t.getIndexOrAdd(a,e.compressedAccount.merkleTree),i=t.getIndexOrAdd(a,e.compressedAccount.nullifierQueue);h.push({amount:e.parsed.amount,delegateIndex:u,merkleContext:{merkleTreePubkeyIndex:n,nullifierQueuePubkeyIndex:i,leafIndex:e.compressedAccount.leafIndex,queueIndex:null},rootIndex:o[r],lamports:e.compressedAccount.lamports.eq(t.bn(0))?null:e.compressedAccount.lamports,tlv:null})}));const m=t.padOutputStateMerkleTrees(n,s.length,r.map((t=>t.compressedAccount))),l=[];m.forEach(((e,r)=>{var n;const i=t.getIndexOrAdd(a,e);l.push({owner:s[r].owner,amount:s[r].amount,lamports:(null===(n=s[r].lamports)||void 0===n?void 0:n.eq(t.bn(0)))?null:s[r].lamports,merkleTreeIndex:i,tlv:null})}));const c=a.map((t=>({pubkey:t,isWritable:1,isSigner:0})));return{inputTokenDataWithContext:h,remainingAccountMetas:c,packedOutputTokenData:l}}const o=Buffer.from("pool"),s=Buffer.from("cpi_authority"),a=Buffer.from([23,169,27,122,147,169,209,152]),u=Buffer.from([241,34,48,186,37,179,123,192]),h=Buffer.from([163,52,200,231,140,3,69,186]),m=Buffer.from([112,230,105,101,145,202,157,97]);var l="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function p(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 d={exports:{}},f="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},g=[],y=[],M="undefined"!=typeof Uint8Array?Uint8Array:Array,v=0;function w(){v=1;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0;e<64;++e)g[e]=t[e],y[t.charCodeAt(e)]=e;y["-".charCodeAt(0)]=62,y["_".charCodeAt(0)]=63}function b(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(g[(i=n)>>18&63]+g[i>>12&63]+g[i>>6&63]+g[63&i]);return o.join("")}function P(t){var e;v||w();for(var r=t.length,n=r%3,i="",o=[],s=16383,a=0,u=r-n;a<u;a+=s)o.push(b(t,a,a+s>u?u:a+s));return 1===n?(e=t[r-1],i+=g[e>>2],i+=g[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=g[e>>10],i+=g[e>>4&63],i+=g[e<<2&63],i+="="),o.push(i),o.join("")}function k(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,h=u>>1,m=-7,l=r?i-1:0,c=r?-1:1,p=t[e+l];for(l+=c,o=p&(1<<-m)-1,p>>=-m,m+=a;m>0;o=256*o+t[e+l],l+=c,m-=8);for(s=o&(1<<-m)-1,o>>=-m,m+=n;m>0;s=256*s+t[e+l],l+=c,m-=8);if(0===o)o=1-h;else{if(o===u)return s?NaN:Infinity*(p?-1:1);s+=Math.pow(2,n),o-=h}return(p?-1:1)*s*Math.pow(2,o-n)}function A(t,e,r,n,i,o){var s,a,u,h=8*o-i-1,m=(1<<h)-1,l=m>>1,c=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,f=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||Infinity===e?(a=isNaN(e)?1:0,s=m):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+l>=1?c/u:c*Math.pow(2,1-l))*u>=2&&(s++,u/=2),s+l>=m?(a=0,s=m):s+l>=1?(a=(e*u-1)*Math.pow(2,i),s+=l):(a=e*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,h+=i;h>0;t[r+p]=255&s,p+=d,s/=256,h-=8);t[r+p-d]|=128*f}var S={}.toString,T=Array.isArray||function(t){return"[object Array]"==S.call(t)};x.TYPED_ARRAY_SUPPORT=void 0!==f.TYPED_ARRAY_SUPPORT?f.TYPED_ARRAY_SUPPORT:1;var C=I();function I(){return x.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function _(t,e){if(I()<e)throw new RangeError("Invalid typed array length");return x.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=x.prototype:(null===t&&(t=new x(e)),t.length=e),t}function x(t,e,r){if(!(x.TYPED_ARRAY_SUPPORT||this instanceof x))return new x(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 O(this,t)}return E(this,t,e,r)}function E(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),x.TYPED_ARRAY_SUPPORT?(t=e).__proto__=x.prototype:t=D(t,e),t}(t,e,r,n):"string"==typeof e?function(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!x.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|U(e,r),i=(t=_(t,n)).write(e,r);return i!==n&&(t=t.slice(0,i)),t}(t,e,r):function(t,e){if(L(e)){var r=0|B(e.length);return 0===(t=_(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?_(t,0):D(t,e);if("Buffer"===e.type&&T(e.data))return D(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function R(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 O(t,e){if(R(e),t=_(t,e<0?0:0|B(e)),!x.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function D(t,e){var r=e.length<0?0:0|B(e.length);t=_(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function B(t){if(t>=I())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+I().toString(16)+" bytes");return 0|t}function L(t){return!(null==t||!t._isBuffer)}function U(t,e){if(L(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 ht(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return mt(t).length;default:if(n)return ht(t).length;e=(""+e).toLowerCase(),n=1}}function N(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 J(this,e,r);case"utf8":case"utf-8":return G(this,e,r);case"ascii":return $(this,e,r);case"latin1":case"binary":return X(this,e,r);case"base64":return V(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return tt(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=1}}function K(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function W(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=x.from(e,n)),L(e))return 0===e.length?-1:q(t,e,r,n,i);if("number"==typeof e)return e&=255,x.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):q(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function q(t,e,r,n,i){var o,s=1,a=t.length,u=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,a/=2,u/=2,r/=2}function h(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){var m=-1;for(o=r;o<a;o++)if(h(t,o)===h(e,-1===m?0:o-m)){if(-1===m&&(m=o),o-m+1===u)return m*s}else-1!==m&&(o-=o-m),m=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){for(var l=1,c=0;c<u;c++)if(h(t,o+c)!==h(e,c)){l=0;break}if(l)return o}return-1}function F(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 a=parseInt(e.substr(2*s,2),16);if(isNaN(a))return s;t[r+s]=a}return s}function Y(t,e,r,n){return lt(ht(e,t.length-r),t,r,n)}function z(t,e,r,n){return lt(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function Z(t,e,r,n){return z(t,e,r,n)}function H(t,e,r,n){return lt(mt(e),t,r,n)}function j(t,e,r,n){return lt(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 V(t,e,r){return 0===e&&r===t.length?P(t):P(t.slice(e,r))}function G(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var o,s,a,u,h=t[i],m=null,l=h>239?4:h>223?3:h>191?2:1;if(i+l<=r)switch(l){case 1:h<128&&(m=h);break;case 2:128==(192&(o=t[i+1]))&&(u=(31&h)<<6|63&o)>127&&(m=u);break;case 3:o=t[i+1],s=t[i+2],128==(192&o)&&128==(192&s)&&(u=(15&h)<<12|(63&o)<<6|63&s)>2047&&(u<55296||u>57343)&&(m=u);break;case 4:o=t[i+1],s=t[i+2],a=t[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(u=(15&h)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&u<1114112&&(m=u)}null===m?(m=65533,l=1):m>65535&&(m-=65536,n.push(m>>>10&1023|55296),m=56320|1023&m),n.push(m),i+=l}return function(t){var e=t.length;if(e<=Q)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=Q));return r}(n)}x.poolSize=8192,x._augment=function(t){return t.__proto__=x.prototype,t},x.from=function(t,e,r){return E(null,t,e,r)},x.TYPED_ARRAY_SUPPORT&&(x.prototype.__proto__=Uint8Array.prototype,x.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&x[Symbol.species]),x.alloc=function(t,e,r){return function(t,e,r,n){return R(e),e<=0?_(t,e):void 0!==r?"string"==typeof n?_(t,e).fill(r,n):_(t,e).fill(r):_(t,e)}(null,t,e,r)},x.allocUnsafe=function(t){return O(null,t)},x.allocUnsafeSlow=function(t){return O(null,t)},x.isBuffer=ct,x.compare=function(t,e){if(!L(t)||!L(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},x.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}},x.concat=function(t,e){if(!T(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return x.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=x.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var o=t[r];if(!L(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},x.byteLength=U,x.prototype._isBuffer=1,x.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)K(this,e,e+1);return this},x.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)K(this,e,e+3),K(this,e+1,e+2);return this},x.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)K(this,e,e+7),K(this,e+1,e+6),K(this,e+2,e+5),K(this,e+3,e+4);return this},x.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?G(this,0,t):N.apply(this,arguments)},x.prototype.equals=function(t){if(!L(t))throw new TypeError("Argument must be a Buffer");return this===t?1:0===x.compare(this,t)},x.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+">"},x.prototype.compare=function(t,e,r,n,i){if(!L(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),a=Math.min(o,s),u=this.slice(n,i),h=t.slice(e,r),m=0;m<a;++m)if(u[m]!==h[m]){o=u[m],s=h[m];break}return o<s?-1:s<o?1:0},x.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},x.prototype.indexOf=function(t,e,r){return W(this,t,e,r,1)},x.prototype.lastIndexOf=function(t,e,r){return W(this,t,e,r,0)},x.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 F(this,t,e,r);case"utf8":case"utf-8":return Y(this,t,e,r);case"ascii":return z(this,t,e,r);case"latin1":case"binary":return Z(this,t,e,r);case"base64":return H(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=1}},x.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;function $(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 X(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 J(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 tt(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 et(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 rt(t,e,r,n,i,o){if(!L(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 nt(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 it(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 ot(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 st(t,e,r,n,i){return i||ot(t,0,r,4),A(t,e,r,n,23,4),r+4}function at(t,e,r,n,i){return i||ot(t,0,r,8),A(t,e,r,n,52,8),r+8}x.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),x.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=x.prototype;else{var i=e-t;r=new x(i,void 0);for(var o=0;o<i;++o)r[o]=this[o+t]}return r},x.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||et(t,e,this.length);for(var n=this[t],i=1,o=0;++o<e&&(i*=256);)n+=this[t+o]*i;return n},x.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||et(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},x.prototype.readUInt8=function(t,e){return e||et(t,1,this.length),this[t]},x.prototype.readUInt16LE=function(t,e){return e||et(t,2,this.length),this[t]|this[t+1]<<8},x.prototype.readUInt16BE=function(t,e){return e||et(t,2,this.length),this[t]<<8|this[t+1]},x.prototype.readUInt32LE=function(t,e){return e||et(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},x.prototype.readUInt32BE=function(t,e){return e||et(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},x.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||et(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},x.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||et(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},x.prototype.readInt8=function(t,e){return e||et(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},x.prototype.readInt16LE=function(t,e){e||et(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},x.prototype.readInt16BE=function(t,e){e||et(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},x.prototype.readInt32LE=function(t,e){return e||et(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},x.prototype.readInt32BE=function(t,e){return e||et(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},x.prototype.readFloatLE=function(t,e){return e||et(t,4,this.length),k(this,t,1,23,4)},x.prototype.readFloatBE=function(t,e){return e||et(t,4,this.length),k(this,t,0,23,4)},x.prototype.readDoubleLE=function(t,e){return e||et(t,8,this.length),k(this,t,1,52,8)},x.prototype.readDoubleBE=function(t,e){return e||et(t,8,this.length),k(this,t,0,52,8)},x.prototype.writeUIntLE=function(t,e,r,n){t=+t,e|=0,r|=0,n||rt(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},x.prototype.writeUIntBE=function(t,e,r,n){t=+t,e|=0,r|=0,n||rt(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},x.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||rt(this,t,e,1,255,0),x.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},x.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||rt(this,t,e,2,65535,0),x.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):nt(this,t,e,1),e+2},x.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||rt(this,t,e,2,65535,0),x.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):nt(this,t,e,0),e+2},x.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||rt(this,t,e,4,4294967295,0),x.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):it(this,t,e,1),e+4},x.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||rt(this,t,e,4,4294967295,0),x.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):it(this,t,e,0),e+4},x.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);rt(this,t,e,r,i-1,-i)}var o=0,s=1,a=0;for(this[e]=255&t;++o<r&&(s*=256);)t<0&&0===a&&0!==this[e+o-1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},x.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);rt(this,t,e,r,i-1,-i)}var o=r-1,s=1,a=0;for(this[e+o]=255&t;--o>=0&&(s*=256);)t<0&&0===a&&0!==this[e+o+1]&&(a=1),this[e+o]=(t/s>>0)-a&255;return e+r},x.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||rt(this,t,e,1,127,-128),x.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},x.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||rt(this,t,e,2,32767,-32768),x.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):nt(this,t,e,1),e+2},x.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||rt(this,t,e,2,32767,-32768),x.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):nt(this,t,e,0),e+2},x.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||rt(this,t,e,4,2147483647,-2147483648),x.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):it(this,t,e,1),e+4},x.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||rt(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),x.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):it(this,t,e,0),e+4},x.prototype.writeFloatLE=function(t,e,r){return st(this,t,e,1,r)},x.prototype.writeFloatBE=function(t,e,r){return st(this,t,e,0,r)},x.prototype.writeDoubleLE=function(t,e,r){return at(this,t,e,1,r)},x.prototype.writeDoubleBE=function(t,e,r){return at(this,t,e,0,r)},x.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||!x.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},x.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&&!x.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=L(t)?t:ht(new x(t,n).toString()),a=s.length;for(o=0;o<r-e;++o)this[o+e]=s[o%a]}return this};var ut=/[^+\/0-9A-Za-z-_]/g;function ht(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 mt(t){return function(t){var e,r,n,i,o,s;v||w();var a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===t[a-2]?2:"="===t[a-1]?1:0,s=new M(3*a/4-o),n=o>0?a-4:a;var u=0;for(e=0,r=0;e<n;e+=4,r+=3)i=y[t.charCodeAt(e)]<<18|y[t.charCodeAt(e+1)]<<12|y[t.charCodeAt(e+2)]<<6|y[t.charCodeAt(e+3)],s[u++]=i>>16&255,s[u++]=i>>8&255,s[u++]=255&i;return 2===o?(i=y[t.charCodeAt(e)]<<2|y[t.charCodeAt(e+1)]>>4,s[u++]=255&i):1===o&&(i=y[t.charCodeAt(e)]<<10|y[t.charCodeAt(e+1)]<<4|y[t.charCodeAt(e+2)]>>2,s[u++]=i>>8&255,s[u++]=255&i),s}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(ut,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function lt(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 ct(t){return null!=t&&(!!t._isBuffer||pt(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&pt(t.slice(0,0))}(t))}function pt(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var dt=p(Object.freeze({__proto__:null,Buffer:x,INSPECT_MAX_BYTES:50,SlowBuffer:function(t){return+t!=t&&(t=0),x.alloc(+t)},isBuffer:ct,kMaxLength:C}));!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 d?d.exports=i:e.BN=i,i.BN=i,i.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:dt.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 a(t,e,r){var n=s(t,r);return r-1>=e&&(n|=s(t,r-1)<<4),n}function u(t,e,n,i){for(var o=0,s=0,a=Math.min(t.length,n),u=e;u<a;u++){var h=t.charCodeAt(u)-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,a=0;if("be"===n)for(i=t.length-1,o=0;i>=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i<t.length;i+=3)s=t[i]|t[i+1]<<8|t[i+2]<<16,this.words[o]|=s<<a&67108863,this.words[o+1]=s>>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this._strip()},i.prototype._parseHex=function(t,e,r){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var n=0;n<this.length;n++)this.words[n]=0;var i,o=0,s=0;if("be"===r)for(n=t.length-1;n>=e;n-=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;else for(n=(t.length-e)%2==0?e+1:e;n<t.length;n+=2)i=a(t,e,n)<<o,this.words[s]|=67108863&i,o>=18?(o-=18,s+=1,this.words[s]|=i>>>26):o+=8;this._strip()},i.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,h=0,m=r;m<a;m+=n)h=u(t,m,m+n,e),this.imuln(i),this.words[0]+h<67108864?this.words[0]+=h:this._iaddn(h);if(0!==s){var l=1;for(h=u(t,m,t.length,e),m=0;m<s;m++)l*=e;this.imuln(l),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")]=m}catch(t){i.prototype.inspect=m}else i.prototype.inspect=m;function m(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var l=["","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"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],p=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function f(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var h=1;h<n;h++){for(var m=u>>>26,l=67108863&u,c=Math.min(h,e.length-1),p=Math.max(0,h-t.length+1);p<=c;p++){var d=h-p|0;m+=(s=(i=0|t.words[d])*(o=0|e.words[p])+l)/67108864|0,l=67108863&s}r.words[h]=0|l,u=0|m}return 0!==u?r.words[h]=0|u:r.length--,r._strip()}i.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s<this.length;s++){var a=this.words[s],u=(16777215&(a<<i|o)).toString(16);o=a>>>24-i&16777215,(i+=2)>=26&&(i-=26,s--),n=0!==o||s!==this.length-1?l[6-u.length]+u+n:u+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=c[t],m=p[t];n="";var d=this.clone();for(d.negative=0;!d.isZero();){var f=d.modrn(m).toString(t);n=(d=d.idivn(m)).isZero()?f+n:l[h-f.length]+f+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 g=function(t,e,r){var n,i,o,s=t.words,a=e.words,u=r.words,h=0,m=0|s[0],l=8191&m,c=m>>>13,p=0|s[1],d=8191&p,f=p>>>13,g=0|s[2],y=8191&g,M=g>>>13,v=0|s[3],w=8191&v,b=v>>>13,P=0|s[4],k=8191&P,A=P>>>13,S=0|s[5],T=8191&S,C=S>>>13,I=0|s[6],_=8191&I,x=I>>>13,E=0|s[7],R=8191&E,O=E>>>13,D=0|s[8],B=8191&D,L=D>>>13,U=0|s[9],N=8191&U,K=U>>>13,W=0|a[0],q=8191&W,F=W>>>13,Y=0|a[1],z=8191&Y,Z=Y>>>13,H=0|a[2],j=8191&H,V=H>>>13,G=0|a[3],Q=8191&G,$=G>>>13,X=0|a[4],J=8191&X,tt=X>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ht=at>>>13,mt=0|a[8],lt=8191&mt,ct=mt>>>13,pt=0|a[9],dt=8191&pt,ft=pt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(h+(n=Math.imul(l,q))|0)+((8191&(i=(i=Math.imul(l,F))+Math.imul(c,q)|0))<<13)|0;h=((o=Math.imul(c,F))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(d,q),i=(i=Math.imul(d,F))+Math.imul(f,q)|0,o=Math.imul(f,F);var yt=(h+(n=n+Math.imul(l,z)|0)|0)+((8191&(i=(i=i+Math.imul(l,Z)|0)+Math.imul(c,z)|0))<<13)|0;h=((o=o+Math.imul(c,Z)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,q),i=(i=Math.imul(y,F))+Math.imul(M,q)|0,o=Math.imul(M,F),n=n+Math.imul(d,z)|0,i=(i=i+Math.imul(d,Z)|0)+Math.imul(f,z)|0,o=o+Math.imul(f,Z)|0;var Mt=(h+(n=n+Math.imul(l,j)|0)|0)+((8191&(i=(i=i+Math.imul(l,V)|0)+Math.imul(c,j)|0))<<13)|0;h=((o=o+Math.imul(c,V)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(w,q),i=(i=Math.imul(w,F))+Math.imul(b,q)|0,o=Math.imul(b,F),n=n+Math.imul(y,z)|0,i=(i=i+Math.imul(y,Z)|0)+Math.imul(M,z)|0,o=o+Math.imul(M,Z)|0,n=n+Math.imul(d,j)|0,i=(i=i+Math.imul(d,V)|0)+Math.imul(f,j)|0,o=o+Math.imul(f,V)|0;var vt=(h+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,$)|0)+Math.imul(c,Q)|0))<<13)|0;h=((o=o+Math.imul(c,$)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(k,q),i=(i=Math.imul(k,F))+Math.imul(A,q)|0,o=Math.imul(A,F),n=n+Math.imul(w,z)|0,i=(i=i+Math.imul(w,Z)|0)+Math.imul(b,z)|0,o=o+Math.imul(b,Z)|0,n=n+Math.imul(y,j)|0,i=(i=i+Math.imul(y,V)|0)+Math.imul(M,j)|0,o=o+Math.imul(M,V)|0,n=n+Math.imul(d,Q)|0,i=(i=i+Math.imul(d,$)|0)+Math.imul(f,Q)|0,o=o+Math.imul(f,$)|0;var wt=(h+(n=n+Math.imul(l,J)|0)|0)+((8191&(i=(i=i+Math.imul(l,tt)|0)+Math.imul(c,J)|0))<<13)|0;h=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(T,q),i=(i=Math.imul(T,F))+Math.imul(C,q)|0,o=Math.imul(C,F),n=n+Math.imul(k,z)|0,i=(i=i+Math.imul(k,Z)|0)+Math.imul(A,z)|0,o=o+Math.imul(A,Z)|0,n=n+Math.imul(w,j)|0,i=(i=i+Math.imul(w,V)|0)+Math.imul(b,j)|0,o=o+Math.imul(b,V)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(M,Q)|0,o=o+Math.imul(M,$)|0,n=n+Math.imul(d,J)|0,i=(i=i+Math.imul(d,tt)|0)+Math.imul(f,J)|0,o=o+Math.imul(f,tt)|0;var bt=(h+(n=n+Math.imul(l,rt)|0)|0)+((8191&(i=(i=i+Math.imul(l,nt)|0)+Math.imul(c,rt)|0))<<13)|0;h=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(_,q),i=(i=Math.imul(_,F))+Math.imul(x,q)|0,o=Math.imul(x,F),n=n+Math.imul(T,z)|0,i=(i=i+Math.imul(T,Z)|0)+Math.imul(C,z)|0,o=o+Math.imul(C,Z)|0,n=n+Math.imul(k,j)|0,i=(i=i+Math.imul(k,V)|0)+Math.imul(A,j)|0,o=o+Math.imul(A,V)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,$)|0,n=n+Math.imul(y,J)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(M,J)|0,o=o+Math.imul(M,tt)|0,n=n+Math.imul(d,rt)|0,i=(i=i+Math.imul(d,nt)|0)+Math.imul(f,rt)|0,o=o+Math.imul(f,nt)|0;var Pt=(h+(n=n+Math.imul(l,ot)|0)|0)+((8191&(i=(i=i+Math.imul(l,st)|0)+Math.imul(c,ot)|0))<<13)|0;h=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(R,q),i=(i=Math.imul(R,F))+Math.imul(O,q)|0,o=Math.imul(O,F),n=n+Math.imul(_,z)|0,i=(i=i+Math.imul(_,Z)|0)+Math.imul(x,z)|0,o=o+Math.imul(x,Z)|0,n=n+Math.imul(T,j)|0,i=(i=i+Math.imul(T,V)|0)+Math.imul(C,j)|0,o=o+Math.imul(C,V)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,$)|0,n=n+Math.imul(w,J)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(b,J)|0,o=o+Math.imul(b,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(M,rt)|0,o=o+Math.imul(M,nt)|0,n=n+Math.imul(d,ot)|0,i=(i=i+Math.imul(d,st)|0)+Math.imul(f,ot)|0,o=o+Math.imul(f,st)|0;var kt=(h+(n=n+Math.imul(l,ut)|0)|0)+((8191&(i=(i=i+Math.imul(l,ht)|0)+Math.imul(c,ut)|0))<<13)|0;h=((o=o+Math.imul(c,ht)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(B,q),i=(i=Math.imul(B,F))+Math.imul(L,q)|0,o=Math.imul(L,F),n=n+Math.imul(R,z)|0,i=(i=i+Math.imul(R,Z)|0)+Math.imul(O,z)|0,o=o+Math.imul(O,Z)|0,n=n+Math.imul(_,j)|0,i=(i=i+Math.imul(_,V)|0)+Math.imul(x,j)|0,o=o+Math.imul(x,V)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,$)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,$)|0,n=n+Math.imul(k,J)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(A,J)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(b,rt)|0,o=o+Math.imul(b,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(M,ot)|0,o=o+Math.imul(M,st)|0,n=n+Math.imul(d,ut)|0,i=(i=i+Math.imul(d,ht)|0)+Math.imul(f,ut)|0,o=o+Math.imul(f,ht)|0;var At=(h+(n=n+Math.imul(l,lt)|0)|0)+((8191&(i=(i=i+Math.imul(l,ct)|0)+Math.imul(c,lt)|0))<<13)|0;h=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(N,q),i=(i=Math.imul(N,F))+Math.imul(K,q)|0,o=Math.imul(K,F),n=n+Math.imul(B,z)|0,i=(i=i+Math.imul(B,Z)|0)+Math.imul(L,z)|0,o=o+Math.imul(L,Z)|0,n=n+Math.imul(R,j)|0,i=(i=i+Math.imul(R,V)|0)+Math.imul(O,j)|0,o=o+Math.imul(O,V)|0,n=n+Math.imul(_,Q)|0,i=(i=i+Math.imul(_,$)|0)+Math.imul(x,Q)|0,o=o+Math.imul(x,$)|0,n=n+Math.imul(T,J)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(C,J)|0,o=o+Math.imul(C,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(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(b,ot)|0,o=o+Math.imul(b,st)|0,n=n+Math.imul(y,ut)|0,i=(i=i+Math.imul(y,ht)|0)+Math.imul(M,ut)|0,o=o+Math.imul(M,ht)|0,n=n+Math.imul(d,lt)|0,i=(i=i+Math.imul(d,ct)|0)+Math.imul(f,lt)|0,o=o+Math.imul(f,ct)|0;var St=(h+(n=n+Math.imul(l,dt)|0)|0)+((8191&(i=(i=i+Math.imul(l,ft)|0)+Math.imul(c,dt)|0))<<13)|0;h=((o=o+Math.imul(c,ft)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(N,z),i=(i=Math.imul(N,Z))+Math.imul(K,z)|0,o=Math.imul(K,Z),n=n+Math.imul(B,j)|0,i=(i=i+Math.imul(B,V)|0)+Math.imul(L,j)|0,o=o+Math.imul(L,V)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(O,Q)|0,o=o+Math.imul(O,$)|0,n=n+Math.imul(_,J)|0,i=(i=i+Math.imul(_,tt)|0)+Math.imul(x,J)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,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(w,ut)|0,i=(i=i+Math.imul(w,ht)|0)+Math.imul(b,ut)|0,o=o+Math.imul(b,ht)|0,n=n+Math.imul(y,lt)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(M,lt)|0,o=o+Math.imul(M,ct)|0;var Tt=(h+(n=n+Math.imul(d,dt)|0)|0)+((8191&(i=(i=i+Math.imul(d,ft)|0)+Math.imul(f,dt)|0))<<13)|0;h=((o=o+Math.imul(f,ft)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(N,j),i=(i=Math.imul(N,V))+Math.imul(K,j)|0,o=Math.imul(K,V),n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,$)|0)+Math.imul(L,Q)|0,o=o+Math.imul(L,$)|0,n=n+Math.imul(R,J)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(O,J)|0,o=o+Math.imul(O,tt)|0,n=n+Math.imul(_,rt)|0,i=(i=i+Math.imul(_,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(T,ot)|0,i=(i=i+Math.imul(T,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(k,ut)|0,i=(i=i+Math.imul(k,ht)|0)+Math.imul(A,ut)|0,o=o+Math.imul(A,ht)|0,n=n+Math.imul(w,lt)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(b,lt)|0,o=o+Math.imul(b,ct)|0;var Ct=(h+(n=n+Math.imul(y,dt)|0)|0)+((8191&(i=(i=i+Math.imul(y,ft)|0)+Math.imul(M,dt)|0))<<13)|0;h=((o=o+Math.imul(M,ft)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,n=Math.imul(N,Q),i=(i=Math.imul(N,$))+Math.imul(K,Q)|0,o=Math.imul(K,$),n=n+Math.imul(B,J)|0,i=(i=i+Math.imul(B,tt)|0)+Math.imul(L,J)|0,o=o+Math.imul(L,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(O,rt)|0,o=o+Math.imul(O,nt)|0,n=n+Math.imul(_,ot)|0,i=(i=i+Math.imul(_,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(T,ut)|0,i=(i=i+Math.imul(T,ht)|0)+Math.imul(C,ut)|0,o=o+Math.imul(C,ht)|0,n=n+Math.imul(k,lt)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(A,lt)|0,o=o+Math.imul(A,ct)|0;var It=(h+(n=n+Math.imul(w,dt)|0)|0)+((8191&(i=(i=i+Math.imul(w,ft)|0)+Math.imul(b,dt)|0))<<13)|0;h=((o=o+Math.imul(b,ft)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(N,J),i=(i=Math.imul(N,tt))+Math.imul(K,J)|0,o=Math.imul(K,tt),n=n+Math.imul(B,rt)|0,i=(i=i+Math.imul(B,nt)|0)+Math.imul(L,rt)|0,o=o+Math.imul(L,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,st)|0)+Math.imul(O,ot)|0,o=o+Math.imul(O,st)|0,n=n+Math.imul(_,ut)|0,i=(i=i+Math.imul(_,ht)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ht)|0,n=n+Math.imul(T,lt)|0,i=(i=i+Math.imul(T,ct)|0)+Math.imul(C,lt)|0,o=o+Math.imul(C,ct)|0;var _t=(h+(n=n+Math.imul(k,dt)|0)|0)+((8191&(i=(i=i+Math.imul(k,ft)|0)+Math.imul(A,dt)|0))<<13)|0;h=((o=o+Math.imul(A,ft)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(N,rt),i=(i=Math.imul(N,nt))+Math.imul(K,rt)|0,o=Math.imul(K,nt),n=n+Math.imul(B,ot)|0,i=(i=i+Math.imul(B,st)|0)+Math.imul(L,ot)|0,o=o+Math.imul(L,st)|0,n=n+Math.imul(R,ut)|0,i=(i=i+Math.imul(R,ht)|0)+Math.imul(O,ut)|0,o=o+Math.imul(O,ht)|0,n=n+Math.imul(_,lt)|0,i=(i=i+Math.imul(_,ct)|0)+Math.imul(x,lt)|0,o=o+Math.imul(x,ct)|0;var xt=(h+(n=n+Math.imul(T,dt)|0)|0)+((8191&(i=(i=i+Math.imul(T,ft)|0)+Math.imul(C,dt)|0))<<13)|0;h=((o=o+Math.imul(C,ft)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(N,ot),i=(i=Math.imul(N,st))+Math.imul(K,ot)|0,o=Math.imul(K,st),n=n+Math.imul(B,ut)|0,i=(i=i+Math.imul(B,ht)|0)+Math.imul(L,ut)|0,o=o+Math.imul(L,ht)|0,n=n+Math.imul(R,lt)|0,i=(i=i+Math.imul(R,ct)|0)+Math.imul(O,lt)|0,o=o+Math.imul(O,ct)|0;var Et=(h+(n=n+Math.imul(_,dt)|0)|0)+((8191&(i=(i=i+Math.imul(_,ft)|0)+Math.imul(x,dt)|0))<<13)|0;h=((o=o+Math.imul(x,ft)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(N,ut),i=(i=Math.imul(N,ht))+Math.imul(K,ut)|0,o=Math.imul(K,ht),n=n+Math.imul(B,lt)|0,i=(i=i+Math.imul(B,ct)|0)+Math.imul(L,lt)|0,o=o+Math.imul(L,ct)|0;var Rt=(h+(n=n+Math.imul(R,dt)|0)|0)+((8191&(i=(i=i+Math.imul(R,ft)|0)+Math.imul(O,dt)|0))<<13)|0;h=((o=o+Math.imul(O,ft)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(N,lt),i=(i=Math.imul(N,ct))+Math.imul(K,lt)|0,o=Math.imul(K,ct);var Ot=(h+(n=n+Math.imul(B,dt)|0)|0)+((8191&(i=(i=i+Math.imul(B,ft)|0)+Math.imul(L,dt)|0))<<13)|0;h=((o=o+Math.imul(L,ft)|0)+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863;var Dt=(h+(n=Math.imul(N,dt))|0)+((8191&(i=(i=Math.imul(N,ft))+Math.imul(K,dt)|0))<<13)|0;return h=((o=Math.imul(K,ft))+(i>>>13)|0)+(Dt>>>26)|0,Dt&=67108863,u[0]=gt,u[1]=yt,u[2]=Mt,u[3]=vt,u[4]=wt,u[5]=bt,u[6]=Pt,u[7]=kt,u[8]=At,u[9]=St,u[10]=Tt,u[11]=Ct,u[12]=It,u[13]=_t,u[14]=xt,u[15]=Et,u[16]=Rt,u[17]=Ot,u[18]=Dt,0!==h&&(u[19]=h,r.length++),r};function y(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o<r.length-1;o++){var s=i;i=0;for(var a=67108863&n,u=Math.min(o,e.length-1),h=Math.max(0,o-t.length+1);h<=u;h++){var m=o-h,l=(0|t.words[m])*(0|e.words[h]),c=67108863&l;a=67108863&(c=c+a|0),i+=(s=(s=s+(l/67108864|0)|0)+(c>>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function M(t,e,r){return y(t,e,r)}Math.imul||(g=f),i.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?g(this,t,e):r<63?f(this,t,e):r<1024?y(this,t,e):M(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),M(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 a=this.words[e]&o,u=(0|this.words[e])-a<<n;this.words[e]=u|s,s=a>>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e<i;e++)this.words[e]=0;this.length+=i}return this._strip()},i.prototype.ishln=function(t){return r(0===this.negative),this.iushln(t)},i.prototype.iushrn=function(t,e,n){var i;r("number"==typeof t&&t>=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<<o,u=n;if(i-=s,i=Math.max(0,i),u){for(var h=0;h<s;h++)u.words[h]=this.words[h];u.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 m=0;for(h=this.length-1;h>=0&&(0!==m||h>=i);h--){var l=0|this.words[h];this.words[h]=m<<26-o|l>>>o,m=l&a}return u&&0!==m&&(u.words[u.length++]=m),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 a=0;for(i=0;i<t.length;i++){o=(0|this.words[i+n])+a;var u=(0|t.words[i])*e;a=((o-=67108863&u)>>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i<this.length-n;i++)a=(o=(0|this.words[i+n])+a)>>26,this.words[i+n]=67108863&o;if(0===a)return this._strip();for(r(-1===a),a=0,i=0;i<this.length;i++)a=(o=-(0|this.words[i])+a)>>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},i.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),o=t,s=0|o.words[o.length-1];0!=(r=26-this._countBits(s))&&(o=o.ushln(r),n.iushln(r),s=0|o.words[o.length-1]);var a,u=n.length-o.length;if("mod"!==e){(a=new i(null)).length=u+1,a.words=new Array(a.length);for(var h=0;h<a.length;h++)a.words[h]=0}var m=n.clone()._ishlnsubmul(o,1,u);0===m.negative&&(n=m,a&&(a.words[u]=1));for(var l=u-1;l>=0;l--){var c=67108864*(0|n.words[o.length+l])+(0|n.words[o.length+l-1]);for(c=Math.min(c/s|0,67108863),n._ishlnsubmul(o,c,l);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(o,1,l),n.isZero()||(n.negative^=1);a&&(a.words[l]=c)}return a&&a._strip(),n._strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},i.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(o=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:o,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(o=a.div.neg()),{div:o,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new i(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new i(this.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,a},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),a=new i(0),u=new i(1),h=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++h;for(var m=n.clone(),l=e.clone();!e.isZero();){for(var c=0,p=1;0==(e.words[0]&p)&&c<26;++c,p<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(o.isOdd()||s.isOdd())&&(o.iadd(m),s.isub(l)),o.iushrn(1),s.iushrn(1);for(var d=0,f=1;0==(n.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(n.iushrn(d);d-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(m),u.isub(l)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a),s.isub(u)):(n.isub(e),a.isub(o),u.isub(s))}return{a:a,b:u,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),a=new i(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,m=1;0==(e.words[0]&m)&&h<26;++h,m<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var l=0,c=1;0==(n.words[0]&c)&&l<26;++l,c<<=1);if(l>0)for(n.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(o=0===e.cmpn(1)?s:a).cmpn(0)<0&&o.iadd(t),o},i.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},i.prototype.invm=function(t){return this.egcd(t).a.umod(t)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(t){return this.words[0]&t},i.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=i,this;for(var o=i,s=n;0!==o&&s<this.length;s++){var a=0|this.words[s];o=(a+=o)>>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:i<t?-1:1}return 0!==this.negative?0|-e:e},i.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},i.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,r=this.length-1;r>=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){n<i?e=-1:n>i&&(e=1);break}}return e},i.prototype.gtn=function(t){return 1===this.cmpn(t)},i.prototype.gt=function(t){return 1===this.cmp(t)},i.prototype.gten=function(t){return this.cmpn(t)>=0},i.prototype.gte=function(t){return this.cmp(t)>=0},i.prototype.ltn=function(t){return-1===this.cmpn(t)},i.prototype.lt=function(t){return-1===this.cmp(t)},i.prototype.lten=function(t){return this.cmpn(t)<=0},i.prototype.lte=function(t){return this.cmp(t)<=0},i.prototype.eqn=function(t){return 0===this.cmpn(t)},i.prototype.eq=function(t){return 0===this.cmp(t)},i.red=function(t){return new S(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 v={k256:null,p224:null,p192:null,p25519:null};function w(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(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function P(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function k(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function A(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(t){if("string"==typeof t){var e=i._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function T(t){S.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)}w.prototype._tmp=function(){var t=new i(null);return t.words=new Array(Math.ceil(this.n/13)),t},w.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},w.prototype.split=function(t,e){t.iushrn(this.n,0,e)},w.prototype.imulK=function(t){return t.imul(this.k)},n(b,w),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(P,w),n(k,w),n(A,w),A.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(v[t])return v[t];var e;if("k256"===t)e=new b;else if("p224"===t)e=new P;else if("p192"===t)e=new k;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new A}return v[t]=e,e},S.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},S.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")},S.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(h(t,t.umod(this.m)._forceRed(this)),t)},S.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},S.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)},S.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},S.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)},S.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},S.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},S.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},S.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},S.prototype.isqr=function(t){return this.imul(t,t.clone())},S.prototype.sqr=function(t){return this.mul(t,t)},S.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new i(1)).iushrn(2);return this.pow(t,n)}for(var o=this.m.subn(1),s=0;!o.isZero()&&0===o.andln(1);)s++,o.iushrn(1);r(!o.isZero());var a=new i(1).toRed(this),u=a.redNeg(),h=this.m.subn(1).iushrn(1),m=this.m.bitLength();for(m=new i(2*m*m).toRed(this);0!==this.pow(m,h).cmp(u);)m.redIAdd(u);for(var l=this.pow(m,o),c=this.pow(t,o.addn(1).iushrn(1)),p=this.pow(t,o),d=s;0!==p.cmp(a);){for(var f=p,g=0;0!==f.cmp(a);g++)f=f.redSqr();r(g<d);var y=this.pow(l,new i(1).iushln(d-g-1));c=c.redMul(y),l=y.redSqr(),p=p.redMul(l),d=g}return c},S.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},S.prototype.pow=function(t,e){if(e.isZero())return new i(1).toRed(this);if(0===e.cmpn(1))return t.clone();var r=new Array(16);r[0]=new i(1).toRed(this),r[1]=t;for(var n=2;n<r.length;n++)r[n]=this.mul(r[n-1],t);var o=r[0],s=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),n=e.length-1;n>=0;n--){for(var h=e.words[n],m=u-1;m>=0;m--){var l=h>>m&1;o!==r[0]&&(o=this.sqr(o)),0!==l||0!==s?(s<<=1,s|=l,(4==++a||0===n&&0===m)&&(o=this.mul(o,r[s]),a=0,s=0)):a=0}u=26}return o},S.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},S.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},i.mont=function(t){return new T(t)},n(T,S),T.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},T.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},T.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)},T.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)},T.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(0,l);var ft=c(d.exports);const gt=n.struct([n.array(n.u8(),32,"a"),n.array(n.u8(),64,"b"),n.array(n.u8(),32,"c")]),yt=n.struct([n.publicKey("owner"),n.u64("amount"),n.option(n.u64(),"lamports"),n.u8("merkleTreeIndex"),n.option(n.vecU8(),"tlv")]),Mt=n.struct([n.u8("queueId"),n.u16("index")]),vt=n.struct([n.u64("amount"),n.option(n.u8(),"delegateIndex"),n.struct([n.u8("merkleTreePubkeyIndex"),n.u8("nullifierQueuePubkeyIndex"),n.u32("leafIndex"),n.option(Mt,"queueIndex")],"merkleContext"),n.u16("rootIndex"),n.option(n.u64(),"lamports"),n.option(n.vecU8(),"tlv")]),wt=n.struct([n.publicKey("owner"),n.option(n.u8(),"delegateChangeAccountIndex")]),bt=n.struct([n.bool("setContext"),n.bool("firstSetContext"),n.u8("cpiContextAccountIndex")]),Pt=n.struct([n.option(gt,"proof"),n.publicKey("mint"),n.option(wt,"delegatedTransfer"),n.vec(vt,"inputTokenDataWithContext"),n.vec(yt,"outputCompressedAccounts"),n.bool("isCompress"),n.option(n.u64(),"compressOrDecompressAmount"),n.option(bt,"cpiContext"),n.option(n.u8(),"lamportsChangeAccountMerkleTreeIndex")]),kt=n.struct([n.vec(n.publicKey(),"recipients"),n.vec(n.u64(),"amounts"),n.option(n.u64(),"lamports")]),At=n.struct([n.publicKey("owner"),n.option(n.u64(),"remainingAmount"),n.option(bt,"cpiContext")]);function St(t){const e=x.alloc(1e3),r=kt.encode({recipients:t.recipients,amounts:t.amounts,lamports:t.lamports},e);return x.concat([u,e.slice(0,r)])}function Tt(t){const e=x.alloc(1e3),r=At.encode({owner:t.owner,remainingAmount:t.remainingAmount,cpiContext:t.cpiContext},e);return x.concat([m,e.slice(0,r)])}function Ct(t){const e=x.alloc(1e3),r=Pt.encode(t,e),n=x.alloc(4);return n.writeUInt32LE(r,0),x.concat([h,n,e.slice(0,r)])}const It=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}]},_t=t=>{const e=Lt.programId,{feePayer:r,authority:n,cpiAuthorityPda:i,mint:o,tokenPoolPda:s,tokenProgram:a,lightSystemProgram:u,registeredProgramPda:h,noopProgram:m,accountCompressionAuthority:l,accountCompressionProgram:c,merkleTree:p,selfProgram:d,systemProgram:f,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:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:h,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0},{pubkey:l,isSigner:0,isWritable:0},{pubkey:c,isSigner:0,isWritable:0},{pubkey:p,isSigner:0,isWritable:1},{pubkey:d,isSigner:0,isWritable:0},{pubkey:f,isSigner:0,isWritable:0},{pubkey:null!=g?g:e,isSigner:0,isWritable:1}]},xt=t=>{const e=Lt.programId,{feePayer:r,authority:n,cpiAuthorityPda:i,lightSystemProgram:o,registeredProgramPda:s,noopProgram:a,accountCompressionAuthority:u,accountCompressionProgram:h,selfProgram:m,tokenPoolPda:l,compressOrDecompressTokenAccount:c,tokenProgram:p,systemProgram:d}=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:a,isSigner:0,isWritable:0},{pubkey:u,isSigner:0,isWritable:0},{pubkey:h,isSigner:0,isWritable:0},{pubkey:m,isSigner:0,isWritable:0},{pubkey:null!=l?l:e,isSigner:0,isWritable:1},{pubkey:null!=c?c:e,isSigner:0,isWritable:1},{pubkey:null!=p?p:e,isSigner:0,isWritable:0},{pubkey:d,isSigner:0,isWritable:0}]},Et=e=>e.reduce(((t,e)=>t.add(e.parsed.amount)),t.bn(0)),Rt=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")}))},Ot=t=>({mint:t[0].parsed.mint,currentOwner:t[0].parsed.owner,delegate:t[0].parsed.delegate});function Dt(e,r,n){n=t.bn(n);const i=Et(e),o=t.sumUpLamports(e.map((t=>t.compressedAccount))),s=i.sub(n);return t.validateSufficientBalance(s),s.eq(t.bn(0))&&o.eq(t.bn(0))?[{owner:r,amount:n,lamports:o,tlv:null}]:(t.validateSameOwner(e.map((t=>t.compressedAccount))),Rt(e),[{owner:e[0].parsed.owner,amount:s,lamports:o,tlv:null},{owner:r,amount:n,lamports:t.bn(0),tlv:null}])}function Bt(e,r){r=t.bn(r);const n=t.sumUpLamports(e.map((t=>t.compressedAccount))),i=Et(e).sub(r);return t.validateSufficientBalance(i),i.eq(t.bn(0))&&n.eq(t.bn(0))?[]:(t.validateSameOwner(e.map((t=>t.compressedAccount))),Rt(e),[{owner:e[0].parsed.owner,amount:i,lamports:n,tlv:null}])}class Lt{constructor(){}static setProgramId(t){this.programId="string"==typeof t?new e.PublicKey(t):t}static deriveTokenPoolPda(t){const r=[o,t.toBuffer()],[n,i]=e.PublicKey.findProgramAddressSync(r,this.programId);return n}static get deriveCpiAuthorityPda(){const[t,r]=e.PublicKey.findProgramAddressSync([s],this.programId);return t}static async createMint(t){const{mint:n,authority:i,feePayer:o,rentExemptBalance:s,tokenProgramId:a,freezeAuthority:u,mintSize:h}=t,m=null!=a?a:r.TOKEN_PROGRAM_ID;return[e.SystemProgram.createAccount({fromPubkey:o,lamports:s,newAccountPubkey:n,programId:m,space:null!=h?h:r.MINT_SIZE}),r.createInitializeMint2Instruction(n,t.decimals,i,u,m),await this.createTokenPool({feePayer:o,mint:n,tokenProgramId:m})]}static async createTokenPool(t){const{mint:n,feePayer:i,tokenProgramId:o}=t,s=null!=o?o:r.TOKEN_PROGRAM_ID,u=this.deriveTokenPoolPda(n),h=It({mint:n,feePayer:i,tokenPoolPda:u,tokenProgram:s,cpiAuthorityPda:this.deriveCpiAuthorityPda,systemProgram:e.SystemProgram.programId});return new e.TransactionInstruction({programId:this.programId,keys:h,data:a})}static async mintTo(n){const i=t.defaultStaticAccountsStruct(),{mint:o,feePayer:s,authority:a,merkleTree:u,toPubkey:h,amount:m,tokenProgramId:l}=n,c=null!=l?l:r.TOKEN_PROGRAM_ID,p=this.deriveTokenPoolPda(o),d=t.toArray(m).map((e=>t.bn(e))),f=t.toArray(h);if(d.length!==f.length)throw new Error("Amount and toPubkey arrays must have the same length");const g=_t({mint:o,feePayer:s,authority:a,cpiAuthorityPda:this.deriveCpiAuthorityPda,tokenProgram:c,tokenPoolPda:p,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:i.registeredProgramPda,noopProgram:i.noopProgram,accountCompressionAuthority:i.accountCompressionAuthority,accountCompressionProgram:i.accountCompressionProgram,merkleTree:null!=u?u:t.defaultTestStateTreeAccounts().merkleTree,selfProgram:this.programId,systemProgram:e.SystemProgram.programId,solPoolPda:null}),y=St({recipients:f,amounts:d,lamports:null});return new e.TransactionInstruction({programId:this.programId,keys:g,data:y})}static async approveAndMintTo(t){const{mint:e,feePayer:n,authorityTokenAccount:i,authority:o,merkleTree:s,toPubkey:a,tokenProgramId:u}=t,h=BigInt(t.amount.toString());return[r.createMintToInstruction(e,i,o,h,[],u),await this.compress({payer:n,owner:o,source:i,toAddress:a,mint:e,amount:t.amount,outputStateTree:s,tokenProgramId:u})]}static async transfer(r){const{payer:n,inputCompressedTokenAccounts:o,recentInputStateRootIndices:s,recentValidityProof:a,amount:u,outputStateTrees:h,toAddress:m}=r,l=Dt(o,m,u),{inputTokenDataWithContext:c,packedOutputTokenData:p,remainingAccountMetas:d}=i({inputCompressedTokenAccounts:o,outputStateTrees:h,rootIndices:s,tokenTransferOutputs:l}),{mint:f,currentOwner:g}=Ot(o),y=Ct({proof:a,mint:f,delegatedTransfer:null,inputTokenDataWithContext:c,outputCompressedAccounts:p,compressOrDecompressAmount:null,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),{accountCompressionAuthority:M,noopProgram:v,registeredProgramPda:w,accountCompressionProgram:b}=t.defaultStaticAccountsStruct(),P=xt({feePayer:n,authority:g,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:w,noopProgram:v,accountCompressionAuthority:M,accountCompressionProgram:b,selfProgram:this.programId,tokenPoolPda:void 0,compressOrDecompressTokenAccount:void 0,tokenProgram:void 0,systemProgram:e.SystemProgram.programId});return P.push(...d),new e.TransactionInstruction({programId:this.programId,keys:P,data:y})}static async createTokenProgramLookupTable(n){const{authority:i,mints:o,recentSlot:s,payer:a,remainingAccounts:u}=n,[h,m]=e.AddressLookupTableProgram.createLookupTable({authority:i,payer:i,recentSlot:s});let l=[];return o&&(l=[...o,...o.map((t=>this.deriveTokenPoolPda(t)))]),{instructions:[h,e.AddressLookupTableProgram.extendLookupTable({payer:a,authority:i,lookupTable:m,addresses:[this.deriveCpiAuthorityPda,t.LightSystemProgram.programId,t.defaultStaticAccountsStruct().registeredProgramPda,t.defaultStaticAccountsStruct().noopProgram,t.defaultStaticAccountsStruct().accountCompressionAuthority,t.defaultStaticAccountsStruct().accountCompressionProgram,t.defaultTestStateTreeAccounts().merkleTree,t.defaultTestStateTreeAccounts().nullifierQueue,t.defaultTestStateTreeAccounts().addressTree,t.defaultTestStateTreeAccounts().addressQueue,this.programId,r.TOKEN_PROGRAM_ID,r.TOKEN_2022_PROGRAM_ID,i,...l,...null!=u?u:[]]})],address:m}}static async compress(n){const{payer:o,owner:s,source:a,toAddress:u,mint:h,outputStateTree:m,tokenProgramId:l}=n;if(Array.isArray(n.amount)!==Array.isArray(n.toAddress))throw new Error("Both amount and toAddress must be arrays or both must be single values");let c;if(Array.isArray(n.amount)&&Array.isArray(n.toAddress)){if(n.amount.length!==n.toAddress.length)throw new Error("Amount and toAddress arrays must have the same length");c=n.amount.map(((e,r)=>{const i=t.bn(e);return{owner:n.toAddress[r],amount:i,lamports:t.bn(0),tlv:null}}))}else c=[{owner:u,amount:t.bn(n.amount),lamports:t.bn(0),tlv:null}];const{inputTokenDataWithContext:p,packedOutputTokenData:d,remainingAccountMetas:f}=i({inputCompressedTokenAccounts:[],outputStateTrees:m,rootIndices:[],tokenTransferOutputs:c}),g=Ct({proof:null,mint:h,delegatedTransfer:null,inputTokenDataWithContext:p,outputCompressedAccounts:d,compressOrDecompressAmount:Array.isArray(n.amount)?n.amount.map((t=>new ft(t))).reduce(((t,e)=>t.add(e)),new ft(0)):new ft(n.amount),isCompress:1,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),y=null!=l?l:r.TOKEN_PROGRAM_ID,M=xt(Object.assign(Object.assign({},t.defaultStaticAccountsStruct()),{feePayer:o,authority:s,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,selfProgram:this.programId,systemProgram:e.SystemProgram.programId,tokenPoolPda:this.deriveTokenPoolPda(h),compressOrDecompressTokenAccount:a,tokenProgram:y}));return M.push(...f),new e.TransactionInstruction({programId:this.programId,keys:M,data:g})}static async decompress(n){const{payer:o,inputCompressedTokenAccounts:s,toAddress:a,outputStateTree:u,recentValidityProof:h,recentInputStateRootIndices:m,tokenProgramId:l}=n,c=t.bn(n.amount),p=Bt(s,c),{inputTokenDataWithContext:d,packedOutputTokenData:f,remainingAccountMetas:g}=i({inputCompressedTokenAccounts:s,outputStateTrees:u,rootIndices:m,tokenTransferOutputs:p}),{mint:y,currentOwner:M}=Ot(s),v=Ct({proof:h,mint:y,delegatedTransfer:null,inputTokenDataWithContext:d,outputCompressedAccounts:f,compressOrDecompressAmount:c,isCompress:0,cpiContext:null,lamportsChangeAccountMerkleTreeIndex:null}),w=null!=l?l:r.TOKEN_PROGRAM_ID,{accountCompressionAuthority:b,noopProgram:P,registeredProgramPda:k,accountCompressionProgram:A}=t.defaultStaticAccountsStruct(),S=xt({feePayer:o,authority:M,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:k,noopProgram:P,accountCompressionAuthority:b,accountCompressionProgram:A,selfProgram:this.programId,tokenPoolPda:this.deriveTokenPoolPda(y),compressOrDecompressTokenAccount:a,tokenProgram:w,systemProgram:e.SystemProgram.programId});return S.push(...g),new e.TransactionInstruction({programId:this.programId,keys:S,data:v})}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 ft(0)),outputStateTrees:i,recentInputStateRootIndices:s,recentValidityProof:o})]}static async compressSplTokenAccount(n){const{feePayer:i,authority:o,tokenAccount:s,mint:a,remainingAmount:u,outputStateTree:h,tokenProgramId:m}=n,l=null!=m?m:r.TOKEN_PROGRAM_ID,c=[{pubkey:h,isSigner:0,isWritable:1}],p=Tt({owner:o,remainingAmount:null!=u?u:null,cpiContext:null}),{accountCompressionAuthority:d,noopProgram:f,registeredProgramPda:g,accountCompressionProgram:y}=t.defaultStaticAccountsStruct(),M=xt({feePayer:i,authority:o,cpiAuthorityPda:this.deriveCpiAuthorityPda,lightSystemProgram:t.LightSystemProgram.programId,registeredProgramPda:g,noopProgram:f,accountCompressionAuthority:d,accountCompressionProgram:y,selfProgram:this.programId,tokenPoolPda:this.deriveTokenPoolPda(a),compressOrDecompressTokenAccount:s,tokenProgram:l,systemProgram:e.SystemProgram.programId});return M.push(...c),new e.TransactionInstruction({programId:this.programId,keys:M,data:p})}static async get_mint_program_id(t,e){var r;return null===(r=await e.getAccountInfo(t))||void 0===r?void 0:r.owner}}function Ut(e,r){let n=t.bn(0),i=t.bn(0);const o=[];e.sort(((t,e)=>e.parsed.amount.cmp(t.parsed.amount)));for(const s of e){if(n.gte(t.bn(r)))break;n=n.add(s.parsed.amount),i=i.add(s.compressedAccount.lamports),o.push(s)}if(n.lt(t.bn(r)))throw new Error(`Not enough balance for transfer. Required: ${r.toString()}, available: ${n.toString()}`);return[o,n,i.lt(t.bn(0))?i:null]}Lt.programId=new e.PublicKey("cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m"),exports.COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR=m,exports.CPI_AUTHORITY_SEED=s,exports.CREATE_TOKEN_POOL_DISCRIMINATOR=a,exports.CompressedTokenInstructionDataTransferLayout=Pt,exports.CompressedTokenProgram=Lt,exports.CpiContextLayout=bt,exports.DelegatedTransferLayout=wt,exports.IDL={version:"1.2.0",name:"light_compressed_token",instructions:[{name:"createTokenPool",docs:["This instruction creates a token pool for a given mint. Every spl mint","can have one token pool. When a token is compressed the tokens are","transferrred to the token pool, and their compressed equivalent is","minted into a Merkle tree."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"cpiAuthorityPda",isMut:0,isSigner:0}],args:[]},{name:"addTokenPool",docs:["This instruction creates an additional token pool for a given mint.","The maximum number of token pools per mint is 5."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"existingTokenPoolPda",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"cpiAuthorityPda",isMut:0,isSigner:0}],args:[{name:"tokenPoolBump",type:"u8"}]},{name:"mintTo",docs:["Mints tokens from an spl token mint to a list of compressed accounts.","Minted tokens are transferred to a pool account owned by the compressed","token program. The instruction creates one compressed output account for","every amount and pubkey input pair. A constant amount of lamports can be","transferred to each output account to enable. A use case to add lamports","to a compressed token account is to prevent spam. This is the only way","to add lamports to a compressed token account."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0,docs:["programs"]},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"merkleTree",isMut:1,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0},{name:"solPoolPda",isMut:1,isSigner:0,isOptional:1}],args:[{name:"publicKeys",type:{vec:"publicKey"}},{name:"amounts",type:{vec:"u64"}},{name:"lamports",type:{option:"u64"}}]},{name:"compressSplTokenAccount",docs:["Compresses the balance of an spl token account sub an optional remaining","amount. This instruction does not close the spl token account. To close","the account bundle a close spl account instruction in your transaction."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"owner",type:"publicKey"},{name:"remainingAmount",type:{option:"u64"}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}}]},{name:"transfer",docs:["Transfers compressed tokens from one account to another. All accounts","must be of the same mint. Additional spl tokens can be compressed or","decompressed. In one transaction only compression or decompression is","possible. Lamports can be transferred alongside tokens. If output token","accounts specify less lamports than inputs the remaining lamports are","transferred to an output compressed account. Signer must be owner or","delegate. If a delegated token account is transferred the delegate is","not preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"approve",docs:["Delegates an amount to a delegate. A compressed token account is either","completely delegated or not. Prior delegates are not preserved. Cannot","be called by a delegate.","The instruction creates two output accounts:","1. one account with delegated amount","2. one account with remaining(change) amount"],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"revoke",docs:["Revokes a delegation. The instruction merges all inputs into one output","account. Cannot be called by a delegate. Delegates are not preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"freeze",docs:["Freezes compressed token accounts. Inputs must not be frozen. Creates as","many outputs as inputs. Balances and delegates are preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["that this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"thaw",docs:["Thaws frozen compressed token accounts. Inputs must be frozen. Creates","as many outputs as inputs. Balances and delegates are preserved."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["that this program is the signer of the cpi."]},{name:"systemProgram",isMut:0,isSigner:0},{name:"mint",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"burn",docs:["Burns compressed tokens and spl tokens from the pool account. Delegates","can burn tokens. The output compressed token account remains delegated.","Creates one output compressed token account."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"mint",isMut:1,isSigner:0},{name:"tokenPoolPda",isMut:1,isSigner:0},{name:"tokenProgram",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs",type:"bytes"}]},{name:"stubIdlBuild",docs:["This function is a stub to allow Anchor to include the input types in","the IDL. It should not be included in production builds nor be called in","practice."],accounts:[{name:"feePayer",isMut:1,isSigner:1,docs:["UNCHECKED: only pays fees."]},{name:"authority",isMut:0,isSigner:1,docs:["Authority is verified through proof since both owner and delegate","are included in the token data hash, which is a public input to the","validity proof."]},{name:"cpiAuthorityPda",isMut:0,isSigner:0},{name:"lightSystemProgram",isMut:0,isSigner:0},{name:"registeredProgramPda",isMut:0,isSigner:0},{name:"noopProgram",isMut:0,isSigner:0},{name:"accountCompressionAuthority",isMut:0,isSigner:0},{name:"accountCompressionProgram",isMut:0,isSigner:0},{name:"selfProgram",isMut:0,isSigner:0,docs:["this program is the signer of the cpi."]},{name:"tokenPoolPda",isMut:1,isSigner:0,isOptional:1},{name:"compressOrDecompressTokenAccount",isMut:1,isSigner:0,isOptional:1},{name:"tokenProgram",isMut:0,isSigner:0,isOptional:1},{name:"systemProgram",isMut:0,isSigner:0}],args:[{name:"inputs1",type:{defined:"CompressedTokenInstructionDataTransfer"}},{name:"inputs2",type:{defined:"TokenData"}}]}],types:[{name:"AccountState",type:{kind:"enum",variants:[{name:"Initialized"},{name:"Frozen"}]}},{name:"CompressedAccount",type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"lamports",type:"u64"},{name:"address",type:{option:{array:["u8",32]}}},{name:"data",type:{option:{defined:"CompressedAccountData"}}}]}},{name:"CompressedAccountData",type:{kind:"struct",fields:[{name:"discriminator",type:{array:["u8",8]}},{name:"data",type:"bytes"},{name:"dataHash",type:{array:["u8",32]}}]}},{name:"CompressedCpiContext",type:{kind:"struct",fields:[{name:"setContext",docs:["Is set by the program that is invoking the CPI to signal that is should","set the cpi context."],type:"bool"},{name:"firstSetContext",docs:["Is set to wipe the cpi context since someone could have set it before","with unrelated data."],type:"bool"},{name:"cpiContextAccountIndex",docs:["Index of cpi context account in remaining accounts."],type:"u8"}]}},{name:"CompressedProof",type:{kind:"struct",fields:[{name:"a",type:{array:["u8",32]}},{name:"b",type:{array:["u8",64]}},{name:"c",type:{array:["u8",32]}}]}},{name:"CompressedTokenInstructionDataTransfer",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"mint",type:"publicKey"},{name:"delegatedTransfer",docs:["Is required if the signer is delegate,","-> delegate is authority account,","owner = Some(owner) is the owner of the token account."],type:{option:{defined:"DelegatedTransfer"}}},{name:"inputTokenDataWithContext",type:{vec:{defined:"InputTokenDataWithContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"PackedTokenTransferOutputData"}}},{name:"isCompress",type:"bool"},{name:"compressOrDecompressAmount",type:{option:"u64"}},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}},{name:"lamportsChangeAccountMerkleTreeIndex",type:{option:"u8"}}]}},{name:"DelegatedTransfer",docs:["Struct to provide the owner when the delegate is signer of the transaction."],type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"delegateChangeAccountIndex",docs:["Index of change compressed account in output compressed accounts. In","case that the delegate didn't spend the complete delegated compressed","account balance the change compressed account will be delegated to her","as well."],type:{option:"u8"}}]}},{name:"InputTokenDataWithContext",type:{kind:"struct",fields:[{name:"amount",type:"u64"},{name:"delegateIndex",type:{option:"u8"}},{name:"merkleContext",type:{defined:"PackedMerkleContext"}},{name:"rootIndex",type:"u16"},{name:"lamports",type:{option:"u64"}},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}},{name:"InstructionDataInvoke",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"inputCompressedAccountsWithMerkleContext",type:{vec:{defined:"PackedCompressedAccountWithMerkleContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"relayFee",type:{option:"u64"}},{name:"newAddressParams",type:{vec:{defined:"NewAddressParamsPacked"}}},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"isCompress",type:"bool"}]}},{name:"InstructionDataInvokeCpi",type:{kind:"struct",fields:[{name:"proof",type:{option:{defined:"CompressedProof"}}},{name:"newAddressParams",type:{vec:{defined:"NewAddressParamsPacked"}}},{name:"inputCompressedAccountsWithMerkleContext",type:{vec:{defined:"PackedCompressedAccountWithMerkleContext"}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"relayFee",type:{option:"u64"}},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"isCompress",type:"bool"},{name:"cpiContext",type:{option:{defined:"CompressedCpiContext"}}}]}},{name:"MerkleTreeSequenceNumber",type:{kind:"struct",fields:[{name:"pubkey",type:"publicKey"},{name:"seq",type:"u64"}]}},{name:"NewAddressParamsPacked",type:{kind:"struct",fields:[{name:"seed",type:{array:["u8",32]}},{name:"addressQueueAccountIndex",type:"u8"},{name:"addressMerkleTreeAccountIndex",type:"u8"},{name:"addressMerkleTreeRootIndex",type:"u16"}]}},{name:"OutputCompressedAccountWithPackedContext",type:{kind:"struct",fields:[{name:"compressedAccount",type:{defined:"CompressedAccount"}},{name:"merkleTreeIndex",type:"u8"}]}},{name:"PackedCompressedAccountWithMerkleContext",type:{kind:"struct",fields:[{name:"compressedAccount",type:{defined:"CompressedAccount"}},{name:"merkleContext",type:{defined:"PackedMerkleContext"}},{name:"rootIndex",docs:["Index of root used in inclusion validity proof."],type:"u16"},{name:"readOnly",docs:["Placeholder to mark accounts read-only unimplemented set to false."],type:"bool"}]}},{name:"PackedMerkleContext",type:{kind:"struct",fields:[{name:"merkleTreePubkeyIndex",type:"u8"},{name:"nullifierQueuePubkeyIndex",type:"u8"},{name:"leafIndex",type:"u32"},{name:"queueIndex",type:{option:{defined:"QueueIndex"}}}]}},{name:"PackedTokenTransferOutputData",type:{kind:"struct",fields:[{name:"owner",type:"publicKey"},{name:"amount",type:"u64"},{name:"lamports",type:{option:"u64"}},{name:"merkleTreeIndex",type:"u8"},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}},{name:"PublicTransactionEvent",type:{kind:"struct",fields:[{name:"inputCompressedAccountHashes",type:{vec:{array:["u8",32]}}},{name:"outputCompressedAccountHashes",type:{vec:{array:["u8",32]}}},{name:"outputCompressedAccounts",type:{vec:{defined:"OutputCompressedAccountWithPackedContext"}}},{name:"outputLeafIndices",type:{vec:"u32"}},{name:"sequenceNumbers",type:{vec:{defined:"MerkleTreeSequenceNumber"}}},{name:"relayFee",type:{option:"u64"}},{name:"isCompress",type:"bool"},{name:"compressOrDecompressLamports",type:{option:"u64"}},{name:"pubkeyArray",type:{vec:"publicKey"}},{name:"message",type:{option:"bytes"}}]}},{name:"QueueIndex",type:{kind:"struct",fields:[{name:"queueId",docs:["Id of queue in queue account."],type:"u8"},{name:"index",docs:["Index of compressed account hash in queue."],type:"u16"}]}},{name:"TokenData",type:{kind:"struct",fields:[{name:"mint",docs:["The mint associated with this account"],type:"publicKey"},{name:"owner",docs:["The owner of this account."],type:"publicKey"},{name:"amount",docs:["The amount of tokens this account holds."],type:"u64"},{name:"delegate",docs:["If `delegate` is `Some` then `delegated_amount` represents","the amount authorized by the delegate"],type:{option:"publicKey"}},{name:"state",docs:["The account's state"],type:{defined:"AccountState"}},{name:"tlv",docs:["Placeholder for TokenExtension tlv data (unimplemented)"],type:{option:"bytes"}}]}}],errors:[{code:6e3,name:"PublicKeyAmountMissmatch",msg:"public keys and amounts must be of same length"},{code:6001,name:"ComputeInputSumFailed",msg:"ComputeInputSumFailed"},{code:6002,name:"ComputeOutputSumFailed",msg:"ComputeOutputSumFailed"},{code:6003,name:"ComputeCompressSumFailed",msg:"ComputeCompressSumFailed"},{code:6004,name:"ComputeDecompressSumFailed",msg:"ComputeDecompressSumFailed"},{code:6005,name:"SumCheckFailed",msg:"SumCheckFailed"},{code:6006,name:"DecompressRecipientUndefinedForDecompress",msg:"DecompressRecipientUndefinedForDecompress"},{code:6007,name:"CompressedPdaUndefinedForDecompress",msg:"CompressedPdaUndefinedForDecompress"},{code:6008,name:"DeCompressAmountUndefinedForDecompress",msg:"DeCompressAmountUndefinedForDecompress"},{code:6009,name:"CompressedPdaUndefinedForCompress",msg:"CompressedPdaUndefinedForCompress"},{code:6010,name:"DeCompressAmountUndefinedForCompress",msg:"DeCompressAmountUndefinedForCompress"},{code:6011,name:"DelegateSignerCheckFailed",msg:"DelegateSignerCheckFailed"},{code:6012,name:"MintTooLarge",msg:"Minted amount greater than u64::MAX"},{code:6013,name:"SplTokenSupplyMismatch",msg:"SplTokenSupplyMismatch"},{code:6014,name:"HeapMemoryCheckFailed",msg:"HeapMemoryCheckFailed"},{code:6015,name:"InstructionNotCallable",msg:"The instruction is not callable"},{code:6016,name:"ArithmeticUnderflow",msg:"ArithmeticUnderflow"},{code:6017,name:"HashToFieldError",msg:"HashToFieldError"},{code:6018,name:"InvalidAuthorityMint",msg:"Expected the authority to be also a mint authority"},{code:6019,name:"InvalidFreezeAuthority",msg:"Provided authority is not the freeze authority"},{code:6020,name:"InvalidDelegateIndex"},{code:6021,name:"TokenPoolPdaUndefined"},{code:6022,name:"IsTokenPoolPda",msg:"Compress or decompress recipient is the same account as the token pool pda."},{code:6023,name:"InvalidTokenPoolPda"},{code:6024,name:"NoInputTokenAccountsProvided"},{code:6025,name:"NoInputsProvided"},{code:6026,name:"MintHasNoFreezeAuthority"},{code:6027,name:"MintWithInvalidExtension"},{code:6028,name:"InsufficientTokenAccountBalance",msg:"The token account balance is less than the remaining amount."},{code:6029,name:"InvalidTokenPoolBump",msg:"Max number of token pools reached."},{code:6030,name:"FailedToDecompress"},{code:6031,name:"FailedToBurnSplTokensFromTokenPool"},{code:6032,name:"NoMatchingBumpFound"}]},exports.MINT_TO_DISCRIMINATOR=u,exports.POOL_SEED=o,exports.SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE=1461600,exports.TRANSFER_DISCRIMINATOR=h,exports.approveAndMintTo=async function(n,i,o,s,a,u,h,m,l){l=l||await Lt.get_mint_program_id(o,n);const c=await r.getOrCreateAssociatedTokenAccount(n,i,o,a.publicKey,void 0,void 0,m,l),p=await Lt.approveAndMintTo({feePayer:i.publicKey,mint:o,authority:a.publicKey,authorityTokenAccount:c.address,amount:u,toPubkey:s,merkleTree:h,tokenProgramId:l}),{blockhash:d}=await n.getLatestBlockhash(),f=t.dedupeSigner(i,[a]),g=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),...p],i,d,f);return await t.sendAndConfirmTx(n,g,m)},exports.compress=async function(r,n,i,o,s,a,u,h,m,l){l=l||await Lt.get_mint_program_id(i,r);const c=await Lt.compress({payer:n.publicKey,owner:s.publicKey,source:a,toAddress:u,amount:o,mint:i,outputStateTree:h,tokenProgramId:l}),p=await r.getLatestBlockhash(),d=t.dedupeSigner(n,[s]),f=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),c],n,p.blockhash,d);return await t.sendAndConfirmTx(r,f,m,p)},exports.compressSplTokenAccount=async function(r,n,i,o,s,a,u,h,m){m=m||await Lt.get_mint_program_id(i,r);const l=await Lt.compressSplTokenAccount({feePayer:n.publicKey,authority:o.publicKey,tokenAccount:s,mint:i,remainingAmount:u,outputStateTree:a,tokenProgramId:m}),c=await r.getLatestBlockhash(),p=t.dedupeSigner(n,[o]),d=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),l],n,c.blockhash,p);return await t.sendAndConfirmTx(r,d,h,c)},exports.compressSplTokenAccountInstructionDataLayout=At,exports.createDecompressOutputState=Bt,exports.createMint=async function(n,i,o,s,a=e.Keypair.generate(),u,h=0){const m=await n.getMinimumBalanceForRentExemption(r.MINT_SIZE),l=h?r.TOKEN_2022_PROGRAM_ID:r.TOKEN_PROGRAM_ID,c=await Lt.createMint({feePayer:i.publicKey,mint:a.publicKey,decimals:s,authority:o,freezeAuthority:null,rentExemptBalance:m,tokenProgramId:l}),{blockhash:p}=await n.getLatestBlockhash(),d=t.dedupeSigner(i,[a]),f=t.buildAndSignTx(c,i,p,d),g=await t.sendAndConfirmTx(n,f,u);return{mint:a.publicKey,transactionSignature:g}},exports.createTokenPool=async function(e,r,n,i,o){o=o||await Lt.get_mint_program_id(n,e);const s=await Lt.createTokenPool({feePayer:r.publicKey,mint:n,tokenProgramId:o}),{blockhash:a}=await e.getLatestBlockhash(),u=t.buildAndSignTx([s],r,a);return await t.sendAndConfirmTx(e,u,i)},exports.createTokenPoolAccountsLayout=It,exports.createTokenProgramLookupTable=async function(e,r,n,i,o){const s=await e.getSlot("finalized"),{instructions:a,address:u}=await Lt.createTokenProgramLookupTable({payer:r.publicKey,authority:n.publicKey,mints:i,remainingAccounts:o,recentSlot:s}),h=t.dedupeSigner(r,[n]),m=await e.getLatestBlockhash(),l=t.buildAndSignTx([a[0]],r,m.blockhash,h),c=await t.sendAndConfirmTx(e,l,{commitment:"finalized"},m),p=await e.getLatestBlockhash(),d=t.buildAndSignTx([a[1]],r,p.blockhash,h);return{txIds:[c,await t.sendAndConfirmTx(e,d,{commitment:"finalized"},p)],address:u}},exports.createTransferOutputState=Dt,exports.decodeCompressSplTokenAccountInstructionData=function(t){const e=At.decode(t.slice(m.length));return{owner:e.owner,remainingAmount:e.remainingAmount,cpiContext:e.cpiContext}},exports.decodeMintToInstructionData=function(t){const e=kt.decode(t.slice(u.length));return{recipients:e.recipients,amounts:e.amounts,lamports:e.lamports}},exports.decodeTransferInstructionData=function(t){return Pt.decode(t.slice(h.length+4))},exports.decompress=async function(r,n,i,o,s,a,u,h,m){m=m||await Lt.get_mint_program_id(i,r),o=t.bn(o);const l=await r.getCompressedTokenAccountsByOwner(s.publicKey,{mint:i}),[c]=Ut(l.items,o),p=await r.getValidityProof(c.map((e=>t.bn(e.compressedAccount.hash)))),d=await Lt.decompress({payer:n.publicKey,inputCompressedTokenAccounts:c,toAddress:a,amount:o,outputStateTree:u,recentInputStateRootIndices:p.rootIndices,recentValidityProof:p.compressedProof,tokenProgramId:m}),{blockhash:f}=await r.getLatestBlockhash(),g=t.dedupeSigner(n,[s]),y=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),d],n,f,g);return await t.sendAndConfirmTx(r,y,h)},exports.encodeCompressSplTokenAccountInstructionData=Tt,exports.encodeMintToInstructionData=St,exports.encodeTransferInstructionData=Ct,exports.mergeTokenAccounts=async function(r,n,i,o,s,a){const u=await r.getCompressedTokenAccountsByOwner(o.publicKey,{mint:i});if(0===u.items.length)throw new Error(`No compressed token accounts found for mint ${i.toBase58()}`);if(u.items.length>=6)throw new Error(`Too many compressed token accounts used for mint ${i.toBase58()}`);const h=[e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6})];for(let e=0;e<u.items.slice(0,6).length;e+=3){const a=u.items.slice(e,e+3),m=await r.getValidityProof(a.map((e=>t.bn(e.compressedAccount.hash)))),l=await Lt.mergeTokenAccounts({payer:n.publicKey,owner:o.publicKey,mint:i,inputCompressedTokenAccounts:a,outputStateTree:s,recentValidityProof:m.compressedProof,recentInputStateRootIndices:m.rootIndices});h.push(...l)}const{blockhash:m}=await r.getLatestBlockhash(),l=t.dedupeSigner(n,[o]),c=t.buildAndSignTx(h,n,m,l);return await t.sendAndConfirmTx(r,c,a)},exports.mintTo=async function(r,n,i,o,s,a,u,h,m){m=m||await Lt.get_mint_program_id(i,r);const l=t.dedupeSigner(n,[s]),c=await Lt.mintTo({feePayer:n.publicKey,mint:i,authority:s.publicKey,amount:a,toPubkey:o,merkleTree:u,tokenProgramId:m}),{blockhash:p}=await r.getLatestBlockhash(),d=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),c],n,p,l);return await t.sendAndConfirmTx(r,d,h)},exports.mintToAccountsLayout=_t,exports.mintToLayout=kt,exports.packCompressedTokenAccounts=i,exports.parseTokenData=Ot,exports.selectMinCompressedTokenAccountsForTransfer=Ut,exports.sumUpTokenAmount=Et,exports.transfer=async function(r,n,i,o,s,a,u,h){o=t.bn(o);const m=await r.getCompressedTokenAccountsByOwner(s.publicKey,{mint:i}),[l]=Ut(m.items,o),c=await r.getValidityProof(l.map((e=>t.bn(e.compressedAccount.hash)))),p=await Lt.transfer({payer:n.publicKey,inputCompressedTokenAccounts:l,toAddress:a,amount:o,recentInputStateRootIndices:c.rootIndices,recentValidityProof:c.compressedProof,outputStateTrees:u}),{blockhash:d}=await r.getLatestBlockhash(),f=t.dedupeSigner(n,[s]),g=t.buildAndSignTx([e.ComputeBudgetProgram.setComputeUnitLimit({units:1e6}),p],n,d,f);return await t.sendAndConfirmTx(r,g,h)},exports.transferAccountsLayout=xt,exports.validateSameTokenOwner=Rt;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|