UNPKG

@maximegirardet/merge-pdfs

Version:

Merging PDF (with Outline).

9 lines (7 loc) 1.27 MB
"use strict"; var _createPyodideModule = (() => { var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; return ( function(_createPyodideModule = {}) { var Module=typeof _createPyodideModule!="undefined"?_createPyodideModule:{};if(typeof globalThis.BigInt64Array==="undefined"){function partsToBigIntSigned(lower,upper){return BigInt(lower)|BigInt(upper+2*(upper&2147483648))<<32n}function partsToBigIntUnsigned(lower,upper){return BigInt(lower)|BigInt(upper)<<32n}function bigIntToParts(value){var lower=Number(BigInt(value)&BigInt(4294967295))|0;var upper=Number(BigInt(value)>>32n)|0;return[lower,upper]}function createBigIntArrayShim(partsToBigInt){function createBigInt64Array(array){if(typeof array==="number"){array=new Uint32Array(2*array)}var orig_array;if(!ArrayBuffer.isView(array)){if(array.constructor&&array.constructor.name==="ArrayBuffer"){array=new Uint32Array(array)}else{orig_array=array;array=new Uint32Array(array.length*2)}}var proxy=new Proxy({slice:function(min,max){if(max===undefined){max=array.length}var new_buf=array.slice(min*2,max*2);return createBigInt64Array(new_buf)},subarray:function(min,max){var new_buf=array.subarray(min*2,max*2);return createBigInt64Array(new_buf)},[Symbol.iterator]:function*(){for(var i=0;i<array.length/2;i++){yield partsToBigInt(array[2*i],array[2*i+1])}},BYTES_PER_ELEMENT:2*array.BYTES_PER_ELEMENT,buffer:array.buffer,byteLength:array.byteLength,byteOffset:array.byteOffset,length:array.length/2,copyWithin:function(target,start,end){array.copyWithin(target*2,start*2,end*2);return proxy},set:function(source,targetOffset){if(targetOffset===undefined){targetOffset=0}if(2*(source.length+targetOffset)>array.length){throw new RangeError("offset is out of bounds")}for(var i=0;i<source.length;i++){var value=source[i];var pair=bigIntToParts(value);array.set(pair,2*(targetOffset+i))}}},{get:function(target,idx,receiver){if(typeof idx!=="string"||!/^\d+$/.test(idx)){return Reflect.get(target,idx,receiver)}var lower=array[idx*2];var upper=array[idx*2+1];return partsToBigInt(lower,upper)},set:function(target,idx,value,receiver){if(typeof idx!=="string"||!/^\d+$/.test(idx)){return Reflect.set(target,idx,value,receiver)}if(typeof value!=="bigint"){throw new TypeError(`Cannot convert ${value} to a BigInt`)}var pair=bigIntToParts(value);array.set(pair,2*idx);return true}});if(orig_array){proxy.set(orig_array)}return proxy}return createBigInt64Array}globalThis.BigUint64Array=createBigIntArrayShim(partsToBigIntUnsigned);globalThis.BigInt64Array=createBigIntArrayShim(partsToBigIntSigned)}var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;function logExceptionOnExit(e){if(e instanceof ExitStatus)return;let toLog=e;if(e&&typeof e=="object"&&e.stack){toLog=[e,e.stack]}err("exiting due to exception: "+toLog)}if(ENVIRONMENT_IS_NODE){var fs=require("fs");var nodePath=require("path");if(ENVIRONMENT_IS_WORKER){scriptDirectory=nodePath.dirname(scriptDirectory)+"/"}else{scriptDirectory=__dirname+"/"}read_=(filename,binary)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);return fs.readFileSync(filename,binary?undefined:"utf8")};readBinary=filename=>{var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}return ret};readAsync=(filename,onload,onerror)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);fs.readFile(filename,function(err,data){if(err)onerror(err);else onload(data.buffer)})};if(process.argv.length>1){thisProgram=process.argv[1].replace(/\\/g,"/")}arguments_=process.argv.slice(2);quit_=(status,toThrow)=>{if(keepRuntimeAlive()){process.exitCode=status;throw toThrow}logExceptionOnExit(toThrow);process.exit(status)};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=title=>document.title=title}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var dynamicLibraries=Module["dynamicLibraries"]||[];var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true;if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;function assert(condition,text){if(!condition){abort(text)}}var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heapOrArray,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i<str.length;++i){var c=str.charCodeAt(i);if(c<=127){len++}else if(c<=2047){len+=2}else if(c>=55296&&c<=57343){len+=4;++i}else{len+=3}}return len}var HEAP,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAP64,HEAPU64,HEAPF64;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=HEAP16=new Int16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=HEAPU16=new Uint16Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=HEAPF32=new Float32Array(b);Module["HEAPF64"]=HEAPF64=new Float64Array(b);Module["HEAP64"]=HEAP64=new BigInt64Array(b);Module["HEAPU64"]=HEAPU64=new BigUint64Array(b)}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||20971520;assert(INITIAL_MEMORY>=5242880,"INITIAL_MEMORY should be larger than STACK_SIZE, was "+INITIAL_MEMORY+"! (STACK_SIZE="+5242880+")");if(Module["wasmMemory"]){wasmMemory=Module["wasmMemory"]}else{wasmMemory=new WebAssembly.Memory({"initial":INITIAL_MEMORY/65536,"maximum":2147483648/65536})}updateMemoryViews();INITIAL_MEMORY=wasmMemory.buffer.byteLength;var wasmTable=new WebAssembly.Table({"initial":6377,"element":"anyfunc"});var __ATPRERUN__=[];var __ATINIT__=[];var __ATMAIN__=[];var __ATEXIT__=[];var __ATPOSTRUN__=[];var __RELOC_FUNCS__=[];var runtimeInitialized=false;function keepRuntimeAlive(){return noExitRuntime}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(__ATPRERUN__)}function initRuntime(){runtimeInitialized=true;callRuntimeCallbacks(__RELOC_FUNCS__);if(!Module["noFSInit"]&&!FS.init.initialized)FS.init();FS.ignorePermissions=false;TTY.init();SOCKFS.root=FS.mount(SOCKFS,{},null);PIPEFS.root=FS.mount(PIPEFS,{},null);callRuntimeCallbacks(__ATINIT__)}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(cb){__ATPRERUN__.unshift(cb)}function addOnInit(cb){__ATINIT__.unshift(cb)}function addOnPreMain(cb){__ATMAIN__.unshift(cb)}function addOnExit(cb){}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb)}var runDependencies=0;var runDependencyWatcher=null;var dependenciesFulfilled=null;function getUniqueRunDependency(id){return id}function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies)}if(runDependencies==0){if(runDependencyWatcher!==null){clearInterval(runDependencyWatcher);runDependencyWatcher=null}if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback()}}}function abort(what){if(Module["onAbort"]){Module["onAbort"](what)}what="Aborted("+what+")";err(what);ABORT=true;EXITSTATUS=1;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}function isFileURI(filename){return filename.startsWith("file://")}var wasmBinaryFile;wasmBinaryFile="pyodide.asm.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile)}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}catch(err){abort(err)}}function getBinaryPromise(binaryFile){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"&&!isFileURI(binaryFile)){return fetch(binaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw"failed to load wasm binary file at '"+binaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(binaryFile)})}else{if(readAsync){return new Promise(function(resolve,reject){readAsync(binaryFile,function(response){resolve(new Uint8Array(response))},reject)})}}}return Promise.resolve().then(function(){return getBinary(binaryFile)})}function instantiateArrayBuffer(binaryFile,imports,receiver){return getBinaryPromise(binaryFile).then(function(binary){return WebAssembly.instantiate(binary,imports)}).then(function(instance){return instance}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason)})}function instantiateAsync(binary,binaryFile,imports,callback){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,imports);return result.then(callback,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(binaryFile,imports,callback)})})}else{return instantiateArrayBuffer(binaryFile,imports,callback)}}function createWasm(){var info={"env":wasmImports,"wasi_snapshot_preview1":wasmImports,"GOT.mem":new Proxy(wasmImports,GOTHandler),"GOT.func":new Proxy(wasmImports,GOTHandler)};function receiveInstance(instance,module){var exports=instance.exports;exports=relocateExports(exports,1024);var metadata=getDylinkMetadata(module);if(metadata.neededDynlibs){dynamicLibraries=metadata.neededDynlibs.concat(dynamicLibraries)}mergeLibSymbols(exports,"main");Module["asm"]=exports;addOnInit(Module["asm"]["__wasm_call_ctors"]);__RELOC_FUNCS__.push(Module["asm"]["__wasm_apply_data_relocs"]);removeRunDependency("wasm-instantiate");return exports}addRunDependency("wasm-instantiate");function receiveInstantiationResult(result){receiveInstance(result["instance"],result["module"])}if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err("Module.instantiateWasm callback failed with error: "+e);readyPromiseReject(e)}}instantiateAsync(wasmBinary,wasmBinaryFile,info,receiveInstantiationResult).catch(readyPromiseReject);return{}}var tempDouble;var tempI64;var ASM_CONSTS={3880638:()=>{throw new Error("intentionally triggered fatal error!")},3880695:$0=>{Hiwire.get_value($0)()},3880718:()=>{Module.UTF8ToString=UTF8ToString;Module.wasmTable=wasmTable;Module.ERRNO_CODES=ERRNO_CODES},3880822:$0=>{API._pyodide=Hiwire.pop_value($0)},3880863:($0,$1)=>{Hiwire.get_value($1).push(...Hiwire.get_value($0))},3880919:$0=>{for(let v of Hiwire.get_value($0)){if(typeof v.destroy==="function"){try{v.destroy()}catch(e){console.warn("Weird error:",e)}}}}};function console_error(msg){let jsmsg=UTF8ToString(msg);console.error(jsmsg)}function console_error_obj(obj){console.error(Hiwire.get_value(obj))}console_error_obj.sig="vi";function new_error(type,msg,err){try{return Hiwire.new_value(new API.PythonError(UTF8ToString(type),UTF8ToString(msg),err))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}new_error.sig="iiii";function fail_test(){API.fail_test=true}fail_test.sig="v";function hiwire_to_bool(val){return!!Hiwire.get_value(val)}hiwire_to_bool.sig="ii";function hiwire_init(){try{let _hiwire={objects:new Map,obj_to_key:new Map,counter:new Uint32Array([1])};Hiwire.UNDEFINED=HEAPU8[_Js_undefined+0];_hiwire.objects.set(Hiwire.UNDEFINED,[undefined,-1]);_hiwire.obj_to_key.set(undefined,Hiwire.UNDEFINED);Hiwire.JSNULL=HEAPU8[_Js_null+0];_hiwire.objects.set(Hiwire.JSNULL,[null,-1]);_hiwire.obj_to_key.set(null,Hiwire.JSNULL);Hiwire.TRUE=HEAPU8[_Js_true+0];_hiwire.objects.set(Hiwire.TRUE,[!!1,-1]);_hiwire.obj_to_key.set(!!1,Hiwire.TRUE);Hiwire.FALSE=HEAPU8[_Js_false+0];_hiwire.objects.set(Hiwire.FALSE,[!!0,-1]);_hiwire.obj_to_key.set(!!0,Hiwire.FALSE);let hiwire_next_permanent=HEAPU8[_Js_novalue]+2;Hiwire.new_value=function(jsval){let idval=_hiwire.obj_to_key.get(jsval);if(idval!==undefined){_hiwire.objects.get(idval)[1]++;return idval}while(_hiwire.objects.has(_hiwire.counter[0])){_hiwire.counter[0]+=2}idval=_hiwire.counter[0];_hiwire.objects.set(idval,[jsval,1]);_hiwire.obj_to_key.set(jsval,idval);_hiwire.counter[0]+=2;return idval};Hiwire.intern_object=function(obj){let id=hiwire_next_permanent;hiwire_next_permanent+=2;_hiwire.objects.set(id,[obj,-1]);return id};Hiwire.num_keys=function(){return Array.from(_hiwire.objects.keys()).filter(x=>x%2).length};Hiwire.get_value=function(idval){if(!idval){API.fail_test=!!1;if(_PyErr_Occurred()){let exc=_wrap_exception();let e=Hiwire.pop_value(exc);console.error(`Pyodide internal error: Argument '${idval}' to hiwire.get_value is falsy. `+"This was probably because the Python error indicator was set when get_value was called. "+"The Python error that caused this was:",e);throw e}else{console.error(`Pyodide internal error: Argument '${idval}' to hiwire.get_value is falsy`+" (but error indicator is not set).");throw new Error(`Pyodide internal error: Argument '${idval}' to hiwire.get_value is falsy`+" (but error indicator is not set).")}}if(!_hiwire.objects.has(idval)){API.fail_test=!!1;console.error(`Pyodide internal error: Undefined id ${idval}`);throw new Error(`Undefined id ${idval}`)}return _hiwire.objects.get(idval)[0]};Hiwire.decref=function(idval){if((idval&1)===0){return}let pair=_hiwire.objects.get(idval);let new_refcnt=--pair[1];if(new_refcnt===0){_hiwire.objects.delete(idval);_hiwire.obj_to_key.delete(pair[0])}};Hiwire.incref=function(idval){if((idval&1)===0){return}_hiwire.objects.get(idval)[1]++};Hiwire.pop_value=function(idval){let result=Hiwire.get_value(idval);Hiwire.decref(idval);return result};Hiwire.isPromise=function(obj){try{return!!obj&&typeof obj.then==="function"}catch(e){return!!0}};API.typedArrayAsUint8Array=function(arg){if(ArrayBuffer.isView(arg)){return new Uint8Array(arg.buffer,arg.byteOffset,arg.byteLength)}else{return new Uint8Array(arg)}};{let dtypes_str=["b","B","h","H","i","I","f","d"].join(String.fromCharCode(0));let dtypes_ptr=stringToNewUTF8(dtypes_str);let dtypes_map={};for(let[idx,val]of Object.entries(dtypes_str)){dtypes_map[val]=dtypes_ptr+Number(idx)}let buffer_datatype_map=new Map([["Int8Array",[dtypes_map["b"],1,!!1]],["Uint8Array",[dtypes_map["B"],1,!!1]],["Uint8ClampedArray",[dtypes_map["B"],1,!!1]],["Int16Array",[dtypes_map["h"],2,!!1]],["Uint16Array",[dtypes_map["H"],2,!!1]],["Int32Array",[dtypes_map["i"],4,!!1]],["Uint32Array",[dtypes_map["I"],4,!!1]],["Float32Array",[dtypes_map["f"],4,!!1]],["Float64Array",[dtypes_map["d"],8,!!1]],["DataView",[dtypes_map["B"],1,!!0]],["ArrayBuffer",[dtypes_map["B"],1,!!0]]]);Module.get_buffer_datatype=function(jsobj){return buffer_datatype_map.get(jsobj.constructor.name)||[0,0,!!0]}}Module.iterObject=function*(object){for(let k in object){if(Object.prototype.hasOwnProperty.call(object,k)){yield k}}};if(globalThis.BigInt){Module.BigInt=BigInt}else{Module.BigInt=Number}return 0}catch(e){Module.handle_js_error(e);return-1}return 0}hiwire_init.sig="i";function hiwire_incref(idval){if(idval&1){Hiwire.incref(idval)}return idval}hiwire_incref.sig="ii";function hiwire_decref(idval){Hiwire.decref(idval)}hiwire_decref.sig="vi";function hiwire_int(val){try{return Hiwire.new_value(val)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_int.sig="ii";function hiwire_int_from_digits(digits,ndigits){try{let result=BigInt(0);for(let i=0;i<ndigits;i++){result+=BigInt(HEAPU32[(digits>>2)+i])<<BigInt(32*i)}result+=BigInt(HEAPU32[(digits>>2)+ndigits-1]&2147483648)<<BigInt(1+32*(ndigits-1));if(-Number.MAX_SAFE_INTEGER<result&&result<Number.MAX_SAFE_INTEGER){result=Number(result)}return Hiwire.new_value(result)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_int_from_digits.sig="iii";function hiwire_double(val){try{return Hiwire.new_value(val)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_double.sig="id";function hiwire_string_utf8(ptr){try{return Hiwire.new_value(UTF8ToString(ptr))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_string_utf8.sig="ii";function hiwire_throw_error(iderr){throw Hiwire.pop_value(iderr)}hiwire_throw_error.sig="vi";function hiwire_call(idfunc,idargs){try{let jsfunc=Hiwire.get_value(idfunc);let jsargs=Hiwire.get_value(idargs);return Hiwire.new_value(jsfunc(...jsargs))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_call.sig="iii";function hiwire_call_OneArg(idfunc,idarg){try{let jsfunc=Hiwire.get_value(idfunc);let jsarg=Hiwire.get_value(idarg);return Hiwire.new_value(jsfunc(jsarg))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_call_OneArg.sig="iii";function hiwire_call_bound(idfunc,idthis,idargs){try{let func=Hiwire.get_value(idfunc);let this_;if(idthis===0){this_=null}else{this_=Hiwire.get_value(idthis)}let args=Hiwire.get_value(idargs);return Hiwire.new_value(func.apply(this_,args))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_call_bound.sig="iiii";function hiwire_HasMethod(obj_id,name){try{let obj=Hiwire.get_value(obj_id);return obj&&typeof obj[Hiwire.get_value(name)]==="function"}catch(e){return!!0}}hiwire_HasMethod.sig="iii";function hiwire_CallMethodString(idobj,name,idargs){try{let jsobj=Hiwire.get_value(idobj);let jsname=UTF8ToString(name);let jsargs=Hiwire.get_value(idargs);return Hiwire.new_value(jsobj[jsname](...jsargs))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_CallMethodString.sig="iiii";function hiwire_CallMethod(idobj,name,idargs){try{let jsobj=Hiwire.get_value(idobj);let jsname=Hiwire.get_value(name);let jsargs=Hiwire.get_value(idargs);return Hiwire.new_value(jsobj[jsname](...jsargs))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_CallMethod.sig="iiii";function hiwire_CallMethod_NoArgs(idobj,name){try{let jsobj=Hiwire.get_value(idobj);let jsname=Hiwire.get_value(name);return Hiwire.new_value(jsobj[jsname]())}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_CallMethod_NoArgs.sig="iii";function hiwire_CallMethod_OneArg(idobj,name,idarg){try{let jsobj=Hiwire.get_value(idobj);let jsname=Hiwire.get_value(name);let jsarg=Hiwire.get_value(idarg);return Hiwire.new_value(jsobj[jsname](jsarg))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_CallMethod_OneArg.sig="iiii";function hiwire_construct(idobj,idargs){try{let jsobj=Hiwire.get_value(idobj);let jsargs=Hiwire.get_value(idargs);return Hiwire.new_value(Reflect.construct(jsobj,jsargs))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_construct.sig="iii";function hiwire_has_length(idobj){try{let val=Hiwire.get_value(idobj);return typeof val.size==="number"||typeof val.length==="number"&&typeof val!=="function"}catch(e){return!!0}}function hiwire_get_length_helper(idobj){try{let val=Hiwire.get_value(idobj);let result;if(typeof val.size==="number"){result=val.size}else if(typeof val.length==="number"){result=val.length}else{return-2}if(result<0){return-3}if(result>2147483647){return-4}return result}catch(e){Module.handle_js_error(e);return-1}return 0}hiwire_get_length_helper.sig="ii";function hiwire_get_length_string(idobj){try{const val=Hiwire.get_value(idobj);let result;if(typeof val.size==="number"){result=val.size}else if(typeof val.length==="number"){result=val.length}return stringToNewUTF8(" "+result.toString())}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_get_length_string.sig="ii";function hiwire_get_bool(idobj){try{let val=Hiwire.get_value(idobj);if(!val){return!!0}if(val.size===0){if(/HTML[A-Za-z]*Element/.test(getTypeTag(val))){return!!1}return!!0}if(val.length===0&&JsArray_Check(idobj)){return!!0}if(val.byteLength===0){return!!0}return!!1}catch(e){return!!0}}hiwire_get_bool.sig="ii";function hiwire_is_function(idobj){try{return typeof Hiwire.get_value(idobj)==="function"}catch(e){return!!0}}hiwire_is_function.sig="ii";function hiwire_is_generator(idobj){try{return getTypeTag(Hiwire.get_value(idobj))==="[object Generator]"}catch(e){return!!0}}hiwire_is_generator.sig="ii";function hiwire_is_async_generator(idobj){try{return Object.prototype.toString.call(Hiwire.get_value(idobj))==="[object AsyncGenerator]"}catch(e){return!!0}}hiwire_is_async_generator.sig="ii";function hiwire_is_comlink_proxy(idobj){try{let value=Hiwire.get_value(idobj);return!!(API.Comlink&&value[API.Comlink.createEndpoint])}catch(e){return!!0}}hiwire_is_comlink_proxy.sig="ii";function hiwire_is_error(idobj){try{let value=Hiwire.get_value(idobj);return!!(value&&typeof value.stack==="string"&&typeof value.message==="string")}catch(e){return!!0}}function hiwire_is_promise(idobj){try{let obj=Hiwire.get_value(idobj);return Hiwire.isPromise(obj)}catch(e){return!!0}}hiwire_is_promise.sig="ii";function hiwire_resolve_promise(idobj){try{let obj=Hiwire.get_value(idobj);let result=Promise.resolve(obj);return Hiwire.new_value(result)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_resolve_promise.sig="ii";function hiwire_to_string(idobj){try{return Hiwire.new_value(Hiwire.get_value(idobj).toString())}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_to_string.sig="ii";function hiwire_typeof(idobj){return Hiwire.new_value(typeof Hiwire.get_value(idobj))}hiwire_typeof.sig="ii";function hiwire_constructor_name(idobj){try{return stringToNewUTF8(Hiwire.get_value(idobj).constructor.name)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_constructor_name.sig="ii";function hiwire_less_than(ida,idb){try{return!!(Hiwire.get_value(ida)<Hiwire.get_value(idb))}catch(e){return!!0}}hiwire_less_than.sig="iii";function hiwire_less_than_equal(ida,idb){try{return!!(Hiwire.get_value(ida)<=Hiwire.get_value(idb))}catch(e){return!!0}}hiwire_less_than_equal.sig="iii";function hiwire_equal(ida,idb){try{return!!(Hiwire.get_value(ida)===Hiwire.get_value(idb))}catch(e){return!!0}}hiwire_equal.sig="iii";function hiwire_not_equal(ida,idb){try{return!!(Hiwire.get_value(ida)!==Hiwire.get_value(idb))}catch(e){return!!0}}hiwire_not_equal.sig="iii";function hiwire_greater_than(ida,idb){try{return!!(Hiwire.get_value(ida)>Hiwire.get_value(idb))}catch(e){return!!0}}hiwire_greater_than.sig="iii";function hiwire_greater_than_equal(ida,idb){try{return!!(Hiwire.get_value(ida)>=Hiwire.get_value(idb))}catch(e){return!!0}}hiwire_greater_than_equal.sig="iii";function hiwire_reversed_iterator(idarray){try{if(!Module._reversedIterator){Module._reversedIterator=class ReversedIterator{constructor(array){this._array=array;this._i=array.length-1}__length_hint__(){return this._array.length}[Symbol.toStringTag](){return"ReverseIterator"}next(){const i=this._i;const a=this._array;const done=i<0;const value=done?undefined:a[i];this._i--;return{done:done,value:value}}}}let array=Hiwire.get_value(idarray);return Hiwire.new_value(new Module._reversedIterator(array))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}hiwire_reversed_iterator.sig="ii";function hiwire_assign_to_ptr(idobj,ptr){try{let jsobj=Hiwire.get_value(idobj);Module.HEAPU8.set(API.typedArrayAsUint8Array(jsobj),ptr)}catch(e){Module.handle_js_error(e);return-1}return 0}hiwire_assign_to_ptr.sig="iii";function hiwire_assign_from_ptr(idobj,ptr){try{let jsobj=Hiwire.get_value(idobj);API.typedArrayAsUint8Array(jsobj).set(Module.HEAPU8.subarray(ptr,ptr+jsobj.byteLength))}catch(e){Module.handle_js_error(e);return-1}return 0}hiwire_assign_from_ptr.sig="iii";function hiwire_read_from_file(idobj,fd){try{let jsobj=Hiwire.get_value(idobj);let uint8_buffer=API.typedArrayAsUint8Array(jsobj);let stream=Module.FS.streams[fd];Module.FS.read(stream,uint8_buffer,0,uint8_buffer.byteLength)}catch(e){Module.handle_js_error(e);return-1}return 0}hiwire_read_from_file.sig="iii";function hiwire_write_to_file(idobj,fd){try{let jsobj=Hiwire.get_value(idobj);let uint8_buffer=API.typedArrayAsUint8Array(jsobj);let stream=Module.FS.streams[fd];Module.FS.write(stream,uint8_buffer,0,uint8_buffer.byteLength)}catch(e){Module.handle_js_error(e);return-1}return 0}hiwire_write_to_file.sig="iii";function hiwire_into_file(idobj,fd){try{let jsobj=Hiwire.get_value(idobj);let uint8_buffer=API.typedArrayAsUint8Array(jsobj);let stream=Module.FS.streams[fd];Module.FS.write(stream,uint8_buffer,0,uint8_buffer.byteLength,undefined,!!1)}catch(e){Module.handle_js_error(e);return-1}return 0}hiwire_into_file.sig="iii";function hiwire_get_buffer_info(idobj,byteLength_ptr,format_ptr,size_ptr,checked_ptr){let jsobj=Hiwire.get_value(idobj);let byteLength=jsobj.byteLength;let[format_utf8,size,checked]=Module.get_buffer_datatype(jsobj);HEAPU32[(byteLength_ptr>>2)+0]=byteLength;HEAPU32[(format_ptr>>2)+0]=format_utf8;HEAPU32[(size_ptr>>2)+0]=size;HEAPU8[checked_ptr+0]=checked}hiwire_get_buffer_info.sig="viiiii";function hiwire_subarray(idarr,start,end){try{let jsarr=Hiwire.get_value(idarr);let jssub=jsarr.subarray(start,end);return Hiwire.new_value(jssub)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}function JsArray_Check(idobj){try{let obj=Hiwire.get_value(idobj);if(Array.isArray(obj)){return!!1}let typeTag=getTypeTag(obj);if(typeTag==="[object HTMLCollection]"||typeTag==="[object NodeList]"){return!!1}if(ArrayBuffer.isView(obj)&&obj.constructor.name!=="DataView"){return!!1}return!!0}catch(e){return!!0}}JsArray_Check.sig="ii";function JsArray_New(){try{return Hiwire.new_value([])}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsArray_New.sig="i";function JsArray_Push(idarr,idval){try{Hiwire.get_value(idarr).push(Hiwire.get_value(idval))}catch(e){Module.handle_js_error(e);return-1}return 0}JsArray_Push.sig="iii";function JsArray_Push_unchecked(idarr,idval){const arr=Hiwire.get_value(idarr);arr.push(Hiwire.get_value(idval));return arr.length-1}JsArray_Push_unchecked.sig="iii";function JsArray_Get(idobj,idx){try{let obj=Hiwire.get_value(idobj);let result=obj[idx];if(result===undefined&&!(idx in obj)){return 0}return Hiwire.new_value(result)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsArray_Get.sig="iii";function JsArray_Set(idobj,idx,idval){try{Hiwire.get_value(idobj)[idx]=Hiwire.get_value(idval)}catch(e){Module.handle_js_error(e);return-1}return 0}JsArray_Set.sig="iiii";function JsArray_Delete(idobj,idx){try{let obj=Hiwire.get_value(idobj);if(idx<0||idx>=obj.length){return-1}obj.splice(idx,1)}catch(e){Module.handle_js_error(e);return-1}return 0}JsArray_Delete.sig="iii";function JsArray_Splice(idobj,idx){try{let obj=Hiwire.get_value(idobj);if(idx<0||idx>=obj.length){return 0}return Hiwire.new_value(obj.splice(idx,1))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsArray_Splice.sig="iii";function JsArray_slice(idobj,length,start,stop,step){try{let obj=Hiwire.get_value(idobj);let result;if(step===1){result=obj.slice(start,stop)}else{result=Array.from({length:length},(_,i)=>obj[start+i*step])}return Hiwire.new_value(result)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsArray_slice.sig="iiiiii";function JsArray_slice_assign(idobj,slicelength,start,stop,step,values_length,values){try{let obj=Hiwire.get_value(idobj);let jsvalues=[];for(let i=0;i<values_length;i++){let ref=_python2js(HEAPU32[(values>>2)+i]);if(ref===0){return-1}jsvalues.push(Hiwire.pop_value(ref))}if(step===1){obj.splice(start,slicelength,...jsvalues)}else{if(values!==0){for(let i=0;i<slicelength;i++){obj.splice(start+i*step,1,jsvalues[i])}}else{for(let i=slicelength-1;i>=0;i--){obj.splice(start+i*step,1)}}}}catch(e){Module.handle_js_error(e);return-1}return 0}JsArray_slice_assign.sig="iiiiiiii";function JsArray_Clear(idobj){try{let obj=Hiwire.get_value(idobj);obj.splice(0,obj.length)}catch(e){Module.handle_js_error(e);return-1}return 0}function JsObject_New(){try{return Hiwire.new_value({})}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsObject_New.sig="i";function isReservedWord(word){if(!Module.pythonReservedWords){Module.pythonReservedWords=new Set(["False","await","else","import","pass","None","break","except","in","raise","True","class","finally","is","return","and","continue","for","lambda","try","as","def","from","nonlocal","while","assert","del","global","not","with","async","elif","if","or","yield"])}return Module.pythonReservedWords.has(word)}function normalizeReservedWords(action,word){const noTrailing_=word.replace(/_*$/,"");if(!isReservedWord(noTrailing_)){return word}if(noTrailing_!==word){return word.slice(0,-1)}let action_ptr=stringToNewUTF8(action);let word_ptr=stringToNewUTF8(word);_setReservedError(action_ptr,word_ptr);_free(action_ptr);_free(word_ptr);throw new Module._PropagatePythonError}function JsObject_GetString(idobj,ptrkey){try{let jsobj=Hiwire.get_value(idobj);let jskey=normalizeReservedWords("get",UTF8ToString(ptrkey));if(jskey in jsobj){return Hiwire.new_value(jsobj[jskey])}return 0}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsObject_GetString.sig="iii";function JsObject_SetString(idobj,ptrkey,idval){try{let jsobj=Hiwire.get_value(idobj);let jskey=normalizeReservedWords("set",UTF8ToString(ptrkey));let jsval=Hiwire.get_value(idval);jsobj[jskey]=jsval}catch(e){Module.handle_js_error(e);return-1}return 0}JsObject_SetString.sig="iiii";function JsObject_DeleteString(idobj,ptrkey){try{let jsobj=Hiwire.get_value(idobj);let jskey=normalizeReservedWords("delete",UTF8ToString(ptrkey));delete jsobj[jskey]}catch(e){Module.handle_js_error(e);return-1}return 0}JsObject_DeleteString.sig="iii";function JsObject_Dir(idobj){try{let jsobj=Hiwire.get_value(idobj);let result=[];do{const names=Object.getOwnPropertyNames(jsobj);result.push(...names.filter(s=>{let c=s.charCodeAt(0);return c<48||c>57}).map(word=>isReservedWord(word.replace(/_*$/,""))?word+"_":word))}while(jsobj=Object.getPrototypeOf(jsobj));return Hiwire.new_value(result)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsObject_Dir.sig="ii";function JsObject_Entries(idobj){try{let jsobj=Hiwire.get_value(idobj);return Hiwire.new_value(Object.entries(jsobj))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsObject_Entries.sig="ii";function JsObject_Keys(idobj){try{let jsobj=Hiwire.get_value(idobj);return Hiwire.new_value(Object.keys(jsobj))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsObject_Keys.sig="ii";function JsObject_Values(idobj){try{let jsobj=Hiwire.get_value(idobj);return Hiwire.new_value(Object.values(jsobj))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsObject_Values.sig="ii";function JsString_InternFromCString(str){try{let jsstring=UTF8ToString(str);return Hiwire.intern_object(jsstring)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsString_InternFromCString.sig="ii";function JsMap_New(){try{return Hiwire.new_value(new Map)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsMap_New.sig="i";function JsMap_Set(mapid,keyid,valueid){try{let map=Hiwire.get_value(mapid);let key=Hiwire.get_value(keyid);let value=Hiwire.get_value(valueid);map.set(key,value)}catch(e){Module.handle_js_error(e);return-1}return 0}JsMap_Set.sig="iiii";function JsSet_New(){try{return Hiwire.new_value(new Set)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsSet_New.sig="i";function JsSet_Add(mapid,keyid){try{let set=Hiwire.get_value(mapid);let key=Hiwire.get_value(keyid);set.add(key)}catch(e){Module.handle_js_error(e);return-1}return 0}JsSet_Add.sig="iii";function js2python_immutable(id){try{let value=Hiwire.get_value(id);let result=Module.js2python_convertImmutable(value,id);if(result!==undefined){return result}return 0}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}js2python_immutable.sig="ii";function js2python(id){try{let value=Hiwire.get_value(id);let result=Module.js2python_convertImmutable(value,id);if(result!==undefined){return result}return _JsProxy_create(id)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}js2python.sig="ii";function js2python_convert(id,depth,default_converter){try{let defaultConverter=default_converter?Module.hiwire.get_value(default_converter):undefined;return Module.js2python_convert(id,{depth:depth,defaultConverter:defaultConverter})}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}js2python_convert.sig="iiii";function js2python_init(){try{{0;let PropagateError=Module._PropagatePythonError;function js2python_string(value){let max_code_point=0;let num_code_points=0;for(let c of value){num_code_points++;let code_point=c.codePointAt(0);max_code_point=code_point>max_code_point?code_point:max_code_point}let result=_PyUnicode_New(num_code_points,max_code_point);if(result===0){throw new PropagateError}let ptr=_PyUnicode_Data(result);if(max_code_point>65535){for(let c of value){HEAPU32[ptr/4]=c.codePointAt(0);ptr+=4}}else if(max_code_point>255){for(let c of value){HEAPU16[ptr/2]=c.codePointAt(0);ptr+=2}}else{for(let c of value){HEAPU8[ptr]=c.codePointAt(0);ptr+=1}}return result}function js2python_bigint(value){let value_orig=value;let length=0;if(value<0){value=-value}value<<=BigInt(1);while(value){length++;value>>=BigInt(32)}let stackTop=stackSave();let ptr=stackAlloc(length*4);value=value_orig;for(let i=0;i<length;i++){HEAPU32[(ptr>>2)+i]=Number(value&BigInt(4294967295));value>>=BigInt(32)}let result=__PyLong_FromByteArray(ptr,length*4,!!1,!!1);stackRestore(stackTop);return result}function js2python_convertImmutable(value,id){let result=js2python_convertImmutableInner(value,id);if(result===0){throw new PropagateError}return result}Module.js2python_convertImmutable=js2python_convertImmutable;function js2python_convertImmutableInner(value,id){let type=typeof value;if(type==="string"){return js2python_string(value)}else if(type==="number"){if(Number.isSafeInteger(value)){return _PyLong_FromDouble(value)}else{return _PyFloat_FromDouble(value)}}else if(type==="bigint"){return js2python_bigint(value)}else if(value===undefined||value===null){return __js2python_none()}else if(value===!!1){return __js2python_true()}else if(value===!!0){return __js2python_false()}else if(API.isPyProxy(value)){if(value.$$.ptr==0){Module.PyProxy_getPtr(value)}if(value.$$props.roundtrip){if(id===undefined){id=Hiwire.new_value(value)}return _JsProxy_create(id)}else{return __js2python_pyproxy(Module.PyProxy_getPtr(value))}}return undefined}function js2python_convertList(obj,context){let list=_PyList_New(obj.length);if(list===0){return 0}let entryid=0;let item=0;try{context.cache.set(obj,list);for(let i=0;i<obj.length;i++){entryid=Hiwire.new_value(obj[i]);item=js2python_convert_with_context(entryid,context);_Py_IncRef(item);if(_PyList_SetItem(list,i,item)===-1){throw new PropagateError}Hiwire.decref(entryid);entryid=0;_Py_DecRef(item);item=0}}catch(e){Hiwire.decref(entryid);_Py_DecRef(item);_Py_DecRef(list);throw e}return list}function js2python_convertMap(obj,entries,context){let dict=_PyDict_New();if(dict===0){return 0}let key_py=0;let value_id=0;let value_py=0;try{context.cache.set(obj,dict);for(let[key_js,value_js]of entries){key_py=js2python_convertImmutable(key_js);if(key_py===undefined){let key_type=key_js.constructor&&key_js.constructor.name||typeof key_js;throw new Error(`Cannot use key of type ${key_type} as a key to a Python dict`)}value_id=Hiwire.new_value(value_js);value_py=js2python_convert_with_context(value_id,context);if(_PyDict_SetItem(dict,key_py,value_py)===-1){throw new PropagateError}_Py_DecRef(key_py);key_py=0;Hiwire.decref(value_id);value_id=0;_Py_DecRef(value_py);value_py=0}}catch(e){_Py_DecRef(key_py);Hiwire.decref(value_id);_Py_DecRef(value_py);_Py_DecRef(dict);throw e}return dict}function js2python_convertSet(obj,context){let set=_PySet_New(0);if(set===0){return 0}let key_py=0;try{context.cache.set(obj,set);for(let key_js of obj){key_py=js2python_convertImmutable(key_js);if(key_py===undefined){let key_type=key_js.constructor&&key_js.constructor.name||typeof key_js;throw new Error(`Cannot use key of type ${key_type} as a key to a Python set`)}let errcode=_PySet_Add(set,key_py);if(errcode===-1){throw new PropagateError}_Py_DecRef(key_py);key_py=0}}catch(e){_Py_DecRef(key_py);_Py_DecRef(set);throw e}return set}function checkBoolIntCollision(obj,ty){if(obj.has(1)&&obj.has(!!1)){throw new Error(`Cannot faithfully convert ${ty} into Python since it `+"contains both 1 and true as keys.")}if(obj.has(0)&&obj.has(!!0)){throw new Error(`Cannot faithfully convert ${ty} into Python since it `+"contains both 0 and false as keys.")}}function js2python_convertOther(id,value,context){let typeTag=getTypeTag(value);if(Array.isArray(value)||value==="[object HTMLCollection]"||value==="[object NodeList]"){return js2python_convertList(value,context)}if(typeTag==="[object Map]"||value instanceof Map){checkBoolIntCollision(value,"Map");return js2python_convertMap(value,value.entries(),context)}if(typeTag==="[object Set]"||value instanceof Set){checkBoolIntCollision(value,"Set");return js2python_convertSet(value,context)}if(typeTag==="[object Object]"&&(value.constructor===undefined||value.constructor.name==="Object")){return js2python_convertMap(value,Object.entries(value),context)}if(typeTag==="[object ArrayBuffer]"||ArrayBuffer.isView(value)){let[format_utf8,itemsize]=Module.get_buffer_datatype(value);return _JsBuffer_CopyIntoMemoryView(id,value.byteLength,format_utf8,itemsize)}return undefined}function js2python_convert_with_context(id,context){let value=Hiwire.get_value(id);let result;result=js2python_convertImmutable(value,id);if(result!==undefined){return result}if(context.depth===0){return _JsProxy_create(id)}result=context.cache.get(value);if(result!==undefined){return result}context.depth--;try{result=js2python_convertOther(id,value,context);if(result!==undefined){return result}if(context.defaultConverter===undefined){return _JsProxy_create(id)}let result_js=context.defaultConverter(value,context.converter,context.cacheConversion);result=js2python_convertImmutable(result_js);if(API.isPyProxy(result_js)){Module.pyproxy_destroy(result_js,"",!!0)}if(result!==undefined){return result}let result_id=Module.hiwire.new_value(result_js);result=_JsProxy_create(result_id);Module.hiwire.decref(result_id);return result}finally{context.depth++}}function js2python_convert(id,{depth:depth,defaultConverter:defaultConverter}){let context={cache:new Map,depth:depth,defaultConverter:defaultConverter,converter(x){let id=Module.hiwire.new_value(x);try{return Module.pyproxy_new(js2python_convert_with_context(id,context))}finally{Module.hiwire.decref(id)}},cacheConversion(input,output){if(API.isPyProxy(output)){context.cache.set(input,Module.PyProxy_getPtr(output))}else{throw new Error("Second argument should be a PyProxy!")}}};return js2python_convert_with_context(id,context)}Module.js2python_convert=js2python_convert}return 0}catch(e){Module.handle_js_error(e);return-1}return 0}js2python_init.sig="i";function JsProxy_GetIter_js(idobj){try{let jsobj=Hiwire.get_value(idobj);return Hiwire.new_value(jsobj[Symbol.iterator]())}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsProxy_GetIter_js.sig="ii";function handle_next_result_js(resid,result_ptr,msg){try{let errmsg;const res=Hiwire.get_value(resid);if(typeof res!=="object"){errmsg=`Result should have type "object" not "${typeof res}"`}else if(typeof res.done==="undefined"){if(typeof res.then==="function"){errmsg=`Result was a promise, use anext() / asend() / athrow() instead.`}else{errmsg=`Result has no "done" field.`}}if(errmsg){HEAPU32[(msg>>2)+0]=stringToNewUTF8(errmsg);return-1}let result_id=Hiwire.new_value(res.value);HEAPU32[(result_ptr>>2)+0]=result_id;return res.done}catch(e){Module.handle_js_error(e);return-1}return 0}handle_next_result_js.sig="iiii";function JsException_new_helper(name_ptr,message_ptr,stack_ptr){try{let name=UTF8ToString(name_ptr);let message=UTF8ToString(message_ptr);let stack=UTF8ToString(stack_ptr);return Hiwire.new_value(API.deserializeError(name,message,stack))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsException_new_helper.sig="iiii";function JsProxy_GetAsyncIter_js(idobj){try{let jsobj=Hiwire.get_value(idobj);return Hiwire.new_value(jsobj[Symbol.asyncIterator]())}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsProxy_GetAsyncIter_js.sig="ii";function _agen_handle_result_js(promiseid,msg,set_result,set_exception,closing){try{let p=Hiwire.get_value(promiseid);let errmsg;if(typeof p!=="object"){errmsg=`Result of anext() should be object not ${typeof p}`}else if(typeof p.then!=="function"){if(typeof p.done==="boolean"){errmsg=`Result of anext() was not a promise, use next() instead.`}else{errmsg=`Result of anext() was not a promise.`}}if(errmsg){HEAPU32[(msg>>2)+0]=stringToNewUTF8(errmsg);return-1}_Py_IncRef(set_result);_Py_IncRef(set_exception);p.then(({done:done,value:value})=>{let id=Hiwire.new_value(value);__agen_handle_result_js_c(set_result,set_exception,done,id,closing);Hiwire.decref(id)},err=>{let id=Hiwire.new_value(err);__agen_handle_result_js_c(set_result,set_exception,-1,id,closing);Hiwire.decref(id)}).finally(()=>{_Py_DecRef(set_result);_Py_DecRef(set_exception)});return 0}catch(e){Module.handle_js_error(e);return-1}return 0}_agen_handle_result_js.sig="iiiiii";function JsArray_index_helper(list,value,start,stop){try{let o=Hiwire.get_value(list);let v=Hiwire.get_value(value);for(let i=start;i<stop;i++){if(o[i]===v){return i}}return-1}catch(e){Module.handle_js_error(e);return-1}return 0}JsArray_index_helper.sig="iiiii";function JsArray_count_helper(list,value){try{let o=Hiwire.get_value(list);let v=Hiwire.get_value(value);let result=0;for(let i=0;i<o.length;i++){if(o[i]===v){result++}}return result}catch(e){Module.handle_js_error(e);return-1}return 0}JsArray_count_helper.sig="iii";function JsArray_reverse_helper(arrayid){try{Hiwire.get_value(arrayid).reverse()}catch(e){Module.handle_js_error(e);return-1}return 0}JsArray_reverse_helper.sig="ii";function JsProxy_subscript_js(idobj,idkey){try{let obj=Hiwire.get_value(idobj);let key=Hiwire.get_value(idkey);let result=obj.get(key);if(result===undefined){if(obj.has&&typeof obj.has==="function"&&!obj.has(key)){return 0}}return Hiwire.new_value(result)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsProxy_subscript_js.sig="iii";function JsMap_GetIter_js(idobj){try{let jsobj=Hiwire.get_value(idobj);let result;if(typeof jsobj.keys==="function"){result=jsobj.keys()}else{result=jsobj[Symbol.iterator]()}return Hiwire.new_value(result)}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsMap_GetIter_js.sig="ii";function JsMap_clear_js(idmap){try{const map=Hiwire.get_value(idmap);if(idmap&&typeof idmap.clear==="function"){idmap.clear();return 1}return 0}catch(e){Module.handle_js_error(e);return-1}return 0}JsMap_clear_js.sig="ii";function JsObjMap_GetIter_js(idobj){try{let jsobj=Hiwire.get_value(idobj);return Hiwire.new_value(Module.iterObject(jsobj))}catch(e){Module.handle_js_error(e);return 0}throw new Error("Assertion error: control reached end of function without return")}JsObjMap_GetIter_js.sig="ii";function JsObjMap_length_js(idobj){try{let jsobj=Hiwire.g