@knockdata/objectexplorer 0.3.15 → 0.3.16
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.
- package/app/assets/WorkerParser.js +144 -152
- package/app/assets/browser.js +2 -0
- package/app/assets/duckdb.js +1 -0
- package/app/assets/entries.js +8 -0
- package/app/assets/esm.js +1 -1
- package/app/assets/index.css +1 -1
- package/app/assets/index.js +164 -114
- package/app/assets/node.js +1 -0
- package/app/assets/search-worker.js +3 -3
- package/app/assets/sqlite-2.js +1 -0
- package/app/assets/sqlite.js +1 -0
- package/app/assets/wasm-worker.js +3 -3
- package/demo/cars.sas7bdat +0 -0
- package/package.json +5 -1
- package/server/WebServer.mjs +332 -313
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./entries.js";function t(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function n(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function r(e){return this instanceof r?(this.v=e,this):new r(e)}function i(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var i=n.apply(e,t||[]),a,o=[];return a=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),c(`next`),c(`throw`),c(`return`,s),a[Symbol.asyncIterator]=function(){return this},a;function s(e){return function(t){return Promise.resolve(t).then(e,te)}}function c(e,t){i[e]&&(a[e]=function(t){return new Promise(function(n,r){o.push([e,t,n,r])>1||l(e,t)})},t&&(a[e]=t(a[e])))}function l(e,t){try{u(i[e](t))}catch(e){d(o[0][3],e)}}function u(e){e.value instanceof r?Promise.resolve(e.value.v).then(ee,te):d(o[0][2],e)}function ee(e){l(`next`,e)}function te(e){l(`throw`,e)}function d(e,t){e(t),o.shift(),o.length&&l(o[0][0],o[0][1])}}function a(e){var t,n;return t={},i(`next`),i(`throw`,function(e){throw e}),i(`return`),t[Symbol.iterator]=function(){return this},t;function i(i,a){t[i]=e[i]?function(t){return(n=!n)?{value:r(e[i](t)),done:!1}:a?a(t):t}:a}}function o(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof n==`function`?n(e):e[Symbol.iterator](),r={},i(`next`),i(`throw`),i(`return`),r[Symbol.asyncIterator]=function(){return this},r);function i(t){r[t]=e[t]&&function(n){return new Promise(function(r,i){n=e[t](n),a(r,i,n.done,n.value)})}}function a(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}const s=new TextDecoder(`utf-8`),c=e=>s.decode(e),l=new TextEncoder,u=e=>l.encode(e),ee=e=>typeof e==`number`,te=e=>typeof e==`boolean`,d=e=>typeof e==`function`,f=e=>e!=null&&Object(e)===e,ne=e=>f(e)&&d(e.then),re=e=>f(e)&&d(e[Symbol.iterator]),ie=e=>f(e)&&d(e[Symbol.asyncIterator]),ae=e=>f(e)&&f(e.schema),oe=e=>f(e)&&`done`in e&&`value`in e,se=e=>f(e)&&d(e.stat)&&ee(e.fd),ce=e=>f(e)&&de(e.body),le=e=>`_getDOMStream`in e&&`_getNodeStream`in e,ue=e=>f(e)&&d(e.abort)&&d(e.getWriter)&&!le(e),de=e=>f(e)&&d(e.cancel)&&d(e.getReader)&&!le(e),fe=e=>f(e)&&d(e.end)&&d(e.write)&&te(e.writable)&&!le(e),pe=e=>f(e)&&d(e.read)&&d(e.pipe)&&te(e.readable)&&!le(e),me=e=>f(e)&&d(e.clear)&&d(e.bytes)&&d(e.position)&&d(e.setPosition)&&d(e.capacity)&&d(e.getBufferIdentifier)&&d(e.createLong),he=typeof SharedArrayBuffer<`u`?SharedArrayBuffer:ArrayBuffer;function ge(e){let t=e[0]?[e[0]]:[],n,r,i,a;for(let o,s,c=0,l=0,u=e.length;++c<u;){if(o=t[l],s=e[c],!o||!s||o.buffer!==s.buffer||s.byteOffset<o.byteOffset){s&&(t[++l]=s);continue}if({byteOffset:n,byteLength:i}=o,{byteOffset:r,byteLength:a}=s,n+i<r||r+a<n){s&&(t[++l]=s);continue}t[l]=new Uint8Array(o.buffer,n,r-n+a)}return t}function _e(e,t,n=0,r=t.byteLength){let i=e.byteLength,a=new Uint8Array(e.buffer,e.byteOffset,i),o=new Uint8Array(t.buffer,t.byteOffset,Math.min(r,i));return a.set(o,n),e}function ve(e,t){let n=ge(e),r=n.reduce((e,t)=>e+t.byteLength,0),i,a,o,s=0,c=-1,l=Math.min(t||1/0,r);for(let e=n.length;++c<e;){if(i=n[c],a=i.subarray(0,Math.min(i.length,l-s)),l<=s+a.length){a.length<i.length?n[c]=i.subarray(a.length):a.length===i.length&&c++,o?_e(o,a,s):o=a;break}_e(o||=new Uint8Array(l),a,s),s+=a.length}return[o||new Uint8Array,n.slice(c),r-(o?o.byteLength:0)]}function p(e,t){let n=oe(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n==`string`&&(n=u(n)),n instanceof ArrayBuffer||n instanceof he?new e(n):me(n)?p(e,n.bytes()):ArrayBuffer.isView(n)?n.byteLength<=0?new e(0):new e(n.buffer,n.byteOffset,n.byteLength/e.BYTES_PER_ELEMENT):e.from(n)):new e(0)}const ye=e=>p(Int32Array,e),be=e=>p(BigInt64Array,e),m=e=>p(Uint8Array,e),xe=e=>(e.next(),e);function*Se(e,t){let n=function*(e){yield e},r=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof he?n(t):re(t)?t:n(t);return yield*xe((function*(t){let n=null;do n=t.next(yield p(e,n));while(!n.done)})(r[Symbol.iterator]())),new e}const Ce=e=>Se(Uint8Array,e);function we(e,t){return i(this,arguments,function*(){if(ne(t))return yield r(yield r(yield*a(o(we(e,yield r(t))))));let n=function(e){return i(this,arguments,function*(){yield yield r(yield r(e))})},s=typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof he?n(t):re(t)?function(e){return i(this,arguments,function*(){yield r(yield*a(o(xe((function*(e){let t=null;do t=e.next(yield t?.value);while(!t.done)})(e[Symbol.iterator]())))))})}(t):ie(t)?t:n(t);return yield r(yield*a(o(xe((function(t){return i(this,arguments,function*(){let n=null;do n=yield r(t.next(yield yield r(p(e,n))));while(!n.done)})})(s[Symbol.asyncIterator]()))))),yield r(new e)})}const Te=e=>we(Uint8Array,e);function Ee(e,t,n){if(e!==0){n=n.slice(0,t);for(let t=-1,r=n.length;++t<r;)n[t]+=e}return n.subarray(0,t)}function De(e,t){let n=0,r=e.length;if(r!==t.length)return!1;if(r>0)do if(e[n]!==t[n])return!1;while(++n<r);return!0}var Oe={fromIterable(e){return ke(Ae(e))},fromAsyncIterable(e){return ke(je(e))},fromDOMStream(e){return ke(Me(e))},fromNodeStream(e){return ke(Fe(e))},toDOMStream(e,t){throw Error(`"toDOMStream" not available in this environment`)},toNodeStream(e,t){throw Error(`"toNodeStream" not available in this environment`)}};const ke=e=>(e.next(),e);function*Ae(e){let t,n=!1,r=[],i,a,o,s=0;function c(){return a===`peek`?ve(r,o)[0]:([i,r,s]=ve(r,o),i)}({cmd:a,size:o}=(yield null)||{cmd:`read`,size:0});let l=Ce(e)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-s)?l.next():l.next(o-s),!t&&i.byteLength>0&&(r.push(i),s+=i.byteLength),t||o<=s)do({cmd:a,size:o}=yield c());while(o<s);while(!t)}catch(e){(n=!0)&&typeof l.throw==`function`&&l.throw(e)}finally{n===!1&&typeof l.return==`function`&&l.return(null)}return null}function je(e){return i(this,arguments,function*(){let t,n=!1,i=[],a,o,s,c=0;function l(){return o===`peek`?ve(i,s)[0]:([a,i,c]=ve(i,s),a)}({cmd:o,size:s}=(yield yield r(null))||{cmd:`read`,size:0});let u=Te(e)[Symbol.asyncIterator]();try{do if({done:t,value:a}=Number.isNaN(s-c)?yield r(u.next()):yield r(u.next(s-c)),!t&&a.byteLength>0&&(i.push(a),c+=a.byteLength),t||s<=c)do({cmd:o,size:s}=yield yield r(l()));while(s<c);while(!t)}catch(e){(n=!0)&&typeof u.throw==`function`&&(yield r(u.throw(e)))}finally{n===!1&&typeof u.return==`function`&&(yield r(u.return(new Uint8Array)))}return yield r(null)})}function Me(e){return i(this,arguments,function*(){let t=!1,n=!1,i=[],a,o,s,c=0;function l(){return o===`peek`?ve(i,s)[0]:([a,i,c]=ve(i,s),a)}({cmd:o,size:s}=(yield yield r(null))||{cmd:`read`,size:0});let u=new Ne(e);try{do if({done:t,value:a}=Number.isNaN(s-c)?yield r(u.read()):yield r(u.read(s-c)),!t&&a.byteLength>0&&(i.push(m(a)),c+=a.byteLength),t||s<=c)do({cmd:o,size:s}=yield yield r(l()));while(s<c);while(!t)}catch(e){(n=!0)&&(yield r(u.cancel(e)))}finally{n===!1?yield r(u.cancel()):e.locked&&u.releaseLock()}return yield r(null)})}var Ne=class{constructor(e){this.source=e,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(e){return t(this,void 0,void 0,function*(){let{reader:t,source:n}=this;t&&(yield t.cancel(e).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(e){return t(this,void 0,void 0,function*(){if(e===0)return{done:this.reader==null,value:new Uint8Array};let t=yield this.reader.read();return!t.done&&(t.value=m(t)),t})}};const Pe=(e,t)=>{let n=e=>r([t,e]),r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function Fe(e){return i(this,arguments,function*(){let t=[],n=`error`,i=!1,a=null,o,s,c=0,l=[],u;function ee(){return o===`peek`?ve(l,s)[0]:([u,l,c]=ve(l,s),u)}if({cmd:o,size:s}=(yield yield r(null))||{cmd:`read`,size:0},e.isTTY)return yield yield r(new Uint8Array),yield r(null);try{t[0]=Pe(e,`end`),t[1]=Pe(e,`error`);do{if(t[2]=Pe(e,`readable`),[n,a]=yield r(Promise.race(t.map(e=>e[2]))),n===`error`)break;if((i=n===`end`)||(Number.isFinite(s-c)?(u=m(e.read(s-c)),u.byteLength<s-c&&(u=m(e.read()))):u=m(e.read()),u.byteLength>0&&(l.push(u),c+=u.byteLength)),i||s<=c)do({cmd:o,size:s}=yield yield r(ee()));while(s<c)}while(!i)}finally{yield r(te(t,n===`error`?a:null))}return yield r(null);function te(t,n){return u=l=null,new Promise((r,i)=>{for(let[n,r]of t)e.off(n,r);try{let t=e.destroy;t&&t.call(e,n),n=void 0}catch(e){n=e||n}finally{n==null?r():i(n)}})}})}var h;(function(e){e[e.V1=0]=`V1`,e[e.V2=1]=`V2`,e[e.V3=2]=`V3`,e[e.V4=3]=`V4`,e[e.V5=4]=`V5`})(h||={});var g;(function(e){e[e.Sparse=0]=`Sparse`,e[e.Dense=1]=`Dense`})(g||={});var _;(function(e){e[e.HALF=0]=`HALF`,e[e.SINGLE=1]=`SINGLE`,e[e.DOUBLE=2]=`DOUBLE`})(_||={});var Ie;(function(e){e[e.DAY=0]=`DAY`,e[e.MILLISECOND=1]=`MILLISECOND`})(Ie||={});var v;(function(e){e[e.SECOND=0]=`SECOND`,e[e.MILLISECOND=1]=`MILLISECOND`,e[e.MICROSECOND=2]=`MICROSECOND`,e[e.NANOSECOND=3]=`NANOSECOND`})(v||={});var Le;(function(e){e[e.YEAR_MONTH=0]=`YEAR_MONTH`,e[e.DAY_TIME=1]=`DAY_TIME`,e[e.MONTH_DAY_NANO=2]=`MONTH_DAY_NANO`})(Le||={});const Re=new Int32Array(2),ze=new Float32Array(Re.buffer),Be=new Float64Array(Re.buffer),Ve=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var He;(function(e){e[e.UTF8_BYTES=1]=`UTF8_BYTES`,e[e.UTF16_STRING=2]=`UTF16_STRING`})(He||={});var Ue=class e{constructor(e){this.bytes_=e,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new e(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(e){this.position_=e}capacity(){return this.bytes_.length}readInt8(e){return this.readUint8(e)<<24>>24}readUint8(e){return this.bytes_[e]}readInt16(e){return this.readUint16(e)<<16>>16}readUint16(e){return this.bytes_[e]|this.bytes_[e+1]<<8}readInt32(e){return this.bytes_[e]|this.bytes_[e+1]<<8|this.bytes_[e+2]<<16|this.bytes_[e+3]<<24}readUint32(e){return this.readInt32(e)>>>0}readInt64(e){return BigInt.asIntN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<<BigInt(32)))}readUint64(e){return BigInt.asUintN(64,BigInt(this.readUint32(e))+(BigInt(this.readUint32(e+4))<<BigInt(32)))}readFloat32(e){return Re[0]=this.readInt32(e),ze[0]}readFloat64(e){return Re[+!Ve]=this.readInt32(e),Re[+!!Ve]=this.readInt32(e+4),Be[0]}writeInt8(e,t){this.bytes_[e]=t}writeUint8(e,t){this.bytes_[e]=t}writeInt16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeUint16(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8}writeInt32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeUint32(e,t){this.bytes_[e]=t,this.bytes_[e+1]=t>>8,this.bytes_[e+2]=t>>16,this.bytes_[e+3]=t>>24}writeInt64(e,t){this.writeInt32(e,Number(BigInt.asIntN(32,t))),this.writeInt32(e+4,Number(BigInt.asIntN(32,t>>BigInt(32))))}writeUint64(e,t){this.writeUint32(e,Number(BigInt.asUintN(32,t))),this.writeUint32(e+4,Number(BigInt.asUintN(32,t>>BigInt(32))))}writeFloat32(e,t){ze[0]=t,this.writeInt32(e,Re[0])}writeFloat64(e,t){Be[0]=t,this.writeInt32(e,Re[+!Ve]),this.writeInt32(e+4,Re[+!!Ve])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw Error(`FlatBuffers: ByteBuffer is too short to contain an identifier.`);let e=``;for(let t=0;t<4;t++)e+=String.fromCharCode(this.readInt8(this.position_+4+t));return e}__offset(e,t){let n=e-this.readInt32(e);return t<this.readInt16(n)?this.readInt16(n+t):0}__union(e,t){return e.bb_pos=t+this.readInt32(t),e.bb=this,e}__string(e,t){e+=this.readInt32(e);let n=this.readInt32(e);e+=4;let r=this.bytes_.subarray(e,e+n);return t===He.UTF8_BYTES?r:this.text_decoder_.decode(r)}__union_with_string(e,t){return typeof e==`string`?this.__string(t):this.__union(e,t)}__indirect(e){return e+this.readInt32(e)}__vector(e){return e+this.readInt32(e)+4}__vector_len(e){return this.readInt32(e+this.readInt32(e))}__has_identifier(e){if(e.length!=4)throw Error(`FlatBuffers: file identifier must be length 4`);for(let t=0;t<4;t++)if(e.charCodeAt(t)!=this.readInt8(this.position()+4+t))return!1;return!0}createScalarList(e,t){let n=[];for(let r=0;r<t;++r){let t=e(r);t!==null&&n.push(t)}return n}createObjList(e,t){let n=[];for(let r=0;r<t;++r){let t=e(r);t!==null&&n.push(t.unpack())}return n}},We=class e{constructor(e){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 t;t=e||1024,this.bb=Ue.allocate(t),this.space=t}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(e){this.force_defaults=e}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,n){t>this.minalign&&(this.minalign=t);let r=~(this.bb.capacity()-this.space+n)+1&t-1;for(;this.space<r+t+n;){let t=this.bb.capacity();this.bb=e.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(r)}pad(e){for(let t=0;t<e;t++)this.bb.writeInt8(--this.space,0)}writeInt8(e){this.bb.writeInt8(--this.space,e)}writeInt16(e){this.bb.writeInt16(this.space-=2,e)}writeInt32(e){this.bb.writeInt32(this.space-=4,e)}writeInt64(e){this.bb.writeInt64(this.space-=8,e)}writeFloat32(e){this.bb.writeFloat32(this.space-=4,e)}writeFloat64(e){this.bb.writeFloat64(this.space-=8,e)}addInt8(e){this.prep(1,0),this.writeInt8(e)}addInt16(e){this.prep(2,0),this.writeInt16(e)}addInt32(e){this.prep(4,0),this.writeInt32(e)}addInt64(e){this.prep(8,0),this.writeInt64(e)}addFloat32(e){this.prep(4,0),this.writeFloat32(e)}addFloat64(e){this.prep(8,0),this.writeFloat64(e)}addFieldInt8(e,t,n){(this.force_defaults||t!=n)&&(this.addInt8(t),this.slot(e))}addFieldInt16(e,t,n){(this.force_defaults||t!=n)&&(this.addInt16(t),this.slot(e))}addFieldInt32(e,t,n){(this.force_defaults||t!=n)&&(this.addInt32(t),this.slot(e))}addFieldInt64(e,t,n){(this.force_defaults||t!==n)&&(this.addInt64(t),this.slot(e))}addFieldFloat32(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat32(t),this.slot(e))}addFieldFloat64(e,t,n){(this.force_defaults||t!=n)&&(this.addFloat64(t),this.slot(e))}addFieldOffset(e,t,n){(this.force_defaults||t!=n)&&(this.addOffset(t),this.slot(e))}addFieldStruct(e,t,n){t!=n&&(this.nested(t),this.slot(e))}nested(e){if(e!=this.offset())throw TypeError(`FlatBuffers: struct must be serialized inline.`)}notNested(){if(this.isNested)throw TypeError(`FlatBuffers: object serialization must not be nested.`)}slot(e){this.vtable!==null&&(this.vtable[e]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(e){let t=e.capacity();if(t&3221225472)throw Error(`FlatBuffers: cannot grow buffer beyond 2 gigabytes.`);let n=t<<1,r=Ue.allocate(n);return r.setPosition(n-t),r.bytes().set(e.bytes(),n-t),r}addOffset(e){this.prep(4,0),this.writeInt32(this.offset()-e+4)}startObject(e){this.notNested(),this.vtable??=[],this.vtable_in_use=e;for(let t=0;t<e;t++)this.vtable[t]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw Error(`FlatBuffers: endObject called without startObject`);this.addInt32(0);let e=this.offset(),t=this.vtable_in_use-1;for(;t>=0&&this.vtable[t]==0;t--);let n=t+1;for(;t>=0;t--)this.addInt16(this.vtable[t]==0?0:e-this.vtable[t]);this.addInt16(e-this.object_start);let r=(n+2)*2;this.addInt16(r);let i=0,a=this.space;outer_loop:for(t=0;t<this.vtables.length;t++){let e=this.bb.capacity()-this.vtables[t];if(r==this.bb.readInt16(e)){for(let t=2;t<r;t+=2)if(this.bb.readInt16(a+t)!=this.bb.readInt16(e+t))continue outer_loop;i=this.vtables[t];break}}return i?(this.space=this.bb.capacity()-e,this.bb.writeInt32(this.space,i-e)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-e,this.offset()-e)),this.isNested=!1,e}finish(e,t,n){let r=n?4:0;if(t){let e=t;if(this.prep(this.minalign,8+r),e.length!=4)throw TypeError(`FlatBuffers: file identifier must be length 4`);for(let t=3;t>=0;t--)this.writeInt8(e.charCodeAt(t))}this.prep(this.minalign,4+r),this.addOffset(e),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(e,t){this.finish(e,t,!0)}requiredField(e,t){let n=this.bb.capacity()-e,r=n-this.bb.readInt32(n);if(!(t<this.bb.readInt16(r)&&this.bb.readInt16(r+t)!=0))throw TypeError(`FlatBuffers: field `+t+` must be set`)}startVector(e,t,n){this.notNested(),this.vector_num_elems=t,this.prep(4,e*t),this.prep(n,e*t)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(e){if(!e)return 0;if(this.string_maps||=new Map,this.string_maps.has(e))return this.string_maps.get(e);let t=this.createString(e);return this.string_maps.set(e,t),t}createString(e){if(e==null)return 0;let t;return t=e instanceof Uint8Array?e:this.text_encoder.encode(e),this.addInt8(0),this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector()}createByteVector(e){return e==null?0:(this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector())}createObjectOffset(e){return e===null?0:typeof e==`string`?this.createString(e):e.pack(this)}createObjectOffsetList(e){let t=[];for(let n=0;n<e.length;++n){let r=e[n];if(r!==null)t.push(this.createObjectOffset(r));else throw TypeError(`FlatBuffers: Argument for createObjectOffsetList cannot contain null.`)}return t}createStructOffsetList(e,t){return t(this,e.length),this.createObjectOffsetList(e.slice().reverse()),this.endVector()}},Ge;(function(e){e[e.BUFFER=0]=`BUFFER`})(Ge||={});var Ke;(function(e){e[e.LZ4_FRAME=0]=`LZ4_FRAME`,e[e.ZSTD=1]=`ZSTD`})(Ke||={});var qe=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsBodyCompression(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}codec(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt8(this.bb_pos+e):Ke.LZ4_FRAME}method(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt8(this.bb_pos+e):Ge.BUFFER}static startBodyCompression(e){e.startObject(2)}static addCodec(e,t){e.addFieldInt8(0,t,Ke.LZ4_FRAME)}static addMethod(e,t){e.addFieldInt8(1,t,Ge.BUFFER)}static endBodyCompression(e){return e.endObject()}static createBodyCompression(t,n,r){return e.startBodyCompression(t),e.addCodec(t,n),e.addMethod(t,r),e.endBodyCompression(t)}},Je=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(e,t,n){return e.prep(8,16),e.writeInt64(BigInt(n??0)),e.writeInt64(BigInt(t??0)),e.offset()}},Ye=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(e,t,n){return e.prep(8,16),e.writeInt64(BigInt(n??0)),e.writeInt64(BigInt(t??0)),e.offset()}},Xe=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsRecordBatch(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}length(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):BigInt(`0`)}nodes(e,t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new Ye).__init(this.bb.__vector(this.bb_pos+n)+e*16,this.bb):null}nodesLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}buffers(e,t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new Je).__init(this.bb.__vector(this.bb_pos+n)+e*16,this.bb):null}buffersLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}compression(e){let t=this.bb.__offset(this.bb_pos,10);return t?(e||new qe).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}static startRecordBatch(e){e.startObject(4)}static addLength(e,t){e.addFieldInt64(0,t,BigInt(`0`))}static addNodes(e,t){e.addFieldOffset(1,t,0)}static startNodesVector(e,t){e.startVector(16,t,8)}static addBuffers(e,t){e.addFieldOffset(2,t,0)}static startBuffersVector(e,t){e.startVector(16,t,8)}static addCompression(e,t){e.addFieldOffset(3,t,0)}static endRecordBatch(e){return e.endObject()}},Ze=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDictionaryBatch(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}id(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):BigInt(`0`)}data(e){let t=this.bb.__offset(this.bb_pos,6);return t?(e||new Xe).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}isDelta(){let e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startDictionaryBatch(e){e.startObject(3)}static addId(e,t){e.addFieldInt64(0,t,BigInt(`0`))}static addData(e,t){e.addFieldOffset(1,t,0)}static addIsDelta(e,t){e.addFieldInt8(2,+t,0)}static endDictionaryBatch(e){return e.endObject()}},Qe;(function(e){e[e.Little=0]=`Little`,e[e.Big=1]=`Big`})(Qe||={});var $e;(function(e){e[e.DenseArray=0]=`DenseArray`})($e||={});var et=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsInt(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}isSigned(){let e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startInt(e){e.startObject(2)}static addBitWidth(e,t){e.addFieldInt32(0,t,0)}static addIsSigned(e,t){e.addFieldInt8(1,+t,0)}static endInt(e){return e.endObject()}static createInt(t,n,r){return e.startInt(t),e.addBitWidth(t,n),e.addIsSigned(t,r),e.endInt(t)}},tt=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDictionaryEncoding(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}id(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt64(this.bb_pos+e):BigInt(`0`)}indexType(e){let t=this.bb.__offset(this.bb_pos,6);return t?(e||new et).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}isOrdered(){let e=this.bb.__offset(this.bb_pos,8);return e?!!this.bb.readInt8(this.bb_pos+e):!1}dictionaryKind(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt16(this.bb_pos+e):$e.DenseArray}static startDictionaryEncoding(e){e.startObject(4)}static addId(e,t){e.addFieldInt64(0,t,BigInt(`0`))}static addIndexType(e,t){e.addFieldOffset(1,t,0)}static addIsOrdered(e,t){e.addFieldInt8(2,+t,0)}static addDictionaryKind(e,t){e.addFieldInt16(3,t,$e.DenseArray)}static endDictionaryEncoding(e){return e.endObject()}},y=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsKeyValue(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}key(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}value(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}static startKeyValue(e){e.startObject(2)}static addKey(e,t){e.addFieldOffset(0,t,0)}static addValue(e,t){e.addFieldOffset(1,t,0)}static endKeyValue(e){return e.endObject()}static createKeyValue(t,n,r){return e.startKeyValue(t),e.addKey(t,n),e.addValue(t,r),e.endKeyValue(t)}},nt=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsBinary(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(e){e.startObject(0)}static endBinary(e){return e.endObject()}static createBinary(t){return e.startBinary(t),e.endBinary(t)}},rt=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsBool(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startBool(e){e.startObject(0)}static endBool(e){return e.endObject()}static createBool(t){return e.startBool(t),e.endBool(t)}},it=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDate(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}unit(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Ie.MILLISECOND}static startDate(e){e.startObject(1)}static addUnit(e,t){e.addFieldInt16(0,t,Ie.MILLISECOND)}static endDate(e){return e.endObject()}static createDate(t,n){return e.startDate(t),e.addUnit(t,n),e.endDate(t)}},at=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDecimal(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}precision(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}scale(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb_pos+e):0}bitWidth(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readInt32(this.bb_pos+e):128}static startDecimal(e){e.startObject(3)}static addPrecision(e,t){e.addFieldInt32(0,t,0)}static addScale(e,t){e.addFieldInt32(1,t,0)}static addBitWidth(e,t){e.addFieldInt32(2,t,128)}static endDecimal(e){return e.endObject()}static createDecimal(t,n,r,i){return e.startDecimal(t),e.addPrecision(t,n),e.addScale(t,r),e.addBitWidth(t,i),e.endDecimal(t)}},ot=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsDuration(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}unit(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):v.MILLISECOND}static startDuration(e){e.startObject(1)}static addUnit(e,t){e.addFieldInt16(0,t,v.MILLISECOND)}static endDuration(e){return e.endObject()}static createDuration(t,n){return e.startDuration(t),e.addUnit(t,n),e.endDuration(t)}},st=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFixedSizeBinary(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}static startFixedSizeBinary(e){e.startObject(1)}static addByteWidth(e,t){e.addFieldInt32(0,t,0)}static endFixedSizeBinary(e){return e.endObject()}static createFixedSizeBinary(t,n){return e.startFixedSizeBinary(t),e.addByteWidth(t,n),e.endFixedSizeBinary(t)}},ct=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFixedSizeList(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}listSize(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt32(this.bb_pos+e):0}static startFixedSizeList(e){e.startObject(1)}static addListSize(e,t){e.addFieldInt32(0,t,0)}static endFixedSizeList(e){return e.endObject()}static createFixedSizeList(t,n){return e.startFixedSizeList(t),e.addListSize(t,n),e.endFixedSizeList(t)}},lt=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFloatingPoint(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}precision(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):_.HALF}static startFloatingPoint(e){e.startObject(1)}static addPrecision(e,t){e.addFieldInt16(0,t,_.HALF)}static endFloatingPoint(e){return e.endObject()}static createFloatingPoint(t,n){return e.startFloatingPoint(t),e.addPrecision(t,n),e.endFloatingPoint(t)}},ut=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsInterval(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}unit(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Le.YEAR_MONTH}static startInterval(e){e.startObject(1)}static addUnit(e,t){e.addFieldInt16(0,t,Le.YEAR_MONTH)}static endInterval(e){return e.endObject()}static createInterval(t,n){return e.startInterval(t),e.addUnit(t,n),e.endInterval(t)}},dt=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsLargeBinary(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(e){e.startObject(0)}static endLargeBinary(e){return e.endObject()}static createLargeBinary(t){return e.startLargeBinary(t),e.endLargeBinary(t)}},ft=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsLargeUtf8(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(e){e.startObject(0)}static endLargeUtf8(e){return e.endObject()}static createLargeUtf8(t){return e.startLargeUtf8(t),e.endLargeUtf8(t)}},pt=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsList(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startList(e){e.startObject(0)}static endList(e){return e.endObject()}static createList(t){return e.startList(t),e.endList(t)}},mt=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMap(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){let e=this.bb.__offset(this.bb_pos,4);return e?!!this.bb.readInt8(this.bb_pos+e):!1}static startMap(e){e.startObject(1)}static addKeysSorted(e,t){e.addFieldInt8(0,+t,0)}static endMap(e){return e.endObject()}static createMap(t,n){return e.startMap(t),e.addKeysSorted(t,n),e.endMap(t)}},ht=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsNull(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startNull(e){e.startObject(0)}static endNull(e){return e.endObject()}static createNull(t){return e.startNull(t),e.endNull(t)}},gt=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsStruct_(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(e){e.startObject(0)}static endStruct_(e){return e.endObject()}static createStruct_(t){return e.startStruct_(t),e.endStruct_(t)}},_t=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsTime(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}unit(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):v.MILLISECOND}bitWidth(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb_pos+e):32}static startTime(e){e.startObject(2)}static addUnit(e,t){e.addFieldInt16(0,t,v.MILLISECOND)}static addBitWidth(e,t){e.addFieldInt32(1,t,32)}static endTime(e){return e.endObject()}static createTime(t,n,r){return e.startTime(t),e.addUnit(t,n),e.addBitWidth(t,r),e.endTime(t)}},vt=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsTimestamp(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}unit(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):v.SECOND}timezone(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__string(this.bb_pos+t,e):null}static startTimestamp(e){e.startObject(2)}static addUnit(e,t){e.addFieldInt16(0,t,v.SECOND)}static addTimezone(e,t){e.addFieldOffset(1,t,0)}static endTimestamp(e){return e.endObject()}static createTimestamp(t,n,r){return e.startTimestamp(t),e.addUnit(t,n),e.addTimezone(t,r),e.endTimestamp(t)}},yt=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUnion(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}mode(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):g.Sparse}typeIds(e){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb.__vector(this.bb_pos+t)+e*4):0}typeIdsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}typeIdsArray(){let e=this.bb.__offset(this.bb_pos,6);return e?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+e),this.bb.__vector_len(this.bb_pos+e)):null}static startUnion(e){e.startObject(2)}static addMode(e,t){e.addFieldInt16(0,t,g.Sparse)}static addTypeIds(e,t){e.addFieldOffset(1,t,0)}static createTypeIdsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addInt32(t[n]);return e.endVector()}static startTypeIdsVector(e,t){e.startVector(4,t,4)}static endUnion(e){return e.endObject()}static createUnion(t,n,r){return e.startUnion(t),e.addMode(t,n),e.addTypeIds(t,r),e.endUnion(t)}},bt=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsUtf8(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(e){e.startObject(0)}static endUtf8(e){return e.endObject()}static createUtf8(t){return e.startUtf8(t),e.endUtf8(t)}},b;(function(e){e[e.NONE=0]=`NONE`,e[e.Null=1]=`Null`,e[e.Int=2]=`Int`,e[e.FloatingPoint=3]=`FloatingPoint`,e[e.Binary=4]=`Binary`,e[e.Utf8=5]=`Utf8`,e[e.Bool=6]=`Bool`,e[e.Decimal=7]=`Decimal`,e[e.Date=8]=`Date`,e[e.Time=9]=`Time`,e[e.Timestamp=10]=`Timestamp`,e[e.Interval=11]=`Interval`,e[e.List=12]=`List`,e[e.Struct_=13]=`Struct_`,e[e.Union=14]=`Union`,e[e.FixedSizeBinary=15]=`FixedSizeBinary`,e[e.FixedSizeList=16]=`FixedSizeList`,e[e.Map=17]=`Map`,e[e.Duration=18]=`Duration`,e[e.LargeBinary=19]=`LargeBinary`,e[e.LargeUtf8=20]=`LargeUtf8`,e[e.LargeList=21]=`LargeList`,e[e.RunEndEncoded=22]=`RunEndEncoded`})(b||={});var x=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsField(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}name(e){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__string(this.bb_pos+t,e):null}nullable(){let e=this.bb.__offset(this.bb_pos,6);return e?!!this.bb.readInt8(this.bb_pos+e):!1}typeType(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readUint8(this.bb_pos+e):b.NONE}type(e){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__union(e,this.bb_pos+t):null}dictionary(e){let t=this.bb.__offset(this.bb_pos,12);return t?(e||new tt).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}children(t,n){let r=this.bb.__offset(this.bb_pos,14);return r?(n||new e).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+t*4),this.bb):null}childrenLength(){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,16);return n?(t||new y).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,16);return e?this.bb.__vector_len(this.bb_pos+e):0}static startField(e){e.startObject(7)}static addName(e,t){e.addFieldOffset(0,t,0)}static addNullable(e,t){e.addFieldInt8(1,+t,0)}static addTypeType(e,t){e.addFieldInt8(2,t,b.NONE)}static addType(e,t){e.addFieldOffset(3,t,0)}static addDictionary(e,t){e.addFieldOffset(4,t,0)}static addChildren(e,t){e.addFieldOffset(5,t,0)}static createChildrenVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startChildrenVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(6,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endField(e){return e.endObject()}},xt=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsSchema(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}endianness(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):Qe.Little}fields(e,t){let n=this.bb.__offset(this.bb_pos,6);return n?(t||new x).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}fieldsLength(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new y).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}features(e){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb.__vector(this.bb_pos+t)+e*8):BigInt(0)}featuresLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}static startSchema(e){e.startObject(4)}static addEndianness(e,t){e.addFieldInt16(0,t,Qe.Little)}static addFields(e,t){e.addFieldOffset(1,t,0)}static createFieldsVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startFieldsVector(e,t){e.startVector(4,t,4)}static addCustomMetadata(e,t){e.addFieldOffset(2,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static addFeatures(e,t){e.addFieldOffset(3,t,0)}static createFeaturesVector(e,t){e.startVector(8,t.length,8);for(let n=t.length-1;n>=0;n--)e.addInt64(t[n]);return e.endVector()}static startFeaturesVector(e,t){e.startVector(8,t,8)}static endSchema(e){return e.endObject()}static finishSchemaBuffer(e,t){e.finish(t)}static finishSizePrefixedSchemaBuffer(e,t){e.finish(t,void 0,!0)}static createSchema(t,n,r,i,a){return e.startSchema(t),e.addEndianness(t,n),e.addFields(t,r),e.addCustomMetadata(t,i),e.addFeatures(t,a),e.endSchema(t)}},S;(function(e){e[e.NONE=0]=`NONE`,e[e.Schema=1]=`Schema`,e[e.DictionaryBatch=2]=`DictionaryBatch`,e[e.RecordBatch=3]=`RecordBatch`,e[e.Tensor=4]=`Tensor`,e[e.SparseTensor=5]=`SparseTensor`})(S||={});var C;(function(e){e[e.NONE=0]=`NONE`,e[e.Null=1]=`Null`,e[e.Int=2]=`Int`,e[e.Float=3]=`Float`,e[e.Binary=4]=`Binary`,e[e.Utf8=5]=`Utf8`,e[e.Bool=6]=`Bool`,e[e.Decimal=7]=`Decimal`,e[e.Date=8]=`Date`,e[e.Time=9]=`Time`,e[e.Timestamp=10]=`Timestamp`,e[e.Interval=11]=`Interval`,e[e.List=12]=`List`,e[e.Struct=13]=`Struct`,e[e.Union=14]=`Union`,e[e.FixedSizeBinary=15]=`FixedSizeBinary`,e[e.FixedSizeList=16]=`FixedSizeList`,e[e.Map=17]=`Map`,e[e.Duration=18]=`Duration`,e[e.LargeBinary=19]=`LargeBinary`,e[e.LargeUtf8=20]=`LargeUtf8`,e[e.Dictionary=-1]=`Dictionary`,e[e.Int8=-2]=`Int8`,e[e.Int16=-3]=`Int16`,e[e.Int32=-4]=`Int32`,e[e.Int64=-5]=`Int64`,e[e.Uint8=-6]=`Uint8`,e[e.Uint16=-7]=`Uint16`,e[e.Uint32=-8]=`Uint32`,e[e.Uint64=-9]=`Uint64`,e[e.Float16=-10]=`Float16`,e[e.Float32=-11]=`Float32`,e[e.Float64=-12]=`Float64`,e[e.DateDay=-13]=`DateDay`,e[e.DateMillisecond=-14]=`DateMillisecond`,e[e.TimestampSecond=-15]=`TimestampSecond`,e[e.TimestampMillisecond=-16]=`TimestampMillisecond`,e[e.TimestampMicrosecond=-17]=`TimestampMicrosecond`,e[e.TimestampNanosecond=-18]=`TimestampNanosecond`,e[e.TimeSecond=-19]=`TimeSecond`,e[e.TimeMillisecond=-20]=`TimeMillisecond`,e[e.TimeMicrosecond=-21]=`TimeMicrosecond`,e[e.TimeNanosecond=-22]=`TimeNanosecond`,e[e.DenseUnion=-23]=`DenseUnion`,e[e.SparseUnion=-24]=`SparseUnion`,e[e.IntervalDayTime=-25]=`IntervalDayTime`,e[e.IntervalYearMonth=-26]=`IntervalYearMonth`,e[e.DurationSecond=-27]=`DurationSecond`,e[e.DurationMillisecond=-28]=`DurationMillisecond`,e[e.DurationMicrosecond=-29]=`DurationMicrosecond`,e[e.DurationNanosecond=-30]=`DurationNanosecond`})(C||={});var St;(function(e){e[e.OFFSET=0]=`OFFSET`,e[e.DATA=1]=`DATA`,e[e.VALIDITY=2]=`VALIDITY`,e[e.TYPE=3]=`TYPE`})(St||={});function Ct(e){if(e===null)return`null`;if(e===void 0)return`undefined`;switch(typeof e){case`number`:return`${e}`;case`bigint`:return`${e}`;case`string`:return`"${e}"`}return typeof e[Symbol.toPrimitive]==`function`?e[Symbol.toPrimitive](`string`):ArrayBuffer.isView(e)?e instanceof BigInt64Array||e instanceof BigUint64Array?`[${[...e].map(e=>Ct(e))}]`:`[${e}]`:ArrayBuffer.isView(e)?`[${e}]`:JSON.stringify(e,(e,t)=>typeof t==`bigint`?`${t}`:t)}function w(e){if(typeof e==`bigint`&&(e<-(2**53-1)||e>2**53-1))throw TypeError(`${e} is not safe to convert to a number.`);return Number(e)}function wt(e,t){return w(e/t)+w(e%t)/w(t)}const Tt=Symbol.for(`isArrowBigNum`);function Et(e,...t){return t.length===0?Object.setPrototypeOf(p(this.TypedArray,e),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(e,...t),this.constructor.prototype)}Et.prototype[Tt]=!0,Et.prototype.toJSON=function(){return`"${Mt(this)}"`},Et.prototype.valueOf=function(e){return jt(this,e)},Et.prototype.toString=function(){return Mt(this)},Et.prototype[Symbol.toPrimitive]=function(e=`default`){switch(e){case`number`:return jt(this);case`string`:return Mt(this);case`default`:return Nt(this)}return Mt(this)};function Dt(...e){return Et.apply(this,e)}function Ot(...e){return Et.apply(this,e)}function kt(...e){return Et.apply(this,e)}Object.setPrototypeOf(Dt.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(Ot.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(kt.prototype,Object.create(Uint32Array.prototype)),Object.assign(Dt.prototype,Et.prototype,{constructor:Dt,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(Ot.prototype,Et.prototype,{constructor:Ot,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(kt.prototype,Et.prototype,{constructor:kt,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});const At=BigInt(4294967296)*BigInt(4294967296)-BigInt(1);function jt(e,t){let{buffer:n,byteOffset:r,byteLength:i,signed:a}=e,o=new BigUint64Array(n,r,i/8),s=a&&o.at(-1)&BigInt(1)<<BigInt(63),c=BigInt(0),l=0;if(s){for(let e of o)c|=(e^At)*(BigInt(1)<<BigInt(64*l++));c*=BigInt(-1),c-=BigInt(1)}else for(let e of o)c|=e*(BigInt(1)<<BigInt(64*l++));if(typeof t==`number`){let e=BigInt(10**t),n=c/e,r=c%e;return w(n)+w(r)/w(e)}return w(c)}function Mt(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return Pt(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Pt(e);t=t.slice();let n=1;for(let e=0;e<t.length;e++){let r=t[e],i=~r+n;t[e]=i,n&=+(r===0)}return`-${Pt(t)}`}function Nt(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:Mt(e)}function Pt(e){let t=``,n=new Uint32Array(2),r=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2),i=new Uint32Array((r=new Uint16Array(r).reverse()).buffer),a=-1,o=r.length-1;do{for(n[0]=r[a=0];a<o;)r[a++]=n[1]=n[0]/10,n[0]=(n[0]-n[1]*10<<16)+r[a];r[a]=n[1]=n[0]/10,n[0]-=n[1]*10,t=`${n[0]}${t}`}while(i[0]||i[1]||i[2]||i[3]);return t??`0`}var Ft=class e{static new(e,t){switch(t){case!0:return new Dt(e);case!1:return new Ot(e)}switch(e.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new Dt(e)}return e.byteLength===16?new kt(e):new Ot(e)}static signed(e){return new Dt(e)}static unsigned(e){return new Ot(e)}static decimal(e){return new kt(e)}constructor(t,n){return e.new(t,n)}},It,Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt,Zt,Qt,$t,en,tn,nn,rn,T=class e{static isNull(e){return e?.typeId===C.Null}static isInt(e){return e?.typeId===C.Int}static isFloat(e){return e?.typeId===C.Float}static isBinary(e){return e?.typeId===C.Binary}static isLargeBinary(e){return e?.typeId===C.LargeBinary}static isUtf8(e){return e?.typeId===C.Utf8}static isLargeUtf8(e){return e?.typeId===C.LargeUtf8}static isBool(e){return e?.typeId===C.Bool}static isDecimal(e){return e?.typeId===C.Decimal}static isDate(e){return e?.typeId===C.Date}static isTime(e){return e?.typeId===C.Time}static isTimestamp(e){return e?.typeId===C.Timestamp}static isInterval(e){return e?.typeId===C.Interval}static isDuration(e){return e?.typeId===C.Duration}static isList(e){return e?.typeId===C.List}static isStruct(e){return e?.typeId===C.Struct}static isUnion(e){return e?.typeId===C.Union}static isFixedSizeBinary(e){return e?.typeId===C.FixedSizeBinary}static isFixedSizeList(e){return e?.typeId===C.FixedSizeList}static isMap(e){return e?.typeId===C.Map}static isDictionary(e){return e?.typeId===C.Dictionary}static isDenseUnion(t){return e.isUnion(t)&&t.mode===g.Dense}static isSparseUnion(t){return e.isUnion(t)&&t.mode===g.Sparse}constructor(e){this.typeId=e}};It=Symbol.toStringTag,T[It]=(e=>(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]=`DataType`))(T.prototype);var an=class extends T{constructor(){super(C.Null)}toString(){return`Null`}};Lt=Symbol.toStringTag,an[Lt]=(e=>e[Symbol.toStringTag]=`Null`)(an.prototype);var E=class extends T{constructor(e,t){super(C.Int),this.isSigned=e,this.bitWidth=t}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 Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?`I`:`Ui`}nt${this.bitWidth}`}};Rt=Symbol.toStringTag,E[Rt]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]=`Int`))(E.prototype);var on=class extends E{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},sn=class extends E{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},cn=class extends E{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},ln=class extends E{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},un=class extends E{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},dn=class extends E{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},fn=class extends E{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},pn=class extends E{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(on.prototype,"ArrayType",{value:Int8Array}),Object.defineProperty(sn.prototype,"ArrayType",{value:Int16Array}),Object.defineProperty(cn.prototype,"ArrayType",{value:Int32Array}),Object.defineProperty(ln.prototype,"ArrayType",{value:BigInt64Array}),Object.defineProperty(un.prototype,"ArrayType",{value:Uint8Array}),Object.defineProperty(dn.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(fn.prototype,"ArrayType",{value:Uint32Array}),Object.defineProperty(pn.prototype,"ArrayType",{value:BigUint64Array});var mn=class extends T{constructor(e){super(C.Float),this.precision=e}get ArrayType(){switch(this.precision){case _.HALF:return Uint16Array;case _.SINGLE:return Float32Array;case _.DOUBLE:return Float64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};zt=Symbol.toStringTag,mn[zt]=(e=>(e.precision=null,e[Symbol.toStringTag]=`Float`))(mn.prototype);var hn=class extends mn{constructor(){super(_.HALF)}},gn=class extends mn{constructor(){super(_.SINGLE)}},_n=class extends mn{constructor(){super(_.DOUBLE)}};Object.defineProperty(hn.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(gn.prototype,"ArrayType",{value:Float32Array}),Object.defineProperty(_n.prototype,"ArrayType",{value:Float64Array});var vn=class extends T{constructor(){super(C.Binary)}toString(){return`Binary`}};Bt=Symbol.toStringTag,vn[Bt]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Binary`))(vn.prototype);var yn=class extends T{constructor(){super(C.LargeBinary)}toString(){return`LargeBinary`}};Vt=Symbol.toStringTag,yn[Vt]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeBinary`))(yn.prototype);var bn=class extends T{constructor(){super(C.Utf8)}toString(){return`Utf8`}};Ht=Symbol.toStringTag,bn[Ht]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Utf8`))(bn.prototype);var xn=class extends T{constructor(){super(C.LargeUtf8)}toString(){return`LargeUtf8`}};Ut=Symbol.toStringTag,xn[Ut]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeUtf8`))(xn.prototype);var Sn=class extends T{constructor(){super(C.Bool)}toString(){return`Bool`}};Wt=Symbol.toStringTag,Sn[Wt]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Bool`))(Sn.prototype);var Cn=class extends T{constructor(e,t,n=128){super(C.Decimal),this.scale=e,this.precision=t,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?`+`:``}${this.scale}]`}};Gt=Symbol.toStringTag,Cn[Gt]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]=`Decimal`))(Cn.prototype);var wn=class extends T{constructor(e){super(C.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${Ie[this.unit]}>`}get ArrayType(){return this.unit===Ie.DAY?Int32Array:BigInt64Array}};Kt=Symbol.toStringTag,wn[Kt]=(e=>(e.unit=null,e[Symbol.toStringTag]=`Date`))(wn.prototype);var Tn=class extends T{constructor(e,t){super(C.Time),this.unit=e,this.bitWidth=t}toString(){return`Time${this.bitWidth}<${v[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};qt=Symbol.toStringTag,Tn[qt]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]=`Time`))(Tn.prototype);var En=class extends T{constructor(e,t){super(C.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${v[this.unit]}${this.timezone?`, ${this.timezone}`:``}>`}};Jt=Symbol.toStringTag,En[Jt]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Timestamp`))(En.prototype);var Dn=class extends T{constructor(e){super(C.Interval),this.unit=e}toString(){return`Interval<${Le[this.unit]}>`}};Yt=Symbol.toStringTag,Dn[Yt]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]=`Interval`))(Dn.prototype);var On=class extends T{constructor(e){super(C.Duration),this.unit=e}toString(){return`Duration<${v[this.unit]}>`}};Xt=Symbol.toStringTag,On[Xt]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Duration`))(On.prototype);var kn=class extends T{constructor(e){super(C.List),this.children=[e]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};Zt=Symbol.toStringTag,kn[Zt]=(e=>(e.children=null,e[Symbol.toStringTag]=`List`))(kn.prototype);var D=class extends T{constructor(e){super(C.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};Qt=Symbol.toStringTag,D[Qt]=(e=>(e.children=null,e[Symbol.toStringTag]=`Struct`))(D.prototype);var An=class extends T{constructor(e,t,n){super(C.Union),this.mode=e,this.children=n,this.typeIds=t=Int32Array.from(t),this.typeIdToChildIndex=t.reduce((e,t,n)=>(e[t]=n)&&e||e,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(e=>`${e.type}`).join(` | `)}>`}};$t=Symbol.toStringTag,An[$t]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]=`Union`))(An.prototype);var jn=class extends T{constructor(e){super(C.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};en=Symbol.toStringTag,jn[en]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`FixedSizeBinary`))(jn.prototype);var Mn=class extends T{constructor(e,t){super(C.FixedSizeList),this.listSize=e,this.children=[t]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};tn=Symbol.toStringTag,Mn[tn]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]=`FixedSizeList`))(Mn.prototype);var Nn=class extends T{constructor(e,t=!1){if(super(C.Map),this.children=[e],this.keysSorted=t,e&&(e.name=`entries`,e?.type?.children)){let t=(e?.type)?.children[0];t&&(t.name=`key`);let n=(e?.type)?.children[1];n&&(n.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<{${this.children[0].type.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};nn=Symbol.toStringTag,Nn[nn]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]=`Map_`))(Nn.prototype);const Pn=(e=>()=>++e)(-1);var Fn=class extends T{constructor(e,t,n,r){super(C.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=r||!1,this.id=n==null?Pn():w(n)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};rn=Symbol.toStringTag,Fn[rn]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]=`Dictionary`))(Fn.prototype);function In(e){let t=e;switch(e.typeId){case C.Decimal:return e.bitWidth/32;case C.Interval:return 1+t.unit;case C.FixedSizeList:return t.listSize;case C.FixedSizeBinary:return t.byteWidth;default:return 1}}var O=class{visitMany(e,...t){return e.map((e,n)=>this.visit(e,...t.map(e=>e[n])))}visit(...e){return this.getVisitFn(e[0],!1).apply(this,e)}getVisitFn(e,t=!0){return Ln(this,e,t)}getVisitFnByTypeId(e,t=!0){return Rn(this,e,t)}visitNull(e,...t){return null}visitBool(e,...t){return null}visitInt(e,...t){return null}visitFloat(e,...t){return null}visitUtf8(e,...t){return null}visitLargeUtf8(e,...t){return null}visitBinary(e,...t){return null}visitLargeBinary(e,...t){return null}visitFixedSizeBinary(e,...t){return null}visitDate(e,...t){return null}visitTimestamp(e,...t){return null}visitTime(e,...t){return null}visitDecimal(e,...t){return null}visitList(e,...t){return null}visitStruct(e,...t){return null}visitUnion(e,...t){return null}visitDictionary(e,...t){return null}visitInterval(e,...t){return null}visitDuration(e,...t){return null}visitFixedSizeList(e,...t){return null}visitMap(e,...t){return null}};function Ln(e,t,n=!0){return typeof t==`number`?Rn(e,t,n):typeof t==`string`&&t in C?Rn(e,C[t],n):t&&t instanceof T?Rn(e,zn(t),n):t?.type&&t.type instanceof T?Rn(e,zn(t.type),n):Rn(e,C.NONE,n)}function Rn(e,t,n=!0){let r=null;switch(t){case C.Null:r=e.visitNull;break;case C.Bool:r=e.visitBool;break;case C.Int:r=e.visitInt;break;case C.Int8:r=e.visitInt8||e.visitInt;break;case C.Int16:r=e.visitInt16||e.visitInt;break;case C.Int32:r=e.visitInt32||e.visitInt;break;case C.Int64:r=e.visitInt64||e.visitInt;break;case C.Uint8:r=e.visitUint8||e.visitInt;break;case C.Uint16:r=e.visitUint16||e.visitInt;break;case C.Uint32:r=e.visitUint32||e.visitInt;break;case C.Uint64:r=e.visitUint64||e.visitInt;break;case C.Float:r=e.visitFloat;break;case C.Float16:r=e.visitFloat16||e.visitFloat;break;case C.Float32:r=e.visitFloat32||e.visitFloat;break;case C.Float64:r=e.visitFloat64||e.visitFloat;break;case C.Utf8:r=e.visitUtf8;break;case C.LargeUtf8:r=e.visitLargeUtf8;break;case C.Binary:r=e.visitBinary;break;case C.LargeBinary:r=e.visitLargeBinary;break;case C.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case C.Date:r=e.visitDate;break;case C.DateDay:r=e.visitDateDay||e.visitDate;break;case C.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case C.Timestamp:r=e.visitTimestamp;break;case C.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case C.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case C.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case C.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case C.Time:r=e.visitTime;break;case C.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case C.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case C.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case C.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case C.Decimal:r=e.visitDecimal;break;case C.List:r=e.visitList;break;case C.Struct:r=e.visitStruct;break;case C.Union:r=e.visitUnion;break;case C.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case C.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case C.Dictionary:r=e.visitDictionary;break;case C.Interval:r=e.visitInterval;break;case C.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case C.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case C.Duration:r=e.visitDuration;break;case C.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case C.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case C.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case C.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case C.FixedSizeList:r=e.visitFixedSizeList;break;case C.Map:r=e.visitMap}if(typeof r==`function`)return r;if(!n)return()=>null;throw Error(`Unrecognized type '${C[t]}'`)}function zn(e){switch(e.typeId){case C.Null:return C.Null;case C.Int:{let{bitWidth:t,isSigned:n}=e;switch(t){case 8:return n?C.Int8:C.Uint8;case 16:return n?C.Int16:C.Uint16;case 32:return n?C.Int32:C.Uint32;case 64:return n?C.Int64:C.Uint64}return C.Int}case C.Float:switch(e.precision){case _.HALF:return C.Float16;case _.SINGLE:return C.Float32;case _.DOUBLE:return C.Float64}return C.Float;case C.Binary:return C.Binary;case C.LargeBinary:return C.LargeBinary;case C.Utf8:return C.Utf8;case C.LargeUtf8:return C.LargeUtf8;case C.Bool:return C.Bool;case C.Decimal:return C.Decimal;case C.Time:switch(e.unit){case v.SECOND:return C.TimeSecond;case v.MILLISECOND:return C.TimeMillisecond;case v.MICROSECOND:return C.TimeMicrosecond;case v.NANOSECOND:return C.TimeNanosecond}return C.Time;case C.Timestamp:switch(e.unit){case v.SECOND:return C.TimestampSecond;case v.MILLISECOND:return C.TimestampMillisecond;case v.MICROSECOND:return C.TimestampMicrosecond;case v.NANOSECOND:return C.TimestampNanosecond}return C.Timestamp;case C.Date:switch(e.unit){case Ie.DAY:return C.DateDay;case Ie.MILLISECOND:return C.DateMillisecond}return C.Date;case C.Interval:switch(e.unit){case Le.DAY_TIME:return C.IntervalDayTime;case Le.YEAR_MONTH:return C.IntervalYearMonth}return C.Interval;case C.Duration:switch(e.unit){case v.SECOND:return C.DurationSecond;case v.MILLISECOND:return C.DurationMillisecond;case v.MICROSECOND:return C.DurationMicrosecond;case v.NANOSECOND:return C.DurationNanosecond}return C.Duration;case C.Map:return C.Map;case C.List:return C.List;case C.Struct:return C.Struct;case C.Union:switch(e.mode){case g.Dense:return C.DenseUnion;case g.Sparse:return C.SparseUnion}return C.Union;case C.FixedSizeBinary:return C.FixedSizeBinary;case C.FixedSizeList:return C.FixedSizeList;case C.Dictionary:return C.Dictionary}throw Error(`Unrecognized type '${C[e.typeId]}'`)}O.prototype.visitInt8=null,O.prototype.visitInt16=null,O.prototype.visitInt32=null,O.prototype.visitInt64=null,O.prototype.visitUint8=null,O.prototype.visitUint16=null,O.prototype.visitUint32=null,O.prototype.visitUint64=null,O.prototype.visitFloat16=null,O.prototype.visitFloat32=null,O.prototype.visitFloat64=null,O.prototype.visitDateDay=null,O.prototype.visitDateMillisecond=null,O.prototype.visitTimestampSecond=null,O.prototype.visitTimestampMillisecond=null,O.prototype.visitTimestampMicrosecond=null,O.prototype.visitTimestampNanosecond=null,O.prototype.visitTimeSecond=null,O.prototype.visitTimeMillisecond=null,O.prototype.visitTimeMicrosecond=null,O.prototype.visitTimeNanosecond=null,O.prototype.visitDenseUnion=null,O.prototype.visitSparseUnion=null,O.prototype.visitIntervalDayTime=null,O.prototype.visitIntervalYearMonth=null,O.prototype.visitDuration=null,O.prototype.visitDurationSecond=null,O.prototype.visitDurationMillisecond=null,O.prototype.visitDurationMicrosecond=null,O.prototype.visitDurationNanosecond=null;const Bn=new Float64Array(1),Vn=new Uint32Array(Bn.buffer);function Hn(e){let t=(e&31744)>>10,n=(e&1023)/1024,r=(-1)**((e&32768)>>15);switch(t){case 31:return r*(n?NaN:1/0);case 0:return r*(n?6103515625e-14*n:0)}return r*2**(t-15)*(1+n)}function Un(e){if(e!==e)return 32256;Bn[0]=e;let t=(Vn[1]&2147483648)>>16&65535,n=Vn[1]&2146435072,r=0;return n>=1089470464?Vn[0]>0?n=31744:(n=(n&2080374784)>>16,r=(Vn[1]&1048575)>>10):n<=1056964608?(r=1048576+(Vn[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(Vn[1]&1048575)+512>>10),t|n|r&65535}var k=class extends O{};function A(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}const Wn=(e,t,n)=>{e[t]=Math.floor(n/864e5)},Gn=(e,t,n,r)=>{if(n+1<t.length){let i=w(t[n]),a=w(t[n+1]);e.set(r.subarray(0,a-i),i)}},Kn=({offset:e,values:t},n,r)=>{let i=e+n;r?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},qn=({values:e},t,n)=>{e[t]=n},Jn=({values:e},t,n)=>{e[t]=n},Yn=({values:e},t,n)=>{e[t]=Un(n)},Xn=(e,t,n)=>{switch(e.type.precision){case _.HALF:return Yn(e,t,n);case _.SINGLE:case _.DOUBLE:return Jn(e,t,n)}},Zn=({values:e},t,n)=>{Wn(e,t,n.valueOf())},Qn=({values:e},t,n)=>{e[t]=BigInt(n)},$n=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},er=({values:e,valueOffsets:t},n,r)=>Gn(e,t,n,r),tr=({values:e,valueOffsets:t},n,r)=>Gn(e,t,n,u(r)),nr=(e,t,n)=>{e.type.unit===Ie.DAY?Zn(e,t,n):Qn(e,t,n)},rr=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},ir=({values:e},t,n)=>{e[t]=BigInt(n)},ar=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},or=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},sr=(e,t,n)=>{switch(e.type.unit){case v.SECOND:return rr(e,t,n);case v.MILLISECOND:return ir(e,t,n);case v.MICROSECOND:return ar(e,t,n);case v.NANOSECOND:return or(e,t,n)}},cr=({values:e},t,n)=>{e[t]=n},lr=({values:e},t,n)=>{e[t]=n},ur=({values:e},t,n)=>{e[t]=n},dr=({values:e},t,n)=>{e[t]=n},fr=(e,t,n)=>{switch(e.type.unit){case v.SECOND:return cr(e,t,n);case v.MILLISECOND:return lr(e,t,n);case v.MICROSECOND:return ur(e,t,n);case v.NANOSECOND:return dr(e,t,n)}},pr=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},mr=(e,t,n)=>{let r=e.children[0],i=e.valueOffsets,a=j.getVisitFn(r);if(Array.isArray(n))for(let e=-1,o=i[t],s=i[t+1];o<s;)a(r,o++,n[++e]);else for(let e=-1,o=i[t],s=i[t+1];o<s;)a(r,o++,n.get(++e))},hr=(e,t,n)=>{let r=e.children[0],{valueOffsets:i}=e,a=j.getVisitFn(r),{[t]:o,[t+1]:s}=i,c=n instanceof Map?n.entries():Object.entries(n);for(let e of c)if(a(r,o,e),++o>=s)break},gr=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[a]),_r=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(a)),vr=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(i.name)),yr=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[i.name]),br=(e,t,n)=>{let r=e.type.children.map(e=>j.getVisitFn(e.type)),i=n instanceof Map?vr(t,n):n instanceof H?_r(t,n):Array.isArray(n)?gr(t,n):yr(t,n);e.type.children.forEach((t,n)=>i(r[n],e.children[n],t,n))},xr=(e,t,n)=>{e.type.mode===g.Dense?Sr(e,t,n):Cr(e,t,n)},Sr=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];j.visit(i,e.valueOffsets[t],n)},Cr=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];j.visit(i,t,n)},wr=(e,t,n)=>{var r;(r=e.dictionary)==null||r.set(e.values[t],n)},Tr=(e,t,n)=>{e.type.unit===Le.DAY_TIME?Er(e,t,n):Dr(e,t,n)},Er=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},Dr=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},Or=({values:e},t,n)=>{e[t]=n},kr=({values:e},t,n)=>{e[t]=n},Ar=({values:e},t,n)=>{e[t]=n},jr=({values:e},t,n)=>{e[t]=n},Mr=(e,t,n)=>{switch(e.type.unit){case v.SECOND:return Or(e,t,n);case v.MILLISECOND:return kr(e,t,n);case v.MICROSECOND:return Ar(e,t,n);case v.NANOSECOND:return jr(e,t,n)}},Nr=(e,t,n)=>{let{stride:r}=e,i=e.children[0],a=j.getVisitFn(i);if(Array.isArray(n))for(let e=-1,o=t*r;++e<r;)a(i,o+e,n[e]);else for(let e=-1,o=t*r;++e<r;)a(i,o+e,n.get(e))};k.prototype.visitBool=A(Kn),k.prototype.visitInt=A(qn),k.prototype.visitInt8=A(qn),k.prototype.visitInt16=A(qn),k.prototype.visitInt32=A(qn),k.prototype.visitInt64=A(qn),k.prototype.visitUint8=A(qn),k.prototype.visitUint16=A(qn),k.prototype.visitUint32=A(qn),k.prototype.visitUint64=A(qn),k.prototype.visitFloat=A(Xn),k.prototype.visitFloat16=A(Yn),k.prototype.visitFloat32=A(Jn),k.prototype.visitFloat64=A(Jn),k.prototype.visitUtf8=A(tr),k.prototype.visitLargeUtf8=A(tr),k.prototype.visitBinary=A(er),k.prototype.visitLargeBinary=A(er),k.prototype.visitFixedSizeBinary=A($n),k.prototype.visitDate=A(nr),k.prototype.visitDateDay=A(Zn),k.prototype.visitDateMillisecond=A(Qn),k.prototype.visitTimestamp=A(sr),k.prototype.visitTimestampSecond=A(rr),k.prototype.visitTimestampMillisecond=A(ir),k.prototype.visitTimestampMicrosecond=A(ar),k.prototype.visitTimestampNanosecond=A(or),k.prototype.visitTime=A(fr),k.prototype.visitTimeSecond=A(cr),k.prototype.visitTimeMillisecond=A(lr),k.prototype.visitTimeMicrosecond=A(ur),k.prototype.visitTimeNanosecond=A(dr),k.prototype.visitDecimal=A(pr),k.prototype.visitList=A(mr),k.prototype.visitStruct=A(br),k.prototype.visitUnion=A(xr),k.prototype.visitDenseUnion=A(Sr),k.prototype.visitSparseUnion=A(Cr),k.prototype.visitDictionary=A(wr),k.prototype.visitInterval=A(Tr),k.prototype.visitIntervalDayTime=A(Er),k.prototype.visitIntervalYearMonth=A(Dr),k.prototype.visitDuration=A(Mr),k.prototype.visitDurationSecond=A(Or),k.prototype.visitDurationMillisecond=A(kr),k.prototype.visitDurationMicrosecond=A(Ar),k.prototype.visitDurationNanosecond=A(jr),k.prototype.visitFixedSizeList=A(Nr),k.prototype.visitMap=A(hr);const j=new k,M=Symbol.for(`parent`),Pr=Symbol.for(`rowIndex`);var Fr=class{constructor(e,t){return this[M]=e,this[Pr]=t,new Proxy(this,new Lr)}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[Pr],t=this[M],n=t.type.children,r={};for(let i=-1,a=n.length;++i<a;)r[n[i].name]=F.visit(t.children[i],e);return r}toString(){return`{${[...this].map(([e,t])=>`${Ct(e)}: ${Ct(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}[Symbol.iterator](){return new Ir(this[M],this[Pr])}},Ir=class{constructor(e,t){this.childIndex=0,this.children=e.children,this.rowIndex=t,this.childFields=e.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let e=this.childIndex;return e<this.numChildren?(this.childIndex=e+1,{done:!1,value:[this.childFields[e].name,F.visit(this.children[e],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(Fr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[M]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Pr]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var Lr=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[M].type.children.map(e=>e.name)}has(e,t){return e[M].type.children.findIndex(e=>e.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[M].type.children.findIndex(e=>e.name===t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[M].type.children.findIndex(e=>e.name===t);if(n!==-1){let r=F.visit(e[M].children[n],e[Pr]);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[M].type.children.findIndex(e=>e.name===t);return r===-1?Reflect.has(e,t)||typeof t==`symbol`?Reflect.set(e,t,n):!1:(j.visit(e[M].children[r],e[Pr],n),Reflect.set(e,t,n))}},N=class extends O{};function P(e){return(t,n)=>t.getValid(n)?e(t,n):null}const Rr=(e,t)=>864e5*e[t],zr=(e,t)=>null,Br=(e,t,n)=>{if(n+1>=t.length)return null;let r=w(t[n]),i=w(t[n+1]);return e.subarray(r,i)},Vr=({offset:e,values:t},n)=>{let r=e+n;return!!(t[r>>3]&1<<r%8)},Hr=({values:e},t)=>Rr(e,t),Ur=({values:e},t)=>w(e[t]),Wr=({stride:e,values:t},n)=>t[e*n],Gr=({stride:e,values:t},n)=>Hn(t[e*n]),Kr=({values:e},t)=>e[t],qr=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),Jr=({values:e,valueOffsets:t},n)=>Br(e,t,n),Yr=({values:e,valueOffsets:t},n)=>{let r=Br(e,t,n);return r===null?null:c(r)},Xr=({values:e},t)=>e[t],Zr=({type:e,values:t},n)=>e.precision===_.HALF?Hn(t[n]):t[n],Qr=(e,t)=>e.type.unit===Ie.DAY?Hr(e,t):Ur(e,t),$r=({values:e},t)=>1e3*w(e[t]),ei=({values:e},t)=>w(e[t]),ti=({values:e},t)=>wt(e[t],BigInt(1e3)),ni=({values:e},t)=>wt(e[t],BigInt(1e6)),ri=(e,t)=>{switch(e.type.unit){case v.SECOND:return $r(e,t);case v.MILLISECOND:return ei(e,t);case v.MICROSECOND:return ti(e,t);case v.NANOSECOND:return ni(e,t)}},ii=({values:e},t)=>e[t],ai=({values:e},t)=>e[t],oi=({values:e},t)=>e[t],si=({values:e},t)=>e[t],ci=(e,t)=>{switch(e.type.unit){case v.SECOND:return ii(e,t);case v.MILLISECOND:return ai(e,t);case v.MICROSECOND:return oi(e,t);case v.NANOSECOND:return si(e,t)}},li=({values:e,stride:t},n)=>Ft.decimal(e.subarray(t*n,t*(n+1))),ui=(e,t)=>{let{valueOffsets:n,stride:r,children:i}=e,{[t*r]:a,[t*r+1]:o}=n;return new H([i[0].slice(a,o-a)])},di=(e,t)=>{let{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:a}=n,o=r[0];return new Ai(o.slice(i,a-i))},fi=(e,t)=>new Fr(e,t),pi=(e,t)=>e.type.mode===g.Dense?mi(e,t):hi(e,t),mi=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return F.visit(r,e.valueOffsets[t])},hi=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return F.visit(r,t)},gi=(e,t)=>e.dictionary?.get(e.values[t]),_i=(e,t)=>e.type.unit===Le.DAY_TIME?vi(e,t):yi(e,t),vi=({values:e},t)=>e.subarray(2*t,2*(t+1)),yi=({values:e},t)=>{let n=e[t],r=new Int32Array(2);return r[0]=Math.trunc(n/12),r[1]=Math.trunc(n%12),r},bi=({values:e},t)=>e[t],xi=({values:e},t)=>e[t],Si=({values:e},t)=>e[t],Ci=({values:e},t)=>e[t],wi=(e,t)=>{switch(e.type.unit){case v.SECOND:return bi(e,t);case v.MILLISECOND:return xi(e,t);case v.MICROSECOND:return Si(e,t);case v.NANOSECOND:return Ci(e,t)}},Ti=(e,t)=>{let{stride:n,children:r}=e;return new H([r[0].slice(t*n,n)])};N.prototype.visitNull=P(zr),N.prototype.visitBool=P(Vr),N.prototype.visitInt=P(Xr),N.prototype.visitInt8=P(Wr),N.prototype.visitInt16=P(Wr),N.prototype.visitInt32=P(Wr),N.prototype.visitInt64=P(Kr),N.prototype.visitUint8=P(Wr),N.prototype.visitUint16=P(Wr),N.prototype.visitUint32=P(Wr),N.prototype.visitUint64=P(Kr),N.prototype.visitFloat=P(Zr),N.prototype.visitFloat16=P(Gr),N.prototype.visitFloat32=P(Wr),N.prototype.visitFloat64=P(Wr),N.prototype.visitUtf8=P(Yr),N.prototype.visitLargeUtf8=P(Yr),N.prototype.visitBinary=P(Jr),N.prototype.visitLargeBinary=P(Jr),N.prototype.visitFixedSizeBinary=P(qr),N.prototype.visitDate=P(Qr),N.prototype.visitDateDay=P(Hr),N.prototype.visitDateMillisecond=P(Ur),N.prototype.visitTimestamp=P(ri),N.prototype.visitTimestampSecond=P($r),N.prototype.visitTimestampMillisecond=P(ei),N.prototype.visitTimestampMicrosecond=P(ti),N.prototype.visitTimestampNanosecond=P(ni),N.prototype.visitTime=P(ci),N.prototype.visitTimeSecond=P(ii),N.prototype.visitTimeMillisecond=P(ai),N.prototype.visitTimeMicrosecond=P(oi),N.prototype.visitTimeNanosecond=P(si),N.prototype.visitDecimal=P(li),N.prototype.visitList=P(ui),N.prototype.visitStruct=P(fi),N.prototype.visitUnion=P(pi),N.prototype.visitDenseUnion=P(mi),N.prototype.visitSparseUnion=P(hi),N.prototype.visitDictionary=P(gi),N.prototype.visitInterval=P(_i),N.prototype.visitIntervalDayTime=P(vi),N.prototype.visitIntervalYearMonth=P(yi),N.prototype.visitDuration=P(wi),N.prototype.visitDurationSecond=P(bi),N.prototype.visitDurationMillisecond=P(xi),N.prototype.visitDurationMicrosecond=P(Si),N.prototype.visitDurationNanosecond=P(Ci),N.prototype.visitFixedSizeList=P(Ti),N.prototype.visitMap=P(di);const F=new N,Ei=Symbol.for(`keys`),Di=Symbol.for(`vals`),Oi=Symbol.for(`kKeysAsStrings`),ki=Symbol.for(`_kKeysAsStrings`);var Ai=class{constructor(e){return this[Ei]=new H([e.children[0]]).memoize(),this[Di]=e.children[1],new Proxy(this,new Mi)}get[Oi](){return this[ki]||(this[ki]=Array.from(this[Ei].toArray(),String))}[Symbol.iterator](){return new ji(this[Ei],this[Di])}get size(){return this[Ei].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[Ei],t=this[Di],n={};for(let r=-1,i=e.length;++r<i;)n[e.get(r)]=F.visit(t,r);return n}toString(){return`{${[...this].map(([e,t])=>`${Ct(e)}: ${Ct(t)}`).join(`, `)}}`}[Symbol.for(`nodejs.util.inspect.custom`)](){return this.toString()}},ji=class{constructor(e,t){this.keys=e,this.vals=t,this.keyIndex=0,this.numKeys=e.length}[Symbol.iterator](){return this}next(){let e=this.keyIndex;return e===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(e),F.visit(this.vals,e)]})}},Mi=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[Oi]}has(e,t){return e[Oi].includes(t)}getOwnPropertyDescriptor(e,t){if(e[Oi].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[Oi].indexOf(t);if(n!==-1){let r=F.visit(Reflect.get(e,Di),n);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[Oi].indexOf(t);return r===-1?Reflect.has(e,t)?Reflect.set(e,t,n):!1:(j.visit(Reflect.get(e,Di),r,n),Reflect.set(e,t,n))}};Object.defineProperties(Ai.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[Ei]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Di]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ki]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Ni;function Pi(e,t,n,r){let{length:i=0}=e,a=typeof t==`number`?t:0,o=typeof n==`number`?n:i;return a<0&&(a=(a%i+i)%i),o<0&&(o=(o%i+i)%i),o<a&&(Ni=a,a=o,o=Ni),o>i&&(o=i),r?r(e,a,o):[a,o]}const Fi=(e,t)=>e<0?t+e:e,Ii=e=>e!==e;function Li(e){if(typeof e!=`object`||!e)return Ii(e)?Ii:t=>t===e;if(e instanceof Date){let t=e.valueOf();return e=>e instanceof Date&&e.valueOf()===t}return ArrayBuffer.isView(e)?t=>t?De(e,t):!1:e instanceof Map?zi(e):Array.isArray(e)?Ri(e):e instanceof H?Bi(e):Vi(e,!0)}function Ri(e){let t=[];for(let n=-1,r=e.length;++n<r;)t[n]=Li(e[n]);return Hi(t)}function zi(e){let t=-1,n=[];for(let r of e.values())n[++t]=Li(r);return Hi(n)}function Bi(e){let t=[];for(let n=-1,r=e.length;++n<r;)t[n]=Li(e.get(n));return Hi(t)}function Vi(e,t=!1){let n=Object.keys(e);if(!t&&n.length===0)return()=>!1;let r=[];for(let t=-1,i=n.length;++t<i;)r[t]=Li(e[n[t]]);return Hi(r,n)}function Hi(e,t){return n=>{if(!n||typeof n!=`object`)return!1;switch(n.constructor){case Array:return Ui(e,n);case Map:return Gi(e,n,n.keys());case Ai:case Fr:case Object:case void 0:return Gi(e,n,t||Object.keys(n))}return n instanceof H&&Wi(e,n)}}function Ui(e,t){let n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t[r]))return!1;return!0}function Wi(e,t){let n=e.length;if(t.length!==n)return!1;for(let r=-1;++r<n;)if(!e[r](t.get(r)))return!1;return!0}function Gi(e,t,n){let r=n[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),a=t instanceof Map?t.values():Object.values(t)[Symbol.iterator](),o=0,s=e.length,c=a.next(),l=r.next(),u=i.next();for(;o<s&&!l.done&&!u.done&&!c.done&&!(l.value!==u.value||!e[o](c.value));++o,l=r.next(),u=i.next(),c=a.next());return o===s&&l.done&&u.done&&c.done?!0:(r.return&&r.return(),i.return&&i.return(),a.return&&a.return(),!1)}function Ki(e,t,n,r){return!!(n&1<<r)}function qi(e,t,n,r){return(n&1<<r)>>r}function Ji(e,t,n){let r=n.byteLength+7&-8;if(e>0||n.byteLength<r){let i=new Uint8Array(r);return i.set(e%8==0?n.subarray(e>>3):Yi(new Xi(n,e,t,null,Ki)).subarray(0,r)),i}return n}function Yi(e){let t=[],n=0,r=0,i=0;for(let a of e)a&&(i|=1<<r),++r===8&&(t[n++]=i,i=r=0);(n===0||r>0)&&(t[n++]=i);let a=new Uint8Array(t.length+7&-8);return a.set(t),a}var Xi=class{constructor(e,t,n,r,i){this.bytes=e,this.length=n,this.context=r,this.get=i,this.bit=t%8,this.byteIndex=t>>3,this.byte=e[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 Zi(e,t,n){if(n-t<=0)return 0;if(n-t<8){let r=0;for(let i of new Xi(e,t,n-t,e,qi))r+=i;return r}let r=n>>3<<3,i=t+(t%8==0?0:8-t%8);return Zi(e,t,i)+Zi(e,r,n)+Qi(e,i>>3,r-i>>3)}function Qi(e,t,n){let r=0,i=Math.trunc(t),a=new DataView(e.buffer,e.byteOffset,e.byteLength),o=n===void 0?e.byteLength:i+n;for(;o-i>=4;)r+=$i(a.getUint32(i)),i+=4;for(;o-i>=2;)r+=$i(a.getUint16(i)),i+=2;for(;o-i>=1;)r+=$i(a.getUint8(i)),i+=1;return r}function $i(e){let t=Math.trunc(e);return t-=t>>>1&1431655765,t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var I=class e{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:e}=this;return T.isSparseUnion(e)||T.isDenseUnion(e)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let e=0,{valueOffsets:t,values:n,nullBitmap:r,typeIds:i}=this;return t&&(e+=t.byteLength),n&&(e+=n.byteLength),r&&(e+=r.byteLength),i&&(e+=i.byteLength),this.children.reduce((e,t)=>e+t.byteLength,e)}get nullCount(){if(T.isUnion(this.type))return this.children.reduce((e,t)=>e+t.nullCount,0);let e=this._nullCount,t;return e<=-1&&(t=this.nullBitmap)&&(this._nullCount=e=t.length===0?0:this.length-Zi(t,this.offset,this.offset+this.length)),e}constructor(t,n,r,i,a,o=[],s){this.type=t,this.children=o,this.dictionary=s,this.offset=Math.floor(Math.max(n||0,0)),this.length=Math.floor(Math.max(r||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let c;a instanceof e?(this.stride=a.stride,this.values=a.values,this.typeIds=a.typeIds,this.nullBitmap=a.nullBitmap,this.valueOffsets=a.valueOffsets):(this.stride=In(t),a&&((c=a[0])&&(this.valueOffsets=c),(c=a[1])&&(this.values=c),(c=a[2])&&(this.nullBitmap=c),(c=a[3])&&(this.typeIds=c)))}getValid(e){let{type:t}=this;if(T.isUnion(t)){let n=t,r=this.children[n.typeIdToChildIndex[this.typeIds[e]]],i=n.mode===g.Dense?this.valueOffsets[e]:e;return r.getValid(i)}if(this.nullable&&this.nullCount>0){let t=this.offset+e;return!!(this.nullBitmap[t>>3]&1<<t%8)}return!0}setValid(e,t){let n,{type:r}=this;if(T.isUnion(r)){let i=r,a=this.children[i.typeIdToChildIndex[this.typeIds[e]]],o=i.mode===g.Dense?this.valueOffsets[e]:e;n=a.getValid(o),a.setValid(o,t)}else{let{nullBitmap:r}=this,{offset:i,length:a}=this,o=i+e,s=1<<o%8,c=o>>3;(!r||r.byteLength<=c)&&(r=new Uint8Array((i+a+63&-64)>>3).fill(255),this.nullCount>0?(r.set(Ji(i,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:r})):Object.assign(this,{nullBitmap:r,_nullCount:0}));let l=r[c];n=(l&s)!==0,r[c]=t?l|s:l&~s}return n!==!!t&&(this._nullCount=this.nullCount+(t?-1:1)),t}clone(t=this.type,n=this.offset,r=this.length,i=this._nullCount,a=this,o=this.children){return new e(t,n,r,i,a,o,this.dictionary)}slice(e,t){let{stride:n,typeId:r,children:i}=this,a=(this._nullCount===0)-1,o=r===16?n:1,s=this._sliceBuffers(e,t,n,r);return this.clone(this.type,this.offset+e,t,a,s,i.length===0||this.valueOffsets?i:this._sliceChildren(i,o*e,o*t))}_changeLengthAndBackfillNullBitmap(e){if(this.typeId===C.Null)return this.clone(this.type,0,e,0);let{length:t,nullCount:n}=this,r=new Uint8Array((e+63&-64)>>3).fill(255,0,t>>3);r[t>>3]=(1<<t-(t&-8))-1,n>0&&r.set(Ji(this.offset,t,this.nullBitmap),0);let i=this.buffers;return i[St.VALIDITY]=r,this.clone(this.type,0,e,n+(e-t),i)}_sliceBuffers(e,t,n,r){let i,{buffers:a}=this;return(i=a[St.TYPE])&&(a[St.TYPE]=i.subarray(e,e+t)),(i=a[St.OFFSET])&&(a[St.OFFSET]=i.subarray(e,e+t+1))||(i=a[St.DATA])&&(a[St.DATA]=r===6?i:i.subarray(n*e,n*(e+t))),a}_sliceChildren(e,t,n){return e.map(e=>e.slice(t,n))}};I.prototype.children=Object.freeze([]);const ea=new class e extends O{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{type:t,offset:n=0,length:r=0}=e;return new I(t,n,r,r)}visitBool(e){let{type:t,offset:n=0}=e,r=m(e.nullBitmap),i=p(t.ArrayType,e.data),{length:a=i.length>>3,nullCount:o=e.nullBitmap?-1:0}=e;return new I(t,n,a,o,[void 0,i,r])}visitInt(e){let{type:t,offset:n=0}=e,r=m(e.nullBitmap),i=p(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new I(t,n,a,o,[void 0,i,r])}visitFloat(e){let{type:t,offset:n=0}=e,r=m(e.nullBitmap),i=p(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new I(t,n,a,o,[void 0,i,r])}visitUtf8(e){let{type:t,offset:n=0}=e,r=m(e.data),i=m(e.nullBitmap),a=ye(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new I(t,n,o,s,[a,r,i])}visitLargeUtf8(e){let{type:t,offset:n=0}=e,r=m(e.data),i=m(e.nullBitmap),a=be(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new I(t,n,o,s,[a,r,i])}visitBinary(e){let{type:t,offset:n=0}=e,r=m(e.data),i=m(e.nullBitmap),a=ye(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new I(t,n,o,s,[a,r,i])}visitLargeBinary(e){let{type:t,offset:n=0}=e,r=m(e.data),i=m(e.nullBitmap),a=be(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new I(t,n,o,s,[a,r,i])}visitFixedSizeBinary(e){let{type:t,offset:n=0}=e,r=m(e.nullBitmap),i=p(t.ArrayType,e.data),{length:a=i.length/In(t),nullCount:o=e.nullBitmap?-1:0}=e;return new I(t,n,a,o,[void 0,i,r])}visitDate(e){let{type:t,offset:n=0}=e,r=m(e.nullBitmap),i=p(t.ArrayType,e.data),{length:a=i.length/In(t),nullCount:o=e.nullBitmap?-1:0}=e;return new I(t,n,a,o,[void 0,i,r])}visitTimestamp(e){let{type:t,offset:n=0}=e,r=m(e.nullBitmap),i=p(t.ArrayType,e.data),{length:a=i.length/In(t),nullCount:o=e.nullBitmap?-1:0}=e;return new I(t,n,a,o,[void 0,i,r])}visitTime(e){let{type:t,offset:n=0}=e,r=m(e.nullBitmap),i=p(t.ArrayType,e.data),{length:a=i.length/In(t),nullCount:o=e.nullBitmap?-1:0}=e;return new I(t,n,a,o,[void 0,i,r])}visitDecimal(e){let{type:t,offset:n=0}=e,r=m(e.nullBitmap),i=p(t.ArrayType,e.data),{length:a=i.length/In(t),nullCount:o=e.nullBitmap?-1:0}=e;return new I(t,n,a,o,[void 0,i,r])}visitList(e){let{type:t,offset:n=0,child:r}=e,i=m(e.nullBitmap),a=ye(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new I(t,n,o,s,[a,void 0,i],[r])}visitStruct(e){let{type:t,offset:n=0,children:r=[]}=e,i=m(e.nullBitmap),{length:a=r.reduce((e,{length:t})=>Math.max(e,t),0),nullCount:o=e.nullBitmap?-1:0}=e;return new I(t,n,a,o,[void 0,void 0,i],r)}visitUnion(e){let{type:t,offset:n=0,children:r=[]}=e,i=p(t.ArrayType,e.typeIds),{length:a=i.length,nullCount:o=-1}=e;return T.isSparseUnion(t)?new I(t,n,a,o,[void 0,void 0,void 0,i],r):new I(t,n,a,o,[ye(e.valueOffsets),void 0,void 0,i],r)}visitDictionary(t){let{type:n,offset:r=0}=t,i=m(t.nullBitmap),a=p(n.indices.ArrayType,t.data),{dictionary:o=new H([new e().visit({type:n.dictionary})])}=t,{length:s=a.length,nullCount:c=t.nullBitmap?-1:0}=t;return new I(n,r,s,c,[void 0,a,i],[],o)}visitInterval(e){let{type:t,offset:n=0}=e,r=m(e.nullBitmap),i=p(t.ArrayType,e.data),{length:a=i.length/In(t),nullCount:o=e.nullBitmap?-1:0}=e;return new I(t,n,a,o,[void 0,i,r])}visitDuration(e){let{type:t,offset:n=0}=e,r=m(e.nullBitmap),i=p(t.ArrayType,e.data),{length:a=i.length,nullCount:o=e.nullBitmap?-1:0}=e;return new I(t,n,a,o,[void 0,i,r])}visitFixedSizeList(t){let{type:n,offset:r=0,child:i=new e().visit({type:n.valueType})}=t,a=m(t.nullBitmap),{length:o=i.length/In(n),nullCount:s=t.nullBitmap?-1:0}=t;return new I(n,r,o,s,[void 0,void 0,a],[i])}visitMap(t){let{type:n,offset:r=0,child:i=new e().visit({type:n.childType})}=t,a=m(t.nullBitmap),o=ye(t.valueOffsets),{length:s=o.length-1,nullCount:c=t.nullBitmap?-1:0}=t;return new I(n,r,s,c,[o,void 0,a],[i])}};function L(e){return ea.visit(e)}var ta=class{constructor(e=0,t){this.numChunks=e,this.getChunkIterator=t,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){let e=this.chunkIterator.next();if(!e.done)return e;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}};function na(e){return e.some(e=>e.nullable)}function ra(e){return e.reduce((e,t)=>e+t.nullCount,0)}function ia(e){return e.reduce((e,t,n)=>(e[n+1]=e[n]+t.length,e),new Uint32Array(e.length+1))}function aa(e,t,n,r){let i=[];for(let a=-1,o=e.length;++a<o;){let o=e[a],s=t[a],{length:c}=o;if(s>=r)break;if(n>=s+c)continue;if(s>=n&&s+c<=r){i.push(o);continue}let l=Math.max(0,n-s),u=Math.min(r-s,c);i.push(o.slice(l,u-l))}return i.length===0&&i.push(e[0].slice(0,0)),i}function oa(e,t,n,r){let i=0,a=0,o=t.length-1;do{if(i>=o-1)return n<t[o]?r(e,i,n-t[i]):null;a=i+Math.trunc((o-i)*.5),n<t[a]?o=a:i=a}while(i<o)}function sa(e,t){return e.getValid(t)}function ca(e){function t(t,n,r){return e(t[n],r)}return function(e){let n=this.data;return oa(n,this._offsets,e,t)}}function la(e){let t;function n(n,r,i){return e(n[r],i,t)}return function(e,r){let i=this.data;t=r;let a=oa(i,this._offsets,e,n);return t=void 0,a}}function ua(e){let t;function n(n,r,i){let a=i,o=0,s=0;for(let i=r-1,c=n.length;++i<c;){let r=n[i];if(~(o=e(r,t,a)))return s+o;a=0,s+=r.length}return-1}return function(e,r){t=e;let i=this.data,a=typeof r==`number`?oa(i,this._offsets,r,n):n(i,0,0);return t=void 0,a}}var R=class extends O{};function da(e,t){return t===null&&e.length>0?0:-1}function fa(e,t){let{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(let i of new Xi(n,e.offset+(t||0),e.length,n,Ki)){if(!i)return r;++r}return-1}function z(e,t,n){if(t===void 0)return-1;if(t===null)switch(e.typeId){case C.Union:break;case C.Dictionary:break;default:return fa(e,n)}let r=F.getVisitFn(e),i=Li(t);for(let t=(n||0)-1,a=e.length;++t<a;)if(i(r(e,t)))return t;return-1}function pa(e,t,n){let r=F.getVisitFn(e),i=Li(t);for(let t=(n||0)-1,a=e.length;++t<a;)if(i(r(e,t)))return t;return-1}R.prototype.visitNull=da,R.prototype.visitBool=z,R.prototype.visitInt=z,R.prototype.visitInt8=z,R.prototype.visitInt16=z,R.prototype.visitInt32=z,R.prototype.visitInt64=z,R.prototype.visitUint8=z,R.prototype.visitUint16=z,R.prototype.visitUint32=z,R.prototype.visitUint64=z,R.prototype.visitFloat=z,R.prototype.visitFloat16=z,R.prototype.visitFloat32=z,R.prototype.visitFloat64=z,R.prototype.visitUtf8=z,R.prototype.visitLargeUtf8=z,R.prototype.visitBinary=z,R.prototype.visitLargeBinary=z,R.prototype.visitFixedSizeBinary=z,R.prototype.visitDate=z,R.prototype.visitDateDay=z,R.prototype.visitDateMillisecond=z,R.prototype.visitTimestamp=z,R.prototype.visitTimestampSecond=z,R.prototype.visitTimestampMillisecond=z,R.prototype.visitTimestampMicrosecond=z,R.prototype.visitTimestampNanosecond=z,R.prototype.visitTime=z,R.prototype.visitTimeSecond=z,R.prototype.visitTimeMillisecond=z,R.prototype.visitTimeMicrosecond=z,R.prototype.visitTimeNanosecond=z,R.prototype.visitDecimal=z,R.prototype.visitList=z,R.prototype.visitStruct=z,R.prototype.visitUnion=z,R.prototype.visitDenseUnion=pa,R.prototype.visitSparseUnion=pa,R.prototype.visitDictionary=z,R.prototype.visitInterval=z,R.prototype.visitIntervalDayTime=z,R.prototype.visitIntervalYearMonth=z,R.prototype.visitDuration=z,R.prototype.visitDurationSecond=z,R.prototype.visitDurationMillisecond=z,R.prototype.visitDurationMicrosecond=z,R.prototype.visitDurationNanosecond=z,R.prototype.visitFixedSizeList=z,R.prototype.visitMap=z;const ma=new R;var B=class extends O{};function V(e){let{type:t}=e;if(e.nullCount===0&&e.stride===1&&(T.isInt(t)&&t.bitWidth!==64||T.isTime(t)&&t.bitWidth!==64||T.isFloat(t)&&t.precision!==_.HALF))return new ta(e.data.length,t=>{let n=e.data[t];return n.values.subarray(0,n.length)[Symbol.iterator]()});let n=0;return new ta(e.data.length,t=>{let r=e.data[t].length,i=e.slice(n,n+r);return n+=r,new ha(i)})}var ha=class{constructor(e){this.vector=e,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}};B.prototype.visitNull=V,B.prototype.visitBool=V,B.prototype.visitInt=V,B.prototype.visitInt8=V,B.prototype.visitInt16=V,B.prototype.visitInt32=V,B.prototype.visitInt64=V,B.prototype.visitUint8=V,B.prototype.visitUint16=V,B.prototype.visitUint32=V,B.prototype.visitUint64=V,B.prototype.visitFloat=V,B.prototype.visitFloat16=V,B.prototype.visitFloat32=V,B.prototype.visitFloat64=V,B.prototype.visitUtf8=V,B.prototype.visitLargeUtf8=V,B.prototype.visitBinary=V,B.prototype.visitLargeBinary=V,B.prototype.visitFixedSizeBinary=V,B.prototype.visitDate=V,B.prototype.visitDateDay=V,B.prototype.visitDateMillisecond=V,B.prototype.visitTimestamp=V,B.prototype.visitTimestampSecond=V,B.prototype.visitTimestampMillisecond=V,B.prototype.visitTimestampMicrosecond=V,B.prototype.visitTimestampNanosecond=V,B.prototype.visitTime=V,B.prototype.visitTimeSecond=V,B.prototype.visitTimeMillisecond=V,B.prototype.visitTimeMicrosecond=V,B.prototype.visitTimeNanosecond=V,B.prototype.visitDecimal=V,B.prototype.visitList=V,B.prototype.visitStruct=V,B.prototype.visitUnion=V,B.prototype.visitDenseUnion=V,B.prototype.visitSparseUnion=V,B.prototype.visitDictionary=V,B.prototype.visitInterval=V,B.prototype.visitIntervalDayTime=V,B.prototype.visitIntervalYearMonth=V,B.prototype.visitDuration=V,B.prototype.visitDurationSecond=V,B.prototype.visitDurationMillisecond=V,B.prototype.visitDurationMicrosecond=V,B.prototype.visitDurationNanosecond=V,B.prototype.visitFixedSizeList=V,B.prototype.visitMap=V;const ga=new B;var _a;const va={},ya={};var H=class e{constructor(t){let n=t[0]instanceof e?t.flatMap(e=>e.data):t;if(n.length===0||n.some(e=>!(e instanceof I)))throw TypeError(`Vector constructor expects an Array of Data instances.`);let r=n[0]?.type;switch(n.length){case 0:this._offsets=[0];break;case 1:{let{get:e,set:t,indexOf:i}=va[r.typeId],a=n[0];this.isValid=e=>sa(a,e),this.get=t=>e(a,t),this.set=(e,n)=>t(a,e,n),this.indexOf=e=>i(a,e),this._offsets=[0,a.length];break}default:Object.setPrototypeOf(this,ya[r.typeId]),this._offsets=ia(n)}this.data=n,this.type=r,this.stride=In(r),this.numChildren=r.children?.length??0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((e,t)=>e+t.byteLength,0)}get nullable(){return na(this.data)}get nullCount(){return ra(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${C[this.type.typeId]}Vector`}isValid(e){return!1}get(e){return null}at(e){return this.get(Fi(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return ga.visit(this)}concat(...t){return new e(this.data.concat(t.flatMap(e=>e.data).flat(1/0)))}slice(t,n){return new e(Pi(this,t,n,({data:e,_offsets:t},n,r)=>aa(e,t,n,r)))}toJSON(){return[...this]}toArray(){let{type:e,data:t,length:n,stride:r,ArrayType:i}=this;switch(e.typeId){case C.Int:case C.Float:case C.Decimal:case C.Time:case C.Timestamp:switch(t.length){case 0:return new i;case 1:return t[0].values.subarray(0,n*r);default:return t.reduce((e,{values:t,length:n})=>(e.array.set(t.subarray(0,n*r),e.offset),e.offset+=n*r,e),{array:new i(n*r),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(`,`)}]`}getChild(e){return this.getChildAt(this.type.children?.findIndex(t=>t.name===e))}getChildAt(t){return t>-1&&t<this.numChildren?new e(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return T.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(T.isDictionary(this.type)){let t=new ba(this.data[0].dictionary),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return new ba(this)}unmemoize(){if(T.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return this}};_a=Symbol.toStringTag,H[_a]=(e=>{e.type=T.prototype,e.data=[],e.length=0,e.stride=1,e.numChildren=0,e._offsets=new Uint32Array([0]),e[Symbol.isConcatSpreadable]=!0;let t=Object.keys(C).map(e=>C[e]).filter(e=>typeof e==`number`&&e!==C.NONE);for(let n of t){let t=F.getVisitFnByTypeId(n),r=j.getVisitFnByTypeId(n),i=ma.getVisitFnByTypeId(n);va[n]={get:t,set:r,indexOf:i},ya[n]=Object.create(e,{isValid:{value:ca(sa)},get:{value:ca(F.getVisitFnByTypeId(n))},set:{value:la(j.getVisitFnByTypeId(n))},indexOf:{value:ua(ma.getVisitFnByTypeId(n))}})}return`Vector`})(H.prototype);var ba=class e extends H{constructor(t){super(t.data);let n=this.get,r=this.set,i=this.slice,a=Array(this.length);Object.defineProperty(this,"get",{value(e){let t=a[e];if(t!==void 0)return t;let r=n.call(this,e);return a[e]=r,r}}),Object.defineProperty(this,"set",{value(e,t){r.call(this,e,t),a[e]=t}}),Object.defineProperty(this,"slice",{value:(t,n)=>new e(i.call(this,t,n))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new H(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}},xa=class{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,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(e,t,n,r){return e.prep(8,24),e.writeInt64(BigInt(r??0)),e.pad(4),e.writeInt32(n),e.writeInt64(BigInt(t??0)),e.offset()}},Sa=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsFooter(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):h.V1}schema(e){let t=this.bb.__offset(this.bb_pos,6);return t?(e||new xt).__init(this.bb.__indirect(this.bb_pos+t),this.bb):null}dictionaries(e,t){let n=this.bb.__offset(this.bb_pos,8);return n?(t||new xa).__init(this.bb.__vector(this.bb_pos+n)+e*24,this.bb):null}dictionariesLength(){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__vector_len(this.bb_pos+e):0}recordBatches(e,t){let n=this.bb.__offset(this.bb_pos,10);return n?(t||new xa).__init(this.bb.__vector(this.bb_pos+n)+e*24,this.bb):null}recordBatchesLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__vector_len(this.bb_pos+e):0}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,12);return n?(t||new y).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startFooter(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,h.V1)}static addSchema(e,t){e.addFieldOffset(1,t,0)}static addDictionaries(e,t){e.addFieldOffset(2,t,0)}static startDictionariesVector(e,t){e.startVector(24,t,8)}static addRecordBatches(e,t){e.addFieldOffset(3,t,0)}static startRecordBatchesVector(e,t){e.startVector(24,t,8)}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endFooter(e){return e.endObject()}static finishFooterBuffer(e,t){e.finish(t)}static finishSizePrefixedFooterBuffer(e,t){e.finish(t,void 0,!0)}},U=class e{constructor(e=[],t,n,r=h.V5){this.fields=e||[],this.metadata=t||new Map,n||=wa(this.fields),this.dictionaries=n,this.metadataVersion=r}get[Symbol.toStringTag](){return`Schema`}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(`, `)} }>`}select(t){let n=new Set(t),r=this.fields.filter(e=>n.has(e.name));return new e(r,this.metadata)}selectAt(t){let n=t.map(e=>this.fields[e]).filter(Boolean);return new e(n,this.metadata)}assign(...t){let n=t[0]instanceof e?t[0]:Array.isArray(t[0])?new e(t[0]):new e(t),r=[...this.fields],i=Ca(Ca(new Map,this.metadata),n.metadata),a=n.fields.filter(e=>{let t=r.findIndex(t=>t.name===e.name);return!~t||(r[t]=e.clone({metadata:Ca(Ca(new Map,r[t].metadata),e.metadata)}))&&!1}),o=wa(a,new Map);return new e([...r,...a],i,new Map([...this.dictionaries,...o]))}};U.prototype.fields=null,U.prototype.metadata=null,U.prototype.dictionaries=null;var W=class e{static new(...t){let[n,r,i,a]=t;return t[0]&&typeof t[0]==`object`&&({name:n}=t[0],r===void 0&&(r=t[0].type),i===void 0&&(i=t[0].nullable),a===void 0&&(a=t[0].metadata)),new e(`${n}`,r,i,a)}constructor(e,t,n=!1,r){this.name=e,this.type=t,this.nullable=n,this.metadata=r||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return`Field`}toString(){return`${this.name}: ${this.type}`}clone(...t){let[n,r,i,a]=t;return!t[0]||typeof t[0]!=`object`?[n=this.name,r=this.type,i=this.nullable,a=this.metadata]=t:{name:n=this.name,type:r=this.type,nullable:i=this.nullable,metadata:a=this.metadata}=t[0],e.new(n,r,i,a)}};W.prototype.type=null,W.prototype.name=null,W.prototype.nullable=null,W.prototype.metadata=null;function Ca(e,t){return new Map([...e||new Map,...t||new Map])}function wa(e,t=new Map){for(let n=-1,r=e.length;++n<r;){let r=e[n].type;if(T.isDictionary(r)){if(!t.has(r.id))t.set(r.id,r.dictionary);else if(t.get(r.id)!==r.dictionary)throw Error(`Cannot create Schema containing two different dictionaries with the same Id`)}r.children&&r.children.length>0&&wa(r.children,t)}return t}var Ta=We,Ea=Ue,Da=class{static decode(e){e=new Ea(m(e));let t=Sa.getRootAsFooter(e);return new Oa(U.decode(t.schema(),new Map,t.version()),t)}static encode(e){let t=new Ta,n=U.encode(t,e.schema);Sa.startRecordBatchesVector(t,e.numRecordBatches);for(let n of[...e.recordBatches()].slice().reverse())ka.encode(t,n);let r=t.endVector();Sa.startDictionariesVector(t,e.numDictionaries);for(let n of[...e.dictionaryBatches()].slice().reverse())ka.encode(t,n);let i=t.endVector();return Sa.startFooter(t),Sa.addSchema(t,n),Sa.addVersion(t,h.V5),Sa.addRecordBatches(t,r),Sa.addDictionaries(t,i),Sa.finishFooterBuffer(t,Sa.endFooter(t)),t.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(e,t=h.V5,n,r){this.schema=e,this.version=t,n&&(this._recordBatches=n),r&&(this._dictionaryBatches=r)}*recordBatches(){for(let e,t=-1,n=this.numRecordBatches;++t<n;)(e=this.getRecordBatch(t))&&(yield e)}*dictionaryBatches(){for(let e,t=-1,n=this.numDictionaries;++t<n;)(e=this.getDictionaryBatch(t))&&(yield e)}getRecordBatch(e){return e>=0&&e<this.numRecordBatches&&this._recordBatches[e]||null}getDictionaryBatch(e){return e>=0&&e<this.numDictionaries&&this._dictionaryBatches[e]||null}},Oa=class extends Da{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(e,t){super(e,t.version()),this._footer=t}getRecordBatch(e){if(e>=0&&e<this.numRecordBatches){let t=this._footer.recordBatches(e);if(t)return ka.decode(t)}return null}getDictionaryBatch(e){if(e>=0&&e<this.numDictionaries){let t=this._footer.dictionaries(e);if(t)return ka.decode(t)}return null}},ka=class e{static decode(t){return new e(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(e,t){let{metaDataLength:n}=t,r=BigInt(t.offset),i=BigInt(t.bodyLength);return xa.createBlock(e,r,n,i)}constructor(e,t,n){this.metaDataLength=e,this.offset=w(n),this.bodyLength=w(t)}};const G=Object.freeze({done:!0,value:void 0});var Aa=class{constructor(e){this._json=e}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},ja=class{tee(){return this._getDOMStream().tee()}pipe(e,t){return this._getNodeStream().pipe(e,t)}pipeTo(e,t){return this._getDOMStream().pipeTo(e,t)}pipeThrough(e,t){return this._getDOMStream().pipeThrough(e,t)}_getDOMStream(){return this._DOMStream||=this.toDOMStream()}_getNodeStream(){return this._nodeStream||=this.toNodeStream()}},Ma=class extends ja{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(e){return t(this,void 0,void 0,function*(){yield this.return(e)})}write(e){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(e):this.resolvers.shift().resolve({done:!1,value:e}))}abort(e){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:e}:this.resolvers.shift().reject({done:!0,value:e}))}close(){if(this._closedPromiseResolve){let{resolvers:e}=this;for(;e.length>0;)e.shift().resolve(G);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return Oe.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return Oe.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(e){return t(this,void 0,void 0,function*(){return yield this.abort(e),G})}return(e){return t(this,void 0,void 0,function*(){return yield this.close(),G})}read(e){return t(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return t(this,void 0,void 0,function*(){return(yield this.next(e,`peek`)).value})}next(...e){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,t)=>{this.resolvers.push({resolve:e,reject:t})}):Promise.resolve(G)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw Error(`AsyncQueue is closed`)}},Na=class extends Ma{write(e){if((e=m(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?c(this.toUint8Array(!0)):this.toUint8Array(!1).then(c)}toUint8Array(e=!1){return e?ve(this._values)[0]:t(this,void 0,void 0,function*(){var e,t,n,r;let i=[],a=0;try{for(var s=!0,c=o(this),l;l=yield c.next(),e=l.done,!e;s=!0){r=l.value,s=!1;let e=r;i.push(e),a+=e.byteLength}}catch(e){t={error:e}}finally{try{!s&&!e&&(n=c.return)&&(yield n.call(c))}finally{if(t)throw t.error}}return ve(i,a)[0]})}},Pa=class{constructor(e){e&&(this.source=new Ia(Oe.fromIterable(e)))}[Symbol.iterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Fa=class e{constructor(t){t instanceof e?this.source=t.source:t instanceof Na?this.source=new La(Oe.fromAsyncIterable(t)):pe(t)?this.source=new La(Oe.fromNodeStream(t)):de(t)?this.source=new La(Oe.fromDOMStream(t)):ce(t)?this.source=new La(Oe.fromDOMStream(t.body)):re(t)?this.source=new La(Oe.fromIterable(t)):(ne(t)||ie(t))&&(this.source=new La(Oe.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(e){return this.source.next(e)}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}get closed(){return this.source.closed}cancel(e){return this.source.cancel(e)}peek(e){return this.source.peek(e)}read(e){return this.source.read(e)}},Ia=class{constructor(e){this.source=e}cancel(e){this.return(e)}peek(e){return this.next(e,`peek`).value}read(e){return this.next(e,`read`).value}next(e,t=`read`){return this.source.next({cmd:t,size:e})}throw(e){return Object.create(this.source.throw&&this.source.throw(e)||G)}return(e){return Object.create(this.source.return&&this.source.return(e)||G)}},La=class{constructor(e){this.source=e,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(e){return t(this,void 0,void 0,function*(){yield this.return(e)})}get closed(){return this._closedPromise}read(e){return t(this,void 0,void 0,function*(){return(yield this.next(e,`read`)).value})}peek(e){return t(this,void 0,void 0,function*(){return(yield this.next(e,`peek`)).value})}next(e){return t(this,arguments,void 0,function*(e,t=`read`){return yield this.source.next({cmd:t,size:e})})}throw(e){return t(this,void 0,void 0,function*(){let t=this.source.throw&&(yield this.source.throw(e))||G;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}return(e){return t(this,void 0,void 0,function*(){let t=this.source.return&&(yield this.source.return(e))||G;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}},Ra=class extends Pa{constructor(e,t){super(),this.position=0,this.buffer=m(e),this.size=t===void 0?this.buffer.byteLength:t}readInt32(e){let{buffer:t,byteOffset:n}=this.readAt(e,4);return new DataView(t,n).getInt32(0,!0)}seek(e){return this.position=Math.min(e,this.size),e<this.size}read(e){let{buffer:t,size:n,position:r}=this;return t&&r<n?(typeof e!=`number`&&(e=1/0),this.position=Math.min(n,r+Math.min(n-r,e)),t.subarray(r,this.position)):null}readAt(e,t){let n=this.buffer,r=Math.min(this.size,e+t);return n?n.subarray(e,r):new Uint8Array(t)}close(){this.buffer&&=null}throw(e){return this.close(),{done:!0,value:e}}return(e){return this.close(),{done:!0,value:e}}},za=class extends Fa{constructor(e,n){super(),this.position=0,this._handle=e,typeof n==`number`?this.size=n:this._pending=t(this,void 0,void 0,function*(){this.size=(yield e.stat()).size,delete this._pending})}readInt32(e){return t(this,void 0,void 0,function*(){let{buffer:t,byteOffset:n}=yield this.readAt(e,4);return new DataView(t,n).getInt32(0,!0)})}seek(e){return t(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(e,this.size),e<this.size})}read(e){return t(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:t,size:n,position:r}=this;if(t&&r<n){typeof e!=`number`&&(e=1/0);let i=r,a=0,o=0,s=Math.min(n,i+Math.min(n-i,e)),c=new Uint8Array(Math.max(0,(this.position=s)-i));for(;(i+=o)<s&&(a+=o)<c.byteLength;)({bytesRead:o}=yield t.read(c,a,c.byteLength-a,i));return c}return null})}readAt(e,n){return t(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:t,size:r}=this;if(t&&e+n<r){let i=Math.min(r,e+n),a=new Uint8Array(i-e);return(yield t.read(a,0,n,e)).buffer}return new Uint8Array(n)})}close(){return t(this,void 0,void 0,function*(){let e=this._handle;this._handle=null,e&&(yield e.close())})}throw(e){return t(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:e}})}return(e){return t(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:e}})}};function Ba(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}const Va=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];var Ha=class{constructor(e){this.buffer=e}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(e){let t=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([e.buffer[1]>>>16,e.buffer[1]&65535,e.buffer[0]>>>16,e.buffer[0]&65535]),r=t[3]*n[3];this.buffer[0]=r&65535;let i=r>>>16;return r=t[2]*n[3],i+=r,r=t[3]*n[2]>>>0,i+=r,this.buffer[0]+=i<<16,this.buffer[1]=i>>>0<r?65536:0,this.buffer[1]+=i>>>16,this.buffer[1]+=t[1]*n[3]+t[2]*n[2]+t[3]*n[1],this.buffer[1]+=t[0]*n[3]+t[1]*n[2]+t[2]*n[1]+t[3]*n[0]<<16,this}_plus(e){let t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]<e.buffer[1]||this.buffer[1]===e.buffer[1]&&this.buffer[0]<e.buffer[0]}equals(e){return this.buffer[1]===e.buffer[1]&&this.buffer[0]==e.buffer[0]}greaterThan(e){return e.lessThan(this)}hex(){return`${Ba(this.buffer[1])} ${Ba(this.buffer[0])}`}},K=class e extends Ha{times(e){return this._times(e),this}plus(e){return this._plus(e),this}static from(t,n=new Uint32Array(2)){return e.fromString(typeof t==`string`?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return e.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){let r=t.length,i=new e(n);for(let n=0;n<r;){let a=8<r-n?8:r-n,o=new e(new Uint32Array([Number.parseInt(t.slice(n,n+a),10),0])),s=new e(new Uint32Array([Va[a],0]));i.times(s),i.plus(o),n+=a}return i}static convertArray(t){let n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)e.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new e(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new e(new Uint32Array(t.buffer)).plus(n)}},Ua=class e extends Ha{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(e){return this._times(e),this}plus(e){return this._plus(e),this}lessThan(e){let t=this.buffer[1]<<0,n=e.buffer[1]<<0;return t<n||t===n&&this.buffer[0]<e.buffer[0]}static from(t,n=new Uint32Array(2)){return e.fromString(typeof t==`string`?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(2)){return e.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(2)){let r=t.startsWith(`-`),i=t.length,a=new e(n);for(let n=+!!r;n<i;){let r=8<i-n?8:i-n,o=new e(new Uint32Array([Number.parseInt(t.slice(n,n+r),10),0])),s=new e(new Uint32Array([Va[r],0]));a.times(s),a.plus(o),n+=r}return r?a.negate():a}static convertArray(t){let n=new Uint32Array(t.length*2);for(let r=-1,i=t.length;++r<i;)e.from(t[r],new Uint32Array(n.buffer,n.byteOffset+2*r*4,2));return n}static multiply(t,n){return new e(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new e(new Uint32Array(t.buffer)).plus(n)}},Wa=class e{constructor(e){this.buffer=e}high(){return new Ua(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Ua(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(e){let t=new K(new Uint32Array([this.buffer[3],0])),n=new K(new Uint32Array([this.buffer[2],0])),r=new K(new Uint32Array([this.buffer[1],0])),i=new K(new Uint32Array([this.buffer[0],0])),a=new K(new Uint32Array([e.buffer[3],0])),o=new K(new Uint32Array([e.buffer[2],0])),s=new K(new Uint32Array([e.buffer[1],0])),c=new K(new Uint32Array([e.buffer[0],0])),l=K.multiply(i,c);this.buffer[0]=l.low();let u=new K(new Uint32Array([l.high(),0]));return l=K.multiply(r,c),u.plus(l),l=K.multiply(i,s),u.plus(l),this.buffer[1]=u.low(),this.buffer[3]=+!!u.lessThan(l),this.buffer[2]=u.high(),new K(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(K.multiply(n,c)).plus(K.multiply(r,s)).plus(K.multiply(i,o)),this.buffer[3]+=K.multiply(t,c).plus(K.multiply(n,s)).plus(K.multiply(r,o)).plus(K.multiply(i,a)).low(),this}plus(e){let t=new Uint32Array(4);return t[3]=this.buffer[3]+e.buffer[3]>>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]<this.buffer[0]>>>0&&++t[1],t[1]<this.buffer[1]>>>0&&++t[2],t[2]<this.buffer[2]>>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${Ba(this.buffer[3])} ${Ba(this.buffer[2])} ${Ba(this.buffer[1])} ${Ba(this.buffer[0])}`}static multiply(t,n){return new e(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new e(new Uint32Array(t.buffer)).plus(n)}static from(t,n=new Uint32Array(4)){return e.fromString(typeof t==`string`?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return e.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){let r=t.startsWith(`-`),i=t.length,a=new e(n);for(let n=+!!r;n<i;){let r=8<i-n?8:i-n,o=new e(new Uint32Array([Number.parseInt(t.slice(n,n+r),10),0,0,0])),s=new e(new Uint32Array([Va[r],0,0,0]));a.times(s),a.plus(o),n+=r}return r?a.negate():a}static convertArray(t){let n=new Uint32Array(t.length*4);for(let r=-1,i=t.length;++r<i;)e.from(t[r],new Uint32Array(n.buffer,n.byteOffset+16*r,4));return n}},Ga=class extends O{constructor(e,t,n,r,i=h.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=e,this.nodes=t,this.buffers=n,this.dictionaries=r,this.metadataVersion=i}visit(e){return super.visit(e instanceof W?e.type:e)}visitNull(e,{length:t}=this.nextFieldNode()){return L({type:e,length:t})}visitBool(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitInt(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitFloat(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitUtf8(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitLargeUtf8(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitBinary(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitLargeBinary(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),data:this.readData(e)})}visitFixedSizeBinary(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDate(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitTimestamp(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitTime(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDecimal(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitList(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),child:this.visit(e.children[0])})}visitStruct(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),children:this.visitMany(e.children)})}visitUnion(e,{length:t,nullCount:n}=this.nextFieldNode()){return this.metadataVersion<h.V5&&this.readNullBitmap(e,n),e.mode===g.Sparse?this.visitSparseUnion(e,{length:t,nullCount:n}):this.visitDenseUnion(e,{length:t,nullCount:n})}visitDenseUnion(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,typeIds:this.readTypeIds(e),valueOffsets:this.readOffsets(e),children:this.visitMany(e.children)})}visitSparseUnion(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,typeIds:this.readTypeIds(e),children:this.visitMany(e.children)})}visitDictionary(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e.indices),dictionary:this.readDictionary(e)})}visitInterval(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDuration(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitFixedSizeList(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),child:this.visit(e.children[0])})}visitMap(e,{length:t,nullCount:n}=this.nextFieldNode()){return L({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),valueOffsets:this.readOffsets(e),child:this.visit(e.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(e,t,n=this.nextBufferRange()){return t>0&&this.readData(e,n)||new Uint8Array}readOffsets(e,t){return this.readData(e,t)}readTypeIds(e,t){return this.readData(e,t)}readData(e,{length:t,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+t)}readDictionary(e){return this.dictionaries.get(e.id)}},Ka=class extends Ga{constructor(e,t,n,r,i){super(new Uint8Array,t,n,r,i),this.sources=e}readNullBitmap(e,t,{offset:n}=this.nextBufferRange()){return t<=0?new Uint8Array:Yi(this.sources[n])}readOffsets(e,{offset:t}=this.nextBufferRange()){return p(Uint8Array,p(e.OffsetArrayType,this.sources[t]))}readTypeIds(e,{offset:t}=this.nextBufferRange()){return p(Uint8Array,p(e.ArrayType,this.sources[t]))}readData(e,{offset:t}=this.nextBufferRange()){let{sources:n}=this;return T.isTimestamp(e)||(T.isInt(e)||T.isTime(e))&&e.bitWidth===64||T.isDuration(e)||T.isDate(e)&&e.unit===Ie.MILLISECOND?p(Uint8Array,Ua.convertArray(n[t])):T.isDecimal(e)?p(Uint8Array,Wa.convertArray(n[t])):T.isBinary(e)||T.isLargeBinary(e)||T.isFixedSizeBinary(e)?qa(n[t]):T.isBool(e)?Yi(n[t]):T.isUtf8(e)||T.isLargeUtf8(e)?u(n[t].join(``)):p(Uint8Array,p(e.ArrayType,n[t].map(e=>+e)))}};function qa(e){let t=e.join(``),n=new Uint8Array(t.length/2);for(let e=0;e<t.length;e+=2)n[e>>1]=Number.parseInt(t.slice(e,e+2),16);return n}var q=class extends O{compareSchemas(e,t){return e===t||t instanceof e.constructor&&this.compareManyFields(e.fields,t.fields)}compareManyFields(e,t){return e===t||Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>this.compareFields(e,t[n]))}compareFields(e,t){return e===t||t instanceof e.constructor&&e.name===t.name&&e.nullable===t.nullable&&this.visit(e.type,t.type)}};function J(e,t){return t instanceof e.constructor}function Ja(e,t){return e===t||J(e,t)}function Ya(e,t){return e===t||J(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function Xa(e,t){return e===t||J(e,t)&&e.precision===t.precision}function Za(e,t){return e===t||J(e,t)&&e.byteWidth===t.byteWidth}function Qa(e,t){return e===t||J(e,t)&&e.unit===t.unit}function $a(e,t){return e===t||J(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function eo(e,t){return e===t||J(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function to(e,t){return e===t||J(e,t)&&e.children.length===t.children.length&&lo.compareManyFields(e.children,t.children)}function no(e,t){return e===t||J(e,t)&&e.children.length===t.children.length&&lo.compareManyFields(e.children,t.children)}function ro(e,t){return e===t||J(e,t)&&e.mode===t.mode&&e.typeIds.every((e,n)=>e===t.typeIds[n])&&lo.compareManyFields(e.children,t.children)}function io(e,t){return e===t||J(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&lo.visit(e.indices,t.indices)&&lo.visit(e.dictionary,t.dictionary)}function ao(e,t){return e===t||J(e,t)&&e.unit===t.unit}function oo(e,t){return e===t||J(e,t)&&e.unit===t.unit}function so(e,t){return e===t||J(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&lo.compareManyFields(e.children,t.children)}function co(e,t){return e===t||J(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&lo.compareManyFields(e.children,t.children)}q.prototype.visitNull=Ja,q.prototype.visitBool=Ja,q.prototype.visitInt=Ya,q.prototype.visitInt8=Ya,q.prototype.visitInt16=Ya,q.prototype.visitInt32=Ya,q.prototype.visitInt64=Ya,q.prototype.visitUint8=Ya,q.prototype.visitUint16=Ya,q.prototype.visitUint32=Ya,q.prototype.visitUint64=Ya,q.prototype.visitFloat=Xa,q.prototype.visitFloat16=Xa,q.prototype.visitFloat32=Xa,q.prototype.visitFloat64=Xa,q.prototype.visitUtf8=Ja,q.prototype.visitLargeUtf8=Ja,q.prototype.visitBinary=Ja,q.prototype.visitLargeBinary=Ja,q.prototype.visitFixedSizeBinary=Za,q.prototype.visitDate=Qa,q.prototype.visitDateDay=Qa,q.prototype.visitDateMillisecond=Qa,q.prototype.visitTimestamp=$a,q.prototype.visitTimestampSecond=$a,q.prototype.visitTimestampMillisecond=$a,q.prototype.visitTimestampMicrosecond=$a,q.prototype.visitTimestampNanosecond=$a,q.prototype.visitTime=eo,q.prototype.visitTimeSecond=eo,q.prototype.visitTimeMillisecond=eo,q.prototype.visitTimeMicrosecond=eo,q.prototype.visitTimeNanosecond=eo,q.prototype.visitDecimal=Ja,q.prototype.visitList=to,q.prototype.visitStruct=no,q.prototype.visitUnion=ro,q.prototype.visitDenseUnion=ro,q.prototype.visitSparseUnion=ro,q.prototype.visitDictionary=io,q.prototype.visitInterval=ao,q.prototype.visitIntervalDayTime=ao,q.prototype.visitIntervalYearMonth=ao,q.prototype.visitDuration=oo,q.prototype.visitDurationSecond=oo,q.prototype.visitDurationMillisecond=oo,q.prototype.visitDurationMicrosecond=oo,q.prototype.visitDurationNanosecond=oo,q.prototype.visitFixedSizeList=so,q.prototype.visitMap=co;const lo=new q;function uo(e,t){return lo.compareSchemas(e,t)}function fo(e,t){return po(e,t.map(e=>e.data.concat()))}function po(e,t){let n=[...e.fields],r=[],i={numBatches:t.reduce((e,t)=>Math.max(e,t.length),0)},a=0,o=0,s=-1,c=t.length,l,u=[];for(;i.numBatches-->0;){for(o=1/0,s=-1;++s<c;)u[s]=l=t[s].shift(),o=Math.min(o,l?l.length:o);Number.isFinite(o)&&(u=mo(n,o,u,t,i),o>0&&(r[a++]=L({type:new D(n),length:o,nullCount:0,children:u.slice()})))}return[e=e.assign(n),r.map(t=>new Y(e,t))]}function mo(e,t,n,r,i){let a=(t+63&-64)>>3;for(let o=-1,s=r.length;++o<s;){let s=n[o],c=s?.length;if(c>=t)c===t?n[o]=s:(n[o]=s.slice(0,t),i.numBatches=Math.max(i.numBatches,r[o].unshift(s.slice(t,c-t))));else{let r=e[o];e[o]=r.clone({nullable:!0}),n[o]=s?._changeLengthAndBackfillNullBitmap(t)??L({type:r.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return n}var ho,go=class e{constructor(...t){if(t.length===0)return this.batches=[],this.schema=new U([]),this._offsets=[0],this;let n,r;t[0]instanceof U&&(n=t.shift()),t.at(-1)instanceof Uint32Array&&(r=t.pop());let i=t=>{if(t){if(t instanceof Y)return[t];if(t instanceof e)return t.batches;if(t instanceof I){if(t.type instanceof D)return[new Y(new U(t.type.children),t)]}else if(Array.isArray(t))return t.flatMap(e=>i(e));else if(typeof t[Symbol.iterator]==`function`)return[...t].flatMap(e=>i(e));else if(typeof t==`object`){let e=Object.keys(t),r=e.map(e=>new H([t[e]])),[,i]=fo(n??new U(e.map((e,t)=>new W(String(e),r[t].type,r[t].nullable))),r);return i.length===0?[new Y(t)]:i}}return[]},a=t.flatMap(e=>i(e));if(n=n??a[0]?.schema??new U([]),!(n instanceof U))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);for(let e of a){if(!(e instanceof Y))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);if(!uo(n,e.schema))throw TypeError(`Table and inner RecordBatch schemas must be equivalent.`)}this.schema=n,this.batches=a,this._offsets=r??ia(this.data)}get data(){return this.batches.map(({data:e})=>e)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((e,t)=>e+t.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=ra(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(Fi(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?ga.visit(new H(this.data)):[][Symbol.iterator]()}toArray(){return[...this]}toString(){return`[\n ${this.toArray().join(`,
|
|
2
|
+
`)}\n]`}concat(...t){let n=this.schema,r=this.data.concat(t.flatMap(({data:e})=>e));return new e(n,r.map(e=>new Y(n,e)))}slice(t,n){let r=this.schema;[t,n]=Pi({length:this.numRows},t,n);let i=aa(this.data,this._offsets,t,n);return new e(r,i.map(e=>new Y(r,e)))}getChild(e){return this.getChildAt(this.schema.fields.findIndex(t=>t.name===e))}getChildAt(e){if(e>-1&&e<this.schema.fields.length){let t=this.data.map(t=>t.children[e]);if(t.length===0){let{type:n}=this.schema.fields[e],r=L({type:n,length:0,nullCount:0});t.push(r._changeLengthAndBackfillNullBitmap(this.numRows))}return new H(t)}return null}setChild(e,t){return this.setChildAt(this.schema.fields?.findIndex(t=>t.name===e),t)}setChildAt(t,n){let r=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){n||=new H([L({type:new an,length:this.numRows})]);let e=r.fields.slice(),a=e[t].clone({type:n.type}),o=this.schema.fields.map((e,t)=>this.getChildAt(t));[e[t],o[t]]=[a,n],[r,i]=fo(r,o)}return new e(r,i)}select(e){let t=this.schema.fields.reduce((e,t,n)=>e.set(t.name,n),new Map);return this.selectAt(e.map(e=>t.get(e)).filter(e=>e>-1))}selectAt(t){let n=this.schema.selectAt(t),r=this.batches.map(e=>e.selectAt(t));return new e(n,r)}assign(t){let n=this.schema.fields,[r,i]=t.schema.fields.reduce((e,t,r)=>{let[i,a]=e,o=n.findIndex(e=>e.name===t.name);return~o?a[o]=r:i.push(r),e},[[],[]]),a=this.schema.assign(t.schema),o=[...n.map((e,t)=>[t,i[t]]).map(([e,n])=>n===void 0?this.getChildAt(e):t.getChildAt(n)),...r.map(e=>t.getChildAt(e))].filter(Boolean);return new e(...fo(a,o))}};ho=Symbol.toStringTag,go[ho]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=ca(sa),e.get=ca(F.getVisitFn(C.Struct)),e.set=la(j.getVisitFn(C.Struct)),e.indexOf=ua(ma.getVisitFn(C.Struct)),`Table`))(go.prototype);var _o,Y=class e{constructor(...e){switch(e.length){case 2:if([this.schema]=e,!(this.schema instanceof U)||([,this.data=L({nullCount:0,type:new D(this.schema.fields),children:this.schema.fields.map(e=>L({type:e.type,nullCount:0}))})]=e,!(this.data instanceof I)))throw TypeError(`RecordBatch constructor expects a [Schema, Data] pair.`);[this.schema,this.data]=vo(this.schema,this.data.children);break;case 1:{let[t]=e,{fields:n,children:r,length:i}=Object.keys(t).reduce((e,n,r)=>(e.children[r]=t[n],e.length=Math.max(e.length,t[n].length),e.fields[r]=W.new({name:n,type:t[n].type,nullable:!0}),e),{length:0,fields:[],children:[]}),a=new U(n),o=L({type:new D(n),length:i,children:r,nullCount:0});[this.schema,this.data]=vo(a,o.children,i);break}default:throw TypeError(`RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.`)}}get dictionaries(){return this._dictionaries||=yo(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(e){return this.data.getValid(e)}get(e){return F.visit(this.data,e)}at(e){return this.get(Fi(e,this.numRows))}set(e,t){return j.visit(this.data,e,t)}indexOf(e,t){return ma.visit(this.data,e,t)}[Symbol.iterator](){return ga.visit(new H([this.data]))}toArray(){return[...this]}concat(...e){return new go(this.schema,[this,...e])}slice(t,n){let[r]=new H([this.data]).slice(t,n).data;return new e(this.schema,r)}getChild(e){return this.getChildAt(this.schema.fields?.findIndex(t=>t.name===e))}getChildAt(e){return e>-1&&e<this.schema.fields.length?new H([this.data.children[e]]):null}setChild(e,t){return this.setChildAt(this.schema.fields?.findIndex(t=>t.name===e),t)}setChildAt(t,n){let r=this.schema,i=this.data;if(t>-1&&t<this.numCols){n||=new H([L({type:new an,length:this.numRows})]);let e=r.fields.slice(),a=i.children.slice(),o=e[t].clone({type:n.type});[e[t],a[t]]=[o,n.data[0]],r=new U(e,new Map(this.schema.metadata)),i=L({type:new D(e),children:a})}return new e(r,i)}select(t){let n=this.schema.select(t),r=new D(n.fields),i=[];for(let e of t){let t=this.schema.fields.findIndex(t=>t.name===e);~t&&(i[t]=this.data.children[t])}return new e(n,L({type:r,length:this.numRows,children:i}))}selectAt(t){let n=this.schema.selectAt(t),r=t.map(e=>this.data.children[e]).filter(Boolean),i=L({type:new D(n.fields),length:this.numRows,children:r});return new e(n,i)}};_o=Symbol.toStringTag,Y[_o]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,`RecordBatch`))(Y.prototype);function vo(e,t,n=t.reduce((e,t)=>Math.max(e,t.length),0)){let r=[...e.fields],i=[...t],a=(n+63&-64)>>3;for(let[o,s]of e.fields.entries()){let e=t[o];(!e||e.length!==n)&&(r[o]=s.clone({nullable:!0}),i[o]=e?._changeLengthAndBackfillNullBitmap(n)??L({type:s.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[e.assign(r),L({type:new D(r),length:n,children:i})]}function yo(e,t,n=new Map){if((e?.length??0)>0&&e?.length===t?.length)for(let r=-1,i=e.length;++r<i;){let{type:i}=e[r],a=t[r];for(let e of[a,...a?.dictionary?.data||[]])yo(i.children,e?.children,n);if(T.isDictionary(i)){let{id:e}=i;if(!n.has(e))a?.dictionary&&n.set(e,a.dictionary);else if(n.get(e)!==a.dictionary)throw Error(`Cannot create Schema containing two different dictionaries with the same Id`)}}return n}var bo=class extends Y{constructor(e){let t=e.fields.map(e=>L({type:e.type})),n=L({type:new D(e.fields),nullCount:0,children:t});super(e,n)}},xo=class e{constructor(){this.bb=null,this.bb_pos=0}__init(e,t){return this.bb_pos=e,this.bb=t,this}static getRootAsMessage(t,n){return(n||new e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,n){return t.setPosition(t.position()+4),(n||new e).__init(t.readInt32(t.position())+t.position(),t)}version(){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readInt16(this.bb_pos+e):h.V1}headerType(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb_pos+e):S.NONE}header(e){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__union(e,this.bb_pos+t):null}bodyLength(){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb_pos+e):BigInt(`0`)}customMetadata(e,t){let n=this.bb.__offset(this.bb_pos,12);return n?(t||new y).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+e*4),this.bb):null}customMetadataLength(){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__vector_len(this.bb_pos+e):0}static startMessage(e){e.startObject(5)}static addVersion(e,t){e.addFieldInt16(0,t,h.V1)}static addHeaderType(e,t){e.addFieldInt8(1,t,S.NONE)}static addHeader(e,t){e.addFieldOffset(2,t,0)}static addBodyLength(e,t){e.addFieldInt64(3,t,BigInt(`0`))}static addCustomMetadata(e,t){e.addFieldOffset(4,t,0)}static createCustomMetadataVector(e,t){e.startVector(4,t.length,4);for(let n=t.length-1;n>=0;n--)e.addOffset(t[n]);return e.endVector()}static startCustomMetadataVector(e,t){e.startVector(4,t,4)}static endMessage(e){return e.endObject()}static finishMessageBuffer(e,t){e.finish(t)}static finishSizePrefixedMessageBuffer(e,t){e.finish(t,void 0,!0)}static createMessage(t,n,r,i,a,o){return e.startMessage(t),e.addVersion(t,n),e.addHeaderType(t,r),e.addHeader(t,i),e.addBodyLength(t,a),e.addCustomMetadata(t,o),e.endMessage(t)}};const So=new class extends O{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return ht.startNull(t),ht.endNull(t)}visitInt(e,t){return et.startInt(t),et.addBitWidth(t,e.bitWidth),et.addIsSigned(t,e.isSigned),et.endInt(t)}visitFloat(e,t){return lt.startFloatingPoint(t),lt.addPrecision(t,e.precision),lt.endFloatingPoint(t)}visitBinary(e,t){return nt.startBinary(t),nt.endBinary(t)}visitLargeBinary(e,t){return dt.startLargeBinary(t),dt.endLargeBinary(t)}visitBool(e,t){return rt.startBool(t),rt.endBool(t)}visitUtf8(e,t){return bt.startUtf8(t),bt.endUtf8(t)}visitLargeUtf8(e,t){return ft.startLargeUtf8(t),ft.endLargeUtf8(t)}visitDecimal(e,t){return at.startDecimal(t),at.addScale(t,e.scale),at.addPrecision(t,e.precision),at.addBitWidth(t,e.bitWidth),at.endDecimal(t)}visitDate(e,t){return it.startDate(t),it.addUnit(t,e.unit),it.endDate(t)}visitTime(e,t){return _t.startTime(t),_t.addUnit(t,e.unit),_t.addBitWidth(t,e.bitWidth),_t.endTime(t)}visitTimestamp(e,t){let n=e.timezone&&t.createString(e.timezone)||void 0;return vt.startTimestamp(t),vt.addUnit(t,e.unit),n!==void 0&&vt.addTimezone(t,n),vt.endTimestamp(t)}visitInterval(e,t){return ut.startInterval(t),ut.addUnit(t,e.unit),ut.endInterval(t)}visitDuration(e,t){return ot.startDuration(t),ot.addUnit(t,e.unit),ot.endDuration(t)}visitList(e,t){return pt.startList(t),pt.endList(t)}visitStruct(e,t){return gt.startStruct_(t),gt.endStruct_(t)}visitUnion(e,t){yt.startTypeIdsVector(t,e.typeIds.length);let n=yt.createTypeIdsVector(t,e.typeIds);return yt.startUnion(t),yt.addMode(t,e.mode),yt.addTypeIds(t,n),yt.endUnion(t)}visitDictionary(e,t){let n=this.visit(e.indices,t);return tt.startDictionaryEncoding(t),tt.addId(t,BigInt(e.id)),tt.addIsOrdered(t,e.isOrdered),n!==void 0&&tt.addIndexType(t,n),tt.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return st.startFixedSizeBinary(t),st.addByteWidth(t,e.byteWidth),st.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return ct.startFixedSizeList(t),ct.addListSize(t,e.listSize),ct.endFixedSizeList(t)}visitMap(e,t){return mt.startMap(t),mt.addKeysSorted(t,e.keysSorted),mt.endMap(t)}};function Co(e,t=new Map){return new U(Eo(e,t),Mo(e.metadata),t)}function wo(e){return new X(e.count,Oo(e.columns),ko(e.columns))}function To(e){return new Ro(wo(e.data),e.id,e.isDelta)}function Eo(e,t){return(e.fields||[]).filter(Boolean).map(e=>W.fromJSON(e,t))}function Do(e,t){return(e.children||[]).filter(Boolean).map(e=>W.fromJSON(e,t))}function Oo(e){return(e||[]).reduce((e,t)=>[...e,new Bo(t.count,Ao(t.VALIDITY)),...Oo(t.children)],[])}function ko(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){let r=e[n];r.VALIDITY&&t.push(new zo(t.length,r.VALIDITY.length)),r.TYPE_ID&&t.push(new zo(t.length,r.TYPE_ID.length)),r.OFFSET&&t.push(new zo(t.length,r.OFFSET.length)),r.DATA&&t.push(new zo(t.length,r.DATA.length)),t=ko(r.children,t)}return t}function Ao(e){return(e||[]).reduce((e,t)=>e+ +(t===0),0)}function jo(e,t){let n,r,i,a,o,s;return!t||!(a=e.dictionary)?(o=Po(e,Do(e,t)),i=new W(e.name,o,e.nullable,Mo(e.metadata))):t.has(n=a.id)?(r=(r=a.indexType)?No(r):new cn,s=new Fn(t.get(n),r,n,a.isOrdered),i=new W(e.name,s,e.nullable,Mo(e.metadata))):(r=(r=a.indexType)?No(r):new cn,t.set(n,o=Po(e,Do(e,t))),s=new Fn(o,r,n,a.isOrdered),i=new W(e.name,s,e.nullable,Mo(e.metadata))),i||null}function Mo(e=[]){return new Map(e.map(({key:e,value:t})=>[e,t]))}function No(e){return new E(e.isSigned,e.bitWidth)}function Po(e,t){let n=e.type.name;switch(n){case`NONE`:return new an;case`null`:return new an;case`binary`:return new vn;case`largebinary`:return new yn;case`utf8`:return new bn;case`largeutf8`:return new xn;case`bool`:return new Sn;case`list`:return new kn((t||[])[0]);case`struct`:return new D(t||[]);case`struct_`:return new D(t||[])}switch(n){case`int`:{let t=e.type;return new E(t.isSigned,t.bitWidth)}case`floatingpoint`:{let t=e.type;return new mn(_[t.precision])}case`decimal`:{let t=e.type;return new Cn(t.scale,t.precision,t.bitWidth)}case`date`:{let t=e.type;return new wn(Ie[t.unit])}case`time`:{let t=e.type;return new Tn(v[t.unit],t.bitWidth)}case`timestamp`:{let t=e.type;return new En(v[t.unit],t.timezone)}case`interval`:{let t=e.type;return new Dn(Le[t.unit])}case`duration`:{let t=e.type;return new On(v[t.unit])}case`union`:{let n=e.type,[r,...i]=(n.mode+``).toLowerCase(),a=r.toUpperCase()+i.join(``);return new An(g[a],n.typeIds||[],t||[])}case`fixedsizebinary`:{let t=e.type;return new jn(t.byteWidth)}case`fixedsizelist`:{let n=e.type;return new Mn(n.listSize,(t||[])[0])}case`map`:{let n=e.type;return new Nn((t||[])[0],n.keysSorted)}}throw Error(`Unrecognized type: "${n}"`)}var Fo=We,Io=Ue,Lo=class e{static fromJSON(t,n){let r=new e(0,h.V5,n);return r._createHeader=Vo(t,n),r}static decode(t){t=new Io(m(t));let n=xo.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),a=n.headerType(),o=new e(r,i,a);return o._createHeader=Ho(n,a),o}static encode(e){let t=new Fo,n=-1;return e.isSchema()?n=U.encode(t,e.header()):e.isRecordBatch()?n=X.encode(t,e.header()):e.isDictionaryBatch()&&(n=Ro.encode(t,e.header())),xo.startMessage(t),xo.addVersion(t,h.V5),xo.addHeader(t,n),xo.addHeaderType(t,e.headerType),xo.addBodyLength(t,BigInt(e.bodyLength)),xo.finishMessageBuffer(t,xo.endMessage(t)),t.asUint8Array()}static from(t,n=0){if(t instanceof U)return new e(0,h.V5,S.Schema,t);if(t instanceof X)return new e(n,h.V5,S.RecordBatch,t);if(t instanceof Ro)return new e(n,h.V5,S.DictionaryBatch,t);throw Error(`Unrecognized Message header: ${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===S.Schema}isRecordBatch(){return this.headerType===S.RecordBatch}isDictionaryBatch(){return this.headerType===S.DictionaryBatch}constructor(e,t,n,r){this._version=t,this._headerType=n,this.body=new Uint8Array,r&&(this._createHeader=()=>r),this._bodyLength=w(e)}},X=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(e,t,n){this._nodes=t,this._buffers=n,this._length=w(e)}},Ro=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(e,t,n=!1){this._data=e,this._isDelta=n,this._id=w(t)}},zo=class{constructor(e,t){this.offset=w(e),this.length=w(t)}},Bo=class{constructor(e,t){this.length=w(e),this.nullCount=w(t)}};function Vo(e,t){return(()=>{switch(t){case S.Schema:return U.fromJSON(e);case S.RecordBatch:return X.fromJSON(e);case S.DictionaryBatch:return Ro.fromJSON(e)}throw Error(`Unrecognized Message type: { name: ${S[t]}, type: ${t} }`)})}function Ho(e,t){return(()=>{switch(t){case S.Schema:return U.decode(e.header(new xt),new Map,e.version());case S.RecordBatch:return X.decode(e.header(new Xe),e.version());case S.DictionaryBatch:return Ro.decode(e.header(new Ze),e.version())}throw Error(`Unrecognized Message type: { name: ${S[t]}, type: ${t} }`)})}W.encode=rs,W.decode=Qo,W.fromJSON=jo,U.encode=ns,U.decode=Uo,U.fromJSON=Co,X.encode=is,X.decode=Wo,X.fromJSON=wo,Ro.encode=as,Ro.decode=Go,Ro.fromJSON=To,Bo.encode=os,Bo.decode=qo,zo.encode=ss,zo.decode=Ko;function Uo(e,t=new Map,n=h.V5){return new U(Xo(e,t),$o(e),t,n)}function Wo(e,t=h.V5){if(e.compression()!==null)throw Error(`Record batch compression not implemented`);return new X(e.length(),Jo(e),Yo(e,t))}function Go(e,t=h.V5){return new Ro(X.decode(e.data(),t),e.id(),e.isDelta())}function Ko(e){return new zo(e.offset(),e.length())}function qo(e){return new Bo(e.length(),e.nullCount())}function Jo(e){let t=[];for(let n,r=-1,i=-1,a=e.nodesLength();++r<a;)(n=e.nodes(r))&&(t[++i]=Bo.decode(n));return t}function Yo(e,t){let n=[];for(let r,i=-1,a=-1,o=e.buffersLength();++i<o;)(r=e.buffers(i))&&(t<h.V4&&(r.bb_pos+=8*(i+1)),n[++a]=zo.decode(r));return n}function Xo(e,t){let n=[];for(let r,i=-1,a=-1,o=e.fieldsLength();++i<o;)(r=e.fields(i))&&(n[++a]=W.decode(r,t));return n}function Zo(e,t){let n=[];for(let r,i=-1,a=-1,o=e.childrenLength();++i<o;)(r=e.children(i))&&(n[++a]=W.decode(r,t));return n}function Qo(e,t){let n,r,i,a,o,s;return!t||!(s=e.dictionary())?(i=ts(e,Zo(e,t)),r=new W(e.name(),i,e.nullable(),$o(e))):t.has(n=w(s.id()))?(a=(a=s.indexType())?es(a):new cn,o=new Fn(t.get(n),a,n,s.isOrdered()),r=new W(e.name(),o,e.nullable(),$o(e))):(a=(a=s.indexType())?es(a):new cn,t.set(n,i=ts(e,Zo(e,t))),o=new Fn(i,a,n,s.isOrdered()),r=new W(e.name(),o,e.nullable(),$o(e))),r||null}function $o(e){let t=new Map;if(e)for(let n,r,i=-1,a=Math.trunc(e.customMetadataLength());++i<a;)(n=e.customMetadata(i))&&(r=n.key())!=null&&t.set(r,n.value());return t}function es(e){return new E(e.isSigned(),e.bitWidth())}function ts(e,t){let n=e.typeType();switch(n){case b.NONE:return new an;case b.Null:return new an;case b.Binary:return new vn;case b.LargeBinary:return new yn;case b.Utf8:return new bn;case b.LargeUtf8:return new xn;case b.Bool:return new Sn;case b.List:return new kn((t||[])[0]);case b.Struct_:return new D(t||[])}switch(n){case b.Int:{let t=e.type(new et);return new E(t.isSigned(),t.bitWidth())}case b.FloatingPoint:return new mn(e.type(new lt).precision());case b.Decimal:{let t=e.type(new at);return new Cn(t.scale(),t.precision(),t.bitWidth())}case b.Date:return new wn(e.type(new it).unit());case b.Time:{let t=e.type(new _t);return new Tn(t.unit(),t.bitWidth())}case b.Timestamp:{let t=e.type(new vt);return new En(t.unit(),t.timezone())}case b.Interval:return new Dn(e.type(new ut).unit());case b.Duration:return new On(e.type(new ot).unit());case b.Union:{let n=e.type(new yt);return new An(n.mode(),n.typeIdsArray()||[],t||[])}case b.FixedSizeBinary:return new jn(e.type(new st).byteWidth());case b.FixedSizeList:return new Mn(e.type(new ct).listSize(),(t||[])[0]);case b.Map:{let n=e.type(new mt);return new Nn((t||[])[0],n.keysSorted())}}throw Error(`Unrecognized type: "${b[n]}" (${n})`)}function ns(e,t){let n=t.fields.map(t=>W.encode(e,t));xt.startFieldsVector(e,n.length);let r=xt.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?xt.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return y.startKeyValue(e),y.addKey(e,r),y.addValue(e,i),y.endKeyValue(e)})):-1;return xt.startSchema(e),xt.addFields(e,r),xt.addEndianness(e,cs?Qe.Little:Qe.Big),i!==-1&&xt.addCustomMetadata(e,i),xt.endSchema(e)}function rs(e,t){let n=-1,r=-1,i=-1,a=t.type,o=t.typeId;T.isDictionary(a)?(o=a.dictionary.typeId,i=So.visit(a,e),r=So.visit(a.dictionary,e)):r=So.visit(a,e);let s=(a.children||[]).map(t=>W.encode(e,t)),c=x.createChildrenVector(e,s),l=t.metadata&&t.metadata.size>0?x.createCustomMetadataVector(e,[...t.metadata].map(([t,n])=>{let r=e.createString(`${t}`),i=e.createString(`${n}`);return y.startKeyValue(e),y.addKey(e,r),y.addValue(e,i),y.endKeyValue(e)})):-1;return t.name&&(n=e.createString(t.name)),x.startField(e),x.addType(e,r),x.addTypeType(e,o),x.addChildren(e,c),x.addNullable(e,!!t.nullable),n!==-1&&x.addName(e,n),i!==-1&&x.addDictionary(e,i),l!==-1&&x.addCustomMetadata(e,l),x.endField(e)}function is(e,t){let n=t.nodes||[],r=t.buffers||[];Xe.startNodesVector(e,n.length);for(let t of n.slice().reverse())Bo.encode(e,t);let i=e.endVector();Xe.startBuffersVector(e,r.length);for(let t of r.slice().reverse())zo.encode(e,t);let a=e.endVector();return Xe.startRecordBatch(e),Xe.addLength(e,BigInt(t.length)),Xe.addNodes(e,i),Xe.addBuffers(e,a),Xe.endRecordBatch(e)}function as(e,t){let n=X.encode(e,t.data);return Ze.startDictionaryBatch(e),Ze.addId(e,BigInt(t.id)),Ze.addIsDelta(e,t.isDelta),Ze.addData(e,n),Ze.endDictionaryBatch(e)}function os(e,t){return Ye.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function ss(e,t){return Je.createBuffer(e,BigInt(t.offset),BigInt(t.length))}const cs=(()=>{let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),ls=e=>`Expected ${S[e]} Message in stream, but was null or length 0.`,us=e=>`Header pointer of flatbuffer-encoded ${S[e]} Message is null or length 0.`,ds=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,fs=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;var ps=class{constructor(e){this.source=e instanceof Pa?e:new Pa(e)}[Symbol.iterator](){return this}next(){let e;return(e=this.readMetadataLength()).done||e.value===-1&&(e=this.readMetadataLength()).done||(e=this.readMetadata(e.value)).done?G:e}throw(e){return this.source.throw(e)}return(e){return this.source.return(e)}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw Error(ls(e));return t.value}readMessageBody(e){if(e<=0)return new Uint8Array;let t=m(this.source.read(e));if(t.byteLength<e)throw Error(fs(e,t.byteLength));return t.byteOffset%8==0&&t.byteOffset+t.byteLength<=t.buffer.byteLength?t:t.slice()}readSchema(e=!1){let t=S.Schema,n=this.readMessage(t)?.header();if(e&&!n)throw Error(us(t));return n}readMetadataLength(){let e=this.source.read(4),t=(e&&new Ue(e))?.readInt32(0)||0;return{done:t===0,value:t}}readMetadata(e){let t=this.source.read(e);if(!t)return G;if(t.byteLength<e)throw Error(ds(e,t.byteLength));return{done:!1,value:Lo.decode(t)}}},ms=class{constructor(e,t){this.source=e instanceof Fa?e:se(e)?new za(e,t):new Fa(e)}[Symbol.asyncIterator](){return this}next(){return t(this,void 0,void 0,function*(){let e;return(e=yield this.readMetadataLength()).done||e.value===-1&&(e=yield this.readMetadataLength()).done||(e=yield this.readMetadata(e.value)).done?G:e})}throw(e){return t(this,void 0,void 0,function*(){return yield this.source.throw(e)})}return(e){return t(this,void 0,void 0,function*(){return yield this.source.return(e)})}readMessage(e){return t(this,void 0,void 0,function*(){let t;if((t=yield this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw Error(ls(e));return t.value})}readMessageBody(e){return t(this,void 0,void 0,function*(){if(e<=0)return new Uint8Array;let t=m(yield this.source.read(e));if(t.byteLength<e)throw Error(fs(e,t.byteLength));return t.byteOffset%8==0&&t.byteOffset+t.byteLength<=t.buffer.byteLength?t:t.slice()})}readSchema(){return t(this,arguments,void 0,function*(e=!1){let t=S.Schema,n=(yield this.readMessage(t))?.header();if(e&&!n)throw Error(us(t));return n})}readMetadataLength(){return t(this,void 0,void 0,function*(){let e=yield this.source.read(4),t=(e&&new Ue(e))?.readInt32(0)||0;return{done:t===0,value:t}})}readMetadata(e){return t(this,void 0,void 0,function*(){let t=yield this.source.read(e);if(!t)return G;if(t.byteLength<e)throw Error(ds(e,t.byteLength));return{done:!1,value:Lo.decode(t)}})}},hs=class extends ps{constructor(e){super(new Uint8Array),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=e instanceof Aa?e:new Aa(e)}next(){let{_json:e}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Lo.fromJSON(e.schema,S.Schema)};if(this._dictionaryIndex<e.dictionaries.length){let t=e.dictionaries[this._dictionaryIndex++];return this._body=t.data.columns,{done:!1,value:Lo.fromJSON(t,S.DictionaryBatch)}}if(this._batchIndex<e.batches.length){let t=e.batches[this._batchIndex++];return this._body=t.columns,{done:!1,value:Lo.fromJSON(t,S.RecordBatch)}}return this._body=[],G}readMessageBody(e){return t(this._body);function t(e){return(e||[]).reduce((e,n)=>[...e,...n.VALIDITY&&[n.VALIDITY]||[],...n.TYPE_ID&&[n.TYPE_ID]||[],...n.OFFSET&&[n.OFFSET]||[],...n.DATA&&[n.DATA]||[],...t(n.children)],[])}}readMessage(e){let t;if((t=this.next()).done)return null;if(e!=null&&t.value.headerType!==e)throw Error(ls(e));return t.value}readSchema(){let e=S.Schema,t=this.readMessage(e),n=t?.header();if(!t||!n)throw Error(us(e));return n}};const gs=new Uint8Array(6);for(let e=0;e<6;e+=1)gs[e]=`ARROW1`.codePointAt(e);function _s(e,t=0){for(let n=-1,r=gs.length;++n<r;)if(gs[n]!==e[t+n])return!1;return!0}const vs=gs.length,ys=vs+4,bs=vs*2+4;var xs=class e extends ja{constructor(e){super(),this._impl=e}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(e){return this._impl.throw(e)}return(e){return this._impl.return(e)}cancel(){return this._impl.cancel()}reset(e){return this._impl.reset(e),this._DOMStream=void 0,this._nodeStream=void 0,this}open(e){let t=this._impl.open(e);return ne(t)?t.then(()=>this):this}readRecordBatch(e){return this._impl.isFile()?this._impl.readRecordBatch(e):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Oe.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Oe.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(e){throw Error(`"throughNode" not available in this environment`)}static throughDOM(e,t){throw Error(`"throughDOM" not available in this environment`)}static from(n){return n instanceof e?n:ae(n)?Fs(n):se(n)?Rs(n):ne(n)?t(this,void 0,void 0,function*(){return yield e.from(yield n)}):ce(n)||de(n)||pe(n)||ie(n)?Ls(new Fa(n)):Is(new Pa(n))}static readAll(t){return t instanceof e?t.isSync()?Ns(t):Ps(t):ae(t)||ArrayBuffer.isView(t)||re(t)||oe(t)?Ns(t):Ps(t)}},Ss=class extends xs{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return i(this,arguments,function*(){yield r(yield*a(o(this[Symbol.iterator]())))})}},Cs=class extends xs{constructor(e){super(e),this._impl=e}readAll(){return t(this,void 0,void 0,function*(){var e,t,n,r;let i=[];try{for(var a=!0,s=o(this),c;c=yield s.next(),e=c.done,!e;a=!0){r=c.value,a=!1;let e=r;i.push(e)}}catch(e){t={error:e}}finally{try{!a&&!e&&(n=s.return)&&(yield n.call(s))}finally{if(t)throw t.error}}return i})}[Symbol.iterator](){throw Error(`AsyncRecordBatchStreamReader is not Iterable`)}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},ws=class extends Ss{constructor(e){super(e),this._impl=e}},Ts=class extends Cs{constructor(e){super(e),this._impl=e}},Es=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(e=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=e}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(e){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=e,this.dictionaries=new Map,this}_loadRecordBatch(e,t){let n=this._loadVectors(e,t,this.schema.fields),r=L({type:new D(this.schema.fields),length:e.length,children:n});return new Y(this.schema,r)}_loadDictionaryBatch(e,t){let{id:n,isDelta:r}=e,{dictionaries:i,schema:a}=this,o=i.get(n),s=a.dictionaries.get(n),c=this._loadVectors(e.data,t,[s]);return(o&&r?o.concat(new H(c)):new H(c)).memoize()}_loadVectors(e,t,n){return new Ga(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},Ds=class extends Es{constructor(e,t){super(t),this._reader=ae(e)?new hs(this._handle=e):new ps(this._handle=e)}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(e){return this.closed||(this.autoDestroy=Ms(this,e),(this.schema||=this._reader.readSchema())||this.cancel()),this}throw(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(e):G}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):G}next(){if(this.closed)return G;let e,{_reader:t}=this;for(;e=this._readNextMessageAndValidate();)if(e.isSchema())this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let n=e.header(),r=t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(n,r)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let n=e.header(),r=t.readMessageBody(e.bodyLength),i=this._loadDictionaryBatch(n,r);this.dictionaries.set(n.id,i)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new bo(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},Os=class extends Es{constructor(e,t){super(t),this._reader=new ms(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return t(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(e){return t(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Ms(this,e),(this.schema||=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(e){return t(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(e):G})}return(e){return t(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):G})}next(){return t(this,void 0,void 0,function*(){if(this.closed)return G;let e,{_reader:t}=this;for(;e=yield this._readNextMessageAndValidate();)if(e.isSchema())yield this.reset(e.header());else if(e.isRecordBatch()){this._recordBatchIndex++;let n=e.header(),r=yield t.readMessageBody(e.bodyLength);return{done:!1,value:this._loadRecordBatch(n,r)}}else if(e.isDictionaryBatch()){this._dictionaryIndex++;let n=e.header(),r=yield t.readMessageBody(e.bodyLength),i=this._loadDictionaryBatch(n,r);this.dictionaries.set(n.id,i)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new bo(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return t(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},ks=class extends Ds{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,t){super(e instanceof Ra?e:new Ra(e),t)}isSync(){return!0}isFile(){return!0}open(e){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(e)}readRecordBatch(e){if(this.closed)return null;this._footer||this.open();let t=this._footer?.getRecordBatch(e);if(t&&this._handle.seek(t.offset)){let e=this._reader.readMessage(S.RecordBatch);if(e?.isRecordBatch()){let t=e.header(),n=this._reader.readMessageBody(e.bodyLength);return this._loadRecordBatch(t,n)}}return null}_readDictionaryBatch(e){let t=this._footer?.getDictionaryBatch(e);if(t&&this._handle.seek(t.offset)){let e=this._reader.readMessage(S.DictionaryBatch);if(e?.isDictionaryBatch()){let t=e.header(),n=this._reader.readMessageBody(e.bodyLength),r=this._loadDictionaryBatch(t,n);this.dictionaries.set(t.id,r)}}}_readFooter(){let{_handle:e}=this,t=e.size-ys,n=e.readInt32(t),r=e.readAt(t-n,n);return Da.decode(r)}_readNextMessageAndValidate(e){if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let t=this._footer?.getRecordBatch(this._recordBatchIndex);if(t&&this._handle.seek(t.offset))return this._reader.readMessage(e)}return null}},As=class extends Os{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(e,...t){let n=typeof t[0]==`number`?void 0:t.shift(),r=t[0]instanceof Map?t.shift():void 0;super(e instanceof za?e:new za(e,n),r)}isFile(){return!0}isAsync(){return!0}open(e){let n=Object.create(null,{open:{get:()=>super.open}});return t(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield n.open.call(this,e)})}readRecordBatch(e){return t(this,void 0,void 0,function*(){if(this.closed)return null;this._footer||(yield this.open());let t=this._footer?.getRecordBatch(e);if(t&&(yield this._handle.seek(t.offset))){let e=yield this._reader.readMessage(S.RecordBatch);if(e?.isRecordBatch()){let t=e.header(),n=yield this._reader.readMessageBody(e.bodyLength);return this._loadRecordBatch(t,n)}}return null})}_readDictionaryBatch(e){return t(this,void 0,void 0,function*(){let t=this._footer?.getDictionaryBatch(e);if(t&&(yield this._handle.seek(t.offset))){let e=yield this._reader.readMessage(S.DictionaryBatch);if(e?.isDictionaryBatch()){let t=e.header(),n=yield this._reader.readMessageBody(e.bodyLength),r=this._loadDictionaryBatch(t,n);this.dictionaries.set(t.id,r)}}})}_readFooter(){return t(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let t=e.size-ys,n=yield e.readInt32(t),r=yield e.readAt(t-n,n);return Da.decode(r)})}_readNextMessageAndValidate(e){return t(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let t=this._footer.getRecordBatch(this._recordBatchIndex);if(t&&(yield this._handle.seek(t.offset)))return yield this._reader.readMessage(e)}return null})}},js=class extends Ds{constructor(e,t){super(e,t)}_loadVectors(e,t,n){return new Ka(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function Ms(e,t){return t&&typeof t.autoDestroy==`boolean`?t.autoDestroy:e.autoDestroy}function*Ns(e){let t=xs.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Ps(e){return i(this,arguments,function*(){let t=yield r(xs.from(e));try{if(!(yield r(t.open({autoDestroy:!1}))).closed)do yield yield r(t);while(!(yield r(t.reset().open())).closed)}finally{yield r(t.cancel())}})}function Fs(e){return new Ss(new js(e))}function Is(e){let t=e.peek(vs+7&-8);return t&&t.byteLength>=4?_s(t)?new ws(new ks(e.read())):new Ss(new Ds(e)):new Ss(new Ds(function*(){}()))}function Ls(e){return t(this,void 0,void 0,function*(){let t=yield e.peek(vs+7&-8);return t&&t.byteLength>=4?_s(t)?new ws(new ks(yield e.read())):new Cs(new Os(e)):new Cs(new Os(function(){return i(this,arguments,function*(){})}()))})}function Rs(e){return t(this,void 0,void 0,function*(){let{size:t}=yield e.stat(),n=new za(e,t);return t>=bs&&_s(yield n.readAt(0,vs+7&-8))?new Ts(new As(n)):new Cs(new Os(n))})}var Z=class e extends O{static assemble(...t){let n=e=>e.flatMap(e=>Array.isArray(e)?n(e):e instanceof Y?e.data.children:e.data),r=new e;return r.visitMany(n(t)),r}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(e){if(e instanceof H)return this.visitMany(e.data),this;let{type:t}=e;if(!T.isDictionary(t)){let{length:n}=e;if(n>2147483647)throw RangeError(`Cannot write arrays larger than 2^31 - 1 in length`);if(T.isUnion(t))this.nodes.push(new Bo(n,0));else{let{nullCount:r}=e;T.isNull(t)||Q.call(this,r<=0?new Uint8Array:Ji(e.offset,n,e.nullBitmap)),this.nodes.push(new Bo(n,r))}}return super.visit(e)}visitNull(e){return this}visitDictionary(e){return this.visit(e.clone(e.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function Q(e){let t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new zo(this._byteLength,t)),this._byteLength+=t,this}function zs(e){let{type:t,length:n,typeIds:r,valueOffsets:i}=e;if(Q.call(this,r),t.mode===g.Sparse)return Ws.call(this,e);if(t.mode===g.Dense){if(e.offset<=0)return Q.call(this,i),Ws.call(this,e);{let a=new Int32Array(n),o=Object.create(null),s=Object.create(null);for(let e,t,c=-1;++c<n;)(e=r[c])!==void 0&&((t=o[e])===void 0&&(t=o[e]=i[c]),a[c]=i[c]-t,s[e]=(s[e]??0)+1);Q.call(this,a),this.visitMany(e.children.map((e,r)=>{let i=t.typeIds[r],a=o[i],c=s[i];return e.slice(a,Math.min(n,c))}))}}return this}function Bs(e){let t;return e.nullCount>=e.length?Q.call(this,new Uint8Array):(t=e.values)instanceof Uint8Array?Q.call(this,Ji(e.offset,e.length,t)):Q.call(this,Yi(e.values))}function Vs(e){return Q.call(this,e.values.subarray(0,e.length*e.stride))}function Hs(e){let{length:t,values:n,valueOffsets:r}=e,i=w(r[0]),a=w(r[t]),o=Math.min(a-i,n.byteLength-i);return Q.call(this,Ee(-i,t+1,r)),Q.call(this,n.subarray(i,i+o)),this}function Us(e){let{length:t,valueOffsets:n}=e;if(n){let{0:r,[t]:i}=n;return Q.call(this,Ee(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function Ws(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}Z.prototype.visitBool=Bs,Z.prototype.visitInt=Vs,Z.prototype.visitFloat=Vs,Z.prototype.visitUtf8=Hs,Z.prototype.visitLargeUtf8=Hs,Z.prototype.visitBinary=Hs,Z.prototype.visitLargeBinary=Hs,Z.prototype.visitFixedSizeBinary=Vs,Z.prototype.visitDate=Vs,Z.prototype.visitTimestamp=Vs,Z.prototype.visitTime=Vs,Z.prototype.visitDecimal=Vs,Z.prototype.visitList=Us,Z.prototype.visitStruct=Ws,Z.prototype.visitUnion=zs,Z.prototype.visitInterval=Vs,Z.prototype.visitDuration=Vs,Z.prototype.visitFixedSizeList=Us,Z.prototype.visitMap=Us;var Gs=class extends ja{static throughNode(e){throw Error(`"throughNode" not available in this environment`)}static throughDOM(e,t){throw Error(`"throughDOM" not available in this environment`)}constructor(e){super(),this._position=0,this._started=!1,this._sink=new Na,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,f(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy!=`boolean`||e.autoDestroy,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat==`boolean`&&e.writeLegacyIpcFormat}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return ne(e)?e.then(e=>this.writeAll(e)):ie(e)?Ys(this,e):Js(this,e)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(e){return this._sink.toDOMStream(e)}toNodeStream(e){return this._sink.toNodeStream(e)}close(){return this.reset()._sink.close()}abort(e){return this.reset()._sink.abort(e)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(e=this._sink,t=null){return e===this._sink||e instanceof Na?this._sink=e:(this._sink=new Na,e&&ue(e)?this.toDOMStream({type:`bytes`}).pipeTo(e):e&&fe(e)&&this.toNodeStream({objectMode:!1}).pipe(e)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!t||!uo(t,this._schema))&&(t==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=t,this._writeSchema(t))),this}write(e){let t=null;if(!this._sink)throw Error(`RecordBatchWriter is closed`);if(e==null||e instanceof go&&!(t=e.schema)||e instanceof Y&&!(t=e.schema))return this.finish()&&void 0;if(t&&!uo(t,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,t)}e instanceof Y?e instanceof bo||this._writeRecordBatch(e):e instanceof go?this.writeAll(e.batches):re(e)&&this.writeAll(e)}_writeMessage(e,t=8){let n=t-1,r=Lo.encode(e),i=r.byteLength,a=this._writeLegacyIpcFormat?4:8,o=i+a+n&~n,s=o-i-a;return e.headerType===S.RecordBatch?this._recordBatchBlocks.push(new ka(o,e.bodyLength,this._position)):e.headerType===S.DictionaryBatch&&this._dictionaryBlocks.push(new ka(o,e.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(o-a)),i>0&&this._write(r),this._writePadding(s)}_write(e){if(this._started){let t=m(e);t&&t.byteLength>0&&(this._sink.write(t),this._position+=t.byteLength)}return this}_writeSchema(e){return this._writeMessage(Lo.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(gs)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:t,nodes:n,bufferRegions:r,buffers:i}=Z.assemble(e),a=new X(e.numRows,n,r),o=Lo.from(a,t);return this._writeDictionaries(e)._writeMessage(o)._writeBodyBuffers(i)}_writeDictionaryBatch(e,t,n=!1){let{byteLength:r,nodes:i,bufferRegions:a,buffers:o}=Z.assemble(new H([e])),s=new Ro(new X(e.length,i,a),t,n),c=Lo.from(s,r);return this._writeMessage(c)._writeBodyBuffers(o)}_writeBodyBuffers(e){let t,n,r;for(let i=-1,a=e.length;++i<a;)(t=e[i])&&(n=t.byteLength)>0&&(this._write(t),(r=(n+7&-8)-n)>0&&this._writePadding(r));return this}_writeDictionaries(e){for(let[t,n]of e.dictionaries){let e=n?.data??[],r=this._seenDictionaries.get(t),i=this._dictionaryDeltaOffsets.get(t)??0;if(!r||r.data[0]!==e[0])for(let[n,r]of e.entries())this._writeDictionaryBatch(r,t,n>0);else if(i<e.length)for(let n of e.slice(i))this._writeDictionaryBatch(n,t,!0);this._seenDictionaries.set(t,n),this._dictionaryDeltaOffsets.set(t,e.length)}return this}},Ks=class e extends Gs{static writeAll(t,n){let r=new e(n);return ne(t)?t.then(e=>r.writeAll(e)):ie(t)?Ys(r,t):Js(r,t)}},qs=class e extends Gs{static writeAll(t){let n=new e;return ne(t)?t.then(e=>n.writeAll(e)):ie(t)?Ys(n,t):Js(n,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(e){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(e,t,n=!1){if(!n&&this._seenDictionaries.has(t))throw Error(`The Arrow File format does not support replacement dictionaries. `);return super._writeDictionaryBatch(e,t,n)}_writeFooter(e){let t=Da.encode(new Da(e,h.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(t)._write(Int32Array.of(t.byteLength))._writeMagic()}};function Js(e,t){let n=t;t instanceof go&&(n=t.batches,e.reset(void 0,t.schema));for(let t of n)e.write(t);return e.finish()}function Ys(e,n){return t(this,void 0,void 0,function*(){var t,r,i,a,s,c,l;try{for(t=!0,r=o(n);i=yield r.next(),a=i.done,!a;t=!0){l=i.value,t=!1;let n=l;e.write(n)}}catch(e){s={error:e}}finally{try{!t&&!a&&(c=r.return)&&(yield c.call(r))}finally{if(s)throw s.error}}return e.finish()})}function Xs(e,t=`stream`){return(t===`stream`?Ks:qs).writeAll(e).toUint8Array(!0)}var Zs=Object.create,Qs=Object.defineProperty,$s=Object.getOwnPropertyDescriptor,ec=Object.getOwnPropertyNames,tc=Object.getPrototypeOf,nc=Object.prototype.hasOwnProperty,rc=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ic=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of ec(t))!nc.call(e,i)&&i!==n&&Qs(e,i,{get:()=>t[i],enumerable:!(r=$s(t,i))||r.enumerable});return e},ac=(e,t,n)=>(n=e==null?{}:Zs(tc(e)),ic(t||!e||!e.__esModule?Qs(n,`default`,{value:e,enumerable:!0}):n,e)),oc=rc((e,t)=>{t.exports=Worker}),sc=(e=>(e[e.UNDEFINED=0]=`UNDEFINED`,e[e.AUTOMATIC=1]=`AUTOMATIC`,e[e.READ_ONLY=2]=`READ_ONLY`,e[e.READ_WRITE=3]=`READ_WRITE`,e))(sc||{}),cc=(e=>(e[e.IDENTIFIER=0]=`IDENTIFIER`,e[e.NUMERIC_CONSTANT=1]=`NUMERIC_CONSTANT`,e[e.STRING_CONSTANT=2]=`STRING_CONSTANT`,e[e.OPERATOR=3]=`OPERATOR`,e[e.KEYWORD=4]=`KEYWORD`,e[e.COMMENT=5]=`COMMENT`,e))(cc||{}),lc=(e=>(e[e.NONE=0]=`NONE`,e[e.DEBUG=1]=`DEBUG`,e[e.INFO=2]=`INFO`,e[e.WARNING=3]=`WARNING`,e[e.ERROR=4]=`ERROR`,e))(lc||{}),uc=(e=>(e[e.NONE=0]=`NONE`,e[e.CONNECT=1]=`CONNECT`,e[e.DISCONNECT=2]=`DISCONNECT`,e[e.OPEN=3]=`OPEN`,e[e.QUERY=4]=`QUERY`,e[e.INSTANTIATE=5]=`INSTANTIATE`,e))(uc||{}),dc=(e=>(e[e.NONE=0]=`NONE`,e[e.OK=1]=`OK`,e[e.ERROR=2]=`ERROR`,e[e.START=3]=`START`,e[e.RUN=4]=`RUN`,e[e.CAPTURE=5]=`CAPTURE`,e))(dc||{}),fc=(e=>(e[e.NONE=0]=`NONE`,e[e.WEB_WORKER=1]=`WEB_WORKER`,e[e.NODE_WORKER=2]=`NODE_WORKER`,e[e.BINDINGS=3]=`BINDINGS`,e[e.ASYNC_DUCKDB=4]=`ASYNC_DUCKDB`,e))(fc||{}),pc=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}},mc=(e=>(e[e.SUCCESS=0]=`SUCCESS`,e[e.MAX_ARROW_ERROR=255]=`MAX_ARROW_ERROR`,e[e.DUCKDB_WASM_RETRY=256]=`DUCKDB_WASM_RETRY`,e))(mc||{}),hc=class{constructor(e,t){this._bindings=e,this._conn=t}get bindings(){return this._bindings}async close(){return this._bindings.disconnect(this._conn)}useUnsafe(e){return e(this._bindings,this._conn)}async query(e){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let t=await this._bindings.runQuery(this._conn,e),n=xs.from(t);return console.assert(n.isSync(),`Reader is not sync`),console.assert(n.isFile(),`Reader is not file`),new go(n)}async send(e,t=!1){this._bindings.logger.log({timestamp:new Date,level:2,origin:4,topic:4,event:4,value:e});let n=await this._bindings.startPendingQuery(this._conn,e,t);for(;n==null;){if(this._bindings.isDetached()){console.error(`cannot send a message since the worker is not set!`);return}n=await this._bindings.pollPendingQuery(this._conn)}let r=new gc(this._bindings,this._conn,n),i=await xs.from(r);return console.assert(i.isAsync()),console.assert(i.isStream()),i}async cancelSent(){return await this._bindings.cancelPendingQuery(this._conn)}async getTableNames(e){return await this._bindings.getTableNames(this._conn,e)}async prepare(e){let t=await this._bindings.createPrepared(this._conn,e);return new _c(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=Xs(e,`stream`);await this.insertArrowFromIPCStream(n,t)}async insertArrowFromIPCStream(e,t){await this._bindings.insertArrowFromIPCStream(this._conn,e,t)}async insertCSVFromPath(e,t){await this._bindings.insertCSVFromPath(this._conn,e,t)}async insertJSONFromPath(e,t){await this._bindings.insertJSONFromPath(this._conn,e,t)}},gc=class{constructor(e,t,n){this.db=e,this.conn=t,this.header=n,this._first=!0,this._depleted=!1,this._inFlight=null}async next(){if(this._first)return this._first=!1,{done:!1,value:this.header};if(this._depleted)return{done:!0,value:null};let e=null;for(this._inFlight!=null&&(e=await this._inFlight,this._inFlight=null);e==null;)e=await this.db.fetchQueryResults(this.conn);return this._depleted=e.length==0,this._depleted||(this._inFlight=this.db.fetchQueryResults(this.conn)),{done:this._depleted,value:e}}[Symbol.asyncIterator](){return this}},_c=class{constructor(e,t,n){this.bindings=e,this.connectionId=t,this.statementId=n}async close(){await this.bindings.closePrepared(this.connectionId,this.statementId)}async query(...e){let t=await this.bindings.runPrepared(this.connectionId,this.statementId,e),n=xs.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new go(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new gc(this.bindings,this.connectionId,t),r=await xs.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},vc=(e=>(e.CANCEL_PENDING_QUERY=`CANCEL_PENDING_QUERY`,e.CLOSE_PREPARED=`CLOSE_PREPARED`,e.COLLECT_FILE_STATISTICS=`COLLECT_FILE_STATISTICS`,e.REGISTER_OPFS_FILE_NAME=`REGISTER_OPFS_FILE_NAME`,e.CONNECT=`CONNECT`,e.COPY_FILE_TO_BUFFER=`COPY_FILE_TO_BUFFER`,e.COPY_FILE_TO_PATH=`COPY_FILE_TO_PATH`,e.CREATE_PREPARED=`CREATE_PREPARED`,e.DISCONNECT=`DISCONNECT`,e.DROP_FILE=`DROP_FILE`,e.DROP_FILES=`DROP_FILES`,e.EXPORT_FILE_STATISTICS=`EXPORT_FILE_STATISTICS`,e.FETCH_QUERY_RESULTS=`FETCH_QUERY_RESULTS`,e.FLUSH_FILES=`FLUSH_FILES`,e.GET_FEATURE_FLAGS=`GET_FEATURE_FLAGS`,e.GET_TABLE_NAMES=`GET_TABLE_NAMES`,e.GET_VERSION=`GET_VERSION`,e.GLOB_FILE_INFOS=`GLOB_FILE_INFOS`,e.INSERT_ARROW_FROM_IPC_STREAM=`INSERT_ARROW_FROM_IPC_STREAM`,e.INSERT_CSV_FROM_PATH=`IMPORT_CSV_FROM_PATH`,e.INSERT_JSON_FROM_PATH=`IMPORT_JSON_FROM_PATH`,e.INSTANTIATE=`INSTANTIATE`,e.OPEN=`OPEN`,e.PING=`PING`,e.POLL_PENDING_QUERY=`POLL_PENDING_QUERY`,e.REGISTER_FILE_BUFFER=`REGISTER_FILE_BUFFER`,e.REGISTER_FILE_HANDLE=`REGISTER_FILE_HANDLE`,e.REGISTER_FILE_URL=`REGISTER_FILE_URL`,e.RESET=`RESET`,e.RUN_PREPARED=`RUN_PREPARED`,e.RUN_QUERY=`RUN_QUERY`,e.SEND_PREPARED=`SEND_PREPARED`,e.START_PENDING_QUERY=`START_PENDING_QUERY`,e.TOKENIZE=`TOKENIZE`,e))(vc||{}),yc=(e=>(e.CONNECTION_INFO=`CONNECTION_INFO`,e.ERROR=`ERROR`,e.FEATURE_FLAGS=`FEATURE_FLAGS`,e.FILE_BUFFER=`FILE_BUFFER`,e.FILE_INFOS=`FILE_INFOS`,e.FILE_SIZE=`FILE_SIZE`,e.FILE_STATISTICS=`FILE_STATISTICS`,e.INSTANTIATE_PROGRESS=`INSTANTIATE_PROGRESS`,e.LOG=`LOG`,e.PROGRESS_UPDATE=`PROGRESS_UPDATE`,e.OK=`OK`,e.PREPARED_STATEMENT_ID=`PREPARED_STATEMENT_ID`,e.QUERY_PLAN=`QUERY_PLAN`,e.QUERY_RESULT=`QUERY_RESULT`,e.QUERY_RESULT_CHUNK=`QUERY_RESULT_CHUNK`,e.QUERY_RESULT_HEADER=`QUERY_RESULT_HEADER`,e.QUERY_RESULT_HEADER_OR_NULL=`QUERY_RESULT_HEADER_OR_NULL`,e.REGISTERED_FILE=`REGISTERED_FILE`,e.SCRIPT_TOKENS=`SCRIPT_TOKENS`,e.SUCCESS=`SUCCESS`,e.TABLE_NAMES=`TABLE_NAMES`,e.VERSION_STRING=`VERSION_STRING`,e))(yc||{}),$=class{constructor(e,t){this.promiseResolver=()=>{},this.promiseRejecter=()=>{},this.type=e,this.data=t,this.promise=new Promise((e,t)=>{this.promiseResolver=e,this.promiseRejecter=t})}};function bc(e){switch(e.typeId){case C.Binary:return{sqlType:`binary`};case C.Bool:return{sqlType:`bool`};case C.Date:return{sqlType:`date`};case C.DateDay:return{sqlType:`date32[d]`};case C.DateMillisecond:return{sqlType:`date64[ms]`};case C.Decimal:{let t=e;return{sqlType:`decimal`,precision:t.precision,scale:t.scale}}case C.Float:return{sqlType:`float`};case C.Float16:return{sqlType:`float16`};case C.Float32:return{sqlType:`float32`};case C.Float64:return{sqlType:`float64`};case C.Int:return{sqlType:`int32`};case C.Int16:return{sqlType:`int16`};case C.Int32:return{sqlType:`int32`};case C.Int64:return{sqlType:`int64`};case C.Uint16:return{sqlType:`uint16`};case C.Uint32:return{sqlType:`uint32`};case C.Uint64:return{sqlType:`uint64`};case C.Uint8:return{sqlType:`uint8`};case C.IntervalDayTime:return{sqlType:`interval[dt]`};case C.IntervalYearMonth:return{sqlType:`interval[m]`};case C.List:return{sqlType:`list`,valueType:bc(e.valueType)};case C.FixedSizeBinary:return{sqlType:`fixedsizebinary`,byteWidth:e.byteWidth};case C.Null:return{sqlType:`null`};case C.Utf8:return{sqlType:`utf8`};case C.Struct:return{sqlType:`struct`,fields:e.children.map(e=>xc(e.name,e.type))};case C.Map:{let t=e;return{sqlType:`map`,keyType:bc(t.keyType),valueType:bc(t.valueType)}}case C.Time:return{sqlType:`time[s]`};case C.TimeMicrosecond:return{sqlType:`time[us]`};case C.TimeMillisecond:return{sqlType:`time[ms]`};case C.TimeNanosecond:return{sqlType:`time[ns]`};case C.TimeSecond:return{sqlType:`time[s]`};case C.Timestamp:return{sqlType:`timestamp`,timezone:e.timezone||void 0};case C.TimestampSecond:return{sqlType:`timestamp[s]`,timezone:e.timezone||void 0};case C.TimestampMicrosecond:return{sqlType:`timestamp[us]`,timezone:e.timezone||void 0};case C.TimestampNanosecond:return{sqlType:`timestamp[ns]`,timezone:e.timezone||void 0};case C.TimestampMillisecond:return{sqlType:`timestamp[ms]`,timezone:e.timezone||void 0}}throw Error(`unsupported arrow type: ${e.toString()}`)}function xc(e,t){let n=bc(t);return n.name=e,n}var Sc=/'(opfs:\/\/\S*?)'/g,Cc=/(opfs:\/\/\S*?)/g;function wc(e){return e.search(Cc)>-1}function Tc(e){return[...e.matchAll(Sc)].map(e=>e[1])}var Ec=new TextEncoder,Dc=class{constructor(e,t=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._config={},this._logger=e,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),t!=null&&this.attach(t)}get logger(){return this._logger}get config(){return this._config}attach(e){this._worker=e,this._worker.addEventListener(`message`,this._onMessageHandler),this._worker.addEventListener(`error`,this._onErrorHandler),this._worker.addEventListener(`close`,this._onCloseHandler),this._workerShutdownPromise=new Promise((e,t)=>{this._workerShutdownResolver=e})}detach(){this._worker&&(this._worker.removeEventListener(`message`,this._onMessageHandler),this._worker.removeEventListener(`error`,this._onErrorHandler),this._worker.removeEventListener(`close`,this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(e,t=[]){if(!this._worker){console.error(`cannot send a message since the worker is not set!:`+e.type+`,`+e.data);return}let n=this._nextMessageId++;return this._pendingRequests.set(n,e),this._worker.postMessage({messageId:n,type:e.type,data:e.data},t),await e.promise}onMessage(e){var t;let n=e.data;switch(n.type){case`PROGRESS_UPDATE`:for(let e of this._onExecutionProgress)e(n.data);return;case`LOG`:this._logger.log(n.data);return;case`INSTANTIATE_PROGRESS`:for(let e of this._onInstantiationProgress)e(n.data);return}let r=this._pendingRequests.get(n.requestId);if(!r){console.warn(`unassociated response: [${n.requestId}, ${n.type.toString()}]`);return}if(this._pendingRequests.delete(n.requestId),n.type==`ERROR`){let e=Error(n.data.message);e.name=n.data.name,(t=Object.getOwnPropertyDescriptor(e,`stack`))!=null&&t.writable&&(e.stack=n.data.stack),r.promiseRejecter(e);return}switch(r.type){case`CLOSE_PREPARED`:case`COLLECT_FILE_STATISTICS`:case`REGISTER_OPFS_FILE_NAME`:case`COPY_FILE_TO_PATH`:case`DISCONNECT`:case`DROP_FILE`:case`DROP_FILES`:case`FLUSH_FILES`:case`INSERT_ARROW_FROM_IPC_STREAM`:case`IMPORT_CSV_FROM_PATH`:case`IMPORT_JSON_FROM_PATH`:case`OPEN`:case`PING`:case`REGISTER_FILE_BUFFER`:case`REGISTER_FILE_HANDLE`:case`REGISTER_FILE_URL`:case`RESET`:if(n.type==`OK`){r.promiseResolver(n.data);return}break;case`INSTANTIATE`:if(this._onInstantiationProgress=[],n.type==`OK`){r.promiseResolver(n.data);return}break;case`GLOB_FILE_INFOS`:if(n.type==`FILE_INFOS`){r.promiseResolver(n.data);return}break;case`GET_VERSION`:if(n.type==`VERSION_STRING`){r.promiseResolver(n.data);return}break;case`GET_FEATURE_FLAGS`:if(n.type==`FEATURE_FLAGS`){r.promiseResolver(n.data);return}break;case`GET_TABLE_NAMES`:if(n.type==`TABLE_NAMES`){r.promiseResolver(n.data);return}break;case`TOKENIZE`:if(n.type==`SCRIPT_TOKENS`){r.promiseResolver(n.data);return}break;case`COPY_FILE_TO_BUFFER`:if(n.type==`FILE_BUFFER`){r.promiseResolver(n.data);return}break;case`EXPORT_FILE_STATISTICS`:if(n.type==`FILE_STATISTICS`){r.promiseResolver(n.data);return}break;case`CONNECT`:if(n.type==`CONNECTION_INFO`){r.promiseResolver(n.data);return}break;case`RUN_PREPARED`:case`RUN_QUERY`:if(n.type==`QUERY_RESULT`){r.promiseResolver(n.data);return}break;case`SEND_PREPARED`:if(n.type==`QUERY_RESULT_HEADER`){r.promiseResolver(n.data);return}break;case`START_PENDING_QUERY`:if(n.type==`QUERY_RESULT_HEADER_OR_NULL`){r.promiseResolver(n.data);return}break;case`POLL_PENDING_QUERY`:if(n.type==`QUERY_RESULT_HEADER_OR_NULL`){r.promiseResolver(n.data);return}break;case`CANCEL_PENDING_QUERY`:if(this._onInstantiationProgress=[],n.type==`SUCCESS`){r.promiseResolver(n.data);return}break;case`FETCH_QUERY_RESULTS`:if(n.type==`QUERY_RESULT_CHUNK`){r.promiseResolver(n.data);return}break;case`CREATE_PREPARED`:if(n.type==`PREPARED_STATEMENT_ID`){r.promiseResolver(n.data);return}}r.promiseRejecter(Error(`unexpected response type: ${n.type.toString()}`))}onError(e){console.error(e),console.error(`error in duckdb worker: ${e.message}`),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn(`worker terminated with ${this._pendingRequests.size} pending requests`);return}this._pendingRequests.clear()}isDetached(){return!this._worker}async reset(){let e=new $(`RESET`,null);return await this.postTask(e)}async ping(){let e=new $(`PING`,null);await this.postTask(e)}async dropFile(e){let t=new $(`DROP_FILE`,e);return await this.postTask(t)}async dropFiles(e){let t=new $(`DROP_FILES`,e);return await this.postTask(t)}async flushFiles(){let e=new $(`FLUSH_FILES`,null);return await this.postTask(e)}async instantiate(e,t=null,n=e=>{}){this._onInstantiationProgress.push(n);let r=new $(`INSTANTIATE`,[e,t]);return await this.postTask(r)}async getVersion(){let e=new $(`GET_VERSION`,null);return await this.postTask(e)}async getFeatureFlags(){let e=new $(`GET_FEATURE_FLAGS`,null);return await this.postTask(e)}async open(e){this._config=e;let t=new $(`OPEN`,e);await this.postTask(t)}async tokenize(e){let t=new $(`TOKENIZE`,e);return await this.postTask(t)}async connectInternal(){let e=new $(`CONNECT`,null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new hc(this,e)}async disconnect(e){let t=new $(`DISCONNECT`,e);await this.postTask(t)}async runQuery(e,t){if(this.shouldOPFSFileHandling()){let n=await this.registerOPFSFileFromSQL(t);try{return await this._runQueryAsync(e,t)}finally{n.length>0&&await this.dropFiles(n)}}return await this._runQueryAsync(e,t)}async _runQueryAsync(e,t){let n=new $(`RUN_QUERY`,[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){if(this.shouldOPFSFileHandling()){let r=await this.registerOPFSFileFromSQL(t);try{return await this._startPendingQueryAsync(e,t,n)}finally{r.length>0&&await this.dropFiles(r)}}return await this._startPendingQueryAsync(e,t,n)}async _startPendingQueryAsync(e,t,n=!1){let r=new $(`START_PENDING_QUERY`,[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new $(`POLL_PENDING_QUERY`,e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new $(`CANCEL_PENDING_QUERY`,e);return await this.postTask(t)}async fetchQueryResults(e){let t=new $(`FETCH_QUERY_RESULTS`,e);return await this.postTask(t)}async getTableNames(e,t){let n=new $(`GET_TABLE_NAMES`,[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new $(`CREATE_PREPARED`,[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new $(`CLOSE_PREPARED`,[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new $(`RUN_PREPARED`,[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new $(`SEND_PREPARED`,[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new $(`GLOB_FILE_INFOS`,e);return await this.postTask(t)}async registerFileText(e,t){let n=Ec.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new $(`REGISTER_FILE_URL`,[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new $(`REGISTER_FILE_BUFFER`,[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new $(`REGISTER_FILE_HANDLE`,[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new $(`REGISTER_OPFS_FILE_NAME`,[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new $(`COLLECT_FILE_STATISTICS`,[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new $(`EXPORT_FILE_STATISTICS`,e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new $(`COPY_FILE_TO_BUFFER`,e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new $(`COPY_FILE_TO_PATH`,[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new $(`INSERT_ARROW_FROM_IPC_STREAM`,[e,t,n]);await this.postTask(r,[t.buffer])}async insertCSVFromPath(e,t,n){if(n.columns!==void 0){let e=[];for(let t in n.columns){let r=n.columns[t];e.push(xc(t,r))}n.columnsFlat=e,delete n.columns}let r=new $(`IMPORT_CSV_FROM_PATH`,[e,t,n]);await this.postTask(r)}async insertJSONFromPath(e,t,n){if(n.columns!==void 0){let e=[];for(let t in n.columns){let r=n.columns[t];e.push(xc(t,r))}n.columnsFlat=e,delete n.columns}let r=new $(`IMPORT_JSON_FROM_PATH`,[e,t,n]);await this.postTask(r)}shouldOPFSFileHandling(){return wc(this.config.path??``)?this.config.opfs?.fileHandling==`auto`:!1}async registerOPFSFileFromSQL(e){let t=Tc(e),n=[];for(let e of t)try{await this.registerOPFSFileName(e),n.push(e)}catch(t){throw console.error(t),Error(`File Not found:`+e)}return n}};function Oc(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<`u`&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}Oc();var kc=(e=>(e[e.BUFFER=0]=`BUFFER`,e[e.NODE_FS=1]=`NODE_FS`,e[e.BROWSER_FILEREADER=2]=`BROWSER_FILEREADER`,e[e.BROWSER_FSACCESS=3]=`BROWSER_FSACCESS`,e[e.HTTP=4]=`HTTP`,e[e.S3=5]=`S3`,e))(kc||{}),Ac={name:`@duckdb/duckdb-wasm`,version:`1.32.0`,description:`DuckDB powered by WebAssembly`,license:`MIT`,repository:{type:`git`,url:`https://github.com/duckdb/duckdb-wasm.git`},keywords:[`sql`,`duckdb`,`relational`,`database`,`data`,`query`,`wasm`,`analytics`,`olap`,`arrow`,`parquet`,`json`,`csv`],dependencies:{"apache-arrow":`^17.0.0`},devDependencies:{"@types/emscripten":`^1.39.10`,"@types/jasmine":`^5.1.4`,"@typescript-eslint/eslint-plugin":`^6.21.0`,"@typescript-eslint/parser":`^6.21.0`,esbuild:`^0.20.2`,eslint:`^8.57.0`,"eslint-plugin-jasmine":`^4.1.3`,"eslint-plugin-react":`^7.34.0`,"fast-glob":`^3.3.2`,jasmine:`^5.1.0`,"jasmine-core":`^5.1.2`,"jasmine-spec-reporter":`^7.0.0`,"js-sha256":`^0.11.1`,karma:`^6.4.2`,"karma-chrome-launcher":`^3.2.0`,"karma-coverage":`^2.2.1`,"karma-firefox-launcher":`^2.1.3`,"karma-jasmine":`^5.1.0`,"karma-jasmine-html-reporter":`^2.1.0`,"karma-sourcemap-loader":`^0.4.0`,"karma-spec-reporter":`^0.0.36`,"make-dir":`^4.0.0`,nyc:`^15.1.0`,prettier:`^3.2.5`,puppeteer:`^22.8.0`,rimraf:`^5.0.5`,s3rver:`^3.7.1`,typedoc:`^0.25.13`,typescript:`^5.3.3`,"wasm-feature-detect":`^1.6.1`,"web-worker":`^1.2.0`},scripts:{"build:debug":`node bundle.mjs debug && tsc --emitDeclarationOnly`,"build:release":`node bundle.mjs release && tsc --emitDeclarationOnly`,docs:`typedoc`,format:`prettier --write "**/*.+(js|ts)"`,report:`node ./coverage.mjs`,"test:node":`node --enable-source-maps ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs`,"test:node:debug":`node --inspect-brk --enable-source-maps ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs`,"test:node:coverage":`nyc -r json --report-dir ./coverage/node node ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs`,"test:firefox":`karma start ./karma/tests-firefox.cjs`,"test:chrome":`karma start ./karma/tests-chrome.cjs`,"test:chrome:eh":`karma start ./karma/tests-chrome-eh.cjs`,"test:chrome:coverage":`karma start ./karma/tests-chrome-coverage.cjs`,"test:browser":`karma start ./karma/tests-all.cjs`,"test:browser:debug":`karma start ./karma/tests-debug.cjs`,test:`npm run test:chrome && npm run test:node`,"test:coverage":`npm run test:chrome:coverage && npm run test:node:coverage && npm run report`,lint:`eslint src test`},files:[`dist`,`!dist/tests-*`,`!dist/duckdb-browser-mvp.worker.js.map`,`!dist/types/test`],main:`dist/duckdb-browser.cjs`,module:`dist/duckdb-browser.mjs`,types:`dist/duckdb-browser.d.ts`,jsdelivr:`dist/duckdb-browser.cjs`,unpkg:`dist/duckdb-browser.mjs`,sideEffects:!1,browser:{fs:!1,path:!1,perf_hooks:!1,os:!1,worker_threads:!1},exports:{"./dist/duckdb-mvp.wasm":`./dist/duckdb-mvp.wasm`,"./dist/duckdb-eh.wasm":`./dist/duckdb-eh.wasm`,"./dist/duckdb-coi.wasm":`./dist/duckdb-coi.wasm`,"./dist/duckdb-browser":`./dist/duckdb-browser.mjs`,"./dist/duckdb-browser.cjs":`./dist/duckdb-browser.cjs`,"./dist/duckdb-browser.mjs":`./dist/duckdb-browser.mjs`,"./dist/duckdb-browser-coi.pthread.worker.js":`./dist/duckdb-browser-coi.pthread.worker.js`,"./dist/duckdb-browser-coi.worker.js":`./dist/duckdb-browser-coi.worker.js`,"./dist/duckdb-browser-eh.worker.js":`./dist/duckdb-browser-eh.worker.js`,"./dist/duckdb-browser-mvp.worker.js":`./dist/duckdb-browser-mvp.worker.js`,"./dist/duckdb-node":`./dist/duckdb-node.cjs`,"./dist/duckdb-node.cjs":`./dist/duckdb-node.cjs`,"./dist/duckdb-node-blocking":`./dist/duckdb-node-blocking.cjs`,"./dist/duckdb-node-blocking.cjs":`./dist/duckdb-node-blocking.cjs`,"./dist/duckdb-node-eh.worker.cjs":`./dist/duckdb-node-eh.worker.cjs`,"./dist/duckdb-node-mvp.worker.cjs":`./dist/duckdb-node-mvp.worker.cjs`,"./blocking":{node:{types:`./dist/duckdb-node-blocking.d.ts`,require:`./dist/duckdb-node-blocking.cjs`,import:`./dist/duckdb-node-blocking.cjs`},types:`./dist/duckdb-node-blocking.d.ts`,import:`./dist/duckdb-node-blocking.mjs`,require:`./dist/duckdb-node-blocking.cjs`},".":{browser:{types:`./dist/duckdb-browser.d.ts`,import:`./dist/duckdb-browser.mjs`,require:`./dist/duckdb-browser.cjs`},node:{types:`./dist/duckdb-node.d.ts`,import:`./dist/duckdb-node.cjs`,require:`./dist/duckdb-node.cjs`},types:`./dist/duckdb-browser.d.ts`,import:`./dist/duckdb-browser.mjs`,require:`./dist/duckdb-browser.cjs`}}};Ac.name,Ac.version;var jc=Ac.version.split(`.`);jc[0],jc[1],jc[2],ac(oc());const Mc=`wasm`,Nc=new URL(`../duckdb/`,self.location.href);let Pc=null,Fc=null,Ic=0;const Lc=new WeakMap;async function Rc(t){let n=await zc();await Vc(n,await Bc(n,t));let r=await n.connect(),i=async e=>(await r.query(e)).toArray().map(e=>e.toJSON());return{query:i,exec:e=>r.query(e),run:e=>r.query(e),close:()=>r.close(),...e(i)}}async function zc(){if(Pc===null){let e=await Uc(),[t,n]=await Promise.all([Kc(e,`worker`,new URL(`duckdb-browser-eh.worker.js`,Nc).href),Kc(e,`wasm`,new URL(`duckdb-eh.wasm`,Nc).href)]),r=new Dc(new pc,new Worker(t));await r.instantiate(n),Pc=r}return Pc}async function Bc(e,t){if(Lc.has(t))return Lc.get(t);{Ic+=1;let n=`db-${Ic}.duckdb`;return await e.registerFileBuffer(n,new Uint8Array(await Hc(t))),Lc.set(t,n),n}}async function Vc(e,t){Fc===t||(await e.open({path:t,accessMode:sc.READ_ONLY}),Fc=t)}async function Hc(e){return e instanceof ArrayBuffer?e:e.arrayBuffer?await e.arrayBuffer():e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}async function Uc(){return new Promise((e,t)=>{let n=indexedDB.open(`duckdb-cache`,1);n.onupgradeneeded=e=>e.target.result.createObjectStore(Mc),n.onsuccess=t=>e(t.target.result),n.onerror=t})}async function Wc(e,t){return new Promise(n=>{let r=e.transaction(Mc).objectStore(Mc).get(t);r.onsuccess=e=>n(e.target.result),r.onerror=()=>n(null)})}async function Gc(e,t,n){return new Promise((r,i)=>{let a=e.transaction(Mc,`readwrite`);a.objectStore(Mc).put(n,t),a.oncomplete=r,a.onerror=i})}async function Kc(e,t,n){let r=await Wc(e,t);r||(r=await(await fetch(n)).arrayBuffer(),await Gc(e,t,r));let i=t===`wasm`?`application/wasm`:`text/javascript`;return URL.createObjectURL(new Blob([r],{type:i}))}export{Rc as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=typeof process<`u`&&process.versions!=null&&process.versions.node!=null;async function t(t){if(e){let e=(await import(`./node.js`)).default;return await e(t)}{let e=(await import(`./browser.js`)).default;return await e(t)}}async function n(e,n,r=``){let i=await t(e);try{return await i.getEntries(n,r)}finally{await i.close()}}async function r(e,n,r=0,i=1e3){let a=await t(e);try{return await a.getEntry(n,r,i)}finally{await a.close()}}export{t as default,n as getEntries,r as getEntry};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
function e(e){return`"${String(e).replaceAll(`"`,`""`)}"`}function t(e){return`'${String(e).replaceAll(`'`,`''`)}'`}function n(e){let t=String(e||``).split(`/`).filter(Boolean);return t.length>1?{schema:t[0],table:t[1]}:{schema:`main`,table:t[0]}}function r(e){let t={};for(let n of Object.keys(e)){let r=e[n];t[n]=typeof r==`bigint`?Number(r):r}return t}function i(i){return{getEntries:a,getEntry:c};async function a(e,t=``){let n=String(t||``).split(`/`).filter(Boolean);return n.length===0?await o(e):n.length===1?await s(e,n[0]):[]}async function o(e){return(await i(`SELECT schema_name FROM duckdb_schemas() WHERE database_name = current_database() ORDER BY schema_name`)).map(t=>({name:t.schema_name,label:t.schema_name,type:`schema`,objectKind:`folder`,path:`${e}/${t.schema_name}`}))}async function s(e,n){return(await i(`SELECT table_name AS name,
|
|
2
|
+
CASE WHEN table_type = 'VIEW' THEN 'view' ELSE 'table' END AS type
|
|
3
|
+
FROM information_schema.tables
|
|
4
|
+
WHERE table_catalog = current_database() AND table_schema = ${t(n)}
|
|
5
|
+
ORDER BY type, name`)).map(t=>({name:t.name,label:t.name,type:t.type,objectKind:`table`,path:`${e}/${n}/${t.name}`}))}async function c(a,o=0,s=1e3){let{schema:c,table:l}=n(a),u=`${e(c)}.${e(l)}`,d=(await i(`SELECT column_name FROM information_schema.columns
|
|
6
|
+
WHERE table_catalog = current_database()
|
|
7
|
+
AND table_schema = ${t(c)} AND table_name = ${t(l)}
|
|
8
|
+
ORDER BY ordinal_position`)).map(e=>e.column_name),f=Number((await i(`SELECT COUNT(*) AS total FROM ${u}`))[0].total);return{rows:(await i(`SELECT * FROM ${u} LIMIT ${s} OFFSET ${o}`)).map(r),columns:d,total:f,offset:o,limit:s}}}export{i as t};
|
package/app/assets/esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e;(function(e){e.LOAD=`LOAD`,e.EXEC=`EXEC`,e.FFPROBE=`FFPROBE`,e.WRITE_FILE=`WRITE_FILE`,e.READ_FILE=`READ_FILE`,e.DELETE_FILE=`DELETE_FILE`,e.RENAME=`RENAME`,e.CREATE_DIR=`CREATE_DIR`,e.LIST_DIR=`LIST_DIR`,e.DELETE_DIR=`DELETE_DIR`,e.ERROR=`ERROR`,e.DOWNLOAD=`DOWNLOAD`,e.PROGRESS=`PROGRESS`,e.LOG=`LOG`,e.MOUNT=`MOUNT`,e.UNMOUNT=`UNMOUNT`})(e||={});const t=(()=>{let e=0;return()=>e++})(),n=Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"),r=Error(`called FFmpeg.terminate()`);var i=class{#e=null;#t={};#n={};#r=[];#i=[];loaded=!1;#a=()=>{this.#e&&(this.#e.onmessage=({data:{id:t,type:n,data:r}})=>{switch(n){case e.LOAD:this.loaded=!0,this.#t[t](r);break;case e.MOUNT:case e.UNMOUNT:case e.EXEC:case e.FFPROBE:case e.WRITE_FILE:case e.READ_FILE:case e.DELETE_FILE:case e.RENAME:case e.CREATE_DIR:case e.LIST_DIR:case e.DELETE_DIR:this.#t[t](r);break;case e.LOG:this.#r.forEach(e=>e(r));break;case e.PROGRESS:this.#i.forEach(e=>e(r));break;case e.ERROR:this.#n[t](r)
|
|
1
|
+
var e;(function(e){e.LOAD=`LOAD`,e.EXEC=`EXEC`,e.FFPROBE=`FFPROBE`,e.WRITE_FILE=`WRITE_FILE`,e.READ_FILE=`READ_FILE`,e.DELETE_FILE=`DELETE_FILE`,e.RENAME=`RENAME`,e.CREATE_DIR=`CREATE_DIR`,e.LIST_DIR=`LIST_DIR`,e.DELETE_DIR=`DELETE_DIR`,e.ERROR=`ERROR`,e.DOWNLOAD=`DOWNLOAD`,e.PROGRESS=`PROGRESS`,e.LOG=`LOG`,e.MOUNT=`MOUNT`,e.UNMOUNT=`UNMOUNT`})(e||={});const t=(()=>{let e=0;return()=>e++})(),n=Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"),r=Error(`called FFmpeg.terminate()`);var i=class{#e=null;#t={};#n={};#r=[];#i=[];loaded=!1;#a=()=>{this.#e&&(this.#e.onmessage=({data:{id:t,type:n,data:r}})=>{switch(n){case e.LOAD:this.loaded=!0,this.#t[t](r);break;case e.MOUNT:case e.UNMOUNT:case e.EXEC:case e.FFPROBE:case e.WRITE_FILE:case e.READ_FILE:case e.DELETE_FILE:case e.RENAME:case e.CREATE_DIR:case e.LIST_DIR:case e.DELETE_DIR:this.#t[t](r);break;case e.LOG:this.#r.forEach(e=>e(r));break;case e.PROGRESS:this.#i.forEach(e=>e(r));break;case e.ERROR:this.#n[t](r)}delete this.#t[t],delete this.#n[t]})};#o=({type:e,data:r},i=[],a)=>this.#e?new Promise((n,o)=>{let s=t();this.#e&&this.#e.postMessage({id:s,type:e,data:r},i),this.#t[s]=n,this.#n[s]=o,a?.addEventListener(`abort`,()=>{o(new DOMException(`Message # ${s} was aborted`,`AbortError`))},{once:!0})}):Promise.reject(n);on(e,t){e===`log`?this.#r.push(t):e===`progress`&&this.#i.push(t)}off(e,t){e===`log`?this.#r=this.#r.filter(e=>e!==t):e===`progress`&&(this.#i=this.#i.filter(e=>e!==t))}load=({classWorkerURL:t,...n}={},{signal:r}={})=>(this.#e||(this.#e=t?new Worker(new URL(t,import.meta.url),{type:`module`}):new Worker(new URL(``+new URL(`esm-worker.js`,import.meta.url).href,``+import.meta.url),{type:`module`}),this.#a()),this.#o({type:e.LOAD,data:n},void 0,r));exec=(t,n=-1,{signal:r}={})=>this.#o({type:e.EXEC,data:{args:t,timeout:n}},void 0,r);ffprobe=(t,n=-1,{signal:r}={})=>this.#o({type:e.FFPROBE,data:{args:t,timeout:n}},void 0,r);terminate=()=>{let e=Object.keys(this.#n);for(let t of e)this.#n[t](r),delete this.#n[t],delete this.#t[t];this.#e&&(this.#e.terminate(),this.#e=null,this.loaded=!1)};writeFile=(t,n,{signal:r}={})=>{let i=[];return n instanceof Uint8Array&&i.push(n.buffer),this.#o({type:e.WRITE_FILE,data:{path:t,data:n}},i,r)};mount=(t,n,r)=>this.#o({type:e.MOUNT,data:{fsType:t,options:n,mountPoint:r}},[]);unmount=t=>this.#o({type:e.UNMOUNT,data:{mountPoint:t}},[]);readFile=(t,n=`binary`,{signal:r}={})=>this.#o({type:e.READ_FILE,data:{path:t,encoding:n}},void 0,r);deleteFile=(t,{signal:n}={})=>this.#o({type:e.DELETE_FILE,data:{path:t}},void 0,n);rename=(t,n,{signal:r}={})=>this.#o({type:e.RENAME,data:{oldPath:t,newPath:n}},void 0,r);createDir=(t,{signal:n}={})=>this.#o({type:e.CREATE_DIR,data:{path:t}},void 0,n);listDir=(t,{signal:n}={})=>this.#o({type:e.LIST_DIR,data:{path:t}},void 0,n);deleteDir=(t,{signal:n}={})=>this.#o({type:e.DELETE_DIR,data:{path:t}},void 0,n)},a;(function(e){e.MEMFS=`MEMFS`,e.NODEFS=`NODEFS`,e.NODERAWFS=`NODERAWFS`,e.IDBFS=`IDBFS`,e.WORKERFS=`WORKERFS`,e.PROXYFS=`PROXYFS`})(a||={});export{i as FFmpeg};
|