@run-trace/duckdb-wasm 0.1.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +24 -20
  2. package/dist/duckdb-browser-blocking.cjs +14 -0
  3. package/dist/duckdb-browser-blocking.cjs.map +7 -0
  4. package/dist/duckdb-browser-blocking.d.ts +1 -0
  5. package/dist/duckdb-browser-blocking.mjs +14 -0
  6. package/dist/duckdb-browser-blocking.mjs.map +7 -0
  7. package/dist/duckdb-browser-coi.pthread.worker.js +1 -18
  8. package/dist/duckdb-browser-coi.pthread.worker.js.map +4 -4
  9. package/dist/duckdb-browser-coi.worker.js +1 -18
  10. package/dist/duckdb-browser-coi.worker.js.map +4 -4
  11. package/dist/duckdb-browser-eh.worker.js +1 -14
  12. package/dist/duckdb-browser-eh.worker.js.map +4 -4
  13. package/dist/duckdb-browser-mvp.worker.js +1 -14
  14. package/dist/duckdb-browser.cjs +2 -0
  15. package/dist/duckdb-browser.cjs.map +7 -0
  16. package/dist/duckdb-browser.d.ts +1 -1
  17. package/dist/duckdb-browser.mjs +2 -0
  18. package/dist/duckdb-browser.mjs.map +7 -0
  19. package/dist/duckdb-coi.wasm +0 -0
  20. package/dist/duckdb-eh.wasm +0 -0
  21. package/dist/duckdb-mvp.wasm +0 -0
  22. package/dist/duckdb-node-blocking.cjs +53 -0
  23. package/dist/duckdb-node-blocking.cjs.map +7 -0
  24. package/dist/duckdb-node-blocking.d.ts +1 -0
  25. package/dist/duckdb-node-eh.worker.cjs +4 -2
  26. package/dist/duckdb-node-eh.worker.cjs.map +4 -4
  27. package/dist/duckdb-node-mvp.worker.cjs +3 -2
  28. package/dist/duckdb-node-mvp.worker.cjs.map +4 -4
  29. package/dist/duckdb-node.cjs +2 -0
  30. package/dist/duckdb-node.cjs.map +7 -0
  31. package/dist/duckdb-node.d.ts +1 -1
  32. package/dist/types/{bindings → src/bindings}/bindings_base.d.ts +3 -2
  33. package/dist/types/{bindings → src/bindings}/bindings_browser_base.d.ts +2 -1
  34. package/dist/types/{bindings → src/bindings}/bindings_interface.d.ts +2 -0
  35. package/dist/types/{bindings → src/bindings}/bindings_node_base.d.ts +2 -1
  36. package/dist/types/{bindings → src/bindings}/connection.d.ts +18 -6
  37. package/dist/types/{bindings → src/bindings}/duckdb_module.d.ts +1 -3
  38. package/dist/types/src/bindings/index.d.ts +11 -0
  39. package/dist/types/{bindings → src/bindings}/insert_options.d.ts +10 -3
  40. package/dist/types/{bindings → src/bindings}/runtime.d.ts +1 -7
  41. package/dist/types/{bindings → src/bindings}/udf_function.d.ts +3 -2
  42. package/dist/types/src/index.d.ts +7 -0
  43. package/dist/types/{sql_field.d.ts → src/json_typedef.d.ts} +6 -3
  44. package/dist/types/{parallel → src/parallel}/async_bindings_interface.d.ts +2 -2
  45. package/dist/types/{parallel → src/parallel}/async_connection.d.ts +17 -6
  46. package/dist/types/src/parallel/index.d.ts +5 -0
  47. package/dist/types/{platform.d.ts → src/platform.d.ts} +1 -0
  48. package/dist/types/src/targets/duckdb-browser-blocking.d.ts +12 -0
  49. package/dist/types/src/targets/duckdb-browser-coi.pthread.worker.d.ts +1 -0
  50. package/dist/types/src/targets/duckdb-node-blocking.d.ts +13 -0
  51. package/dist/types/src/targets/duckdb.d.ts +9 -0
  52. package/dist/types/src/version.d.ts +5 -0
  53. package/package.json +97 -42
  54. package/dist/duckdb-browser-mvp.worker.js.map +0 -7
  55. package/dist/duckdb-node.mjs +0 -8
  56. package/dist/duckdb-node.mjs.map +0 -7
  57. package/dist/duckdb-wasm.mjs +0 -1160
  58. package/dist/duckdb-wasm.umd.js +0 -1
  59. package/dist/types/bindings/index.d.ts +0 -11
  60. package/dist/types/duckdb.d.ts +0 -8
  61. package/dist/types/index.d.ts +0 -11
  62. package/dist/types/parallel/index.d.ts +0 -5
  63. package/dist/types/targets/duckdb.d.ts +0 -10
  64. package/dist/types/worker_node.d.ts +0 -6
  65. /package/dist/types/{bindings → src/bindings}/bindings_browser_coi.d.ts +0 -0
  66. /package/dist/types/{bindings → src/bindings}/bindings_browser_eh.d.ts +0 -0
  67. /package/dist/types/{bindings → src/bindings}/bindings_browser_mvp.d.ts +0 -0
  68. /package/dist/types/{bindings → src/bindings}/bindings_node_eh.d.ts +0 -0
  69. /package/dist/types/{bindings → src/bindings}/bindings_node_mvp.d.ts +0 -0
  70. /package/dist/types/{bindings → src/bindings}/config.d.ts +0 -0
  71. /package/dist/types/{bindings → src/bindings}/file_stats.d.ts +0 -0
  72. /package/dist/types/{bindings → src/bindings}/progress.d.ts +0 -0
  73. /package/dist/types/{bindings → src/bindings}/runtime_browser.d.ts +0 -0
  74. /package/dist/types/{bindings → src/bindings}/runtime_node.d.ts +0 -0
  75. /package/dist/types/{bindings → src/bindings}/tokens.d.ts +0 -0
  76. /package/dist/types/{bindings → src/bindings}/udf_runtime.d.ts +0 -0
  77. /package/dist/types/{bindings → src/bindings}/web_file.d.ts +0 -0
  78. /package/dist/types/{targets/duckdb-browser-coi.pthread.worker.d.ts → src/index_docs.d.ts} +0 -0
  79. /package/dist/types/{log.d.ts → src/log.d.ts} +0 -0
  80. /package/dist/types/{parallel → src/parallel}/async_bindings.d.ts +0 -0
  81. /package/dist/types/{parallel → src/parallel}/worker_dispatcher.d.ts +0 -0
  82. /package/dist/types/{parallel → src/parallel}/worker_request.d.ts +0 -0
  83. /package/dist/types/{status.d.ts → src/status.d.ts} +0 -0
  84. /package/dist/types/{targets → src/targets}/duckdb-browser-coi.worker.d.ts +0 -0
  85. /package/dist/types/{targets → src/targets}/duckdb-browser-eh.worker.d.ts +0 -0
  86. /package/dist/types/{targets → src/targets}/duckdb-browser-mvp.worker.d.ts +0 -0
  87. /package/dist/types/{targets → src/targets}/duckdb-node-eh.worker.d.ts +0 -0
  88. /package/dist/types/{targets → src/targets}/duckdb-node-mvp.worker.d.ts +0 -0
  89. /package/dist/types/{utils → src/utils}/binary_dump.d.ts +0 -0
  90. /package/dist/types/{utils → src/utils}/index.d.ts +0 -0
  91. /package/dist/types/{utils → src/utils}/opfs_util.d.ts +0 -0
  92. /package/dist/types/{utils → src/utils}/s3_helper.d.ts +0 -0
  93. /package/dist/types/{worker.d.ts → src/worker.d.ts} +0 -0
@@ -1,21 +1,4 @@
1
- "use strict";var duckdb=(()=>{var ki=Object.create;var je=Object.defineProperty;var Ri=Object.getOwnPropertyDescriptor;var Di=Object.getOwnPropertyNames;var Ti=Object.getPrototypeOf,Ii=Object.prototype.hasOwnProperty;var Hi=(i,n,a)=>n in i?je(i,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[n]=a;var Bt=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(n,a)=>(typeof require<"u"?require:n)[a]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Ie=(i,n)=>()=>(n||i((n={exports:{}}).exports,n),n.exports),Ui=(i,n)=>{for(var a in n)je(i,a,{get:n[a],enumerable:!0})},jr=(i,n,a,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Di(n))!Ii.call(i,r)&&r!==a&&je(i,r,{get:()=>n[r],enumerable:!(l=Ri(n,r))||l.enumerable});return i};var zr=(i,n,a)=>(a=i!=null?ki(Ti(i)):{},jr(n||!i||!i.__esModule?je(a,"default",{value:i,enumerable:!0}):a,i)),xi=i=>jr(je({},"__esModule",{value:!0}),i);var at=(i,n,a)=>Hi(i,typeof n!="symbol"?n+"":n,a);var Nt=Ie(()=>{});var rn=Ie(()=>{});var nn=Ie(()=>{});var sn=Ie(()=>{});var fn=Ie((dn,_t)=>{"use strict";var ft=(()=>{var n;var i=typeof document<"u"?(n=document.currentScript)==null?void 0:n.src:void 0;return typeof __filename<"u"&&(i=i||__filename),async function(a={}){var Vr;var l,r=a,c,h,m=new Promise((e,t)=>{c=e,h=t}),f=typeof window=="object",C=typeof WorkerGlobalScope<"u",b=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer",U=C&&((Vr=self.name)==null?void 0:Vr.startsWith("em-pthread"));if(b){var j=Nt();global.Worker=j.Worker,C=!j.isMainThread,U=C&&j.workerData=="em-pthread"}var H=Object.assign({},r),O=[],ne="./this.program",J=(e,t)=>{throw t},Y="";function ee(e){return r.locateFile?r.locateFile(e,Y):Y+e}var V,ie;if(b){var se=rn(),g=nn();Y=__dirname+"/",ie=e=>{e=Kt(e)?new URL(e):e;var t=se.readFileSync(e);return t},V=async(e,t=!0)=>{e=Kt(e)?new URL(e):e;var s=se.readFileSync(e,t?void 0:"utf8");return s},!r.thisProgram&&process.argv.length>1&&(ne=process.argv[1].replace(/\\/g,"/")),O=process.argv.slice(2),J=(e,t)=>{throw process.exitCode=e,t}}else(f||C)&&(C?Y=self.location.href:typeof document<"u"&&document.currentScript&&(Y=document.currentScript.src),i&&(Y=i),Y.startsWith("blob:")?Y="":Y=Y.slice(0,Y.replace(/[?#].*/,"").lastIndexOf("/")+1),b||(C&&(ie=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),V=async e=>{var t=await fetch(e,{credentials:"same-origin"});if(t.ok)return t.arrayBuffer();throw new Error(t.status+" : "+t.url)}));var R=console.log.bind(console),M=console.error.bind(console);b&&(R=(...e)=>se.writeSync(1,e.join(" ")+`
2
- `),M=(...e)=>se.writeSync(2,e.join(" ")+`
3
- `));var y=r.print||R,k=r.printErr||M;Object.assign(r,H),H=null,r.arguments&&(O=r.arguments),r.thisProgram&&(ne=r.thisProgram);var E=r.wasmBinary,I,v,x=!1,B;function Q(e,t){e||ke(t)}var Z,de,q,fe,_e,Se,Ne,ue,Be,Gt,$t=!1,Kt=e=>e.startsWith("file://");function mt(){return I.buffer!=Z.buffer&&he(),Z}function ye(){return I.buffer!=Z.buffer&&he(),de}function ze(){return I.buffer!=Z.buffer&&he(),q}function En(){return I.buffer!=Z.buffer&&he(),fe}function S(){return I.buffer!=Z.buffer&&he(),_e}function ce(){return I.buffer!=Z.buffer&&he(),Se}function gt(){return I.buffer!=Z.buffer&&he(),Gt}if(U){let e=function(...o){var u=o.join(" ");if(b){se.writeSync(2,u+`
4
- `);return}console.error(u)},t=function(...o){var u=o.join(" ");postMessage({cmd:"alert",text:u,threadId:st()})},s=function(o){try{var u=o.data,d=u.cmd;if(d==="load"){let _=[];self.onmessage=p=>_.push(p),self.startWorker=p=>{postMessage({cmd:"loaded"});for(let A of _)s(A);self.onmessage=s};for(let p of u.handlers)(!r[p]||r[p].proxy)&&(r[p]=(...A)=>{postMessage({cmd:"callHandler",handler:p,args:A})},p=="print"&&(y=r[p]),p=="printErr"&&(k=r[p]));I=u.wasmMemory,he(),qt(u.wasmModule)}else if(d==="run"){Bn(u.pthread_ptr),Ut(u.pthread_ptr,0,0,1,0,0),$.receiveObjectTransfer(u),$.threadInitTLS(),St(u.pthread_ptr),wt||(wt=!0);try{Pn(u.start_routine,u.arg)}catch(_){if(_!="unwind")throw _}}else u.target==="setimmediate"||(d==="checkMailbox"?wt&&Qe():d&&(k(`worker: received unknown command ${d}`),k(u)))}catch(_){throw Mr(),_}};var Vi=e,Xi=t,ji=s,qt;if(b){var Vt=j.parentPort;Vt.on("message",o=>onmessage({data:o})),Object.assign(globalThis,{self:global,postMessage:o=>Vt.postMessage(o)})}var wt=!1;r.printErr||(k=e),self.alert=t,self.onunhandledrejection=o=>{throw o.reason||o},self.onmessage=s}function he(){var e=I.buffer;r.HEAP8=Z=new Int8Array(e),r.HEAP16=q=new Int16Array(e),r.HEAPU8=de=new Uint8Array(e),r.HEAPU16=fe=new Uint16Array(e),r.HEAP32=_e=new Int32Array(e),r.HEAPU32=Se=new Uint32Array(e),r.HEAPF32=Ne=new Float32Array(e),r.HEAPF64=Gt=new Float64Array(e),r.HEAP64=ue=new BigInt64Array(e),r.HEAPU64=Be=new BigUint64Array(e)}if(U&&r.wasmMemory&&(I=r.wasmMemory),!U){if(r.wasmMemory)I=r.wasmMemory;else{var Fn=r.INITIAL_MEMORY||16777216;I=new WebAssembly.Memory({initial:Fn/65536,maximum:65536,shared:!0})}he()}r.wasmMemory=I;function An(){if(r.preRun)for(typeof r.preRun=="function"&&(r.preRun=[r.preRun]);r.preRun.length;)nr(r.preRun.shift());tr(rr)}function Xt(){if($t=!0,U)return startWorker(r);D.Ia()}function qi(){}function Sn(){if(!U){if(r.postRun)for(typeof r.postRun=="function"&&(r.postRun=[r.postRun]);r.postRun.length;)Mn(r.postRun.shift());tr(or)}}var Ue=0,We=null;function jt(e){var t;Ue++,(t=r.monitorRunDependencies)==null||t.call(r,Ue)}function zt(e){var s;if(Ue--,(s=r.monitorRunDependencies)==null||s.call(r,Ue),Ue==0&&We){var t=We;We=null,t()}}function ke(e){var s;(s=r.onAbort)==null||s.call(r,e),e="Aborted("+e+")",k(e),x=!0,e+=". Build with -sASSERTIONS for more info.",$t&&___trap();var t=new WebAssembly.RuntimeError(e);throw h(t),t}var Ge;function kn(){return ee("./duckdb-coi.wasm")}function Rn(e){if(e==Ge&&E)return new Uint8Array(E);if(ie)return ie(e);throw"both async and sync fetching of the wasm failed"}async function Dn(e){if(!E)try{var t=await V(e);return new Uint8Array(t)}catch{}return Rn(e)}async function Tn(e,t){try{var s=await Dn(e),o=await WebAssembly.instantiate(s,t);return o}catch(u){k(`failed to asynchronously prepare wasm: ${u}`),ke(u)}}async function In(e,t,s){if(!e&&typeof WebAssembly.instantiateStreaming=="function"&&!b)try{var o=fetch(t,{credentials:"same-origin"}),u=await WebAssembly.instantiateStreaming(o,s);return u}catch(d){k(`wasm streaming compile failed: ${d}`),k("falling back to ArrayBuffer instantiation")}return Tn(t,s)}function Jt(){return Ha(),{a:Ur}}async function Hn(){function e(d,_){return D=d.exports,D=Ai(D),Ln(D.Ab),lr=D.Ka,v=_,zt("wasm-instantiate"),D}jt("wasm-instantiate");function t(d){return e(d.instance,d.module)}var s=Jt();if(r.instantiateWasm)return new Promise((d,_)=>{r.instantiateWasm(s,(p,A)=>{e(p,A),d(p.exports)})});if(U)return new Promise(d=>{qt=_=>{var p=new WebAssembly.Instance(_,Jt());d(e(p,_))}});Ge!=null||(Ge=kn());try{var o=await In(E,Ge,s),u=t(o);return u}catch(d){return h(d),Promise.reject(d)}}var Yt={10331745:(e,t,s,o)=>{var u=K(e);if(typeof XMLHttpRequest>"u")return 0;let d=new XMLHttpRequest;d.open(K(o),u,!1),d.responseType="arraybuffer";for(var _=0,w=t;_<w*2;){var p=S()[s/4+_>>>0],A=S()[s/4+_+1>>>0];try{var T=encodeURI(K(p));T==="Host"&&(T="X-Host-Override"),T==="User-Agent"&&(T="X-user-agent"),T==="Authorization"?d.setRequestHeader(T,K(A)):d.setRequestHeader(T,encodeURI(K(A)))}catch(ae){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",ae)}_+=2}try{d.send(null)}catch{return 0}if(d.status>=400)return 0;for(var P=d.response,w=P.byteLength,G=Ae(w+4),X=new Uint8Array(P),N=0;N<w;N++)r.HEAPU8[N+G+4]=X[N];var F=new Uint8Array(4);return F[0]=w%256,w-=F[0],w/=256,F[1]=w%256,w-=F[1],w/=256,F[2]=w%256,w-=F[2],w/=256,F[3]=w%256,w-=F[3],w/=256,r.HEAPU8.set(F,G),G},10333152:(e,t,s,o,u,d)=>{var _=K(e);if(typeof XMLHttpRequest>"u")return 0;let p=new XMLHttpRequest;p.open(K(o),_,!1),p.responseType="arraybuffer";for(var A=0,F=t;A<F*2;){var T=S()[s/4+A>>>0],P=S()[s/4+A+1>>>0];try{var w=encodeURI(K(T));w==="Host"&&(w="X-Host-Override"),w==="User-Agent"&&(w="X-user-agent"),w==="Authorization"?p.setRequestHeader(w,K(P)):p.setRequestHeader(w,encodeURI(K(P)))}catch(Te){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Te)}A+=2}try{for(var G=new Uint8Array(d),X=0;X<d;X++)G[X]=r.HEAPU8[X+u];p.send(G)}catch{return 0}if(p.status>=400)return 0;for(var N=Uint8Array.from(Array.from(p.getResponseHeader("Etag")).map(Te=>Te.charCodeAt(0))),F=N.byteLength,ae=Ae(F+4),pe=new Uint8Array(N),X=0;X<F;X++)r.HEAPU8[X+ae+4]=pe[X];var te=new Uint8Array(4);return te[0]=F%256,F-=te[0],F/=256,te[1]=F%256,F-=te[1],F/=256,te[2]=F%256,F-=te[2],F/=256,te[3]=F%256,F-=te[3],F/=256,r.HEAPU8.set(te,ae),ae},10334772:(e,t,s,o)=>{var u=K(e);if(typeof XMLHttpRequest>"u")return 0;let d=new XMLHttpRequest;d.open(K(o),u,!1),d.responseType="arraybuffer";for(var _=0,w=t;_<w*2;){var p=S()[s/4+_>>>0],A=S()[s/4+_+1>>>0];try{var T=encodeURI(K(p));T==="Host"&&(T="X-Host-Override"),T==="User-Agent"&&(T="X-user-agent"),T==="Authorization"?d.setRequestHeader(T,K(A)):d.setRequestHeader(T,encodeURI(K(A)))}catch(te){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",te)}_+=2}try{d.send(null)}catch{return 0}if(d.status>=400)return 0;for(var P=d.response,w=P.byteLength,G=Ae(w+8),X=new Uint8Array(P),N=0;N<w;N++)r.HEAPU8[N+G+8]=X[N];var F=new Uint8Array(4);F[0]=w%256,w-=F[0],w/=256,F[1]=w%256,w-=F[1],w/=256,F[2]=w%256,w-=F[2],w/=256,F[3]=w%256,w-=F[3],w/=256,r.HEAPU8.set(F,G+4);var ae=Uint8Array.from(Array.from(d.getAllResponseHeaders()).map(te=>te.charCodeAt(0)));w=ae.byteLength;for(var pe=Ae(w+8),N=0;N<w;N++)r.HEAPU8[N+pe+8]=ae[N];return F=new Uint8Array(4),F[0]=w%256,w-=F[0],w/=256,F[1]=w%256,w-=F[1],w/=256,F[2]=w%256,w-=F[2],w/=256,F[3]=w%256,w-=F[3],w/=256,r.HEAPU8.set(F,pe+4),w=pe,F=new Uint8Array(4),F[0]=w%256,w-=F[0],w/=256,F[1]=w%256,w-=F[1],w/=256,F[2]=w%256,w-=F[2],w/=256,F[3]=w%256,w-=F[3],w/=256,r.HEAPU8.set(F,G),G},10337056:(e,t,s,o)=>{var u=K(e);if(typeof XMLHttpRequest>"u")return 0;let d=new XMLHttpRequest;d.open(K(o),u,!1),d.responseType="arraybuffer";for(var _=0,w=t;_<w*2;){var p=S()[s/4+_>>>0],A=S()[s/4+_+1>>>0];try{var T=encodeURI(K(p));T==="Host"&&(T="X-Host-Override"),T==="User-Agent"&&(T="X-user-agent"),T==="Authorization"?d.setRequestHeader(T,K(A)):d.setRequestHeader(T,encodeURI(K(A)))}catch(ae){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",ae)}_+=2}try{d.send(null)}catch{return 0}if(d.status>=400)return 0;for(var P=d.response,w=P.byteLength,G=Ae(w+4),X=new Uint8Array(P),N=0;N<w;N++)r.HEAPU8[N+G+4]=X[N];var F=new Uint8Array(4);return F[0]=w%256,w-=F[0],w/=256,F[1]=w%256,w-=F[1],w/=256,F[2]=w%256,w-=F[2],w/=256,F[3]=w%256,w-=F[3],w/=256,r.HEAPU8.set(F,G),G},10338463:(e,t,s,o,u,d)=>{var _=K(e);if(typeof XMLHttpRequest>"u")return 0;let p=new XMLHttpRequest;p.open(K(o),_,!1),p.responseType="arraybuffer";for(var A=0,F=t;A<F*2;){var T=S()[s/4+A>>>0],P=S()[s/4+A+1>>>0];try{var w=encodeURI(K(T));w==="Host"&&(w="X-Host-Override"),w==="User-Agent"&&(w="X-user-agent"),w==="Authorization"?p.setRequestHeader(w,K(P)):p.setRequestHeader(w,encodeURI(K(P)))}catch(Te){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Te)}A+=2}try{for(var G=new Uint8Array(d),X=0;X<d;X++)G[X]=r.HEAPU8[X+u];p.send(G)}catch{return 0}if(p.status>=400)return 0;for(var N=p.response,F=N.byteLength,ae=Ae(F+4),pe=new Uint8Array(N),X=0;X<F;X++)r.HEAPU8[X+ae+4]=pe[X];var te=new Uint8Array(4);return te[0]=F%256,F-=te[0],F/=256,te[1]=F%256,F-=te[1],F/=256,te[2]=F%256,F-=te[2],F/=256,te[3]=F%256,F-=te[3],F/=256,r.HEAPU8.set(te,ae),ae}};class Qt{constructor(t){at(this,"name","ExitStatus");this.message=`Program terminated with exit(${t})`,this.status=t}}var Zt=e=>{e.terminate(),e.onmessage=t=>{}},er=e=>{var t=$.pthreads[e];$.returnWorkerToPool(t)},tr=e=>{for(;e.length>0;)e.shift()(r)},rr=[],nr=e=>rr.unshift(e),sr=e=>{var t=$.getNewWorker();if(!t)return 6;$.runningWorkers.push(t),$.pthreads[e.pthread_ptr]=t,t.pthread_ptr=e.pthread_ptr;var s={cmd:"run",start_routine:e.startRoutine,arg:e.arg,pthread_ptr:e.pthread_ptr};return b&&t.unref(),t.postMessage(s,e.transferList),0},Je=0,yt=()=>At||Je>0,Ye=()=>qr(),$e=e=>$r(e),Ke=e=>Kr(e);r.stackAlloc=Ke;var Un=9007199254740992,xn=-9007199254740992,Re=e=>e<xn||e>Un?NaN:Number(e),Pe=(e,t,s,...o)=>{for(var u=o.length*2,d=Ye(),_=Ke(u*8),p=_>>>3,A=0;A<o.length;A++){var T=o[A];typeof T=="bigint"?(ue[p+2*A]=1n,ue[p+2*A+1]=T):(ue[p+2*A]=0n,gt()[p+2*A+1>>>0]=T)}var P=Lr(e,t,u,_,s);return $e(d),P};function vt(e){var t;if(U)return Pe(0,0,1,e);B=e,yt()||($.terminateAllThreads(),(t=r.onExit)==null||t.call(r,e),x=!0),J(e,new Qt(e))}var Et=e=>{if(e instanceof Qt||e=="unwind")return B;J(1,e)};function ar(e){if(U)return Pe(1,0,0,e);Ft(e)}var ir=(e,t)=>{if(B=e,U)throw ar(e),"unwind";vt(e)},Ft=ir,$={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},init(){U||$.initMainThread()},initMainThread(){for(var e=4;e--;)$.allocateUnusedWorker();nr(()=>{jt("loading-workers"),$.loadWasmModuleToAllWorkers(()=>zt("loading-workers"))})},terminateAllThreads:()=>{for(var e of $.runningWorkers)Zt(e);for(var e of $.unusedWorkers)Zt(e);$.unusedWorkers=[],$.runningWorkers=[],$.pthreads={}},returnWorkerToPool:e=>{var t=e.pthread_ptr;delete $.pthreads[t],$.unusedWorkers.push(e),$.runningWorkers.splice($.runningWorkers.indexOf(e),1),e.pthread_ptr=0,Or(t)},receiveObjectTransfer(e){},threadInitTLS(){$.tlsInitFunctions.forEach(e=>e())},loadWasmModuleToWorker:e=>new Promise(t=>{e.onmessage=d=>{var _=d.data,p=_.cmd;if(_.targetThread&&_.targetThread!=st()){var A=$.pthreads[_.targetThread];A?A.postMessage(_,_.transferList):k(`Internal error! Worker sent a message "${p}" to target pthread ${_.targetThread}, but that thread no longer exists!`);return}p==="checkMailbox"?Qe():p==="spawnThread"?sr(_):p==="cleanupThread"?er(_.thread):p==="loaded"?(e.loaded=!0,b&&!e.pthread_ptr&&e.unref(),t(e)):p==="alert"?alert(`Thread ${_.threadId}: ${_.text}`):_.target==="setimmediate"?e.postMessage(_):p==="callHandler"?r[_.handler](..._.args):p&&k(`worker sent an unknown command ${p}`)},e.onerror=d=>{var _="worker sent an error!";throw k(`${_} ${d.filename}:${d.lineno}: ${d.message}`),d},b&&(e.on("message",d=>e.onmessage({data:d})),e.on("error",d=>e.onerror(d)));var s=[],o=["onExit","onAbort","print","printErr"];for(var u of o)r.propertyIsEnumerable(u)&&s.push(u);e.postMessage({cmd:"load",handlers:s,wasmMemory:I,wasmModule:v})}),loadWasmModuleToAllWorkers(e){if(U)return e();Promise.all($.unusedWorkers.map($.loadWasmModuleToWorker)).then(e)},allocateUnusedWorker(){var e,t={workerData:"em-pthread",name:"em-pthread"},s=i;r.mainScriptUrlOrBlob&&(s=r.mainScriptUrlOrBlob,typeof s!="string"&&(s=URL.createObjectURL(s))),e=new Worker(s,t),$.unusedWorkers.push(e)},getNewWorker(){return $.unusedWorkers.length==0&&($.allocateUnusedWorker(),$.loadWasmModuleToWorker($.unusedWorkers[0])),$.unusedWorkers.pop()}},or=[],Mn=e=>or.unshift(e),Bn=e=>{he();var t=ce()[e+52>>>2>>>0],s=ce()[e+56>>>2>>>0],o=t-s;Gr(t,o),$e(t)},lr,ur=e=>lr.get(e),Pn=(e,t)=>{Je=0,At=0;var s=ur(e)(t);function o(u){yt()?B=u:xt(u)}o(s)},At=r.noExitRuntime||!0,Ln=e=>$.tlsInitFunctions.push(e);function On(e,t){return e>>>=0,ur(e)(t)}function cr(e,t,s,o){return U?Pe(2,0,1,e,t,s,o):dr(e,t,s,o)}var Cn=()=>typeof SharedArrayBuffer<"u";function dr(e,t,s,o){if(e>>>=0,t>>>=0,s>>>=0,o>>>=0,!Cn())return 6;var u=[],d=0;if(U&&(u.length===0||d))return cr(e,t,s,o);if(d)return d;var _={startRoutine:s,pthread_ptr:e,arg:o,transferList:u};return U?(_.cmd="spawnThread",postMessage(_,u),0):sr(_)}var Nn=()=>ke("");function Wn(e){e>>>=0,Ut(e,!C,1,!f,1048576,!1),$.threadInitTLS()}var Gn=()=>{if(!yt())try{U?xt(B):Ft(B)}catch(e){Et(e)}},$n=e=>{if(!x)try{e(),Gn()}catch(t){Et(t)}};function St(e){if(e>>>=0,typeof Atomics.waitAsync=="function"){var t=Atomics.waitAsync(S(),e>>>2,e);t.value.then(Qe);var s=e+128;Atomics.store(S(),s>>>2,1)}}var Qe=()=>{var e=st();e&&(St(e),$n(Cr))};function Kn(e,t){if(e>>>=0,t>>>=0,e==t)setTimeout(Qe);else if(U)postMessage({targetThread:e,cmd:"checkMailbox"});else{var s=$.pthreads[e];if(!s)return;s.postMessage({cmd:"checkMailbox"})}}var Ze=[];function qn(e,t,s,o,u){t>>>=0,s>>>=0,u>>>=0,o/=2,Ze.length=o;for(var d=u>>>3,_=0;_<o;_++)ue[d+2*_]?Ze[_]=ue[d+2*_+1]:Ze[_]=gt()[d+2*_+1>>>0];var p=t?Yt[t]:Ia[e];$.currentProxiedOperationCallerThread=s;var A=p(...Ze);return $.currentProxiedOperationCallerThread=0,A}var Vn=()=>{At=!1,Je=0},fr=typeof TextDecoder<"u"?new TextDecoder:void 0,Xn=(e,t=0,s=NaN)=>{t>>>=0;for(var o=t+s,u=t;e[u]&&!(u>=o);)++u;if(u-t>16&&e.buffer&&fr)return fr.decode(e.slice(t,u));for(var d="";t<u;){var _=e[t++];if(!(_&128)){d+=String.fromCharCode(_);continue}var p=e[t++]&63;if((_&224)==192){d+=String.fromCharCode((_&31)<<6|p);continue}var A=e[t++]&63;if((_&240)==224?_=(_&15)<<12|p<<6|A:_=(_&7)<<18|p<<12|A<<6|e[t++]&63,_<65536)d+=String.fromCharCode(_);else{var T=_-65536;d+=String.fromCharCode(55296|T>>10,56320|T&1023)}}return d},K=(e,t)=>(e>>>=0,e?Xn(ye(),e,t):"");function jn(e){if(e>>>=0,b){if(!e)return 1;var t=K(e);if(!t.length)return 0;var s=["child_process"].map(Bt)[0],o=s.spawnSync(t,[],{shell:!0,stdio:"inherit"}),u=(_,p)=>_<<8|p;if(o.status===null){var d=_=>{switch(_){case"SIGHUP":return 1;case"SIGQUIT":return 3;case"SIGFPE":return 8;case"SIGKILL":return 9;case"SIGALRM":return 14;case"SIGTERM":return 15;default:return 2}};return u(0,d(o.signal))}return u(o.status,0)}return e?-52:0}function zn(e){e>>>=0,U?postMessage({cmd:"cleanupThread",thread:e}):er(e)}function Jn(e){e>>>=0,b&&$.pthreads[e].ref()}function _r(){ke("missing function: _emval_call_method")}_r.stub=!0;function hr(){ke("missing function: _emval_decref")}hr.stub=!0;function br(){ke("missing function: _emval_get_global")}br.stub=!0;function pr(){ke("missing function: _emval_get_method_caller")}pr.stub=!0;function mr(){ke("missing function: _emval_run_destructors")}mr.stub=!0;function Yn(e,t){e=Re(e),t>>>=0;var s=new Date(e*1e3);S()[t>>>2>>>0]=s.getUTCSeconds(),S()[t+4>>>2>>>0]=s.getUTCMinutes(),S()[t+8>>>2>>>0]=s.getUTCHours(),S()[t+12>>>2>>>0]=s.getUTCDate(),S()[t+16>>>2>>>0]=s.getUTCMonth(),S()[t+20>>>2>>>0]=s.getUTCFullYear()-1900,S()[t+24>>>2>>>0]=s.getUTCDay();var o=Date.UTC(s.getUTCFullYear(),0,1,0,0,0,0),u=(s.getTime()-o)/(1e3*60*60*24)|0;S()[t+28>>>2>>>0]=u}var Qn=e=>e%4===0&&(e%100!==0||e%400===0),Zn=[0,31,60,91,121,152,182,213,244,274,305,335],es=[0,31,59,90,120,151,181,212,243,273,304,334],gr=e=>{var t=Qn(e.getFullYear()),s=t?Zn:es,o=s[e.getMonth()]+e.getDate()-1;return o};function ts(e,t){e=Re(e),t>>>=0;var s=new Date(e*1e3);S()[t>>>2>>>0]=s.getSeconds(),S()[t+4>>>2>>>0]=s.getMinutes(),S()[t+8>>>2>>>0]=s.getHours(),S()[t+12>>>2>>>0]=s.getDate(),S()[t+16>>>2>>>0]=s.getMonth(),S()[t+20>>>2>>>0]=s.getFullYear()-1900,S()[t+24>>>2>>>0]=s.getDay();var o=gr(s)|0;S()[t+28>>>2>>>0]=o,S()[t+36>>>2>>>0]=-(s.getTimezoneOffset()*60);var u=new Date(s.getFullYear(),0,1),d=new Date(s.getFullYear(),6,1).getTimezoneOffset(),_=u.getTimezoneOffset(),p=(d!=_&&s.getTimezoneOffset()==Math.min(_,d))|0;S()[t+32>>>2>>>0]=p}var rs=function(e){e>>>=0;var t=(()=>{var s=new Date(S()[e+20>>>2>>>0]+1900,S()[e+16>>>2>>>0],S()[e+12>>>2>>>0],S()[e+8>>>2>>>0],S()[e+4>>>2>>>0],S()[e>>>2>>>0],0),o=S()[e+32>>>2>>>0],u=s.getTimezoneOffset(),d=new Date(s.getFullYear(),0,1),_=new Date(s.getFullYear(),6,1).getTimezoneOffset(),p=d.getTimezoneOffset(),A=Math.min(p,_);if(o<0)S()[e+32>>>2>>>0]=+(_!=p&&A==u);else if(o>0!=(A==u)){var T=Math.max(p,_),P=o>0?A:T;s.setTime(s.getTime()+(P-u)*6e4)}S()[e+24>>>2>>>0]=s.getDay();var w=gr(s)|0;S()[e+28>>>2>>>0]=w,S()[e>>>2>>>0]=s.getSeconds(),S()[e+4>>>2>>>0]=s.getMinutes(),S()[e+8>>>2>>>0]=s.getHours(),S()[e+12>>>2>>>0]=s.getDate(),S()[e+16>>>2>>>0]=s.getMonth(),S()[e+20>>>2>>>0]=s.getYear();var G=s.getTime();return isNaN(G)?-1:G/1e3})();return BigInt(t)},wr=(e,t,s,o)=>{if(s>>>=0,!(o>0))return 0;for(var u=s,d=s+o-1,_=0;_<e.length;++_){var p=e.charCodeAt(_);if(p>=55296&&p<=57343){var A=e.charCodeAt(++_);p=65536+((p&1023)<<10)|A&1023}if(p<=127){if(s>=d)break;t[s++>>>0]=p}else if(p<=2047){if(s+1>=d)break;t[s++>>>0]=192|p>>6,t[s++>>>0]=128|p&63}else if(p<=65535){if(s+2>=d)break;t[s++>>>0]=224|p>>12,t[s++>>>0]=128|p>>6&63,t[s++>>>0]=128|p&63}else{if(s+3>=d)break;t[s++>>>0]=240|p>>18,t[s++>>>0]=128|p>>12&63,t[s++>>>0]=128|p>>6&63,t[s++>>>0]=128|p&63}}return t[s>>>0]=0,s-u},be=(e,t,s)=>wr(e,ye(),t,s);r.stringToUTF8=be;var ns=function(e,t,s,o){e>>>=0,t>>>=0,s>>>=0,o>>>=0;var u=new Date().getFullYear(),d=new Date(u,0,1),_=new Date(u,6,1),p=d.getTimezoneOffset(),A=_.getTimezoneOffset(),T=Math.max(p,A);ce()[e>>>2>>>0]=T*60,S()[t>>>2>>>0]=+(p!=A);var P=X=>{var N=X>=0?"-":"+",F=Math.abs(X),ae=String(Math.floor(F/60)).padStart(2,"0"),pe=String(F%60).padStart(2,"0");return`UTC${N}${ae}${pe}`},w=P(p),G=P(A);A<p?(be(w,s,17),be(G,o,17)):(be(w,o,17),be(G,s,17))};function ss(e,t){return t>>>=0,ye().set(qe[e].fileData,t>>>0)}var kt=[],as=()=>kt.length,qe=[],is=!1,os=()=>(is=!0,qe.length);function ls(e,t){t>>>=0;var s=kt[e].childName,o=Le(s)+1;be(s,t,o)}var us=e=>qe[e].mode;function cs(e){return qe[e].fileData.length}function ds(e,t){t>>>=0;var s=kt[e].parentPath,o=Le(s)+1;be(s,t,o)}var Le=e=>{for(var t=0,s=0;s<e.length;++s){var o=e.charCodeAt(s);o<=127?t++:o<=2047?t+=2:o>=55296&&o<=57343?(t+=4,++s):t+=3}return t};r.lengthBytesUTF8=Le;function fs(e,t){t>>>=0;var s=qe[e].pathName,o=Le(s)+1;be(s,t,o)}class et{constructor(){at(this,"allocated",[void 0]);at(this,"freelist",[])}get(t){return this.allocated[t]}has(t){return this.allocated[t]!==void 0}allocate(t){var s=this.freelist.pop()||this.allocated.length;return this.allocated[s]=t,s}free(t){this.allocated[t]=void 0,this.freelist.push(t)}}var De=new et,oe=e=>{Pr(e)};async function _s(e,t,s){e>>>=0,s>>>=0;let o=De.get(t);try{await o.close()}catch{let u=-29;S()[s>>>2>>>0]=u}De.free(t),oe(e)}var tt=new et,hs=e=>{tt.free(e)};async function bs(e,t,s){e>>>=0,s>>>=0;let o=De.get(t);try{await o.flush()}catch{let u=-29;S()[s>>>2>>>0]=u}oe(e)}var Ee=new et,ps=e=>{Ee.free(e)},xe=new et,ms=e=>{xe.free(e)};async function yr(e,t,s){let o=Ee.get(e),u;try{u=await o.getFileHandle(t,{create:s})}catch(d){return d.name==="NotFoundError"?-20:d.name==="TypeMismatchError"?-31:-29}return xe.allocate(u)}async function vr(e,t,s){let o=Ee.get(e),u;try{u=await o.getDirectoryHandle(t,{create:s})}catch(d){return d.name==="NotFoundError"?-20:d.name==="TypeMismatchError"?-54:-29}return Ee.allocate(u)}async function gs(e,t,s,o,u){e>>>=0,s>>>=0,o>>>=0,u>>>=0;let d=K(s),_=1,p=await yr(t,d,!1);p==-31&&(_=2,p=await vr(t,d,!1)),S()[o>>>2>>>0]=_,S()[u>>>2>>>0]=p,oe(e)}async function ws(e,t,s,o){e>>>=0,s>>>=0,o>>>=0;let u=Ee.get(t);try{let d=u.entries();for(let _;_=await d.next(),!_.done;){let[p,A]=_.value,T=Ye(),P=Hr(p),w=A.kind=="file"?1:2;__wasmfs_opfs_record_entry(s,P,w),$e(T)}}catch{let d=-29;S()[o>>>2>>>0]=d}oe(e)}async function ys(e,t,s){e>>>=0,s>>>=0;let o=De.get(t),u;try{u=await o.getSize()}catch{u=-29}ue[s>>>3]=BigInt(u),oe(e)}var vs=function(e){var t=tt.get(e).size;return BigInt(t)};async function Es(e,t,s){e>>>=0,s>>>=0;let o=xe.get(t),u;try{u=(await o.getFile()).size}catch{u=-29}ue[s>>>3]=BigInt(u),oe(e)}async function Fs(e){if(e>>>=0,Ee.allocated.length==1){let t=await navigator.storage.getDirectory();Ee.allocated.push(t)}oe(e)}async function As(e,t,s,o){e>>>=0,s>>>=0,o>>>=0;let u=K(s),d=await vr(t,u,!0);S()[o>>>2>>>0]=d,oe(e)}async function Ss(e,t,s,o){e>>>=0,s>>>=0,o>>>=0;let u=K(s),d=await yr(t,u,!0);S()[o>>>2>>>0]=d,oe(e)}async function ks(e,t,s,o,u){e>>>=0,o>>>=0,u>>>=0;let d=K(o),_=xe.get(t),p=Ee.get(s);try{await _.move(p,d)}catch{let A=-29;S()[u>>>2>>>0]=A}oe(e)}async function Rs(e,t,s){e>>>=0,s>>>=0;let o=xe.get(t),u;try{let _;var d=FileSystemFileHandle.prototype.createSyncAccessHandle.length;d==0?_=await o.createSyncAccessHandle():_=await o.createSyncAccessHandle({mode:"in-place"}),u=De.allocate(_)}catch(_){_.name==="InvalidStateError"||_.name==="NoModificationAllowedError"?u=-2:u=-29}S()[s>>>2>>>0]=u,oe(e)}async function Ds(e,t,s){e>>>=0,s>>>=0;let o=xe.get(t),u;try{let d=await o.getFile();u=tt.allocate(d)}catch(d){d.name==="NotAllowedError"?u=-2:u=-29}S()[s>>>2>>>0]=u,oe(e)}function Ts(e,t,s,o){t>>>=0,o=Re(o);let u=De.get(e),d=ye().subarray(t>>>0,t+s>>>0);try{return u.read(d,{at:o})}catch(_){return _.name=="TypeError"?-28:-29}}async function Is(e,t,s,o,u,d){e>>>=0,s>>>=0,u=Re(u),d>>>=0;let p=tt.get(t).slice(u,u+o),A=0;try{let T=await p.arrayBuffer(),P=new Uint8Array(T);ye().set(P,s>>>0),A+=P.length}catch(T){T instanceof RangeError?A=-21:A=-29}S()[d>>>2>>>0]=A,oe(e)}async function Hs(e,t,s,o){e>>>=0,s>>>=0,o>>>=0;let u=K(s),d=Ee.get(t);try{await d.removeEntry(u)}catch{let _=-29;S()[o>>>2>>>0]=_}oe(e)}async function Us(e,t,s,o){e>>>=0,s=Re(s),o>>>=0;let u=De.get(t);try{await u.truncate(s)}catch{let d=-29;S()[o>>>2>>>0]=d}oe(e)}async function xs(e,t,s,o){e>>>=0,s=Re(s),o>>>=0;let u=xe.get(t);try{let d=await u.createWritable({keepExistingData:!0});await d.truncate(s),await d.close()}catch{let d=-29;S()[o>>>2>>>0]=d}oe(e)}function Ms(e,t,s,o){t>>>=0,o=Re(o);let u=De.get(e),d=ye().subarray(t>>>0,t+s>>>0);try{return u.write(d,{at:o})}catch(_){return _.name=="TypeError"?-28:-29}}var Rt=[],Bs=(e,t,s)=>{var o=s>0?s:Le(e)+1,u=new Array(o),d=wr(e,u,0,u.length);return t&&(u.length=d),u},Ps=()=>{if(!Rt.length){var e=null;if(b){var t=256,s=Buffer.alloc(t),o=0,u=process.stdin.fd;try{o=se.readSync(u,s,0,t)}catch(d){if(d.toString().includes("EOF"))o=0;else throw d}o>0&&(e=s.slice(0,o).toString("utf-8"))}else typeof window<"u"&&typeof window.prompt=="function"&&(e=window.prompt("Input: "),e!==null&&(e+=`
5
- `));if(!e)return null;Rt=Bs(e,!0)}return Rt.shift()},Ls=()=>{var e=Ps();return typeof e=="number"?e:-1},Os=function(e){e>>>=0;var t=setInterval(()=>{x?clearInterval(t):Br(e)},50)},Er=()=>performance.timeOrigin+performance.now(),Fr=()=>Date.now(),Cs=1,Ns=e=>e>=0&&e<=3;function Ws(e,t,s){if(t=Re(t),s>>>=0,!Ns(e))return 28;var o;if(e===0)o=Fr();else if(Cs)o=Er();else return 52;var u=Math.round(o*1e3*1e3);return ue[s>>>3]=BigInt(u),0}function Gs(e,t){return e>>>=0,globalThis.DUCKDB_RUNTIME.createDirectory(r,e,t)}function $s(e,t){return e>>>=0,globalThis.DUCKDB_RUNTIME.checkDirectory(r,e,t)}function Ks(e,t){return e>>>=0,globalThis.DUCKDB_RUNTIME.listDirectoryEntries(r,e,t)}function qs(e,t){return e>>>=0,globalThis.DUCKDB_RUNTIME.removeDirectory(r,e,t)}function Vs(e){return globalThis.DUCKDB_RUNTIME.closeFile(r,e)}function Xs(e,t){return e>>>=0,globalThis.DUCKDB_RUNTIME.dropFile(r,e,t)}function js(e,t){return e>>>=0,globalThis.DUCKDB_RUNTIME.checkFile(r,e,t)}function zs(e,t,s,o){return e>>>=0,s>>>=0,globalThis.DUCKDB_RUNTIME.moveFile(r,e,t,s,o)}function Js(e,t){return globalThis.DUCKDB_RUNTIME.openFile(r,e,t)}function Ys(e,t,s,o){return t>>>=0,globalThis.DUCKDB_RUNTIME.readFile(r,e,t,s,o)}function Qs(e,t){return globalThis.DUCKDB_RUNTIME.truncateFile(r,e,t)}function Zs(e,t,s,o){return t>>>=0,globalThis.DUCKDB_RUNTIME.writeFile(r,e,t,s,o)}function ea(e){return globalThis.DUCKDB_RUNTIME.getDefaultDataProtocol(e)}function ta(e,t){return e>>>=0,globalThis.DUCKDB_RUNTIME.glob(r,e,t)}function ra(e){return globalThis.DUCKDB_RUNTIME.testPlatformFeature(r,e)}function na(e,t,s,o,u,d){return e>>>=0,s>>>=0,u>>>=0,globalThis.DUCKDB_RUNTIME.callScalarUDF(r,e,t,s,o,u,d)}var Dt=[],sa=(e,t)=>{Dt.length=0;for(var s;s=ye()[e++>>>0];){var o=s!=105;o&=s!=112,t+=o&&t%8?4:0,Dt.push(s==112?ce()[t>>>2>>>0]:s==106?ue[t>>>3]:s==105?S()[t>>>2>>>0]:gt()[t>>>3>>>0]),t+=o?8:4}return Dt},aa=(e,t,s)=>{var o=sa(t,s);return Yt[e](...o)};function ia(e,t,s){return e>>>=0,t>>>=0,s>>>=0,aa(e,t,s)}var Ve=e=>{Ve.shown||(Ve.shown={}),Ve.shown[e]||(Ve.shown[e]=1,b&&(e="warning: "+e),k(e))},oa=()=>{};function la(e){return e>>>=0,k(K(e))}var ua=()=>{Je+=1},ca=()=>{throw ua(),"unwind"},Ar=()=>4294901760;function da(){return Ar()}var fa=()=>b?sn().cpus().length:navigator.hardwareConcurrency;function _a(e){return e>>>=0,y(K(e))}var ha=(e,t)=>Math.ceil(e/t)*t,ba=e=>{var t=I.buffer,s=(e-t.byteLength+65535)/65536|0;try{return I.grow(s),he(),1}catch{}};function pa(e){e>>>=0;var t=ye().length;if(e<=t)return!1;var s=Ar();if(e>s)return!1;for(var o=1;o<=4;o*=2){var u=t*(1+.2/o);u=Math.min(u,e+100663296);var d=Math.min(s,ha(Math.max(e,u),65536)),_=ba(d);if(_)return!0}return!1}var ma=()=>{throw"unwind"},Tt={},ga=()=>ne||"./this.program",Xe=()=>{if(!Xe.strings){var e=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:e,_:ga()};for(var s in Tt)Tt[s]===void 0?delete t[s]:t[s]=Tt[s];var o=[];for(var s in t)o.push(`${s}=${t[s]}`);Xe.strings=o}return Xe.strings},wa=(e,t)=>{for(var s=0;s<e.length;++s)mt()[t++>>>0]=e.charCodeAt(s);mt()[t>>>0]=0},Sr=function(e,t){if(U)return Pe(3,0,1,e,t);e>>>=0,t>>>=0;var s=0;return Xe().forEach((o,u)=>{var d=t+s;ce()[e+u*4>>>2>>>0]=d,wa(o,d),s+=o.length+1}),0},kr=function(e,t){if(U)return Pe(4,0,1,e,t);e>>>=0,t>>>=0;var s=Xe();ce()[e>>>2>>>0]=s.length;var o=0;return s.forEach(u=>o+=u.length+1),ce()[t>>>2>>>0]=o,0},rt=e=>{for(var t=e.split("."),s=0;s<4;s++){var o=Number(t[s]);if(isNaN(o))return null;t[s]=o}return(t[0]|t[1]<<8|t[2]<<16|t[3]<<24)>>>0},nt=e=>parseInt(e),It=e=>{var t,s,o,u,d=/^((?=.*::)(?!.*::.+::)(::)?([\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,_=[];if(!d.test(e))return null;if(e==="::")return[0,0,0,0,0,0,0,0];for(e.startsWith("::")?e=e.replace("::","Z:"):e=e.replace("::",":Z:"),e.indexOf(".")>0?(e=e.replace(new RegExp("[.]","g"),":"),t=e.split(":"),t[t.length-4]=nt(t[t.length-4])+nt(t[t.length-3])*256,t[t.length-3]=nt(t[t.length-2])+nt(t[t.length-1])*256,t=t.slice(0,t.length-2)):t=e.split(":"),o=0,u=0,s=0;s<t.length;s++)if(typeof t[s]=="string")if(t[s]==="Z"){for(u=0;u<8-t.length+1;u++)_[s+u]=0;o=u-1}else _[s+o]=_htons(parseInt(t[s],16));else _[s+o]=t[s];return[_[1]<<16|_[0],_[3]<<16|_[2],_[5]<<16|_[4],_[7]<<16|_[6]]},Fe={address_map:{id:1,addrs:{},names:{}},lookup_name(e){var t=rt(e);if(t!==null||(t=It(e),t!==null))return e;var s;if(Fe.address_map.addrs[e])s=Fe.address_map.addrs[e];else{var o=Fe.address_map.id++;Q(o<65535,"exceeded max address mappings of 65535"),s="172.29."+(o&255)+"."+(o&65280),Fe.address_map.names[s]=e,Fe.address_map.addrs[e]=s}return s},lookup_addr(e){return Fe.address_map.names[e]?Fe.address_map.names[e]:null}},Ht=e=>(e&255)+"."+(e>>8&255)+"."+(e>>16&255)+"."+(e>>24&255),Rr=e=>{var t="",s=0,o=0,u=0,d=0,_=0,p=0,A=[e[0]&65535,e[0]>>16,e[1]&65535,e[1]>>16,e[2]&65535,e[2]>>16,e[3]&65535,e[3]>>16],T=!0,P="";for(p=0;p<5;p++)if(A[p]!==0){T=!1;break}if(T){if(P=Ht(A[6]|A[7]<<16),A[5]===-1)return t="::ffff:",t+=P,t;if(A[5]===0)return t="::",P==="0.0.0.0"&&(P=""),P==="0.0.0.1"&&(P="1"),t+=P,t}for(s=0;s<8;s++)A[s]===0&&(s-u>1&&(_=0),u=s,_++),_>o&&(o=_,d=s-o+1);for(s=0;s<8;s++){if(o>1&&A[s]===0&&s>=d&&s<d+o){s===d&&(t+=":",d===0&&(t+=":"));continue}t+=Number(_ntohs(A[s]&65535)).toString(16),t+=s<7?":":""}return t},Dr=(e,t)=>{ye().fill(0,e,e+t)},ya=(e,t,s,o,u)=>{switch(t){case 2:s=rt(s),Dr(e,16),u&&(S()[u>>>2>>>0]=16),ze()[e>>>1>>>0]=t,S()[e+4>>>2>>>0]=s,ze()[e+2>>>1>>>0]=_htons(o);break;case 10:s=It(s),Dr(e,28),u&&(S()[u>>>2>>>0]=28),S()[e>>>2>>>0]=t,S()[e+8>>>2>>>0]=s[0],S()[e+12>>>2>>>0]=s[1],S()[e+16>>>2>>>0]=s[2],S()[e+20>>>2>>>0]=s[3],ze()[e+2>>>1>>>0]=_htons(o);break;default:return 5}return 0};function Tr(e,t,s,o){if(U)return Pe(5,0,1,e,t,s,o);e>>>=0,t>>>=0,s>>>=0,o>>>=0;var u=0,d=0,_=0,p=0,A=0,T=0,P;function w(G,X,N,F,ae,pe){var te,Te,ve,Xr;return Te=G===10?28:16,ae=G===10?Rr(ae):Ht(ae),te=Ae(Te),Xr=ya(te,G,ae,pe),Q(!Xr),ve=Ae(32),S()[ve+4>>>2>>>0]=G,S()[ve+8>>>2>>>0]=X,S()[ve+12>>>2>>>0]=N,ce()[ve+24>>>2>>>0]=F,ce()[ve+20>>>2>>>0]=te,G===10?S()[ve+16>>>2>>>0]=28:S()[ve+16>>>2>>>0]=16,S()[ve+28>>>2>>>0]=0,ve}if(s&&(_=S()[s>>>2>>>0],p=S()[s+4>>>2>>>0],A=S()[s+8>>>2>>>0],T=S()[s+12>>>2>>>0]),A&&!T&&(T=A===2?17:6),!A&&T&&(A=T===17?2:1),T===0&&(T=6),A===0&&(A=1),!e&&!t)return-2;if(_&-1088||s!==0&&S()[s>>>2>>>0]&2&&!e)return-1;if(_&32)return-2;if(A!==0&&A!==1&&A!==2)return-7;if(p!==0&&p!==2&&p!==10)return-6;if(t&&(t=K(t),d=parseInt(t,10),isNaN(d)))return _&1024?-2:-8;if(!e)return p===0&&(p=2),(_&1)===0&&(p===2?u=_htonl(2130706433):u=[0,0,0,_htonl(1)]),P=w(p,A,T,null,u,d),ce()[o>>>2>>>0]=P,0;if(e=K(e),u=rt(e),u!==null)if(p===0||p===2)p=2;else if(p===10&&_&8)u=[0,0,_htonl(65535),u],p=10;else return-2;else if(u=It(e),u!==null)if(p===0||p===10)p=10;else return-2;return u!=null?(P=w(p,A,T,e,u,d),ce()[o>>>2>>>0]=P,0):_&4?-2:(e=Fe.lookup_name(e),u=rt(e),p===0?p=2:p===10&&(u=[0,0,_htonl(65535),u]),P=w(p,A,T,null,u,d),ce()[o>>>2>>>0]=P,0)}var va=(e,t)=>{var s=ze()[e>>>1>>>0],o=_ntohs(En()[e+2>>>1>>>0]),u;switch(s){case 2:if(t!==16)return{errno:28};u=S()[e+4>>>2>>>0],u=Ht(u);break;case 10:if(t!==28)return{errno:28};u=[S()[e+8>>>2>>>0],S()[e+12>>>2>>>0],S()[e+16>>>2>>>0],S()[e+20>>>2>>>0]],u=Rr(u);break;default:return{errno:5}}return{family:s,addr:u,port:o}};function Ea(e,t,s,o,u,d,_){e>>>=0,s>>>=0,u>>>=0;var p=va(e,t);if(p.errno)return-6;var A=p.port,T=p.addr,P=!1;if(s&&o){var w;if(_&1||!(w=Fe.lookup_addr(T))){if(_&8)return-2}else T=w;var G=be(T,s,o);G+1>=o&&(P=!0)}if(u&&d){A=""+A;var G=be(A,u,d);G+1>=d&&(P=!0)}return P?-12:0}var Fa=()=>{if(b){var e=["crypto"].map(Bt)[0];return t=>e.randomFillSync(t)}return t=>t.set(crypto.getRandomValues(new Uint8Array(t.byteLength)))},Ir=e=>{(Ir=Fa())(e)};function Aa(e,t){return e>>>=0,t>>>=0,Ir(ye().subarray(e>>>0,e+t>>>0)),0}var Sa=e=>{var t=r["_"+e];return t},ka=(e,t)=>{mt().set(e,t>>>0)},Hr=e=>{var t=Le(e)+1,s=Ke(t);return be(e,s,t),s},Ra=(e,t,s,o,u)=>{var d={string:N=>{var F=0;return N!=null&&N!==0&&(F=Hr(N)),F},array:N=>{var F=Ke(N.length);return ka(N,F),F}};function _(N){return t==="string"?K(N):t==="boolean"?!!N:N}var p=Sa(e),A=[],T=0;if(o)for(var P=0;P<o.length;P++){var w=d[s[P]];w?(T===0&&(T=Ye()),A[P]=w(o[P])):A[P]=o[P]}var G=p(...A);function X(N){return T!==0&&$e(T),_(N)}return G=X(G),G},Da=e=>Wr(),Ta=e=>Nr(e);$.init();var Ia=[vt,ar,cr,Sr,kr,Tr],Ur;function Ha(){Ur={ha:On,oa:dr,Ga:Nn,aa:Wn,za:Kn,ia:qn,m:Vn,x:jn,q:zn,S:St,I:Jn,u:_r,v:hr,w:br,t:pr,s:mr,ka:Yn,la:ts,ma:rs,pa:ns,ya:ss,wa:as,xa:os,ua:ls,sa:us,Aa:cs,va:ds,ta:fs,M:_s,N:hs,F:bs,y:ps,E:ms,T:gs,z:ws,Q:ys,P:vs,R:Es,U:Fs,C:As,D:Ss,B:ks,j:Rs,O:Ds,L:Ts,K:Is,A:Hs,H:Us,G:xs,J:Ms,Da:Ls,V:Os,Ha:Ws,$:Gs,ba:$s,Z:Ks,_:qs,l:Vs,ea:Xs,X:js,Y:zs,da:Js,f:Ys,ca:Qs,g:Zs,fa:ea,W:ta,k:ra,ga:na,e:ia,p:oa,b:Fr,h:la,i:ca,Ea:da,d:Er,Fa:fa,Ca:_a,r:pa,na:ma,qa:Sr,ra:kr,c:Ft,o:Tr,n:Ea,a:I,ja:vt,Ba:Aa}}var D=await Hn(),xr=r._main=(e,t)=>(xr=r._main=D.Ja)(e,t),Ua=r._duckdb_web_fs_glob_add_path=e=>(Ua=r._duckdb_web_fs_glob_add_path=D.La)(e),xa=r._duckdb_web_clear_response=()=>(xa=r._duckdb_web_clear_response=D.Ma)(),Ma=r._duckdb_web_fail_with=e=>(Ma=r._duckdb_web_fail_with=D.Na)(e),Ba=r._duckdb_web_reset=e=>(Ba=r._duckdb_web_reset=D.Oa)(e),Pa=r._duckdb_web_connect=()=>(Pa=r._duckdb_web_connect=D.Pa)(),La=r._duckdb_web_disconnect=e=>(La=r._duckdb_web_disconnect=D.Qa)(e),Oa=r._duckdb_web_flush_files=()=>(Oa=r._duckdb_web_flush_files=D.Ra)(),Ca=r._duckdb_web_flush_file=e=>(Ca=r._duckdb_web_flush_file=D.Sa)(e),Na=r._duckdb_web_open=(e,t)=>(Na=r._duckdb_web_open=D.Ta)(e,t),Wa=r._duckdb_web_get_global_file_info=(e,t)=>(Wa=r._duckdb_web_get_global_file_info=D.Ua)(e,t),Ga=r._duckdb_web_collect_file_stats=(e,t,s)=>(Ga=r._duckdb_web_collect_file_stats=D.Va)(e,t,s),$a=r._duckdb_web_export_file_stats=(e,t)=>($a=r._duckdb_web_export_file_stats=D.Wa)(e,t),Ka=r._duckdb_web_fs_drop_file=(e,t)=>(Ka=r._duckdb_web_fs_drop_file=D.Xa)(e,t),qa=r._duckdb_web_fs_drop_files=(e,t,s)=>(qa=r._duckdb_web_fs_drop_files=D.Ya)(e,t,s),Va=r._duckdb_web_fs_glob_file_infos=(e,t)=>(Va=r._duckdb_web_fs_glob_file_infos=D.Za)(e,t),Xa=r._duckdb_web_fs_get_file_info_by_id=(e,t,s)=>(Xa=r._duckdb_web_fs_get_file_info_by_id=D._a)(e,t,s),ja=r._duckdb_web_fs_get_file_info_by_name=(e,t,s)=>(ja=r._duckdb_web_fs_get_file_info_by_name=D.$a)(e,t,s),za=r._duckdb_web_fs_register_file_url=(e,t,s,o,u)=>(za=r._duckdb_web_fs_register_file_url=D.ab)(e,t,s,o,u),Ja=r._duckdb_web_fs_register_file_buffer=(e,t,s,o)=>(Ja=r._duckdb_web_fs_register_file_buffer=D.bb)(e,t,s,o),Ya=r._duckdb_web_copy_file_to_buffer=(e,t)=>(Ya=r._duckdb_web_copy_file_to_buffer=D.cb)(e,t),Qa=r._duckdb_web_copy_file_to_path=(e,t,s)=>(Qa=r._duckdb_web_copy_file_to_path=D.db)(e,t,s),Za=r._duckdb_web_get_version=e=>(Za=r._duckdb_web_get_version=D.eb)(e),ei=r._duckdb_web_get_feature_flags=()=>(ei=r._duckdb_web_get_feature_flags=D.fb)(),ti=r._duckdb_web_tokenize=(e,t)=>(ti=r._duckdb_web_tokenize=D.gb)(e,t),ri=r._duckdb_web_tokenize_buffer=(e,t,s)=>(ri=r._duckdb_web_tokenize_buffer=D.hb)(e,t,s),ni=r._duckdb_web_udf_scalar_create=(e,t,s)=>(ni=r._duckdb_web_udf_scalar_create=D.ib)(e,t,s),si=r._duckdb_web_prepared_create=(e,t,s)=>(si=r._duckdb_web_prepared_create=D.jb)(e,t,s),ai=r._duckdb_web_prepared_create_buffer=(e,t,s,o)=>(ai=r._duckdb_web_prepared_create_buffer=D.kb)(e,t,s,o),ii=r._duckdb_web_prepared_close=(e,t,s)=>(ii=r._duckdb_web_prepared_close=D.lb)(e,t,s),oi=r._duckdb_web_prepared_run=(e,t,s,o)=>(oi=r._duckdb_web_prepared_run=D.mb)(e,t,s,o),li=r._duckdb_web_prepared_send=(e,t,s,o)=>(li=r._duckdb_web_prepared_send=D.nb)(e,t,s,o),ui=r._duckdb_web_query_run=(e,t,s)=>(ui=r._duckdb_web_query_run=D.ob)(e,t,s),ci=r._duckdb_web_query_run_buffer=(e,t,s,o)=>(ci=r._duckdb_web_query_run_buffer=D.pb)(e,t,s,o),di=r._duckdb_web_pending_query_start=(e,t,s,o)=>(di=r._duckdb_web_pending_query_start=D.qb)(e,t,s,o),fi=r._duckdb_web_pending_query_start_buffer=(e,t,s,o,u)=>(fi=r._duckdb_web_pending_query_start_buffer=D.rb)(e,t,s,o,u),_i=r._duckdb_web_pending_query_poll=(e,t,s)=>(_i=r._duckdb_web_pending_query_poll=D.sb)(e,t,s),hi=r._duckdb_web_pending_query_cancel=(e,t)=>(hi=r._duckdb_web_pending_query_cancel=D.tb)(e,t),bi=r._duckdb_web_query_fetch_results=(e,t)=>(bi=r._duckdb_web_query_fetch_results=D.ub)(e,t),pi=r._duckdb_web_get_tablenames=(e,t,s)=>(pi=r._duckdb_web_get_tablenames=D.vb)(e,t,s),mi=r._duckdb_web_get_tablenames_buffer=(e,t,s,o)=>(mi=r._duckdb_web_get_tablenames_buffer=D.wb)(e,t,s,o),gi=r._duckdb_web_insert_arrow_from_ipc_stream=(e,t,s,o,u)=>(gi=r._duckdb_web_insert_arrow_from_ipc_stream=D.xb)(e,t,s,o,u),wi=r._duckdb_web_insert_csv_from_path=(e,t,s,o)=>(wi=r._duckdb_web_insert_csv_from_path=D.yb)(e,t,s,o),yi=r._duckdb_web_insert_json_from_path=(e,t,s,o)=>(yi=r._duckdb_web_insert_json_from_path=D.zb)(e,t,s,o),vi=()=>(vi=D.Ab)(),st=()=>(st=D.Bb)(),Ut=(e,t,s,o,u,d)=>(Ut=D.Cb)(e,t,s,o,u,d),Mr=()=>(Mr=D.Db)(),Br=e=>(Br=D.Hb)(e),Pr=e=>(Pr=D.Ib)(e),Lr=(e,t,s,o,u)=>(Lr=D.Jb)(e,t,s,o,u),Or=e=>(Or=D.Kb)(e),xt=e=>(xt=D.Lb)(e),Cr=()=>(Cr=D.Mb)(),Ae=r._malloc=e=>(Ae=r._malloc=D.Nb)(e),Ei=r._free=e=>(Ei=r._free=D.Ob)(e),Fi=r._calloc=(e,t)=>(Fi=r._calloc=D.Pb)(e,t),Nr=e=>(Nr=D.Rb)(e),Wr=()=>(Wr=D.Sb)(),Gr=(e,t)=>(Gr=D.Tb)(e,t),$r=e=>($r=D.Ub)(e),Kr=e=>(Kr=D.Vb)(e),qr=()=>(qr=D.Wb)();function Ai(e){e=Object.assign({},e);var t=u=>()=>u()>>>0,s=u=>d=>u(d)>>>0,o=u=>(d,_)=>u(d,_)>>>0;return e.Bb=t(e.Bb),e.Nb=s(e.Nb),e.Pb=o(e.Pb),e.Vb=s(e.Vb),e.Wb=t(e.Wb),e}r.stackSave=Ye,r.stackRestore=$e,r.stackAlloc=Ke,r.getTempRet0=Da,r.setTempRet0=Ta,r.ccall=Ra;function Si(){var e=xr,t=0,s=0;try{var o=e(t,s);return ir(o,!0),o}catch(u){return Et(u)}}function Mt(){if(Ue>0){We=Mt;return}if(U){c(r),Xt();return}if(An(),Ue>0){We=Mt;return}function e(){var s;if(r.calledRun=!0,!x){Xt(),c(r),(s=r.onRuntimeInitialized)==null||s.call(r);var t=r.noInitialRun;t||Si(),Sn()}}r.setStatus?(r.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>r.setStatus(""),1),e()},1)):e()}if(r.preInit)for(typeof r.preInit=="function"&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return Mt(),l=m,l}})();typeof dn=="object"&&typeof _t=="object"?(_t.exports=ft,_t.exports.default=ft):typeof define=="function"&&define.amd&&define([],()=>ft);var an,on,cn=(on=(an=globalThis.self)==null?void 0:an.name)==null?void 0:on.startsWith("em-pthread"),ln,un,Oi=typeof((un=(ln=globalThis.process)==null?void 0:ln.versions)==null?void 0:un.node)=="string";Oi&&(cn=Nt().workerData==="em-pthread");cn&&ft()});var hn=Ie(()=>{});var bn=Ie(()=>{});var pn=Ie((ko,pt)=>{(function(){"use strict";var i="input is invalid type",n=typeof window=="object",a=n?window:{};a.JS_SHA256_NO_WINDOW&&(n=!1);var l=!n&&typeof self=="object",r=!a.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node&&process.type!="renderer";r?a=global:l&&(a=self);var c=!a.JS_SHA256_NO_COMMON_JS&&typeof pt=="object"&&pt.exports,h=typeof define=="function"&&define.amd,m=!a.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",f="0123456789abcdef".split(""),C=[-2147483648,8388608,32768,128],b=[24,16,8,0],U=[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],j=["hex","array","digest","arrayBuffer"],H=[];(a.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(g){return Object.prototype.toString.call(g)==="[object Array]"}),m&&(a.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(g){return typeof g=="object"&&g.buffer&&g.buffer.constructor===ArrayBuffer});var O=function(g,R){return function(M){return new V(R,!0).update(M)[g]()}},ne=function(g){var R=O("hex",g);r&&(R=J(R,g)),R.create=function(){return new V(g)},R.update=function(k){return R.create().update(k)};for(var M=0;M<j.length;++M){var y=j[M];R[y]=O(y,g)}return R},J=function(g,R){var M=hn(),y=bn().Buffer,k=R?"sha224":"sha256",E;y.from&&!a.JS_SHA256_NO_BUFFER_FROM?E=y.from:E=function(v){return new y(v)};var I=function(v){if(typeof v=="string")return M.createHash(k).update(v,"utf8").digest("hex");if(v==null)throw new Error(i);return v.constructor===ArrayBuffer&&(v=new Uint8Array(v)),Array.isArray(v)||ArrayBuffer.isView(v)||v.constructor===y?M.createHash(k).update(E(v)).digest("hex"):g(v)};return I},Y=function(g,R){return function(M,y){return new ie(M,R,!0).update(y)[g]()}},ee=function(g){var R=Y("hex",g);R.create=function(k){return new ie(k,g)},R.update=function(k,E){return R.create(k).update(E)};for(var M=0;M<j.length;++M){var y=j[M];R[y]=Y(y,g)}return R};function V(g,R){R?(H[0]=H[16]=H[1]=H[2]=H[3]=H[4]=H[5]=H[6]=H[7]=H[8]=H[9]=H[10]=H[11]=H[12]=H[13]=H[14]=H[15]=0,this.blocks=H):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],g?(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=g}V.prototype.update=function(g){if(!this.finalized){var R,M=typeof g;if(M!=="string"){if(M==="object"){if(g===null)throw new Error(i);if(m&&g.constructor===ArrayBuffer)g=new Uint8Array(g);else if(!Array.isArray(g)&&(!m||!ArrayBuffer.isView(g)))throw new Error(i)}else throw new Error(i);R=!0}for(var y,k=0,E,I=g.length,v=this.blocks;k<I;){if(this.hashed&&(this.hashed=!1,v[0]=this.block,this.block=v[16]=v[1]=v[2]=v[3]=v[4]=v[5]=v[6]=v[7]=v[8]=v[9]=v[10]=v[11]=v[12]=v[13]=v[14]=v[15]=0),R)for(E=this.start;k<I&&E<64;++k)v[E>>>2]|=g[k]<<b[E++&3];else for(E=this.start;k<I&&E<64;++k)y=g.charCodeAt(k),y<128?v[E>>>2]|=y<<b[E++&3]:y<2048?(v[E>>>2]|=(192|y>>>6)<<b[E++&3],v[E>>>2]|=(128|y&63)<<b[E++&3]):y<55296||y>=57344?(v[E>>>2]|=(224|y>>>12)<<b[E++&3],v[E>>>2]|=(128|y>>>6&63)<<b[E++&3],v[E>>>2]|=(128|y&63)<<b[E++&3]):(y=65536+((y&1023)<<10|g.charCodeAt(++k)&1023),v[E>>>2]|=(240|y>>>18)<<b[E++&3],v[E>>>2]|=(128|y>>>12&63)<<b[E++&3],v[E>>>2]|=(128|y>>>6&63)<<b[E++&3],v[E>>>2]|=(128|y&63)<<b[E++&3]);this.lastByteIndex=E,this.bytes+=E-this.start,E>=64?(this.block=v[16],this.start=E-64,this.hash(),this.hashed=!0):this.start=E}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},V.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var g=this.blocks,R=this.lastByteIndex;g[16]=this.block,g[R>>>2]|=C[R&3],this.block=g[16],R>=56&&(this.hashed||this.hash(),g[0]=this.block,g[16]=g[1]=g[2]=g[3]=g[4]=g[5]=g[6]=g[7]=g[8]=g[9]=g[10]=g[11]=g[12]=g[13]=g[14]=g[15]=0),g[14]=this.hBytes<<3|this.bytes>>>29,g[15]=this.bytes<<3,this.hash()}},V.prototype.hash=function(){var g=this.h0,R=this.h1,M=this.h2,y=this.h3,k=this.h4,E=this.h5,I=this.h6,v=this.h7,x=this.blocks,B,Q,Z,de,q,fe,_e,Se,Ne,ue,Be;for(B=16;B<64;++B)q=x[B-15],Q=(q>>>7|q<<25)^(q>>>18|q<<14)^q>>>3,q=x[B-2],Z=(q>>>17|q<<15)^(q>>>19|q<<13)^q>>>10,x[B]=x[B-16]+Q+x[B-7]+Z<<0;for(Be=R&M,B=0;B<64;B+=4)this.first?(this.is224?(Se=300032,q=x[0]-1413257819,v=q-150054599<<0,y=q+24177077<<0):(Se=704751109,q=x[0]-210244248,v=q-1521486534<<0,y=q+143694565<<0),this.first=!1):(Q=(g>>>2|g<<30)^(g>>>13|g<<19)^(g>>>22|g<<10),Z=(k>>>6|k<<26)^(k>>>11|k<<21)^(k>>>25|k<<7),Se=g&R,de=Se^g&M^Be,_e=k&E^~k&I,q=v+Z+_e+U[B]+x[B],fe=Q+de,v=y+q<<0,y=q+fe<<0),Q=(y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10),Z=(v>>>6|v<<26)^(v>>>11|v<<21)^(v>>>25|v<<7),Ne=y&g,de=Ne^y&R^Se,_e=v&k^~v&E,q=I+Z+_e+U[B+1]+x[B+1],fe=Q+de,I=M+q<<0,M=q+fe<<0,Q=(M>>>2|M<<30)^(M>>>13|M<<19)^(M>>>22|M<<10),Z=(I>>>6|I<<26)^(I>>>11|I<<21)^(I>>>25|I<<7),ue=M&y,de=ue^M&g^Ne,_e=I&v^~I&k,q=E+Z+_e+U[B+2]+x[B+2],fe=Q+de,E=R+q<<0,R=q+fe<<0,Q=(R>>>2|R<<30)^(R>>>13|R<<19)^(R>>>22|R<<10),Z=(E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7),Be=R&M,de=Be^R&y^ue,_e=E&I^~E&v,q=k+Z+_e+U[B+3]+x[B+3],fe=Q+de,k=g+q<<0,g=q+fe<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+g<<0,this.h1=this.h1+R<<0,this.h2=this.h2+M<<0,this.h3=this.h3+y<<0,this.h4=this.h4+k<<0,this.h5=this.h5+E<<0,this.h6=this.h6+I<<0,this.h7=this.h7+v<<0},V.prototype.hex=function(){this.finalize();var g=this.h0,R=this.h1,M=this.h2,y=this.h3,k=this.h4,E=this.h5,I=this.h6,v=this.h7,x=f[g>>>28&15]+f[g>>>24&15]+f[g>>>20&15]+f[g>>>16&15]+f[g>>>12&15]+f[g>>>8&15]+f[g>>>4&15]+f[g&15]+f[R>>>28&15]+f[R>>>24&15]+f[R>>>20&15]+f[R>>>16&15]+f[R>>>12&15]+f[R>>>8&15]+f[R>>>4&15]+f[R&15]+f[M>>>28&15]+f[M>>>24&15]+f[M>>>20&15]+f[M>>>16&15]+f[M>>>12&15]+f[M>>>8&15]+f[M>>>4&15]+f[M&15]+f[y>>>28&15]+f[y>>>24&15]+f[y>>>20&15]+f[y>>>16&15]+f[y>>>12&15]+f[y>>>8&15]+f[y>>>4&15]+f[y&15]+f[k>>>28&15]+f[k>>>24&15]+f[k>>>20&15]+f[k>>>16&15]+f[k>>>12&15]+f[k>>>8&15]+f[k>>>4&15]+f[k&15]+f[E>>>28&15]+f[E>>>24&15]+f[E>>>20&15]+f[E>>>16&15]+f[E>>>12&15]+f[E>>>8&15]+f[E>>>4&15]+f[E&15]+f[I>>>28&15]+f[I>>>24&15]+f[I>>>20&15]+f[I>>>16&15]+f[I>>>12&15]+f[I>>>8&15]+f[I>>>4&15]+f[I&15];return this.is224||(x+=f[v>>>28&15]+f[v>>>24&15]+f[v>>>20&15]+f[v>>>16&15]+f[v>>>12&15]+f[v>>>8&15]+f[v>>>4&15]+f[v&15]),x},V.prototype.toString=V.prototype.hex,V.prototype.digest=function(){this.finalize();var g=this.h0,R=this.h1,M=this.h2,y=this.h3,k=this.h4,E=this.h5,I=this.h6,v=this.h7,x=[g>>>24&255,g>>>16&255,g>>>8&255,g&255,R>>>24&255,R>>>16&255,R>>>8&255,R&255,M>>>24&255,M>>>16&255,M>>>8&255,M&255,y>>>24&255,y>>>16&255,y>>>8&255,y&255,k>>>24&255,k>>>16&255,k>>>8&255,k&255,E>>>24&255,E>>>16&255,E>>>8&255,E&255,I>>>24&255,I>>>16&255,I>>>8&255,I&255];return this.is224||x.push(v>>>24&255,v>>>16&255,v>>>8&255,v&255),x},V.prototype.array=V.prototype.digest,V.prototype.arrayBuffer=function(){this.finalize();var g=new ArrayBuffer(this.is224?28:32),R=new DataView(g);return R.setUint32(0,this.h0),R.setUint32(4,this.h1),R.setUint32(8,this.h2),R.setUint32(12,this.h3),R.setUint32(16,this.h4),R.setUint32(20,this.h5),R.setUint32(24,this.h6),this.is224||R.setUint32(28,this.h7),g};function ie(g,R,M){var y,k=typeof g;if(k==="string"){var E=[],I=g.length,v=0,x;for(y=0;y<I;++y)x=g.charCodeAt(y),x<128?E[v++]=x:x<2048?(E[v++]=192|x>>>6,E[v++]=128|x&63):x<55296||x>=57344?(E[v++]=224|x>>>12,E[v++]=128|x>>>6&63,E[v++]=128|x&63):(x=65536+((x&1023)<<10|g.charCodeAt(++y)&1023),E[v++]=240|x>>>18,E[v++]=128|x>>>12&63,E[v++]=128|x>>>6&63,E[v++]=128|x&63);g=E}else if(k==="object"){if(g===null)throw new Error(i);if(m&&g.constructor===ArrayBuffer)g=new Uint8Array(g);else if(!Array.isArray(g)&&(!m||!ArrayBuffer.isView(g)))throw new Error(i)}else throw new Error(i);g.length>64&&(g=new V(R,!0).update(g).array());var B=[],Q=[];for(y=0;y<64;++y){var Z=g[y]||0;B[y]=92^Z,Q[y]=54^Z}V.call(this,R,M),this.update(Q),this.oKeyPad=B,this.inner=!0,this.sharedMemory=M}ie.prototype=new V,ie.prototype.finalize=function(){if(V.prototype.finalize.call(this),this.inner){this.inner=!1;var g=this.array();V.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(g),V.prototype.finalize.call(this)}};var se=ne();se.sha256=se,se.sha224=ne(!0),se.sha256.hmac=ee(),se.sha224.hmac=ee(!0),c?pt.exports=se:(a.sha256=se.sha256,a.sha224=se.sha224,h&&define(function(){return se}))})()});var Ki={};Ui(Ki,{registerWorker:()=>vn});var it=class{constructor(n,a){this._bindings=n,this._conn=a}close(){this._bindings.disconnect(this._conn)}useUnsafe(n){return n(this._bindings,this._conn)}query(n){return this._bindings.runQuery(this._conn,n)}async send(n,a=!1){let l=this._bindings.startPendingQuery(this._conn,n,a);for(;l==null;)l=await new Promise((r,c)=>{try{r(this._bindings.pollPendingQuery(this._conn))}catch(h){console.log(h),h.message.includes("worker is not set!")?c(new Error("Worker has been terminated")):c(h)}});return new ot(this._bindings,this._conn,l)}cancelSent(){return this._bindings.cancelPendingQuery(this._conn)}getTableNames(n){return this._bindings.getTableNames(this._conn,n)}prepare(n){let a=this._bindings.createPrepared(this._conn,n);return new Pt(this._bindings,this._conn,a)}insertArrowFromIPCStream(n,a){this._bindings.insertArrowFromIPCStream(this._conn,n,a)}insertCSVFromPath(n,a){this._bindings.insertCSVFromPath(this._conn,n,a)}insertJSONFromPath(n,a){this._bindings.insertJSONFromPath(this._conn,n,a)}},ot=class{constructor(n,a,l){this.bindings=n;this.conn=a;this.header=l;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 n=null;do n=this.bindings.fetchQueryResults(this.conn);while(n==null);return this._depleted=n.length==0,{done:this._depleted,value:n}}[Symbol.iterator](){return this}},Pt=class{constructor(n,a,l){this.bindings=n,this.connectionId=a,this.statementId=l}close(){this.bindings.closePrepared(this.connectionId,this.statementId)}query(...n){return this.bindings.runPrepared(this.connectionId,this.statementId,n)}send(...n){let a=this.bindings.sendPrepared(this.connectionId,this.statementId,n);return new ot(this.bindings,this.connectionId,a)}};function Jr(i){return i<=255}function Yr(i){return i===256}var en=new TextEncoder,Qr=new TextDecoder("utf-8");function Lt(i,n,a){let l=en.encode(a),r=i._malloc(l.byteLength),c=i.HEAPU8.subarray(r,r+l.byteLength);c.set(l),i.HEAPF64[(n>>3)+0]=1,i.HEAPF64[(n>>3)+1]=r,i.HEAPF64[(n>>3)+2]=c.byteLength}function Ct(i){switch(i){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 Ot(i,n,a,l){let r=i.HEAPU8.subarray(n,n+l*Ct(a));switch(a){case"UINT8":return new Uint8Array(r.buffer,r.byteOffset,l);case"INT8":return new Int8Array(r.buffer,r.byteOffset,l);case"INT32":return new Int32Array(r.buffer,r.byteOffset,l);case"FLOAT":return new Float32Array(r.buffer,r.byteOffset,l);case"DOUBLE":return new Float64Array(r.buffer,r.byteOffset,l);case"VARCHAR":return new Float64Array(r.buffer,r.byteOffset,l);default:return new Array(0)}}function Zr(i,n,a){let l=i.HEAPU8.subarray(n,n+a);return new Uint8Array(l.buffer,l.byteOffset,a)}function lt(i,n,a){let l=i.HEAPU8.subarray(n,n+a*8);return new Float64Array(l.buffer,l.byteOffset,a)}function tn(i,n,a,l,r,c,h,m){try{let f=i._udfFunctions.get(l);if(!f){Lt(n,a,"Unknown UDF with id: "+l);return}let C=Qr.decode(n.HEAPU8.subarray(r,r+c)),b=JSON.parse(C),U=lt(n,h,m/8),j=y=>{var E;let k=null;switch(y.validityBuffer!==void 0&&(k=Zr(n,U[y.validityBuffer],b.rows)),y.physicalType){case"VARCHAR":{if(y.dataBuffer===null||y.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for VARCHAR argument");if(y.lengthBuffer===null||y.lengthBuffer===void 0)throw new Error("malformed data view, expected data length buffer for VARCHAR argument");let I=Ot(n,U[y.dataBuffer],y.physicalType,b.rows),v=[],x=lt(n,U[y.lengthBuffer],b.rows);for(let B=0;B<b.rows;++B){if(k!=null&&!k[B]){v.push(null);continue}let Q=n.HEAPU8.subarray(I[B],I[B]+x[B]),Z=Qr.decode(Q);v.push(Z)}return B=>v[B]}case"STRUCT":{let I={},v=[];for(let x=0;x<(((E=y.children)==null?void 0:E.length)||0);++x){let B=y.children[x],Q=j(B);v.push(Z=>{I[B.name]=Q(Z)})}return k!=null?x=>{if(!k[x])return null;for(let B of v)B(x);return I}:x=>{for(let B of v)B(x);return I}}default:{if(y.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for argument of type: "+y.physicalType);let I=Ot(n,U[y.dataBuffer],y.physicalType,b.rows);return k!=null?v=>k[v]?I[v]:null:v=>I[v]}}},H=[];for(let y=0;y<b.args.length;++y)H.push(j(b.args[y]));let O=b.rows*Ct(b.ret.physicalType),ne=n._malloc(O),J=Ot(n,ne,b.ret.physicalType,b.rows),Y=n._malloc(b.rows),ee=Zr(n,Y,b.rows);if(J.length==0||ee.length==0){Lt(n,a,"Can't create physical arrays for result");return}let V=J;b.ret.physicalType=="VARCHAR"&&(V=new Array(b.rows));let ie=[];for(let y=0;y<b.args.length;++y)ie.push(null);for(let y=0;y<b.rows;++y){for(let E=0;E<b.args.length;++E)ie[E]=H[E](y);let k=f.func(...ie);V[y]=k,ee[y]=k==null?0:1}let se=0;switch(b.ret.physicalType){case"VARCHAR":{let y=new Array(0);se=n._malloc(b.rows*Ct("DOUBLE"));let k=lt(n,se,b.rows),E=0;for(let B=0;B<b.rows;++B){let Q=en.encode(V[B]||"");y.push(Q),k[B]=Q.length,E+=Q.length}let I=n._malloc(E),v=n.HEAPU8.subarray(I,I+E),x=0;for(let B=0;B<b.rows;++B){J[B]=x;let Q=y[B];v.subarray(x,x+Q.length).set(Q),x+=Q.length}}}let g=3*8,R=n._malloc(g),M=lt(n,R,3);M[0]=ne,M[1]=Y,M[2]=se,n.HEAPF64[(a>>3)+0]=0,n.HEAPF64[(a>>3)+1]=R,n.HEAPF64[(a>>3)+2]=0}catch(f){Lt(n,a,f.toString())}}function Bi(){let i=new TextDecoder;return n=>(typeof SharedArrayBuffer<"u"&&n.buffer instanceof SharedArrayBuffer&&(n=new Uint8Array(n)),i.decode(n))}var Pi=Bi();function me(i,n){console.error(`FAIL WITH: ${n}`),i.ccall("duckdb_web_fail_with",null,["string"],[n])}function Oe(i){let n=i.wasmMemory;if(n&&n.buffer!==i.HEAPU8.buffer){let a=n.buffer;i.HEAPU8=new Uint8Array(a),i.HEAPF64=new Float64Array(a)}}function Me(i,n,a){Oe(i);let l=new Uint8Array(i.HEAPU8.buffer,n,a),r=new Uint8Array(new ArrayBuffer(l.byteLength));return r.set(l),r}function W(i,n,a){return Oe(i),Pi(new Uint8Array(i.HEAPU8.buffer,n,a))}function z(i,n,a,l){let r=i.stackSave(),c=i.stackAlloc(3*8);a.unshift("number"),l.unshift(c),i.ccall(n,null,a,l),Oe(i);let h=i.HEAPF64[(c>>3)+0],m=i.HEAPF64[(c>>3)+1],f=i.HEAPF64[(c>>3)+2];return i.stackRestore(r),[h,m,f]}function re(i){i.ccall("duckdb_web_clear_response",null,[],[])}var ut=class{constructor(n){let a=new Float64Array(n.buffer,n.byteOffset,n.byteLength/8),l=new Uint8Array(new ArrayBuffer(n.byteLength));l.set(n.subarray(7*8)),this.totalFileReadsCold=a[0],this.totalFileReadsAhead=a[1],this.totalFileReadsCached=a[2],this.totalFileWrites=a[3],this.totalPageAccesses=a[4],this.totalPageLoads=a[5],this.blockSize=a[6],this.blockStats=l}getBlockStats(n,a){return a=a||{file_reads_cold:0,file_reads_ahead:0,file_reads_cached:0,file_writes:0,page_accesses:0,page_loads:0},a.file_writes=this.blockStats[n*3+0]&15,a.file_reads_cold=this.blockStats[n*3+0]>>4,a.file_reads_ahead=this.blockStats[n*3+1]&15,a.file_reads_cached=this.blockStats[n*3+1]>>4,a.page_accesses=this.blockStats[n*3+1]&15,a.page_loads=this.blockStats[n*3+1]>>4,a}};var Ce=new TextEncoder;function le(i){return i!==0}var ct=class{constructor(n,a){this._instance=null;this._initPromise=null;this._initPromiseResolver=()=>{};this.onInstantiationProgress=[];this._logger=n,this._runtime=a,this._nextUDFId=1}get logger(){return this._logger}get mod(){return this._instance}get pthread(){return this.mod.PThread||null}async instantiate(n=a=>{}){return this._instance!=null?this:(this._initPromise!=null&&(this.onInstantiationProgress.push(n),await this._initPromise),this._initPromise=new Promise(a=>{this._initPromiseResolver=a}),this.onInstantiationProgress=[n],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(a=>a!=n),globalThis.DUCKDB_BINDINGS=this,this)}open(n){let[a,l,r]=z(this.mod,"duckdb_web_open",["string"],[JSON.stringify(n)]);if(a!==0)throw new Error(W(this.mod,l,r));re(this.mod)}reset(){let[n,a,l]=z(this.mod,"duckdb_web_reset",[],[]);if(n!==0)throw new Error(W(this.mod,a,l));re(this.mod)}getVersion(){let[n,a,l]=z(this.mod,"duckdb_web_get_version",[],[]);if(n!==0)throw new Error(W(this.mod,a,l));let r=W(this.mod,a,l);return re(this.mod),r}getFeatureFlags(){return this.mod.ccall("duckdb_web_get_feature_flags","number",[],[])}tokenize(n){let a=Ce.encode(n),l=this.mod._malloc(a.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,l,a.length).set(a);let[c,h,m]=z(this.mod,"duckdb_web_tokenize_buffer",["number","number"],[l,a.length]);if(this.mod._free(l),c!==0)throw new Error(W(this.mod,h,m));let f=W(this.mod,h,m);return re(this.mod),JSON.parse(f)}connect(){let n=this.mod.ccall("duckdb_web_connect","number",[],[]);return new it(this,n)}disconnect(n){if(this.mod.ccall("duckdb_web_disconnect",null,["number"],[n]),this.pthread)for(let a of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])a.postMessage({cmd:"dropUDFFunctions",connectionId:n})}runQuery(n,a){let l=Ce.encode(a),r=this.mod._malloc(l.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,l.length).set(l);let[h,m,f]=z(this.mod,"duckdb_web_query_run_buffer",["number","number","number"],[n,r,l.length]);if(this.mod._free(r),h!==0)throw new Error(W(this.mod,m,f));let C=Me(this.mod,m,f);return re(this.mod),C}startPendingQuery(n,a,l=!1){let r=Ce.encode(a),c=this.mod._malloc(r.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,c,r.length).set(r);let[m,f,C]=z(this.mod,"duckdb_web_pending_query_start_buffer",["number","number","number","boolean"],[n,c,r.length,l]);if(this.mod._free(c),m!==0)throw new Error(W(this.mod,f,C));if(f==0)return null;let b=Me(this.mod,f,C);return re(this.mod),b}pollPendingQuery(n){let[a,l,r]=z(this.mod,"duckdb_web_pending_query_poll",["number"],[n]);if(a!==0)throw new Error(W(this.mod,l,r));if(l==0)return null;let c=Me(this.mod,l,r);return re(this.mod),c}cancelPendingQuery(n){return this.mod.ccall("duckdb_web_pending_query_cancel","boolean",["number"],[n])}fetchQueryResults(n){let[a,l,r]=z(this.mod,"duckdb_web_query_fetch_results",["number"],[n]);if(Yr(a))return re(this.mod),null;if(!Jr(a))throw new Error("Unexpected StatusCode from duckdb_web_query_fetch_results ("+a+") and with self reported error as"+W(this.mod,l,r));if(a!==0)throw new Error(W(this.mod,l,r));let c=Me(this.mod,l,r);return re(this.mod),c}getTableNames(n,a){let l=Ce.encode(a),r=this.mod._malloc(l.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,l.length).set(l);let[h,m,f]=z(this.mod,"duckdb_web_get_tablenames_buffer",["number","number","number"],[n,r,l.length]);if(this.mod._free(r),h!==0)throw new Error(W(this.mod,m,f));let C=W(this.mod,m,f);return re(this.mod),JSON.parse(C)}createPrepared(n,a){let l=Ce.encode(a),r=this.mod._malloc(l.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,l.length).set(l);let[h,m,f]=z(this.mod,"duckdb_web_prepared_create_buffer",["number","number","number"],[n,r,l.length]);if(this.mod._free(r),le(h))throw new Error(W(this.mod,m,f));return re(this.mod),m}closePrepared(n,a){let[l,r,c]=z(this.mod,"duckdb_web_prepared_close",["number","number"],[n,a]);if(le(l))throw new Error(W(this.mod,r,c));re(this.mod)}runPrepared(n,a,l){let[r,c,h]=z(this.mod,"duckdb_web_prepared_run",["number","number","string"],[n,a,JSON.stringify(l)]);if(le(r))throw new Error(W(this.mod,c,h));let m=Me(this.mod,c,h);return re(this.mod),m}sendPrepared(n,a,l){let[r,c,h]=z(this.mod,"duckdb_web_prepared_send",["number","number","string"],[n,a,JSON.stringify(l)]);if(le(r))throw new Error(W(this.mod,c,h));let m=Me(this.mod,c,h);return re(this.mod),m}insertArrowFromIPCStream(n,a,l){if(a.length==0)return;let r=this.mod._malloc(a.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,a.length).set(a);let h=l?JSON.stringify(l):"",[m,f,C]=z(this.mod,"duckdb_web_insert_arrow_from_ipc_stream",["number","number","number","string"],[n,r,a.length,h]);if(this.mod._free(r),m!==0)throw new Error(W(this.mod,f,C))}insertCSVFromPath(n,a,l){let r=JSON.stringify(l),[c,h,m]=z(this.mod,"duckdb_web_insert_csv_from_path",["number","string","string"],[n,a,r]);if(le(c))throw new Error(W(this.mod,h,m))}insertJSONFromPath(n,a,l){let r=JSON.stringify(l),[c,h,m]=z(this.mod,"duckdb_web_insert_json_from_path",["number","string","string"],[n,a,r]);if(le(c))throw new Error(W(this.mod,h,m))}globFiles(n){let[a,l,r]=z(this.mod,"duckdb_web_fs_glob_file_infos",["string"],[n]);if(le(a))throw new Error(W(this.mod,l,r));let c=W(this.mod,l,r);re(this.mod);let h=JSON.parse(c);return h==null?[]:h}registerFileURL(n,a,l,r=!1){a===void 0&&(a=n);let[c,h,m]=z(this.mod,"duckdb_web_fs_register_file_url",["string","string"],[n,a,l,r]);if(le(c))throw new Error(W(this.mod,h,m));re(this.mod)}registerFileText(n,a){let l=Ce.encode(a);this.registerFileBuffer(n,l)}registerFileBuffer(n,a){let l=this.mod._malloc(a.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,l,a.length).set(a);let[c,h,m]=z(this.mod,"duckdb_web_fs_register_file_buffer",["string","number","number"],[n,l,a.length]);if(le(c))throw new Error(W(this.mod,h,m));re(this.mod)}async prepareFileHandle(n,a){if(a===3&&this._runtime.prepareFileHandles){let l=await this._runtime.prepareFileHandles([n],3);for(let r of l){let{handle:c,path:h,fromCached:m}=r;!m&&c.getSize()&&await this.registerFileHandleAsync(h,c,3,!0)}return}throw new Error(`prepareFileHandle: unsupported protocol ${a}`)}async prepareDBFileHandle(n,a){if(a===3&&this._runtime.prepareDBFileHandle){let l=await this._runtime.prepareDBFileHandle(n,3);for(let r of l){let{handle:c,path:h,fromCached:m}=r;!m&&c.getSize()&&await this.registerFileHandleAsync(h,c,3,!0)}return}throw new Error(`prepareDBFileHandle: unsupported protocol ${a}`)}async prepareFileHandleAsync(n,a,l,r){if(l===3&&!(a instanceof FileSystemSyncAccessHandle)){if(a instanceof FileSystemFileHandle){let c=a;try{a=await c.createSyncAccessHandle()}catch(h){throw new Error(h.message+":"+n)}}else if(n!=null)try{a=await(await(await navigator.storage.getDirectory()).getFileHandle(n)).createSyncAccessHandle()}catch(c){throw new Error(c.message+":"+n)}}return a}async registerFileHandleAsync(n,a,l,r){let c=await this.prepareFileHandleAsync(n,a,l,r);this.registerFileHandle(n,c,l,r)}registerFileHandle(n,a,l,r){var f;let[c,h,m]=z(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[n,n,l,r]);if(le(c))throw new Error(W(this.mod,h,m));if(re(this.mod),globalThis.DUCKDB_RUNTIME._files=(globalThis.DUCKDB_RUNTIME._files||new Map).set(n,a),(f=globalThis.DUCKDB_RUNTIME._preparedHandles)!=null&&f[n]&&delete globalThis.DUCKDB_RUNTIME._preparedHandles[n],this.pthread){for(let C of this.pthread.runningWorkers)C.postMessage({cmd:"registerFileHandle",fileName:n,fileHandle:a});for(let C of this.pthread.unusedWorkers)C.postMessage({cmd:"dropFileHandle",fileName:n})}}dropFile(n){let[a,l,r]=z(this.mod,"duckdb_web_fs_drop_file",["string"],[n]);if(le(a))throw new Error(W(this.mod,l,r));re(this.mod)}dropFiles(n){let a=[],l=-1;try{for(let m of n!=null?n:[])if(m!=null&&m.length>0){let f=this.mod.lengthBytesUTF8(m)+1,C=this.mod._malloc(f)>>>0;if(!C)throw new Error(`Failed to allocate memory for string: ${m}`);this.mod.stringToUTF8(m,C,f),a.push(C)}if(l=this.mod._malloc(a.length*4)>>>0,!l)throw new Error("Failed to allocate memory for pointers array");for(let m=0;m<a.length;m++)this.mod.HEAP32[(l>>2)+m]=a[m];let[r,c,h]=z(this.mod,"duckdb_web_fs_drop_files",["number","number"],[l,a.length]);if(r!==0)throw new Error(W(this.mod,c,h));re(this.mod)}finally{for(let r of a)this.mod._free(r);l>0&&this.mod._free(l)}}flushFiles(){this.mod.ccall("duckdb_web_flush_files",null,[],[])}copyFileToPath(n,a){let[l,r,c]=z(this.mod,"duckdb_web_copy_file_to_path",["string","string"],[n,a]);if(le(l))throw new Error(W(this.mod,r,c));re(this.mod)}copyFileToBuffer(n){let[a,l,r]=z(this.mod,"duckdb_web_copy_file_to_buffer",["string"],[n]);if(le(a))throw new Error(W(this.mod,l,r));Oe(this.mod);let c=new Uint8Array(this.mod.HEAPU8.buffer,l,r),h=new Uint8Array(c.length);return h.set(c),re(this.mod),h}async registerOPFSFileName(n){if(n.startsWith("opfs://"))return this.prepareFileHandle(n,3);throw new Error("Not an OPFS file name: "+n)}collectFileStatistics(n,a){let[l,r,c]=z(this.mod,"duckdb_web_collect_file_stats",["string","boolean"],[n,a]);if(le(l))throw new Error(W(this.mod,r,c))}exportFileStatistics(n){let[a,l,r]=z(this.mod,"duckdb_web_export_file_stats",["string"],[n]);if(le(a))throw new Error(W(this.mod,l,r));return Oe(this.mod),new ut(new Uint8Array(this.mod.HEAPU8.buffer,l,r))}};var dt=class{constructor(){this._bindings=null;this._nextMessageId=0}log(n){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:n},[])}sendOK(n){this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"OK",data:null},[])}failWith(n,a){let l={name:a.name,message:a.message,stack:a.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"ERROR",data:l},[])}async onMessage(n){switch(n.type){case"PING":this.sendOK(n);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(n,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(n.data[0],n.data[1],a=>{this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"INSTANTIATE_PROGRESS",data:a},[])}),this.sendOK(n)}catch(a){console.log(a),this._bindings=null,this.failWith(n,a)}return;default:break}if(!this._bindings)return this.failWith(n,new Error("duckdb is not initialized"));try{switch(n.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(n);break;case"OPEN":{let a=n.data.path,l=!!(this._bindings.getFeatureFlags()&2);if(a!=null&&a.startsWith("opfs://")&&!l){let r=globalThis.DUCKDB_RUNTIME;r!=null&&r.prepareDBFileHandle&&await r.prepareDBFileHandle(a,3),n.data.useDirectIO=!0}this._bindings.open(n.data),this.sendOK(n);break}case"DROP_FILE":this._bindings.dropFile(n.data),this.sendOK(n);break;case"DROP_FILES":this._bindings.dropFiles(n.data),this.sendOK(n);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(n);break;case"CONNECT":{let a=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"CONNECTION_INFO",data:a.useUnsafe((l,r)=>r)},[]);break}case"DISCONNECT":this._bindings.disconnect(n.data),this.sendOK(n);break;case"CREATE_PREPARED":{let a=this._bindings.createPrepared(n.data[0],n.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"PREPARED_STATEMENT_ID",data:a},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(n.data[0],n.data[1]),this.sendOK(n);break}case"RUN_PREPARED":{let a=this._bindings.runPrepared(n.data[0],n.data[1],n.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"QUERY_RESULT",data:a},[a.buffer]);break}case"RUN_QUERY":{let a=this._bindings.runQuery(n.data[0],n.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"QUERY_RESULT",data:a},[a.buffer]);break}case"SEND_PREPARED":{let a=this._bindings.sendPrepared(n.data[0],n.data[1],n.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"QUERY_RESULT_HEADER",data:a},[a.buffer]);break}case"START_PENDING_QUERY":{let a=this._bindings.startPendingQuery(n.data[0],n.data[1],n.data[2]),l=[];a&&l.push(a.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:a},l);break}case"POLL_PENDING_QUERY":{let a=this._bindings.pollPendingQuery(n.data),l=[];a&&l.push(a.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:a},l);break}case"CANCEL_PENDING_QUERY":{let a=this._bindings.cancelPendingQuery(n.data);this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"SUCCESS",data:a},[]);break}case"FETCH_QUERY_RESULTS":{let a=this._bindings.fetchQueryResults(n.data),l=a?[a.buffer]:[];this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"QUERY_RESULT_CHUNK",data:a},l);break}case"GET_TABLE_NAMES":{let a=this._bindings.getTableNames(n.data[0],n.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"TABLE_NAMES",data:a},[]);break}case"GLOB_FILE_INFOS":{let a=this._bindings.globFiles(n.data);this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"FILE_INFOS",data:a},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(n.data[0],n.data[1],n.data[2],n.data[3]),this.sendOK(n);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(n.data[0],n.data[1]),this.sendOK(n);break;case"REGISTER_FILE_HANDLE":await this._bindings.registerFileHandleAsync(n.data[0],n.data[1],n.data[2],n.data[3]),this.sendOK(n);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(n.data[0],n.data[1]),this.sendOK(n);break;case"COPY_FILE_TO_BUFFER":{let a=this._bindings.copyFileToBuffer(n.data);this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"FILE_BUFFER",data:a},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(n.data[0],n.data[1]),this.sendOK(n);break;case"REGISTER_OPFS_FILE_NAME":await this._bindings.registerOPFSFileName(n.data[0]),this.sendOK(n);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(n.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(n.data[0],n.data[1],n.data[2]),this.sendOK(n);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(n.data[0],n.data[1],n.data[2]),this.sendOK(n);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(n.data[0],n.data[1],n.data[2]),this.sendOK(n);break}case"TOKENIZE":{let a=this._bindings.tokenize(n.data);this.postMessage({messageId:this._nextMessageId++,requestId:n.messageId,type:"SCRIPT_TOKENS",data:a},[]);break}}}catch(a){return console.log(a),this.failWith(n,a)}}};var _n=zr(fn());var ht=class extends ct{constructor(n,a,l,r){super(n,a),this.mainModuleURL=l,this.pthreadWorkerURL=r}locateFile(n,a){if(n.endsWith(".wasm"))return this.mainModuleURL;if(n.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=${a} path=${n}`)}instantiateWasm(n,a){globalThis.DUCKDB_RUNTIME=this._runtime;let l=this.onInstantiationProgress;if(WebAssembly.instantiateStreaming)if(typeof TransformStream=="function"){let c=(async()=>{var O;let h=new Request(this.mainModuleURL),m=await fetch(h),f=m.headers.get("content-length"),C=f&&parseInt(f,10)||0,b=new Date,U={startedAt:b,updatedAt:b,bytesTotal:C||0,bytesLoaded:0},j={transform(ne,J){U.bytesLoaded+=ne.byteLength;let Y=new Date;if(Y.getTime()-U.updatedAt.getTime()<20){U.updatedAt=Y,J.enqueue(ne);return}for(let ee of l)ee(U);J.enqueue(ne)}},H=new TransformStream(j);return new Response((O=m.body)==null?void 0:O.pipeThrough(H),m)})();WebAssembly.instantiateStreaming(c,n).then(h=>{a(h.instance,h.module)})}else{console.warn("instantiating without progress handler since transform streams are unavailable");let r=new Request(this.mainModuleURL);WebAssembly.instantiateStreaming(fetch(r),n).then(c=>{a(c.instance,c.module)})}else if(typeof XMLHttpRequest=="function"){let r=new XMLHttpRequest,c=this.mainModuleURL,h=new Date,m={startedAt:h,updatedAt:h,bytesTotal:0,bytesLoaded:0};r.open("GET",c),r.responseType="arraybuffer",r.onerror=f=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to load WASM: "+f}),new Error(f.toString())},r.onprogress=f=>{m.bytesTotal=f.total,m.bytesLoaded=f.loaded;let C=new Date;if(C.getTime()-m.updatedAt.getTime()<20){m.updatedAt=C;return}for(let b of l)b(m)},r.onload=()=>{WebAssembly.instantiate(r.response,n).then(f=>{a(f.instance,f.module)}).catch(f=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to instantiate WASM: "+f}),new Error(f)})},r.send()}else console.warn("instantiating with manual fetch since streaming instantiation and xhrs are unavailable"),(async()=>{let c=new Request(this.mainModuleURL),m=await(await fetch(c)).arrayBuffer();WebAssembly.instantiate(m,n).then(f=>{a(f.instance,f.module)})})();return{}}};var bt=class extends ht{constructor(n,a,l,r=null){super(n,a,l,r)}instantiateImpl(n){var a;return(0,_n.default)({...n,instantiateWasm:this.instantiateWasm.bind(this),locateFile:this.locateFile.bind(this),mainScriptUrlOrBlob:(a=this.pthreadWorkerURL)!=null?a:void 0})}};var He=zr(pn()),mn=function(i,n,a){var l;if((l=i==null?void 0:i.endpoint)!=null&&l.startsWith("http")){let r=`${i==null?void 0:i.endpoint}`,c=r.indexOf("://")+3;return r.substring(c)}else return i!=null&&i.endpoint?`${a}.${i==null?void 0:i.endpoint}`:`${a}.s3.amazonaws.com`};function Ci(i,n,a){var c,h,m,f;let l=gn(n),r=l.path;return wn(i)&&(r=`/${l.bucket}${r}`),{url:r,query:"",host:mn(i,n,l.bucket),region:(c=i==null?void 0:i.region)!=null?c:"",service:"s3",method:a,accessKeyId:(h=i==null?void 0:i.accessKeyId)!=null?h:"",secretAccessKey:(m=i==null?void 0:i.secretAccessKey)!=null?m:"",sessionToken:(f=i==null?void 0:i.sessionToken)!=null?f:"",dateNow:new Date().toISOString().replace(/-/g,"").split("T")[0],datetimeNow:new Date().toISOString().replace(/-/g,"").replace(/:/g,"").split(".")[0]+"Z"}}function Ni(i,n=!1){let a="0123456789ABCDEF",l="";for(let r=0;r<i.length;r++){let c=i[r];c>="A"&&c<="Z"||c>="a"&&c<="z"||c>="0"&&c<="9"||c=="_"||c=="-"||c=="~"||c=="."?l+=c:c=="/"?n?l+="%2F":l+=c:(l+="%",l+=a[c.charCodeAt(0)>>4],l+=a[c.charCodeAt(0)&15])}return l}function Wi(i,n=null){var O;let a=(O=n==null?void 0:n.contentHash)!=null?O:"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",l=new Map;l.set("x-amz-date",i.datetimeNow),l.set("x-amz-content-sha256",a),i.sessionToken&&l.set("x-amz-security-token",i.sessionToken);let r="";n!=null&&n.contentType&&(r+="content-type;"),r+="host;x-amz-content-sha256;x-amz-date",i.sessionToken&&(r+=";x-amz-security-token");let c=i.method+`
6
- `+Ni(i.url)+`
7
- `+i.query;n!=null&&n.contentType&&(c+=`
8
- content-type:`+(n==null?void 0:n.contentType)),c+=`
9
- host:`+i.host+`
10
- x-amz-content-sha256:`+a+`
11
- x-amz-date:`+i.datetimeNow,i.sessionToken&&i.sessionToken.length>0&&(c+=`
12
- x-amz-security-token:`+i.sessionToken),c+=`
13
-
14
- `+r+`
15
- `+a;let h=(0,He.sha256)(c),m=`AWS4-HMAC-SHA256
16
- `+i.datetimeNow+`
17
- `+i.dateNow+"/"+i.region+"/"+i.service+`/aws4_request
18
- `+h,f="AWS4"+i.secretAccessKey,C=He.sha256.hmac.arrayBuffer(f,i.dateNow),b=He.sha256.hmac.arrayBuffer(C,i.region),U=He.sha256.hmac.arrayBuffer(b,i.service),j=He.sha256.hmac.arrayBuffer(U,"aws4_request"),H=He.sha256.hmac(j,m);return l.set("Authorization","AWS4-HMAC-SHA256 Credential="+i.accessKeyId+"/"+i.dateNow+"/"+i.region+"/"+i.service+"/aws4_request, SignedHeaders="+r+", Signature="+H),l}var Gi=function(i,n,a,l=null,r=null){let c=Ci(i,n,a),h={contentType:l,contentHash:r?He.sha256.hex(r):null};return Wi(c,h)};function ge(i,n,a,l,r=null,c=null){(n!=null&&n.accessKeyId||n!=null&&n.sessionToken)&&(Gi(n,a,l,r,c).forEach((m,f)=>{i.setRequestHeader(f,m)}),r&&i.setRequestHeader("content-type",r))}function gn(i){if(i.indexOf("s3://")!=0)throw new Error("URL needs to start with s3://");let n=i.indexOf("/",5);if(n==-1)throw new Error("URL needs to contain a '/' after the host");let a=i.substring(5,n);if(!a)throw new Error("URL needs to contain a bucket name");let l=i.substring(n);if(!l)throw new Error("URL needs to contain key");return{bucket:a,path:l}}function wn(i){var n;return!!((n=i==null?void 0:i.endpoint)!=null&&n.startsWith("http"))}function we(i,n){let a=gn(n);return wn(i)?`${i==null?void 0:i.endpoint}/${a.bucket}`+a.path:"https://"+mn(i,n,a.bucket)+a.path}var $i=7,yn=/\/|\\/,L={_files:new Map,_fileInfoCache:new Map,_udfFunctions:new Map,_globalFileInfo:null,_preparedHandles:{},_opfsRoot:null,getFileInfo(i,n){try{let a=L._fileInfoCache.get(n),[l,r,c]=z(i,"duckdb_web_fs_get_file_info_by_id",["number","number"],[n,(a==null?void 0:a.cacheEpoch)||0]);if(l!==0)return null;if(c===0)return a;let h=W(i,r,c);re(i);try{let m=JSON.parse(h);if(m==null)return null;let f={...m,blob:null};return L._fileInfoCache.set(n,f),!L._files.has(f.fileName)&&L._preparedHandles[f.fileName]&&(L._files.set(f.fileName,L._preparedHandles[f.fileName]),delete L._preparedHandles[f.fileName]),f}catch(m){return console.warn(m),null}}catch(a){return console.log(a),null}},getGlobalFileInfo(i){var n;try{let[a,l,r]=z(i,"duckdb_web_get_global_file_info",["number"],[((n=L._globalFileInfo)==null?void 0:n.cacheEpoch)||0]);if(a!==0)return null;if(r===0)return L._globalFileInfo;let c=W(i,l,r);re(i);let h=JSON.parse(c);return h==null?null:(L._globalFileInfo={...h,blob:null},L._globalFileInfo)}catch(a){return console.log(a),null}},async assignOPFSRoot(){L._opfsRoot||(L._opfsRoot=await navigator.storage.getDirectory())},async prepareFileHandles(i,n){if(n===3){await L.assignOPFSRoot();let a=async r=>{if(L._files.has(r))return{path:r,handle:L._files.get(r),fromCached:!0};let h=L._opfsRoot,m=r.slice($i),f=m;if(yn.test(m)){let b=m.split(yn);if(b.length===0)throw new Error(`Invalid path ${m}`);if(f=b[b.length-1],!f)throw new Error(`Invalid path ${m}. File Not Found.`);b.pop();for(let U of b)h=await h.getDirectoryHandle(U,{create:!0})}let C=await h.getFileHandle(f,{create:!1}).catch(b=>{if((b==null?void 0:b.name)==="NotFoundError")return console.debug(`File ${r} does not exists yet, creating...`),h.getFileHandle(f,{create:!0});throw b});try{let b=await C.createSyncAccessHandle();return L._preparedHandles[r]=b,{path:r,handle:b,fromCached:!1}}catch(b){throw new Error(b.message+":"+name)}},l=[];for(let r of i){let c=await a(r);l.push(c)}return l}throw new Error(`Unsupported protocol ${n} for paths ${i} with protocol ${n}`)},async prepareDBFileHandle(i,n){if(n===3&&this.prepareFileHandles){let a=[i,`${i}.wal`];return this.prepareFileHandles(a,n)}throw new Error(`Unsupported protocol ${n} for path ${i} with protocol ${n}`)},testPlatformFeature:(i,n)=>{switch(n){case 1:return typeof BigInt64Array<"u";default:return console.warn(`test for unknown feature: ${n}`),!1}},getDefaultDataProtocol(i){return 2},openFile:(i,n,a)=>{var l,r,c,h,m,f,C;try{L._fileInfoCache.delete(n);let b=L.getFileInfo(i,n);switch(b==null?void 0:b.dataProtocol){case 4:case 5:{if(a&1&&a&2)throw new Error(`Opening file ${b.fileName} failed: cannot open file with both read and write flags set`);if(a&32)throw new Error(`Opening file ${b.fileName} failed: appending to HTTP/S3 files is not supported`);if(a&2){let H=new XMLHttpRequest;if(b.dataProtocol==5?(H.open("HEAD",we(b.s3Config,b.dataUrl),!1),ge(H,b.s3Config,b.dataUrl,"HEAD")):H.open("HEAD",b.dataUrl,!1),H.send(null),H.status!=200&&H.status!=404)throw new Error(`Opening file ${b.fileName} failed: Unexpected return status from server (${H.status})`);if(H.status==404&&!(a&8||a&16))throw new Error(`Opening file ${b.fileName} failed: Cannot write to non-existent file without FILE_FLAGS_FILE_CREATE or FILE_FLAGS_FILE_CREATE_NEW flag.`);let O=i._malloc(1),ne=new Uint8Array;i.HEAPU8.set(ne,O);let J=i._malloc(3*8);return i.HEAPF64[(J>>>3)+0]=1,i.HEAPF64[(J>>>3)+1]=O,i.HEAPF64[(J>>>3)+2]=new Date().getTime()/1e3,J}else if((a&1)==0)throw new Error(`Opening file ${b.fileName} failed: unsupported file flags: ${a}`);let U=null,j=null;if(!b.forceFullHttpReads&&(b.reliableHeadRequests||!b.allowFullHttpReads))try{let H=new XMLHttpRequest;b.dataProtocol==5?(H.open("HEAD",we(b.s3Config,b.dataUrl),!1),ge(H,b.s3Config,b.dataUrl,"HEAD")):H.open("HEAD",b.dataUrl,!1),H.setRequestHeader("Range","bytes=0-"),H.send(null),U=null;try{U=H.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}if(U!==null&&H.status==206){let O=i._malloc(24);i.HEAPF64[(O>>>3)+0]=+U,i.HEAPF64[(O>>>3)+1]=0;let ne=0;try{ne=new Date((l=H.getResponseHeader("Last-Modified"))!=null?l:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return i.HEAPF64[(O>>>3)+2]=+ne,O}}catch(H){j=H,console.warn(`HEAD request with range header failed: ${H}`)}if(b.allowFullHttpReads){if(!b.forceFullHttpReads){let O=new XMLHttpRequest;b.dataProtocol==5?(O.open("GET",we(b.s3Config,b.dataUrl),!1),ge(O,b.s3Config,b.dataUrl,"GET")):O.open("GET",b.dataUrl,!1),O.responseType="arraybuffer",O.setRequestHeader("Range","bytes=0-0"),O.send(null);let ne=null;try{ne=(r=O.getResponseHeader("Content-Range"))==null?void 0:r.split("/")[1]}catch{console.warn("Failed to get Content-Range on request")}let J=null;try{J=O.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}let Y=null;if(ne!==void 0)Y=ne;else if(!b.reliableHeadRequests){let ee=new XMLHttpRequest;b.dataProtocol==5?(ee.open("HEAD",we(b.s3Config,b.dataUrl),!1),ge(ee,b.s3Config,b.dataUrl,"HEAD")):ee.open("HEAD",b.dataUrl,!1),ee.setRequestHeader("Range","bytes=0-"),ee.send(null),U=null;try{U=ee.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}U!==null&&+U>1&&(Y=U)}if(O.status==206&&J!==null&&+J==1&&Y!==null){let ee=i._malloc(24);i.HEAPF64[(ee>>>3)+0]=+Y,i.HEAPF64[(ee>>>3)+1]=0;let V=0;try{V=new Date((c=O.getResponseHeader("Last-Modified"))!=null?c:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return i.HEAPF64[(ee>>>3)+2]=+V,ee}if(O.status==200&&J!==null&&U!==null&&+J==+U){console.warn(`fall back to full HTTP read for: ${b.dataUrl}`);let ee=i._malloc(O.response.byteLength),V=new Uint8Array(O.response,0,O.response.byteLength);i.HEAPU8.set(V,ee);let ie=i._malloc(3*8);i.HEAPF64[(ie>>>3)+0]=O.response.byteLength,i.HEAPF64[(ie>>>3)+1]=ee;let se=0;try{se=new Date((h=O.getResponseHeader("Last-Modified"))!=null?h:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return i.HEAPF64[(ie>>>3)+2]=+se,ie}console.warn(`falling back to full HTTP read for: ${b.dataUrl}`)}let H=new XMLHttpRequest;if(b.dataProtocol==5?(H.open("GET",we(b.s3Config,b.dataUrl),!1),ge(H,b.s3Config,b.dataUrl,"GET")):H.open("GET",b.dataUrl,!1),H.responseType="arraybuffer",H.send(null),H.status==200){let O=i._malloc(H.response.byteLength),ne=new Uint8Array(H.response,0,H.response.byteLength);i.HEAPU8.set(ne,O);let J=i._malloc(3*8);i.HEAPF64[(J>>>3)+0]=H.response.byteLength,i.HEAPF64[(J>>>3)+1]=O;let Y=0;try{Y=new Date((m=H.getResponseHeader("Last-Modified"))!=null?m:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return i.HEAPF64[(J>>>3)+2]=+Y,J}}if(j!=null)throw new Error(`Reading file ${b.fileName} failed with error: ${j}`);return 0}case 2:{let U=(f=L._files)==null?void 0:f.get(b.fileName);if(U){let O=i._malloc(24);return i.HEAPF64[(O>>>3)+0]=U.size,i.HEAPF64[(O>>>3)+1]=0,i.HEAPF64[(O>>>3)+2]=0,O}if(a&128)return 0;console.warn(`Buffering missing file: ${b.fileName}`);let j=i._malloc(3*8),H=i._malloc(1);return i.HEAPF64[(j>>>3)+0]=1,i.HEAPF64[(j>>>3)+1]=H,i.HEAPF64[(j>>>3)+2]=0,j}case 3:{let U=(C=L._files)==null?void 0:C.get(b.fileName);if(!U)throw new Error(`No OPFS access handle registered with name: ${b.fileName}`);a&16&&U.truncate(0);let j=i._malloc(3*8),H=U.getSize();return i.HEAPF64[(j>>>3)+0]=H,i.HEAPF64[(j>>>3)+1]=0,i.HEAPF64[(j>>>3)+2]=0,j}}}catch(b){console.error(b.toString()),me(i,b.toString())}return 0},glob:(i,n,a)=>{var l;try{let r=W(i,n,a);if(r.startsWith("http")||r.startsWith("s3://")){let c=new XMLHttpRequest;if(r.startsWith("s3://")){let h=L.getGlobalFileInfo(i);c.open("HEAD",we(h==null?void 0:h.s3Config,r),!1),ge(c,h==null?void 0:h.s3Config,r,"HEAD")}else c.open("HEAD",r,!1);if(c.send(null),c.status!=200&&c.status!==206){if(!((l=L.getGlobalFileInfo(i))!=null&&l.allowFullHttpReads))return console.log(`HEAD request failed: ${r}, with full http reads are disabled`),0;let h=new XMLHttpRequest;if(r.startsWith("s3://")){let f=L.getGlobalFileInfo(i);h.open("GET",we(f==null?void 0:f.s3Config,r),!1),ge(h,f==null?void 0:f.s3Config,r,"HEAD")}else h.open("GET",r,!1);if(h.setRequestHeader("Range","bytes=0-0"),h.send(null),h.status!=200&&h.status!==206)return console.log(`HEAD and GET requests failed: ${r}`),0;let m=null;try{m=h.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}m&&+m>1&&console.warn(`Range request for ${r} did not return a partial response: ${h.status} "${h.statusText}"`)}i.ccall("duckdb_web_fs_glob_add_path",null,["string"],[r])}else for(let[c]of L._files.entries()||[])c.startsWith(r)&&i.ccall("duckdb_web_fs_glob_add_path",null,["string"],[c])}catch(r){return console.log(r),me(i,r.toString()),0}},checkFile:(i,n,a)=>{try{let l=W(i,n,a);if(l.startsWith("http")||l.startsWith("s3://")){let r=new XMLHttpRequest;if(l.startsWith("s3://")){let c=L.getGlobalFileInfo(i);r.open("HEAD",we(c==null?void 0:c.s3Config,l),!1),ge(r,c==null?void 0:c.s3Config,l,"HEAD")}else r.open("HEAD",l,!1);return r.send(null),r.status==206||r.status==200}else return L._files.has(l)}catch(l){return console.log(l),!1}return!1},syncFile:(i,n)=>{},closeFile:(i,n)=>{var l;let a=L.getFileInfo(i,n);L._fileInfoCache.delete(n);try{switch(a==null?void 0:a.dataProtocol){case 0:case 4:case 5:break;case 1:case 2:return;case 3:{let r=(l=L._files)==null?void 0:l.get(a.fileName);if(!r)throw new Error(`No OPFS access handle registered with name: ${a.fileName}`);return r.flush()}}}catch(r){console.log(r),me(i,r.toString())}},dropFile:(i,n,a)=>{var c;let l=W(i,n,a),r=(c=L._files)==null?void 0:c.get(l);if(r){if(L._files.delete(l),r instanceof FileSystemSyncAccessHandle)try{r.flush(),r.close()}catch{throw new Error(`Cannot drop file with name: ${l}`)}r instanceof Blob}},truncateFile:(i,n,a)=>{var r;let l=L.getFileInfo(i,n);switch(l==null?void 0:l.dataProtocol){case 4:me(i,"Cannot truncate a http file");return;case 5:me(i,"Cannot truncate an s3 file");return;case 0:case 1:case 2:me(i,"truncateFile not implemented");return;case 3:{let c=(r=L._files)==null?void 0:r.get(l.fileName);if(!c)throw new Error(`No OPFS access handle registered with name: ${l.fileName}`);return c.truncate(a)}}return 0},readFile(i,n,a,l,r){var c;if(l==0)return 0;try{let h=L.getFileInfo(i,n);switch(h==null?void 0:h.dataProtocol){case 4:case 5:{if(!h.dataUrl)throw new Error(`Missing data URL for file ${n}`);try{let m=new XMLHttpRequest;if(h.dataProtocol==5?(m.open("GET",we(h==null?void 0:h.s3Config,h.dataUrl),!1),ge(m,h==null?void 0:h.s3Config,h.dataUrl,"GET")):m.open("GET",h.dataUrl,!1),m.responseType="arraybuffer",m.setRequestHeader("Range",`bytes=${r}-${r+l-1}`),m.send(null),m.status==206||m.status==200&&l==m.response.byteLength&&r==0){let f=new Uint8Array(m.response,0,Math.min(m.response.byteLength,l));return i.HEAPU8.set(f,a),f.byteLength}else if(m.status==200){console.warn(`Range request for ${h.dataUrl} did not return a partial response: ${m.status} "${m.statusText}"`);let f=new Uint8Array(m.response,r,Math.min(m.response.byteLength-r,l));return i.HEAPU8.set(f,a),f.byteLength}else throw new Error(`Range request for ${h.dataUrl} did returned non-success status: ${m.status} "${m.statusText}"`)}catch(m){throw console.log(m),new Error(`Range request for ${h.dataUrl} failed with error: ${m}"`)}}case 2:{let m=(c=L._files)==null?void 0:c.get(h.fileName);if(!m)throw new Error(`No HTML5 file registered with name: ${h.fileName}`);let f=m.slice(r,r+l),C=new Uint8Array(new FileReaderSync().readAsArrayBuffer(f));return i.HEAPU8.set(C,a),C.byteLength}case 3:{let m=L._files.get(h.fileName);if(!m)throw new Error(`No OPFS access handle registered with name: ${h.fileName}`);let f=i.HEAPU8.subarray(a,a+l);return m.read(f,{at:r})}}return 0}catch(h){return console.log(h),me(i,h.toString()),0}},writeFile:(i,n,a,l,r)=>{var h;let c=L.getFileInfo(i,n);switch(c==null?void 0:c.dataProtocol){case 4:return me(i,"Cannot write to HTTP file"),0;case 5:{let m=i.HEAPU8.subarray(a,a+l),f=new XMLHttpRequest;return f.open("PUT",we(c==null?void 0:c.s3Config,c.dataUrl),!1),ge(f,c==null?void 0:c.s3Config,c.dataUrl,"PUT","",m),f.send(m),f.status!==200?(me(i,"Failed writing file: HTTP "+f.status),0):l}case 2:return me(i,"cannot write using the html5 file reader api"),0;case 3:{let m=(h=L._files)==null?void 0:h.get(c.fileName);if(!m)throw new Error(`No OPFS access handle registered with name: ${c.fileName}`);let f=i.HEAPU8.subarray(a,a+l);return m.write(f,{at:r})}}return 0},getLastFileModificationTime:(i,n)=>{var l;let a=L.getFileInfo(i,n);switch(a==null?void 0:a.dataProtocol){case 2:{if(!((l=L._files)==null?void 0:l.get(a.fileName)))throw Error(`No handle available for file: ${a.fileName}`);return 0}case 4:case 5:return new Date().getTime()/1e3}return 0},progressUpdate:(i,n,a)=>{postMessage&&postMessage({requestId:0,type:"PROGRESS_UPDATE",data:{status:i?"completed":"in-progress",percentage:n,repetitions:a}})},checkDirectory:(i,n,a)=>!1,createDirectory:(i,n,a)=>{},removeDirectory:(i,n,a)=>{},listDirectoryEntries:(i,n,a)=>!1,moveFile:(i,n,a,l,r)=>{var f,C;let c=W(i,n,a),h=W(i,l,r),m=(f=L._files)==null?void 0:f.get(c);m!==void 0&&(L._files.delete(m),L._files.set(h,m));for(let[b,U]of((C=L._fileInfoCache)==null?void 0:C.entries())||[])if(U.dataUrl==c){L._fileInfoCache.delete(b);break}return!0},removeFile:(i,n,a)=>{},callScalarUDF:(i,n,a,l,r,c,h)=>{tn(L,i,n,a,l,r,c,h)}};var Wt=class extends dt{postMessage(n,a){globalThis.postMessage(n,a)}async instantiate(n,a,l){return await new bt(this,L,n,a).instantiate(l)}};function vn(){let i=new Wt;globalThis.onmessage=async n=>{await i.onMessage(n.data)}}vn();return xi(Ki);})();
1
+ "use strict";var duckdb=(()=>{var Dm=Object.create;var Bs=Object.defineProperty;var Bm=Object.getOwnPropertyDescriptor;var Fm=Object.getOwnPropertyNames;var Am=Object.getPrototypeOf,Tm=Object.prototype.hasOwnProperty;var La=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r);var ka=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var pr=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),jr=(r,t)=>{for(var e in t)Bs(r,e,{get:t[e],enumerable:!0})},Lu=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Fm(t))!Tm.call(r,i)&&i!==e&&Bs(r,i,{get:()=>t[i],enumerable:!(n=Bm(t,i))||n.enumerable});return r};var ku=(r,t,e)=>(e=r!=null?Dm(Am(r)):{},Lu(t||!r||!r.__esModule?Bs(e,"default",{value:r,enumerable:!0}):e,r)),xm=r=>Lu(Bs({},"__esModule",{value:!0}),r);var Em=function(r,t){this[0]=r,this[1]=t};var un=r=>{var t=r[La("asyncIterator")],e=!1,n,i={};return t==null?(t=r[La("iterator")](),n=s=>i[s]=a=>t[s](a)):(t=t.call(r),n=s=>i[s]=a=>{if(e){if(e=!1,s==="throw")throw a;return a}return e=!0,{done:!1,value:new Em(new Promise(c=>{var d=t[s](a);if(!(d instanceof Object))throw TypeError("Object expected");c(d)}),1)}}),i[La("iterator")]=()=>i,n("next"),"throw"in t?n("throw"):i.throw=s=>{throw s},"return"in t&&n("return"),i};var Nf=pr(()=>{});var Cf=pr(()=>{});var Pf=pr(()=>{});var Hf=pr(()=>{});var Vf=pr(()=>{});var jf=pr((zf,Wc)=>{"use strict";var Wf=(()=>{var t;var r=typeof document<"u"?(t=document.currentScript)==null?void 0:t.src:void 0;return typeof __filename<"u"&&(r||(r=__filename)),function(e={}){function n(){return Ut.buffer!=be.buffer&&fr(),be}function i(){return Ut.buffer!=be.buffer&&fr(),On}function s(){return Ut.buffer!=be.buffer&&fr(),cn}function a(){return Ut.buffer!=be.buffer&&fr(),jc}function c(){return Ut.buffer!=be.buffer&&fr(),$c}function d(){return Ut.buffer!=be.buffer&&fr(),Gc}function h(){return Ut.buffer!=be.buffer&&fr(),Yc}var u=e,I,T,E=new Promise((o,l)=>{I=o,T=l}),ft=Object.assign({},u),At=[],jt="./this.program",Lt=(o,l)=>{throw l},Tt=typeof window=="object",bt=typeof importScripts=="function",xt=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",U=u.ENVIRONMENT_IS_PTHREAD||!1,w="";function M(o){return u.locateFile?u.locateFile(o,w):w+o}var H,D,N;if(xt){var A=Nf(),J=Cf();bt?w=J.dirname(w)+"/":w=__dirname+"/",H=(o,l)=>(o=il(o)?new URL(o):J.normalize(o),A.readFileSync(o,l?void 0:"utf8")),N=o=>{var l=H(o,!0);return l.buffer||(l=new Uint8Array(l)),l},D=(o,l,f,p=!0)=>{o=il(o)?new URL(o):J.normalize(o),A.readFile(o,p?void 0:"utf8",(_,b)=>{_?f(_):l(p?b.buffer:b)})},!u.thisProgram&&process.argv.length>1&&(jt=process.argv[1].replace(/\\/g,"/")),At=process.argv.slice(2),Lt=(o,l)=>{throw process.exitCode=o,l},global.Worker=Pf().Worker}else(Tt||bt)&&(bt?w=self.location.href:typeof document<"u"&&document.currentScript&&(w=document.currentScript.src),r&&(w=r),w.startsWith("blob:")?w="":w=w.substr(0,w.replace(/[?#].*/,"").lastIndexOf("/")+1),xt||(H=o=>{var l=new XMLHttpRequest;return l.open("GET",o,!1),l.send(null),l.responseText},bt&&(N=o=>{var l=new XMLHttpRequest;return l.open("GET",o,!1),l.responseType="arraybuffer",l.send(null),new Uint8Array(l.response)}),D=(o,l,f)=>{var p=new XMLHttpRequest;p.open("GET",o,!0),p.responseType="arraybuffer",p.onload=()=>{if(p.status==200||p.status==0&&p.response){l(p.response);return}f()},p.onerror=f,p.send(null)}));xt&&typeof performance>"u"&&(global.performance=Hf().performance);var B=console.log.bind(console),W=console.error.bind(console);xt&&(B=(...o)=>A.writeSync(1,o.join(" ")+"\n"),W=(...o)=>A.writeSync(2,o.join(" ")+"\n"));var Q=u.print||B,pt=u.printErr||W;Object.assign(u,ft),ft=null,u.arguments&&(At=u.arguments),u.thisProgram&&(jt=u.thisProgram),u.quit&&(Lt=u.quit);var Ht;u.wasmBinary&&(Ht=u.wasmBinary);var Ut,vt,ye=!1,se;function Vr(o,l){o||Re(l)}var be,On,cn,jc,$c,Gc,th,Yc;function fr(){var o=Ut.buffer;u.HEAP8=be=new Int8Array(o),u.HEAP16=cn=new Int16Array(o),u.HEAPU8=On=new Uint8Array(o),u.HEAPU16=jc=new Uint16Array(o),u.HEAP32=$c=new Int32Array(o),u.HEAPU32=Gc=new Uint32Array(o),u.HEAPF32=th=new Float32Array(o),u.HEAPF64=Yc=new Float64Array(o)}var qc=u.INITIAL_MEMORY||16777216;if(U)Ut=u.wasmMemory;else if(u.wasmMemory)Ut=u.wasmMemory;else if(Ut=new WebAssembly.Memory({initial:qc/65536,maximum:65536,shared:!0}),!(Ut.buffer instanceof SharedArrayBuffer))throw pt("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),xt&&pt("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");fr(),qc=Ut.buffer.byteLength;var Kc=[],Jc=[],eh=[],Xc=[],Zc=!1;function rh(){if(u.preRun)for(typeof u.preRun=="function"&&(u.preRun=[u.preRun]);u.preRun.length;)tl(u.preRun.shift());_s(Kc)}function Qc(){Zc=!0,!U&&_s(Jc)}function nh(){U||_s(eh)}function ih(){if(!U){if(u.postRun)for(typeof u.postRun=="function"&&(u.postRun=[u.postRun]);u.postRun.length;)oh(u.postRun.shift());_s(Xc)}}function tl(o){Kc.unshift(o)}function sh(o){Jc.unshift(o)}function oh(o){Xc.unshift(o)}var ln=0,pa=null,ui=null;function el(o){var l;ln++,(l=u.monitorRunDependencies)==null||l.call(u,ln)}function rl(o){var f;if(ln--,(f=u.monitorRunDependencies)==null||f.call(u,ln),ln==0&&(pa!==null&&(clearInterval(pa),pa=null),ui)){var l=ui;ui=null,l()}}function Re(o){var f;(f=u.onAbort)==null||f.call(u,o),o="Aborted("+o+")",pt(o),ye=!0,se=1,o+=". Build with -sASSERTIONS for more info.",Zc&&___trap();var l=new WebAssembly.RuntimeError(o);throw T(l),l}var ah="data:application/octet-stream;base64,",nl=o=>o.startsWith(ah),il=o=>o.startsWith("file://"),Mn;Mn="./duckdb-coi.wasm",nl(Mn)||(Mn=M(Mn));function sl(o){if(o==Mn&&Ht)return new Uint8Array(Ht);if(N)return N(o);throw"both async and sync fetching of the wasm failed"}function ch(o){return!Ht&&(Tt||bt)&&typeof fetch=="function"?fetch(o,{credentials:"same-origin"}).then(l=>{if(!l.ok)throw"failed to load wasm binary file at '".concat(o,"'");return l.arrayBuffer()}).catch(()=>sl(o)):Promise.resolve().then(()=>sl(o))}function ol(o,l,f){return ch(o).then(p=>WebAssembly.instantiate(p,l)).then(f,p=>{pt("failed to asynchronously prepare wasm: ".concat(p)),Re(p)})}function lh(o,l,f,p){return!o&&typeof WebAssembly.instantiateStreaming=="function"&&!nl(l)&&!xt&&typeof fetch=="function"?fetch(l,{credentials:"same-origin"}).then(_=>{var b=WebAssembly.instantiateStreaming(_,f);return b.then(p,function(y){return pt("wasm streaming compile failed: ".concat(y)),pt("falling back to ArrayBuffer instantiation"),ol(l,f,p)})}):ol(l,f,p)}function uh(){var o={a:Bp};function l(p,_){return R=p.exports,R=vm(R),yh(R.Bb),va=R.La,sh(R.Ja),vt=_,rl("wasm-instantiate"),R}el("wasm-instantiate");function f(p){l(p.instance,p.module)}if(u.instantiateWasm)try{return u.instantiateWasm(o,l)}catch(p){pt("Module.instantiateWasm callback failed with error: ".concat(p)),T(p)}return lh(Ht,Mn,o,f).catch(T),{}}var Qt,Un,al={10173248:(o,l,f,p)=>{var _=gt(o);if(typeof XMLHttpRequest>"u")return 0;let b=new XMLHttpRequest;b.open(gt(p),_,!1),b.responseType="arraybuffer";for(var y=0,v=l;y<v*2;){var g=c()[f/4+y>>>0],x=c()[f/4+y+1>>>0];try{var O=encodeURI(gt(g));O==="Host"&&(O="X-Host-Override"),O==="User-Agent"&&(O="X-user-agent"),O==="Authorization"?b.setRequestHeader(O,gt(x)):b.setRequestHeader(O,encodeURI(gt(x)))}catch(kt){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",kt)}y+=2}try{b.send(null)}catch(kt){return 0}if(b.status>=400)return 0;for(var z=b.response,v=z.byteLength,j=hr(v+4),mt=new Uint8Array(z),it=0;it<v;it++)u.HEAPU8[it+j+4]=mt[it];var F=new Uint8Array(4);return F[0]=v%256,v-=F[0],v/=256,F[1]=v%256,v-=F[1],v/=256,F[2]=v%256,v-=F[2],v/=256,F[3]=v%256,v-=F[3],v/=256,u.HEAPU8.set(F,j),j},10174655:(o,l,f,p,_,b)=>{var y=gt(o);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(gt(p),y,!1),g.responseType="arraybuffer";for(var x=0,F=l;x<F*2;){var O=c()[f/4+x>>>0],z=c()[f/4+x+1>>>0];try{var v=encodeURI(gt(O));v==="Host"&&(v="X-Host-Override"),v==="User-Agent"&&(v="X-user-agent"),v==="Authorization"?g.setRequestHeader(v,gt(z)):g.setRequestHeader(v,encodeURI(gt(z)))}catch(V){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",V)}x+=2}try{for(var j=new Uint8Array(b),mt=0;mt<b;mt++)j[mt]=u.HEAPU8[mt+_];g.send(j)}catch(V){return 0}if(g.status>=400)return 0;for(var it=Uint8Array.from(Array.from(g.getResponseHeader("Etag")).map(V=>V.charCodeAt(0))),F=it.byteLength,kt=hr(F+4),ae=new Uint8Array(it),mt=0;mt<F;mt++)u.HEAPU8[mt+kt+4]=ae[mt];var S=new Uint8Array(4);return S[0]=F%256,F-=S[0],F/=256,S[1]=F%256,F-=S[1],F/=256,S[2]=F%256,F-=S[2],F/=256,S[3]=F%256,F-=S[3],F/=256,u.HEAPU8.set(S,kt),kt},10176275:(o,l,f,p)=>{var _=gt(o);if(typeof XMLHttpRequest>"u")return 0;let b=new XMLHttpRequest;b.open(gt(p),_,!1),b.responseType="arraybuffer";for(var y=0,v=l;y<v*2;){var g=c()[f/4+y>>>0],x=c()[f/4+y+1>>>0];console.log("HEAD",gt(g),gt(x));try{var O=encodeURI(gt(g));O==="Host"&&(O="X-Host-Override"),O==="User-Agent"&&(O="X-user-agent"),O==="Authorization"?b.setRequestHeader(O,gt(x)):b.setRequestHeader(O,encodeURI(gt(x)))}catch(S){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",S)}y+=2}try{b.send(null)}catch(S){return 0}if(b.status>=400)return 0;for(var z=b.response,v=z.byteLength,j=hr(v+8),mt=new Uint8Array(z),it=0;it<v;it++)u.HEAPU8[it+j+8]=mt[it];var F=new Uint8Array(4);F[0]=v%256,v-=F[0],v/=256,F[1]=v%256,v-=F[1],v/=256,F[2]=v%256,v-=F[2],v/=256,F[3]=v%256,v-=F[3],v/=256,u.HEAPU8.set(F,j+4);var kt=Uint8Array.from(Array.from(b.getAllResponseHeaders()).map(S=>S.charCodeAt(0)));v=kt.byteLength;for(var ae=hr(v+8),it=0;it<v;it++)u.HEAPU8[it+ae+8]=kt[it];return F=new Uint8Array(4),F[0]=v%256,v-=F[0],v/=256,F[1]=v%256,v-=F[1],v/=256,F[2]=v%256,v-=F[2],v/=256,F[3]=v%256,v-=F[3],v/=256,u.HEAPU8.set(F,ae+4),v=ae,F=new Uint8Array(4),F[0]=v%256,v-=F[0],v/=256,F[1]=v%256,v-=F[1],v/=256,F[2]=v%256,v-=F[2],v/=256,F[3]=v%256,v-=F[3],v/=256,u.HEAPU8.set(F,j),j},10178620:(o,l,f,p)=>{var _=gt(o);if(typeof XMLHttpRequest>"u")return 0;let b=new XMLHttpRequest;b.open(gt(p),_,!1),b.responseType="arraybuffer";for(var y=0,v=l;y<v*2;){var g=c()[f/4+y>>>0],x=c()[f/4+y+1>>>0];try{var O=encodeURI(gt(g));O==="Host"&&(O="X-Host-Override"),O==="User-Agent"&&(O="X-user-agent"),O==="Authorization"?b.setRequestHeader(O,gt(x)):b.setRequestHeader(O,encodeURI(gt(x)))}catch(kt){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",kt)}y+=2}try{b.send(null)}catch(kt){return 0}if(b.status>=400)return 0;for(var z=b.response,v=z.byteLength,j=hr(v+4),mt=new Uint8Array(z),it=0;it<v;it++)u.HEAPU8[it+j+4]=mt[it];var F=new Uint8Array(4);return F[0]=v%256,v-=F[0],v/=256,F[1]=v%256,v-=F[1],v/=256,F[2]=v%256,v-=F[2],v/=256,F[3]=v%256,v-=F[3],v/=256,u.HEAPU8.set(F,j),j},10180027:(o,l,f,p,_,b)=>{var y=gt(o);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(gt(p),y,!1),g.responseType="arraybuffer";for(var x=0,F=l;x<F*2;){var O=c()[f/4+x>>>0],z=c()[f/4+x+1>>>0];try{var v=encodeURI(gt(O));v==="Host"&&(v="X-Host-Override"),v==="User-Agent"&&(v="X-user-agent"),v==="Authorization"?g.setRequestHeader(v,gt(z)):g.setRequestHeader(v,encodeURI(gt(z)))}catch(V){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",V)}x+=2}try{for(var j=new Uint8Array(b),mt=0;mt<b;mt++)j[mt]=u.HEAPU8[mt+_];g.send(j)}catch(V){return 0}if(g.status>=400)return 0;for(var it=g.response,F=it.byteLength,kt=hr(F+4),ae=new Uint8Array(it),mt=0;mt<F;mt++)u.HEAPU8[mt+kt+4]=ae[mt];var S=new Uint8Array(4);return S[0]=F%256,F-=S[0],F/=256,S[1]=F%256,F-=S[1],F/=256,S[2]=F%256,F-=S[2],F/=256,S[3]=F%256,F-=S[3],F/=256,u.HEAPU8.set(S,kt),kt}};function ma(o){this.name="ExitStatus",this.message="Program terminated with exit(".concat(o,")"),this.status=o}var _a=o=>{o.terminate(),o.onmessage=l=>{}},dh=o=>{var l=ct.pthreads[o];delete ct.pthreads[o],_a(l),Ua(o),ct.runningWorkers.splice(ct.runningWorkers.indexOf(l),1),l.pthread_ptr=0},fh=o=>{var l=ct.pthreads[o];l.postMessage({cmd:"cancel"})},cl=o=>{var l=ct.pthreads[o];ct.returnWorkerToPool(l)},ll=(o,l)=>(i().fill(0,o,o+l),o),ul=o=>{var l=ct.getNewWorker();if(!l)return 6;ct.runningWorkers.push(l),ct.pthreads[o.pthread_ptr]=l,l.pthread_ptr=o.pthread_ptr;var f={cmd:"run",start_routine:o.startRoutine,arg:o.arg,pthread_ptr:o.pthread_ptr};return xt&&l.unref(),l.postMessage(f,o.transferList),0},ya=0,ps=()=>pl||ya>0,ba=()=>Mu(),ms=o=>Eu(o),hh=o=>{var l=ba(),f=o();return ms(l),f},di=o=>Ou(o);u.stackAlloc=di;var Wr=(o,l)=>l+2097152>>>0<4194305-!!o?(o>>>0)+l*4294967296:NaN,ut=(o,l,f,...p)=>hh(()=>{for(var _=p.length,b=di(_*8),y=b>>>3,g=0;g<p.length;g++){var x=p[g];h()[y+g>>>0]=x}return Bu(o,l,_,b,f)});function dl(o){var l;if(U)return ut(0,0,1,o);se=o,ps()||(ct.terminateAllThreads(),(l=u.onExit)==null||l.call(u,o),ye=!0),Lt(o,new ma(o))}var fl=(o,l)=>{if(se=o,U)throw hl(o),"unwind";dl(o)},ga=fl,wa=o=>{if(o instanceof ma||o=="unwind")return se;Lt(1,o)},ct={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},init(){U?ct.initWorker():ct.initMainThread()},initMainThread(){for(var o=4;o--;)ct.allocateUnusedWorker();tl(()=>{el("loading-workers"),ct.loadWasmModuleToAllWorkers(()=>rl("loading-workers"))})},initWorker(){pl=!1},setExitStatus:o=>se=o,terminateAllThreads__deps:["$terminateWorker"],terminateAllThreads:()=>{for(var o of ct.runningWorkers)_a(o);for(var o of ct.unusedWorkers)_a(o);ct.unusedWorkers=[],ct.runningWorkers=[],ct.pthreads=[]},returnWorkerToPool:o=>{var l=o.pthread_ptr;delete ct.pthreads[l],ct.unusedWorkers.push(o),ct.runningWorkers.splice(ct.runningWorkers.indexOf(o),1),o.pthread_ptr=0,Ua(l)},receiveObjectTransfer(o){},threadInitTLS(){ct.tlsInitFunctions.forEach(o=>o())},loadWasmModuleToWorker:o=>new Promise(l=>{o.onmessage=b=>{var y=b.data,g=y.cmd;if(y.targetThread&&y.targetThread!=Ss()){var x=ct.pthreads[y.targetThread];x?x.postMessage(y,y.transferList):pt('Internal error! Worker sent a message "'.concat(g,'" to target pthread ').concat(y.targetThread,", but that thread no longer exists!"));return}g==="checkMailbox"?vs():g==="spawnThread"?ul(y):g==="cleanupThread"?cl(y.thread):g==="killThread"?dh(y.thread):g==="cancelThread"?fh(y.thread):g==="loaded"?(o.loaded=!0,xt&&!o.pthread_ptr&&o.unref(),l(o)):g==="alert"?alert("Thread ".concat(y.threadId,": ").concat(y.text)):y.target==="setimmediate"?o.postMessage(y):g==="callHandler"?u[y.handler](...y.args):g&&pt("worker sent an unknown command ".concat(g))},o.onerror=b=>{var y="worker sent an error!";throw pt("".concat(y," ").concat(b.filename,":").concat(b.lineno,": ").concat(b.message)),b},xt&&(o.on("message",b=>o.onmessage({data:b})),o.on("error",b=>o.onerror(b)));var f=[],p=["onExit","onAbort","print","printErr"];for(var _ of p)u.hasOwnProperty(_)&&f.push(_);o.postMessage({cmd:"load",handlers:f,urlOrBlob:u.mainScriptUrlOrBlob||r,wasmMemory:Ut,wasmModule:vt})}),loadWasmModuleToAllWorkers(o){if(U)return o();Promise.all(ct.unusedWorkers.map(ct.loadWasmModuleToWorker)).then(o)},allocateUnusedWorker(){var o,l=M("duckdb_wasm.worker.js");o=new Worker(l),ct.unusedWorkers.push(o)},getNewWorker(){return ct.unusedWorkers.length==0&&(ct.allocateUnusedWorker(),ct.loadWasmModuleToWorker(ct.unusedWorkers[0])),ct.unusedWorkers.pop()}};u.PThread=ct;var _s=o=>{for(;o.length>0;)o.shift()(u)},ph=()=>{var o=Ss(),l=d()[o+52>>>2>>>0],f=d()[o+56>>>2>>>0],p=l-f;xu(l,p),ms(l)};u.establishStackSpace=ph;function hl(o){if(U)return ut(1,0,0,o);ga(o)}var ys=[],va,mh=o=>{var l=ys[o];return l||(o>=ys.length&&(ys.length=o+1),ys[o]=l=va.get(o)),l},_h=(o,l)=>{ya=0;var f=mh(o)(l);function p(_){ps()?ct.setExitStatus(_):Ra(_)}p(f)};u.invokeEntryPoint=_h;var pl=u.noExitRuntime||!0,yh=o=>ct.tlsInitFunctions.push(o);function bh(o){o>>>=0,Du(o,!bt,1,!Tt,1048576,!1),ct.threadInitTLS()}function gh(o){o>>>=0,U?postMessage({cmd:"cleanupThread",thread:o}):cl(o)}function ml(o,l,f,p){return U?ut(2,0,1,o,l,f,p):_l(o,l,f,p)}function _l(o,l,f,p){if(o>>>=0,l>>>=0,f>>>=0,p>>>=0,typeof SharedArrayBuffer>"u")return pt("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var _=[],b=0;if(U&&(_.length===0||b))return ml(o,l,f,p);if(b)return b;var y={startRoutine:f,pthread_ptr:o,arg:p,transferList:_};return U?(y.cmd="spawnThread",postMessage(y,_),0):ul(y)}function yl(){Re("missing function: $SOCKFS")}yl.stub=!0;function Sa(){Re("missing function: $FS")}Sa.stub=!0;var Rn=o=>{var l=yl.getSocket(o);if(!l)throw new Sa.ErrnoError(8);return l},Ia=o=>(o&255)+"."+(o>>8&255)+"."+(o>>16&255)+"."+(o>>24&255),bl=o=>{var l="",f=0,p=0,_=0,b=0,y=0,g=0,x=[o[0]&65535,o[0]>>16,o[1]&65535,o[1]>>16,o[2]&65535,o[2]>>16,o[3]&65535,o[3]>>16],O=!0,z="";for(g=0;g<5;g++)if(x[g]!==0){O=!1;break}if(O){if(z=Ia(x[6]|x[7]<<16),x[5]===-1)return l="::ffff:",l+=z,l;if(x[5]===0)return l="::",z==="0.0.0.0"&&(z=""),z==="0.0.0.1"&&(z="1"),l+=z,l}for(f=0;f<8;f++)x[f]===0&&(f-_>1&&(y=0),_=f,y++),y>p&&(p=y,b=f-p+1);for(f=0;f<8;f++){if(p>1&&x[f]===0&&f>=b&&f<b+p){f===b&&(l+=":",b===0&&(l+=":"));continue}l+=Number(_ntohs(x[f]&65535)).toString(16),l+=f<7?":":""}return l},gl=(o,l)=>{var f=s()[o>>>1>>>0],p=_ntohs(a()[o+2>>>1>>>0]),_;switch(f){case 2:if(l!==16)return{errno:28};_=c()[o+4>>>2>>>0],_=Ia(_);break;case 10:if(l!==28)return{errno:28};_=[c()[o+8>>>2>>>0],c()[o+12>>>2>>>0],c()[o+16>>>2>>>0],c()[o+20>>>2>>>0]],_=bl(_);break;default:return{errno:5}}return{family:f,addr:_,port:p}},bs=o=>{for(var l=o.split("."),f=0;f<4;f++){var p=Number(l[f]);if(isNaN(p))return null;l[f]=p}return(l[0]|l[1]<<8|l[2]<<16|l[3]<<24)>>>0},gs=o=>parseInt(o),Da=o=>{var l,f,p,_,b=/^((?=.*::)(?!.*::.+::)(::)?([\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,y=[];if(!b.test(o))return null;if(o==="::")return[0,0,0,0,0,0,0,0];for(o.startsWith("::")?o=o.replace("::","Z:"):o=o.replace("::",":Z:"),o.indexOf(".")>0?(o=o.replace(new RegExp("[.]","g"),":"),l=o.split(":"),l[l.length-4]=gs(l[l.length-4])+gs(l[l.length-3])*256,l[l.length-3]=gs(l[l.length-2])+gs(l[l.length-1])*256,l=l.slice(0,l.length-2)):l=o.split(":"),p=0,_=0,f=0;f<l.length;f++)if(typeof l[f]=="string")if(l[f]==="Z"){for(_=0;_<8-l.length+1;_++)y[f+_]=0;p=_-1}else y[f+p]=_htons(parseInt(l[f],16));else y[f+p]=l[f];return[y[1]<<16|y[0],y[3]<<16|y[2],y[5]<<16|y[4],y[7]<<16|y[6]]},ge={address_map:{id:1,addrs:{},names:{}},lookup_name(o){var l=bs(o);if(l!==null||(l=Da(o),l!==null))return o;var f;if(ge.address_map.addrs[o])f=ge.address_map.addrs[o];else{var p=ge.address_map.id++;Vr(p<65535,"exceeded max address mappings of 65535"),f="172.29."+(p&255)+"."+(p&65280),ge.address_map.names[f]=o,ge.address_map.addrs[o]=f}return f},lookup_addr(o){return ge.address_map.names[o]?ge.address_map.names[o]:null}},wl=(o,l,f)=>{if(f&&o===0)return null;var p=gl(o,l);if(p.errno)throw new Sa.ErrnoError(p.errno);return p.addr=ge.lookup_addr(p.addr)||p.addr,p};function vl(o,l,f,p,_,b){if(U)return ut(3,0,1,o,l,f,p,_,b);l>>>=0,f>>>=0;var y=Rn(o),g=wl(l,f);return y.sock_ops.bind(y,g.addr,g.port),0}function Sl(o,l,f,p,_,b){if(U)return ut(4,0,1,o,l,f,p,_,b);l>>>=0,f>>>=0;var y=Rn(o),g=wl(l,f);return y.sock_ops.connect(y,g.addr,g.port),0}function Il(o,l,f){if(U)return ut(5,0,1,o,l,f)}function Dl(o,l,f,p){if(U)return ut(6,0,1,o,l,f,p);l>>>=0}var Bl=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Fl=(o,l,f)=>{l>>>=0;for(var p=l+f,_=l;o[_]&&!(_>=p);)++_;if(_-l>16&&o.buffer&&Bl)return Bl.decode(o.buffer instanceof SharedArrayBuffer?o.slice(l,_):o.subarray(l,_));for(var b="";l<_;){var y=o[l++];if(!(y&128)){b+=String.fromCharCode(y);continue}var g=o[l++]&63;if((y&224)==192){b+=String.fromCharCode((y&31)<<6|g);continue}var x=o[l++]&63;if((y&240)==224?y=(y&15)<<12|g<<6|x:y=(y&7)<<18|g<<12|x<<6|o[l++]&63,y<65536)b+=String.fromCharCode(y);else{var O=y-65536;b+=String.fromCharCode(55296|O>>10,56320|O&1023)}}return b},gt=(o,l)=>(o>>>=0,o?Fl(i(),o,l):""),Ba={varargs:void 0,getStr(o){var l=gt(o);return l}};function Al(o,l,f){return U?ut(7,0,1,o,l,f):(f>>>=0,Ba.varargs=f,0)}function Tl(o,l){if(U)return ut(8,0,1,o,l);l>>>=0}function xl(o,l,f){if(U)return ut(9,0,1,o,l,f);var p=Wr(l,f)}var Fa=o=>{for(var l=0,f=0;f<o.length;++f){var p=o.charCodeAt(f);p<=127?l++:p<=2047?l+=2:p>=55296&&p<=57343?(l+=4,++f):l+=3}return l};u.lengthBytesUTF8=Fa;var El=(o,l,f,p)=>{if(f>>>=0,!(p>0))return 0;for(var _=f,b=f+p-1,y=0;y<o.length;++y){var g=o.charCodeAt(y);if(g>=55296&&g<=57343){var x=o.charCodeAt(++y);g=65536+((g&1023)<<10)|x&1023}if(g<=127){if(f>=b)break;l[f++>>>0]=g}else if(g<=2047){if(f+1>=b)break;l[f++>>>0]=192|g>>6,l[f++>>>0]=128|g&63}else if(g<=65535){if(f+2>=b)break;l[f++>>>0]=224|g>>12,l[f++>>>0]=128|g>>6&63,l[f++>>>0]=128|g&63}else{if(f+3>=b)break;l[f++>>>0]=240|g>>18,l[f++>>>0]=128|g>>12&63,l[f++>>>0]=128|g>>6&63,l[f++>>>0]=128|g&63}}return l[f>>>0]=0,f-_},zr=(o,l,f)=>El(o,i(),l,f);u.stringToUTF8=zr;function Ol(o,l){if(U)return ut(10,0,1,o,l);o>>>=0,l>>>=0}function Ml(o,l,f){if(U)return ut(11,0,1,o,l,f);l>>>=0,f>>>=0}var ws=(o,l,f,p,_)=>{switch(l){case 2:f=bs(f),ll(o,16),_&&(c()[_>>>2>>>0]=16),s()[o>>>1>>>0]=l,c()[o+4>>>2>>>0]=f,s()[o+2>>>1>>>0]=_htons(p);break;case 10:f=Da(f),ll(o,28),_&&(c()[_>>>2>>>0]=28),c()[o>>>2>>>0]=l,c()[o+8>>>2>>>0]=f[0],c()[o+12>>>2>>>0]=f[1],c()[o+16>>>2>>>0]=f[2],c()[o+20>>>2>>>0]=f[3],s()[o+2>>>1>>>0]=_htons(p);break;default:return 5}return 0};function Ul(o,l,f,p,_,b){if(U)return ut(12,0,1,o,l,f,p,_,b);l>>>=0,f>>>=0;var y=Rn(o);if(!y.daddr)return-53;var g=ws(l,y.family,ge.lookup_name(y.daddr),y.dport,f);return 0}function Rl(o,l,f,p,_,b){if(U)return ut(13,0,1,o,l,f,p,_,b);l>>>=0,f>>>=0;var y=Rn(o),g=ws(l,y.family,ge.lookup_name(y.saddr||"0.0.0.0"),y.sport,f);return 0}function Ll(o,l,f,p,_,b){if(U)return ut(14,0,1,o,l,f,p,_,b);p>>>=0,_>>>=0;var y=Rn(o);return l===1&&f===4?(c()[p>>>2>>>0]=y.error,c()[_>>>2>>>0]=4,y.error=null,0):-50}function kl(o,l,f){return U?ut(15,0,1,o,l,f):(f>>>=0,Ba.varargs=f,0)}function Nl(o,l){if(U)return ut(16,0,1,o,l);o>>>=0,l>>>=0}function Cl(o,l,f){if(U)return ut(17,0,1,o,l,f);l>>>=0}function Pl(o,l,f,p){if(U)return ut(18,0,1,o,l,f,p);l>>>=0,f>>>=0}function Hl(o,l,f,p){if(U)return ut(19,0,1,o,l,f,p);l>>>=0,p>>>=0,Ba.varargs=p}function Vl(o,l,f){if(U)return ut(20,0,1,o,l,f);o>>>=0}function Wl(o,l,f,p){if(U)return ut(21,0,1,o,l,f,p);l>>>=0,f>>>=0,p>>>=0}function zl(o,l,f,p,_,b){if(U)return ut(22,0,1,o,l,f,p,_,b);l>>>=0,f>>>=0,_>>>=0,b>>>=0;var y=Rn(o),g=y.sock_ops.recvmsg(y,f);if(!g)return 0;if(_)var x=ws(_,y.family,ge.lookup_name(g.addr),g.port,b);return i().set(g.buffer,l>>>0),g.buffer.byteLength}function jl(o,l,f,p){if(U)return ut(23,0,1,o,l,f,p);l>>>=0,p>>>=0}function $l(o){if(U)return ut(24,0,1,o);o>>>=0}function Gl(o,l,f,p,_,b){if(U)return ut(25,0,1,o,l,f,p,_,b);l>>>=0,f>>>=0,_>>>=0,b>>>=0}function Yl(o,l,f){if(U)return ut(26,0,1,o,l,f)}function ql(o,l){if(U)return ut(27,0,1,o,l);o>>>=0,l>>>=0}function Kl(o,l,f){if(U)return ut(28,0,1,o,l,f);o>>>=0,l>>>=0,f>>>=0}function Jl(o,l,f){if(U)return ut(29,0,1,o,l,f);l>>>=0}var wh=1,vh=()=>wh,Sh=()=>{if(!ps())try{U?Ra(se):ga(se)}catch(o){wa(o)}},Ih=o=>{if(!ye)try{o(),Sh()}catch(l){wa(l)}};function Aa(o){if(o>>>=0,typeof Atomics.waitAsync=="function"){var l=Atomics.waitAsync(c(),o>>>2,o);l.value.then(vs);var f=o+128;Atomics.store(c(),f>>>2,1)}}u.__emscripten_thread_mailbox_await=Aa;var vs=()=>{var o=Ss();o&&(Aa(o),Ih(Fu))};u.checkMailbox=vs;function Dh(o,l,f){if(o>>>=0,l>>>=0,f>>>=0,o==l)setTimeout(vs);else if(U)postMessage({targetThread:o,cmd:"checkMailbox"});else{var p=ct.pthreads[o];if(!p)return;p.postMessage({cmd:"checkMailbox"})}}var Ta=[];function Bh(o,l,f,p,_){l>>>=0,f>>>=0,_>>>=0,Ta.length=p;for(var b=_>>>3,y=0;y<p;y++)Ta[y]=h()[b+y>>>0];var g=l?al[l]:Dp[o];ct.currentProxiedOperationCallerThread=f;var x=g(...Ta);return ct.currentProxiedOperationCallerThread=0,x}function Fh(o){if(o>>>=0,xt){if(!o)return 1;var l=gt(o);if(!l.length)return 0;var f=["child_process"].map(ka),p=f.spawnSync(l,[],{shell:!0,stdio:"inherit"}),_=(y,g)=>y<<8|g;if(p.status===null){var b=y=>{switch(y){case"SIGHUP":return 1;case"SIGINT":return 2;case"SIGQUIT":return 3;case"SIGFPE":return 8;case"SIGKILL":return 9;case"SIGALRM":return 14;case"SIGTERM":return 15}return 2};return _(0,b(p.signal))}return _(p.status,0)}return o?-52:0}function Ah(o){o>>>=0,xt&&ct.pthreads[o].ref()}function Xl(){Re("missing function: _emval_call_method")}Xl.stub=!0;function Zl(){Re("missing function: _emval_decref")}Zl.stub=!0;function Ql(){Re("missing function: _emval_get_global")}Ql.stub=!0;function tu(){Re("missing function: _emval_get_method_caller")}tu.stub=!0;function eu(){Re("missing function: _emval_run_destructors")}eu.stub=!0;function Th(o,l,f){var p=Wr(o,l);f>>>=0;var _=new Date(p*1e3);c()[f>>>2>>>0]=_.getUTCSeconds(),c()[f+4>>>2>>>0]=_.getUTCMinutes(),c()[f+8>>>2>>>0]=_.getUTCHours(),c()[f+12>>>2>>>0]=_.getUTCDate(),c()[f+16>>>2>>>0]=_.getUTCMonth(),c()[f+20>>>2>>>0]=_.getUTCFullYear()-1900,c()[f+24>>>2>>>0]=_.getUTCDay();var b=Date.UTC(_.getUTCFullYear(),0,1,0,0,0,0),y=(_.getTime()-b)/(1e3*60*60*24)|0;c()[f+28>>>2>>>0]=y}var fi=o=>o%4===0&&(o%100!==0||o%400===0),xh=[0,31,60,91,121,152,182,213,244,274,305,335],Eh=[0,31,59,90,120,151,181,212,243,273,304,334],ru=o=>{var l=fi(o.getFullYear()),f=l?xh:Eh,p=f[o.getMonth()]+o.getDate()-1;return p};function Oh(o,l,f){var p=Wr(o,l);f>>>=0;var _=new Date(p*1e3);c()[f>>>2>>>0]=_.getSeconds(),c()[f+4>>>2>>>0]=_.getMinutes(),c()[f+8>>>2>>>0]=_.getHours(),c()[f+12>>>2>>>0]=_.getDate(),c()[f+16>>>2>>>0]=_.getMonth(),c()[f+20>>>2>>>0]=_.getFullYear()-1900,c()[f+24>>>2>>>0]=_.getDay();var b=ru(_)|0;c()[f+28>>>2>>>0]=b,c()[f+36>>>2>>>0]=-(_.getTimezoneOffset()*60);var y=new Date(_.getFullYear(),0,1),g=new Date(_.getFullYear(),6,1).getTimezoneOffset(),x=y.getTimezoneOffset(),O=(g!=x&&_.getTimezoneOffset()==Math.min(x,g))|0;c()[f+32>>>2>>>0]=O}var xa=o=>Au(o),Mh=function(o){o>>>=0;var l=(()=>{var f=new Date(c()[o+20>>>2>>>0]+1900,c()[o+16>>>2>>>0],c()[o+12>>>2>>>0],c()[o+8>>>2>>>0],c()[o+4>>>2>>>0],c()[o>>>2>>>0],0),p=c()[o+32>>>2>>>0],_=f.getTimezoneOffset(),b=new Date(f.getFullYear(),0,1),y=new Date(f.getFullYear(),6,1).getTimezoneOffset(),g=b.getTimezoneOffset(),x=Math.min(g,y);if(p<0)c()[o+32>>>2>>>0]=+(y!=g&&x==_);else if(p>0!=(x==_)){var O=Math.max(g,y),z=p>0?x:O;f.setTime(f.getTime()+(z-_)*6e4)}c()[o+24>>>2>>>0]=f.getDay();var v=ru(f)|0;c()[o+28>>>2>>>0]=v,c()[o>>>2>>>0]=f.getSeconds(),c()[o+4>>>2>>>0]=f.getMinutes(),c()[o+8>>>2>>>0]=f.getHours(),c()[o+12>>>2>>>0]=f.getDate(),c()[o+16>>>2>>>0]=f.getMonth(),c()[o+20>>>2>>>0]=f.getYear();var j=f.getTime();return isNaN(j)?-1:j/1e3})();return xa((Qt=l,+Math.abs(Qt)>=1?Qt>0?+Math.floor(Qt/4294967296)>>>0:~~+Math.ceil((Qt-+(~~Qt>>>0))/4294967296)>>>0:0)),l>>>0};function nu(o,l,f,p,_,b,y,g){if(U)return ut(30,0,1,o,l,f,p,_,b,y,g);o>>>=0;var x=Wr(_,b);return y>>>=0,g>>>=0,-52}function iu(o,l,f,p,_,b,y){if(U)return ut(31,0,1,o,l,f,p,_,b,y);o>>>=0,l>>>=0;var g=Wr(b,y)}var Uh=function(o,l,f,p){o>>>=0,l>>>=0,f>>>=0,p>>>=0;var _=new Date().getFullYear(),b=new Date(_,0,1),y=new Date(_,6,1),g=b.getTimezoneOffset(),x=y.getTimezoneOffset(),O=Math.max(g,x);d()[o>>>2>>>0]=O*60,c()[l>>>2>>>0]=+(g!=x);var z=mt=>mt.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1],v=z(b),j=z(y);x<g?(zr(v,f,17),zr(j,p,17)):(zr(v,p,17),zr(j,f,17))},Rh=()=>{Re("")};function Lh(o,l){return o>>>=0,globalThis.DUCKDB_RUNTIME.createDirectory(u,o,l)}function kh(o,l){return o>>>=0,globalThis.DUCKDB_RUNTIME.checkDirectory(u,o,l)}function Nh(o,l){return o>>>=0,globalThis.DUCKDB_RUNTIME.listDirectoryEntries(u,o,l)}function Ch(o,l){return o>>>=0,globalThis.DUCKDB_RUNTIME.removeDirectory(u,o,l)}function Ph(o){return globalThis.DUCKDB_RUNTIME.closeFile(u,o)}function Hh(o,l){return o>>>=0,globalThis.DUCKDB_RUNTIME.dropFile(u,o,l)}function Vh(o,l){return o>>>=0,globalThis.DUCKDB_RUNTIME.checkFile(u,o,l)}function Wh(o,l,f,p){return o>>>=0,f>>>=0,globalThis.DUCKDB_RUNTIME.moveFile(u,o,l,f,p)}function zh(o,l){return globalThis.DUCKDB_RUNTIME.openFile(u,o,l)}function jh(o,l,f,p){return l>>>=0,globalThis.DUCKDB_RUNTIME.readFile(u,o,l,f,p)}function $h(o,l){return globalThis.DUCKDB_RUNTIME.truncateFile(u,o,l)}function Gh(o,l,f,p){return l>>>=0,globalThis.DUCKDB_RUNTIME.writeFile(u,o,l,f,p)}function Yh(o){return globalThis.DUCKDB_RUNTIME.getDefaultDataProtocol(o)}function qh(o,l){return o>>>=0,globalThis.DUCKDB_RUNTIME.glob(u,o,l)}function Kh(o){return globalThis.DUCKDB_RUNTIME.testPlatformFeature(u,o)}function Jh(o,l,f,p,_,b){return o>>>=0,f>>>=0,_>>>=0,globalThis.DUCKDB_RUNTIME.callScalarUDF(u,o,l,f,p,_,b)}var Ea=[],Xh=(o,l)=>{Ea.length=0;for(var f;f=i()[o++>>>0];){var p=f!=105;p&=f!=112,l+=p&&l%8?4:0,Ea.push(f==112?d()[l>>>2>>>0]:f==105?c()[l>>>2>>>0]:h()[l>>>3>>>0]),l+=p?8:4}return Ea},Zh=(o,l,f)=>{var p=Xh(l,f);return al[o](...p)};function Qh(o,l,f){return o>>>=0,l>>>=0,f>>>=0,Zh(o,l,f)}var hi=o=>{hi.shown||(hi.shown={}),hi.shown[o]||(hi.shown[o]=1,xt&&(o="warning: "+o),pt(o))},tp=()=>{},ep=()=>Date.now(),rp=()=>{ya+=1},np=()=>{throw rp(),"unwind"},su=()=>4294901760;function ip(){return su()}var ou;ou=()=>performance.timeOrigin+performance.now();var sp=()=>xt?Vf().cpus().length:navigator.hardwareConcurrency,op=o=>{var l=Ut.buffer,f=(o-l.byteLength+65535)/65536;try{return Ut.grow(f),fr(),1}catch(p){}};function ap(o){o>>>=0;var l=i().length;if(o<=l)return!1;var f=su();if(o>f)return!1;for(var p=(x,O)=>x+(O-x%O)%O,_=1;_<=4;_*=2){var b=l*(1+.2/_);b=Math.min(b,o+100663296);var y=Math.min(f,p(Math.max(o,b),65536)),g=op(y);if(g)return!0}return!1}var Oa={},cp=()=>jt||"./this.program",pi=()=>{if(!pi.strings){var o=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",l={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:o,_:cp()};for(var f in Oa)Oa[f]===void 0?delete l[f]:l[f]=Oa[f];var p=[];for(var f in l)p.push("".concat(f,"=").concat(l[f]));pi.strings=p}return pi.strings},lp=(o,l)=>{for(var f=0;f<o.length;++f)n()[l++>>>0]=o.charCodeAt(f);n()[l>>>0]=0},au=function(o,l){if(U)return ut(32,0,1,o,l);o>>>=0,l>>>=0;var f=0;return pi().forEach((p,_)=>{var b=l+f;d()[o+_*4>>>2>>>0]=b,lp(p,b),f+=p.length+1}),0},cu=function(o,l){if(U)return ut(33,0,1,o,l);o>>>=0,l>>>=0;var f=pi();d()[o>>>2>>>0]=f.length;var p=0;return f.forEach(_=>p+=_.length+1),d()[l>>>2>>>0]=p,0};function lu(o){return U?ut(34,0,1,o):52}function uu(o,l){if(U)return ut(35,0,1,o,l);l>>>=0;var f=0,p=0,_=0;{var b=2;o==0?f=2:(o==1||o==2)&&(f=64),_=1}return n()[l>>>0]=b,s()[l+2>>>1>>>0]=_,Un=[f>>>0,(Qt=f,+Math.abs(Qt)>=1?Qt>0?+Math.floor(Qt/4294967296)>>>0:~~+Math.ceil((Qt-+(~~Qt>>>0))/4294967296)>>>0:0)],c()[l+8>>>2>>>0]=Un[0],c()[l+12>>>2>>>0]=Un[1],Un=[p>>>0,(Qt=p,+Math.abs(Qt)>=1?Qt>0?+Math.floor(Qt/4294967296)>>>0:~~+Math.ceil((Qt-+(~~Qt>>>0))/4294967296)>>>0:0)],c()[l+16>>>2>>>0]=Un[0],c()[l+20>>>2>>>0]=Un[1],0}function du(o,l,f,p,_,b){if(U)return ut(36,0,1,o,l,f,p,_,b);l>>>=0,f>>>=0;var y=Wr(p,_);return b>>>=0,52}function fu(o,l,f,p,_,b){if(U)return ut(37,0,1,o,l,f,p,_,b);l>>>=0,f>>>=0;var y=Wr(p,_);return b>>>=0,52}function hu(o,l,f,p){return U?ut(38,0,1,o,l,f,p):(l>>>=0,f>>>=0,p>>>=0,52)}function pu(o,l,f,p,_){if(U)return ut(39,0,1,o,l,f,p,_);var b=Wr(l,f);return _>>>=0,70}function mu(o){return U?ut(40,0,1,o):52}var up=[null,[],[]],dp=(o,l)=>{var f=up[o];l===0||l===10?((o===1?Q:pt)(Fl(f,0)),f.length=0):f.push(l)};function _u(o,l,f,p){if(U)return ut(41,0,1,o,l,f,p);l>>>=0,f>>>=0,p>>>=0;for(var _=0,b=0;b<f;b++){var y=d()[l>>>2>>>0],g=d()[l+4>>>2>>>0];l+=8;for(var x=0;x<g;x++)dp(o,i()[y+x>>>0]);_+=g}return d()[p>>>2>>>0]=_,0}function yu(o,l,f,p){if(U)return ut(42,0,1,o,l,f,p);o>>>=0,l>>>=0,f>>>=0,p>>>=0;var _=0,b=0,y=0,g=0,x=0,O=0,z;function v(j,mt,it,F,kt,ae){var S,V,Wt,te;return V=j===10?28:16,kt=j===10?bl(kt):Ia(kt),S=hr(V),te=ws(S,j,kt,ae),Vr(!te),Wt=hr(32),c()[Wt+4>>>2>>>0]=j,c()[Wt+8>>>2>>>0]=mt,c()[Wt+12>>>2>>>0]=it,d()[Wt+24>>>2>>>0]=F,d()[Wt+20>>>2>>>0]=S,j===10?c()[Wt+16>>>2>>>0]=28:c()[Wt+16>>>2>>>0]=16,c()[Wt+28>>>2>>>0]=0,Wt}if(f&&(y=c()[f>>>2>>>0],g=c()[f+4>>>2>>>0],x=c()[f+8>>>2>>>0],O=c()[f+12>>>2>>>0]),x&&!O&&(O=x===2?17:6),!x&&O&&(x=O===17?2:1),O===0&&(O=6),x===0&&(x=1),!o&&!l)return-2;if(y&-1088||f!==0&&c()[f>>>2>>>0]&2&&!o)return-1;if(y&32)return-2;if(x!==0&&x!==1&&x!==2)return-7;if(g!==0&&g!==2&&g!==10)return-6;if(l&&(l=gt(l),b=parseInt(l,10),isNaN(b)))return y&1024?-2:-8;if(!o)return g===0&&(g=2),y&1||(g===2?_=_htonl(2130706433):_=[0,0,0,1]),z=v(g,x,O,null,_,b),d()[p>>>2>>>0]=z,0;if(o=gt(o),_=bs(o),_!==null)if(g===0||g===2)g=2;else if(g===10&&y&8)_=[0,0,_htonl(65535),_],g=10;else return-2;else if(_=Da(o),_!==null)if(g===0||g===10)g=10;else return-2;return _!=null?(z=v(g,x,O,o,_,b),d()[p>>>2>>>0]=z,0):y&4?-2:(o=ge.lookup_name(o),_=bs(o),g===0?g=2:g===10&&(_=[0,0,_htonl(65535),_]),z=v(g,x,O,null,_,b),d()[p>>>2>>>0]=z,0)}var fp=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return p=>(p.set(crypto.getRandomValues(new Uint8Array(p.byteLength))),p);if(xt)try{var o=ka("crypto"),l=o.randomFillSync;if(l)return p=>o.randomFillSync(p);var f=o.randomBytes;return p=>(p.set(f(p.byteLength)),p)}catch(p){}Re("initRandomDevice")},bu=o=>(bu=fp())(o);function hp(o,l){return o>>>=0,l>>>=0,bu(i().subarray(o>>>0,o+l>>>0)),0}function pp(o,l,f,p,_,b,y){o>>>=0,f>>>=0,_>>>=0;var g=gl(o,l);if(g.errno)return-6;var x=g.port,O=g.addr,z=!1;if(f&&p){var v;if(y&1||!(v=ge.lookup_addr(O))){if(y&8)return-2}else O=v;var j=zr(O,f,p);j+1>=p&&(z=!0)}if(_&&b){x=""+x;var j=zr(x,_,b);j+1>=b&&(z=!0)}return z?-12:0}var mp=(o,l)=>{for(var f=0,p=0;p<=l;f+=o[p++]);return f},gu=[31,29,31,30,31,30,31,31,30,31,30,31],wu=[31,28,31,30,31,30,31,31,30,31,30,31],_p=(o,l)=>{for(var f=new Date(o.getTime());l>0;){var p=fi(f.getFullYear()),_=f.getMonth(),b=(p?gu:wu)[_];if(l>b-f.getDate())l-=b-f.getDate()+1,f.setDate(1),_<11?f.setMonth(_+1):(f.setMonth(0),f.setFullYear(f.getFullYear()+1));else return f.setDate(f.getDate()+l),f}return f};function yp(o,l,f){var p=f>0?f:Fa(o)+1,_=new Array(p),b=El(o,_,0,_.length);return l&&(_.length=b),_}var vu=(o,l)=>{n().set(o,l>>>0)};function Su(o,l,f,p){o>>>=0,l>>>=0,f>>>=0,p>>>=0;var _=d()[p+40>>>2>>>0],b={tm_sec:c()[p>>>2>>>0],tm_min:c()[p+4>>>2>>>0],tm_hour:c()[p+8>>>2>>>0],tm_mday:c()[p+12>>>2>>>0],tm_mon:c()[p+16>>>2>>>0],tm_year:c()[p+20>>>2>>>0],tm_wday:c()[p+24>>>2>>>0],tm_yday:c()[p+28>>>2>>>0],tm_isdst:c()[p+32>>>2>>>0],tm_gmtoff:c()[p+36>>>2>>>0],tm_zone:_?gt(_):""},y=gt(f),g={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var x in g)y=y.replace(new RegExp(x,"g"),g[x]);var O=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],z=["January","February","March","April","May","June","July","August","September","October","November","December"];function v(S,V,Wt){for(var te=typeof S=="number"?S.toString():S||"";te.length<V;)te=Wt[0]+te;return te}function j(S,V){return v(S,V,"0")}function mt(S,V){function Wt(Ds){return Ds<0?-1:Ds>0?1:0}var te;return(te=Wt(S.getFullYear()-V.getFullYear()))===0&&(te=Wt(S.getMonth()-V.getMonth()))===0&&(te=Wt(S.getDate()-V.getDate())),te}function it(S){switch(S.getDay()){case 0:return new Date(S.getFullYear()-1,11,29);case 1:return S;case 2:return new Date(S.getFullYear(),0,3);case 3:return new Date(S.getFullYear(),0,2);case 4:return new Date(S.getFullYear(),0,1);case 5:return new Date(S.getFullYear()-1,11,31);case 6:return new Date(S.getFullYear()-1,11,30)}}function F(S){var V=_p(new Date(S.tm_year+1900,0,1),S.tm_yday),Wt=new Date(V.getFullYear(),0,4),te=new Date(V.getFullYear()+1,0,4),Ds=it(Wt),Im=it(te);return mt(Ds,V)<=0?mt(Im,V)<=0?V.getFullYear()+1:V.getFullYear():V.getFullYear()-1}var kt={"%a":S=>O[S.tm_wday].substring(0,3),"%A":S=>O[S.tm_wday],"%b":S=>z[S.tm_mon].substring(0,3),"%B":S=>z[S.tm_mon],"%C":S=>{var V=S.tm_year+1900;return j(V/100|0,2)},"%d":S=>j(S.tm_mday,2),"%e":S=>v(S.tm_mday,2," "),"%g":S=>F(S).toString().substring(2),"%G":F,"%H":S=>j(S.tm_hour,2),"%I":S=>{var V=S.tm_hour;return V==0?V=12:V>12&&(V-=12),j(V,2)},"%j":S=>j(S.tm_mday+mp(fi(S.tm_year+1900)?gu:wu,S.tm_mon-1),3),"%m":S=>j(S.tm_mon+1,2),"%M":S=>j(S.tm_min,2),"%n":()=>"\n","%p":S=>S.tm_hour>=0&&S.tm_hour<12?"AM":"PM","%S":S=>j(S.tm_sec,2),"%t":()=>" ","%u":S=>S.tm_wday||7,"%U":S=>{var V=S.tm_yday+7-S.tm_wday;return j(Math.floor(V/7),2)},"%V":S=>{var V=Math.floor((S.tm_yday+7-(S.tm_wday+6)%7)/7);if((S.tm_wday+371-S.tm_yday-2)%7<=2&&V++,V){if(V==53){var te=(S.tm_wday+371-S.tm_yday)%7;te!=4&&(te!=3||!fi(S.tm_year))&&(V=1)}}else{V=52;var Wt=(S.tm_wday+7-S.tm_yday-1)%7;(Wt==4||Wt==5&&fi(S.tm_year%400-1))&&V++}return j(V,2)},"%w":S=>S.tm_wday,"%W":S=>{var V=S.tm_yday+7-(S.tm_wday+6)%7;return j(Math.floor(V/7),2)},"%y":S=>(S.tm_year+1900).toString().substring(2),"%Y":S=>S.tm_year+1900,"%z":S=>{var V=S.tm_gmtoff,Wt=V>=0;return V=Math.abs(V)/60,V=V/60*100+V%60,(Wt?"+":"-")+("0000"+V).slice(-4)},"%Z":S=>S.tm_zone,"%%":()=>"%"};y=y.replace(/%%/g,"\0\0");for(var x in kt)y.includes(x)&&(y=y.replace(new RegExp(x,"g"),kt[x](b)));y=y.replace(/\0\0/g,"%");var ae=yp(y,!1);return ae.length>l?0:(vu(ae,o),ae.length-1)}function bp(o,l,f,p,_){return o>>>=0,l>>>=0,f>>>=0,p>>>=0,_>>>=0,Su(o,l,f,p)}var gp=o=>{var l=u["_"+o];return l},wp=o=>{var l=Fa(o)+1,f=di(l);return zr(o,f,l),f},vp=(o,l,f,p,_)=>{var b={string:it=>{var F=0;return it!=null&&it!==0&&(F=wp(it)),F},array:it=>{var F=di(it.length);return vu(it,F),F}};function y(it){return l==="string"?gt(it):l==="boolean"?!!it:it}var g=gp(o),x=[],O=0;if(p)for(var z=0;z<p.length;z++){var v=b[f[z]];v?(O===0&&(O=ba()),x[z]=v(p[z])):x[z]=p[z]}var j=g(...x);function mt(it){return O!==0&&ms(O),y(it)}return j=mt(j),j},Ln=(o,l)=>{o<128?l.push(o):l.push(o%128|128,o>>7)},Ma=(o,l)=>{var f=o.slice(0,1),p=o.slice(1),_={i:127,p:127,j:126,f:125,d:124,e:111};l.push(96),Ln(p.length,l);for(var b=0;b<p.length;++b)l.push(_[p[b]]);f=="v"?l.push(0):l.push(1,_[f])},Sp=o=>{var l=[],f=[0,97,115,109,1,0,0,0];l.push(f);var p=[o[0].replace("j","i"),"i",o.slice(1).replace(/j/g,"ii")].join(""),_=[3];Ma(p,_),Ma(o,_),Ma("vi",_);var b=[1];Ln(_.length,b),b.push(..._),l.push(b);var y=[2,15,2,1,101,1,116,1,112,0,0,1,101,1,114,0,2];l.push(y);var g=[3,2,1,0];l.push(g);var x=[7,5,1,1,102,0,1];l.push(x);var O=[];o[0]==="j"?O=[1,1,126]:O.push(0);function z(V){O.push(32),Ln(V,O)}for(var v=1,j=1;j<o.length;j++)o[j]=="j"?(z(v+1),O.push(173,66,32,134),z(v),O.push(172,132),v+=2):(z(v),v++);O.push(32,0,17,1,0),o[0]==="j"&&(O.push(34),Ln(v,O),O.push(66,32,136,167,16,0),z(v),O.push(167)),O.push(11);var mt=[1];Ln(O.length,mt),mt.push(...O);var it=[10];Ln(mt.length,it),it.push(...mt),l.push(it);var F=new Uint8Array([].concat.apply([],l)),kt=new WebAssembly.Module(F),ae=new WebAssembly.Instance(kt,{e:{t:va,r:xa}}),S=ae.exports.f;return S},Ip=o=>Tu();ct.init();var Dp=[dl,hl,ml,vl,Sl,Il,Dl,Al,Tl,xl,Ol,Ml,Ul,Rl,Ll,kl,Nl,Cl,Pl,Hl,Vl,Wl,zl,jl,$l,Gl,Yl,ql,Kl,Jl,nu,iu,au,cu,lu,uu,du,fu,hu,pu,mu,_u,yu],Bp={$:bh,y:gh,Ba:_l,ua:vl,Aa:Sl,R:Il,oa:Dl,e:Al,na:Tl,B:xl,pa:Ol,ia:Ml,ta:Ul,sa:Rl,xa:Ll,m:kl,ka:Nl,ja:Cl,la:Pl,n:Hl,ya:Vl,s:Wl,va:zl,fa:jl,t:$l,wa:Gl,x:Yl,ma:ql,qa:Kl,l:Jl,Ia:vh,za:Dh,ha:Bh,P:Fh,S:Aa,J:Ah,M:Xl,p:Zl,O:Ql,N:tu,L:eu,E:Th,F:Oh,G:Mh,H:nu,I:iu,ra:Uh,b:Rh,Y:Lh,Z:kh,W:Nh,X:Ch,r:Ph,ba:Hh,U:Vh,V:Wh,aa:zh,j:jh,_:$h,k:Gh,ca:Yh,T:qh,q:Kh,da:Jh,h:Qh,u:tp,i:ep,A:np,Ca:ip,f:ou,Da:sp,Ha:ap,Ea:au,Fa:cu,c:ga,g:lu,Ga:uu,D:du,C:fu,z:hu,K:pu,ga:mu,o:_u,w:yu,ea:hp,v:pp,a:Ut||u.wasmMemory,Q:Su,d:bp},R=uh(),Iu=u._main=(o,l)=>(Iu=u._main=R.Ka)(o,l),Fp=u._duckdb_web_fs_glob_add_path=o=>(Fp=u._duckdb_web_fs_glob_add_path=R.Ma)(o),Ap=u._duckdb_web_clear_response=()=>(Ap=u._duckdb_web_clear_response=R.Na)(),Tp=u._duckdb_web_fail_with=o=>(Tp=u._duckdb_web_fail_with=R.Oa)(o),xp=u._duckdb_web_reset=o=>(xp=u._duckdb_web_reset=R.Pa)(o),Ep=u._duckdb_web_connect=()=>(Ep=u._duckdb_web_connect=R.Qa)(),Op=u._duckdb_web_disconnect=o=>(Op=u._duckdb_web_disconnect=R.Ra)(o),Mp=u._duckdb_web_flush_files=()=>(Mp=u._duckdb_web_flush_files=R.Sa)(),Up=u._duckdb_web_flush_file=o=>(Up=u._duckdb_web_flush_file=R.Ta)(o),Rp=u._duckdb_web_open=(o,l)=>(Rp=u._duckdb_web_open=R.Ua)(o,l),Lp=u._duckdb_web_get_global_file_info=(o,l)=>(Lp=u._duckdb_web_get_global_file_info=R.Va)(o,l),kp=u._duckdb_web_collect_file_stats=(o,l,f)=>(kp=u._duckdb_web_collect_file_stats=R.Wa)(o,l,f),Np=u._duckdb_web_export_file_stats=(o,l)=>(Np=u._duckdb_web_export_file_stats=R.Xa)(o,l),Cp=u._duckdb_web_fs_drop_file=(o,l)=>(Cp=u._duckdb_web_fs_drop_file=R.Ya)(o,l),Pp=u._duckdb_web_fs_drop_files=(o,l,f)=>(Pp=u._duckdb_web_fs_drop_files=R.Za)(o,l,f),Hp=u._duckdb_web_fs_glob_file_infos=(o,l)=>(Hp=u._duckdb_web_fs_glob_file_infos=R._a)(o,l),Vp=u._duckdb_web_fs_get_file_info_by_id=(o,l,f)=>(Vp=u._duckdb_web_fs_get_file_info_by_id=R.$a)(o,l,f),Wp=u._duckdb_web_fs_get_file_info_by_name=(o,l,f)=>(Wp=u._duckdb_web_fs_get_file_info_by_name=R.ab)(o,l,f),zp=u._duckdb_web_fs_register_file_url=(o,l,f,p,_)=>(zp=u._duckdb_web_fs_register_file_url=R.bb)(o,l,f,p,_),jp=u._duckdb_web_fs_register_file_buffer=(o,l,f,p)=>(jp=u._duckdb_web_fs_register_file_buffer=R.cb)(o,l,f,p),$p=u._duckdb_web_copy_file_to_buffer=(o,l)=>($p=u._duckdb_web_copy_file_to_buffer=R.db)(o,l),Gp=u._duckdb_web_copy_file_to_path=(o,l,f)=>(Gp=u._duckdb_web_copy_file_to_path=R.eb)(o,l,f),Yp=u._duckdb_web_get_version=o=>(Yp=u._duckdb_web_get_version=R.fb)(o),qp=u._duckdb_web_get_feature_flags=()=>(qp=u._duckdb_web_get_feature_flags=R.gb)(),Kp=u._duckdb_web_tokenize=(o,l)=>(Kp=u._duckdb_web_tokenize=R.hb)(o,l),Jp=u._duckdb_web_tokenize_buffer=(o,l,f)=>(Jp=u._duckdb_web_tokenize_buffer=R.ib)(o,l,f),Xp=u._duckdb_web_udf_scalar_create=(o,l,f)=>(Xp=u._duckdb_web_udf_scalar_create=R.jb)(o,l,f),Zp=u._duckdb_web_prepared_create=(o,l,f)=>(Zp=u._duckdb_web_prepared_create=R.kb)(o,l,f),Qp=u._duckdb_web_prepared_create_buffer=(o,l,f,p)=>(Qp=u._duckdb_web_prepared_create_buffer=R.lb)(o,l,f,p),tm=u._duckdb_web_prepared_close=(o,l,f)=>(tm=u._duckdb_web_prepared_close=R.mb)(o,l,f),em=u._duckdb_web_prepared_run=(o,l,f,p)=>(em=u._duckdb_web_prepared_run=R.nb)(o,l,f,p),rm=u._duckdb_web_prepared_send=(o,l,f,p)=>(rm=u._duckdb_web_prepared_send=R.ob)(o,l,f,p),nm=u._duckdb_web_query_run=(o,l,f)=>(nm=u._duckdb_web_query_run=R.pb)(o,l,f),im=u._duckdb_web_query_run_buffer=(o,l,f,p)=>(im=u._duckdb_web_query_run_buffer=R.qb)(o,l,f,p),sm=u._duckdb_web_pending_query_start=(o,l,f,p)=>(sm=u._duckdb_web_pending_query_start=R.rb)(o,l,f,p),om=u._duckdb_web_pending_query_start_buffer=(o,l,f,p,_)=>(om=u._duckdb_web_pending_query_start_buffer=R.sb)(o,l,f,p,_),am=u._duckdb_web_pending_query_poll=(o,l,f)=>(am=u._duckdb_web_pending_query_poll=R.tb)(o,l,f),cm=u._duckdb_web_pending_query_cancel=(o,l)=>(cm=u._duckdb_web_pending_query_cancel=R.ub)(o,l),lm=u._duckdb_web_query_fetch_results=(o,l)=>(lm=u._duckdb_web_query_fetch_results=R.vb)(o,l),um=u._duckdb_web_get_tablenames=(o,l,f)=>(um=u._duckdb_web_get_tablenames=R.wb)(o,l,f),dm=u._duckdb_web_get_tablenames_buffer=(o,l,f,p)=>(dm=u._duckdb_web_get_tablenames_buffer=R.xb)(o,l,f,p),fm=u._duckdb_web_insert_arrow_from_ipc_stream=(o,l,f,p,_)=>(fm=u._duckdb_web_insert_arrow_from_ipc_stream=R.yb)(o,l,f,p,_),hm=u._duckdb_web_insert_csv_from_path=(o,l,f,p)=>(hm=u._duckdb_web_insert_csv_from_path=R.zb)(o,l,f,p),pm=u._duckdb_web_insert_json_from_path=(o,l,f,p)=>(pm=u._duckdb_web_insert_json_from_path=R.Ab)(o,l,f,p),mm=u.__emscripten_tls_init=()=>(mm=u.__emscripten_tls_init=R.Bb)(),Ss=u._pthread_self=()=>(Ss=u._pthread_self=R.Cb)(),Du=u.__emscripten_thread_init=(o,l,f,p,_,b)=>(Du=u.__emscripten_thread_init=R.Db)(o,l,f,p,_,b),_m=u.__emscripten_thread_crashed=()=>(_m=u.__emscripten_thread_crashed=R.Eb)(),ym=()=>(ym=R.emscripten_main_runtime_thread_id)(),bm=()=>(bm=R.emscripten_main_thread_process_queued_calls)(),Bu=(o,l,f,p,_)=>(Bu=R.Ib)(o,l,f,p,_),Ua=o=>(Ua=R.Jb)(o),Ra=u.__emscripten_thread_exit=o=>(Ra=u.__emscripten_thread_exit=R.Kb)(o),Fu=()=>(Fu=R.Lb)(),hr=u._malloc=o=>(hr=u._malloc=R.Mb)(o),gm=u._free=o=>(gm=u._free=R.Nb)(o),wm=u._calloc=(o,l)=>(wm=u._calloc=R.Ob)(o,l),Au=o=>(Au=R.Qb)(o),Tu=()=>(Tu=R.Rb)(),xu=(o,l)=>(xu=R.Sb)(o,l),Eu=o=>(Eu=R.Tb)(o),Ou=o=>(Ou=R.Ub)(o),Mu=()=>(Mu=R.Vb)();function vm(o){o=Object.assign({},o);var l=p=>()=>p()>>>0,f=p=>_=>p(_)>>>0;return o.Cb=l(o.Cb),o.emscripten_main_runtime_thread_id=l(o.emscripten_main_runtime_thread_id),o.Mb=f(o.Mb),o.Ub=f(o.Ub),o.Vb=l(o.Vb),o}u.wasmMemory=Ut,u.stackSave=ba,u.stackRestore=ms,u.stackAlloc=di,u.getTempRet0=Ip,u.setTempRet0=xa,u.keepRuntimeAlive=ps,u.ccall=vp,u.ExitStatus=ma,u.createDyncallWrapper=Sp,u.PThread=ct;var Is;ui=function o(){Is||Uu(),Is||(ui=o)};function Sm(){var o=Iu,l=0,f=0;try{var p=o(l,f);return fl(p,!0),p}catch(_){return wa(_)}}function Uu(){if(ln>0)return;if(U){I(u),Qc(),startWorker(u);return}if(rh(),ln>0)return;function o(){Is||(Is=!0,u.calledRun=!0,!ye&&(Qc(),nh(),I(u),u.onRuntimeInitialized&&u.onRuntimeInitialized(),Ru&&Sm(),ih()))}u.setStatus?(u.setStatus("Running..."),setTimeout(function(){setTimeout(function(){u.setStatus("")},1),o()},1)):o()}if(u.preInit)for(typeof u.preInit=="function"&&(u.preInit=[u.preInit]);u.preInit.length>0;)u.preInit.pop()();var Ru=!0;return u.noInitialRun&&(Ru=!1),Uu(),E}})();typeof zf=="object"&&typeof Wc=="object"?Wc.exports=Wf:typeof define=="function"&&define.amd&&define([],()=>Wf)});var Gf=pr(()=>{});var Yf=pr(()=>{});var qf=pr((mF,ha)=>{(function(){"use strict";var r="input is invalid type",t=typeof window=="object",e=t?window:{};e.JS_SHA256_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",i=!e.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node&&process.type!="renderer";i?e=global:n&&(e=self);var s=!e.JS_SHA256_NO_COMMON_JS&&typeof ha=="object"&&ha.exports,a=typeof define=="function"&&define.amd,c=!e.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",d="0123456789abcdef".split(""),h=[-2147483648,8388608,32768,128],u=[24,16,8,0],I=[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],T=["hex","array","digest","arrayBuffer"],E=[];(e.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(w){return Object.prototype.toString.call(w)==="[object Array]"}),c&&(e.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(w){return typeof w=="object"&&w.buffer&&w.buffer.constructor===ArrayBuffer});var ft=function(w,M){return function(H){return new bt(M,!0).update(H)[w]()}},At=function(w){var M=ft("hex",w);i&&(M=jt(M,w)),M.create=function(){return new bt(w)},M.update=function(N){return M.create().update(N)};for(var H=0;H<T.length;++H){var D=T[H];M[D]=ft(D,w)}return M},jt=function(w,M){var H=Gf(),D=Yf().Buffer,N=M?"sha224":"sha256",A;D.from&&!e.JS_SHA256_NO_BUFFER_FROM?A=D.from:A=function(B){return new D(B)};var J=function(B){if(typeof B=="string")return H.createHash(N).update(B,"utf8").digest("hex");if(B==null)throw new Error(r);return B.constructor===ArrayBuffer&&(B=new Uint8Array(B)),Array.isArray(B)||ArrayBuffer.isView(B)||B.constructor===D?H.createHash(N).update(A(B)).digest("hex"):w(B)};return J},Lt=function(w,M){return function(H,D){return new xt(H,M,!0).update(D)[w]()}},Tt=function(w){var M=Lt("hex",w);M.create=function(N){return new xt(N,w)},M.update=function(N,A){return M.create(N).update(A)};for(var H=0;H<T.length;++H){var D=T[H];M[D]=Lt(D,w)}return M};function bt(w,M){M?(E[0]=E[16]=E[1]=E[2]=E[3]=E[4]=E[5]=E[6]=E[7]=E[8]=E[9]=E[10]=E[11]=E[12]=E[13]=E[14]=E[15]=0,this.blocks=E):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],w?(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=w}bt.prototype.update=function(w){if(!this.finalized){var M,H=typeof w;if(H!=="string"){if(H==="object"){if(w===null)throw new Error(r);if(c&&w.constructor===ArrayBuffer)w=new Uint8Array(w);else if(!Array.isArray(w)&&(!c||!ArrayBuffer.isView(w)))throw new Error(r)}else throw new Error(r);M=!0}for(var D,N=0,A,J=w.length,B=this.blocks;N<J;){if(this.hashed&&(this.hashed=!1,B[0]=this.block,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),M)for(A=this.start;N<J&&A<64;++N)B[A>>>2]|=w[N]<<u[A++&3];else for(A=this.start;N<J&&A<64;++N)D=w.charCodeAt(N),D<128?B[A>>>2]|=D<<u[A++&3]:D<2048?(B[A>>>2]|=(192|D>>>6)<<u[A++&3],B[A>>>2]|=(128|D&63)<<u[A++&3]):D<55296||D>=57344?(B[A>>>2]|=(224|D>>>12)<<u[A++&3],B[A>>>2]|=(128|D>>>6&63)<<u[A++&3],B[A>>>2]|=(128|D&63)<<u[A++&3]):(D=65536+((D&1023)<<10|w.charCodeAt(++N)&1023),B[A>>>2]|=(240|D>>>18)<<u[A++&3],B[A>>>2]|=(128|D>>>12&63)<<u[A++&3],B[A>>>2]|=(128|D>>>6&63)<<u[A++&3],B[A>>>2]|=(128|D&63)<<u[A++&3]);this.lastByteIndex=A,this.bytes+=A-this.start,A>=64?(this.block=B[16],this.start=A-64,this.hash(),this.hashed=!0):this.start=A}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},bt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var w=this.blocks,M=this.lastByteIndex;w[16]=this.block,w[M>>>2]|=h[M&3],this.block=w[16],M>=56&&(this.hashed||this.hash(),w[0]=this.block,w[16]=w[1]=w[2]=w[3]=w[4]=w[5]=w[6]=w[7]=w[8]=w[9]=w[10]=w[11]=w[12]=w[13]=w[14]=w[15]=0),w[14]=this.hBytes<<3|this.bytes>>>29,w[15]=this.bytes<<3,this.hash()}},bt.prototype.hash=function(){var w=this.h0,M=this.h1,H=this.h2,D=this.h3,N=this.h4,A=this.h5,J=this.h6,B=this.h7,W=this.blocks,Q,pt,Ht,Ut,vt,ye,se,Vr,be,On,cn;for(Q=16;Q<64;++Q)vt=W[Q-15],pt=(vt>>>7|vt<<25)^(vt>>>18|vt<<14)^vt>>>3,vt=W[Q-2],Ht=(vt>>>17|vt<<15)^(vt>>>19|vt<<13)^vt>>>10,W[Q]=W[Q-16]+pt+W[Q-7]+Ht<<0;for(cn=M&H,Q=0;Q<64;Q+=4)this.first?(this.is224?(Vr=300032,vt=W[0]-1413257819,B=vt-150054599<<0,D=vt+24177077<<0):(Vr=704751109,vt=W[0]-210244248,B=vt-1521486534<<0,D=vt+143694565<<0),this.first=!1):(pt=(w>>>2|w<<30)^(w>>>13|w<<19)^(w>>>22|w<<10),Ht=(N>>>6|N<<26)^(N>>>11|N<<21)^(N>>>25|N<<7),Vr=w&M,Ut=Vr^w&H^cn,se=N&A^~N&J,vt=B+Ht+se+I[Q]+W[Q],ye=pt+Ut,B=D+vt<<0,D=vt+ye<<0),pt=(D>>>2|D<<30)^(D>>>13|D<<19)^(D>>>22|D<<10),Ht=(B>>>6|B<<26)^(B>>>11|B<<21)^(B>>>25|B<<7),be=D&w,Ut=be^D&M^Vr,se=B&N^~B&A,vt=J+Ht+se+I[Q+1]+W[Q+1],ye=pt+Ut,J=H+vt<<0,H=vt+ye<<0,pt=(H>>>2|H<<30)^(H>>>13|H<<19)^(H>>>22|H<<10),Ht=(J>>>6|J<<26)^(J>>>11|J<<21)^(J>>>25|J<<7),On=H&D,Ut=On^H&w^be,se=J&B^~J&N,vt=A+Ht+se+I[Q+2]+W[Q+2],ye=pt+Ut,A=M+vt<<0,M=vt+ye<<0,pt=(M>>>2|M<<30)^(M>>>13|M<<19)^(M>>>22|M<<10),Ht=(A>>>6|A<<26)^(A>>>11|A<<21)^(A>>>25|A<<7),cn=M&H,Ut=cn^M&D^On,se=A&J^~A&B,vt=N+Ht+se+I[Q+3]+W[Q+3],ye=pt+Ut,N=w+vt<<0,w=vt+ye<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+w<<0,this.h1=this.h1+M<<0,this.h2=this.h2+H<<0,this.h3=this.h3+D<<0,this.h4=this.h4+N<<0,this.h5=this.h5+A<<0,this.h6=this.h6+J<<0,this.h7=this.h7+B<<0},bt.prototype.hex=function(){this.finalize();var w=this.h0,M=this.h1,H=this.h2,D=this.h3,N=this.h4,A=this.h5,J=this.h6,B=this.h7,W=d[w>>>28&15]+d[w>>>24&15]+d[w>>>20&15]+d[w>>>16&15]+d[w>>>12&15]+d[w>>>8&15]+d[w>>>4&15]+d[w&15]+d[M>>>28&15]+d[M>>>24&15]+d[M>>>20&15]+d[M>>>16&15]+d[M>>>12&15]+d[M>>>8&15]+d[M>>>4&15]+d[M&15]+d[H>>>28&15]+d[H>>>24&15]+d[H>>>20&15]+d[H>>>16&15]+d[H>>>12&15]+d[H>>>8&15]+d[H>>>4&15]+d[H&15]+d[D>>>28&15]+d[D>>>24&15]+d[D>>>20&15]+d[D>>>16&15]+d[D>>>12&15]+d[D>>>8&15]+d[D>>>4&15]+d[D&15]+d[N>>>28&15]+d[N>>>24&15]+d[N>>>20&15]+d[N>>>16&15]+d[N>>>12&15]+d[N>>>8&15]+d[N>>>4&15]+d[N&15]+d[A>>>28&15]+d[A>>>24&15]+d[A>>>20&15]+d[A>>>16&15]+d[A>>>12&15]+d[A>>>8&15]+d[A>>>4&15]+d[A&15]+d[J>>>28&15]+d[J>>>24&15]+d[J>>>20&15]+d[J>>>16&15]+d[J>>>12&15]+d[J>>>8&15]+d[J>>>4&15]+d[J&15];return this.is224||(W+=d[B>>>28&15]+d[B>>>24&15]+d[B>>>20&15]+d[B>>>16&15]+d[B>>>12&15]+d[B>>>8&15]+d[B>>>4&15]+d[B&15]),W},bt.prototype.toString=bt.prototype.hex,bt.prototype.digest=function(){this.finalize();var w=this.h0,M=this.h1,H=this.h2,D=this.h3,N=this.h4,A=this.h5,J=this.h6,B=this.h7,W=[w>>>24&255,w>>>16&255,w>>>8&255,w&255,M>>>24&255,M>>>16&255,M>>>8&255,M&255,H>>>24&255,H>>>16&255,H>>>8&255,H&255,D>>>24&255,D>>>16&255,D>>>8&255,D&255,N>>>24&255,N>>>16&255,N>>>8&255,N&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255,J>>>24&255,J>>>16&255,J>>>8&255,J&255];return this.is224||W.push(B>>>24&255,B>>>16&255,B>>>8&255,B&255),W},bt.prototype.array=bt.prototype.digest,bt.prototype.arrayBuffer=function(){this.finalize();var w=new ArrayBuffer(this.is224?28:32),M=new DataView(w);return M.setUint32(0,this.h0),M.setUint32(4,this.h1),M.setUint32(8,this.h2),M.setUint32(12,this.h3),M.setUint32(16,this.h4),M.setUint32(20,this.h5),M.setUint32(24,this.h6),this.is224||M.setUint32(28,this.h7),w};function xt(w,M,H){var D,N=typeof w;if(N==="string"){var A=[],J=w.length,B=0,W;for(D=0;D<J;++D)W=w.charCodeAt(D),W<128?A[B++]=W:W<2048?(A[B++]=192|W>>>6,A[B++]=128|W&63):W<55296||W>=57344?(A[B++]=224|W>>>12,A[B++]=128|W>>>6&63,A[B++]=128|W&63):(W=65536+((W&1023)<<10|w.charCodeAt(++D)&1023),A[B++]=240|W>>>18,A[B++]=128|W>>>12&63,A[B++]=128|W>>>6&63,A[B++]=128|W&63);w=A}else if(N==="object"){if(w===null)throw new Error(r);if(c&&w.constructor===ArrayBuffer)w=new Uint8Array(w);else if(!Array.isArray(w)&&(!c||!ArrayBuffer.isView(w)))throw new Error(r)}else throw new Error(r);w.length>64&&(w=new bt(M,!0).update(w).array());var Q=[],pt=[];for(D=0;D<64;++D){var Ht=w[D]||0;Q[D]=92^Ht,pt[D]=54^Ht}bt.call(this,M,H),this.update(pt),this.oKeyPad=Q,this.inner=!0,this.sharedMemory=H}xt.prototype=new bt,xt.prototype.finalize=function(){if(bt.prototype.finalize.call(this),this.inner){this.inner=!1;var w=this.array();bt.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(w),bt.prototype.finalize.call(this)}};var U=At();U.sha256=U,U.sha224=At(!0),U.sha256.hmac=Tt(),U.sha224.hmac=Tt(!0),s?ha.exports=U:(e.sha256=U.sha256,e.sha224=U.sha224,a&&define(function(){return U}))})()});var sb={};jr(sb,{registerWorker:()=>Qf});function Cu(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e}function L(r,t,e,n){function i(s){return s instanceof e?s:new e(function(a){a(s)})}return new(e||(e=Promise))(function(s,a){function c(u){try{h(n.next(u))}catch(I){a(I)}}function d(u){try{h(n.throw(u))}catch(I){a(I)}}function h(u){u.done?s(u.value):i(u.value).then(c,d)}h((n=n.apply(r,t||[])).next())})}function Nu(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],n=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function lt(r){return this instanceof lt?(this.v=r,this):new lt(r)}function we(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(r,t||[]),i,s=[];return i={},a("next"),a("throw"),a("return"),i[Symbol.asyncIterator]=function(){return this},i;function a(T){n[T]&&(i[T]=function(E){return new Promise(function(ft,At){s.push([T,E,ft,At])>1||c(T,E)})})}function c(T,E){try{d(n[T](E))}catch(ft){I(s[0][3],ft)}}function d(T){T.value instanceof lt?Promise.resolve(T.value.v).then(h,u):I(s[0][2],T)}function h(T){c("next",T)}function u(T){c("throw",T)}function I(T,E){T(E),s.shift(),s.length&&c(s[0][0],s[0][1])}}function kn(r){var t,e;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=r[i]?function(a){return(e=!e)?{value:lt(r[i](a)),done:!1}:s?s(a):a}:s}}function Le(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof Nu=="function"?Nu(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=r[s]&&function(a){return new Promise(function(c,d){a=r[s](a),i(c,d,a.done,a.value)})}}function i(s,a,c,d){Promise.resolve(d).then(function(h){s({value:h,done:c})},a)}}var Wa={};jr(Wa,{compareArrayLike:()=>Va,joinUint8Arrays:()=>ve,memcpy:()=>yi,rebaseValueOffsets:()=>Us,toArrayBufferView:()=>dt,toArrayBufferViewAsyncIterator:()=>Ce,toArrayBufferViewIterator:()=>rr,toBigInt64Array:()=>Ms,toBigUint64Array:()=>Pm,toFloat32Array:()=>Hm,toFloat32ArrayAsyncIterator:()=>r_,toFloat32ArrayIterator:()=>qm,toFloat64Array:()=>Vm,toFloat64ArrayAsyncIterator:()=>n_,toFloat64ArrayIterator:()=>Km,toInt16Array:()=>km,toInt16ArrayAsyncIterator:()=>Zm,toInt16ArrayIterator:()=>jm,toInt32Array:()=>dn,toInt32ArrayAsyncIterator:()=>Qm,toInt32ArrayIterator:()=>$m,toInt8Array:()=>Lm,toInt8ArrayAsyncIterator:()=>Xm,toInt8ArrayIterator:()=>zm,toUint16Array:()=>Nm,toUint16ArrayAsyncIterator:()=>t_,toUint16ArrayIterator:()=>Gm,toUint32Array:()=>Cm,toUint32ArrayAsyncIterator:()=>e_,toUint32ArrayIterator:()=>Ym,toUint8Array:()=>Z,toUint8ArrayAsyncIterator:()=>Ha,toUint8ArrayIterator:()=>Pa,toUint8ClampedArray:()=>Wm,toUint8ClampedArrayAsyncIterator:()=>i_,toUint8ClampedArrayIterator:()=>Jm});var Om=new TextDecoder("utf-8"),mi=r=>Om.decode(r),Mm=new TextEncoder,er=r=>Mm.encode(r);var Um=r=>typeof r=="number",Pu=r=>typeof r=="boolean",Kt=r=>typeof r=="function",ce=r=>r!=null&&Object(r)===r,ke=r=>ce(r)&&Kt(r.then);var Ne=r=>ce(r)&&Kt(r[Symbol.iterator]),Ae=r=>ce(r)&&Kt(r[Symbol.asyncIterator]),Fs=r=>ce(r)&&ce(r.schema);var As=r=>ce(r)&&"done"in r&&"value"in r;var Ts=r=>ce(r)&&Kt(r.stat)&&Um(r.fd);var xs=r=>ce(r)&&_i(r.body),Es=r=>"_getDOMStream"in r&&"_getNodeStream"in r,Hu=r=>ce(r)&&Kt(r.abort)&&Kt(r.getWriter)&&!Es(r),_i=r=>ce(r)&&Kt(r.cancel)&&Kt(r.getReader)&&!Es(r),Vu=r=>ce(r)&&Kt(r.end)&&Kt(r.write)&&Pu(r.writable)&&!Es(r),Os=r=>ce(r)&&Kt(r.read)&&Kt(r.pipe)&&Pu(r.readable)&&!Es(r),Wu=r=>ce(r)&&Kt(r.clear)&&Kt(r.bytes)&&Kt(r.position)&&Kt(r.setPosition)&&Kt(r.capacity)&&Kt(r.getBufferIdentifier)&&Kt(r.createLong);var Ca=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Rm(r){let t=r[0]?[r[0]]:[],e,n,i,s;for(let a,c,d=0,h=0,u=r.length;++d<u;){if(a=t[h],c=r[d],!a||!c||a.buffer!==c.buffer||c.byteOffset<a.byteOffset){c&&(t[++h]=c);continue}if({byteOffset:e,byteLength:i}=a,{byteOffset:n,byteLength:s}=c,e+i<n||n+s<e){c&&(t[++h]=c);continue}t[h]=new Uint8Array(a.buffer,e,n-e+s)}return t}function yi(r,t,e=0,n=t.byteLength){let i=r.byteLength,s=new Uint8Array(r.buffer,r.byteOffset,i),a=new Uint8Array(t.buffer,t.byteOffset,Math.min(n,i));return s.set(a,e),r}function ve(r,t){let e=Rm(r),n=e.reduce((u,I)=>u+I.byteLength,0),i,s,a,c=0,d=-1,h=Math.min(t||Number.POSITIVE_INFINITY,n);for(let u=e.length;++d<u;){if(i=e[d],s=i.subarray(0,Math.min(i.length,h-c)),h<=c+s.length){s.length<i.length?e[d]=i.subarray(s.length):s.length===i.length&&d++,a?yi(a,s,c):a=s;break}yi(a||(a=new Uint8Array(h)),s,c),c+=s.length}return[a||new Uint8Array(0),e.slice(d),n-(a?a.byteLength:0)]}function dt(r,t){let e=As(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=er(e)),e instanceof ArrayBuffer?new r(e):e instanceof Ca?new r(e):Wu(e)?dt(r,e.bytes()):ArrayBuffer.isView(e)?e.byteLength<=0?new r(0):new r(e.buffer,e.byteOffset,e.byteLength/r.BYTES_PER_ELEMENT):r.from(e)):new r(0)}var Lm=r=>dt(Int8Array,r),km=r=>dt(Int16Array,r),dn=r=>dt(Int32Array,r),Ms=r=>dt(BigInt64Array,r),Z=r=>dt(Uint8Array,r),Nm=r=>dt(Uint16Array,r),Cm=r=>dt(Uint32Array,r),Pm=r=>dt(BigUint64Array,r),Hm=r=>dt(Float32Array,r),Vm=r=>dt(Float64Array,r),Wm=r=>dt(Uint8ClampedArray,r),Na=r=>(r.next(),r);function*rr(r,t){let e=function*(i){yield i},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Ca?e(t):Ne(t)?t:e(t);return yield*un(Na(function*(i){let s=null;do s=i.next(yield dt(r,s));while(!s.done)}(n[Symbol.iterator]()))),new r}var zm=r=>rr(Int8Array,r),jm=r=>rr(Int16Array,r),$m=r=>rr(Int32Array,r),Pa=r=>rr(Uint8Array,r),Gm=r=>rr(Uint16Array,r),Ym=r=>rr(Uint32Array,r),qm=r=>rr(Float32Array,r),Km=r=>rr(Float64Array,r),Jm=r=>rr(Uint8ClampedArray,r);function Ce(r,t){return we(this,arguments,function*(){if(ke(t))return yield lt(yield lt(yield*un(kn(Le(Ce(r,yield lt(t)))))));let n=function(a){return we(this,arguments,function*(){yield yield lt(yield lt(a))})},i=function(a){return we(this,arguments,function*(){yield lt(yield*un(kn(Le(Na(function*(c){let d=null;do d=c.next(yield d==null?void 0:d.value);while(!d.done)}(a[Symbol.iterator]()))))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Ca?n(t):Ne(t)?i(t):Ae(t)?t:n(t);return yield lt(yield*un(kn(Le(Na(function(a){return we(this,arguments,function*(){let c=null;do c=yield lt(a.next(yield yield lt(dt(r,c))));while(!c.done)})}(s[Symbol.asyncIterator]())))))),yield lt(new r)})}var Xm=r=>Ce(Int8Array,r),Zm=r=>Ce(Int16Array,r),Qm=r=>Ce(Int32Array,r),Ha=r=>Ce(Uint8Array,r),t_=r=>Ce(Uint16Array,r),e_=r=>Ce(Uint32Array,r),r_=r=>Ce(Float32Array,r),n_=r=>Ce(Float64Array,r),i_=r=>Ce(Uint8ClampedArray,r);function Us(r,t,e){if(r!==0){e=e.slice(0,t);for(let n=-1,i=e.length;++n<i;)e[n]+=r}return e.subarray(0,t)}function Va(r,t){let e=0,n=r.length;if(n!==t.length)return!1;if(n>0)do if(r[e]!==t[e])return!1;while(++e<n);return!0}var ee={fromIterable(r){return Rs(s_(r))},fromAsyncIterable(r){return Rs(o_(r))},fromDOMStream(r){return Rs(a_(r))},fromNodeStream(r){return Rs(c_(r))},toDOMStream(r,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(r,t){throw new Error('"toNodeStream" not available in this environment')}},Rs=r=>(r.next(),r);function*s_(r){let t,e=!1,n=[],i,s,a,c=0;function d(){return s==="peek"?ve(n,a)[0]:([i,n,c]=ve(n,a),i)}({cmd:s,size:a}=(yield null)||{cmd:"read",size:0});let h=Pa(r)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(a-c)?h.next():h.next(a-c),!t&&i.byteLength>0&&(n.push(i),c+=i.byteLength),t||a<=c)do({cmd:s,size:a}=yield d());while(a<c);while(!t)}catch(u){(e=!0)&&typeof h.throw=="function"&&h.throw(u)}finally{e===!1&&typeof h.return=="function"&&h.return(null)}return null}function o_(r){return we(this,arguments,function*(){let e,n=!1,i=[],s,a,c,d=0;function h(){return a==="peek"?ve(i,c)[0]:([s,i,d]=ve(i,c),s)}({cmd:a,size:c}=(yield yield lt(null))||{cmd:"read",size:0});let u=Ha(r)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(c-d)?yield lt(u.next()):yield lt(u.next(c-d)),!e&&s.byteLength>0&&(i.push(s),d+=s.byteLength),e||c<=d)do({cmd:a,size:c}=yield yield lt(h()));while(c<d);while(!e)}catch(I){(n=!0)&&typeof u.throw=="function"&&(yield lt(u.throw(I)))}finally{n===!1&&typeof u.return=="function"&&(yield lt(u.return(new Uint8Array(0))))}return yield lt(null)})}function a_(r){return we(this,arguments,function*(){let e=!1,n=!1,i=[],s,a,c,d=0;function h(){return a==="peek"?ve(i,c)[0]:([s,i,d]=ve(i,c),s)}({cmd:a,size:c}=(yield yield lt(null))||{cmd:"read",size:0});let u=new ja(r);try{do if({done:e,value:s}=Number.isNaN(c-d)?yield lt(u.read()):yield lt(u.read(c-d)),!e&&s.byteLength>0&&(i.push(Z(s)),d+=s.byteLength),e||c<=d)do({cmd:a,size:c}=yield yield lt(h()));while(c<d);while(!e)}catch(I){(n=!0)&&(yield lt(u.cancel(I)))}finally{n===!1?yield lt(u.cancel()):r.locked&&u.releaseLock()}return yield lt(null)})}var ja=class{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return L(this,void 0,void 0,function*(){let{reader:e,source:n}=this;e&&(yield e.cancel(t).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(t){return L(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};let e=yield this.reader.read();return!e.done&&(e.value=Z(e)),e})}},za=(r,t)=>{let e=i=>n([t,i]),n;return[t,e,new Promise(i=>(n=i)&&r.once(t,e))]};function c_(r){return we(this,arguments,function*(){let e=[],n="error",i=!1,s=null,a,c,d=0,h=[],u;function I(){return a==="peek"?ve(h,c)[0]:([u,h,d]=ve(h,c),u)}if({cmd:a,size:c}=(yield yield lt(null))||{cmd:"read",size:0},r.isTTY)return yield yield lt(new Uint8Array(0)),yield lt(null);try{e[0]=za(r,"end"),e[1]=za(r,"error");do{if(e[2]=za(r,"readable"),[n,s]=yield lt(Promise.race(e.map(E=>E[2]))),n==="error")break;if((i=n==="end")||(Number.isFinite(c-d)?(u=Z(r.read(c-d)),u.byteLength<c-d&&(u=Z(r.read()))):u=Z(r.read()),u.byteLength>0&&(h.push(u),d+=u.byteLength)),i||c<=d)do({cmd:a,size:c}=yield yield lt(I()));while(c<d)}while(!i)}finally{yield lt(T(e,n==="error"?s:null))}return yield lt(null);function T(E,ft){return u=h=null,new Promise((At,jt)=>{for(let[Lt,Tt]of E)r.off(Lt,Tt);try{let Lt=r.destroy;Lt&&Lt.call(r,ft),ft=void 0}catch(Lt){ft=Lt||ft}finally{ft!=null?jt(ft):At()}})}})}var It;(function(r){r[r.V1=0]="V1",r[r.V2=1]="V2",r[r.V3=2]="V3",r[r.V4=3]="V4",r[r.V5=4]="V5"})(It||(It={}));var Ot;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(Ot||(Ot={}));var Et;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(Et||(Et={}));var $t;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})($t||($t={}));var C;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(C||(C={}));var Jt;(function(r){r[r.YEAR_MONTH=0]="YEAR_MONTH",r[r.DAY_TIME=1]="DAY_TIME",r[r.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(Jt||(Jt={}));var nr=new Int32Array(2),Ls=new Float32Array(nr.buffer),ks=new Float64Array(nr.buffer),Nn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var bi;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(bi||(bi={}));var Se=class r{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new r(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return nr[0]=this.readInt32(t),Ls[0]}readFloat64(t){return nr[Nn?0:1]=this.readInt32(t),nr[Nn?1:0]=this.readInt32(t+4),ks[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){Ls[0]=e,this.writeInt32(t,nr[0])}writeFloat64(t,e){ks[0]=e,this.writeInt32(t,nr[Nn?0:1]),this.writeInt32(t+4,nr[Nn?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){let n=t-this.readInt32(t);return e<this.readInt16(n)?this.readInt16(n+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);let n=this.readInt32(t);t+=4;let i=this.bytes_.subarray(t,t+n);return e===bi.UTF8_BYTES?i:this.text_decoder_.decode(i)}__union_with_string(t,e){return typeof t=="string"?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=4)throw new Error("FlatBuffers: file identifier must be length "+4);for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createScalarList(t,e){let n=[];for(let i=0;i<e;++i){let s=t(i);s!==null&&n.push(s)}return n}createObjList(t,e){let n=[];for(let i=0;i<e;++i){let s=t(i);s!==null&&n.push(s.unpack())}return n}};var fn=class r{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let e;t?e=t:e=1024,this.bb=Se.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);let n=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<n+t+e;){let i=this.bb.capacity();this.bb=r.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(n)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,n){(this.force_defaults||e!=n)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,n){(this.force_defaults||e!=n)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,n){(this.force_defaults||e!=n)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,n){(this.force_defaults||e!==n)&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,n){(this.force_defaults||e!=n)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,n){e!=n&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){let e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");let n=e<<1,i=Se.allocate(n);return i.setPosition(n-e),i.bytes().set(t.bytes(),n-e),i}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);let t=this.offset(),e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);let n=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);let i=2;this.addInt16(t-this.object_start);let s=(n+i)*2;this.addInt16(s);let a=0,c=this.space;t:for(e=0;e<this.vtables.length;e++){let d=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(d)){for(let h=2;h<s;h+=2)if(this.bb.readInt16(c+h)!=this.bb.readInt16(d+h))continue t;a=this.vtables[e];break}}return a?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,a-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,n){let i=n?4:0;if(e){let s=e;if(this.prep(this.minalign,8+i),s.length!=4)throw new TypeError("FlatBuffers: file identifier must be length "+4);for(let a=3;a>=0;a--)this.writeInt8(s.charCodeAt(a))}this.prep(this.minalign,4+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){let n=this.bb.capacity()-t,i=n-this.bb.readInt32(n);if(!(e<this.bb.readInt16(i)&&this.bb.readInt16(i+e)!=0))throw new TypeError("FlatBuffers: field "+e+" must be set")}startVector(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(n,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);let e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(t==null)return 0;let e;return t instanceof Uint8Array?e=t:e=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){let e=[];for(let n=0;n<t.length;++n){let i=t[n];if(i!==null)e.push(this.createObjectOffset(i));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var gi;(function(r){r[r.BUFFER=0]="BUFFER"})(gi||(gi={}));var wi;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(wi||(wi={}));var Cs=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}codec(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):wi.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):gi.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,wi.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,gi.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return r.startBodyCompression(t),r.addCodec(t,e),r.addMethod(t,n),r.endBodyCompression(t)}};var Cn=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n!=null?n:0)),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var Pn=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n!=null?n:0)),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var Ie=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}length(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new Pn).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}nodesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new Cn).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}buffersLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){let e=this.bb.__offset(this.bb_pos,10);return e?(t||new Cs).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addNodes(t,e){t.addFieldOffset(1,e,0)}static startNodesVector(t,e){t.startVector(16,e,8)}static addBuffers(t,e){t.addFieldOffset(2,e,0)}static startBuffersVector(t,e){t.startVector(16,e,8)}static addCompression(t,e){t.addFieldOffset(3,e,0)}static endRecordBatch(t){return t.endObject()}};var mr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new Ie).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}};var $r;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})($r||($r={}));var vi;(function(r){r[r.DenseArray=0]="DenseArray"})(vi||(vi={}));var He=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInt(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,e){t.addFieldInt32(0,e,0)}static addIsSigned(t,e){t.addFieldInt8(1,+e,0)}static endInt(t){return t.endObject()}static createInt(t,e,n){return r.startInt(t),r.addBitWidth(t,e),r.addIsSigned(t,n),r.endInt(t)}};var ir=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryEncoding(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new He).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isOrdered(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):vi.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addIndexType(t,e){t.addFieldOffset(1,e,0)}static addIsOrdered(t,e){t.addFieldInt8(2,+e,0)}static addDictionaryKind(t,e){t.addFieldInt16(3,e,vi.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}};var Xt=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsKeyValue(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}key(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}value(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,e){t.addFieldOffset(0,e,0)}static addValue(t,e){t.addFieldOffset(1,e,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,e,n){return r.startKeyValue(t),r.addKey(t,e),r.addValue(t,n),r.endKeyValue(t)}};var Si=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return r.startBinary(t),r.endBinary(t)}};var Ii=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBool(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return r.startBool(t),r.endBool(t)}};var Gr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDate(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):$t.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,$t.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return r.startDate(t),r.addUnit(t,e),r.endDate(t)}};var sr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDecimal(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,e){t.addFieldInt32(0,e,0)}static addScale(t,e){t.addFieldInt32(1,e,0)}static addBitWidth(t,e){t.addFieldInt32(2,e,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,e,n,i){return r.startDecimal(t),r.addPrecision(t,e),r.addScale(t,n),r.addBitWidth(t,i),r.endDecimal(t)}};var Yr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDuration(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):C.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,C.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return r.startDuration(t),r.addUnit(t,e),r.endDuration(t)}};var qr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,e){return r.startFixedSizeBinary(t),r.addByteWidth(t,e),r.endFixedSizeBinary(t)}};var Kr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}listSize(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,e){return r.startFixedSizeList(t),r.addListSize(t,e),r.endFixedSizeList(t)}};var Jr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFloatingPoint(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Et.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,Et.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return r.startFloatingPoint(t),r.addPrecision(t,e),r.endFloatingPoint(t)}};var Xr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInterval(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Jt.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,Jt.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return r.startInterval(t),r.addUnit(t,e),r.endInterval(t)}};var Di=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeBinary(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return r.startLargeBinary(t),r.endLargeBinary(t)}};var Bi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return r.startLargeUtf8(t),r.endLargeUtf8(t)}};var Fi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsList(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return r.startList(t),r.endList(t)}};var Zr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMap(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){let t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,e){t.addFieldInt8(0,+e,0)}static endMap(t){return t.endObject()}static createMap(t,e){return r.startMap(t),r.addKeysSorted(t,e),r.endMap(t)}};var Ai=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNull(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return r.startNull(t),r.endNull(t)}};var Ti=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsStruct_(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return r.startStruct_(t),r.endStruct_(t)}};var _r=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTime(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):C.MILLISECOND}bitWidth(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,C.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return r.startTime(t),r.addUnit(t,e),r.addBitWidth(t,n),r.endTime(t)}};var yr=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTimestamp(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):C.SECOND}timezone(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,C.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return r.startTimestamp(t),r.addUnit(t,e),r.addTimezone(t,n),r.endTimestamp(t)}};var Ve=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUnion(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}mode(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):Ot.Sparse}typeIds(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+t*4):0}typeIdsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,e){t.addFieldInt16(0,e,Ot.Sparse)}static addTypeIds(t,e){t.addFieldOffset(1,e,0)}static createTypeIdsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addInt32(e[n]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,n){return r.startUnion(t),r.addMode(t,e),r.addTypeIds(t,n),r.endUnion(t)}};var xi=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return r.startUtf8(t),r.endUtf8(t)}};var Mt;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.FloatingPoint=3]="FloatingPoint",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct_=13]="Struct_",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.LargeList=21]="LargeList",r[r.RunEndEncoded=22]="RunEndEncoded"})(Mt||(Mt={}));var oe=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):Mt.NONE}type(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){let e=this.bb.__offset(this.bb_pos,12);return e?(t||new ir).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){let n=this.bb.__offset(this.bb_pos,14);return n?(e||new r).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}childrenLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,16);return n?(e||new Xt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,Mt.NONE)}static addType(t,e){t.addFieldOffset(3,e,0)}static addDictionary(t,e){t.addFieldOffset(4,e,0)}static addChildren(t,e){t.addFieldOffset(5,e,0)}static createChildrenVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startChildrenVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(6,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}};var fe=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}endianness(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):$r.Little}fields(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new oe).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}fieldsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new Xt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}featuresLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,$r.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(t,e,n,i,s){return r.startSchema(t),r.addEndianness(t,e),r.addFields(t,n),r.addCustomMetadata(t,i),r.addFeatures(t,s),r.endSchema(t)}};var _t;(function(r){r[r.NONE=0]="NONE",r[r.Schema=1]="Schema",r[r.DictionaryBatch=2]="DictionaryBatch",r[r.RecordBatch=3]="RecordBatch",r[r.Tensor=4]="Tensor",r[r.SparseTensor=5]="SparseTensor"})(_t||(_t={}));var m;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.Float=3]="Float",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct=13]="Struct",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.Dictionary=-1]="Dictionary",r[r.Int8=-2]="Int8",r[r.Int16=-3]="Int16",r[r.Int32=-4]="Int32",r[r.Int64=-5]="Int64",r[r.Uint8=-6]="Uint8",r[r.Uint16=-7]="Uint16",r[r.Uint32=-8]="Uint32",r[r.Uint64=-9]="Uint64",r[r.Float16=-10]="Float16",r[r.Float32=-11]="Float32",r[r.Float64=-12]="Float64",r[r.DateDay=-13]="DateDay",r[r.DateMillisecond=-14]="DateMillisecond",r[r.TimestampSecond=-15]="TimestampSecond",r[r.TimestampMillisecond=-16]="TimestampMillisecond",r[r.TimestampMicrosecond=-17]="TimestampMicrosecond",r[r.TimestampNanosecond=-18]="TimestampNanosecond",r[r.TimeSecond=-19]="TimeSecond",r[r.TimeMillisecond=-20]="TimeMillisecond",r[r.TimeMicrosecond=-21]="TimeMicrosecond",r[r.TimeNanosecond=-22]="TimeNanosecond",r[r.DenseUnion=-23]="DenseUnion",r[r.SparseUnion=-24]="SparseUnion",r[r.IntervalDayTime=-25]="IntervalDayTime",r[r.IntervalYearMonth=-26]="IntervalYearMonth",r[r.DurationSecond=-27]="DurationSecond",r[r.DurationMillisecond=-28]="DurationMillisecond",r[r.DurationMicrosecond=-29]="DurationMicrosecond",r[r.DurationNanosecond=-30]="DurationNanosecond"})(m||(m={}));var xe;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(xe||(xe={}));var uc={};jr(uc,{clampRange:()=>Ui,createElementComparator:()=>rn,wrapIndex:()=>hn});var $a={};jr($a,{valueToString:()=>We});function We(r){if(r===null)return"null";if(r===void 0)return"undefined";switch(typeof r){case"number":return"".concat(r);case"bigint":return"".concat(r);case"string":return'"'.concat(r,'"')}return typeof r[Symbol.toPrimitive]=="function"?r[Symbol.toPrimitive]("string"):ArrayBuffer.isView(r)?r instanceof BigInt64Array||r instanceof BigUint64Array?"[".concat([...r].map(t=>We(t)),"]"):"[".concat(r,"]"):ArrayBuffer.isView(r)?"[".concat(r,"]"):JSON.stringify(r,(t,e)=>typeof e=="bigint"?"".concat(e):e)}var Ka={};jr(Ka,{BN:()=>Oi,bigNumToBigInt:()=>ju,bigNumToNumber:()=>qa,bigNumToString:()=>Wn,isArrowBigNumSymbol:()=>zu});function wt(r){if(typeof r=="bigint"&&(r<Number.MIN_SAFE_INTEGER||r>Number.MAX_SAFE_INTEGER))throw new TypeError("".concat(r," is not safe to convert to a number."));return Number(r)}function Ga(r,t){return wt(r/t)+wt(r%t)/wt(t)}var zu=Symbol.for("isArrowBigNum");function ze(r,...t){return t.length===0?Object.setPrototypeOf(dt(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}ze.prototype[zu]=!0;ze.prototype.toJSON=function(){return'"'.concat(Wn(this),'"')};ze.prototype.valueOf=function(r){return qa(this,r)};ze.prototype.toString=function(){return Wn(this)};ze.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return qa(this);case"string":return Wn(this);case"default":return ju(this)}return Wn(this)};function Hn(...r){return ze.apply(this,r)}function Vn(...r){return ze.apply(this,r)}function Ei(...r){return ze.apply(this,r)}Object.setPrototypeOf(Hn.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Vn.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Ei.prototype,Object.create(Uint32Array.prototype));Object.assign(Hn.prototype,ze.prototype,{constructor:Hn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(Vn.prototype,ze.prototype,{constructor:Vn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Ei.prototype,ze.prototype,{constructor:Ei,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var l_=BigInt(4294967296)*BigInt(4294967296),u_=l_-BigInt(1);function qa(r,t){let{buffer:e,byteOffset:n,byteLength:i,signed:s}=r,a=new BigUint64Array(e,n,i/8),c=s&&a.at(-1)&BigInt(1)<<BigInt(63),d=BigInt(0),h=0;if(c){for(let u of a)d|=(u^u_)*(BigInt(1)<<BigInt(64*h++));d*=BigInt(-1),d-=BigInt(1)}else for(let u of a)d|=u*(BigInt(1)<<BigInt(64*h++));if(typeof t=="number"){let u=BigInt(Math.pow(10,t)),I=d/u,T=d%u;return wt(I)+wt(T)/wt(u)}return wt(d)}function Wn(r){if(r.byteLength===8){let s=new r.BigIntArray(r.buffer,r.byteOffset,1);return"".concat(s[0])}if(!r.signed)return Ya(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Ya(r);t=t.slice();let n=1;for(let s=0;s<t.length;s++){let a=t[s],c=~a+n;t[s]=c,n&=a===0?1:0}let i=Ya(t);return"-".concat(i)}function ju(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:Wn(r)}function Ya(r){let t="",e=new Uint32Array(2),n=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),i=new Uint32Array((n=new Uint16Array(n).reverse()).buffer),s=-1,a=n.length-1;do{for(e[0]=n[s=0];s<a;)n[s++]=e[1]=e[0]/10,e[0]=(e[0]-e[1]*10<<16)+n[s];n[s]=e[1]=e[0]/10,e[0]=e[0]-e[1]*10,t="".concat(e[0]).concat(t)}while(i[0]||i[1]||i[2]||i[3]);return t!=null?t:"0"}var Oi=class r{static new(t,e){switch(e){case!0:return new Hn(t);case!1:return new Vn(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new Hn(t)}return t.byteLength===16?new Ei(t):new Vn(t)}static signed(t){return new Hn(t)}static unsigned(t){return new Vn(t)}static decimal(t){return new Ei(t)}constructor(t,e){return r.new(t,e)}};var $u,Gu,Yu,qu,Ku,Ju,Xu,Zu,Qu,td,ed,rd,nd,id,sd,od,ad,cd,ld,ud,dd,fd,k=class r{static isNull(t){return(t==null?void 0:t.typeId)===m.Null}static isInt(t){return(t==null?void 0:t.typeId)===m.Int}static isFloat(t){return(t==null?void 0:t.typeId)===m.Float}static isBinary(t){return(t==null?void 0:t.typeId)===m.Binary}static isLargeBinary(t){return(t==null?void 0:t.typeId)===m.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===m.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===m.LargeUtf8}static isBool(t){return(t==null?void 0:t.typeId)===m.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===m.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===m.Date}static isTime(t){return(t==null?void 0:t.typeId)===m.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===m.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===m.Interval}static isDuration(t){return(t==null?void 0:t.typeId)===m.Duration}static isList(t){return(t==null?void 0:t.typeId)===m.List}static isStruct(t){return(t==null?void 0:t.typeId)===m.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===m.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===m.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===m.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===m.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===m.Dictionary}static isDenseUnion(t){return r.isUnion(t)&&t.mode===Ot.Dense}static isSparseUnion(t){return r.isUnion(t)&&t.mode===Ot.Sparse}constructor(t){this.typeId=t}};$u=Symbol.toStringTag;k[$u]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(k.prototype);var le=class extends k{constructor(){super(m.Null)}toString(){return"Null"}};Gu=Symbol.toStringTag;le[Gu]=(r=>r[Symbol.toStringTag]="Null")(le.prototype);var Zt=class extends k{constructor(t,e){super(m.Int),this.isSigned=t,this.bitWidth=e}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error("Unrecognized ".concat(this[Symbol.toStringTag]," type"))}toString(){return"".concat(this.isSigned?"I":"Ui","nt").concat(this.bitWidth)}};Yu=Symbol.toStringTag;Zt[Yu]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(Zt.prototype);var Ps=class extends Zt{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},Hs=class extends Zt{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},or=class extends Zt{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Vs=class extends Zt{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Ws=class extends Zt{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},zs=class extends Zt{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},js=class extends Zt{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},$s=class extends Zt{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(Ps.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(Hs.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(or.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(Vs.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(Ws.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(zs.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(js.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty($s.prototype,"ArrayType",{value:BigUint64Array});var Ee=class extends k{constructor(t){super(m.Float),this.precision=t}get ArrayType(){switch(this.precision){case Et.HALF:return Uint16Array;case Et.SINGLE:return Float32Array;case Et.DOUBLE:return Float64Array}throw new Error("Unrecognized ".concat(this[Symbol.toStringTag]," type"))}toString(){return"Float".concat(this.precision<<5||16)}};qu=Symbol.toStringTag;Ee[qu]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(Ee.prototype);var Gs=class extends Ee{constructor(){super(Et.HALF)}},Ys=class extends Ee{constructor(){super(Et.SINGLE)}},qs=class extends Ee{constructor(){super(Et.DOUBLE)}};Object.defineProperty(Gs.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Ys.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(qs.prototype,"ArrayType",{value:Float64Array});var br=class extends k{constructor(){super(m.Binary)}toString(){return"Binary"}};Ku=Symbol.toStringTag;br[Ku]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(br.prototype);var gr=class extends k{constructor(){super(m.LargeBinary)}toString(){return"LargeBinary"}};Ju=Symbol.toStringTag;gr[Ju]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(gr.prototype);var wr=class extends k{constructor(){super(m.Utf8)}toString(){return"Utf8"}};Xu=Symbol.toStringTag;wr[Xu]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(wr.prototype);var vr=class extends k{constructor(){super(m.LargeUtf8)}toString(){return"LargeUtf8"}};Zu=Symbol.toStringTag;vr[Zu]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(vr.prototype);var Sr=class extends k{constructor(){super(m.Bool)}toString(){return"Bool"}};Qu=Symbol.toStringTag;Sr[Qu]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(Sr.prototype);var Ir=class extends k{constructor(t,e,n=128){super(m.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return"Decimal[".concat(this.precision,"e").concat(this.scale>0?"+":"").concat(this.scale,"]")}};td=Symbol.toStringTag;Ir[td]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(Ir.prototype);var Dr=class extends k{constructor(t){super(m.Date),this.unit=t}toString(){return"Date".concat((this.unit+1)*32,"<").concat($t[this.unit],">")}get ArrayType(){return this.unit===$t.DAY?Int32Array:BigInt64Array}};ed=Symbol.toStringTag;Dr[ed]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(Dr.prototype);var Br=class extends k{constructor(t,e){super(m.Time),this.unit=t,this.bitWidth=e}toString(){return"Time".concat(this.bitWidth,"<").concat(C[this.unit],">")}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error("Unrecognized ".concat(this[Symbol.toStringTag]," type"))}};rd=Symbol.toStringTag;Br[rd]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Br.prototype);var Fr=class extends k{constructor(t,e){super(m.Timestamp),this.unit=t,this.timezone=e}toString(){return"Timestamp<".concat(C[this.unit]).concat(this.timezone?", ".concat(this.timezone):"",">")}};nd=Symbol.toStringTag;Fr[nd]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(Fr.prototype);var Ar=class extends k{constructor(t){super(m.Interval),this.unit=t}toString(){return"Interval<".concat(Jt[this.unit],">")}};id=Symbol.toStringTag;Ar[id]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Ar.prototype);var Tr=class extends k{constructor(t){super(m.Duration),this.unit=t}toString(){return"Duration<".concat(C[this.unit],">")}};sd=Symbol.toStringTag;Tr[sd]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(Tr.prototype);var je=class extends k{constructor(t){super(m.List),this.children=[t]}toString(){return"List<".concat(this.valueType,">")}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};od=Symbol.toStringTag;je[od]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(je.prototype);var Nt=class extends k{constructor(t){super(m.Struct),this.children=t}toString(){return"Struct<{".concat(this.children.map(t=>"".concat(t.name,":").concat(t.type)).join(", "),"}>")}};ad=Symbol.toStringTag;Nt[ad]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(Nt.prototype);var $e=class extends k{constructor(t,e,n){super(m.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((i,s,a)=>(i[s]=a)&&i||i,Object.create(null))}toString(){return"".concat(this[Symbol.toStringTag],"<").concat(this.children.map(t=>"".concat(t.type)).join(" | "),">")}};cd=Symbol.toStringTag;$e[cd]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))($e.prototype);var xr=class extends k{constructor(t){super(m.FixedSizeBinary),this.byteWidth=t}toString(){return"FixedSizeBinary[".concat(this.byteWidth,"]")}};ld=Symbol.toStringTag;xr[ld]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(xr.prototype);var Ge=class extends k{constructor(t,e){super(m.FixedSizeList),this.listSize=t,this.children=[e]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return"FixedSizeList[".concat(this.listSize,"]<").concat(this.valueType,">")}};ud=Symbol.toStringTag;Ge[ud]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(Ge.prototype);var Ye=class extends k{constructor(t,e=!1){var n,i,s;if(super(m.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((n=t==null?void 0:t.type)===null||n===void 0)&&n.children)){let a=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];a&&(a.name="key");let c=(s=t==null?void 0:t.type)===null||s===void 0?void 0:s.children[1];c&&(c.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return"Map<{".concat(this.children[0].type.children.map(t=>"".concat(t.name,":").concat(t.type)).join(", "),"}>")}};dd=Symbol.toStringTag;Ye[dd]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(Ye.prototype);var d_=(r=>()=>++r)(-1),De=class extends k{constructor(t,e,n,i){super(m.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=n==null?d_():wt(n)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return"Dictionary<".concat(this.indices,", ").concat(this.dictionary,">")}};fd=Symbol.toStringTag;De[fd]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(De.prototype);function Be(r){let t=r;switch(r.typeId){case m.Decimal:return r.bitWidth/32;case m.Interval:return 1+t.unit;case m.FixedSizeList:return t.listSize;case m.FixedSizeBinary:return t.byteWidth;default:return 1}}var $=class{visitMany(t,...e){return t.map((n,i)=>this.visit(n,...e.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return f_(this,t,e)}getVisitFnByTypeId(t,e=!0){return zn(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitLargeUtf8(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}};function f_(r,t,e=!0){return typeof t=="number"?zn(r,t,e):typeof t=="string"&&t in m?zn(r,m[t],e):t&&t instanceof k?zn(r,hd(t),e):t!=null&&t.type&&t.type instanceof k?zn(r,hd(t.type),e):zn(r,m.NONE,e)}function zn(r,t,e=!0){let n=null;switch(t){case m.Null:n=r.visitNull;break;case m.Bool:n=r.visitBool;break;case m.Int:n=r.visitInt;break;case m.Int8:n=r.visitInt8||r.visitInt;break;case m.Int16:n=r.visitInt16||r.visitInt;break;case m.Int32:n=r.visitInt32||r.visitInt;break;case m.Int64:n=r.visitInt64||r.visitInt;break;case m.Uint8:n=r.visitUint8||r.visitInt;break;case m.Uint16:n=r.visitUint16||r.visitInt;break;case m.Uint32:n=r.visitUint32||r.visitInt;break;case m.Uint64:n=r.visitUint64||r.visitInt;break;case m.Float:n=r.visitFloat;break;case m.Float16:n=r.visitFloat16||r.visitFloat;break;case m.Float32:n=r.visitFloat32||r.visitFloat;break;case m.Float64:n=r.visitFloat64||r.visitFloat;break;case m.Utf8:n=r.visitUtf8;break;case m.LargeUtf8:n=r.visitLargeUtf8;break;case m.Binary:n=r.visitBinary;break;case m.LargeBinary:n=r.visitLargeBinary;break;case m.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case m.Date:n=r.visitDate;break;case m.DateDay:n=r.visitDateDay||r.visitDate;break;case m.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case m.Timestamp:n=r.visitTimestamp;break;case m.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case m.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case m.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case m.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case m.Time:n=r.visitTime;break;case m.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case m.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case m.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case m.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case m.Decimal:n=r.visitDecimal;break;case m.List:n=r.visitList;break;case m.Struct:n=r.visitStruct;break;case m.Union:n=r.visitUnion;break;case m.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case m.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case m.Dictionary:n=r.visitDictionary;break;case m.Interval:n=r.visitInterval;break;case m.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case m.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case m.Duration:n=r.visitDuration;break;case m.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case m.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case m.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case m.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case m.FixedSizeList:n=r.visitFixedSizeList;break;case m.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error("Unrecognized type '".concat(m[t],"'"))}function hd(r){switch(r.typeId){case m.Null:return m.Null;case m.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?m.Int8:m.Uint8;case 16:return e?m.Int16:m.Uint16;case 32:return e?m.Int32:m.Uint32;case 64:return e?m.Int64:m.Uint64}return m.Int}case m.Float:switch(r.precision){case Et.HALF:return m.Float16;case Et.SINGLE:return m.Float32;case Et.DOUBLE:return m.Float64}return m.Float;case m.Binary:return m.Binary;case m.LargeBinary:return m.LargeBinary;case m.Utf8:return m.Utf8;case m.LargeUtf8:return m.LargeUtf8;case m.Bool:return m.Bool;case m.Decimal:return m.Decimal;case m.Time:switch(r.unit){case C.SECOND:return m.TimeSecond;case C.MILLISECOND:return m.TimeMillisecond;case C.MICROSECOND:return m.TimeMicrosecond;case C.NANOSECOND:return m.TimeNanosecond}return m.Time;case m.Timestamp:switch(r.unit){case C.SECOND:return m.TimestampSecond;case C.MILLISECOND:return m.TimestampMillisecond;case C.MICROSECOND:return m.TimestampMicrosecond;case C.NANOSECOND:return m.TimestampNanosecond}return m.Timestamp;case m.Date:switch(r.unit){case $t.DAY:return m.DateDay;case $t.MILLISECOND:return m.DateMillisecond}return m.Date;case m.Interval:switch(r.unit){case Jt.DAY_TIME:return m.IntervalDayTime;case Jt.YEAR_MONTH:return m.IntervalYearMonth}return m.Interval;case m.Duration:switch(r.unit){case C.SECOND:return m.DurationSecond;case C.MILLISECOND:return m.DurationMillisecond;case C.MICROSECOND:return m.DurationMicrosecond;case C.NANOSECOND:return m.DurationNanosecond}return m.Duration;case m.Map:return m.Map;case m.List:return m.List;case m.Struct:return m.Struct;case m.Union:switch(r.mode){case Ot.Dense:return m.DenseUnion;case Ot.Sparse:return m.SparseUnion}return m.Union;case m.FixedSizeBinary:return m.FixedSizeBinary;case m.FixedSizeList:return m.FixedSizeList;case m.Dictionary:return m.Dictionary}throw new Error("Unrecognized type '".concat(m[r.typeId],"'"))}$.prototype.visitInt8=null;$.prototype.visitInt16=null;$.prototype.visitInt32=null;$.prototype.visitInt64=null;$.prototype.visitUint8=null;$.prototype.visitUint16=null;$.prototype.visitUint32=null;$.prototype.visitUint64=null;$.prototype.visitFloat16=null;$.prototype.visitFloat32=null;$.prototype.visitFloat64=null;$.prototype.visitDateDay=null;$.prototype.visitDateMillisecond=null;$.prototype.visitTimestampSecond=null;$.prototype.visitTimestampMillisecond=null;$.prototype.visitTimestampMicrosecond=null;$.prototype.visitTimestampNanosecond=null;$.prototype.visitTimeSecond=null;$.prototype.visitTimeMillisecond=null;$.prototype.visitTimeMicrosecond=null;$.prototype.visitTimeNanosecond=null;$.prototype.visitDenseUnion=null;$.prototype.visitSparseUnion=null;$.prototype.visitIntervalDayTime=null;$.prototype.visitIntervalYearMonth=null;$.prototype.visitDuration=null;$.prototype.visitDurationSecond=null;$.prototype.visitDurationMillisecond=null;$.prototype.visitDurationMicrosecond=null;$.prototype.visitDurationNanosecond=null;var Ja={};jr(Ja,{float64ToUint16:()=>Mi,uint16ToFloat64:()=>Ks});var pd=new Float64Array(1),jn=new Uint32Array(pd.buffer);function Ks(r){let t=(r&31744)>>10,e=(r&1023)/1024,n=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return n*(e?Number.NaN:1/0);case 0:return n*(e?6103515625e-14*e:0)}return n*Math.pow(2,t-15)*(1+e)}function Mi(r){if(r!==r)return 32256;pd[0]=r;let t=(jn[1]&2147483648)>>16&65535,e=jn[1]&2146435072,n=0;return e>=1089470464?jn[0]>0?e=31744:(e=(e&2080374784)>>16,n=(jn[1]&1048575)>>10):e<=1056964608?(n=1048576+(jn[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(jn[1]&1048575)+512>>10),t|e|n&65535}var X=class extends ${};function nt(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}var h_=(r,t,e)=>{r[t]=Math.floor(e/864e5)},md=(r,t,e,n)=>{if(e+1<t.length){let i=wt(t[e]),s=wt(t[e+1]);r.set(n.subarray(0,s-i),i)}},p_=({offset:r,values:t},e,n)=>{let i=r+e;n?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Er=({values:r},t,e)=>{r[t]=e},Xa=({values:r},t,e)=>{r[t]=e},_d=({values:r},t,e)=>{r[t]=Mi(e)},m_=(r,t,e)=>{switch(r.type.precision){case Et.HALF:return _d(r,t,e);case Et.SINGLE:case Et.DOUBLE:return Xa(r,t,e)}},Js=({values:r},t,e)=>{h_(r,t,e.valueOf())},Xs=({values:r},t,e)=>{r[t]=BigInt(e)},Za=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},yd=({values:r,valueOffsets:t},e,n)=>md(r,t,e,n),bd=({values:r,valueOffsets:t},e,n)=>md(r,t,e,er(n)),Qa=(r,t,e)=>{r.type.unit===$t.DAY?Js(r,t,e):Xs(r,t,e)},Zs=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},Qs=({values:r},t,e)=>{r[t]=BigInt(e)},to=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},eo=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},tc=(r,t,e)=>{switch(r.type.unit){case C.SECOND:return Zs(r,t,e);case C.MILLISECOND:return Qs(r,t,e);case C.MICROSECOND:return to(r,t,e);case C.NANOSECOND:return eo(r,t,e)}},ro=({values:r},t,e)=>{r[t]=e},no=({values:r},t,e)=>{r[t]=e},io=({values:r},t,e)=>{r[t]=e},so=({values:r},t,e)=>{r[t]=e},ec=(r,t,e)=>{switch(r.type.unit){case C.SECOND:return ro(r,t,e);case C.MILLISECOND:return no(r,t,e);case C.MICROSECOND:return io(r,t,e);case C.NANOSECOND:return so(r,t,e)}},rc=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},__=(r,t,e)=>{let n=r.children[0],i=r.valueOffsets,s=re.getVisitFn(n);if(Array.isArray(e))for(let a=-1,c=i[t],d=i[t+1];c<d;)s(n,c++,e[++a]);else for(let a=-1,c=i[t],d=i[t+1];c<d;)s(n,c++,e.get(++a))},y_=(r,t,e)=>{let n=r.children[0],{valueOffsets:i}=r,s=re.getVisitFn(n),{[t]:a,[t+1]:c}=i,d=e instanceof Map?e.entries():Object.entries(e);for(let h of d)if(s(n,a,h),++a>=c)break},b_=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[s]),g_=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(s)),w_=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(i.name)),v_=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[i.name]),S_=(r,t,e)=>{let n=r.type.children.map(s=>re.getVisitFn(s.type)),i=e instanceof Map?w_(t,e):e instanceof yt?g_(t,e):Array.isArray(e)?b_(t,e):v_(t,e);r.type.children.forEach((s,a)=>i(n[a],r.children[a],s,a))},I_=(r,t,e)=>{r.type.mode===Ot.Dense?gd(r,t,e):wd(r,t,e)},gd=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];re.visit(i,r.valueOffsets[t],e)},wd=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];re.visit(i,t,e)},D_=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},nc=(r,t,e)=>{r.type.unit===Jt.DAY_TIME?oo(r,t,e):ao(r,t,e)},oo=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},ao=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},co=({values:r},t,e)=>{r[t]=e},lo=({values:r},t,e)=>{r[t]=e},uo=({values:r},t,e)=>{r[t]=e},fo=({values:r},t,e)=>{r[t]=e},ic=(r,t,e)=>{switch(r.type.unit){case C.SECOND:return co(r,t,e);case C.MILLISECOND:return lo(r,t,e);case C.MICROSECOND:return uo(r,t,e);case C.NANOSECOND:return fo(r,t,e)}},B_=(r,t,e)=>{let{stride:n}=r,i=r.children[0],s=re.getVisitFn(i);if(Array.isArray(e))for(let a=-1,c=t*n;++a<n;)s(i,c+a,e[a]);else for(let a=-1,c=t*n;++a<n;)s(i,c+a,e.get(a))};X.prototype.visitBool=nt(p_);X.prototype.visitInt=nt(Er);X.prototype.visitInt8=nt(Er);X.prototype.visitInt16=nt(Er);X.prototype.visitInt32=nt(Er);X.prototype.visitInt64=nt(Er);X.prototype.visitUint8=nt(Er);X.prototype.visitUint16=nt(Er);X.prototype.visitUint32=nt(Er);X.prototype.visitUint64=nt(Er);X.prototype.visitFloat=nt(m_);X.prototype.visitFloat16=nt(_d);X.prototype.visitFloat32=nt(Xa);X.prototype.visitFloat64=nt(Xa);X.prototype.visitUtf8=nt(bd);X.prototype.visitLargeUtf8=nt(bd);X.prototype.visitBinary=nt(yd);X.prototype.visitLargeBinary=nt(yd);X.prototype.visitFixedSizeBinary=nt(Za);X.prototype.visitDate=nt(Qa);X.prototype.visitDateDay=nt(Js);X.prototype.visitDateMillisecond=nt(Xs);X.prototype.visitTimestamp=nt(tc);X.prototype.visitTimestampSecond=nt(Zs);X.prototype.visitTimestampMillisecond=nt(Qs);X.prototype.visitTimestampMicrosecond=nt(to);X.prototype.visitTimestampNanosecond=nt(eo);X.prototype.visitTime=nt(ec);X.prototype.visitTimeSecond=nt(ro);X.prototype.visitTimeMillisecond=nt(no);X.prototype.visitTimeMicrosecond=nt(io);X.prototype.visitTimeNanosecond=nt(so);X.prototype.visitDecimal=nt(rc);X.prototype.visitList=nt(__);X.prototype.visitStruct=nt(S_);X.prototype.visitUnion=nt(I_);X.prototype.visitDenseUnion=nt(gd);X.prototype.visitSparseUnion=nt(wd);X.prototype.visitDictionary=nt(D_);X.prototype.visitInterval=nt(nc);X.prototype.visitIntervalDayTime=nt(oo);X.prototype.visitIntervalYearMonth=nt(ao);X.prototype.visitDuration=nt(ic);X.prototype.visitDurationSecond=nt(co);X.prototype.visitDurationMillisecond=nt(lo);X.prototype.visitDurationMicrosecond=nt(uo);X.prototype.visitDurationNanosecond=nt(fo);X.prototype.visitFixedSizeList=nt(B_);X.prototype.visitMap=nt(y_);var re=new X;var qe=Symbol.for("parent"),$n=Symbol.for("rowIndex"),Qr=class{constructor(t,e){return this[qe]=t,this[$n]=e,new Proxy(this,new oc)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[$n],e=this[qe],n=e.type.children,i={};for(let s=-1,a=n.length;++s<a;)i[n[s].name]=Yt.visit(e.children[s],t);return i}toString(){return"{".concat([...this].map(([t,e])=>"".concat(We(t),": ").concat(We(e))).join(", "),"}")}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new sc(this[qe],this[$n])}},sc=class{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,Yt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(Qr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[qe]:{writable:!0,enumerable:!1,configurable:!1,value:null},[$n]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var oc=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[qe].type.children.map(e=>e.name)}has(t,e){return t[qe].type.children.findIndex(n=>n.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[qe].type.children.findIndex(n=>n.name===e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[qe].type.children.findIndex(i=>i.name===e);if(n!==-1){let i=Yt.visit(t[qe].children[n],t[$n]);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[qe].type.children.findIndex(s=>s.name===e);return i!==-1?(re.visit(t[qe].children[i],t[$n],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}};var G=class extends ${};function tt(r){return(t,e)=>t.getValid(e)?r(t,e):null}var F_=(r,t)=>864e5*r[t],A_=(r,t)=>null,vd=(r,t,e)=>{if(e+1>=t.length)return null;let n=wt(t[e]),i=wt(t[e+1]);return r.subarray(n,i)},T_=({offset:r,values:t},e)=>{let n=r+e;return(t[n>>3]&1<<n%8)!==0},Sd=({values:r},t)=>F_(r,t),Id=({values:r},t)=>wt(r[t]),tn=({stride:r,values:t},e)=>t[r*e],x_=({stride:r,values:t},e)=>Ks(t[r*e]),Dd=({values:r},t)=>r[t],E_=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Bd=({values:r,valueOffsets:t},e)=>vd(r,t,e),Fd=({values:r,valueOffsets:t},e)=>{let n=vd(r,t,e);return n!==null?mi(n):null},O_=({values:r},t)=>r[t],M_=({type:r,values:t},e)=>r.precision!==Et.HALF?t[e]:Ks(t[e]),U_=(r,t)=>r.type.unit===$t.DAY?Sd(r,t):Id(r,t),Ad=({values:r},t)=>1e3*wt(r[t]),Td=({values:r},t)=>wt(r[t]),xd=({values:r},t)=>Ga(r[t],BigInt(1e3)),Ed=({values:r},t)=>Ga(r[t],BigInt(1e6)),R_=(r,t)=>{switch(r.type.unit){case C.SECOND:return Ad(r,t);case C.MILLISECOND:return Td(r,t);case C.MICROSECOND:return xd(r,t);case C.NANOSECOND:return Ed(r,t)}},Od=({values:r},t)=>r[t],Md=({values:r},t)=>r[t],Ud=({values:r},t)=>r[t],Rd=({values:r},t)=>r[t],L_=(r,t)=>{switch(r.type.unit){case C.SECOND:return Od(r,t);case C.MILLISECOND:return Md(r,t);case C.MICROSECOND:return Ud(r,t);case C.NANOSECOND:return Rd(r,t)}},k_=({values:r,stride:t},e)=>Oi.decimal(r.subarray(t*e,t*(e+1))),N_=(r,t)=>{let{valueOffsets:e,stride:n,children:i}=r,{[t*n]:s,[t*n+1]:a}=e,d=i[0].slice(s,a-s);return new yt([d])},C_=(r,t)=>{let{valueOffsets:e,children:n}=r,{[t]:i,[t+1]:s}=e,a=n[0];return new ar(a.slice(i,s-i))},P_=(r,t)=>new Qr(r,t),H_=(r,t)=>r.type.mode===Ot.Dense?Ld(r,t):kd(r,t),Ld=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return Yt.visit(n,r.valueOffsets[t])},kd=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return Yt.visit(n,t)},V_=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},W_=(r,t)=>r.type.unit===Jt.DAY_TIME?Nd(r,t):Cd(r,t),Nd=({values:r},t)=>r.subarray(2*t,2*(t+1)),Cd=({values:r},t)=>{let e=r[t],n=new Int32Array(2);return n[0]=Math.trunc(e/12),n[1]=Math.trunc(e%12),n},Pd=({values:r},t)=>r[t],Hd=({values:r},t)=>r[t],Vd=({values:r},t)=>r[t],Wd=({values:r},t)=>r[t],z_=(r,t)=>{switch(r.type.unit){case C.SECOND:return Pd(r,t);case C.MILLISECOND:return Hd(r,t);case C.MICROSECOND:return Vd(r,t);case C.NANOSECOND:return Wd(r,t)}},j_=(r,t)=>{let{stride:e,children:n}=r,s=n[0].slice(t*e,e);return new yt([s])};G.prototype.visitNull=tt(A_);G.prototype.visitBool=tt(T_);G.prototype.visitInt=tt(O_);G.prototype.visitInt8=tt(tn);G.prototype.visitInt16=tt(tn);G.prototype.visitInt32=tt(tn);G.prototype.visitInt64=tt(Dd);G.prototype.visitUint8=tt(tn);G.prototype.visitUint16=tt(tn);G.prototype.visitUint32=tt(tn);G.prototype.visitUint64=tt(Dd);G.prototype.visitFloat=tt(M_);G.prototype.visitFloat16=tt(x_);G.prototype.visitFloat32=tt(tn);G.prototype.visitFloat64=tt(tn);G.prototype.visitUtf8=tt(Fd);G.prototype.visitLargeUtf8=tt(Fd);G.prototype.visitBinary=tt(Bd);G.prototype.visitLargeBinary=tt(Bd);G.prototype.visitFixedSizeBinary=tt(E_);G.prototype.visitDate=tt(U_);G.prototype.visitDateDay=tt(Sd);G.prototype.visitDateMillisecond=tt(Id);G.prototype.visitTimestamp=tt(R_);G.prototype.visitTimestampSecond=tt(Ad);G.prototype.visitTimestampMillisecond=tt(Td);G.prototype.visitTimestampMicrosecond=tt(xd);G.prototype.visitTimestampNanosecond=tt(Ed);G.prototype.visitTime=tt(L_);G.prototype.visitTimeSecond=tt(Od);G.prototype.visitTimeMillisecond=tt(Md);G.prototype.visitTimeMicrosecond=tt(Ud);G.prototype.visitTimeNanosecond=tt(Rd);G.prototype.visitDecimal=tt(k_);G.prototype.visitList=tt(N_);G.prototype.visitStruct=tt(P_);G.prototype.visitUnion=tt(H_);G.prototype.visitDenseUnion=tt(Ld);G.prototype.visitSparseUnion=tt(kd);G.prototype.visitDictionary=tt(V_);G.prototype.visitInterval=tt(W_);G.prototype.visitIntervalDayTime=tt(Nd);G.prototype.visitIntervalYearMonth=tt(Cd);G.prototype.visitDuration=tt(z_);G.prototype.visitDurationSecond=tt(Pd);G.prototype.visitDurationMillisecond=tt(Hd);G.prototype.visitDurationMicrosecond=tt(Vd);G.prototype.visitDurationNanosecond=tt(Wd);G.prototype.visitFixedSizeList=tt(j_);G.prototype.visitMap=tt(C_);var Yt=new G;var en=Symbol.for("keys"),Yn=Symbol.for("vals"),Gn=Symbol.for("kKeysAsStrings"),ac=Symbol.for("_kKeysAsStrings"),ar=class{constructor(t){return this[en]=new yt([t.children[0]]).memoize(),this[Yn]=t.children[1],new Proxy(this,new lc)}get[Gn](){return this[ac]||(this[ac]=Array.from(this[en].toArray(),String))}[Symbol.iterator](){return new cc(this[en],this[Yn])}get size(){return this[en].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[en],e=this[Yn],n={};for(let i=-1,s=t.length;++i<s;)n[t.get(i)]=Yt.visit(e,i);return n}toString(){return"{".concat([...this].map(([t,e])=>"".concat(We(t),": ").concat(We(e))).join(", "),"}")}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},cc=class{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){let t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),Yt.visit(this.vals,t)]})}},lc=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Gn]}has(t,e){return t[Gn].includes(e)}getOwnPropertyDescriptor(t,e){if(t[Gn].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[Gn].indexOf(e);if(n!==-1){let i=Yt.visit(Reflect.get(t,Yn),n);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[Gn].indexOf(e);return i!==-1?(re.visit(Reflect.get(t,Yn),i,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}};Object.defineProperties(ar.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[en]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Yn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ac]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var zd;function Ui(r,t,e,n){let{length:i=0}=r,s=typeof t!="number"?0:t,a=typeof e!="number"?i:e;return s<0&&(s=(s%i+i)%i),a<0&&(a=(a%i+i)%i),a<s&&(zd=s,s=a,a=zd),a>i&&(a=i),n?n(r,s,a):[s,a]}var hn=(r,t)=>r<0?t+r:r,jd=r=>r!==r;function rn(r){if(typeof r!=="object"||r===null)return jd(r)?jd:e=>e===r;if(r instanceof Date){let e=r.valueOf();return n=>n instanceof Date?n.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?Va(r,e):!1:r instanceof Map?G_(r):Array.isArray(r)?$_(r):r instanceof yt?Y_(r):q_(r,!0)}function $_(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=rn(r[e]);return ho(t)}function G_(r){let t=-1,e=[];for(let n of r.values())e[++t]=rn(n);return ho(e)}function Y_(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=rn(r.get(e));return ho(t)}function q_(r,t=!1){let e=Object.keys(r);if(!t&&e.length===0)return()=>!1;let n=[];for(let i=-1,s=e.length;++i<s;)n[i]=rn(r[e[i]]);return ho(n,e)}function ho(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return K_(r,e);case Map:return $d(r,e,e.keys());case ar:case Qr:case Object:case void 0:return $d(r,e,t||Object.keys(e))}return e instanceof yt?J_(r,e):!1}}function K_(r,t){let e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t[n]))return!1;return!0}function J_(r,t){let e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t.get(n)))return!1;return!0}function $d(r,t,e){let n=e[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator](),a=0,c=r.length,d=s.next(),h=n.next(),u=i.next();for(;a<c&&!h.done&&!u.done&&!d.done&&!(h.value!==u.value||!r[a](d.value));++a,h=n.next(),u=i.next(),d=s.next());return a===c&&h.done&&u.done&&d.done?!0:(n.return&&n.return(),i.return&&i.return(),s.return&&s.return(),!1)}var dc={};jr(dc,{BitIterator:()=>pn,getBit:()=>Gd,getBool:()=>mo,packBools:()=>_n,popcnt_array:()=>Yd,popcnt_bit_range:()=>Ri,popcnt_uint32:()=>po,setBool:()=>X_,truncateBitmap:()=>mn});function mo(r,t,e,n){return(e&1<<n)!==0}function Gd(r,t,e,n){return(e&1<<n)>>n}function X_(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function mn(r,t,e){let n=e.byteLength+7&-8;if(r>0||e.byteLength<n){let i=new Uint8Array(n);return i.set(r%8===0?e.subarray(r>>3):_n(new pn(e,r,t,null,mo)).subarray(0,n)),i}return e}function _n(r){let t=[],e=0,n=0,i=0;for(let a of r)a&&(i|=1<<n),++n===8&&(t[e++]=i,i=n=0);(e===0||n>0)&&(t[e++]=i);let s=new Uint8Array(t.length+7&-8);return s.set(t),s}var pn=class{constructor(t,e,n,i,s){this.bytes=t,this.length=n,this.context=i,this.get=s,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}};function Ri(r,t,e){if(e-t<=0)return 0;if(e-t<8){let s=0;for(let a of new pn(r,t,e-t,r,Gd))s+=a;return s}let n=e>>3<<3,i=t+(t%8===0?0:8-t%8);return Ri(r,t,i)+Ri(r,n,e)+Yd(r,i>>3,n-i>>3)}function Yd(r,t,e){let n=0,i=Math.trunc(t),s=new DataView(r.buffer,r.byteOffset,r.byteLength),a=e===void 0?r.byteLength:i+e;for(;a-i>=4;)n+=po(s.getUint32(i)),i+=4;for(;a-i>=2;)n+=po(s.getUint16(i)),i+=2;for(;a-i>=1;)n+=po(s.getUint8(i)),i+=1;return n}function po(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var Z_=-1,St=class r{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:t}=this;return k.isSparseUnion(t)?this.children.some(e=>e.nullable):k.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0,{valueOffsets:e,values:n,nullBitmap:i,typeIds:s}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((a,c)=>a+c.byteLength,t)}get nullCount(){if(k.isUnion(this.type))return this.children.reduce((n,i)=>n+i.nullCount,0);let t=this._nullCount,e;return t<=Z_&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Ri(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,i,s,a=[],c){this.type=t,this.children=a,this.dictionary=c,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let d;s instanceof r?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=Be(t),s&&((d=s[0])&&(this.valueOffsets=d),(d=s[1])&&(this.values=d),(d=s[2])&&(this.nullBitmap=d),(d=s[3])&&(this.typeIds=d)))}getValid(t){let{type:e}=this;if(k.isUnion(e)){let n=e,i=this.children[n.typeIdToChildIndex[this.typeIds[t]]],s=n.mode===Ot.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){let n=this.offset+t;return(this.nullBitmap[n>>3]&1<<n%8)!==0}return!0}setValid(t,e){let n,{type:i}=this;if(k.isUnion(i)){let s=i,a=this.children[s.typeIdToChildIndex[this.typeIds[t]]],c=s.mode===Ot.Dense?this.valueOffsets[t]:t;n=a.getValid(c),a.setValid(c,e)}else{let{nullBitmap:s}=this,{offset:a,length:c}=this,d=a+t,h=1<<d%8,u=d>>3;(!s||s.byteLength<=u)&&(s=new Uint8Array((a+c+63&-64)>>3).fill(255),this.nullCount>0?(s.set(mn(a,c,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let I=s[u];n=(I&h)!==0,s[u]=e?I|h:I&~h}return n!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,n=this.length,i=this._nullCount,s=this,a=this.children){return new r(t,e,n,i,s,a,this.dictionary)}slice(t,e){let{stride:n,typeId:i,children:s}=this,a=+(this._nullCount===0)-1,c=i===16?n:1,d=this._sliceBuffers(t,e,n,i);return this.clone(this.type,this.offset+t,e,a,d,s.length===0||this.valueOffsets?s:this._sliceChildren(s,c*t,c*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===m.Null)return this.clone(this.type,0,t,0);let{length:e,nullCount:n}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);i[e>>3]=(1<<e-(e&-8))-1,n>0&&i.set(mn(this.offset,e,this.nullBitmap),0);let s=this.buffers;return s[xe.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),s)}_sliceBuffers(t,e,n,i){let s,{buffers:a}=this;return(s=a[xe.TYPE])&&(a[xe.TYPE]=s.subarray(t,t+e)),(s=a[xe.OFFSET])&&(a[xe.OFFSET]=s.subarray(t,t+e+1))||(s=a[xe.DATA])&&(a[xe.DATA]=i===6?s:s.subarray(n*t,n*(t+e))),a}_sliceChildren(t,e,n){return t.map(i=>i.slice(e,n))}};St.prototype.children=Object.freeze([]);var fc=class r extends ${visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:e,["offset"]:n=0,["length"]:i=0}=t;return new St(e,n,i,i)}visitBool(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.nullBitmap),s=dt(e.ArrayType,t.data),{["length"]:a=s.length>>3,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new St(e,n,a,c,[void 0,s,i])}visitInt(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.nullBitmap),s=dt(e.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new St(e,n,a,c,[void 0,s,i])}visitFloat(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.nullBitmap),s=dt(e.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new St(e,n,a,c,[void 0,s,i])}visitUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.data),s=Z(t.nullBitmap),a=dn(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new St(e,n,c,d,[a,i,s])}visitLargeUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.data),s=Z(t.nullBitmap),a=Ms(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new St(e,n,c,d,[a,i,s])}visitBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.data),s=Z(t.nullBitmap),a=dn(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new St(e,n,c,d,[a,i,s])}visitLargeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.data),s=Z(t.nullBitmap),a=Ms(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new St(e,n,c,d,[a,i,s])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.nullBitmap),s=dt(e.ArrayType,t.data),{["length"]:a=s.length/Be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new St(e,n,a,c,[void 0,s,i])}visitDate(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.nullBitmap),s=dt(e.ArrayType,t.data),{["length"]:a=s.length/Be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new St(e,n,a,c,[void 0,s,i])}visitTimestamp(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.nullBitmap),s=dt(e.ArrayType,t.data),{["length"]:a=s.length/Be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new St(e,n,a,c,[void 0,s,i])}visitTime(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.nullBitmap),s=dt(e.ArrayType,t.data),{["length"]:a=s.length/Be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new St(e,n,a,c,[void 0,s,i])}visitDecimal(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.nullBitmap),s=dt(e.ArrayType,t.data),{["length"]:a=s.length/Be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new St(e,n,a,c,[void 0,s,i])}visitList(t){let{["type"]:e,["offset"]:n=0,["child"]:i}=t,s=Z(t.nullBitmap),a=dn(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new St(e,n,c,d,[a,void 0,s],[i])}visitStruct(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=Z(t.nullBitmap),{length:a=i.reduce((d,{length:h})=>Math.max(d,h),0),nullCount:c=t.nullBitmap?-1:0}=t;return new St(e,n,a,c,[void 0,void 0,s],i)}visitUnion(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=dt(e.ArrayType,t.typeIds),{["length"]:a=s.length,["nullCount"]:c=-1}=t;if(k.isSparseUnion(e))return new St(e,n,a,c,[void 0,void 0,void 0,s],i);let d=dn(t.valueOffsets);return new St(e,n,a,c,[d,void 0,void 0,s],i)}visitDictionary(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.nullBitmap),s=dt(e.indices.ArrayType,t.data),{["dictionary"]:a=new yt([new r().visit({type:e.dictionary})])}=t,{["length"]:c=s.length,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new St(e,n,c,d,[void 0,s,i],[],a)}visitInterval(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.nullBitmap),s=dt(e.ArrayType,t.data),{["length"]:a=s.length/Be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new St(e,n,a,c,[void 0,s,i])}visitDuration(t){let{["type"]:e,["offset"]:n=0}=t,i=Z(t.nullBitmap),s=dt(e.ArrayType,t.data),{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new St(e,n,a,c,[void 0,s,i])}visitFixedSizeList(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new r().visit({type:e.valueType})}=t,s=Z(t.nullBitmap),{["length"]:a=i.length/Be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new St(e,n,a,c,[void 0,void 0,s],[i])}visitMap(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new r().visit({type:e.childType})}=t,s=Z(t.nullBitmap),a=dn(t.valueOffsets),{["length"]:c=a.length-1,["nullCount"]:d=t.nullBitmap?-1:0}=t;return new St(e,n,c,d,[a,void 0,s],[i])}},Q_=new fc;function st(r){return Q_.visit(r)}var Li=class{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){let t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}};function qd(r){return r.some(t=>t.nullable)}function _o(r){return r.reduce((t,e)=>t+e.nullCount,0)}function yo(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function bo(r,t,e,n){let i=[];for(let s=-1,a=r.length;++s<a;){let c=r[s],d=t[s],{length:h}=c;if(d>=n)break;if(e>=d+h)continue;if(d>=e&&d+h<=n){i.push(c);continue}let u=Math.max(0,e-d),I=Math.min(n-d,h);i.push(c.slice(u,I-u))}return i.length===0&&i.push(r[0].slice(0,0)),i}function hc(r,t,e,n){let i=0,s=0,a=t.length-1;do{if(i>=a-1)return e<t[a]?n(r,i,e-t[i]):null;s=i+Math.trunc((a-i)*.5),e<t[s]?a=s:i=s}while(i<a)}function ki(r,t){return r.getValid(t)}function qn(r){function t(e,n,i){return r(e[n],i)}return function(e){let n=this.data;return hc(n,this._offsets,e,t)}}function go(r){let t;function e(n,i,s){return r(n[i],s,t)}return function(n,i){let s=this.data;t=i;let a=hc(s,this._offsets,n,e);return t=void 0,a}}function wo(r){let t;function e(n,i,s){let a=s,c=0,d=0;for(let h=i-1,u=n.length;++h<u;){let I=n[h];if(~(c=r(I,t,a)))return d+c;a=0,d+=I.length}return-1}return function(n,i){t=n;let s=this.data,a=typeof i!="number"?e(s,0,0):hc(s,this._offsets,i,e);return t=void 0,a}}var Y=class extends ${};function ty(r,t){return t===null&&r.length>0?0:-1}function ey(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(let i of new pn(e,r.offset+(t||0),r.length,e,mo)){if(!i)return n;++n}return-1}function ot(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case m.Union:break;case m.Dictionary:break;default:return ey(r,e)}let n=Yt.getVisitFn(r),i=rn(t);for(let s=(e||0)-1,a=r.length;++s<a;)if(i(n(r,s)))return s;return-1}function Kd(r,t,e){let n=Yt.getVisitFn(r),i=rn(t);for(let s=(e||0)-1,a=r.length;++s<a;)if(i(n(r,s)))return s;return-1}Y.prototype.visitNull=ty;Y.prototype.visitBool=ot;Y.prototype.visitInt=ot;Y.prototype.visitInt8=ot;Y.prototype.visitInt16=ot;Y.prototype.visitInt32=ot;Y.prototype.visitInt64=ot;Y.prototype.visitUint8=ot;Y.prototype.visitUint16=ot;Y.prototype.visitUint32=ot;Y.prototype.visitUint64=ot;Y.prototype.visitFloat=ot;Y.prototype.visitFloat16=ot;Y.prototype.visitFloat32=ot;Y.prototype.visitFloat64=ot;Y.prototype.visitUtf8=ot;Y.prototype.visitLargeUtf8=ot;Y.prototype.visitBinary=ot;Y.prototype.visitLargeBinary=ot;Y.prototype.visitFixedSizeBinary=ot;Y.prototype.visitDate=ot;Y.prototype.visitDateDay=ot;Y.prototype.visitDateMillisecond=ot;Y.prototype.visitTimestamp=ot;Y.prototype.visitTimestampSecond=ot;Y.prototype.visitTimestampMillisecond=ot;Y.prototype.visitTimestampMicrosecond=ot;Y.prototype.visitTimestampNanosecond=ot;Y.prototype.visitTime=ot;Y.prototype.visitTimeSecond=ot;Y.prototype.visitTimeMillisecond=ot;Y.prototype.visitTimeMicrosecond=ot;Y.prototype.visitTimeNanosecond=ot;Y.prototype.visitDecimal=ot;Y.prototype.visitList=ot;Y.prototype.visitStruct=ot;Y.prototype.visitUnion=ot;Y.prototype.visitDenseUnion=Kd;Y.prototype.visitSparseUnion=Kd;Y.prototype.visitDictionary=ot;Y.prototype.visitInterval=ot;Y.prototype.visitIntervalDayTime=ot;Y.prototype.visitIntervalYearMonth=ot;Y.prototype.visitDuration=ot;Y.prototype.visitDurationSecond=ot;Y.prototype.visitDurationMillisecond=ot;Y.prototype.visitDurationMicrosecond=ot;Y.prototype.visitDurationNanosecond=ot;Y.prototype.visitFixedSizeList=ot;Y.prototype.visitMap=ot;var yn=new Y;var q=class extends ${};function et(r){let{type:t}=r;if(r.nullCount===0&&r.stride===1&&(k.isInt(t)&&t.bitWidth!==64||k.isTime(t)&&t.bitWidth!==64||k.isFloat(t)&&t.precision!==Et.HALF))return new Li(r.data.length,n=>{let i=r.data[n];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new Li(r.data.length,n=>{let s=r.data[n].length,a=r.slice(e,e+s);return e+=s,new pc(a)})}var pc=class{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}};q.prototype.visitNull=et;q.prototype.visitBool=et;q.prototype.visitInt=et;q.prototype.visitInt8=et;q.prototype.visitInt16=et;q.prototype.visitInt32=et;q.prototype.visitInt64=et;q.prototype.visitUint8=et;q.prototype.visitUint16=et;q.prototype.visitUint32=et;q.prototype.visitUint64=et;q.prototype.visitFloat=et;q.prototype.visitFloat16=et;q.prototype.visitFloat32=et;q.prototype.visitFloat64=et;q.prototype.visitUtf8=et;q.prototype.visitLargeUtf8=et;q.prototype.visitBinary=et;q.prototype.visitLargeBinary=et;q.prototype.visitFixedSizeBinary=et;q.prototype.visitDate=et;q.prototype.visitDateDay=et;q.prototype.visitDateMillisecond=et;q.prototype.visitTimestamp=et;q.prototype.visitTimestampSecond=et;q.prototype.visitTimestampMillisecond=et;q.prototype.visitTimestampMicrosecond=et;q.prototype.visitTimestampNanosecond=et;q.prototype.visitTime=et;q.prototype.visitTimeSecond=et;q.prototype.visitTimeMillisecond=et;q.prototype.visitTimeMicrosecond=et;q.prototype.visitTimeNanosecond=et;q.prototype.visitDecimal=et;q.prototype.visitList=et;q.prototype.visitStruct=et;q.prototype.visitUnion=et;q.prototype.visitDenseUnion=et;q.prototype.visitSparseUnion=et;q.prototype.visitDictionary=et;q.prototype.visitInterval=et;q.prototype.visitIntervalDayTime=et;q.prototype.visitIntervalYearMonth=et;q.prototype.visitDuration=et;q.prototype.visitDurationSecond=et;q.prototype.visitDurationMillisecond=et;q.prototype.visitDurationMicrosecond=et;q.prototype.visitDurationNanosecond=et;q.prototype.visitFixedSizeList=et;q.prototype.visitMap=et;var Kn=new q;var Jd,Xd={},Zd={},yt=class r{constructor(t){var e,n,i;let s=t[0]instanceof r?t.flatMap(c=>c.data):t;if(s.length===0||s.some(c=>!(c instanceof St)))throw new TypeError("Vector constructor expects an Array of Data instances.");let a=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:c,set:d,indexOf:h}=Xd[a.typeId],u=s[0];this.isValid=I=>ki(u,I),this.get=I=>c(u,I),this.set=(I,T)=>d(u,I,T),this.indexOf=I=>h(u,I),this._offsets=[0,u.length];break}default:Object.setPrototypeOf(this,Zd[a.typeId]),this._offsets=yo(s);break}this.data=s,this.type=a,this.stride=Be(a),this.numChildren=(i=(n=a.children)===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return qd(this.data)}get nullCount(){return _o(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return"".concat(this.VectorName,"<").concat(this.type[Symbol.toStringTag],">")}get VectorName(){return"".concat(m[this.type.typeId],"Vector")}isValid(t){return!1}get(t){return null}at(t){return this.get(hn(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return Kn.visit(this)}concat(...t){return new r(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new r(Ui(this,t,e,({data:n,_offsets:i},s,a)=>bo(n,i,s,a)))}toJSON(){return[...this]}toArray(){let{type:t,data:e,length:n,stride:i,ArrayType:s}=this;switch(t.typeId){case m.Int:case m.Float:case m.Decimal:case m.Time:case m.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,n*i);default:return e.reduce((a,{values:c,length:d})=>(a.array.set(c.subarray(0,d*i),a.offset),a.offset+=d*i,a),{array:new s(n*i),offset:0}).array}}return[...this]}toString(){return"[".concat([...this].join(","),"]")}getChild(t){var e;return this.getChildAt((e=this.type.children)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new r(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return k.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(k.isDictionary(this.type)){let t=new vo(this.data[0].dictionary),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new r(e)}return new vo(this)}unmemoize(){if(k.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new r(e)}return this}};Jd=Symbol.toStringTag;yt[Jd]=(r=>{r.type=k.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;let t=Object.keys(m).map(e=>m[e]).filter(e=>typeof e=="number"&&e!==m.NONE);for(let e of t){let n=Yt.getVisitFnByTypeId(e),i=re.getVisitFnByTypeId(e),s=yn.getVisitFnByTypeId(e);Xd[e]={get:n,set:i,indexOf:s},Zd[e]=Object.create(r,{isValid:{value:qn(ki)},get:{value:qn(Yt.getVisitFnByTypeId(e))},set:{value:go(re.getVisitFnByTypeId(e))},indexOf:{value:wo(yn.getVisitFnByTypeId(e))}})}return"Vector"})(yt.prototype);var vo=class r extends yt{constructor(t){super(t.data);let e=this.get,n=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(a){let c=s[a];if(c!==void 0)return c;let d=e.call(this,a);return s[a]=d,d}}),Object.defineProperty(this,"set",{value(a,c){n.call(this,a,c),s[a]=c}}),Object.defineProperty(this,"slice",{value:(a,c)=>new r(i.call(this,a,c))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new yt(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function Qd(r){if(!r||r.length<=0)return function(i){return!0};let t="",e=r.filter(n=>n===n);return e.length>0&&(t="\n switch (x) {".concat(e.map(n=>"\n case ".concat(ry(n),":")).join(""),"\n return false;\n }")),r.length!==e.length&&(t="if (x !== x) return false;\n".concat(t)),new Function("x","".concat(t,"\nreturn true;"))}function ry(r){return typeof r!="bigint"?We(r):"".concat(We(r),"n")}function mc(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function tf(r,t=0){return r.length>=t?r.subarray(0,t):yi(new r.constructor(t),r,0)}var Ke=class{constructor(t,e=0,n=1){this.length=Math.ceil(e/n),this.buffer=new t(this.length),this.stride=n,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=t}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(t,e){return this}append(t){return this.set(this.length,t)}reserve(t){if(t>0){this.length+=t;let e=this.stride,n=this.length*e,i=this.buffer.length;n>=i&&this._resize(i===0?mc(n*1,this.BYTES_PER_ELEMENT):mc(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=mc(t*this.stride,this.BYTES_PER_ELEMENT);let e=tf(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=tf(this.buffer,t)}},Or=class extends Ke{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}},Jn=class extends Or{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){let{buffer:n}=this.reserve(t-this.length+1),i=t>>3,s=t%8,a=n[i]>>s&1;return e?a===0&&(n[i]|=1<<s,++this.numValid):a===1&&(n[i]&=~(1<<s),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},Xn=class extends Or{constructor(t){super(t.OffsetArrayType,1,1)}append(t){return this.set(this.length-1,t)}set(t,e){let n=this.length-1,i=this.reserve(t-n+1).buffer;return n<t++&&n>=0&&i.fill(i[n],n,t),i[t]=i[t-1]+e,this}flush(t=this.length-1){return t>this.length&&this.set(t-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(t+1)}};var Pt=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=Be(t),this._nulls=new Jn,e&&e.length>0&&(this._isValid=Qd(e))}toVector(){return new yt([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0,{_offsets:e,_values:n,_nulls:i,_typeIds:s,children:a}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),a.reduce((c,d)=>c+d.byteLength,t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((e,n)=>e+n.reservedByteLength,t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e="".concat(this.numChildren)){throw new Error('Cannot append children to non-nested type "'.concat(this.type,'"'))}getChildAt(t){return this.children[t]||null}flush(){let t,e,n,i,{type:s,length:a,nullCount:c,_typeIds:d,_offsets:h,_values:u,_nulls:I}=this;(e=d==null?void 0:d.flush(a))?i=h==null?void 0:h.flush(a):(i=h==null?void 0:h.flush(a))?t=u==null?void 0:u.flush(h.last()):t=u==null?void 0:u.flush(a),c>0&&(n=I==null?void 0:I.flush(a));let T=this.children.map(E=>E.flush());return this.clear(),st({type:s,length:a,nullCount:c,children:T,child:T[0],data:t,typeIds:e,nullBitmap:n,valueOffsets:i})}finish(){this.finished=!0;for(let t of this.children)t.finish();return this}clear(){var t,e,n,i;this.length=0,(t=this._nulls)===null||t===void 0||t.clear(),(e=this._values)===null||e===void 0||e.clear(),(n=this._offsets)===null||n===void 0||n.clear(),(i=this._typeIds)===null||i===void 0||i.clear();for(let s of this.children)s.clear();return this}};Pt.prototype.length=1;Pt.prototype.stride=1;Pt.prototype.children=null;Pt.prototype.finished=!1;Pt.prototype.nullValues=null;Pt.prototype._isValid=()=>!0;var qt=class extends Pt{constructor(t){super(t),this._values=new Or(this.ArrayType,0,this.stride)}setValue(t,e){let n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}},he=class extends Pt{constructor(t){super(t),this._pendingLength=0,this._offsets=new Xn(t.type)}setValue(t,e){let n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.length),this._pendingLength+=e instanceof ar?e[en].length:e.length,n.set(t,e)}setValid(t,e){return super.setValid(t,e)?!0:((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}};var bn=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,n,i){return t.prep(8,24),t.writeInt64(BigInt(i!=null?i:0)),t.pad(4),t.writeInt32(n),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var Fe=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):It.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new fe).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new bn).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}dictionariesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){let n=this.bb.__offset(this.bb_pos,10);return n?(e||new bn).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}recordBatchesLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Xt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,It.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}};var Bt=class r{constructor(t=[],e,n,i=It.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=_c(this.fields)),this.dictionaries=n,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return"Schema<{ ".concat(this.fields.map((t,e)=>"".concat(e,": ").concat(t)).join(", ")," }>")}select(t){let e=new Set(t),n=this.fields.filter(i=>e.has(i.name));return new r(n,this.metadata)}selectAt(t){let e=t.map(n=>this.fields[n]).filter(Boolean);return new r(e,this.metadata)}assign(...t){let e=t[0]instanceof r?t[0]:Array.isArray(t[0])?new r(t[0]):new r(t),n=[...this.fields],i=So(So(new Map,this.metadata),e.metadata),s=e.fields.filter(c=>{let d=n.findIndex(h=>h.name===c.name);return~d?(n[d]=c.clone({metadata:So(So(new Map,n[d].metadata),c.metadata)}))&&!1:!0}),a=_c(s,new Map);return new r([...n,...s],i,new Map([...this.dictionaries,...a]))}};Bt.prototype.fields=null;Bt.prototype.metadata=null;Bt.prototype.dictionaries=null;var ht=class r{static new(...t){let[e,n,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],n===void 0&&(n=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new r("".concat(e),n,i,s)}constructor(t,e,n=!1,i){this.name=t,this.type=e,this.nullable=n,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return"".concat(this.name,": ").concat(this.type)}clone(...t){let[e,n,i,s]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,n=this.type,i=this.nullable,s=this.metadata]=t:{name:e=this.name,type:n=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],r.new(e,n,i,s)}};ht.prototype.type=null;ht.prototype.name=null;ht.prototype.nullable=null;ht.prototype.metadata=null;function So(r,t){return new Map([...r||new Map,...t||new Map])}function _c(r,t=new Map){for(let e=-1,n=r.length;++e<n;){let s=r[e].type;if(k.isDictionary(s)){if(!t.has(s.id))t.set(s.id,s.dictionary);else if(t.get(s.id)!==s.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}s.children&&s.children.length>0&&_c(s.children,t)}return t}var ny=fn,iy=Se,Mr=class{static decode(t){t=new iy(Z(t));let e=Fe.getRootAsFooter(t),n=Bt.decode(e.schema(),new Map,e.version());return new yc(n,e)}static encode(t){let e=new ny,n=Bt.encode(e,t.schema);Fe.startRecordBatchesVector(e,t.numRecordBatches);for(let a of[...t.recordBatches()].slice().reverse())Ur.encode(e,a);let i=e.endVector();Fe.startDictionariesVector(e,t.numDictionaries);for(let a of[...t.dictionaryBatches()].slice().reverse())Ur.encode(e,a);let s=e.endVector();return Fe.startFooter(e),Fe.addSchema(e,n),Fe.addVersion(e,It.V5),Fe.addRecordBatches(e,i),Fe.addDictionaries(e,s),Fe.finishFooterBuffer(e,Fe.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=It.V5,n,i){this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e<n;)(t=this.getRecordBatch(e))&&(yield t)}*dictionaryBatches(){for(let t,e=-1,n=this.numDictionaries;++e<n;)(t=this.getDictionaryBatch(e))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}};var yc=class extends Mr{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,e){super(t,e.version()),this._footer=e}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){let e=this._footer.recordBatches(t);if(e)return Ur.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return Ur.decode(e)}return null}},Ur=class r{static decode(t){return new r(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){let{metaDataLength:n}=e,i=BigInt(e.offset),s=BigInt(e.bodyLength);return bn.createBlock(t,i,n,s)}constructor(t,e,n){this.metaDataLength=t,this.offset=wt(n),this.bodyLength=wt(e)}};var Ct=Object.freeze({done:!0,value:void 0}),Ni=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},gn=class{tee(){return this._getDOMStream().tee()}pipe(t,e){return this._getNodeStream().pipe(t,e)}pipeTo(t,e){return this._getDOMStream().pipeTo(t,e)}pipeThrough(t,e){return this._getDOMStream().pipeThrough(t,e)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}},Io=class extends gn{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return L(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){let{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(Ct);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return ee.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return ee.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return L(this,void 0,void 0,function*(){return yield this.abort(t),Ct})}return(t){return L(this,void 0,void 0,function*(){return yield this.close(),Ct})}read(t){return L(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return L(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,n)=>{this.resolvers.push({resolve:e,reject:n})}):Promise.resolve(Ct)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var cr=class extends Io{write(t){if((t=Z(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?mi(this.toUint8Array(!0)):this.toUint8Array(!1).then(mi)}toUint8Array(t=!1){return t?ve(this._values)[0]:L(this,void 0,void 0,function*(){var e,n,i,s;let a=[],c=0;try{for(var d=!0,h=Le(this),u;u=yield h.next(),e=u.done,!e;d=!0){s=u.value,d=!1;let I=s;a.push(I),c+=I.byteLength}}catch(I){n={error:I}}finally{try{!d&&!e&&(i=h.return)&&(yield i.call(h))}finally{if(n)throw n.error}}return ve(a,c)[0]})}},lr=class{constructor(t){t&&(this.source=new bc(ee.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},Oe=class r{constructor(t){t instanceof r?this.source=t.source:t instanceof cr?this.source=new Rr(ee.fromAsyncIterable(t)):Os(t)?this.source=new Rr(ee.fromNodeStream(t)):_i(t)?this.source=new Rr(ee.fromDOMStream(t)):xs(t)?this.source=new Rr(ee.fromDOMStream(t.body)):Ne(t)?this.source=new Rr(ee.fromIterable(t)):ke(t)?this.source=new Rr(ee.fromAsyncIterable(t)):Ae(t)&&(this.source=new Rr(ee.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},bc=class{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||Ct)}return(t){return Object.create(this.source.return&&this.source.return(t)||Ct)}},Rr=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return L(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return L(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return L(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return L(this,arguments,void 0,function*(e,n="read"){return yield this.source.next({cmd:n,size:e})})}throw(t){return L(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||Ct;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return L(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||Ct;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var Ci=class extends lr{constructor(t,e){super(),this.position=0,this.buffer=Z(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){let{buffer:e,byteOffset:n}=this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){let{buffer:e,size:n,position:i}=this;return e&&i<n?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(n,i+Math.min(n-i,t)),e.subarray(i,this.position)):null}readAt(t,e){let n=this.buffer,i=Math.min(this.size,t+e);return n?n.subarray(t,i):new Uint8Array(e)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}},nn=class extends Oe{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=L(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return L(this,void 0,void 0,function*(){let{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return L(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return L(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:n,position:i}=this;if(e&&i<n){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,a=0,c=0,d=Math.min(n,s+Math.min(n-s,t)),h=new Uint8Array(Math.max(0,(this.position=d)-s));for(;(s+=c)<d&&(a+=c)<h.byteLength;)({bytesRead:c}=yield e.read(h,a,h.byteLength-a,s));return h}return null})}readAt(t,e){return L(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:n,size:i}=this;if(n&&t+e<i){let s=Math.min(i,t+e),a=new Uint8Array(s-t);return(yield n.read(a,0,e,t)).buffer}return new Uint8Array(e)})}close(){return L(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return L(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return L(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var wc={};jr(wc,{BaseInt64:()=>Pi,Int128:()=>Hi,Int64:()=>Lr,Uint64:()=>zt});function Zn(r){return r<0&&(r=4294967295+r+1),"0x".concat(r.toString(16))}var Qn=8,gc=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],Pi=class{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){let e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]),i=e[3]*n[3];this.buffer[0]=i&65535;let s=i>>>16;return i=e[2]*n[3],s+=i,i=e[3]*n[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?65536:0,this.buffer[1]+=s>>>16,this.buffer[1]+=e[1]*n[3]+e[2]*n[2]+e[3]*n[1],this.buffer[1]+=e[0]*n[3]+e[1]*n[2]+e[2]*n[1]+e[3]*n[0]<<16,this}_plus(t){let e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return"".concat(Zn(this.buffer[1])," ").concat(Zn(this.buffer[0]))}},zt=class r extends Pi{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.length,i=new r(e);for(let s=0;s<n;){let a=Qn<n-s?Qn:n-s,c=new r(new Uint32Array([Number.parseInt(t.slice(s,s+a),10),0])),d=new r(new Uint32Array([gc[a],0]));i.times(d),i.plus(c),s+=a}return i}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},Lr=class r extends Pi{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){let e=this.buffer[1]<<0,n=t.buffer[1]<<0;return e<n||e===n&&this.buffer[0]<t.buffer[0]}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.startsWith("-"),i=t.length,s=new r(e);for(let a=n?1:0;a<i;){let c=Qn<i-a?Qn:i-a,d=new r(new Uint32Array([Number.parseInt(t.slice(a,a+c),10),0])),h=new r(new Uint32Array([gc[c],0]));s.times(h),s.plus(d),a+=c}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},Hi=class r{constructor(t){this.buffer=t}high(){return new Lr(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Lr(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){let e=new zt(new Uint32Array([this.buffer[3],0])),n=new zt(new Uint32Array([this.buffer[2],0])),i=new zt(new Uint32Array([this.buffer[1],0])),s=new zt(new Uint32Array([this.buffer[0],0])),a=new zt(new Uint32Array([t.buffer[3],0])),c=new zt(new Uint32Array([t.buffer[2],0])),d=new zt(new Uint32Array([t.buffer[1],0])),h=new zt(new Uint32Array([t.buffer[0],0])),u=zt.multiply(s,h);this.buffer[0]=u.low();let I=new zt(new Uint32Array([u.high(),0]));return u=zt.multiply(i,h),I.plus(u),u=zt.multiply(s,d),I.plus(u),this.buffer[1]=I.low(),this.buffer[3]=I.lessThan(u)?1:0,this.buffer[2]=I.high(),new zt(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(zt.multiply(n,h)).plus(zt.multiply(i,d)).plus(zt.multiply(s,c)),this.buffer[3]+=zt.multiply(e,h).plus(zt.multiply(n,d)).plus(zt.multiply(i,c)).plus(zt.multiply(s,a)).low(),this}plus(t){let e=new Uint32Array(4);return e[3]=this.buffer[3]+t.buffer[3]>>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]<this.buffer[0]>>>0&&++e[1],e[1]<this.buffer[1]>>>0&&++e[2],e[2]<this.buffer[2]>>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return"".concat(Zn(this.buffer[3])," ").concat(Zn(this.buffer[2])," ").concat(Zn(this.buffer[1])," ").concat(Zn(this.buffer[0]))}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let n=t.startsWith("-"),i=t.length,s=new r(e);for(let a=n?1:0;a<i;){let c=Qn<i-a?Qn:i-a,d=new r(new Uint32Array([Number.parseInt(t.slice(a,a+c),10),0,0,0])),h=new r(new Uint32Array([gc[c],0,0,0]));s.times(h),s.plus(d),a+=c}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*4);for(let n=-1,i=t.length;++n<i;)r.from(t[n],new Uint32Array(e.buffer,e.byteOffset+4*4*n,4));return e}};var Vi=class extends ${constructor(t,e,n,i,s=It.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=e,this.buffers=n,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof ht?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return st({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),children:this.visitMany(t.children)})}visitUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return this.metadataVersion<It.V5&&this.readNullBitmap(t,n),t.mode===Ot.Sparse?this.visitSparseUnion(t,{length:e,nullCount:n}):this.visitDenseUnion(t,{length:e,nullCount:n})}visitDenseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),child:this.visit(t.children[0])})}visitMap(t,{length:e,nullCount:n}=this.nextFieldNode()){return st({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,e,n=this.nextBufferRange()){return e>0&&this.readData(t,n)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+e)}readDictionary(t){return this.dictionaries.get(t.id)}},Do=class extends Vi{constructor(t,e,n,i,s){super(new Uint8Array(0),e,n,i,s),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):_n(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return dt(Uint8Array,dt(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return dt(Uint8Array,dt(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;return k.isTimestamp(t)?dt(Uint8Array,Lr.convertArray(n[e])):(k.isInt(t)||k.isTime(t))&&t.bitWidth===64||k.isDuration(t)?dt(Uint8Array,Lr.convertArray(n[e])):k.isDate(t)&&t.unit===$t.MILLISECOND?dt(Uint8Array,Lr.convertArray(n[e])):k.isDecimal(t)?dt(Uint8Array,Hi.convertArray(n[e])):k.isBinary(t)||k.isLargeBinary(t)||k.isFixedSizeBinary(t)?sy(n[e]):k.isBool(t)?_n(n[e]):k.isUtf8(t)||k.isLargeUtf8(t)?er(n[e].join("")):dt(Uint8Array,dt(t.ArrayType,n[e].map(i=>+i)))}};function sy(r){let t=r.join(""),e=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)e[n>>1]=Number.parseInt(t.slice(n,n+2),16);return e}var ti=class extends he{constructor(t){super(t),this._values=new Ke(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Z(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[a,c]of t)if(c===void 0)n.set(a,0);else{let d=c.length;i.set(c,s),n.set(a,d),s+=d}}};var ei=class extends he{constructor(t){super(t),this._values=new Ke(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Z(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[a,c]of t)if(c===void 0)n.set(a,BigInt(0));else{let d=c.length;i.set(c,s),n.set(a,BigInt(d)),s+=d}}};var Bo=class extends Pt{constructor(t){super(t),this._values=new Jn}setValue(t,e){this._values.set(t,+e)}};var wn=class extends qt{};wn.prototype._setValue=Qa;var Wi=class extends wn{};Wi.prototype._setValue=Js;var zi=class extends wn{};zi.prototype._setValue=Xs;var ji=class extends qt{};ji.prototype._setValue=rc;var Fo=class extends Pt{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new De(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=vn({type:this.type.indices,nullValues:e}),this.dictionary=vn({type:this.type.dictionary,nullValues:null}),typeof n=="function"&&(this.valueToKey=n)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(t){return this.indices.isValid(t)}setValid(t,e){let n=this.indices;return e=n.setValid(t,e),this.length=n.length,e}setValue(t,e){let n=this._keysToIndices,i=this.valueToKey(e),s=n[i];return s===void 0&&(n[i]=s=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,s)}flush(){let t=this.type,e=this._dictionary,n=this.dictionary.toVector(),i=this.indices.flush().clone(t);return i.dictionary=e?e.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=i.dictionary,this.clear(),i}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(t){return typeof t=="string"?t:"".concat(t)}};var $i=class extends qt{};$i.prototype._setValue=Za;var Ao=class extends Pt{setValue(t,e){let[n]=this.children,i=t*this.stride;for(let s=-1,a=e.length;++s<a;)n.set(i+s,e[s])}addChild(t,e="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");let n=this.children.push(t);return this.type=new Ge(this.type.listSize,new ht(e,t.type,!0)),n}};var Sn=class extends qt{setValue(t,e){this._values.set(t,e)}},To=class extends Sn{setValue(t,e){super.setValue(t,Mi(e))}},xo=class extends Sn{},Eo=class extends Sn{};var In=class extends qt{};In.prototype._setValue=nc;var Gi=class extends In{};Gi.prototype._setValue=oo;var Yi=class extends In{};Yi.prototype._setValue=ao;var kr=class extends qt{};kr.prototype._setValue=ic;var qi=class extends kr{};qi.prototype._setValue=co;var Ki=class extends kr{};Ki.prototype._setValue=lo;var Ji=class extends kr{};Ji.prototype._setValue=uo;var Xi=class extends kr{};Xi.prototype._setValue=fo;var Me=class extends qt{setValue(t,e){this._values.set(t,e)}},Oo=class extends Me{},Mo=class extends Me{},Uo=class extends Me{},Ro=class extends Me{},Lo=class extends Me{},ko=class extends Me{},No=class extends Me{},Co=class extends Me{};var Po=class extends he{constructor(t){super(t),this._offsets=new Xn(t.type)}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new je(new ht(e,t.type,!0)),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(typeof s>"u")e.set(i,0);else{let a=s,c=a.length,d=e.set(i,c).buffer[i];for(let h=-1;++h<c;)n.set(d+h,a[h])}}};var Ho=class extends he{set(t,e){return super.set(t,e)}setValue(t,e){let n=e instanceof Map?e:new Map(Object.entries(e)),i=this._pending||(this._pending=new Map),s=i.get(t);s&&(this._pendingLength-=s.size),this._pendingLength+=n.size,i.set(t,n)}addChild(t,e="".concat(this.numChildren)){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new Ye(new ht(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(s===void 0)e.set(i,0);else{let{[i]:a,[i+1]:c}=e.set(i,s.size).buffer;for(let d of s.entries())if(n.set(a,d),++a>=c)break}}};var Vo=class extends Pt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var Wo=class extends Pt{setValue(t,e){let{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach((s,a)=>n[a].set(t,e[a]));case Map:return i.children.forEach((s,a)=>n[a].set(t,e.get(s.name)));default:return i.children.forEach((s,a)=>n[a].set(t,e[s.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(n=>n.setValid(t,e)),e}addChild(t,e="".concat(this.numChildren)){let n=this.children.push(t);return this.type=new Nt([...this.type.children,new ht(e,t.type,!0)]),n}};var Nr=class extends qt{};Nr.prototype._setValue=tc;var Zi=class extends Nr{};Zi.prototype._setValue=Zs;var Qi=class extends Nr{};Qi.prototype._setValue=Qs;var ts=class extends Nr{};ts.prototype._setValue=to;var es=class extends Nr{};es.prototype._setValue=eo;var Cr=class extends qt{};Cr.prototype._setValue=ec;var rs=class extends Cr{};rs.prototype._setValue=ro;var ns=class extends Cr{};ns.prototype._setValue=no;var is=class extends Cr{};is.prototype._setValue=io;var ss=class extends Cr{};ss.prototype._setValue=so;var ri=class extends Pt{constructor(t){super(t),this._typeIds=new Or(Int8Array,0,1),typeof t.valueToChildTypeId=="function"&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,n){return n===void 0&&(n=this._valueToChildTypeId(this,e,t)),this.setValue(t,e,n),this}setValue(t,e,n){this._typeIds.set(t,n);let i=this.type.typeIdToChildIndex[n],s=this.children[i];s==null||s.set(t,e)}addChild(t,e="".concat(this.children.length)){let n=this.children.push(t),{type:{children:i,mode:s,typeIds:a}}=this,c=[...i,new ht(e,t.type)];return this.type=new $e(s,[...a,n],c),n}_valueToChildTypeId(t,e,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},zo=class extends ri{},jo=class extends ri{constructor(t){super(t),this._offsets=new Or(Int32Array)}setValue(t,e,n){let i=this._typeIds.set(t,n).buffer[t],s=this.getChildAt(this.type.typeIdToChildIndex[i]),a=this._offsets.set(t,s.length).buffer[t];s==null||s.set(a,e)}};var os=class extends he{constructor(t){super(t),this._values=new Ke(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,er(e))}_flushPending(t,e){}};os.prototype._flushPending=ti.prototype._flushPending;var as=class extends he{constructor(t){super(t),this._values=new Ke(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,er(e))}_flushPending(t,e){}};as.prototype._flushPending=ei.prototype._flushPending;var vc=class extends ${visitNull(){return Vo}visitBool(){return Bo}visitInt(){return Me}visitInt8(){return Oo}visitInt16(){return Mo}visitInt32(){return Uo}visitInt64(){return Ro}visitUint8(){return Lo}visitUint16(){return ko}visitUint32(){return No}visitUint64(){return Co}visitFloat(){return Sn}visitFloat16(){return To}visitFloat32(){return xo}visitFloat64(){return Eo}visitUtf8(){return os}visitLargeUtf8(){return as}visitBinary(){return ti}visitLargeBinary(){return ei}visitFixedSizeBinary(){return $i}visitDate(){return wn}visitDateDay(){return Wi}visitDateMillisecond(){return zi}visitTimestamp(){return Nr}visitTimestampSecond(){return Zi}visitTimestampMillisecond(){return Qi}visitTimestampMicrosecond(){return ts}visitTimestampNanosecond(){return es}visitTime(){return Cr}visitTimeSecond(){return rs}visitTimeMillisecond(){return ns}visitTimeMicrosecond(){return is}visitTimeNanosecond(){return ss}visitDecimal(){return ji}visitList(){return Po}visitStruct(){return Wo}visitUnion(){return ri}visitDenseUnion(){return jo}visitSparseUnion(){return zo}visitDictionary(){return Fo}visitInterval(){return In}visitIntervalDayTime(){return Gi}visitIntervalYearMonth(){return Yi}visitDuration(){return kr}visitDurationSecond(){return qi}visitDurationMillisecond(){return Ki}visitDurationMicrosecond(){return Ji}visitDurationNanosecond(){return Xi}visitFixedSizeList(){return Ao}visitMap(){return Ho}},ef=new vc;var K=class extends ${compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((n,i)=>this.compareFields(n,e[i]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}};function ue(r,t){return t instanceof r.constructor}function Dn(r,t){return r===t||ue(r,t)}function Pr(r,t){return r===t||ue(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function $o(r,t){return r===t||ue(r,t)&&r.precision===t.precision}function oy(r,t){return r===t||ue(r,t)&&r.byteWidth===t.byteWidth}function Sc(r,t){return r===t||ue(r,t)&&r.unit===t.unit}function cs(r,t){return r===t||ue(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function ls(r,t){return r===t||ue(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function ay(r,t){return r===t||ue(r,t)&&r.children.length===t.children.length&&ur.compareManyFields(r.children,t.children)}function cy(r,t){return r===t||ue(r,t)&&r.children.length===t.children.length&&ur.compareManyFields(r.children,t.children)}function Ic(r,t){return r===t||ue(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&ur.compareManyFields(r.children,t.children)}function ly(r,t){return r===t||ue(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&ur.visit(r.indices,t.indices)&&ur.visit(r.dictionary,t.dictionary)}function Dc(r,t){return r===t||ue(r,t)&&r.unit===t.unit}function us(r,t){return r===t||ue(r,t)&&r.unit===t.unit}function uy(r,t){return r===t||ue(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&ur.compareManyFields(r.children,t.children)}function dy(r,t){return r===t||ue(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&ur.compareManyFields(r.children,t.children)}K.prototype.visitNull=Dn;K.prototype.visitBool=Dn;K.prototype.visitInt=Pr;K.prototype.visitInt8=Pr;K.prototype.visitInt16=Pr;K.prototype.visitInt32=Pr;K.prototype.visitInt64=Pr;K.prototype.visitUint8=Pr;K.prototype.visitUint16=Pr;K.prototype.visitUint32=Pr;K.prototype.visitUint64=Pr;K.prototype.visitFloat=$o;K.prototype.visitFloat16=$o;K.prototype.visitFloat32=$o;K.prototype.visitFloat64=$o;K.prototype.visitUtf8=Dn;K.prototype.visitLargeUtf8=Dn;K.prototype.visitBinary=Dn;K.prototype.visitLargeBinary=Dn;K.prototype.visitFixedSizeBinary=oy;K.prototype.visitDate=Sc;K.prototype.visitDateDay=Sc;K.prototype.visitDateMillisecond=Sc;K.prototype.visitTimestamp=cs;K.prototype.visitTimestampSecond=cs;K.prototype.visitTimestampMillisecond=cs;K.prototype.visitTimestampMicrosecond=cs;K.prototype.visitTimestampNanosecond=cs;K.prototype.visitTime=ls;K.prototype.visitTimeSecond=ls;K.prototype.visitTimeMillisecond=ls;K.prototype.visitTimeMicrosecond=ls;K.prototype.visitTimeNanosecond=ls;K.prototype.visitDecimal=Dn;K.prototype.visitList=ay;K.prototype.visitStruct=cy;K.prototype.visitUnion=Ic;K.prototype.visitDenseUnion=Ic;K.prototype.visitSparseUnion=Ic;K.prototype.visitDictionary=ly;K.prototype.visitInterval=Dc;K.prototype.visitIntervalDayTime=Dc;K.prototype.visitIntervalYearMonth=Dc;K.prototype.visitDuration=us;K.prototype.visitDurationSecond=us;K.prototype.visitDurationMillisecond=us;K.prototype.visitDurationMicrosecond=us;K.prototype.visitDurationNanosecond=us;K.prototype.visitFixedSizeList=uy;K.prototype.visitMap=dy;var ur=new K;function Bn(r,t){return ur.compareSchemas(r,t)}function rf(r,t){return ur.compareFields(r,t)}function nf(r,t){return ur.visit(r,t)}function vn(r){let t=r.type,e=new(ef.getVisitFn(t)())(r);if(t.children&&t.children.length>0){let n=r.children||[],i={nullValues:r.nullValues},s=Array.isArray(n)?(a,c)=>n[c]||i:({name:a})=>n[a]||i;for(let[a,c]of t.children.entries()){let{type:d}=c,h=s(c,a);e.children.push(vn(Object.assign(Object.assign({},h),{type:d})))}}return e}function Go(r,t){return fy(r,t.map(e=>e.data.concat()))}function fy(r,t){let e=[...r.fields],n=[],i={numBatches:t.reduce((I,T)=>Math.max(I,T.length),0)},s=0,a=0,c=-1,d=t.length,h,u=[];for(;i.numBatches-- >0;){for(a=Number.POSITIVE_INFINITY,c=-1;++c<d;)u[c]=h=t[c].shift(),a=Math.min(a,h?h.length:a);Number.isFinite(a)&&(u=hy(e,a,u,t,i),a>0&&(n[s++]=st({type:new Nt(e),length:a,nullCount:0,children:u.slice()})))}return[r=r.assign(e),n.map(I=>new Gt(r,I))]}function hy(r,t,e,n,i){var s;let a=(t+63&-64)>>3;for(let c=-1,d=n.length;++c<d;){let h=e[c],u=h==null?void 0:h.length;if(u>=t)u===t?e[c]=h:(e[c]=h.slice(0,t),i.numBatches=Math.max(i.numBatches,n[c].unshift(h.slice(t,u-t))));else{let I=r[c];r[c]=I.clone({nullable:!0}),e[c]=(s=h==null?void 0:h._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:st({type:I.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return e}var sf,de=class r{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new Bt([]),this._offsets=[0],this;let i,s;t[0]instanceof Bt&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let a=d=>{if(d){if(d instanceof Gt)return[d];if(d instanceof r)return d.batches;if(d instanceof St){if(d.type instanceof Nt)return[new Gt(new Bt(d.type.children),d)]}else{if(Array.isArray(d))return d.flatMap(h=>a(h));if(typeof d[Symbol.iterator]=="function")return[...d].flatMap(h=>a(h));if(typeof d=="object"){let h=Object.keys(d),u=h.map(E=>new yt([d[E]])),I=i!=null?i:new Bt(h.map((E,ft)=>new ht(String(E),u[ft].type,u[ft].nullable))),[,T]=Go(I,u);return T.length===0?[new Gt(d)]:T}}}return[]},c=t.flatMap(d=>a(d));if(i=(n=i!=null?i:(e=c[0])===null||e===void 0?void 0:e.schema)!==null&&n!==void 0?n:new Bt([]),!(i instanceof Bt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let d of c){if(!(d instanceof Gt))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Bn(i,d.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=c,this._offsets=s!=null?s:yo(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,e)=>t+e.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=_o(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(hn(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?Kn.visit(new yt(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return"[\n ".concat(this.toArray().join(",\n "),"\n]")}concat(...t){let e=this.schema,n=this.data.concat(t.flatMap(({data:i})=>i));return new r(e,n.map(i=>new Gt(e,i)))}slice(t,e){let n=this.schema;[t,e]=Ui({length:this.numRows},t,e);let i=bo(this.data,this._offsets,t,e);return new r(n,i.map(s=>new Gt(n,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){let e=this.data.map(n=>n.children[t]);if(e.length===0){let{type:n}=this.schema.fields[t],i=st({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new yt(e)}return null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new yt([st({type:new le,length:this.numRows})]));let s=n.fields.slice(),a=s[t].clone({type:e.type}),c=this.schema.fields.map((d,h)=>this.getChildAt(h));[s[t],c[t]]=[a,e],[n,i]=Go(n,c)}return new r(n,i)}select(t){let e=this.schema.fields.reduce((n,i,s)=>n.set(i.name,s),new Map);return this.selectAt(t.map(n=>e.get(n)).filter(n=>n>-1))}selectAt(t){let e=this.schema.selectAt(t),n=this.batches.map(i=>i.selectAt(t));return new r(e,n)}assign(t){let e=this.schema.fields,[n,i]=t.schema.fields.reduce((c,d,h)=>{let[u,I]=c,T=e.findIndex(E=>E.name===d.name);return~T?I[T]=h:u.push(h),c},[[],[]]),s=this.schema.assign(t.schema),a=[...e.map((c,d)=>[d,i[d]]).map(([c,d])=>d===void 0?this.getChildAt(c):t.getChildAt(d)),...n.map(c=>t.getChildAt(c))].filter(Boolean);return new r(...Go(s,a))}};sf=Symbol.toStringTag;de[sf]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=qn(ki),r.get=qn(Yt.getVisitFn(m.Struct)),r.set=go(re.getVisitFn(m.Struct)),r.indexOf=wo(yn.getVisitFn(m.Struct)),"Table"))(de.prototype);var af,Gt=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof Bt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=st({nullCount:0,type:new Nt(this.schema.fields),children:this.schema.fields.map(e=>st({type:e.type,nullCount:0}))})]=t,!(this.data instanceof St))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=of(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:n,children:i,length:s}=Object.keys(e).reduce((d,h,u)=>(d.children[u]=e[h],d.length=Math.max(d.length,e[h].length),d.fields[u]=ht.new({name:h,type:e[h].type,nullable:!0}),d),{length:0,fields:new Array,children:new Array}),a=new Bt(n),c=st({type:new Nt(n),length:s,children:i,nullCount:0});[this.schema,this.data]=of(a,c.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=cf(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return Yt.visit(this.data,t)}at(t){return this.get(hn(t,this.numRows))}set(t,e){return re.visit(this.data,t,e)}indexOf(t,e){return yn.visit(this.data,t,e)}[Symbol.iterator](){return Kn.visit(new yt([this.data]))}toArray(){return[...this]}concat(...t){return new de(this.schema,[this,...t])}slice(t,e){let[n]=new yt([this.data]).slice(t,e).data;return new r(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new yt([this.data.children[t]]):null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=this.data;if(t>-1&&t<this.numCols){e||(e=new yt([st({type:new le,length:this.numRows})]));let s=n.fields.slice(),a=i.children.slice(),c=s[t].clone({type:e.type});[s[t],a[t]]=[c,e.data[0]],n=new Bt(s,new Map(this.schema.metadata)),i=st({type:new Nt(s),children:a})}return new r(n,i)}select(t){let e=this.schema.select(t),n=new Nt(e.fields),i=[];for(let s of t){let a=this.schema.fields.findIndex(c=>c.name===s);~a&&(i[a]=this.data.children[a])}return new r(e,st({type:n,length:this.numRows,children:i}))}selectAt(t){let e=this.schema.selectAt(t),n=t.map(s=>this.data.children[s]).filter(Boolean),i=st({type:new Nt(e.fields),length:this.numRows,children:n});return new r(e,i)}};af=Symbol.toStringTag;Gt[af]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Gt.prototype);function of(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;let i=[...r.fields],s=[...t],a=(e+63&-64)>>3;for(let[c,d]of r.fields.entries()){let h=t[c];(!h||h.length!==e)&&(i[c]=d.clone({nullable:!0}),s[c]=(n=h==null?void 0:h._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:st({type:d.type,length:e,nullCount:e,nullBitmap:new Uint8Array(a)}))}return[r.assign(i),st({type:new Nt(i),length:e,children:s})]}function cf(r,t,e=new Map){var n,i;if(((n=r==null?void 0:r.length)!==null&&n!==void 0?n:0)>0&&(r==null?void 0:r.length)===(t==null?void 0:t.length))for(let s=-1,a=r.length;++s<a;){let{type:c}=r[s],d=t[s];for(let h of[d,...((i=d==null?void 0:d.dictionary)===null||i===void 0?void 0:i.data)||[]])cf(c.children,h==null?void 0:h.children,e);if(k.isDictionary(c)){let{id:h}=c;if(!e.has(h))d!=null&&d.dictionary&&e.set(h,d.dictionary);else if(e.get(h)!==d.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var Fn=class extends Gt{constructor(t){let e=t.fields.map(i=>st({type:i.type})),n=st({type:new Nt(t.fields),nullCount:0,children:e});super(t,n)}};var Je=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):It.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):_t.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Xt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,It.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,_t.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,n,i,s,a){return r.startMessage(t),r.addVersion(t,e),r.addHeaderType(t,n),r.addHeader(t,i),r.addBodyLength(t,s),r.addCustomMetadata(t,a),r.endMessage(t)}};var Bc=class extends ${visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Ai.startNull(e),Ai.endNull(e)}visitInt(t,e){return He.startInt(e),He.addBitWidth(e,t.bitWidth),He.addIsSigned(e,t.isSigned),He.endInt(e)}visitFloat(t,e){return Jr.startFloatingPoint(e),Jr.addPrecision(e,t.precision),Jr.endFloatingPoint(e)}visitBinary(t,e){return Si.startBinary(e),Si.endBinary(e)}visitLargeBinary(t,e){return Di.startLargeBinary(e),Di.endLargeBinary(e)}visitBool(t,e){return Ii.startBool(e),Ii.endBool(e)}visitUtf8(t,e){return xi.startUtf8(e),xi.endUtf8(e)}visitLargeUtf8(t,e){return Bi.startLargeUtf8(e),Bi.endLargeUtf8(e)}visitDecimal(t,e){return sr.startDecimal(e),sr.addScale(e,t.scale),sr.addPrecision(e,t.precision),sr.addBitWidth(e,t.bitWidth),sr.endDecimal(e)}visitDate(t,e){return Gr.startDate(e),Gr.addUnit(e,t.unit),Gr.endDate(e)}visitTime(t,e){return _r.startTime(e),_r.addUnit(e,t.unit),_r.addBitWidth(e,t.bitWidth),_r.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return yr.startTimestamp(e),yr.addUnit(e,t.unit),n!==void 0&&yr.addTimezone(e,n),yr.endTimestamp(e)}visitInterval(t,e){return Xr.startInterval(e),Xr.addUnit(e,t.unit),Xr.endInterval(e)}visitDuration(t,e){return Yr.startDuration(e),Yr.addUnit(e,t.unit),Yr.endDuration(e)}visitList(t,e){return Fi.startList(e),Fi.endList(e)}visitStruct(t,e){return Ti.startStruct_(e),Ti.endStruct_(e)}visitUnion(t,e){Ve.startTypeIdsVector(e,t.typeIds.length);let n=Ve.createTypeIdsVector(e,t.typeIds);return Ve.startUnion(e),Ve.addMode(e,t.mode),Ve.addTypeIds(e,n),Ve.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return ir.startDictionaryEncoding(e),ir.addId(e,BigInt(t.id)),ir.addIsOrdered(e,t.isOrdered),n!==void 0&&ir.addIndexType(e,n),ir.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return qr.startFixedSizeBinary(e),qr.addByteWidth(e,t.byteWidth),qr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Kr.startFixedSizeList(e),Kr.addListSize(e,t.listSize),Kr.endFixedSizeList(e)}visitMap(t,e){return Zr.startMap(e),Zr.addKeysSorted(e,t.keysSorted),Zr.endMap(e)}},Yo=new Bc;function ff(r,t=new Map){return new Bt(my(r,t),qo(r.metadata),t)}function Fc(r){return new ne(r.count,pf(r.columns),mf(r.columns))}function hf(r){return new me(Fc(r.data),r.id,r.isDelta)}function my(r,t){return(r.fields||[]).filter(Boolean).map(e=>ht.fromJSON(e,t))}function lf(r,t){return(r.children||[]).filter(Boolean).map(e=>ht.fromJSON(e,t))}function pf(r){return(r||[]).reduce((t,e)=>[...t,new Ue(e.count,_y(e.VALIDITY)),...pf(e.children)],[])}function mf(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new pe(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new pe(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new pe(t.length,i.OFFSET.length)),i.DATA&&t.push(new pe(t.length,i.DATA.length)),t=mf(i.children,t)}return t}function _y(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function _f(r,t){let e,n,i,s,a,c;return!t||!(s=r.dictionary)?(a=df(r,lf(r,t)),i=new ht(r.name,a,r.nullable,qo(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?uf(n):new or,c=new De(t.get(e),n,e,s.isOrdered),i=new ht(r.name,c,r.nullable,qo(r.metadata))):(n=(n=s.indexType)?uf(n):new or,t.set(e,a=df(r,lf(r,t))),c=new De(a,n,e,s.isOrdered),i=new ht(r.name,c,r.nullable,qo(r.metadata))),i||null}function qo(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function uf(r){return new Zt(r.isSigned,r.bitWidth)}function df(r,t){let e=r.type.name;switch(e){case"NONE":return new le;case"null":return new le;case"binary":return new br;case"largebinary":return new gr;case"utf8":return new wr;case"largeutf8":return new vr;case"bool":return new Sr;case"list":return new je((t||[])[0]);case"struct":return new Nt(t||[]);case"struct_":return new Nt(t||[])}switch(e){case"int":{let n=r.type;return new Zt(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new Ee(Et[n.precision])}case"decimal":{let n=r.type;return new Ir(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new Dr($t[n.unit])}case"time":{let n=r.type;return new Br(C[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new Fr(C[n.unit],n.timezone)}case"interval":{let n=r.type;return new Ar(Jt[n.unit])}case"duration":{let n=r.type;return new Tr(C[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),a=i.toUpperCase()+s.join("");return new $e(Ot[a],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new xr(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new Ge(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new Ye((t||[])[0],n.keysSorted)}}throw new Error('Unrecognized type: "'.concat(e,'"'))}var yy=fn,by=Se,_e=class r{static fromJSON(t,e){let n=new r(0,It.V5,e);return n._createHeader=gy(t,e),n}static decode(t){t=new by(Z(t));let e=Je.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),a=new r(n,i,s);return a._createHeader=wy(e,s),a}static encode(t){let e=new yy,n=-1;return t.isSchema()?n=Bt.encode(e,t.header()):t.isRecordBatch()?n=ne.encode(e,t.header()):t.isDictionaryBatch()&&(n=me.encode(e,t.header())),Je.startMessage(e),Je.addVersion(e,It.V5),Je.addHeader(e,n),Je.addHeaderType(e,t.headerType),Je.addBodyLength(e,BigInt(t.bodyLength)),Je.finishMessageBuffer(e,Je.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof Bt)return new r(0,It.V5,_t.Schema,t);if(t instanceof ne)return new r(e,It.V5,_t.RecordBatch,t);if(t instanceof me)return new r(e,It.V5,_t.DictionaryBatch,t);throw new Error("Unrecognized Message header: ".concat(t))}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===_t.Schema}isRecordBatch(){return this.headerType===_t.RecordBatch}isDictionaryBatch(){return this.headerType===_t.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=wt(t)}},ne=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=wt(t)}},me=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,n=!1){this._data=t,this._isDelta=n,this._id=wt(e)}},pe=class{constructor(t,e){this.offset=wt(t),this.length=wt(e)}},Ue=class{constructor(t,e){this.length=wt(t),this.nullCount=wt(e)}};function gy(r,t){return()=>{switch(t){case _t.Schema:return Bt.fromJSON(r);case _t.RecordBatch:return ne.fromJSON(r);case _t.DictionaryBatch:return me.fromJSON(r)}throw new Error("Unrecognized Message type: { name: ".concat(_t[t],", type: ").concat(t," }"))}}function wy(r,t){return()=>{switch(t){case _t.Schema:return Bt.decode(r.header(new fe),new Map,r.version());case _t.RecordBatch:return ne.decode(r.header(new Ie),r.version());case _t.DictionaryBatch:return me.decode(r.header(new mr),r.version())}throw new Error("Unrecognized Message type: { name: ".concat(_t[t],", type: ").concat(t," }"))}}ht.encode=Oy;ht.decode=xy;ht.fromJSON=_f;Bt.encode=Ey;Bt.decode=vy;Bt.fromJSON=ff;ne.encode=My;ne.decode=Sy;ne.fromJSON=Fc;me.encode=Uy;me.decode=Iy;me.fromJSON=hf;Ue.encode=Ry;Ue.decode=By;pe.encode=Ly;pe.decode=Dy;function vy(r,t=new Map,e=It.V5){let n=Ty(r,t);return new Bt(n,Ko(r),t,e)}function Sy(r,t=It.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new ne(r.length(),Fy(r),Ay(r,t))}function Iy(r,t=It.V5){return new me(ne.decode(r.data(),t),r.id(),r.isDelta())}function Dy(r){return new pe(r.offset(),r.length())}function By(r){return new Ue(r.length(),r.nullCount())}function Fy(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=Ue.decode(e));return t}function Ay(r,t){let e=[];for(let n,i=-1,s=-1,a=r.buffersLength();++i<a;)(n=r.buffers(i))&&(t<It.V4&&(n.bb_pos+=8*(i+1)),e[++s]=pe.decode(n));return e}function Ty(r,t){let e=[];for(let n,i=-1,s=-1,a=r.fieldsLength();++i<a;)(n=r.fields(i))&&(e[++s]=ht.decode(n,t));return e}function yf(r,t){let e=[];for(let n,i=-1,s=-1,a=r.childrenLength();++i<a;)(n=r.children(i))&&(e[++s]=ht.decode(n,t));return e}function xy(r,t){let e,n,i,s,a,c;return!t||!(c=r.dictionary())?(i=gf(r,yf(r,t)),n=new ht(r.name(),i,r.nullable(),Ko(r))):t.has(e=wt(c.id()))?(s=(s=c.indexType())?bf(s):new or,a=new De(t.get(e),s,e,c.isOrdered()),n=new ht(r.name(),a,r.nullable(),Ko(r))):(s=(s=c.indexType())?bf(s):new or,t.set(e,i=gf(r,yf(r,t))),a=new De(i,s,e,c.isOrdered()),n=new ht(r.name(),a,r.nullable(),Ko(r))),n||null}function Ko(r){let t=new Map;if(r)for(let e,n,i=-1,s=Math.trunc(r.customMetadataLength());++i<s;)(e=r.customMetadata(i))&&(n=e.key())!=null&&t.set(n,e.value());return t}function bf(r){return new Zt(r.isSigned(),r.bitWidth())}function gf(r,t){let e=r.typeType();switch(e){case Mt.NONE:return new le;case Mt.Null:return new le;case Mt.Binary:return new br;case Mt.LargeBinary:return new gr;case Mt.Utf8:return new wr;case Mt.LargeUtf8:return new vr;case Mt.Bool:return new Sr;case Mt.List:return new je((t||[])[0]);case Mt.Struct_:return new Nt(t||[])}switch(e){case Mt.Int:{let n=r.type(new He);return new Zt(n.isSigned(),n.bitWidth())}case Mt.FloatingPoint:{let n=r.type(new Jr);return new Ee(n.precision())}case Mt.Decimal:{let n=r.type(new sr);return new Ir(n.scale(),n.precision(),n.bitWidth())}case Mt.Date:{let n=r.type(new Gr);return new Dr(n.unit())}case Mt.Time:{let n=r.type(new _r);return new Br(n.unit(),n.bitWidth())}case Mt.Timestamp:{let n=r.type(new yr);return new Fr(n.unit(),n.timezone())}case Mt.Interval:{let n=r.type(new Xr);return new Ar(n.unit())}case Mt.Duration:{let n=r.type(new Yr);return new Tr(n.unit())}case Mt.Union:{let n=r.type(new Ve);return new $e(n.mode(),n.typeIdsArray()||[],t||[])}case Mt.FixedSizeBinary:{let n=r.type(new qr);return new xr(n.byteWidth())}case Mt.FixedSizeList:{let n=r.type(new Kr);return new Ge(n.listSize(),(t||[])[0])}case Mt.Map:{let n=r.type(new Zr);return new Ye((t||[])[0],n.keysSorted())}}throw new Error('Unrecognized type: "'.concat(Mt[e],'" (').concat(e,")"))}function Ey(r,t){let e=t.fields.map(s=>ht.encode(r,s));fe.startFieldsVector(r,e.length);let n=fe.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?fe.createCustomMetadataVector(r,[...t.metadata].map(([s,a])=>{let c=r.createString("".concat(s)),d=r.createString("".concat(a));return Xt.startKeyValue(r),Xt.addKey(r,c),Xt.addValue(r,d),Xt.endKeyValue(r)})):-1;return fe.startSchema(r),fe.addFields(r,n),fe.addEndianness(r,ky?$r.Little:$r.Big),i!==-1&&fe.addCustomMetadata(r,i),fe.endSchema(r)}function Oy(r,t){let e=-1,n=-1,i=-1,s=t.type,a=t.typeId;k.isDictionary(s)?(a=s.dictionary.typeId,i=Yo.visit(s,r),n=Yo.visit(s.dictionary,r)):n=Yo.visit(s,r);let c=(s.children||[]).map(u=>ht.encode(r,u)),d=oe.createChildrenVector(r,c),h=t.metadata&&t.metadata.size>0?oe.createCustomMetadataVector(r,[...t.metadata].map(([u,I])=>{let T=r.createString("".concat(u)),E=r.createString("".concat(I));return Xt.startKeyValue(r),Xt.addKey(r,T),Xt.addValue(r,E),Xt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),oe.startField(r),oe.addType(r,n),oe.addTypeType(r,a),oe.addChildren(r,d),oe.addNullable(r,!!t.nullable),e!==-1&&oe.addName(r,e),i!==-1&&oe.addDictionary(r,i),h!==-1&&oe.addCustomMetadata(r,h),oe.endField(r)}function My(r,t){let e=t.nodes||[],n=t.buffers||[];Ie.startNodesVector(r,e.length);for(let a of e.slice().reverse())Ue.encode(r,a);let i=r.endVector();Ie.startBuffersVector(r,n.length);for(let a of n.slice().reverse())pe.encode(r,a);let s=r.endVector();return Ie.startRecordBatch(r),Ie.addLength(r,BigInt(t.length)),Ie.addNodes(r,i),Ie.addBuffers(r,s),Ie.endRecordBatch(r)}function Uy(r,t){let e=ne.encode(r,t.data);return mr.startDictionaryBatch(r),mr.addId(r,BigInt(t.id)),mr.addIsDelta(r,t.isDelta),mr.addData(r,e),mr.endDictionaryBatch(r)}function Ry(r,t){return Pn.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function Ly(r,t){return Cn.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var ky=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var Tc=r=>"Expected ".concat(_t[r]," Message in stream, but was null or length 0."),xc=r=>"Header pointer of flatbuffer-encoded ".concat(_t[r]," Message is null or length 0."),wf=(r,t)=>"Expected to read ".concat(r," metadata bytes, but only read ").concat(t,"."),vf=(r,t)=>"Expected to read ".concat(r," bytes for message body, but only read ").concat(t,"."),ni=class{constructor(t){this.source=t instanceof lr?t:new lr(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?Ct:t.value===-1&&(t=this.readMetadataLength()).done?Ct:(t=this.readMetadata(t.value)).done?Ct:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(Tc(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=Z(this.source.read(t));if(e.byteLength<t)throw new Error(vf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=_t.Schema,n=this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(xc(e));return i}readMetadataLength(){let t=this.source.read(Jo),e=t&&new Se(t),n=(e==null?void 0:e.readInt32(0))||0;return{done:n===0,value:n}}readMetadata(t){let e=this.source.read(t);if(!e)return Ct;if(e.byteLength<t)throw new Error(wf(t,e.byteLength));return{done:!1,value:_e.decode(e)}}},ds=class{constructor(t,e){this.source=t instanceof Oe?t:Ts(t)?new nn(t,e):new Oe(t)}[Symbol.asyncIterator](){return this}next(){return L(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?Ct:t.value===-1&&(t=yield this.readMetadataLength()).done?Ct:(t=yield this.readMetadata(t.value)).done?Ct:t})}throw(t){return L(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return L(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return L(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(Tc(t));return e.value})}readMessageBody(t){return L(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=Z(yield this.source.read(t));if(e.byteLength<t)throw new Error(vf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return L(this,arguments,void 0,function*(t=!1){let e=_t.Schema,n=yield this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(xc(e));return i})}readMetadataLength(){return L(this,void 0,void 0,function*(){let t=yield this.source.read(Jo),e=t&&new Se(t),n=(e==null?void 0:e.readInt32(0))||0;return{done:n===0,value:n}})}readMetadata(t){return L(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return Ct;if(e.byteLength<t)throw new Error(wf(t,e.byteLength));return{done:!1,value:_e.decode(e)}})}},fs=class extends ni{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Ni?t:new Ni(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:_e.fromJSON(t.schema,_t.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:_e.fromJSON(e,_t.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:_e.fromJSON(e,_t.RecordBatch)}}return this._body=[],Ct}readMessageBody(t){return e(this._body);function e(n){return(n||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(Tc(t));return e.value}readSchema(){let t=_t.Schema,e=this.readMessage(t),n=e==null?void 0:e.header();if(!e||!n)throw new Error(xc(t));return n}},Jo=4,Ac="ARROW1",ii=new Uint8Array(Ac.length);for(let r=0;r<Ac.length;r+=1)ii[r]=Ac.codePointAt(r);function Xo(r,t=0){for(let e=-1,n=ii.length;++e<n;)if(ii[e]!==r[t+e])return!1;return!0}var si=ii.length,Ec=si+Jo,Sf=si*2+Jo;var ie=class r extends gn{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){let e=this._impl.open(t);return ke(e)?e.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return ee.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return ee.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof r?t:Fs(t)?Cy(t):Ts(t)?Vy(t):ke(t)?L(this,void 0,void 0,function*(){return yield r.from(yield t)}):xs(t)||_i(t)||Os(t)||Ae(t)?Hy(new Oe(t)):Py(new lr(t))}static readAll(t){return t instanceof r?t.isSync()?If(t):Df(t):Fs(t)||ArrayBuffer.isView(t)||Ne(t)||As(t)?If(t):Df(t)}},dr=class extends ie{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return we(this,arguments,function*(){yield lt(yield*un(kn(Le(this[Symbol.iterator]()))))})}},sn=class extends ie{constructor(t){super(t),this._impl=t}readAll(){return L(this,void 0,void 0,function*(){var t,e,n,i;let s=new Array;try{for(var a=!0,c=Le(this),d;d=yield c.next(),t=d.done,!t;a=!0){i=d.value,a=!1;let h=i;s.push(h)}}catch(h){e={error:h}}finally{try{!a&&!t&&(n=c.return)&&(yield n.call(c))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},on=class extends dr{constructor(t){super(t),this._impl=t}},hs=class extends sn{constructor(t){super(t),this._impl=t}},Zo=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){let n=this._loadVectors(t,e,this.schema.fields),i=st({type:new Nt(this.schema.fields),length:t.length,children:n});return new Gt(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:a}=this,c=s.get(n),d=a.dictionaries.get(n),h=this._loadVectors(t.data,e,[d]);return(c&&i?c.concat(new yt(h)):new yt(h)).memoize()}_loadVectors(t,e,n){return new Vi(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},oi=class extends Zo{constructor(t,e){super(e),this._reader=Fs(t)?new fs(this._handle=t):new ni(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=Bf(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):Ct}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Ct}next(){if(this.closed)return Ct;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Fn(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},ai=class extends Zo{constructor(t,e){super(e),this._reader=new ds(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return L(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return L(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Bf(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return L(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):Ct})}return(t){return L(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Ct})}next(){return L(this,void 0,void 0,function*(){if(this.closed)return Ct;let t,{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Fn(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return L(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Qo=class extends oi{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof Ci?t:new Ci(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(_t.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),a=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null}_readDictionaryBatch(t){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(_t.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),a=this._reader.readMessageBody(i.bodyLength),c=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,c)}}}_readFooter(){let{_handle:t}=this,e=t.size-Ec,n=t.readInt32(e),i=t.readAt(e-n,n);return Mr.decode(i)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(n&&this._handle.seek(n.offset))return this._reader.readMessage(t)}return null}},Oc=class extends ai{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let n=typeof e[0]!="number"?e.shift():void 0,i=e[0]instanceof Map?e.shift():void 0;super(t instanceof nn?t:new nn(t,n),i)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return L(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return L(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(_t.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,a)}}return null})}_readDictionaryBatch(t){return L(this,void 0,void 0,function*(){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(_t.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),a=yield this._reader.readMessageBody(i.bodyLength),c=this._loadDictionaryBatch(s,a);this.dictionaries.set(s.id,c)}}})}_readFooter(){return L(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Ec,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return Mr.decode(i)})}_readNextMessageAndValidate(t){return L(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},Mc=class extends oi{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new Do(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function Bf(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*If(r){let t=ie.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Df(r){return we(this,arguments,function*(){let e=yield lt(ie.from(r));try{if(!(yield lt(e.open({autoDestroy:!1}))).closed)do yield yield lt(e);while(!(yield lt(e.reset().open())).closed)}finally{yield lt(e.cancel())}})}function Cy(r){return new dr(new Mc(r))}function Py(r){let t=r.peek(si+7&-8);return t&&t.byteLength>=4?Xo(t)?new on(new Qo(r.read())):new dr(new oi(r)):new dr(new oi(function*(){}()))}function Hy(r){return L(this,void 0,void 0,function*(){let t=yield r.peek(si+7&-8);return t&&t.byteLength>=4?Xo(t)?new on(new Qo(yield r.read())):new sn(new ai(r)):new sn(new ai(function(){return we(this,arguments,function*(){})}()))})}function Vy(r){return L(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new nn(r,t);return t>=Sf&&Xo(yield e.readAt(0,si+7&-8))?new hs(new Oc(e)):new sn(new ai(e))})}var Vt=class r extends ${static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof Gt?s.data.children:s.data),n=new r;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof yt)return this.visitMany(t.data),this;let{type:e}=t;if(!k.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(k.isUnion(e))this.nodes.push(new Ue(n,0));else{let{nullCount:i}=t;k.isNull(e)||Xe.call(this,i<=0?new Uint8Array(0):mn(t.offset,n,t.nullBitmap)),this.nodes.push(new Ue(n,i))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function Xe(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new pe(this._byteLength,t)),this._byteLength+=t,this}function Wy(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(Xe.call(this,i),e.mode===Ot.Sparse)return Uc.call(this,r);if(e.mode===Ot.Dense){if(r.offset<=0)return Xe.call(this,s),Uc.call(this,r);{let a=new Int32Array(n),c=Object.create(null),d=Object.create(null);for(let h,u,I=-1;++I<n;)(h=i[I])!==void 0&&((u=c[h])===void 0&&(u=c[h]=s[I]),a[I]=s[I]-u,d[h]=((t=d[h])!==null&&t!==void 0?t:0)+1);Xe.call(this,a),this.visitMany(r.children.map((h,u)=>{let I=e.typeIds[u],T=c[I],E=d[I];return h.slice(T,Math.min(n,E))}))}}return this}function zy(r){let t;return r.nullCount>=r.length?Xe.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?Xe.call(this,mn(r.offset,r.length,t)):Xe.call(this,_n(r.values))}function Hr(r){return Xe.call(this,r.values.subarray(0,r.length*r.stride))}function ta(r){let{length:t,values:e,valueOffsets:n}=r,i=wt(n[0]),s=wt(n[t]),a=Math.min(s-i,e.byteLength-i);return Xe.call(this,Us(-i,t+1,n)),Xe.call(this,e.subarray(i,i+a)),this}function Rc(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return Xe.call(this,Us(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function Uc(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}Vt.prototype.visitBool=zy;Vt.prototype.visitInt=Hr;Vt.prototype.visitFloat=Hr;Vt.prototype.visitUtf8=ta;Vt.prototype.visitLargeUtf8=ta;Vt.prototype.visitBinary=ta;Vt.prototype.visitLargeBinary=ta;Vt.prototype.visitFixedSizeBinary=Hr;Vt.prototype.visitDate=Hr;Vt.prototype.visitTimestamp=Hr;Vt.prototype.visitTime=Hr;Vt.prototype.visitDecimal=Hr;Vt.prototype.visitList=Rc;Vt.prototype.visitStruct=Uc;Vt.prototype.visitUnion=Wy;Vt.prototype.visitInterval=Hr;Vt.prototype.visitDuration=Hr;Vt.prototype.visitFixedSizeList=Rc;Vt.prototype.visitMap=Rc;var An=class extends gn{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new cr,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,ce(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return ke(t)?t.then(e=>this.writeAll(e)):Ae(t)?kc(this,t):Lc(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){return t===this._sink||t instanceof cr?this._sink=t:(this._sink=new cr,t&&Hu(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Vu(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!e||!Bn(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof de&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Gt&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!Bn(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Gt?t instanceof Fn||this._writeRecordBatch(t):t instanceof de?this.writeAll(t.batches):Ne(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=_e.encode(t),s=i.byteLength,a=this._writeLegacyIpcFormat?4:8,c=s+a+n&~n,d=c-s-a;return t.headerType===_t.RecordBatch?this._recordBatchBlocks.push(new Ur(c,t.bodyLength,this._position)):t.headerType===_t.DictionaryBatch&&this._dictionaryBlocks.push(new Ur(c,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(c-a)),s>0&&this._write(i),this._writePadding(d)}_write(t){if(this._started){let e=Z(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(_e.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(ii)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=Vt.assemble(t),a=new ne(t.numRows,n,i),c=_e.from(a,e);return this._writeDictionaries(t)._writeMessage(c)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){let{byteLength:i,nodes:s,bufferRegions:a,buffers:c}=Vt.assemble(new yt([t])),d=new ne(t.length,s,a),h=new me(d,e,n),u=_e.from(h,i);return this._writeMessage(u)._writeBodyBuffers(c)}_writeBodyBuffers(t){let e,n,i;for(let s=-1,a=t.length;++s<a;)(e=t[s])&&(n=e.byteLength)>0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this}_writeDictionaries(t){var e,n;for(let[i,s]of t.dictionaries){let a=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],c=this._seenDictionaries.get(i),d=(n=this._dictionaryDeltaOffsets.get(i))!==null&&n!==void 0?n:0;if(!c||c.data[0]!==a[0])for(let[h,u]of a.entries())this._writeDictionaryBatch(u,i,h>0);else if(d<a.length)for(let h of a.slice(d))this._writeDictionaryBatch(h,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,a.length)}return this}},Tn=class r extends An{static writeAll(t,e){let n=new r(e);return ke(t)?t.then(i=>n.writeAll(i)):Ae(t)?kc(n,t):Lc(n,t)}},xn=class r extends An{static writeAll(t){let e=new r;return ke(t)?t.then(n=>e.writeAll(n)):Ae(t)?kc(e,t):Lc(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,n=!1){if(!n&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,n)}_writeFooter(t){let e=Mr.encode(new Mr(t,It.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Lc(r,t){let e=t;t instanceof de&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function kc(r,t){return L(this,void 0,void 0,function*(){var e,n,i,s,a,c,d;try{for(e=!0,n=Le(t);i=yield n.next(),s=i.done,!s;e=!0){d=i.value,e=!1;let h=d;r.write(h)}}catch(h){a={error:h}}finally{try{!e&&!s&&(c=n.return)&&(yield c.call(n))}finally{if(a)throw a.error}}return r.finish()})}function Ff(r,t){if(Ae(r))return $y(r,t);if(Ne(r))return jy(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function jy(r,t){let e=null,n=(t==null?void 0:t.type)==="bytes"||!1,i=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(a){s(a,e||(e=r[Symbol.iterator]()))},pull(a){e?s(a,e):a.close()},cancel(){(e!=null&&e.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:n?i:void 0},t));function s(a,c){let d,h=null,u=a.desiredSize||null;for(;!(h=c.next(n?u:null)).done;)if(ArrayBuffer.isView(h.value)&&(d=Z(h.value))&&(u!=null&&n&&(u=u-d.byteLength+1),h.value=d),a.enqueue(h.value),u!=null&&--u<=0)return;a.close()}}function $y(r,t){let e=null,n=(t==null?void 0:t.type)==="bytes"||!1,i=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(a){return L(this,void 0,void 0,function*(){yield s(a,e||(e=r[Symbol.asyncIterator]()))})},pull(a){return L(this,void 0,void 0,function*(){e?yield s(a,e):a.close()})},cancel(){return L(this,void 0,void 0,function*(){(e!=null&&e.return&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:n?i:void 0},t));function s(a,c){return L(this,void 0,void 0,function*(){let d,h=null,u=a.desiredSize||null;for(;!(h=yield c.next(n?u:null)).done;)if(ArrayBuffer.isView(h.value)&&(d=Z(h.value))&&(u!=null&&n&&(u=u-d.byteLength+1),h.value=d),a.enqueue(h.value),u!=null&&--u<=0)return;a.close()})}}function xf(r){return new Nc(r)}var Nc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=Cu(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=vn(s),this._getSize=i!=="bytes"?Af:Tf;let{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:c=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:d=>{this._maybeFlush(this._builder,this._controller=d)},start:d=>{this._maybeFlush(this._builder,this._controller=d)}},{highWaterMark:a,size:i!=="bytes"?Af:Tf}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:c,size:d=>this._writeValueAndReturnChunkSize(d)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},Af=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Tf=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function ea(r,t){let e=new cr,n=null,i=new ReadableStream({cancel(){return L(this,void 0,void 0,function*(){yield e.close()})},start(c){return L(this,void 0,void 0,function*(){yield a(c,n||(n=yield s()))})},pull(c){return L(this,void 0,void 0,function*(){n?yield a(c,n):c.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:i};function s(){return L(this,void 0,void 0,function*(){return yield(yield ie.from(e)).open(t)})}function a(c,d){return L(this,void 0,void 0,function*(){let h=c.desiredSize,u=null;for(;!(u=yield d.next()).done;)if(c.enqueue(u.value),h!=null&&--h<=0)return;c.close()})}}function ra(r,t){let e=new this(r),n=new Oe(e),i=new ReadableStream({cancel(){return L(this,void 0,void 0,function*(){yield n.cancel()})},pull(a){return L(this,void 0,void 0,function*(){yield s(a)})},start(a){return L(this,void 0,void 0,function*(){yield s(a)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(a){return L(this,void 0,void 0,function*(){let c=null,d=a.desiredSize;for(;c=yield n.read(d||null);)if(a.enqueue(c),d!=null&&(d-=c.byteLength)<=0)return;a.close()})}}function na(r,t="stream"){return(t==="stream"?Tn:xn).writeAll(r).toUint8Array(!0)}var Ky=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Ka),wc),dc),Ja),Wa),uc),$a),{compareSchemas:Bn,compareFields:rf,compareTypes:nf});ee.toDOMStream=Ff;Pt.throughDOM=xf;ie.throughDOM=ea;on.throughDOM=ea;dr.throughDOM=ea;An.throughDOM=ra;xn.throughDOM=ra;Tn.throughDOM=ra;function ci(r){switch(r.typeId){case m.Binary:return{sqlType:"binary"};case m.Bool:return{sqlType:"bool"};case m.Date:return{sqlType:"date"};case m.DateDay:return{sqlType:"date32[d]"};case m.DateMillisecond:return{sqlType:"date64[ms]"};case m.Decimal:{let t=r;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case m.Float:return{sqlType:"float"};case m.Float16:return{sqlType:"float16"};case m.Float32:return{sqlType:"float32"};case m.Float64:return{sqlType:"float64"};case m.Int:return{sqlType:"int32"};case m.Int16:return{sqlType:"int16"};case m.Int32:return{sqlType:"int32"};case m.Int64:return{sqlType:"int64"};case m.Uint16:return{sqlType:"uint16"};case m.Uint32:return{sqlType:"uint32"};case m.Uint64:return{sqlType:"uint64"};case m.Uint8:return{sqlType:"uint8"};case m.IntervalDayTime:return{sqlType:"interval[dt]"};case m.IntervalYearMonth:return{sqlType:"interval[m]"};case m.List:return{sqlType:"list",valueType:ci(r.valueType)};case m.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:r.byteWidth};case m.Null:return{sqlType:"null"};case m.Utf8:return{sqlType:"utf8"};case m.Struct:return{sqlType:"struct",fields:r.children.map(e=>ia(e.name,e.type))};case m.Map:{let t=r;return{sqlType:"map",keyType:ci(t.keyType),valueType:ci(t.valueType)}}case m.Time:return{sqlType:"time[s]"};case m.TimeMicrosecond:return{sqlType:"time[us]"};case m.TimeMillisecond:return{sqlType:"time[ms]"};case m.TimeNanosecond:return{sqlType:"time[ns]"};case m.TimeSecond:return{sqlType:"time[s]"};case m.Timestamp:return{sqlType:"timestamp",timezone:r.timezone||void 0};case m.TimestampSecond:return{sqlType:"timestamp[s]",timezone:r.timezone||void 0};case m.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:r.timezone||void 0};case m.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:r.timezone||void 0};case m.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:r.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(r.toString()))}function ia(r,t){let e=ci(t);return e.name=r,e}var sa=class{constructor(t,e){this._bindings=t,this._conn=e}close(){this._bindings.disconnect(this._conn)}useUnsafe(t){return t(this._bindings,this._conn)}query(t){let e=this._bindings.runQuery(this._conn,t),n=ie.from(e);return console.assert(n.isSync()),console.assert(n.isFile()),new de(n)}async send(t,e=!1){let n=this._bindings.startPendingQuery(this._conn,t,e);for(;n==null;)n=await new Promise((a,c)=>{try{a(this._bindings.pollPendingQuery(this._conn))}catch(d){console.log(d),d.message.includes("worker is not set!")?c(new Error("Worker has been terminated")):c(d)}});let i=new oa(this._bindings,this._conn,n),s=ie.from(i);return console.assert(s.isSync()),console.assert(s.isStream()),s}cancelSent(){return this._bindings.cancelPendingQuery(this._conn)}getTableNames(t){return this._bindings.getTableNames(this._conn,t)}prepare(t){let e=this._bindings.createPrepared(this._conn,t);return new Cc(this._bindings,this._conn,e)}createScalarFunction(t,e,n){this._bindings.createScalarFunction(this._conn,t,e,n)}insertArrowTable(t,e){let n=na(t,"stream");this.insertArrowFromIPCStream(n,e)}insertArrowFromIPCStream(t,e){this._bindings.insertArrowFromIPCStream(this._conn,t,e)}insertCSVFromPath(t,e){this._bindings.insertCSVFromPath(this._conn,t,e)}insertJSONFromPath(t,e){this._bindings.insertJSONFromPath(this._conn,t,e)}},oa=class{constructor(t,e,n){this.bindings=t;this.conn=e;this.header=n;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 t=null;do t=this.bindings.fetchQueryResults(this.conn);while(t==null);return this._depleted=t.length==0,{done:this._depleted,value:t}}[Symbol.iterator](){return this}},Cc=class{constructor(t,e,n){this.bindings=t,this.connectionId=e,this.statementId=n}close(){this.bindings.closePrepared(this.connectionId,this.statementId)}query(...t){let e=this.bindings.runPrepared(this.connectionId,this.statementId,t),n=ie.from(e);return console.assert(n.isSync()),console.assert(n.isFile()),new de(n)}send(...t){let e=this.bindings.sendPrepared(this.connectionId,this.statementId,t),n=new oa(this.bindings,this.connectionId,e),i=ie.from(n);return console.assert(i.isSync()),console.assert(i.isStream()),i}};function Of(r){return r<=255}function Mf(r){return r===256}var Lf=new TextEncoder,Uf=new TextDecoder("utf-8");function Pc(r,t,e){let n=Lf.encode(e),i=r._malloc(n.byteLength),s=r.HEAPU8.subarray(i,i+n.byteLength);s.set(n),r.HEAPF64[(t>>3)+0]=1,r.HEAPF64[(t>>3)+1]=i,r.HEAPF64[(t>>3)+2]=s.byteLength}function Vc(r){switch(r){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 Hc(r,t,e,n){let i=r.HEAPU8.subarray(t,t+n*Vc(e));switch(e){case"UINT8":return new Uint8Array(i.buffer,i.byteOffset,n);case"INT8":return new Int8Array(i.buffer,i.byteOffset,n);case"INT32":return new Int32Array(i.buffer,i.byteOffset,n);case"FLOAT":return new Float32Array(i.buffer,i.byteOffset,n);case"DOUBLE":return new Float64Array(i.buffer,i.byteOffset,n);case"VARCHAR":return new Float64Array(i.buffer,i.byteOffset,n);default:return new Array(0)}}function Rf(r,t,e){let n=r.HEAPU8.subarray(t,t+e);return new Uint8Array(n.buffer,n.byteOffset,e)}function aa(r,t,e){let n=r.HEAPU8.subarray(t,t+e*8);return new Float64Array(n.buffer,n.byteOffset,e)}function kf(r,t,e,n,i,s,a,c){try{let d=r._udfFunctions.get(n);if(!d){Pc(t,e,"Unknown UDF with id: "+n);return}let h=Uf.decode(t.HEAPU8.subarray(i,i+s)),u=JSON.parse(h),I=aa(t,a,c/8),T=D=>{var A;let N=null;switch(D.validityBuffer!==void 0&&(N=Rf(t,I[D.validityBuffer],u.rows)),D.physicalType){case"VARCHAR":{if(D.dataBuffer===null||D.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for VARCHAR argument");if(D.lengthBuffer===null||D.lengthBuffer===void 0)throw new Error("malformed data view, expected data length buffer for VARCHAR argument");let J=Hc(t,I[D.dataBuffer],D.physicalType,u.rows),B=[],W=aa(t,I[D.lengthBuffer],u.rows);for(let Q=0;Q<u.rows;++Q){if(N!=null&&!N[Q]){B.push(null);continue}let pt=t.HEAPU8.subarray(J[Q],J[Q]+W[Q]),Ht=Uf.decode(pt);B.push(Ht)}return Q=>B[Q]}case"STRUCT":{let J={},B=[];for(let W=0;W<(((A=D.children)==null?void 0:A.length)||0);++W){let Q=D.children[W],pt=T(Q);B.push(Ht=>{J[Q.name]=pt(Ht)})}return N!=null?W=>{if(!N[W])return null;for(let Q of B)Q(W);return J}:W=>{for(let Q of B)Q(W);return J}}default:{if(D.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for argument of type: "+D.physicalType);let J=Hc(t,I[D.dataBuffer],D.physicalType,u.rows);return N!=null?B=>N[B]?J[B]:null:B=>J[B]}}},E=[];for(let D=0;D<u.args.length;++D)E.push(T(u.args[D]));let ft=u.rows*Vc(u.ret.physicalType),At=t._malloc(ft),jt=Hc(t,At,u.ret.physicalType,u.rows),Lt=t._malloc(u.rows),Tt=Rf(t,Lt,u.rows);if(jt.length==0||Tt.length==0){Pc(t,e,"Can't create physical arrays for result");return}let bt=jt;u.ret.physicalType=="VARCHAR"&&(bt=new Array(u.rows));let xt=[];for(let D=0;D<u.args.length;++D)xt.push(null);for(let D=0;D<u.rows;++D){for(let A=0;A<u.args.length;++A)xt[A]=E[A](D);let N=d.func(...xt);bt[D]=N,Tt[D]=N==null?0:1}let U=0;switch(u.ret.physicalType){case"VARCHAR":{let D=new Array(0);U=t._malloc(u.rows*Vc("DOUBLE"));let N=aa(t,U,u.rows),A=0;for(let Q=0;Q<u.rows;++Q){let pt=Lf.encode(bt[Q]||"");D.push(pt),N[Q]=pt.length,A+=pt.length}let J=t._malloc(A),B=t.HEAPU8.subarray(J,J+A),W=0;for(let Q=0;Q<u.rows;++Q){jt[Q]=W;let pt=D[Q];B.subarray(W,W+pt.length).set(pt),W+=pt.length}}}let w=3*8,M=t._malloc(w),H=aa(t,M,3);H[0]=At,H[1]=Lt,H[2]=U,t.HEAPF64[(e>>3)+0]=0,t.HEAPF64[(e>>3)+1]=M,t.HEAPF64[(e>>3)+2]=0}catch(d){Pc(t,e,d.toString())}}function Xy(){let r=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),r.decode(t))}var Zy=Xy();function Ze(r,t){console.error("FAIL WITH: ".concat(t)),r.ccall("duckdb_web_fail_with",null,["string"],[t])}function En(r,t,e){let n=r.HEAPU8.subarray(t,t+e),i=new Uint8Array(new ArrayBuffer(n.byteLength));return i.set(n),i}function at(r,t,e){return Zy(r.HEAPU8.subarray(t,t+e))}function Ft(r,t,e,n){let i=r.stackSave(),s=r.stackAlloc(3*8);e.unshift("number"),n.unshift(s),r.ccall(t,null,e,n);let a=r.HEAPF64[(s>>3)+0],c=r.HEAPF64[(s>>3)+1],d=r.HEAPF64[(s>>3)+2];return r.stackRestore(i),[a,c,d]}function Rt(r){r.ccall("duckdb_web_clear_response",null,[],[])}var ca=class{constructor(t){let e=new Float64Array(t.buffer,t.byteOffset,t.byteLength/8),n=new Uint8Array(new ArrayBuffer(t.byteLength));n.set(t.subarray(7*8)),this.totalFileReadsCold=e[0],this.totalFileReadsAhead=e[1],this.totalFileReadsCached=e[2],this.totalFileWrites=e[3],this.totalPageAccesses=e[4],this.totalPageLoads=e[5],this.blockSize=e[6],this.blockStats=n}getBlockStats(t,e){return e=e||{file_reads_cold:0,file_reads_ahead:0,file_reads_cached:0,file_writes:0,page_accesses:0,page_loads:0},e.file_writes=this.blockStats[t*3+0]&15,e.file_reads_cold=this.blockStats[t*3+0]>>4,e.file_reads_ahead=this.blockStats[t*3+1]&15,e.file_reads_cached=this.blockStats[t*3+1]>>4,e.page_accesses=this.blockStats[t*3+1]&15,e.page_loads=this.blockStats[t*3+1]>>4,e}};var li=new TextEncoder;var la=class{constructor(t,e){this._instance=null;this._initPromise=null;this._initPromiseResolver=()=>{};this.onInstantiationProgress=[];this._logger=t,this._runtime=e,this._nextUDFId=1}get logger(){return this._logger}get mod(){return this._instance}get pthread(){return this.mod.PThread||null}async instantiate(t=e=>{}){return this._instance!=null?this:(this._initPromise!=null&&(this.onInstantiationProgress.push(t),await this._initPromise),this._initPromise=new Promise(e=>{this._initPromiseResolver=e}),this.onInstantiationProgress=[t],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(e=>e!=t),globalThis.DUCKDB_BINDINGS=this,this)}open(t){let[e,n,i]=Ft(this.mod,"duckdb_web_open",["string"],[JSON.stringify(t)]);if(e!==0)throw new Error(at(this.mod,n,i));Rt(this.mod)}reset(){let[t,e,n]=Ft(this.mod,"duckdb_web_reset",[],[]);if(t!==0)throw new Error(at(this.mod,e,n));Rt(this.mod)}getVersion(){let[t,e,n]=Ft(this.mod,"duckdb_web_get_version",[],[]);if(t!==0)throw new Error(at(this.mod,e,n));let i=at(this.mod,e,n);return Rt(this.mod),i}getFeatureFlags(){return this.mod.ccall("duckdb_web_get_feature_flags","number",[],[])}tokenize(t){let e=li.encode(t),n=this.mod._malloc(e.length);this.mod.HEAPU8.subarray(n,n+e.length).set(e);let[s,a,c]=Ft(this.mod,"duckdb_web_tokenize_buffer",["number","number"],[n,e.length]);if(this.mod._free(n),s!==0)throw new Error(at(this.mod,a,c));let d=at(this.mod,a,c);return Rt(this.mod),JSON.parse(d)}connect(){let t=this.mod.ccall("duckdb_web_connect","number",[],[]);return new sa(this,t)}disconnect(t){if(this.mod.ccall("duckdb_web_disconnect",null,["number"],[t]),this.pthread)for(let e of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])e.postMessage({cmd:"dropUDFFunctions",connectionId:t})}runQuery(t,e){let n=li.encode(e),i=this.mod._malloc(n.length);this.mod.HEAPU8.subarray(i,i+n.length).set(n);let[a,c,d]=Ft(this.mod,"duckdb_web_query_run_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),a!==0)throw new Error(at(this.mod,c,d));let h=En(this.mod,c,d);return Rt(this.mod),h}startPendingQuery(t,e,n=!1){let i=li.encode(e),s=this.mod._malloc(i.length);this.mod.HEAPU8.subarray(s,s+i.length).set(i);let[c,d,h]=Ft(this.mod,"duckdb_web_pending_query_start_buffer",["number","number","number","boolean"],[t,s,i.length,n]);if(this.mod._free(s),c!==0)throw new Error(at(this.mod,d,h));if(d==0)return null;let u=En(this.mod,d,h);return Rt(this.mod),u}pollPendingQuery(t){let[e,n,i]=Ft(this.mod,"duckdb_web_pending_query_poll",["number"],[t]);if(e!==0)throw new Error(at(this.mod,n,i));if(n==0)return null;let s=En(this.mod,n,i);return Rt(this.mod),s}cancelPendingQuery(t){return this.mod.ccall("duckdb_web_pending_query_cancel","boolean",["number"],[t])}fetchQueryResults(t){let[e,n,i]=Ft(this.mod,"duckdb_web_query_fetch_results",["number"],[t]);if(Mf(e))return Rt(this.mod),null;if(!Of(e))throw new Error("Unexpected StatusCode from duckdb_web_query_fetch_results ("+e+") and with self reported error as"+at(this.mod,n,i));if(e!==0)throw new Error(at(this.mod,n,i));let s=En(this.mod,n,i);return Rt(this.mod),s}getTableNames(t,e){let n=li.encode(e),i=this.mod._malloc(n.length);this.mod.HEAPU8.subarray(i,i+n.length).set(n);let[a,c,d]=Ft(this.mod,"duckdb_web_get_tablenames_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),a!==0)throw new Error(at(this.mod,c,d));let h=at(this.mod,c,d);return Rt(this.mod),JSON.parse(h)}createScalarFunction(t,e,n,i){let s={functionId:this._nextUDFId,name:e,returnType:ci(n)},a={functionId:s.functionId,connectionId:t,name:e,returnType:n,func:i};this._nextUDFId+=1;let[c,d,h]=Ft(this.mod,"duckdb_web_udf_scalar_create",["number","string"],[t,JSON.stringify(s)]);if(c!==0)throw new Error(at(this.mod,d,h));if(Rt(this.mod),globalThis.DUCKDB_RUNTIME._udfFunctions=(globalThis.DUCKDB_RUNTIME._udfFunctions||new Map).set(a.functionId,a),this.pthread)for(let u of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])u.postMessage({cmd:"registerUDFFunction",udf:a})}createPrepared(t,e){let n=li.encode(e),i=this.mod._malloc(n.length);this.mod.HEAPU8.subarray(i,i+n.length).set(n);let[a,c,d]=Ft(this.mod,"duckdb_web_prepared_create_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),a!==0)throw new Error(at(this.mod,c,d));return Rt(this.mod),c}closePrepared(t,e){let[n,i,s]=Ft(this.mod,"duckdb_web_prepared_close",["number","number"],[t,e]);if(n!==0)throw new Error(at(this.mod,i,s));Rt(this.mod)}runPrepared(t,e,n){let[i,s,a]=Ft(this.mod,"duckdb_web_prepared_run",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(at(this.mod,s,a));let c=En(this.mod,s,a);return Rt(this.mod),c}sendPrepared(t,e,n){let[i,s,a]=Ft(this.mod,"duckdb_web_prepared_send",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(at(this.mod,s,a));let c=En(this.mod,s,a);return Rt(this.mod),c}insertArrowFromIPCStream(t,e,n){if(e.length==0)return;let i=this.mod._malloc(e.length);this.mod.HEAPU8.subarray(i,i+e.length).set(e);let a=n?JSON.stringify(n):"",[c,d,h]=Ft(this.mod,"duckdb_web_insert_arrow_from_ipc_stream",["number","number","number","string"],[t,i,e.length,a]);if(this.mod._free(i),c!==0)throw new Error(at(this.mod,d,h))}insertCSVFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let h in n.columns)n.columnsFlat.push(ia(h,n.columns[h]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[a,c,d]=Ft(this.mod,"duckdb_web_insert_csv_from_path",["number","string","string"],[t,e,s]);if(a!==0)throw new Error(at(this.mod,c,d))}insertJSONFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let h in n.columns)n.columnsFlat.push(ia(h,n.columns[h]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[a,c,d]=Ft(this.mod,"duckdb_web_insert_json_from_path",["number","string","string"],[t,e,s]);if(a!==0)throw new Error(at(this.mod,c,d))}globFiles(t){let[e,n,i]=Ft(this.mod,"duckdb_web_fs_glob_file_infos",["string"],[t]);if(e!==0)throw new Error(at(this.mod,n,i));let s=at(this.mod,n,i);Rt(this.mod);let a=JSON.parse(s);return a==null?[]:a}registerFileURL(t,e,n,i=!1){e===void 0&&(e=t);let[s,a,c]=Ft(this.mod,"duckdb_web_fs_register_file_url",["string","string"],[t,e,n,i]);if(s!==0)throw new Error(at(this.mod,a,c));Rt(this.mod)}registerFileText(t,e){let n=li.encode(e);this.registerFileBuffer(t,n)}registerFileBuffer(t,e){let n=this.mod._malloc(e.length);this.mod.HEAPU8.subarray(n,n+e.length).set(e);let[s,a,c]=Ft(this.mod,"duckdb_web_fs_register_file_buffer",["string","number","number"],[t,n,e.length]);if(s!==0)throw new Error(at(this.mod,a,c));Rt(this.mod)}async prepareFileHandle(t,e){if(e===3&&this._runtime.prepareFileHandles){let n=await this._runtime.prepareFileHandles([t],3);for(let i of n){let{handle:s,path:a,fromCached:c}=i;!c&&s.getSize()&&await this.registerFileHandleAsync(a,s,3,!0)}return}throw new Error("prepareFileHandle: unsupported protocol ".concat(e))}async prepareDBFileHandle(t,e){if(e===3&&this._runtime.prepareDBFileHandle){let n=await this._runtime.prepareDBFileHandle(t,3);for(let i of n){let{handle:s,path:a,fromCached:c}=i;!c&&s.getSize()&&await this.registerFileHandleAsync(a,s,3,!0)}return}throw new Error("prepareDBFileHandle: unsupported protocol ".concat(e))}async prepareFileHandleAsync(t,e,n,i){if(n===3&&!(e instanceof FileSystemSyncAccessHandle)){if(e instanceof FileSystemFileHandle){let s=e;try{e=await s.createSyncAccessHandle()}catch(a){throw new Error(a.message+":"+t)}}else if(t!=null)try{e=await(await(await navigator.storage.getDirectory()).getFileHandle(t)).createSyncAccessHandle()}catch(s){throw new Error(s.message+":"+t)}}return e}async registerFileHandleAsync(t,e,n,i){let s=await this.prepareFileHandleAsync(t,e,n,i);this.registerFileHandle(t,s,n,i)}registerFileHandle(t,e,n,i){var d;let[s,a,c]=Ft(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[t,t,n,i]);if(s!==0)throw new Error(at(this.mod,a,c));if(Rt(this.mod),globalThis.DUCKDB_RUNTIME._files=(globalThis.DUCKDB_RUNTIME._files||new Map).set(t,e),(d=globalThis.DUCKDB_RUNTIME._preparedHandles)!=null&&d[t]&&delete globalThis.DUCKDB_RUNTIME._preparedHandles[t],this.pthread){for(let h of this.pthread.runningWorkers)h.postMessage({cmd:"registerFileHandle",fileName:t,fileHandle:e});for(let h of this.pthread.unusedWorkers)h.postMessage({cmd:"dropFileHandle",fileName:t})}}dropFile(t){let[e,n,i]=Ft(this.mod,"duckdb_web_fs_drop_file",["string"],[t]);if(e!==0)throw new Error(at(this.mod,n,i));Rt(this.mod)}dropFiles(t){let e=[],n=-1;try{for(let c of t!=null?t:[])if(c!=null&&c.length>0){let d=this.mod.lengthBytesUTF8(c)+1,h=this.mod._malloc(d);if(!h)throw new Error("Failed to allocate memory for string: ".concat(c));this.mod.stringToUTF8(c,h,d),e.push(h)}if(n=this.mod._malloc(e.length*4),!n)throw new Error("Failed to allocate memory for pointers array");for(let c=0;c<e.length;c++)this.mod.HEAP32[(n>>2)+c]=e[c];let[i,s,a]=Ft(this.mod,"duckdb_web_fs_drop_files",["number","number"],[n,e.length]);if(i!==0)throw new Error(at(this.mod,s,a));Rt(this.mod)}finally{for(let i of e)this.mod._free(i);n>0&&this.mod._free(n)}}flushFiles(){this.mod.ccall("duckdb_web_flush_files",null,[],[])}copyFileToPath(t,e){let[n,i,s]=Ft(this.mod,"duckdb_web_copy_file_to_path",["string","string"],[t,e]);if(n!==0)throw new Error(at(this.mod,i,s));Rt(this.mod)}copyFileToBuffer(t){let[e,n,i]=Ft(this.mod,"duckdb_web_copy_file_to_buffer",["string"],[t]);if(e!==0)throw new Error(at(this.mod,n,i));let s=this.mod.HEAPU8.subarray(n,n+i),a=new Uint8Array(s.length);return a.set(s),Rt(this.mod),a}async registerOPFSFileName(t){if(t.startsWith("opfs://"))return this.prepareFileHandle(t,3);throw new Error("Not an OPFS file name: "+t)}collectFileStatistics(t,e){let[n,i,s]=Ft(this.mod,"duckdb_web_collect_file_stats",["string","boolean"],[t,e]);if(n!==0)throw new Error(at(this.mod,i,s))}exportFileStatistics(t){let[e,n,i]=Ft(this.mod,"duckdb_web_export_file_stats",["string"],[t]);if(e!==0)throw new Error(at(this.mod,n,i));return new ca(this.mod.HEAPU8.subarray(n,n+i))}};var ua=class{constructor(){this._bindings=null;this._nextMessageId=0}log(t){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:t},[])}sendOK(t){this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"OK",data:null},[])}failWith(t,e){let n={name:e.name,message:e.message,stack:e.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"ERROR",data:n},[])}async onMessage(t){switch(t.type){case"PING":this.sendOK(t);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(t,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(t.data[0],t.data[1],e=>{this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"INSTANTIATE_PROGRESS",data:e},[])}),this.sendOK(t)}catch(e){console.log(e),this._bindings=null,this.failWith(t,e)}return;default:break}if(!this._bindings)return this.failWith(t,new Error("duckdb is not initialized"));try{switch(t.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(t);break;case"OPEN":{let e=t.data.path;e!=null&&e.startsWith("opfs://")&&(await this._bindings.prepareDBFileHandle(e,3),t.data.useDirectIO=!0),this._bindings.open(t.data),this.sendOK(t);break}case"DROP_FILE":this._bindings.dropFile(t.data),this.sendOK(t);break;case"DROP_FILES":this._bindings.dropFiles(t.data),this.sendOK(t);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(t);break;case"CONNECT":{let e=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"CONNECTION_INFO",data:e.useUnsafe((n,i)=>i)},[]);break}case"DISCONNECT":this._bindings.disconnect(t.data),this.sendOK(t);break;case"CREATE_PREPARED":{let e=this._bindings.createPrepared(t.data[0],t.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"PREPARED_STATEMENT_ID",data:e},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(t.data[0],t.data[1]),this.sendOK(t);break}case"RUN_PREPARED":{let e=this._bindings.runPrepared(t.data[0],t.data[1],t.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT",data:e},[e.buffer]);break}case"RUN_QUERY":{let e=this._bindings.runQuery(t.data[0],t.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT",data:e},[e.buffer]);break}case"SEND_PREPARED":{let e=this._bindings.sendPrepared(t.data[0],t.data[1],t.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_HEADER",data:e},[e.buffer]);break}case"START_PENDING_QUERY":{let e=this._bindings.startPendingQuery(t.data[0],t.data[1],t.data[2]),n=[];e&&n.push(e.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:e},n);break}case"POLL_PENDING_QUERY":{let e=this._bindings.pollPendingQuery(t.data),n=[];e&&n.push(e.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:e},n);break}case"CANCEL_PENDING_QUERY":{let e=this._bindings.cancelPendingQuery(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"SUCCESS",data:e},[]);break}case"FETCH_QUERY_RESULTS":{let e=this._bindings.fetchQueryResults(t.data),n=e?[e.buffer]:[];this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"QUERY_RESULT_CHUNK",data:e},n);break}case"GET_TABLE_NAMES":{let e=this._bindings.getTableNames(t.data[0],t.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"TABLE_NAMES",data:e},[]);break}case"GLOB_FILE_INFOS":{let e=this._bindings.globFiles(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FILE_INFOS",data:e},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(t.data[0],t.data[1],t.data[2],t.data[3]),this.sendOK(t);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(t.data[0],t.data[1]),this.sendOK(t);break;case"REGISTER_FILE_HANDLE":await this._bindings.registerFileHandleAsync(t.data[0],t.data[1],t.data[2],t.data[3]),this.sendOK(t);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(t.data[0],t.data[1]),this.sendOK(t);break;case"COPY_FILE_TO_BUFFER":{let e=this._bindings.copyFileToBuffer(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FILE_BUFFER",data:e},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(t.data[0],t.data[1]),this.sendOK(t);break;case"REGISTER_OPFS_FILE_NAME":await this._bindings.registerOPFSFileName(t.data[0]),this.sendOK(t);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(t.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(t.data[0],t.data[1],t.data[2]),this.sendOK(t);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(t.data[0],t.data[1],t.data[2]),this.sendOK(t);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(t.data[0],t.data[1],t.data[2]),this.sendOK(t);break}case"TOKENIZE":{let e=this._bindings.tokenize(t.data);this.postMessage({messageId:this._nextMessageId++,requestId:t.messageId,type:"SCRIPT_TOKENS",data:e},[]);break}}}catch(e){return console.log(e),this.failWith(t,e)}}};var $f=ku(jf());var da=class extends la{constructor(t,e,n,i){super(t,e),this.mainModuleURL=n,this.pthreadWorkerURL=i}locateFile(t,e){if(t.endsWith(".wasm"))return this.mainModuleURL;if(t.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=".concat(e," path=").concat(t))}instantiateWasm(t,e){globalThis.DUCKDB_RUNTIME=this._runtime;let n=this.onInstantiationProgress;if(WebAssembly.instantiateStreaming)if(typeof TransformStream=="function"){let s=(async()=>{var ft;let a=new Request(this.mainModuleURL),c=await fetch(a),d=c.headers.get("content-length"),h=d&&parseInt(d,10)||0,u=new Date,I={startedAt:u,updatedAt:u,bytesTotal:h||0,bytesLoaded:0},T={transform(At,jt){I.bytesLoaded+=At.byteLength;let Lt=new Date;if(Lt.getTime()-I.updatedAt.getTime()<20){I.updatedAt=Lt,jt.enqueue(At);return}for(let Tt of n)Tt(I);jt.enqueue(At)}},E=new TransformStream(T);return new Response((ft=c.body)==null?void 0:ft.pipeThrough(E),c)})();WebAssembly.instantiateStreaming(s,t).then(a=>{e(a.instance,a.module)})}else{console.warn("instantiating without progress handler since transform streams are unavailable");let i=new Request(this.mainModuleURL);WebAssembly.instantiateStreaming(fetch(i),t).then(s=>{e(s.instance,s.module)})}else if(typeof XMLHttpRequest=="function"){let i=new XMLHttpRequest,s=this.mainModuleURL,a=new Date,c={startedAt:a,updatedAt:a,bytesTotal:0,bytesLoaded:0};i.open("GET",s),i.responseType="arraybuffer",i.onerror=d=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to load WASM: "+d}),new Error(d.toString())},i.onprogress=d=>{c.bytesTotal=d.total,c.bytesLoaded=d.loaded;let h=new Date;if(h.getTime()-c.updatedAt.getTime()<20){c.updatedAt=h;return}for(let u of n)u(c)},i.onload=()=>{WebAssembly.instantiate(i.response,t).then(d=>{e(d.instance,d.module)}).catch(d=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to instantiate WASM: "+d}),new Error(d)})},i.send()}else console.warn("instantiating with manual fetch since streaming instantiation and xhrs are unavailable"),(async()=>{let s=new Request(this.mainModuleURL),c=await(await fetch(s)).arrayBuffer();WebAssembly.instantiate(c,t).then(d=>{e(d.instance,d.module)})})();return[]}};var fa=class extends da{constructor(t,e,n,i=null){super(t,e,n,i)}instantiateImpl(t){return(0,$f.default)({...t,instantiateWasm:this.instantiateWasm.bind(this),locateFile:this.locateFile.bind(this)})}};var an=ku(qf()),Kf=function(r,t,e){var n;return(n=r==null?void 0:r.endpoint)!=null&&n.startsWith("http")?new URL(r.endpoint).host:r!=null&&r.endpoint?"".concat(e,".").concat(r==null?void 0:r.endpoint):"".concat(e,".s3.amazonaws.com")};function tb(r,t,e){var s,a,c,d;let n=Jf(t),i=n.path;if(Xf(r)){let h="";if(r!=null&&r.endpoint){let u=new URL(r.endpoint);u.pathname!=="/"&&(h=u.pathname)}i="".concat(h,"/").concat(n.bucket).concat(i)}return{url:i,query:"",host:Kf(r,t,n.bucket),region:(s=r==null?void 0:r.region)!=null?s:"",service:"s3",method:e,accessKeyId:(a=r==null?void 0:r.accessKeyId)!=null?a:"",secretAccessKey:(c=r==null?void 0:r.secretAccessKey)!=null?c:"",sessionToken:(d=r==null?void 0:r.sessionToken)!=null?d:"",dateNow:new Date().toISOString().replace(/-/g,"").split("T")[0],datetimeNow:new Date().toISOString().replace(/-/g,"").replace(/:/g,"").split(".")[0]+"Z"}}function eb(r,t=!1){let e="0123456789ABCDEF",n="";for(let i=0;i<r.length;i++){let s=r[i];s>="A"&&s<="Z"||s>="a"&&s<="z"||s>="0"&&s<="9"||s=="_"||s=="-"||s=="~"||s=="."?n+=s:s=="/"?t?n+="%2F":n+=s:(n+="%",n+=e[s.charCodeAt(0)>>4],n+=e[s.charCodeAt(0)&15])}return n}function rb(r,t=null){var ft;let e=(ft=t==null?void 0:t.contentHash)!=null?ft:"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",n=new Map;n.set("x-amz-date",r.datetimeNow),n.set("x-amz-content-sha256",e),r.sessionToken&&n.set("x-amz-security-token",r.sessionToken);let i="";t!=null&&t.contentType&&(i+="content-type;"),i+="host;x-amz-content-sha256;x-amz-date",r.sessionToken&&(i+=";x-amz-security-token");let s=r.method+"\n"+eb(r.url)+"\n"+r.query;t!=null&&t.contentType&&(s+="\ncontent-type:"+(t==null?void 0:t.contentType)),s+="\nhost:"+r.host+"\nx-amz-content-sha256:"+e+"\nx-amz-date:"+r.datetimeNow,r.sessionToken&&r.sessionToken.length>0&&(s+="\nx-amz-security-token:"+r.sessionToken),s+="\n\n"+i+"\n"+e;let a=(0,an.sha256)(s),c="AWS4-HMAC-SHA256\n"+r.datetimeNow+"\n"+r.dateNow+"/"+r.region+"/"+r.service+"/aws4_request\n"+a,d="AWS4"+r.secretAccessKey,h=an.sha256.hmac.arrayBuffer(d,r.dateNow),u=an.sha256.hmac.arrayBuffer(h,r.region),I=an.sha256.hmac.arrayBuffer(u,r.service),T=an.sha256.hmac.arrayBuffer(I,"aws4_request"),E=an.sha256.hmac(T,c);return n.set("Authorization","AWS4-HMAC-SHA256 Credential="+r.accessKeyId+"/"+r.dateNow+"/"+r.region+"/"+r.service+"/aws4_request, SignedHeaders="+i+", Signature="+E),n}var nb=function(r,t,e,n=null,i=null){let s=tb(r,t,e),a={contentType:n,contentHash:i?an.sha256.hex(i):null};return rb(s,a)};function Qe(r,t,e,n,i=null,s=null){(t!=null&&t.accessKeyId||t!=null&&t.sessionToken)&&(nb(t,e,n,i,s).forEach((c,d)=>{r.setRequestHeader(d,c)}),i&&r.setRequestHeader("content-type",i))}function Jf(r){if(r.indexOf("s3://")!=0)throw new Error("URL needs to start with s3://");let t=r.indexOf("/",5);if(t==-1)throw new Error("URL needs to contain a '/' after the host");let e=r.substring(5,t);if(!e)throw new Error("URL needs to contain a bucket name");let n=r.substring(t);if(!n)throw new Error("URL needs to contain key");return{bucket:e,path:n}}function Xf(r){var t;return!!((t=r==null?void 0:r.endpoint)!=null&&t.startsWith("http"))}function tr(r,t){let e=Jf(t);return Xf(r)?"".concat(r==null?void 0:r.endpoint,"/").concat(e.bucket)+e.path:"https://"+Kf(r,t,e.bucket)+e.path}var ib=7,Zf=/\/|\\/,rt={_files:new Map,_fileInfoCache:new Map,_udfFunctions:new Map,_globalFileInfo:null,_preparedHandles:{},_opfsRoot:null,getFileInfo(r,t){try{let e=rt._fileInfoCache.get(t),[n,i,s]=Ft(r,"duckdb_web_fs_get_file_info_by_id",["number","number"],[t,(e==null?void 0:e.cacheEpoch)||0]);if(n!==0)return null;if(s===0)return e;let a=at(r,i,s);Rt(r);try{let c=JSON.parse(a);if(c==null)return null;let d={...c,blob:null};return rt._fileInfoCache.set(t,d),!rt._files.has(d.fileName)&&rt._preparedHandles[d.fileName]&&(rt._files.set(d.fileName,rt._preparedHandles[d.fileName]),delete rt._preparedHandles[d.fileName]),d}catch(c){return console.warn(c),null}}catch(e){return console.log(e),null}},getGlobalFileInfo(r){var t;try{let[e,n,i]=Ft(r,"duckdb_web_get_global_file_info",["number"],[((t=rt._globalFileInfo)==null?void 0:t.cacheEpoch)||0]);if(e!==0)return null;if(i===0)return rt._globalFileInfo;let s=at(r,n,i);Rt(r);let a=JSON.parse(s);return a==null?null:(rt._globalFileInfo={...a,blob:null},rt._globalFileInfo)}catch(e){return console.log(e),null}},async assignOPFSRoot(){rt._opfsRoot||(rt._opfsRoot=await navigator.storage.getDirectory())},async prepareFileHandles(r,t){if(t===3){await rt.assignOPFSRoot();let e=async i=>{if(rt._files.has(i))return{path:i,handle:rt._files.get(i),fromCached:!0};let a=rt._opfsRoot,c=i.slice(ib),d=c;if(Zf.test(c)){let u=c.split(Zf);if(u.length===0)throw new Error("Invalid path ".concat(c));if(d=u[u.length-1],!d)throw new Error("Invalid path ".concat(c,". File Not Found."));u.pop();for(let I of u)a=await a.getDirectoryHandle(I,{create:!0})}let h=await a.getFileHandle(d,{create:!1}).catch(u=>{if((u==null?void 0:u.name)==="NotFoundError")return console.debug("File ".concat(i," does not exists yet, creating...")),a.getFileHandle(d,{create:!0});throw u});try{let u=await h.createSyncAccessHandle();return rt._preparedHandles[i]=u,{path:i,handle:u,fromCached:!1}}catch(u){throw new Error(u.message+":"+name)}},n=[];for(let i of r){let s=await e(i);n.push(s)}return n}throw new Error("Unsupported protocol ".concat(t," for paths ").concat(r," with protocol ").concat(t))},async prepareDBFileHandle(r,t){if(t===3&&this.prepareFileHandles){let e=[r,"".concat(r,".wal")];return this.prepareFileHandles(e,t)}throw new Error("Unsupported protocol ".concat(t," for path ").concat(r," with protocol ").concat(t))},testPlatformFeature:(r,t)=>{switch(t){case 1:return typeof BigInt64Array<"u";default:return console.warn("test for unknown feature: ".concat(t)),!1}},getDefaultDataProtocol(r){return 2},openFile:(r,t,e)=>{var n,i,s,a,c,d;try{rt._fileInfoCache.delete(t);let h=rt.getFileInfo(r,t);switch(h==null?void 0:h.dataProtocol){case 4:case 5:{if(e&1&&e&2)throw new Error("Opening file ".concat(h.fileName," failed: cannot open file with both read and write flags set"));if(e&32)throw new Error("Opening file ".concat(h.fileName," failed: appending to HTTP/S3 files is not supported"));if(e&2){let T=new XMLHttpRequest;if(h.dataProtocol==5?(T.open("HEAD",tr(h.s3Config,h.dataUrl),!1),Qe(T,h.s3Config,h.dataUrl,"HEAD")):T.open("HEAD",h.dataUrl,!1),T.send(null),T.status!=200&&T.status!=404)throw new Error("Opening file ".concat(h.fileName," failed: Unexpected return status from server (").concat(T.status,")"));if(T.status==404&&!(e&8||e&16))throw new Error("Opening file ".concat(h.fileName," failed: Cannot write to non-existent file without FILE_FLAGS_FILE_CREATE or FILE_FLAGS_FILE_CREATE_NEW flag."));let E=r._malloc(1),ft=new Uint8Array;r.HEAPU8.set(ft,E);let At=r._malloc(3*8);return r.HEAPF64[(At>>3)+0]=1,r.HEAPF64[(At>>3)+1]=E,r.HEAPF64[(At>>3)+2]=new Date().getTime()/1e3,At}else if(!(e&1))throw new Error("Opening file ".concat(h.fileName," failed: unsupported file flags: ").concat(e));let u=null,I=null;if(!h.forceFullHttpReads&&(h.reliableHeadRequests||!h.allowFullHttpReads))try{let T=new XMLHttpRequest;h.dataProtocol==5?(T.open("HEAD",tr(h.s3Config,h.dataUrl),!1),Qe(T,h.s3Config,h.dataUrl,"HEAD")):T.open("HEAD",h.dataUrl,!1),T.setRequestHeader("Range","bytes=0-"),T.send(null),u=null;try{u=T.getResponseHeader("Content-Length")}catch(E){console.warn("Failed to get Content-Length on request")}if(u!==null&&T.status==206){let E=r._malloc(24);r.HEAPF64[(E>>3)+0]=+u,r.HEAPF64[(E>>3)+1]=0;let ft=0;try{ft=new Date((n=T.getResponseHeader("Last-Modified"))!=null?n:"").getTime()/1e3}catch(At){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(E>>3)+2]=+ft,E}}catch(T){I=T,console.warn("HEAD request with range header failed: ".concat(T))}if(h.allowFullHttpReads){if(!h.forceFullHttpReads){let E=new XMLHttpRequest;h.dataProtocol==5?(E.open("GET",tr(h.s3Config,h.dataUrl),!1),Qe(E,h.s3Config,h.dataUrl,"GET")):E.open("GET",h.dataUrl,!1),E.responseType="arraybuffer",E.setRequestHeader("Range","bytes=0-0"),E.send(null);let ft=null;try{ft=E.getResponseHeader("Content-Length")}catch(Tt){console.warn("Failed to get Content-Length on request")}let At=ft==null?void 0:ft.split("/")[1],jt=ft,Lt=null;if(At!==void 0)Lt=At;else if(!h.reliableHeadRequests){let Tt=new XMLHttpRequest;h.dataProtocol==5?(Tt.open("HEAD",tr(h.s3Config,h.dataUrl),!1),Qe(Tt,h.s3Config,h.dataUrl,"HEAD")):Tt.open("HEAD",h.dataUrl,!1),Tt.setRequestHeader("Range","bytes=0-"),Tt.send(null),u=null;try{u=Tt.getResponseHeader("Content-Length")}catch(bt){console.warn("Failed to get Content-Length on request")}u!==null&&+u>1&&(Lt=u)}if(E.status==206&&jt!==null&&+jt==1&&Lt!==null){let Tt=r._malloc(24);r.HEAPF64[(Tt>>3)+0]=+Lt,r.HEAPF64[(Tt>>3)+1]=0;let bt=0;try{bt=new Date((i=E.getResponseHeader("Last-Modified"))!=null?i:"").getTime()/1e3}catch(xt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(Tt>>3)+2]=+bt,Tt}if(E.status==200&&jt!==null&&u!==null&&+jt==+u){console.warn("fall back to full HTTP read for: ".concat(h.dataUrl));let Tt=r._malloc(E.response.byteLength),bt=new Uint8Array(E.response,0,E.response.byteLength);r.HEAPU8.set(bt,Tt);let xt=r._malloc(3*8);r.HEAPF64[(xt>>3)+0]=E.response.byteLength,r.HEAPF64[(xt>>3)+1]=Tt;let U=0;try{U=new Date((s=E.getResponseHeader("Last-Modified"))!=null?s:"").getTime()/1e3}catch(w){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(xt>>3)+2]=+U,xt}console.warn("falling back to full HTTP read for: ".concat(h.dataUrl))}let T=new XMLHttpRequest;if(h.dataProtocol==5?(T.open("GET",tr(h.s3Config,h.dataUrl),!1),Qe(T,h.s3Config,h.dataUrl,"GET")):T.open("GET",h.dataUrl,!1),T.responseType="arraybuffer",T.send(null),T.status==200){let E=r._malloc(T.response.byteLength),ft=new Uint8Array(T.response,0,T.response.byteLength);r.HEAPU8.set(ft,E);let At=r._malloc(3*8);r.HEAPF64[(At>>3)+0]=T.response.byteLength,r.HEAPF64[(At>>3)+1]=E;let jt=0;try{jt=new Date((a=T.getResponseHeader("Last-Modified"))!=null?a:"").getTime()/1e3}catch(Lt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(At>>3)+2]=+jt,At}}if(I!=null)throw new Error("Reading file ".concat(h.fileName," failed with error: ").concat(I));return 0}case 2:{let u=(c=rt._files)==null?void 0:c.get(h.fileName);if(u){let E=r._malloc(24);return r.HEAPF64[(E>>3)+0]=u.size,r.HEAPF64[(E>>3)+1]=0,r.HEAPF64[(E>>3)+2]=0,E}if(e&128)return 0;console.warn("Buffering missing file: ".concat(h.fileName));let I=r._malloc(3*8),T=r._malloc(1);return r.HEAPF64[(I>>3)+0]=1,r.HEAPF64[(I>>3)+1]=T,r.HEAPF64[(I>>3)+2]=0,I}case 3:{let u=(d=rt._files)==null?void 0:d.get(h.fileName);if(!u)throw new Error("No OPFS access handle registered with name: ".concat(h.fileName));e&16&&u.truncate(0);let I=r._malloc(3*8),T=u.getSize();return r.HEAPF64[(I>>3)+0]=T,r.HEAPF64[(I>>3)+1]=0,r.HEAPF64[(I>>3)+2]=0,I}}}catch(h){console.error(h.toString()),Ze(r,h.toString())}return 0},glob:(r,t,e)=>{var n;try{let i=at(r,t,e);if(i.startsWith("http")||i.startsWith("s3://")){let s=new XMLHttpRequest;if(i.startsWith("s3://")){let a=rt.getGlobalFileInfo(r);s.open("HEAD",tr(a==null?void 0:a.s3Config,i),!1),Qe(s,a==null?void 0:a.s3Config,i,"HEAD")}else s.open("HEAD",i,!1);if(s.send(null),s.status!=200&&s.status!==206){if(!((n=rt.getGlobalFileInfo(r))!=null&&n.allowFullHttpReads))return console.log("HEAD request failed: ".concat(i,", with full http reads are disabled")),0;let a=new XMLHttpRequest;if(i.startsWith("s3://")){let d=rt.getGlobalFileInfo(r);a.open("GET",tr(d==null?void 0:d.s3Config,i),!1),Qe(a,d==null?void 0:d.s3Config,i,"HEAD")}else a.open("GET",i,!1);if(a.setRequestHeader("Range","bytes=0-0"),a.send(null),a.status!=200&&a.status!==206)return console.log("HEAD and GET requests failed: ".concat(i)),0;let c=null;try{c=a.getResponseHeader("Content-Length")}catch(d){console.warn("Failed to get Content-Length on request")}c&&+c>1&&console.warn("Range request for ".concat(i," did not return a partial response: ").concat(a.status,' "').concat(a.statusText,'"'))}r.ccall("duckdb_web_fs_glob_add_path",null,["string"],[i])}else for(let[s]of rt._files.entries()||[])s.startsWith(i)&&r.ccall("duckdb_web_fs_glob_add_path",null,["string"],[s])}catch(i){return console.log(i),Ze(r,i.toString()),0}},checkFile:(r,t,e)=>{try{let n=at(r,t,e);if(n.startsWith("http")||n.startsWith("s3://")){let i=new XMLHttpRequest;if(n.startsWith("s3://")){let s=rt.getGlobalFileInfo(r);i.open("HEAD",tr(s==null?void 0:s.s3Config,n),!1),Qe(i,s==null?void 0:s.s3Config,n,"HEAD")}else i.open("HEAD",n,!1);return i.send(null),i.status==206||i.status==200}else return rt._files.has(n)}catch(n){return console.log(n),!1}return!1},syncFile:(r,t)=>{},closeFile:(r,t)=>{var n;let e=rt.getFileInfo(r,t);rt._fileInfoCache.delete(t);try{switch(e==null?void 0:e.dataProtocol){case 0:case 4:case 5:break;case 1:case 2:return;case 3:{let i=(n=rt._files)==null?void 0:n.get(e.fileName);if(!i)throw new Error("No OPFS access handle registered with name: ".concat(e.fileName));return i.flush()}}}catch(i){console.log(i),Ze(r,i.toString())}},dropFile:(r,t,e)=>{var s;let n=at(r,t,e),i=(s=rt._files)==null?void 0:s.get(n);if(i){if(rt._files.delete(n),i instanceof FileSystemSyncAccessHandle)try{i.flush(),i.close()}catch(a){throw new Error("Cannot drop file with name: ".concat(n))}i instanceof Blob}},truncateFile:(r,t,e)=>{var i;let n=rt.getFileInfo(r,t);switch(n==null?void 0:n.dataProtocol){case 4:Ze(r,"Cannot truncate a http file");return;case 5:Ze(r,"Cannot truncate an s3 file");return;case 0:case 1:case 2:Ze(r,"truncateFile not implemented");return;case 3:{let s=(i=rt._files)==null?void 0:i.get(n.fileName);if(!s)throw new Error("No OPFS access handle registered with name: ".concat(n.fileName));return s.truncate(e)}}return 0},readFile(r,t,e,n,i){var s;if(n==0)return 0;try{let a=rt.getFileInfo(r,t);switch(a==null?void 0:a.dataProtocol){case 4:case 5:{if(!a.dataUrl)throw new Error("Missing data URL for file ".concat(t));try{let c=new XMLHttpRequest;if(a.dataProtocol==5?(c.open("GET",tr(a==null?void 0:a.s3Config,a.dataUrl),!1),Qe(c,a==null?void 0:a.s3Config,a.dataUrl,"GET")):c.open("GET",a.dataUrl,!1),c.responseType="arraybuffer",c.setRequestHeader("Range","bytes=".concat(i,"-").concat(i+n-1)),c.send(null),c.status==206||c.status==200&&n==c.response.byteLength&&i==0){let d=new Uint8Array(c.response,0,Math.min(c.response.byteLength,n));return r.HEAPU8.set(d,e),d.byteLength}else if(c.status==200){console.warn("Range request for ".concat(a.dataUrl," did not return a partial response: ").concat(c.status,' "').concat(c.statusText,'"'));let d=new Uint8Array(c.response,i,Math.min(c.response.byteLength-i,n));return r.HEAPU8.set(d,e),d.byteLength}else throw new Error("Range request for ".concat(a.dataUrl," did returned non-success status: ").concat(c.status,' "').concat(c.statusText,'"'))}catch(c){throw console.log(c),new Error("Range request for ".concat(a.dataUrl," failed with error: ").concat(c,'"'))}}case 2:{let c=(s=rt._files)==null?void 0:s.get(a.fileName);if(!c)throw new Error("No HTML5 file registered with name: ".concat(a.fileName));let d=c.slice(i,i+n),h=new Uint8Array(new FileReaderSync().readAsArrayBuffer(d));return r.HEAPU8.set(h,e),h.byteLength}case 3:{let c=rt._files.get(a.fileName);if(!c)throw new Error("No OPFS access handle registered with name: ".concat(a.fileName));let d=r.HEAPU8.subarray(e,e+n);return c.read(d,{at:i})}}return 0}catch(a){return console.log(a),Ze(r,a.toString()),0}},writeFile:(r,t,e,n,i)=>{var a;let s=rt.getFileInfo(r,t);switch(s==null?void 0:s.dataProtocol){case 4:return Ze(r,"Cannot write to HTTP file"),0;case 5:{let c=r.HEAPU8.subarray(e,e+n),d=new XMLHttpRequest;return d.open("PUT",tr(s==null?void 0:s.s3Config,s.dataUrl),!1),Qe(d,s==null?void 0:s.s3Config,s.dataUrl,"PUT","",c),d.send(c),d.status!==200?(Ze(r,"Failed writing file: HTTP "+d.status),0):n}case 2:return Ze(r,"cannot write using the html5 file reader api"),0;case 3:{let c=(a=rt._files)==null?void 0:a.get(s.fileName);if(!c)throw new Error("No OPFS access handle registered with name: ".concat(s.fileName));let d=r.HEAPU8.subarray(e,e+n);return c.write(d,{at:i})}}return 0},getLastFileModificationTime:(r,t)=>{var n;let e=rt.getFileInfo(r,t);switch(e==null?void 0:e.dataProtocol){case 2:{if(!((n=rt._files)==null?void 0:n.get(e.fileName)))throw Error("No handle available for file: ".concat(e.fileName));return 0}case 4:case 5:return new Date().getTime()/1e3}return 0},progressUpdate:(r,t,e)=>{postMessage&&postMessage({requestId:0,type:"PROGRESS_UPDATE",data:{status:r?"completed":"in-progress",percentage:t,repetitions:e}})},checkDirectory:(r,t,e)=>{let n=at(r,t,e);return console.log("checkDirectory: ".concat(n)),!1},createDirectory:(r,t,e)=>{let n=at(r,t,e);console.log("createDirectory: ".concat(n))},removeDirectory:(r,t,e)=>{let n=at(r,t,e);console.log("removeDirectory: ".concat(n))},listDirectoryEntries:(r,t,e)=>{let n=at(r,t,e);return console.log("listDirectoryEntries: ".concat(n)),!1},moveFile:(r,t,e,n,i)=>{var d,h;let s=at(r,t,e),a=at(r,n,i),c=(d=rt._files)==null?void 0:d.get(s);c!==void 0&&(rt._files.delete(c),rt._files.set(a,c));for(let[u,I]of((h=rt._fileInfoCache)==null?void 0:h.entries())||[])if(I.dataUrl==s){rt._fileInfoCache.delete(u);break}return!0},removeFile:(r,t,e)=>{},callScalarUDF:(r,t,e,n,i,s,a)=>{kf(rt,r,t,e,n,i,s,a)}};var zc=class extends ua{postMessage(t,e){globalThis.postMessage(t,e)}async instantiate(t,e,n){return await new fa(this,rt,t,e).instantiate(n)}};function Qf(){let r=new zc;globalThis.onmessage=async t=>{await r.onMessage(t.data)}}Qf();return xm(sb);})();
19
2
  /*! Bundled license information:
20
3
 
21
4
  js-sha256/src/sha256.js: