@run-trace/duckdb-wasm 0.0.2 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- "use strict";var duckdb=(()=>{var ds=Object.create;var Pe=Object.defineProperty;var fs=Object.getOwnPropertyDescriptor;var _s=Object.getOwnPropertyNames;var hs=Object.getPrototypeOf,bs=Object.prototype.hasOwnProperty;var ps=(a,e,n)=>e in a?Pe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[e]=n;var Ht=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var ke=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports),ms=(a,e)=>{for(var n in e)Pe(a,n,{get:e[n],enumerable:!0})},Pt=(a,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of _s(e))!bs.call(a,r)&&r!==n&&Pe(a,r,{get:()=>e[r],enumerable:!(o=fs(e,r))||o.enumerable});return a};var xt=(a,e,n)=>(n=a!=null?ds(hs(a)):{},Pt(e||!a||!a.__esModule?Pe(n,"default",{value:a,enumerable:!0}):n,a)),gs=a=>Pt(Pe({},"__esModule",{value:!0}),a);var Bt=(a,e,n)=>ps(a,typeof e!="symbol"?e+"":e,n);var Gt=ke(()=>{});var Kt=ke(()=>{});var Xt=ke(($t,$e)=>{"use strict";var at=(()=>{var e;var a=typeof document<"u"?(e=document.currentScript)==null?void 0:e.src:void 0;return typeof __filename<"u"&&(a=a||__filename),async function(n={}){var o,r=n,l,d,f=new Promise((t,s)=>{l=t,d=s}),u=typeof window=="object",O=typeof WorkerGlobalScope<"u",_=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer",N=Object.assign({},r),Y=[],R="./this.program",M=(t,s)=>{throw s},X="";function Q(t){return r.locateFile?r.locateFile(t,X):X+t}var re,J;if(_){var q=Gt(),se=Kt();X=__dirname+"/",J=t=>{t=Ae(t)?new URL(t):t;var s=q.readFileSync(t);return s},re=async(t,s=!0)=>{t=Ae(t)?new URL(t):t;var i=q.readFileSync(t,s?void 0:"utf8");return i},!r.thisProgram&&process.argv.length>1&&(R=process.argv[1].replace(/\\/g,"/")),Y=process.argv.slice(2),M=(t,s)=>{throw process.exitCode=t,s}}else(u||O)&&(O?X=self.location.href:typeof document<"u"&&document.currentScript&&(X=document.currentScript.src),a&&(X=a),X.startsWith("blob:")?X="":X=X.slice(0,X.replace(/[?#].*/,"").lastIndexOf("/")+1),O&&(J=t=>{var s=new XMLHttpRequest;return s.open("GET",t,!1),s.responseType="arraybuffer",s.send(null),new Uint8Array(s.response)}),re=async t=>{var s=await fetch(t,{credentials:"same-origin"});if(s.ok)return s.arrayBuffer();throw new Error(s.status+" : "+s.url)});var ne=r.print||console.log.bind(console),b=r.printErr||console.error.bind(console);Object.assign(r,N),N=null,r.arguments&&(Y=r.arguments),r.thisProgram&&(R=r.thisProgram);var A=r.wasmBinary,I,m=!1,D;function F(t,s){t||he(s)}var P,p,U,x,S,$,fe,G,_e,oe,pe=!1,Ae=t=>t.startsWith("file://");function Se(){var t=I.buffer;r.HEAP8=P=new Int8Array(t),r.HEAP16=U=new Int16Array(t),r.HEAPU8=p=new Uint8Array(t),r.HEAPU16=x=new Uint16Array(t),r.HEAP32=S=new Int32Array(t),r.HEAPU32=$=new Uint32Array(t),r.HEAPF32=fe=new Float32Array(t),r.HEAPF64=oe=new Float64Array(t),r.HEAP64=G=new BigInt64Array(t),r.HEAPU64=_e=new BigUint64Array(t)}function Re(){if(r.preRun)for(typeof r.preRun=="function"&&(r.preRun=[r.preRun]);r.preRun.length;)hr(r.preRun.shift());lt(ct)}function tr(){pe=!0,T.ta()}function Is(){}function rr(){if(r.postRun)for(typeof r.postRun=="function"&&(r.postRun=[r.postRun]);r.postRun.length;)_r(r.postRun.shift());lt(ut)}var ve=0,Ue=null;function nr(t){var s;ve++,(s=r.monitorRunDependencies)==null||s.call(r,ve)}function sr(t){var i;if(ve--,(i=r.monitorRunDependencies)==null||i.call(r,ve),ve==0&&Ue){var s=Ue;Ue=null,s()}}function he(t){var i;(i=r.onAbort)==null||i.call(r,t),t="Aborted("+t+")",b(t),m=!0,t+=". Build with -sASSERTIONS for more info.",pe&&___trap();var s=new WebAssembly.RuntimeError(t);throw d(s),s}var Te;function ar(){return Q("./duckdb-eh.wasm")}function ir(t){if(t==Te&&A)return new Uint8Array(A);if(J)return J(t);throw"both async and sync fetching of the wasm failed"}async function or(t){if(!A)try{var s=await re(t);return new Uint8Array(s)}catch{}return ir(t)}async function lr(t,s){try{var i=await or(t),c=await WebAssembly.instantiate(i,s);return c}catch(h){b(`failed to asynchronously prepare wasm: ${h}`),he(h)}}async function ur(t,s,i){if(!t&&typeof WebAssembly.instantiateStreaming=="function"&&!_)try{var c=fetch(s,{credentials:"same-origin"}),h=await WebAssembly.instantiateStreaming(c,i);return h}catch(g){b(`wasm streaming compile failed: ${g}`),b("falling back to ArrayBuffer instantiation")}return lr(s,i)}function cr(){return{a:rs}}async function dr(){function t(g,w){return T=g.exports,T=us(T),I=T.sa,Se(),sr("wasm-instantiate"),T}nr("wasm-instantiate");function s(g){return t(g.instance)}var i=cr();if(r.instantiateWasm)return new Promise((g,w)=>{r.instantiateWasm(i,(E,k)=>{t(E,k),g(E.exports)})});Te!=null||(Te=ar());try{var c=await ur(A,Te,i),h=s(c);return h}catch(g){return d(g),Promise.reject(g)}}var fr={10294593:(t,s,i,c)=>{var h=z(t);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(z(c),h,!1),g.responseType="arraybuffer";for(var w=0,y=s;w<y*2;){var E=S[i/4+w>>>0],k=S[i/4+w+1>>>0];try{var H=encodeURI(z(E));H==="Host"&&(H="X-Host-Override"),H==="User-Agent"&&(H="X-user-agent"),H==="Authorization"?g.setRequestHeader(H,z(k)):g.setRequestHeader(H,encodeURI(z(k)))}catch(te){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",te)}w+=2}try{g.send(null)}catch{return 0}if(g.status>=400)return 0;for(var L=g.response,y=L.byteLength,K=ye(y+4),V=new Uint8Array(L),C=0;C<y;C++)r.HEAPU8[C+K+4]=V[C];var v=new Uint8Array(4);return v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,K),K},10296e3:(t,s,i,c,h,g)=>{var w=z(t);if(typeof XMLHttpRequest>"u")return 0;let E=new XMLHttpRequest;E.open(z(c),w,!1),E.responseType="arraybuffer";for(var k=0,v=s;k<v*2;){var H=S[i/4+k>>>0],L=S[i/4+k+1>>>0];try{var y=encodeURI(z(H));y==="Host"&&(y="X-Host-Override"),y==="User-Agent"&&(y="X-user-agent"),y==="Authorization"?E.setRequestHeader(y,z(L)):E.setRequestHeader(y,encodeURI(z(L)))}catch(we){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",we)}k+=2}try{for(var K=new Uint8Array(g),V=0;V<g;V++)K[V]=r.HEAPU8[V+h];E.send(K)}catch{return 0}if(E.status>=400)return 0;for(var C=Uint8Array.from(Array.from(E.getResponseHeader("Etag")).map(we=>we.charCodeAt(0))),v=C.byteLength,te=ye(v+4),le=new Uint8Array(C),V=0;V<v;V++)r.HEAPU8[V+te+4]=le[V];var Z=new Uint8Array(4);return Z[0]=v%256,v-=Z[0],v/=256,Z[1]=v%256,v-=Z[1],v/=256,Z[2]=v%256,v-=Z[2],v/=256,Z[3]=v%256,v-=Z[3],v/=256,r.HEAPU8.set(Z,te),te},10297620:(t,s,i,c)=>{var h=z(t);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(z(c),h,!1),g.responseType="arraybuffer";for(var w=0,y=s;w<y*2;){var E=S[i/4+w>>>0],k=S[i/4+w+1>>>0];try{var H=encodeURI(z(E));H==="Host"&&(H="X-Host-Override"),H==="User-Agent"&&(H="X-user-agent"),H==="Authorization"?g.setRequestHeader(H,z(k)):g.setRequestHeader(H,encodeURI(z(k)))}catch(Z){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Z)}w+=2}try{g.send(null)}catch{return 0}if(g.status>=400)return 0;for(var L=g.response,y=L.byteLength,K=ye(y+8),V=new Uint8Array(L),C=0;C<y;C++)r.HEAPU8[C+K+8]=V[C];var v=new Uint8Array(4);v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,K+4);var te=Uint8Array.from(Array.from(g.getAllResponseHeaders()).map(Z=>Z.charCodeAt(0)));y=te.byteLength;for(var le=ye(y+8),C=0;C<y;C++)r.HEAPU8[C+le+8]=te[C];return v=new Uint8Array(4),v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,le+4),y=le,v=new Uint8Array(4),v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,K),K},10299904:(t,s,i,c)=>{var h=z(t);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(z(c),h,!1),g.responseType="arraybuffer";for(var w=0,y=s;w<y*2;){var E=S[i/4+w>>>0],k=S[i/4+w+1>>>0];try{var H=encodeURI(z(E));H==="Host"&&(H="X-Host-Override"),H==="User-Agent"&&(H="X-user-agent"),H==="Authorization"?g.setRequestHeader(H,z(k)):g.setRequestHeader(H,encodeURI(z(k)))}catch(te){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",te)}w+=2}try{g.send(null)}catch{return 0}if(g.status>=400)return 0;for(var L=g.response,y=L.byteLength,K=ye(y+4),V=new Uint8Array(L),C=0;C<y;C++)r.HEAPU8[C+K+4]=V[C];var v=new Uint8Array(4);return v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,K),K},10301311:(t,s,i,c,h,g)=>{var w=z(t);if(typeof XMLHttpRequest>"u")return 0;let E=new XMLHttpRequest;E.open(z(c),w,!1),E.responseType="arraybuffer";for(var k=0,v=s;k<v*2;){var H=S[i/4+k>>>0],L=S[i/4+k+1>>>0];try{var y=encodeURI(z(H));y==="Host"&&(y="X-Host-Override"),y==="User-Agent"&&(y="X-user-agent"),y==="Authorization"?E.setRequestHeader(y,z(L)):E.setRequestHeader(y,encodeURI(z(L)))}catch(we){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",we)}k+=2}try{for(var K=new Uint8Array(g),V=0;V<g;V++)K[V]=r.HEAPU8[V+h];E.send(K)}catch{return 0}if(E.status>=400)return 0;for(var C=E.response,v=C.byteLength,te=ye(v+4),le=new Uint8Array(C),V=0;V<v;V++)r.HEAPU8[V+te+4]=le[V];var Z=new Uint8Array(4);return Z[0]=v%256,v-=Z[0],v/=256,Z[1]=v%256,v-=Z[1],v/=256,Z[2]=v%256,v-=Z[2],v/=256,Z[3]=v%256,v-=Z[3],v/=256,r.HEAPU8.set(Z,te),te}};class ot{constructor(s){Bt(this,"name","ExitStatus");this.message=`Program terminated with exit(${s})`,this.status=s}}var lt=t=>{for(;t.length>0;)t.shift()(r)},ut=[],_r=t=>ut.unshift(t),ct=[],hr=t=>ct.unshift(t),br=r.noExitRuntime||!0;function dt(){he("missing function: $SOCKFS")}dt.stub=!0;function Je(){he("missing function: $FS")}Je.stub=!0;var De=t=>{var s=dt.getSocket(t);if(!s)throw new Je.ErrnoError(8);return s},je=t=>(t&255)+"."+(t>>8&255)+"."+(t>>16&255)+"."+(t>>24&255),ft=t=>{var s="",i=0,c=0,h=0,g=0,w=0,E=0,k=[t[0]&65535,t[0]>>16,t[1]&65535,t[1]>>16,t[2]&65535,t[2]>>16,t[3]&65535,t[3]>>16],H=!0,L="";for(E=0;E<5;E++)if(k[E]!==0){H=!1;break}if(H){if(L=je(k[6]|k[7]<<16),k[5]===-1)return s="::ffff:",s+=L,s;if(k[5]===0)return s="::",L==="0.0.0.0"&&(L=""),L==="0.0.0.1"&&(L="1"),s+=L,s}for(i=0;i<8;i++)k[i]===0&&(i-h>1&&(w=0),h=i,w++),w>c&&(c=w,g=i-c+1);for(i=0;i<8;i++){if(c>1&&k[i]===0&&i>=g&&i<g+c){i===g&&(s+=":",g===0&&(s+=":"));continue}s+=Number(_ntohs(k[i]&65535)).toString(16),s+=i<7?":":""}return s},_t=(t,s)=>{var i=U[t>>>1>>>0],c=_ntohs(x[t+2>>>1>>>0]),h;switch(i){case 2:if(s!==16)return{errno:28};h=S[t+4>>>2>>>0],h=je(h);break;case 10:if(s!==28)return{errno:28};h=[S[t+8>>>2>>>0],S[t+12>>>2>>>0],S[t+16>>>2>>>0],S[t+20>>>2>>>0]],h=ft(h);break;default:return{errno:5}}return{family:i,addr:h,port:c}},xe=t=>{for(var s=t.split("."),i=0;i<4;i++){var c=Number(s[i]);if(isNaN(c))return null;s[i]=c}return(s[0]|s[1]<<8|s[2]<<16|s[3]<<24)>>>0},Be=t=>parseInt(t),ze=t=>{var s,i,c,h,g=/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,w=[];if(!g.test(t))return null;if(t==="::")return[0,0,0,0,0,0,0,0];for(t.startsWith("::")?t=t.replace("::","Z:"):t=t.replace("::",":Z:"),t.indexOf(".")>0?(t=t.replace(new RegExp("[.]","g"),":"),s=t.split(":"),s[s.length-4]=Be(s[s.length-4])+Be(s[s.length-3])*256,s[s.length-3]=Be(s[s.length-2])+Be(s[s.length-1])*256,s=s.slice(0,s.length-2)):s=t.split(":"),c=0,h=0,i=0;i<s.length;i++)if(typeof s[i]=="string")if(s[i]==="Z"){for(h=0;h<8-s.length+1;h++)w[i+h]=0;c=h-1}else w[i+c]=_htons(parseInt(s[i],16));else w[i+c]=s[i];return[w[1]<<16|w[0],w[3]<<16|w[2],w[5]<<16|w[4],w[7]<<16|w[6]]},ie={address_map:{id:1,addrs:{},names:{}},lookup_name(t){var s=xe(t);if(s!==null||(s=ze(t),s!==null))return t;var i;if(ie.address_map.addrs[t])i=ie.address_map.addrs[t];else{var c=ie.address_map.id++;F(c<65535,"exceeded max address mappings of 65535"),i="172.29."+(c&255)+"."+(c&65280),ie.address_map.names[i]=t,ie.address_map.addrs[t]=i}return i},lookup_addr(t){return ie.address_map.names[t]?ie.address_map.names[t]:null}},ht=(t,s)=>{var i=_t(t,s);if(i.errno)throw new Je.ErrnoError(i.errno);return i.addr=ie.lookup_addr(i.addr)||i.addr,i},pr=9007199254740992,mr=-9007199254740992,me=t=>t<mr||t>pr?NaN:Number(t);function gr(t,s,i,c,h,g){s>>>=0,i>>>=0;var w=De(t),E=ht(s,i);return w.sock_ops.bind(w,E.addr,E.port),0}function yr(t,s,i,c,h,g){s>>>=0,i>>>=0;var w=De(t),E=ht(s,i);return w.sock_ops.connect(w,E.addr,E.port),0}var wr=(t,s,i)=>{};function Er(t,s,i,c){s>>>=0}var bt=typeof TextDecoder<"u"?new TextDecoder:void 0,pt=(t,s=0,i=NaN)=>{s>>>=0;for(var c=s+i,h=s;t[h]&&!(h>=c);)++h;if(h-s>16&&t.buffer&&bt)return bt.decode(t.subarray(s,h));for(var g="";s<h;){var w=t[s++];if(!(w&128)){g+=String.fromCharCode(w);continue}var E=t[s++]&63;if((w&224)==192){g+=String.fromCharCode((w&31)<<6|E);continue}var k=t[s++]&63;if((w&240)==224?w=(w&15)<<12|E<<6|k:w=(w&7)<<18|E<<12|k<<6|t[s++]&63,w<65536)g+=String.fromCharCode(w);else{var H=w-65536;g+=String.fromCharCode(55296|H>>10,56320|H&1023)}}return g},z=(t,s)=>(t>>>=0,t?pt(p,t,s):""),Ye={varargs:void 0,getStr(t){var s=z(t);return s}};function vr(t,s,i){return i>>>=0,Ye.varargs=i,0}function Fr(t,s){s>>>=0}function Ar(t,s){s=me(s)}var mt=t=>{for(var s=0,i=0;i<t.length;++i){var c=t.charCodeAt(i);c<=127?s++:c<=2047?s+=2:c>=55296&&c<=57343?(s+=4,++i):s+=3}return s};r.lengthBytesUTF8=mt;var Sr=(t,s,i,c)=>{if(i>>>=0,!(c>0))return 0;for(var h=i,g=i+c-1,w=0;w<t.length;++w){var E=t.charCodeAt(w);if(E>=55296&&E<=57343){var k=t.charCodeAt(++w);E=65536+((E&1023)<<10)|k&1023}if(E<=127){if(i>=g)break;s[i++>>>0]=E}else if(E<=2047){if(i+1>=g)break;s[i++>>>0]=192|E>>6,s[i++>>>0]=128|E&63}else if(E<=65535){if(i+2>=g)break;s[i++>>>0]=224|E>>12,s[i++>>>0]=128|E>>6&63,s[i++>>>0]=128|E&63}else{if(i+3>=g)break;s[i++>>>0]=240|E>>18,s[i++>>>0]=128|E>>12&63,s[i++>>>0]=128|E>>6&63,s[i++>>>0]=128|E&63}}return s[i>>>0]=0,i-h},ge=(t,s,i)=>Sr(t,p,s,i);r.stringToUTF8=ge;function Rr(t,s){t>>>=0,s>>>=0}function Dr(t,s,i){s>>>=0,i>>>=0}var gt=(t,s)=>{p.fill(0,t,t+s)},Me=(t,s,i,c,h)=>{switch(s){case 2:i=xe(i),gt(t,16),h&&(S[h>>>2>>>0]=16),U[t>>>1>>>0]=s,S[t+4>>>2>>>0]=i,U[t+2>>>1>>>0]=_htons(c);break;case 10:i=ze(i),gt(t,28),h&&(S[h>>>2>>>0]=28),S[t>>>2>>>0]=s,S[t+8>>>2>>>0]=i[0],S[t+12>>>2>>>0]=i[1],S[t+16>>>2>>>0]=i[2],S[t+20>>>2>>>0]=i[3],U[t+2>>>1>>>0]=_htons(c);break;default:return 5}return 0};function kr(t,s,i,c,h,g){s>>>=0,i>>>=0;var w=De(t);if(!w.daddr)return-53;var E=Me(s,w.family,ie.lookup_name(w.daddr),w.dport,i);return 0}function Ir(t,s,i,c,h,g){s>>>=0,i>>>=0;var w=De(t),E=Me(s,w.family,ie.lookup_name(w.saddr||"0.0.0.0"),w.sport,i);return 0}function Ur(t,s,i,c,h,g){c>>>=0,h>>>=0;var w=De(t);return s===1&&i===4?(S[c>>>2>>>0]=w.error,S[h>>>2>>>0]=4,w.error=null,0):-50}function Tr(t,s,i){return i>>>=0,Ye.varargs=i,0}function Hr(t,s){t>>>=0,s>>>=0}function Pr(t,s,i){s>>>=0}function xr(t,s,i,c){s>>>=0,i>>>=0}function Br(t,s,i,c){s>>>=0,c>>>=0,Ye.varargs=c}function Mr(t,s,i){t>>>=0}function Lr(t,s,i,c,h,g){s>>>=0,i>>>=0,h>>>=0,g>>>=0;var w=De(t),E=w.sock_ops.recvmsg(w,i);if(!E)return 0;if(h)var k=Me(h,w.family,ie.lookup_name(E.addr),E.port,g);return p.set(E.buffer,s>>>0),E.buffer.byteLength}function Cr(t,s,i,c){s>>>=0,c>>>=0}function Or(t){t>>>=0}function Nr(t,s,i,c,h,g){s>>>=0,i>>>=0,h>>>=0,g>>>=0}var Wr=(t,s,i)=>{};function Gr(t,s){t>>>=0,s>>>=0}function Kr(t,s,i){t>>>=0,s>>>=0,i>>>=0}function $r(t,s,i){s>>>=0}var Xr=()=>he("");function yt(){he("missing function: _emval_call_method")}yt.stub=!0;function wt(){he("missing function: _emval_decref")}wt.stub=!0;function Et(){he("missing function: _emval_get_global")}Et.stub=!0;function vt(){he("missing function: _emval_get_method_caller")}vt.stub=!0;function Ft(){he("missing function: _emval_run_destructors")}Ft.stub=!0;var Vr=t=>t%4===0&&(t%100!==0||t%400===0),qr=[0,31,60,91,121,152,182,213,244,274,305,335],Jr=[0,31,59,90,120,151,181,212,243,273,304,334],jr=t=>{var s=Vr(t.getFullYear()),i=s?qr:Jr,c=i[t.getMonth()]+t.getDate()-1;return c};function zr(t,s){t=me(t),s>>>=0;var i=new Date(t*1e3);S[s>>>2>>>0]=i.getSeconds(),S[s+4>>>2>>>0]=i.getMinutes(),S[s+8>>>2>>>0]=i.getHours(),S[s+12>>>2>>>0]=i.getDate(),S[s+16>>>2>>>0]=i.getMonth(),S[s+20>>>2>>>0]=i.getFullYear()-1900,S[s+24>>>2>>>0]=i.getDay();var c=jr(i)|0;S[s+28>>>2>>>0]=c,S[s+36>>>2>>>0]=-(i.getTimezoneOffset()*60);var h=new Date(i.getFullYear(),0,1),g=new Date(i.getFullYear(),6,1).getTimezoneOffset(),w=h.getTimezoneOffset(),E=(g!=w&&i.getTimezoneOffset()==Math.min(w,g))|0;S[s+32>>>2>>>0]=E}function Yr(t,s,i,c,h,g,w){return t>>>=0,h=me(h),g>>>=0,w>>>=0,-52}function Qr(t,s,i,c,h,g){t>>>=0,s>>>=0,g=me(g)}var Zr=function(t,s,i,c){t>>>=0,s>>>=0,i>>>=0,c>>>=0;var h=new Date().getFullYear(),g=new Date(h,0,1),w=new Date(h,6,1),E=g.getTimezoneOffset(),k=w.getTimezoneOffset(),H=Math.max(E,k);$[t>>>2>>>0]=H*60,S[s>>>2>>>0]=+(E!=k);var L=V=>{var C=V>=0?"-":"+",v=Math.abs(V),te=String(Math.floor(v/60)).padStart(2,"0"),le=String(v%60).padStart(2,"0");return`UTC${C}${te}${le}`},y=L(E),K=L(k);k<E?(ge(y,i,17),ge(K,c,17)):(ge(y,c,17),ge(K,i,17))},At=()=>performance.now(),St=()=>Date.now(),en=1,tn=t=>t>=0&&t<=3;function rn(t,s,i){if(s=me(s),i>>>=0,!tn(t))return 28;var c;if(t===0)c=St();else if(en)c=At();else return 52;var h=Math.round(c*1e3*1e3);return G[i>>>3]=BigInt(h),0}function nn(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.createDirectory(r,t,s)}function sn(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.checkDirectory(r,t,s)}function an(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.listDirectoryEntries(r,t,s)}function on(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.removeDirectory(r,t,s)}function ln(t){return globalThis.DUCKDB_RUNTIME.closeFile(r,t)}function un(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.dropFile(r,t,s)}function cn(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.checkFile(r,t,s)}function dn(t,s,i,c){return t>>>=0,i>>>=0,globalThis.DUCKDB_RUNTIME.moveFile(r,t,s,i,c)}function fn(t,s){return globalThis.DUCKDB_RUNTIME.openFile(r,t,s)}function _n(t,s,i,c){return s>>>=0,globalThis.DUCKDB_RUNTIME.readFile(r,t,s,i,c)}function hn(t,s){return globalThis.DUCKDB_RUNTIME.truncateFile(r,t,s)}function bn(t,s,i,c){return s>>>=0,globalThis.DUCKDB_RUNTIME.writeFile(r,t,s,i,c)}function pn(t){return globalThis.DUCKDB_RUNTIME.getDefaultDataProtocol(t)}function mn(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.glob(r,t,s)}function gn(t){return globalThis.DUCKDB_RUNTIME.testPlatformFeature(r,t)}function yn(t,s,i,c,h,g){return t>>>=0,i>>>=0,h>>>=0,globalThis.DUCKDB_RUNTIME.callScalarUDF(r,t,s,i,c,h,g)}var Qe=[],wn=(t,s)=>{Qe.length=0;for(var i;i=p[t++>>>0];){var c=i!=105;c&=i!=112,s+=c&&s%8?4:0,Qe.push(i==112?$[s>>>2>>>0]:i==106?G[s>>>3]:i==105?S[s>>>2>>>0]:oe[s>>>3>>>0]),s+=c?8:4}return Qe},En=(t,s,i)=>{var c=wn(s,i);return fr[t](...c)};function vn(t,s,i){return t>>>=0,s>>>=0,i>>>=0,En(t,s,i)}var Rt=()=>4294901760;function Fn(){return Rt()}var An=(t,s)=>Math.ceil(t/s)*s,Sn=t=>{var s=I.buffer,i=(t-s.byteLength+65535)/65536|0;try{return I.grow(i),Se(),1}catch{}};function Rn(t){t>>>=0;var s=p.length,i=Rt();if(t>i)return!1;for(var c=1;c<=4;c*=2){var h=s*(1+.2/c);h=Math.min(h,t+100663296);var g=Math.min(i,An(Math.max(t,h),65536)),w=Sn(g);if(w)return!0}return!1}var Ze={},Dn=()=>R||"./this.program",He=()=>{if(!He.strings){var t=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",s={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:t,_:Dn()};for(var i in Ze)Ze[i]===void 0?delete s[i]:s[i]=Ze[i];var c=[];for(var i in s)c.push(`${i}=${s[i]}`);He.strings=c}return He.strings},kn=(t,s)=>{for(var i=0;i<t.length;++i)P[s++>>>0]=t.charCodeAt(i);P[s>>>0]=0},In=function(t,s){t>>>=0,s>>>=0;var i=0;return He().forEach((c,h)=>{var g=s+i;$[t+h*4>>>2>>>0]=g,kn(c,g),i+=c.length+1}),0},Un=function(t,s){t>>>=0,s>>>=0;var i=He();$[t>>>2>>>0]=i.length;var c=0;return i.forEach(h=>c+=h.length+1),$[s>>>2>>>0]=c,0},Tn=0,Hn=()=>br||Tn>0,Pn=t=>{var s;D=t,Hn()||((s=r.onExit)==null||s.call(r,t),m=!0),M(t,new ot(t))},Dt=(t,s)=>{D=t,Pn(t)},xn=Dt,Bn=t=>52;function Mn(t,s){s>>>=0;var i=0,c=0,h=0;{var g=2;t==0?i=2:(t==1||t==2)&&(i=64),h=1}return P[s>>>0]=g,U[s+2>>>1>>>0]=h,G[s+8>>>3]=BigInt(i),G[s+16>>>3]=BigInt(c),0}function Ln(t,s,i,c,h){return s>>>=0,i>>>=0,c=me(c),h>>>=0,52}function Cn(t,s,i,c,h){return s>>>=0,i>>>=0,c=me(c),h>>>=0,52}function On(t,s,i,c){return s>>>=0,i>>>=0,c>>>=0,52}function Nn(t,s,i,c){return s=me(s),c>>>=0,70}var Wn=t=>52,Gn=[null,[],[]],Kn=(t,s)=>{var i=Gn[t];s===0||s===10?((t===1?ne:b)(pt(i)),i.length=0):i.push(s)};function $n(t,s,i,c){s>>>=0,i>>>=0,c>>>=0;for(var h=0,g=0;g<i;g++){var w=$[s>>>2>>>0],E=$[s+4>>>2>>>0];s+=8;for(var k=0;k<E;k++)Kn(t,p[w+k>>>0]);h+=E}return $[c>>>2>>>0]=h,0}function Xn(t,s,i,c){t>>>=0,s>>>=0,i>>>=0,c>>>=0;var h=0,g=0,w=0,E=0,k=0,H=0,L;function y(K,V,C,v,te,le){var Z,we,be,Tt;return we=K===10?28:16,te=K===10?ft(te):je(te),Z=ye(we),Tt=Me(Z,K,te,le),F(!Tt),be=ye(32),S[be+4>>>2>>>0]=K,S[be+8>>>2>>>0]=V,S[be+12>>>2>>>0]=C,$[be+24>>>2>>>0]=v,$[be+20>>>2>>>0]=Z,K===10?S[be+16>>>2>>>0]=28:S[be+16>>>2>>>0]=16,S[be+28>>>2>>>0]=0,be}if(i&&(w=S[i>>>2>>>0],E=S[i+4>>>2>>>0],k=S[i+8>>>2>>>0],H=S[i+12>>>2>>>0]),k&&!H&&(H=k===2?17:6),!k&&H&&(k=H===17?2:1),H===0&&(H=6),k===0&&(k=1),!t&&!s)return-2;if(w&-1088||i!==0&&S[i>>>2>>>0]&2&&!t)return-1;if(w&32)return-2;if(k!==0&&k!==1&&k!==2)return-7;if(E!==0&&E!==2&&E!==10)return-6;if(s&&(s=z(s),g=parseInt(s,10),isNaN(g)))return w&1024?-2:-8;if(!t)return E===0&&(E=2),(w&1)===0&&(E===2?h=_htonl(2130706433):h=[0,0,0,_htonl(1)]),L=y(E,k,H,null,h,g),$[c>>>2>>>0]=L,0;if(t=z(t),h=xe(t),h!==null)if(E===0||E===2)E=2;else if(E===10&&w&8)h=[0,0,_htonl(65535),h],E=10;else return-2;else if(h=ze(t),h!==null)if(E===0||E===10)E=10;else return-2;return h!=null?(L=y(E,k,H,t,h,g),$[c>>>2>>>0]=L,0):w&4?-2:(t=ie.lookup_name(t),h=xe(t),E===0?E=2:E===10&&(h=[0,0,_htonl(65535),h]),L=y(E,k,H,null,h,g),$[c>>>2>>>0]=L,0)}function Vn(t,s,i,c,h,g,w){t>>>=0,i>>>=0,h>>>=0;var E=_t(t,s);if(E.errno)return-6;var k=E.port,H=E.addr,L=!1;if(i&&c){var y;if(w&1||!(y=ie.lookup_addr(H))){if(w&8)return-2}else H=y;var K=ge(H,i,c);K+1>=c&&(L=!0)}if(h&&g){k=""+k;var K=ge(k,h,g);K+1>=g&&(L=!0)}return L?-12:0}var qn=()=>{if(_){var t=["crypto"].map(Ht);return s=>t.randomFillSync(s)}return s=>crypto.getRandomValues(s)},kt=t=>{(kt=qn())(t)};function Jn(t,s){return t>>>=0,s>>>=0,kt(p.subarray(t>>>0,t+s>>>0)),0}var jn=t=>{if(t instanceof ot||t=="unwind")return D;M(1,t)},zn=t=>{var s=r["_"+t];return s},Yn=(t,s)=>{P.set(t,s>>>0)},Le=t=>os(t);r.stackAlloc=Le;var Qn=t=>{var s=mt(t)+1,i=Le(s);return ge(t,i,s),i},It=()=>ls(),Ut=t=>is(t),Zn=(t,s,i,c,h)=>{var g={string:C=>{var v=0;return C!=null&&C!==0&&(v=Qn(C)),v},array:C=>{var v=Le(C.length);return Yn(C,v),v}};function w(C){return s==="string"?z(C):s==="boolean"?!!C:C}var E=zn(t),k=[],H=0;if(c)for(var L=0;L<c.length;L++){var y=g[i[L]];y?(H===0&&(H=It()),k[L]=y(c[L])):k[L]=c[L]}var K=E(...k);function V(C){return H!==0&&Ut(H),w(C)}return K=V(K),K},es=t=>as(),ts=t=>ss(t),rs={X:gr,W:yr,A:wr,ja:Er,b:vr,ia:Fr,ca:Ar,ka:Rr,aa:Dr,R:kr,Q:Ir,U:Ur,i:Tr,fa:Hr,ba:Pr,ga:xr,s:Br,V:Mr,S:Lr,_:Cr,q:Or,T:Nr,p:Wr,ha:Gr,la:Kr,r:$r,qa:Xr,x:yt,y:wt,z:Et,w:vt,u:Ft,Y:zr,O:Yr,P:Qr,oa:Zr,ma:rn,G:nn,H:sn,E:an,F:on,m:ln,K:un,C:cn,D:dn,J:fn,g:_n,I:hn,h:bn,L:pn,B:mn,k:gn,N:yn,e:vn,j:St,na:Fn,c:At,ra:Rn,pa:In,t:Un,a:xn,d:Bn,M:Mn,ea:Ln,da:Cn,l:On,v:Nn,$:Wn,f:$n,o:Xn,n:Vn,Z:Jn},T=await dr(),ns=r._main=T.ua,Us=r._duckdb_web_fs_glob_add_path=T.wa,Ts=r._duckdb_web_clear_response=T.xa,Hs=r._duckdb_web_fail_with=T.ya,Ps=r._duckdb_web_reset=T.za,xs=r._duckdb_web_connect=T.Aa,Bs=r._duckdb_web_disconnect=T.Ba,Ms=r._duckdb_web_flush_files=T.Ca,Ls=r._duckdb_web_flush_file=T.Da,Cs=r._duckdb_web_open=T.Ea,Os=r._duckdb_web_get_global_file_info=T.Fa,Ns=r._duckdb_web_collect_file_stats=T.Ga,Ws=r._duckdb_web_export_file_stats=T.Ha,Gs=r._duckdb_web_fs_drop_file=T.Ia,Ks=r._duckdb_web_fs_drop_files=T.Ja,$s=r._duckdb_web_fs_glob_file_infos=T.Ka,Xs=r._duckdb_web_fs_get_file_info_by_id=T.La,Vs=r._duckdb_web_fs_get_file_info_by_name=T.Ma,qs=r._duckdb_web_fs_register_file_url=T.Na,Js=r._duckdb_web_fs_register_file_buffer=T.Oa,js=r._duckdb_web_copy_file_to_buffer=T.Pa,zs=r._duckdb_web_copy_file_to_path=T.Qa,Ys=r._duckdb_web_get_version=T.Ra,Qs=r._duckdb_web_get_feature_flags=T.Sa,Zs=r._duckdb_web_tokenize=T.Ta,ea=r._duckdb_web_tokenize_buffer=T.Ua,ta=r._duckdb_web_udf_scalar_create=T.Va,ra=r._duckdb_web_prepared_create=T.Wa,na=r._duckdb_web_prepared_create_buffer=T.Xa,sa=r._duckdb_web_prepared_close=T.Ya,aa=r._duckdb_web_prepared_run=T.Za,ia=r._duckdb_web_prepared_send=T._a,oa=r._duckdb_web_query_run=T.$a,la=r._duckdb_web_query_run_buffer=T.ab,ua=r._duckdb_web_pending_query_start=T.bb,ca=r._duckdb_web_pending_query_start_buffer=T.cb,da=r._duckdb_web_pending_query_poll=T.db,fa=r._duckdb_web_pending_query_cancel=T.eb,_a=r._duckdb_web_query_fetch_results=T.fb,ha=r._duckdb_web_get_tablenames=T.gb,ba=r._duckdb_web_get_tablenames_buffer=T.hb,pa=r._duckdb_web_insert_arrow_from_ipc_stream=T.ib,ma=r._duckdb_web_insert_csv_from_path=T.jb,ga=r._duckdb_web_insert_json_from_path=T.kb,ye=r._malloc=T.ob,ya=r._free=T.pb,wa=r._calloc=T.qb,ss=T.sb,as=T.tb,is=T.ub,os=T.vb,ls=T.wb;function us(t){t=Object.assign({},t);var s=h=>g=>h(g)>>>0,i=h=>(g,w)=>h(g,w)>>>0,c=h=>()=>h()>>>0;return t.ob=s(t.ob),t.qb=i(t.qb),t.vb=s(t.vb),t.wb=c(t.wb),t}r.stackSave=It,r.stackRestore=Ut,r.stackAlloc=Le,r.getTempRet0=es,r.setTempRet0=ts,r.ccall=Zn;function cs(){var t=ns,s=0,i=0;try{var c=t(s,i);return Dt(c,!0),c}catch(h){return jn(h)}}function et(){if(ve>0){Ue=et;return}if(Re(),ve>0){Ue=et;return}function t(){var i;if(r.calledRun=!0,!m){tr(),l(r),(i=r.onRuntimeInitialized)==null||i.call(r);var s=r.noInitialRun;s||cs(),rr()}}r.setStatus?(r.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>r.setStatus(""),1),t()},1)):t()}if(r.preInit)for(typeof r.preInit=="function"&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return et(),o=f,o}})();typeof $t=="object"&&typeof $e=="object"?($e.exports=at,$e.exports.default=at):typeof define=="function"&&define.amd&&define([],()=>at)});var qt=ke(()=>{});var Jt=ke(()=>{});var jt=ke((qa,qe)=>{(function(){"use strict";var a="input is invalid type",e=typeof window=="object",n=e?window:{};n.JS_SHA256_NO_WINDOW&&(e=!1);var o=!e&&typeof self=="object",r=!n.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node&&process.type!="renderer";r?n=global:o&&(n=self);var l=!n.JS_SHA256_NO_COMMON_JS&&typeof qe=="object"&&qe.exports,d=typeof define=="function"&&define.amd,f=!n.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),O=[-2147483648,8388608,32768,128],_=[24,16,8,0],N=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Y=["hex","array","digest","arrayBuffer"],R=[];(n.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(b){return Object.prototype.toString.call(b)==="[object Array]"}),f&&(n.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(b){return typeof b=="object"&&b.buffer&&b.buffer.constructor===ArrayBuffer});var M=function(b,A){return function(I){return new q(A,!0).update(I)[b]()}},X=function(b){var A=M("hex",b);r&&(A=Q(A,b)),A.create=function(){return new q(b)},A.update=function(D){return A.create().update(D)};for(var I=0;I<Y.length;++I){var m=Y[I];A[m]=M(m,b)}return A},Q=function(b,A){var I=qt(),m=Jt().Buffer,D=A?"sha224":"sha256",F;m.from&&!n.JS_SHA256_NO_BUFFER_FROM?F=m.from:F=function(p){return new m(p)};var P=function(p){if(typeof p=="string")return I.createHash(D).update(p,"utf8").digest("hex");if(p==null)throw new Error(a);return p.constructor===ArrayBuffer&&(p=new Uint8Array(p)),Array.isArray(p)||ArrayBuffer.isView(p)||p.constructor===m?I.createHash(D).update(F(p)).digest("hex"):b(p)};return P},re=function(b,A){return function(I,m){return new se(I,A,!0).update(m)[b]()}},J=function(b){var A=re("hex",b);A.create=function(D){return new se(D,b)},A.update=function(D,F){return A.create(D).update(F)};for(var I=0;I<Y.length;++I){var m=Y[I];A[m]=re(m,b)}return A};function q(b,A){A?(R[0]=R[16]=R[1]=R[2]=R[3]=R[4]=R[5]=R[6]=R[7]=R[8]=R[9]=R[10]=R[11]=R[12]=R[13]=R[14]=R[15]=0,this.blocks=R):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],b?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=b}q.prototype.update=function(b){if(!this.finalized){var A,I=typeof b;if(I!=="string"){if(I==="object"){if(b===null)throw new Error(a);if(f&&b.constructor===ArrayBuffer)b=new Uint8Array(b);else if(!Array.isArray(b)&&(!f||!ArrayBuffer.isView(b)))throw new Error(a)}else throw new Error(a);A=!0}for(var m,D=0,F,P=b.length,p=this.blocks;D<P;){if(this.hashed&&(this.hashed=!1,p[0]=this.block,this.block=p[16]=p[1]=p[2]=p[3]=p[4]=p[5]=p[6]=p[7]=p[8]=p[9]=p[10]=p[11]=p[12]=p[13]=p[14]=p[15]=0),A)for(F=this.start;D<P&&F<64;++D)p[F>>>2]|=b[D]<<_[F++&3];else for(F=this.start;D<P&&F<64;++D)m=b.charCodeAt(D),m<128?p[F>>>2]|=m<<_[F++&3]:m<2048?(p[F>>>2]|=(192|m>>>6)<<_[F++&3],p[F>>>2]|=(128|m&63)<<_[F++&3]):m<55296||m>=57344?(p[F>>>2]|=(224|m>>>12)<<_[F++&3],p[F>>>2]|=(128|m>>>6&63)<<_[F++&3],p[F>>>2]|=(128|m&63)<<_[F++&3]):(m=65536+((m&1023)<<10|b.charCodeAt(++D)&1023),p[F>>>2]|=(240|m>>>18)<<_[F++&3],p[F>>>2]|=(128|m>>>12&63)<<_[F++&3],p[F>>>2]|=(128|m>>>6&63)<<_[F++&3],p[F>>>2]|=(128|m&63)<<_[F++&3]);this.lastByteIndex=F,this.bytes+=F-this.start,F>=64?(this.block=p[16],this.start=F-64,this.hash(),this.hashed=!0):this.start=F}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},q.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var b=this.blocks,A=this.lastByteIndex;b[16]=this.block,b[A>>>2]|=O[A&3],this.block=b[16],A>=56&&(this.hashed||this.hash(),b[0]=this.block,b[16]=b[1]=b[2]=b[3]=b[4]=b[5]=b[6]=b[7]=b[8]=b[9]=b[10]=b[11]=b[12]=b[13]=b[14]=b[15]=0),b[14]=this.hBytes<<3|this.bytes>>>29,b[15]=this.bytes<<3,this.hash()}},q.prototype.hash=function(){var b=this.h0,A=this.h1,I=this.h2,m=this.h3,D=this.h4,F=this.h5,P=this.h6,p=this.h7,U=this.blocks,x,S,$,fe,G,_e,oe,pe,Ae,Se,Re;for(x=16;x<64;++x)G=U[x-15],S=(G>>>7|G<<25)^(G>>>18|G<<14)^G>>>3,G=U[x-2],$=(G>>>17|G<<15)^(G>>>19|G<<13)^G>>>10,U[x]=U[x-16]+S+U[x-7]+$<<0;for(Re=A&I,x=0;x<64;x+=4)this.first?(this.is224?(pe=300032,G=U[0]-1413257819,p=G-150054599<<0,m=G+24177077<<0):(pe=704751109,G=U[0]-210244248,p=G-1521486534<<0,m=G+143694565<<0),this.first=!1):(S=(b>>>2|b<<30)^(b>>>13|b<<19)^(b>>>22|b<<10),$=(D>>>6|D<<26)^(D>>>11|D<<21)^(D>>>25|D<<7),pe=b&A,fe=pe^b&I^Re,oe=D&F^~D&P,G=p+$+oe+N[x]+U[x],_e=S+fe,p=m+G<<0,m=G+_e<<0),S=(m>>>2|m<<30)^(m>>>13|m<<19)^(m>>>22|m<<10),$=(p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7),Ae=m&b,fe=Ae^m&A^pe,oe=p&D^~p&F,G=P+$+oe+N[x+1]+U[x+1],_e=S+fe,P=I+G<<0,I=G+_e<<0,S=(I>>>2|I<<30)^(I>>>13|I<<19)^(I>>>22|I<<10),$=(P>>>6|P<<26)^(P>>>11|P<<21)^(P>>>25|P<<7),Se=I&m,fe=Se^I&b^Ae,oe=P&p^~P&D,G=F+$+oe+N[x+2]+U[x+2],_e=S+fe,F=A+G<<0,A=G+_e<<0,S=(A>>>2|A<<30)^(A>>>13|A<<19)^(A>>>22|A<<10),$=(F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7),Re=A&I,fe=Re^A&m^Se,oe=F&P^~F&p,G=D+$+oe+N[x+3]+U[x+3],_e=S+fe,D=b+G<<0,b=G+_e<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+b<<0,this.h1=this.h1+A<<0,this.h2=this.h2+I<<0,this.h3=this.h3+m<<0,this.h4=this.h4+D<<0,this.h5=this.h5+F<<0,this.h6=this.h6+P<<0,this.h7=this.h7+p<<0},q.prototype.hex=function(){this.finalize();var b=this.h0,A=this.h1,I=this.h2,m=this.h3,D=this.h4,F=this.h5,P=this.h6,p=this.h7,U=u[b>>>28&15]+u[b>>>24&15]+u[b>>>20&15]+u[b>>>16&15]+u[b>>>12&15]+u[b>>>8&15]+u[b>>>4&15]+u[b&15]+u[A>>>28&15]+u[A>>>24&15]+u[A>>>20&15]+u[A>>>16&15]+u[A>>>12&15]+u[A>>>8&15]+u[A>>>4&15]+u[A&15]+u[I>>>28&15]+u[I>>>24&15]+u[I>>>20&15]+u[I>>>16&15]+u[I>>>12&15]+u[I>>>8&15]+u[I>>>4&15]+u[I&15]+u[m>>>28&15]+u[m>>>24&15]+u[m>>>20&15]+u[m>>>16&15]+u[m>>>12&15]+u[m>>>8&15]+u[m>>>4&15]+u[m&15]+u[D>>>28&15]+u[D>>>24&15]+u[D>>>20&15]+u[D>>>16&15]+u[D>>>12&15]+u[D>>>8&15]+u[D>>>4&15]+u[D&15]+u[F>>>28&15]+u[F>>>24&15]+u[F>>>20&15]+u[F>>>16&15]+u[F>>>12&15]+u[F>>>8&15]+u[F>>>4&15]+u[F&15]+u[P>>>28&15]+u[P>>>24&15]+u[P>>>20&15]+u[P>>>16&15]+u[P>>>12&15]+u[P>>>8&15]+u[P>>>4&15]+u[P&15];return this.is224||(U+=u[p>>>28&15]+u[p>>>24&15]+u[p>>>20&15]+u[p>>>16&15]+u[p>>>12&15]+u[p>>>8&15]+u[p>>>4&15]+u[p&15]),U},q.prototype.toString=q.prototype.hex,q.prototype.digest=function(){this.finalize();var b=this.h0,A=this.h1,I=this.h2,m=this.h3,D=this.h4,F=this.h5,P=this.h6,p=this.h7,U=[b>>>24&255,b>>>16&255,b>>>8&255,b&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255,I>>>24&255,I>>>16&255,I>>>8&255,I&255,m>>>24&255,m>>>16&255,m>>>8&255,m&255,D>>>24&255,D>>>16&255,D>>>8&255,D&255,F>>>24&255,F>>>16&255,F>>>8&255,F&255,P>>>24&255,P>>>16&255,P>>>8&255,P&255];return this.is224||U.push(p>>>24&255,p>>>16&255,p>>>8&255,p&255),U},q.prototype.array=q.prototype.digest,q.prototype.arrayBuffer=function(){this.finalize();var b=new ArrayBuffer(this.is224?28:32),A=new DataView(b);return A.setUint32(0,this.h0),A.setUint32(4,this.h1),A.setUint32(8,this.h2),A.setUint32(12,this.h3),A.setUint32(16,this.h4),A.setUint32(20,this.h5),A.setUint32(24,this.h6),this.is224||A.setUint32(28,this.h7),b};function se(b,A,I){var m,D=typeof b;if(D==="string"){var F=[],P=b.length,p=0,U;for(m=0;m<P;++m)U=b.charCodeAt(m),U<128?F[p++]=U:U<2048?(F[p++]=192|U>>>6,F[p++]=128|U&63):U<55296||U>=57344?(F[p++]=224|U>>>12,F[p++]=128|U>>>6&63,F[p++]=128|U&63):(U=65536+((U&1023)<<10|b.charCodeAt(++m)&1023),F[p++]=240|U>>>18,F[p++]=128|U>>>12&63,F[p++]=128|U>>>6&63,F[p++]=128|U&63);b=F}else if(D==="object"){if(b===null)throw new Error(a);if(f&&b.constructor===ArrayBuffer)b=new Uint8Array(b);else if(!Array.isArray(b)&&(!f||!ArrayBuffer.isView(b)))throw new Error(a)}else throw new Error(a);b.length>64&&(b=new q(A,!0).update(b).array());var x=[],S=[];for(m=0;m<64;++m){var $=b[m]||0;x[m]=92^$,S[m]=54^$}q.call(this,A,I),this.update(S),this.oKeyPad=x,this.inner=!0,this.sharedMemory=I}se.prototype=new q,se.prototype.finalize=function(){if(q.prototype.finalize.call(this),this.inner){this.inner=!1;var b=this.array();q.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(b),q.prototype.finalize.call(this)}};var ne=X();ne.sha256=ne,ne.sha224=X(!0),ne.sha256.hmac=J(),ne.sha224.hmac=J(!0),l?qe.exports=ne:(n.sha256=ne.sha256,n.sha224=ne.sha224,d&&define(function(){return ne}))})()});var ks={};ms(ks,{registerWorker:()=>er});var Ce=class{constructor(e,n){this._bindings=e,this._conn=n}close(){this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}query(e){return this._bindings.runQuery(this._conn,e)}async send(e,n=!1){let o=this._bindings.startPendingQuery(this._conn,e,n);for(;o==null;)o=await new Promise((r,l)=>{try{r(this._bindings.pollPendingQuery(this._conn))}catch(d){console.log(d),d.message.includes("worker is not set!")?l(new Error("Worker has been terminated")):l(d)}});return new Oe(this._bindings,this._conn,o)}cancelSent(){return this._bindings.cancelPendingQuery(this._conn)}getTableNames(e){return this._bindings.getTableNames(this._conn,e)}prepare(e){let n=this._bindings.createPrepared(this._conn,e);return new tt(this._bindings,this._conn,n)}insertArrowFromIPCStream(e,n){this._bindings.insertArrowFromIPCStream(this._conn,e,n)}insertCSVFromPath(e,n){this._bindings.insertCSVFromPath(this._conn,e,n)}insertJSONFromPath(e,n){this._bindings.insertJSONFromPath(this._conn,e,n)}},Oe=class{constructor(e,n,o){this.bindings=e;this.conn=n;this.header=o;this._first=!0,this._depleted=!1}next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e=null;do e=this.bindings.fetchQueryResults(this.conn);while(e==null);return this._depleted=e.length==0,{done:this._depleted,value:e}}[Symbol.iterator](){return this}},tt=class{constructor(e,n,o){this.bindings=e,this.connectionId=n,this.statementId=o}close(){this.bindings.closePrepared(this.connectionId,this.statementId)}query(...e){return this.bindings.runPrepared(this.connectionId,this.statementId,e)}send(...e){let n=this.bindings.sendPrepared(this.connectionId,this.statementId,e);return new Oe(this.bindings,this.connectionId,n)}};function Mt(a){return a<=255}function Lt(a){return a===256}var Nt=new TextEncoder,Ct=new TextDecoder("utf-8");function rt(a,e,n){let o=Nt.encode(n),r=a._malloc(o.byteLength),l=a.HEAPU8.subarray(r,r+o.byteLength);l.set(o),a.HEAPF64[(e>>3)+0]=1,a.HEAPF64[(e>>3)+1]=r,a.HEAPF64[(e>>3)+2]=l.byteLength}function st(a){switch(a){case"UINT8":case"INT8":return 1;case"INT32":case"FLOAT":return 4;case"INT64":case"UINT64":case"DOUBLE":case"VARCHAR":return 8;default:return 0}}function nt(a,e,n,o){let r=a.HEAPU8.subarray(e,e+o*st(n));switch(n){case"UINT8":return new Uint8Array(r.buffer,r.byteOffset,o);case"INT8":return new Int8Array(r.buffer,r.byteOffset,o);case"INT32":return new Int32Array(r.buffer,r.byteOffset,o);case"FLOAT":return new Float32Array(r.buffer,r.byteOffset,o);case"DOUBLE":return new Float64Array(r.buffer,r.byteOffset,o);case"VARCHAR":return new Float64Array(r.buffer,r.byteOffset,o);default:return new Array(0)}}function Ot(a,e,n){let o=a.HEAPU8.subarray(e,e+n);return new Uint8Array(o.buffer,o.byteOffset,n)}function Ne(a,e,n){let o=a.HEAPU8.subarray(e,e+n*8);return new Float64Array(o.buffer,o.byteOffset,n)}function Wt(a,e,n,o,r,l,d,f){try{let u=a._udfFunctions.get(o);if(!u){rt(e,n,"Unknown UDF with id: "+o);return}let O=Ct.decode(e.HEAPU8.subarray(r,r+l)),_=JSON.parse(O),N=Ne(e,d,f/8),Y=m=>{var F;let D=null;switch(m.validityBuffer!==void 0&&(D=Ot(e,N[m.validityBuffer],_.rows)),m.physicalType){case"VARCHAR":{if(m.dataBuffer===null||m.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for VARCHAR argument");if(m.lengthBuffer===null||m.lengthBuffer===void 0)throw new Error("malformed data view, expected data length buffer for VARCHAR argument");let P=nt(e,N[m.dataBuffer],m.physicalType,_.rows),p=[],U=Ne(e,N[m.lengthBuffer],_.rows);for(let x=0;x<_.rows;++x){if(D!=null&&!D[x]){p.push(null);continue}let S=e.HEAPU8.subarray(P[x],P[x]+U[x]),$=Ct.decode(S);p.push($)}return x=>p[x]}case"STRUCT":{let P={},p=[];for(let U=0;U<(((F=m.children)==null?void 0:F.length)||0);++U){let x=m.children[U],S=Y(x);p.push($=>{P[x.name]=S($)})}return D!=null?U=>{if(!D[U])return null;for(let x of p)x(U);return P}:U=>{for(let x of p)x(U);return P}}default:{if(m.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for argument of type: "+m.physicalType);let P=nt(e,N[m.dataBuffer],m.physicalType,_.rows);return D!=null?p=>D[p]?P[p]:null:p=>P[p]}}},R=[];for(let m=0;m<_.args.length;++m)R.push(Y(_.args[m]));let M=_.rows*st(_.ret.physicalType),X=e._malloc(M),Q=nt(e,X,_.ret.physicalType,_.rows),re=e._malloc(_.rows),J=Ot(e,re,_.rows);if(Q.length==0||J.length==0){rt(e,n,"Can't create physical arrays for result");return}let q=Q;_.ret.physicalType=="VARCHAR"&&(q=new Array(_.rows));let se=[];for(let m=0;m<_.args.length;++m)se.push(null);for(let m=0;m<_.rows;++m){for(let F=0;F<_.args.length;++F)se[F]=R[F](m);let D=u.func(...se);q[m]=D,J[m]=D==null?0:1}let ne=0;switch(_.ret.physicalType){case"VARCHAR":{let m=new Array(0);ne=e._malloc(_.rows*st("DOUBLE"));let D=Ne(e,ne,_.rows),F=0;for(let x=0;x<_.rows;++x){let S=Nt.encode(q[x]||"");m.push(S),D[x]=S.length,F+=S.length}let P=e._malloc(F),p=e.HEAPU8.subarray(P,P+F),U=0;for(let x=0;x<_.rows;++x){Q[x]=U;let S=m[x];p.subarray(U,U+S.length).set(S),U+=S.length}}}let b=3*8,A=e._malloc(b),I=Ne(e,A,3);I[0]=X,I[1]=re,I[2]=ne,e.HEAPF64[(n>>3)+0]=0,e.HEAPF64[(n>>3)+1]=A,e.HEAPF64[(n>>3)+2]=0}catch(u){rt(e,n,u.toString())}}function ws(){let a=new TextDecoder;return e=>(typeof SharedArrayBuffer<"u"&&e.buffer instanceof SharedArrayBuffer&&(e=new Uint8Array(e)),a.decode(e))}var Es=ws();function ue(a,e){console.error(`FAIL WITH: ${e}`),a.ccall("duckdb_web_fail_with",null,["string"],[e])}function Fe(a,e,n){let o=new Uint8Array(a.HEAPU8.buffer,e,n),r=new Uint8Array(new ArrayBuffer(o.byteLength));return r.set(o),r}function W(a,e,n){return Es(new Uint8Array(a.HEAPU8.buffer,e,n))}function j(a,e,n,o){let r=a.stackSave(),l=a.stackAlloc(3*8);n.unshift("number"),o.unshift(l),a.ccall(e,null,n,o);let d=a.HEAPF64[(l>>3)+0],f=a.HEAPF64[(l>>3)+1],u=a.HEAPF64[(l>>3)+2];return a.stackRestore(r),[d,f,u]}function ee(a){a.ccall("duckdb_web_clear_response",null,[],[])}var We=class{constructor(e){let n=new Float64Array(e.buffer,e.byteOffset,e.byteLength/8),o=new Uint8Array(new ArrayBuffer(e.byteLength));o.set(e.subarray(7*8)),this.totalFileReadsCold=n[0],this.totalFileReadsAhead=n[1],this.totalFileReadsCached=n[2],this.totalFileWrites=n[3],this.totalPageAccesses=n[4],this.totalPageLoads=n[5],this.blockSize=n[6],this.blockStats=o}getBlockStats(e,n){return n=n||{file_reads_cold:0,file_reads_ahead:0,file_reads_cached:0,file_writes:0,page_accesses:0,page_loads:0},n.file_writes=this.blockStats[e*3+0]&15,n.file_reads_cold=this.blockStats[e*3+0]>>4,n.file_reads_ahead=this.blockStats[e*3+1]&15,n.file_reads_cached=this.blockStats[e*3+1]>>4,n.page_accesses=this.blockStats[e*3+1]&15,n.page_loads=this.blockStats[e*3+1]>>4,n}};var Ie=new TextEncoder;function ae(a){return a!==0}var Ge=class{constructor(e,n){this._instance=null;this._initPromise=null;this._initPromiseResolver=()=>{};this.onInstantiationProgress=[];this._logger=e,this._runtime=n,this._nextUDFId=1}get logger(){return this._logger}get mod(){return this._instance}get pthread(){return this.mod.PThread||null}async instantiate(e=n=>{}){return this._instance!=null?this:(this._initPromise!=null&&(this.onInstantiationProgress.push(e),await this._initPromise),this._initPromise=new Promise(n=>{this._initPromiseResolver=n}),this.onInstantiationProgress=[e],this._instance=await this.instantiateImpl({print:console.log.bind(console),printErr:console.log.bind(console),onRuntimeInitialized:this._initPromiseResolver}),await this._initPromise,this._initPromise=null,this.onInstantiationProgress=this.onInstantiationProgress.filter(n=>n!=e),globalThis.DUCKDB_BINDINGS=this,this)}open(e){let[n,o,r]=j(this.mod,"duckdb_web_open",["string"],[JSON.stringify(e)]);if(n!==0)throw new Error(W(this.mod,o,r));ee(this.mod)}reset(){let[e,n,o]=j(this.mod,"duckdb_web_reset",[],[]);if(e!==0)throw new Error(W(this.mod,n,o));ee(this.mod)}getVersion(){let[e,n,o]=j(this.mod,"duckdb_web_get_version",[],[]);if(e!==0)throw new Error(W(this.mod,n,o));let r=W(this.mod,n,o);return ee(this.mod),r}getFeatureFlags(){return this.mod.ccall("duckdb_web_get_feature_flags","number",[],[])}tokenize(e){let n=Ie.encode(e),o=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,o,n.length).set(n);let[l,d,f]=j(this.mod,"duckdb_web_tokenize_buffer",["number","number"],[o,n.length]);if(this.mod._free(o),l!==0)throw new Error(W(this.mod,d,f));let u=W(this.mod,d,f);return ee(this.mod),JSON.parse(u)}connect(){let e=this.mod.ccall("duckdb_web_connect","number",[],[]);return new Ce(this,e)}disconnect(e){if(this.mod.ccall("duckdb_web_disconnect",null,["number"],[e]),this.pthread)for(let n of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])n.postMessage({cmd:"dropUDFFunctions",connectionId:e})}runQuery(e,n){let o=Ie.encode(n),r=this.mod._malloc(o.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,o.length).set(o);let[d,f,u]=j(this.mod,"duckdb_web_query_run_buffer",["number","number","number"],[e,r,o.length]);if(this.mod._free(r),d!==0)throw new Error(W(this.mod,f,u));let O=Fe(this.mod,f,u);return ee(this.mod),O}startPendingQuery(e,n,o=!1){let r=Ie.encode(n),l=this.mod._malloc(r.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,l,r.length).set(r);let[f,u,O]=j(this.mod,"duckdb_web_pending_query_start_buffer",["number","number","number","boolean"],[e,l,r.length,o]);if(this.mod._free(l),f!==0)throw new Error(W(this.mod,u,O));if(u==0)return null;let _=Fe(this.mod,u,O);return ee(this.mod),_}pollPendingQuery(e){let[n,o,r]=j(this.mod,"duckdb_web_pending_query_poll",["number"],[e]);if(n!==0)throw new Error(W(this.mod,o,r));if(o==0)return null;let l=Fe(this.mod,o,r);return ee(this.mod),l}cancelPendingQuery(e){return this.mod.ccall("duckdb_web_pending_query_cancel","boolean",["number"],[e])}fetchQueryResults(e){let[n,o,r]=j(this.mod,"duckdb_web_query_fetch_results",["number"],[e]);if(Lt(n))return ee(this.mod),null;if(!Mt(n))throw new Error("Unexpected StatusCode from duckdb_web_query_fetch_results ("+n+") and with self reported error as"+W(this.mod,o,r));if(n!==0)throw new Error(W(this.mod,o,r));let l=Fe(this.mod,o,r);return ee(this.mod),l}getTableNames(e,n){let o=Ie.encode(n),r=this.mod._malloc(o.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,o.length).set(o);let[d,f,u]=j(this.mod,"duckdb_web_get_tablenames_buffer",["number","number","number"],[e,r,o.length]);if(this.mod._free(r),d!==0)throw new Error(W(this.mod,f,u));let O=W(this.mod,f,u);return ee(this.mod),JSON.parse(O)}createPrepared(e,n){let o=Ie.encode(n),r=this.mod._malloc(o.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,o.length).set(o);let[d,f,u]=j(this.mod,"duckdb_web_prepared_create_buffer",["number","number","number"],[e,r,o.length]);if(this.mod._free(r),ae(d))throw new Error(W(this.mod,f,u));return ee(this.mod),f}closePrepared(e,n){let[o,r,l]=j(this.mod,"duckdb_web_prepared_close",["number","number"],[e,n]);if(ae(o))throw new Error(W(this.mod,r,l));ee(this.mod)}runPrepared(e,n,o){let[r,l,d]=j(this.mod,"duckdb_web_prepared_run",["number","number","string"],[e,n,JSON.stringify(o)]);if(ae(r))throw new Error(W(this.mod,l,d));let f=Fe(this.mod,l,d);return ee(this.mod),f}sendPrepared(e,n,o){let[r,l,d]=j(this.mod,"duckdb_web_prepared_send",["number","number","string"],[e,n,JSON.stringify(o)]);if(ae(r))throw new Error(W(this.mod,l,d));let f=Fe(this.mod,l,d);return ee(this.mod),f}insertArrowFromIPCStream(e,n,o){if(n.length==0)return;let r=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,n.length).set(n);let d=o?JSON.stringify(o):"",[f,u,O]=j(this.mod,"duckdb_web_insert_arrow_from_ipc_stream",["number","number","number","string"],[e,r,n.length,d]);if(this.mod._free(r),f!==0)throw new Error(W(this.mod,u,O))}insertCSVFromPath(e,n,o){let r=JSON.stringify(o),[l,d,f]=j(this.mod,"duckdb_web_insert_csv_from_path",["number","string","string"],[e,n,r]);if(ae(l))throw new Error(W(this.mod,d,f))}insertJSONFromPath(e,n,o){let r=JSON.stringify(o),[l,d,f]=j(this.mod,"duckdb_web_insert_json_from_path",["number","string","string"],[e,n,r]);if(ae(l))throw new Error(W(this.mod,d,f))}globFiles(e){let[n,o,r]=j(this.mod,"duckdb_web_fs_glob_file_infos",["string"],[e]);if(ae(n))throw new Error(W(this.mod,o,r));let l=W(this.mod,o,r);ee(this.mod);let d=JSON.parse(l);return d==null?[]:d}registerFileURL(e,n,o,r=!1){n===void 0&&(n=e);let[l,d,f]=j(this.mod,"duckdb_web_fs_register_file_url",["string","string"],[e,n,o,r]);if(ae(l))throw new Error(W(this.mod,d,f));ee(this.mod)}registerFileText(e,n){let o=Ie.encode(n);this.registerFileBuffer(e,o)}registerFileBuffer(e,n){let o=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,o,n.length).set(n);let[l,d,f]=j(this.mod,"duckdb_web_fs_register_file_buffer",["string","number","number"],[e,o,n.length]);if(ae(l))throw new Error(W(this.mod,d,f));ee(this.mod)}async prepareFileHandle(e,n){if(n===3&&this._runtime.prepareFileHandles){let o=await this._runtime.prepareFileHandles([e],3);for(let r of o){let{handle:l,path:d,fromCached:f}=r;!f&&l.getSize()&&await this.registerFileHandleAsync(d,l,3,!0)}return}throw new Error(`prepareFileHandle: unsupported protocol ${n}`)}async prepareDBFileHandle(e,n){if(n===3&&this._runtime.prepareDBFileHandle){let o=await this._runtime.prepareDBFileHandle(e,3);for(let r of o){let{handle:l,path:d,fromCached:f}=r;!f&&l.getSize()&&await this.registerFileHandleAsync(d,l,3,!0)}return}throw new Error(`prepareDBFileHandle: unsupported protocol ${n}`)}async prepareFileHandleAsync(e,n,o,r){if(o===3&&!(n instanceof FileSystemSyncAccessHandle)){if(n instanceof FileSystemFileHandle){let l=n;try{n=await l.createSyncAccessHandle()}catch(d){throw new Error(d.message+":"+e)}}else if(e!=null)try{n=await(await(await navigator.storage.getDirectory()).getFileHandle(e)).createSyncAccessHandle()}catch(l){throw new Error(l.message+":"+e)}}return n}async registerFileHandleAsync(e,n,o,r){let l=await this.prepareFileHandleAsync(e,n,o,r);this.registerFileHandle(e,l,o,r)}registerFileHandle(e,n,o,r){var u;let[l,d,f]=j(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[e,e,o,r]);if(ae(l))throw new Error(W(this.mod,d,f));if(ee(this.mod),globalThis.DUCKDB_RUNTIME._files=(globalThis.DUCKDB_RUNTIME._files||new Map).set(e,n),(u=globalThis.DUCKDB_RUNTIME._preparedHandles)!=null&&u[e]&&delete globalThis.DUCKDB_RUNTIME._preparedHandles[e],this.pthread){for(let O of this.pthread.runningWorkers)O.postMessage({cmd:"registerFileHandle",fileName:e,fileHandle:n});for(let O of this.pthread.unusedWorkers)O.postMessage({cmd:"dropFileHandle",fileName:e})}}dropFile(e){let[n,o,r]=j(this.mod,"duckdb_web_fs_drop_file",["string"],[e]);if(ae(n))throw new Error(W(this.mod,o,r));ee(this.mod)}dropFiles(e){let n=[],o=-1;try{for(let f of e!=null?e:[])if(f!=null&&f.length>0){let u=this.mod.lengthBytesUTF8(f)+1,O=this.mod._malloc(u)>>>0;if(!O)throw new Error(`Failed to allocate memory for string: ${f}`);this.mod.stringToUTF8(f,O,u),n.push(O)}if(o=this.mod._malloc(n.length*4)>>>0,!o)throw new Error("Failed to allocate memory for pointers array");for(let f=0;f<n.length;f++)this.mod.HEAP32[(o>>2)+f]=n[f];let[r,l,d]=j(this.mod,"duckdb_web_fs_drop_files",["number","number"],[o,n.length]);if(r!==0)throw new Error(W(this.mod,l,d));ee(this.mod)}finally{for(let r of n)this.mod._free(r);o>0&&this.mod._free(o)}}flushFiles(){this.mod.ccall("duckdb_web_flush_files",null,[],[])}copyFileToPath(e,n){let[o,r,l]=j(this.mod,"duckdb_web_copy_file_to_path",["string","string"],[e,n]);if(ae(o))throw new Error(W(this.mod,r,l));ee(this.mod)}copyFileToBuffer(e){let[n,o,r]=j(this.mod,"duckdb_web_copy_file_to_buffer",["string"],[e]);if(ae(n))throw new Error(W(this.mod,o,r));let l=new Uint8Array(this.mod.HEAPU8.buffer,o,r),d=new Uint8Array(l.length);return d.set(l),ee(this.mod),d}async registerOPFSFileName(e){if(e.startsWith("opfs://"))return this.prepareFileHandle(e,3);throw new Error("Not an OPFS file name: "+e)}collectFileStatistics(e,n){let[o,r,l]=j(this.mod,"duckdb_web_collect_file_stats",["string","boolean"],[e,n]);if(ae(o))throw new Error(W(this.mod,r,l))}exportFileStatistics(e){let[n,o,r]=j(this.mod,"duckdb_web_export_file_stats",["string"],[e]);if(ae(n))throw new Error(W(this.mod,o,r));return new We(new Uint8Array(this.mod.HEAPU8.buffer,o,r))}};var Ke=class{constructor(){this._bindings=null;this._nextMessageId=0}log(e){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:e},[])}sendOK(e){this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"OK",data:null},[])}failWith(e,n){let o={name:n.name,message:n.message,stack:n.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"ERROR",data:o},[])}async onMessage(e){switch(e.type){case"PING":this.sendOK(e);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(e,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(e.data[0],e.data[1],n=>{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"INSTANTIATE_PROGRESS",data:n},[])}),this.sendOK(e)}catch(n){console.log(n),this._bindings=null,this.failWith(e,n)}return;default:break}if(!this._bindings)return this.failWith(e,new Error("duckdb is not initialized"));try{switch(e.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(e);break;case"OPEN":{let n=e.data.path,o=!!(this._bindings.getFeatureFlags()&2);if(n!=null&&n.startsWith("opfs://")&&!o){let r=globalThis.DUCKDB_RUNTIME;r!=null&&r.prepareDBFileHandle&&await r.prepareDBFileHandle(n,3),e.data.useDirectIO=!0}this._bindings.open(e.data),this.sendOK(e);break}case"DROP_FILE":this._bindings.dropFile(e.data),this.sendOK(e);break;case"DROP_FILES":this._bindings.dropFiles(e.data),this.sendOK(e);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(e);break;case"CONNECT":{let n=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"CONNECTION_INFO",data:n.useUnsafe((o,r)=>r)},[]);break}case"DISCONNECT":this._bindings.disconnect(e.data),this.sendOK(e);break;case"CREATE_PREPARED":{let n=this._bindings.createPrepared(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"PREPARED_STATEMENT_ID",data:n},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(e.data[0],e.data[1]),this.sendOK(e);break}case"RUN_PREPARED":{let n=this._bindings.runPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:n},[n.buffer]);break}case"RUN_QUERY":{let n=this._bindings.runQuery(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:n},[n.buffer]);break}case"SEND_PREPARED":{let n=this._bindings.sendPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER",data:n},[n.buffer]);break}case"START_PENDING_QUERY":{let n=this._bindings.startPendingQuery(e.data[0],e.data[1],e.data[2]),o=[];n&&o.push(n.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:n},o);break}case"POLL_PENDING_QUERY":{let n=this._bindings.pollPendingQuery(e.data),o=[];n&&o.push(n.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:n},o);break}case"CANCEL_PENDING_QUERY":{let n=this._bindings.cancelPendingQuery(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SUCCESS",data:n},[]);break}case"FETCH_QUERY_RESULTS":{let n=this._bindings.fetchQueryResults(e.data),o=n?[n.buffer]:[];this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_CHUNK",data:n},o);break}case"GET_TABLE_NAMES":{let n=this._bindings.getTableNames(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"TABLE_NAMES",data:n},[]);break}case"GLOB_FILE_INFOS":{let n=this._bindings.globFiles(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_INFOS",data:n},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_FILE_HANDLE":await this._bindings.registerFileHandleAsync(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(e.data[0],e.data[1]),this.sendOK(e);break;case"COPY_FILE_TO_BUFFER":{let n=this._bindings.copyFileToBuffer(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_BUFFER",data:n},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_OPFS_FILE_NAME":await this._bindings.registerOPFSFileName(e.data[0]),this.sendOK(e);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(e.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"TOKENIZE":{let n=this._bindings.tokenize(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SCRIPT_TOKENS",data:n},[]);break}}}catch(n){return console.log(n),this.failWith(e,n)}}};var Vt=xt(Xt());var Xe=class extends Ge{constructor(e,n,o,r){super(e,n),this.mainModuleURL=o,this.pthreadWorkerURL=r}locateFile(e,n){if(e.endsWith(".wasm"))return this.mainModuleURL;if(e.endsWith(".worker.js")){if(!this.pthreadWorkerURL)throw new Error("Missing DuckDB worker URL!");return this.pthreadWorkerURL}throw new Error(`WASM instantiation requested unexpected file: prefix=${n} path=${e}`)}instantiateWasm(e,n){globalThis.DUCKDB_RUNTIME=this._runtime;let o=this.onInstantiationProgress;if(WebAssembly.instantiateStreaming)if(typeof TransformStream=="function"){let l=(async()=>{var M;let d=new Request(this.mainModuleURL),f=await fetch(d),u=f.headers.get("content-length"),O=u&&parseInt(u,10)||0,_=new Date,N={startedAt:_,updatedAt:_,bytesTotal:O||0,bytesLoaded:0},Y={transform(X,Q){N.bytesLoaded+=X.byteLength;let re=new Date;if(re.getTime()-N.updatedAt.getTime()<20){N.updatedAt=re,Q.enqueue(X);return}for(let J of o)J(N);Q.enqueue(X)}},R=new TransformStream(Y);return new Response((M=f.body)==null?void 0:M.pipeThrough(R),f)})();WebAssembly.instantiateStreaming(l,e).then(d=>{n(d.instance,d.module)})}else{console.warn("instantiating without progress handler since transform streams are unavailable");let r=new Request(this.mainModuleURL);WebAssembly.instantiateStreaming(fetch(r),e).then(l=>{n(l.instance,l.module)})}else if(typeof XMLHttpRequest=="function"){let r=new XMLHttpRequest,l=this.mainModuleURL,d=new Date,f={startedAt:d,updatedAt:d,bytesTotal:0,bytesLoaded:0};r.open("GET",l),r.responseType="arraybuffer",r.onerror=u=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to load WASM: "+u}),new Error(u.toString())},r.onprogress=u=>{f.bytesTotal=u.total,f.bytesLoaded=u.loaded;let O=new Date;if(O.getTime()-f.updatedAt.getTime()<20){f.updatedAt=O;return}for(let _ of o)_(f)},r.onload=()=>{WebAssembly.instantiate(r.response,e).then(u=>{n(u.instance,u.module)}).catch(u=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to instantiate WASM: "+u}),new Error(u)})},r.send()}else console.warn("instantiating with manual fetch since streaming instantiation and xhrs are unavailable"),(async()=>{let l=new Request(this.mainModuleURL),f=await(await fetch(l)).arrayBuffer();WebAssembly.instantiate(f,e).then(u=>{n(u.instance,u.module)})})();return{}}};var Ve=class extends Xe{constructor(e,n,o,r=null){super(e,n,o,r)}instantiateImpl(e){return(0,Vt.default)({...e,instantiateWasm:this.instantiateWasm.bind(this),locateFile:this.locateFile.bind(this)})}};var Ee=xt(jt()),zt=function(a,e,n){var o;if((o=a==null?void 0:a.endpoint)!=null&&o.startsWith("http")){let r=`${a==null?void 0:a.endpoint}`,l=r.indexOf("://")+3;return r.substring(l)}else return a!=null&&a.endpoint?`${n}.${a==null?void 0:a.endpoint}`:`${n}.s3.amazonaws.com`};function Fs(a,e,n){var l,d,f,u;let o=Yt(e),r=o.path;return Qt(a)&&(r=`/${o.bucket}${r}`),{url:r,query:"",host:zt(a,e,o.bucket),region:(l=a==null?void 0:a.region)!=null?l:"",service:"s3",method:n,accessKeyId:(d=a==null?void 0:a.accessKeyId)!=null?d:"",secretAccessKey:(f=a==null?void 0:a.secretAccessKey)!=null?f:"",sessionToken:(u=a==null?void 0:a.sessionToken)!=null?u:"",dateNow:new Date().toISOString().replace(/-/g,"").split("T")[0],datetimeNow:new Date().toISOString().replace(/-/g,"").replace(/:/g,"").split(".")[0]+"Z"}}function As(a,e=!1){let n="0123456789ABCDEF",o="";for(let r=0;r<a.length;r++){let l=a[r];l>="A"&&l<="Z"||l>="a"&&l<="z"||l>="0"&&l<="9"||l=="_"||l=="-"||l=="~"||l=="."?o+=l:l=="/"?e?o+="%2F":o+=l:(o+="%",o+=n[l.charCodeAt(0)>>4],o+=n[l.charCodeAt(0)&15])}return o}function Ss(a,e=null){var M;let n=(M=e==null?void 0:e.contentHash)!=null?M:"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",o=new Map;o.set("x-amz-date",a.datetimeNow),o.set("x-amz-content-sha256",n),a.sessionToken&&o.set("x-amz-security-token",a.sessionToken);let r="";e!=null&&e.contentType&&(r+="content-type;"),r+="host;x-amz-content-sha256;x-amz-date",a.sessionToken&&(r+=";x-amz-security-token");let l=a.method+`
2
- `+As(a.url)+`
1
+ "use strict";var duckdb=(()=>{var fs=Object.create;var xe=Object.defineProperty;var _s=Object.getOwnPropertyDescriptor;var hs=Object.getOwnPropertyNames;var bs=Object.getPrototypeOf,ps=Object.prototype.hasOwnProperty;var ms=(a,e,n)=>e in a?xe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[e]=n;var Pt=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var ke=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports),gs=(a,e)=>{for(var n in e)xe(a,n,{get:e[n],enumerable:!0})},xt=(a,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of hs(e))!ps.call(a,r)&&r!==n&&xe(a,r,{get:()=>e[r],enumerable:!(o=_s(e,r))||o.enumerable});return a};var Bt=(a,e,n)=>(n=a!=null?fs(bs(a)):{},xt(e||!a||!a.__esModule?xe(n,"default",{value:a,enumerable:!0}):n,a)),ys=a=>xt(xe({},"__esModule",{value:!0}),a);var Mt=(a,e,n)=>ms(a,typeof e!="symbol"?e+"":e,n);var Kt=ke(()=>{});var $t=ke(()=>{});var Vt=ke((Xt,Xe)=>{"use strict";var it=(()=>{var e;var a=typeof document<"u"?(e=document.currentScript)==null?void 0:e.src:void 0;return typeof __filename<"u"&&(a=a||__filename),async function(n={}){var o,r=n,l,d,f=new Promise((t,s)=>{l=t,d=s}),u=typeof window=="object",O=typeof WorkerGlobalScope<"u",_=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer",N=Object.assign({},r),Y=[],R="./this.program",M=(t,s)=>{throw s},X="";function Q(t){return r.locateFile?r.locateFile(t,X):X+t}var re,J;if(_){var q=Kt(),se=$t();X=__dirname+"/",J=t=>{t=Ae(t)?new URL(t):t;var s=q.readFileSync(t);return s},re=async(t,s=!0)=>{t=Ae(t)?new URL(t):t;var i=q.readFileSync(t,s?void 0:"utf8");return i},!r.thisProgram&&process.argv.length>1&&(R=process.argv[1].replace(/\\/g,"/")),Y=process.argv.slice(2),M=(t,s)=>{throw process.exitCode=t,s}}else(u||O)&&(O?X=self.location.href:typeof document<"u"&&document.currentScript&&(X=document.currentScript.src),a&&(X=a),X.startsWith("blob:")?X="":X=X.slice(0,X.replace(/[?#].*/,"").lastIndexOf("/")+1),O&&(J=t=>{var s=new XMLHttpRequest;return s.open("GET",t,!1),s.responseType="arraybuffer",s.send(null),new Uint8Array(s.response)}),re=async t=>{var s=await fetch(t,{credentials:"same-origin"});if(s.ok)return s.arrayBuffer();throw new Error(s.status+" : "+s.url)});var ne=r.print||console.log.bind(console),b=r.printErr||console.error.bind(console);Object.assign(r,N),N=null,r.arguments&&(Y=r.arguments),r.thisProgram&&(R=r.thisProgram);var A=r.wasmBinary,I,m=!1,D;function F(t,s){t||he(s)}var P,p,U,x,S,$,fe,G,_e,oe,pe=!1,Ae=t=>t.startsWith("file://");function Se(){var t=I.buffer;r.HEAP8=P=new Int8Array(t),r.HEAP16=U=new Int16Array(t),r.HEAPU8=p=new Uint8Array(t),r.HEAPU16=x=new Uint16Array(t),r.HEAP32=S=new Int32Array(t),r.HEAPU32=$=new Uint32Array(t),r.HEAPF32=fe=new Float32Array(t),r.HEAPF64=oe=new Float64Array(t),r.HEAP64=G=new BigInt64Array(t),r.HEAPU64=_e=new BigUint64Array(t)}function Re(){if(r.preRun)for(typeof r.preRun=="function"&&(r.preRun=[r.preRun]);r.preRun.length;)br(r.preRun.shift());ut(dt)}function rr(){pe=!0,T.ta()}function Us(){}function nr(){if(r.postRun)for(typeof r.postRun=="function"&&(r.postRun=[r.postRun]);r.postRun.length;)hr(r.postRun.shift());ut(ct)}var ve=0,Te=null;function sr(t){var s;ve++,(s=r.monitorRunDependencies)==null||s.call(r,ve)}function ar(t){var i;if(ve--,(i=r.monitorRunDependencies)==null||i.call(r,ve),ve==0&&Te){var s=Te;Te=null,s()}}function he(t){var i;(i=r.onAbort)==null||i.call(r,t),t="Aborted("+t+")",b(t),m=!0,t+=". Build with -sASSERTIONS for more info.",pe&&___trap();var s=new WebAssembly.RuntimeError(t);throw d(s),s}var He;function ir(){return Q("./duckdb-eh.wasm")}function or(t){if(t==He&&A)return new Uint8Array(A);if(J)return J(t);throw"both async and sync fetching of the wasm failed"}async function lr(t){if(!A)try{var s=await re(t);return new Uint8Array(s)}catch{}return or(t)}async function ur(t,s){try{var i=await lr(t),c=await WebAssembly.instantiate(i,s);return c}catch(h){b(`failed to asynchronously prepare wasm: ${h}`),he(h)}}async function cr(t,s,i){if(!t&&typeof WebAssembly.instantiateStreaming=="function"&&!_)try{var c=fetch(s,{credentials:"same-origin"}),h=await WebAssembly.instantiateStreaming(c,i);return h}catch(g){b(`wasm streaming compile failed: ${g}`),b("falling back to ArrayBuffer instantiation")}return ur(s,i)}function dr(){return{a:ns}}async function fr(){function t(g,w){return T=g.exports,T=cs(T),I=T.sa,Se(),ar("wasm-instantiate"),T}sr("wasm-instantiate");function s(g){return t(g.instance)}var i=dr();if(r.instantiateWasm)return new Promise((g,w)=>{r.instantiateWasm(i,(E,k)=>{t(E,k),g(E.exports)})});He!=null||(He=ir());try{var c=await cr(A,He,i),h=s(c);return h}catch(g){return d(g),Promise.reject(g)}}var _r={10294593:(t,s,i,c)=>{var h=z(t);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(z(c),h,!1),g.responseType="arraybuffer";for(var w=0,y=s;w<y*2;){var E=S[i/4+w>>>0],k=S[i/4+w+1>>>0];try{var H=encodeURI(z(E));H==="Host"&&(H="X-Host-Override"),H==="User-Agent"&&(H="X-user-agent"),H==="Authorization"?g.setRequestHeader(H,z(k)):g.setRequestHeader(H,encodeURI(z(k)))}catch(te){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",te)}w+=2}try{g.send(null)}catch{return 0}if(g.status>=400)return 0;for(var L=g.response,y=L.byteLength,K=ye(y+4),V=new Uint8Array(L),C=0;C<y;C++)r.HEAPU8[C+K+4]=V[C];var v=new Uint8Array(4);return v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,K),K},10296e3:(t,s,i,c,h,g)=>{var w=z(t);if(typeof XMLHttpRequest>"u")return 0;let E=new XMLHttpRequest;E.open(z(c),w,!1),E.responseType="arraybuffer";for(var k=0,v=s;k<v*2;){var H=S[i/4+k>>>0],L=S[i/4+k+1>>>0];try{var y=encodeURI(z(H));y==="Host"&&(y="X-Host-Override"),y==="User-Agent"&&(y="X-user-agent"),y==="Authorization"?E.setRequestHeader(y,z(L)):E.setRequestHeader(y,encodeURI(z(L)))}catch(we){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",we)}k+=2}try{for(var K=new Uint8Array(g),V=0;V<g;V++)K[V]=r.HEAPU8[V+h];E.send(K)}catch{return 0}if(E.status>=400)return 0;for(var C=Uint8Array.from(Array.from(E.getResponseHeader("Etag")).map(we=>we.charCodeAt(0))),v=C.byteLength,te=ye(v+4),le=new Uint8Array(C),V=0;V<v;V++)r.HEAPU8[V+te+4]=le[V];var Z=new Uint8Array(4);return Z[0]=v%256,v-=Z[0],v/=256,Z[1]=v%256,v-=Z[1],v/=256,Z[2]=v%256,v-=Z[2],v/=256,Z[3]=v%256,v-=Z[3],v/=256,r.HEAPU8.set(Z,te),te},10297620:(t,s,i,c)=>{var h=z(t);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(z(c),h,!1),g.responseType="arraybuffer";for(var w=0,y=s;w<y*2;){var E=S[i/4+w>>>0],k=S[i/4+w+1>>>0];try{var H=encodeURI(z(E));H==="Host"&&(H="X-Host-Override"),H==="User-Agent"&&(H="X-user-agent"),H==="Authorization"?g.setRequestHeader(H,z(k)):g.setRequestHeader(H,encodeURI(z(k)))}catch(Z){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Z)}w+=2}try{g.send(null)}catch{return 0}if(g.status>=400)return 0;for(var L=g.response,y=L.byteLength,K=ye(y+8),V=new Uint8Array(L),C=0;C<y;C++)r.HEAPU8[C+K+8]=V[C];var v=new Uint8Array(4);v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,K+4);var te=Uint8Array.from(Array.from(g.getAllResponseHeaders()).map(Z=>Z.charCodeAt(0)));y=te.byteLength;for(var le=ye(y+8),C=0;C<y;C++)r.HEAPU8[C+le+8]=te[C];return v=new Uint8Array(4),v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,le+4),y=le,v=new Uint8Array(4),v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,K),K},10299904:(t,s,i,c)=>{var h=z(t);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(z(c),h,!1),g.responseType="arraybuffer";for(var w=0,y=s;w<y*2;){var E=S[i/4+w>>>0],k=S[i/4+w+1>>>0];try{var H=encodeURI(z(E));H==="Host"&&(H="X-Host-Override"),H==="User-Agent"&&(H="X-user-agent"),H==="Authorization"?g.setRequestHeader(H,z(k)):g.setRequestHeader(H,encodeURI(z(k)))}catch(te){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",te)}w+=2}try{g.send(null)}catch{return 0}if(g.status>=400)return 0;for(var L=g.response,y=L.byteLength,K=ye(y+4),V=new Uint8Array(L),C=0;C<y;C++)r.HEAPU8[C+K+4]=V[C];var v=new Uint8Array(4);return v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,K),K},10301311:(t,s,i,c,h,g)=>{var w=z(t);if(typeof XMLHttpRequest>"u")return 0;let E=new XMLHttpRequest;E.open(z(c),w,!1),E.responseType="arraybuffer";for(var k=0,v=s;k<v*2;){var H=S[i/4+k>>>0],L=S[i/4+k+1>>>0];try{var y=encodeURI(z(H));y==="Host"&&(y="X-Host-Override"),y==="User-Agent"&&(y="X-user-agent"),y==="Authorization"?E.setRequestHeader(y,z(L)):E.setRequestHeader(y,encodeURI(z(L)))}catch(we){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",we)}k+=2}try{for(var K=new Uint8Array(g),V=0;V<g;V++)K[V]=r.HEAPU8[V+h];E.send(K)}catch{return 0}if(E.status>=400)return 0;for(var C=E.response,v=C.byteLength,te=ye(v+4),le=new Uint8Array(C),V=0;V<v;V++)r.HEAPU8[V+te+4]=le[V];var Z=new Uint8Array(4);return Z[0]=v%256,v-=Z[0],v/=256,Z[1]=v%256,v-=Z[1],v/=256,Z[2]=v%256,v-=Z[2],v/=256,Z[3]=v%256,v-=Z[3],v/=256,r.HEAPU8.set(Z,te),te}};class lt{constructor(s){Mt(this,"name","ExitStatus");this.message=`Program terminated with exit(${s})`,this.status=s}}var ut=t=>{for(;t.length>0;)t.shift()(r)},ct=[],hr=t=>ct.unshift(t),dt=[],br=t=>dt.unshift(t),pr=r.noExitRuntime||!0;function ft(){he("missing function: $SOCKFS")}ft.stub=!0;function je(){he("missing function: $FS")}je.stub=!0;var De=t=>{var s=ft.getSocket(t);if(!s)throw new je.ErrnoError(8);return s},ze=t=>(t&255)+"."+(t>>8&255)+"."+(t>>16&255)+"."+(t>>24&255),_t=t=>{var s="",i=0,c=0,h=0,g=0,w=0,E=0,k=[t[0]&65535,t[0]>>16,t[1]&65535,t[1]>>16,t[2]&65535,t[2]>>16,t[3]&65535,t[3]>>16],H=!0,L="";for(E=0;E<5;E++)if(k[E]!==0){H=!1;break}if(H){if(L=ze(k[6]|k[7]<<16),k[5]===-1)return s="::ffff:",s+=L,s;if(k[5]===0)return s="::",L==="0.0.0.0"&&(L=""),L==="0.0.0.1"&&(L="1"),s+=L,s}for(i=0;i<8;i++)k[i]===0&&(i-h>1&&(w=0),h=i,w++),w>c&&(c=w,g=i-c+1);for(i=0;i<8;i++){if(c>1&&k[i]===0&&i>=g&&i<g+c){i===g&&(s+=":",g===0&&(s+=":"));continue}s+=Number(_ntohs(k[i]&65535)).toString(16),s+=i<7?":":""}return s},ht=(t,s)=>{var i=U[t>>>1>>>0],c=_ntohs(x[t+2>>>1>>>0]),h;switch(i){case 2:if(s!==16)return{errno:28};h=S[t+4>>>2>>>0],h=ze(h);break;case 10:if(s!==28)return{errno:28};h=[S[t+8>>>2>>>0],S[t+12>>>2>>>0],S[t+16>>>2>>>0],S[t+20>>>2>>>0]],h=_t(h);break;default:return{errno:5}}return{family:i,addr:h,port:c}},Be=t=>{for(var s=t.split("."),i=0;i<4;i++){var c=Number(s[i]);if(isNaN(c))return null;s[i]=c}return(s[0]|s[1]<<8|s[2]<<16|s[3]<<24)>>>0},Me=t=>parseInt(t),Ye=t=>{var s,i,c,h,g=/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,w=[];if(!g.test(t))return null;if(t==="::")return[0,0,0,0,0,0,0,0];for(t.startsWith("::")?t=t.replace("::","Z:"):t=t.replace("::",":Z:"),t.indexOf(".")>0?(t=t.replace(new RegExp("[.]","g"),":"),s=t.split(":"),s[s.length-4]=Me(s[s.length-4])+Me(s[s.length-3])*256,s[s.length-3]=Me(s[s.length-2])+Me(s[s.length-1])*256,s=s.slice(0,s.length-2)):s=t.split(":"),c=0,h=0,i=0;i<s.length;i++)if(typeof s[i]=="string")if(s[i]==="Z"){for(h=0;h<8-s.length+1;h++)w[i+h]=0;c=h-1}else w[i+c]=_htons(parseInt(s[i],16));else w[i+c]=s[i];return[w[1]<<16|w[0],w[3]<<16|w[2],w[5]<<16|w[4],w[7]<<16|w[6]]},ie={address_map:{id:1,addrs:{},names:{}},lookup_name(t){var s=Be(t);if(s!==null||(s=Ye(t),s!==null))return t;var i;if(ie.address_map.addrs[t])i=ie.address_map.addrs[t];else{var c=ie.address_map.id++;F(c<65535,"exceeded max address mappings of 65535"),i="172.29."+(c&255)+"."+(c&65280),ie.address_map.names[i]=t,ie.address_map.addrs[t]=i}return i},lookup_addr(t){return ie.address_map.names[t]?ie.address_map.names[t]:null}},bt=(t,s)=>{var i=ht(t,s);if(i.errno)throw new je.ErrnoError(i.errno);return i.addr=ie.lookup_addr(i.addr)||i.addr,i},mr=9007199254740992,gr=-9007199254740992,me=t=>t<gr||t>mr?NaN:Number(t);function yr(t,s,i,c,h,g){s>>>=0,i>>>=0;var w=De(t),E=bt(s,i);return w.sock_ops.bind(w,E.addr,E.port),0}function wr(t,s,i,c,h,g){s>>>=0,i>>>=0;var w=De(t),E=bt(s,i);return w.sock_ops.connect(w,E.addr,E.port),0}var Er=(t,s,i)=>{};function vr(t,s,i,c){s>>>=0}var pt=typeof TextDecoder<"u"?new TextDecoder:void 0,mt=(t,s=0,i=NaN)=>{s>>>=0;for(var c=s+i,h=s;t[h]&&!(h>=c);)++h;if(h-s>16&&t.buffer&&pt)return pt.decode(t.subarray(s,h));for(var g="";s<h;){var w=t[s++];if(!(w&128)){g+=String.fromCharCode(w);continue}var E=t[s++]&63;if((w&224)==192){g+=String.fromCharCode((w&31)<<6|E);continue}var k=t[s++]&63;if((w&240)==224?w=(w&15)<<12|E<<6|k:w=(w&7)<<18|E<<12|k<<6|t[s++]&63,w<65536)g+=String.fromCharCode(w);else{var H=w-65536;g+=String.fromCharCode(55296|H>>10,56320|H&1023)}}return g},z=(t,s)=>(t>>>=0,t?mt(p,t,s):""),Qe={varargs:void 0,getStr(t){var s=z(t);return s}};function Fr(t,s,i){return i>>>=0,Qe.varargs=i,0}function Ar(t,s){s>>>=0}function Sr(t,s){s=me(s)}var gt=t=>{for(var s=0,i=0;i<t.length;++i){var c=t.charCodeAt(i);c<=127?s++:c<=2047?s+=2:c>=55296&&c<=57343?(s+=4,++i):s+=3}return s};r.lengthBytesUTF8=gt;var Rr=(t,s,i,c)=>{if(i>>>=0,!(c>0))return 0;for(var h=i,g=i+c-1,w=0;w<t.length;++w){var E=t.charCodeAt(w);if(E>=55296&&E<=57343){var k=t.charCodeAt(++w);E=65536+((E&1023)<<10)|k&1023}if(E<=127){if(i>=g)break;s[i++>>>0]=E}else if(E<=2047){if(i+1>=g)break;s[i++>>>0]=192|E>>6,s[i++>>>0]=128|E&63}else if(E<=65535){if(i+2>=g)break;s[i++>>>0]=224|E>>12,s[i++>>>0]=128|E>>6&63,s[i++>>>0]=128|E&63}else{if(i+3>=g)break;s[i++>>>0]=240|E>>18,s[i++>>>0]=128|E>>12&63,s[i++>>>0]=128|E>>6&63,s[i++>>>0]=128|E&63}}return s[i>>>0]=0,i-h},ge=(t,s,i)=>Rr(t,p,s,i);r.stringToUTF8=ge;function Dr(t,s){t>>>=0,s>>>=0}function kr(t,s,i){s>>>=0,i>>>=0}var yt=(t,s)=>{p.fill(0,t,t+s)},Le=(t,s,i,c,h)=>{switch(s){case 2:i=Be(i),yt(t,16),h&&(S[h>>>2>>>0]=16),U[t>>>1>>>0]=s,S[t+4>>>2>>>0]=i,U[t+2>>>1>>>0]=_htons(c);break;case 10:i=Ye(i),yt(t,28),h&&(S[h>>>2>>>0]=28),S[t>>>2>>>0]=s,S[t+8>>>2>>>0]=i[0],S[t+12>>>2>>>0]=i[1],S[t+16>>>2>>>0]=i[2],S[t+20>>>2>>>0]=i[3],U[t+2>>>1>>>0]=_htons(c);break;default:return 5}return 0};function Ir(t,s,i,c,h,g){s>>>=0,i>>>=0;var w=De(t);if(!w.daddr)return-53;var E=Le(s,w.family,ie.lookup_name(w.daddr),w.dport,i);return 0}function Ur(t,s,i,c,h,g){s>>>=0,i>>>=0;var w=De(t),E=Le(s,w.family,ie.lookup_name(w.saddr||"0.0.0.0"),w.sport,i);return 0}function Tr(t,s,i,c,h,g){c>>>=0,h>>>=0;var w=De(t);return s===1&&i===4?(S[c>>>2>>>0]=w.error,S[h>>>2>>>0]=4,w.error=null,0):-50}function Hr(t,s,i){return i>>>=0,Qe.varargs=i,0}function Pr(t,s){t>>>=0,s>>>=0}function xr(t,s,i){s>>>=0}function Br(t,s,i,c){s>>>=0,i>>>=0}function Mr(t,s,i,c){s>>>=0,c>>>=0,Qe.varargs=c}function Lr(t,s,i){t>>>=0}function Cr(t,s,i,c,h,g){s>>>=0,i>>>=0,h>>>=0,g>>>=0;var w=De(t),E=w.sock_ops.recvmsg(w,i);if(!E)return 0;if(h)var k=Le(h,w.family,ie.lookup_name(E.addr),E.port,g);return p.set(E.buffer,s>>>0),E.buffer.byteLength}function Or(t,s,i,c){s>>>=0,c>>>=0}function Nr(t){t>>>=0}function Wr(t,s,i,c,h,g){s>>>=0,i>>>=0,h>>>=0,g>>>=0}var Gr=(t,s,i)=>{};function Kr(t,s){t>>>=0,s>>>=0}function $r(t,s,i){t>>>=0,s>>>=0,i>>>=0}function Xr(t,s,i){s>>>=0}var Vr=()=>he("");function wt(){he("missing function: _emval_call_method")}wt.stub=!0;function Et(){he("missing function: _emval_decref")}Et.stub=!0;function vt(){he("missing function: _emval_get_global")}vt.stub=!0;function Ft(){he("missing function: _emval_get_method_caller")}Ft.stub=!0;function At(){he("missing function: _emval_run_destructors")}At.stub=!0;var qr=t=>t%4===0&&(t%100!==0||t%400===0),Jr=[0,31,60,91,121,152,182,213,244,274,305,335],jr=[0,31,59,90,120,151,181,212,243,273,304,334],zr=t=>{var s=qr(t.getFullYear()),i=s?Jr:jr,c=i[t.getMonth()]+t.getDate()-1;return c};function Yr(t,s){t=me(t),s>>>=0;var i=new Date(t*1e3);S[s>>>2>>>0]=i.getSeconds(),S[s+4>>>2>>>0]=i.getMinutes(),S[s+8>>>2>>>0]=i.getHours(),S[s+12>>>2>>>0]=i.getDate(),S[s+16>>>2>>>0]=i.getMonth(),S[s+20>>>2>>>0]=i.getFullYear()-1900,S[s+24>>>2>>>0]=i.getDay();var c=zr(i)|0;S[s+28>>>2>>>0]=c,S[s+36>>>2>>>0]=-(i.getTimezoneOffset()*60);var h=new Date(i.getFullYear(),0,1),g=new Date(i.getFullYear(),6,1).getTimezoneOffset(),w=h.getTimezoneOffset(),E=(g!=w&&i.getTimezoneOffset()==Math.min(w,g))|0;S[s+32>>>2>>>0]=E}function Qr(t,s,i,c,h,g,w){return t>>>=0,h=me(h),g>>>=0,w>>>=0,-52}function Zr(t,s,i,c,h,g){t>>>=0,s>>>=0,g=me(g)}var en=function(t,s,i,c){t>>>=0,s>>>=0,i>>>=0,c>>>=0;var h=new Date().getFullYear(),g=new Date(h,0,1),w=new Date(h,6,1),E=g.getTimezoneOffset(),k=w.getTimezoneOffset(),H=Math.max(E,k);$[t>>>2>>>0]=H*60,S[s>>>2>>>0]=+(E!=k);var L=V=>{var C=V>=0?"-":"+",v=Math.abs(V),te=String(Math.floor(v/60)).padStart(2,"0"),le=String(v%60).padStart(2,"0");return`UTC${C}${te}${le}`},y=L(E),K=L(k);k<E?(ge(y,i,17),ge(K,c,17)):(ge(y,c,17),ge(K,i,17))},St=()=>performance.now(),Rt=()=>Date.now(),tn=1,rn=t=>t>=0&&t<=3;function nn(t,s,i){if(s=me(s),i>>>=0,!rn(t))return 28;var c;if(t===0)c=Rt();else if(tn)c=St();else return 52;var h=Math.round(c*1e3*1e3);return G[i>>>3]=BigInt(h),0}function sn(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.createDirectory(r,t,s)}function an(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.checkDirectory(r,t,s)}function on(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.listDirectoryEntries(r,t,s)}function ln(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.removeDirectory(r,t,s)}function un(t){return globalThis.DUCKDB_RUNTIME.closeFile(r,t)}function cn(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.dropFile(r,t,s)}function dn(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.checkFile(r,t,s)}function fn(t,s,i,c){return t>>>=0,i>>>=0,globalThis.DUCKDB_RUNTIME.moveFile(r,t,s,i,c)}function _n(t,s){return globalThis.DUCKDB_RUNTIME.openFile(r,t,s)}function hn(t,s,i,c){return s>>>=0,globalThis.DUCKDB_RUNTIME.readFile(r,t,s,i,c)}function bn(t,s){return globalThis.DUCKDB_RUNTIME.truncateFile(r,t,s)}function pn(t,s,i,c){return s>>>=0,globalThis.DUCKDB_RUNTIME.writeFile(r,t,s,i,c)}function mn(t){return globalThis.DUCKDB_RUNTIME.getDefaultDataProtocol(t)}function gn(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.glob(r,t,s)}function yn(t){return globalThis.DUCKDB_RUNTIME.testPlatformFeature(r,t)}function wn(t,s,i,c,h,g){return t>>>=0,i>>>=0,h>>>=0,globalThis.DUCKDB_RUNTIME.callScalarUDF(r,t,s,i,c,h,g)}var Ze=[],En=(t,s)=>{Ze.length=0;for(var i;i=p[t++>>>0];){var c=i!=105;c&=i!=112,s+=c&&s%8?4:0,Ze.push(i==112?$[s>>>2>>>0]:i==106?G[s>>>3]:i==105?S[s>>>2>>>0]:oe[s>>>3>>>0]),s+=c?8:4}return Ze},vn=(t,s,i)=>{var c=En(s,i);return _r[t](...c)};function Fn(t,s,i){return t>>>=0,s>>>=0,i>>>=0,vn(t,s,i)}var Dt=()=>4294901760;function An(){return Dt()}var Sn=(t,s)=>Math.ceil(t/s)*s,Rn=t=>{var s=I.buffer,i=(t-s.byteLength+65535)/65536|0;try{return I.grow(i),Se(),1}catch{}};function Dn(t){t>>>=0;var s=p.length,i=Dt();if(t>i)return!1;for(var c=1;c<=4;c*=2){var h=s*(1+.2/c);h=Math.min(h,t+100663296);var g=Math.min(i,Sn(Math.max(t,h),65536)),w=Rn(g);if(w)return!0}return!1}var et={},kn=()=>R||"./this.program",Pe=()=>{if(!Pe.strings){var t=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",s={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:t,_:kn()};for(var i in et)et[i]===void 0?delete s[i]:s[i]=et[i];var c=[];for(var i in s)c.push(`${i}=${s[i]}`);Pe.strings=c}return Pe.strings},In=(t,s)=>{for(var i=0;i<t.length;++i)P[s++>>>0]=t.charCodeAt(i);P[s>>>0]=0},Un=function(t,s){t>>>=0,s>>>=0;var i=0;return Pe().forEach((c,h)=>{var g=s+i;$[t+h*4>>>2>>>0]=g,In(c,g),i+=c.length+1}),0},Tn=function(t,s){t>>>=0,s>>>=0;var i=Pe();$[t>>>2>>>0]=i.length;var c=0;return i.forEach(h=>c+=h.length+1),$[s>>>2>>>0]=c,0},Hn=0,Pn=()=>pr||Hn>0,xn=t=>{var s;D=t,Pn()||((s=r.onExit)==null||s.call(r,t),m=!0),M(t,new lt(t))},kt=(t,s)=>{D=t,xn(t)},Bn=kt,Mn=t=>52;function Ln(t,s){s>>>=0;var i=0,c=0,h=0;{var g=2;t==0?i=2:(t==1||t==2)&&(i=64),h=1}return P[s>>>0]=g,U[s+2>>>1>>>0]=h,G[s+8>>>3]=BigInt(i),G[s+16>>>3]=BigInt(c),0}function Cn(t,s,i,c,h){return s>>>=0,i>>>=0,c=me(c),h>>>=0,52}function On(t,s,i,c,h){return s>>>=0,i>>>=0,c=me(c),h>>>=0,52}function Nn(t,s,i,c){return s>>>=0,i>>>=0,c>>>=0,52}function Wn(t,s,i,c){return s=me(s),c>>>=0,70}var Gn=t=>52,Kn=[null,[],[]],$n=(t,s)=>{var i=Kn[t];s===0||s===10?((t===1?ne:b)(mt(i)),i.length=0):i.push(s)};function Xn(t,s,i,c){s>>>=0,i>>>=0,c>>>=0;for(var h=0,g=0;g<i;g++){var w=$[s>>>2>>>0],E=$[s+4>>>2>>>0];s+=8;for(var k=0;k<E;k++)$n(t,p[w+k>>>0]);h+=E}return $[c>>>2>>>0]=h,0}function Vn(t,s,i,c){t>>>=0,s>>>=0,i>>>=0,c>>>=0;var h=0,g=0,w=0,E=0,k=0,H=0,L;function y(K,V,C,v,te,le){var Z,we,be,Ht;return we=K===10?28:16,te=K===10?_t(te):ze(te),Z=ye(we),Ht=Le(Z,K,te,le),F(!Ht),be=ye(32),S[be+4>>>2>>>0]=K,S[be+8>>>2>>>0]=V,S[be+12>>>2>>>0]=C,$[be+24>>>2>>>0]=v,$[be+20>>>2>>>0]=Z,K===10?S[be+16>>>2>>>0]=28:S[be+16>>>2>>>0]=16,S[be+28>>>2>>>0]=0,be}if(i&&(w=S[i>>>2>>>0],E=S[i+4>>>2>>>0],k=S[i+8>>>2>>>0],H=S[i+12>>>2>>>0]),k&&!H&&(H=k===2?17:6),!k&&H&&(k=H===17?2:1),H===0&&(H=6),k===0&&(k=1),!t&&!s)return-2;if(w&-1088||i!==0&&S[i>>>2>>>0]&2&&!t)return-1;if(w&32)return-2;if(k!==0&&k!==1&&k!==2)return-7;if(E!==0&&E!==2&&E!==10)return-6;if(s&&(s=z(s),g=parseInt(s,10),isNaN(g)))return w&1024?-2:-8;if(!t)return E===0&&(E=2),(w&1)===0&&(E===2?h=_htonl(2130706433):h=[0,0,0,_htonl(1)]),L=y(E,k,H,null,h,g),$[c>>>2>>>0]=L,0;if(t=z(t),h=Be(t),h!==null)if(E===0||E===2)E=2;else if(E===10&&w&8)h=[0,0,_htonl(65535),h],E=10;else return-2;else if(h=Ye(t),h!==null)if(E===0||E===10)E=10;else return-2;return h!=null?(L=y(E,k,H,t,h,g),$[c>>>2>>>0]=L,0):w&4?-2:(t=ie.lookup_name(t),h=Be(t),E===0?E=2:E===10&&(h=[0,0,_htonl(65535),h]),L=y(E,k,H,null,h,g),$[c>>>2>>>0]=L,0)}function qn(t,s,i,c,h,g,w){t>>>=0,i>>>=0,h>>>=0;var E=ht(t,s);if(E.errno)return-6;var k=E.port,H=E.addr,L=!1;if(i&&c){var y;if(w&1||!(y=ie.lookup_addr(H))){if(w&8)return-2}else H=y;var K=ge(H,i,c);K+1>=c&&(L=!0)}if(h&&g){k=""+k;var K=ge(k,h,g);K+1>=g&&(L=!0)}return L?-12:0}var Jn=()=>{if(_){var t=["crypto"].map(Pt)[0];return s=>t.randomFillSync(s)}return s=>crypto.getRandomValues(s)},It=t=>{(It=Jn())(t)};function jn(t,s){return t>>>=0,s>>>=0,It(p.subarray(t>>>0,t+s>>>0)),0}var zn=t=>{if(t instanceof lt||t=="unwind")return D;M(1,t)},Yn=t=>{var s=r["_"+t];return s},Qn=(t,s)=>{P.set(t,s>>>0)},Ce=t=>ls(t);r.stackAlloc=Ce;var Zn=t=>{var s=gt(t)+1,i=Ce(s);return ge(t,i,s),i},Ut=()=>us(),Tt=t=>os(t),es=(t,s,i,c,h)=>{var g={string:C=>{var v=0;return C!=null&&C!==0&&(v=Zn(C)),v},array:C=>{var v=Ce(C.length);return Qn(C,v),v}};function w(C){return s==="string"?z(C):s==="boolean"?!!C:C}var E=Yn(t),k=[],H=0;if(c)for(var L=0;L<c.length;L++){var y=g[i[L]];y?(H===0&&(H=Ut()),k[L]=y(c[L])):k[L]=c[L]}var K=E(...k);function V(C){return H!==0&&Tt(H),w(C)}return K=V(K),K},ts=t=>is(),rs=t=>as(t),ns={X:yr,W:wr,A:Er,ja:vr,b:Fr,ia:Ar,ca:Sr,ka:Dr,aa:kr,R:Ir,Q:Ur,U:Tr,i:Hr,fa:Pr,ba:xr,ga:Br,s:Mr,V:Lr,S:Cr,_:Or,q:Nr,T:Wr,p:Gr,ha:Kr,la:$r,r:Xr,qa:Vr,x:wt,y:Et,z:vt,w:Ft,u:At,Y:Yr,O:Qr,P:Zr,oa:en,ma:nn,G:sn,H:an,E:on,F:ln,m:un,K:cn,C:dn,D:fn,J:_n,g:hn,I:bn,h:pn,L:mn,B:gn,k:yn,N:wn,e:Fn,j:Rt,na:An,c:St,ra:Dn,pa:Un,t:Tn,a:Bn,d:Mn,M:Ln,ea:Cn,da:On,l:Nn,v:Wn,$:Gn,f:Xn,o:Vn,n:qn,Z:jn},T=await fr(),ss=r._main=T.ua,Ts=r._duckdb_web_fs_glob_add_path=T.wa,Hs=r._duckdb_web_clear_response=T.xa,Ps=r._duckdb_web_fail_with=T.ya,xs=r._duckdb_web_reset=T.za,Bs=r._duckdb_web_connect=T.Aa,Ms=r._duckdb_web_disconnect=T.Ba,Ls=r._duckdb_web_flush_files=T.Ca,Cs=r._duckdb_web_flush_file=T.Da,Os=r._duckdb_web_open=T.Ea,Ns=r._duckdb_web_get_global_file_info=T.Fa,Ws=r._duckdb_web_collect_file_stats=T.Ga,Gs=r._duckdb_web_export_file_stats=T.Ha,Ks=r._duckdb_web_fs_drop_file=T.Ia,$s=r._duckdb_web_fs_drop_files=T.Ja,Xs=r._duckdb_web_fs_glob_file_infos=T.Ka,Vs=r._duckdb_web_fs_get_file_info_by_id=T.La,qs=r._duckdb_web_fs_get_file_info_by_name=T.Ma,Js=r._duckdb_web_fs_register_file_url=T.Na,js=r._duckdb_web_fs_register_file_buffer=T.Oa,zs=r._duckdb_web_copy_file_to_buffer=T.Pa,Ys=r._duckdb_web_copy_file_to_path=T.Qa,Qs=r._duckdb_web_get_version=T.Ra,Zs=r._duckdb_web_get_feature_flags=T.Sa,ea=r._duckdb_web_tokenize=T.Ta,ta=r._duckdb_web_tokenize_buffer=T.Ua,ra=r._duckdb_web_udf_scalar_create=T.Va,na=r._duckdb_web_prepared_create=T.Wa,sa=r._duckdb_web_prepared_create_buffer=T.Xa,aa=r._duckdb_web_prepared_close=T.Ya,ia=r._duckdb_web_prepared_run=T.Za,oa=r._duckdb_web_prepared_send=T._a,la=r._duckdb_web_query_run=T.$a,ua=r._duckdb_web_query_run_buffer=T.ab,ca=r._duckdb_web_pending_query_start=T.bb,da=r._duckdb_web_pending_query_start_buffer=T.cb,fa=r._duckdb_web_pending_query_poll=T.db,_a=r._duckdb_web_pending_query_cancel=T.eb,ha=r._duckdb_web_query_fetch_results=T.fb,ba=r._duckdb_web_get_tablenames=T.gb,pa=r._duckdb_web_get_tablenames_buffer=T.hb,ma=r._duckdb_web_insert_arrow_from_ipc_stream=T.ib,ga=r._duckdb_web_insert_csv_from_path=T.jb,ya=r._duckdb_web_insert_json_from_path=T.kb,ye=r._malloc=T.ob,wa=r._free=T.pb,Ea=r._calloc=T.qb,as=T.sb,is=T.tb,os=T.ub,ls=T.vb,us=T.wb;function cs(t){t=Object.assign({},t);var s=h=>g=>h(g)>>>0,i=h=>(g,w)=>h(g,w)>>>0,c=h=>()=>h()>>>0;return t.ob=s(t.ob),t.qb=i(t.qb),t.vb=s(t.vb),t.wb=c(t.wb),t}r.stackSave=Ut,r.stackRestore=Tt,r.stackAlloc=Ce,r.getTempRet0=ts,r.setTempRet0=rs,r.ccall=es;function ds(){var t=ss,s=0,i=0;try{var c=t(s,i);return kt(c,!0),c}catch(h){return zn(h)}}function tt(){if(ve>0){Te=tt;return}if(Re(),ve>0){Te=tt;return}function t(){var i;if(r.calledRun=!0,!m){rr(),l(r),(i=r.onRuntimeInitialized)==null||i.call(r);var s=r.noInitialRun;s||ds(),nr()}}r.setStatus?(r.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>r.setStatus(""),1),t()},1)):t()}if(r.preInit)for(typeof r.preInit=="function"&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return tt(),o=f,o}})();typeof Xt=="object"&&typeof Xe=="object"?(Xe.exports=it,Xe.exports.default=it):typeof define=="function"&&define.amd&&define([],()=>it)});var Jt=ke(()=>{});var jt=ke(()=>{});var zt=ke((Ja,Je)=>{(function(){"use strict";var a="input is invalid type",e=typeof window=="object",n=e?window:{};n.JS_SHA256_NO_WINDOW&&(e=!1);var o=!e&&typeof self=="object",r=!n.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node&&process.type!="renderer";r?n=global:o&&(n=self);var l=!n.JS_SHA256_NO_COMMON_JS&&typeof Je=="object"&&Je.exports,d=typeof define=="function"&&define.amd,f=!n.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),O=[-2147483648,8388608,32768,128],_=[24,16,8,0],N=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Y=["hex","array","digest","arrayBuffer"],R=[];(n.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(b){return Object.prototype.toString.call(b)==="[object Array]"}),f&&(n.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(b){return typeof b=="object"&&b.buffer&&b.buffer.constructor===ArrayBuffer});var M=function(b,A){return function(I){return new q(A,!0).update(I)[b]()}},X=function(b){var A=M("hex",b);r&&(A=Q(A,b)),A.create=function(){return new q(b)},A.update=function(D){return A.create().update(D)};for(var I=0;I<Y.length;++I){var m=Y[I];A[m]=M(m,b)}return A},Q=function(b,A){var I=Jt(),m=jt().Buffer,D=A?"sha224":"sha256",F;m.from&&!n.JS_SHA256_NO_BUFFER_FROM?F=m.from:F=function(p){return new m(p)};var P=function(p){if(typeof p=="string")return I.createHash(D).update(p,"utf8").digest("hex");if(p==null)throw new Error(a);return p.constructor===ArrayBuffer&&(p=new Uint8Array(p)),Array.isArray(p)||ArrayBuffer.isView(p)||p.constructor===m?I.createHash(D).update(F(p)).digest("hex"):b(p)};return P},re=function(b,A){return function(I,m){return new se(I,A,!0).update(m)[b]()}},J=function(b){var A=re("hex",b);A.create=function(D){return new se(D,b)},A.update=function(D,F){return A.create(D).update(F)};for(var I=0;I<Y.length;++I){var m=Y[I];A[m]=re(m,b)}return A};function q(b,A){A?(R[0]=R[16]=R[1]=R[2]=R[3]=R[4]=R[5]=R[6]=R[7]=R[8]=R[9]=R[10]=R[11]=R[12]=R[13]=R[14]=R[15]=0,this.blocks=R):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],b?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=b}q.prototype.update=function(b){if(!this.finalized){var A,I=typeof b;if(I!=="string"){if(I==="object"){if(b===null)throw new Error(a);if(f&&b.constructor===ArrayBuffer)b=new Uint8Array(b);else if(!Array.isArray(b)&&(!f||!ArrayBuffer.isView(b)))throw new Error(a)}else throw new Error(a);A=!0}for(var m,D=0,F,P=b.length,p=this.blocks;D<P;){if(this.hashed&&(this.hashed=!1,p[0]=this.block,this.block=p[16]=p[1]=p[2]=p[3]=p[4]=p[5]=p[6]=p[7]=p[8]=p[9]=p[10]=p[11]=p[12]=p[13]=p[14]=p[15]=0),A)for(F=this.start;D<P&&F<64;++D)p[F>>>2]|=b[D]<<_[F++&3];else for(F=this.start;D<P&&F<64;++D)m=b.charCodeAt(D),m<128?p[F>>>2]|=m<<_[F++&3]:m<2048?(p[F>>>2]|=(192|m>>>6)<<_[F++&3],p[F>>>2]|=(128|m&63)<<_[F++&3]):m<55296||m>=57344?(p[F>>>2]|=(224|m>>>12)<<_[F++&3],p[F>>>2]|=(128|m>>>6&63)<<_[F++&3],p[F>>>2]|=(128|m&63)<<_[F++&3]):(m=65536+((m&1023)<<10|b.charCodeAt(++D)&1023),p[F>>>2]|=(240|m>>>18)<<_[F++&3],p[F>>>2]|=(128|m>>>12&63)<<_[F++&3],p[F>>>2]|=(128|m>>>6&63)<<_[F++&3],p[F>>>2]|=(128|m&63)<<_[F++&3]);this.lastByteIndex=F,this.bytes+=F-this.start,F>=64?(this.block=p[16],this.start=F-64,this.hash(),this.hashed=!0):this.start=F}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},q.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var b=this.blocks,A=this.lastByteIndex;b[16]=this.block,b[A>>>2]|=O[A&3],this.block=b[16],A>=56&&(this.hashed||this.hash(),b[0]=this.block,b[16]=b[1]=b[2]=b[3]=b[4]=b[5]=b[6]=b[7]=b[8]=b[9]=b[10]=b[11]=b[12]=b[13]=b[14]=b[15]=0),b[14]=this.hBytes<<3|this.bytes>>>29,b[15]=this.bytes<<3,this.hash()}},q.prototype.hash=function(){var b=this.h0,A=this.h1,I=this.h2,m=this.h3,D=this.h4,F=this.h5,P=this.h6,p=this.h7,U=this.blocks,x,S,$,fe,G,_e,oe,pe,Ae,Se,Re;for(x=16;x<64;++x)G=U[x-15],S=(G>>>7|G<<25)^(G>>>18|G<<14)^G>>>3,G=U[x-2],$=(G>>>17|G<<15)^(G>>>19|G<<13)^G>>>10,U[x]=U[x-16]+S+U[x-7]+$<<0;for(Re=A&I,x=0;x<64;x+=4)this.first?(this.is224?(pe=300032,G=U[0]-1413257819,p=G-150054599<<0,m=G+24177077<<0):(pe=704751109,G=U[0]-210244248,p=G-1521486534<<0,m=G+143694565<<0),this.first=!1):(S=(b>>>2|b<<30)^(b>>>13|b<<19)^(b>>>22|b<<10),$=(D>>>6|D<<26)^(D>>>11|D<<21)^(D>>>25|D<<7),pe=b&A,fe=pe^b&I^Re,oe=D&F^~D&P,G=p+$+oe+N[x]+U[x],_e=S+fe,p=m+G<<0,m=G+_e<<0),S=(m>>>2|m<<30)^(m>>>13|m<<19)^(m>>>22|m<<10),$=(p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7),Ae=m&b,fe=Ae^m&A^pe,oe=p&D^~p&F,G=P+$+oe+N[x+1]+U[x+1],_e=S+fe,P=I+G<<0,I=G+_e<<0,S=(I>>>2|I<<30)^(I>>>13|I<<19)^(I>>>22|I<<10),$=(P>>>6|P<<26)^(P>>>11|P<<21)^(P>>>25|P<<7),Se=I&m,fe=Se^I&b^Ae,oe=P&p^~P&D,G=F+$+oe+N[x+2]+U[x+2],_e=S+fe,F=A+G<<0,A=G+_e<<0,S=(A>>>2|A<<30)^(A>>>13|A<<19)^(A>>>22|A<<10),$=(F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7),Re=A&I,fe=Re^A&m^Se,oe=F&P^~F&p,G=D+$+oe+N[x+3]+U[x+3],_e=S+fe,D=b+G<<0,b=G+_e<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+b<<0,this.h1=this.h1+A<<0,this.h2=this.h2+I<<0,this.h3=this.h3+m<<0,this.h4=this.h4+D<<0,this.h5=this.h5+F<<0,this.h6=this.h6+P<<0,this.h7=this.h7+p<<0},q.prototype.hex=function(){this.finalize();var b=this.h0,A=this.h1,I=this.h2,m=this.h3,D=this.h4,F=this.h5,P=this.h6,p=this.h7,U=u[b>>>28&15]+u[b>>>24&15]+u[b>>>20&15]+u[b>>>16&15]+u[b>>>12&15]+u[b>>>8&15]+u[b>>>4&15]+u[b&15]+u[A>>>28&15]+u[A>>>24&15]+u[A>>>20&15]+u[A>>>16&15]+u[A>>>12&15]+u[A>>>8&15]+u[A>>>4&15]+u[A&15]+u[I>>>28&15]+u[I>>>24&15]+u[I>>>20&15]+u[I>>>16&15]+u[I>>>12&15]+u[I>>>8&15]+u[I>>>4&15]+u[I&15]+u[m>>>28&15]+u[m>>>24&15]+u[m>>>20&15]+u[m>>>16&15]+u[m>>>12&15]+u[m>>>8&15]+u[m>>>4&15]+u[m&15]+u[D>>>28&15]+u[D>>>24&15]+u[D>>>20&15]+u[D>>>16&15]+u[D>>>12&15]+u[D>>>8&15]+u[D>>>4&15]+u[D&15]+u[F>>>28&15]+u[F>>>24&15]+u[F>>>20&15]+u[F>>>16&15]+u[F>>>12&15]+u[F>>>8&15]+u[F>>>4&15]+u[F&15]+u[P>>>28&15]+u[P>>>24&15]+u[P>>>20&15]+u[P>>>16&15]+u[P>>>12&15]+u[P>>>8&15]+u[P>>>4&15]+u[P&15];return this.is224||(U+=u[p>>>28&15]+u[p>>>24&15]+u[p>>>20&15]+u[p>>>16&15]+u[p>>>12&15]+u[p>>>8&15]+u[p>>>4&15]+u[p&15]),U},q.prototype.toString=q.prototype.hex,q.prototype.digest=function(){this.finalize();var b=this.h0,A=this.h1,I=this.h2,m=this.h3,D=this.h4,F=this.h5,P=this.h6,p=this.h7,U=[b>>>24&255,b>>>16&255,b>>>8&255,b&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255,I>>>24&255,I>>>16&255,I>>>8&255,I&255,m>>>24&255,m>>>16&255,m>>>8&255,m&255,D>>>24&255,D>>>16&255,D>>>8&255,D&255,F>>>24&255,F>>>16&255,F>>>8&255,F&255,P>>>24&255,P>>>16&255,P>>>8&255,P&255];return this.is224||U.push(p>>>24&255,p>>>16&255,p>>>8&255,p&255),U},q.prototype.array=q.prototype.digest,q.prototype.arrayBuffer=function(){this.finalize();var b=new ArrayBuffer(this.is224?28:32),A=new DataView(b);return A.setUint32(0,this.h0),A.setUint32(4,this.h1),A.setUint32(8,this.h2),A.setUint32(12,this.h3),A.setUint32(16,this.h4),A.setUint32(20,this.h5),A.setUint32(24,this.h6),this.is224||A.setUint32(28,this.h7),b};function se(b,A,I){var m,D=typeof b;if(D==="string"){var F=[],P=b.length,p=0,U;for(m=0;m<P;++m)U=b.charCodeAt(m),U<128?F[p++]=U:U<2048?(F[p++]=192|U>>>6,F[p++]=128|U&63):U<55296||U>=57344?(F[p++]=224|U>>>12,F[p++]=128|U>>>6&63,F[p++]=128|U&63):(U=65536+((U&1023)<<10|b.charCodeAt(++m)&1023),F[p++]=240|U>>>18,F[p++]=128|U>>>12&63,F[p++]=128|U>>>6&63,F[p++]=128|U&63);b=F}else if(D==="object"){if(b===null)throw new Error(a);if(f&&b.constructor===ArrayBuffer)b=new Uint8Array(b);else if(!Array.isArray(b)&&(!f||!ArrayBuffer.isView(b)))throw new Error(a)}else throw new Error(a);b.length>64&&(b=new q(A,!0).update(b).array());var x=[],S=[];for(m=0;m<64;++m){var $=b[m]||0;x[m]=92^$,S[m]=54^$}q.call(this,A,I),this.update(S),this.oKeyPad=x,this.inner=!0,this.sharedMemory=I}se.prototype=new q,se.prototype.finalize=function(){if(q.prototype.finalize.call(this),this.inner){this.inner=!1;var b=this.array();q.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(b),q.prototype.finalize.call(this)}};var ne=X();ne.sha256=ne,ne.sha224=X(!0),ne.sha256.hmac=J(),ne.sha224.hmac=J(!0),l?Je.exports=ne:(n.sha256=ne.sha256,n.sha224=ne.sha224,d&&define(function(){return ne}))})()});var Is={};gs(Is,{registerWorker:()=>tr});var Oe=class{constructor(e,n){this._bindings=e,this._conn=n}close(){this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}query(e){return this._bindings.runQuery(this._conn,e)}async send(e,n=!1){let o=this._bindings.startPendingQuery(this._conn,e,n);for(;o==null;)o=await new Promise((r,l)=>{try{r(this._bindings.pollPendingQuery(this._conn))}catch(d){console.log(d),d.message.includes("worker is not set!")?l(new Error("Worker has been terminated")):l(d)}});return new Ne(this._bindings,this._conn,o)}cancelSent(){return this._bindings.cancelPendingQuery(this._conn)}getTableNames(e){return this._bindings.getTableNames(this._conn,e)}prepare(e){let n=this._bindings.createPrepared(this._conn,e);return new rt(this._bindings,this._conn,n)}insertArrowFromIPCStream(e,n){this._bindings.insertArrowFromIPCStream(this._conn,e,n)}insertCSVFromPath(e,n){this._bindings.insertCSVFromPath(this._conn,e,n)}insertJSONFromPath(e,n){this._bindings.insertJSONFromPath(this._conn,e,n)}},Ne=class{constructor(e,n,o){this.bindings=e;this.conn=n;this.header=o;this._first=!0,this._depleted=!1}next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e=null;do e=this.bindings.fetchQueryResults(this.conn);while(e==null);return this._depleted=e.length==0,{done:this._depleted,value:e}}[Symbol.iterator](){return this}},rt=class{constructor(e,n,o){this.bindings=e,this.connectionId=n,this.statementId=o}close(){this.bindings.closePrepared(this.connectionId,this.statementId)}query(...e){return this.bindings.runPrepared(this.connectionId,this.statementId,e)}send(...e){let n=this.bindings.sendPrepared(this.connectionId,this.statementId,e);return new Ne(this.bindings,this.connectionId,n)}};function Lt(a){return a<=255}function Ct(a){return a===256}var Wt=new TextEncoder,Ot=new TextDecoder("utf-8");function nt(a,e,n){let o=Wt.encode(n),r=a._malloc(o.byteLength),l=a.HEAPU8.subarray(r,r+o.byteLength);l.set(o),a.HEAPF64[(e>>3)+0]=1,a.HEAPF64[(e>>3)+1]=r,a.HEAPF64[(e>>3)+2]=l.byteLength}function at(a){switch(a){case"UINT8":case"INT8":return 1;case"INT32":case"FLOAT":return 4;case"INT64":case"UINT64":case"DOUBLE":case"VARCHAR":return 8;default:return 0}}function st(a,e,n,o){let r=a.HEAPU8.subarray(e,e+o*at(n));switch(n){case"UINT8":return new Uint8Array(r.buffer,r.byteOffset,o);case"INT8":return new Int8Array(r.buffer,r.byteOffset,o);case"INT32":return new Int32Array(r.buffer,r.byteOffset,o);case"FLOAT":return new Float32Array(r.buffer,r.byteOffset,o);case"DOUBLE":return new Float64Array(r.buffer,r.byteOffset,o);case"VARCHAR":return new Float64Array(r.buffer,r.byteOffset,o);default:return new Array(0)}}function Nt(a,e,n){let o=a.HEAPU8.subarray(e,e+n);return new Uint8Array(o.buffer,o.byteOffset,n)}function We(a,e,n){let o=a.HEAPU8.subarray(e,e+n*8);return new Float64Array(o.buffer,o.byteOffset,n)}function Gt(a,e,n,o,r,l,d,f){try{let u=a._udfFunctions.get(o);if(!u){nt(e,n,"Unknown UDF with id: "+o);return}let O=Ot.decode(e.HEAPU8.subarray(r,r+l)),_=JSON.parse(O),N=We(e,d,f/8),Y=m=>{var F;let D=null;switch(m.validityBuffer!==void 0&&(D=Nt(e,N[m.validityBuffer],_.rows)),m.physicalType){case"VARCHAR":{if(m.dataBuffer===null||m.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for VARCHAR argument");if(m.lengthBuffer===null||m.lengthBuffer===void 0)throw new Error("malformed data view, expected data length buffer for VARCHAR argument");let P=st(e,N[m.dataBuffer],m.physicalType,_.rows),p=[],U=We(e,N[m.lengthBuffer],_.rows);for(let x=0;x<_.rows;++x){if(D!=null&&!D[x]){p.push(null);continue}let S=e.HEAPU8.subarray(P[x],P[x]+U[x]),$=Ot.decode(S);p.push($)}return x=>p[x]}case"STRUCT":{let P={},p=[];for(let U=0;U<(((F=m.children)==null?void 0:F.length)||0);++U){let x=m.children[U],S=Y(x);p.push($=>{P[x.name]=S($)})}return D!=null?U=>{if(!D[U])return null;for(let x of p)x(U);return P}:U=>{for(let x of p)x(U);return P}}default:{if(m.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for argument of type: "+m.physicalType);let P=st(e,N[m.dataBuffer],m.physicalType,_.rows);return D!=null?p=>D[p]?P[p]:null:p=>P[p]}}},R=[];for(let m=0;m<_.args.length;++m)R.push(Y(_.args[m]));let M=_.rows*at(_.ret.physicalType),X=e._malloc(M),Q=st(e,X,_.ret.physicalType,_.rows),re=e._malloc(_.rows),J=Nt(e,re,_.rows);if(Q.length==0||J.length==0){nt(e,n,"Can't create physical arrays for result");return}let q=Q;_.ret.physicalType=="VARCHAR"&&(q=new Array(_.rows));let se=[];for(let m=0;m<_.args.length;++m)se.push(null);for(let m=0;m<_.rows;++m){for(let F=0;F<_.args.length;++F)se[F]=R[F](m);let D=u.func(...se);q[m]=D,J[m]=D==null?0:1}let ne=0;switch(_.ret.physicalType){case"VARCHAR":{let m=new Array(0);ne=e._malloc(_.rows*at("DOUBLE"));let D=We(e,ne,_.rows),F=0;for(let x=0;x<_.rows;++x){let S=Wt.encode(q[x]||"");m.push(S),D[x]=S.length,F+=S.length}let P=e._malloc(F),p=e.HEAPU8.subarray(P,P+F),U=0;for(let x=0;x<_.rows;++x){Q[x]=U;let S=m[x];p.subarray(U,U+S.length).set(S),U+=S.length}}}let b=3*8,A=e._malloc(b),I=We(e,A,3);I[0]=X,I[1]=re,I[2]=ne,e.HEAPF64[(n>>3)+0]=0,e.HEAPF64[(n>>3)+1]=A,e.HEAPF64[(n>>3)+2]=0}catch(u){nt(e,n,u.toString())}}function Es(){let a=new TextDecoder;return e=>(typeof SharedArrayBuffer<"u"&&e.buffer instanceof SharedArrayBuffer&&(e=new Uint8Array(e)),a.decode(e))}var vs=Es();function ue(a,e){console.error(`FAIL WITH: ${e}`),a.ccall("duckdb_web_fail_with",null,["string"],[e])}function Ie(a){let e=a.wasmMemory;if(e&&e.buffer!==a.HEAPU8.buffer){let n=e.buffer;a.HEAPU8=new Uint8Array(n),a.HEAPF64=new Float64Array(n)}}function Fe(a,e,n){Ie(a);let o=new Uint8Array(a.HEAPU8.buffer,e,n),r=new Uint8Array(new ArrayBuffer(o.byteLength));return r.set(o),r}function W(a,e,n){return Ie(a),vs(new Uint8Array(a.HEAPU8.buffer,e,n))}function j(a,e,n,o){let r=a.stackSave(),l=a.stackAlloc(3*8);n.unshift("number"),o.unshift(l),a.ccall(e,null,n,o),Ie(a);let d=a.HEAPF64[(l>>3)+0],f=a.HEAPF64[(l>>3)+1],u=a.HEAPF64[(l>>3)+2];return a.stackRestore(r),[d,f,u]}function ee(a){a.ccall("duckdb_web_clear_response",null,[],[])}var Ge=class{constructor(e){let n=new Float64Array(e.buffer,e.byteOffset,e.byteLength/8),o=new Uint8Array(new ArrayBuffer(e.byteLength));o.set(e.subarray(7*8)),this.totalFileReadsCold=n[0],this.totalFileReadsAhead=n[1],this.totalFileReadsCached=n[2],this.totalFileWrites=n[3],this.totalPageAccesses=n[4],this.totalPageLoads=n[5],this.blockSize=n[6],this.blockStats=o}getBlockStats(e,n){return n=n||{file_reads_cold:0,file_reads_ahead:0,file_reads_cached:0,file_writes:0,page_accesses:0,page_loads:0},n.file_writes=this.blockStats[e*3+0]&15,n.file_reads_cold=this.blockStats[e*3+0]>>4,n.file_reads_ahead=this.blockStats[e*3+1]&15,n.file_reads_cached=this.blockStats[e*3+1]>>4,n.page_accesses=this.blockStats[e*3+1]&15,n.page_loads=this.blockStats[e*3+1]>>4,n}};var Ue=new TextEncoder;function ae(a){return a!==0}var Ke=class{constructor(e,n){this._instance=null;this._initPromise=null;this._initPromiseResolver=()=>{};this.onInstantiationProgress=[];this._logger=e,this._runtime=n,this._nextUDFId=1}get logger(){return this._logger}get mod(){return this._instance}get pthread(){return this.mod.PThread||null}async instantiate(e=n=>{}){return this._instance!=null?this:(this._initPromise!=null&&(this.onInstantiationProgress.push(e),await this._initPromise),this._initPromise=new Promise(n=>{this._initPromiseResolver=n}),this.onInstantiationProgress=[e],this._instance=await this.instantiateImpl({print:console.log.bind(console),printErr:console.log.bind(console),onRuntimeInitialized:this._initPromiseResolver}),await this._initPromise,this._initPromise=null,this.onInstantiationProgress=this.onInstantiationProgress.filter(n=>n!=e),globalThis.DUCKDB_BINDINGS=this,this)}open(e){let[n,o,r]=j(this.mod,"duckdb_web_open",["string"],[JSON.stringify(e)]);if(n!==0)throw new Error(W(this.mod,o,r));ee(this.mod)}reset(){let[e,n,o]=j(this.mod,"duckdb_web_reset",[],[]);if(e!==0)throw new Error(W(this.mod,n,o));ee(this.mod)}getVersion(){let[e,n,o]=j(this.mod,"duckdb_web_get_version",[],[]);if(e!==0)throw new Error(W(this.mod,n,o));let r=W(this.mod,n,o);return ee(this.mod),r}getFeatureFlags(){return this.mod.ccall("duckdb_web_get_feature_flags","number",[],[])}tokenize(e){let n=Ue.encode(e),o=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,o,n.length).set(n);let[l,d,f]=j(this.mod,"duckdb_web_tokenize_buffer",["number","number"],[o,n.length]);if(this.mod._free(o),l!==0)throw new Error(W(this.mod,d,f));let u=W(this.mod,d,f);return ee(this.mod),JSON.parse(u)}connect(){let e=this.mod.ccall("duckdb_web_connect","number",[],[]);return new Oe(this,e)}disconnect(e){if(this.mod.ccall("duckdb_web_disconnect",null,["number"],[e]),this.pthread)for(let n of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])n.postMessage({cmd:"dropUDFFunctions",connectionId:e})}runQuery(e,n){let o=Ue.encode(n),r=this.mod._malloc(o.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,o.length).set(o);let[d,f,u]=j(this.mod,"duckdb_web_query_run_buffer",["number","number","number"],[e,r,o.length]);if(this.mod._free(r),d!==0)throw new Error(W(this.mod,f,u));let O=Fe(this.mod,f,u);return ee(this.mod),O}startPendingQuery(e,n,o=!1){let r=Ue.encode(n),l=this.mod._malloc(r.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,l,r.length).set(r);let[f,u,O]=j(this.mod,"duckdb_web_pending_query_start_buffer",["number","number","number","boolean"],[e,l,r.length,o]);if(this.mod._free(l),f!==0)throw new Error(W(this.mod,u,O));if(u==0)return null;let _=Fe(this.mod,u,O);return ee(this.mod),_}pollPendingQuery(e){let[n,o,r]=j(this.mod,"duckdb_web_pending_query_poll",["number"],[e]);if(n!==0)throw new Error(W(this.mod,o,r));if(o==0)return null;let l=Fe(this.mod,o,r);return ee(this.mod),l}cancelPendingQuery(e){return this.mod.ccall("duckdb_web_pending_query_cancel","boolean",["number"],[e])}fetchQueryResults(e){let[n,o,r]=j(this.mod,"duckdb_web_query_fetch_results",["number"],[e]);if(Ct(n))return ee(this.mod),null;if(!Lt(n))throw new Error("Unexpected StatusCode from duckdb_web_query_fetch_results ("+n+") and with self reported error as"+W(this.mod,o,r));if(n!==0)throw new Error(W(this.mod,o,r));let l=Fe(this.mod,o,r);return ee(this.mod),l}getTableNames(e,n){let o=Ue.encode(n),r=this.mod._malloc(o.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,o.length).set(o);let[d,f,u]=j(this.mod,"duckdb_web_get_tablenames_buffer",["number","number","number"],[e,r,o.length]);if(this.mod._free(r),d!==0)throw new Error(W(this.mod,f,u));let O=W(this.mod,f,u);return ee(this.mod),JSON.parse(O)}createPrepared(e,n){let o=Ue.encode(n),r=this.mod._malloc(o.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,o.length).set(o);let[d,f,u]=j(this.mod,"duckdb_web_prepared_create_buffer",["number","number","number"],[e,r,o.length]);if(this.mod._free(r),ae(d))throw new Error(W(this.mod,f,u));return ee(this.mod),f}closePrepared(e,n){let[o,r,l]=j(this.mod,"duckdb_web_prepared_close",["number","number"],[e,n]);if(ae(o))throw new Error(W(this.mod,r,l));ee(this.mod)}runPrepared(e,n,o){let[r,l,d]=j(this.mod,"duckdb_web_prepared_run",["number","number","string"],[e,n,JSON.stringify(o)]);if(ae(r))throw new Error(W(this.mod,l,d));let f=Fe(this.mod,l,d);return ee(this.mod),f}sendPrepared(e,n,o){let[r,l,d]=j(this.mod,"duckdb_web_prepared_send",["number","number","string"],[e,n,JSON.stringify(o)]);if(ae(r))throw new Error(W(this.mod,l,d));let f=Fe(this.mod,l,d);return ee(this.mod),f}insertArrowFromIPCStream(e,n,o){if(n.length==0)return;let r=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,n.length).set(n);let d=o?JSON.stringify(o):"",[f,u,O]=j(this.mod,"duckdb_web_insert_arrow_from_ipc_stream",["number","number","number","string"],[e,r,n.length,d]);if(this.mod._free(r),f!==0)throw new Error(W(this.mod,u,O))}insertCSVFromPath(e,n,o){let r=JSON.stringify(o),[l,d,f]=j(this.mod,"duckdb_web_insert_csv_from_path",["number","string","string"],[e,n,r]);if(ae(l))throw new Error(W(this.mod,d,f))}insertJSONFromPath(e,n,o){let r=JSON.stringify(o),[l,d,f]=j(this.mod,"duckdb_web_insert_json_from_path",["number","string","string"],[e,n,r]);if(ae(l))throw new Error(W(this.mod,d,f))}globFiles(e){let[n,o,r]=j(this.mod,"duckdb_web_fs_glob_file_infos",["string"],[e]);if(ae(n))throw new Error(W(this.mod,o,r));let l=W(this.mod,o,r);ee(this.mod);let d=JSON.parse(l);return d==null?[]:d}registerFileURL(e,n,o,r=!1){n===void 0&&(n=e);let[l,d,f]=j(this.mod,"duckdb_web_fs_register_file_url",["string","string"],[e,n,o,r]);if(ae(l))throw new Error(W(this.mod,d,f));ee(this.mod)}registerFileText(e,n){let o=Ue.encode(n);this.registerFileBuffer(e,o)}registerFileBuffer(e,n){let o=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,o,n.length).set(n);let[l,d,f]=j(this.mod,"duckdb_web_fs_register_file_buffer",["string","number","number"],[e,o,n.length]);if(ae(l))throw new Error(W(this.mod,d,f));ee(this.mod)}async prepareFileHandle(e,n){if(n===3&&this._runtime.prepareFileHandles){let o=await this._runtime.prepareFileHandles([e],3);for(let r of o){let{handle:l,path:d,fromCached:f}=r;!f&&l.getSize()&&await this.registerFileHandleAsync(d,l,3,!0)}return}throw new Error(`prepareFileHandle: unsupported protocol ${n}`)}async prepareDBFileHandle(e,n){if(n===3&&this._runtime.prepareDBFileHandle){let o=await this._runtime.prepareDBFileHandle(e,3);for(let r of o){let{handle:l,path:d,fromCached:f}=r;!f&&l.getSize()&&await this.registerFileHandleAsync(d,l,3,!0)}return}throw new Error(`prepareDBFileHandle: unsupported protocol ${n}`)}async prepareFileHandleAsync(e,n,o,r){if(o===3&&!(n instanceof FileSystemSyncAccessHandle)){if(n instanceof FileSystemFileHandle){let l=n;try{n=await l.createSyncAccessHandle()}catch(d){throw new Error(d.message+":"+e)}}else if(e!=null)try{n=await(await(await navigator.storage.getDirectory()).getFileHandle(e)).createSyncAccessHandle()}catch(l){throw new Error(l.message+":"+e)}}return n}async registerFileHandleAsync(e,n,o,r){let l=await this.prepareFileHandleAsync(e,n,o,r);this.registerFileHandle(e,l,o,r)}registerFileHandle(e,n,o,r){var u;let[l,d,f]=j(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[e,e,o,r]);if(ae(l))throw new Error(W(this.mod,d,f));if(ee(this.mod),globalThis.DUCKDB_RUNTIME._files=(globalThis.DUCKDB_RUNTIME._files||new Map).set(e,n),(u=globalThis.DUCKDB_RUNTIME._preparedHandles)!=null&&u[e]&&delete globalThis.DUCKDB_RUNTIME._preparedHandles[e],this.pthread){for(let O of this.pthread.runningWorkers)O.postMessage({cmd:"registerFileHandle",fileName:e,fileHandle:n});for(let O of this.pthread.unusedWorkers)O.postMessage({cmd:"dropFileHandle",fileName:e})}}dropFile(e){let[n,o,r]=j(this.mod,"duckdb_web_fs_drop_file",["string"],[e]);if(ae(n))throw new Error(W(this.mod,o,r));ee(this.mod)}dropFiles(e){let n=[],o=-1;try{for(let f of e!=null?e:[])if(f!=null&&f.length>0){let u=this.mod.lengthBytesUTF8(f)+1,O=this.mod._malloc(u)>>>0;if(!O)throw new Error(`Failed to allocate memory for string: ${f}`);this.mod.stringToUTF8(f,O,u),n.push(O)}if(o=this.mod._malloc(n.length*4)>>>0,!o)throw new Error("Failed to allocate memory for pointers array");for(let f=0;f<n.length;f++)this.mod.HEAP32[(o>>2)+f]=n[f];let[r,l,d]=j(this.mod,"duckdb_web_fs_drop_files",["number","number"],[o,n.length]);if(r!==0)throw new Error(W(this.mod,l,d));ee(this.mod)}finally{for(let r of n)this.mod._free(r);o>0&&this.mod._free(o)}}flushFiles(){this.mod.ccall("duckdb_web_flush_files",null,[],[])}copyFileToPath(e,n){let[o,r,l]=j(this.mod,"duckdb_web_copy_file_to_path",["string","string"],[e,n]);if(ae(o))throw new Error(W(this.mod,r,l));ee(this.mod)}copyFileToBuffer(e){let[n,o,r]=j(this.mod,"duckdb_web_copy_file_to_buffer",["string"],[e]);if(ae(n))throw new Error(W(this.mod,o,r));Ie(this.mod);let l=new Uint8Array(this.mod.HEAPU8.buffer,o,r),d=new Uint8Array(l.length);return d.set(l),ee(this.mod),d}async registerOPFSFileName(e){if(e.startsWith("opfs://"))return this.prepareFileHandle(e,3);throw new Error("Not an OPFS file name: "+e)}collectFileStatistics(e,n){let[o,r,l]=j(this.mod,"duckdb_web_collect_file_stats",["string","boolean"],[e,n]);if(ae(o))throw new Error(W(this.mod,r,l))}exportFileStatistics(e){let[n,o,r]=j(this.mod,"duckdb_web_export_file_stats",["string"],[e]);if(ae(n))throw new Error(W(this.mod,o,r));return Ie(this.mod),new Ge(new Uint8Array(this.mod.HEAPU8.buffer,o,r))}};var $e=class{constructor(){this._bindings=null;this._nextMessageId=0}log(e){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:e},[])}sendOK(e){this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"OK",data:null},[])}failWith(e,n){let o={name:n.name,message:n.message,stack:n.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"ERROR",data:o},[])}async onMessage(e){switch(e.type){case"PING":this.sendOK(e);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(e,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(e.data[0],e.data[1],n=>{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"INSTANTIATE_PROGRESS",data:n},[])}),this.sendOK(e)}catch(n){console.log(n),this._bindings=null,this.failWith(e,n)}return;default:break}if(!this._bindings)return this.failWith(e,new Error("duckdb is not initialized"));try{switch(e.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(e);break;case"OPEN":{let n=e.data.path,o=!!(this._bindings.getFeatureFlags()&2);if(n!=null&&n.startsWith("opfs://")&&!o){let r=globalThis.DUCKDB_RUNTIME;r!=null&&r.prepareDBFileHandle&&await r.prepareDBFileHandle(n,3),e.data.useDirectIO=!0}this._bindings.open(e.data),this.sendOK(e);break}case"DROP_FILE":this._bindings.dropFile(e.data),this.sendOK(e);break;case"DROP_FILES":this._bindings.dropFiles(e.data),this.sendOK(e);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(e);break;case"CONNECT":{let n=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"CONNECTION_INFO",data:n.useUnsafe((o,r)=>r)},[]);break}case"DISCONNECT":this._bindings.disconnect(e.data),this.sendOK(e);break;case"CREATE_PREPARED":{let n=this._bindings.createPrepared(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"PREPARED_STATEMENT_ID",data:n},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(e.data[0],e.data[1]),this.sendOK(e);break}case"RUN_PREPARED":{let n=this._bindings.runPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:n},[n.buffer]);break}case"RUN_QUERY":{let n=this._bindings.runQuery(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:n},[n.buffer]);break}case"SEND_PREPARED":{let n=this._bindings.sendPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER",data:n},[n.buffer]);break}case"START_PENDING_QUERY":{let n=this._bindings.startPendingQuery(e.data[0],e.data[1],e.data[2]),o=[];n&&o.push(n.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:n},o);break}case"POLL_PENDING_QUERY":{let n=this._bindings.pollPendingQuery(e.data),o=[];n&&o.push(n.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:n},o);break}case"CANCEL_PENDING_QUERY":{let n=this._bindings.cancelPendingQuery(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SUCCESS",data:n},[]);break}case"FETCH_QUERY_RESULTS":{let n=this._bindings.fetchQueryResults(e.data),o=n?[n.buffer]:[];this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_CHUNK",data:n},o);break}case"GET_TABLE_NAMES":{let n=this._bindings.getTableNames(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"TABLE_NAMES",data:n},[]);break}case"GLOB_FILE_INFOS":{let n=this._bindings.globFiles(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_INFOS",data:n},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_FILE_HANDLE":await this._bindings.registerFileHandleAsync(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(e.data[0],e.data[1]),this.sendOK(e);break;case"COPY_FILE_TO_BUFFER":{let n=this._bindings.copyFileToBuffer(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_BUFFER",data:n},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_OPFS_FILE_NAME":await this._bindings.registerOPFSFileName(e.data[0]),this.sendOK(e);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(e.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"TOKENIZE":{let n=this._bindings.tokenize(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SCRIPT_TOKENS",data:n},[]);break}}}catch(n){return console.log(n),this.failWith(e,n)}}};var qt=Bt(Vt());var Ve=class extends Ke{constructor(e,n,o,r){super(e,n),this.mainModuleURL=o,this.pthreadWorkerURL=r}locateFile(e,n){if(e.endsWith(".wasm"))return this.mainModuleURL;if(e.endsWith(".worker.js")){if(!this.pthreadWorkerURL)throw new Error("Missing DuckDB worker URL!");return this.pthreadWorkerURL}throw new Error(`WASM instantiation requested unexpected file: prefix=${n} path=${e}`)}instantiateWasm(e,n){globalThis.DUCKDB_RUNTIME=this._runtime;let o=this.onInstantiationProgress;if(WebAssembly.instantiateStreaming)if(typeof TransformStream=="function"){let l=(async()=>{var M;let d=new Request(this.mainModuleURL),f=await fetch(d),u=f.headers.get("content-length"),O=u&&parseInt(u,10)||0,_=new Date,N={startedAt:_,updatedAt:_,bytesTotal:O||0,bytesLoaded:0},Y={transform(X,Q){N.bytesLoaded+=X.byteLength;let re=new Date;if(re.getTime()-N.updatedAt.getTime()<20){N.updatedAt=re,Q.enqueue(X);return}for(let J of o)J(N);Q.enqueue(X)}},R=new TransformStream(Y);return new Response((M=f.body)==null?void 0:M.pipeThrough(R),f)})();WebAssembly.instantiateStreaming(l,e).then(d=>{n(d.instance,d.module)})}else{console.warn("instantiating without progress handler since transform streams are unavailable");let r=new Request(this.mainModuleURL);WebAssembly.instantiateStreaming(fetch(r),e).then(l=>{n(l.instance,l.module)})}else if(typeof XMLHttpRequest=="function"){let r=new XMLHttpRequest,l=this.mainModuleURL,d=new Date,f={startedAt:d,updatedAt:d,bytesTotal:0,bytesLoaded:0};r.open("GET",l),r.responseType="arraybuffer",r.onerror=u=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to load WASM: "+u}),new Error(u.toString())},r.onprogress=u=>{f.bytesTotal=u.total,f.bytesLoaded=u.loaded;let O=new Date;if(O.getTime()-f.updatedAt.getTime()<20){f.updatedAt=O;return}for(let _ of o)_(f)},r.onload=()=>{WebAssembly.instantiate(r.response,e).then(u=>{n(u.instance,u.module)}).catch(u=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to instantiate WASM: "+u}),new Error(u)})},r.send()}else console.warn("instantiating with manual fetch since streaming instantiation and xhrs are unavailable"),(async()=>{let l=new Request(this.mainModuleURL),f=await(await fetch(l)).arrayBuffer();WebAssembly.instantiate(f,e).then(u=>{n(u.instance,u.module)})})();return{}}};var qe=class extends Ve{constructor(e,n,o,r=null){super(e,n,o,r)}instantiateImpl(e){return(0,qt.default)({...e,instantiateWasm:this.instantiateWasm.bind(this),locateFile:this.locateFile.bind(this)})}};var Ee=Bt(zt()),Yt=function(a,e,n){var o;if((o=a==null?void 0:a.endpoint)!=null&&o.startsWith("http")){let r=`${a==null?void 0:a.endpoint}`,l=r.indexOf("://")+3;return r.substring(l)}else return a!=null&&a.endpoint?`${n}.${a==null?void 0:a.endpoint}`:`${n}.s3.amazonaws.com`};function As(a,e,n){var l,d,f,u;let o=Qt(e),r=o.path;return Zt(a)&&(r=`/${o.bucket}${r}`),{url:r,query:"",host:Yt(a,e,o.bucket),region:(l=a==null?void 0:a.region)!=null?l:"",service:"s3",method:n,accessKeyId:(d=a==null?void 0:a.accessKeyId)!=null?d:"",secretAccessKey:(f=a==null?void 0:a.secretAccessKey)!=null?f:"",sessionToken:(u=a==null?void 0:a.sessionToken)!=null?u:"",dateNow:new Date().toISOString().replace(/-/g,"").split("T")[0],datetimeNow:new Date().toISOString().replace(/-/g,"").replace(/:/g,"").split(".")[0]+"Z"}}function Ss(a,e=!1){let n="0123456789ABCDEF",o="";for(let r=0;r<a.length;r++){let l=a[r];l>="A"&&l<="Z"||l>="a"&&l<="z"||l>="0"&&l<="9"||l=="_"||l=="-"||l=="~"||l=="."?o+=l:l=="/"?e?o+="%2F":o+=l:(o+="%",o+=n[l.charCodeAt(0)>>4],o+=n[l.charCodeAt(0)&15])}return o}function Rs(a,e=null){var M;let n=(M=e==null?void 0:e.contentHash)!=null?M:"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",o=new Map;o.set("x-amz-date",a.datetimeNow),o.set("x-amz-content-sha256",n),a.sessionToken&&o.set("x-amz-security-token",a.sessionToken);let r="";e!=null&&e.contentType&&(r+="content-type;"),r+="host;x-amz-content-sha256;x-amz-date",a.sessionToken&&(r+=";x-amz-security-token");let l=a.method+`
2
+ `+Ss(a.url)+`
3
3
  `+a.query;e!=null&&e.contentType&&(l+=`
4
4
  content-type:`+(e==null?void 0:e.contentType)),l+=`
5
5
  host:`+a.host+`
@@ -11,7 +11,7 @@ x-amz-security-token:`+a.sessionToken),l+=`
11
11
  `+n;let d=(0,Ee.sha256)(l),f=`AWS4-HMAC-SHA256
12
12
  `+a.datetimeNow+`
13
13
  `+a.dateNow+"/"+a.region+"/"+a.service+`/aws4_request
14
- `+d,u="AWS4"+a.secretAccessKey,O=Ee.sha256.hmac.arrayBuffer(u,a.dateNow),_=Ee.sha256.hmac.arrayBuffer(O,a.region),N=Ee.sha256.hmac.arrayBuffer(_,a.service),Y=Ee.sha256.hmac.arrayBuffer(N,"aws4_request"),R=Ee.sha256.hmac(Y,f);return o.set("Authorization","AWS4-HMAC-SHA256 Credential="+a.accessKeyId+"/"+a.dateNow+"/"+a.region+"/"+a.service+"/aws4_request, SignedHeaders="+r+", Signature="+R),o}var Rs=function(a,e,n,o=null,r=null){let l=Fs(a,e,n),d={contentType:o,contentHash:r?Ee.sha256.hex(r):null};return Ss(l,d)};function ce(a,e,n,o,r=null,l=null){(e!=null&&e.accessKeyId||e!=null&&e.sessionToken)&&(Rs(e,n,o,r,l).forEach((f,u)=>{a.setRequestHeader(u,f)}),r&&a.setRequestHeader("content-type",r))}function Yt(a){if(a.indexOf("s3://")!=0)throw new Error("URL needs to start with s3://");let e=a.indexOf("/",5);if(e==-1)throw new Error("URL needs to contain a '/' after the host");let n=a.substring(5,e);if(!n)throw new Error("URL needs to contain a bucket name");let o=a.substring(e);if(!o)throw new Error("URL needs to contain key");return{bucket:n,path:o}}function Qt(a){var e;return!!((e=a==null?void 0:a.endpoint)!=null&&e.startsWith("http"))}function de(a,e){let n=Yt(e);return Qt(a)?`${a==null?void 0:a.endpoint}/${n.bucket}`+n.path:"https://"+zt(a,e,n.bucket)+n.path}var Ds=7,Zt=/\/|\\/,B={_files:new Map,_fileInfoCache:new Map,_udfFunctions:new Map,_globalFileInfo:null,_preparedHandles:{},_opfsRoot:null,getFileInfo(a,e){try{let n=B._fileInfoCache.get(e),[o,r,l]=j(a,"duckdb_web_fs_get_file_info_by_id",["number","number"],[e,(n==null?void 0:n.cacheEpoch)||0]);if(o!==0)return null;if(l===0)return n;let d=W(a,r,l);ee(a);try{let f=JSON.parse(d);if(f==null)return null;let u={...f,blob:null};return B._fileInfoCache.set(e,u),!B._files.has(u.fileName)&&B._preparedHandles[u.fileName]&&(B._files.set(u.fileName,B._preparedHandles[u.fileName]),delete B._preparedHandles[u.fileName]),u}catch(f){return console.warn(f),null}}catch(n){return console.log(n),null}},getGlobalFileInfo(a){var e;try{let[n,o,r]=j(a,"duckdb_web_get_global_file_info",["number"],[((e=B._globalFileInfo)==null?void 0:e.cacheEpoch)||0]);if(n!==0)return null;if(r===0)return B._globalFileInfo;let l=W(a,o,r);ee(a);let d=JSON.parse(l);return d==null?null:(B._globalFileInfo={...d,blob:null},B._globalFileInfo)}catch(n){return console.log(n),null}},async assignOPFSRoot(){B._opfsRoot||(B._opfsRoot=await navigator.storage.getDirectory())},async prepareFileHandles(a,e){if(e===3){await B.assignOPFSRoot();let n=async r=>{if(B._files.has(r))return{path:r,handle:B._files.get(r),fromCached:!0};let d=B._opfsRoot,f=r.slice(Ds),u=f;if(Zt.test(f)){let _=f.split(Zt);if(_.length===0)throw new Error(`Invalid path ${f}`);if(u=_[_.length-1],!u)throw new Error(`Invalid path ${f}. File Not Found.`);_.pop();for(let N of _)d=await d.getDirectoryHandle(N,{create:!0})}let O=await d.getFileHandle(u,{create:!1}).catch(_=>{if((_==null?void 0:_.name)==="NotFoundError")return console.debug(`File ${r} does not exists yet, creating...`),d.getFileHandle(u,{create:!0});throw _});try{let _=await O.createSyncAccessHandle();return B._preparedHandles[r]=_,{path:r,handle:_,fromCached:!1}}catch(_){throw new Error(_.message+":"+name)}},o=[];for(let r of a){let l=await n(r);o.push(l)}return o}throw new Error(`Unsupported protocol ${e} for paths ${a} with protocol ${e}`)},async prepareDBFileHandle(a,e){if(e===3&&this.prepareFileHandles){let n=[a,`${a}.wal`];return this.prepareFileHandles(n,e)}throw new Error(`Unsupported protocol ${e} for path ${a} with protocol ${e}`)},testPlatformFeature:(a,e)=>{switch(e){case 1:return typeof BigInt64Array<"u";default:return console.warn(`test for unknown feature: ${e}`),!1}},getDefaultDataProtocol(a){return 2},openFile:(a,e,n)=>{var o,r,l,d,f,u,O;try{B._fileInfoCache.delete(e);let _=B.getFileInfo(a,e);switch(_==null?void 0:_.dataProtocol){case 4:case 5:{if(n&1&&n&2)throw new Error(`Opening file ${_.fileName} failed: cannot open file with both read and write flags set`);if(n&32)throw new Error(`Opening file ${_.fileName} failed: appending to HTTP/S3 files is not supported`);if(n&2){let R=new XMLHttpRequest;if(_.dataProtocol==5?(R.open("HEAD",de(_.s3Config,_.dataUrl),!1),ce(R,_.s3Config,_.dataUrl,"HEAD")):R.open("HEAD",_.dataUrl,!1),R.send(null),R.status!=200&&R.status!=404)throw new Error(`Opening file ${_.fileName} failed: Unexpected return status from server (${R.status})`);if(R.status==404&&!(n&8||n&16))throw new Error(`Opening file ${_.fileName} failed: Cannot write to non-existent file without FILE_FLAGS_FILE_CREATE or FILE_FLAGS_FILE_CREATE_NEW flag.`);let M=a._malloc(1),X=new Uint8Array;a.HEAPU8.set(X,M);let Q=a._malloc(3*8);return a.HEAPF64[(Q>>>3)+0]=1,a.HEAPF64[(Q>>>3)+1]=M,a.HEAPF64[(Q>>>3)+2]=new Date().getTime()/1e3,Q}else if((n&1)==0)throw new Error(`Opening file ${_.fileName} failed: unsupported file flags: ${n}`);let N=null,Y=null;if(!_.forceFullHttpReads&&(_.reliableHeadRequests||!_.allowFullHttpReads))try{let R=new XMLHttpRequest;_.dataProtocol==5?(R.open("HEAD",de(_.s3Config,_.dataUrl),!1),ce(R,_.s3Config,_.dataUrl,"HEAD")):R.open("HEAD",_.dataUrl,!1),R.setRequestHeader("Range","bytes=0-"),R.send(null),N=null;try{N=R.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}if(N!==null&&R.status==206){let M=a._malloc(24);a.HEAPF64[(M>>>3)+0]=+N,a.HEAPF64[(M>>>3)+1]=0;let X=0;try{X=new Date((o=R.getResponseHeader("Last-Modified"))!=null?o:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return a.HEAPF64[(M>>>3)+2]=+X,M}}catch(R){Y=R,console.warn(`HEAD request with range header failed: ${R}`)}if(_.allowFullHttpReads){if(!_.forceFullHttpReads){let M=new XMLHttpRequest;_.dataProtocol==5?(M.open("GET",de(_.s3Config,_.dataUrl),!1),ce(M,_.s3Config,_.dataUrl,"GET")):M.open("GET",_.dataUrl,!1),M.responseType="arraybuffer",M.setRequestHeader("Range","bytes=0-0"),M.send(null);let X=null;try{X=(r=M.getResponseHeader("Content-Range"))==null?void 0:r.split("/")[1]}catch{console.warn("Failed to get Content-Range on request")}let Q=null;try{Q=M.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}let re=null;if(X!==void 0)re=X;else if(!_.reliableHeadRequests){let J=new XMLHttpRequest;_.dataProtocol==5?(J.open("HEAD",de(_.s3Config,_.dataUrl),!1),ce(J,_.s3Config,_.dataUrl,"HEAD")):J.open("HEAD",_.dataUrl,!1),J.setRequestHeader("Range","bytes=0-"),J.send(null),N=null;try{N=J.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}N!==null&&+N>1&&(re=N)}if(M.status==206&&Q!==null&&+Q==1&&re!==null){let J=a._malloc(24);a.HEAPF64[(J>>>3)+0]=+re,a.HEAPF64[(J>>>3)+1]=0;let q=0;try{q=new Date((l=M.getResponseHeader("Last-Modified"))!=null?l:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return a.HEAPF64[(J>>>3)+2]=+q,J}if(M.status==200&&Q!==null&&N!==null&&+Q==+N){console.warn(`fall back to full HTTP read for: ${_.dataUrl}`);let J=a._malloc(M.response.byteLength),q=new Uint8Array(M.response,0,M.response.byteLength);a.HEAPU8.set(q,J);let se=a._malloc(3*8);a.HEAPF64[(se>>>3)+0]=M.response.byteLength,a.HEAPF64[(se>>>3)+1]=J;let ne=0;try{ne=new Date((d=M.getResponseHeader("Last-Modified"))!=null?d:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return a.HEAPF64[(se>>>3)+2]=+ne,se}console.warn(`falling back to full HTTP read for: ${_.dataUrl}`)}let R=new XMLHttpRequest;if(_.dataProtocol==5?(R.open("GET",de(_.s3Config,_.dataUrl),!1),ce(R,_.s3Config,_.dataUrl,"GET")):R.open("GET",_.dataUrl,!1),R.responseType="arraybuffer",R.send(null),R.status==200){let M=a._malloc(R.response.byteLength),X=new Uint8Array(R.response,0,R.response.byteLength);a.HEAPU8.set(X,M);let Q=a._malloc(3*8);a.HEAPF64[(Q>>>3)+0]=R.response.byteLength,a.HEAPF64[(Q>>>3)+1]=M;let re=0;try{re=new Date((f=R.getResponseHeader("Last-Modified"))!=null?f:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return a.HEAPF64[(Q>>>3)+2]=+re,Q}}if(Y!=null)throw new Error(`Reading file ${_.fileName} failed with error: ${Y}`);return 0}case 2:{let N=(u=B._files)==null?void 0:u.get(_.fileName);if(N){let M=a._malloc(24);return a.HEAPF64[(M>>>3)+0]=N.size,a.HEAPF64[(M>>>3)+1]=0,a.HEAPF64[(M>>>3)+2]=0,M}if(n&128)return 0;console.warn(`Buffering missing file: ${_.fileName}`);let Y=a._malloc(3*8),R=a._malloc(1);return a.HEAPF64[(Y>>>3)+0]=1,a.HEAPF64[(Y>>>3)+1]=R,a.HEAPF64[(Y>>>3)+2]=0,Y}case 3:{let N=(O=B._files)==null?void 0:O.get(_.fileName);if(!N)throw new Error(`No OPFS access handle registered with name: ${_.fileName}`);n&16&&N.truncate(0);let Y=a._malloc(3*8),R=N.getSize();return a.HEAPF64[(Y>>>3)+0]=R,a.HEAPF64[(Y>>>3)+1]=0,a.HEAPF64[(Y>>>3)+2]=0,Y}}}catch(_){console.error(_.toString()),ue(a,_.toString())}return 0},glob:(a,e,n)=>{var o;try{let r=W(a,e,n);if(r.startsWith("http")||r.startsWith("s3://")){let l=new XMLHttpRequest;if(r.startsWith("s3://")){let d=B.getGlobalFileInfo(a);l.open("HEAD",de(d==null?void 0:d.s3Config,r),!1),ce(l,d==null?void 0:d.s3Config,r,"HEAD")}else l.open("HEAD",r,!1);if(l.send(null),l.status!=200&&l.status!==206){if(!((o=B.getGlobalFileInfo(a))!=null&&o.allowFullHttpReads))return console.log(`HEAD request failed: ${r}, with full http reads are disabled`),0;let d=new XMLHttpRequest;if(r.startsWith("s3://")){let u=B.getGlobalFileInfo(a);d.open("GET",de(u==null?void 0:u.s3Config,r),!1),ce(d,u==null?void 0:u.s3Config,r,"HEAD")}else d.open("GET",r,!1);if(d.setRequestHeader("Range","bytes=0-0"),d.send(null),d.status!=200&&d.status!==206)return console.log(`HEAD and GET requests failed: ${r}`),0;let f=null;try{f=d.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}f&&+f>1&&console.warn(`Range request for ${r} did not return a partial response: ${d.status} "${d.statusText}"`)}a.ccall("duckdb_web_fs_glob_add_path",null,["string"],[r])}else for(let[l]of B._files.entries()||[])l.startsWith(r)&&a.ccall("duckdb_web_fs_glob_add_path",null,["string"],[l])}catch(r){return console.log(r),ue(a,r.toString()),0}},checkFile:(a,e,n)=>{try{let o=W(a,e,n);if(o.startsWith("http")||o.startsWith("s3://")){let r=new XMLHttpRequest;if(o.startsWith("s3://")){let l=B.getGlobalFileInfo(a);r.open("HEAD",de(l==null?void 0:l.s3Config,o),!1),ce(r,l==null?void 0:l.s3Config,o,"HEAD")}else r.open("HEAD",o,!1);return r.send(null),r.status==206||r.status==200}else return B._files.has(o)}catch(o){return console.log(o),!1}return!1},syncFile:(a,e)=>{},closeFile:(a,e)=>{var o;let n=B.getFileInfo(a,e);B._fileInfoCache.delete(e);try{switch(n==null?void 0:n.dataProtocol){case 0:case 4:case 5:break;case 1:case 2:return;case 3:{let r=(o=B._files)==null?void 0:o.get(n.fileName);if(!r)throw new Error(`No OPFS access handle registered with name: ${n.fileName}`);return r.flush()}}}catch(r){console.log(r),ue(a,r.toString())}},dropFile:(a,e,n)=>{var l;let o=W(a,e,n),r=(l=B._files)==null?void 0:l.get(o);if(r){if(B._files.delete(o),r instanceof FileSystemSyncAccessHandle)try{r.flush(),r.close()}catch{throw new Error(`Cannot drop file with name: ${o}`)}r instanceof Blob}},truncateFile:(a,e,n)=>{var r;let o=B.getFileInfo(a,e);switch(o==null?void 0:o.dataProtocol){case 4:ue(a,"Cannot truncate a http file");return;case 5:ue(a,"Cannot truncate an s3 file");return;case 0:case 1:case 2:ue(a,"truncateFile not implemented");return;case 3:{let l=(r=B._files)==null?void 0:r.get(o.fileName);if(!l)throw new Error(`No OPFS access handle registered with name: ${o.fileName}`);return l.truncate(n)}}return 0},readFile(a,e,n,o,r){var l;if(o==0)return 0;try{let d=B.getFileInfo(a,e);switch(d==null?void 0:d.dataProtocol){case 4:case 5:{if(!d.dataUrl)throw new Error(`Missing data URL for file ${e}`);try{let f=new XMLHttpRequest;if(d.dataProtocol==5?(f.open("GET",de(d==null?void 0:d.s3Config,d.dataUrl),!1),ce(f,d==null?void 0:d.s3Config,d.dataUrl,"GET")):f.open("GET",d.dataUrl,!1),f.responseType="arraybuffer",f.setRequestHeader("Range",`bytes=${r}-${r+o-1}`),f.send(null),f.status==206||f.status==200&&o==f.response.byteLength&&r==0){let u=new Uint8Array(f.response,0,Math.min(f.response.byteLength,o));return a.HEAPU8.set(u,n),u.byteLength}else if(f.status==200){console.warn(`Range request for ${d.dataUrl} did not return a partial response: ${f.status} "${f.statusText}"`);let u=new Uint8Array(f.response,r,Math.min(f.response.byteLength-r,o));return a.HEAPU8.set(u,n),u.byteLength}else throw new Error(`Range request for ${d.dataUrl} did returned non-success status: ${f.status} "${f.statusText}"`)}catch(f){throw console.log(f),new Error(`Range request for ${d.dataUrl} failed with error: ${f}"`)}}case 2:{let f=(l=B._files)==null?void 0:l.get(d.fileName);if(!f)throw new Error(`No HTML5 file registered with name: ${d.fileName}`);let u=f.slice(r,r+o),O=new Uint8Array(new FileReaderSync().readAsArrayBuffer(u));return a.HEAPU8.set(O,n),O.byteLength}case 3:{let f=B._files.get(d.fileName);if(!f)throw new Error(`No OPFS access handle registered with name: ${d.fileName}`);let u=a.HEAPU8.subarray(n,n+o);return f.read(u,{at:r})}}return 0}catch(d){return console.log(d),ue(a,d.toString()),0}},writeFile:(a,e,n,o,r)=>{var d;let l=B.getFileInfo(a,e);switch(l==null?void 0:l.dataProtocol){case 4:return ue(a,"Cannot write to HTTP file"),0;case 5:{let f=a.HEAPU8.subarray(n,n+o),u=new XMLHttpRequest;return u.open("PUT",de(l==null?void 0:l.s3Config,l.dataUrl),!1),ce(u,l==null?void 0:l.s3Config,l.dataUrl,"PUT","",f),u.send(f),u.status!==200?(ue(a,"Failed writing file: HTTP "+u.status),0):o}case 2:return ue(a,"cannot write using the html5 file reader api"),0;case 3:{let f=(d=B._files)==null?void 0:d.get(l.fileName);if(!f)throw new Error(`No OPFS access handle registered with name: ${l.fileName}`);let u=a.HEAPU8.subarray(n,n+o);return f.write(u,{at:r})}}return 0},getLastFileModificationTime:(a,e)=>{var o;let n=B.getFileInfo(a,e);switch(n==null?void 0:n.dataProtocol){case 2:{if(!((o=B._files)==null?void 0:o.get(n.fileName)))throw Error(`No handle available for file: ${n.fileName}`);return 0}case 4:case 5:return new Date().getTime()/1e3}return 0},progressUpdate:(a,e,n)=>{postMessage&&postMessage({requestId:0,type:"PROGRESS_UPDATE",data:{status:a?"completed":"in-progress",percentage:e,repetitions:n}})},checkDirectory:(a,e,n)=>!1,createDirectory:(a,e,n)=>{},removeDirectory:(a,e,n)=>{},listDirectoryEntries:(a,e,n)=>!1,moveFile:(a,e,n,o,r)=>{var u,O;let l=W(a,e,n),d=W(a,o,r),f=(u=B._files)==null?void 0:u.get(l);f!==void 0&&(B._files.delete(f),B._files.set(d,f));for(let[_,N]of((O=B._fileInfoCache)==null?void 0:O.entries())||[])if(N.dataUrl==l){B._fileInfoCache.delete(_);break}return!0},removeFile:(a,e,n)=>{},callScalarUDF:(a,e,n,o,r,l,d)=>{Wt(B,a,e,n,o,r,l,d)}};var it=class extends Ke{postMessage(e,n){globalThis.postMessage(e,n)}async instantiate(e,n,o){return await new Ve(this,B,e,n).instantiate(o)}};function er(){let a=new it;globalThis.onmessage=async e=>{await a.onMessage(e.data)}}er();return gs(ks);})();
14
+ `+d,u="AWS4"+a.secretAccessKey,O=Ee.sha256.hmac.arrayBuffer(u,a.dateNow),_=Ee.sha256.hmac.arrayBuffer(O,a.region),N=Ee.sha256.hmac.arrayBuffer(_,a.service),Y=Ee.sha256.hmac.arrayBuffer(N,"aws4_request"),R=Ee.sha256.hmac(Y,f);return o.set("Authorization","AWS4-HMAC-SHA256 Credential="+a.accessKeyId+"/"+a.dateNow+"/"+a.region+"/"+a.service+"/aws4_request, SignedHeaders="+r+", Signature="+R),o}var Ds=function(a,e,n,o=null,r=null){let l=As(a,e,n),d={contentType:o,contentHash:r?Ee.sha256.hex(r):null};return Rs(l,d)};function ce(a,e,n,o,r=null,l=null){(e!=null&&e.accessKeyId||e!=null&&e.sessionToken)&&(Ds(e,n,o,r,l).forEach((f,u)=>{a.setRequestHeader(u,f)}),r&&a.setRequestHeader("content-type",r))}function Qt(a){if(a.indexOf("s3://")!=0)throw new Error("URL needs to start with s3://");let e=a.indexOf("/",5);if(e==-1)throw new Error("URL needs to contain a '/' after the host");let n=a.substring(5,e);if(!n)throw new Error("URL needs to contain a bucket name");let o=a.substring(e);if(!o)throw new Error("URL needs to contain key");return{bucket:n,path:o}}function Zt(a){var e;return!!((e=a==null?void 0:a.endpoint)!=null&&e.startsWith("http"))}function de(a,e){let n=Qt(e);return Zt(a)?`${a==null?void 0:a.endpoint}/${n.bucket}`+n.path:"https://"+Yt(a,e,n.bucket)+n.path}var ks=7,er=/\/|\\/,B={_files:new Map,_fileInfoCache:new Map,_udfFunctions:new Map,_globalFileInfo:null,_preparedHandles:{},_opfsRoot:null,getFileInfo(a,e){try{let n=B._fileInfoCache.get(e),[o,r,l]=j(a,"duckdb_web_fs_get_file_info_by_id",["number","number"],[e,(n==null?void 0:n.cacheEpoch)||0]);if(o!==0)return null;if(l===0)return n;let d=W(a,r,l);ee(a);try{let f=JSON.parse(d);if(f==null)return null;let u={...f,blob:null};return B._fileInfoCache.set(e,u),!B._files.has(u.fileName)&&B._preparedHandles[u.fileName]&&(B._files.set(u.fileName,B._preparedHandles[u.fileName]),delete B._preparedHandles[u.fileName]),u}catch(f){return console.warn(f),null}}catch(n){return console.log(n),null}},getGlobalFileInfo(a){var e;try{let[n,o,r]=j(a,"duckdb_web_get_global_file_info",["number"],[((e=B._globalFileInfo)==null?void 0:e.cacheEpoch)||0]);if(n!==0)return null;if(r===0)return B._globalFileInfo;let l=W(a,o,r);ee(a);let d=JSON.parse(l);return d==null?null:(B._globalFileInfo={...d,blob:null},B._globalFileInfo)}catch(n){return console.log(n),null}},async assignOPFSRoot(){B._opfsRoot||(B._opfsRoot=await navigator.storage.getDirectory())},async prepareFileHandles(a,e){if(e===3){await B.assignOPFSRoot();let n=async r=>{if(B._files.has(r))return{path:r,handle:B._files.get(r),fromCached:!0};let d=B._opfsRoot,f=r.slice(ks),u=f;if(er.test(f)){let _=f.split(er);if(_.length===0)throw new Error(`Invalid path ${f}`);if(u=_[_.length-1],!u)throw new Error(`Invalid path ${f}. File Not Found.`);_.pop();for(let N of _)d=await d.getDirectoryHandle(N,{create:!0})}let O=await d.getFileHandle(u,{create:!1}).catch(_=>{if((_==null?void 0:_.name)==="NotFoundError")return console.debug(`File ${r} does not exists yet, creating...`),d.getFileHandle(u,{create:!0});throw _});try{let _=await O.createSyncAccessHandle();return B._preparedHandles[r]=_,{path:r,handle:_,fromCached:!1}}catch(_){throw new Error(_.message+":"+name)}},o=[];for(let r of a){let l=await n(r);o.push(l)}return o}throw new Error(`Unsupported protocol ${e} for paths ${a} with protocol ${e}`)},async prepareDBFileHandle(a,e){if(e===3&&this.prepareFileHandles){let n=[a,`${a}.wal`];return this.prepareFileHandles(n,e)}throw new Error(`Unsupported protocol ${e} for path ${a} with protocol ${e}`)},testPlatformFeature:(a,e)=>{switch(e){case 1:return typeof BigInt64Array<"u";default:return console.warn(`test for unknown feature: ${e}`),!1}},getDefaultDataProtocol(a){return 2},openFile:(a,e,n)=>{var o,r,l,d,f,u,O;try{B._fileInfoCache.delete(e);let _=B.getFileInfo(a,e);switch(_==null?void 0:_.dataProtocol){case 4:case 5:{if(n&1&&n&2)throw new Error(`Opening file ${_.fileName} failed: cannot open file with both read and write flags set`);if(n&32)throw new Error(`Opening file ${_.fileName} failed: appending to HTTP/S3 files is not supported`);if(n&2){let R=new XMLHttpRequest;if(_.dataProtocol==5?(R.open("HEAD",de(_.s3Config,_.dataUrl),!1),ce(R,_.s3Config,_.dataUrl,"HEAD")):R.open("HEAD",_.dataUrl,!1),R.send(null),R.status!=200&&R.status!=404)throw new Error(`Opening file ${_.fileName} failed: Unexpected return status from server (${R.status})`);if(R.status==404&&!(n&8||n&16))throw new Error(`Opening file ${_.fileName} failed: Cannot write to non-existent file without FILE_FLAGS_FILE_CREATE or FILE_FLAGS_FILE_CREATE_NEW flag.`);let M=a._malloc(1),X=new Uint8Array;a.HEAPU8.set(X,M);let Q=a._malloc(3*8);return a.HEAPF64[(Q>>>3)+0]=1,a.HEAPF64[(Q>>>3)+1]=M,a.HEAPF64[(Q>>>3)+2]=new Date().getTime()/1e3,Q}else if((n&1)==0)throw new Error(`Opening file ${_.fileName} failed: unsupported file flags: ${n}`);let N=null,Y=null;if(!_.forceFullHttpReads&&(_.reliableHeadRequests||!_.allowFullHttpReads))try{let R=new XMLHttpRequest;_.dataProtocol==5?(R.open("HEAD",de(_.s3Config,_.dataUrl),!1),ce(R,_.s3Config,_.dataUrl,"HEAD")):R.open("HEAD",_.dataUrl,!1),R.setRequestHeader("Range","bytes=0-"),R.send(null),N=null;try{N=R.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}if(N!==null&&R.status==206){let M=a._malloc(24);a.HEAPF64[(M>>>3)+0]=+N,a.HEAPF64[(M>>>3)+1]=0;let X=0;try{X=new Date((o=R.getResponseHeader("Last-Modified"))!=null?o:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return a.HEAPF64[(M>>>3)+2]=+X,M}}catch(R){Y=R,console.warn(`HEAD request with range header failed: ${R}`)}if(_.allowFullHttpReads){if(!_.forceFullHttpReads){let M=new XMLHttpRequest;_.dataProtocol==5?(M.open("GET",de(_.s3Config,_.dataUrl),!1),ce(M,_.s3Config,_.dataUrl,"GET")):M.open("GET",_.dataUrl,!1),M.responseType="arraybuffer",M.setRequestHeader("Range","bytes=0-0"),M.send(null);let X=null;try{X=(r=M.getResponseHeader("Content-Range"))==null?void 0:r.split("/")[1]}catch{console.warn("Failed to get Content-Range on request")}let Q=null;try{Q=M.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}let re=null;if(X!==void 0)re=X;else if(!_.reliableHeadRequests){let J=new XMLHttpRequest;_.dataProtocol==5?(J.open("HEAD",de(_.s3Config,_.dataUrl),!1),ce(J,_.s3Config,_.dataUrl,"HEAD")):J.open("HEAD",_.dataUrl,!1),J.setRequestHeader("Range","bytes=0-"),J.send(null),N=null;try{N=J.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}N!==null&&+N>1&&(re=N)}if(M.status==206&&Q!==null&&+Q==1&&re!==null){let J=a._malloc(24);a.HEAPF64[(J>>>3)+0]=+re,a.HEAPF64[(J>>>3)+1]=0;let q=0;try{q=new Date((l=M.getResponseHeader("Last-Modified"))!=null?l:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return a.HEAPF64[(J>>>3)+2]=+q,J}if(M.status==200&&Q!==null&&N!==null&&+Q==+N){console.warn(`fall back to full HTTP read for: ${_.dataUrl}`);let J=a._malloc(M.response.byteLength),q=new Uint8Array(M.response,0,M.response.byteLength);a.HEAPU8.set(q,J);let se=a._malloc(3*8);a.HEAPF64[(se>>>3)+0]=M.response.byteLength,a.HEAPF64[(se>>>3)+1]=J;let ne=0;try{ne=new Date((d=M.getResponseHeader("Last-Modified"))!=null?d:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return a.HEAPF64[(se>>>3)+2]=+ne,se}console.warn(`falling back to full HTTP read for: ${_.dataUrl}`)}let R=new XMLHttpRequest;if(_.dataProtocol==5?(R.open("GET",de(_.s3Config,_.dataUrl),!1),ce(R,_.s3Config,_.dataUrl,"GET")):R.open("GET",_.dataUrl,!1),R.responseType="arraybuffer",R.send(null),R.status==200){let M=a._malloc(R.response.byteLength),X=new Uint8Array(R.response,0,R.response.byteLength);a.HEAPU8.set(X,M);let Q=a._malloc(3*8);a.HEAPF64[(Q>>>3)+0]=R.response.byteLength,a.HEAPF64[(Q>>>3)+1]=M;let re=0;try{re=new Date((f=R.getResponseHeader("Last-Modified"))!=null?f:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return a.HEAPF64[(Q>>>3)+2]=+re,Q}}if(Y!=null)throw new Error(`Reading file ${_.fileName} failed with error: ${Y}`);return 0}case 2:{let N=(u=B._files)==null?void 0:u.get(_.fileName);if(N){let M=a._malloc(24);return a.HEAPF64[(M>>>3)+0]=N.size,a.HEAPF64[(M>>>3)+1]=0,a.HEAPF64[(M>>>3)+2]=0,M}if(n&128)return 0;console.warn(`Buffering missing file: ${_.fileName}`);let Y=a._malloc(3*8),R=a._malloc(1);return a.HEAPF64[(Y>>>3)+0]=1,a.HEAPF64[(Y>>>3)+1]=R,a.HEAPF64[(Y>>>3)+2]=0,Y}case 3:{let N=(O=B._files)==null?void 0:O.get(_.fileName);if(!N)throw new Error(`No OPFS access handle registered with name: ${_.fileName}`);n&16&&N.truncate(0);let Y=a._malloc(3*8),R=N.getSize();return a.HEAPF64[(Y>>>3)+0]=R,a.HEAPF64[(Y>>>3)+1]=0,a.HEAPF64[(Y>>>3)+2]=0,Y}}}catch(_){console.error(_.toString()),ue(a,_.toString())}return 0},glob:(a,e,n)=>{var o;try{let r=W(a,e,n);if(r.startsWith("http")||r.startsWith("s3://")){let l=new XMLHttpRequest;if(r.startsWith("s3://")){let d=B.getGlobalFileInfo(a);l.open("HEAD",de(d==null?void 0:d.s3Config,r),!1),ce(l,d==null?void 0:d.s3Config,r,"HEAD")}else l.open("HEAD",r,!1);if(l.send(null),l.status!=200&&l.status!==206){if(!((o=B.getGlobalFileInfo(a))!=null&&o.allowFullHttpReads))return console.log(`HEAD request failed: ${r}, with full http reads are disabled`),0;let d=new XMLHttpRequest;if(r.startsWith("s3://")){let u=B.getGlobalFileInfo(a);d.open("GET",de(u==null?void 0:u.s3Config,r),!1),ce(d,u==null?void 0:u.s3Config,r,"HEAD")}else d.open("GET",r,!1);if(d.setRequestHeader("Range","bytes=0-0"),d.send(null),d.status!=200&&d.status!==206)return console.log(`HEAD and GET requests failed: ${r}`),0;let f=null;try{f=d.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}f&&+f>1&&console.warn(`Range request for ${r} did not return a partial response: ${d.status} "${d.statusText}"`)}a.ccall("duckdb_web_fs_glob_add_path",null,["string"],[r])}else for(let[l]of B._files.entries()||[])l.startsWith(r)&&a.ccall("duckdb_web_fs_glob_add_path",null,["string"],[l])}catch(r){return console.log(r),ue(a,r.toString()),0}},checkFile:(a,e,n)=>{try{let o=W(a,e,n);if(o.startsWith("http")||o.startsWith("s3://")){let r=new XMLHttpRequest;if(o.startsWith("s3://")){let l=B.getGlobalFileInfo(a);r.open("HEAD",de(l==null?void 0:l.s3Config,o),!1),ce(r,l==null?void 0:l.s3Config,o,"HEAD")}else r.open("HEAD",o,!1);return r.send(null),r.status==206||r.status==200}else return B._files.has(o)}catch(o){return console.log(o),!1}return!1},syncFile:(a,e)=>{},closeFile:(a,e)=>{var o;let n=B.getFileInfo(a,e);B._fileInfoCache.delete(e);try{switch(n==null?void 0:n.dataProtocol){case 0:case 4:case 5:break;case 1:case 2:return;case 3:{let r=(o=B._files)==null?void 0:o.get(n.fileName);if(!r)throw new Error(`No OPFS access handle registered with name: ${n.fileName}`);return r.flush()}}}catch(r){console.log(r),ue(a,r.toString())}},dropFile:(a,e,n)=>{var l;let o=W(a,e,n),r=(l=B._files)==null?void 0:l.get(o);if(r){if(B._files.delete(o),r instanceof FileSystemSyncAccessHandle)try{r.flush(),r.close()}catch{throw new Error(`Cannot drop file with name: ${o}`)}r instanceof Blob}},truncateFile:(a,e,n)=>{var r;let o=B.getFileInfo(a,e);switch(o==null?void 0:o.dataProtocol){case 4:ue(a,"Cannot truncate a http file");return;case 5:ue(a,"Cannot truncate an s3 file");return;case 0:case 1:case 2:ue(a,"truncateFile not implemented");return;case 3:{let l=(r=B._files)==null?void 0:r.get(o.fileName);if(!l)throw new Error(`No OPFS access handle registered with name: ${o.fileName}`);return l.truncate(n)}}return 0},readFile(a,e,n,o,r){var l;if(o==0)return 0;try{let d=B.getFileInfo(a,e);switch(d==null?void 0:d.dataProtocol){case 4:case 5:{if(!d.dataUrl)throw new Error(`Missing data URL for file ${e}`);try{let f=new XMLHttpRequest;if(d.dataProtocol==5?(f.open("GET",de(d==null?void 0:d.s3Config,d.dataUrl),!1),ce(f,d==null?void 0:d.s3Config,d.dataUrl,"GET")):f.open("GET",d.dataUrl,!1),f.responseType="arraybuffer",f.setRequestHeader("Range",`bytes=${r}-${r+o-1}`),f.send(null),f.status==206||f.status==200&&o==f.response.byteLength&&r==0){let u=new Uint8Array(f.response,0,Math.min(f.response.byteLength,o));return a.HEAPU8.set(u,n),u.byteLength}else if(f.status==200){console.warn(`Range request for ${d.dataUrl} did not return a partial response: ${f.status} "${f.statusText}"`);let u=new Uint8Array(f.response,r,Math.min(f.response.byteLength-r,o));return a.HEAPU8.set(u,n),u.byteLength}else throw new Error(`Range request for ${d.dataUrl} did returned non-success status: ${f.status} "${f.statusText}"`)}catch(f){throw console.log(f),new Error(`Range request for ${d.dataUrl} failed with error: ${f}"`)}}case 2:{let f=(l=B._files)==null?void 0:l.get(d.fileName);if(!f)throw new Error(`No HTML5 file registered with name: ${d.fileName}`);let u=f.slice(r,r+o),O=new Uint8Array(new FileReaderSync().readAsArrayBuffer(u));return a.HEAPU8.set(O,n),O.byteLength}case 3:{let f=B._files.get(d.fileName);if(!f)throw new Error(`No OPFS access handle registered with name: ${d.fileName}`);let u=a.HEAPU8.subarray(n,n+o);return f.read(u,{at:r})}}return 0}catch(d){return console.log(d),ue(a,d.toString()),0}},writeFile:(a,e,n,o,r)=>{var d;let l=B.getFileInfo(a,e);switch(l==null?void 0:l.dataProtocol){case 4:return ue(a,"Cannot write to HTTP file"),0;case 5:{let f=a.HEAPU8.subarray(n,n+o),u=new XMLHttpRequest;return u.open("PUT",de(l==null?void 0:l.s3Config,l.dataUrl),!1),ce(u,l==null?void 0:l.s3Config,l.dataUrl,"PUT","",f),u.send(f),u.status!==200?(ue(a,"Failed writing file: HTTP "+u.status),0):o}case 2:return ue(a,"cannot write using the html5 file reader api"),0;case 3:{let f=(d=B._files)==null?void 0:d.get(l.fileName);if(!f)throw new Error(`No OPFS access handle registered with name: ${l.fileName}`);let u=a.HEAPU8.subarray(n,n+o);return f.write(u,{at:r})}}return 0},getLastFileModificationTime:(a,e)=>{var o;let n=B.getFileInfo(a,e);switch(n==null?void 0:n.dataProtocol){case 2:{if(!((o=B._files)==null?void 0:o.get(n.fileName)))throw Error(`No handle available for file: ${n.fileName}`);return 0}case 4:case 5:return new Date().getTime()/1e3}return 0},progressUpdate:(a,e,n)=>{postMessage&&postMessage({requestId:0,type:"PROGRESS_UPDATE",data:{status:a?"completed":"in-progress",percentage:e,repetitions:n}})},checkDirectory:(a,e,n)=>!1,createDirectory:(a,e,n)=>{},removeDirectory:(a,e,n)=>{},listDirectoryEntries:(a,e,n)=>!1,moveFile:(a,e,n,o,r)=>{var u,O;let l=W(a,e,n),d=W(a,o,r),f=(u=B._files)==null?void 0:u.get(l);f!==void 0&&(B._files.delete(f),B._files.set(d,f));for(let[_,N]of((O=B._fileInfoCache)==null?void 0:O.entries())||[])if(N.dataUrl==l){B._fileInfoCache.delete(_);break}return!0},removeFile:(a,e,n)=>{},callScalarUDF:(a,e,n,o,r,l,d)=>{Gt(B,a,e,n,o,r,l,d)}};var ot=class extends $e{postMessage(e,n){globalThis.postMessage(e,n)}async instantiate(e,n,o){return await new qe(this,B,e,n).instantiate(o)}};function tr(){let a=new ot;globalThis.onmessage=async e=>{await a.onMessage(e.data)}}tr();return ys(Is);})();
15
15
  /*! Bundled license information:
16
16
 
17
17
  js-sha256/src/sha256.js: