Update r2papi.ts 0.1.1 ##lang

This commit is contained in:
pancake 2023-05-18 02:31:30 +02:00 committed by pancake
parent 983ba627e2
commit f500fbe771
6 changed files with 570 additions and 519 deletions

View File

@ -64,7 +64,7 @@ static void js_std_dump_error1(JSContext *ctx, JSValueConst exception_val) {
}
}
void js_std_dump_error(JSContext *ctx) {
static void js_std_dump_error(JSContext *ctx) {
JSValue exception_val;
exception_val = JS_GetException (ctx);
js_std_dump_error1 (ctx, exception_val);

View File

@ -1,214 +1,222 @@
static const char *const js_r2papi_qjs = "" \
"Object.defineProperty(G,\"__esModule\",{value:!0}),G.Base64=G.N"\
"ativePointer=G.R2Papi=void 0;const shell_js_1=G;G.R2Papi=clas"\
"s{constructor(t){this.r2=t}jsonToTypescript(t,s){let i=`inter"\
"face ${t} {\n`;s.length&&0<s.length&&(s=s[0]);for(let t of Obj"\
"ect.keys(s))i+=` ${t}: ${typeof s[t]};\n`;return i+`}\n`}new"\
"Map(t,s,i,e,r,n=\"\"){this.cmd(`om ${t} ${s} ${i} ${e} ${r} `+n"\
")}at(t){return new NativePointer(t)}getShell(){return new she"\
"ll_js_1.R2PapiShell(this)}version(){return this.r2.cmd(\"?Vq\")"\
".trim()}platform(){return this.r2.cmd(\"uname\").trim()}arch(){"\
"return this.r2.cmd(\"uname -a\").trim()}bits(){return this.r2.c"\
"md(\"uname -b\").trim()}id(){return+this.r2.cmd(\"?vi:$p\")}print"\
"At(t,s,i){}clearScreen(){return this.r2.cmd(\"!clear\"),this}ge"\
"tConfig(t){return this.r2.call(\"e \"+t).trim()}setConfig(t,s){"\
"return this.r2.call(\"e \"+t+\"=\"+s),this}getRegisters(){return "\
"this.cmdj(\"drj\")}resizeFile(t){return this.cmd(\"r \"+t),this}i"\
"nsertNullBytes(t,s){return this.cmd(`r+${t}@`+(s=void 0===s?\""\
"$$\":s)),this}removeBytes(t,s){return this.cmd(`r-${t}@`+(s=vo"\
"id 0===s?\"$$\":s)),this}seek(t){return this.cmd(\"s \"+t),this}g"\
"etBlockSize(){return+this.cmd(\"b\")}setBlockSize(t){return thi"\
"s.cmd(\"b \"+t),this}enumerateThreads(){return[{context:this.cm"\
"dj(\"drj\"),id:0,state:\"waiting\",selected:!0}]}currentThreadId("\
"){return+this.cmd(\"e cfg.debug\")?+this.cmd(\"dpt.\"):this.id()}"\
"setRegisters(t){for(var s of Object.keys(t)){var i=t[s];this."\
"r2.cmd(\"dr \"+s+\"=\"+i)}}hex(t){return this.r2.cmd(\"?v \"+t).tri"\
"m()}step(){return this.r2.cmd(\"ds\"),this}stepOver(){return th"\
"is.r2.cmd(\"dso\"),this}math(t){return+this.r2.cmd(\"?v \"+t)}ste"\
"pUntil(t){this.cmd(\"dsu \"+t)}searchDisasm(t){return this.call"\
"j(\"/ad \"+t)}searchString(t){return this.cmdj(\"/j \"+t)}searchB"\
"ytes(t){t=t.map(function(t){return(255&t).toString(16)}).join"\
"(\"\");return this.cmdj(\"/xj \"+t)}binInfo(){try{return this.cmd"\
"j(\"ij~{bin}\")}catch(t){return{}}}selectBinary(t){this.call(\"o"\
"b \"+t)}openFile(t){this.call(\"o \"+t)}enumeratePlugins(t){swit"\
"ch(t){case\"bin\":return this.callj(\"Lij\");case\"io\":return this"\
".callj(\"Loj\");case\"core\":return this.callj(\"Lcj\");case\"anal\":"\
"return this.callj(\"Laj\");case\"lang\":return this.callj(\"Llj\")}"\
"return[]}enumerateModules(){return this.callj(\"dmmj\")}enumera"\
"teFiles(){return this.callj(\"oj\")}enumerateBinaries(){return "\
"this.callj(\"obj\")}enumerateMaps(){return this.callj(\"omj\")}en"\
"umerateSymbols(){return this.callj(\"isj\")}enumerateExports(){"\
"return this.callj(\"iEj\")}enumerateImports(){return this.callj"\
"(\"iij\")}enumerateLibraries(){return this.callj(\"ilj\")}enumera"\
"teSections(){return this.callj(\"iSj\")}enumerateSegments(){ret"\
"urn this.callj(\"iSSj\")}enumerateEntrypoints(){return this.cal"\
"lj(\"iej\")}enumerateRelocations(){return this.callj(\"irj\")}enu"\
"merateFunctions(){return this.cmdj(\"aflj\")}enumerateFlags(){r"\
"eturn this.cmdj(\"fj\")}skip(){this.r2.cmd(\"dss\")}ptr(t){return"\
" new NativePointer(t,this)}call(t){return this.r2.call(t)}cal"\
"lj(t){return JSON.parse(this.call(t))}cmd(t){return this.r2.c"\
"md(t)}cmdj(t){return JSON.parse(this.cmd(t))}log(t){return th"\
"is.r2.log(t)}clippy(t){this.r2.log(this.r2.cmd(\"?E \"+t))}asci"\
"i(t){this.r2.log(this.r2.cmd(\"?ea \"+t))}};class NativePointer"\
"{constructor(t,s){this.api=void 0===s?G.R:s,this.addr=(\"\"+t)."\
"trim()}hexdump(t){return this.api.cmd(`x${void 0===t?\"\":\"\"+t}"\
"@`+this.addr)}functionGraph(t){return\"dot\"===t?this.api.cmd(\""\
"agfd@ \"+this.addr):\"json\"===t?this.api.cmd(\"agfj@\"+this.addr)"\
":\"mermaid\"===t?this.api.cmd(\"agfm@\"+this.addr):this.api.cmd(\""\
"agf@\"+this.addr)}readByteArray(t){return JSON.parse(this.api."\
"cmd(`p8j ${t}@`+this.addr))}and(t){return this.addr=this.api."\
"call(`?v ${this.addr} & `+t).trim(),this}or(t){return this.ad"\
"dr=this.api.call(`?v ${this.addr} | `+t).trim(),this}add(t){r"\
"eturn this.addr=this.api.call(`?v ${this.addr}+`+t).trim(),th"\
"is}sub(t){return this.addr=this.api.call(`?v ${this.addr}-`+t"\
").trim(),this}writeByteArray(t){return this.api.cmd(\"wx \"+t.j"\
"oin(\"\")),this}writeAssembly(t){return this.api.cmd(`\"wa ${t} "\
"@ `+this.addr),this}writeCString(t){return this.api.call(\"w \""\
"+t),this}isNull(){return 0==+this.addr}compare(t){return(t=\"s"\
"tring\"!=typeof t&&\"number\"!=typeof t?t:new NativePointer(t))."\
"addr===this.addr}pointsToNull(){return this.readPointer().com"\
"pare(0)}toString(){return this.addr.trim()}writePointer(t){va"\
"r s=64==+this.api.getConfig(\"asm.bits\")?\"wv8\":\"wv4\";this.api."\
"cmd(s+` ${t}@`+this)}readPointer(){return 64==+this.api.getCo"\
"nfig(\"asm.bits\")?new NativePointer(this.api.call(\"pv8@\"+this."\
"addr)):new NativePointer(this.api.call(\"pv4@\"+this.addr))}rea"\
"dU8(){return+this.api.cmd('pv1@\"'+this.addr)}readU16(){return"\
"+this.api.cmd('pv2@\"'+this.addr)}readU32(){return+this.api.cm"\
"d('pv4@\"'+this.addr)}readU64(){return+this.api.cmd('pv8@\"'+th"\
"is.addr)}writeInt(t){return+this.api.cmd(`wv4 ${t}@`+this.add"\
"r)}writeU8(t){return this.api.cmd(`wv1 ${t}@`+this.addr),!0}w"\
"riteU16(t){return this.api.cmd(`wv2 ${t}@`+this.addr),!0}writ"\
"eU32(t){return this.api.cmd(`wv4 ${t}@`+this.addr),!0}writeU6"\
"4(t){return this.api.cmd(`wv8 ${t}@`+this.addr),!0}readInt(){"\
"return+this.api.cmd('pv4@\"'+this.addr)}readCString(){return J"\
"SON.parse(this.api.cmd(\"psj@\"+this.addr)).string}instruction("\
"){return this.api.cmdj(\"aoj@\"+this.addr)[0]}disassemble(t){re"\
"turn this.api.cmd(`pd ${void 0===t?\"\":\"\"+t}@`+this.addr)}anal"\
"yzeFunction(){return this.api.cmd(\"af@\"+this.addr),this}analy"\
"zeFunctionRecursively(){return this.api.cmd(\"afr@\"+this.addr)"\
",this}analyzeProgram(t){switch(t=void 0===t?0:t){case 0:this."\
"api.cmd(\"aa\");break;case 1:this.api.cmd(\"aaa\");break;case 2:t"\
"his.api.cmd(\"aaaa\");break;case 3:this.api.cmd(\"aaaaa\")}return"\
" this}name(){return this.api.cmd(\"fd \"+this.addr).trim()}basi"\
"cBlock(){return this.api.cmdj(\"abj@\"+this.addr)}functionBasic"\
"Blocks(){return this.api.cmdj(\"afbj@\"+this.addr)}xrefs(){retu"\
"rn this.api.cmdj(\"axtj@\"+this.addr)}}G.NativePointer=NativePo"\
"inter;G.Base64=class{static encode(t){return(0,G.b64)(t)}stat"\
"ic decode(t){return(0,G.b64)(t,!0)}},Object.defineProperty(G,"\
"\"__esModule\",{value:!0}),G.R2PapiShell=void 0;G.R2PapiShell=c"\
"lass{constructor(t){this.rp=t}mkdir(t,s){return!0===s?this.rp"\
".call(\"mkdir -p \"+t):this.rp.call(\"mkdir \"+t),!0}unlink(t){re"\
"turn this.rp.call(\"rm \"+t),!0}chdir(t){return this.rp.call(\"c"\
"d \"+t),!0}ls(){return this.rp.call(\"ls -q\").trim().split(\"\\n\""\
")}fileExists(t){return!1}open(t){this.rp.call(\"open \"+t)}syst"\
"em(t){return this.rp.call(\"!\"+t),0}run(t){return this.rp.call"\
"(\"rm \"+t),0}mount(t,s){return this.rp.call(`m ${t} `+s),!0}um"\
"ount(t){this.rp.call(\"m-\"+t)}chdir2(t){return this.rp.call(\"m"\
"dq \"+(t=void 0===t?\"/\":t)),!0}ls2(t){return this.rp.call(\"mdq"\
" \"+(t=void 0===t?\"/\":t)).trim().split(\"\\n\")}enumerateMountpoi"\
"nts(){return this.rp.cmdj(\"mlj\")}isSymlink(t){return!1}isDire"\
"ctory(t){return!1}},Object.defineProperty(G,\"__esModule\",{val"\
"ue:!0}),G.EsilParser=G.EsilNode=G.EsilToken=void 0;class Esil"\
"Token{constructor(t=\"\",s=0){this.label=\"\",this.comment=\"\",thi"\
"s.text=\"\",this.addr=\"0\",this.position=0,this.text=t,this.posi"\
"tion=s}toString(){return this.text}}G.EsilToken=EsilToken;cla"\
"ss EsilNode{constructor(t=new EsilToken,s){this.type=\"none\",t"\
"his.token=t,this.children=[]}setSides(t,s){this.lhs=t,this.rh"\
"s=s}addChildren(t,s){void 0!==t&&this.children.push(t),void 0"\
"!==s&&this.children.push(s)}toEsil(){if(void 0===this.lhs||vo"\
"id 0===this.rhs)return\"\";{let t=this.lhs.toEsil();return\"\"!=="\
"t&&(t+=\",\"),this.rhs.toEsil()+\",\"+t+this.token}}toString(){le"\
"t t=\"\";if(\"\"!==this.token.label&&(t+=this.token.label+\":\\n\"),"\
"this.token.addr,\"\"!==this.token.comment&&(t+=\"/*\"+this.token."\
"comment+\"*/\\n\"),\"GOTO\"===this.token.toString()&&(0<this.child"\
"ren.length?t+=\"goto label_\"+this.children[0].token.position+\""\
";\\n\":t+=`goto label_0;\n`),0<this.children.length){t+=` (if ("\
"${this.rhs})\n`;for(var s of this.children)null!==s&&\"\"!=(s=s."\
"toString())&&(t+=` ${s}\n`);t+=\" )\\n\"}return void 0!==this.l"\
"hs&&void 0!==this.rhs?t+` ( ${this.lhs} ${this.token} ${th"\
"is.rhs} )`:t+this.token.toString()}}G.EsilNode=EsilNode;G.Esi"\
"lParser=class{constructor(t){this.cur=0,this.r2=t,this.cur=0,"\
"this.stack=[],this.nodes=[],this.tokens=[],this.root=new Esil"\
"Node(new EsilToken(\"function\",0),\"block\")}toJSON(){if(0<this."\
"stack.length)throw new Error(\"The ESIL stack is not empty\");r"\
"eturn JSON.stringify(this.root,null,2)}toEsil(){return this.n"\
"odes.map(t=>t.toEsil()).join(\",\")}optimizeFlags(t){void 0!==t"\
".rhs&&this.optimizeFlags(t.rhs),void 0!==t.lhs&&this.optimize"\
"Flags(t.lhs);for(let s=0;s<t.children.length;s++)this.optimiz"\
"eFlags(t.children[s]);var s=t.toString();4096<+s&&\"\"!=(s=r2.c"\
"md(\"fd.@ \"+s).trim().split(\"\\n\")[0].trim())&&-1===s.indexOf(\""\
"+\")&&(t.token.text=s)}optimize(t){-1!=t.indexOf(\"flag\")&&this"\
".optimizeFlags(this.root)}toString(){return this.root.childre"\
"n.map(t=>t.toString()).join(\";\\n\")}reset(){this.nodes=[],this"\
".stack=[],this.tokens=[],this.cur=0,this.root=new EsilNode(ne"\
"w EsilToken(\"function\",0),\"block\")}parseRange(t,s){let i=t;fo"\
"r(;i<this.tokens.length&&i<s;){const t=this.peek(i);if(!t)bre"\
"ak;this.cur=i,this.pushToken(t),i=this.cur,i++}}parseFunction"\
"(t){var s=this;var e=r2.cmd(\"?v $$\").trim(),r=(void 0===t&&(t"\
"=e),r2.cmdj(\"afbj@\"+t));for(let t of r)r2.cmd(\"s \"+t.addr),fu"\
"nction(t){const i=r2.cmd(\"pie \"+t+\" @e:scr.color=0\").trim().s"\
"plit(\"\\n\");for(const t of i)if(0===t.length)console.log(\"Empt"\
"y\");else{const i=t.split(\" \");1<i.length&&(r2.cmd(\"s \"+i[0]),"\
"s.parse(i[1],i[0]),s.optimize(\"flags,labels\"))}}(t.ninstr);r2"\
".cmd(\"s \"+e)}parse(t,s){const i=t.trim().split(\",\").map(t=>t."\
"trim()),e=this.tokens.length;for(let t of i){const i=new Esil"\
"Token(t,this.tokens.length);void 0!==s&&(i.addr=s),this.token"\
"s.push(i)}t=this.tokens.length;this.parseRange(e,t)}peek(t){r"\
"eturn this.tokens[t]}pushToken(t){if(this.isNumber(t)){var s="\
"new EsilNode(t,\"number\");this.stack.push(s),this.nodes.push(s"\
")}else if(this.isInternal(t)){const s=new EsilNode(t,\"flag\");"\
"this.stack.push(s),this.nodes.push(s)}else if(!this.isOperati"\
"on(t)){const s=new EsilNode(t,\"register\");this.stack.push(s),"\
"this.nodes.push(s)}}isNumber(t){return!!t.toString().startsWi"\
"th(\"0\")||0<+t}isInternal(t){t=t.toString();return t.startsWit"\
"h(\"$\")&&1<t.length}parseUntil(t){t+=1;let i=t;const e=[],r=th"\
"is.nodes.length;for(this.stack.forEach(t=>e.push(t));i<this.t"\
"okens.length;){const t=this.peek(i);if(!t)break;if(\"}\"===t.to"\
"String())break;if(\"}{\"===t.toString())break;i++}this.stack=e;"\
"var n=i;return this.parseRange(t,n),this.nodes.length==r?null"\
":this.nodes[this.nodes.length-1]}getNodeFor(t){if(void 0!==th"\
"is.peek(t)){for(var s of this.nodes)if(s.token.position===t)r"\
"eturn s;this.nodes.push(new EsilNode(new EsilToken(\"label\",t)"\
",\"label\"))}return null}findNodeFor(t){for(var s of this.nodes"\
")if(s.token.position===t)return s;return null}isOperation(t){"\
"switch(t.toString()){case\"[1]\":case\"[2]\":case\"[4]\":case\"[8]\":"\
"if(!(1<=this.stack.length))throw new Error(\"Stack needs more "\
"items\");{const t=this.stack.pop();new EsilNode(t.token,\"opera"\
"tion\"),this.stack.push(t)}return!0;case\"!\":var s,i,e;if(1<=th"\
"is.stack.length)return s=new EsilNode(new EsilToken(\"\",t.posi"\
"tion),\"none\"),i=this.stack.pop(),(e=new EsilNode(t,\"operation"\
"\")).setSides(s,i),this.stack.push(e),!0;throw new Error(\"Stac"\
"k needs more items\");case\"\":case\"}\":case\"}{\":return!0;case\"DU"\
"P\":{if(this.stack.length<1)throw new Error(\"goto cant pop\");c"\
"onst t=this.stack.pop();this.stack.push(t),this.stack.push(t)"\
"}return!0;case\"GOTO\":if(null!==this.peek(t.position-1)){if(th"\
"is.stack.length<1)throw new Error(\"goto cant pop\");const s=th"\
"is.stack.pop();if(null!==s){const i=0|+s.toString();if(0<i){c"\
"onst s=this.peek(i);if(void 0!==s){s.label=\"label_\"+i,s.comme"\
"nt=\"hehe\";const e=new EsilNode(t,\"goto\"),r=this.getNodeFor(s."\
"position);null!=r&&e.children.push(r),this.root.children.push"\
"(e)}else console.error(\"Cannot find goto node\")}else console."\
"error(\"Cannot find dest node for goto\")}}return!0;case\"?{\":if"\
"(!(1<=this.stack.length))throw new Error(\"Stack needs more it"\
"ems\");{const s=new EsilNode(new EsilToken(\"if\",t.position),\"n"\
"one\"),i=this.stack.pop(),e=new EsilNode(t,\"operation\");e.setS"\
"ides(s,i);let r=this.parseUntil(t.position),n=null;null!==r&&"\
"(e.children.push(r),this.nodes.push(r),null!==(n=this.parseUn"\
"til(r.token.position+1)))&&(e.children.push(n),this.nodes.pus"\
"h(n)),this.nodes.push(e),this.root.children.push(e),null!==n&"\
"&(this.cur=n.token.position)}return!0;case\"-\":if(!(2<=this.st"\
"ack.length))throw new Error(\"Stack needs more items\");{const "\
"s=this.stack.pop(),i=this.stack.pop(),e=new EsilNode(t,\"opera"\
"tion\");e.setSides(s,i),this.stack.length,this.stack.push(e),t"\
"his.nodes.push(e)}return!0;case\"<\":case\">\":case\"^\":case\"&\":ca"\
"se\"|\":case\"+\":case\"*\":case\"/\":case\">>=\":case\"<<=\":case\">>>=\":"\
"case\"<<<=\":case\">>>>=\":case\"<<<<=\":if(!(2<=this.stack.length)"\
")throw new Error(\"Stack needs more items\");{const s=this.stac"\
"k.pop(),i=this.stack.pop(),e=new EsilNode(t,\"operation\");e.se"\
"tSides(s,i),this.stack.length,this.stack.push(e),this.nodes.p"\
"ush(e)}return!0;case\"=\":case\":=\":case\"-=\":case\"+=\":case\"==\":c"\
"ase\"=[1]\":case\"=[2]\":case\"=[4]\":case\"=[8]\":if(!(2<=this.stack"\
".length))throw new Error(\"Stack needs more items\");{const s=t"\
"his.stack.pop(),i=this.stack.pop(),e=new EsilNode(t,\"operatio"\
"n\");e.setSides(s,i),0===this.stack.length&&this.root.children"\
".push(e),this.nodes.push(e)}return!0}return!1}};\n";
"ativePointer=G.R2Papi=G.Assembler=void 0;const shell_js_1=G;G"\
".Assembler=class{constructor(t){this.program=\"\",this.labels={"\
"},this.endian=!1,this.pc=0,this.r2=null,this.r2=t,this.progra"\
"m=\"\",this.labels={}}setProgramCounter(t){this.pc=t}setEndian("\
"t){this.endian=t}toString(){return this.program}append(t){thi"\
"s.pc+=t.length/2,this.program+=t}label(t){var s=this.pc;retur"\
"n this.labels[t]=this.pc,s}asm(t){let s=this.r2.cmd('\"\"pa '+t"\
").trim();s.length<16||(s=\"____\",console.error(\"Invalid instru"\
"ction: \"+t)),this.append(s)}};G.R2Papi=class{constructor(t){t"\
"his.r2=t}jsonToTypescript(t,s){let i=`interface ${t} {\n`;s.le"\
"ngth&&0<s.length&&(s=s[0]);for(let t of Object.keys(s))i+=` "\
" ${t}: ${typeof s[t]};\n`;return i+`}\n`}newMap(t,s,i,e,r,n=\"\""\
"){this.cmd(`om ${t} ${s} ${i} ${e} ${r} `+n)}at(t){return new"\
" NativePointer(t)}getShell(){return new shell_js_1.R2PapiShel"\
"l(this)}version(){return this.r2.cmd(\"?Vq\").trim()}platform()"\
"{return this.r2.cmd(\"uname\").trim()}arch(){return this.r2.cmd"\
"(\"uname -a\").trim()}bits(){return this.r2.cmd(\"uname -b\").tri"\
"m()}id(){return+this.r2.cmd(\"?vi:$p\")}printAt(t,s,i){}clearSc"\
"reen(){return this.r2.cmd(\"!clear\"),this}getConfig(t){return "\
"this.r2.call(\"e \"+t).trim()}setConfig(t,s){return this.r2.cal"\
"l(\"e \"+t+\"=\"+s),this}getRegisters(){return this.cmdj(\"drj\")}r"\
"esizeFile(t){return this.cmd(\"r \"+t),this}insertNullBytes(t,s"\
"){return this.cmd(`r+${t}@`+(s=void 0===s?\"$$\":s)),this}remov"\
"eBytes(t,s){return this.cmd(`r-${t}@`+(s=void 0===s?\"$$\":s)),"\
"this}seek(t){return this.cmd(\"s \"+t),this}getBlockSize(){retu"\
"rn+this.cmd(\"b\")}setBlockSize(t){return this.cmd(\"b \"+t),this"\
"}enumerateThreads(){return[{context:this.cmdj(\"drj\"),id:0,sta"\
"te:\"waiting\",selected:!0}]}currentThreadId(){return+this.cmd("\
"\"e cfg.debug\")?+this.cmd(\"dpt.\"):this.id()}setRegisters(t){fo"\
"r(var s of Object.keys(t)){var i=t[s];this.r2.cmd(\"dr \"+s+\"=\""\
"+i)}}hex(t){return this.r2.cmd(\"?v \"+t).trim()}step(){return "\
"this.r2.cmd(\"ds\"),this}stepOver(){return this.r2.cmd(\"dso\"),t"\
"his}math(t){return+this.r2.cmd(\"?v \"+t)}stepUntil(t){this.cmd"\
"(\"dsu \"+t)}searchDisasm(t){return this.callj(\"/ad \"+t)}search"\
"String(t){return this.cmdj(\"/j \"+t)}searchBytes(t){t=t.map(fu"\
"nction(t){return(255&t).toString(16)}).join(\"\");return this.c"\
"mdj(\"/xj \"+t)}binInfo(){try{return this.cmdj(\"ij~{bin}\")}catc"\
"h(t){return{}}}selectBinary(t){this.call(\"ob \"+t)}openFile(t)"\
"{this.call(\"o \"+t)}enumeratePlugins(t){switch(t){case\"bin\":re"\
"turn this.callj(\"Lij\");case\"io\":return this.callj(\"Loj\");case"\
"\"core\":return this.callj(\"Lcj\");case\"anal\":return this.callj("\
"\"Laj\");case\"lang\":return this.callj(\"Llj\")}return[]}enumerate"\
"Modules(){return this.callj(\"dmmj\")}enumerateFiles(){return t"\
"his.callj(\"oj\")}enumerateBinaries(){return this.callj(\"obj\")}"\
"enumerateMaps(){return this.callj(\"omj\")}enumerateSymbols(){r"\
"eturn this.callj(\"isj\")}enumerateExports(){return this.callj("\
"\"iEj\")}enumerateImports(){return this.callj(\"iij\")}enumerateL"\
"ibraries(){return this.callj(\"ilj\")}enumerateSections(){retur"\
"n this.callj(\"iSj\")}enumerateSegments(){return this.callj(\"iS"\
"Sj\")}enumerateEntrypoints(){return this.callj(\"iej\")}enumerat"\
"eRelocations(){return this.callj(\"irj\")}enumerateFunctions(){"\
"return this.cmdj(\"aflj\")}enumerateFlags(){return this.cmdj(\"f"\
"j\")}skip(){this.r2.cmd(\"dss\")}ptr(t){return new NativePointer"\
"(t,this)}call(t){return this.r2.call(t)}callj(t){return JSON."\
"parse(this.call(t))}cmd(t){return this.r2.cmd(t)}cmdj(t){retu"\
"rn JSON.parse(this.cmd(t))}log(t){return this.r2.log(t)}clipp"\
"y(t){this.r2.log(this.r2.cmd(\"?E \"+t))}ascii(t){this.r2.log(t"\
"his.r2.cmd(\"?ea \"+t))}};class NativePointer{constructor(t,s){"\
"this.api=void 0===s?G.R:s,this.addr=(\"\"+t).trim()}hexdump(t){"\
"return this.api.cmd(`x${void 0===t?\"\":\"\"+t}@`+this.addr)}func"\
"tionGraph(t){return\"dot\"===t?this.api.cmd(\"agfd@ \"+this.addr)"\
":\"json\"===t?this.api.cmd(\"agfj@\"+this.addr):\"mermaid\"===t?thi"\
"s.api.cmd(\"agfm@\"+this.addr):this.api.cmd(\"agf@\"+this.addr)}r"\
"eadByteArray(t){return JSON.parse(this.api.cmd(`p8j ${t}@`+th"\
"is.addr))}and(t){return this.addr=this.api.call(`?v ${this.ad"\
"dr} & `+t).trim(),this}or(t){return this.addr=this.api.call(`"\
"?v ${this.addr} | `+t).trim(),this}add(t){return this.addr=th"\
"is.api.call(`?v ${this.addr}+`+t).trim(),this}sub(t){return t"\
"his.addr=this.api.call(`?v ${this.addr}-`+t).trim(),this}writ"\
"eByteArray(t){return this.api.cmd(\"wx \"+t.join(\"\")),this}writ"\
"eAssembly(t){return this.api.cmd(`\"wa ${t} @ `+this.addr),thi"\
"s}writeCString(t){return this.api.call(\"w \"+t),this}isNull(){"\
"return 0==+this.addr}compare(t){return(t=\"string\"!=typeof t&&"\
"\"number\"!=typeof t?t:new NativePointer(t)).addr===this.addr}p"\
"ointsToNull(){return this.readPointer().compare(0)}toString()"\
"{return this.addr.trim()}writePointer(t){var s=64==+this.api."\
"getConfig(\"asm.bits\")?\"wv8\":\"wv4\";this.api.cmd(s+` ${t}@`+thi"\
"s)}readPointer(){return 64==+this.api.getConfig(\"asm.bits\")?n"\
"ew NativePointer(this.api.call(\"pv8@\"+this.addr)):new NativeP"\
"ointer(this.api.call(\"pv4@\"+this.addr))}readU8(){return+this."\
"api.cmd('pv1@\"'+this.addr)}readU16(){return+this.api.cmd('pv2"\
"@\"'+this.addr)}readU32(){return+this.api.cmd('pv4@\"'+this.add"\
"r)}readU64(){return+this.api.cmd('pv8@\"'+this.addr)}writeInt("\
"t){return+this.api.cmd(`wv4 ${t}@`+this.addr)}writeU8(t){retu"\
"rn this.api.cmd(`wv1 ${t}@`+this.addr),!0}writeU16(t){return "\
"this.api.cmd(`wv2 ${t}@`+this.addr),!0}writeU32(t){return thi"\
"s.api.cmd(`wv4 ${t}@`+this.addr),!0}writeU64(t){return this.a"\
"pi.cmd(`wv8 ${t}@`+this.addr),!0}readInt(){return+this.api.cm"\
"d('pv4@\"'+this.addr)}readCString(){return JSON.parse(this.api"\
".cmd(\"psj@\"+this.addr)).string}instruction(){return this.api."\
"cmdj(\"aoj@\"+this.addr)[0]}disassemble(t){return this.api.cmd("\
"`pd ${void 0===t?\"\":\"\"+t}@`+this.addr)}analyzeFunction(){retu"\
"rn this.api.cmd(\"af@\"+this.addr),this}analyzeFunctionRecursiv"\
"ely(){return this.api.cmd(\"afr@\"+this.addr),this}analyzeProgr"\
"am(t){switch(t=void 0===t?0:t){case 0:this.api.cmd(\"aa\");brea"\
"k;case 1:this.api.cmd(\"aaa\");break;case 2:this.api.cmd(\"aaaa\""\
");break;case 3:this.api.cmd(\"aaaaa\")}return this}name(){retur"\
"n this.api.cmd(\"fd \"+this.addr).trim()}basicBlock(){return th"\
"is.api.cmdj(\"abj@\"+this.addr)}functionBasicBlocks(){return th"\
"is.api.cmdj(\"afbj@\"+this.addr)}xrefs(){return this.api.cmdj(\""\
"axtj@\"+this.addr)}}G.NativePointer=NativePointer;G.Base64=cla"\
"ss{static encode(t){return(0,G.b64)(t)}static decode(t){retur"\
"n(0,G.b64)(t,!0)}},Object.defineProperty(G,\"__esModule\",{valu"\
"e:!0}),G.R2PapiShell=void 0;G.R2PapiShell=class{constructor(t"\
"){this.rp=t}mkdir(t,s){return!0===s?this.rp.call(\"mkdir -p \"+"\
"t):this.rp.call(\"mkdir \"+t),!0}unlink(t){return this.rp.call("\
"\"rm \"+t),!0}chdir(t){return this.rp.call(\"cd \"+t),!0}ls(){ret"\
"urn this.rp.call(\"ls -q\").trim().split(\"\\n\")}fileExists(t){re"\
"turn!1}open(t){this.rp.call(\"open \"+t)}system(t){return this."\
"rp.call(\"!\"+t),0}run(t){return this.rp.call(\"rm \"+t),0}mount("\
"t,s){return this.rp.call(`m ${t} `+s),!0}umount(t){this.rp.ca"\
"ll(\"m-\"+t)}chdir2(t){return this.rp.call(\"mdq \"+(t=void 0===t"\
"?\"/\":t)),!0}ls2(t){return this.rp.call(\"mdq \"+(t=void 0===t?\""\
"/\":t)).trim().split(\"\\n\")}enumerateMountpoints(){return this."\
"rp.cmdj(\"mlj\")}isSymlink(t){return!1}isDirectory(t){return!1}"\
"},Object.defineProperty(G,\"__esModule\",{value:!0}),G.EsilPars"\
"er=G.EsilNode=G.EsilToken=void 0;class EsilToken{constructor("\
"t=\"\",s=0){this.label=\"\",this.comment=\"\",this.text=\"\",this.add"\
"r=\"0\",this.position=0,this.text=t,this.position=s}toString(){"\
"return this.text}}G.EsilToken=EsilToken;class EsilNode{constr"\
"uctor(t=new EsilToken,s){this.type=\"none\",this.token=t,this.c"\
"hildren=[]}setSides(t,s){this.lhs=t,this.rhs=s}addChildren(t,"\
"s){void 0!==t&&this.children.push(t),void 0!==s&&this.childre"\
"n.push(s)}toEsil(){if(void 0===this.lhs||void 0===this.rhs)re"\
"turn\"\";{let t=this.lhs.toEsil();return\"\"!==t&&(t+=\",\"),this.r"\
"hs.toEsil()+\",\"+t+this.token}}toString(){let t=\"\";if(\"\"!==thi"\
"s.token.label&&(t+=this.token.label+\":\\n\"),this.token.addr,\"\""\
"!==this.token.comment&&(t+=\"/*\"+this.token.comment+\"*/\\n\"),\"G"\
"OTO\"===this.token.toString()&&(0<this.children.length?t+=\"got"\
"o label_\"+this.children[0].token.position+\";\\n\":t+=`goto labe"\
"l_0;\n`),0<this.children.length){t+=` (if (${this.rhs})\n`;for"\
"(var s of this.children)null!==s&&\"\"!=(s=s.toString())&&(t+=`"\
" ${s}\n`);t+=\" )\\n\"}return void 0!==this.lhs&&void 0!==this."\
"rhs?t+` ( ${this.lhs} ${this.token} ${this.rhs} )`:t+this."\
"token.toString()}}G.EsilNode=EsilNode;G.EsilParser=class{cons"\
"tructor(t){this.cur=0,this.r2=t,this.cur=0,this.stack=[],this"\
".nodes=[],this.tokens=[],this.root=new EsilNode(new EsilToken"\
"(\"function\",0),\"block\")}toJSON(){if(0<this.stack.length)throw"\
" new Error(\"The ESIL stack is not empty\");return JSON.stringi"\
"fy(this.root,null,2)}toEsil(){return this.nodes.map(t=>t.toEs"\
"il()).join(\",\")}optimizeFlags(t){void 0!==t.rhs&&this.optimiz"\
"eFlags(t.rhs),void 0!==t.lhs&&this.optimizeFlags(t.lhs);for(l"\
"et s=0;s<t.children.length;s++)this.optimizeFlags(t.children["\
"s]);var s=t.toString();4096<+s&&\"\"!=(s=r2.cmd(\"fd.@ \"+s).trim"\
"().split(\"\\n\")[0].trim())&&-1===s.indexOf(\"+\")&&(t.token.text"\
"=s)}optimize(t){-1!=t.indexOf(\"flag\")&&this.optimizeFlags(thi"\
"s.root)}toString(){return this.root.children.map(t=>t.toStrin"\
"g()).join(\";\\n\")}reset(){this.nodes=[],this.stack=[],this.tok"\
"ens=[],this.cur=0,this.root=new EsilNode(new EsilToken(\"funct"\
"ion\",0),\"block\")}parseRange(t,s){let i=t;for(;i<this.tokens.l"\
"ength&&i<s;){const t=this.peek(i);if(!t)break;this.cur=i,this"\
".pushToken(t),i=this.cur,i++}}parseFunction(t){var s=this;var"\
" e=r2.cmd(\"?v $$\").trim(),r=(void 0===t&&(t=e),r2.cmdj(\"afbj@"\
"\"+t));for(let t of r)r2.cmd(\"s \"+t.addr),function(t){const i="\
"r2.cmd(\"pie \"+t+\" @e:scr.color=0\").trim().split(\"\\n\");for(con"\
"st t of i)if(0===t.length)console.log(\"Empty\");else{const i=t"\
".split(\" \");1<i.length&&(r2.cmd(\"s \"+i[0]),s.parse(i[1],i[0])"\
",s.optimize(\"flags,labels\"))}}(t.ninstr);r2.cmd(\"s \"+e)}parse"\
"(t,s){const i=t.trim().split(\",\").map(t=>t.trim()),e=this.tok"\
"ens.length;for(let t of i){const i=new EsilToken(t,this.token"\
"s.length);void 0!==s&&(i.addr=s),this.tokens.push(i)}t=this.t"\
"okens.length;this.parseRange(e,t)}peek(t){return this.tokens["\
"t]}pushToken(t){if(this.isNumber(t)){var s=new EsilNode(t,\"nu"\
"mber\");this.stack.push(s),this.nodes.push(s)}else if(this.isI"\
"nternal(t)){const s=new EsilNode(t,\"flag\");this.stack.push(s)"\
",this.nodes.push(s)}else if(!this.isOperation(t)){const s=new"\
" EsilNode(t,\"register\");this.stack.push(s),this.nodes.push(s)"\
"}}isNumber(t){return!!t.toString().startsWith(\"0\")||0<+t}isIn"\
"ternal(t){t=t.toString();return t.startsWith(\"$\")&&1<t.length"\
"}parseUntil(t){t+=1;let i=t;const e=[],r=this.nodes.length;fo"\
"r(this.stack.forEach(t=>e.push(t));i<this.tokens.length;){con"\
"st t=this.peek(i);if(!t)break;if(\"}\"===t.toString())break;if("\
"\"}{\"===t.toString())break;i++}this.stack=e;var n=i;return thi"\
"s.parseRange(t,n),this.nodes.length==r?null:this.nodes[this.n"\
"odes.length-1]}getNodeFor(t){if(void 0!==this.peek(t)){for(va"\
"r s of this.nodes)if(s.token.position===t)return s;this.nodes"\
".push(new EsilNode(new EsilToken(\"label\",t),\"label\"))}return "\
"null}findNodeFor(t){for(var s of this.nodes)if(s.token.positi"\
"on===t)return s;return null}isOperation(t){switch(t.toString("\
")){case\"[1]\":case\"[2]\":case\"[4]\":case\"[8]\":if(!(1<=this.stack"\
".length))throw new Error(\"Stack needs more items\");{const t=t"\
"his.stack.pop();new EsilNode(t.token,\"operation\"),this.stack."\
"push(t)}return!0;case\"!\":var s,i,e;if(1<=this.stack.length)re"\
"turn s=new EsilNode(new EsilToken(\"\",t.position),\"none\"),i=th"\
"is.stack.pop(),(e=new EsilNode(t,\"operation\")).setSides(s,i),"\
"this.stack.push(e),!0;throw new Error(\"Stack needs more items"\
"\");case\"\":case\"}\":case\"}{\":return!0;case\"DUP\":{if(this.stack."\
"length<1)throw new Error(\"goto cant pop\");const t=this.stack."\
"pop();this.stack.push(t),this.stack.push(t)}return!0;case\"GOT"\
"O\":if(null!==this.peek(t.position-1)){if(this.stack.length<1)"\
"throw new Error(\"goto cant pop\");const s=this.stack.pop();if("\
"null!==s){const i=0|+s.toString();if(0<i){const s=this.peek(i"\
");if(void 0!==s){s.label=\"label_\"+i,s.comment=\"hehe\";const e="\
"new EsilNode(t,\"goto\"),r=this.getNodeFor(s.position);null!=r&"\
"&e.children.push(r),this.root.children.push(e)}else console.e"\
"rror(\"Cannot find goto node\")}else console.error(\"Cannot find"\
" dest node for goto\")}}return!0;case\"?{\":if(!(1<=this.stack.l"\
"ength))throw new Error(\"Stack needs more items\");{const s=new"\
" EsilNode(new EsilToken(\"if\",t.position),\"none\"),i=this.stack"\
".pop(),e=new EsilNode(t,\"operation\");e.setSides(s,i);let r=th"\
"is.parseUntil(t.position),n=null;null!==r&&(e.children.push(r"\
"),this.nodes.push(r),null!==(n=this.parseUntil(r.token.positi"\
"on+1)))&&(e.children.push(n),this.nodes.push(n)),this.nodes.p"\
"ush(e),this.root.children.push(e),null!==n&&(this.cur=n.token"\
".position)}return!0;case\"-\":if(!(2<=this.stack.length))throw "\
"new Error(\"Stack needs more items\");{const s=this.stack.pop()"\
",i=this.stack.pop(),e=new EsilNode(t,\"operation\");e.setSides("\
"s,i),this.stack.length,this.stack.push(e),this.nodes.push(e)}"\
"return!0;case\"<\":case\">\":case\"^\":case\"&\":case\"|\":case\"+\":case"\
"\"*\":case\"/\":case\">>=\":case\"<<=\":case\">>>=\":case\"<<<=\":case\">>"\
">>=\":case\"<<<<=\":if(!(2<=this.stack.length))throw new Error(\""\
"Stack needs more items\");{const s=this.stack.pop(),i=this.sta"\
"ck.pop(),e=new EsilNode(t,\"operation\");e.setSides(s,i),this.s"\
"tack.length,this.stack.push(e),this.nodes.push(e)}return!0;ca"\
"se\"=\":case\":=\":case\"-=\":case\"+=\":case\"==\":case\"=[1]\":case\"=[2"\
"]\":case\"=[4]\":case\"=[8]\":if(!(2<=this.stack.length))throw new"\
" Error(\"Stack needs more items\");{const s=this.stack.pop(),i="\
"this.stack.pop(),e=new EsilNode(t,\"operation\");e.setSides(s,i"\
"),0===this.stack.length&&this.root.children.push(e),this.node"\
"s.push(e)}return!0}return!1}};\n";

View File

@ -1,6 +1,6 @@
// r2papi main file
Object.defineProperty(G, "__esModule", { value: true });
G.Base64 = G.NativePointer = G.R2Papi = void 0;
G.Base64 = G.NativePointer = G.R2Papi = G.Assembler = void 0;
const shell_js_1 = G;//"./shell.js");
;
;
@ -10,6 +10,49 @@ const shell_js_1 = G;//"./shell.js");
;
;
;
class Assembler {
constructor(r2) {
this.program = "";
this.labels = {};
this.endian = false;
this.pc = 0;
this.r2 = null;
this.r2 = r2;
this.program = '';
this.labels = {};
}
setProgramCounter(pc) {
this.pc = pc;
}
setEndian(big) {
this.endian = big;
}
toString() {
return this.program;
}
append(x) {
this.pc += x.length / 2;
this.program += x;
}
// api
label(s) {
const pos = this.pc; // this.#program.length / 4;
this.labels[s] = this.pc;
return pos;
}
asm(s) {
let hex = this.r2.cmd('""pa ' + s).trim();
if (hex.length < 16) {
// ok
}
else {
hex = "____";
console.error("Invalid instruction: " + s);
}
this.append(hex);
}
}
G.Assembler = Assembler;
class R2Papi {
constructor(r2) {
this.r2 = r2;

View File

@ -18,306 +18,306 @@ static const char *const js_repl_qjs = "" \
"\",keyword:\"magenta\",function:\"yellow\",type:\"magenta\",identifi"\
"er:\"green\",error:\"red\",result:\"bright_white\",error_msg:\"brigh"\
"t_red\"};const history=[];let clip_board=\"\",prec,expBits,log2_"\
"10,pstate=\"\",prompt=\"\",plen=0,ps1;ps1=config_numcalc?\"> \":\"qj"\
"s> \";const ps2=\" ... \",utf8=!0;let show_time=!1,show_colors=!"\
"0,eval_time=0,mexpr=\"\",level=0,cmd=\"\",cursor_pos=0,last_cmd=\""\
"\",last_cursor_pos=0,history_index,this_fun,last_fun,quote_fla"\
"g=!1,utf8_state=0,utf8_val=0,term_fd,term_read_buf,term_width"\
",term_cursor_x=0;function termInit(){for(term_fd=0,(term_widt"\
"h=+r2cmd(\"?vi $c\"))<1&&(term_width=80),term_read_buf=new Uint"\
"8Array(64),cmd_start(),running=!0;running;)try{term_read_hand"\
"ler(),flush()}catch(e){console.error(e)}}function term_read_h"\
"andler(){var e=os.read(term_fd,term_read_buf.buffer,0,term_re"\
"ad_buf.length);for(let r=0;r<e;r++)handle_byte(term_read_buf["\
"r])}function handle_byte(e){utf8?0!==utf8_state&&128<=e&&e<19"\
"2?(utf8_val=utf8_val<<6|63&e,0==--utf8_state&&handle_char(utf"\
"8_val)):192<=e&&e<248?(utf8_state=1+(224<=e)+(240<=e),utf8_va"\
"l=e&(1<<6-utf8_state)-1):(utf8_state=0,handle_char(e)):handle"\
"_char(e)}function is_alpha(e){return\"string\"==typeof e&&(\"A\"<"\
"=e&&e<=\"Z\"||\"a\"<=e&&e<=\"z\")}function is_digit(e){return\"strin"\
"g\"==typeof e&&\"0\"<=e&&e<=\"9\"}function is_word(e){return\"strin"\
"g\"==typeof e&&(is_alpha(e)||is_digit(e)||\"_\"===e||\"$\"===e)}fu"\
"nction ucs_length(e){let r,t,n;var o=e.length;for(r=0,n=0;n<o"\
";n++)((t=e.charCodeAt(n))<56320||57344<=t)&&r++;return r}func"\
"tion is_trailing_surrogate(e){if(\"string\"==typeof e)return 56"\
"320<=(e=e.codePointAt(0))&&e<57344}function is_balanced(e,r){"\
"switch(e+r){case\"()\":case\"[]\":case\"{}\":return 1}}function pri"\
"nt_color_text(e,r,t){let n,o;for(o=r;o<e.length;){const r=t[n"\
"=o];for(;++o<e.length&&t[o]===r;);write(colors[styles[r]||\"de"\
"fault\"]),write(e.substring(n,o)),write(colors.none)}}function"\
" print_csi(e,r){write(\"""\x1b""[\"+(1!==e?e:\"\")+r)}function move_c"\
"ursor(e){let r;if(0<e)for(;0<e;)term_cursor_x===term_width-1?"\
"(write(\"\\n\"),term_cursor_x=0,e--):(print_csi(r=Math.min(term_"\
"width-1-term_cursor_x,e),\"C\"),e-=r,term_cursor_x+=r);else for"\
"(e=-e;0<e;)0===term_cursor_x?(print_csi(1,\"A\"),print_csi(term"\
"_width-1,\"C\"),e--,term_cursor_x=term_width-1):(print_csi(r=Ma"\
"th.min(e,term_cursor_x),\"D\"),e-=r,term_cursor_x-=r)}function "\
"update(){var e;cmd!==last_cmd&&(show_colors||last_cmd.substri"\
"ng(0,last_cursor_pos)!==cmd.substring(0,last_cursor_pos)?(mov"\
"e_cursor(-ucs_length(last_cmd.substring(0,last_cursor_pos))),"\
"show_colors?print_color_text(e=mexpr?mexpr+\"\\n\"+cmd:cmd,e.len"\
"gth-cmd.length,colorize_js(e)[2]):write(cmd)):write(cmd.subst"\
"ring(last_cursor_pos)),0==(term_cursor_x=(term_cursor_x+ucs_l"\
"ength(cmd))%term_width)&&write(\" \\b\"),write(\"""\x1b""[J\"),last_cm"\
"d=cmd,last_cursor_pos=cmd.length),cursor_pos>last_cursor_pos?"\
"move_cursor(ucs_length(cmd.substring(last_cursor_pos,cursor_p"\
"os))):cursor_pos<last_cursor_pos&&move_cursor(-ucs_length(cmd"\
".substring(cursor_pos,last_cursor_pos))),last_cursor_pos=curs"\
"or_pos,flush()}function insert(e){e&&(cmd=cmd.substring(0,cur"\
"sor_pos)+e+cmd.substring(cursor_pos),cursor_pos+=e.length)}fu"\
"nction quoted_insert(){quote_flag=!0}function abort(){return "\
"cmd=\"\",cursor_pos=0,-2}function alert(){}function beginning_o"\
"f_line(){cursor_pos=0}function end_of_line(){cursor_pos=cmd.l"\
"ength}function forward_char(){if(cursor_pos<cmd.length)for(cu"\
"rsor_pos++;is_trailing_surrogate(cmd.charAt(cursor_pos));)cur"\
"sor_pos++}function backward_char(){if(0<cursor_pos)for(cursor"\
"_pos--;is_trailing_surrogate(cmd.charAt(cursor_pos));)cursor_"\
"pos--}function skip_word_forward(e){for(;e<cmd.length&&!is_wo"\
"rd(cmd.charAt(e));)e++;for(;e<cmd.length&&is_word(cmd.charAt("\
"e));)e++;return e}function skip_word_backward(e){for(;0<e&&!i"\
"s_word(cmd.charAt(e-1));)e--;for(;0<e&&is_word(cmd.charAt(e-1"\
"));)e--;return e}function forward_word(){cursor_pos=skip_word"\
"_forward(cursor_pos)}function backward_word(){cursor_pos=skip"\
"_word_backward(cursor_pos)}function accept_line(){return writ"\
"e(\"\\n\"),history_add(cmd),-1}function history_add(e){e&&histor"\
"y.push(e),history_index=history.length}function previous_hist"\
"ory(){0<history_index&&(history_index===history.length&&histo"\
"ry.push(cmd),history_index--,cmd=history[history_index],curso"\
"r_pos=cmd.length)}function next_history(){history_index<histo"\
"ry.length-1&&(history_index++,cmd=history[history_index],curs"\
"or_pos=cmd.length)}function history_search(e){var r=cursor_po"\
"s;for(let n=1;n<=history.length;n++){var t=(history.length+n*"\
"e+history_index)%history.length;if(history[t].substring(0,r)="\
"==cmd.substring(0,r))return history_index=t,void(cmd=history["\
"t])}}function history_search_backward(){return history_search"\
"(-1)}function history_search_forward(){return history_search("\
"1)}function delete_char_dir(e){let r,t;if(r=cursor_pos,e<0)fo"\
"r(r--;is_trailing_surrogate(cmd.charAt(r));)r--;for(t=r+1;is_"\
"trailing_surrogate(cmd.charAt(t));)t++;0<=r&&r<cmd.length&&(l"\
"ast_fun===kill_region?kill_region(r,t,e):(cmd=cmd.substring(0"\
",r)+cmd.substring(t),cursor_pos=r))}function delete_char(){de"\
"lete_char_dir(1)}function control_d(){if(0===cmd.length)retur"\
"n write(\"\\n\"),running=!1,-3;delete_char_dir(1)}function backw"\
"ard_delete_char(){delete_char_dir(-1)}function transpose_char"\
"s(){let e=cursor_pos;1<cmd.length&&0<e&&(e===cmd.length&&e--,"\
"cmd=cmd.substring(0,e-1)+cmd.substring(e,e+1)+cmd.substring(e"\
"-1,e)+cmd.substring(e+1),cursor_pos=e+1)}function transpose_w"\
"ords(){var e=skip_word_backward(cursor_pos),r=skip_word_forwa"\
"rd(e),t=skip_word_forward(cursor_pos),n=skip_word_backward(t)"\
";e<r&&r<=cursor_pos&&cursor_pos<=n&&n<t&&(cmd=cmd.substring(0"\
",e)+cmd.substring(n,t)+cmd.substring(r,n)+cmd.substring(e,r),"\
"cursor_pos=t)}function upcase_word(){var e=skip_word_forward("\
"cursor_pos);cmd=cmd.substring(0,cursor_pos)+cmd.substring(cur"\
"sor_pos,e).toUpperCase()+cmd.substring(e)}function downcase_w"\
"ord(){var e=skip_word_forward(cursor_pos);cmd=cmd.substring(0"\
",cursor_pos)+cmd.substring(cursor_pos,e).toLowerCase()+cmd.su"\
"bstring(e)}function kill_region(e,r,t){var n=cmd.substring(e,"\
"r);last_fun!==kill_region?clip_board=n:t<0?clip_board=n+clip_"\
"board:clip_board+=n,cmd=cmd.substring(0,e)+cmd.substring(r),c"\
"ursor_pos>r?cursor_pos-=r-e:cursor_pos>e&&(cursor_pos=e),this"\
"_fun=kill_region}function kill_line(){kill_region(cursor_pos,"\
"cmd.length,1)}function backward_kill_line(){kill_region(0,cur"\
"sor_pos,-1)}function kill_word(){kill_region(cursor_pos,skip_"\
"word_forward(cursor_pos),1)}function backward_kill_word(){kil"\
"l_region(skip_word_backward(cursor_pos),cursor_pos,-1)}functi"\
"on yank(){insert(clip_board)}function control_c(){console.log"\
"(\"^C\"),reset(),readline_print_prompt()}function reset(){cmd=\""\
"\",cursor_pos=0}function get_context_word(e,r){let t=\"\";for(;0"\
"<r&&is_word(e[r-1]);)t=e[--r]+t;return t}function get_context"\
"_object(line,pos){let obj,base,c;if(pos<=0||0<=\" ~!%^&*(-+={["\
"|:;,<>?/\".indexOf(line[pos-1]))return g;if(2<=pos&&\".\"===line"\
"[pos-1])switch(pos--,obj={},c=line[pos-1]){case\"'\":case'\"':re"\
"turn\"a\";case\"]\":return[];case\"}\":return{};case\"/\":return/ /;d"\
"efault:return is_word(c)?(base=get_context_word(line,pos),[\"t"\
"rue\",\"false\",\"null\",\"this\"].includes(base)||!isNaN(+base)?eva"\
"l(base):(obj=get_context_object(line,pos-base.length),null==o"\
"bj?obj:obj===g&&void 0===obj[base]?eval(base):obj[base])):{}}"\
"}function get_completions(e,r){let t,n,o;var i=get_context_wo"\
"rd(e,r),s=[];for(n=0,t=e=get_context_object(e,r-i.length);n<1"\
"0&&null!=t;n++){const e=Object.getOwnPropertyNames(t);for(o=0"\
";o<e.length;o++){const r=e[o];\"string\"==typeof r&&\"\"+ +r!==r&"\
"&r.startsWith(i)&&s.push(r)}t=Object.getPrototypeOf(t)}if(1<s"\
".length){for(s.sort((function(e,r){if(e[0]!==r[0]){if(\"_\"===e"\
"[0])return 1;if(\"_\"===r[0])return-1}return e<r?-1:r<e?1:0})),"\
"n=o=1;n<s.length;n++)s[n]!==s[n-1]&&(s[o++]=s[n]);s.length=o}"\
"return{tab:s,pos:i.length,ctx:e}}function completion(){let e,"\
"r,t,n,o,i,s,c,a,l;var _=get_completions(cmd,cursor_pos),u=_.t"\
"ab;if(0!==u.length){for(e=u[0],n=e.length,r=1;r<u.length;r++)"\
"for(o=u[r],t=0;t<n;t++)if(o[t]!==e[t]){n=t;break}for(r=_.pos;"\
"r<n;r++)insert(e[r]);if(last_fun===completion&&1===u.length){"\
"const e=_.ctx[u[0]];\"function\"==typeof e?(insert(\"(\"),0===e.l"\
"ength&&insert(\")\")):\"object\"==typeof e&&insert(\".\")}if(last_f"\
"un===completion&&2<=u.length){for(i=0,r=0;r<u.length;r++)i=Ma"\
"th.max(i,u[r].length);for(i+=2,c=Math.max(1,Math.floor((term_"\
"width+1)/i)),l=Math.ceil(u.length/c),write(\"\\n\"),a=0;a<l;a++)"\
"{for(s=0;s<c&&!((r=s*l+a)>=u.length);s++)e=u[r],s!==c-1&&(e=e"\
".padEnd(i)),write(e);write(\"\\n\")}readline_print_prompt()}}}co"\
"nst commands={\"""\x01""\":beginning_of_line,\"""\x02""\":backward_char,\""\
"""\x03""\":control_c,\"""\x04""\":control_d,\"""\x05""\":end_of_line,\"""\x06""\":fo"\
"rward_char,\"""\x07""\":abort,\"\\b\":backward_delete_char,\"\\t\":comple"\
"tion,\"\\n\":accept_line,\"\\v\":kill_line,\"\\r\":accept_line,\"""\x0e""\":"\
"next_history,\"""\x10""\":previous_history,\"""\x11""\":quoted_insert,\"""\x12"""\
"\":alert,\"""\x13""\":alert,\"""\x14""\":transpose_chars,\"""\x17""\":backward_k"\
"ill_word,\"""\x18""\":reset,\"""\x19""\":yank,\"""\x1b""OA\":previous_history,\""\
"""\x1b""OB\":next_history,\"""\x1b""OC\":forward_char,\"""\x1b""OD\":backward_"\
"char,\"""\x1b""OF\":forward_word,\"""\x1b""OH\":backward_word,\"""\x1b""[1;5C\""\
":forward_word,\"""\x1b""[1;5D\":backward_word,\"""\x1b""[1~\":beginning_o"\
"f_line,\"""\x1b""[3~\":delete_char,\"""\x1b""[4~\":end_of_line,\"""\x1b""[5~\":"\
"history_search_backward,\"""\x1b""[6~\":history_search_forward,\"""\x1b"""\
"[A\":previous_history,\"""\x1b""[B\":next_history,\"""\x1b""[C\":forward_c"\
"har,\"""\x1b""[D\":backward_char,\"""\x1b""[F\":end_of_line,\"""\x1b""[H\":begi"\
"nning_of_line,\"""\x1b""""\x7f""\":backward_kill_word,\"""\x1b""b\":backward_"\
"word,\"""\x1b""d\":kill_word,\"""\x1b""f\":forward_word,\"""\x1b""k\":backward_"\
"kill_line,\"""\x1b""l\":downcase_word,\"""\x1b""t\":transpose_words,\"""\x1b"""\
"u\":upcase_word,\"""\x7f""\":backward_delete_char};function dupstr(e"\
",r){let t=\"\";for(;0<r--;)t+=e;return t}let readline_keys,read"\
"line_state,readline_cb;function readline_print_prompt(){write"\
"(prompt),term_cursor_x=ucs_length(prompt)%term_width,last_cmd"\
"=\"\",last_cursor_pos=0}function readline_start(e,r){if(cmd=e||"\
"\"\",cursor_pos=cmd.length,history_index=history.length,readlin"\
"e_cb=r,prompt=pstate,mexpr)prompt=(prompt+=dupstr(\" \",plen-pr"\
"ompt.length))+ps2;else{if(show_time){let e=Math.round(eval_ti"\
"me)+\" \";eval_time=0,e=dupstr(\"0\",5-e.length)+e,prompt+=e.subs"\
"tring(0,e.length-4)+\".\"+e.substring(e.length-4)}plen=prompt.l"\
"ength,show_colors&&(prompt+=colors.yellow),prompt+=ps1,show_c"\
"olors&&(prompt+=colors.none)}readline_print_prompt(),update()"\
",readline_state=0}function handle_char(e){var r=String.fromCo"\
"dePoint(e);switch(readline_state){case 0:\"""\x1b""\"===r?(readline"\
"_keys=r,readline_state=1):handle_key(r);break;case 1:readline"\
"_keys+=r,readline_state=\"[\"===r?2:\"O\"===r?3:(handle_key(readl"\
"ine_keys),0);break;case 2:readline_keys+=r,\";\"===r||\"0\"<=r&&r"\
"<=\"9\"||(handle_key(readline_keys),readline_state=0);break;cas"\
"e 3:handle_key(readline_keys+=r),readline_state=0}}function h"\
"andle_key(e){var r;if(quote_flag)1===ucs_length(e)&&insert(e)"\
",quote_flag=!1;else if(r=commands[e]){switch((this_fun=r)(e))"\
"{case-1:return readline_cb(cmd);case-2:return readline_cb(nul"\
"l);case-3:return}last_fun=this_fun}else 1===ucs_length(e)&&\" "\
"\"<=e?(insert(e),last_fun=insert):alert();cursor_pos=cursor_po"\
"s<0?0:cursor_pos>cmd.length?cmd.length:cursor_pos,update()}le"\
"t hex_mode=!1,eval_mode=\"std\";function number_to_string(e,r){"\
"if(isFinite(e)){let t;return 0===e?t=1/e<0?\"-0\":\"0\":16===r&&e"\
"===Math.floor(e)?(t=e<0?(e=-e,\"-\"):\"\",t+=\"0x\"+e.toString(16))"\
":t=e.toString(),t}return e.toString()}function bigfloat_to_st"\
"ring(e,r){let t;return BigFloat.isFinite(e)?(0===e?t=1/e<0?\"-"\
"0\":\"0\":16===r?(t=e<0?(e=-e,\"-\"):\"\",t+=\"0x\"+e.toString(16)):t="\
"e.toString(),\"bigfloat\"==typeof e&&\"math\"!==eval_mode?t+=\"l\":"\
"\"std\"!==eval_mode&&t.indexOf(\".\")<0&&(16===r&&t.indexOf(\"p\")<"\
"0||10===r&&t.indexOf(\"e\")<0)&&(t+=\".0\"),t):\"math\"!==eval_mode"\
"?\"BigFloat(\"+e.toString()+\")\":e.toString()}function bigint_to"\
"_string(e,r){let t;return 16===r?(t=e<0?(e=-e,\"-\"):\"\",t+=\"0x\""\
"+e.toString(16)):t=e.toString(),\"std\"===eval_mode&&(t+=\"n\"),t"\
"}function print(e){const r=[];!function e(t){let n,o,i,s,c;va"\
"r a=typeof t;if(\"object\"==a)if(null===t)write(t);else if(0<=r"\
".indexOf(t))write(\"[circular]\");else if(has_jscalc&&(t instan"\
"ceof Fraction||t instanceof Complex||t instanceof Mod||t inst"\
"anceof Polynomial||t instanceof PolyMod||t instanceof Rationa"\
"lFunction||t instanceof Series))write(t.toString());else{if(r"\
".push(t),Array.isArray(t)){for(n=t.length,write(\"[ \"),o=0;o<n"\
";o++)if(0!==o&&write(\", \"),o in t?e(t[o]):write(\"<empty>\"),20"\
"<o){write(\"...\");break}write(\" ]\")}else if(\"RegExp\"===Object."\
"__getClass(t))write(t.toString());else{for(i=Object.keys(t),n"\
"=i.length,write(\"{ \"),o=0;o<n;o++)0!==o&&write(\", \"),s=i[o],w"\
"rite(s,\": \"),e(t[s]);write(\" }\")}r.pop(t)}else\"string\"==a?(79"\
"<(c=t.__quote()).length&&(c=c.substring(0,75)+'...\"'),write(c"\
")):\"number\"==a?write(number_to_string(t,hex_mode?16:10)):\"big"\
"int\"==a?write(bigint_to_string(t,hex_mode?16:10)):\"bigfloat\"="\
"=a?write(bigfloat_to_string(t,hex_mode?16:10)):\"bigdecimal\"=="\
"a?write(t.toString()+\"m\"):\"symbol\"==a?write(String(t)):\"funct"\
"ion\"==a?write(\"function \"+t.name+\"()\"):write(t)}(e)}function "\
"extract_directive(e){let r;if(\"\\\\\"!==e[0])return\"\";for(r=1;r<"\
"e.length&&is_alpha(e[r]);r++);return e.substring(1,r)}functio"\
"n handle_directive(e,r){let t,n,o;if(\"h\"===e||\"?\"===e||\"help\""\
"===e)help();else{if(\"load\"===e){let t=r.substring(e.length+1)"\
".trim();return t.lastIndexOf(\".\")<=t.lastIndexOf(\"/\")&&(t+=\"."\
"js\"),0}if(\"x\"===e)hex_mode=!0;else if(\"d\"===e)hex_mode=!1;els"\
"e if(\"t\"===e)show_time=!show_time;else{if(has_bignum&&\"p\"===e"\
"){if(1===(t=r.substring(e.length+1).trim().split(\" \")).length"\
"&&\"\"===t[0])write(\"BigFloat precision=\"+prec+\" bits (~\"+Math."\
"floor(prec/log2_10)+\" digits), exponent size=\"+expBits+\" bits"\
"\\n\");else if(\"f16\"===t[0])prec=11,expBits=5;else if(\"f32\"===t"\
"[0])prec=24,expBits=8;else if(\"f64\"===t[0])prec=53,expBits=11"\
";else if(\"f128\"===t[0])prec=113,expBits=15;else{if(n=parseInt"\
"(t[0]),o=2<=t.length?parseInt(t[1]):BigFloatEnv.expBitsMax,Nu"\
"mber.isNaN(n)||n<BigFloatEnv.precMin||n>BigFloatEnv.precMax)r"\
"eturn write(\"Invalid precision\\n\"),0;if(Number.isNaN(o)||o<Bi"\
"gFloatEnv.expBitsMin||o>BigFloatEnv.expBitsMax)return write(\""\
"Invalid exponent bits\\n\"),0;prec=n,expBits=o}return}if(has_bi"\
"gnum&&\"digits\"===e)return t=r.substring(e.length+1).trim(),(n"\
"=Math.ceil(parseFloat(t)*log2_10))<BigFloatEnv.precMin||n>Big"\
"FloatEnv.precMax?write(\"Invalid precision\\n\"):(prec=n,expBits"\
"=BigFloatEnv.expBitsMax),0;if(has_bignum&&\"mode\"===e)return\"\""\
"===(t=r.substring(e.length+1).trim())?write(\"Running mode=\"+e"\
"val_mode+\"\\n\"):\"std\"===t||\"math\"===t?eval_mode=t:write(\"Inval"\
"id mode\\n\"),0;if(\"clear\"===e)write(\"""\x1b""[H""\x1b""[J\");else if(\"c"\
"\"===e)show_colors=!show_colors;else{if(\"q\"===e)return running"\
"=!1,1;if(has_jscalc&&\"a\"===e)algebraicMode=!0;else{if(!has_js"\
"calc||\"n\"!==e)return write(\"Unknown directive: \"+e+\"\\n\"),0;al"\
"gebraicMode=!1}}}}return 1}function help(){function e(e){retu"\
"rn e?\"*\":\" \"}write(\"\\\\h this help\\n\\\\x \"+e(h"\
"ex_mode)+\"hexadecimal number display\\n\\\\c toggle col"\
"ors\\n\\\\d \"+e(!hex_mode)+\"decimal number display\\n\\\\cl"\
"ear clear the terminal\\n\"),has_jscalc&&write(\"\\\\a "\
" \"+e(algebraicMode)+\"algebraic mode\\n\\\\n \"+e(!algebr"\
"aicMode)+\"numeric mode\\n\"),has_bignum&&(write(\"\\\\p [m [e]] s"\
"et the BigFloat precision to 'm' bits\\n\\\\digits n set the B"\
"igFloat precision to 'ceil(n*log2(10))' bits\\n\"),has_jscalc||"\
"write(\"\\\\mode [std|math] change the running mode (current = \""\
"+eval_mode+\")\\n\")),config_numcalc||write(\"\\\\q exit\\n"\
"\")}function eval_and_print(expr){let result;try{\"math\"===eval"\
"_mode&&(expr='\"use math\"; void 0;'+expr);const now=(new Date)"\
".getTime();result=eval(expr),eval_time=(new Date).getTime()-n"\
"ow,write(colors[styles.result]),print(result),write(\"\\n\"),wri"\
"te(colors.none),g._=result}catch(e){show_colors&&write(colors"\
"[styles.error_msg]),e instanceof Error?(console.log(e),e.stac"\
"k&&write(e.stack)):write(\"Throw: \"),show_colors&&write(colors"\
".none)}}function cmd_start(){var e;config_numcalc||(e=has_jsc"\
"alc?\"QJSCalc\":\"QuickJS\",console.log(e,'- Type \"\\\\h\" for help'"\
")),has_bignum&&(log2_10=Math.log(10)/Math.log(2),prec=113,exp"\
"Bits=15,has_jscalc)&&(eval_mode=\"math\",g.algebraicMode=config"\
"_numcalc),cmd_readline_start()}function cmd_readline_start(){"\
"try{readline_start(dupstr(\" \",level),readline_handle_cmd)}"\
"catch(e){console.error(\"ERROR\",e)}}function readline_handle_c"\
"md(e){handle_cmd(e),os.pending(),cmd_readline_start()}functio"\
"n handle_cmd(e){if(null===e)return\"\";if(\"?\"===e||\"h\"===e)retu"\
"rn help();var r=extract_directive(e);if(0<r.length){if(!handl"\
"e_directive(r,e))return;e=e.substring(r.length+1)}\"\"!==e&&(r="\
"colorize_js(e=mexpr?mexpr+\"\\n\"+e:e),pstate=r[0],level=r[1],ps"\
"tate?mexpr=e:(mexpr=\"\",has_bignum?BigFloatEnv.setPrec(eval_an"\
"d_print.bind(null,e),prec,expBits):eval_and_print(e),level=0)"\
")}function colorize_js(e){let r,t,n;const o=e.length;let i,s="\
"\"\",c=0,a=1;const l=[];function _(e){s+=e}function u(){return "\
"s.substring(s.length-1)}function d(){var e=u();return s=s.sub"\
"string(0,s.length-1),e}function f(e,r){for(;l.length<e;)l.pus"\
"h(\"default\");for(;l.length<r;)l.push(i)}for(r=0;r<o;){switch("\
"i=null,n=r,t=e[r++]){case\" \":case\"\\t\":case\"\\r\":case\"\\n\":conti"\
"nue;case\"+\":case\"-\":if(r<o&&e[r]===t){r++;continue}a=1;contin"\
"ue;case\"/\":if(r<o&&\"*\"===e[r]){for(i=\"comment\",_(\"/\"),r++;r<o"\
"-1;r++)if(\"*\"===e[r]&&\"/\"===e[r+1]){r+=2,d();break}break}if(r"\
"<o&&\"/\"===e[r]){for(i=\"comment\",r++;r<o&&\"\\n\"!==e[r];r++);bre"\
"ak}if(a){for(i=\"regex\",_(\"/\");r<o;)if(\"\\n\"!==(t=e[r++]))if(\"\\"\
"\\\"!==t)if(\"[\"!==u())if(\"[\"!==t){if(\"/\"===t){for(d();r<o&&is_w"\
"ord(e[r]);)r++;break}}else _(\"[\"),\"[\"!==e[r]&&\"]\"!==e[r]||r++"\
";else\"]\"===t&&d();else r<o&&r++;else i=\"error\";a=0;break}a=1;"\
"continue;case\"'\":case'\"':case\"`\":(function(n){for(i=\"string\","\
"_(n);r<o;)if(\"\\n\"!==(t=e[r++])){if(\"\\\\\"===t){if(r>=o)break;r+"\
"+}else if(t===n){d();break}}else i=\"error\"})(t),a=0;break;cas"\
"e\"(\":case\"[\":case\"{\":a=1,c++,_(t);continue;case\")\":case\"]\":ca"\
"se\"}\":if((a=0)<c&&is_balanced(u(),t)){c--,d();continue}i=\"err"\
"or\";break;default:if(is_digit(t)){for(i=\"number\";r<o&&(is_wor"\
"d(e[r])||\".\"===e[r]&&(r===o-1||\".\"!==e[r+1]));)r++;a=0}else{i"\
"f(!is_word(t)&&\"$\"!==t){a=1;continue}!function(){for(a=1;r<o&"\
"&is_word(e[r]);)r++;var t=\"|\"+e.substring(n,r)+\"|\";if(0<=\"|br"\
"eak|case|catch|continue|debugger|default|delete|do|else|final"\
"ly|for|function|if|in|instanceof|new|return|switch|this|throw"\
"|try|typeof|while|with|class|const|enum|import|export|extends"\
"|super|implements|interface|let|package|private|protected|pub"\
"lic|static|yield|undefined|null|true|false|Infinity|NaN|eval|"\
"arguments|await|\".indexOf(t))return i=\"keyword\",0<=\"|this|sup"\
"er|undefined|null|true|false|Infinity|NaN|arguments|\".indexOf"\
"(t)&&(a=0);let s=r;for(;s<o&&\" \"===e[s];)s++;s<o&&\"(\"===e[s]?"\
"i=\"function\":0<=\"|void|var|\".indexOf(t)?i=\"type\":(i=\"identifi"\
"er\",a=0)}()}}i&&f(n,r)}return f(o,o),[s,c,l]}config_numcalc&&"\
"(g.execCmd=function(e){switch(e){case\"dec\":hex_mode=!1;break;"\
"case\"hex\":hex_mode=!0;break;case\"num\":algebraicMode=!1;break;"\
"case\"alg\":algebraicMode=!0}});try{termInit()}catch(e){console"\
".error(e)}}(globalThis)}));\n";
"10,pstate=\"\",prompt=\"\",plen=0,ps1;ps1=config_numcalc?\"> \":\"[r"\
"2js]> \";const ps2=\" ... \",utf8=!0;let show_time=!1,show_color"\
"s=!0,eval_time=0,mexpr=\"\",level=0,cmd=\"\",cursor_pos=0,last_cm"\
"d=\"\",last_cursor_pos=0,history_index,this_fun,last_fun,quote_"\
"flag=!1,utf8_state=0,utf8_val=0,term_fd,term_read_buf,term_wi"\
"dth,term_cursor_x=0;function termInit(){for(term_fd=0,(term_w"\
"idth=+r2cmd(\"?vi $c\"))<1&&(term_width=80),term_read_buf=new U"\
"int8Array(64),cmd_start(),running=!0;running;)try{term_read_h"\
"andler(),flush()}catch(e){console.error(e)}}function term_rea"\
"d_handler(){var e=os.read(term_fd,term_read_buf.buffer,0,term"\
"_read_buf.length);for(let r=0;r<e;r++)handle_byte(term_read_b"\
"uf[r])}function handle_byte(e){utf8?0!==utf8_state&&128<=e&&e"\
"<192?(utf8_val=utf8_val<<6|63&e,0==--utf8_state&&handle_char("\
"utf8_val)):192<=e&&e<248?(utf8_state=1+(224<=e)+(240<=e),utf8"\
"_val=e&(1<<6-utf8_state)-1):(utf8_state=0,handle_char(e)):han"\
"dle_char(e)}function is_alpha(e){return\"string\"==typeof e&&(\""\
"A\"<=e&&e<=\"Z\"||\"a\"<=e&&e<=\"z\")}function is_digit(e){return\"st"\
"ring\"==typeof e&&\"0\"<=e&&e<=\"9\"}function is_word(e){return\"st"\
"ring\"==typeof e&&(is_alpha(e)||is_digit(e)||\"_\"===e||\"$\"===e)"\
"}function ucs_length(e){let r,t,n;var o=e.length;for(r=0,n=0;"\
"n<o;n++)((t=e.charCodeAt(n))<56320||57344<=t)&&r++;return r}f"\
"unction is_trailing_surrogate(e){if(\"string\"==typeof e)return"\
" 56320<=(e=e.codePointAt(0))&&e<57344}function is_balanced(e,"\
"r){switch(e+r){case\"()\":case\"[]\":case\"{}\":return 1}}function "\
"print_color_text(e,r,t){let n,o;for(o=r;o<e.length;){const r="\
"t[n=o];for(;++o<e.length&&t[o]===r;);write(colors[styles[r]||"\
"\"default\"]),write(e.substring(n,o)),write(colors.none)}}funct"\
"ion print_csi(e,r){write(\"""\x1b""[\"+(1!==e?e:\"\")+r)}function mov"\
"e_cursor(e){let r;if(0<e)for(;0<e;)term_cursor_x===term_width"\
"-1?(write(\"\\n\"),term_cursor_x=0,e--):(print_csi(r=Math.min(te"\
"rm_width-1-term_cursor_x,e),\"C\"),e-=r,term_cursor_x+=r);else "\
"for(e=-e;0<e;)0===term_cursor_x?(print_csi(1,\"A\"),print_csi(t"\
"erm_width-1,\"C\"),e--,term_cursor_x=term_width-1):(print_csi(r"\
"=Math.min(e,term_cursor_x),\"D\"),e-=r,term_cursor_x-=r)}functi"\
"on update(){var e;cmd!==last_cmd&&(show_colors||last_cmd.subs"\
"tring(0,last_cursor_pos)!==cmd.substring(0,last_cursor_pos)?("\
"move_cursor(-ucs_length(last_cmd.substring(0,last_cursor_pos)"\
")),show_colors?print_color_text(e=mexpr?mexpr+\"\\n\"+cmd:cmd,e."\
"length-cmd.length,colorize_js(e)[2]):write(cmd)):write(cmd.su"\
"bstring(last_cursor_pos)),0==(term_cursor_x=(term_cursor_x+uc"\
"s_length(cmd))%term_width)&&write(\" \\b\"),write(\"""\x1b""[J\"),last"\
"_cmd=cmd,last_cursor_pos=cmd.length),cursor_pos>last_cursor_p"\
"os?move_cursor(ucs_length(cmd.substring(last_cursor_pos,curso"\
"r_pos))):cursor_pos<last_cursor_pos&&move_cursor(-ucs_length("\
"cmd.substring(cursor_pos,last_cursor_pos))),last_cursor_pos=c"\
"ursor_pos,flush()}function insert(e){e&&(cmd=cmd.substring(0,"\
"cursor_pos)+e+cmd.substring(cursor_pos),cursor_pos+=e.length)"\
"}function quoted_insert(){quote_flag=!0}function abort(){retu"\
"rn cmd=\"\",cursor_pos=0,-2}function alert(){}function beginnin"\
"g_of_line(){cursor_pos=0}function end_of_line(){cursor_pos=cm"\
"d.length}function forward_char(){if(cursor_pos<cmd.length)for"\
"(cursor_pos++;is_trailing_surrogate(cmd.charAt(cursor_pos));)"\
"cursor_pos++}function backward_char(){if(0<cursor_pos)for(cur"\
"sor_pos--;is_trailing_surrogate(cmd.charAt(cursor_pos));)curs"\
"or_pos--}function skip_word_forward(e){for(;e<cmd.length&&!is"\
"_word(cmd.charAt(e));)e++;for(;e<cmd.length&&is_word(cmd.char"\
"At(e));)e++;return e}function skip_word_backward(e){for(;0<e&"\
"&!is_word(cmd.charAt(e-1));)e--;for(;0<e&&is_word(cmd.charAt("\
"e-1));)e--;return e}function forward_word(){cursor_pos=skip_w"\
"ord_forward(cursor_pos)}function backward_word(){cursor_pos=s"\
"kip_word_backward(cursor_pos)}function accept_line(){return w"\
"rite(\"\\n\"),history_add(cmd),-1}function history_add(e){e&&his"\
"tory.push(e),history_index=history.length}function previous_h"\
"istory(){0<history_index&&(history_index===history.length&&hi"\
"story.push(cmd),history_index--,cmd=history[history_index],cu"\
"rsor_pos=cmd.length)}function next_history(){history_index<hi"\
"story.length-1&&(history_index++,cmd=history[history_index],c"\
"ursor_pos=cmd.length)}function history_search(e){var r=cursor"\
"_pos;for(let n=1;n<=history.length;n++){var t=(history.length"\
"+n*e+history_index)%history.length;if(history[t].substring(0,"\
"r)===cmd.substring(0,r))return history_index=t,void(cmd=histo"\
"ry[t])}}function history_search_backward(){return history_sea"\
"rch(-1)}function history_search_forward(){return history_sear"\
"ch(1)}function delete_char_dir(e){let r,t;if(r=cursor_pos,e<0"\
")for(r--;is_trailing_surrogate(cmd.charAt(r));)r--;for(t=r+1;"\
"is_trailing_surrogate(cmd.charAt(t));)t++;0<=r&&r<cmd.length&"\
"&(last_fun===kill_region?kill_region(r,t,e):(cmd=cmd.substrin"\
"g(0,r)+cmd.substring(t),cursor_pos=r))}function delete_char()"\
"{delete_char_dir(1)}function control_d(){if(0===cmd.length)re"\
"turn write(\"\\n\"),running=!1,-3;delete_char_dir(1)}function ba"\
"ckward_delete_char(){delete_char_dir(-1)}function transpose_c"\
"hars(){let e=cursor_pos;1<cmd.length&&0<e&&(e===cmd.length&&e"\
"--,cmd=cmd.substring(0,e-1)+cmd.substring(e,e+1)+cmd.substrin"\
"g(e-1,e)+cmd.substring(e+1),cursor_pos=e+1)}function transpos"\
"e_words(){var e=skip_word_backward(cursor_pos),r=skip_word_fo"\
"rward(e),t=skip_word_forward(cursor_pos),n=skip_word_backward"\
"(t);e<r&&r<=cursor_pos&&cursor_pos<=n&&n<t&&(cmd=cmd.substrin"\
"g(0,e)+cmd.substring(n,t)+cmd.substring(r,n)+cmd.substring(e,"\
"r),cursor_pos=t)}function upcase_word(){var e=skip_word_forwa"\
"rd(cursor_pos);cmd=cmd.substring(0,cursor_pos)+cmd.substring("\
"cursor_pos,e).toUpperCase()+cmd.substring(e)}function downcas"\
"e_word(){var e=skip_word_forward(cursor_pos);cmd=cmd.substrin"\
"g(0,cursor_pos)+cmd.substring(cursor_pos,e).toLowerCase()+cmd"\
".substring(e)}function kill_region(e,r,t){var n=cmd.substring"\
"(e,r);last_fun!==kill_region?clip_board=n:t<0?clip_board=n+cl"\
"ip_board:clip_board+=n,cmd=cmd.substring(0,e)+cmd.substring(r"\
"),cursor_pos>r?cursor_pos-=r-e:cursor_pos>e&&(cursor_pos=e),t"\
"his_fun=kill_region}function kill_line(){kill_region(cursor_p"\
"os,cmd.length,1)}function backward_kill_line(){kill_region(0,"\
"cursor_pos,-1)}function kill_word(){kill_region(cursor_pos,sk"\
"ip_word_forward(cursor_pos),1)}function backward_kill_word(){"\
"kill_region(skip_word_backward(cursor_pos),cursor_pos,-1)}fun"\
"ction yank(){insert(clip_board)}function control_c(){console."\
"log(\"^C\"),reset(),readline_print_prompt()}function reset(){cm"\
"d=\"\",cursor_pos=0}function get_context_word(e,r){let t=\"\";for"\
"(;0<r&&is_word(e[r-1]);)t=e[--r]+t;return t}function get_cont"\
"ext_object(line,pos){let obj,base,c;if(pos<=0||0<=\" ~!%^&*(-+"\
"={[|:;,<>?/\".indexOf(line[pos-1]))return g;if(2<=pos&&\".\"===l"\
"ine[pos-1])switch(pos--,obj={},c=line[pos-1]){case\"'\":case'\"'"\
":return\"a\";case\"]\":return[];case\"}\":return{};case\"/\":return/ "\
"/;default:return is_word(c)?(base=get_context_word(line,pos),"\
"[\"true\",\"false\",\"null\",\"this\"].includes(base)||!isNaN(+base)?"\
"eval(base):(obj=get_context_object(line,pos-base.length),null"\
"==obj?obj:obj===g&&void 0===obj[base]?eval(base):obj[base])):"\
"{}}}function get_completions(e,r){let t,n,o;var i=get_context"\
"_word(e,r),s=[];for(n=0,t=e=get_context_object(e,r-i.length);"\
"n<10&&null!=t;n++){const e=Object.getOwnPropertyNames(t);for("\
"o=0;o<e.length;o++){const r=e[o];\"string\"==typeof r&&\"\"+ +r!="\
"=r&&r.startsWith(i)&&s.push(r)}t=Object.getPrototypeOf(t)}if("\
"1<s.length){for(s.sort((function(e,r){if(e[0]!==r[0]){if(\"_\"="\
"==e[0])return 1;if(\"_\"===r[0])return-1}return e<r?-1:r<e?1:0}"\
")),n=o=1;n<s.length;n++)s[n]!==s[n-1]&&(s[o++]=s[n]);s.length"\
"=o}return{tab:s,pos:i.length,ctx:e}}function completion(){let"\
" e,r,t,n,o,i,s,c,a,l;var _=get_completions(cmd,cursor_pos),u="\
"_.tab;if(0!==u.length){for(e=u[0],n=e.length,r=1;r<u.length;r"\
"++)for(o=u[r],t=0;t<n;t++)if(o[t]!==e[t]){n=t;break}for(r=_.p"\
"os;r<n;r++)insert(e[r]);if(last_fun===completion&&1===u.lengt"\
"h){const e=_.ctx[u[0]];\"function\"==typeof e?(insert(\"(\"),0==="\
"e.length&&insert(\")\")):\"object\"==typeof e&&insert(\".\")}if(las"\
"t_fun===completion&&2<=u.length){for(i=0,r=0;r<u.length;r++)i"\
"=Math.max(i,u[r].length);for(i+=2,c=Math.max(1,Math.floor((te"\
"rm_width+1)/i)),l=Math.ceil(u.length/c),write(\"\\n\"),a=0;a<l;a"\
"++){for(s=0;s<c&&!((r=s*l+a)>=u.length);s++)e=u[r],s!==c-1&&("\
"e=e.padEnd(i)),write(e);write(\"\\n\")}readline_print_prompt()}}"\
"}const commands={\"""\x01""\":beginning_of_line,\"""\x02""\":backward_cha"\
"r,\"""\x03""\":control_c,\"""\x04""\":control_d,\"""\x05""\":end_of_line,\"""\x06""\""\
":forward_char,\"""\x07""\":abort,\"\\b\":backward_delete_char,\"\\t\":com"\
"pletion,\"\\n\":accept_line,\"\\v\":kill_line,\"\\r\":accept_line,\"""\x0e"""\
"\":next_history,\"""\x10""\":previous_history,\"""\x11""\":quoted_insert,\""\
"""\x12""\":alert,\"""\x13""\":alert,\"""\x14""\":transpose_chars,\"""\x17""\":backwa"\
"rd_kill_word,\"""\x18""\":reset,\"""\x19""\":yank,\"""\x1b""OA\":previous_histo"\
"ry,\"""\x1b""OB\":next_history,\"""\x1b""OC\":forward_char,\"""\x1b""OD\":backw"\
"ard_char,\"""\x1b""OF\":forward_word,\"""\x1b""OH\":backward_word,\"""\x1b""[1"\
";5C\":forward_word,\"""\x1b""[1;5D\":backward_word,\"""\x1b""[1~\":beginni"\
"ng_of_line,\"""\x1b""[3~\":delete_char,\"""\x1b""[4~\":end_of_line,\"""\x1b""["\
"5~\":history_search_backward,\"""\x1b""[6~\":history_search_forward,"\
"\"""\x1b""[A\":previous_history,\"""\x1b""[B\":next_history,\"""\x1b""[C\":forw"\
"ard_char,\"""\x1b""[D\":backward_char,\"""\x1b""[F\":end_of_line,\"""\x1b""[H\""\
":beginning_of_line,\"""\x1b""""\x7f""\":backward_kill_word,\"""\x1b""b\":back"\
"ward_word,\"""\x1b""d\":kill_word,\"""\x1b""f\":forward_word,\"""\x1b""k\":back"\
"ward_kill_line,\"""\x1b""l\":downcase_word,\"""\x1b""t\":transpose_words,"\
"\"""\x1b""u\":upcase_word,\"""\x7f""\":backward_delete_char};function dup"\
"str(e,r){let t=\"\";for(;0<r--;)t+=e;return t}let readline_keys"\
",readline_state,readline_cb;function readline_print_prompt(){"\
"write(prompt),term_cursor_x=ucs_length(prompt)%term_width,las"\
"t_cmd=\"\",last_cursor_pos=0}function readline_start(e,r){if(cm"\
"d=e||\"\",cursor_pos=cmd.length,history_index=history.length,re"\
"adline_cb=r,prompt=pstate,mexpr)prompt=(prompt+=dupstr(\" \",pl"\
"en-prompt.length))+ps2;else{if(show_time){let e=Math.round(ev"\
"al_time)+\" \";eval_time=0,e=dupstr(\"0\",5-e.length)+e,prompt+=e"\
".substring(0,e.length-4)+\".\"+e.substring(e.length-4)}plen=pro"\
"mpt.length,show_colors&&(prompt+=colors.yellow),prompt+=ps1,s"\
"how_colors&&(prompt+=colors.none)}readline_print_prompt(),upd"\
"ate(),readline_state=0}function handle_char(e){var r=String.f"\
"romCodePoint(e);switch(readline_state){case 0:\"""\x1b""\"===r?(rea"\
"dline_keys=r,readline_state=1):handle_key(r);break;case 1:rea"\
"dline_keys+=r,readline_state=\"[\"===r?2:\"O\"===r?3:(handle_key("\
"readline_keys),0);break;case 2:readline_keys+=r,\";\"===r||\"0\"<"\
"=r&&r<=\"9\"||(handle_key(readline_keys),readline_state=0);brea"\
"k;case 3:handle_key(readline_keys+=r),readline_state=0}}funct"\
"ion handle_key(e){var r;if(quote_flag)1===ucs_length(e)&&inse"\
"rt(e),quote_flag=!1;else if(r=commands[e]){switch((this_fun=r"\
")(e)){case-1:return readline_cb(cmd);case-2:return readline_c"\
"b(null);case-3:return}last_fun=this_fun}else 1===ucs_length(e"\
")&&\" \"<=e?(insert(e),last_fun=insert):alert();cursor_pos=curs"\
"or_pos<0?0:cursor_pos>cmd.length?cmd.length:cursor_pos,update"\
"()}let hex_mode=!1,eval_mode=\"std\";function number_to_string("\
"e,r){if(isFinite(e)){let t;return 0===e?t=1/e<0?\"-0\":\"0\":16=="\
"=r&&e===Math.floor(e)?(t=e<0?(e=-e,\"-\"):\"\",t+=\"0x\"+e.toString"\
"(16)):t=e.toString(),t}return e.toString()}function bigfloat_"\
"to_string(e,r){let t;return BigFloat.isFinite(e)?(0===e?t=1/e"\
"<0?\"-0\":\"0\":16===r?(t=e<0?(e=-e,\"-\"):\"\",t+=\"0x\"+e.toString(16"\
")):t=e.toString(),\"bigfloat\"==typeof e&&\"math\"!==eval_mode?t+"\
"=\"l\":\"std\"!==eval_mode&&t.indexOf(\".\")<0&&(16===r&&t.indexOf("\
"\"p\")<0||10===r&&t.indexOf(\"e\")<0)&&(t+=\".0\"),t):\"math\"!==eval"\
"_mode?\"BigFloat(\"+e.toString()+\")\":e.toString()}function bigi"\
"nt_to_string(e,r){let t;return 16===r?(t=e<0?(e=-e,\"-\"):\"\",t+"\
"=\"0x\"+e.toString(16)):t=e.toString(),\"std\"===eval_mode&&(t+=\""\
"n\"),t}function print(e){const r=[];!function e(t){let n,o,i,s"\
",c;var a=typeof t;if(\"object\"==a)if(null===t)write(t);else if"\
"(0<=r.indexOf(t))write(\"[circular]\");else if(has_jscalc&&(t i"\
"nstanceof Fraction||t instanceof Complex||t instanceof Mod||t"\
" instanceof Polynomial||t instanceof PolyMod||t instanceof Ra"\
"tionalFunction||t instanceof Series))write(t.toString());else"\
"{if(r.push(t),Array.isArray(t)){for(n=t.length,write(\"[ \"),o="\
"0;o<n;o++)if(0!==o&&write(\", \"),o in t?e(t[o]):write(\"<empty>"\
"\"),20<o){write(\"...\");break}write(\" ]\")}else if(\"RegExp\"===Ob"\
"ject.__getClass(t))write(t.toString());else{for(i=Object.keys"\
"(t),n=i.length,write(\"{ \"),o=0;o<n;o++)0!==o&&write(\", \"),s=i"\
"[o],write(s,\": \"),e(t[s]);write(\" }\")}r.pop(t)}else\"string\"=="\
"a?(79<(c=t.__quote()).length&&(c=c.substring(0,75)+'...\"'),wr"\
"ite(c)):\"number\"==a?write(number_to_string(t,hex_mode?16:10))"\
":\"bigint\"==a?write(bigint_to_string(t,hex_mode?16:10)):\"bigfl"\
"oat\"==a?write(bigfloat_to_string(t,hex_mode?16:10)):\"bigdecim"\
"al\"==a?write(t.toString()+\"m\"):\"symbol\"==a?write(String(t)):\""\
"function\"==a?write(\"function \"+t.name+\"()\"):write(t)}(e)}func"\
"tion extract_directive(e){let r;if(\"\\\\\"!==e[0])return\"\";for(r"\
"=1;r<e.length&&is_alpha(e[r]);r++);return e.substring(1,r)}fu"\
"nction handle_directive(e,r){let t,n,o;if(\"h\"===e||\"?\"===e||\""\
"help\"===e)help();else{if(\"load\"===e){let t=r.substring(e.leng"\
"th+1).trim();return t.lastIndexOf(\".\")<=t.lastIndexOf(\"/\")&&("\
"t+=\".js\"),0}if(\"x\"===e)hex_mode=!0;else if(\"d\"===e)hex_mode=!"\
"1;else if(\"t\"===e)show_time=!show_time;else{if(has_bignum&&\"p"\
"\"===e){if(1===(t=r.substring(e.length+1).trim().split(\" \")).l"\
"ength&&\"\"===t[0])write(\"BigFloat precision=\"+prec+\" bits (~\"+"\
"Math.floor(prec/log2_10)+\" digits), exponent size=\"+expBits+\""\
" bits\\n\");else if(\"f16\"===t[0])prec=11,expBits=5;else if(\"f32"\
"\"===t[0])prec=24,expBits=8;else if(\"f64\"===t[0])prec=53,expBi"\
"ts=11;else if(\"f128\"===t[0])prec=113,expBits=15;else{if(n=par"\
"seInt(t[0]),o=2<=t.length?parseInt(t[1]):BigFloatEnv.expBitsM"\
"ax,Number.isNaN(n)||n<BigFloatEnv.precMin||n>BigFloatEnv.prec"\
"Max)return write(\"Invalid precision\\n\"),0;if(Number.isNaN(o)|"\
"|o<BigFloatEnv.expBitsMin||o>BigFloatEnv.expBitsMax)return wr"\
"ite(\"Invalid exponent bits\\n\"),0;prec=n,expBits=o}return}if(h"\
"as_bignum&&\"digits\"===e)return t=r.substring(e.length+1).trim"\
"(),(n=Math.ceil(parseFloat(t)*log2_10))<BigFloatEnv.precMin||"\
"n>BigFloatEnv.precMax?write(\"Invalid precision\\n\"):(prec=n,ex"\
"pBits=BigFloatEnv.expBitsMax),0;if(has_bignum&&\"mode\"===e)ret"\
"urn\"\"===(t=r.substring(e.length+1).trim())?write(\"Running mod"\
"e=\"+eval_mode+\"\\n\"):\"std\"===t||\"math\"===t?eval_mode=t:write(\""\
"Invalid mode\\n\"),0;if(\"clear\"===e)write(\"""\x1b""[H""\x1b""[J\");else "\
"if(\"c\"===e)show_colors=!show_colors;else{if(\"q\"===e)return ru"\
"nning=!1,1;if(has_jscalc&&\"a\"===e)algebraicMode=!0;else{if(!h"\
"as_jscalc||\"n\"!==e)return write(\"Unknown directive: \"+e+\"\\n\")"\
",0;algebraicMode=!1}}}}return 1}function help(){function e(e)"\
"{return e?\"*\":\" \"}write(\"\\\\h this help\\n\\\\x "\
"\"+e(hex_mode)+\"hexadecimal number display\\n\\\\c toggl"\
"e colors\\n\\\\d \"+e(!hex_mode)+\"decimal number display\\"\
"n\\\\clear clear the terminal\\n\"),has_jscalc&&write(\"\\\\a "\
" \"+e(algebraicMode)+\"algebraic mode\\n\\\\n \"+e(!a"\
"lgebraicMode)+\"numeric mode\\n\"),has_bignum&&(write(\"\\\\p [m [e"\
"]] set the BigFloat precision to 'm' bits\\n\\\\digits n set "\
"the BigFloat precision to 'ceil(n*log2(10))' bits\\n\"),has_jsc"\
"alc||write(\"\\\\mode [std|math] change the running mode (curren"\
"t = \"+eval_mode+\")\\n\")),config_numcalc||write(\"\\\\q e"\
"xit\\n\")}function eval_and_print(expr){let result;try{\"math\"=="\
"=eval_mode&&(expr='\"use math\"; void 0;'+expr);const now=(new "\
"Date).getTime();result=eval(expr),eval_time=(new Date).getTim"\
"e()-now,write(colors[styles.result]),print(result),write(\"\\n\""\
"),write(colors.none),g._=result}catch(e){show_colors&&write(c"\
"olors[styles.error_msg]),e instanceof Error?(console.log(e),e"\
".stack&&write(e.stack)):write(\"Throw: \"),show_colors&&write(c"\
"olors.none)}}function cmd_start(){var e;config_numcalc||(e=ha"\
"s_jscalc?\"QJSCalc\":\"QuickJS\",console.log(e,'- Type \"\\\\h\" for "\
"help')),has_bignum&&(log2_10=Math.log(10)/Math.log(2),prec=11"\
"3,expBits=15,has_jscalc)&&(eval_mode=\"math\",g.algebraicMode=c"\
"onfig_numcalc),cmd_readline_start()}function cmd_readline_sta"\
"rt(){try{readline_start(dupstr(\" \",level),readline_handle_"\
"cmd)}catch(e){console.error(\"ERROR\",e)}}function readline_han"\
"dle_cmd(e){handle_cmd(e),os.pending(),cmd_readline_start()}fu"\
"nction handle_cmd(e){if(null===e)return\"\";if(\"?\"===e||\"h\"===e"\
")return help();var r=extract_directive(e);if(0<r.length){if(!"\
"handle_directive(r,e))return;e=e.substring(r.length+1)}\"\"!==e"\
"&&(r=colorize_js(e=mexpr?mexpr+\"\\n\"+e:e),pstate=r[0],level=r["\
"1],pstate?mexpr=e:(mexpr=\"\",has_bignum?BigFloatEnv.setPrec(ev"\
"al_and_print.bind(null,e),prec,expBits):eval_and_print(e),lev"\
"el=0))}function colorize_js(e){let r,t,n;const o=e.length;let"\
" i,s=\"\",c=0,a=1;const l=[];function _(e){s+=e}function u(){re"\
"turn s.substring(s.length-1)}function d(){var e=u();return s="\
"s.substring(0,s.length-1),e}function f(e,r){for(;l.length<e;)"\
"l.push(\"default\");for(;l.length<r;)l.push(i)}for(r=0;r<o;){sw"\
"itch(i=null,n=r,t=e[r++]){case\" \":case\"\\t\":case\"\\r\":case\"\\n\":"\
"continue;case\"+\":case\"-\":if(r<o&&e[r]===t){r++;continue}a=1;c"\
"ontinue;case\"/\":if(r<o&&\"*\"===e[r]){for(i=\"comment\",_(\"/\"),r+"\
"+;r<o-1;r++)if(\"*\"===e[r]&&\"/\"===e[r+1]){r+=2,d();break}break"\
"}if(r<o&&\"/\"===e[r]){for(i=\"comment\",r++;r<o&&\"\\n\"!==e[r];r++"\
");break}if(a){for(i=\"regex\",_(\"/\");r<o;)if(\"\\n\"!==(t=e[r++]))"\
"if(\"\\\\\"!==t)if(\"[\"!==u())if(\"[\"!==t){if(\"/\"===t){for(d();r<o&"\
"&is_word(e[r]);)r++;break}}else _(\"[\"),\"[\"!==e[r]&&\"]\"!==e[r]"\
"||r++;else\"]\"===t&&d();else r<o&&r++;else i=\"error\";a=0;break"\
"}a=1;continue;case\"'\":case'\"':case\"`\":(function(n){for(i=\"str"\
"ing\",_(n);r<o;)if(\"\\n\"!==(t=e[r++])){if(\"\\\\\"===t){if(r>=o)bre"\
"ak;r++}else if(t===n){d();break}}else i=\"error\"})(t),a=0;brea"\
"k;case\"(\":case\"[\":case\"{\":a=1,c++,_(t);continue;case\")\":case\""\
"]\":case\"}\":if((a=0)<c&&is_balanced(u(),t)){c--,d();continue}i"\
"=\"error\";break;default:if(is_digit(t)){for(i=\"number\";r<o&&(i"\
"s_word(e[r])||\".\"===e[r]&&(r===o-1||\".\"!==e[r+1]));)r++;a=0}e"\
"lse{if(!is_word(t)&&\"$\"!==t){a=1;continue}!function(){for(a=1"\
";r<o&&is_word(e[r]);)r++;var t=\"|\"+e.substring(n,r)+\"|\";if(0<"\
"=\"|break|case|catch|continue|debugger|default|delete|do|else|"\
"finally|for|function|if|in|instanceof|new|return|switch|this|"\
"throw|try|typeof|while|with|class|const|enum|import|export|ex"\
"tends|super|implements|interface|let|package|private|protecte"\
"d|public|static|yield|undefined|null|true|false|Infinity|NaN|"\
"eval|arguments|await|\".indexOf(t))return i=\"keyword\",0<=\"|thi"\
"s|super|undefined|null|true|false|Infinity|NaN|arguments|\".in"\
"dexOf(t)&&(a=0);let s=r;for(;s<o&&\" \"===e[s];)s++;s<o&&\"(\"==="\
"e[s]?i=\"function\":0<=\"|void|var|\".indexOf(t)?i=\"type\":(i=\"ide"\
"ntifier\",a=0)}()}}i&&f(n,r)}return f(o,o),[s,c,l]}config_numc"\
"alc&&(g.execCmd=function(e){switch(e){case\"dec\":hex_mode=!1;b"\
"reak;case\"hex\":hex_mode=!0;break;case\"num\":algebraicMode=!1;b"\
"reak;case\"alg\":algebraicMode=!0}});try{termInit()}catch(e){co"\
"nsole.error(e)}}(globalThis)}));\n";

View File

@ -109,7 +109,7 @@ import('os').catch(console.error).then((os) => {
let prompt = '';
let plen = 0;
let ps1;
if (config_numcalc) { ps1 = '> '; } else { ps1 = 'qjs> '; }
if (config_numcalc) { ps1 = '> '; } else { ps1 = '[r2js]> '; }
const ps2 = ' ... ';
const utf8 = true;
let show_time = false;

View File

@ -1,5 +1,5 @@
{
"dependencies": {
"r2papi": "^0.0.23"
"r2papi": "^0.1.1"
}
}