@run-trace/duckdb-wasm 0.1.3 → 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,17 +1,4 @@
1
- "use strict";var duckdb=(()=>{var fs=Object.create;var xe=Object.defineProperty;var _s=Object.getOwnPropertyDescriptor;var hs=Object.getOwnPropertyNames;var bs=Object.getPrototypeOf,ps=Object.prototype.hasOwnProperty;var ms=(a,e,n)=>e in a?xe(a,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[e]=n;var Pt=(a=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(a,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):a)(function(a){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+a+'" is not supported')});var ke=(a,e)=>()=>(e||a((e={exports:{}}).exports,e),e.exports),gs=(a,e)=>{for(var n in e)xe(a,n,{get:e[n],enumerable:!0})},xt=(a,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of hs(e))!ps.call(a,r)&&r!==n&&xe(a,r,{get:()=>e[r],enumerable:!(o=_s(e,r))||o.enumerable});return a};var Bt=(a,e,n)=>(n=a!=null?fs(bs(a)):{},xt(e||!a||!a.__esModule?xe(n,"default",{value:a,enumerable:!0}):n,a)),ys=a=>xt(xe({},"__esModule",{value:!0}),a);var Mt=(a,e,n)=>ms(a,typeof e!="symbol"?e+"":e,n);var Kt=ke(()=>{});var $t=ke(()=>{});var Vt=ke((Xt,Xe)=>{"use strict";var it=(()=>{var e;var a=typeof document<"u"?(e=document.currentScript)==null?void 0:e.src:void 0;return typeof __filename<"u"&&(a=a||__filename),async function(n={}){var o,r=n,l,d,f=new Promise((t,s)=>{l=t,d=s}),u=typeof window=="object",O=typeof WorkerGlobalScope<"u",_=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string"&&process.type!="renderer",N=Object.assign({},r),Y=[],R="./this.program",M=(t,s)=>{throw s},X="";function Q(t){return r.locateFile?r.locateFile(t,X):X+t}var re,J;if(_){var q=Kt(),se=$t();X=__dirname+"/",J=t=>{t=Ae(t)?new URL(t):t;var s=q.readFileSync(t);return s},re=async(t,s=!0)=>{t=Ae(t)?new URL(t):t;var i=q.readFileSync(t,s?void 0:"utf8");return i},!r.thisProgram&&process.argv.length>1&&(R=process.argv[1].replace(/\\/g,"/")),Y=process.argv.slice(2),M=(t,s)=>{throw process.exitCode=t,s}}else(u||O)&&(O?X=self.location.href:typeof document<"u"&&document.currentScript&&(X=document.currentScript.src),a&&(X=a),X.startsWith("blob:")?X="":X=X.slice(0,X.replace(/[?#].*/,"").lastIndexOf("/")+1),O&&(J=t=>{var s=new XMLHttpRequest;return s.open("GET",t,!1),s.responseType="arraybuffer",s.send(null),new Uint8Array(s.response)}),re=async t=>{var s=await fetch(t,{credentials:"same-origin"});if(s.ok)return s.arrayBuffer();throw new Error(s.status+" : "+s.url)});var ne=r.print||console.log.bind(console),b=r.printErr||console.error.bind(console);Object.assign(r,N),N=null,r.arguments&&(Y=r.arguments),r.thisProgram&&(R=r.thisProgram);var A=r.wasmBinary,I,m=!1,D;function F(t,s){t||he(s)}var P,p,U,x,S,$,fe,G,_e,oe,pe=!1,Ae=t=>t.startsWith("file://");function Se(){var t=I.buffer;r.HEAP8=P=new Int8Array(t),r.HEAP16=U=new Int16Array(t),r.HEAPU8=p=new Uint8Array(t),r.HEAPU16=x=new Uint16Array(t),r.HEAP32=S=new Int32Array(t),r.HEAPU32=$=new Uint32Array(t),r.HEAPF32=fe=new Float32Array(t),r.HEAPF64=oe=new Float64Array(t),r.HEAP64=G=new BigInt64Array(t),r.HEAPU64=_e=new BigUint64Array(t)}function Re(){if(r.preRun)for(typeof r.preRun=="function"&&(r.preRun=[r.preRun]);r.preRun.length;)br(r.preRun.shift());ut(dt)}function rr(){pe=!0,T.ta()}function Us(){}function nr(){if(r.postRun)for(typeof r.postRun=="function"&&(r.postRun=[r.postRun]);r.postRun.length;)hr(r.postRun.shift());ut(ct)}var ve=0,Te=null;function sr(t){var s;ve++,(s=r.monitorRunDependencies)==null||s.call(r,ve)}function ar(t){var i;if(ve--,(i=r.monitorRunDependencies)==null||i.call(r,ve),ve==0&&Te){var s=Te;Te=null,s()}}function he(t){var i;(i=r.onAbort)==null||i.call(r,t),t="Aborted("+t+")",b(t),m=!0,t+=". Build with -sASSERTIONS for more info.",pe&&___trap();var s=new WebAssembly.RuntimeError(t);throw d(s),s}var He;function ir(){return Q("./duckdb-eh.wasm")}function or(t){if(t==He&&A)return new Uint8Array(A);if(J)return J(t);throw"both async and sync fetching of the wasm failed"}async function lr(t){if(!A)try{var s=await re(t);return new Uint8Array(s)}catch{}return or(t)}async function ur(t,s){try{var i=await lr(t),c=await WebAssembly.instantiate(i,s);return c}catch(h){b(`failed to asynchronously prepare wasm: ${h}`),he(h)}}async function cr(t,s,i){if(!t&&typeof WebAssembly.instantiateStreaming=="function"&&!_)try{var c=fetch(s,{credentials:"same-origin"}),h=await WebAssembly.instantiateStreaming(c,i);return h}catch(g){b(`wasm streaming compile failed: ${g}`),b("falling back to ArrayBuffer instantiation")}return ur(s,i)}function dr(){return{a:ns}}async function fr(){function t(g,w){return T=g.exports,T=cs(T),I=T.sa,Se(),ar("wasm-instantiate"),T}sr("wasm-instantiate");function s(g){return t(g.instance)}var i=dr();if(r.instantiateWasm)return new Promise((g,w)=>{r.instantiateWasm(i,(E,k)=>{t(E,k),g(E.exports)})});He!=null||(He=ir());try{var c=await cr(A,He,i),h=s(c);return h}catch(g){return d(g),Promise.reject(g)}}var _r={10316881:(t,s,i,c)=>{var h=z(t);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(z(c),h,!1),g.responseType="arraybuffer";for(var w=0,y=s;w<y*2;){var E=S[i/4+w>>>0],k=S[i/4+w+1>>>0];try{var H=encodeURI(z(E));H==="Host"&&(H="X-Host-Override"),H==="User-Agent"&&(H="X-user-agent"),H==="Authorization"?g.setRequestHeader(H,z(k)):g.setRequestHeader(H,encodeURI(z(k)))}catch(te){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",te)}w+=2}try{g.send(null)}catch{return 0}if(g.status>=400)return 0;for(var L=g.response,y=L.byteLength,K=ye(y+4),V=new Uint8Array(L),C=0;C<y;C++)r.HEAPU8[C+K+4]=V[C];var v=new Uint8Array(4);return v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,K),K},10318288:(t,s,i,c,h,g)=>{var w=z(t);if(typeof XMLHttpRequest>"u")return 0;let E=new XMLHttpRequest;E.open(z(c),w,!1),E.responseType="arraybuffer";for(var k=0,v=s;k<v*2;){var H=S[i/4+k>>>0],L=S[i/4+k+1>>>0];try{var y=encodeURI(z(H));y==="Host"&&(y="X-Host-Override"),y==="User-Agent"&&(y="X-user-agent"),y==="Authorization"?E.setRequestHeader(y,z(L)):E.setRequestHeader(y,encodeURI(z(L)))}catch(we){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",we)}k+=2}try{for(var K=new Uint8Array(g),V=0;V<g;V++)K[V]=r.HEAPU8[V+h];E.send(K)}catch{return 0}if(E.status>=400)return 0;for(var C=Uint8Array.from(Array.from(E.getResponseHeader("Etag")).map(we=>we.charCodeAt(0))),v=C.byteLength,te=ye(v+4),le=new Uint8Array(C),V=0;V<v;V++)r.HEAPU8[V+te+4]=le[V];var Z=new Uint8Array(4);return Z[0]=v%256,v-=Z[0],v/=256,Z[1]=v%256,v-=Z[1],v/=256,Z[2]=v%256,v-=Z[2],v/=256,Z[3]=v%256,v-=Z[3],v/=256,r.HEAPU8.set(Z,te),te},10319908:(t,s,i,c)=>{var h=z(t);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(z(c),h,!1),g.responseType="arraybuffer";for(var w=0,y=s;w<y*2;){var E=S[i/4+w>>>0],k=S[i/4+w+1>>>0];try{var H=encodeURI(z(E));H==="Host"&&(H="X-Host-Override"),H==="User-Agent"&&(H="X-user-agent"),H==="Authorization"?g.setRequestHeader(H,z(k)):g.setRequestHeader(H,encodeURI(z(k)))}catch(Z){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Z)}w+=2}try{g.send(null)}catch{return 0}if(g.status>=400)return 0;for(var L=g.response,y=L.byteLength,K=ye(y+8),V=new Uint8Array(L),C=0;C<y;C++)r.HEAPU8[C+K+8]=V[C];var v=new Uint8Array(4);v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,K+4);var te=Uint8Array.from(Array.from(g.getAllResponseHeaders()).map(Z=>Z.charCodeAt(0)));y=te.byteLength;for(var le=ye(y+8),C=0;C<y;C++)r.HEAPU8[C+le+8]=te[C];return v=new Uint8Array(4),v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,le+4),y=le,v=new Uint8Array(4),v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,K),K},10322192:(t,s,i,c)=>{var h=z(t);if(typeof XMLHttpRequest>"u")return 0;let g=new XMLHttpRequest;g.open(z(c),h,!1),g.responseType="arraybuffer";for(var w=0,y=s;w<y*2;){var E=S[i/4+w>>>0],k=S[i/4+w+1>>>0];try{var H=encodeURI(z(E));H==="Host"&&(H="X-Host-Override"),H==="User-Agent"&&(H="X-user-agent"),H==="Authorization"?g.setRequestHeader(H,z(k)):g.setRequestHeader(H,encodeURI(z(k)))}catch(te){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",te)}w+=2}try{g.send(null)}catch{return 0}if(g.status>=400)return 0;for(var L=g.response,y=L.byteLength,K=ye(y+4),V=new Uint8Array(L),C=0;C<y;C++)r.HEAPU8[C+K+4]=V[C];var v=new Uint8Array(4);return v[0]=y%256,y-=v[0],y/=256,v[1]=y%256,y-=v[1],y/=256,v[2]=y%256,y-=v[2],y/=256,v[3]=y%256,y-=v[3],y/=256,r.HEAPU8.set(v,K),K},10323599:(t,s,i,c,h,g)=>{var w=z(t);if(typeof XMLHttpRequest>"u")return 0;let E=new XMLHttpRequest;E.open(z(c),w,!1),E.responseType="arraybuffer";for(var k=0,v=s;k<v*2;){var H=S[i/4+k>>>0],L=S[i/4+k+1>>>0];try{var y=encodeURI(z(H));y==="Host"&&(y="X-Host-Override"),y==="User-Agent"&&(y="X-user-agent"),y==="Authorization"?E.setRequestHeader(y,z(L)):E.setRequestHeader(y,encodeURI(z(L)))}catch(we){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",we)}k+=2}try{for(var K=new Uint8Array(g),V=0;V<g;V++)K[V]=r.HEAPU8[V+h];E.send(K)}catch{return 0}if(E.status>=400)return 0;for(var C=E.response,v=C.byteLength,te=ye(v+4),le=new Uint8Array(C),V=0;V<v;V++)r.HEAPU8[V+te+4]=le[V];var Z=new Uint8Array(4);return Z[0]=v%256,v-=Z[0],v/=256,Z[1]=v%256,v-=Z[1],v/=256,Z[2]=v%256,v-=Z[2],v/=256,Z[3]=v%256,v-=Z[3],v/=256,r.HEAPU8.set(Z,te),te}};class lt{constructor(s){Mt(this,"name","ExitStatus");this.message=`Program terminated with exit(${s})`,this.status=s}}var ut=t=>{for(;t.length>0;)t.shift()(r)},ct=[],hr=t=>ct.unshift(t),dt=[],br=t=>dt.unshift(t),pr=r.noExitRuntime||!0;function ft(){he("missing function: $SOCKFS")}ft.stub=!0;function je(){he("missing function: $FS")}je.stub=!0;var De=t=>{var s=ft.getSocket(t);if(!s)throw new je.ErrnoError(8);return s},ze=t=>(t&255)+"."+(t>>8&255)+"."+(t>>16&255)+"."+(t>>24&255),_t=t=>{var s="",i=0,c=0,h=0,g=0,w=0,E=0,k=[t[0]&65535,t[0]>>16,t[1]&65535,t[1]>>16,t[2]&65535,t[2]>>16,t[3]&65535,t[3]>>16],H=!0,L="";for(E=0;E<5;E++)if(k[E]!==0){H=!1;break}if(H){if(L=ze(k[6]|k[7]<<16),k[5]===-1)return s="::ffff:",s+=L,s;if(k[5]===0)return s="::",L==="0.0.0.0"&&(L=""),L==="0.0.0.1"&&(L="1"),s+=L,s}for(i=0;i<8;i++)k[i]===0&&(i-h>1&&(w=0),h=i,w++),w>c&&(c=w,g=i-c+1);for(i=0;i<8;i++){if(c>1&&k[i]===0&&i>=g&&i<g+c){i===g&&(s+=":",g===0&&(s+=":"));continue}s+=Number(_ntohs(k[i]&65535)).toString(16),s+=i<7?":":""}return s},ht=(t,s)=>{var i=U[t>>>1>>>0],c=_ntohs(x[t+2>>>1>>>0]),h;switch(i){case 2:if(s!==16)return{errno:28};h=S[t+4>>>2>>>0],h=ze(h);break;case 10:if(s!==28)return{errno:28};h=[S[t+8>>>2>>>0],S[t+12>>>2>>>0],S[t+16>>>2>>>0],S[t+20>>>2>>>0]],h=_t(h);break;default:return{errno:5}}return{family:i,addr:h,port:c}},Be=t=>{for(var s=t.split("."),i=0;i<4;i++){var c=Number(s[i]);if(isNaN(c))return null;s[i]=c}return(s[0]|s[1]<<8|s[2]<<16|s[3]<<24)>>>0},Me=t=>parseInt(t),Ye=t=>{var s,i,c,h,g=/^((?=.*::)(?!.*::.+::)(::)?([\dA-F]{1,4}:(:|\b)|){5}|([\dA-F]{1,4}:){6})((([\dA-F]{1,4}((?!\3)::|:\b|$))|(?!\2\3)){2}|(((2[0-4]|1\d|[1-9])?\d|25[0-5])\.?\b){4})$/i,w=[];if(!g.test(t))return null;if(t==="::")return[0,0,0,0,0,0,0,0];for(t.startsWith("::")?t=t.replace("::","Z:"):t=t.replace("::",":Z:"),t.indexOf(".")>0?(t=t.replace(new RegExp("[.]","g"),":"),s=t.split(":"),s[s.length-4]=Me(s[s.length-4])+Me(s[s.length-3])*256,s[s.length-3]=Me(s[s.length-2])+Me(s[s.length-1])*256,s=s.slice(0,s.length-2)):s=t.split(":"),c=0,h=0,i=0;i<s.length;i++)if(typeof s[i]=="string")if(s[i]==="Z"){for(h=0;h<8-s.length+1;h++)w[i+h]=0;c=h-1}else w[i+c]=_htons(parseInt(s[i],16));else w[i+c]=s[i];return[w[1]<<16|w[0],w[3]<<16|w[2],w[5]<<16|w[4],w[7]<<16|w[6]]},ie={address_map:{id:1,addrs:{},names:{}},lookup_name(t){var s=Be(t);if(s!==null||(s=Ye(t),s!==null))return t;var i;if(ie.address_map.addrs[t])i=ie.address_map.addrs[t];else{var c=ie.address_map.id++;F(c<65535,"exceeded max address mappings of 65535"),i="172.29."+(c&255)+"."+(c&65280),ie.address_map.names[i]=t,ie.address_map.addrs[t]=i}return i},lookup_addr(t){return ie.address_map.names[t]?ie.address_map.names[t]:null}},bt=(t,s)=>{var i=ht(t,s);if(i.errno)throw new je.ErrnoError(i.errno);return i.addr=ie.lookup_addr(i.addr)||i.addr,i},mr=9007199254740992,gr=-9007199254740992,me=t=>t<gr||t>mr?NaN:Number(t);function yr(t,s,i,c,h,g){s>>>=0,i>>>=0;var w=De(t),E=bt(s,i);return w.sock_ops.bind(w,E.addr,E.port),0}function wr(t,s,i,c,h,g){s>>>=0,i>>>=0;var w=De(t),E=bt(s,i);return w.sock_ops.connect(w,E.addr,E.port),0}var Er=(t,s,i)=>{};function vr(t,s,i,c){s>>>=0}var pt=typeof TextDecoder<"u"?new TextDecoder:void 0,mt=(t,s=0,i=NaN)=>{s>>>=0;for(var c=s+i,h=s;t[h]&&!(h>=c);)++h;if(h-s>16&&t.buffer&&pt)return pt.decode(t.subarray(s,h));for(var g="";s<h;){var w=t[s++];if(!(w&128)){g+=String.fromCharCode(w);continue}var E=t[s++]&63;if((w&224)==192){g+=String.fromCharCode((w&31)<<6|E);continue}var k=t[s++]&63;if((w&240)==224?w=(w&15)<<12|E<<6|k:w=(w&7)<<18|E<<12|k<<6|t[s++]&63,w<65536)g+=String.fromCharCode(w);else{var H=w-65536;g+=String.fromCharCode(55296|H>>10,56320|H&1023)}}return g},z=(t,s)=>(t>>>=0,t?mt(p,t,s):""),Qe={varargs:void 0,getStr(t){var s=z(t);return s}};function Fr(t,s,i){return i>>>=0,Qe.varargs=i,0}function Ar(t,s){s>>>=0}function Sr(t,s){s=me(s)}var gt=t=>{for(var s=0,i=0;i<t.length;++i){var c=t.charCodeAt(i);c<=127?s++:c<=2047?s+=2:c>=55296&&c<=57343?(s+=4,++i):s+=3}return s};r.lengthBytesUTF8=gt;var Rr=(t,s,i,c)=>{if(i>>>=0,!(c>0))return 0;for(var h=i,g=i+c-1,w=0;w<t.length;++w){var E=t.charCodeAt(w);if(E>=55296&&E<=57343){var k=t.charCodeAt(++w);E=65536+((E&1023)<<10)|k&1023}if(E<=127){if(i>=g)break;s[i++>>>0]=E}else if(E<=2047){if(i+1>=g)break;s[i++>>>0]=192|E>>6,s[i++>>>0]=128|E&63}else if(E<=65535){if(i+2>=g)break;s[i++>>>0]=224|E>>12,s[i++>>>0]=128|E>>6&63,s[i++>>>0]=128|E&63}else{if(i+3>=g)break;s[i++>>>0]=240|E>>18,s[i++>>>0]=128|E>>12&63,s[i++>>>0]=128|E>>6&63,s[i++>>>0]=128|E&63}}return s[i>>>0]=0,i-h},ge=(t,s,i)=>Rr(t,p,s,i);r.stringToUTF8=ge;function Dr(t,s){t>>>=0,s>>>=0}function kr(t,s,i){s>>>=0,i>>>=0}var yt=(t,s)=>{p.fill(0,t,t+s)},Le=(t,s,i,c,h)=>{switch(s){case 2:i=Be(i),yt(t,16),h&&(S[h>>>2>>>0]=16),U[t>>>1>>>0]=s,S[t+4>>>2>>>0]=i,U[t+2>>>1>>>0]=_htons(c);break;case 10:i=Ye(i),yt(t,28),h&&(S[h>>>2>>>0]=28),S[t>>>2>>>0]=s,S[t+8>>>2>>>0]=i[0],S[t+12>>>2>>>0]=i[1],S[t+16>>>2>>>0]=i[2],S[t+20>>>2>>>0]=i[3],U[t+2>>>1>>>0]=_htons(c);break;default:return 5}return 0};function Ir(t,s,i,c,h,g){s>>>=0,i>>>=0;var w=De(t);if(!w.daddr)return-53;var E=Le(s,w.family,ie.lookup_name(w.daddr),w.dport,i);return 0}function Ur(t,s,i,c,h,g){s>>>=0,i>>>=0;var w=De(t),E=Le(s,w.family,ie.lookup_name(w.saddr||"0.0.0.0"),w.sport,i);return 0}function Tr(t,s,i,c,h,g){c>>>=0,h>>>=0;var w=De(t);return s===1&&i===4?(S[c>>>2>>>0]=w.error,S[h>>>2>>>0]=4,w.error=null,0):-50}function Hr(t,s,i){return i>>>=0,Qe.varargs=i,0}function Pr(t,s){t>>>=0,s>>>=0}function xr(t,s,i){s>>>=0}function Br(t,s,i,c){s>>>=0,i>>>=0}function Mr(t,s,i,c){s>>>=0,c>>>=0,Qe.varargs=c}function Lr(t,s,i){t>>>=0}function Cr(t,s,i,c,h,g){s>>>=0,i>>>=0,h>>>=0,g>>>=0;var w=De(t),E=w.sock_ops.recvmsg(w,i);if(!E)return 0;if(h)var k=Le(h,w.family,ie.lookup_name(E.addr),E.port,g);return p.set(E.buffer,s>>>0),E.buffer.byteLength}function Or(t,s,i,c){s>>>=0,c>>>=0}function Nr(t){t>>>=0}function Wr(t,s,i,c,h,g){s>>>=0,i>>>=0,h>>>=0,g>>>=0}var Gr=(t,s,i)=>{};function Kr(t,s){t>>>=0,s>>>=0}function $r(t,s,i){t>>>=0,s>>>=0,i>>>=0}function Xr(t,s,i){s>>>=0}var Vr=()=>he("");function wt(){he("missing function: _emval_call_method")}wt.stub=!0;function Et(){he("missing function: _emval_decref")}Et.stub=!0;function vt(){he("missing function: _emval_get_global")}vt.stub=!0;function Ft(){he("missing function: _emval_get_method_caller")}Ft.stub=!0;function At(){he("missing function: _emval_run_destructors")}At.stub=!0;var qr=t=>t%4===0&&(t%100!==0||t%400===0),Jr=[0,31,60,91,121,152,182,213,244,274,305,335],jr=[0,31,59,90,120,151,181,212,243,273,304,334],zr=t=>{var s=qr(t.getFullYear()),i=s?Jr:jr,c=i[t.getMonth()]+t.getDate()-1;return c};function Yr(t,s){t=me(t),s>>>=0;var i=new Date(t*1e3);S[s>>>2>>>0]=i.getSeconds(),S[s+4>>>2>>>0]=i.getMinutes(),S[s+8>>>2>>>0]=i.getHours(),S[s+12>>>2>>>0]=i.getDate(),S[s+16>>>2>>>0]=i.getMonth(),S[s+20>>>2>>>0]=i.getFullYear()-1900,S[s+24>>>2>>>0]=i.getDay();var c=zr(i)|0;S[s+28>>>2>>>0]=c,S[s+36>>>2>>>0]=-(i.getTimezoneOffset()*60);var h=new Date(i.getFullYear(),0,1),g=new Date(i.getFullYear(),6,1).getTimezoneOffset(),w=h.getTimezoneOffset(),E=(g!=w&&i.getTimezoneOffset()==Math.min(w,g))|0;S[s+32>>>2>>>0]=E}function Qr(t,s,i,c,h,g,w){return t>>>=0,h=me(h),g>>>=0,w>>>=0,-52}function Zr(t,s,i,c,h,g){t>>>=0,s>>>=0,g=me(g)}var en=function(t,s,i,c){t>>>=0,s>>>=0,i>>>=0,c>>>=0;var h=new Date().getFullYear(),g=new Date(h,0,1),w=new Date(h,6,1),E=g.getTimezoneOffset(),k=w.getTimezoneOffset(),H=Math.max(E,k);$[t>>>2>>>0]=H*60,S[s>>>2>>>0]=+(E!=k);var L=V=>{var C=V>=0?"-":"+",v=Math.abs(V),te=String(Math.floor(v/60)).padStart(2,"0"),le=String(v%60).padStart(2,"0");return`UTC${C}${te}${le}`},y=L(E),K=L(k);k<E?(ge(y,i,17),ge(K,c,17)):(ge(y,c,17),ge(K,i,17))},St=()=>performance.now(),Rt=()=>Date.now(),tn=1,rn=t=>t>=0&&t<=3;function nn(t,s,i){if(s=me(s),i>>>=0,!rn(t))return 28;var c;if(t===0)c=Rt();else if(tn)c=St();else return 52;var h=Math.round(c*1e3*1e3);return G[i>>>3]=BigInt(h),0}function sn(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.createDirectory(r,t,s)}function an(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.checkDirectory(r,t,s)}function on(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.listDirectoryEntries(r,t,s)}function ln(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.removeDirectory(r,t,s)}function un(t){return globalThis.DUCKDB_RUNTIME.closeFile(r,t)}function cn(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.dropFile(r,t,s)}function dn(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.checkFile(r,t,s)}function fn(t,s,i,c){return t>>>=0,i>>>=0,globalThis.DUCKDB_RUNTIME.moveFile(r,t,s,i,c)}function _n(t,s){return globalThis.DUCKDB_RUNTIME.openFile(r,t,s)}function hn(t,s,i,c){return s>>>=0,globalThis.DUCKDB_RUNTIME.readFile(r,t,s,i,c)}function bn(t,s){return globalThis.DUCKDB_RUNTIME.truncateFile(r,t,s)}function pn(t,s,i,c){return s>>>=0,globalThis.DUCKDB_RUNTIME.writeFile(r,t,s,i,c)}function mn(t){return globalThis.DUCKDB_RUNTIME.getDefaultDataProtocol(t)}function gn(t,s){return t>>>=0,globalThis.DUCKDB_RUNTIME.glob(r,t,s)}function yn(t){return globalThis.DUCKDB_RUNTIME.testPlatformFeature(r,t)}function wn(t,s,i,c,h,g){return t>>>=0,i>>>=0,h>>>=0,globalThis.DUCKDB_RUNTIME.callScalarUDF(r,t,s,i,c,h,g)}var Ze=[],En=(t,s)=>{Ze.length=0;for(var i;i=p[t++>>>0];){var c=i!=105;c&=i!=112,s+=c&&s%8?4:0,Ze.push(i==112?$[s>>>2>>>0]:i==106?G[s>>>3]:i==105?S[s>>>2>>>0]:oe[s>>>3>>>0]),s+=c?8:4}return Ze},vn=(t,s,i)=>{var c=En(s,i);return _r[t](...c)};function Fn(t,s,i){return t>>>=0,s>>>=0,i>>>=0,vn(t,s,i)}var Dt=()=>4294901760;function An(){return Dt()}var Sn=(t,s)=>Math.ceil(t/s)*s,Rn=t=>{var s=I.buffer,i=(t-s.byteLength+65535)/65536|0;try{return I.grow(i),Se(),1}catch{}};function Dn(t){t>>>=0;var s=p.length,i=Dt();if(t>i)return!1;for(var c=1;c<=4;c*=2){var h=s*(1+.2/c);h=Math.min(h,t+100663296);var g=Math.min(i,Sn(Math.max(t,h),65536)),w=Rn(g);if(w)return!0}return!1}var et={},kn=()=>R||"./this.program",Pe=()=>{if(!Pe.strings){var t=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",s={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:t,_:kn()};for(var i in et)et[i]===void 0?delete s[i]:s[i]=et[i];var c=[];for(var i in s)c.push(`${i}=${s[i]}`);Pe.strings=c}return Pe.strings},In=(t,s)=>{for(var i=0;i<t.length;++i)P[s++>>>0]=t.charCodeAt(i);P[s>>>0]=0},Un=function(t,s){t>>>=0,s>>>=0;var i=0;return Pe().forEach((c,h)=>{var g=s+i;$[t+h*4>>>2>>>0]=g,In(c,g),i+=c.length+1}),0},Tn=function(t,s){t>>>=0,s>>>=0;var i=Pe();$[t>>>2>>>0]=i.length;var c=0;return i.forEach(h=>c+=h.length+1),$[s>>>2>>>0]=c,0},Hn=0,Pn=()=>pr||Hn>0,xn=t=>{var s;D=t,Pn()||((s=r.onExit)==null||s.call(r,t),m=!0),M(t,new lt(t))},kt=(t,s)=>{D=t,xn(t)},Bn=kt,Mn=t=>52;function Ln(t,s){s>>>=0;var i=0,c=0,h=0;{var g=2;t==0?i=2:(t==1||t==2)&&(i=64),h=1}return P[s>>>0]=g,U[s+2>>>1>>>0]=h,G[s+8>>>3]=BigInt(i),G[s+16>>>3]=BigInt(c),0}function Cn(t,s,i,c,h){return s>>>=0,i>>>=0,c=me(c),h>>>=0,52}function On(t,s,i,c,h){return s>>>=0,i>>>=0,c=me(c),h>>>=0,52}function Nn(t,s,i,c){return s>>>=0,i>>>=0,c>>>=0,52}function Wn(t,s,i,c){return s=me(s),c>>>=0,70}var Gn=t=>52,Kn=[null,[],[]],$n=(t,s)=>{var i=Kn[t];s===0||s===10?((t===1?ne:b)(mt(i)),i.length=0):i.push(s)};function Xn(t,s,i,c){s>>>=0,i>>>=0,c>>>=0;for(var h=0,g=0;g<i;g++){var w=$[s>>>2>>>0],E=$[s+4>>>2>>>0];s+=8;for(var k=0;k<E;k++)$n(t,p[w+k>>>0]);h+=E}return $[c>>>2>>>0]=h,0}function Vn(t,s,i,c){t>>>=0,s>>>=0,i>>>=0,c>>>=0;var h=0,g=0,w=0,E=0,k=0,H=0,L;function y(K,V,C,v,te,le){var Z,we,be,Ht;return we=K===10?28:16,te=K===10?_t(te):ze(te),Z=ye(we),Ht=Le(Z,K,te,le),F(!Ht),be=ye(32),S[be+4>>>2>>>0]=K,S[be+8>>>2>>>0]=V,S[be+12>>>2>>>0]=C,$[be+24>>>2>>>0]=v,$[be+20>>>2>>>0]=Z,K===10?S[be+16>>>2>>>0]=28:S[be+16>>>2>>>0]=16,S[be+28>>>2>>>0]=0,be}if(i&&(w=S[i>>>2>>>0],E=S[i+4>>>2>>>0],k=S[i+8>>>2>>>0],H=S[i+12>>>2>>>0]),k&&!H&&(H=k===2?17:6),!k&&H&&(k=H===17?2:1),H===0&&(H=6),k===0&&(k=1),!t&&!s)return-2;if(w&-1088||i!==0&&S[i>>>2>>>0]&2&&!t)return-1;if(w&32)return-2;if(k!==0&&k!==1&&k!==2)return-7;if(E!==0&&E!==2&&E!==10)return-6;if(s&&(s=z(s),g=parseInt(s,10),isNaN(g)))return w&1024?-2:-8;if(!t)return E===0&&(E=2),(w&1)===0&&(E===2?h=_htonl(2130706433):h=[0,0,0,_htonl(1)]),L=y(E,k,H,null,h,g),$[c>>>2>>>0]=L,0;if(t=z(t),h=Be(t),h!==null)if(E===0||E===2)E=2;else if(E===10&&w&8)h=[0,0,_htonl(65535),h],E=10;else return-2;else if(h=Ye(t),h!==null)if(E===0||E===10)E=10;else return-2;return h!=null?(L=y(E,k,H,t,h,g),$[c>>>2>>>0]=L,0):w&4?-2:(t=ie.lookup_name(t),h=Be(t),E===0?E=2:E===10&&(h=[0,0,_htonl(65535),h]),L=y(E,k,H,null,h,g),$[c>>>2>>>0]=L,0)}function qn(t,s,i,c,h,g,w){t>>>=0,i>>>=0,h>>>=0;var E=ht(t,s);if(E.errno)return-6;var k=E.port,H=E.addr,L=!1;if(i&&c){var y;if(w&1||!(y=ie.lookup_addr(H))){if(w&8)return-2}else H=y;var K=ge(H,i,c);K+1>=c&&(L=!0)}if(h&&g){k=""+k;var K=ge(k,h,g);K+1>=g&&(L=!0)}return L?-12:0}var Jn=()=>{if(_){var t=["crypto"].map(Pt)[0];return s=>t.randomFillSync(s)}return s=>crypto.getRandomValues(s)},It=t=>{(It=Jn())(t)};function jn(t,s){return t>>>=0,s>>>=0,It(p.subarray(t>>>0,t+s>>>0)),0}var zn=t=>{if(t instanceof lt||t=="unwind")return D;M(1,t)},Yn=t=>{var s=r["_"+t];return s},Qn=(t,s)=>{P.set(t,s>>>0)},Ce=t=>ls(t);r.stackAlloc=Ce;var Zn=t=>{var s=gt(t)+1,i=Ce(s);return ge(t,i,s),i},Ut=()=>us(),Tt=t=>os(t),es=(t,s,i,c,h)=>{var g={string:C=>{var v=0;return C!=null&&C!==0&&(v=Zn(C)),v},array:C=>{var v=Ce(C.length);return Qn(C,v),v}};function w(C){return s==="string"?z(C):s==="boolean"?!!C:C}var E=Yn(t),k=[],H=0;if(c)for(var L=0;L<c.length;L++){var y=g[i[L]];y?(H===0&&(H=Ut()),k[L]=y(c[L])):k[L]=c[L]}var K=E(...k);function V(C){return H!==0&&Tt(H),w(C)}return K=V(K),K},ts=t=>is(),rs=t=>as(t),ns={la:yr,ka:wr,A:Er,ba:vr,b:Fr,aa:Ar,W:Sr,ca:Dr,U:kr,fa:Ir,ea:Ur,ia:Tr,i:Hr,Z:Pr,V:xr,_:Br,s:Mr,ja:Lr,ga:Cr,S:Or,n:Nr,ha:Wr,r:Gr,$:Kr,da:$r,o:Xr,qa:Vr,x:wt,y:Et,z:vt,w:Ft,u:At,Q:Yr,O:Qr,P:Zr,oa:en,ma:nn,G:sn,H:an,E:on,F:ln,m:un,K:cn,C:dn,D:fn,J:_n,g:hn,I:bn,h:pn,L:mn,B:gn,k:yn,N:wn,e:Fn,j:Rt,na:An,c:St,ra:Dn,pa:Un,t:Tn,a:Bn,d:Mn,M:Ln,Y:Cn,X:On,l:Nn,v:Wn,T:Gn,f:Xn,q:Vn,p:qn,R:jn},T=await fr(),ss=r._main=T.ua,Ts=r._duckdb_web_fs_glob_add_path=T.wa,Hs=r._duckdb_web_clear_response=T.xa,Ps=r._duckdb_web_fail_with=T.ya,xs=r._duckdb_web_reset=T.za,Bs=r._duckdb_web_connect=T.Aa,Ms=r._duckdb_web_disconnect=T.Ba,Ls=r._duckdb_web_flush_files=T.Ca,Cs=r._duckdb_web_flush_file=T.Da,Os=r._duckdb_web_open=T.Ea,Ns=r._duckdb_web_get_global_file_info=T.Fa,Ws=r._duckdb_web_collect_file_stats=T.Ga,Gs=r._duckdb_web_export_file_stats=T.Ha,Ks=r._duckdb_web_fs_drop_file=T.Ia,$s=r._duckdb_web_fs_drop_files=T.Ja,Xs=r._duckdb_web_fs_glob_file_infos=T.Ka,Vs=r._duckdb_web_fs_get_file_info_by_id=T.La,qs=r._duckdb_web_fs_get_file_info_by_name=T.Ma,Js=r._duckdb_web_fs_register_file_url=T.Na,js=r._duckdb_web_fs_register_file_buffer=T.Oa,zs=r._duckdb_web_copy_file_to_buffer=T.Pa,Ys=r._duckdb_web_copy_file_to_path=T.Qa,Qs=r._duckdb_web_get_version=T.Ra,Zs=r._duckdb_web_get_feature_flags=T.Sa,ea=r._duckdb_web_tokenize=T.Ta,ta=r._duckdb_web_tokenize_buffer=T.Ua,ra=r._duckdb_web_udf_scalar_create=T.Va,na=r._duckdb_web_prepared_create=T.Wa,sa=r._duckdb_web_prepared_create_buffer=T.Xa,aa=r._duckdb_web_prepared_close=T.Ya,ia=r._duckdb_web_prepared_run=T.Za,oa=r._duckdb_web_prepared_send=T._a,la=r._duckdb_web_query_run=T.$a,ua=r._duckdb_web_query_run_buffer=T.ab,ca=r._duckdb_web_pending_query_start=T.bb,da=r._duckdb_web_pending_query_start_buffer=T.cb,fa=r._duckdb_web_pending_query_poll=T.db,_a=r._duckdb_web_pending_query_cancel=T.eb,ha=r._duckdb_web_query_fetch_results=T.fb,ba=r._duckdb_web_get_tablenames=T.gb,pa=r._duckdb_web_get_tablenames_buffer=T.hb,ma=r._duckdb_web_insert_arrow_from_ipc_stream=T.ib,ga=r._duckdb_web_insert_csv_from_path=T.jb,ya=r._duckdb_web_insert_json_from_path=T.kb,ye=r._malloc=T.ob,wa=r._free=T.pb,Ea=r._calloc=T.qb,as=T.sb,is=T.tb,os=T.ub,ls=T.vb,us=T.wb;function cs(t){t=Object.assign({},t);var s=h=>g=>h(g)>>>0,i=h=>(g,w)=>h(g,w)>>>0,c=h=>()=>h()>>>0;return t.ob=s(t.ob),t.qb=i(t.qb),t.vb=s(t.vb),t.wb=c(t.wb),t}r.stackSave=Ut,r.stackRestore=Tt,r.stackAlloc=Ce,r.getTempRet0=ts,r.setTempRet0=rs,r.ccall=es;function ds(){var t=ss,s=0,i=0;try{var c=t(s,i);return kt(c,!0),c}catch(h){return zn(h)}}function tt(){if(ve>0){Te=tt;return}if(Re(),ve>0){Te=tt;return}function t(){var i;if(r.calledRun=!0,!m){rr(),l(r),(i=r.onRuntimeInitialized)==null||i.call(r);var s=r.noInitialRun;s||ds(),nr()}}r.setStatus?(r.setStatus("Running..."),setTimeout(()=>{setTimeout(()=>r.setStatus(""),1),t()},1)):t()}if(r.preInit)for(typeof r.preInit=="function"&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();return tt(),o=f,o}})();typeof Xt=="object"&&typeof Xe=="object"?(Xe.exports=it,Xe.exports.default=it):typeof define=="function"&&define.amd&&define([],()=>it)});var Jt=ke(()=>{});var jt=ke(()=>{});var zt=ke((Ja,Je)=>{(function(){"use strict";var a="input is invalid type",e=typeof window=="object",n=e?window:{};n.JS_SHA256_NO_WINDOW&&(e=!1);var o=!e&&typeof self=="object",r=!n.JS_SHA256_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node&&process.type!="renderer";r?n=global:o&&(n=self);var l=!n.JS_SHA256_NO_COMMON_JS&&typeof Je=="object"&&Je.exports,d=typeof define=="function"&&define.amd,f=!n.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),O=[-2147483648,8388608,32768,128],_=[24,16,8,0],N=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Y=["hex","array","digest","arrayBuffer"],R=[];(n.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(b){return Object.prototype.toString.call(b)==="[object Array]"}),f&&(n.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(b){return typeof b=="object"&&b.buffer&&b.buffer.constructor===ArrayBuffer});var M=function(b,A){return function(I){return new q(A,!0).update(I)[b]()}},X=function(b){var A=M("hex",b);r&&(A=Q(A,b)),A.create=function(){return new q(b)},A.update=function(D){return A.create().update(D)};for(var I=0;I<Y.length;++I){var m=Y[I];A[m]=M(m,b)}return A},Q=function(b,A){var I=Jt(),m=jt().Buffer,D=A?"sha224":"sha256",F;m.from&&!n.JS_SHA256_NO_BUFFER_FROM?F=m.from:F=function(p){return new m(p)};var P=function(p){if(typeof p=="string")return I.createHash(D).update(p,"utf8").digest("hex");if(p==null)throw new Error(a);return p.constructor===ArrayBuffer&&(p=new Uint8Array(p)),Array.isArray(p)||ArrayBuffer.isView(p)||p.constructor===m?I.createHash(D).update(F(p)).digest("hex"):b(p)};return P},re=function(b,A){return function(I,m){return new se(I,A,!0).update(m)[b]()}},J=function(b){var A=re("hex",b);A.create=function(D){return new se(D,b)},A.update=function(D,F){return A.create(D).update(F)};for(var I=0;I<Y.length;++I){var m=Y[I];A[m]=re(m,b)}return A};function q(b,A){A?(R[0]=R[16]=R[1]=R[2]=R[3]=R[4]=R[5]=R[6]=R[7]=R[8]=R[9]=R[10]=R[11]=R[12]=R[13]=R[14]=R[15]=0,this.blocks=R):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],b?(this.h0=3238371032,this.h1=914150663,this.h2=812702999,this.h3=4144912697,this.h4=4290775857,this.h5=1750603025,this.h6=1694076839,this.h7=3204075428):(this.h0=1779033703,this.h1=3144134277,this.h2=1013904242,this.h3=2773480762,this.h4=1359893119,this.h5=2600822924,this.h6=528734635,this.h7=1541459225),this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0,this.is224=b}q.prototype.update=function(b){if(!this.finalized){var A,I=typeof b;if(I!=="string"){if(I==="object"){if(b===null)throw new Error(a);if(f&&b.constructor===ArrayBuffer)b=new Uint8Array(b);else if(!Array.isArray(b)&&(!f||!ArrayBuffer.isView(b)))throw new Error(a)}else throw new Error(a);A=!0}for(var m,D=0,F,P=b.length,p=this.blocks;D<P;){if(this.hashed&&(this.hashed=!1,p[0]=this.block,this.block=p[16]=p[1]=p[2]=p[3]=p[4]=p[5]=p[6]=p[7]=p[8]=p[9]=p[10]=p[11]=p[12]=p[13]=p[14]=p[15]=0),A)for(F=this.start;D<P&&F<64;++D)p[F>>>2]|=b[D]<<_[F++&3];else for(F=this.start;D<P&&F<64;++D)m=b.charCodeAt(D),m<128?p[F>>>2]|=m<<_[F++&3]:m<2048?(p[F>>>2]|=(192|m>>>6)<<_[F++&3],p[F>>>2]|=(128|m&63)<<_[F++&3]):m<55296||m>=57344?(p[F>>>2]|=(224|m>>>12)<<_[F++&3],p[F>>>2]|=(128|m>>>6&63)<<_[F++&3],p[F>>>2]|=(128|m&63)<<_[F++&3]):(m=65536+((m&1023)<<10|b.charCodeAt(++D)&1023),p[F>>>2]|=(240|m>>>18)<<_[F++&3],p[F>>>2]|=(128|m>>>12&63)<<_[F++&3],p[F>>>2]|=(128|m>>>6&63)<<_[F++&3],p[F>>>2]|=(128|m&63)<<_[F++&3]);this.lastByteIndex=F,this.bytes+=F-this.start,F>=64?(this.block=p[16],this.start=F-64,this.hash(),this.hashed=!0):this.start=F}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},q.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var b=this.blocks,A=this.lastByteIndex;b[16]=this.block,b[A>>>2]|=O[A&3],this.block=b[16],A>=56&&(this.hashed||this.hash(),b[0]=this.block,b[16]=b[1]=b[2]=b[3]=b[4]=b[5]=b[6]=b[7]=b[8]=b[9]=b[10]=b[11]=b[12]=b[13]=b[14]=b[15]=0),b[14]=this.hBytes<<3|this.bytes>>>29,b[15]=this.bytes<<3,this.hash()}},q.prototype.hash=function(){var b=this.h0,A=this.h1,I=this.h2,m=this.h3,D=this.h4,F=this.h5,P=this.h6,p=this.h7,U=this.blocks,x,S,$,fe,G,_e,oe,pe,Ae,Se,Re;for(x=16;x<64;++x)G=U[x-15],S=(G>>>7|G<<25)^(G>>>18|G<<14)^G>>>3,G=U[x-2],$=(G>>>17|G<<15)^(G>>>19|G<<13)^G>>>10,U[x]=U[x-16]+S+U[x-7]+$<<0;for(Re=A&I,x=0;x<64;x+=4)this.first?(this.is224?(pe=300032,G=U[0]-1413257819,p=G-150054599<<0,m=G+24177077<<0):(pe=704751109,G=U[0]-210244248,p=G-1521486534<<0,m=G+143694565<<0),this.first=!1):(S=(b>>>2|b<<30)^(b>>>13|b<<19)^(b>>>22|b<<10),$=(D>>>6|D<<26)^(D>>>11|D<<21)^(D>>>25|D<<7),pe=b&A,fe=pe^b&I^Re,oe=D&F^~D&P,G=p+$+oe+N[x]+U[x],_e=S+fe,p=m+G<<0,m=G+_e<<0),S=(m>>>2|m<<30)^(m>>>13|m<<19)^(m>>>22|m<<10),$=(p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7),Ae=m&b,fe=Ae^m&A^pe,oe=p&D^~p&F,G=P+$+oe+N[x+1]+U[x+1],_e=S+fe,P=I+G<<0,I=G+_e<<0,S=(I>>>2|I<<30)^(I>>>13|I<<19)^(I>>>22|I<<10),$=(P>>>6|P<<26)^(P>>>11|P<<21)^(P>>>25|P<<7),Se=I&m,fe=Se^I&b^Ae,oe=P&p^~P&D,G=F+$+oe+N[x+2]+U[x+2],_e=S+fe,F=A+G<<0,A=G+_e<<0,S=(A>>>2|A<<30)^(A>>>13|A<<19)^(A>>>22|A<<10),$=(F>>>6|F<<26)^(F>>>11|F<<21)^(F>>>25|F<<7),Re=A&I,fe=Re^A&m^Se,oe=F&P^~F&p,G=D+$+oe+N[x+3]+U[x+3],_e=S+fe,D=b+G<<0,b=G+_e<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+b<<0,this.h1=this.h1+A<<0,this.h2=this.h2+I<<0,this.h3=this.h3+m<<0,this.h4=this.h4+D<<0,this.h5=this.h5+F<<0,this.h6=this.h6+P<<0,this.h7=this.h7+p<<0},q.prototype.hex=function(){this.finalize();var b=this.h0,A=this.h1,I=this.h2,m=this.h3,D=this.h4,F=this.h5,P=this.h6,p=this.h7,U=u[b>>>28&15]+u[b>>>24&15]+u[b>>>20&15]+u[b>>>16&15]+u[b>>>12&15]+u[b>>>8&15]+u[b>>>4&15]+u[b&15]+u[A>>>28&15]+u[A>>>24&15]+u[A>>>20&15]+u[A>>>16&15]+u[A>>>12&15]+u[A>>>8&15]+u[A>>>4&15]+u[A&15]+u[I>>>28&15]+u[I>>>24&15]+u[I>>>20&15]+u[I>>>16&15]+u[I>>>12&15]+u[I>>>8&15]+u[I>>>4&15]+u[I&15]+u[m>>>28&15]+u[m>>>24&15]+u[m>>>20&15]+u[m>>>16&15]+u[m>>>12&15]+u[m>>>8&15]+u[m>>>4&15]+u[m&15]+u[D>>>28&15]+u[D>>>24&15]+u[D>>>20&15]+u[D>>>16&15]+u[D>>>12&15]+u[D>>>8&15]+u[D>>>4&15]+u[D&15]+u[F>>>28&15]+u[F>>>24&15]+u[F>>>20&15]+u[F>>>16&15]+u[F>>>12&15]+u[F>>>8&15]+u[F>>>4&15]+u[F&15]+u[P>>>28&15]+u[P>>>24&15]+u[P>>>20&15]+u[P>>>16&15]+u[P>>>12&15]+u[P>>>8&15]+u[P>>>4&15]+u[P&15];return this.is224||(U+=u[p>>>28&15]+u[p>>>24&15]+u[p>>>20&15]+u[p>>>16&15]+u[p>>>12&15]+u[p>>>8&15]+u[p>>>4&15]+u[p&15]),U},q.prototype.toString=q.prototype.hex,q.prototype.digest=function(){this.finalize();var b=this.h0,A=this.h1,I=this.h2,m=this.h3,D=this.h4,F=this.h5,P=this.h6,p=this.h7,U=[b>>>24&255,b>>>16&255,b>>>8&255,b&255,A>>>24&255,A>>>16&255,A>>>8&255,A&255,I>>>24&255,I>>>16&255,I>>>8&255,I&255,m>>>24&255,m>>>16&255,m>>>8&255,m&255,D>>>24&255,D>>>16&255,D>>>8&255,D&255,F>>>24&255,F>>>16&255,F>>>8&255,F&255,P>>>24&255,P>>>16&255,P>>>8&255,P&255];return this.is224||U.push(p>>>24&255,p>>>16&255,p>>>8&255,p&255),U},q.prototype.array=q.prototype.digest,q.prototype.arrayBuffer=function(){this.finalize();var b=new ArrayBuffer(this.is224?28:32),A=new DataView(b);return A.setUint32(0,this.h0),A.setUint32(4,this.h1),A.setUint32(8,this.h2),A.setUint32(12,this.h3),A.setUint32(16,this.h4),A.setUint32(20,this.h5),A.setUint32(24,this.h6),this.is224||A.setUint32(28,this.h7),b};function se(b,A,I){var m,D=typeof b;if(D==="string"){var F=[],P=b.length,p=0,U;for(m=0;m<P;++m)U=b.charCodeAt(m),U<128?F[p++]=U:U<2048?(F[p++]=192|U>>>6,F[p++]=128|U&63):U<55296||U>=57344?(F[p++]=224|U>>>12,F[p++]=128|U>>>6&63,F[p++]=128|U&63):(U=65536+((U&1023)<<10|b.charCodeAt(++m)&1023),F[p++]=240|U>>>18,F[p++]=128|U>>>12&63,F[p++]=128|U>>>6&63,F[p++]=128|U&63);b=F}else if(D==="object"){if(b===null)throw new Error(a);if(f&&b.constructor===ArrayBuffer)b=new Uint8Array(b);else if(!Array.isArray(b)&&(!f||!ArrayBuffer.isView(b)))throw new Error(a)}else throw new Error(a);b.length>64&&(b=new q(A,!0).update(b).array());var x=[],S=[];for(m=0;m<64;++m){var $=b[m]||0;x[m]=92^$,S[m]=54^$}q.call(this,A,I),this.update(S),this.oKeyPad=x,this.inner=!0,this.sharedMemory=I}se.prototype=new q,se.prototype.finalize=function(){if(q.prototype.finalize.call(this),this.inner){this.inner=!1;var b=this.array();q.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(b),q.prototype.finalize.call(this)}};var ne=X();ne.sha256=ne,ne.sha224=X(!0),ne.sha256.hmac=J(),ne.sha224.hmac=J(!0),l?Je.exports=ne:(n.sha256=ne.sha256,n.sha224=ne.sha224,d&&define(function(){return ne}))})()});var Is={};gs(Is,{registerWorker:()=>tr});var Oe=class{constructor(e,n){this._bindings=e,this._conn=n}close(){this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}query(e){return this._bindings.runQuery(this._conn,e)}async send(e,n=!1){let o=this._bindings.startPendingQuery(this._conn,e,n);for(;o==null;)o=await new Promise((r,l)=>{try{r(this._bindings.pollPendingQuery(this._conn))}catch(d){console.log(d),d.message.includes("worker is not set!")?l(new Error("Worker has been terminated")):l(d)}});return new Ne(this._bindings,this._conn,o)}cancelSent(){return this._bindings.cancelPendingQuery(this._conn)}getTableNames(e){return this._bindings.getTableNames(this._conn,e)}prepare(e){let n=this._bindings.createPrepared(this._conn,e);return new rt(this._bindings,this._conn,n)}insertArrowFromIPCStream(e,n){this._bindings.insertArrowFromIPCStream(this._conn,e,n)}insertCSVFromPath(e,n){this._bindings.insertCSVFromPath(this._conn,e,n)}insertJSONFromPath(e,n){this._bindings.insertJSONFromPath(this._conn,e,n)}},Ne=class{constructor(e,n,o){this.bindings=e;this.conn=n;this.header=o;this._first=!0,this._depleted=!1}next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e=null;do e=this.bindings.fetchQueryResults(this.conn);while(e==null);return this._depleted=e.length==0,{done:this._depleted,value:e}}[Symbol.iterator](){return this}},rt=class{constructor(e,n,o){this.bindings=e,this.connectionId=n,this.statementId=o}close(){this.bindings.closePrepared(this.connectionId,this.statementId)}query(...e){return this.bindings.runPrepared(this.connectionId,this.statementId,e)}send(...e){let n=this.bindings.sendPrepared(this.connectionId,this.statementId,e);return new Ne(this.bindings,this.connectionId,n)}};function Lt(a){return a<=255}function Ct(a){return a===256}var Wt=new TextEncoder,Ot=new TextDecoder("utf-8");function nt(a,e,n){let o=Wt.encode(n),r=a._malloc(o.byteLength),l=a.HEAPU8.subarray(r,r+o.byteLength);l.set(o),a.HEAPF64[(e>>3)+0]=1,a.HEAPF64[(e>>3)+1]=r,a.HEAPF64[(e>>3)+2]=l.byteLength}function at(a){switch(a){case"UINT8":case"INT8":return 1;case"INT32":case"FLOAT":return 4;case"INT64":case"UINT64":case"DOUBLE":case"VARCHAR":return 8;default:return 0}}function st(a,e,n,o){let r=a.HEAPU8.subarray(e,e+o*at(n));switch(n){case"UINT8":return new Uint8Array(r.buffer,r.byteOffset,o);case"INT8":return new Int8Array(r.buffer,r.byteOffset,o);case"INT32":return new Int32Array(r.buffer,r.byteOffset,o);case"FLOAT":return new Float32Array(r.buffer,r.byteOffset,o);case"DOUBLE":return new Float64Array(r.buffer,r.byteOffset,o);case"VARCHAR":return new Float64Array(r.buffer,r.byteOffset,o);default:return new Array(0)}}function Nt(a,e,n){let o=a.HEAPU8.subarray(e,e+n);return new Uint8Array(o.buffer,o.byteOffset,n)}function We(a,e,n){let o=a.HEAPU8.subarray(e,e+n*8);return new Float64Array(o.buffer,o.byteOffset,n)}function Gt(a,e,n,o,r,l,d,f){try{let u=a._udfFunctions.get(o);if(!u){nt(e,n,"Unknown UDF with id: "+o);return}let O=Ot.decode(e.HEAPU8.subarray(r,r+l)),_=JSON.parse(O),N=We(e,d,f/8),Y=m=>{var F;let D=null;switch(m.validityBuffer!==void 0&&(D=Nt(e,N[m.validityBuffer],_.rows)),m.physicalType){case"VARCHAR":{if(m.dataBuffer===null||m.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for VARCHAR argument");if(m.lengthBuffer===null||m.lengthBuffer===void 0)throw new Error("malformed data view, expected data length buffer for VARCHAR argument");let P=st(e,N[m.dataBuffer],m.physicalType,_.rows),p=[],U=We(e,N[m.lengthBuffer],_.rows);for(let x=0;x<_.rows;++x){if(D!=null&&!D[x]){p.push(null);continue}let S=e.HEAPU8.subarray(P[x],P[x]+U[x]),$=Ot.decode(S);p.push($)}return x=>p[x]}case"STRUCT":{let P={},p=[];for(let U=0;U<(((F=m.children)==null?void 0:F.length)||0);++U){let x=m.children[U],S=Y(x);p.push($=>{P[x.name]=S($)})}return D!=null?U=>{if(!D[U])return null;for(let x of p)x(U);return P}:U=>{for(let x of p)x(U);return P}}default:{if(m.dataBuffer===void 0)throw new Error("malformed data view, expected data buffer for argument of type: "+m.physicalType);let P=st(e,N[m.dataBuffer],m.physicalType,_.rows);return D!=null?p=>D[p]?P[p]:null:p=>P[p]}}},R=[];for(let m=0;m<_.args.length;++m)R.push(Y(_.args[m]));let M=_.rows*at(_.ret.physicalType),X=e._malloc(M),Q=st(e,X,_.ret.physicalType,_.rows),re=e._malloc(_.rows),J=Nt(e,re,_.rows);if(Q.length==0||J.length==0){nt(e,n,"Can't create physical arrays for result");return}let q=Q;_.ret.physicalType=="VARCHAR"&&(q=new Array(_.rows));let se=[];for(let m=0;m<_.args.length;++m)se.push(null);for(let m=0;m<_.rows;++m){for(let F=0;F<_.args.length;++F)se[F]=R[F](m);let D=u.func(...se);q[m]=D,J[m]=D==null?0:1}let ne=0;switch(_.ret.physicalType){case"VARCHAR":{let m=new Array(0);ne=e._malloc(_.rows*at("DOUBLE"));let D=We(e,ne,_.rows),F=0;for(let x=0;x<_.rows;++x){let S=Wt.encode(q[x]||"");m.push(S),D[x]=S.length,F+=S.length}let P=e._malloc(F),p=e.HEAPU8.subarray(P,P+F),U=0;for(let x=0;x<_.rows;++x){Q[x]=U;let S=m[x];p.subarray(U,U+S.length).set(S),U+=S.length}}}let b=3*8,A=e._malloc(b),I=We(e,A,3);I[0]=X,I[1]=re,I[2]=ne,e.HEAPF64[(n>>3)+0]=0,e.HEAPF64[(n>>3)+1]=A,e.HEAPF64[(n>>3)+2]=0}catch(u){nt(e,n,u.toString())}}function Es(){let a=new TextDecoder;return e=>(typeof SharedArrayBuffer<"u"&&e.buffer instanceof SharedArrayBuffer&&(e=new Uint8Array(e)),a.decode(e))}var vs=Es();function ue(a,e){console.error(`FAIL WITH: ${e}`),a.ccall("duckdb_web_fail_with",null,["string"],[e])}function Ie(a){let e=a.wasmMemory;if(e&&e.buffer!==a.HEAPU8.buffer){let n=e.buffer;a.HEAPU8=new Uint8Array(n),a.HEAPF64=new Float64Array(n)}}function Fe(a,e,n){Ie(a);let o=new Uint8Array(a.HEAPU8.buffer,e,n),r=new Uint8Array(new ArrayBuffer(o.byteLength));return r.set(o),r}function W(a,e,n){return Ie(a),vs(new Uint8Array(a.HEAPU8.buffer,e,n))}function j(a,e,n,o){let r=a.stackSave(),l=a.stackAlloc(3*8);n.unshift("number"),o.unshift(l),a.ccall(e,null,n,o),Ie(a);let d=a.HEAPF64[(l>>3)+0],f=a.HEAPF64[(l>>3)+1],u=a.HEAPF64[(l>>3)+2];return a.stackRestore(r),[d,f,u]}function ee(a){a.ccall("duckdb_web_clear_response",null,[],[])}var Ge=class{constructor(e){let n=new Float64Array(e.buffer,e.byteOffset,e.byteLength/8),o=new Uint8Array(new ArrayBuffer(e.byteLength));o.set(e.subarray(7*8)),this.totalFileReadsCold=n[0],this.totalFileReadsAhead=n[1],this.totalFileReadsCached=n[2],this.totalFileWrites=n[3],this.totalPageAccesses=n[4],this.totalPageLoads=n[5],this.blockSize=n[6],this.blockStats=o}getBlockStats(e,n){return n=n||{file_reads_cold:0,file_reads_ahead:0,file_reads_cached:0,file_writes:0,page_accesses:0,page_loads:0},n.file_writes=this.blockStats[e*3+0]&15,n.file_reads_cold=this.blockStats[e*3+0]>>4,n.file_reads_ahead=this.blockStats[e*3+1]&15,n.file_reads_cached=this.blockStats[e*3+1]>>4,n.page_accesses=this.blockStats[e*3+1]&15,n.page_loads=this.blockStats[e*3+1]>>4,n}};var Ue=new TextEncoder;function ae(a){return a!==0}var Ke=class{constructor(e,n){this._instance=null;this._initPromise=null;this._initPromiseResolver=()=>{};this.onInstantiationProgress=[];this._logger=e,this._runtime=n,this._nextUDFId=1}get logger(){return this._logger}get mod(){return this._instance}get pthread(){return this.mod.PThread||null}async instantiate(e=n=>{}){return this._instance!=null?this:(this._initPromise!=null&&(this.onInstantiationProgress.push(e),await this._initPromise),this._initPromise=new Promise(n=>{this._initPromiseResolver=n}),this.onInstantiationProgress=[e],this._instance=await this.instantiateImpl({print:console.log.bind(console),printErr:console.log.bind(console),onRuntimeInitialized:this._initPromiseResolver}),await this._initPromise,this._initPromise=null,this.onInstantiationProgress=this.onInstantiationProgress.filter(n=>n!=e),globalThis.DUCKDB_BINDINGS=this,this)}open(e){let[n,o,r]=j(this.mod,"duckdb_web_open",["string"],[JSON.stringify(e)]);if(n!==0)throw new Error(W(this.mod,o,r));ee(this.mod)}reset(){let[e,n,o]=j(this.mod,"duckdb_web_reset",[],[]);if(e!==0)throw new Error(W(this.mod,n,o));ee(this.mod)}getVersion(){let[e,n,o]=j(this.mod,"duckdb_web_get_version",[],[]);if(e!==0)throw new Error(W(this.mod,n,o));let r=W(this.mod,n,o);return ee(this.mod),r}getFeatureFlags(){return this.mod.ccall("duckdb_web_get_feature_flags","number",[],[])}tokenize(e){let n=Ue.encode(e),o=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,o,n.length).set(n);let[l,d,f]=j(this.mod,"duckdb_web_tokenize_buffer",["number","number"],[o,n.length]);if(this.mod._free(o),l!==0)throw new Error(W(this.mod,d,f));let u=W(this.mod,d,f);return ee(this.mod),JSON.parse(u)}connect(){let e=this.mod.ccall("duckdb_web_connect","number",[],[]);return new Oe(this,e)}disconnect(e){if(this.mod.ccall("duckdb_web_disconnect",null,["number"],[e]),this.pthread)for(let n of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])n.postMessage({cmd:"dropUDFFunctions",connectionId:e})}runQuery(e,n){let o=Ue.encode(n),r=this.mod._malloc(o.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,o.length).set(o);let[d,f,u]=j(this.mod,"duckdb_web_query_run_buffer",["number","number","number"],[e,r,o.length]);if(this.mod._free(r),d!==0)throw new Error(W(this.mod,f,u));let O=Fe(this.mod,f,u);return ee(this.mod),O}startPendingQuery(e,n,o=!1){let r=Ue.encode(n),l=this.mod._malloc(r.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,l,r.length).set(r);let[f,u,O]=j(this.mod,"duckdb_web_pending_query_start_buffer",["number","number","number","boolean"],[e,l,r.length,o]);if(this.mod._free(l),f!==0)throw new Error(W(this.mod,u,O));if(u==0)return null;let _=Fe(this.mod,u,O);return ee(this.mod),_}pollPendingQuery(e){let[n,o,r]=j(this.mod,"duckdb_web_pending_query_poll",["number"],[e]);if(n!==0)throw new Error(W(this.mod,o,r));if(o==0)return null;let l=Fe(this.mod,o,r);return ee(this.mod),l}cancelPendingQuery(e){return this.mod.ccall("duckdb_web_pending_query_cancel","boolean",["number"],[e])}fetchQueryResults(e){let[n,o,r]=j(this.mod,"duckdb_web_query_fetch_results",["number"],[e]);if(Ct(n))return ee(this.mod),null;if(!Lt(n))throw new Error("Unexpected StatusCode from duckdb_web_query_fetch_results ("+n+") and with self reported error as"+W(this.mod,o,r));if(n!==0)throw new Error(W(this.mod,o,r));let l=Fe(this.mod,o,r);return ee(this.mod),l}getTableNames(e,n){let o=Ue.encode(n),r=this.mod._malloc(o.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,o.length).set(o);let[d,f,u]=j(this.mod,"duckdb_web_get_tablenames_buffer",["number","number","number"],[e,r,o.length]);if(this.mod._free(r),d!==0)throw new Error(W(this.mod,f,u));let O=W(this.mod,f,u);return ee(this.mod),JSON.parse(O)}createPrepared(e,n){let o=Ue.encode(n),r=this.mod._malloc(o.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,o.length).set(o);let[d,f,u]=j(this.mod,"duckdb_web_prepared_create_buffer",["number","number","number"],[e,r,o.length]);if(this.mod._free(r),ae(d))throw new Error(W(this.mod,f,u));return ee(this.mod),f}closePrepared(e,n){let[o,r,l]=j(this.mod,"duckdb_web_prepared_close",["number","number"],[e,n]);if(ae(o))throw new Error(W(this.mod,r,l));ee(this.mod)}runPrepared(e,n,o){let[r,l,d]=j(this.mod,"duckdb_web_prepared_run",["number","number","string"],[e,n,JSON.stringify(o)]);if(ae(r))throw new Error(W(this.mod,l,d));let f=Fe(this.mod,l,d);return ee(this.mod),f}sendPrepared(e,n,o){let[r,l,d]=j(this.mod,"duckdb_web_prepared_send",["number","number","string"],[e,n,JSON.stringify(o)]);if(ae(r))throw new Error(W(this.mod,l,d));let f=Fe(this.mod,l,d);return ee(this.mod),f}insertArrowFromIPCStream(e,n,o){if(n.length==0)return;let r=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,r,n.length).set(n);let d=o?JSON.stringify(o):"",[f,u,O]=j(this.mod,"duckdb_web_insert_arrow_from_ipc_stream",["number","number","number","string"],[e,r,n.length,d]);if(this.mod._free(r),f!==0)throw new Error(W(this.mod,u,O))}insertCSVFromPath(e,n,o){let r=JSON.stringify(o),[l,d,f]=j(this.mod,"duckdb_web_insert_csv_from_path",["number","string","string"],[e,n,r]);if(ae(l))throw new Error(W(this.mod,d,f))}insertJSONFromPath(e,n,o){let r=JSON.stringify(o),[l,d,f]=j(this.mod,"duckdb_web_insert_json_from_path",["number","string","string"],[e,n,r]);if(ae(l))throw new Error(W(this.mod,d,f))}globFiles(e){let[n,o,r]=j(this.mod,"duckdb_web_fs_glob_file_infos",["string"],[e]);if(ae(n))throw new Error(W(this.mod,o,r));let l=W(this.mod,o,r);ee(this.mod);let d=JSON.parse(l);return d==null?[]:d}registerFileURL(e,n,o,r=!1){n===void 0&&(n=e);let[l,d,f]=j(this.mod,"duckdb_web_fs_register_file_url",["string","string"],[e,n,o,r]);if(ae(l))throw new Error(W(this.mod,d,f));ee(this.mod)}registerFileText(e,n){let o=Ue.encode(n);this.registerFileBuffer(e,o)}registerFileBuffer(e,n){let o=this.mod._malloc(n.length)>>>0;new Uint8Array(this.mod.HEAPU8.buffer,o,n.length).set(n);let[l,d,f]=j(this.mod,"duckdb_web_fs_register_file_buffer",["string","number","number"],[e,o,n.length]);if(ae(l))throw new Error(W(this.mod,d,f));ee(this.mod)}async prepareFileHandle(e,n){if(n===3&&this._runtime.prepareFileHandles){let o=await this._runtime.prepareFileHandles([e],3);for(let r of o){let{handle:l,path:d,fromCached:f}=r;!f&&l.getSize()&&await this.registerFileHandleAsync(d,l,3,!0)}return}throw new Error(`prepareFileHandle: unsupported protocol ${n}`)}async prepareDBFileHandle(e,n){if(n===3&&this._runtime.prepareDBFileHandle){let o=await this._runtime.prepareDBFileHandle(e,3);for(let r of o){let{handle:l,path:d,fromCached:f}=r;!f&&l.getSize()&&await this.registerFileHandleAsync(d,l,3,!0)}return}throw new Error(`prepareDBFileHandle: unsupported protocol ${n}`)}async prepareFileHandleAsync(e,n,o,r){if(o===3&&!(n instanceof FileSystemSyncAccessHandle)){if(n instanceof FileSystemFileHandle){let l=n;try{n=await l.createSyncAccessHandle()}catch(d){throw new Error(d.message+":"+e)}}else if(e!=null)try{n=await(await(await navigator.storage.getDirectory()).getFileHandle(e)).createSyncAccessHandle()}catch(l){throw new Error(l.message+":"+e)}}return n}async registerFileHandleAsync(e,n,o,r){let l=await this.prepareFileHandleAsync(e,n,o,r);this.registerFileHandle(e,l,o,r)}registerFileHandle(e,n,o,r){var u;let[l,d,f]=j(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[e,e,o,r]);if(ae(l))throw new Error(W(this.mod,d,f));if(ee(this.mod),globalThis.DUCKDB_RUNTIME._files=(globalThis.DUCKDB_RUNTIME._files||new Map).set(e,n),(u=globalThis.DUCKDB_RUNTIME._preparedHandles)!=null&&u[e]&&delete globalThis.DUCKDB_RUNTIME._preparedHandles[e],this.pthread){for(let O of this.pthread.runningWorkers)O.postMessage({cmd:"registerFileHandle",fileName:e,fileHandle:n});for(let O of this.pthread.unusedWorkers)O.postMessage({cmd:"dropFileHandle",fileName:e})}}dropFile(e){let[n,o,r]=j(this.mod,"duckdb_web_fs_drop_file",["string"],[e]);if(ae(n))throw new Error(W(this.mod,o,r));ee(this.mod)}dropFiles(e){let n=[],o=-1;try{for(let f of e!=null?e:[])if(f!=null&&f.length>0){let u=this.mod.lengthBytesUTF8(f)+1,O=this.mod._malloc(u)>>>0;if(!O)throw new Error(`Failed to allocate memory for string: ${f}`);this.mod.stringToUTF8(f,O,u),n.push(O)}if(o=this.mod._malloc(n.length*4)>>>0,!o)throw new Error("Failed to allocate memory for pointers array");for(let f=0;f<n.length;f++)this.mod.HEAP32[(o>>2)+f]=n[f];let[r,l,d]=j(this.mod,"duckdb_web_fs_drop_files",["number","number"],[o,n.length]);if(r!==0)throw new Error(W(this.mod,l,d));ee(this.mod)}finally{for(let r of n)this.mod._free(r);o>0&&this.mod._free(o)}}flushFiles(){this.mod.ccall("duckdb_web_flush_files",null,[],[])}copyFileToPath(e,n){let[o,r,l]=j(this.mod,"duckdb_web_copy_file_to_path",["string","string"],[e,n]);if(ae(o))throw new Error(W(this.mod,r,l));ee(this.mod)}copyFileToBuffer(e){let[n,o,r]=j(this.mod,"duckdb_web_copy_file_to_buffer",["string"],[e]);if(ae(n))throw new Error(W(this.mod,o,r));Ie(this.mod);let l=new Uint8Array(this.mod.HEAPU8.buffer,o,r),d=new Uint8Array(l.length);return d.set(l),ee(this.mod),d}async registerOPFSFileName(e){if(e.startsWith("opfs://"))return this.prepareFileHandle(e,3);throw new Error("Not an OPFS file name: "+e)}collectFileStatistics(e,n){let[o,r,l]=j(this.mod,"duckdb_web_collect_file_stats",["string","boolean"],[e,n]);if(ae(o))throw new Error(W(this.mod,r,l))}exportFileStatistics(e){let[n,o,r]=j(this.mod,"duckdb_web_export_file_stats",["string"],[e]);if(ae(n))throw new Error(W(this.mod,o,r));return Ie(this.mod),new Ge(new Uint8Array(this.mod.HEAPU8.buffer,o,r))}};var $e=class{constructor(){this._bindings=null;this._nextMessageId=0}log(e){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:"LOG",data:e},[])}sendOK(e){this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"OK",data:null},[])}failWith(e,n){let o={name:n.name,message:n.message,stack:n.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"ERROR",data:o},[])}async onMessage(e){switch(e.type){case"PING":this.sendOK(e);return;case"INSTANTIATE":this._bindings!=null&&this.failWith(e,new Error("duckdb already initialized"));try{this._bindings=await this.instantiate(e.data[0],e.data[1],n=>{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"INSTANTIATE_PROGRESS",data:n},[])}),this.sendOK(e)}catch(n){console.log(n),this._bindings=null,this.failWith(e,n)}return;default:break}if(!this._bindings)return this.failWith(e,new Error("duckdb is not initialized"));try{switch(e.type){case"GET_VERSION":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"VERSION_STRING",data:this._bindings.getVersion()},[]);break;case"GET_FEATURE_FLAGS":this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FEATURE_FLAGS",data:this._bindings.getFeatureFlags()},[]);break;case"RESET":this._bindings.reset(),this.sendOK(e);break;case"OPEN":{let n=e.data.path,o=!!(this._bindings.getFeatureFlags()&2);if(n!=null&&n.startsWith("opfs://")&&!o){let r=globalThis.DUCKDB_RUNTIME;r!=null&&r.prepareDBFileHandle&&await r.prepareDBFileHandle(n,3),e.data.useDirectIO=!0}this._bindings.open(e.data),this.sendOK(e);break}case"DROP_FILE":this._bindings.dropFile(e.data),this.sendOK(e);break;case"DROP_FILES":this._bindings.dropFiles(e.data),this.sendOK(e);break;case"FLUSH_FILES":this._bindings.flushFiles(),this.sendOK(e);break;case"CONNECT":{let n=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"CONNECTION_INFO",data:n.useUnsafe((o,r)=>r)},[]);break}case"DISCONNECT":this._bindings.disconnect(e.data),this.sendOK(e);break;case"CREATE_PREPARED":{let n=this._bindings.createPrepared(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"PREPARED_STATEMENT_ID",data:n},[]);break}case"CLOSE_PREPARED":{this._bindings.closePrepared(e.data[0],e.data[1]),this.sendOK(e);break}case"RUN_PREPARED":{let n=this._bindings.runPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:n},[n.buffer]);break}case"RUN_QUERY":{let n=this._bindings.runQuery(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT",data:n},[n.buffer]);break}case"SEND_PREPARED":{let n=this._bindings.sendPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER",data:n},[n.buffer]);break}case"START_PENDING_QUERY":{let n=this._bindings.startPendingQuery(e.data[0],e.data[1],e.data[2]),o=[];n&&o.push(n.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:n},o);break}case"POLL_PENDING_QUERY":{let n=this._bindings.pollPendingQuery(e.data),o=[];n&&o.push(n.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_HEADER_OR_NULL",data:n},o);break}case"CANCEL_PENDING_QUERY":{let n=this._bindings.cancelPendingQuery(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SUCCESS",data:n},[]);break}case"FETCH_QUERY_RESULTS":{let n=this._bindings.fetchQueryResults(e.data),o=n?[n.buffer]:[];this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"QUERY_RESULT_CHUNK",data:n},o);break}case"GET_TABLE_NAMES":{let n=this._bindings.getTableNames(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"TABLE_NAMES",data:n},[]);break}case"GLOB_FILE_INFOS":{let n=this._bindings.globFiles(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_INFOS",data:n},[]);break}case"REGISTER_FILE_URL":this._bindings.registerFileURL(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"REGISTER_FILE_BUFFER":this._bindings.registerFileBuffer(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_FILE_HANDLE":await this._bindings.registerFileHandleAsync(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case"COPY_FILE_TO_PATH":this._bindings.copyFileToPath(e.data[0],e.data[1]),this.sendOK(e);break;case"COPY_FILE_TO_BUFFER":{let n=this._bindings.copyFileToBuffer(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_BUFFER",data:n},[]);break}case"COLLECT_FILE_STATISTICS":this._bindings.collectFileStatistics(e.data[0],e.data[1]),this.sendOK(e);break;case"REGISTER_OPFS_FILE_NAME":await this._bindings.registerOPFSFileName(e.data[0]),this.sendOK(e);break;case"EXPORT_FILE_STATISTICS":{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"FILE_STATISTICS",data:this._bindings.exportFileStatistics(e.data)},[]);break}case"INSERT_ARROW_FROM_IPC_STREAM":{this._bindings.insertArrowFromIPCStream(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_CSV_FROM_PATH":{this._bindings.insertCSVFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"IMPORT_JSON_FROM_PATH":{this._bindings.insertJSONFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break}case"TOKENIZE":{let n=this._bindings.tokenize(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:"SCRIPT_TOKENS",data:n},[]);break}}}catch(n){return console.log(n),this.failWith(e,n)}}};var qt=Bt(Vt());var Ve=class extends Ke{constructor(e,n,o,r){super(e,n),this.mainModuleURL=o,this.pthreadWorkerURL=r}locateFile(e,n){if(e.endsWith(".wasm"))return this.mainModuleURL;if(e.endsWith(".worker.js")){if(!this.pthreadWorkerURL)throw new Error("Missing DuckDB worker URL!");return this.pthreadWorkerURL}throw new Error(`WASM instantiation requested unexpected file: prefix=${n} path=${e}`)}instantiateWasm(e,n){globalThis.DUCKDB_RUNTIME=this._runtime;let o=this.onInstantiationProgress;if(WebAssembly.instantiateStreaming)if(typeof TransformStream=="function"){let l=(async()=>{var M;let d=new Request(this.mainModuleURL),f=await fetch(d),u=f.headers.get("content-length"),O=u&&parseInt(u,10)||0,_=new Date,N={startedAt:_,updatedAt:_,bytesTotal:O||0,bytesLoaded:0},Y={transform(X,Q){N.bytesLoaded+=X.byteLength;let re=new Date;if(re.getTime()-N.updatedAt.getTime()<20){N.updatedAt=re,Q.enqueue(X);return}for(let J of o)J(N);Q.enqueue(X)}},R=new TransformStream(Y);return new Response((M=f.body)==null?void 0:M.pipeThrough(R),f)})();WebAssembly.instantiateStreaming(l,e).then(d=>{n(d.instance,d.module)})}else{console.warn("instantiating without progress handler since transform streams are unavailable");let r=new Request(this.mainModuleURL);WebAssembly.instantiateStreaming(fetch(r),e).then(l=>{n(l.instance,l.module)})}else if(typeof XMLHttpRequest=="function"){let r=new XMLHttpRequest,l=this.mainModuleURL,d=new Date,f={startedAt:d,updatedAt:d,bytesTotal:0,bytesLoaded:0};r.open("GET",l),r.responseType="arraybuffer",r.onerror=u=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to load WASM: "+u}),new Error(u.toString())},r.onprogress=u=>{f.bytesTotal=u.total,f.bytesLoaded=u.loaded;let O=new Date;if(O.getTime()-f.updatedAt.getTime()<20){f.updatedAt=O;return}for(let _ of o)_(f)},r.onload=()=>{WebAssembly.instantiate(r.response,e).then(u=>{n(u.instance,u.module)}).catch(u=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to instantiate WASM: "+u}),new Error(u)})},r.send()}else console.warn("instantiating with manual fetch since streaming instantiation and xhrs are unavailable"),(async()=>{let l=new Request(this.mainModuleURL),f=await(await fetch(l)).arrayBuffer();WebAssembly.instantiate(f,e).then(u=>{n(u.instance,u.module)})})();return{}}};var qe=class extends Ve{constructor(e,n,o,r=null){super(e,n,o,r)}instantiateImpl(e){return(0,qt.default)({...e,instantiateWasm:this.instantiateWasm.bind(this),locateFile:this.locateFile.bind(this)})}};var Ee=Bt(zt()),Yt=function(a,e,n){var o;if((o=a==null?void 0:a.endpoint)!=null&&o.startsWith("http")){let r=`${a==null?void 0:a.endpoint}`,l=r.indexOf("://")+3;return r.substring(l)}else return a!=null&&a.endpoint?`${n}.${a==null?void 0:a.endpoint}`:`${n}.s3.amazonaws.com`};function As(a,e,n){var l,d,f,u;let o=Qt(e),r=o.path;return Zt(a)&&(r=`/${o.bucket}${r}`),{url:r,query:"",host:Yt(a,e,o.bucket),region:(l=a==null?void 0:a.region)!=null?l:"",service:"s3",method:n,accessKeyId:(d=a==null?void 0:a.accessKeyId)!=null?d:"",secretAccessKey:(f=a==null?void 0:a.secretAccessKey)!=null?f:"",sessionToken:(u=a==null?void 0:a.sessionToken)!=null?u:"",dateNow:new Date().toISOString().replace(/-/g,"").split("T")[0],datetimeNow:new Date().toISOString().replace(/-/g,"").replace(/:/g,"").split(".")[0]+"Z"}}function Ss(a,e=!1){let n="0123456789ABCDEF",o="";for(let r=0;r<a.length;r++){let l=a[r];l>="A"&&l<="Z"||l>="a"&&l<="z"||l>="0"&&l<="9"||l=="_"||l=="-"||l=="~"||l=="."?o+=l:l=="/"?e?o+="%2F":o+=l:(o+="%",o+=n[l.charCodeAt(0)>>4],o+=n[l.charCodeAt(0)&15])}return o}function Rs(a,e=null){var M;let n=(M=e==null?void 0:e.contentHash)!=null?M:"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",o=new Map;o.set("x-amz-date",a.datetimeNow),o.set("x-amz-content-sha256",n),a.sessionToken&&o.set("x-amz-security-token",a.sessionToken);let r="";e!=null&&e.contentType&&(r+="content-type;"),r+="host;x-amz-content-sha256;x-amz-date",a.sessionToken&&(r+=";x-amz-security-token");let l=a.method+`
2
- `+Ss(a.url)+`
3
- `+a.query;e!=null&&e.contentType&&(l+=`
4
- content-type:`+(e==null?void 0:e.contentType)),l+=`
5
- host:`+a.host+`
6
- x-amz-content-sha256:`+n+`
7
- x-amz-date:`+a.datetimeNow,a.sessionToken&&a.sessionToken.length>0&&(l+=`
8
- x-amz-security-token:`+a.sessionToken),l+=`
9
-
10
- `+r+`
11
- `+n;let d=(0,Ee.sha256)(l),f=`AWS4-HMAC-SHA256
12
- `+a.datetimeNow+`
13
- `+a.dateNow+"/"+a.region+"/"+a.service+`/aws4_request
14
- `+d,u="AWS4"+a.secretAccessKey,O=Ee.sha256.hmac.arrayBuffer(u,a.dateNow),_=Ee.sha256.hmac.arrayBuffer(O,a.region),N=Ee.sha256.hmac.arrayBuffer(_,a.service),Y=Ee.sha256.hmac.arrayBuffer(N,"aws4_request"),R=Ee.sha256.hmac(Y,f);return o.set("Authorization","AWS4-HMAC-SHA256 Credential="+a.accessKeyId+"/"+a.dateNow+"/"+a.region+"/"+a.service+"/aws4_request, SignedHeaders="+r+", Signature="+R),o}var Ds=function(a,e,n,o=null,r=null){let l=As(a,e,n),d={contentType:o,contentHash:r?Ee.sha256.hex(r):null};return Rs(l,d)};function ce(a,e,n,o,r=null,l=null){(e!=null&&e.accessKeyId||e!=null&&e.sessionToken)&&(Ds(e,n,o,r,l).forEach((f,u)=>{a.setRequestHeader(u,f)}),r&&a.setRequestHeader("content-type",r))}function Qt(a){if(a.indexOf("s3://")!=0)throw new Error("URL needs to start with s3://");let e=a.indexOf("/",5);if(e==-1)throw new Error("URL needs to contain a '/' after the host");let n=a.substring(5,e);if(!n)throw new Error("URL needs to contain a bucket name");let o=a.substring(e);if(!o)throw new Error("URL needs to contain key");return{bucket:n,path:o}}function Zt(a){var e;return!!((e=a==null?void 0:a.endpoint)!=null&&e.startsWith("http"))}function de(a,e){let n=Qt(e);return Zt(a)?`${a==null?void 0:a.endpoint}/${n.bucket}`+n.path:"https://"+Yt(a,e,n.bucket)+n.path}var ks=7,er=/\/|\\/,B={_files:new Map,_fileInfoCache:new Map,_udfFunctions:new Map,_globalFileInfo:null,_preparedHandles:{},_opfsRoot:null,getFileInfo(a,e){try{let n=B._fileInfoCache.get(e),[o,r,l]=j(a,"duckdb_web_fs_get_file_info_by_id",["number","number"],[e,(n==null?void 0:n.cacheEpoch)||0]);if(o!==0)return null;if(l===0)return n;let d=W(a,r,l);ee(a);try{let f=JSON.parse(d);if(f==null)return null;let u={...f,blob:null};return B._fileInfoCache.set(e,u),!B._files.has(u.fileName)&&B._preparedHandles[u.fileName]&&(B._files.set(u.fileName,B._preparedHandles[u.fileName]),delete B._preparedHandles[u.fileName]),u}catch(f){return console.warn(f),null}}catch(n){return console.log(n),null}},getGlobalFileInfo(a){var e;try{let[n,o,r]=j(a,"duckdb_web_get_global_file_info",["number"],[((e=B._globalFileInfo)==null?void 0:e.cacheEpoch)||0]);if(n!==0)return null;if(r===0)return B._globalFileInfo;let l=W(a,o,r);ee(a);let d=JSON.parse(l);return d==null?null:(B._globalFileInfo={...d,blob:null},B._globalFileInfo)}catch(n){return console.log(n),null}},async assignOPFSRoot(){B._opfsRoot||(B._opfsRoot=await navigator.storage.getDirectory())},async prepareFileHandles(a,e){if(e===3){await B.assignOPFSRoot();let n=async r=>{if(B._files.has(r))return{path:r,handle:B._files.get(r),fromCached:!0};let d=B._opfsRoot,f=r.slice(ks),u=f;if(er.test(f)){let _=f.split(er);if(_.length===0)throw new Error(`Invalid path ${f}`);if(u=_[_.length-1],!u)throw new Error(`Invalid path ${f}. File Not Found.`);_.pop();for(let N of _)d=await d.getDirectoryHandle(N,{create:!0})}let O=await d.getFileHandle(u,{create:!1}).catch(_=>{if((_==null?void 0:_.name)==="NotFoundError")return console.debug(`File ${r} does not exists yet, creating...`),d.getFileHandle(u,{create:!0});throw _});try{let _=await O.createSyncAccessHandle();return B._preparedHandles[r]=_,{path:r,handle:_,fromCached:!1}}catch(_){throw new Error(_.message+":"+name)}},o=[];for(let r of a){let l=await n(r);o.push(l)}return o}throw new Error(`Unsupported protocol ${e} for paths ${a} with protocol ${e}`)},async prepareDBFileHandle(a,e){if(e===3&&this.prepareFileHandles){let n=[a,`${a}.wal`];return this.prepareFileHandles(n,e)}throw new Error(`Unsupported protocol ${e} for path ${a} with protocol ${e}`)},testPlatformFeature:(a,e)=>{switch(e){case 1:return typeof BigInt64Array<"u";default:return console.warn(`test for unknown feature: ${e}`),!1}},getDefaultDataProtocol(a){return 2},openFile:(a,e,n)=>{var o,r,l,d,f,u,O;try{B._fileInfoCache.delete(e);let _=B.getFileInfo(a,e);switch(_==null?void 0:_.dataProtocol){case 4:case 5:{if(n&1&&n&2)throw new Error(`Opening file ${_.fileName} failed: cannot open file with both read and write flags set`);if(n&32)throw new Error(`Opening file ${_.fileName} failed: appending to HTTP/S3 files is not supported`);if(n&2){let R=new XMLHttpRequest;if(_.dataProtocol==5?(R.open("HEAD",de(_.s3Config,_.dataUrl),!1),ce(R,_.s3Config,_.dataUrl,"HEAD")):R.open("HEAD",_.dataUrl,!1),R.send(null),R.status!=200&&R.status!=404)throw new Error(`Opening file ${_.fileName} failed: Unexpected return status from server (${R.status})`);if(R.status==404&&!(n&8||n&16))throw new Error(`Opening file ${_.fileName} failed: Cannot write to non-existent file without FILE_FLAGS_FILE_CREATE or FILE_FLAGS_FILE_CREATE_NEW flag.`);let M=a._malloc(1),X=new Uint8Array;a.HEAPU8.set(X,M);let Q=a._malloc(3*8);return a.HEAPF64[(Q>>>3)+0]=1,a.HEAPF64[(Q>>>3)+1]=M,a.HEAPF64[(Q>>>3)+2]=new Date().getTime()/1e3,Q}else if((n&1)==0)throw new Error(`Opening file ${_.fileName} failed: unsupported file flags: ${n}`);let N=null,Y=null;if(!_.forceFullHttpReads&&(_.reliableHeadRequests||!_.allowFullHttpReads))try{let R=new XMLHttpRequest;_.dataProtocol==5?(R.open("HEAD",de(_.s3Config,_.dataUrl),!1),ce(R,_.s3Config,_.dataUrl,"HEAD")):R.open("HEAD",_.dataUrl,!1),R.setRequestHeader("Range","bytes=0-"),R.send(null),N=null;try{N=R.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}if(N!==null&&R.status==206){let M=a._malloc(24);a.HEAPF64[(M>>>3)+0]=+N,a.HEAPF64[(M>>>3)+1]=0;let X=0;try{X=new Date((o=R.getResponseHeader("Last-Modified"))!=null?o:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return a.HEAPF64[(M>>>3)+2]=+X,M}}catch(R){Y=R,console.warn(`HEAD request with range header failed: ${R}`)}if(_.allowFullHttpReads){if(!_.forceFullHttpReads){let M=new XMLHttpRequest;_.dataProtocol==5?(M.open("GET",de(_.s3Config,_.dataUrl),!1),ce(M,_.s3Config,_.dataUrl,"GET")):M.open("GET",_.dataUrl,!1),M.responseType="arraybuffer",M.setRequestHeader("Range","bytes=0-0"),M.send(null);let X=null;try{X=(r=M.getResponseHeader("Content-Range"))==null?void 0:r.split("/")[1]}catch{console.warn("Failed to get Content-Range on request")}let Q=null;try{Q=M.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}let re=null;if(X!==void 0)re=X;else if(!_.reliableHeadRequests){let J=new XMLHttpRequest;_.dataProtocol==5?(J.open("HEAD",de(_.s3Config,_.dataUrl),!1),ce(J,_.s3Config,_.dataUrl,"HEAD")):J.open("HEAD",_.dataUrl,!1),J.setRequestHeader("Range","bytes=0-"),J.send(null),N=null;try{N=J.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}N!==null&&+N>1&&(re=N)}if(M.status==206&&Q!==null&&+Q==1&&re!==null){let J=a._malloc(24);a.HEAPF64[(J>>>3)+0]=+re,a.HEAPF64[(J>>>3)+1]=0;let q=0;try{q=new Date((l=M.getResponseHeader("Last-Modified"))!=null?l:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return a.HEAPF64[(J>>>3)+2]=+q,J}if(M.status==200&&Q!==null&&N!==null&&+Q==+N){console.warn(`fall back to full HTTP read for: ${_.dataUrl}`);let J=a._malloc(M.response.byteLength),q=new Uint8Array(M.response,0,M.response.byteLength);a.HEAPU8.set(q,J);let se=a._malloc(3*8);a.HEAPF64[(se>>>3)+0]=M.response.byteLength,a.HEAPF64[(se>>>3)+1]=J;let ne=0;try{ne=new Date((d=M.getResponseHeader("Last-Modified"))!=null?d:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return a.HEAPF64[(se>>>3)+2]=+ne,se}console.warn(`falling back to full HTTP read for: ${_.dataUrl}`)}let R=new XMLHttpRequest;if(_.dataProtocol==5?(R.open("GET",de(_.s3Config,_.dataUrl),!1),ce(R,_.s3Config,_.dataUrl,"GET")):R.open("GET",_.dataUrl,!1),R.responseType="arraybuffer",R.send(null),R.status==200){let M=a._malloc(R.response.byteLength),X=new Uint8Array(R.response,0,R.response.byteLength);a.HEAPU8.set(X,M);let Q=a._malloc(3*8);a.HEAPF64[(Q>>>3)+0]=R.response.byteLength,a.HEAPF64[(Q>>>3)+1]=M;let re=0;try{re=new Date((f=R.getResponseHeader("Last-Modified"))!=null?f:"").getTime()/1e3}catch{console.warn("Failed to get Last-Modified on request")}return a.HEAPF64[(Q>>>3)+2]=+re,Q}}if(Y!=null)throw new Error(`Reading file ${_.fileName} failed with error: ${Y}`);return 0}case 2:{let N=(u=B._files)==null?void 0:u.get(_.fileName);if(N){let M=a._malloc(24);return a.HEAPF64[(M>>>3)+0]=N.size,a.HEAPF64[(M>>>3)+1]=0,a.HEAPF64[(M>>>3)+2]=0,M}if(n&128)return 0;console.warn(`Buffering missing file: ${_.fileName}`);let Y=a._malloc(3*8),R=a._malloc(1);return a.HEAPF64[(Y>>>3)+0]=1,a.HEAPF64[(Y>>>3)+1]=R,a.HEAPF64[(Y>>>3)+2]=0,Y}case 3:{let N=(O=B._files)==null?void 0:O.get(_.fileName);if(!N)throw new Error(`No OPFS access handle registered with name: ${_.fileName}`);n&16&&N.truncate(0);let Y=a._malloc(3*8),R=N.getSize();return a.HEAPF64[(Y>>>3)+0]=R,a.HEAPF64[(Y>>>3)+1]=0,a.HEAPF64[(Y>>>3)+2]=0,Y}}}catch(_){console.error(_.toString()),ue(a,_.toString())}return 0},glob:(a,e,n)=>{var o;try{let r=W(a,e,n);if(r.startsWith("http")||r.startsWith("s3://")){let l=new XMLHttpRequest;if(r.startsWith("s3://")){let d=B.getGlobalFileInfo(a);l.open("HEAD",de(d==null?void 0:d.s3Config,r),!1),ce(l,d==null?void 0:d.s3Config,r,"HEAD")}else l.open("HEAD",r,!1);if(l.send(null),l.status!=200&&l.status!==206){if(!((o=B.getGlobalFileInfo(a))!=null&&o.allowFullHttpReads))return console.log(`HEAD request failed: ${r}, with full http reads are disabled`),0;let d=new XMLHttpRequest;if(r.startsWith("s3://")){let u=B.getGlobalFileInfo(a);d.open("GET",de(u==null?void 0:u.s3Config,r),!1),ce(d,u==null?void 0:u.s3Config,r,"HEAD")}else d.open("GET",r,!1);if(d.setRequestHeader("Range","bytes=0-0"),d.send(null),d.status!=200&&d.status!==206)return console.log(`HEAD and GET requests failed: ${r}`),0;let f=null;try{f=d.getResponseHeader("Content-Length")}catch{console.warn("Failed to get Content-Length on request")}f&&+f>1&&console.warn(`Range request for ${r} did not return a partial response: ${d.status} "${d.statusText}"`)}a.ccall("duckdb_web_fs_glob_add_path",null,["string"],[r])}else for(let[l]of B._files.entries()||[])l.startsWith(r)&&a.ccall("duckdb_web_fs_glob_add_path",null,["string"],[l])}catch(r){return console.log(r),ue(a,r.toString()),0}},checkFile:(a,e,n)=>{try{let o=W(a,e,n);if(o.startsWith("http")||o.startsWith("s3://")){let r=new XMLHttpRequest;if(o.startsWith("s3://")){let l=B.getGlobalFileInfo(a);r.open("HEAD",de(l==null?void 0:l.s3Config,o),!1),ce(r,l==null?void 0:l.s3Config,o,"HEAD")}else r.open("HEAD",o,!1);return r.send(null),r.status==206||r.status==200}else return B._files.has(o)}catch(o){return console.log(o),!1}return!1},syncFile:(a,e)=>{},closeFile:(a,e)=>{var o;let n=B.getFileInfo(a,e);B._fileInfoCache.delete(e);try{switch(n==null?void 0:n.dataProtocol){case 0:case 4:case 5:break;case 1:case 2:return;case 3:{let r=(o=B._files)==null?void 0:o.get(n.fileName);if(!r)throw new Error(`No OPFS access handle registered with name: ${n.fileName}`);return r.flush()}}}catch(r){console.log(r),ue(a,r.toString())}},dropFile:(a,e,n)=>{var l;let o=W(a,e,n),r=(l=B._files)==null?void 0:l.get(o);if(r){if(B._files.delete(o),r instanceof FileSystemSyncAccessHandle)try{r.flush(),r.close()}catch{throw new Error(`Cannot drop file with name: ${o}`)}r instanceof Blob}},truncateFile:(a,e,n)=>{var r;let o=B.getFileInfo(a,e);switch(o==null?void 0:o.dataProtocol){case 4:ue(a,"Cannot truncate a http file");return;case 5:ue(a,"Cannot truncate an s3 file");return;case 0:case 1:case 2:ue(a,"truncateFile not implemented");return;case 3:{let l=(r=B._files)==null?void 0:r.get(o.fileName);if(!l)throw new Error(`No OPFS access handle registered with name: ${o.fileName}`);return l.truncate(n)}}return 0},readFile(a,e,n,o,r){var l;if(o==0)return 0;try{let d=B.getFileInfo(a,e);switch(d==null?void 0:d.dataProtocol){case 4:case 5:{if(!d.dataUrl)throw new Error(`Missing data URL for file ${e}`);try{let f=new XMLHttpRequest;if(d.dataProtocol==5?(f.open("GET",de(d==null?void 0:d.s3Config,d.dataUrl),!1),ce(f,d==null?void 0:d.s3Config,d.dataUrl,"GET")):f.open("GET",d.dataUrl,!1),f.responseType="arraybuffer",f.setRequestHeader("Range",`bytes=${r}-${r+o-1}`),f.send(null),f.status==206||f.status==200&&o==f.response.byteLength&&r==0){let u=new Uint8Array(f.response,0,Math.min(f.response.byteLength,o));return a.HEAPU8.set(u,n),u.byteLength}else if(f.status==200){console.warn(`Range request for ${d.dataUrl} did not return a partial response: ${f.status} "${f.statusText}"`);let u=new Uint8Array(f.response,r,Math.min(f.response.byteLength-r,o));return a.HEAPU8.set(u,n),u.byteLength}else throw new Error(`Range request for ${d.dataUrl} did returned non-success status: ${f.status} "${f.statusText}"`)}catch(f){throw console.log(f),new Error(`Range request for ${d.dataUrl} failed with error: ${f}"`)}}case 2:{let f=(l=B._files)==null?void 0:l.get(d.fileName);if(!f)throw new Error(`No HTML5 file registered with name: ${d.fileName}`);let u=f.slice(r,r+o),O=new Uint8Array(new FileReaderSync().readAsArrayBuffer(u));return a.HEAPU8.set(O,n),O.byteLength}case 3:{let f=B._files.get(d.fileName);if(!f)throw new Error(`No OPFS access handle registered with name: ${d.fileName}`);let u=a.HEAPU8.subarray(n,n+o);return f.read(u,{at:r})}}return 0}catch(d){return console.log(d),ue(a,d.toString()),0}},writeFile:(a,e,n,o,r)=>{var d;let l=B.getFileInfo(a,e);switch(l==null?void 0:l.dataProtocol){case 4:return ue(a,"Cannot write to HTTP file"),0;case 5:{let f=a.HEAPU8.subarray(n,n+o),u=new XMLHttpRequest;return u.open("PUT",de(l==null?void 0:l.s3Config,l.dataUrl),!1),ce(u,l==null?void 0:l.s3Config,l.dataUrl,"PUT","",f),u.send(f),u.status!==200?(ue(a,"Failed writing file: HTTP "+u.status),0):o}case 2:return ue(a,"cannot write using the html5 file reader api"),0;case 3:{let f=(d=B._files)==null?void 0:d.get(l.fileName);if(!f)throw new Error(`No OPFS access handle registered with name: ${l.fileName}`);let u=a.HEAPU8.subarray(n,n+o);return f.write(u,{at:r})}}return 0},getLastFileModificationTime:(a,e)=>{var o;let n=B.getFileInfo(a,e);switch(n==null?void 0:n.dataProtocol){case 2:{if(!((o=B._files)==null?void 0:o.get(n.fileName)))throw Error(`No handle available for file: ${n.fileName}`);return 0}case 4:case 5:return new Date().getTime()/1e3}return 0},progressUpdate:(a,e,n)=>{postMessage&&postMessage({requestId:0,type:"PROGRESS_UPDATE",data:{status:a?"completed":"in-progress",percentage:e,repetitions:n}})},checkDirectory:(a,e,n)=>!1,createDirectory:(a,e,n)=>{},removeDirectory:(a,e,n)=>{},listDirectoryEntries:(a,e,n)=>!1,moveFile:(a,e,n,o,r)=>{var u,O;let l=W(a,e,n),d=W(a,o,r),f=(u=B._files)==null?void 0:u.get(l);f!==void 0&&(B._files.delete(f),B._files.set(d,f));for(let[_,N]of((O=B._fileInfoCache)==null?void 0:O.entries())||[])if(N.dataUrl==l){B._fileInfoCache.delete(_);break}return!0},removeFile:(a,e,n)=>{},callScalarUDF:(a,e,n,o,r,l,d)=>{Gt(B,a,e,n,o,r,l,d)}};var ot=class extends $e{postMessage(e,n){globalThis.postMessage(e,n)}async instantiate(e,n,o){return await new qe(this,B,e,n).instantiate(o)}};function tr(){let a=new ot;globalThis.onmessage=async e=>{await a.onMessage(e.data)}}tr();return ys(Is);})();
1
+ "use strict";var duckdb=(()=>{var yp=Object.create;var ys=Object.defineProperty;var _p=Object.getOwnPropertyDescriptor;var bp=Object.getOwnPropertyNames;var gp=Object.getPrototypeOf,wp=Object.prototype.hasOwnProperty;var pa=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r);var vp=(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 On=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Cr=(r,t)=>{for(var e in t)ys(r,e,{get:t[e],enumerable:!0})},sl=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of bp(t))!wp.call(r,i)&&i!==e&&ys(r,i,{get:()=>t[i],enumerable:!(n=_p(t,i))||n.enumerable});return r};var ol=(r,t,e)=>(e=r!=null?yp(gp(r)):{},sl(t||!r||!r.__esModule?ys(e,"default",{value:r,enumerable:!0}):e,r)),Sp=r=>sl(ys({},"__esModule",{value:!0}),r);var Ip=function(r,t){this[0]=r,this[1]=t};var sn=r=>{var t=r[pa("asyncIterator")],e=!1,n,i={};return t==null?(t=r[pa("iterator")](),n=s=>i[s]=o=>t[s](o)):(t=t.call(r),n=s=>i[s]=o=>{if(e){if(e=!1,s==="throw")throw o;return o}return e=!0,{done:!1,value:new Ip(new Promise(c=>{var l=t[s](o);if(!(l instanceof Object))throw TypeError("Object expected");c(l)}),1)}}),i[pa("iterator")]=()=>i,n("next"),"throw"in t?n("throw"):i.throw=s=>{throw s},"return"in t&&n("return"),i};var od=On(()=>{});var ad=On(()=>{});var ud=On((ld,wc)=>{"use strict";var cd=(()=>{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={}){var n=e,i,s,o=new Promise((a,u)=>{i=a,s=u}),c=Object.assign({},n),l=[],f="./this.program",p=(a,u)=>{throw u},B=typeof window=="object",A=typeof importScripts=="function",E=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",X="";function Ft(a){return n.locateFile?n.locateFile(a,X):X+a}var Pt,Lt,Bt;if(E){var wt=od(),qt=ad();A?X=qt.dirname(X)+"/":X=__dirname+"/",Pt=(a,u)=>(a=Ic(a)?new URL(a):qt.normalize(a),wt.readFileSync(a,u?void 0:"utf8")),Bt=a=>{var u=Pt(a,!0);return u.buffer||(u=new Uint8Array(u)),u},Lt=(a,u,d,m=!0)=>{a=Ic(a)?new URL(a):qt.normalize(a),wt.readFile(a,m?void 0:"utf8",(y,_)=>{y?d(y):u(m?_.buffer:_)})},!n.thisProgram&&process.argv.length>1&&(f=process.argv[1].replace(/\\/g,"/")),l=process.argv.slice(2),p=(a,u)=>{throw process.exitCode=a,u}}else(B||A)&&(A?X=self.location.href:typeof document<"u"&&document.currentScript&&(X=document.currentScript.src),r&&(X=r),X.startsWith("blob:")?X="":X=X.substr(0,X.replace(/[?#].*/,"").lastIndexOf("/")+1),Pt=a=>{var u=new XMLHttpRequest;return u.open("GET",a,!1),u.send(null),u.responseText},A&&(Bt=a=>{var u=new XMLHttpRequest;return u.open("GET",a,!1),u.responseType="arraybuffer",u.send(null),new Uint8Array(u.response)}),Lt=(a,u,d)=>{var m=new XMLHttpRequest;m.open("GET",a,!0),m.responseType="arraybuffer",m.onload=()=>{if(m.status==200||m.status==0&&m.response){u(m.response);return}d()},m.onerror=d,m.send(null)});var Kt=n.print||console.log.bind(console),w=n.printErr||console.error.bind(console);Object.assign(n,c),c=null,n.arguments&&(l=n.arguments),n.thisProgram&&(f=n.thisProgram),n.quit&&(p=n.quit);var M;n.wasmBinary&&(M=n.wasmBinary);var V,D=!1,N;function x(a,u){a||Ee(u)}var j,I,H,Z,T,mt,Xe,_t;function xe(){var a=V.buffer;n.HEAP8=j=new Int8Array(a),n.HEAP16=H=new Int16Array(a),n.HEAPU8=I=new Uint8Array(a),n.HEAPU16=Z=new Uint16Array(a),n.HEAP32=T=new Int32Array(a),n.HEAPU32=mt=new Uint32Array(a),n.HEAPF32=Xe=new Float32Array(a),n.HEAPF64=_t=new Float64Array(a)}var Te=[],Nr=[],oi=[],Fn=[],en=!1;function wd(){if(n.preRun)for(typeof n.preRun=="function"&&(n.preRun=[n.preRun]);n.preRun.length;)Dd(n.preRun.shift());ls(Te)}function vd(){en=!0,ls(Nr)}function Sd(){ls(oi)}function Id(){if(n.postRun)for(typeof n.postRun=="function"&&(n.postRun=[n.postRun]);n.postRun.length;)Fd(n.postRun.shift());ls(Fn)}function Dd(a){Te.unshift(a)}function Bd(a){Nr.unshift(a)}function Fd(a){Fn.unshift(a)}var rn=0,sa=null,ai=null;function Ad(a){var u;rn++,(u=n.monitorRunDependencies)==null||u.call(n,rn)}function xd(a){var d;if(rn--,(d=n.monitorRunDependencies)==null||d.call(n,rn),rn==0&&(sa!==null&&(clearInterval(sa),sa=null),ai)){var u=ai;ai=null,u()}}function Ee(a){var d;(d=n.onAbort)==null||d.call(n,a),a="Aborted("+a+")",w(a),D=!0,N=1,a+=". Build with -sASSERTIONS for more info.",en&&___trap();var u=new WebAssembly.RuntimeError(a);throw s(u),u}var Td="data:application/octet-stream;base64,",Sc=a=>a.startsWith(Td),Ic=a=>a.startsWith("file://"),An;An="./duckdb-eh.wasm",Sc(An)||(An=Ft(An));function Dc(a){if(a==An&&M)return new Uint8Array(M);if(Bt)return Bt(a);throw"both async and sync fetching of the wasm failed"}function Ed(a){return!M&&(B||A)&&typeof fetch=="function"?fetch(a,{credentials:"same-origin"}).then(u=>{if(!u.ok)throw"failed to load wasm binary file at '".concat(a,"'");return u.arrayBuffer()}).catch(()=>Dc(a)):Promise.resolve().then(()=>Dc(a))}function Bc(a,u,d){return Ed(a).then(m=>WebAssembly.instantiate(m,u)).then(d,m=>{w("failed to asynchronously prepare wasm: ".concat(m)),Ee(m)})}function Od(a,u,d,m){return!a&&typeof WebAssembly.instantiateStreaming=="function"&&!Sc(u)&&!E&&typeof fetch=="function"?fetch(u,{credentials:"same-origin"}).then(y=>{var _=WebAssembly.instantiateStreaming(y,d);return _.then(m,function(b){return w("wasm streaming compile failed: ".concat(b)),w("falling back to ArrayBuffer instantiation"),Bc(u,d,m)})}):Bc(u,d,m)}function Ud(){var a={a:vh};function u(m,y){return P=m.exports,P=hp(P),V=P.ua,xe(),Jc=P.xa,Bd(P.va),xd("wasm-instantiate"),P}Ad("wasm-instantiate");function d(m){u(m.instance)}if(n.instantiateWasm)try{return n.instantiateWasm(a,u)}catch(m){w("Module.instantiateWasm callback failed with error: ".concat(m)),s(m)}return Od(M,An,a,d).catch(s),{}}var we,xn,Md={10168112:(a,u,d,m)=>{var y=bt(a);if(typeof XMLHttpRequest>"u")return 0;let _=new XMLHttpRequest;_.open(bt(m),y,!1),_.responseType="arraybuffer";for(var b=0,g=u;b<g*2;){var S=T[d/4+b>>>0],O=T[d/4+b+1>>>0];try{var U=encodeURI(bt(S));U==="Host"&&(U="X-Host-Override"),U==="User-Agent"&&(U="X-user-agent"),U==="Authorization"?_.setRequestHeader(U,bt(O)):_.setRequestHeader(U,encodeURI(bt(O)))}catch(Ot){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Ot)}b+=2}try{_.send(null)}catch(Ot){return 0}if(_.status>=400)return 0;for(var K=_.response,g=K.byteLength,Q=lr(g+4),ft=new Uint8Array(K),st=0;st<g;st++)n.HEAPU8[st+Q+4]=ft[st];var F=new Uint8Array(4);return F[0]=g%256,g-=F[0],g/=256,F[1]=g%256,g-=F[1],g/=256,F[2]=g%256,g-=F[2],g/=256,F[3]=g%256,g-=F[3],g/=256,n.HEAPU8.set(F,Q),Q},10169519:(a,u,d,m,y,_)=>{var b=bt(a);if(typeof XMLHttpRequest>"u")return 0;let S=new XMLHttpRequest;S.open(bt(m),b,!1),S.responseType="arraybuffer";for(var O=0,F=u;O<F*2;){var U=T[d/4+O>>>0],K=T[d/4+O+1>>>0];try{var g=encodeURI(bt(U));g==="Host"&&(g="X-Host-Override"),g==="User-Agent"&&(g="X-user-agent"),g==="Authorization"?S.setRequestHeader(g,bt(K)):S.setRequestHeader(g,encodeURI(bt(K)))}catch(z){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",z)}O+=2}try{for(var Q=new Uint8Array(_),ft=0;ft<_;ft++)Q[ft]=n.HEAPU8[ft+y];S.send(Q)}catch(z){return 0}if(S.status>=400)return 0;for(var st=Uint8Array.from(Array.from(S.getResponseHeader("Etag")).map(z=>z.charCodeAt(0))),F=st.byteLength,Ot=lr(F+4),re=new Uint8Array(st),ft=0;ft<F;ft++)n.HEAPU8[ft+Ot+4]=re[ft];var v=new Uint8Array(4);return v[0]=F%256,F-=v[0],F/=256,v[1]=F%256,F-=v[1],F/=256,v[2]=F%256,F-=v[2],F/=256,v[3]=F%256,F-=v[3],F/=256,n.HEAPU8.set(v,Ot),Ot},10171139:(a,u,d,m)=>{var y=bt(a);if(typeof XMLHttpRequest>"u")return 0;let _=new XMLHttpRequest;_.open(bt(m),y,!1),_.responseType="arraybuffer";for(var b=0,g=u;b<g*2;){var S=T[d/4+b>>>0],O=T[d/4+b+1>>>0];console.log("HEAD",bt(S),bt(O));try{var U=encodeURI(bt(S));U==="Host"&&(U="X-Host-Override"),U==="User-Agent"&&(U="X-user-agent"),U==="Authorization"?_.setRequestHeader(U,bt(O)):_.setRequestHeader(U,encodeURI(bt(O)))}catch(v){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",v)}b+=2}try{_.send(null)}catch(v){return 0}if(_.status>=400)return 0;for(var K=_.response,g=K.byteLength,Q=lr(g+8),ft=new Uint8Array(K),st=0;st<g;st++)n.HEAPU8[st+Q+8]=ft[st];var F=new Uint8Array(4);F[0]=g%256,g-=F[0],g/=256,F[1]=g%256,g-=F[1],g/=256,F[2]=g%256,g-=F[2],g/=256,F[3]=g%256,g-=F[3],g/=256,n.HEAPU8.set(F,Q+4);var Ot=Uint8Array.from(Array.from(_.getAllResponseHeaders()).map(v=>v.charCodeAt(0)));g=Ot.byteLength;for(var re=lr(g+8),st=0;st<g;st++)n.HEAPU8[st+re+8]=Ot[st];return F=new Uint8Array(4),F[0]=g%256,g-=F[0],g/=256,F[1]=g%256,g-=F[1],g/=256,F[2]=g%256,g-=F[2],g/=256,F[3]=g%256,g-=F[3],g/=256,n.HEAPU8.set(F,re+4),g=re,F=new Uint8Array(4),F[0]=g%256,g-=F[0],g/=256,F[1]=g%256,g-=F[1],g/=256,F[2]=g%256,g-=F[2],g/=256,F[3]=g%256,g-=F[3],g/=256,n.HEAPU8.set(F,Q),Q},10173484:(a,u,d,m)=>{var y=bt(a);if(typeof XMLHttpRequest>"u")return 0;let _=new XMLHttpRequest;_.open(bt(m),y,!1),_.responseType="arraybuffer";for(var b=0,g=u;b<g*2;){var S=T[d/4+b>>>0],O=T[d/4+b+1>>>0];try{var U=encodeURI(bt(S));U==="Host"&&(U="X-Host-Override"),U==="User-Agent"&&(U="X-user-agent"),U==="Authorization"?_.setRequestHeader(U,bt(O)):_.setRequestHeader(U,encodeURI(bt(O)))}catch(Ot){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",Ot)}b+=2}try{_.send(null)}catch(Ot){return 0}if(_.status>=400)return 0;for(var K=_.response,g=K.byteLength,Q=lr(g+4),ft=new Uint8Array(K),st=0;st<g;st++)n.HEAPU8[st+Q+4]=ft[st];var F=new Uint8Array(4);return F[0]=g%256,g-=F[0],g/=256,F[1]=g%256,g-=F[1],g/=256,F[2]=g%256,g-=F[2],g/=256,F[3]=g%256,g-=F[3],g/=256,n.HEAPU8.set(F,Q),Q},10174891:(a,u,d,m,y,_)=>{var b=bt(a);if(typeof XMLHttpRequest>"u")return 0;let S=new XMLHttpRequest;S.open(bt(m),b,!1),S.responseType="arraybuffer";for(var O=0,F=u;O<F*2;){var U=T[d/4+O>>>0],K=T[d/4+O+1>>>0];try{var g=encodeURI(bt(U));g==="Host"&&(g="X-Host-Override"),g==="User-Agent"&&(g="X-user-agent"),g==="Authorization"?S.setRequestHeader(g,bt(K)):S.setRequestHeader(g,encodeURI(bt(K)))}catch(z){console.warn("Error while performing XMLHttpRequest.setRequestHeader()",z)}O+=2}try{for(var Q=new Uint8Array(_),ft=0;ft<_;ft++)Q[ft]=n.HEAPU8[ft+y];S.send(Q)}catch(z){return 0}if(S.status>=400)return 0;for(var st=S.response,F=st.byteLength,Ot=lr(F+4),re=new Uint8Array(st),ft=0;ft<F;ft++)n.HEAPU8[ft+Ot+4]=re[ft];var v=new Uint8Array(4);return v[0]=F%256,F-=v[0],F/=256,v[1]=F%256,F-=v[1],F/=256,v[2]=F%256,F-=v[2],F/=256,v[3]=F%256,F-=v[3],F/=256,n.HEAPU8.set(v,Ot),Ot}};function Fc(a){this.name="ExitStatus",this.message="Program terminated with exit(".concat(a,")"),this.status=a}var ls=a=>{for(;a.length>0;)a.shift()(n)},Rd=n.noExitRuntime||!0;function Ac(){Ee("missing function: $SOCKFS")}Ac.stub=!0;function oa(){Ee("missing function: $FS")}oa.stub=!0;var Tn=a=>{var u=Ac.getSocket(a);if(!u)throw new oa.ErrnoError(8);return u},aa=a=>(a&255)+"."+(a>>8&255)+"."+(a>>16&255)+"."+(a>>24&255),xc=a=>{var u="",d=0,m=0,y=0,_=0,b=0,S=0,O=[a[0]&65535,a[0]>>16,a[1]&65535,a[1]>>16,a[2]&65535,a[2]>>16,a[3]&65535,a[3]>>16],U=!0,K="";for(S=0;S<5;S++)if(O[S]!==0){U=!1;break}if(U){if(K=aa(O[6]|O[7]<<16),O[5]===-1)return u="::ffff:",u+=K,u;if(O[5]===0)return u="::",K==="0.0.0.0"&&(K=""),K==="0.0.0.1"&&(K="1"),u+=K,u}for(d=0;d<8;d++)O[d]===0&&(d-y>1&&(b=0),y=d,b++),b>m&&(m=b,_=d-m+1);for(d=0;d<8;d++){if(m>1&&O[d]===0&&d>=_&&d<_+m){d===_&&(u+=":",_===0&&(u+=":"));continue}u+=Number(_ntohs(O[d]&65535)).toString(16),u+=d<7?":":""}return u},Tc=(a,u)=>{var d=H[a>>>1>>>0],m=_ntohs(Z[a+2>>>1>>>0]),y;switch(d){case 2:if(u!==16)return{errno:28};y=T[a+4>>>2>>>0],y=aa(y);break;case 10:if(u!==28)return{errno:28};y=[T[a+8>>>2>>>0],T[a+12>>>2>>>0],T[a+16>>>2>>>0],T[a+20>>>2>>>0]],y=xc(y);break;default:return{errno:5}}return{family:d,addr:y,port:m}},us=a=>{for(var u=a.split("."),d=0;d<4;d++){var m=Number(u[d]);if(isNaN(m))return null;u[d]=m}return(u[0]|u[1]<<8|u[2]<<16|u[3]<<24)>>>0},ds=a=>parseInt(a),ca=a=>{var u,d,m,y,_=/^((?=.*::)(?!.*::.+::)(::)?([\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,b=[];if(!_.test(a))return null;if(a==="::")return[0,0,0,0,0,0,0,0];for(a.startsWith("::")?a=a.replace("::","Z:"):a=a.replace("::",":Z:"),a.indexOf(".")>0?(a=a.replace(new RegExp("[.]","g"),":"),u=a.split(":"),u[u.length-4]=ds(u[u.length-4])+ds(u[u.length-3])*256,u[u.length-3]=ds(u[u.length-2])+ds(u[u.length-1])*256,u=u.slice(0,u.length-2)):u=a.split(":"),m=0,y=0,d=0;d<u.length;d++)if(typeof u[d]=="string")if(u[d]==="Z"){for(y=0;y<8-u.length+1;y++)b[d+y]=0;m=y-1}else b[d+m]=_htons(parseInt(u[d],16));else b[d+m]=u[d];return[b[1]<<16|b[0],b[3]<<16|b[2],b[5]<<16|b[4],b[7]<<16|b[6]]},fe={address_map:{id:1,addrs:{},names:{}},lookup_name(a){var u=us(a);if(u!==null||(u=ca(a),u!==null))return a;var d;if(fe.address_map.addrs[a])d=fe.address_map.addrs[a];else{var m=fe.address_map.id++;x(m<65535,"exceeded max address mappings of 65535"),d="172.29."+(m&255)+"."+(m&65280),fe.address_map.names[d]=a,fe.address_map.addrs[a]=d}return d},lookup_addr(a){return fe.address_map.names[a]?fe.address_map.names[a]:null}},Ec=(a,u,d)=>{if(d&&a===0)return null;var m=Tc(a,u);if(m.errno)throw new oa.ErrnoError(m.errno);return m.addr=fe.lookup_addr(m.addr)||m.addr,m},nn=(a,u)=>u+2097152>>>0<4194305-!!a?(a>>>0)+u*4294967296:NaN;function Ld(a,u,d,m,y,_){u>>>=0,d>>>=0;var b=Tn(a),S=Ec(u,d);return b.sock_ops.bind(b,S.addr,S.port),0}function Nd(a,u,d,m,y,_){u>>>=0,d>>>=0;var b=Tn(a),S=Ec(u,d);return b.sock_ops.connect(b,S.addr,S.port),0}var kd=(a,u,d)=>{};function Cd(a,u,d,m){u>>>=0}var Oc=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Uc=(a,u,d)=>{u>>>=0;for(var m=u+d,y=u;a[y]&&!(y>=m);)++y;if(y-u>16&&a.buffer&&Oc)return Oc.decode(a.subarray(u,y));for(var _="";u<y;){var b=a[u++];if(!(b&128)){_+=String.fromCharCode(b);continue}var S=a[u++]&63;if((b&224)==192){_+=String.fromCharCode((b&31)<<6|S);continue}var O=a[u++]&63;if((b&240)==224?b=(b&15)<<12|S<<6|O:b=(b&7)<<18|S<<12|O<<6|a[u++]&63,b<65536)_+=String.fromCharCode(b);else{var U=b-65536;_+=String.fromCharCode(55296|U>>10,56320|U&1023)}}return _},bt=(a,u)=>(a>>>=0,a?Uc(I,a,u):""),la={varargs:void 0,getStr(a){var u=bt(a);return u}};function Pd(a,u,d){return d>>>=0,la.varargs=d,0}function Vd(a,u){u>>>=0}function Hd(a,u,d){var m=nn(u,d)}var ua=a=>{for(var u=0,d=0;d<a.length;++d){var m=a.charCodeAt(d);m<=127?u++:m<=2047?u+=2:m>=55296&&m<=57343?(u+=4,++d):u+=3}return u};n.lengthBytesUTF8=ua;var Mc=(a,u,d,m)=>{if(d>>>=0,!(m>0))return 0;for(var y=d,_=d+m-1,b=0;b<a.length;++b){var S=a.charCodeAt(b);if(S>=55296&&S<=57343){var O=a.charCodeAt(++b);S=65536+((S&1023)<<10)|O&1023}if(S<=127){if(d>=_)break;u[d++>>>0]=S}else if(S<=2047){if(d+1>=_)break;u[d++>>>0]=192|S>>6,u[d++>>>0]=128|S&63}else if(S<=65535){if(d+2>=_)break;u[d++>>>0]=224|S>>12,u[d++>>>0]=128|S>>6&63,u[d++>>>0]=128|S&63}else{if(d+3>=_)break;u[d++>>>0]=240|S>>18,u[d++>>>0]=128|S>>12&63,u[d++>>>0]=128|S>>6&63,u[d++>>>0]=128|S&63}}return u[d>>>0]=0,d-y},kr=(a,u,d)=>Mc(a,I,u,d);n.stringToUTF8=kr;function zd(a,u){a>>>=0,u>>>=0}function jd(a,u,d){u>>>=0,d>>>=0}var Rc=(a,u)=>(I.fill(0,a,a+u),a),fs=(a,u,d,m,y)=>{switch(u){case 2:d=us(d),Rc(a,16),y&&(T[y>>>2>>>0]=16),H[a>>>1>>>0]=u,T[a+4>>>2>>>0]=d,H[a+2>>>1>>>0]=_htons(m);break;case 10:d=ca(d),Rc(a,28),y&&(T[y>>>2>>>0]=28),T[a>>>2>>>0]=u,T[a+8>>>2>>>0]=d[0],T[a+12>>>2>>>0]=d[1],T[a+16>>>2>>>0]=d[2],T[a+20>>>2>>>0]=d[3],H[a+2>>>1>>>0]=_htons(m);break;default:return 5}return 0};function Wd(a,u,d,m,y,_){u>>>=0,d>>>=0;var b=Tn(a);if(!b.daddr)return-53;var S=fs(u,b.family,fe.lookup_name(b.daddr),b.dport,d);return 0}function $d(a,u,d,m,y,_){u>>>=0,d>>>=0;var b=Tn(a),S=fs(u,b.family,fe.lookup_name(b.saddr||"0.0.0.0"),b.sport,d);return 0}function Yd(a,u,d,m,y,_){m>>>=0,y>>>=0;var b=Tn(a);return u===1&&d===4?(T[m>>>2>>>0]=b.error,T[y>>>2>>>0]=4,b.error=null,0):-50}function Gd(a,u,d){return d>>>=0,la.varargs=d,0}function qd(a,u){a>>>=0,u>>>=0}function Kd(a,u,d){u>>>=0}function Jd(a,u,d,m){u>>>=0,d>>>=0}function Xd(a,u,d,m){u>>>=0,m>>>=0,la.varargs=m}function Zd(a,u,d){a>>>=0}function Qd(a,u,d,m){u>>>=0,d>>>=0,m>>>=0}function tf(a,u,d,m,y,_){u>>>=0,d>>>=0,y>>>=0,_>>>=0;var b=Tn(a),S=b.sock_ops.recvmsg(b,d);if(!S)return 0;if(y)var O=fs(y,b.family,fe.lookup_name(S.addr),S.port,_);return I.set(S.buffer,u>>>0),S.buffer.byteLength}function ef(a,u,d,m){u>>>=0,m>>>=0}function rf(a){a>>>=0}function nf(a,u,d,m,y,_){u>>>=0,d>>>=0,y>>>=0,_>>>=0}var sf=(a,u,d)=>{};function of(a,u){a>>>=0,u>>>=0}function af(a,u,d){a>>>=0,u>>>=0,d>>>=0}function cf(a,u,d){u>>>=0}var lf=1,uf=()=>lf;function Lc(){Ee("missing function: _emval_call_method")}Lc.stub=!0;function Nc(){Ee("missing function: _emval_decref")}Nc.stub=!0;function kc(){Ee("missing function: _emval_get_global")}kc.stub=!0;function Cc(){Ee("missing function: _emval_get_method_caller")}Cc.stub=!0;function Pc(){Ee("missing function: _emval_run_destructors")}Pc.stub=!0;var ci=a=>a%4===0&&(a%100!==0||a%400===0),df=[0,31,60,91,121,152,182,213,244,274,305,335],ff=[0,31,59,90,120,151,181,212,243,273,304,334],hf=a=>{var u=ci(a.getFullYear()),d=u?df:ff,m=d[a.getMonth()]+a.getDate()-1;return m};function pf(a,u,d){var m=nn(a,u);d>>>=0;var y=new Date(m*1e3);T[d>>>2>>>0]=y.getSeconds(),T[d+4>>>2>>>0]=y.getMinutes(),T[d+8>>>2>>>0]=y.getHours(),T[d+12>>>2>>>0]=y.getDate(),T[d+16>>>2>>>0]=y.getMonth(),T[d+20>>>2>>>0]=y.getFullYear()-1900,T[d+24>>>2>>>0]=y.getDay();var _=hf(y)|0;T[d+28>>>2>>>0]=_,T[d+36>>>2>>>0]=-(y.getTimezoneOffset()*60);var b=new Date(y.getFullYear(),0,1),S=new Date(y.getFullYear(),6,1).getTimezoneOffset(),O=b.getTimezoneOffset(),U=(S!=O&&y.getTimezoneOffset()==Math.min(O,S))|0;T[d+32>>>2>>>0]=U}function mf(a,u,d,m,y,_,b,S){a>>>=0;var O=nn(y,_);return b>>>=0,S>>>=0,-52}function yf(a,u,d,m,y,_,b){a>>>=0,u>>>=0;var S=nn(_,b)}var _f=function(a,u,d,m){a>>>=0,u>>>=0,d>>>=0,m>>>=0;var y=new Date().getFullYear(),_=new Date(y,0,1),b=new Date(y,6,1),S=_.getTimezoneOffset(),O=b.getTimezoneOffset(),U=Math.max(S,O);mt[a>>>2>>>0]=U*60,T[u>>>2>>>0]=+(S!=O);var K=ft=>ft.toLocaleTimeString(void 0,{hour12:!1,timeZoneName:"short"}).split(" ")[1],g=K(_),Q=K(b);O<S?(kr(g,d,17),kr(Q,m,17)):(kr(g,m,17),kr(Q,d,17))},bf=()=>{Ee("")};function gf(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.createDirectory(n,a,u)}function wf(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.checkDirectory(n,a,u)}function vf(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.listDirectoryEntries(n,a,u)}function Sf(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.removeDirectory(n,a,u)}function If(a){return globalThis.DUCKDB_RUNTIME.closeFile(n,a)}function Df(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.dropFile(n,a,u)}function Bf(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.checkFile(n,a,u)}function Ff(a,u,d,m){return a>>>=0,d>>>=0,globalThis.DUCKDB_RUNTIME.moveFile(n,a,u,d,m)}function Af(a,u){return globalThis.DUCKDB_RUNTIME.openFile(n,a,u)}function xf(a,u,d,m){return u>>>=0,globalThis.DUCKDB_RUNTIME.readFile(n,a,u,d,m)}function Tf(a,u){return globalThis.DUCKDB_RUNTIME.truncateFile(n,a,u)}function Ef(a,u,d,m){return u>>>=0,globalThis.DUCKDB_RUNTIME.writeFile(n,a,u,d,m)}function Of(a){return globalThis.DUCKDB_RUNTIME.getDefaultDataProtocol(a)}function Uf(a,u){return a>>>=0,globalThis.DUCKDB_RUNTIME.glob(n,a,u)}function Mf(a){return globalThis.DUCKDB_RUNTIME.testPlatformFeature(n,a)}function Rf(a,u,d,m,y,_){return a>>>=0,d>>>=0,y>>>=0,globalThis.DUCKDB_RUNTIME.callScalarUDF(n,a,u,d,m,y,_)}var da=[],Lf=(a,u)=>{da.length=0;for(var d;d=I[a++>>>0];){var m=d!=105;m&=d!=112,u+=m&&u%8?4:0,da.push(d==112?mt[u>>>2>>>0]:d==105?T[u>>>2>>>0]:_t[u>>>3>>>0]),u+=m?8:4}return da},Nf=(a,u,d)=>{var m=Lf(u,d);return Md[a](...m)};function kf(a,u,d){return a>>>=0,u>>>=0,d>>>=0,Nf(a,u,d)}var Cf=()=>Date.now(),Vc=()=>4294901760;function Pf(){return Vc()}var Hc;Hc=()=>performance.now();var Vf=a=>{var u=V.buffer,d=(a-u.byteLength+65535)/65536;try{return V.grow(d),xe(),1}catch(m){}};function Hf(a){a>>>=0;var u=I.length,d=Vc();if(a>d)return!1;for(var m=(O,U)=>O+(U-O%U)%U,y=1;y<=4;y*=2){var _=u*(1+.2/y);_=Math.min(_,a+100663296);var b=Math.min(d,m(Math.max(a,_),65536)),S=Vf(b);if(S)return!0}return!1}var fa={},zf=()=>f||"./this.program",li=()=>{if(!li.strings){var a=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",u={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:a,_:zf()};for(var d in fa)fa[d]===void 0?delete u[d]:u[d]=fa[d];var m=[];for(var d in u)m.push("".concat(d,"=").concat(u[d]));li.strings=m}return li.strings},jf=(a,u)=>{for(var d=0;d<a.length;++d)j[u++>>>0]=a.charCodeAt(d);j[u>>>0]=0},Wf=function(a,u){a>>>=0,u>>>=0;var d=0;return li().forEach((m,y)=>{var _=u+d;mt[a+y*4>>>2>>>0]=_,jf(m,_),d+=m.length+1}),0},$f=function(a,u){a>>>=0,u>>>=0;var d=li();mt[a>>>2>>>0]=d.length;var m=0;return d.forEach(y=>m+=y.length+1),mt[u>>>2>>>0]=m,0},Yf=0,Gf=()=>Rd||Yf>0,qf=a=>{var u;N=a,Gf()||((u=n.onExit)==null||u.call(n,a),D=!0),p(a,new Fc(a))},zc=(a,u)=>{N=a,qf(a)},Kf=zc,Jf=a=>52;function Xf(a,u){u>>>=0;var d=0,m=0,y=0;{var _=2;a==0?d=2:(a==1||a==2)&&(d=64),y=1}return j[u>>>0]=_,H[u+2>>>1>>>0]=y,xn=[d>>>0,(we=d,+Math.abs(we)>=1?we>0?+Math.floor(we/4294967296)>>>0:~~+Math.ceil((we-+(~~we>>>0))/4294967296)>>>0:0)],T[u+8>>>2>>>0]=xn[0],T[u+12>>>2>>>0]=xn[1],xn=[m>>>0,(we=m,+Math.abs(we)>=1?we>0?+Math.floor(we/4294967296)>>>0:~~+Math.ceil((we-+(~~we>>>0))/4294967296)>>>0:0)],T[u+16>>>2>>>0]=xn[0],T[u+20>>>2>>>0]=xn[1],0}function Zf(a,u,d,m,y,_){u>>>=0,d>>>=0;var b=nn(m,y);return _>>>=0,52}function Qf(a,u,d,m,y,_){u>>>=0,d>>>=0;var b=nn(m,y);return _>>>=0,52}function th(a,u,d,m){return u>>>=0,d>>>=0,m>>>=0,52}function eh(a,u,d,m,y){var _=nn(u,d);return y>>>=0,70}var rh=a=>52,nh=[null,[],[]],ih=(a,u)=>{var d=nh[a];u===0||u===10?((a===1?Kt:w)(Uc(d,0)),d.length=0):d.push(u)};function sh(a,u,d,m){u>>>=0,d>>>=0,m>>>=0;for(var y=0,_=0;_<d;_++){var b=mt[u>>>2>>>0],S=mt[u+4>>>2>>>0];u+=8;for(var O=0;O<S;O++)ih(a,I[b+O>>>0]);y+=S}return mt[m>>>2>>>0]=y,0}function oh(a,u,d,m){a>>>=0,u>>>=0,d>>>=0,m>>>=0;var y=0,_=0,b=0,S=0,O=0,U=0,K;function g(Q,ft,st,F,Ot,re){var v,z,kt,Jt;return z=Q===10?28:16,Ot=Q===10?xc(Ot):aa(Ot),v=lr(z),Jt=fs(v,Q,Ot,re),x(!Jt),kt=lr(32),T[kt+4>>>2>>>0]=Q,T[kt+8>>>2>>>0]=ft,T[kt+12>>>2>>>0]=st,mt[kt+24>>>2>>>0]=F,mt[kt+20>>>2>>>0]=v,Q===10?T[kt+16>>>2>>>0]=28:T[kt+16>>>2>>>0]=16,T[kt+28>>>2>>>0]=0,kt}if(d&&(b=T[d>>>2>>>0],S=T[d+4>>>2>>>0],O=T[d+8>>>2>>>0],U=T[d+12>>>2>>>0]),O&&!U&&(U=O===2?17:6),!O&&U&&(O=U===17?2:1),U===0&&(U=6),O===0&&(O=1),!a&&!u)return-2;if(b&-1088||d!==0&&T[d>>>2>>>0]&2&&!a)return-1;if(b&32)return-2;if(O!==0&&O!==1&&O!==2)return-7;if(S!==0&&S!==2&&S!==10)return-6;if(u&&(u=bt(u),_=parseInt(u,10),isNaN(_)))return b&1024?-2:-8;if(!a)return S===0&&(S=2),b&1||(S===2?y=_htonl(2130706433):y=[0,0,0,1]),K=g(S,O,U,null,y,_),mt[m>>>2>>>0]=K,0;if(a=bt(a),y=us(a),y!==null)if(S===0||S===2)S=2;else if(S===10&&b&8)y=[0,0,_htonl(65535),y],S=10;else return-2;else if(y=ca(a),y!==null)if(S===0||S===10)S=10;else return-2;return y!=null?(K=g(S,O,U,a,y,_),mt[m>>>2>>>0]=K,0):b&4?-2:(a=fe.lookup_name(a),y=us(a),S===0?S=2:S===10&&(y=[0,0,_htonl(65535),y]),K=g(S,O,U,null,y,_),mt[m>>>2>>>0]=K,0)}var ah=()=>{if(typeof crypto=="object"&&typeof crypto.getRandomValues=="function")return m=>crypto.getRandomValues(m);if(E)try{var a=vp("crypto"),u=a.randomFillSync;if(u)return m=>a.randomFillSync(m);var d=a.randomBytes;return m=>(m.set(d(m.byteLength)),m)}catch(m){}Ee("initRandomDevice")},jc=a=>(jc=ah())(a);function ch(a,u){return a>>>=0,u>>>=0,jc(I.subarray(a>>>0,a+u>>>0)),0}function lh(a,u,d,m,y,_,b){a>>>=0,d>>>=0,y>>>=0;var S=Tc(a,u);if(S.errno)return-6;var O=S.port,U=S.addr,K=!1;if(d&&m){var g;if(b&1||!(g=fe.lookup_addr(U))){if(b&8)return-2}else U=g;var Q=kr(U,d,m);Q+1>=m&&(K=!0)}if(y&&_){O=""+O;var Q=kr(O,y,_);Q+1>=_&&(K=!0)}return K?-12:0}var uh=(a,u)=>{for(var d=0,m=0;m<=u;d+=a[m++]);return d},Wc=[31,29,31,30,31,30,31,31,30,31,30,31],$c=[31,28,31,30,31,30,31,31,30,31,30,31],dh=(a,u)=>{for(var d=new Date(a.getTime());u>0;){var m=ci(d.getFullYear()),y=d.getMonth(),_=(m?Wc:$c)[y];if(u>_-d.getDate())u-=_-d.getDate()+1,d.setDate(1),y<11?d.setMonth(y+1):(d.setMonth(0),d.setFullYear(d.getFullYear()+1));else return d.setDate(d.getDate()+u),d}return d};function fh(a,u,d){var m=d>0?d:ua(a)+1,y=new Array(m),_=Mc(a,y,0,y.length);return u&&(y.length=_),y}var Yc=(a,u)=>{j.set(a,u>>>0)};function hh(a,u,d,m){a>>>=0,u>>>=0,d>>>=0,m>>>=0;var y=mt[m+40>>>2>>>0],_={tm_sec:T[m>>>2>>>0],tm_min:T[m+4>>>2>>>0],tm_hour:T[m+8>>>2>>>0],tm_mday:T[m+12>>>2>>>0],tm_mon:T[m+16>>>2>>>0],tm_year:T[m+20>>>2>>>0],tm_wday:T[m+24>>>2>>>0],tm_yday:T[m+28>>>2>>>0],tm_isdst:T[m+32>>>2>>>0],tm_gmtoff:T[m+36>>>2>>>0],tm_zone:y?bt(y):""},b=bt(d),S={"%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 O in S)b=b.replace(new RegExp(O,"g"),S[O]);var U=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],K=["January","February","March","April","May","June","July","August","September","October","November","December"];function g(v,z,kt){for(var Jt=typeof v=="number"?v.toString():v||"";Jt.length<z;)Jt=kt[0]+Jt;return Jt}function Q(v,z){return g(v,z,"0")}function ft(v,z){function kt(ms){return ms<0?-1:ms>0?1:0}var Jt;return(Jt=kt(v.getFullYear()-z.getFullYear()))===0&&(Jt=kt(v.getMonth()-z.getMonth()))===0&&(Jt=kt(v.getDate()-z.getDate())),Jt}function st(v){switch(v.getDay()){case 0:return new Date(v.getFullYear()-1,11,29);case 1:return v;case 2:return new Date(v.getFullYear(),0,3);case 3:return new Date(v.getFullYear(),0,2);case 4:return new Date(v.getFullYear(),0,1);case 5:return new Date(v.getFullYear()-1,11,31);case 6:return new Date(v.getFullYear()-1,11,30)}}function F(v){var z=dh(new Date(v.tm_year+1900,0,1),v.tm_yday),kt=new Date(z.getFullYear(),0,4),Jt=new Date(z.getFullYear()+1,0,4),ms=st(kt),mp=st(Jt);return ft(ms,z)<=0?ft(mp,z)<=0?z.getFullYear()+1:z.getFullYear():z.getFullYear()-1}var Ot={"%a":v=>U[v.tm_wday].substring(0,3),"%A":v=>U[v.tm_wday],"%b":v=>K[v.tm_mon].substring(0,3),"%B":v=>K[v.tm_mon],"%C":v=>{var z=v.tm_year+1900;return Q(z/100|0,2)},"%d":v=>Q(v.tm_mday,2),"%e":v=>g(v.tm_mday,2," "),"%g":v=>F(v).toString().substring(2),"%G":F,"%H":v=>Q(v.tm_hour,2),"%I":v=>{var z=v.tm_hour;return z==0?z=12:z>12&&(z-=12),Q(z,2)},"%j":v=>Q(v.tm_mday+uh(ci(v.tm_year+1900)?Wc:$c,v.tm_mon-1),3),"%m":v=>Q(v.tm_mon+1,2),"%M":v=>Q(v.tm_min,2),"%n":()=>"\n","%p":v=>v.tm_hour>=0&&v.tm_hour<12?"AM":"PM","%S":v=>Q(v.tm_sec,2),"%t":()=>" ","%u":v=>v.tm_wday||7,"%U":v=>{var z=v.tm_yday+7-v.tm_wday;return Q(Math.floor(z/7),2)},"%V":v=>{var z=Math.floor((v.tm_yday+7-(v.tm_wday+6)%7)/7);if((v.tm_wday+371-v.tm_yday-2)%7<=2&&z++,z){if(z==53){var Jt=(v.tm_wday+371-v.tm_yday)%7;Jt!=4&&(Jt!=3||!ci(v.tm_year))&&(z=1)}}else{z=52;var kt=(v.tm_wday+7-v.tm_yday-1)%7;(kt==4||kt==5&&ci(v.tm_year%400-1))&&z++}return Q(z,2)},"%w":v=>v.tm_wday,"%W":v=>{var z=v.tm_yday+7-(v.tm_wday+6)%7;return Q(Math.floor(z/7),2)},"%y":v=>(v.tm_year+1900).toString().substring(2),"%Y":v=>v.tm_year+1900,"%z":v=>{var z=v.tm_gmtoff,kt=z>=0;return z=Math.abs(z)/60,z=z/60*100+z%60,(kt?"+":"-")+("0000"+z).slice(-4)},"%Z":v=>v.tm_zone,"%%":()=>"%"};b=b.replace(/%%/g,"\0\0");for(var O in Ot)b.includes(O)&&(b=b.replace(new RegExp(O,"g"),Ot[O](_)));b=b.replace(/\0\0/g,"%");var re=fh(b,!1);return re.length>u?0:(Yc(re,a),re.length-1)}function ph(a,u,d,m,y){return a>>>=0,u>>>=0,d>>>=0,m>>>=0,y>>>=0,hh(a,u,d,m)}var mh=a=>{if(a instanceof Fc||a=="unwind")return N;p(1,a)},yh=a=>{var u=n["_"+a];return u},hs=a=>el(a);n.stackAlloc=hs;var _h=a=>{var u=ua(a)+1,d=hs(u);return kr(a,d,u),d},Gc=()=>rl(),qc=a=>tl(a),bh=(a,u,d,m,y)=>{var _={string:st=>{var F=0;return st!=null&&st!==0&&(F=_h(st)),F},array:st=>{var F=hs(st.length);return Yc(st,F),F}};function b(st){return u==="string"?bt(st):u==="boolean"?!!st:st}var S=yh(a),O=[],U=0;if(m)for(var K=0;K<m.length;K++){var g=_[d[K]];g?(U===0&&(U=Gc()),O[K]=g(m[K])):O[K]=m[K]}var Q=S(...O);function ft(st){return U!==0&&qc(U),b(st)}return Q=ft(Q),Q},En=(a,u)=>{a<128?u.push(a):u.push(a%128|128,a>>7)},ha=(a,u)=>{var d=a.slice(0,1),m=a.slice(1),y={i:127,p:127,j:126,f:125,d:124,e:111};u.push(96),En(m.length,u);for(var _=0;_<m.length;++_)u.push(y[m[_]]);d=="v"?u.push(0):u.push(1,y[d])},Kc=a=>Zc(a),Jc,gh=a=>{var u=[],d=[0,97,115,109,1,0,0,0];u.push(d);var m=[a[0].replace("j","i"),"i",a.slice(1).replace(/j/g,"ii")].join(""),y=[3];ha(m,y),ha(a,y),ha("vi",y);var _=[1];En(y.length,_),_.push(...y),u.push(_);var b=[2,15,2,1,101,1,116,1,112,0,0,1,101,1,114,0,2];u.push(b);var S=[3,2,1,0];u.push(S);var O=[7,5,1,1,102,0,1];u.push(O);var U=[];a[0]==="j"?U=[1,1,126]:U.push(0);function K(z){U.push(32),En(z,U)}for(var g=1,Q=1;Q<a.length;Q++)a[Q]=="j"?(K(g+1),U.push(173,66,32,134),K(g),U.push(172,132),g+=2):(K(g),g++);U.push(32,0,17,1,0),a[0]==="j"&&(U.push(34),En(g,U),U.push(66,32,136,167,16,0),K(g),U.push(167)),U.push(11);var ft=[1];En(U.length,ft),ft.push(...U);var st=[10];En(ft.length,st),st.push(...ft),u.push(st);var F=new Uint8Array([].concat.apply([],u)),Ot=new WebAssembly.Module(F),re=new WebAssembly.Instance(Ot,{e:{t:Jc,r:Kc}}),v=re.exports.f;return v},wh=a=>Qc(),vh={la:Ld,qa:Nd,J:kd,fa:Cd,d:Pd,ea:Vd,y:Hd,ga:zd,$:jd,ka:Wd,ja:$d,oa:Yd,k:Gd,ba:qd,aa:Kd,ca:Jd,v:Xd,pa:Zd,Y:Qd,ma:tf,Z:ef,q:rf,na:nf,u:sf,da:of,ha:af,r:cf,ra:uf,G:Lc,l:Nc,I:kc,H:Cc,F:Pc,B:pf,C:mf,D:yf,ia:_f,a:bf,Q:gf,R:wf,O:vf,P:Sf,o:If,U:Df,M:Bf,N:Ff,T:Af,i:xf,S:Tf,p:Ef,V:Of,L:Uf,m:Mf,W:Rf,g:kf,h:Cf,sa:Pf,e:Hc,ta:Hf,w:Wf,x:$f,c:Kf,f:Jf,K:Xf,A:Zf,z:Qf,n:th,E:eh,_:rh,j:sh,t:oh,X:ch,s:lh,b:ph},P=Ud(),Xc=n._main=(a,u)=>(Xc=n._main=P.wa)(a,u),Sh=n._duckdb_web_fs_glob_add_path=a=>(Sh=n._duckdb_web_fs_glob_add_path=P.ya)(a),Ih=n._duckdb_web_clear_response=()=>(Ih=n._duckdb_web_clear_response=P.za)(),Dh=n._duckdb_web_fail_with=a=>(Dh=n._duckdb_web_fail_with=P.Aa)(a),Bh=n._duckdb_web_reset=a=>(Bh=n._duckdb_web_reset=P.Ba)(a),Fh=n._duckdb_web_connect=()=>(Fh=n._duckdb_web_connect=P.Ca)(),Ah=n._duckdb_web_disconnect=a=>(Ah=n._duckdb_web_disconnect=P.Da)(a),xh=n._duckdb_web_flush_files=()=>(xh=n._duckdb_web_flush_files=P.Ea)(),Th=n._duckdb_web_flush_file=a=>(Th=n._duckdb_web_flush_file=P.Fa)(a),Eh=n._duckdb_web_open=(a,u)=>(Eh=n._duckdb_web_open=P.Ga)(a,u),Oh=n._duckdb_web_get_global_file_info=(a,u)=>(Oh=n._duckdb_web_get_global_file_info=P.Ha)(a,u),Uh=n._duckdb_web_collect_file_stats=(a,u,d)=>(Uh=n._duckdb_web_collect_file_stats=P.Ia)(a,u,d),Mh=n._duckdb_web_export_file_stats=(a,u)=>(Mh=n._duckdb_web_export_file_stats=P.Ja)(a,u),Rh=n._duckdb_web_fs_drop_file=(a,u)=>(Rh=n._duckdb_web_fs_drop_file=P.Ka)(a,u),Lh=n._duckdb_web_fs_drop_files=(a,u,d)=>(Lh=n._duckdb_web_fs_drop_files=P.La)(a,u,d),Nh=n._duckdb_web_fs_glob_file_infos=(a,u)=>(Nh=n._duckdb_web_fs_glob_file_infos=P.Ma)(a,u),kh=n._duckdb_web_fs_get_file_info_by_id=(a,u,d)=>(kh=n._duckdb_web_fs_get_file_info_by_id=P.Na)(a,u,d),Ch=n._duckdb_web_fs_get_file_info_by_name=(a,u,d)=>(Ch=n._duckdb_web_fs_get_file_info_by_name=P.Oa)(a,u,d),Ph=n._duckdb_web_fs_register_file_url=(a,u,d,m,y)=>(Ph=n._duckdb_web_fs_register_file_url=P.Pa)(a,u,d,m,y),Vh=n._duckdb_web_fs_register_file_buffer=(a,u,d,m)=>(Vh=n._duckdb_web_fs_register_file_buffer=P.Qa)(a,u,d,m),Hh=n._duckdb_web_copy_file_to_buffer=(a,u)=>(Hh=n._duckdb_web_copy_file_to_buffer=P.Ra)(a,u),zh=n._duckdb_web_copy_file_to_path=(a,u,d)=>(zh=n._duckdb_web_copy_file_to_path=P.Sa)(a,u,d),jh=n._duckdb_web_get_version=a=>(jh=n._duckdb_web_get_version=P.Ta)(a),Wh=n._duckdb_web_get_feature_flags=()=>(Wh=n._duckdb_web_get_feature_flags=P.Ua)(),$h=n._duckdb_web_tokenize=(a,u)=>($h=n._duckdb_web_tokenize=P.Va)(a,u),Yh=n._duckdb_web_tokenize_buffer=(a,u,d)=>(Yh=n._duckdb_web_tokenize_buffer=P.Wa)(a,u,d),Gh=n._duckdb_web_udf_scalar_create=(a,u,d)=>(Gh=n._duckdb_web_udf_scalar_create=P.Xa)(a,u,d),qh=n._duckdb_web_prepared_create=(a,u,d)=>(qh=n._duckdb_web_prepared_create=P.Ya)(a,u,d),Kh=n._duckdb_web_prepared_create_buffer=(a,u,d,m)=>(Kh=n._duckdb_web_prepared_create_buffer=P.Za)(a,u,d,m),Jh=n._duckdb_web_prepared_close=(a,u,d)=>(Jh=n._duckdb_web_prepared_close=P._a)(a,u,d),Xh=n._duckdb_web_prepared_run=(a,u,d,m)=>(Xh=n._duckdb_web_prepared_run=P.$a)(a,u,d,m),Zh=n._duckdb_web_prepared_send=(a,u,d,m)=>(Zh=n._duckdb_web_prepared_send=P.ab)(a,u,d,m),Qh=n._duckdb_web_query_run=(a,u,d)=>(Qh=n._duckdb_web_query_run=P.bb)(a,u,d),tp=n._duckdb_web_query_run_buffer=(a,u,d,m)=>(tp=n._duckdb_web_query_run_buffer=P.cb)(a,u,d,m),ep=n._duckdb_web_pending_query_start=(a,u,d,m)=>(ep=n._duckdb_web_pending_query_start=P.db)(a,u,d,m),rp=n._duckdb_web_pending_query_start_buffer=(a,u,d,m,y)=>(rp=n._duckdb_web_pending_query_start_buffer=P.eb)(a,u,d,m,y),np=n._duckdb_web_pending_query_poll=(a,u,d)=>(np=n._duckdb_web_pending_query_poll=P.fb)(a,u,d),ip=n._duckdb_web_pending_query_cancel=(a,u)=>(ip=n._duckdb_web_pending_query_cancel=P.gb)(a,u),sp=n._duckdb_web_query_fetch_results=(a,u)=>(sp=n._duckdb_web_query_fetch_results=P.hb)(a,u),op=n._duckdb_web_get_tablenames=(a,u,d)=>(op=n._duckdb_web_get_tablenames=P.ib)(a,u,d),ap=n._duckdb_web_get_tablenames_buffer=(a,u,d,m)=>(ap=n._duckdb_web_get_tablenames_buffer=P.jb)(a,u,d,m),cp=n._duckdb_web_insert_arrow_from_ipc_stream=(a,u,d,m,y)=>(cp=n._duckdb_web_insert_arrow_from_ipc_stream=P.kb)(a,u,d,m,y),lp=n._duckdb_web_insert_csv_from_path=(a,u,d,m)=>(lp=n._duckdb_web_insert_csv_from_path=P.lb)(a,u,d,m),up=n._duckdb_web_insert_json_from_path=(a,u,d,m)=>(up=n._duckdb_web_insert_json_from_path=P.mb)(a,u,d,m),lr=n._malloc=a=>(lr=n._malloc=P.qb)(a),dp=n._free=a=>(dp=n._free=P.rb)(a),fp=n._calloc=(a,u)=>(fp=n._calloc=P.sb)(a,u),Zc=a=>(Zc=P.ub)(a),Qc=()=>(Qc=P.vb)(),tl=a=>(tl=P.wb)(a),el=a=>(el=P.xb)(a),rl=()=>(rl=P.yb)();function hp(a){a=Object.assign({},a);var u=m=>y=>m(y)>>>0,d=m=>()=>m()>>>0;return a.qb=u(a.qb),a.xb=u(a.xb),a.yb=d(a.yb),a}n.stackSave=Gc,n.stackRestore=qc,n.stackAlloc=hs,n.getTempRet0=wh,n.setTempRet0=Kc,n.ccall=bh,n.createDyncallWrapper=gh;var ps;ai=function a(){ps||nl(),ps||(ai=a)};function pp(){var a=Xc,u=0,d=0;try{var m=a(u,d);return zc(m,!0),m}catch(y){return mh(y)}}function nl(){if(rn>0||(wd(),rn>0))return;function a(){ps||(ps=!0,n.calledRun=!0,!D&&(vd(),Sd(),i(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),il&&pp(),Id()))}n.setStatus?(n.setStatus("Running..."),setTimeout(function(){setTimeout(function(){n.setStatus("")},1),a()},1)):a()}if(n.preInit)for(typeof n.preInit=="function"&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.pop()();var il=!0;return n.noInitialRun&&(il=!1),nl(),o}})();typeof ld=="object"&&typeof wc=="object"?wc.exports=cd:typeof define=="function"&&define.amd&&define([],()=>cd)});var fd=On(()=>{});var hd=On(()=>{});var pd=On((eF,ia)=>{(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 ia=="object"&&ia.exports,o=typeof define=="function"&&define.amd,c=!e.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",l="0123456789abcdef".split(""),f=[-2147483648,8388608,32768,128],p=[24,16,8,0],B=[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],A=["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 X=function(w,M){return function(V){return new wt(M,!0).update(V)[w]()}},Ft=function(w){var M=X("hex",w);i&&(M=Pt(M,w)),M.create=function(){return new wt(w)},M.update=function(N){return M.create().update(N)};for(var V=0;V<A.length;++V){var D=A[V];M[D]=X(D,w)}return M},Pt=function(w,M){var V=fd(),D=hd().Buffer,N=M?"sha224":"sha256",x;D.from&&!e.JS_SHA256_NO_BUFFER_FROM?x=D.from:x=function(I){return new D(I)};var j=function(I){if(typeof I=="string")return V.createHash(N).update(I,"utf8").digest("hex");if(I==null)throw new Error(r);return I.constructor===ArrayBuffer&&(I=new Uint8Array(I)),Array.isArray(I)||ArrayBuffer.isView(I)||I.constructor===D?V.createHash(N).update(x(I)).digest("hex"):w(I)};return j},Lt=function(w,M){return function(V,D){return new qt(V,M,!0).update(D)[w]()}},Bt=function(w){var M=Lt("hex",w);M.create=function(N){return new qt(N,w)},M.update=function(N,x){return M.create(N).update(x)};for(var V=0;V<A.length;++V){var D=A[V];M[D]=Lt(D,w)}return M};function wt(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}wt.prototype.update=function(w){if(!this.finalized){var M,V=typeof w;if(V!=="string"){if(V==="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,x,j=w.length,I=this.blocks;N<j;){if(this.hashed&&(this.hashed=!1,I[0]=this.block,this.block=I[16]=I[1]=I[2]=I[3]=I[4]=I[5]=I[6]=I[7]=I[8]=I[9]=I[10]=I[11]=I[12]=I[13]=I[14]=I[15]=0),M)for(x=this.start;N<j&&x<64;++N)I[x>>>2]|=w[N]<<p[x++&3];else for(x=this.start;N<j&&x<64;++N)D=w.charCodeAt(N),D<128?I[x>>>2]|=D<<p[x++&3]:D<2048?(I[x>>>2]|=(192|D>>>6)<<p[x++&3],I[x>>>2]|=(128|D&63)<<p[x++&3]):D<55296||D>=57344?(I[x>>>2]|=(224|D>>>12)<<p[x++&3],I[x>>>2]|=(128|D>>>6&63)<<p[x++&3],I[x>>>2]|=(128|D&63)<<p[x++&3]):(D=65536+((D&1023)<<10|w.charCodeAt(++N)&1023),I[x>>>2]|=(240|D>>>18)<<p[x++&3],I[x>>>2]|=(128|D>>>12&63)<<p[x++&3],I[x>>>2]|=(128|D>>>6&63)<<p[x++&3],I[x>>>2]|=(128|D&63)<<p[x++&3]);this.lastByteIndex=x,this.bytes+=x-this.start,x>=64?(this.block=I[16],this.start=x-64,this.hash(),this.hashed=!0):this.start=x}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this}},wt.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var w=this.blocks,M=this.lastByteIndex;w[16]=this.block,w[M>>>2]|=f[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()}},wt.prototype.hash=function(){var w=this.h0,M=this.h1,V=this.h2,D=this.h3,N=this.h4,x=this.h5,j=this.h6,I=this.h7,H=this.blocks,Z,T,mt,Xe,_t,xe,Te,Nr,oi,Fn,en;for(Z=16;Z<64;++Z)_t=H[Z-15],T=(_t>>>7|_t<<25)^(_t>>>18|_t<<14)^_t>>>3,_t=H[Z-2],mt=(_t>>>17|_t<<15)^(_t>>>19|_t<<13)^_t>>>10,H[Z]=H[Z-16]+T+H[Z-7]+mt<<0;for(en=M&V,Z=0;Z<64;Z+=4)this.first?(this.is224?(Nr=300032,_t=H[0]-1413257819,I=_t-150054599<<0,D=_t+24177077<<0):(Nr=704751109,_t=H[0]-210244248,I=_t-1521486534<<0,D=_t+143694565<<0),this.first=!1):(T=(w>>>2|w<<30)^(w>>>13|w<<19)^(w>>>22|w<<10),mt=(N>>>6|N<<26)^(N>>>11|N<<21)^(N>>>25|N<<7),Nr=w&M,Xe=Nr^w&V^en,Te=N&x^~N&j,_t=I+mt+Te+B[Z]+H[Z],xe=T+Xe,I=D+_t<<0,D=_t+xe<<0),T=(D>>>2|D<<30)^(D>>>13|D<<19)^(D>>>22|D<<10),mt=(I>>>6|I<<26)^(I>>>11|I<<21)^(I>>>25|I<<7),oi=D&w,Xe=oi^D&M^Nr,Te=I&N^~I&x,_t=j+mt+Te+B[Z+1]+H[Z+1],xe=T+Xe,j=V+_t<<0,V=_t+xe<<0,T=(V>>>2|V<<30)^(V>>>13|V<<19)^(V>>>22|V<<10),mt=(j>>>6|j<<26)^(j>>>11|j<<21)^(j>>>25|j<<7),Fn=V&D,Xe=Fn^V&w^oi,Te=j&I^~j&N,_t=x+mt+Te+B[Z+2]+H[Z+2],xe=T+Xe,x=M+_t<<0,M=_t+xe<<0,T=(M>>>2|M<<30)^(M>>>13|M<<19)^(M>>>22|M<<10),mt=(x>>>6|x<<26)^(x>>>11|x<<21)^(x>>>25|x<<7),en=M&V,Xe=en^M&D^Fn,Te=x&j^~x&I,_t=N+mt+Te+B[Z+3]+H[Z+3],xe=T+Xe,N=w+_t<<0,w=_t+xe<<0,this.chromeBugWorkAround=!0;this.h0=this.h0+w<<0,this.h1=this.h1+M<<0,this.h2=this.h2+V<<0,this.h3=this.h3+D<<0,this.h4=this.h4+N<<0,this.h5=this.h5+x<<0,this.h6=this.h6+j<<0,this.h7=this.h7+I<<0},wt.prototype.hex=function(){this.finalize();var w=this.h0,M=this.h1,V=this.h2,D=this.h3,N=this.h4,x=this.h5,j=this.h6,I=this.h7,H=l[w>>>28&15]+l[w>>>24&15]+l[w>>>20&15]+l[w>>>16&15]+l[w>>>12&15]+l[w>>>8&15]+l[w>>>4&15]+l[w&15]+l[M>>>28&15]+l[M>>>24&15]+l[M>>>20&15]+l[M>>>16&15]+l[M>>>12&15]+l[M>>>8&15]+l[M>>>4&15]+l[M&15]+l[V>>>28&15]+l[V>>>24&15]+l[V>>>20&15]+l[V>>>16&15]+l[V>>>12&15]+l[V>>>8&15]+l[V>>>4&15]+l[V&15]+l[D>>>28&15]+l[D>>>24&15]+l[D>>>20&15]+l[D>>>16&15]+l[D>>>12&15]+l[D>>>8&15]+l[D>>>4&15]+l[D&15]+l[N>>>28&15]+l[N>>>24&15]+l[N>>>20&15]+l[N>>>16&15]+l[N>>>12&15]+l[N>>>8&15]+l[N>>>4&15]+l[N&15]+l[x>>>28&15]+l[x>>>24&15]+l[x>>>20&15]+l[x>>>16&15]+l[x>>>12&15]+l[x>>>8&15]+l[x>>>4&15]+l[x&15]+l[j>>>28&15]+l[j>>>24&15]+l[j>>>20&15]+l[j>>>16&15]+l[j>>>12&15]+l[j>>>8&15]+l[j>>>4&15]+l[j&15];return this.is224||(H+=l[I>>>28&15]+l[I>>>24&15]+l[I>>>20&15]+l[I>>>16&15]+l[I>>>12&15]+l[I>>>8&15]+l[I>>>4&15]+l[I&15]),H},wt.prototype.toString=wt.prototype.hex,wt.prototype.digest=function(){this.finalize();var w=this.h0,M=this.h1,V=this.h2,D=this.h3,N=this.h4,x=this.h5,j=this.h6,I=this.h7,H=[w>>>24&255,w>>>16&255,w>>>8&255,w&255,M>>>24&255,M>>>16&255,M>>>8&255,M&255,V>>>24&255,V>>>16&255,V>>>8&255,V&255,D>>>24&255,D>>>16&255,D>>>8&255,D&255,N>>>24&255,N>>>16&255,N>>>8&255,N&255,x>>>24&255,x>>>16&255,x>>>8&255,x&255,j>>>24&255,j>>>16&255,j>>>8&255,j&255];return this.is224||H.push(I>>>24&255,I>>>16&255,I>>>8&255,I&255),H},wt.prototype.array=wt.prototype.digest,wt.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 qt(w,M,V){var D,N=typeof w;if(N==="string"){var x=[],j=w.length,I=0,H;for(D=0;D<j;++D)H=w.charCodeAt(D),H<128?x[I++]=H:H<2048?(x[I++]=192|H>>>6,x[I++]=128|H&63):H<55296||H>=57344?(x[I++]=224|H>>>12,x[I++]=128|H>>>6&63,x[I++]=128|H&63):(H=65536+((H&1023)<<10|w.charCodeAt(++D)&1023),x[I++]=240|H>>>18,x[I++]=128|H>>>12&63,x[I++]=128|H>>>6&63,x[I++]=128|H&63);w=x}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 wt(M,!0).update(w).array());var Z=[],T=[];for(D=0;D<64;++D){var mt=w[D]||0;Z[D]=92^mt,T[D]=54^mt}wt.call(this,M,V),this.update(T),this.oKeyPad=Z,this.inner=!0,this.sharedMemory=V}qt.prototype=new wt,qt.prototype.finalize=function(){if(wt.prototype.finalize.call(this),this.inner){this.inner=!1;var w=this.array();wt.call(this,this.is224,this.sharedMemory),this.update(this.oKeyPad),this.update(w),wt.prototype.finalize.call(this)}};var Kt=Ft();Kt.sha256=Kt,Kt.sha224=Ft(!0),Kt.sha256.hmac=Bt(),Kt.sha224.hmac=Bt(!0),s?ia.exports=Kt:(e.sha256=Kt.sha256,e.sha224=Kt.sha224,o&&define(function(){return Kt}))})()});var Zy={};Cr(Zy,{registerWorker:()=>gd});function cl(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 R(r,t,e,n){function i(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function c(p){try{f(n.next(p))}catch(B){o(B)}}function l(p){try{f(n.throw(p))}catch(B){o(B)}}function f(p){p.done?s(p.value):i(p.value).then(c,l)}f((n=n.apply(r,t||[])).next())})}function al(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 he(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(r,t||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(A){n[A]&&(i[A]=function(E){return new Promise(function(X,Ft){s.push([A,E,X,Ft])>1||c(A,E)})})}function c(A,E){try{l(n[A](E))}catch(X){B(s[0][3],X)}}function l(A){A.value instanceof lt?Promise.resolve(A.value.v).then(f,p):B(s[0][2],A)}function f(A){c("next",A)}function p(A){c("throw",A)}function B(A,E){A(E),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Un(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(o){return(e=!e)?{value:lt(r[i](o)),done:!1}:s?s(o):o}:s}}function Oe(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 al=="function"?al(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(o){return new Promise(function(c,l){o=r[s](o),i(c,l,o.done,o.value)})}}function i(s,o,c,l){Promise.resolve(l).then(function(f){s({value:f,done:c})},o)}}var wa={};Cr(wa,{compareArrayLike:()=>ga,joinUint8Arrays:()=>pe,memcpy:()=>fi,rebaseValueOffsets:()=>Ds,toArrayBufferView:()=>ut,toArrayBufferViewAsyncIterator:()=>Re,toArrayBufferViewIterator:()=>Qe,toBigInt64Array:()=>Is,toBigUint64Array:()=>Up,toFloat32Array:()=>Mp,toFloat32ArrayAsyncIterator:()=>Kp,toFloat32ArrayIterator:()=>Hp,toFloat64Array:()=>Rp,toFloat64ArrayAsyncIterator:()=>Jp,toFloat64ArrayIterator:()=>zp,toInt16Array:()=>Tp,toInt16ArrayAsyncIterator:()=>$p,toInt16ArrayIterator:()=>kp,toInt32Array:()=>on,toInt32ArrayAsyncIterator:()=>Yp,toInt32ArrayIterator:()=>Cp,toInt8Array:()=>xp,toInt8ArrayAsyncIterator:()=>Wp,toInt8ArrayIterator:()=>Np,toUint16Array:()=>Ep,toUint16ArrayAsyncIterator:()=>Gp,toUint16ArrayIterator:()=>Pp,toUint32Array:()=>Op,toUint32ArrayAsyncIterator:()=>qp,toUint32ArrayIterator:()=>Vp,toUint8Array:()=>tt,toUint8ArrayAsyncIterator:()=>ba,toUint8ArrayIterator:()=>_a,toUint8ClampedArray:()=>Lp,toUint8ClampedArrayAsyncIterator:()=>Xp,toUint8ClampedArrayIterator:()=>jp});var Dp=new TextDecoder("utf-8"),ui=r=>Dp.decode(r),Bp=new TextEncoder,Ze=r=>Bp.encode(r);var Fp=r=>typeof r=="number",ll=r=>typeof r=="boolean",Wt=r=>typeof r=="function",ne=r=>r!=null&&Object(r)===r,Ue=r=>ne(r)&&Wt(r.then);var Me=r=>ne(r)&&Wt(r[Symbol.iterator]),ve=r=>ne(r)&&Wt(r[Symbol.asyncIterator]),_s=r=>ne(r)&&ne(r.schema);var bs=r=>ne(r)&&"done"in r&&"value"in r;var gs=r=>ne(r)&&Wt(r.stat)&&Fp(r.fd);var ws=r=>ne(r)&&di(r.body),vs=r=>"_getDOMStream"in r&&"_getNodeStream"in r,ul=r=>ne(r)&&Wt(r.abort)&&Wt(r.getWriter)&&!vs(r),di=r=>ne(r)&&Wt(r.cancel)&&Wt(r.getReader)&&!vs(r),dl=r=>ne(r)&&Wt(r.end)&&Wt(r.write)&&ll(r.writable)&&!vs(r),Ss=r=>ne(r)&&Wt(r.read)&&Wt(r.pipe)&&ll(r.readable)&&!vs(r),fl=r=>ne(r)&&Wt(r.clear)&&Wt(r.bytes)&&Wt(r.position)&&Wt(r.setPosition)&&Wt(r.capacity)&&Wt(r.getBufferIdentifier)&&Wt(r.createLong);var ya=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Ap(r){let t=r[0]?[r[0]]:[],e,n,i,s;for(let o,c,l=0,f=0,p=r.length;++l<p;){if(o=t[f],c=r[l],!o||!c||o.buffer!==c.buffer||c.byteOffset<o.byteOffset){c&&(t[++f]=c);continue}if({byteOffset:e,byteLength:i}=o,{byteOffset:n,byteLength:s}=c,e+i<n||n+s<e){c&&(t[++f]=c);continue}t[f]=new Uint8Array(o.buffer,e,n-e+s)}return t}function fi(r,t,e=0,n=t.byteLength){let i=r.byteLength,s=new Uint8Array(r.buffer,r.byteOffset,i),o=new Uint8Array(t.buffer,t.byteOffset,Math.min(n,i));return s.set(o,e),r}function pe(r,t){let e=Ap(r),n=e.reduce((p,B)=>p+B.byteLength,0),i,s,o,c=0,l=-1,f=Math.min(t||Number.POSITIVE_INFINITY,n);for(let p=e.length;++l<p;){if(i=e[l],s=i.subarray(0,Math.min(i.length,f-c)),f<=c+s.length){s.length<i.length?e[l]=i.subarray(s.length):s.length===i.length&&l++,o?fi(o,s,c):o=s;break}fi(o||(o=new Uint8Array(f)),s,c),c+=s.length}return[o||new Uint8Array(0),e.slice(l),n-(o?o.byteLength:0)]}function ut(r,t){let e=bs(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=Ze(e)),e instanceof ArrayBuffer?new r(e):e instanceof ya?new r(e):fl(e)?ut(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 xp=r=>ut(Int8Array,r),Tp=r=>ut(Int16Array,r),on=r=>ut(Int32Array,r),Is=r=>ut(BigInt64Array,r),tt=r=>ut(Uint8Array,r),Ep=r=>ut(Uint16Array,r),Op=r=>ut(Uint32Array,r),Up=r=>ut(BigUint64Array,r),Mp=r=>ut(Float32Array,r),Rp=r=>ut(Float64Array,r),Lp=r=>ut(Uint8ClampedArray,r),ma=r=>(r.next(),r);function*Qe(r,t){let e=function*(i){yield i},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof ya?e(t):Me(t)?t:e(t);return yield*sn(ma(function*(i){let s=null;do s=i.next(yield ut(r,s));while(!s.done)}(n[Symbol.iterator]()))),new r}var Np=r=>Qe(Int8Array,r),kp=r=>Qe(Int16Array,r),Cp=r=>Qe(Int32Array,r),_a=r=>Qe(Uint8Array,r),Pp=r=>Qe(Uint16Array,r),Vp=r=>Qe(Uint32Array,r),Hp=r=>Qe(Float32Array,r),zp=r=>Qe(Float64Array,r),jp=r=>Qe(Uint8ClampedArray,r);function Re(r,t){return he(this,arguments,function*(){if(Ue(t))return yield lt(yield lt(yield*sn(Un(Oe(Re(r,yield lt(t)))))));let n=function(o){return he(this,arguments,function*(){yield yield lt(yield lt(o))})},i=function(o){return he(this,arguments,function*(){yield lt(yield*sn(Un(Oe(ma(function*(c){let l=null;do l=c.next(yield l==null?void 0:l.value);while(!l.done)}(o[Symbol.iterator]()))))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof ya?n(t):Me(t)?i(t):ve(t)?t:n(t);return yield lt(yield*sn(Un(Oe(ma(function(o){return he(this,arguments,function*(){let c=null;do c=yield lt(o.next(yield yield lt(ut(r,c))));while(!c.done)})}(s[Symbol.asyncIterator]())))))),yield lt(new r)})}var Wp=r=>Re(Int8Array,r),$p=r=>Re(Int16Array,r),Yp=r=>Re(Int32Array,r),ba=r=>Re(Uint8Array,r),Gp=r=>Re(Uint16Array,r),qp=r=>Re(Uint32Array,r),Kp=r=>Re(Float32Array,r),Jp=r=>Re(Float64Array,r),Xp=r=>Re(Uint8ClampedArray,r);function Ds(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 ga(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 Xt={fromIterable(r){return Bs(Zp(r))},fromAsyncIterable(r){return Bs(Qp(r))},fromDOMStream(r){return Bs(tm(r))},fromNodeStream(r){return Bs(em(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')}},Bs=r=>(r.next(),r);function*Zp(r){let t,e=!1,n=[],i,s,o,c=0;function l(){return s==="peek"?pe(n,o)[0]:([i,n,c]=pe(n,o),i)}({cmd:s,size:o}=(yield null)||{cmd:"read",size:0});let f=_a(r)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-c)?f.next():f.next(o-c),!t&&i.byteLength>0&&(n.push(i),c+=i.byteLength),t||o<=c)do({cmd:s,size:o}=yield l());while(o<c);while(!t)}catch(p){(e=!0)&&typeof f.throw=="function"&&f.throw(p)}finally{e===!1&&typeof f.return=="function"&&f.return(null)}return null}function Qp(r){return he(this,arguments,function*(){let e,n=!1,i=[],s,o,c,l=0;function f(){return o==="peek"?pe(i,c)[0]:([s,i,l]=pe(i,c),s)}({cmd:o,size:c}=(yield yield lt(null))||{cmd:"read",size:0});let p=ba(r)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(c-l)?yield lt(p.next()):yield lt(p.next(c-l)),!e&&s.byteLength>0&&(i.push(s),l+=s.byteLength),e||c<=l)do({cmd:o,size:c}=yield yield lt(f()));while(c<l);while(!e)}catch(B){(n=!0)&&typeof p.throw=="function"&&(yield lt(p.throw(B)))}finally{n===!1&&typeof p.return=="function"&&(yield lt(p.return(new Uint8Array(0))))}return yield lt(null)})}function tm(r){return he(this,arguments,function*(){let e=!1,n=!1,i=[],s,o,c,l=0;function f(){return o==="peek"?pe(i,c)[0]:([s,i,l]=pe(i,c),s)}({cmd:o,size:c}=(yield yield lt(null))||{cmd:"read",size:0});let p=new Sa(r);try{do if({done:e,value:s}=Number.isNaN(c-l)?yield lt(p.read()):yield lt(p.read(c-l)),!e&&s.byteLength>0&&(i.push(tt(s)),l+=s.byteLength),e||c<=l)do({cmd:o,size:c}=yield yield lt(f()));while(c<l);while(!e)}catch(B){(n=!0)&&(yield lt(p.cancel(B)))}finally{n===!1?yield lt(p.cancel()):r.locked&&p.releaseLock()}return yield lt(null)})}var Sa=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 R(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 R(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=tt(e)),e})}},va=(r,t)=>{let e=i=>n([t,i]),n;return[t,e,new Promise(i=>(n=i)&&r.once(t,e))]};function em(r){return he(this,arguments,function*(){let e=[],n="error",i=!1,s=null,o,c,l=0,f=[],p;function B(){return o==="peek"?pe(f,c)[0]:([p,f,l]=pe(f,c),p)}if({cmd:o,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]=va(r,"end"),e[1]=va(r,"error");do{if(e[2]=va(r,"readable"),[n,s]=yield lt(Promise.race(e.map(E=>E[2]))),n==="error")break;if((i=n==="end")||(Number.isFinite(c-l)?(p=tt(r.read(c-l)),p.byteLength<c-l&&(p=tt(r.read()))):p=tt(r.read()),p.byteLength>0&&(f.push(p),l+=p.byteLength)),i||c<=l)do({cmd:o,size:c}=yield yield lt(B()));while(c<l)}while(!i)}finally{yield lt(A(e,n==="error"?s:null))}return yield lt(null);function A(E,X){return p=f=null,new Promise((Ft,Pt)=>{for(let[Lt,Bt]of E)r.off(Lt,Bt);try{let Lt=r.destroy;Lt&&Lt.call(r,X),X=void 0}catch(Lt){X=Lt||X}finally{X!=null?Pt(X):Ft()}})}})}var vt;(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"})(vt||(vt={}));var xt;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(xt||(xt={}));var At;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(At||(At={}));var Vt;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(Vt||(Vt={}));var k;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(k||(k={}));var $t;(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"})($t||($t={}));var tr=new Int32Array(2),Fs=new Float32Array(tr.buffer),As=new Float64Array(tr.buffer),Mn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var hi;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(hi||(hi={}));var me=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 tr[0]=this.readInt32(t),Fs[0]}readFloat64(t){return tr[Mn?0:1]=this.readInt32(t),tr[Mn?1:0]=this.readInt32(t+4),As[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){Fs[0]=e,this.writeInt32(t,tr[0])}writeFloat64(t,e){As[0]=e,this.writeInt32(t,tr[Mn?0:1]),this.writeInt32(t+4,tr[Mn?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===hi.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 an=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=me.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=me.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 o=0,c=this.space;t:for(e=0;e<this.vtables.length;e++){let l=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(l)){for(let f=2;f<s;f+=2)if(this.bb.readInt16(c+f)!=this.bb.readInt16(l+f))continue t;o=this.vtables[e];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-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 o=3;o>=0;o--)this.writeInt8(s.charCodeAt(o))}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 pi;(function(r){r[r.BUFFER=0]="BUFFER"})(pi||(pi={}));var mi;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(mi||(mi={}));var Ts=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):mi.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):pi.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,mi.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,pi.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 Rn=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 Ln=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 ye=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 Ln).__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 Rn).__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 Ts).__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 ur=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 ye).__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 Pr;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(Pr||(Pr={}));var yi;(function(r){r[r.DenseArray=0]="DenseArray"})(yi||(yi={}));var Ne=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 er=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 Ne).__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):yi.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,yi.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}};var Yt=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 _i=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 bi=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 Vr=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):Vt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,Vt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return r.startDate(t),r.addUnit(t,e),r.endDate(t)}};var rr=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 Hr=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):k.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,k.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return r.startDuration(t),r.addUnit(t,e),r.endDuration(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 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 jr=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 Wr=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):At.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,At.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return r.startFloatingPoint(t),r.addPrecision(t,e),r.endFloatingPoint(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 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):$t.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,$t.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return r.startInterval(t),r.addUnit(t,e),r.endInterval(t)}};var gi=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 wi=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 vi=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 Yr=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 Si=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 Ii=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 dr=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):k.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,k.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 fr=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):k.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,k.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 ke=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):xt.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,xt.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 Di=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 Tt;(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"})(Tt||(Tt={}));var ee=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):Tt.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 er).__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 Yt).__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,Tt.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 ae=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):Pr.Little}fields(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new ee).__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 Yt).__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,Pr.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 ht;(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"})(ht||(ht={}));var h;(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"})(h||(h={}));var Ie;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(Ie||(Ie={}));var za={};Cr(za,{clampRange:()=>xi,createElementComparator:()=>Jr,wrapIndex:()=>cn});var Ia={};Cr(Ia,{valueToString:()=>Ce});function Ce(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=>Ce(t)),"]"):"[".concat(r,"]"):ArrayBuffer.isView(r)?"[".concat(r,"]"):JSON.stringify(r,(t,e)=>typeof e=="bigint"?"".concat(e):e)}var Aa={};Cr(Aa,{BN:()=>Fi,bigNumToBigInt:()=>pl,bigNumToNumber:()=>Fa,bigNumToString:()=>Cn,isArrowBigNumSymbol:()=>hl});function yt(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 Da(r,t){return yt(r/t)+yt(r%t)/yt(t)}var hl=Symbol.for("isArrowBigNum");function Pe(r,...t){return t.length===0?Object.setPrototypeOf(ut(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}Pe.prototype[hl]=!0;Pe.prototype.toJSON=function(){return'"'.concat(Cn(this),'"')};Pe.prototype.valueOf=function(r){return Fa(this,r)};Pe.prototype.toString=function(){return Cn(this)};Pe.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Fa(this);case"string":return Cn(this);case"default":return pl(this)}return Cn(this)};function Nn(...r){return Pe.apply(this,r)}function kn(...r){return Pe.apply(this,r)}function Bi(...r){return Pe.apply(this,r)}Object.setPrototypeOf(Nn.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(kn.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Bi.prototype,Object.create(Uint32Array.prototype));Object.assign(Nn.prototype,Pe.prototype,{constructor:Nn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(kn.prototype,Pe.prototype,{constructor:kn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Bi.prototype,Pe.prototype,{constructor:Bi,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var rm=BigInt(4294967296)*BigInt(4294967296),nm=rm-BigInt(1);function Fa(r,t){let{buffer:e,byteOffset:n,byteLength:i,signed:s}=r,o=new BigUint64Array(e,n,i/8),c=s&&o.at(-1)&BigInt(1)<<BigInt(63),l=BigInt(0),f=0;if(c){for(let p of o)l|=(p^nm)*(BigInt(1)<<BigInt(64*f++));l*=BigInt(-1),l-=BigInt(1)}else for(let p of o)l|=p*(BigInt(1)<<BigInt(64*f++));if(typeof t=="number"){let p=BigInt(Math.pow(10,t)),B=l/p,A=l%p;return yt(B)+yt(A)/yt(p)}return yt(l)}function Cn(r){if(r.byteLength===8){let s=new r.BigIntArray(r.buffer,r.byteOffset,1);return"".concat(s[0])}if(!r.signed)return Ba(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Ba(r);t=t.slice();let n=1;for(let s=0;s<t.length;s++){let o=t[s],c=~o+n;t[s]=c,n&=o===0?1:0}let i=Ba(t);return"-".concat(i)}function pl(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:Cn(r)}function Ba(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,o=n.length-1;do{for(e[0]=n[s=0];s<o;)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 Fi=class r{static new(t,e){switch(e){case!0:return new Nn(t);case!1:return new kn(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new Nn(t)}return t.byteLength===16?new Bi(t):new kn(t)}static signed(t){return new Nn(t)}static unsigned(t){return new kn(t)}static decimal(t){return new Bi(t)}constructor(t,e){return r.new(t,e)}};var ml,yl,_l,bl,gl,wl,vl,Sl,Il,Dl,Bl,Fl,Al,xl,Tl,El,Ol,Ul,Ml,Rl,Ll,Nl,L=class r{static isNull(t){return(t==null?void 0:t.typeId)===h.Null}static isInt(t){return(t==null?void 0:t.typeId)===h.Int}static isFloat(t){return(t==null?void 0:t.typeId)===h.Float}static isBinary(t){return(t==null?void 0:t.typeId)===h.Binary}static isLargeBinary(t){return(t==null?void 0:t.typeId)===h.LargeBinary}static isUtf8(t){return(t==null?void 0:t.typeId)===h.Utf8}static isLargeUtf8(t){return(t==null?void 0:t.typeId)===h.LargeUtf8}static isBool(t){return(t==null?void 0:t.typeId)===h.Bool}static isDecimal(t){return(t==null?void 0:t.typeId)===h.Decimal}static isDate(t){return(t==null?void 0:t.typeId)===h.Date}static isTime(t){return(t==null?void 0:t.typeId)===h.Time}static isTimestamp(t){return(t==null?void 0:t.typeId)===h.Timestamp}static isInterval(t){return(t==null?void 0:t.typeId)===h.Interval}static isDuration(t){return(t==null?void 0:t.typeId)===h.Duration}static isList(t){return(t==null?void 0:t.typeId)===h.List}static isStruct(t){return(t==null?void 0:t.typeId)===h.Struct}static isUnion(t){return(t==null?void 0:t.typeId)===h.Union}static isFixedSizeBinary(t){return(t==null?void 0:t.typeId)===h.FixedSizeBinary}static isFixedSizeList(t){return(t==null?void 0:t.typeId)===h.FixedSizeList}static isMap(t){return(t==null?void 0:t.typeId)===h.Map}static isDictionary(t){return(t==null?void 0:t.typeId)===h.Dictionary}static isDenseUnion(t){return r.isUnion(t)&&t.mode===xt.Dense}static isSparseUnion(t){return r.isUnion(t)&&t.mode===xt.Sparse}constructor(t){this.typeId=t}};ml=Symbol.toStringTag;L[ml]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(L.prototype);var ie=class extends L{constructor(){super(h.Null)}toString(){return"Null"}};yl=Symbol.toStringTag;ie[yl]=(r=>r[Symbol.toStringTag]="Null")(ie.prototype);var Gt=class extends L{constructor(t,e){super(h.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)}};_l=Symbol.toStringTag;Gt[_l]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(Gt.prototype);var Es=class extends Gt{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},Os=class extends Gt{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},nr=class extends Gt{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Us=class extends Gt{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Ms=class extends Gt{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},Rs=class extends Gt{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Ls=class extends Gt{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Ns=class extends Gt{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(Es.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(Os.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(nr.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(Us.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(Ms.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(Rs.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Ls.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(Ns.prototype,"ArrayType",{value:BigUint64Array});var De=class extends L{constructor(t){super(h.Float),this.precision=t}get ArrayType(){switch(this.precision){case At.HALF:return Uint16Array;case At.SINGLE:return Float32Array;case At.DOUBLE:return Float64Array}throw new Error("Unrecognized ".concat(this[Symbol.toStringTag]," type"))}toString(){return"Float".concat(this.precision<<5||16)}};bl=Symbol.toStringTag;De[bl]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(De.prototype);var ks=class extends De{constructor(){super(At.HALF)}},Cs=class extends De{constructor(){super(At.SINGLE)}},Ps=class extends De{constructor(){super(At.DOUBLE)}};Object.defineProperty(ks.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Cs.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(Ps.prototype,"ArrayType",{value:Float64Array});var hr=class extends L{constructor(){super(h.Binary)}toString(){return"Binary"}};gl=Symbol.toStringTag;hr[gl]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(hr.prototype);var pr=class extends L{constructor(){super(h.LargeBinary)}toString(){return"LargeBinary"}};wl=Symbol.toStringTag;pr[wl]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(pr.prototype);var mr=class extends L{constructor(){super(h.Utf8)}toString(){return"Utf8"}};vl=Symbol.toStringTag;mr[vl]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(mr.prototype);var yr=class extends L{constructor(){super(h.LargeUtf8)}toString(){return"LargeUtf8"}};Sl=Symbol.toStringTag;yr[Sl]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(yr.prototype);var _r=class extends L{constructor(){super(h.Bool)}toString(){return"Bool"}};Il=Symbol.toStringTag;_r[Il]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(_r.prototype);var br=class extends L{constructor(t,e,n=128){super(h.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return"Decimal[".concat(this.precision,"e").concat(this.scale>0?"+":"").concat(this.scale,"]")}};Dl=Symbol.toStringTag;br[Dl]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(br.prototype);var gr=class extends L{constructor(t){super(h.Date),this.unit=t}toString(){return"Date".concat((this.unit+1)*32,"<").concat(Vt[this.unit],">")}get ArrayType(){return this.unit===Vt.DAY?Int32Array:BigInt64Array}};Bl=Symbol.toStringTag;gr[Bl]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(gr.prototype);var wr=class extends L{constructor(t,e){super(h.Time),this.unit=t,this.bitWidth=e}toString(){return"Time".concat(this.bitWidth,"<").concat(k[this.unit],">")}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error("Unrecognized ".concat(this[Symbol.toStringTag]," type"))}};Fl=Symbol.toStringTag;wr[Fl]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(wr.prototype);var vr=class extends L{constructor(t,e){super(h.Timestamp),this.unit=t,this.timezone=e}toString(){return"Timestamp<".concat(k[this.unit]).concat(this.timezone?", ".concat(this.timezone):"",">")}};Al=Symbol.toStringTag;vr[Al]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(vr.prototype);var Sr=class extends L{constructor(t){super(h.Interval),this.unit=t}toString(){return"Interval<".concat($t[this.unit],">")}};xl=Symbol.toStringTag;Sr[xl]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Sr.prototype);var Ir=class extends L{constructor(t){super(h.Duration),this.unit=t}toString(){return"Duration<".concat(k[this.unit],">")}};Tl=Symbol.toStringTag;Ir[Tl]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(Ir.prototype);var Ve=class extends L{constructor(t){super(h.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}};El=Symbol.toStringTag;Ve[El]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(Ve.prototype);var Ut=class extends L{constructor(t){super(h.Struct),this.children=t}toString(){return"Struct<{".concat(this.children.map(t=>"".concat(t.name,":").concat(t.type)).join(", "),"}>")}};Ol=Symbol.toStringTag;Ut[Ol]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(Ut.prototype);var He=class extends L{constructor(t,e,n){super(h.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return"".concat(this[Symbol.toStringTag],"<").concat(this.children.map(t=>"".concat(t.type)).join(" | "),">")}};Ul=Symbol.toStringTag;He[Ul]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(He.prototype);var Dr=class extends L{constructor(t){super(h.FixedSizeBinary),this.byteWidth=t}toString(){return"FixedSizeBinary[".concat(this.byteWidth,"]")}};Ml=Symbol.toStringTag;Dr[Ml]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Dr.prototype);var ze=class extends L{constructor(t,e){super(h.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,">")}};Rl=Symbol.toStringTag;ze[Rl]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(ze.prototype);var je=class extends L{constructor(t,e=!1){var n,i,s;if(super(h.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 o=(i=t==null?void 0:t.type)===null||i===void 0?void 0:i.children[0];o&&(o.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(", "),"}>")}};Ll=Symbol.toStringTag;je[Ll]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(je.prototype);var im=(r=>()=>++r)(-1),_e=class extends L{constructor(t,e,n,i){super(h.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=n==null?im():yt(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,">")}};Nl=Symbol.toStringTag;_e[Nl]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(_e.prototype);function be(r){let t=r;switch(r.typeId){case h.Decimal:return r.bitWidth/32;case h.Interval:return 1+t.unit;case h.FixedSizeList:return t.listSize;case h.FixedSizeBinary:return t.byteWidth;default:return 1}}var W=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 sm(this,t,e)}getVisitFnByTypeId(t,e=!0){return Pn(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 sm(r,t,e=!0){return typeof t=="number"?Pn(r,t,e):typeof t=="string"&&t in h?Pn(r,h[t],e):t&&t instanceof L?Pn(r,kl(t),e):t!=null&&t.type&&t.type instanceof L?Pn(r,kl(t.type),e):Pn(r,h.NONE,e)}function Pn(r,t,e=!0){let n=null;switch(t){case h.Null:n=r.visitNull;break;case h.Bool:n=r.visitBool;break;case h.Int:n=r.visitInt;break;case h.Int8:n=r.visitInt8||r.visitInt;break;case h.Int16:n=r.visitInt16||r.visitInt;break;case h.Int32:n=r.visitInt32||r.visitInt;break;case h.Int64:n=r.visitInt64||r.visitInt;break;case h.Uint8:n=r.visitUint8||r.visitInt;break;case h.Uint16:n=r.visitUint16||r.visitInt;break;case h.Uint32:n=r.visitUint32||r.visitInt;break;case h.Uint64:n=r.visitUint64||r.visitInt;break;case h.Float:n=r.visitFloat;break;case h.Float16:n=r.visitFloat16||r.visitFloat;break;case h.Float32:n=r.visitFloat32||r.visitFloat;break;case h.Float64:n=r.visitFloat64||r.visitFloat;break;case h.Utf8:n=r.visitUtf8;break;case h.LargeUtf8:n=r.visitLargeUtf8;break;case h.Binary:n=r.visitBinary;break;case h.LargeBinary:n=r.visitLargeBinary;break;case h.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case h.Date:n=r.visitDate;break;case h.DateDay:n=r.visitDateDay||r.visitDate;break;case h.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case h.Timestamp:n=r.visitTimestamp;break;case h.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case h.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case h.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case h.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case h.Time:n=r.visitTime;break;case h.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case h.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case h.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case h.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case h.Decimal:n=r.visitDecimal;break;case h.List:n=r.visitList;break;case h.Struct:n=r.visitStruct;break;case h.Union:n=r.visitUnion;break;case h.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case h.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case h.Dictionary:n=r.visitDictionary;break;case h.Interval:n=r.visitInterval;break;case h.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case h.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case h.Duration:n=r.visitDuration;break;case h.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case h.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case h.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case h.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case h.FixedSizeList:n=r.visitFixedSizeList;break;case h.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error("Unrecognized type '".concat(h[t],"'"))}function kl(r){switch(r.typeId){case h.Null:return h.Null;case h.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?h.Int8:h.Uint8;case 16:return e?h.Int16:h.Uint16;case 32:return e?h.Int32:h.Uint32;case 64:return e?h.Int64:h.Uint64}return h.Int}case h.Float:switch(r.precision){case At.HALF:return h.Float16;case At.SINGLE:return h.Float32;case At.DOUBLE:return h.Float64}return h.Float;case h.Binary:return h.Binary;case h.LargeBinary:return h.LargeBinary;case h.Utf8:return h.Utf8;case h.LargeUtf8:return h.LargeUtf8;case h.Bool:return h.Bool;case h.Decimal:return h.Decimal;case h.Time:switch(r.unit){case k.SECOND:return h.TimeSecond;case k.MILLISECOND:return h.TimeMillisecond;case k.MICROSECOND:return h.TimeMicrosecond;case k.NANOSECOND:return h.TimeNanosecond}return h.Time;case h.Timestamp:switch(r.unit){case k.SECOND:return h.TimestampSecond;case k.MILLISECOND:return h.TimestampMillisecond;case k.MICROSECOND:return h.TimestampMicrosecond;case k.NANOSECOND:return h.TimestampNanosecond}return h.Timestamp;case h.Date:switch(r.unit){case Vt.DAY:return h.DateDay;case Vt.MILLISECOND:return h.DateMillisecond}return h.Date;case h.Interval:switch(r.unit){case $t.DAY_TIME:return h.IntervalDayTime;case $t.YEAR_MONTH:return h.IntervalYearMonth}return h.Interval;case h.Duration:switch(r.unit){case k.SECOND:return h.DurationSecond;case k.MILLISECOND:return h.DurationMillisecond;case k.MICROSECOND:return h.DurationMicrosecond;case k.NANOSECOND:return h.DurationNanosecond}return h.Duration;case h.Map:return h.Map;case h.List:return h.List;case h.Struct:return h.Struct;case h.Union:switch(r.mode){case xt.Dense:return h.DenseUnion;case xt.Sparse:return h.SparseUnion}return h.Union;case h.FixedSizeBinary:return h.FixedSizeBinary;case h.FixedSizeList:return h.FixedSizeList;case h.Dictionary:return h.Dictionary}throw new Error("Unrecognized type '".concat(h[r.typeId],"'"))}W.prototype.visitInt8=null;W.prototype.visitInt16=null;W.prototype.visitInt32=null;W.prototype.visitInt64=null;W.prototype.visitUint8=null;W.prototype.visitUint16=null;W.prototype.visitUint32=null;W.prototype.visitUint64=null;W.prototype.visitFloat16=null;W.prototype.visitFloat32=null;W.prototype.visitFloat64=null;W.prototype.visitDateDay=null;W.prototype.visitDateMillisecond=null;W.prototype.visitTimestampSecond=null;W.prototype.visitTimestampMillisecond=null;W.prototype.visitTimestampMicrosecond=null;W.prototype.visitTimestampNanosecond=null;W.prototype.visitTimeSecond=null;W.prototype.visitTimeMillisecond=null;W.prototype.visitTimeMicrosecond=null;W.prototype.visitTimeNanosecond=null;W.prototype.visitDenseUnion=null;W.prototype.visitSparseUnion=null;W.prototype.visitIntervalDayTime=null;W.prototype.visitIntervalYearMonth=null;W.prototype.visitDuration=null;W.prototype.visitDurationSecond=null;W.prototype.visitDurationMillisecond=null;W.prototype.visitDurationMicrosecond=null;W.prototype.visitDurationNanosecond=null;var xa={};Cr(xa,{float64ToUint16:()=>Ai,uint16ToFloat64:()=>Vs});var Cl=new Float64Array(1),Vn=new Uint32Array(Cl.buffer);function Vs(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 Ai(r){if(r!==r)return 32256;Cl[0]=r;let t=(Vn[1]&2147483648)>>16&65535,e=Vn[1]&2146435072,n=0;return e>=1089470464?Vn[0]>0?e=31744:(e=(e&2080374784)>>16,n=(Vn[1]&1048575)>>10):e<=1056964608?(n=1048576+(Vn[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(Vn[1]&1048575)+512>>10),t|e|n&65535}var J=class extends W{};function it(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}var om=(r,t,e)=>{r[t]=Math.floor(e/864e5)},Pl=(r,t,e,n)=>{if(e+1<t.length){let i=yt(t[e]),s=yt(t[e+1]);r.set(n.subarray(0,s-i),i)}},am=({offset:r,values:t},e,n)=>{let i=r+e;n?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Br=({values:r},t,e)=>{r[t]=e},Ta=({values:r},t,e)=>{r[t]=e},Vl=({values:r},t,e)=>{r[t]=Ai(e)},cm=(r,t,e)=>{switch(r.type.precision){case At.HALF:return Vl(r,t,e);case At.SINGLE:case At.DOUBLE:return Ta(r,t,e)}},Hs=({values:r},t,e)=>{om(r,t,e.valueOf())},zs=({values:r},t,e)=>{r[t]=BigInt(e)},Ea=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},Hl=({values:r,valueOffsets:t},e,n)=>Pl(r,t,e,n),zl=({values:r,valueOffsets:t},e,n)=>Pl(r,t,e,Ze(n)),Oa=(r,t,e)=>{r.type.unit===Vt.DAY?Hs(r,t,e):zs(r,t,e)},js=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},Ws=({values:r},t,e)=>{r[t]=BigInt(e)},$s=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},Ys=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},Ua=(r,t,e)=>{switch(r.type.unit){case k.SECOND:return js(r,t,e);case k.MILLISECOND:return Ws(r,t,e);case k.MICROSECOND:return $s(r,t,e);case k.NANOSECOND:return Ys(r,t,e)}},Gs=({values:r},t,e)=>{r[t]=e},qs=({values:r},t,e)=>{r[t]=e},Ks=({values:r},t,e)=>{r[t]=e},Js=({values:r},t,e)=>{r[t]=e},Ma=(r,t,e)=>{switch(r.type.unit){case k.SECOND:return Gs(r,t,e);case k.MILLISECOND:return qs(r,t,e);case k.MICROSECOND:return Ks(r,t,e);case k.NANOSECOND:return Js(r,t,e)}},Ra=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},lm=(r,t,e)=>{let n=r.children[0],i=r.valueOffsets,s=Zt.getVisitFn(n);if(Array.isArray(e))for(let o=-1,c=i[t],l=i[t+1];c<l;)s(n,c++,e[++o]);else for(let o=-1,c=i[t],l=i[t+1];c<l;)s(n,c++,e.get(++o))},um=(r,t,e)=>{let n=r.children[0],{valueOffsets:i}=r,s=Zt.getVisitFn(n),{[t]:o,[t+1]:c}=i,l=e instanceof Map?e.entries():Object.entries(e);for(let f of l)if(s(n,o,f),++o>=c)break},dm=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[s]),fm=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(s)),hm=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(i.name)),pm=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[i.name]),mm=(r,t,e)=>{let n=r.type.children.map(s=>Zt.getVisitFn(s.type)),i=e instanceof Map?hm(t,e):e instanceof pt?fm(t,e):Array.isArray(e)?dm(t,e):pm(t,e);r.type.children.forEach((s,o)=>i(n[o],r.children[o],s,o))},ym=(r,t,e)=>{r.type.mode===xt.Dense?jl(r,t,e):Wl(r,t,e)},jl=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Zt.visit(i,r.valueOffsets[t],e)},Wl=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Zt.visit(i,t,e)},_m=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},La=(r,t,e)=>{r.type.unit===$t.DAY_TIME?Xs(r,t,e):Zs(r,t,e)},Xs=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},Zs=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},Qs=({values:r},t,e)=>{r[t]=e},to=({values:r},t,e)=>{r[t]=e},eo=({values:r},t,e)=>{r[t]=e},ro=({values:r},t,e)=>{r[t]=e},Na=(r,t,e)=>{switch(r.type.unit){case k.SECOND:return Qs(r,t,e);case k.MILLISECOND:return to(r,t,e);case k.MICROSECOND:return eo(r,t,e);case k.NANOSECOND:return ro(r,t,e)}},bm=(r,t,e)=>{let{stride:n}=r,i=r.children[0],s=Zt.getVisitFn(i);if(Array.isArray(e))for(let o=-1,c=t*n;++o<n;)s(i,c+o,e[o]);else for(let o=-1,c=t*n;++o<n;)s(i,c+o,e.get(o))};J.prototype.visitBool=it(am);J.prototype.visitInt=it(Br);J.prototype.visitInt8=it(Br);J.prototype.visitInt16=it(Br);J.prototype.visitInt32=it(Br);J.prototype.visitInt64=it(Br);J.prototype.visitUint8=it(Br);J.prototype.visitUint16=it(Br);J.prototype.visitUint32=it(Br);J.prototype.visitUint64=it(Br);J.prototype.visitFloat=it(cm);J.prototype.visitFloat16=it(Vl);J.prototype.visitFloat32=it(Ta);J.prototype.visitFloat64=it(Ta);J.prototype.visitUtf8=it(zl);J.prototype.visitLargeUtf8=it(zl);J.prototype.visitBinary=it(Hl);J.prototype.visitLargeBinary=it(Hl);J.prototype.visitFixedSizeBinary=it(Ea);J.prototype.visitDate=it(Oa);J.prototype.visitDateDay=it(Hs);J.prototype.visitDateMillisecond=it(zs);J.prototype.visitTimestamp=it(Ua);J.prototype.visitTimestampSecond=it(js);J.prototype.visitTimestampMillisecond=it(Ws);J.prototype.visitTimestampMicrosecond=it($s);J.prototype.visitTimestampNanosecond=it(Ys);J.prototype.visitTime=it(Ma);J.prototype.visitTimeSecond=it(Gs);J.prototype.visitTimeMillisecond=it(qs);J.prototype.visitTimeMicrosecond=it(Ks);J.prototype.visitTimeNanosecond=it(Js);J.prototype.visitDecimal=it(Ra);J.prototype.visitList=it(lm);J.prototype.visitStruct=it(mm);J.prototype.visitUnion=it(ym);J.prototype.visitDenseUnion=it(jl);J.prototype.visitSparseUnion=it(Wl);J.prototype.visitDictionary=it(_m);J.prototype.visitInterval=it(La);J.prototype.visitIntervalDayTime=it(Xs);J.prototype.visitIntervalYearMonth=it(Zs);J.prototype.visitDuration=it(Na);J.prototype.visitDurationSecond=it(Qs);J.prototype.visitDurationMillisecond=it(to);J.prototype.visitDurationMicrosecond=it(eo);J.prototype.visitDurationNanosecond=it(ro);J.prototype.visitFixedSizeList=it(bm);J.prototype.visitMap=it(um);var Zt=new J;var We=Symbol.for("parent"),Hn=Symbol.for("rowIndex"),Gr=class{constructor(t,e){return this[We]=t,this[Hn]=e,new Proxy(this,new Ca)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[Hn],e=this[We],n=e.type.children,i={};for(let s=-1,o=n.length;++s<o;)i[n[s].name]=zt.visit(e.children[s],t);return i}toString(){return"{".concat([...this].map(([t,e])=>"".concat(Ce(t),": ").concat(Ce(e))).join(", "),"}")}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new ka(this[We],this[Hn])}},ka=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,zt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(Gr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[We]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Hn]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var Ca=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[We].type.children.map(e=>e.name)}has(t,e){return t[We].type.children.findIndex(n=>n.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[We].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[We].type.children.findIndex(i=>i.name===e);if(n!==-1){let i=zt.visit(t[We].children[n],t[Hn]);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[We].type.children.findIndex(s=>s.name===e);return i!==-1?(Zt.visit(t[We].children[i],t[Hn],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}};var $=class extends W{};function et(r){return(t,e)=>t.getValid(e)?r(t,e):null}var gm=(r,t)=>864e5*r[t],wm=(r,t)=>null,$l=(r,t,e)=>{if(e+1>=t.length)return null;let n=yt(t[e]),i=yt(t[e+1]);return r.subarray(n,i)},vm=({offset:r,values:t},e)=>{let n=r+e;return(t[n>>3]&1<<n%8)!==0},Yl=({values:r},t)=>gm(r,t),Gl=({values:r},t)=>yt(r[t]),qr=({stride:r,values:t},e)=>t[r*e],Sm=({stride:r,values:t},e)=>Vs(t[r*e]),ql=({values:r},t)=>r[t],Im=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Kl=({values:r,valueOffsets:t},e)=>$l(r,t,e),Jl=({values:r,valueOffsets:t},e)=>{let n=$l(r,t,e);return n!==null?ui(n):null},Dm=({values:r},t)=>r[t],Bm=({type:r,values:t},e)=>r.precision!==At.HALF?t[e]:Vs(t[e]),Fm=(r,t)=>r.type.unit===Vt.DAY?Yl(r,t):Gl(r,t),Xl=({values:r},t)=>1e3*yt(r[t]),Zl=({values:r},t)=>yt(r[t]),Ql=({values:r},t)=>Da(r[t],BigInt(1e3)),tu=({values:r},t)=>Da(r[t],BigInt(1e6)),Am=(r,t)=>{switch(r.type.unit){case k.SECOND:return Xl(r,t);case k.MILLISECOND:return Zl(r,t);case k.MICROSECOND:return Ql(r,t);case k.NANOSECOND:return tu(r,t)}},eu=({values:r},t)=>r[t],ru=({values:r},t)=>r[t],nu=({values:r},t)=>r[t],iu=({values:r},t)=>r[t],xm=(r,t)=>{switch(r.type.unit){case k.SECOND:return eu(r,t);case k.MILLISECOND:return ru(r,t);case k.MICROSECOND:return nu(r,t);case k.NANOSECOND:return iu(r,t)}},Tm=({values:r,stride:t},e)=>Fi.decimal(r.subarray(t*e,t*(e+1))),Em=(r,t)=>{let{valueOffsets:e,stride:n,children:i}=r,{[t*n]:s,[t*n+1]:o}=e,l=i[0].slice(s,o-s);return new pt([l])},Om=(r,t)=>{let{valueOffsets:e,children:n}=r,{[t]:i,[t+1]:s}=e,o=n[0];return new ir(o.slice(i,s-i))},Um=(r,t)=>new Gr(r,t),Mm=(r,t)=>r.type.mode===xt.Dense?su(r,t):ou(r,t),su=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return zt.visit(n,r.valueOffsets[t])},ou=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return zt.visit(n,t)},Rm=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},Lm=(r,t)=>r.type.unit===$t.DAY_TIME?au(r,t):cu(r,t),au=({values:r},t)=>r.subarray(2*t,2*(t+1)),cu=({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},lu=({values:r},t)=>r[t],uu=({values:r},t)=>r[t],du=({values:r},t)=>r[t],fu=({values:r},t)=>r[t],Nm=(r,t)=>{switch(r.type.unit){case k.SECOND:return lu(r,t);case k.MILLISECOND:return uu(r,t);case k.MICROSECOND:return du(r,t);case k.NANOSECOND:return fu(r,t)}},km=(r,t)=>{let{stride:e,children:n}=r,s=n[0].slice(t*e,e);return new pt([s])};$.prototype.visitNull=et(wm);$.prototype.visitBool=et(vm);$.prototype.visitInt=et(Dm);$.prototype.visitInt8=et(qr);$.prototype.visitInt16=et(qr);$.prototype.visitInt32=et(qr);$.prototype.visitInt64=et(ql);$.prototype.visitUint8=et(qr);$.prototype.visitUint16=et(qr);$.prototype.visitUint32=et(qr);$.prototype.visitUint64=et(ql);$.prototype.visitFloat=et(Bm);$.prototype.visitFloat16=et(Sm);$.prototype.visitFloat32=et(qr);$.prototype.visitFloat64=et(qr);$.prototype.visitUtf8=et(Jl);$.prototype.visitLargeUtf8=et(Jl);$.prototype.visitBinary=et(Kl);$.prototype.visitLargeBinary=et(Kl);$.prototype.visitFixedSizeBinary=et(Im);$.prototype.visitDate=et(Fm);$.prototype.visitDateDay=et(Yl);$.prototype.visitDateMillisecond=et(Gl);$.prototype.visitTimestamp=et(Am);$.prototype.visitTimestampSecond=et(Xl);$.prototype.visitTimestampMillisecond=et(Zl);$.prototype.visitTimestampMicrosecond=et(Ql);$.prototype.visitTimestampNanosecond=et(tu);$.prototype.visitTime=et(xm);$.prototype.visitTimeSecond=et(eu);$.prototype.visitTimeMillisecond=et(ru);$.prototype.visitTimeMicrosecond=et(nu);$.prototype.visitTimeNanosecond=et(iu);$.prototype.visitDecimal=et(Tm);$.prototype.visitList=et(Em);$.prototype.visitStruct=et(Um);$.prototype.visitUnion=et(Mm);$.prototype.visitDenseUnion=et(su);$.prototype.visitSparseUnion=et(ou);$.prototype.visitDictionary=et(Rm);$.prototype.visitInterval=et(Lm);$.prototype.visitIntervalDayTime=et(au);$.prototype.visitIntervalYearMonth=et(cu);$.prototype.visitDuration=et(Nm);$.prototype.visitDurationSecond=et(lu);$.prototype.visitDurationMillisecond=et(uu);$.prototype.visitDurationMicrosecond=et(du);$.prototype.visitDurationNanosecond=et(fu);$.prototype.visitFixedSizeList=et(km);$.prototype.visitMap=et(Om);var zt=new $;var Kr=Symbol.for("keys"),jn=Symbol.for("vals"),zn=Symbol.for("kKeysAsStrings"),Pa=Symbol.for("_kKeysAsStrings"),ir=class{constructor(t){return this[Kr]=new pt([t.children[0]]).memoize(),this[jn]=t.children[1],new Proxy(this,new Ha)}get[zn](){return this[Pa]||(this[Pa]=Array.from(this[Kr].toArray(),String))}[Symbol.iterator](){return new Va(this[Kr],this[jn])}get size(){return this[Kr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[Kr],e=this[jn],n={};for(let i=-1,s=t.length;++i<s;)n[t.get(i)]=zt.visit(e,i);return n}toString(){return"{".concat([...this].map(([t,e])=>"".concat(Ce(t),": ").concat(Ce(e))).join(", "),"}")}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},Va=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),zt.visit(this.vals,t)]})}},Ha=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[zn]}has(t,e){return t[zn].includes(e)}getOwnPropertyDescriptor(t,e){if(t[zn].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[zn].indexOf(e);if(n!==-1){let i=zt.visit(Reflect.get(t,jn),n);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[zn].indexOf(e);return i!==-1?(Zt.visit(Reflect.get(t,jn),i,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}};Object.defineProperties(ir.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Kr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[jn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Pa]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var hu;function xi(r,t,e,n){let{length:i=0}=r,s=typeof t!="number"?0:t,o=typeof e!="number"?i:e;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),o<s&&(hu=s,s=o,o=hu),o>i&&(o=i),n?n(r,s,o):[s,o]}var cn=(r,t)=>r<0?t+r:r,pu=r=>r!==r;function Jr(r){if(typeof r!=="object"||r===null)return pu(r)?pu: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?ga(r,e):!1:r instanceof Map?Pm(r):Array.isArray(r)?Cm(r):r instanceof pt?Vm(r):Hm(r,!0)}function Cm(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Jr(r[e]);return no(t)}function Pm(r){let t=-1,e=[];for(let n of r.values())e[++t]=Jr(n);return no(e)}function Vm(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Jr(r.get(e));return no(t)}function Hm(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]=Jr(r[e[i]]);return no(n,e)}function no(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return zm(r,e);case Map:return mu(r,e,e.keys());case ir:case Gr:case Object:case void 0:return mu(r,e,t||Object.keys(e))}return e instanceof pt?jm(r,e):!1}}function zm(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 jm(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 mu(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](),o=0,c=r.length,l=s.next(),f=n.next(),p=i.next();for(;o<c&&!f.done&&!p.done&&!l.done&&!(f.value!==p.value||!r[o](l.value));++o,f=n.next(),p=i.next(),l=s.next());return o===c&&f.done&&p.done&&l.done?!0:(n.return&&n.return(),i.return&&i.return(),s.return&&s.return(),!1)}var ja={};Cr(ja,{BitIterator:()=>ln,getBit:()=>yu,getBool:()=>so,packBools:()=>dn,popcnt_array:()=>_u,popcnt_bit_range:()=>Ti,popcnt_uint32:()=>io,setBool:()=>Wm,truncateBitmap:()=>un});function so(r,t,e,n){return(e&1<<n)!==0}function yu(r,t,e,n){return(e&1<<n)>>n}function Wm(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function un(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):dn(new ln(e,r,t,null,so)).subarray(0,n)),i}return e}function dn(r){let t=[],e=0,n=0,i=0;for(let o of r)o&&(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 ln=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 Ti(r,t,e){if(e-t<=0)return 0;if(e-t<8){let s=0;for(let o of new ln(r,t,e-t,r,yu))s+=o;return s}let n=e>>3<<3,i=t+(t%8===0?0:8-t%8);return Ti(r,t,i)+Ti(r,n,e)+_u(r,i>>3,n-i>>3)}function _u(r,t,e){let n=0,i=Math.trunc(t),s=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:i+e;for(;o-i>=4;)n+=io(s.getUint32(i)),i+=4;for(;o-i>=2;)n+=io(s.getUint16(i)),i+=2;for(;o-i>=1;)n+=io(s.getUint8(i)),i+=1;return n}function io(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 $m=-1,gt=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 L.isSparseUnion(t)?this.children.some(e=>e.nullable):L.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((o,c)=>o+c.byteLength,t)}get nullCount(){if(L.isUnion(this.type))return this.children.reduce((n,i)=>n+i.nullCount,0);let t=this._nullCount,e;return t<=$m&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Ti(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,i,s,o=[],c){this.type=t,this.children=o,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 l;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&&((l=s[0])&&(this.valueOffsets=l),(l=s[1])&&(this.values=l),(l=s[2])&&(this.nullBitmap=l),(l=s[3])&&(this.typeIds=l)))}getValid(t){let{type:e}=this;if(L.isUnion(e)){let n=e,i=this.children[n.typeIdToChildIndex[this.typeIds[t]]],s=n.mode===xt.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(L.isUnion(i)){let s=i,o=this.children[s.typeIdToChildIndex[this.typeIds[t]]],c=s.mode===xt.Dense?this.valueOffsets[t]:t;n=o.getValid(c),o.setValid(c,e)}else{let{nullBitmap:s}=this,{offset:o,length:c}=this,l=o+t,f=1<<l%8,p=l>>3;(!s||s.byteLength<=p)&&(s=new Uint8Array((o+c+63&-64)>>3).fill(255),this.nullCount>0?(s.set(un(o,c,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let B=s[p];n=(B&f)!==0,s[p]=e?B|f:B&~f}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,o=this.children){return new r(t,e,n,i,s,o,this.dictionary)}slice(t,e){let{stride:n,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,c=i===16?n:1,l=this._sliceBuffers(t,e,n,i);return this.clone(this.type,this.offset+t,e,o,l,s.length===0||this.valueOffsets?s:this._sliceChildren(s,c*t,c*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===h.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(un(this.offset,e,this.nullBitmap),0);let s=this.buffers;return s[Ie.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),s)}_sliceBuffers(t,e,n,i){let s,{buffers:o}=this;return(s=o[Ie.TYPE])&&(o[Ie.TYPE]=s.subarray(t,t+e)),(s=o[Ie.OFFSET])&&(o[Ie.OFFSET]=s.subarray(t,t+e+1))||(s=o[Ie.DATA])&&(o[Ie.DATA]=i===6?s:s.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map(i=>i.slice(e,n))}};gt.prototype.children=Object.freeze([]);var Wa=class r extends W{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:e,["offset"]:n=0,["length"]:i=0}=t;return new gt(e,n,i,i)}visitBool(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitInt(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitFloat(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.data),s=tt(t.nullBitmap),o=on(t.valueOffsets),{["length"]:c=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[o,i,s])}visitLargeUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.data),s=tt(t.nullBitmap),o=Is(t.valueOffsets),{["length"]:c=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[o,i,s])}visitBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.data),s=tt(t.nullBitmap),o=on(t.valueOffsets),{["length"]:c=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[o,i,s])}visitLargeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.data),s=tt(t.nullBitmap),o=Is(t.valueOffsets),{["length"]:c=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[o,i,s])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitDate(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitTimestamp(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitTime(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitDecimal(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitList(t){let{["type"]:e,["offset"]:n=0,["child"]:i}=t,s=tt(t.nullBitmap),o=on(t.valueOffsets),{["length"]:c=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[o,void 0,s],[i])}visitStruct(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=tt(t.nullBitmap),{length:o=i.reduce((l,{length:f})=>Math.max(l,f),0),nullCount:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,void 0,s],i)}visitUnion(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=ut(e.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:c=-1}=t;if(L.isSparseUnion(e))return new gt(e,n,o,c,[void 0,void 0,void 0,s],i);let l=on(t.valueOffsets);return new gt(e,n,o,c,[l,void 0,void 0,s],i)}visitDictionary(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.indices.ArrayType,t.data),{["dictionary"]:o=new pt([new r().visit({type:e.dictionary})])}=t,{["length"]:c=s.length,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[void 0,s,i],[],o)}visitInterval(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitDuration(t){let{["type"]:e,["offset"]:n=0}=t,i=tt(t.nullBitmap),s=ut(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,c,[void 0,s,i])}visitFixedSizeList(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new r().visit({type:e.valueType})}=t,s=tt(t.nullBitmap),{["length"]:o=i.length/be(e),["nullCount"]:c=t.nullBitmap?-1:0}=t;return new gt(e,n,o,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=tt(t.nullBitmap),o=on(t.valueOffsets),{["length"]:c=o.length-1,["nullCount"]:l=t.nullBitmap?-1:0}=t;return new gt(e,n,c,l,[o,void 0,s],[i])}},Ym=new Wa;function ot(r){return Ym.visit(r)}var Ei=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 bu(r){return r.some(t=>t.nullable)}function oo(r){return r.reduce((t,e)=>t+e.nullCount,0)}function ao(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function co(r,t,e,n){let i=[];for(let s=-1,o=r.length;++s<o;){let c=r[s],l=t[s],{length:f}=c;if(l>=n)break;if(e>=l+f)continue;if(l>=e&&l+f<=n){i.push(c);continue}let p=Math.max(0,e-l),B=Math.min(n-l,f);i.push(c.slice(p,B-p))}return i.length===0&&i.push(r[0].slice(0,0)),i}function $a(r,t,e,n){let i=0,s=0,o=t.length-1;do{if(i>=o-1)return e<t[o]?n(r,i,e-t[i]):null;s=i+Math.trunc((o-i)*.5),e<t[s]?o=s:i=s}while(i<o)}function Oi(r,t){return r.getValid(t)}function Wn(r){function t(e,n,i){return r(e[n],i)}return function(e){let n=this.data;return $a(n,this._offsets,e,t)}}function lo(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 o=$a(s,this._offsets,n,e);return t=void 0,o}}function uo(r){let t;function e(n,i,s){let o=s,c=0,l=0;for(let f=i-1,p=n.length;++f<p;){let B=n[f];if(~(c=r(B,t,o)))return l+c;o=0,l+=B.length}return-1}return function(n,i){t=n;let s=this.data,o=typeof i!="number"?e(s,0,0):$a(s,this._offsets,i,e);return t=void 0,o}}var Y=class extends W{};function Gm(r,t){return t===null&&r.length>0?0:-1}function qm(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(let i of new ln(e,r.offset+(t||0),r.length,e,so)){if(!i)return n;++n}return-1}function at(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case h.Union:break;case h.Dictionary:break;default:return qm(r,e)}let n=zt.getVisitFn(r),i=Jr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}function gu(r,t,e){let n=zt.getVisitFn(r),i=Jr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}Y.prototype.visitNull=Gm;Y.prototype.visitBool=at;Y.prototype.visitInt=at;Y.prototype.visitInt8=at;Y.prototype.visitInt16=at;Y.prototype.visitInt32=at;Y.prototype.visitInt64=at;Y.prototype.visitUint8=at;Y.prototype.visitUint16=at;Y.prototype.visitUint32=at;Y.prototype.visitUint64=at;Y.prototype.visitFloat=at;Y.prototype.visitFloat16=at;Y.prototype.visitFloat32=at;Y.prototype.visitFloat64=at;Y.prototype.visitUtf8=at;Y.prototype.visitLargeUtf8=at;Y.prototype.visitBinary=at;Y.prototype.visitLargeBinary=at;Y.prototype.visitFixedSizeBinary=at;Y.prototype.visitDate=at;Y.prototype.visitDateDay=at;Y.prototype.visitDateMillisecond=at;Y.prototype.visitTimestamp=at;Y.prototype.visitTimestampSecond=at;Y.prototype.visitTimestampMillisecond=at;Y.prototype.visitTimestampMicrosecond=at;Y.prototype.visitTimestampNanosecond=at;Y.prototype.visitTime=at;Y.prototype.visitTimeSecond=at;Y.prototype.visitTimeMillisecond=at;Y.prototype.visitTimeMicrosecond=at;Y.prototype.visitTimeNanosecond=at;Y.prototype.visitDecimal=at;Y.prototype.visitList=at;Y.prototype.visitStruct=at;Y.prototype.visitUnion=at;Y.prototype.visitDenseUnion=gu;Y.prototype.visitSparseUnion=gu;Y.prototype.visitDictionary=at;Y.prototype.visitInterval=at;Y.prototype.visitIntervalDayTime=at;Y.prototype.visitIntervalYearMonth=at;Y.prototype.visitDuration=at;Y.prototype.visitDurationSecond=at;Y.prototype.visitDurationMillisecond=at;Y.prototype.visitDurationMicrosecond=at;Y.prototype.visitDurationNanosecond=at;Y.prototype.visitFixedSizeList=at;Y.prototype.visitMap=at;var fn=new Y;var G=class extends W{};function rt(r){let{type:t}=r;if(r.nullCount===0&&r.stride===1&&(L.isInt(t)&&t.bitWidth!==64||L.isTime(t)&&t.bitWidth!==64||L.isFloat(t)&&t.precision!==At.HALF))return new Ei(r.data.length,n=>{let i=r.data[n];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new Ei(r.data.length,n=>{let s=r.data[n].length,o=r.slice(e,e+s);return e+=s,new Ya(o)})}var Ya=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}};G.prototype.visitNull=rt;G.prototype.visitBool=rt;G.prototype.visitInt=rt;G.prototype.visitInt8=rt;G.prototype.visitInt16=rt;G.prototype.visitInt32=rt;G.prototype.visitInt64=rt;G.prototype.visitUint8=rt;G.prototype.visitUint16=rt;G.prototype.visitUint32=rt;G.prototype.visitUint64=rt;G.prototype.visitFloat=rt;G.prototype.visitFloat16=rt;G.prototype.visitFloat32=rt;G.prototype.visitFloat64=rt;G.prototype.visitUtf8=rt;G.prototype.visitLargeUtf8=rt;G.prototype.visitBinary=rt;G.prototype.visitLargeBinary=rt;G.prototype.visitFixedSizeBinary=rt;G.prototype.visitDate=rt;G.prototype.visitDateDay=rt;G.prototype.visitDateMillisecond=rt;G.prototype.visitTimestamp=rt;G.prototype.visitTimestampSecond=rt;G.prototype.visitTimestampMillisecond=rt;G.prototype.visitTimestampMicrosecond=rt;G.prototype.visitTimestampNanosecond=rt;G.prototype.visitTime=rt;G.prototype.visitTimeSecond=rt;G.prototype.visitTimeMillisecond=rt;G.prototype.visitTimeMicrosecond=rt;G.prototype.visitTimeNanosecond=rt;G.prototype.visitDecimal=rt;G.prototype.visitList=rt;G.prototype.visitStruct=rt;G.prototype.visitUnion=rt;G.prototype.visitDenseUnion=rt;G.prototype.visitSparseUnion=rt;G.prototype.visitDictionary=rt;G.prototype.visitInterval=rt;G.prototype.visitIntervalDayTime=rt;G.prototype.visitIntervalYearMonth=rt;G.prototype.visitDuration=rt;G.prototype.visitDurationSecond=rt;G.prototype.visitDurationMillisecond=rt;G.prototype.visitDurationMicrosecond=rt;G.prototype.visitDurationNanosecond=rt;G.prototype.visitFixedSizeList=rt;G.prototype.visitMap=rt;var $n=new G;var wu,vu={},Su={},pt=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 gt)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(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:l,indexOf:f}=vu[o.typeId],p=s[0];this.isValid=B=>Oi(p,B),this.get=B=>c(p,B),this.set=(B,A)=>l(p,B,A),this.indexOf=B=>f(p,B),this._offsets=[0,p.length];break}default:Object.setPrototypeOf(this,Su[o.typeId]),this._offsets=ao(s);break}this.data=s,this.type=o,this.stride=be(o),this.numChildren=(i=(n=o.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 bu(this.data)}get nullCount(){return oo(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return"".concat(this.VectorName,"<").concat(this.type[Symbol.toStringTag],">")}get VectorName(){return"".concat(h[this.type.typeId],"Vector")}isValid(t){return!1}get(t){return null}at(t){return this.get(cn(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return $n.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(xi(this,t,e,({data:n,_offsets:i},s,o)=>co(n,i,s,o)))}toJSON(){return[...this]}toArray(){let{type:t,data:e,length:n,stride:i,ArrayType:s}=this;switch(t.typeId){case h.Int:case h.Float:case h.Decimal:case h.Time:case h.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,n*i);default:return e.reduce((o,{values:c,length:l})=>(o.array.set(c.subarray(0,l*i),o.offset),o.offset+=l*i,o),{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 L.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(L.isDictionary(this.type)){let t=new fo(this.data[0].dictionary),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new r(e)}return new fo(this)}unmemoize(){if(L.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}};wu=Symbol.toStringTag;pt[wu]=(r=>{r.type=L.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(h).map(e=>h[e]).filter(e=>typeof e=="number"&&e!==h.NONE);for(let e of t){let n=zt.getVisitFnByTypeId(e),i=Zt.getVisitFnByTypeId(e),s=fn.getVisitFnByTypeId(e);vu[e]={get:n,set:i,indexOf:s},Su[e]=Object.create(r,{isValid:{value:Wn(Oi)},get:{value:Wn(zt.getVisitFnByTypeId(e))},set:{value:lo(Zt.getVisitFnByTypeId(e))},indexOf:{value:uo(fn.getVisitFnByTypeId(e))}})}return"Vector"})(pt.prototype);var fo=class r extends pt{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(o){let c=s[o];if(c!==void 0)return c;let l=e.call(this,o);return s[o]=l,l}}),Object.defineProperty(this,"set",{value(o,c){n.call(this,o,c),s[o]=c}}),Object.defineProperty(this,"slice",{value:(o,c)=>new r(i.call(this,o,c))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new pt(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function Iu(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(Km(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 Km(r){return typeof r!="bigint"?Ce(r):"".concat(Ce(r),"n")}function Ga(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function Du(r,t=0){return r.length>=t?r.subarray(0,t):fi(new r.constructor(t),r,0)}var $e=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?Ga(n*1,this.BYTES_PER_ELEMENT):Ga(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=Ga(t*this.stride,this.BYTES_PER_ELEMENT);let e=Du(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=Du(this.buffer,t)}},Fr=class extends $e{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}},Yn=class extends Fr{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,o=n[i]>>s&1;return e?o===0&&(n[i]|=1<<s,++this.numValid):o===1&&(n[i]&=~(1<<s),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},Gn=class extends Fr{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 Rt=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 Yn,e&&e.length>0&&(this._isValid=Iu(e))}toVector(){return new pt([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:o}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),o.reduce((c,l)=>c+l.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:o,nullCount:c,_typeIds:l,_offsets:f,_values:p,_nulls:B}=this;(e=l==null?void 0:l.flush(o))?i=f==null?void 0:f.flush(o):(i=f==null?void 0:f.flush(o))?t=p==null?void 0:p.flush(f.last()):t=p==null?void 0:p.flush(o),c>0&&(n=B==null?void 0:B.flush(o));let A=this.children.map(E=>E.flush());return this.clear(),ot({type:s,length:o,nullCount:c,children:A,child:A[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}};Rt.prototype.length=1;Rt.prototype.stride=1;Rt.prototype.children=null;Rt.prototype.finished=!1;Rt.prototype.nullValues=null;Rt.prototype._isValid=()=>!0;var jt=class extends Rt{constructor(t){super(t),this._values=new Fr(this.ArrayType,0,this.stride)}setValue(t,e){let n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}},ce=class extends Rt{constructor(t){super(t),this._pendingLength=0,this._offsets=new Gn(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 ir?e[Kr].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 hn=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 ge=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):vt.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new ae).__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 hn).__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 hn).__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 Yt).__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,vt.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 It=class r{constructor(t=[],e,n,i=vt.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=qa(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=ho(ho(new Map,this.metadata),e.metadata),s=e.fields.filter(c=>{let l=n.findIndex(f=>f.name===c.name);return~l?(n[l]=c.clone({metadata:ho(ho(new Map,n[l].metadata),c.metadata)}))&&!1:!0}),o=qa(s,new Map);return new r([...n,...s],i,new Map([...this.dictionaries,...o]))}};It.prototype.fields=null;It.prototype.metadata=null;It.prototype.dictionaries=null;var dt=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)}};dt.prototype.type=null;dt.prototype.name=null;dt.prototype.nullable=null;dt.prototype.metadata=null;function ho(r,t){return new Map([...r||new Map,...t||new Map])}function qa(r,t=new Map){for(let e=-1,n=r.length;++e<n;){let s=r[e].type;if(L.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&&qa(s.children,t)}return t}var Jm=an,Xm=me,Ar=class{static decode(t){t=new Xm(tt(t));let e=ge.getRootAsFooter(t),n=It.decode(e.schema(),new Map,e.version());return new Ka(n,e)}static encode(t){let e=new Jm,n=It.encode(e,t.schema);ge.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())xr.encode(e,o);let i=e.endVector();ge.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())xr.encode(e,o);let s=e.endVector();return ge.startFooter(e),ge.addSchema(e,n),ge.addVersion(e,vt.V5),ge.addRecordBatches(e,i),ge.addDictionaries(e,s),ge.finishFooterBuffer(e,ge.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=vt.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 Ka=class extends Ar{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 xr.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return xr.decode(e)}return null}},xr=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 hn.createBlock(t,i,n,s)}constructor(t,e,n){this.metaDataLength=t,this.offset=yt(n),this.bodyLength=yt(e)}};var Mt=Object.freeze({done:!0,value:void 0}),Ui=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},pn=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())}},po=class extends pn{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return R(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(Mt);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Xt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Xt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return R(this,void 0,void 0,function*(){return yield this.abort(t),Mt})}return(t){return R(this,void 0,void 0,function*(){return yield this.close(),Mt})}read(t){return R(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return R(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(Mt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var sr=class extends po{write(t){if((t=tt(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?ui(this.toUint8Array(!0)):this.toUint8Array(!1).then(ui)}toUint8Array(t=!1){return t?pe(this._values)[0]:R(this,void 0,void 0,function*(){var e,n,i,s;let o=[],c=0;try{for(var l=!0,f=Oe(this),p;p=yield f.next(),e=p.done,!e;l=!0){s=p.value,l=!1;let B=s;o.push(B),c+=B.byteLength}}catch(B){n={error:B}}finally{try{!l&&!e&&(i=f.return)&&(yield i.call(f))}finally{if(n)throw n.error}}return pe(o,c)[0]})}},or=class{constructor(t){t&&(this.source=new Ja(Xt.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)}},Be=class r{constructor(t){t instanceof r?this.source=t.source:t instanceof sr?this.source=new Tr(Xt.fromAsyncIterable(t)):Ss(t)?this.source=new Tr(Xt.fromNodeStream(t)):di(t)?this.source=new Tr(Xt.fromDOMStream(t)):ws(t)?this.source=new Tr(Xt.fromDOMStream(t.body)):Me(t)?this.source=new Tr(Xt.fromIterable(t)):Ue(t)?this.source=new Tr(Xt.fromAsyncIterable(t)):ve(t)&&(this.source=new Tr(Xt.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)}},Ja=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)||Mt)}return(t){return Object.create(this.source.return&&this.source.return(t)||Mt)}},Tr=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return R(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return R(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return R(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return R(this,arguments,void 0,function*(e,n="read"){return yield this.source.next({cmd:n,size:e})})}throw(t){return R(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||Mt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return R(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||Mt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var Mi=class extends or{constructor(t,e){super(),this.position=0,this.buffer=tt(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}}},Xr=class extends Be{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=R(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return R(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 R(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 R(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,o=0,c=0,l=Math.min(n,s+Math.min(n-s,t)),f=new Uint8Array(Math.max(0,(this.position=l)-s));for(;(s+=c)<l&&(o+=c)<f.byteLength;)({bytesRead:c}=yield e.read(f,o,f.byteLength-o,s));return f}return null})}readAt(t,e){return R(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),o=new Uint8Array(s-t);return(yield n.read(o,0,e,t)).buffer}return new Uint8Array(e)})}close(){return R(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return R(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return R(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var Za={};Cr(Za,{BaseInt64:()=>Ri,Int128:()=>Li,Int64:()=>Er,Uint64:()=>Ct});function qn(r){return r<0&&(r=4294967295+r+1),"0x".concat(r.toString(16))}var Kn=8,Xa=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],Ri=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(qn(this.buffer[1])," ").concat(qn(this.buffer[0]))}},Ct=class r extends Ri{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 o=Kn<n-s?Kn:n-s,c=new r(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),l=new r(new Uint32Array([Xa[o],0]));i.times(l),i.plus(c),s+=o}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)}},Er=class r extends Ri{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 o=n?1:0;o<i;){let c=Kn<i-o?Kn:i-o,l=new r(new Uint32Array([Number.parseInt(t.slice(o,o+c),10),0])),f=new r(new Uint32Array([Xa[c],0]));s.times(f),s.plus(l),o+=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)}},Li=class r{constructor(t){this.buffer=t}high(){return new Er(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Er(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 Ct(new Uint32Array([this.buffer[3],0])),n=new Ct(new Uint32Array([this.buffer[2],0])),i=new Ct(new Uint32Array([this.buffer[1],0])),s=new Ct(new Uint32Array([this.buffer[0],0])),o=new Ct(new Uint32Array([t.buffer[3],0])),c=new Ct(new Uint32Array([t.buffer[2],0])),l=new Ct(new Uint32Array([t.buffer[1],0])),f=new Ct(new Uint32Array([t.buffer[0],0])),p=Ct.multiply(s,f);this.buffer[0]=p.low();let B=new Ct(new Uint32Array([p.high(),0]));return p=Ct.multiply(i,f),B.plus(p),p=Ct.multiply(s,l),B.plus(p),this.buffer[1]=B.low(),this.buffer[3]=B.lessThan(p)?1:0,this.buffer[2]=B.high(),new Ct(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(Ct.multiply(n,f)).plus(Ct.multiply(i,l)).plus(Ct.multiply(s,c)),this.buffer[3]+=Ct.multiply(e,f).plus(Ct.multiply(n,l)).plus(Ct.multiply(i,c)).plus(Ct.multiply(s,o)).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(qn(this.buffer[3])," ").concat(qn(this.buffer[2])," ").concat(qn(this.buffer[1])," ").concat(qn(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 o=n?1:0;o<i;){let c=Kn<i-o?Kn:i-o,l=new r(new Uint32Array([Number.parseInt(t.slice(o,o+c),10),0,0,0])),f=new r(new Uint32Array([Xa[c],0,0,0]));s.times(f),s.plus(l),o+=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 Ni=class extends W{constructor(t,e,n,i,s=vt.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 dt?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return ot({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({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 ot({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 ot({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 ot({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 ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({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 ot({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<vt.V5&&this.readNullBitmap(t,n),t.mode===xt.Sparse?this.visitSparseUnion(t,{length:e,nullCount:n}):this.visitDenseUnion(t,{length:e,nullCount:n})}visitDenseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({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 ot({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({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 ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return ot({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 ot({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)}},mo=class extends Ni{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):dn(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return ut(Uint8Array,ut(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return ut(Uint8Array,ut(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;return L.isTimestamp(t)?ut(Uint8Array,Er.convertArray(n[e])):(L.isInt(t)||L.isTime(t))&&t.bitWidth===64||L.isDuration(t)?ut(Uint8Array,Er.convertArray(n[e])):L.isDate(t)&&t.unit===Vt.MILLISECOND?ut(Uint8Array,Er.convertArray(n[e])):L.isDecimal(t)?ut(Uint8Array,Li.convertArray(n[e])):L.isBinary(t)||L.isLargeBinary(t)||L.isFixedSizeBinary(t)?Zm(n[e]):L.isBool(t)?dn(n[e]):L.isUtf8(t)||L.isLargeUtf8(t)?Ze(n[e].join("")):ut(Uint8Array,ut(t.ArrayType,n[e].map(i=>+i)))}};function Zm(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 Jn=class extends ce{constructor(t){super(t),this._values=new $e(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,tt(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,c]of t)if(c===void 0)n.set(o,0);else{let l=c.length;i.set(c,s),n.set(o,l),s+=l}}};var Xn=class extends ce{constructor(t){super(t),this._values=new $e(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,tt(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,c]of t)if(c===void 0)n.set(o,BigInt(0));else{let l=c.length;i.set(c,s),n.set(o,BigInt(l)),s+=l}}};var yo=class extends Rt{constructor(t){super(t),this._values=new Yn}setValue(t,e){this._values.set(t,+e)}};var mn=class extends jt{};mn.prototype._setValue=Oa;var ki=class extends mn{};ki.prototype._setValue=Hs;var Ci=class extends mn{};Ci.prototype._setValue=zs;var Pi=class extends jt{};Pi.prototype._setValue=Ra;var _o=class extends Rt{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new _e(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=yn({type:this.type.indices,nullValues:e}),this.dictionary=yn({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 Vi=class extends jt{};Vi.prototype._setValue=Ea;var bo=class extends Rt{setValue(t,e){let[n]=this.children,i=t*this.stride;for(let s=-1,o=e.length;++s<o;)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 ze(this.type.listSize,new dt(e,t.type,!0)),n}};var _n=class extends jt{setValue(t,e){this._values.set(t,e)}},go=class extends _n{setValue(t,e){super.setValue(t,Ai(e))}},wo=class extends _n{},vo=class extends _n{};var bn=class extends jt{};bn.prototype._setValue=La;var Hi=class extends bn{};Hi.prototype._setValue=Xs;var zi=class extends bn{};zi.prototype._setValue=Zs;var Or=class extends jt{};Or.prototype._setValue=Na;var ji=class extends Or{};ji.prototype._setValue=Qs;var Wi=class extends Or{};Wi.prototype._setValue=to;var $i=class extends Or{};$i.prototype._setValue=eo;var Yi=class extends Or{};Yi.prototype._setValue=ro;var Fe=class extends jt{setValue(t,e){this._values.set(t,e)}},So=class extends Fe{},Io=class extends Fe{},Do=class extends Fe{},Bo=class extends Fe{},Fo=class extends Fe{},Ao=class extends Fe{},xo=class extends Fe{},To=class extends Fe{};var Eo=class extends ce{constructor(t){super(t),this._offsets=new Gn(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 Ve(new dt(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 o=s,c=o.length,l=e.set(i,c).buffer[i];for(let f=-1;++f<c;)n.set(l+f,o[f])}}};var Oo=class extends ce{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 je(new dt(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]:o,[i+1]:c}=e.set(i,s.size).buffer;for(let l of s.entries())if(n.set(o,l),++o>=c)break}}};var Uo=class extends Rt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var Mo=class extends Rt{setValue(t,e){let{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach((s,o)=>n[o].set(t,e[o]));case Map:return i.children.forEach((s,o)=>n[o].set(t,e.get(s.name)));default:return i.children.forEach((s,o)=>n[o].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 Ut([...this.type.children,new dt(e,t.type,!0)]),n}};var Ur=class extends jt{};Ur.prototype._setValue=Ua;var Gi=class extends Ur{};Gi.prototype._setValue=js;var qi=class extends Ur{};qi.prototype._setValue=Ws;var Ki=class extends Ur{};Ki.prototype._setValue=$s;var Ji=class extends Ur{};Ji.prototype._setValue=Ys;var Mr=class extends jt{};Mr.prototype._setValue=Ma;var Xi=class extends Mr{};Xi.prototype._setValue=Gs;var Zi=class extends Mr{};Zi.prototype._setValue=qs;var Qi=class extends Mr{};Qi.prototype._setValue=Ks;var ts=class extends Mr{};ts.prototype._setValue=Js;var Zn=class extends Rt{constructor(t){super(t),this._typeIds=new Fr(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:o}}=this,c=[...i,new dt(e,t.type)];return this.type=new He(s,[...o,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.")}},Ro=class extends Zn{},Lo=class extends Zn{constructor(t){super(t),this._offsets=new Fr(Int32Array)}setValue(t,e,n){let i=this._typeIds.set(t,n).buffer[t],s=this.getChildAt(this.type.typeIdToChildIndex[i]),o=this._offsets.set(t,s.length).buffer[t];s==null||s.set(o,e)}};var es=class extends ce{constructor(t){super(t),this._values=new $e(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,Ze(e))}_flushPending(t,e){}};es.prototype._flushPending=Jn.prototype._flushPending;var rs=class extends ce{constructor(t){super(t),this._values=new $e(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,Ze(e))}_flushPending(t,e){}};rs.prototype._flushPending=Xn.prototype._flushPending;var Qa=class extends W{visitNull(){return Uo}visitBool(){return yo}visitInt(){return Fe}visitInt8(){return So}visitInt16(){return Io}visitInt32(){return Do}visitInt64(){return Bo}visitUint8(){return Fo}visitUint16(){return Ao}visitUint32(){return xo}visitUint64(){return To}visitFloat(){return _n}visitFloat16(){return go}visitFloat32(){return wo}visitFloat64(){return vo}visitUtf8(){return es}visitLargeUtf8(){return rs}visitBinary(){return Jn}visitLargeBinary(){return Xn}visitFixedSizeBinary(){return Vi}visitDate(){return mn}visitDateDay(){return ki}visitDateMillisecond(){return Ci}visitTimestamp(){return Ur}visitTimestampSecond(){return Gi}visitTimestampMillisecond(){return qi}visitTimestampMicrosecond(){return Ki}visitTimestampNanosecond(){return Ji}visitTime(){return Mr}visitTimeSecond(){return Xi}visitTimeMillisecond(){return Zi}visitTimeMicrosecond(){return Qi}visitTimeNanosecond(){return ts}visitDecimal(){return Pi}visitList(){return Eo}visitStruct(){return Mo}visitUnion(){return Zn}visitDenseUnion(){return Lo}visitSparseUnion(){return Ro}visitDictionary(){return _o}visitInterval(){return bn}visitIntervalDayTime(){return Hi}visitIntervalYearMonth(){return zi}visitDuration(){return Or}visitDurationSecond(){return ji}visitDurationMillisecond(){return Wi}visitDurationMicrosecond(){return $i}visitDurationNanosecond(){return Yi}visitFixedSizeList(){return bo}visitMap(){return Oo}},Bu=new Qa;var q=class extends W{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 se(r,t){return t instanceof r.constructor}function gn(r,t){return r===t||se(r,t)}function Rr(r,t){return r===t||se(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function No(r,t){return r===t||se(r,t)&&r.precision===t.precision}function Qm(r,t){return r===t||se(r,t)&&r.byteWidth===t.byteWidth}function tc(r,t){return r===t||se(r,t)&&r.unit===t.unit}function ns(r,t){return r===t||se(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function is(r,t){return r===t||se(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function ty(r,t){return r===t||se(r,t)&&r.children.length===t.children.length&&ar.compareManyFields(r.children,t.children)}function ey(r,t){return r===t||se(r,t)&&r.children.length===t.children.length&&ar.compareManyFields(r.children,t.children)}function ec(r,t){return r===t||se(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&ar.compareManyFields(r.children,t.children)}function ry(r,t){return r===t||se(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&ar.visit(r.indices,t.indices)&&ar.visit(r.dictionary,t.dictionary)}function rc(r,t){return r===t||se(r,t)&&r.unit===t.unit}function ss(r,t){return r===t||se(r,t)&&r.unit===t.unit}function ny(r,t){return r===t||se(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&ar.compareManyFields(r.children,t.children)}function iy(r,t){return r===t||se(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&ar.compareManyFields(r.children,t.children)}q.prototype.visitNull=gn;q.prototype.visitBool=gn;q.prototype.visitInt=Rr;q.prototype.visitInt8=Rr;q.prototype.visitInt16=Rr;q.prototype.visitInt32=Rr;q.prototype.visitInt64=Rr;q.prototype.visitUint8=Rr;q.prototype.visitUint16=Rr;q.prototype.visitUint32=Rr;q.prototype.visitUint64=Rr;q.prototype.visitFloat=No;q.prototype.visitFloat16=No;q.prototype.visitFloat32=No;q.prototype.visitFloat64=No;q.prototype.visitUtf8=gn;q.prototype.visitLargeUtf8=gn;q.prototype.visitBinary=gn;q.prototype.visitLargeBinary=gn;q.prototype.visitFixedSizeBinary=Qm;q.prototype.visitDate=tc;q.prototype.visitDateDay=tc;q.prototype.visitDateMillisecond=tc;q.prototype.visitTimestamp=ns;q.prototype.visitTimestampSecond=ns;q.prototype.visitTimestampMillisecond=ns;q.prototype.visitTimestampMicrosecond=ns;q.prototype.visitTimestampNanosecond=ns;q.prototype.visitTime=is;q.prototype.visitTimeSecond=is;q.prototype.visitTimeMillisecond=is;q.prototype.visitTimeMicrosecond=is;q.prototype.visitTimeNanosecond=is;q.prototype.visitDecimal=gn;q.prototype.visitList=ty;q.prototype.visitStruct=ey;q.prototype.visitUnion=ec;q.prototype.visitDenseUnion=ec;q.prototype.visitSparseUnion=ec;q.prototype.visitDictionary=ry;q.prototype.visitInterval=rc;q.prototype.visitIntervalDayTime=rc;q.prototype.visitIntervalYearMonth=rc;q.prototype.visitDuration=ss;q.prototype.visitDurationSecond=ss;q.prototype.visitDurationMillisecond=ss;q.prototype.visitDurationMicrosecond=ss;q.prototype.visitDurationNanosecond=ss;q.prototype.visitFixedSizeList=ny;q.prototype.visitMap=iy;var ar=new q;function wn(r,t){return ar.compareSchemas(r,t)}function Fu(r,t){return ar.compareFields(r,t)}function Au(r,t){return ar.visit(r,t)}function yn(r){let t=r.type,e=new(Bu.getVisitFn(t)())(r);if(t.children&&t.children.length>0){let n=r.children||[],i={nullValues:r.nullValues},s=Array.isArray(n)?(o,c)=>n[c]||i:({name:o})=>n[o]||i;for(let[o,c]of t.children.entries()){let{type:l}=c,f=s(c,o);e.children.push(yn(Object.assign(Object.assign({},f),{type:l})))}}return e}function ko(r,t){return sy(r,t.map(e=>e.data.concat()))}function sy(r,t){let e=[...r.fields],n=[],i={numBatches:t.reduce((B,A)=>Math.max(B,A.length),0)},s=0,o=0,c=-1,l=t.length,f,p=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,c=-1;++c<l;)p[c]=f=t[c].shift(),o=Math.min(o,f?f.length:o);Number.isFinite(o)&&(p=oy(e,o,p,t,i),o>0&&(n[s++]=ot({type:new Ut(e),length:o,nullCount:0,children:p.slice()})))}return[r=r.assign(e),n.map(B=>new Ht(r,B))]}function oy(r,t,e,n,i){var s;let o=(t+63&-64)>>3;for(let c=-1,l=n.length;++c<l;){let f=e[c],p=f==null?void 0:f.length;if(p>=t)p===t?e[c]=f:(e[c]=f.slice(0,t),i.numBatches=Math.max(i.numBatches,n[c].unshift(f.slice(t,p-t))));else{let B=r[c];r[c]=B.clone({nullable:!0}),e[c]=(s=f==null?void 0:f._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:ot({type:B.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var xu,oe=class r{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new It([]),this._offsets=[0],this;let i,s;t[0]instanceof It&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=l=>{if(l){if(l instanceof Ht)return[l];if(l instanceof r)return l.batches;if(l instanceof gt){if(l.type instanceof Ut)return[new Ht(new It(l.type.children),l)]}else{if(Array.isArray(l))return l.flatMap(f=>o(f));if(typeof l[Symbol.iterator]=="function")return[...l].flatMap(f=>o(f));if(typeof l=="object"){let f=Object.keys(l),p=f.map(E=>new pt([l[E]])),B=i!=null?i:new It(f.map((E,X)=>new dt(String(E),p[X].type,p[X].nullable))),[,A]=ko(B,p);return A.length===0?[new Ht(l)]:A}}}return[]},c=t.flatMap(l=>o(l));if(i=(n=i!=null?i:(e=c[0])===null||e===void 0?void 0:e.schema)!==null&&n!==void 0?n:new It([]),!(i instanceof It))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let l of c){if(!(l instanceof Ht))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!wn(i,l.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=c,this._offsets=s!=null?s:ao(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=oo(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(cn(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?$n.visit(new pt(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 Ht(e,i)))}slice(t,e){let n=this.schema;[t,e]=xi({length:this.numRows},t,e);let i=co(this.data,this._offsets,t,e);return new r(n,i.map(s=>new Ht(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=ot({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new pt(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 pt([ot({type:new ie,length:this.numRows})]));let s=n.fields.slice(),o=s[t].clone({type:e.type}),c=this.schema.fields.map((l,f)=>this.getChildAt(f));[s[t],c[t]]=[o,e],[n,i]=ko(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,l,f)=>{let[p,B]=c,A=e.findIndex(E=>E.name===l.name);return~A?B[A]=f:p.push(f),c},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((c,l)=>[l,i[l]]).map(([c,l])=>l===void 0?this.getChildAt(c):t.getChildAt(l)),...n.map(c=>t.getChildAt(c))].filter(Boolean);return new r(...ko(s,o))}};xu=Symbol.toStringTag;oe[xu]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Wn(Oi),r.get=Wn(zt.getVisitFn(h.Struct)),r.set=lo(Zt.getVisitFn(h.Struct)),r.indexOf=uo(fn.getVisitFn(h.Struct)),"Table"))(oe.prototype);var Eu,Ht=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof It))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=ot({nullCount:0,type:new Ut(this.schema.fields),children:this.schema.fields.map(e=>ot({type:e.type,nullCount:0}))})]=t,!(this.data instanceof gt))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Tu(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:n,children:i,length:s}=Object.keys(e).reduce((l,f,p)=>(l.children[p]=e[f],l.length=Math.max(l.length,e[f].length),l.fields[p]=dt.new({name:f,type:e[f].type,nullable:!0}),l),{length:0,fields:new Array,children:new Array}),o=new It(n),c=ot({type:new Ut(n),length:s,children:i,nullCount:0});[this.schema,this.data]=Tu(o,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=Ou(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 zt.visit(this.data,t)}at(t){return this.get(cn(t,this.numRows))}set(t,e){return Zt.visit(this.data,t,e)}indexOf(t,e){return fn.visit(this.data,t,e)}[Symbol.iterator](){return $n.visit(new pt([this.data]))}toArray(){return[...this]}concat(...t){return new oe(this.schema,[this,...t])}slice(t,e){let[n]=new pt([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 pt([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 pt([ot({type:new ie,length:this.numRows})]));let s=n.fields.slice(),o=i.children.slice(),c=s[t].clone({type:e.type});[s[t],o[t]]=[c,e.data[0]],n=new It(s,new Map(this.schema.metadata)),i=ot({type:new Ut(s),children:o})}return new r(n,i)}select(t){let e=this.schema.select(t),n=new Ut(e.fields),i=[];for(let s of t){let o=this.schema.fields.findIndex(c=>c.name===s);~o&&(i[o]=this.data.children[o])}return new r(e,ot({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=ot({type:new Ut(e.fields),length:this.numRows,children:n});return new r(e,i)}};Eu=Symbol.toStringTag;Ht[Eu]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Ht.prototype);function Tu(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;let i=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(let[c,l]of r.fields.entries()){let f=t[c];(!f||f.length!==e)&&(i[c]=l.clone({nullable:!0}),s[c]=(n=f==null?void 0:f._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:ot({type:l.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(i),ot({type:new Ut(i),length:e,children:s})]}function Ou(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,o=r.length;++s<o;){let{type:c}=r[s],l=t[s];for(let f of[l,...((i=l==null?void 0:l.dictionary)===null||i===void 0?void 0:i.data)||[]])Ou(c.children,f==null?void 0:f.children,e);if(L.isDictionary(c)){let{id:f}=c;if(!e.has(f))l!=null&&l.dictionary&&e.set(f,l.dictionary);else if(e.get(f)!==l.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var vn=class extends Ht{constructor(t){let e=t.fields.map(i=>ot({type:i.type})),n=ot({type:new Ut(t.fields),nullCount:0,children:e});super(t,n)}};var Ye=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):vt.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):ht.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 Yt).__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,vt.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,ht.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,o){return r.startMessage(t),r.addVersion(t,e),r.addHeaderType(t,n),r.addHeader(t,i),r.addBodyLength(t,s),r.addCustomMetadata(t,o),r.endMessage(t)}};var nc=class extends W{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Si.startNull(e),Si.endNull(e)}visitInt(t,e){return Ne.startInt(e),Ne.addBitWidth(e,t.bitWidth),Ne.addIsSigned(e,t.isSigned),Ne.endInt(e)}visitFloat(t,e){return Wr.startFloatingPoint(e),Wr.addPrecision(e,t.precision),Wr.endFloatingPoint(e)}visitBinary(t,e){return _i.startBinary(e),_i.endBinary(e)}visitLargeBinary(t,e){return gi.startLargeBinary(e),gi.endLargeBinary(e)}visitBool(t,e){return bi.startBool(e),bi.endBool(e)}visitUtf8(t,e){return Di.startUtf8(e),Di.endUtf8(e)}visitLargeUtf8(t,e){return wi.startLargeUtf8(e),wi.endLargeUtf8(e)}visitDecimal(t,e){return rr.startDecimal(e),rr.addScale(e,t.scale),rr.addPrecision(e,t.precision),rr.addBitWidth(e,t.bitWidth),rr.endDecimal(e)}visitDate(t,e){return Vr.startDate(e),Vr.addUnit(e,t.unit),Vr.endDate(e)}visitTime(t,e){return dr.startTime(e),dr.addUnit(e,t.unit),dr.addBitWidth(e,t.bitWidth),dr.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return fr.startTimestamp(e),fr.addUnit(e,t.unit),n!==void 0&&fr.addTimezone(e,n),fr.endTimestamp(e)}visitInterval(t,e){return $r.startInterval(e),$r.addUnit(e,t.unit),$r.endInterval(e)}visitDuration(t,e){return Hr.startDuration(e),Hr.addUnit(e,t.unit),Hr.endDuration(e)}visitList(t,e){return vi.startList(e),vi.endList(e)}visitStruct(t,e){return Ii.startStruct_(e),Ii.endStruct_(e)}visitUnion(t,e){ke.startTypeIdsVector(e,t.typeIds.length);let n=ke.createTypeIdsVector(e,t.typeIds);return ke.startUnion(e),ke.addMode(e,t.mode),ke.addTypeIds(e,n),ke.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return er.startDictionaryEncoding(e),er.addId(e,BigInt(t.id)),er.addIsOrdered(e,t.isOrdered),n!==void 0&&er.addIndexType(e,n),er.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return zr.startFixedSizeBinary(e),zr.addByteWidth(e,t.byteWidth),zr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return jr.startFixedSizeList(e),jr.addListSize(e,t.listSize),jr.endFixedSizeList(e)}visitMap(t,e){return Yr.startMap(e),Yr.addKeysSorted(e,t.keysSorted),Yr.endMap(e)}},Co=new nc;function Lu(r,t=new Map){return new It(cy(r,t),Po(r.metadata),t)}function ic(r){return new Qt(r.count,ku(r.columns),Cu(r.columns))}function Nu(r){return new ue(ic(r.data),r.id,r.isDelta)}function cy(r,t){return(r.fields||[]).filter(Boolean).map(e=>dt.fromJSON(e,t))}function Uu(r,t){return(r.children||[]).filter(Boolean).map(e=>dt.fromJSON(e,t))}function ku(r){return(r||[]).reduce((t,e)=>[...t,new Ae(e.count,ly(e.VALIDITY)),...ku(e.children)],[])}function Cu(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new le(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new le(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new le(t.length,i.OFFSET.length)),i.DATA&&t.push(new le(t.length,i.DATA.length)),t=Cu(i.children,t)}return t}function ly(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function Pu(r,t){let e,n,i,s,o,c;return!t||!(s=r.dictionary)?(o=Ru(r,Uu(r,t)),i=new dt(r.name,o,r.nullable,Po(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?Mu(n):new nr,c=new _e(t.get(e),n,e,s.isOrdered),i=new dt(r.name,c,r.nullable,Po(r.metadata))):(n=(n=s.indexType)?Mu(n):new nr,t.set(e,o=Ru(r,Uu(r,t))),c=new _e(o,n,e,s.isOrdered),i=new dt(r.name,c,r.nullable,Po(r.metadata))),i||null}function Po(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function Mu(r){return new Gt(r.isSigned,r.bitWidth)}function Ru(r,t){let e=r.type.name;switch(e){case"NONE":return new ie;case"null":return new ie;case"binary":return new hr;case"largebinary":return new pr;case"utf8":return new mr;case"largeutf8":return new yr;case"bool":return new _r;case"list":return new Ve((t||[])[0]);case"struct":return new Ut(t||[]);case"struct_":return new Ut(t||[])}switch(e){case"int":{let n=r.type;return new Gt(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new De(At[n.precision])}case"decimal":{let n=r.type;return new br(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new gr(Vt[n.unit])}case"time":{let n=r.type;return new wr(k[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new vr(k[n.unit],n.timezone)}case"interval":{let n=r.type;return new Sr($t[n.unit])}case"duration":{let n=r.type;return new Ir(k[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new He(xt[o],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new Dr(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new ze(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new je((t||[])[0],n.keysSorted)}}throw new Error('Unrecognized type: "'.concat(e,'"'))}var uy=an,dy=me,de=class r{static fromJSON(t,e){let n=new r(0,vt.V5,e);return n._createHeader=fy(t,e),n}static decode(t){t=new dy(tt(t));let e=Ye.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new r(n,i,s);return o._createHeader=hy(e,s),o}static encode(t){let e=new uy,n=-1;return t.isSchema()?n=It.encode(e,t.header()):t.isRecordBatch()?n=Qt.encode(e,t.header()):t.isDictionaryBatch()&&(n=ue.encode(e,t.header())),Ye.startMessage(e),Ye.addVersion(e,vt.V5),Ye.addHeader(e,n),Ye.addHeaderType(e,t.headerType),Ye.addBodyLength(e,BigInt(t.bodyLength)),Ye.finishMessageBuffer(e,Ye.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof It)return new r(0,vt.V5,ht.Schema,t);if(t instanceof Qt)return new r(e,vt.V5,ht.RecordBatch,t);if(t instanceof ue)return new r(e,vt.V5,ht.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===ht.Schema}isRecordBatch(){return this.headerType===ht.RecordBatch}isDictionaryBatch(){return this.headerType===ht.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=yt(t)}},Qt=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=yt(t)}},ue=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=yt(e)}},le=class{constructor(t,e){this.offset=yt(t),this.length=yt(e)}},Ae=class{constructor(t,e){this.length=yt(t),this.nullCount=yt(e)}};function fy(r,t){return()=>{switch(t){case ht.Schema:return It.fromJSON(r);case ht.RecordBatch:return Qt.fromJSON(r);case ht.DictionaryBatch:return ue.fromJSON(r)}throw new Error("Unrecognized Message type: { name: ".concat(ht[t],", type: ").concat(t," }"))}}function hy(r,t){return()=>{switch(t){case ht.Schema:return It.decode(r.header(new ae),new Map,r.version());case ht.RecordBatch:return Qt.decode(r.header(new ye),r.version());case ht.DictionaryBatch:return ue.decode(r.header(new ur),r.version())}throw new Error("Unrecognized Message type: { name: ".concat(ht[t],", type: ").concat(t," }"))}}dt.encode=Dy;dt.decode=Sy;dt.fromJSON=Pu;It.encode=Iy;It.decode=py;It.fromJSON=Lu;Qt.encode=By;Qt.decode=my;Qt.fromJSON=ic;ue.encode=Fy;ue.decode=yy;ue.fromJSON=Nu;Ae.encode=Ay;Ae.decode=by;le.encode=xy;le.decode=_y;function py(r,t=new Map,e=vt.V5){let n=vy(r,t);return new It(n,Vo(r),t,e)}function my(r,t=vt.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Qt(r.length(),gy(r),wy(r,t))}function yy(r,t=vt.V5){return new ue(Qt.decode(r.data(),t),r.id(),r.isDelta())}function _y(r){return new le(r.offset(),r.length())}function by(r){return new Ae(r.length(),r.nullCount())}function gy(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=Ae.decode(e));return t}function wy(r,t){let e=[];for(let n,i=-1,s=-1,o=r.buffersLength();++i<o;)(n=r.buffers(i))&&(t<vt.V4&&(n.bb_pos+=8*(i+1)),e[++s]=le.decode(n));return e}function vy(r,t){let e=[];for(let n,i=-1,s=-1,o=r.fieldsLength();++i<o;)(n=r.fields(i))&&(e[++s]=dt.decode(n,t));return e}function Vu(r,t){let e=[];for(let n,i=-1,s=-1,o=r.childrenLength();++i<o;)(n=r.children(i))&&(e[++s]=dt.decode(n,t));return e}function Sy(r,t){let e,n,i,s,o,c;return!t||!(c=r.dictionary())?(i=zu(r,Vu(r,t)),n=new dt(r.name(),i,r.nullable(),Vo(r))):t.has(e=yt(c.id()))?(s=(s=c.indexType())?Hu(s):new nr,o=new _e(t.get(e),s,e,c.isOrdered()),n=new dt(r.name(),o,r.nullable(),Vo(r))):(s=(s=c.indexType())?Hu(s):new nr,t.set(e,i=zu(r,Vu(r,t))),o=new _e(i,s,e,c.isOrdered()),n=new dt(r.name(),o,r.nullable(),Vo(r))),n||null}function Vo(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 Hu(r){return new Gt(r.isSigned(),r.bitWidth())}function zu(r,t){let e=r.typeType();switch(e){case Tt.NONE:return new ie;case Tt.Null:return new ie;case Tt.Binary:return new hr;case Tt.LargeBinary:return new pr;case Tt.Utf8:return new mr;case Tt.LargeUtf8:return new yr;case Tt.Bool:return new _r;case Tt.List:return new Ve((t||[])[0]);case Tt.Struct_:return new Ut(t||[])}switch(e){case Tt.Int:{let n=r.type(new Ne);return new Gt(n.isSigned(),n.bitWidth())}case Tt.FloatingPoint:{let n=r.type(new Wr);return new De(n.precision())}case Tt.Decimal:{let n=r.type(new rr);return new br(n.scale(),n.precision(),n.bitWidth())}case Tt.Date:{let n=r.type(new Vr);return new gr(n.unit())}case Tt.Time:{let n=r.type(new dr);return new wr(n.unit(),n.bitWidth())}case Tt.Timestamp:{let n=r.type(new fr);return new vr(n.unit(),n.timezone())}case Tt.Interval:{let n=r.type(new $r);return new Sr(n.unit())}case Tt.Duration:{let n=r.type(new Hr);return new Ir(n.unit())}case Tt.Union:{let n=r.type(new ke);return new He(n.mode(),n.typeIdsArray()||[],t||[])}case Tt.FixedSizeBinary:{let n=r.type(new zr);return new Dr(n.byteWidth())}case Tt.FixedSizeList:{let n=r.type(new jr);return new ze(n.listSize(),(t||[])[0])}case Tt.Map:{let n=r.type(new Yr);return new je((t||[])[0],n.keysSorted())}}throw new Error('Unrecognized type: "'.concat(Tt[e],'" (').concat(e,")"))}function Iy(r,t){let e=t.fields.map(s=>dt.encode(r,s));ae.startFieldsVector(r,e.length);let n=ae.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?ae.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let c=r.createString("".concat(s)),l=r.createString("".concat(o));return Yt.startKeyValue(r),Yt.addKey(r,c),Yt.addValue(r,l),Yt.endKeyValue(r)})):-1;return ae.startSchema(r),ae.addFields(r,n),ae.addEndianness(r,Ty?Pr.Little:Pr.Big),i!==-1&&ae.addCustomMetadata(r,i),ae.endSchema(r)}function Dy(r,t){let e=-1,n=-1,i=-1,s=t.type,o=t.typeId;L.isDictionary(s)?(o=s.dictionary.typeId,i=Co.visit(s,r),n=Co.visit(s.dictionary,r)):n=Co.visit(s,r);let c=(s.children||[]).map(p=>dt.encode(r,p)),l=ee.createChildrenVector(r,c),f=t.metadata&&t.metadata.size>0?ee.createCustomMetadataVector(r,[...t.metadata].map(([p,B])=>{let A=r.createString("".concat(p)),E=r.createString("".concat(B));return Yt.startKeyValue(r),Yt.addKey(r,A),Yt.addValue(r,E),Yt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),ee.startField(r),ee.addType(r,n),ee.addTypeType(r,o),ee.addChildren(r,l),ee.addNullable(r,!!t.nullable),e!==-1&&ee.addName(r,e),i!==-1&&ee.addDictionary(r,i),f!==-1&&ee.addCustomMetadata(r,f),ee.endField(r)}function By(r,t){let e=t.nodes||[],n=t.buffers||[];ye.startNodesVector(r,e.length);for(let o of e.slice().reverse())Ae.encode(r,o);let i=r.endVector();ye.startBuffersVector(r,n.length);for(let o of n.slice().reverse())le.encode(r,o);let s=r.endVector();return ye.startRecordBatch(r),ye.addLength(r,BigInt(t.length)),ye.addNodes(r,i),ye.addBuffers(r,s),ye.endRecordBatch(r)}function Fy(r,t){let e=Qt.encode(r,t.data);return ur.startDictionaryBatch(r),ur.addId(r,BigInt(t.id)),ur.addIsDelta(r,t.isDelta),ur.addData(r,e),ur.endDictionaryBatch(r)}function Ay(r,t){return Ln.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function xy(r,t){return Rn.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var Ty=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var oc=r=>"Expected ".concat(ht[r]," Message in stream, but was null or length 0."),ac=r=>"Header pointer of flatbuffer-encoded ".concat(ht[r]," Message is null or length 0."),ju=(r,t)=>"Expected to read ".concat(r," metadata bytes, but only read ").concat(t,"."),Wu=(r,t)=>"Expected to read ".concat(r," bytes for message body, but only read ").concat(t,"."),Qn=class{constructor(t){this.source=t instanceof or?t:new or(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?Mt:t.value===-1&&(t=this.readMetadataLength()).done?Mt:(t=this.readMetadata(t.value)).done?Mt: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(oc(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=tt(this.source.read(t));if(e.byteLength<t)throw new Error(Wu(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=ht.Schema,n=this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(ac(e));return i}readMetadataLength(){let t=this.source.read(Ho),e=t&&new me(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 Mt;if(e.byteLength<t)throw new Error(ju(t,e.byteLength));return{done:!1,value:de.decode(e)}}},os=class{constructor(t,e){this.source=t instanceof Be?t:gs(t)?new Xr(t,e):new Be(t)}[Symbol.asyncIterator](){return this}next(){return R(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?Mt:t.value===-1&&(t=yield this.readMetadataLength()).done?Mt:(t=yield this.readMetadata(t.value)).done?Mt:t})}throw(t){return R(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return R(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return R(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(oc(t));return e.value})}readMessageBody(t){return R(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=tt(yield this.source.read(t));if(e.byteLength<t)throw new Error(Wu(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return R(this,arguments,void 0,function*(t=!1){let e=ht.Schema,n=yield this.readMessage(e),i=n==null?void 0:n.header();if(t&&!i)throw new Error(ac(e));return i})}readMetadataLength(){return R(this,void 0,void 0,function*(){let t=yield this.source.read(Ho),e=t&&new me(t),n=(e==null?void 0:e.readInt32(0))||0;return{done:n===0,value:n}})}readMetadata(t){return R(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return Mt;if(e.byteLength<t)throw new Error(ju(t,e.byteLength));return{done:!1,value:de.decode(e)}})}},as=class extends Qn{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Ui?t:new Ui(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:de.fromJSON(t.schema,ht.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:de.fromJSON(e,ht.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:de.fromJSON(e,ht.RecordBatch)}}return this._body=[],Mt}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(oc(t));return e.value}readSchema(){let t=ht.Schema,e=this.readMessage(t),n=e==null?void 0:e.header();if(!e||!n)throw new Error(ac(t));return n}},Ho=4,sc="ARROW1",ti=new Uint8Array(sc.length);for(let r=0;r<sc.length;r+=1)ti[r]=sc.codePointAt(r);function zo(r,t=0){for(let e=-1,n=ti.length;++e<n;)if(ti[e]!==r[t+e])return!1;return!0}var ei=ti.length,cc=ei+Ho,$u=ei*2+Ho;var te=class r extends pn{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 Ue(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 Xt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Xt.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:_s(t)?Oy(t):gs(t)?Ry(t):Ue(t)?R(this,void 0,void 0,function*(){return yield r.from(yield t)}):ws(t)||di(t)||Ss(t)||ve(t)?My(new Be(t)):Uy(new or(t))}static readAll(t){return t instanceof r?t.isSync()?Yu(t):Gu(t):_s(t)||ArrayBuffer.isView(t)||Me(t)||bs(t)?Yu(t):Gu(t)}},cr=class extends te{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return he(this,arguments,function*(){yield lt(yield*sn(Un(Oe(this[Symbol.iterator]()))))})}},Zr=class extends te{constructor(t){super(t),this._impl=t}readAll(){return R(this,void 0,void 0,function*(){var t,e,n,i;let s=new Array;try{for(var o=!0,c=Oe(this),l;l=yield c.next(),t=l.done,!t;o=!0){i=l.value,o=!1;let f=i;s.push(f)}}catch(f){e={error:f}}finally{try{!o&&!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]()}},Qr=class extends cr{constructor(t){super(t),this._impl=t}},cs=class extends Zr{constructor(t){super(t),this._impl=t}},jo=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=ot({type:new Ut(this.schema.fields),length:t.length,children:n});return new Ht(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:o}=this,c=s.get(n),l=o.dictionaries.get(n),f=this._loadVectors(t.data,e,[l]);return(c&&i?c.concat(new pt(f)):new pt(f)).memoize()}_loadVectors(t,e,n){return new Ni(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},ri=class extends jo{constructor(t,e){super(e),this._reader=_s(t)?new as(this._handle=t):new Qn(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=qu(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):Mt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):Mt}next(){if(this.closed)return Mt;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 vn(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},ni=class extends jo{constructor(t,e){super(e),this._reader=new os(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return R(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 R(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=qu(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return R(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):Mt})}return(t){return R(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):Mt})}next(){return R(this,void 0,void 0,function*(){if(this.closed)return Mt;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 vn(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return R(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Wo=class extends ri{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 Mi?t:new Mi(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(ht.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}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(ht.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),c=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,c)}}}_readFooter(){let{_handle:t}=this,e=t.size-cc,n=t.readInt32(e),i=t.readAt(e-n,n);return Ar.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}},lc=class extends ni{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 Xr?t:new Xr(t,n),i)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return R(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 R(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(ht.RecordBatch);if(i!=null&&i.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return R(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(ht.DictionaryBatch);if(i!=null&&i.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),c=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,c)}}})}_readFooter(){return R(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-cc,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return Ar.decode(i)})}_readNextMessageAndValidate(t){return R(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})}},uc=class extends ri{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new mo(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function qu(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Yu(r){let t=te.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Gu(r){return he(this,arguments,function*(){let e=yield lt(te.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 Oy(r){return new cr(new uc(r))}function Uy(r){let t=r.peek(ei+7&-8);return t&&t.byteLength>=4?zo(t)?new Qr(new Wo(r.read())):new cr(new ri(r)):new cr(new ri(function*(){}()))}function My(r){return R(this,void 0,void 0,function*(){let t=yield r.peek(ei+7&-8);return t&&t.byteLength>=4?zo(t)?new Qr(new Wo(yield r.read())):new Zr(new ni(r)):new Zr(new ni(function(){return he(this,arguments,function*(){})}()))})}function Ry(r){return R(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Xr(r,t);return t>=$u&&zo(yield e.readAt(0,ei+7&-8))?new cs(new lc(e)):new Zr(new ni(e))})}var Nt=class r extends W{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof Ht?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 pt)return this.visitMany(t.data),this;let{type:e}=t;if(!L.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(L.isUnion(e))this.nodes.push(new Ae(n,0));else{let{nullCount:i}=t;L.isNull(e)||Ge.call(this,i<=0?new Uint8Array(0):un(t.offset,n,t.nullBitmap)),this.nodes.push(new Ae(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 Ge(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new le(this._byteLength,t)),this._byteLength+=t,this}function Ly(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(Ge.call(this,i),e.mode===xt.Sparse)return dc.call(this,r);if(e.mode===xt.Dense){if(r.offset<=0)return Ge.call(this,s),dc.call(this,r);{let o=new Int32Array(n),c=Object.create(null),l=Object.create(null);for(let f,p,B=-1;++B<n;)(f=i[B])!==void 0&&((p=c[f])===void 0&&(p=c[f]=s[B]),o[B]=s[B]-p,l[f]=((t=l[f])!==null&&t!==void 0?t:0)+1);Ge.call(this,o),this.visitMany(r.children.map((f,p)=>{let B=e.typeIds[p],A=c[B],E=l[B];return f.slice(A,Math.min(n,E))}))}}return this}function Ny(r){let t;return r.nullCount>=r.length?Ge.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?Ge.call(this,un(r.offset,r.length,t)):Ge.call(this,dn(r.values))}function Lr(r){return Ge.call(this,r.values.subarray(0,r.length*r.stride))}function $o(r){let{length:t,values:e,valueOffsets:n}=r,i=yt(n[0]),s=yt(n[t]),o=Math.min(s-i,e.byteLength-i);return Ge.call(this,Ds(-i,t+1,n)),Ge.call(this,e.subarray(i,i+o)),this}function fc(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return Ge.call(this,Ds(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function dc(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}Nt.prototype.visitBool=Ny;Nt.prototype.visitInt=Lr;Nt.prototype.visitFloat=Lr;Nt.prototype.visitUtf8=$o;Nt.prototype.visitLargeUtf8=$o;Nt.prototype.visitBinary=$o;Nt.prototype.visitLargeBinary=$o;Nt.prototype.visitFixedSizeBinary=Lr;Nt.prototype.visitDate=Lr;Nt.prototype.visitTimestamp=Lr;Nt.prototype.visitTime=Lr;Nt.prototype.visitDecimal=Lr;Nt.prototype.visitList=fc;Nt.prototype.visitStruct=dc;Nt.prototype.visitUnion=Ly;Nt.prototype.visitInterval=Lr;Nt.prototype.visitDuration=Lr;Nt.prototype.visitFixedSizeList=fc;Nt.prototype.visitMap=fc;var Sn=class extends pn{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 sr,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,ne(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 Ue(t)?t.then(e=>this.writeAll(e)):ve(t)?pc(this,t):hc(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 sr?this._sink=t:(this._sink=new sr,t&&ul(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&dl(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||!wn(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 oe&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Ht&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!wn(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Ht?t instanceof vn||this._writeRecordBatch(t):t instanceof oe?this.writeAll(t.batches):Me(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=de.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,c=s+o+n&~n,l=c-s-o;return t.headerType===ht.RecordBatch?this._recordBatchBlocks.push(new xr(c,t.bodyLength,this._position)):t.headerType===ht.DictionaryBatch&&this._dictionaryBlocks.push(new xr(c,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(c-o)),s>0&&this._write(i),this._writePadding(l)}_write(t){if(this._started){let e=tt(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(de.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(ti)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=Nt.assemble(t),o=new Qt(t.numRows,n,i),c=de.from(o,e);return this._writeDictionaries(t)._writeMessage(c)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){let{byteLength:i,nodes:s,bufferRegions:o,buffers:c}=Nt.assemble(new pt([t])),l=new Qt(t.length,s,o),f=new ue(l,e,n),p=de.from(f,i);return this._writeMessage(p)._writeBodyBuffers(c)}_writeBodyBuffers(t){let e,n,i;for(let s=-1,o=t.length;++s<o;)(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 o=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],c=this._seenDictionaries.get(i),l=(n=this._dictionaryDeltaOffsets.get(i))!==null&&n!==void 0?n:0;if(!c||c.data[0]!==o[0])for(let[f,p]of o.entries())this._writeDictionaryBatch(p,i,f>0);else if(l<o.length)for(let f of o.slice(l))this._writeDictionaryBatch(f,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,o.length)}return this}},In=class r extends Sn{static writeAll(t,e){let n=new r(e);return Ue(t)?t.then(i=>n.writeAll(i)):ve(t)?pc(n,t):hc(n,t)}},Dn=class r extends Sn{static writeAll(t){let e=new r;return Ue(t)?t.then(n=>e.writeAll(n)):ve(t)?pc(e,t):hc(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=Ar.encode(new Ar(t,vt.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function hc(r,t){let e=t;t instanceof oe&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function pc(r,t){return R(this,void 0,void 0,function*(){var e,n,i,s,o,c,l;try{for(e=!0,n=Oe(t);i=yield n.next(),s=i.done,!s;e=!0){l=i.value,e=!1;let f=l;r.write(f)}}catch(f){o={error:f}}finally{try{!e&&!s&&(c=n.return)&&(yield c.call(n))}finally{if(o)throw o.error}}return r.finish()})}function Ku(r,t){if(ve(r))return Cy(r,t);if(Me(r))return ky(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function ky(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(o){s(o,e||(e=r[Symbol.iterator]()))},pull(o){e?s(o,e):o.close()},cancel(){(e!=null&&e.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,c){let l,f=null,p=o.desiredSize||null;for(;!(f=c.next(n?p:null)).done;)if(ArrayBuffer.isView(f.value)&&(l=tt(f.value))&&(p!=null&&n&&(p=p-l.byteLength+1),f.value=l),o.enqueue(f.value),p!=null&&--p<=0)return;o.close()}}function Cy(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(o){return R(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return R(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return R(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(o,c){return R(this,void 0,void 0,function*(){let l,f=null,p=o.desiredSize||null;for(;!(f=yield c.next(n?p:null)).done;)if(ArrayBuffer.isView(f.value)&&(l=tt(f.value))&&(p!=null&&n&&(p=p-l.byteLength+1),f.value=l),o.enqueue(f.value),p!=null&&--p<=0)return;o.close()})}}function Zu(r){return new mc(r)}var mc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=cl(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=yn(s),this._getSize=i!=="bytes"?Ju:Xu;let{["highWaterMark"]:o=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:l=>{this._maybeFlush(this._builder,this._controller=l)},start:l=>{this._maybeFlush(this._builder,this._controller=l)}},{highWaterMark:o,size:i!=="bytes"?Ju:Xu}),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:l=>this._writeValueAndReturnChunkSize(l)})}_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)}},Ju=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Xu=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function Yo(r,t){let e=new sr,n=null,i=new ReadableStream({cancel(){return R(this,void 0,void 0,function*(){yield e.close()})},start(c){return R(this,void 0,void 0,function*(){yield o(c,n||(n=yield s()))})},pull(c){return R(this,void 0,void 0,function*(){n?yield o(c,n):c.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:i};function s(){return R(this,void 0,void 0,function*(){return yield(yield te.from(e)).open(t)})}function o(c,l){return R(this,void 0,void 0,function*(){let f=c.desiredSize,p=null;for(;!(p=yield l.next()).done;)if(c.enqueue(p.value),f!=null&&--f<=0)return;c.close()})}}function Go(r,t){let e=new this(r),n=new Be(e),i=new ReadableStream({cancel(){return R(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return R(this,void 0,void 0,function*(){yield s(o)})},start(o){return R(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(o){return R(this,void 0,void 0,function*(){let c=null,l=o.desiredSize;for(;c=yield n.read(l||null);)if(o.enqueue(c),l!=null&&(l-=c.byteLength)<=0)return;o.close()})}}function qo(r,t="stream"){return(t==="stream"?In:Dn).writeAll(r).toUint8Array(!0)}var zy=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Aa),Za),ja),xa),wa),za),Ia),{compareSchemas:wn,compareFields:Fu,compareTypes:Au});Xt.toDOMStream=Ku;Rt.throughDOM=Zu;te.throughDOM=Yo;Qr.throughDOM=Yo;cr.throughDOM=Yo;Sn.throughDOM=Go;Dn.throughDOM=Go;In.throughDOM=Go;function ii(r){switch(r.typeId){case h.Binary:return{sqlType:"binary"};case h.Bool:return{sqlType:"bool"};case h.Date:return{sqlType:"date"};case h.DateDay:return{sqlType:"date32[d]"};case h.DateMillisecond:return{sqlType:"date64[ms]"};case h.Decimal:{let t=r;return{sqlType:"decimal",precision:t.precision,scale:t.scale}}case h.Float:return{sqlType:"float"};case h.Float16:return{sqlType:"float16"};case h.Float32:return{sqlType:"float32"};case h.Float64:return{sqlType:"float64"};case h.Int:return{sqlType:"int32"};case h.Int16:return{sqlType:"int16"};case h.Int32:return{sqlType:"int32"};case h.Int64:return{sqlType:"int64"};case h.Uint16:return{sqlType:"uint16"};case h.Uint32:return{sqlType:"uint32"};case h.Uint64:return{sqlType:"uint64"};case h.Uint8:return{sqlType:"uint8"};case h.IntervalDayTime:return{sqlType:"interval[dt]"};case h.IntervalYearMonth:return{sqlType:"interval[m]"};case h.List:return{sqlType:"list",valueType:ii(r.valueType)};case h.FixedSizeBinary:return{sqlType:"fixedsizebinary",byteWidth:r.byteWidth};case h.Null:return{sqlType:"null"};case h.Utf8:return{sqlType:"utf8"};case h.Struct:return{sqlType:"struct",fields:r.children.map(e=>Ko(e.name,e.type))};case h.Map:{let t=r;return{sqlType:"map",keyType:ii(t.keyType),valueType:ii(t.valueType)}}case h.Time:return{sqlType:"time[s]"};case h.TimeMicrosecond:return{sqlType:"time[us]"};case h.TimeMillisecond:return{sqlType:"time[ms]"};case h.TimeNanosecond:return{sqlType:"time[ns]"};case h.TimeSecond:return{sqlType:"time[s]"};case h.Timestamp:return{sqlType:"timestamp",timezone:r.timezone||void 0};case h.TimestampSecond:return{sqlType:"timestamp[s]",timezone:r.timezone||void 0};case h.TimestampMicrosecond:return{sqlType:"timestamp[us]",timezone:r.timezone||void 0};case h.TimestampNanosecond:return{sqlType:"timestamp[ns]",timezone:r.timezone||void 0};case h.TimestampMillisecond:return{sqlType:"timestamp[ms]",timezone:r.timezone||void 0}}throw new Error("unsupported arrow type: ".concat(r.toString()))}function Ko(r,t){let e=ii(t);return e.name=r,e}var Jo=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=te.from(e);return console.assert(n.isSync()),console.assert(n.isFile()),new oe(n)}async send(t,e=!1){let n=this._bindings.startPendingQuery(this._conn,t,e);for(;n==null;)n=await new Promise((o,c)=>{try{o(this._bindings.pollPendingQuery(this._conn))}catch(l){console.log(l),l.message.includes("worker is not set!")?c(new Error("Worker has been terminated")):c(l)}});let i=new Xo(this._bindings,this._conn,n),s=te.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 yc(this._bindings,this._conn,e)}createScalarFunction(t,e,n){this._bindings.createScalarFunction(this._conn,t,e,n)}insertArrowTable(t,e){let n=qo(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)}},Xo=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}},yc=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=te.from(e);return console.assert(n.isSync()),console.assert(n.isFile()),new oe(n)}send(...t){let e=this.bindings.sendPrepared(this.connectionId,this.statementId,t),n=new Xo(this.bindings,this.connectionId,e),i=te.from(n);return console.assert(i.isSync()),console.assert(i.isStream()),i}};function td(r){return r<=255}function ed(r){return r===256}var id=new TextEncoder,rd=new TextDecoder("utf-8");function _c(r,t,e){let n=id.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 gc(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 bc(r,t,e,n){let i=r.HEAPU8.subarray(t,t+n*gc(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 nd(r,t,e){let n=r.HEAPU8.subarray(t,t+e);return new Uint8Array(n.buffer,n.byteOffset,e)}function Zo(r,t,e){let n=r.HEAPU8.subarray(t,t+e*8);return new Float64Array(n.buffer,n.byteOffset,e)}function sd(r,t,e,n,i,s,o,c){try{let l=r._udfFunctions.get(n);if(!l){_c(t,e,"Unknown UDF with id: "+n);return}let f=rd.decode(t.HEAPU8.subarray(i,i+s)),p=JSON.parse(f),B=Zo(t,o,c/8),A=D=>{var x;let N=null;switch(D.validityBuffer!==void 0&&(N=nd(t,B[D.validityBuffer],p.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=bc(t,B[D.dataBuffer],D.physicalType,p.rows),I=[],H=Zo(t,B[D.lengthBuffer],p.rows);for(let Z=0;Z<p.rows;++Z){if(N!=null&&!N[Z]){I.push(null);continue}let T=t.HEAPU8.subarray(j[Z],j[Z]+H[Z]),mt=rd.decode(T);I.push(mt)}return Z=>I[Z]}case"STRUCT":{let j={},I=[];for(let H=0;H<(((x=D.children)==null?void 0:x.length)||0);++H){let Z=D.children[H],T=A(Z);I.push(mt=>{j[Z.name]=T(mt)})}return N!=null?H=>{if(!N[H])return null;for(let Z of I)Z(H);return j}:H=>{for(let Z of I)Z(H);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=bc(t,B[D.dataBuffer],D.physicalType,p.rows);return N!=null?I=>N[I]?j[I]:null:I=>j[I]}}},E=[];for(let D=0;D<p.args.length;++D)E.push(A(p.args[D]));let X=p.rows*gc(p.ret.physicalType),Ft=t._malloc(X),Pt=bc(t,Ft,p.ret.physicalType,p.rows),Lt=t._malloc(p.rows),Bt=nd(t,Lt,p.rows);if(Pt.length==0||Bt.length==0){_c(t,e,"Can't create physical arrays for result");return}let wt=Pt;p.ret.physicalType=="VARCHAR"&&(wt=new Array(p.rows));let qt=[];for(let D=0;D<p.args.length;++D)qt.push(null);for(let D=0;D<p.rows;++D){for(let x=0;x<p.args.length;++x)qt[x]=E[x](D);let N=l.func(...qt);wt[D]=N,Bt[D]=N==null?0:1}let Kt=0;switch(p.ret.physicalType){case"VARCHAR":{let D=new Array(0);Kt=t._malloc(p.rows*gc("DOUBLE"));let N=Zo(t,Kt,p.rows),x=0;for(let Z=0;Z<p.rows;++Z){let T=id.encode(wt[Z]||"");D.push(T),N[Z]=T.length,x+=T.length}let j=t._malloc(x),I=t.HEAPU8.subarray(j,j+x),H=0;for(let Z=0;Z<p.rows;++Z){Pt[Z]=H;let T=D[Z];I.subarray(H,H+T.length).set(T),H+=T.length}}}let w=3*8,M=t._malloc(w),V=Zo(t,M,3);V[0]=Ft,V[1]=Lt,V[2]=Kt,t.HEAPF64[(e>>3)+0]=0,t.HEAPF64[(e>>3)+1]=M,t.HEAPF64[(e>>3)+2]=0}catch(l){_c(t,e,l.toString())}}function Wy(){let r=new TextDecoder;return t=>(typeof SharedArrayBuffer<"u"&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),r.decode(t))}var $y=Wy();function qe(r,t){console.error("FAIL WITH: ".concat(t)),r.ccall("duckdb_web_fail_with",null,["string"],[t])}function Bn(r,t,e){let n=r.HEAPU8.subarray(t,t+e),i=new Uint8Array(new ArrayBuffer(n.byteLength));return i.set(n),i}function ct(r,t,e){return $y(r.HEAPU8.subarray(t,t+e))}function Dt(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 o=r.HEAPF64[(s>>3)+0],c=r.HEAPF64[(s>>3)+1],l=r.HEAPF64[(s>>3)+2];return r.stackRestore(i),[o,c,l]}function Et(r){r.ccall("duckdb_web_clear_response",null,[],[])}var Qo=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 si=new TextEncoder;var ta=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]=Dt(this.mod,"duckdb_web_open",["string"],[JSON.stringify(t)]);if(e!==0)throw new Error(ct(this.mod,n,i));Et(this.mod)}reset(){let[t,e,n]=Dt(this.mod,"duckdb_web_reset",[],[]);if(t!==0)throw new Error(ct(this.mod,e,n));Et(this.mod)}getVersion(){let[t,e,n]=Dt(this.mod,"duckdb_web_get_version",[],[]);if(t!==0)throw new Error(ct(this.mod,e,n));let i=ct(this.mod,e,n);return Et(this.mod),i}getFeatureFlags(){return this.mod.ccall("duckdb_web_get_feature_flags","number",[],[])}tokenize(t){let e=si.encode(t),n=this.mod._malloc(e.length);this.mod.HEAPU8.subarray(n,n+e.length).set(e);let[s,o,c]=Dt(this.mod,"duckdb_web_tokenize_buffer",["number","number"],[n,e.length]);if(this.mod._free(n),s!==0)throw new Error(ct(this.mod,o,c));let l=ct(this.mod,o,c);return Et(this.mod),JSON.parse(l)}connect(){let t=this.mod.ccall("duckdb_web_connect","number",[],[]);return new Jo(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=si.encode(e),i=this.mod._malloc(n.length);this.mod.HEAPU8.subarray(i,i+n.length).set(n);let[o,c,l]=Dt(this.mod,"duckdb_web_query_run_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),o!==0)throw new Error(ct(this.mod,c,l));let f=Bn(this.mod,c,l);return Et(this.mod),f}startPendingQuery(t,e,n=!1){let i=si.encode(e),s=this.mod._malloc(i.length);this.mod.HEAPU8.subarray(s,s+i.length).set(i);let[c,l,f]=Dt(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(ct(this.mod,l,f));if(l==0)return null;let p=Bn(this.mod,l,f);return Et(this.mod),p}pollPendingQuery(t){let[e,n,i]=Dt(this.mod,"duckdb_web_pending_query_poll",["number"],[t]);if(e!==0)throw new Error(ct(this.mod,n,i));if(n==0)return null;let s=Bn(this.mod,n,i);return Et(this.mod),s}cancelPendingQuery(t){return this.mod.ccall("duckdb_web_pending_query_cancel","boolean",["number"],[t])}fetchQueryResults(t){let[e,n,i]=Dt(this.mod,"duckdb_web_query_fetch_results",["number"],[t]);if(ed(e))return Et(this.mod),null;if(!td(e))throw new Error("Unexpected StatusCode from duckdb_web_query_fetch_results ("+e+") and with self reported error as"+ct(this.mod,n,i));if(e!==0)throw new Error(ct(this.mod,n,i));let s=Bn(this.mod,n,i);return Et(this.mod),s}getTableNames(t,e){let n=si.encode(e),i=this.mod._malloc(n.length);this.mod.HEAPU8.subarray(i,i+n.length).set(n);let[o,c,l]=Dt(this.mod,"duckdb_web_get_tablenames_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),o!==0)throw new Error(ct(this.mod,c,l));let f=ct(this.mod,c,l);return Et(this.mod),JSON.parse(f)}createScalarFunction(t,e,n,i){let s={functionId:this._nextUDFId,name:e,returnType:ii(n)},o={functionId:s.functionId,connectionId:t,name:e,returnType:n,func:i};this._nextUDFId+=1;let[c,l,f]=Dt(this.mod,"duckdb_web_udf_scalar_create",["number","string"],[t,JSON.stringify(s)]);if(c!==0)throw new Error(ct(this.mod,l,f));if(Et(this.mod),globalThis.DUCKDB_RUNTIME._udfFunctions=(globalThis.DUCKDB_RUNTIME._udfFunctions||new Map).set(o.functionId,o),this.pthread)for(let p of[...this.pthread.runningWorkers,...this.pthread.unusedWorkers])p.postMessage({cmd:"registerUDFFunction",udf:o})}createPrepared(t,e){let n=si.encode(e),i=this.mod._malloc(n.length);this.mod.HEAPU8.subarray(i,i+n.length).set(n);let[o,c,l]=Dt(this.mod,"duckdb_web_prepared_create_buffer",["number","number","number"],[t,i,n.length]);if(this.mod._free(i),o!==0)throw new Error(ct(this.mod,c,l));return Et(this.mod),c}closePrepared(t,e){let[n,i,s]=Dt(this.mod,"duckdb_web_prepared_close",["number","number"],[t,e]);if(n!==0)throw new Error(ct(this.mod,i,s));Et(this.mod)}runPrepared(t,e,n){let[i,s,o]=Dt(this.mod,"duckdb_web_prepared_run",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(ct(this.mod,s,o));let c=Bn(this.mod,s,o);return Et(this.mod),c}sendPrepared(t,e,n){let[i,s,o]=Dt(this.mod,"duckdb_web_prepared_send",["number","number","string"],[t,e,JSON.stringify(n)]);if(i!==0)throw new Error(ct(this.mod,s,o));let c=Bn(this.mod,s,o);return Et(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 o=n?JSON.stringify(n):"",[c,l,f]=Dt(this.mod,"duckdb_web_insert_arrow_from_ipc_stream",["number","number","number","string"],[t,i,e.length,o]);if(this.mod._free(i),c!==0)throw new Error(ct(this.mod,l,f))}insertCSVFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let f in n.columns)n.columnsFlat.push(Ko(f,n.columns[f]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[o,c,l]=Dt(this.mod,"duckdb_web_insert_csv_from_path",["number","string","string"],[t,e,s]);if(o!==0)throw new Error(ct(this.mod,c,l))}insertJSONFromPath(t,e,n){if(n.columns!==void 0){n.columnsFlat=[];for(let f in n.columns)n.columnsFlat.push(Ko(f,n.columns[f]))}let i={...n};i.columns=i.columnsFlat,delete i.columnsFlat;let s=JSON.stringify(i),[o,c,l]=Dt(this.mod,"duckdb_web_insert_json_from_path",["number","string","string"],[t,e,s]);if(o!==0)throw new Error(ct(this.mod,c,l))}globFiles(t){let[e,n,i]=Dt(this.mod,"duckdb_web_fs_glob_file_infos",["string"],[t]);if(e!==0)throw new Error(ct(this.mod,n,i));let s=ct(this.mod,n,i);Et(this.mod);let o=JSON.parse(s);return o==null?[]:o}registerFileURL(t,e,n,i=!1){e===void 0&&(e=t);let[s,o,c]=Dt(this.mod,"duckdb_web_fs_register_file_url",["string","string"],[t,e,n,i]);if(s!==0)throw new Error(ct(this.mod,o,c));Et(this.mod)}registerFileText(t,e){let n=si.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,o,c]=Dt(this.mod,"duckdb_web_fs_register_file_buffer",["string","number","number"],[t,n,e.length]);if(s!==0)throw new Error(ct(this.mod,o,c));Et(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:o,fromCached:c}=i;!c&&s.getSize()&&await this.registerFileHandleAsync(o,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:o,fromCached:c}=i;!c&&s.getSize()&&await this.registerFileHandleAsync(o,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(o){throw new Error(o.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 l;let[s,o,c]=Dt(this.mod,"duckdb_web_fs_register_file_url",["string","string","number","boolean"],[t,t,n,i]);if(s!==0)throw new Error(ct(this.mod,o,c));if(Et(this.mod),globalThis.DUCKDB_RUNTIME._files=(globalThis.DUCKDB_RUNTIME._files||new Map).set(t,e),(l=globalThis.DUCKDB_RUNTIME._preparedHandles)!=null&&l[t]&&delete globalThis.DUCKDB_RUNTIME._preparedHandles[t],this.pthread){for(let f of this.pthread.runningWorkers)f.postMessage({cmd:"registerFileHandle",fileName:t,fileHandle:e});for(let f of this.pthread.unusedWorkers)f.postMessage({cmd:"dropFileHandle",fileName:t})}}dropFile(t){let[e,n,i]=Dt(this.mod,"duckdb_web_fs_drop_file",["string"],[t]);if(e!==0)throw new Error(ct(this.mod,n,i));Et(this.mod)}dropFiles(t){let e=[],n=-1;try{for(let c of t!=null?t:[])if(c!=null&&c.length>0){let l=this.mod.lengthBytesUTF8(c)+1,f=this.mod._malloc(l);if(!f)throw new Error("Failed to allocate memory for string: ".concat(c));this.mod.stringToUTF8(c,f,l),e.push(f)}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,o]=Dt(this.mod,"duckdb_web_fs_drop_files",["number","number"],[n,e.length]);if(i!==0)throw new Error(ct(this.mod,s,o));Et(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]=Dt(this.mod,"duckdb_web_copy_file_to_path",["string","string"],[t,e]);if(n!==0)throw new Error(ct(this.mod,i,s));Et(this.mod)}copyFileToBuffer(t){let[e,n,i]=Dt(this.mod,"duckdb_web_copy_file_to_buffer",["string"],[t]);if(e!==0)throw new Error(ct(this.mod,n,i));let s=this.mod.HEAPU8.subarray(n,n+i),o=new Uint8Array(s.length);return o.set(s),Et(this.mod),o}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]=Dt(this.mod,"duckdb_web_collect_file_stats",["string","boolean"],[t,e]);if(n!==0)throw new Error(ct(this.mod,i,s))}exportFileStatistics(t){let[e,n,i]=Dt(this.mod,"duckdb_web_export_file_stats",["string"],[t]);if(e!==0)throw new Error(ct(this.mod,n,i));return new Qo(this.mod.HEAPU8.subarray(n,n+i))}};var ea=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 dd=ol(ud());var ra=class extends ta{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 X;let o=new Request(this.mainModuleURL),c=await fetch(o),l=c.headers.get("content-length"),f=l&&parseInt(l,10)||0,p=new Date,B={startedAt:p,updatedAt:p,bytesTotal:f||0,bytesLoaded:0},A={transform(Ft,Pt){B.bytesLoaded+=Ft.byteLength;let Lt=new Date;if(Lt.getTime()-B.updatedAt.getTime()<20){B.updatedAt=Lt,Pt.enqueue(Ft);return}for(let Bt of n)Bt(B);Pt.enqueue(Ft)}},E=new TransformStream(A);return new Response((X=c.body)==null?void 0:X.pipeThrough(E),c)})();WebAssembly.instantiateStreaming(s,t).then(o=>{e(o.instance,o.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,o=new Date,c={startedAt:o,updatedAt:o,bytesTotal:0,bytesLoaded:0};i.open("GET",s),i.responseType="arraybuffer",i.onerror=l=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to load WASM: "+l}),new Error(l.toString())},i.onprogress=l=>{c.bytesTotal=l.total,c.bytesLoaded=l.loaded;let f=new Date;if(f.getTime()-c.updatedAt.getTime()<20){c.updatedAt=f;return}for(let p of n)p(c)},i.onload=()=>{WebAssembly.instantiate(i.response,t).then(l=>{e(l.instance,l.module)}).catch(l=>{throw this.logger.log({timestamp:new Date,level:4,origin:3,topic:5,event:2,value:"Failed to instantiate WASM: "+l}),new Error(l)})},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(l=>{e(l.instance,l.module)})})();return[]}};var na=class extends ra{constructor(t,e,n,i=null){super(t,e,n,i)}instantiateImpl(t){return(0,dd.default)({...t,instantiateWasm:this.instantiateWasm.bind(this),locateFile:this.locateFile.bind(this)})}};var tn=ol(pd()),md=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 Gy(r,t,e){var s,o,c,l;let n=yd(t),i=n.path;if(_d(r)){let f="";if(r!=null&&r.endpoint){let p=new URL(r.endpoint);p.pathname!=="/"&&(f=p.pathname)}i="".concat(f,"/").concat(n.bucket).concat(i)}return{url:i,query:"",host:md(r,t,n.bucket),region:(s=r==null?void 0:r.region)!=null?s:"",service:"s3",method:e,accessKeyId:(o=r==null?void 0:r.accessKeyId)!=null?o:"",secretAccessKey:(c=r==null?void 0:r.secretAccessKey)!=null?c:"",sessionToken:(l=r==null?void 0:r.sessionToken)!=null?l:"",dateNow:new Date().toISOString().replace(/-/g,"").split("T")[0],datetimeNow:new Date().toISOString().replace(/-/g,"").replace(/:/g,"").split(".")[0]+"Z"}}function qy(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 Ky(r,t=null){var X;let e=(X=t==null?void 0:t.contentHash)!=null?X:"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"+qy(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 o=(0,tn.sha256)(s),c="AWS4-HMAC-SHA256\n"+r.datetimeNow+"\n"+r.dateNow+"/"+r.region+"/"+r.service+"/aws4_request\n"+o,l="AWS4"+r.secretAccessKey,f=tn.sha256.hmac.arrayBuffer(l,r.dateNow),p=tn.sha256.hmac.arrayBuffer(f,r.region),B=tn.sha256.hmac.arrayBuffer(p,r.service),A=tn.sha256.hmac.arrayBuffer(B,"aws4_request"),E=tn.sha256.hmac(A,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 Jy=function(r,t,e,n=null,i=null){let s=Gy(r,t,e),o={contentType:n,contentHash:i?tn.sha256.hex(i):null};return Ky(s,o)};function Ke(r,t,e,n,i=null,s=null){(t!=null&&t.accessKeyId||t!=null&&t.sessionToken)&&(Jy(t,e,n,i,s).forEach((c,l)=>{r.setRequestHeader(l,c)}),i&&r.setRequestHeader("content-type",i))}function yd(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 _d(r){var t;return!!((t=r==null?void 0:r.endpoint)!=null&&t.startsWith("http"))}function Je(r,t){let e=yd(t);return _d(r)?"".concat(r==null?void 0:r.endpoint,"/").concat(e.bucket)+e.path:"https://"+md(r,t,e.bucket)+e.path}var Xy=7,bd=/\/|\\/,nt={_files:new Map,_fileInfoCache:new Map,_udfFunctions:new Map,_globalFileInfo:null,_preparedHandles:{},_opfsRoot:null,getFileInfo(r,t){try{let e=nt._fileInfoCache.get(t),[n,i,s]=Dt(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 o=ct(r,i,s);Et(r);try{let c=JSON.parse(o);if(c==null)return null;let l={...c,blob:null};return nt._fileInfoCache.set(t,l),!nt._files.has(l.fileName)&&nt._preparedHandles[l.fileName]&&(nt._files.set(l.fileName,nt._preparedHandles[l.fileName]),delete nt._preparedHandles[l.fileName]),l}catch(c){return console.warn(c),null}}catch(e){return console.log(e),null}},getGlobalFileInfo(r){var t;try{let[e,n,i]=Dt(r,"duckdb_web_get_global_file_info",["number"],[((t=nt._globalFileInfo)==null?void 0:t.cacheEpoch)||0]);if(e!==0)return null;if(i===0)return nt._globalFileInfo;let s=ct(r,n,i);Et(r);let o=JSON.parse(s);return o==null?null:(nt._globalFileInfo={...o,blob:null},nt._globalFileInfo)}catch(e){return console.log(e),null}},async assignOPFSRoot(){nt._opfsRoot||(nt._opfsRoot=await navigator.storage.getDirectory())},async prepareFileHandles(r,t){if(t===3){await nt.assignOPFSRoot();let e=async i=>{if(nt._files.has(i))return{path:i,handle:nt._files.get(i),fromCached:!0};let o=nt._opfsRoot,c=i.slice(Xy),l=c;if(bd.test(c)){let p=c.split(bd);if(p.length===0)throw new Error("Invalid path ".concat(c));if(l=p[p.length-1],!l)throw new Error("Invalid path ".concat(c,". File Not Found."));p.pop();for(let B of p)o=await o.getDirectoryHandle(B,{create:!0})}let f=await o.getFileHandle(l,{create:!1}).catch(p=>{if((p==null?void 0:p.name)==="NotFoundError")return console.debug("File ".concat(i," does not exists yet, creating...")),o.getFileHandle(l,{create:!0});throw p});try{let p=await f.createSyncAccessHandle();return nt._preparedHandles[i]=p,{path:i,handle:p,fromCached:!1}}catch(p){throw new Error(p.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,o,c,l;try{nt._fileInfoCache.delete(t);let f=nt.getFileInfo(r,t);switch(f==null?void 0:f.dataProtocol){case 4:case 5:{if(e&1&&e&2)throw new Error("Opening file ".concat(f.fileName," failed: cannot open file with both read and write flags set"));if(e&32)throw new Error("Opening file ".concat(f.fileName," failed: appending to HTTP/S3 files is not supported"));if(e&2){let A=new XMLHttpRequest;if(f.dataProtocol==5?(A.open("HEAD",Je(f.s3Config,f.dataUrl),!1),Ke(A,f.s3Config,f.dataUrl,"HEAD")):A.open("HEAD",f.dataUrl,!1),A.send(null),A.status!=200&&A.status!=404)throw new Error("Opening file ".concat(f.fileName," failed: Unexpected return status from server (").concat(A.status,")"));if(A.status==404&&!(e&8||e&16))throw new Error("Opening file ".concat(f.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),X=new Uint8Array;r.HEAPU8.set(X,E);let Ft=r._malloc(3*8);return r.HEAPF64[(Ft>>3)+0]=1,r.HEAPF64[(Ft>>3)+1]=E,r.HEAPF64[(Ft>>3)+2]=new Date().getTime()/1e3,Ft}else if(!(e&1))throw new Error("Opening file ".concat(f.fileName," failed: unsupported file flags: ").concat(e));let p=null,B=null;if(!f.forceFullHttpReads&&(f.reliableHeadRequests||!f.allowFullHttpReads))try{let A=new XMLHttpRequest;f.dataProtocol==5?(A.open("HEAD",Je(f.s3Config,f.dataUrl),!1),Ke(A,f.s3Config,f.dataUrl,"HEAD")):A.open("HEAD",f.dataUrl,!1),A.setRequestHeader("Range","bytes=0-"),A.send(null),p=null;try{p=A.getResponseHeader("Content-Length")}catch(E){console.warn("Failed to get Content-Length on request")}if(p!==null&&A.status==206){let E=r._malloc(24);r.HEAPF64[(E>>3)+0]=+p,r.HEAPF64[(E>>3)+1]=0;let X=0;try{X=new Date((n=A.getResponseHeader("Last-Modified"))!=null?n:"").getTime()/1e3}catch(Ft){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(E>>3)+2]=+X,E}}catch(A){B=A,console.warn("HEAD request with range header failed: ".concat(A))}if(f.allowFullHttpReads){if(!f.forceFullHttpReads){let E=new XMLHttpRequest;f.dataProtocol==5?(E.open("GET",Je(f.s3Config,f.dataUrl),!1),Ke(E,f.s3Config,f.dataUrl,"GET")):E.open("GET",f.dataUrl,!1),E.responseType="arraybuffer",E.setRequestHeader("Range","bytes=0-0"),E.send(null);let X=null;try{X=E.getResponseHeader("Content-Length")}catch(Bt){console.warn("Failed to get Content-Length on request")}let Ft=X==null?void 0:X.split("/")[1],Pt=X,Lt=null;if(Ft!==void 0)Lt=Ft;else if(!f.reliableHeadRequests){let Bt=new XMLHttpRequest;f.dataProtocol==5?(Bt.open("HEAD",Je(f.s3Config,f.dataUrl),!1),Ke(Bt,f.s3Config,f.dataUrl,"HEAD")):Bt.open("HEAD",f.dataUrl,!1),Bt.setRequestHeader("Range","bytes=0-"),Bt.send(null),p=null;try{p=Bt.getResponseHeader("Content-Length")}catch(wt){console.warn("Failed to get Content-Length on request")}p!==null&&+p>1&&(Lt=p)}if(E.status==206&&Pt!==null&&+Pt==1&&Lt!==null){let Bt=r._malloc(24);r.HEAPF64[(Bt>>3)+0]=+Lt,r.HEAPF64[(Bt>>3)+1]=0;let wt=0;try{wt=new Date((i=E.getResponseHeader("Last-Modified"))!=null?i:"").getTime()/1e3}catch(qt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(Bt>>3)+2]=+wt,Bt}if(E.status==200&&Pt!==null&&p!==null&&+Pt==+p){console.warn("fall back to full HTTP read for: ".concat(f.dataUrl));let Bt=r._malloc(E.response.byteLength),wt=new Uint8Array(E.response,0,E.response.byteLength);r.HEAPU8.set(wt,Bt);let qt=r._malloc(3*8);r.HEAPF64[(qt>>3)+0]=E.response.byteLength,r.HEAPF64[(qt>>3)+1]=Bt;let Kt=0;try{Kt=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[(qt>>3)+2]=+Kt,qt}console.warn("falling back to full HTTP read for: ".concat(f.dataUrl))}let A=new XMLHttpRequest;if(f.dataProtocol==5?(A.open("GET",Je(f.s3Config,f.dataUrl),!1),Ke(A,f.s3Config,f.dataUrl,"GET")):A.open("GET",f.dataUrl,!1),A.responseType="arraybuffer",A.send(null),A.status==200){let E=r._malloc(A.response.byteLength),X=new Uint8Array(A.response,0,A.response.byteLength);r.HEAPU8.set(X,E);let Ft=r._malloc(3*8);r.HEAPF64[(Ft>>3)+0]=A.response.byteLength,r.HEAPF64[(Ft>>3)+1]=E;let Pt=0;try{Pt=new Date((o=A.getResponseHeader("Last-Modified"))!=null?o:"").getTime()/1e3}catch(Lt){console.warn("Failed to get Last-Modified on request")}return r.HEAPF64[(Ft>>3)+2]=+Pt,Ft}}if(B!=null)throw new Error("Reading file ".concat(f.fileName," failed with error: ").concat(B));return 0}case 2:{let p=(c=nt._files)==null?void 0:c.get(f.fileName);if(p){let E=r._malloc(24);return r.HEAPF64[(E>>3)+0]=p.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(f.fileName));let B=r._malloc(3*8),A=r._malloc(1);return r.HEAPF64[(B>>3)+0]=1,r.HEAPF64[(B>>3)+1]=A,r.HEAPF64[(B>>3)+2]=0,B}case 3:{let p=(l=nt._files)==null?void 0:l.get(f.fileName);if(!p)throw new Error("No OPFS access handle registered with name: ".concat(f.fileName));e&16&&p.truncate(0);let B=r._malloc(3*8),A=p.getSize();return r.HEAPF64[(B>>3)+0]=A,r.HEAPF64[(B>>3)+1]=0,r.HEAPF64[(B>>3)+2]=0,B}}}catch(f){console.error(f.toString()),qe(r,f.toString())}return 0},glob:(r,t,e)=>{var n;try{let i=ct(r,t,e);if(i.startsWith("http")||i.startsWith("s3://")){let s=new XMLHttpRequest;if(i.startsWith("s3://")){let o=nt.getGlobalFileInfo(r);s.open("HEAD",Je(o==null?void 0:o.s3Config,i),!1),Ke(s,o==null?void 0:o.s3Config,i,"HEAD")}else s.open("HEAD",i,!1);if(s.send(null),s.status!=200&&s.status!==206){if(!((n=nt.getGlobalFileInfo(r))!=null&&n.allowFullHttpReads))return console.log("HEAD request failed: ".concat(i,", with full http reads are disabled")),0;let o=new XMLHttpRequest;if(i.startsWith("s3://")){let l=nt.getGlobalFileInfo(r);o.open("GET",Je(l==null?void 0:l.s3Config,i),!1),Ke(o,l==null?void 0:l.s3Config,i,"HEAD")}else o.open("GET",i,!1);if(o.setRequestHeader("Range","bytes=0-0"),o.send(null),o.status!=200&&o.status!==206)return console.log("HEAD and GET requests failed: ".concat(i)),0;let c=null;try{c=o.getResponseHeader("Content-Length")}catch(l){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(o.status,' "').concat(o.statusText,'"'))}r.ccall("duckdb_web_fs_glob_add_path",null,["string"],[i])}else for(let[s]of nt._files.entries()||[])s.startsWith(i)&&r.ccall("duckdb_web_fs_glob_add_path",null,["string"],[s])}catch(i){return console.log(i),qe(r,i.toString()),0}},checkFile:(r,t,e)=>{try{let n=ct(r,t,e);if(n.startsWith("http")||n.startsWith("s3://")){let i=new XMLHttpRequest;if(n.startsWith("s3://")){let s=nt.getGlobalFileInfo(r);i.open("HEAD",Je(s==null?void 0:s.s3Config,n),!1),Ke(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 nt._files.has(n)}catch(n){return console.log(n),!1}return!1},syncFile:(r,t)=>{},closeFile:(r,t)=>{var n;let e=nt.getFileInfo(r,t);nt._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=nt._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),qe(r,i.toString())}},dropFile:(r,t,e)=>{var s;let n=ct(r,t,e),i=(s=nt._files)==null?void 0:s.get(n);if(i){if(nt._files.delete(n),i instanceof FileSystemSyncAccessHandle)try{i.flush(),i.close()}catch(o){throw new Error("Cannot drop file with name: ".concat(n))}i instanceof Blob}},truncateFile:(r,t,e)=>{var i;let n=nt.getFileInfo(r,t);switch(n==null?void 0:n.dataProtocol){case 4:qe(r,"Cannot truncate a http file");return;case 5:qe(r,"Cannot truncate an s3 file");return;case 0:case 1:case 2:qe(r,"truncateFile not implemented");return;case 3:{let s=(i=nt._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 o=nt.getFileInfo(r,t);switch(o==null?void 0:o.dataProtocol){case 4:case 5:{if(!o.dataUrl)throw new Error("Missing data URL for file ".concat(t));try{let c=new XMLHttpRequest;if(o.dataProtocol==5?(c.open("GET",Je(o==null?void 0:o.s3Config,o.dataUrl),!1),Ke(c,o==null?void 0:o.s3Config,o.dataUrl,"GET")):c.open("GET",o.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 l=new Uint8Array(c.response,0,Math.min(c.response.byteLength,n));return r.HEAPU8.set(l,e),l.byteLength}else if(c.status==200){console.warn("Range request for ".concat(o.dataUrl," did not return a partial response: ").concat(c.status,' "').concat(c.statusText,'"'));let l=new Uint8Array(c.response,i,Math.min(c.response.byteLength-i,n));return r.HEAPU8.set(l,e),l.byteLength}else throw new Error("Range request for ".concat(o.dataUrl," did returned non-success status: ").concat(c.status,' "').concat(c.statusText,'"'))}catch(c){throw console.log(c),new Error("Range request for ".concat(o.dataUrl," failed with error: ").concat(c,'"'))}}case 2:{let c=(s=nt._files)==null?void 0:s.get(o.fileName);if(!c)throw new Error("No HTML5 file registered with name: ".concat(o.fileName));let l=c.slice(i,i+n),f=new Uint8Array(new FileReaderSync().readAsArrayBuffer(l));return r.HEAPU8.set(f,e),f.byteLength}case 3:{let c=nt._files.get(o.fileName);if(!c)throw new Error("No OPFS access handle registered with name: ".concat(o.fileName));let l=r.HEAPU8.subarray(e,e+n);return c.read(l,{at:i})}}return 0}catch(o){return console.log(o),qe(r,o.toString()),0}},writeFile:(r,t,e,n,i)=>{var o;let s=nt.getFileInfo(r,t);switch(s==null?void 0:s.dataProtocol){case 4:return qe(r,"Cannot write to HTTP file"),0;case 5:{let c=r.HEAPU8.subarray(e,e+n),l=new XMLHttpRequest;return l.open("PUT",Je(s==null?void 0:s.s3Config,s.dataUrl),!1),Ke(l,s==null?void 0:s.s3Config,s.dataUrl,"PUT","",c),l.send(c),l.status!==200?(qe(r,"Failed writing file: HTTP "+l.status),0):n}case 2:return qe(r,"cannot write using the html5 file reader api"),0;case 3:{let c=(o=nt._files)==null?void 0:o.get(s.fileName);if(!c)throw new Error("No OPFS access handle registered with name: ".concat(s.fileName));let l=r.HEAPU8.subarray(e,e+n);return c.write(l,{at:i})}}return 0},getLastFileModificationTime:(r,t)=>{var n;let e=nt.getFileInfo(r,t);switch(e==null?void 0:e.dataProtocol){case 2:{if(!((n=nt._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=ct(r,t,e);return console.log("checkDirectory: ".concat(n)),!1},createDirectory:(r,t,e)=>{let n=ct(r,t,e);console.log("createDirectory: ".concat(n))},removeDirectory:(r,t,e)=>{let n=ct(r,t,e);console.log("removeDirectory: ".concat(n))},listDirectoryEntries:(r,t,e)=>{let n=ct(r,t,e);return console.log("listDirectoryEntries: ".concat(n)),!1},moveFile:(r,t,e,n,i)=>{var l,f;let s=ct(r,t,e),o=ct(r,n,i),c=(l=nt._files)==null?void 0:l.get(s);c!==void 0&&(nt._files.delete(c),nt._files.set(o,c));for(let[p,B]of((f=nt._fileInfoCache)==null?void 0:f.entries())||[])if(B.dataUrl==s){nt._fileInfoCache.delete(p);break}return!0},removeFile:(r,t,e)=>{},callScalarUDF:(r,t,e,n,i,s,o)=>{sd(nt,r,t,e,n,i,s,o)}};var vc=class extends ea{postMessage(t,e){globalThis.postMessage(t,e)}async instantiate(t,e,n){return await new na(this,nt,t,e).instantiate(n)}};function gd(){let r=new vc;globalThis.onmessage=async t=>{await r.onMessage(t.data)}}gd();return Sp(Zy);})();
15
2
  /*! Bundled license information:
16
3
 
17
4
  js-sha256/src/sha256.js: