From 05fd03355048d54dce296af8e6e653e05955e040 Mon Sep 17 00:00:00 2001 From: ChiaMineJP Date: Sun, 11 Jul 2021 00:18:25 +0900 Subject: [PATCH 1/4] Fixed an issue where `int_to_bytes` did not work as expected if the argument is a negative number --- CHANGELOG.md | 5 +++++ src/casts.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 698d758..540f7cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## [0.0.18] +### Changed +- Fixed an issue where `int_to_bytes` did not work as expected if the argument is a negative number. + ## [0.0.17] ### Changed - Updated `jscrypto` version to 1.0.2 @@ -108,6 +112,7 @@ Initial (beta) release. +[0.0.18]: https://github.com/Chia-Mine/clvm-js/compare/v0.0.17...v0.0.18 [0.0.17]: https://github.com/Chia-Mine/clvm-js/compare/v0.0.16...v0.0.17 [0.0.16]: https://github.com/Chia-Mine/clvm-js/compare/v0.0.15...v0.0.16 [0.0.15]: https://github.com/Chia-Mine/clvm-js/compare/v0.0.14...v0.0.15 diff --git a/src/casts.ts b/src/casts.ts index c648d75..dc69760 100644 --- a/src/casts.ts +++ b/src/casts.ts @@ -7,7 +7,12 @@ export function int_from_bytes(b: Bytes|None): int { if(!b || b.length === 0){ return 0; } - return parseInt(b.hex(), 16); + const unsigned32 = parseInt(b.hex(), 16); + // If the first bit is 1, it is recognized as a negative number. + if(b.get_byte_at(0) & 0x80){ + return unsigned32 - (1 << (b.length*8)); + } + return unsigned32; } export function int_to_bytes(v: int): Bytes { From 265b455c9516f96606d36b236f108efd8e44c55f Mon Sep 17 00:00:00 2001 From: ChiaMineJP Date: Sun, 11 Jul 2021 18:34:40 +0900 Subject: [PATCH 2/4] Changed `Bytes::toString()` to return python's `bytes.__repr__` style string --- CHANGELOG.md | 1 + src/SExp.ts | 4 +-- src/__type_compatibility__.ts | 60 ++++++++++++++++++++++++++++++++--- src/operators.ts | 2 +- 4 files changed, 60 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 540f7cf..d9d23a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [0.0.18] ### Changed - Fixed an issue where `int_to_bytes` did not work as expected if the argument is a negative number. +- Changed `Bytes::toString()` to return python's `bytes.__repr__` style string. ## [0.0.17] ### Changed diff --git a/src/SExp.ts b/src/SExp.ts index 12d74f0..c2ed375 100644 --- a/src/SExp.ts +++ b/src/SExp.ts @@ -289,10 +289,10 @@ export class SExp extends CLVMObject { } public toString(){ - return this.as_bin().toString(); + return this.as_bin().hex(); } public __repr__(){ - return `SExp(${this.as_bin().toString()})`; + return `SExp(${this.as_bin().hex()})`; } } diff --git a/src/__type_compatibility__.ts b/src/__type_compatibility__.ts index fcfcb17..55651b2 100644 --- a/src/__type_compatibility__.ts +++ b/src/__type_compatibility__.ts @@ -9,6 +9,58 @@ export function to_hexstr(r: Uint8Array) { return (new Word32Array(r)).toString(); } +/** + * Get python's bytes.__repr__ style string. + * @see https://github.com/python/cpython/blob/main/Objects/bytesobject.c#L1337 + * @param {Uint8Array} r - byteArray to stringify + */ +export function PyBytes_Repr(r: Uint8Array) { + let squotes = 0; + let dquotes = 0; + for(let i=0;i= 0x7f){ + s += "\\x"; + s += b.toString(16).padStart(2, "0"); + } + else{ + s += c; + } + } + + s += quote; + + return s; +} + export type BytesFromType = "hex"|"utf8"|"G1Element"; /** @@ -120,11 +172,11 @@ export class Bytes { } public toString(){ - return to_hexstr(this._b); + return PyBytes_Repr(this._b); } public hex(){ - return this.toString(); + return to_hexstr(this._b); } public decode(){ @@ -132,11 +184,11 @@ export class Bytes { } public startswith(b: Bytes){ - return this.toString().startsWith(b.toString()); + return this.hex().startsWith(b.hex()); } public endswith(b: Bytes){ - return this.toString().endsWith(b.toString()); + return this.hex().endsWith(b.hex()); } public equal_to(b: Bytes|None){ diff --git a/src/operators.ts b/src/operators.ts index 94c0c46..feb57c8 100644 --- a/src/operators.ts +++ b/src/operators.ts @@ -330,7 +330,7 @@ export function OperatorDict( merge(dict, OperatorDict as any); - const f = (dict as Record)[op.toString()]; + const f = (dict as Record)[op.hex()]; if(typeof f !== "function"){ return dict.unknown_op_handler(op, args); } From a98cd492e00e569283ed07a90a70f24e45a92db9 Mon Sep 17 00:00:00 2001 From: ChiaMineJP Date: Sun, 11 Jul 2021 18:42:17 +0900 Subject: [PATCH 3/4] Build --- dist/SExp.js | 4 +-- dist/__type_compatibility__.d.ts | 6 ++++ dist/__type_compatibility__.js | 62 +++++++++++++++++++++++++++++--- dist/browser/index.js | 2 +- dist/casts.js | 7 +++- dist/operators.js | 2 +- 6 files changed, 73 insertions(+), 10 deletions(-) diff --git a/dist/SExp.js b/dist/SExp.js index 1519d4c..bcd04e2 100644 --- a/dist/SExp.js +++ b/dist/SExp.js @@ -232,10 +232,10 @@ class SExp extends CLVMObject_1.CLVMObject { return as_javascript_1.as_javascript(this); } toString() { - return this.as_bin().toString(); + return this.as_bin().hex(); } __repr__() { - return `SExp(${this.as_bin().toString()})`; + return `SExp(${this.as_bin().hex()})`; } } exports.SExp = SExp; diff --git a/dist/__type_compatibility__.d.ts b/dist/__type_compatibility__.d.ts index 9cfa0c0..0134ce2 100644 --- a/dist/__type_compatibility__.d.ts +++ b/dist/__type_compatibility__.d.ts @@ -2,6 +2,12 @@ import { Word32Array } from "jscrypto/Word32Array"; import { None, str } from "./__python_types__"; import { G1Element } from "@chiamine/bls-signatures"; export declare function to_hexstr(r: Uint8Array): string; +/** + * Get python's bytes.__repr__ style string. + * @see https://github.com/python/cpython/blob/main/Objects/bytesobject.c#L1337 + * @param {Uint8Array} r - byteArray to stringify + */ +export declare function PyBytes_Repr(r: Uint8Array): string; export declare type BytesFromType = "hex" | "utf8" | "G1Element"; /** * Unlike python, there is no immutable byte type in javascript. diff --git a/dist/__type_compatibility__.js b/dist/__type_compatibility__.js index e48c989..0ac7b12 100644 --- a/dist/__type_compatibility__.js +++ b/dist/__type_compatibility__.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.Stream = exports.isIterable = exports.isList = exports.isTuple = exports.t = exports.Tuple = exports.h = exports.b = exports.Bytes = exports.to_hexstr = void 0; +exports.Stream = exports.isIterable = exports.isList = exports.isTuple = exports.t = exports.Tuple = exports.h = exports.b = exports.Bytes = exports.PyBytes_Repr = exports.to_hexstr = void 0; const Hex_1 = require("jscrypto/Hex"); const Utf8_1 = require("jscrypto/Utf8"); const Word32Array_1 = require("jscrypto/Word32Array"); @@ -10,6 +10,58 @@ function to_hexstr(r) { return (new Word32Array_1.Word32Array(r)).toString(); } exports.to_hexstr = to_hexstr; +/** + * Get python's bytes.__repr__ style string. + * @see https://github.com/python/cpython/blob/main/Objects/bytesobject.c#L1337 + * @param {Uint8Array} r - byteArray to stringify + */ +function PyBytes_Repr(r) { + let squotes = 0; + let dquotes = 0; + for (let i = 0; i < r.length; i++) { + const b = r[i]; + const c = String.fromCodePoint(b); + switch (c) { + case "'": + squotes++; + break; + case "\"": + dquotes++; + break; + } + } + let quote = "'"; + if (squotes && !dquotes) { + quote = "\""; + } + let s = "b" + quote; + for (let i = 0; i < r.length; i++) { + const b = r[i]; + const c = String.fromCodePoint(b); + if (c === quote || c === "\\") { + s += "\\" + c; + } + else if (c === "\t") { + s += "\\t"; + } + else if (c === "\n") { + s += "\\n"; + } + else if (c === "\r") { + s += "\\r"; + } + else if (c < " " || b >= 0x7f) { + s += "\\x"; + s += b.toString(16).padStart(2, "0"); + } + else { + s += c; + } + } + s += quote; + return s; +} +exports.PyBytes_Repr = PyBytes_Repr; /** * Unlike python, there is no immutable byte type in javascript. */ @@ -103,19 +155,19 @@ class Bytes { return new Bytes(this._b); } toString() { - return to_hexstr(this._b); + return PyBytes_Repr(this._b); } hex() { - return this.toString(); + return to_hexstr(this._b); } decode() { return Utf8_1.Utf8.stringify(this.as_word()); } startswith(b) { - return this.toString().startsWith(b.toString()); + return this.hex().startsWith(b.hex()); } endswith(b) { - return this.toString().endsWith(b.toString()); + return this.hex().endsWith(b.hex()); } equal_to(b) { if (!b) { diff --git a/dist/browser/index.js b/dist/browser/index.js index d7d8fc7..a02531d 100644 --- a/dist/browser/index.js +++ b/dist/browser/index.js @@ -1 +1 @@ -!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.clvm=t():n.clvm=t()}(this,(function(){return n={513:function(n,t,r){var e,o=(e=(e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(n){var t,o,i;n=n||{},t||(t=void 0!==n?n:{}),t.ready=new Promise((function(n,t){o=n,i=t}));var u,f={};for(u in t)t.hasOwnProperty(u)&&(f[u]=t[u]);var a,c,s,l,h="./this.program";a="object"==typeof window,c="function"==typeof importScripts,s="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,l=!a&&!s&&!c;var w,v,d,y,p,b="";s?(b=c?r(794).dirname(b)+"/":"//",w=function(n,t){return y||(y=r(33)),p||(p=r(794)),n=p.normalize(n),y.readFileSync(n,t?null:"utf8")},d=function(n){return(n=w(n,!0)).buffer||(n=new Uint8Array(n)),_(n.buffer),n},1=e);)++r;if(16(o=224==(240&o)?(15&o)<<12|i<<6|u:(7&o)<<18|i<<12|u<<6|63&n[t++])?e+=String.fromCharCode(o):(o-=65536,e+=String.fromCharCode(55296|o>>10,56320|1023&o))}}else e+=String.fromCharCode(o)}return e}function M(n,t,r,e){if(!(0=u&&(u=65536+((1023&u)<<10)|1023&n.charCodeAt(++i)),127>=u){if(r>=e)break;t[r++]=u}else{if(2047>=u){if(r+1>=e)break;t[r++]=192|u>>6}else{if(65535>=u){if(r+2>=e)break;t[r++]=224|u>>12}else{if(r+3>=e)break;t[r++]=240|u>>18,t[r++]=128|u>>12&63}t[r++]=128|u>>6&63}t[r++]=128|63&u}}return t[r]=0,r-o}function U(n){for(var t=0,r=0;r=e&&(e=65536+((1023&e)<<10)|1023&n.charCodeAt(++r)),127>=e?++t:t=2047>=e?t+2:65535>=e?t+3:t+4}return t}var T="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function I(n,t){for(var r=n>>1,e=r+t/2;!(r>=e)&&B[r];)++r;if(32<(r<<=1)-n&&T)return T.decode(W.subarray(n,r));for(r="",e=0;!(e>=t/2);++e){var o=$[n+2*e>>1];if(0==o)break;r+=String.fromCharCode(o)}return r}function S(n,t,r){if(void 0===r&&(r=2147483647),2>r)return 0;var e=t;r=(r-=2)<2*n.length?r/2:n.length;for(var o=0;o>1]=n.charCodeAt(o),t+=2;return $[t>>1]=0,t-e}function x(n){return 2*n.length}function F(n,t){for(var r=0,e="";!(r>=t/4);){var o=G[n+4*r>>2];if(0==o)break;++r,65536<=o?(o-=65536,e+=String.fromCharCode(55296|o>>10,56320|1023&o)):e+=String.fromCharCode(o)}return e}function C(n,t,r){if(void 0===r&&(r=2147483647),4>r)return 0;var e=t;r=e+r-4;for(var o=0;o=i&&(i=65536+((1023&i)<<10)|1023&n.charCodeAt(++o)),G[t>>2]=i,(t+=4)+4>r)break}return G[t>>2]=0,t-e}function D(n){for(var t=0,r=0;r=e&&++r,t+=4}return t}var P,N,W,$,B,G,q,H,R,z,V=[],J=[],Y=[];function L(){var n=t.preRun.shift();V.unshift(n)}var X=0,Q=null,Z=null;function K(n){throw t.onAbort&&t.onAbort(n),A(n),j=!0,n=new WebAssembly.RuntimeError("abort("+n+"). Build with -s ASSERTIONS=1 for more info."),i(n),n}function nn(){return tn.startsWith("data:application/octet-stream;base64,")}t.preloadedImages={},t.preloadedAudios={};var tn="blsjs.wasm";if(!nn()){var rn=tn;tn=t.locateFile?t.locateFile(rn,b):b+rn}function en(){var n=tn;try{if(n==tn&&m)return new Uint8Array(m);if(d)return d(n);throw"both async and sync fetching of the wasm failed"}catch(n){K(n)}}function on(n){for(;0>2]=n},this.pb=function(n){G[this.Y+0>>2]=n},this.qb=function(){G[this.Y+4>>2]=0},this.ob=function(){N[this.Y+12>>0]=0},this.rb=function(){N[this.Y+13>>0]=0},this.eb=function(n,t){this.sb(n),this.pb(t),this.qb(),this.ob(),this.rb()}}function fn(n,t){for(var r=0,e=n.length-1;0<=e;e--){var o=n[e];"."===o?n.splice(e,1):".."===o?(n.splice(e,1),r++):r&&(n.splice(e,1),r--)}if(t)for(;r;r--)n.unshift("..");return n}function an(n){var t="/"===n.charAt(0),r="/"===n.substr(-1);return(n=fn(n.split("/").filter((function(n){return!!n})),!t).join("/"))||t||(n="."),n&&r&&(n+="/"),(t?"/":"")+n}function cn(n){var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(n).slice(1);return n=t[0],t=t[1],n||t?(t&&(t=t.substr(0,t.length-1)),n+t):"."}function sn(n){if("/"===n)return"/";var t=(n=(n=an(n)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?n:n.substr(t+1)}function ln(){for(var n="",t=!1,r=arguments.length-1;-1<=r&&!t;r--){if("string"!=typeof(t=0<=r?arguments[r]:"/"))throw new TypeError("Arguments to path.resolve must be strings");if(!t)return"";n=t+"/"+n,t="/"===t.charAt(0)}return(t?"/":"")+(n=fn(n.split("/").filter((function(n){return!!n})),!t).join("/"))||"."}var hn=[];function wn(n,t){hn[n]={input:[],output:[],sa:t},Pn(n,vn)}var vn={open:function(n){var t=hn[n.node.rdev];if(!t)throw new _n(43);n.tty=t,n.seekable=!1},close:function(n){n.tty.sa.flush(n.tty)},flush:function(n){n.tty.sa.flush(n.tty)},read:function(n,t,r,e){if(!n.tty||!n.tty.sa.Ra)throw new _n(60);for(var o=0,i=0;i=t||(t=Math.max(t,r*(1048576>r?2:1.125)>>>0),0!=r&&(t=Math.max(t,256)),r=n.W,n.W=new Uint8Array(t),0=n.node.aa)return 0;if(8<(n=Math.min(n.node.aa-o,e))&&i.subarray)t.set(i.subarray(o,o+n),r);else for(e=0;et)throw new _n(28);return t},La:function(n,t,r){pn.Oa(n.node,t+r),n.node.aa=Math.max(n.node.aa,t+r)},Sa:function(n,t,r,e,o,i){if(0!==t)throw new _n(28);if(32768!=(61440&n.node.mode))throw new _n(43);if(n=n.node.W,2&i||n.buffer!==P){for((0>>0)%En.length}function Tn(n,t){var r;if(r=n.X.lookup?0:2)throw new _n(r,n);for(r=En[Un(n.id,t)];r;r=r.hb){var e=r.name;if(r.parent.id===n.id&&e===t)return r}return n.X.lookup(n,t)}function In(n,t,r,e){return t=Un((n=new sr(n,t,r,e)).parent.id,n.name),n.hb=En[t],En[t]=n}var Sn={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090};function xn(n,t){try{return Tn(n,t),20}catch(n){}return 0}function Fn(n){Jn||((Jn=function(){}).prototype={});var t,r=new Jn;for(t in n)r[t]=n[t];return n=r,r=function(){for(var n=0;n<=4096;n++)if(!gn[n])return n;throw new _n(33)}(),n.fd=r,gn[r]=n}var Cn,Dn={open:function(n){n.$=mn[n.node.rdev].$,n.$.open&&n.$.open(n)},va:function(){throw new _n(70)}};function Pn(n,t){mn[n]={$:t}}function Nn(n,t){var r="/"===t,e=!t;if(r&&bn)throw new _n(10);if(!r&&!e){var o=kn(t,{Qa:!1});if(t=o.path,(o=o.node).Ca)throw new _n(10);if(16384!=(61440&o.mode))throw new _n(54)}t={type:n,Bb:{},Ta:t,gb:[]},(n=n.la(t)).la=t,t.root=n,r?bn=n:o&&(o.Ca=t,o.la&&o.la.gb.push(t))}function Wn(n,t,r){var e=kn(n,{parent:!0}).node;if(!(n=sn(n))||"."===n||".."===n)throw new _n(28);var o=xn(e,n);if(o)throw new _n(o);if(!e.X.Ba)throw new _n(63);return e.X.Ba(e,n,t,r)}function $n(n){return Wn(n,16895,0)}function Bn(n,t,r){void 0===r&&(r=t,t=438),Wn(n,8192|t,r)}function Gn(n,t){if(!ln(n))throw new _n(44);var r=kn(t,{parent:!0}).node;if(!r)throw new _n(44);var e=xn(r,t=sn(t));if(e)throw new _n(e);if(!r.X.symlink)throw new _n(63);r.X.symlink(r,t,n)}function qn(n){if(!(n=kn(n).node))throw new _n(44);if(!n.X.readlink)throw new _n(28);return ln(Mn(n.parent),n.X.readlink(n))}function Hn(n,r,e){if(""===n)throw new _n(44);if("string"==typeof r){var o=Sn[r];if(void 0===o)throw Error("Unknown file open mode: "+r);r=o}if(e=64&r?4095&(void 0===e?438:e)|32768:0,"object"==typeof n)var i=n;else{n=an(n);try{i=kn(n,{Pa:!(131072&r)}).node}catch(n){}}if(o=!1,64&r)if(i){if(128&r)throw new _n(20)}else i=Wn(n,e,0),o=!0;if(!i)throw new _n(44);if(8192==(61440&i.mode)&&(r&=-513),65536&r&&16384!=(61440&i.mode))throw new _n(54);if(!o&&(i?40960==(61440&i.mode)?e=32:((e=16384==(61440&i.mode))&&(e=["r","w","rw"][3&r],512&r&&(e+="w"),e="r"!==e||512&r),e=e?31:0):e=44,e))throw new _n(e);if(512&r){if(!(e="string"==typeof(e=i)?kn(e,{Pa:!0}).node:e).X.ja)throw new _n(63);if(16384==(61440&e.mode))throw new _n(31);if(32768!=(61440&e.mode))throw new _n(28);e.X.ja(e,{size:0,timestamp:Date.now()})}r&=-131713,(i=Fn({node:i,path:Mn(i),flags:r,seekable:!0,position:0,$:i.$,Db:[],error:!1})).$.open&&i.$.open(i),!t.logReadFiles||1&r||(Yn||(Yn={}),n in Yn||(Yn[n]=1,A("FS.trackingDelegate error on read file: "+n)));try{jn.onOpenFile&&(e=0,1!=(2097155&r)&&(e|=1),0!=(2097155&r)&&(e|=2),jn.onOpenFile(n,e))}catch(t){A("FS.trackingDelegate['onOpenFile']('"+n+"', flags) threw an exception: "+t.message)}return i}function Rn(){_n||((_n=function(n,t){this.node=t,this.nb=function(n){this.ua=n},this.nb(n),this.message="FS error"}).prototype=Error(),_n.prototype.constructor=_n,[44].forEach((function(n){On[n]=new _n(n),On[n].stack=""})))}function zn(n,t,r){n=an("/dev/"+n);var e=function(n,t){var r=0;return n&&(r|=365),t&&(r|=146),r}(!!t,!!r);Vn||(Vn=64);var o=Vn++<<8|0;Pn(o,{open:function(n){n.seekable=!1},close:function(){r&&r.buffer&&r.buffer.length&&r(10)},read:function(n,r,e,o){for(var i=0,u=0;u=t?"_"+n:n}function it(n,t){return n=ot(n),new Function("body","return function "+n+'() {\n "use strict"; return body.apply(this, arguments);\n};\n')(t)}function ut(n){var t=Error,r=it(n,(function(t){this.name=n,this.message=t,void 0!==(t=Error(t).stack)&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}));return r.prototype=Object.create(t.prototype),r.prototype.constructor=r,r.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},r}var ft=void 0;function at(n){throw new ft(n)}var ct=void 0;function st(n){throw new ct(n)}function lt(n,t,r){function e(t){(t=r(t)).length!==n.length&&st("Mismatched type converter count");for(var e=0;e>2])}function It(n,t,r){return t===r?n:void 0===r.ha||null===(n=It(n,t,r.ha))?null:r.Za(n)}var St={};function xt(n,t){return t.ba&&t.Y||st("makeClassHandle requires ptr and ptrType"),!!t.ga!=!!t.fa&&st("Both smartPtrType and smartPtr must be specified"),t.count={value:1},pt(Object.create(n,{V:{value:t}}))}function Ft(n,t,r,e){this.name=n,this.Z=t,this.Ha=r,this.za=e,this.Aa=!1,this.oa=this.lb=this.kb=this.Va=this.tb=this.ib=void 0,void 0!==t.ha?this.toWireType=Mt:(this.toWireType=e?kt:Ut,this.ka=null)}function Ct(n,r){var e=(n=nt(n)).includes("j")?function(n,r){var e=[];return function(){e.length=arguments.length;for(var o=0;oi&&at("argTypes array size mismatch! Must at least get return value and 'this' types!");var u=null!==t[1]&&null!==r,f=!1;for(r=1;r>2)+e]);return r}var qt=[],Ht=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Rt(n){4>2])};case 3:return function(n){return this.fromWireType(R[n>>3])};default:throw new TypeError("Unknown float type: "+n)}}function Yt(n,t,r){switch(t){case 0:return r?function(n){return N[n]}:function(n){return W[n]};case 1:return r?function(n){return $[n>>1]}:function(n){return B[n>>1]};case 2:return r?function(n){return G[n>>2]}:function(n){return q[n>>2]};default:throw new TypeError("Unknown integer type: "+n)}}function Lt(n){return n||at("Cannot use deleted val. handle = "+n),Ht[n].value}function Xt(n,t){var r=rt[n];return void 0===r&&at(t+" has unknown type "+Pt(n)),r}var Qt={};function Zt(n){var t=Qt[n];return void 0===t?nt(n):t}var Kt=[];function nr(){return"object"==typeof globalThis?globalThis:Function("return this")()}var tr,rr={},er={};function or(){if(!tr){var n,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:h||"./this.program"};for(n in er)t[n]=er[n];var r=[];for(n in t)r.push(n+"="+t[n]);tr=r}return tr}function ir(n){return 0==n%4&&(0!=n%100||0==n%400)}function ur(n,t){for(var r=0,e=0;e<=t;r+=n[e++]);return r}var fr=[31,29,31,30,31,30,31,31,30,31,30,31],ar=[31,28,31,30,31,30,31,31,30,31,30,31];function cr(n,t){for(n=new Date(n.getTime());0e-n.getDate())){n.setDate(n.getDate()+t);break}t-=e-n.getDate()+1,n.setDate(1),11>r?n.setMonth(r+1):(n.setMonth(0),n.setFullYear(n.getFullYear()+1))}return n}function sr(n,t,r,e){n||(n=this),this.parent=n,this.la=n.la,this.Ca=null,this.id=An++,this.name=t,this.mode=r,this.X={},this.$={},this.rdev=e}Object.defineProperties(sr.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(n){n?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(n){n?this.mode|=146:this.mode&=-147}}}),Rn(),En=Array(4096),Nn(pn,"/"),$n("/tmp"),$n("/home"),$n("/home/web_user"),function(){$n("/dev"),Pn(259,{read:function(){return 0},write:function(n,t,r,e){return e}}),Bn("/dev/null",259),wn(1280,dn),wn(1536,yn),Bn("/dev/tty",1280),Bn("/dev/tty1",1536);var n=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var n=new Uint8Array(1);return function(){return crypto.getRandomValues(n),n[0]}}if(s)try{var t=r(135);return function(){return t.randomBytes(1)[0]}}catch(n){}return function(){K("randomDevice")}}();zn("random",n),zn("urandom",n),$n("/dev/shm"),$n("/dev/shm/tmp")}(),function(){$n("/proc");var n=$n("/proc/self");$n("/proc/self/fd"),Nn({la:function(){var t=In(n,"fd",16895,73);return t.X={lookup:function(n,t){var r=gn[+t];if(!r)throw new _n(8);return(n={parent:null,la:{Ta:"fake"},X:{readlink:function(){return r.path}}}).parent=n}},t}},"/proc/self/fd")}();for(var lr=Array(256),hr=0;256>hr;++hr)lr[hr]=String.fromCharCode(hr);function wr(n,t){var r=Array(U(n)+1);return n=M(n,r,0,r.length),t&&(r.length=n),r}Kn=lr,ft=t.BindingError=ut("BindingError"),ct=t.InternalError=ut("InternalError"),At.prototype.isAliasOf=function(n){if(!(this instanceof At&&n instanceof At))return!1;var t=this.V.ba.Z,r=this.V.Y,e=n.V.ba.Z;for(n=n.V.Y;t.ha;)r=t.ya(r),t=t.ha;for(;e.ha;)n=e.ya(n),e=e.ha;return t===e&&r===n},At.prototype.clone=function(){if(this.V.Y||wt(this),this.V.wa)return this.V.count.value+=1,this;var n=pt,t=Object,r=t.create,e=Object.getPrototypeOf(this),o=this.V;return(n=n(r.call(t,e,{V:{value:{count:o.count,qa:o.qa,wa:o.wa,Y:o.Y,ba:o.ba,fa:o.fa,ga:o.ga}}}))).V.count.value+=1,n.V.qa=!1,n},At.prototype.delete=function(){this.V.Y||wt(this),this.V.qa&&!this.V.wa&&at("Object already scheduled for deletion"),dt(this),yt(this.V),this.V.wa||(this.V.fa=void 0,this.V.Y=void 0)},At.prototype.isDeleted=function(){return!this.V.Y},At.prototype.deleteLater=function(){return this.V.Y||wt(this),this.V.qa&&!this.V.wa&&at("Object already scheduled for deletion"),mt.push(this),1===mt.length&&bt&&bt(gt),this.V.qa=!0,this},Ft.prototype.ab=function(n){return this.Va&&(n=this.Va(n)),n},Ft.prototype.Na=function(n){this.oa&&this.oa(n)},Ft.prototype.argPackAdvance=8,Ft.prototype.readValueFromPointer=Tt,Ft.prototype.deleteObject=function(n){null!==n&&n.delete()},Ft.prototype.fromWireType=function(n){function t(){return this.Aa?xt(this.Z.ra,{ba:this.ib,Y:r,ga:this,fa:n}):xt(this.Z.ra,{ba:this,Y:n})}var r=this.ab(n);if(!r)return this.Na(n),null;var e=function(n,t){for(void 0===t&&at("ptr should not be undefined");n.ha;)t=n.ya(t),n=n.ha;return St[t]}(this.Z,r);if(void 0!==e)return 0===e.V.count.value?(e.V.Y=r,e.V.fa=n,e.clone()):(e=e.clone(),this.Na(n),e);if(e=this.Z.$a(r),!(e=Et[e]))return t.call(this);e=this.za?e.Ya:e.pointerType;var o=It(r,this.Z,e.Z);return null===o?t.call(this):this.Aa?xt(e.Z.ra,{ba:e,Y:o,ga:this,fa:n}):xt(e.Z.ra,{ba:e,Y:o})},t.getInheritedInstanceCount=function(){return Object.keys(St).length},t.getLiveInheritedInstances=function(){var n,t=[];for(n in St)St.hasOwnProperty(n)&&t.push(St[n]);return t},t.flushPendingDeletes=gt,t.setDelayFunction=function(n){bt=n,mt.length&&bt&&bt(gt)},Dt=t.UnboundTypeError=ut("UnboundTypeError"),t.count_emval_handles=function(){for(var n=0,t=5;t>2];else o=0;return Hn(e,t,o).fd}catch(n){return void 0!==Ln&&n instanceof _n||K(n),-n.ua}},w:function(){},F:function(n,t,r,e,o){var i=Zn(r);ht(n,{name:t=nt(t),fromWireType:function(n){return!!n},toWireType:function(n,t){return t?e:o},argPackAdvance:8,readValueFromPointer:function(n){if(1===r)var e=N;else if(2===r)e=$;else{if(4!==r)throw new TypeError("Unknown boolean type size: "+t);e=G}return this.fromWireType(e[n>>i])},ka:null})},l:function(n,r,e,o,i,u,f,a,c,s,l,h,w){l=nt(l),u=Ct(i,u),a&&(a=Ct(f,a)),s&&(s=Ct(c,s)),w=Ct(h,w);var v=ot(l);!function(n,r){t.hasOwnProperty(n)?(at("Cannot register public name '"+n+"' twice"),jt(t,n,n),t.hasOwnProperty(void 0)&&at("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),t[n].da[void 0]=r):t[n]=r}(v,(function(){Nt("Cannot construct "+l+" due to unbound types",[o])})),lt([n,r,e],o?[o]:[],(function(r){if(r=r[0],o)var e=r.Z,i=e.ra;else i=At.prototype;r=it(v,(function(){if(Object.getPrototypeOf(this)!==f)throw new ft("Use 'new' to construct "+l);if(void 0===c.na)throw new ft(l+" has no accessible constructor");var n=c.na[arguments.length];if(void 0===n)throw new ft("Tried to invoke ctor of "+l+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(c.na).toString()+") parameters instead!");return n.apply(this,arguments)}));var f=Object.create(i,{constructor:{value:r}});r.prototype=f;var c=new _t(l,r,f,w,e,u,a,s);e=new Ft(l,c,!0,!1),i=new Ft(l+"*",c,!1,!1);var h=new Ft(l+" const*",c,!1,!0);return Et[n]={pointerType:i,Ya:h},function(n,r){t.hasOwnProperty(n)||st("Replacing nonexistant public symbol"),t[n]=r,t[n].pa=void 0}(v,r),[e,i,h]}))},b:function(n,t,r,e,o,i,u){var f=Gt(r,e);t=nt(t),i=Ct(o,i),lt([],[n],(function(n){function e(){Nt("Cannot call "+o+" due to unbound types",f)}var o=(n=n[0]).name+"."+t;t.startsWith("@@")&&(t=Symbol[t.substring(2)]);var a=n.Z.constructor;return void 0===a[t]?(e.pa=r-1,a[t]=e):(jt(a,t,o),a[t].da[r-1]=e),lt([],f,(function(n){return n=[n[0],null].concat(n.slice(1)),n=Bt(o,n,null,i,u),void 0===a[t].da?(n.pa=r-1,a[t]=n):a[t].da[r-1]=n,[]})),[]}))},p:function(n,t,r,e,o,i,u,f){t=nt(t),i=Ct(o,i),lt([],[n],(function(n){var o=(n=n[0]).name+"."+t,a={get:function(){Nt("Cannot access "+o+" due to unbound types",[r])},enumerable:!0,configurable:!0};return a.set=f?function(){Nt("Cannot access "+o+" due to unbound types",[r])}:function(){at(o+" is a read-only property")},Object.defineProperty(n.Z.constructor,t,a),lt([],[r],(function(r){r=r[0];var o={get:function(){return r.fromWireType(i(e))},enumerable:!0};return f&&(f=Ct(u,f),o.set=function(n){var t=[];f(e,r.toWireType(t,n)),$t(t)}),Object.defineProperty(n.Z.constructor,t,o),[]})),[]}))},r:function(n,t,r,e,o,i){_(0>>f}}var a=t.includes("unsigned");ht(n,{name:t,fromWireType:i,toWireType:function(n,r){if("number"!=typeof r&&"boolean"!=typeof r)throw new TypeError('Cannot convert "'+Vt(r)+'" to '+this.name);if(ro)throw new TypeError('Passing a number "'+Vt(r)+'" from JS side to C/C++ side to an argument of type "'+t+'", which is outside the valid range ['+e+", "+o+"]!");return a?r>>>0:0|r},argPackAdvance:8,readValueFromPointer:Yt(t,u,0!==e),ka:null})},g:function(n,t,r){function e(n){var t=q;return new o(P,t[1+(n>>=2)],t[n])}var o=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];ht(n,{name:r=nt(r),fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{cb:!0})},t:function(n,t){var r="std::string"===(t=nt(t));ht(n,{name:t,fromWireType:function(n){var t=q[n>>2];if(r)for(var e=n+4,o=0;o<=t;++o){var i=n+4+o;if(o==t||0==W[i]){if(e=e?k(W,e,i-e):"",void 0===u)var u=e;else u+=String.fromCharCode(0),u+=e;e=i+1}}else{for(u=Array(t),o=0;o>2]=o,r&&e)M(t,W,i+4,o+1);else if(e)for(e=0;e>2],i=u(),a=n+4,c=0;c<=o;++c){var s=n+4+c*t;c!=o&&0!=i[s>>f]||(a=e(a,s-a),void 0===r?r=a:(r+=String.fromCharCode(0),r+=a),a=s+t)}return pr(n),r},toWireType:function(n,e){"string"!=typeof e&&at("Cannot pass non-string to C++ string type "+r);var u=i(e),a=yr(4+u+t);return q[a>>2]=u>>f,o(e,a+4,u+t),null!==n&&n.push(pr,a),a},argPackAdvance:8,readValueFromPointer:Tt,ka:function(n){pr(n)}})},G:function(n,t){ht(n,{fb:!0,name:t=nt(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},i:function(n,t,r){n=Lt(n),t=Xt(t,"emval::as");var e=[],o=zt(e);return G[r>>2]=o,t.toWireType(e,n)},H:function(n,t,r,e,o){n=Kt[n],t=Lt(t),r=Zt(r);var i=[];return G[e>>2]=zt(i),n(t,r,i,o)},I:function(n,t,r,e){(n=Kt[n])(t=Lt(t),r=Zt(r),null,e)},a:Rt,v:function(n){return 0===n?zt(nr()):(n=Zt(n),zt(nr()[n]))},u:function(n,t){for(var r=(t=function(n,t){for(var r=Array(n),e=0;e>2)+e],"parameter "+e);return r}(n,t))[0],e=r.name+"_$"+t.slice(1).map((function(n){return n.name})).join("_")+"$",o=["retType"],i=[r],u="",f=0;f>> 2) + "+u+'], "parameter '+u+'");\nvar arg'+u+" = argType"+u+".readValueFromPointer(args);\nargs += argType"+u+"['argPackAdvance'];\n";i=new Function("requireRegisteredType","Module","__emval_register",f+"var obj = new constructor("+i+");\nreturn __emval_register(obj);\n}\n")(Xt,t,zt),rr[r]=i}return i(n,e,o)},m:function(n){return zt(Zt(n))},h:function(n){$t(Ht[n].value),Rt(n)},n:function(n,t){return zt(n=(n=Xt(n,"_emval_take_value")).readValueFromPointer(t))},q:function(){K()},x:function(){K("OOM")},z:function(n,t){try{var r=0;return or().forEach((function(e,o){var i=t+r;for(o=G[n+4*o>>2]=i,i=0;i>0]=e.charCodeAt(i);N[o>>0]=0,r+=e.length+1})),0}catch(n){return void 0!==Ln&&n instanceof _n||K(n),n.ua}},A:function(n,t){try{var r=or();G[n>>2]=r.length;var e=0;return r.forEach((function(n){e+=n.length+1})),G[t>>2]=e,0}catch(n){return void 0!==Ln&&n instanceof _n||K(n),n.ua}},B:function(n){try{var t=Qn(n);if(null===t.fd)throw new _n(8);t.bb&&(t.bb=null);try{t.$.close&&t.$.close(t)}catch(n){throw n}finally{gn[t.fd]=null}return t.fd=null,0}catch(n){return void 0!==Ln&&n instanceof _n||K(n),n.ua}},C:function(n,t,r,e){try{n:{for(var o=Qn(n),i=n=0;i>2],f=o,a=G[t+8*i>>2],c=u,s=void 0,l=N;if(0>c||0>s)throw new _n(28);if(null===f.fd)throw new _n(8);if(1==(2097155&f.flags))throw new _n(8);if(16384==(61440&f.node.mode))throw new _n(31);if(!f.$.read)throw new _n(28);var h=void 0!==s;if(h){if(!f.seekable)throw new _n(70)}else s=f.position;var w=f.$.read(f,l,a,c,s);h||(f.position+=w);var v=w;if(0>v){var d=-1;break n}if(n+=v,v>2]=d,0}catch(n){return void 0!==Ln&&n instanceof _n||K(n),n.ua}},y:function(n,t,r,e){return function(n,t,r,e){function o(n,t,r){for(n="number"==typeof n?n.toString():n||"";n.lengthn?-1:0=u(r,n)?0>=u(t,n)?n.getFullYear()+1:n.getFullYear():n.getFullYear()-1}var c=G[e+40>>2];for(var s in e={wb:G[e>>2],vb:G[e+4>>2],Da:G[e+8>>2],xa:G[e+12>>2],ta:G[e+16>>2],ea:G[e+20>>2],Ea:G[e+24>>2],Fa:G[e+28>>2],Cb:G[e+32>>2],ub:G[e+36>>2],xb:c&&c?k(W,c,void 0):""},r=r?k(W,r,void 0):"",c={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})r=r.replace(new RegExp(s,"g"),c[s]);var l="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),h="January February March April May June July August September October November December".split(" ");for(s in c={"%a":function(n){return l[n.Ea].substring(0,3)},"%A":function(n){return l[n.Ea]},"%b":function(n){return h[n.ta].substring(0,3)},"%B":function(n){return h[n.ta]},"%C":function(n){return i((n.ea+1900)/100|0,2)},"%d":function(n){return i(n.xa,2)},"%e":function(n){return o(n.xa,2," ")},"%g":function(n){return a(n).toString().substring(2)},"%G":function(n){return a(n)},"%H":function(n){return i(n.Da,2)},"%I":function(n){return 0==(n=n.Da)?n=12:12n.Da?"AM":"PM"},"%S":function(n){return i(n.wb,2)},"%t":function(){return"\t"},"%u":function(n){return n.Ea||7},"%U":function(n){var t=new Date(n.ea+1900,0,1),r=0===t.getDay()?t:cr(t,7-t.getDay());return 0>u(r,n=new Date(n.ea+1900,n.ta,n.xa))?i(Math.ceil((31-r.getDate()+(ur(ir(n.getFullYear())?fr:ar,n.getMonth()-1)-31)+n.getDate())/7),2):0===u(r,t)?"01":"00"},"%V":function(n){var t=new Date(n.ea+1901,0,4),r=f(new Date(n.ea+1900,0,4));t=f(t);var e=cr(new Date(n.ea+1900,0,1),n.Fa);return 0>u(e,r)?"53":0>=u(t,e)?"01":i(Math.ceil((r.getFullYear()u(r,n=new Date(n.ea+1900,n.ta,n.xa))?i(Math.ceil((31-r.getDate()+(ur(ir(n.getFullYear())?fr:ar,n.getMonth()-1)-31)+n.getDate())/7),2):0===u(r,t)?"01":"00"},"%y":function(n){return(n.ea+1900).toString().substring(2)},"%Y":function(n){return n.ea+1900},"%z":function(n){var t=0<=(n=n.ub);return n=Math.abs(n)/60,(t?"+":"-")+String("0000"+(n/60*100+n%60)).slice(-4)},"%Z":function(n){return n.xb},"%%":function(){return"%"}})r.includes(s)&&(r=r.replace(new RegExp(s,"g"),c[s](e)));return(s=wr(r,!1)).length>t?0:(N.set(s,n),s.length-1)}(n,t,r,e)}};!function(){function n(n){t.asm=n.exports,E=t.asm.K,P=n=E.buffer,t.HEAP8=N=new Int8Array(n),t.HEAP16=$=new Int16Array(n),t.HEAP32=G=new Int32Array(n),t.HEAPU8=W=new Uint8Array(n),t.HEAPU16=B=new Uint16Array(n),t.HEAPU32=q=new Uint32Array(n),t.HEAPF32=H=new Float32Array(n),t.HEAPF64=R=new Float64Array(n),z=t.asm.N,J.unshift(t.asm.L),X--,t.monitorRunDependencies&&t.monitorRunDependencies(X),0==X&&(null!==Q&&(clearInterval(Q),Q=null),Z&&(n=Z,Z=null,n()))}function r(t){n(t.instance)}function e(n){return function(){if(!m&&(a||c)){if("function"==typeof fetch&&!tn.startsWith("file://"))return fetch(tn,{credentials:"same-origin"}).then((function(n){if(!n.ok)throw"failed to load wasm binary file at '"+tn+"'";return n.arrayBuffer()})).catch((function(){return en()}));if(v)return new Promise((function(n,t){v(tn,(function(t){n(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return en()}))}().then((function(n){return WebAssembly.instantiate(n,o)})).then(n,(function(n){A("failed to asynchronously prepare wasm: "+n),K(n)}))}var o={a:vr};if(X++,t.monitorRunDependencies&&t.monitorRunDependencies(X),t.instantiateWasm)try{return t.instantiateWasm(o,n)}catch(n){return A("Module.instantiateWasm callback failed with error: "+n),!1}(m||"function"!=typeof WebAssembly.instantiateStreaming||nn()||tn.startsWith("file://")||"function"!=typeof fetch?e(r):fetch(tn,{credentials:"same-origin"}).then((function(n){return WebAssembly.instantiateStreaming(n,o).then(r,(function(n){return A("wasm streaming compile failed: "+n),A("falling back to ArrayBuffer instantiation"),e(r)}))}))).catch(i)}(),t.nn=function(){return(t.nn=t.asm.L).apply(null,arguments)};var dr,yr=t.tn=function(){return(yr=t.tn=t.asm.M).apply(null,arguments)},pr=t.rn=function(){return(pr=t.rn=t.asm.O).apply(null,arguments)},br=t.en=function(){return(br=t.en=t.asm.P).apply(null,arguments)};function mr(){function n(){if(!dr&&(dr=!0,t.calledRun=!0,!j)){if(t.noFSInit||Cn||(Cn=!0,Rn(),t.stdin=t.stdin,t.stdout=t.stdout,t.stderr=t.stderr,t.stdin?zn("stdin",t.stdin):Gn("/dev/tty","/dev/stdin"),t.stdout?zn("stdout",null,t.stdout):Gn("/dev/tty","/dev/stdout"),t.stderr?zn("stderr",null,t.stderr):Gn("/dev/tty1","/dev/stderr"),Hn("/dev/stdin",0),Hn("/dev/stdout",1),Hn("/dev/stderr",1)),on(J),o(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;){var n=t.postRun.shift();Y.unshift(n)}on(Y)}}if(!(0"===n?i>t:">="===n?i>=t:i===t))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return t.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return r(845).randomBytes(4).readInt32LE()}}(),f=function(){function n(t,r){if(Array.isArray(t)||!t)return this.i=Array.isArray(t)?t:[],void(this.u="number"==typeof r?r:4*this.i.length);if(t instanceof n)return this.i=t.words.slice(),void(this.u=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var o=e.byteLength,i=[],u=0;u>>2]|=e[u]<<24-u%4*8;this.i=i,this.u=o}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):a.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.i,t=this.u,r=new Uint8Array(t),e=0;e>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=o<<24-(this.u+e)%4*8}else for(e=0;e>>2]=t[e>>>2];return this.u+=r,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(t){for(var r=[],e=0;e>>2]>>>24-o%4*8&255;e.push((i>>>4).toString(16)),e.push((15&i).toString(16))}return e.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new f(r,t/2)}};return t}()},915:function(n,t,r){n.exports=function(){"use strict";var n={3354:function(n,t,r){r.d(t,{e:function(){return i}});var e=r(5720),o=r(9054),i=function(){function n(t,r){if(Array.isArray(t)||!t)return this.t=Array.isArray(t)?t:[],void(this.i="number"==typeof r?r:4*this.t.length);if(t instanceof n)return this.t=t.words.slice(),void(this.i=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var o=e.byteLength,i=[],u=0;u>>2]|=e[u]<<24-u%4*8;this.t=i,this.i=o}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.i},set:function(n){this.i=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.t},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):e.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.t,t=this.i,r=new Uint8Array(t),e=0;e>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.i%4)for(var e=0;e>>2]>>>24-e%4*8&255;this.t[this.i+e>>>2]|=o<<24-(this.i+e)%4*8}else for(e=0;e>>2]=t[e>>>2];return this.i+=r,this},n.prototype.clamp=function(){var n=this.i;this.t[n>>>2]&=4294967295<<32-n%4*8,this.t.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.t.slice(),this.i)},n.random=function(t){for(var r=[],e=0;e"===n?i>t:">="===n?i>=t:i===t))}},5720:function(n,t,r){r.d(t,{p:function(){return o}});var e=r(3354),o={stringify:function(n){for(var t=n.nSigBytes,r=n.words,e=[],o=0;o>>2]>>>24-o%4*8&255;e.push((i>>>4).toString(16)),e.push((15&i).toString(16))}return e.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],o=0;o>>3]|=parseInt(n.substr(o,2),16)<<24-o%8*4;return new e.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return o}});var e=r(3354),o={stringify:function(n){for(var t=n.nSigBytes,r=n.words,e=[],o=0;o>>2]>>>24-o%4*8&255;e.push(String.fromCharCode(i))}return e.join("")},parse:function(n){for(var t=n.length,r=[],o=0;o>>2]|=(255&n.charCodeAt(o))<<24-o%4*8;return new e.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return o}});var e=r(8702),o={stringify:function(n){try{return decodeURIComponent(escape(e.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return e.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,e){e.d(t,{M:function(){return i}});var o=e(1756),i=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,o.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==e.g&&e.g.crypto?function(){return e.g.crypto.randomBytes(4).readInt32LE()}:function(){return r(845).randomBytes(4).readInt32LE()}}()}},t={};function e(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return n[r](i,i.exports,e),i.exports}e.d=function(n,t){for(var r in t)e.o(t,r)&&!e.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:t[r]})},e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"S",{value:!0})};var o={};return function(){e.r(o),e.d(o,{SHA256:function(){return l}});var n,t=e(1868),r=e(3354),i=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function e(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}),u=[],f=[];function a(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function c(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)a(n)&&(t<8&&(u[t]=c(Math.pow(n,.5))),f[t]=c(Math.pow(n,1/3)),t++),n++}();var s=[],l=function(n){function t(t){var e=n.call(this,t)||this;return e.N=new r.e(u.slice(0)),e.v=t,t&&void 0!==t.hash&&(e.N=t.hash.clone()),e}return i(t,n),t.prototype.U=function(){this.N=new r.e(u.slice(0))},t.prototype.I=function(n,t){for(var r=this.N.words,e=r[0],o=r[1],i=r[2],u=r[3],a=r[4],c=r[5],l=r[6],h=r[7],w=0;w<64;w++){if(w<16)s[w]=0|n[t+w];else{var v=s[w-15],d=(v<<25|v>>>7)^(v<<14|v>>>18)^v>>>3,y=s[w-2],p=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;s[w]=d+s[w-7]+p+s[w-16]}var b=e&o^e&i^o&i,m=(e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22),g=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&c^~a&l)+f[w]+s[w];h=l,l=c,c=a,a=u+g|0,u=i,i=o,o=e,e=g+(m+b)|0}r[0]=r[0]+e|0,r[1]=r[1]+o|0,r[2]=r[2]+i|0,r[3]=r[3]+u|0,r[4]=r[4]+a|0,r[5]=r[5]+c|0,r[6]=r[6]+l|0,r[7]=r[7]+h|0},t.prototype._=function(){var n=this.l.words,t=8*this.A,r=8*this.l.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.l.nSigBytes=4*n.length,this.O(),this.N},t.prototype.clone=function(){return new t({hash:this.N,blockSize:this.h,data:this.l,nBytes:this.A})},t.hash=function(n,r){return new t(r).finalize(n)},t}(t.P)}(),o}()},699:function(n,t,r){n.exports=function(){"use strict";var n={d:function(t,r){for(var e in r)n.o(r,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var t={};n.r(t),n.d(t,{Utf8:function(){return l}});var e,o=function(n){for(var t=n.nSigBytes,r=n.words,e=[],o=0;o>>2]>>>24-o%4*8&255;e.push((i>>>4).toString(16)),e.push((15&i).toString(16))}return e.join("")},i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",u=(e=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(e)?(e=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(e)&&e):e),f=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(!t){if(function(n,t){return!1!==u&&(!t||("<"===n?u"===n?u>t:">="===n?u>=t:u===t))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return t.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return r(845).randomBytes(4).readInt32LE()}}(),a=function(){function n(t,r){if(Array.isArray(t)||!t)return this.i=Array.isArray(t)?t:[],void(this.u="number"==typeof r?r:4*this.i.length);if(t instanceof n)return this.i=t.words.slice(),void(this.u=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var o=e.byteLength,i=[],u=0;u>>2]|=e[u]<<24-u%4*8;this.i=i,this.u=o}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):o(this)},n.prototype.toUint8Array=function(){for(var n=this.i,t=this.u,r=new Uint8Array(t),e=0;e>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=o<<24-(this.u+e)%4*8}else for(e=0;e>>2]=t[e>>>2];return this.u+=r,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(t){for(var r=[],e=0;e>>2]>>>24-o%4*8&255;e.push(String.fromCharCode(i))}return e.join("")},s=function(n){for(var t=n.length,r=[],e=0;e>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new a(r,t)},l={stringify:function(n){try{return decodeURIComponent(escape(c(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return s(unescape(encodeURIComponent(n)))}};return t}()},893:function(n,t,r){n.exports=function(){"use strict";var n={d:function(t,r){for(var e in r)n.o(r,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var t={};n.r(t),n.d(t,{Word32Array:function(){return a}});var e,o=function(n){for(var t=n.nSigBytes,r=n.words,e=[],o=0;o>>2]>>>24-o%4*8&255;e.push((i>>>4).toString(16)),e.push((15&i).toString(16))}return e.join("")},i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",u=(e=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(e)?(e=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(e)&&e):e),f=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(!t){if(function(n,t){return!1!==u&&(!t||("<"===n?u"===n?u>t:">="===n?u>=t:u===t))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return t.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return r(845).randomBytes(4).readInt32LE()}}(),a=function(){function n(t,r){if(Array.isArray(t)||!t)return this.i=Array.isArray(t)?t:[],void(this.u="number"==typeof r?r:4*this.i.length);if(t instanceof n)return this.i=t.words.slice(),void(this.u=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var o=e.byteLength,i=[],u=0;u>>2]|=e[u]<<24-u%4*8;this.i=i,this.u=o}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):o(this)},n.prototype.toUint8Array=function(){for(var n=this.i,t=this.u,r=new Uint8Array(t),e=0;e>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=o<<24-(this.u+e)%4*8}else for(e=0;e>>2]=t[e>>>2];return this.u+=r,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(t){for(var r=[],e=0;e0)throw new Error(`can't cast ${JSON.stringify(n)} to bytes`);return i.Bytes.NULL}if("function"==typeof n.serialize)return i.Bytes.from(n,"G1Element");throw new Error(`can't cast ${JSON.stringify(n)} to bytes`)}function h(n){let t=n;const r=[t],u=[i.t(0,e.None)];for(;u.length;){const n=u.pop(),f=n[0];let a=n[1];if(0!==f){if(null===a)throw new Error("Invalid target. target is null");1===f?r[a].pair=i.t(new o.CLVMObject(r.pop()),r[a].pair[1]):2===f?r[a].pair=i.t(r[a].pair[0],new o.CLVMObject(r.pop())):3===f&&(r[a]=new o.CLVMObject(i.t(r.pop(),r[a])))}else{if(s(r[r.length-1]))continue;if(t=r.pop(),t instanceof i.Tuple){if(2!==t.length)throw new Error(`can't cast tuple of size ${t.length}`);const[n,f]=t;a=r.length,r.push(new o.CLVMObject(i.t(n,f))),s(f)||(r.push(f),u.push(i.t(2,a)),u.push(i.t(0,e.None))),s(n)||(r.push(n),u.push(i.t(1,a)),u.push(i.t(0,e.None)));continue}if(Array.isArray(t)){a=r.length,r.push(new o.CLVMObject(i.Bytes.NULL));for(const n of t)r.push(n),u.push(i.t(3,a)),s(n)||u.push(i.t(0,e.None));continue}r.push(new o.CLVMObject(l(t)))}}if(1!==r.length)throw new Error("internal error");return r[0]}t.looks_like_clvm_object=s,t.convert_atom_to_bytes=l,t.to_sexp_type=h;class w extends o.CLVMObject{constructor(n){super(n),this.atom=n.atom,this.pair=n.pair}static to(n){return n instanceof w?n:s(n)?new w(n):new w(h(n))}static null(){return w.an}as_pair(){const n=this.pair;return n===e.None?n:i.t(new w(n[0]),new w(n[1]))}listp(){return this.pair!==e.None}nullp(){return this.atom!==e.None&&0===this.atom.raw().length}as_int(){return u.int_from_bytes(this.atom)}as_bin(){const n=new i.Stream;return f.sexp_to_stream(this,n),n.getValue()}cons(n){return w.to(i.t(this,n))}first(){const n=this.pair;if(n)return new w(n[0]);throw new c.EvalError("first of non-cons",this)}rest(){const n=this.pair;if(n)return new w(n[1]);throw new c.EvalError("rest of non-cons",this)}*as_iter(){let n=this;for(;!n.nullp();)yield n.first(),n=n.rest()}equal_to(n){try{n=w.to(n);const t=[i.t(this,n)];for(;t.length;){const[n,r]=t.pop(),e=n.as_pair();if(e){const n=r.as_pair();if(!n)return!1;t.push(i.t(e[0],n[0])),t.push(i.t(e[1],n[1]))}else if(r.as_pair()||!(n.atom&&r.atom&&n.atom.equal_to(r.atom)))return!1}return!0}catch(n){return!1}}list_len(){let n=this,t=0;for(;n.listp();)t+=1,n=n.rest();return t}as_javascript(){return a.as_javascript(this)}toString(){return this.as_bin().toString()}cn(){return`SExp(${this.as_bin().toString()})`}}t.SExp=w,w.TRUE=new w(new o.CLVMObject(i.Bytes.from("0x01","hex"))),w.FALSE=new w(new o.CLVMObject(i.Bytes.NULL)),w.an=new w(new o.CLVMObject(i.Bytes.NULL))},190:function(n,t,r){"use strict";var e=this&&this.sn||function(n,t,r,e){return new(r||(r=Promise))((function(o,i){function u(n){try{a(e.next(n))}catch(n){i(n)}}function f(n){try{a(e.throw(n))}catch(n){i(n)}}function a(n){var t;n.done?o(n.value):(t=n.value,t instanceof r?t:new r((function(n){n(t)}))).then(u,f)}a((e=e.apply(n,t||[])).next())}))};Object.defineProperty(t,"un",{value:!0}),t.G1Element_add=t.assert_G1Element_valid=t.G1Element_from_bytes=t.getBLSModule=t.initializeBLS=t.loadPromise=t.BLS=void 0;const o=r(513);function i(){if(!t.BLS)throw new Error("BLS module has not been loaded. Please call `await initializeBLS()` on start up");return t.BLS}function u(n){const t=i(),{G1Element:r}=t;if(n.length!==r.SIZE)throw new Error("G1Element: Invalid size");if(192==(192&n[0])){if(192!==n[0])throw new Error("G1Element: Given G1 infinity element must be canonical");for(let t=1;t{if(t.BLS)return t.loadPromise=void 0,n(t.BLS);o().then((e=>e?(t.loadPromise=void 0,n(t.BLS=e)):r())).catch((n=>(console.error("Error while loading BLS module"),r(n))))}))}))},t.getBLSModule=i,t.G1Element_from_bytes=function(n){u(n);const t=i();try{return t.G1Element.from_bytes(n)}catch(n){throw new Error("Exception in G1Element operation")}},t.assert_G1Element_valid=u,t.G1Element_add=function(n,t){try{return n.add(t)}catch(n){throw new Error("Exception in G1Element operation")}}},572:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.prettyPrint=void 0;const e=r(907);t.prettyPrint=function(n){if(n){const n=e.SExp.prototype.toString;e.SExp.prototype.toString=e.SExp.prototype.cn,e.SExp.prototype.cn=n}else{const n=e.SExp.prototype.toString;e.SExp.prototype.toString=e.SExp.prototype.cn,e.SExp.prototype.cn=n}}},213:function(n,t){"use strict";Object.defineProperty(t,"un",{value:!0}),t.None=void 0,t.None=null},593:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.Stream=t.isIterable=t.isList=t.isTuple=t.t=t.Tuple=t.h=t.b=t.Bytes=t.to_hexstr=void 0;const e=r(502),o=r(699),i=r(893),u=r(915),f=r(213);function a(n){return new i.Word32Array(n).toString()}t.to_hexstr=a;class c{constructor(n){if(n instanceof Uint8Array)this.ln=new Uint8Array(n);else if(n instanceof c)this.ln=n.data();else{if(n&&n!==f.None)throw new Error(`Invalid value: ${JSON.stringify(n)}`);this.ln=new Uint8Array}}static from(n,t){if(n instanceof Uint8Array||n instanceof c||n===f.None||void 0===n)return new c(n);if(Array.isArray(n)&&n.every((n=>"number"==typeof n))){if(n.some((n=>n<0||n>255)))throw new Error("Bytes must be in range [0, 256)");return new c(Uint8Array.from(n))}if("string"==typeof n)return"hex"===t?(n=n.replace(/^0x/,""),new c(e.Hex.parse(n).toUint8Array())):new c(o.Utf8.parse(n).toUint8Array());if("G1Element"===t){if("function"!=typeof n.serialize)throw new Error("Invalid G1Element");const t=n.serialize();return new c(t)}throw new Error(`Invalid value: ${JSON.stringify(n)}`)}static SHA256(n){let t;if("string"==typeof n)t=u.SHA256.hash(n);else if(n instanceof Uint8Array)t=new i.Word32Array(n),t=u.SHA256.hash(t);else{if(!(n instanceof c))throw new Error("Invalid argument");t=n.as_word(),t=u.SHA256.hash(t)}return new c(t.toUint8Array())}get length(){return this.ln.length}get_byte_at(n){return 0|this.ln[n]}concat(n){const t=this.as_word(),r=n.as_word(),e=t.concat(r);return c.from(e.toUint8Array())}slice(n,t){const r="number"==typeof t?t:this.length-n;return new c(this.ln.slice(n,n+r))}as_word(){return new i.Word32Array(this.ln)}data(){return new Uint8Array(this.ln)}raw(){return this.ln}clone(){return new c(this.ln)}toString(){return a(this.ln)}hex(){return this.toString()}decode(){return o.Utf8.stringify(this.as_word())}startswith(n){return this.toString().startsWith(n.toString())}endswith(n){return this.toString().endsWith(n.toString())}equal_to(n){return!!n&&0===this.compare(n)}compare(n){if(this.length!==n.length)return this.length>n.length?1:-1;for(let t=0;te?1:-1}return 0}}t.Bytes=c,c.NULL=new c,t.b=function(n,t="utf8"){return c.from(n,t)},t.h=function(n){return c.from(n,"hex")};class s extends Array{constructor(...n){return super(...n),Object.freeze(this),this}toString(){return`(${this[0]}, ${this[1]})`}}t.Tuple=s,t.t=function(n,t){return new s(n,t)},t.isTuple=function(n){return n instanceof s},t.isList=function(n){return Array.isArray(n)&&!(n instanceof s)},t.isIterable=function(n){return!!Array.isArray(n)||"string"!=typeof n&&"function"==typeof n[Symbol.iterator]},t.Stream=class{constructor(n){this.hn=n?new c(n):new c,this.wn=0}get seek(){return this.wn}set seek(n){n<0?this.wn=this.hn.length-1:n>this.hn.length-1?this.wn=this.hn.length:this.wn=n}get length(){return this.hn.length}write(n){const t=this.hn.data(),r=n.data(),e=Math.max(t.length,r.length+this.wn),o=new Uint8Array(e),i=this.seek;for(let n=0;nthis.hn.length-1)return new c;const t=this.hn.slice(this.seek,n);return this.seek+=n,t}getValue(){return this.hn}}},19:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.as_javascript=void 0;const e=r(593);t.as_javascript=function(n){function t(n,t){const r=t.pop(),e=t.pop();t.push(r),t.push(e)}function r(n,t){const r=t.pop(),o=t.pop();o.equal_to(e.Bytes.NULL)?t.push([r]):t.push(e.t(r,o))}function o(n,t){let r=[t.pop()];const e=t.pop();r=r.concat(e),t.push(r)}const i=[function n(e,i){const u=i.pop(),f=u.as_pair();if(f){const[u,a]=f;a.listp()?e.push(o):e.push(r),e.push(n),e.push(t),e.push(n),i.push(u),i.push(a)}else i.push(u.atom)}],u=[n];for(;i.length;){const n=i.pop();n&&n(i,u)}return u[u.length-1]}},959:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.limbs_for_int=t.int_to_bytes=t.int_from_bytes=void 0;const e=r(593);t.int_from_bytes=function(n){return n&&0!==n.length?parseInt(n.hex(),16):0},t.int_to_bytes=function(n){if(n>Number.MAX_SAFE_INTEGER||n0?"MAX_SAFE_INTEGER":"MIN_SAFE_INTEGER"}: ${n}`);if(0===n)return e.Bytes.NULL;const t=(n<0?-n:n).toString(2).length+8>>3;let r=(n>>>0).toString(16);for(n>=0&&(r=r.length%2?`0${r}`:r);r.length/22&&r.substr(0,2)===(128&parseInt(r.substr(2,2),16)?"ff":"00");)r=r.substr(2);return e.h(r)},t.limbs_for_int=function(n){return(n<0?-n:n).toString(2).length+7>>3}},143:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.op_eq=t.op_raise=t.op_listp=t.op_rest=t.op_first=t.op_cons=t.op_if=void 0;const e=r(907),o=r(593),i=r(449),u=r(755);t.op_if=function(n){if(3!==n.list_len())throw new u.EvalError("i takes exactly 3 arguments",n);const t=n.rest();return n.first().nullp()?o.t(i.IF_COST,t.rest().first()):o.t(i.IF_COST,t.first())},t.op_cons=function(n){if(2!==n.list_len())throw new u.EvalError("c takes exactly 2 arguments",n);return o.t(i.CONS_COST,n.first().cons(n.rest().first()))},t.op_first=function(n){if(1!==n.list_len())throw new u.EvalError("f takes exactly 1 argument",n);return o.t(i.FIRST_COST,n.first().first())},t.op_rest=function(n){if(1!==n.list_len())throw new u.EvalError("r takes exactly 1 argument",n);return o.t(i.REST_COST,n.first().rest())},t.op_listp=function(n){if(1!==n.list_len())throw new u.EvalError("l takes exactly 1 argument",n);return o.t(i.LISTP_COST,n.first().listp()?e.SExp.TRUE:e.SExp.FALSE)},t.op_raise=function(n){throw new u.EvalError("clvm raise",n)},t.op_eq=function(n){if(2!==n.list_len())throw new u.EvalError("= takes exactly 2 arguments",n);const t=n.first(),r=n.rest().first();if(t.pair||r.pair)throw new u.EvalError("= on list",t.pair?t:r);const f=t.atom,a=r.atom;let c=i.EQ_BASE_COST;return c+=(f.length+a.length)*i.EQ_COST_PER_BYTE,o.t(c,f.equal_to(a)?e.SExp.TRUE:e.SExp.FALSE)}},449:function(n,t){"use strict";Object.defineProperty(t,"un",{value:!0}),t.APPLY_COST=t.LOGNOT_COST_PER_BYTE=t.LOGNOT_BASE_COST=t.LSHIFT_COST_PER_BYTE=t.LSHIFT_BASE_COST=t.ASHIFT_COST_PER_BYTE=t.ASHIFT_BASE_COST=t.BOOL_COST_PER_ARG=t.BOOL_BASE_COST=t.CONCAT_COST_PER_BYTE=t.CONCAT_COST_PER_ARG=t.CONCAT_BASE_COST=t.PATH_LOOKUP_COST_PER_ZERO_BYTE=t.PATH_LOOKUP_COST_PER_LEG=t.PATH_LOOKUP_BASE_COST=t.STRLEN_COST_PER_BYTE=t.STRLEN_BASE_COST=t.MUL_SQUARE_COST_PER_BYTE_DIVIDER=t.MUL_LINEAR_COST_PER_BYTE=t.MUL_COST_PER_OP=t.MUL_BASE_COST=t.PUBKEY_COST_PER_BYTE=t.PUBKEY_BASE_COST=t.POINT_ADD_COST_PER_ARG=t.POINT_ADD_BASE_COST=t.SHA256_COST_PER_BYTE=t.SHA256_COST_PER_ARG=t.SHA256_BASE_COST=t.DIV_COST_PER_BYTE=t.DIV_BASE_COST=t.DIVMOD_COST_PER_BYTE=t.DIVMOD_BASE_COST=t.GR_COST_PER_BYTE=t.GR_BASE_COST=t.EQ_COST_PER_BYTE=t.EQ_BASE_COST=t.GRS_COST_PER_BYTE=t.GRS_BASE_COST=t.LOG_COST_PER_ARG=t.LOG_COST_PER_BYTE=t.LOG_BASE_COST=t.ARITH_COST_PER_ARG=t.ARITH_COST_PER_BYTE=t.ARITH_BASE_COST=t.MALLOC_COST_PER_BYTE=t.LISTP_COST=t.REST_COST=t.FIRST_COST=t.CONS_COST=t.IF_COST=void 0,t.QUOTE_COST=void 0,t.IF_COST=33,t.CONS_COST=50,t.FIRST_COST=30,t.REST_COST=30,t.LISTP_COST=19,t.MALLOC_COST_PER_BYTE=10,t.ARITH_BASE_COST=99,t.ARITH_COST_PER_BYTE=3,t.ARITH_COST_PER_ARG=320,t.LOG_BASE_COST=100,t.LOG_COST_PER_BYTE=3,t.LOG_COST_PER_ARG=264,t.GRS_BASE_COST=117,t.GRS_COST_PER_BYTE=1,t.EQ_BASE_COST=117,t.EQ_COST_PER_BYTE=1,t.GR_BASE_COST=498,t.GR_COST_PER_BYTE=2,t.DIVMOD_BASE_COST=1116,t.DIVMOD_COST_PER_BYTE=6,t.DIV_BASE_COST=988,t.DIV_COST_PER_BYTE=4,t.SHA256_BASE_COST=87,t.SHA256_COST_PER_ARG=134,t.SHA256_COST_PER_BYTE=2,t.POINT_ADD_BASE_COST=101094,t.POINT_ADD_COST_PER_ARG=1343980,t.PUBKEY_BASE_COST=1325730,t.PUBKEY_COST_PER_BYTE=38,t.MUL_BASE_COST=92,t.MUL_COST_PER_OP=885,t.MUL_LINEAR_COST_PER_BYTE=6,t.MUL_SQUARE_COST_PER_BYTE_DIVIDER=128,t.STRLEN_BASE_COST=173,t.STRLEN_COST_PER_BYTE=1,t.PATH_LOOKUP_BASE_COST=40,t.PATH_LOOKUP_COST_PER_LEG=4,t.PATH_LOOKUP_COST_PER_ZERO_BYTE=4,t.CONCAT_BASE_COST=142,t.CONCAT_COST_PER_ARG=135,t.CONCAT_COST_PER_BYTE=3,t.BOOL_BASE_COST=200,t.BOOL_COST_PER_ARG=300,t.ASHIFT_BASE_COST=596,t.ASHIFT_COST_PER_BYTE=3,t.LSHIFT_BASE_COST=277,t.LSHIFT_COST_PER_BYTE=3,t.LOGNOT_BASE_COST=331,t.LOGNOT_COST_PER_BYTE=3,t.APPLY_COST=90,t.QUOTE_COST=20},465:function(n,t,r){"use strict";var e=this&&this.vn||(Object.create?function(n,t,r,e){void 0===e&&(e=r),Object.defineProperty(n,e,{enumerable:!0,get:function(){return t[r]}})}:function(n,t,r,e){void 0===e&&(e=r),n[e]=t[r]}),o=this&&this.dn||function(n,t){for(var r in n)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||e(t,n,r)};Object.defineProperty(t,"un",{value:!0}),t.to_sexp_f=void 0;const i=r(907);o(r(572),t),o(r(190),t),o(r(213),t),o(r(593),t),o(r(19),t),o(r(959),t),o(r(629),t),o(r(143),t),o(r(449),t),o(r(755),t),o(r(419),t),o(r(601),t),o(r(637),t),o(r(990),t),o(r(282),t),o(r(351),t),o(r(907),t),t.to_sexp_f=i.SExp.to},419:function(n,t,r){"use strict";var e=this&&this.sn||function(n,t,r,e){return new(r||(r=Promise))((function(o,i){function u(n){try{a(e.next(n))}catch(n){i(n)}}function f(n){try{a(e.throw(n))}catch(n){i(n)}}function a(n){var t;n.done?o(n.value):(t=n.value,t instanceof r?t:new r((function(n){n(t)}))).then(u,f)}a((e=e.apply(n,t||[])).next())}))};Object.defineProperty(t,"un",{value:!0}),t.initialize=void 0;const o=r(190);t.initialize=function(){return e(this,void 0,void 0,(function*(){yield o.initializeBLS()}))}},601:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.op_softfork=t.op_all=t.op_any=t.op_not=t.op_lognot=t.op_logxor=t.op_logior=t.op_logand=t.binop_reduction=t.op_lsh=t.op_ash=t.op_concat=t.op_substr=t.op_strlen=t.op_pubkey_for_exp=t.op_gr_bytes=t.op_gr=t.op_div=t.op_divmod=t.op_multiply=t.op_subtract=t.op_add=t.args_as_bool_list=t.args_as_bools=t.args_as_int_list=t.args_as_int32=t.args_as_ints=t.op_sha256=t.malloc_cost=void 0;const e=r(915),o=r(907),i=r(449),u=r(593),f=r(755),a=r(959),c=r(629),s=r(190);function l(n,t){if(!t.atom)throw new f.EvalError("atom is None",t);return u.t(n+t.atom.length*i.MALLOC_COST_PER_BYTE,t)}function*h(n,t){for(const r of t.as_iter()){if(r.pair||!r.atom)throw new f.EvalError(`${n} requires int args`,r);yield u.t(r.as_int(),r.atom.length)}}function*w(n,t){for(const r of t.as_iter()){if(r.pair||!r.atom)throw new f.EvalError(`${n} requires int32 args`,r);if(r.atom.length>4)throw new f.EvalError(`${n} requires int32 args (with no leading zeros`,r);yield r.as_int()}}function v(n,t,r){const e=[];for(const r of h(n,t))e.push(r);if(e.length!==r){const e=1!==r?"s":"";throw new f.EvalError(`${n} takes exactly ${r} argument${e}`,t)}return e}function*d(n,t){for(const n of t.as_iter()){const t=n.atom;(null==t?void 0:t.equal_to(u.Bytes.NULL))?yield o.SExp.FALSE:yield o.SExp.TRUE}}function y(n,t,r){const e=[];for(const n of d(0,t))e.push(n);if(e.length!==r){const e=1!==r?"s":"";throw new f.EvalError(`${n} takes exactly ${r} argument${e}`,t)}return e}function p(n,t,r,e){let u=t,f=0,a=i.LOG_BASE_COST;for(const t of h(n,r)){const[n,r]=t;u=e(u,n),f+=r,a+=i.LOG_COST_PER_ARG}return a+=f*i.LOG_COST_PER_BYTE,l(a,o.SExp.to(u))}t.malloc_cost=l,t.op_sha256=function(n){let t=i.SHA256_BASE_COST,r=0;const a=new e.SHA256;for(const e of n.as_iter()){const n=e.atom;if(!n)throw new f.EvalError("sha256 on list",e);r+=n.length,t+=i.SHA256_COST_PER_ARG,a.update(n.as_word())}return t+=r*i.SHA256_COST_PER_BYTE,l(t,o.SExp.to(u.Bytes.from(a.finalize().toUint8Array())))},t.args_as_ints=h,t.args_as_int32=w,t.args_as_int_list=v,t.args_as_bools=d,t.args_as_bool_list=y,t.op_add=function(n){let t=0,r=i.ARITH_BASE_COST,e=0;for(const o of h("+",n)){const[n,u]=o;t+=n,e+=u,r+=i.ARITH_COST_PER_ARG}return r+=e*i.ARITH_COST_PER_BYTE,l(r,o.SExp.to(t))},t.op_subtract=function(n){let t=i.ARITH_BASE_COST;if(n.nullp())return l(t,o.SExp.to(0));let r=1,e=0,u=0;for(const o of h("-",n)){const[n,f]=o;e+=r*n,r=-1,u+=f,t+=i.ARITH_COST_PER_BYTE}return t+=u*i.ARITH_COST_PER_BYTE,l(t,o.SExp.to(e))},t.op_multiply=function(n){let t=i.MUL_BASE_COST;const r=h("*",n),e=r.next();if(e.done)return l(t,o.SExp.to(1));let[u,f]=e.value;for(const n of r){const[r,e]=n;t+=i.MUL_COST_PER_OP,t+=(e+f)*i.MUL_LINEAR_COST_PER_BYTE,t+=e*f/i.MUL_SQUARE_COST_PER_BYTE_DIVIDER>>0,u*=r,f=a.limbs_for_int(u)}return l(t,o.SExp.to(u))},t.op_divmod=function(n){let t=i.DIVMOD_BASE_COST;const[r,e]=v("divmod",n,2),[a,c]=r,[s,l]=e;if(0===s)throw new f.EvalError("divmod with 0",o.SExp.to(a));t+=(c+l)*i.DIVMOD_COST_PER_BYTE;const h=a/s>>0,w=a%s,d=o.SExp.to(h),y=o.SExp.to(w);return t+=(d.atom.length+y.atom.length)*i.MALLOC_COST_PER_BYTE,u.t(t,o.SExp.to(u.t(h,w)))},t.op_div=function(n){let t=i.DIV_BASE_COST;const[r,e]=v("/",n,2),[u,a]=r,[c,s]=e;if(0===c)throw new f.EvalError("div with 0",o.SExp.to(u));t+=(a+s)*i.DIV_COST_PER_BYTE;const h=u/c>>0;return l(t,o.SExp.to(h))},t.op_gr=function(n){const[t,r]=v(">",n,2),[e,f]=t,[a,c]=r;let s=i.GR_BASE_COST;return s+=(f+c)*i.GR_COST_PER_BYTE,u.t(s,e>a?o.SExp.TRUE:o.SExp.FALSE)},t.op_gr_bytes=function(n){const t=[];for(const r of n.as_iter())t.push(r);if(2!==t.length)throw new f.EvalError(">s takes exactly 2 arguments",n);const[r,e]=t;if(r.pair||e.pair)throw new f.EvalError(">s on list",r.pair?r:e);const a=r.atom,c=e.atom;let s=i.GRS_BASE_COST;return s+=(a.length+c.length)*i.GRS_COST_PER_BYTE,u.t(s,a.compare(c)>0?o.SExp.TRUE:o.SExp.FALSE)},t.op_pubkey_for_exp=function(n){let t=i.POINT_ADD_BASE_COST;const{G1Element:r}=s.getBLSModule();let e=new r;for(const r of n.as_iter()){if(!c.isAtom(r))throw new f.EvalError("point_add on list",r);try{const n=s.G1Element_from_bytes(r.atom.data());e=s.G1Element_add(e,n),t+=i.POINT_ADD_COST_PER_ARG}catch(t){throw new f.EvalError(`point_add expects blob, got ${r.atom}: ${JSON.stringify(t)}`,n)}}return l(t,o.SExp.to(e))},t.op_strlen=function(n){if(1!==n.list_len())throw new f.EvalError("strlen takes exactly 1 argument",n);const t=n.first();if(!c.isAtom(t))throw new f.EvalError("strlen on list",t);const r=t.atom.length;return l(i.STRLEN_BASE_COST+r*i.STRLEN_COST_PER_BYTE,o.SExp.to(r))},t.op_substr=function(n){const t=n.list_len();if(![2,3].includes(t))throw new f.EvalError("substr takes exactly 2 or 3 arguments",n);const r=n.first();if(!c.isAtom(r))throw new f.EvalError("substr on list",r);const e=r.atom;let i,a;if(2===t)i=w("substr",n.rest()).next().value,a=e.length;else{const t=[];for(const r of w("substr",n.rest()))t.push(r);[i,a]=t}if(a>e.length||a4)throw new f.EvalError("ash requires int32 args (with no leading zeros)",n.rest().first());if(Math.abs(c)>65535)throw new f.EvalError("shift too large",o.SExp.to(c));let h;h=c>=0?e<>-c;let w=i.ASHIFT_BASE_COST;return w+=(u+a.limbs_for_int(h))*i.ASHIFT_COST_PER_BYTE,l(w,o.SExp.to(h))},t.op_lsh=function(n){const[t,r]=v("lsh",n,2),e=t[1],[u,c]=r;if(c>4)throw new f.EvalError("lsh requires int32 args (with no leading zeros)",n.rest().first());if(Math.abs(u)>65535)throw new f.EvalError("shift too large",o.SExp.to(u));const s=n.first().atom,h=a.int_from_bytes(s);let w;w=u>=0?h<>-u;let d=i.LSHIFT_BASE_COST;return d+=(e+a.limbs_for_int(w))*i.LSHIFT_COST_PER_BYTE,l(d,o.SExp.to(w))},t.binop_reduction=p,t.op_logand=function(n){return p("logand",-1,n,((n,t)=>n&=t))},t.op_logior=function(n){return p("logior",0,n,((n,t)=>n|=t))},t.op_logxor=function(n){return p("logxor",0,n,((n,t)=>n^=t))},t.op_lognot=function(n){const t=v("lognot",n,1),[r,e]=t[0];return l(i.LOGNOT_BASE_COST+e*i.LOGNOT_COST_PER_BYTE,o.SExp.to(~r))},t.op_not=function(n){const t=y("not",n,1)[0];if(!c.isAtom(t))throw new f.EvalError("not on list",n);let r;return r=t.atom.equal_to(u.Bytes.NULL)?o.SExp.TRUE:o.SExp.FALSE,u.t(i.BOOL_BASE_COST,o.SExp.to(r))},t.op_any=function(n){const t=[];for(const r of d(0,n))t.push(r);const r=i.BOOL_BASE_COST+t.length*i.BOOL_COST_PER_ARG;let e=o.SExp.FALSE;for(const r of t){if(!c.isAtom(r))throw new f.EvalError("any on list",n);if(!r.atom.equal_to(u.Bytes.NULL)){e=o.SExp.TRUE;break}}return u.t(r,o.SExp.to(e))},t.op_all=function(n){const t=[];for(const r of d(0,n))t.push(r);const r=i.BOOL_BASE_COST+t.length*i.BOOL_COST_PER_ARG;let e=o.SExp.TRUE;for(const r of t){if(!c.isAtom(r))throw new f.EvalError("all on list",n);if(r.atom.equal_to(u.Bytes.NULL)){e=o.SExp.FALSE;break}}return u.t(r,o.SExp.to(e))},t.op_softfork=function(n){if(n.list_len()<1)throw new f.EvalError("softfork takes at least 1 argument",n);const t=n.first();if(!c.isAtom(t))throw new f.EvalError("softfork requires int args",t);const r=t.as_int();if(r<1)throw new f.EvalError("cost must be > 0",n);return u.t(r,o.SExp.FALSE)}},637:function(n,t){"use strict";function r(n,t,r){const e={};for(const o of Object.keys(n)){const i=t[`op_${r[o]||o}`];"function"==typeof i&&(e[n[o]]=i)}return e}Object.defineProperty(t,"un",{value:!0}),t.operators_for_module=t.operators_for_dict=void 0,t.operators_for_dict=r,t.operators_for_module=function(n,t,e={}){return r(n,t,e)}},990:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.OPERATOR_LOOKUP=t.OperatorDict=t.APPLY_ATOM=t.QUOTE_ATOM=t.default_unknown_op=t.args_len=t.OP_REWRITE=t.KEYWORD_TO_ATOM=t.KEYWORD_FROM_ATOM=void 0;const e=r(959),o=r(907),i=r(593),u=r(755),f=r(449),a=r(637),c=r(143),s=r(601);function*l(n,t){for(const r of t.as_iter()){if(r.pair)throw new u.EvalError(`${n} requires int args"`,r);yield r.atom.length}}function h(n,t){if(0===n.length||n.slice(0,2).equal_to(i.Bytes.from("0xffff","hex")))throw new u.EvalError("reserved operator",o.SExp.to(n));const r=(192&n.get_byte_at(n.length-1))>>6;if(n.length>5)throw new u.EvalError("invalid operator",o.SExp.to(n));const a=e.int_from_bytes(n.slice(0,n.length-1))+1;let c;if(0===r)c=1;else if(1===r){c=f.ARITH_BASE_COST;let n=0;for(const r of l("unknown op",t))n+=r,c+=f.ARITH_COST_PER_ARG;c+=n*f.ARITH_COST_PER_BYTE}else if(2===r){c=f.MUL_BASE_COST;const n=l("unknown op",t),r=n.next();if(!r.done){let t=r.value;for(const r of n)c+=f.MUL_COST_PER_OP,c+=(r+t)*f.MUL_LINEAR_COST_PER_BYTE,c+=r*t/f.MUL_SQUARE_COST_PER_BYTE_DIVIDER>>0,t+=r}}else{if(3!==r)throw new Error(`Invalid cost_function: ${r}`);{c=f.CONCAT_BASE_COST;let n=0;for(const r of t.as_iter()){if(r.pair)throw new u.EvalError("unknown op on list",r);c+=f.CONCAT_COST_PER_ARG,n+=r.atom.length}c+=n*f.CONCAT_COST_PER_BYTE}}if(c*=a,c>=2**32)throw new u.EvalError("invalid operator",o.SExp.to(n));return i.t(c,o.SExp.null())}function w(n,t){Object.keys(t).forEach((r=>{n[r]=t[r]}))}function v(n,r,e,o){const u=Object.assign(Object.assign({},n),{quote_atom:r||n.quote_atom||t.QUOTE_ATOM,apply_atom:e||n.apply_atom||t.APPLY_ATOM,unknown_op_handler:o||h}),f=function(n,t){if("string"==typeof n)n=i.Bytes.from(n,"hex");else if("number"==typeof n)n=i.Bytes.from([n]);else if(!(n instanceof i.Bytes))throw new Error(`Invalid op: ${JSON.stringify(n)}`);w(u,f);const r=u[n.toString()];return"function"!=typeof r?u.unknown_op_handler(n,t):r(t)};return w(f,u),f}t.KEYWORD_FROM_ATOM={"00":".","01":"q","02":"a","03":"i","04":"c","05":"f","06":"r","07":"l","08":"x","09":"=","0a":">s","0b":"sha256","0c":"substr","0d":"strlen","0e":"concat","0f":".",10:"+",11:"-",12:"*",13:"/",14:"divmod",15:">",16:"ash",17:"lsh",18:"logand",19:"logior","1a":"logxor","1b":"lognot","1c":".","1d":"point_add","1e":"pubkey_for_exp","1f":".",20:"not",21:"any",22:"all",23:".",24:"softfork"},t.KEYWORD_TO_ATOM={q:"01",a:"02",i:"03",c:"04",f:"05",r:"06",l:"07",x:"08","=":"09",">s":"0a",sha256:"0b",substr:"0c",strlen:"0d",concat:"0e","+":"10","-":"11","*":"12","/":"13",divmod:"14",">":"15",ash:"16",lsh:"17",logand:"18",logior:"19",logxor:"1a",lognot:"1b",point_add:"1d",pubkey_for_exp:"1e",not:"20",any:"21",all:"22",".":"23",softfork:"24"},t.OP_REWRITE={"+":"add","-":"subtract","*":"multiply","/":"div",i:"if",c:"cons",f:"first",r:"rest",l:"listp",x:"raise","=":"eq",">":"gr",">s":"gr_bytes"},t.args_len=l,t.default_unknown_op=h,t.QUOTE_ATOM=i.Bytes.from(t.KEYWORD_TO_ATOM.q,"hex"),t.APPLY_ATOM=i.Bytes.from(t.KEYWORD_TO_ATOM.a,"hex"),t.OperatorDict=v;const d=v(a.operators_for_module(t.KEYWORD_TO_ATOM,c,t.OP_REWRITE),t.QUOTE_ATOM,t.APPLY_ATOM);w(d,a.operators_for_module(t.KEYWORD_TO_ATOM,s,t.OP_REWRITE)),t.OPERATOR_LOOKUP=d},282:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.run_program=t.msb_mask=t.to_pre_eval_op=void 0;const e=r(213),o=r(907),i=r(629),u=r(593),f=r(449),a=r(755);function c(n,t){return function(r,e){const o=t(e[e.length-1]),i=n(o.first(),o.rest());if("function"==typeof i){const n=(n,r)=>(i(t(r[r.length-1])),0);r.push(n)}}}function s(n){return n|=n>>1,n|=n>>2,1+(n|=n>>4)>>1}t.to_pre_eval_op=c,t.msb_mask=s,t.run_program=function(n,t,r,l=e.None,h=e.None){n=o.SExp.to(n);const w=h?c(h,o.SExp.to):e.None;function v(n,t){const r=t.pop(),e=t.pop();return t.push(r),t.push(e),0}function d(n,t){const r=t.pop(),e=t.pop();return t.push(r.cons(e)),0}function y(n,t){w&&w(n,t);const e=t.pop(),c=e.first(),l=e.rest();if(!i.isCons(c)){const[n,r]=function(n,t){let r=f.PATH_LOOKUP_BASE_COST;if(r+=f.PATH_LOOKUP_COST_PER_LEG,n.nullp())return u.t(r,o.SExp.null());const e=n.atom;let c=0;for(;cc||wl)throw new a.EvalError("cost exceeded",o.SExp.to(l));return u.t(g,m[m.length-1])}},351:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.sexp_buffer_from_stream=t.sexp_from_stream=t.sexp_to_stream=t.atom_to_byte_iterator=t.sexp_to_byte_iterator=void 0;const e=r(593),o=r(959),i=r(629),u=127;function*f(n){const t=[n];for(;t.length;){const r=(n=t.pop()).as_pair();r?(yield e.Bytes.from([255]),t.push(r[1]),t.push(r[0])):yield*a(n.atom)}}function*a(n){const t=n?n.length:0;if(0===t||!n)return void(yield e.Bytes.from("0x80","hex"));if(1===t&&n.get_byte_at(0)<=127)return void(yield n);let r;if(t<64)r=Uint8Array.from([128|t]);else if(t<8192)r=Uint8Array.from([192|t>>8,t>>0&255]);else if(t<1048576)r=Uint8Array.from([224|t>>16,t>>8&255,t>>0&255]);else if(t<134217728)r=Uint8Array.from([240|t>>24,t>>16&255,t>>8&255,t>>0&255]);else{if(!(t<17179869184))throw new Error(`sexp too long ${n}`);r=Uint8Array.from([248|t/2**32>>0,t/2**24>>0&255,t/65536>>0&255,t/256>>0&255,t/1>>0&255])}const o=e.Bytes.from(r);yield o,yield n}function c(n,t,r,i){const f=r.read(1);if(0===f.length)throw new Error("bad encoding");const a=f.get_byte_at(0);if(255===a)return n.push(s),n.push(c),void n.push(c);t.push(function(n,t,r){if(128===t)return r(e.Bytes.NULL);if(t<=u)return r(e.Bytes.from([t]));let i=0,f=128;for(;t&f;)i+=1,t&=255^f,f>>=1;let a=e.Bytes.from([t]);if(i>1){const t=n.read(i-1);if(t.length!==i-1)throw new Error("bad encoding");a=a.concat(t)}const c=o.int_from_bytes(a);if(c>=17179869184)throw new Error("blob too large");const s=n.read(c);if(s.length!==c)throw new Error("bad encoding");return r(s)}(r,a,i))}function s(n,t,r,o){const i=t.pop(),u=t.pop();t.push(o(e.t(u,i)))}function l(n){const t=n.read(1);if(0===t.length)throw new Error("bad encoding");const r=t.get_byte_at(0);return 255===r?e.t(t,2):e.t(function(n,t){if(128===t)return e.Bytes.from([t]);if(t<=u)return e.Bytes.from([t]);let r=0,i=128,f=t;for(;f&i;)r+=1,f&=255^i,i>>=1;let a=e.Bytes.from([f]);if(r>1){const t=n.read(r-1);if(t.length!==r-1)throw new Error("bad encoding");a=a.concat(t)}const c=o.int_from_bytes(a);if(c>=17179869184)throw new Error("blob too large");const s=n.read(c);if(s.length!==c)throw new Error("bad encoding");return e.Bytes.from([t]).concat(a.slice(1)).concat(s)}(n,r),0)}t.sexp_to_byte_iterator=f,t.atom_to_byte_iterator=a,t.sexp_to_stream=function(n,t){for(const r of f(n))t.write(r)},t.sexp_from_stream=function(n,t){const r=[c],e=[];for(;r.length;){const t=r.pop();t&&t(r,e,n,(n=>new i.CLVMObject(n)))}return t(e.pop())},t.sexp_buffer_from_stream=function(n){let t=new e.Bytes,r=1;for(;r>0;){r-=1;const[e,o]=l(n);r+=o,t=t.concat(e)}return t}},135:function(){},33:function(){},794:function(){},845:function(){}},t={},function r(e){var o=t[e];if(void 0!==o)return o.exports;var i=t[e]={exports:{}};return n[e].call(i.exports,i,i.exports,r),i.exports}(465);var n,t})); \ No newline at end of file +!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.clvm=t():n.clvm=t()}(this,(function(){return n={513:function(n,t,r){var e,o=(e=(e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0)||"/index.js",function(n){var t,o,i;n=n||{},t||(t=void 0!==n?n:{}),t.ready=new Promise((function(n,t){o=n,i=t}));var u,f={};for(u in t)t.hasOwnProperty(u)&&(f[u]=t[u]);var a,c,s,l,h="./this.program";a="object"==typeof window,c="function"==typeof importScripts,s="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,l=!a&&!s&&!c;var w,v,d,y,p,b="";s?(b=c?r(794).dirname(b)+"/":"//",w=function(n,t){return y||(y=r(33)),p||(p=r(794)),n=p.normalize(n),y.readFileSync(n,t?null:"utf8")},d=function(n){return(n=w(n,!0)).buffer||(n=new Uint8Array(n)),_(n.buffer),n},1=e);)++r;if(16(o=224==(240&o)?(15&o)<<12|i<<6|u:(7&o)<<18|i<<12|u<<6|63&n[t++])?e+=String.fromCharCode(o):(o-=65536,e+=String.fromCharCode(55296|o>>10,56320|1023&o))}}else e+=String.fromCharCode(o)}return e}function M(n,t,r,e){if(!(0=u&&(u=65536+((1023&u)<<10)|1023&n.charCodeAt(++i)),127>=u){if(r>=e)break;t[r++]=u}else{if(2047>=u){if(r+1>=e)break;t[r++]=192|u>>6}else{if(65535>=u){if(r+2>=e)break;t[r++]=224|u>>12}else{if(r+3>=e)break;t[r++]=240|u>>18,t[r++]=128|u>>12&63}t[r++]=128|u>>6&63}t[r++]=128|63&u}}return t[r]=0,r-o}function U(n){for(var t=0,r=0;r=e&&(e=65536+((1023&e)<<10)|1023&n.charCodeAt(++r)),127>=e?++t:t=2047>=e?t+2:65535>=e?t+3:t+4}return t}var T="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function S(n,t){for(var r=n>>1,e=r+t/2;!(r>=e)&&B[r];)++r;if(32<(r<<=1)-n&&T)return T.decode(W.subarray(n,r));for(r="",e=0;!(e>=t/2);++e){var o=$[n+2*e>>1];if(0==o)break;r+=String.fromCharCode(o)}return r}function I(n,t,r){if(void 0===r&&(r=2147483647),2>r)return 0;var e=t;r=(r-=2)<2*n.length?r/2:n.length;for(var o=0;o>1]=n.charCodeAt(o),t+=2;return $[t>>1]=0,t-e}function x(n){return 2*n.length}function F(n,t){for(var r=0,e="";!(r>=t/4);){var o=G[n+4*r>>2];if(0==o)break;++r,65536<=o?(o-=65536,e+=String.fromCharCode(55296|o>>10,56320|1023&o)):e+=String.fromCharCode(o)}return e}function C(n,t,r){if(void 0===r&&(r=2147483647),4>r)return 0;var e=t;r=e+r-4;for(var o=0;o=i&&(i=65536+((1023&i)<<10)|1023&n.charCodeAt(++o)),G[t>>2]=i,(t+=4)+4>r)break}return G[t>>2]=0,t-e}function D(n){for(var t=0,r=0;r=e&&++r,t+=4}return t}var P,N,W,$,B,G,q,H,R,z,V=[],J=[],Y=[];function L(){var n=t.preRun.shift();V.unshift(n)}var X=0,Q=null,Z=null;function K(n){throw t.onAbort&&t.onAbort(n),A(n),j=!0,n=new WebAssembly.RuntimeError("abort("+n+"). Build with -s ASSERTIONS=1 for more info."),i(n),n}function nn(){return tn.startsWith("data:application/octet-stream;base64,")}t.preloadedImages={},t.preloadedAudios={};var tn="blsjs.wasm";if(!nn()){var rn=tn;tn=t.locateFile?t.locateFile(rn,b):b+rn}function en(){var n=tn;try{if(n==tn&&m)return new Uint8Array(m);if(d)return d(n);throw"both async and sync fetching of the wasm failed"}catch(n){K(n)}}function on(n){for(;0>2]=n},this.pb=function(n){G[this.Y+0>>2]=n},this.qb=function(){G[this.Y+4>>2]=0},this.ob=function(){N[this.Y+12>>0]=0},this.rb=function(){N[this.Y+13>>0]=0},this.eb=function(n,t){this.sb(n),this.pb(t),this.qb(),this.ob(),this.rb()}}function fn(n,t){for(var r=0,e=n.length-1;0<=e;e--){var o=n[e];"."===o?n.splice(e,1):".."===o?(n.splice(e,1),r++):r&&(n.splice(e,1),r--)}if(t)for(;r;r--)n.unshift("..");return n}function an(n){var t="/"===n.charAt(0),r="/"===n.substr(-1);return(n=fn(n.split("/").filter((function(n){return!!n})),!t).join("/"))||t||(n="."),n&&r&&(n+="/"),(t?"/":"")+n}function cn(n){var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(n).slice(1);return n=t[0],t=t[1],n||t?(t&&(t=t.substr(0,t.length-1)),n+t):"."}function sn(n){if("/"===n)return"/";var t=(n=(n=an(n)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?n:n.substr(t+1)}function ln(){for(var n="",t=!1,r=arguments.length-1;-1<=r&&!t;r--){if("string"!=typeof(t=0<=r?arguments[r]:"/"))throw new TypeError("Arguments to path.resolve must be strings");if(!t)return"";n=t+"/"+n,t="/"===t.charAt(0)}return(t?"/":"")+(n=fn(n.split("/").filter((function(n){return!!n})),!t).join("/"))||"."}var hn=[];function wn(n,t){hn[n]={input:[],output:[],sa:t},Pn(n,vn)}var vn={open:function(n){var t=hn[n.node.rdev];if(!t)throw new _n(43);n.tty=t,n.seekable=!1},close:function(n){n.tty.sa.flush(n.tty)},flush:function(n){n.tty.sa.flush(n.tty)},read:function(n,t,r,e){if(!n.tty||!n.tty.sa.Ra)throw new _n(60);for(var o=0,i=0;i=t||(t=Math.max(t,r*(1048576>r?2:1.125)>>>0),0!=r&&(t=Math.max(t,256)),r=n.W,n.W=new Uint8Array(t),0=n.node.aa)return 0;if(8<(n=Math.min(n.node.aa-o,e))&&i.subarray)t.set(i.subarray(o,o+n),r);else for(e=0;et)throw new _n(28);return t},La:function(n,t,r){pn.Oa(n.node,t+r),n.node.aa=Math.max(n.node.aa,t+r)},Sa:function(n,t,r,e,o,i){if(0!==t)throw new _n(28);if(32768!=(61440&n.node.mode))throw new _n(43);if(n=n.node.W,2&i||n.buffer!==P){for((0>>0)%En.length}function Tn(n,t){var r;if(r=n.X.lookup?0:2)throw new _n(r,n);for(r=En[Un(n.id,t)];r;r=r.hb){var e=r.name;if(r.parent.id===n.id&&e===t)return r}return n.X.lookup(n,t)}function Sn(n,t,r,e){return t=Un((n=new sr(n,t,r,e)).parent.id,n.name),n.hb=En[t],En[t]=n}var In={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090};function xn(n,t){try{return Tn(n,t),20}catch(n){}return 0}function Fn(n){Jn||((Jn=function(){}).prototype={});var t,r=new Jn;for(t in n)r[t]=n[t];return n=r,r=function(){for(var n=0;n<=4096;n++)if(!gn[n])return n;throw new _n(33)}(),n.fd=r,gn[r]=n}var Cn,Dn={open:function(n){n.$=mn[n.node.rdev].$,n.$.open&&n.$.open(n)},va:function(){throw new _n(70)}};function Pn(n,t){mn[n]={$:t}}function Nn(n,t){var r="/"===t,e=!t;if(r&&bn)throw new _n(10);if(!r&&!e){var o=kn(t,{Qa:!1});if(t=o.path,(o=o.node).Ca)throw new _n(10);if(16384!=(61440&o.mode))throw new _n(54)}t={type:n,Bb:{},Ta:t,gb:[]},(n=n.la(t)).la=t,t.root=n,r?bn=n:o&&(o.Ca=t,o.la&&o.la.gb.push(t))}function Wn(n,t,r){var e=kn(n,{parent:!0}).node;if(!(n=sn(n))||"."===n||".."===n)throw new _n(28);var o=xn(e,n);if(o)throw new _n(o);if(!e.X.Ba)throw new _n(63);return e.X.Ba(e,n,t,r)}function $n(n){return Wn(n,16895,0)}function Bn(n,t,r){void 0===r&&(r=t,t=438),Wn(n,8192|t,r)}function Gn(n,t){if(!ln(n))throw new _n(44);var r=kn(t,{parent:!0}).node;if(!r)throw new _n(44);var e=xn(r,t=sn(t));if(e)throw new _n(e);if(!r.X.symlink)throw new _n(63);r.X.symlink(r,t,n)}function qn(n){if(!(n=kn(n).node))throw new _n(44);if(!n.X.readlink)throw new _n(28);return ln(Mn(n.parent),n.X.readlink(n))}function Hn(n,r,e){if(""===n)throw new _n(44);if("string"==typeof r){var o=In[r];if(void 0===o)throw Error("Unknown file open mode: "+r);r=o}if(e=64&r?4095&(void 0===e?438:e)|32768:0,"object"==typeof n)var i=n;else{n=an(n);try{i=kn(n,{Pa:!(131072&r)}).node}catch(n){}}if(o=!1,64&r)if(i){if(128&r)throw new _n(20)}else i=Wn(n,e,0),o=!0;if(!i)throw new _n(44);if(8192==(61440&i.mode)&&(r&=-513),65536&r&&16384!=(61440&i.mode))throw new _n(54);if(!o&&(i?40960==(61440&i.mode)?e=32:((e=16384==(61440&i.mode))&&(e=["r","w","rw"][3&r],512&r&&(e+="w"),e="r"!==e||512&r),e=e?31:0):e=44,e))throw new _n(e);if(512&r){if(!(e="string"==typeof(e=i)?kn(e,{Pa:!0}).node:e).X.ja)throw new _n(63);if(16384==(61440&e.mode))throw new _n(31);if(32768!=(61440&e.mode))throw new _n(28);e.X.ja(e,{size:0,timestamp:Date.now()})}r&=-131713,(i=Fn({node:i,path:Mn(i),flags:r,seekable:!0,position:0,$:i.$,Db:[],error:!1})).$.open&&i.$.open(i),!t.logReadFiles||1&r||(Yn||(Yn={}),n in Yn||(Yn[n]=1,A("FS.trackingDelegate error on read file: "+n)));try{jn.onOpenFile&&(e=0,1!=(2097155&r)&&(e|=1),0!=(2097155&r)&&(e|=2),jn.onOpenFile(n,e))}catch(t){A("FS.trackingDelegate['onOpenFile']('"+n+"', flags) threw an exception: "+t.message)}return i}function Rn(){_n||((_n=function(n,t){this.node=t,this.nb=function(n){this.ua=n},this.nb(n),this.message="FS error"}).prototype=Error(),_n.prototype.constructor=_n,[44].forEach((function(n){On[n]=new _n(n),On[n].stack=""})))}function zn(n,t,r){n=an("/dev/"+n);var e=function(n,t){var r=0;return n&&(r|=365),t&&(r|=146),r}(!!t,!!r);Vn||(Vn=64);var o=Vn++<<8|0;Pn(o,{open:function(n){n.seekable=!1},close:function(){r&&r.buffer&&r.buffer.length&&r(10)},read:function(n,r,e,o){for(var i=0,u=0;u=t?"_"+n:n}function it(n,t){return n=ot(n),new Function("body","return function "+n+'() {\n "use strict"; return body.apply(this, arguments);\n};\n')(t)}function ut(n){var t=Error,r=it(n,(function(t){this.name=n,this.message=t,void 0!==(t=Error(t).stack)&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}));return r.prototype=Object.create(t.prototype),r.prototype.constructor=r,r.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},r}var ft=void 0;function at(n){throw new ft(n)}var ct=void 0;function st(n){throw new ct(n)}function lt(n,t,r){function e(t){(t=r(t)).length!==n.length&&st("Mismatched type converter count");for(var e=0;e>2])}function St(n,t,r){return t===r?n:void 0===r.ha||null===(n=St(n,t,r.ha))?null:r.Za(n)}var It={};function xt(n,t){return t.ba&&t.Y||st("makeClassHandle requires ptr and ptrType"),!!t.ga!=!!t.fa&&st("Both smartPtrType and smartPtr must be specified"),t.count={value:1},pt(Object.create(n,{V:{value:t}}))}function Ft(n,t,r,e){this.name=n,this.Z=t,this.Ha=r,this.za=e,this.Aa=!1,this.oa=this.lb=this.kb=this.Va=this.tb=this.ib=void 0,void 0!==t.ha?this.toWireType=Mt:(this.toWireType=e?kt:Ut,this.ka=null)}function Ct(n,r){var e=(n=nt(n)).includes("j")?function(n,r){var e=[];return function(){e.length=arguments.length;for(var o=0;oi&&at("argTypes array size mismatch! Must at least get return value and 'this' types!");var u=null!==t[1]&&null!==r,f=!1;for(r=1;r>2)+e]);return r}var qt=[],Ht=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Rt(n){4>2])};case 3:return function(n){return this.fromWireType(R[n>>3])};default:throw new TypeError("Unknown float type: "+n)}}function Yt(n,t,r){switch(t){case 0:return r?function(n){return N[n]}:function(n){return W[n]};case 1:return r?function(n){return $[n>>1]}:function(n){return B[n>>1]};case 2:return r?function(n){return G[n>>2]}:function(n){return q[n>>2]};default:throw new TypeError("Unknown integer type: "+n)}}function Lt(n){return n||at("Cannot use deleted val. handle = "+n),Ht[n].value}function Xt(n,t){var r=rt[n];return void 0===r&&at(t+" has unknown type "+Pt(n)),r}var Qt={};function Zt(n){var t=Qt[n];return void 0===t?nt(n):t}var Kt=[];function nr(){return"object"==typeof globalThis?globalThis:Function("return this")()}var tr,rr={},er={};function or(){if(!tr){var n,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:h||"./this.program"};for(n in er)t[n]=er[n];var r=[];for(n in t)r.push(n+"="+t[n]);tr=r}return tr}function ir(n){return 0==n%4&&(0!=n%100||0==n%400)}function ur(n,t){for(var r=0,e=0;e<=t;r+=n[e++]);return r}var fr=[31,29,31,30,31,30,31,31,30,31,30,31],ar=[31,28,31,30,31,30,31,31,30,31,30,31];function cr(n,t){for(n=new Date(n.getTime());0e-n.getDate())){n.setDate(n.getDate()+t);break}t-=e-n.getDate()+1,n.setDate(1),11>r?n.setMonth(r+1):(n.setMonth(0),n.setFullYear(n.getFullYear()+1))}return n}function sr(n,t,r,e){n||(n=this),this.parent=n,this.la=n.la,this.Ca=null,this.id=An++,this.name=t,this.mode=r,this.X={},this.$={},this.rdev=e}Object.defineProperties(sr.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(n){n?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(n){n?this.mode|=146:this.mode&=-147}}}),Rn(),En=Array(4096),Nn(pn,"/"),$n("/tmp"),$n("/home"),$n("/home/web_user"),function(){$n("/dev"),Pn(259,{read:function(){return 0},write:function(n,t,r,e){return e}}),Bn("/dev/null",259),wn(1280,dn),wn(1536,yn),Bn("/dev/tty",1280),Bn("/dev/tty1",1536);var n=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var n=new Uint8Array(1);return function(){return crypto.getRandomValues(n),n[0]}}if(s)try{var t=r(135);return function(){return t.randomBytes(1)[0]}}catch(n){}return function(){K("randomDevice")}}();zn("random",n),zn("urandom",n),$n("/dev/shm"),$n("/dev/shm/tmp")}(),function(){$n("/proc");var n=$n("/proc/self");$n("/proc/self/fd"),Nn({la:function(){var t=Sn(n,"fd",16895,73);return t.X={lookup:function(n,t){var r=gn[+t];if(!r)throw new _n(8);return(n={parent:null,la:{Ta:"fake"},X:{readlink:function(){return r.path}}}).parent=n}},t}},"/proc/self/fd")}();for(var lr=Array(256),hr=0;256>hr;++hr)lr[hr]=String.fromCharCode(hr);function wr(n,t){var r=Array(U(n)+1);return n=M(n,r,0,r.length),t&&(r.length=n),r}Kn=lr,ft=t.BindingError=ut("BindingError"),ct=t.InternalError=ut("InternalError"),At.prototype.isAliasOf=function(n){if(!(this instanceof At&&n instanceof At))return!1;var t=this.V.ba.Z,r=this.V.Y,e=n.V.ba.Z;for(n=n.V.Y;t.ha;)r=t.ya(r),t=t.ha;for(;e.ha;)n=e.ya(n),e=e.ha;return t===e&&r===n},At.prototype.clone=function(){if(this.V.Y||wt(this),this.V.wa)return this.V.count.value+=1,this;var n=pt,t=Object,r=t.create,e=Object.getPrototypeOf(this),o=this.V;return(n=n(r.call(t,e,{V:{value:{count:o.count,qa:o.qa,wa:o.wa,Y:o.Y,ba:o.ba,fa:o.fa,ga:o.ga}}}))).V.count.value+=1,n.V.qa=!1,n},At.prototype.delete=function(){this.V.Y||wt(this),this.V.qa&&!this.V.wa&&at("Object already scheduled for deletion"),dt(this),yt(this.V),this.V.wa||(this.V.fa=void 0,this.V.Y=void 0)},At.prototype.isDeleted=function(){return!this.V.Y},At.prototype.deleteLater=function(){return this.V.Y||wt(this),this.V.qa&&!this.V.wa&&at("Object already scheduled for deletion"),mt.push(this),1===mt.length&&bt&&bt(gt),this.V.qa=!0,this},Ft.prototype.ab=function(n){return this.Va&&(n=this.Va(n)),n},Ft.prototype.Na=function(n){this.oa&&this.oa(n)},Ft.prototype.argPackAdvance=8,Ft.prototype.readValueFromPointer=Tt,Ft.prototype.deleteObject=function(n){null!==n&&n.delete()},Ft.prototype.fromWireType=function(n){function t(){return this.Aa?xt(this.Z.ra,{ba:this.ib,Y:r,ga:this,fa:n}):xt(this.Z.ra,{ba:this,Y:n})}var r=this.ab(n);if(!r)return this.Na(n),null;var e=function(n,t){for(void 0===t&&at("ptr should not be undefined");n.ha;)t=n.ya(t),n=n.ha;return It[t]}(this.Z,r);if(void 0!==e)return 0===e.V.count.value?(e.V.Y=r,e.V.fa=n,e.clone()):(e=e.clone(),this.Na(n),e);if(e=this.Z.$a(r),!(e=Et[e]))return t.call(this);e=this.za?e.Ya:e.pointerType;var o=St(r,this.Z,e.Z);return null===o?t.call(this):this.Aa?xt(e.Z.ra,{ba:e,Y:o,ga:this,fa:n}):xt(e.Z.ra,{ba:e,Y:o})},t.getInheritedInstanceCount=function(){return Object.keys(It).length},t.getLiveInheritedInstances=function(){var n,t=[];for(n in It)It.hasOwnProperty(n)&&t.push(It[n]);return t},t.flushPendingDeletes=gt,t.setDelayFunction=function(n){bt=n,mt.length&&bt&&bt(gt)},Dt=t.UnboundTypeError=ut("UnboundTypeError"),t.count_emval_handles=function(){for(var n=0,t=5;t>2];else o=0;return Hn(e,t,o).fd}catch(n){return void 0!==Ln&&n instanceof _n||K(n),-n.ua}},w:function(){},F:function(n,t,r,e,o){var i=Zn(r);ht(n,{name:t=nt(t),fromWireType:function(n){return!!n},toWireType:function(n,t){return t?e:o},argPackAdvance:8,readValueFromPointer:function(n){if(1===r)var e=N;else if(2===r)e=$;else{if(4!==r)throw new TypeError("Unknown boolean type size: "+t);e=G}return this.fromWireType(e[n>>i])},ka:null})},l:function(n,r,e,o,i,u,f,a,c,s,l,h,w){l=nt(l),u=Ct(i,u),a&&(a=Ct(f,a)),s&&(s=Ct(c,s)),w=Ct(h,w);var v=ot(l);!function(n,r){t.hasOwnProperty(n)?(at("Cannot register public name '"+n+"' twice"),jt(t,n,n),t.hasOwnProperty(void 0)&&at("Cannot register multiple overloads of a function with the same number of arguments (undefined)!"),t[n].da[void 0]=r):t[n]=r}(v,(function(){Nt("Cannot construct "+l+" due to unbound types",[o])})),lt([n,r,e],o?[o]:[],(function(r){if(r=r[0],o)var e=r.Z,i=e.ra;else i=At.prototype;r=it(v,(function(){if(Object.getPrototypeOf(this)!==f)throw new ft("Use 'new' to construct "+l);if(void 0===c.na)throw new ft(l+" has no accessible constructor");var n=c.na[arguments.length];if(void 0===n)throw new ft("Tried to invoke ctor of "+l+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(c.na).toString()+") parameters instead!");return n.apply(this,arguments)}));var f=Object.create(i,{constructor:{value:r}});r.prototype=f;var c=new _t(l,r,f,w,e,u,a,s);e=new Ft(l,c,!0,!1),i=new Ft(l+"*",c,!1,!1);var h=new Ft(l+" const*",c,!1,!0);return Et[n]={pointerType:i,Ya:h},function(n,r){t.hasOwnProperty(n)||st("Replacing nonexistant public symbol"),t[n]=r,t[n].pa=void 0}(v,r),[e,i,h]}))},b:function(n,t,r,e,o,i,u){var f=Gt(r,e);t=nt(t),i=Ct(o,i),lt([],[n],(function(n){function e(){Nt("Cannot call "+o+" due to unbound types",f)}var o=(n=n[0]).name+"."+t;t.startsWith("@@")&&(t=Symbol[t.substring(2)]);var a=n.Z.constructor;return void 0===a[t]?(e.pa=r-1,a[t]=e):(jt(a,t,o),a[t].da[r-1]=e),lt([],f,(function(n){return n=[n[0],null].concat(n.slice(1)),n=Bt(o,n,null,i,u),void 0===a[t].da?(n.pa=r-1,a[t]=n):a[t].da[r-1]=n,[]})),[]}))},p:function(n,t,r,e,o,i,u,f){t=nt(t),i=Ct(o,i),lt([],[n],(function(n){var o=(n=n[0]).name+"."+t,a={get:function(){Nt("Cannot access "+o+" due to unbound types",[r])},enumerable:!0,configurable:!0};return a.set=f?function(){Nt("Cannot access "+o+" due to unbound types",[r])}:function(){at(o+" is a read-only property")},Object.defineProperty(n.Z.constructor,t,a),lt([],[r],(function(r){r=r[0];var o={get:function(){return r.fromWireType(i(e))},enumerable:!0};return f&&(f=Ct(u,f),o.set=function(n){var t=[];f(e,r.toWireType(t,n)),$t(t)}),Object.defineProperty(n.Z.constructor,t,o),[]})),[]}))},r:function(n,t,r,e,o,i){_(0>>f}}var a=t.includes("unsigned");ht(n,{name:t,fromWireType:i,toWireType:function(n,r){if("number"!=typeof r&&"boolean"!=typeof r)throw new TypeError('Cannot convert "'+Vt(r)+'" to '+this.name);if(ro)throw new TypeError('Passing a number "'+Vt(r)+'" from JS side to C/C++ side to an argument of type "'+t+'", which is outside the valid range ['+e+", "+o+"]!");return a?r>>>0:0|r},argPackAdvance:8,readValueFromPointer:Yt(t,u,0!==e),ka:null})},g:function(n,t,r){function e(n){var t=q;return new o(P,t[1+(n>>=2)],t[n])}var o=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];ht(n,{name:r=nt(r),fromWireType:e,argPackAdvance:8,readValueFromPointer:e},{cb:!0})},t:function(n,t){var r="std::string"===(t=nt(t));ht(n,{name:t,fromWireType:function(n){var t=q[n>>2];if(r)for(var e=n+4,o=0;o<=t;++o){var i=n+4+o;if(o==t||0==W[i]){if(e=e?k(W,e,i-e):"",void 0===u)var u=e;else u+=String.fromCharCode(0),u+=e;e=i+1}}else{for(u=Array(t),o=0;o>2]=o,r&&e)M(t,W,i+4,o+1);else if(e)for(e=0;e>2],i=u(),a=n+4,c=0;c<=o;++c){var s=n+4+c*t;c!=o&&0!=i[s>>f]||(a=e(a,s-a),void 0===r?r=a:(r+=String.fromCharCode(0),r+=a),a=s+t)}return pr(n),r},toWireType:function(n,e){"string"!=typeof e&&at("Cannot pass non-string to C++ string type "+r);var u=i(e),a=yr(4+u+t);return q[a>>2]=u>>f,o(e,a+4,u+t),null!==n&&n.push(pr,a),a},argPackAdvance:8,readValueFromPointer:Tt,ka:function(n){pr(n)}})},G:function(n,t){ht(n,{fb:!0,name:t=nt(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},i:function(n,t,r){n=Lt(n),t=Xt(t,"emval::as");var e=[],o=zt(e);return G[r>>2]=o,t.toWireType(e,n)},H:function(n,t,r,e,o){n=Kt[n],t=Lt(t),r=Zt(r);var i=[];return G[e>>2]=zt(i),n(t,r,i,o)},I:function(n,t,r,e){(n=Kt[n])(t=Lt(t),r=Zt(r),null,e)},a:Rt,v:function(n){return 0===n?zt(nr()):(n=Zt(n),zt(nr()[n]))},u:function(n,t){for(var r=(t=function(n,t){for(var r=Array(n),e=0;e>2)+e],"parameter "+e);return r}(n,t))[0],e=r.name+"_$"+t.slice(1).map((function(n){return n.name})).join("_")+"$",o=["retType"],i=[r],u="",f=0;f>> 2) + "+u+'], "parameter '+u+'");\nvar arg'+u+" = argType"+u+".readValueFromPointer(args);\nargs += argType"+u+"['argPackAdvance'];\n";i=new Function("requireRegisteredType","Module","__emval_register",f+"var obj = new constructor("+i+");\nreturn __emval_register(obj);\n}\n")(Xt,t,zt),rr[r]=i}return i(n,e,o)},m:function(n){return zt(Zt(n))},h:function(n){$t(Ht[n].value),Rt(n)},n:function(n,t){return zt(n=(n=Xt(n,"_emval_take_value")).readValueFromPointer(t))},q:function(){K()},x:function(){K("OOM")},z:function(n,t){try{var r=0;return or().forEach((function(e,o){var i=t+r;for(o=G[n+4*o>>2]=i,i=0;i>0]=e.charCodeAt(i);N[o>>0]=0,r+=e.length+1})),0}catch(n){return void 0!==Ln&&n instanceof _n||K(n),n.ua}},A:function(n,t){try{var r=or();G[n>>2]=r.length;var e=0;return r.forEach((function(n){e+=n.length+1})),G[t>>2]=e,0}catch(n){return void 0!==Ln&&n instanceof _n||K(n),n.ua}},B:function(n){try{var t=Qn(n);if(null===t.fd)throw new _n(8);t.bb&&(t.bb=null);try{t.$.close&&t.$.close(t)}catch(n){throw n}finally{gn[t.fd]=null}return t.fd=null,0}catch(n){return void 0!==Ln&&n instanceof _n||K(n),n.ua}},C:function(n,t,r,e){try{n:{for(var o=Qn(n),i=n=0;i>2],f=o,a=G[t+8*i>>2],c=u,s=void 0,l=N;if(0>c||0>s)throw new _n(28);if(null===f.fd)throw new _n(8);if(1==(2097155&f.flags))throw new _n(8);if(16384==(61440&f.node.mode))throw new _n(31);if(!f.$.read)throw new _n(28);var h=void 0!==s;if(h){if(!f.seekable)throw new _n(70)}else s=f.position;var w=f.$.read(f,l,a,c,s);h||(f.position+=w);var v=w;if(0>v){var d=-1;break n}if(n+=v,v>2]=d,0}catch(n){return void 0!==Ln&&n instanceof _n||K(n),n.ua}},y:function(n,t,r,e){return function(n,t,r,e){function o(n,t,r){for(n="number"==typeof n?n.toString():n||"";n.lengthn?-1:0=u(r,n)?0>=u(t,n)?n.getFullYear()+1:n.getFullYear():n.getFullYear()-1}var c=G[e+40>>2];for(var s in e={wb:G[e>>2],vb:G[e+4>>2],Da:G[e+8>>2],xa:G[e+12>>2],ta:G[e+16>>2],ea:G[e+20>>2],Ea:G[e+24>>2],Fa:G[e+28>>2],Cb:G[e+32>>2],ub:G[e+36>>2],xb:c&&c?k(W,c,void 0):""},r=r?k(W,r,void 0):"",c={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})r=r.replace(new RegExp(s,"g"),c[s]);var l="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),h="January February March April May June July August September October November December".split(" ");for(s in c={"%a":function(n){return l[n.Ea].substring(0,3)},"%A":function(n){return l[n.Ea]},"%b":function(n){return h[n.ta].substring(0,3)},"%B":function(n){return h[n.ta]},"%C":function(n){return i((n.ea+1900)/100|0,2)},"%d":function(n){return i(n.xa,2)},"%e":function(n){return o(n.xa,2," ")},"%g":function(n){return a(n).toString().substring(2)},"%G":function(n){return a(n)},"%H":function(n){return i(n.Da,2)},"%I":function(n){return 0==(n=n.Da)?n=12:12n.Da?"AM":"PM"},"%S":function(n){return i(n.wb,2)},"%t":function(){return"\t"},"%u":function(n){return n.Ea||7},"%U":function(n){var t=new Date(n.ea+1900,0,1),r=0===t.getDay()?t:cr(t,7-t.getDay());return 0>u(r,n=new Date(n.ea+1900,n.ta,n.xa))?i(Math.ceil((31-r.getDate()+(ur(ir(n.getFullYear())?fr:ar,n.getMonth()-1)-31)+n.getDate())/7),2):0===u(r,t)?"01":"00"},"%V":function(n){var t=new Date(n.ea+1901,0,4),r=f(new Date(n.ea+1900,0,4));t=f(t);var e=cr(new Date(n.ea+1900,0,1),n.Fa);return 0>u(e,r)?"53":0>=u(t,e)?"01":i(Math.ceil((r.getFullYear()u(r,n=new Date(n.ea+1900,n.ta,n.xa))?i(Math.ceil((31-r.getDate()+(ur(ir(n.getFullYear())?fr:ar,n.getMonth()-1)-31)+n.getDate())/7),2):0===u(r,t)?"01":"00"},"%y":function(n){return(n.ea+1900).toString().substring(2)},"%Y":function(n){return n.ea+1900},"%z":function(n){var t=0<=(n=n.ub);return n=Math.abs(n)/60,(t?"+":"-")+String("0000"+(n/60*100+n%60)).slice(-4)},"%Z":function(n){return n.xb},"%%":function(){return"%"}})r.includes(s)&&(r=r.replace(new RegExp(s,"g"),c[s](e)));return(s=wr(r,!1)).length>t?0:(N.set(s,n),s.length-1)}(n,t,r,e)}};!function(){function n(n){t.asm=n.exports,E=t.asm.K,P=n=E.buffer,t.HEAP8=N=new Int8Array(n),t.HEAP16=$=new Int16Array(n),t.HEAP32=G=new Int32Array(n),t.HEAPU8=W=new Uint8Array(n),t.HEAPU16=B=new Uint16Array(n),t.HEAPU32=q=new Uint32Array(n),t.HEAPF32=H=new Float32Array(n),t.HEAPF64=R=new Float64Array(n),z=t.asm.N,J.unshift(t.asm.L),X--,t.monitorRunDependencies&&t.monitorRunDependencies(X),0==X&&(null!==Q&&(clearInterval(Q),Q=null),Z&&(n=Z,Z=null,n()))}function r(t){n(t.instance)}function e(n){return function(){if(!m&&(a||c)){if("function"==typeof fetch&&!tn.startsWith("file://"))return fetch(tn,{credentials:"same-origin"}).then((function(n){if(!n.ok)throw"failed to load wasm binary file at '"+tn+"'";return n.arrayBuffer()})).catch((function(){return en()}));if(v)return new Promise((function(n,t){v(tn,(function(t){n(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return en()}))}().then((function(n){return WebAssembly.instantiate(n,o)})).then(n,(function(n){A("failed to asynchronously prepare wasm: "+n),K(n)}))}var o={a:vr};if(X++,t.monitorRunDependencies&&t.monitorRunDependencies(X),t.instantiateWasm)try{return t.instantiateWasm(o,n)}catch(n){return A("Module.instantiateWasm callback failed with error: "+n),!1}(m||"function"!=typeof WebAssembly.instantiateStreaming||nn()||tn.startsWith("file://")||"function"!=typeof fetch?e(r):fetch(tn,{credentials:"same-origin"}).then((function(n){return WebAssembly.instantiateStreaming(n,o).then(r,(function(n){return A("wasm streaming compile failed: "+n),A("falling back to ArrayBuffer instantiation"),e(r)}))}))).catch(i)}(),t.nn=function(){return(t.nn=t.asm.L).apply(null,arguments)};var dr,yr=t.tn=function(){return(yr=t.tn=t.asm.M).apply(null,arguments)},pr=t.rn=function(){return(pr=t.rn=t.asm.O).apply(null,arguments)},br=t.en=function(){return(br=t.en=t.asm.P).apply(null,arguments)};function mr(){function n(){if(!dr&&(dr=!0,t.calledRun=!0,!j)){if(t.noFSInit||Cn||(Cn=!0,Rn(),t.stdin=t.stdin,t.stdout=t.stdout,t.stderr=t.stderr,t.stdin?zn("stdin",t.stdin):Gn("/dev/tty","/dev/stdin"),t.stdout?zn("stdout",null,t.stdout):Gn("/dev/tty","/dev/stdout"),t.stderr?zn("stderr",null,t.stderr):Gn("/dev/tty1","/dev/stderr"),Hn("/dev/stdin",0),Hn("/dev/stdout",1),Hn("/dev/stderr",1)),on(J),o(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;){var n=t.postRun.shift();Y.unshift(n)}on(Y)}}if(!(0"===n?i>t:">="===n?i>=t:i===t))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return t.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return r(845).randomBytes(4).readInt32LE()}}(),f=function(){function n(t,r){if(Array.isArray(t)||!t)return this.i=Array.isArray(t)?t:[],void(this.u="number"==typeof r?r:4*this.i.length);if(t instanceof n)return this.i=t.words.slice(),void(this.u=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var o=e.byteLength,i=[],u=0;u>>2]|=e[u]<<24-u%4*8;this.i=i,this.u=o}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):a.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.i,t=this.u,r=new Uint8Array(t),e=0;e>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=o<<24-(this.u+e)%4*8}else for(e=0;e>>2]=t[e>>>2];return this.u+=r,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(t){for(var r=[],e=0;e>>2]>>>24-o%4*8&255;e.push((i>>>4).toString(16)),e.push((15&i).toString(16))}return e.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],e=0;e>>3]|=parseInt(n.substr(e,2),16)<<24-e%8*4;return new f(r,t/2)}};return t}()},915:function(n,t,r){n.exports=function(){"use strict";var n={3354:function(n,t,r){r.d(t,{e:function(){return i}});var e=r(5720),o=r(9054),i=function(){function n(t,r){if(Array.isArray(t)||!t)return this.t=Array.isArray(t)?t:[],void(this.i="number"==typeof r?r:4*this.t.length);if(t instanceof n)return this.t=t.words.slice(),void(this.i=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var o=e.byteLength,i=[],u=0;u>>2]|=e[u]<<24-u%4*8;this.t=i,this.i=o}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.i},set:function(n){this.i=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.t},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):e.p.stringify(this)},n.prototype.toUint8Array=function(){for(var n=this.t,t=this.i,r=new Uint8Array(t),e=0;e>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.i%4)for(var e=0;e>>2]>>>24-e%4*8&255;this.t[this.i+e>>>2]|=o<<24-(this.i+e)%4*8}else for(e=0;e>>2]=t[e>>>2];return this.i+=r,this},n.prototype.clamp=function(){var n=this.i;this.t[n>>>2]&=4294967295<<32-n%4*8,this.t.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.t.slice(),this.i)},n.random=function(t){for(var r=[],e=0;e"===n?i>t:">="===n?i>=t:i===t))}},5720:function(n,t,r){r.d(t,{p:function(){return o}});var e=r(3354),o={stringify:function(n){for(var t=n.nSigBytes,r=n.words,e=[],o=0;o>>2]>>>24-o%4*8&255;e.push((i>>>4).toString(16)),e.push((15&i).toString(16))}return e.join("")},parse:function(n){var t=n.length;if(t%2!=0)throw new Error("Hex string count must be even");if(!/^[a-fA-F0-9]+$/.test(n))throw new Error("Invalid Hex string: "+n);for(var r=[],o=0;o>>3]|=parseInt(n.substr(o,2),16)<<24-o%8*4;return new e.e(r,t/2)}}},8702:function(n,t,r){r.d(t,{m:function(){return o}});var e=r(3354),o={stringify:function(n){for(var t=n.nSigBytes,r=n.words,e=[],o=0;o>>2]>>>24-o%4*8&255;e.push(String.fromCharCode(i))}return e.join("")},parse:function(n){for(var t=n.length,r=[],o=0;o>>2]|=(255&n.charCodeAt(o))<<24-o%4*8;return new e.e(r,t)}}},4768:function(n,t,r){r.d(t,{d:function(){return o}});var e=r(8702),o={stringify:function(n){try{return decodeURIComponent(escape(e.m.stringify(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return e.m.parse(unescape(encodeURIComponent(n)))}}},9054:function(n,t,e){e.d(t,{M:function(){return i}});var o=e(1756),i=function(){if("undefined"!=typeof window){var n=window.crypto||window.msCrypto;if(!n){if((0,o.w)("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return n.getRandomValues(new Uint32Array(1))[0]}}return void 0!==e.g&&e.g.crypto?function(){return e.g.crypto.randomBytes(4).readInt32LE()}:function(){return r(845).randomBytes(4).readInt32LE()}}()}},t={};function e(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return n[r](i,i.exports,e),i.exports}e.d=function(n,t){for(var r in t)e.o(t,r)&&!e.o(n,r)&&Object.defineProperty(n,r,{enumerable:!0,get:t[r]})},e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"S",{value:!0})};var o={};return function(){e.r(o),e.d(o,{SHA256:function(){return l}});var n,t=e(1868),r=e(3354),i=(n=function(t,r){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,t){n.__proto__=t}||function(n,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])})(t,r)},function(t,r){function e(){this.constructor=t}n(t,r),t.prototype=null===r?Object.create(r):(e.prototype=r.prototype,new e)}),u=[],f=[];function a(n){for(var t=Math.sqrt(n),r=2;r<=t;r++)if(!(n%r))return!1;return!0}function c(n){return 4294967296*(n-(0|n))|0}!function(){for(var n=2,t=0;t<64;)a(n)&&(t<8&&(u[t]=c(Math.pow(n,.5))),f[t]=c(Math.pow(n,1/3)),t++),n++}();var s=[],l=function(n){function t(t){var e=n.call(this,t)||this;return e.N=new r.e(u.slice(0)),e.v=t,t&&void 0!==t.hash&&(e.N=t.hash.clone()),e}return i(t,n),t.prototype.U=function(){this.N=new r.e(u.slice(0))},t.prototype.I=function(n,t){for(var r=this.N.words,e=r[0],o=r[1],i=r[2],u=r[3],a=r[4],c=r[5],l=r[6],h=r[7],w=0;w<64;w++){if(w<16)s[w]=0|n[t+w];else{var v=s[w-15],d=(v<<25|v>>>7)^(v<<14|v>>>18)^v>>>3,y=s[w-2],p=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;s[w]=d+s[w-7]+p+s[w-16]}var b=e&o^e&i^o&i,m=(e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22),g=h+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&c^~a&l)+f[w]+s[w];h=l,l=c,c=a,a=u+g|0,u=i,i=o,o=e,e=g+(m+b)|0}r[0]=r[0]+e|0,r[1]=r[1]+o|0,r[2]=r[2]+i|0,r[3]=r[3]+u|0,r[4]=r[4]+a|0,r[5]=r[5]+c|0,r[6]=r[6]+l|0,r[7]=r[7]+h|0},t.prototype._=function(){var n=this.l.words,t=8*this.A,r=8*this.l.nSigBytes;return n[r>>>5]|=128<<24-r%32,n[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),n[15+(r+64>>>9<<4)]=t,this.l.nSigBytes=4*n.length,this.O(),this.N},t.prototype.clone=function(){return new t({hash:this.N,blockSize:this.h,data:this.l,nBytes:this.A})},t.hash=function(n,r){return new t(r).finalize(n)},t}(t.P)}(),o}()},699:function(n,t,r){n.exports=function(){"use strict";var n={d:function(t,r){for(var e in r)n.o(r,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var t={};n.r(t),n.d(t,{Utf8:function(){return l}});var e,o=function(n){for(var t=n.nSigBytes,r=n.words,e=[],o=0;o>>2]>>>24-o%4*8&255;e.push((i>>>4).toString(16)),e.push((15&i).toString(16))}return e.join("")},i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",u=(e=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(e)?(e=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(e)&&e):e),f=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(!t){if(function(n,t){return!1!==u&&(!t||("<"===n?u"===n?u>t:">="===n?u>=t:u===t))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return t.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return r(845).randomBytes(4).readInt32LE()}}(),a=function(){function n(t,r){if(Array.isArray(t)||!t)return this.i=Array.isArray(t)?t:[],void(this.u="number"==typeof r?r:4*this.i.length);if(t instanceof n)return this.i=t.words.slice(),void(this.u=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var o=e.byteLength,i=[],u=0;u>>2]|=e[u]<<24-u%4*8;this.i=i,this.u=o}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):o(this)},n.prototype.toUint8Array=function(){for(var n=this.i,t=this.u,r=new Uint8Array(t),e=0;e>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=o<<24-(this.u+e)%4*8}else for(e=0;e>>2]=t[e>>>2];return this.u+=r,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(t){for(var r=[],e=0;e>>2]>>>24-o%4*8&255;e.push(String.fromCharCode(i))}return e.join("")},s=function(n){for(var t=n.length,r=[],e=0;e>>2]|=(255&n.charCodeAt(e))<<24-e%4*8;return new a(r,t)},l={stringify:function(n){try{return decodeURIComponent(escape(c(n)))}catch(n){throw new Error("Malformed UTF-8 data")}},parse:function(n){return s(unescape(encodeURIComponent(n)))}};return t}()},893:function(n,t,r){n.exports=function(){"use strict";var n={d:function(t,r){for(var e in r)n.o(r,e)&&!n.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:r[e]})}};n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(n){if("object"==typeof window)return window}}(),n.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},n.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"t",{value:!0})};var t={};n.r(t),n.d(t,{Word32Array:function(){return a}});var e,o=function(n){for(var t=n.nSigBytes,r=n.words,e=[],o=0;o>>2]>>>24-o%4*8&255;e.push((i>>>4).toString(16)),e.push((15&i).toString(16))}return e.join("")},i="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",u=(e=parseInt((/msie (\d+)/.exec(i)||[])[1],10),isNaN(e)?(e=parseInt((/trident\/.*; rv:(\d+)/.exec(i)||[])[1],10),!isNaN(e)&&e):e),f=function(){if("undefined"!=typeof window){var t=window.crypto||window.msCrypto;if(!t){if(function(n,t){return!1!==u&&(!t||("<"===n?u"===n?u>t:">="===n?u>=t:u===t))}("<",11))return console.warn("IE <= 10 uses insecure random generator. Please consider to use IE11 or another modern browser"),function(){return Math.floor(512*Math.random())%256};throw new Error("Crypto module not found")}return function(){return t.getRandomValues(new Uint32Array(1))[0]}}return void 0!==n.g&&n.g.crypto?function(){return n.g.crypto.randomBytes(4).readInt32LE()}:function(){return r(845).randomBytes(4).readInt32LE()}}(),a=function(){function n(t,r){if(Array.isArray(t)||!t)return this.i=Array.isArray(t)?t:[],void(this.u="number"==typeof r?r:4*this.i.length);if(t instanceof n)return this.i=t.words.slice(),void(this.u=t.nSigBytes);var e;try{t instanceof ArrayBuffer?e=new Uint8Array(t):(t instanceof Uint8Array||t instanceof Int8Array||t instanceof Uint8ClampedArray||t instanceof Int16Array||t instanceof Uint16Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Float32Array||t instanceof Float64Array)&&(e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength))}catch(n){throw new Error("Invalid argument")}if(!e)throw new Error("Invalid argument");for(var o=e.byteLength,i=[],u=0;u>>2]|=e[u]<<24-u%4*8;this.i=i,this.u=o}return Object.defineProperty(n.prototype,"nSigBytes",{get:function(){return this.u},set:function(n){this.u=n},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"words",{get:function(){return this.i},enumerable:!1,configurable:!0}),n.prototype.toString=function(n){return n?n.stringify(this):o(this)},n.prototype.toUint8Array=function(){for(var n=this.i,t=this.u,r=new Uint8Array(t),e=0;e>>2]>>>24-e%4*8&255;return r},n.prototype.concat=function(n){var t=n.words.slice(),r=n.nSigBytes;if(this.clamp(),this.u%4)for(var e=0;e>>2]>>>24-e%4*8&255;this.i[this.u+e>>>2]|=o<<24-(this.u+e)%4*8}else for(e=0;e>>2]=t[e>>>2];return this.u+=r,this},n.prototype.clamp=function(){var n=this.u;this.i[n>>>2]&=4294967295<<32-n%4*8,this.i.length=Math.ceil(n/4)},n.prototype.clone=function(){return new n(this.i.slice(),this.u)},n.random=function(t){for(var r=[],e=0;e0)throw new Error(`can't cast ${JSON.stringify(n)} to bytes`);return i.Bytes.NULL}if("function"==typeof n.serialize)return i.Bytes.from(n,"G1Element");throw new Error(`can't cast ${JSON.stringify(n)} to bytes`)}function h(n){let t=n;const r=[t],u=[i.t(0,e.None)];for(;u.length;){const n=u.pop(),f=n[0];let a=n[1];if(0!==f){if(null===a)throw new Error("Invalid target. target is null");1===f?r[a].pair=i.t(new o.CLVMObject(r.pop()),r[a].pair[1]):2===f?r[a].pair=i.t(r[a].pair[0],new o.CLVMObject(r.pop())):3===f&&(r[a]=new o.CLVMObject(i.t(r.pop(),r[a])))}else{if(s(r[r.length-1]))continue;if(t=r.pop(),t instanceof i.Tuple){if(2!==t.length)throw new Error(`can't cast tuple of size ${t.length}`);const[n,f]=t;a=r.length,r.push(new o.CLVMObject(i.t(n,f))),s(f)||(r.push(f),u.push(i.t(2,a)),u.push(i.t(0,e.None))),s(n)||(r.push(n),u.push(i.t(1,a)),u.push(i.t(0,e.None)));continue}if(Array.isArray(t)){a=r.length,r.push(new o.CLVMObject(i.Bytes.NULL));for(const n of t)r.push(n),u.push(i.t(3,a)),s(n)||u.push(i.t(0,e.None));continue}r.push(new o.CLVMObject(l(t)))}}if(1!==r.length)throw new Error("internal error");return r[0]}t.looks_like_clvm_object=s,t.convert_atom_to_bytes=l,t.to_sexp_type=h;class w extends o.CLVMObject{constructor(n){super(n),this.atom=n.atom,this.pair=n.pair}static to(n){return n instanceof w?n:s(n)?new w(n):new w(h(n))}static null(){return w.an}as_pair(){const n=this.pair;return n===e.None?n:i.t(new w(n[0]),new w(n[1]))}listp(){return this.pair!==e.None}nullp(){return this.atom!==e.None&&0===this.atom.raw().length}as_int(){return u.int_from_bytes(this.atom)}as_bin(){const n=new i.Stream;return f.sexp_to_stream(this,n),n.getValue()}cons(n){return w.to(i.t(this,n))}first(){const n=this.pair;if(n)return new w(n[0]);throw new c.EvalError("first of non-cons",this)}rest(){const n=this.pair;if(n)return new w(n[1]);throw new c.EvalError("rest of non-cons",this)}*as_iter(){let n=this;for(;!n.nullp();)yield n.first(),n=n.rest()}equal_to(n){try{n=w.to(n);const t=[i.t(this,n)];for(;t.length;){const[n,r]=t.pop(),e=n.as_pair();if(e){const n=r.as_pair();if(!n)return!1;t.push(i.t(e[0],n[0])),t.push(i.t(e[1],n[1]))}else if(r.as_pair()||!(n.atom&&r.atom&&n.atom.equal_to(r.atom)))return!1}return!0}catch(n){return!1}}list_len(){let n=this,t=0;for(;n.listp();)t+=1,n=n.rest();return t}as_javascript(){return a.as_javascript(this)}toString(){return this.as_bin().hex()}cn(){return`SExp(${this.as_bin().hex()})`}}t.SExp=w,w.TRUE=new w(new o.CLVMObject(i.Bytes.from("0x01","hex"))),w.FALSE=new w(new o.CLVMObject(i.Bytes.NULL)),w.an=new w(new o.CLVMObject(i.Bytes.NULL))},190:function(n,t,r){"use strict";var e=this&&this.sn||function(n,t,r,e){return new(r||(r=Promise))((function(o,i){function u(n){try{a(e.next(n))}catch(n){i(n)}}function f(n){try{a(e.throw(n))}catch(n){i(n)}}function a(n){var t;n.done?o(n.value):(t=n.value,t instanceof r?t:new r((function(n){n(t)}))).then(u,f)}a((e=e.apply(n,t||[])).next())}))};Object.defineProperty(t,"un",{value:!0}),t.G1Element_add=t.assert_G1Element_valid=t.G1Element_from_bytes=t.getBLSModule=t.initializeBLS=t.loadPromise=t.BLS=void 0;const o=r(513);function i(){if(!t.BLS)throw new Error("BLS module has not been loaded. Please call `await initializeBLS()` on start up");return t.BLS}function u(n){const t=i(),{G1Element:r}=t;if(n.length!==r.SIZE)throw new Error("G1Element: Invalid size");if(192==(192&n[0])){if(192!==n[0])throw new Error("G1Element: Given G1 infinity element must be canonical");for(let t=1;t{if(t.BLS)return t.loadPromise=void 0,n(t.BLS);o().then((e=>e?(t.loadPromise=void 0,n(t.BLS=e)):r())).catch((n=>(console.error("Error while loading BLS module"),r(n))))}))}))},t.getBLSModule=i,t.G1Element_from_bytes=function(n){u(n);const t=i();try{return t.G1Element.from_bytes(n)}catch(n){throw new Error("Exception in G1Element operation")}},t.assert_G1Element_valid=u,t.G1Element_add=function(n,t){try{return n.add(t)}catch(n){throw new Error("Exception in G1Element operation")}}},572:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.prettyPrint=void 0;const e=r(907);t.prettyPrint=function(n){if(n){const n=e.SExp.prototype.toString;e.SExp.prototype.toString=e.SExp.prototype.cn,e.SExp.prototype.cn=n}else{const n=e.SExp.prototype.toString;e.SExp.prototype.toString=e.SExp.prototype.cn,e.SExp.prototype.cn=n}}},213:function(n,t){"use strict";Object.defineProperty(t,"un",{value:!0}),t.None=void 0,t.None=null},593:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.Stream=t.isIterable=t.isList=t.isTuple=t.t=t.Tuple=t.h=t.b=t.Bytes=t.PyBytes_Repr=t.to_hexstr=void 0;const e=r(502),o=r(699),i=r(893),u=r(915),f=r(213);function a(n){return new i.Word32Array(n).toString()}function c(n){let t=0,r=0;for(let e=0;e=127?(o+="\\x",o+=r.toString(16).padStart(2,"0")):o+=i}return o+=e,o}t.to_hexstr=a,t.PyBytes_Repr=c;class s{constructor(n){if(n instanceof Uint8Array)this.ln=new Uint8Array(n);else if(n instanceof s)this.ln=n.data();else{if(n&&n!==f.None)throw new Error(`Invalid value: ${JSON.stringify(n)}`);this.ln=new Uint8Array}}static from(n,t){if(n instanceof Uint8Array||n instanceof s||n===f.None||void 0===n)return new s(n);if(Array.isArray(n)&&n.every((n=>"number"==typeof n))){if(n.some((n=>n<0||n>255)))throw new Error("Bytes must be in range [0, 256)");return new s(Uint8Array.from(n))}if("string"==typeof n)return"hex"===t?(n=n.replace(/^0x/,""),new s(e.Hex.parse(n).toUint8Array())):new s(o.Utf8.parse(n).toUint8Array());if("G1Element"===t){if("function"!=typeof n.serialize)throw new Error("Invalid G1Element");const t=n.serialize();return new s(t)}throw new Error(`Invalid value: ${JSON.stringify(n)}`)}static SHA256(n){let t;if("string"==typeof n)t=u.SHA256.hash(n);else if(n instanceof Uint8Array)t=new i.Word32Array(n),t=u.SHA256.hash(t);else{if(!(n instanceof s))throw new Error("Invalid argument");t=n.as_word(),t=u.SHA256.hash(t)}return new s(t.toUint8Array())}get length(){return this.ln.length}get_byte_at(n){return 0|this.ln[n]}concat(n){const t=this.as_word(),r=n.as_word(),e=t.concat(r);return s.from(e.toUint8Array())}slice(n,t){const r="number"==typeof t?t:this.length-n;return new s(this.ln.slice(n,n+r))}as_word(){return new i.Word32Array(this.ln)}data(){return new Uint8Array(this.ln)}raw(){return this.ln}clone(){return new s(this.ln)}toString(){return c(this.ln)}hex(){return a(this.ln)}decode(){return o.Utf8.stringify(this.as_word())}startswith(n){return this.hex().startsWith(n.hex())}endswith(n){return this.hex().endsWith(n.hex())}equal_to(n){return!!n&&0===this.compare(n)}compare(n){if(this.length!==n.length)return this.length>n.length?1:-1;for(let t=0;te?1:-1}return 0}}t.Bytes=s,s.NULL=new s,t.b=function(n,t="utf8"){return s.from(n,t)},t.h=function(n){return s.from(n,"hex")};class l extends Array{constructor(...n){return super(...n),Object.freeze(this),this}toString(){return`(${this[0]}, ${this[1]})`}}t.Tuple=l,t.t=function(n,t){return new l(n,t)},t.isTuple=function(n){return n instanceof l},t.isList=function(n){return Array.isArray(n)&&!(n instanceof l)},t.isIterable=function(n){return!!Array.isArray(n)||"string"!=typeof n&&"function"==typeof n[Symbol.iterator]},t.Stream=class{constructor(n){this.hn=n?new s(n):new s,this.wn=0}get seek(){return this.wn}set seek(n){n<0?this.wn=this.hn.length-1:n>this.hn.length-1?this.wn=this.hn.length:this.wn=n}get length(){return this.hn.length}write(n){const t=this.hn.data(),r=n.data(),e=Math.max(t.length,r.length+this.wn),o=new Uint8Array(e),i=this.seek;for(let n=0;nthis.hn.length-1)return new s;const t=this.hn.slice(this.seek,n);return this.seek+=n,t}getValue(){return this.hn}}},19:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.as_javascript=void 0;const e=r(593);t.as_javascript=function(n){function t(n,t){const r=t.pop(),e=t.pop();t.push(r),t.push(e)}function r(n,t){const r=t.pop(),o=t.pop();o.equal_to(e.Bytes.NULL)?t.push([r]):t.push(e.t(r,o))}function o(n,t){let r=[t.pop()];const e=t.pop();r=r.concat(e),t.push(r)}const i=[function n(e,i){const u=i.pop(),f=u.as_pair();if(f){const[u,a]=f;a.listp()?e.push(o):e.push(r),e.push(n),e.push(t),e.push(n),i.push(u),i.push(a)}else i.push(u.atom)}],u=[n];for(;i.length;){const n=i.pop();n&&n(i,u)}return u[u.length-1]}},959:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.limbs_for_int=t.int_to_bytes=t.int_from_bytes=void 0;const e=r(593);t.int_from_bytes=function(n){if(!n||0===n.length)return 0;const t=parseInt(n.hex(),16);return 128&n.get_byte_at(0)?t-(1<<8*n.length):t},t.int_to_bytes=function(n){if(n>Number.MAX_SAFE_INTEGER||n0?"MAX_SAFE_INTEGER":"MIN_SAFE_INTEGER"}: ${n}`);if(0===n)return e.Bytes.NULL;const t=(n<0?-n:n).toString(2).length+8>>3;let r=(n>>>0).toString(16);for(n>=0&&(r=r.length%2?`0${r}`:r);r.length/22&&r.substr(0,2)===(128&parseInt(r.substr(2,2),16)?"ff":"00");)r=r.substr(2);return e.h(r)},t.limbs_for_int=function(n){return(n<0?-n:n).toString(2).length+7>>3}},143:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.op_eq=t.op_raise=t.op_listp=t.op_rest=t.op_first=t.op_cons=t.op_if=void 0;const e=r(907),o=r(593),i=r(449),u=r(755);t.op_if=function(n){if(3!==n.list_len())throw new u.EvalError("i takes exactly 3 arguments",n);const t=n.rest();return n.first().nullp()?o.t(i.IF_COST,t.rest().first()):o.t(i.IF_COST,t.first())},t.op_cons=function(n){if(2!==n.list_len())throw new u.EvalError("c takes exactly 2 arguments",n);return o.t(i.CONS_COST,n.first().cons(n.rest().first()))},t.op_first=function(n){if(1!==n.list_len())throw new u.EvalError("f takes exactly 1 argument",n);return o.t(i.FIRST_COST,n.first().first())},t.op_rest=function(n){if(1!==n.list_len())throw new u.EvalError("r takes exactly 1 argument",n);return o.t(i.REST_COST,n.first().rest())},t.op_listp=function(n){if(1!==n.list_len())throw new u.EvalError("l takes exactly 1 argument",n);return o.t(i.LISTP_COST,n.first().listp()?e.SExp.TRUE:e.SExp.FALSE)},t.op_raise=function(n){throw new u.EvalError("clvm raise",n)},t.op_eq=function(n){if(2!==n.list_len())throw new u.EvalError("= takes exactly 2 arguments",n);const t=n.first(),r=n.rest().first();if(t.pair||r.pair)throw new u.EvalError("= on list",t.pair?t:r);const f=t.atom,a=r.atom;let c=i.EQ_BASE_COST;return c+=(f.length+a.length)*i.EQ_COST_PER_BYTE,o.t(c,f.equal_to(a)?e.SExp.TRUE:e.SExp.FALSE)}},449:function(n,t){"use strict";Object.defineProperty(t,"un",{value:!0}),t.APPLY_COST=t.LOGNOT_COST_PER_BYTE=t.LOGNOT_BASE_COST=t.LSHIFT_COST_PER_BYTE=t.LSHIFT_BASE_COST=t.ASHIFT_COST_PER_BYTE=t.ASHIFT_BASE_COST=t.BOOL_COST_PER_ARG=t.BOOL_BASE_COST=t.CONCAT_COST_PER_BYTE=t.CONCAT_COST_PER_ARG=t.CONCAT_BASE_COST=t.PATH_LOOKUP_COST_PER_ZERO_BYTE=t.PATH_LOOKUP_COST_PER_LEG=t.PATH_LOOKUP_BASE_COST=t.STRLEN_COST_PER_BYTE=t.STRLEN_BASE_COST=t.MUL_SQUARE_COST_PER_BYTE_DIVIDER=t.MUL_LINEAR_COST_PER_BYTE=t.MUL_COST_PER_OP=t.MUL_BASE_COST=t.PUBKEY_COST_PER_BYTE=t.PUBKEY_BASE_COST=t.POINT_ADD_COST_PER_ARG=t.POINT_ADD_BASE_COST=t.SHA256_COST_PER_BYTE=t.SHA256_COST_PER_ARG=t.SHA256_BASE_COST=t.DIV_COST_PER_BYTE=t.DIV_BASE_COST=t.DIVMOD_COST_PER_BYTE=t.DIVMOD_BASE_COST=t.GR_COST_PER_BYTE=t.GR_BASE_COST=t.EQ_COST_PER_BYTE=t.EQ_BASE_COST=t.GRS_COST_PER_BYTE=t.GRS_BASE_COST=t.LOG_COST_PER_ARG=t.LOG_COST_PER_BYTE=t.LOG_BASE_COST=t.ARITH_COST_PER_ARG=t.ARITH_COST_PER_BYTE=t.ARITH_BASE_COST=t.MALLOC_COST_PER_BYTE=t.LISTP_COST=t.REST_COST=t.FIRST_COST=t.CONS_COST=t.IF_COST=void 0,t.QUOTE_COST=void 0,t.IF_COST=33,t.CONS_COST=50,t.FIRST_COST=30,t.REST_COST=30,t.LISTP_COST=19,t.MALLOC_COST_PER_BYTE=10,t.ARITH_BASE_COST=99,t.ARITH_COST_PER_BYTE=3,t.ARITH_COST_PER_ARG=320,t.LOG_BASE_COST=100,t.LOG_COST_PER_BYTE=3,t.LOG_COST_PER_ARG=264,t.GRS_BASE_COST=117,t.GRS_COST_PER_BYTE=1,t.EQ_BASE_COST=117,t.EQ_COST_PER_BYTE=1,t.GR_BASE_COST=498,t.GR_COST_PER_BYTE=2,t.DIVMOD_BASE_COST=1116,t.DIVMOD_COST_PER_BYTE=6,t.DIV_BASE_COST=988,t.DIV_COST_PER_BYTE=4,t.SHA256_BASE_COST=87,t.SHA256_COST_PER_ARG=134,t.SHA256_COST_PER_BYTE=2,t.POINT_ADD_BASE_COST=101094,t.POINT_ADD_COST_PER_ARG=1343980,t.PUBKEY_BASE_COST=1325730,t.PUBKEY_COST_PER_BYTE=38,t.MUL_BASE_COST=92,t.MUL_COST_PER_OP=885,t.MUL_LINEAR_COST_PER_BYTE=6,t.MUL_SQUARE_COST_PER_BYTE_DIVIDER=128,t.STRLEN_BASE_COST=173,t.STRLEN_COST_PER_BYTE=1,t.PATH_LOOKUP_BASE_COST=40,t.PATH_LOOKUP_COST_PER_LEG=4,t.PATH_LOOKUP_COST_PER_ZERO_BYTE=4,t.CONCAT_BASE_COST=142,t.CONCAT_COST_PER_ARG=135,t.CONCAT_COST_PER_BYTE=3,t.BOOL_BASE_COST=200,t.BOOL_COST_PER_ARG=300,t.ASHIFT_BASE_COST=596,t.ASHIFT_COST_PER_BYTE=3,t.LSHIFT_BASE_COST=277,t.LSHIFT_COST_PER_BYTE=3,t.LOGNOT_BASE_COST=331,t.LOGNOT_COST_PER_BYTE=3,t.APPLY_COST=90,t.QUOTE_COST=20},465:function(n,t,r){"use strict";var e=this&&this.vn||(Object.create?function(n,t,r,e){void 0===e&&(e=r),Object.defineProperty(n,e,{enumerable:!0,get:function(){return t[r]}})}:function(n,t,r,e){void 0===e&&(e=r),n[e]=t[r]}),o=this&&this.dn||function(n,t){for(var r in n)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||e(t,n,r)};Object.defineProperty(t,"un",{value:!0}),t.to_sexp_f=void 0;const i=r(907);o(r(572),t),o(r(190),t),o(r(213),t),o(r(593),t),o(r(19),t),o(r(959),t),o(r(629),t),o(r(143),t),o(r(449),t),o(r(755),t),o(r(419),t),o(r(601),t),o(r(637),t),o(r(990),t),o(r(282),t),o(r(351),t),o(r(907),t),t.to_sexp_f=i.SExp.to},419:function(n,t,r){"use strict";var e=this&&this.sn||function(n,t,r,e){return new(r||(r=Promise))((function(o,i){function u(n){try{a(e.next(n))}catch(n){i(n)}}function f(n){try{a(e.throw(n))}catch(n){i(n)}}function a(n){var t;n.done?o(n.value):(t=n.value,t instanceof r?t:new r((function(n){n(t)}))).then(u,f)}a((e=e.apply(n,t||[])).next())}))};Object.defineProperty(t,"un",{value:!0}),t.initialize=void 0;const o=r(190);t.initialize=function(){return e(this,void 0,void 0,(function*(){yield o.initializeBLS()}))}},601:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.op_softfork=t.op_all=t.op_any=t.op_not=t.op_lognot=t.op_logxor=t.op_logior=t.op_logand=t.binop_reduction=t.op_lsh=t.op_ash=t.op_concat=t.op_substr=t.op_strlen=t.op_pubkey_for_exp=t.op_gr_bytes=t.op_gr=t.op_div=t.op_divmod=t.op_multiply=t.op_subtract=t.op_add=t.args_as_bool_list=t.args_as_bools=t.args_as_int_list=t.args_as_int32=t.args_as_ints=t.op_sha256=t.malloc_cost=void 0;const e=r(915),o=r(907),i=r(449),u=r(593),f=r(755),a=r(959),c=r(629),s=r(190);function l(n,t){if(!t.atom)throw new f.EvalError("atom is None",t);return u.t(n+t.atom.length*i.MALLOC_COST_PER_BYTE,t)}function*h(n,t){for(const r of t.as_iter()){if(r.pair||!r.atom)throw new f.EvalError(`${n} requires int args`,r);yield u.t(r.as_int(),r.atom.length)}}function*w(n,t){for(const r of t.as_iter()){if(r.pair||!r.atom)throw new f.EvalError(`${n} requires int32 args`,r);if(r.atom.length>4)throw new f.EvalError(`${n} requires int32 args (with no leading zeros`,r);yield r.as_int()}}function v(n,t,r){const e=[];for(const r of h(n,t))e.push(r);if(e.length!==r){const e=1!==r?"s":"";throw new f.EvalError(`${n} takes exactly ${r} argument${e}`,t)}return e}function*d(n,t){for(const n of t.as_iter()){const t=n.atom;(null==t?void 0:t.equal_to(u.Bytes.NULL))?yield o.SExp.FALSE:yield o.SExp.TRUE}}function y(n,t,r){const e=[];for(const n of d(0,t))e.push(n);if(e.length!==r){const e=1!==r?"s":"";throw new f.EvalError(`${n} takes exactly ${r} argument${e}`,t)}return e}function p(n,t,r,e){let u=t,f=0,a=i.LOG_BASE_COST;for(const t of h(n,r)){const[n,r]=t;u=e(u,n),f+=r,a+=i.LOG_COST_PER_ARG}return a+=f*i.LOG_COST_PER_BYTE,l(a,o.SExp.to(u))}t.malloc_cost=l,t.op_sha256=function(n){let t=i.SHA256_BASE_COST,r=0;const a=new e.SHA256;for(const e of n.as_iter()){const n=e.atom;if(!n)throw new f.EvalError("sha256 on list",e);r+=n.length,t+=i.SHA256_COST_PER_ARG,a.update(n.as_word())}return t+=r*i.SHA256_COST_PER_BYTE,l(t,o.SExp.to(u.Bytes.from(a.finalize().toUint8Array())))},t.args_as_ints=h,t.args_as_int32=w,t.args_as_int_list=v,t.args_as_bools=d,t.args_as_bool_list=y,t.op_add=function(n){let t=0,r=i.ARITH_BASE_COST,e=0;for(const o of h("+",n)){const[n,u]=o;t+=n,e+=u,r+=i.ARITH_COST_PER_ARG}return r+=e*i.ARITH_COST_PER_BYTE,l(r,o.SExp.to(t))},t.op_subtract=function(n){let t=i.ARITH_BASE_COST;if(n.nullp())return l(t,o.SExp.to(0));let r=1,e=0,u=0;for(const o of h("-",n)){const[n,f]=o;e+=r*n,r=-1,u+=f,t+=i.ARITH_COST_PER_BYTE}return t+=u*i.ARITH_COST_PER_BYTE,l(t,o.SExp.to(e))},t.op_multiply=function(n){let t=i.MUL_BASE_COST;const r=h("*",n),e=r.next();if(e.done)return l(t,o.SExp.to(1));let[u,f]=e.value;for(const n of r){const[r,e]=n;t+=i.MUL_COST_PER_OP,t+=(e+f)*i.MUL_LINEAR_COST_PER_BYTE,t+=e*f/i.MUL_SQUARE_COST_PER_BYTE_DIVIDER>>0,u*=r,f=a.limbs_for_int(u)}return l(t,o.SExp.to(u))},t.op_divmod=function(n){let t=i.DIVMOD_BASE_COST;const[r,e]=v("divmod",n,2),[a,c]=r,[s,l]=e;if(0===s)throw new f.EvalError("divmod with 0",o.SExp.to(a));t+=(c+l)*i.DIVMOD_COST_PER_BYTE;const h=a/s>>0,w=a%s,d=o.SExp.to(h),y=o.SExp.to(w);return t+=(d.atom.length+y.atom.length)*i.MALLOC_COST_PER_BYTE,u.t(t,o.SExp.to(u.t(h,w)))},t.op_div=function(n){let t=i.DIV_BASE_COST;const[r,e]=v("/",n,2),[u,a]=r,[c,s]=e;if(0===c)throw new f.EvalError("div with 0",o.SExp.to(u));t+=(a+s)*i.DIV_COST_PER_BYTE;const h=u/c>>0;return l(t,o.SExp.to(h))},t.op_gr=function(n){const[t,r]=v(">",n,2),[e,f]=t,[a,c]=r;let s=i.GR_BASE_COST;return s+=(f+c)*i.GR_COST_PER_BYTE,u.t(s,e>a?o.SExp.TRUE:o.SExp.FALSE)},t.op_gr_bytes=function(n){const t=[];for(const r of n.as_iter())t.push(r);if(2!==t.length)throw new f.EvalError(">s takes exactly 2 arguments",n);const[r,e]=t;if(r.pair||e.pair)throw new f.EvalError(">s on list",r.pair?r:e);const a=r.atom,c=e.atom;let s=i.GRS_BASE_COST;return s+=(a.length+c.length)*i.GRS_COST_PER_BYTE,u.t(s,a.compare(c)>0?o.SExp.TRUE:o.SExp.FALSE)},t.op_pubkey_for_exp=function(n){let t=i.POINT_ADD_BASE_COST;const{G1Element:r}=s.getBLSModule();let e=new r;for(const r of n.as_iter()){if(!c.isAtom(r))throw new f.EvalError("point_add on list",r);try{const n=s.G1Element_from_bytes(r.atom.data());e=s.G1Element_add(e,n),t+=i.POINT_ADD_COST_PER_ARG}catch(t){throw new f.EvalError(`point_add expects blob, got ${r.atom}: ${JSON.stringify(t)}`,n)}}return l(t,o.SExp.to(e))},t.op_strlen=function(n){if(1!==n.list_len())throw new f.EvalError("strlen takes exactly 1 argument",n);const t=n.first();if(!c.isAtom(t))throw new f.EvalError("strlen on list",t);const r=t.atom.length;return l(i.STRLEN_BASE_COST+r*i.STRLEN_COST_PER_BYTE,o.SExp.to(r))},t.op_substr=function(n){const t=n.list_len();if(![2,3].includes(t))throw new f.EvalError("substr takes exactly 2 or 3 arguments",n);const r=n.first();if(!c.isAtom(r))throw new f.EvalError("substr on list",r);const e=r.atom;let i,a;if(2===t)i=w("substr",n.rest()).next().value,a=e.length;else{const t=[];for(const r of w("substr",n.rest()))t.push(r);[i,a]=t}if(a>e.length||a4)throw new f.EvalError("ash requires int32 args (with no leading zeros)",n.rest().first());if(Math.abs(c)>65535)throw new f.EvalError("shift too large",o.SExp.to(c));let h;h=c>=0?e<>-c;let w=i.ASHIFT_BASE_COST;return w+=(u+a.limbs_for_int(h))*i.ASHIFT_COST_PER_BYTE,l(w,o.SExp.to(h))},t.op_lsh=function(n){const[t,r]=v("lsh",n,2),e=t[1],[u,c]=r;if(c>4)throw new f.EvalError("lsh requires int32 args (with no leading zeros)",n.rest().first());if(Math.abs(u)>65535)throw new f.EvalError("shift too large",o.SExp.to(u));const s=n.first().atom,h=a.int_from_bytes(s);let w;w=u>=0?h<>-u;let d=i.LSHIFT_BASE_COST;return d+=(e+a.limbs_for_int(w))*i.LSHIFT_COST_PER_BYTE,l(d,o.SExp.to(w))},t.binop_reduction=p,t.op_logand=function(n){return p("logand",-1,n,((n,t)=>n&=t))},t.op_logior=function(n){return p("logior",0,n,((n,t)=>n|=t))},t.op_logxor=function(n){return p("logxor",0,n,((n,t)=>n^=t))},t.op_lognot=function(n){const t=v("lognot",n,1),[r,e]=t[0];return l(i.LOGNOT_BASE_COST+e*i.LOGNOT_COST_PER_BYTE,o.SExp.to(~r))},t.op_not=function(n){const t=y("not",n,1)[0];if(!c.isAtom(t))throw new f.EvalError("not on list",n);let r;return r=t.atom.equal_to(u.Bytes.NULL)?o.SExp.TRUE:o.SExp.FALSE,u.t(i.BOOL_BASE_COST,o.SExp.to(r))},t.op_any=function(n){const t=[];for(const r of d(0,n))t.push(r);const r=i.BOOL_BASE_COST+t.length*i.BOOL_COST_PER_ARG;let e=o.SExp.FALSE;for(const r of t){if(!c.isAtom(r))throw new f.EvalError("any on list",n);if(!r.atom.equal_to(u.Bytes.NULL)){e=o.SExp.TRUE;break}}return u.t(r,o.SExp.to(e))},t.op_all=function(n){const t=[];for(const r of d(0,n))t.push(r);const r=i.BOOL_BASE_COST+t.length*i.BOOL_COST_PER_ARG;let e=o.SExp.TRUE;for(const r of t){if(!c.isAtom(r))throw new f.EvalError("all on list",n);if(r.atom.equal_to(u.Bytes.NULL)){e=o.SExp.FALSE;break}}return u.t(r,o.SExp.to(e))},t.op_softfork=function(n){if(n.list_len()<1)throw new f.EvalError("softfork takes at least 1 argument",n);const t=n.first();if(!c.isAtom(t))throw new f.EvalError("softfork requires int args",t);const r=t.as_int();if(r<1)throw new f.EvalError("cost must be > 0",n);return u.t(r,o.SExp.FALSE)}},637:function(n,t){"use strict";function r(n,t,r){const e={};for(const o of Object.keys(n)){const i=t[`op_${r[o]||o}`];"function"==typeof i&&(e[n[o]]=i)}return e}Object.defineProperty(t,"un",{value:!0}),t.operators_for_module=t.operators_for_dict=void 0,t.operators_for_dict=r,t.operators_for_module=function(n,t,e={}){return r(n,t,e)}},990:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.OPERATOR_LOOKUP=t.OperatorDict=t.APPLY_ATOM=t.QUOTE_ATOM=t.default_unknown_op=t.args_len=t.OP_REWRITE=t.KEYWORD_TO_ATOM=t.KEYWORD_FROM_ATOM=void 0;const e=r(959),o=r(907),i=r(593),u=r(755),f=r(449),a=r(637),c=r(143),s=r(601);function*l(n,t){for(const r of t.as_iter()){if(r.pair)throw new u.EvalError(`${n} requires int args"`,r);yield r.atom.length}}function h(n,t){if(0===n.length||n.slice(0,2).equal_to(i.Bytes.from("0xffff","hex")))throw new u.EvalError("reserved operator",o.SExp.to(n));const r=(192&n.get_byte_at(n.length-1))>>6;if(n.length>5)throw new u.EvalError("invalid operator",o.SExp.to(n));const a=e.int_from_bytes(n.slice(0,n.length-1))+1;let c;if(0===r)c=1;else if(1===r){c=f.ARITH_BASE_COST;let n=0;for(const r of l("unknown op",t))n+=r,c+=f.ARITH_COST_PER_ARG;c+=n*f.ARITH_COST_PER_BYTE}else if(2===r){c=f.MUL_BASE_COST;const n=l("unknown op",t),r=n.next();if(!r.done){let t=r.value;for(const r of n)c+=f.MUL_COST_PER_OP,c+=(r+t)*f.MUL_LINEAR_COST_PER_BYTE,c+=r*t/f.MUL_SQUARE_COST_PER_BYTE_DIVIDER>>0,t+=r}}else{if(3!==r)throw new Error(`Invalid cost_function: ${r}`);{c=f.CONCAT_BASE_COST;let n=0;for(const r of t.as_iter()){if(r.pair)throw new u.EvalError("unknown op on list",r);c+=f.CONCAT_COST_PER_ARG,n+=r.atom.length}c+=n*f.CONCAT_COST_PER_BYTE}}if(c*=a,c>=2**32)throw new u.EvalError("invalid operator",o.SExp.to(n));return i.t(c,o.SExp.null())}function w(n,t){Object.keys(t).forEach((r=>{n[r]=t[r]}))}function v(n,r,e,o){const u=Object.assign(Object.assign({},n),{quote_atom:r||n.quote_atom||t.QUOTE_ATOM,apply_atom:e||n.apply_atom||t.APPLY_ATOM,unknown_op_handler:o||h}),f=function(n,t){if("string"==typeof n)n=i.Bytes.from(n,"hex");else if("number"==typeof n)n=i.Bytes.from([n]);else if(!(n instanceof i.Bytes))throw new Error(`Invalid op: ${JSON.stringify(n)}`);w(u,f);const r=u[n.hex()];return"function"!=typeof r?u.unknown_op_handler(n,t):r(t)};return w(f,u),f}t.KEYWORD_FROM_ATOM={"00":".","01":"q","02":"a","03":"i","04":"c","05":"f","06":"r","07":"l","08":"x","09":"=","0a":">s","0b":"sha256","0c":"substr","0d":"strlen","0e":"concat","0f":".",10:"+",11:"-",12:"*",13:"/",14:"divmod",15:">",16:"ash",17:"lsh",18:"logand",19:"logior","1a":"logxor","1b":"lognot","1c":".","1d":"point_add","1e":"pubkey_for_exp","1f":".",20:"not",21:"any",22:"all",23:".",24:"softfork"},t.KEYWORD_TO_ATOM={q:"01",a:"02",i:"03",c:"04",f:"05",r:"06",l:"07",x:"08","=":"09",">s":"0a",sha256:"0b",substr:"0c",strlen:"0d",concat:"0e","+":"10","-":"11","*":"12","/":"13",divmod:"14",">":"15",ash:"16",lsh:"17",logand:"18",logior:"19",logxor:"1a",lognot:"1b",point_add:"1d",pubkey_for_exp:"1e",not:"20",any:"21",all:"22",".":"23",softfork:"24"},t.OP_REWRITE={"+":"add","-":"subtract","*":"multiply","/":"div",i:"if",c:"cons",f:"first",r:"rest",l:"listp",x:"raise","=":"eq",">":"gr",">s":"gr_bytes"},t.args_len=l,t.default_unknown_op=h,t.QUOTE_ATOM=i.Bytes.from(t.KEYWORD_TO_ATOM.q,"hex"),t.APPLY_ATOM=i.Bytes.from(t.KEYWORD_TO_ATOM.a,"hex"),t.OperatorDict=v;const d=v(a.operators_for_module(t.KEYWORD_TO_ATOM,c,t.OP_REWRITE),t.QUOTE_ATOM,t.APPLY_ATOM);w(d,a.operators_for_module(t.KEYWORD_TO_ATOM,s,t.OP_REWRITE)),t.OPERATOR_LOOKUP=d},282:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.run_program=t.msb_mask=t.to_pre_eval_op=void 0;const e=r(213),o=r(907),i=r(629),u=r(593),f=r(449),a=r(755);function c(n,t){return function(r,e){const o=t(e[e.length-1]),i=n(o.first(),o.rest());if("function"==typeof i){const n=(n,r)=>(i(t(r[r.length-1])),0);r.push(n)}}}function s(n){return n|=n>>1,n|=n>>2,1+(n|=n>>4)>>1}t.to_pre_eval_op=c,t.msb_mask=s,t.run_program=function(n,t,r,l=e.None,h=e.None){n=o.SExp.to(n);const w=h?c(h,o.SExp.to):e.None;function v(n,t){const r=t.pop(),e=t.pop();return t.push(r),t.push(e),0}function d(n,t){const r=t.pop(),e=t.pop();return t.push(r.cons(e)),0}function y(n,t){w&&w(n,t);const e=t.pop(),c=e.first(),l=e.rest();if(!i.isCons(c)){const[n,r]=function(n,t){let r=f.PATH_LOOKUP_BASE_COST;if(r+=f.PATH_LOOKUP_COST_PER_LEG,n.nullp())return u.t(r,o.SExp.null());const e=n.atom;let c=0;for(;cc||wl)throw new a.EvalError("cost exceeded",o.SExp.to(l));return u.t(g,m[m.length-1])}},351:function(n,t,r){"use strict";Object.defineProperty(t,"un",{value:!0}),t.sexp_buffer_from_stream=t.sexp_from_stream=t.sexp_to_stream=t.atom_to_byte_iterator=t.sexp_to_byte_iterator=void 0;const e=r(593),o=r(959),i=r(629),u=127;function*f(n){const t=[n];for(;t.length;){const r=(n=t.pop()).as_pair();r?(yield e.Bytes.from([255]),t.push(r[1]),t.push(r[0])):yield*a(n.atom)}}function*a(n){const t=n?n.length:0;if(0===t||!n)return void(yield e.Bytes.from("0x80","hex"));if(1===t&&n.get_byte_at(0)<=127)return void(yield n);let r;if(t<64)r=Uint8Array.from([128|t]);else if(t<8192)r=Uint8Array.from([192|t>>8,t>>0&255]);else if(t<1048576)r=Uint8Array.from([224|t>>16,t>>8&255,t>>0&255]);else if(t<134217728)r=Uint8Array.from([240|t>>24,t>>16&255,t>>8&255,t>>0&255]);else{if(!(t<17179869184))throw new Error(`sexp too long ${n}`);r=Uint8Array.from([248|t/2**32>>0,t/2**24>>0&255,t/65536>>0&255,t/256>>0&255,t/1>>0&255])}const o=e.Bytes.from(r);yield o,yield n}function c(n,t,r,i){const f=r.read(1);if(0===f.length)throw new Error("bad encoding");const a=f.get_byte_at(0);if(255===a)return n.push(s),n.push(c),void n.push(c);t.push(function(n,t,r){if(128===t)return r(e.Bytes.NULL);if(t<=u)return r(e.Bytes.from([t]));let i=0,f=128;for(;t&f;)i+=1,t&=255^f,f>>=1;let a=e.Bytes.from([t]);if(i>1){const t=n.read(i-1);if(t.length!==i-1)throw new Error("bad encoding");a=a.concat(t)}const c=o.int_from_bytes(a);if(c>=17179869184)throw new Error("blob too large");const s=n.read(c);if(s.length!==c)throw new Error("bad encoding");return r(s)}(r,a,i))}function s(n,t,r,o){const i=t.pop(),u=t.pop();t.push(o(e.t(u,i)))}function l(n){const t=n.read(1);if(0===t.length)throw new Error("bad encoding");const r=t.get_byte_at(0);return 255===r?e.t(t,2):e.t(function(n,t){if(128===t)return e.Bytes.from([t]);if(t<=u)return e.Bytes.from([t]);let r=0,i=128,f=t;for(;f&i;)r+=1,f&=255^i,i>>=1;let a=e.Bytes.from([f]);if(r>1){const t=n.read(r-1);if(t.length!==r-1)throw new Error("bad encoding");a=a.concat(t)}const c=o.int_from_bytes(a);if(c>=17179869184)throw new Error("blob too large");const s=n.read(c);if(s.length!==c)throw new Error("bad encoding");return e.Bytes.from([t]).concat(a.slice(1)).concat(s)}(n,r),0)}t.sexp_to_byte_iterator=f,t.atom_to_byte_iterator=a,t.sexp_to_stream=function(n,t){for(const r of f(n))t.write(r)},t.sexp_from_stream=function(n,t){const r=[c],e=[];for(;r.length;){const t=r.pop();t&&t(r,e,n,(n=>new i.CLVMObject(n)))}return t(e.pop())},t.sexp_buffer_from_stream=function(n){let t=new e.Bytes,r=1;for(;r>0;){r-=1;const[e,o]=l(n);r+=o,t=t.concat(e)}return t}},135:function(){},33:function(){},794:function(){},845:function(){}},t={},function r(e){var o=t[e];if(void 0!==o)return o.exports;var i=t[e]={exports:{}};return n[e].call(i.exports,i,i.exports,r),i.exports}(465);var n,t})); \ No newline at end of file diff --git a/dist/casts.js b/dist/casts.js index d680e9d..6b6e511 100644 --- a/dist/casts.js +++ b/dist/casts.js @@ -8,7 +8,12 @@ function int_from_bytes(b) { if (!b || b.length === 0) { return 0; } - return parseInt(b.hex(), 16); + const unsigned32 = parseInt(b.hex(), 16); + // If the first bit is 1, it is recognized as a negative number. + if (b.get_byte_at(0) & 0x80) { + return unsigned32 - (1 << (b.length * 8)); + } + return unsigned32; } exports.int_from_bytes = int_from_bytes; function int_to_bytes(v) { diff --git a/dist/operators.js b/dist/operators.js index f3a9255..2ea692f 100644 --- a/dist/operators.js +++ b/dist/operators.js @@ -283,7 +283,7 @@ function OperatorDict(atom_op_function_map, quote_atom, apply_atom, unknown_op_h throw new Error(`Invalid op: ${JSON.stringify(op)}`); } merge(dict, OperatorDict); - const f = dict[op.toString()]; + const f = dict[op.hex()]; if (typeof f !== "function") { return dict.unknown_op_handler(op, args); } From bc109e932c042f17903a2aba886ea424ffb399c3 Mon Sep 17 00:00:00 2001 From: ChiaMineJP Date: Sun, 11 Jul 2021 19:05:45 +0900 Subject: [PATCH 4/4] Set version to 0.0.18 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4ef4a9a..0cd83da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clvm", - "version": "0.0.17", + "version": "0.0.18", "author": "Admin ChiaMineJP ", "description": "Javascript implementation of chia lisp", "license": "MIT",