factom
Version:
Library to build applications on the Factom blockchain
2 lines • 86.5 kB
JavaScript
/*! For license information please see factom-struct.js.LICENSE.txt */
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports["factom-struct"]=r():t["factom-struct"]=r()}(self,(function(){return(()=>{var t={7228:t=>{t.exports=function(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n},t.exports.default=t.exports,t.exports.__esModule=!0},9873:(t,r,e)=>{var n=e(7228);t.exports=function(t){if(Array.isArray(t))return n(t)},t.exports.default=t.exports,t.exports.__esModule=!0},8926:t=>{function r(t,r,e,n,i,o,s){try{var h=t[o](s),u=h.value}catch(t){return void e(t)}h.done?r(u):Promise.resolve(u).then(n,i)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(i,o){var s=t.apply(e,n);function h(t){r(s,i,o,h,u,"next",t)}function u(t){r(s,i,o,h,u,"throw",t)}h(void 0)}))}},t.exports.default=t.exports,t.exports.__esModule=!0},4575:t=>{t.exports=function(t,r){if(!(t instanceof r))throw new TypeError("Cannot call a class as a function")},t.exports.default=t.exports,t.exports.__esModule=!0},3913:t=>{function r(t,r){for(var e=0;e<r.length;e++){var n=r[e];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t},t.exports.default=t.exports,t.exports.__esModule=!0},5318:t=>{t.exports=function(t){return t&&t.__esModule?t:{default:t}},t.exports.default=t.exports,t.exports.__esModule=!0},6860:t=>{t.exports=function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)},t.exports.default=t.exports,t.exports.__esModule=!0},8206:t=>{t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.default=t.exports,t.exports.__esModule=!0},319:(t,r,e)=>{var n=e(9873),i=e(6860),o=e(379),s=e(8206);t.exports=function(t){return n(t)||i(t)||o(t)||s()},t.exports.default=t.exports,t.exports.__esModule=!0},8:t=>{function r(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(t.exports=r=function(t){return typeof t},t.exports.default=t.exports,t.exports.__esModule=!0):(t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.default=t.exports,t.exports.__esModule=!0),r(e)}t.exports=r,t.exports.default=t.exports,t.exports.__esModule=!0},379:(t,r,e)=>{var n=e(7228);t.exports=function(t,r){if(t){if("string"==typeof t)return n(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?n(t,r):void 0}},t.exports.default=t.exports,t.exports.__esModule=!0},7757:(t,r,e)=>{t.exports=e(5666)},8092:(t,r,e)=>{"use strict";var n=e(6177),i=e(780),o=e(4420),s=o.RCD_TYPE_1,h=o.secretToPublicKey,u=o.sha256d,a=e(5694),f=a.FACTOID_PUBLIC_PREFIX,c=a.FACTOID_PRIVATE_PREFIX,l=a.ENTRYCREDIT_PUBLIC_PREFIX,d=a.ENTRYCREDIT_PRIVATE_PREFIX,g=a.VALID_PREFIXES,p=a.PUBLIC_ADDRESS_VALID_PREFIXES,y=a.PRIVATE_ADDRESS_VALID_PREFIXES,v=a.EC_ADDRESS_VALID_PREFIXES,m=a.FCT_ADDRESS_VALID_PREFIXES;function w(t){try{if(!g.has(t.slice(0,2)))return!1;var r=Buffer.from(n.decode(t));return 38===r.length&&!!u(r.slice(0,34)).slice(0,4).equals(r.slice(34,38))}catch(t){return!1}}function _(t){return w(t)&&"FA"===t.substring(0,2)}function E(t){return I(t,f,!0)}function b(t){return I(t,c)}function x(t){return I(t,l)}function A(t){return I(t,d)}function I(t,r,e){var i=Buffer.from(t,"hex");if(32!==i.length)throw new Error("Key ".concat(i," is not 32 bytes long."));var o=Buffer.concat([r,e?S(i):i]),s=u(o).slice(0,4);return n.encode(Buffer.concat([o,s]))}function S(t){return u(Buffer.concat([s,t]))}t.exports={isValidAddress:w,addressToKey:function(t){if(!w(t))throw new Error("Invalid address ".concat(t,"."));if(t.startsWith("FA"))throw new Error("A public Factoid address does not hold a public key but a RCD hash. Use addressToRcdHash function instead.");return Buffer.from(n.decode(t).slice(2,34))},addressToRcdHash:function(t){if(!_(t))throw new Error("Address ".concat(t," is not a valid public Factoid address"));return Buffer.from(n.decode(t).slice(2,34))},isValidPublicAddress:function(t){return w(t)&&p.has(t.substring(0,2))},isValidPrivateAddress:function(t){return w(t)&&y.has(t.substring(0,2))},isValidEcAddress:function(t){return w(t)&&v.has(t.substring(0,2))},isValidPublicEcAddress:function(t){return w(t)&&"EC"===t.substring(0,2)},isValidPrivateEcAddress:function(t){return w(t)&&"Es"===t.substring(0,2)},isValidFctAddress:function(t){return w(t)&&m.has(t.substring(0,2))},isValidPublicFctAddress:_,isValidPrivateFctAddress:function(t){return w(t)&&"Fs"===t.substring(0,2)},getPublicAddress:function(t){if(!w(t))throw new Error("Invalid address ".concat(t,"."));if("s"!==t[1])return t;var r=n.decode(t).slice(2,34),e=h(r);return"F"===t[0]?E(e):x(e)},keyToPublicFctAddress:E,rcdHashToPublicFctAddress:function(t){return I(t,f)},seedToPrivateFctAddress:b,keyToPublicEcAddress:x,seedToPrivateEcAddress:A,generateRandomFctAddress:function(){var t=i.randomBytes(32);return{public:E(i.sign.keyPair.fromSeed(t).publicKey),private:b(t)}},generateRandomEcAddress:function(){var t=i.randomBytes(32);return{public:x(i.sign.keyPair.fromSeed(t).publicKey),private:A(t)}}}},5299:(t,r,e)=>{"use strict";var n=e(5318),i=n(e(7757)),o=n(e(8926)),s=n(e(4575)),h=n(e(3913)),u=e(780).sign,a=e(8092),f=a.addressToKey,c=a.isValidPrivateEcAddress,l=a.isValidPublicEcAddress,d=e(636).Entry,g=e(4420),p=g.sha256,y=g.sha256d,v=e(5694),m=v.CHAIN_CREATION_COST,w=v.CHAIN_REGEX,_=function(){function t(r){if((0,s.default)(this,t),r instanceof d){var e=R(r);this.firstEntry=d.builder(r).chainId(e).build(),this.id=e}else{if(!(r.firstEntry instanceof d))throw new Error("Argument of Chain constructor must be an instance of Entry or Chain.");var n=R(r.firstEntry);this.firstEntry=d.builder(r.firstEntry).chainId(n).build(),this.id=n}Object.freeze(this)}return(0,h.default)(t,[{key:"idHex",get:function(){return this.id.toString("hex")}},{key:"ecCost",value:function(){return m+this.firstEntry.ecCost()}},{key:"toObject",value:function(){return{firstEntry:this.firstEntry.toObject(),id:this.idHex}}}]),t}();function E(t,r,e){B(t);var n,i,o=A(t);if(c(r)){var s=f(r),h=u.keyPair.fromSeed(s);n=Buffer.from(h.publicKey),i=Buffer.from(u.detached(o,h.secretKey))}else{if(!l(r))throw new Error("".concat(r," is not a valid EC address"));if(!e)throw new Error("Signature of the commit missing.");if(console.warn("composeChainCommit with signature is deprecated. Use composeEntryCommitDelegateSig."),n=f(r),i=Buffer.from(e,"hex"),!u.detached.verify(o,i,n))throw new Error("Invalid signature manually provided for the chain commit. (first entry timestamp not fixed?)")}return Buffer.concat([o,n,i])}function b(t,r,e){return x.apply(this,arguments)}function x(){return(x=(0,o.default)(i.default.mark((function t(r,e,n){var o,s,h;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(B(r),l(e)){t.next=3;break}throw new Error("".concat(e," is not a valid public EC address"));case 3:if("function"==typeof n){t.next=5;break}throw new Error("sign must be a function");case 5:return o=A(r),t.t0=Buffer,t.next=9,n(o,e);case 9:if(t.t1=t.sent,s=t.t0.from.call(t.t0,t.t1,"hex"),h=f(e),u.detached.verify(o,s,h)){t.next=14;break}throw new Error("Invalid signature manually returned by the signing function for the chain commit.");case 14:return t.abrupt("return",Buffer.concat([o,h,s]));case 15:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function A(t){B(t);var r=t.firstEntry,e=r.hash(),n=Buffer.alloc(104);return n.writeInt8(0),n.writeIntBE(r.timestamp||Date.now(),1,6),y(t.id).copy(n,7),y(Buffer.concat([e,t.id])).copy(n,39),e.copy(n,71),n.writeInt8(t.ecCost(),103),n}function I(t){return B(t),t.firstEntry.marshalBinary()}function S(){return(S=(0,o.default)(i.default.mark((function t(r,e,n){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,b(r,e,n);case 2:return t.t0=t.sent,t.t1=I(r),t.abrupt("return",{commit:t.t0,reveal:t.t1});case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function B(t){if(!(t instanceof _))throw new Error("Argument must be an instance of Chain")}function R(t){var r=t.extIds.map(p),e=Buffer.concat(r);return p(e)}t.exports={Chain:_,computeChainTxId:function(t){return B(t),p(A(t))},computeChainId:R,composeChainCommit:E,composeChainCommitDelegateSig:b,composeChainReveal:I,composeChain:function(t,r,e){return{commit:E(t,r,e),reveal:I(t)}},composeChainDelegateSig:function(t,r,e){return S.apply(this,arguments)},composeChainLedger:A,validateChainInstance:B,isValidChainId:function(t){return"string"==typeof t&&t.match(w)}}},5694:t=>{"use strict";var r="000000000000000000000000000000000000000000000000000000000000000a",e="000000000000000000000000000000000000000000000000000000000000000c",n="000000000000000000000000000000000000000000000000000000000000000f",i=new Map([[1,"DIRECTORY_BLOCK_SIGNATURE"],[2,"REVEAL_MATRYOSHKA_HASH"],[3,"ADD_REPLACE_MATRYOSHKA_HASH"],[4,"INCREASE_SERVER_COUNT"],[5,"ADD_FEDERATED_SERVER"],[6,"ADD_AUDIT_SERVER"],[7,"REMOVE_FEDERATED_SERVER"],[8,"ADD_FEDERATED_SERVER_SIGNING_KEY"],[9,"ADD_FEDERATED_SERVER_BITCOIN_ANCHOR_KEY"],[10,"SERVER_FAULT_HANDOFF"],[11,"COINBASE_DESCRIPTOR"],[12,"COINBASE_DESCRIPTOR_CANCEL"],[13,"ADD_AUTHORITY_FACTOID_ADDRESS"],[14,"ADD_AUTHORITY_EFFICIENCY"]]);t.exports={MAX_TRANSACTION_SIZE:10240,MAX_ENTRY_PAYLOAD_SIZE:10240,MAX_ENTRY_SIZE:10275,CHAIN_CREATION_COST:10,NULL_HASH:"0000000000000000000000000000000000000000000000000000000000000000",ADMIN_BLOCKS_CHAIN_ID:r,ENTRY_CREDIT_BLOCKS_CHAIN_ID:e,FACTOID_BLOCKS_CHAIN_ID:n,RESERVED_CHAIN_IDS:new Set([r,e,n]),VALID_PREFIXES:new Set(["Fs","FA","EC","Es"]),PUBLIC_ADDRESS_VALID_PREFIXES:new Set(["FA","EC"]),PRIVATE_ADDRESS_VALID_PREFIXES:new Set(["Fs","Es"]),EC_ADDRESS_VALID_PREFIXES:new Set(["EC","Es"]),FCT_ADDRESS_VALID_PREFIXES:new Set(["FA","Fs"]),FACTOID_PUBLIC_PREFIX:Buffer.from("5fb1","hex"),FACTOID_PRIVATE_PREFIX:Buffer.from("6478","hex"),ENTRYCREDIT_PUBLIC_PREFIX:Buffer.from("592a","hex"),ENTRYCREDIT_PRIVATE_PREFIX:Buffer.from("5db6","hex"),ADMIN_ID_TO_CODE:i,CHAIN_REGEX:/\b[A-Fa-f0-9]{64}\b/}},636:(t,r,e)=>{"use strict";var n=e(5318),i=n(e(7757)),o=n(e(8926)),s=n(e(4575)),h=n(e(3913));function u(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}var a=e(780).sign,f=e(8092),c=f.addressToKey,l=f.isValidPrivateEcAddress,d=f.isValidPublicEcAddress,g=e(5694).MAX_ENTRY_PAYLOAD_SIZE,p=e(4420),y=p.sha256,v=p.sha512,m=function(){function t(r){if((0,s.default)(this,t),!(r instanceof w))throw new Error("Use `Entry.builder()` syntax to create a new Entry");this.chainId=r._chainId,this.content=r._content,this.timestamp=r._timestamp,this.extIds=Object.freeze(r._extIds),this.blockContext=Object.freeze(r._blockContext),Object.freeze(this)}return(0,h.default)(t,[{key:"chainIdHex",get:function(){return this.chainId.toString("hex")}},{key:"contentHex",get:function(){return this.content.toString("hex")}},{key:"extIdsHex",get:function(){return this.extIds.map((function(t){return t.toString("hex")}))}},{key:"size",value:function(){return 35+this.payloadSize()}},{key:"payloadSize",value:function(){return this.rawDataSize()+2*this.extIds.length}},{key:"rawDataSize",value:function(){return this.content.length+this.extIds.reduce((function(t,r){return t+r.length}),0)}},{key:"remainingFreeBytes",value:function(){var t=this.payloadSize();if(0===t)return 1024;var r=t%1024;return r?1024-r:0}},{key:"remainingMaxBytes",value:function(){var t=g-this.payloadSize();if(t<0)throw new Error("Entry cannot be larger than 10Kb");return t}},{key:"hash",value:function(){var t=this.marshalBinary();return y(Buffer.concat([v(t),t]))}},{key:"hashHex",value:function(){return this.hash().toString("hex")}},{key:"marshalBinary",value:function(){if(0===this.chainId.length)throw new Error("ChainId is missing to marshal the entry");var t=function(t){var r,e=[],n=function(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return u(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?u(t,r):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,h=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return s=t.done,t},e:function(t){h=!0,o=t},f:function(){try{s||null==e.return||e.return()}finally{if(h)throw o}}}}(t);try{for(n.s();!(r=n.n()).done;){var i=r.value,o=Buffer.alloc(2);o.writeInt16BE(i.length),e.push(o),e.push(i)}}catch(t){n.e(t)}finally{n.f()}return Buffer.concat(e)}(this.extIds),r=function(t,r){var e=Buffer.alloc(35);return e.writeInt8(0),t.copy(e,1),e.writeInt16BE(r,33),e}(this.chainId,t.length);return Buffer.concat([r,t,this.content])}},{key:"marshalBinaryHex",value:function(){return this.marshalBinary().toString("hex")}},{key:"ecCost",value:function(){var t=this.payloadSize();if(t>g)throw new Error("Entry cannot be larger than 10Kb");return Math.ceil(t/1024)}},{key:"toObject",value:function(){var t={chainId:this.chainIdHex,extIds:this.extIdsHex,content:this.contentHex};return this.timestamp&&(t.timestamp=this.timestamp),t}}],[{key:"builder",value:function(t){return new w(t)}}]),t}(),w=function(){function t(r){(0,s.default)(this,t),r instanceof Object?(this._chainId=r.chainId?Buffer.from(r.chainId,"hex"):Buffer.from(""),this._extIds=Array.isArray(r.extIds)?r.extIds.map((function(t){return Buffer.from(t,"hex")})):[],this._content=r.content?Buffer.from(r.content,"hex"):Buffer.from(""),this._timestamp=r.timestamp):(this._extIds=[],this._content=Buffer.from(""),this._chainId=Buffer.from(""))}return(0,h.default)(t,[{key:"content",value:function(t,r){return t&&(this._content=Buffer.from(t,r||"hex")),this}},{key:"chainId",value:function(t,r){return t&&(this._chainId=Buffer.from(t,r||"hex")),this}},{key:"extIds",value:function(t,r){return Array.isArray(t)&&(this._extIds=t.map((function(t){return Buffer.from(t,r||"hex")}))),this}},{key:"extId",value:function(t,r){return t&&this._extIds.push(Buffer.from(t,r||"hex")),this}},{key:"timestamp",value:function(t){return this._timestamp=t,this}},{key:"blockContext",value:function(t){return this._blockContext=t,this}},{key:"build",value:function(){return new m(this)}}]),t}();function _(t,r,e){S(t);var n,i,o=x(t);if(l(r)){var s=c(r),h=a.keyPair.fromSeed(s);n=Buffer.from(h.publicKey),i=Buffer.from(a.detached(o,h.secretKey))}else{if(!d(r))throw new Error("".concat(r," is not a valid EC address"));if(!e)throw new Error("Signature of the commit missing.");if(console.warn("composeEntryCommit with signature is deprecated. Use composeEntryCommitDelegateSig."),n=c(r),i=Buffer.from(e,"hex"),!a.detached.verify(o,i,n))throw new Error("Invalid signature manually provided for the entry commit. (entry timestamp not fixed?)")}return Buffer.concat([o,n,i])}function E(t,r,e){return b.apply(this,arguments)}function b(){return(b=(0,o.default)(i.default.mark((function t(r,e,n){var o,s,h;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(S(r),d(e)){t.next=3;break}throw new Error("".concat(e," is not a valid public EC address"));case 3:if("function"==typeof n){t.next=5;break}throw new Error("sign must be a function");case 5:return o=x(r),t.t0=Buffer,t.next=9,n(o,e);case 9:if(t.t1=t.sent,s=t.t0.from.call(t.t0,t.t1,"hex"),h=c(e),a.detached.verify(o,s,h)){t.next=14;break}throw new Error("Invalid signature returned by the signing function for the entry commit.");case 14:return t.abrupt("return",Buffer.concat([o,h,s]));case 15:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function x(t){S(t);var r=Buffer.alloc(40);return r.writeInt8(0),r.writeIntBE(t.timestamp||Date.now(),1,6),t.hash().copy(r,7),r.writeInt8(t.ecCost(),39),r}function A(t){return S(t),t.marshalBinary()}function I(){return(I=(0,o.default)(i.default.mark((function t(r,e,n){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,E(r,e,n);case 2:return t.t0=t.sent,t.t1=A(r),t.abrupt("return",{commit:t.t0,reveal:t.t1});case 5:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function S(t){if(!(t instanceof m))throw new Error("Argument must be an instance of Entry")}t.exports={Entry:m,computeEntryTxId:function(t){return S(t),y(x(t))},validateEntryInstance:S,composeEntryCommit:_,composeEntryCommitDelegateSig:E,composeEntryReveal:A,composeEntry:function(t,r,e){return{commit:_(t,r,e),reveal:A(t)}},composeEntryDelegateSig:function(t,r,e){return I.apply(this,arguments)},composeEntryLedger:x}},8100:(t,r,e)=>{"use strict";t.exports=Object.assign({},e(636),e(5299),e(8092),e(9672))},9672:(t,r,e)=>{"use strict";var n=e(5318),i=n(e(319)),o=n(e(8)),s=n(e(4575)),h=n(e(3913)),u=e(780).sign,a=e(6177),f=e(4420),c=f.RCD_TYPE_1,l=f.encodeVarInt,d=f.sha256,g=f.sha256d,p=f.flatMap,y=e(5694).MAX_TRANSACTION_SIZE,v=e(8092),m=v.isValidFctAddress,w=v.isValidPublicAddress,_=v.getPublicAddress,E=v.addressToKey,b=v.addressToRcdHash,x=function(){function t(r,e){if((0,s.default)(this,t),!w(r))throw new TypeError("Address must be a valid Factoid or EntryCredit public address.");!function(t){if(!Number.isSafeInteger(t))throw new Error("Amount must be a safe integer (less than 2^53 - 1).");if(t<0)throw new Error("Amount must be a positive number.")}(e),this.address=r,this.amount=e,Object.freeze(this)}return(0,h.default)(t,[{key:"marshalBinary",value:function(){return Buffer.concat([l(this.amount),Buffer.from(a.decode(this.address).slice(2,34))])}}]),t}(),A=function(){function t(r,e){var n=this;if((0,s.default)(this,t),r instanceof I)this.timestamp=r._timestamp||Date.now(),this.inputs=r._inputs,this.factoidOutputs=r._factoidOutputs,this.entryCreditOutputs=r._entryCreditOutputs,this.blockContext=e,this.marshalBinarySig=function(t,r,e,n){var o=Buffer.alloc(10);o.writeInt8(2),o.writeIntBE(t,1,6),o.writeInt8(r.length,7),o.writeInt8(e.length,8),o.writeInt8(n.length,9);var s=r.map((function(t){return t.marshalBinary()})),h=e.map((function(t){return t.marshalBinary()})),u=n.map((function(t){return t.marshalBinary()}));return Buffer.concat([o].concat((0,i.default)(s),(0,i.default)(h),(0,i.default)(u)))}(this.timestamp,this.inputs,this.factoidOutputs,this.entryCreditOutputs),this.id=d(this.marshalBinarySig).toString("hex"),0!==r._keys.length?(this.rcds=r._keys.map((function(t){return Buffer.concat([c,Buffer.from(t.publicKey)])})),this.signatures=r._keys.map((function(t){return Buffer.from(u.detached(n.marshalBinarySig,t.secretKey))}))):(this.rcds=r._rcds,this.signatures=r._signatures,0!==this.rcds.length&&0!==this.signatures.length&&(function(t,r){if(r.length!==t.length)throw new Error("The number of RCDs (".concat(r.length,") does not equal the number of inputs (").concat(t.length,")."));for(var e=0;e<r.length;++e)S(t[e],r[e])}(this.inputs,this.rcds),function(t,r,e){if(r.length!==e.length)throw new Error("The number of RCDs (".concat(r.length,") does not equal the number of signatures (").concat(e.length,")"));for(var n=0;n<e.length;++n)B(t,r[n],e[n])}(this.marshalBinarySig,this.rcds,this.signatures)));else{if("object"!==(0,o.default)(r))throw new Error("Use `Transaction.builder()` syntax to create a new Transaction.");this.id=r.txid,this.timestamp=r.millitimestamp,this.inputs=r.inputs.map((function(t){return new x(t.useraddress,t.amount)})),this.factoidOutputs=r.outputs.map((function(t){return new x(t.useraddress,t.amount)})),this.entryCreditOutputs=r.outecs.map((function(t){return new x(t.useraddress,t.amount)})),this.rcds=r.rcds.map((function(t){return Buffer.from(t,"hex")})),this.signatures=p(r.sigblocks,(function(t){return t.signatures})).map((function(t){return Buffer.from(t,"hex")})),this.blockContext=e}if(0!==this.signatures.length&&this.inputs.length!==this.signatures.length)throw new Error("All inputs must be signed or none of them.");this.totalInputs=this.inputs.reduce((function(t,r){return t+r.amount}),0),this.totalFactoidOutputs=this.factoidOutputs.reduce((function(t,r){return t+r.amount}),0),this.totalEntryCreditOutputs=this.entryCreditOutputs.reduce((function(t,r){return t+r.amount}),0);var h=this.totalFactoidOutputs+this.totalEntryCreditOutputs;if(!Number.isSafeInteger(this.totalInputs)||!Number.isSafeInteger(h))throw new Error("Total inputs/outputs are not safe integers (too big to be handled by the library).");if(0===this.totalInputs)this.feesPaid=0;else{if(!(this.totalInputs>=h))throw new Error("Sum of Transaction outputs (".concat(h,") is greater than the sum of inputs (").concat(this.totalInputs,")"));this.feesPaid=this.totalInputs-h}Object.freeze(this)}return(0,h.default)(t,[{key:"isSigned",value:function(){return 0!==this.signatures.length}},{key:"validateFees",value:function(t){return this.computeRequiredFees(t)<=this.feesPaid}},{key:"computeRequiredFees",value:function(t,r){return this.computeEcRequiredFees(r)*t}},{key:"computeEcRequiredFees",value:function(t){var r,e,n=t||{};if(this.isSigned())r=this.marshalBinary().length,e=this.signatures.length;else if("number"==typeof n.rcdSignatureLength&&"number"==typeof n.numberOfSignatures)r=this.marshalBinarySig.length+n.rcdSignatureLength,e=n.numberOfSignatures;else{if(1!==n.rcdType)throw new Error("Missing parameters to compute fees of unsigned transaction.");r=this.marshalBinarySig.length+97*this.inputs.length,e=this.inputs.length}if(r>y)throw new Error("Transaction size is bigger than the maximum (".concat(y," bytes)."));var i=Math.floor((r+1023)/1024);return(i+=10*(this.factoidOutputs.length+this.entryCreditOutputs.length))+e}},{key:"marshalBinary",value:function(){if(!this.isSigned())throw new Error("Cannot marshal an unsigned Transaction.");for(var t=[this.marshalBinarySig],r=0;r<this.rcds.length;++r)t.push(this.rcds[r]),t.push(this.signatures[r]);return Buffer.concat(t)}}],[{key:"builder",value:function(t){return new I(t)}}]),t}(),I=function(){function t(r){(0,s.default)(this,t),this._timestamp,this._inputs=[],this._factoidOutputs=[],this._entryCreditOutputs=[],this._keys=[],this._rcds=[],this._signatures=[],r instanceof A&&(this._timestamp=r.timestamp,this._inputs=r.inputs,this._factoidOutputs=r.factoidOutputs,this._entryCreditOutputs=r.entryCreditOutputs)}return(0,h.default)(t,[{key:"input",value:function(t,r){if(!m(t))throw new TypeError("First argument must be a valid Factoid address.");if(this._inputs.push(new x(_(t),r)),"s"===t[1]){var e=E(t),n=u.keyPair.fromSeed(e);this._keys.push(n)}return this}},{key:"output",value:function(t,r){var e=new x(t,r);return"F"===t[0]?this._factoidOutputs.push(e):this._entryCreditOutputs.push(e),this}},{key:"rcdSignature",value:function(t,r){return this._rcds.push(Buffer.from(t,"hex")),this._signatures.push(Buffer.from(r,"hex")),this}},{key:"timestamp",value:function(t){return this._timestamp=t,this}},{key:"build",value:function(){return new A(this)}}]),t}();function S(t,r){if(!g(r).equals(b(t.address)))throw new Error("RCD does not match the RCD hash from input address ".concat(t.address,"."))}function B(t,r,e){if(1!==r[0])throw new Error("Only RCD type 1 is currently supported. Invalid RCD: ".concat(r,"."));var n=Buffer.from(r,1).slice(1);if(!u.detached.verify(t,e,n))throw new Error("Signature of Transaction is invalid.")}t.exports={Transaction:A}},4420:(t,r,e)=>{"use strict";var n=e(5318)(e(319)),i=e(780).sign,o=e(1583),s=e(9344),h=e(5900),u=Buffer.from("01","hex"),a=o.fromString("8000000000000000",!0,16);t.exports={RCD_TYPE_1:u,sha256:function(t){return Buffer.from(s().update(t).digest())},sha512:function(t){return Buffer.from(h().update(t).digest())},sha256d:function(t){return Buffer.from(s().update(s().update(t).digest()).digest())},toHex:function(t){return Buffer.isBuffer(t)?t.toString("hex"):t},encodeVarInt:function(t){var r=[];0!==t&&"0"!==t||r.push(0);var e=o.fromValue(t,!0),n=!1;e.and(a).isZero()||(r.push(129),n=!0);for(var i=0;i<9;++i){var s=e.shiftRightUnsigned(56).toNumber();(s||n)&&(n=!0,8!==i?s|=128:s&=127,r.push(s)),e=e.shiftLeft(7)}return Buffer.from(r)},isIterable:function(t){return null!=t&&"function"==typeof t[Symbol.iterator]},flatMap:function(t,r){var e;return(e=[]).concat.apply(e,(0,n.default)(t.map(r)))},secretToPublicKey:function(t){var r=i.keyPair.fromSeed(t);return Buffer.from(r.publicKey)}}},6177:function(t,r,e){t=e.nmd(t),function(){var r,e,n,i;for(n=(null!==t?t.exports:void 0)||(window.Base58={}),r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",e={},i=0;i<r.length;)e[r.charAt(i)]=i,i++;n.encode=function(t){var e,n,o;if(0===t.length)return"";for(i=void 0,o=void 0,n=[0],i=0;i<t.length;){for(o=0;o<n.length;)n[o]<<=8,o++;for(n[0]+=t[i],e=0,o=0;o<n.length;)n[o]+=e,e=n[o]/58|0,n[o]%=58,++o;for(;e;)n.push(e%58),e=e/58|0;i++}for(i=0;0===t[i]&&i<t.length-1;)n.push(0),i++;return n.reverse().map((function(t){return r[t]})).join("")},n.decode=function(t){var r,n,o,s;if(0===t.length)return new("undefined"!=typeof Uint8Array&&null!==Uint8Array?Uint8Array:Buffer)(0);for(i=void 0,s=void 0,r=[0],i=0;i<t.length;){if(!((n=t[i])in e))throw"Base58.decode received unacceptable input. Character '"+n+"' is not in the Base58 alphabet.";for(s=0;s<r.length;)r[s]*=58,s++;for(r[0]+=e[n],o=0,s=0;s<r.length;)r[s]+=o,o=r[s]>>8,r[s]&=255,++s;for(;o;)r.push(255&o),o>>=8;i++}for(i=0;"1"===t[i]&&i<t.length-1;)r.push(0),i++;return new("undefined"!=typeof Uint8Array&&null!==Uint8Array?Uint8Array:Buffer)(r.reverse())}}.call(this)},5772:(t,r,e)=>{"use strict";var n=e(6436),i=e(9746);function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(t,r){if(t=n.toArray(t,r),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var e=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-e,t.length),0===this.pending.length&&(this.pending=null),t=n.join32(t,0,t.length-e,this.endian);for(var i=0;i<t.length;i+=this._delta32)this._update(t,i,i+this._delta32)}return this},o.prototype.digest=function(t){return this.update(this._pad()),i(null===this.pending),this._digest(t)},o.prototype._pad=function(){var t=this.pendingTotal,r=this._delta8,e=r-(t+this.padLength)%r,n=new Array(e+this.padLength);n[0]=128;for(var i=1;i<e;i++)n[i]=0;if(t<<=3,"big"===this.endian){for(var o=8;o<this.padLength;o++)n[i++]=0;n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=t>>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o<this.padLength;o++)n[i++]=0;return n}},9344:(t,r,e)=>{"use strict";var n=e(6436),i=e(5772),o=e(7038),s=e(9746),h=n.sum32,u=n.sum32_4,a=n.sum32_5,f=o.ch32,c=o.maj32,l=o.s0_256,d=o.s1_256,g=o.g0_256,p=o.g1_256,y=i.BlockHash,v=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function m(){if(!(this instanceof m))return new m;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=v,this.W=new Array(64)}n.inherits(m,y),t.exports=m,m.blockSize=512,m.outSize=256,m.hmacStrength=192,m.padLength=64,m.prototype._update=function(t,r){for(var e=this.W,n=0;n<16;n++)e[n]=t[r+n];for(;n<e.length;n++)e[n]=u(p(e[n-2]),e[n-7],g(e[n-15]),e[n-16]);var i=this.h[0],o=this.h[1],y=this.h[2],v=this.h[3],m=this.h[4],w=this.h[5],_=this.h[6],E=this.h[7];for(s(this.k.length===e.length),n=0;n<e.length;n++){var b=a(E,d(m),f(m,w,_),this.k[n],e[n]),x=h(l(i),c(i,o,y));E=_,_=w,w=m,m=h(v,b),v=y,y=o,o=i,i=h(b,x)}this.h[0]=h(this.h[0],i),this.h[1]=h(this.h[1],o),this.h[2]=h(this.h[2],y),this.h[3]=h(this.h[3],v),this.h[4]=h(this.h[4],m),this.h[5]=h(this.h[5],w),this.h[6]=h(this.h[6],_),this.h[7]=h(this.h[7],E)},m.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},5900:(t,r,e)=>{"use strict";var n=e(6436),i=e(5772),o=e(9746),s=n.rotr64_hi,h=n.rotr64_lo,u=n.shr64_hi,a=n.shr64_lo,f=n.sum64,c=n.sum64_hi,l=n.sum64_lo,d=n.sum64_4_hi,g=n.sum64_4_lo,p=n.sum64_5_hi,y=n.sum64_5_lo,v=i.BlockHash,m=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function w(){if(!(this instanceof w))return new w;v.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=m,this.W=new Array(160)}function _(t,r,e,n,i){var o=t&e^~t&i;return o<0&&(o+=4294967296),o}function E(t,r,e,n,i,o){var s=r&n^~r&o;return s<0&&(s+=4294967296),s}function b(t,r,e,n,i){var o=t&e^t&i^e&i;return o<0&&(o+=4294967296),o}function x(t,r,e,n,i,o){var s=r&n^r&o^n&o;return s<0&&(s+=4294967296),s}function A(t,r){var e=s(t,r,28)^s(r,t,2)^s(r,t,7);return e<0&&(e+=4294967296),e}function I(t,r){var e=h(t,r,28)^h(r,t,2)^h(r,t,7);return e<0&&(e+=4294967296),e}function S(t,r){var e=h(t,r,14)^h(t,r,18)^h(r,t,9);return e<0&&(e+=4294967296),e}function B(t,r){var e=s(t,r,1)^s(t,r,8)^u(t,r,7);return e<0&&(e+=4294967296),e}function R(t,r){var e=h(t,r,1)^h(t,r,8)^a(t,r,7);return e<0&&(e+=4294967296),e}function C(t,r){var e=h(t,r,19)^h(r,t,29)^a(t,r,6);return e<0&&(e+=4294967296),e}n.inherits(w,v),t.exports=w,w.blockSize=1024,w.outSize=512,w.hmacStrength=192,w.padLength=128,w.prototype._prepareBlock=function(t,r){for(var e=this.W,n=0;n<32;n++)e[n]=t[r+n];for(;n<e.length;n+=2){var i=(y=e[n-4],v=e[n-3],m=void 0,(m=s(y,v,19)^s(v,y,29)^u(y,v,6))<0&&(m+=4294967296),m),o=C(e[n-4],e[n-3]),h=e[n-14],a=e[n-13],f=B(e[n-30],e[n-29]),c=R(e[n-30],e[n-29]),l=e[n-32],p=e[n-31];e[n]=d(i,o,h,a,f,c,l,p),e[n+1]=g(i,o,h,a,f,c,l,p)}var y,v,m},w.prototype._update=function(t,r){this._prepareBlock(t,r);var e,n,i,h=this.W,u=this.h[0],a=this.h[1],d=this.h[2],g=this.h[3],v=this.h[4],m=this.h[5],w=this.h[6],B=this.h[7],R=this.h[8],C=this.h[9],T=this.h[10],k=this.h[11],O=this.h[12],L=this.h[13],U=this.h[14],D=this.h[15];o(this.k.length===h.length);for(var N=0;N<h.length;N+=2){var P=U,M=D,F=(i=void 0,(i=s(e=R,n=C,14)^s(e,n,18)^s(n,e,9))<0&&(i+=4294967296),i),V=S(R,C),z=_(R,0,T,0,O),K=E(0,C,0,k,0,L),Y=this.k[N],H=this.k[N+1],j=h[N],q=h[N+1],X=p(P,M,F,V,z,K,Y,H,j,q),Z=y(P,M,F,V,z,K,Y,H,j,q);P=A(u,a),M=I(u,a),F=b(u,0,d,0,v),V=x(0,a,0,g,0,m);var G=c(P,M,F,V),W=l(P,M,F,V);U=O,D=L,O=T,L=k,T=R,k=C,R=c(w,B,X,Z),C=l(B,B,X,Z),w=v,B=m,v=d,m=g,d=u,g=a,u=c(X,Z,G,W),a=l(X,Z,G,W)}f(this.h,0,u,a),f(this.h,2,d,g),f(this.h,4,v,m),f(this.h,6,w,B),f(this.h,8,R,C),f(this.h,10,T,k),f(this.h,12,O,L),f(this.h,14,U,D)},w.prototype._digest=function(t){return"hex"===t?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},7038:(t,r,e)=>{"use strict";var n=e(6436).rotr32;function i(t,r,e){return t&r^~t&e}function o(t,r,e){return t&r^t&e^r&e}function s(t,r,e){return t^r^e}r.ft_1=function(t,r,e,n){return 0===t?i(r,e,n):1===t||3===t?s(r,e,n):2===t?o(r,e,n):void 0},r.ch32=i,r.maj32=o,r.p32=s,r.s0_256=function(t){return n(t,2)^n(t,13)^n(t,22)},r.s1_256=function(t){return n(t,6)^n(t,11)^n(t,25)},r.g0_256=function(t){return n(t,7)^n(t,18)^t>>>3},r.g1_256=function(t){return n(t,17)^n(t,19)^t>>>10}},6436:(t,r,e)=>{"use strict";var n=e(9746),i=e(5717);function o(t,r){return 55296==(64512&t.charCodeAt(r))&&!(r<0||r+1>=t.length)&&56320==(64512&t.charCodeAt(r+1))}function s(t){return(t>>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function h(t){return 1===t.length?"0"+t:t}function u(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}r.inherits=i,r.toArray=function(t,r){if(Array.isArray(t))return t.slice();if(!t)return[];var e=[];if("string"==typeof t)if(r){if("hex"===r)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),i=0;i<t.length;i+=2)e.push(parseInt(t[i]+t[i+1],16))}else for(var n=0,i=0;i<t.length;i++){var s=t.charCodeAt(i);s<128?e[n++]=s:s<2048?(e[n++]=s>>6|192,e[n++]=63&s|128):o(t,i)?(s=65536+((1023&s)<<10)+(1023&t.charCodeAt(++i)),e[n++]=s>>18|240,e[n++]=s>>12&63|128,e[n++]=s>>6&63|128,e[n++]=63&s|128):(e[n++]=s>>12|224,e[n++]=s>>6&63|128,e[n++]=63&s|128)}else for(i=0;i<t.length;i++)e[i]=0|t[i];return e},r.toHex=function(t){for(var r="",e=0;e<t.length;e++)r+=h(t[e].toString(16));return r},r.htonl=s,r.toHex32=function(t,r){for(var e="",n=0;n<t.length;n++){var i=t[n];"little"===r&&(i=s(i)),e+=u(i.toString(16))}return e},r.zero2=h,r.zero8=u,r.join32=function(t,r,e,i){var o=e-r;n(o%4==0);for(var s=new Array(o/4),h=0,u=r;h<s.length;h++,u+=4){var a;a="big"===i?t[u]<<24|t[u+1]<<16|t[u+2]<<8|t[u+3]:t[u+3]<<24|t[u+2]<<16|t[u+1]<<8|t[u],s[h]=a>>>0}return s},r.split32=function(t,r){for(var e=new Array(4*t.length),n=0,i=0;n<t.length;n++,i+=4){var o=t[n];"big"===r?(e[i]=o>>>24,e[i+1]=o>>>16&255,e[i+2]=o>>>8&255,e[i+3]=255&o):(e[i+3]=o>>>24,e[i+2]=o>>>16&255,e[i+1]=o>>>8&255,e[i]=255&o)}return e},r.rotr32=function(t,r){return t>>>r|t<<32-r},r.rotl32=function(t,r){return t<<r|t>>>32-r},r.sum32=function(t,r){return t+r>>>0},r.sum32_3=function(t,r,e){return t+r+e>>>0},r.sum32_4=function(t,r,e,n){return t+r+e+n>>>0},r.sum32_5=function(t,r,e,n,i){return t+r+e+n+i>>>0},r.sum64=function(t,r,e,n){var i=t[r],o=n+t[r+1]>>>0,s=(o<n?1:0)+e+i;t[r]=s>>>0,t[r+1]=o},r.sum64_hi=function(t,r,e,n){return(r+n>>>0<r?1:0)+t+e>>>0},r.sum64_lo=function(t,r,e,n){return r+n>>>0},r.sum64_4_hi=function(t,r,e,n,i,o,s,h){var u=0,a=r;return u+=(a=a+n>>>0)<r?1:0,u+=(a=a+o>>>0)<o?1:0,t+e+i+s+(u+=(a=a+h>>>0)<h?1:0)>>>0},r.sum64_4_lo=function(t,r,e,n,i,o,s,h){return r+n+o+h>>>0},r.sum64_5_hi=function(t,r,e,n,i,o,s,h,u,a){var f=0,c=r;return f+=(c=c+n>>>0)<r?1:0,f+=(c=c+o>>>0)<o?1:0,f+=(c=c+h>>>0)<h?1:0,t+e+i+s+u+(f+=(c=c+a>>>0)<a?1:0)>>>0},r.sum64_5_lo=function(t,r,e,n,i,o,s,h,u,a){return r+n+o+h+a>>>0},r.rotr64_hi=function(t,r,e){return(r<<32-e|t>>>e)>>>0},r.rotr64_lo=function(t,r,e){return(t<<32-e|r>>>e)>>>0},r.shr64_hi=function(t,r,e){return t>>>e},r.shr64_lo=function(t,r,e){return(t<<32-e|r>>>e)>>>0}},5717:t=>{"function"==typeof Object.create?t.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,r){if(r){t.super_=r;var e=function(){};e.prototype=r.prototype,t.prototype=new e,t.prototype.constructor=t}}},9746:t=>{function r(t,r){if(!t)throw new Error(r||"Assertion failed")}t.exports=r,r.equal=function(t,r,e){if(t!=r)throw new Error(e||"Assertion failed: "+t+" != "+r)}},5666:t=>{var r=function(t){"use strict";var r,e=Object.prototype,n=e.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",h=i.toStringTag||"@@toStringTag";function u(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{u({},"")}catch(t){u=function(t,r,e){return t[r]=e}}function a(t,r,e,n){var i=r&&r.prototype instanceof y?r:y,o=Object.create(i.prototype),s=new R(n||[]);return o._invoke=function(t,r,e){var n=c;return function(i,o){if(n===d)throw new Error("Generator is already running");if(n===g){if("throw"===i)throw o;return T()}for(e.method=i,e.arg=o;;){var s=e.delegate;if(s){var h=I(s,e);if(h){if(h===p)continue;return h}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if(n===c)throw n=g,e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n=d;var u=f(t,r,e);if("normal"===u.type){if(n=e.done?g:l,u.arg===p)continue;return{value:u.arg,done:e.done}}"throw"===u.type&&(n=g,e.method="throw",e.arg=u.arg)}}}(t,e,s),o}function f(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=a;var c="suspendedStart",l="suspendedYield",d="executing",g="completed",p={};function y(){}function v(){}function m(){}var w={};u(w,o,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(C([])));E&&E!==e&&n.call(E,o)&&(w=E);var b=m.prototype=y.prototype=Object.create(w);function x(t){["next","throw","return"].forEach((function(r){u(t,r,(function(t){return this._invoke(r,t)}))}))}function A(t,r){function e(i,o,s,h){var u=f(t[i],t,o);if("throw"!==u.type){var a=u.arg,c=a.value;return c&&"object"==typeof c&&n.call(c,"__await")?r.resolve(c.__await).then((function(t){e("next",t,s,h)}),(function(t){e("throw",t,s,h)})):r.resolve(c).then((function(t){a.value=t,s(a)}),(function(t){return e("throw",t,s,h)}))}h(u.arg)}var i;this._invoke=function(t,n){function o(){return new r((function(r,i){e(t,n,r,i)}))}return i=i?i.then(o,o):o()}}function I(t,e){var n=t.iterator[e.method];if(n===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=r,I(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var i=f(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,p;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,p):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function S(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function B(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function R(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function C(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,s=function e(){for(;++i<t.length;)if(n.call(t,i))return e.value=t[i],e.done=!1,e;return e.value=r,e.done=!0,e};return s.next=s}}return{next:T}}function T(){return{value:r,done:!0}}return v.prototype=m,u(b,"constructor",m),u(m,"constructor",v),v.displayName=u(m,h,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===v||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,u(t,h,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},x(A.prototype),u(A.prototype,s,(function(){return this})),t.AsyncIterator=A,t.async=function(r,e,n,i,o){void 0===o&&(o=Promise);var s=new A(a(r,e,n,i),o);return t.isGeneratorFunction(e)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},x(b),u(b,h,"Generator"),u(b,o,(function(){return this})),u(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=C,R.prototype={constructor:R,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(B),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function i(n,i){return h.type="throw",h.arg=t,e.next=n,i&&(e.method="next",e.arg=r),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],h=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var u=n.call(s,"catchLoc"),a=n.call(s,"finallyLoc");if(u&&a){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!a)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var i=this.tryEntries[e];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=r,o?(this.method="next",this.next=o.finallyLoc,p):this.complete(s)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),p},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),B(e),p}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var i=n.arg;B(e)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:C(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),p}},t}(t.exports);try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}},780:(t,r,e)=>{!function(t){"use strict";var r=function(t){var r,e=new Float64Array(16);if(t)for(r=0;r<t.length;r++)e[r]=t[r];return e},n=function(){throw new Error("no PRNG")},i=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var s=r(),h=r([1]),u=r([56129,1]),a=r([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),f=r([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),c=r([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),l=r([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),d=r([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function g(t,r,e,n){t[r]=e>>24&255,t[r+1]=e>>16&255,t[r+2]=e>>8&255,t[r+3]=255&e,t[r+4]=n>>24&255,t[r+5]=n>>16&255,t[r+6]=n>>8&255,t[r+7]=255&n}function p(t,r,e,n,i){var o,s=0;for(o=0;o<i;o++)s|=t[r+o]^e[n+o];return(1&s-1>>>8)-1}function y(t,r,e,n){return p(t,r,e,n,16)}function v(t,r,e,n){return p(t,r,e,n,32)}function m(t,r,e,n){!function(t,r,e,n){for(var i,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,h=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,u=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,a=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,f=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,l=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,g=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,y=255&e[16]|(255&e[17])<<8|(255&e[18])<<16|(255&e[19])<<24,v=255&e[20]|(255&e[21])<<8|(255&e[22])<<16|(255&e[23])<<24,m=255&e[24]|(255&e[25])<<8|(255&e[26])<<16|(255&e[27])<<24,w=255&e[28]|(255&e[29])<<8|(255&e[30])<<16|(255&e[31])<<24,_=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,E=o,b=s,x=h,A=u,I=a,S=f,B=c,R=l,C=d,T=g,k=p,O=y,L=v,U=m,D=w,N=_,P=0;P<20;P+=2)E^=(i=(L^=(i=(C^=(i=(I^=(i=E+L|0)<<7|i>>>25)+E|0)<<9|i>>>23)+I|0)<<13|i>>>19)+C|0)<<18|i>>>14,S^=(i=(b^=(i=(U^=(i=(T^=(i=S+b|0)<<7|i>>>25)+S|0)<<9|i>>>23)+T|0)<<13|i>>>19)+U|0)<<18|i>>>14,k^=(i=(B^=(i=(x^=(i=(D^=(i=k+B|0)<<7|i>>>25)+k|0)<<9|i>>>23)+D|0)<<13|i>>>19)+x|0)<<18|i>>>14,N^=(i=(O^=(i=(R^=(i=(A^=(i=N+O|0)<<7|i>>>25)+N|0)<<9|i>>>23)+A|0)<<13|i>>>19)+R|0)<<18|i>>>14,E^=(i=(A^=(i=(x^=(i=(b^=(i=E+A|0)<<7|i>>>25)+E|0)<<9|i>>>23)+b|0)<<13|i>>>19)+x|0)<<18|i>>>14,S^=(i=(I^=(i=(R^=(i=(B^=(i=S+I|0)<<7|i>>>25)+S|0)<<9|i>>>23)+B|0)<<13|i>>>19)+R|0)<<18|i>>>14,k^=(i=(T^=(i=(C^=(i=(O^=(i=k+T|0)<<7|i>>>25)+k|0)<<9|i>>>23)+O|0)<<13|i>>>19)+C|0)<<18|i>>>14,N^=(i=(D^=(i=(U^=(i=(L^=(i=N+D|0)<<7|i>>>25)+N|0)<<9|i>>>23)+L|0)<<13|i>>>19)+U|0)<<18|i>>>14;E=E+o|0,b=b+s|0,x=x+h|0,A=A+u|0,I=I+a|0,S=S+f|0,B=B+c|0,R=R+l|0,C=C+d|0,T=T+g|0,k=k+p|0,O=O+y|0,L=L+v|0,U=U+m|0,D=D+w|0,N=N+_|0,t[0]=E>>>0&255,t[1]=E>>>8&255,t[2]=E>>>16&255,t[3]=E>>>24&255,t[4]=b>>>0&255,t[5]=b>>>8&255,t[6]=b>>>16&255,t[7]=b>>>24&255,t[8]=x>>>0&255,t[9]=x>>>8&255,t[10]=x>>>16&255,t[11]=x>>>24&255,t[12]=A>>>0&255,t[13]=A>>>8&255,t[14]=A>>>16&255,t[15]=A>>>24&255,t[16]=I>>>0&255,t[17]=I>>>8&255,t[18]=I>>>16&255,t[19]=I>>>24&255,t[20]=S>>>0&255,t[21]=S>>>8&255,t[22]=S>>>16&255,t[23]=S>>>24&255,t[24]=B>>>0&255,t[25]=B>>>8&255,t[26]=B>>>16&255,t[27]=B>>>24&255,t[28]=R>>>0&255,t[29]=R>>>8&255,t[30]=R>>>16&255,t[31]=R>>>24&255,t[32]=C>>>0&255,t[33]=C>>>8&255,t[34]=C>>>16&255,t[35]=C>>>24&255,t[36]=T>>>0&255,t[37]=T>>>8&255,t[38]=T>>>16&255,t[39]=T>>>24&255,t[40]=k>>>0&255,t[41]=k>>>8&255,t[42]=k>>>16&255,t[43]=k>>>24&255,t[44]=O>>>0&255,t[45]=O>>>8&255,t[46]=O>>>16&255,t[47]=O>>>24&255,t[48]=L>>>0&255,t[49]=L>>>8&255,t[50]=L>>>16&255,t[51]=L>>>24&255,t[52]=U>>>0&255,t[53]=U>>>8&255,t[54]=U>>>16&255,t[55]=U>>>24&255,t[56]=D>>>0&255,t[57]=D>>>8&255,t[58]=D>>>16&255,t[59]=D>>>24&255,t[60]=N>>>0&255,t[61]=N>>>8&255,t[62]=N>>>16&255,t[63]=N>>>24&255}(t,r,e,n)}function w(t,r,e,n){!function(t,r,e,n){for(var i,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,s=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,h=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,u=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,a=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,f=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,c=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,l=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,d=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,g=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,p=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,y=255&e[16]|(255&e[17])<<8|(255&e[18])<<16|(255&e[19])<<24,v=255&e[20]|(255&e[21])<<8|(255&e[22])<<16|(255&e[23])<<24,m=255&e[24]|(255&e[25])<<8|(255&e[26])<<16|(255&e[27])<<24,w=255&e[28]|(255&e[29])<<8|(255&e[30])<<16|(255&e[31])<<24,_=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,E=0;E<20;E+=2)o^=(i=(v^=(i=(d^=(i=(a^=(i=o+v|0)<<7|i>>>25)+o|0)<<9|i>>>23)+a|0)<<13|i>>>19)+d|0)<<18|i>>>14,f^=(i=(s^=(i=(m^=(i=(g^=(i=f+s|0)<<7|i>>>25)+f|0)<<9|i>>>23)+g|0)<<13|i>>>19)+m|0)<<18|i>>>14,p^=(i=(c^=(i=(h^=(i=(w^=(i=p+c|0)<<7|i>>>25)+p|0)<<9|i>>>23)+w|0)<<13|i>>>19)+h|0)<<18|i>>>14,_^=(i=(y^=(i=(l^=(i=(u^=(i=_+y|0)<<7|i>>>25)+_|0)<<9|i>>>23)+u|0)<<13|i>>>19)+l|0)<<18|i>>>14,o^=(i=(u^=(i=(h^=(i=(s^=(i=o+u|0)<<7|i>>>25)+o|0)<<9|i>>>23)+s|0)<<13|i>>>19)+h|0)<<18|i>>>14,f^=(i=(a^=(i=(l^=(i=(c^=(i=f+a|0)<<7|i>>>25)+f|0)<<9|i>>>23)+c|0)<<13|i>>>19)+l|0)<<18|i>>>14,p^=(i=(g^=(i=(d^=(i=(y^=(i=p+g|0)<<7|i>>>25)+p|0)<<9|i>>>23)+y|0)<<13|i>>>19)+d|0)<<18|i>>>14,_^=(i=(w^=(i=(m^=(i=(v^=(i=_+w|0)<<7|i>>>25)+_|0)<<9|i>>>23)+v|0)<<13|i>>>19)+m|0)<<18|i>>>14;t[0]=o>>>0&255,t[1]=o>>>8&255,t[2]=o>>>16&255,t[3]=o>>>24&255,t[4]=f>>>0&255,t[5]=f>>>8&255,t[6]=f>>>16&255,t[7]=f>>>24&255,t[8]=p>>>0&255,t[9]=p>>>8