@tearleads/client-sdk 0.1.261 → 0.1.263

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +1 -1
  2. package/client/documents/index.d.ts +11 -0
  3. package/client/documents/index.js +7 -1
  4. package/client/documents/index.js.map +1 -1
  5. package/client/index.d.ts +1 -1
  6. package/client/index.js.map +1 -1
  7. package/index.d.ts +1 -1
  8. package/index.js.map +1 -1
  9. package/internal/sqlite-worker/crossTabConnectionMachine.js +67 -0
  10. package/internal/sqlite-worker/crossTabConnectionMachine.js.map +1 -0
  11. package/internal/sqlite-worker/crossTabLocalClient.js +76 -14
  12. package/internal/sqlite-worker/crossTabLocalClient.js.map +1 -1
  13. package/internal/sqlite-worker/crossTabProtocol.js +17 -0
  14. package/internal/sqlite-worker/crossTabProtocol.js.map +1 -1
  15. package/internal/sqlite-worker/crossTabRuntime.js +20 -18
  16. package/internal/sqlite-worker/crossTabRuntime.js.map +1 -1
  17. package/internal/sqlite-worker/runtime.d.ts +1 -1
  18. package/internal/sqlite-worker/runtime.js +1 -0
  19. package/internal/sqlite-worker/runtime.js.map +1 -1
  20. package/internal/sqlite-worker/types.d.ts +7 -0
  21. package/internal/sqlite-worker/types.js +12 -0
  22. package/internal/sqlite-worker/types.js.map +1 -1
  23. package/internal/sqlite-worker/workerCrash.d.ts +23 -0
  24. package/internal/sqlite-worker/workerCrash.js +17 -0
  25. package/internal/sqlite-worker/workerCrash.js.map +1 -1
  26. package/package.json +1 -1
  27. package/sqlite/index.d.ts +1 -1
  28. package/sqlite/index.js +1 -1
  29. package/sqlite/index.js.map +1 -1
  30. package/sqlite/worker.js +4 -4
  31. package/stores/documents/downloadRetry.d.ts +16 -0
  32. package/stores/documents/downloadRetry.js +28 -0
  33. package/stores/documents/downloadRetry.js.map +1 -0
  34. package/stores/documents/index.d.ts +1 -0
  35. package/stores/documents/index.js +1 -0
  36. package/stores/documents/index.js.map +1 -1
  37. package/workflows/container-contents/documentQueries/pendingDownloads.d.ts +23 -2
  38. package/workflows/container-contents/documentQueries/pendingDownloads.js +63 -1
  39. package/workflows/container-contents/documentQueries/pendingDownloads.js.map +1 -1
package/sqlite/worker.js CHANGED
@@ -1,4 +1,4 @@
1
- var jc=(g,s,Y)=>()=>{if(g)try{s=g(g=0)}catch(ne){Y=[ne]}if(Y)throw Y[0];return s};async function Bt(g={}){var s=g,Y=!!globalThis.window,ne=!!globalThis.WorkerGlobalScope,ge=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer",Se=!Y&&!ge&&!ne;(function(e){let n=globalThis.sqlite3InitModuleState||Object.assign(Object.create(null),{debugModule:function(){console.warn("globalThis.sqlite3InitModuleState is missing",arguments)}});delete globalThis.sqlite3InitModuleState,n.debugModule("pre-js.js sqlite3InitModuleState =",n),e.locateFile=function(o,i){if(this.emscriptenLocateFile instanceof Function)return this.emscriptenLocateFile(o,i);return new URL(o,import.meta.url).href}.bind(n),e.instantiateWasm=function(i,t){if(this.emscriptenInstantiateWasm instanceof Function)return this.emscriptenInstantiateWasm(i,t);let r=this,a=(S)=>{S.imports=i,r.instantiateWasm=S,t(S.instance,S.module)},_=e.locateFile(r.wasmFilename,typeof ot>"u"?"":ot);r.debugModule("instantiateWasm() uri =",_,"sIMS =",this);let h=()=>fetch(_,{credentials:"same-origin"});return(WebAssembly.instantiateStreaming?async()=>WebAssembly.instantiateStreaming(h(),i).then(a):async()=>h().then((S)=>S.arrayBuffer()).then((S)=>WebAssembly.instantiate(S,i)).then(a))()}.bind(n)})(s);var Me=[],ze="./this.program",nt=(e,n)=>{throw n},ut=import.meta.url,ot="";function ft(e){if(s.locateFile)return s.locateFile(e,ot);return ot+e}var Ye,Et;if(Y||ne){try{ot=new URL(".",ut).href}catch{}{if(ne)Et=(e)=>{var n=new XMLHttpRequest;return n.open("GET",e,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)};Ye=async(e)=>{var n=await fetch(e,{credentials:"same-origin"});if(n.ok)return n.arrayBuffer();throw Error(n.status+" : "+n.url)}}}var kt=console.log.bind(console),rt=console.error.bind(console),$t,Ot=!1,Jt;function q_(e,n){if(!e)Ke(n)}var v_=(e)=>e.startsWith("file://");class Yt{}class Zn extends Yt{}var er=!1;function tr(){return Ze.buffer}function Xt(){if(Ue?.buffer?.resizable)return;var e=tr();Ue=new Int8Array(e),at=new Int16Array(e),Xe=new Uint8Array(e),dr=new Uint16Array(e),Ie=new Int32Array(e),ke=new Uint32Array(e),Pt=new Float32Array(e),Ft=new Float64Array(e),Be=new BigInt64Array(e),pr=new BigUint64Array(e)}function nr(){if(s.wasmMemory)Ze=s.wasmMemory;else{var e=s.INITIAL_MEMORY||8388608;Ze=new WebAssembly.Memory({initial:e/65536,maximum:32768})}Xt()}function rr(){var e=s.preRun;if(e){if(typeof e=="function")e=[e];Ct.push(...e)}tn(Ct)}function ir(){if(er=!0,!s.noFSInit&&!l.initialized)l.init();it.init(),gt.__wasm_call_ctors(),l.ignorePermissions=!1}function sr(){var e=s.postRun;if(e){if(typeof e=="function")e=[e];Lt.push(...e)}tn(Lt)}function Ke(e){s.onAbort?.(e),e=`Aborted(${e})`,rt(e),Ot=!0,e+=". Build with -sASSERTIONS for more info.";var n=new WebAssembly.RuntimeError(e);throw n}var Zt;function or(){if(s.locateFile)return ft("sqlite3.wasm");return new URL("sqlite3.wasm",import.meta.url).href}function ar(e){if(Et)return Et(e);throw"both async and sync fetching of the wasm failed"}async function lr(e){if(!$t)try{var n=await Ye(e);return new Uint8Array(n)}catch{}return ar(e)}async function cr(e,n){try{var o=await lr(e),i=await WebAssembly.instantiate(o,n);return i}catch(t){rt(`failed to asynchronously prepare wasm: ${t}`),Ke(t)}}async function _r(e,n,o){if(!e)try{var i=fetch(n,{credentials:"same-origin"}),t=await WebAssembly.instantiateStreaming(i,o);return t}catch(r){rt(`wasm streaming compile failed: ${r}`),rt("falling back to ArrayBuffer instantiation")}return cr(n,o)}function ur(){var e={env:vn,wasi_snapshot_preview1:vn};return e}async function fr(){function e(a){return gt=a.exports,Rc(gt),gt}function n(a){return e(a.instance)}var o=ur(),i=s.instantiateWasm;if(i)return new Promise((a)=>{i(o,(_)=>a(e(_)))});Zt??=or();var t=await _r($t,Zt,o),r=n(t);return r}class en{name="ExitStatus";constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var at,Ie,Be,Ue,Pt,Ft,dr,ke,pr,Xe,tn=(e)=>{while(e.length>0)e.shift()(s)},Lt=[],S_=(e)=>Lt.push(e),Ct=[],w_=(e)=>Ct.push(e);function E_(e,n="i8"){if(n.endsWith("*"))n="*";switch(n){case"i1":return Ue[e];case"i8":return Ue[e];case"i16":return at[e>>1];case"i32":return Ie[e>>2];case"i64":return Be[e>>3];case"float":return Pt[e>>2];case"double":return Ft[e>>3];case"*":return ke[e>>2];default:Ke(`invalid type for getValue: ${n}`)}}var nn=!0;function k_(e,n,o="i8"){if(o.endsWith("*"))o="*";switch(o){case"i1":Ue[e]=n;break;case"i8":Ue[e]=n;break;case"i16":at[e>>1]=n;break;case"i32":Ie[e>>2]=n;break;case"i64":Be[e>>3]=BigInt(n);break;case"float":Pt[e>>2]=n;break;case"double":Ft[e>>3]=n;break;case"*":ke[e>>2]=n;break;default:Ke(`invalid type for setValue: ${o}`)}}var A_=(e)=>yn(e),I_=()=>qn(),Ze,Te={isAbs:(e)=>e.charAt(0)==="/",splitPath:(e)=>{var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return n.exec(e).slice(1)},normalizeArray:(e,n)=>{var o=0;for(var i=e.length-1;i>=0;i--){var t=e[i];if(t===".")e.splice(i,1);else if(t==="..")e.splice(i,1),o++;else if(o)e.splice(i,1),o--}if(n)for(;o;o--)e.unshift("..");return e},normalize:(e)=>{var n=Te.isAbs(e),o=e.slice(-1)==="/";if(e=Te.normalizeArray(e.split("/").filter((i)=>!!i),!n).join("/"),!e&&!n)e=".";if(e&&o)e+="/";return(n?"/":"")+e},dirname:(e)=>{var n=Te.splitPath(e),o=n[0],i=n[1];if(!o&&!i)return".";if(i)i=i.slice(0,-1);return o+i},basename:(e)=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>Te.normalize(e.join("/")),join2:(e,n)=>Te.normalize(e+"/"+n)},hr=()=>(e)=>(crypto.getRandomValues(e),0),rn=(e)=>(rn=hr())(e),dt={resolve:(...e)=>{var n="",o=!1;for(var i=e.length-1;i>=-1&&!o;i--){var t=i>=0?e[i]:l.cwd();if(typeof t!="string")throw TypeError("Arguments to path.resolve must be strings");else if(!t)return"";n=t+"/"+n,o=Te.isAbs(t)}return n=Te.normalizeArray(n.split("/").filter((r)=>!!r),!o).join("/"),(o?"/":"")+n||"."},relative:(e,n)=>{e=dt.resolve(e).slice(1),n=dt.resolve(n).slice(1);function o(I){var S=0;for(;S<I.length;S++)if(I[S]!=="")break;var R=I.length-1;for(;R>=0;R--)if(I[R]!=="")break;if(S>R)return[];return I.slice(S,R-S+1)}var i=o(e.split("/")),t=o(n.split("/")),r=Math.min(i.length,t.length),a=r;for(var _=0;_<r;_++)if(i[_]!==t[_]){a=_;break}var h=[];for(var _=a;_<i.length;_++)h.push("..");return h=h.concat(t.slice(a)),h.join("/")}},sn=new TextDecoder,on=(e,n,o,i)=>{var t=n+o;if(i)return t;while(e[n]&&!(n>=t))++n;return n},qt=(e,n=0,o,i)=>{var t=on(e,n,o,i);return sn.decode(e.buffer?e.subarray(n,t):new Uint8Array(e.slice(n,t)))},Dt=[],At=(e)=>{var n=0;for(var o=0;o<e.length;++o){var i=e.charCodeAt(o);if(i<=127)n++;else if(i<=2047)n+=2;else if(i>=55296&&i<=57343)n+=4,++o;else n+=3}return n},an=(e,n,o,i)=>{if(!(i>0))return 0;var t=o,r=o+i-1;for(var a=0;a<e.length;++a){var _=e.codePointAt(a);if(_<=127){if(o>=r)break;n[o++]=_}else if(_<=2047){if(o+1>=r)break;n[o++]=192|_>>6,n[o++]=128|_&63}else if(_<=65535){if(o+2>=r)break;n[o++]=224|_>>12,n[o++]=128|_>>6&63,n[o++]=128|_&63}else{if(o+3>=r)break;n[o++]=240|_>>18,n[o++]=128|_>>12&63,n[o++]=128|_>>6&63,n[o++]=128|_&63,a++}}return n[o]=0,o-t},Nt=(e,n,o)=>{var i=o>0?o:At(e)+1,t=Array(i),r=an(e,t,0,t.length);if(n)t.length=r;return t},mr=()=>{if(!Dt.length){var e=null;if(globalThis.window?.prompt){if(e=window.prompt("Input: "),e!==null)e+=`
2
- `}if(!e)return null;Dt=Nt(e,!0)}return Dt.shift()},it={ttys:[],init(){},shutdown(){},register(e,n){it.ttys[e]={input:[],output:[],ops:n},l.registerDevice(e,it.stream_ops)},stream_ops:{open(e){var n=it.ttys[e.node.rdev];if(!n)throw new l.ErrnoError(43);e.tty=n,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,n,o,i,t){if(!e.tty||!e.tty.ops.get_char)throw new l.ErrnoError(60);var r=0;for(var a=0;a<i;a++){var _;try{_=e.tty.ops.get_char(e.tty)}catch(h){throw new l.ErrnoError(29)}if(_===void 0&&r===0)throw new l.ErrnoError(6);if(_===null||_===void 0)break;r++,n[o+a]=_}if(r)e.node.atime=Date.now();return r},write(e,n,o,i,t){if(!e.tty||!e.tty.ops.put_char)throw new l.ErrnoError(60);try{for(var r=0;r<i;r++)e.tty.ops.put_char(e.tty,n[o+r])}catch(a){throw new l.ErrnoError(29)}if(i)e.node.mtime=e.node.ctime=Date.now();return r}},default_tty_ops:{get_char(e){return mr()},put_char(e,n){if(n===null||n===10)kt(qt(e.output)),e.output=[];else if(n!=0)e.output.push(n)},fsync(e){if(e.output?.length>0)kt(qt(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,n,o){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,n){if(n===null||n===10)rt(qt(e.output)),e.output=[];else if(n!=0)e.output.push(n)},fsync(e){if(e.output?.length>0)rt(qt(e.output)),e.output=[]}}},gr=(e,n)=>Xe.fill(0,e,e+n),ln=(e,n)=>Math.ceil(e/n)*n,cn=(e)=>{e=ln(e,65536);var n=bn(65536,e);if(n)gr(n,e);return n},ye={ops_table:null,mount(e){return ye.createNode(null,"/",16895,0)},createNode(e,n,o,i){if(l.isBlkdev(o)||l.isFIFO(o))throw new l.ErrnoError(63);ye.ops_table||={dir:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr,lookup:ye.node_ops.lookup,mknod:ye.node_ops.mknod,rename:ye.node_ops.rename,unlink:ye.node_ops.unlink,rmdir:ye.node_ops.rmdir,readdir:ye.node_ops.readdir,symlink:ye.node_ops.symlink},stream:{llseek:ye.stream_ops.llseek}},file:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr},stream:{llseek:ye.stream_ops.llseek,read:ye.stream_ops.read,write:ye.stream_ops.write,mmap:ye.stream_ops.mmap,msync:ye.stream_ops.msync}},link:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr,readlink:ye.node_ops.readlink},stream:{}},chrdev:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr},stream:l.chrdev_stream_ops}};var t=l.createNode(e,n,o,i);if(l.isDir(t.mode))t.node_ops=ye.ops_table.dir.node,t.stream_ops=ye.ops_table.dir.stream,t.contents={};else if(l.isFile(t.mode))t.node_ops=ye.ops_table.file.node,t.stream_ops=ye.ops_table.file.stream,t.usedBytes=0,t.contents=ye.emptyFileContents??=new Uint8Array(0);else if(l.isLink(t.mode))t.node_ops=ye.ops_table.link.node,t.stream_ops=ye.ops_table.link.stream;else if(l.isChrdev(t.mode))t.node_ops=ye.ops_table.chrdev.node,t.stream_ops=ye.ops_table.chrdev.stream;if(t.atime=t.mtime=t.ctime=Date.now(),e)e.contents[n]=t,e.atime=e.mtime=e.ctime=t.atime;return t},getFileDataAsTypedArray(e){return e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,n){var o=e.contents.length;if(o>=n)return;var i=1048576;if(n=Math.max(n,o*(o<i?2:1.125)>>>0),o)n=Math.max(n,256);var t=ye.getFileDataAsTypedArray(e);e.contents=new Uint8Array(n),e.contents.set(t)},resizeFileStorage(e,n){if(e.usedBytes==n)return;var o=e.contents;e.contents=new Uint8Array(n),e.contents.set(o.subarray(0,Math.min(n,e.usedBytes))),e.usedBytes=n},node_ops:{getattr(e){var n={};if(n.dev=l.isChrdev(e.mode)?e.id:1,n.ino=e.id,n.mode=e.mode,n.nlink=1,n.uid=0,n.gid=0,n.rdev=e.rdev,l.isDir(e.mode))n.size=4096;else if(l.isFile(e.mode))n.size=e.usedBytes;else if(l.isLink(e.mode))n.size=e.link.length;else n.size=0;return n.atime=new Date(e.atime),n.mtime=new Date(e.mtime),n.ctime=new Date(e.ctime),n.blksize=4096,n.blocks=Math.ceil(n.size/n.blksize),n},setattr(e,n){for(let o of["mode","atime","mtime","ctime"])if(n[o]!=null)e[o]=n[o];if(n.size!==void 0)ye.resizeFileStorage(e,n.size)},lookup(e,n){if(!ye.doesNotExistError)ye.doesNotExistError=new l.ErrnoError(44),ye.doesNotExistError.stack="<generic error, no stack>";throw ye.doesNotExistError},mknod(e,n,o,i){return ye.createNode(e,n,o,i)},rename(e,n,o){var i;try{i=l.lookupNode(n,o)}catch(r){}if(i){if(l.isDir(e.mode))for(var t in i.contents)throw new l.ErrnoError(55);l.hashRemoveNode(i)}delete e.parent.contents[e.name],n.contents[o]=e,e.name=o,n.ctime=n.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,n){delete e.contents[n],e.ctime=e.mtime=Date.now()},rmdir(e,n){var o=l.lookupNode(e,n);for(var i in o.contents)throw new l.ErrnoError(55);delete e.contents[n],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,n,o){var i=ye.createNode(e,n,41471,0);return i.link=o,i},readlink(e){if(!l.isLink(e.mode))throw new l.ErrnoError(28);return e.link}},stream_ops:{read(e,n,o,i,t){var r=e.node.contents;if(t>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-t,i);return n.set(r.subarray(t,t+a),o),a},write(e,n,o,i,t,r){if(n.buffer===Ue.buffer)r=!1;if(!i)return 0;var a=e.node;if(a.mtime=a.ctime=Date.now(),r)a.contents=n.subarray(o,o+i),a.usedBytes=i;else if(a.usedBytes===0&&t===0)a.contents=n.slice(o,o+i),a.usedBytes=i;else ye.expandFileStorage(a,t+i),a.contents.set(n.subarray(o,o+i),t),a.usedBytes=Math.max(a.usedBytes,t+i);return i},llseek(e,n,o){var i=n;if(o===1)i+=e.position;else if(o===2){if(l.isFile(e.node.mode))i+=e.node.usedBytes}if(i<0)throw new l.ErrnoError(28);return i},mmap(e,n,o,i,t){if(!l.isFile(e.node.mode))throw new l.ErrnoError(43);var r,a,_=e.node.contents;if(!(t&2)&&_.buffer===Ue.buffer)a=!1,r=_.byteOffset;else{if(a=!0,r=cn(n),!r)throw new l.ErrnoError(48);if(_){if(o>0||o+n<_.length)if(_.subarray)_=_.subarray(o,o+n);else _=Array.prototype.slice.call(_,o,o+n);Ue.set(_,r)}}return{ptr:r,allocated:a}},msync(e,n,o,i,t){return ye.stream_ops.write(e,n,0,i,o,!1),0}}},br=(e)=>{if(typeof e!="string")return e;var n={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},o=n[e];if(typeof o>"u")throw Error(`Unknown file open mode: ${e}`);return o},_n=(e)=>{if(typeof e=="string")e=Nt(e,!0);if(!e.subarray)e=new Uint8Array(e);return e},Rt=(e,n)=>{var o=0;if(e)o|=365;if(n)o|=146;return o},yr=async(e)=>{var n=await Ye(e);return new Uint8Array(n)},qr=(...e)=>l.createDataFile(...e),vr=(e)=>e,un=null,Sr=async()=>un,lt=0,fn=null,wr=(e)=>{if(lt--,s.monitorRunDependencies?.(lt),!lt)fn()},Er=(e)=>{if(!lt)un=new Promise((n)=>fn=n);lt++,s.monitorRunDependencies?.(lt)},kr=[],Ar=async(e,n)=>{if(typeof Browser<"u")Browser.init();for(var o of kr)if(o.canHandle(n))return o.handle(e,n);return e},dn=async(e,n,o,i,t,r,a,_)=>{var h=n?dt.resolve(Te.join2(e,n)):e,I=vr(`cp ${h}`);Er(I);try{var S=o;if(typeof o=="string")S=await yr(o);if(S=await Ar(S,h),_?.(),!r)qr(e,n,S,i,t,a)}finally{wr(I)}},Ir=(e,n,o,i,t,r,a,_,h,I)=>{dn(e,n,o,i,t,_,h,I).then(r).catch(a)},l={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,n,o,i){if(!e)e=this;this.parent=e,this.mount=e.mount,this.id=l.nextInode++,this.name=n,this.mode=o,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 l.isDir(this.mode)}get isDevice(){return l.isChrdev(this.mode)}addListener(e,n=!1){var o={cb:e,exclusive:n},i=this.listeners??=new Set;return i.add(o),{listeners:i,entry:o}}notifyListeners(e){if(!this.listeners)return;var n;for(var o of this.listeners)if(o.exclusive)(n||=[]).push(o);else o.cb(e);if(n){var i=(this.exclTurn||0)%n.length;this.exclTurn=i+1,n[i].cb(e)}}},lookupPath(e,n={}){if(!e)throw new l.ErrnoError(44);if(n.follow_mount??=!0,!Te.isAbs(e))e=l.cwd()+"/"+e;e:for(var o=0;o<40;o++){var i=e.split("/").filter((I)=>!!I),t=l.root,r="/";for(var a=0;a<i.length;a++){var _=a===i.length-1;if(_&&n.parent)break;if(i[a]===".")continue;if(i[a]===".."){if(r=Te.dirname(r),l.isRoot(t)){e=r+"/"+i.slice(a+1).join("/"),o--;continue e}else t=t.parent;continue}r=Te.join2(r,i[a]);try{t=l.lookupNode(t,i[a])}catch(I){if(I?.errno===44&&_&&n.noent_okay)return{path:r};throw I}if(l.isMountpoint(t)&&(!_||n.follow_mount))t=t.mounted.root;if(l.isLink(t.mode)&&(!_||n.follow)){if(!t.node_ops.readlink)throw new l.ErrnoError(52);var h=t.node_ops.readlink(t);if(!Te.isAbs(h))h=Te.dirname(r)+"/"+h;e=h+"/"+i.slice(a+1).join("/");continue e}}return{path:r,node:t}}throw new l.ErrnoError(32)},getPath(e){var n;while(!0){if(l.isRoot(e)){var o=e.mount.mountpoint;if(!n)return o;return o[o.length-1]!=="/"?`${o}/${n}`:o+n}n=n?`${e.name}/${n}`:e.name,e=e.parent}},hashName(e,n){var o=0;for(var i=0;i<n.length;i++)o=(o<<5)-o+n.charCodeAt(i)|0;return(e+o>>>0)%l.nameTable.length},hashAddNode(e){var n=l.hashName(e.parent.id,e.name);e.name_next=l.nameTable[n],l.nameTable[n]=e},hashRemoveNode(e){var n=l.hashName(e.parent.id,e.name);if(l.nameTable[n]===e)l.nameTable[n]=e.name_next;else{var o=l.nameTable[n];while(o){if(o.name_next===e){o.name_next=e.name_next;break}o=o.name_next}}},lookupNode(e,n){var o=l.mayLookup(e);if(o)throw new l.ErrnoError(o);var i=l.hashName(e.id,n);for(var t=l.nameTable[i];t;t=t.name_next){var r=t.name;if(t.parent.id===e.id&&r===n)return t}return l.lookup(e,n)},createNode(e,n,o,i){var t=new l.FSNode(e,n,o,i);return l.hashAddNode(t),t},destroyNode(e){l.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 n=["r","w","rw"][e&3];if(e&512)n+="w";return n},nodePermissions(e,n){if(l.ignorePermissions)return 0;if(n.includes("r")&&!(e.mode&292))return 2;if(n.includes("w")&&!(e.mode&146))return 2;if(n.includes("x")&&!(e.mode&73))return 2;return 0},mayLookup(e){if(!l.isDir(e.mode))return 54;var n=l.nodePermissions(e,"x");if(n)return n;if(!e.node_ops.lookup)return 2;return 0},mayCreate(e,n){if(!l.isDir(e.mode))return 54;try{var o=l.lookupNode(e,n);return 20}catch(i){}return l.nodePermissions(e,"wx")},mayDelete(e,n,o){var i;try{i=l.lookupNode(e,n)}catch(r){return r.errno}var t=l.nodePermissions(e,"wx");if(t)return t;if(o){if(!l.isDir(i.mode))return 54;if(l.isRoot(i)||l.getPath(i)===l.cwd())return 10}else if(l.isDir(i.mode))return 31;return 0},mayOpen(e,n){if(!e)return 44;if(l.isLink(e.mode))return 32;var o=l.flagsToPermissionString(n);if(l.isDir(e.mode)){if(o!=="r"||n&576)return 31}return l.nodePermissions(e,o)},checkOpExists(e,n){if(!e)throw new l.ErrnoError(n);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=l.MAX_OPEN_FDS;e++)if(!l.streams[e])return e;throw new l.ErrnoError(33)},getStreamChecked(e){var n=l.getStream(e);if(!n)throw new l.ErrnoError(8);return n},getStream:(e)=>l.streams[e],createStream(e,n=-1){if(e=Object.assign(new l.FSStream,e),n==-1)n=l.nextfd();return e.fd=n,l.streams[n]=e,e},closeStream(e){l.streams[e]=null},dupStream(e,n=-1){var o=l.createStream(e,n);return o.stream_ops?.dup?.(o),o},doSetAttr(e,n,o){var i=e?.stream_ops.setattr,t=i?e:n;i??=n.node_ops.setattr,l.checkOpExists(i,63);try{i(t,o)}catch(r){if(r instanceof RangeError)throw new l.ErrnoError(22);throw r}},chrdev_stream_ops:{open(e){var n=l.getDevice(e.node.rdev);e.stream_ops=n.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new l.ErrnoError(70)}},major:(e)=>e>>8,minor:(e)=>e&255,makedev:(e,n)=>e<<8|n,registerDevice(e,n){l.devices[e]={stream_ops:n}},getDevice:(e)=>l.devices[e],getMounts(e){var n=[],o=[e];while(o.length){var i=o.pop();n.push(i),o.push(...i.mounts)}return n},syncfs(e,n){if(typeof e=="function")n=e,e=!1;if(l.syncFSRequests++,l.syncFSRequests>1)rt(`warning: ${l.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var o=l.getMounts(l.root.mount),i=0;function t(_){return l.syncFSRequests--,n(_)}function r(_){if(_){if(!r.errored)return r.errored=!0,t(_);return}if(++i>=o.length)t(null)}for(var a of o)if(a.type.syncfs)a.type.syncfs(a,e,r);else r(null)},mount(e,n,o){var i=o==="/",t=!o,r;if(i&&l.root)throw new l.ErrnoError(10);else if(!i&&!t){var a=l.lookupPath(o,{follow_mount:!1});if(o=a.path,r=a.node,l.isMountpoint(r))throw new l.ErrnoError(10);if(!l.isDir(r.mode))throw new l.ErrnoError(54)}var _={type:e,opts:n,mountpoint:o,mounts:[]},h=e.mount(_);if(h.mount=_,_.root=h,i)l.root=h;else if(r){if(r.mounted=_,r.mount)r.mount.mounts.push(_)}return h},unmount(e){var n=l.lookupPath(e,{follow_mount:!1});if(!l.isMountpoint(n.node))throw new l.ErrnoError(28);var o=n.node,i=o.mounted,t=l.getMounts(i);for(var[r,a]of Object.entries(l.nameTable))while(a){var _=a.name_next;if(t.includes(a.mount))l.destroyNode(a);a=_}o.mounted=null;var h=o.mount.mounts.indexOf(i);o.mount.mounts.splice(h,1)},lookup(e,n){return e.node_ops.lookup(e,n)},mknod(e,n,o){var i=l.lookupPath(e,{parent:!0}),t=i.node,r=Te.basename(e);if(!r)throw new l.ErrnoError(28);if(r==="."||r==="..")throw new l.ErrnoError(20);var a=l.mayCreate(t,r);if(a)throw new l.ErrnoError(a);if(!t.node_ops.mknod)throw new l.ErrnoError(63);return t.node_ops.mknod(t,r,n,o)},statfs(e){return l.statfsNode(l.lookupPath(e,{follow:!0}).node)},statfsStream(e){return l.statfsNode(e.node)},statfsNode(e){var n={bsize:4096,frsize:4096,blocks:1e6,bfree:500000,bavail:500000,files:l.nextInode,ffree:l.nextInode-1,fsid:42,flags:2,namelen:255};if(e.node_ops.statfs)Object.assign(n,e.node_ops.statfs(e.mount.opts.root));return n},create(e,n=438){return n&=4095,n|=32768,l.mknod(e,n,0)},mkdir(e,n=511){return n&=1023,n|=16384,l.mknod(e,n,0)},mkdirTree(e,n){var o=e.split("/"),i="";for(var t of o){if(!t)continue;if(i||Te.isAbs(e))i+="/";i+=t;try{l.mkdir(i,n)}catch(r){if(r.errno!=20)throw r}}},mkdev(e,n,o){if(typeof o>"u")o=n,n=438;return n|=8192,l.mknod(e,n,o)},symlink(e,n){if(!dt.resolve(e))throw new l.ErrnoError(44);var o=l.lookupPath(n,{parent:!0}),i=o.node;if(!i)throw new l.ErrnoError(44);var t=Te.basename(n),r=l.mayCreate(i,t);if(r)throw new l.ErrnoError(r);if(!i.node_ops.symlink)throw new l.ErrnoError(63);return i.node_ops.symlink(i,t,e)},link(e,n,o){var i=l.lookupPath(n,{parent:!0}),t=i.node;if(!t)throw new l.ErrnoError(44);var r=Te.basename(n),a=l.mayCreate(t,r);if(a)throw new l.ErrnoError(a);if(!t.node_ops.link)throw new l.ErrnoError(34);return t.node_ops.link(t,r,e,o)},rename(e,n){var o=Te.dirname(e),i=Te.dirname(n),t=Te.basename(e),r=Te.basename(n),a,_,h;if(a=l.lookupPath(e,{parent:!0}),_=a.node,a=l.lookupPath(n,{parent:!0}),h=a.node,!_||!h)throw new l.ErrnoError(44);if(_.mount!==h.mount)throw new l.ErrnoError(75);var I=l.lookupNode(_,t),S=dt.relative(e,i);if(S.charAt(0)!==".")throw new l.ErrnoError(28);if(S=dt.relative(n,o),S.charAt(0)!==".")throw new l.ErrnoError(55);var R;try{R=l.lookupNode(h,r)}catch(te){}if(I===R)return;var M=l.isDir(I.mode),p=l.mayDelete(_,t,M);if(p)throw new l.ErrnoError(p);if(p=R?l.mayDelete(h,r,M):l.mayCreate(h,r),p)throw new l.ErrnoError(p);if(!_.node_ops.rename)throw new l.ErrnoError(63);if(l.isMountpoint(I)||R&&l.isMountpoint(R))throw new l.ErrnoError(10);if(h!==_){if(p=l.nodePermissions(_,"w"),p)throw new l.ErrnoError(p)}l.hashRemoveNode(I);try{_.node_ops.rename(I,h,r),I.parent=h}catch(te){throw te}finally{l.hashAddNode(I)}},rmdir(e){var n=l.lookupPath(e,{parent:!0}),o=n.node,i=Te.basename(e),t=l.lookupNode(o,i),r=l.mayDelete(o,i,!0);if(r)throw new l.ErrnoError(r);if(!o.node_ops.rmdir)throw new l.ErrnoError(63);if(l.isMountpoint(t))throw new l.ErrnoError(10);o.node_ops.rmdir(o,i),l.destroyNode(t)},readdir(e){var n=l.lookupPath(e,{follow:!0}),o=n.node,i=l.checkOpExists(o.node_ops.readdir,54);return i(o)},unlink(e){var n=l.lookupPath(e,{parent:!0}),o=n.node;if(!o)throw new l.ErrnoError(44);var i=Te.basename(e),t=l.lookupNode(o,i),r=l.mayDelete(o,i,!1);if(r)throw new l.ErrnoError(r);if(!o.node_ops.unlink)throw new l.ErrnoError(63);if(l.isMountpoint(t))throw new l.ErrnoError(10);o.node_ops.unlink(o,i),l.destroyNode(t)},readlink(e){var n=l.lookupPath(e),o=n.node;if(!o)throw new l.ErrnoError(44);if(!o.node_ops.readlink)throw new l.ErrnoError(28);return o.node_ops.readlink(o)},stat(e,n){var o=l.lookupPath(e,{follow:!n}),i=o.node,t=l.checkOpExists(i.node_ops.getattr,63);return t(i)},fstat(e){var n=l.getStreamChecked(e),o=n.node,i=n.stream_ops.getattr,t=i?n:o;return i??=o.node_ops.getattr,l.checkOpExists(i,63),i(t)},lstat(e){return l.stat(e,!0)},doChmod(e,n,o,i){l.doSetAttr(e,n,{mode:o&4095|n.mode&-4096,ctime:Date.now(),dontFollow:i})},chmod(e,n,o){var i;if(typeof e=="string"){var t=l.lookupPath(e,{follow:!o});i=t.node}else i=e;l.doChmod(null,i,n,o)},lchmod(e,n){l.chmod(e,n,!0)},fchmod(e,n){var o=l.getStreamChecked(e);l.doChmod(o,o.node,n,!1)},doChown(e,n,o){l.doSetAttr(e,n,{timestamp:Date.now(),dontFollow:o})},chown(e,n,o,i){var t;if(typeof e=="string"){var r=l.lookupPath(e,{follow:!i});t=r.node}else t=e;l.doChown(null,t,i)},lchown(e,n,o){l.chown(e,n,o,!0)},fchown(e,n,o){var i=l.getStreamChecked(e);l.doChown(i,i.node,!1)},doTruncate(e,n,o){if(l.isDir(n.mode))throw new l.ErrnoError(31);if(!l.isFile(n.mode))throw new l.ErrnoError(28);var i=l.nodePermissions(n,"w");if(i)throw new l.ErrnoError(i);l.doSetAttr(e,n,{size:o,timestamp:Date.now()})},truncate(e,n){if(n<0)throw new l.ErrnoError(28);var o;if(typeof e=="string"){var i=l.lookupPath(e,{follow:!0});o=i.node}else o=e;l.doTruncate(null,o,n)},ftruncate(e,n){var o=l.getStreamChecked(e);if(n<0||(o.flags&2097155)===0)throw new l.ErrnoError(28);l.doTruncate(o,o.node,n)},utime(e,n,o,i){var t=l.lookupPath(e,{follow:!i});l.doSetAttr(null,t.node,{atime:n,mtime:o,dontFollow:i})},open(e,n,o=438){if(e==="")throw new l.ErrnoError(44);if(n=br(n),n&64)o=o&4095|32768;else o=0;var i,t;if(typeof e=="object")i=e;else{t=e.endsWith("/");var r=l.lookupPath(e,{follow:!(n&131072),noent_okay:!0});i=r.node,e=r.path}var a=!1;if(n&64)if(i){if(n&128)throw new l.ErrnoError(20)}else if(t)throw new l.ErrnoError(31);else i=l.mknod(e,o|511,0),a=!0;if(!i)throw new l.ErrnoError(44);if(l.isChrdev(i.mode))n&=-513;if(n&65536&&!l.isDir(i.mode))throw new l.ErrnoError(54);if(!a){var _=l.mayOpen(i,n);if(_)throw new l.ErrnoError(_)}if(n&512&&!a)l.truncate(i,0);n&=-131713;var h=l.createStream({node:i,path:l.getPath(i),flags:n,seekable:!0,position:0,stream_ops:i.stream_ops,ungotten:[],error:!1});if(h.stream_ops.open)h.stream_ops.open(h);if(a)l.chmod(i,o&511);return h},close(e){if(l.isClosed(e))throw new l.ErrnoError(8);if(e.getdents)e.getdents=null;e.node?.notifyListeners(32);try{if(e.stream_ops.close)e.stream_ops.close(e)}catch(n){throw n}finally{l.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,n,o){if(l.isClosed(e))throw new l.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new l.ErrnoError(70);if(o!=0&&o!=1&&o!=2)throw new l.ErrnoError(28);return e.position=e.stream_ops.llseek(e,n,o),e.ungotten=[],e.position},read(e,n,o,i,t){if(i<0||t<0)throw new l.ErrnoError(28);if(l.isClosed(e))throw new l.ErrnoError(8);if((e.flags&2097155)===1)throw new l.ErrnoError(8);if(l.isDir(e.node.mode))throw new l.ErrnoError(31);if(!e.stream_ops.read)throw new l.ErrnoError(28);var r=typeof t<"u";if(!r)t=e.position;else if(!e.seekable)throw new l.ErrnoError(70);var a=e.stream_ops.read(e,n,o,i,t);if(!r)e.position+=a;return a},write(e,n,o,i,t,r){if(i<0||t<0)throw new l.ErrnoError(28);if(l.isClosed(e))throw new l.ErrnoError(8);if((e.flags&2097155)===0)throw new l.ErrnoError(8);if(l.isDir(e.node.mode))throw new l.ErrnoError(31);if(!e.stream_ops.write)throw new l.ErrnoError(28);if(e.seekable&&e.flags&1024)l.llseek(e,0,2);var a=typeof t<"u";if(!a)t=e.position;else if(!e.seekable)throw new l.ErrnoError(70);var _=e.stream_ops.write(e,n,o,i,t,r);if(!a)e.position+=_;return _},mmap(e,n,o,i,t){if((i&2)!==0&&(t&2)===0&&(e.flags&2097155)!==2)throw new l.ErrnoError(2);if((e.flags&2097155)===1)throw new l.ErrnoError(2);if(!e.stream_ops.mmap)throw new l.ErrnoError(43);if(!n)throw new l.ErrnoError(28);return e.stream_ops.mmap(e,n,o,i,t)},msync(e,n,o,i,t){if(!e.stream_ops.msync)return 0;return e.stream_ops.msync(e,n,o,i,t)},ioctl(e,n,o){if(!e.stream_ops.ioctl)throw new l.ErrnoError(59);return e.stream_ops.ioctl(e,n,o)},readFile(e,n={}){if(n.flags=n.flags??0,n.encoding=n.encoding??"binary",n.encoding!=="utf8"&&n.encoding!=="binary")Ke(`Invalid encoding type "${n.encoding}"`);var o=l.open(e,n.flags),i=l.stat(e),t=i.size,r=new Uint8Array(t);if(l.read(o,r,0,t,0),n.encoding==="utf8")r=qt(r);return l.close(o),r},writeFile(e,n,o={}){o.flags=o.flags??577;var i=l.open(e,o.flags,o.mode);n=_n(n),l.write(i,n,0,n.byteLength,void 0,o.canOwn),l.close(i)},cwd:()=>l.currentPath,chdir(e){var n=l.lookupPath(e,{follow:!0});if(n.node===null)throw new l.ErrnoError(44);if(!l.isDir(n.node.mode))throw new l.ErrnoError(54);var o=l.nodePermissions(n.node,"x");if(o)throw new l.ErrnoError(o);l.currentPath=n.path},createDefaultDirectories(){l.mkdir("/tmp"),l.mkdir("/home"),l.mkdir("/home/web_user")},createDefaultDevices(){l.mkdir("/dev"),l.registerDevice(l.makedev(1,3),{read:()=>0,write:(i,t,r,a,_)=>a,llseek:()=>0}),l.mkdev("/dev/null",l.makedev(1,3)),it.register(l.makedev(5,0),it.default_tty_ops),it.register(l.makedev(6,0),it.default_tty1_ops),l.mkdev("/dev/tty",l.makedev(5,0)),l.mkdev("/dev/tty1",l.makedev(6,0));var e=new Uint8Array(1024),n=0,o=()=>{if(n===0)rn(e),n=e.byteLength;return e[--n]};l.createDevice("/dev","random",o),l.createDevice("/dev","urandom",o),l.mkdir("/dev/shm"),l.mkdir("/dev/shm/tmp")},createSpecialDirectories(){l.mkdir("/proc");var e=l.mkdir("/proc/self");l.mkdir("/proc/self/fd"),l.mount({mount(){var n=l.createNode(e,"fd",16895,73);return n.stream_ops={llseek:ye.stream_ops.llseek},n.node_ops={lookup(o,i){var t=+i,r=l.getStreamChecked(t),a={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>r.path},id:t+1};return a.parent=a,a},readdir(){return Array.from(l.streams.entries()).filter(([o,i])=>i).map(([o,i])=>o.toString())}},n}},{},"/proc/self/fd")},createStandardStreams(e,n,o){if(e)l.createDevice("/dev","stdin",e);else l.symlink("/dev/tty","/dev/stdin");if(n)l.createDevice("/dev","stdout",null,n);else l.symlink("/dev/tty","/dev/stdout");if(o)l.createDevice("/dev","stderr",null,o);else l.symlink("/dev/tty1","/dev/stderr");var i=l.open("/dev/stdin",0),t=l.open("/dev/stdout",1),r=l.open("/dev/stderr",1)},staticInit(){l.nameTable=Array(4096),l.mount(ye,{},"/"),l.createDefaultDirectories(),l.createDefaultDevices(),l.createSpecialDirectories(),l.filesystems={MEMFS:ye}},init(e,n,o){l.initialized=!0,e??=s.stdin,n??=s.stdout,o??=s.stderr,l.createStandardStreams(e,n,o)},quit(){l.initialized=!1;for(var e of l.streams)if(e)l.close(e)},findObject(e,n){var o=l.analyzePath(e,n);if(!o.exists)return null;return o.object},analyzePath(e,n){try{var o=l.lookupPath(e,{follow:!n});e=o.path}catch(t){}var i={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var o=l.lookupPath(e,{parent:!0});i.parentExists=!0,i.parentPath=o.path,i.parentObject=o.node,i.name=Te.basename(e),o=l.lookupPath(e,{follow:!n}),i.exists=!0,i.path=o.path,i.object=o.node,i.name=o.node.name,i.isRoot=o.path==="/"}catch(t){i.error=t.errno}return i},createPath(e,n,o,i){e=typeof e=="string"?e:l.getPath(e);var t=n.split("/").reverse();while(t.length){var r=t.pop();if(!r)continue;var a=Te.join2(e,r);try{l.mkdir(a)}catch(_){if(_.errno!=20)throw _}e=a}return a},createFile(e,n,o,i,t){var r=Te.join2(typeof e=="string"?e:l.getPath(e),n),a=Rt(i,t);return l.create(r,a)},createDataFile(e,n,o,i,t,r){var a=n;if(e)e=typeof e=="string"?e:l.getPath(e),a=n?Te.join2(e,n):e;var _=Rt(i,t),h=l.create(a,_);if(o){o=_n(o),l.chmod(h,_|146);var I=l.open(h,577);l.write(I,o,0,o.length,0,r),l.close(I),l.chmod(h,_)}},createDevice(e,n,o,i){var t=Te.join2(typeof e=="string"?e:l.getPath(e),n),r=Rt(!!o,!!i);l.createDevice.major??=64;var a=l.makedev(l.createDevice.major++,0);return l.registerDevice(a,{open(_){_.seekable=!1},close(_){if(i?.buffer?.length)i(10)},read(_,h,I,S,R){var M=0;for(var p=0;p<S;p++){var te;try{te=o()}catch(j){throw new l.ErrnoError(29)}if(te===void 0&&M===0)throw new l.ErrnoError(6);if(te===null||te===void 0)break;M++,h[I+p]=te}if(M)_.node.atime=Date.now();return M},write(_,h,I,S,R){for(var M=0;M<S;M++)try{i(h[I+M])}catch(p){throw new l.ErrnoError(29)}if(S)_.node.mtime=_.node.ctime=Date.now();return M}}),l.mkdev(t,r,a)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)Ke("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");else try{e.contents=Et(e.url)}catch(n){throw new l.ErrnoError(29)}},createLazyFile(e,n,o,i,t){class r{lengthKnown=!1;chunks=[];get(R){if(R>this.length-1||R<0)return;var M=R%this.chunkSize,p=R/this.chunkSize|0;return this.getter(p)[M]}setDataGetter(R){this.getter=R}cacheLength(){var R=new XMLHttpRequest;if(R.open("HEAD",o,!1),R.send(null),!(R.status>=200&&R.status<300||R.status===304))Ke("Couldn't load "+o+". Status: "+R.status);var M=Number(R.getResponseHeader("Content-length")),p,te=(p=R.getResponseHeader("Accept-Ranges"))&&p==="bytes",j=(p=R.getResponseHeader("Content-Encoding"))&&p==="gzip",U=1048576;if(!te)U=M;var E=(F,x)=>{if(F>x)Ke(`invalid range (${F}, ${x}) or no bytes requested!`);if(x>M-1)Ke(`only ${M} bytes available! programmer error!`);var A=new XMLHttpRequest;if(A.open("GET",o,!1),M!==U)A.setRequestHeader("Range","bytes="+F+"-"+x);if(A.responseType="arraybuffer",A.overrideMimeType)A.overrideMimeType("text/plain; charset=x-user-defined");if(A.send(null),!(A.status>=200&&A.status<300||A.status===304))Ke("Couldn't load "+o+". Status: "+A.status);if(A.response!==void 0)return new Uint8Array(A.response||[]);return Nt(A.responseText??"",!0)},b=this;if(b.setDataGetter((F)=>{var x=F*U,A=(F+1)*U-1;if(A=Math.min(A,M-1),typeof b.chunks[F]>"u")b.chunks[F]=E(x,A);if(typeof b.chunks[F]>"u")Ke("doXHR failed!");return b.chunks[F]}),j||!M)U=M=1,M=this.getter(0).length,U=M,kt("LazyFiles on gzip forces download of the whole file when length is accessed");this._length=M,this._chunkSize=U,this.lengthKnown=!0}get length(){if(!this.lengthKnown)this.cacheLength();return this._length}get chunkSize(){if(!this.lengthKnown)this.cacheLength();return this._chunkSize}}if(globalThis.XMLHttpRequest){if(!ne)Ke("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var a=new r,_={isDevice:!1,contents:a}}else var _={isDevice:!1,url:o};var h=l.createFile(e,n,_,i,t);if(_.contents)h.contents=_.contents;else if(_.url)h.contents=null,h.url=_.url;Object.defineProperties(h,{usedBytes:{get:function(){return this.contents.length}}});var I={};for(let[R,M]of Object.entries(h.stream_ops))I[R]=(...p)=>(l.forceLoadFile(h),M(...p));function S(R,M,p,te,j){var U=R.node.contents;if(j>=U.length)return 0;var E=Math.min(U.length-j,te);if(U.slice)for(var b=0;b<E;b++)M[p+b]=U[j+b];else for(var b=0;b<E;b++)M[p+b]=U.get(j+b);return E}return I.read=(R,M,p,te,j)=>(l.forceLoadFile(h),S(R,M,p,te,j)),I.mmap=(R,M,p,te,j)=>{l.forceLoadFile(h);var U=cn(M);if(!U)throw new l.ErrnoError(48);return S(R,Ue,U,M,p),{ptr:U,allocated:!0}},h.stream_ops=I,h}},xr=(e,n,o)=>{if(!e)return"";var i=on(Xe,e,n,o);return sn.decode(Xe.subarray(e,i))},ve={currentUmask:18,calculateAt(e,n,o){if(Te.isAbs(n))return n;var i;if(e===-100)i=l.cwd();else{var t=ve.getStreamFromFD(e);i=t.path}if(n.length==0){if(!o)throw new l.ErrnoError(44);return i}return i+"/"+n},writeStat(e,n){ke[e>>2]=n.dev,ke[e+4>>2]=n.mode,ke[e+8>>2]=n.nlink,ke[e+12>>2]=n.uid,ke[e+16>>2]=n.gid,ke[e+20>>2]=n.rdev,Be[e+24>>3]=BigInt(n.size),Ie[e+32>>2]=4096,Ie[e+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),t=n.ctime.getTime();return Be[e+40>>3]=BigInt(Math.floor(o/1000)),ke[e+48>>2]=o%1000*1000*1000,Be[e+56>>3]=BigInt(Math.floor(i/1000)),ke[e+64>>2]=i%1000*1000*1000,Be[e+72>>3]=BigInt(Math.floor(t/1000)),ke[e+80>>2]=t%1000*1000*1000,Be[e+88>>3]=BigInt(n.ino),0},writeStatFs(e,n){ke[e+4>>2]=n.bsize,ke[e+60>>2]=n.bsize,Be[e+8>>3]=BigInt(n.blocks),Be[e+16>>3]=BigInt(n.bfree),Be[e+24>>3]=BigInt(n.bavail),Be[e+32>>3]=BigInt(n.files),Be[e+40>>3]=BigInt(n.ffree),ke[e+48>>2]=n.fsid,ke[e+64>>2]=n.flags,ke[e+56>>2]=n.namelen},doMsync(e,n,o,i,t){if(!l.isFile(n.node.mode))throw new l.ErrnoError(43);if(i&2)return 0;var r=Xe.subarray(e,e+o);l.msync(n,r,t,o,i)},getStreamFromFD(e){var n=l.getStreamChecked(e);return n},varargs:void 0,getStr(e){var n=xr(e);return n}};function Tr(e,n){try{return e=ve.getStr(e),l.chmod(e,n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Or(e,n,o,i){try{if(n=ve.getStr(n),n=ve.calculateAt(e,n),o&-8)return-28;var t=l.lookupPath(n,{follow:!0}),r=t.node;if(!r)return-44;var a="";if(o&4)a+="r";if(o&2)a+="w";if(o&1)a+="x";if(a&&l.nodePermissions(r,a))return-2;return 0}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}function Pr(e,n){try{return l.fchmod(e,n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Fr(e,n,o){try{return l.fchown(e,n,o),0}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var It=()=>{var e=Ie[+ve.varargs>>2];return ve.varargs+=4,e},pt=It;function Lr(e,n,o){ve.varargs=o;try{var i=ve.getStreamFromFD(e);switch(n){case 0:{var t=It();if(t<0)return-28;while(l.streams[t])t++;var r=l.dupStream(i,t);return r.fd}case 1:case 2:return 0;case 3:return i.flags;case 4:{var t=It(),a=289792;return i.flags=i.flags&~a|t&a,0}case 12:{var t=pt(),_=0;return at[t+_>>1]=2,0}case 13:case 14:return 0}return-28}catch(h){if(typeof l>"u"||h.name!=="ErrnoError")throw h;return-h.errno}}function Cr(e,n){try{return ve.writeStat(n,l.fstat(e))}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var Dr=9007199254740992,Nr=-9007199254740992,ht=(e)=>e<Nr||e>Dr?NaN:Number(e);function Rr(e,n){n=ht(n);try{if(isNaN(n))return-22;return l.ftruncate(e,n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var ct=(e,n,o)=>an(e,Xe,n,o);function Mr(e,n){try{if(n===0)return-28;var o=l.cwd(),i=At(o)+1;if(n<i)return-68;return ct(o,e,n),i}catch(t){if(typeof l>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}function jr(e,n,o){ve.varargs=o;try{var i=ve.getStreamFromFD(e);switch(n){case 21509:{if(!i.tty)return-59;return 0}case 21505:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tcgets){var t=i.tty.ops.ioctl_tcgets(i),r=pt();Ie[r>>2]=t.c_iflag||0,Ie[r+4>>2]=t.c_oflag||0,Ie[r+8>>2]=t.c_cflag||0,Ie[r+12>>2]=t.c_lflag||0;for(var a=0;a<32;a++)Ue[r+a+17]=t.c_cc[a]||0;return 0}return 0}case 21510:case 21511:case 21512:{if(!i.tty)return-59;return 0}case 21506:case 21507:case 21508:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tcsets){var r=pt(),_=Ie[r>>2],h=Ie[r+4>>2],I=Ie[r+8>>2],S=Ie[r+12>>2],R=[];for(var a=0;a<32;a++)R.push(Ue[r+a+17]);return i.tty.ops.ioctl_tcsets(i.tty,n,{c_iflag:_,c_oflag:h,c_cflag:I,c_lflag:S,c_cc:R})}return 0}case 21519:{if(!i.tty)return-59;var r=pt();return Ie[r>>2]=0,0}case 21520:{if(!i.tty)return-59;return-28}case 21537:case 21531:{var r=pt();return l.ioctl(i,n,r)}case 21523:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tiocgwinsz){var M=i.tty.ops.ioctl_tiocgwinsz(i.tty),r=pt();at[r>>1]=M[0],at[r+2>>1]=M[1]}return 0}case 21524:{if(!i.tty)return-59;return 0}case 21515:{if(!i.tty)return-59;return 0}default:return-28}}catch(p){if(typeof l>"u"||p.name!=="ErrnoError")throw p;return-p.errno}}function Wr(e,n){try{return e=ve.getStr(e),ve.writeStat(n,l.lstat(e))}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function zr(e,n,o){try{return n=ve.getStr(n),n=ve.calculateAt(e,n),o&=~ve.currentUmask,l.mkdir(n,o,0),0}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function Br(e,n,o,i){try{n=ve.getStr(n);var t=i&256,r=i&4096;return i=i&-6401,n=ve.calculateAt(e,n,r),ve.writeStat(o,t?l.lstat(n):l.stat(n))}catch(a){if(typeof l>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function Ur(e,n,o,i){ve.varargs=i;try{n=ve.getStr(n),n=ve.calculateAt(e,n);var t=i?It():0;if(o&64)t&=~ve.currentUmask;return l.open(n,o,t).fd}catch(r){if(typeof l>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function Qr(e,n,o,i){try{if(n=ve.getStr(n),n=ve.calculateAt(e,n),i<=0)return-28;var t=l.readlink(n),r=Math.min(i,At(t)),a=Ue[o+r];return ct(t,o,i+1),Ue[o+r]=a,r}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}function Vr(e){try{return e=ve.getStr(e),l.rmdir(e),0}catch(n){if(typeof l>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}function Hr(e,n){try{return e=ve.getStr(e),ve.writeStat(n,l.stat(e))}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Gr(e,n,o){try{if(n=ve.getStr(n),n=ve.calculateAt(e,n),!o)l.unlink(n);else if(o===512)l.rmdir(n);else return-28;return 0}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var pn=(e)=>ke[e>>2]+Ie[e+4>>2]*4294967296;function Kr(e,n,o,i){try{var t=i&256;n=ve.getStr(n),n=ve.calculateAt(e,n,!0);var r=Date.now(),a,_;if(!o)a=r,_=r;else{var h=pn(o),I=Ie[o+8>>2];if(I==1073741823)a=r;else if(I==1073741822)a=null;else a=h*1000+I/1e6;if(o+=16,h=pn(o),I=Ie[o+8>>2],I==1073741823)_=r;else if(I==1073741822)_=null;else _=h*1000+I/1e6}if((_??a)!==null)l.utime(n,a,_,t);return 0}catch(S){if(typeof l>"u"||S.name!=="ErrnoError")throw S;return-S.errno}}var $r=()=>Ke(""),Jr=(e)=>e%4===0&&(e%100!==0||e%400===0),Yr=[0,31,60,91,121,152,182,213,244,274,305,335],Xr=[0,31,59,90,120,151,181,212,243,273,304,334],Zr=(e)=>{var n=Jr(e.getFullYear()),o=n?Yr:Xr,i=o[e.getMonth()]+e.getDate()-1;return i};function ei(e,n){e=ht(e);var o=new Date(e*1000);if(isNaN(o.getTime()))return 1;Ie[n>>2]=o.getSeconds(),Ie[n+4>>2]=o.getMinutes(),Ie[n+8>>2]=o.getHours(),Ie[n+12>>2]=o.getDate(),Ie[n+16>>2]=o.getMonth(),Ie[n+20>>2]=o.getFullYear()-1900,Ie[n+24>>2]=o.getDay();var i=Zr(o)|0;Ie[n+28>>2]=i,Ie[n+36>>2]=-(o.getTimezoneOffset()*60);var t=new Date(o.getFullYear(),0,1),r=new Date(o.getFullYear(),6,1).getTimezoneOffset(),a=t.getTimezoneOffset(),_=(r!=a&&o.getTimezoneOffset()==Math.min(a,r))|0;return Ie[n+32>>2]=_,0}function ti(e,n,o,i,t,r,a){t=ht(t);try{var _=ve.getStreamFromFD(i),h=l.mmap(_,e,t,n,o),I=h.ptr;return Ie[r>>2]=h.allocated,ke[a>>2]=I,0}catch(S){if(typeof l>"u"||S.name!=="ErrnoError")throw S;return-S.errno}}function ni(e,n,o,i,t,r){r=ht(r);try{var a=ve.getStreamFromFD(t);if(o&2)ve.doMsync(e,a,n,i,r)}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}var ri=(e,n,o,i)=>{var t=new Date().getFullYear(),r=new Date(t,0,1),a=new Date(t,6,1),_=r.getTimezoneOffset(),h=a.getTimezoneOffset(),I=Math.max(_,h);ke[e>>2]=I*60,Ie[n>>2]=Number(_!=h);var S=(p)=>{var te=p>=0?"-":"+",j=Math.abs(p),U=String(Math.floor(j/60)).padStart(2,"0"),E=String(j%60).padStart(2,"0");return`UTC${te}${U}${E}`},R=S(_),M=S(h);if(h<_)ct(R,o,17),ct(M,i,17);else ct(R,i,17),ct(M,o,17)},hn=()=>performance.now(),mn=()=>Date.now(),ii=1,si=(e)=>e>=0&&e<=3;function oi(e,n,o){if(n=ht(n),!si(e))return 28;var i;if(e===0)i=mn();else if(ii)i=hn();else return 52;var t=Math.round(i*1000*1000);return Be[o>>3]=BigInt(t),0}var gn=()=>2147483648,ai=()=>gn(),li=(e)=>{var n=Ze.buffer.byteLength,o=(e-n+65535)/65536|0;try{return Ze.grow(o),Xt(),1}catch(i){}},ci=(e)=>{var n=Xe.length;e>>>=0;var o=gn();if(e>o)return!1;for(var i=1;i<=4;i*=2){var t=n*(1+0.2/i);t=Math.min(t,e+100663296);var r=Math.min(o,ln(Math.max(e,t),65536)),a=li(r);if(a)return!0}return!1},Mt={},_i=()=>ze,vt=()=>{if(!vt.strings){var e=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",n={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:_i()};for(var o in Mt)if(Mt[o]===void 0)delete n[o];else n[o]=Mt[o];var i=[];for(var o in n)i.push(`${o}=${n[o]}`);vt.strings=i}return vt.strings},ui=(e,n)=>{var o=0,i=0;for(var t of vt()){var r=n+o;ke[e+i>>2]=r,o+=ct(t,r,1/0)+1,i+=4}return 0},fi=(e,n)=>{var o=vt();ke[e>>2]=o.length;var i=0;for(var t of o)i+=At(t)+1;return ke[n>>2]=i,0},di=0,pi=()=>nn||di>0,hi=(e)=>{if(Jt=e,!pi())s.onExit?.(e),Ot=!0;nt(e,new en(e))},mi=(e,n)=>{Jt=e,hi(e)},gi=mi;function bi(e){try{var n=ve.getStreamFromFD(e);return l.close(n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return o.errno}}function yi(e,n){try{var o=0,i=0,t=0,r=ve.getStreamFromFD(e),a=r.tty?2:l.isDir(r.mode)?3:l.isLink(r.mode)?7:4;return Ue[n]=a,at[n+2>>1]=t,Be[n+8>>3]=BigInt(o),Be[n+16>>3]=BigInt(i),0}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return _.errno}}var qi=(e,n,o,i)=>{var t=0;for(var r=0;r<o;r++){var a=ke[n>>2],_=ke[n+4>>2];n+=8;try{var h=l.read(e,Ue,a,_,i)}catch(I){if(t>0&&I instanceof l.ErrnoError&&(I.errno==6||I.errno==6))break;throw I}if(h<0)return-1;if(t+=h,h<_)break;if(typeof i<"u")i+=h}return t};function vi(e,n,o,i){try{var t=ve.getStreamFromFD(e),r=qi(t,n,o);return ke[i>>2]=r,0}catch(a){if(typeof l>"u"||a.name!=="ErrnoError")throw a;return a.errno}}function Si(e,n,o,i){n=ht(n);try{if(isNaN(n))return 22;var t=ve.getStreamFromFD(e);if(l.llseek(t,n,o),Be[i>>3]=BigInt(t.position),t.getdents&&n===0&&o===0)t.getdents=null;return 0}catch(r){if(typeof l>"u"||r.name!=="ErrnoError")throw r;return r.errno}}function wi(e){try{var n=ve.getStreamFromFD(e),o=n.stream_ops?.fsync?.(n);return o}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return i.errno}}var Ei=(e,n,o,i)=>{if(o==1)return l.write(e,Ue,ke[n>>2],ke[n+4>>2],i);var t=0;for(var r=0,a=n;r<o;r++,a+=8)t+=ke[a+4>>2];var _=new Uint8Array(t),h=0;for(var r=0;r<o;r++,n+=8){var I=ke[n>>2],S=ke[n+4>>2];_.set(Xe.subarray(I,I+S),h),h+=S}return l.write(e,_,0,t,i)};function ki(e,n,o,i){try{var t=ve.getStreamFromFD(e),r=Ei(t,n,o);return ke[i>>2]=r,0}catch(a){if(typeof l>"u"||a.name!=="ErrnoError")throw a;return a.errno}}l.createPreloadedFile=Ir,l.preloadFile=dn,l.staticInit();{if(nr(),s.noExitRuntime)nn=s.noExitRuntime;if(s.print)kt=s.print;if(s.printErr)rt=s.printErr;if(s.arguments)Me=s.arguments;if(s.thisProgram)ze=s.thisProgram;var mt=s.preInit;if(mt){if(typeof mt=="function")s.preInit=mt=[mt];while(mt.length>0)mt.shift()()}}s.wasmMemory=Ze;function Ai(e,n){if(typeof crypto>"u"||!crypto.getRandomValues)return-1;try{var o=new Uint8Array(Xe.buffer,e,n),i=65536;for(var t=0;t<n;t+=i)crypto.getRandomValues(o.subarray(t,Math.min(t+i,n)));return 0}catch(r){return-1}}var Ii,xi,Ti,Oi,Pi,Fi,Li,Ci,Di,Ni,Ri,Mi,ji,Wi,zi,Bi,Ui,Qi,Vi,Hi,Gi,Ki,$i,Ji,Yi,Xi,Zi,es,ts,ns,rs,is,ss,os,as,ls,cs,_s,us,fs,ds,ps,hs,ms,gs,bs,ys,qs,vs,Ss,ws,Es,ks,As,Is,xs,Ts,Os,Ps,Fs,Ls,Cs,Ds,Ns,Rs,Ms,js,Ws,zs,Bs,Us,Qs,Vs,Hs,Gs,Ks,$s,Js,Ys,Xs,Zs,eo,to,no,ro,io,so,oo,ao,lo,co,_o,uo,fo,po,ho,mo,go,bo,yo,qo,vo,So,wo,Eo,ko,Ao,Io,xo,To,Oo,Po,Fo,Lo,Co,Do,No,Ro,Mo,jo,Wo,zo,Bo,Uo,Qo,Vo,Ho,Go,Ko,$o,Jo,Yo,Xo,Zo,ea,ta,na,ra,ia,sa,oa,aa,la,ca,_a,ua,fa,da,pa,ha,ma,ga,ba,ya,qa,va,Sa,wa,Ea,ka,Aa,Ia,xa,Ta,Oa,Pa,Fa,La,Ca,Da,Na,Ra,Ma,ja,Wa,za,Ba,Ua,Qa,Va,Ha,Ga,Ka,$a,Ja,Ya,Xa,Za,el,tl,nl,rl,il,sl,ol,al,ll,cl,_l,ul,fl,dl,pl,hl,ml,gl,bl,yl,ql,vl,Sl,wl,El,kl,Al,Il,xl,Tl,Ol,Pl,Fl,Ll,Cl,Dl,Nl,Rl,Ml,jl,Wl,zl,Bl,Ul,Ql,Vl,Hl,Gl,Kl,$l,Jl,Yl,Xl,Zl,ec,tc,nc,rc,ic,sc,oc,ac,lc,cc,_c,uc,fc,dc,pc,hc,mc,gc,bc,yc,qc,vc,Sc,wc,Ec,kc,Ac,Ic,xc,Tc,Oc,Pc,Fc,Lc,Cc,bn,yn,Dc,qn,Nc;function Rc(e){Ii=s._sqlite3_status64=e.sqlite3_status64,xi=s._sqlite3_status=e.sqlite3_status,Ti=s._sqlite3_db_status64=e.sqlite3_db_status64,Oi=s._sqlite3_msize=e.sqlite3_msize,Pi=s._sqlite3_db_status=e.sqlite3_db_status,Fi=s._sqlite3_vfs_find=e.sqlite3_vfs_find,Li=s._sqlite3_initialize=e.sqlite3_initialize,Ci=s._sqlite3_vfs_register=e.sqlite3_vfs_register,Di=s._sqlite3_vfs_unregister=e.sqlite3_vfs_unregister,Ni=s._sqlite3_malloc=e.sqlite3_malloc,Ri=s._sqlite3_malloc64=e.sqlite3_malloc64,Mi=s._sqlite3_free=e.sqlite3_free,ji=s._sqlite3_realloc=e.sqlite3_realloc,Wi=s._sqlite3_realloc64=e.sqlite3_realloc64,zi=s._sqlite3_value_text=e.sqlite3_value_text,Bi=s._sqlite3_randomness=e.sqlite3_randomness,Ui=s._sqlite3_stricmp=e.sqlite3_stricmp,Qi=s._sqlite3_strnicmp=e.sqlite3_strnicmp,Vi=s._sqlite3_uri_parameter=e.sqlite3_uri_parameter,Hi=s._sqlite3_uri_boolean=e.sqlite3_uri_boolean,Gi=s._sqlite3_serialize=e.sqlite3_serialize,Ki=s._sqlite3_prepare_v2=e.sqlite3_prepare_v2,$i=s._sqlite3_step=e.sqlite3_step,Ji=s._sqlite3_column_int64=e.sqlite3_column_int64,Yi=s._sqlite3_reset=e.sqlite3_reset,Xi=s._sqlite3_exec=e.sqlite3_exec,Zi=s._sqlite3_column_int=e.sqlite3_column_int,es=s._sqlite3_finalize=e.sqlite3_finalize,ts=s._sqlite3_file_control=e.sqlite3_file_control,ns=s._sqlite3_column_name=e.sqlite3_column_name,rs=s._sqlite3_column_text=e.sqlite3_column_text,is=s._sqlite3_column_type=e.sqlite3_column_type,ss=s._sqlite3_errmsg=e.sqlite3_errmsg,os=s._sqlite3_deserialize=e.sqlite3_deserialize,as=s._sqlite3_backup_init=e.sqlite3_backup_init,ls=s._sqlite3_backup_step=e.sqlite3_backup_step,cs=s._sqlite3_backup_finish=e.sqlite3_backup_finish,_s=s._sqlite3_backup_remaining=e.sqlite3_backup_remaining,us=s._sqlite3_backup_pagecount=e.sqlite3_backup_pagecount,fs=s._sqlite3_clear_bindings=e.sqlite3_clear_bindings,ds=s._sqlite3_value_blob=e.sqlite3_value_blob,ps=s._sqlite3_value_bytes=e.sqlite3_value_bytes,hs=s._sqlite3_value_double=e.sqlite3_value_double,ms=s._sqlite3_value_int=e.sqlite3_value_int,gs=s._sqlite3_value_int64=e.sqlite3_value_int64,bs=s._sqlite3_value_subtype=e.sqlite3_value_subtype,ys=s._sqlite3_value_pointer=e.sqlite3_value_pointer,qs=s._sqlite3_value_type=e.sqlite3_value_type,vs=s._sqlite3_value_nochange=e.sqlite3_value_nochange,Ss=s._sqlite3_value_frombind=e.sqlite3_value_frombind,ws=s._sqlite3_value_dup=e.sqlite3_value_dup,Es=s._sqlite3_value_free=e.sqlite3_value_free,ks=s._sqlite3_result_blob=e.sqlite3_result_blob,As=s._sqlite3_result_error_toobig=e.sqlite3_result_error_toobig,Is=s._sqlite3_result_error_nomem=e.sqlite3_result_error_nomem,xs=s._sqlite3_result_double=e.sqlite3_result_double,Ts=s._sqlite3_result_error=e.sqlite3_result_error,Os=s._sqlite3_result_int=e.sqlite3_result_int,Ps=s._sqlite3_result_int64=e.sqlite3_result_int64,Fs=s._sqlite3_result_null=e.sqlite3_result_null,Ls=s._sqlite3_result_pointer=e.sqlite3_result_pointer,Cs=s._sqlite3_result_subtype=e.sqlite3_result_subtype,Ds=s._sqlite3_result_text=e.sqlite3_result_text,Ns=s._sqlite3_result_zeroblob=e.sqlite3_result_zeroblob,Rs=s._sqlite3_result_zeroblob64=e.sqlite3_result_zeroblob64,Ms=s._sqlite3_result_error_code=e.sqlite3_result_error_code,js=s._sqlite3_user_data=e.sqlite3_user_data,Ws=s._sqlite3_context_db_handle=e.sqlite3_context_db_handle,zs=s._sqlite3_vtab_nochange=e.sqlite3_vtab_nochange,Bs=s._sqlite3_vtab_in_first=e.sqlite3_vtab_in_first,Us=s._sqlite3_vtab_in_next=e.sqlite3_vtab_in_next,Qs=s._sqlite3_aggregate_context=e.sqlite3_aggregate_context,Vs=s._sqlite3_get_auxdata=e.sqlite3_get_auxdata,Hs=s._sqlite3_set_auxdata=e.sqlite3_set_auxdata,Gs=s._sqlite3_column_count=e.sqlite3_column_count,Ks=s._sqlite3_data_count=e.sqlite3_data_count,$s=s._sqlite3_column_blob=e.sqlite3_column_blob,Js=s._sqlite3_column_bytes=e.sqlite3_column_bytes,Ys=s._sqlite3_column_double=e.sqlite3_column_double,Xs=s._sqlite3_column_value=e.sqlite3_column_value,Zs=s._sqlite3_column_decltype=e.sqlite3_column_decltype,eo=s._sqlite3_column_database_name=e.sqlite3_column_database_name,to=s._sqlite3_column_table_name=e.sqlite3_column_table_name,no=s._sqlite3_column_origin_name=e.sqlite3_column_origin_name,ro=s._sqlite3_bind_blob=e.sqlite3_bind_blob,io=s._sqlite3_bind_double=e.sqlite3_bind_double,so=s._sqlite3_bind_int=e.sqlite3_bind_int,oo=s._sqlite3_bind_int64=e.sqlite3_bind_int64,ao=s._sqlite3_bind_null=e.sqlite3_bind_null,lo=s._sqlite3_bind_pointer=e.sqlite3_bind_pointer,co=s._sqlite3_bind_text=e.sqlite3_bind_text,_o=s._sqlite3_bind_zeroblob=e.sqlite3_bind_zeroblob,uo=s._sqlite3_bind_parameter_count=e.sqlite3_bind_parameter_count,fo=s._sqlite3_bind_parameter_name=e.sqlite3_bind_parameter_name,po=s._sqlite3_bind_parameter_index=e.sqlite3_bind_parameter_index,ho=s._sqlite3_db_handle=e.sqlite3_db_handle,mo=s._sqlite3_stmt_readonly=e.sqlite3_stmt_readonly,go=s._sqlite3_stmt_isexplain=e.sqlite3_stmt_isexplain,bo=s._sqlite3_stmt_explain=e.sqlite3_stmt_explain,yo=s._sqlite3_stmt_busy=e.sqlite3_stmt_busy,qo=s._sqlite3_next_stmt=e.sqlite3_next_stmt,vo=s._sqlite3_stmt_status=e.sqlite3_stmt_status,So=s._sqlite3_sql=e.sqlite3_sql,wo=s._sqlite3_expanded_sql=e.sqlite3_expanded_sql,Eo=s._sqlite3_preupdate_old=e.sqlite3_preupdate_old,ko=s._sqlite3_preupdate_count=e.sqlite3_preupdate_count,Ao=s._sqlite3_preupdate_depth=e.sqlite3_preupdate_depth,Io=s._sqlite3_preupdate_blobwrite=e.sqlite3_preupdate_blobwrite,xo=s._sqlite3_preupdate_new=e.sqlite3_preupdate_new,To=s._sqlite3_value_numeric_type=e.sqlite3_value_numeric_type,Oo=s._sqlite3_set_authorizer=e.sqlite3_set_authorizer,Po=s._sqlite3_strglob=e.sqlite3_strglob,Fo=s._sqlite3_strlike=e.sqlite3_strlike,Lo=s._sqlite3_auto_extension=e.sqlite3_auto_extension,Co=s._sqlite3_cancel_auto_extension=e.sqlite3_cancel_auto_extension,Do=s._sqlite3_reset_auto_extension=e.sqlite3_reset_auto_extension,No=s._sqlite3_prepare_v3=e.sqlite3_prepare_v3,Ro=s._sqlite3_create_module=e.sqlite3_create_module,Mo=s._sqlite3_create_module_v2=e.sqlite3_create_module_v2,jo=s._sqlite3_drop_modules=e.sqlite3_drop_modules,Wo=s._sqlite3_declare_vtab=e.sqlite3_declare_vtab,zo=s._sqlite3_vtab_on_conflict=e.sqlite3_vtab_on_conflict,Bo=s._sqlite3_vtab_collation=e.sqlite3_vtab_collation,Uo=s._sqlite3_vtab_in=e.sqlite3_vtab_in,Qo=s._sqlite3_vtab_rhs_value=e.sqlite3_vtab_rhs_value,Vo=s._sqlite3_vtab_distinct=e.sqlite3_vtab_distinct,Ho=s._sqlite3_keyword_name=e.sqlite3_keyword_name,Go=s._sqlite3_keyword_count=e.sqlite3_keyword_count,Ko=s._sqlite3_keyword_check=e.sqlite3_keyword_check,$o=s._sqlite3_complete=e.sqlite3_complete,Jo=s._sqlite3_libversion=e.sqlite3_libversion,Yo=s._sqlite3_libversion_number=e.sqlite3_libversion_number,Xo=s._sqlite3mc_vfs_create=e.sqlite3mc_vfs_create,Zo=s._sqlite3_shutdown=e.sqlite3_shutdown,ea=s._sqlite3mc_vfs_shutdown=e.sqlite3mc_vfs_shutdown,ta=s._sqlite3_last_insert_rowid=e.sqlite3_last_insert_rowid,na=s._sqlite3_set_last_insert_rowid=e.sqlite3_set_last_insert_rowid,ra=s._sqlite3_changes64=e.sqlite3_changes64,ia=s._sqlite3_changes=e.sqlite3_changes,sa=s._sqlite3_total_changes64=e.sqlite3_total_changes64,oa=s._sqlite3_total_changes=e.sqlite3_total_changes,aa=s._sqlite3_txn_state=e.sqlite3_txn_state,la=s._sqlite3_close_v2=e.sqlite3_close_v2,ca=s._sqlite3_busy_handler=e.sqlite3_busy_handler,_a=s._sqlite3_progress_handler=e.sqlite3_progress_handler,ua=s._sqlite3_busy_timeout=e.sqlite3_busy_timeout,fa=s._sqlite3_interrupt=e.sqlite3_interrupt,da=s._sqlite3_is_interrupted=e.sqlite3_is_interrupted,pa=s._sqlite3_create_function=e.sqlite3_create_function,ha=s._sqlite3_create_function_v2=e.sqlite3_create_function_v2,ma=s._sqlite3_create_window_function=e.sqlite3_create_window_function,ga=s._sqlite3_overload_function=e.sqlite3_overload_function,ba=s._sqlite3_trace_v2=e.sqlite3_trace_v2,ya=s._sqlite3_commit_hook=e.sqlite3_commit_hook,qa=s._sqlite3_update_hook=e.sqlite3_update_hook,va=s._sqlite3_rollback_hook=e.sqlite3_rollback_hook,Sa=s._sqlite3_preupdate_hook=e.sqlite3_preupdate_hook,wa=s._sqlite3_set_errmsg=e.sqlite3_set_errmsg,Ea=s._sqlite3_error_offset=e.sqlite3_error_offset,ka=s._sqlite3_errcode=e.sqlite3_errcode,Aa=s._sqlite3_extended_errcode=e.sqlite3_extended_errcode,Ia=s._sqlite3_errstr=e.sqlite3_errstr,xa=s._sqlite3_limit=e.sqlite3_limit,Ta=s._sqlite3_open=e.sqlite3_open,Oa=s._sqlite3_open_v2=e.sqlite3_open_v2,Pa=s._sqlite3_create_collation=e.sqlite3_create_collation,Fa=s._sqlite3_create_collation_v2=e.sqlite3_create_collation_v2,La=s._sqlite3_collation_needed=e.sqlite3_collation_needed,Ca=s._sqlite3_get_autocommit=e.sqlite3_get_autocommit,Da=s._sqlite3_table_column_metadata=e.sqlite3_table_column_metadata,Na=s._sqlite3_extended_result_codes=e.sqlite3_extended_result_codes,Ra=s._sqlite3_uri_key=e.sqlite3_uri_key,Ma=s._sqlite3_uri_int64=e.sqlite3_uri_int64,ja=s._sqlite3_db_name=e.sqlite3_db_name,Wa=s._sqlite3_db_filename=e.sqlite3_db_filename,za=s._sqlite3_db_readonly=e.sqlite3_db_readonly,Ba=s._sqlite3_compileoption_used=e.sqlite3_compileoption_used,Ua=s._sqlite3_compileoption_get=e.sqlite3_compileoption_get,Qa=s._sqlite3session_diff=e.sqlite3session_diff,Va=s._sqlite3session_attach=e.sqlite3session_attach,Ha=s._sqlite3session_create=e.sqlite3session_create,Ga=s._sqlite3session_delete=e.sqlite3session_delete,Ka=s._sqlite3session_table_filter=e.sqlite3session_table_filter,$a=s._sqlite3session_changeset=e.sqlite3session_changeset,Ja=s._sqlite3session_changeset_strm=e.sqlite3session_changeset_strm,Ya=s._sqlite3session_patchset_strm=e.sqlite3session_patchset_strm,Xa=s._sqlite3session_patchset=e.sqlite3session_patchset,Za=s._sqlite3session_enable=e.sqlite3session_enable,el=s._sqlite3session_indirect=e.sqlite3session_indirect,tl=s._sqlite3session_isempty=e.sqlite3session_isempty,nl=s._sqlite3session_memory_used=e.sqlite3session_memory_used,rl=s._sqlite3session_object_config=e.sqlite3session_object_config,il=s._sqlite3session_changeset_size=e.sqlite3session_changeset_size,sl=s._sqlite3changeset_start=e.sqlite3changeset_start,ol=s._sqlite3changeset_start_v2=e.sqlite3changeset_start_v2,al=s._sqlite3changeset_start_strm=e.sqlite3changeset_start_strm,ll=s._sqlite3changeset_start_v2_strm=e.sqlite3changeset_start_v2_strm,cl=s._sqlite3changeset_next=e.sqlite3changeset_next,_l=s._sqlite3changeset_op=e.sqlite3changeset_op,ul=s._sqlite3changeset_pk=e.sqlite3changeset_pk,fl=s._sqlite3changeset_old=e.sqlite3changeset_old,dl=s._sqlite3changeset_new=e.sqlite3changeset_new,pl=s._sqlite3changeset_conflict=e.sqlite3changeset_conflict,hl=s._sqlite3changeset_fk_conflicts=e.sqlite3changeset_fk_conflicts,ml=s._sqlite3changeset_finalize=e.sqlite3changeset_finalize,gl=s._sqlite3changeset_invert=e.sqlite3changeset_invert,bl=s._sqlite3changeset_invert_strm=e.sqlite3changeset_invert_strm,yl=s._sqlite3changeset_apply_v2=e.sqlite3changeset_apply_v2,ql=s._sqlite3changeset_apply_v3=e.sqlite3changeset_apply_v3,vl=s._sqlite3changeset_apply=e.sqlite3changeset_apply,Sl=s._sqlite3changeset_apply_v3_strm=e.sqlite3changeset_apply_v3_strm,wl=s._sqlite3changeset_apply_v2_strm=e.sqlite3changeset_apply_v2_strm,El=s._sqlite3changeset_apply_strm=e.sqlite3changeset_apply_strm,kl=s._sqlite3changegroup_new=e.sqlite3changegroup_new,Al=s._sqlite3changegroup_add=e.sqlite3changegroup_add,Il=s._sqlite3changegroup_output=e.sqlite3changegroup_output,xl=s._sqlite3changegroup_add_strm=e.sqlite3changegroup_add_strm,Tl=s._sqlite3changegroup_output_strm=e.sqlite3changegroup_output_strm,Ol=s._sqlite3changegroup_delete=e.sqlite3changegroup_delete,Pl=s._sqlite3changeset_concat=e.sqlite3changeset_concat,Fl=s._sqlite3changeset_concat_strm=e.sqlite3changeset_concat_strm,Ll=s._sqlite3session_config=e.sqlite3session_config,Cl=s._sqlite3_sourceid=e.sqlite3_sourceid,Dl=s._sqlite3mc_version=e.sqlite3mc_version,Nl=s._sqlite3mc_config=e.sqlite3mc_config,Rl=s._sqlite3mc_cipher_count=e.sqlite3mc_cipher_count,Ml=s._sqlite3mc_cipher_index=e.sqlite3mc_cipher_index,jl=s._sqlite3mc_cipher_name=e.sqlite3mc_cipher_name,Wl=s._sqlite3mc_cipher_name_copy=e.sqlite3mc_cipher_name_copy,zl=s._sqlite3mc_config_cipher=e.sqlite3mc_config_cipher,Bl=s._sqlite3mc_codec_data=e.sqlite3mc_codec_data,Ul=s._sqlite3_activate_see=e.sqlite3_activate_see,Ql=s._sqlite3_key=e.sqlite3_key,Vl=s._sqlite3_key_v2=e.sqlite3_key_v2,Hl=s._sqlite3_rekey_v2=e.sqlite3_rekey_v2,Gl=s._sqlite3_rekey=e.sqlite3_rekey,Kl=s._sqlite3mc_vfs_destroy=e.sqlite3mc_vfs_destroy,$l=s._sqlite3__wasm_pstack_ptr=e.sqlite3__wasm_pstack_ptr,Jl=s._sqlite3__wasm_pstack_restore=e.sqlite3__wasm_pstack_restore,Yl=s._sqlite3__wasm_pstack_alloc=e.sqlite3__wasm_pstack_alloc,Xl=s._sqlite3__wasm_pstack_remaining=e.sqlite3__wasm_pstack_remaining,Zl=s._sqlite3__wasm_pstack_quota=e.sqlite3__wasm_pstack_quota,ec=s._sqlite3__wasm_test_struct=e.sqlite3__wasm_test_struct,tc=s._sqlite3__wasm_enum_json=e.sqlite3__wasm_enum_json,nc=s._sqlite3__wasm_vfs_unlink=e.sqlite3__wasm_vfs_unlink,rc=s._sqlite3__wasm_db_vfs=e.sqlite3__wasm_db_vfs,ic=s._sqlite3__wasm_db_reset=e.sqlite3__wasm_db_reset,sc=s._sqlite3__wasm_db_export_chunked=e.sqlite3__wasm_db_export_chunked,oc=s._sqlite3__wasm_db_serialize=e.sqlite3__wasm_db_serialize,ac=s._sqlite3__wasm_vfs_create_file=e.sqlite3__wasm_vfs_create_file,lc=s._sqlite3__wasm_posix_create_file=e.sqlite3__wasm_posix_create_file,cc=s._sqlite3__wasm_kvvfsMakeKey=e.sqlite3__wasm_kvvfsMakeKey,_c=s._sqlite3__wasm_kvvfs_methods=e.sqlite3__wasm_kvvfs_methods,uc=s._sqlite3__wasm_vtab_config=e.sqlite3__wasm_vtab_config,fc=s._sqlite3__wasm_db_config_ip=e.sqlite3__wasm_db_config_ip,dc=s._sqlite3__wasm_db_config_pii=e.sqlite3__wasm_db_config_pii,pc=s._sqlite3__wasm_db_config_s=e.sqlite3__wasm_db_config_s,hc=s._sqlite3__wasm_config_i=e.sqlite3__wasm_config_i,mc=s._sqlite3__wasm_config_ii=e.sqlite3__wasm_config_ii,gc=s._sqlite3__wasm_config_j=e.sqlite3__wasm_config_j,bc=s._sqlite3__wasm_qfmt_token=e.sqlite3__wasm_qfmt_token,yc=s._sqlite3__wasm_kvvfs_decode=e.sqlite3__wasm_kvvfs_decode,qc=s._sqlite3__wasm_kvvfs_encode=e.sqlite3__wasm_kvvfs_encode,vc=s._sqlite3__wasm_init_wasmfs=e.sqlite3__wasm_init_wasmfs,Sc=s._sqlite3__wasm_test_intptr=e.sqlite3__wasm_test_intptr,wc=s._sqlite3__wasm_test_voidptr=e.sqlite3__wasm_test_voidptr,Ec=s._sqlite3__wasm_test_int64_max=e.sqlite3__wasm_test_int64_max,kc=s._sqlite3__wasm_test_int64_min=e.sqlite3__wasm_test_int64_min,Ac=s._sqlite3__wasm_test_int64_times2=e.sqlite3__wasm_test_int64_times2,Ic=s._sqlite3__wasm_test_int64_minmax=e.sqlite3__wasm_test_int64_minmax,xc=s._sqlite3__wasm_test_int64ptr=e.sqlite3__wasm_test_int64ptr,Tc=s._sqlite3__wasm_test_stack_overflow=e.sqlite3__wasm_test_stack_overflow,Oc=s._sqlite3__wasm_test_str_hello=e.sqlite3__wasm_test_str_hello,Pc=s._sqlite3__wasm_SQLTester_strglob=e.sqlite3__wasm_SQLTester_strglob,Fc=s._malloc=e.malloc,Lc=s._free=e.free,Cc=s._realloc=e.realloc,bn=e.emscripten_builtin_memalign,yn=e._emscripten_stack_restore,Dc=e._emscripten_stack_alloc,qn=e.emscripten_stack_get_current,Nc=e.__indirect_function_table}var vn={__syscall_chmod:Tr,__syscall_faccessat:Or,__syscall_fchmod:Pr,__syscall_fchown32:Fr,__syscall_fcntl64:Lr,__syscall_fstat64:Cr,__syscall_ftruncate64:Rr,__syscall_getcwd:Mr,__syscall_ioctl:jr,__syscall_lstat64:Wr,__syscall_mkdirat:zr,__syscall_newfstatat:Br,__syscall_openat:Ur,__syscall_readlinkat:Qr,__syscall_rmdir:Vr,__syscall_stat64:Hr,__syscall_unlinkat:Gr,__syscall_utimensat:Kr,_abort_js:$r,_localtime_js:ei,_mmap_js:ti,_munmap_js:ni,_tzset_js:ri,clock_time_get:oi,emscripten_date_now:mn,emscripten_get_heap_max:ai,emscripten_get_now:hn,emscripten_resize_heap:ci,environ_get:ui,environ_sizes_get:fi,exit:gi,fd_close:bi,fd_fdstat_get:yi,fd_read:vi,fd_seek:Si,fd_sync:wi,fd_write:ki,memory:Ze,wasm_crypto_getrandom:Ai};async function Mc(){if(rr(),lt)await Sr();var e=s.setStatus;if(e)e("Running..."),await new Promise((n)=>setTimeout(n,1)),setTimeout(e,1,"");if(Ot)return;ir(),s.onRuntimeInitialized?.(),sr()}var gt=await fr();return await Mc(),s.runSQLite3PostLoadInit=async function(e,n,o){delete n.runSQLite3PostLoadInit,globalThis.sqlite3ApiBootstrap=async function i(t=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;let r=(...f)=>Object.assign(Object.create(null),...f),a=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},t);Object.assign(a,{allocExportName:a.useStdAlloc?"malloc":"sqlite3_malloc",deallocExportName:a.useStdAlloc?"free":"sqlite3_free",reallocExportName:a.useStdAlloc?"realloc":"sqlite3_realloc"}),["exports","memory","functionTable","wasmfsOpfsDir"].forEach((f)=>{if(typeof a[f]==="function")a[f]=a[f]()});let _=r(),h=r(),I=(f)=>_.sqlite3_js_rc_str&&_.sqlite3_js_rc_str(f)||"Unknown result code #"+f,S=(f)=>typeof f==="number"&&f===(f|0)&&f<=2147483647&&f>=-2147483648;class R extends Error{constructor(...f){let w;if(f.length)if(S(f[0]))if(w=f[0],f.length===1)super(I(f[0]));else{let N=I(w);if(typeof f[1]==="object")super(N,f[1]);else{f[0]=N+":";super(f.join(" "))}}else if(f.length===2&&typeof f[1]==="object")super(...f);else super(f.join(" "));this.resultCode=w||_.SQLITE_ERROR,this.name="SQLite3Error"}}R.toss=(...f)=>{throw new R(...f)};let M=R.toss;if(a.wasmfsOpfsDir&&!/^\/[^/]+$/.test(a.wasmfsOpfsDir))M("config.wasmfsOpfsDir must be falsy or in the form '/dir-name'.");let p=function f(w){if(!f._max)f._max=BigInt("0x7fffffffffffffff"),f._min=~f._max;return w>=f._min&&w<=f._max},te=(f)=>f>=-0x7fffffffn-1n&&f<=0x7fffffffn,j=function f(w){if(!f._min)f._min=Number.MIN_SAFE_INTEGER,f._max=Number.MAX_SAFE_INTEGER;return w>=f._min&&w<=f._max},U=(f)=>f&&f.constructor&&S(f.constructor.BYTES_PER_ELEMENT)?f:!1,E=(f)=>f&&(f instanceof Uint8Array||f instanceof Int8Array||f instanceof ArrayBuffer),b=(f)=>f&&(f instanceof Uint8Array||f instanceof Int8Array||f instanceof ArrayBuffer),F=(f)=>E(f)||M("Value is not of a supported TypedArray type."),x=function(f){if(b(f))return h.typedArrayToString(f instanceof ArrayBuffer?new Uint8Array(f):f,0,f.length);else if(Array.isArray(f))return f.join("");else if(h.isPtr(f))f=h.cstrToJs(f);return f};class A extends Error{constructor(...f){if(f.length===2&&typeof f[1]==="object")super(...f);else if(f.length)super(f.join(" "));else super("Allocation failed.");this.resultCode=_.SQLITE_NOMEM,this.name="WasmAllocError"}}A.toss=(...f)=>{throw new A(...f)},Object.assign(_,{sqlite3_bind_blob:void 0,sqlite3_bind_text:void 0,sqlite3_create_function_v2:(f,w,N,J,ie,le,we,me,K)=>{},sqlite3_create_function:(f,w,N,J,ie,le,we,me)=>{},sqlite3_create_window_function:(f,w,N,J,ie,le,we,me,K,oe)=>{},sqlite3_prepare_v3:(f,w,N,J,ie,le)=>{},sqlite3_prepare_v2:(f,w,N,J,ie)=>{},sqlite3_exec:(f,w,N,J,ie)=>{},sqlite3_randomness:(f,w)=>{}});let D={affirmBindableTypedArray:F,flexibleString:x,bigIntFits32:te,bigIntFits64:p,bigIntFitsDouble:j,isBindableTypedArray:E,isInt32:S,isSQLableTypedArray:b,isTypedArray:U,isUIThread:()=>globalThis.window===globalThis&&!!globalThis.document,toss:function(...f){throw Error(f.join(" "))},toss3:M,typedArrayPart:h.typedArrayPart,nu:r,assert:function(f,w){if(!f)D.toss("Assertion failed:",w)},affirmDbHeader:function(f){if(f instanceof ArrayBuffer)f=new Uint8Array(f);let w="SQLite format 3";if(w.length>f.byteLength)M("Input does not contain an SQLite3 database header.");for(let N=0;N<w.length;++N)if(w.charCodeAt(N)!==f[N])break},affirmIsDb:function(f){if(f instanceof ArrayBuffer)f=new Uint8Array(f);let w=f.byteLength;if(w<512||w%512!==0)M("Byte array size",w,"is invalid for an SQLite3 db.");D.affirmDbHeader(f)}};Object.assign(h,{exports:a.exports||M("Missing API config.exports (WASM module exports)."),memory:a.memory||a.exports.memory||M("API config object requires a WebAssembly.Memory object","in either config.exports.memory (exported)","or config.memory (imported)."),pointerSize:typeof a.exports.sqlite3_libversion()==="number"?4:8,bigIntEnabled:!!a.bigIntEnabled,functionTable:a.functionTable,alloc:void 0,realloc:void 0,dealloc:void 0}),h.allocFromTypedArray=function(f){if(f instanceof ArrayBuffer)f=new Uint8Array(f);F(f);let w=h.alloc(f.byteLength||1);return h.heapForSize(f.constructor).set(f.byteLength?f:[0],Number(w)),w};{let{allocExportName:f,deallocExportName:w,reallocExportName:N}=a;for(let J of[f,w,N])if(!(h.exports[J]instanceof Function))M("Missing required exports[",J,"] function.");h.alloc=function J(ie){return J.impl(ie)||A.toss("Failed to allocate",ie," bytes.")},h.alloc.impl=h.exports[f],h.realloc=function J(ie,le){let we=J.impl(h.ptr.coerce(ie),le);return le?we||A.toss("Failed to reallocate",le," bytes."):h.ptr.null},h.realloc.impl=h.exports[N],h.dealloc=function J(ie){J.impl(h.ptr.coerce(ie))},h.dealloc.impl=h.exports[w]}h.compileOptionUsed=function f(w){if(!arguments.length){if(f._result)return f._result;else if(!f._opt)f._rx=/^([^=]+)=(.+)/,f._rxInt=/^-?\d+$/,f._opt=function(we,me){let K=f._rx.exec(we);me[0]=K?K[1]:we,me[1]=K?f._rxInt.test(K[2])?+K[2]:K[2]:!0};let N=r(),J=[0,0],ie=0,le;while(le=_.sqlite3_compileoption_get(ie++))f._opt(le,J),N[J[0]]=J[1];return f._result=N}else if(Array.isArray(w)){let N=r();return w.forEach((J)=>{N[J]=_.sqlite3_compileoption_used(J)}),N}else if(typeof w==="object")return Object.keys(w).forEach((N)=>{w[N]=_.sqlite3_compileoption_used(N)}),w;return typeof w==="string"?!!_.sqlite3_compileoption_used(w):!1},h.pstack=r({restore:h.exports.sqlite3__wasm_pstack_restore,alloc:function(f){if(typeof f==="string"&&!(f=h.sizeofIR(f)))A.toss("Invalid value for pstack.alloc(",arguments[0],")");return h.exports.sqlite3__wasm_pstack_alloc(f)||A.toss("Could not allocate",f,"bytes from the pstack.")},allocChunks:function(f,w){if(typeof w==="string"&&!(w=h.sizeofIR(w)))A.toss("Invalid size value for allocChunks(",arguments[1],")");let N=h.pstack.alloc(f*w),J=[N],ie=1,le=w;for(;ie<f;++ie,le+=w)J.push(h.ptr.add(N,le));return J},allocPtr:(f=1,w=!0)=>f===1?h.pstack.alloc(w?8:h.ptr.size):h.pstack.allocChunks(f,w?8:h.ptr.size),call:function(f){let w=h.pstack.pointer;try{return f(z)}finally{h.pstack.restore(w)}}}),Object.defineProperties(h.pstack,{pointer:{configurable:!1,iterable:!0,writeable:!1,get:h.exports.sqlite3__wasm_pstack_ptr},quota:{configurable:!1,iterable:!0,writeable:!1,get:h.exports.sqlite3__wasm_pstack_quota},remaining:{configurable:!1,iterable:!0,writeable:!1,get:h.exports.sqlite3__wasm_pstack_remaining}}),_.sqlite3_randomness=(...f)=>{if(f.length===1&&D.isTypedArray(f[0])&&f[0].BYTES_PER_ELEMENT===1){let w=f[0];if(w.byteLength===0)return h.exports.sqlite3_randomness(0,h.ptr.null),w;let N=h.pstack.pointer;try{let J=w.byteLength,ie=0,le=h.exports.sqlite3_randomness,we=h.heap8u(),me=J<512?J:512,K=h.pstack.alloc(me);do{let oe=J>me?me:J;le(oe,K),w.set(h.typedArrayPart(we,K,h.ptr.add(K,oe)),ie),J-=oe,ie+=oe}while(J>0)}catch(J){a.error("Highly unexpected (and ignored!) exception in sqlite3_randomness():",J)}finally{h.pstack.restore(N)}return w}h.exports.sqlite3_randomness(...f)},_.sqlite3_wasmfs_opfs_dir=function(){if(this.dir!==void 0)return this.dir;let f=a.wasmfsOpfsDir;if(!f||!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!h.exports.sqlite3__wasm_init_wasmfs)return this.dir="";try{if(f&&h.xCallWrapped("sqlite3__wasm_init_wasmfs","i32",["string"],f)===0)return this.dir=f;else return this.dir=""}catch(w){return this.dir=""}}.bind(r()),_.sqlite3_wasmfs_filename_is_persistent=function(f){let w=_.sqlite3_wasmfs_opfs_dir();return w&&f?f.startsWith(w+"/"):!1},_.sqlite3_js_db_uses_vfs=function(f,w,N=0){try{let J=_.sqlite3_vfs_find(w);if(!J)return!1;else if(!f)return J===_.sqlite3_vfs_find(0)?J:!1;else return J===_.sqlite3_js_db_vfs(f,N)?J:!1}catch(J){return!1}},_.sqlite3_js_vfs_list=function(){let f=[],w=_.sqlite3_vfs_find(h.ptr.null);while(w){let N=new _.sqlite3_vfs(w);f.push(h.cstrToJs(N.$zName)),w=N.$pNext,N.dispose()}return f},_.sqlite3_js_db_export=function(f,w=0){if(f=h.xWrap.testConvertArg("sqlite3*",f),!f)M("Invalid sqlite3* argument.");if(!h.bigIntEnabled)M("BigInt support is not enabled.");let N=h.scopedAllocPush(),J;try{let ie=h.scopedAlloc(8+h.ptr.size),le=h.ptr.add(ie,8),we=w?h.isPtr(w)?w:h.scopedAllocCString(""+w):h.ptr.null,me=h.exports.sqlite3__wasm_db_serialize(f,we,le,ie,0);if(me)M("Database serialization failed with code",z.capi.sqlite3_js_rc_str(me));J=h.peekPtr(le);let K=h.peek(ie,"i64");return me=K?h.heap8u().slice(Number(J),Number(J)+Number(K)):new Uint8Array,me}finally{if(J)h.exports.sqlite3_free(J);h.scopedAllocPop(N)}},_.sqlite3_js_db_vfs=(f,w=h.ptr.null)=>D.sqlite3__wasm_db_vfs(f,w),_.sqlite3_js_aggregate_context=(f,w)=>_.sqlite3_aggregate_context(f,w)||(w?A.toss("Cannot allocate",w,"bytes for sqlite3_aggregate_context()"):0),_.sqlite3_js_posix_create_file=function(f,w,N){let J;if(w&&h.isPtr(w))J=w;else if(w instanceof ArrayBuffer||w instanceof Uint8Array){if(J=h.allocFromTypedArray(w),arguments.length<3||!D.isInt32(N)||N<0)N=w.byteLength}else R.toss("Invalid 2nd argument for sqlite3_js_posix_create_file().");try{if(!D.isInt32(N)||N<0)R.toss("Invalid 3rd argument for sqlite3_js_posix_create_file().");let ie=D.sqlite3__wasm_posix_create_file(f,J,N);if(ie)R.toss("Creation of file failed with sqlite3 result code",_.sqlite3_js_rc_str(ie))}finally{if(J&&J!==w)h.dealloc(J)}},_.sqlite3_js_vfs_create_file=function(f,w,N,J){a.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 ie;if(N)if(h.isPtr(N))ie=N;else{if(N instanceof ArrayBuffer)N=new Uint8Array(N);if(N instanceof Uint8Array){if(ie=h.allocFromTypedArray(N),arguments.length<4||!D.isInt32(J)||J<0)J=N.byteLength}else R.toss("Invalid 3rd argument type for sqlite3_js_vfs_create_file().")}else ie=0;if(!D.isInt32(J)||J<0){if(ie&&ie!==N)h.dealloc(ie);R.toss("Invalid 4th argument for sqlite3_js_vfs_create_file().")}try{let le=D.sqlite3__wasm_vfs_create_file(f,w,ie,J);if(le)R.toss("Creation of file failed with sqlite3 result code",_.sqlite3_js_rc_str(le))}finally{if(ie&&ie!==N)h.dealloc(ie)}},_.sqlite3_js_sql_to_string=(f)=>{if(typeof f==="string")return f;let w=x(v);return w===v?void 0:w},_.sqlite3_db_config=function(f,w,...N){switch(w){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:if(!this.ip)this.ip=h.xWrap("sqlite3__wasm_db_config_ip","int",["sqlite3*","int","int","*"]);return this.ip(f,w,N[0],N[1]||0);case _.SQLITE_DBCONFIG_LOOKASIDE:if(!this.pii)this.pii=h.xWrap("sqlite3__wasm_db_config_pii","int",["sqlite3*","int","*","int","int"]);return this.pii(f,w,N[0],N[1],N[2]);case _.SQLITE_DBCONFIG_MAINDBNAME:if(!this.s)this.s=h.xWrap("sqlite3__wasm_db_config_s","int",["sqlite3*","int","string:static"]);return this.s(f,w,N[0]);default:return _.SQLITE_MISUSE}}.bind(r()),_.sqlite3_value_to_js=function(f,w=!0){let N,J=_.sqlite3_value_type(f);switch(J){case _.SQLITE_INTEGER:if(h.bigIntEnabled){if(N=_.sqlite3_value_int64(f),D.bigIntFitsDouble(N))N=Number(N)}else N=_.sqlite3_value_double(f);break;case _.SQLITE_FLOAT:N=_.sqlite3_value_double(f);break;case _.SQLITE_TEXT:N=_.sqlite3_value_text(f);break;case _.SQLITE_BLOB:{let ie=_.sqlite3_value_bytes(f),le=_.sqlite3_value_blob(f);if(ie&&!le)z.WasmAllocError.toss("Cannot allocate memory for blob argument of",ie,"byte(s)");N=ie?h.heap8u().slice(Number(le),Number(le)+Number(ie)):null;break}case _.SQLITE_NULL:N=null;break;default:if(w)M(_.SQLITE_MISMATCH,"Unhandled sqlite3_value_type():",J);N=void 0}return N},_.sqlite3_values_to_js=function(f,w,N=!0){let J,ie=[];for(J=0;J<f;++J)ie.push(_.sqlite3_value_to_js(h.peekPtr(h.ptr.add(w,h.ptr.size*J)),N));return ie},_.sqlite3_result_error_js=function(f,w){if(w instanceof A)_.sqlite3_result_error_nomem(f);else _.sqlite3_result_error(f,""+w,-1)},_.sqlite3_result_js=function(f,w){if(w instanceof Error){_.sqlite3_result_error_js(f,w);return}try{switch(typeof w){case"undefined":break;case"boolean":_.sqlite3_result_int(f,w?1:0);break;case"bigint":if(D.bigIntFits32(w))_.sqlite3_result_int(f,Number(w));else if(D.bigIntFitsDouble(w))_.sqlite3_result_double(f,Number(w));else if(h.bigIntEnabled)if(D.bigIntFits64(w))_.sqlite3_result_int64(f,w);else M("BigInt value",w.toString(),"is too BigInt for int64.");else M("BigInt value",w.toString(),"is too BigInt.");break;case"number":{let N;if(D.isInt32(w))N=_.sqlite3_result_int;else if(h.bigIntEnabled&&Number.isInteger(w)&&D.bigIntFits64(BigInt(w)))N=_.sqlite3_result_int64;else N=_.sqlite3_result_double;N(f,w);break}case"string":{let[N,J]=h.allocCString(w,!0);_.sqlite3_result_text(f,N,J,_.SQLITE_WASM_DEALLOC);break}case"object":if(w===null){_.sqlite3_result_null(f);break}else if(D.isBindableTypedArray(w)){let N=h.allocFromTypedArray(w);_.sqlite3_result_blob(f,N,w.byteLength,_.SQLITE_WASM_DEALLOC);break}default:M("Don't not how to handle this UDF result value:",typeof w,w)}}catch(N){_.sqlite3_result_error_js(f,N)}},_.sqlite3_column_js=function(f,w,N=!0){let J=_.sqlite3_column_value(f,w);return J===0?void 0:_.sqlite3_value_to_js(J,N)};{let f=function(w,N,J){if(J=_[J],!this.ptr)this.ptr=h.allocPtr();else h.pokePtr(this.ptr,0);let ie=J(w,N,this.ptr);if(ie)return R.toss(ie,arguments[2]+"() failed with code "+ie);let le=h.peekPtr(this.ptr);return le?_.sqlite3_value_to_js(le,!0):void 0}.bind(r());_.sqlite3_preupdate_new_js=(w,N)=>f(w,N,"sqlite3_preupdate_new"),_.sqlite3_preupdate_old_js=(w,N)=>f(w,N,"sqlite3_preupdate_old"),_.sqlite3changeset_new_js=(w,N)=>f(w,N,"sqlite3changeset_new"),_.sqlite3changeset_old_js=(w,N)=>f(w,N,"sqlite3changeset_old")}_.sqlite3_js_retry_busy=function(f,w,N){for(let J=1;J<=f;++J)try{if(N&&J>1)N(J);let ie=w();if(_.SQLITE_BUSY===ie){if(J===f)throw new R(ie,["sqlite3_js_retry_busy() max retry attempts (",f,") reached."].join(""));continue}return ie}catch(ie){if(J<f&&ie instanceof R&&ie.resultCode===_.SQLITE_BUSY)continue;throw ie}};let z={WasmAllocError:A,SQLite3Error:R,capi:_,util:D,wasm:h,config:a,version:r(),client:void 0,asyncPostInit:async function f(){if(f.isReady instanceof Promise)return f.isReady;let w=this.initializersAsync;delete this.initializersAsync;let N=async()=>{if(!z.__isUnderTest)delete z.util,delete z.StructBinder,delete z.opfs;return z},J=(le)=>{throw a.error("an async sqlite3 initializer failed:",le),le};if(!w||!w.length)return f.isReady=N().catch(J);w=w.map((le)=>le instanceof Function?async(we)=>le(z):le),w.push(N);let ie=Promise.resolve(z);while(w.length)ie=ie.then(w.shift());return f.isReady=ie.catch(J)}.bind(i),scriptInfo:void 0};if(typeof o<"u")z.__isUnderTest=!!o;try{i.initializers.forEach((f)=>{f(z)})}catch(f){throw console.error("sqlite3 bootstrap initializer threw:",f),f}if(delete i.initializers,i.sqlite3=z,typeof e<"u")e.debugModule("sqlite3ApiBootstrap() complete",z),z.scriptInfo=e;if(z.__isUnderTest){if(typeof n<"u")z.config.emscripten=n;let f=z.scriptInfo?.instantiateWasm;if(f)z.wasm.module=f.module,z.wasm.instance=f.instance,z.wasm.imports=f.imports}return delete globalThis.sqlite3ApiConfig,delete globalThis.sqlite3ApiBootstrap,delete i.defaultConfig,z.asyncPostInit().then((f)=>{if(typeof e<"u")e.debugModule("sqlite3.asyncPostInit() complete",f);return delete f.asyncPostInit,delete f.scriptInfo,delete f.emscripten,f})},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.54.0",libVersionNumber:3054000,sourceId:"2026-10-09 15:46:58 be8d059e9a49089ab2dce5ed26dd87aaf598fdc5fbe0b107c0dd758464bcd5e3",downloadVersion:3540000,scm:{"sha3-256":"be8d059e9a49089ab2dce5ed26dd87aaf598fdc5fbe0b107c0dd758464bcd5e3",branch:"trunk",tags:"release major-release version-3.54.0",datetime:"2026-10-09T15:46:58.543Z"}}}),globalThis.WhWasmUtilInstaller=function(t){if(t.bigIntEnabled===void 0)t.bigIntEnabled=!!globalThis.BigInt64Array;let r=(...u)=>{throw Error(u.join(" "))};if(!t.pointerSize&&!t.pointerIR&&t.alloc&&t.dealloc){let u=t.alloc(1);t.pointerSize=typeof u==="bigint"?8:4,t.dealloc(u)}if(t.pointerSize&&!t.pointerIR)t.pointerIR=t.pointerSize===4?"i32":"i64";let a=t.pointerIR??="i32",_=t.pointerSize??=a==="i32"?4:a==="i64"?8:0;if(delete t.pointerSize,delete t.pointerIR,a!=="i32"&&a!=="i64")r("Invalid pointerIR:",a);else if(_!==8&&_!==4)r("Invalid pointerSize:",_);let h=t.bigIntEnabled?(u)=>BigInt(u||0):(u)=>r("BigInt support is disabled in this build."),S=_===4?(u)=>Number(u||0):h,R=S(0),M=function(...u){let q=S(0);for(let O of u)q+=S(O);return q};{let u=Object.create(null);Object.defineProperty(t,"ptr",{enumerable:!0,get:()=>u,set:()=>r("The ptr property is read-only.")}),function q(O,V){return Object.defineProperty(u,O,{enumerable:!0,get:()=>V,set:()=>r("ptr["+O+"] is read-only.")}),q}("null",R)("size",_)("ir",a)("coerce",S)("add",M)("addn",a===4?M:(...q)=>Number(M(...q)))}if(!t.exports)Object.defineProperty(t,"exports",{enumerable:!0,configurable:!0,get:()=>t.instance?.exports});let p=Object.create(null);p.heapSize=0,p.memory=null,p.freeFuncIndexes=[],p.scopedAlloc=[],p.scopedAlloc.pushPtr=(u)=>(p.scopedAlloc[p.scopedAlloc.length-1].push(u),u),p.utf8Decoder=new TextDecoder,p.utf8Encoder=new TextEncoder("utf-8"),t.sizeofIR=(u)=>{switch(u){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(""+u).endsWith("*")?_:void 0}};let te=function(){if(!p.memory)p.memory=t.memory instanceof WebAssembly.Memory?t.memory:t.exports.memory;else if(p.heapSize===p.memory.buffer.byteLength)return p;let u=p.memory.buffer;if(p.HEAP8=new Int8Array(u),p.HEAP8U=new Uint8Array(u),p.HEAP16=new Int16Array(u),p.HEAP16U=new Uint16Array(u),p.HEAP32=new Int32Array(u),p.HEAP32U=new Uint32Array(u),p.HEAP32F=new Float32Array(u),p.HEAP64F=new Float64Array(u),t.bigIntEnabled)if(typeof BigInt64Array<"u")p.HEAP64=new BigInt64Array(u),p.HEAP64U=new BigUint64Array(u);else r("BigInt support is enabled, but the BigInt64Array type is missing.");return p.heapSize=u.byteLength,p};t.heap8=()=>te().HEAP8,t.heap8u=()=>te().HEAP8U,t.heap16=()=>te().HEAP16,t.heap16u=()=>te().HEAP16U,t.heap32=()=>te().HEAP32,t.heap32u=()=>te().HEAP32U,t.heapForSize=function(u,q=!0){let O,V=p.memory&&p.heapSize===p.memory.buffer.byteLength?p:te();switch(u){case Int8Array:return V.HEAP8;case Uint8Array:return V.HEAP8U;case Int16Array:return V.HEAP16;case Uint16Array:return V.HEAP16U;case Int32Array:return V.HEAP32;case Uint32Array:return V.HEAP32U;case 8:return q?V.HEAP8U:V.HEAP8;case 16:return q?V.HEAP16U:V.HEAP16;case 32:return q?V.HEAP32U:V.HEAP32;case 64:if(V.HEAP64)return q?V.HEAP64U:V.HEAP64;break;default:if(t.bigIntEnabled){if(u===globalThis.BigUint64Array)return V.HEAP64U;else if(u===globalThis.BigInt64Array)return V.HEAP64;break}}r("Invalid heapForSize() size: expecting 8, 16, 32,","or (if BigInt is enabled) 64.")};let j=t.functionTable;delete t.functionTable,t.functionTable=j?()=>j:()=>t.exports.__indirect_function_table,t.functionEntry=function(u){let q=t.functionTable();return u<q.length?q.get(S(u)):void 0},t.jsFuncToWasm=function u(q,O){if(!u._)u._={sigTypes:Object.assign(Object.create(null),{i:"i32",p:a,P:a,s:a,j:"i64",f:"f32",d:"f64"}),typeCodes:Object.assign(Object.create(null),{f64:124,f32:125,i64:126,i32:127}),uleb128Encode:(y,C,c)=>{if(c<128)y[C](c);else y[C](c%128|128,c>>7)},rxJSig:/^(\w)\((\w*)\)$/,sigParams:(y)=>{let C=u._.rxJSig.exec(y);return C?C[2]:y.substr(1)},letterType:(y)=>u._.sigTypes[y]||r("Invalid signature letter:",y),pushSigType:(y,C)=>y.push(u._.typeCodes[u._.letterType(C)])};if(typeof q==="string"){let y=O;O=q,q=y}let V=u._,Z=V.sigParams(O),m=[1,96];V.uleb128Encode(m,"push",Z.length);for(let y of Z)V.pushSigType(m,y);if(O[0]==="v")m.push(0);else m.push(1),V.pushSigType(m,O[0]);return V.uleb128Encode(m,"unshift",m.length),m.unshift(0,97,115,109,1,0,0,0,1),m.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(m)),{e:{f:q}}).exports.f};let U=function(q,O,V){if(V&&!p.scopedAlloc.length)r("No scopedAllocPush() scope is active.");if(typeof q==="string"){let C=O;O=q,q=C}if(typeof O!=="string"||!(q instanceof Function))r("Invalid arguments: expecting (function,signature) or (signature,function).");let Z=t.functionTable(),m=S(Z.length),y;while(y=p.freeFuncIndexes.pop())if(Z.get(y)){y=null;continue}else break;if(!y)y=S(m),Z.grow(S(1));try{if(Z.set(y,q),V)p.scopedAlloc.pushPtr(y);return y}catch(C){if(!(C instanceof TypeError)){if(y===m)p.freeFuncIndexes.push(m);throw C}}try{let C=t.jsFuncToWasm(q,O);if(Z.set(y,C),V)p.scopedAlloc.pushPtr(y)}catch(C){if(y===m)p.freeFuncIndexes.push(m);throw C}return y};t.installFunction=(u,q)=>U(u,q,!1),t.scopedInstallFunction=(u,q)=>U(u,q,!0),t.uninstallFunction=function(u){if(!u&&R!==u)return;let q=t.functionTable();p.freeFuncIndexes.push(u);let O=q.get(u);return q.set(u,null),O},t.peek=function(q,O="i8"){if(O.endsWith("*"))O=a;let V=p.memory&&p.heapSize===p.memory.buffer.byteLength?p:te(),Z=Array.isArray(q)?[]:void 0,m;do{if(Z)q=arguments[0].shift();switch(O){case"i1":case"i8":m=V.HEAP8[Number(q)>>0];break;case"i16":m=V.HEAP16[Number(q)>>1];break;case"i32":m=V.HEAP32[Number(q)>>2];break;case"float":case"f32":m=V.HEAP32F[Number(q)>>2];break;case"double":case"f64":m=Number(V.HEAP64F[Number(q)>>3]);break;case"i64":if(V.HEAP64){m=h(V.HEAP64[Number(q)>>3]);break}default:r("Invalid type for peek():",O)}if(Z)Z.push(m)}while(Z&&arguments[0].length);return Z||m},t.poke=function(u,q,O="i8"){if(O.endsWith("*"))O=a;let V=p.memory&&p.heapSize===p.memory.buffer.byteLength?p:te();for(let Z of Array.isArray(u)?u:[u])switch(O){case"i1":case"i8":V.HEAP8[Number(Z)>>0]=q;continue;case"i16":V.HEAP16[Number(Z)>>1]=q;continue;case"i32":V.HEAP32[Number(Z)>>2]=q;continue;case"float":case"f32":V.HEAP32F[Number(Z)>>2]=q;continue;case"double":case"f64":V.HEAP64F[Number(Z)>>3]=q;continue;case"i64":if(V.HEAP64){V.HEAP64[Number(Z)>>3]=h(q);continue}default:r("Invalid type for poke(): "+O)}return this},t.peekPtr=(...u)=>t.peek(u.length===1?u[0]:u,a),t.pokePtr=(u,q=0)=>t.poke(u,q,a),t.peek8=(...u)=>t.peek(u.length===1?u[0]:u,"i8"),t.poke8=(u,q)=>t.poke(u,q,"i8"),t.peek16=(...u)=>t.peek(u.length===1?u[0]:u,"i16"),t.poke16=(u,q)=>t.poke(u,q,"i16"),t.peek32=(...u)=>t.peek(u.length===1?u[0]:u,"i32"),t.poke32=(u,q)=>t.poke(u,q,"i32"),t.peek64=(...u)=>t.peek(u.length===1?u[0]:u,"i64"),t.poke64=(u,q)=>t.poke(u,q,"i64"),t.peek32f=(...u)=>t.peek(u.length===1?u[0]:u,"f32"),t.poke32f=(u,q)=>t.poke(u,q,"f32"),t.peek64f=(...u)=>t.peek(u.length===1?u[0]:u,"f64"),t.poke64f=(u,q)=>t.poke(u,q,"f64"),t.getMemValue=t.peek,t.getPtrValue=t.peekPtr,t.setMemValue=t.poke,t.setPtrValue=t.pokePtr,t.isPtr32=(u)=>typeof u==="number"&&u>=0&&u===(u|0),t.isPtr64=(u)=>typeof u==="bigint"?u>=0:t.isPtr32(u),t.isPtr=_===4?t.isPtr32:t.isPtr64,t.cstrlen=function(u){if(!u||!t.isPtr(u))return null;u=Number(u);let q=te().HEAP8U,O=u;for(;q[O]!==0;++O);return O-u};let E=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,b=(u)=>u.buffer instanceof E;t.isSharedTypedArray=b;let F=(u,q,O)=>{if(_===8){if(typeof q==="bigint")q=Number(q);if(typeof O==="bigint")O=Number(O)}return b(u)?u.slice(q,O):u.subarray(q,O)};t.typedArrayPart=F;let x=(u,q,O)=>p.utf8Decoder.decode(F(u,q,O));t.typedArrayToString=x,t.cstrToJs=function(u){let q=t.cstrlen(u);return q?x(te().HEAP8U,Number(u),Number(u)+q):q===null?q:""},t.jstrlen=function(u){if(typeof u!=="string")return null;let q=u.length,O=0;for(let V=0;V<q;++V){let Z=u.charCodeAt(V);if(Z>=55296&&Z<=57343)Z=65536+((Z&1023)<<10)|u.charCodeAt(++V)&1023;if(Z<=127)++O;else if(Z<=2047)O+=2;else if(Z<=65535)O+=3;else O+=4}return O},t.jstrcpy=function(u,q,O=0,V=-1,Z=!0){if(!q||!(q instanceof Int8Array)&&!(q instanceof Uint8Array))r("jstrcpy() target must be an Int8Array or Uint8Array.");if(V=Number(V),O=Number(O),V<0)V=q.length-O;if(!(V>0)||!(O>=0))return 0;let m=0,y=u.length,C=O,c=O+V-(Z?1:0);for(;m<y&&O<c;++m){let d=u.charCodeAt(m);if(d>=55296&&d<=57343)d=65536+((d&1023)<<10)|u.charCodeAt(++m)&1023;if(d<=127){if(O>=c)break;q[O++]=d}else if(d<=2047){if(O+1>=c)break;q[O++]=192|d>>6,q[O++]=128|d&63}else if(d<=65535){if(O+2>=c)break;q[O++]=224|d>>12,q[O++]=128|d>>6&63,q[O++]=128|d&63}else{if(O+3>=c)break;q[O++]=240|d>>18,q[O++]=128|d>>12&63,q[O++]=128|d>>6&63,q[O++]=128|d&63}}if(Z)q[O++]=0;return O-C},t.cstrncpy=function(u,q,O){if(!u||!q)r("cstrncpy() does not accept NULL strings.");if(O<0)O=t.cstrlen(strPtr)+1;else if(!(O>0))return 0;let V=t.heap8u(),Z=0,m,y=Number(u),C=Number(q);for(;Z<O&&(m=V[C+Z]);++Z)V[y+Z]=m;if(Z<O)V[y+Z++]=0;return Z},t.jstrToUintArray=(u,q=!1)=>p.utf8Encoder.encode(q?u+"\x00":u);let A=(u,q)=>{if(!(u.alloc instanceof Function)||!(u.dealloc instanceof Function))r("Object is missing alloc() and/or dealloc() function(s)","required by",q+"().")},D=function(u,q,O,V){if(A(t,V),typeof u!=="string")return null;let Z=p.utf8Encoder.encode(u),m=O(Z.length+1),y=m;try{let C=te().HEAP8U;return C.set(Z,Number(m)),C[M(m,Z.length)]=0,y=R,q?[m,Z.length]:m}finally{if(y)t.dealloc(y)}};t.allocCString=(u,q=!1)=>D(u,q,t.alloc,"allocCString()"),t.scopedAllocPush=function(){A(t,"scopedAllocPush");let u=[];return p.scopedAlloc.push(u),u},t.scopedAllocPop=function(u){A(t,"scopedAllocPop");let q=arguments.length?p.scopedAlloc.indexOf(u):p.scopedAlloc.length-1;if(q<0)r("Invalid state object for scopedAllocPop().");if(arguments.length===0)u=p.scopedAlloc[q];p.scopedAlloc.splice(q,1);for(let O;O=u.pop();)if(t.functionEntry(O))t.uninstallFunction(O);else t.dealloc(O)},t.scopedAlloc=function(u){if(!p.scopedAlloc.length)r("No scopedAllocPush() scope is active.");let q=S(t.alloc(u));return p.scopedAlloc.pushPtr(q)},Object.defineProperty(t.scopedAlloc,"level",{configurable:!1,enumerable:!1,get:()=>p.scopedAlloc.length,set:()=>r("The 'active' property is read-only.")}),t.scopedAllocCString=(u,q=!1)=>D(u,q,t.scopedAlloc,"scopedAllocCString()");let z=function(u,q){let O=t[u?"scopedAlloc":"alloc"]((q.length+1)*t.ptr.size),V=0;return q.forEach((Z)=>{t.pokePtr(M(O,t.ptr.size*V++),t[u?"scopedAllocCString":"allocCString"](""+Z))}),t.pokePtr(M(O,t.ptr.size*V),0),O};t.scopedAllocMainArgv=(u)=>z(!0,u),t.allocMainArgv=(u)=>z(!1,u),t.cArgvToJs=(u,q)=>{let O=[];for(let V=0;V<u;++V){let Z=t.peekPtr(M(q,t.ptr.size*V));O.push(Z?t.cstrToJs(Z):null)}return O},t.scopedAllocCall=function(u){t.scopedAllocPush();try{return u()}finally{t.scopedAllocPop()}};let f=function(u,q,O){A(t,O);let V=q?"i64":a,Z=t[O](u*(q?8:_));if(t.poke(Z,0,V),u===1)return Z;let m=[Z];for(let y=1;y<u;++y)Z=M(Z,q?8:_),m[y]=Z,t.poke(Z,0,V);return m};t.allocPtr=(u=1,q=!0)=>f(u,q,"alloc"),t.scopedAllocPtr=(u=1,q=!0)=>f(u,q,"scopedAlloc"),t.xGet=function(u){return t.exports[u]||r("Cannot find exported symbol:",u)};let w=(u,q)=>r(u+"() requires",q,"argument(s).");t.xCall=function(u,...q){let O=u instanceof Function?u:t.xGet(u);if(!(O instanceof Function))r("Exported symbol",u,"is not a function.");if(O.length!==q.length)w(O===u?O.name:u,O.length);return arguments.length===2&&Array.isArray(arguments[1])?O.apply(null,arguments[1]):O.apply(null,q)},p.xWrap=Object.create(null),p.xWrap.convert=Object.create(null),p.xWrap.convert.arg=new Map,p.xWrap.convert.result=new Map;let N=p.xWrap.convert.arg,J=p.xWrap.convert.result,ie=S;N.set("i64",h).set("i32",(u)=>u|0).set("i16",(u)=>(u|0)&65535).set("i8",(u)=>(u|0)&255).set("f32",(u)=>Number(u).valueOf()).set("float",N.get("f32")).set("f64",N.get("f32")).set("double",N.get("f64")).set("int",N.get("i32")).set("null",(u)=>u).set(null,N.get("null")).set("**",ie).set("*",ie),J.set("*",ie).set("pointer",ie).set("number",(u)=>Number(u)).set("void",(u)=>{return}).set(void 0,J.get("void")).set("null",(u)=>u).set(null,J.get("null"));for(let u of["i8","i16","i32","i64","int","f32","float","f64","double"])N.set(u+"*",ie),J.set(u+"*",ie),J.set(u,N.get(u)||r("Maintenance required: missing arg converter for",u));let le=(u)=>typeof u==="string"?t.scopedAllocCString(u):S(u);N.set("string",le).set("utf8",le),J.set("string",(u)=>t.cstrToJs(u)).set("utf8",J.get("string")).set("string:dealloc",(u)=>{try{return u?t.cstrToJs(u):null}finally{t.dealloc(u)}}).set("utf8:dealloc",J.get("string:dealloc")).set("json",(u)=>JSON.parse(t.cstrToJs(u))).set("json:dealloc",(u)=>{try{return u?JSON.parse(t.cstrToJs(u)):null}finally{t.dealloc(u)}});let we=class{constructor(u){this.name=u.name||"unnamed adapter"}convertArg(u,q,O){r("AbstractArgAdapter must be subclassed.")}};N.FuncPtrAdapter=class u extends we{constructor(q){super(q);if(N.FuncPtrAdapter.warnOnUse)console.warn("xArg.FuncPtrAdapter is an internal-only API","and is not intended to be invoked from","client-level code. Invoked with:",q);if(this.name=q.name||"unnamed",this.signature=q.signature,q.contextKey instanceof Function){if(this.contextKey=q.contextKey,!q.bindScope)q.bindScope="context"}if(this.bindScope=q.bindScope||r("FuncPtrAdapter options requires a bindScope (explicit or implied)."),u.bindScopes.indexOf(q.bindScope)<0)r("Invalid options.bindScope ("+q.bindMod+") for FuncPtrAdapter. Expecting one of: ("+u.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=q.callProxy instanceof Function?q.callProxy:void 0}contextKey(q,O){return this}contextMap(q){let O=this.__cmap||(this.__cmap=new Map),V=O.get(q);if(V===void 0)O.set(q,V=[]);return V}convertArg(q,O,V){let Z=this.singleton;if(!Z&&this.isContext)Z=this.contextMap(this.contextKey(O,V));if(Z&&Z.length===2&&Z[0]===q)return Z[1];if(q instanceof Function){if(this.callProxy)q=this.callProxy(q);let m=U(q,this.signature,this.isTransient);if(u.debugFuncInstall)u.debugOut("FuncPtrAdapter installed",this,this.contextKey(O,V),"@"+m,q);if(Z){if(Z[1]){if(u.debugFuncInstall)u.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(O,V),"@"+Z[1],q);try{p.scopedAlloc.pushPtr(Z[1])}catch(y){}}Z[0]=arguments[0]||R,Z[1]=m}return m}else if(t.isPtr(q)||q===null||q===void 0){if(Z&&Z[1]&&Z[1]!==q){if(u.debugFuncInstall)u.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(O,V),"@"+Z[1],q);try{p.scopedAlloc.pushPtr(Z[1])}catch(m){}Z[0]=Z[1]=q||R}return q||R}else throw TypeError("Invalid FuncPtrAdapter argument type. Expecting a function pointer or a "+(this.name?this.name+" ":"")+"function matching signature "+this.signature+".")}},N.FuncPtrAdapter.warnOnUse=!1,N.FuncPtrAdapter.debugFuncInstall=!1,N.FuncPtrAdapter.debugOut=console.debug.bind(console),N.FuncPtrAdapter.bindScopes=["transient","context","singleton","permanent"];let me=(u)=>N.get(u)||r("Argument adapter not found:",u),K=(u)=>J.get(u)||r("Result adapter not found:",u);p.xWrap.convertArg=(u,...q)=>me(u)(...q),p.xWrap.convertArgNoCheck=(u,...q)=>N.get(u)(...q),p.xWrap.convertResult=(u,q)=>u===null?q:u?K(u)(q):void 0,p.xWrap.convertResultNoCheck=(u,q)=>u===null?q:u?J.get(u)(q):void 0,t.xWrap=function u(q,O,...V){if(arguments.length===3&&Array.isArray(arguments[2]))V=arguments[2];if(t.isPtr(q))q=t.functionEntry(q)||r("Function pointer not found in WASM function table.");let Z=q instanceof Function,m=Z?q:t.xGet(q);if(Z)q=m.name||"unnamed function";if(V.length!==m.length)w(q,m.length);if(m.length===0&&(O===null||O==="null"))return m;K(O);for(let C of V)if(C instanceof we)N.set(C,(...c)=>C.convertArg(...c));else me(C);let y=p.xWrap;if(m.length===0)return(...C)=>C.length?w(q,m.length):y.convertResult(O,m.call(null));return function(...C){if(C.length!==m.length)w(q,m.length);let c=t.scopedAllocPush();try{let d=0;if(u.debug)console.debug("xWrap() preparing: resultType ",O,"xf",m,"argTypes",V,"args",C);for(;d<C.length;++d)C[d]=y.convertArgNoCheck(V[d],C[d],C,d);if(u.debug)console.debug("xWrap() calling: resultType ",O,"xf",m,"argTypes",V,"args",C);return y.convertResultNoCheck(O,m.apply(null,C))}finally{t.scopedAllocPop(c)}}};let oe=function(u,q,O,V,Z,m){if(typeof O==="string"){if(q===1)return m.get(O);else if(q===2){if(!V)return m.delete(O),u;else if(!(V instanceof Function))r(Z,"requires a function argument.");return m.set(O,V),u}}r("Invalid arguments to",Z)};return t.xWrap.resultAdapter=function u(q,O){return oe(u,arguments.length,q,O,"resultAdapter()",J)},t.xWrap.argAdapter=function u(q,O){return oe(u,arguments.length,q,O,"argAdapter()",N)},t.xWrap.FuncPtrAdapter=N.FuncPtrAdapter,t.xCallWrapped=function(u,q,O,...V){if(Array.isArray(arguments[3]))V=arguments[3];return t.xWrap(u,q,O||[]).apply(null,V||[])},t.xWrap.testConvertArg=p.xWrap.convertArg,t.xWrap.testConvertResult=p.xWrap.convertResult,t},globalThis.WhWasmUtilInstaller.yawl=function(t){let r=()=>fetch(t.uri,{credentials:"same-origin"}),a=this,_=function(I){if(t.wasmUtilTarget){let S=(...M)=>{throw Error(M.join(" "))},R=t.wasmUtilTarget;if(R.module=I.module,R.instance=I.instance,!R.instance.exports.memory)R.memory=t?.imports?.env?.memory||S("Missing 'memory' object!");if(!R.alloc&&I.instance.exports.malloc){let M=I.instance.exports;R.alloc=function(p){return M.malloc(p)||S("Allocation of",p,"bytes failed.")},R.dealloc=function(p){p&&M.free(p)}}a(R)}if(I.config=t,t.onload)t.onload(I);return I};return WebAssembly.instantiateStreaming?()=>WebAssembly.instantiateStreaming(r(),t.imports||{}).then(_):()=>r().then((I)=>I.arrayBuffer()).then((I)=>WebAssembly.instantiate(I,t.imports||{})).then(_)}.bind(globalThis.WhWasmUtilInstaller),globalThis.Jaccwabyt=function i(t){let r=(...P)=>{throw Error(P.join(" "))};{let P=t.heap;if(P instanceof WebAssembly.Memory)P=function(){return new Uint8Array(this.buffer)}.bind(P);else if(!(P instanceof Function))r("config.heap must be WebAssembly.Memory instance or","a function which returns one.");t.heap=P}["alloc","dealloc"].forEach(function(P){t[P]instanceof Function||r("Config option '"+P+"' must be a function.")});let a=i,{heap:_,alloc:h,dealloc:I}=t,S=t.realloc||function(){r("This StructBinderFactory was configured without realloc()")},R=t.log||console.debug.bind(console),M=t.memberPrefix||"",p=t.memberSuffix||"",{BigInt:te,BigInt64Array:j}=globalThis,U=t.bigIntEnabled??!!j,E,b=t.pointerSize||t.ptrSize||(typeof(E=h(1))==="bigint"?8:4),F=t.pointerIR||t.ptrIR||(b===4?"i32":"i64");if(E)I(E),E=void 0;if(b!==4&&b!==8)r("Invalid pointer size:",b);if(F!=="i32"&&F!=="i64")r("Invalid pointer representation:",F);let x=U&&te?(P)=>te(P||0):(P)=>r("BigInt support is disabled in this build."),A=F=="i32"?Number:x,D=A(0),z=function(...P){let X=D;for(let ee=0;ee<P.length;++ee)X+=A(P[ee]);return X},f=function(...P){return z(this.pointer,...P)};if(!a.debugFlags)a.__makeDebugFlags=function(P=null){if(P&&P.__flags)P=P.__flags;let X=function ee(re){if(arguments.length===0)return ee.__flags;if(re<0)delete ee.__flags.getter,delete ee.__flags.setter,delete ee.__flags.alloc,delete ee.__flags.dealloc;else ee.__flags.getter=(1&re)!==0,ee.__flags.setter=(2&re)!==0,ee.__flags.alloc=(4&re)!==0,ee.__flags.dealloc=(8&re)!==0;return ee._flags};if(Object.defineProperty(X,"__flags",{iterable:!1,writable:!1,value:Object.create(P)}),!P)X(0);return X},a.debugFlags=a.__makeDebugFlags();let w=!0,N=(P)=>P[1]==="(",J=(P)=>P==="p"||P==="P"||P==="s",ie=(P)=>P==="P",le=(P)=>P?N(P)?"p":P[0]:void 0,we=function(P){switch(le(P)){case"c":case"C":return"i8";case"i":return"i32";case"p":case"P":case"s":return F;case"j":return"i64";case"f":return"float";case"d":return"double"}r("Unhandled signature IR:",P)},me=function(P){switch(le(P)){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:",P)},K=j?()=>!0:()=>r("BigInt64Array is not available."),oe=function(P){switch(le(P)){case"p":case"P":case"s":{switch(b){case 4:return"getInt32";case 8:return K()&&"getBigInt64"}break}case"i":return"getInt32";case"c":return"getInt8";case"C":return"getUint8";case"j":return K()&&"getBigInt64";case"f":return"getFloat32";case"d":return"getFloat64"}r("Unhandled DataView getter for signature:",P)},u=function(P){switch(le(P)){case"p":case"P":case"s":{switch(b){case 4:return"setInt32";case 8:return K()&&"setBigInt64"}break}case"i":return"setInt32";case"c":return"setInt8";case"C":return"setUint8";case"j":return K()&&"setBigInt64";case"f":return"setFloat32";case"d":return"setFloat64"}r("Unhandled DataView setter for signature:",P)},q=function(P){switch(le(P)){case"i":case"f":case"c":case"C":case"d":return Number;case"j":return x;case"p":case"P":case"s":switch(b){case 4:return Number;case 8:return x}break}r("Unhandled DataView set wrapper for signature:",P)},O=(P,X)=>P+"::"+X,V=function(P,X){return()=>r(O(P,X),"is read-only.")},Z=function P(X,ee=!0){let re=P.map.get(X);if(!re&&ee)P.map.set(X,re=P.create(X));return re};Z.map=new WeakMap,Z.create=(P)=>Object.assign(Object.create(null),{o:P,p:void 0,ownsPointer:!1,zod:!1,xb:0});let m=(P)=>Z.map.delete(P),y=(P)=>typeof P==="number"&&P===(P|0)&&P>=0,c=b===4?y:(P)=>typeof P==="bigint"&&P>=0||y(P),d=(P)=>c(P)&&P>0,L=function(P,X,ee){let re=Z(X,!1);if(!re||re.isDisposing)return;if(re.isDisposing=!0,!ee&&!(ee=re.p)){console.warn("Cannot(?) happen: __freeStruct() found no instanceInfo");return}if(Array.isArray(X.ondispose)){let fe;while(fe=X.ondispose.pop())try{if(fe instanceof Function)fe.call(X);else if(fe instanceof Je)fe.dispose();else if(c(fe))I(fe)}catch(Oe){console.warn("ondispose() for",P.structName,"@",ee,"threw. NOT propagating it.",Oe)}}else if(X.ondispose instanceof Function)try{X.ondispose()}catch(fe){console.warn("ondispose() for",P.structName,"@",ee,"threw. NOT propagating it.",fe)}if(m(X),delete X.ondispose,P.debugFlags.__flags.dealloc)R("debug.dealloc:",re.ownsPointer?"":"EXTERNAL",P.structName,"instance:",P.structInfo.sizeof,"bytes @"+ee);if(re.ownsPointer){if(re.zod||P.structInfo.zeroOnDispose)_().fill(0,Number(ee),Number(ee)+P.structInfo.sizeof+re.xb);I(ee)}},G=()=>({configurable:!1,writable:!1,iterable:!1}),B=(P)=>({...G(),value:P}),ae=function(X,ee,re){let fe,Oe=(xe)=>{d(xe)||r("Invalid pointer value",arguments[0],"for",X.structName,"constructor.")};if(arguments.length>=3)if(re&&typeof re==="object")fe=re,re=fe?.wrap;else Oe(re),fe={wrap:re};else fe={};let je=!re,Ve=0,Ge=!1;if(re)Oe(re),Ge=!!fe?.takeOwnership;else{let xe=fe?.extraBytes??0;if(xe<0||xe!==(xe|0))r("Invalid extraBytes value:",fe?.extraBytes);Ve=X.structInfo.sizeof+xe,re=h(Ve)||r("Allocation of",X.structName,"structure failed."),Ge=!0}try{if(fe?.debugFlags)ee.debugFlags(fe.debugFlags);if(X.debugFlags.__flags.alloc)R("debug.alloc:",je?"":"EXTERNAL",X.structName,"instance:",X.structInfo.sizeof,"bytes @"+re);if(je)_().fill(0,Number(re),Number(re)+Ve);let xe=Z(ee);if(xe.p=re,xe.ownsPointer=Ge,xe.xb=Ve?Ve-X.structInfo.sizeof:0,xe.zod=!!fe?.zeroOnDispose,fe?.ondispose&&fe.ondispose!==re)ee.addOnDispose(fe.ondispose)}catch(xe){throw L(X,ee,re),xe}},ce=function P(X){return P.rxSig1??=/^[ipPsjfdcC]$/,P.rxSig2??=/^[vipPsjfdcC]\([ipPsjfdcC]*\)$/,P.rxSig1.test(X)||P.rxSig2.test(X)},be=function(P){let X=this.get(P);if(!X)X=[Object.create(null),Object.create(null),Object.create(null)],this.set(P,X);return X}.bind(new WeakMap),qe=function(P,X,ee,re){let fe=be(P)[X];if(arguments.length===3)return fe[ee];if(re)return fe[ee]=re;return delete fe[ee]},Fe=(P)=>P,Pe=function(P,...X){return qe(this,0,P,...X)},Ee=function(P,X){ce(X)&&r(P,"(",X,") collides with a data type signature.")},Qe=function(P,...X){return Ee("Setter adaptor",P),qe(this,1,P,...X)},He=function(P,...X){return Ee("Struct adaptor",P),qe(this,2,P,...X)},T=function(P,X){let ee=typeof X==="string"?qe(P,2,X):X;if(typeof ee!=="object")r("Invalid struct mapping object. Arg =",X,JSON.stringify(ee));return ee},Q=B((P)=>M+P+p),H=function(P,X,ee=!0){let re=P.members[X];if(!re&&(M||p)){for(let fe of Object.values(P.members))if(fe.key===X){re=fe;break}if(!re&&ee)r(O(P.name||P.structName,X),"is not a mapped struct member.")}return re},se=function P(X,ee,re=!1){if(!P._)P._=(Oe)=>Oe.replace(/[^vipPsjrdcC]/g,"").replace(/[pPscC]/g,"i");let fe=H(X.structInfo,ee,!0);return re?P._(fe.signature):fe.signature},_e=B(function(){let P=[];for(let X of Object.keys(this.structInfo.members))P.push(this.memberKey(X));return P}),de=new TextDecoder("utf-8"),ue=new TextEncoder,pe=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,Le=function(P,X,ee){if(b===8)X=Number(X),ee=Number(ee);return de.decode(P.buffer instanceof pe?P.slice(X,ee):P.subarray(X,ee))},Ce=function(P,X,ee=!1){let re=H(P.structInfo,X,ee);return re&&re.signature.length===1&&re.signature[0]==="s"?re:!1},Ae=function(P){if(P.signature==="s")return;r("Invalid member type signature for C-string value:",JSON.stringify(P))},De=function(X,ee){let re=H(X.structInfo,ee,!0);Ae(re);let fe=X[re.key];if(!fe)return null;let Oe=fe,je=_();for(;je[Oe]!==0;++Oe);return fe===Oe?"":Le(je,fe,Oe)},Re=function(P,...X){if(P.ondispose){if(!Array.isArray(P.ondispose))P.ondispose=[P.ondispose]}else P.ondispose=[];P.ondispose.push(...X)},et=function(P){let X=ue.encode(P),ee=h(X.length+1);if(!ee)r("Allocation error while duplicating string:",P);let re=_();return re.set(X,Number(ee)),re[z(ee,X.length)]=0,ee},st=function(P,X,ee){let re=H(P.structInfo,X,!0);Ae(re);let fe=et(ee);return P[re.key]=fe,Re(P,fe),P},Je=function(X,ee){if(arguments[2]!==B)r("Do not call the StructType constructor","from client-level code.");Object.defineProperties(this,{structName:B(X),structInfo:B(ee)})};Je.prototype=Object.create(null,{dispose:B(function(){L(this.constructor,this)}),lookupMember:B(function(P,X=!0){return H(this.structInfo,P,X)}),memberToJsString:B(function(P){return De(this,P)}),memberIsString:B(function(P,X=!0){return Ce(this,P,X)}),memberKey:Q,memberKeys:_e,memberSignature:B(function(P,X=!1){return se(this,P,X)}),memoryDump:B(function(){let P=this.pointer;return P?new Uint8Array(_().slice(Number(P),Number(P)+this.structInfo.sizeof)):null}),extraBytes:{configurable:!1,enumerable:!1,get:function(){return Z(this,!1)?.xb??0}},zeroOnDispose:{configurable:!1,enumerable:!1,get:function(){return Z(this,!1)?.zod??!!this.structInfo.zeroOnDispose}},pointer:{configurable:!1,enumerable:!1,get:function(){return Z(this,!1)?.p},set:()=>r("Cannot assign the 'pointer' property of a struct.")},setMemberCString:B(function(P,X){return st(this,P,X)})}),Object.assign(Je.prototype,{addOnDispose:function(...P){return Re(this,...P),this}}),Object.defineProperties(Je,{allocCString:B(et),isA:B((P)=>P instanceof Je),hasExternalPointer:B((P)=>{let X=Z(P,!1);return!!(X?.p&&!X?.ownsPointer)}),memberKey:Q});let bt=function(P){return P.get||(P.adaptGet?$e.adaptGet(P.adaptGet):void 0)},yt=function(P){return P.set||(P.adaptSet?$e.adaptSet(P.adaptSet):void 0)},_t=function P(X,ee,re){let fe=P.innerStructs??=new Map,Oe=X.memberKey(ee);if(re.signature!==void 0)r("'signature' cannot be used on an embedded struct (",X.structName,".",Oe,").");if(yt(re))r("'set' and 'adaptSet' are not permitted for nested struct members.");re.structName??=X.structName+"::"+ee,re.key=Oe,re.name=ee,re.constructor=this.call(this,re.structName,re);let je=bt(re),Ve=Object.assign(Object.create(null),{configurable:!1,enumerable:!1,set:V(X.structName,Oe),get:function(){let Ge=this.debugFlags.__flags,xe=this.pointer,We=xe+"."+Oe,he=fe.get(We);if(Ge.getter)R("debug.getter: k =",We);if(!he)he=new re.constructor(z(xe,re.offset)),fe.set(We,he),this.addOnDispose(()=>he.dispose()),he.addOnDispose(()=>fe.delete(We));if(je)he=je.apply(this,[he,Oe]);if(Ge.getter)R("debug.getter: result =",he);return he}});Object.defineProperty(X.prototype,Oe,Ve)},jt=function P(X,ee,re){if(re=T(this,re),re.members)return _t.call(this,X,ee,re);if(!P.cache){P.cache={getters:{},setters:{},sw:{}};let We=["i","c","C","p","P","s","f","d","v()"];if(U)We.push("j");We.forEach(function(he){P.cache.getters[he]=oe(he),P.cache.setters[he]=u(he),P.cache.sw[he]=q(he)}),P.sigCheck=function(he,Ne,xt,wn){if(Object.prototype.hasOwnProperty.call(he,xt))r(he.structName,"already has a property named",xt+".");ce(wn)||r("Malformed signature for",O(he.structName,Ne)+":",wn)}}let fe=X.memberKey(ee);P.sigCheck(X.prototype,ee,fe,re.signature),re.key=fe,re.name=ee;let Oe=le(re.signature),je=O(X.structName,fe),Ve=X.debugFlags.__flags,Ge=bt(re),xe=Object.create(null);if(xe.configurable=!1,xe.enumerable=!1,xe.get=function(){if(Ve.getter)R("debug.getter:",P.cache.getters[Oe],"for",we(Oe),je,"@",this.pointer,"+",re.offset,"sz",re.sizeof);let We=new DataView(_().buffer,Number(this.pointer)+re.offset,re.sizeof)[P.cache.getters[Oe]](0,w);if(Ge)We=Ge.apply(this,[fe,We]);if(Ve.getter)R("debug.getter:",je,"result =",We);return We},re.readOnly)xe.set=V(X.prototype.structName,fe);else{let We=yt(re);xe.set=function(he){if(Ve.setter)R("debug.setter:",P.cache.setters[Oe],"for",we(Oe),je,"@",this.pointer,"+",re.offset,"sz",re.sizeof,he);if(!this.pointer)r("Cannot set native property on a disposed",this.structName,"instance.");if(We)he=We.apply(this,[fe,he]);if(he===null||he===void 0)he=D;else if(J(re.signature)&&!c(he))if(ie(re.signature)&&he instanceof Je){if(he=he.pointer||D,Ve.setter)R("debug.setter:",je,"resolved to",he)}else r("Invalid value for pointer-type",je+".");new DataView(_().buffer,Number(this.pointer)+re.offset,re.sizeof)[P.cache.setters[Oe]](0,P.cache.sw[Oe](he),w)}}Object.defineProperty(X.prototype,fe,xe)},Sn=function P(X,ee,re=Object.create(null)){let fe=function he(Ne){if(!(this instanceof he))r("The",X,"constructor may only be called via 'new'.");ae(he,this,...arguments)},Oe=this,je=(he)=>typeof he==="string"&&ce(he)?{signature:he}:T(Oe,he);if(arguments.length===1)ee=je(X),X=ee.structName||ee.name;else if(arguments.length===2)ee=je(ee),ee.name??=X;else ee=je(ee);if(X??=ee.structName,X??=re.structName,!X)r("One of 'name' or 'structName' are required.");if(ee.adapt)Object.keys(ee.adapt.struct||{}).forEach((he)=>{He.call(P,he,ee.adapt.struct[he])}),Object.keys(ee.adapt.set||{}).forEach((he)=>{Qe.call(P,he,ee.adapt.set[he])}),Object.keys(ee.adapt.get||{}).forEach((he)=>{Pe.call(P,he,ee.adapt.get[he])});if(!ee.members&&!ee.sizeof)ee.sizeof=me(ee.signature);let Ve=B(a.__makeDebugFlags($e.debugFlags));Object.defineProperties(fe,{debugFlags:Ve,isA:B((he)=>he instanceof fe),memberKey:Q,memberKeys:_e,structInfo:B(ee),structName:B(X),ptrAdd:B(z)}),fe.prototype=new Je(X,ee,B),Object.defineProperties(fe.prototype,{debugFlags:Ve,constructor:B(fe),ptrAdd:B(f)});let Ge=!1,xe=0,We=!!ee.autoCalcSizeOffset;if(!We){if(!ee.sizeof)r(X,"description is missing its sizeof property.");ee.offset??=0}else ee.offset??=0;if(Object.keys(ee.members||{}).forEach((he)=>{let Ne=je(ee.members[he]);if(!Ne.members&&!Ne.sizeof){if(Ne.sizeof=me(Ne.signature),!Ne.sizeof)r(O(X,he),"is missing a sizeof property.",Ne)}if(Ne.offset===void 0)if(We)Ne.offset=xe;else r(O(X,he),"is missing its offset.",JSON.stringify(Ne));if(ee.members[he]=Ne,!Ge||Ge.offset<Ne.offset)Ge=Ne;let xt=!!Ne.autoCalc;if(We)Ne.autoCalcSizeOffset=!0;if(jt.call(Oe,fe,he,Ne),xt)Ne.autoCalcSizeOffset=!0;else delete Ne.autoCalcSizeOffset;xe+=Ne.sizeof}),!Ge)r("No member property descriptions found.");if(!ee.sizeof)ee.sizeof=xe;if(ee.sizeof===1)ee.signature==="c"||ee.signature==="C"||r("Unexpected sizeof==1 member",O(X,k),"with signature",ee.signature);else{if(ee.sizeof%4!==0)console.warn("Invalid struct member description",ee),r(X,"sizeof is not aligned. sizeof="+ee.sizeof);if(ee.offset%4!==0)console.warn("Invalid struct member description",ee),r(X,"offset is not aligned. offset="+ee.offset)}if(ee.sizeof<xe)console.warn("Suspect struct description:",ee,"offset =",xe),r("Mismatch in the calculated vs. the provided sizeof/offset info.","Expected sizeof",xe,"but got",ee.sizeof,"for",ee);return delete ee.autoCalcSizeOffset,fe},$e=function P(X,ee){return arguments.length==1?Sn.call(P,X):Sn.call(P,X,ee)};if($e.StructType=Je,$e.config=t,$e.allocCString=et,$e.adaptGet=Pe,$e.adaptSet=Qe,$e.adaptStruct=He,$e.ptrAdd=z,!$e.debugFlags)$e.debugFlags=a.__makeDebugFlags(a.debugFlags);return $e},globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let t=(...E)=>{throw Error(E.join(" "))},{capi:r,wasm:a,util:_}=i;globalThis.WhWasmUtilInstaller(a),delete globalThis.WhWasmUtilInstaller;let h={core:[["sqlite3_aggregate_context","void*","sqlite3_context*","int"],["sqlite3_backup_init","sqlite3_backup*","sqlite3*","string","sqlite3*","string"],["sqlite3_backup_step","int","sqlite3_backup*","int"],["sqlite3_backup_finish","int","sqlite3_backup*"],["sqlite3_backup_remaining","int","sqlite3_backup*"],["sqlite3_backup_pagecount","int","sqlite3_backup*"],["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 a.xWrap.FuncPtrAdapter({signature:"i(pi)",contextKey:(E,b)=>E[0]}),"*"]],["sqlite3_busy_timeout","int","sqlite3*","int"],["sqlite3_changes","int","sqlite3*"],["sqlite3_clear_bindings","int","sqlite3_stmt*"],["sqlite3_collation_needed","int","sqlite3*","*","*"],["sqlite3_column_blob","*","sqlite3_stmt*","int"],["sqlite3_column_bytes","int","sqlite3_stmt*","int"],["sqlite3_column_count","int","sqlite3_stmt*"],["sqlite3_column_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 a.xWrap.FuncPtrAdapter({name:"sqlite3_commit_hook",signature:"i(p)",contextKey:(E)=>E[0]}),"*"]],["sqlite3_compileoption_get","string","int"],["sqlite3_compileoption_used","int","string"],["sqlite3_complete","int","string:flexible"],["sqlite3_context_db_handle","sqlite3*","sqlite3_context*"],["sqlite3_data_count","int","sqlite3_stmt*"],["sqlite3_db_filename","string","sqlite3*","string"],["sqlite3_db_handle","sqlite3*","sqlite3_stmt*"],["sqlite3_db_name","string","sqlite3*","int"],["sqlite3_db_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 a.xWrap.FuncPtrAdapter({signature:"i(pipp)",bindScope:"transient",callProxy:(E)=>{let b;return(F,x,A,D)=>{try{let z=a.cArgvToJs(x,A);if(!b)b=a.cArgvToJs(x,D);return E(z,b)|0}catch(z){return z.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 a.xWrap.FuncPtrAdapter({name:"sqlite3_rollback_hook",signature:"v(p)",contextKey:(E)=>E[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 a.xWrap.FuncPtrAdapter({name:"sqlite3_trace_v2::callback",signature:"i(ippp)",contextKey:(E,b)=>E[0]}),"*"]],["sqlite3_txn_state","int",["sqlite3*","string"]],["sqlite3_uri_boolean","int","sqlite3_filename","string","int"],["sqlite3_uri_key","string","sqlite3_filename","int"],["sqlite3_uri_parameter","string","sqlite3_filename","string"],["sqlite3_user_data","void*","sqlite3_context*"],["sqlite3_value_blob","*","sqlite3_value*"],["sqlite3_value_bytes","int","sqlite3_value*"],["sqlite3_value_double","f64","sqlite3_value*"],["sqlite3_value_dup","sqlite3_value*","sqlite3_value*"],["sqlite3_value_free",void 0,"sqlite3_value*"],["sqlite3_value_frombind","int","sqlite3_value*"],["sqlite3_value_int","int","sqlite3_value*"],["sqlite3_value_nochange","int","sqlite3_value*"],["sqlite3_value_numeric_type","int","sqlite3_value*"],["sqlite3_value_pointer","*","sqlite3_value*","string:static"],["sqlite3_value_subtype","int","sqlite3_value*"],["sqlite3_value_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 a.xWrap.FuncPtrAdapter({name:"sqlite3_update_hook::callback",signature:"v(pippj)",contextKey:(E)=>E[0],callProxy:(E)=>(b,F,x,A,D)=>{E(b,F,a.cstrToJs(x),a.cstrToJs(A),D)}}),"*"]],["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(a.exports.sqlite3_progress_handler)h.core.push(["sqlite3_progress_handler",void 0,["sqlite3*","int",new a.xWrap.FuncPtrAdapter({name:"xProgressHandler",signature:"i(p)",bindScope:"context",contextKey:(E,b)=>E[0]}),"*"]]);if(a.exports.sqlite3_stmt_explain)h.core.push(["sqlite3_stmt_explain","int","sqlite3_stmt*","int"],["sqlite3_stmt_isexplain","int","sqlite3_stmt*"]);if(a.exports.sqlite3_set_authorizer)h.core.push(["sqlite3_set_authorizer","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"sqlite3_set_authorizer::xAuth",signature:"i(pissss)",contextKey:(E,b)=>E[0],callProxy:(E)=>(b,F,x,A,D,z)=>{try{return x=x&&a.cstrToJs(x),A=A&&a.cstrToJs(A),D=D&&a.cstrToJs(D),z=z&&a.cstrToJs(z),E(b,F,x,A,D,z)|0}catch(f){return f.resultCode||r.SQLITE_ERROR}}}),"*"]]);if(a.exports.sqlite3_column_origin_name)h.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"]);if(a.exports.sqlite3_key_v2)h.core.push(["sqlite3_key","int","sqlite3*","string","int"],["sqlite3_key_v2","int","sqlite3*","string","*","int"],["sqlite3_rekey","int","sqlite3*","string","int"],["sqlite3_rekey_v2","int","sqlite3*","string","*","int"],["sqlite3_activate_see",void 0,"string"],["sqlite3mc_cipher_count","int"],["sqlite3mc_cipher_index","int","string"],["sqlite3mc_cipher_name","string","int"],["sqlite3mc_cipher_name_copy","int","int","string","int"],["sqlite3mc_config","int","sqlite3*","string","int"],["sqlite3mc_config_cipher","int","sqlite3*","string","string","int"],["sqlite3mc_codec_data","string","sqlite3*","string","string"],["sqlite3mc_version","string"],["sqlite3mc_vfs_create","int","string","int"],["sqlite3mc_vfs_destroy",void 0,"string"],["sqlite3mc_vfs_shutdown",void 0]);if(a.bigIntEnabled&&!!a.exports.sqlite3_declare_vtab)h.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","**"]);if(a.bigIntEnabled&&!!a.exports.sqlite3_preupdate_hook)h.int64.push(["sqlite3_preupdate_blobwrite","int","sqlite3*"],["sqlite3_preupdate_count","int","sqlite3*"],["sqlite3_preupdate_depth","int","sqlite3*"],["sqlite3_preupdate_hook","*",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"sqlite3_preupdate_hook",signature:"v(ppippjj)",contextKey:(E)=>E[0],callProxy:(E)=>(b,F,x,A,D,z,f)=>{E(b,F,x,a.cstrToJs(A),a.cstrToJs(D),z,f)}}),"*"]],["sqlite3_preupdate_new","int",["sqlite3*","int","**"]],["sqlite3_preupdate_old","int",["sqlite3*","int","**"]]);if(a.bigIntEnabled&&!!a.exports.sqlite3changegroup_add&&!!a.exports.sqlite3session_create&&!!a.exports.sqlite3_preupdate_hook){let E={signature:"i(ps)",callProxy:(b)=>(F,x)=>{try{return b(F,a.cstrToJs(x))|0}catch(A){return A.resultCode||r.SQLITE_ERROR}}};h.int64.push(["sqlite3changegroup_add","int",["sqlite3_changegroup*","int","void*"]],["sqlite3changegroup_add_strm","int",["sqlite3_changegroup*",new a.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 a.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply","int",["sqlite3*","int","void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_strm","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_v2","int",["sqlite3*","int","void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v2_strm","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v3","int",["sqlite3*","int","void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",signature:"i(pp)",bindScope:"transient"}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v3_strm","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",signature:"i(pp)",bindScope:"transient"}),new a.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 a.xWrap.FuncPtrAdapter({name:"xInputA",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xInputB",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.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 a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.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 a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3changeset_start_v2","int",["**","int","*","int"]],["sqlite3changeset_start_v2_strm","int",["**",new a.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 a.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 a.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3session_table_filter",void 0,["sqlite3_session*",new a.xWrap.FuncPtrAdapter({name:"xFilter",...E,contextKey:(b,F)=>b[0]}),"*"]])}i.StructBinder=globalThis.Jaccwabyt({heap:a.heap8u,alloc:a.alloc,dealloc:a.dealloc,bigIntEnabled:a.bigIntEnabled,pointerIR:a.ptr.ir,memberPrefix:"$"}),delete globalThis.Jaccwabyt;{let E=a.xWrap.argAdapter("string");a.xWrap.argAdapter("string:flexible",(A)=>E(_.flexibleString(A))),a.xWrap.argAdapter("string:static",function(A){if(a.isPtr(A))return A;return A=""+A,this[A]||(this[A]=a.allocCString(A))}.bind(Object.create(null)));let b=a.xWrap.argAdapter("*"),F=function(){};if(a.xWrap.argAdapter("sqlite3_filename",b)("sqlite3_backup*",b)("sqlite3_context*",b)("sqlite3_value*",b)("void*",b)("sqlite3_changegroup*",b)("sqlite3_changeset_iter*",b)("sqlite3_session*",b)("sqlite3_stmt*",(A)=>b(A instanceof(i?.oo1?.Stmt||F)?A.pointer:A))("sqlite3*",(A)=>b(A instanceof(i?.oo1?.DB||F)?A.pointer:A))("sqlite3_vfs*",(A)=>{if(typeof A==="string")return r.sqlite3_vfs_find(A)||i.SQLite3Error.toss(r.SQLITE_NOTFOUND,"Unknown sqlite3_vfs name:",A);return b(A instanceof(r.sqlite3_vfs||F)?A.pointer:A)}),a.exports.sqlite3_declare_vtab)a.xWrap.argAdapter("sqlite3_index_info*",(A)=>b(A instanceof(r.sqlite3_index_info||F)?A.pointer:A))("sqlite3_module*",(A)=>b(A instanceof(r.sqlite3_module||F)?A.pointer:A));let x=a.xWrap.resultAdapter("*");a.xWrap.resultAdapter("sqlite3*",x)("sqlite3_backup*",x)("sqlite3_context*",x)("sqlite3_stmt*",x)("sqlite3_value*",x)("sqlite3_vfs*",x)("void*",x);for(let A of h.core)r[A[0]]=a.xWrap.apply(null,A);for(let A of h.wasmInternal)_[A[0]]=a.xWrap.apply(null,A);for(let A of h.int64)r[A[0]]=a.bigIntEnabled?a.xWrap.apply(null,A):()=>t(A[0]+"() is unavailable due to lack","of BigInt support in this build.");delete h.core,delete h.int64,delete h.wasmInternal,_.sqlite3__wasm_db_error=function(A,D,z){if(!A)return r.SQLITE_MISUSE;if(D instanceof i.WasmAllocError)D=r.SQLITE_NOMEM,z=0;else if(D instanceof Error)z=z||""+D,D=D.resultCode||r.SQLITE_ERROR;return r.sqlite3_set_errmsg(A,D,z)||D}}{let E=a.xCall("sqlite3__wasm_enum_json");if(!E)t("Maintenance required: increase sqlite3__wasm_enum_json()'s","static buffer size!");a.ctype=JSON.parse(a.cstrToJs(E));let b=["access","authorizer","blobFinalizers","changeset","config","dataTypes","dbConfig","dbStatus","encodings","fcntl","flock","ioCap","limits","openFlags","prepareFlags","resultCodes","sqlite3Status","stmtStatus","syncFlags","trace","txnState","udfFlags","version"];if(a.bigIntEnabled)b.push("serialize","session","vtab");for(let A of b)for(let D of Object.entries(a.ctype[A]))r[D[0]]=D[1];if(!a.functionEntry(r.SQLITE_WASM_DEALLOC))t("Internal error: cannot resolve exported function","entry SQLITE_WASM_DEALLOC (=="+r.SQLITE_WASM_DEALLOC+").");let F=Object.create(null);for(let A of Object.entries(a.ctype.resultCodes))F[A[1]]=A[0];r.sqlite3_js_rc_str=(A)=>F[A];let x=Object.assign(Object.create(null),{WasmTestStruct:!0,sqlite3_index_info:!a.bigIntEnabled,sqlite3_index_constraint:!a.bigIntEnabled,sqlite3_index_orderby:!a.bigIntEnabled,sqlite3_index_constraint_usage:!a.bigIntEnabled});for(let A of a.ctype.structs)if(!x[A.name])r[A.name]=i.StructBinder(A);if(r.sqlite3_index_info){for(let 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=a.xWrap("sqlite3__wasm_vtab_config","int",["sqlite3*","int","int"])}}let I=(E,b,F)=>_.sqlite3__wasm_db_error(E,r.SQLITE_MISUSE,b+"() requires "+F+" argument"+(F===1?"":"s")+"."),S=(E)=>_.sqlite3__wasm_db_error(E,r.SQLITE_FORMAT,"SQLITE_UTF8 is the only supported encoding."),R=(E)=>a.xWrap.argAdapter("sqlite3*")(E),M=(E)=>a.isPtr(E)?a.cstrToJs(E):E,p=function(E,b){E=R(E);let F=this.dbMap.get(E);if(!b)return this.dbMap.delete(E),F;else if(!F&&b>0)this.dbMap.set(E,F=Object.create(null));return F}.bind(Object.assign(Object.create(null),{dbMap:new Map}));if(p.addCollation=function(E,b){let F=p(E,1);if(!F.collation)F.collation=new Set;F.collation.add(M(b).toLowerCase())},p._addUDF=function(E,b,F,x){b=M(b).toLowerCase();let A=x.get(b);if(!A)x.set(b,A=new Set);A.add(F<0?-1:F)},p.addFunction=function(E,b,F){let x=p(E,1);if(!x.udf)x.udf=new Map;this._addUDF(E,b,F,x.udf)},a.exports.sqlite3_create_window_function)p.addWindowFunc=function(E,b,F){let x=p(E,1);if(!x.wudf)x.wudf=new Map;this._addUDF(E,b,F,x.wudf)};p.cleanup=function(E){E=R(E);for(let x 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]]){let[A,D]=x;if(!a.exports[A])continue;let f=[E];f.length=D;try{r[A](...f)}catch(w){i.config.warn("close-time call of",A+"(",f,") threw:",w)}}let b=p(E,0);if(!b)return;if(b.collation){for(let x of b.collation)try{r.sqlite3_create_collation_v2(E,x,r.SQLITE_UTF8,0,0,0)}catch(A){}delete b.collation}let F;for(F=0;F<2;++F){let x=F?b.wudf:b.udf;if(!x)continue;let A=F?r.sqlite3_create_window_function:r.sqlite3_create_function_v2;for(let D of x){let z=D[0],f=D[1],w=[E,z,0,r.SQLITE_UTF8,0,0,0,0,0];if(F)w.push(0);for(let N of f)try{w[2]=N,A.apply(null,w)}catch(J){}f.clear()}x.clear()}delete b.udf,delete b.wudf};{let E=a.xWrap("sqlite3_close_v2","int","sqlite3*");r.sqlite3_close_v2=function(b){if(arguments.length!==1)return I(b,"sqlite3_close_v2",1);if(b)try{p.cleanup(b)}catch(F){}return E(b)}}if(r.sqlite3session_create){let E=a.xWrap("sqlite3session_delete",void 0,["sqlite3_session*"]);r.sqlite3session_delete=function(b){if(arguments.length!==1)return I(pDb,"sqlite3session_delete",1);else if(b)r.sqlite3session_table_filter(b,0,0);E(b)}}{let E=(F,x)=>"argv["+x+"]:"+F[0]+":"+a.cstrToJs(F[1]).toLowerCase(),b=a.xWrap("sqlite3_create_collation_v2","int",["sqlite3*","string","int","*",new a.xWrap.FuncPtrAdapter({name:"xCompare",signature:"i(pipip)",contextKey:E}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",signature:"v(p)",contextKey:E})]);r.sqlite3_create_collation_v2=function(F,x,A,D,z,f){if(arguments.length!==6)return I(F,"sqlite3_create_collation_v2",6);else if((A&15)===0)A|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(A&15))return S(F);try{let w=b(F,x,A,D,z,f);if(w===0&&z instanceof Function)p.addCollation(F,x);return w}catch(w){return _.sqlite3__wasm_db_error(F,w)}},r.sqlite3_create_collation=(F,x,A,D,z)=>arguments.length===5?r.sqlite3_create_collation_v2(F,x,A,D,z,0):I(F,"sqlite3_create_collation",5)}{let E=function(A,D){return A[0]+":"+(A[2]<0?-1:A[2])+":"+D+":"+a.cstrToJs(A[1]).toLowerCase()},b=Object.assign(Object.create(null),{xInverseAndStep:{signature:"v(pip)",contextKey:E,callProxy:(A)=>(D,z,f)=>{try{A(D,...r.sqlite3_values_to_js(z,f))}catch(w){r.sqlite3_result_error_js(D,w)}}},xFinalAndValue:{signature:"v(p)",contextKey:E,callProxy:(A)=>(D)=>{try{r.sqlite3_result_js(D,A(D))}catch(z){r.sqlite3_result_error_js(D,z)}}},xFunc:{signature:"v(pip)",contextKey:E,callProxy:(A)=>(D,z,f)=>{try{r.sqlite3_result_js(D,A(D,...r.sqlite3_values_to_js(z,f)))}catch(w){r.sqlite3_result_error_js(D,w)}}},xDestroy:{signature:"v(p)",contextKey:E,callProxy:(A)=>(D)=>{try{A(D)}catch(z){console.error("UDF xDestroy method threw:",z)}}}}),F=a.xWrap("sqlite3_create_function_v2","int",["sqlite3*","string","int","int","*",new a.xWrap.FuncPtrAdapter({name:"xFunc",...b.xFunc}),new a.xWrap.FuncPtrAdapter({name:"xStep",...b.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xFinal",...b.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",...b.xDestroy})]),x=a.exports.sqlite3_create_window_function?a.xWrap("sqlite3_create_window_function","int",["sqlite3*","string","int","int","*",new a.xWrap.FuncPtrAdapter({name:"xStep",...b.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xFinal",...b.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xValue",...b.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xInverse",...b.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",...b.xDestroy})]):void 0;if(r.sqlite3_create_function_v2=function A(D,z,f,w,N,J,ie,le,we){if(A.length!==arguments.length)return I(D,"sqlite3_create_function_v2",A.length);else if((w&15)===0)w|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(w&15))return S(D);try{let me=F(D,z,f,w,N,J,ie,le,we);if(me===0&&(J instanceof Function||ie instanceof Function||le instanceof Function||we instanceof Function))p.addFunction(D,z,f);return me}catch(me){return console.error("sqlite3_create_function_v2() setup threw:",me),_.sqlite3__wasm_db_error(D,me,"Creation of UDF threw: "+me)}},r.sqlite3_create_function=function A(D,z,f,w,N,J,ie,le){return A.length===arguments.length?r.sqlite3_create_function_v2(D,z,f,w,N,J,ie,le,0):I(D,"sqlite3_create_function",A.length)},x)r.sqlite3_create_window_function=function A(D,z,f,w,N,J,ie,le,we,me){if(A.length!==arguments.length)return I(D,"sqlite3_create_window_function",A.length);else if((w&15)===0)w|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(w&15))return S(D);try{let K=x(D,z,f,w,N,J,ie,le,we,me);if(K===0&&(J instanceof Function||ie instanceof Function||le instanceof Function||we instanceof Function||me instanceof Function))p.addWindowFunc(D,z,f);return K}catch(K){return console.error("sqlite3_create_window_function() setup threw:",K),_.sqlite3__wasm_db_error(D,K,"Creation of UDF threw: "+K)}};else delete r.sqlite3_create_window_function;if(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;if(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;if(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}{let E=(F,x)=>{if(typeof F==="string")x=-1;else if(_.isSQLableTypedArray(F))x=F.byteLength,F=a.typedArrayToString(F instanceof ArrayBuffer?new Uint8Array(F):F);else if(Array.isArray(F))F=F.join(""),x=-1;return[F,x]},b={basic:a.xWrap("sqlite3_prepare_v3","int",["sqlite3*","string","int","int","**","**"]),full:a.xWrap("sqlite3_prepare_v3","int",["sqlite3*","*","int","int","**","**"])};r.sqlite3_prepare_v3=function F(x,A,D,z,f,w){if(F.length!==arguments.length)return I(x,"sqlite3_prepare_v3",F.length);let[N,J]=E(A,Number(D));switch(typeof N){case"string":return b.basic(x,N,J,z,f,null);case typeof a.ptr.null:return b.full(x,a.ptr.coerce(N),J,z,f,w);default:return _.sqlite3__wasm_db_error(x,r.SQLITE_MISUSE,"Invalid SQL argument type for sqlite3_prepare_v2/v3(). typeof="+typeof N)}},r.sqlite3_prepare_v2=function F(x,A,D,z,f){return F.length===arguments.length?r.sqlite3_prepare_v3(x,A,D,0,z,f):I(x,"sqlite3_prepare_v2",F.length)}}{let E=a.xWrap("sqlite3_bind_text","int",["sqlite3_stmt*","int","string","int","*"]),b=a.xWrap("sqlite3_bind_blob","int",["sqlite3_stmt*","int","*","int","*"]);r.sqlite3_bind_text=function F(x,A,D,z,f){if(F.length!==arguments.length)return I(r.sqlite3_db_handle(x),"sqlite3_bind_text",F.length);else if(a.isPtr(D)||D===null)return E(x,A,D,z,f);else if(D instanceof ArrayBuffer)D=new Uint8Array(D);else if(Array.isArray(pMem))D=pMem.join("");let w,N;try{if(_.isSQLableTypedArray(D))w=a.allocFromTypedArray(D),N=D.byteLength;else if(typeof D==="string")[w,N]=a.allocCString(D);else return _.sqlite3__wasm_db_error(r.sqlite3_db_handle(x),r.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_text().");return E(x,A,w,N,r.SQLITE_WASM_DEALLOC)}catch(J){return a.dealloc(w),_.sqlite3__wasm_db_error(r.sqlite3_db_handle(x),J)}},r.sqlite3_bind_blob=function F(x,A,D,z,f){if(F.length!==arguments.length)return I(r.sqlite3_db_handle(x),"sqlite3_bind_blob",F.length);else if(a.isPtr(D)||D===null)return b(x,A,D,z,f);else if(D instanceof ArrayBuffer)D=new Uint8Array(D);else if(Array.isArray(D))D=D.join("");let w,N;try{if(_.isBindableTypedArray(D))w=a.allocFromTypedArray(D),N=z>=0?z:D.byteLength;else if(typeof D==="string")[w,N]=a.allocCString(D);else return _.sqlite3__wasm_db_error(r.sqlite3_db_handle(x),r.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_blob().");return b(x,A,w,N,r.SQLITE_WASM_DEALLOC)}catch(J){return a.dealloc(w),_.sqlite3__wasm_db_error(r.sqlite3_db_handle(x),J)}}}if(!r.sqlite3_column_text){let E=a.xWrap.argAdapter("sqlite3_stmt*"),b=a.xWrap.argAdapter("int"),F=a.xWrap.argAdapter("sqlite3_value*"),x=(A,D)=>a.typedArrayToString(a.heap8u(),Number(A),Number(A)+D);r.sqlite3_column_text=function(A,D){let z=E(A),f=b(D),w=a.exports.sqlite3_column_text(z,f);return w?x(w,a.exports.sqlite3_column_bytes(z,f)):null},r.sqlite3_value_text=function(A){let D=F(A),z=a.exports.sqlite3_value_text(D);return z?x(z,a.exports.sqlite3_value_bytes(D)):null}}r.sqlite3_config=function(E,...b){if(arguments.length<2)return r.SQLITE_MISUSE;switch(E){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 a.exports.sqlite3__wasm_config_i(E,b[0]);case r.SQLITE_CONFIG_LOOKASIDE:return a.exports.sqlite3__wasm_config_ii(E,b[0],b[1]);case r.SQLITE_CONFIG_MEMDB_MAXSIZE:return a.exports.sqlite3__wasm_config_j(E,b[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}};{let E=new Set;r.sqlite3_auto_extension=function(b){if(b instanceof Function)b=a.installFunction("i(ppp)",b);else if(arguments.length!==1||!a.isPtr(b))return r.SQLITE_MISUSE;let F=a.exports.sqlite3_auto_extension(b);if(b!==arguments[0])if(F===0)E.add(b);else a.uninstallFunction(b);return F},r.sqlite3_cancel_auto_extension=function(b){if(!b||arguments.length!==1||!a.isPtr(b))return 0;return a.exports.sqlite3_cancel_auto_extension(b)},r.sqlite3_reset_auto_extension=function(){a.exports.sqlite3_reset_auto_extension();for(let b of E)a.uninstallFunction(b);E.clear()}}a.xWrap.FuncPtrAdapter.warnOnUse=!0;let te=i.StructBinder,j=function E(b,F,x,A=E.installMethodArgcCheck){if(!(b instanceof te.StructType))t("Usage error: target object is-not-a StructType.");else if(!(x instanceof Function)&&!a.isPtr(x))t("Usage error: expecting a Function or WASM pointer to one.");if(arguments.length===1)return(w,N)=>E(b,w,N,A);if(!E.argcProxy)E.argcProxy=function(w,N,J,ie){return function(...le){if(J.length!==arguments.length)t("Argument mismatch for",w.structInfo.name+"::"+N+": Native signature is:",ie);return J.apply(this,le)}},E.removeFuncList=function(){if(this.ondispose.__removeFuncList)this.ondispose.__removeFuncList.forEach((w,N)=>{if(a.isPtr(w))try{a.uninstallFunction(w)}catch(J){}}),delete this.ondispose.__removeFuncList};let D=b.memberSignature(F);if(D.length<2)t("Member",F,"does not have a function pointer signature:",D);let z=b.memberKey(F),f=A&&!a.isPtr(x)?E.argcProxy(b,z,x,D):x;if(a.isPtr(f)){if(f&&!a.functionEntry(f))t("Pointer",f,"is not a WASM function table entry.");b[z]=f}else{let w=a.installFunction(f,D);if(b[z]=w,!b.ondispose||!b.ondispose.__removeFuncList)b.addOnDispose("ondispose.__removeFuncList handler",E.removeFuncList),b.ondispose.__removeFuncList=[];b.ondispose.__removeFuncList.push(z,w)}return(w,N)=>E(b,w,N,A)};j.installMethodArgcCheck=!1;let U=function(E,b,F=j.installMethodArgcCheck){let x=new Map;for(let A of Object.keys(b)){let D=b[A],z=x.get(D);if(z){let f=E.memberKey(A);E[f]=E[E.memberKey(z)]}else j(E,A,D,F),x.set(D,A)}return E};te.StructType.prototype.installMethod=function(b,F,x=j.installMethodArgcCheck){return arguments.length<3&&b&&typeof b==="object"?U(this,...arguments):j(this,...arguments)},te.StructType.prototype.installMethods=function(E,b=j.installMethodArgcCheck){return U(this,E,b)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let t=(...m)=>{throw new i.SQLite3Error(...m)},{capi:r,wasm:a,util:_}=i,h=function(m){return(...y)=>m("sqlite3.oo1:",...y)},I=i.__isUnderTest?h(console.debug.bind(console)):h(i.config.debug),S=i.__isUnderTest?h(console.warn.bind(console)):h(i.config.warn),R=i.__isUnderTest?h(console.error.bind(console)):h(i.config.error),M=new WeakMap,p=new Set,te=new WeakMap,j=(m,y,C)=>{let c=Object.getOwnPropertyDescriptor(m,y);return c?c.value:C},U=function(m,y){if(y){if(m instanceof D)m=m.pointer;t(y,"sqlite3 result code",y+":",m?r.sqlite3_errmsg(m):r.sqlite3_errstr(y))}return arguments[0]},E=a.installFunction("i(ippp)",function(m,y,C,c){if(r.SQLITE_TRACE_STMT===m)console.log("SQL TRACE #"+ ++this.counter,"via sqlite3@"+y+"["+r.sqlite3_db_filename(y,null)+"]",a.cstrToJs(c))}.bind({counter:0})),b=Object.create(null),F=function(m){if(m instanceof ArrayBuffer)m=new Uint8Array(m);let y=[],C="0123456789abcdef";for(let c of m)y.push(C[(c&240)>>4],C[c&15]);return y.join("")},x=function(m,y){if(!r.sqlite3_key_v2)return;let C,c,d=(y.key?1:0)+(y.hexkey?1:0)+(y.textkey?1:0);if(!d)return;else if(d>1)t(r.SQLITE_MISUSE,"Only ONE of (key, hexkey, textkey) may be provided.");if(y.key){if(C="key",c=y.key,typeof c==="string")c=new TextEncoder("utf-8").encode(c);if(c instanceof ArrayBuffer||c instanceof Uint8Array)c=F(c),C="hexkey";else{t(r.SQLITE_MISUSE,"Invalid value for the 'key' option. Expecting a string,","ArrayBuffer, or Uint8Array.");return}}else if(y.textkey){if(C="textkey",c=y.textkey,c instanceof ArrayBuffer)c=new Uint8Array(c);if(c instanceof Uint8Array)c=new TextDecoder("utf-8").decode(c);else if(typeof c!=="string")t(r.SQLITE_MISUSE,"Invalid value for the 'textkey' option. Expecting a string,","ArrayBuffer, or Uint8Array.")}else if(y.hexkey){if(C="hexkey",c=y.hexkey,c instanceof ArrayBuffer||c instanceof Uint8Array)c=F(c);else if(typeof c!=="string")t(r.SQLITE_MISUSE,"Invalid value for the 'hexkey' option. Expecting a string,","ArrayBuffer, or Uint8Array.")}else return;let L;try{return L=m.prepare("PRAGMA "+C+"="+_.sqlite3__wasm_qfmt_token(c,1)),L.step(),!0}finally{if(L)L.finalize()}},A=function m(...y){let C=m.normalizeArgs(...y),c;if(c=C["sqlite3*"]){if(!C["sqlite3*:takeOwnership"])p.add(this);this.filename=r.sqlite3_db_filename(c,"main")}else{let{filename:d,vfs:L,flags:G}=C;if(typeof d!=="string"&&!a.isPtr(d)||typeof G!=="string"||L&&(typeof L!=="string"&&!a.isPtr(L)))i.config.error("Invalid DB ctor args",C,arguments),t("Invalid arguments for DB constructor:",arguments,"opts:",C);let B=0;if(G.indexOf("c")>=0)B|=r.SQLITE_OPEN_CREATE|r.SQLITE_OPEN_READWRITE;if(G.indexOf("w")>=0)B|=r.SQLITE_OPEN_READWRITE;if(B===0)B|=r.SQLITE_OPEN_READONLY;B|=r.SQLITE_OPEN_EXRESCODE;let ae=a.pstack.pointer;try{let ce=a.pstack.allocPtr(),be=r.sqlite3_open_v2(d,ce,B,L||a.ptr.null);if(c=a.peekPtr(ce),U(c,be),r.sqlite3_extended_result_codes(c,1),G.indexOf("t")>=0)r.sqlite3_trace_v2(c,r.SQLITE_TRACE_STMT,E,c)}catch(ce){if(c)r.sqlite3_close_v2(c);throw ce}finally{a.pstack.restore(ae)}this.filename=a.isPtr(d)?a.cstrToJs(d):d}if(M.set(this,c),te.set(this,Object.create(null)),!C["sqlite3*"])try{x(this,C);let d=r.sqlite3_js_db_vfs(c)||t("Internal error: cannot get VFS for new db handle."),L=b[d];if(L)if(L instanceof Function)L(this,i);else U(c,r.sqlite3_exec(c,L,0,0,0))}catch(d){throw this.close(),d}};A.setVfsPostOpenCallback=function(m,y){if(!(y instanceof Function))t("dbCtorHelper.setVfsPostOpenCallback() should not be used with a non-function argument.",arguments);b[m]=y},A.normalizeArgs=function(m=":memory:",y="c",C=null){let c={};if(arguments.length===1&&arguments[0]&&typeof arguments[0]==="object"){if(Object.assign(c,arguments[0]),c.flags===void 0)c.flags="c";if(c.vfs===void 0)c.vfs=null;if(c.filename===void 0)c.filename=":memory:"}else c.filename=m,c.flags=y,c.vfs=C;return c};let D=function(...m){A.apply(this,m)};D.dbCtorHelper=A;let z={null:1,number:2,string:3,boolean:4,blob:5};if(a.bigIntEnabled)z.bigint=z.number;let f=function(){if(z!==arguments[2])t(r.SQLITE_MISUSE,"Do not call the Stmt constructor directly. Use DB.prepare().");if(this.db=arguments[0],M.set(this,arguments[1]),arguments.length>3&&!arguments[3])p.add(this)},w=function(m){if(!m.pointer)t("DB has been closed.");return m},N=function(m,y){if(y!==(y|0)||y<0||y>=m.columnCount)t("Column index",y,"is out of range.");return m},J=function(m,y){let C=Object.create(null);switch(C.opt=Object.create(null),y.length){case 1:if(typeof y[0]==="string"||_.isSQLableTypedArray(y[0]))C.sql=y[0];else if(Array.isArray(y[0]))C.sql=y[0];else if(y[0]&&typeof y[0]==="object")C.opt=y[0],C.sql=C.opt.sql;break;case 2:C.sql=y[0],C.opt=y[1];break;default:t("Invalid argument count for exec().")}if(C.sql=_.flexibleString(C.sql),typeof C.sql!=="string")t("Missing SQL argument or unsupported SQL value type.");let c=C.opt;switch(c.returnValue){case"resultRows":if(!c.resultRows)c.resultRows=[];C.returnVal=()=>c.resultRows;break;case"saveSql":if(!c.saveSql)c.saveSql=[];C.returnVal=()=>c.saveSql;break;case void 0:case"this":C.returnVal=()=>m;break;default:t("Invalid returnValue value:",c.returnValue)}if(!c.callback&&!c.returnValue&&c.rowMode!==void 0){if(!c.resultRows)c.resultRows=[];C.returnVal=()=>c.resultRows}if(c.callback||c.resultRows)switch(c.rowMode===void 0?"array":c.rowMode){case"object":C.cbArg=(d,L)=>{if(!L.columnNames)L.columnNames=d.getColumnNames([]);let G=d.get([]),B=Object.create(null);for(let ae in L.columnNames)B[L.columnNames[ae]]=G[ae];return B};break;case"array":C.cbArg=(d)=>d.get([]);break;case"stmt":if(Array.isArray(c.resultRows))t("exec(): invalid rowMode for a resultRows array: must","be one of 'array', 'object',","a result column number, or column name reference.");C.cbArg=(d)=>d;break;default:if(_.isInt32(c.rowMode)){C.cbArg=(d)=>d.get(c.rowMode);break}else if(typeof c.rowMode==="string"&&c.rowMode.length>1&&c.rowMode[0]==="$"){let d=c.rowMode.substr(1);C.cbArg=(L)=>{let G=L.get(Object.create(null))[d];return G===void 0?t(r.SQLITE_NOTFOUND,"exec(): unknown result column:",d):G};break}t("Invalid rowMode:",c.rowMode)}return C},ie=(m,y,C,...c)=>{let d=m.prepare(y);try{let L=d.bind(C).step()?d.get(...c):void 0;return d.reset(),L}finally{d.finalize()}},le=(m,y,C,c)=>m.exec({sql:y,bind:C,rowMode:c,returnValue:"resultRows"}),we=(m,y,C)=>{switch(C===void 0?r.sqlite3_column_type(m.pointer,y):C){case r.SQLITE_NULL:return null;case r.SQLITE_INTEGER:if(a.bigIntEnabled){let c=r.sqlite3_column_int64(m.pointer,y);if(c>=Number.MIN_SAFE_INTEGER&&c<=Number.MAX_SAFE_INTEGER)return Number(c).valueOf();return c}else{let c=r.sqlite3_column_double(m.pointer,y);if(c>Number.MAX_SAFE_INTEGER||c<Number.MIN_SAFE_INTEGER)t("Integer is out of range for JS integer range: "+c);return _.isInt32(c)?c|0:c}case r.SQLITE_FLOAT:return r.sqlite3_column_double(m.pointer,y);case r.SQLITE_TEXT:return r.sqlite3_column_text(m.pointer,y);case r.SQLITE_BLOB:{let c=r.sqlite3_column_bytes(m.pointer,y),d=r.sqlite3_column_blob(m.pointer,y),L=new Uint8Array(c);if(c){if(L.set(a.heap8u().slice(Number(d),Number(d)+c),0),m.db._blobXfer instanceof Array)m.db._blobXfer.push(L.buffer)}return L}default:t("Don't know how to translate","type of result column #"+y+".")}t("Not reached.")};D.checkRc=(m,y)=>U(m,y),D.prototype={isOpen:function(){return!!this.pointer},affirmOpen:function(){return w(this)},close:function(){let m=this.pointer;if(m){if(this.onclose?.before instanceof Function)try{this.onclose.before(this)}catch(y){}for(let y of Object.values(te.get(this)))if(y?.pointer)try{y.finalize()}catch(C){}if(M.delete(this),te.delete(this),!p.delete(this))r.sqlite3_close_v2(m);if(this.onclose?.after instanceof Function)try{this.onclose.after(this)}catch(y){}delete this.filename}},changes:function(m=!1,y=!1){let C=w(this).pointer;if(m)return y?r.sqlite3_total_changes64(C):r.sqlite3_total_changes(C);else return y?r.sqlite3_changes64(C):r.sqlite3_changes(C)},dbFilename:function(m="main"){return r.sqlite3_db_filename(w(this).pointer,m)},dbName:function(m=0){return r.sqlite3_db_name(w(this).pointer,m)},dbVfsName:function(m=0){let y,C=r.sqlite3_js_db_vfs(w(this).pointer,m);if(C){let c=new r.sqlite3_vfs(C);try{y=a.cstrToJs(c.$zName)}finally{c.dispose()}}return y},prepare:function(m){w(this);let y=a.pstack.pointer,C,c;try{C=a.pstack.alloc(8),D.checkRc(this,r.sqlite3_prepare_v2(this.pointer,m,-1,C,null)),c=a.peekPtr(C)}finally{a.pstack.restore(y)}if(!c)t("Cannot prepare empty SQL.");let d=new f(this,c,z);return te.get(this)[c]=d,d},exec:function(){w(this);let m=J(this,arguments);if(!m.sql)return t("exec() requires an SQL string.");let y=m.opt,C=y.callback,c=Array.isArray(y.resultRows)?y.resultRows:void 0,d,L=y.bind,G=!!(m.cbArg||y.columnNames||c),B=a.scopedAllocPush(),ae=Array.isArray(y.saveSql)?y.saveSql:void 0;try{let ce=_.isSQLableTypedArray(m.sql),be=ce?m.sql.byteLength:a.jstrlen(m.sql),qe=a.scopedAlloc(2*a.ptr.size+(be+1)),Fe=a.ptr.add(qe,a.ptr.size),Pe=a.ptr.add(Fe,a.ptr.size),Ee=a.ptr.add(Pe,be);if(ce)a.heap8().set(m.sql,Pe);else a.jstrcpy(m.sql,a.heap8(),Pe,be,!1);a.poke8(a.ptr.add(Pe,be),0);while(Pe&&a.peek8(Pe)){a.pokePtr([qe,Fe],0),D.checkRc(this,r.sqlite3_prepare_v3(this.pointer,Pe,be,0,qe,Fe));let Qe=a.peekPtr(qe);if(Pe=a.peekPtr(Fe),be=Number(a.ptr.add(Ee,-Pe)),!Qe)continue;if(ae)ae.push(r.sqlite3_sql(Qe).trim());if(d=new f(this,Qe,z),L&&d.parameterCount)d.bind(L),L=null;if(G&&d.columnCount){let He=Array.isArray(y.columnNames)?0:1;if(G=!1,m.cbArg||c){let T=Object.create(null);for(;d.step();q.delete(d)){if(He++===0)d.getColumnNames(T.columnNames=y.columnNames||[]);q.add(d);let W=m.cbArg(d,T);if(c)c.push(W);if(C&&C.call(y,W,d)===!1)break}q.delete(d)}if(He===0)d.getColumnNames(y.columnNames)}else d.step();d.reset().finalize(),d=null}}finally{if(d)q.delete(d),d.finalize();a.scopedAllocPop(B)}return m.returnVal()},createFunction:function(y,C,c){let d=(T)=>T instanceof Function;switch(arguments.length){case 1:c=y,y=c.name,C=c.xFunc||0;break;case 2:if(!d(C))c=C,C=c.xFunc||0;break;case 3:break;default:break}if(!c)c={};if(typeof y!=="string")t("Invalid arguments: missing function name.");let L=c.xStep||0,G=c.xFinal||0,B=c.xValue||0,ae=c.xInverse||0,ce=void 0;if(d(C)){if(ce=!1,d(L)||d(G))t("Ambiguous arguments: scalar or aggregate?");L=G=null}else if(d(L)){if(!d(G))t("Missing xFinal() callback for aggregate or window UDF.");C=null}else if(d(G))t("Missing xStep() callback for aggregate or window UDF.");else t("Missing function-type properties.");if(ce===!1){if(d(B)||d(ae))t("xValue and xInverse are not permitted for non-window UDFs.")}else if(d(B)){if(!d(ae))t("xInverse must be provided if xValue is.");ce=!0}else if(d(ae))t("xValue must be provided if xInverse is.");let be=c.pApp;if(be!==void 0&&be!==null&&!a.isPtr(be))t("Invalid value for pApp property. Must be a legal WASM pointer value.");let qe=c.xDestroy||0;if(qe&&!d(qe))t("xDestroy property must be a function.");let Fe=0;if(j(c,"deterministic"))Fe|=r.SQLITE_DETERMINISTIC;if(j(c,"directOnly"))Fe|=r.SQLITE_DIRECTONLY;if(j(c,"innocuous"))Fe|=r.SQLITE_INNOCUOUS;y=y.toLowerCase();let Pe=C||L,Ee=j(c,"arity"),Qe=typeof Ee==="number"?Ee:Pe.length?Pe.length-1:0,He;if(ce)He=r.sqlite3_create_window_function(this.pointer,y,Qe,r.SQLITE_UTF8|Fe,be||0,L,G,B,ae,qe);else He=r.sqlite3_create_function_v2(this.pointer,y,Qe,r.SQLITE_UTF8|Fe,be||0,C,L,G,qe);return D.checkRc(this,He),this},selectValue:function(m,y,C){return ie(this,m,y,0,C)},selectValues:function(m,y,C){let c=this.prepare(m),d=[];try{N(c,0),c.bind(y);while(c.step())d.push(we(c,0,C));c.reset()}finally{c.finalize()}return d},selectArray:function(m,y){return ie(this,m,y,[])},selectObject:function(m,y){return ie(this,m,y,{})},selectArrays:function(m,y){return le(this,m,y,"array")},selectObjects:function(m,y){return le(this,m,y,"object")},openStatementCount:function(){return this.pointer?Object.keys(te.get(this)).length:0},transaction:function(m){let y="BEGIN";if(arguments.length>1){if(/[^a-zA-Z]/.test(arguments[0]))t(r.SQLITE_MISUSE,"Invalid argument for BEGIN qualifier.");y+=" "+arguments[0],m=arguments[1]}w(this).exec(y);try{let C=m(this);return this.exec("COMMIT"),C}catch(C){throw this.exec("ROLLBACK"),C}},savepoint:function(m){w(this).exec("SAVEPOINT oo1");try{let y=m(this);return this.exec("RELEASE oo1"),y}catch(y){throw this.exec("ROLLBACK to SAVEPOINT oo1; RELEASE SAVEPOINT oo1"),y}},checkRc:function(m){return U(this,m)}},D.wrapHandle=function(m,y=!1){if(!m||!a.isPtr(m))throw new i.SQLite3Error(r.SQLITE_MISUSE,"Argument must be a WASM sqlite3 pointer");return new D({"sqlite3*":m,"sqlite3*:takeOwnership":!!y})};let me=function(m){if(!m.pointer)t("Stmt has been closed.");return m},K=function(m){let y=z[m===null||m===void 0?"null":typeof m];switch(y){case z.boolean:case z.null:case z.number:case z.string:return y;case z.bigint:return a.bigIntEnabled?y:void 0;default:return _.isBindableTypedArray(m)?z.blob:void 0}},oe=function(m){return K(m)||t("Unsupported bind() argument type:",typeof m)},u=function(m,y){let C=typeof y==="number"?y:r.sqlite3_bind_parameter_index(m.pointer,y);if(C===0||!_.isInt32(C))t("Invalid bind() parameter name: "+y);else if(C<1||C>m.parameterCount)t("Bind index",y,"is out of range.");return C},q=new Set,O=new Set,V=function(m,y){if(q.has(m))t("Operation is illegal when statement is locked:",y);return m},Z=function m(y,C,c,d){if(V(me(y),"bind()"),!m._)m._tooBigInt=(G)=>t("BigInt value is too big to store without precision loss:",G),m._={string:function(G,B,ae,ce){let[be,qe]=a.allocCString(ae,!0);return(ce?r.sqlite3_bind_blob:r.sqlite3_bind_text)(G.pointer,B,be,qe,r.SQLITE_WASM_DEALLOC)}};oe(d),C=u(y,C);let L=0;switch(d===null||d===void 0?z.null:c){case z.null:L=r.sqlite3_bind_null(y.pointer,C);break;case z.string:L=m._.string(y,C,d,!1);break;case z.number:{let G;if(_.isInt32(d))G=r.sqlite3_bind_int;else if(typeof d==="bigint")if(!_.bigIntFits64(d))m._tooBigInt(d);else if(a.bigIntEnabled)G=r.sqlite3_bind_int64;else if(_.bigIntFitsDouble(d))d=Number(d),G=r.sqlite3_bind_double;else m._tooBigInt(d);else if(d=Number(d),a.bigIntEnabled&&Number.isInteger(d))G=r.sqlite3_bind_int64;else G=r.sqlite3_bind_double;L=G(y.pointer,C,d);break}case z.boolean:L=r.sqlite3_bind_int(y.pointer,C,d?1:0);break;case z.blob:{if(typeof d==="string"){L=m._.string(y,C,d,!0);break}else if(d instanceof ArrayBuffer)d=new Uint8Array(d);else if(!_.isBindableTypedArray(d))t("Binding a value as a blob requires","that it be a string, Uint8Array, Int8Array, or ArrayBuffer.");let G=a.alloc(d.byteLength||1);a.heap8().set(d.byteLength?d:[0],Number(G)),L=r.sqlite3_bind_blob(y.pointer,C,G,d.byteLength,r.SQLITE_WASM_DEALLOC);break}default:i.config.warn("Unsupported bind() argument type:",d),t("Unsupported bind() argument type: "+typeof d)}if(L)D.checkRc(y.db.pointer,L);return y};f.prototype={finalize:function(){let m=this.pointer;if(m){V(this,"finalize()");let y=p.delete(this)?0:r.sqlite3_finalize(m);return delete te.get(this.db)[m],M.delete(this),q.delete(this),O.delete(this),delete this.parameterCount,delete this.db,y}},clearBindings:function(){return V(me(this),"clearBindings()"),r.sqlite3_clear_bindings(this.pointer),O.delete(this),this},reset:function(m){if(V(this,"reset()"),m)this.clearBindings();let y=r.sqlite3_reset(me(this).pointer);return O.delete(this),U(this.db,y),this},resetNoThrow:function(m){if(V(this,"reset()"),m)this.clearBindings();let y=r.sqlite3_reset(me(this).pointer);return O.delete(this),y},bind:function(){me(this);let m,y;switch(arguments.length){case 1:m=1,y=arguments[0];break;case 2:m=arguments[0],y=arguments[1];break;default:t("Invalid bind() arguments.")}if(y===void 0)return this;else if(!this.parameterCount)t("This statement has no bindable parameters.");if(O.delete(this),y===null)return Z(this,m,z.null,y);else if(Array.isArray(y)){if(arguments.length!==1)t("When binding an array, an index argument is not permitted.");return y.forEach((C,c)=>Z(this,c+1,oe(C),C)),this}else if(y instanceof ArrayBuffer)y=new Uint8Array(y);if(typeof y==="object"&&!_.isBindableTypedArray(y)){if(arguments.length!==1)t("When binding an object, an index argument is not permitted.");return Object.keys(y).forEach((C)=>Z(this,C,oe(y[C]),y[C])),this}else return Z(this,m,oe(y),y);t("Should not reach this point.")},bindAsBlob:function(m,y){if(me(this),arguments.length===1)y=m,m=1;let C=oe(y);if(z.string!==C&&z.blob!==C&&z.null!==C)t("Invalid value type for bindAsBlob()");return Z(this,m,z.blob,y)},step:function(){V(this,"step()");let m=r.sqlite3_step(me(this).pointer);switch(m){case r.SQLITE_DONE:return O.delete(this),!1;case r.SQLITE_ROW:return O.add(this),!0;default:O.delete(this),i.config.warn("sqlite3_step() rc=",m,r.sqlite3_js_rc_str(m),"SQL =",r.sqlite3_sql(this.pointer)),D.checkRc(this.db.pointer,m)}},stepReset:function(){return this.step(),this.reset()},stepFinalize:function(){try{let m=this.step();return this.reset(),m}finally{try{this.finalize()}catch(m){}}},get:function(m,y){if(!O.has(me(this)))t("Stmt.step() has not (recently) returned true.");if(Array.isArray(m)){let C=0,c=this.columnCount;while(C<c)m[C]=we(this,C,y),++C;return m}else if(m&&typeof m==="object"){let C=0,c=this.columnCount;while(C<c)m[r.sqlite3_column_name(this.pointer,C)]=we(this,C,y),++C;return m}return N(this,m),we(this,m,y)},getInt:function(m){return this.get(m,r.SQLITE_INTEGER)},getFloat:function(m){return this.get(m,r.SQLITE_FLOAT)},getString:function(m){return this.get(m,r.SQLITE_TEXT)},getBlob:function(m){return this.get(m,r.SQLITE_BLOB)},getJSON:function(m){let y=this.get(m,r.SQLITE_STRING);return y===null?y:JSON.parse(y)},getColumnName:function(m){return r.sqlite3_column_name(N(me(this),m).pointer,m)},getColumnNames:function(m=[]){N(me(this),0);let y=this.columnCount;for(let C=0;C<y;++C)m.push(r.sqlite3_column_name(this.pointer,C));return m},getParamIndex:function(m){return me(this).parameterCount?r.sqlite3_bind_parameter_index(this.pointer,m):void 0},getParamName:function(m){return me(this).parameterCount?r.sqlite3_bind_parameter_name(this.pointer,m):void 0},isBusy:function(){return r.sqlite3_stmt_busy(me(this))!==0},isReadOnly:function(){return r.sqlite3_stmt_readonly(me(this))!==0}};{let m={enumerable:!0,get:function(){return M.get(this)},set:()=>t("The pointer property is read-only.")};Object.defineProperty(f.prototype,"pointer",m),Object.defineProperty(D.prototype,"pointer",m)}Object.defineProperty(f.prototype,"columnCount",{enumerable:!1,get:function(){return r.sqlite3_column_count(this.pointer)},set:()=>t("The columnCount property is read-only.")}),Object.defineProperty(f.prototype,"parameterCount",{enumerable:!1,get:function(){return r.sqlite3_bind_parameter_count(this.pointer)},set:()=>t("The parameterCount property is read-only.")}),f.wrapHandle=function(m,y,C=!1){let c=f;if(!(m instanceof D)||!m.pointer)throw new i.SQLite3Error(i.SQLITE_MISUSE,"First argument must be an opened sqlite3.oo1.DB instance");if(!y||!a.isPtr(y))throw new i.SQLite3Error(i.SQLITE_MISUSE,"Second argument must be a WASM sqlite3_stmt pointer");return new f(m,y,z,!!C)},i.oo1={DB:D,Stmt:f}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let t=i.util;i.initWorker1API=function(){let r=(...j)=>{throw Error(j.join(" "))};if(!(globalThis.WorkerGlobalScope instanceof Function))r("initWorker1API() must be run from a Worker thread.");let a=this.sqlite3||r("Missing this.sqlite3 object."),_=a.oo1.DB,h=function(j){let U=I.idMap.get(j);if(U)return U;return U="db#"+ ++I.idSeq+":"+Math.floor(Math.random()*1e8)+":"+Math.floor(Math.random()*1e8),I.idMap.set(j,U),U},I={dbList:[],idSeq:0,idMap:new WeakMap,xfer:[],open:function(j){let U=new _(j);if(this.dbs[h(U)]=U,this.dbList.indexOf(U)<0)this.dbList.push(U);return U},close:function(j,U){if(j){delete this.dbs[h(j)];let E=j.filename,b=t.sqlite3__wasm_db_vfs(j.pointer,0);j.close();let F=this.dbList.indexOf(j);if(F>=0)this.dbList.splice(F,1);if(U&&E&&b)t.sqlite3__wasm_vfs_unlink(b,E)}},post:function(j,U){if(U&&U.length)globalThis.postMessage(j,Array.from(U)),U.length=0;else globalThis.postMessage(j)},dbs:Object.create(null),getDb:function(j,U=!0){return this.dbs[j]||(U?r("Unknown (or closed) DB ID:",j):void 0)}},S=function(j=I.dbList[0]){return j&&j.pointer?j:r("DB is not opened.")},R=function(j,U=!0){let E=I.getDb(j.dbId,!1)||I.dbList[0];return U?S(E):E},M=function(){return I.dbList[0]&&h(I.dbList[0])},p=(j)=>j===""||j[0]===":",te={open:function(j){let U=Object.create(null),E=j.args||Object.create(null);if(E.simulateError)r("Throwing because of simulateError flag.");let b=Object.create(null);U.vfs=E.vfs,U.filename=E.filename||"";let F=I.open(U);return b.filename=F.filename,b.persistent=!!a.capi.sqlite3_js_db_uses_vfs(F.pointer,"opfs"),b.dbId=h(F),b.vfs=F.dbVfsName(),b},close:function(j){let U=R(j,!1),E={filename:U&&U.filename};if(U){let b=j.args&&typeof j.args==="object"?!!j.args.unlink:!1;I.close(U,b)}return E},exec:function(j){let U=typeof j.args==="string"?{sql:j.args}:j.args||Object.create(null);if(U.rowMode==="stmt")r("Invalid rowMode for 'exec': stmt mode","does not work in the Worker API.");else if(!U.sql)r("'exec' requires input SQL.");let E=R(j);if(U.callback||Array.isArray(U.resultRows))E._blobXfer=I.xfer;let b=U.callback,F=0,x=!!U.columnNames;if(typeof b==="string"){if(!x)U.columnNames=[];U.callback=function(A,D){I.post({type:b,columnNames:U.columnNames,rowNumber:++F,row:A},I.xfer)}}try{let A=U.countChanges?E.changes(!0,U.countChanges===64):void 0;if(E.exec(U),A!==void 0)U.changeCount=E.changes(!0,U.countChanges===64)-A;let D=U.lastInsertRowId?a.capi.sqlite3_last_insert_rowid(E):void 0;if(D!==void 0)U.lastInsertRowId=D;if(U.callback instanceof Function)U.callback=b,I.post({type:b,columnNames:U.columnNames,rowNumber:null,row:void 0})}finally{if(delete E._blobXfer,U.callback)U.callback=b}return U},"config-get":function(){let j=Object.create(null),U=a.config;return["bigIntEnabled"].forEach(function(E){if(Object.getOwnPropertyDescriptor(U,E))j[E]=U[E]}),j.version=a.version,j.vfsList=a.capi.sqlite3_js_vfs_list(),j},export:function(j){let U=R(j),E={byteArray:a.capi.sqlite3_js_db_export(U.pointer),filename:U.filename,mimetype:"application/x-sqlite3"};return I.xfer.push(E.byteArray.buffer),E},toss:function(j){r("Testing worker exception")}};globalThis.onmessage=async function(j){j=j.data;let U,E=j.dbId,b=j.type,F=performance.now();try{if(te.hasOwnProperty(b)&&te[b]instanceof Function)U=await te[b](j);else r("Unknown db worker message type:",j.type)}catch(x){if(b="error",U={operation:j.type,message:x.message,errorClass:x.name,input:j},x.stack)U.stack=typeof x.stack==="string"?x.stack.split(/\n\s*/):x.stack}if(!E)E=U.dbId||M();I.post({type:b,dbId:E,messageId:j.messageId,workerReceivedTime:F,workerRespondTime:performance.now(),departureTime:j.departureTime,result:U},I.xfer)},globalThis.postMessage({type:"sqlite3-api",result:"worker1-ready"})}.bind({sqlite3:i})}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let{wasm:t,capi:r}=i,a=i.util.toss3,_=Object.create(null);i.vfs=_,r.sqlite3_vfs.prototype.registerVfs=function(h=!1){if(!(this instanceof i.capi.sqlite3_vfs))a("Expecting a sqlite3_vfs-type argument.");let I=r.sqlite3_vfs_register(this,h?1:0);if(I)a("sqlite3_vfs_register(",this,") failed with rc",I);if(this.pointer!==r.sqlite3_vfs_find(this.$zName))a("BUG: sqlite3_vfs_find(vfs.$zName) failed for just-installed VFS",this);return this},_.installVfs=function(h){let I=0,S=["io","vfs"];for(let R of S){let M=h[R];if(M){if(++I,M.struct.installMethods(M.methods,!!M.applyArgcCheck),R==="vfs"){if(!M.struct.$zName&&typeof M.name==="string")M.struct.addOnDispose(M.struct.$zName=t.allocCString(M.name));M.struct.registerVfs(!!M.asDefault)}}}if(!I)a("Misuse: installVfs() options object requires at least","one of:",S);return this}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.wasm.exports.sqlite3_declare_vtab)return;let{wasm:t,capi:r}=i,a=i.util.toss3,_=Object.create(null);i.vtab=_;let h=r.sqlite3_index_info;h.prototype.nthConstraint=function(R,M=!1){if(R<0||R>=this.$nConstraint)return!1;let p=t.ptr.add(this.$aConstraint,h.sqlite3_index_constraint.structInfo.sizeof*R);return M?p:new h.sqlite3_index_constraint(p)},h.prototype.nthConstraintUsage=function(R,M=!1){if(R<0||R>=this.$nConstraint)return!1;let p=t.ptr.add(this.$aConstraintUsage,h.sqlite3_index_constraint_usage.structInfo.sizeof*R);return M?p:new h.sqlite3_index_constraint_usage(p)},h.prototype.nthOrderBy=function(R,M=!1){if(R<0||R>=this.$nOrderBy)return!1;let p=t.ptr.add(this.$aOrderBy,h.sqlite3_index_orderby.structInfo.sizeof*R);return M?p:new h.sqlite3_index_orderby(p)};let I=function(R,M){return function(p,te=!1){if(arguments.length===0)p=new M;if(p instanceof M)return this.set(p.pointer,p),p;else if(!t.isPtr(p))i.SQLite3Error.toss("Invalid argument to",R+"()");let j=this.get(p);if(te)this.delete(p);return j}.bind(new Map)},S=function(R,M){let p=I(R,M);return Object.assign(Object.create(null),{StructType:M,create:(te)=>{let j=p();return t.pokePtr(te,j.pointer),j},get:(te)=>p(te),unget:(te)=>p(te,!0),dispose:(te)=>p(te,!0)?.dispose?.()})};_.xVtab=S("xVtab",r.sqlite3_vtab),_.xCursor=S("xCursor",r.sqlite3_vtab_cursor),_.xIndexInfo=(R)=>new r.sqlite3_index_info(R),_.xError=function R(M,p,te){if(R.errorReporter instanceof Function)try{R.errorReporter("sqlite3_module::"+M+"(): "+p.message)}catch(U){}let j;if(p instanceof i.WasmAllocError)j=r.SQLITE_NOMEM;else if(arguments.length>2)j=te;else if(p instanceof i.SQLite3Error)j=p.resultCode;return j||r.SQLITE_ERROR},_.xError.errorReporter=i.config.error.bind(i.config),_.xRowid=(R,M)=>t.poke(R,M,"i64"),_.setupModule=function(R){let M=!1,p=this instanceof r.sqlite3_module?this:R.struct||(M=new r.sqlite3_module);try{let te=R.methods||a("Missing 'methods' object.");for(let j of Object.entries({xConnect:"xCreate",xDisconnect:"xDestroy"})){let U=j[0],E=j[1];if(te[U]===!0)te[U]=te[E];else if(te[E]===!0)te[E]=te[U]}if(R.catchExceptions){let j=function(b,F){if(["xConnect","xCreate"].indexOf(b)>=0)return function(x,A,D,z,f,w){try{return F(...arguments)||0}catch(N){if(!(N instanceof i.WasmAllocError))t.dealloc(t.peekPtr(w)),t.pokePtr(w,t.allocCString(N.message));return _.xError(b,N)}};else return function(...x){try{return F(...x)||0}catch(A){return _.xError(b,A)}}},U=["xCreate","xConnect","xBestIndex","xDisconnect","xDestroy","xOpen","xClose","xFilter","xNext","xEof","xColumn","xRowid","xUpdate","xBegin","xSync","xCommit","xRollback","xFindFunction","xRename","xSavepoint","xRelease","xRollbackTo","xShadowName"],E=Object.create(null);for(let b of U){let F=te[b];if(!(F instanceof Function))continue;else if(b==="xConnect"&&te.xCreate===F)E[b]=te.xCreate;else if(b==="xCreate"&&te.xConnect===F)E[b]=te.xConnect;else E[b]=j(b,F)}p.installMethods(E,!1)}else p.installMethods(te,!!R.applyArgcCheck);if(p.$iVersion===0){let j;if(typeof R.iVersion==="number")j=R.iVersion;else if(p.$xIntegrity)j=4;else if(p.$xShadowName)j=3;else if(p.$xSavePoint||p.$xRelease||p.$xRollbackTo)j=2;else j=1;p.$iVersion=j}}catch(te){if(M)M.dispose();throw te}return p},r.sqlite3_module.prototype.setupModule=function(R){return _.setupModule.call(this,R)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.kvvfs)return;let t=i.capi,{sqlite3_kvvfs_methods:r,KVVfsFile:a}=t,_=i.capi.sqlite3_vfs_find("kvvfs");if(delete t.sqlite3_kvvfs_methods,delete t.KVVfsFile,!_)return;let{util:h,wasm:I}=i,S=h.toss3,R=(T,W)=>Object.prototype.hasOwnProperty.call(T,W),M=new r(I.exports.sqlite3__wasm_kvvfs_methods());h.assert(32<=M.$nKeySize,"unexpected kvvfsMethods.$nKeySize: "+M.$nKeySize);let p=Object.assign(Object.create(null),{rxJournalSuffix:/-journal$/,zKeyJrnl:I.allocCString("jrnl"),zKeySz:I.allocCString("sz"),keySize:M.$nKeySize,buffer:Object.assign(Object.create(null),{n:M.$nBufferSize,pool:Object.create(null)})});p.memBuffer=(T=0)=>p.buffer.pool[T]??=I.alloc(p.buffer.n),p.memBufferFree=(T)=>{let W=p.buffer.pool[T];if(W)I.dealloc(W),delete p.buffer.pool[T]};let te=()=>{},j=i.__isUnderTest?(...T)=>i.config.debug?.("kvvfs:",...T):te,U=(...T)=>i.config.warn?.("kvvfs:",...T),E=(...T)=>i.config.error?.("kvvfs:",...T);class b{#e=Object.create(null);#i=null;#s=0;constructor(){this.clear()}#t(){return this.#i??=Object.keys(this.#e)}key(T){if(T<0||T>=this.#s)return null;return this.#t()[T]}getItem(T){return this.#e[T]??null}setItem(T,W){if(!(T in this.#e))++this.#s,this.#i=null;this.#e[T]=""+W}removeItem(T){if(T in this.#e)delete this.#e[T],--this.#s,this.#i=null}clear(){this.#e=Object.create(null),this.#i=null,this.#s=0}get length(){return this.#s}}let F=(T)=>T==="local"||T==="session",x=(T)=>F(T)?"kvvfs-"+T+"-":"",A=function(T,W=!1){if(F(T))return;let Q=new Blob([T]).size;if(!Q)S(t.SQLITE_MISUSE,"Empty name is not permitted.");let H=p.keySize-1;if(p.rxJournalSuffix.test(T)){if(!W)S(t.SQLITE_MISUSE,"Storage names may not have a '-journal' suffix.")}else if(["-wal","-shm"].filter((_e)=>T.endsWith(_e)).length)S(t.SQLITE_MISUSE,"Storage names may not have a -wal or -shm suffix.");else H-=8;if(Q>H)S(t.SQLITE_RANGE,"Storage name is too long. Limit =",H);let se;for(se=0;se<Q;++se){let _e=T.codePointAt(se);if(_e<32)S(t.SQLITE_RANGE,"Illegal character ("+_e+"d) in storage name:",T)}},D=(T,W=void 0)=>Object.assign(Object.create(null),{jzClass:T,refc:1,deleteAtRefc0:!1,storage:W||new b,keyPrefix:x(T),files:[],listeners:void 0}),z=i.kvvfs=Object.create(null);if(i.__isUnderTest)z.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});let f=function(T){let W=p.rxJournalSuffix.test(T.jzClass)?T.jzClass.replace(p.rxJournalSuffix,""):T.jzClass+"-journal";if(z?.log?.xClose&&j("cleaning up storage handles [",T.jzClass,W,"]",T),delete p.storagePool[T.jzClass],delete p.storagePool[W],!i.__isUnderTest)delete T.storage,delete T.refc},w=(T)=>p.storagePool[T.jzClass]=p.storagePool[T.jzClass+"-journal"]=T,N=".";if(p.storagePool=Object.assign(Object.create(null),{[N]:D(N)}),globalThis.Storage){if(globalThis.localStorage instanceof globalThis.Storage)p.storagePool.local=D("local",globalThis.localStorage);if(globalThis.sessionStorage instanceof globalThis.Storage)p.storagePool.session=D("session",globalThis.sessionStorage)}p.builtinStorageNames=Object.keys(p.storagePool);let J=(T)=>p.builtinStorageNames.indexOf(T)>-1;for(let T of Object.keys(p.storagePool)){let W=p.storagePool[T];p.storagePool[T+"-journal"]=W}p.setError=(T=void 0,W=t.SQLITE_ERROR)=>{if(T)return p.lastError=T,T.resultCode|0||W;return delete p.lastError,0},p.popError=()=>{let T=p.lastError;return delete p.lastError,T};let ie=(T)=>{U("kvvfs.listener handler threw:",T)},le=I.exports.sqlite3__wasm_kvvfs_decode,we=I.exports.sqlite3__wasm_kvvfs_encode,me=async function(T,W,...Q){try{if(W.keyPrefix&&Q[0])Q[0]=Q[0].replace(W.keyPrefix,"");let H,se,_e,de;for(let ue of W.listeners){let pe=Object.create(null);pe.storageName=W.jzClass,pe.type=T;let Le=ue.decodePages,Ce=ue.events[T];if(Ce){if(!ue.includeJournal&&Q[0]==="jrnl")continue;if(T==="write"&&ue.decodePages&&+Q[0]>0){if(pe.data=[Q[0]],de?.[Q[0]]){pe.data[1]=de[Q[0]];continue}H??=new TextEncoder("utf-8"),se??=p.memBuffer(10),_e??=p.memBuffer(11);let Ae=H.encode(Q[1]),De=I.heap8u();De.set(Ae,Number(se)),De[I.ptr.addn(se,Ae.length)]=0;let Re=le(se,_e,p.buffer.n);if(Re>0)de??=Object.create(null),de[Q[0]]=pe.data[1]=De.slice(Number(_e),I.ptr.addn(_e,Re));else continue}else pe.data=Q.length?Q.length===1?Q[0]:Q:void 0;try{Ce(pe)?.catch?.(ie)}catch(Ae){U("notifyListeners [",W.jzClass,"]",T,Ae)}}}}catch(H){ie(H)}},K=(T)=>typeof T==="string"?p.storagePool[T]:p.storagePool[I.cstrToJs(T)],oe=I.exports.sqlite3__wasm_kvvfsMakeKey,u=(T,W,Q)=>W&&T.keyPrefix?oe(W,Q):Q,q=(T,W,Q)=>I.cstrToJs(u(T,W,Q)),O=(T)=>+T.storage.getItem(T.keyPrefix+"sz"),V=new Map,Z=new Map,m=function(T,W){if(T.lockType<=W)return;let Q=Z.get(T.jzClass);if(T.lockType>t.SQLITE_LOCK_SHARED)Q.lockType=t.SQLITE_LOCK_SHARED;if(W===t.SQLITE_LOCK_NONE&&--Q.nShared===0)Z.delete(T.jzClass);T.lockType=W},y={vfs:Object.create(null),ioDb:Object.create(null),ioJrnl:Object.create(null)},C=(T)=>y[T.$isJournal?"ioJrnl":"ioDb"],c=new t.sqlite3_vfs(M.$pVfs),d=new t.sqlite3_io_methods(M.$pIoDb),L=new t.sqlite3_io_methods(M.$pIoJrnl),G=Object.create(null),B=Object.assign(Object.create(null),{pFileHandles:V,cache:p,storageForZClass:K,KVVfsStorage:b,disablePageSizeChange:!0});if(z.log)z.internal=B;let ae={recordHandler:{xRcrdRead:(T,W,Q,H)=>{try{let se=I.cstrToJs(T),_e=K(se);if(!_e)return-1;let de=q(_e,T,W);z?.log?.xRcrdRead&&U("xRcrdRead",se,de,H,_e);let ue=_e.storage.getItem(de);if(ue===null)return-1;let pe=ue.length;if(H<=0)return pe;else if(H===1)return I.poke(Q,0),pe;else if(H<pe)S(t.SQLITE_RANGE,"xRcrdRead()",se,de,"input buffer is too small: need",pe,"but have",H);else if(H>pe+1)H=pe+1;let Le=pe<H?pe:H-1,Ce=I.heap8();for(let Ae=0;Ae<Le;++Ae)Ce[I.ptr.add(Q,Ae)]=ue.codePointAt(Ae)&255;return Ce[I.ptr.add(Q,Le)]=0,Le}catch(se){return E("kvrecordRead()",se),p.setError(se),-2}},xRcrdWrite:(T,W,Q)=>{try{let H=K(T),se=q(H,T,W),_e=I.cstrToJs(Q);return z?.log?.xRcrdWrite&&U("xRcrdWrite",se,H),H.storage.setItem(se,_e),H.listeners&&me("write",H,se,_e),0}catch(H){return E("kvrecordWrite()",H),p.setError(H,t.SQLITE_IOERR)}},xRcrdDelete:(T,W)=>{try{let Q=K(T),H=q(Q,T,W);return z?.log?.xRcrdDelete&&U("xRcrdDelete",H,Q),Q.storage.removeItem(H),Q.listeners&&me("delete",Q,H),0}catch(Q){return E("kvrecordDelete()",Q),p.setError(Q,t.SQLITE_IOERR)}}},vfs:{xOpen:function(T,W,Q,H,se){p.popError();let _e;try{if(!W)_e=I.allocCString(""+Q+"."+(Math.random()*1e5|0)),W=_e;let de=I.cstrToJs(W);if(z?.log?.xOpen&&j("xOpen",de,"flags =",H),A(de,!0),H&(t.SQLITE_OPEN_MAIN_DB|t.SQLITE_OPEN_TEMP_DB|t.SQLITE_OPEN_TRANSIENT_DB)&&p.rxJournalSuffix.test(de))S(t.SQLITE_ERROR,"DB files may not have a '-journal' suffix.");let ue=K(de);if(!ue&&!(H&t.SQLITE_OPEN_CREATE))S(t.SQLITE_ERROR,"Storage not found:",de);let pe=y.vfs.xOpen(T,W,Q,H,se);if(pe)return pe;let Le=!!(t.SQLITE_OPEN_DELETEONCLOSE&H);if(I.isPtr(arguments[1])){if(t.sqlite3_uri_boolean(W,"delete-on-close",0))Le=!0}let Ce=new a(Q);if(h.assert(Ce.$zClass,"Missing f.$zClass"),Ce.addOnDispose(_e),_e=void 0,ue)++ue.refc,ue.files.push(Ce),I.poke32(se,H);else{I.poke32(se,H|t.SQLITE_OPEN_CREATE),h.assert(!Ce.$isJournal,"Opening a journal before its db? "+de);let Ae=de.replace(p.rxJournalSuffix,"");ue=D(Ae),w(ue),ue.files.push(Ce),ue.deleteAtRefc0=Le,z?.log?.xOpen&&j("xOpen installed storage handle [",Ae,Ae+"-journal","]",ue)}return V.set(Q,Object.assign(Object.create(null),{store:ue,file:Ce,jzClass:de,lockType:0})),ue.listeners&&me("open",ue,ue.files.length),0}catch(de){return U("xOpen:",de),p.setError(de)}finally{_e&&I.dealloc(_e)}},xDelete:function(T,W,Q){p.popError();try{let H=I.cstrToJs(W);if(p.rxJournalSuffix.test(H))G.xRcrdDelete(W,p.zKeyJrnl);return 0}catch(H){return U("xDelete",H),p.setError(H)}},xAccess:function(T,W,Q,H){p.popError();try{let se=K(W),_e=se?.jzClass||I.cstrToJs(W);if(z?.log?.xAccess)j("xAccess",_e,"flags =",Q,"*pResOut =",I.peek32(H),"store =",se);if(!se)try{A(_e)}catch(de){return I.poke32(H,0),0}if(se){let de=se.keyPrefix+(p.rxJournalSuffix.test(_e)?"jrnl":"1"),ue=se.storage.getItem(de)?0:1;I.poke32(H,ue)}else I.poke32(H,0);return 0}catch(se){return E("xAccess",se),p.setError(se)}},xRandomness:function(T,W,Q){let H=I.heap8u(),se=0,_e=Number(Q);for(;se<W;++se)H[_e+se]=Math.random()*255000&255;return W},xGetLastError:function(T,W,Q){let H=p.popError();if(j("xGetLastError",H),H){let se=I.scopedAllocPush();try{let[_e,de]=I.scopedAllocCString(H.message,!0);if(I.cstrncpy(Q,_e,W),de>W)I.poke8(I.ptr.add(Q,W,-1),0);return j("set xGetLastError",H.message),H.resultCode|0||t.SQLITE_IOERR}catch(_e){return t.SQLITE_NOMEM}finally{I.scopedAllocPop(se)}}return 0},xSleep:(T,W)=>0},ioDb:{xClose:function(T){p.popError();try{let W=V.get(T);if(z?.log?.xClose&&j("xClose",T,W),W){V.delete(T),m(W,t.SQLITE_LOCK_NONE);let Q=W.store;if(Q.files=Q.files.filter((H)=>H!==W.file),--Q.refc<=0&&Q.deleteAtRefc0)f(Q);y.ioDb.xClose(T),W.file.dispose(),Q.listeners&&me("close",Q,Q.files.length)}return 0}catch(W){return E("xClose",W),p.setError(W)}},xFileControl:function(T,W,Q){p.popError();try{let H=V.get(T);if(h.assert(H,"Missing KVVfsFile handle"),z?.log?.xFileControl&&j("xFileControl",H,"op =",W),W===t.SQLITE_FCNTL_PRAGMA&&B.disablePageSizeChange){let _e=I.peekPtr(I.ptr.add(Q,I.ptr.size));if(I.cstrToJs(_e)==="page_size"){z?.log?.xFileControl&&j("xFileControl pragma",I.cstrToJs(_e));let de=I.peekPtr(I.ptr.add(Q,2*I.ptr.size));if(de)return z?.log?.xFileControl&&U("xFileControl pragma",H,"NOT setting page size to",I.cstrToJs(de)),H.file.$szPage=-1,0;else if(H.file.$szPage>0)return z?.log?.xFileControl&&U("xFileControl",H,"getting page size",H.file.$szPage),I.pokePtr(Q,I.allocCString(""+H.file.$szPage)),0}}let se=y.ioDb.xFileControl(T,W,Q);if(se==0&&t.SQLITE_FCNTL_SYNC===W)H.store.listeners&&me("sync",H.store,!1);return se}catch(H){return E("xFileControl",H),p.setError(H)}},xSync:function(T,W){p.popError();try{let Q=V.get(T);z?.log?.xSync&&j("xSync",Q),h.assert(Q,"Missing KVVfsFile handle");let H=y.ioDb.xSync(T,W);if(H==0&&Q.store.listeners)me("sync",Q.store,!0);return H}catch(Q){return E("xSync",Q),p.setError(Q)}},xLock:function(T,W){p.popError();try{let Q=V.get(T);if(t.SQLITE_LOCK_NONE!==W)y.ioDb.xLock(T,W);if(Q.lockType>=W)return 0;let H=Z.get(Q.jzClass);if(!H)H=Object.assign(Object.create(null),{nShared:0,lockType:t.SQLITE_LOCK_NONE}),Z.set(Q.jzClass,H);if(Q.lockType!==H.lockType&&(H.lockType>=t.SQLITE_LOCK_PENDING||W>t.SQLITE_LOCK_SHARED))return t.SQLITE_BUSY;if(W===t.SQLITE_LOCK_SHARED){if(++H.nShared,H.lockType===t.SQLITE_LOCK_NONE)H.lockType=W}else if(W===t.SQLITE_LOCK_EXCLUSIVE&&H.nShared>1){if(Q.lockType===t.SQLITE_LOCK_RESERVED)Q.lockType=H.lockType=t.SQLITE_LOCK_PENDING;return t.SQLITE_BUSY}else H.lockType=W;return Q.lockType=W,0}catch(Q){return E("xLock",Q),p.setError(Q)}},xUnlock:function(T,W){p.popError();try{if(t.SQLITE_LOCK_NONE===W)y.ioDb.xUnlock(T,W);let Q=V.get(T);return m(Q,W),0}catch(Q){return E("xUnlock",Q),p.setError(Q)}},xCheckReservedLock:function(T,W){p.popError();try{let Q=V.get(T),H=Z.get(Q.jzClass);return I.poke32(W,!!H&&H.lockType>t.SQLITE_LOCK_SHARED?1:0),0}catch(Q){return E("xCheckReservedLock",Q),p.setError(Q)}}},ioJrnl:{xClose:!0,xLock:!0,xUnlock:!0,xCheckReservedLock:!0}};try{h.assert(p.buffer.n>132096,"Heap buffer is not large enough");for(let T of Object.entries(ae.recordHandler)){let W=T[0],Q=T[1];G[W]=Q,M[M.memberKey(W)]=I.installFunction(M.memberSignature(W),Q)}for(let T of Object.entries(ae.vfs)){let W=T[0],Q=T[1],H=c.memberKey(W),se=c.structInfo.members[W]||h.toss("Missing pVfs.structInfo[",W,"]");y.vfs[W]=I.functionEntry(c[H]),c[H]=I.installFunction(se.signature,Q)}for(let T of Object.entries(ae.ioDb)){let W=T[0],Q=T[1],H=d.memberKey(W);y.ioDb[W]=I.functionEntry(d[H])||h.toss("Missing native pIoDb[",H,"]"),d[H]=I.installFunction(d.memberSignature(W),Q)}for(let T of Object.entries(ae.ioJrnl)){let W=T[0],Q=T[1],H=L.memberKey(W);if(y.ioJrnl[W]=I.functionEntry(L[H])||h.toss("Missing native pIoJrnl[",H,"]"),Q===!0)L[H]=d[H]||h.toss("Missing copied pIoDb[",H,"]");else L[H]=I.installFunction(L.memberSignature(W),Q)}}finally{M.dispose(),c.dispose(),d.dispose(),L.dispose()}let ce=function T(W){if(W==="")return T("local")+T("session");let Q=K(W);if(!Q)return 0;if(Q.files.length)if(globalThis.localStorage===Q.storage||globalThis.sessionStorage===Q.storage);else S(t.SQLITE_ACCESS,"Cannot clear in-use database storage.");let H=Q.storage,se=[],_e,de=H.length;for(_e=0;_e<de;++_e){let ue=H.key(_e);if(!Q.keyPrefix||ue.startsWith(Q.keyPrefix))se.push(ue)}return se.forEach((ue)=>H.removeItem(ue)),se.length},be=function T(W){if(W==="")return T("local")+T("session");let Q=K(W);if(!Q)return 0;let H=Q.storage,se,_e=0;for(se=0;se<H.length;++se){let de=H.key(se);if(!Q.keyPrefix||de.startsWith(Q.keyPrefix))_e+=de.length,_e+=H.getItem(de).length}return _e*2},qe=function(...W){let Q;if(W.length===1&&typeof W[0]==="object")Q=W[0];else if(W.length)Q=Object.assign(Object.create(null),{name:W[0]});let H=Q?K(Q.name):null;if(!H)S(t.SQLITE_NOTFOUND,"There is no kvvfs storage named",Q?.name);let se=H.storage,_e=Object.assign(Object.create(null),{name:H.jzClass,timestamp:Date.now(),pages:[]}),de=Object.create(null),ue,pe=H.keyPrefix,Le=pe?/^kvvfs-[^-]+-(\w+)/:void 0,Ce=0,Ae=se.length;for(;Ce<Ae;++Ce){let De=se.key(Ce);if(!pe||De.startsWith(pe)){let Re=(pe?Le.exec(De):void 0)?.[1]??De;switch(Re){case"jrnl":if(Q.includeJournal)_e.journal=se.getItem(De);break;case"sz":_e.size=+se.getItem(De);break;default:if(Re=+Re,!h.isInt32(Re)||Re<=0)S(t.SQLITE_RANGE,"Malformed kvvfs key: "+De);if(Q.decodePages){let et=se.getItem(De),st=et.length,Je=p.memBuffer(0),bt=p.memBuffer(1),yt=I.heap8u(),_t=0;for(;_t<st;++_t)yt[I.ptr.add(Je,_t)]=et.codePointAt(_t)&255;yt[I.ptr.add(Je,_t)]=0;let jt=le(Je,bt,p.buffer.n);de[Re]=yt.slice(Number(bt),I.ptr.addn(bt,jt))}else de[Re]=se.getItem(De);break}}}if(Q.decodePages)p.memBufferFree(1);return Object.keys(de).map((De)=>+De).sort().forEach((De)=>_e.pages.push(de[De])),_e},Fe=function(T,W=!1){if(!T?.timestamp||!T.name||T.size===void 0||!Array.isArray(T.pages))S(t.SQLITE_MISUSE,"Malformed export object.");else if(!T.size||T.size!==(T.size|0)||T.size>=2147483647)S(t.SQLITE_RANGE,"Invalid db size: "+T.size);A(T.name);let Q=K(T.name),H=!Q;if(Q){if(!W)S(t.SQLITE_ACCESS,"Storage '"+T.name+"' already exists and","overwrite was not specified.");else if(!Q.files||!Q.jzClass)S(t.SQLITE_ERROR,"Internal storage object",T.name,"seems to be malformed.");else if(Q.files.length)S(t.SQLITE_IOERR_ACCESS,"Cannot import db storage while it is in use.");ce(T.name)}else Q=D(T.name);let se=x(T.name),_e;try{let de=Q.storage;if(de.setItem(se+"sz",T.size),T.journal)de.setItem(se+"jrnl",T.journal);if(T.pages[0]instanceof Uint8Array)T.pages.forEach((ue,pe)=>{let Le=ue.length;_e??=p.memBuffer(1);let Ce=p.memBuffer(0),Ae=I.heap8u();Ae.set(ue,Number(Ce)),Ae[I.ptr.addn(Ce,Le)]=0;let De=we(Ce,Le,_e);h.assert(De<p.buffer.n,"Impossibly long output - possibly smashed the heap"),h.assert(I.peek8(I.ptr.add(_e,De))===0,"Expecting NUL-terminated encoded output");let Re=I.cstrToJs(_e);de.setItem(se+(pe+1),Re)});else if(T.pages[0])T.pages.forEach((ue,pe)=>de.setItem(se+(pe+1),ue));if(H)w(Q)}catch{if(!H)try{ce(T.name)}catch(de){}}finally{if(_e)p.memBufferFree(1)}return this},Pe=function(T){let W=K(T);if(W){++W.refc;return}A(T),w(D(T))},Ee=function(T){let W=K(T);if(!W||F(W.jzClass)||J(W.jzClass)||p.rxJournalSuffix.test(T))return!1;if(W.refc>W.files.length||W.files.length===0){if(--W.refc<=0)f(W);return!0}return!1},Qe=function(T){if(!T||typeof T!=="object")S(t.SQLITE_MISUSE,"Expecting a listener object.");let W=K(T.storage);if(!W)if(T.storage&&T.reserve)Pe(T.storage),W=K(T.storage),h.assert(W,"Unexpectedly cannot fetch reserved storage "+T.storage);else S(t.SQLITE_NOTFOUND,"No such storage:",T.storage);if(T.events)(W.listeners??=[]).push(T)},He=function(T){let W=K(T?.storage);if(W?.listeners&&T.events){let Q=W.listeners.length;W.listeners=W.listeners.filter((se)=>se!==T);let H=Q>W.listeners.length;if(!W.listeners.length)W.listeners=void 0;return H}return!1};if(i.kvvfs.reserve=Pe,i.kvvfs.import=Fe,i.kvvfs.export=qe,i.kvvfs.unlink=Ee,i.kvvfs.listen=Qe,i.kvvfs.unlisten=He,i.kvvfs.exists=(T)=>!!K(T),i.kvvfs.estimateSize=be,i.kvvfs.clear=ce,globalThis.Storage)t.sqlite3_js_kvvfs_size=(T="")=>be(T),t.sqlite3_js_kvvfs_clear=(T="")=>ce(T);if(i.oo1?.DB){let T=i.oo1.DB;i.oo1.JsStorageDb=function(Q=i.oo1.JsStorageDb.defaultStorageName){let H=T.dbCtorHelper.normalizeArgs(...arguments);switch(H.vfs="kvvfs",H.filename){case":sessionStorage:":H.filename="session";break;case":localStorage:":H.filename="local";break}let se=/(file:(\/\/)?)([^?]+)/.exec(H.filename);A(se?se[3]:H.filename),T.dbCtorHelper.call(this,H)},i.oo1.JsStorageDb.defaultStorageName=p.storagePool.session?"session":N;let W=i.oo1.JsStorageDb;W.prototype=Object.create(T.prototype),W.clearStorage=ce,W.prototype.clearStorage=function(){return W.clearStorage(this.affirmOpen().dbFilename(),!0)},W.storageSize=be,W.prototype.storageSize=function(){return W.storageSize(this.affirmOpen().dbFilename(),!0)}}if(i.__isUnderTest&&i.vtab){let T=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(T).forEach((de,ue)=>T[de].colId=ue);let W=i.vtab,Q=Object.assign(Object.create(null),{row:function(){return p.storagePool[this.names[this.rowid]]}});Object.assign(Object.create(Q),{rowid:0,names:Object.keys(p.storagePool).filter((de)=>!p.rxJournalSuffix.test(de))});let H=function(de,ue){let pe=de instanceof t.sqlite3_vtab_cursor?de:W.xCursor.get(de);if(ue||!pe.vTabState)pe.vTabState=Object.assign(Object.create(Q),{rowid:0,names:Object.keys(p.storagePool).filter((Le)=>!p.rxJournalSuffix.test(Le))});return pe.vTabState},se=()=>{},_e=function de(){return de.mod??=new i.capi.sqlite3_module().setupModule({catchExceptions:!0,methods:{xConnect:function(ue,pe,Le,Ce,Ae,De){se("xConnect");try{let Re=[];Object.keys(T).forEach((st)=>{Re.push(st+" "+T[st].type)});let et=t.sqlite3_declare_vtab(ue,"CREATE TABLE ignored("+Re.join(",")+")");if(et===0){let st=W.xVtab.create(Ae);h.assert(st===W.xVtab.get(I.peekPtr(Ae)),"output pointer check failed")}return et}catch(Re){return W.xError("xConnect",Re,t.SQLITE_ERROR)}},xCreate:I.ptr.null,xDisconnect:function(ue){return se("xDisconnect",...arguments),W.xVtab.dispose(ue),0},xOpen:function(ue,pe){return se("xOpen",...arguments),W.xCursor.create(pe),0},xClose:function(ue){se("xClose",...arguments);let pe=W.xCursor.unget(ue);return delete pe.vTabState,pe.dispose(),0},xNext:function(ue){se("xNext",...arguments);let pe=W.xCursor.get(ue);return++H(pe).rowid,0},xColumn:function(ue,pe,Le){se("xColumn",...arguments);let Ce=H(ue),Ae=Ce.row();switch(h.assert(Ae,"Unexpected xColumn call"),Le){case T.rowid.colId:t.sqlite3_result_int(pe,Ce.rowid);break;case T.name.colId:t.sqlite3_result_text(pe,Ae.jzClass,-1,t.SQLITE_TRANSIENT);break;case T.nRef.colId:t.sqlite3_result_int(pe,Ae.refc);break;case T.nOpen.colId:t.sqlite3_result_int(pe,Ae.files.length);break;case T.isTransient.colId:t.sqlite3_result_int(pe,!!Ae.deleteAtRefc0);break;case T.dbSize.colId:t.sqlite3_result_int(pe,O(Ae));break;default:return t.sqlite3_result_error(pe,"Invalid column id: "+Le),t.SQLITE_RANGE}return 0},xRowid:function(ue,pe){se("xRowid",...arguments);let Le=H(ue);return W.xRowid(pe,Le.rowid),0},xEof:function(ue){let pe=H(ue);return se("xEof?="+!pe.row(),...arguments),!pe.row()},xFilter:function(ue,pe,Le,Ce,Ae){se("xFilter",...arguments);let De=H(ue,!0);return 0},xBestIndex:function(ue,pe){se("xBestIndex",...arguments);let Le=new t.sqlite3_index_info(pe);return Le.$estimatedRows=p.storagePool.size,Le.$estimatedCost=1,Le.dispose(),0}}})};i.kvvfs.create_module=function(de,ue="sqlite_kvvfs"){return t.sqlite3_create_module(de,ue,_e(),I.ptr.null)}}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.opfs&&i.config.disable.vfs["opfs-vfs"])return;let t=i.util.toss,{capi:r,util:a,wasm:_}=i,h=i.opfs=Object.create(null);h.thisThreadHasOPFS=()=>globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&navigator?.storage?.getDirectory,h.getRootDir=async function S(){return S.promise??=navigator.storage.getDirectory().then((R)=>(h.rootDirectory=R,R)).catch((R)=>{throw delete S.promise,R})},h.getResolvedPath=function(S,R){let M=new URL(S,"file://irrelevant").pathname;return R?M.split("/").filter((p)=>!!p):M},h.getDirForFilename=async function(R,M=!1){let p=h.getResolvedPath(R,!0),te=p.pop(),j=await h.getRootDir();for(let U of p)if(U)j=await j.getDirectoryHandle(U,{create:!!M});return[j,te]},h.mkdir=async function(S){try{return await h.getDirForFilename(S+"/filepart",!0),!0}catch(R){return!1}},h.entryExists=async function(S){try{let[R,M]=await h.getDirForFilename(S);return await R.getFileHandle(M),!0}catch(R){return!1}},h.randomFilename=function S(R=16){if(!S._chars)S._chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012346789",S._n=S._chars.length;let M=[],p=0;for(;p<R;++p){let te=Math.random()*(S._n*64)%S._n|0;M[p]=S._chars[te]}return M.join("")},h.treeList=async function(){let S=async function p(te,j){j.name=te.name,j.dirs=[],j.files=[];for await(let U of te.values())if(U.kind==="directory"){let E=Object.create(null);j.dirs.push(E),await p(U,E)}else j.files.push(U.name)},R=Object.create(null),M=await h.getRootDir();return await S(M,R),R},h.rmfr=async function(){let R=await h.getRootDir(),M={recurse:!0};for await(let p of R.values())R.removeEntry(p.name,M)},h.unlink=async function(S,R=!1,M=!1){try{let[p,te]=await h.getDirForFilename(S,!1);return await p.removeEntry(te,{recursive:R}),!0}catch(p){if(M)throw Error("unlink(",arguments[0],") failed: "+p.message,{cause:p});return!1}},h.traverse=async function(S){let R={recursive:!0,directory:await h.getRootDir()};if(typeof S==="function")S={callback:S};S=Object.assign(R,S||{}),async function p(te,j){for await(let U of te.values())if(S.callback(U,te,j)===!1)return!1;else if(S.recursive&&U.kind==="directory"){if(await p(U,j+1)===!1)break}}(S.directory,0)};let I=async function(S,R){let[M,p]=await h.getDirForFilename(S,!0),j=await(await M.getFileHandle(p,{create:!0})).createSyncAccessHandle(),U=0,E,b=!1,F=!1;try{j.truncate(0);while((E=await R())!==void 0){if(E instanceof ArrayBuffer)E=new Uint8Array(E);if(!b&&U===0&&E.byteLength>=15)a.affirmDbHeader(E),b=!0;j.write(E,{at:U}),U+=E.byteLength}if(U<512||U%512!==0)t("Input size",U,"is not correct for an SQLite database.");if(!b){let x=new Uint8Array(20);j.read(x,{at:0}),a.affirmDbHeader(x)}return j.write(new Uint8Array([1,1]),{at:18}),U}catch(x){throw await j.close(),j=void 0,await M.removeEntry(p).catch(()=>{}),x}finally{if(j)await j.close()}};h.importDb=async function(S,R){if(R instanceof Function)return I(S,R);if(R instanceof ArrayBuffer)R=new Uint8Array(R);a.affirmIsDb(R);let M=R.byteLength,[p,te]=await h.getDirForFilename(S,!0),j,U,E=0;try{if(j=await(await p.getFileHandle(te,{create:!0})).createSyncAccessHandle(),j.truncate(0),E=j.write(R,{at:0}),E!=M)t("Expected to write "+M+" bytes but wrote "+E+".");return j.write(new Uint8Array([1,1]),{at:18}),E}catch(b){if(j)await j.close(),j=void 0;throw await p.removeEntry(te).catch(()=>{}),b}finally{if(j)await j.close()}},h.vfsInstallationFeatureCheck=function(S){if(!globalThis.SharedArrayBuffer||!globalThis.Atomics)t("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");else if(typeof WorkerGlobalScope>"u")t("The OPFS sqlite3_vfs cannot run in the main thread","because it requires Atomics.wait().");else if(!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle?.prototype?.createSyncAccessHandle||!navigator?.storage?.getDirectory)t("Missing required OPFS APIs.");else if(S==="opfs-wl"&&!globalThis.Atomics.waitAsync)t("The",S,"VFS requires Atomics.waitAsync(), which is not available.")},h.initOptions=function(R,M){let p=new URL(globalThis.location.href).searchParams;if(p.has(R+"-disable"))return;try{h.vfsInstallationFeatureCheck(R)}catch(te){return}if(M=a.nu(M),M.vfsName=R,M.verbose??=p.has("opfs-verbose")?+p.get("opfs-verbose"):1,M.sanityChecks??=p.has("opfs-sanity-check"),!h.proxyUri){if(h.proxyUri="sqlite3-opfs-async-proxy.js",i.scriptInfo?.sqlite3Dir)h.proxyUri=i.scriptInfo.sqlite3Dir+h.proxyUri}if(M.proxyUri??=h.proxyUri,typeof M.proxyUri==="function")M.proxyUri=M.proxyUri();return h.options=M},h.createVfsState=function(){let S=a.nu(),R=h.options;S.verbose=R.verbose;let M=[i.config.error,i.config.warn,i.config.log],p=R.vfsName||t("Maintenance required: missing VFS name"),te=(K,...oe)=>{if(S.verbose>K)M[K](p+":",...oe)},j=(...K)=>te(2,...K),U=(...K)=>te(1,...K),E=(...K)=>te(0,...K),{capi:b,wasm:F}=i,x=S.vfs=new b.sqlite3_vfs,A=x.ioMethods=new b.sqlite3_io_methods;A.$iVersion=1,x.$iVersion=2,x.$szOsFile=b.sqlite3_file.structInfo.sizeof,x.$mxPathname=1024,x.$zName=F.allocCString(p),x.addOnDispose("$zName",x.$zName,A),x.metrics=a.nu({counters:a.nu(),dump:function(){let K,oe=0,u=0,q=0;for(K in S.opIds){let O=D[K];oe+=O.count,u+=O.time,q+=O.wait,O.avgTime=O.count&&O.time?O.time/O.count:0,O.avgWait=O.count&&O.wait?O.wait/O.count:0}i.config.log(globalThis.location.href,"metrics for",globalThis.location.href,":",D,`
3
- Total of`,oe,"op(s) for",u,"ms (incl. "+q+" ms of waiting on the async side)"),i.config.log("Serialization metrics:",x.metrics.counters.s11n),x.worker?.postMessage?.({type:"opfs-async-metrics"})},reset:function(){let K,oe=(O)=>O.count=O.time=O.wait=0,u=x.metrics.counters;for(K in S.opIds)oe(u[K]=Object.create(null));let q=u.s11n=Object.create(null);q=q.serialize=Object.create(null),q.count=q.time=0,q=u.s11n.deserialize=Object.create(null),q.count=q.time=0}}),S.asyncIdleWaitTime=150,S.asyncS11nExceptions=1,S.fileBufferSize=65536,S.sabS11nOffset=S.fileBufferSize,S.sabS11nSize=x.$mxPathname*2,S.sabIO=new SharedArrayBuffer(S.fileBufferSize+S.sabS11nSize),S.opIds=Object.create(null);{let K=0;S.opIds.whichOp=K++,S.opIds.rc=K++,S.opIds.xAccess=K++,S.opIds.xClose=K++,S.opIds.xDelete=K++,S.opIds.xDeleteNoWait=K++,S.opIds.xFileSize=K++,S.opIds.xLock=K++,S.opIds.xOpen=K++,S.opIds.xRead=K++,S.opIds.xSleep=K++,S.opIds.xSync=K++,S.opIds.xTruncate=K++,S.opIds.xUnlock=K++,S.opIds.xWrite=K++,S.opIds.mkdir=K++,S.opIds["opfs-async-metrics"]=K++,S.opIds["opfs-async-shutdown"]=K++,S.opIds.retry=K++,S.sabOP=new SharedArrayBuffer(K*4)}S.sq3Codes=Object.create(null);for(let K 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"])S.sq3Codes[K]=b[K]??t("Maintenance required: not found:",K);S.opfsFlags=Object.assign(Object.create(null),{OPFS_UNLOCK_ASAP:1,OPFS_UNLINK_BEFORE_OPEN:2,defaultUnlockAsap:!1}),x.metrics.reset();let D=x.metrics.counters,z=x.opRun=(K,...oe)=>{let u=S.opIds[K]||t(x.vfsName+": Invalid op ID:",K);S.s11n.serialize(...oe),Atomics.store(S.sabOPView,S.opIds.rc,-1),Atomics.store(S.sabOPView,S.opIds.whichOp,u),Atomics.notify(S.sabOPView,S.opIds.whichOp);let q=performance.now();while(Atomics.wait(S.sabOPView,S.opIds.rc,-1)!=="not-equal");let O=Atomics.load(S.sabOPView,S.opIds.rc);if(D[K].wait+=performance.now()-q,O&&S.asyncS11nExceptions){let V=S.s11n.deserialize();if(V)E(K+"() async error:",...V)}return O},f=Object.create(null);f.op=void 0,f.start=void 0;let w=x.mTimeStart=(K)=>{f.start=performance.now(),f.op=K,++D[K].count},N=x.mTimeEnd=()=>D[f.op].time+=performance.now()-f.start,J=x.__openFiles=Object.create(null),ie=x.ioSyncWrappers=a.nu({xCheckReservedLock:function(K,oe){return F.poke(oe,0,"i32"),0},xClose:function(K){w("xClose");let oe=0,u=J[K];if(u){if(delete J[K],oe=z("xClose",K),u.sq3File)u.sq3File.dispose()}return N(),oe},xDeviceCharacteristics:function(K){return b.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(K,oe,u){return b.SQLITE_NOTFOUND},xFileSize:function(K,oe){w("xFileSize");let u=z("xFileSize",K);if(u==0)try{let q=S.s11n.deserialize()[0];F.poke(oe,q,"i64")}catch(q){E("Unexpected error reading xFileSize() result:",q),u=S.sq3Codes.SQLITE_IOERR}return N(),u},xRead:function(K,oe,u,q){w("xRead");let O=J[K],V;try{if(V=z("xRead",K,u,Number(q)),V===0||b.SQLITE_IOERR_SHORT_READ===V)F.heap8u().set(O.sabView.subarray(0,u),Number(oe))}catch(Z){E("xRead(",arguments,") failed:",Z,O),V=b.SQLITE_IOERR_READ}return N(),V},xSync:function(K,oe){w("xSync");let u=z("xSync",K,oe);return N(),u},xTruncate:function(K,oe){w("xTruncate");let u=z("xTruncate",K,Number(oe));return N(),u},xWrite:function(K,oe,u,q){w("xWrite");let O=J[K],V;try{O.sabView.set(F.heap8u().subarray(Number(oe),Number(oe)+u)),V=z("xWrite",K,u,Number(q))}catch(Z){E("xWrite(",arguments,") failed:",Z,O),V=b.SQLITE_IOERR_WRITE}return N(),V}}),le=x.vfsSyncWrappers={xAccess:function(K,oe,u,q){w("xAccess");let O=z("xAccess",F.cstrToJs(oe));return F.poke(q,O?0:1,"i32"),N(),0},xCurrentTime:function(K,oe){return F.poke(oe,2440587.5+new Date().getTime()/86400000,"double"),0},xCurrentTimeInt64:function(K,oe){return F.poke(oe,210866760000000+new Date().getTime(),"i64"),0},xDelete:function(K,oe,u){w("xDelete");let q=z("xDelete",F.cstrToJs(oe),u,!1);return N(),q},xFullPathname:function(K,oe,u,q){return F.cstrncpy(q,oe,u)<u?0:b.SQLITE_CANTOPEN},xGetLastError:function(K,oe,u){return i.config.warn("OPFS xGetLastError() has nothing sensible to return."),0},xOpen:function(oe,u,q,O,V){w("xOpen");let Z=0,m,y;if(!u)m=h.randomFilename(),u=y=F.allocCString(m);else if(F.isPtr(u)){if(b.sqlite3_uri_boolean(u,"opfs-unlock-asap",0))Z|=S.opfsFlags.OPFS_UNLOCK_ASAP;if(b.sqlite3_uri_boolean(u,"delete-before-open",0))Z|=S.opfsFlags.OPFS_UNLINK_BEFORE_OPEN;m=F.cstrToJs(u)}else return i.config.error("Impossible zName value in xOpen?",u),b.SQLITE_CANTOPEN;let C=a.nu({fid:q,filename:m,sab:new SharedArrayBuffer(S.fileBufferSize),flags:O,readOnly:!(b.SQLITE_OPEN_CREATE&O)&&!!(O&b.SQLITE_OPEN_READONLY)}),c=z("xOpen",q,m,O,Z);if(c){if(y)F.dealloc(y)}else{if(C.readOnly)F.poke(V,b.SQLITE_OPEN_READONLY,"i32");if(J[q]=C,C.sabView=S.sabFileBufView,C.sq3File=new b.sqlite3_file(q),y)C.sq3File.addOnDispose(y);C.sq3File.$pMethods=A.pointer,C.lockType=b.SQLITE_LOCK_NONE}return N(),c}},we=b.sqlite3_vfs_find(null);if(we){let K=new b.sqlite3_vfs(we);x.$xRandomness=K.$xRandomness,x.$xSleep=K.$xSleep,K.dispose()}if(!x.$xRandomness)x.vfsSyncWrappers.xRandomness=function(K,oe,u){let q=F.heap8u(),O=0,V=Number(u);for(;O<oe;++O)q[V+O]=Math.random()*255000&255;return O};if(!x.$xSleep)x.vfsSyncWrappers.xSleep=function(K,oe){return w("xSleep"),Atomics.wait(S.sabOPView,S.opIds.xSleep,0,oe),N(),0};let me=function(){if(S.s11n)return S.s11n;let K=new TextDecoder,oe=new TextEncoder("utf-8"),u=new Uint8Array(S.sabIO,S.sabS11nOffset,S.sabS11nSize),q=new DataView(S.sabIO,S.sabS11nOffset,S.sabS11nSize);S.s11n=Object.create(null);let O=Object.create(null);O.number={id:1,size:8,getter:"getFloat64",setter:"setFloat64"},O.bigint={id:2,size:8,getter:"getBigInt64",setter:"setBigInt64"},O.boolean={id:3,size:4,getter:"getInt32",setter:"setInt32"},O.string={id:4};let V=(m)=>O[typeof m]||t("Maintenance required: this value type cannot be serialized.",m),Z=(m)=>{switch(m){case O.number.id:return O.number;case O.bigint.id:return O.bigint;case O.boolean.id:return O.boolean;case O.string.id:return O.string;default:t("Invalid type ID:",m)}};return S.s11n.deserialize=function(m=!1){let y=performance.now(),C=u[0],c=C?[]:null;if(C){let d=[],L=1,G,B,ae;for(G=0;G<C;++G,++L)d.push(Z(u[L]));for(G=0;G<C;++G){let ce=d[G];if(ce.getter)ae=q[ce.getter](L,S.littleEndian),L+=ce.size;else B=q.getInt32(L,S.littleEndian),L+=4,ae=K.decode(u.slice(L,L+B)),L+=B;c.push(ae)}}if(m)u[0]=0;return c},S.s11n.serialize=function(...m){let y=performance.now();if(m.length){let C=[],c=0,d=1;u[0]=m.length&255;for(;c<m.length;++c,++d)C.push(V(m[c])),u[d]=C[c].id;for(c=0;c<m.length;++c){let L=C[c];if(L.setter)q[L.setter](d,m[c],S.littleEndian),d+=L.size;else{let G=oe.encode(m[c]);q.setInt32(d,G.byteLength,S.littleEndian),d+=4,u.set(G,d),d+=G.byteLength}}}else u[0]=0},S.s11n};return x.initS11n=me,x.bindVfs=function(K,oe){return Object.assign(x.ioSyncWrappers,K),new Promise(function(q,O){let V=void 0,Z=(B)=>(V=!0,x.dispose(),O(B)),m=()=>{try{oe(i,x)}catch(B){return Z(B)}return V=!1,q(i)},y=h.options,C=y.proxyUri+(y.proxyUri.indexOf("?")<0?"?":"&")+"vfs="+p,c=x.worker=new Worker(new URL(C,import.meta.url)),d=setTimeout(()=>{if(V===void 0)Z(Error("Timeout while waiting for OPFS async proxy worker."))},4000);c._originalOnError=c.onerror,c.onerror=function(B){E("Error initializing OPFS asyncer:",B),Z(Error("Loading OPFS async Worker failed for unknown reasons."))};let L=x.opRun,G=function(){let B=F.scopedAllocPush(),ae=new b.sqlite3_file;try{let ce=ae.pointer,be=b.SQLITE_OPEN_CREATE|b.SQLITE_OPEN_READWRITE|b.SQLITE_OPEN_MAIN_DB,qe=F.scopedAlloc(8),Fe="/sanity/check/file"+h.randomFilename(8),Pe=F.scopedAllocCString(Fe),Ee;if(S.s11n.serialize("This is ä string."),Ee=S.s11n.deserialize(),j("deserialize() says:",Ee),Ee[0]!=="This is ä string.")t("String d13n error.");if(x.vfsSyncWrappers.xAccess(x.pointer,Pe,0,qe),Ee=F.peek(qe,"i32"),j("xAccess(",Fe,") exists ?=",Ee),Ee=x.vfsSyncWrappers.xOpen(x.pointer,Pe,ce,be,qe),j("open rc =",Ee,"state.sabOPView[xOpen] =",S.sabOPView[S.opIds.xOpen]),Ee!==0){E("open failed with code",Ee);return}if(x.vfsSyncWrappers.xAccess(x.pointer,Pe,0,qe),Ee=F.peek(qe,"i32"),!Ee)t("xAccess() failed to detect file.");if(Ee=x.ioSyncWrappers.xSync(ae.pointer,0),Ee)t("sync failed w/ rc",Ee);if(Ee=x.ioSyncWrappers.xTruncate(ae.pointer,1024),Ee)t("truncate failed w/ rc",Ee);if(F.poke(qe,0,"i64"),Ee=x.ioSyncWrappers.xFileSize(ae.pointer,qe),Ee)t("xFileSize failed w/ rc",Ee);if(j("xFileSize says:",F.peek(qe,"i64")),Ee=x.ioSyncWrappers.xWrite(ae.pointer,Pe,10,1),Ee)t("xWrite() failed!");let Qe=F.scopedAlloc(16);Ee=x.ioSyncWrappers.xRead(ae.pointer,Qe,6,2),F.poke(Qe+6,0);let He=F.cstrToJs(Qe);if(j("xRead() got:",He),He!=="sanity")t("Unexpected xRead() value.");if(x.vfsSyncWrappers.xSleep)j("xSleep()ing before close()ing..."),x.vfsSyncWrappers.xSleep(x.pointer,2000),j("waking up from xSleep()");if(Ee=x.ioSyncWrappers.xClose(ce),j("xClose rc =",Ee,"sabOPView =",S.sabOPView),j("Deleting file:",Fe),x.vfsSyncWrappers.xDelete(x.pointer,Pe,4660),x.vfsSyncWrappers.xAccess(x.pointer,Pe,0,qe),Ee=F.peek(qe,"i32"),Ee)t("Expecting 0 from xAccess(",Fe,") after xDelete().");U("End of OPFS sanity checks.")}finally{ae.dispose(),F.scopedAllocPop(B)}};c.onmessage=function({data:B}){switch(B.type){case"opfs-unavailable":Z(Error(B.payload.join(" ")));break;case"opfs-async-loaded":delete S.vfs,c.postMessage({type:"opfs-async-init",args:a.nu(S)});break;case"opfs-async-inited":{if(V===!0)break;clearTimeout(d),d=null;try{if(i.vfs.installVfs({io:{struct:x.ioMethods,methods:x.ioSyncWrappers},vfs:{struct:x,methods:x.vfsSyncWrappers}}),S.sabOPView=new Int32Array(S.sabOP),S.sabFileBufView=new Uint8Array(S.sabIO,0,S.fileBufferSize),S.sabS11nView=new Uint8Array(S.sabIO,S.sabS11nOffset,S.sabS11nSize),x.initS11n(),x.initS11n=null,y.sanityChecks)U("Running sanity checks because of opfs-sanity-check URL arg..."),G();if(h.thisThreadHasOPFS())h.getRootDir().then((ae)=>{c.onerror=c._originalOnError,delete c._originalOnError,j("End of OPFS sqlite3_vfs setup.",x),m()}).catch(Z);else m()}catch(ae){E(ae),Z(ae)}break}case"debug":U("debug message from worker:",B);break;default:{let ae="Unexpected message from the OPFS async worker: "+JSON.stringify(B);E(ae),Z(Error(ae));break}}}})},S}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.opfs||i.config.disable?.vfs?.opfs)return;let t=i.util,r=i.opfs||i.util.toss("Missing sqlite3.opfs"),a=async function(_){if(_=r.initOptions("opfs",_),!_)return i;let h=i.capi,I=r.createVfsState(),S=I.vfs,R=S.metrics.counters,{mTimeStart:M,mTimeEnd:p,opRun:te}=S,j=(...b)=>i.config.debug("opfs:",...b),U=(...b)=>i.config.warn("opfs:",...b),E=S.__openFiles;return S.bindVfs(t.nu({xLock:function(b,F){M("xLock"),++R.xLock.count;let x=E[b],A=0;if(x.lockType)x.lockType=F;else if(A=te("xLock",b,F),A===0)x.lockType=F;return p(),A},xUnlock:function(b,F){M("xUnlock"),++R.xUnlock.count;let x=E[b],A=0;if(h.SQLITE_LOCK_NONE===F&&x.lockType)A=te("xUnlock",b,F);if(A===0)x.lockType=F;return p(),A}}),function(b,F){if(b.oo1){let x=function(...A){let D=b.oo1.DB.dbCtorHelper.normalizeArgs(...A);D.vfs=F.$zName,b.oo1.DB.dbCtorHelper.call(this,D)};x.prototype=Object.create(b.oo1.DB.prototype),b.oo1.OpfsDb=x,x.importDb=r.importDb,b.oo1.DB.dbCtorHelper.setVfsPostOpenCallback(S.pointer,function(A,D){D.capi.sqlite3_busy_timeout(A,1e4)})}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async(_)=>a().catch((h)=>{_.config.warn("Ignoring inability to install 'opfs' sqlite3_vfs:",h)}))}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.["opfs-sahpool"])return;let t=i.util.toss,r=i.util.toss3,a=Object.create(null),{capi:_,util:h,wasm:I}=i,S=4096,R=512,M=4,p=8,te=R+M,j=R,U=te,E=S,b=_.SQLITE_OPEN_MAIN_DB|_.SQLITE_OPEN_MAIN_JOURNAL|_.SQLITE_OPEN_SUPER_JOURNAL|_.SQLITE_OPEN_WAL,F=_.SQLITE_OPEN_MEMORY,x=".opaque",A=()=>Math.random().toString(36).slice(2),D=new TextDecoder,z=new TextEncoder,f=Object.assign(Object.create(null),{name:"opfs-sahpool",directory:void 0,initialCapacity:6,clearOnInit:!1,verbosity:2,forceReinitIfPreviouslyFailed:!1,preserveOnInitFailure:!1}),w=[i.config.error,i.config.warn,i.config.log],N=i.config.log,J=i.config.warn,ie=i.config.error,le=new Map,we=(c)=>le.get(c),me=(c,d)=>{if(d)le.set(c,d);else le.delete(c)},K=new Map,oe=(c)=>K.get(c),u=(c,d)=>{if(d)K.set(c,d);else K.delete(c)},q={xCheckReservedLock:function(c,d){let L=oe(c);L.log("xCheckReservedLock"),L.storeErr();let G=L.getOFileForS3File(c);return I.poke32(d,L.hasReservedLock(G.path)?1:0),0},xClose:function(c){let d=oe(c);d.storeErr();let L=d.getOFileForS3File(c);if(L)try{if(d.log(`xClose ${L.path}`),d.unlockFile(L,_.SQLITE_LOCK_NONE),d.mapS3FileToOFile(c,!1),L.sah.flush(),L.flags&_.SQLITE_OPEN_DELETEONCLOSE)d.deletePath(L.path)}catch(G){return d.storeErr(G,_.SQLITE_IOERR)}return 0},xDeviceCharacteristics:function(c){return _.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(c,d,L){return _.SQLITE_NOTFOUND},xFileSize:function(c,d){let L=oe(c);L.log("xFileSize");let B=L.getOFileForS3File(c).sah.getSize()-E;return I.poke64(d,BigInt(B)),0},xLock:function(c,d){let L=oe(c);L.log(`xLock ${d}`),L.storeErr();let G=L.getOFileForS3File(c);return L.lockFile(G,d)},xRead:function(c,d,L,G){let B=oe(c);B.storeErr();let ae=B.getOFileForS3File(c);B.log(`xRead ${ae.path} ${L} @ ${G}`);try{let ce=ae.sah.read(I.heap8u().subarray(Number(d),Number(d)+L),{at:E+Number(G)});if(ce<L)return I.heap8u().fill(0,Number(d)+ce,Number(d)+L),_.SQLITE_IOERR_SHORT_READ;return 0}catch(ce){return B.storeErr(ce,_.SQLITE_IOERR)}},xSectorSize:function(c){return S},xSync:function(c,d){let L=oe(c);L.log(`xSync ${d}`),L.storeErr();let G=L.getOFileForS3File(c);try{return G.sah.flush(),0}catch(B){return L.storeErr(B,_.SQLITE_IOERR)}},xTruncate:function(c,d){let L=oe(c);L.log(`xTruncate ${d}`),L.storeErr();let G=L.getOFileForS3File(c);try{return G.sah.truncate(E+Number(d)),0}catch(B){return L.storeErr(B,_.SQLITE_IOERR)}},xUnlock:function(c,d){let L=oe(c);L.log("xUnlock");let G=L.getOFileForS3File(c);return L.unlockFile(G,d),0},xWrite:function(c,d,L,G){let B=oe(c);B.storeErr();let ae=B.getOFileForS3File(c);B.log(`xWrite ${ae.path} ${L} ${G}`);try{let ce=ae.sah.write(I.heap8u().subarray(Number(d),Number(d)+L),{at:E+Number(G)});return L===ce?0:t("Unknown write() failure.")}catch(ce){return B.storeErr(ce,_.SQLITE_IOERR)}}},O=new _.sqlite3_io_methods;O.$iVersion=1,i.vfs.installVfs({io:{struct:O,methods:q}});let V={xAccess:function(c,d,L,G){let B=we(c);B.storeErr();try{let ae=B.getPath(d);I.poke32(G,B.hasFilename(ae)?1:0)}catch(ae){I.poke32(G,0)}return 0},xCurrentTime:function(c,d){return I.poke(d,2440587.5+new Date().getTime()/86400000,"double"),0},xCurrentTimeInt64:function(c,d){return I.poke(d,210866760000000+new Date().getTime(),"i64"),0},xDelete:function(c,d,L){let G=we(c);G.log(`xDelete ${I.cstrToJs(d)}`),G.storeErr();try{return G.deletePath(G.getPath(d)),0}catch(B){return G.storeErr(B),_.SQLITE_IOERR_DELETE}},xFullPathname:function(c,d,L,G){return I.cstrncpy(G,d,L)<L?0:_.SQLITE_CANTOPEN},xGetLastError:function(c,d,L){let G=we(c),B=G.popErr();if(G.log(`xGetLastError ${d} e =`,B),B){let ae=I.scopedAllocPush();try{let[ce,be]=I.scopedAllocCString(B.message,!0);if(I.cstrncpy(L,ce,d),be>d)I.poke8(I.ptr.add(L,d,-1),0)}catch(ce){return _.SQLITE_NOMEM}finally{I.scopedAllocPop(ae)}}return B?B.sqlite3Rc||_.SQLITE_IOERR:0},xOpen:function(d,L,G,B,ae){let ce=we(d);try{B&=~F,ce.log(`xOpen ${I.cstrToJs(L)} ${B}`);let be=L&&I.peek8(L)?ce.getPath(L):A(),qe=ce.getSAHForPath(be);if(qe&&B&_.SQLITE_OPEN_CREATE&&B&_.SQLITE_OPEN_EXCLUSIVE)t("file already exists:",be);if(!qe&&B&_.SQLITE_OPEN_CREATE)if(ce.getFileCount()<ce.getCapacity())qe=ce.nextAvailableSAH(),ce.setAssociatedPath(qe,be,B);else t("SAH pool is full. Cannot create file",be);if(!qe)t("file not found:",be);let Fe={path:be,flags:B,sah:qe};ce.mapS3FileToOFile(G,Fe),Fe.lockType=_.SQLITE_LOCK_NONE;let Pe=new _.sqlite3_file(G);return Pe.$pMethods=O.pointer,Pe.dispose(),I.poke32(ae,B),0}catch(be){return ce.storeErr(be),_.SQLITE_CANTOPEN}}},Z=function(c){if(i.capi.sqlite3_vfs_find(c))r("VFS name is already registered:",c);let d=new _.sqlite3_vfs,L=_.sqlite3_vfs_find(null),G=L?new _.sqlite3_vfs(L):null;if(d.$iVersion=2,d.$szOsFile=_.sqlite3_file.structInfo.sizeof,d.$mxPathname=R,d.addOnDispose(d.$zName=I.allocCString(c),()=>me(d.pointer,0)),G)d.$xRandomness=G.$xRandomness,G.dispose();if(!d.$xRandomness&&!V.xRandomness)V.xRandomness=function(B,ae,ce){let be=I.heap8u(),qe=0,Fe=Number(ce);for(;qe<ae;++qe)be[Fe+qe]=Math.random()*255000&255;return qe};return V.xSleep=(B,ae)=>0,i.vfs.installVfs({vfs:{struct:d,methods:V}}),d};class m{vfsDir;#e;#i;#s;#t=new Map;#n=new Map;#o=new Set;#c=new Map;#l=new Map;#r=new Uint8Array(te);#_;#a;#f;constructor(c=Object.create(null)){this.#f=c.verbosity??f.verbosity,this.vfsName=c.name||f.name,this.#a=Z(this.vfsName),me(this.#a.pointer,this),this.vfsDir=c.directory||"."+this.vfsName,this.#_=new DataView(this.#r.buffer,this.#r.byteOffset),this.isReady=this.reset(!!(c.clearOnInit??f.clearOnInit)).then(()=>{if(this.$error)throw this.$error;return this.getCapacity()?Promise.resolve(void 0):this.addCapacity(c.initialCapacity||f.initialCapacity)})}#u(c,...d){if(this.#f>c)w[c](this.vfsName+":",...d)}log(...c){this.#u(2,...c)}warn(...c){this.#u(1,...c)}error(...c){this.#u(0,...c)}getVfs(){return this.#a}getCapacity(){return this.#t.size}getFileCount(){return this.#n.size}getFileNames(){let c=[];for(let d of this.#n.keys())c.push(d);return c}async addCapacity(c){for(let d=0;d<c;++d){let L=A(),B=await(await this.#i.getFileHandle(L,{create:!0})).createSyncAccessHandle();this.#t.set(B,L),this.setAssociatedPath(B,"",0)}return this.getCapacity()}async reduceCapacity(c){if(!Number.isSafeInteger(c)||c<0)t("Invalid capacity reduction:",c);let d=0;for(let L of Array.from(this.#o)){if(d===c||this.getFileCount()===this.getCapacity())break;let G=this.#t.get(L);L.close(),this.#t.delete(L),this.#o.delete(L),await this.#i.removeEntry(G),++d}return d}releaseAccessHandles(){for(let c of this.#t.keys())c.close();this.#t.clear(),this.#n.clear(),this.#o.clear(),this.#c.clear(),this.#l.clear()}async acquireAccessHandles(c=!1){let d=[];for await(let[B,ae]of this.#i)if(ae.kind==="file")d.push([B,ae]);let G=(await Promise.allSettled(d.map(async([B,ae])=>{let ce=await ae.createSyncAccessHandle();if(this.#t.set(ce,B),c)ce.truncate(E),this.setAssociatedPath(ce,"",0);else{let be=this.getAssociatedPath(ce);if(be)this.#n.set(be,ce);else this.#o.add(ce)}}))).find((B)=>B.status==="rejected");if(G)throw this.storeErr(G.reason),this.releaseAccessHandles(),G.reason}getAssociatedPath(c){c.read(this.#r,{at:0});let d=this.#_.getUint32(j);if(this.#r[0]&&(d&_.SQLITE_OPEN_DELETEONCLOSE||(d&b)===0))return J(`Removing file with unexpected flags ${d.toString(16)}`,this.#r),this.setAssociatedPath(c,"",0),"";let L=new Uint32Array(p/4);c.read(L,{at:U});let G=this.computeDigest(this.#r,d);if(L.every((B,ae)=>B===G[ae])){let B=this.#r.findIndex((ae)=>ae===0);if(B===0)c.truncate(E);return B?D.decode(this.#r.subarray(0,B)):""}else return J("Disassociating file with bad digest."),this.setAssociatedPath(c,"",0),""}setAssociatedPath(c,d,L){let G=z.encodeInto(d,this.#r);if(R<=G.written+1)t("Path too long:",d);if(d&&L)L|=F;this.#r.fill(0,G.written,R),this.#_.setUint32(j,L);let B=this.computeDigest(this.#r,L);if(c.write(this.#r,{at:0}),c.write(B,{at:U}),c.flush(),d)this.#n.set(d,c),this.#o.delete(c);else c.truncate(E),this.#o.add(c)}computeDigest(c,d){if(d&F){let L=3735928559,G=1103547991;for(let B of c)L=Math.imul(L^B,2654435761),G=Math.imul(G^B,104729);return new Uint32Array([L>>>0,G>>>0])}else return new Uint32Array([0,0])}async reset(c){await this.isReady;let d=await navigator.storage.getDirectory(),L,G;for(let B of this.vfsDir.split("/"))if(B)L=d,d=await d.getDirectoryHandle(B,{create:!0});return this.#e=d,this.#s=L,this.#i=await this.#e.getDirectoryHandle(x,{create:!0}),this.releaseAccessHandles(),this.acquireAccessHandles(c)}getPath(c){if(I.isPtr(c))c=I.cstrToJs(c);return(c instanceof URL?c:new URL(c,"file://localhost/")).pathname}deletePath(c){let d=this.#n.get(c);if(d)this.#n.delete(c),this.setAssociatedPath(d,"",0);return!!d}storeErr(c,d){if(c)c.sqlite3Rc=d||_.SQLITE_IOERR,this.error(c);return this.$error=c,d}popErr(){let c=this.$error;return this.$error=void 0,c}nextAvailableSAH(){let[c]=this.#o.keys();return c}getOFileForS3File(c){return this.#c.get(c)}mapS3FileToOFile(c,d){if(d)this.#c.set(c,d),u(c,this);else this.#c.delete(c),u(c,!1)}hasFilename(c){return this.#n.has(c)}getSAHForPath(c){return this.#n.get(c)}async removeVfs(){if(!this.#a.pointer||!this.#i)return!1;_.sqlite3_vfs_unregister(this.#a.pointer),this.#a.dispose(),delete a[this.vfsName];try{this.releaseAccessHandles(),await this.#e.removeEntry(x,{recursive:!0}),this.#i=void 0,await this.#s.removeEntry(this.#e.name,{recursive:!0}),this.#e=this.#s=void 0}catch(c){i.config.error(this.vfsName,"removeVfs() failed with no recovery strategy:",c)}return!0}pauseVfs(){if(this.#c.size>0)i.SQLite3Error.toss(_.SQLITE_MISUSE,"Cannot pause VFS",this.vfsName,"because it has opened files.");if(this.#t.size>0)_.sqlite3_vfs_unregister(this.vfsName),this.releaseAccessHandles();return this}isPaused(){return this.#t.size===0}async unpauseVfs(){if(this.#t.size===0)return this.acquireAccessHandles(!1).then(()=>_.sqlite3_vfs_register(this.#a,0),this);return this}exportFile(c){let d=this.#n.get(c)||t("File not found:",c),L=d.getSize()-E,G=new Uint8Array(L>0?L:0);if(L>0){let B=d.read(G,{at:E});if(B!=L)t("Expected to read "+L+" bytes but read "+B+".")}return G}async importDbChunked(c,d){let L=this.#n.get(c)||this.nextAvailableSAH()||t("No available handles to import to.");L.truncate(0);let G=0,B,ae=!1,ce=!1;try{while((B=await d())!==void 0){if(B instanceof ArrayBuffer)B=new Uint8Array(B);if(!ae&&G===0&&B.byteLength>=15)h.affirmDbHeader(B),ae=!0;let be=L.write(B,{at:E+G});if(be!==B.byteLength)t("Expected to write "+B.byteLength+"bytes but wrote"+be+".");G+=B.byteLength}if(G<512||G%512!==0)t("Input size",G,"is not correct for an SQLite database.");if(!ae){let be=new Uint8Array(20);L.read(be,{at:E}),h.affirmDbHeader(be)}L.write(new Uint8Array([1,1]),{at:E+18})}catch(be){throw this.setAssociatedPath(L,"",0),be}return this.setAssociatedPath(L,c,_.SQLITE_OPEN_MAIN_DB),G}importDb(c,d){if(d instanceof ArrayBuffer)d=new Uint8Array(d);else if(d instanceof Function)return this.importDbChunked(c,d);h.affirmIsDb(d);let L=this.#n.get(c)||this.nextAvailableSAH()||t("No available handles to import to."),G=d.byteLength,B=L.write(d,{at:E});if(B!=G)this.setAssociatedPath(L,"",0),t("Expected to write "+G+" bytes but wrote "+B+".");else L.truncate(E+G),L.write(new Uint8Array([1,1]),{at:E+18}),this.setAssociatedPath(L,c,_.SQLITE_OPEN_MAIN_DB);return B}hasReservedLock(c){let d=this.#l.get(c);return!!d&&d.lockType>_.SQLITE_LOCK_SHARED}lockFile(c,d){if(c.lockType>=d)return 0;let L=this.#l.get(c.path);if(!L)L=Object.assign(Object.create(null),{nShared:0,lockType:_.SQLITE_LOCK_NONE}),this.#l.set(c.path,L);if(c.lockType!==L.lockType&&(L.lockType>=_.SQLITE_LOCK_PENDING||d>_.SQLITE_LOCK_SHARED))return _.SQLITE_BUSY;if(d===_.SQLITE_LOCK_SHARED){if(++L.nShared,L.lockType===_.SQLITE_LOCK_NONE)L.lockType=d}else if(d===_.SQLITE_LOCK_EXCLUSIVE&&L.nShared>1){if(c.lockType===_.SQLITE_LOCK_RESERVED)c.lockType=L.lockType=_.SQLITE_LOCK_PENDING;return _.SQLITE_BUSY}else L.lockType=d;return c.lockType=d,0}unlockFile(c,d){if(c.lockType<=d)return;let L=this.#l.get(c.path);if(c.lockType>_.SQLITE_LOCK_SHARED)L.lockType=_.SQLITE_LOCK_SHARED;if(d===_.SQLITE_LOCK_NONE&&--L.nShared===0)this.#l.delete(c.path);c.lockType=d}}class y{#e;constructor(c){this.#e=c,this.vfsName=c.vfsName}async addCapacity(c){return this.#e.addCapacity(c)}async reduceCapacity(c){return this.#e.reduceCapacity(c)}getCapacity(){return this.#e.getCapacity(this.#e)}getFileCount(){return this.#e.getFileCount()}getFileNames(){return this.#e.getFileNames()}async reserveMinimumCapacity(c){let d=this.#e.getCapacity();return d<c?this.#e.addCapacity(c-d):d}exportFile(c){return this.#e.exportFile(c)}importDb(c,d){return this.#e.importDb(c,d)}async wipeFiles(){return this.#e.reset(!0)}unlink(c){return this.#e.deletePath(c)}async removeVfs(){return this.#e.removeVfs()}pauseVfs(){return this.#e.pauseVfs(),this}async unpauseVfs(){return this.#e.unpauseVfs().then(()=>this)}isPaused(){return this.#e.isPaused()}}let C=async()=>{let c=await navigator.storage.getDirectory(),d=".opfs-sahpool-sync-check-"+A(),B=(await(await c.getFileHandle(d,{create:!0})).createSyncAccessHandle()).close();if(await B,await c.removeEntry(d),B?.then)t("The local OPFS API is too old for opfs-sahpool:","it has an async FileSystemSyncAccessHandle.close() method.");return!0};i.installOpfsSAHPoolVfs=async function(c=Object.create(null)){c=Object.assign(Object.create(null),f,c||{});let d=c.name;if(c.$testThrowPhase1)throw c.$testThrowPhase1;if(a[d])try{return await a[d]}catch(G){if(c.forceReinitIfPreviouslyFailed)delete a[d];else throw G}if(!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle||!navigator?.storage?.getDirectory)return a[d]=Promise.reject(Error("Missing required OPFS APIs."));let L=(G)=>{let B=G.getVfs();if(B?.pointer)_.sqlite3_vfs_unregister(B.pointer),B.dispose(),G.releaseAccessHandles()};return a[d]=C().then(async function(){if(c.$testThrowPhase2)throw c.$testThrowPhase2;let G=new m(c);return G.isReady.then(async()=>{let B=new y(G);if(i.oo1){let ae=i.oo1,ce=G.getVfs(),be=function(...qe){let Fe=ae.DB.dbCtorHelper.normalizeArgs(...qe);Fe.vfs=ce.$zName,ae.DB.dbCtorHelper.call(this,Fe)};be.prototype=Object.create(ae.DB.prototype),B.OpfsSAHPoolDb=be}return G.log("VFS initialized."),B}).catch(async(B)=>{if(c.preserveOnInitFailure)L(G);else await G.removeVfs().catch(()=>{});throw B})}).catch((G)=>a[d]=Promise.reject(G))}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.opfs||i.config.disable?.vfs?.["opfs-wl"])return;let t=i.util,r=i.util.toss,a=i.opfs,_="opfs-wl",h=async function(I){if(I=a.initOptions(_,I),!I)return i;let S=i.capi,R=a.createVfsState(),M=R.vfs,p=M.metrics.counters,{mTimeStart:te,mTimeEnd:j,opRun:U}=M,E=(...x)=>i.config.debug(_+":",...x),b=(...x)=>i.config.warn(_+":",...x),F=M.__openFiles;return M.bindVfs(t.nu({xLock:function(x,A){te("xLock");let D=F[x],z=U("xLock",x,A);if(!z)D.lockType=A;return j(),z},xUnlock:function(x,A){te("xUnlock");let D=F[x],z=U("xUnlock",x,A);if(!z)D.lockType=A;return j(),z}}),function(x,A){if(x.oo1){let D=function(...z){let f=x.oo1.DB.dbCtorHelper.normalizeArgs(...z);f.vfs=A.$zName,x.oo1.DB.dbCtorHelper.call(this,f)};D.prototype=Object.create(x.oo1.DB.prototype),x.oo1.OpfsWlDb=D,D.importDb=a.importDb}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async(I)=>h().catch((S)=>{I.config.warn("Ignoring inability to install the",_,"sqlite3_vfs:",S)}))});try{let i=Object.assign(Object.create(null),{memory:typeof Ze<"u"?Ze:n.wasmMemory,exports:typeof gt<"u"?gt:Object.prototype.hasOwnProperty.call(n,"wasmExports")?n.wasmExports:n.asm},globalThis.sqlite3ApiBootstrap.defaultConfig,globalThis.sqlite3ApiConfig||{});e.debugModule("Bootstrapping lib config",i);let t=globalThis.sqlite3ApiBootstrap(i);return delete globalThis.sqlite3ApiBootstrap,t}catch(i){throw console.error("sqlite3ApiBootstrap() error:",i),i}},s}var Vc,Tn;var On=jc(()=>{Vc=function(){let g=Bt;if(!g)throw Error("Expecting sqlite3InitModule to be defined by the Emscripten build.");let s=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(s.debugModule=s.urlParams.has("sqlite3.debugModule")?(...ne)=>console.warn("sqlite3.debugModule:",...ne):()=>{},s.urlParams.has("sqlite3.dir"))s.sqlite3Dir=s.urlParams.get("sqlite3.dir")+"/";else if(s.moduleScript){let ne=s.moduleScript.src.split("/");ne.pop(),s.sqlite3Dir=ne.join("/")+"/"}let Y=globalThis.sqlite3InitModule=function ne(...ge){return s.emscriptenLocateFile=ge[0]?.locateFile,s.emscriptenInstantiateWasm=ge[0]?.instantiateWasm,g(...ge).then((Se)=>{s.debugModule("sqlite3InitModule() sIMS =",s),s.debugModule("sqlite3InitModule() EmscriptenModule =",Se);let Me=Se.runSQLite3PostLoadInit(s,Se,!!ne.__isUnderTest);return s.debugModule("sqlite3InitModule() sqlite3 =",Me),Me}).catch((Se)=>{throw console.error("Exception loading sqlite3 module:",Se),Se})};if(Y.ready=g.ready,s.moduleScript){let ne=s.moduleScript.src.split("/");ne.pop(),s.scriptDir=ne.join("/")+"/"}return s.debugModule("extern-post-js.c-pp.js sqlite3InitModuleState =",s),Y}();Bt=Vc;Tn=Bt});var En=Promise.resolve();function Wc(){return typeof Bun>"u"?null:Bun.fetch}function zc(g){if(typeof g==="string")return g;return g instanceof URL?g.href:g.url}function Bc(g,s){return Object.assign((Y,ne)=>zc(Y).startsWith("file:")?g(Y,ne):s(Y,ne),{preconnect:s.preconnect})}function Wt(g){let s=Wc();if(!s)return g();let Y=En.then(async()=>{let ne=globalThis.fetch;globalThis.fetch=Bc(s,ne);try{return await g()}finally{globalThis.fetch=ne}});return En=Y.then(()=>{return},()=>{return}),Y}function Uc(g,s){let Y=Reflect.get(g.capi,"sqlite3mc_vfs_create");if(typeof Y!=="function")return null;let ne=Reflect.apply(Y,g.capi,[s,0]);return typeof ne==="number"?ne:null}function kn(g,s){let Y=new Set(g.capi.sqlite3_js_vfs_list()),ne=Uc(g,s);if(ne===null)throw Error("Persistent storage requested but the SQLite build does not provide sqlite3mc_vfs_create.");if(ne!==0)throw Error(`Failed to create the multiple-ciphers VFS over ${s} (rc=${ne}).`);let ge=g.capi.sqlite3_js_vfs_list().filter((Me)=>!Y.has(Me)),Se=ge.find((Me)=>Me.includes(s))??ge[0];if(!Se)throw Error("The multiple-ciphers VFS was created but could not be located in the VFS list.");return Se}function An(g,s){let Y=Reflect.get(g.capi,"sqlite3mc_vfs_destroy");if(typeof Y!=="function")throw Error("The SQLite build does not provide sqlite3mc_vfs_destroy.");Reflect.apply(Y,g.capi,[s])}var St=8000;class Tt extends Error{constructor(g){super(g);this.name="SahPoolStepTimeoutError"}}function wt(g,s){g.catch(()=>{});let Y;return Promise.race([g,new Promise((ne,ge)=>{Y=setTimeout(()=>{ge(new Tt(`SAHPool handle acquisition did not settle within ${s}ms (likely a hung createSyncAccessHandle under OPFS handle-cap contention).`))},s)})]).finally(()=>{clearTimeout(Y)})}var In="tearleads-opfs-sahpool",xn="/tearleads-sqlite";function Qc(g){let s=g.trim().replace(/^\/+/u,"").replace(/[^a-zA-Z0-9_.-]+/gu,"_").replace(/^_+/u,""),Y=s.length;while(Y>0&&s[Y-1]==="_")Y-=1;let ne=s.slice(0,Y);return!ne||ne==="."||ne===".."?"default":ne}function zt(g){let s=Qc(g);return{directory:`/tearleads-sqlite/${s}`,vfsName:`tearleads-opfs-sahpool-${s}`}}var Hc=["Missing SharedArrayBuffer and/or Atomics","The OPFS sqlite3_vfs cannot run in the main thread"],Pn=Symbol.for("tearleads.sqliteWorker.autoOpfsVfsWarnFilterInstalled");function Fn(g){if(typeof g==="string")return g;if(g instanceof Error)return g.message;if(typeof g==="object"&&g!==null){let s=Reflect.get(g,"message");if(typeof s==="string")return s}try{return String(g)}catch{return"[Object]"}}function Gc(g){return Hc.some((s)=>g.includes(s))}function Ln(g){if(g.length===0)return!1;let s=Fn(g[0]),Y=g.map(Fn).join(" ");return(s==="Ignoring inability to install OPFS sqlite3_vfs:"||s.includes("Ignoring inability to install OPFS sqlite3_vfs:"))&&Gc(Y)}function Cn(){if(Reflect.get(console,Pn)===!0||typeof console.warn!=="function")return;let g=console.warn;Reflect.set(console,"warn",(...Y)=>{if(Ln(Y))return;Reflect.apply(g,console,Y)}),Reflect.set(console,Pn,!0)}function Kc(g){let s=typeof g==="object"&&g!==null?g:void 0,Y=s?Reflect.get(s,"warn"):void 0,ne=(...ge)=>{if(Ln(ge))return;if(typeof Y==="function"){Reflect.apply(Y,s??globalThis,ge);return}console.warn(...ge)};return Object.assign(Object.create(null),s,{warn:ne})}function $c(g){if(g===void 0){Reflect.deleteProperty(globalThis,"sqlite3ApiConfig");return}Reflect.set(globalThis,"sqlite3ApiConfig",g)}async function Dn(){let g=Reflect.get(globalThis,"sqlite3ApiConfig"),s=Kc(g);Reflect.set(globalThis,"sqlite3ApiConfig",s);try{await Promise.resolve().then(() => On());return await Tn()}finally{if(Reflect.get(globalThis,"sqlite3ApiConfig")===s)$c(g)}}function Ut(g,s){if(s.rowMode==="array"){let ne=[];return g.exec(s.sql,{...s.bind!==void 0?{bind:s.bind}:{},rowMode:"array",resultRows:ne}),ne}let Y=[];return g.exec(s.sql,{...s.bind!==void 0?{bind:s.bind}:{},rowMode:"object",resultRows:Y}),Y}var Jc=12,Yc=3000,Xc=150,Zc=600;function e_(g){return new Promise((s)=>{setTimeout(s,g)})}function t_(g){if(typeof g!=="object"||g===null)return!1;if(Reflect.get(g,"name")==="NoModificationAllowedError")return!0;let Y=Reflect.get(g,"message");return typeof Y==="string"&&Y.includes("Access Handles cannot be created")}var Qt,Vt,tt=new Map,Ht=new WeakMap;function Nn(g){return`${g.vfsName}
4
- ${g.directory}`}function n_(g,s){let Y={installation:s.catch((ne)=>{if(tt.get(g)===Y)tt.delete(g);throw ne instanceof Error?ne:Error("Failed to install the persistent SQLite VFS.",{cause:ne})}),resume:null};return tt.set(g,Y),Y}async function r_(g){if(g.resume)return g.resume;let s=g.installation.then(async(Y)=>{if(Y.poolUtil.isPaused())await wt(Y.poolUtil.unpauseVfs(),St);return Y});g.resume=s;try{return await s}finally{if(g.resume===s)g.resume=null}}async function i_(){if(Qt)return Qt;if(!Vt)Vt=Wt(async()=>{let g=await Dn();return Qt=g,g});return Vt}function s_(g){return{directory:g?.directory??xn,initialDelayMs:g?.initialDelayMs??Xc,maxDelayMs:g?.maxDelayMs??Zc,now:g?.now??(()=>Date.now()),stepHangTimeoutMs:g?.stepHangTimeoutMs??St,totalBudgetMs:g?.totalBudgetMs??Yc,vfsName:g?.vfsName??In}}async function o_(g,s){let{directory:Y,initialDelayMs:ne,maxDelayMs:ge,now:Se,stepHangTimeoutMs:Me,totalBudgetMs:ze,vfsName:nt}=s_(s),ut={name:nt,directory:Y,clearOnInit:!1,forceReinitIfPreviouslyFailed:!0,preserveOnInitFailure:!0},ot=Se(),ft=ne;for(;;)try{return await wt(g.installOpfsSAHPoolVfs(ut),Me)}catch(Ye){if(Ye instanceof Tt)throw Ye;if(!t_(Ye))throw Ye;if(Se()-ot+ft>ze)throw Ye;await e_(ft),ft=Math.min(ft*2,ge)}}async function a_(g,s){let Y=zt(s),ne=Nn(Y);if(typeof g.installOpfsSAHPoolVfs!=="function")throw Error("Persistent storage requested but the SQLite build does not provide installOpfsSAHPoolVfs.");let ge=tt.get(ne);if(ge)return r_(ge);let Se=(async()=>{let Me=await o_(g,{directory:Y.directory,vfsName:Y.vfsName});await wt(Me.reserveMinimumCapacity(Jc),St);let ze=kn(g,Me.vfsName);return{poolUtil:Me,cipherVfsName:ze,destroyCipherWrapper:()=>An(g,ze)}})();return n_(ne,Se).installation}async function l_(g,s,Y){if(Y==="memory")return new g.oo1.DB(s);let{cipherVfsName:ne}=await a_(g,s),ge=new g.oo1.DB(s,"c",ne),Se=zt(s);return Ht.set(ge,Nn(Se)),ge}async function Rn(g){let s=await i_(),Y=g.persistence??"memory";return Wt(async()=>{let ne=await l_(s,g.dbName,Y);return ne.exec(`PRAGMA cipher='${g.cipher}'`),ne.exec(`PRAGMA key='${g.key}'`),ne})}function c_(g,s,Y){if(g){let ge=tt.get(g);if(Y)tt.delete(g);return[ge]}if(s)return[];let ne=[...tt.values()];if(Y)tt.clear();return ne}async function Mn(g,s,Y){let ne=g?Ht.get(g):void 0;try{g?.close()}catch{}if(g)Ht.delete(g);let ge=c_(ne,g!==null,Y);for(let Se of ge){if(!Se)continue;try{await s(await(Se.resume??Se.installation))}catch{}}}function jn(g){return Mn(g,(s)=>{s.poolUtil.pauseVfs()},!1)}function Wn(g){return Mn(g,async(s)=>{if(s.poolUtil.isPaused())await wt(s.poolUtil.unpauseVfs(),St);await s.poolUtil.wipeFiles(),s.destroyCipherWrapper(),await s.poolUtil.removeVfs()},!0)}function zn(){return tt.size>0}function __(g){return g!==void 0&&"getDirectory"in g&&typeof g.getDirectory==="function"}async function u_(g,s,Y,ne){for(let ge=1;;ge+=1){try{await g.removeEntry(s,{recursive:!0});return}catch(ze){if(ze instanceof Error&&ze.name==="NotFoundError")return;if(ge>=Y)throw Error(`Could not remove "${s}" from OPFS.`,{cause:ze})}let{promise:Se,resolve:Me}=Promise.withResolvers();setTimeout(Me,ne),await Se}}async function Bn(g={}){if(typeof navigator!=="object"||!__(navigator.storage))return"unavailable";let s=await navigator.storage.getDirectory(),Y=[];for await(let[ne]of s.entries())Y.push(ne);for(let ne of Y)await u_(s,ne,g.attempts??10,g.retryDelayMs??200);return"wiped"}function f_(g){return[g.dbName,g.persistence??"memory",g.cipher,g.key].join("\x00")}function Gt(g,s){let Y=g.queue.then(s,s);return g.queue=Y.then(()=>{return},()=>{return}),Y}class Un{databasesByName=new Map;connectionsByName=new Map;lifecycleByName=new Map;initializingConnections=0;storageWipe=Promise.resolve();createConnection(){let g={dbName:null,generation:0,initializing:!1};return{onInit:(s)=>this.initConnection(g,s),onExec:(s)=>this.execForConnection(g,s),onClose:()=>this.closeConnection(g),onPrepareDelete:()=>g.dbName?this.databasesByName.get(g.dbName)?.queue:void 0,onDelete:()=>this.deleteConnection(g),onWipeStorage:()=>this.wipeStorage()}}async initConnection(g,s){if(g.dbName||g.initializing)throw Error("Database has already been initialized.");let Y=g.generation;g.initializing=!0,this.initializingConnections+=1;try{let ne=await this.acquireDatabase(s);if(g.generation!==Y||g.dbName)throw await this.releaseDatabase(ne.dbName),Error("Database connection closed before initialization completed.");g.dbName=ne.dbName,this.addConnection(ne.dbName,g)}finally{g.initializing=!1,this.initializingConnections-=1}}async execForConnection(g,s){let Y=g.dbName;if(!Y)throw Error("Database has not been initialized.");let ne=this.databasesByName.get(Y);if(!ne)throw this.detachConnection(g),Error("Database has not been initialized.");return Gt(ne,()=>Ut(ne.db,s))}async wipeStorage(){if(this.initializingConnections>0||this.databasesByName.size>0||zn())throw Error("Storage can only be wiped before this worker opens a database.");let g=this.storageWipe.then(()=>Bn());this.storageWipe=g.then(()=>{return},()=>{return}),await g}async acquireDatabase(g){let{dbName:s}=g,Y=f_(g);await this.storageWipe,await this.waitForLifecycle(s);let ne=this.databasesByName.get(s);if(ne)return this.attachDatabase(ne,Y);let ge=await this.runLifecycle(s,async()=>{let Se=this.databasesByName.get(s);if(Se)return Se;let ze={db:await Rn(g),dbName:s,optionsKey:Y,refCount:0,queue:Promise.resolve()};return this.databasesByName.set(s,ze),ze});return this.attachDatabase(ge,Y)}attachDatabase(g,s){if(g.optionsKey!==s)throw Error("Database is already initialized with different options.");return g.refCount+=1,g}async closeConnection(g){g.generation+=1;let s=this.detachConnection(g);if(s)await this.releaseDatabase(s)}async deleteConnection(g){g.generation+=1;let s=g.dbName;if(!s)return;await this.deleteDatabase(s)}async releaseDatabase(g){let s=this.databasesByName.get(g);if(!s)return;if(s.refCount=Math.max(0,s.refCount-1),s.refCount>0)return;this.databasesByName.delete(g),await this.runLifecycle(g,()=>Gt(s,()=>jn(s.db)))}async deleteDatabase(g){let s=this.connectionsByName.get(g);if(s){for(let ne of s)ne.dbName=null,ne.generation+=1;this.connectionsByName.delete(g)}let Y=this.databasesByName.get(g);if(!Y)return;Y.refCount=0,this.databasesByName.delete(g),await this.runLifecycle(g,()=>Gt(Y,()=>Wn(Y.db)))}addConnection(g,s){let Y=this.connectionsByName.get(g)??new Set;Y.add(s),this.connectionsByName.set(g,Y)}detachConnection(g){let s=g.dbName;if(g.dbName=null,!s)return null;let Y=this.connectionsByName.get(s);if(Y?.delete(g),Y?.size===0)this.connectionsByName.delete(s);return s}async waitForLifecycle(g){await this.lifecycleByName.get(g)}async runLifecycle(g,s){let ne=(this.lifecycleByName.get(g)??Promise.resolve()).then(s,s),ge=ne.then(()=>{return},()=>{return});this.lifecycleByName.set(g,ge);try{return await ne}finally{if(this.lifecycleByName.get(g)===ge)this.lifecycleByName.delete(g)}}}function Qn(){let g=new Un;return()=>g.createConnection()}var Vn="tearleads:sqlite-connect-port",Hn="tearleads:sqlite-disconnect-port",Gn="tearleads:sqlite-port-disconnected";function d_(g){if(typeof g!=="object"||g===null)return!1;let s=Reflect.get(g,"id"),Y=Reflect.get(g,"method");return typeof s==="number"&&(Y==="ping"||Y==="init"||Y==="exec"||Y==="close"||Y==="prepareDelete"||Y==="delete"||Y==="wipeStorage")}function Kt(g,s={}){let Y=async(ne)=>{let ge=ne.data;if(!d_(ge))return;try{let Se=await p_(ge,s);g.postMessage(Se)}catch(Se){g.postMessage({id:ge.id,result:{ok:!1,message:Se instanceof Error?Se.message:String(Se)}})}};return g.addEventListener("message",Y),()=>g.removeEventListener?.("message",Y)}async function p_(g,s){switch(g.method){case"ping":return{id:g.id,result:{ok:!0,message:"pong"}};case"init":return await s.onInit?.(g.params),{id:g.id,result:{ok:!0}};case"exec":return{id:g.id,result:{ok:!0,rows:await s.onExec?.(g.params)??[]}};case"close":return await s.onClose?.(),{id:g.id,result:{ok:!0}};case"prepareDelete":return await s.onPrepareDelete?.(),{id:g.id,result:{ok:!0}};case"delete":return await s.onDelete?.(),{id:g.id,result:{ok:!0}};case"wipeStorage":return await s.onWipeStorage?.(),{id:g.id,result:{ok:!0}}}}function $n(g){return typeof g==="object"&&g!==null&&typeof Reflect.get(g,"addEventListener")==="function"}function Jn(g){return $n(g)&&typeof Reflect.get(g,"postMessage")==="function"}function Yn(g){return Jn(g)&&typeof Reflect.get(g,"removeEventListener")==="function"}function h_(g){return typeof g==="function"?g:()=>g}function m_(g){return{addEventListener(s,Y){g.addEventListener(s,(ne)=>{if(ne instanceof MessageEvent)Y(ne)})},postMessage(s){g.postMessage(s)}}}function g_(g){let s=new Map;return{addEventListener(Y,ne){let ge=(Se)=>{ne(Se)};s.set(ne,ge),g.addEventListener(Y,ge)},postMessage(Y){g.postMessage(Y)},removeEventListener(Y,ne){let ge=s.get(ne);if(!ge)return;s.delete(ne),g.removeEventListener(Y,ge)}}}function b_(g){return typeof g==="object"&&g!==null&&Reflect.get(g,"type")===Hn}function Kn(g,s){let Y=!1,ne=!1,ge=async(nt)=>{await s.onInit?.(nt),ne=!1},Se=()=>{if(ne)return;return ne=!0,s.onClose?.()},Me=Kt(g_(g),{...s,onInit:ge,onClose:Se}),ze=(nt)=>{if(Y||!b_(nt.data))return;Y=!0,Me(),g.removeEventListener("message",ze);let ut=()=>{try{g.postMessage({type:Gn})}catch{}try{g.close()}catch{}};Promise.resolve().then(Se).then(ut,ut)};g.addEventListener("message",ze),g.start?.()}function y_(g){let s=g.data;if(typeof s!=="object"||s===null||Reflect.get(s,"type")!==Vn)return null;let Y=Reflect.get(g,"ports"),ne=Array.isArray(Y)?Y[0]:null;return Yn(ne)?ne:null}function Xn(g={}){let s=h_(g),Y=self;if(Jn(Y))Y.addEventListener("message",(ne)=>{if(!(ne instanceof MessageEvent))return;let ge=y_(ne);if(!ge)return;Kn(ge,s())}),Kt(m_(Y),s());if(!$n(Y))return;Y.addEventListener("connect",(ne)=>{let ge=Reflect.get(ne,"ports"),Se=Array.isArray(ge)?ge[0]:null;if(!Yn(Se))return;Kn(Se,s())})}Cn();Xn(Qn());
1
+ var Bc=(g,s,Y)=>()=>{if(g)try{s=g(g=0)}catch(te){Y=[te]}if(Y)throw Y[0];return s};async function Bt(g={}){var s=g,Y=!!globalThis.window,te=!!globalThis.WorkerGlobalScope,pe=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer",qe=!Y&&!pe&&!te;(function(e){let n=globalThis.sqlite3InitModuleState||Object.assign(Object.create(null),{debugModule:function(){console.warn("globalThis.sqlite3InitModuleState is missing",arguments)}});delete globalThis.sqlite3InitModuleState,n.debugModule("pre-js.js sqlite3InitModuleState =",n),e.locateFile=function(o,i){if(this.emscriptenLocateFile instanceof Function)return this.emscriptenLocateFile(o,i);return new URL(o,import.meta.url).href}.bind(n),e.instantiateWasm=function(i,t){if(this.emscriptenInstantiateWasm instanceof Function)return this.emscriptenInstantiateWasm(i,t);let r=this,a=(S)=>{S.imports=i,r.instantiateWasm=S,t(S.instance,S.module)},_=e.locateFile(r.wasmFilename,typeof ot>"u"?"":ot);r.debugModule("instantiateWasm() uri =",_,"sIMS =",this);let h=()=>fetch(_,{credentials:"same-origin"});return(WebAssembly.instantiateStreaming?async()=>WebAssembly.instantiateStreaming(h(),i).then(a):async()=>h().then((S)=>S.arrayBuffer()).then((S)=>WebAssembly.instantiate(S,i)).then(a))()}.bind(n)})(s);var Ne=[],ze="./this.program",nt=(e,n)=>{throw n},ut=import.meta.url,ot="";function ft(e){if(s.locateFile)return s.locateFile(e,ot);return ot+e}var Ye,Et;if(Y||te){try{ot=new URL(".",ut).href}catch{}{if(te)Et=(e)=>{var n=new XMLHttpRequest;return n.open("GET",e,!1),n.responseType="arraybuffer",n.send(null),new Uint8Array(n.response)};Ye=async(e)=>{var n=await fetch(e,{credentials:"same-origin"});if(n.ok)return n.arrayBuffer();throw Error(n.status+" : "+n.url)}}}var kt=console.log.bind(console),rt=console.error.bind(console),Jt,Ot=!1,Yt;function w_(e,n){if(!e)Ke(n)}var E_=(e)=>e.startsWith("file://");class Xt{}class nr extends Xt{}var rr=!1;function ir(){return Ze.buffer}function Zt(){if(Ue?.buffer?.resizable)return;var e=ir();Ue=new Int8Array(e),at=new Int16Array(e),Xe=new Uint8Array(e),mr=new Uint16Array(e),Ie=new Int32Array(e),ke=new Uint32Array(e),Pt=new Float32Array(e),Ft=new Float64Array(e),Be=new BigInt64Array(e),gr=new BigUint64Array(e)}function sr(){if(s.wasmMemory)Ze=s.wasmMemory;else{var e=s.INITIAL_MEMORY||8388608;Ze=new WebAssembly.Memory({initial:e/65536,maximum:32768})}Zt()}function or(){var e=s.preRun;if(e){if(typeof e=="function")e=[e];Dt.push(...e)}nn(Dt)}function ar(){if(rr=!0,!s.noFSInit&&!l.initialized)l.init();it.init(),gt.__wasm_call_ctors(),l.ignorePermissions=!1}function lr(){var e=s.postRun;if(e){if(typeof e=="function")e=[e];Lt.push(...e)}nn(Lt)}function Ke(e){s.onAbort?.(e),e=`Aborted(${e})`,rt(e),Ot=!0,e+=". Build with -sASSERTIONS for more info.";var n=new WebAssembly.RuntimeError(e);throw n}var en;function cr(){if(s.locateFile)return ft("sqlite3.wasm");return new URL("sqlite3.wasm",import.meta.url).href}function _r(e){if(Et)return Et(e);throw"both async and sync fetching of the wasm failed"}async function ur(e){if(!Jt)try{var n=await Ye(e);return new Uint8Array(n)}catch{}return _r(e)}async function fr(e,n){try{var o=await ur(e),i=await WebAssembly.instantiate(o,n);return i}catch(t){rt(`failed to asynchronously prepare wasm: ${t}`),Ke(t)}}async function dr(e,n,o){if(!e)try{var i=fetch(n,{credentials:"same-origin"}),t=await WebAssembly.instantiateStreaming(i,o);return t}catch(r){rt(`wasm streaming compile failed: ${r}`),rt("falling back to ArrayBuffer instantiation")}return fr(n,o)}function pr(){var e={env:Sn,wasi_snapshot_preview1:Sn};return e}async function hr(){function e(a){return gt=a.exports,jc(gt),gt}function n(a){return e(a.instance)}var o=pr(),i=s.instantiateWasm;if(i)return new Promise((a)=>{i(o,(_)=>a(e(_)))});en??=cr();var t=await dr(Jt,en,o),r=n(t);return r}class tn{name="ExitStatus";constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var at,Ie,Be,Ue,Pt,Ft,mr,ke,gr,Xe,nn=(e)=>{while(e.length>0)e.shift()(s)},Lt=[],k_=(e)=>Lt.push(e),Dt=[],A_=(e)=>Dt.push(e);function I_(e,n="i8"){if(n.endsWith("*"))n="*";switch(n){case"i1":return Ue[e];case"i8":return Ue[e];case"i16":return at[e>>1];case"i32":return Ie[e>>2];case"i64":return Be[e>>3];case"float":return Pt[e>>2];case"double":return Ft[e>>3];case"*":return ke[e>>2];default:Ke(`invalid type for getValue: ${n}`)}}var rn=!0;function T_(e,n,o="i8"){if(o.endsWith("*"))o="*";switch(o){case"i1":Ue[e]=n;break;case"i8":Ue[e]=n;break;case"i16":at[e>>1]=n;break;case"i32":Ie[e>>2]=n;break;case"i64":Be[e>>3]=BigInt(n);break;case"float":Pt[e>>2]=n;break;case"double":Ft[e>>3]=n;break;case"*":ke[e>>2]=n;break;default:Ke(`invalid type for setValue: ${o}`)}}var x_=(e)=>qn(e),O_=()=>vn(),Ze,xe={isAbs:(e)=>e.charAt(0)==="/",splitPath:(e)=>{var n=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;return n.exec(e).slice(1)},normalizeArray:(e,n)=>{var o=0;for(var i=e.length-1;i>=0;i--){var t=e[i];if(t===".")e.splice(i,1);else if(t==="..")e.splice(i,1),o++;else if(o)e.splice(i,1),o--}if(n)for(;o;o--)e.unshift("..");return e},normalize:(e)=>{var n=xe.isAbs(e),o=e.slice(-1)==="/";if(e=xe.normalizeArray(e.split("/").filter((i)=>!!i),!n).join("/"),!e&&!n)e=".";if(e&&o)e+="/";return(n?"/":"")+e},dirname:(e)=>{var n=xe.splitPath(e),o=n[0],i=n[1];if(!o&&!i)return".";if(i)i=i.slice(0,-1);return o+i},basename:(e)=>e&&e.match(/([^\/]+|\/)\/*$/)[1],join:(...e)=>xe.normalize(e.join("/")),join2:(e,n)=>xe.normalize(e+"/"+n)},br=()=>(e)=>(crypto.getRandomValues(e),0),sn=(e)=>(sn=br())(e),dt={resolve:(...e)=>{var n="",o=!1;for(var i=e.length-1;i>=-1&&!o;i--){var t=i>=0?e[i]:l.cwd();if(typeof t!="string")throw TypeError("Arguments to path.resolve must be strings");else if(!t)return"";n=t+"/"+n,o=xe.isAbs(t)}return n=xe.normalizeArray(n.split("/").filter((r)=>!!r),!o).join("/"),(o?"/":"")+n||"."},relative:(e,n)=>{e=dt.resolve(e).slice(1),n=dt.resolve(n).slice(1);function o(I){var S=0;for(;S<I.length;S++)if(I[S]!=="")break;var R=I.length-1;for(;R>=0;R--)if(I[R]!=="")break;if(S>R)return[];return I.slice(S,R-S+1)}var i=o(e.split("/")),t=o(n.split("/")),r=Math.min(i.length,t.length),a=r;for(var _=0;_<r;_++)if(i[_]!==t[_]){a=_;break}var h=[];for(var _=a;_<i.length;_++)h.push("..");return h=h.concat(t.slice(a)),h.join("/")}},on=new TextDecoder,an=(e,n,o,i)=>{var t=n+o;if(i)return t;while(e[n]&&!(n>=t))++n;return n},qt=(e,n=0,o,i)=>{var t=an(e,n,o,i);return on.decode(e.buffer?e.subarray(n,t):new Uint8Array(e.slice(n,t)))},Ct=[],At=(e)=>{var n=0;for(var o=0;o<e.length;++o){var i=e.charCodeAt(o);if(i<=127)n++;else if(i<=2047)n+=2;else if(i>=55296&&i<=57343)n+=4,++o;else n+=3}return n},ln=(e,n,o,i)=>{if(!(i>0))return 0;var t=o,r=o+i-1;for(var a=0;a<e.length;++a){var _=e.codePointAt(a);if(_<=127){if(o>=r)break;n[o++]=_}else if(_<=2047){if(o+1>=r)break;n[o++]=192|_>>6,n[o++]=128|_&63}else if(_<=65535){if(o+2>=r)break;n[o++]=224|_>>12,n[o++]=128|_>>6&63,n[o++]=128|_&63}else{if(o+3>=r)break;n[o++]=240|_>>18,n[o++]=128|_>>12&63,n[o++]=128|_>>6&63,n[o++]=128|_&63,a++}}return n[o]=0,o-t},Nt=(e,n,o)=>{var i=o>0?o:At(e)+1,t=Array(i),r=ln(e,t,0,t.length);if(n)t.length=r;return t},yr=()=>{if(!Ct.length){var e=null;if(globalThis.window?.prompt){if(e=window.prompt("Input: "),e!==null)e+=`
2
+ `}if(!e)return null;Ct=Nt(e,!0)}return Ct.shift()},it={ttys:[],init(){},shutdown(){},register(e,n){it.ttys[e]={input:[],output:[],ops:n},l.registerDevice(e,it.stream_ops)},stream_ops:{open(e){var n=it.ttys[e.node.rdev];if(!n)throw new l.ErrnoError(43);e.tty=n,e.seekable=!1},close(e){e.tty.ops.fsync(e.tty)},fsync(e){e.tty.ops.fsync(e.tty)},read(e,n,o,i,t){if(!e.tty||!e.tty.ops.get_char)throw new l.ErrnoError(60);var r=0;for(var a=0;a<i;a++){var _;try{_=e.tty.ops.get_char(e.tty)}catch(h){throw new l.ErrnoError(29)}if(_===void 0&&r===0)throw new l.ErrnoError(6);if(_===null||_===void 0)break;r++,n[o+a]=_}if(r)e.node.atime=Date.now();return r},write(e,n,o,i,t){if(!e.tty||!e.tty.ops.put_char)throw new l.ErrnoError(60);try{for(var r=0;r<i;r++)e.tty.ops.put_char(e.tty,n[o+r])}catch(a){throw new l.ErrnoError(29)}if(i)e.node.mtime=e.node.ctime=Date.now();return r}},default_tty_ops:{get_char(e){return yr()},put_char(e,n){if(n===null||n===10)kt(qt(e.output)),e.output=[];else if(n!=0)e.output.push(n)},fsync(e){if(e.output?.length>0)kt(qt(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,n,o){return 0},ioctl_tiocgwinsz(e){return[24,80]}},default_tty1_ops:{put_char(e,n){if(n===null||n===10)rt(qt(e.output)),e.output=[];else if(n!=0)e.output.push(n)},fsync(e){if(e.output?.length>0)rt(qt(e.output)),e.output=[]}}},qr=(e,n)=>Xe.fill(0,e,e+n),cn=(e,n)=>Math.ceil(e/n)*n,_n=(e)=>{e=cn(e,65536);var n=yn(65536,e);if(n)qr(n,e);return n},ye={ops_table:null,mount(e){return ye.createNode(null,"/",16895,0)},createNode(e,n,o,i){if(l.isBlkdev(o)||l.isFIFO(o))throw new l.ErrnoError(63);ye.ops_table||={dir:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr,lookup:ye.node_ops.lookup,mknod:ye.node_ops.mknod,rename:ye.node_ops.rename,unlink:ye.node_ops.unlink,rmdir:ye.node_ops.rmdir,readdir:ye.node_ops.readdir,symlink:ye.node_ops.symlink},stream:{llseek:ye.stream_ops.llseek}},file:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr},stream:{llseek:ye.stream_ops.llseek,read:ye.stream_ops.read,write:ye.stream_ops.write,mmap:ye.stream_ops.mmap,msync:ye.stream_ops.msync}},link:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr,readlink:ye.node_ops.readlink},stream:{}},chrdev:{node:{getattr:ye.node_ops.getattr,setattr:ye.node_ops.setattr},stream:l.chrdev_stream_ops}};var t=l.createNode(e,n,o,i);if(l.isDir(t.mode))t.node_ops=ye.ops_table.dir.node,t.stream_ops=ye.ops_table.dir.stream,t.contents={};else if(l.isFile(t.mode))t.node_ops=ye.ops_table.file.node,t.stream_ops=ye.ops_table.file.stream,t.usedBytes=0,t.contents=ye.emptyFileContents??=new Uint8Array(0);else if(l.isLink(t.mode))t.node_ops=ye.ops_table.link.node,t.stream_ops=ye.ops_table.link.stream;else if(l.isChrdev(t.mode))t.node_ops=ye.ops_table.chrdev.node,t.stream_ops=ye.ops_table.chrdev.stream;if(t.atime=t.mtime=t.ctime=Date.now(),e)e.contents[n]=t,e.atime=e.mtime=e.ctime=t.atime;return t},getFileDataAsTypedArray(e){return e.contents.subarray(0,e.usedBytes)},expandFileStorage(e,n){var o=e.contents.length;if(o>=n)return;var i=1048576;if(n=Math.max(n,o*(o<i?2:1.125)>>>0),o)n=Math.max(n,256);var t=ye.getFileDataAsTypedArray(e);e.contents=new Uint8Array(n),e.contents.set(t)},resizeFileStorage(e,n){if(e.usedBytes==n)return;var o=e.contents;e.contents=new Uint8Array(n),e.contents.set(o.subarray(0,Math.min(n,e.usedBytes))),e.usedBytes=n},node_ops:{getattr(e){var n={};if(n.dev=l.isChrdev(e.mode)?e.id:1,n.ino=e.id,n.mode=e.mode,n.nlink=1,n.uid=0,n.gid=0,n.rdev=e.rdev,l.isDir(e.mode))n.size=4096;else if(l.isFile(e.mode))n.size=e.usedBytes;else if(l.isLink(e.mode))n.size=e.link.length;else n.size=0;return n.atime=new Date(e.atime),n.mtime=new Date(e.mtime),n.ctime=new Date(e.ctime),n.blksize=4096,n.blocks=Math.ceil(n.size/n.blksize),n},setattr(e,n){for(let o of["mode","atime","mtime","ctime"])if(n[o]!=null)e[o]=n[o];if(n.size!==void 0)ye.resizeFileStorage(e,n.size)},lookup(e,n){if(!ye.doesNotExistError)ye.doesNotExistError=new l.ErrnoError(44),ye.doesNotExistError.stack="<generic error, no stack>";throw ye.doesNotExistError},mknod(e,n,o,i){return ye.createNode(e,n,o,i)},rename(e,n,o){var i;try{i=l.lookupNode(n,o)}catch(r){}if(i){if(l.isDir(e.mode))for(var t in i.contents)throw new l.ErrnoError(55);l.hashRemoveNode(i)}delete e.parent.contents[e.name],n.contents[o]=e,e.name=o,n.ctime=n.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,n){delete e.contents[n],e.ctime=e.mtime=Date.now()},rmdir(e,n){var o=l.lookupNode(e,n);for(var i in o.contents)throw new l.ErrnoError(55);delete e.contents[n],e.ctime=e.mtime=Date.now()},readdir(e){return[".","..",...Object.keys(e.contents)]},symlink(e,n,o){var i=ye.createNode(e,n,41471,0);return i.link=o,i},readlink(e){if(!l.isLink(e.mode))throw new l.ErrnoError(28);return e.link}},stream_ops:{read(e,n,o,i,t){var r=e.node.contents;if(t>=e.node.usedBytes)return 0;var a=Math.min(e.node.usedBytes-t,i);return n.set(r.subarray(t,t+a),o),a},write(e,n,o,i,t,r){if(n.buffer===Ue.buffer)r=!1;if(!i)return 0;var a=e.node;if(a.mtime=a.ctime=Date.now(),r)a.contents=n.subarray(o,o+i),a.usedBytes=i;else if(a.usedBytes===0&&t===0)a.contents=n.slice(o,o+i),a.usedBytes=i;else ye.expandFileStorage(a,t+i),a.contents.set(n.subarray(o,o+i),t),a.usedBytes=Math.max(a.usedBytes,t+i);return i},llseek(e,n,o){var i=n;if(o===1)i+=e.position;else if(o===2){if(l.isFile(e.node.mode))i+=e.node.usedBytes}if(i<0)throw new l.ErrnoError(28);return i},mmap(e,n,o,i,t){if(!l.isFile(e.node.mode))throw new l.ErrnoError(43);var r,a,_=e.node.contents;if(!(t&2)&&_.buffer===Ue.buffer)a=!1,r=_.byteOffset;else{if(a=!0,r=_n(n),!r)throw new l.ErrnoError(48);if(_){if(o>0||o+n<_.length)if(_.subarray)_=_.subarray(o,o+n);else _=Array.prototype.slice.call(_,o,o+n);Ue.set(_,r)}}return{ptr:r,allocated:a}},msync(e,n,o,i,t){return ye.stream_ops.write(e,n,0,i,o,!1),0}}},vr=(e)=>{if(typeof e!="string")return e;var n={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},o=n[e];if(typeof o>"u")throw Error(`Unknown file open mode: ${e}`);return o},un=(e)=>{if(typeof e=="string")e=Nt(e,!0);if(!e.subarray)e=new Uint8Array(e);return e},Rt=(e,n)=>{var o=0;if(e)o|=365;if(n)o|=146;return o},Sr=async(e)=>{var n=await Ye(e);return new Uint8Array(n)},wr=(...e)=>l.createDataFile(...e),Er=(e)=>e,fn=null,kr=async()=>fn,lt=0,dn=null,Ar=(e)=>{if(lt--,s.monitorRunDependencies?.(lt),!lt)dn()},Ir=(e)=>{if(!lt)fn=new Promise((n)=>dn=n);lt++,s.monitorRunDependencies?.(lt)},Tr=[],xr=async(e,n)=>{if(typeof Browser<"u")Browser.init();for(var o of Tr)if(o.canHandle(n))return o.handle(e,n);return e},pn=async(e,n,o,i,t,r,a,_)=>{var h=n?dt.resolve(xe.join2(e,n)):e,I=Er(`cp ${h}`);Ir(I);try{var S=o;if(typeof o=="string")S=await Sr(o);if(S=await xr(S,h),_?.(),!r)wr(e,n,S,i,t,a)}finally{Ar(I)}},Or=(e,n,o,i,t,r,a,_,h,I)=>{pn(e,n,o,i,t,_,h,I).then(r).catch(a)},l={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,n,o,i){if(!e)e=this;this.parent=e,this.mount=e.mount,this.id=l.nextInode++,this.name=n,this.mode=o,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 l.isDir(this.mode)}get isDevice(){return l.isChrdev(this.mode)}addListener(e,n=!1){var o={cb:e,exclusive:n},i=this.listeners??=new Set;return i.add(o),{listeners:i,entry:o}}notifyListeners(e){if(!this.listeners)return;var n;for(var o of this.listeners)if(o.exclusive)(n||=[]).push(o);else o.cb(e);if(n){var i=(this.exclTurn||0)%n.length;this.exclTurn=i+1,n[i].cb(e)}}},lookupPath(e,n={}){if(!e)throw new l.ErrnoError(44);if(n.follow_mount??=!0,!xe.isAbs(e))e=l.cwd()+"/"+e;e:for(var o=0;o<40;o++){var i=e.split("/").filter((I)=>!!I),t=l.root,r="/";for(var a=0;a<i.length;a++){var _=a===i.length-1;if(_&&n.parent)break;if(i[a]===".")continue;if(i[a]===".."){if(r=xe.dirname(r),l.isRoot(t)){e=r+"/"+i.slice(a+1).join("/"),o--;continue e}else t=t.parent;continue}r=xe.join2(r,i[a]);try{t=l.lookupNode(t,i[a])}catch(I){if(I?.errno===44&&_&&n.noent_okay)return{path:r};throw I}if(l.isMountpoint(t)&&(!_||n.follow_mount))t=t.mounted.root;if(l.isLink(t.mode)&&(!_||n.follow)){if(!t.node_ops.readlink)throw new l.ErrnoError(52);var h=t.node_ops.readlink(t);if(!xe.isAbs(h))h=xe.dirname(r)+"/"+h;e=h+"/"+i.slice(a+1).join("/");continue e}}return{path:r,node:t}}throw new l.ErrnoError(32)},getPath(e){var n;while(!0){if(l.isRoot(e)){var o=e.mount.mountpoint;if(!n)return o;return o[o.length-1]!=="/"?`${o}/${n}`:o+n}n=n?`${e.name}/${n}`:e.name,e=e.parent}},hashName(e,n){var o=0;for(var i=0;i<n.length;i++)o=(o<<5)-o+n.charCodeAt(i)|0;return(e+o>>>0)%l.nameTable.length},hashAddNode(e){var n=l.hashName(e.parent.id,e.name);e.name_next=l.nameTable[n],l.nameTable[n]=e},hashRemoveNode(e){var n=l.hashName(e.parent.id,e.name);if(l.nameTable[n]===e)l.nameTable[n]=e.name_next;else{var o=l.nameTable[n];while(o){if(o.name_next===e){o.name_next=e.name_next;break}o=o.name_next}}},lookupNode(e,n){var o=l.mayLookup(e);if(o)throw new l.ErrnoError(o);var i=l.hashName(e.id,n);for(var t=l.nameTable[i];t;t=t.name_next){var r=t.name;if(t.parent.id===e.id&&r===n)return t}return l.lookup(e,n)},createNode(e,n,o,i){var t=new l.FSNode(e,n,o,i);return l.hashAddNode(t),t},destroyNode(e){l.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 n=["r","w","rw"][e&3];if(e&512)n+="w";return n},nodePermissions(e,n){if(l.ignorePermissions)return 0;if(n.includes("r")&&!(e.mode&292))return 2;if(n.includes("w")&&!(e.mode&146))return 2;if(n.includes("x")&&!(e.mode&73))return 2;return 0},mayLookup(e){if(!l.isDir(e.mode))return 54;var n=l.nodePermissions(e,"x");if(n)return n;if(!e.node_ops.lookup)return 2;return 0},mayCreate(e,n){if(!l.isDir(e.mode))return 54;try{var o=l.lookupNode(e,n);return 20}catch(i){}return l.nodePermissions(e,"wx")},mayDelete(e,n,o){var i;try{i=l.lookupNode(e,n)}catch(r){return r.errno}var t=l.nodePermissions(e,"wx");if(t)return t;if(o){if(!l.isDir(i.mode))return 54;if(l.isRoot(i)||l.getPath(i)===l.cwd())return 10}else if(l.isDir(i.mode))return 31;return 0},mayOpen(e,n){if(!e)return 44;if(l.isLink(e.mode))return 32;var o=l.flagsToPermissionString(n);if(l.isDir(e.mode)){if(o!=="r"||n&576)return 31}return l.nodePermissions(e,o)},checkOpExists(e,n){if(!e)throw new l.ErrnoError(n);return e},MAX_OPEN_FDS:4096,nextfd(){for(var e=0;e<=l.MAX_OPEN_FDS;e++)if(!l.streams[e])return e;throw new l.ErrnoError(33)},getStreamChecked(e){var n=l.getStream(e);if(!n)throw new l.ErrnoError(8);return n},getStream:(e)=>l.streams[e],createStream(e,n=-1){if(e=Object.assign(new l.FSStream,e),n==-1)n=l.nextfd();return e.fd=n,l.streams[n]=e,e},closeStream(e){l.streams[e]=null},dupStream(e,n=-1){var o=l.createStream(e,n);return o.stream_ops?.dup?.(o),o},doSetAttr(e,n,o){var i=e?.stream_ops.setattr,t=i?e:n;i??=n.node_ops.setattr,l.checkOpExists(i,63);try{i(t,o)}catch(r){if(r instanceof RangeError)throw new l.ErrnoError(22);throw r}},chrdev_stream_ops:{open(e){var n=l.getDevice(e.node.rdev);e.stream_ops=n.stream_ops,e.stream_ops.open?.(e)},llseek(){throw new l.ErrnoError(70)}},major:(e)=>e>>8,minor:(e)=>e&255,makedev:(e,n)=>e<<8|n,registerDevice(e,n){l.devices[e]={stream_ops:n}},getDevice:(e)=>l.devices[e],getMounts(e){var n=[],o=[e];while(o.length){var i=o.pop();n.push(i),o.push(...i.mounts)}return n},syncfs(e,n){if(typeof e=="function")n=e,e=!1;if(l.syncFSRequests++,l.syncFSRequests>1)rt(`warning: ${l.syncFSRequests} FS.syncfs operations in flight at once, probably just doing extra work`);var o=l.getMounts(l.root.mount),i=0;function t(_){return l.syncFSRequests--,n(_)}function r(_){if(_){if(!r.errored)return r.errored=!0,t(_);return}if(++i>=o.length)t(null)}for(var a of o)if(a.type.syncfs)a.type.syncfs(a,e,r);else r(null)},mount(e,n,o){var i=o==="/",t=!o,r;if(i&&l.root)throw new l.ErrnoError(10);else if(!i&&!t){var a=l.lookupPath(o,{follow_mount:!1});if(o=a.path,r=a.node,l.isMountpoint(r))throw new l.ErrnoError(10);if(!l.isDir(r.mode))throw new l.ErrnoError(54)}var _={type:e,opts:n,mountpoint:o,mounts:[]},h=e.mount(_);if(h.mount=_,_.root=h,i)l.root=h;else if(r){if(r.mounted=_,r.mount)r.mount.mounts.push(_)}return h},unmount(e){var n=l.lookupPath(e,{follow_mount:!1});if(!l.isMountpoint(n.node))throw new l.ErrnoError(28);var o=n.node,i=o.mounted,t=l.getMounts(i);for(var[r,a]of Object.entries(l.nameTable))while(a){var _=a.name_next;if(t.includes(a.mount))l.destroyNode(a);a=_}o.mounted=null;var h=o.mount.mounts.indexOf(i);o.mount.mounts.splice(h,1)},lookup(e,n){return e.node_ops.lookup(e,n)},mknod(e,n,o){var i=l.lookupPath(e,{parent:!0}),t=i.node,r=xe.basename(e);if(!r)throw new l.ErrnoError(28);if(r==="."||r==="..")throw new l.ErrnoError(20);var a=l.mayCreate(t,r);if(a)throw new l.ErrnoError(a);if(!t.node_ops.mknod)throw new l.ErrnoError(63);return t.node_ops.mknod(t,r,n,o)},statfs(e){return l.statfsNode(l.lookupPath(e,{follow:!0}).node)},statfsStream(e){return l.statfsNode(e.node)},statfsNode(e){var n={bsize:4096,frsize:4096,blocks:1e6,bfree:500000,bavail:500000,files:l.nextInode,ffree:l.nextInode-1,fsid:42,flags:2,namelen:255};if(e.node_ops.statfs)Object.assign(n,e.node_ops.statfs(e.mount.opts.root));return n},create(e,n=438){return n&=4095,n|=32768,l.mknod(e,n,0)},mkdir(e,n=511){return n&=1023,n|=16384,l.mknod(e,n,0)},mkdirTree(e,n){var o=e.split("/"),i="";for(var t of o){if(!t)continue;if(i||xe.isAbs(e))i+="/";i+=t;try{l.mkdir(i,n)}catch(r){if(r.errno!=20)throw r}}},mkdev(e,n,o){if(typeof o>"u")o=n,n=438;return n|=8192,l.mknod(e,n,o)},symlink(e,n){if(!dt.resolve(e))throw new l.ErrnoError(44);var o=l.lookupPath(n,{parent:!0}),i=o.node;if(!i)throw new l.ErrnoError(44);var t=xe.basename(n),r=l.mayCreate(i,t);if(r)throw new l.ErrnoError(r);if(!i.node_ops.symlink)throw new l.ErrnoError(63);return i.node_ops.symlink(i,t,e)},link(e,n,o){var i=l.lookupPath(n,{parent:!0}),t=i.node;if(!t)throw new l.ErrnoError(44);var r=xe.basename(n),a=l.mayCreate(t,r);if(a)throw new l.ErrnoError(a);if(!t.node_ops.link)throw new l.ErrnoError(34);return t.node_ops.link(t,r,e,o)},rename(e,n){var o=xe.dirname(e),i=xe.dirname(n),t=xe.basename(e),r=xe.basename(n),a,_,h;if(a=l.lookupPath(e,{parent:!0}),_=a.node,a=l.lookupPath(n,{parent:!0}),h=a.node,!_||!h)throw new l.ErrnoError(44);if(_.mount!==h.mount)throw new l.ErrnoError(75);var I=l.lookupNode(_,t),S=dt.relative(e,i);if(S.charAt(0)!==".")throw new l.ErrnoError(28);if(S=dt.relative(n,o),S.charAt(0)!==".")throw new l.ErrnoError(55);var R;try{R=l.lookupNode(h,r)}catch(ne){}if(I===R)return;var M=l.isDir(I.mode),p=l.mayDelete(_,t,M);if(p)throw new l.ErrnoError(p);if(p=R?l.mayDelete(h,r,M):l.mayCreate(h,r),p)throw new l.ErrnoError(p);if(!_.node_ops.rename)throw new l.ErrnoError(63);if(l.isMountpoint(I)||R&&l.isMountpoint(R))throw new l.ErrnoError(10);if(h!==_){if(p=l.nodePermissions(_,"w"),p)throw new l.ErrnoError(p)}l.hashRemoveNode(I);try{_.node_ops.rename(I,h,r),I.parent=h}catch(ne){throw ne}finally{l.hashAddNode(I)}},rmdir(e){var n=l.lookupPath(e,{parent:!0}),o=n.node,i=xe.basename(e),t=l.lookupNode(o,i),r=l.mayDelete(o,i,!0);if(r)throw new l.ErrnoError(r);if(!o.node_ops.rmdir)throw new l.ErrnoError(63);if(l.isMountpoint(t))throw new l.ErrnoError(10);o.node_ops.rmdir(o,i),l.destroyNode(t)},readdir(e){var n=l.lookupPath(e,{follow:!0}),o=n.node,i=l.checkOpExists(o.node_ops.readdir,54);return i(o)},unlink(e){var n=l.lookupPath(e,{parent:!0}),o=n.node;if(!o)throw new l.ErrnoError(44);var i=xe.basename(e),t=l.lookupNode(o,i),r=l.mayDelete(o,i,!1);if(r)throw new l.ErrnoError(r);if(!o.node_ops.unlink)throw new l.ErrnoError(63);if(l.isMountpoint(t))throw new l.ErrnoError(10);o.node_ops.unlink(o,i),l.destroyNode(t)},readlink(e){var n=l.lookupPath(e),o=n.node;if(!o)throw new l.ErrnoError(44);if(!o.node_ops.readlink)throw new l.ErrnoError(28);return o.node_ops.readlink(o)},stat(e,n){var o=l.lookupPath(e,{follow:!n}),i=o.node,t=l.checkOpExists(i.node_ops.getattr,63);return t(i)},fstat(e){var n=l.getStreamChecked(e),o=n.node,i=n.stream_ops.getattr,t=i?n:o;return i??=o.node_ops.getattr,l.checkOpExists(i,63),i(t)},lstat(e){return l.stat(e,!0)},doChmod(e,n,o,i){l.doSetAttr(e,n,{mode:o&4095|n.mode&-4096,ctime:Date.now(),dontFollow:i})},chmod(e,n,o){var i;if(typeof e=="string"){var t=l.lookupPath(e,{follow:!o});i=t.node}else i=e;l.doChmod(null,i,n,o)},lchmod(e,n){l.chmod(e,n,!0)},fchmod(e,n){var o=l.getStreamChecked(e);l.doChmod(o,o.node,n,!1)},doChown(e,n,o){l.doSetAttr(e,n,{timestamp:Date.now(),dontFollow:o})},chown(e,n,o,i){var t;if(typeof e=="string"){var r=l.lookupPath(e,{follow:!i});t=r.node}else t=e;l.doChown(null,t,i)},lchown(e,n,o){l.chown(e,n,o,!0)},fchown(e,n,o){var i=l.getStreamChecked(e);l.doChown(i,i.node,!1)},doTruncate(e,n,o){if(l.isDir(n.mode))throw new l.ErrnoError(31);if(!l.isFile(n.mode))throw new l.ErrnoError(28);var i=l.nodePermissions(n,"w");if(i)throw new l.ErrnoError(i);l.doSetAttr(e,n,{size:o,timestamp:Date.now()})},truncate(e,n){if(n<0)throw new l.ErrnoError(28);var o;if(typeof e=="string"){var i=l.lookupPath(e,{follow:!0});o=i.node}else o=e;l.doTruncate(null,o,n)},ftruncate(e,n){var o=l.getStreamChecked(e);if(n<0||(o.flags&2097155)===0)throw new l.ErrnoError(28);l.doTruncate(o,o.node,n)},utime(e,n,o,i){var t=l.lookupPath(e,{follow:!i});l.doSetAttr(null,t.node,{atime:n,mtime:o,dontFollow:i})},open(e,n,o=438){if(e==="")throw new l.ErrnoError(44);if(n=vr(n),n&64)o=o&4095|32768;else o=0;var i,t;if(typeof e=="object")i=e;else{t=e.endsWith("/");var r=l.lookupPath(e,{follow:!(n&131072),noent_okay:!0});i=r.node,e=r.path}var a=!1;if(n&64)if(i){if(n&128)throw new l.ErrnoError(20)}else if(t)throw new l.ErrnoError(31);else i=l.mknod(e,o|511,0),a=!0;if(!i)throw new l.ErrnoError(44);if(l.isChrdev(i.mode))n&=-513;if(n&65536&&!l.isDir(i.mode))throw new l.ErrnoError(54);if(!a){var _=l.mayOpen(i,n);if(_)throw new l.ErrnoError(_)}if(n&512&&!a)l.truncate(i,0);n&=-131713;var h=l.createStream({node:i,path:l.getPath(i),flags:n,seekable:!0,position:0,stream_ops:i.stream_ops,ungotten:[],error:!1});if(h.stream_ops.open)h.stream_ops.open(h);if(a)l.chmod(i,o&511);return h},close(e){if(l.isClosed(e))throw new l.ErrnoError(8);if(e.getdents)e.getdents=null;e.node?.notifyListeners(32);try{if(e.stream_ops.close)e.stream_ops.close(e)}catch(n){throw n}finally{l.closeStream(e.fd)}e.fd=null},isClosed(e){return e.fd===null},llseek(e,n,o){if(l.isClosed(e))throw new l.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new l.ErrnoError(70);if(o!=0&&o!=1&&o!=2)throw new l.ErrnoError(28);return e.position=e.stream_ops.llseek(e,n,o),e.ungotten=[],e.position},read(e,n,o,i,t){if(i<0||t<0)throw new l.ErrnoError(28);if(l.isClosed(e))throw new l.ErrnoError(8);if((e.flags&2097155)===1)throw new l.ErrnoError(8);if(l.isDir(e.node.mode))throw new l.ErrnoError(31);if(!e.stream_ops.read)throw new l.ErrnoError(28);var r=typeof t<"u";if(!r)t=e.position;else if(!e.seekable)throw new l.ErrnoError(70);var a=e.stream_ops.read(e,n,o,i,t);if(!r)e.position+=a;return a},write(e,n,o,i,t,r){if(i<0||t<0)throw new l.ErrnoError(28);if(l.isClosed(e))throw new l.ErrnoError(8);if((e.flags&2097155)===0)throw new l.ErrnoError(8);if(l.isDir(e.node.mode))throw new l.ErrnoError(31);if(!e.stream_ops.write)throw new l.ErrnoError(28);if(e.seekable&&e.flags&1024)l.llseek(e,0,2);var a=typeof t<"u";if(!a)t=e.position;else if(!e.seekable)throw new l.ErrnoError(70);var _=e.stream_ops.write(e,n,o,i,t,r);if(!a)e.position+=_;return _},mmap(e,n,o,i,t){if((i&2)!==0&&(t&2)===0&&(e.flags&2097155)!==2)throw new l.ErrnoError(2);if((e.flags&2097155)===1)throw new l.ErrnoError(2);if(!e.stream_ops.mmap)throw new l.ErrnoError(43);if(!n)throw new l.ErrnoError(28);return e.stream_ops.mmap(e,n,o,i,t)},msync(e,n,o,i,t){if(!e.stream_ops.msync)return 0;return e.stream_ops.msync(e,n,o,i,t)},ioctl(e,n,o){if(!e.stream_ops.ioctl)throw new l.ErrnoError(59);return e.stream_ops.ioctl(e,n,o)},readFile(e,n={}){if(n.flags=n.flags??0,n.encoding=n.encoding??"binary",n.encoding!=="utf8"&&n.encoding!=="binary")Ke(`Invalid encoding type "${n.encoding}"`);var o=l.open(e,n.flags),i=l.stat(e),t=i.size,r=new Uint8Array(t);if(l.read(o,r,0,t,0),n.encoding==="utf8")r=qt(r);return l.close(o),r},writeFile(e,n,o={}){o.flags=o.flags??577;var i=l.open(e,o.flags,o.mode);n=un(n),l.write(i,n,0,n.byteLength,void 0,o.canOwn),l.close(i)},cwd:()=>l.currentPath,chdir(e){var n=l.lookupPath(e,{follow:!0});if(n.node===null)throw new l.ErrnoError(44);if(!l.isDir(n.node.mode))throw new l.ErrnoError(54);var o=l.nodePermissions(n.node,"x");if(o)throw new l.ErrnoError(o);l.currentPath=n.path},createDefaultDirectories(){l.mkdir("/tmp"),l.mkdir("/home"),l.mkdir("/home/web_user")},createDefaultDevices(){l.mkdir("/dev"),l.registerDevice(l.makedev(1,3),{read:()=>0,write:(i,t,r,a,_)=>a,llseek:()=>0}),l.mkdev("/dev/null",l.makedev(1,3)),it.register(l.makedev(5,0),it.default_tty_ops),it.register(l.makedev(6,0),it.default_tty1_ops),l.mkdev("/dev/tty",l.makedev(5,0)),l.mkdev("/dev/tty1",l.makedev(6,0));var e=new Uint8Array(1024),n=0,o=()=>{if(n===0)sn(e),n=e.byteLength;return e[--n]};l.createDevice("/dev","random",o),l.createDevice("/dev","urandom",o),l.mkdir("/dev/shm"),l.mkdir("/dev/shm/tmp")},createSpecialDirectories(){l.mkdir("/proc");var e=l.mkdir("/proc/self");l.mkdir("/proc/self/fd"),l.mount({mount(){var n=l.createNode(e,"fd",16895,73);return n.stream_ops={llseek:ye.stream_ops.llseek},n.node_ops={lookup(o,i){var t=+i,r=l.getStreamChecked(t),a={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:()=>r.path},id:t+1};return a.parent=a,a},readdir(){return Array.from(l.streams.entries()).filter(([o,i])=>i).map(([o,i])=>o.toString())}},n}},{},"/proc/self/fd")},createStandardStreams(e,n,o){if(e)l.createDevice("/dev","stdin",e);else l.symlink("/dev/tty","/dev/stdin");if(n)l.createDevice("/dev","stdout",null,n);else l.symlink("/dev/tty","/dev/stdout");if(o)l.createDevice("/dev","stderr",null,o);else l.symlink("/dev/tty1","/dev/stderr");var i=l.open("/dev/stdin",0),t=l.open("/dev/stdout",1),r=l.open("/dev/stderr",1)},staticInit(){l.nameTable=Array(4096),l.mount(ye,{},"/"),l.createDefaultDirectories(),l.createDefaultDevices(),l.createSpecialDirectories(),l.filesystems={MEMFS:ye}},init(e,n,o){l.initialized=!0,e??=s.stdin,n??=s.stdout,o??=s.stderr,l.createStandardStreams(e,n,o)},quit(){l.initialized=!1;for(var e of l.streams)if(e)l.close(e)},findObject(e,n){var o=l.analyzePath(e,n);if(!o.exists)return null;return o.object},analyzePath(e,n){try{var o=l.lookupPath(e,{follow:!n});e=o.path}catch(t){}var i={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var o=l.lookupPath(e,{parent:!0});i.parentExists=!0,i.parentPath=o.path,i.parentObject=o.node,i.name=xe.basename(e),o=l.lookupPath(e,{follow:!n}),i.exists=!0,i.path=o.path,i.object=o.node,i.name=o.node.name,i.isRoot=o.path==="/"}catch(t){i.error=t.errno}return i},createPath(e,n,o,i){e=typeof e=="string"?e:l.getPath(e);var t=n.split("/").reverse();while(t.length){var r=t.pop();if(!r)continue;var a=xe.join2(e,r);try{l.mkdir(a)}catch(_){if(_.errno!=20)throw _}e=a}return a},createFile(e,n,o,i,t){var r=xe.join2(typeof e=="string"?e:l.getPath(e),n),a=Rt(i,t);return l.create(r,a)},createDataFile(e,n,o,i,t,r){var a=n;if(e)e=typeof e=="string"?e:l.getPath(e),a=n?xe.join2(e,n):e;var _=Rt(i,t),h=l.create(a,_);if(o){o=un(o),l.chmod(h,_|146);var I=l.open(h,577);l.write(I,o,0,o.length,0,r),l.close(I),l.chmod(h,_)}},createDevice(e,n,o,i){var t=xe.join2(typeof e=="string"?e:l.getPath(e),n),r=Rt(!!o,!!i);l.createDevice.major??=64;var a=l.makedev(l.createDevice.major++,0);return l.registerDevice(a,{open(_){_.seekable=!1},close(_){if(i?.buffer?.length)i(10)},read(_,h,I,S,R){var M=0;for(var p=0;p<S;p++){var ne;try{ne=o()}catch(W){throw new l.ErrnoError(29)}if(ne===void 0&&M===0)throw new l.ErrnoError(6);if(ne===null||ne===void 0)break;M++,h[I+p]=ne}if(M)_.node.atime=Date.now();return M},write(_,h,I,S,R){for(var M=0;M<S;M++)try{i(h[I+M])}catch(p){throw new l.ErrnoError(29)}if(S)_.node.mtime=_.node.ctime=Date.now();return M}}),l.mkdev(t,r,a)},forceLoadFile(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if(globalThis.XMLHttpRequest)Ke("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");else try{e.contents=Et(e.url)}catch(n){throw new l.ErrnoError(29)}},createLazyFile(e,n,o,i,t){class r{lengthKnown=!1;chunks=[];get(R){if(R>this.length-1||R<0)return;var M=R%this.chunkSize,p=R/this.chunkSize|0;return this.getter(p)[M]}setDataGetter(R){this.getter=R}cacheLength(){var R=new XMLHttpRequest;if(R.open("HEAD",o,!1),R.send(null),!(R.status>=200&&R.status<300||R.status===304))Ke("Couldn't load "+o+". Status: "+R.status);var M=Number(R.getResponseHeader("Content-length")),p,ne=(p=R.getResponseHeader("Accept-Ranges"))&&p==="bytes",W=(p=R.getResponseHeader("Content-Encoding"))&&p==="gzip",U=1048576;if(!ne)U=M;var E=(F,T)=>{if(F>T)Ke(`invalid range (${F}, ${T}) or no bytes requested!`);if(T>M-1)Ke(`only ${M} bytes available! programmer error!`);var A=new XMLHttpRequest;if(A.open("GET",o,!1),M!==U)A.setRequestHeader("Range","bytes="+F+"-"+T);if(A.responseType="arraybuffer",A.overrideMimeType)A.overrideMimeType("text/plain; charset=x-user-defined");if(A.send(null),!(A.status>=200&&A.status<300||A.status===304))Ke("Couldn't load "+o+". Status: "+A.status);if(A.response!==void 0)return new Uint8Array(A.response||[]);return Nt(A.responseText??"",!0)},b=this;if(b.setDataGetter((F)=>{var T=F*U,A=(F+1)*U-1;if(A=Math.min(A,M-1),typeof b.chunks[F]>"u")b.chunks[F]=E(T,A);if(typeof b.chunks[F]>"u")Ke("doXHR failed!");return b.chunks[F]}),W||!M)U=M=1,M=this.getter(0).length,U=M,kt("LazyFiles on gzip forces download of the whole file when length is accessed");this._length=M,this._chunkSize=U,this.lengthKnown=!0}get length(){if(!this.lengthKnown)this.cacheLength();return this._length}get chunkSize(){if(!this.lengthKnown)this.cacheLength();return this._chunkSize}}if(globalThis.XMLHttpRequest){if(!te)Ke("Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc");var a=new r,_={isDevice:!1,contents:a}}else var _={isDevice:!1,url:o};var h=l.createFile(e,n,_,i,t);if(_.contents)h.contents=_.contents;else if(_.url)h.contents=null,h.url=_.url;Object.defineProperties(h,{usedBytes:{get:function(){return this.contents.length}}});var I={};for(let[R,M]of Object.entries(h.stream_ops))I[R]=(...p)=>(l.forceLoadFile(h),M(...p));function S(R,M,p,ne,W){var U=R.node.contents;if(W>=U.length)return 0;var E=Math.min(U.length-W,ne);if(U.slice)for(var b=0;b<E;b++)M[p+b]=U[W+b];else for(var b=0;b<E;b++)M[p+b]=U.get(W+b);return E}return I.read=(R,M,p,ne,W)=>(l.forceLoadFile(h),S(R,M,p,ne,W)),I.mmap=(R,M,p,ne,W)=>{l.forceLoadFile(h);var U=_n(M);if(!U)throw new l.ErrnoError(48);return S(R,Ue,U,M,p),{ptr:U,allocated:!0}},h.stream_ops=I,h}},Pr=(e,n,o)=>{if(!e)return"";var i=an(Xe,e,n,o);return on.decode(Xe.subarray(e,i))},Se={currentUmask:18,calculateAt(e,n,o){if(xe.isAbs(n))return n;var i;if(e===-100)i=l.cwd();else{var t=Se.getStreamFromFD(e);i=t.path}if(n.length==0){if(!o)throw new l.ErrnoError(44);return i}return i+"/"+n},writeStat(e,n){ke[e>>2]=n.dev,ke[e+4>>2]=n.mode,ke[e+8>>2]=n.nlink,ke[e+12>>2]=n.uid,ke[e+16>>2]=n.gid,ke[e+20>>2]=n.rdev,Be[e+24>>3]=BigInt(n.size),Ie[e+32>>2]=4096,Ie[e+36>>2]=n.blocks;var o=n.atime.getTime(),i=n.mtime.getTime(),t=n.ctime.getTime();return Be[e+40>>3]=BigInt(Math.floor(o/1000)),ke[e+48>>2]=o%1000*1000*1000,Be[e+56>>3]=BigInt(Math.floor(i/1000)),ke[e+64>>2]=i%1000*1000*1000,Be[e+72>>3]=BigInt(Math.floor(t/1000)),ke[e+80>>2]=t%1000*1000*1000,Be[e+88>>3]=BigInt(n.ino),0},writeStatFs(e,n){ke[e+4>>2]=n.bsize,ke[e+60>>2]=n.bsize,Be[e+8>>3]=BigInt(n.blocks),Be[e+16>>3]=BigInt(n.bfree),Be[e+24>>3]=BigInt(n.bavail),Be[e+32>>3]=BigInt(n.files),Be[e+40>>3]=BigInt(n.ffree),ke[e+48>>2]=n.fsid,ke[e+64>>2]=n.flags,ke[e+56>>2]=n.namelen},doMsync(e,n,o,i,t){if(!l.isFile(n.node.mode))throw new l.ErrnoError(43);if(i&2)return 0;var r=Xe.subarray(e,e+o);l.msync(n,r,t,o,i)},getStreamFromFD(e){var n=l.getStreamChecked(e);return n},varargs:void 0,getStr(e){var n=Pr(e);return n}};function Fr(e,n){try{return e=Se.getStr(e),l.chmod(e,n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Lr(e,n,o,i){try{if(n=Se.getStr(n),n=Se.calculateAt(e,n),o&-8)return-28;var t=l.lookupPath(n,{follow:!0}),r=t.node;if(!r)return-44;var a="";if(o&4)a+="r";if(o&2)a+="w";if(o&1)a+="x";if(a&&l.nodePermissions(r,a))return-2;return 0}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}function Dr(e,n){try{return l.fchmod(e,n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Cr(e,n,o){try{return l.fchown(e,n,o),0}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var It=()=>{var e=Ie[+Se.varargs>>2];return Se.varargs+=4,e},pt=It;function Nr(e,n,o){Se.varargs=o;try{var i=Se.getStreamFromFD(e);switch(n){case 0:{var t=It();if(t<0)return-28;while(l.streams[t])t++;var r=l.dupStream(i,t);return r.fd}case 1:case 2:return 0;case 3:return i.flags;case 4:{var t=It(),a=289792;return i.flags=i.flags&~a|t&a,0}case 12:{var t=pt(),_=0;return at[t+_>>1]=2,0}case 13:case 14:return 0}return-28}catch(h){if(typeof l>"u"||h.name!=="ErrnoError")throw h;return-h.errno}}function Rr(e,n){try{return Se.writeStat(n,l.fstat(e))}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var Mr=9007199254740992,Wr=-9007199254740992,ht=(e)=>e<Wr||e>Mr?NaN:Number(e);function jr(e,n){n=ht(n);try{if(isNaN(n))return-22;return l.ftruncate(e,n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}var ct=(e,n,o)=>ln(e,Xe,n,o);function zr(e,n){try{if(n===0)return-28;var o=l.cwd(),i=At(o)+1;if(n<i)return-68;return ct(o,e,n),i}catch(t){if(typeof l>"u"||t.name!=="ErrnoError")throw t;return-t.errno}}function Br(e,n,o){Se.varargs=o;try{var i=Se.getStreamFromFD(e);switch(n){case 21509:{if(!i.tty)return-59;return 0}case 21505:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tcgets){var t=i.tty.ops.ioctl_tcgets(i),r=pt();Ie[r>>2]=t.c_iflag||0,Ie[r+4>>2]=t.c_oflag||0,Ie[r+8>>2]=t.c_cflag||0,Ie[r+12>>2]=t.c_lflag||0;for(var a=0;a<32;a++)Ue[r+a+17]=t.c_cc[a]||0;return 0}return 0}case 21510:case 21511:case 21512:{if(!i.tty)return-59;return 0}case 21506:case 21507:case 21508:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tcsets){var r=pt(),_=Ie[r>>2],h=Ie[r+4>>2],I=Ie[r+8>>2],S=Ie[r+12>>2],R=[];for(var a=0;a<32;a++)R.push(Ue[r+a+17]);return i.tty.ops.ioctl_tcsets(i.tty,n,{c_iflag:_,c_oflag:h,c_cflag:I,c_lflag:S,c_cc:R})}return 0}case 21519:{if(!i.tty)return-59;var r=pt();return Ie[r>>2]=0,0}case 21520:{if(!i.tty)return-59;return-28}case 21537:case 21531:{var r=pt();return l.ioctl(i,n,r)}case 21523:{if(!i.tty)return-59;if(i.tty.ops.ioctl_tiocgwinsz){var M=i.tty.ops.ioctl_tiocgwinsz(i.tty),r=pt();at[r>>1]=M[0],at[r+2>>1]=M[1]}return 0}case 21524:{if(!i.tty)return-59;return 0}case 21515:{if(!i.tty)return-59;return 0}default:return-28}}catch(p){if(typeof l>"u"||p.name!=="ErrnoError")throw p;return-p.errno}}function Ur(e,n){try{return e=Se.getStr(e),Se.writeStat(n,l.lstat(e))}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Qr(e,n,o){try{return n=Se.getStr(n),n=Se.calculateAt(e,n),o&=~Se.currentUmask,l.mkdir(n,o,0),0}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}function Vr(e,n,o,i){try{n=Se.getStr(n);var t=i&256,r=i&4096;return i=i&-6401,n=Se.calculateAt(e,n,r),Se.writeStat(o,t?l.lstat(n):l.stat(n))}catch(a){if(typeof l>"u"||a.name!=="ErrnoError")throw a;return-a.errno}}function Hr(e,n,o,i){Se.varargs=i;try{n=Se.getStr(n),n=Se.calculateAt(e,n);var t=i?It():0;if(o&64)t&=~Se.currentUmask;return l.open(n,o,t).fd}catch(r){if(typeof l>"u"||r.name!=="ErrnoError")throw r;return-r.errno}}function Gr(e,n,o,i){try{if(n=Se.getStr(n),n=Se.calculateAt(e,n),i<=0)return-28;var t=l.readlink(n),r=Math.min(i,At(t)),a=Ue[o+r];return ct(t,o,i+1),Ue[o+r]=a,r}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}function Kr(e){try{return e=Se.getStr(e),l.rmdir(e),0}catch(n){if(typeof l>"u"||n.name!=="ErrnoError")throw n;return-n.errno}}function $r(e,n){try{return e=Se.getStr(e),Se.writeStat(n,l.stat(e))}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return-o.errno}}function Jr(e,n,o){try{if(n=Se.getStr(n),n=Se.calculateAt(e,n),!o)l.unlink(n);else if(o===512)l.rmdir(n);else return-28;return 0}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return-i.errno}}var hn=(e)=>ke[e>>2]+Ie[e+4>>2]*4294967296;function Yr(e,n,o,i){try{var t=i&256;n=Se.getStr(n),n=Se.calculateAt(e,n,!0);var r=Date.now(),a,_;if(!o)a=r,_=r;else{var h=hn(o),I=Ie[o+8>>2];if(I==1073741823)a=r;else if(I==1073741822)a=null;else a=h*1000+I/1e6;if(o+=16,h=hn(o),I=Ie[o+8>>2],I==1073741823)_=r;else if(I==1073741822)_=null;else _=h*1000+I/1e6}if((_??a)!==null)l.utime(n,a,_,t);return 0}catch(S){if(typeof l>"u"||S.name!=="ErrnoError")throw S;return-S.errno}}var Xr=()=>Ke(""),Zr=(e)=>e%4===0&&(e%100!==0||e%400===0),ei=[0,31,60,91,121,152,182,213,244,274,305,335],ti=[0,31,59,90,120,151,181,212,243,273,304,334],ni=(e)=>{var n=Zr(e.getFullYear()),o=n?ei:ti,i=o[e.getMonth()]+e.getDate()-1;return i};function ri(e,n){e=ht(e);var o=new Date(e*1000);if(isNaN(o.getTime()))return 1;Ie[n>>2]=o.getSeconds(),Ie[n+4>>2]=o.getMinutes(),Ie[n+8>>2]=o.getHours(),Ie[n+12>>2]=o.getDate(),Ie[n+16>>2]=o.getMonth(),Ie[n+20>>2]=o.getFullYear()-1900,Ie[n+24>>2]=o.getDay();var i=ni(o)|0;Ie[n+28>>2]=i,Ie[n+36>>2]=-(o.getTimezoneOffset()*60);var t=new Date(o.getFullYear(),0,1),r=new Date(o.getFullYear(),6,1).getTimezoneOffset(),a=t.getTimezoneOffset(),_=(r!=a&&o.getTimezoneOffset()==Math.min(a,r))|0;return Ie[n+32>>2]=_,0}function ii(e,n,o,i,t,r,a){t=ht(t);try{var _=Se.getStreamFromFD(i),h=l.mmap(_,e,t,n,o),I=h.ptr;return Ie[r>>2]=h.allocated,ke[a>>2]=I,0}catch(S){if(typeof l>"u"||S.name!=="ErrnoError")throw S;return-S.errno}}function si(e,n,o,i,t,r){r=ht(r);try{var a=Se.getStreamFromFD(t);if(o&2)Se.doMsync(e,a,n,i,r)}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return-_.errno}}var oi=(e,n,o,i)=>{var t=new Date().getFullYear(),r=new Date(t,0,1),a=new Date(t,6,1),_=r.getTimezoneOffset(),h=a.getTimezoneOffset(),I=Math.max(_,h);ke[e>>2]=I*60,Ie[n>>2]=Number(_!=h);var S=(p)=>{var ne=p>=0?"-":"+",W=Math.abs(p),U=String(Math.floor(W/60)).padStart(2,"0"),E=String(W%60).padStart(2,"0");return`UTC${ne}${U}${E}`},R=S(_),M=S(h);if(h<_)ct(R,o,17),ct(M,i,17);else ct(R,i,17),ct(M,o,17)},mn=()=>performance.now(),gn=()=>Date.now(),ai=1,li=(e)=>e>=0&&e<=3;function ci(e,n,o){if(n=ht(n),!li(e))return 28;var i;if(e===0)i=gn();else if(ai)i=mn();else return 52;var t=Math.round(i*1000*1000);return Be[o>>3]=BigInt(t),0}var bn=()=>2147483648,_i=()=>bn(),ui=(e)=>{var n=Ze.buffer.byteLength,o=(e-n+65535)/65536|0;try{return Ze.grow(o),Zt(),1}catch(i){}},fi=(e)=>{var n=Xe.length;e>>>=0;var o=bn();if(e>o)return!1;for(var i=1;i<=4;i*=2){var t=n*(1+0.2/i);t=Math.min(t,e+100663296);var r=Math.min(o,cn(Math.max(e,t),65536)),a=ui(r);if(a)return!0}return!1},Mt={},di=()=>ze,vt=()=>{if(!vt.strings){var e=(globalThis.navigator?.language??"C").replace("-","_")+".UTF-8",n={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:di()};for(var o in Mt)if(Mt[o]===void 0)delete n[o];else n[o]=Mt[o];var i=[];for(var o in n)i.push(`${o}=${n[o]}`);vt.strings=i}return vt.strings},pi=(e,n)=>{var o=0,i=0;for(var t of vt()){var r=n+o;ke[e+i>>2]=r,o+=ct(t,r,1/0)+1,i+=4}return 0},hi=(e,n)=>{var o=vt();ke[e>>2]=o.length;var i=0;for(var t of o)i+=At(t)+1;return ke[n>>2]=i,0},mi=0,gi=()=>rn||mi>0,bi=(e)=>{if(Yt=e,!gi())s.onExit?.(e),Ot=!0;nt(e,new tn(e))},yi=(e,n)=>{Yt=e,bi(e)},qi=yi;function vi(e){try{var n=Se.getStreamFromFD(e);return l.close(n),0}catch(o){if(typeof l>"u"||o.name!=="ErrnoError")throw o;return o.errno}}function Si(e,n){try{var o=0,i=0,t=0,r=Se.getStreamFromFD(e),a=r.tty?2:l.isDir(r.mode)?3:l.isLink(r.mode)?7:4;return Ue[n]=a,at[n+2>>1]=t,Be[n+8>>3]=BigInt(o),Be[n+16>>3]=BigInt(i),0}catch(_){if(typeof l>"u"||_.name!=="ErrnoError")throw _;return _.errno}}var wi=(e,n,o,i)=>{var t=0;for(var r=0;r<o;r++){var a=ke[n>>2],_=ke[n+4>>2];n+=8;try{var h=l.read(e,Ue,a,_,i)}catch(I){if(t>0&&I instanceof l.ErrnoError&&(I.errno==6||I.errno==6))break;throw I}if(h<0)return-1;if(t+=h,h<_)break;if(typeof i<"u")i+=h}return t};function Ei(e,n,o,i){try{var t=Se.getStreamFromFD(e),r=wi(t,n,o);return ke[i>>2]=r,0}catch(a){if(typeof l>"u"||a.name!=="ErrnoError")throw a;return a.errno}}function ki(e,n,o,i){n=ht(n);try{if(isNaN(n))return 22;var t=Se.getStreamFromFD(e);if(l.llseek(t,n,o),Be[i>>3]=BigInt(t.position),t.getdents&&n===0&&o===0)t.getdents=null;return 0}catch(r){if(typeof l>"u"||r.name!=="ErrnoError")throw r;return r.errno}}function Ai(e){try{var n=Se.getStreamFromFD(e),o=n.stream_ops?.fsync?.(n);return o}catch(i){if(typeof l>"u"||i.name!=="ErrnoError")throw i;return i.errno}}var Ii=(e,n,o,i)=>{if(o==1)return l.write(e,Ue,ke[n>>2],ke[n+4>>2],i);var t=0;for(var r=0,a=n;r<o;r++,a+=8)t+=ke[a+4>>2];var _=new Uint8Array(t),h=0;for(var r=0;r<o;r++,n+=8){var I=ke[n>>2],S=ke[n+4>>2];_.set(Xe.subarray(I,I+S),h),h+=S}return l.write(e,_,0,t,i)};function Ti(e,n,o,i){try{var t=Se.getStreamFromFD(e),r=Ii(t,n,o);return ke[i>>2]=r,0}catch(a){if(typeof l>"u"||a.name!=="ErrnoError")throw a;return a.errno}}l.createPreloadedFile=Or,l.preloadFile=pn,l.staticInit();{if(sr(),s.noExitRuntime)rn=s.noExitRuntime;if(s.print)kt=s.print;if(s.printErr)rt=s.printErr;if(s.arguments)Ne=s.arguments;if(s.thisProgram)ze=s.thisProgram;var mt=s.preInit;if(mt){if(typeof mt=="function")s.preInit=mt=[mt];while(mt.length>0)mt.shift()()}}s.wasmMemory=Ze;function xi(e,n){if(typeof crypto>"u"||!crypto.getRandomValues)return-1;try{var o=new Uint8Array(Xe.buffer,e,n),i=65536;for(var t=0;t<n;t+=i)crypto.getRandomValues(o.subarray(t,Math.min(t+i,n)));return 0}catch(r){return-1}}var Oi,Pi,Fi,Li,Di,Ci,Ni,Ri,Mi,Wi,ji,zi,Bi,Ui,Qi,Vi,Hi,Gi,Ki,$i,Ji,Yi,Xi,Zi,es,ts,ns,rs,is,ss,os,as,ls,cs,_s,us,fs,ds,ps,hs,ms,gs,bs,ys,qs,vs,Ss,ws,Es,ks,As,Is,Ts,xs,Os,Ps,Fs,Ls,Ds,Cs,Ns,Rs,Ms,Ws,js,zs,Bs,Us,Qs,Vs,Hs,Gs,Ks,$s,Js,Ys,Xs,Zs,eo,to,no,ro,io,so,oo,ao,lo,co,_o,uo,fo,po,ho,mo,go,bo,yo,qo,vo,So,wo,Eo,ko,Ao,Io,To,xo,Oo,Po,Fo,Lo,Do,Co,No,Ro,Mo,Wo,jo,zo,Bo,Uo,Qo,Vo,Ho,Go,Ko,$o,Jo,Yo,Xo,Zo,ea,ta,na,ra,ia,sa,oa,aa,la,ca,_a,ua,fa,da,pa,ha,ma,ga,ba,ya,qa,va,Sa,wa,Ea,ka,Aa,Ia,Ta,xa,Oa,Pa,Fa,La,Da,Ca,Na,Ra,Ma,Wa,ja,za,Ba,Ua,Qa,Va,Ha,Ga,Ka,$a,Ja,Ya,Xa,Za,el,tl,nl,rl,il,sl,ol,al,ll,cl,_l,ul,fl,dl,pl,hl,ml,gl,bl,yl,ql,vl,Sl,wl,El,kl,Al,Il,Tl,xl,Ol,Pl,Fl,Ll,Dl,Cl,Nl,Rl,Ml,Wl,jl,zl,Bl,Ul,Ql,Vl,Hl,Gl,Kl,$l,Jl,Yl,Xl,Zl,ec,tc,nc,rc,ic,sc,oc,ac,lc,cc,_c,uc,fc,dc,pc,hc,mc,gc,bc,yc,qc,vc,Sc,wc,Ec,kc,Ac,Ic,Tc,xc,Oc,Pc,Fc,Lc,Dc,Cc,Nc,Rc,yn,qn,Mc,vn,Wc;function jc(e){Oi=s._sqlite3_status64=e.sqlite3_status64,Pi=s._sqlite3_status=e.sqlite3_status,Fi=s._sqlite3_db_status64=e.sqlite3_db_status64,Li=s._sqlite3_msize=e.sqlite3_msize,Di=s._sqlite3_db_status=e.sqlite3_db_status,Ci=s._sqlite3_vfs_find=e.sqlite3_vfs_find,Ni=s._sqlite3_initialize=e.sqlite3_initialize,Ri=s._sqlite3_vfs_register=e.sqlite3_vfs_register,Mi=s._sqlite3_vfs_unregister=e.sqlite3_vfs_unregister,Wi=s._sqlite3_malloc=e.sqlite3_malloc,ji=s._sqlite3_malloc64=e.sqlite3_malloc64,zi=s._sqlite3_free=e.sqlite3_free,Bi=s._sqlite3_realloc=e.sqlite3_realloc,Ui=s._sqlite3_realloc64=e.sqlite3_realloc64,Qi=s._sqlite3_value_text=e.sqlite3_value_text,Vi=s._sqlite3_randomness=e.sqlite3_randomness,Hi=s._sqlite3_stricmp=e.sqlite3_stricmp,Gi=s._sqlite3_strnicmp=e.sqlite3_strnicmp,Ki=s._sqlite3_uri_parameter=e.sqlite3_uri_parameter,$i=s._sqlite3_uri_boolean=e.sqlite3_uri_boolean,Ji=s._sqlite3_serialize=e.sqlite3_serialize,Yi=s._sqlite3_prepare_v2=e.sqlite3_prepare_v2,Xi=s._sqlite3_step=e.sqlite3_step,Zi=s._sqlite3_column_int64=e.sqlite3_column_int64,es=s._sqlite3_reset=e.sqlite3_reset,ts=s._sqlite3_exec=e.sqlite3_exec,ns=s._sqlite3_column_int=e.sqlite3_column_int,rs=s._sqlite3_finalize=e.sqlite3_finalize,is=s._sqlite3_file_control=e.sqlite3_file_control,ss=s._sqlite3_column_name=e.sqlite3_column_name,os=s._sqlite3_column_text=e.sqlite3_column_text,as=s._sqlite3_column_type=e.sqlite3_column_type,ls=s._sqlite3_errmsg=e.sqlite3_errmsg,cs=s._sqlite3_deserialize=e.sqlite3_deserialize,_s=s._sqlite3_backup_init=e.sqlite3_backup_init,us=s._sqlite3_backup_step=e.sqlite3_backup_step,fs=s._sqlite3_backup_finish=e.sqlite3_backup_finish,ds=s._sqlite3_backup_remaining=e.sqlite3_backup_remaining,ps=s._sqlite3_backup_pagecount=e.sqlite3_backup_pagecount,hs=s._sqlite3_clear_bindings=e.sqlite3_clear_bindings,ms=s._sqlite3_value_blob=e.sqlite3_value_blob,gs=s._sqlite3_value_bytes=e.sqlite3_value_bytes,bs=s._sqlite3_value_double=e.sqlite3_value_double,ys=s._sqlite3_value_int=e.sqlite3_value_int,qs=s._sqlite3_value_int64=e.sqlite3_value_int64,vs=s._sqlite3_value_subtype=e.sqlite3_value_subtype,Ss=s._sqlite3_value_pointer=e.sqlite3_value_pointer,ws=s._sqlite3_value_type=e.sqlite3_value_type,Es=s._sqlite3_value_nochange=e.sqlite3_value_nochange,ks=s._sqlite3_value_frombind=e.sqlite3_value_frombind,As=s._sqlite3_value_dup=e.sqlite3_value_dup,Is=s._sqlite3_value_free=e.sqlite3_value_free,Ts=s._sqlite3_result_blob=e.sqlite3_result_blob,xs=s._sqlite3_result_error_toobig=e.sqlite3_result_error_toobig,Os=s._sqlite3_result_error_nomem=e.sqlite3_result_error_nomem,Ps=s._sqlite3_result_double=e.sqlite3_result_double,Fs=s._sqlite3_result_error=e.sqlite3_result_error,Ls=s._sqlite3_result_int=e.sqlite3_result_int,Ds=s._sqlite3_result_int64=e.sqlite3_result_int64,Cs=s._sqlite3_result_null=e.sqlite3_result_null,Ns=s._sqlite3_result_pointer=e.sqlite3_result_pointer,Rs=s._sqlite3_result_subtype=e.sqlite3_result_subtype,Ms=s._sqlite3_result_text=e.sqlite3_result_text,Ws=s._sqlite3_result_zeroblob=e.sqlite3_result_zeroblob,js=s._sqlite3_result_zeroblob64=e.sqlite3_result_zeroblob64,zs=s._sqlite3_result_error_code=e.sqlite3_result_error_code,Bs=s._sqlite3_user_data=e.sqlite3_user_data,Us=s._sqlite3_context_db_handle=e.sqlite3_context_db_handle,Qs=s._sqlite3_vtab_nochange=e.sqlite3_vtab_nochange,Vs=s._sqlite3_vtab_in_first=e.sqlite3_vtab_in_first,Hs=s._sqlite3_vtab_in_next=e.sqlite3_vtab_in_next,Gs=s._sqlite3_aggregate_context=e.sqlite3_aggregate_context,Ks=s._sqlite3_get_auxdata=e.sqlite3_get_auxdata,$s=s._sqlite3_set_auxdata=e.sqlite3_set_auxdata,Js=s._sqlite3_column_count=e.sqlite3_column_count,Ys=s._sqlite3_data_count=e.sqlite3_data_count,Xs=s._sqlite3_column_blob=e.sqlite3_column_blob,Zs=s._sqlite3_column_bytes=e.sqlite3_column_bytes,eo=s._sqlite3_column_double=e.sqlite3_column_double,to=s._sqlite3_column_value=e.sqlite3_column_value,no=s._sqlite3_column_decltype=e.sqlite3_column_decltype,ro=s._sqlite3_column_database_name=e.sqlite3_column_database_name,io=s._sqlite3_column_table_name=e.sqlite3_column_table_name,so=s._sqlite3_column_origin_name=e.sqlite3_column_origin_name,oo=s._sqlite3_bind_blob=e.sqlite3_bind_blob,ao=s._sqlite3_bind_double=e.sqlite3_bind_double,lo=s._sqlite3_bind_int=e.sqlite3_bind_int,co=s._sqlite3_bind_int64=e.sqlite3_bind_int64,_o=s._sqlite3_bind_null=e.sqlite3_bind_null,uo=s._sqlite3_bind_pointer=e.sqlite3_bind_pointer,fo=s._sqlite3_bind_text=e.sqlite3_bind_text,po=s._sqlite3_bind_zeroblob=e.sqlite3_bind_zeroblob,ho=s._sqlite3_bind_parameter_count=e.sqlite3_bind_parameter_count,mo=s._sqlite3_bind_parameter_name=e.sqlite3_bind_parameter_name,go=s._sqlite3_bind_parameter_index=e.sqlite3_bind_parameter_index,bo=s._sqlite3_db_handle=e.sqlite3_db_handle,yo=s._sqlite3_stmt_readonly=e.sqlite3_stmt_readonly,qo=s._sqlite3_stmt_isexplain=e.sqlite3_stmt_isexplain,vo=s._sqlite3_stmt_explain=e.sqlite3_stmt_explain,So=s._sqlite3_stmt_busy=e.sqlite3_stmt_busy,wo=s._sqlite3_next_stmt=e.sqlite3_next_stmt,Eo=s._sqlite3_stmt_status=e.sqlite3_stmt_status,ko=s._sqlite3_sql=e.sqlite3_sql,Ao=s._sqlite3_expanded_sql=e.sqlite3_expanded_sql,Io=s._sqlite3_preupdate_old=e.sqlite3_preupdate_old,To=s._sqlite3_preupdate_count=e.sqlite3_preupdate_count,xo=s._sqlite3_preupdate_depth=e.sqlite3_preupdate_depth,Oo=s._sqlite3_preupdate_blobwrite=e.sqlite3_preupdate_blobwrite,Po=s._sqlite3_preupdate_new=e.sqlite3_preupdate_new,Fo=s._sqlite3_value_numeric_type=e.sqlite3_value_numeric_type,Lo=s._sqlite3_set_authorizer=e.sqlite3_set_authorizer,Do=s._sqlite3_strglob=e.sqlite3_strglob,Co=s._sqlite3_strlike=e.sqlite3_strlike,No=s._sqlite3_auto_extension=e.sqlite3_auto_extension,Ro=s._sqlite3_cancel_auto_extension=e.sqlite3_cancel_auto_extension,Mo=s._sqlite3_reset_auto_extension=e.sqlite3_reset_auto_extension,Wo=s._sqlite3_prepare_v3=e.sqlite3_prepare_v3,jo=s._sqlite3_create_module=e.sqlite3_create_module,zo=s._sqlite3_create_module_v2=e.sqlite3_create_module_v2,Bo=s._sqlite3_drop_modules=e.sqlite3_drop_modules,Uo=s._sqlite3_declare_vtab=e.sqlite3_declare_vtab,Qo=s._sqlite3_vtab_on_conflict=e.sqlite3_vtab_on_conflict,Vo=s._sqlite3_vtab_collation=e.sqlite3_vtab_collation,Ho=s._sqlite3_vtab_in=e.sqlite3_vtab_in,Go=s._sqlite3_vtab_rhs_value=e.sqlite3_vtab_rhs_value,Ko=s._sqlite3_vtab_distinct=e.sqlite3_vtab_distinct,$o=s._sqlite3_keyword_name=e.sqlite3_keyword_name,Jo=s._sqlite3_keyword_count=e.sqlite3_keyword_count,Yo=s._sqlite3_keyword_check=e.sqlite3_keyword_check,Xo=s._sqlite3_complete=e.sqlite3_complete,Zo=s._sqlite3_libversion=e.sqlite3_libversion,ea=s._sqlite3_libversion_number=e.sqlite3_libversion_number,ta=s._sqlite3mc_vfs_create=e.sqlite3mc_vfs_create,na=s._sqlite3_shutdown=e.sqlite3_shutdown,ra=s._sqlite3mc_vfs_shutdown=e.sqlite3mc_vfs_shutdown,ia=s._sqlite3_last_insert_rowid=e.sqlite3_last_insert_rowid,sa=s._sqlite3_set_last_insert_rowid=e.sqlite3_set_last_insert_rowid,oa=s._sqlite3_changes64=e.sqlite3_changes64,aa=s._sqlite3_changes=e.sqlite3_changes,la=s._sqlite3_total_changes64=e.sqlite3_total_changes64,ca=s._sqlite3_total_changes=e.sqlite3_total_changes,_a=s._sqlite3_txn_state=e.sqlite3_txn_state,ua=s._sqlite3_close_v2=e.sqlite3_close_v2,fa=s._sqlite3_busy_handler=e.sqlite3_busy_handler,da=s._sqlite3_progress_handler=e.sqlite3_progress_handler,pa=s._sqlite3_busy_timeout=e.sqlite3_busy_timeout,ha=s._sqlite3_interrupt=e.sqlite3_interrupt,ma=s._sqlite3_is_interrupted=e.sqlite3_is_interrupted,ga=s._sqlite3_create_function=e.sqlite3_create_function,ba=s._sqlite3_create_function_v2=e.sqlite3_create_function_v2,ya=s._sqlite3_create_window_function=e.sqlite3_create_window_function,qa=s._sqlite3_overload_function=e.sqlite3_overload_function,va=s._sqlite3_trace_v2=e.sqlite3_trace_v2,Sa=s._sqlite3_commit_hook=e.sqlite3_commit_hook,wa=s._sqlite3_update_hook=e.sqlite3_update_hook,Ea=s._sqlite3_rollback_hook=e.sqlite3_rollback_hook,ka=s._sqlite3_preupdate_hook=e.sqlite3_preupdate_hook,Aa=s._sqlite3_set_errmsg=e.sqlite3_set_errmsg,Ia=s._sqlite3_error_offset=e.sqlite3_error_offset,Ta=s._sqlite3_errcode=e.sqlite3_errcode,xa=s._sqlite3_extended_errcode=e.sqlite3_extended_errcode,Oa=s._sqlite3_errstr=e.sqlite3_errstr,Pa=s._sqlite3_limit=e.sqlite3_limit,Fa=s._sqlite3_open=e.sqlite3_open,La=s._sqlite3_open_v2=e.sqlite3_open_v2,Da=s._sqlite3_create_collation=e.sqlite3_create_collation,Ca=s._sqlite3_create_collation_v2=e.sqlite3_create_collation_v2,Na=s._sqlite3_collation_needed=e.sqlite3_collation_needed,Ra=s._sqlite3_get_autocommit=e.sqlite3_get_autocommit,Ma=s._sqlite3_table_column_metadata=e.sqlite3_table_column_metadata,Wa=s._sqlite3_extended_result_codes=e.sqlite3_extended_result_codes,ja=s._sqlite3_uri_key=e.sqlite3_uri_key,za=s._sqlite3_uri_int64=e.sqlite3_uri_int64,Ba=s._sqlite3_db_name=e.sqlite3_db_name,Ua=s._sqlite3_db_filename=e.sqlite3_db_filename,Qa=s._sqlite3_db_readonly=e.sqlite3_db_readonly,Va=s._sqlite3_compileoption_used=e.sqlite3_compileoption_used,Ha=s._sqlite3_compileoption_get=e.sqlite3_compileoption_get,Ga=s._sqlite3session_diff=e.sqlite3session_diff,Ka=s._sqlite3session_attach=e.sqlite3session_attach,$a=s._sqlite3session_create=e.sqlite3session_create,Ja=s._sqlite3session_delete=e.sqlite3session_delete,Ya=s._sqlite3session_table_filter=e.sqlite3session_table_filter,Xa=s._sqlite3session_changeset=e.sqlite3session_changeset,Za=s._sqlite3session_changeset_strm=e.sqlite3session_changeset_strm,el=s._sqlite3session_patchset_strm=e.sqlite3session_patchset_strm,tl=s._sqlite3session_patchset=e.sqlite3session_patchset,nl=s._sqlite3session_enable=e.sqlite3session_enable,rl=s._sqlite3session_indirect=e.sqlite3session_indirect,il=s._sqlite3session_isempty=e.sqlite3session_isempty,sl=s._sqlite3session_memory_used=e.sqlite3session_memory_used,ol=s._sqlite3session_object_config=e.sqlite3session_object_config,al=s._sqlite3session_changeset_size=e.sqlite3session_changeset_size,ll=s._sqlite3changeset_start=e.sqlite3changeset_start,cl=s._sqlite3changeset_start_v2=e.sqlite3changeset_start_v2,_l=s._sqlite3changeset_start_strm=e.sqlite3changeset_start_strm,ul=s._sqlite3changeset_start_v2_strm=e.sqlite3changeset_start_v2_strm,fl=s._sqlite3changeset_next=e.sqlite3changeset_next,dl=s._sqlite3changeset_op=e.sqlite3changeset_op,pl=s._sqlite3changeset_pk=e.sqlite3changeset_pk,hl=s._sqlite3changeset_old=e.sqlite3changeset_old,ml=s._sqlite3changeset_new=e.sqlite3changeset_new,gl=s._sqlite3changeset_conflict=e.sqlite3changeset_conflict,bl=s._sqlite3changeset_fk_conflicts=e.sqlite3changeset_fk_conflicts,yl=s._sqlite3changeset_finalize=e.sqlite3changeset_finalize,ql=s._sqlite3changeset_invert=e.sqlite3changeset_invert,vl=s._sqlite3changeset_invert_strm=e.sqlite3changeset_invert_strm,Sl=s._sqlite3changeset_apply_v2=e.sqlite3changeset_apply_v2,wl=s._sqlite3changeset_apply_v3=e.sqlite3changeset_apply_v3,El=s._sqlite3changeset_apply=e.sqlite3changeset_apply,kl=s._sqlite3changeset_apply_v3_strm=e.sqlite3changeset_apply_v3_strm,Al=s._sqlite3changeset_apply_v2_strm=e.sqlite3changeset_apply_v2_strm,Il=s._sqlite3changeset_apply_strm=e.sqlite3changeset_apply_strm,Tl=s._sqlite3changegroup_new=e.sqlite3changegroup_new,xl=s._sqlite3changegroup_add=e.sqlite3changegroup_add,Ol=s._sqlite3changegroup_output=e.sqlite3changegroup_output,Pl=s._sqlite3changegroup_add_strm=e.sqlite3changegroup_add_strm,Fl=s._sqlite3changegroup_output_strm=e.sqlite3changegroup_output_strm,Ll=s._sqlite3changegroup_delete=e.sqlite3changegroup_delete,Dl=s._sqlite3changeset_concat=e.sqlite3changeset_concat,Cl=s._sqlite3changeset_concat_strm=e.sqlite3changeset_concat_strm,Nl=s._sqlite3session_config=e.sqlite3session_config,Rl=s._sqlite3_sourceid=e.sqlite3_sourceid,Ml=s._sqlite3mc_version=e.sqlite3mc_version,Wl=s._sqlite3mc_config=e.sqlite3mc_config,jl=s._sqlite3mc_cipher_count=e.sqlite3mc_cipher_count,zl=s._sqlite3mc_cipher_index=e.sqlite3mc_cipher_index,Bl=s._sqlite3mc_cipher_name=e.sqlite3mc_cipher_name,Ul=s._sqlite3mc_cipher_name_copy=e.sqlite3mc_cipher_name_copy,Ql=s._sqlite3mc_config_cipher=e.sqlite3mc_config_cipher,Vl=s._sqlite3mc_codec_data=e.sqlite3mc_codec_data,Hl=s._sqlite3_activate_see=e.sqlite3_activate_see,Gl=s._sqlite3_key=e.sqlite3_key,Kl=s._sqlite3_key_v2=e.sqlite3_key_v2,$l=s._sqlite3_rekey_v2=e.sqlite3_rekey_v2,Jl=s._sqlite3_rekey=e.sqlite3_rekey,Yl=s._sqlite3mc_vfs_destroy=e.sqlite3mc_vfs_destroy,Xl=s._sqlite3__wasm_pstack_ptr=e.sqlite3__wasm_pstack_ptr,Zl=s._sqlite3__wasm_pstack_restore=e.sqlite3__wasm_pstack_restore,ec=s._sqlite3__wasm_pstack_alloc=e.sqlite3__wasm_pstack_alloc,tc=s._sqlite3__wasm_pstack_remaining=e.sqlite3__wasm_pstack_remaining,nc=s._sqlite3__wasm_pstack_quota=e.sqlite3__wasm_pstack_quota,rc=s._sqlite3__wasm_test_struct=e.sqlite3__wasm_test_struct,ic=s._sqlite3__wasm_enum_json=e.sqlite3__wasm_enum_json,sc=s._sqlite3__wasm_vfs_unlink=e.sqlite3__wasm_vfs_unlink,oc=s._sqlite3__wasm_db_vfs=e.sqlite3__wasm_db_vfs,ac=s._sqlite3__wasm_db_reset=e.sqlite3__wasm_db_reset,lc=s._sqlite3__wasm_db_export_chunked=e.sqlite3__wasm_db_export_chunked,cc=s._sqlite3__wasm_db_serialize=e.sqlite3__wasm_db_serialize,_c=s._sqlite3__wasm_vfs_create_file=e.sqlite3__wasm_vfs_create_file,uc=s._sqlite3__wasm_posix_create_file=e.sqlite3__wasm_posix_create_file,fc=s._sqlite3__wasm_kvvfsMakeKey=e.sqlite3__wasm_kvvfsMakeKey,dc=s._sqlite3__wasm_kvvfs_methods=e.sqlite3__wasm_kvvfs_methods,pc=s._sqlite3__wasm_vtab_config=e.sqlite3__wasm_vtab_config,hc=s._sqlite3__wasm_db_config_ip=e.sqlite3__wasm_db_config_ip,mc=s._sqlite3__wasm_db_config_pii=e.sqlite3__wasm_db_config_pii,gc=s._sqlite3__wasm_db_config_s=e.sqlite3__wasm_db_config_s,bc=s._sqlite3__wasm_config_i=e.sqlite3__wasm_config_i,yc=s._sqlite3__wasm_config_ii=e.sqlite3__wasm_config_ii,qc=s._sqlite3__wasm_config_j=e.sqlite3__wasm_config_j,vc=s._sqlite3__wasm_qfmt_token=e.sqlite3__wasm_qfmt_token,Sc=s._sqlite3__wasm_kvvfs_decode=e.sqlite3__wasm_kvvfs_decode,wc=s._sqlite3__wasm_kvvfs_encode=e.sqlite3__wasm_kvvfs_encode,Ec=s._sqlite3__wasm_init_wasmfs=e.sqlite3__wasm_init_wasmfs,kc=s._sqlite3__wasm_test_intptr=e.sqlite3__wasm_test_intptr,Ac=s._sqlite3__wasm_test_voidptr=e.sqlite3__wasm_test_voidptr,Ic=s._sqlite3__wasm_test_int64_max=e.sqlite3__wasm_test_int64_max,Tc=s._sqlite3__wasm_test_int64_min=e.sqlite3__wasm_test_int64_min,xc=s._sqlite3__wasm_test_int64_times2=e.sqlite3__wasm_test_int64_times2,Oc=s._sqlite3__wasm_test_int64_minmax=e.sqlite3__wasm_test_int64_minmax,Pc=s._sqlite3__wasm_test_int64ptr=e.sqlite3__wasm_test_int64ptr,Fc=s._sqlite3__wasm_test_stack_overflow=e.sqlite3__wasm_test_stack_overflow,Lc=s._sqlite3__wasm_test_str_hello=e.sqlite3__wasm_test_str_hello,Dc=s._sqlite3__wasm_SQLTester_strglob=e.sqlite3__wasm_SQLTester_strglob,Cc=s._malloc=e.malloc,Nc=s._free=e.free,Rc=s._realloc=e.realloc,yn=e.emscripten_builtin_memalign,qn=e._emscripten_stack_restore,Mc=e._emscripten_stack_alloc,vn=e.emscripten_stack_get_current,Wc=e.__indirect_function_table}var Sn={__syscall_chmod:Fr,__syscall_faccessat:Lr,__syscall_fchmod:Dr,__syscall_fchown32:Cr,__syscall_fcntl64:Nr,__syscall_fstat64:Rr,__syscall_ftruncate64:jr,__syscall_getcwd:zr,__syscall_ioctl:Br,__syscall_lstat64:Ur,__syscall_mkdirat:Qr,__syscall_newfstatat:Vr,__syscall_openat:Hr,__syscall_readlinkat:Gr,__syscall_rmdir:Kr,__syscall_stat64:$r,__syscall_unlinkat:Jr,__syscall_utimensat:Yr,_abort_js:Xr,_localtime_js:ri,_mmap_js:ii,_munmap_js:si,_tzset_js:oi,clock_time_get:ci,emscripten_date_now:gn,emscripten_get_heap_max:_i,emscripten_get_now:mn,emscripten_resize_heap:fi,environ_get:pi,environ_sizes_get:hi,exit:qi,fd_close:vi,fd_fdstat_get:Si,fd_read:Ei,fd_seek:ki,fd_sync:Ai,fd_write:Ti,memory:Ze,wasm_crypto_getrandom:xi};async function zc(){if(or(),lt)await kr();var e=s.setStatus;if(e)e("Running..."),await new Promise((n)=>setTimeout(n,1)),setTimeout(e,1,"");if(Ot)return;ar(),s.onRuntimeInitialized?.(),lr()}var gt=await hr();return await zc(),s.runSQLite3PostLoadInit=async function(e,n,o){delete n.runSQLite3PostLoadInit,globalThis.sqlite3ApiBootstrap=async function i(t=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;let r=(...f)=>Object.assign(Object.create(null),...f),a=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},t);Object.assign(a,{allocExportName:a.useStdAlloc?"malloc":"sqlite3_malloc",deallocExportName:a.useStdAlloc?"free":"sqlite3_free",reallocExportName:a.useStdAlloc?"realloc":"sqlite3_realloc"}),["exports","memory","functionTable","wasmfsOpfsDir"].forEach((f)=>{if(typeof a[f]==="function")a[f]=a[f]()});let _=r(),h=r(),I=(f)=>_.sqlite3_js_rc_str&&_.sqlite3_js_rc_str(f)||"Unknown result code #"+f,S=(f)=>typeof f==="number"&&f===(f|0)&&f<=2147483647&&f>=-2147483648;class R extends Error{constructor(...f){let w;if(f.length)if(S(f[0]))if(w=f[0],f.length===1)super(I(f[0]));else{let N=I(w);if(typeof f[1]==="object")super(N,f[1]);else{f[0]=N+":";super(f.join(" "))}}else if(f.length===2&&typeof f[1]==="object")super(...f);else super(f.join(" "));this.resultCode=w||_.SQLITE_ERROR,this.name="SQLite3Error"}}R.toss=(...f)=>{throw new R(...f)};let M=R.toss;if(a.wasmfsOpfsDir&&!/^\/[^/]+$/.test(a.wasmfsOpfsDir))M("config.wasmfsOpfsDir must be falsy or in the form '/dir-name'.");let p=function f(w){if(!f._max)f._max=BigInt("0x7fffffffffffffff"),f._min=~f._max;return w>=f._min&&w<=f._max},ne=(f)=>f>=-0x7fffffffn-1n&&f<=0x7fffffffn,W=function f(w){if(!f._min)f._min=Number.MIN_SAFE_INTEGER,f._max=Number.MAX_SAFE_INTEGER;return w>=f._min&&w<=f._max},U=(f)=>f&&f.constructor&&S(f.constructor.BYTES_PER_ELEMENT)?f:!1,E=(f)=>f&&(f instanceof Uint8Array||f instanceof Int8Array||f instanceof ArrayBuffer),b=(f)=>f&&(f instanceof Uint8Array||f instanceof Int8Array||f instanceof ArrayBuffer),F=(f)=>E(f)||M("Value is not of a supported TypedArray type."),T=function(f){if(b(f))return h.typedArrayToString(f instanceof ArrayBuffer?new Uint8Array(f):f,0,f.length);else if(Array.isArray(f))return f.join("");else if(h.isPtr(f))f=h.cstrToJs(f);return f};class A extends Error{constructor(...f){if(f.length===2&&typeof f[1]==="object")super(...f);else if(f.length)super(f.join(" "));else super("Allocation failed.");this.resultCode=_.SQLITE_NOMEM,this.name="WasmAllocError"}}A.toss=(...f)=>{throw new A(...f)},Object.assign(_,{sqlite3_bind_blob:void 0,sqlite3_bind_text:void 0,sqlite3_create_function_v2:(f,w,N,J,ie,le,we,ge,K)=>{},sqlite3_create_function:(f,w,N,J,ie,le,we,ge)=>{},sqlite3_create_window_function:(f,w,N,J,ie,le,we,ge,K,oe)=>{},sqlite3_prepare_v3:(f,w,N,J,ie,le)=>{},sqlite3_prepare_v2:(f,w,N,J,ie)=>{},sqlite3_exec:(f,w,N,J,ie)=>{},sqlite3_randomness:(f,w)=>{}});let C={affirmBindableTypedArray:F,flexibleString:T,bigIntFits32:ne,bigIntFits64:p,bigIntFitsDouble:W,isBindableTypedArray:E,isInt32:S,isSQLableTypedArray:b,isTypedArray:U,isUIThread:()=>globalThis.window===globalThis&&!!globalThis.document,toss:function(...f){throw Error(f.join(" "))},toss3:M,typedArrayPart:h.typedArrayPart,nu:r,assert:function(f,w){if(!f)C.toss("Assertion failed:",w)},affirmDbHeader:function(f){if(f instanceof ArrayBuffer)f=new Uint8Array(f);let w="SQLite format 3";if(w.length>f.byteLength)M("Input does not contain an SQLite3 database header.");for(let N=0;N<w.length;++N)if(w.charCodeAt(N)!==f[N])break},affirmIsDb:function(f){if(f instanceof ArrayBuffer)f=new Uint8Array(f);let w=f.byteLength;if(w<512||w%512!==0)M("Byte array size",w,"is invalid for an SQLite3 db.");C.affirmDbHeader(f)}};Object.assign(h,{exports:a.exports||M("Missing API config.exports (WASM module exports)."),memory:a.memory||a.exports.memory||M("API config object requires a WebAssembly.Memory object","in either config.exports.memory (exported)","or config.memory (imported)."),pointerSize:typeof a.exports.sqlite3_libversion()==="number"?4:8,bigIntEnabled:!!a.bigIntEnabled,functionTable:a.functionTable,alloc:void 0,realloc:void 0,dealloc:void 0}),h.allocFromTypedArray=function(f){if(f instanceof ArrayBuffer)f=new Uint8Array(f);F(f);let w=h.alloc(f.byteLength||1);return h.heapForSize(f.constructor).set(f.byteLength?f:[0],Number(w)),w};{let{allocExportName:f,deallocExportName:w,reallocExportName:N}=a;for(let J of[f,w,N])if(!(h.exports[J]instanceof Function))M("Missing required exports[",J,"] function.");h.alloc=function J(ie){return J.impl(ie)||A.toss("Failed to allocate",ie," bytes.")},h.alloc.impl=h.exports[f],h.realloc=function J(ie,le){let we=J.impl(h.ptr.coerce(ie),le);return le?we||A.toss("Failed to reallocate",le," bytes."):h.ptr.null},h.realloc.impl=h.exports[N],h.dealloc=function J(ie){J.impl(h.ptr.coerce(ie))},h.dealloc.impl=h.exports[w]}h.compileOptionUsed=function f(w){if(!arguments.length){if(f._result)return f._result;else if(!f._opt)f._rx=/^([^=]+)=(.+)/,f._rxInt=/^-?\d+$/,f._opt=function(we,ge){let K=f._rx.exec(we);ge[0]=K?K[1]:we,ge[1]=K?f._rxInt.test(K[2])?+K[2]:K[2]:!0};let N=r(),J=[0,0],ie=0,le;while(le=_.sqlite3_compileoption_get(ie++))f._opt(le,J),N[J[0]]=J[1];return f._result=N}else if(Array.isArray(w)){let N=r();return w.forEach((J)=>{N[J]=_.sqlite3_compileoption_used(J)}),N}else if(typeof w==="object")return Object.keys(w).forEach((N)=>{w[N]=_.sqlite3_compileoption_used(N)}),w;return typeof w==="string"?!!_.sqlite3_compileoption_used(w):!1},h.pstack=r({restore:h.exports.sqlite3__wasm_pstack_restore,alloc:function(f){if(typeof f==="string"&&!(f=h.sizeofIR(f)))A.toss("Invalid value for pstack.alloc(",arguments[0],")");return h.exports.sqlite3__wasm_pstack_alloc(f)||A.toss("Could not allocate",f,"bytes from the pstack.")},allocChunks:function(f,w){if(typeof w==="string"&&!(w=h.sizeofIR(w)))A.toss("Invalid size value for allocChunks(",arguments[1],")");let N=h.pstack.alloc(f*w),J=[N],ie=1,le=w;for(;ie<f;++ie,le+=w)J.push(h.ptr.add(N,le));return J},allocPtr:(f=1,w=!0)=>f===1?h.pstack.alloc(w?8:h.ptr.size):h.pstack.allocChunks(f,w?8:h.ptr.size),call:function(f){let w=h.pstack.pointer;try{return f(z)}finally{h.pstack.restore(w)}}}),Object.defineProperties(h.pstack,{pointer:{configurable:!1,iterable:!0,writeable:!1,get:h.exports.sqlite3__wasm_pstack_ptr},quota:{configurable:!1,iterable:!0,writeable:!1,get:h.exports.sqlite3__wasm_pstack_quota},remaining:{configurable:!1,iterable:!0,writeable:!1,get:h.exports.sqlite3__wasm_pstack_remaining}}),_.sqlite3_randomness=(...f)=>{if(f.length===1&&C.isTypedArray(f[0])&&f[0].BYTES_PER_ELEMENT===1){let w=f[0];if(w.byteLength===0)return h.exports.sqlite3_randomness(0,h.ptr.null),w;let N=h.pstack.pointer;try{let J=w.byteLength,ie=0,le=h.exports.sqlite3_randomness,we=h.heap8u(),ge=J<512?J:512,K=h.pstack.alloc(ge);do{let oe=J>ge?ge:J;le(oe,K),w.set(h.typedArrayPart(we,K,h.ptr.add(K,oe)),ie),J-=oe,ie+=oe}while(J>0)}catch(J){a.error("Highly unexpected (and ignored!) exception in sqlite3_randomness():",J)}finally{h.pstack.restore(N)}return w}h.exports.sqlite3_randomness(...f)},_.sqlite3_wasmfs_opfs_dir=function(){if(this.dir!==void 0)return this.dir;let f=a.wasmfsOpfsDir;if(!f||!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!h.exports.sqlite3__wasm_init_wasmfs)return this.dir="";try{if(f&&h.xCallWrapped("sqlite3__wasm_init_wasmfs","i32",["string"],f)===0)return this.dir=f;else return this.dir=""}catch(w){return this.dir=""}}.bind(r()),_.sqlite3_wasmfs_filename_is_persistent=function(f){let w=_.sqlite3_wasmfs_opfs_dir();return w&&f?f.startsWith(w+"/"):!1},_.sqlite3_js_db_uses_vfs=function(f,w,N=0){try{let J=_.sqlite3_vfs_find(w);if(!J)return!1;else if(!f)return J===_.sqlite3_vfs_find(0)?J:!1;else return J===_.sqlite3_js_db_vfs(f,N)?J:!1}catch(J){return!1}},_.sqlite3_js_vfs_list=function(){let f=[],w=_.sqlite3_vfs_find(h.ptr.null);while(w){let N=new _.sqlite3_vfs(w);f.push(h.cstrToJs(N.$zName)),w=N.$pNext,N.dispose()}return f},_.sqlite3_js_db_export=function(f,w=0){if(f=h.xWrap.testConvertArg("sqlite3*",f),!f)M("Invalid sqlite3* argument.");if(!h.bigIntEnabled)M("BigInt support is not enabled.");let N=h.scopedAllocPush(),J;try{let ie=h.scopedAlloc(8+h.ptr.size),le=h.ptr.add(ie,8),we=w?h.isPtr(w)?w:h.scopedAllocCString(""+w):h.ptr.null,ge=h.exports.sqlite3__wasm_db_serialize(f,we,le,ie,0);if(ge)M("Database serialization failed with code",z.capi.sqlite3_js_rc_str(ge));J=h.peekPtr(le);let K=h.peek(ie,"i64");return ge=K?h.heap8u().slice(Number(J),Number(J)+Number(K)):new Uint8Array,ge}finally{if(J)h.exports.sqlite3_free(J);h.scopedAllocPop(N)}},_.sqlite3_js_db_vfs=(f,w=h.ptr.null)=>C.sqlite3__wasm_db_vfs(f,w),_.sqlite3_js_aggregate_context=(f,w)=>_.sqlite3_aggregate_context(f,w)||(w?A.toss("Cannot allocate",w,"bytes for sqlite3_aggregate_context()"):0),_.sqlite3_js_posix_create_file=function(f,w,N){let J;if(w&&h.isPtr(w))J=w;else if(w instanceof ArrayBuffer||w instanceof Uint8Array){if(J=h.allocFromTypedArray(w),arguments.length<3||!C.isInt32(N)||N<0)N=w.byteLength}else R.toss("Invalid 2nd argument for sqlite3_js_posix_create_file().");try{if(!C.isInt32(N)||N<0)R.toss("Invalid 3rd argument for sqlite3_js_posix_create_file().");let ie=C.sqlite3__wasm_posix_create_file(f,J,N);if(ie)R.toss("Creation of file failed with sqlite3 result code",_.sqlite3_js_rc_str(ie))}finally{if(J&&J!==w)h.dealloc(J)}},_.sqlite3_js_vfs_create_file=function(f,w,N,J){a.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 ie;if(N)if(h.isPtr(N))ie=N;else{if(N instanceof ArrayBuffer)N=new Uint8Array(N);if(N instanceof Uint8Array){if(ie=h.allocFromTypedArray(N),arguments.length<4||!C.isInt32(J)||J<0)J=N.byteLength}else R.toss("Invalid 3rd argument type for sqlite3_js_vfs_create_file().")}else ie=0;if(!C.isInt32(J)||J<0){if(ie&&ie!==N)h.dealloc(ie);R.toss("Invalid 4th argument for sqlite3_js_vfs_create_file().")}try{let le=C.sqlite3__wasm_vfs_create_file(f,w,ie,J);if(le)R.toss("Creation of file failed with sqlite3 result code",_.sqlite3_js_rc_str(le))}finally{if(ie&&ie!==N)h.dealloc(ie)}},_.sqlite3_js_sql_to_string=(f)=>{if(typeof f==="string")return f;let w=T(v);return w===v?void 0:w},_.sqlite3_db_config=function(f,w,...N){switch(w){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:if(!this.ip)this.ip=h.xWrap("sqlite3__wasm_db_config_ip","int",["sqlite3*","int","int","*"]);return this.ip(f,w,N[0],N[1]||0);case _.SQLITE_DBCONFIG_LOOKASIDE:if(!this.pii)this.pii=h.xWrap("sqlite3__wasm_db_config_pii","int",["sqlite3*","int","*","int","int"]);return this.pii(f,w,N[0],N[1],N[2]);case _.SQLITE_DBCONFIG_MAINDBNAME:if(!this.s)this.s=h.xWrap("sqlite3__wasm_db_config_s","int",["sqlite3*","int","string:static"]);return this.s(f,w,N[0]);default:return _.SQLITE_MISUSE}}.bind(r()),_.sqlite3_value_to_js=function(f,w=!0){let N,J=_.sqlite3_value_type(f);switch(J){case _.SQLITE_INTEGER:if(h.bigIntEnabled){if(N=_.sqlite3_value_int64(f),C.bigIntFitsDouble(N))N=Number(N)}else N=_.sqlite3_value_double(f);break;case _.SQLITE_FLOAT:N=_.sqlite3_value_double(f);break;case _.SQLITE_TEXT:N=_.sqlite3_value_text(f);break;case _.SQLITE_BLOB:{let ie=_.sqlite3_value_bytes(f),le=_.sqlite3_value_blob(f);if(ie&&!le)z.WasmAllocError.toss("Cannot allocate memory for blob argument of",ie,"byte(s)");N=ie?h.heap8u().slice(Number(le),Number(le)+Number(ie)):null;break}case _.SQLITE_NULL:N=null;break;default:if(w)M(_.SQLITE_MISMATCH,"Unhandled sqlite3_value_type():",J);N=void 0}return N},_.sqlite3_values_to_js=function(f,w,N=!0){let J,ie=[];for(J=0;J<f;++J)ie.push(_.sqlite3_value_to_js(h.peekPtr(h.ptr.add(w,h.ptr.size*J)),N));return ie},_.sqlite3_result_error_js=function(f,w){if(w instanceof A)_.sqlite3_result_error_nomem(f);else _.sqlite3_result_error(f,""+w,-1)},_.sqlite3_result_js=function(f,w){if(w instanceof Error){_.sqlite3_result_error_js(f,w);return}try{switch(typeof w){case"undefined":break;case"boolean":_.sqlite3_result_int(f,w?1:0);break;case"bigint":if(C.bigIntFits32(w))_.sqlite3_result_int(f,Number(w));else if(C.bigIntFitsDouble(w))_.sqlite3_result_double(f,Number(w));else if(h.bigIntEnabled)if(C.bigIntFits64(w))_.sqlite3_result_int64(f,w);else M("BigInt value",w.toString(),"is too BigInt for int64.");else M("BigInt value",w.toString(),"is too BigInt.");break;case"number":{let N;if(C.isInt32(w))N=_.sqlite3_result_int;else if(h.bigIntEnabled&&Number.isInteger(w)&&C.bigIntFits64(BigInt(w)))N=_.sqlite3_result_int64;else N=_.sqlite3_result_double;N(f,w);break}case"string":{let[N,J]=h.allocCString(w,!0);_.sqlite3_result_text(f,N,J,_.SQLITE_WASM_DEALLOC);break}case"object":if(w===null){_.sqlite3_result_null(f);break}else if(C.isBindableTypedArray(w)){let N=h.allocFromTypedArray(w);_.sqlite3_result_blob(f,N,w.byteLength,_.SQLITE_WASM_DEALLOC);break}default:M("Don't not how to handle this UDF result value:",typeof w,w)}}catch(N){_.sqlite3_result_error_js(f,N)}},_.sqlite3_column_js=function(f,w,N=!0){let J=_.sqlite3_column_value(f,w);return J===0?void 0:_.sqlite3_value_to_js(J,N)};{let f=function(w,N,J){if(J=_[J],!this.ptr)this.ptr=h.allocPtr();else h.pokePtr(this.ptr,0);let ie=J(w,N,this.ptr);if(ie)return R.toss(ie,arguments[2]+"() failed with code "+ie);let le=h.peekPtr(this.ptr);return le?_.sqlite3_value_to_js(le,!0):void 0}.bind(r());_.sqlite3_preupdate_new_js=(w,N)=>f(w,N,"sqlite3_preupdate_new"),_.sqlite3_preupdate_old_js=(w,N)=>f(w,N,"sqlite3_preupdate_old"),_.sqlite3changeset_new_js=(w,N)=>f(w,N,"sqlite3changeset_new"),_.sqlite3changeset_old_js=(w,N)=>f(w,N,"sqlite3changeset_old")}_.sqlite3_js_retry_busy=function(f,w,N){for(let J=1;J<=f;++J)try{if(N&&J>1)N(J);let ie=w();if(_.SQLITE_BUSY===ie){if(J===f)throw new R(ie,["sqlite3_js_retry_busy() max retry attempts (",f,") reached."].join(""));continue}return ie}catch(ie){if(J<f&&ie instanceof R&&ie.resultCode===_.SQLITE_BUSY)continue;throw ie}};let z={WasmAllocError:A,SQLite3Error:R,capi:_,util:C,wasm:h,config:a,version:r(),client:void 0,asyncPostInit:async function f(){if(f.isReady instanceof Promise)return f.isReady;let w=this.initializersAsync;delete this.initializersAsync;let N=async()=>{if(!z.__isUnderTest)delete z.util,delete z.StructBinder,delete z.opfs;return z},J=(le)=>{throw a.error("an async sqlite3 initializer failed:",le),le};if(!w||!w.length)return f.isReady=N().catch(J);w=w.map((le)=>le instanceof Function?async(we)=>le(z):le),w.push(N);let ie=Promise.resolve(z);while(w.length)ie=ie.then(w.shift());return f.isReady=ie.catch(J)}.bind(i),scriptInfo:void 0};if(typeof o<"u")z.__isUnderTest=!!o;try{i.initializers.forEach((f)=>{f(z)})}catch(f){throw console.error("sqlite3 bootstrap initializer threw:",f),f}if(delete i.initializers,i.sqlite3=z,typeof e<"u")e.debugModule("sqlite3ApiBootstrap() complete",z),z.scriptInfo=e;if(z.__isUnderTest){if(typeof n<"u")z.config.emscripten=n;let f=z.scriptInfo?.instantiateWasm;if(f)z.wasm.module=f.module,z.wasm.instance=f.instance,z.wasm.imports=f.imports}return delete globalThis.sqlite3ApiConfig,delete globalThis.sqlite3ApiBootstrap,delete i.defaultConfig,z.asyncPostInit().then((f)=>{if(typeof e<"u")e.debugModule("sqlite3.asyncPostInit() complete",f);return delete f.asyncPostInit,delete f.scriptInfo,delete f.emscripten,f})},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.54.0",libVersionNumber:3054000,sourceId:"2026-10-09 15:46:58 be8d059e9a49089ab2dce5ed26dd87aaf598fdc5fbe0b107c0dd758464bcd5e3",downloadVersion:3540000,scm:{"sha3-256":"be8d059e9a49089ab2dce5ed26dd87aaf598fdc5fbe0b107c0dd758464bcd5e3",branch:"trunk",tags:"release major-release version-3.54.0",datetime:"2026-10-09T15:46:58.543Z"}}}),globalThis.WhWasmUtilInstaller=function(t){if(t.bigIntEnabled===void 0)t.bigIntEnabled=!!globalThis.BigInt64Array;let r=(...u)=>{throw Error(u.join(" "))};if(!t.pointerSize&&!t.pointerIR&&t.alloc&&t.dealloc){let u=t.alloc(1);t.pointerSize=typeof u==="bigint"?8:4,t.dealloc(u)}if(t.pointerSize&&!t.pointerIR)t.pointerIR=t.pointerSize===4?"i32":"i64";let a=t.pointerIR??="i32",_=t.pointerSize??=a==="i32"?4:a==="i64"?8:0;if(delete t.pointerSize,delete t.pointerIR,a!=="i32"&&a!=="i64")r("Invalid pointerIR:",a);else if(_!==8&&_!==4)r("Invalid pointerSize:",_);let h=t.bigIntEnabled?(u)=>BigInt(u||0):(u)=>r("BigInt support is disabled in this build."),S=_===4?(u)=>Number(u||0):h,R=S(0),M=function(...u){let q=S(0);for(let O of u)q+=S(O);return q};{let u=Object.create(null);Object.defineProperty(t,"ptr",{enumerable:!0,get:()=>u,set:()=>r("The ptr property is read-only.")}),function q(O,V){return Object.defineProperty(u,O,{enumerable:!0,get:()=>V,set:()=>r("ptr["+O+"] is read-only.")}),q}("null",R)("size",_)("ir",a)("coerce",S)("add",M)("addn",a===4?M:(...q)=>Number(M(...q)))}if(!t.exports)Object.defineProperty(t,"exports",{enumerable:!0,configurable:!0,get:()=>t.instance?.exports});let p=Object.create(null);p.heapSize=0,p.memory=null,p.freeFuncIndexes=[],p.scopedAlloc=[],p.scopedAlloc.pushPtr=(u)=>(p.scopedAlloc[p.scopedAlloc.length-1].push(u),u),p.utf8Decoder=new TextDecoder,p.utf8Encoder=new TextEncoder("utf-8"),t.sizeofIR=(u)=>{switch(u){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(""+u).endsWith("*")?_:void 0}};let ne=function(){if(!p.memory)p.memory=t.memory instanceof WebAssembly.Memory?t.memory:t.exports.memory;else if(p.heapSize===p.memory.buffer.byteLength)return p;let u=p.memory.buffer;if(p.HEAP8=new Int8Array(u),p.HEAP8U=new Uint8Array(u),p.HEAP16=new Int16Array(u),p.HEAP16U=new Uint16Array(u),p.HEAP32=new Int32Array(u),p.HEAP32U=new Uint32Array(u),p.HEAP32F=new Float32Array(u),p.HEAP64F=new Float64Array(u),t.bigIntEnabled)if(typeof BigInt64Array<"u")p.HEAP64=new BigInt64Array(u),p.HEAP64U=new BigUint64Array(u);else r("BigInt support is enabled, but the BigInt64Array type is missing.");return p.heapSize=u.byteLength,p};t.heap8=()=>ne().HEAP8,t.heap8u=()=>ne().HEAP8U,t.heap16=()=>ne().HEAP16,t.heap16u=()=>ne().HEAP16U,t.heap32=()=>ne().HEAP32,t.heap32u=()=>ne().HEAP32U,t.heapForSize=function(u,q=!0){let O,V=p.memory&&p.heapSize===p.memory.buffer.byteLength?p:ne();switch(u){case Int8Array:return V.HEAP8;case Uint8Array:return V.HEAP8U;case Int16Array:return V.HEAP16;case Uint16Array:return V.HEAP16U;case Int32Array:return V.HEAP32;case Uint32Array:return V.HEAP32U;case 8:return q?V.HEAP8U:V.HEAP8;case 16:return q?V.HEAP16U:V.HEAP16;case 32:return q?V.HEAP32U:V.HEAP32;case 64:if(V.HEAP64)return q?V.HEAP64U:V.HEAP64;break;default:if(t.bigIntEnabled){if(u===globalThis.BigUint64Array)return V.HEAP64U;else if(u===globalThis.BigInt64Array)return V.HEAP64;break}}r("Invalid heapForSize() size: expecting 8, 16, 32,","or (if BigInt is enabled) 64.")};let W=t.functionTable;delete t.functionTable,t.functionTable=W?()=>W:()=>t.exports.__indirect_function_table,t.functionEntry=function(u){let q=t.functionTable();return u<q.length?q.get(S(u)):void 0},t.jsFuncToWasm=function u(q,O){if(!u._)u._={sigTypes:Object.assign(Object.create(null),{i:"i32",p:a,P:a,s:a,j:"i64",f:"f32",d:"f64"}),typeCodes:Object.assign(Object.create(null),{f64:124,f32:125,i64:126,i32:127}),uleb128Encode:(y,D,c)=>{if(c<128)y[D](c);else y[D](c%128|128,c>>7)},rxJSig:/^(\w)\((\w*)\)$/,sigParams:(y)=>{let D=u._.rxJSig.exec(y);return D?D[2]:y.substr(1)},letterType:(y)=>u._.sigTypes[y]||r("Invalid signature letter:",y),pushSigType:(y,D)=>y.push(u._.typeCodes[u._.letterType(D)])};if(typeof q==="string"){let y=O;O=q,q=y}let V=u._,Z=V.sigParams(O),m=[1,96];V.uleb128Encode(m,"push",Z.length);for(let y of Z)V.pushSigType(m,y);if(O[0]==="v")m.push(0);else m.push(1),V.pushSigType(m,O[0]);return V.uleb128Encode(m,"unshift",m.length),m.unshift(0,97,115,109,1,0,0,0,1),m.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(m)),{e:{f:q}}).exports.f};let U=function(q,O,V){if(V&&!p.scopedAlloc.length)r("No scopedAllocPush() scope is active.");if(typeof q==="string"){let D=O;O=q,q=D}if(typeof O!=="string"||!(q instanceof Function))r("Invalid arguments: expecting (function,signature) or (signature,function).");let Z=t.functionTable(),m=S(Z.length),y;while(y=p.freeFuncIndexes.pop())if(Z.get(y)){y=null;continue}else break;if(!y)y=S(m),Z.grow(S(1));try{if(Z.set(y,q),V)p.scopedAlloc.pushPtr(y);return y}catch(D){if(!(D instanceof TypeError)){if(y===m)p.freeFuncIndexes.push(m);throw D}}try{let D=t.jsFuncToWasm(q,O);if(Z.set(y,D),V)p.scopedAlloc.pushPtr(y)}catch(D){if(y===m)p.freeFuncIndexes.push(m);throw D}return y};t.installFunction=(u,q)=>U(u,q,!1),t.scopedInstallFunction=(u,q)=>U(u,q,!0),t.uninstallFunction=function(u){if(!u&&R!==u)return;let q=t.functionTable();p.freeFuncIndexes.push(u);let O=q.get(u);return q.set(u,null),O},t.peek=function(q,O="i8"){if(O.endsWith("*"))O=a;let V=p.memory&&p.heapSize===p.memory.buffer.byteLength?p:ne(),Z=Array.isArray(q)?[]:void 0,m;do{if(Z)q=arguments[0].shift();switch(O){case"i1":case"i8":m=V.HEAP8[Number(q)>>0];break;case"i16":m=V.HEAP16[Number(q)>>1];break;case"i32":m=V.HEAP32[Number(q)>>2];break;case"float":case"f32":m=V.HEAP32F[Number(q)>>2];break;case"double":case"f64":m=Number(V.HEAP64F[Number(q)>>3]);break;case"i64":if(V.HEAP64){m=h(V.HEAP64[Number(q)>>3]);break}default:r("Invalid type for peek():",O)}if(Z)Z.push(m)}while(Z&&arguments[0].length);return Z||m},t.poke=function(u,q,O="i8"){if(O.endsWith("*"))O=a;let V=p.memory&&p.heapSize===p.memory.buffer.byteLength?p:ne();for(let Z of Array.isArray(u)?u:[u])switch(O){case"i1":case"i8":V.HEAP8[Number(Z)>>0]=q;continue;case"i16":V.HEAP16[Number(Z)>>1]=q;continue;case"i32":V.HEAP32[Number(Z)>>2]=q;continue;case"float":case"f32":V.HEAP32F[Number(Z)>>2]=q;continue;case"double":case"f64":V.HEAP64F[Number(Z)>>3]=q;continue;case"i64":if(V.HEAP64){V.HEAP64[Number(Z)>>3]=h(q);continue}default:r("Invalid type for poke(): "+O)}return this},t.peekPtr=(...u)=>t.peek(u.length===1?u[0]:u,a),t.pokePtr=(u,q=0)=>t.poke(u,q,a),t.peek8=(...u)=>t.peek(u.length===1?u[0]:u,"i8"),t.poke8=(u,q)=>t.poke(u,q,"i8"),t.peek16=(...u)=>t.peek(u.length===1?u[0]:u,"i16"),t.poke16=(u,q)=>t.poke(u,q,"i16"),t.peek32=(...u)=>t.peek(u.length===1?u[0]:u,"i32"),t.poke32=(u,q)=>t.poke(u,q,"i32"),t.peek64=(...u)=>t.peek(u.length===1?u[0]:u,"i64"),t.poke64=(u,q)=>t.poke(u,q,"i64"),t.peek32f=(...u)=>t.peek(u.length===1?u[0]:u,"f32"),t.poke32f=(u,q)=>t.poke(u,q,"f32"),t.peek64f=(...u)=>t.peek(u.length===1?u[0]:u,"f64"),t.poke64f=(u,q)=>t.poke(u,q,"f64"),t.getMemValue=t.peek,t.getPtrValue=t.peekPtr,t.setMemValue=t.poke,t.setPtrValue=t.pokePtr,t.isPtr32=(u)=>typeof u==="number"&&u>=0&&u===(u|0),t.isPtr64=(u)=>typeof u==="bigint"?u>=0:t.isPtr32(u),t.isPtr=_===4?t.isPtr32:t.isPtr64,t.cstrlen=function(u){if(!u||!t.isPtr(u))return null;u=Number(u);let q=ne().HEAP8U,O=u;for(;q[O]!==0;++O);return O-u};let E=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,b=(u)=>u.buffer instanceof E;t.isSharedTypedArray=b;let F=(u,q,O)=>{if(_===8){if(typeof q==="bigint")q=Number(q);if(typeof O==="bigint")O=Number(O)}return b(u)?u.slice(q,O):u.subarray(q,O)};t.typedArrayPart=F;let T=(u,q,O)=>p.utf8Decoder.decode(F(u,q,O));t.typedArrayToString=T,t.cstrToJs=function(u){let q=t.cstrlen(u);return q?T(ne().HEAP8U,Number(u),Number(u)+q):q===null?q:""},t.jstrlen=function(u){if(typeof u!=="string")return null;let q=u.length,O=0;for(let V=0;V<q;++V){let Z=u.charCodeAt(V);if(Z>=55296&&Z<=57343)Z=65536+((Z&1023)<<10)|u.charCodeAt(++V)&1023;if(Z<=127)++O;else if(Z<=2047)O+=2;else if(Z<=65535)O+=3;else O+=4}return O},t.jstrcpy=function(u,q,O=0,V=-1,Z=!0){if(!q||!(q instanceof Int8Array)&&!(q instanceof Uint8Array))r("jstrcpy() target must be an Int8Array or Uint8Array.");if(V=Number(V),O=Number(O),V<0)V=q.length-O;if(!(V>0)||!(O>=0))return 0;let m=0,y=u.length,D=O,c=O+V-(Z?1:0);for(;m<y&&O<c;++m){let d=u.charCodeAt(m);if(d>=55296&&d<=57343)d=65536+((d&1023)<<10)|u.charCodeAt(++m)&1023;if(d<=127){if(O>=c)break;q[O++]=d}else if(d<=2047){if(O+1>=c)break;q[O++]=192|d>>6,q[O++]=128|d&63}else if(d<=65535){if(O+2>=c)break;q[O++]=224|d>>12,q[O++]=128|d>>6&63,q[O++]=128|d&63}else{if(O+3>=c)break;q[O++]=240|d>>18,q[O++]=128|d>>12&63,q[O++]=128|d>>6&63,q[O++]=128|d&63}}if(Z)q[O++]=0;return O-D},t.cstrncpy=function(u,q,O){if(!u||!q)r("cstrncpy() does not accept NULL strings.");if(O<0)O=t.cstrlen(strPtr)+1;else if(!(O>0))return 0;let V=t.heap8u(),Z=0,m,y=Number(u),D=Number(q);for(;Z<O&&(m=V[D+Z]);++Z)V[y+Z]=m;if(Z<O)V[y+Z++]=0;return Z},t.jstrToUintArray=(u,q=!1)=>p.utf8Encoder.encode(q?u+"\x00":u);let A=(u,q)=>{if(!(u.alloc instanceof Function)||!(u.dealloc instanceof Function))r("Object is missing alloc() and/or dealloc() function(s)","required by",q+"().")},C=function(u,q,O,V){if(A(t,V),typeof u!=="string")return null;let Z=p.utf8Encoder.encode(u),m=O(Z.length+1),y=m;try{let D=ne().HEAP8U;return D.set(Z,Number(m)),D[M(m,Z.length)]=0,y=R,q?[m,Z.length]:m}finally{if(y)t.dealloc(y)}};t.allocCString=(u,q=!1)=>C(u,q,t.alloc,"allocCString()"),t.scopedAllocPush=function(){A(t,"scopedAllocPush");let u=[];return p.scopedAlloc.push(u),u},t.scopedAllocPop=function(u){A(t,"scopedAllocPop");let q=arguments.length?p.scopedAlloc.indexOf(u):p.scopedAlloc.length-1;if(q<0)r("Invalid state object for scopedAllocPop().");if(arguments.length===0)u=p.scopedAlloc[q];p.scopedAlloc.splice(q,1);for(let O;O=u.pop();)if(t.functionEntry(O))t.uninstallFunction(O);else t.dealloc(O)},t.scopedAlloc=function(u){if(!p.scopedAlloc.length)r("No scopedAllocPush() scope is active.");let q=S(t.alloc(u));return p.scopedAlloc.pushPtr(q)},Object.defineProperty(t.scopedAlloc,"level",{configurable:!1,enumerable:!1,get:()=>p.scopedAlloc.length,set:()=>r("The 'active' property is read-only.")}),t.scopedAllocCString=(u,q=!1)=>C(u,q,t.scopedAlloc,"scopedAllocCString()");let z=function(u,q){let O=t[u?"scopedAlloc":"alloc"]((q.length+1)*t.ptr.size),V=0;return q.forEach((Z)=>{t.pokePtr(M(O,t.ptr.size*V++),t[u?"scopedAllocCString":"allocCString"](""+Z))}),t.pokePtr(M(O,t.ptr.size*V),0),O};t.scopedAllocMainArgv=(u)=>z(!0,u),t.allocMainArgv=(u)=>z(!1,u),t.cArgvToJs=(u,q)=>{let O=[];for(let V=0;V<u;++V){let Z=t.peekPtr(M(q,t.ptr.size*V));O.push(Z?t.cstrToJs(Z):null)}return O},t.scopedAllocCall=function(u){t.scopedAllocPush();try{return u()}finally{t.scopedAllocPop()}};let f=function(u,q,O){A(t,O);let V=q?"i64":a,Z=t[O](u*(q?8:_));if(t.poke(Z,0,V),u===1)return Z;let m=[Z];for(let y=1;y<u;++y)Z=M(Z,q?8:_),m[y]=Z,t.poke(Z,0,V);return m};t.allocPtr=(u=1,q=!0)=>f(u,q,"alloc"),t.scopedAllocPtr=(u=1,q=!0)=>f(u,q,"scopedAlloc"),t.xGet=function(u){return t.exports[u]||r("Cannot find exported symbol:",u)};let w=(u,q)=>r(u+"() requires",q,"argument(s).");t.xCall=function(u,...q){let O=u instanceof Function?u:t.xGet(u);if(!(O instanceof Function))r("Exported symbol",u,"is not a function.");if(O.length!==q.length)w(O===u?O.name:u,O.length);return arguments.length===2&&Array.isArray(arguments[1])?O.apply(null,arguments[1]):O.apply(null,q)},p.xWrap=Object.create(null),p.xWrap.convert=Object.create(null),p.xWrap.convert.arg=new Map,p.xWrap.convert.result=new Map;let N=p.xWrap.convert.arg,J=p.xWrap.convert.result,ie=S;N.set("i64",h).set("i32",(u)=>u|0).set("i16",(u)=>(u|0)&65535).set("i8",(u)=>(u|0)&255).set("f32",(u)=>Number(u).valueOf()).set("float",N.get("f32")).set("f64",N.get("f32")).set("double",N.get("f64")).set("int",N.get("i32")).set("null",(u)=>u).set(null,N.get("null")).set("**",ie).set("*",ie),J.set("*",ie).set("pointer",ie).set("number",(u)=>Number(u)).set("void",(u)=>{return}).set(void 0,J.get("void")).set("null",(u)=>u).set(null,J.get("null"));for(let u of["i8","i16","i32","i64","int","f32","float","f64","double"])N.set(u+"*",ie),J.set(u+"*",ie),J.set(u,N.get(u)||r("Maintenance required: missing arg converter for",u));let le=(u)=>typeof u==="string"?t.scopedAllocCString(u):S(u);N.set("string",le).set("utf8",le),J.set("string",(u)=>t.cstrToJs(u)).set("utf8",J.get("string")).set("string:dealloc",(u)=>{try{return u?t.cstrToJs(u):null}finally{t.dealloc(u)}}).set("utf8:dealloc",J.get("string:dealloc")).set("json",(u)=>JSON.parse(t.cstrToJs(u))).set("json:dealloc",(u)=>{try{return u?JSON.parse(t.cstrToJs(u)):null}finally{t.dealloc(u)}});let we=class{constructor(u){this.name=u.name||"unnamed adapter"}convertArg(u,q,O){r("AbstractArgAdapter must be subclassed.")}};N.FuncPtrAdapter=class u extends we{constructor(q){super(q);if(N.FuncPtrAdapter.warnOnUse)console.warn("xArg.FuncPtrAdapter is an internal-only API","and is not intended to be invoked from","client-level code. Invoked with:",q);if(this.name=q.name||"unnamed",this.signature=q.signature,q.contextKey instanceof Function){if(this.contextKey=q.contextKey,!q.bindScope)q.bindScope="context"}if(this.bindScope=q.bindScope||r("FuncPtrAdapter options requires a bindScope (explicit or implied)."),u.bindScopes.indexOf(q.bindScope)<0)r("Invalid options.bindScope ("+q.bindMod+") for FuncPtrAdapter. Expecting one of: ("+u.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=q.callProxy instanceof Function?q.callProxy:void 0}contextKey(q,O){return this}contextMap(q){let O=this.__cmap||(this.__cmap=new Map),V=O.get(q);if(V===void 0)O.set(q,V=[]);return V}convertArg(q,O,V){let Z=this.singleton;if(!Z&&this.isContext)Z=this.contextMap(this.contextKey(O,V));if(Z&&Z.length===2&&Z[0]===q)return Z[1];if(q instanceof Function){if(this.callProxy)q=this.callProxy(q);let m=U(q,this.signature,this.isTransient);if(u.debugFuncInstall)u.debugOut("FuncPtrAdapter installed",this,this.contextKey(O,V),"@"+m,q);if(Z){if(Z[1]){if(u.debugFuncInstall)u.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(O,V),"@"+Z[1],q);try{p.scopedAlloc.pushPtr(Z[1])}catch(y){}}Z[0]=arguments[0]||R,Z[1]=m}return m}else if(t.isPtr(q)||q===null||q===void 0){if(Z&&Z[1]&&Z[1]!==q){if(u.debugFuncInstall)u.debugOut("FuncPtrAdapter uninstalling",this,this.contextKey(O,V),"@"+Z[1],q);try{p.scopedAlloc.pushPtr(Z[1])}catch(m){}Z[0]=Z[1]=q||R}return q||R}else throw TypeError("Invalid FuncPtrAdapter argument type. Expecting a function pointer or a "+(this.name?this.name+" ":"")+"function matching signature "+this.signature+".")}},N.FuncPtrAdapter.warnOnUse=!1,N.FuncPtrAdapter.debugFuncInstall=!1,N.FuncPtrAdapter.debugOut=console.debug.bind(console),N.FuncPtrAdapter.bindScopes=["transient","context","singleton","permanent"];let ge=(u)=>N.get(u)||r("Argument adapter not found:",u),K=(u)=>J.get(u)||r("Result adapter not found:",u);p.xWrap.convertArg=(u,...q)=>ge(u)(...q),p.xWrap.convertArgNoCheck=(u,...q)=>N.get(u)(...q),p.xWrap.convertResult=(u,q)=>u===null?q:u?K(u)(q):void 0,p.xWrap.convertResultNoCheck=(u,q)=>u===null?q:u?J.get(u)(q):void 0,t.xWrap=function u(q,O,...V){if(arguments.length===3&&Array.isArray(arguments[2]))V=arguments[2];if(t.isPtr(q))q=t.functionEntry(q)||r("Function pointer not found in WASM function table.");let Z=q instanceof Function,m=Z?q:t.xGet(q);if(Z)q=m.name||"unnamed function";if(V.length!==m.length)w(q,m.length);if(m.length===0&&(O===null||O==="null"))return m;K(O);for(let D of V)if(D instanceof we)N.set(D,(...c)=>D.convertArg(...c));else ge(D);let y=p.xWrap;if(m.length===0)return(...D)=>D.length?w(q,m.length):y.convertResult(O,m.call(null));return function(...D){if(D.length!==m.length)w(q,m.length);let c=t.scopedAllocPush();try{let d=0;if(u.debug)console.debug("xWrap() preparing: resultType ",O,"xf",m,"argTypes",V,"args",D);for(;d<D.length;++d)D[d]=y.convertArgNoCheck(V[d],D[d],D,d);if(u.debug)console.debug("xWrap() calling: resultType ",O,"xf",m,"argTypes",V,"args",D);return y.convertResultNoCheck(O,m.apply(null,D))}finally{t.scopedAllocPop(c)}}};let oe=function(u,q,O,V,Z,m){if(typeof O==="string"){if(q===1)return m.get(O);else if(q===2){if(!V)return m.delete(O),u;else if(!(V instanceof Function))r(Z,"requires a function argument.");return m.set(O,V),u}}r("Invalid arguments to",Z)};return t.xWrap.resultAdapter=function u(q,O){return oe(u,arguments.length,q,O,"resultAdapter()",J)},t.xWrap.argAdapter=function u(q,O){return oe(u,arguments.length,q,O,"argAdapter()",N)},t.xWrap.FuncPtrAdapter=N.FuncPtrAdapter,t.xCallWrapped=function(u,q,O,...V){if(Array.isArray(arguments[3]))V=arguments[3];return t.xWrap(u,q,O||[]).apply(null,V||[])},t.xWrap.testConvertArg=p.xWrap.convertArg,t.xWrap.testConvertResult=p.xWrap.convertResult,t},globalThis.WhWasmUtilInstaller.yawl=function(t){let r=()=>fetch(t.uri,{credentials:"same-origin"}),a=this,_=function(I){if(t.wasmUtilTarget){let S=(...M)=>{throw Error(M.join(" "))},R=t.wasmUtilTarget;if(R.module=I.module,R.instance=I.instance,!R.instance.exports.memory)R.memory=t?.imports?.env?.memory||S("Missing 'memory' object!");if(!R.alloc&&I.instance.exports.malloc){let M=I.instance.exports;R.alloc=function(p){return M.malloc(p)||S("Allocation of",p,"bytes failed.")},R.dealloc=function(p){p&&M.free(p)}}a(R)}if(I.config=t,t.onload)t.onload(I);return I};return WebAssembly.instantiateStreaming?()=>WebAssembly.instantiateStreaming(r(),t.imports||{}).then(_):()=>r().then((I)=>I.arrayBuffer()).then((I)=>WebAssembly.instantiate(I,t.imports||{})).then(_)}.bind(globalThis.WhWasmUtilInstaller),globalThis.Jaccwabyt=function i(t){let r=(...P)=>{throw Error(P.join(" "))};{let P=t.heap;if(P instanceof WebAssembly.Memory)P=function(){return new Uint8Array(this.buffer)}.bind(P);else if(!(P instanceof Function))r("config.heap must be WebAssembly.Memory instance or","a function which returns one.");t.heap=P}["alloc","dealloc"].forEach(function(P){t[P]instanceof Function||r("Config option '"+P+"' must be a function.")});let a=i,{heap:_,alloc:h,dealloc:I}=t,S=t.realloc||function(){r("This StructBinderFactory was configured without realloc()")},R=t.log||console.debug.bind(console),M=t.memberPrefix||"",p=t.memberSuffix||"",{BigInt:ne,BigInt64Array:W}=globalThis,U=t.bigIntEnabled??!!W,E,b=t.pointerSize||t.ptrSize||(typeof(E=h(1))==="bigint"?8:4),F=t.pointerIR||t.ptrIR||(b===4?"i32":"i64");if(E)I(E),E=void 0;if(b!==4&&b!==8)r("Invalid pointer size:",b);if(F!=="i32"&&F!=="i64")r("Invalid pointer representation:",F);let T=U&&ne?(P)=>ne(P||0):(P)=>r("BigInt support is disabled in this build."),A=F=="i32"?Number:T,C=A(0),z=function(...P){let X=C;for(let ee=0;ee<P.length;++ee)X+=A(P[ee]);return X},f=function(...P){return z(this.pointer,...P)};if(!a.debugFlags)a.__makeDebugFlags=function(P=null){if(P&&P.__flags)P=P.__flags;let X=function ee(re){if(arguments.length===0)return ee.__flags;if(re<0)delete ee.__flags.getter,delete ee.__flags.setter,delete ee.__flags.alloc,delete ee.__flags.dealloc;else ee.__flags.getter=(1&re)!==0,ee.__flags.setter=(2&re)!==0,ee.__flags.alloc=(4&re)!==0,ee.__flags.dealloc=(8&re)!==0;return ee._flags};if(Object.defineProperty(X,"__flags",{iterable:!1,writable:!1,value:Object.create(P)}),!P)X(0);return X},a.debugFlags=a.__makeDebugFlags();let w=!0,N=(P)=>P[1]==="(",J=(P)=>P==="p"||P==="P"||P==="s",ie=(P)=>P==="P",le=(P)=>P?N(P)?"p":P[0]:void 0,we=function(P){switch(le(P)){case"c":case"C":return"i8";case"i":return"i32";case"p":case"P":case"s":return F;case"j":return"i64";case"f":return"float";case"d":return"double"}r("Unhandled signature IR:",P)},ge=function(P){switch(le(P)){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:",P)},K=W?()=>!0:()=>r("BigInt64Array is not available."),oe=function(P){switch(le(P)){case"p":case"P":case"s":{switch(b){case 4:return"getInt32";case 8:return K()&&"getBigInt64"}break}case"i":return"getInt32";case"c":return"getInt8";case"C":return"getUint8";case"j":return K()&&"getBigInt64";case"f":return"getFloat32";case"d":return"getFloat64"}r("Unhandled DataView getter for signature:",P)},u=function(P){switch(le(P)){case"p":case"P":case"s":{switch(b){case 4:return"setInt32";case 8:return K()&&"setBigInt64"}break}case"i":return"setInt32";case"c":return"setInt8";case"C":return"setUint8";case"j":return K()&&"setBigInt64";case"f":return"setFloat32";case"d":return"setFloat64"}r("Unhandled DataView setter for signature:",P)},q=function(P){switch(le(P)){case"i":case"f":case"c":case"C":case"d":return Number;case"j":return T;case"p":case"P":case"s":switch(b){case 4:return Number;case 8:return T}break}r("Unhandled DataView set wrapper for signature:",P)},O=(P,X)=>P+"::"+X,V=function(P,X){return()=>r(O(P,X),"is read-only.")},Z=function P(X,ee=!0){let re=P.map.get(X);if(!re&&ee)P.map.set(X,re=P.create(X));return re};Z.map=new WeakMap,Z.create=(P)=>Object.assign(Object.create(null),{o:P,p:void 0,ownsPointer:!1,zod:!1,xb:0});let m=(P)=>Z.map.delete(P),y=(P)=>typeof P==="number"&&P===(P|0)&&P>=0,c=b===4?y:(P)=>typeof P==="bigint"&&P>=0||y(P),d=(P)=>c(P)&&P>0,L=function(P,X,ee){let re=Z(X,!1);if(!re||re.isDisposing)return;if(re.isDisposing=!0,!ee&&!(ee=re.p)){console.warn("Cannot(?) happen: __freeStruct() found no instanceInfo");return}if(Array.isArray(X.ondispose)){let fe;while(fe=X.ondispose.pop())try{if(fe instanceof Function)fe.call(X);else if(fe instanceof Je)fe.dispose();else if(c(fe))I(fe)}catch(Oe){console.warn("ondispose() for",P.structName,"@",ee,"threw. NOT propagating it.",Oe)}}else if(X.ondispose instanceof Function)try{X.ondispose()}catch(fe){console.warn("ondispose() for",P.structName,"@",ee,"threw. NOT propagating it.",fe)}if(m(X),delete X.ondispose,P.debugFlags.__flags.dealloc)R("debug.dealloc:",re.ownsPointer?"":"EXTERNAL",P.structName,"instance:",P.structInfo.sizeof,"bytes @"+ee);if(re.ownsPointer){if(re.zod||P.structInfo.zeroOnDispose)_().fill(0,Number(ee),Number(ee)+P.structInfo.sizeof+re.xb);I(ee)}},G=()=>({configurable:!1,writable:!1,iterable:!1}),B=(P)=>({...G(),value:P}),ae=function(X,ee,re){let fe,Oe=(Te)=>{d(Te)||r("Invalid pointer value",arguments[0],"for",X.structName,"constructor.")};if(arguments.length>=3)if(re&&typeof re==="object")fe=re,re=fe?.wrap;else Oe(re),fe={wrap:re};else fe={};let We=!re,Ve=0,Ge=!1;if(re)Oe(re),Ge=!!fe?.takeOwnership;else{let Te=fe?.extraBytes??0;if(Te<0||Te!==(Te|0))r("Invalid extraBytes value:",fe?.extraBytes);Ve=X.structInfo.sizeof+Te,re=h(Ve)||r("Allocation of",X.structName,"structure failed."),Ge=!0}try{if(fe?.debugFlags)ee.debugFlags(fe.debugFlags);if(X.debugFlags.__flags.alloc)R("debug.alloc:",We?"":"EXTERNAL",X.structName,"instance:",X.structInfo.sizeof,"bytes @"+re);if(We)_().fill(0,Number(re),Number(re)+Ve);let Te=Z(ee);if(Te.p=re,Te.ownsPointer=Ge,Te.xb=Ve?Ve-X.structInfo.sizeof:0,Te.zod=!!fe?.zeroOnDispose,fe?.ondispose&&fe.ondispose!==re)ee.addOnDispose(fe.ondispose)}catch(Te){throw L(X,ee,re),Te}},ce=function P(X){return P.rxSig1??=/^[ipPsjfdcC]$/,P.rxSig2??=/^[vipPsjfdcC]\([ipPsjfdcC]*\)$/,P.rxSig1.test(X)||P.rxSig2.test(X)},be=function(P){let X=this.get(P);if(!X)X=[Object.create(null),Object.create(null),Object.create(null)],this.set(P,X);return X}.bind(new WeakMap),ve=function(P,X,ee,re){let fe=be(P)[X];if(arguments.length===3)return fe[ee];if(re)return fe[ee]=re;return delete fe[ee]},Fe=(P)=>P,Pe=function(P,...X){return ve(this,0,P,...X)},Ee=function(P,X){ce(X)&&r(P,"(",X,") collides with a data type signature.")},Qe=function(P,...X){return Ee("Setter adaptor",P),ve(this,1,P,...X)},He=function(P,...X){return Ee("Struct adaptor",P),ve(this,2,P,...X)},x=function(P,X){let ee=typeof X==="string"?ve(P,2,X):X;if(typeof ee!=="object")r("Invalid struct mapping object. Arg =",X,JSON.stringify(ee));return ee},Q=B((P)=>M+P+p),H=function(P,X,ee=!0){let re=P.members[X];if(!re&&(M||p)){for(let fe of Object.values(P.members))if(fe.key===X){re=fe;break}if(!re&&ee)r(O(P.name||P.structName,X),"is not a mapped struct member.")}return re},se=function P(X,ee,re=!1){if(!P._)P._=(Oe)=>Oe.replace(/[^vipPsjrdcC]/g,"").replace(/[pPscC]/g,"i");let fe=H(X.structInfo,ee,!0);return re?P._(fe.signature):fe.signature},_e=B(function(){let P=[];for(let X of Object.keys(this.structInfo.members))P.push(this.memberKey(X));return P}),de=new TextDecoder("utf-8"),ue=new TextEncoder,he=typeof SharedArrayBuffer>"u"?function(){}:SharedArrayBuffer,Le=function(P,X,ee){if(b===8)X=Number(X),ee=Number(ee);return de.decode(P.buffer instanceof he?P.slice(X,ee):P.subarray(X,ee))},De=function(P,X,ee=!1){let re=H(P.structInfo,X,ee);return re&&re.signature.length===1&&re.signature[0]==="s"?re:!1},Ae=function(P){if(P.signature==="s")return;r("Invalid member type signature for C-string value:",JSON.stringify(P))},Ce=function(X,ee){let re=H(X.structInfo,ee,!0);Ae(re);let fe=X[re.key];if(!fe)return null;let Oe=fe,We=_();for(;We[Oe]!==0;++Oe);return fe===Oe?"":Le(We,fe,Oe)},Me=function(P,...X){if(P.ondispose){if(!Array.isArray(P.ondispose))P.ondispose=[P.ondispose]}else P.ondispose=[];P.ondispose.push(...X)},et=function(P){let X=ue.encode(P),ee=h(X.length+1);if(!ee)r("Allocation error while duplicating string:",P);let re=_();return re.set(X,Number(ee)),re[z(ee,X.length)]=0,ee},st=function(P,X,ee){let re=H(P.structInfo,X,!0);Ae(re);let fe=et(ee);return P[re.key]=fe,Me(P,fe),P},Je=function(X,ee){if(arguments[2]!==B)r("Do not call the StructType constructor","from client-level code.");Object.defineProperties(this,{structName:B(X),structInfo:B(ee)})};Je.prototype=Object.create(null,{dispose:B(function(){L(this.constructor,this)}),lookupMember:B(function(P,X=!0){return H(this.structInfo,P,X)}),memberToJsString:B(function(P){return Ce(this,P)}),memberIsString:B(function(P,X=!0){return De(this,P,X)}),memberKey:Q,memberKeys:_e,memberSignature:B(function(P,X=!1){return se(this,P,X)}),memoryDump:B(function(){let P=this.pointer;return P?new Uint8Array(_().slice(Number(P),Number(P)+this.structInfo.sizeof)):null}),extraBytes:{configurable:!1,enumerable:!1,get:function(){return Z(this,!1)?.xb??0}},zeroOnDispose:{configurable:!1,enumerable:!1,get:function(){return Z(this,!1)?.zod??!!this.structInfo.zeroOnDispose}},pointer:{configurable:!1,enumerable:!1,get:function(){return Z(this,!1)?.p},set:()=>r("Cannot assign the 'pointer' property of a struct.")},setMemberCString:B(function(P,X){return st(this,P,X)})}),Object.assign(Je.prototype,{addOnDispose:function(...P){return Me(this,...P),this}}),Object.defineProperties(Je,{allocCString:B(et),isA:B((P)=>P instanceof Je),hasExternalPointer:B((P)=>{let X=Z(P,!1);return!!(X?.p&&!X?.ownsPointer)}),memberKey:Q});let bt=function(P){return P.get||(P.adaptGet?$e.adaptGet(P.adaptGet):void 0)},yt=function(P){return P.set||(P.adaptSet?$e.adaptSet(P.adaptSet):void 0)},_t=function P(X,ee,re){let fe=P.innerStructs??=new Map,Oe=X.memberKey(ee);if(re.signature!==void 0)r("'signature' cannot be used on an embedded struct (",X.structName,".",Oe,").");if(yt(re))r("'set' and 'adaptSet' are not permitted for nested struct members.");re.structName??=X.structName+"::"+ee,re.key=Oe,re.name=ee,re.constructor=this.call(this,re.structName,re);let We=bt(re),Ve=Object.assign(Object.create(null),{configurable:!1,enumerable:!1,set:V(X.structName,Oe),get:function(){let Ge=this.debugFlags.__flags,Te=this.pointer,je=Te+"."+Oe,me=fe.get(je);if(Ge.getter)R("debug.getter: k =",je);if(!me)me=new re.constructor(z(Te,re.offset)),fe.set(je,me),this.addOnDispose(()=>me.dispose()),me.addOnDispose(()=>fe.delete(je));if(We)me=We.apply(this,[me,Oe]);if(Ge.getter)R("debug.getter: result =",me);return me}});Object.defineProperty(X.prototype,Oe,Ve)},Wt=function P(X,ee,re){if(re=x(this,re),re.members)return _t.call(this,X,ee,re);if(!P.cache){P.cache={getters:{},setters:{},sw:{}};let je=["i","c","C","p","P","s","f","d","v()"];if(U)je.push("j");je.forEach(function(me){P.cache.getters[me]=oe(me),P.cache.setters[me]=u(me),P.cache.sw[me]=q(me)}),P.sigCheck=function(me,Re,Tt,En){if(Object.prototype.hasOwnProperty.call(me,Tt))r(me.structName,"already has a property named",Tt+".");ce(En)||r("Malformed signature for",O(me.structName,Re)+":",En)}}let fe=X.memberKey(ee);P.sigCheck(X.prototype,ee,fe,re.signature),re.key=fe,re.name=ee;let Oe=le(re.signature),We=O(X.structName,fe),Ve=X.debugFlags.__flags,Ge=bt(re),Te=Object.create(null);if(Te.configurable=!1,Te.enumerable=!1,Te.get=function(){if(Ve.getter)R("debug.getter:",P.cache.getters[Oe],"for",we(Oe),We,"@",this.pointer,"+",re.offset,"sz",re.sizeof);let je=new DataView(_().buffer,Number(this.pointer)+re.offset,re.sizeof)[P.cache.getters[Oe]](0,w);if(Ge)je=Ge.apply(this,[fe,je]);if(Ve.getter)R("debug.getter:",We,"result =",je);return je},re.readOnly)Te.set=V(X.prototype.structName,fe);else{let je=yt(re);Te.set=function(me){if(Ve.setter)R("debug.setter:",P.cache.setters[Oe],"for",we(Oe),We,"@",this.pointer,"+",re.offset,"sz",re.sizeof,me);if(!this.pointer)r("Cannot set native property on a disposed",this.structName,"instance.");if(je)me=je.apply(this,[fe,me]);if(me===null||me===void 0)me=C;else if(J(re.signature)&&!c(me))if(ie(re.signature)&&me instanceof Je){if(me=me.pointer||C,Ve.setter)R("debug.setter:",We,"resolved to",me)}else r("Invalid value for pointer-type",We+".");new DataView(_().buffer,Number(this.pointer)+re.offset,re.sizeof)[P.cache.setters[Oe]](0,P.cache.sw[Oe](me),w)}}Object.defineProperty(X.prototype,fe,Te)},wn=function P(X,ee,re=Object.create(null)){let fe=function me(Re){if(!(this instanceof me))r("The",X,"constructor may only be called via 'new'.");ae(me,this,...arguments)},Oe=this,We=(me)=>typeof me==="string"&&ce(me)?{signature:me}:x(Oe,me);if(arguments.length===1)ee=We(X),X=ee.structName||ee.name;else if(arguments.length===2)ee=We(ee),ee.name??=X;else ee=We(ee);if(X??=ee.structName,X??=re.structName,!X)r("One of 'name' or 'structName' are required.");if(ee.adapt)Object.keys(ee.adapt.struct||{}).forEach((me)=>{He.call(P,me,ee.adapt.struct[me])}),Object.keys(ee.adapt.set||{}).forEach((me)=>{Qe.call(P,me,ee.adapt.set[me])}),Object.keys(ee.adapt.get||{}).forEach((me)=>{Pe.call(P,me,ee.adapt.get[me])});if(!ee.members&&!ee.sizeof)ee.sizeof=ge(ee.signature);let Ve=B(a.__makeDebugFlags($e.debugFlags));Object.defineProperties(fe,{debugFlags:Ve,isA:B((me)=>me instanceof fe),memberKey:Q,memberKeys:_e,structInfo:B(ee),structName:B(X),ptrAdd:B(z)}),fe.prototype=new Je(X,ee,B),Object.defineProperties(fe.prototype,{debugFlags:Ve,constructor:B(fe),ptrAdd:B(f)});let Ge=!1,Te=0,je=!!ee.autoCalcSizeOffset;if(!je){if(!ee.sizeof)r(X,"description is missing its sizeof property.");ee.offset??=0}else ee.offset??=0;if(Object.keys(ee.members||{}).forEach((me)=>{let Re=We(ee.members[me]);if(!Re.members&&!Re.sizeof){if(Re.sizeof=ge(Re.signature),!Re.sizeof)r(O(X,me),"is missing a sizeof property.",Re)}if(Re.offset===void 0)if(je)Re.offset=Te;else r(O(X,me),"is missing its offset.",JSON.stringify(Re));if(ee.members[me]=Re,!Ge||Ge.offset<Re.offset)Ge=Re;let Tt=!!Re.autoCalc;if(je)Re.autoCalcSizeOffset=!0;if(Wt.call(Oe,fe,me,Re),Tt)Re.autoCalcSizeOffset=!0;else delete Re.autoCalcSizeOffset;Te+=Re.sizeof}),!Ge)r("No member property descriptions found.");if(!ee.sizeof)ee.sizeof=Te;if(ee.sizeof===1)ee.signature==="c"||ee.signature==="C"||r("Unexpected sizeof==1 member",O(X,k),"with signature",ee.signature);else{if(ee.sizeof%4!==0)console.warn("Invalid struct member description",ee),r(X,"sizeof is not aligned. sizeof="+ee.sizeof);if(ee.offset%4!==0)console.warn("Invalid struct member description",ee),r(X,"offset is not aligned. offset="+ee.offset)}if(ee.sizeof<Te)console.warn("Suspect struct description:",ee,"offset =",Te),r("Mismatch in the calculated vs. the provided sizeof/offset info.","Expected sizeof",Te,"but got",ee.sizeof,"for",ee);return delete ee.autoCalcSizeOffset,fe},$e=function P(X,ee){return arguments.length==1?wn.call(P,X):wn.call(P,X,ee)};if($e.StructType=Je,$e.config=t,$e.allocCString=et,$e.adaptGet=Pe,$e.adaptSet=Qe,$e.adaptStruct=He,$e.ptrAdd=z,!$e.debugFlags)$e.debugFlags=a.__makeDebugFlags(a.debugFlags);return $e},globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let t=(...E)=>{throw Error(E.join(" "))},{capi:r,wasm:a,util:_}=i;globalThis.WhWasmUtilInstaller(a),delete globalThis.WhWasmUtilInstaller;let h={core:[["sqlite3_aggregate_context","void*","sqlite3_context*","int"],["sqlite3_backup_init","sqlite3_backup*","sqlite3*","string","sqlite3*","string"],["sqlite3_backup_step","int","sqlite3_backup*","int"],["sqlite3_backup_finish","int","sqlite3_backup*"],["sqlite3_backup_remaining","int","sqlite3_backup*"],["sqlite3_backup_pagecount","int","sqlite3_backup*"],["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 a.xWrap.FuncPtrAdapter({signature:"i(pi)",contextKey:(E,b)=>E[0]}),"*"]],["sqlite3_busy_timeout","int","sqlite3*","int"],["sqlite3_changes","int","sqlite3*"],["sqlite3_clear_bindings","int","sqlite3_stmt*"],["sqlite3_collation_needed","int","sqlite3*","*","*"],["sqlite3_column_blob","*","sqlite3_stmt*","int"],["sqlite3_column_bytes","int","sqlite3_stmt*","int"],["sqlite3_column_count","int","sqlite3_stmt*"],["sqlite3_column_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 a.xWrap.FuncPtrAdapter({name:"sqlite3_commit_hook",signature:"i(p)",contextKey:(E)=>E[0]}),"*"]],["sqlite3_compileoption_get","string","int"],["sqlite3_compileoption_used","int","string"],["sqlite3_complete","int","string:flexible"],["sqlite3_context_db_handle","sqlite3*","sqlite3_context*"],["sqlite3_data_count","int","sqlite3_stmt*"],["sqlite3_db_filename","string","sqlite3*","string"],["sqlite3_db_handle","sqlite3*","sqlite3_stmt*"],["sqlite3_db_name","string","sqlite3*","int"],["sqlite3_db_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 a.xWrap.FuncPtrAdapter({signature:"i(pipp)",bindScope:"transient",callProxy:(E)=>{let b;return(F,T,A,C)=>{try{let z=a.cArgvToJs(T,A);if(!b)b=a.cArgvToJs(T,C);return E(z,b)|0}catch(z){return z.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 a.xWrap.FuncPtrAdapter({name:"sqlite3_rollback_hook",signature:"v(p)",contextKey:(E)=>E[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 a.xWrap.FuncPtrAdapter({name:"sqlite3_trace_v2::callback",signature:"i(ippp)",contextKey:(E,b)=>E[0]}),"*"]],["sqlite3_txn_state","int",["sqlite3*","string"]],["sqlite3_uri_boolean","int","sqlite3_filename","string","int"],["sqlite3_uri_key","string","sqlite3_filename","int"],["sqlite3_uri_parameter","string","sqlite3_filename","string"],["sqlite3_user_data","void*","sqlite3_context*"],["sqlite3_value_blob","*","sqlite3_value*"],["sqlite3_value_bytes","int","sqlite3_value*"],["sqlite3_value_double","f64","sqlite3_value*"],["sqlite3_value_dup","sqlite3_value*","sqlite3_value*"],["sqlite3_value_free",void 0,"sqlite3_value*"],["sqlite3_value_frombind","int","sqlite3_value*"],["sqlite3_value_int","int","sqlite3_value*"],["sqlite3_value_nochange","int","sqlite3_value*"],["sqlite3_value_numeric_type","int","sqlite3_value*"],["sqlite3_value_pointer","*","sqlite3_value*","string:static"],["sqlite3_value_subtype","int","sqlite3_value*"],["sqlite3_value_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 a.xWrap.FuncPtrAdapter({name:"sqlite3_update_hook::callback",signature:"v(pippj)",contextKey:(E)=>E[0],callProxy:(E)=>(b,F,T,A,C)=>{E(b,F,a.cstrToJs(T),a.cstrToJs(A),C)}}),"*"]],["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(a.exports.sqlite3_progress_handler)h.core.push(["sqlite3_progress_handler",void 0,["sqlite3*","int",new a.xWrap.FuncPtrAdapter({name:"xProgressHandler",signature:"i(p)",bindScope:"context",contextKey:(E,b)=>E[0]}),"*"]]);if(a.exports.sqlite3_stmt_explain)h.core.push(["sqlite3_stmt_explain","int","sqlite3_stmt*","int"],["sqlite3_stmt_isexplain","int","sqlite3_stmt*"]);if(a.exports.sqlite3_set_authorizer)h.core.push(["sqlite3_set_authorizer","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"sqlite3_set_authorizer::xAuth",signature:"i(pissss)",contextKey:(E,b)=>E[0],callProxy:(E)=>(b,F,T,A,C,z)=>{try{return T=T&&a.cstrToJs(T),A=A&&a.cstrToJs(A),C=C&&a.cstrToJs(C),z=z&&a.cstrToJs(z),E(b,F,T,A,C,z)|0}catch(f){return f.resultCode||r.SQLITE_ERROR}}}),"*"]]);if(a.exports.sqlite3_column_origin_name)h.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"]);if(a.exports.sqlite3_key_v2)h.core.push(["sqlite3_key","int","sqlite3*","string","int"],["sqlite3_key_v2","int","sqlite3*","string","*","int"],["sqlite3_rekey","int","sqlite3*","string","int"],["sqlite3_rekey_v2","int","sqlite3*","string","*","int"],["sqlite3_activate_see",void 0,"string"],["sqlite3mc_cipher_count","int"],["sqlite3mc_cipher_index","int","string"],["sqlite3mc_cipher_name","string","int"],["sqlite3mc_cipher_name_copy","int","int","string","int"],["sqlite3mc_config","int","sqlite3*","string","int"],["sqlite3mc_config_cipher","int","sqlite3*","string","string","int"],["sqlite3mc_codec_data","string","sqlite3*","string","string"],["sqlite3mc_version","string"],["sqlite3mc_vfs_create","int","string","int"],["sqlite3mc_vfs_destroy",void 0,"string"],["sqlite3mc_vfs_shutdown",void 0]);if(a.bigIntEnabled&&!!a.exports.sqlite3_declare_vtab)h.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","**"]);if(a.bigIntEnabled&&!!a.exports.sqlite3_preupdate_hook)h.int64.push(["sqlite3_preupdate_blobwrite","int","sqlite3*"],["sqlite3_preupdate_count","int","sqlite3*"],["sqlite3_preupdate_depth","int","sqlite3*"],["sqlite3_preupdate_hook","*",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"sqlite3_preupdate_hook",signature:"v(ppippjj)",contextKey:(E)=>E[0],callProxy:(E)=>(b,F,T,A,C,z,f)=>{E(b,F,T,a.cstrToJs(A),a.cstrToJs(C),z,f)}}),"*"]],["sqlite3_preupdate_new","int",["sqlite3*","int","**"]],["sqlite3_preupdate_old","int",["sqlite3*","int","**"]]);if(a.bigIntEnabled&&!!a.exports.sqlite3changegroup_add&&!!a.exports.sqlite3session_create&&!!a.exports.sqlite3_preupdate_hook){let E={signature:"i(ps)",callProxy:(b)=>(F,T)=>{try{return b(F,a.cstrToJs(T))|0}catch(A){return A.resultCode||r.SQLITE_ERROR}}};h.int64.push(["sqlite3changegroup_add","int",["sqlite3_changegroup*","int","void*"]],["sqlite3changegroup_add_strm","int",["sqlite3_changegroup*",new a.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 a.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppi)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply","int",["sqlite3*","int","void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_strm","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*"]],["sqlite3changeset_apply_v2","int",["sqlite3*","int","void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v2_strm","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",bindScope:"transient",...E}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v3","int",["sqlite3*","int","void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",signature:"i(pp)",bindScope:"transient"}),new a.xWrap.FuncPtrAdapter({name:"xConflict",signature:"i(pip)",bindScope:"transient"}),"void*","**","int*","int"]],["sqlite3changeset_apply_v3_strm","int",["sqlite3*",new a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xFilter",signature:"i(pp)",bindScope:"transient"}),new a.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 a.xWrap.FuncPtrAdapter({name:"xInputA",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.xWrap.FuncPtrAdapter({name:"xInputB",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.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 a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*",new a.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 a.xWrap.FuncPtrAdapter({name:"xInput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3changeset_start_v2","int",["**","int","*","int"]],["sqlite3changeset_start_v2_strm","int",["**",new a.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 a.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 a.xWrap.FuncPtrAdapter({name:"xOutput",signature:"i(ppp)",bindScope:"transient"}),"void*"]],["sqlite3session_table_filter",void 0,["sqlite3_session*",new a.xWrap.FuncPtrAdapter({name:"xFilter",...E,contextKey:(b,F)=>b[0]}),"*"]])}i.StructBinder=globalThis.Jaccwabyt({heap:a.heap8u,alloc:a.alloc,dealloc:a.dealloc,bigIntEnabled:a.bigIntEnabled,pointerIR:a.ptr.ir,memberPrefix:"$"}),delete globalThis.Jaccwabyt;{let E=a.xWrap.argAdapter("string");a.xWrap.argAdapter("string:flexible",(A)=>E(_.flexibleString(A))),a.xWrap.argAdapter("string:static",function(A){if(a.isPtr(A))return A;return A=""+A,this[A]||(this[A]=a.allocCString(A))}.bind(Object.create(null)));let b=a.xWrap.argAdapter("*"),F=function(){};if(a.xWrap.argAdapter("sqlite3_filename",b)("sqlite3_backup*",b)("sqlite3_context*",b)("sqlite3_value*",b)("void*",b)("sqlite3_changegroup*",b)("sqlite3_changeset_iter*",b)("sqlite3_session*",b)("sqlite3_stmt*",(A)=>b(A instanceof(i?.oo1?.Stmt||F)?A.pointer:A))("sqlite3*",(A)=>b(A instanceof(i?.oo1?.DB||F)?A.pointer:A))("sqlite3_vfs*",(A)=>{if(typeof A==="string")return r.sqlite3_vfs_find(A)||i.SQLite3Error.toss(r.SQLITE_NOTFOUND,"Unknown sqlite3_vfs name:",A);return b(A instanceof(r.sqlite3_vfs||F)?A.pointer:A)}),a.exports.sqlite3_declare_vtab)a.xWrap.argAdapter("sqlite3_index_info*",(A)=>b(A instanceof(r.sqlite3_index_info||F)?A.pointer:A))("sqlite3_module*",(A)=>b(A instanceof(r.sqlite3_module||F)?A.pointer:A));let T=a.xWrap.resultAdapter("*");a.xWrap.resultAdapter("sqlite3*",T)("sqlite3_backup*",T)("sqlite3_context*",T)("sqlite3_stmt*",T)("sqlite3_value*",T)("sqlite3_vfs*",T)("void*",T);for(let A of h.core)r[A[0]]=a.xWrap.apply(null,A);for(let A of h.wasmInternal)_[A[0]]=a.xWrap.apply(null,A);for(let A of h.int64)r[A[0]]=a.bigIntEnabled?a.xWrap.apply(null,A):()=>t(A[0]+"() is unavailable due to lack","of BigInt support in this build.");delete h.core,delete h.int64,delete h.wasmInternal,_.sqlite3__wasm_db_error=function(A,C,z){if(!A)return r.SQLITE_MISUSE;if(C instanceof i.WasmAllocError)C=r.SQLITE_NOMEM,z=0;else if(C instanceof Error)z=z||""+C,C=C.resultCode||r.SQLITE_ERROR;return r.sqlite3_set_errmsg(A,C,z)||C}}{let E=a.xCall("sqlite3__wasm_enum_json");if(!E)t("Maintenance required: increase sqlite3__wasm_enum_json()'s","static buffer size!");a.ctype=JSON.parse(a.cstrToJs(E));let b=["access","authorizer","blobFinalizers","changeset","config","dataTypes","dbConfig","dbStatus","encodings","fcntl","flock","ioCap","limits","openFlags","prepareFlags","resultCodes","sqlite3Status","stmtStatus","syncFlags","trace","txnState","udfFlags","version"];if(a.bigIntEnabled)b.push("serialize","session","vtab");for(let A of b)for(let C of Object.entries(a.ctype[A]))r[C[0]]=C[1];if(!a.functionEntry(r.SQLITE_WASM_DEALLOC))t("Internal error: cannot resolve exported function","entry SQLITE_WASM_DEALLOC (=="+r.SQLITE_WASM_DEALLOC+").");let F=Object.create(null);for(let A of Object.entries(a.ctype.resultCodes))F[A[1]]=A[0];r.sqlite3_js_rc_str=(A)=>F[A];let T=Object.assign(Object.create(null),{WasmTestStruct:!0,sqlite3_index_info:!a.bigIntEnabled,sqlite3_index_constraint:!a.bigIntEnabled,sqlite3_index_orderby:!a.bigIntEnabled,sqlite3_index_constraint_usage:!a.bigIntEnabled});for(let A of a.ctype.structs)if(!T[A.name])r[A.name]=i.StructBinder(A);if(r.sqlite3_index_info){for(let 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=a.xWrap("sqlite3__wasm_vtab_config","int",["sqlite3*","int","int"])}}let I=(E,b,F)=>_.sqlite3__wasm_db_error(E,r.SQLITE_MISUSE,b+"() requires "+F+" argument"+(F===1?"":"s")+"."),S=(E)=>_.sqlite3__wasm_db_error(E,r.SQLITE_FORMAT,"SQLITE_UTF8 is the only supported encoding."),R=(E)=>a.xWrap.argAdapter("sqlite3*")(E),M=(E)=>a.isPtr(E)?a.cstrToJs(E):E,p=function(E,b){E=R(E);let F=this.dbMap.get(E);if(!b)return this.dbMap.delete(E),F;else if(!F&&b>0)this.dbMap.set(E,F=Object.create(null));return F}.bind(Object.assign(Object.create(null),{dbMap:new Map}));if(p.addCollation=function(E,b){let F=p(E,1);if(!F.collation)F.collation=new Set;F.collation.add(M(b).toLowerCase())},p._addUDF=function(E,b,F,T){b=M(b).toLowerCase();let A=T.get(b);if(!A)T.set(b,A=new Set);A.add(F<0?-1:F)},p.addFunction=function(E,b,F){let T=p(E,1);if(!T.udf)T.udf=new Map;this._addUDF(E,b,F,T.udf)},a.exports.sqlite3_create_window_function)p.addWindowFunc=function(E,b,F){let T=p(E,1);if(!T.wudf)T.wudf=new Map;this._addUDF(E,b,F,T.wudf)};p.cleanup=function(E){E=R(E);for(let T 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]]){let[A,C]=T;if(!a.exports[A])continue;let f=[E];f.length=C;try{r[A](...f)}catch(w){i.config.warn("close-time call of",A+"(",f,") threw:",w)}}let b=p(E,0);if(!b)return;if(b.collation){for(let T of b.collation)try{r.sqlite3_create_collation_v2(E,T,r.SQLITE_UTF8,0,0,0)}catch(A){}delete b.collation}let F;for(F=0;F<2;++F){let T=F?b.wudf:b.udf;if(!T)continue;let A=F?r.sqlite3_create_window_function:r.sqlite3_create_function_v2;for(let C of T){let z=C[0],f=C[1],w=[E,z,0,r.SQLITE_UTF8,0,0,0,0,0];if(F)w.push(0);for(let N of f)try{w[2]=N,A.apply(null,w)}catch(J){}f.clear()}T.clear()}delete b.udf,delete b.wudf};{let E=a.xWrap("sqlite3_close_v2","int","sqlite3*");r.sqlite3_close_v2=function(b){if(arguments.length!==1)return I(b,"sqlite3_close_v2",1);if(b)try{p.cleanup(b)}catch(F){}return E(b)}}if(r.sqlite3session_create){let E=a.xWrap("sqlite3session_delete",void 0,["sqlite3_session*"]);r.sqlite3session_delete=function(b){if(arguments.length!==1)return I(pDb,"sqlite3session_delete",1);else if(b)r.sqlite3session_table_filter(b,0,0);E(b)}}{let E=(F,T)=>"argv["+T+"]:"+F[0]+":"+a.cstrToJs(F[1]).toLowerCase(),b=a.xWrap("sqlite3_create_collation_v2","int",["sqlite3*","string","int","*",new a.xWrap.FuncPtrAdapter({name:"xCompare",signature:"i(pipip)",contextKey:E}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",signature:"v(p)",contextKey:E})]);r.sqlite3_create_collation_v2=function(F,T,A,C,z,f){if(arguments.length!==6)return I(F,"sqlite3_create_collation_v2",6);else if((A&15)===0)A|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(A&15))return S(F);try{let w=b(F,T,A,C,z,f);if(w===0&&z instanceof Function)p.addCollation(F,T);return w}catch(w){return _.sqlite3__wasm_db_error(F,w)}},r.sqlite3_create_collation=(F,T,A,C,z)=>arguments.length===5?r.sqlite3_create_collation_v2(F,T,A,C,z,0):I(F,"sqlite3_create_collation",5)}{let E=function(A,C){return A[0]+":"+(A[2]<0?-1:A[2])+":"+C+":"+a.cstrToJs(A[1]).toLowerCase()},b=Object.assign(Object.create(null),{xInverseAndStep:{signature:"v(pip)",contextKey:E,callProxy:(A)=>(C,z,f)=>{try{A(C,...r.sqlite3_values_to_js(z,f))}catch(w){r.sqlite3_result_error_js(C,w)}}},xFinalAndValue:{signature:"v(p)",contextKey:E,callProxy:(A)=>(C)=>{try{r.sqlite3_result_js(C,A(C))}catch(z){r.sqlite3_result_error_js(C,z)}}},xFunc:{signature:"v(pip)",contextKey:E,callProxy:(A)=>(C,z,f)=>{try{r.sqlite3_result_js(C,A(C,...r.sqlite3_values_to_js(z,f)))}catch(w){r.sqlite3_result_error_js(C,w)}}},xDestroy:{signature:"v(p)",contextKey:E,callProxy:(A)=>(C)=>{try{A(C)}catch(z){console.error("UDF xDestroy method threw:",z)}}}}),F=a.xWrap("sqlite3_create_function_v2","int",["sqlite3*","string","int","int","*",new a.xWrap.FuncPtrAdapter({name:"xFunc",...b.xFunc}),new a.xWrap.FuncPtrAdapter({name:"xStep",...b.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xFinal",...b.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",...b.xDestroy})]),T=a.exports.sqlite3_create_window_function?a.xWrap("sqlite3_create_window_function","int",["sqlite3*","string","int","int","*",new a.xWrap.FuncPtrAdapter({name:"xStep",...b.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xFinal",...b.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xValue",...b.xFinalAndValue}),new a.xWrap.FuncPtrAdapter({name:"xInverse",...b.xInverseAndStep}),new a.xWrap.FuncPtrAdapter({name:"xDestroy",...b.xDestroy})]):void 0;if(r.sqlite3_create_function_v2=function A(C,z,f,w,N,J,ie,le,we){if(A.length!==arguments.length)return I(C,"sqlite3_create_function_v2",A.length);else if((w&15)===0)w|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(w&15))return S(C);try{let ge=F(C,z,f,w,N,J,ie,le,we);if(ge===0&&(J instanceof Function||ie instanceof Function||le instanceof Function||we instanceof Function))p.addFunction(C,z,f);return ge}catch(ge){return console.error("sqlite3_create_function_v2() setup threw:",ge),_.sqlite3__wasm_db_error(C,ge,"Creation of UDF threw: "+ge)}},r.sqlite3_create_function=function A(C,z,f,w,N,J,ie,le){return A.length===arguments.length?r.sqlite3_create_function_v2(C,z,f,w,N,J,ie,le,0):I(C,"sqlite3_create_function",A.length)},T)r.sqlite3_create_window_function=function A(C,z,f,w,N,J,ie,le,we,ge){if(A.length!==arguments.length)return I(C,"sqlite3_create_window_function",A.length);else if((w&15)===0)w|=r.SQLITE_UTF8;else if(r.SQLITE_UTF8!==(w&15))return S(C);try{let K=T(C,z,f,w,N,J,ie,le,we,ge);if(K===0&&(J instanceof Function||ie instanceof Function||le instanceof Function||we instanceof Function||ge instanceof Function))p.addWindowFunc(C,z,f);return K}catch(K){return console.error("sqlite3_create_window_function() setup threw:",K),_.sqlite3__wasm_db_error(C,K,"Creation of UDF threw: "+K)}};else delete r.sqlite3_create_window_function;if(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;if(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;if(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}{let E=(F,T)=>{if(typeof F==="string")T=-1;else if(_.isSQLableTypedArray(F))T=F.byteLength,F=a.typedArrayToString(F instanceof ArrayBuffer?new Uint8Array(F):F);else if(Array.isArray(F))F=F.join(""),T=-1;return[F,T]},b={basic:a.xWrap("sqlite3_prepare_v3","int",["sqlite3*","string","int","int","**","**"]),full:a.xWrap("sqlite3_prepare_v3","int",["sqlite3*","*","int","int","**","**"])};r.sqlite3_prepare_v3=function F(T,A,C,z,f,w){if(F.length!==arguments.length)return I(T,"sqlite3_prepare_v3",F.length);let[N,J]=E(A,Number(C));switch(typeof N){case"string":return b.basic(T,N,J,z,f,null);case typeof a.ptr.null:return b.full(T,a.ptr.coerce(N),J,z,f,w);default:return _.sqlite3__wasm_db_error(T,r.SQLITE_MISUSE,"Invalid SQL argument type for sqlite3_prepare_v2/v3(). typeof="+typeof N)}},r.sqlite3_prepare_v2=function F(T,A,C,z,f){return F.length===arguments.length?r.sqlite3_prepare_v3(T,A,C,0,z,f):I(T,"sqlite3_prepare_v2",F.length)}}{let E=a.xWrap("sqlite3_bind_text","int",["sqlite3_stmt*","int","string","int","*"]),b=a.xWrap("sqlite3_bind_blob","int",["sqlite3_stmt*","int","*","int","*"]);r.sqlite3_bind_text=function F(T,A,C,z,f){if(F.length!==arguments.length)return I(r.sqlite3_db_handle(T),"sqlite3_bind_text",F.length);else if(a.isPtr(C)||C===null)return E(T,A,C,z,f);else if(C instanceof ArrayBuffer)C=new Uint8Array(C);else if(Array.isArray(pMem))C=pMem.join("");let w,N;try{if(_.isSQLableTypedArray(C))w=a.allocFromTypedArray(C),N=C.byteLength;else if(typeof C==="string")[w,N]=a.allocCString(C);else return _.sqlite3__wasm_db_error(r.sqlite3_db_handle(T),r.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_text().");return E(T,A,w,N,r.SQLITE_WASM_DEALLOC)}catch(J){return a.dealloc(w),_.sqlite3__wasm_db_error(r.sqlite3_db_handle(T),J)}},r.sqlite3_bind_blob=function F(T,A,C,z,f){if(F.length!==arguments.length)return I(r.sqlite3_db_handle(T),"sqlite3_bind_blob",F.length);else if(a.isPtr(C)||C===null)return b(T,A,C,z,f);else if(C instanceof ArrayBuffer)C=new Uint8Array(C);else if(Array.isArray(C))C=C.join("");let w,N;try{if(_.isBindableTypedArray(C))w=a.allocFromTypedArray(C),N=z>=0?z:C.byteLength;else if(typeof C==="string")[w,N]=a.allocCString(C);else return _.sqlite3__wasm_db_error(r.sqlite3_db_handle(T),r.SQLITE_MISUSE,"Invalid 3rd argument type for sqlite3_bind_blob().");return b(T,A,w,N,r.SQLITE_WASM_DEALLOC)}catch(J){return a.dealloc(w),_.sqlite3__wasm_db_error(r.sqlite3_db_handle(T),J)}}}if(!r.sqlite3_column_text){let E=a.xWrap.argAdapter("sqlite3_stmt*"),b=a.xWrap.argAdapter("int"),F=a.xWrap.argAdapter("sqlite3_value*"),T=(A,C)=>a.typedArrayToString(a.heap8u(),Number(A),Number(A)+C);r.sqlite3_column_text=function(A,C){let z=E(A),f=b(C),w=a.exports.sqlite3_column_text(z,f);return w?T(w,a.exports.sqlite3_column_bytes(z,f)):null},r.sqlite3_value_text=function(A){let C=F(A),z=a.exports.sqlite3_value_text(C);return z?T(z,a.exports.sqlite3_value_bytes(C)):null}}r.sqlite3_config=function(E,...b){if(arguments.length<2)return r.SQLITE_MISUSE;switch(E){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 a.exports.sqlite3__wasm_config_i(E,b[0]);case r.SQLITE_CONFIG_LOOKASIDE:return a.exports.sqlite3__wasm_config_ii(E,b[0],b[1]);case r.SQLITE_CONFIG_MEMDB_MAXSIZE:return a.exports.sqlite3__wasm_config_j(E,b[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}};{let E=new Set;r.sqlite3_auto_extension=function(b){if(b instanceof Function)b=a.installFunction("i(ppp)",b);else if(arguments.length!==1||!a.isPtr(b))return r.SQLITE_MISUSE;let F=a.exports.sqlite3_auto_extension(b);if(b!==arguments[0])if(F===0)E.add(b);else a.uninstallFunction(b);return F},r.sqlite3_cancel_auto_extension=function(b){if(!b||arguments.length!==1||!a.isPtr(b))return 0;return a.exports.sqlite3_cancel_auto_extension(b)},r.sqlite3_reset_auto_extension=function(){a.exports.sqlite3_reset_auto_extension();for(let b of E)a.uninstallFunction(b);E.clear()}}a.xWrap.FuncPtrAdapter.warnOnUse=!0;let ne=i.StructBinder,W=function E(b,F,T,A=E.installMethodArgcCheck){if(!(b instanceof ne.StructType))t("Usage error: target object is-not-a StructType.");else if(!(T instanceof Function)&&!a.isPtr(T))t("Usage error: expecting a Function or WASM pointer to one.");if(arguments.length===1)return(w,N)=>E(b,w,N,A);if(!E.argcProxy)E.argcProxy=function(w,N,J,ie){return function(...le){if(J.length!==arguments.length)t("Argument mismatch for",w.structInfo.name+"::"+N+": Native signature is:",ie);return J.apply(this,le)}},E.removeFuncList=function(){if(this.ondispose.__removeFuncList)this.ondispose.__removeFuncList.forEach((w,N)=>{if(a.isPtr(w))try{a.uninstallFunction(w)}catch(J){}}),delete this.ondispose.__removeFuncList};let C=b.memberSignature(F);if(C.length<2)t("Member",F,"does not have a function pointer signature:",C);let z=b.memberKey(F),f=A&&!a.isPtr(T)?E.argcProxy(b,z,T,C):T;if(a.isPtr(f)){if(f&&!a.functionEntry(f))t("Pointer",f,"is not a WASM function table entry.");b[z]=f}else{let w=a.installFunction(f,C);if(b[z]=w,!b.ondispose||!b.ondispose.__removeFuncList)b.addOnDispose("ondispose.__removeFuncList handler",E.removeFuncList),b.ondispose.__removeFuncList=[];b.ondispose.__removeFuncList.push(z,w)}return(w,N)=>E(b,w,N,A)};W.installMethodArgcCheck=!1;let U=function(E,b,F=W.installMethodArgcCheck){let T=new Map;for(let A of Object.keys(b)){let C=b[A],z=T.get(C);if(z){let f=E.memberKey(A);E[f]=E[E.memberKey(z)]}else W(E,A,C,F),T.set(C,A)}return E};ne.StructType.prototype.installMethod=function(b,F,T=W.installMethodArgcCheck){return arguments.length<3&&b&&typeof b==="object"?U(this,...arguments):W(this,...arguments)},ne.StructType.prototype.installMethods=function(E,b=W.installMethodArgcCheck){return U(this,E,b)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let t=(...m)=>{throw new i.SQLite3Error(...m)},{capi:r,wasm:a,util:_}=i,h=function(m){return(...y)=>m("sqlite3.oo1:",...y)},I=i.__isUnderTest?h(console.debug.bind(console)):h(i.config.debug),S=i.__isUnderTest?h(console.warn.bind(console)):h(i.config.warn),R=i.__isUnderTest?h(console.error.bind(console)):h(i.config.error),M=new WeakMap,p=new Set,ne=new WeakMap,W=(m,y,D)=>{let c=Object.getOwnPropertyDescriptor(m,y);return c?c.value:D},U=function(m,y){if(y){if(m instanceof C)m=m.pointer;t(y,"sqlite3 result code",y+":",m?r.sqlite3_errmsg(m):r.sqlite3_errstr(y))}return arguments[0]},E=a.installFunction("i(ippp)",function(m,y,D,c){if(r.SQLITE_TRACE_STMT===m)console.log("SQL TRACE #"+ ++this.counter,"via sqlite3@"+y+"["+r.sqlite3_db_filename(y,null)+"]",a.cstrToJs(c))}.bind({counter:0})),b=Object.create(null),F=function(m){if(m instanceof ArrayBuffer)m=new Uint8Array(m);let y=[],D="0123456789abcdef";for(let c of m)y.push(D[(c&240)>>4],D[c&15]);return y.join("")},T=function(m,y){if(!r.sqlite3_key_v2)return;let D,c,d=(y.key?1:0)+(y.hexkey?1:0)+(y.textkey?1:0);if(!d)return;else if(d>1)t(r.SQLITE_MISUSE,"Only ONE of (key, hexkey, textkey) may be provided.");if(y.key){if(D="key",c=y.key,typeof c==="string")c=new TextEncoder("utf-8").encode(c);if(c instanceof ArrayBuffer||c instanceof Uint8Array)c=F(c),D="hexkey";else{t(r.SQLITE_MISUSE,"Invalid value for the 'key' option. Expecting a string,","ArrayBuffer, or Uint8Array.");return}}else if(y.textkey){if(D="textkey",c=y.textkey,c instanceof ArrayBuffer)c=new Uint8Array(c);if(c instanceof Uint8Array)c=new TextDecoder("utf-8").decode(c);else if(typeof c!=="string")t(r.SQLITE_MISUSE,"Invalid value for the 'textkey' option. Expecting a string,","ArrayBuffer, or Uint8Array.")}else if(y.hexkey){if(D="hexkey",c=y.hexkey,c instanceof ArrayBuffer||c instanceof Uint8Array)c=F(c);else if(typeof c!=="string")t(r.SQLITE_MISUSE,"Invalid value for the 'hexkey' option. Expecting a string,","ArrayBuffer, or Uint8Array.")}else return;let L;try{return L=m.prepare("PRAGMA "+D+"="+_.sqlite3__wasm_qfmt_token(c,1)),L.step(),!0}finally{if(L)L.finalize()}},A=function m(...y){let D=m.normalizeArgs(...y),c;if(c=D["sqlite3*"]){if(!D["sqlite3*:takeOwnership"])p.add(this);this.filename=r.sqlite3_db_filename(c,"main")}else{let{filename:d,vfs:L,flags:G}=D;if(typeof d!=="string"&&!a.isPtr(d)||typeof G!=="string"||L&&(typeof L!=="string"&&!a.isPtr(L)))i.config.error("Invalid DB ctor args",D,arguments),t("Invalid arguments for DB constructor:",arguments,"opts:",D);let B=0;if(G.indexOf("c")>=0)B|=r.SQLITE_OPEN_CREATE|r.SQLITE_OPEN_READWRITE;if(G.indexOf("w")>=0)B|=r.SQLITE_OPEN_READWRITE;if(B===0)B|=r.SQLITE_OPEN_READONLY;B|=r.SQLITE_OPEN_EXRESCODE;let ae=a.pstack.pointer;try{let ce=a.pstack.allocPtr(),be=r.sqlite3_open_v2(d,ce,B,L||a.ptr.null);if(c=a.peekPtr(ce),U(c,be),r.sqlite3_extended_result_codes(c,1),G.indexOf("t")>=0)r.sqlite3_trace_v2(c,r.SQLITE_TRACE_STMT,E,c)}catch(ce){if(c)r.sqlite3_close_v2(c);throw ce}finally{a.pstack.restore(ae)}this.filename=a.isPtr(d)?a.cstrToJs(d):d}if(M.set(this,c),ne.set(this,Object.create(null)),!D["sqlite3*"])try{T(this,D);let d=r.sqlite3_js_db_vfs(c)||t("Internal error: cannot get VFS for new db handle."),L=b[d];if(L)if(L instanceof Function)L(this,i);else U(c,r.sqlite3_exec(c,L,0,0,0))}catch(d){throw this.close(),d}};A.setVfsPostOpenCallback=function(m,y){if(!(y instanceof Function))t("dbCtorHelper.setVfsPostOpenCallback() should not be used with a non-function argument.",arguments);b[m]=y},A.normalizeArgs=function(m=":memory:",y="c",D=null){let c={};if(arguments.length===1&&arguments[0]&&typeof arguments[0]==="object"){if(Object.assign(c,arguments[0]),c.flags===void 0)c.flags="c";if(c.vfs===void 0)c.vfs=null;if(c.filename===void 0)c.filename=":memory:"}else c.filename=m,c.flags=y,c.vfs=D;return c};let C=function(...m){A.apply(this,m)};C.dbCtorHelper=A;let z={null:1,number:2,string:3,boolean:4,blob:5};if(a.bigIntEnabled)z.bigint=z.number;let f=function(){if(z!==arguments[2])t(r.SQLITE_MISUSE,"Do not call the Stmt constructor directly. Use DB.prepare().");if(this.db=arguments[0],M.set(this,arguments[1]),arguments.length>3&&!arguments[3])p.add(this)},w=function(m){if(!m.pointer)t("DB has been closed.");return m},N=function(m,y){if(y!==(y|0)||y<0||y>=m.columnCount)t("Column index",y,"is out of range.");return m},J=function(m,y){let D=Object.create(null);switch(D.opt=Object.create(null),y.length){case 1:if(typeof y[0]==="string"||_.isSQLableTypedArray(y[0]))D.sql=y[0];else if(Array.isArray(y[0]))D.sql=y[0];else if(y[0]&&typeof y[0]==="object")D.opt=y[0],D.sql=D.opt.sql;break;case 2:D.sql=y[0],D.opt=y[1];break;default:t("Invalid argument count for exec().")}if(D.sql=_.flexibleString(D.sql),typeof D.sql!=="string")t("Missing SQL argument or unsupported SQL value type.");let c=D.opt;switch(c.returnValue){case"resultRows":if(!c.resultRows)c.resultRows=[];D.returnVal=()=>c.resultRows;break;case"saveSql":if(!c.saveSql)c.saveSql=[];D.returnVal=()=>c.saveSql;break;case void 0:case"this":D.returnVal=()=>m;break;default:t("Invalid returnValue value:",c.returnValue)}if(!c.callback&&!c.returnValue&&c.rowMode!==void 0){if(!c.resultRows)c.resultRows=[];D.returnVal=()=>c.resultRows}if(c.callback||c.resultRows)switch(c.rowMode===void 0?"array":c.rowMode){case"object":D.cbArg=(d,L)=>{if(!L.columnNames)L.columnNames=d.getColumnNames([]);let G=d.get([]),B=Object.create(null);for(let ae in L.columnNames)B[L.columnNames[ae]]=G[ae];return B};break;case"array":D.cbArg=(d)=>d.get([]);break;case"stmt":if(Array.isArray(c.resultRows))t("exec(): invalid rowMode for a resultRows array: must","be one of 'array', 'object',","a result column number, or column name reference.");D.cbArg=(d)=>d;break;default:if(_.isInt32(c.rowMode)){D.cbArg=(d)=>d.get(c.rowMode);break}else if(typeof c.rowMode==="string"&&c.rowMode.length>1&&c.rowMode[0]==="$"){let d=c.rowMode.substr(1);D.cbArg=(L)=>{let G=L.get(Object.create(null))[d];return G===void 0?t(r.SQLITE_NOTFOUND,"exec(): unknown result column:",d):G};break}t("Invalid rowMode:",c.rowMode)}return D},ie=(m,y,D,...c)=>{let d=m.prepare(y);try{let L=d.bind(D).step()?d.get(...c):void 0;return d.reset(),L}finally{d.finalize()}},le=(m,y,D,c)=>m.exec({sql:y,bind:D,rowMode:c,returnValue:"resultRows"}),we=(m,y,D)=>{switch(D===void 0?r.sqlite3_column_type(m.pointer,y):D){case r.SQLITE_NULL:return null;case r.SQLITE_INTEGER:if(a.bigIntEnabled){let c=r.sqlite3_column_int64(m.pointer,y);if(c>=Number.MIN_SAFE_INTEGER&&c<=Number.MAX_SAFE_INTEGER)return Number(c).valueOf();return c}else{let c=r.sqlite3_column_double(m.pointer,y);if(c>Number.MAX_SAFE_INTEGER||c<Number.MIN_SAFE_INTEGER)t("Integer is out of range for JS integer range: "+c);return _.isInt32(c)?c|0:c}case r.SQLITE_FLOAT:return r.sqlite3_column_double(m.pointer,y);case r.SQLITE_TEXT:return r.sqlite3_column_text(m.pointer,y);case r.SQLITE_BLOB:{let c=r.sqlite3_column_bytes(m.pointer,y),d=r.sqlite3_column_blob(m.pointer,y),L=new Uint8Array(c);if(c){if(L.set(a.heap8u().slice(Number(d),Number(d)+c),0),m.db._blobXfer instanceof Array)m.db._blobXfer.push(L.buffer)}return L}default:t("Don't know how to translate","type of result column #"+y+".")}t("Not reached.")};C.checkRc=(m,y)=>U(m,y),C.prototype={isOpen:function(){return!!this.pointer},affirmOpen:function(){return w(this)},close:function(){let m=this.pointer;if(m){if(this.onclose?.before instanceof Function)try{this.onclose.before(this)}catch(y){}for(let y of Object.values(ne.get(this)))if(y?.pointer)try{y.finalize()}catch(D){}if(M.delete(this),ne.delete(this),!p.delete(this))r.sqlite3_close_v2(m);if(this.onclose?.after instanceof Function)try{this.onclose.after(this)}catch(y){}delete this.filename}},changes:function(m=!1,y=!1){let D=w(this).pointer;if(m)return y?r.sqlite3_total_changes64(D):r.sqlite3_total_changes(D);else return y?r.sqlite3_changes64(D):r.sqlite3_changes(D)},dbFilename:function(m="main"){return r.sqlite3_db_filename(w(this).pointer,m)},dbName:function(m=0){return r.sqlite3_db_name(w(this).pointer,m)},dbVfsName:function(m=0){let y,D=r.sqlite3_js_db_vfs(w(this).pointer,m);if(D){let c=new r.sqlite3_vfs(D);try{y=a.cstrToJs(c.$zName)}finally{c.dispose()}}return y},prepare:function(m){w(this);let y=a.pstack.pointer,D,c;try{D=a.pstack.alloc(8),C.checkRc(this,r.sqlite3_prepare_v2(this.pointer,m,-1,D,null)),c=a.peekPtr(D)}finally{a.pstack.restore(y)}if(!c)t("Cannot prepare empty SQL.");let d=new f(this,c,z);return ne.get(this)[c]=d,d},exec:function(){w(this);let m=J(this,arguments);if(!m.sql)return t("exec() requires an SQL string.");let y=m.opt,D=y.callback,c=Array.isArray(y.resultRows)?y.resultRows:void 0,d,L=y.bind,G=!!(m.cbArg||y.columnNames||c),B=a.scopedAllocPush(),ae=Array.isArray(y.saveSql)?y.saveSql:void 0;try{let ce=_.isSQLableTypedArray(m.sql),be=ce?m.sql.byteLength:a.jstrlen(m.sql),ve=a.scopedAlloc(2*a.ptr.size+(be+1)),Fe=a.ptr.add(ve,a.ptr.size),Pe=a.ptr.add(Fe,a.ptr.size),Ee=a.ptr.add(Pe,be);if(ce)a.heap8().set(m.sql,Pe);else a.jstrcpy(m.sql,a.heap8(),Pe,be,!1);a.poke8(a.ptr.add(Pe,be),0);while(Pe&&a.peek8(Pe)){a.pokePtr([ve,Fe],0),C.checkRc(this,r.sqlite3_prepare_v3(this.pointer,Pe,be,0,ve,Fe));let Qe=a.peekPtr(ve);if(Pe=a.peekPtr(Fe),be=Number(a.ptr.add(Ee,-Pe)),!Qe)continue;if(ae)ae.push(r.sqlite3_sql(Qe).trim());if(d=new f(this,Qe,z),L&&d.parameterCount)d.bind(L),L=null;if(G&&d.columnCount){let He=Array.isArray(y.columnNames)?0:1;if(G=!1,m.cbArg||c){let x=Object.create(null);for(;d.step();q.delete(d)){if(He++===0)d.getColumnNames(x.columnNames=y.columnNames||[]);q.add(d);let j=m.cbArg(d,x);if(c)c.push(j);if(D&&D.call(y,j,d)===!1)break}q.delete(d)}if(He===0)d.getColumnNames(y.columnNames)}else d.step();d.reset().finalize(),d=null}}finally{if(d)q.delete(d),d.finalize();a.scopedAllocPop(B)}return m.returnVal()},createFunction:function(y,D,c){let d=(x)=>x instanceof Function;switch(arguments.length){case 1:c=y,y=c.name,D=c.xFunc||0;break;case 2:if(!d(D))c=D,D=c.xFunc||0;break;case 3:break;default:break}if(!c)c={};if(typeof y!=="string")t("Invalid arguments: missing function name.");let L=c.xStep||0,G=c.xFinal||0,B=c.xValue||0,ae=c.xInverse||0,ce=void 0;if(d(D)){if(ce=!1,d(L)||d(G))t("Ambiguous arguments: scalar or aggregate?");L=G=null}else if(d(L)){if(!d(G))t("Missing xFinal() callback for aggregate or window UDF.");D=null}else if(d(G))t("Missing xStep() callback for aggregate or window UDF.");else t("Missing function-type properties.");if(ce===!1){if(d(B)||d(ae))t("xValue and xInverse are not permitted for non-window UDFs.")}else if(d(B)){if(!d(ae))t("xInverse must be provided if xValue is.");ce=!0}else if(d(ae))t("xValue must be provided if xInverse is.");let be=c.pApp;if(be!==void 0&&be!==null&&!a.isPtr(be))t("Invalid value for pApp property. Must be a legal WASM pointer value.");let ve=c.xDestroy||0;if(ve&&!d(ve))t("xDestroy property must be a function.");let Fe=0;if(W(c,"deterministic"))Fe|=r.SQLITE_DETERMINISTIC;if(W(c,"directOnly"))Fe|=r.SQLITE_DIRECTONLY;if(W(c,"innocuous"))Fe|=r.SQLITE_INNOCUOUS;y=y.toLowerCase();let Pe=D||L,Ee=W(c,"arity"),Qe=typeof Ee==="number"?Ee:Pe.length?Pe.length-1:0,He;if(ce)He=r.sqlite3_create_window_function(this.pointer,y,Qe,r.SQLITE_UTF8|Fe,be||0,L,G,B,ae,ve);else He=r.sqlite3_create_function_v2(this.pointer,y,Qe,r.SQLITE_UTF8|Fe,be||0,D,L,G,ve);return C.checkRc(this,He),this},selectValue:function(m,y,D){return ie(this,m,y,0,D)},selectValues:function(m,y,D){let c=this.prepare(m),d=[];try{N(c,0),c.bind(y);while(c.step())d.push(we(c,0,D));c.reset()}finally{c.finalize()}return d},selectArray:function(m,y){return ie(this,m,y,[])},selectObject:function(m,y){return ie(this,m,y,{})},selectArrays:function(m,y){return le(this,m,y,"array")},selectObjects:function(m,y){return le(this,m,y,"object")},openStatementCount:function(){return this.pointer?Object.keys(ne.get(this)).length:0},transaction:function(m){let y="BEGIN";if(arguments.length>1){if(/[^a-zA-Z]/.test(arguments[0]))t(r.SQLITE_MISUSE,"Invalid argument for BEGIN qualifier.");y+=" "+arguments[0],m=arguments[1]}w(this).exec(y);try{let D=m(this);return this.exec("COMMIT"),D}catch(D){throw this.exec("ROLLBACK"),D}},savepoint:function(m){w(this).exec("SAVEPOINT oo1");try{let y=m(this);return this.exec("RELEASE oo1"),y}catch(y){throw this.exec("ROLLBACK to SAVEPOINT oo1; RELEASE SAVEPOINT oo1"),y}},checkRc:function(m){return U(this,m)}},C.wrapHandle=function(m,y=!1){if(!m||!a.isPtr(m))throw new i.SQLite3Error(r.SQLITE_MISUSE,"Argument must be a WASM sqlite3 pointer");return new C({"sqlite3*":m,"sqlite3*:takeOwnership":!!y})};let ge=function(m){if(!m.pointer)t("Stmt has been closed.");return m},K=function(m){let y=z[m===null||m===void 0?"null":typeof m];switch(y){case z.boolean:case z.null:case z.number:case z.string:return y;case z.bigint:return a.bigIntEnabled?y:void 0;default:return _.isBindableTypedArray(m)?z.blob:void 0}},oe=function(m){return K(m)||t("Unsupported bind() argument type:",typeof m)},u=function(m,y){let D=typeof y==="number"?y:r.sqlite3_bind_parameter_index(m.pointer,y);if(D===0||!_.isInt32(D))t("Invalid bind() parameter name: "+y);else if(D<1||D>m.parameterCount)t("Bind index",y,"is out of range.");return D},q=new Set,O=new Set,V=function(m,y){if(q.has(m))t("Operation is illegal when statement is locked:",y);return m},Z=function m(y,D,c,d){if(V(ge(y),"bind()"),!m._)m._tooBigInt=(G)=>t("BigInt value is too big to store without precision loss:",G),m._={string:function(G,B,ae,ce){let[be,ve]=a.allocCString(ae,!0);return(ce?r.sqlite3_bind_blob:r.sqlite3_bind_text)(G.pointer,B,be,ve,r.SQLITE_WASM_DEALLOC)}};oe(d),D=u(y,D);let L=0;switch(d===null||d===void 0?z.null:c){case z.null:L=r.sqlite3_bind_null(y.pointer,D);break;case z.string:L=m._.string(y,D,d,!1);break;case z.number:{let G;if(_.isInt32(d))G=r.sqlite3_bind_int;else if(typeof d==="bigint")if(!_.bigIntFits64(d))m._tooBigInt(d);else if(a.bigIntEnabled)G=r.sqlite3_bind_int64;else if(_.bigIntFitsDouble(d))d=Number(d),G=r.sqlite3_bind_double;else m._tooBigInt(d);else if(d=Number(d),a.bigIntEnabled&&Number.isInteger(d))G=r.sqlite3_bind_int64;else G=r.sqlite3_bind_double;L=G(y.pointer,D,d);break}case z.boolean:L=r.sqlite3_bind_int(y.pointer,D,d?1:0);break;case z.blob:{if(typeof d==="string"){L=m._.string(y,D,d,!0);break}else if(d instanceof ArrayBuffer)d=new Uint8Array(d);else if(!_.isBindableTypedArray(d))t("Binding a value as a blob requires","that it be a string, Uint8Array, Int8Array, or ArrayBuffer.");let G=a.alloc(d.byteLength||1);a.heap8().set(d.byteLength?d:[0],Number(G)),L=r.sqlite3_bind_blob(y.pointer,D,G,d.byteLength,r.SQLITE_WASM_DEALLOC);break}default:i.config.warn("Unsupported bind() argument type:",d),t("Unsupported bind() argument type: "+typeof d)}if(L)C.checkRc(y.db.pointer,L);return y};f.prototype={finalize:function(){let m=this.pointer;if(m){V(this,"finalize()");let y=p.delete(this)?0:r.sqlite3_finalize(m);return delete ne.get(this.db)[m],M.delete(this),q.delete(this),O.delete(this),delete this.parameterCount,delete this.db,y}},clearBindings:function(){return V(ge(this),"clearBindings()"),r.sqlite3_clear_bindings(this.pointer),O.delete(this),this},reset:function(m){if(V(this,"reset()"),m)this.clearBindings();let y=r.sqlite3_reset(ge(this).pointer);return O.delete(this),U(this.db,y),this},resetNoThrow:function(m){if(V(this,"reset()"),m)this.clearBindings();let y=r.sqlite3_reset(ge(this).pointer);return O.delete(this),y},bind:function(){ge(this);let m,y;switch(arguments.length){case 1:m=1,y=arguments[0];break;case 2:m=arguments[0],y=arguments[1];break;default:t("Invalid bind() arguments.")}if(y===void 0)return this;else if(!this.parameterCount)t("This statement has no bindable parameters.");if(O.delete(this),y===null)return Z(this,m,z.null,y);else if(Array.isArray(y)){if(arguments.length!==1)t("When binding an array, an index argument is not permitted.");return y.forEach((D,c)=>Z(this,c+1,oe(D),D)),this}else if(y instanceof ArrayBuffer)y=new Uint8Array(y);if(typeof y==="object"&&!_.isBindableTypedArray(y)){if(arguments.length!==1)t("When binding an object, an index argument is not permitted.");return Object.keys(y).forEach((D)=>Z(this,D,oe(y[D]),y[D])),this}else return Z(this,m,oe(y),y);t("Should not reach this point.")},bindAsBlob:function(m,y){if(ge(this),arguments.length===1)y=m,m=1;let D=oe(y);if(z.string!==D&&z.blob!==D&&z.null!==D)t("Invalid value type for bindAsBlob()");return Z(this,m,z.blob,y)},step:function(){V(this,"step()");let m=r.sqlite3_step(ge(this).pointer);switch(m){case r.SQLITE_DONE:return O.delete(this),!1;case r.SQLITE_ROW:return O.add(this),!0;default:O.delete(this),i.config.warn("sqlite3_step() rc=",m,r.sqlite3_js_rc_str(m),"SQL =",r.sqlite3_sql(this.pointer)),C.checkRc(this.db.pointer,m)}},stepReset:function(){return this.step(),this.reset()},stepFinalize:function(){try{let m=this.step();return this.reset(),m}finally{try{this.finalize()}catch(m){}}},get:function(m,y){if(!O.has(ge(this)))t("Stmt.step() has not (recently) returned true.");if(Array.isArray(m)){let D=0,c=this.columnCount;while(D<c)m[D]=we(this,D,y),++D;return m}else if(m&&typeof m==="object"){let D=0,c=this.columnCount;while(D<c)m[r.sqlite3_column_name(this.pointer,D)]=we(this,D,y),++D;return m}return N(this,m),we(this,m,y)},getInt:function(m){return this.get(m,r.SQLITE_INTEGER)},getFloat:function(m){return this.get(m,r.SQLITE_FLOAT)},getString:function(m){return this.get(m,r.SQLITE_TEXT)},getBlob:function(m){return this.get(m,r.SQLITE_BLOB)},getJSON:function(m){let y=this.get(m,r.SQLITE_STRING);return y===null?y:JSON.parse(y)},getColumnName:function(m){return r.sqlite3_column_name(N(ge(this),m).pointer,m)},getColumnNames:function(m=[]){N(ge(this),0);let y=this.columnCount;for(let D=0;D<y;++D)m.push(r.sqlite3_column_name(this.pointer,D));return m},getParamIndex:function(m){return ge(this).parameterCount?r.sqlite3_bind_parameter_index(this.pointer,m):void 0},getParamName:function(m){return ge(this).parameterCount?r.sqlite3_bind_parameter_name(this.pointer,m):void 0},isBusy:function(){return r.sqlite3_stmt_busy(ge(this))!==0},isReadOnly:function(){return r.sqlite3_stmt_readonly(ge(this))!==0}};{let m={enumerable:!0,get:function(){return M.get(this)},set:()=>t("The pointer property is read-only.")};Object.defineProperty(f.prototype,"pointer",m),Object.defineProperty(C.prototype,"pointer",m)}Object.defineProperty(f.prototype,"columnCount",{enumerable:!1,get:function(){return r.sqlite3_column_count(this.pointer)},set:()=>t("The columnCount property is read-only.")}),Object.defineProperty(f.prototype,"parameterCount",{enumerable:!1,get:function(){return r.sqlite3_bind_parameter_count(this.pointer)},set:()=>t("The parameterCount property is read-only.")}),f.wrapHandle=function(m,y,D=!1){let c=f;if(!(m instanceof C)||!m.pointer)throw new i.SQLite3Error(i.SQLITE_MISUSE,"First argument must be an opened sqlite3.oo1.DB instance");if(!y||!a.isPtr(y))throw new i.SQLite3Error(i.SQLITE_MISUSE,"Second argument must be a WASM sqlite3_stmt pointer");return new f(m,y,z,!!D)},i.oo1={DB:C,Stmt:f}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let t=i.util;i.initWorker1API=function(){let r=(...W)=>{throw Error(W.join(" "))};if(!(globalThis.WorkerGlobalScope instanceof Function))r("initWorker1API() must be run from a Worker thread.");let a=this.sqlite3||r("Missing this.sqlite3 object."),_=a.oo1.DB,h=function(W){let U=I.idMap.get(W);if(U)return U;return U="db#"+ ++I.idSeq+":"+Math.floor(Math.random()*1e8)+":"+Math.floor(Math.random()*1e8),I.idMap.set(W,U),U},I={dbList:[],idSeq:0,idMap:new WeakMap,xfer:[],open:function(W){let U=new _(W);if(this.dbs[h(U)]=U,this.dbList.indexOf(U)<0)this.dbList.push(U);return U},close:function(W,U){if(W){delete this.dbs[h(W)];let E=W.filename,b=t.sqlite3__wasm_db_vfs(W.pointer,0);W.close();let F=this.dbList.indexOf(W);if(F>=0)this.dbList.splice(F,1);if(U&&E&&b)t.sqlite3__wasm_vfs_unlink(b,E)}},post:function(W,U){if(U&&U.length)globalThis.postMessage(W,Array.from(U)),U.length=0;else globalThis.postMessage(W)},dbs:Object.create(null),getDb:function(W,U=!0){return this.dbs[W]||(U?r("Unknown (or closed) DB ID:",W):void 0)}},S=function(W=I.dbList[0]){return W&&W.pointer?W:r("DB is not opened.")},R=function(W,U=!0){let E=I.getDb(W.dbId,!1)||I.dbList[0];return U?S(E):E},M=function(){return I.dbList[0]&&h(I.dbList[0])},p=(W)=>W===""||W[0]===":",ne={open:function(W){let U=Object.create(null),E=W.args||Object.create(null);if(E.simulateError)r("Throwing because of simulateError flag.");let b=Object.create(null);U.vfs=E.vfs,U.filename=E.filename||"";let F=I.open(U);return b.filename=F.filename,b.persistent=!!a.capi.sqlite3_js_db_uses_vfs(F.pointer,"opfs"),b.dbId=h(F),b.vfs=F.dbVfsName(),b},close:function(W){let U=R(W,!1),E={filename:U&&U.filename};if(U){let b=W.args&&typeof W.args==="object"?!!W.args.unlink:!1;I.close(U,b)}return E},exec:function(W){let U=typeof W.args==="string"?{sql:W.args}:W.args||Object.create(null);if(U.rowMode==="stmt")r("Invalid rowMode for 'exec': stmt mode","does not work in the Worker API.");else if(!U.sql)r("'exec' requires input SQL.");let E=R(W);if(U.callback||Array.isArray(U.resultRows))E._blobXfer=I.xfer;let b=U.callback,F=0,T=!!U.columnNames;if(typeof b==="string"){if(!T)U.columnNames=[];U.callback=function(A,C){I.post({type:b,columnNames:U.columnNames,rowNumber:++F,row:A},I.xfer)}}try{let A=U.countChanges?E.changes(!0,U.countChanges===64):void 0;if(E.exec(U),A!==void 0)U.changeCount=E.changes(!0,U.countChanges===64)-A;let C=U.lastInsertRowId?a.capi.sqlite3_last_insert_rowid(E):void 0;if(C!==void 0)U.lastInsertRowId=C;if(U.callback instanceof Function)U.callback=b,I.post({type:b,columnNames:U.columnNames,rowNumber:null,row:void 0})}finally{if(delete E._blobXfer,U.callback)U.callback=b}return U},"config-get":function(){let W=Object.create(null),U=a.config;return["bigIntEnabled"].forEach(function(E){if(Object.getOwnPropertyDescriptor(U,E))W[E]=U[E]}),W.version=a.version,W.vfsList=a.capi.sqlite3_js_vfs_list(),W},export:function(W){let U=R(W),E={byteArray:a.capi.sqlite3_js_db_export(U.pointer),filename:U.filename,mimetype:"application/x-sqlite3"};return I.xfer.push(E.byteArray.buffer),E},toss:function(W){r("Testing worker exception")}};globalThis.onmessage=async function(W){W=W.data;let U,E=W.dbId,b=W.type,F=performance.now();try{if(ne.hasOwnProperty(b)&&ne[b]instanceof Function)U=await ne[b](W);else r("Unknown db worker message type:",W.type)}catch(T){if(b="error",U={operation:W.type,message:T.message,errorClass:T.name,input:W},T.stack)U.stack=typeof T.stack==="string"?T.stack.split(/\n\s*/):T.stack}if(!E)E=U.dbId||M();I.post({type:b,dbId:E,messageId:W.messageId,workerReceivedTime:F,workerRespondTime:performance.now(),departureTime:W.departureTime,result:U},I.xfer)},globalThis.postMessage({type:"sqlite3-api",result:"worker1-ready"})}.bind({sqlite3:i})}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){let{wasm:t,capi:r}=i,a=i.util.toss3,_=Object.create(null);i.vfs=_,r.sqlite3_vfs.prototype.registerVfs=function(h=!1){if(!(this instanceof i.capi.sqlite3_vfs))a("Expecting a sqlite3_vfs-type argument.");let I=r.sqlite3_vfs_register(this,h?1:0);if(I)a("sqlite3_vfs_register(",this,") failed with rc",I);if(this.pointer!==r.sqlite3_vfs_find(this.$zName))a("BUG: sqlite3_vfs_find(vfs.$zName) failed for just-installed VFS",this);return this},_.installVfs=function(h){let I=0,S=["io","vfs"];for(let R of S){let M=h[R];if(M){if(++I,M.struct.installMethods(M.methods,!!M.applyArgcCheck),R==="vfs"){if(!M.struct.$zName&&typeof M.name==="string")M.struct.addOnDispose(M.struct.$zName=t.allocCString(M.name));M.struct.registerVfs(!!M.asDefault)}}}if(!I)a("Misuse: installVfs() options object requires at least","one of:",S);return this}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.wasm.exports.sqlite3_declare_vtab)return;let{wasm:t,capi:r}=i,a=i.util.toss3,_=Object.create(null);i.vtab=_;let h=r.sqlite3_index_info;h.prototype.nthConstraint=function(R,M=!1){if(R<0||R>=this.$nConstraint)return!1;let p=t.ptr.add(this.$aConstraint,h.sqlite3_index_constraint.structInfo.sizeof*R);return M?p:new h.sqlite3_index_constraint(p)},h.prototype.nthConstraintUsage=function(R,M=!1){if(R<0||R>=this.$nConstraint)return!1;let p=t.ptr.add(this.$aConstraintUsage,h.sqlite3_index_constraint_usage.structInfo.sizeof*R);return M?p:new h.sqlite3_index_constraint_usage(p)},h.prototype.nthOrderBy=function(R,M=!1){if(R<0||R>=this.$nOrderBy)return!1;let p=t.ptr.add(this.$aOrderBy,h.sqlite3_index_orderby.structInfo.sizeof*R);return M?p:new h.sqlite3_index_orderby(p)};let I=function(R,M){return function(p,ne=!1){if(arguments.length===0)p=new M;if(p instanceof M)return this.set(p.pointer,p),p;else if(!t.isPtr(p))i.SQLite3Error.toss("Invalid argument to",R+"()");let W=this.get(p);if(ne)this.delete(p);return W}.bind(new Map)},S=function(R,M){let p=I(R,M);return Object.assign(Object.create(null),{StructType:M,create:(ne)=>{let W=p();return t.pokePtr(ne,W.pointer),W},get:(ne)=>p(ne),unget:(ne)=>p(ne,!0),dispose:(ne)=>p(ne,!0)?.dispose?.()})};_.xVtab=S("xVtab",r.sqlite3_vtab),_.xCursor=S("xCursor",r.sqlite3_vtab_cursor),_.xIndexInfo=(R)=>new r.sqlite3_index_info(R),_.xError=function R(M,p,ne){if(R.errorReporter instanceof Function)try{R.errorReporter("sqlite3_module::"+M+"(): "+p.message)}catch(U){}let W;if(p instanceof i.WasmAllocError)W=r.SQLITE_NOMEM;else if(arguments.length>2)W=ne;else if(p instanceof i.SQLite3Error)W=p.resultCode;return W||r.SQLITE_ERROR},_.xError.errorReporter=i.config.error.bind(i.config),_.xRowid=(R,M)=>t.poke(R,M,"i64"),_.setupModule=function(R){let M=!1,p=this instanceof r.sqlite3_module?this:R.struct||(M=new r.sqlite3_module);try{let ne=R.methods||a("Missing 'methods' object.");for(let W of Object.entries({xConnect:"xCreate",xDisconnect:"xDestroy"})){let U=W[0],E=W[1];if(ne[U]===!0)ne[U]=ne[E];else if(ne[E]===!0)ne[E]=ne[U]}if(R.catchExceptions){let W=function(b,F){if(["xConnect","xCreate"].indexOf(b)>=0)return function(T,A,C,z,f,w){try{return F(...arguments)||0}catch(N){if(!(N instanceof i.WasmAllocError))t.dealloc(t.peekPtr(w)),t.pokePtr(w,t.allocCString(N.message));return _.xError(b,N)}};else return function(...T){try{return F(...T)||0}catch(A){return _.xError(b,A)}}},U=["xCreate","xConnect","xBestIndex","xDisconnect","xDestroy","xOpen","xClose","xFilter","xNext","xEof","xColumn","xRowid","xUpdate","xBegin","xSync","xCommit","xRollback","xFindFunction","xRename","xSavepoint","xRelease","xRollbackTo","xShadowName"],E=Object.create(null);for(let b of U){let F=ne[b];if(!(F instanceof Function))continue;else if(b==="xConnect"&&ne.xCreate===F)E[b]=ne.xCreate;else if(b==="xCreate"&&ne.xConnect===F)E[b]=ne.xConnect;else E[b]=W(b,F)}p.installMethods(E,!1)}else p.installMethods(ne,!!R.applyArgcCheck);if(p.$iVersion===0){let W;if(typeof R.iVersion==="number")W=R.iVersion;else if(p.$xIntegrity)W=4;else if(p.$xShadowName)W=3;else if(p.$xSavePoint||p.$xRelease||p.$xRollbackTo)W=2;else W=1;p.$iVersion=W}}catch(ne){if(M)M.dispose();throw ne}return p},r.sqlite3_module.prototype.setupModule=function(R){return _.setupModule.call(this,R)}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.kvvfs)return;let t=i.capi,{sqlite3_kvvfs_methods:r,KVVfsFile:a}=t,_=i.capi.sqlite3_vfs_find("kvvfs");if(delete t.sqlite3_kvvfs_methods,delete t.KVVfsFile,!_)return;let{util:h,wasm:I}=i,S=h.toss3,R=(x,j)=>Object.prototype.hasOwnProperty.call(x,j),M=new r(I.exports.sqlite3__wasm_kvvfs_methods());h.assert(32<=M.$nKeySize,"unexpected kvvfsMethods.$nKeySize: "+M.$nKeySize);let p=Object.assign(Object.create(null),{rxJournalSuffix:/-journal$/,zKeyJrnl:I.allocCString("jrnl"),zKeySz:I.allocCString("sz"),keySize:M.$nKeySize,buffer:Object.assign(Object.create(null),{n:M.$nBufferSize,pool:Object.create(null)})});p.memBuffer=(x=0)=>p.buffer.pool[x]??=I.alloc(p.buffer.n),p.memBufferFree=(x)=>{let j=p.buffer.pool[x];if(j)I.dealloc(j),delete p.buffer.pool[x]};let ne=()=>{},W=i.__isUnderTest?(...x)=>i.config.debug?.("kvvfs:",...x):ne,U=(...x)=>i.config.warn?.("kvvfs:",...x),E=(...x)=>i.config.error?.("kvvfs:",...x);class b{#e=Object.create(null);#i=null;#s=0;constructor(){this.clear()}#t(){return this.#i??=Object.keys(this.#e)}key(x){if(x<0||x>=this.#s)return null;return this.#t()[x]}getItem(x){return this.#e[x]??null}setItem(x,j){if(!(x in this.#e))++this.#s,this.#i=null;this.#e[x]=""+j}removeItem(x){if(x in this.#e)delete this.#e[x],--this.#s,this.#i=null}clear(){this.#e=Object.create(null),this.#i=null,this.#s=0}get length(){return this.#s}}let F=(x)=>x==="local"||x==="session",T=(x)=>F(x)?"kvvfs-"+x+"-":"",A=function(x,j=!1){if(F(x))return;let Q=new Blob([x]).size;if(!Q)S(t.SQLITE_MISUSE,"Empty name is not permitted.");let H=p.keySize-1;if(p.rxJournalSuffix.test(x)){if(!j)S(t.SQLITE_MISUSE,"Storage names may not have a '-journal' suffix.")}else if(["-wal","-shm"].filter((_e)=>x.endsWith(_e)).length)S(t.SQLITE_MISUSE,"Storage names may not have a -wal or -shm suffix.");else H-=8;if(Q>H)S(t.SQLITE_RANGE,"Storage name is too long. Limit =",H);let se;for(se=0;se<Q;++se){let _e=x.codePointAt(se);if(_e<32)S(t.SQLITE_RANGE,"Illegal character ("+_e+"d) in storage name:",x)}},C=(x,j=void 0)=>Object.assign(Object.create(null),{jzClass:x,refc:1,deleteAtRefc0:!1,storage:j||new b,keyPrefix:T(x),files:[],listeners:void 0}),z=i.kvvfs=Object.create(null);if(i.__isUnderTest)z.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});let f=function(x){let j=p.rxJournalSuffix.test(x.jzClass)?x.jzClass.replace(p.rxJournalSuffix,""):x.jzClass+"-journal";if(z?.log?.xClose&&W("cleaning up storage handles [",x.jzClass,j,"]",x),delete p.storagePool[x.jzClass],delete p.storagePool[j],!i.__isUnderTest)delete x.storage,delete x.refc},w=(x)=>p.storagePool[x.jzClass]=p.storagePool[x.jzClass+"-journal"]=x,N=".";if(p.storagePool=Object.assign(Object.create(null),{[N]:C(N)}),globalThis.Storage){if(globalThis.localStorage instanceof globalThis.Storage)p.storagePool.local=C("local",globalThis.localStorage);if(globalThis.sessionStorage instanceof globalThis.Storage)p.storagePool.session=C("session",globalThis.sessionStorage)}p.builtinStorageNames=Object.keys(p.storagePool);let J=(x)=>p.builtinStorageNames.indexOf(x)>-1;for(let x of Object.keys(p.storagePool)){let j=p.storagePool[x];p.storagePool[x+"-journal"]=j}p.setError=(x=void 0,j=t.SQLITE_ERROR)=>{if(x)return p.lastError=x,x.resultCode|0||j;return delete p.lastError,0},p.popError=()=>{let x=p.lastError;return delete p.lastError,x};let ie=(x)=>{U("kvvfs.listener handler threw:",x)},le=I.exports.sqlite3__wasm_kvvfs_decode,we=I.exports.sqlite3__wasm_kvvfs_encode,ge=async function(x,j,...Q){try{if(j.keyPrefix&&Q[0])Q[0]=Q[0].replace(j.keyPrefix,"");let H,se,_e,de;for(let ue of j.listeners){let he=Object.create(null);he.storageName=j.jzClass,he.type=x;let Le=ue.decodePages,De=ue.events[x];if(De){if(!ue.includeJournal&&Q[0]==="jrnl")continue;if(x==="write"&&ue.decodePages&&+Q[0]>0){if(he.data=[Q[0]],de?.[Q[0]]){he.data[1]=de[Q[0]];continue}H??=new TextEncoder("utf-8"),se??=p.memBuffer(10),_e??=p.memBuffer(11);let Ae=H.encode(Q[1]),Ce=I.heap8u();Ce.set(Ae,Number(se)),Ce[I.ptr.addn(se,Ae.length)]=0;let Me=le(se,_e,p.buffer.n);if(Me>0)de??=Object.create(null),de[Q[0]]=he.data[1]=Ce.slice(Number(_e),I.ptr.addn(_e,Me));else continue}else he.data=Q.length?Q.length===1?Q[0]:Q:void 0;try{De(he)?.catch?.(ie)}catch(Ae){U("notifyListeners [",j.jzClass,"]",x,Ae)}}}}catch(H){ie(H)}},K=(x)=>typeof x==="string"?p.storagePool[x]:p.storagePool[I.cstrToJs(x)],oe=I.exports.sqlite3__wasm_kvvfsMakeKey,u=(x,j,Q)=>j&&x.keyPrefix?oe(j,Q):Q,q=(x,j,Q)=>I.cstrToJs(u(x,j,Q)),O=(x)=>+x.storage.getItem(x.keyPrefix+"sz"),V=new Map,Z=new Map,m=function(x,j){if(x.lockType<=j)return;let Q=Z.get(x.jzClass);if(x.lockType>t.SQLITE_LOCK_SHARED)Q.lockType=t.SQLITE_LOCK_SHARED;if(j===t.SQLITE_LOCK_NONE&&--Q.nShared===0)Z.delete(x.jzClass);x.lockType=j},y={vfs:Object.create(null),ioDb:Object.create(null),ioJrnl:Object.create(null)},D=(x)=>y[x.$isJournal?"ioJrnl":"ioDb"],c=new t.sqlite3_vfs(M.$pVfs),d=new t.sqlite3_io_methods(M.$pIoDb),L=new t.sqlite3_io_methods(M.$pIoJrnl),G=Object.create(null),B=Object.assign(Object.create(null),{pFileHandles:V,cache:p,storageForZClass:K,KVVfsStorage:b,disablePageSizeChange:!0});if(z.log)z.internal=B;let ae={recordHandler:{xRcrdRead:(x,j,Q,H)=>{try{let se=I.cstrToJs(x),_e=K(se);if(!_e)return-1;let de=q(_e,x,j);z?.log?.xRcrdRead&&U("xRcrdRead",se,de,H,_e);let ue=_e.storage.getItem(de);if(ue===null)return-1;let he=ue.length;if(H<=0)return he;else if(H===1)return I.poke(Q,0),he;else if(H<he)S(t.SQLITE_RANGE,"xRcrdRead()",se,de,"input buffer is too small: need",he,"but have",H);else if(H>he+1)H=he+1;let Le=he<H?he:H-1,De=I.heap8();for(let Ae=0;Ae<Le;++Ae)De[I.ptr.add(Q,Ae)]=ue.codePointAt(Ae)&255;return De[I.ptr.add(Q,Le)]=0,Le}catch(se){return E("kvrecordRead()",se),p.setError(se),-2}},xRcrdWrite:(x,j,Q)=>{try{let H=K(x),se=q(H,x,j),_e=I.cstrToJs(Q);return z?.log?.xRcrdWrite&&U("xRcrdWrite",se,H),H.storage.setItem(se,_e),H.listeners&&ge("write",H,se,_e),0}catch(H){return E("kvrecordWrite()",H),p.setError(H,t.SQLITE_IOERR)}},xRcrdDelete:(x,j)=>{try{let Q=K(x),H=q(Q,x,j);return z?.log?.xRcrdDelete&&U("xRcrdDelete",H,Q),Q.storage.removeItem(H),Q.listeners&&ge("delete",Q,H),0}catch(Q){return E("kvrecordDelete()",Q),p.setError(Q,t.SQLITE_IOERR)}}},vfs:{xOpen:function(x,j,Q,H,se){p.popError();let _e;try{if(!j)_e=I.allocCString(""+Q+"."+(Math.random()*1e5|0)),j=_e;let de=I.cstrToJs(j);if(z?.log?.xOpen&&W("xOpen",de,"flags =",H),A(de,!0),H&(t.SQLITE_OPEN_MAIN_DB|t.SQLITE_OPEN_TEMP_DB|t.SQLITE_OPEN_TRANSIENT_DB)&&p.rxJournalSuffix.test(de))S(t.SQLITE_ERROR,"DB files may not have a '-journal' suffix.");let ue=K(de);if(!ue&&!(H&t.SQLITE_OPEN_CREATE))S(t.SQLITE_ERROR,"Storage not found:",de);let he=y.vfs.xOpen(x,j,Q,H,se);if(he)return he;let Le=!!(t.SQLITE_OPEN_DELETEONCLOSE&H);if(I.isPtr(arguments[1])){if(t.sqlite3_uri_boolean(j,"delete-on-close",0))Le=!0}let De=new a(Q);if(h.assert(De.$zClass,"Missing f.$zClass"),De.addOnDispose(_e),_e=void 0,ue)++ue.refc,ue.files.push(De),I.poke32(se,H);else{I.poke32(se,H|t.SQLITE_OPEN_CREATE),h.assert(!De.$isJournal,"Opening a journal before its db? "+de);let Ae=de.replace(p.rxJournalSuffix,"");ue=C(Ae),w(ue),ue.files.push(De),ue.deleteAtRefc0=Le,z?.log?.xOpen&&W("xOpen installed storage handle [",Ae,Ae+"-journal","]",ue)}return V.set(Q,Object.assign(Object.create(null),{store:ue,file:De,jzClass:de,lockType:0})),ue.listeners&&ge("open",ue,ue.files.length),0}catch(de){return U("xOpen:",de),p.setError(de)}finally{_e&&I.dealloc(_e)}},xDelete:function(x,j,Q){p.popError();try{let H=I.cstrToJs(j);if(p.rxJournalSuffix.test(H))G.xRcrdDelete(j,p.zKeyJrnl);return 0}catch(H){return U("xDelete",H),p.setError(H)}},xAccess:function(x,j,Q,H){p.popError();try{let se=K(j),_e=se?.jzClass||I.cstrToJs(j);if(z?.log?.xAccess)W("xAccess",_e,"flags =",Q,"*pResOut =",I.peek32(H),"store =",se);if(!se)try{A(_e)}catch(de){return I.poke32(H,0),0}if(se){let de=se.keyPrefix+(p.rxJournalSuffix.test(_e)?"jrnl":"1"),ue=se.storage.getItem(de)?0:1;I.poke32(H,ue)}else I.poke32(H,0);return 0}catch(se){return E("xAccess",se),p.setError(se)}},xRandomness:function(x,j,Q){let H=I.heap8u(),se=0,_e=Number(Q);for(;se<j;++se)H[_e+se]=Math.random()*255000&255;return j},xGetLastError:function(x,j,Q){let H=p.popError();if(W("xGetLastError",H),H){let se=I.scopedAllocPush();try{let[_e,de]=I.scopedAllocCString(H.message,!0);if(I.cstrncpy(Q,_e,j),de>j)I.poke8(I.ptr.add(Q,j,-1),0);return W("set xGetLastError",H.message),H.resultCode|0||t.SQLITE_IOERR}catch(_e){return t.SQLITE_NOMEM}finally{I.scopedAllocPop(se)}}return 0},xSleep:(x,j)=>0},ioDb:{xClose:function(x){p.popError();try{let j=V.get(x);if(z?.log?.xClose&&W("xClose",x,j),j){V.delete(x),m(j,t.SQLITE_LOCK_NONE);let Q=j.store;if(Q.files=Q.files.filter((H)=>H!==j.file),--Q.refc<=0&&Q.deleteAtRefc0)f(Q);y.ioDb.xClose(x),j.file.dispose(),Q.listeners&&ge("close",Q,Q.files.length)}return 0}catch(j){return E("xClose",j),p.setError(j)}},xFileControl:function(x,j,Q){p.popError();try{let H=V.get(x);if(h.assert(H,"Missing KVVfsFile handle"),z?.log?.xFileControl&&W("xFileControl",H,"op =",j),j===t.SQLITE_FCNTL_PRAGMA&&B.disablePageSizeChange){let _e=I.peekPtr(I.ptr.add(Q,I.ptr.size));if(I.cstrToJs(_e)==="page_size"){z?.log?.xFileControl&&W("xFileControl pragma",I.cstrToJs(_e));let de=I.peekPtr(I.ptr.add(Q,2*I.ptr.size));if(de)return z?.log?.xFileControl&&U("xFileControl pragma",H,"NOT setting page size to",I.cstrToJs(de)),H.file.$szPage=-1,0;else if(H.file.$szPage>0)return z?.log?.xFileControl&&U("xFileControl",H,"getting page size",H.file.$szPage),I.pokePtr(Q,I.allocCString(""+H.file.$szPage)),0}}let se=y.ioDb.xFileControl(x,j,Q);if(se==0&&t.SQLITE_FCNTL_SYNC===j)H.store.listeners&&ge("sync",H.store,!1);return se}catch(H){return E("xFileControl",H),p.setError(H)}},xSync:function(x,j){p.popError();try{let Q=V.get(x);z?.log?.xSync&&W("xSync",Q),h.assert(Q,"Missing KVVfsFile handle");let H=y.ioDb.xSync(x,j);if(H==0&&Q.store.listeners)ge("sync",Q.store,!0);return H}catch(Q){return E("xSync",Q),p.setError(Q)}},xLock:function(x,j){p.popError();try{let Q=V.get(x);if(t.SQLITE_LOCK_NONE!==j)y.ioDb.xLock(x,j);if(Q.lockType>=j)return 0;let H=Z.get(Q.jzClass);if(!H)H=Object.assign(Object.create(null),{nShared:0,lockType:t.SQLITE_LOCK_NONE}),Z.set(Q.jzClass,H);if(Q.lockType!==H.lockType&&(H.lockType>=t.SQLITE_LOCK_PENDING||j>t.SQLITE_LOCK_SHARED))return t.SQLITE_BUSY;if(j===t.SQLITE_LOCK_SHARED){if(++H.nShared,H.lockType===t.SQLITE_LOCK_NONE)H.lockType=j}else if(j===t.SQLITE_LOCK_EXCLUSIVE&&H.nShared>1){if(Q.lockType===t.SQLITE_LOCK_RESERVED)Q.lockType=H.lockType=t.SQLITE_LOCK_PENDING;return t.SQLITE_BUSY}else H.lockType=j;return Q.lockType=j,0}catch(Q){return E("xLock",Q),p.setError(Q)}},xUnlock:function(x,j){p.popError();try{if(t.SQLITE_LOCK_NONE===j)y.ioDb.xUnlock(x,j);let Q=V.get(x);return m(Q,j),0}catch(Q){return E("xUnlock",Q),p.setError(Q)}},xCheckReservedLock:function(x,j){p.popError();try{let Q=V.get(x),H=Z.get(Q.jzClass);return I.poke32(j,!!H&&H.lockType>t.SQLITE_LOCK_SHARED?1:0),0}catch(Q){return E("xCheckReservedLock",Q),p.setError(Q)}}},ioJrnl:{xClose:!0,xLock:!0,xUnlock:!0,xCheckReservedLock:!0}};try{h.assert(p.buffer.n>132096,"Heap buffer is not large enough");for(let x of Object.entries(ae.recordHandler)){let j=x[0],Q=x[1];G[j]=Q,M[M.memberKey(j)]=I.installFunction(M.memberSignature(j),Q)}for(let x of Object.entries(ae.vfs)){let j=x[0],Q=x[1],H=c.memberKey(j),se=c.structInfo.members[j]||h.toss("Missing pVfs.structInfo[",j,"]");y.vfs[j]=I.functionEntry(c[H]),c[H]=I.installFunction(se.signature,Q)}for(let x of Object.entries(ae.ioDb)){let j=x[0],Q=x[1],H=d.memberKey(j);y.ioDb[j]=I.functionEntry(d[H])||h.toss("Missing native pIoDb[",H,"]"),d[H]=I.installFunction(d.memberSignature(j),Q)}for(let x of Object.entries(ae.ioJrnl)){let j=x[0],Q=x[1],H=L.memberKey(j);if(y.ioJrnl[j]=I.functionEntry(L[H])||h.toss("Missing native pIoJrnl[",H,"]"),Q===!0)L[H]=d[H]||h.toss("Missing copied pIoDb[",H,"]");else L[H]=I.installFunction(L.memberSignature(j),Q)}}finally{M.dispose(),c.dispose(),d.dispose(),L.dispose()}let ce=function x(j){if(j==="")return x("local")+x("session");let Q=K(j);if(!Q)return 0;if(Q.files.length)if(globalThis.localStorage===Q.storage||globalThis.sessionStorage===Q.storage);else S(t.SQLITE_ACCESS,"Cannot clear in-use database storage.");let H=Q.storage,se=[],_e,de=H.length;for(_e=0;_e<de;++_e){let ue=H.key(_e);if(!Q.keyPrefix||ue.startsWith(Q.keyPrefix))se.push(ue)}return se.forEach((ue)=>H.removeItem(ue)),se.length},be=function x(j){if(j==="")return x("local")+x("session");let Q=K(j);if(!Q)return 0;let H=Q.storage,se,_e=0;for(se=0;se<H.length;++se){let de=H.key(se);if(!Q.keyPrefix||de.startsWith(Q.keyPrefix))_e+=de.length,_e+=H.getItem(de).length}return _e*2},ve=function(...j){let Q;if(j.length===1&&typeof j[0]==="object")Q=j[0];else if(j.length)Q=Object.assign(Object.create(null),{name:j[0]});let H=Q?K(Q.name):null;if(!H)S(t.SQLITE_NOTFOUND,"There is no kvvfs storage named",Q?.name);let se=H.storage,_e=Object.assign(Object.create(null),{name:H.jzClass,timestamp:Date.now(),pages:[]}),de=Object.create(null),ue,he=H.keyPrefix,Le=he?/^kvvfs-[^-]+-(\w+)/:void 0,De=0,Ae=se.length;for(;De<Ae;++De){let Ce=se.key(De);if(!he||Ce.startsWith(he)){let Me=(he?Le.exec(Ce):void 0)?.[1]??Ce;switch(Me){case"jrnl":if(Q.includeJournal)_e.journal=se.getItem(Ce);break;case"sz":_e.size=+se.getItem(Ce);break;default:if(Me=+Me,!h.isInt32(Me)||Me<=0)S(t.SQLITE_RANGE,"Malformed kvvfs key: "+Ce);if(Q.decodePages){let et=se.getItem(Ce),st=et.length,Je=p.memBuffer(0),bt=p.memBuffer(1),yt=I.heap8u(),_t=0;for(;_t<st;++_t)yt[I.ptr.add(Je,_t)]=et.codePointAt(_t)&255;yt[I.ptr.add(Je,_t)]=0;let Wt=le(Je,bt,p.buffer.n);de[Me]=yt.slice(Number(bt),I.ptr.addn(bt,Wt))}else de[Me]=se.getItem(Ce);break}}}if(Q.decodePages)p.memBufferFree(1);return Object.keys(de).map((Ce)=>+Ce).sort().forEach((Ce)=>_e.pages.push(de[Ce])),_e},Fe=function(x,j=!1){if(!x?.timestamp||!x.name||x.size===void 0||!Array.isArray(x.pages))S(t.SQLITE_MISUSE,"Malformed export object.");else if(!x.size||x.size!==(x.size|0)||x.size>=2147483647)S(t.SQLITE_RANGE,"Invalid db size: "+x.size);A(x.name);let Q=K(x.name),H=!Q;if(Q){if(!j)S(t.SQLITE_ACCESS,"Storage '"+x.name+"' already exists and","overwrite was not specified.");else if(!Q.files||!Q.jzClass)S(t.SQLITE_ERROR,"Internal storage object",x.name,"seems to be malformed.");else if(Q.files.length)S(t.SQLITE_IOERR_ACCESS,"Cannot import db storage while it is in use.");ce(x.name)}else Q=C(x.name);let se=T(x.name),_e;try{let de=Q.storage;if(de.setItem(se+"sz",x.size),x.journal)de.setItem(se+"jrnl",x.journal);if(x.pages[0]instanceof Uint8Array)x.pages.forEach((ue,he)=>{let Le=ue.length;_e??=p.memBuffer(1);let De=p.memBuffer(0),Ae=I.heap8u();Ae.set(ue,Number(De)),Ae[I.ptr.addn(De,Le)]=0;let Ce=we(De,Le,_e);h.assert(Ce<p.buffer.n,"Impossibly long output - possibly smashed the heap"),h.assert(I.peek8(I.ptr.add(_e,Ce))===0,"Expecting NUL-terminated encoded output");let Me=I.cstrToJs(_e);de.setItem(se+(he+1),Me)});else if(x.pages[0])x.pages.forEach((ue,he)=>de.setItem(se+(he+1),ue));if(H)w(Q)}catch{if(!H)try{ce(x.name)}catch(de){}}finally{if(_e)p.memBufferFree(1)}return this},Pe=function(x){let j=K(x);if(j){++j.refc;return}A(x),w(C(x))},Ee=function(x){let j=K(x);if(!j||F(j.jzClass)||J(j.jzClass)||p.rxJournalSuffix.test(x))return!1;if(j.refc>j.files.length||j.files.length===0){if(--j.refc<=0)f(j);return!0}return!1},Qe=function(x){if(!x||typeof x!=="object")S(t.SQLITE_MISUSE,"Expecting a listener object.");let j=K(x.storage);if(!j)if(x.storage&&x.reserve)Pe(x.storage),j=K(x.storage),h.assert(j,"Unexpectedly cannot fetch reserved storage "+x.storage);else S(t.SQLITE_NOTFOUND,"No such storage:",x.storage);if(x.events)(j.listeners??=[]).push(x)},He=function(x){let j=K(x?.storage);if(j?.listeners&&x.events){let Q=j.listeners.length;j.listeners=j.listeners.filter((se)=>se!==x);let H=Q>j.listeners.length;if(!j.listeners.length)j.listeners=void 0;return H}return!1};if(i.kvvfs.reserve=Pe,i.kvvfs.import=Fe,i.kvvfs.export=ve,i.kvvfs.unlink=Ee,i.kvvfs.listen=Qe,i.kvvfs.unlisten=He,i.kvvfs.exists=(x)=>!!K(x),i.kvvfs.estimateSize=be,i.kvvfs.clear=ce,globalThis.Storage)t.sqlite3_js_kvvfs_size=(x="")=>be(x),t.sqlite3_js_kvvfs_clear=(x="")=>ce(x);if(i.oo1?.DB){let x=i.oo1.DB;i.oo1.JsStorageDb=function(Q=i.oo1.JsStorageDb.defaultStorageName){let H=x.dbCtorHelper.normalizeArgs(...arguments);switch(H.vfs="kvvfs",H.filename){case":sessionStorage:":H.filename="session";break;case":localStorage:":H.filename="local";break}let se=/(file:(\/\/)?)([^?]+)/.exec(H.filename);A(se?se[3]:H.filename),x.dbCtorHelper.call(this,H)},i.oo1.JsStorageDb.defaultStorageName=p.storagePool.session?"session":N;let j=i.oo1.JsStorageDb;j.prototype=Object.create(x.prototype),j.clearStorage=ce,j.prototype.clearStorage=function(){return j.clearStorage(this.affirmOpen().dbFilename(),!0)},j.storageSize=be,j.prototype.storageSize=function(){return j.storageSize(this.affirmOpen().dbFilename(),!0)}}if(i.__isUnderTest&&i.vtab){let x=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(x).forEach((de,ue)=>x[de].colId=ue);let j=i.vtab,Q=Object.assign(Object.create(null),{row:function(){return p.storagePool[this.names[this.rowid]]}});Object.assign(Object.create(Q),{rowid:0,names:Object.keys(p.storagePool).filter((de)=>!p.rxJournalSuffix.test(de))});let H=function(de,ue){let he=de instanceof t.sqlite3_vtab_cursor?de:j.xCursor.get(de);if(ue||!he.vTabState)he.vTabState=Object.assign(Object.create(Q),{rowid:0,names:Object.keys(p.storagePool).filter((Le)=>!p.rxJournalSuffix.test(Le))});return he.vTabState},se=()=>{},_e=function de(){return de.mod??=new i.capi.sqlite3_module().setupModule({catchExceptions:!0,methods:{xConnect:function(ue,he,Le,De,Ae,Ce){se("xConnect");try{let Me=[];Object.keys(x).forEach((st)=>{Me.push(st+" "+x[st].type)});let et=t.sqlite3_declare_vtab(ue,"CREATE TABLE ignored("+Me.join(",")+")");if(et===0){let st=j.xVtab.create(Ae);h.assert(st===j.xVtab.get(I.peekPtr(Ae)),"output pointer check failed")}return et}catch(Me){return j.xError("xConnect",Me,t.SQLITE_ERROR)}},xCreate:I.ptr.null,xDisconnect:function(ue){return se("xDisconnect",...arguments),j.xVtab.dispose(ue),0},xOpen:function(ue,he){return se("xOpen",...arguments),j.xCursor.create(he),0},xClose:function(ue){se("xClose",...arguments);let he=j.xCursor.unget(ue);return delete he.vTabState,he.dispose(),0},xNext:function(ue){se("xNext",...arguments);let he=j.xCursor.get(ue);return++H(he).rowid,0},xColumn:function(ue,he,Le){se("xColumn",...arguments);let De=H(ue),Ae=De.row();switch(h.assert(Ae,"Unexpected xColumn call"),Le){case x.rowid.colId:t.sqlite3_result_int(he,De.rowid);break;case x.name.colId:t.sqlite3_result_text(he,Ae.jzClass,-1,t.SQLITE_TRANSIENT);break;case x.nRef.colId:t.sqlite3_result_int(he,Ae.refc);break;case x.nOpen.colId:t.sqlite3_result_int(he,Ae.files.length);break;case x.isTransient.colId:t.sqlite3_result_int(he,!!Ae.deleteAtRefc0);break;case x.dbSize.colId:t.sqlite3_result_int(he,O(Ae));break;default:return t.sqlite3_result_error(he,"Invalid column id: "+Le),t.SQLITE_RANGE}return 0},xRowid:function(ue,he){se("xRowid",...arguments);let Le=H(ue);return j.xRowid(he,Le.rowid),0},xEof:function(ue){let he=H(ue);return se("xEof?="+!he.row(),...arguments),!he.row()},xFilter:function(ue,he,Le,De,Ae){se("xFilter",...arguments);let Ce=H(ue,!0);return 0},xBestIndex:function(ue,he){se("xBestIndex",...arguments);let Le=new t.sqlite3_index_info(he);return Le.$estimatedRows=p.storagePool.size,Le.$estimatedCost=1,Le.dispose(),0}}})};i.kvvfs.create_module=function(de,ue="sqlite_kvvfs"){return t.sqlite3_create_module(de,ue,_e(),I.ptr.null)}}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.opfs&&i.config.disable.vfs["opfs-vfs"])return;let t=i.util.toss,{capi:r,util:a,wasm:_}=i,h=i.opfs=Object.create(null);h.thisThreadHasOPFS=()=>globalThis.FileSystemHandle&&globalThis.FileSystemDirectoryHandle&&globalThis.FileSystemFileHandle&&globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle&&navigator?.storage?.getDirectory,h.getRootDir=async function S(){return S.promise??=navigator.storage.getDirectory().then((R)=>(h.rootDirectory=R,R)).catch((R)=>{throw delete S.promise,R})},h.getResolvedPath=function(S,R){let M=new URL(S,"file://irrelevant").pathname;return R?M.split("/").filter((p)=>!!p):M},h.getDirForFilename=async function(R,M=!1){let p=h.getResolvedPath(R,!0),ne=p.pop(),W=await h.getRootDir();for(let U of p)if(U)W=await W.getDirectoryHandle(U,{create:!!M});return[W,ne]},h.mkdir=async function(S){try{return await h.getDirForFilename(S+"/filepart",!0),!0}catch(R){return!1}},h.entryExists=async function(S){try{let[R,M]=await h.getDirForFilename(S);return await R.getFileHandle(M),!0}catch(R){return!1}},h.randomFilename=function S(R=16){if(!S._chars)S._chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012346789",S._n=S._chars.length;let M=[],p=0;for(;p<R;++p){let ne=Math.random()*(S._n*64)%S._n|0;M[p]=S._chars[ne]}return M.join("")},h.treeList=async function(){let S=async function p(ne,W){W.name=ne.name,W.dirs=[],W.files=[];for await(let U of ne.values())if(U.kind==="directory"){let E=Object.create(null);W.dirs.push(E),await p(U,E)}else W.files.push(U.name)},R=Object.create(null),M=await h.getRootDir();return await S(M,R),R},h.rmfr=async function(){let R=await h.getRootDir(),M={recurse:!0};for await(let p of R.values())R.removeEntry(p.name,M)},h.unlink=async function(S,R=!1,M=!1){try{let[p,ne]=await h.getDirForFilename(S,!1);return await p.removeEntry(ne,{recursive:R}),!0}catch(p){if(M)throw Error("unlink(",arguments[0],") failed: "+p.message,{cause:p});return!1}},h.traverse=async function(S){let R={recursive:!0,directory:await h.getRootDir()};if(typeof S==="function")S={callback:S};S=Object.assign(R,S||{}),async function p(ne,W){for await(let U of ne.values())if(S.callback(U,ne,W)===!1)return!1;else if(S.recursive&&U.kind==="directory"){if(await p(U,W+1)===!1)break}}(S.directory,0)};let I=async function(S,R){let[M,p]=await h.getDirForFilename(S,!0),W=await(await M.getFileHandle(p,{create:!0})).createSyncAccessHandle(),U=0,E,b=!1,F=!1;try{W.truncate(0);while((E=await R())!==void 0){if(E instanceof ArrayBuffer)E=new Uint8Array(E);if(!b&&U===0&&E.byteLength>=15)a.affirmDbHeader(E),b=!0;W.write(E,{at:U}),U+=E.byteLength}if(U<512||U%512!==0)t("Input size",U,"is not correct for an SQLite database.");if(!b){let T=new Uint8Array(20);W.read(T,{at:0}),a.affirmDbHeader(T)}return W.write(new Uint8Array([1,1]),{at:18}),U}catch(T){throw await W.close(),W=void 0,await M.removeEntry(p).catch(()=>{}),T}finally{if(W)await W.close()}};h.importDb=async function(S,R){if(R instanceof Function)return I(S,R);if(R instanceof ArrayBuffer)R=new Uint8Array(R);a.affirmIsDb(R);let M=R.byteLength,[p,ne]=await h.getDirForFilename(S,!0),W,U,E=0;try{if(W=await(await p.getFileHandle(ne,{create:!0})).createSyncAccessHandle(),W.truncate(0),E=W.write(R,{at:0}),E!=M)t("Expected to write "+M+" bytes but wrote "+E+".");return W.write(new Uint8Array([1,1]),{at:18}),E}catch(b){if(W)await W.close(),W=void 0;throw await p.removeEntry(ne).catch(()=>{}),b}finally{if(W)await W.close()}},h.vfsInstallationFeatureCheck=function(S){if(!globalThis.SharedArrayBuffer||!globalThis.Atomics)t("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");else if(typeof WorkerGlobalScope>"u")t("The OPFS sqlite3_vfs cannot run in the main thread","because it requires Atomics.wait().");else if(!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle?.prototype?.createSyncAccessHandle||!navigator?.storage?.getDirectory)t("Missing required OPFS APIs.");else if(S==="opfs-wl"&&!globalThis.Atomics.waitAsync)t("The",S,"VFS requires Atomics.waitAsync(), which is not available.")},h.initOptions=function(R,M){let p=new URL(globalThis.location.href).searchParams;if(p.has(R+"-disable"))return;try{h.vfsInstallationFeatureCheck(R)}catch(ne){return}if(M=a.nu(M),M.vfsName=R,M.verbose??=p.has("opfs-verbose")?+p.get("opfs-verbose"):1,M.sanityChecks??=p.has("opfs-sanity-check"),!h.proxyUri){if(h.proxyUri="sqlite3-opfs-async-proxy.js",i.scriptInfo?.sqlite3Dir)h.proxyUri=i.scriptInfo.sqlite3Dir+h.proxyUri}if(M.proxyUri??=h.proxyUri,typeof M.proxyUri==="function")M.proxyUri=M.proxyUri();return h.options=M},h.createVfsState=function(){let S=a.nu(),R=h.options;S.verbose=R.verbose;let M=[i.config.error,i.config.warn,i.config.log],p=R.vfsName||t("Maintenance required: missing VFS name"),ne=(K,...oe)=>{if(S.verbose>K)M[K](p+":",...oe)},W=(...K)=>ne(2,...K),U=(...K)=>ne(1,...K),E=(...K)=>ne(0,...K),{capi:b,wasm:F}=i,T=S.vfs=new b.sqlite3_vfs,A=T.ioMethods=new b.sqlite3_io_methods;A.$iVersion=1,T.$iVersion=2,T.$szOsFile=b.sqlite3_file.structInfo.sizeof,T.$mxPathname=1024,T.$zName=F.allocCString(p),T.addOnDispose("$zName",T.$zName,A),T.metrics=a.nu({counters:a.nu(),dump:function(){let K,oe=0,u=0,q=0;for(K in S.opIds){let O=C[K];oe+=O.count,u+=O.time,q+=O.wait,O.avgTime=O.count&&O.time?O.time/O.count:0,O.avgWait=O.count&&O.wait?O.wait/O.count:0}i.config.log(globalThis.location.href,"metrics for",globalThis.location.href,":",C,`
3
+ Total of`,oe,"op(s) for",u,"ms (incl. "+q+" ms of waiting on the async side)"),i.config.log("Serialization metrics:",T.metrics.counters.s11n),T.worker?.postMessage?.({type:"opfs-async-metrics"})},reset:function(){let K,oe=(O)=>O.count=O.time=O.wait=0,u=T.metrics.counters;for(K in S.opIds)oe(u[K]=Object.create(null));let q=u.s11n=Object.create(null);q=q.serialize=Object.create(null),q.count=q.time=0,q=u.s11n.deserialize=Object.create(null),q.count=q.time=0}}),S.asyncIdleWaitTime=150,S.asyncS11nExceptions=1,S.fileBufferSize=65536,S.sabS11nOffset=S.fileBufferSize,S.sabS11nSize=T.$mxPathname*2,S.sabIO=new SharedArrayBuffer(S.fileBufferSize+S.sabS11nSize),S.opIds=Object.create(null);{let K=0;S.opIds.whichOp=K++,S.opIds.rc=K++,S.opIds.xAccess=K++,S.opIds.xClose=K++,S.opIds.xDelete=K++,S.opIds.xDeleteNoWait=K++,S.opIds.xFileSize=K++,S.opIds.xLock=K++,S.opIds.xOpen=K++,S.opIds.xRead=K++,S.opIds.xSleep=K++,S.opIds.xSync=K++,S.opIds.xTruncate=K++,S.opIds.xUnlock=K++,S.opIds.xWrite=K++,S.opIds.mkdir=K++,S.opIds["opfs-async-metrics"]=K++,S.opIds["opfs-async-shutdown"]=K++,S.opIds.retry=K++,S.sabOP=new SharedArrayBuffer(K*4)}S.sq3Codes=Object.create(null);for(let K 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"])S.sq3Codes[K]=b[K]??t("Maintenance required: not found:",K);S.opfsFlags=Object.assign(Object.create(null),{OPFS_UNLOCK_ASAP:1,OPFS_UNLINK_BEFORE_OPEN:2,defaultUnlockAsap:!1}),T.metrics.reset();let C=T.metrics.counters,z=T.opRun=(K,...oe)=>{let u=S.opIds[K]||t(T.vfsName+": Invalid op ID:",K);S.s11n.serialize(...oe),Atomics.store(S.sabOPView,S.opIds.rc,-1),Atomics.store(S.sabOPView,S.opIds.whichOp,u),Atomics.notify(S.sabOPView,S.opIds.whichOp);let q=performance.now();while(Atomics.wait(S.sabOPView,S.opIds.rc,-1)!=="not-equal");let O=Atomics.load(S.sabOPView,S.opIds.rc);if(C[K].wait+=performance.now()-q,O&&S.asyncS11nExceptions){let V=S.s11n.deserialize();if(V)E(K+"() async error:",...V)}return O},f=Object.create(null);f.op=void 0,f.start=void 0;let w=T.mTimeStart=(K)=>{f.start=performance.now(),f.op=K,++C[K].count},N=T.mTimeEnd=()=>C[f.op].time+=performance.now()-f.start,J=T.__openFiles=Object.create(null),ie=T.ioSyncWrappers=a.nu({xCheckReservedLock:function(K,oe){return F.poke(oe,0,"i32"),0},xClose:function(K){w("xClose");let oe=0,u=J[K];if(u){if(delete J[K],oe=z("xClose",K),u.sq3File)u.sq3File.dispose()}return N(),oe},xDeviceCharacteristics:function(K){return b.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(K,oe,u){return b.SQLITE_NOTFOUND},xFileSize:function(K,oe){w("xFileSize");let u=z("xFileSize",K);if(u==0)try{let q=S.s11n.deserialize()[0];F.poke(oe,q,"i64")}catch(q){E("Unexpected error reading xFileSize() result:",q),u=S.sq3Codes.SQLITE_IOERR}return N(),u},xRead:function(K,oe,u,q){w("xRead");let O=J[K],V;try{if(V=z("xRead",K,u,Number(q)),V===0||b.SQLITE_IOERR_SHORT_READ===V)F.heap8u().set(O.sabView.subarray(0,u),Number(oe))}catch(Z){E("xRead(",arguments,") failed:",Z,O),V=b.SQLITE_IOERR_READ}return N(),V},xSync:function(K,oe){w("xSync");let u=z("xSync",K,oe);return N(),u},xTruncate:function(K,oe){w("xTruncate");let u=z("xTruncate",K,Number(oe));return N(),u},xWrite:function(K,oe,u,q){w("xWrite");let O=J[K],V;try{O.sabView.set(F.heap8u().subarray(Number(oe),Number(oe)+u)),V=z("xWrite",K,u,Number(q))}catch(Z){E("xWrite(",arguments,") failed:",Z,O),V=b.SQLITE_IOERR_WRITE}return N(),V}}),le=T.vfsSyncWrappers={xAccess:function(K,oe,u,q){w("xAccess");let O=z("xAccess",F.cstrToJs(oe));return F.poke(q,O?0:1,"i32"),N(),0},xCurrentTime:function(K,oe){return F.poke(oe,2440587.5+new Date().getTime()/86400000,"double"),0},xCurrentTimeInt64:function(K,oe){return F.poke(oe,210866760000000+new Date().getTime(),"i64"),0},xDelete:function(K,oe,u){w("xDelete");let q=z("xDelete",F.cstrToJs(oe),u,!1);return N(),q},xFullPathname:function(K,oe,u,q){return F.cstrncpy(q,oe,u)<u?0:b.SQLITE_CANTOPEN},xGetLastError:function(K,oe,u){return i.config.warn("OPFS xGetLastError() has nothing sensible to return."),0},xOpen:function(oe,u,q,O,V){w("xOpen");let Z=0,m,y;if(!u)m=h.randomFilename(),u=y=F.allocCString(m);else if(F.isPtr(u)){if(b.sqlite3_uri_boolean(u,"opfs-unlock-asap",0))Z|=S.opfsFlags.OPFS_UNLOCK_ASAP;if(b.sqlite3_uri_boolean(u,"delete-before-open",0))Z|=S.opfsFlags.OPFS_UNLINK_BEFORE_OPEN;m=F.cstrToJs(u)}else return i.config.error("Impossible zName value in xOpen?",u),b.SQLITE_CANTOPEN;let D=a.nu({fid:q,filename:m,sab:new SharedArrayBuffer(S.fileBufferSize),flags:O,readOnly:!(b.SQLITE_OPEN_CREATE&O)&&!!(O&b.SQLITE_OPEN_READONLY)}),c=z("xOpen",q,m,O,Z);if(c){if(y)F.dealloc(y)}else{if(D.readOnly)F.poke(V,b.SQLITE_OPEN_READONLY,"i32");if(J[q]=D,D.sabView=S.sabFileBufView,D.sq3File=new b.sqlite3_file(q),y)D.sq3File.addOnDispose(y);D.sq3File.$pMethods=A.pointer,D.lockType=b.SQLITE_LOCK_NONE}return N(),c}},we=b.sqlite3_vfs_find(null);if(we){let K=new b.sqlite3_vfs(we);T.$xRandomness=K.$xRandomness,T.$xSleep=K.$xSleep,K.dispose()}if(!T.$xRandomness)T.vfsSyncWrappers.xRandomness=function(K,oe,u){let q=F.heap8u(),O=0,V=Number(u);for(;O<oe;++O)q[V+O]=Math.random()*255000&255;return O};if(!T.$xSleep)T.vfsSyncWrappers.xSleep=function(K,oe){return w("xSleep"),Atomics.wait(S.sabOPView,S.opIds.xSleep,0,oe),N(),0};let ge=function(){if(S.s11n)return S.s11n;let K=new TextDecoder,oe=new TextEncoder("utf-8"),u=new Uint8Array(S.sabIO,S.sabS11nOffset,S.sabS11nSize),q=new DataView(S.sabIO,S.sabS11nOffset,S.sabS11nSize);S.s11n=Object.create(null);let O=Object.create(null);O.number={id:1,size:8,getter:"getFloat64",setter:"setFloat64"},O.bigint={id:2,size:8,getter:"getBigInt64",setter:"setBigInt64"},O.boolean={id:3,size:4,getter:"getInt32",setter:"setInt32"},O.string={id:4};let V=(m)=>O[typeof m]||t("Maintenance required: this value type cannot be serialized.",m),Z=(m)=>{switch(m){case O.number.id:return O.number;case O.bigint.id:return O.bigint;case O.boolean.id:return O.boolean;case O.string.id:return O.string;default:t("Invalid type ID:",m)}};return S.s11n.deserialize=function(m=!1){let y=performance.now(),D=u[0],c=D?[]:null;if(D){let d=[],L=1,G,B,ae;for(G=0;G<D;++G,++L)d.push(Z(u[L]));for(G=0;G<D;++G){let ce=d[G];if(ce.getter)ae=q[ce.getter](L,S.littleEndian),L+=ce.size;else B=q.getInt32(L,S.littleEndian),L+=4,ae=K.decode(u.slice(L,L+B)),L+=B;c.push(ae)}}if(m)u[0]=0;return c},S.s11n.serialize=function(...m){let y=performance.now();if(m.length){let D=[],c=0,d=1;u[0]=m.length&255;for(;c<m.length;++c,++d)D.push(V(m[c])),u[d]=D[c].id;for(c=0;c<m.length;++c){let L=D[c];if(L.setter)q[L.setter](d,m[c],S.littleEndian),d+=L.size;else{let G=oe.encode(m[c]);q.setInt32(d,G.byteLength,S.littleEndian),d+=4,u.set(G,d),d+=G.byteLength}}}else u[0]=0},S.s11n};return T.initS11n=ge,T.bindVfs=function(K,oe){return Object.assign(T.ioSyncWrappers,K),new Promise(function(q,O){let V=void 0,Z=(B)=>(V=!0,T.dispose(),O(B)),m=()=>{try{oe(i,T)}catch(B){return Z(B)}return V=!1,q(i)},y=h.options,D=y.proxyUri+(y.proxyUri.indexOf("?")<0?"?":"&")+"vfs="+p,c=T.worker=new Worker(new URL(D,import.meta.url)),d=setTimeout(()=>{if(V===void 0)Z(Error("Timeout while waiting for OPFS async proxy worker."))},4000);c._originalOnError=c.onerror,c.onerror=function(B){E("Error initializing OPFS asyncer:",B),Z(Error("Loading OPFS async Worker failed for unknown reasons."))};let L=T.opRun,G=function(){let B=F.scopedAllocPush(),ae=new b.sqlite3_file;try{let ce=ae.pointer,be=b.SQLITE_OPEN_CREATE|b.SQLITE_OPEN_READWRITE|b.SQLITE_OPEN_MAIN_DB,ve=F.scopedAlloc(8),Fe="/sanity/check/file"+h.randomFilename(8),Pe=F.scopedAllocCString(Fe),Ee;if(S.s11n.serialize("This is ä string."),Ee=S.s11n.deserialize(),W("deserialize() says:",Ee),Ee[0]!=="This is ä string.")t("String d13n error.");if(T.vfsSyncWrappers.xAccess(T.pointer,Pe,0,ve),Ee=F.peek(ve,"i32"),W("xAccess(",Fe,") exists ?=",Ee),Ee=T.vfsSyncWrappers.xOpen(T.pointer,Pe,ce,be,ve),W("open rc =",Ee,"state.sabOPView[xOpen] =",S.sabOPView[S.opIds.xOpen]),Ee!==0){E("open failed with code",Ee);return}if(T.vfsSyncWrappers.xAccess(T.pointer,Pe,0,ve),Ee=F.peek(ve,"i32"),!Ee)t("xAccess() failed to detect file.");if(Ee=T.ioSyncWrappers.xSync(ae.pointer,0),Ee)t("sync failed w/ rc",Ee);if(Ee=T.ioSyncWrappers.xTruncate(ae.pointer,1024),Ee)t("truncate failed w/ rc",Ee);if(F.poke(ve,0,"i64"),Ee=T.ioSyncWrappers.xFileSize(ae.pointer,ve),Ee)t("xFileSize failed w/ rc",Ee);if(W("xFileSize says:",F.peek(ve,"i64")),Ee=T.ioSyncWrappers.xWrite(ae.pointer,Pe,10,1),Ee)t("xWrite() failed!");let Qe=F.scopedAlloc(16);Ee=T.ioSyncWrappers.xRead(ae.pointer,Qe,6,2),F.poke(Qe+6,0);let He=F.cstrToJs(Qe);if(W("xRead() got:",He),He!=="sanity")t("Unexpected xRead() value.");if(T.vfsSyncWrappers.xSleep)W("xSleep()ing before close()ing..."),T.vfsSyncWrappers.xSleep(T.pointer,2000),W("waking up from xSleep()");if(Ee=T.ioSyncWrappers.xClose(ce),W("xClose rc =",Ee,"sabOPView =",S.sabOPView),W("Deleting file:",Fe),T.vfsSyncWrappers.xDelete(T.pointer,Pe,4660),T.vfsSyncWrappers.xAccess(T.pointer,Pe,0,ve),Ee=F.peek(ve,"i32"),Ee)t("Expecting 0 from xAccess(",Fe,") after xDelete().");U("End of OPFS sanity checks.")}finally{ae.dispose(),F.scopedAllocPop(B)}};c.onmessage=function({data:B}){switch(B.type){case"opfs-unavailable":Z(Error(B.payload.join(" ")));break;case"opfs-async-loaded":delete S.vfs,c.postMessage({type:"opfs-async-init",args:a.nu(S)});break;case"opfs-async-inited":{if(V===!0)break;clearTimeout(d),d=null;try{if(i.vfs.installVfs({io:{struct:T.ioMethods,methods:T.ioSyncWrappers},vfs:{struct:T,methods:T.vfsSyncWrappers}}),S.sabOPView=new Int32Array(S.sabOP),S.sabFileBufView=new Uint8Array(S.sabIO,0,S.fileBufferSize),S.sabS11nView=new Uint8Array(S.sabIO,S.sabS11nOffset,S.sabS11nSize),T.initS11n(),T.initS11n=null,y.sanityChecks)U("Running sanity checks because of opfs-sanity-check URL arg..."),G();if(h.thisThreadHasOPFS())h.getRootDir().then((ae)=>{c.onerror=c._originalOnError,delete c._originalOnError,W("End of OPFS sqlite3_vfs setup.",T),m()}).catch(Z);else m()}catch(ae){E(ae),Z(ae)}break}case"debug":U("debug message from worker:",B);break;default:{let ae="Unexpected message from the OPFS async worker: "+JSON.stringify(B);E(ae),Z(Error(ae));break}}}})},S}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.opfs||i.config.disable?.vfs?.opfs)return;let t=i.util,r=i.opfs||i.util.toss("Missing sqlite3.opfs"),a=async function(_){if(_=r.initOptions("opfs",_),!_)return i;let h=i.capi,I=r.createVfsState(),S=I.vfs,R=S.metrics.counters,{mTimeStart:M,mTimeEnd:p,opRun:ne}=S,W=(...b)=>i.config.debug("opfs:",...b),U=(...b)=>i.config.warn("opfs:",...b),E=S.__openFiles;return S.bindVfs(t.nu({xLock:function(b,F){M("xLock"),++R.xLock.count;let T=E[b],A=0;if(T.lockType)T.lockType=F;else if(A=ne("xLock",b,F),A===0)T.lockType=F;return p(),A},xUnlock:function(b,F){M("xUnlock"),++R.xUnlock.count;let T=E[b],A=0;if(h.SQLITE_LOCK_NONE===F&&T.lockType)A=ne("xUnlock",b,F);if(A===0)T.lockType=F;return p(),A}}),function(b,F){if(b.oo1){let T=function(...A){let C=b.oo1.DB.dbCtorHelper.normalizeArgs(...A);C.vfs=F.$zName,b.oo1.DB.dbCtorHelper.call(this,C)};T.prototype=Object.create(b.oo1.DB.prototype),b.oo1.OpfsDb=T,T.importDb=r.importDb,b.oo1.DB.dbCtorHelper.setVfsPostOpenCallback(S.pointer,function(A,C){C.capi.sqlite3_busy_timeout(A,1e4)})}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async(_)=>a().catch((h)=>{_.config.warn("Ignoring inability to install 'opfs' sqlite3_vfs:",h)}))}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(i.config.disable?.vfs?.["opfs-sahpool"])return;let t=i.util.toss,r=i.util.toss3,a=Object.create(null),{capi:_,util:h,wasm:I}=i,S=4096,R=512,M=4,p=8,ne=R+M,W=R,U=ne,E=S,b=_.SQLITE_OPEN_MAIN_DB|_.SQLITE_OPEN_MAIN_JOURNAL|_.SQLITE_OPEN_SUPER_JOURNAL|_.SQLITE_OPEN_WAL,F=_.SQLITE_OPEN_MEMORY,T=".opaque",A=()=>Math.random().toString(36).slice(2),C=new TextDecoder,z=new TextEncoder,f=Object.assign(Object.create(null),{name:"opfs-sahpool",directory:void 0,initialCapacity:6,clearOnInit:!1,verbosity:2,forceReinitIfPreviouslyFailed:!1,preserveOnInitFailure:!1}),w=[i.config.error,i.config.warn,i.config.log],N=i.config.log,J=i.config.warn,ie=i.config.error,le=new Map,we=(c)=>le.get(c),ge=(c,d)=>{if(d)le.set(c,d);else le.delete(c)},K=new Map,oe=(c)=>K.get(c),u=(c,d)=>{if(d)K.set(c,d);else K.delete(c)},q={xCheckReservedLock:function(c,d){let L=oe(c);L.log("xCheckReservedLock"),L.storeErr();let G=L.getOFileForS3File(c);return I.poke32(d,L.hasReservedLock(G.path)?1:0),0},xClose:function(c){let d=oe(c);d.storeErr();let L=d.getOFileForS3File(c);if(L)try{if(d.log(`xClose ${L.path}`),d.unlockFile(L,_.SQLITE_LOCK_NONE),d.mapS3FileToOFile(c,!1),L.sah.flush(),L.flags&_.SQLITE_OPEN_DELETEONCLOSE)d.deletePath(L.path)}catch(G){return d.storeErr(G,_.SQLITE_IOERR)}return 0},xDeviceCharacteristics:function(c){return _.SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN},xFileControl:function(c,d,L){return _.SQLITE_NOTFOUND},xFileSize:function(c,d){let L=oe(c);L.log("xFileSize");let B=L.getOFileForS3File(c).sah.getSize()-E;return I.poke64(d,BigInt(B)),0},xLock:function(c,d){let L=oe(c);L.log(`xLock ${d}`),L.storeErr();let G=L.getOFileForS3File(c);return L.lockFile(G,d)},xRead:function(c,d,L,G){let B=oe(c);B.storeErr();let ae=B.getOFileForS3File(c);B.log(`xRead ${ae.path} ${L} @ ${G}`);try{let ce=ae.sah.read(I.heap8u().subarray(Number(d),Number(d)+L),{at:E+Number(G)});if(ce<L)return I.heap8u().fill(0,Number(d)+ce,Number(d)+L),_.SQLITE_IOERR_SHORT_READ;return 0}catch(ce){return B.storeErr(ce,_.SQLITE_IOERR)}},xSectorSize:function(c){return S},xSync:function(c,d){let L=oe(c);L.log(`xSync ${d}`),L.storeErr();let G=L.getOFileForS3File(c);try{return G.sah.flush(),0}catch(B){return L.storeErr(B,_.SQLITE_IOERR)}},xTruncate:function(c,d){let L=oe(c);L.log(`xTruncate ${d}`),L.storeErr();let G=L.getOFileForS3File(c);try{return G.sah.truncate(E+Number(d)),0}catch(B){return L.storeErr(B,_.SQLITE_IOERR)}},xUnlock:function(c,d){let L=oe(c);L.log("xUnlock");let G=L.getOFileForS3File(c);return L.unlockFile(G,d),0},xWrite:function(c,d,L,G){let B=oe(c);B.storeErr();let ae=B.getOFileForS3File(c);B.log(`xWrite ${ae.path} ${L} ${G}`);try{let ce=ae.sah.write(I.heap8u().subarray(Number(d),Number(d)+L),{at:E+Number(G)});return L===ce?0:t("Unknown write() failure.")}catch(ce){return B.storeErr(ce,_.SQLITE_IOERR)}}},O=new _.sqlite3_io_methods;O.$iVersion=1,i.vfs.installVfs({io:{struct:O,methods:q}});let V={xAccess:function(c,d,L,G){let B=we(c);B.storeErr();try{let ae=B.getPath(d);I.poke32(G,B.hasFilename(ae)?1:0)}catch(ae){I.poke32(G,0)}return 0},xCurrentTime:function(c,d){return I.poke(d,2440587.5+new Date().getTime()/86400000,"double"),0},xCurrentTimeInt64:function(c,d){return I.poke(d,210866760000000+new Date().getTime(),"i64"),0},xDelete:function(c,d,L){let G=we(c);G.log(`xDelete ${I.cstrToJs(d)}`),G.storeErr();try{return G.deletePath(G.getPath(d)),0}catch(B){return G.storeErr(B),_.SQLITE_IOERR_DELETE}},xFullPathname:function(c,d,L,G){return I.cstrncpy(G,d,L)<L?0:_.SQLITE_CANTOPEN},xGetLastError:function(c,d,L){let G=we(c),B=G.popErr();if(G.log(`xGetLastError ${d} e =`,B),B){let ae=I.scopedAllocPush();try{let[ce,be]=I.scopedAllocCString(B.message,!0);if(I.cstrncpy(L,ce,d),be>d)I.poke8(I.ptr.add(L,d,-1),0)}catch(ce){return _.SQLITE_NOMEM}finally{I.scopedAllocPop(ae)}}return B?B.sqlite3Rc||_.SQLITE_IOERR:0},xOpen:function(d,L,G,B,ae){let ce=we(d);try{B&=~F,ce.log(`xOpen ${I.cstrToJs(L)} ${B}`);let be=L&&I.peek8(L)?ce.getPath(L):A(),ve=ce.getSAHForPath(be);if(ve&&B&_.SQLITE_OPEN_CREATE&&B&_.SQLITE_OPEN_EXCLUSIVE)t("file already exists:",be);if(!ve&&B&_.SQLITE_OPEN_CREATE)if(ce.getFileCount()<ce.getCapacity())ve=ce.nextAvailableSAH(),ce.setAssociatedPath(ve,be,B);else t("SAH pool is full. Cannot create file",be);if(!ve)t("file not found:",be);let Fe={path:be,flags:B,sah:ve};ce.mapS3FileToOFile(G,Fe),Fe.lockType=_.SQLITE_LOCK_NONE;let Pe=new _.sqlite3_file(G);return Pe.$pMethods=O.pointer,Pe.dispose(),I.poke32(ae,B),0}catch(be){return ce.storeErr(be),_.SQLITE_CANTOPEN}}},Z=function(c){if(i.capi.sqlite3_vfs_find(c))r("VFS name is already registered:",c);let d=new _.sqlite3_vfs,L=_.sqlite3_vfs_find(null),G=L?new _.sqlite3_vfs(L):null;if(d.$iVersion=2,d.$szOsFile=_.sqlite3_file.structInfo.sizeof,d.$mxPathname=R,d.addOnDispose(d.$zName=I.allocCString(c),()=>ge(d.pointer,0)),G)d.$xRandomness=G.$xRandomness,G.dispose();if(!d.$xRandomness&&!V.xRandomness)V.xRandomness=function(B,ae,ce){let be=I.heap8u(),ve=0,Fe=Number(ce);for(;ve<ae;++ve)be[Fe+ve]=Math.random()*255000&255;return ve};return V.xSleep=(B,ae)=>0,i.vfs.installVfs({vfs:{struct:d,methods:V}}),d};class m{vfsDir;#e;#i;#s;#t=new Map;#n=new Map;#o=new Set;#c=new Map;#l=new Map;#r=new Uint8Array(ne);#_;#a;#f;constructor(c=Object.create(null)){this.#f=c.verbosity??f.verbosity,this.vfsName=c.name||f.name,this.#a=Z(this.vfsName),ge(this.#a.pointer,this),this.vfsDir=c.directory||"."+this.vfsName,this.#_=new DataView(this.#r.buffer,this.#r.byteOffset),this.isReady=this.reset(!!(c.clearOnInit??f.clearOnInit)).then(()=>{if(this.$error)throw this.$error;return this.getCapacity()?Promise.resolve(void 0):this.addCapacity(c.initialCapacity||f.initialCapacity)})}#u(c,...d){if(this.#f>c)w[c](this.vfsName+":",...d)}log(...c){this.#u(2,...c)}warn(...c){this.#u(1,...c)}error(...c){this.#u(0,...c)}getVfs(){return this.#a}getCapacity(){return this.#t.size}getFileCount(){return this.#n.size}getFileNames(){let c=[];for(let d of this.#n.keys())c.push(d);return c}async addCapacity(c){for(let d=0;d<c;++d){let L=A(),B=await(await this.#i.getFileHandle(L,{create:!0})).createSyncAccessHandle();this.#t.set(B,L),this.setAssociatedPath(B,"",0)}return this.getCapacity()}async reduceCapacity(c){if(!Number.isSafeInteger(c)||c<0)t("Invalid capacity reduction:",c);let d=0;for(let L of Array.from(this.#o)){if(d===c||this.getFileCount()===this.getCapacity())break;let G=this.#t.get(L);L.close(),this.#t.delete(L),this.#o.delete(L),await this.#i.removeEntry(G),++d}return d}releaseAccessHandles(){for(let c of this.#t.keys())c.close();this.#t.clear(),this.#n.clear(),this.#o.clear(),this.#c.clear(),this.#l.clear()}async acquireAccessHandles(c=!1){let d=[];for await(let[B,ae]of this.#i)if(ae.kind==="file")d.push([B,ae]);let G=(await Promise.allSettled(d.map(async([B,ae])=>{let ce=await ae.createSyncAccessHandle();if(this.#t.set(ce,B),c)ce.truncate(E),this.setAssociatedPath(ce,"",0);else{let be=this.getAssociatedPath(ce);if(be)this.#n.set(be,ce);else this.#o.add(ce)}}))).find((B)=>B.status==="rejected");if(G)throw this.storeErr(G.reason),this.releaseAccessHandles(),G.reason}getAssociatedPath(c){c.read(this.#r,{at:0});let d=this.#_.getUint32(W);if(this.#r[0]&&(d&_.SQLITE_OPEN_DELETEONCLOSE||(d&b)===0))return J(`Removing file with unexpected flags ${d.toString(16)}`,this.#r),this.setAssociatedPath(c,"",0),"";let L=new Uint32Array(p/4);c.read(L,{at:U});let G=this.computeDigest(this.#r,d);if(L.every((B,ae)=>B===G[ae])){let B=this.#r.findIndex((ae)=>ae===0);if(B===0)c.truncate(E);return B?C.decode(this.#r.subarray(0,B)):""}else return J("Disassociating file with bad digest."),this.setAssociatedPath(c,"",0),""}setAssociatedPath(c,d,L){let G=z.encodeInto(d,this.#r);if(R<=G.written+1)t("Path too long:",d);if(d&&L)L|=F;this.#r.fill(0,G.written,R),this.#_.setUint32(W,L);let B=this.computeDigest(this.#r,L);if(c.write(this.#r,{at:0}),c.write(B,{at:U}),c.flush(),d)this.#n.set(d,c),this.#o.delete(c);else c.truncate(E),this.#o.add(c)}computeDigest(c,d){if(d&F){let L=3735928559,G=1103547991;for(let B of c)L=Math.imul(L^B,2654435761),G=Math.imul(G^B,104729);return new Uint32Array([L>>>0,G>>>0])}else return new Uint32Array([0,0])}async reset(c){await this.isReady;let d=await navigator.storage.getDirectory(),L,G;for(let B of this.vfsDir.split("/"))if(B)L=d,d=await d.getDirectoryHandle(B,{create:!0});return this.#e=d,this.#s=L,this.#i=await this.#e.getDirectoryHandle(T,{create:!0}),this.releaseAccessHandles(),this.acquireAccessHandles(c)}getPath(c){if(I.isPtr(c))c=I.cstrToJs(c);return(c instanceof URL?c:new URL(c,"file://localhost/")).pathname}deletePath(c){let d=this.#n.get(c);if(d)this.#n.delete(c),this.setAssociatedPath(d,"",0);return!!d}storeErr(c,d){if(c)c.sqlite3Rc=d||_.SQLITE_IOERR,this.error(c);return this.$error=c,d}popErr(){let c=this.$error;return this.$error=void 0,c}nextAvailableSAH(){let[c]=this.#o.keys();return c}getOFileForS3File(c){return this.#c.get(c)}mapS3FileToOFile(c,d){if(d)this.#c.set(c,d),u(c,this);else this.#c.delete(c),u(c,!1)}hasFilename(c){return this.#n.has(c)}getSAHForPath(c){return this.#n.get(c)}async removeVfs(){if(!this.#a.pointer||!this.#i)return!1;_.sqlite3_vfs_unregister(this.#a.pointer),this.#a.dispose(),delete a[this.vfsName];try{this.releaseAccessHandles(),await this.#e.removeEntry(T,{recursive:!0}),this.#i=void 0,await this.#s.removeEntry(this.#e.name,{recursive:!0}),this.#e=this.#s=void 0}catch(c){i.config.error(this.vfsName,"removeVfs() failed with no recovery strategy:",c)}return!0}pauseVfs(){if(this.#c.size>0)i.SQLite3Error.toss(_.SQLITE_MISUSE,"Cannot pause VFS",this.vfsName,"because it has opened files.");if(this.#t.size>0)_.sqlite3_vfs_unregister(this.vfsName),this.releaseAccessHandles();return this}isPaused(){return this.#t.size===0}async unpauseVfs(){if(this.#t.size===0)return this.acquireAccessHandles(!1).then(()=>_.sqlite3_vfs_register(this.#a,0),this);return this}exportFile(c){let d=this.#n.get(c)||t("File not found:",c),L=d.getSize()-E,G=new Uint8Array(L>0?L:0);if(L>0){let B=d.read(G,{at:E});if(B!=L)t("Expected to read "+L+" bytes but read "+B+".")}return G}async importDbChunked(c,d){let L=this.#n.get(c)||this.nextAvailableSAH()||t("No available handles to import to.");L.truncate(0);let G=0,B,ae=!1,ce=!1;try{while((B=await d())!==void 0){if(B instanceof ArrayBuffer)B=new Uint8Array(B);if(!ae&&G===0&&B.byteLength>=15)h.affirmDbHeader(B),ae=!0;let be=L.write(B,{at:E+G});if(be!==B.byteLength)t("Expected to write "+B.byteLength+"bytes but wrote"+be+".");G+=B.byteLength}if(G<512||G%512!==0)t("Input size",G,"is not correct for an SQLite database.");if(!ae){let be=new Uint8Array(20);L.read(be,{at:E}),h.affirmDbHeader(be)}L.write(new Uint8Array([1,1]),{at:E+18})}catch(be){throw this.setAssociatedPath(L,"",0),be}return this.setAssociatedPath(L,c,_.SQLITE_OPEN_MAIN_DB),G}importDb(c,d){if(d instanceof ArrayBuffer)d=new Uint8Array(d);else if(d instanceof Function)return this.importDbChunked(c,d);h.affirmIsDb(d);let L=this.#n.get(c)||this.nextAvailableSAH()||t("No available handles to import to."),G=d.byteLength,B=L.write(d,{at:E});if(B!=G)this.setAssociatedPath(L,"",0),t("Expected to write "+G+" bytes but wrote "+B+".");else L.truncate(E+G),L.write(new Uint8Array([1,1]),{at:E+18}),this.setAssociatedPath(L,c,_.SQLITE_OPEN_MAIN_DB);return B}hasReservedLock(c){let d=this.#l.get(c);return!!d&&d.lockType>_.SQLITE_LOCK_SHARED}lockFile(c,d){if(c.lockType>=d)return 0;let L=this.#l.get(c.path);if(!L)L=Object.assign(Object.create(null),{nShared:0,lockType:_.SQLITE_LOCK_NONE}),this.#l.set(c.path,L);if(c.lockType!==L.lockType&&(L.lockType>=_.SQLITE_LOCK_PENDING||d>_.SQLITE_LOCK_SHARED))return _.SQLITE_BUSY;if(d===_.SQLITE_LOCK_SHARED){if(++L.nShared,L.lockType===_.SQLITE_LOCK_NONE)L.lockType=d}else if(d===_.SQLITE_LOCK_EXCLUSIVE&&L.nShared>1){if(c.lockType===_.SQLITE_LOCK_RESERVED)c.lockType=L.lockType=_.SQLITE_LOCK_PENDING;return _.SQLITE_BUSY}else L.lockType=d;return c.lockType=d,0}unlockFile(c,d){if(c.lockType<=d)return;let L=this.#l.get(c.path);if(c.lockType>_.SQLITE_LOCK_SHARED)L.lockType=_.SQLITE_LOCK_SHARED;if(d===_.SQLITE_LOCK_NONE&&--L.nShared===0)this.#l.delete(c.path);c.lockType=d}}class y{#e;constructor(c){this.#e=c,this.vfsName=c.vfsName}async addCapacity(c){return this.#e.addCapacity(c)}async reduceCapacity(c){return this.#e.reduceCapacity(c)}getCapacity(){return this.#e.getCapacity(this.#e)}getFileCount(){return this.#e.getFileCount()}getFileNames(){return this.#e.getFileNames()}async reserveMinimumCapacity(c){let d=this.#e.getCapacity();return d<c?this.#e.addCapacity(c-d):d}exportFile(c){return this.#e.exportFile(c)}importDb(c,d){return this.#e.importDb(c,d)}async wipeFiles(){return this.#e.reset(!0)}unlink(c){return this.#e.deletePath(c)}async removeVfs(){return this.#e.removeVfs()}pauseVfs(){return this.#e.pauseVfs(),this}async unpauseVfs(){return this.#e.unpauseVfs().then(()=>this)}isPaused(){return this.#e.isPaused()}}let D=async()=>{let c=await navigator.storage.getDirectory(),d=".opfs-sahpool-sync-check-"+A(),B=(await(await c.getFileHandle(d,{create:!0})).createSyncAccessHandle()).close();if(await B,await c.removeEntry(d),B?.then)t("The local OPFS API is too old for opfs-sahpool:","it has an async FileSystemSyncAccessHandle.close() method.");return!0};i.installOpfsSAHPoolVfs=async function(c=Object.create(null)){c=Object.assign(Object.create(null),f,c||{});let d=c.name;if(c.$testThrowPhase1)throw c.$testThrowPhase1;if(a[d])try{return await a[d]}catch(G){if(c.forceReinitIfPreviouslyFailed)delete a[d];else throw G}if(!globalThis.FileSystemHandle||!globalThis.FileSystemDirectoryHandle||!globalThis.FileSystemFileHandle||!globalThis.FileSystemFileHandle.prototype.createSyncAccessHandle||!navigator?.storage?.getDirectory)return a[d]=Promise.reject(Error("Missing required OPFS APIs."));let L=(G)=>{let B=G.getVfs();if(B?.pointer)_.sqlite3_vfs_unregister(B.pointer),B.dispose(),G.releaseAccessHandles()};return a[d]=D().then(async function(){if(c.$testThrowPhase2)throw c.$testThrowPhase2;let G=new m(c);return G.isReady.then(async()=>{let B=new y(G);if(i.oo1){let ae=i.oo1,ce=G.getVfs(),be=function(...ve){let Fe=ae.DB.dbCtorHelper.normalizeArgs(...ve);Fe.vfs=ce.$zName,ae.DB.dbCtorHelper.call(this,Fe)};be.prototype=Object.create(ae.DB.prototype),B.OpfsSAHPoolDb=be}return G.log("VFS initialized."),B}).catch(async(B)=>{if(c.preserveOnInitFailure)L(G);else await G.removeVfs().catch(()=>{});throw B})}).catch((G)=>a[d]=Promise.reject(G))}}),globalThis.sqlite3ApiBootstrap.initializers.push(function(i){if(!i.opfs||i.config.disable?.vfs?.["opfs-wl"])return;let t=i.util,r=i.util.toss,a=i.opfs,_="opfs-wl",h=async function(I){if(I=a.initOptions(_,I),!I)return i;let S=i.capi,R=a.createVfsState(),M=R.vfs,p=M.metrics.counters,{mTimeStart:ne,mTimeEnd:W,opRun:U}=M,E=(...T)=>i.config.debug(_+":",...T),b=(...T)=>i.config.warn(_+":",...T),F=M.__openFiles;return M.bindVfs(t.nu({xLock:function(T,A){ne("xLock");let C=F[T],z=U("xLock",T,A);if(!z)C.lockType=A;return W(),z},xUnlock:function(T,A){ne("xUnlock");let C=F[T],z=U("xUnlock",T,A);if(!z)C.lockType=A;return W(),z}}),function(T,A){if(T.oo1){let C=function(...z){let f=T.oo1.DB.dbCtorHelper.normalizeArgs(...z);f.vfs=A.$zName,T.oo1.DB.dbCtorHelper.call(this,f)};C.prototype=Object.create(T.oo1.DB.prototype),T.oo1.OpfsWlDb=C,C.importDb=a.importDb}})};globalThis.sqlite3ApiBootstrap.initializersAsync.push(async(I)=>h().catch((S)=>{I.config.warn("Ignoring inability to install the",_,"sqlite3_vfs:",S)}))});try{let i=Object.assign(Object.create(null),{memory:typeof Ze<"u"?Ze:n.wasmMemory,exports:typeof gt<"u"?gt:Object.prototype.hasOwnProperty.call(n,"wasmExports")?n.wasmExports:n.asm},globalThis.sqlite3ApiBootstrap.defaultConfig,globalThis.sqlite3ApiConfig||{});e.debugModule("Bootstrapping lib config",i);let t=globalThis.sqlite3ApiBootstrap(i);return delete globalThis.sqlite3ApiBootstrap,t}catch(i){throw console.error("sqlite3ApiBootstrap() error:",i),i}},s}var Kc,On;var Pn=Bc(()=>{Kc=function(){let g=Bt;if(!g)throw Error("Expecting sqlite3InitModule to be defined by the Emscripten build.");let s=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(s.debugModule=s.urlParams.has("sqlite3.debugModule")?(...te)=>console.warn("sqlite3.debugModule:",...te):()=>{},s.urlParams.has("sqlite3.dir"))s.sqlite3Dir=s.urlParams.get("sqlite3.dir")+"/";else if(s.moduleScript){let te=s.moduleScript.src.split("/");te.pop(),s.sqlite3Dir=te.join("/")+"/"}let Y=globalThis.sqlite3InitModule=function te(...pe){return s.emscriptenLocateFile=pe[0]?.locateFile,s.emscriptenInstantiateWasm=pe[0]?.instantiateWasm,g(...pe).then((qe)=>{s.debugModule("sqlite3InitModule() sIMS =",s),s.debugModule("sqlite3InitModule() EmscriptenModule =",qe);let Ne=qe.runSQLite3PostLoadInit(s,qe,!!te.__isUnderTest);return s.debugModule("sqlite3InitModule() sqlite3 =",Ne),Ne}).catch((qe)=>{throw console.error("Exception loading sqlite3 module:",qe),qe})};if(Y.ready=g.ready,s.moduleScript){let te=s.moduleScript.src.split("/");te.pop(),s.scriptDir=te.join("/")+"/"}return s.debugModule("extern-post-js.c-pp.js sqlite3InitModuleState =",s),Y}();Bt=Kc;On=Bt});var kn=Promise.resolve();function Uc(){return typeof Bun>"u"?null:Bun.fetch}function Qc(g){if(typeof g==="string")return g;return g instanceof URL?g.href:g.url}function Vc(g,s){return Object.assign((Y,te)=>Qc(Y).startsWith("file:")?g(Y,te):s(Y,te),{preconnect:s.preconnect})}function jt(g){let s=Uc();if(!s)return g();let Y=kn.then(async()=>{let te=globalThis.fetch;globalThis.fetch=Vc(s,te);try{return await g()}finally{globalThis.fetch=te}});return kn=Y.then(()=>{return},()=>{return}),Y}function Hc(g,s){let Y=Reflect.get(g.capi,"sqlite3mc_vfs_create");if(typeof Y!=="function")return null;let te=Reflect.apply(Y,g.capi,[s,0]);return typeof te==="number"?te:null}function An(g,s){let Y=new Set(g.capi.sqlite3_js_vfs_list()),te=Hc(g,s);if(te===null)throw Error("Persistent storage requested but the SQLite build does not provide sqlite3mc_vfs_create.");if(te!==0)throw Error(`Failed to create the multiple-ciphers VFS over ${s} (rc=${te}).`);let pe=g.capi.sqlite3_js_vfs_list().filter((Ne)=>!Y.has(Ne)),qe=pe.find((Ne)=>Ne.includes(s))??pe[0];if(!qe)throw Error("The multiple-ciphers VFS was created but could not be located in the VFS list.");return qe}function In(g,s){let Y=Reflect.get(g.capi,"sqlite3mc_vfs_destroy");if(typeof Y!=="function")throw Error("The SQLite build does not provide sqlite3mc_vfs_destroy.");Reflect.apply(Y,g.capi,[s])}var St=8000;class xt extends Error{constructor(g){super(g);this.name="SahPoolStepTimeoutError"}}function wt(g,s){g.catch(()=>{});let Y;return Promise.race([g,new Promise((te,pe)=>{Y=setTimeout(()=>{pe(new xt(`SAHPool handle acquisition did not settle within ${s}ms (likely a hung createSyncAccessHandle under OPFS handle-cap contention).`))},s)})]).finally(()=>{clearTimeout(Y)})}var Tn="tearleads-opfs-sahpool",xn="/tearleads-sqlite";function Gc(g){let s=g.trim().replace(/^\/+/u,"").replace(/[^a-zA-Z0-9_.-]+/gu,"_").replace(/^_+/u,""),Y=s.length;while(Y>0&&s[Y-1]==="_")Y-=1;let te=s.slice(0,Y);return!te||te==="."||te===".."?"default":te}function zt(g){let s=Gc(g);return{directory:`/tearleads-sqlite/${s}`,vfsName:`tearleads-opfs-sahpool-${s}`}}var $c=["Missing SharedArrayBuffer and/or Atomics","The OPFS sqlite3_vfs cannot run in the main thread"],Fn=Symbol.for("tearleads.sqliteWorker.autoOpfsVfsWarnFilterInstalled");function Ln(g){if(typeof g==="string")return g;if(g instanceof Error)return g.message;if(typeof g==="object"&&g!==null){let s=Reflect.get(g,"message");if(typeof s==="string")return s}try{return String(g)}catch{return"[Object]"}}function Jc(g){return $c.some((s)=>g.includes(s))}function Dn(g){if(g.length===0)return!1;let s=Ln(g[0]),Y=g.map(Ln).join(" ");return(s==="Ignoring inability to install OPFS sqlite3_vfs:"||s.includes("Ignoring inability to install OPFS sqlite3_vfs:"))&&Jc(Y)}function Cn(){if(Reflect.get(console,Fn)===!0||typeof console.warn!=="function")return;let g=console.warn;Reflect.set(console,"warn",(...Y)=>{if(Dn(Y))return;Reflect.apply(g,console,Y)}),Reflect.set(console,Fn,!0)}function Yc(g){let s=typeof g==="object"&&g!==null?g:void 0,Y=s?Reflect.get(s,"warn"):void 0,te=(...pe)=>{if(Dn(pe))return;if(typeof Y==="function"){Reflect.apply(Y,s??globalThis,pe);return}console.warn(...pe)};return Object.assign(Object.create(null),s,{warn:te})}function Xc(g){if(g===void 0){Reflect.deleteProperty(globalThis,"sqlite3ApiConfig");return}Reflect.set(globalThis,"sqlite3ApiConfig",g)}async function Nn(){let g=Reflect.get(globalThis,"sqlite3ApiConfig"),s=Yc(g);Reflect.set(globalThis,"sqlite3ApiConfig",s);try{await Promise.resolve().then(() => Pn());return await On()}finally{if(Reflect.get(globalThis,"sqlite3ApiConfig")===s)Xc(g)}}function Ut(g,s){if(s.rowMode==="array"){let te=[];return g.exec(s.sql,{...s.bind!==void 0?{bind:s.bind}:{},rowMode:"array",resultRows:te}),te}let Y=[];return g.exec(s.sql,{...s.bind!==void 0?{bind:s.bind}:{},rowMode:"object",resultRows:Y}),Y}var Zc=12,e_=3000,t_=150,n_=600;function r_(g){return new Promise((s)=>{setTimeout(s,g)})}function i_(g){if(typeof g!=="object"||g===null)return!1;if(Reflect.get(g,"name")==="NoModificationAllowedError")return!0;let Y=Reflect.get(g,"message");return typeof Y==="string"&&Y.includes("Access Handles cannot be created")}var Qt,Vt,tt=new Map,Ht=new WeakMap;function Rn(g){return`${g.vfsName}
4
+ ${g.directory}`}function s_(g,s){let Y={installation:s.catch((te)=>{if(tt.get(g)===Y)tt.delete(g);throw te instanceof Error?te:Error("Failed to install the persistent SQLite VFS.",{cause:te})}),resume:null};return tt.set(g,Y),Y}async function o_(g){if(g.resume)return g.resume;let s=g.installation.then(async(Y)=>{if(Y.poolUtil.isPaused())await wt(Y.poolUtil.unpauseVfs(),St);return Y});g.resume=s;try{return await s}finally{if(g.resume===s)g.resume=null}}async function a_(){if(Qt)return Qt;if(!Vt)Vt=jt(async()=>{let g=await Nn();return Qt=g,g});return Vt}function l_(g){return{directory:g?.directory??xn,initialDelayMs:g?.initialDelayMs??t_,maxDelayMs:g?.maxDelayMs??n_,now:g?.now??(()=>Date.now()),stepHangTimeoutMs:g?.stepHangTimeoutMs??St,totalBudgetMs:g?.totalBudgetMs??e_,vfsName:g?.vfsName??Tn}}async function c_(g,s){let{directory:Y,initialDelayMs:te,maxDelayMs:pe,now:qe,stepHangTimeoutMs:Ne,totalBudgetMs:ze,vfsName:nt}=l_(s),ut={name:nt,directory:Y,clearOnInit:!1,forceReinitIfPreviouslyFailed:!0,preserveOnInitFailure:!0},ot=qe(),ft=te;for(;;)try{return await wt(g.installOpfsSAHPoolVfs(ut),Ne)}catch(Ye){if(Ye instanceof xt)throw Ye;if(!i_(Ye))throw Ye;if(qe()-ot+ft>ze)throw Ye;await r_(ft),ft=Math.min(ft*2,pe)}}async function __(g,s){let Y=zt(s),te=Rn(Y);if(typeof g.installOpfsSAHPoolVfs!=="function")throw Error("Persistent storage requested but the SQLite build does not provide installOpfsSAHPoolVfs.");let pe=tt.get(te);if(pe)return o_(pe);let qe=(async()=>{let Ne=await c_(g,{directory:Y.directory,vfsName:Y.vfsName});await wt(Ne.reserveMinimumCapacity(Zc),St);let ze=An(g,Ne.vfsName);return{poolUtil:Ne,cipherVfsName:ze,destroyCipherWrapper:()=>In(g,ze)}})();return s_(te,qe).installation}async function u_(g,s,Y){if(Y==="memory")return new g.oo1.DB(s);let{cipherVfsName:te}=await __(g,s),pe=new g.oo1.DB(s,"c",te),qe=zt(s);return Ht.set(pe,Rn(qe)),pe}async function Mn(g){let s=await a_(),Y=g.persistence??"memory";return jt(async()=>{let te=await u_(s,g.dbName,Y);return te.exec(`PRAGMA cipher='${g.cipher}'`),te.exec(`PRAGMA key='${g.key}'`),te})}function f_(g,s,Y){if(g){let pe=tt.get(g);if(Y)tt.delete(g);return[pe]}if(s)return[];let te=[...tt.values()];if(Y)tt.clear();return te}async function Wn(g,s,Y){let te=g?Ht.get(g):void 0;try{g?.close()}catch{}if(g)Ht.delete(g);let pe=f_(te,g!==null,Y);for(let qe of pe){if(!qe)continue;try{await s(await(qe.resume??qe.installation))}catch{}}}function jn(g){return Wn(g,(s)=>{s.poolUtil.pauseVfs()},!1)}function zn(g){return Wn(g,async(s)=>{if(s.poolUtil.isPaused())await wt(s.poolUtil.unpauseVfs(),St);await s.poolUtil.wipeFiles(),s.destroyCipherWrapper(),await s.poolUtil.removeVfs()},!0)}function Bn(){return tt.size>0}var Un="tearleads:sqlite-connect-port",Qn="tearleads:sqlite-disconnect-port",Vn="tearleads:sqlite-port-disconnected",Gt="Database has not been initialized.",Hn="Database was deleted by another connection.",Gn="tearleads:sqlite-database-deleted";function d_(g){return g!==void 0&&"getDirectory"in g&&typeof g.getDirectory==="function"}async function p_(g,s,Y,te){for(let pe=1;;pe+=1){try{await g.removeEntry(s,{recursive:!0});return}catch(ze){if(ze instanceof Error&&ze.name==="NotFoundError")return;if(pe>=Y)throw Error(`Could not remove "${s}" from OPFS.`,{cause:ze})}let{promise:qe,resolve:Ne}=Promise.withResolvers();setTimeout(Ne,te),await qe}}async function Kn(g={}){if(typeof navigator!=="object"||!d_(navigator.storage))return"unavailable";let s=await navigator.storage.getDirectory(),Y=[];for await(let[te]of s.entries())Y.push(te);for(let te of Y)await p_(s,te,g.attempts??10,g.retryDelayMs??200);return"wiped"}function h_(g){return[g.dbName,g.persistence??"memory",g.cipher,g.key].join("\x00")}function Kt(g,s){let Y=g.queue.then(s,s);return g.queue=Y.then(()=>{return},()=>{return}),Y}class $n{databasesByName=new Map;connectionsByName=new Map;lifecycleByName=new Map;initializingConnections=0;storageWipe=Promise.resolve();createConnection(g=()=>{}){let s={dbName:null,databaseDeleted:!1,generation:0,initializing:!1,notify:g};return{onInit:(Y)=>this.initConnection(s,Y),onExec:(Y)=>this.execForConnection(s,Y),onClose:()=>this.closeConnection(s),onPrepareDelete:()=>s.dbName?this.databasesByName.get(s.dbName)?.queue:void 0,onDelete:()=>this.deleteConnection(s),onWipeStorage:()=>this.wipeStorage()}}async initConnection(g,s){if(g.dbName||g.initializing)throw Error("Database has already been initialized.");let Y=g.generation;g.initializing=!0,this.initializingConnections+=1;try{let te=await this.acquireDatabase(s);if(g.generation!==Y||g.dbName)throw await this.releaseDatabase(te.dbName),Error("Database connection closed before initialization completed.");g.dbName=te.dbName,g.databaseDeleted=!1,this.addConnection(te.dbName,g)}finally{g.initializing=!1,this.initializingConnections-=1}}async execForConnection(g,s){let Y=g.dbName;if(!Y)throw Error(g.databaseDeleted?Hn:Gt);let te=this.databasesByName.get(Y);if(!te)throw this.detachConnection(g),Error(Gt);return Kt(te,()=>Ut(te.db,s))}async wipeStorage(){if(this.initializingConnections>0||this.databasesByName.size>0||Bn())throw Error("Storage can only be wiped before this worker opens a database.");let g=this.storageWipe.then(()=>Kn());this.storageWipe=g.then(()=>{return},()=>{return}),await g}async acquireDatabase(g){let{dbName:s}=g,Y=h_(g);await this.storageWipe,await this.waitForLifecycle(s);let te=this.databasesByName.get(s);if(te)return this.attachDatabase(te,Y);let pe=await this.runLifecycle(s,async()=>{let qe=this.databasesByName.get(s);if(qe)return qe;let ze={db:await Mn(g),dbName:s,optionsKey:Y,refCount:0,queue:Promise.resolve()};return this.databasesByName.set(s,ze),ze});return this.attachDatabase(pe,Y)}attachDatabase(g,s){if(g.optionsKey!==s)throw Error("Database is already initialized with different options.");return g.refCount+=1,g}async closeConnection(g){g.generation+=1;let s=this.detachConnection(g);if(s)await this.releaseDatabase(s)}async deleteConnection(g){g.generation+=1;let s=g.dbName;if(!s)return;await this.deleteDatabase(s,g)}async releaseDatabase(g){let s=this.databasesByName.get(g);if(!s)return;if(s.refCount=Math.max(0,s.refCount-1),s.refCount>0)return;this.databasesByName.delete(g),await this.runLifecycle(g,()=>Kt(s,()=>jn(s.db)))}async deleteDatabase(g,s){let Y=this.connectionsByName.get(g);if(Y){for(let pe of Y)if(pe.dbName=null,pe.generation+=1,pe!==s)pe.databaseDeleted=!0,pe.notify({type:Gn});this.connectionsByName.delete(g)}let te=this.databasesByName.get(g);if(!te)return;te.refCount=0,this.databasesByName.delete(g),await this.runLifecycle(g,()=>Kt(te,()=>zn(te.db)))}addConnection(g,s){let Y=this.connectionsByName.get(g)??new Set;Y.add(s),this.connectionsByName.set(g,Y)}detachConnection(g){let s=g.dbName;if(g.dbName=null,!s)return null;let Y=this.connectionsByName.get(s);if(Y?.delete(g),Y?.size===0)this.connectionsByName.delete(s);return s}async waitForLifecycle(g){await this.lifecycleByName.get(g)}async runLifecycle(g,s){let te=(this.lifecycleByName.get(g)??Promise.resolve()).then(s,s),pe=te.then(()=>{return},()=>{return});this.lifecycleByName.set(g,pe);try{return await te}finally{if(this.lifecycleByName.get(g)===pe)this.lifecycleByName.delete(g)}}}function Jn(){let g=new $n;return(s)=>g.createConnection(s)}function m_(g){if(typeof g!=="object"||g===null)return!1;let s=Reflect.get(g,"id"),Y=Reflect.get(g,"method");return typeof s==="number"&&(Y==="ping"||Y==="init"||Y==="exec"||Y==="close"||Y==="prepareDelete"||Y==="delete"||Y==="wipeStorage")}function $t(g,s={}){let Y=async(te)=>{let pe=te.data;if(!m_(pe))return;try{let qe=await g_(pe,s);g.postMessage(qe)}catch(qe){g.postMessage({id:pe.id,result:{ok:!1,message:qe instanceof Error?qe.message:String(qe)}})}};return g.addEventListener("message",Y),()=>g.removeEventListener?.("message",Y)}async function g_(g,s){switch(g.method){case"ping":return{id:g.id,result:{ok:!0,message:"pong"}};case"init":return await s.onInit?.(g.params),{id:g.id,result:{ok:!0}};case"exec":return{id:g.id,result:{ok:!0,rows:await s.onExec?.(g.params)??[]}};case"close":return await s.onClose?.(),{id:g.id,result:{ok:!0}};case"prepareDelete":return await s.onPrepareDelete?.(),{id:g.id,result:{ok:!0}};case"delete":return await s.onDelete?.(),{id:g.id,result:{ok:!0}};case"wipeStorage":return await s.onWipeStorage?.(),{id:g.id,result:{ok:!0}}}}function Xn(g){return typeof g==="object"&&g!==null&&typeof Reflect.get(g,"addEventListener")==="function"}function Zn(g){return Xn(g)&&typeof Reflect.get(g,"postMessage")==="function"}function er(g){return Zn(g)&&typeof Reflect.get(g,"removeEventListener")==="function"}function b_(g){return typeof g==="function"?g:()=>g}function y_(g){return{addEventListener(s,Y){g.addEventListener(s,(te)=>{if(te instanceof MessageEvent)Y(te)})},postMessage(s){g.postMessage(s)}}}function q_(g){let s=new Map;return{addEventListener(Y,te){let pe=(qe)=>{te(qe)};s.set(te,pe),g.addEventListener(Y,pe)},postMessage(Y){g.postMessage(Y)},removeEventListener(Y,te){let pe=s.get(te);if(!pe)return;s.delete(te),g.removeEventListener(Y,pe)}}}function v_(g){return typeof g==="object"&&g!==null&&Reflect.get(g,"type")===Qn}function Yn(g,s){let Y=!1,te=!1,pe=async(nt)=>{await s.onInit?.(nt),te=!1},qe=()=>{if(te)return;return te=!0,s.onClose?.()},Ne=$t(q_(g),{...s,onInit:pe,onClose:qe}),ze=(nt)=>{if(Y||!v_(nt.data))return;Y=!0,Ne(),g.removeEventListener("message",ze);let ut=()=>{try{g.postMessage({type:Vn})}catch{}try{g.close()}catch{}};Promise.resolve().then(qe).then(ut,ut)};g.addEventListener("message",ze),g.start?.()}function S_(g){let s=g.data;if(typeof s!=="object"||s===null||Reflect.get(s,"type")!==Un)return null;let Y=Reflect.get(g,"ports"),te=Array.isArray(Y)?Y[0]:null;return er(te)?te:null}function tr(g={}){let s=b_(g),Y=self;if(Zn(Y))Y.addEventListener("message",(te)=>{if(!(te instanceof MessageEvent))return;let pe=S_(te);if(!pe)return;Yn(pe,s((qe)=>pe.postMessage(qe)))}),$t(y_(Y),s((te)=>Y.postMessage(te)));if(!Xn(Y))return;Y.addEventListener("connect",(te)=>{let pe=Reflect.get(te,"ports"),qe=Array.isArray(pe)?pe[0]:null;if(!er(qe))return;Yn(qe,s((Ne)=>qe.postMessage(Ne)))})}Cn();tr(Jn());