@xmtp/wasm-bindings 0.0.16 → 0.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- var e,t=(e=import.meta.url,function(t){var n,r,s=t||{},i=void 0!==s?s:{};i.ready=new Promise((function(e,t){n=e,r=t}));const o=globalThis.sqlite3InitModuleState||Object.assign(Object.create(null),{debugModule:()=>{}});delete globalThis.sqlite3InitModuleState,o.debugModule("globalThis.location =",globalThis.location);const a="emscripten-bug-17951";i[a]=function e(t,n){t.env.foo=function(){};const r=i.locateFile(e.uri,void 0===m?"":m);o.debugModule("instantiateWasm() uri =",r);const s=()=>fetch(r,{credentials:"same-origin"});return(WebAssembly.instantiateStreaming?async()=>WebAssembly.instantiateStreaming(s(),t).then((e=>n(e.instance,e.module))):async()=>s().then((e=>e.arrayBuffer())).then((e=>WebAssembly.instantiate(e,t))).then((e=>n(e.instance,e.module))))(),{}},i[a].uri="sqlite3.wasm";var l,c,u,_=Object.assign({},i),p="./this.program",f="object"==typeof window,d="function"==typeof importScripts,m="";(f||d)&&(d?m=self.location.href:"undefined"!=typeof document&&document.currentScript&&(m=document.currentScript.src),e&&(m=e),m=0!==m.indexOf("blob:")?m.substr(0,m.replace(/[?#].*/,"").lastIndexOf("/")+1):"",l=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},d&&(u=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),c=(e,t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):n()},r.onerror=n,r.send(null)});var h,g,q=i.print||console.log.bind(console),y=i.printErr||console.warn.bind(console);Object.assign(i,_),_=null,i.thisProgram&&(p=i.thisProgram),i.wasmBinary&&(h=i.wasmBinary),"object"!=typeof WebAssembly&&H("no native wasm support detected");var b,w,E,S,x,A=!1,I="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function T(e,t,n){for(var r=t+n,s=t;e[s]&&!(s>=r);)++s;if(s-t>16&&e.buffer&&I)return I.decode(e.subarray(t,s));for(var i="";t<s;){var o=e[t++];if(128&o){var a=63&e[t++];if(192!=(224&o)){var l=63&e[t++];if((o=224==(240&o)?(15&o)<<12|a<<6|l:(7&o)<<18|a<<12|l<<6|63&e[t++])<65536)i+=String.fromCharCode(o);else{var c=o-65536;i+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else i+=String.fromCharCode((31&o)<<6|a)}else i+=String.fromCharCode(o)}return i}function k(e,t,n,r){if(!(r>0))return 0;for(var s=n,i=n+r-1,o=0;o<e.length;++o){var a=e.charCodeAt(o);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++o)),a<=127){if(n>=i)break;t[n++]=a}else if(a<=2047){if(n+1>=i)break;t[n++]=192|a>>6,t[n++]=128|63&a}else if(a<=65535){if(n+2>=i)break;t[n++]=224|a>>12,t[n++]=128|a>>6&63,t[n++]=128|63&a}else{if(n+3>=i)break;t[n++]=240|a>>18,t[n++]=128|a>>12&63,t[n++]=128|a>>6&63,t[n++]=128|63&a}}return t[n]=0,n-s}function F(e,t,n){return k(e,w,t,n)}function O(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);r<=127?t++:r<=2047?t+=2:r>=55296&&r<=57343?(t+=4,++n):t+=3}return t}function P(){var e=g.buffer;i.HEAP8=b=new Int8Array(e),i.HEAP16=E=new Int16Array(e),i.HEAP32=S=new Int32Array(e),i.HEAPU8=w=new Uint8Array(e),i.HEAPU16=new Uint16Array(e),i.HEAPU32=x=new Uint32Array(e),i.HEAPF32=new Float32Array(e),i.HEAPF64=new Float64Array(e),i.HEAP64=new BigInt64Array(e),i.HEAPU64=new BigUint64Array(e)}var L=i.INITIAL_MEMORY||16777216;g=i.wasmMemory?i.wasmMemory:new WebAssembly.Memory({initial:L/65536,maximum:32768}),P(),L=g.buffer.byteLength;var C,D,N,R,j=[],M=[],z=[],B=0,U=null;function Q(e){B++,i.monitorRunDependencies&&i.monitorRunDependencies(B)}function W(e){if(B--,i.monitorRunDependencies&&i.monitorRunDependencies(B),0==B&&U){var t=U;U=null,t()}}function H(e){i.onAbort&&i.onAbort(e),y(e="Aborted("+e+")"),A=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw r(t),t}function V(e){return e.startsWith("data:application/octet-stream;base64,")}function G(e){try{if(e==C&&h)return new Uint8Array(h);if(u)return u(e);throw"both async and sync fetching of the wasm failed"}catch(e){H(e)}}function $(e){for(;e.length>0;)e.shift()(i)}i.locateFile?V(C="sqlite3.wasm")||(D=C,C=i.locateFile?i.locateFile(D,m):m+D):C=new URL("sqlite3.wasm",import.meta.url).href;var K={isAbs:e=>"/"===e.charAt(0),splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var n=0,r=e.length-1;r>=0;r--){var s=e[r];"."===s?e.splice(r,1):".."===s?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n;n--)e.unshift("..");return e},normalize:e=>{var t=K.isAbs(e),n="/"===e.substr(-1);return(e=K.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e},dirname:e=>{var t=K.splitPath(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},basename:e=>{if("/"===e)return"/";var t=(e=(e=K.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},join:function(){var e=Array.prototype.slice.call(arguments);return K.normalize(e.join("/"))},join2:(e,t)=>K.normalize(e+"/"+t)},J={resolve:function(){for(var e="",t=!1,n=arguments.length-1;n>=-1&&!t;n--){var r=n>=0?arguments[n]:ne.cwd();if("string"!=typeof r)throw new TypeError("Arguments to path.resolve must be strings");if(!r)return"";e=r+"/"+e,t=K.isAbs(r)}return(t?"/":"")+(e=K.normalizeArray(e.split("/").filter((e=>!!e)),!t).join("/"))||"."},relative:(e,t)=>{function n(e){for(var t=0;t<e.length&&""===e[t];t++);for(var n=e.length-1;n>=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=J.resolve(e).substr(1),t=J.resolve(t).substr(1);for(var r=n(e.split("/")),s=n(t.split("/")),i=Math.min(r.length,s.length),o=i,a=0;a<i;a++)if(r[a]!==s[a]){o=a;break}var l=[];for(a=o;a<r.length;a++)l.push("..");return(l=l.concat(s.slice(o))).join("/")}};function X(e,t,n){var r=O(e)+1,s=new Array(r),i=k(e,s,0,s.length);return s.length=i,s}var Y={ttys:[],init:function(){},shutdown:function(){},register:function(e,t){Y.ttys[e]={input:[],output:[],ops:t},ne.registerDevice(e,Y.stream_ops)},stream_ops:{open:function(e){var t=Y.ttys[e.node.rdev];if(!t)throw new ne.ErrnoError(43);e.tty=t,e.seekable=!1},close:function(e){e.tty.ops.fsync(e.tty)},fsync:function(e){e.tty.ops.fsync(e.tty)},read:function(e,t,n,r,s){if(!e.tty||!e.tty.ops.get_char)throw new ne.ErrnoError(60);for(var i=0,o=0;o<r;o++){var a;try{a=e.tty.ops.get_char(e.tty)}catch(e){throw new ne.ErrnoError(29)}if(void 0===a&&0===i)throw new ne.ErrnoError(6);if(null==a)break;i++,t[n+o]=a}return i&&(e.node.timestamp=Date.now()),i},write:function(e,t,n,r,s){if(!e.tty||!e.tty.ops.put_char)throw new ne.ErrnoError(60);try{for(var i=0;i<r;i++)e.tty.ops.put_char(e.tty,t[n+i])}catch(e){throw new ne.ErrnoError(29)}return r&&(e.node.timestamp=Date.now()),i}},default_tty_ops:{get_char:function(e){if(!e.input.length){var t=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(t=window.prompt("Input: "))&&(t+="\n"):"function"==typeof readline&&null!==(t=readline())&&(t+="\n"),!t)return null;e.input=X(t)}return e.input.shift()},put_char:function(e,t){null===t||10===t?(q(T(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(q(T(e.output,0)),e.output=[])}},default_tty1_ops:{put_char:function(e,t){null===t||10===t?(y(T(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},fsync:function(e){e.output&&e.output.length>0&&(y(T(e.output,0)),e.output=[])}}};function Z(e){e=function(e,t){return Math.ceil(e/t)*t}(e,65536);var t=be(65536,e);return t?function(e,t){return w.fill(0,e,e+t),e}(t,e):0}var ee={ops_table:null,mount:function(e){return ee.createNode(null,"/",16895,0)},createNode:function(e,t,n,r){if(ne.isBlkdev(n)||ne.isFIFO(n))throw new ne.ErrnoError(63);ee.ops_table||(ee.ops_table={dir:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr,lookup:ee.node_ops.lookup,mknod:ee.node_ops.mknod,rename:ee.node_ops.rename,unlink:ee.node_ops.unlink,rmdir:ee.node_ops.rmdir,readdir:ee.node_ops.readdir,symlink:ee.node_ops.symlink},stream:{llseek:ee.stream_ops.llseek}},file:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr},stream:{llseek:ee.stream_ops.llseek,read:ee.stream_ops.read,write:ee.stream_ops.write,allocate:ee.stream_ops.allocate,mmap:ee.stream_ops.mmap,msync:ee.stream_ops.msync}},link:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr,readlink:ee.node_ops.readlink},stream:{}},chrdev:{node:{getattr:ee.node_ops.getattr,setattr:ee.node_ops.setattr},stream:ne.chrdev_stream_ops}});var s=ne.createNode(e,t,n,r);return ne.isDir(s.mode)?(s.node_ops=ee.ops_table.dir.node,s.stream_ops=ee.ops_table.dir.stream,s.contents={}):ne.isFile(s.mode)?(s.node_ops=ee.ops_table.file.node,s.stream_ops=ee.ops_table.file.stream,s.usedBytes=0,s.contents=null):ne.isLink(s.mode)?(s.node_ops=ee.ops_table.link.node,s.stream_ops=ee.ops_table.link.stream):ne.isChrdev(s.mode)&&(s.node_ops=ee.ops_table.chrdev.node,s.stream_ops=ee.ops_table.chrdev.stream),s.timestamp=Date.now(),e&&(e.contents[t]=s,e.timestamp=s.timestamp),s},getFileDataAsTypedArray:function(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage:function(e,t){var n=e.contents?e.contents.length:0;if(!(n>=t)){t=Math.max(t,n*(n<1048576?2:1.125)>>>0),0!=n&&(t=Math.max(t,256));var r=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(r.subarray(0,e.usedBytes),0)}},resizeFileStorage:function(e,t){if(e.usedBytes!=t)if(0==t)e.contents=null,e.usedBytes=0;else{var n=e.contents;e.contents=new Uint8Array(t),n&&e.contents.set(n.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr:function(e){var t={};return t.dev=ne.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,ne.isDir(e.mode)?t.size=4096:ne.isFile(e.mode)?t.size=e.usedBytes:ne.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr:function(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&ee.resizeFileStorage(e,t.size)},lookup:function(e,t){throw ne.genericErrors[44]},mknod:function(e,t,n,r){return ee.createNode(e,t,n,r)},rename:function(e,t,n){if(ne.isDir(e.mode)){var r;try{r=ne.lookupNode(t,n)}catch(e){}if(r)for(var s in r.contents)throw new ne.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=n,t.contents[n]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink:function(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir:function(e,t){var n=ne.lookupNode(e,t);for(var r in n.contents)throw new ne.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir:function(e){var t=[".",".."];for(var n in e.contents)e.contents.hasOwnProperty(n)&&t.push(n);return t},symlink:function(e,t,n){var r=ee.createNode(e,t,41471,0);return r.link=n,r},readlink:function(e){if(!ne.isLink(e.mode))throw new ne.ErrnoError(28);return e.link}},stream_ops:{read:function(e,t,n,r,s){var i=e.node.contents;if(s>=e.node.usedBytes)return 0;var o=Math.min(e.node.usedBytes-s,r);if(o>8&&i.subarray)t.set(i.subarray(s,s+o),n);else for(var a=0;a<o;a++)t[n+a]=i[s+a];return o},write:function(e,t,n,r,s,i){if(t.buffer===b.buffer&&(i=!1),!r)return 0;var o=e.node;if(o.timestamp=Date.now(),t.subarray&&(!o.contents||o.contents.subarray)){if(i)return o.contents=t.subarray(n,n+r),o.usedBytes=r,r;if(0===o.usedBytes&&0===s)return o.contents=t.slice(n,n+r),o.usedBytes=r,r;if(s+r<=o.usedBytes)return o.contents.set(t.subarray(n,n+r),s),r}if(ee.expandFileStorage(o,s+r),o.contents.subarray&&t.subarray)o.contents.set(t.subarray(n,n+r),s);else for(var a=0;a<r;a++)o.contents[s+a]=t[n+a];return o.usedBytes=Math.max(o.usedBytes,s+r),r},llseek:function(e,t,n){var r=t;if(1===n?r+=e.position:2===n&&ne.isFile(e.node.mode)&&(r+=e.node.usedBytes),r<0)throw new ne.ErrnoError(28);return r},allocate:function(e,t,n){ee.expandFileStorage(e.node,t+n),e.node.usedBytes=Math.max(e.node.usedBytes,t+n)},mmap:function(e,t,n,r,s){if(!ne.isFile(e.node.mode))throw new ne.ErrnoError(43);var i,o,a=e.node.contents;if(2&s||a.buffer!==b.buffer){if((n>0||n+t<a.length)&&(a=a.subarray?a.subarray(n,n+t):Array.prototype.slice.call(a,n,n+t)),o=!0,!(i=Z(t)))throw new ne.ErrnoError(48);b.set(a,i)}else o=!1,i=a.byteOffset;return{ptr:i,allocated:o}},msync:function(e,t,n,r,s){return ee.stream_ops.write(e,t,0,r,n,!1),0}}};function te(e,t,n,r){var s="al "+e;c(e,(n=>{var r;r='Loading data file "'+e+'" failed (no arrayBuffer).',n||H(r),t(new Uint8Array(n)),s&&W()}),(t=>{if(!n)throw'Loading data file "'+e+'" failed.';n()})),s&&Q()}var ne={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:(e,t={})=>{if(!(e=J.resolve(e)))return{path:"",node:null};if((t=Object.assign({follow_mount:!0,recurse_count:0},t)).recurse_count>8)throw new ne.ErrnoError(32);for(var n=e.split("/").filter((e=>!!e)),r=ne.root,s="/",i=0;i<n.length;i++){var o=i===n.length-1;if(o&&t.parent)break;if(r=ne.lookupNode(r,n[i]),s=K.join2(s,n[i]),ne.isMountpoint(r)&&(!o||o&&t.follow_mount)&&(r=r.mounted.root),!o||t.follow)for(var a=0;ne.isLink(r.mode);){var l=ne.readlink(s);if(s=J.resolve(K.dirname(s),l),r=ne.lookupPath(s,{recurse_count:t.recurse_count+1}).node,a++>40)throw new ne.ErrnoError(32)}}return{path:s,node:r}},getPath:e=>{for(var t;;){if(ne.isRoot(e)){var n=e.mount.mountpoint;return t?"/"!==n[n.length-1]?n+"/"+t:n+t:n}t=t?e.name+"/"+t:e.name,e=e.parent}},hashName:(e,t)=>{for(var n=0,r=0;r<t.length;r++)n=(n<<5)-n+t.charCodeAt(r)|0;return(e+n>>>0)%ne.nameTable.length},hashAddNode:e=>{var t=ne.hashName(e.parent.id,e.name);e.name_next=ne.nameTable[t],ne.nameTable[t]=e},hashRemoveNode:e=>{var t=ne.hashName(e.parent.id,e.name);if(ne.nameTable[t]===e)ne.nameTable[t]=e.name_next;else for(var n=ne.nameTable[t];n;){if(n.name_next===e){n.name_next=e.name_next;break}n=n.name_next}},lookupNode:(e,t)=>{var n=ne.mayLookup(e);if(n)throw new ne.ErrnoError(n,e);for(var r=ne.hashName(e.id,t),s=ne.nameTable[r];s;s=s.name_next){var i=s.name;if(s.parent.id===e.id&&i===t)return s}return ne.lookup(e,t)},createNode:(e,t,n,r)=>{var s=new ne.FSNode(e,t,n,r);return ne.hashAddNode(s),s},destroyNode:e=>{ne.hashRemoveNode(e)},isRoot:e=>e===e.parent,isMountpoint:e=>!!e.mounted,isFile:e=>32768==(61440&e),isDir:e=>16384==(61440&e),isLink:e=>40960==(61440&e),isChrdev:e=>8192==(61440&e),isBlkdev:e=>24576==(61440&e),isFIFO:e=>4096==(61440&e),isSocket:e=>!(49152&~e),flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:e=>{var t=ne.flagModes[e];if(void 0===t)throw new Error("Unknown file open mode: "+e);return t},flagsToPermissionString:e=>{var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:(e,t)=>ne.ignorePermissions||(!t.includes("r")||292&e.mode)&&(!t.includes("w")||146&e.mode)&&(!t.includes("x")||73&e.mode)?0:2,mayLookup:e=>{var t=ne.nodePermissions(e,"x");return t||(e.node_ops.lookup?0:2)},mayCreate:(e,t)=>{try{return ne.lookupNode(e,t),20}catch(e){}return ne.nodePermissions(e,"wx")},mayDelete:(e,t,n)=>{var r;try{r=ne.lookupNode(e,t)}catch(e){return e.errno}var s=ne.nodePermissions(e,"wx");if(s)return s;if(n){if(!ne.isDir(r.mode))return 54;if(ne.isRoot(r)||ne.getPath(r)===ne.cwd())return 10}else if(ne.isDir(r.mode))return 31;return 0},mayOpen:(e,t)=>e?ne.isLink(e.mode)?32:ne.isDir(e.mode)&&("r"!==ne.flagsToPermissionString(t)||512&t)?31:ne.nodePermissions(e,ne.flagsToPermissionString(t)):44,MAX_OPEN_FDS:4096,nextfd:(e=0,t=ne.MAX_OPEN_FDS)=>{for(var n=e;n<=t;n++)if(!ne.streams[n])return n;throw new ne.ErrnoError(33)},getStream:e=>ne.streams[e],createStream:(e,t,n)=>{ne.FSStream||(ne.FSStream=function(){this.shared={}},ne.FSStream.prototype={},Object.defineProperties(ne.FSStream.prototype,{object:{get:function(){return this.node},set:function(e){this.node=e}},isRead:{get:function(){return 1!=(2097155&this.flags)}},isWrite:{get:function(){return!!(2097155&this.flags)}},isAppend:{get:function(){return 1024&this.flags}},flags:{get:function(){return this.shared.flags},set:function(e){this.shared.flags=e}},position:{get:function(){return this.shared.position},set:function(e){this.shared.position=e}}})),e=Object.assign(new ne.FSStream,e);var r=ne.nextfd(t,n);return e.fd=r,ne.streams[r]=e,e},closeStream:e=>{ne.streams[e]=null},chrdev_stream_ops:{open:e=>{var t=ne.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:()=>{throw new ne.ErrnoError(70)}},major:e=>e>>8,minor:e=>255&e,makedev:(e,t)=>e<<8|t,registerDevice:(e,t)=>{ne.devices[e]={stream_ops:t}},getDevice:e=>ne.devices[e],getMounts:e=>{for(var t=[],n=[e];n.length;){var r=n.pop();t.push(r),n.push.apply(n,r.mounts)}return t},syncfs:(e,t)=>{"function"==typeof e&&(t=e,e=!1),ne.syncFSRequests++,ne.syncFSRequests>1&&y("warning: "+ne.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work");var n=ne.getMounts(ne.root.mount),r=0;function s(e){return ne.syncFSRequests--,t(e)}function i(e){if(e)return i.errored?void 0:(i.errored=!0,s(e));++r>=n.length&&s(null)}n.forEach((t=>{if(!t.type.syncfs)return i(null);t.type.syncfs(t,e,i)}))},mount:(e,t,n)=>{var r,s="/"===n,i=!n;if(s&&ne.root)throw new ne.ErrnoError(10);if(!s&&!i){var o=ne.lookupPath(n,{follow_mount:!1});if(n=o.path,r=o.node,ne.isMountpoint(r))throw new ne.ErrnoError(10);if(!ne.isDir(r.mode))throw new ne.ErrnoError(54)}var a={type:e,opts:t,mountpoint:n,mounts:[]},l=e.mount(a);return l.mount=a,a.root=l,s?ne.root=l:r&&(r.mounted=a,r.mount&&r.mount.mounts.push(a)),l},unmount:e=>{var t=ne.lookupPath(e,{follow_mount:!1});if(!ne.isMountpoint(t.node))throw new ne.ErrnoError(28);var n=t.node,r=n.mounted,s=ne.getMounts(r);Object.keys(ne.nameTable).forEach((e=>{for(var t=ne.nameTable[e];t;){var n=t.name_next;s.includes(t.mount)&&ne.destroyNode(t),t=n}})),n.mounted=null;var i=n.mount.mounts.indexOf(r);n.mount.mounts.splice(i,1)},lookup:(e,t)=>e.node_ops.lookup(e,t),mknod:(e,t,n)=>{var r=ne.lookupPath(e,{parent:!0}).node,s=K.basename(e);if(!s||"."===s||".."===s)throw new ne.ErrnoError(28);var i=ne.mayCreate(r,s);if(i)throw new ne.ErrnoError(i);if(!r.node_ops.mknod)throw new ne.ErrnoError(63);return r.node_ops.mknod(r,s,t,n)},create:(e,t)=>(t=void 0!==t?t:438,t&=4095,t|=32768,ne.mknod(e,t,0)),mkdir:(e,t)=>(t=void 0!==t?t:511,t&=1023,t|=16384,ne.mknod(e,t,0)),mkdirTree:(e,t)=>{for(var n=e.split("/"),r="",s=0;s<n.length;++s)if(n[s]){r+="/"+n[s];try{ne.mkdir(r,t)}catch(e){if(20!=e.errno)throw e}}},mkdev:(e,t,n)=>(void 0===n&&(n=t,t=438),t|=8192,ne.mknod(e,t,n)),symlink:(e,t)=>{if(!J.resolve(e))throw new ne.ErrnoError(44);var n=ne.lookupPath(t,{parent:!0}).node;if(!n)throw new ne.ErrnoError(44);var r=K.basename(t),s=ne.mayCreate(n,r);if(s)throw new ne.ErrnoError(s);if(!n.node_ops.symlink)throw new ne.ErrnoError(63);return n.node_ops.symlink(n,r,e)},rename:(e,t)=>{var n,r,s=K.dirname(e),i=K.dirname(t),o=K.basename(e),a=K.basename(t);if(n=ne.lookupPath(e,{parent:!0}).node,r=ne.lookupPath(t,{parent:!0}).node,!n||!r)throw new ne.ErrnoError(44);if(n.mount!==r.mount)throw new ne.ErrnoError(75);var l,c=ne.lookupNode(n,o),u=J.relative(e,i);if("."!==u.charAt(0))throw new ne.ErrnoError(28);if("."!==(u=J.relative(t,s)).charAt(0))throw new ne.ErrnoError(55);try{l=ne.lookupNode(r,a)}catch(e){}if(c!==l){var _=ne.isDir(c.mode),p=ne.mayDelete(n,o,_);if(p)throw new ne.ErrnoError(p);if(p=l?ne.mayDelete(r,a,_):ne.mayCreate(r,a))throw new ne.ErrnoError(p);if(!n.node_ops.rename)throw new ne.ErrnoError(63);if(ne.isMountpoint(c)||l&&ne.isMountpoint(l))throw new ne.ErrnoError(10);if(r!==n&&(p=ne.nodePermissions(n,"w")))throw new ne.ErrnoError(p);ne.hashRemoveNode(c);try{n.node_ops.rename(c,r,a)}catch(e){throw e}finally{ne.hashAddNode(c)}}},rmdir:e=>{var t=ne.lookupPath(e,{parent:!0}).node,n=K.basename(e),r=ne.lookupNode(t,n),s=ne.mayDelete(t,n,!0);if(s)throw new ne.ErrnoError(s);if(!t.node_ops.rmdir)throw new ne.ErrnoError(63);if(ne.isMountpoint(r))throw new ne.ErrnoError(10);t.node_ops.rmdir(t,n),ne.destroyNode(r)},readdir:e=>{var t=ne.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new ne.ErrnoError(54);return t.node_ops.readdir(t)},unlink:e=>{var t=ne.lookupPath(e,{parent:!0}).node;if(!t)throw new ne.ErrnoError(44);var n=K.basename(e),r=ne.lookupNode(t,n),s=ne.mayDelete(t,n,!1);if(s)throw new ne.ErrnoError(s);if(!t.node_ops.unlink)throw new ne.ErrnoError(63);if(ne.isMountpoint(r))throw new ne.ErrnoError(10);t.node_ops.unlink(t,n),ne.destroyNode(r)},readlink:e=>{var t=ne.lookupPath(e).node;if(!t)throw new ne.ErrnoError(44);if(!t.node_ops.readlink)throw new ne.ErrnoError(28);return J.resolve(ne.getPath(t.parent),t.node_ops.readlink(t))},stat:(e,t)=>{var n=ne.lookupPath(e,{follow:!t}).node;if(!n)throw new ne.ErrnoError(44);if(!n.node_ops.getattr)throw new ne.ErrnoError(63);return n.node_ops.getattr(n)},lstat:e=>ne.stat(e,!0),chmod:(e,t,n)=>{var r;if(!(r="string"==typeof e?ne.lookupPath(e,{follow:!n}).node:e).node_ops.setattr)throw new ne.ErrnoError(63);r.node_ops.setattr(r,{mode:4095&t|-4096&r.mode,timestamp:Date.now()})},lchmod:(e,t)=>{ne.chmod(e,t,!0)},fchmod:(e,t)=>{var n=ne.getStream(e);if(!n)throw new ne.ErrnoError(8);ne.chmod(n.node,t)},chown:(e,t,n,r)=>{var s;if(!(s="string"==typeof e?ne.lookupPath(e,{follow:!r}).node:e).node_ops.setattr)throw new ne.ErrnoError(63);s.node_ops.setattr(s,{timestamp:Date.now()})},lchown:(e,t,n)=>{ne.chown(e,t,n,!0)},fchown:(e,t,n)=>{var r=ne.getStream(e);if(!r)throw new ne.ErrnoError(8);ne.chown(r.node,t,n)},truncate:(e,t)=>{if(t<0)throw new ne.ErrnoError(28);var n;if(!(n="string"==typeof e?ne.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new ne.ErrnoError(63);if(ne.isDir(n.mode))throw new ne.ErrnoError(31);if(!ne.isFile(n.mode))throw new ne.ErrnoError(28);var r=ne.nodePermissions(n,"w");if(r)throw new ne.ErrnoError(r);n.node_ops.setattr(n,{size:t,timestamp:Date.now()})},ftruncate:(e,t)=>{var n=ne.getStream(e);if(!n)throw new ne.ErrnoError(8);if(!(2097155&n.flags))throw new ne.ErrnoError(28);ne.truncate(n.node,t)},utime:(e,t,n)=>{var r=ne.lookupPath(e,{follow:!0}).node;r.node_ops.setattr(r,{timestamp:Math.max(t,n)})},open:(e,t,n)=>{if(""===e)throw new ne.ErrnoError(44);var r;if(n=void 0===n?438:n,n=64&(t="string"==typeof t?ne.modeStringToFlags(t):t)?4095&n|32768:0,"object"==typeof e)r=e;else{e=K.normalize(e);try{r=ne.lookupPath(e,{follow:!(131072&t)}).node}catch(e){}}var s=!1;if(64&t)if(r){if(128&t)throw new ne.ErrnoError(20)}else r=ne.mknod(e,n,0),s=!0;if(!r)throw new ne.ErrnoError(44);if(ne.isChrdev(r.mode)&&(t&=-513),65536&t&&!ne.isDir(r.mode))throw new ne.ErrnoError(54);if(!s){var o=ne.mayOpen(r,t);if(o)throw new ne.ErrnoError(o)}512&t&&!s&&ne.truncate(r,0),t&=-131713;var a=ne.createStream({node:r,path:ne.getPath(r),flags:t,seekable:!0,position:0,stream_ops:r.stream_ops,ungotten:[],error:!1});return a.stream_ops.open&&a.stream_ops.open(a),!i.logReadFiles||1&t||(ne.readFiles||(ne.readFiles={}),e in ne.readFiles||(ne.readFiles[e]=1)),a},close:e=>{if(ne.isClosed(e))throw new ne.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{ne.closeStream(e.fd)}e.fd=null},isClosed:e=>null===e.fd,llseek:(e,t,n)=>{if(ne.isClosed(e))throw new ne.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new ne.ErrnoError(70);if(0!=n&&1!=n&&2!=n)throw new ne.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,n),e.ungotten=[],e.position},read:(e,t,n,r,s)=>{if(r<0||s<0)throw new ne.ErrnoError(28);if(ne.isClosed(e))throw new ne.ErrnoError(8);if(1==(2097155&e.flags))throw new ne.ErrnoError(8);if(ne.isDir(e.node.mode))throw new ne.ErrnoError(31);if(!e.stream_ops.read)throw new ne.ErrnoError(28);var i=void 0!==s;if(i){if(!e.seekable)throw new ne.ErrnoError(70)}else s=e.position;var o=e.stream_ops.read(e,t,n,r,s);return i||(e.position+=o),o},write:(e,t,n,r,s,i)=>{if(r<0||s<0)throw new ne.ErrnoError(28);if(ne.isClosed(e))throw new ne.ErrnoError(8);if(!(2097155&e.flags))throw new ne.ErrnoError(8);if(ne.isDir(e.node.mode))throw new ne.ErrnoError(31);if(!e.stream_ops.write)throw new ne.ErrnoError(28);e.seekable&&1024&e.flags&&ne.llseek(e,0,2);var o=void 0!==s;if(o){if(!e.seekable)throw new ne.ErrnoError(70)}else s=e.position;var a=e.stream_ops.write(e,t,n,r,s,i);return o||(e.position+=a),a},allocate:(e,t,n)=>{if(ne.isClosed(e))throw new ne.ErrnoError(8);if(t<0||n<=0)throw new ne.ErrnoError(28);if(!(2097155&e.flags))throw new ne.ErrnoError(8);if(!ne.isFile(e.node.mode)&&!ne.isDir(e.node.mode))throw new ne.ErrnoError(43);if(!e.stream_ops.allocate)throw new ne.ErrnoError(138);e.stream_ops.allocate(e,t,n)},mmap:(e,t,n,r,s)=>{if(2&r&&!(2&s)&&2!=(2097155&e.flags))throw new ne.ErrnoError(2);if(1==(2097155&e.flags))throw new ne.ErrnoError(2);if(!e.stream_ops.mmap)throw new ne.ErrnoError(43);return e.stream_ops.mmap(e,t,n,r,s)},msync:(e,t,n,r,s)=>e.stream_ops.msync?e.stream_ops.msync(e,t,n,r,s):0,munmap:e=>0,ioctl:(e,t,n)=>{if(!e.stream_ops.ioctl)throw new ne.ErrnoError(59);return e.stream_ops.ioctl(e,t,n)},readFile:(e,t={})=>{if(t.flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error('Invalid encoding type "'+t.encoding+'"');var n,r=ne.open(e,t.flags),s=ne.stat(e).size,i=new Uint8Array(s);return ne.read(r,i,0,s,0),"utf8"===t.encoding?n=T(i,0):"binary"===t.encoding&&(n=i),ne.close(r),n},writeFile:(e,t,n={})=>{n.flags=n.flags||577;var r=ne.open(e,n.flags,n.mode);if("string"==typeof t){var s=new Uint8Array(O(t)+1),i=k(t,s,0,s.length);ne.write(r,s,0,i,void 0,n.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");ne.write(r,t,0,t.byteLength,void 0,n.canOwn)}ne.close(r)},cwd:()=>ne.currentPath,chdir:e=>{var t=ne.lookupPath(e,{follow:!0});if(null===t.node)throw new ne.ErrnoError(44);if(!ne.isDir(t.node.mode))throw new ne.ErrnoError(54);var n=ne.nodePermissions(t.node,"x");if(n)throw new ne.ErrnoError(n);ne.currentPath=t.path},createDefaultDirectories:()=>{ne.mkdir("/tmp"),ne.mkdir("/home"),ne.mkdir("/home/web_user")},createDefaultDevices:()=>{ne.mkdir("/dev"),ne.registerDevice(ne.makedev(1,3),{read:()=>0,write:(e,t,n,r,s)=>r}),ne.mkdev("/dev/null",ne.makedev(1,3)),Y.register(ne.makedev(5,0),Y.default_tty_ops),Y.register(ne.makedev(6,0),Y.default_tty1_ops),ne.mkdev("/dev/tty",ne.makedev(5,0)),ne.mkdev("/dev/tty1",ne.makedev(6,0));var e=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return()=>(crypto.getRandomValues(e),e[0])}return()=>H("randomDevice")}();ne.createDevice("/dev","random",e),ne.createDevice("/dev","urandom",e),ne.mkdir("/dev/shm"),ne.mkdir("/dev/shm/tmp")},createSpecialDirectories:()=>{ne.mkdir("/proc");var e=ne.mkdir("/proc/self");ne.mkdir("/proc/self/fd"),ne.mount({mount:()=>{var t=ne.createNode(e,"fd",16895,73);return t.node_ops={lookup:(e,t)=>{var n=+t,r=ne.getStream(n);if(!r)throw new ne.ErrnoError(8);var s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>r.path}};return s.parent=s,s}},t}},{},"/proc/self/fd")},createStandardStreams:()=>{i.stdin?ne.createDevice("/dev","stdin",i.stdin):ne.symlink("/dev/tty","/dev/stdin"),i.stdout?ne.createDevice("/dev","stdout",null,i.stdout):ne.symlink("/dev/tty","/dev/stdout"),i.stderr?ne.createDevice("/dev","stderr",null,i.stderr):ne.symlink("/dev/tty1","/dev/stderr"),ne.open("/dev/stdin",0),ne.open("/dev/stdout",1),ne.open("/dev/stderr",1)},ensureErrnoError:()=>{ne.ErrnoError||(ne.ErrnoError=function(e,t){this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},ne.ErrnoError.prototype=new Error,ne.ErrnoError.prototype.constructor=ne.ErrnoError,[44].forEach((e=>{ne.genericErrors[e]=new ne.ErrnoError(e),ne.genericErrors[e].stack="<generic error, no stack>"})))},staticInit:()=>{ne.ensureErrnoError(),ne.nameTable=new Array(4096),ne.mount(ee,{},"/"),ne.createDefaultDirectories(),ne.createDefaultDevices(),ne.createSpecialDirectories(),ne.filesystems={MEMFS:ee}},init:(e,t,n)=>{ne.init.initialized=!0,ne.ensureErrnoError(),i.stdin=e||i.stdin,i.stdout=t||i.stdout,i.stderr=n||i.stderr,ne.createStandardStreams()},quit:()=>{ne.init.initialized=!1;for(var e=0;e<ne.streams.length;e++){var t=ne.streams[e];t&&ne.close(t)}},getMode:(e,t)=>{var n=0;return e&&(n|=365),t&&(n|=146),n},findObject:(e,t)=>{var n=ne.analyzePath(e,t);return n.exists?n.object:null},analyzePath:(e,t)=>{try{e=(r=ne.lookupPath(e,{follow:!t})).path}catch(e){}var n={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var r=ne.lookupPath(e,{parent:!0});n.parentExists=!0,n.parentPath=r.path,n.parentObject=r.node,n.name=K.basename(e),r=ne.lookupPath(e,{follow:!t}),n.exists=!0,n.path=r.path,n.object=r.node,n.name=r.node.name,n.isRoot="/"===r.path}catch(e){n.error=e.errno}return n},createPath:(e,t,n,r)=>{e="string"==typeof e?e:ne.getPath(e);for(var s=t.split("/").reverse();s.length;){var i=s.pop();if(i){var o=K.join2(e,i);try{ne.mkdir(o)}catch(e){}e=o}}return o},createFile:(e,t,n,r,s)=>{var i=K.join2("string"==typeof e?e:ne.getPath(e),t),o=ne.getMode(r,s);return ne.create(i,o)},createDataFile:(e,t,n,r,s,i)=>{var o=t;e&&(e="string"==typeof e?e:ne.getPath(e),o=t?K.join2(e,t):e);var a=ne.getMode(r,s),l=ne.create(o,a);if(n){if("string"==typeof n){for(var c=new Array(n.length),u=0,_=n.length;u<_;++u)c[u]=n.charCodeAt(u);n=c}ne.chmod(l,146|a);var p=ne.open(l,577);ne.write(p,n,0,n.length,0,i),ne.close(p),ne.chmod(l,a)}return l},createDevice:(e,t,n,r)=>{var s=K.join2("string"==typeof e?e:ne.getPath(e),t),i=ne.getMode(!!n,!!r);ne.createDevice.major||(ne.createDevice.major=64);var o=ne.makedev(ne.createDevice.major++,0);return ne.registerDevice(o,{open:e=>{e.seekable=!1},close:e=>{r&&r.buffer&&r.buffer.length&&r(10)},read:(e,t,r,s,i)=>{for(var o=0,a=0;a<s;a++){var l;try{l=n()}catch(e){throw new ne.ErrnoError(29)}if(void 0===l&&0===o)throw new ne.ErrnoError(6);if(null==l)break;o++,t[r+a]=l}return o&&(e.node.timestamp=Date.now()),o},write:(e,t,n,s,i)=>{for(var o=0;o<s;o++)try{r(t[n+o])}catch(e){throw new ne.ErrnoError(29)}return s&&(e.node.timestamp=Date.now()),o}}),ne.mkdev(s,i,o)},forceLoadFile:e=>{if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!l)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=X(l(e.url)),e.usedBytes=e.contents.length}catch(e){throw new ne.ErrnoError(29)}},createLazyFile:(e,t,n,r,s)=>{function i(){this.lengthKnown=!1,this.chunks=[]}if(i.prototype.get=function(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,n=e/this.chunkSize|0;return this.getter(n)[t]}},i.prototype.setDataGetter=function(e){this.getter=e},i.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",n,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+n+". Status: "+e.status);var t,r=Number(e.getResponseHeader("Content-length")),s=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,i=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,o=1048576;s||(o=r);var a=this;a.setDataGetter((e=>{var t=e*o,s=(e+1)*o-1;if(s=Math.min(s,r-1),void 0===a.chunks[e]&&(a.chunks[e]=((e,t)=>{if(e>t)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(t>r-1)throw new Error("only "+r+" bytes available! programmer error!");var s=new XMLHttpRequest;if(s.open("GET",n,!1),r!==o&&s.setRequestHeader("Range","bytes="+e+"-"+t),s.responseType="arraybuffer",s.overrideMimeType&&s.overrideMimeType("text/plain; charset=x-user-defined"),s.send(null),!(s.status>=200&&s.status<300||304===s.status))throw new Error("Couldn't load "+n+". Status: "+s.status);return void 0!==s.response?new Uint8Array(s.response||[]):X(s.responseText||"")})(t,s)),void 0===a.chunks[e])throw new Error("doXHR failed!");return a.chunks[e]})),!i&&r||(o=r=1,r=this.getter(0).length,o=r,q("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=r,this._chunkSize=o,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest){if(!d)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var o=new i;Object.defineProperties(o,{length:{get:function(){return this.lengthKnown||this.cacheLength(),this._length}},chunkSize:{get:function(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}});var a={isDevice:!1,contents:o}}else a={isDevice:!1,url:n};var l=ne.createFile(e,t,a,r,s);a.contents?l.contents=a.contents:a.url&&(l.contents=null,l.url=a.url),Object.defineProperties(l,{usedBytes:{get:function(){return this.contents.length}}});var c={};function u(e,t,n,r,s){var i=e.node.contents;if(s>=i.length)return 0;var o=Math.min(i.length-s,r);if(i.slice)for(var a=0;a<o;a++)t[n+a]=i[s+a];else for(a=0;a<o;a++)t[n+a]=i.get(s+a);return o}return Object.keys(l.stream_ops).forEach((e=>{var t=l.stream_ops[e];c[e]=function(){return ne.forceLoadFile(l),t.apply(null,arguments)}})),c.read=(e,t,n,r,s)=>(ne.forceLoadFile(l),u(e,t,n,r,s)),c.mmap=(e,t,n,r,s)=>{ne.forceLoadFile(l);var i=Z(t);if(!i)throw new ne.ErrnoError(48);return u(e,b,i,t,n),{ptr:i,allocated:!0}},l.stream_ops=c,l},createPreloadedFile:(e,t,n,r,s,i,o,a,l,c)=>{var u=t?J.resolve(K.join2(e,t)):e;function _(n){function _(n){c&&c(),a||ne.createDataFile(e,t,n,r,s,l),i&&i(),W()}Browser.handledByPreloadPlugin(n,u,_,(()=>{o&&o(),W()}))||_(n)}Q(),"string"==typeof n?te(n,(e=>_(e)),o):_(n)},indexedDB:()=>window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,DB_NAME:()=>"EM_FS_"+window.location.pathname,DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:(e,t,n)=>{t=t||(()=>{}),n=n||(()=>{});var r=ne.indexedDB();try{var s=r.open(ne.DB_NAME(),ne.DB_VERSION)}catch(e){return n(e)}s.onupgradeneeded=()=>{q("creating db"),s.result.createObjectStore(ne.DB_STORE_NAME)},s.onsuccess=()=>{var r=s.result.transaction([ne.DB_STORE_NAME],"readwrite"),i=r.objectStore(ne.DB_STORE_NAME),o=0,a=0,l=e.length;function c(){0==a?t():n()}e.forEach((e=>{var t=i.put(ne.analyzePath(e).object.contents,e);t.onsuccess=()=>{++o+a==l&&c()},t.onerror=()=>{a++,o+a==l&&c()}})),r.onerror=n},s.onerror=n},loadFilesFromDB:(e,t,n)=>{t=t||(()=>{}),n=n||(()=>{});var r=ne.indexedDB();try{var s=r.open(ne.DB_NAME(),ne.DB_VERSION)}catch(e){return n(e)}s.onupgradeneeded=n,s.onsuccess=()=>{var r=s.result;try{var i=r.transaction([ne.DB_STORE_NAME],"readonly")}catch(e){return void n(e)}var o=i.objectStore(ne.DB_STORE_NAME),a=0,l=0,c=e.length;function u(){0==l?t():n()}e.forEach((e=>{var t=o.get(e);t.onsuccess=()=>{ne.analyzePath(e).exists&&ne.unlink(e),ne.createDataFile(K.dirname(e),K.basename(e),t.result,!0,!0,!0),++a+l==c&&u()},t.onerror=()=>{l++,a+l==c&&u()}})),i.onerror=n},s.onerror=n}},re={DEFAULT_POLLMASK:5,calculateAt:function(e,t,n){if(K.isAbs(t))return t;var r;if(r=-100===e?ne.cwd():re.getStreamFromFD(e).path,0==t.length){if(!n)throw new ne.ErrnoError(44);return r}return K.join2(r,t)},doStat:function(e,t,n){try{var r=e(t)}catch(e){if(e&&e.node&&K.normalize(t)!==K.normalize(ne.getPath(e.node)))return-54;throw e}S[n>>2]=r.dev,S[n+8>>2]=r.ino,S[n+12>>2]=r.mode,x[n+16>>2]=r.nlink,S[n+20>>2]=r.uid,S[n+24>>2]=r.gid,S[n+28>>2]=r.rdev,R=[r.size>>>0,(N=r.size,+Math.abs(N)>=1?N>0?(0|Math.min(+Math.floor(N/4294967296),4294967295))>>>0:~~+Math.ceil((N-+(~~N>>>0))/4294967296)>>>0:0)],S[n+40>>2]=R[0],S[n+44>>2]=R[1],S[n+48>>2]=4096,S[n+52>>2]=r.blocks;var s=r.atime.getTime(),i=r.mtime.getTime(),o=r.ctime.getTime();return R=[Math.floor(s/1e3)>>>0,(N=Math.floor(s/1e3),+Math.abs(N)>=1?N>0?(0|Math.min(+Math.floor(N/4294967296),4294967295))>>>0:~~+Math.ceil((N-+(~~N>>>0))/4294967296)>>>0:0)],S[n+56>>2]=R[0],S[n+60>>2]=R[1],x[n+64>>2]=s%1e3*1e3,R=[Math.floor(i/1e3)>>>0,(N=Math.floor(i/1e3),+Math.abs(N)>=1?N>0?(0|Math.min(+Math.floor(N/4294967296),4294967295))>>>0:~~+Math.ceil((N-+(~~N>>>0))/4294967296)>>>0:0)],S[n+72>>2]=R[0],S[n+76>>2]=R[1],x[n+80>>2]=i%1e3*1e3,R=[Math.floor(o/1e3)>>>0,(N=Math.floor(o/1e3),+Math.abs(N)>=1?N>0?(0|Math.min(+Math.floor(N/4294967296),4294967295))>>>0:~~+Math.ceil((N-+(~~N>>>0))/4294967296)>>>0:0)],S[n+88>>2]=R[0],S[n+92>>2]=R[1],x[n+96>>2]=o%1e3*1e3,R=[r.ino>>>0,(N=r.ino,+Math.abs(N)>=1?N>0?(0|Math.min(+Math.floor(N/4294967296),4294967295))>>>0:~~+Math.ceil((N-+(~~N>>>0))/4294967296)>>>0:0)],S[n+104>>2]=R[0],S[n+108>>2]=R[1],0},doMsync:function(e,t,n,r,s){if(!ne.isFile(t.node.mode))throw new ne.ErrnoError(43);if(2&r)return 0;var i=w.slice(e,e+n);ne.msync(t,i,s,n,r)},varargs:void 0,get:function(){return re.varargs+=4,S[re.varargs-4>>2]},getStr:function(e){var t=function(e,t){return e?T(w,e,t):""}(e);return t},getStreamFromFD:function(e){var t=ne.getStream(e);if(!t)throw new ne.ErrnoError(8);return t}};function se(e){return e<-9007199254740992||e>9007199254740992?NaN:Number(e)}function ie(e){return x[e>>2]+4294967296*S[e+4>>2]}var oe,ae=[0,31,60,91,121,152,182,213,244,274,305,335],le=[0,31,59,90,120,151,181,212,243,273,304,334];function ce(e){var t=O(e)+1,n=qe(t);return n&&k(e,b,n,t),n}function ue(e){var t=g.buffer;try{return g.grow(e-t.byteLength+65535>>>16),P(),1}catch(e){}}oe=()=>performance.now();var _e={};function pe(){if(!pe.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:p||"./this.program"};for(var t in _e)void 0===_e[t]?delete e[t]:e[t]=_e[t];var n=[];for(var t in e)n.push(t+"="+e[t]);pe.strings=n}return pe.strings}var fe=function(e,t,n,r){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=ne.nextInode++,this.name=t,this.mode=n,this.node_ops={},this.stream_ops={},this.rdev=r},de=365,me=146;Object.defineProperties(fe.prototype,{read:{get:function(){return(this.mode&de)===de},set:function(e){e?this.mode|=de:this.mode&=-366}},write:{get:function(){return(this.mode&me)===me},set:function(e){e?this.mode|=me:this.mode&=-147}},isFolder:{get:function(){return ne.isDir(this.mode)}},isDevice:{get:function(){return ne.isChrdev(this.mode)}}}),ne.FSNode=fe,ne.staticInit();var he={__syscall_chmod:function(e,t){try{return e=re.getStr(e),ne.chmod(e,t),0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_faccessat:function(e,t,n,r){try{if(t=re.getStr(t),t=re.calculateAt(e,t),-8&n)return-28;var s=ne.lookupPath(t,{follow:!0}).node;if(!s)return-44;var i="";return 4&n&&(i+="r"),2&n&&(i+="w"),1&n&&(i+="x"),i&&ne.nodePermissions(s,i)?-2:0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_fchmod:function(e,t){try{return ne.fchmod(e,t),0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_fchown32:function(e,t,n){try{return ne.fchown(e,t,n),0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_fcntl64:function(e,t,n){re.varargs=n;try{var r=re.getStreamFromFD(e);switch(t){case 0:return(s=re.get())<0?-28:ne.createStream(r,s).fd;case 1:case 2:case 6:case 7:return 0;case 3:return r.flags;case 4:var s=re.get();return r.flags|=s,0;case 5:return s=re.get(),E[s+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return i=28,S[ge()>>2]=i,-1}}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}var i},__syscall_fstat64:function(e,t){try{var n=re.getStreamFromFD(e);return re.doStat(ne.stat,n.path,t)}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_ftruncate64:function(e,t){try{return t=se(t),isNaN(t)?-61:(ne.ftruncate(e,t),0)}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_getcwd:function(e,t){try{if(0===t)return-28;var n=ne.cwd(),r=O(n)+1;return t<r?-68:(F(n,e,t),r)}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_ioctl:function(e,t,n){re.varargs=n;try{var r=re.getStreamFromFD(e);switch(t){case 21509:case 21505:case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:case 21523:case 21524:return r.tty?0:-59;case 21519:if(!r.tty)return-59;var s=re.get();return S[s>>2]=0,0;case 21520:return r.tty?-28:-59;case 21531:return s=re.get(),ne.ioctl(r,t,s);default:return-28}}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_lstat64:function(e,t){try{return e=re.getStr(e),re.doStat(ne.lstat,e,t)}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_mkdirat:function(e,t,n){try{return t=re.getStr(t),t=re.calculateAt(e,t),"/"===(t=K.normalize(t))[t.length-1]&&(t=t.substr(0,t.length-1)),ne.mkdir(t,n,0),0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_newfstatat:function(e,t,n,r){try{t=re.getStr(t);var s=256&r,i=4096&r;return r&=-6401,t=re.calculateAt(e,t,i),re.doStat(s?ne.lstat:ne.stat,t,n)}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_openat:function(e,t,n,r){re.varargs=r;try{t=re.getStr(t),t=re.calculateAt(e,t);var s=r?re.get():0;return ne.open(t,n,s).fd}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_readlinkat:function(e,t,n,r){try{if(t=re.getStr(t),t=re.calculateAt(e,t),r<=0)return-28;var s=ne.readlink(t),i=Math.min(r,O(s)),o=b[n+i];return F(s,n,r+1),b[n+i]=o,i}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_rmdir:function(e){try{return e=re.getStr(e),ne.rmdir(e),0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_stat64:function(e,t){try{return e=re.getStr(e),re.doStat(ne.stat,e,t)}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_unlinkat:function(e,t,n){try{return t=re.getStr(t),t=re.calculateAt(e,t),0===n?ne.unlink(t):512===n?ne.rmdir(t):H("Invalid flags passed to unlinkat"),0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},__syscall_utimensat:function(e,t,n,r){try{if(t=re.getStr(t),t=re.calculateAt(e,t,!0),n){var s=ie(n),i=S[n+8>>2];o=1e3*s+i/1e6,a=1e3*(s=ie(n+=16))+(i=S[n+8>>2])/1e6}else var o=Date.now(),a=o;return ne.utime(t,o,a),0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},_emscripten_get_now_is_monotonic:function(){return!0},_localtime_js:function(e,t){var n=new Date(1e3*ie(e));S[t>>2]=n.getSeconds(),S[t+4>>2]=n.getMinutes(),S[t+8>>2]=n.getHours(),S[t+12>>2]=n.getDate(),S[t+16>>2]=n.getMonth(),S[t+20>>2]=n.getFullYear()-1900,S[t+24>>2]=n.getDay();var r=0|function(e){var t;return((t=e.getFullYear())%4!=0||t%100==0&&t%400!=0?le:ae)[e.getMonth()]+e.getDate()-1}(n);S[t+28>>2]=r,S[t+36>>2]=-60*n.getTimezoneOffset();var s=new Date(n.getFullYear(),0,1),i=new Date(n.getFullYear(),6,1).getTimezoneOffset(),o=s.getTimezoneOffset(),a=0|(i!=o&&n.getTimezoneOffset()==Math.min(o,i));S[t+32>>2]=a},_mmap_js:function(e,t,n,r,s,i,o){try{var a=re.getStreamFromFD(r),l=ne.mmap(a,e,s,t,n),c=l.ptr;return S[i>>2]=l.allocated,x[o>>2]=c,0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},_munmap_js:function(e,t,n,r,s,i){try{var o=re.getStreamFromFD(s);2&n&&re.doMsync(e,o,t,r,i)}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return-e.errno}},_tzset_js:function(e,t,n){var r=(new Date).getFullYear(),s=new Date(r,0,1),i=new Date(r,6,1),o=s.getTimezoneOffset(),a=i.getTimezoneOffset(),l=Math.max(o,a);function c(e){var t=e.toTimeString().match(/\(([A-Za-z ]+)\)$/);return t?t[1]:"GMT"}x[e>>2]=60*l,S[t>>2]=Number(o!=a);var u=c(s),_=c(i),p=ce(u),f=ce(_);a<o?(x[n>>2]=p,x[n+4>>2]=f):(x[n>>2]=f,x[n+4>>2]=p)},emscripten_date_now:function(){return Date.now()},emscripten_get_now:oe,emscripten_resize_heap:function(e){var t,n,r=w.length,s=2147483648;if((e>>>=0)>s)return!1;for(var i=1;i<=4;i*=2){var o=r*(1+.2/i);if(o=Math.min(o,e+100663296),ue(Math.min(s,(t=Math.max(e,o))+((n=65536)-t%n)%n)))return!0}return!1},environ_get:function(e,t){var n=0;return pe().forEach((function(r,s){var i=t+n;x[e+4*s>>2]=i,function(e,t){for(var n=0;n<e.length;++n)b[0|t++]=e.charCodeAt(n);b[0|t]=0}(r,i),n+=r.length+1})),0},environ_sizes_get:function(e,t){var n=pe();x[e>>2]=n.length;var r=0;return n.forEach((function(e){r+=e.length+1})),x[t>>2]=r,0},fd_close:function(e){try{var t=re.getStreamFromFD(e);return ne.close(t),0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return e.errno}},fd_fdstat_get:function(e,t){try{var n=re.getStreamFromFD(e),r=n.tty?2:ne.isDir(n.mode)?3:ne.isLink(n.mode)?7:4;return b[0|t]=r,0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return e.errno}},fd_read:function(e,t,n,r){try{var s=function(e,t,n,r){for(var s=0,i=0;i<n;i++){var o=x[t>>2],a=x[t+4>>2];t+=8;var l=ne.read(e,b,o,a,r);if(l<0)return-1;if(s+=l,l<a)break}return s}(re.getStreamFromFD(e),t,n);return x[r>>2]=s,0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return e.errno}},fd_seek:function(e,t,n,r){try{if(t=se(t),isNaN(t))return 61;var s=re.getStreamFromFD(e);return ne.llseek(s,t,n),R=[s.position>>>0,(N=s.position,+Math.abs(N)>=1?N>0?(0|Math.min(+Math.floor(N/4294967296),4294967295))>>>0:~~+Math.ceil((N-+(~~N>>>0))/4294967296)>>>0:0)],S[r>>2]=R[0],S[r+4>>2]=R[1],s.getdents&&0===t&&0===n&&(s.getdents=null),0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return e.errno}},fd_sync:function(e){try{var t=re.getStreamFromFD(e);return t.stream_ops&&t.stream_ops.fsync?t.stream_ops.fsync(t):0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return e.errno}},fd_write:function(e,t,n,r){try{var s=function(e,t,n,r){for(var s=0,i=0;i<n;i++){var o=x[t>>2],a=x[t+4>>2];t+=8;var l=ne.write(e,b,o,a,r);if(l<0)return-1;s+=l}return s}(re.getStreamFromFD(e),t,n);return x[r>>2]=s,0}catch(e){if(void 0===ne||!(e instanceof ne.ErrnoError))throw e;return e.errno}},memory:g};!function(){var e={env:he,wasi_snapshot_preview1:he};function t(e,t){var n,r=e.exports;i.asm=r,n=i.asm.__wasm_call_ctors,M.unshift(n),W()}function n(e){t(e.instance)}function s(t){return(h||!f&&!d||"function"!=typeof fetch?Promise.resolve().then((function(){return G(C)})):fetch(C,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+C+"'";return e.arrayBuffer()})).catch((function(){return G(C)}))).then((function(t){return WebAssembly.instantiate(t,e)})).then((function(e){return e})).then(t,(function(e){y("failed to asynchronously prepare wasm: "+e),H(e)}))}if(Q(),i.instantiateWasm)try{return i.instantiateWasm(e,t)}catch(e){y("Module.instantiateWasm callback failed with error: "+e),r(e)}(h||"function"!=typeof WebAssembly.instantiateStreaming||V(C)||"function"!=typeof fetch?s(n):fetch(C,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(n,(function(e){return y("wasm streaming compile failed: "+e),y("falling back to ArrayBuffer instantiation"),s(n)}))}))).catch(r)}(),i.___wasm_call_ctors=function(){return(i.___wasm_call_ctors=i.asm.__wasm_call_ctors).apply(null,arguments)},i._sqlite3_status64=function(){return(i._sqlite3_status64=i.asm.sqlite3_status64).apply(null,arguments)},i._sqlite3_status=function(){return(i._sqlite3_status=i.asm.sqlite3_status).apply(null,arguments)},i._sqlite3_db_status=function(){return(i._sqlite3_db_status=i.asm.sqlite3_db_status).apply(null,arguments)},i._sqlite3_msize=function(){return(i._sqlite3_msize=i.asm.sqlite3_msize).apply(null,arguments)},i._sqlite3_vfs_find=function(){return(i._sqlite3_vfs_find=i.asm.sqlite3_vfs_find).apply(null,arguments)},i._sqlite3_initialize=function(){return(i._sqlite3_initialize=i.asm.sqlite3_initialize).apply(null,arguments)},i._sqlite3_malloc=function(){return(i._sqlite3_malloc=i.asm.sqlite3_malloc).apply(null,arguments)},i._sqlite3_free=function(){return(i._sqlite3_free=i.asm.sqlite3_free).apply(null,arguments)},i._sqlite3_vfs_register=function(){return(i._sqlite3_vfs_register=i.asm.sqlite3_vfs_register).apply(null,arguments)},i._sqlite3_vfs_unregister=function(){return(i._sqlite3_vfs_unregister=i.asm.sqlite3_vfs_unregister).apply(null,arguments)},i._sqlite3_malloc64=function(){return(i._sqlite3_malloc64=i.asm.sqlite3_malloc64).apply(null,arguments)},i._sqlite3_realloc=function(){return(i._sqlite3_realloc=i.asm.sqlite3_realloc).apply(null,arguments)},i._sqlite3_realloc64=function(){return(i._sqlite3_realloc64=i.asm.sqlite3_realloc64).apply(null,arguments)},i._sqlite3_value_text=function(){return(i._sqlite3_value_text=i.asm.sqlite3_value_text).apply(null,arguments)},i._sqlite3_randomness=function(){return(i._sqlite3_randomness=i.asm.sqlite3_randomness).apply(null,arguments)},i._sqlite3_stricmp=function(){return(i._sqlite3_stricmp=i.asm.sqlite3_stricmp).apply(null,arguments)},i._sqlite3_strnicmp=function(){return(i._sqlite3_strnicmp=i.asm.sqlite3_strnicmp).apply(null,arguments)},i._sqlite3_uri_parameter=function(){return(i._sqlite3_uri_parameter=i.asm.sqlite3_uri_parameter).apply(null,arguments)};var ge=i.___errno_location=function(){return(ge=i.___errno_location=i.asm.__errno_location).apply(null,arguments)};i._sqlite3_uri_boolean=function(){return(i._sqlite3_uri_boolean=i.asm.sqlite3_uri_boolean).apply(null,arguments)},i._sqlite3_serialize=function(){return(i._sqlite3_serialize=i.asm.sqlite3_serialize).apply(null,arguments)},i._sqlite3_prepare_v2=function(){return(i._sqlite3_prepare_v2=i.asm.sqlite3_prepare_v2).apply(null,arguments)},i._sqlite3_step=function(){return(i._sqlite3_step=i.asm.sqlite3_step).apply(null,arguments)},i._sqlite3_column_int64=function(){return(i._sqlite3_column_int64=i.asm.sqlite3_column_int64).apply(null,arguments)},i._sqlite3_reset=function(){return(i._sqlite3_reset=i.asm.sqlite3_reset).apply(null,arguments)},i._sqlite3_exec=function(){return(i._sqlite3_exec=i.asm.sqlite3_exec).apply(null,arguments)},i._sqlite3_column_int=function(){return(i._sqlite3_column_int=i.asm.sqlite3_column_int).apply(null,arguments)},i._sqlite3_finalize=function(){return(i._sqlite3_finalize=i.asm.sqlite3_finalize).apply(null,arguments)},i._sqlite3_file_control=function(){return(i._sqlite3_file_control=i.asm.sqlite3_file_control).apply(null,arguments)},i._sqlite3_column_name=function(){return(i._sqlite3_column_name=i.asm.sqlite3_column_name).apply(null,arguments)},i._sqlite3_column_text=function(){return(i._sqlite3_column_text=i.asm.sqlite3_column_text).apply(null,arguments)},i._sqlite3_column_type=function(){return(i._sqlite3_column_type=i.asm.sqlite3_column_type).apply(null,arguments)},i._sqlite3_errmsg=function(){return(i._sqlite3_errmsg=i.asm.sqlite3_errmsg).apply(null,arguments)},i._sqlite3_deserialize=function(){return(i._sqlite3_deserialize=i.asm.sqlite3_deserialize).apply(null,arguments)},i._sqlite3_clear_bindings=function(){return(i._sqlite3_clear_bindings=i.asm.sqlite3_clear_bindings).apply(null,arguments)},i._sqlite3_value_blob=function(){return(i._sqlite3_value_blob=i.asm.sqlite3_value_blob).apply(null,arguments)},i._sqlite3_value_bytes=function(){return(i._sqlite3_value_bytes=i.asm.sqlite3_value_bytes).apply(null,arguments)},i._sqlite3_value_double=function(){return(i._sqlite3_value_double=i.asm.sqlite3_value_double).apply(null,arguments)},i._sqlite3_value_int=function(){return(i._sqlite3_value_int=i.asm.sqlite3_value_int).apply(null,arguments)},i._sqlite3_value_int64=function(){return(i._sqlite3_value_int64=i.asm.sqlite3_value_int64).apply(null,arguments)},i._sqlite3_value_subtype=function(){return(i._sqlite3_value_subtype=i.asm.sqlite3_value_subtype).apply(null,arguments)},i._sqlite3_value_pointer=function(){return(i._sqlite3_value_pointer=i.asm.sqlite3_value_pointer).apply(null,arguments)},i._sqlite3_value_type=function(){return(i._sqlite3_value_type=i.asm.sqlite3_value_type).apply(null,arguments)},i._sqlite3_value_nochange=function(){return(i._sqlite3_value_nochange=i.asm.sqlite3_value_nochange).apply(null,arguments)},i._sqlite3_value_frombind=function(){return(i._sqlite3_value_frombind=i.asm.sqlite3_value_frombind).apply(null,arguments)},i._sqlite3_value_dup=function(){return(i._sqlite3_value_dup=i.asm.sqlite3_value_dup).apply(null,arguments)},i._sqlite3_value_free=function(){return(i._sqlite3_value_free=i.asm.sqlite3_value_free).apply(null,arguments)},i._sqlite3_result_blob=function(){return(i._sqlite3_result_blob=i.asm.sqlite3_result_blob).apply(null,arguments)},i._sqlite3_result_error_toobig=function(){return(i._sqlite3_result_error_toobig=i.asm.sqlite3_result_error_toobig).apply(null,arguments)},i._sqlite3_result_error_nomem=function(){return(i._sqlite3_result_error_nomem=i.asm.sqlite3_result_error_nomem).apply(null,arguments)},i._sqlite3_result_double=function(){return(i._sqlite3_result_double=i.asm.sqlite3_result_double).apply(null,arguments)},i._sqlite3_result_error=function(){return(i._sqlite3_result_error=i.asm.sqlite3_result_error).apply(null,arguments)},i._sqlite3_result_int=function(){return(i._sqlite3_result_int=i.asm.sqlite3_result_int).apply(null,arguments)},i._sqlite3_result_int64=function(){return(i._sqlite3_result_int64=i.asm.sqlite3_result_int64).apply(null,arguments)},i._sqlite3_result_null=function(){return(i._sqlite3_result_null=i.asm.sqlite3_result_null).apply(null,arguments)},i._sqlite3_result_pointer=function(){return(i._sqlite3_result_pointer=i.asm.sqlite3_result_pointer).apply(null,arguments)},i._sqlite3_result_subtype=function(){return(i._sqlite3_result_subtype=i.asm.sqlite3_result_subtype).apply(null,arguments)},i._sqlite3_result_text=function(){return(i._sqlite3_result_text=i.asm.sqlite3_result_text).apply(null,arguments)},i._sqlite3_result_zeroblob=function(){return(i._sqlite3_result_zeroblob=i.asm.sqlite3_result_zeroblob).apply(null,arguments)},i._sqlite3_result_zeroblob64=function(){return(i._sqlite3_result_zeroblob64=i.asm.sqlite3_result_zeroblob64).apply(null,arguments)},i._sqlite3_result_error_code=function(){return(i._sqlite3_result_error_code=i.asm.sqlite3_result_error_code).apply(null,arguments)},i._sqlite3_user_data=function(){return(i._sqlite3_user_data=i.asm.sqlite3_user_data).apply(null,arguments)},i._sqlite3_context_db_handle=function(){return(i._sqlite3_context_db_handle=i.asm.sqlite3_context_db_handle).apply(null,arguments)},i._sqlite3_vtab_nochange=function(){return(i._sqlite3_vtab_nochange=i.asm.sqlite3_vtab_nochange).apply(null,arguments)},i._sqlite3_vtab_in_first=function(){return(i._sqlite3_vtab_in_first=i.asm.sqlite3_vtab_in_first).apply(null,arguments)},i._sqlite3_vtab_in_next=function(){return(i._sqlite3_vtab_in_next=i.asm.sqlite3_vtab_in_next).apply(null,arguments)},i._sqlite3_aggregate_context=function(){return(i._sqlite3_aggregate_context=i.asm.sqlite3_aggregate_context).apply(null,arguments)},i._sqlite3_get_auxdata=function(){return(i._sqlite3_get_auxdata=i.asm.sqlite3_get_auxdata).apply(null,arguments)},i._sqlite3_set_auxdata=function(){return(i._sqlite3_set_auxdata=i.asm.sqlite3_set_auxdata).apply(null,arguments)},i._sqlite3_column_count=function(){return(i._sqlite3_column_count=i.asm.sqlite3_column_count).apply(null,arguments)},i._sqlite3_data_count=function(){return(i._sqlite3_data_count=i.asm.sqlite3_data_count).apply(null,arguments)},i._sqlite3_column_blob=function(){return(i._sqlite3_column_blob=i.asm.sqlite3_column_blob).apply(null,arguments)},i._sqlite3_column_bytes=function(){return(i._sqlite3_column_bytes=i.asm.sqlite3_column_bytes).apply(null,arguments)},i._sqlite3_column_double=function(){return(i._sqlite3_column_double=i.asm.sqlite3_column_double).apply(null,arguments)},i._sqlite3_column_value=function(){return(i._sqlite3_column_value=i.asm.sqlite3_column_value).apply(null,arguments)},i._sqlite3_bind_blob=function(){return(i._sqlite3_bind_blob=i.asm.sqlite3_bind_blob).apply(null,arguments)},i._sqlite3_bind_double=function(){return(i._sqlite3_bind_double=i.asm.sqlite3_bind_double).apply(null,arguments)},i._sqlite3_bind_int=function(){return(i._sqlite3_bind_int=i.asm.sqlite3_bind_int).apply(null,arguments)},i._sqlite3_bind_int64=function(){return(i._sqlite3_bind_int64=i.asm.sqlite3_bind_int64).apply(null,arguments)},i._sqlite3_bind_null=function(){return(i._sqlite3_bind_null=i.asm.sqlite3_bind_null).apply(null,arguments)},i._sqlite3_bind_pointer=function(){return(i._sqlite3_bind_pointer=i.asm.sqlite3_bind_pointer).apply(null,arguments)},i._sqlite3_bind_text=function(){return(i._sqlite3_bind_text=i.asm.sqlite3_bind_text).apply(null,arguments)},i._sqlite3_bind_parameter_count=function(){return(i._sqlite3_bind_parameter_count=i.asm.sqlite3_bind_parameter_count).apply(null,arguments)},i._sqlite3_bind_parameter_index=function(){return(i._sqlite3_bind_parameter_index=i.asm.sqlite3_bind_parameter_index).apply(null,arguments)},i._sqlite3_db_handle=function(){return(i._sqlite3_db_handle=i.asm.sqlite3_db_handle).apply(null,arguments)},i._sqlite3_stmt_readonly=function(){return(i._sqlite3_stmt_readonly=i.asm.sqlite3_stmt_readonly).apply(null,arguments)},i._sqlite3_stmt_isexplain=function(){return(i._sqlite3_stmt_isexplain=i.asm.sqlite3_stmt_isexplain).apply(null,arguments)},i._sqlite3_stmt_status=function(){return(i._sqlite3_stmt_status=i.asm.sqlite3_stmt_status).apply(null,arguments)},i._sqlite3_sql=function(){return(i._sqlite3_sql=i.asm.sqlite3_sql).apply(null,arguments)},i._sqlite3_expanded_sql=function(){return(i._sqlite3_expanded_sql=i.asm.sqlite3_expanded_sql).apply(null,arguments)},i._sqlite3_preupdate_old=function(){return(i._sqlite3_preupdate_old=i.asm.sqlite3_preupdate_old).apply(null,arguments)},i._sqlite3_preupdate_count=function(){return(i._sqlite3_preupdate_count=i.asm.sqlite3_preupdate_count).apply(null,arguments)},i._sqlite3_preupdate_depth=function(){return(i._sqlite3_preupdate_depth=i.asm.sqlite3_preupdate_depth).apply(null,arguments)},i._sqlite3_preupdate_blobwrite=function(){return(i._sqlite3_preupdate_blobwrite=i.asm.sqlite3_preupdate_blobwrite).apply(null,arguments)},i._sqlite3_preupdate_new=function(){return(i._sqlite3_preupdate_new=i.asm.sqlite3_preupdate_new).apply(null,arguments)},i._sqlite3_value_numeric_type=function(){return(i._sqlite3_value_numeric_type=i.asm.sqlite3_value_numeric_type).apply(null,arguments)},i._sqlite3_set_authorizer=function(){return(i._sqlite3_set_authorizer=i.asm.sqlite3_set_authorizer).apply(null,arguments)},i._sqlite3_strglob=function(){return(i._sqlite3_strglob=i.asm.sqlite3_strglob).apply(null,arguments)},i._sqlite3_strlike=function(){return(i._sqlite3_strlike=i.asm.sqlite3_strlike).apply(null,arguments)},i._sqlite3_auto_extension=function(){return(i._sqlite3_auto_extension=i.asm.sqlite3_auto_extension).apply(null,arguments)},i._sqlite3_cancel_auto_extension=function(){return(i._sqlite3_cancel_auto_extension=i.asm.sqlite3_cancel_auto_extension).apply(null,arguments)},i._sqlite3_reset_auto_extension=function(){return(i._sqlite3_reset_auto_extension=i.asm.sqlite3_reset_auto_extension).apply(null,arguments)},i._sqlite3_prepare_v3=function(){return(i._sqlite3_prepare_v3=i.asm.sqlite3_prepare_v3).apply(null,arguments)},i._sqlite3_create_module=function(){return(i._sqlite3_create_module=i.asm.sqlite3_create_module).apply(null,arguments)},i._sqlite3_create_module_v2=function(){return(i._sqlite3_create_module_v2=i.asm.sqlite3_create_module_v2).apply(null,arguments)},i._sqlite3_drop_modules=function(){return(i._sqlite3_drop_modules=i.asm.sqlite3_drop_modules).apply(null,arguments)},i._sqlite3_declare_vtab=function(){return(i._sqlite3_declare_vtab=i.asm.sqlite3_declare_vtab).apply(null,arguments)},i._sqlite3_vtab_on_conflict=function(){return(i._sqlite3_vtab_on_conflict=i.asm.sqlite3_vtab_on_conflict).apply(null,arguments)},i._sqlite3_vtab_collation=function(){return(i._sqlite3_vtab_collation=i.asm.sqlite3_vtab_collation).apply(null,arguments)},i._sqlite3_vtab_in=function(){return(i._sqlite3_vtab_in=i.asm.sqlite3_vtab_in).apply(null,arguments)},i._sqlite3_vtab_rhs_value=function(){return(i._sqlite3_vtab_rhs_value=i.asm.sqlite3_vtab_rhs_value).apply(null,arguments)},i._sqlite3_vtab_distinct=function(){return(i._sqlite3_vtab_distinct=i.asm.sqlite3_vtab_distinct).apply(null,arguments)},i._sqlite3_keyword_name=function(){return(i._sqlite3_keyword_name=i.asm.sqlite3_keyword_name).apply(null,arguments)},i._sqlite3_keyword_count=function(){return(i._sqlite3_keyword_count=i.asm.sqlite3_keyword_count).apply(null,arguments)},i._sqlite3_keyword_check=function(){return(i._sqlite3_keyword_check=i.asm.sqlite3_keyword_check).apply(null,arguments)},i._sqlite3_complete=function(){return(i._sqlite3_complete=i.asm.sqlite3_complete).apply(null,arguments)},i._sqlite3_libversion=function(){return(i._sqlite3_libversion=i.asm.sqlite3_libversion).apply(null,arguments)},i._sqlite3_libversion_number=function(){return(i._sqlite3_libversion_number=i.asm.sqlite3_libversion_number).apply(null,arguments)},i._sqlite3_shutdown=function(){return(i._sqlite3_shutdown=i.asm.sqlite3_shutdown).apply(null,arguments)},i._sqlite3_last_insert_rowid=function(){return(i._sqlite3_last_insert_rowid=i.asm.sqlite3_last_insert_rowid).apply(null,arguments)},i._sqlite3_set_last_insert_rowid=function(){return(i._sqlite3_set_last_insert_rowid=i.asm.sqlite3_set_last_insert_rowid).apply(null,arguments)},i._sqlite3_changes64=function(){return(i._sqlite3_changes64=i.asm.sqlite3_changes64).apply(null,arguments)},i._sqlite3_changes=function(){return(i._sqlite3_changes=i.asm.sqlite3_changes).apply(null,arguments)},i._sqlite3_total_changes64=function(){return(i._sqlite3_total_changes64=i.asm.sqlite3_total_changes64).apply(null,arguments)},i._sqlite3_total_changes=function(){return(i._sqlite3_total_changes=i.asm.sqlite3_total_changes).apply(null,arguments)},i._sqlite3_txn_state=function(){return(i._sqlite3_txn_state=i.asm.sqlite3_txn_state).apply(null,arguments)},i._sqlite3_close_v2=function(){return(i._sqlite3_close_v2=i.asm.sqlite3_close_v2).apply(null,arguments)},i._sqlite3_busy_handler=function(){return(i._sqlite3_busy_handler=i.asm.sqlite3_busy_handler).apply(null,arguments)},i._sqlite3_progress_handler=function(){return(i._sqlite3_progress_handler=i.asm.sqlite3_progress_handler).apply(null,arguments)},i._sqlite3_busy_timeout=function(){return(i._sqlite3_busy_timeout=i.asm.sqlite3_busy_timeout).apply(null,arguments)},i._sqlite3_create_function=function(){return(i._sqlite3_create_function=i.asm.sqlite3_create_function).apply(null,arguments)},i._sqlite3_create_function_v2=function(){return(i._sqlite3_create_function_v2=i.asm.sqlite3_create_function_v2).apply(null,arguments)},i._sqlite3_create_window_function=function(){return(i._sqlite3_create_window_function=i.asm.sqlite3_create_window_function).apply(null,arguments)},i._sqlite3_overload_function=function(){return(i._sqlite3_overload_function=i.asm.sqlite3_overload_function).apply(null,arguments)},i._sqlite3_trace_v2=function(){return(i._sqlite3_trace_v2=i.asm.sqlite3_trace_v2).apply(null,arguments)},i._sqlite3_commit_hook=function(){return(i._sqlite3_commit_hook=i.asm.sqlite3_commit_hook).apply(null,arguments)},i._sqlite3_update_hook=function(){return(i._sqlite3_update_hook=i.asm.sqlite3_update_hook).apply(null,arguments)},i._sqlite3_rollback_hook=function(){return(i._sqlite3_rollback_hook=i.asm.sqlite3_rollback_hook).apply(null,arguments)},i._sqlite3_preupdate_hook=function(){return(i._sqlite3_preupdate_hook=i.asm.sqlite3_preupdate_hook).apply(null,arguments)},i._sqlite3_error_offset=function(){return(i._sqlite3_error_offset=i.asm.sqlite3_error_offset).apply(null,arguments)},i._sqlite3_errcode=function(){return(i._sqlite3_errcode=i.asm.sqlite3_errcode).apply(null,arguments)},i._sqlite3_extended_errcode=function(){return(i._sqlite3_extended_errcode=i.asm.sqlite3_extended_errcode).apply(null,arguments)},i._sqlite3_errstr=function(){return(i._sqlite3_errstr=i.asm.sqlite3_errstr).apply(null,arguments)},i._sqlite3_limit=function(){return(i._sqlite3_limit=i.asm.sqlite3_limit).apply(null,arguments)},i._sqlite3_open=function(){return(i._sqlite3_open=i.asm.sqlite3_open).apply(null,arguments)},i._sqlite3_open_v2=function(){return(i._sqlite3_open_v2=i.asm.sqlite3_open_v2).apply(null,arguments)},i._sqlite3_create_collation=function(){return(i._sqlite3_create_collation=i.asm.sqlite3_create_collation).apply(null,arguments)},i._sqlite3_create_collation_v2=function(){return(i._sqlite3_create_collation_v2=i.asm.sqlite3_create_collation_v2).apply(null,arguments)},i._sqlite3_collation_needed=function(){return(i._sqlite3_collation_needed=i.asm.sqlite3_collation_needed).apply(null,arguments)},i._sqlite3_get_autocommit=function(){return(i._sqlite3_get_autocommit=i.asm.sqlite3_get_autocommit).apply(null,arguments)},i._sqlite3_table_column_metadata=function(){return(i._sqlite3_table_column_metadata=i.asm.sqlite3_table_column_metadata).apply(null,arguments)},i._sqlite3_extended_result_codes=function(){return(i._sqlite3_extended_result_codes=i.asm.sqlite3_extended_result_codes).apply(null,arguments)},i._sqlite3_uri_key=function(){return(i._sqlite3_uri_key=i.asm.sqlite3_uri_key).apply(null,arguments)},i._sqlite3_uri_int64=function(){return(i._sqlite3_uri_int64=i.asm.sqlite3_uri_int64).apply(null,arguments)},i._sqlite3_db_name=function(){return(i._sqlite3_db_name=i.asm.sqlite3_db_name).apply(null,arguments)},i._sqlite3_db_filename=function(){return(i._sqlite3_db_filename=i.asm.sqlite3_db_filename).apply(null,arguments)},i._sqlite3_compileoption_used=function(){return(i._sqlite3_compileoption_used=i.asm.sqlite3_compileoption_used).apply(null,arguments)},i._sqlite3_compileoption_get=function(){return(i._sqlite3_compileoption_get=i.asm.sqlite3_compileoption_get).apply(null,arguments)},i._sqlite3session_diff=function(){return(i._sqlite3session_diff=i.asm.sqlite3session_diff).apply(null,arguments)},i._sqlite3session_attach=function(){return(i._sqlite3session_attach=i.asm.sqlite3session_attach).apply(null,arguments)},i._sqlite3session_create=function(){return(i._sqlite3session_create=i.asm.sqlite3session_create).apply(null,arguments)},i._sqlite3session_delete=function(){return(i._sqlite3session_delete=i.asm.sqlite3session_delete).apply(null,arguments)},i._sqlite3session_table_filter=function(){return(i._sqlite3session_table_filter=i.asm.sqlite3session_table_filter).apply(null,arguments)},i._sqlite3session_changeset=function(){return(i._sqlite3session_changeset=i.asm.sqlite3session_changeset).apply(null,arguments)},i._sqlite3session_changeset_strm=function(){return(i._sqlite3session_changeset_strm=i.asm.sqlite3session_changeset_strm).apply(null,arguments)},i._sqlite3session_patchset_strm=function(){return(i._sqlite3session_patchset_strm=i.asm.sqlite3session_patchset_strm).apply(null,arguments)},i._sqlite3session_patchset=function(){return(i._sqlite3session_patchset=i.asm.sqlite3session_patchset).apply(null,arguments)},i._sqlite3session_enable=function(){return(i._sqlite3session_enable=i.asm.sqlite3session_enable).apply(null,arguments)},i._sqlite3session_indirect=function(){return(i._sqlite3session_indirect=i.asm.sqlite3session_indirect).apply(null,arguments)},i._sqlite3session_isempty=function(){return(i._sqlite3session_isempty=i.asm.sqlite3session_isempty).apply(null,arguments)},i._sqlite3session_memory_used=function(){return(i._sqlite3session_memory_used=i.asm.sqlite3session_memory_used).apply(null,arguments)},i._sqlite3session_object_config=function(){return(i._sqlite3session_object_config=i.asm.sqlite3session_object_config).apply(null,arguments)},i._sqlite3session_changeset_size=function(){return(i._sqlite3session_changeset_size=i.asm.sqlite3session_changeset_size).apply(null,arguments)},i._sqlite3changeset_start=function(){return(i._sqlite3changeset_start=i.asm.sqlite3changeset_start).apply(null,arguments)},i._sqlite3changeset_start_v2=function(){return(i._sqlite3changeset_start_v2=i.asm.sqlite3changeset_start_v2).apply(null,arguments)},i._sqlite3changeset_start_strm=function(){return(i._sqlite3changeset_start_strm=i.asm.sqlite3changeset_start_strm).apply(null,arguments)},i._sqlite3changeset_start_v2_strm=function(){return(i._sqlite3changeset_start_v2_strm=i.asm.sqlite3changeset_start_v2_strm).apply(null,arguments)},i._sqlite3changeset_next=function(){return(i._sqlite3changeset_next=i.asm.sqlite3changeset_next).apply(null,arguments)},i._sqlite3changeset_op=function(){return(i._sqlite3changeset_op=i.asm.sqlite3changeset_op).apply(null,arguments)},i._sqlite3changeset_pk=function(){return(i._sqlite3changeset_pk=i.asm.sqlite3changeset_pk).apply(null,arguments)},i._sqlite3changeset_old=function(){return(i._sqlite3changeset_old=i.asm.sqlite3changeset_old).apply(null,arguments)},i._sqlite3changeset_new=function(){return(i._sqlite3changeset_new=i.asm.sqlite3changeset_new).apply(null,arguments)},i._sqlite3changeset_conflict=function(){return(i._sqlite3changeset_conflict=i.asm.sqlite3changeset_conflict).apply(null,arguments)},i._sqlite3changeset_fk_conflicts=function(){return(i._sqlite3changeset_fk_conflicts=i.asm.sqlite3changeset_fk_conflicts).apply(null,arguments)},i._sqlite3changeset_finalize=function(){return(i._sqlite3changeset_finalize=i.asm.sqlite3changeset_finalize).apply(null,arguments)},i._sqlite3changeset_invert=function(){return(i._sqlite3changeset_invert=i.asm.sqlite3changeset_invert).apply(null,arguments)},i._sqlite3changeset_invert_strm=function(){return(i._sqlite3changeset_invert_strm=i.asm.sqlite3changeset_invert_strm).apply(null,arguments)},i._sqlite3changeset_apply_v2=function(){return(i._sqlite3changeset_apply_v2=i.asm.sqlite3changeset_apply_v2).apply(null,arguments)},i._sqlite3changeset_apply=function(){return(i._sqlite3changeset_apply=i.asm.sqlite3changeset_apply).apply(null,arguments)},i._sqlite3changeset_apply_v2_strm=function(){return(i._sqlite3changeset_apply_v2_strm=i.asm.sqlite3changeset_apply_v2_strm).apply(null,arguments)},i._sqlite3changeset_apply_strm=function(){return(i._sqlite3changeset_apply_strm=i.asm.sqlite3changeset_apply_strm).apply(null,arguments)},i._sqlite3changegroup_new=function(){return(i._sqlite3changegroup_new=i.asm.sqlite3changegroup_new).apply(null,arguments)},i._sqlite3changegroup_add=function(){return(i._sqlite3changegroup_add=i.asm.sqlite3changegroup_add).apply(null,arguments)},i._sqlite3changegroup_output=function(){return(i._sqlite3changegroup_output=i.asm.sqlite3changegroup_output).apply(null,arguments)},i._sqlite3changegroup_add_strm=function(){return(i._sqlite3changegroup_add_strm=i.asm.sqlite3changegroup_add_strm).apply(null,arguments)},i._sqlite3changegroup_output_strm=function(){return(i._sqlite3changegroup_output_strm=i.asm.sqlite3changegroup_output_strm).apply(null,arguments)},i._sqlite3changegroup_delete=function(){return(i._sqlite3changegroup_delete=i.asm.sqlite3changegroup_delete).apply(null,arguments)},i._sqlite3changeset_concat=function(){return(i._sqlite3changeset_concat=i.asm.sqlite3changeset_concat).apply(null,arguments)},i._sqlite3changeset_concat_strm=function(){return(i._sqlite3changeset_concat_strm=i.asm.sqlite3changeset_concat_strm).apply(null,arguments)},i._sqlite3session_config=function(){return(i._sqlite3session_config=i.asm.sqlite3session_config).apply(null,arguments)},i._sqlite3_sourceid=function(){return(i._sqlite3_sourceid=i.asm.sqlite3_sourceid).apply(null,arguments)},i._sqlite3__wasm_pstack_ptr=function(){return(i._sqlite3__wasm_pstack_ptr=i.asm.sqlite3__wasm_pstack_ptr).apply(null,arguments)},i._sqlite3__wasm_pstack_restore=function(){return(i._sqlite3__wasm_pstack_restore=i.asm.sqlite3__wasm_pstack_restore).apply(null,arguments)},i._sqlite3__wasm_pstack_alloc=function(){return(i._sqlite3__wasm_pstack_alloc=i.asm.sqlite3__wasm_pstack_alloc).apply(null,arguments)},i._sqlite3__wasm_pstack_remaining=function(){return(i._sqlite3__wasm_pstack_remaining=i.asm.sqlite3__wasm_pstack_remaining).apply(null,arguments)},i._sqlite3__wasm_pstack_quota=function(){return(i._sqlite3__wasm_pstack_quota=i.asm.sqlite3__wasm_pstack_quota).apply(null,arguments)},i._sqlite3__wasm_db_error=function(){return(i._sqlite3__wasm_db_error=i.asm.sqlite3__wasm_db_error).apply(null,arguments)},i._sqlite3__wasm_test_struct=function(){return(i._sqlite3__wasm_test_struct=i.asm.sqlite3__wasm_test_struct).apply(null,arguments)},i._sqlite3__wasm_enum_json=function(){return(i._sqlite3__wasm_enum_json=i.asm.sqlite3__wasm_enum_json).apply(null,arguments)},i._sqlite3__wasm_vfs_unlink=function(){return(i._sqlite3__wasm_vfs_unlink=i.asm.sqlite3__wasm_vfs_unlink).apply(null,arguments)},i._sqlite3__wasm_db_vfs=function(){return(i._sqlite3__wasm_db_vfs=i.asm.sqlite3__wasm_db_vfs).apply(null,arguments)},i._sqlite3__wasm_db_reset=function(){return(i._sqlite3__wasm_db_reset=i.asm.sqlite3__wasm_db_reset).apply(null,arguments)},i._sqlite3__wasm_db_export_chunked=function(){return(i._sqlite3__wasm_db_export_chunked=i.asm.sqlite3__wasm_db_export_chunked).apply(null,arguments)},i._sqlite3__wasm_db_serialize=function(){return(i._sqlite3__wasm_db_serialize=i.asm.sqlite3__wasm_db_serialize).apply(null,arguments)},i._sqlite3__wasm_vfs_create_file=function(){return(i._sqlite3__wasm_vfs_create_file=i.asm.sqlite3__wasm_vfs_create_file).apply(null,arguments)},i._sqlite3__wasm_posix_create_file=function(){return(i._sqlite3__wasm_posix_create_file=i.asm.sqlite3__wasm_posix_create_file).apply(null,arguments)},i._sqlite3__wasm_kvvfsMakeKeyOnPstack=function(){return(i._sqlite3__wasm_kvvfsMakeKeyOnPstack=i.asm.sqlite3__wasm_kvvfsMakeKeyOnPstack).apply(null,arguments)},i._sqlite3__wasm_kvvfs_methods=function(){return(i._sqlite3__wasm_kvvfs_methods=i.asm.sqlite3__wasm_kvvfs_methods).apply(null,arguments)},i._sqlite3__wasm_vtab_config=function(){return(i._sqlite3__wasm_vtab_config=i.asm.sqlite3__wasm_vtab_config).apply(null,arguments)},i._sqlite3__wasm_db_config_ip=function(){return(i._sqlite3__wasm_db_config_ip=i.asm.sqlite3__wasm_db_config_ip).apply(null,arguments)},i._sqlite3__wasm_db_config_pii=function(){return(i._sqlite3__wasm_db_config_pii=i.asm.sqlite3__wasm_db_config_pii).apply(null,arguments)},i._sqlite3__wasm_db_config_s=function(){return(i._sqlite3__wasm_db_config_s=i.asm.sqlite3__wasm_db_config_s).apply(null,arguments)},i._sqlite3__wasm_config_i=function(){return(i._sqlite3__wasm_config_i=i.asm.sqlite3__wasm_config_i).apply(null,arguments)},i._sqlite3__wasm_config_ii=function(){return(i._sqlite3__wasm_config_ii=i.asm.sqlite3__wasm_config_ii).apply(null,arguments)},i._sqlite3__wasm_config_j=function(){return(i._sqlite3__wasm_config_j=i.asm.sqlite3__wasm_config_j).apply(null,arguments)},i._sqlite3__wasm_qfmt_token=function(){return(i._sqlite3__wasm_qfmt_token=i.asm.sqlite3__wasm_qfmt_token).apply(null,arguments)},i._sqlite3__wasm_init_wasmfs=function(){return(i._sqlite3__wasm_init_wasmfs=i.asm.sqlite3__wasm_init_wasmfs).apply(null,arguments)},i._sqlite3__wasm_test_intptr=function(){return(i._sqlite3__wasm_test_intptr=i.asm.sqlite3__wasm_test_intptr).apply(null,arguments)},i._sqlite3__wasm_test_voidptr=function(){return(i._sqlite3__wasm_test_voidptr=i.asm.sqlite3__wasm_test_voidptr).apply(null,arguments)},i._sqlite3__wasm_test_int64_max=function(){return(i._sqlite3__wasm_test_int64_max=i.asm.sqlite3__wasm_test_int64_max).apply(null,arguments)},i._sqlite3__wasm_test_int64_min=function(){return(i._sqlite3__wasm_test_int64_min=i.asm.sqlite3__wasm_test_int64_min).apply(null,arguments)},i._sqlite3__wasm_test_int64_times2=function(){return(i._sqlite3__wasm_test_int64_times2=i.asm.sqlite3__wasm_test_int64_times2).apply(null,arguments)},i._sqlite3__wasm_test_int64_minmax=function(){return(i._sqlite3__wasm_test_int64_minmax=i.asm.sqlite3__wasm_test_int64_minmax).apply(null,arguments)},i._sqlite3__wasm_test_int64ptr=function(){return(i._sqlite3__wasm_test_int64ptr=i.asm.sqlite3__wasm_test_int64ptr).apply(null,arguments)},i._sqlite3__wasm_test_stack_overflow=function(){return(i._sqlite3__wasm_test_stack_overflow=i.asm.sqlite3__wasm_test_stack_overflow).apply(null,arguments)},i._sqlite3__wasm_test_str_hello=function(){return(i._sqlite3__wasm_test_str_hello=i.asm.sqlite3__wasm_test_str_hello).apply(null,arguments)},i._sqlite3__wasm_SQLTester_strglob=function(){return(i._sqlite3__wasm_SQLTester_strglob=i.asm.sqlite3__wasm_SQLTester_strglob).apply(null,arguments)};var qe=i._malloc=function(){return(qe=i._malloc=i.asm.malloc).apply(null,arguments)};i._free=function(){return(i._free=i.asm.free).apply(null,arguments)},i._realloc=function(){return(i._realloc=i.asm.realloc).apply(null,arguments)};var ye,be=i._emscripten_builtin_memalign=function(){return(be=i._emscripten_builtin_memalign=i.asm.emscripten_builtin_memalign).apply(null,arguments)};function we(e){function t(){ye||(ye=!0,i.calledRun=!0,A||(i.noFSInit||ne.init.initialized||ne.init(),ne.ignorePermissions=!1,$(M),n(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)e=i.postRun.shift(),z.unshift(e);var e;$(z)}()))}B>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)e=i.preRun.shift(),j.unshift(e);var e;$(j)}(),B>0||(i.setStatus?(i.setStatus("Running..."),setTimeout((function(){setTimeout((function(){i.setStatus("")}),1),t()}),1)):t()))}if(i.stackSave=function(){return(i.stackSave=i.asm.stackSave).apply(null,arguments)},i.stackRestore=function(){return(i.stackRestore=i.asm.stackRestore).apply(null,arguments)},i.stackAlloc=function(){return(i.stackAlloc=i.asm.stackAlloc).apply(null,arguments)},i.wasmMemory=g,U=function e(){ye||we(),ye||(U=e)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();return we(),i.postRun||(i.postRun=[]),i.postRun.push((function(e){if(globalThis.sqlite3ApiBootstrap=function t(n=globalThis.sqlite3ApiConfig||t.defaultConfig){if(t.sqlite3)return(t.sqlite3.config||console).warn("sqlite3ApiBootstrap() called multiple times.","Config and external initializers are ignored on calls after the first."),t.sqlite3;const r=Object.assign(Object.create(null),{exports:void 0,memory:void 0,bigIntEnabled:!(void 0===e||!e.HEAPU64)||!!globalThis.BigInt64Array,debug:console.debug.bind(console),warn:console.warn.bind(console),error:console.error.bind(console),log:console.log.bind(console),wasmfsOpfsDir:"/opfs",useStdAlloc:!1},n||{});Object.assign(r,{allocExportName:r.useStdAlloc?"malloc":"sqlite3_malloc",deallocExportName:r.useStdAlloc?"free":"sqlite3_free",reallocExportName:r.useStdAlloc?"realloc":"sqlite3_realloc"},r),["exports","memory","wasmfsOpfsDir"].forEach((e=>{"function"==typeof r[e]&&(r[e]=r[e]())})),delete globalThis.sqlite3ApiConfig,delete t.defaultConfig;const s=Object.create(null),i=Object.create(null),o=e=>s.sqlite3_js_rc_str&&s.sqlite3_js_rc_str(e)||"Unknown result code #"+e;class a extends Error{constructor(...e){let t;if(e.length)if("number"==typeof(n=e[0])&&n===(0|n))if(t=e[0],1===e.length)super(o(e[0]));else{const n=o(t);"object"==typeof e[1]?super(n,e[1]):(e[0]=n+":",super(e.join(" ")))}else 2===e.length&&"object"==typeof e[1]?super(...e):super(e.join(" "));var n;this.resultCode=t||s.SQLITE_ERROR,this.name="SQLite3Error"}}a.toss=(...e)=>{throw new a(...e)};const l=a.toss;r.wasmfsOpfsDir&&!/^\/[^/]+$/.test(r.wasmfsOpfsDir)&&l("config.wasmfsOpfsDir must be falsy or in the form '/dir-name'.");const c=e=>"bigint"!=typeof e&&!!(e===(0|e)&&e<=2147483647&&e>=-2147483648),u="undefined"==typeof SharedArrayBuffer?function(){}:SharedArrayBuffer,_=e=>e.buffer instanceof u,p=(e,t,n)=>_(e)?e.slice(t,n):e.subarray(t,n),f=e=>e&&(e instanceof Uint8Array||e instanceof Int8Array||e instanceof ArrayBuffer),d=e=>e&&(e instanceof Uint8Array||e instanceof Int8Array||e instanceof ArrayBuffer),m=e=>f(e)||l("Value is not of a supported TypedArray type."),h=new TextDecoder("utf-8"),g=function(e,t,n){return h.decode(p(e,t,n))},q=function(e){return d(e)?g(e instanceof ArrayBuffer?new Uint8Array(e):e):Array.isArray(e)?e.join(""):(i.isPtr(e)&&(e=i.cstrToJs(e)),e)};class y extends Error{constructor(...e){2===e.length&&"object"==typeof e[1]?super(...e):e.length?super(e.join(" ")):super("Allocation failed."),this.resultCode=s.SQLITE_NOMEM,this.name="WasmAllocError"}}y.toss=(...e)=>{throw new y(...e)},Object.assign(s,{sqlite3_bind_blob:void 0,sqlite3_bind_text:void 0,sqlite3_create_function_v2:(e,t,n,r,s,i,o,a,l)=>{},sqlite3_create_function:(e,t,n,r,s,i,o,a)=>{},sqlite3_create_window_function:(e,t,n,r,s,i,o,a,l,c)=>{},sqlite3_prepare_v3:(e,t,n,r,s,i)=>{},sqlite3_prepare_v2:(e,t,n,r,s)=>{},sqlite3_exec:(e,t,n,r,s)=>{},sqlite3_randomness:(e,t)=>{}});const b={affirmBindableTypedArray:m,flexibleString:q,bigIntFits32:e=>e>=-2147483648n&&e<=0x7fffffffn,bigIntFits64:function e(t){return e._max||(e._max=BigInt("0x7fffffffffffffff"),e._min=~e._max),t>=e._min&&t<=e._max},bigIntFitsDouble:function e(t){return e._min||(e._min=Number.MIN_SAFE_INTEGER,e._max=Number.MAX_SAFE_INTEGER),t>=e._min&&t<=e._max},isBindableTypedArray:f,isInt32:c,isSQLableTypedArray:d,isTypedArray:e=>!!(e&&e.constructor&&c(e.constructor.BYTES_PER_ELEMENT))&&e,typedArrayToString:g,isUIThread:()=>globalThis.window===globalThis&&!!globalThis.document,isSharedTypedArray:_,toss:function(...e){throw new Error(e.join(" "))},toss3:l,typedArrayPart:p,affirmDbHeader:function(e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));const t="SQLite format 3";15>e.byteLength&&l("Input does not contain an SQLite3 database header.");for(let n=0;n<15;++n)t.charCodeAt(n)!==e[n]&&l("Input does not contain an SQLite3 database header.")},affirmIsDb:function(e){e instanceof ArrayBuffer&&(e=new Uint8Array(e));const t=e.byteLength;(t<512||t%512!=0)&&l("Byte array size",t,"is invalid for an SQLite3 db."),b.affirmDbHeader(e)}};Object.assign(i,{ptrSizeof:r.wasmPtrSizeof||4,ptrIR:r.wasmPtrIR||"i32",bigIntEnabled:!!r.bigIntEnabled,exports:r.exports||l("Missing API config.exports (WASM module exports)."),memory:r.memory||r.exports.memory||l("API config object requires a WebAssembly.Memory object","in either config.exports.memory (exported)","or config.memory (imported)."),alloc:void 0,realloc:void 0,dealloc:void 0}),i.allocFromTypedArray=function(e){e instanceof ArrayBuffer&&(e=new Uint8Array(e)),m(e);const t=i.alloc(e.byteLength||1);return i.heapForSize(e.constructor).set(e.byteLength?e:[0],t),t};{const e=r.allocExportName,t=r.deallocExportName,n=r.reallocExportName;for(const r of[e,t,n])i.exports[r]instanceof Function||l("Missing required exports[",r,"] function.");i.alloc=function e(t){return e.impl(t)||y.toss("Failed to allocate",t," bytes.")},i.alloc.impl=i.exports[e],i.realloc=function e(t,n){const r=e.impl(t,n);return n?r||y.toss("Failed to reallocate",n," bytes."):0},i.realloc.impl=i.exports[n],i.dealloc=i.exports[t]}let w;if(i.compileOptionUsed=function e(t){if(!arguments.length){if(e._result)return e._result;e._opt||(e._rx=/^([^=]+)=(.+)/,e._rxInt=/^-?\d+$/,e._opt=function(t,n){const r=e._rx.exec(t);n[0]=r?r[1]:t,n[1]=!r||(e._rxInt.test(r[2])?+r[2]:r[2])});const t={},n=[0,0];let r,i=0;for(;r=s.sqlite3_compileoption_get(i++);)e._opt(r,n),t[n[0]]=n[1];return e._result=t}if(Array.isArray(t)){const e={};return t.forEach((t=>{e[t]=s.sqlite3_compileoption_used(t)})),e}return"object"==typeof t?(Object.keys(t).forEach((e=>{t[e]=s.sqlite3_compileoption_used(e)})),t):"string"==typeof t&&!!s.sqlite3_compileoption_used(t)},i.pstack=Object.assign(Object.create(null),{restore:i.exports.sqlite3__wasm_pstack_restore,alloc:function(e){return"string"!=typeof e||(e=i.sizeofIR(e))||y.toss("Invalid value for pstack.alloc(",arguments[0],")"),i.exports.sqlite3__wasm_pstack_alloc(e)||y.toss("Could not allocate",e,"bytes from the pstack.")},allocChunks:function(e,t){"string"!=typeof t||(t=i.sizeofIR(t))||y.toss("Invalid size value for allocChunks(",arguments[1],")");const n=i.pstack.alloc(e*t),r=[];let s=0,o=0;for(;s<e;++s,o+=t)r.push(n+o);return r},allocPtr:(e=1,t=!0)=>1===e?i.pstack.alloc(t?8:i.ptrSizeof):i.pstack.allocChunks(e,t?8:i.ptrSizeof),call:function(e){const t=i.pstack.pointer;try{return e(S)}finally{i.pstack.restore(t)}}}),Object.defineProperties(i.pstack,{pointer:{configurable:!1,iterable:!0,writeable:!1,get:i.exports.sqlite3__wasm_pstack_ptr},quota:{configurable:!1,iterable:!0,writeable:!1,get:i.exports.sqlite3__wasm_pstack_quota},remaining:{configurable:!1,iterable:!0,writeable:!1,get:i.exports.sqlite3__wasm_pstack_remaining}}),s.sqlite3_randomness=(...e)=>{if(1===e.length&&b.isTypedArray(e[0])&&1===e[0].BYTES_PER_ELEMENT){const t=e[0];if(0===t.byteLength)return i.exports.sqlite3_randomness(0,0),t;const n=i.pstack.pointer;try{let e=t.byteLength,n=0;const r=i.exports.sqlite3_randomness,s=i.heap8u(),o=e<512?e:512,a=i.pstack.alloc(o);do{const i=e>o?o:e;r(i,a),t.set(p(s,a,a+i),n),e-=i,n+=i}while(e>0)}catch(e){console.error("Highly unexpected (and ignored!) exception in sqlite3_randomness():",e)}finally{i.pstack.restore(n)}return t}i.exports.sqlite3_randomness(...e)},s.sqlite3_wasmfs_opfs_dir=function(){if(void 0!==w)return w;const e=r.wasmfsOpfsDir;if(!(e&&globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle))return w="";try{return w=e&&0===i.xCallWrapped("sqlite3__wasm_init_wasmfs","i32",["string"],e)?e:""}catch(e){return w=""}},s.sqlite3_wasmfs_filename_is_persistent=function(e){const t=s.sqlite3_wasmfs_opfs_dir();return!(!t||!e)&&e.startsWith(t+"/")},s.sqlite3_js_db_uses_vfs=function(e,t,n=0){try{const r=s.sqlite3_vfs_find(t);return!!r&&(e?r===s.sqlite3_js_db_vfs(e,n)&&r:r===s.sqlite3_vfs_find(0)&&r)}catch(e){return!1}},s.sqlite3_js_vfs_list=function(){const e=[];let t=s.sqlite3_vfs_find(0);for(;t;){const n=new s.sqlite3_vfs(t);e.push(i.cstrToJs(n.$zName)),t=n.$pNext,n.dispose()}return e},s.sqlite3_js_db_export=function(e,t=0){(e=i.xWrap.testConvertArg("sqlite3*",e))||l("Invalid sqlite3* argument."),i.bigIntEnabled||l("BigInt64 support is not enabled.");const n=i.scopedAllocPush();let r;try{const n=i.scopedAlloc(8+i.ptrSizeof),s=n+8,o=t?i.isPtr(t)?t:i.scopedAllocCString(""+t):0;let a=i.exports.sqlite3__wasm_db_serialize(e,o,s,n,0);a&&l("Database serialization failed with code",S.capi.sqlite3_js_rc_str(a)),r=i.peekPtr(s);const c=i.peek(n,"i64");return a=c?i.heap8u().slice(r,r+Number(c)):new Uint8Array,a}finally{r&&i.exports.sqlite3_free(r),i.scopedAllocPop(n)}},s.sqlite3_js_db_vfs=(e,t=0)=>b.sqlite3__wasm_db_vfs(e,t),s.sqlite3_js_aggregate_context=(e,t)=>s.sqlite3_aggregate_context(e,t)||(t?y.toss("Cannot allocate",t,"bytes for sqlite3_aggregate_context()"):0),s.sqlite3_js_posix_create_file=function(e,t,n){let r;t&&i.isPtr(t)?r=t:t instanceof ArrayBuffer||t instanceof Uint8Array?(r=i.allocFromTypedArray(t),(arguments.length<3||!b.isInt32(n)||n<0)&&(n=t.byteLength)):a.toss("Invalid 2nd argument for sqlite3_js_posix_create_file().");try{(!b.isInt32(n)||n<0)&&a.toss("Invalid 3rd argument for sqlite3_js_posix_create_file().");const t=b.sqlite3__wasm_posix_create_file(e,r,n);t&&a.toss("Creation of file failed with sqlite3 result code",s.sqlite3_js_rc_str(t))}finally{i.dealloc(r)}},s.sqlite3_js_vfs_create_file=function(e,t,n,o){let l;r.warn("sqlite3_js_vfs_create_file() is deprecated and","should be avoided because it can lead to C-level crashes.","See its documentation for alternative options."),n?(i.isPtr(n)?l=n:n instanceof ArrayBuffer&&(n=new Uint8Array(n)),n instanceof Uint8Array?(l=i.allocFromTypedArray(n),(arguments.length<4||!b.isInt32(o)||o<0)&&(o=n.byteLength)):a.toss("Invalid 3rd argument type for sqlite3_js_vfs_create_file().")):l=0,(!b.isInt32(o)||o<0)&&(i.dealloc(l),a.toss("Invalid 4th argument for sqlite3_js_vfs_create_file()."));try{const n=b.sqlite3__wasm_vfs_create_file(e,t,l,o);n&&a.toss("Creation of file failed with sqlite3 result code",s.sqlite3_js_rc_str(n))}finally{i.dealloc(l)}},s.sqlite3_js_sql_to_string=e=>{if("string"==typeof e)return e;const t=q(v);return t===v?void 0:t},b.isUIThread()){const e=function(e){const t=Object.create(null);return t.prefix="kvvfs-"+e,t.stores=[],"session"!==e&&""!==e||t.stores.push(globalThis.sessionStorage),"local"!==e&&""!==e||t.stores.push(globalThis.localStorage),t};s.sqlite3_js_kvvfs_clear=function(t=""){let n=0;const r=e(t);return r.stores.forEach((e=>{const t=[];let s;for(s=0;s<e.length;++s){const n=e.key(s);n.startsWith(r.prefix)&&t.push(n)}t.forEach((t=>e.removeItem(t))),n+=t.length})),n},s.sqlite3_js_kvvfs_size=function(t=""){let n=0;const r=e(t);return r.stores.forEach((e=>{let t;for(t=0;t<e.length;++t){const s=e.key(t);s.startsWith(r.prefix)&&(n+=s.length,n+=e.getItem(s).length)}})),2*n}}s.sqlite3_db_config=function(e,t,...n){switch(this.s||(this.s=i.xWrap("sqlite3__wasm_db_config_s","int",["sqlite3*","int","string:static"]),this.pii=i.xWrap("sqlite3__wasm_db_config_pii","int",["sqlite3*","int","*","int","int"]),this.ip=i.xWrap("sqlite3__wasm_db_config_ip","int",["sqlite3*","int","int","*"])),t){case s.SQLITE_DBCONFIG_ENABLE_FKEY:case s.SQLITE_DBCONFIG_ENABLE_TRIGGER:case s.SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER:case s.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION:case s.SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE:case s.SQLITE_DBCONFIG_ENABLE_QPSG:case s.SQLITE_DBCONFIG_TRIGGER_EQP:case s.SQLITE_DBCONFIG_RESET_DATABASE:case s.SQLITE_DBCONFIG_DEFENSIVE:case s.SQLITE_DBCONFIG_WRITABLE_SCHEMA:case s.SQLITE_DBCONFIG_LEGACY_ALTER_TABLE:case s.SQLITE_DBCONFIG_DQS_DML:case s.SQLITE_DBCONFIG_DQS_DDL:case s.SQLITE_DBCONFIG_ENABLE_VIEW:case s.SQLITE_DBCONFIG_LEGACY_FILE_FORMAT:case s.SQLITE_DBCONFIG_TRUSTED_SCHEMA:case s.SQLITE_DBCONFIG_STMT_SCANSTATUS:case s.SQLITE_DBCONFIG_REVERSE_SCANORDER:return this.ip(e,t,n[0],n[1]||0);case s.SQLITE_DBCONFIG_LOOKASIDE:return this.pii(e,t,n[0],n[1],n[2]);case s.SQLITE_DBCONFIG_MAINDBNAME:return this.s(e,t,n[0]);default:return s.SQLITE_MISUSE}}.bind(Object.create(null)),s.sqlite3_value_to_js=function(e,t=!0){let n;const r=s.sqlite3_value_type(e);switch(r){case s.SQLITE_INTEGER:i.bigIntEnabled?(n=s.sqlite3_value_int64(e),b.bigIntFitsDouble(n)&&(n=Number(n))):n=s.sqlite3_value_double(e);break;case s.SQLITE_FLOAT:n=s.sqlite3_value_double(e);break;case s.SQLITE_TEXT:n=s.sqlite3_value_text(e);break;case s.SQLITE_BLOB:{const t=s.sqlite3_value_bytes(e),r=s.sqlite3_value_blob(e);t&&!r&&S.WasmAllocError.toss("Cannot allocate memory for blob argument of",t,"byte(s)"),n=t?i.heap8u().slice(r,r+Number(t)):null;break}case s.SQLITE_NULL:n=null;break;default:t&&l(s.SQLITE_MISMATCH,"Unhandled sqlite3_value_type():",r),n=void 0}return n},s.sqlite3_values_to_js=function(e,t,n=!0){let r;const o=[];for(r=0;r<e;++r)o.push(s.sqlite3_value_to_js(i.peekPtr(t+i.ptrSizeof*r),n));return o},s.sqlite3_result_error_js=function(e,t){t instanceof y?s.sqlite3_result_error_nomem(e):s.sqlite3_result_error(e,""+t,-1)},s.sqlite3_result_js=function(e,t){if(t instanceof Error)s.sqlite3_result_error_js(e,t);else try{switch(typeof t){case"undefined":break;case"boolean":s.sqlite3_result_int(e,t?1:0);break;case"bigint":b.bigIntFits32(t)?s.sqlite3_result_int(e,Number(t)):b.bigIntFitsDouble(t)?s.sqlite3_result_double(e,Number(t)):i.bigIntEnabled?b.bigIntFits64(t)?s.sqlite3_result_int64(e,t):l("BigInt value",t.toString(),"is too BigInt for int64."):l("BigInt value",t.toString(),"is too BigInt.");break;case"number":{let n;n=b.isInt32(t)?s.sqlite3_result_int:i.bigIntEnabled&&Number.isInteger(t)&&b.bigIntFits64(BigInt(t))?s.sqlite3_result_int64:s.sqlite3_result_double,n(e,t);break}case"string":{const[n,r]=i.allocCString(t,!0);s.sqlite3_result_text(e,n,r,s.SQLITE_WASM_DEALLOC);break}case"object":if(null===t){s.sqlite3_result_null(e);break}if(b.isBindableTypedArray(t)){const n=i.allocFromTypedArray(t);s.sqlite3_result_blob(e,n,t.byteLength,s.SQLITE_WASM_DEALLOC);break}default:l("Don't not how to handle this UDF result value:",typeof t,t)}}catch(t){s.sqlite3_result_error_js(e,t)}},s.sqlite3_column_js=function(e,t,n=!0){const r=s.sqlite3_column_value(e,t);return 0===r?void 0:s.sqlite3_value_to_js(r,n)};const E=function(e,t,n){n=s[n],this.ptr?i.pokePtr(this.ptr,0):this.ptr=i.allocPtr();const r=n(e,t,this.ptr);if(r)return a.toss(r,arguments[2]+"() failed with code "+r);const o=i.peekPtr(this.ptr);return o?s.sqlite3_value_to_js(o,!0):void 0}.bind(Object.create(null));s.sqlite3_preupdate_new_js=(e,t)=>E(e,t,"sqlite3_preupdate_new"),s.sqlite3_preupdate_old_js=(e,t)=>E(e,t,"sqlite3_preupdate_old"),s.sqlite3changeset_new_js=(e,t)=>E(e,t,"sqlite3changeset_new"),s.sqlite3changeset_old_js=(e,t)=>E(e,t,"sqlite3changeset_old");const S={WasmAllocError:y,SQLite3Error:a,capi:s,util:b,wasm:i,config:r,version:Object.create(null),client:void 0,asyncPostInit:async function e(){if(e.isReady instanceof Promise)return e.isReady;let n=t.initializersAsync;delete t.initializersAsync;const s=async()=>(S.__isUnderTest||(delete S.util,delete S.StructBinder),S),i=e=>{throw r.error("an async sqlite3 initializer failed:",e),e};if(!n||!n.length)return e.isReady=s().catch(i);n=n.map((e=>e instanceof Function?async t=>e(S):e)),n.push(s);let o=Promise.resolve(S);for(;n.length;)o=o.then(n.shift());return e.isReady=o.catch(i)},scriptInfo:void 0};try{t.initializers.forEach((e=>{e(S)}))}catch(e){throw console.error("sqlite3 bootstrap initializer threw:",e),e}return delete t.initializers,t.sqlite3=S,S},globalThis.sqlite3ApiBootstrap.initializers=[],globalThis.sqlite3ApiBootstrap.initializersAsync=[],globalThis.sqlite3ApiBootstrap.defaultConfig=Object.create(null),globalThis.sqlite3ApiBootstrap.sqlite3=void 0,globalThis.WhWasmUtilInstaller=function(e){void 0===e.bigIntEnabled&&(e.bigIntEnabled=!!globalThis.BigInt64Array);const t=(...e)=>{throw new Error(e.join(" "))};e.exports||Object.defineProperty(e,"exports",{enumerable:!0,configurable:!0,get:()=>e.instance&&e.instance.exports});const n=e.pointerIR||"i32",r=e.ptrSizeof="i32"===n?4:"i64"===n?8:t("Unhandled ptrSizeof:",n),s=Object.create(null);s.heapSize=0,s.memory=null,s.freeFuncIndexes=[],s.scopedAlloc=[],s.utf8Decoder=new TextDecoder,s.utf8Encoder=new TextEncoder("utf-8"),e.sizeofIR=e=>{switch(e){case"i8":return 1;case"i16":return 2;case"i32":case"f32":case"float":return 4;case"i64":case"f64":case"double":return 8;case"*":return r;default:return(""+e).endsWith("*")?r:void 0}};const i=function(){if(s.memory){if(s.heapSize===s.memory.buffer.byteLength)return s}else s.memory=e.memory instanceof WebAssembly.Memory?e.memory:e.exports.memory;const t=s.memory.buffer;return s.HEAP8=new Int8Array(t),s.HEAP8U=new Uint8Array(t),s.HEAP16=new Int16Array(t),s.HEAP16U=new Uint16Array(t),s.HEAP32=new Int32Array(t),s.HEAP32U=new Uint32Array(t),e.bigIntEnabled&&(s.HEAP64=new BigInt64Array(t),s.HEAP64U=new BigUint64Array(t)),s.HEAP32F=new Float32Array(t),s.HEAP64F=new Float64Array(t),s.heapSize=t.byteLength,s};e.heap8=()=>i().HEAP8,e.heap8u=()=>i().HEAP8U,e.heap16=()=>i().HEAP16,e.heap16u=()=>i().HEAP16U,e.heap32=()=>i().HEAP32,e.heap32u=()=>i().HEAP32U,e.heapForSize=function(n,r=!0){const o=s.memory&&s.heapSize===s.memory.buffer.byteLength?s:i();switch(n){case Int8Array:return o.HEAP8;case Uint8Array:return o.HEAP8U;case Int16Array:return o.HEAP16;case Uint16Array:return o.HEAP16U;case Int32Array:return o.HEAP32;case Uint32Array:return o.HEAP32U;case 8:return r?o.HEAP8U:o.HEAP8;case 16:return r?o.HEAP16U:o.HEAP16;case 32:return r?o.HEAP32U:o.HEAP32;case 64:if(o.HEAP64)return r?o.HEAP64U:o.HEAP64;break;default:if(e.bigIntEnabled){if(n===globalThis.BigUint64Array)return o.HEAP64U;if(n===globalThis.BigInt64Array)return o.HEAP64;break}}t("Invalid heapForSize() size: expecting 8, 16, 32,","or (if BigInt is enabled) 64.")},e.functionTable=function(){return e.exports.__indirect_function_table},e.functionEntry=function(t){const n=e.functionTable();return t<n.length?n.get(t):void 0},e.jsFuncToWasm=function e(n,r){if(e._||(e._={sigTypes:Object.assign(Object.create(null),{i:"i32",p:"i32",P:"i32",s:"i32",j:"i64",f:"f32",d:"f64"}),typeCodes:Object.assign(Object.create(null),{f64:124,f32:125,i64:126,i32:127}),uleb128Encode:function(e,t,n){n<128?e[t](n):e[t](n%128|128,n>>7)},rxJSig:/^(\w)\((\w*)\)$/,sigParams:function(t){const n=e._.rxJSig.exec(t);return n?n[2]:t.substr(1)},letterType:n=>e._.sigTypes[n]||t("Invalid signature letter:",n),pushSigType:(t,n)=>t.push(e._.typeCodes[e._.letterType(n)])}),"string"==typeof n){const e=r;r=n,n=e}const s=e._.sigParams(r),i=[1,96];e._.uleb128Encode(i,"push",s.length);for(const t of s)e._.pushSigType(i,t);return"v"===r[0]?i.push(0):(i.push(1),e._.pushSigType(i,r[0])),e._.uleb128Encode(i,"unshift",i.length),i.unshift(0,97,115,109,1,0,0,0,1),i.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array(i)),{e:{f:n}}).exports.f};const o=function(n,r,i){if(i&&!s.scopedAlloc.length&&t("No scopedAllocPush() scope is active."),"string"==typeof n){const e=r;r=n,n=e}"string"==typeof r&&n instanceof Function||t("Invalid arguments: expecting (function,signature) or (signature,function).");const o=e.functionTable(),a=o.length;let l;for(;s.freeFuncIndexes.length&&(l=s.freeFuncIndexes.pop(),o.get(l));)l=null;l||(l=a,o.grow(1));try{return o.set(l,n),i&&s.scopedAlloc[s.scopedAlloc.length-1].push(l),l}catch(e){if(!(e instanceof TypeError))throw l===a&&s.freeFuncIndexes.push(a),e}try{const t=e.jsFuncToWasm(n,r);o.set(l,t),i&&s.scopedAlloc[s.scopedAlloc.length-1].push(l)}catch(e){throw l===a&&s.freeFuncIndexes.push(a),e}return l};e.installFunction=(e,t)=>o(e,t,!1),e.scopedInstallFunction=(e,t)=>o(e,t,!0),e.uninstallFunction=function(t){if(!t&&0!==t)return;const n=s.freeFuncIndexes,r=e.functionTable();n.push(t);const i=r.get(t);return r.set(t,null),i},e.peek=function(r,o="i8"){o.endsWith("*")&&(o=n);const a=s.memory&&s.heapSize===s.memory.buffer.byteLength?s:i(),l=Array.isArray(r)?[]:void 0;let c;do{switch(l&&(r=arguments[0].shift()),o){case"i1":case"i8":c=a.HEAP8[0|r];break;case"i16":c=a.HEAP16[r>>1];break;case"i32":c=a.HEAP32[r>>2];break;case"float":case"f32":c=a.HEAP32F[r>>2];break;case"double":case"f64":c=Number(a.HEAP64F[r>>3]);break;case"i64":if(e.bigIntEnabled){c=BigInt(a.HEAP64[r>>3]);break}default:t("Invalid type for peek():",o)}l&&l.push(c)}while(l&&arguments[0].length);return l||c},e.poke=function(e,r,o="i8"){o.endsWith("*")&&(o=n);const a=s.memory&&s.heapSize===s.memory.buffer.byteLength?s:i();for(const n of Array.isArray(e)?e:[e])switch(o){case"i1":case"i8":a.HEAP8[0|n]=r;continue;case"i16":a.HEAP16[n>>1]=r;continue;case"i32":a.HEAP32[n>>2]=r;continue;case"float":case"f32":a.HEAP32F[n>>2]=r;continue;case"double":case"f64":a.HEAP64F[n>>3]=r;continue;case"i64":if(a.HEAP64){a.HEAP64[n>>3]=BigInt(r);continue}default:t("Invalid type for poke(): "+o)}return this},e.peekPtr=(...t)=>e.peek(1===t.length?t[0]:t,n),e.pokePtr=(t,r=0)=>e.poke(t,r,n),e.peek8=(...t)=>e.peek(1===t.length?t[0]:t,"i8"),e.poke8=(t,n)=>e.poke(t,n,"i8"),e.peek16=(...t)=>e.peek(1===t.length?t[0]:t,"i16"),e.poke16=(t,n)=>e.poke(t,n,"i16"),e.peek32=(...t)=>e.peek(1===t.length?t[0]:t,"i32"),e.poke32=(t,n)=>e.poke(t,n,"i32"),e.peek64=(...t)=>e.peek(1===t.length?t[0]:t,"i64"),e.poke64=(t,n)=>e.poke(t,n,"i64"),e.peek32f=(...t)=>e.peek(1===t.length?t[0]:t,"f32"),e.poke32f=(t,n)=>e.poke(t,n,"f32"),e.peek64f=(...t)=>e.peek(1===t.length?t[0]:t,"f64"),e.poke64f=(t,n)=>e.poke(t,n,"f64"),e.getMemValue=e.peek,e.getPtrValue=e.peekPtr,e.setMemValue=e.poke,e.setPtrValue=e.pokePtr,e.isPtr32=e=>"number"==typeof e&&e===(0|e)&&e>=0,e.isPtr=e.isPtr32,e.cstrlen=function(t){if(!t||!e.isPtr(t))return null;const n=i().HEAP8U;let r=t;for(;0!==n[r];++r);return r-t};const a="undefined"==typeof SharedArrayBuffer?function(){}:SharedArrayBuffer;e.cstrToJs=function(t){const n=e.cstrlen(t);return n?(r=i().HEAP8U,o=t,l=t+n,s.utf8Decoder.decode(r.buffer instanceof a?r.slice(o,l):r.subarray(o,l))):null===n?n:"";var r,o,l},e.jstrlen=function(e){if("string"!=typeof e)return null;const t=e.length;let n=0;for(let r=0;r<t;++r){let t=e.charCodeAt(r);t>=55296&&t<=57343&&(t=65536+((1023&t)<<10)|1023&e.charCodeAt(++r)),t<=127?++n:n+=t<=2047?2:t<=65535?3:4}return n},e.jstrcpy=function(e,n,r=0,s=-1,i=!0){if(n&&(n instanceof Int8Array||n instanceof Uint8Array)||t("jstrcpy() target must be an Int8Array or Uint8Array."),s<0&&(s=n.length-r),!(s>0&&r>=0))return 0;let o=0,a=e.length;const l=r,c=r+s-(i?1:0);for(;o<a&&r<c;++o){let t=e.charCodeAt(o);if(t>=55296&&t<=57343&&(t=65536+((1023&t)<<10)|1023&e.charCodeAt(++o)),t<=127){if(r>=c)break;n[r++]=t}else if(t<=2047){if(r+1>=c)break;n[r++]=192|t>>6,n[r++]=128|63&t}else if(t<=65535){if(r+2>=c)break;n[r++]=224|t>>12,n[r++]=128|t>>6&63,n[r++]=128|63&t}else{if(r+3>=c)break;n[r++]=240|t>>18,n[r++]=128|t>>12&63,n[r++]=128|t>>6&63,n[r++]=128|63&t}}return i&&(n[r++]=0),r-l},e.cstrncpy=function(n,r,s){if(n&&r||t("cstrncpy() does not accept NULL strings."),s<0)s=e.cstrlen(strPtr)+1;else if(!(s>0))return 0;const i=e.heap8u();let o,a=0;for(;a<s&&(o=i[r+a]);++a)i[n+a]=o;return a<s&&(i[n+a++]=0),a},e.jstrToUintArray=(e,t=!1)=>s.utf8Encoder.encode(t?e+"\0":e);const l=(e,n)=>{e.alloc instanceof Function&&e.dealloc instanceof Function||t("Object is missing alloc() and/or dealloc() function(s)","required by",n+"().")},c=function(t,n,r,o){if(l(e,o),"string"!=typeof t)return null;{const e=s.utf8Encoder.encode(t),o=r(e.length+1),a=i().HEAP8U;return a.set(e,o),a[o+e.length]=0,n?[o,e.length]:o}};e.allocCString=(t,n=!1)=>c(t,n,e.alloc,"allocCString()"),e.scopedAllocPush=function(){l(e,"scopedAllocPush");const t=[];return s.scopedAlloc.push(t),t},e.scopedAllocPop=function(n){l(e,"scopedAllocPop");const r=arguments.length?s.scopedAlloc.indexOf(n):s.scopedAlloc.length-1;r<0&&t("Invalid state object for scopedAllocPop()."),0===arguments.length&&(n=s.scopedAlloc[r]),s.scopedAlloc.splice(r,1);for(let t;t=n.pop();)e.functionEntry(t)?e.uninstallFunction(t):e.dealloc(t)},e.scopedAlloc=function(n){s.scopedAlloc.length||t("No scopedAllocPush() scope is active.");const r=e.alloc(n);return s.scopedAlloc[s.scopedAlloc.length-1].push(r),r},Object.defineProperty(e.scopedAlloc,"level",{configurable:!1,enumerable:!1,get:()=>s.scopedAlloc.length,set:()=>t("The 'active' property is read-only.")}),e.scopedAllocCString=(t,n=!1)=>c(t,n,e.scopedAlloc,"scopedAllocCString()");const u=function(t,n){const r=e[t?"scopedAlloc":"alloc"]((n.length+1)*e.ptrSizeof);let s=0;return n.forEach((n=>{e.pokePtr(r+e.ptrSizeof*s++,e[t?"scopedAllocCString":"allocCString"](""+n))})),e.pokePtr(r+e.ptrSizeof*s,0),r};e.scopedAllocMainArgv=e=>u(!0,e),e.allocMainArgv=e=>u(!1,e),e.cArgvToJs=(t,n)=>{const r=[];for(let s=0;s<t;++s){const t=e.peekPtr(n+e.ptrSizeof*s);r.push(t?e.cstrToJs(t):null)}return r},e.scopedAllocCall=function(t){e.scopedAllocPush();try{return t()}finally{e.scopedAllocPop()}};const _=function(t,s,i){l(e,i);const o=s?"i64":n;let a=e[i](t*(s?8:r));if(e.poke(a,0,o),1===t)return a;const c=[a];for(let n=1;n<t;++n)a+=s?8:r,c[n]=a,e.poke(a,0,o);return c};e.allocPtr=(e=1,t=!0)=>_(e,t,"alloc"),e.scopedAllocPtr=(e=1,t=!0)=>_(e,t,"scopedAlloc"),e.xGet=function(n){return e.exports[n]||t("Cannot find exported symbol:",n)};const p=(e,n)=>t(e+"() requires",n,"argument(s).");e.xCall=function(n,...r){const s=n instanceof Function?n:e.xGet(n);return s instanceof Function||t("Exported symbol",n,"is not a function."),s.length!==r.length&&p(s===n?s.name:n,s.length),2===arguments.length&&Array.isArray(arguments[1])?s.apply(null,arguments[1]):s.apply(null,r)},s.xWrap=Object.create(null),s.xWrap.convert=Object.create(null),s.xWrap.convert.arg=new Map,s.xWrap.convert.result=new Map;const f=s.xWrap.convert.arg,d=s.xWrap.convert.result;e.bigIntEnabled&&f.set("i64",(e=>BigInt(e)));const m="i32"===n?e=>0|e:e=>BigInt(e)|BigInt(0);f.set("i32",m).set("i16",(e=>65535&e)).set("i8",(e=>255&e)).set("f32",(e=>Number(e).valueOf())).set("float",f.get("f32")).set("f64",f.get("f32")).set("double",f.get("f64")).set("int",f.get("i32")).set("null",(e=>e)).set(null,f.get("null")).set("**",m).set("*",m),d.set("*",m).set("pointer",m).set("number",(e=>Number(e))).set("void",(e=>{})).set("null",(e=>e)).set(null,d.get("null"));{const r=["i8","i16","i32","int","f32","float","f64","double"];e.bigIntEnabled&&r.push("i64");const s=f.get(n);for(const e of r)f.set(e+"*",s),d.set(e+"*",s),d.set(e,f.get(e)||t("Missing arg converter:",e))}const h=function(t){return"string"==typeof t?e.scopedAllocCString(t):t?m(t):null};f.set("string",h).set("utf8",h).set("pointer",h),d.set("string",(t=>e.cstrToJs(t))).set("utf8",d.get("string")).set("string:dealloc",(t=>{try{return t?e.cstrToJs(t):null}finally{e.dealloc(t)}})).set("utf8:dealloc",d.get("string:dealloc")).set("json",(t=>JSON.parse(e.cstrToJs(t)))).set("json:dealloc",(t=>{try{return t?JSON.parse(e.cstrToJs(t)):null}finally{e.dealloc(t)}}));const g=class{constructor(e){this.name=e.name||"unnamed adapter"}convertArg(e,n,r){t("AbstractArgAdapter must be subclassed.")}};f.FuncPtrAdapter=class n extends g{constructor(e){super(e),f.FuncPtrAdapter.warnOnUse&&console.warn("xArg.FuncPtrAdapter is an internal-only API","and is not intended to be invoked from","client-level code. Invoked with:",e),this.name=e.name||"unnamed",this.signature=e.signature,e.contextKey instanceof Function&&(this.contextKey=e.contextKey,e.bindScope||(e.bindScope="context")),this.bindScope=e.bindScope||t("FuncPtrAdapter options requires a bindScope (explicit or implied)."),n.bindScopes.indexOf(e.bindScope)<0&&t("Invalid options.bindScope ("+e.bindMod+") for FuncPtrAdapter. Expecting one of: ("+n.bindScopes.join(", ")+")"),this.isTransient="transient"===this.bindScope,this.isContext="context"===this.bindScope,this.isPermanent="permanent"===this.bindScope,this.singleton="singleton"===this.bindScope?[]:void 0,this.callProxy=e.callProxy instanceof Function?e.callProxy:void 0}contextKey(e,t){return this}contextMap(e){const t=this.__cmap||(this.__cmap=new Map);let n=t.get(e);return void 0===n&&t.set(e,n=[]),n}convertArg(t,r,i){let a=this.singleton;if(!a&&this.isContext&&(a=this.contextMap(this.contextKey(r,i))),a&&a[0]===t)return a[1];if(t instanceof Function){this.callProxy&&(t=this.callProxy(t));const e=o(t,this.signature,this.isTransient);if(n.debugFuncInstall&&n.debugOut("FuncPtrAdapter installed",this,this.contextKey(r,i),"@"+e,t),a){if(a[1]){n.debugFuncInstall&&n.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(r,i),"@"+a[1],t);try{s.scopedAlloc[s.scopedAlloc.length-1].push(a[1])}catch(e){}}a[0]=t,a[1]=e}return e}if(e.isPtr(t)||null==t){if(a&&a[1]&&a[1]!==t){n.debugFuncInstall&&n.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(r,i),"@"+a[1],t);try{s.scopedAlloc[s.scopedAlloc.length-1].push(a[1])}catch(e){}a[0]=a[1]=0|t}return t||0}throw new TypeError("Invalid FuncPtrAdapter argument type. Expecting a function pointer or a "+(this.name?this.name+" ":"")+"function matching signature "+this.signature+".")}},f.FuncPtrAdapter.warnOnUse=!1,f.FuncPtrAdapter.debugFuncInstall=!1,f.FuncPtrAdapter.debugOut=console.debug.bind(console),f.FuncPtrAdapter.bindScopes=["transient","context","singleton","permanent"];const q=e=>f.get(e)||t("Argument adapter not found:",e),y=e=>d.get(e)||t("Result adapter not found:",e);s.xWrap.convertArg=(e,...t)=>q(e)(...t),s.xWrap.convertArgNoCheck=(e,...t)=>f.get(e)(...t),s.xWrap.convertResult=(e,t)=>null===e?t:e?y(e)(t):void 0,s.xWrap.convertResultNoCheck=(e,t)=>null===e?t:e?d.get(e)(t):void 0,e.xWrap=function(n,r,...i){3===arguments.length&&Array.isArray(arguments[2])&&(i=arguments[2]),e.isPtr(n)&&(n=e.functionEntry(n)||t("Function pointer not found in WASM function table."));const o=n instanceof Function,a=o?n:e.xGet(n);if(o&&(n=a.name||"unnamed function"),i.length!==a.length&&p(n,a.length),null===r&&0===a.length)return a;null!=r&&y(r);for(const e of i)e instanceof g?f.set(e,((...t)=>e.convertArg(...t))):q(e);const l=s.xWrap;return 0===a.length?(...e)=>e.length?p(n,a.length):l.convertResult(r,a.call(null)):function(...t){t.length!==a.length&&p(n,a.length);const s=e.scopedAllocPush();try{let e=0;for(;e<t.length;++e)t[e]=l.convertArgNoCheck(i[e],t[e],t,e);return l.convertResultNoCheck(r,a.apply(null,t))}finally{e.scopedAllocPop(s)}}};const b=function(e,n,r,s,i,o){if("string"==typeof r){if(1===n)return o.get(r);if(2===n)return s?(s instanceof Function||t(i,"requires a function argument."),o.set(r,s),e):(o.get(r),e)}t("Invalid arguments to",i)};return e.xWrap.resultAdapter=function e(t,n){return b(e,arguments.length,t,n,"resultAdapter()",d)},e.xWrap.argAdapter=function e(t,n){return b(e,arguments.length,t,n,"argAdapter()",f)},e.xWrap.FuncPtrAdapter=f.FuncPtrAdapter,e.xCallWrapped=function(t,n,r,...s){return Array.isArray(arguments[3])&&(s=arguments[3]),e.xWrap(t,n,r||[]).apply(null,s||[])},e.xWrap.testConvertArg=s.xWrap.convertArg,e.xWrap.testConvertResult=s.xWrap.convertResult,e},globalThis.WhWasmUtilInstaller.yawl=function(e){const t=()=>fetch(e.uri,{credentials:"same-origin"}),n=this,r=function(t){if(e.wasmUtilTarget){const r=(...e)=>{throw new Error(e.join(" "))},s=e.wasmUtilTarget;if(s.module=t.module,s.instance=t.instance,s.instance.exports.memory||(s.memory=e.imports&&e.imports.env&&e.imports.env.memory||r("Missing 'memory' object!")),!s.alloc&&t.instance.exports.malloc){const e=t.instance.exports;s.alloc=function(t){return e.malloc(t)||r("Allocation of",t,"bytes failed.")},s.dealloc=function(t){e.free(t)}}n(s)}return e.onload&&e.onload(t,e),t};return WebAssembly.instantiateStreaming?function(){return WebAssembly.instantiateStreaming(t(),e.imports||{}).then(r)}:function(){return t().then((e=>e.arrayBuffer())).then((t=>WebAssembly.instantiate(t,e.imports||{}))).then(r)}}.bind(globalThis.WhWasmUtilInstaller),globalThis.Jaccwabyt=function e(t){const n=(...e)=>{throw new Error(e.join(" "))};t.heap instanceof WebAssembly.Memory||t.heap instanceof Function||n("config.heap must be WebAssembly.Memory instance or a function."),["alloc","dealloc"].forEach((function(e){t[e]instanceof Function||n("Config option '"+e+"' must be a function.")}));const r=e,s=t.heap instanceof Function?t.heap:()=>new Uint8Array(t.heap.buffer),i=t.alloc,o=t.dealloc,a=t.log||console.log.bind(console),l=t.memberPrefix||"",c=t.memberSuffix||"",u=void 0===t.bigIntEnabled?!!globalThis.BigInt64Array:!!t.bigIntEnabled,_=globalThis.BigInt,p=globalThis.BigInt64Array,f=t.ptrSizeof||4,d=t.ptrIR||"i32";r.debugFlags||(r.__makeDebugFlags=function(e=null){e&&e.__flags&&(e=e.__flags);const t=function e(t){return 0===arguments.length?e.__flags:(t<0?(delete e.__flags.getter,delete e.__flags.setter,delete e.__flags.alloc,delete e.__flags.dealloc):(e.__flags.getter=!!(1&t),e.__flags.setter=!!(2&t),e.__flags.alloc=!!(4&t),e.__flags.dealloc=!!(8&t)),e._flags)};return Object.defineProperty(t,"__flags",{iterable:!1,writable:!1,value:Object.create(e)}),e||t(0),t},r.debugFlags=r.__makeDebugFlags());const m=function(){const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]}(),h=e=>(e=>"("===e[1])(e)?"p":e[0],g=function(e){switch(h(e)){case"c":case"C":return"i8";case"i":return"i32";case"p":case"P":case"s":return d;case"j":return"i64";case"f":return"float";case"d":return"double"}n("Unhandled signature IR:",e)},q=p?()=>!0:()=>n("BigInt64Array is not available."),y=(e,t)=>e+"::"+t,b=new WeakMap,w="(pointer-is-external)",v=function(e,t,n){if(n||(n=b.get(t)),n){if(b.delete(t),Array.isArray(t.ondispose)){let r;for(;r=t.ondispose.shift();)try{r instanceof Function?r.call(t):r instanceof R?r.dispose():"number"==typeof r&&o(r)}catch(t){console.warn("ondispose() for",e.structName,"@",n,"threw. NOT propagating it.",t)}}else if(t.ondispose instanceof Function)try{t.ondispose()}catch(t){console.warn("ondispose() for",e.structName,"@",n,"threw. NOT propagating it.",t)}delete t.ondispose,e.debugFlags.__flags.dealloc&&a("debug.dealloc:",t[w]?"EXTERNAL":"",e.structName,"instance:",e.structInfo.sizeof,"bytes @"+n),t[w]||o(n)}},E=e=>({configurable:!1,writable:!1,iterable:!1,value:e}),S=function(e,t,r){let o=!r;r?Object.defineProperty(t,w,E(r)):(r=i(e.structInfo.sizeof))||n("Allocation of",e.structName,"structure failed.");try{e.debugFlags.__flags.alloc&&a("debug.alloc:",o?"":"EXTERNAL",e.structName,"instance:",e.structInfo.sizeof,"bytes @"+r),o&&s().fill(0,r,r+e.structInfo.sizeof),b.set(t,r)}catch(n){throw v(e,t,r),n}},x=E((e=>l+e+c)),A=function(e,t,r=!0){let s=e.members[t];if(!s&&(l||c)){for(const n of Object.values(e.members))if(n.key===t){s=n;break}!s&&r&&n(y(e.name,t),"is not a mapped struct member.")}return s},I=function e(t,n,r=!1){e._||(e._=e=>e.replace(/[^vipPsjrdcC]/g,"").replace(/[pPscC]/g,"i"));const s=A(t.structInfo,n,!0);return r?e._(s.signature):s.signature},T={configurable:!1,enumerable:!1,get:function(){return b.get(this)},set:()=>n("Cannot assign the 'pointer' property of a struct.")},k=E((function(){const e=[];for(const t of Object.keys(this.structInfo.members))e.push(this.memberKey(t));return e})),F=new TextDecoder("utf-8"),O=new TextEncoder,P="undefined"==typeof SharedArrayBuffer?function(){}:SharedArrayBuffer,L=function(e){"s"!==e.signature&&n("Invalid member type signature for C-string value:",JSON.stringify(e))},C=function(e,t){const n=A(e.structInfo,t,!0);L(n);const r=e[n.key];if(!r)return null;let i=r;const o=s();for(;0!==o[i];++i);return r===i?"":(a=o,l=r,c=i,F.decode(a.buffer instanceof P?a.slice(l,c):a.subarray(l,c)));var a,l,c},D=function(e,...t){e.ondispose?Array.isArray(e.ondispose)||(e.ondispose=[e.ondispose]):e.ondispose=[],e.ondispose.push(...t)},N=function(e){const t=O.encode(e),r=i(t.length+1);r||n("Allocation error while duplicating string:",e);const o=s();return o.set(t,r),o[r+t.length]=0,r},R=function(e,t){arguments[2]!==E&&n("Do not call the StructType constructor","from client-level code."),Object.defineProperties(this,{structName:E(e),structInfo:E(t)})};R.prototype=Object.create(null,{dispose:E((function(){v(this.constructor,this)})),lookupMember:E((function(e,t=!0){return A(this.structInfo,e,t)})),memberToJsString:E((function(e){return C(this,e)})),memberIsString:E((function(e,t=!0){return function(e,t,n=!1){const r=A(e.structInfo,t,n);return!(!r||1!==r.signature.length||"s"!==r.signature[0])&&r}(this,e,t)})),memberKey:x,memberKeys:k,memberSignature:E((function(e,t=!1){return I(this,e,t)})),memoryDump:E((function(){const e=this.pointer;return e?new Uint8Array(s().slice(e,e+this.structInfo.sizeof)):null})),pointer:T,setMemberCString:E((function(e,t){return function(e,t,n){const r=A(e.structInfo,t,!0);L(r);const s=N(n);return e[r.key]=s,D(e,s),e}(this,e,t)}))}),Object.assign(R.prototype,{addOnDispose:function(...e){return D(this,...e),this}}),Object.defineProperties(R,{allocCString:E(N),isA:E((e=>e instanceof R)),hasExternalPointer:E((e=>e instanceof R&&!!e[w])),memberKey:x});const j=e=>Number.isFinite(e)||e instanceof(_||Number),M=function e(t,r,i){if(!e._){e._={getters:{},setters:{},sw:{}};const t=["i","c","C","p","P","s","f","d","v()"];u&&t.push("j"),t.forEach((function(t){e._.getters[t]=function(e){switch(h(e)){case"p":case"P":case"s":switch(f){case 4:return"getInt32";case 8:return q()&&"getBigInt64"}break;case"i":return"getInt32";case"c":return"getInt8";case"C":return"getUint8";case"j":return q()&&"getBigInt64";case"f":return"getFloat32";case"d":return"getFloat64"}n("Unhandled DataView getter for signature:",e)}(t),e._.setters[t]=function(e){switch(h(e)){case"p":case"P":case"s":switch(f){case 4:return"setInt32";case 8:return q()&&"setBigInt64"}break;case"i":return"setInt32";case"c":return"setInt8";case"C":return"setUint8";case"j":return q()&&"setBigInt64";case"f":return"setFloat32";case"d":return"setFloat64"}n("Unhandled DataView setter for signature:",e)}(t),e._.sw[t]=function(e){switch(h(e)){case"i":case"f":case"c":case"C":case"d":return Number;case"j":return q()&&_;case"p":case"P":case"s":switch(f){case 4:return Number;case 8:return q()&&_}}n("Unhandled DataView set wrapper for signature:",e)}(t)}));const r=/^[ipPsjfdcC]$/,s=/^[vipPsjfdcC]\([ipPsjfdcC]*\)$/;e.sigCheck=function(e,t,i,o){Object.prototype.hasOwnProperty.call(e,i)&&n(e.structName,"already has a property named",i+"."),r.test(o)||s.test(o)||n("Malformed signature for",y(e.structName,t)+":",o)}}const o=t.memberKey(r);e.sigCheck(t.prototype,r,o,i.signature),i.key=o,i.name=r;const l=h(i.signature),c=y(t.prototype.structName,o),p=t.prototype.debugFlags.__flags,d=Object.create(null);var b,w;d.configurable=!1,d.enumerable=!1,d.get=function(){p.getter&&a("debug.getter:",e._.getters[l],"for",g(l),c,"@",this.pointer,"+",i.offset,"sz",i.sizeof);let t=new DataView(s().buffer,this.pointer+i.offset,i.sizeof)[e._.getters[l]](0,m);return p.getter&&a("debug.getter:",c,"result =",t),t},i.readOnly?d.set=(b=t.prototype.structName,w=o,()=>n(y(b,w),"is read-only.")):d.set=function(t){if(p.setter&&a("debug.setter:",e._.setters[l],"for",g(l),c,"@",this.pointer,"+",i.offset,"sz",i.sizeof,t),this.pointer||n("Cannot set struct property on disposed instance."),null===t)t=0;else for(;!j(t);){if("P"===i.signature&&t instanceof R){t=t.pointer||0,p.setter&&a("debug.setter:",c,"resolved to",t);break}n("Invalid value for pointer-type",c+".")}new DataView(s().buffer,this.pointer+i.offset,i.sizeof)[e._.setters[l]](0,e._.sw[l](t),m)},Object.defineProperty(t.prototype,o,d)},z=function e(t,s){1===arguments.length?t=(s=t).name:s.name||(s.name=t),t||n("Struct name is required.");let i=!1;Object.keys(s.members).forEach((e=>{const r=s.members[e];r.sizeof?1===r.sizeof?"c"===r.signature||"C"===r.signature||n("Unexpected sizeof==1 member",y(s.name,e),"with signature",r.signature):(0!=r.sizeof%4&&(console.warn("Invalid struct member description =",r,"from",s),n(t,"member",e,"sizeof is not aligned. sizeof="+r.sizeof)),0!=r.offset%4&&(console.warn("Invalid struct member description =",r,"from",s),n(t,"member",e,"offset is not aligned. offset="+r.offset))):n(t,"member",e,"is missing sizeof."),(!i||i.offset<r.offset)&&(i=r)})),i?s.sizeof<i.offset+i.sizeof&&n("Invalid struct config:",t,"max member offset ("+i.offset+") ","extends past end of struct (sizeof="+s.sizeof+")."):n("No member property descriptions found.");const o=E(r.__makeDebugFlags(e.debugFlags)),a=function e(r){this instanceof e?arguments.length?((r!==(0|r)||r<=0)&&n("Invalid pointer value for",t,"constructor."),S(e,this,r)):S(e,this):n("The",t,"constructor may only be called via 'new'.")};return Object.defineProperties(a,{debugFlags:o,isA:E((e=>e instanceof a)),memberKey:x,memberKeys:k,methodInfoForKey:E((function(e){})),structInfo:E(s),structName:E(t)}),a.prototype=new R(t,s,E),Object.defineProperties(a.prototype,{debugFlags:o,constructor:E(a)}),Object.keys(s.members).forEach((e=>M(a,e,s.members[e]))),a};return z.StructType=R,z.config=t,z.allocCString=N,z.debugFlags||(z.debugFlags=r.__makeDebugFlags(r.debugFlags)),z},globalThis.sqlite3ApiBootstrap.initializers.push((function(e){const t=(...e)=>{throw new Error(e.join(" "))},n=e.capi,r=e.wasm,s=e.util;if(globalThis.WhWasmUtilInstaller(r),delete globalThis.WhWasmUtilInstaller,r.bindingSignatures=[["sqlite3_aggregate_context","void*","sqlite3_context*","int"],["sqlite3_bind_double","int","sqlite3_stmt*","int","f64"],["sqlite3_bind_int","int","sqlite3_stmt*","int","int"],["sqlite3_bind_null",void 0,"sqlite3_stmt*","int"],["sqlite3_bind_parameter_count","int","sqlite3_stmt*"],["sqlite3_bind_parameter_index","int","sqlite3_stmt*","string"],["sqlite3_bind_pointer","int","sqlite3_stmt*","int","*","string:static","*"],["sqlite3_busy_handler","int",["sqlite3*",new r.xWrap.FuncPtrAdapter({signature:"i(pi)",contextKey:(e,t)=>e[0]}),"*"]],["sqlite3_busy_timeout","int","sqlite3*","int"],["sqlite3_changes","int","sqlite3*"],["sqlite3_clear_bindings","int","sqlite3_stmt*"],["sqlite3_collation_needed","int","sqlite3*","*","*"],["sqlite3_column_blob","*","sqlite3_stmt*","int"],["sqlite3_column_bytes","int","sqlite3_stmt*","int"],["sqlite3_column_count","int","sqlite3_stmt*"],["sqlite3_column_double","f64","sqlite3_stmt*","int"],["sqlite3_column_int","int","sqlite3_stmt*","int"],["sqlite3_column_name","string","sqlite3_stmt*","int"],["sqlite3_column_text","string","sqlite3_stmt*","int"],["sqlite3_column_type","int","sqlite3_stmt*","int"],["sqlite3_column_value","sqlite3_value*","sqlite3_stmt*","int"],["sqlite3_commit_hook","void*",["sqlite3*",new r.xWrap.FuncPtrAdapter({name:"sqlite3_commit_hook",signature:"i(p)",contextKey:e=>e[0]}),"*"]],["sqlite3_compileoption_get","string","int"],["sqlite3_compileoption_used","int","string"],["sqlite3_complete","int","string:flexible"],["sqlite3_context_db_handle","sqlite3*","sqlite3_context*"],["sqlite3_data_count","int","sqlite3_stmt*"],["sqlite3_db_filename","string","sqlite3*","string"],["sqlite3_db_handle","sqlite3*","sqlite3_stmt*"],["sqlite3_db_name","string","sqlite3*","int"],["sqlite3_db_status","int","sqlite3*","int","*","*","int"],["sqlite3_errcode","int","sqlite3*"],["sqlite3_errmsg","string","sqlite3*"],["sqlite3_error_offset","int","sqlite3*"],["sqlite3_errstr","string","int"],["sqlite3_exec","int",["sqlite3*","string:flexible",new r.xWrap.FuncPtrAdapter({signature:"i(pipp)",bindScope:"transient",callProxy:e=>{let t;return(s,i,o,a)=>{try{const n=r.cArgvToJs(i,o);return t||(t=r.cArgvToJs(i,a)),0|e(n,t)}catch(e){return e.resultCode||n.SQLITE_ERROR}}}}),"*","**"]],["sqlite3_expanded_sql","string","sqlite3_stmt*"],["sqlite3_extended_errcode","int","sqlite3*"],["sqlite3_extended_result_codes","int","sqlite3*","int"],["sqlite3_file_control","int","sqlite3*","string","int","*"],["sqlite3_finalize","int","sqlite3_stmt*"],["sqlite3_free",void 0,"*"],["sqlite3_get_autocommit","int","sqlite3*"],["sqlite3_get_auxdata","*","sqlite3_context*","int"],["sqlite3_initialize",void 0],["sqlite3_keyword_count","int"],["sqlite3_keyword_name","int",["int","**","*"]],["sqlite3_keyword_check","int",["string","int"]],["sqlite3_libversion","string"],["sqlite3_libversion_number","int"],["sqlite3_limit","int",["sqlite3*","int","int"]],["sqlite3_malloc","*","int"],["sqlite3_open","int","string","*"],["sqlite3_open_v2","int","string","*","int","string"],["sqlite3_progress_handler",void 0,["sqlite3*","int",new r.xWrap.FuncPtrAdapter({name:"xProgressHandler",signature:"i(p)",bindScope:"context",contextKey:(e,t)=>e[0]}),"*"]],["sqlite3_realloc","*","*","int"],["sqlite3_reset","int","sqlite3_stmt*"],["sqlite3_result_blob",void 0,"sqlite3_context*","*","int","*"],["sqlite3_result_double",void 0,"sqlite3_context*","f64"],["sqlite3_result_error",void 0,"sqlite3_context*","string","int"],["sqlite3_result_error_code",void 0,"sqlite3_context*","int"],["sqlite3_result_error_nomem",void 0,"sqlite3_context*"],["sqlite3_result_error_toobig",void 0,"sqlite3_context*"],["sqlite3_result_int",void 0,"sqlite3_context*","int"],["sqlite3_result_null",void 0,"sqlite3_context*"],["sqlite3_result_pointer",void 0,"sqlite3_context*","*","string:static","*"],["sqlite3_result_subtype",void 0,"sqlite3_value*","int"],["sqlite3_result_text",void 0,"sqlite3_context*","string","int","*"],["sqlite3_result_zeroblob",void 0,"sqlite3_context*","int"],["sqlite3_rollback_hook","void*",["sqlite3*",new r.xWrap.FuncPtrAdapter({name:"sqlite3_rollback_hook",signature:"v(p)",contextKey:e=>e[0]}),"*"]],["sqlite3_set_authorizer","int",["sqlite3*",new r.xWrap.FuncPtrAdapter({name:"sqlite3_set_authorizer::xAuth",signature:"i(pissss)",contextKey:(e,t)=>e[0],callProxy:e=>(t,s,i,o,a,l)=>{try{return i=i&&r.cstrToJs(i),o=o&&r.cstrToJs(o),a=a&&r.cstrToJs(a),l=l&&r.cstrToJs(l),e(t,s,i,o,a,l)||0}catch(e){return e.resultCode||n.SQLITE_ERROR}}}),"*"]],["sqlite3_set_auxdata",void 0,["sqlite3_context*","int","*",new r.xWrap.FuncPtrAdapter({name:"xDestroyAuxData",signature:"v(*)",contextKey:(e,t)=>e[0]})]],["sqlite3_shutdown",void 0],["sqlite3_sourceid","string"],["sqlite3_sql","string","sqlite3_stmt*"],["sqlite3_status","int","int","*","*","int"],["sqlite3_step","int","sqlite3_stmt*"],["sqlite3_stmt_isexplain","int",["sqlite3_stmt*"]],["sqlite3_stmt_readonly","int",["sqlite3_stmt*"]],["sqlite3_stmt_status","int","sqlite3_stmt*","int","int"],["sqlite3_strglob","int","string","string"],["sqlite3_stricmp","int","string","string"],["sqlite3_strlike","int","string","string","int"],["sqlite3_strnicmp","int","string","string","int"],["sqlite3_table_column_metadata","int","sqlite3*","string","string","string","**","**","*","*","*"],["sqlite3_total_changes","int","sqlite3*"],["sqlite3_trace_v2","int",["sqlite3*","int",new r.xWrap.FuncPtrAdapter({name:"sqlite3_trace_v2::callback",signature:"i(ippp)",contextKey:(e,t)=>e[0]}),"*"]],["sqlite3_txn_state","int",["sqlite3*","string"]],["sqlite3_uri_boolean","int","sqlite3_filename","string","int"],["sqlite3_uri_key","string","sqlite3_filename","int"],["sqlite3_uri_parameter","string","sqlite3_filename","string"],["sqlite3_user_data","void*","sqlite3_context*"],["sqlite3_value_blob","*","sqlite3_value*"],["sqlite3_value_bytes","int","sqlite3_value*"],["sqlite3_value_double","f64","sqlite3_value*"],["sqlite3_value_dup","sqlite3_value*","sqlite3_value*"],["sqlite3_value_free",void 0,"sqlite3_value*"],["sqlite3_value_frombind","int","sqlite3_value*"],["sqlite3_value_int","int","sqlite3_value*"],["sqlite3_value_nochange","int","sqlite3_value*"],["sqlite3_value_numeric_type","int","sqlite3_value*"],["sqlite3_value_pointer","*","sqlite3_value*","string:static"],["sqlite3_value_subtype","int","sqlite3_value*"],["sqlite3_value_text","string","sqlite3_value*"],["sqlite3_value_type","int","sqlite3_value*"],["sqlite3_vfs_find","*","string"],["sqlite3_vfs_register","int","sqlite3_vfs*","int"],["sqlite3_vfs_unregister","int","sqlite3_vfs*"]],r.bindingSignatures.int64=[["sqlite3_bind_int64","int",["sqlite3_stmt*","int","i64"]],["sqlite3_changes64","i64",["sqlite3*"]],["sqlite3_column_int64","i64",["sqlite3_stmt*","int"]],["sqlite3_create_module","int",["sqlite3*","string","sqlite3_module*","*"]],["sqlite3_create_module_v2","int",["sqlite3*","string","sqlite3_module*","*","*"]],["sqlite3_declare_vtab","int",["sqlite3*","string:flexible"]],["sqlite3_deserialize","int","sqlite3*","string","*","i64","i64","int"],["sqlite3_drop_modules","int",["sqlite3*","**"]],["sqlite3_last_insert_rowid","i64",["sqlite3*"]],["sqlite3_malloc64","*","i64"],["sqlite3_msize","i64","*"],["sqlite3_overload_function","int",["sqlite3*","string","int"]],["sqlite3_preupdate_blobwrite","int","sqlite3*"],["sqlite3_preupdate_count","int","sqlite3*"],["sqlite3_preupdate_depth","int","sqlite3*"],["sqlite3_preupdate_hook","*",["sqlite3*",new r.xWrap.FuncPtrAdapter({name:"sqlite3_preupdate_hook",signature:"v(ppippjj)",contextKey:e=>e[0],callProxy:e=>(t,n,s,i,o,a,l)=>{e(t,n,s,r.cstrToJs(i),r.cstrToJs(o),a,l)}}),"*"]],["sqlite3_preupdate_new","int",["sqlite3*","int","**"]],["sqlite3_preupdate_old","int",["sqlite3*","int","**"]],["sqlite3_realloc64","*","*","i64"],["sqlite3_result_int64",void 0,"*","i64"],["sqlite3_result_zeroblob64","int","*","i64"],["sqlite3_serialize","*","sqlite3*","string","*","int"],["sqlite3_set_last_insert_rowid",void 0,["sqlite3*","i64"]],["sqlite3_status64","int","int","*","*","int"],["sqlite3_total_changes64","i64",["sqlite3*"]],["sqlite3_update_hook","*",["sqlite3*",new r.xWrap.FuncPtrAdapter({name:"sqlite3_update_hook",signature:"v(iippj)",contextKey:e=>e[0],callProxy:e=>(t,n,s,i,o)=>{e(t,n,r.cstrToJs(s),r.cstrToJs(i),o)}}),"*"]],["sqlite3_uri_int64","i64",["sqlite3_filename","string","i64"]],["sqlite3_value_int64","i64","sqlite3_value*"],["sqlite3_vtab_collation","string","sqlite3_index_info*","int"],["sqlite3_vtab_distinct","int","sqlite3_index_info*"],["sqlite3_vtab_in","int","sqlite3_index_info*","int","int"],["sqlite3_vtab_in_first","int","sqlite3_value*","**"],["sqlite3_vtab_in_next","int","sqlite3_value*","**"],["sqlite3_vtab_nochange","int","sqlite3_context*"],["sqlite3_vtab_on_conflict","int","sqlite3*"],["sqlite3_vtab_rhs_value","int","sqlite3_index_info*","int","**"]],r.bigIntEnabled&&r.exports.sqlite3changegroup_add){const e={signature:"i(ps)",callProxy:e=>(t,s)=>{try{return 0|e(t,r.cstrToJs(s))}catch(e){return e.resultCode||n.SQLITE_ERROR}}};r.bindingSignatures.int64.push(["sqlite3changegroup_add","int",["sqlite3_changegroup*","int","void*"]],["sqlite3changegroup_add_strm","int",["sqlite3_changegroup*",new r.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3changegroup_delete",void 0,["sqlite3_changegroup*"]],["sqlite3changegroup_new","int",["**"]],["sqlite3changegroup_output","int",["sqlite3_changegroup*","int*","**"]],["sqlite3changegroup_output_strm","int",["sqlite3_changegroup*",new r.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply","int",["sqlite3*","int","void*",new r.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...e}),new r.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_strm","int",["sqlite3*",new r.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new r.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...e}),new r.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_v2","int",["sqlite3*","int","void*",new r.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...e}),new r.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v2_strm","int",["sqlite3*",new r.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new r.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...e}),new r.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_concat","int",["int","void*","int","void*","int*","**"]],["sqlite3changeset_concat_strm","int",[new r.xWrap.FuncPtrAdapter({name:"xInputA",signature:"i(ppp)",bindScope:"transient"}),"void*",new r.xWrap.FuncPtrAdapter({name:"xInputB",signature:"i(ppp)",bindScope:"transient"}),"void*",new r.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_conflict","int",["sqlite3_changeset_iter*","int","**"]],["sqlite3changeset_finalize","int",["sqlite3_changeset_iter*"]],["sqlite3changeset_fk_conflicts","int",["sqlite3_changeset_iter*","int*"]],["sqlite3changeset_invert","int",["int","void*","int*","**"]],["sqlite3changeset_invert_strm","int",[new r.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new r.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_new","int",["sqlite3_changeset_iter*","int","**"]],["sqlite3changeset_next","int",["sqlite3_changeset_iter*"]],["sqlite3changeset_old","int",["sqlite3_changeset_iter*","int","**"]],["sqlite3changeset_op","int",["sqlite3_changeset_iter*","**","int*","int*","int*"]],["sqlite3changeset_pk","int",["sqlite3_changeset_iter*","**","int*"]],["sqlite3changeset_start","int",["**","int","*"]],["sqlite3changeset_start_strm","int",["**",new r.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3changeset_start_v2","int",["**","int","*","int"]],["sqlite3changeset_start_v2_strm","int",["**",new r.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*","int"]],["sqlite3session_attach","int",["sqlite3_session*","string"]],["sqlite3session_changeset","int",["sqlite3_session*","int*","**"]],["sqlite3session_changeset_size","i64",["sqlite3_session*"]],["sqlite3session_changeset_strm","int",["sqlite3_session*",new r.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3session_config","int",["int","void*"]],["sqlite3session_create","int",["sqlite3*","string","**"]],["sqlite3session_diff","int",["sqlite3_session*","string","string","**"]],["sqlite3session_enable","int",["sqlite3_session*","int"]],["sqlite3session_indirect","int",["sqlite3_session*","int"]],["sqlite3session_isempty","int",["sqlite3_session*"]],["sqlite3session_memory_used","i64",["sqlite3_session*"]],["sqlite3session_object_config","int",["sqlite3_session*","int","void*"]],["sqlite3session_patchset","int",["sqlite3_session*","*","**"]],["sqlite3session_patchset_strm","int",["sqlite3_session*",new r.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3session_table_filter",void 0,["sqlite3_session*",new r.xWrap.FuncPtrAdapter({name:"xFilter",...e,contextKey:(e,t)=>e[0]}),"*"]])}r.bindingSignatures.wasmInternal=[["sqlite3__wasm_db_reset","int","sqlite3*"],["sqlite3__wasm_db_vfs","sqlite3_vfs*","sqlite3*","string"],["sqlite3__wasm_vfs_create_file","int","sqlite3_vfs*","string","*","int"],["sqlite3__wasm_posix_create_file","int","string","*","int"],["sqlite3__wasm_vfs_unlink","int","sqlite3_vfs*","string"],["sqlite3__wasm_qfmt_token","string:dealloc","string","int"]],e.StructBinder=globalThis.Jaccwabyt({heap:r.heap8u,alloc:r.alloc,dealloc:r.dealloc,bigIntEnabled:r.bigIntEnabled,memberPrefix:"$"}),delete globalThis.Jaccwabyt;{const i=r.xWrap.argAdapter("string");r.xWrap.argAdapter("string:flexible",(e=>i(s.flexibleString(e)))),r.xWrap.argAdapter("string:static",function(e){return r.isPtr(e)?e:this[e=""+e]||(this[e]=r.allocCString(e))}.bind(Object.create(null)));const o=r.xWrap.argAdapter("*"),a=function(){};r.xWrap.argAdapter("sqlite3_filename",o)("sqlite3_context*",o)("sqlite3_value*",o)("void*",o)("sqlite3_changegroup*",o)("sqlite3_changeset_iter*",o)("sqlite3_session*",o)("sqlite3_stmt*",(t=>o(t instanceof(e?.oo1?.Stmt||a)?t.pointer:t)))("sqlite3*",(t=>o(t instanceof(e?.oo1?.DB||a)?t.pointer:t)))("sqlite3_index_info*",(e=>o(e instanceof(n.sqlite3_index_info||a)?e.pointer:e)))("sqlite3_module*",(e=>o(e instanceof(n.sqlite3_module||a)?e.pointer:e)))("sqlite3_vfs*",(t=>"string"==typeof t?n.sqlite3_vfs_find(t)||e.SQLite3Error.toss(n.SQLITE_NOTFOUND,"Unknown sqlite3_vfs name:",t):o(t instanceof(n.sqlite3_vfs||a)?t.pointer:t)));const l=r.xWrap.resultAdapter("*");r.xWrap.resultAdapter("sqlite3*",l)("sqlite3_context*",l)("sqlite3_stmt*",l)("sqlite3_value*",l)("sqlite3_vfs*",l)("void*",l),0===r.exports.sqlite3_step.length&&(r.xWrap.doArgcCheck=!1,e.config.warn("Disabling sqlite3.wasm.xWrap.doArgcCheck due to environmental quirks."));for(const e of r.bindingSignatures)n[e[0]]=r.xWrap.apply(null,e);for(const e of r.bindingSignatures.wasmInternal)s[e[0]]=r.xWrap.apply(null,e);const c=function(e){return()=>t(e+"() is unavailable due to lack","of BigInt support in this build.")};for(const e of r.bindingSignatures.int64)n[e[0]]=r.bigIntEnabled?r.xWrap.apply(null,e):c(e[0]);if(delete r.bindingSignatures,r.exports.sqlite3__wasm_db_error){const t=r.xWrap("sqlite3__wasm_db_error","int","sqlite3*","int","string");s.sqlite3__wasm_db_error=function(r,s,i){return s instanceof e.WasmAllocError?(s=n.SQLITE_NOMEM,i=0):s instanceof Error&&(i=i||""+s,s=s.resultCode||n.SQLITE_ERROR),r?t(r,s,i):s}}else s.sqlite3__wasm_db_error=function(e,t,n){return console.warn("sqlite3__wasm_db_error() is not exported.",arguments),t}}{const i=r.xCall("sqlite3__wasm_enum_json");i||t("Maintenance required: increase sqlite3__wasm_enum_json()'s","static buffer size!"),r.ctype=JSON.parse(r.cstrToJs(i));const o=["access","authorizer","blobFinalizers","changeset","config","dataTypes","dbConfig","dbStatus","encodings","fcntl","flock","ioCap","limits","openFlags","prepareFlags","resultCodes","sqlite3Status","stmtStatus","syncFlags","trace","txnState","udfFlags","version"];r.bigIntEnabled&&o.push("serialize","session","vtab");for(const e of o)for(const t of Object.entries(r.ctype[e]))n[t[0]]=t[1];r.functionEntry(n.SQLITE_WASM_DEALLOC)||t("Internal error: cannot resolve exported function","entry SQLITE_WASM_DEALLOC (=="+n.SQLITE_WASM_DEALLOC+").");const a=Object.create(null);for(const e of["resultCodes"])for(const t of Object.entries(r.ctype[e]))a[t[1]]=t[0];n.sqlite3_js_rc_str=e=>a[e];const l=Object.assign(Object.create(null),{WasmTestStruct:!0,sqlite3_kvvfs_methods:!s.isUIThread(),sqlite3_index_info:!r.bigIntEnabled,sqlite3_index_constraint:!r.bigIntEnabled,sqlite3_index_orderby:!r.bigIntEnabled,sqlite3_index_constraint_usage:!r.bigIntEnabled});for(const t of r.ctype.structs)l[t.name]||(n[t.name]=e.StructBinder(t));if(n.sqlite3_index_info){for(const e of["sqlite3_index_constraint","sqlite3_index_orderby","sqlite3_index_constraint_usage"])n.sqlite3_index_info[e]=n[e],delete n[e];n.sqlite3_vtab_config=r.xWrap("sqlite3__wasm_vtab_config","int",["sqlite3*","int","int"])}}const i=(e,t,r)=>s.sqlite3__wasm_db_error(e,n.SQLITE_MISUSE,t+"() requires "+r+" argument"+(1===r?"":"s")+"."),o=e=>s.sqlite3__wasm_db_error(e,n.SQLITE_FORMAT,"SQLITE_UTF8 is the only supported encoding."),a=e=>r.xWrap.argAdapter("sqlite3*")(e),l=e=>r.isPtr(e)?r.cstrToJs(e):e,c=function(e,t){e=a(e);let n=this.dbMap.get(e);return t?(!n&&t>0&&this.dbMap.set(e,n=Object.create(null)),n):(this.dbMap.delete(e),n)}.bind(Object.assign(Object.create(null),{dbMap:new Map}));c.addCollation=function(e,t){const n=c(e,1);n.collation||(n.collation=new Set),n.collation.add(l(t).toLowerCase())},c._addUDF=function(e,t,n,r){t=l(t).toLowerCase();let s=r.get(t);s||r.set(t,s=new Set),s.add(n<0?-1:n)},c.addFunction=function(e,t,n){const r=c(e,1);r.udf||(r.udf=new Map),this._addUDF(e,t,n,r.udf)},c.addWindowFunc=function(e,t,n){const r=c(e,1);r.wudf||(r.wudf=new Map),this._addUDF(e,t,n,r.wudf)},c.cleanup=function(e){const t=[e=a(e)];for(const e of["sqlite3_busy_handler","sqlite3_commit_hook","sqlite3_preupdate_hook","sqlite3_progress_handler","sqlite3_rollback_hook","sqlite3_set_authorizer","sqlite3_trace_v2","sqlite3_update_hook"]){const s=r.exports[e];t.length=s.length;try{n[e](...t)}catch(n){console.warn("close-time call of",e+"(",t,") threw:",n)}}const s=c(e,0);if(!s)return;if(s.collation){for(const t of s.collation)try{n.sqlite3_create_collation_v2(e,t,n.SQLITE_UTF8,0,0,0)}catch(e){}delete s.collation}let i;for(i=0;i<2;++i){const t=i?s.wudf:s.udf;if(!t)continue;const r=i?n.sqlite3_create_window_function:n.sqlite3_create_function_v2;for(const s of t){const t=s[0],o=s[1],a=[e,t,0,n.SQLITE_UTF8,0,0,0,0,0];i&&a.push(0);for(const e of o)try{a[2]=e,r.apply(null,a)}catch(e){}o.clear()}t.clear()}delete s.udf,delete s.wudf};{const e=r.xWrap("sqlite3_close_v2","int","sqlite3*");n.sqlite3_close_v2=function(t){if(1!==arguments.length)return i(t,"sqlite3_close_v2",1);if(t)try{c.cleanup(t)}catch(e){}return e(t)}}if(n.sqlite3session_table_filter){const e=r.xWrap("sqlite3session_delete",void 0,["sqlite3_session*"]);n.sqlite3session_delete=function(t){if(1!==arguments.length)return i(pDb,"sqlite3session_delete",1);t&&n.sqlite3session_table_filter(t,0,0),e(t)}}{const e=(e,t)=>"argv["+t+"]:"+e[0]+":"+r.cstrToJs(e[1]).toLowerCase(),t=r.xWrap("sqlite3_create_collation_v2","int",["sqlite3*","string","int","*",new r.xWrap.FuncPtrAdapter({name:"xCompare",signature:"i(pipip)",contextKey:e}),new r.xWrap.FuncPtrAdapter({name:"xDestroy",signature:"v(p)",contextKey:e})]);n.sqlite3_create_collation_v2=function(e,r,a,l,u,_){if(6!==arguments.length)return i(e,"sqlite3_create_collation_v2",6);if(15&a){if(n.SQLITE_UTF8!==(15&a))return o(e)}else a|=n.SQLITE_UTF8;try{const n=t(e,r,a,l,u,_);return 0===n&&u instanceof Function&&c.addCollation(e,r),n}catch(t){return s.sqlite3__wasm_db_error(e,t)}},n.sqlite3_create_collation=(e,t,r,s,o)=>5===arguments.length?n.sqlite3_create_collation_v2(e,t,r,s,o,0):i(e,"sqlite3_create_collation",5)}{const e=function(e,t){return e[0]+":"+(e[2]<0?-1:e[2])+":"+t+":"+r.cstrToJs(e[1]).toLowerCase()},t=Object.assign(Object.create(null),{xInverseAndStep:{signature:"v(pip)",contextKey:e,callProxy:e=>(t,r,s)=>{try{e(t,...n.sqlite3_values_to_js(r,s))}catch(e){n.sqlite3_result_error_js(t,e)}}},xFinalAndValue:{signature:"v(p)",contextKey:e,callProxy:e=>t=>{try{n.sqlite3_result_js(t,e(t))}catch(e){n.sqlite3_result_error_js(t,e)}}},xFunc:{signature:"v(pip)",contextKey:e,callProxy:e=>(t,r,s)=>{try{n.sqlite3_result_js(t,e(t,...n.sqlite3_values_to_js(r,s)))}catch(e){n.sqlite3_result_error_js(t,e)}}},xDestroy:{signature:"v(p)",contextKey:e,callProxy:e=>t=>{try{e(t)}catch(e){console.error("UDF xDestroy method threw:",e)}}}}),a=r.xWrap("sqlite3_create_function_v2","int",["sqlite3*","string","int","int","*",new r.xWrap.FuncPtrAdapter({name:"xFunc",...t.xFunc}),new r.xWrap.FuncPtrAdapter({name:"xStep",...t.xInverseAndStep}),new r.xWrap.FuncPtrAdapter({name:"xFinal",...t.xFinalAndValue}),new r.xWrap.FuncPtrAdapter({name:"xDestroy",...t.xDestroy})]),l=r.xWrap("sqlite3_create_window_function","int",["sqlite3*","string","int","int","*",new r.xWrap.FuncPtrAdapter({name:"xStep",...t.xInverseAndStep}),new r.xWrap.FuncPtrAdapter({name:"xFinal",...t.xFinalAndValue}),new r.xWrap.FuncPtrAdapter({name:"xValue",...t.xFinalAndValue}),new r.xWrap.FuncPtrAdapter({name:"xInverse",...t.xInverseAndStep}),new r.xWrap.FuncPtrAdapter({name:"xDestroy",...t.xDestroy})]);n.sqlite3_create_function_v2=function e(t,r,l,u,_,p,f,d,m){if(e.length!==arguments.length)return i(t,"sqlite3_create_function_v2",e.length);if(15&u){if(n.SQLITE_UTF8!==(15&u))return o(t)}else u|=n.SQLITE_UTF8;try{const e=a(t,r,l,u,_,p,f,d,m);return 0===e&&(p instanceof Function||f instanceof Function||d instanceof Function||m instanceof Function)&&c.addFunction(t,r,l),e}catch(e){return console.error("sqlite3_create_function_v2() setup threw:",e),s.sqlite3__wasm_db_error(t,e,"Creation of UDF threw: "+e)}},n.sqlite3_create_function=function e(t,r,s,o,a,l,c,u){return e.length===arguments.length?n.sqlite3_create_function_v2(t,r,s,o,a,l,c,u,0):i(t,"sqlite3_create_function",e.length)},n.sqlite3_create_window_function=function e(t,r,a,u,_,p,f,d,m,h){if(e.length!==arguments.length)return i(t,"sqlite3_create_window_function",e.length);if(15&u){if(n.SQLITE_UTF8!==(15&u))return o(t)}else u|=n.SQLITE_UTF8;try{const e=l(t,r,a,u,_,p,f,d,m,h);return 0===e&&(p instanceof Function||f instanceof Function||d instanceof Function||m instanceof Function||h instanceof Function)&&c.addWindowFunc(t,r,a),e}catch(e){return console.error("sqlite3_create_window_function() setup threw:",e),s.sqlite3__wasm_db_error(t,e,"Creation of UDF threw: "+e)}},n.sqlite3_create_function_v2.udfSetResult=n.sqlite3_create_function.udfSetResult=n.sqlite3_create_window_function.udfSetResult=n.sqlite3_result_js,n.sqlite3_create_function_v2.udfConvertArgs=n.sqlite3_create_function.udfConvertArgs=n.sqlite3_create_window_function.udfConvertArgs=n.sqlite3_values_to_js,n.sqlite3_create_function_v2.udfSetError=n.sqlite3_create_function.udfSetError=n.sqlite3_create_window_function.udfSetError=n.sqlite3_result_error_js}{const e=(e,t)=>("string"==typeof e?t=-1:s.isSQLableTypedArray(e)?(t=e.byteLength,e=s.typedArrayToString(e instanceof ArrayBuffer?new Uint8Array(e):e)):Array.isArray(e)&&(e=e.join(""),t=-1),[e,t]),t={basic:r.xWrap("sqlite3_prepare_v3","int",["sqlite3*","string","int","int","**","**"]),full:r.xWrap("sqlite3_prepare_v3","int",["sqlite3*","*","int","int","**","**"])};n.sqlite3_prepare_v3=function r(o,a,l,c,u,_){if(r.length!==arguments.length)return i(o,"sqlite3_prepare_v3",r.length);const[p,f]=e(a,l);switch(typeof p){case"string":return t.basic(o,p,f,c,u,null);case"number":return t.full(o,p,f,c,u,_);default:return s.sqlite3__wasm_db_error(o,n.SQLITE_MISUSE,"Invalid SQL argument type for sqlite3_prepare_v2/v3().")}},n.sqlite3_prepare_v2=function e(t,r,s,o,a){return e.length===arguments.length?n.sqlite3_prepare_v3(t,r,s,0,o,a):i(t,"sqlite3_prepare_v2",e.length)}}{const e=r.xWrap("sqlite3_bind_text","int",["sqlite3_stmt*","int","string","int","*"]),t=r.xWrap("sqlite3_bind_blob","int",["sqlite3_stmt*","int","*","int","*"]);n.sqlite3_bind_text=function t(o,a,l,c,u){if(t.length!==arguments.length)return i(n.sqlite3_db_handle(o),"sqlite3_bind_text",t.length);if(r.isPtr(l)||null===l)return e(o,a,l,c,u);let _,p;l instanceof ArrayBuffer?l=new Uint8Array(l):Array.isArray(pMem)&&(l=pMem.join(""));try{if(s.isSQLableTypedArray(l))_=r.allocFromTypedArray(l),p=l.byteLength;else{if("string"!=typeof l)return s.sqlite3__wasm_db_error(n.sqlite3_db_handle(o),n.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_text().");[_,p]=r.allocCString(l)}return e(o,a,_,p,n.SQLITE_WASM_DEALLOC)}catch(e){return r.dealloc(_),s.sqlite3__wasm_db_error(n.sqlite3_db_handle(o),e)}},n.sqlite3_bind_blob=function e(o,a,l,c,u){if(e.length!==arguments.length)return i(n.sqlite3_db_handle(o),"sqlite3_bind_blob",e.length);if(r.isPtr(l)||null===l)return t(o,a,l,c,u);let _,p;l instanceof ArrayBuffer?l=new Uint8Array(l):Array.isArray(l)&&(l=l.join(""));try{if(s.isBindableTypedArray(l))_=r.allocFromTypedArray(l),p=c>=0?c:l.byteLength;else{if("string"!=typeof l)return s.sqlite3__wasm_db_error(n.sqlite3_db_handle(o),n.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_blob().");[_,p]=r.allocCString(l)}return t(o,a,_,p,n.SQLITE_WASM_DEALLOC)}catch(e){return r.dealloc(_),s.sqlite3__wasm_db_error(n.sqlite3_db_handle(o),e)}}}n.sqlite3_config=function(e,...t){if(arguments.length<2)return n.SQLITE_MISUSE;switch(e){case n.SQLITE_CONFIG_COVERING_INDEX_SCAN:case n.SQLITE_CONFIG_MEMSTATUS:case n.SQLITE_CONFIG_SMALL_MALLOC:case n.SQLITE_CONFIG_SORTERREF_SIZE:case n.SQLITE_CONFIG_STMTJRNL_SPILL:case n.SQLITE_CONFIG_URI:return r.exports.sqlite3__wasm_config_i(e,t[0]);case n.SQLITE_CONFIG_LOOKASIDE:return r.exports.sqlite3__wasm_config_ii(e,t[0],t[1]);case n.SQLITE_CONFIG_MEMDB_MAXSIZE:return r.exports.sqlite3__wasm_config_j(e,t[0]);case n.SQLITE_CONFIG_GETMALLOC:case n.SQLITE_CONFIG_GETMUTEX:case n.SQLITE_CONFIG_GETPCACHE2:case n.SQLITE_CONFIG_GETPCACHE:case n.SQLITE_CONFIG_HEAP:case n.SQLITE_CONFIG_LOG:case n.SQLITE_CONFIG_MALLOC:case n.SQLITE_CONFIG_MMAP_SIZE:case n.SQLITE_CONFIG_MULTITHREAD:case n.SQLITE_CONFIG_MUTEX:case n.SQLITE_CONFIG_PAGECACHE:case n.SQLITE_CONFIG_PCACHE2:case n.SQLITE_CONFIG_PCACHE:case n.SQLITE_CONFIG_PCACHE_HDRSZ:case n.SQLITE_CONFIG_PMASZ:case n.SQLITE_CONFIG_SERIALIZED:case n.SQLITE_CONFIG_SINGLETHREAD:case n.SQLITE_CONFIG_SQLLOG:case n.SQLITE_CONFIG_WIN32_HEAPSIZE:default:return n.SQLITE_NOTFOUND}};{const e=new Set;n.sqlite3_auto_extension=function(t){if(t instanceof Function)t=r.installFunction("i(ppp)",t);else if(1!==arguments.length||!r.isPtr(t))return n.SQLITE_MISUSE;const s=r.exports.sqlite3_auto_extension(t);return t!==arguments[0]&&(0===s?e.add(t):r.uninstallFunction(t)),s},n.sqlite3_cancel_auto_extension=function(e){return e&&1===arguments.length&&r.isPtr(e)?r.exports.sqlite3_cancel_auto_extension(e):0},n.sqlite3_reset_auto_extension=function(){r.exports.sqlite3_reset_auto_extension();for(const t of e)r.uninstallFunction(t);e.clear()}}const u=n.sqlite3_vfs_find("kvvfs");if(u)if(s.isUIThread()){const e=new n.sqlite3_kvvfs_methods(r.exports.sqlite3__wasm_kvvfs_methods());delete n.sqlite3_kvvfs_methods;const t=r.exports.sqlite3__wasm_kvvfsMakeKeyOnPstack,s=r.pstack,i=e=>115===r.peek(e)?sessionStorage:localStorage,o={xRead:(e,n,o,a)=>{const l=s.pointer,c=r.scopedAllocPush();try{const s=t(e,n);if(!s)return-3;const l=r.cstrToJs(s),c=i(e).getItem(l);if(!c)return-1;const u=c.length;if(a<=0)return u;if(1===a)return r.poke(o,0),u;const _=r.scopedAllocCString(c);return a>u+1&&(a=u+1),r.heap8u().copyWithin(o,_,_+a-1),r.poke(o+a-1,0),a-1}catch(e){return console.error("kvstorageRead()",e),-2}finally{s.restore(l),r.scopedAllocPop(c)}},xWrite:(e,o,a)=>{const l=s.pointer;try{const n=t(e,o);if(!n)return 1;const s=r.cstrToJs(n);return i(e).setItem(s,r.cstrToJs(a)),0}catch(e){return console.error("kvstorageWrite()",e),n.SQLITE_IOERR}finally{s.restore(l)}},xDelete:(e,o)=>{const a=s.pointer;try{const n=t(e,o);return n?(i(e).removeItem(r.cstrToJs(n)),0):1}catch(e){return console.error("kvstorageDelete()",e),n.SQLITE_IOERR}finally{s.restore(a)}}};for(const t of Object.keys(o))e[e.memberKey(t)]=r.installFunction(e.memberSignature(t),o[t])}else n.sqlite3_vfs_unregister(u);r.xWrap.FuncPtrAdapter.warnOnUse=!0;const _=e.StructBinder,p=function e(n,s,i,o=e.installMethodArgcCheck){if(n instanceof _.StructType?i instanceof Function||r.isPtr(i)||t("Usage errror: expecting a Function or WASM pointer to one."):t("Usage error: target object is-not-a StructType."),1===arguments.length)return(t,r)=>e(n,t,r,o);e.argcProxy||(e.argcProxy=function(e,n,r,s){return function(...i){return r.length!==arguments.length&&t("Argument mismatch for",e.structInfo.name+"::"+n+": Native signature is:",s),r.apply(this,i)}},e.removeFuncList=function(){this.ondispose.__removeFuncList&&(this.ondispose.__removeFuncList.forEach(((e,t)=>{if("number"==typeof e)try{r.uninstallFunction(e)}catch(e){}})),delete this.ondispose.__removeFuncList)});const a=n.memberSignature(s);a.length<2&&t("Member",s,"does not have a function pointer signature:",a);const l=n.memberKey(s),c=o&&!r.isPtr(i)?e.argcProxy(n,l,i,a):i;if(r.isPtr(c))c&&!r.functionEntry(c)&&t("Pointer",c,"is not a WASM function table entry."),n[l]=c;else{const t=r.installFunction(c,n.memberSignature(s,!0));n[l]=t,n.ondispose&&n.ondispose.__removeFuncList||(n.addOnDispose("ondispose.__removeFuncList handler",e.removeFuncList),n.ondispose.__removeFuncList=[]),n.ondispose.__removeFuncList.push(l,t)}return(t,r)=>e(n,t,r,o)};p.installMethodArgcCheck=!1;const f=function(e,t,n=p.installMethodArgcCheck){const r=new Map;for(const s of Object.keys(t)){const i=t[s],o=r.get(i);if(o){const t=e.memberKey(s);e[t]=e[e.memberKey(o)]}else p(e,s,i,n),r.set(i,s)}return e};_.StructType.prototype.installMethod=function(e,t,n=p.installMethodArgcCheck){return arguments.length<3&&e&&"object"==typeof e?f(this,...arguments):p(this,...arguments)},_.StructType.prototype.installMethods=function(e,t=p.installMethodArgcCheck){return f(this,e,t)}})),globalThis.sqlite3ApiBootstrap.initializers.push((function(e){e.version={libVersion:"3.46.1",libVersionNumber:3046001,sourceId:"2024-08-13 09:16:08 c9c2ab54ba1f5f46360f1b4f35d849cd3f080e6fc2b6c60e91b16c63f69a1e33",downloadVersion:3460100}})),globalThis.sqlite3ApiBootstrap.initializers.push((function(e){const t=(...t)=>{throw new e.SQLite3Error(...t)},n=e.capi,r=e.wasm,s=e.util,i=new WeakMap,o=new WeakMap,a=(e,t,n)=>{const r=Object.getOwnPropertyDescriptor(e,t);return r?r.value:n},l=function(e,r){return r&&(e instanceof p&&(e=e.pointer),t(r,"sqlite3 result code",r+":",e?n.sqlite3_errmsg(e):n.sqlite3_errstr(r))),arguments[0]},c=r.installFunction("i(ippp)",function(e,t,s,i){n.SQLITE_TRACE_STMT===e&&console.log("SQL TRACE #"+ ++this.counter+" via sqlite3@"+t+":",r.cstrToJs(i))}.bind({counter:0})),u=Object.create(null),_=function s(...a){if(!s._name2vfs){s._name2vfs=Object.create(null);const e="function"==typeof importScripts&&(e=>t("The VFS for",e,"is only available in the main window thread."));s._name2vfs[":localStorage:"]={vfs:"kvvfs",filename:e||(()=>"local")},s._name2vfs[":sessionStorage:"]={vfs:"kvvfs",filename:e||(()=>"session")}}const _=s.normalizeArgs(...a);let p=_.filename,f=_.vfs,d=_.flags;("string"!=typeof p&&"number"!=typeof p||"string"!=typeof d||f&&"string"!=typeof f&&"number"!=typeof f)&&(e.config.error("Invalid DB ctor args",_,arguments),t("Invalid arguments for DB constructor."));let m="number"==typeof p?r.cstrToJs(p):p;const h=s._name2vfs[m];h&&(f=h.vfs,p=m=h.filename(m));let g,q=0;d.indexOf("c")>=0&&(q|=n.SQLITE_OPEN_CREATE|n.SQLITE_OPEN_READWRITE),d.indexOf("w")>=0&&(q|=n.SQLITE_OPEN_READWRITE),0===q&&(q|=n.SQLITE_OPEN_READONLY),q|=n.SQLITE_OPEN_EXRESCODE;const y=r.pstack.pointer;try{const e=r.pstack.allocPtr();let t=n.sqlite3_open_v2(p,e,q,f||0);g=r.peekPtr(e),l(g,t),n.sqlite3_extended_result_codes(g,1),d.indexOf("t")>=0&&n.sqlite3_trace_v2(g,n.SQLITE_TRACE_STMT,c,g)}catch(e){throw g&&n.sqlite3_close_v2(g),e}finally{r.pstack.restore(y)}this.filename=m,i.set(this,g),o.set(this,Object.create(null));try{const r=n.sqlite3_js_db_vfs(g)||t("Internal error: cannot get VFS for new db handle."),s=u[r];s&&(s instanceof Function?s(this,e):l(g,n.sqlite3_exec(g,s,0,0,0)))}catch(e){throw this.close(),e}};_.setVfsPostOpenSql=function(e,t){u[e]=t},_.normalizeArgs=function(e=":memory:",t="c",n=null){const r={};return 1===arguments.length&&arguments[0]&&"object"==typeof arguments[0]?(Object.assign(r,arguments[0]),void 0===r.flags&&(r.flags="c"),void 0===r.vfs&&(r.vfs=null),void 0===r.filename&&(r.filename=":memory:")):(r.filename=e,r.flags=t,r.vfs=n),r};const p=function(...e){_.apply(this,e)};p.dbCtorHelper=_;const f={null:1,number:2,string:3,boolean:4,blob:5};r.bigIntEnabled&&(f.bigint=f.number);const d=function(){f!==arguments[2]&&t(n.SQLITE_MISUSE,"Do not call the Stmt constructor directly. Use DB.prepare()."),this.db=arguments[0],i.set(this,arguments[1]),this.parameterCount=n.sqlite3_bind_parameter_count(this.pointer)},m=function(e){return e.pointer||t("DB has been closed."),e},h=function(e,n){return(n!==(0|n)||n<0||n>=e.columnCount)&&t("Column index",n,"is out of range."),e},g=(e,t,n,...r)=>{const s=e.prepare(t);try{const e=s.bind(n).step()?s.get(...r):void 0;return s.reset(),e}finally{s.finalize()}},q=(e,t,n,r)=>e.exec({sql:t,bind:n,rowMode:r,returnValue:"resultRows"});p.checkRc=(e,t)=>l(e,t),p.prototype={isOpen:function(){return!!this.pointer},affirmOpen:function(){return m(this)},close:function(){if(this.pointer){if(this.onclose&&this.onclose.before instanceof Function)try{this.onclose.before(this)}catch(e){}const e=this.pointer;if(Object.keys(o.get(this)).forEach(((e,t)=>{if(t&&t.pointer)try{t.finalize()}catch(e){}})),i.delete(this),o.delete(this),n.sqlite3_close_v2(e),this.onclose&&this.onclose.after instanceof Function)try{this.onclose.after(this)}catch(e){}delete this.filename}},changes:function(e=!1,t=!1){const r=m(this).pointer;return e?t?n.sqlite3_total_changes64(r):n.sqlite3_total_changes(r):t?n.sqlite3_changes64(r):n.sqlite3_changes(r)},dbFilename:function(e="main"){return n.sqlite3_db_filename(m(this).pointer,e)},dbName:function(e=0){return n.sqlite3_db_name(m(this).pointer,e)},dbVfsName:function(e=0){let t;const s=n.sqlite3_js_db_vfs(m(this).pointer,e);if(s){const e=new n.sqlite3_vfs(s);try{t=r.cstrToJs(e.$zName)}finally{e.dispose()}}return t},prepare:function(e){m(this);const s=r.pstack.pointer;let i,a;try{i=r.pstack.alloc(8),p.checkRc(this,n.sqlite3_prepare_v2(this.pointer,e,-1,i,null)),a=r.peekPtr(i)}finally{r.pstack.restore(s)}a||t("Cannot prepare empty SQL.");const l=new d(this,a,f);return o.get(this)[a]=l,l},exec:function(){m(this);const e=function(e,r){const i=Object.create(null);switch(i.opt=Object.create(null),r.length){case 1:"string"==typeof r[0]||s.isSQLableTypedArray(r[0])||Array.isArray(r[0])?i.sql=r[0]:r[0]&&"object"==typeof r[0]&&(i.opt=r[0],i.sql=i.opt.sql);break;case 2:i.sql=r[0],i.opt=r[1];break;default:t("Invalid argument count for exec().")}i.sql=s.flexibleString(i.sql),"string"!=typeof i.sql&&t("Missing SQL argument or unsupported SQL value type.");const o=i.opt;switch(o.returnValue){case"resultRows":o.resultRows||(o.resultRows=[]),i.returnVal=()=>o.resultRows;break;case"saveSql":o.saveSql||(o.saveSql=[]),i.returnVal=()=>o.saveSql;break;case void 0:case"this":i.returnVal=()=>e;break;default:t("Invalid returnValue value:",o.returnValue)}if(o.callback||o.returnValue||void 0===o.rowMode||(o.resultRows||(o.resultRows=[]),i.returnVal=()=>o.resultRows),o.callback||o.resultRows)switch(void 0===o.rowMode?"array":o.rowMode){case"object":i.cbArg=(e,t)=>{t.columnNames||(t.columnNames=e.getColumnNames([]));const n=e.get([]),r=Object.create(null);for(const e in t.columnNames)r[t.columnNames[e]]=n[e];return r};break;case"array":i.cbArg=e=>e.get([]);break;case"stmt":Array.isArray(o.resultRows)&&t("exec(): invalid rowMode for a resultRows array: must","be one of 'array', 'object',","a result column number, or column name reference."),i.cbArg=e=>e;break;default:if(s.isInt32(o.rowMode)){i.cbArg=e=>e.get(o.rowMode);break}if("string"==typeof o.rowMode&&o.rowMode.length>1&&"$"===o.rowMode[0]){const e=o.rowMode.substr(1);i.cbArg=r=>{const s=r.get(Object.create(null))[e];return void 0===s?t(n.SQLITE_NOTFOUND,"exec(): unknown result column:",e):s};break}t("Invalid rowMode:",o.rowMode)}return i}(this,arguments);if(!e.sql)return t("exec() requires an SQL string.");const i=e.opt,o=i.callback,a=Array.isArray(i.resultRows)?i.resultRows:void 0;let l,c=i.bind,u=!!(e.cbArg||i.columnNames||a);const _=r.scopedAllocPush(),h=Array.isArray(i.saveSql)?i.saveSql:void 0;try{const t=s.isSQLableTypedArray(e.sql);let _=t?e.sql.byteLength:r.jstrlen(e.sql);const m=r.scopedAlloc(2*r.ptrSizeof+(_+1)),g=m+r.ptrSizeof;let q=g+r.ptrSizeof;const y=q+_;for(t?r.heap8().set(e.sql,q):r.jstrcpy(e.sql,r.heap8(),q,_,!1),r.poke(q+_,0);q&&r.peek(q,"i8");){r.pokePtr([m,g],0),p.checkRc(this,n.sqlite3_prepare_v3(this.pointer,q,_,0,m,g));const t=r.peekPtr(m);if(q=r.peekPtr(g),_=y-q,t){if(h&&h.push(n.sqlite3_sql(t).trim()),l=new d(this,t,f),c&&l.parameterCount&&(l.bind(c),c=null),u&&l.columnCount){let t=Array.isArray(i.columnNames)?0:1;if(u=!1,e.cbArg||a){const n=Object.create(null);for(;l.step();l._lockedByExec=!1){0==t++&&l.getColumnNames(n.columnNames=i.columnNames||[]),l._lockedByExec=!0;const r=e.cbArg(l,n);if(a&&a.push(r),o&&!1===o.call(i,r,l))break}l._lockedByExec=!1}0===t&&l.getColumnNames(i.columnNames)}else l.step();l.reset().finalize(),l=null}}}finally{r.scopedAllocPop(_),l&&(delete l._lockedByExec,l.finalize())}return e.returnVal()},createFunction:function(e,r,i){const o=e=>e instanceof Function;switch(arguments.length){case 1:e=(i=e).name,r=i.xFunc||0;break;case 2:o(r)||(r=(i=r).xFunc||0)}i||(i={}),"string"!=typeof e&&t("Invalid arguments: missing function name.");let l=i.xStep||0,c=i.xFinal||0;const u=i.xValue||0,_=i.xInverse||0;let f;o(r)?(f=!1,(o(l)||o(c))&&t("Ambiguous arguments: scalar or aggregate?"),l=c=null):o(l)?(o(c)||t("Missing xFinal() callback for aggregate or window UDF."),r=null):o(c)?t("Missing xStep() callback for aggregate or window UDF."):t("Missing function-type properties."),!1===f?(o(u)||o(_))&&t("xValue and xInverse are not permitted for non-window UDFs."):o(u)?(o(_)||t("xInverse must be provided if xValue is."),f=!0):o(_)&&t("xValue must be provided if xInverse is.");const d=i.pApp;null==d||"number"==typeof d&&s.isInt32(d)||t("Invalid value for pApp property. Must be a legal WASM pointer value.");const m=i.xDestroy||0;m&&!o(m)&&t("xDestroy property must be a function.");let h=0;a(i,"deterministic")&&(h|=n.SQLITE_DETERMINISTIC),a(i,"directOnly")&&(h|=n.SQLITE_DIRECTONLY),a(i,"innocuous")&&(h|=n.SQLITE_INNOCUOUS),e=e.toLowerCase();const g=r||l,q=a(i,"arity"),y="number"==typeof q?q:g.length?g.length-1:0;let b;return b=f?n.sqlite3_create_window_function(this.pointer,e,y,n.SQLITE_UTF8|h,d||0,l,c,u,_,m):n.sqlite3_create_function_v2(this.pointer,e,y,n.SQLITE_UTF8|h,d||0,r,l,c,m),p.checkRc(this,b),this},selectValue:function(e,t,n){return g(this,e,t,0,n)},selectValues:function(e,t,n){const r=this.prepare(e),s=[];try{for(r.bind(t);r.step();)s.push(r.get(0,n));r.reset()}finally{r.finalize()}return s},selectArray:function(e,t){return g(this,e,t,[])},selectObject:function(e,t){return g(this,e,t,{})},selectArrays:function(e,t){return q(this,e,t,"array")},selectObjects:function(e,t){return q(this,e,t,"object")},openStatementCount:function(){return this.pointer?Object.keys(o.get(this)).length:0},transaction:function(e){let r="BEGIN";arguments.length>1&&(/[^a-zA-Z]/.test(arguments[0])&&t(n.SQLITE_MISUSE,"Invalid argument for BEGIN qualifier."),r+=" "+arguments[0],e=arguments[1]),m(this).exec(r);try{const t=e(this);return this.exec("COMMIT"),t}catch(e){throw this.exec("ROLLBACK"),e}},savepoint:function(e){m(this).exec("SAVEPOINT oo1");try{const t=e(this);return this.exec("RELEASE oo1"),t}catch(e){throw this.exec("ROLLBACK to SAVEPOINT oo1; RELEASE SAVEPOINT oo1"),e}},checkRc:function(e){return l(this,e)}};const y=function(e){return e.pointer||t("Stmt has been closed."),e},b=function(e){return function(e){let t=f[null==e?"null":typeof e];switch(t){case f.boolean:case f.null:case f.number:case f.string:return t;case f.bigint:if(r.bigIntEnabled)return t;default:return s.isBindableTypedArray(e)?f.blob:void 0}}(e)||t("Unsupported bind() argument type:",typeof e)},w=function(e,n){return e._lockedByExec&&t("Operation is illegal when statement is locked:",n),e},v=function i(o,a,l,c){w(y(o),"bind()"),i._||(i._tooBigInt=e=>t("BigInt value is too big to store without precision loss:",e),i._={string:function(e,t,s,i){const[o,a]=r.allocCString(s,!0);return(i?n.sqlite3_bind_blob:n.sqlite3_bind_text)(e.pointer,t,o,a,n.SQLITE_WASM_DEALLOC)}}),b(c),a=function(e,r){const i="number"==typeof r?r:n.sqlite3_bind_parameter_index(e.pointer,r);return 0!==i&&s.isInt32(i)?(i<1||i>e.parameterCount)&&t("Bind index",r,"is out of range."):t("Invalid bind() parameter name: "+r),i}(o,a);let u=0;switch(null==c?f.null:l){case f.null:u=n.sqlite3_bind_null(o.pointer,a);break;case f.string:u=i._.string(o,a,c,!1);break;case f.number:{let e;s.isInt32(c)?e=n.sqlite3_bind_int:"bigint"==typeof c?s.bigIntFits64(c)?r.bigIntEnabled?e=n.sqlite3_bind_int64:s.bigIntFitsDouble(c)?(c=Number(c),e=n.sqlite3_bind_double):i._tooBigInt(c):i._tooBigInt(c):(c=Number(c),e=r.bigIntEnabled&&Number.isInteger(c)?n.sqlite3_bind_int64:n.sqlite3_bind_double),u=e(o.pointer,a,c);break}case f.boolean:u=n.sqlite3_bind_int(o.pointer,a,c?1:0);break;case f.blob:{if("string"==typeof c){u=i._.string(o,a,c,!0);break}c instanceof ArrayBuffer?c=new Uint8Array(c):s.isBindableTypedArray(c)||t("Binding a value as a blob requires","that it be a string, Uint8Array, Int8Array, or ArrayBuffer.");const e=r.alloc(c.byteLength||1);r.heap8().set(c.byteLength?c:[0],e),u=n.sqlite3_bind_blob(o.pointer,a,e,c.byteLength,n.SQLITE_WASM_DEALLOC);break}default:e.config.warn("Unsupported bind() argument type:",c),t("Unsupported bind() argument type: "+typeof c)}return u&&p.checkRc(o.db.pointer,u),o._mayGet=!1,o};d.prototype={finalize:function(){if(this.pointer){w(this,"finalize()");const e=n.sqlite3_finalize(this.pointer);return delete o.get(this.db)[this.pointer],i.delete(this),delete this._mayGet,delete this.parameterCount,delete this._lockedByExec,delete this.db,e}},clearBindings:function(){return w(y(this),"clearBindings()"),n.sqlite3_clear_bindings(this.pointer),this._mayGet=!1,this},reset:function(e){w(this,"reset()"),e&&this.clearBindings();const t=n.sqlite3_reset(y(this).pointer);return this._mayGet=!1,l(this.db,t),this},bind:function(){let e,n;switch(y(this),arguments.length){case 1:e=1,n=arguments[0];break;case 2:e=arguments[0],n=arguments[1];break;default:t("Invalid bind() arguments.")}return void 0===n?this:(this.parameterCount||t("This statement has no bindable parameters."),this._mayGet=!1,null===n?v(this,e,f.null,n):Array.isArray(n)?(1!==arguments.length&&t("When binding an array, an index argument is not permitted."),n.forEach(((e,t)=>v(this,t+1,b(e),e))),this):(n instanceof ArrayBuffer&&(n=new Uint8Array(n)),"object"!=typeof n||s.isBindableTypedArray(n)?v(this,e,b(n),n):(1!==arguments.length&&t("When binding an object, an index argument is not permitted."),Object.keys(n).forEach((e=>v(this,e,b(n[e]),n[e]))),this)))},bindAsBlob:function(e,n){y(this),1===arguments.length&&(n=e,e=1);const r=b(n);return f.string!==r&&f.blob!==r&&f.null!==r&&t("Invalid value type for bindAsBlob()"),v(this,e,f.blob,n)},step:function(){w(this,"step()");const t=n.sqlite3_step(y(this).pointer);switch(t){case n.SQLITE_DONE:return this._mayGet=!1;case n.SQLITE_ROW:return this._mayGet=!0;default:this._mayGet=!1,e.config.warn("sqlite3_step() rc=",t,n.sqlite3_js_rc_str(t),"SQL =",n.sqlite3_sql(this.pointer)),p.checkRc(this.db.pointer,t)}},stepReset:function(){return this.step(),this.reset()},stepFinalize:function(){try{const e=this.step();return this.reset(),e}finally{try{this.finalize()}catch(e){}}},get:function(e,i){if(y(this)._mayGet||t("Stmt.step() has not (recently) returned true."),Array.isArray(e)){let t=0;const n=this.columnCount;for(;t<n;)e[t]=this.get(t++);return e}if(e&&"object"==typeof e){let t=0;const r=this.columnCount;for(;t<r;)e[n.sqlite3_column_name(this.pointer,t)]=this.get(t++);return e}switch(h(this,e),void 0===i?n.sqlite3_column_type(this.pointer,e):i){case n.SQLITE_NULL:return null;case n.SQLITE_INTEGER:if(r.bigIntEnabled){const t=n.sqlite3_column_int64(this.pointer,e);return t>=Number.MIN_SAFE_INTEGER&&t<=Number.MAX_SAFE_INTEGER?Number(t).valueOf():t}{const r=n.sqlite3_column_double(this.pointer,e);return(r>Number.MAX_SAFE_INTEGER||r<Number.MIN_SAFE_INTEGER)&&t("Integer is out of range for JS integer range: "+r),s.isInt32(r)?0|r:r}case n.SQLITE_FLOAT:return n.sqlite3_column_double(this.pointer,e);case n.SQLITE_TEXT:return n.sqlite3_column_text(this.pointer,e);case n.SQLITE_BLOB:{const t=n.sqlite3_column_bytes(this.pointer,e),s=n.sqlite3_column_blob(this.pointer,e),i=new Uint8Array(t);return t&&i.set(r.heap8u().slice(s,s+t),0),t&&this.db._blobXfer instanceof Array&&this.db._blobXfer.push(i.buffer),i}default:t("Don't know how to translate","type of result column #"+e+".")}t("Not reached.")},getInt:function(e){return this.get(e,n.SQLITE_INTEGER)},getFloat:function(e){return this.get(e,n.SQLITE_FLOAT)},getString:function(e){return this.get(e,n.SQLITE_TEXT)},getBlob:function(e){return this.get(e,n.SQLITE_BLOB)},getJSON:function(e){const t=this.get(e,n.SQLITE_STRING);return null===t?t:JSON.parse(t)},getColumnName:function(e){return n.sqlite3_column_name(h(y(this),e).pointer,e)},getColumnNames:function(e=[]){h(y(this),0);const t=this.columnCount;for(let r=0;r<t;++r)e.push(n.sqlite3_column_name(this.pointer,r));return e},getParamIndex:function(e){return y(this).parameterCount?n.sqlite3_bind_parameter_index(this.pointer,e):void 0}};{const e={enumerable:!0,get:function(){return i.get(this)},set:()=>t("The pointer property is read-only.")};Object.defineProperty(d.prototype,"pointer",e),Object.defineProperty(p.prototype,"pointer",e)}if(Object.defineProperty(d.prototype,"columnCount",{enumerable:!1,get:function(){return n.sqlite3_column_count(this.pointer)},set:()=>t("The columnCount property is read-only.")}),e.oo1={DB:p,Stmt:d},s.isUIThread()){e.oo1.JsStorageDb=function(e="session"){const n=_.normalizeArgs(...arguments);"session"!==(e=n.filename)&&"local"!==e&&t("JsStorageDb db name must be one of 'session' or 'local'."),n.vfs="kvvfs",_.call(this,n)};const r=e.oo1.JsStorageDb;r.prototype=Object.create(p.prototype),r.clearStorage=n.sqlite3_js_kvvfs_clear,r.prototype.clearStorage=function(){return r.clearStorage(m(this).filename)},r.storageSize=n.sqlite3_js_kvvfs_size,r.prototype.storageSize=function(){return r.storageSize(m(this).filename)}}})),globalThis.sqlite3ApiBootstrap.initializers.push((function(e){const t=e.util;e.initWorker1API=function(){const e=(...e)=>{throw new Error(e.join(" "))};globalThis.WorkerGlobalScope instanceof Function||e("initWorker1API() must be run from a Worker thread.");const n=this.sqlite3||e("Missing this.sqlite3 object."),r=n.oo1.DB,s=function(e){let t=i.idMap.get(e);return t||(t="db#"+ ++i.idSeq+"@"+e.pointer,i.idMap.set(e,t),t)},i={dbList:[],idSeq:0,idMap:new WeakMap,xfer:[],open:function(e){const t=new r(e);return this.dbs[s(t)]=t,this.dbList.indexOf(t)<0&&this.dbList.push(t),t},close:function(e,n){if(e){delete this.dbs[s(e)];const r=e.filename,i=t.sqlite3__wasm_db_vfs(e.pointer,0);e.close();const o=this.dbList.indexOf(e);o>=0&&this.dbList.splice(o,1),n&&r&&i&&t.sqlite3__wasm_vfs_unlink(i,r)}},post:function(e,t){t&&t.length?(globalThis.postMessage(e,Array.from(t)),t.length=0):globalThis.postMessage(e)},dbs:Object.create(null),getDb:function(t,n=!0){return this.dbs[t]||(n?e("Unknown (or closed) DB ID:",t):void 0)}},o=function(t,n=!0){const r=i.getDb(t.dbId,!1)||i.dbList[0];return n?function(t=i.dbList[0]){return t&&t.pointer?t:e("DB is not opened.")}(r):r},a={open:function(t){const r=Object.create(null),o=t.args||Object.create(null);o.simulateError&&e("Throwing because of simulateError flag.");const a=Object.create(null);r.vfs=o.vfs,r.filename=o.filename||"";const l=i.open(r);return a.filename=l.filename,a.persistent=!!n.capi.sqlite3_js_db_uses_vfs(l.pointer,"opfs"),a.dbId=s(l),a.vfs=l.dbVfsName(),a},close:function(e){const t=o(e,!1),n={filename:t&&t.filename};if(t){const n=!(!e.args||"object"!=typeof e.args||!e.args.unlink);i.close(t,n)}return n},exec:function(t){const n="string"==typeof t.args?{sql:t.args}:t.args||Object.create(null);"stmt"===n.rowMode?e("Invalid rowMode for 'exec': stmt mode","does not work in the Worker API."):n.sql||e("'exec' requires input SQL.");const r=o(t);(n.callback||Array.isArray(n.resultRows))&&(r._blobXfer=i.xfer);const s=n.callback;let a=0;const l=!!n.columnNames;"string"==typeof s&&(l||(n.columnNames=[]),n.callback=function(e,t){i.post({type:s,columnNames:n.columnNames,rowNumber:++a,row:e},i.xfer)});try{const e=n.countChanges?r.changes(!0,64===n.countChanges):void 0;r.exec(n),void 0!==e&&(n.changeCount=r.changes(!0,64===n.countChanges)-e),n.callback instanceof Function&&(n.callback=s,i.post({type:s,columnNames:n.columnNames,rowNumber:null,row:void 0}))}finally{delete r._blobXfer,n.callback&&(n.callback=s)}return n},"config-get":function(){const e=Object.create(null),t=n.config;return["bigIntEnabled"].forEach((function(n){Object.getOwnPropertyDescriptor(t,n)&&(e[n]=t[n])})),e.version=n.version,e.vfsList=n.capi.sqlite3_js_vfs_list(),e.opfsEnabled=!!n.opfs,e},export:function(e){const t=o(e),r={byteArray:n.capi.sqlite3_js_db_export(t.pointer),filename:t.filename,mimetype:"application/x-sqlite3"};return i.xfer.push(r.byteArray.buffer),r},toss:function(t){e("Testing worker exception")},"opfs-tree":async function(t){return n.opfs||e("OPFS support is unavailable."),await n.opfs.treeList()}};globalThis.onmessage=async function(t){let n,r=(t=t.data).dbId,o=t.type;const l=performance.now();try{a.hasOwnProperty(o)&&a[o]instanceof Function?n=await a[o](t):e("Unknown db worker message type:",t.type)}catch(e){o="error",n={operation:t.type,message:e.message,errorClass:e.name,input:t},e.stack&&(n.stack="string"==typeof e.stack?e.stack.split(/\n\s*/):e.stack)}r||(r=n.dbId||i.dbList[0]&&s(i.dbList[0])),i.post({type:o,dbId:r,messageId:t.messageId,workerReceivedTime:l,workerRespondTime:performance.now(),departureTime:t.departureTime,result:n},i.xfer)},globalThis.postMessage({type:"sqlite3-api",result:"worker1-ready"})}.bind({sqlite3:e})})),globalThis.sqlite3ApiBootstrap.initializers.push((function(e){const t=e.wasm,n=e.capi,r=e.util.toss3,s=Object.create(null);e.vfs=s,n.sqlite3_vfs.prototype.registerVfs=function(t=!1){this instanceof e.capi.sqlite3_vfs||r("Expecting a sqlite3_vfs-type argument.");const s=n.sqlite3_vfs_register(this,t?1:0);return s&&r("sqlite3_vfs_register(",this,") failed with rc",s),this.pointer!==n.sqlite3_vfs_find(this.$zName)&&r("BUG: sqlite3_vfs_find(vfs.$zName) failed for just-installed VFS",this),this},s.installVfs=function(e){let n=0;const s=["io","vfs"];for(const r of s){const s=e[r];s&&(++n,s.struct.installMethods(s.methods,!!s.applyArgcCheck),"vfs"===r&&(s.struct.$zName||"string"!=typeof s.name||s.struct.addOnDispose(s.struct.$zName=t.allocCString(s.name)),s.struct.registerVfs(!!s.asDefault)))}return n||r("Misuse: installVfs() options object requires at least","one of:",s),this}})),globalThis.sqlite3ApiBootstrap.initializers.push((function(e){const t=e.wasm,n=e.capi,r=e.util.toss3,s=Object.create(null);e.vtab=s;const i=n.sqlite3_index_info;i.prototype.nthConstraint=function(e,t=!1){if(e<0||e>=this.$nConstraint)return!1;const n=this.$aConstraint+i.sqlite3_index_constraint.structInfo.sizeof*e;return t?n:new i.sqlite3_index_constraint(n)},i.prototype.nthConstraintUsage=function(e,t=!1){if(e<0||e>=this.$nConstraint)return!1;const n=this.$aConstraintUsage+i.sqlite3_index_constraint_usage.structInfo.sizeof*e;return t?n:new i.sqlite3_index_constraint_usage(n)},i.prototype.nthOrderBy=function(e,t=!1){if(e<0||e>=this.$nOrderBy)return!1;const n=this.$aOrderBy+i.sqlite3_index_orderby.structInfo.sizeof*e;return t?n:new i.sqlite3_index_orderby(n)};const o=function(n,r){const s=function(n,r){return function(s,i=!1){if(0===arguments.length&&(s=new r),s instanceof r)return this.set(s.pointer,s),s;t.isPtr(s)||e.SQLite3Error.toss("Invalid argument to",n+"()");let o=this.get(s);return i&&this.delete(s),o}.bind(new Map)}(n,r);return Object.assign(Object.create(null),{StructType:r,create:e=>{const n=s();return t.pokePtr(e,n.pointer),n},get:e=>s(e),unget:e=>s(e,!0),dispose:e=>{const t=s(e,!0);t&&t.dispose()}})};s.xVtab=o("xVtab",n.sqlite3_vtab),s.xCursor=o("xCursor",n.sqlite3_vtab_cursor),s.xIndexInfo=e=>new n.sqlite3_index_info(e),s.xError=function t(r,s,i){if(t.errorReporter instanceof Function)try{t.errorReporter("sqlite3_module::"+r+"(): "+s.message)}catch(e){}let o;return s instanceof e.WasmAllocError?o=n.SQLITE_NOMEM:arguments.length>2?o=i:s instanceof e.SQLite3Error&&(o=s.resultCode),o||n.SQLITE_ERROR},s.xError.errorReporter=console.error.bind(console),s.xRowid=(e,n)=>t.poke(e,n,"i64"),s.setupModule=function(i){let o=!1;const a=this instanceof n.sqlite3_module?this:i.struct||(o=new n.sqlite3_module);try{const n=i.methods||r("Missing 'methods' object.");for(const e of Object.entries({xConnect:"xCreate",xDisconnect:"xDestroy"})){const t=e[0],r=e[1];!0===n[t]?n[t]=n[r]:!0===n[r]&&(n[r]=n[t])}if(i.catchExceptions){const r=function(n,r){return["xConnect","xCreate"].indexOf(n)>=0?function(i,o,a,l,c,u){try{return r(...arguments)||0}catch(r){return r instanceof e.WasmAllocError||(t.dealloc(t.peekPtr(u)),t.pokePtr(u,t.allocCString(r.message))),s.xError(n,r)}}:function(...e){try{return r(...e)||0}catch(e){return s.xError(n,e)}}},i=["xCreate","xConnect","xBestIndex","xDisconnect","xDestroy","xOpen","xClose","xFilter","xNext","xEof","xColumn","xRowid","xUpdate","xBegin","xSync","xCommit","xRollback","xFindFunction","xRename","xSavepoint","xRelease","xRollbackTo","xShadowName"],o=Object.create(null);for(const e of i){const t=n[e];t instanceof Function&&("xConnect"===e&&n.xCreate===t?o[e]=n.xCreate:"xCreate"===e&&n.xConnect===t?o[e]=n.xConnect:o[e]=r(e,t))}a.installMethods(o,!1)}else a.installMethods(n,!!i.applyArgcCheck);if(0===a.$iVersion){let e;e="number"==typeof i.iVersion?i.iVersion:a.$xShadowName?3:a.$xSavePoint||a.$xRelease||a.$xRollbackTo?2:1,a.$iVersion=e}}catch(e){throw o&&o.dispose(),e}return a},n.sqlite3_module.prototype.setupModule=function(e){return s.setupModule.call(this,e)}})),globalThis.sqlite3ApiBootstrap.initializers.push((function(e){const t=function t(n){if(!globalThis.SharedArrayBuffer||!globalThis.Atomics)return Promise.reject(new Error("Cannot install OPFS: Missing SharedArrayBuffer and/or Atomics. The server must emit the COOP/COEP response headers to enable those. See https://sqlite.org/wasm/doc/trunk/persistence.md#coop-coep"));if("undefined"==typeof WorkerGlobalScope)return Promise.reject(new Error("The OPFS sqlite3_vfs cannot run in the main thread because it requires Atomics.wait()."));if(!(globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&navigator?.storage?.getDirectory))return Promise.reject(new Error("Missing required OPFS APIs."));n&&"object"==typeof n||(n=Object.create(null));const r=new URL(globalThis.location.href).searchParams;if(r.has("opfs-disable"))return Promise.resolve(e);void 0===n.verbose&&(n.verbose=r.has("opfs-verbose")?+r.get("opfs-verbose")||2:1),void 0===n.sanityChecks&&(n.sanityChecks=r.has("opfs-sanity-check")),void 0===n.proxyUri&&(n.proxyUri=t.defaultProxyUri),"function"==typeof n.proxyUri&&(n.proxyUri=n.proxyUri());const s=new Promise((function(t,r){const s=[e.config.error,e.config.warn,e.config.log],i=(e,...t)=>{n.verbose>e&&s[e]("OPFS syncer:",...t)},o=(...e)=>i(2,...e),a=(...e)=>i(1,...e),l=(...e)=>i(0,...e),c=e.util.toss,u=e.capi,_=e.util,p=e.wasm,f=u.sqlite3_vfs,d=u.sqlite3_file,m=u.sqlite3_io_methods,h=Object.create(null);h.metrics={dump:function(){let t,n=0,r=0,s=0;for(t in x.opIds){const e=A[t];n+=e.count,r+=e.time,s+=e.wait,e.avgTime=e.count&&e.time?e.time/e.count:0,e.avgWait=e.count&&e.wait?e.wait/e.count:0}e.config.log(globalThis.location.href,"metrics for",globalThis.location.href,":",A,"\nTotal of",n,"op(s) for",r,"ms (incl. "+s+" ms of waiting on the async side)"),e.config.log("Serialization metrics:",A.s11n),v.postMessage({type:"opfs-async-metrics"})},reset:function(){let e;for(e in x.opIds)(t=A[e]=Object.create(null)).count=t.time=t.wait=0;var t;let n=A.s11n=Object.create(null);n=n.serialize=Object.create(null),n.count=n.time=0,n=A.s11n.deserialize=Object.create(null),n.count=n.time=0}};const g=new m,q=(new f).addOnDispose((()=>g.dispose()));let y;const b=e=>(y=!0,q.dispose(),r(e)),w=()=>(y=!1,t(e)),v=new Worker(new URL("sqlite3-opfs-async-proxy.js",import.meta.url));setTimeout((()=>{void 0===y&&b(new Error("Timeout while waiting for OPFS async proxy worker."))}),4e3),v._originalOnError=v.onerror,v.onerror=function(e){l("Error initializing OPFS asyncer:",e),b(new Error("Loading OPFS async Worker failed for unknown reasons."))};const E=u.sqlite3_vfs_find(null),S=E?new f(E):null;g.$iVersion=1,q.$iVersion=2,q.$szOsFile=u.sqlite3_file.structInfo.sizeof,q.$mxPathname=1024,q.$zName=p.allocCString("opfs"),q.$xDlOpen=q.$xDlError=q.$xDlSym=q.$xDlClose=null,q.addOnDispose("$zName",q.$zName,"cleanup default VFS wrapper",(()=>S?S.dispose():null));const x=Object.create(null);x.verbose=n.verbose,x.littleEndian=(()=>{const e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),256===new Int16Array(e)[0]})(),x.asyncIdleWaitTime=150,x.asyncS11nExceptions=1,x.fileBufferSize=65536,x.sabS11nOffset=x.fileBufferSize,x.sabS11nSize=2*q.$mxPathname,x.sabIO=new SharedArrayBuffer(x.fileBufferSize+x.sabS11nSize),x.opIds=Object.create(null);const A=Object.create(null);{let e=0;x.opIds.whichOp=e++,x.opIds.rc=e++,x.opIds.xAccess=e++,x.opIds.xClose=e++,x.opIds.xDelete=e++,x.opIds.xDeleteNoWait=e++,x.opIds.xFileSize=e++,x.opIds.xLock=e++,x.opIds.xOpen=e++,x.opIds.xRead=e++,x.opIds.xSleep=e++,x.opIds.xSync=e++,x.opIds.xTruncate=e++,x.opIds.xUnlock=e++,x.opIds.xWrite=e++,x.opIds.mkdir=e++,x.opIds["opfs-async-metrics"]=e++,x.opIds["opfs-async-shutdown"]=e++,x.opIds.retry=e++,x.sabOP=new SharedArrayBuffer(4*e),h.metrics.reset()}x.sq3Codes=Object.create(null),["SQLITE_ACCESS_EXISTS","SQLITE_ACCESS_READWRITE","SQLITE_BUSY","SQLITE_CANTOPEN","SQLITE_ERROR","SQLITE_IOERR","SQLITE_IOERR_ACCESS","SQLITE_IOERR_CLOSE","SQLITE_IOERR_DELETE","SQLITE_IOERR_FSYNC","SQLITE_IOERR_LOCK","SQLITE_IOERR_READ","SQLITE_IOERR_SHORT_READ","SQLITE_IOERR_TRUNCATE","SQLITE_IOERR_UNLOCK","SQLITE_IOERR_WRITE","SQLITE_LOCK_EXCLUSIVE","SQLITE_LOCK_NONE","SQLITE_LOCK_PENDING","SQLITE_LOCK_RESERVED","SQLITE_LOCK_SHARED","SQLITE_LOCKED","SQLITE_MISUSE","SQLITE_NOTFOUND","SQLITE_OPEN_CREATE","SQLITE_OPEN_DELETEONCLOSE","SQLITE_OPEN_MAIN_DB","SQLITE_OPEN_READONLY"].forEach((e=>{void 0===(x.sq3Codes[e]=u[e])&&c("Maintenance required: not found:",e)})),x.opfsFlags=Object.assign(Object.create(null),{OPFS_UNLOCK_ASAP:1,OPFS_UNLINK_BEFORE_OPEN:2,defaultUnlockAsap:!1});const I=(e,...t)=>{const n=x.opIds[e]||c("Invalid op ID:",e);x.s11n.serialize(...t),Atomics.store(x.sabOPView,x.opIds.rc,-1),Atomics.store(x.sabOPView,x.opIds.whichOp,n),Atomics.notify(x.sabOPView,x.opIds.whichOp);const r=performance.now();for(;"not-equal"!==Atomics.wait(x.sabOPView,x.opIds.rc,-1););const s=Atomics.load(x.sabOPView,x.opIds.rc);if(A[e].wait+=performance.now()-r,s&&x.asyncS11nExceptions){const t=x.s11n.deserialize();t&&l(e+"() async error:",...t)}return s};h.debug={asyncShutdown:()=>{a("Shutting down OPFS async listener. The OPFS VFS will no longer work."),I("opfs-async-shutdown")},asyncRestart:()=>{a("Attempting to restart OPFS VFS async listener. Might work, might not."),v.postMessage({type:"opfs-async-restart"})}};const T=function e(t=16){e._chars||(e._n=(e._chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012346789").length);const n=[];let r=0;for(;r<t;++r){const t=Math.random()*(64*e._n)%e._n|0;n[r]=e._chars[t]}return n.join("")},k=Object.create(null),F=Object.create(null);F.op=void 0,F.start=void 0;const O=e=>{F.start=performance.now(),F.op=e,++A[e].count},P=()=>A[F.op].time+=performance.now()-F.start,L={xCheckReservedLock:function(e,t){return p.poke(t,0,"i32"),0},xClose:function(e){O("xClose");let t=0;const n=k[e];return n&&(delete k[e],t=I("xClose",e),n.sq3File&&n.sq3File.dispose()),P(),t},xDeviceCharacteristics:function(e){return u.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(e,t,n){return u.SQLITE_NOTFOUND},xFileSize:function(e,t){O("xFileSize");let n=I("xFileSize",e);if(0==n)try{const e=x.s11n.deserialize()[0];p.poke(t,e,"i64")}catch(e){l("Unexpected error reading xFileSize() result:",e),n=x.sq3Codes.SQLITE_IOERR}return P(),n},xLock:function(e,t){O("xLock");const n=k[e];let r=0;return n.lockType?n.lockType=t:(r=I("xLock",e,t),0===r&&(n.lockType=t)),P(),r},xRead:function(e,t,n,r){O("xRead");const s=k[e];let i;try{i=I("xRead",e,n,Number(r)),0!==i&&u.SQLITE_IOERR_SHORT_READ!==i||p.heap8u().set(s.sabView.subarray(0,n),t)}catch(e){l("xRead(",arguments,") failed:",e,s),i=u.SQLITE_IOERR_READ}return P(),i},xSync:function(e,t){O("xSync"),++A.xSync.count;const n=I("xSync",e,t);return P(),n},xTruncate:function(e,t){O("xTruncate");const n=I("xTruncate",e,Number(t));return P(),n},xUnlock:function(e,t){O("xUnlock");const n=k[e];let r=0;return u.SQLITE_LOCK_NONE===t&&n.lockType&&(r=I("xUnlock",e,t)),0===r&&(n.lockType=t),P(),r},xWrite:function(e,t,n,r){O("xWrite");const s=k[e];let i;try{s.sabView.set(p.heap8u().subarray(t,t+n)),i=I("xWrite",e,n,Number(r))}catch(e){l("xWrite(",arguments,") failed:",e,s),i=u.SQLITE_IOERR_WRITE}return P(),i}},C={xAccess:function(e,t,n,r){O("xAccess");const s=I("xAccess",p.cstrToJs(t));return p.poke(r,s?0:1,"i32"),P(),0},xCurrentTime:function(e,t){return p.poke(t,2440587.5+(new Date).getTime()/864e5,"double"),0},xCurrentTimeInt64:function(e,t){return p.poke(t,21086676e7+(new Date).getTime(),"i64"),0},xDelete:function(e,t,n){O("xDelete");const r=I("xDelete",p.cstrToJs(t),n,!1);return P(),r},xFullPathname:function(e,t,n,r){return p.cstrncpy(r,t,n)<n?0:u.SQLITE_CANTOPEN},xGetLastError:function(e,t,n){return a("OPFS xGetLastError() has nothing sensible to return."),0},xOpen:function(e,t,n,r,s){O("xOpen");let i=0;0===t?t=T():p.isPtr(t)&&(u.sqlite3_uri_boolean(t,"opfs-unlock-asap",0)&&(i|=x.opfsFlags.OPFS_UNLOCK_ASAP),u.sqlite3_uri_boolean(t,"delete-before-open",0)&&(i|=x.opfsFlags.OPFS_UNLINK_BEFORE_OPEN),t=p.cstrToJs(t));const o=Object.create(null);o.fid=n,o.filename=t,o.sab=new SharedArrayBuffer(x.fileBufferSize),o.flags=r;const a=I("xOpen",n,t,r,i);return a||(o.readOnly&&p.poke(s,u.SQLITE_OPEN_READONLY,"i32"),k[n]=o,o.sabView=x.sabFileBufView,o.sq3File=new d(n),o.sq3File.$pMethods=g.pointer,o.lockType=u.SQLITE_LOCK_NONE),P(),a}};if(S&&(q.$xRandomness=S.$xRandomness,q.$xSleep=S.$xSleep),q.$xRandomness||(C.xRandomness=function(e,t,n){const r=p.heap8u();let s=0;for(;s<t;++s)r[n+s]=255e3*Math.random()&255;return s}),q.$xSleep||(C.xSleep=function(e,t){return Atomics.wait(x.sabOPView,x.opIds.xSleep,0,t),0}),h.getResolvedPath=function(e,t){const n=new URL(e,"file://irrelevant").pathname;return t?n.split("/").filter((e=>!!e)):n},h.getDirForFilename=async function(e,t=!1){const n=h.getResolvedPath(e,!0),r=n.pop();let s=h.rootDirectory;for(const e of n)e&&(s=await s.getDirectoryHandle(e,{create:!!t}));return[s,r]},h.mkdir=async function(e){try{return await h.getDirForFilename(e+"/filepart",!0),!0}catch(e){return!1}},h.entryExists=async function(e){try{const[t,n]=await h.getDirForFilename(e);return await t.getFileHandle(n),!0}catch(e){return!1}},h.randomFilename=T,h.treeList=async function(){const e=Object.create(null);return await async function e(t,n){n.name=t.name,n.dirs=[],n.files=[];for await(const r of t.values())if("directory"===r.kind){const t=Object.create(null);n.dirs.push(t),await e(r,t)}else n.files.push(r.name)}(h.rootDirectory,e),e},h.rmfr=async function(){const e=h.rootDirectory,t={recurse:!0};for await(const n of e.values())e.removeEntry(n.name,t)},h.unlink=async function(e,t=!1,n=!1){try{const[n,r]=await h.getDirForFilename(e,!1);return await n.removeEntry(r,{recursive:t}),!0}catch(e){if(n)throw new Error("unlink(",arguments[0],") failed: "+e.message,{cause:e});return!1}},h.traverse=async function(e){const t={recursive:!0,directory:h.rootDirectory};"function"==typeof e&&(e={callback:e}),async function t(n,r){for await(const s of n.values()){if(!1===e.callback(s,n,r))return!1;if(e.recursive&&"directory"===s.kind&&!1===await t(s,r+1))break}}((e=Object.assign(t,e||{})).directory,0)},h.importDb=async function(e,t){if(t instanceof Function)return async function(e,t){const[n,r]=await h.getDirForFilename(e,!0),s=await n.getFileHandle(r,{create:!0});let i,o=await s.createSyncAccessHandle(),a=0,l=!1;try{for(o.truncate(0);void 0!==(i=await t());)i instanceof ArrayBuffer&&(i=new Uint8Array(i)),0===a&&i.byteLength>=15&&(_.affirmDbHeader(i),l=!0),o.write(i,{at:a}),a+=i.byteLength;if((a<512||0!=a%512)&&c("Input size",a,"is not correct for an SQLite database."),!l){const e=new Uint8Array(20);o.read(e,{at:0}),_.affirmDbHeader(e)}return o.write(new Uint8Array([1,1]),{at:18}),a}catch(e){throw await o.close(),o=void 0,await n.removeEntry(r).catch((()=>{})),e}finally{o&&await o.close()}}(e,t);t instanceof ArrayBuffer&&(t=new Uint8Array(t)),_.affirmIsDb(t);const n=t.byteLength,[r,s]=await h.getDirForFilename(e,!0);let i,o=0;try{const e=await r.getFileHandle(s,{create:!0});return i=await e.createSyncAccessHandle(),i.truncate(0),o=i.write(t,{at:0}),o!=n&&c("Expected to write "+n+" bytes but wrote "+o+"."),i.write(new Uint8Array([1,1]),{at:18}),o}catch(e){throw i&&(await i.close(),i=void 0),await r.removeEntry(s).catch((()=>{})),e}finally{i&&await i.close()}},e.oo1){const t=function(...t){const n=e.oo1.DB.dbCtorHelper.normalizeArgs(...t);n.vfs=q.$zName,e.oo1.DB.dbCtorHelper.call(this,n)};t.prototype=Object.create(e.oo1.DB.prototype),e.oo1.OpfsDb=t,t.importDb=h.importDb,e.oo1.DB.dbCtorHelper.setVfsPostOpenSql(q.pointer,(function(e,t){t.capi.sqlite3_busy_timeout(e,1e4),t.capi.sqlite3_exec(e,["pragma journal_mode=DELETE;","pragma cache_size=-16384;"],0,0,0)}))}v.onmessage=function({data:t}){switch(t.type){case"opfs-unavailable":b(new Error(t.payload.join(" ")));break;case"opfs-async-loaded":v.postMessage({type:"opfs-async-init",args:x});break;case"opfs-async-inited":if(!0===y)break;try{e.vfs.installVfs({io:{struct:g,methods:L},vfs:{struct:q,methods:C}}),x.sabOPView=new Int32Array(x.sabOP),x.sabFileBufView=new Uint8Array(x.sabIO,0,x.fileBufferSize),x.sabS11nView=new Uint8Array(x.sabIO,x.sabS11nOffset,x.sabS11nSize),(()=>{if(x.s11n)return x.s11n;const e=new TextDecoder,t=new TextEncoder("utf-8"),n=new Uint8Array(x.sabIO,x.sabS11nOffset,x.sabS11nSize),r=new DataView(x.sabIO,x.sabS11nOffset,x.sabS11nSize);x.s11n=Object.create(null);const s=Object.create(null);s.number={id:1,size:8,getter:"getFloat64",setter:"setFloat64"},s.bigint={id:2,size:8,getter:"getBigInt64",setter:"setBigInt64"},s.boolean={id:3,size:4,getter:"getInt32",setter:"setInt32"},s.string={id:4};const i=e=>s[typeof e]||c("Maintenance required: this value type cannot be serialized.",e),o=e=>{switch(e){case s.number.id:return s.number;case s.bigint.id:return s.bigint;case s.boolean.id:return s.boolean;case s.string.id:return s.string;default:c("Invalid type ID:",e)}};x.s11n.deserialize=function(t=!1){++A.s11n.deserialize.count;const s=performance.now(),i=n[0],a=i?[]:null;if(i){const t=[];let s,l,c,u=1;for(s=0;s<i;++s,++u)t.push(o(n[u]));for(s=0;s<i;++s){const i=t[s];i.getter?(c=r[i.getter](u,x.littleEndian),u+=i.size):(l=r.getInt32(u,x.littleEndian),u+=4,c=e.decode(n.slice(u,u+l)),u+=l),a.push(c)}}return t&&(n[0]=0),A.s11n.deserialize.time+=performance.now()-s,a},x.s11n.serialize=function(...e){const s=performance.now();if(++A.s11n.serialize.count,e.length){const s=[];let o=0,a=1;for(n[0]=255&e.length;o<e.length;++o,++a)s.push(i(e[o])),n[a]=s[o].id;for(o=0;o<e.length;++o){const i=s[o];if(i.setter)r[i.setter](a,e[o],x.littleEndian),a+=i.size;else{const s=t.encode(e[o]);r.setInt32(a,s.byteLength,x.littleEndian),a+=4,n.set(s,a),a+=s.byteLength}}}else n[0]=0;A.s11n.serialize.time+=performance.now()-s},x.s11n})(),n.sanityChecks&&(a("Running sanity checks because of opfs-sanity-check URL arg..."),function(){const e=p.scopedAllocPush(),t=new d;try{const e=t.pointer,n=u.SQLITE_OPEN_CREATE|u.SQLITE_OPEN_READWRITE|u.SQLITE_OPEN_MAIN_DB,r=p.scopedAlloc(8),s="/sanity/check/file"+T(8),i=p.scopedAllocCString(s);let _;if(x.s11n.serialize("This is ä string."),_=x.s11n.deserialize(),o("deserialize() says:",_),"This is ä string."!==_[0]&&c("String d13n error."),C.xAccess(q.pointer,i,0,r),_=p.peek(r,"i32"),o("xAccess(",s,") exists ?=",_),_=C.xOpen(q.pointer,i,e,n,r),o("open rc =",_,"state.sabOPView[xOpen] =",x.sabOPView[x.opIds.xOpen]),0!==_)return void l("open failed with code",_);C.xAccess(q.pointer,i,0,r),_=p.peek(r,"i32"),_||c("xAccess() failed to detect file."),_=L.xSync(t.pointer,0),_&&c("sync failed w/ rc",_),_=L.xTruncate(t.pointer,1024),_&&c("truncate failed w/ rc",_),p.poke(r,0,"i64"),_=L.xFileSize(t.pointer,r),_&&c("xFileSize failed w/ rc",_),o("xFileSize says:",p.peek(r,"i64")),_=L.xWrite(t.pointer,i,10,1),_&&c("xWrite() failed!");const f=p.scopedAlloc(16);_=L.xRead(t.pointer,f,6,2),p.poke(f+6,0);let d=p.cstrToJs(f);o("xRead() got:",d),"sanity"!==d&&c("Unexpected xRead() value."),C.xSleep&&(o("xSleep()ing before close()ing..."),C.xSleep(q.pointer,2e3),o("waking up from xSleep()")),_=L.xClose(e),o("xClose rc =",_,"sabOPView =",x.sabOPView),o("Deleting file:",s),C.xDelete(q.pointer,i,4660),C.xAccess(q.pointer,i,0,r),_=p.peek(r,"i32"),_&&c("Expecting 0 from xAccess(",s,") after xDelete()."),a("End of OPFS sanity checks.")}finally{t.dispose(),p.scopedAllocPop(e)}}()),globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&navigator?.storage?.getDirectory?navigator.storage.getDirectory().then((t=>{v.onerror=v._originalOnError,delete v._originalOnError,e.opfs=h,h.rootDirectory=t,o("End of OPFS sqlite3_vfs setup.",q),w()})).catch(b):w()}catch(e){l(e),b(e)}break;default:{const e="Unexpected message from the OPFS async worker: "+JSON.stringify(t);l(e),b(new Error(e));break}}}}));return s};t.defaultProxyUri="sqlite3-opfs-async-proxy.js",globalThis.sqlite3ApiBootstrap.initializersAsync.push((async e=>{try{let n=t.defaultProxyUri;return e.scriptInfo.sqlite3Dir&&(t.defaultProxyUri=e.scriptInfo.sqlite3Dir+n),t().catch((t=>{e.config.warn("Ignoring inability to install OPFS sqlite3_vfs:",t.message)}))}catch(t){return e.config.error("installOpfsVfs() exception:",t),Promise.reject(t)}}))})),globalThis.sqlite3ApiBootstrap.initializers.push((function(e){const t=e.util.toss,n=e.util.toss3,r=Object.create(null),s=e.capi,i=e.util,o=e.wasm,a=512,l=4096,c=s.SQLITE_OPEN_MAIN_DB|s.SQLITE_OPEN_MAIN_JOURNAL|s.SQLITE_OPEN_SUPER_JOURNAL|s.SQLITE_OPEN_WAL,u=".opaque",_=()=>Math.random().toString(36).slice(2),p=new TextDecoder,f=new TextEncoder,d=Object.assign(Object.create(null),{name:"opfs-sahpool",directory:void 0,initialCapacity:6,clearOnInit:!1,verbosity:2}),m=[e.config.error,e.config.warn,e.config.log],h=e.config.warn,g=new Map,q=e=>g.get(e),y=(e,t)=>{t?g.set(e,t):g.delete(e)},b=new Map,w=e=>b.get(e),v=(e,t)=>{t?b.set(e,t):b.delete(e)},E={xCheckReservedLock:function(e,t){const n=w(e);return n.log("xCheckReservedLock"),n.storeErr(),o.poke32(t,1),0},xClose:function(e){const t=w(e);t.storeErr();const n=t.getOFileForS3File(e);if(n)try{t.log(`xClose ${n.path}`),t.mapS3FileToOFile(e,!1),n.sah.flush(),n.flags&s.SQLITE_OPEN_DELETEONCLOSE&&t.deletePath(n.path)}catch(e){return t.storeErr(e,s.SQLITE_IOERR)}return 0},xDeviceCharacteristics:function(e){return s.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(e,t,n){return s.SQLITE_NOTFOUND},xFileSize:function(e,t){const n=w(e);n.log("xFileSize");const r=n.getOFileForS3File(e).sah.getSize()-l;return o.poke64(t,BigInt(r)),0},xLock:function(e,t){const n=w(e);return n.log(`xLock ${t}`),n.storeErr(),n.getOFileForS3File(e).lockType=t,0},xRead:function(e,t,n,r){const i=w(e);i.storeErr();const a=i.getOFileForS3File(e);i.log(`xRead ${a.path} ${n} @ ${r}`);try{const e=a.sah.read(o.heap8u().subarray(t,t+n),{at:l+Number(r)});return e<n?(o.heap8u().fill(0,t+e,t+n),s.SQLITE_IOERR_SHORT_READ):0}catch(e){return i.storeErr(e,s.SQLITE_IOERR)}},xSectorSize:function(e){return 4096},xSync:function(e,t){const n=w(e);n.log(`xSync ${t}`),n.storeErr();const r=n.getOFileForS3File(e);try{return r.sah.flush(),0}catch(e){return n.storeErr(e,s.SQLITE_IOERR)}},xTruncate:function(e,t){const n=w(e);n.log(`xTruncate ${t}`),n.storeErr();const r=n.getOFileForS3File(e);try{return r.sah.truncate(l+Number(t)),0}catch(e){return n.storeErr(e,s.SQLITE_IOERR)}},xUnlock:function(e,t){const n=w(e);return n.log("xUnlock"),n.getOFileForS3File(e).lockType=t,0},xWrite:function(e,n,r,i){const a=w(e);a.storeErr();const c=a.getOFileForS3File(e);a.log(`xWrite ${c.path} ${r} ${i}`);try{return r===c.sah.write(o.heap8u().subarray(n,n+r),{at:l+Number(i)})?0:t("Unknown write() failure.")}catch(e){return a.storeErr(e,s.SQLITE_IOERR)}}},S=new s.sqlite3_io_methods;S.$iVersion=1,e.vfs.installVfs({io:{struct:S,methods:E}});const x={xAccess:function(e,t,n,r){const s=q(e);s.storeErr();try{const e=s.getPath(t);o.poke32(r,s.hasFilename(e)?1:0)}catch(e){o.poke32(r,0)}return 0},xCurrentTime:function(e,t){return o.poke(t,2440587.5+(new Date).getTime()/864e5,"double"),0},xCurrentTimeInt64:function(e,t){return o.poke(t,21086676e7+(new Date).getTime(),"i64"),0},xDelete:function(e,t,n){const r=q(e);r.log(`xDelete ${o.cstrToJs(t)}`),r.storeErr();try{return r.deletePath(r.getPath(t)),0}catch(e){return r.storeErr(e),s.SQLITE_IOERR_DELETE}},xFullPathname:function(e,t,n,r){return o.cstrncpy(r,t,n)<n?0:s.SQLITE_CANTOPEN},xGetLastError:function(e,t,n){const r=q(e),i=r.popErr();if(r.log(`xGetLastError ${t} e =`,i),i){const e=o.scopedAllocPush();try{const[e,r]=o.scopedAllocCString(i.message,!0);o.cstrncpy(n,e,t),r>t&&o.poke8(n+t-1,0)}catch(i){return s.SQLITE_NOMEM}finally{o.scopedAllocPop(e)}}return i?i.sqlite3Rc||s.SQLITE_IOERR:0},xOpen:function(e,n,r,i,a){const l=q(e);try{l.log(`xOpen ${o.cstrToJs(n)} ${i}`);const e=n&&o.peek8(n)?l.getPath(n):_();let c=l.getSAHForPath(e);!c&&i&s.SQLITE_OPEN_CREATE&&(l.getFileCount()<l.getCapacity()?(c=l.nextAvailableSAH(),l.setAssociatedPath(c,e,i)):t("SAH pool is full. Cannot create file",e)),c||t("file not found:",e);const u={path:e,flags:i,sah:c};l.mapS3FileToOFile(r,u),u.lockType=s.SQLITE_LOCK_NONE;const p=new s.sqlite3_file(r);return p.$pMethods=S.pointer,p.dispose(),o.poke32(a,i),0}catch(e){return l.storeErr(e),s.SQLITE_CANTOPEN}}};class A{vfsDir;#e;#t;#n;#r=new Map;#s=new Map;#i=new Set;#o=new Map;#a=new Uint8Array(516);#l;#c;#u;constructor(t=Object.create(null)){this.#u=t.verbosity??d.verbosity,this.vfsName=t.name||d.name,this.#c=function(t){e.capi.sqlite3_vfs_find(t)&&n("VFS name is already registered:",t);const r=new s.sqlite3_vfs,i=s.sqlite3_vfs_find(null),l=i?new s.sqlite3_vfs(i):null;return r.$iVersion=2,r.$szOsFile=s.sqlite3_file.structInfo.sizeof,r.$mxPathname=a,r.addOnDispose(r.$zName=o.allocCString(t),(()=>y(r.pointer,0))),l&&(r.$xRandomness=l.$xRandomness,r.$xSleep=l.$xSleep,l.dispose()),r.$xRandomness||x.xRandomness||(x.xRandomness=function(e,t,n){const r=o.heap8u();let s=0;for(;s<t;++s)r[n+s]=255e3*Math.random()&255;return s}),r.$xSleep||x.xSleep||(x.xSleep=(e,t)=>0),e.vfs.installVfs({vfs:{struct:r,methods:x}}),r}(this.vfsName),y(this.#c.pointer,this),this.vfsDir=t.directory||"."+this.vfsName,this.#l=new DataView(this.#a.buffer,this.#a.byteOffset),this.isReady=this.reset(!!(t.clearOnInit??d.clearOnInit)).then((()=>{if(this.$error)throw this.$error;return this.getCapacity()?Promise.resolve(void 0):this.addCapacity(t.initialCapacity||d.initialCapacity)}))}#_(e,...t){this.#u>e&&m[e](this.vfsName+":",...t)}log(...e){this.#_(2,...e)}warn(...e){this.#_(1,...e)}error(...e){this.#_(0,...e)}getVfs(){return this.#c}getCapacity(){return this.#r.size}getFileCount(){return this.#s.size}getFileNames(){const e=[],t=this.#s.keys();for(const n of t)e.push(n);return e}async addCapacity(e){for(let t=0;t<e;++t){const e=_(),t=await this.#t.getFileHandle(e,{create:!0}),n=await t.createSyncAccessHandle();this.#r.set(n,e),this.setAssociatedPath(n,"",0)}return this.getCapacity()}async reduceCapacity(e){let t=0;for(const n of Array.from(this.#i)){if(t===e||this.getFileCount()===this.getCapacity())break;const r=this.#r.get(n);n.close(),await this.#t.removeEntry(r),this.#r.delete(n),this.#i.delete(n),++t}return t}releaseAccessHandles(){for(const e of this.#r.keys())e.close();this.#r.clear(),this.#s.clear(),this.#i.clear()}async acquireAccessHandles(e){const t=[];for await(const[e,n]of this.#t)"file"===n.kind&&t.push([e,n]);return Promise.all(t.map((async([t,n])=>{try{const r=await n.createSyncAccessHandle();if(this.#r.set(r,t),e)r.truncate(l),this.setAssociatedPath(r,"",0);else{const e=this.getAssociatedPath(r);e?this.#s.set(e,r):this.#i.add(r)}}catch(e){throw this.storeErr(e),this.releaseAccessHandles(),e}})))}getAssociatedPath(e){e.read(this.#a,{at:0});const t=this.#l.getUint32(512);if(this.#a[0]&&(t&s.SQLITE_OPEN_DELETEONCLOSE||!(t&c)))return h(`Removing file with unexpected flags ${t.toString(16)}`,this.#a),this.setAssociatedPath(e,"",0),"";const n=new Uint32Array(2);e.read(n,{at:516});const r=this.computeDigest(this.#a);if(n.every(((e,t)=>e===r[t]))){const t=this.#a.findIndex((e=>0===e));return 0===t&&e.truncate(l),t?p.decode(this.#a.subarray(0,t)):""}return h("Disassociating file with bad digest."),this.setAssociatedPath(e,"",0),""}setAssociatedPath(e,n,r){const s=f.encodeInto(n,this.#a);a<=s.written+1&&t("Path too long:",n),this.#a.fill(0,s.written,a),this.#l.setUint32(512,r);const i=this.computeDigest(this.#a);e.write(this.#a,{at:0}),e.write(i,{at:516}),e.flush(),n?(this.#s.set(n,e),this.#i.delete(e)):(e.truncate(l),this.#i.add(e))}computeDigest(e){let t=3735928559,n=1103547991;for(const r of e)t=31*t+307*r,n=31*n+307*r;return new Uint32Array([t>>>0,n>>>0])}async reset(e){await this.isReady;let t,n=await navigator.storage.getDirectory();for(const e of this.vfsDir.split("/"))e&&(t=n,n=await n.getDirectoryHandle(e,{create:!0}));return this.#e=n,this.#n=t,this.#t=await this.#e.getDirectoryHandle(u,{create:!0}),this.releaseAccessHandles(),this.acquireAccessHandles(e)}getPath(e){return o.isPtr(e)&&(e=o.cstrToJs(e)),(e instanceof URL?e:new URL(e,"file://localhost/")).pathname}deletePath(e){const t=this.#s.get(e);return t&&(this.#s.delete(e),this.setAssociatedPath(t,"",0)),!!t}storeErr(e,t){return e&&(e.sqlite3Rc=t||s.SQLITE_IOERR,this.error(e)),this.$error=e,t}popErr(){const e=this.$error;return this.$error=void 0,e}nextAvailableSAH(){const[e]=this.#i.keys();return e}getOFileForS3File(e){return this.#o.get(e)}mapS3FileToOFile(e,t){t?(this.#o.set(e,t),v(e,this)):(this.#o.delete(e),v(e,!1))}hasFilename(e){return this.#s.has(e)}getSAHForPath(e){return this.#s.get(e)}async removeVfs(){if(!this.#c.pointer||!this.#t)return!1;s.sqlite3_vfs_unregister(this.#c.pointer),this.#c.dispose();try{this.releaseAccessHandles(),await this.#e.removeEntry(u,{recursive:!0}),this.#t=void 0,await this.#n.removeEntry(this.#e.name,{recursive:!0}),this.#e=this.#n=void 0}catch(t){e.config.error(this.vfsName,"removeVfs() failed:",t)}return!0}exportFile(e){const n=this.#s.get(e)||t("File not found:",e),r=n.getSize()-l,s=new Uint8Array(r>0?r:0);if(r>0){const e=n.read(s,{at:l});e!=r&&t("Expected to read "+r+" bytes but read "+e+".")}return s}async importDbChunked(e,n){const r=this.#s.get(e)||this.nextAvailableSAH()||t("No available handles to import to.");r.truncate(0);let o,a=0,c=!1;try{for(;void 0!==(o=await n());)o instanceof ArrayBuffer&&(o=new Uint8Array(o)),0===a&&o.byteLength>=15&&(i.affirmDbHeader(o),c=!0),r.write(o,{at:l+a}),a+=o.byteLength;if((a<512||0!=a%512)&&t("Input size",a,"is not correct for an SQLite database."),!c){const e=new Uint8Array(20);r.read(e,{at:0}),i.affirmDbHeader(e)}r.write(new Uint8Array([1,1]),{at:4114})}catch(e){throw this.setAssociatedPath(r,"",0),e}return this.setAssociatedPath(r,e,s.SQLITE_OPEN_MAIN_DB),a}importDb(e,n){if(n instanceof ArrayBuffer)n=new Uint8Array(n);else if(n instanceof Function)return this.importDbChunked(e,n);const r=this.#s.get(e)||this.nextAvailableSAH()||t("No available handles to import to."),i=n.byteLength;(i<512||i%512!=0)&&t("Byte array size is invalid for an SQLite db.");const o="SQLite format 3";for(let e=0;e<15;++e)o.charCodeAt(e)!==n[e]&&t("Input does not contain an SQLite database header.");const a=r.write(n,{at:l});return a!=i?(this.setAssociatedPath(r,"",0),t("Expected to write "+i+" bytes but wrote "+a+".")):(r.write(new Uint8Array([1,1]),{at:4114}),this.setAssociatedPath(r,e,s.SQLITE_OPEN_MAIN_DB)),a}}class I{#p;constructor(e){this.#p=e,this.vfsName=e.vfsName}async addCapacity(e){return this.#p.addCapacity(e)}async reduceCapacity(e){return this.#p.reduceCapacity(e)}getCapacity(){return this.#p.getCapacity(this.#p)}getFileCount(){return this.#p.getFileCount()}getFileNames(){return this.#p.getFileNames()}async reserveMinimumCapacity(e){const t=this.#p.getCapacity();return t<e?this.#p.addCapacity(e-t):t}exportFile(e){return this.#p.exportFile(e)}importDb(e,t){return this.#p.importDb(e,t)}async wipeFiles(){return this.#p.reset(!0)}unlink(e){return this.#p.deletePath(e)}async removeVfs(){return this.#p.removeVfs()}}e.installOpfsSAHPoolVfs=async function(n=Object.create(null)){const s=n.name||d.name;return r[s]?r[s]:globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&navigator?.storage?.getDirectory?r[s]=(async()=>{const e=await navigator.storage.getDirectory(),n=".opfs-sahpool-sync-check-"+_(),r=await e.getFileHandle(n,{create:!0}),s=(await r.createSyncAccessHandle()).close();return await s,await e.removeEntry(n),s?.then&&t("The local OPFS API is too old for opfs-sahpool:","it has an async FileSystemSyncAccessHandle.close() method."),!0})().then((async function(){if(n.$testThrowInInit)throw n.$testThrowInInit;const t=new A(n);return t.isReady.then((async()=>{const n=new I(t);if(e.oo1){const r=e.oo1,s=t.getVfs(),i=function(...e){const t=r.DB.dbCtorHelper.normalizeArgs(...e);t.vfs=s.$zName,r.DB.dbCtorHelper.call(this,t)};i.prototype=Object.create(r.DB.prototype),n.OpfsSAHPoolDb=i,r.DB.dbCtorHelper.setVfsPostOpenSql(s.pointer,(function(e,t){t.capi.sqlite3_exec(e,["pragma journal_mode=DELETE;","pragma cache_size=-16384;"],0,0,0)}))}return t.log("VFS initialized."),n})).catch((async e=>{throw await t.removeVfs().catch((()=>{})),e}))})).catch((e=>r[s]=Promise.reject(e))):r[s]=Promise.reject(new Error("Missing required OPFS APIs."))}})),void 0!==e){const t=Object.assign(Object.create(null),{exports:"undefined"==typeof wasmExports?e.asm:wasmExports,memory:e.wasmMemory},globalThis.sqlite3ApiConfig||{});let n;globalThis.sqlite3ApiConfig=t;try{n=globalThis.sqlite3ApiBootstrap()}catch(e){throw console.error("sqlite3ApiBootstrap() error:",e),e}finally{delete globalThis.sqlite3ApiBootstrap,delete globalThis.sqlite3ApiConfig}e.sqlite3=n}else console.warn("This is not running in an Emscripten module context, so","globalThis.sqlite3ApiBootstrap() is _not_ being called due to lack","of config info for the WASM environment.","It must be called manually.")})),s.ready});const n=function(){const e=t;if(!e)throw new Error("Expecting globalThis.sqlite3InitModule to be defined by the Emscripten build.");const n=globalThis.sqlite3InitModuleState=Object.assign(Object.create(null),{moduleScript:globalThis?.document?.currentScript,isWorker:"undefined"!=typeof WorkerGlobalScope,location:globalThis.location,urlParams:globalThis?.location?.href?new URL(globalThis.location.href).searchParams:new URLSearchParams});if(n.debugModule=n.urlParams.has("sqlite3.debugModule")?(...e)=>console.warn("sqlite3.debugModule:",...e):()=>{},n.urlParams.has("sqlite3.dir"))n.sqlite3Dir=n.urlParams.get("sqlite3.dir")+"/";else if(n.moduleScript){const e=n.moduleScript.src.split("/");e.pop(),n.sqlite3Dir=e.join("/")+"/"}if(globalThis.sqlite3InitModule=function t(...r){return e(...r).then((e=>{const r=e.sqlite3;r.scriptInfo=n,t.__isUnderTest&&(r.__isUnderTest=!0);const s=r.asyncPostInit;return delete r.asyncPostInit,s()})).catch((e=>{throw console.error("Exception loading sqlite3 module:",e),e}))},globalThis.sqlite3InitModule.ready=e.ready,globalThis.sqlite3InitModuleState.moduleScript){const e=globalThis.sqlite3InitModuleState;let t=e.moduleScript.src.split("/");t.pop(),e.scriptDir=t.join("/")+"/"}return n.debugModule("sqlite3InitModuleState =",n),globalThis.sqlite3InitModule}();t=n;const r=console.log,s=console.error;class i extends Error{constructor(e,t){super(e),this.code=t}}class o{#f;#d;constructor(e){if(void 0===e)throw new Error("`sqliteObject` must be defined before calling constructor");this.sqlite3=e}static async init_module(e){return await t({print:r,printErr:s,...e})}version(){return this.sqlite3.version}filename(e,t){return this.sqlite3.capi.sqlite3_db_filename(e,t)}extended_errcode(e){return this.sqlite3.capi.sqlite3_extended_errcode(e)}errstr(e){return this.sqlite3.capi.sqlite3_errstr(e)}errmsg(e){return this.sqlite3.capi.sqlite3_errmsg(e)}result_js(e,t){return this.sqlite3.capi.sqlite3_result_js(e,t)}result_text(e,t){return this.sqlite3.capi.sqlite3_result_text(e,t)}result_int(e,t){return this.sqlite3.capi.sqlite3_result_int(e,t)}result_int64(e,t){return this.sqlite3.capi.sqlite3_result_int64(e,t)}result_double(e,t){return this.sqlite3.capi.sqlite3_result_double(e,t)}result_blob(e,t){return this.sqlite3.capi.sqlite3_result_blob(e,t)}result_null(e){return this.sqlite3.capi.sqlite3_result_null(e)}bind_blob(e,t,n,r,s){return this.sqlite3.capi.sqlite3_bind_blob(e,t,n,r,s)}bind_text(e,t,n,r,s){return this.sqlite3.capi.sqlite3_bind_text(e,t,n,r,s)}bind_double(e,t,n){return this.sqlite3.capi.sqlite3_bind_double(e,t,n)}bind_int(e,t,n){return this.sqlite3.capi.sqlite3_bind_int(e,t,n)}bind_int64(e,t,n){return this.sqlite3.capi.sqlite3_bind_int64(e,t,n)}bind_null(e,t){return this.sqlite3.capi.sqlite3_bind_null(e,t),this.sqlite3.capi.SQLITE_OK}bind_parameter_count(e){return this.sqlite3.capi.sqlite3_bind_parameter_count(e)}bind_parameter_name(e,t){return this.sqlite3.capi.sqlite3_bind_paramater_name(e,it)}value_dup(e){return this.sqlite3.capi.sqlite3_value_dup(e)}value_blob(e){return this.sqlite3.capi.sqlite3_value_blob(e)}value_bytes(e){return this.sqlite3.capi.sqlite3_value_bytes(e)}value_double(e){return this.sqlite3.capi.sqlite3_value_double(e)}value_int(e){return this.sqlite3.capi.sqlite3_value_int(e)}value_int64(e){return this.sqlite3.capi.sqlite3_value_int64(e)}value_text(e){return this.sqlite3.capi.sqlite3_value_text(e)}value_type(e){return this.sqlite3.capi.sqlite3_value_type(e)}open(e,t){try{return new this.sqlite3.oo1.OpfsDb(e)}catch(e){throw console.log("OPFS open error",e),e}}exec(e,t){try{return e.exec(t,{callback:e=>{}})}catch(e){throw e}}finalize(e){return this.sqlite3.capi.sqlite3_finalize(e)}changes(e){return this.sqlite3.capi.sqlite3_changes(e)}clear_bindings(e){return this.sqlite3.capi.sqlite3_clear_bindings(e)}reset(e){return this.sqlite3.capi.sqlite3_reset(e)}close(e){return this.sqlite3.capi.sqlite3_close_v2(e.pointer)}db_handle(e){return this.sqlite3.capi.sqlite3_db_handle(e)}prepare_v3(e,t,n,r,s,i){return this.sqlite3.capi.sqlite3_prepare_v3(e.pointer,t,n,r,s,i)}step(e){return this.sqlite3.capi.sqlite3_step(e)}column_value(e,t){return this.sqlite3.capi.sqlite3_column_value(e,t)}column_name(e,t){return this.sqlite3.capi.sqlite3_column_name(e,t)}column_count(e){return this.sqlite3.capi.sqlite3_column_count(e)}create_function(e,t,n,r,s,i,o,a){try{this.sqlite3.capi.sqlite3_create_function(e,t,n,r,s,i,o,a),console.log("create function")}catch(e){throw console.log("create function err"),e}}register_diesel_sql_functions(e){try{this.sqlite3.capi.sqlite3_create_function(e,"diesel_manage_updated_at",1,this.sqlite3.capi.SQLITE_UTF8,0,(async(t,n)=>{const s=this.sqlite3.value_text(n[0]);e.exec(t,`CREATE TRIGGER __diesel_manage_updated_at_${s}\n AFTER UPDATE ON ${s}\n FOR EACH ROW WHEN\n old.updated_at IS NULL AND\n new.updated_at IS NULL OR\n old.updated_at == new.updated_at\n BEGIN\n UPDATE ${s}\n SET updated_at = CURRENT_TIMESTAMP\n WHERE ROWID = new.ROWID;\n END`,(e=>{r("------------------------------------"),r(`Created trigger for ${s}`),r(e),r("------------------------------------")}))}))}catch(e){throw console.log("error creating diesel trigger"),e}}value_free(e){return this.sqlite3.capi.sqlite3_value_free(e)}sqlite3_serialize(e,t,n,r){try{return this.sqlite3.capi.sqlite3_serialize(e,t,n,r)}catch(e){throw console.log("error serializing"),e}}sqlite3_deserialize(e,t,n,r,s,i){try{return this.sqlite3.capi.sqlite3_deserialize(e,t,n,r,s,i)}catch(e){throw console.log("error deserializing"),e}}sqlite3_free(e,t){return this.sqlite3.capi.sqlite3_free(t)}}export{o as SQLite,i as SQLiteError};
@@ -1 +0,0 @@
1
- const e=(e,...t)=>postMessage({type:e,payload:t}),t=function(){const t=function(...e){throw new Error(e.join(" "))};globalThis.window===globalThis?t("This code cannot run from the main thread.","Load it as a Worker from a separate Worker."):navigator?.storage?.getDirectory||t("This API requires navigator.storage.getDirectory.");const n=Object.create(null);n.verbose=1;const s={0:console.error.bind(console),1:console.warn.bind(console),2:console.log.bind(console)},a=(e,...t)=>{n.verbose>e&&s[e]("OPFS asyncer:",...t)},i=(...e)=>a(2,...e),o=(...e)=>a(1,...e),r=(...e)=>a(0,...e),c=Object.create(null),l=new Set,d=function(e,t){const n=new URL(e,"file://irrelevant").pathname;return t?n.split("/").filter((e=>!!e)):n},f=async function(e,t=!1){const s=d(e,!0),a=s.pop();let i=n.rootDir;for(const e of s)e&&(i=await i.getDirectoryHandle(e,{create:!!t}));return[i,a]},y=async e=>{if(e.syncHandle){i("Closing sync handle for",e.filenameAbs);const t=e.syncHandle;return delete e.syncHandle,delete e.xLock,l.delete(e.fid),t.close()}},u=async e=>{try{await y(e)}catch(t){o("closeSyncHandleNoThrow() ignoring:",t,e)}},E=async()=>{if(l.size)for(const e of l){const t=c[e];await u(t),i("Auto-unlocked",e,t.filenameAbs)}},b=async e=>{if(e.releaseImplicitLocks&&l.has(e.fid))return u(e)};class O extends Error{constructor(e,...t){super([...t,": "+e.name+":",e.message].join(" "),{cause:e}),this.name="GetSyncHandleError"}}O.convertRc=(e,t)=>{if(e instanceof O){if("NoModificationAllowedError"===e.cause.name||"DOMException"===e.cause.name&&0===e.cause.message.indexOf("Access Handles cannot"))return n.sq3Codes.SQLITE_BUSY;if("NotFoundError"===e.cause.name)return n.sq3Codes.SQLITE_CANTOPEN}else if("NotFoundError"===e?.name)return n.sq3Codes.SQLITE_CANTOPEN;return t};const g=async(e,t)=>{if(!e.syncHandle){const s=performance.now();i("Acquiring sync handle for",e.filenameAbs);const a=6,r=2*n.asyncIdleWaitTime;let c=1,d=r;for(;;d=r*++c)try{e.syncHandle=await e.fileHandle.createSyncAccessHandle();break}catch(s){if(c===a)throw new O(s,"Error getting sync handle for",t+"().",a,"attempts failed.",e.filenameAbs);o("Error getting sync handle for",t+"(). Waiting",d,"ms and trying again.",e.filenameAbs,s),Atomics.wait(n.sabOPView,n.opIds.retry,0,d)}i("Got",t+"() sync handle for",e.filenameAbs,"in",performance.now()-s,"ms"),e.xLock||(l.add(e.fid),i("Acquired implicit lock for",t+"()",e.fid,e.filenameAbs))}return e.syncHandle},h=(e,t)=>{i(e+"() => notify(",t,")"),Atomics.store(n.sabOPView,n.opIds.rc,t),Atomics.notify(n.sabOPView,n.opIds.rc)},w=function(e,n){n.readOnly&&t(e+"(): File is read-only: "+n.filenameAbs)};let p=!1;const I={"opfs-async-shutdown":async()=>{p=!0,h("opfs-async-shutdown",0)},mkdir:async e=>{let t=0;try{await f(e+"/filepart",!0)}catch(e){n.s11n.storeException(2,e),t=n.sq3Codes.SQLITE_IOERR}h("mkdir",t)},xAccess:async e=>{let t=0;try{const[t,n]=await f(e);await t.getFileHandle(n)}catch(e){n.s11n.storeException(2,e),t=n.sq3Codes.SQLITE_IOERR}h("xAccess",t)},xClose:async function(e){l.delete(e);const t=c[e];let s=0;if(t){if(delete c[e],await y(t),t.deleteOnClose)try{await t.dirHandle.removeEntry(t.filenamePart)}catch(e){o("Ignoring dirHandle.removeEntry() failure of",t,e)}}else n.s11n.serialize(),s=n.sq3Codes.SQLITE_NOTFOUND;h("xClose",s)},xDelete:async function(...e){const t=await I.xDeleteNoWait(...e);h("xDelete",t)},xDeleteNoWait:async function(e,t=0,s=!1){let a=0;try{for(;e;){const[n,a]=await f(e,!1);if(!a)break;if(await n.removeEntry(a,{recursive:s}),4660!==t)break;s=!1,(e=d(e,!0)).pop(),e=e.join("/")}}catch(e){n.s11n.storeException(2,e),a=n.sq3Codes.SQLITE_IOERR_DELETE}return a},xFileSize:async function(e){const t=c[e];let s=0;try{const e=await(await g(t,"xFileSize")).getSize();n.s11n.serialize(Number(e))}catch(e){n.s11n.storeException(1,e),s=O.convertRc(e,n.sq3Codes.SQLITE_IOERR)}await b(t),h("xFileSize",s)},xLock:async function(e,t){const s=c[e];let a=0;const i=s.xLock;if(s.xLock=t,!s.syncHandle)try{await g(s,"xLock"),l.delete(e)}catch(e){n.s11n.storeException(1,e),a=O.convertRc(e,n.sq3Codes.SQLITE_IOERR_LOCK),s.xLock=i}h("xLock",a)},xOpen:async function(e,t,s,a){const i="xOpen",o=n.sq3Codes.SQLITE_OPEN_CREATE&s;try{let r,l;try{[r,l]=await f(t,!!o)}catch(e){return n.s11n.storeException(1,e),void h(i,n.sq3Codes.SQLITE_NOTFOUND)}if(n.opfsFlags.OPFS_UNLINK_BEFORE_OPEN&a)try{await r.removeEntry(l)}catch(e){}const d=await r.getFileHandle(l,{create:o}),y=Object.assign(Object.create(null),{fid:e,filenameAbs:t,filenamePart:l,dirHandle:r,fileHandle:d,sabView:n.sabFileBufView,readOnly:!o&&n.sq3Codes.SQLITE_OPEN_READONLY&s,deleteOnClose:!!(n.sq3Codes.SQLITE_OPEN_DELETEONCLOSE&s)});y.releaseImplicitLocks=a&n.opfsFlags.OPFS_UNLOCK_ASAP||n.opfsFlags.defaultUnlockAsap,c[e]=y,h(i,0)}catch(e){r(i,e),n.s11n.storeException(1,e),h(i,n.sq3Codes.SQLITE_IOERR)}},xRead:async function(e,t,s){let a,i=0;const o=c[e];try{a=(await g(o,"xRead")).read(o.sabView.subarray(0,t),{at:Number(s)}),a<t&&(o.sabView.fill(0,a,t),i=n.sq3Codes.SQLITE_IOERR_SHORT_READ)}catch(e){r("xRead() failed",e,o),n.s11n.storeException(1,e),i=O.convertRc(e,n.sq3Codes.SQLITE_IOERR_READ)}await b(o),h("xRead",i)},xSync:async function(e,t){const s=c[e];let a=0;if(!s.readOnly&&s.syncHandle)try{await s.syncHandle.flush()}catch(e){n.s11n.storeException(2,e),a=n.sq3Codes.SQLITE_IOERR_FSYNC}h("xSync",a)},xTruncate:async function(e,t){let s=0;const a=c[e];try{w("xTruncate",a),await(await g(a,"xTruncate")).truncate(t)}catch(e){r("xTruncate():",e,a),n.s11n.storeException(2,e),s=O.convertRc(e,n.sq3Codes.SQLITE_IOERR_TRUNCATE)}await b(a),h("xTruncate",s)},xUnlock:async function(e,t){let s=0;const a=c[e];if(n.sq3Codes.SQLITE_LOCK_NONE===t&&a.syncHandle)try{await y(a)}catch(e){n.s11n.storeException(1,e),s=n.sq3Codes.SQLITE_IOERR_UNLOCK}h("xUnlock",s)},xWrite:async function(e,t,s){let a;const i=c[e];try{w("xWrite",i),a=t===(await g(i,"xWrite")).write(i.sabView.subarray(0,t),{at:Number(s)})?0:n.sq3Codes.SQLITE_IOERR_WRITE}catch(e){r("xWrite():",e,i),n.s11n.storeException(1,e),a=O.convertRc(e,n.sq3Codes.SQLITE_IOERR_WRITE)}await b(i),h("xWrite",a)}},m=async function(){const e=Object.create(null);for(let t of Object.keys(n.opIds)){const s=I[t];if(!s)continue;const a=Object.create(null);e[n.opIds[t]]=a,a.key=t,a.f=s}for(;!p;)try{if("not-equal"!==Atomics.wait(n.sabOPView,n.opIds.whichOp,0,n.asyncIdleWaitTime)){await E();continue}const s=Atomics.load(n.sabOPView,n.opIds.whichOp);Atomics.store(n.sabOPView,n.opIds.whichOp,0);const a=e[s]??t("No waitLoop handler for whichOp #",s),i=n.s11n.deserialize(!0)||[];a.f?await a.f(...i):r("Missing callback for opId",s)}catch(e){r("in waitLoop():",e)}};navigator.storage.getDirectory().then((function(s){n.rootDir=s,globalThis.onmessage=function({data:s}){switch(s.type){case"opfs-async-init":{const a=s.args;for(const e in a)n[e]=a[e];n.verbose=a.verbose??1,n.sabOPView=new Int32Array(n.sabOP),n.sabFileBufView=new Uint8Array(n.sabIO,0,n.fileBufferSize),n.sabS11nView=new Uint8Array(n.sabIO,n.sabS11nOffset,n.sabS11nSize),Object.keys(I).forEach((e=>{Number.isFinite(n.opIds[e])||t("Maintenance required: missing state.opIds[",e,"]")})),(()=>{if(n.s11n)return n.s11n;const e=new TextDecoder,s=new TextEncoder("utf-8"),a=new Uint8Array(n.sabIO,n.sabS11nOffset,n.sabS11nSize),i=new DataView(n.sabIO,n.sabS11nOffset,n.sabS11nSize);n.s11n=Object.create(null);const o=Object.create(null);o.number={id:1,size:8,getter:"getFloat64",setter:"setFloat64"},o.bigint={id:2,size:8,getter:"getBigInt64",setter:"setBigInt64"},o.boolean={id:3,size:4,getter:"getInt32",setter:"setInt32"},o.string={id:4};const r=e=>{switch(e){case o.number.id:return o.number;case o.bigint.id:return o.bigint;case o.boolean.id:return o.boolean;case o.string.id:return o.string;default:t("Invalid type ID:",e)}};n.s11n.deserialize=function(t=!1){const s=a[0],o=s?[]:null;if(s){const t=[];let c,l,d,f=1;for(c=0;c<s;++c,++f)t.push(r(a[f]));for(c=0;c<s;++c){const s=t[c];s.getter?(d=i[s.getter](f,n.littleEndian),f+=s.size):(l=i.getInt32(f,n.littleEndian),f+=4,d=e.decode(a.slice(f,f+l)),f+=l),o.push(d)}}return t&&(a[0]=0),o},n.s11n.serialize=function(...e){if(e.length){const c=[];let l=0,d=1;for(a[0]=255&e.length;l<e.length;++l,++d)c.push((r=e[l],o[typeof r]||t("Maintenance required: this value type cannot be serialized.",r))),a[d]=c[l].id;for(l=0;l<e.length;++l){const t=c[l];if(t.setter)i[t.setter](d,e[l],n.littleEndian),d+=t.size;else{const t=s.encode(e[l]);i.setInt32(d,t.byteLength,n.littleEndian),d+=4,a.set(t,d),d+=t.byteLength}}}else a[0]=0;var r},n.s11n.storeException=n.asyncS11nExceptions?(e,t)=>{e<=n.asyncS11nExceptions&&n.s11n.serialize([t.name,": ",t.message].join(""))}:()=>{},n.s11n})(),i("init state",n),e("opfs-async-inited"),m();break}case"opfs-async-restart":p&&(o("Restarting after opfs-async-shutdown. Might or might not work."),p=!1,m())}},e("opfs-async-loaded")})).catch((e=>r("error initializing OPFS asyncer:",e)))};globalThis.SharedArrayBuffer?globalThis.Atomics?globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&navigator?.storage?.getDirectory?t():e("opfs-unavailable","Missing required OPFS APIs."):e("opfs-unavailable","Missing Atomics API.","The server must emit the COOP/COEP response headers to enable that."):e("opfs-unavailable","Missing SharedArrayBuffer API.","The server must emit the COOP/COEP response headers to enable that.");