(function(){"use strict";async function bt(He={}){var Ee,f=He,je=!!globalThis.window,Ve=!!globalThis.WorkerGlobalScope;globalThis.process?.versions?.node&&globalThis.process?.type,(function(e){const t=globalThis.sqlite3InitModuleState||Object.assign(Object.create(null),{debugModule:function(){console.warn("globalThis.sqlite3InitModuleState is missing",arguments)}});delete globalThis.sqlite3InitModuleState,t.debugModule("pre-js.js sqlite3InitModuleState =",t),e.locateFile=(function(l,i){return this.emscriptenLocateFile instanceof Function?this.emscriptenLocateFile(l,i):new URL(l,self.location.href).href}).bind(t),e.instantiateWasm=(function(i,n){if(this.emscriptenInstantiateWasm instanceof Function)return this.emscriptenInstantiateWasm(i,n);const r=this,s=e.locateFile(r.wasmFilename,typeof rt>"u"?"":rt);r.debugModule("instantiateWasm() uri =",s,"sIMS =",this);const _=()=>fetch(s,{credentials:"same-origin"}),c=m=>{m.imports=i,r.instantiateWasm=m,n(m.instance,m.module)};return(WebAssembly.instantiateStreaming?async()=>WebAssembly.instantiateStreaming(_(),i).then(c):async()=>_().then(m=>m.arrayBuffer()).then(m=>WebAssembly.instantiate(m,i)).then(c))()}).bind(t)})(f);var ze="./this.program",_t=self.location.href,rt="";function Yt(e){return f.locateFile?f.locateFile(e,rt):rt+e}var yt,ft;if(je||Ve){try{rt=new URL(".",_t).href}catch{}Ve&&(ft=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),yt=async e=>{var t=await fetch(e,{credentials:"same-origin"});if(t.ok)return t.arrayBuffer();throw new Error(t.status+" : "+t.url)}}var dt=console.log.bind(console),We=console.error.bind(console),it,It=!1,Tt,kt,Ot=!1;function xt(){var e=Qe.buffer;Ne=new Int8Array(e),st=new Int16Array(e),Ge=new Uint8Array(e),qe=new Int32Array(e),we=new Uint32Array(e),xe=new BigInt64Array(e),new BigUint64Array(e)}function Zt(){if(f.wasmMemory)Qe=f.wasmMemory;else{var e=f.INITIAL_MEMORY||8388608;Qe=new WebAssembly.Memory({initial:e/65536,maximum:32768})}xt()}function en(){if(f.preRun)for(typeof f.preRun=="function"&&(f.preRun=[f.preRun]);f.preRun.length;)fn(f.preRun.shift());Ft(Lt)}function tn(){Ot=!0,!f.noFSInit&&!a.initialized&&a.init(),tt.__wasm_call_ctors(),a.ignorePermissions=!1}function nn(){if(f.postRun)for(typeof f.postRun=="function"&&(f.postRun=[f.postRun]);f.postRun.length;)_n(f.postRun.shift());Ft(Pt)}function Be(e){f.onAbort?.(e),e=`Aborted(${e})`,We(e),It=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw kt?.(t),t}var qt;function rn(){return f.locateFile?Yt("sqlite3.wasm"):new URL("/assets/sqlite3-BVKGSWc-.wasm",self.location.href).href}function sn(e){if(e==qt&&it)return new Uint8Array(it);if(ft)return ft(e);throw"both async and sync fetching of the wasm failed"}async function on(e){if(!it)try{var t=await yt(e);return new Uint8Array(t)}catch{}return sn(e)}async function ln(e,t){try{var l=await on(e);return await WebAssembly.instantiate(l,t)}catch(i){We(`failed to asynchronously prepare wasm: ${i}`),Be(i)}}async function an(e,t,l){if(!e)try{var i=fetch(t,{credentials:"same-origin"});return await WebAssembly.instantiateStreaming(i,l)}catch(n){We(`wasm streaming compile failed: ${n}`),We("falling back to ArrayBuffer instantiation")}return ln(t,l)}function cn(){return{env:$t,wasi_snapshot_preview1:$t}}async function un(){function e(i,n){return tt=i.exports,pr(tt),tt}function t(i){return e(i.instance)}var l=cn();return f.instantiateWasm?new Promise((i,n)=>{f.instantiateWasm(l,(r,s)=>{i(e(r))})}):(qt??=rn(),t(await an(it,qt,l)))}var st,qe,xe,Ne,we,Ge,Ft=e=>{for(;e.length>0;)e.shift()(f)},Pt=[],_n=e=>Pt.push(e),Lt=[],fn=e=>Lt.push(e),Qe,ve={isAbs:e=>e.charAt(0)==="/",splitPath:e=>/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1),normalizeArray:(e,t)=>{for(var l=0,i=e.length-1;i>=0;i--){var n=e[i];n==="."?e.splice(i,1):n===".."?(e.splice(i,1),l++):l&&(e.splice(i,1),l--)}if(t)for(;l;l--)e.unshift("..");return e},normalize:e=>{var t=ve.isAbs(e),l=e.slice(-1)==="/";return e=ve.normalizeArray(e.split("/").filter(i=>!!i),!t).join("/"),!e&&!t&&(e="."),e&&l&&(e+="/"),(t?"/":"")+e},dirname:e=>{var t=ve.splitPath(e),l=t[0],i=t[1];return!l&&!i?".":(i&&(i=i.slice(0,-1)),l+i)},basename:e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>ve.normalize(e.join("/")),join2:(e,t)=>ve.normalize(e+"/"+t)},dn=()=>e=>(crypto.getRandomValues(e),0),Ct=e=>(Ct=dn())(e),Ze={resolve:(...e)=>{for(var t="",l=!1,i=e.length-1;i>=-1&&!l;i--){var n=i>=0?e[i]:a.cwd();if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)return"";t=n+"/"+t,l=ve.isAbs(n)}return t=ve.normalizeArray(t.split("/").filter(r=>!!r),!l).join("/"),(l?"/":"")+t||"."},relative:(e,t)=>{e=Ze.resolve(e).slice(1),t=Ze.resolve(t).slice(1);function l(m){for(var M=0;M=0&&m[I]==="";I--);return M>I?[]:m.slice(M,I-M+1)}for(var i=l(e.split("/")),n=l(t.split("/")),r=Math.min(i.length,n.length),s=r,_=0;_{for(var n=t+l;e[t]&&!(t>=n);)++t;return t},ot=(e,t=0,l,i)=>{var n=Rt(e,t,l);return Nt.decode(e.buffer?e.subarray(t,n):new Uint8Array(e.slice(t,n)))},vt=[],pt=e=>{for(var t=0,l=0;l=55296&&i<=57343?(t+=4,++l):t+=3}return t},Dt=(e,t,l,i)=>{if(!(i>0))return 0;for(var n=l,r=l+i-1,s=0;s=r)break;t[l++]=_}else if(_<=2047){if(l+1>=r)break;t[l++]=192|_>>6,t[l++]=128|_&63}else if(_<=65535){if(l+2>=r)break;t[l++]=224|_>>12,t[l++]=128|_>>6&63,t[l++]=128|_&63}else{if(l+3>=r)break;t[l++]=240|_>>18,t[l++]=128|_>>12&63,t[l++]=128|_>>6&63,t[l++]=128|_&63,s++}}return t[l]=0,l-n},St=(e,t,l)=>{var i=pt(e)+1,n=new Array(i),r=Dt(e,n,0,n.length);return n.length=r,n},pn=()=>{if(!vt.length){var e=null;if(globalThis.window?.prompt&&(e=window.prompt("Input: "),e!==null&&(e+=` `)),!e)return null;vt=St(e)}return vt.shift()},$e={ttys:[],init(){},shutdown(){},register(e,t){$e.ttys[e]={input:[],output:[],ops:t},a.registerDevice(e,$e.stream_ops)},stream_ops:{open(e){var t=$e.ttys[e.node.rdev];if(!t)throw new a.ErrnoError(43);e.tty=t,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,t,l,i,n){if(!e.tty||!e.tty.ops.get_char)throw new a.ErrnoError(60);for(var r=0,s=0;s0&&(dt(ot(e.output)),e.output=[])},ioctl_tcgets(e){return{c_iflag:25856,c_oflag:5,c_cflag:191,c_lflag:35387,c_cc:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ioctl_tcsets(e,t,l){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,t){t===null||t===10?(We(ot(e.output)),e.output=[]):t!=0&&e.output.push(t)},fsync(e){e.output?.length>0&&(We(ot(e.output)),e.output=[])}}},hn=(e,t)=>Ge.fill(0,e,e+t),jt=(e,t)=>Math.ceil(e/t)*t,Mt=e=>{e=jt(e,65536);var t=Gt(65536,e);return t&&hn(t,e),t},de={ops_table:null,mount(e){return de.createNode(null,"/",16895,0)},createNode(e,t,l,i){if(a.isBlkdev(l)||a.isFIFO(l))throw new a.ErrnoError(63);de.ops_table||={dir:{node:{getattr:de.node_ops.getattr,setattr:de.node_ops.setattr,lookup:de.node_ops.lookup,mknod:de.node_ops.mknod,rename:de.node_ops.rename,unlink:de.node_ops.unlink,rmdir:de.node_ops.rmdir,readdir:de.node_ops.readdir,symlink:de.node_ops.symlink},stream:{llseek:de.stream_ops.llseek}},file:{node:{getattr:de.node_ops.getattr,setattr:de.node_ops.setattr},stream:{llseek:de.stream_ops.llseek,read:de.stream_ops.read,write:de.stream_ops.write,mmap:de.stream_ops.mmap,msync:de.stream_ops.msync}},link:{node:{getattr:de.node_ops.getattr,setattr:de.node_ops.setattr,readlink:de.node_ops.readlink},stream:{}},chrdev:{node:{getattr:de.node_ops.getattr,setattr:de.node_ops.setattr},stream:a.chrdev_stream_ops}};var n=a.createNode(e,t,l,i);return a.isDir(n.mode)?(n.node_ops=de.ops_table.dir.node,n.stream_ops=de.ops_table.dir.stream,n.contents={}):a.isFile(n.mode)?(n.node_ops=de.ops_table.file.node,n.stream_ops=de.ops_table.file.stream,n.usedBytes=0,n.contents=de.emptyFileContents??=new Uint8Array(0)):a.isLink(n.mode)?(n.node_ops=de.ops_table.link.node,n.stream_ops=de.ops_table.link.stream):a.isChrdev(n.mode)&&(n.node_ops=de.ops_table.chrdev.node,n.stream_ops=de.ops_table.chrdev.stream),n.atime=n.mtime=n.ctime=Date.now(),e&&(e.contents[t]=n,e.atime=e.mtime=e.ctime=n.atime),n},getFileDataAsTypedArray(e){return e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,t){var l=e.contents.length;if(!(l>=t)){t=Math.max(t,l*(l<1024*1024?2:1.125)>>>0),l&&(t=Math.max(t,256));var i=de.getFileDataAsTypedArray(e);e.contents=new Uint8Array(t),e.contents.set(i)}},resizeFileStorage(e,t){if(e.usedBytes!=t){var l=e.contents;e.contents=new Uint8Array(t),e.contents.set(l.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr(e){var t={};return t.dev=a.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,a.isDir(e.mode)?t.size=4096:a.isFile(e.mode)?t.size=e.usedBytes:a.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.atime),t.mtime=new Date(e.mtime),t.ctime=new Date(e.ctime),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr(e,t){for(const l of["mode","atime","mtime","ctime"])t[l]!=null&&(e[l]=t[l]);t.size!==void 0&&de.resizeFileStorage(e,t.size)},lookup(e,t){throw de.doesNotExistError||(de.doesNotExistError=new a.ErrnoError(44),de.doesNotExistError.stack=""),de.doesNotExistError},mknod(e,t,l,i){return de.createNode(e,t,l,i)},rename(e,t,l){var i;try{i=a.lookupNode(t,l)}catch{}if(i){if(a.isDir(e.mode))for(var n in i.contents)throw new a.ErrnoError(55);a.hashRemoveNode(i)}delete e.parent.contents[e.name],t.contents[l]=e,e.name=l,t.ctime=t.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,t){delete e.contents[t],e.ctime=e.mtime=Date.now()},rmdir(e,t){for(var l in a.lookupNode(e,t).contents)throw new a.ErrnoError(55);delete e.contents[t],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,t,l){var i=de.createNode(e,t,41471,0);return i.link=l,i},readlink(e){if(!a.isLink(e.mode))throw new a.ErrnoError(28);return e.link}},stream_ops:{read(e,t,l,i,n){var r=e.node.contents;if(n>=e.node.usedBytes)return 0;var s=Math.min(e.node.usedBytes-n,i);return t.set(r.subarray(n,n+s),l),s},write(e,t,l,i,n,r){if(t.buffer===Ne.buffer&&(r=!1),!i)return 0;var s=e.node;return s.mtime=s.ctime=Date.now(),r?(s.contents=t.subarray(l,l+i),s.usedBytes=i):s.usedBytes===0&&n===0?(s.contents=t.slice(l,l+i),s.usedBytes=i):(de.expandFileStorage(s,n+i),s.contents.set(t.subarray(l,l+i),n),s.usedBytes=Math.max(s.usedBytes,n+i)),i},llseek(e,t,l){var i=t;if(l===1?i+=e.position:l===2&&a.isFile(e.node.mode)&&(i+=e.node.usedBytes),i<0)throw new a.ErrnoError(28);return i},mmap(e,t,l,i,n){if(!a.isFile(e.node.mode))throw new a.ErrnoError(43);var r,s,_=e.node.contents;if(!(n&2)&&_.buffer===Ne.buffer)s=!1,r=_.byteOffset;else{if(s=!0,r=Mt(t),!r)throw new a.ErrnoError(48);_&&((l>0||l+t<_.length)&&(_.subarray?_=_.subarray(l,l+t):_=Array.prototype.slice.call(_,l,l+t)),Ne.set(_,r))}return{ptr:r,allocated:s}},msync(e,t,l,i,n){return de.stream_ops.write(e,t,0,i,l,!1),0}}},mn=e=>{if(typeof e!="string")return e;var t={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[e];if(typeof t>"u")throw new Error(`Unknown file open mode: ${e}`);return t},zt=e=>(typeof e=="string"&&(e=St(e)),e.subarray||(e=new Uint8Array(e)),e),wt=(e,t)=>{var l=0;return e&&(l|=365),t&&(l|=146),l},gn=async e=>{var t=await yt(e);return new Uint8Array(t)},bn=(...e)=>a.createDataFile(...e),Ke=0,lt=null,yn=e=>{if(Ke--,f.monitorRunDependencies?.(Ke),Ke==0&<){var t=lt;lt=null,t()}},qn=e=>{Ke++,f.monitorRunDependencies?.(Ke)},Bt=[],vn=async(e,t)=>{typeof Browser<"u"&&Browser.init();for(var l of Bt)if(l.canHandle(t))return l.handle(e,t);return e},Qt=async(e,t,l,i,n,r,s,_)=>{var c=t?Ze.resolve(ve.join2(e,t)):e;qn();try{var m=l;typeof l=="string"&&(m=await gn(l)),m=await vn(m,c),_?.(),r||bn(e,t,m,i,n,s)}finally{yn()}},Sn=(e,t,l,i,n,r,s,_,c,m)=>{Qt(e,t,l,i,n,_,c,m).then(r).catch(s)},a={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,filesystems:null,syncFSRequests:0,ErrnoError:class{name="ErrnoError";constructor(e){this.errno=e}},FSStream:class{shared={};get object(){return this.node}set object(e){this.node=e}get isRead(){return(this.flags&2097155)!==1}get isWrite(){return(this.flags&2097155)!==0}get isAppend(){return this.flags&1024}get flags(){return this.shared.flags}set flags(e){this.shared.flags=e}get position(){return this.shared.position}set position(e){this.shared.position=e}},FSNode:class{node_ops={};stream_ops={};readMode=365;writeMode=146;mounted=null;constructor(e,t,l,i){e||(e=this),this.parent=e,this.mount=e.mount,this.id=a.nextInode++,this.name=t,this.mode=l,this.rdev=i,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&this.readMode)===this.readMode}set read(e){e?this.mode|=this.readMode:this.mode&=~this.readMode}get write(){return(this.mode&this.writeMode)===this.writeMode}set write(e){e?this.mode|=this.writeMode:this.mode&=~this.writeMode}get isFolder(){return a.isDir(this.mode)}get isDevice(){return a.isChrdev(this.mode)}},lookupPath(e,t={}){if(!e)throw new a.ErrnoError(44);t.follow_mount??=!0,ve.isAbs(e)||(e=a.cwd()+"/"+e);e:for(var l=0;l<40;l++){for(var i=e.split("/").filter(m=>!!m),n=a.root,r="/",s=0;s>>0)%a.nameTable.length},hashAddNode(e){var t=a.hashName(e.parent.id,e.name);e.name_next=a.nameTable[t],a.nameTable[t]=e},hashRemoveNode(e){var t=a.hashName(e.parent.id,e.name);if(a.nameTable[t]===e)a.nameTable[t]=e.name_next;else for(var l=a.nameTable[t];l;){if(l.name_next===e){l.name_next=e.name_next;break}l=l.name_next}},lookupNode(e,t){var l=a.mayLookup(e);if(l)throw new a.ErrnoError(l);for(var i=a.hashName(e.id,t),n=a.nameTable[i];n;n=n.name_next){var r=n.name;if(n.parent.id===e.id&&r===t)return n}return a.lookup(e,t)},createNode(e,t,l,i){var n=new a.FSNode(e,t,l,i);return a.hashAddNode(n),n},destroyNode(e){a.hashRemoveNode(e)},isRoot(e){return e===e.parent},isMountpoint(e){return!!e.mounted},isFile(e){return(e&61440)===32768},isDir(e){return(e&61440)===16384},isLink(e){return(e&61440)===40960},isChrdev(e){return(e&61440)===8192},isBlkdev(e){return(e&61440)===24576},isFIFO(e){return(e&61440)===4096},isSocket(e){return(e&49152)===49152},flagsToPermissionString(e){var t=["r","w","rw"][e&3];return e&512&&(t+="w"),t},nodePermissions(e,t){return a.ignorePermissions?0:t.includes("r")&&!(e.mode&292)||t.includes("w")&&!(e.mode&146)||t.includes("x")&&!(e.mode&73)?2:0},mayLookup(e){if(!a.isDir(e.mode))return 54;var t=a.nodePermissions(e,"x");return t||(e.node_ops.lookup?0:2)},mayCreate(e,t){if(!a.isDir(e.mode))return 54;try{return a.lookupNode(e,t),20}catch{}return a.nodePermissions(e,"wx")},mayDelete(e,t,l){var i;try{i=a.lookupNode(e,t)}catch(r){return r.errno}var n=a.nodePermissions(e,"wx");if(n)return n;if(l){if(!a.isDir(i.mode))return 54;if(a.isRoot(i)||a.getPath(i)===a.cwd())return 10}else if(a.isDir(i.mode))return 31;return 0},mayOpen(e,t){if(!e)return 44;if(a.isLink(e.mode))return 32;var l=a.flagsToPermissionString(t);return a.isDir(e.mode)&&(l!=="r"||t&576)?31:a.nodePermissions(e,l)},checkOpExists(e,t){if(!e)throw new a.ErrnoError(t);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=a.MAX_OPEN_FDS;e++)if(!a.streams[e])return e;throw new a.ErrnoError(33)},getStreamChecked(e){var t=a.getStream(e);if(!t)throw new a.ErrnoError(8);return t},getStream:e=>a.streams[e],createStream(e,t=-1){return e=Object.assign(new a.FSStream,e),t==-1&&(t=a.nextfd()),e.fd=t,a.streams[t]=e,e},closeStream(e){a.streams[e]=null},dupStream(e,t=-1){var l=a.createStream(e,t);return l.stream_ops?.dup?.(l),l},doSetAttr(e,t,l){var i=e?.stream_ops.setattr,n=i?e:t;i??=t.node_ops.setattr,a.checkOpExists(i,63),i(n,l)},chrdev_stream_ops:{open(e){e.stream_ops=a.getDevice(e.node.rdev).stream_ops,e.stream_ops.open?.(e)},llseek(){throw new a.ErrnoError(70)}},major:e=>e>>8,minor:e=>e&255,makedev:(e,t)=>e<<8|t,registerDevice(e,t){a.devices[e]={stream_ops:t}},getDevice:e=>a.devices[e],getMounts(e){for(var t=[],l=[e];l.length;){var i=l.pop();t.push(i),l.push(...i.mounts)}return t},syncfs(e,t){typeof e=="function"&&(t=e,e=!1),a.syncFSRequests++,a.syncFSRequests>1&&We(`warning: ${a.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var l=a.getMounts(a.root.mount),i=0;function n(_){return a.syncFSRequests--,t(_)}function r(_){if(_)return r.errored?void 0:(r.errored=!0,n(_));++i>=l.length&&n(null)}for(var s of l)s.type.syncfs?s.type.syncfs(s,e,r):r(null)},mount(e,t,l){var i=l==="/",n=!l,r;if(i&&a.root)throw new a.ErrnoError(10);if(!i&&!n){var s=a.lookupPath(l,{follow_mount:!1});if(l=s.path,r=s.node,a.isMountpoint(r))throw new a.ErrnoError(10);if(!a.isDir(r.mode))throw new a.ErrnoError(54)}var _={type:e,opts:t,mountpoint:l,mounts:[]},c=e.mount(_);return c.mount=_,_.root=c,i?a.root=c:r&&(r.mounted=_,r.mount&&r.mount.mounts.push(_)),c},unmount(e){var t=a.lookupPath(e,{follow_mount:!1});if(!a.isMountpoint(t.node))throw new a.ErrnoError(28);var l=t.node,i=l.mounted,n=a.getMounts(i);for(var[r,s]of Object.entries(a.nameTable))for(;s;){var _=s.name_next;n.includes(s.mount)&&a.destroyNode(s),s=_}l.mounted=null;var c=l.mount.mounts.indexOf(i);l.mount.mounts.splice(c,1)},lookup(e,t){return e.node_ops.lookup(e,t)},mknod(e,t,l){var i=a.lookupPath(e,{parent:!0}).node,n=ve.basename(e);if(!n)throw new a.ErrnoError(28);if(n==="."||n==="..")throw new a.ErrnoError(20);var r=a.mayCreate(i,n);if(r)throw new a.ErrnoError(r);if(!i.node_ops.mknod)throw new a.ErrnoError(63);return i.node_ops.mknod(i,n,t,l)},statfs(e){return a.statfsNode(a.lookupPath(e,{follow:!0}).node)},statfsStream(e){return a.statfsNode(e.node)},statfsNode(e){var t={bsize:4096,frsize:4096,blocks:1e6,bfree:5e5,bavail:5e5,files:a.nextInode,ffree:a.nextInode-1,fsid:42,flags:2,namelen:255};return e.node_ops.statfs&&Object.assign(t,e.node_ops.statfs(e.mount.opts.root)),t},create(e,t=438){return t&=4095,t|=32768,a.mknod(e,t,0)},mkdir(e,t=511){return t&=1023,t|=16384,a.mknod(e,t,0)},mkdirTree(e,t){var l=e.split("/"),i="";for(var n of l)if(n){(i||ve.isAbs(e))&&(i+="/"),i+=n;try{a.mkdir(i,t)}catch(r){if(r.errno!=20)throw r}}},mkdev(e,t,l){return typeof l>"u"&&(l=t,t=438),t|=8192,a.mknod(e,t,l)},symlink(e,t){if(!Ze.resolve(e))throw new a.ErrnoError(44);var l=a.lookupPath(t,{parent:!0}).node;if(!l)throw new a.ErrnoError(44);var i=ve.basename(t),n=a.mayCreate(l,i);if(n)throw new a.ErrnoError(n);if(!l.node_ops.symlink)throw new a.ErrnoError(63);return l.node_ops.symlink(l,i,e)},rename(e,t){var l=ve.dirname(e),i=ve.dirname(t),n=ve.basename(e),r=ve.basename(t),s=a.lookupPath(e,{parent:!0}),_=s.node,c;if(s=a.lookupPath(t,{parent:!0}),c=s.node,!_||!c)throw new a.ErrnoError(44);if(_.mount!==c.mount)throw new a.ErrnoError(75);var m=a.lookupNode(_,n),M=Ze.relative(e,i);if(M.charAt(0)!==".")throw new a.ErrnoError(28);if(M=Ze.relative(t,l),M.charAt(0)!==".")throw new a.ErrnoError(55);var I;try{I=a.lookupNode(c,r)}catch{}if(m!==I){var S=a.isDir(m.mode),w=a.mayDelete(_,n,S);if(w)throw new a.ErrnoError(w);if(w=I?a.mayDelete(c,r,S):a.mayCreate(c,r),w)throw new a.ErrnoError(w);if(!_.node_ops.rename)throw new a.ErrnoError(63);if(a.isMountpoint(m)||I&&a.isMountpoint(I))throw new a.ErrnoError(10);if(c!==_&&(w=a.nodePermissions(_,"w"),w))throw new a.ErrnoError(w);a.hashRemoveNode(m);try{_.node_ops.rename(m,c,r),m.parent=c}catch(x){throw x}finally{a.hashAddNode(m)}}},rmdir(e){var t=a.lookupPath(e,{parent:!0}).node,l=ve.basename(e),i=a.lookupNode(t,l),n=a.mayDelete(t,l,!0);if(n)throw new a.ErrnoError(n);if(!t.node_ops.rmdir)throw new a.ErrnoError(63);if(a.isMountpoint(i))throw new a.ErrnoError(10);t.node_ops.rmdir(t,l),a.destroyNode(i)},readdir(e){var t=a.lookupPath(e,{follow:!0}).node;return a.checkOpExists(t.node_ops.readdir,54)(t)},unlink(e){var t=a.lookupPath(e,{parent:!0}).node;if(!t)throw new a.ErrnoError(44);var l=ve.basename(e),i=a.lookupNode(t,l),n=a.mayDelete(t,l,!1);if(n)throw new a.ErrnoError(n);if(!t.node_ops.unlink)throw new a.ErrnoError(63);if(a.isMountpoint(i))throw new a.ErrnoError(10);t.node_ops.unlink(t,l),a.destroyNode(i)},readlink(e){var t=a.lookupPath(e).node;if(!t)throw new a.ErrnoError(44);if(!t.node_ops.readlink)throw new a.ErrnoError(28);return t.node_ops.readlink(t)},stat(e,t){var l=a.lookupPath(e,{follow:!t}).node;return a.checkOpExists(l.node_ops.getattr,63)(l)},fstat(e){var t=a.getStreamChecked(e),l=t.node,i=t.stream_ops.getattr,n=i?t:l;return i??=l.node_ops.getattr,a.checkOpExists(i,63),i(n)},lstat(e){return a.stat(e,!0)},doChmod(e,t,l,i){a.doSetAttr(e,t,{mode:l&4095|t.mode&-4096,ctime:Date.now(),dontFollow:i})},chmod(e,t,l){var i;typeof e=="string"?i=a.lookupPath(e,{follow:!l}).node:i=e,a.doChmod(null,i,t,l)},lchmod(e,t){a.chmod(e,t,!0)},fchmod(e,t){var l=a.getStreamChecked(e);a.doChmod(l,l.node,t,!1)},doChown(e,t,l){a.doSetAttr(e,t,{timestamp:Date.now(),dontFollow:l})},chown(e,t,l,i){var n;typeof e=="string"?n=a.lookupPath(e,{follow:!i}).node:n=e,a.doChown(null,n,i)},lchown(e,t,l){a.chown(e,t,l,!0)},fchown(e,t,l){var i=a.getStreamChecked(e);a.doChown(i,i.node,!1)},doTruncate(e,t,l){if(a.isDir(t.mode))throw new a.ErrnoError(31);if(!a.isFile(t.mode))throw new a.ErrnoError(28);var i=a.nodePermissions(t,"w");if(i)throw new a.ErrnoError(i);a.doSetAttr(e,t,{size:l,timestamp:Date.now()})},truncate(e,t){if(t<0)throw new a.ErrnoError(28);var l;typeof e=="string"?l=a.lookupPath(e,{follow:!0}).node:l=e,a.doTruncate(null,l,t)},ftruncate(e,t){var l=a.getStreamChecked(e);if(t<0||(l.flags&2097155)===0)throw new a.ErrnoError(28);a.doTruncate(l,l.node,t)},utime(e,t,l){var i=a.lookupPath(e,{follow:!0}).node;a.checkOpExists(i.node_ops.setattr,63)(i,{atime:t,mtime:l})},open(e,t,l=438){if(e==="")throw new a.ErrnoError(44);t=mn(t),t&64?l=l&4095|32768:l=0;var i,n;if(typeof e=="object")i=e;else{n=e.endsWith("/");var r=a.lookupPath(e,{follow:!(t&131072),noent_okay:!0});i=r.node,e=r.path}var s=!1;if(t&64)if(i){if(t&128)throw new a.ErrnoError(20)}else{if(n)throw new a.ErrnoError(31);i=a.mknod(e,l|511,0),s=!0}if(!i)throw new a.ErrnoError(44);if(a.isChrdev(i.mode)&&(t&=-513),t&65536&&!a.isDir(i.mode))throw new a.ErrnoError(54);if(!s){var _=a.mayOpen(i,t);if(_)throw new a.ErrnoError(_)}t&512&&!s&&a.truncate(i,0),t&=-131713;var c=a.createStream({node:i,path:a.getPath(i),flags:t,seekable:!0,position:0,stream_ops:i.stream_ops,ungotten:[],error:!1});return c.stream_ops.open&&c.stream_ops.open(c),s&&a.chmod(i,l&511),c},close(e){if(a.isClosed(e))throw new a.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(t){throw t}finally{a.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,t,l){if(a.isClosed(e))throw new a.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new a.ErrnoError(70);if(l!=0&&l!=1&&l!=2)throw new a.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,l),e.ungotten=[],e.position},read(e,t,l,i,n){if(i<0||n<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===1)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.read)throw new a.ErrnoError(28);var r=typeof n<"u";if(!r)n=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var s=e.stream_ops.read(e,t,l,i,n);return r||(e.position+=s),s},write(e,t,l,i,n,r){if(i<0||n<0)throw new a.ErrnoError(28);if(a.isClosed(e))throw new a.ErrnoError(8);if((e.flags&2097155)===0)throw new a.ErrnoError(8);if(a.isDir(e.node.mode))throw new a.ErrnoError(31);if(!e.stream_ops.write)throw new a.ErrnoError(28);e.seekable&&e.flags&1024&&a.llseek(e,0,2);var s=typeof n<"u";if(!s)n=e.position;else if(!e.seekable)throw new a.ErrnoError(70);var _=e.stream_ops.write(e,t,l,i,n,r);return s||(e.position+=_),_},mmap(e,t,l,i,n){if((i&2)!==0&&(n&2)===0&&(e.flags&2097155)!==2)throw new a.ErrnoError(2);if((e.flags&2097155)===1)throw new a.ErrnoError(2);if(!e.stream_ops.mmap)throw new a.ErrnoError(43);if(!t)throw new a.ErrnoError(28);return e.stream_ops.mmap(e,t,l,i,n)},msync(e,t,l,i,n){return e.stream_ops.msync?e.stream_ops.msync(e,t,l,i,n):0},ioctl(e,t,l){if(!e.stream_ops.ioctl)throw new a.ErrnoError(59);return e.stream_ops.ioctl(e,t,l)},readFile(e,t={}){t.flags=t.flags||0,t.encoding=t.encoding||"binary",t.encoding!=="utf8"&&t.encoding!=="binary"&&Be(`Invalid encoding type "${t.encoding}"`);var l=a.open(e,t.flags),i=a.stat(e).size,n=new Uint8Array(i);return a.read(l,n,0,i,0),t.encoding==="utf8"&&(n=ot(n)),a.close(l),n},writeFile(e,t,l={}){l.flags=l.flags||577;var i=a.open(e,l.flags,l.mode);t=zt(t),a.write(i,t,0,t.byteLength,void 0,l.canOwn),a.close(i)},cwd:()=>a.currentPath,chdir(e){var t=a.lookupPath(e,{follow:!0});if(t.node===null)throw new a.ErrnoError(44);if(!a.isDir(t.node.mode))throw new a.ErrnoError(54);var l=a.nodePermissions(t.node,"x");if(l)throw new a.ErrnoError(l);a.currentPath=t.path},createDefaultDirectories(){a.mkdir("/tmp"),a.mkdir("/home"),a.mkdir("/home/web_user")},createDefaultDevices(){a.mkdir("/dev"),a.registerDevice(a.makedev(1,3),{read:()=>0,write:(i,n,r,s,_)=>s,llseek:()=>0}),a.mkdev("/dev/null",a.makedev(1,3)),$e.register(a.makedev(5,0),$e.default_tty_ops),$e.register(a.makedev(6,0),$e.default_tty1_ops),a.mkdev("/dev/tty",a.makedev(5,0)),a.mkdev("/dev/tty1",a.makedev(6,0));var e=new Uint8Array(1024),t=0,l=()=>(t===0&&(Ct(e),t=e.byteLength),e[--t]);a.createDevice("/dev","random",l),a.createDevice("/dev","urandom",l),a.mkdir("/dev/shm"),a.mkdir("/dev/shm/tmp")},createSpecialDirectories(){a.mkdir("/proc");var e=a.mkdir("/proc/self");a.mkdir("/proc/self/fd"),a.mount({mount(){var t=a.createNode(e,"fd",16895,73);return t.stream_ops={llseek:de.stream_ops.llseek},t.node_ops={lookup(l,i){var n=+i,r=a.getStreamChecked(n),s={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>r.path},id:n+1};return s.parent=s,s},readdir(){return Array.from(a.streams.entries()).filter(([l,i])=>i).map(([l,i])=>l.toString())}},t}},{},"/proc/self/fd")},createStandardStreams(e,t,l){e?a.createDevice("/dev","stdin",e):a.symlink("/dev/tty","/dev/stdin"),t?a.createDevice("/dev","stdout",null,t):a.symlink("/dev/tty","/dev/stdout"),l?a.createDevice("/dev","stderr",null,l):a.symlink("/dev/tty1","/dev/stderr"),a.open("/dev/stdin",0),a.open("/dev/stdout",1),a.open("/dev/stderr",1)},staticInit(){a.nameTable=new Array(4096),a.mount(de,{},"/"),a.createDefaultDirectories(),a.createDefaultDevices(),a.createSpecialDirectories(),a.filesystems={MEMFS:de}},init(e,t,l){a.initialized=!0,e??=f.stdin,t??=f.stdout,l??=f.stderr,a.createStandardStreams(e,t,l)},quit(){a.initialized=!1;for(var e of a.streams)e&&a.close(e)},findObject(e,t){var l=a.analyzePath(e,t);return l.exists?l.object:null},analyzePath(e,t){try{var l=a.lookupPath(e,{follow:!t});e=l.path}catch{}var i={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var l=a.lookupPath(e,{parent:!0});i.parentExists=!0,i.parentPath=l.path,i.parentObject=l.node,i.name=ve.basename(e),l=a.lookupPath(e,{follow:!t}),i.exists=!0,i.path=l.path,i.object=l.node,i.name=l.node.name,i.isRoot=l.path==="/"}catch(n){i.error=n.errno}return i},createPath(e,t,l,i){e=typeof e=="string"?e:a.getPath(e);for(var n=t.split("/").reverse();n.length;){var r=n.pop();if(r){var s=ve.join2(e,r);try{a.mkdir(s)}catch(_){if(_.errno!=20)throw _}e=s}}return s},createFile(e,t,l,i,n){var r=ve.join2(typeof e=="string"?e:a.getPath(e),t),s=wt(i,n);return a.create(r,s)},createDataFile(e,t,l,i,n,r){var s=t;e&&(e=typeof e=="string"?e:a.getPath(e),s=t?ve.join2(e,t):e);var _=wt(i,n),c=a.create(s,_);if(l){l=zt(l),a.chmod(c,_|146);var m=a.open(c,577);a.write(m,l,0,l.length,0,r),a.close(m),a.chmod(c,_)}},createDevice(e,t,l,i){var n=ve.join2(typeof e=="string"?e:a.getPath(e),t),r=wt(!!l,!!i);a.createDevice.major??=64;var s=a.makedev(a.createDevice.major++,0);return a.registerDevice(s,{open(_){_.seekable=!1},close(_){i?.buffer?.length&&i(10)},read(_,c,m,M,I){for(var S=0,w=0;wthis.length-1||I<0)){var S=I%this.chunkSize,w=I/this.chunkSize|0;return this.getter(w)[S]}}setDataGetter(I){this.getter=I}cacheLength(){var I=new XMLHttpRequest;I.open("HEAD",l,!1),I.send(null),I.status>=200&&I.status<300||I.status===304||Be("Couldn't load "+l+". Status: "+I.status);var S=Number(I.getResponseHeader("Content-length")),w,x=(w=I.getResponseHeader("Accept-Ranges"))&&w==="bytes",L=(w=I.getResponseHeader("Content-Encoding"))&&w==="gzip",V=1024*1024;x||(V=S);var b=(D,U)=>{D>U&&Be("invalid range ("+D+", "+U+") or no bytes requested!"),U>S-1&&Be("only "+S+" bytes available! programmer error!");var A=new XMLHttpRequest;return A.open("GET",l,!1),S!==V&&A.setRequestHeader("Range","bytes="+D+"-"+U),A.responseType="arraybuffer",A.overrideMimeType&&A.overrideMimeType("text/plain; charset=x-user-defined"),A.send(null),A.status>=200&&A.status<300||A.status===304||Be("Couldn't load "+l+". Status: "+A.status),A.response!==void 0?new Uint8Array(A.response||[]):St(A.responseText||"")},h=this;h.setDataGetter(D=>{var U=D*V,A=(D+1)*V-1;return A=Math.min(A,S-1),typeof h.chunks[D]>"u"&&(h.chunks[D]=b(U,A)),typeof h.chunks[D]>"u"&&Be("doXHR failed!"),h.chunks[D]}),(L||!S)&&(V=S=1,S=this.getter(0).length,V=S,dt("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=S,this._chunkSize=V,this.lengthKnown=!0}get length(){return this.lengthKnown||this.cacheLength(),this._length}get chunkSize(){return this.lengthKnown||this.cacheLength(),this._chunkSize}}if(globalThis.XMLHttpRequest){Ve||Be("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var s={isDevice:!1,contents:new r}}else var s={isDevice:!1,url:l};var _=a.createFile(e,t,s,i,n);s.contents?_.contents=s.contents:s.url&&(_.contents=null,_.url=s.url),Object.defineProperties(_,{usedBytes:{get:function(){return this.contents.length}}});var c={};for(const[M,I]of Object.entries(_.stream_ops))c[M]=(...S)=>(a.forceLoadFile(_),I(...S));function m(M,I,S,w,x){var L=M.node.contents;if(x>=L.length)return 0;var V=Math.min(L.length-x,w);if(L.slice)for(var b=0;b(a.forceLoadFile(_),m(M,I,S,w,x)),c.mmap=(M,I,S,w,x)=>{a.forceLoadFile(_);var L=Mt(I);if(!L)throw new a.ErrnoError(48);return m(M,Ne,L,I,S),{ptr:L,allocated:!0}},_.stream_ops=c,_}},wn=(e,t,l)=>{if(!e)return"";var i=Rt(Ge,e,t);return Nt.decode(Ge.subarray(e,i))},he={calculateAt(e,t,l){if(ve.isAbs(t))return t;var i;if(e===-100?i=a.cwd():i=he.getStreamFromFD(e).path,t.length==0){if(!l)throw new a.ErrnoError(44);return i}return i+"/"+t},writeStat(e,t){we[e>>2]=t.dev,we[e+4>>2]=t.mode,we[e+8>>2]=t.nlink,we[e+12>>2]=t.uid,we[e+16>>2]=t.gid,we[e+20>>2]=t.rdev,xe[e+24>>3]=BigInt(t.size),qe[e+32>>2]=4096,qe[e+36>>2]=t.blocks;var l=t.atime.getTime(),i=t.mtime.getTime(),n=t.ctime.getTime();return xe[e+40>>3]=BigInt(Math.floor(l/1e3)),we[e+48>>2]=l%1e3*1e3*1e3,xe[e+56>>3]=BigInt(Math.floor(i/1e3)),we[e+64>>2]=i%1e3*1e3*1e3,xe[e+72>>3]=BigInt(Math.floor(n/1e3)),we[e+80>>2]=n%1e3*1e3*1e3,xe[e+88>>3]=BigInt(t.ino),0},writeStatFs(e,t){we[e+4>>2]=t.bsize,we[e+60>>2]=t.bsize,xe[e+8>>3]=BigInt(t.blocks),xe[e+16>>3]=BigInt(t.bfree),xe[e+24>>3]=BigInt(t.bavail),xe[e+32>>3]=BigInt(t.files),xe[e+40>>3]=BigInt(t.ffree),we[e+48>>2]=t.fsid,we[e+64>>2]=t.flags,we[e+56>>2]=t.namelen},doMsync(e,t,l,i,n){if(!a.isFile(t.node.mode))throw new a.ErrnoError(43);if(i&2)return 0;var r=Ge.slice(e,e+l);a.msync(t,r,n,l,i)},getStreamFromFD(e){return a.getStreamChecked(e)},varargs:void 0,getStr(e){return wn(e)}};function En(e,t){try{return e=he.getStr(e),a.chmod(e,t),0}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}function An(e,t,l,i){try{if(t=he.getStr(t),t=he.calculateAt(e,t),l&-8)return-28;var n=a.lookupPath(t,{follow:!0}).node;if(!n)return-44;var r="";return l&4&&(r+="r"),l&2&&(r+="w"),l&1&&(r+="x"),r&&a.nodePermissions(n,r)?-2:0}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}function In(e,t){try{return a.fchmod(e,t),0}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}function Tn(e,t,l){try{return a.fchown(e,t,l),0}catch(i){if(typeof a>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var ht=()=>{var e=qe[+he.varargs>>2];return he.varargs+=4,e},et=ht;function kn(e,t,l){he.varargs=l;try{var i=he.getStreamFromFD(e);switch(t){case 0:var n=ht();if(n<0)return-28;for(;a.streams[n];)n++;return a.dupStream(i,n).fd;case 1:case 2:return 0;case 3:return i.flags;case 4:var n=ht();return i.flags|=n,0;case 12:var n=et(),r=0;return st[n+r>>1]=2,0;case 13:case 14:return 0}return-28}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}function On(e,t){try{return he.writeStat(t,a.fstat(e))}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}var xn=9007199254740992,Fn=-9007199254740992,at=e=>exn?NaN:Number(e);function Pn(e,t){t=at(t);try{return isNaN(t)?-61:(a.ftruncate(e,t),0)}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}var Je=(e,t,l)=>Dt(e,Ge,t,l);function Ln(e,t){try{if(t===0)return-28;var l=a.cwd(),i=pt(l)+1;return t"u"||n.name!=="ErrnoError")throw n;return-n.errno}}function Cn(e,t,l){he.varargs=l;try{var i=he.getStreamFromFD(e);switch(t){case 21509:return i.tty?0:-59;case 21505:if(!i.tty)return-59;if(i.tty.ops.ioctl_tcgets){var n=i.tty.ops.ioctl_tcgets(i),I=et();qe[I>>2]=n.c_iflag||0,qe[I+4>>2]=n.c_oflag||0,qe[I+8>>2]=n.c_cflag||0,qe[I+12>>2]=n.c_lflag||0;for(var r=0;r<32;r++)Ne[I+r+17]=n.c_cc[r]||0;return 0}return 0;case 21510:case 21511:case 21512:return i.tty?0:-59;case 21506:case 21507:case 21508:if(!i.tty)return-59;if(i.tty.ops.ioctl_tcsets){for(var I=et(),s=qe[I>>2],_=qe[I+4>>2],c=qe[I+8>>2],m=qe[I+12>>2],M=[],r=0;r<32;r++)M.push(Ne[I+r+17]);return i.tty.ops.ioctl_tcsets(i.tty,t,{c_iflag:s,c_oflag:_,c_cflag:c,c_lflag:m,c_cc:M})}return 0;case 21519:if(!i.tty)return-59;var I=et();return qe[I>>2]=0,0;case 21520:return i.tty?-28:-59;case 21537:case 21531:var I=et();return a.ioctl(i,t,I);case 21523:if(!i.tty)return-59;if(i.tty.ops.ioctl_tiocgwinsz){var S=i.tty.ops.ioctl_tiocgwinsz(i.tty),I=et();st[I>>1]=S[0],st[I+2>>1]=S[1]}return 0;case 21524:return i.tty?0:-59;case 21515:return i.tty?0:-59;default:return-28}}catch(w){if(typeof a>"u"||w.name!=="ErrnoError")throw w;return-w.errno}}function Nn(e,t){try{return e=he.getStr(e),he.writeStat(t,a.lstat(e))}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}function Rn(e,t,l){try{return t=he.getStr(t),t=he.calculateAt(e,t),a.mkdir(t,l,0),0}catch(i){if(typeof a>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function Dn(e,t,l,i){try{t=he.getStr(t);var n=i&256,r=i&4096;return i=i&-6401,t=he.calculateAt(e,t,r),he.writeStat(l,n?a.lstat(t):a.stat(t))}catch(s){if(typeof a>"u"||s.name!=="ErrnoError")throw s;return-s.errno}}function jn(e,t,l,i){he.varargs=i;try{t=he.getStr(t),t=he.calculateAt(e,t);var n=i?ht():0;return a.open(t,l,n).fd}catch(r){if(typeof a>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function Mn(e,t,l,i){try{if(t=he.getStr(t),t=he.calculateAt(e,t),i<=0)return-28;var n=a.readlink(t),r=Math.min(i,pt(n)),s=Ne[l+r];return Je(n,l,i+1),Ne[l+r]=s,r}catch(_){if(typeof a>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}function zn(e){try{return e=he.getStr(e),a.rmdir(e),0}catch(t){if(typeof a>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}function Bn(e,t){try{return e=he.getStr(e),he.writeStat(t,a.stat(e))}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return-l.errno}}function Qn(e,t,l){try{if(t=he.getStr(t),t=he.calculateAt(e,t),!l)a.unlink(t);else if(l===512)a.rmdir(t);else return-28;return 0}catch(i){if(typeof a>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var Ut=e=>we[e>>2]+qe[e+4>>2]*4294967296;function Un(e,t,l,i){try{t=he.getStr(t),t=he.calculateAt(e,t,!0);var n=Date.now(),r,s;if(!l)r=n,s=n;else{var _=Ut(l),c=qe[l+8>>2];c==1073741823?r=n:c==1073741822?r=null:r=_*1e3+c/(1e3*1e3),l+=16,_=Ut(l),c=qe[l+8>>2],c==1073741823?s=n:c==1073741822?s=null:s=_*1e3+c/(1e3*1e3)}return(s??r)!==null&&a.utime(t,r,s),0}catch(m){if(typeof a>"u"||m.name!=="ErrnoError")throw m;return-m.errno}}var Wn=e=>e%4===0&&(e%100!==0||e%400===0),Hn=[0,31,60,91,121,152,182,213,244,274,305,335],Vn=[0,31,59,90,120,151,181,212,243,273,304,334],Gn=e=>(Wn(e.getFullYear())?Hn:Vn)[e.getMonth()]+e.getDate()-1;function $n(e,t){e=at(e);var l=new Date(e*1e3);qe[t>>2]=l.getSeconds(),qe[t+4>>2]=l.getMinutes(),qe[t+8>>2]=l.getHours(),qe[t+12>>2]=l.getDate(),qe[t+16>>2]=l.getMonth(),qe[t+20>>2]=l.getFullYear()-1900,qe[t+24>>2]=l.getDay();var i=Gn(l)|0;qe[t+28>>2]=i,qe[t+36>>2]=-(l.getTimezoneOffset()*60);var n=new Date(l.getFullYear(),0,1),r=new Date(l.getFullYear(),6,1).getTimezoneOffset(),s=n.getTimezoneOffset(),_=(r!=s&&l.getTimezoneOffset()==Math.min(s,r))|0;qe[t+32>>2]=_}function Kn(e,t,l,i,n,r,s){n=at(n);try{var _=he.getStreamFromFD(i),c=a.mmap(_,e,n,t,l),m=c.ptr;return qe[r>>2]=c.allocated,we[s>>2]=m,0}catch(M){if(typeof a>"u"||M.name!=="ErrnoError")throw M;return-M.errno}}function Jn(e,t,l,i,n,r){r=at(r);try{var s=he.getStreamFromFD(n);l&2&&he.doMsync(e,s,t,i,r)}catch(_){if(typeof a>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}var Xn=(e,t,l,i)=>{var n=new Date().getFullYear(),r=new Date(n,0,1),s=new Date(n,6,1),_=r.getTimezoneOffset(),c=s.getTimezoneOffset(),m=Math.max(_,c);we[e>>2]=m*60,qe[t>>2]=+(_!=c);var M=w=>{var x=w>=0?"-":"+",L=Math.abs(w);return`UTC${x}${String(Math.floor(L/60)).padStart(2,"0")}${String(L%60).padStart(2,"0")}`},I=M(_),S=M(c);c<_?(Je(I,l,17),Je(S,i,17)):(Je(I,i,17),Je(S,l,17))},Wt=()=>performance.now(),Ht=()=>Date.now(),Yn=e=>e>=0&&e<=3;function Zn(e,t,l){if(!Yn(e))return 28;var i;e===0?i=Ht():i=Wt();var n=Math.round(i*1e3*1e3);return xe[l>>3]=BigInt(n),0}var Vt=()=>2147483648,er=()=>Vt(),tr=e=>{var t=(e-Qe.buffer.byteLength+65535)/65536|0;try{return Qe.grow(t),xt(),1}catch{}},nr=e=>{var t=Ge.length;e>>>=0;var l=Vt();if(e>l)return!1;for(var i=1;i<=4;i*=2){var n=t*(1+.2/i);if(n=Math.min(n,e+100663296),tr(Math.min(l,jt(Math.max(e,n),65536))))return!0}return!1},Et={},rr=()=>ze||"./this.program",ct=()=>{if(!ct.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",_:rr()};for(var t in Et)Et[t]===void 0?delete e[t]:e[t]=Et[t];var l=[];for(var t in e)l.push(`${t}=${e[t]}`);ct.strings=l}return ct.strings},ir=(e,t)=>{var l=0,i=0;for(var n of ct()){var r=t+l;we[e+i>>2]=r,l+=Je(n,r,1/0)+1,i+=4}return 0},sr=(e,t)=>{var l=ct();we[e>>2]=l.length;var i=0;for(var n of l)i+=pt(n)+1;return we[t>>2]=i,0};function or(e){try{var t=he.getStreamFromFD(e);return a.close(t),0}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return l.errno}}function lr(e,t){try{var l=0,i=0,n=0,r=he.getStreamFromFD(e),s=r.tty?2:a.isDir(r.mode)?3:a.isLink(r.mode)?7:4;return Ne[t]=s,st[t+2>>1]=n,xe[t+8>>3]=BigInt(l),xe[t+16>>3]=BigInt(i),0}catch(_){if(typeof a>"u"||_.name!=="ErrnoError")throw _;return _.errno}}var ar=(e,t,l,i)=>{for(var n=0,r=0;r>2],_=we[t+4>>2];t+=8;var c=a.read(e,Ne,s,_,i);if(c<0)return-1;if(n+=c,c<_)break}return n};function cr(e,t,l,i){try{var n=ar(he.getStreamFromFD(e),t,l);return we[i>>2]=n,0}catch(r){if(typeof a>"u"||r.name!=="ErrnoError")throw r;return r.errno}}function ur(e,t,l,i){t=at(t);try{if(isNaN(t))return 61;var n=he.getStreamFromFD(e);return a.llseek(n,t,l),xe[i>>3]=BigInt(n.position),n.getdents&&t===0&&l===0&&(n.getdents=null),0}catch(r){if(typeof a>"u"||r.name!=="ErrnoError")throw r;return r.errno}}function _r(e){try{var t=he.getStreamFromFD(e);return t.stream_ops?.fsync?.(t)}catch(l){if(typeof a>"u"||l.name!=="ErrnoError")throw l;return l.errno}}var fr=(e,t,l,i)=>{for(var n=0,r=0;r>2],_=we[t+4>>2];t+=8;var c=a.write(e,Ne,s,_,i);if(c<0)return-1;if(n+=c,c<_)break}return n};function dr(e,t,l,i){try{var n=fr(he.getStreamFromFD(e),t,l);return we[i>>2]=n,0}catch(r){if(typeof a>"u"||r.name!=="ErrnoError")throw r;return r.errno}}if(a.createPreloadedFile=Sn,a.preloadFile=Qt,a.staticInit(),Zt(),f.noExitRuntime&&f.noExitRuntime,f.preloadPlugins&&(Bt=f.preloadPlugins),f.print&&(dt=f.print),f.printErr&&(We=f.printErr),f.wasmBinary&&(it=f.wasmBinary),f.arguments&&f.arguments,f.thisProgram&&(ze=f.thisProgram),f.preInit)for(typeof f.preInit=="function"&&(f.preInit=[f.preInit]);f.preInit.length>0;)f.preInit.shift()();f.wasmMemory=Qe;var Gt;function pr(e){f._sqlite3_status64=e.sqlite3_status64,f._sqlite3_status=e.sqlite3_status,f._sqlite3_db_status64=e.sqlite3_db_status64,f._sqlite3_msize=e.sqlite3_msize,f._sqlite3_db_status=e.sqlite3_db_status,f._sqlite3_vfs_find=e.sqlite3_vfs_find,f._sqlite3_initialize=e.sqlite3_initialize,f._sqlite3_malloc=e.sqlite3_malloc,f._sqlite3_free=e.sqlite3_free,f._sqlite3_vfs_register=e.sqlite3_vfs_register,f._sqlite3_vfs_unregister=e.sqlite3_vfs_unregister,f._sqlite3_malloc64=e.sqlite3_malloc64,f._sqlite3_realloc=e.sqlite3_realloc,f._sqlite3_realloc64=e.sqlite3_realloc64,f._sqlite3_value_text=e.sqlite3_value_text,f._sqlite3_randomness=e.sqlite3_randomness,f._sqlite3_stricmp=e.sqlite3_stricmp,f._sqlite3_strnicmp=e.sqlite3_strnicmp,f._sqlite3_uri_parameter=e.sqlite3_uri_parameter,f._sqlite3_uri_boolean=e.sqlite3_uri_boolean,f._sqlite3_serialize=e.sqlite3_serialize,f._sqlite3_prepare_v2=e.sqlite3_prepare_v2,f._sqlite3_step=e.sqlite3_step,f._sqlite3_column_int64=e.sqlite3_column_int64,f._sqlite3_reset=e.sqlite3_reset,f._sqlite3_exec=e.sqlite3_exec,f._sqlite3_column_int=e.sqlite3_column_int,f._sqlite3_finalize=e.sqlite3_finalize,f._sqlite3_file_control=e.sqlite3_file_control,f._sqlite3_column_name=e.sqlite3_column_name,f._sqlite3_column_text=e.sqlite3_column_text,f._sqlite3_column_type=e.sqlite3_column_type,f._sqlite3_errmsg=e.sqlite3_errmsg,f._sqlite3_deserialize=e.sqlite3_deserialize,f._sqlite3_clear_bindings=e.sqlite3_clear_bindings,f._sqlite3_value_blob=e.sqlite3_value_blob,f._sqlite3_value_bytes=e.sqlite3_value_bytes,f._sqlite3_value_double=e.sqlite3_value_double,f._sqlite3_value_int=e.sqlite3_value_int,f._sqlite3_value_int64=e.sqlite3_value_int64,f._sqlite3_value_subtype=e.sqlite3_value_subtype,f._sqlite3_value_pointer=e.sqlite3_value_pointer,f._sqlite3_value_type=e.sqlite3_value_type,f._sqlite3_value_nochange=e.sqlite3_value_nochange,f._sqlite3_value_frombind=e.sqlite3_value_frombind,f._sqlite3_value_dup=e.sqlite3_value_dup,f._sqlite3_value_free=e.sqlite3_value_free,f._sqlite3_result_blob=e.sqlite3_result_blob,f._sqlite3_result_error_toobig=e.sqlite3_result_error_toobig,f._sqlite3_result_error_nomem=e.sqlite3_result_error_nomem,f._sqlite3_result_double=e.sqlite3_result_double,f._sqlite3_result_error=e.sqlite3_result_error,f._sqlite3_result_int=e.sqlite3_result_int,f._sqlite3_result_int64=e.sqlite3_result_int64,f._sqlite3_result_null=e.sqlite3_result_null,f._sqlite3_result_pointer=e.sqlite3_result_pointer,f._sqlite3_result_subtype=e.sqlite3_result_subtype,f._sqlite3_result_text=e.sqlite3_result_text,f._sqlite3_result_zeroblob=e.sqlite3_result_zeroblob,f._sqlite3_result_zeroblob64=e.sqlite3_result_zeroblob64,f._sqlite3_result_error_code=e.sqlite3_result_error_code,f._sqlite3_user_data=e.sqlite3_user_data,f._sqlite3_context_db_handle=e.sqlite3_context_db_handle,f._sqlite3_vtab_nochange=e.sqlite3_vtab_nochange,f._sqlite3_vtab_in_first=e.sqlite3_vtab_in_first,f._sqlite3_vtab_in_next=e.sqlite3_vtab_in_next,f._sqlite3_aggregate_context=e.sqlite3_aggregate_context,f._sqlite3_get_auxdata=e.sqlite3_get_auxdata,f._sqlite3_set_auxdata=e.sqlite3_set_auxdata,f._sqlite3_column_count=e.sqlite3_column_count,f._sqlite3_data_count=e.sqlite3_data_count,f._sqlite3_column_blob=e.sqlite3_column_blob,f._sqlite3_column_bytes=e.sqlite3_column_bytes,f._sqlite3_column_double=e.sqlite3_column_double,f._sqlite3_column_value=e.sqlite3_column_value,f._sqlite3_column_decltype=e.sqlite3_column_decltype,f._sqlite3_column_database_name=e.sqlite3_column_database_name,f._sqlite3_column_table_name=e.sqlite3_column_table_name,f._sqlite3_column_origin_name=e.sqlite3_column_origin_name,f._sqlite3_bind_blob=e.sqlite3_bind_blob,f._sqlite3_bind_double=e.sqlite3_bind_double,f._sqlite3_bind_int=e.sqlite3_bind_int,f._sqlite3_bind_int64=e.sqlite3_bind_int64,f._sqlite3_bind_null=e.sqlite3_bind_null,f._sqlite3_bind_pointer=e.sqlite3_bind_pointer,f._sqlite3_bind_text=e.sqlite3_bind_text,f._sqlite3_bind_zeroblob=e.sqlite3_bind_zeroblob,f._sqlite3_bind_parameter_count=e.sqlite3_bind_parameter_count,f._sqlite3_bind_parameter_name=e.sqlite3_bind_parameter_name,f._sqlite3_bind_parameter_index=e.sqlite3_bind_parameter_index,f._sqlite3_db_handle=e.sqlite3_db_handle,f._sqlite3_stmt_readonly=e.sqlite3_stmt_readonly,f._sqlite3_stmt_isexplain=e.sqlite3_stmt_isexplain,f._sqlite3_stmt_explain=e.sqlite3_stmt_explain,f._sqlite3_stmt_busy=e.sqlite3_stmt_busy,f._sqlite3_next_stmt=e.sqlite3_next_stmt,f._sqlite3_stmt_status=e.sqlite3_stmt_status,f._sqlite3_sql=e.sqlite3_sql,f._sqlite3_expanded_sql=e.sqlite3_expanded_sql,f._sqlite3_preupdate_old=e.sqlite3_preupdate_old,f._sqlite3_preupdate_count=e.sqlite3_preupdate_count,f._sqlite3_preupdate_depth=e.sqlite3_preupdate_depth,f._sqlite3_preupdate_blobwrite=e.sqlite3_preupdate_blobwrite,f._sqlite3_preupdate_new=e.sqlite3_preupdate_new,f._sqlite3_value_numeric_type=e.sqlite3_value_numeric_type,f._sqlite3_set_authorizer=e.sqlite3_set_authorizer,f._sqlite3_strglob=e.sqlite3_strglob,f._sqlite3_strlike=e.sqlite3_strlike,f._sqlite3_auto_extension=e.sqlite3_auto_extension,f._sqlite3_cancel_auto_extension=e.sqlite3_cancel_auto_extension,f._sqlite3_reset_auto_extension=e.sqlite3_reset_auto_extension,f._sqlite3_prepare_v3=e.sqlite3_prepare_v3,f._sqlite3_create_module=e.sqlite3_create_module,f._sqlite3_create_module_v2=e.sqlite3_create_module_v2,f._sqlite3_drop_modules=e.sqlite3_drop_modules,f._sqlite3_declare_vtab=e.sqlite3_declare_vtab,f._sqlite3_vtab_on_conflict=e.sqlite3_vtab_on_conflict,f._sqlite3_vtab_collation=e.sqlite3_vtab_collation,f._sqlite3_vtab_in=e.sqlite3_vtab_in,f._sqlite3_vtab_rhs_value=e.sqlite3_vtab_rhs_value,f._sqlite3_vtab_distinct=e.sqlite3_vtab_distinct,f._sqlite3_keyword_name=e.sqlite3_keyword_name,f._sqlite3_keyword_count=e.sqlite3_keyword_count,f._sqlite3_keyword_check=e.sqlite3_keyword_check,f._sqlite3_complete=e.sqlite3_complete,f._sqlite3_libversion=e.sqlite3_libversion,f._sqlite3_libversion_number=e.sqlite3_libversion_number,f._sqlite3_shutdown=e.sqlite3_shutdown,f._sqlite3_last_insert_rowid=e.sqlite3_last_insert_rowid,f._sqlite3_set_last_insert_rowid=e.sqlite3_set_last_insert_rowid,f._sqlite3_changes64=e.sqlite3_changes64,f._sqlite3_changes=e.sqlite3_changes,f._sqlite3_total_changes64=e.sqlite3_total_changes64,f._sqlite3_total_changes=e.sqlite3_total_changes,f._sqlite3_txn_state=e.sqlite3_txn_state,f._sqlite3_close_v2=e.sqlite3_close_v2,f._sqlite3_busy_handler=e.sqlite3_busy_handler,f._sqlite3_progress_handler=e.sqlite3_progress_handler,f._sqlite3_busy_timeout=e.sqlite3_busy_timeout,f._sqlite3_interrupt=e.sqlite3_interrupt,f._sqlite3_is_interrupted=e.sqlite3_is_interrupted,f._sqlite3_create_function=e.sqlite3_create_function,f._sqlite3_create_function_v2=e.sqlite3_create_function_v2,f._sqlite3_create_window_function=e.sqlite3_create_window_function,f._sqlite3_overload_function=e.sqlite3_overload_function,f._sqlite3_trace_v2=e.sqlite3_trace_v2,f._sqlite3_commit_hook=e.sqlite3_commit_hook,f._sqlite3_update_hook=e.sqlite3_update_hook,f._sqlite3_rollback_hook=e.sqlite3_rollback_hook,f._sqlite3_preupdate_hook=e.sqlite3_preupdate_hook,f._sqlite3_set_errmsg=e.sqlite3_set_errmsg,f._sqlite3_error_offset=e.sqlite3_error_offset,f._sqlite3_errcode=e.sqlite3_errcode,f._sqlite3_extended_errcode=e.sqlite3_extended_errcode,f._sqlite3_errstr=e.sqlite3_errstr,f._sqlite3_limit=e.sqlite3_limit,f._sqlite3_open=e.sqlite3_open,f._sqlite3_open_v2=e.sqlite3_open_v2,f._sqlite3_create_collation=e.sqlite3_create_collation,f._sqlite3_create_collation_v2=e.sqlite3_create_collation_v2,f._sqlite3_collation_needed=e.sqlite3_collation_needed,f._sqlite3_get_autocommit=e.sqlite3_get_autocommit,f._sqlite3_table_column_metadata=e.sqlite3_table_column_metadata,f._sqlite3_extended_result_codes=e.sqlite3_extended_result_codes,f._sqlite3_uri_key=e.sqlite3_uri_key,f._sqlite3_uri_int64=e.sqlite3_uri_int64,f._sqlite3_db_name=e.sqlite3_db_name,f._sqlite3_db_filename=e.sqlite3_db_filename,f._sqlite3_db_readonly=e.sqlite3_db_readonly,f._sqlite3_compileoption_used=e.sqlite3_compileoption_used,f._sqlite3_compileoption_get=e.sqlite3_compileoption_get,f._sqlite3session_diff=e.sqlite3session_diff,f._sqlite3session_attach=e.sqlite3session_attach,f._sqlite3session_create=e.sqlite3session_create,f._sqlite3session_delete=e.sqlite3session_delete,f._sqlite3session_table_filter=e.sqlite3session_table_filter,f._sqlite3session_changeset=e.sqlite3session_changeset,f._sqlite3session_changeset_strm=e.sqlite3session_changeset_strm,f._sqlite3session_patchset_strm=e.sqlite3session_patchset_strm,f._sqlite3session_patchset=e.sqlite3session_patchset,f._sqlite3session_enable=e.sqlite3session_enable,f._sqlite3session_indirect=e.sqlite3session_indirect,f._sqlite3session_isempty=e.sqlite3session_isempty,f._sqlite3session_memory_used=e.sqlite3session_memory_used,f._sqlite3session_object_config=e.sqlite3session_object_config,f._sqlite3session_changeset_size=e.sqlite3session_changeset_size,f._sqlite3changeset_start=e.sqlite3changeset_start,f._sqlite3changeset_start_v2=e.sqlite3changeset_start_v2,f._sqlite3changeset_start_strm=e.sqlite3changeset_start_strm,f._sqlite3changeset_start_v2_strm=e.sqlite3changeset_start_v2_strm,f._sqlite3changeset_next=e.sqlite3changeset_next,f._sqlite3changeset_op=e.sqlite3changeset_op,f._sqlite3changeset_pk=e.sqlite3changeset_pk,f._sqlite3changeset_old=e.sqlite3changeset_old,f._sqlite3changeset_new=e.sqlite3changeset_new,f._sqlite3changeset_conflict=e.sqlite3changeset_conflict,f._sqlite3changeset_fk_conflicts=e.sqlite3changeset_fk_conflicts,f._sqlite3changeset_finalize=e.sqlite3changeset_finalize,f._sqlite3changeset_invert=e.sqlite3changeset_invert,f._sqlite3changeset_invert_strm=e.sqlite3changeset_invert_strm,f._sqlite3changeset_apply_v2=e.sqlite3changeset_apply_v2,f._sqlite3changeset_apply_v3=e.sqlite3changeset_apply_v3,f._sqlite3changeset_apply=e.sqlite3changeset_apply,f._sqlite3changeset_apply_v3_strm=e.sqlite3changeset_apply_v3_strm,f._sqlite3changeset_apply_v2_strm=e.sqlite3changeset_apply_v2_strm,f._sqlite3changeset_apply_strm=e.sqlite3changeset_apply_strm,f._sqlite3changegroup_new=e.sqlite3changegroup_new,f._sqlite3changegroup_add=e.sqlite3changegroup_add,f._sqlite3changegroup_output=e.sqlite3changegroup_output,f._sqlite3changegroup_add_strm=e.sqlite3changegroup_add_strm,f._sqlite3changegroup_output_strm=e.sqlite3changegroup_output_strm,f._sqlite3changegroup_delete=e.sqlite3changegroup_delete,f._sqlite3changeset_concat=e.sqlite3changeset_concat,f._sqlite3changeset_concat_strm=e.sqlite3changeset_concat_strm,f._sqlite3session_config=e.sqlite3session_config,f._sqlite3_sourceid=e.sqlite3_sourceid,f._sqlite3__wasm_pstack_ptr=e.sqlite3__wasm_pstack_ptr,f._sqlite3__wasm_pstack_restore=e.sqlite3__wasm_pstack_restore,f._sqlite3__wasm_pstack_alloc=e.sqlite3__wasm_pstack_alloc,f._sqlite3__wasm_pstack_remaining=e.sqlite3__wasm_pstack_remaining,f._sqlite3__wasm_pstack_quota=e.sqlite3__wasm_pstack_quota,f._sqlite3__wasm_test_struct=e.sqlite3__wasm_test_struct,f._sqlite3__wasm_enum_json=e.sqlite3__wasm_enum_json,f._sqlite3__wasm_vfs_unlink=e.sqlite3__wasm_vfs_unlink,f._sqlite3__wasm_db_vfs=e.sqlite3__wasm_db_vfs,f._sqlite3__wasm_db_reset=e.sqlite3__wasm_db_reset,f._sqlite3__wasm_db_export_chunked=e.sqlite3__wasm_db_export_chunked,f._sqlite3__wasm_db_serialize=e.sqlite3__wasm_db_serialize,f._sqlite3__wasm_vfs_create_file=e.sqlite3__wasm_vfs_create_file,f._sqlite3__wasm_posix_create_file=e.sqlite3__wasm_posix_create_file,f._sqlite3__wasm_kvvfsMakeKey=e.sqlite3__wasm_kvvfsMakeKey,f._sqlite3__wasm_kvvfs_methods=e.sqlite3__wasm_kvvfs_methods,f._sqlite3__wasm_vtab_config=e.sqlite3__wasm_vtab_config,f._sqlite3__wasm_db_config_ip=e.sqlite3__wasm_db_config_ip,f._sqlite3__wasm_db_config_pii=e.sqlite3__wasm_db_config_pii,f._sqlite3__wasm_db_config_s=e.sqlite3__wasm_db_config_s,f._sqlite3__wasm_config_i=e.sqlite3__wasm_config_i,f._sqlite3__wasm_config_ii=e.sqlite3__wasm_config_ii,f._sqlite3__wasm_config_j=e.sqlite3__wasm_config_j,f._sqlite3__wasm_qfmt_token=e.sqlite3__wasm_qfmt_token,f._sqlite3__wasm_kvvfs_decode=e.sqlite3__wasm_kvvfs_decode,f._sqlite3__wasm_kvvfs_encode=e.sqlite3__wasm_kvvfs_encode,f._sqlite3__wasm_init_wasmfs=e.sqlite3__wasm_init_wasmfs,f._sqlite3__wasm_test_intptr=e.sqlite3__wasm_test_intptr,f._sqlite3__wasm_test_voidptr=e.sqlite3__wasm_test_voidptr,f._sqlite3__wasm_test_int64_max=e.sqlite3__wasm_test_int64_max,f._sqlite3__wasm_test_int64_min=e.sqlite3__wasm_test_int64_min,f._sqlite3__wasm_test_int64_times2=e.sqlite3__wasm_test_int64_times2,f._sqlite3__wasm_test_int64_minmax=e.sqlite3__wasm_test_int64_minmax,f._sqlite3__wasm_test_int64ptr=e.sqlite3__wasm_test_int64ptr,f._sqlite3__wasm_test_stack_overflow=e.sqlite3__wasm_test_stack_overflow,f._sqlite3__wasm_test_str_hello=e.sqlite3__wasm_test_str_hello,f._sqlite3__wasm_SQLTester_strglob=e.sqlite3__wasm_SQLTester_strglob,f._malloc=e.malloc,f._free=e.free,f._realloc=e.realloc,Gt=e.emscripten_builtin_memalign,e._emscripten_stack_restore,e._emscripten_stack_alloc,e.emscripten_stack_get_current,e.__indirect_function_table}var $t={__syscall_chmod:En,__syscall_faccessat:An,__syscall_fchmod:In,__syscall_fchown32:Tn,__syscall_fcntl64:kn,__syscall_fstat64:On,__syscall_ftruncate64:Pn,__syscall_getcwd:Ln,__syscall_ioctl:Cn,__syscall_lstat64:Nn,__syscall_mkdirat:Rn,__syscall_newfstatat:Dn,__syscall_openat:jn,__syscall_readlinkat:Mn,__syscall_rmdir:zn,__syscall_stat64:Bn,__syscall_unlinkat:Qn,__syscall_utimensat:Un,_localtime_js:$n,_mmap_js:Kn,_munmap_js:Jn,_tzset_js:Xn,clock_time_get:Zn,emscripten_date_now:Ht,emscripten_get_heap_max:er,emscripten_get_now:Wt,emscripten_resize_heap:nr,environ_get:ir,environ_sizes_get:sr,fd_close:or,fd_fdstat_get:lr,fd_read:cr,fd_seek:ur,fd_sync:_r,fd_write:dr,memory:Qe};function At(){if(Ke>0){lt=At;return}if(en(),Ke>0){lt=At;return}function e(){f.calledRun=!0,!It&&(tn(),Tt?.(f),f.onRuntimeInitialized?.(),nn())}f.setStatus?(f.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>f.setStatus(""),1),e()},1)):e()}var tt=await un();return At(),f.runSQLite3PostLoadInit=async function(e,t,l){delete t.runSQLite3PostLoadInit,globalThis.sqlite3ApiBootstrap=async function i(n=globalThis.sqlite3ApiConfig||i.defaultConfig){if(i.sqlite3)return(i.sqlite3.config||console).warn("sqlite3ApiBootstrap() called multiple times.","Config and external initializers are ignored on calls after the first."),i.sqlite3;const r=(...d)=>Object.assign(Object.create(null),...d),s=r({exports:void 0,memory:void 0,bigIntEnabled:!!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(s,{allocExportName:s.useStdAlloc?"malloc":"sqlite3_malloc",deallocExportName:s.useStdAlloc?"free":"sqlite3_free",reallocExportName:s.useStdAlloc?"realloc":"sqlite3_realloc"}),["exports","memory","functionTable","wasmfsOpfsDir"].forEach(d=>{typeof s[d]=="function"&&(s[d]=s[d]())});const _=r(),c=r(),m=d=>_.sqlite3_js_rc_str&&_.sqlite3_js_rc_str(d)||"Unknown result code #"+d,M=d=>typeof d=="number"&&d===(d|0)&&d<=2147483647&&d>=-2147483648;class I extends Error{constructor(...y){let P;if(y.length)if(M(y[0]))if(P=y[0],y.length===1)super(m(y[0]));else{const Q=m(P);typeof y[1]=="object"?super(Q,y[1]):(y[0]=Q+":",super(y.join(" ")))}else y.length===2&&typeof y[1]=="object"?super(...y):super(y.join(" "));this.resultCode=P||_.SQLITE_ERROR,this.name="SQLite3Error"}}I.toss=(...d)=>{throw new I(...d)};const S=I.toss;s.wasmfsOpfsDir&&!/^\/[^/]+$/.test(s.wasmfsOpfsDir)&&S("config.wasmfsOpfsDir must be falsy or in the form '/dir-name'.");const w=function d(y){return d._max||(d._max=BigInt("0x7fffffffffffffff"),d._min=~d._max),y>=d._min&&y<=d._max},x=d=>d>=-2147483647n-1n&&d<=2147483647n,L=function d(y){return d._min||(d._min=Number.MIN_SAFE_INTEGER,d._max=Number.MAX_SAFE_INTEGER),y>=d._min&&y<=d._max},V=d=>d&&d.constructor&&M(d.constructor.BYTES_PER_ELEMENT)?d:!1,b=d=>d&&(d instanceof Uint8Array||d instanceof Int8Array||d instanceof ArrayBuffer),h=d=>d&&(d instanceof Uint8Array||d instanceof Int8Array||d instanceof ArrayBuffer),D=d=>b(d)||S("Value is not of a supported TypedArray type."),U=function(d){return h(d)?c.typedArrayToString(d instanceof ArrayBuffer?new Uint8Array(d):d,0,d.length):Array.isArray(d)?d.join(""):(c.isPtr(d)&&(d=c.cstrToJs(d)),d)};class A extends Error{constructor(...y){y.length===2&&typeof y[1]=="object"?super(...y):y.length?super(y.join(" ")):super("Allocation failed."),this.resultCode=_.SQLITE_NOMEM,this.name="WasmAllocError"}}A.toss=(...d)=>{throw new A(...d)},Object.assign(_,{sqlite3_bind_blob:void 0,sqlite3_bind_text:void 0,sqlite3_create_function_v2:(d,y,P,Q,F,X,ee,Z,te)=>{},sqlite3_create_function:(d,y,P,Q,F,X,ee,Z)=>{},sqlite3_create_window_function:(d,y,P,Q,F,X,ee,Z,te,E)=>{},sqlite3_prepare_v3:(d,y,P,Q,F,X)=>{},sqlite3_prepare_v2:(d,y,P,Q,F)=>{},sqlite3_exec:(d,y,P,Q,F)=>{},sqlite3_randomness:(d,y)=>{}});const N={affirmBindableTypedArray:D,flexibleString:U,bigIntFits32:x,bigIntFits64:w,bigIntFitsDouble:L,isBindableTypedArray:b,isInt32:M,isSQLableTypedArray:h,isTypedArray:V,isUIThread:()=>globalThis.window===globalThis&&!!globalThis.document,toss:function(...d){throw new Error(d.join(" "))},toss3:S,typedArrayPart:c.typedArrayPart,nu:r,assert:function(d,y){d||N.toss("Assertion failed:",y)},affirmDbHeader:function(d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));const y="SQLite format 3";15>d.byteLength&&S("Input does not contain an SQLite3 database header.");for(let P=0;P<15;++P)y.charCodeAt(P)!==d[P]&&S("Input does not contain an SQLite3 database header.")},affirmIsDb:function(d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));const y=d.byteLength;(y<512||y%512!==0)&&S("Byte array size",y,"is invalid for an SQLite3 db."),N.affirmDbHeader(d)}};Object.assign(c,{exports:s.exports||S("Missing API config.exports (WASM module exports)."),memory:s.memory||s.exports.memory||S("API config object requires a WebAssembly.Memory object","in either config.exports.memory (exported)","or config.memory (imported)."),pointerSize:typeof s.exports.sqlite3_libversion()=="number"?4:8,bigIntEnabled:!!s.bigIntEnabled,functionTable:s.functionTable,alloc:void 0,realloc:void 0,dealloc:void 0}),c.allocFromTypedArray=function(d){d instanceof ArrayBuffer&&(d=new Uint8Array(d)),D(d);const y=c.alloc(d.byteLength||1);return c.heapForSize(d.constructor).set(d.byteLength?d:[0],Number(y)),y};{const d=s.allocExportName,y=s.deallocExportName,P=s.reallocExportName;for(const Q of[d,y,P])c.exports[Q]instanceof Function||S("Missing required exports[",Q,"] function.");c.alloc=function Q(F){return Q.impl(F)||A.toss("Failed to allocate",F," bytes.")},c.alloc.impl=c.exports[d],c.realloc=function Q(F,X){const ee=Q.impl(c.ptr.coerce(F),X);return X?ee||A.toss("Failed to reallocate",X," bytes."):c.ptr.null},c.realloc.impl=c.exports[P],c.dealloc=function Q(F){Q.impl(c.ptr.coerce(F))},c.dealloc.impl=c.exports[y]}c.compileOptionUsed=function d(y){if(arguments.length){if(Array.isArray(y)){const P=r();return y.forEach(Q=>{P[Q]=_.sqlite3_compileoption_used(Q)}),P}else if(typeof y=="object")return Object.keys(y).forEach(P=>{y[P]=_.sqlite3_compileoption_used(P)}),y}else{if(d._result)return d._result;d._opt||(d._rx=/^([^=]+)=(.+)/,d._rxInt=/^-?\d+$/,d._opt=function(ee,Z){const te=d._rx.exec(ee);Z[0]=te?te[1]:ee,Z[1]=te?d._rxInt.test(te[2])?+te[2]:te[2]:!0});const P=r(),Q=[0,0];let F=0,X;for(;X=_.sqlite3_compileoption_get(F++);)d._opt(X,Q),P[Q[0]]=Q[1];return d._result=P}return typeof y=="string"?!!_.sqlite3_compileoption_used(y):!1},c.pstack=r({restore:c.exports.sqlite3__wasm_pstack_restore,alloc:function(d){return typeof d=="string"&&!(d=c.sizeofIR(d))&&A.toss("Invalid value for pstack.alloc(",arguments[0],")"),c.exports.sqlite3__wasm_pstack_alloc(d)||A.toss("Could not allocate",d,"bytes from the pstack.")},allocChunks:function(d,y){typeof y=="string"&&!(y=c.sizeofIR(y))&&A.toss("Invalid size value for allocChunks(",arguments[1],")");const P=c.pstack.alloc(d*y),Q=[P];let F=1,X=y;for(;Fd===1?c.pstack.alloc(y?8:c.ptr.size):c.pstack.allocChunks(d,y?8:c.ptr.size),call:function(d){const y=c.pstack.pointer;try{return d(J)}finally{c.pstack.restore(y)}}}),Object.defineProperties(c.pstack,{pointer:{configurable:!1,iterable:!0,writeable:!1,get:c.exports.sqlite3__wasm_pstack_ptr},quota:{configurable:!1,iterable:!0,writeable:!1,get:c.exports.sqlite3__wasm_pstack_quota},remaining:{configurable:!1,iterable:!0,writeable:!1,get:c.exports.sqlite3__wasm_pstack_remaining}}),_.sqlite3_randomness=(...d)=>{if(d.length===1&&N.isTypedArray(d[0])&&d[0].BYTES_PER_ELEMENT===1){const y=d[0];if(y.byteLength===0)return c.exports.sqlite3_randomness(0,c.ptr.null),y;const P=c.pstack.pointer;try{let Q=y.byteLength,F=0;const X=c.exports.sqlite3_randomness,ee=c.heap8u(),Z=Q<512?Q:512,te=c.pstack.alloc(Z);do{const E=Q>Z?Z:Q;X(E,te),y.set(c.typedArrayPart(ee,te,c.ptr.add(te,E)),F),Q-=E,F+=E}while(Q>0)}catch(Q){s.error("Highly unexpected (and ignored!) exception in sqlite3_randomness():",Q)}finally{c.pstack.restore(P)}return y}c.exports.sqlite3_randomness(...d)},_.sqlite3_wasmfs_opfs_dir=(function(){if(this.dir!==void 0)return this.dir;const d=s.wasmfsOpfsDir;if(!d||!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!c.exports.sqlite3__wasm_init_wasmfs)return this.dir="";try{return d&&c.xCallWrapped("sqlite3__wasm_init_wasmfs","i32",["string"],d)===0?this.dir=d:this.dir=""}catch{return this.dir=""}}).bind(r()),_.sqlite3_wasmfs_filename_is_persistent=function(d){const y=_.sqlite3_wasmfs_opfs_dir();return y&&d?d.startsWith(y+"/"):!1},_.sqlite3_js_db_uses_vfs=function(d,y,P=0){try{const Q=_.sqlite3_vfs_find(y);return Q?d?Q===_.sqlite3_js_db_vfs(d,P)?Q:!1:Q===_.sqlite3_vfs_find(0)?Q:!1:!1}catch{return!1}},_.sqlite3_js_vfs_list=function(){const d=[];let y=_.sqlite3_vfs_find(c.ptr.null);for(;y;){const P=new _.sqlite3_vfs(y);d.push(c.cstrToJs(P.$zName)),y=P.$pNext,P.dispose()}return d},_.sqlite3_js_db_export=function(d,y=0){d=c.xWrap.testConvertArg("sqlite3*",d),d||S("Invalid sqlite3* argument."),c.bigIntEnabled||S("BigInt support is not enabled.");const P=c.scopedAllocPush();let Q;try{const F=c.scopedAlloc(8+c.ptr.size),X=c.ptr.add(F,8),ee=y?c.isPtr(y)?y:c.scopedAllocCString(""+y):c.ptr.null;let Z=c.exports.sqlite3__wasm_db_serialize(d,ee,X,F,0);Z&&S("Database serialization failed with code",J.capi.sqlite3_js_rc_str(Z)),Q=c.peekPtr(X);const te=c.peek(F,"i64");return Z=te?c.heap8u().slice(Number(Q),Number(Q)+Number(te)):new Uint8Array,Z}finally{Q&&c.exports.sqlite3_free(Q),c.scopedAllocPop(P)}},_.sqlite3_js_db_vfs=(d,y=c.ptr.null)=>N.sqlite3__wasm_db_vfs(d,y),_.sqlite3_js_aggregate_context=(d,y)=>_.sqlite3_aggregate_context(d,y)||(y?A.toss("Cannot allocate",y,"bytes for sqlite3_aggregate_context()"):0),_.sqlite3_js_posix_create_file=function(d,y,P){let Q;y&&c.isPtr(y)?Q=y:y instanceof ArrayBuffer||y instanceof Uint8Array?(Q=c.allocFromTypedArray(y),(arguments.length<3||!N.isInt32(P)||P<0)&&(P=y.byteLength)):I.toss("Invalid 2nd argument for sqlite3_js_posix_create_file().");try{(!N.isInt32(P)||P<0)&&I.toss("Invalid 3rd argument for sqlite3_js_posix_create_file().");const F=N.sqlite3__wasm_posix_create_file(d,Q,P);F&&I.toss("Creation of file failed with sqlite3 result code",_.sqlite3_js_rc_str(F))}finally{Q&&Q!==y&&c.dealloc(Q)}},_.sqlite3_js_vfs_create_file=function(d,y,P,Q){s.warn("sqlite3_js_vfs_create_file() is deprecated and","should be avoided because it can lead to C-level crashes.","See its documentation for alternatives.");let F;P?c.isPtr(P)?F=P:(P instanceof ArrayBuffer&&(P=new Uint8Array(P)),P instanceof Uint8Array?(F=c.allocFromTypedArray(P),(arguments.length<4||!N.isInt32(Q)||Q<0)&&(Q=P.byteLength)):I.toss("Invalid 3rd argument type for sqlite3_js_vfs_create_file().")):F=0,(!N.isInt32(Q)||Q<0)&&(F&&F!==P&&c.dealloc(F),I.toss("Invalid 4th argument for sqlite3_js_vfs_create_file()."));try{const X=N.sqlite3__wasm_vfs_create_file(d,y,F,Q);X&&I.toss("Creation of file failed with sqlite3 result code",_.sqlite3_js_rc_str(X))}finally{F&&F!==P&&c.dealloc(F)}},_.sqlite3_js_sql_to_string=d=>{if(typeof d=="string")return d;const y=U(v);return y===v?void 0:y},_.sqlite3_db_config=(function(d,y,...P){switch(y){case _.SQLITE_DBCONFIG_ENABLE_FKEY:case _.SQLITE_DBCONFIG_ENABLE_TRIGGER:case _.SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER:case _.SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION:case _.SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE:case _.SQLITE_DBCONFIG_ENABLE_QPSG:case _.SQLITE_DBCONFIG_TRIGGER_EQP:case _.SQLITE_DBCONFIG_RESET_DATABASE:case _.SQLITE_DBCONFIG_DEFENSIVE:case _.SQLITE_DBCONFIG_WRITABLE_SCHEMA:case _.SQLITE_DBCONFIG_LEGACY_ALTER_TABLE:case _.SQLITE_DBCONFIG_DQS_DML:case _.SQLITE_DBCONFIG_DQS_DDL:case _.SQLITE_DBCONFIG_ENABLE_VIEW:case _.SQLITE_DBCONFIG_LEGACY_FILE_FORMAT:case _.SQLITE_DBCONFIG_TRUSTED_SCHEMA:case _.SQLITE_DBCONFIG_STMT_SCANSTATUS:case _.SQLITE_DBCONFIG_REVERSE_SCANORDER:case _.SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE:case _.SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE:case _.SQLITE_DBCONFIG_ENABLE_COMMENTS:case _.SQLITE_DBCONFIG_FP_DIGITS:return this.ip||(this.ip=c.xWrap("sqlite3__wasm_db_config_ip","int",["sqlite3*","int","int","*"])),this.ip(d,y,P[0],P[1]||0);case _.SQLITE_DBCONFIG_LOOKASIDE:return this.pii||(this.pii=c.xWrap("sqlite3__wasm_db_config_pii","int",["sqlite3*","int","*","int","int"])),this.pii(d,y,P[0],P[1],P[2]);case _.SQLITE_DBCONFIG_MAINDBNAME:return this.s||(this.s=c.xWrap("sqlite3__wasm_db_config_s","int",["sqlite3*","int","string:static"])),this.s(d,y,P[0]);default:return _.SQLITE_MISUSE}}).bind(r()),_.sqlite3_value_to_js=function(d,y=!0){let P;const Q=_.sqlite3_value_type(d);switch(Q){case _.SQLITE_INTEGER:c.bigIntEnabled?(P=_.sqlite3_value_int64(d),N.bigIntFitsDouble(P)&&(P=Number(P))):P=_.sqlite3_value_double(d);break;case _.SQLITE_FLOAT:P=_.sqlite3_value_double(d);break;case _.SQLITE_TEXT:P=_.sqlite3_value_text(d);break;case _.SQLITE_BLOB:{const F=_.sqlite3_value_bytes(d),X=_.sqlite3_value_blob(d);F&&!X&&J.WasmAllocError.toss("Cannot allocate memory for blob argument of",F,"byte(s)"),P=F?c.heap8u().slice(Number(X),Number(X)+Number(F)):null;break}case _.SQLITE_NULL:P=null;break;default:y&&S(_.SQLITE_MISMATCH,"Unhandled sqlite3_value_type():",Q),P=void 0}return P},_.sqlite3_values_to_js=function(d,y,P=!0){let Q;const F=[];for(Q=0;Qd(y,P,"sqlite3_preupdate_new"),_.sqlite3_preupdate_old_js=(y,P)=>d(y,P,"sqlite3_preupdate_old"),_.sqlite3changeset_new_js=(y,P)=>d(y,P,"sqlite3changeset_new"),_.sqlite3changeset_old_js=(y,P)=>d(y,P,"sqlite3changeset_old")}_.sqlite3_js_retry_busy=function(d,y,P){for(let Q=1;Q<=d;++Q)try{P&&Q>1&&P(Q);const F=y();if(_.SQLITE_BUSY===F){if(Q===d)throw new I(F,["sqlite3_js_retry_busy() max retry attempts (",d,") reached."].join(""));continue}return F}catch(F){if(Q(J.__isUnderTest||(delete J.util,delete J.StructBinder,delete J.opfs),J),Q=X=>{throw s.error("an async sqlite3 initializer failed:",X),X};if(!y||!y.length)return d.isReady=P().catch(Q);y=y.map(X=>X instanceof Function?async ee=>X(J):X),y.push(P);let F=Promise.resolve(J);for(;y.length;)F=F.then(y.shift());return d.isReady=F.catch(Q)}).bind(i),scriptInfo:void 0};typeof l<"u"&&(J.__isUnderTest=!!l);try{i.initializers.forEach(d=>{d(J)})}catch(d){throw console.error("sqlite3 bootstrap initializer threw:",d),d}if(delete i.initializers,i.sqlite3=J,typeof e<"u"&&(e.debugModule("sqlite3ApiBootstrap() complete",J),J.scriptInfo=e),J.__isUnderTest){typeof t<"u"&&(J.config.emscripten=t);const d=J.scriptInfo?.instantiateWasm;d&&(J.wasm.module=d.module,J.wasm.instance=d.instance,J.wasm.imports=d.imports)}return delete globalThis.sqlite3ApiConfig,delete globalThis.sqlite3ApiBootstrap,delete i.defaultConfig,J.asyncPostInit().then(d=>(typeof e<"u"&&e.debugModule("sqlite3.asyncPostInit() complete",d),delete d.asyncPostInit,delete d.scriptInfo,delete d.emscripten,d))},globalThis.sqlite3ApiBootstrap.initializers=[],globalThis.sqlite3ApiBootstrap.initializersAsync=[],globalThis.sqlite3ApiBootstrap.defaultConfig=Object.create(null),globalThis.sqlite3ApiBootstrap.sqlite3=void 0,globalThis.sqlite3ApiBootstrap.initializers.push(function(i){i.version={libVersion:"3.53.0",libVersionNumber:3053e3,sourceId:"2026-04-09 11:41:38 4525003a53a7fc63ca75c59b22c79608659ca12f0131f52c18637f829977f20b",downloadVersion:353e4,scm:{"sha3-256":"4525003a53a7fc63ca75c59b22c79608659ca12f0131f52c18637f829977f20b",branch:"trunk",tags:"release major-release version-3.53.0",datetime:"2026-04-09T11:41:38.498Z"}}}),globalThis.WhWasmUtilInstaller=function(n){n.bigIntEnabled===void 0&&(n.bigIntEnabled=!!globalThis.BigInt64Array);const r=(...o)=>{throw new Error(o.join(" "))};if(!n.pointerSize&&!n.pointerIR&&n.alloc&&n.dealloc){const o=n.alloc(1);n.pointerSize=typeof o=="bigint"?8:4,n.dealloc(o)}n.pointerSize&&!n.pointerIR&&(n.pointerIR=n.pointerSize===4?"i32":"i64");const s=n.pointerIR??="i32",_=n.pointerSize??=s==="i32"?4:s==="i64"?8:0;delete n.pointerSize,delete n.pointerIR,s!=="i32"&&s!=="i64"?r("Invalid pointerIR:",s):_!==8&&_!==4&&r("Invalid pointerSize:",_);const c=n.bigIntEnabled?o=>BigInt(o||0):o=>r("BigInt support is disabled in this build."),M=_===4?o=>Number(o||0):c,I=M(0),S=function(...o){let u=M(0);for(const p of o)u+=M(p);return u};{const o=Object.create(null);Object.defineProperty(n,"ptr",{enumerable:!0,get:()=>o,set:()=>r("The ptr property is read-only.")}),(function u(p,q){return Object.defineProperty(o,p,{enumerable:!0,get:()=>q,set:()=>r("ptr["+p+"] is read-only.")}),u})("null",I)("size",_)("ir",s)("coerce",M)("add",S)("addn",s===4?S:(...u)=>Number(S(...u)))}n.exports||Object.defineProperty(n,"exports",{enumerable:!0,configurable:!0,get:()=>n.instance?.exports});const w=Object.create(null);w.heapSize=0,w.memory=null,w.freeFuncIndexes=[],w.scopedAlloc=[],w.scopedAlloc.pushPtr=o=>(w.scopedAlloc[w.scopedAlloc.length-1].push(o),o),w.utf8Decoder=new TextDecoder,w.utf8Encoder=new TextEncoder("utf-8"),n.sizeofIR=o=>{switch(o){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 _;default:return(""+o).endsWith("*")?_:void 0}};const x=function(){if(!w.memory)w.memory=n.memory instanceof WebAssembly.Memory?n.memory:n.exports.memory;else if(w.heapSize===w.memory.buffer.byteLength)return w;const o=w.memory.buffer;return w.HEAP8=new Int8Array(o),w.HEAP8U=new Uint8Array(o),w.HEAP16=new Int16Array(o),w.HEAP16U=new Uint16Array(o),w.HEAP32=new Int32Array(o),w.HEAP32U=new Uint32Array(o),w.HEAP32F=new Float32Array(o),w.HEAP64F=new Float64Array(o),n.bigIntEnabled&&(typeof BigInt64Array<"u"?(w.HEAP64=new BigInt64Array(o),w.HEAP64U=new BigUint64Array(o)):r("BigInt support is enabled, but the BigInt64Array type is missing.")),w.heapSize=o.byteLength,w};n.heap8=()=>x().HEAP8,n.heap8u=()=>x().HEAP8U,n.heap16=()=>x().HEAP16,n.heap16u=()=>x().HEAP16U,n.heap32=()=>x().HEAP32,n.heap32u=()=>x().HEAP32U,n.heapForSize=function(o,u=!0){const p=w.memory&&w.heapSize===w.memory.buffer.byteLength?w:x();switch(o){case Int8Array:return p.HEAP8;case Uint8Array:return p.HEAP8U;case Int16Array:return p.HEAP16;case Uint16Array:return p.HEAP16U;case Int32Array:return p.HEAP32;case Uint32Array:return p.HEAP32U;case 8:return u?p.HEAP8U:p.HEAP8;case 16:return u?p.HEAP16U:p.HEAP16;case 32:return u?p.HEAP32U:p.HEAP32;case 64:if(p.HEAP64)return u?p.HEAP64U:p.HEAP64;break;default:if(n.bigIntEnabled){if(o===globalThis.BigUint64Array)return p.HEAP64U;if(o===globalThis.BigInt64Array)return p.HEAP64;break}}r("Invalid heapForSize() size: expecting 8, 16, 32,","or (if BigInt is enabled) 64.")};const L=n.functionTable;delete n.functionTable,n.functionTable=L?()=>L:()=>n.exports.__indirect_function_table,n.functionEntry=function(o){const u=n.functionTable();return o{C<128?R[g](C):R[g](C%128|128,C>>7)},rxJSig:/^(\w)\((\w*)\)$/,sigParams:R=>{const g=o._.rxJSig.exec(R);return g?g[2]:R.substr(1)},letterType:R=>o._.sigTypes[R]||r("Invalid signature letter:",R),pushSigType:(R,g)=>R.push(o._.typeCodes[o._.letterType(g)])}),typeof u=="string"){const R=p;p=u,u=R}const q=o._,z=q.sigParams(p),H=[1,96];q.uleb128Encode(H,"push",z.length);for(const R of z)q.pushSigType(H,R);return p[0]==="v"?H.push(0):(H.push(1),q.pushSigType(H,p[0])),q.uleb128Encode(H,"unshift",H.length),H.unshift(0,97,115,109,1,0,0,0,1),H.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(H)),{e:{f:u}}).exports.f};const V=function(u,p,q){if(q&&!w.scopedAlloc.length&&r("No scopedAllocPush() scope is active."),typeof u=="string"){const g=p;p=u,u=g}(typeof p!="string"||!(u instanceof Function))&&r("Invalid arguments: expecting (function,signature) or (signature,function).");const z=n.functionTable(),H=M(z.length);let R;for(;(R=w.freeFuncIndexes.pop())&&z.get(R);){R=null;continue}R||(R=M(H),z.grow(M(1)));try{return z.set(R,u),q&&w.scopedAlloc.pushPtr(R),R}catch(g){if(!(g instanceof TypeError))throw R===H&&w.freeFuncIndexes.push(H),g}try{const g=n.jsFuncToWasm(u,p);z.set(R,g),q&&w.scopedAlloc.pushPtr(R)}catch(g){throw R===H&&w.freeFuncIndexes.push(H),g}return R};n.installFunction=(o,u)=>V(o,u,!1),n.scopedInstallFunction=(o,u)=>V(o,u,!0),n.uninstallFunction=function(o){if(!o&&I!==o)return;const u=n.functionTable();w.freeFuncIndexes.push(o);const p=u.get(o);return u.set(o,null),p},n.peek=function(u,p="i8"){p.endsWith("*")&&(p=s);const q=w.memory&&w.heapSize===w.memory.buffer.byteLength?w:x(),z=Array.isArray(u)?[]:void 0;let H;do{switch(z&&(u=arguments[0].shift()),p){case"i1":case"i8":H=q.HEAP8[Number(u)>>0];break;case"i16":H=q.HEAP16[Number(u)>>1];break;case"i32":H=q.HEAP32[Number(u)>>2];break;case"float":case"f32":H=q.HEAP32F[Number(u)>>2];break;case"double":case"f64":H=Number(q.HEAP64F[Number(u)>>3]);break;case"i64":if(q.HEAP64){H=c(q.HEAP64[Number(u)>>3]);break}default:r("Invalid type for peek():",p)}z&&z.push(H)}while(z&&arguments[0].length);return z||H},n.poke=function(o,u,p="i8"){p.endsWith("*")&&(p=s);const q=w.memory&&w.heapSize===w.memory.buffer.byteLength?w:x();for(const z of Array.isArray(o)?o:[o])switch(p){case"i1":case"i8":q.HEAP8[Number(z)>>0]=u;continue;case"i16":q.HEAP16[Number(z)>>1]=u;continue;case"i32":q.HEAP32[Number(z)>>2]=u;continue;case"float":case"f32":q.HEAP32F[Number(z)>>2]=u;continue;case"double":case"f64":q.HEAP64F[Number(z)>>3]=u;continue;case"i64":if(q.HEAP64){q.HEAP64[Number(z)>>3]=c(u);continue}default:r("Invalid type for poke(): "+p)}return this},n.peekPtr=(...o)=>n.peek(o.length===1?o[0]:o,s),n.pokePtr=(o,u=0)=>n.poke(o,u,s),n.peek8=(...o)=>n.peek(o.length===1?o[0]:o,"i8"),n.poke8=(o,u)=>n.poke(o,u,"i8"),n.peek16=(...o)=>n.peek(o.length===1?o[0]:o,"i16"),n.poke16=(o,u)=>n.poke(o,u,"i16"),n.peek32=(...o)=>n.peek(o.length===1?o[0]:o,"i32"),n.poke32=(o,u)=>n.poke(o,u,"i32"),n.peek64=(...o)=>n.peek(o.length===1?o[0]:o,"i64"),n.poke64=(o,u)=>n.poke(o,u,"i64"),n.peek32f=(...o)=>n.peek(o.length===1?o[0]:o,"f32"),n.poke32f=(o,u)=>n.poke(o,u,"f32"),n.peek64f=(...o)=>n.peek(o.length===1?o[0]:o,"f64"),n.poke64f=(o,u)=>n.poke(o,u,"f64"),n.getMemValue=n.peek,n.getPtrValue=n.peekPtr,n.setMemValue=n.poke,n.setPtrValue=n.pokePtr,n.isPtr32=o=>typeof o=="number"&&o>=0&&o===(o|0),n.isPtr64=o=>typeof o=="bigint"?o>=0:n.isPtr32(o),n.isPtr=_===4?n.isPtr32:n.isPtr64,n.cstrlen=function(o){if(!o||!n.isPtr(o))return null;o=Number(o);const u=x().HEAP8U;let p=o;for(;u[p]!==0;++p);return p-o};const b=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,h=o=>o.buffer instanceof b;n.isSharedTypedArray=h;const D=(o,u,p)=>(_===8&&(typeof u=="bigint"&&(u=Number(u)),typeof p=="bigint"&&(p=Number(p))),h(o)?o.slice(u,p):o.subarray(u,p));n.typedArrayPart=D;const U=(o,u,p)=>w.utf8Decoder.decode(D(o,u,p));n.typedArrayToString=U,n.cstrToJs=function(o){const u=n.cstrlen(o);return u?U(x().HEAP8U,Number(o),Number(o)+u):u===null?u:""},n.jstrlen=function(o){if(typeof o!="string")return null;const u=o.length;let p=0;for(let q=0;q=55296&&z<=57343&&(z=65536+((z&1023)<<10)|o.charCodeAt(++q)&1023),z<=127?++p:z<=2047?p+=2:z<=65535?p+=3:p+=4}return p},n.jstrcpy=function(o,u,p=0,q=-1,z=!0){if((!u||!(u instanceof Int8Array)&&!(u instanceof Uint8Array))&&r("jstrcpy() target must be an Int8Array or Uint8Array."),q=Number(q),p=Number(p),q<0&&(q=u.length-p),!(q>0)||!(p>=0))return 0;let H=0,R=o.length;const g=p,C=p+q-(z?1:0);for(;H=55296&&B<=57343&&(B=65536+((B&1023)<<10)|o.charCodeAt(++H)&1023),B<=127){if(p>=C)break;u[p++]=B}else if(B<=2047){if(p+1>=C)break;u[p++]=192|B>>6,u[p++]=128|B&63}else if(B<=65535){if(p+2>=C)break;u[p++]=224|B>>12,u[p++]=128|B>>6&63,u[p++]=128|B&63}else{if(p+3>=C)break;u[p++]=240|B>>18,u[p++]=128|B>>12&63,u[p++]=128|B>>6&63,u[p++]=128|B&63}}return z&&(u[p++]=0),p-g},n.cstrncpy=function(o,u,p){if((!o||!u)&&r("cstrncpy() does not accept NULL strings."),p<0)p=n.cstrlen(strPtr)+1;else if(!(p>0))return 0;const q=n.heap8u();let z=0,H;const R=Number(o),g=Number(u);for(;zw.utf8Encoder.encode(u?o+"\0":o);const A=(o,u)=>{(!(o.alloc instanceof Function)||!(o.dealloc instanceof Function))&&r("Object is missing alloc() and/or dealloc() function(s)","required by",u+"().")},N=function(o,u,p,q){if(A(n,q),typeof o!="string")return null;const z=w.utf8Encoder.encode(o),H=p(z.length+1);let R=H;try{const g=x().HEAP8U;return g.set(z,Number(H)),g[S(H,z.length)]=0,R=I,u?[H,z.length]:H}finally{R&&n.dealloc(R)}};n.allocCString=(o,u=!1)=>N(o,u,n.alloc,"allocCString()"),n.scopedAllocPush=function(){A(n,"scopedAllocPush");const o=[];return w.scopedAlloc.push(o),o},n.scopedAllocPop=function(o){A(n,"scopedAllocPop");const u=arguments.length?w.scopedAlloc.indexOf(o):w.scopedAlloc.length-1;u<0&&r("Invalid state object for scopedAllocPop()."),arguments.length===0&&(o=w.scopedAlloc[u]),w.scopedAlloc.splice(u,1);for(let p;p=o.pop();)n.functionEntry(p)?n.uninstallFunction(p):n.dealloc(p)},n.scopedAlloc=function(o){w.scopedAlloc.length||r("No scopedAllocPush() scope is active.");const u=M(n.alloc(o));return w.scopedAlloc.pushPtr(u)},Object.defineProperty(n.scopedAlloc,"level",{configurable:!1,enumerable:!1,get:()=>w.scopedAlloc.length,set:()=>r("The 'active' property is read-only.")}),n.scopedAllocCString=(o,u=!1)=>N(o,u,n.scopedAlloc,"scopedAllocCString()");const J=function(o,u){const p=n[o?"scopedAlloc":"alloc"]((u.length+1)*n.ptr.size);let q=0;return u.forEach(z=>{n.pokePtr(S(p,n.ptr.size*q++),n[o?"scopedAllocCString":"allocCString"](""+z))}),n.pokePtr(S(p,n.ptr.size*q),0),p};n.scopedAllocMainArgv=o=>J(!0,o),n.allocMainArgv=o=>J(!1,o),n.cArgvToJs=(o,u)=>{const p=[];for(let q=0;qd(o,u,"alloc"),n.scopedAllocPtr=(o=1,u=!0)=>d(o,u,"scopedAlloc"),n.xGet=function(o){return n.exports[o]||r("Cannot find exported symbol:",o)};const y=(o,u)=>r(o+"() requires",u,"argument(s).");n.xCall=function(o,...u){const p=o instanceof Function?o:n.xGet(o);return p instanceof Function||r("Exported symbol",o,"is not a function."),p.length!==u.length&&y(p===o?p.name:o,p.length),arguments.length===2&&Array.isArray(arguments[1])?p.apply(null,arguments[1]):p.apply(null,u)},w.xWrap=Object.create(null),w.xWrap.convert=Object.create(null),w.xWrap.convert.arg=new Map,w.xWrap.convert.result=new Map;const P=w.xWrap.convert.arg,Q=w.xWrap.convert.result,F=M;P.set("i64",c).set("i32",o=>o|0).set("i16",o=>(o|0)&65535).set("i8",o=>(o|0)&255).set("f32",o=>Number(o).valueOf()).set("float",P.get("f32")).set("f64",P.get("f32")).set("double",P.get("f64")).set("int",P.get("i32")).set("null",o=>o).set(null,P.get("null")).set("**",F).set("*",F),Q.set("*",F).set("pointer",F).set("number",o=>Number(o)).set("void",o=>{}).set(void 0,Q.get("void")).set("null",o=>o).set(null,Q.get("null"));for(const o of["i8","i16","i32","i64","int","f32","float","f64","double"])P.set(o+"*",F),Q.set(o+"*",F),Q.set(o,P.get(o)||r("Maintenance required: missing arg converter for",o));const X=o=>typeof o=="string"?n.scopedAllocCString(o):M(o);P.set("string",X).set("utf8",X),Q.set("string",o=>n.cstrToJs(o)).set("utf8",Q.get("string")).set("string:dealloc",o=>{try{return o?n.cstrToJs(o):null}finally{n.dealloc(o)}}).set("utf8:dealloc",Q.get("string:dealloc")).set("json",o=>JSON.parse(n.cstrToJs(o))).set("json:dealloc",o=>{try{return o?JSON.parse(n.cstrToJs(o)):null}finally{n.dealloc(o)}});const ee=class{constructor(o){this.name=o.name||"unnamed adapter"}convertArg(o,u,p){r("AbstractArgAdapter must be subclassed.")}};P.FuncPtrAdapter=class Ue extends ee{constructor(u){super(u),P.FuncPtrAdapter.warnOnUse&&console.warn("xArg.FuncPtrAdapter is an internal-only API","and is not intended to be invoked from","client-level code. Invoked with:",u),this.name=u.name||"unnamed",this.signature=u.signature,u.contextKey instanceof Function&&(this.contextKey=u.contextKey,u.bindScope||(u.bindScope="context")),this.bindScope=u.bindScope||r("FuncPtrAdapter options requires a bindScope (explicit or implied)."),Ue.bindScopes.indexOf(u.bindScope)<0&&r("Invalid options.bindScope ("+u.bindMod+") for FuncPtrAdapter. Expecting one of: ("+Ue.bindScopes.join(", ")+")"),this.isTransient=this.bindScope==="transient",this.isContext=this.bindScope==="context",this.isPermanent=this.bindScope==="permanent",this.singleton=this.bindScope==="singleton"?[]:void 0,this.callProxy=u.callProxy instanceof Function?u.callProxy:void 0}contextKey(u,p){return this}contextMap(u){const p=this.__cmap||(this.__cmap=new Map);let q=p.get(u);return q===void 0&&p.set(u,q=[]),q}convertArg(u,p,q){let z=this.singleton;if(!z&&this.isContext&&(z=this.contextMap(this.contextKey(p,q))),z&&z.length===2&&z[0]===u)return z[1];if(u instanceof Function){this.callProxy&&(u=this.callProxy(u));const H=V(u,this.signature,this.isTransient);if(Ue.debugFuncInstall&&Ue.debugOut("FuncPtrAdapter installed",this,this.contextKey(p,q),"@"+H,u),z){if(z[1]){Ue.debugFuncInstall&&Ue.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(p,q),"@"+z[1],u);try{w.scopedAlloc.pushPtr(z[1])}catch{}}z[0]=arguments[0]||I,z[1]=H}return H}else if(n.isPtr(u)||u===null||u===void 0){if(z&&z[1]&&z[1]!==u){Ue.debugFuncInstall&&Ue.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(p,q),"@"+z[1],u);try{w.scopedAlloc.pushPtr(z[1])}catch{}z[0]=z[1]=u||I}return u||I}else throw new TypeError("Invalid FuncPtrAdapter argument type. Expecting a function pointer or a "+(this.name?this.name+" ":"")+"function matching signature "+this.signature+".")}},P.FuncPtrAdapter.warnOnUse=!1,P.FuncPtrAdapter.debugFuncInstall=!1,P.FuncPtrAdapter.debugOut=console.debug.bind(console),P.FuncPtrAdapter.bindScopes=["transient","context","singleton","permanent"];const Z=o=>P.get(o)||r("Argument adapter not found:",o),te=o=>Q.get(o)||r("Result adapter not found:",o);w.xWrap.convertArg=(o,...u)=>Z(o)(...u),w.xWrap.convertArgNoCheck=(o,...u)=>P.get(o)(...u),w.xWrap.convertResult=(o,u)=>o===null?u:o?te(o)(u):void 0,w.xWrap.convertResultNoCheck=(o,u)=>o===null?u:o?Q.get(o)(u):void 0,n.xWrap=function o(u,p,...q){arguments.length===3&&Array.isArray(arguments[2])&&(q=arguments[2]),n.isPtr(u)&&(u=n.functionEntry(u)||r("Function pointer not found in WASM function table."));const z=u instanceof Function,H=z?u:n.xGet(u);if(z&&(u=H.name||"unnamed function"),q.length!==H.length&&y(u,H.length),H.length===0&&(p===null||p==="null"))return H;te(p);for(const g of q)g instanceof ee?P.set(g,(...C)=>g.convertArg(...C)):Z(g);const R=w.xWrap;return H.length===0?(...g)=>g.length?y(u,H.length):R.convertResult(p,H.call(null)):function(...g){g.length!==H.length&&y(u,H.length);const C=n.scopedAllocPush();try{let B=0;for(o.debug&&console.debug("xWrap() preparing: resultType ",p,"xf",H,"argTypes",q,"args",g);Bfetch(n.uri,{credentials:"same-origin"}),s=this,_=function(c){if(n.wasmUtilTarget){const m=(...I)=>{throw new Error(I.join(" "))},M=n.wasmUtilTarget;if(M.module=c.module,M.instance=c.instance,M.instance.exports.memory||(M.memory=n?.imports?.env?.memory||m("Missing 'memory' object!")),!M.alloc&&c.instance.exports.malloc){const I=c.instance.exports;M.alloc=function(S){return I.malloc(S)||m("Allocation of",S,"bytes failed.")},M.dealloc=function(S){S&&I.free(S)}}s(M)}return c.config=n,n.onload&&n.onload(c),c};return WebAssembly.instantiateStreaming?()=>WebAssembly.instantiateStreaming(r(),n.imports||{}).then(_):()=>r().then(c=>c.arrayBuffer()).then(c=>WebAssembly.instantiate(c,n.imports||{})).then(_)}).bind(globalThis.WhWasmUtilInstaller),globalThis.Jaccwabyt=function i(n){const r=(...T)=>{throw new Error(T.join(" "))};{let T=n.heap;T instanceof WebAssembly.Memory?T=(function(){return new Uint8Array(this.buffer)}).bind(T):T instanceof Function||r("config.heap must be WebAssembly.Memory instance or","a function which returns one."),n.heap=T}["alloc","dealloc"].forEach(function(T){n[T]instanceof Function||r("Config option '"+T+"' must be a function.")});const s=i,_=n.heap,c=n.alloc,m=n.dealloc;n.realloc;const M=n.log||console.debug.bind(console),I=n.memberPrefix||"",S=n.memberSuffix||"",w=globalThis.BigInt,x=globalThis.BigInt64Array,L=n.bigIntEnabled??!!x;let V;const b=n.pointerSize||n.ptrSize||(typeof(V=c(1))=="bigint"?8:4),h=n.pointerIR||n.ptrIR||(b===4?"i32":"i64");V&&(m(V),V=void 0),b!==4&&b!==8&&r("Invalid pointer size:",b),h!=="i32"&&h!=="i64"&&r("Invalid pointer representation:",h);const D=L&&w?T=>w(T||0):T=>r("BigInt support is disabled in this build."),U=h=="i32"?Number:D,A=U(0),N=function(...T){let W=A;for(let K=0;KT[1]==="(",P=T=>T==="p"||T==="P"||T==="s",Q=T=>T==="P",F=T=>T?y(T)?"p":T[0]:void 0,X=function(T){switch(F(T)){case"c":case"C":return"i8";case"i":return"i32";case"p":case"P":case"s":return h;case"j":return"i64";case"f":return"float";case"d":return"double"}r("Unhandled signature IR:",T)},ee=function(T){switch(F(T)){case"c":case"C":return 1;case"i":return 4;case"p":case"P":case"s":return b;case"j":return 8;case"f":return 4;case"d":return 8}r("Unhandled signature sizeof:",T)},Z=x?()=>!0:()=>r("BigInt64Array is not available."),te=function(T){switch(F(T)){case"p":case"P":case"s":switch(b){case 4:return"getInt32";case 8:return Z()&&"getBigInt64"}break;case"i":return"getInt32";case"c":return"getInt8";case"C":return"getUint8";case"j":return Z()&&"getBigInt64";case"f":return"getFloat32";case"d":return"getFloat64"}r("Unhandled DataView getter for signature:",T)},E=function(T){switch(F(T)){case"p":case"P":case"s":switch(b){case 4:return"setInt32";case 8:return Z()&&"setBigInt64"}break;case"i":return"setInt32";case"c":return"setInt8";case"C":return"setUint8";case"j":return Z()&&"setBigInt64";case"f":return"setFloat32";case"d":return"setFloat64"}r("Unhandled DataView setter for signature:",T)},o=function(T){switch(F(T)){case"i":case"f":case"c":case"C":case"d":return Number;case"j":return D;case"p":case"P":case"s":switch(b){case 4:return Number;case 8:return D}break}r("Unhandled DataView set wrapper for signature:",T)},u=(T,W)=>T+"::"+W,p=function(T,W){return()=>r(u(T,W),"is read-only.")},q=function T(W,K=!0){let re=T.map.get(W);return!re&&K&&T.map.set(W,re=T.create(W)),re};q.map=new WeakMap,q.create=T=>Object.assign(Object.create(null),{o:T,p:void 0,ownsPointer:!1,zod:!1,xb:0});const z=T=>q.map.delete(T),H=T=>typeof T=="number"&&T===(T|0)&&T>=0,g=b===4?H:T=>typeof T=="bigint"&&T>=0||H(T),C=T=>g(T)&&T>0,B=function(T,W,K){const re=q(W,!1);if(re){if(z(W),!K&&!(K=re.p)){console.warn("Cannot(?) happen: __freeStruct() found no instanceInfo");return}if(Array.isArray(W.ondispose)){let ce;for(;ce=W.ondispose.pop();)try{ce instanceof Function?ce.call(W):ce instanceof Pe?ce.dispose():g(ce)&&m(ce)}catch(ye){console.warn("ondispose() for",T.structName,"@",K,"threw. NOT propagating it.",ye)}}else if(W.ondispose instanceof Function)try{W.ondispose()}catch(ce){console.warn("ondispose() for",T.structName,"@",K,"threw. NOT propagating it.",ce)}delete W.ondispose,T.debugFlags.__flags.dealloc&&M("debug.dealloc:",re.ownsPointer?"":"EXTERNAL",T.structName,"instance:",T.structInfo.sizeof,"bytes @"+K),re.ownsPointer&&((re.zod||T.structInfo.zeroOnDispose)&&_().fill(0,Number(K),Number(K)+T.structInfo.sizeof+re.xb),m(K))}},Y=()=>({configurable:!1,writable:!1,iterable:!1}),ne=T=>({...Y(),value:T}),le=function(W,K,re){let ce;const ye=ge=>{C(ge)||r("Invalid pointer value",arguments[0],"for",W.structName,"constructor.")};arguments.length>=3?re&&typeof re=="object"?(ce=re,re=ce?.wrap):(ye(re),ce={wrap:re}):ce={};const Te=!re;let Fe=0,Le=!1;if(re)ye(re),Le=!!ce?.takeOwnership;else{const ge=ce?.extraBytes??0;(ge<0||ge!==(ge|0))&&r("Invalid extraBytes value:",ce?.extraBytes),Fe=W.structInfo.sizeof+ge,re=c(Fe)||r("Allocation of",W.structName,"structure failed."),Le=!0}try{ce?.debugFlags&&K.debugFlags(ce.debugFlags),W.debugFlags.__flags.alloc&&M("debug.alloc:",Te?"":"EXTERNAL",W.structName,"instance:",W.structInfo.sizeof,"bytes @"+re),Te&&_().fill(0,Number(re),Number(re)+Fe);const ge=q(K);ge.p=re,ge.ownsPointer=Le,ge.xb=Fe?Fe-W.structInfo.sizeof:0,ge.zod=!!ce?.zeroOnDispose,ce?.ondispose&&ce.ondispose!==re&&K.addOnDispose(ce.ondispose)}catch(ge){throw B(W,K,re),ge}},ae=function T(W){return T.rxSig1??=/^[ipPsjfdcC]$/,T.rxSig2??=/^[vipPsjfdcC]\([ipPsjfdcC]*\)$/,T.rxSig1.test(W)||T.rxSig2.test(W)},be=(function(T){let W=this.get(T);return W||(W=[Object.create(null),Object.create(null),Object.create(null)],this.set(T,W)),W}).bind(new WeakMap),Ae=function(T,W,K,re){const ce=be(T)[W];return arguments.length===3?ce[K]:re?ce[K]=re:delete ce[K]},Re=function(T,...W){return Ae(this,0,T,...W)},Xe=function(T,W){ae(W)&&r(T,"(",W,") collides with a data type signature.")},O=function(T,...W){return Xe("Setter adaptor",T),Ae(this,1,T,...W)},j=function(T,...W){return Xe("Struct adaptor",T),Ae(this,2,T,...W)},G=function(T,W){const K=typeof W=="string"?Ae(T,2,W):W;return typeof K!="object"&&r("Invalid struct mapping object. Arg =",W,JSON.stringify(K)),K},ie=ne(T=>I+T+S),oe=function(T,W,K=!0){let re=T.members[W];if(!re&&(I||S)){for(const ce of Object.values(T.members))if(ce.key===W){re=ce;break}!re&&K&&r(u(T.name||T.structName,W),"is not a mapped struct member.")}return re},ue=function T(W,K,re=!1){T._||(T._=ye=>ye.replace(/[^vipPsjrdcC]/g,"").replace(/[pPscC]/g,"i"));const ce=oe(W.structInfo,K,!0);return re?T._(ce.signature):ce.signature},se=ne(function(){const T=[];for(const W of Object.keys(this.structInfo.members))T.push(this.memberKey(W));return T}),fe=new TextDecoder("utf-8"),me=new TextEncoder,Se=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,pe=function(T,W,K){return b===8&&(W=Number(W),K=Number(K)),fe.decode(T.buffer instanceof Se?T.slice(W,K):T.subarray(W,K))},Oe=function(T,W,K=!1){const re=oe(T.structInfo,W,K);return re&&re.signature.length===1&&re.signature[0]==="s"?re:!1},De=function(T){T.signature!=="s"&&r("Invalid member type signature for C-string value:",JSON.stringify(T))},nt=function(W,K){const re=oe(W.structInfo,K,!0);De(re);const ce=W[re.key];if(!ce)return null;let ye=ce;const Te=_();for(;Te[ye]!==0;++ye);return ce===ye?"":pe(Te,ce,ye)},Me=function(T,...W){T.ondispose?Array.isArray(T.ondispose)||(T.ondispose=[T.ondispose]):T.ondispose=[],T.ondispose.push(...W)},Ye=function(T){const W=me.encode(T),K=c(W.length+1);K||r("Allocation error while duplicating string:",T);const re=_();return re.set(W,Number(K)),re[N(K,W.length)]=0,K},ut=function(T,W,K){const re=oe(T.structInfo,W,!0);De(re);const ce=Ye(K);return T[re.key]=ce,Me(T,ce),T},Pe=function(W,K){arguments[2]!==ne&&r("Do not call the StructType constructor","from client-level code."),Object.defineProperties(this,{structName:ne(W),structInfo:ne(K)})};Pe.prototype=Object.create(null,{dispose:ne(function(){B(this.constructor,this)}),lookupMember:ne(function(T,W=!0){return oe(this.structInfo,T,W)}),memberToJsString:ne(function(T){return nt(this,T)}),memberIsString:ne(function(T,W=!0){return Oe(this,T,W)}),memberKey:ie,memberKeys:se,memberSignature:ne(function(T,W=!1){return ue(this,T,W)}),memoryDump:ne(function(){const T=this.pointer;return T?new Uint8Array(_().slice(Number(T),Number(T)+this.structInfo.sizeof)):null}),extraBytes:{configurable:!1,enumerable:!1,get:function(){return q(this,!1)?.xb??0}},zeroOnDispose:{configurable:!1,enumerable:!1,get:function(){return q(this,!1)?.zod??!!this.structInfo.zeroOnDispose}},pointer:{configurable:!1,enumerable:!1,get:function(){return q(this,!1)?.p},set:()=>r("Cannot assign the 'pointer' property of a struct.")},setMemberCString:ne(function(T,W){return ut(this,T,W)})}),Object.assign(Pe.prototype,{addOnDispose:function(...T){return Me(this,...T),this}}),Object.defineProperties(Pe,{allocCString:ne(Ye),isA:ne(T=>T instanceof Pe),hasExternalPointer:ne(T=>{const W=q(T,!1);return!!(W?.p&&!W?.ownsPointer)}),memberKey:ie});const mt=function(T){return T.get||(T.adaptGet?Ce.adaptGet(T.adaptGet):void 0)},Kt=function(T){return T.set||(T.adaptSet?Ce.adaptSet(T.adaptSet):void 0)},hr=function T(W,K,re){const ce=T.innerStructs??=new Map,ye=W.memberKey(K);re.signature!==void 0&&r("'signature' cannot be used on an embedded struct (",W.structName,".",ye,")."),Kt(re)&&r("'set' and 'adaptSet' are not permitted for nested struct members."),re.structName??=W.structName+"::"+K,re.key=ye,re.name=K,re.constructor=this.call(this,re.structName,re);const Te=mt(re),Fe=Object.assign(Object.create(null),{configurable:!1,enumerable:!1,set:p(W.structName,ye),get:function(){const Le=this.debugFlags.__flags,ge=this.pointer,ke=ge+"."+ye;let _e=ce.get(ke);return Le.getter&&M("debug.getter: k =",ke),_e||(_e=new re.constructor(N(ge,re.offset)),ce.set(ke,_e),this.addOnDispose(()=>_e.dispose()),_e.addOnDispose(()=>ce.delete(ke))),Te&&(_e=Te.apply(this,[_e,ye])),Le.getter&&M("debug.getter: result =",_e),_e}});Object.defineProperty(W.prototype,ye,Fe)},mr=function T(W,K,re){if(re=G(this,re),re.members)return hr.call(this,W,K,re);if(!T.cache){T.cache={getters:{},setters:{},sw:{}};const ke=["i","c","C","p","P","s","f","d","v()"];L&&ke.push("j"),ke.forEach(function(_e){T.cache.getters[_e]=te(_e),T.cache.setters[_e]=E(_e),T.cache.sw[_e]=o(_e)}),T.sigCheck=function(_e,Ie,gt,Xt){Object.prototype.hasOwnProperty.call(_e,gt)&&r(_e.structName,"already has a property named",gt+"."),ae(Xt)||r("Malformed signature for",u(_e.structName,Ie)+":",Xt)}}const ce=W.memberKey(K);T.sigCheck(W.prototype,K,ce,re.signature),re.key=ce,re.name=K;const ye=F(re.signature),Te=u(W.structName,ce),Fe=W.debugFlags.__flags,Le=mt(re),ge=Object.create(null);if(ge.configurable=!1,ge.enumerable=!1,ge.get=function(){Fe.getter&&M("debug.getter:",T.cache.getters[ye],"for",X(ye),Te,"@",this.pointer,"+",re.offset,"sz",re.sizeof);let ke=new DataView(_().buffer,Number(this.pointer)+re.offset,re.sizeof)[T.cache.getters[ye]](0,d);return Le&&(ke=Le.apply(this,[ce,ke])),Fe.getter&&M("debug.getter:",Te,"result =",ke),ke},re.readOnly)ge.set=p(W.prototype.structName,ce);else{const ke=Kt(re);ge.set=function(_e){Fe.setter&&M("debug.setter:",T.cache.setters[ye],"for",X(ye),Te,"@",this.pointer,"+",re.offset,"sz",re.sizeof,_e),this.pointer||r("Cannot set native property on a disposed",this.structName,"instance."),ke&&(_e=ke.apply(this,[ce,_e])),_e==null?_e=A:P(re.signature)&&!g(_e)&&(Q(re.signature)&&_e instanceof Pe?(_e=_e.pointer||A,Fe.setter&&M("debug.setter:",Te,"resolved to",_e)):r("Invalid value for pointer-type",Te+".")),new DataView(_().buffer,Number(this.pointer)+re.offset,re.sizeof)[T.cache.setters[ye]](0,T.cache.sw[ye](_e),d)}}Object.defineProperty(W.prototype,ce,ge)},Jt=function T(W,K,re=Object.create(null)){const ce=function _e(Ie){this instanceof _e||r("The",W,"constructor may only be called via 'new'."),le(_e,this,...arguments)},ye=this,Te=_e=>typeof _e=="string"&&ae(_e)?{signature:_e}:G(ye,_e);arguments.length===1?(K=Te(W),W=K.structName||K.name):arguments.length===2?(K=Te(K),K.name??=W):K=Te(K),W??=K.structName,W??=re.structName,W||r("One of 'name' or 'structName' are required."),K.adapt&&(Object.keys(K.adapt.struct||{}).forEach(_e=>{j.call(T,_e,K.adapt.struct[_e])}),Object.keys(K.adapt.set||{}).forEach(_e=>{O.call(T,_e,K.adapt.set[_e])}),Object.keys(K.adapt.get||{}).forEach(_e=>{Re.call(T,_e,K.adapt.get[_e])})),!K.members&&!K.sizeof&&(K.sizeof=ee(K.signature));const Fe=ne(s.__makeDebugFlags(Ce.debugFlags));Object.defineProperties(ce,{debugFlags:Fe,isA:ne(_e=>_e instanceof ce),memberKey:ie,memberKeys:se,structInfo:ne(K),structName:ne(W),ptrAdd:ne(N)}),ce.prototype=new Pe(W,K,ne),Object.defineProperties(ce.prototype,{debugFlags:Fe,constructor:ne(ce),ptrAdd:ne(J)});let Le=!1,ge=0;const ke=!!K.autoCalcSizeOffset;return ke||K.sizeof||r(W,"description is missing its sizeof property."),K.offset??=0,Object.keys(K.members||{}).forEach(_e=>{let Ie=Te(K.members[_e]);!Ie.members&&!Ie.sizeof&&(Ie.sizeof=ee(Ie.signature),Ie.sizeof||r(u(W,_e),"is missing a sizeof property.",Ie)),Ie.offset===void 0&&(ke?Ie.offset=ge:r(u(W,_e),"is missing its offset.",JSON.stringify(Ie))),K.members[_e]=Ie,(!Le||Le.offset{throw new Error(b.join(" "))},r=i.capi,s=i.wasm,_=i.util;globalThis.WhWasmUtilInstaller(s),delete globalThis.WhWasmUtilInstaller;const c={core:[["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_parameter_name","string","sqlite3_stmt*","int"],["sqlite3_bind_pointer","int","sqlite3_stmt*","int","*","string:static","*"],["sqlite3_bind_zeroblob","int","sqlite3_stmt*","int","int"],["sqlite3_busy_handler","int",["sqlite3*",new s.xWrap.FuncPtrAdapter({signature:"i(pi)",contextKey:(b,h)=>b[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_decltype","string","sqlite3_stmt*","int"],["sqlite3_column_double","f64","sqlite3_stmt*","int"],["sqlite3_column_int","int","sqlite3_stmt*","int"],["sqlite3_column_name","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 s.xWrap.FuncPtrAdapter({name:"sqlite3_commit_hook",signature:"i(p)",contextKey:b=>b[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_readonly","int","sqlite3*","string"],["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 s.xWrap.FuncPtrAdapter({signature:"i(pipp)",bindScope:"transient",callProxy:b=>{let h;return(D,U,A,N)=>{try{const J=s.cArgvToJs(U,A);return h||(h=s.cArgvToJs(U,N)),b(J,h)|0}catch(J){return J.resultCode||r.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_interrupt",void 0,"sqlite3*"],["sqlite3_is_interrupted","int","sqlite3*"],["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_next_stmt","sqlite3_stmt*",["sqlite3*","sqlite3_stmt*"]],["sqlite3_open","int","string","*"],["sqlite3_open_v2","int","string","*","int","string"],["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 s.xWrap.FuncPtrAdapter({name:"sqlite3_rollback_hook",signature:"v(p)",contextKey:b=>b[0]}),"*"]],["sqlite3_set_auxdata",void 0,["sqlite3_context*","int","*","*"]],["sqlite3_set_errmsg","int","sqlite3*","int","string"],["sqlite3_shutdown",void 0],["sqlite3_sourceid","string"],["sqlite3_sql","string","sqlite3_stmt*"],["sqlite3_status","int","int","*","*","int"],["sqlite3_step","int","sqlite3_stmt*"],["sqlite3_stmt_busy","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 s.xWrap.FuncPtrAdapter({name:"sqlite3_trace_v2::callback",signature:"i(ippp)",contextKey:(b,h)=>b[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_type","int","sqlite3_value*"],["sqlite3_vfs_find","*","string"],["sqlite3_vfs_register","int","sqlite3_vfs*","int"],["sqlite3_vfs_unregister","int","sqlite3_vfs*"]],int64:[["sqlite3_bind_int64","int",["sqlite3_stmt*","int","i64"]],["sqlite3_changes64","i64",["sqlite3*"]],["sqlite3_column_int64","i64",["sqlite3_stmt*","int"]],["sqlite3_deserialize","int","sqlite3*","string","*","i64","i64","int"],["sqlite3_last_insert_rowid","i64",["sqlite3*"]],["sqlite3_malloc64","*","i64"],["sqlite3_msize","i64","*"],["sqlite3_overload_function","int",["sqlite3*","string","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_db_status64","int","sqlite3*","int","*","*","int"],["sqlite3_total_changes64","i64",["sqlite3*"]],["sqlite3_update_hook","*",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"sqlite3_update_hook::callback",signature:"v(pippj)",contextKey:b=>b[0],callProxy:b=>(h,D,U,A,N)=>{b(h,D,s.cstrToJs(U),s.cstrToJs(A),N)}}),"*"]],["sqlite3_uri_int64","i64",["sqlite3_filename","string","i64"]],["sqlite3_value_int64","i64","sqlite3_value*"]],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"]]};if(s.exports.sqlite3_progress_handler&&c.core.push(["sqlite3_progress_handler",void 0,["sqlite3*","int",new s.xWrap.FuncPtrAdapter({name:"xProgressHandler",signature:"i(p)",bindScope:"context",contextKey:(b,h)=>b[0]}),"*"]]),s.exports.sqlite3_stmt_explain&&c.core.push(["sqlite3_stmt_explain","int","sqlite3_stmt*","int"],["sqlite3_stmt_isexplain","int","sqlite3_stmt*"]),s.exports.sqlite3_set_authorizer&&c.core.push(["sqlite3_set_authorizer","int",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"sqlite3_set_authorizer::xAuth",signature:"i(pissss)",contextKey:(b,h)=>b[0],callProxy:b=>(h,D,U,A,N,J)=>{try{return U=U&&s.cstrToJs(U),A=A&&s.cstrToJs(A),N=N&&s.cstrToJs(N),J=J&&s.cstrToJs(J),b(h,D,U,A,N,J)|0}catch(d){return d.resultCode||r.SQLITE_ERROR}}}),"*"]]),s.exports.sqlite3_column_origin_name&&c.core.push(["sqlite3_column_database_name","string","sqlite3_stmt*","int"],["sqlite3_column_origin_name","string","sqlite3_stmt*","int"],["sqlite3_column_table_name","string","sqlite3_stmt*","int"]),s.bigIntEnabled&&s.exports.sqlite3_declare_vtab&&c.int64.push(["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_drop_modules","int",["sqlite3*","**"]],["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","**"]),s.bigIntEnabled&&s.exports.sqlite3_preupdate_hook&&c.int64.push(["sqlite3_preupdate_blobwrite","int","sqlite3*"],["sqlite3_preupdate_count","int","sqlite3*"],["sqlite3_preupdate_depth","int","sqlite3*"],["sqlite3_preupdate_hook","*",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"sqlite3_preupdate_hook",signature:"v(ppippjj)",contextKey:b=>b[0],callProxy:b=>(h,D,U,A,N,J,d)=>{b(h,D,U,s.cstrToJs(A),s.cstrToJs(N),J,d)}}),"*"]],["sqlite3_preupdate_new","int",["sqlite3*","int","**"]],["sqlite3_preupdate_old","int",["sqlite3*","int","**"]]),s.bigIntEnabled&&s.exports.sqlite3changegroup_add&&s.exports.sqlite3session_create&&s.exports.sqlite3_preupdate_hook){const b={signature:"i(ps)",callProxy:h=>(D,U)=>{try{return h(D,s.cstrToJs(U))|0}catch(A){return A.resultCode||r.SQLITE_ERROR}}};c.int64.push(["sqlite3changegroup_add","int",["sqlite3_changegroup*","int","void*"]],["sqlite3changegroup_add_strm","int",["sqlite3_changegroup*",new s.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 s.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply","int",["sqlite3*","int","void*",new s.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...b}),new s.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_strm","int",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new s.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...b}),new s.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_v2","int",["sqlite3*","int","void*",new s.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...b}),new s.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v2_strm","int",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new s.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...b}),new s.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v3","int",["sqlite3*","int","void*",new s.xWrap.FuncPtrAdapter({name:"xFilter",signature:"i(pp)",bindScope:"transient"}),new s.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v3_strm","int",["sqlite3*",new s.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new s.xWrap.FuncPtrAdapter({name:"xFilter",signature:"i(pp)",bindScope:"transient"}),new s.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 s.xWrap.FuncPtrAdapter({name:"xInputA",signature:"i(ppp)",bindScope:"transient"}),"void*",new s.xWrap.FuncPtrAdapter({name:"xInputB",signature:"i(ppp)",bindScope:"transient"}),"void*",new s.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 s.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new s.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 s.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3changeset_start_v2","int",["**","int","*","int"]],["sqlite3changeset_start_v2_strm","int",["**",new s.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 s.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 s.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3session_table_filter",void 0,["sqlite3_session*",new s.xWrap.FuncPtrAdapter({name:"xFilter",...b,contextKey:(h,D)=>h[0]}),"*"]])}i.StructBinder=globalThis.Jaccwabyt({heap:s.heap8u,alloc:s.alloc,dealloc:s.dealloc,bigIntEnabled:s.bigIntEnabled,pointerIR:s.ptr.ir,memberPrefix:"$"}),delete globalThis.Jaccwabyt;{const b=s.xWrap.argAdapter("string");s.xWrap.argAdapter("string:flexible",A=>b(_.flexibleString(A))),s.xWrap.argAdapter("string:static",(function(A){return s.isPtr(A)?A:(A=""+A,this[A]||(this[A]=s.allocCString(A)))}).bind(Object.create(null)));const h=s.xWrap.argAdapter("*"),D=function(){};s.xWrap.argAdapter("sqlite3_filename",h)("sqlite3_context*",h)("sqlite3_value*",h)("void*",h)("sqlite3_changegroup*",h)("sqlite3_changeset_iter*",h)("sqlite3_session*",h)("sqlite3_stmt*",A=>h(A instanceof(i?.oo1?.Stmt||D)?A.pointer:A))("sqlite3*",A=>h(A instanceof(i?.oo1?.DB||D)?A.pointer:A))("sqlite3_vfs*",A=>typeof A=="string"?r.sqlite3_vfs_find(A)||i.SQLite3Error.toss(r.SQLITE_NOTFOUND,"Unknown sqlite3_vfs name:",A):h(A instanceof(r.sqlite3_vfs||D)?A.pointer:A)),s.exports.sqlite3_declare_vtab&&s.xWrap.argAdapter("sqlite3_index_info*",A=>h(A instanceof(r.sqlite3_index_info||D)?A.pointer:A))("sqlite3_module*",A=>h(A instanceof(r.sqlite3_module||D)?A.pointer:A));const U=s.xWrap.resultAdapter("*");s.xWrap.resultAdapter("sqlite3*",U)("sqlite3_context*",U)("sqlite3_stmt*",U)("sqlite3_value*",U)("sqlite3_vfs*",U)("void*",U);for(const A of c.core)r[A[0]]=s.xWrap.apply(null,A);for(const A of c.wasmInternal)_[A[0]]=s.xWrap.apply(null,A);for(const A of c.int64)r[A[0]]=s.bigIntEnabled?s.xWrap.apply(null,A):()=>n(A[0]+"() is unavailable due to lack","of BigInt support in this build.");delete c.core,delete c.int64,delete c.wasmInternal,_.sqlite3__wasm_db_error=function(A,N,J){return A?(N instanceof i.WasmAllocError?(N=r.SQLITE_NOMEM,J=0):N instanceof Error&&(J=J||""+N,N=N.resultCode||r.SQLITE_ERROR),r.sqlite3_set_errmsg(A,N,J)||N):r.SQLITE_MISUSE}}{const b=s.xCall("sqlite3__wasm_enum_json");b||n("Maintenance required: increase sqlite3__wasm_enum_json()'s","static buffer size!"),s.ctype=JSON.parse(s.cstrToJs(b));const h=["access","authorizer","blobFinalizers","changeset","config","dataTypes","dbConfig","dbStatus","encodings","fcntl","flock","ioCap","limits","openFlags","prepareFlags","resultCodes","sqlite3Status","stmtStatus","syncFlags","trace","txnState","udfFlags","version"];s.bigIntEnabled&&h.push("serialize","session","vtab");for(const A of h)for(const N of Object.entries(s.ctype[A]))r[N[0]]=N[1];s.functionEntry(r.SQLITE_WASM_DEALLOC)||n("Internal error: cannot resolve exported function","entry SQLITE_WASM_DEALLOC (=="+r.SQLITE_WASM_DEALLOC+").");const D=Object.create(null);for(const A of Object.entries(s.ctype.resultCodes))D[A[1]]=A[0];r.sqlite3_js_rc_str=A=>D[A];const U=Object.assign(Object.create(null),{WasmTestStruct:!0,sqlite3_index_info:!s.bigIntEnabled,sqlite3_index_constraint:!s.bigIntEnabled,sqlite3_index_orderby:!s.bigIntEnabled,sqlite3_index_constraint_usage:!s.bigIntEnabled});for(const A of s.ctype.structs)U[A.name]||(r[A.name]=i.StructBinder(A));if(r.sqlite3_index_info){for(const A of["sqlite3_index_constraint","sqlite3_index_orderby","sqlite3_index_constraint_usage"])r.sqlite3_index_info[A]=r[A],delete r[A];r.sqlite3_vtab_config=s.xWrap("sqlite3__wasm_vtab_config","int",["sqlite3*","int","int"])}}const m=(b,h,D)=>_.sqlite3__wasm_db_error(b,r.SQLITE_MISUSE,h+"() requires "+D+" argument"+(D===1?"":"s")+"."),M=b=>_.sqlite3__wasm_db_error(b,r.SQLITE_FORMAT,"SQLITE_UTF8 is the only supported encoding."),I=b=>s.xWrap.argAdapter("sqlite3*")(b),S=b=>s.isPtr(b)?s.cstrToJs(b):b,w=(function(b,h){b=I(b);let D=this.dbMap.get(b);if(h)!D&&h>0&&this.dbMap.set(b,D=Object.create(null));else return this.dbMap.delete(b),D;return D}).bind(Object.assign(Object.create(null),{dbMap:new Map}));w.addCollation=function(b,h){const D=w(b,1);D.collation||(D.collation=new Set),D.collation.add(S(h).toLowerCase())},w._addUDF=function(b,h,D,U){h=S(h).toLowerCase();let A=U.get(h);A||U.set(h,A=new Set),A.add(D<0?-1:D)},w.addFunction=function(b,h,D){const U=w(b,1);U.udf||(U.udf=new Map),this._addUDF(b,h,D,U.udf)},s.exports.sqlite3_create_window_function&&(w.addWindowFunc=function(b,h,D){const U=w(b,1);U.wudf||(U.wudf=new Map),this._addUDF(b,h,D,U.wudf)}),w.cleanup=function(b){b=I(b);for(const U of[["sqlite3_busy_handler",3],["sqlite3_commit_hook",3],["sqlite3_preupdate_hook",3],["sqlite3_progress_handler",4],["sqlite3_rollback_hook",3],["sqlite3_set_authorizer",3],["sqlite3_trace_v2",4],["sqlite3_update_hook",3]]){const[A,N]=U;if(!s.exports[A])continue;const J=[b];J.length=N;try{r[A](...J)}catch(d){i.config.warn("close-time call of",A+"(",J,") threw:",d)}}const h=w(b,0);if(!h)return;if(h.collation){for(const U of h.collation)try{r.sqlite3_create_collation_v2(b,U,r.SQLITE_UTF8,0,0,0)}catch{}delete h.collation}let D;for(D=0;D<2;++D){const U=D?h.wudf:h.udf;if(!U)continue;const A=D?r.sqlite3_create_window_function:r.sqlite3_create_function_v2;for(const N of U){const J=N[0],d=N[1],y=[b,J,0,r.SQLITE_UTF8,0,0,0,0,0];D&&y.push(0);for(const P of d)try{y[2]=P,A.apply(null,y)}catch{}d.clear()}U.clear()}delete h.udf,delete h.wudf};{const b=s.xWrap("sqlite3_close_v2","int","sqlite3*");r.sqlite3_close_v2=function(h){if(arguments.length!==1)return m(h,"sqlite3_close_v2",1);if(h)try{w.cleanup(h)}catch{}return b(h)}}if(r.sqlite3session_create){const b=s.xWrap("sqlite3session_delete",void 0,["sqlite3_session*"]);r.sqlite3session_delete=function(h){if(arguments.length!==1)return m(pDb,"sqlite3session_delete",1);h&&r.sqlite3session_table_filter(h,0,0),b(h)}}{const b=(D,U)=>"argv["+U+"]:"+D[0]+":"+s.cstrToJs(D[1]).toLowerCase(),h=s.xWrap("sqlite3_create_collation_v2","int",["sqlite3*","string","int","*",new s.xWrap.FuncPtrAdapter({name:"xCompare",signature:"i(pipip)",contextKey:b}),new s.xWrap.FuncPtrAdapter({name:"xDestroy",signature:"v(p)",contextKey:b})]);r.sqlite3_create_collation_v2=function(D,U,A,N,J,d){if(arguments.length!==6)return m(D,"sqlite3_create_collation_v2",6);if((A&15)===0)A|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(A&15))return M(D);try{const y=h(D,U,A,N,J,d);return y===0&&J instanceof Function&&w.addCollation(D,U),y}catch(y){return _.sqlite3__wasm_db_error(D,y)}},r.sqlite3_create_collation=(D,U,A,N,J)=>arguments.length===5?r.sqlite3_create_collation_v2(D,U,A,N,J,0):m(D,"sqlite3_create_collation",5)}{const b=function(A,N){return A[0]+":"+(A[2]<0?-1:A[2])+":"+N+":"+s.cstrToJs(A[1]).toLowerCase()},h=Object.assign(Object.create(null),{xInverseAndStep:{signature:"v(pip)",contextKey:b,callProxy:A=>(N,J,d)=>{try{A(N,...r.sqlite3_values_to_js(J,d))}catch(y){r.sqlite3_result_error_js(N,y)}}},xFinalAndValue:{signature:"v(p)",contextKey:b,callProxy:A=>N=>{try{r.sqlite3_result_js(N,A(N))}catch(J){r.sqlite3_result_error_js(N,J)}}},xFunc:{signature:"v(pip)",contextKey:b,callProxy:A=>(N,J,d)=>{try{r.sqlite3_result_js(N,A(N,...r.sqlite3_values_to_js(J,d)))}catch(y){r.sqlite3_result_error_js(N,y)}}},xDestroy:{signature:"v(p)",contextKey:b,callProxy:A=>N=>{try{A(N)}catch(J){console.error("UDF xDestroy method threw:",J)}}}}),D=s.xWrap("sqlite3_create_function_v2","int",["sqlite3*","string","int","int","*",new s.xWrap.FuncPtrAdapter({name:"xFunc",...h.xFunc}),new s.xWrap.FuncPtrAdapter({name:"xStep",...h.xInverseAndStep}),new s.xWrap.FuncPtrAdapter({name:"xFinal",...h.xFinalAndValue}),new s.xWrap.FuncPtrAdapter({name:"xDestroy",...h.xDestroy})]),U=s.exports.sqlite3_create_window_function?s.xWrap("sqlite3_create_window_function","int",["sqlite3*","string","int","int","*",new s.xWrap.FuncPtrAdapter({name:"xStep",...h.xInverseAndStep}),new s.xWrap.FuncPtrAdapter({name:"xFinal",...h.xFinalAndValue}),new s.xWrap.FuncPtrAdapter({name:"xValue",...h.xFinalAndValue}),new s.xWrap.FuncPtrAdapter({name:"xInverse",...h.xInverseAndStep}),new s.xWrap.FuncPtrAdapter({name:"xDestroy",...h.xDestroy})]):void 0;r.sqlite3_create_function_v2=function A(N,J,d,y,P,Q,F,X,ee){if(A.length!==arguments.length)return m(N,"sqlite3_create_function_v2",A.length);if((y&15)===0)y|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(y&15))return M(N);try{const Z=D(N,J,d,y,P,Q,F,X,ee);return Z===0&&(Q instanceof Function||F instanceof Function||X instanceof Function||ee instanceof Function)&&w.addFunction(N,J,d),Z}catch(Z){return console.error("sqlite3_create_function_v2() setup threw:",Z),_.sqlite3__wasm_db_error(N,Z,"Creation of UDF threw: "+Z)}},r.sqlite3_create_function=function A(N,J,d,y,P,Q,F,X){return A.length===arguments.length?r.sqlite3_create_function_v2(N,J,d,y,P,Q,F,X,0):m(N,"sqlite3_create_function",A.length)},U?r.sqlite3_create_window_function=function A(N,J,d,y,P,Q,F,X,ee,Z){if(A.length!==arguments.length)return m(N,"sqlite3_create_window_function",A.length);if((y&15)===0)y|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(y&15))return M(N);try{const te=U(N,J,d,y,P,Q,F,X,ee,Z);return te===0&&(Q instanceof Function||F instanceof Function||X instanceof Function||ee instanceof Function||Z instanceof Function)&&w.addWindowFunc(N,J,d),te}catch(te){return console.error("sqlite3_create_window_function() setup threw:",te),_.sqlite3__wasm_db_error(N,te,"Creation of UDF threw: "+te)}}:delete r.sqlite3_create_window_function,r.sqlite3_create_function_v2.udfSetResult=r.sqlite3_create_function.udfSetResult=r.sqlite3_result_js,r.sqlite3_create_window_function&&(r.sqlite3_create_window_function.udfSetResult=r.sqlite3_result_js),r.sqlite3_create_function_v2.udfConvertArgs=r.sqlite3_create_function.udfConvertArgs=r.sqlite3_values_to_js,r.sqlite3_create_window_function&&(r.sqlite3_create_window_function.udfConvertArgs=r.sqlite3_values_to_js),r.sqlite3_create_function_v2.udfSetError=r.sqlite3_create_function.udfSetError=r.sqlite3_result_error_js,r.sqlite3_create_window_function&&(r.sqlite3_create_window_function.udfSetError=r.sqlite3_result_error_js)}{const b=(D,U)=>(typeof D=="string"?U=-1:_.isSQLableTypedArray(D)?(U=D.byteLength,D=s.typedArrayToString(D instanceof ArrayBuffer?new Uint8Array(D):D)):Array.isArray(D)&&(D=D.join(""),U=-1),[D,U]),h={basic:s.xWrap("sqlite3_prepare_v3","int",["sqlite3*","string","int","int","**","**"]),full:s.xWrap("sqlite3_prepare_v3","int",["sqlite3*","*","int","int","**","**"])};r.sqlite3_prepare_v3=function D(U,A,N,J,d,y){if(D.length!==arguments.length)return m(U,"sqlite3_prepare_v3",D.length);const[P,Q]=b(A,Number(N));switch(typeof P){case"string":return h.basic(U,P,Q,J,d,null);case typeof s.ptr.null:return h.full(U,s.ptr.coerce(P),Q,J,d,y);default:return _.sqlite3__wasm_db_error(U,r.SQLITE_MISUSE,"Invalid SQL argument type for sqlite3_prepare_v2/v3(). typeof="+typeof P)}},r.sqlite3_prepare_v2=function D(U,A,N,J,d){return D.length===arguments.length?r.sqlite3_prepare_v3(U,A,N,0,J,d):m(U,"sqlite3_prepare_v2",D.length)}}{const b=s.xWrap("sqlite3_bind_text","int",["sqlite3_stmt*","int","string","int","*"]),h=s.xWrap("sqlite3_bind_blob","int",["sqlite3_stmt*","int","*","int","*"]);r.sqlite3_bind_text=function D(U,A,N,J,d){if(D.length!==arguments.length)return m(r.sqlite3_db_handle(U),"sqlite3_bind_text",D.length);if(s.isPtr(N)||N===null)return b(U,A,N,J,d);N instanceof ArrayBuffer?N=new Uint8Array(N):Array.isArray(pMem)&&(N=pMem.join(""));let y,P;try{if(_.isSQLableTypedArray(N))y=s.allocFromTypedArray(N),P=N.byteLength;else if(typeof N=="string")[y,P]=s.allocCString(N);else return _.sqlite3__wasm_db_error(r.sqlite3_db_handle(U),r.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_text().");return b(U,A,y,P,r.SQLITE_WASM_DEALLOC)}catch(Q){return s.dealloc(y),_.sqlite3__wasm_db_error(r.sqlite3_db_handle(U),Q)}},r.sqlite3_bind_blob=function D(U,A,N,J,d){if(D.length!==arguments.length)return m(r.sqlite3_db_handle(U),"sqlite3_bind_blob",D.length);if(s.isPtr(N)||N===null)return h(U,A,N,J,d);N instanceof ArrayBuffer?N=new Uint8Array(N):Array.isArray(N)&&(N=N.join(""));let y,P;try{if(_.isBindableTypedArray(N))y=s.allocFromTypedArray(N),P=J>=0?J:N.byteLength;else if(typeof N=="string")[y,P]=s.allocCString(N);else return _.sqlite3__wasm_db_error(r.sqlite3_db_handle(U),r.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_blob().");return h(U,A,y,P,r.SQLITE_WASM_DEALLOC)}catch(Q){return s.dealloc(y),_.sqlite3__wasm_db_error(r.sqlite3_db_handle(U),Q)}}}if(!r.sqlite3_column_text){const b=s.xWrap.argAdapter("sqlite3_stmt*"),h=s.xWrap.argAdapter("int"),D=s.xWrap.argAdapter("sqlite3_value*"),U=(A,N)=>s.typedArrayToString(s.heap8u(),Number(A),Number(A)+N);r.sqlite3_column_text=function(A,N){const J=b(A),d=h(N),y=s.exports.sqlite3_column_text(J,d);return y?U(y,s.exports.sqlite3_column_bytes(J,d)):null},r.sqlite3_value_text=function(A){const N=D(A),J=s.exports.sqlite3_value_text(N);return J?U(J,s.exports.sqlite3_value_bytes(N)):null}}r.sqlite3_config=function(b,...h){if(arguments.length<2)return r.SQLITE_MISUSE;switch(b){case r.SQLITE_CONFIG_COVERING_INDEX_SCAN:case r.SQLITE_CONFIG_MEMSTATUS:case r.SQLITE_CONFIG_SMALL_MALLOC:case r.SQLITE_CONFIG_SORTERREF_SIZE:case r.SQLITE_CONFIG_STMTJRNL_SPILL:case r.SQLITE_CONFIG_URI:return s.exports.sqlite3__wasm_config_i(b,h[0]);case r.SQLITE_CONFIG_LOOKASIDE:return s.exports.sqlite3__wasm_config_ii(b,h[0],h[1]);case r.SQLITE_CONFIG_MEMDB_MAXSIZE:return s.exports.sqlite3__wasm_config_j(b,h[0]);case r.SQLITE_CONFIG_GETMALLOC:case r.SQLITE_CONFIG_GETMUTEX:case r.SQLITE_CONFIG_GETPCACHE2:case r.SQLITE_CONFIG_GETPCACHE:case r.SQLITE_CONFIG_HEAP:case r.SQLITE_CONFIG_LOG:case r.SQLITE_CONFIG_MALLOC:case r.SQLITE_CONFIG_MMAP_SIZE:case r.SQLITE_CONFIG_MULTITHREAD:case r.SQLITE_CONFIG_MUTEX:case r.SQLITE_CONFIG_PAGECACHE:case r.SQLITE_CONFIG_PCACHE2:case r.SQLITE_CONFIG_PCACHE:case r.SQLITE_CONFIG_PCACHE_HDRSZ:case r.SQLITE_CONFIG_PMASZ:case r.SQLITE_CONFIG_SERIALIZED:case r.SQLITE_CONFIG_SINGLETHREAD:case r.SQLITE_CONFIG_SQLLOG:case r.SQLITE_CONFIG_WIN32_HEAPSIZE:default:return r.SQLITE_NOTFOUND}};{const b=new Set;r.sqlite3_auto_extension=function(h){if(h instanceof Function)h=s.installFunction("i(ppp)",h);else if(arguments.length!==1||!s.isPtr(h))return r.SQLITE_MISUSE;const D=s.exports.sqlite3_auto_extension(h);return h!==arguments[0]&&(D===0?b.add(h):s.uninstallFunction(h)),D},r.sqlite3_cancel_auto_extension=function(h){return!h||arguments.length!==1||!s.isPtr(h)?0:s.exports.sqlite3_cancel_auto_extension(h)},r.sqlite3_reset_auto_extension=function(){s.exports.sqlite3_reset_auto_extension();for(const h of b)s.uninstallFunction(h);b.clear()}}s.xWrap.FuncPtrAdapter.warnOnUse=!0;const x=i.StructBinder,L=function b(h,D,U,A=b.installMethodArgcCheck){if(h instanceof x.StructType?!(U instanceof Function)&&!s.isPtr(U)&&n("Usage error: expecting a Function or WASM pointer to one."):n("Usage error: target object is-not-a StructType."),arguments.length===1)return(y,P)=>b(h,y,P,A);b.argcProxy||(b.argcProxy=function(y,P,Q,F){return function(...X){return Q.length!==arguments.length&&n("Argument mismatch for",y.structInfo.name+"::"+P+": Native signature is:",F),Q.apply(this,X)}},b.removeFuncList=function(){this.ondispose.__removeFuncList&&(this.ondispose.__removeFuncList.forEach((y,P)=>{if(s.isPtr(y))try{s.uninstallFunction(y)}catch{}}),delete this.ondispose.__removeFuncList)});const N=h.memberSignature(D);N.length<2&&n("Member",D,"does not have a function pointer signature:",N);const J=h.memberKey(D),d=A&&!s.isPtr(U)?b.argcProxy(h,J,U,N):U;if(s.isPtr(d))d&&!s.functionEntry(d)&&n("Pointer",d,"is not a WASM function table entry."),h[J]=d;else{const y=s.installFunction(d,N);h[J]=y,(!h.ondispose||!h.ondispose.__removeFuncList)&&(h.addOnDispose("ondispose.__removeFuncList handler",b.removeFuncList),h.ondispose.__removeFuncList=[]),h.ondispose.__removeFuncList.push(J,y)}return(y,P)=>b(h,y,P,A)};L.installMethodArgcCheck=!1;const V=function(b,h,D=L.installMethodArgcCheck){const U=new Map;for(const A of Object.keys(h)){const N=h[A],J=U.get(N);if(J){const d=b.memberKey(A);b[d]=b[b.memberKey(J)]}else L(b,A,N,D),U.set(N,A)}return b};x.StructType.prototype.installMethod=function(h,D,U=L.installMethodArgcCheck){return arguments.length<3&&h&&typeof h=="object"?V(this,...arguments):L(this,...arguments)},x.StructType.prototype.installMethods=function(b,h=L.installMethodArgcCheck){return V(this,b,h)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){const n=(...E)=>{throw new i.SQLite3Error(...E)},r=i.capi,s=i.wasm,_=i.util,c=function(E){return(...o)=>E("sqlite3.oo1:",...o)};i.__isUnderTest?c(console.debug.bind(console)):c(i.config.debug),i.__isUnderTest?c(console.warn.bind(console)):c(i.config.warn),i.__isUnderTest?c(console.error.bind(console)):c(i.config.error);const m=new WeakMap,M=new Set,I=new WeakMap,S=(E,o,u)=>{const p=Object.getOwnPropertyDescriptor(E,o);return p?p.value:u},w=function(E,o){return o&&(E instanceof b&&(E=E.pointer),n(o,"sqlite3 result code",o+":",E?r.sqlite3_errmsg(E):r.sqlite3_errstr(o))),arguments[0]},x=s.installFunction("i(ippp)",(function(E,o,u,p){r.SQLITE_TRACE_STMT===E&&console.log("SQL TRACE #"+ ++this.counter,"via sqlite3@"+o+"["+r.sqlite3_db_filename(o,null)+"]",s.cstrToJs(p))}).bind({counter:0})),L=Object.create(null),V=function E(...o){const u=E.normalizeArgs(...o);let p;if(p=u["sqlite3*"])u["sqlite3*:takeOwnership"]||M.add(this),this.filename=r.sqlite3_db_filename(p,"main");else{let q=u.filename,z=u.vfs,H=u.flags;(typeof q!="string"&&!s.isPtr(q)||typeof H!="string"||z&&typeof z!="string"&&!s.isPtr(z))&&(i.config.error("Invalid DB ctor args",u,arguments),n("Invalid arguments for DB constructor:",arguments,"opts:",u));let R=0;H.indexOf("c")>=0&&(R|=r.SQLITE_OPEN_CREATE|r.SQLITE_OPEN_READWRITE),H.indexOf("w")>=0&&(R|=r.SQLITE_OPEN_READWRITE),R===0&&(R|=r.SQLITE_OPEN_READONLY),R|=r.SQLITE_OPEN_EXRESCODE;const g=s.pstack.pointer;try{const C=s.pstack.allocPtr();let B=r.sqlite3_open_v2(q,C,R,z||s.ptr.null);p=s.peekPtr(C),w(p,B),r.sqlite3_extended_result_codes(p,1),H.indexOf("t")>=0&&r.sqlite3_trace_v2(p,r.SQLITE_TRACE_STMT,x,p)}catch(C){throw p&&r.sqlite3_close_v2(p),C}finally{s.pstack.restore(g)}this.filename=s.isPtr(q)?s.cstrToJs(q):q}if(m.set(this,p),I.set(this,Object.create(null)),!u["sqlite3*"])try{const q=L[r.sqlite3_js_db_vfs(p)||n("Internal error: cannot get VFS for new db handle.")];q&&(q instanceof Function?q(this,i):w(p,r.sqlite3_exec(p,q,0,0,0)))}catch(q){throw this.close(),q}};V.setVfsPostOpenCallback=function(E,o){o instanceof Function||n("dbCtorHelper.setVfsPostOpenCallback() should not be used with a non-function argument.",arguments),L[E]=o},V.normalizeArgs=function(E=":memory:",o="c",u=null){const p={};return arguments.length===1&&arguments[0]&&typeof arguments[0]=="object"?(Object.assign(p,arguments[0]),p.flags===void 0&&(p.flags="c"),p.vfs===void 0&&(p.vfs=null),p.filename===void 0&&(p.filename=":memory:")):(p.filename=E,p.flags=o,p.vfs=u),p};const b=function(...E){V.apply(this,E)};b.dbCtorHelper=V;const h={null:1,number:2,string:3,boolean:4,blob:5};s.bigIntEnabled&&(h.bigint=h.number);const D=function(){h!==arguments[2]&&n(r.SQLITE_MISUSE,"Do not call the Stmt constructor directly. Use DB.prepare()."),this.db=arguments[0],m.set(this,arguments[1]),arguments.length>3&&!arguments[3]&&M.add(this)},U=function(E){return E.pointer||n("DB has been closed."),E},A=function(E,o){return(o!==(o|0)||o<0||o>=E.columnCount)&&n("Column index",o,"is out of range."),E},N=function(E,o){const u=Object.create(null);switch(u.opt=Object.create(null),o.length){case 1:typeof o[0]=="string"||_.isSQLableTypedArray(o[0])||Array.isArray(o[0])?u.sql=o[0]:o[0]&&typeof o[0]=="object"&&(u.opt=o[0],u.sql=u.opt.sql);break;case 2:u.sql=o[0],u.opt=o[1];break;default:n("Invalid argument count for exec().")}u.sql=_.flexibleString(u.sql),typeof u.sql!="string"&&n("Missing SQL argument or unsupported SQL value type.");const p=u.opt;switch(p.returnValue){case"resultRows":p.resultRows||(p.resultRows=[]),u.returnVal=()=>p.resultRows;break;case"saveSql":p.saveSql||(p.saveSql=[]),u.returnVal=()=>p.saveSql;break;case void 0:case"this":u.returnVal=()=>E;break;default:n("Invalid returnValue value:",p.returnValue)}if(!p.callback&&!p.returnValue&&p.rowMode!==void 0&&(p.resultRows||(p.resultRows=[]),u.returnVal=()=>p.resultRows),p.callback||p.resultRows)switch(p.rowMode===void 0?"array":p.rowMode){case"object":u.cbArg=(q,z)=>{z.columnNames||(z.columnNames=q.getColumnNames([]));const H=q.get([]),R=Object.create(null);for(const g in z.columnNames)R[z.columnNames[g]]=H[g];return R};break;case"array":u.cbArg=q=>q.get([]);break;case"stmt":Array.isArray(p.resultRows)&&n("exec(): invalid rowMode for a resultRows array: must","be one of 'array', 'object',","a result column number, or column name reference."),u.cbArg=q=>q;break;default:if(_.isInt32(p.rowMode)){u.cbArg=q=>q.get(p.rowMode);break}else if(typeof p.rowMode=="string"&&p.rowMode.length>1&&p.rowMode[0]==="$"){const q=p.rowMode.substr(1);u.cbArg=z=>{const H=z.get(Object.create(null))[q];return H===void 0?n(r.SQLITE_NOTFOUND,"exec(): unknown result column:",q):H};break}n("Invalid rowMode:",p.rowMode)}return u},J=(E,o,u,...p)=>{const q=E.prepare(o);try{const z=q.bind(u).step()?q.get(...p):void 0;return q.reset(),z}finally{q.finalize()}},d=(E,o,u,p)=>E.exec({sql:o,bind:u,rowMode:p,returnValue:"resultRows"});b.checkRc=(E,o)=>w(E,o),b.prototype={isOpen:function(){return!!this.pointer},affirmOpen:function(){return U(this)},close:function(){const E=this.pointer;if(E){if(this.onclose&&this.onclose.before instanceof Function)try{this.onclose.before(this)}catch{}if(Object.keys(I.get(this)).forEach((o,u)=>{if(u&&u.pointer)try{u.finalize()}catch{}}),m.delete(this),I.delete(this),M.delete(this)||r.sqlite3_close_v2(E),this.onclose&&this.onclose.after instanceof Function)try{this.onclose.after(this)}catch{}delete this.filename}},changes:function(E=!1,o=!1){const u=U(this).pointer;return E?o?r.sqlite3_total_changes64(u):r.sqlite3_total_changes(u):o?r.sqlite3_changes64(u):r.sqlite3_changes(u)},dbFilename:function(E="main"){return r.sqlite3_db_filename(U(this).pointer,E)},dbName:function(E=0){return r.sqlite3_db_name(U(this).pointer,E)},dbVfsName:function(E=0){let o;const u=r.sqlite3_js_db_vfs(U(this).pointer,E);if(u){const p=new r.sqlite3_vfs(u);try{o=s.cstrToJs(p.$zName)}finally{p.dispose()}}return o},prepare:function(E){U(this);const o=s.pstack.pointer;let u,p;try{u=s.pstack.alloc(8),b.checkRc(this,r.sqlite3_prepare_v2(this.pointer,E,-1,u,null)),p=s.peekPtr(u)}finally{s.pstack.restore(o)}p||n("Cannot prepare empty SQL.");const q=new D(this,p,h);return I.get(this)[p]=q,q},exec:function(){U(this);const E=N(this,arguments);if(!E.sql)return n("exec() requires an SQL string.");const o=E.opt,u=o.callback,p=Array.isArray(o.resultRows)?o.resultRows:void 0;let q,z=o.bind,H=!!(E.cbArg||o.columnNames||p);const R=s.scopedAllocPush(),g=Array.isArray(o.saveSql)?o.saveSql:void 0;try{const C=_.isSQLableTypedArray(E.sql);let B=C?E.sql.byteLength:s.jstrlen(E.sql);const Y=s.scopedAlloc(2*s.ptr.size+(B+1)),ne=s.ptr.add(Y,s.ptr.size);let le=s.ptr.add(ne,s.ptr.size);const ae=s.ptr.add(le,B);for(C?s.heap8().set(E.sql,le):s.jstrcpy(E.sql,s.heap8(),le,B,!1),s.poke8(s.ptr.add(le,B),0);le&&s.peek8(le);){s.pokePtr([Y,ne],0),b.checkRc(this,r.sqlite3_prepare_v3(this.pointer,le,B,0,Y,ne));const be=s.peekPtr(Y);if(le=s.peekPtr(ne),B=Number(s.ptr.add(ae,-le)),!!be){if(g&&g.push(r.sqlite3_sql(be).trim()),q=new D(this,be,h),z&&q.parameterCount&&(q.bind(z),z=null),H&&q.columnCount){let Ae=Array.isArray(o.columnNames)?0:1;if(H=!1,E.cbArg||p){const Re=Object.create(null);for(;q.step();X.delete(q)){Ae++===0&&q.getColumnNames(Re.columnNames=o.columnNames||[]),X.add(q);const Xe=E.cbArg(q,Re);if(p&&p.push(Xe),u&&u.call(o,Xe,q)===!1)break}X.delete(q)}Ae===0&&q.getColumnNames(o.columnNames)}else q.step();q.reset().finalize(),q=null}}}finally{q&&(X.delete(q),q.finalize()),s.scopedAllocPop(R)}return E.returnVal()},createFunction:function(o,u,p){const q=Re=>Re instanceof Function;switch(arguments.length){case 1:p=o,o=p.name,u=p.xFunc||0;break;case 2:q(u)||(p=u,u=p.xFunc||0);break}p||(p={}),typeof o!="string"&&n("Invalid arguments: missing function name.");let z=p.xStep||0,H=p.xFinal||0;const R=p.xValue||0,g=p.xInverse||0;let C;q(u)?(C=!1,(q(z)||q(H))&&n("Ambiguous arguments: scalar or aggregate?"),z=H=null):q(z)?(q(H)||n("Missing xFinal() callback for aggregate or window UDF."),u=null):q(H)?n("Missing xStep() callback for aggregate or window UDF."):n("Missing function-type properties."),C===!1?(q(R)||q(g))&&n("xValue and xInverse are not permitted for non-window UDFs."):q(R)?(q(g)||n("xInverse must be provided if xValue is."),C=!0):q(g)&&n("xValue must be provided if xInverse is.");const B=p.pApp;B!=null&&!s.isPtr(B)&&n("Invalid value for pApp property. Must be a legal WASM pointer value.");const Y=p.xDestroy||0;Y&&!q(Y)&&n("xDestroy property must be a function.");let ne=0;S(p,"deterministic")&&(ne|=r.SQLITE_DETERMINISTIC),S(p,"directOnly")&&(ne|=r.SQLITE_DIRECTONLY),S(p,"innocuous")&&(ne|=r.SQLITE_INNOCUOUS),o=o.toLowerCase();const le=u||z,ae=S(p,"arity"),be=typeof ae=="number"?ae:le.length?le.length-1:0;let Ae;return C?Ae=r.sqlite3_create_window_function(this.pointer,o,be,r.SQLITE_UTF8|ne,B||0,z,H,R,g,Y):Ae=r.sqlite3_create_function_v2(this.pointer,o,be,r.SQLITE_UTF8|ne,B||0,u,z,H,Y),b.checkRc(this,Ae),this},selectValue:function(E,o,u){return J(this,E,o,0,u)},selectValues:function(E,o,u){const p=this.prepare(E),q=[];try{for(p.bind(o);p.step();)q.push(p.get(0,u));p.reset()}finally{p.finalize()}return q},selectArray:function(E,o){return J(this,E,o,[])},selectObject:function(E,o){return J(this,E,o,{})},selectArrays:function(E,o){return d(this,E,o,"array")},selectObjects:function(E,o){return d(this,E,o,"object")},openStatementCount:function(){return this.pointer?Object.keys(I.get(this)).length:0},transaction:function(E){let o="BEGIN";arguments.length>1&&(/[^a-zA-Z]/.test(arguments[0])&&n(r.SQLITE_MISUSE,"Invalid argument for BEGIN qualifier."),o+=" "+arguments[0],E=arguments[1]),U(this).exec(o);try{const u=E(this);return this.exec("COMMIT"),u}catch(u){throw this.exec("ROLLBACK"),u}},savepoint:function(E){U(this).exec("SAVEPOINT oo1");try{const o=E(this);return this.exec("RELEASE oo1"),o}catch(o){throw this.exec("ROLLBACK to SAVEPOINT oo1; RELEASE SAVEPOINT oo1"),o}},checkRc:function(E){return w(this,E)}},b.wrapHandle=function(E,o=!1){if(!E||!s.isPtr(E))throw new i.SQLite3Error(r.SQLITE_MISUSE,"Argument must be a WASM sqlite3 pointer");return new b({"sqlite3*":E,"sqlite3*:takeOwnership":!!o})};const y=function(E){return E.pointer||n("Stmt has been closed."),E},P=function(E){let o=h[E==null?"null":typeof E];switch(o){case h.boolean:case h.null:case h.number:case h.string:return o;case h.bigint:return s.bigIntEnabled?o:void 0;default:return _.isBindableTypedArray(E)?h.blob:void 0}},Q=function(E){return P(E)||n("Unsupported bind() argument type:",typeof E)},F=function(E,o){const u=typeof o=="number"?o:r.sqlite3_bind_parameter_index(E.pointer,o);return u===0||!_.isInt32(u)?n("Invalid bind() parameter name: "+o):(u<1||u>E.parameterCount)&&n("Bind index",o,"is out of range."),u},X=new Set,ee=new Set,Z=function(E,o){return X.has(E)&&n("Operation is illegal when statement is locked:",o),E},te=function E(o,u,p,q){Z(y(o),"bind()"),E._||(E._tooBigInt=H=>n("BigInt value is too big to store without precision loss:",H),E._={string:function(H,R,g,C){const[B,Y]=s.allocCString(g,!0);return(C?r.sqlite3_bind_blob:r.sqlite3_bind_text)(H.pointer,R,B,Y,r.SQLITE_WASM_DEALLOC)}}),Q(q),u=F(o,u);let z=0;switch(q==null?h.null:p){case h.null:z=r.sqlite3_bind_null(o.pointer,u);break;case h.string:z=E._.string(o,u,q,!1);break;case h.number:{let H;_.isInt32(q)?H=r.sqlite3_bind_int:typeof q=="bigint"?_.bigIntFits64(q)?s.bigIntEnabled?H=r.sqlite3_bind_int64:_.bigIntFitsDouble(q)?(q=Number(q),H=r.sqlite3_bind_double):E._tooBigInt(q):E._tooBigInt(q):(q=Number(q),s.bigIntEnabled&&Number.isInteger(q)?H=r.sqlite3_bind_int64:H=r.sqlite3_bind_double),z=H(o.pointer,u,q);break}case h.boolean:z=r.sqlite3_bind_int(o.pointer,u,q?1:0);break;case h.blob:{if(typeof q=="string"){z=E._.string(o,u,q,!0);break}else q instanceof ArrayBuffer?q=new Uint8Array(q):_.isBindableTypedArray(q)||n("Binding a value as a blob requires","that it be a string, Uint8Array, Int8Array, or ArrayBuffer.");const H=s.alloc(q.byteLength||1);s.heap8().set(q.byteLength?q:[0],Number(H)),z=r.sqlite3_bind_blob(o.pointer,u,H,q.byteLength,r.SQLITE_WASM_DEALLOC);break}default:i.config.warn("Unsupported bind() argument type:",q),n("Unsupported bind() argument type: "+typeof q)}return z&&b.checkRc(o.db.pointer,z),o};D.prototype={finalize:function(){const E=this.pointer;if(E){Z(this,"finalize()");const o=M.delete(this)?0:r.sqlite3_finalize(E);return delete I.get(this.db)[E],m.delete(this),X.delete(this),ee.delete(this),delete this.parameterCount,delete this.db,o}},clearBindings:function(){return Z(y(this),"clearBindings()"),r.sqlite3_clear_bindings(this.pointer),ee.delete(this),this},reset:function(E){Z(this,"reset()"),E&&this.clearBindings();const o=r.sqlite3_reset(y(this).pointer);return ee.delete(this),w(this.db,o),this},bind:function(){y(this);let E,o;switch(arguments.length){case 1:E=1,o=arguments[0];break;case 2:E=arguments[0],o=arguments[1];break;default:n("Invalid bind() arguments.")}return o===void 0?this:(this.parameterCount||n("This statement has no bindable parameters."),ee.delete(this),o===null?te(this,E,h.null,o):Array.isArray(o)?(arguments.length!==1&&n("When binding an array, an index argument is not permitted."),o.forEach((u,p)=>te(this,p+1,Q(u),u)),this):(o instanceof ArrayBuffer&&(o=new Uint8Array(o)),typeof o=="object"&&!_.isBindableTypedArray(o)?(arguments.length!==1&&n("When binding an object, an index argument is not permitted."),Object.keys(o).forEach(u=>te(this,u,Q(o[u]),o[u])),this):te(this,E,Q(o),o)))},bindAsBlob:function(E,o){y(this),arguments.length===1&&(o=E,E=1);const u=Q(o);return h.string!==u&&h.blob!==u&&h.null!==u&&n("Invalid value type for bindAsBlob()"),te(this,E,h.blob,o)},step:function(){Z(this,"step()");const E=r.sqlite3_step(y(this).pointer);switch(E){case r.SQLITE_DONE:return ee.delete(this),!1;case r.SQLITE_ROW:return ee.add(this),!0;default:ee.delete(this),i.config.warn("sqlite3_step() rc=",E,r.sqlite3_js_rc_str(E),"SQL =",r.sqlite3_sql(this.pointer)),b.checkRc(this.db.pointer,E)}},stepReset:function(){return this.step(),this.reset()},stepFinalize:function(){try{const E=this.step();return this.reset(),E}finally{try{this.finalize()}catch{}}},get:function(E,o){if(ee.has(y(this))||n("Stmt.step() has not (recently) returned true."),Array.isArray(E)){let u=0;const p=this.columnCount;for(;u=Number.MIN_SAFE_INTEGER&&u<=Number.MAX_SAFE_INTEGER?Number(u).valueOf():u}else{const u=r.sqlite3_column_double(this.pointer,E);return(u>Number.MAX_SAFE_INTEGER||un("The pointer property is read-only.")};Object.defineProperty(D.prototype,"pointer",E),Object.defineProperty(b.prototype,"pointer",E)}Object.defineProperty(D.prototype,"columnCount",{enumerable:!1,get:function(){return r.sqlite3_column_count(this.pointer)},set:()=>n("The columnCount property is read-only.")}),Object.defineProperty(D.prototype,"parameterCount",{enumerable:!1,get:function(){return r.sqlite3_bind_parameter_count(this.pointer)},set:()=>n("The parameterCount property is read-only.")}),D.wrapHandle=function(E,o,u=!1){if(!(E instanceof b)||!E.pointer)throw new i.SQLite3Error(i.SQLITE_MISUSE,"First argument must be an opened sqlite3.oo1.DB instance");if(!o||!s.isPtr(o))throw new i.SQLite3Error(i.SQLITE_MISUSE,"Second argument must be a WASM sqlite3_stmt pointer");return new D(E,o,h,!!u)},i.oo1={DB:b,Stmt:D}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){const n=i.util;i.initWorker1API=(function(){const r=(...x)=>{throw new Error(x.join(" "))};globalThis.WorkerGlobalScope instanceof Function||r("initWorker1API() must be run from a Worker thread.");const s=this.sqlite3||r("Missing this.sqlite3 object."),_=s.oo1.DB,c=function(x){let L=m.idMap.get(x);return L||(L="db#"+ ++m.idSeq+":"+Math.floor(Math.random()*1e8)+":"+Math.floor(Math.random()*1e8),m.idMap.set(x,L),L)},m={dbList:[],idSeq:0,idMap:new WeakMap,xfer:[],open:function(x){const L=new _(x);return this.dbs[c(L)]=L,this.dbList.indexOf(L)<0&&this.dbList.push(L),L},close:function(x,L){if(x){delete this.dbs[c(x)];const V=x.filename,b=n.sqlite3__wasm_db_vfs(x.pointer,0);x.close();const h=this.dbList.indexOf(x);h>=0&&this.dbList.splice(h,1),L&&V&&b&&n.sqlite3__wasm_vfs_unlink(b,V)}},post:function(x,L){L&&L.length?(globalThis.postMessage(x,Array.from(L)),L.length=0):globalThis.postMessage(x)},dbs:Object.create(null),getDb:function(x,L=!0){return this.dbs[x]||(L?r("Unknown (or closed) DB ID:",x):void 0)}},M=function(x=m.dbList[0]){return x&&x.pointer?x:r("DB is not opened.")},I=function(x,L=!0){const V=m.getDb(x.dbId,!1)||m.dbList[0];return L?M(V):V},S=function(){return m.dbList[0]&&c(m.dbList[0])},w={open:function(x){const L=Object.create(null),V=x.args||Object.create(null);V.simulateError&&r("Throwing because of simulateError flag.");const b=Object.create(null);L.vfs=V.vfs,L.filename=V.filename||"";const h=m.open(L);return b.filename=h.filename,b.persistent=!!s.capi.sqlite3_js_db_uses_vfs(h.pointer,"opfs"),b.dbId=c(h),b.vfs=h.dbVfsName(),b},close:function(x){const L=I(x,!1),V={filename:L&&L.filename};if(L){const b=x.args&&typeof x.args=="object"?!!x.args.unlink:!1;m.close(L,b)}return V},exec:function(x){const L=typeof x.args=="string"?{sql:x.args}:x.args||Object.create(null);L.rowMode==="stmt"?r("Invalid rowMode for 'exec': stmt mode","does not work in the Worker API."):L.sql||r("'exec' requires input SQL.");const V=I(x);(L.callback||Array.isArray(L.resultRows))&&(V._blobXfer=m.xfer);const b=L.callback;let h=0;const D=!!L.columnNames;typeof b=="string"&&(D||(L.columnNames=[]),L.callback=function(U,A){m.post({type:b,columnNames:L.columnNames,rowNumber:++h,row:U},m.xfer)});try{const U=L.countChanges?V.changes(!0,L.countChanges===64):void 0;V.exec(L),U!==void 0&&(L.changeCount=V.changes(!0,L.countChanges===64)-U);const A=L.lastInsertRowId?s.capi.sqlite3_last_insert_rowid(V):void 0;A!==void 0&&(L.lastInsertRowId=A),L.callback instanceof Function&&(L.callback=b,m.post({type:b,columnNames:L.columnNames,rowNumber:null,row:void 0}))}finally{delete V._blobXfer,L.callback&&(L.callback=b)}return L},"config-get":function(){const x=Object.create(null),L=s.config;return["bigIntEnabled"].forEach(function(V){Object.getOwnPropertyDescriptor(L,V)&&(x[V]=L[V])}),x.version=s.version,x.vfsList=s.capi.sqlite3_js_vfs_list(),x},export:function(x){const L=I(x),V={byteArray:s.capi.sqlite3_js_db_export(L.pointer),filename:L.filename,mimetype:"application/x-sqlite3"};return m.xfer.push(V.byteArray.buffer),V},toss:function(x){r("Testing worker exception")}};globalThis.onmessage=async function(x){x=x.data;let L,V=x.dbId,b=x.type;const h=performance.now();try{w.hasOwnProperty(b)&&w[b]instanceof Function?L=await w[b](x):r("Unknown db worker message type:",x.type)}catch(D){b="error",L={operation:x.type,message:D.message,errorClass:D.name,input:x},D.stack&&(L.stack=typeof D.stack=="string"?D.stack.split(/\n\s*/):D.stack)}V||(V=L.dbId||S()),m.post({type:b,dbId:V,messageId:x.messageId,workerReceivedTime:h,workerRespondTime:performance.now(),departureTime:x.departureTime,result:L},m.xfer)},globalThis.postMessage({type:"sqlite3-api",result:"worker1-ready"})}).bind({sqlite3:i})}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){const n=i.wasm,r=i.capi,s=i.util.toss3,_=Object.create(null);i.vfs=_,r.sqlite3_vfs.prototype.registerVfs=function(c=!1){this instanceof i.capi.sqlite3_vfs||s("Expecting a sqlite3_vfs-type argument.");const m=r.sqlite3_vfs_register(this,c?1:0);return m&&s("sqlite3_vfs_register(",this,") failed with rc",m),this.pointer!==r.sqlite3_vfs_find(this.$zName)&&s("BUG: sqlite3_vfs_find(vfs.$zName) failed for just-installed VFS",this),this},_.installVfs=function(c){let m=0;const M=["io","vfs"];for(const I of M){const S=c[I];S&&(++m,S.struct.installMethods(S.methods,!!S.applyArgcCheck),I==="vfs"&&(!S.struct.$zName&&typeof S.name=="string"&&S.struct.addOnDispose(S.struct.$zName=n.allocCString(S.name)),S.struct.registerVfs(!!S.asDefault)))}return m||s("Misuse: installVfs() options object requires at least","one of:",M),this}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.wasm.exports.sqlite3_declare_vtab)return;const n=i.wasm,r=i.capi,s=i.util.toss3,_=Object.create(null);i.vtab=_;const c=r.sqlite3_index_info;c.prototype.nthConstraint=function(I,S=!1){if(I<0||I>=this.$nConstraint)return!1;const w=n.ptr.add(this.$aConstraint,c.sqlite3_index_constraint.structInfo.sizeof*I);return S?w:new c.sqlite3_index_constraint(w)},c.prototype.nthConstraintUsage=function(I,S=!1){if(I<0||I>=this.$nConstraint)return!1;const w=n.ptr.add(this.$aConstraintUsage,c.sqlite3_index_constraint_usage.structInfo.sizeof*I);return S?w:new c.sqlite3_index_constraint_usage(w)},c.prototype.nthOrderBy=function(I,S=!1){if(I<0||I>=this.$nOrderBy)return!1;const w=n.ptr.add(this.$aOrderBy,c.sqlite3_index_orderby.structInfo.sizeof*I);return S?w:new c.sqlite3_index_orderby(w)};const m=function(I,S){return(function(w,x=!1){if(arguments.length===0&&(w=new S),w instanceof S)return this.set(w.pointer,w),w;n.isPtr(w)||i.SQLite3Error.toss("Invalid argument to",I+"()");let L=this.get(w);return x&&this.delete(w),L}).bind(new Map)},M=function(I,S){const w=m(I,S);return Object.assign(Object.create(null),{StructType:S,create:x=>{const L=w();return n.pokePtr(x,L.pointer),L},get:x=>w(x),unget:x=>w(x,!0),dispose:x=>w(x,!0)?.dispose?.()})};_.xVtab=M("xVtab",r.sqlite3_vtab),_.xCursor=M("xCursor",r.sqlite3_vtab_cursor),_.xIndexInfo=I=>new r.sqlite3_index_info(I),_.xError=function I(S,w,x){if(I.errorReporter instanceof Function)try{I.errorReporter("sqlite3_module::"+S+"(): "+w.message)}catch{}let L;return w instanceof i.WasmAllocError?L=r.SQLITE_NOMEM:arguments.length>2?L=x:w instanceof i.SQLite3Error&&(L=w.resultCode),L||r.SQLITE_ERROR},_.xError.errorReporter=i.config.error.bind(i.config),_.xRowid=(I,S)=>n.poke(I,S,"i64"),_.setupModule=function(I){let S=!1;const w=this instanceof r.sqlite3_module?this:I.struct||(S=new r.sqlite3_module);try{const x=I.methods||s("Missing 'methods' object.");for(const L of Object.entries({xConnect:"xCreate",xDisconnect:"xDestroy"})){const V=L[0],b=L[1];x[V]===!0?x[V]=x[b]:x[b]===!0&&(x[b]=x[V])}if(I.catchExceptions){const L=function(h,D){return["xConnect","xCreate"].indexOf(h)>=0?function(U,A,N,J,d,y){try{return D(...arguments)||0}catch(P){return P instanceof i.WasmAllocError||(n.dealloc(n.peekPtr(y)),n.pokePtr(y,n.allocCString(P.message))),_.xError(h,P)}}:function(...U){try{return D(...U)||0}catch(A){return _.xError(h,A)}}},V=["xCreate","xConnect","xBestIndex","xDisconnect","xDestroy","xOpen","xClose","xFilter","xNext","xEof","xColumn","xRowid","xUpdate","xBegin","xSync","xCommit","xRollback","xFindFunction","xRename","xSavepoint","xRelease","xRollbackTo","xShadowName"],b=Object.create(null);for(const h of V){const D=x[h];if(D instanceof Function)h==="xConnect"&&x.xCreate===D?b[h]=x.xCreate:h==="xCreate"&&x.xConnect===D?b[h]=x.xConnect:b[h]=L(h,D);else continue}w.installMethods(b,!1)}else w.installMethods(x,!!I.applyArgcCheck);if(w.$iVersion===0){let L;typeof I.iVersion=="number"?L=I.iVersion:w.$xIntegrity?L=4:w.$xShadowName?L=3:w.$xSavePoint||w.$xRelease||w.$xRollbackTo?L=2:L=1,w.$iVersion=L}}catch(x){throw S&&S.dispose(),x}return w},r.sqlite3_module.prototype.setupModule=function(I){return _.setupModule.call(this,I)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.kvvfs)return;const n=i.capi,r=n.sqlite3_kvvfs_methods,s=n.KVVfsFile,_=i.capi.sqlite3_vfs_find("kvvfs");if(delete n.sqlite3_kvvfs_methods,delete n.KVVfsFile,!_)return;const c=i.util,m=i.wasm,M=c.toss3,I=new r(m.exports.sqlite3__wasm_kvvfs_methods());c.assert(32<=I.$nKeySize,"unexpected kvvfsMethods.$nKeySize: "+I.$nKeySize);const S=Object.assign(Object.create(null),{rxJournalSuffix:/-journal$/,zKeyJrnl:m.allocCString("jrnl"),zKeySz:m.allocCString("sz"),keySize:I.$nKeySize,buffer:Object.assign(Object.create(null),{n:I.$nBufferSize,pool:Object.create(null)})});S.memBuffer=(O=0)=>S.buffer.pool[O]??=m.alloc(S.buffer.n),S.memBufferFree=O=>{const j=S.buffer.pool[O];j&&(m.dealloc(j),delete S.buffer.pool[O])};const w=()=>{},x=i.__isUnderTest?(...O)=>i.config.debug?.("kvvfs:",...O):w,L=(...O)=>i.config.warn?.("kvvfs:",...O),V=(...O)=>i.config.error?.("kvvfs:",...O);class b{#e=Object.create(null);#i=null;#s=0;constructor(){this.clear()}#t(){return this.#i??=Object.keys(this.#e)}key(j){return j<0||j>=this.#s?null:this.#t()[j]}getItem(j){return this.#e[j]??null}setItem(j,G){j in this.#e||(++this.#s,this.#i=null),this.#e[j]=""+G}removeItem(j){j in this.#e&&(delete this.#e[j],--this.#s,this.#i=null)}clear(){this.#e=Object.create(null),this.#i=null,this.#s=0}get length(){return this.#s}}const h=O=>O==="local"||O==="session",D=O=>h(O)?"kvvfs-"+O+"-":"",U=function(O,j=!1){if(h(O))return;const G=new Blob([O]).size;G||M(n.SQLITE_MISUSE,"Empty name is not permitted.");let $=S.keySize-1;S.rxJournalSuffix.test(O)?j||M(n.SQLITE_MISUSE,"Storage names may not have a '-journal' suffix."):["-wal","-shm"].filter(oe=>O.endsWith(oe)).length?M(n.SQLITE_MISUSE,"Storage names may not have a -wal or -shm suffix."):$-=8,G>$&&M(n.SQLITE_RANGE,"Storage name is too long. Limit =",$);let ie;for(ie=0;ieObject.assign(Object.create(null),{jzClass:O,refc:1,deleteAtRefc0:!1,storage:j||new b,keyPrefix:D(O),files:[],listeners:void 0}),N=i.kvvfs=Object.create(null);i.__isUnderTest&&(N.log=Object.assign(Object.create(null),{xOpen:!1,xClose:!1,xWrite:!1,xRead:!1,xSync:!1,xAccess:!1,xFileControl:!1,xRcrdRead:!1,xRcrdWrite:!1,xRcrdDelete:!1}));const J=function(O){const j=S.rxJournalSuffix.test(O.jzClass)?O.jzClass.replace(S.rxJournalSuffix,""):O.jzClass+"-journal";N?.log?.xClose&&x("cleaning up storage handles [",O.jzClass,j,"]",O),delete S.storagePool[O.jzClass],delete S.storagePool[j],i.__isUnderTest||(delete O.storage,delete O.refc)},d=O=>S.storagePool[O.jzClass]=S.storagePool[O.jzClass+"-journal"]=O,y=".";S.storagePool=Object.assign(Object.create(null),{[y]:A(y)}),globalThis.Storage&&(globalThis.localStorage instanceof globalThis.Storage&&(S.storagePool.local=A("local",globalThis.localStorage)),globalThis.sessionStorage instanceof globalThis.Storage&&(S.storagePool.session=A("session",globalThis.sessionStorage))),S.builtinStorageNames=Object.keys(S.storagePool);const P=O=>S.builtinStorageNames.indexOf(O)>-1;for(const O of Object.keys(S.storagePool)){const j=S.storagePool[O];S.storagePool[O+"-journal"]=j}S.setError=(O=void 0,j=n.SQLITE_ERROR)=>O?(S.lastError=O,O.resultCode|0||j):(delete S.lastError,0),S.popError=()=>{const O=S.lastError;return delete S.lastError,O};const Q=O=>{L("kvvfs.listener handler threw:",O)},F=m.exports.sqlite3__wasm_kvvfs_decode,X=m.exports.sqlite3__wasm_kvvfs_encode,ee=async function(O,j,...G){try{j.keyPrefix&&G[0]&&(G[0]=G[0].replace(j.keyPrefix,""));let $,ie,oe,ue;for(const se of j.listeners){const fe=Object.create(null);fe.storageName=j.jzClass,fe.type=O,se.decodePages;const me=se.events[O];if(me){if(!se.includeJournal&&G[0]==="jrnl")continue;if(O==="write"&&se.decodePages&&+G[0]>0){if(fe.data=[G[0]],ue?.[G[0]]){fe.data[1]=ue[G[0]];continue}$??=new TextEncoder("utf-8"),ie??=S.memBuffer(10),oe??=S.memBuffer(11);const Se=$.encode(G[1]),pe=m.heap8u();pe.set(Se,Number(ie)),pe[m.ptr.addn(ie,Se.length)]=0;const Oe=F(ie,oe,S.buffer.n);if(Oe>0)ue??=Object.create(null),ue[G[0]]=fe.data[1]=pe.slice(Number(oe),m.ptr.addn(oe,Oe));else continue}else fe.data=G.length?G.length===1?G[0]:G:void 0;try{me(fe)?.catch?.(Q)}catch(Se){L("notifyListeners [",j.jzClass,"]",O,Se)}}}}catch($){Q($)}},Z=O=>typeof O=="string"?S.storagePool[O]:S.storagePool[m.cstrToJs(O)],te=m.exports.sqlite3__wasm_kvvfsMakeKey,E=(O,j,G)=>j&&O.keyPrefix?te(j,G):G,o=(O,j,G)=>m.cstrToJs(E(O,j,G)),u=O=>+O.storage.getItem(O.keyPrefix+"sz"),p=new Map,q={vfs:Object.create(null),ioDb:Object.create(null),ioJrnl:Object.create(null)},z=new n.sqlite3_vfs(I.$pVfs),H=new n.sqlite3_io_methods(I.$pIoDb),R=new n.sqlite3_io_methods(I.$pIoJrnl),g=Object.create(null),C=Object.assign(Object.create(null),{pFileHandles:p,cache:S,storageForZClass:Z,KVVfsStorage:b,disablePageSizeChange:!0});N.log&&(N.internal=C);const B={recordHandler:{xRcrdRead:(O,j,G,$)=>{try{const ie=m.cstrToJs(O),oe=Z(ie);if(!oe)return-1;const ue=o(oe,O,j);N?.log?.xRcrdRead&&L("xRcrdRead",ie,ue,$,oe);const se=oe.storage.getItem(ue);if(se===null)return-1;const fe=se.length;if($<=0)return fe;if($===1)return m.poke(G,0),fe;$+1{try{const $=Z(O),ie=o($,O,j),oe=m.cstrToJs(G);return N?.log?.xRcrdWrite&&L("xRcrdWrite",ie,$),$.storage.setItem(ie,oe),$.listeners&&ee("write",$,ie,oe),0}catch($){return V("kvrecordWrite()",$),S.setError($,n.SQLITE_IOERR)}},xRcrdDelete:(O,j)=>{try{const G=Z(O),$=o(G,O,j);return N?.log?.xRcrdDelete&&L("xRcrdDelete",$,G),G.storage.removeItem($),G.listeners&&ee("delete",G,$),0}catch(G){return V("kvrecordDelete()",G),S.setError(G,n.SQLITE_IOERR)}}},vfs:{xOpen:function(O,j,G,$,ie){S.popError();let oe;try{j||(oe=m.allocCString(""+G+"."+(Math.random()*1e5|0)),j=oe);const ue=m.cstrToJs(j);N?.log?.xOpen&&x("xOpen",ue,"flags =",$),U(ue,!0),$&(n.SQLITE_OPEN_MAIN_DB|n.SQLITE_OPEN_TEMP_DB|n.SQLITE_OPEN_TRANSIENT_DB)&&S.rxJournalSuffix.test(ue)&&M(n.SQLITE_ERROR,"DB files may not have a '-journal' suffix.");let se=Z(ue);!se&&!($&n.SQLITE_OPEN_CREATE)&&M(n.SQLITE_ERROR,"Storage not found:",ue);const fe=q.vfs.xOpen(O,j,G,$,ie);if(fe)return fe;let me=!!(n.SQLITE_OPEN_DELETEONCLOSE&$);m.isPtr(arguments[1])&&n.sqlite3_uri_boolean(j,"delete-on-close",0)&&(me=!0);const Se=new s(G);if(c.assert(Se.$zClass,"Missing f.$zClass"),Se.addOnDispose(oe),oe=void 0,se)++se.refc,se.files.push(Se),m.poke32(ie,$);else{m.poke32(ie,$|n.SQLITE_OPEN_CREATE),c.assert(!Se.$isJournal,"Opening a journal before its db? "+ue);const pe=ue.replace(S.rxJournalSuffix,"");se=A(pe),d(se),se.files.push(Se),se.deleteAtRefc0=me,N?.log?.xOpen&&x("xOpen installed storage handle [",pe,pe+"-journal","]",se)}return p.set(G,{store:se,file:Se,jzClass:ue}),se.listeners&&ee("open",se,se.files.length),0}catch(ue){return L("xOpen:",ue),S.setError(ue)}finally{oe&&m.dealloc(oe)}},xDelete:function(O,j,G){S.popError();try{const $=m.cstrToJs(j);return S.rxJournalSuffix.test($)&&g.xRcrdDelete(j,S.zKeyJrnl),0}catch($){return L("xDelete",$),S.setError($)}},xAccess:function(O,j,G,$){S.popError();try{const ie=Z(j),oe=ie?.jzClass||m.cstrToJs(j);if(N?.log?.xAccess&&x("xAccess",oe,"flags =",G,"*pResOut =",m.peek32($),"store =",ie),!ie)try{U(oe)}catch{return m.poke32($,0),0}if(ie){const ue=ie.keyPrefix+(S.rxJournalSuffix.test(oe)?"jrnl":"1"),se=ie.storage.getItem(ue)?0:1;m.poke32($,se)}else m.poke32($,0);return 0}catch(ie){return V("xAccess",ie),S.setError(ie)}},xRandomness:function(O,j,G){const $=m.heap8u();let ie=0;const oe=Number(G);for(;iej&&m.poke8(m.ptr.add(G,j,-1),0),x("set xGetLastError",$.message),$.resultCode|0||n.SQLITE_IOERR}catch{return n.SQLITE_NOMEM}finally{m.scopedAllocPop(ie)}}return 0}},ioDb:{xClose:function(O){S.popError();try{const j=p.get(O);if(N?.log?.xClose&&x("xClose",O,j),j){p.delete(O);const G=j.store;G.files=G.files.filter($=>$!==j.file),--G.refc<=0&&G.deleteAtRefc0&&J(G),q.ioDb.xClose(O),j.file.dispose(),G.listeners&&ee("close",G,G.files.length)}return 0}catch(j){return V("xClose",j),S.setError(j)}},xFileControl:function(O,j,G){S.popError();try{const $=p.get(O);if(c.assert($,"Missing KVVfsFile handle"),N?.log?.xFileControl&&x("xFileControl",$,"op =",j),j===n.SQLITE_FCNTL_PRAGMA&&C.disablePageSizeChange){const oe=m.peekPtr(m.ptr.add(G,m.ptr.size));if(m.cstrToJs(oe)==="page_size"){N?.log?.xFileControl&&x("xFileControl pragma",m.cstrToJs(oe));const ue=m.peekPtr(m.ptr.add(G,2*m.ptr.size));if(ue)return N?.log?.xFileControl&&L("xFileControl pragma",$,"NOT setting page size to",m.cstrToJs(ue)),$.file.$szPage=-1,0;if($.file.$szPage>0)return N?.log?.xFileControl&&L("xFileControl",$,"getting page size",$.file.$szPage),m.pokePtr(G,m.allocCString(""+$.file.$szPage)),0}}const ie=q.ioDb.xFileControl(O,j,G);return ie==0&&n.SQLITE_FCNTL_SYNC===j&&$.store.listeners&&ee("sync",$.store,!1),ie}catch($){return V("xFileControl",$),S.setError($)}},xSync:function(O,j){S.popError();try{const G=p.get(O);N?.log?.xSync&&x("xSync",G),c.assert(G,"Missing KVVfsFile handle");const $=q.ioDb.xSync(O,j);return $==0&&G.store.listeners&&ee("sync",G.store,!0),$}catch(G){return V("xSync",G),S.setError(G)}}},ioJrnl:{xClose:!0}};try{c.assert(S.buffer.n>1024*129,"Heap buffer is not large enough");for(const O of Object.entries(B.recordHandler)){const j=O[0],G=O[1];g[j]=G,I[I.memberKey(j)]=m.installFunction(I.memberSignature(j),G)}for(const O of Object.entries(B.vfs)){const j=O[0],G=O[1],$=z.memberKey(j),ie=z.structInfo.members[j]||c.toss("Missing pVfs.structInfo[",j,"]");q.vfs[j]=m.functionEntry(z[$]),z[$]=m.installFunction(ie.signature,G)}for(const O of Object.entries(B.ioDb)){const j=O[0],G=O[1],$=H.memberKey(j);q.ioDb[j]=m.functionEntry(H[$])||c.toss("Missing native pIoDb[",$,"]"),H[$]=m.installFunction(H.memberSignature(j),G)}for(const O of Object.entries(B.ioJrnl)){const j=O[0],G=O[1],$=R.memberKey(j);q.ioJrnl[j]=m.functionEntry(R[$])||c.toss("Missing native pIoJrnl[",$,"]"),G===!0?R[$]=H[$]||c.toss("Missing copied pIoDb[",$,"]"):R[$]=m.installFunction(R.memberSignature(j),G)}}finally{I.dispose(),z.dispose(),H.dispose(),R.dispose()}const Y=function O(j){if(j==="")return O("local")+O("session");const G=Z(j);if(!G)return 0;G.files.length&&(globalThis.localStorage===G.storage||globalThis.sessionStorage===G.storage||M(n.SQLITE_ACCESS,"Cannot clear in-use database storage."));const $=G.storage,ie=[];let oe,ue=$.length;for(oe=0;oe$.removeItem(se)),ie.length},ne=function O(j){if(j==="")return O("local")+O("session");const G=Z(j);if(!G)return 0;const $=G.storage;let ie,oe=0;for(ie=0;ie<$.length;++ie){const ue=$.key(ie);(!G.keyPrefix||ue.startsWith(G.keyPrefix))&&(oe+=ue.length,oe+=$.getItem(ue).length)}return oe*2},le=function(...j){let G;j.length===1&&typeof j[0]=="object"?G=j[0]:j.length&&(G=Object.assign(Object.create(null),{name:j[0]}));const $=G?Z(G.name):null;$||M(n.SQLITE_NOTFOUND,"There is no kvvfs storage named",G?.name);const ie=$.storage,oe=Object.assign(Object.create(null),{name:$.jzClass,timestamp:Date.now(),pages:[]}),ue=Object.create(null),se=$.keyPrefix,fe=se?/^kvvfs-[^-]+-(\w+)/:void 0;let me=0,Se=ie.length;for(;me+pe).sort().forEach(pe=>oe.pages.push(ue[pe])),oe},ae=function(O,j=!1){!O?.timestamp||!O.name||O.size===void 0||!Array.isArray(O.pages)?M(n.SQLITE_MISUSE,"Malformed export object."):(!O.size||O.size!==(O.size|0)||O.size>=2147483647)&&M(n.SQLITE_RANGE,"Invalid db size: "+O.size),U(O.name);let G=Z(O.name);const $=!G;G?(j?!G.files||!G.jzClass?M(n.SQLITE_ERROR,"Internal storage object",O.name,"seems to be malformed."):G.files.length&&M(n.SQLITE_IOERR_ACCESS,"Cannot import db storage while it is in use."):M(n.SQLITE_ACCESS,"Storage '"+O.name+"' already exists and","overwrite was not specified."),Y(O.name)):G=A(O.name);const ie=D(O.name);let oe;try{const ue=G.storage;ue.setItem(ie+"sz",O.size),O.journal&&ue.setItem(ie+"jrnl",O.journal),O.pages[0]instanceof Uint8Array?O.pages.forEach((se,fe)=>{const me=se.length;oe??=S.memBuffer(1);const Se=S.memBuffer(0),pe=m.heap8u();pe.set(se,Number(Se)),pe[m.ptr.addn(Se,me)]=0;const Oe=X(Se,me,oe);c.assert(Oeue.setItem(ie+(fe+1),se)),$&&d(G)}catch{if(!$)try{Y(O.name)}catch{}}finally{oe&&S.memBufferFree(1)}return this},be=function(O){let j=Z(O);if(j){++j.refc;return}U(O),d(A(O))},Ae=function(O){const j=Z(O);return!j||h(j.jzClass)||P(j.jzClass)||S.rxJournalSuffix.test(O)?!1:j.refc>j.files.length||j.files.length===0?(--j.refc<=0&&J(j),!0):!1},Re=function(O){(!O||typeof O!="object")&&M(n.SQLITE_MISUSE,"Expecting a listener object.");let j=Z(O.storage);j||(O.storage&&O.reserve?(be(O.storage),j=Z(O.storage),c.assert(j,"Unexpectedly cannot fetch reserved storage "+O.storage)):M(n.SQLITE_NOTFOUND,"No such storage:",O.storage)),O.events&&(j.listeners??=[]).push(O)},Xe=function(O){const j=Z(O?.storage);if(j?.listeners&&O.events){const G=j.listeners.length;j.listeners=j.listeners.filter(ie=>ie!==O);const $=G>j.listeners.length;return j.listeners.length||(j.listeners=void 0),$}return!1};if(i.kvvfs.reserve=be,i.kvvfs.import=ae,i.kvvfs.export=le,i.kvvfs.unlink=Ae,i.kvvfs.listen=Re,i.kvvfs.unlisten=Xe,i.kvvfs.exists=O=>!!Z(O),i.kvvfs.estimateSize=ne,i.kvvfs.clear=Y,globalThis.Storage&&(n.sqlite3_js_kvvfs_size=(O="")=>ne(O),n.sqlite3_js_kvvfs_clear=(O="")=>Y(O)),i.oo1?.DB){const O=i.oo1.DB;i.oo1.JsStorageDb=function(G=i.oo1.JsStorageDb.defaultStorageName){const $=O.dbCtorHelper.normalizeArgs(...arguments);switch($.vfs="kvvfs",$.filename){case":sessionStorage:":$.filename="session";break;case":localStorage:":$.filename="local";break}const ie=/(file:(\/\/)?)([^?]+)/.exec($.filename);U(ie?ie[3]:$.filename),O.dbCtorHelper.call(this,$)},i.oo1.JsStorageDb.defaultStorageName=S.storagePool.session?"session":y;const j=i.oo1.JsStorageDb;j.prototype=Object.create(O.prototype),j.clearStorage=Y,j.prototype.clearStorage=function(){return j.clearStorage(this.affirmOpen().dbFilename(),!0)},j.storageSize=ne,j.prototype.storageSize=function(){return j.storageSize(this.affirmOpen().dbFilename(),!0)}}if(i.__isUnderTest&&i.vtab){const O=Object.assign(Object.create(null),{rowid:{type:"INTEGER"},name:{type:"TEXT"},nRef:{type:"INTEGER"},nOpen:{type:"INTEGER"},isTransient:{type:"INTEGER"},dbSize:{type:"INTEGER"}});Object.keys(O).forEach((ue,se)=>O[ue].colId=se);const j=i.vtab,G=Object.assign(Object.create(null),{row:function(){return S.storagePool[this.names[this.rowid]]}});Object.assign(Object.create(G),{rowid:0,names:Object.keys(S.storagePool).filter(ue=>!S.rxJournalSuffix.test(ue))});const $=function(ue,se){const fe=ue instanceof n.sqlite3_vtab_cursor?ue:j.xCursor.get(ue);return(se||!fe.vTabState)&&(fe.vTabState=Object.assign(Object.create(G),{rowid:0,names:Object.keys(S.storagePool).filter(me=>!S.rxJournalSuffix.test(me))})),fe.vTabState},ie=()=>{},oe=function ue(){return ue.mod??=new i.capi.sqlite3_module().setupModule({catchExceptions:!0,methods:{xConnect:function(se,fe,me,Se,pe,Oe){try{const De=[];Object.keys(O).forEach(Me=>{De.push(Me+" "+O[Me].type)});const nt=n.sqlite3_declare_vtab(se,"CREATE TABLE ignored("+De.join(",")+")");if(nt===0){const Me=j.xVtab.create(pe);c.assert(Me===j.xVtab.get(m.peekPtr(pe)),"output pointer check failed")}return nt}catch(De){return j.xError("xConnect",De,n.SQLITE_ERROR)}},xCreate:m.ptr.null,xDisconnect:function(se){return j.xVtab.dispose(se),0},xOpen:function(se,fe){return j.xCursor.create(fe),0},xClose:function(se){const fe=j.xCursor.unget(se);return delete fe.vTabState,fe.dispose(),0},xNext:function(se){const fe=j.xCursor.get(se);return++$(fe).rowid,0},xColumn:function(se,fe,me){const Se=$(se),pe=Se.row();switch(c.assert(pe,"Unexpected xColumn call"),me){case O.rowid.colId:n.sqlite3_result_int(fe,Se.rowid);break;case O.name.colId:n.sqlite3_result_text(fe,pe.jzClass,-1,n.SQLITE_TRANSIENT);break;case O.nRef.colId:n.sqlite3_result_int(fe,pe.refc);break;case O.nOpen.colId:n.sqlite3_result_int(fe,pe.files.length);break;case O.isTransient.colId:n.sqlite3_result_int(fe,!!pe.deleteAtRefc0);break;case O.dbSize.colId:n.sqlite3_result_int(fe,u(pe));break;default:return n.sqlite3_result_error(fe,"Invalid column id: "+me),n.SQLITE_RANGE}return 0},xRowid:function(se,fe){const me=$(se);return j.xRowid(fe,me.rowid),0},xEof:function(se){const fe=$(se);return ie("xEof?="+!fe.row(),...arguments),!fe.row()},xFilter:function(se,fe,me,Se,pe){return $(se,!0),0},xBestIndex:function(se,fe){const me=new n.sqlite3_index_info(fe);return me.$estimatedRows=S.storagePool.size,me.$estimatedCost=1,me.dispose(),0}}})};i.kvvfs.create_module=function(ue,se="sqlite_kvvfs"){return n.sqlite3_create_module(ue,se,oe(),m.ptr.null)}}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.opfs&&i.config.disable.vfs["opfs-vfs"])return;const n=i.util.toss;i.capi;const r=i.util;i.wasm;const s=i.opfs=Object.create(null);s.thisThreadHasOPFS=()=>globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&navigator?.storage?.getDirectory,s.getRootDir=async function c(){return c.promise??=navigator.storage.getDirectory().then(m=>(s.rootDirectory=m,m)).catch(m=>{throw delete c.promise,m})},s.getResolvedPath=function(c,m){const M=new URL(c,"file://irrelevant").pathname;return m?M.split("/").filter(I=>!!I):M},s.getDirForFilename=async function(m,M=!1){const I=s.getResolvedPath(m,!0),S=I.pop();let w=await s.getRootDir();for(const x of I)x&&(w=await w.getDirectoryHandle(x,{create:!!M}));return[w,S]},s.mkdir=async function(c){try{return await s.getDirForFilename(c+"/filepart",!0),!0}catch{return!1}},s.entryExists=async function(c){try{const[m,M]=await s.getDirForFilename(c);return await m.getFileHandle(M),!0}catch{return!1}},s.randomFilename=function c(m=16){c._chars||(c._chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012346789",c._n=c._chars.length);const M=[];let I=0;for(;I=15&&(r.affirmDbHeader(x),L=!0),S.write(x,{at:w}),w+=x.byteLength;if((w<512||w%512!==0)&&n("Input size",w,"is not correct for an SQLite database."),!L){const V=new Uint8Array(20);S.read(V,{at:0}),r.affirmDbHeader(V)}return S.write(new Uint8Array([1,1]),{at:18}),w}catch(V){throw await S.close(),S=void 0,await M.removeEntry(I).catch(()=>{}),V}finally{S&&await S.close()}};s.importDb=async function(c,m){if(m instanceof Function)return _(c,m);m instanceof ArrayBuffer&&(m=new Uint8Array(m)),r.affirmIsDb(m);const M=m.byteLength,[I,S]=await s.getDirForFilename(c,!0);let w,x=0;try{return w=await(await I.getFileHandle(S,{create:!0})).createSyncAccessHandle(),w.truncate(0),x=w.write(m,{at:0}),x!=M&&n("Expected to write "+M+" bytes but wrote "+x+"."),w.write(new Uint8Array([1,1]),{at:18}),x}catch(L){throw w&&(await w.close(),w=void 0),await I.removeEntry(S).catch(()=>{}),L}finally{w&&await w.close()}},s.vfsInstallationFeatureCheck=function(c){!globalThis.SharedArrayBuffer||!globalThis.Atomics?n("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"):typeof WorkerGlobalScope>"u"?n("The OPFS sqlite3_vfs cannot run in the main thread","because it requires Atomics.wait()."):!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle?.prototype?.createSyncAccessHandle||!navigator?.storage?.getDirectory?n("Missing required OPFS APIs."):c==="opfs-wl"&&!globalThis.Atomics.waitAsync&&n("The",c,"VFS requires Atomics.waitAsync(), which is not available.")},s.initOptions=function(m,M){const I=new URL(globalThis.location.href).searchParams;if(!I.has(m+"-disable")){try{s.vfsInstallationFeatureCheck(m)}catch{return}return M=r.nu(M),M.vfsName=m,M.verbose??=I.has("opfs-verbose")?+I.get("opfs-verbose"):1,M.sanityChecks??=I.has("opfs-sanity-check"),s.proxyUri||(s.proxyUri="sqlite3-opfs-async-proxy.js",i.scriptInfo?.sqlite3Dir&&(s.proxyUri=i.scriptInfo.sqlite3Dir+s.proxyUri)),M.proxyUri??=s.proxyUri,typeof M.proxyUri=="function"&&(M.proxyUri=M.proxyUri()),s.options=M}},s.createVfsState=function(){const c=r.nu(),m=s.options;c.verbose=m.verbose;const M=[i.config.error,i.config.warn,i.config.log],I=m.vfsName||n("Maintenance required: missing VFS name"),S=(F,...X)=>{c.verbose>F&&M[F](I+":",...X)},w=(...F)=>S(2,...F),x=(...F)=>S(1,...F),L=(...F)=>S(0,...F),V=i.capi,b=i.wasm,h=c.vfs=new V.sqlite3_vfs,D=h.ioMethods=new V.sqlite3_io_methods;D.$iVersion=1,h.$iVersion=2,h.$szOsFile=V.sqlite3_file.structInfo.sizeof,h.$mxPathname=1024,h.$zName=b.allocCString(I),h.addOnDispose("$zName",h.$zName,D),h.metrics=r.nu({counters:r.nu(),dump:function(){let F,X=0,ee=0,Z=0;for(F in c.opIds){const te=U[F];X+=te.count,ee+=te.time,Z+=te.wait,te.avgTime=te.count&&te.time?te.time/te.count:0,te.avgWait=te.count&&te.wait?te.wait/te.count:0}i.config.log(globalThis.location.href,"metrics for",globalThis.location.href,":",U,` Total of`,X,"op(s) for",ee,"ms (incl. "+Z+" ms of waiting on the async side)"),i.config.log("Serialization metrics:",h.metrics.counters.s11n),h.worker?.postMessage?.({type:"opfs-async-metrics"})},reset:function(){let F;const X=te=>te.count=te.time=te.wait=0,ee=h.metrics.counters;for(F in c.opIds)X(ee[F]=Object.create(null));let Z=ee.s11n=Object.create(null);Z=Z.serialize=Object.create(null),Z.count=Z.time=0,Z=ee.s11n.deserialize=Object.create(null),Z.count=Z.time=0}}),c.asyncIdleWaitTime=150,c.asyncS11nExceptions=1,c.fileBufferSize=1024*64,c.sabS11nOffset=c.fileBufferSize,c.sabS11nSize=h.$mxPathname*2,c.sabIO=new SharedArrayBuffer(c.fileBufferSize+c.sabS11nSize),c.opIds=Object.create(null);{let F=0;c.opIds.whichOp=F++,c.opIds.rc=F++,c.opIds.xAccess=F++,c.opIds.xClose=F++,c.opIds.xDelete=F++,c.opIds.xDeleteNoWait=F++,c.opIds.xFileSize=F++,c.opIds.xLock=F++,c.opIds.xOpen=F++,c.opIds.xRead=F++,c.opIds.xSleep=F++,c.opIds.xSync=F++,c.opIds.xTruncate=F++,c.opIds.xUnlock=F++,c.opIds.xWrite=F++,c.opIds.mkdir=F++,c.opIds["opfs-async-metrics"]=F++,c.opIds["opfs-async-shutdown"]=F++,c.opIds.retry=F++,c.sabOP=new SharedArrayBuffer(F*4)}c.sq3Codes=Object.create(null);for(const F of["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","SQLITE_LOCK_NONE","SQLITE_LOCK_SHARED","SQLITE_LOCK_RESERVED","SQLITE_LOCK_PENDING","SQLITE_LOCK_EXCLUSIVE"])c.sq3Codes[F]=V[F]??n("Maintenance required: not found:",F);c.opfsFlags=Object.assign(Object.create(null),{OPFS_UNLOCK_ASAP:1,OPFS_UNLINK_BEFORE_OPEN:2,defaultUnlockAsap:!1}),h.metrics.reset();const U=h.metrics.counters,A=h.opRun=(F,...X)=>{const ee=c.opIds[F]||n(h.vfsName+": Invalid op ID:",F);c.s11n.serialize(...X),Atomics.store(c.sabOPView,c.opIds.rc,-1),Atomics.store(c.sabOPView,c.opIds.whichOp,ee),Atomics.notify(c.sabOPView,c.opIds.whichOp);const Z=performance.now();for(;Atomics.wait(c.sabOPView,c.opIds.rc,-1)!=="not-equal";);const te=Atomics.load(c.sabOPView,c.opIds.rc);if(U[F].wait+=performance.now()-Z,te&&c.asyncS11nExceptions){const E=c.s11n.deserialize();E&&L(F+"() async error:",...E)}return te},N=Object.create(null);N.op=void 0,N.start=void 0;const J=h.mTimeStart=F=>{N.start=performance.now(),N.op=F,++U[F].count},d=h.mTimeEnd=()=>U[N.op].time+=performance.now()-N.start,y=h.__openFiles=Object.create(null);h.ioSyncWrappers=r.nu({xCheckReservedLock:function(F,X){return b.poke(X,0,"i32"),0},xClose:function(F){J("xClose");let X=0;const ee=y[F];return ee&&(delete y[F],X=A("xClose",F),ee.sq3File&&ee.sq3File.dispose()),d(),X},xDeviceCharacteristics:function(F){return V.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(F,X,ee){return V.SQLITE_NOTFOUND},xFileSize:function(F,X){J("xFileSize");let ee=A("xFileSize",F);if(ee==0)try{const Z=c.s11n.deserialize()[0];b.poke(X,Z,"i64")}catch(Z){L("Unexpected error reading xFileSize() result:",Z),ee=c.sq3Codes.SQLITE_IOERR}return d(),ee},xRead:function(F,X,ee,Z){J("xRead");const te=y[F];let E;try{E=A("xRead",F,ee,Number(Z)),(E===0||V.SQLITE_IOERR_SHORT_READ===E)&&b.heap8u().set(te.sabView.subarray(0,ee),Number(X))}catch(o){L("xRead(",arguments,") failed:",o,te),E=V.SQLITE_IOERR_READ}return d(),E},xSync:function(F,X){J("xSync");const ee=A("xSync",F,X);return d(),ee},xTruncate:function(F,X){J("xTruncate");const ee=A("xTruncate",F,Number(X));return d(),ee},xWrite:function(F,X,ee,Z){J("xWrite");const te=y[F];let E;try{te.sabView.set(b.heap8u().subarray(Number(X),Number(X)+ee)),E=A("xWrite",F,ee,Number(Z))}catch(o){L("xWrite(",arguments,") failed:",o,te),E=V.SQLITE_IOERR_WRITE}return d(),E}}),h.vfsSyncWrappers={xAccess:function(F,X,ee,Z){J("xAccess");const te=A("xAccess",b.cstrToJs(X));return b.poke(Z,te?0:1,"i32"),d(),0},xCurrentTime:function(F,X){return b.poke(X,24405875e-1+new Date().getTime()/864e5,"double"),0},xCurrentTimeInt64:function(F,X){return b.poke(X,24405875e-1*864e5+new Date().getTime(),"i64"),0},xDelete:function(F,X,ee){J("xDelete");const Z=A("xDelete",b.cstrToJs(X),ee,!1);return d(),Z},xFullPathname:function(F,X,ee,Z){return b.cstrncpy(Z,X,ee)te[typeof u]||n("Maintenance required: this value type cannot be serialized.",u),o=u=>{switch(u){case te.number.id:return te.number;case te.bigint.id:return te.bigint;case te.boolean.id:return te.boolean;case te.string.id:return te.string;default:n("Invalid type ID:",u)}};return c.s11n.deserialize=function(u=!1){performance.now();const p=ee[0],q=p?[]:null;if(p){const z=[];let H=1,R,g,C;for(R=0;R(te=!0,h.dispose(),Z(R)),o=()=>{try{X(i,h)}catch(R){return E(R)}return te=!1,ee(i)},u=s.options;let p=u.proxyUri+(u.proxyUri.indexOf("?")<0?"?":"&")+"vfs="+I;const q=h.worker=new Worker(new URL(p,self.location.href));let z=setTimeout(()=>{te===void 0&&E(new Error("Timeout while waiting for OPFS async proxy worker."))},4e3);q._originalOnError=q.onerror,q.onerror=function(R){L("Error initializing OPFS asyncer:",R),E(new Error("Loading OPFS async Worker failed for unknown reasons."))},h.opRun;const H=function(){const R=b.scopedAllocPush(),g=new V.sqlite3_file;try{const C=g.pointer,B=V.SQLITE_OPEN_CREATE|V.SQLITE_OPEN_READWRITE|V.SQLITE_OPEN_MAIN_DB,Y=b.scopedAlloc(8),ne="/sanity/check/file"+randomFilename(8),le=b.scopedAllocCString(ne);let ae;if(c.s11n.serialize("This is ä string."),ae=c.s11n.deserialize(),w("deserialize() says:",ae),ae[0]!=="This is ä string."&&n("String d13n error."),h.vfsSyncWrappers.xAccess(h.pointer,le,0,Y),ae=b.peek(Y,"i32"),w("xAccess(",ne,") exists ?=",ae),ae=h.vfsSyncWrappers.xOpen(h.pointer,le,C,B,Y),w("open rc =",ae,"state.sabOPView[xOpen] =",c.sabOPView[c.opIds.xOpen]),ae!==0){L("open failed with code",ae);return}h.vfsSyncWrappers.xAccess(h.pointer,le,0,Y),ae=b.peek(Y,"i32"),ae||n("xAccess() failed to detect file."),ae=h.ioSyncWrappers.xSync(g.pointer,0),ae&&n("sync failed w/ rc",ae),ae=h.ioSyncWrappers.xTruncate(g.pointer,1024),ae&&n("truncate failed w/ rc",ae),b.poke(Y,0,"i64"),ae=h.ioSyncWrappers.xFileSize(g.pointer,Y),ae&&n("xFileSize failed w/ rc",ae),w("xFileSize says:",b.peek(Y,"i64")),ae=h.ioSyncWrappers.xWrite(g.pointer,le,10,1),ae&&n("xWrite() failed!");const be=b.scopedAlloc(16);ae=h.ioSyncWrappers.xRead(g.pointer,be,6,2),b.poke(be+6,0);let Ae=b.cstrToJs(be);w("xRead() got:",Ae),Ae!=="sanity"&&n("Unexpected xRead() value."),h.vfsSyncWrappers.xSleep&&(w("xSleep()ing before close()ing..."),h.vfsSyncWrappers.xSleep(h.pointer,2e3),w("waking up from xSleep()")),ae=h.ioSyncWrappers.xClose(C),w("xClose rc =",ae,"sabOPView =",c.sabOPView),w("Deleting file:",ne),h.vfsSyncWrappers.xDelete(h.pointer,le,4660),h.vfsSyncWrappers.xAccess(h.pointer,le,0,Y),ae=b.peek(Y,"i32"),ae&&n("Expecting 0 from xAccess(",ne,") after xDelete()."),x("End of OPFS sanity checks.")}finally{g.dispose(),b.scopedAllocPop(R)}};q.onmessage=function({data:R}){switch(R.type){case"opfs-unavailable":E(new Error(R.payload.join(" ")));break;case"opfs-async-loaded":delete c.vfs,q.postMessage({type:"opfs-async-init",args:r.nu(c)});break;case"opfs-async-inited":if(te===!0)break;clearTimeout(z),z=null;try{i.vfs.installVfs({io:{struct:h.ioMethods,methods:h.ioSyncWrappers},vfs:{struct:h,methods:h.vfsSyncWrappers}}),c.sabOPView=new Int32Array(c.sabOP),c.sabFileBufView=new Uint8Array(c.sabIO,0,c.fileBufferSize),c.sabS11nView=new Uint8Array(c.sabIO,c.sabS11nOffset,c.sabS11nSize),h.initS11n(),delete h.initS11n,u.sanityChecks&&(x("Running sanity checks because of opfs-sanity-check URL arg..."),H()),s.thisThreadHasOPFS()?s.getRootDir().then(g=>{q.onerror=q._originalOnError,delete q._originalOnError,w("End of OPFS sqlite3_vfs setup.",h),o()}).catch(E):o()}catch(g){L(g),E(g)}break;case"debug":x("debug message from worker:",R);break;default:{const g="Unexpected message from the OPFS async worker: "+JSON.stringify(R);L(g),E(new Error(g));break}}}})},c}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.opfs||i.config.disable?.vfs?.opfs)return;const n=i.util,r=i.opfs||i.util.toss("Missing sqlite3.opfs"),s=async function(_){if(_=r.initOptions("opfs",_),!_)return i;const c=i.capi,m=r.createVfsState().vfs,M=m.metrics.counters,I=m.mTimeStart,S=m.mTimeEnd,w=m.opRun,x=m.__openFiles;return m.bindVfs(n.nu({xLock:function(L,V){I("xLock"),++M.xLock.count;const b=x[L];let h=0;return b.lockType?b.lockType=V:(h=w("xLock",L,V),h===0&&(b.lockType=V)),S(),h},xUnlock:function(L,V){I("xUnlock"),++M.xUnlock.count;const b=x[L];let h=0;return c.SQLITE_LOCK_NONE===V&&b.lockType&&(h=w("xUnlock",L,V)),h===0&&(b.lockType=V),S(),h}}),function(L,V){if(L.oo1){const b=function(...h){const D=L.oo1.DB.dbCtorHelper.normalizeArgs(...h);D.vfs=V.$zName,L.oo1.DB.dbCtorHelper.call(this,D)};b.prototype=Object.create(L.oo1.DB.prototype),L.oo1.OpfsDb=b,b.importDb=r.importDb,L.oo1.DB.dbCtorHelper.setVfsPostOpenCallback(m.pointer,function(h,D){D.capi.sqlite3_busy_timeout(h,1e4)})}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async _=>s().catch(c=>{_.config.warn("Ignoring inability to install 'opfs' sqlite3_vfs:",c)}))}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.["opfs-sahpool"])return;const n=i.util.toss,r=i.util.toss3,s=Object.create(null),_=i.capi,c=i.util,m=i.wasm,M=4096,I=512,S=4,w=8,x=I+S,L=I,V=x,b=M,h=_.SQLITE_OPEN_MAIN_DB|_.SQLITE_OPEN_MAIN_JOURNAL|_.SQLITE_OPEN_SUPER_JOURNAL|_.SQLITE_OPEN_WAL,D=_.SQLITE_OPEN_MEMORY,U=".opaque",A=()=>Math.random().toString(36).slice(2),N=new TextDecoder,J=new TextEncoder,d=Object.assign(Object.create(null),{name:"opfs-sahpool",directory:void 0,initialCapacity:6,clearOnInit:!1,verbosity:2,forceReinitIfPreviouslyFailed:!1}),y=[i.config.error,i.config.warn,i.config.log];i.config.log;const P=i.config.warn;i.config.error;const Q=new Map,F=R=>Q.get(R),X=(R,g)=>{g?Q.set(R,g):Q.delete(R)},ee=new Map,Z=R=>ee.get(R),te=(R,g)=>{g?ee.set(R,g):ee.delete(R)},E={xCheckReservedLock:function(R,g){const C=Z(R);return C.log("xCheckReservedLock"),C.storeErr(),m.poke32(g,1),0},xClose:function(R){const g=Z(R);g.storeErr();const C=g.getOFileForS3File(R);if(C)try{g.log(`xClose ${C.path}`),g.mapS3FileToOFile(R,!1),C.sah.flush(),C.flags&_.SQLITE_OPEN_DELETEONCLOSE&&g.deletePath(C.path)}catch(B){return g.storeErr(B,_.SQLITE_IOERR)}return 0},xDeviceCharacteristics:function(R){return _.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(R,g,C){return _.SQLITE_NOTFOUND},xFileSize:function(R,g){const C=Z(R);C.log("xFileSize");const B=C.getOFileForS3File(R).sah.getSize()-b;return m.poke64(g,BigInt(B)),0},xLock:function(R,g){const C=Z(R);C.log(`xLock ${g}`),C.storeErr();const B=C.getOFileForS3File(R);return B.lockType=g,0},xRead:function(R,g,C,B){const Y=Z(R);Y.storeErr();const ne=Y.getOFileForS3File(R);Y.log(`xRead ${ne.path} ${C} @ ${B}`);try{const le=ne.sah.read(m.heap8u().subarray(Number(g),Number(g)+C),{at:b+Number(B)});return leg&&m.poke8(m.ptr.add(C,g,-1),0)}catch{return _.SQLITE_NOMEM}finally{m.scopedAllocPop(ne)}}return Y?Y.sqlite3Rc||_.SQLITE_IOERR:0},xOpen:function(g,C,B,Y,ne){const le=F(g);try{Y&=~D,le.log(`xOpen ${m.cstrToJs(C)} ${Y}`);const ae=C&&m.peek8(C)?le.getPath(C):A();let be=le.getSAHForPath(ae);!be&&Y&_.SQLITE_OPEN_CREATE&&(le.getFileCount()X(g.pointer,0)),B&&(g.$xRandomness=B.$xRandomness,g.$xSleep=B.$xSleep,B.dispose()),!g.$xRandomness&&!u.xRandomness&&(u.xRandomness=function(Y,ne,le){const ae=m.heap8u();let be=0;const Ae=Number(le);for(;be0),i.vfs.installVfs({vfs:{struct:g,methods:u}}),g};class q{vfsDir;#e;#i;#s;#t=new Map;#n=new Map;#o=new Set;#a=new Map;#r=new Uint8Array(x);#c;#l;#_;constructor(g=Object.create(null)){this.#_=g.verbosity??d.verbosity,this.vfsName=g.name||d.name,this.#l=p(this.vfsName),X(this.#l.pointer,this),this.vfsDir=g.directory||"."+this.vfsName,this.#c=new DataView(this.#r.buffer,this.#r.byteOffset),this.isReady=this.reset(!!(g.clearOnInit??d.clearOnInit)).then(()=>{if(this.$error)throw this.$error;return this.getCapacity()?Promise.resolve(void 0):this.addCapacity(g.initialCapacity||d.initialCapacity)})}#u(g,...C){this.#_>g&&y[g](this.vfsName+":",...C)}log(...g){this.#u(2,...g)}warn(...g){this.#u(1,...g)}error(...g){this.#u(0,...g)}getVfs(){return this.#l}getCapacity(){return this.#t.size}getFileCount(){return this.#n.size}getFileNames(){const g=[];for(const C of this.#n.keys())g.push(C);return g}async addCapacity(g){for(let C=0;C{try{const ne=await Y.createSyncAccessHandle();if(this.#t.set(ne,B),g)ne.truncate(b),this.setAssociatedPath(ne,"",0);else{const le=this.getAssociatedPath(ne);le?this.#n.set(le,ne):this.#o.add(ne)}}catch(ne){throw this.storeErr(ne),this.releaseAccessHandles(),ne}}))}getAssociatedPath(g){g.read(this.#r,{at:0});const C=this.#c.getUint32(L);if(this.#r[0]&&(C&_.SQLITE_OPEN_DELETEONCLOSE||(C&h)===0))return P(`Removing file with unexpected flags ${C.toString(16)}`,this.#r),this.setAssociatedPath(g,"",0),"";const B=new Uint32Array(w/4);g.read(B,{at:V});const Y=this.computeDigest(this.#r,C);if(B.every((ne,le)=>ne===Y[le])){const ne=this.#r.findIndex(le=>le===0);return ne===0&&g.truncate(b),ne?N.decode(this.#r.subarray(0,ne)):""}else return P("Disassociating file with bad digest."),this.setAssociatedPath(g,"",0),""}setAssociatedPath(g,C,B){const Y=J.encodeInto(C,this.#r);I<=Y.written+1&&n("Path too long:",C),C&&B&&(B|=D),this.#r.fill(0,Y.written,I),this.#c.setUint32(L,B);const ne=this.computeDigest(this.#r,B);g.write(this.#r,{at:0}),g.write(ne,{at:V}),g.flush(),C?(this.#n.set(C,g),this.#o.delete(g)):(g.truncate(b),this.#o.add(g))}computeDigest(g,C){if(C&D){let B=3735928559,Y=1103547991;for(const ne of g)B=Math.imul(B^ne,2654435761),Y=Math.imul(Y^ne,104729);return new Uint32Array([B>>>0,Y>>>0])}else return new Uint32Array([0,0])}async reset(g){await this.isReady;let C=await navigator.storage.getDirectory(),B;for(const Y of this.vfsDir.split("/"))Y&&(B=C,C=await C.getDirectoryHandle(Y,{create:!0}));return this.#e=C,this.#s=B,this.#i=await this.#e.getDirectoryHandle(U,{create:!0}),this.releaseAccessHandles(),this.acquireAccessHandles(g)}getPath(g){return m.isPtr(g)&&(g=m.cstrToJs(g)),(g instanceof URL?g:new URL(g,"file://localhost/")).pathname}deletePath(g){const C=this.#n.get(g);return C&&(this.#n.delete(g),this.setAssociatedPath(C,"",0)),!!C}storeErr(g,C){return g&&(g.sqlite3Rc=C||_.SQLITE_IOERR,this.error(g)),this.$error=g,C}popErr(){const g=this.$error;return this.$error=void 0,g}nextAvailableSAH(){const[g]=this.#o.keys();return g}getOFileForS3File(g){return this.#a.get(g)}mapS3FileToOFile(g,C){C?(this.#a.set(g,C),te(g,this)):(this.#a.delete(g),te(g,!1))}hasFilename(g){return this.#n.has(g)}getSAHForPath(g){return this.#n.get(g)}async removeVfs(){if(!this.#l.pointer||!this.#i)return!1;_.sqlite3_vfs_unregister(this.#l.pointer),this.#l.dispose(),delete s[this.vfsName];try{this.releaseAccessHandles(),await this.#e.removeEntry(U,{recursive:!0}),this.#i=void 0,await this.#s.removeEntry(this.#e.name,{recursive:!0}),this.#e=this.#s=void 0}catch(g){i.config.error(this.vfsName,"removeVfs() failed with no recovery strategy:",g)}return!0}pauseVfs(){return this.#a.size>0&&i.SQLite3Error.toss(_.SQLITE_MISUSE,"Cannot pause VFS",this.vfsName,"because it has opened files."),this.#t.size>0&&(_.sqlite3_vfs_unregister(this.vfsName),this.releaseAccessHandles()),this}isPaused(){return this.#t.size===0}async unpauseVfs(){return this.#t.size===0?this.acquireAccessHandles(!1).then(()=>_.sqlite3_vfs_register(this.#l,0),this):this}exportFile(g){const C=this.#n.get(g)||n("File not found:",g),B=C.getSize()-b,Y=new Uint8Array(B>0?B:0);if(B>0){const ne=C.read(Y,{at:b});ne!=B&&n("Expected to read "+B+" bytes but read "+ne+".")}return Y}async importDbChunked(g,C){const B=this.#n.get(g)||this.nextAvailableSAH()||n("No available handles to import to.");B.truncate(0);let Y=0,ne,le=!1;try{for(;(ne=await C())!==void 0;)ne instanceof ArrayBuffer&&(ne=new Uint8Array(ne)),!le&&Y===0&&ne.byteLength>=15&&(c.affirmDbHeader(ne),le=!0),B.write(ne,{at:b+Y}),Y+=ne.byteLength;if((Y<512||Y%512!==0)&&n("Input size",Y,"is not correct for an SQLite database."),!le){const ae=new Uint8Array(20);B.read(ae,{at:0}),c.affirmDbHeader(ae)}B.write(new Uint8Array([1,1]),{at:b+18})}catch(ae){throw this.setAssociatedPath(B,"",0),ae}return this.setAssociatedPath(B,g,_.SQLITE_OPEN_MAIN_DB),Y}importDb(g,C){if(C instanceof ArrayBuffer)C=new Uint8Array(C);else if(C instanceof Function)return this.importDbChunked(g,C);const B=this.#n.get(g)||this.nextAvailableSAH()||n("No available handles to import to."),Y=C.byteLength;(Y<512||Y%512!=0)&&n("Byte array size is invalid for an SQLite db.");const ne="SQLite format 3";for(let ae=0;ae<15;++ae)ne.charCodeAt(ae)!==C[ae]&&n("Input does not contain an SQLite database header.");const le=B.write(C,{at:b});return le!=Y?(this.setAssociatedPath(B,"",0),n("Expected to write "+Y+" bytes but wrote "+le+".")):(B.write(new Uint8Array([1,1]),{at:b+18}),this.setAssociatedPath(B,g,_.SQLITE_OPEN_MAIN_DB)),le}}class z{#e;constructor(g){this.#e=g,this.vfsName=g.vfsName}async addCapacity(g){return this.#e.addCapacity(g)}async reduceCapacity(g){return this.#e.reduceCapacity(g)}getCapacity(){return this.#e.getCapacity(this.#e)}getFileCount(){return this.#e.getFileCount()}getFileNames(){return this.#e.getFileNames()}async reserveMinimumCapacity(g){const C=this.#e.getCapacity();return Cthis)}isPaused(){return this.#e.isPaused()}}const H=async()=>{const R=await navigator.storage.getDirectory(),g=".opfs-sahpool-sync-check-"+A(),C=(await(await R.getFileHandle(g,{create:!0})).createSyncAccessHandle()).close();return await C,await R.removeEntry(g),C?.then&&n("The local OPFS API is too old for opfs-sahpool:","it has an async FileSystemSyncAccessHandle.close() method."),!0};i.installOpfsSAHPoolVfs=async function(R=Object.create(null)){R=Object.assign(Object.create(null),d,R||{});const g=R.name;if(R.$testThrowPhase1)throw R.$testThrowPhase1;if(s[g])try{return await s[g]}catch(C){if(R.forceReinitIfPreviouslyFailed)delete s[g];else throw C}return!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle||!navigator?.storage?.getDirectory?s[g]=Promise.reject(new Error("Missing required OPFS APIs.")):s[g]=H().then(async function(){if(R.$testThrowPhase2)throw R.$testThrowPhase2;const C=new q(R);return C.isReady.then(async()=>{const B=new z(C);if(i.oo1){const Y=i.oo1,ne=C.getVfs(),le=function(...ae){const be=Y.DB.dbCtorHelper.normalizeArgs(...ae);be.vfs=ne.$zName,Y.DB.dbCtorHelper.call(this,be)};le.prototype=Object.create(Y.DB.prototype),B.OpfsSAHPoolDb=le}return C.log("VFS initialized."),B}).catch(async B=>{throw await C.removeVfs().catch(()=>{}),B})}).catch(C=>s[g]=Promise.reject(C))}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.opfs||i.config.disable?.vfs?.["opfs-wl"])return;const n=i.util;i.util.toss;const r=i.opfs,s="opfs-wl",_=async function(c){if(c=r.initOptions(s,c),!c)return i;i.capi;const m=r.createVfsState().vfs;m.metrics.counters;const M=m.mTimeStart,I=m.mTimeEnd,S=m.opRun,w=m.__openFiles;return m.bindVfs(n.nu({xLock:function(x,L){M("xLock");const V=w[x],b=S("xLock",x,L);return b||(V.lockType=L),I(),b},xUnlock:function(x,L){M("xUnlock");const V=w[x],b=S("xUnlock",x,L);return b||(V.lockType=L),I(),b}}),function(x,L){if(x.oo1){const V=function(...b){const h=x.oo1.DB.dbCtorHelper.normalizeArgs(...b);h.vfs=L.$zName,x.oo1.DB.dbCtorHelper.call(this,h)};V.prototype=Object.create(x.oo1.DB.prototype),x.oo1.OpfsWlDb=V,V.importDb=r.importDb}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async c=>_().catch(m=>{c.config.warn("Ignoring inability to install the",s,"sqlite3_vfs:",m)}))});try{const i=Object.assign(Object.create(null),{memory:typeof Qe<"u"?Qe:t.wasmMemory,exports:typeof tt<"u"?tt:Object.prototype.hasOwnProperty.call(t,"wasmExports")?t.wasmExports:t.asm},globalThis.sqlite3ApiBootstrap.defaultConfig,globalThis.sqlite3ApiConfig||{});e.debugModule("Bootstrapping lib config",i);const n=globalThis.sqlite3ApiBootstrap(i);return delete globalThis.sqlite3ApiBootstrap,n}catch(i){throw console.error("sqlite3ApiBootstrap() error:",i),i}},Ot?Ee=f:Ee=new Promise((e,t)=>{Tt=e,kt=t}),Ee}bt=(function(){const He=bt;if(!He)throw new Error("Expecting sqlite3InitModule to be defined by the Emscripten build.");const Ee=globalThis.sqlite3InitModuleState=Object.assign(Object.create(null),{moduleScript:globalThis?.document?.currentScript,isWorker:typeof WorkerGlobalScope<"u",location:globalThis.location,urlParams:globalThis?.location?.href?new URL(globalThis.location.href).searchParams:new URLSearchParams,wasmFilename:"sqlite3.wasm"});if(Ee.debugModule=Ee.urlParams.has("sqlite3.debugModule")?(...je)=>console.warn("sqlite3.debugModule:",...je):()=>{},Ee.urlParams.has("sqlite3.dir"))Ee.sqlite3Dir=Ee.urlParams.get("sqlite3.dir")+"/";else if(Ee.moduleScript){const je=Ee.moduleScript.src.split("/");je.pop(),Ee.sqlite3Dir=je.join("/")+"/"}const f=globalThis.sqlite3InitModule=function je(...Ve){return Ee.emscriptenLocateFile=Ve[0]?.locateFile,Ee.emscriptenInstantiateWasm=Ve[0]?.instantiateWasm,He(...Ve).then(ze=>{Ee.debugModule("sqlite3InitModule() sIMS =",Ee),Ee.debugModule("sqlite3InitModule() EmscriptenModule =",ze);const _t=ze.runSQLite3PostLoadInit(Ee,ze,!!je.__isUnderTest);return Ee.debugModule("sqlite3InitModule() sqlite3 =",_t),_t}).catch(ze=>{throw console.error("Exception loading sqlite3 module:",ze),ze})};if(f.ready=He.ready,Ee.moduleScript){let je=Ee.moduleScript.src.split("/");je.pop(),Ee.scriptDir=je.join("/")+"/"}return Ee.debugModule("extern-post-js.c-pp.js sqlite3InitModuleState =",Ee),f})(),bt().then(He=>He.initWorker1API())})();