@sksat/uneri 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 sksat <sksat@sksat.net>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # uneri
2
+
3
+ DuckDB-wasm + uPlot time-series charting library for real-time streaming data.
4
+
5
+ Generic schema-driven design: define columns and derived SQL expressions, and uneri handles DuckDB ingestion, query-time downsampling, and chart rendering.
6
+
7
+ ## Build
8
+
9
+ ```bash
10
+ pnpm install
11
+ pnpm build
12
+ ```
13
+
14
+ ## Test
15
+
16
+ ```bash
17
+ pnpm test # vitest unit tests (59 tests)
18
+ pnpm test:e2e # Playwright E2E tests (5 tests)
19
+ ```
20
+
21
+ ## Examples
22
+
23
+ ### sine-wave
24
+
25
+ Basic real-time sine/cosine visualization.
26
+
27
+ ```bash
28
+ pnpm example:sine-wave
29
+ ```
30
+
31
+ Open http://localhost:5174
32
+
33
+ ### mixed-density
34
+
35
+ Mixed-density data test: sparse overview (100 points over 5000s) + dense streaming (100 msg/sec). Used for E2E testing of the time-bucket downsampling algorithm.
36
+
37
+ ```bash
38
+ pnpm example:mixed-density
39
+ ```
40
+
41
+ Open http://localhost:5175
42
+
43
+ ## Architecture
44
+
45
+ - `IngestBuffer<T>` — staging buffer with drain pattern (decouples WebSocket arrival from DuckDB insertion)
46
+ - `useDuckDB(schema)` — initializes DuckDB-wasm, creates table
47
+ - `useTimeSeriesStore(options)` — tick loop: drain buffer → INSERT → periodic query with downsampling
48
+ - `TimeSeriesChart` — uPlot wrapper with programmatic update guard
49
+ - `buildDerivedQuery(schema, tMin, maxPoints)` — time-bucket downsampling SQL
50
+ - `sliceArrays` / `lowerBound` / `upperBound` — binary search viewport clipping
@@ -0,0 +1,12 @@
1
+ (function(){var e=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);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)}}let 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)}let 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};return yield*xe((function*(t){let n=null;do n=t.next(yield p(e,n));while(!n.done)})((typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof he?n(t):re(t)?t:n(t))[Symbol.iterator]())),new e}let 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))})};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)})})((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))[Symbol.asyncIterator]()))))),yield r(new e)})}let 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`)}};let 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})}};let 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||={});let 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)}let 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});let 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);let 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;break}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;let 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)}}let 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 V?_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);let j=new k,Pr=Symbol.for(`parent`),Fr=Symbol.for(`rowIndex`);var Ir=class{constructor(e,t){return this[Pr]=e,this[Fr]=t,new Proxy(this,new Rr)}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[Fr],t=this[Pr],n=t.type.children,r={};for(let i=-1,a=n.length;++i<a;)r[n[i].name]=P.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 Lr(this[Pr],this[Fr])}},Lr=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,P.visit(this.children[e],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(Ir.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[Pr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Fr]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var Rr=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[Pr].type.children.map(e=>e.name)}has(e,t){return e[Pr].type.children.findIndex(e=>e.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[Pr].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[Pr].type.children.findIndex(e=>e.name===t);if(n!==-1){let r=P.visit(e[Pr].children[n],e[Fr]);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[Pr].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[Pr].children[r],e[Fr],n),Reflect.set(e,t,n))}},M=class extends O{};function N(e){return(t,n)=>t.getValid(n)?e(t,n):null}let zr=(e,t)=>864e5*e[t],Br=(e,t)=>null,Vr=(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)},Hr=({offset:e,values:t},n)=>{let r=e+n;return(t[r>>3]&1<<r%8)!=0},Ur=({values:e},t)=>zr(e,t),Wr=({values:e},t)=>w(e[t]),Gr=({stride:e,values:t},n)=>t[e*n],Kr=({stride:e,values:t},n)=>Hn(t[e*n]),qr=({values:e},t)=>e[t],Jr=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),Yr=({values:e,valueOffsets:t},n)=>Vr(e,t,n),Xr=({values:e,valueOffsets:t},n)=>{let r=Vr(e,t,n);return r===null?null:c(r)},Zr=({values:e},t)=>e[t],Qr=({type:e,values:t},n)=>e.precision===_.HALF?Hn(t[n]):t[n],$r=(e,t)=>e.type.unit===Ie.DAY?Ur(e,t):Wr(e,t),ei=({values:e},t)=>1e3*w(e[t]),ti=({values:e},t)=>w(e[t]),ni=({values:e},t)=>wt(e[t],BigInt(1e3)),ri=({values:e},t)=>wt(e[t],BigInt(1e6)),ii=(e,t)=>{switch(e.type.unit){case v.SECOND:return ei(e,t);case v.MILLISECOND:return ti(e,t);case v.MICROSECOND:return ni(e,t);case v.NANOSECOND:return ri(e,t)}},ai=({values:e},t)=>e[t],oi=({values:e},t)=>e[t],si=({values:e},t)=>e[t],ci=({values:e},t)=>e[t],li=(e,t)=>{switch(e.type.unit){case v.SECOND:return ai(e,t);case v.MILLISECOND:return oi(e,t);case v.MICROSECOND:return si(e,t);case v.NANOSECOND:return ci(e,t)}},ui=({values:e,stride:t},n)=>Ft.decimal(e.subarray(t*n,t*(n+1))),di=(e,t)=>{let{valueOffsets:n,stride:r,children:i}=e,{[t*r]:a,[t*r+1]:o}=n;return new V([i[0].slice(a,o-a)])},fi=(e,t)=>{let{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:a}=n,o=r[0];return new ji(o.slice(i,a-i))},pi=(e,t)=>new Ir(e,t),mi=(e,t)=>e.type.mode===g.Dense?hi(e,t):gi(e,t),hi=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return P.visit(r,e.valueOffsets[t])},gi=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return P.visit(r,t)},_i=(e,t)=>e.dictionary?.get(e.values[t]),vi=(e,t)=>e.type.unit===Le.DAY_TIME?yi(e,t):bi(e,t),yi=({values:e},t)=>e.subarray(2*t,2*(t+1)),bi=({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},xi=({values:e},t)=>e[t],Si=({values:e},t)=>e[t],Ci=({values:e},t)=>e[t],wi=({values:e},t)=>e[t],Ti=(e,t)=>{switch(e.type.unit){case v.SECOND:return xi(e,t);case v.MILLISECOND:return Si(e,t);case v.MICROSECOND:return Ci(e,t);case v.NANOSECOND:return wi(e,t)}},Ei=(e,t)=>{let{stride:n,children:r}=e;return new V([r[0].slice(t*n,n)])};M.prototype.visitNull=N(Br),M.prototype.visitBool=N(Hr),M.prototype.visitInt=N(Zr),M.prototype.visitInt8=N(Gr),M.prototype.visitInt16=N(Gr),M.prototype.visitInt32=N(Gr),M.prototype.visitInt64=N(qr),M.prototype.visitUint8=N(Gr),M.prototype.visitUint16=N(Gr),M.prototype.visitUint32=N(Gr),M.prototype.visitUint64=N(qr),M.prototype.visitFloat=N(Qr),M.prototype.visitFloat16=N(Kr),M.prototype.visitFloat32=N(Gr),M.prototype.visitFloat64=N(Gr),M.prototype.visitUtf8=N(Xr),M.prototype.visitLargeUtf8=N(Xr),M.prototype.visitBinary=N(Yr),M.prototype.visitLargeBinary=N(Yr),M.prototype.visitFixedSizeBinary=N(Jr),M.prototype.visitDate=N($r),M.prototype.visitDateDay=N(Ur),M.prototype.visitDateMillisecond=N(Wr),M.prototype.visitTimestamp=N(ii),M.prototype.visitTimestampSecond=N(ei),M.prototype.visitTimestampMillisecond=N(ti),M.prototype.visitTimestampMicrosecond=N(ni),M.prototype.visitTimestampNanosecond=N(ri),M.prototype.visitTime=N(li),M.prototype.visitTimeSecond=N(ai),M.prototype.visitTimeMillisecond=N(oi),M.prototype.visitTimeMicrosecond=N(si),M.prototype.visitTimeNanosecond=N(ci),M.prototype.visitDecimal=N(ui),M.prototype.visitList=N(di),M.prototype.visitStruct=N(pi),M.prototype.visitUnion=N(mi),M.prototype.visitDenseUnion=N(hi),M.prototype.visitSparseUnion=N(gi),M.prototype.visitDictionary=N(_i),M.prototype.visitInterval=N(vi),M.prototype.visitIntervalDayTime=N(yi),M.prototype.visitIntervalYearMonth=N(bi),M.prototype.visitDuration=N(Ti),M.prototype.visitDurationSecond=N(xi),M.prototype.visitDurationMillisecond=N(Si),M.prototype.visitDurationMicrosecond=N(Ci),M.prototype.visitDurationNanosecond=N(wi),M.prototype.visitFixedSizeList=N(Ei),M.prototype.visitMap=N(fi);let P=new M,Di=Symbol.for(`keys`),Oi=Symbol.for(`vals`),ki=Symbol.for(`kKeysAsStrings`),Ai=Symbol.for(`_kKeysAsStrings`);var ji=class{constructor(e){return this[Di]=new V([e.children[0]]).memoize(),this[Oi]=e.children[1],new Proxy(this,new Ni)}get[ki](){return this[Ai]||(this[Ai]=Array.from(this[Di].toArray(),String))}[Symbol.iterator](){return new Mi(this[Di],this[Oi])}get size(){return this[Di].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[Di],t=this[Oi],n={};for(let r=-1,i=e.length;++r<i;)n[e.get(r)]=P.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()}},Mi=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),P.visit(this.vals,e)]})}},Ni=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[ki]}has(e,t){return e[ki].includes(t)}getOwnPropertyDescriptor(e,t){if(e[ki].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[ki].indexOf(t);if(n!==-1){let r=P.visit(Reflect.get(e,Oi),n);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[ki].indexOf(t);return r===-1?Reflect.has(e,t)?Reflect.set(e,t,n):!1:(j.visit(Reflect.get(e,Oi),r,n),Reflect.set(e,t,n))}};Object.defineProperties(ji.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[Di]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Oi]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ai]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let Pi;function Fi(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&&(Pi=a,a=o,o=Pi),o>i&&(o=i),r?r(e,a,o):[a,o]}let Ii=(e,t)=>e<0?t+e:e,Li=e=>e!==e;function Ri(e){if(typeof e!=`object`||!e)return Li(e)?Li:t=>t===e;if(e instanceof Date){let t=e.valueOf();return e=>e instanceof Date?e.valueOf()===t:!1}return ArrayBuffer.isView(e)?t=>t?De(e,t):!1:e instanceof Map?Bi(e):Array.isArray(e)?zi(e):e instanceof V?Vi(e):Hi(e,!0)}function zi(e){let t=[];for(let n=-1,r=e.length;++n<r;)t[n]=Ri(e[n]);return Ui(t)}function Bi(e){let t=-1,n=[];for(let r of e.values())n[++t]=Ri(r);return Ui(n)}function Vi(e){let t=[];for(let n=-1,r=e.length;++n<r;)t[n]=Ri(e.get(n));return Ui(t)}function Hi(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]=Ri(e[n[t]]);return Ui(r,n)}function Ui(e,t){return n=>{if(!n||typeof n!=`object`)return!1;switch(n.constructor){case Array:return Wi(e,n);case Map:return Ki(e,n,n.keys());case ji:case Ir:case Object:case void 0:return Ki(e,n,t||Object.keys(n))}return n instanceof V?Gi(e,n):!1}}function Wi(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 Gi(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 Ki(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 qi(e,t,n,r){return(n&1<<r)!=0}function Ji(e,t,n,r){return(n&1<<r)>>r}function Yi(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):Xi(new Zi(n,e,t,null,qi)).subarray(0,r)),i}return n}function Xi(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 Zi=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 Qi(e,t,n){if(n-t<=0)return 0;if(n-t<8){let r=0;for(let i of new Zi(e,t,n-t,e,Ji))r+=i;return r}let r=n>>3<<3,i=t+(t%8==0?0:8-t%8);return Qi(e,t,i)+Qi(e,r,n)+$i(e,i>>3,r-i>>3)}function $i(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+=ea(a.getUint32(i)),i+=4;for(;o-i>=2;)r+=ea(a.getUint16(i)),i+=2;for(;o-i>=1;)r+=ea(a.getUint8(i)),i+=1;return r}function ea(e){let t=Math.trunc(e);return t-=t>>>1&1431655765,t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var F=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-Qi(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)!=0}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(Yi(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(Yi(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))}};F.prototype.children=Object.freeze([]);let ta=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 F(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 F(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 F(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 F(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 F(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 F(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 F(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 F(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 F(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 F(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 F(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 F(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 F(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 F(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 F(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 F(t,n,a,o,[void 0,void 0,void 0,i],r):new F(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 V([new e().visit({type:n.dictionary})])}=t,{length:s=a.length,nullCount:c=t.nullBitmap?-1:0}=t;return new F(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 F(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 F(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 F(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 F(n,r,s,c,[o,void 0,a],[i])}};function I(e){return ta.visit(e)}var na=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 ra(e){return e.some(e=>e.nullable)}function ia(e){return e.reduce((e,t)=>e+t.nullCount,0)}function aa(e){return e.reduce((e,t,n)=>(e[n+1]=e[n]+t.length,e),new Uint32Array(e.length+1))}function oa(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 sa(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 ca(e,t){return e.getValid(t)}function la(e){function t(t,n,r){return e(t[n],r)}return function(e){let n=this.data;return sa(n,this._offsets,e,t)}}function ua(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=sa(i,this._offsets,e,n);return t=void 0,a}}function da(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`?sa(i,this._offsets,r,n):n(i,0,0);return t=void 0,a}}var L=class extends O{};function fa(e,t){return t===null&&e.length>0?0:-1}function pa(e,t){let{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(let i of new Zi(n,e.offset+(t||0),e.length,n,qi)){if(!i)return r;++r}return-1}function R(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 pa(e,n)}let r=P.getVisitFn(e),i=Ri(t);for(let t=(n||0)-1,a=e.length;++t<a;)if(i(r(e,t)))return t;return-1}function ma(e,t,n){let r=P.getVisitFn(e),i=Ri(t);for(let t=(n||0)-1,a=e.length;++t<a;)if(i(r(e,t)))return t;return-1}L.prototype.visitNull=fa,L.prototype.visitBool=R,L.prototype.visitInt=R,L.prototype.visitInt8=R,L.prototype.visitInt16=R,L.prototype.visitInt32=R,L.prototype.visitInt64=R,L.prototype.visitUint8=R,L.prototype.visitUint16=R,L.prototype.visitUint32=R,L.prototype.visitUint64=R,L.prototype.visitFloat=R,L.prototype.visitFloat16=R,L.prototype.visitFloat32=R,L.prototype.visitFloat64=R,L.prototype.visitUtf8=R,L.prototype.visitLargeUtf8=R,L.prototype.visitBinary=R,L.prototype.visitLargeBinary=R,L.prototype.visitFixedSizeBinary=R,L.prototype.visitDate=R,L.prototype.visitDateDay=R,L.prototype.visitDateMillisecond=R,L.prototype.visitTimestamp=R,L.prototype.visitTimestampSecond=R,L.prototype.visitTimestampMillisecond=R,L.prototype.visitTimestampMicrosecond=R,L.prototype.visitTimestampNanosecond=R,L.prototype.visitTime=R,L.prototype.visitTimeSecond=R,L.prototype.visitTimeMillisecond=R,L.prototype.visitTimeMicrosecond=R,L.prototype.visitTimeNanosecond=R,L.prototype.visitDecimal=R,L.prototype.visitList=R,L.prototype.visitStruct=R,L.prototype.visitUnion=R,L.prototype.visitDenseUnion=ma,L.prototype.visitSparseUnion=ma,L.prototype.visitDictionary=R,L.prototype.visitInterval=R,L.prototype.visitIntervalDayTime=R,L.prototype.visitIntervalYearMonth=R,L.prototype.visitDuration=R,L.prototype.visitDurationSecond=R,L.prototype.visitDurationMillisecond=R,L.prototype.visitDurationMicrosecond=R,L.prototype.visitDurationNanosecond=R,L.prototype.visitFixedSizeList=R,L.prototype.visitMap=R;let ha=new L;var z=class extends O{};function B(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 na(e.data.length,t=>{let n=e.data[t];return n.values.subarray(0,n.length)[Symbol.iterator]()});let n=0;return new na(e.data.length,t=>{let r=e.data[t].length,i=e.slice(n,n+r);return n+=r,new ga(i)})}var ga=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}};z.prototype.visitNull=B,z.prototype.visitBool=B,z.prototype.visitInt=B,z.prototype.visitInt8=B,z.prototype.visitInt16=B,z.prototype.visitInt32=B,z.prototype.visitInt64=B,z.prototype.visitUint8=B,z.prototype.visitUint16=B,z.prototype.visitUint32=B,z.prototype.visitUint64=B,z.prototype.visitFloat=B,z.prototype.visitFloat16=B,z.prototype.visitFloat32=B,z.prototype.visitFloat64=B,z.prototype.visitUtf8=B,z.prototype.visitLargeUtf8=B,z.prototype.visitBinary=B,z.prototype.visitLargeBinary=B,z.prototype.visitFixedSizeBinary=B,z.prototype.visitDate=B,z.prototype.visitDateDay=B,z.prototype.visitDateMillisecond=B,z.prototype.visitTimestamp=B,z.prototype.visitTimestampSecond=B,z.prototype.visitTimestampMillisecond=B,z.prototype.visitTimestampMicrosecond=B,z.prototype.visitTimestampNanosecond=B,z.prototype.visitTime=B,z.prototype.visitTimeSecond=B,z.prototype.visitTimeMillisecond=B,z.prototype.visitTimeMicrosecond=B,z.prototype.visitTimeNanosecond=B,z.prototype.visitDecimal=B,z.prototype.visitList=B,z.prototype.visitStruct=B,z.prototype.visitUnion=B,z.prototype.visitDenseUnion=B,z.prototype.visitSparseUnion=B,z.prototype.visitDictionary=B,z.prototype.visitInterval=B,z.prototype.visitIntervalDayTime=B,z.prototype.visitIntervalYearMonth=B,z.prototype.visitDuration=B,z.prototype.visitDurationSecond=B,z.prototype.visitDurationMillisecond=B,z.prototype.visitDurationMicrosecond=B,z.prototype.visitDurationNanosecond=B,z.prototype.visitFixedSizeList=B,z.prototype.visitMap=B;let _a=new z;var va;let ya={},ba={};var V=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 F)))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}=ya[r.typeId],a=n[0];this.isValid=e=>ca(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,ba[r.typeId]),this._offsets=aa(n);break}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 ra(this.data)}get nullCount(){return ia(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(Ii(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return _a.visit(this)}concat(...t){return new e(this.data.concat(t.flatMap(e=>e.data).flat(1/0)))}slice(t,n){return new e(Fi(this,t,n,({data:e,_offsets:t},n,r)=>oa(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 xa(this.data[0].dictionary);return new e(this.data.map(e=>{let n=e.clone();return n.dictionary=t,n}))}return new xa(this)}unmemoize(){if(T.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize();return new e(this.data.map(e=>{let n=e.clone();return n.dictionary=t,n}))}return this}};va=Symbol.toStringTag,V[va]=(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)ya[n]={get:P.getVisitFnByTypeId(n),set:j.getVisitFnByTypeId(n),indexOf:ha.getVisitFnByTypeId(n)},ba[n]=Object.create(e,{isValid:{value:la(ca)},get:{value:la(P.getVisitFnByTypeId(n))},set:{value:ua(j.getVisitFnByTypeId(n))},indexOf:{value:da(ha.getVisitFnByTypeId(n))}});return`Vector`})(V.prototype);var xa=class e extends V{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 V(this.data)}),Object.defineProperty(this,`memoize`,{value:()=>this})}},Sa=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()}},Ca=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 Sa).__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 Sa).__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)}},H=class e{constructor(e=[],t,n,r=h.V5){this.fields=e||[],this.metadata=t||new Map,n||=Ta(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);return new e(this.fields.filter(e=>n.has(e.name)),this.metadata)}selectAt(t){return new e(t.map(e=>this.fields[e]).filter(Boolean),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=wa(wa(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:wa(wa(new Map,r[t].metadata),e.metadata)}))&&!1:!0}),o=Ta(a,new Map);return new e([...r,...a],i,new Map([...this.dictionaries,...o]))}};H.prototype.fields=null,H.prototype.metadata=null,H.prototype.dictionaries=null;var U=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)}};U.prototype.type=null,U.prototype.name=null,U.prototype.nullable=null,U.prototype.metadata=null;function wa(e,t){return new Map([...e||new Map,...t||new Map])}function Ta(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&&Ta(r.children,t)}return t}var Ea=We,Da=Ue,Oa=class{static decode(e){e=new Da(m(e));let t=Ca.getRootAsFooter(e);return new ka(H.decode(t.schema(),new Map,t.version()),t)}static encode(e){let t=new Ea,n=H.encode(t,e.schema);Ca.startRecordBatchesVector(t,e.numRecordBatches);for(let n of[...e.recordBatches()].slice().reverse())Aa.encode(t,n);let r=t.endVector();Ca.startDictionariesVector(t,e.numDictionaries);for(let n of[...e.dictionaryBatches()].slice().reverse())Aa.encode(t,n);let i=t.endVector();return Ca.startFooter(t),Ca.addSchema(t,n),Ca.addVersion(t,h.V5),Ca.addRecordBatches(t,r),Ca.addDictionaries(t,i),Ca.finishFooterBuffer(t,Ca.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}},ka=class extends Oa{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 Aa.decode(t)}return null}getDictionaryBatch(e){if(e>=0&&e<this.numDictionaries){let t=this._footer.dictionaries(e);if(t)return Aa.decode(t)}return null}},Aa=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 Sa.createBlock(e,r,n,i)}constructor(e,t,n){this.metaDataLength=e,this.offset=w(n),this.bodyLength=w(t)}};let W=Object.freeze({done:!0,value:void 0});var ja=class{constructor(e){this._json=e}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},Ma=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()}},Na=class extends Ma{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(W);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),W})}return(e){return t(this,void 0,void 0,function*(){return yield this.close(),W})}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(W)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw Error(`AsyncQueue is closed`)}},Pa=class extends Na{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]})}},Fa=class{constructor(e){e&&(this.source=new La(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)}},Ia=class e{constructor(t){t instanceof e?this.source=t.source:t instanceof Pa?this.source=new Ra(Oe.fromAsyncIterable(t)):pe(t)?this.source=new Ra(Oe.fromNodeStream(t)):de(t)?this.source=new Ra(Oe.fromDOMStream(t)):ce(t)?this.source=new Ra(Oe.fromDOMStream(t.body)):re(t)?this.source=new Ra(Oe.fromIterable(t)):(ne(t)||ie(t))&&(this.source=new Ra(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)}},La=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)||W)}return(e){return Object.create(this.source.return&&this.source.return(e)||W)}},Ra=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))||W;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))||W;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(t)})}},za=class extends Fa{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}}},Ba=class extends Ia{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 Va(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}let Ha=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8];var Ua=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`${Va(this.buffer[1])} ${Va(this.buffer[0])}`}},G=class e extends Ua{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([Ha[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)}},Wa=class e extends Ua{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([Ha[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)}},Ga=class e{constructor(e){this.buffer=e}high(){return new Wa(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new Wa(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 G(new Uint32Array([this.buffer[3],0])),n=new G(new Uint32Array([this.buffer[2],0])),r=new G(new Uint32Array([this.buffer[1],0])),i=new G(new Uint32Array([this.buffer[0],0])),a=new G(new Uint32Array([e.buffer[3],0])),o=new G(new Uint32Array([e.buffer[2],0])),s=new G(new Uint32Array([e.buffer[1],0])),c=new G(new Uint32Array([e.buffer[0],0])),l=G.multiply(i,c);this.buffer[0]=l.low();let u=new G(new Uint32Array([l.high(),0]));return l=G.multiply(r,c),u.plus(l),l=G.multiply(i,s),u.plus(l),this.buffer[1]=u.low(),this.buffer[3]=+!!u.lessThan(l),this.buffer[2]=u.high(),new G(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(G.multiply(n,c)).plus(G.multiply(r,s)).plus(G.multiply(i,o)),this.buffer[3]+=G.multiply(t,c).plus(G.multiply(n,s)).plus(G.multiply(r,o)).plus(G.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`${Va(this.buffer[3])} ${Va(this.buffer[2])} ${Va(this.buffer[1])} ${Va(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([Ha[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}},Ka=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 U?e.type:e)}visitNull(e,{length:t}=this.nextFieldNode()){return I({type:e,length:t})}visitBool(e,{length:t,nullCount:n}=this.nextFieldNode()){return I({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitInt(e,{length:t,nullCount:n}=this.nextFieldNode()){return I({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitFloat(e,{length:t,nullCount:n}=this.nextFieldNode()){return I({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitUtf8(e,{length:t,nullCount:n}=this.nextFieldNode()){return I({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 I({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 I({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 I({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 I({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDate(e,{length:t,nullCount:n}=this.nextFieldNode()){return I({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitTimestamp(e,{length:t,nullCount:n}=this.nextFieldNode()){return I({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitTime(e,{length:t,nullCount:n}=this.nextFieldNode()){return I({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDecimal(e,{length:t,nullCount:n}=this.nextFieldNode()){return I({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitList(e,{length:t,nullCount:n}=this.nextFieldNode()){return I({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 I({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 I({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 I({type:e,length:t,nullCount:n,typeIds:this.readTypeIds(e),children:this.visitMany(e.children)})}visitDictionary(e,{length:t,nullCount:n}=this.nextFieldNode()){return I({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 I({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDuration(e,{length:t,nullCount:n}=this.nextFieldNode()){return I({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitFixedSizeList(e,{length:t,nullCount:n}=this.nextFieldNode()){return I({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 I({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)}},qa=class extends Ka{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:Xi(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,Wa.convertArray(n[t])):T.isDecimal(e)?p(Uint8Array,Ga.convertArray(n[t])):T.isBinary(e)||T.isLargeBinary(e)||T.isFixedSizeBinary(e)?Ja(n[t]):T.isBool(e)?Xi(n[t]):T.isUtf8(e)||T.isLargeUtf8(e)?u(n[t].join(``)):p(Uint8Array,p(e.ArrayType,n[t].map(e=>+e)))}};function Ja(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 K=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 q(e,t){return t instanceof e.constructor}function Ya(e,t){return e===t||q(e,t)}function Xa(e,t){return e===t||q(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function Za(e,t){return e===t||q(e,t)&&e.precision===t.precision}function Qa(e,t){return e===t||q(e,t)&&e.byteWidth===t.byteWidth}function $a(e,t){return e===t||q(e,t)&&e.unit===t.unit}function eo(e,t){return e===t||q(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function to(e,t){return e===t||q(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function no(e,t){return e===t||q(e,t)&&e.children.length===t.children.length&&uo.compareManyFields(e.children,t.children)}function ro(e,t){return e===t||q(e,t)&&e.children.length===t.children.length&&uo.compareManyFields(e.children,t.children)}function io(e,t){return e===t||q(e,t)&&e.mode===t.mode&&e.typeIds.every((e,n)=>e===t.typeIds[n])&&uo.compareManyFields(e.children,t.children)}function ao(e,t){return e===t||q(e,t)&&e.id===t.id&&e.isOrdered===t.isOrdered&&uo.visit(e.indices,t.indices)&&uo.visit(e.dictionary,t.dictionary)}function oo(e,t){return e===t||q(e,t)&&e.unit===t.unit}function so(e,t){return e===t||q(e,t)&&e.unit===t.unit}function co(e,t){return e===t||q(e,t)&&e.listSize===t.listSize&&e.children.length===t.children.length&&uo.compareManyFields(e.children,t.children)}function lo(e,t){return e===t||q(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&uo.compareManyFields(e.children,t.children)}K.prototype.visitNull=Ya,K.prototype.visitBool=Ya,K.prototype.visitInt=Xa,K.prototype.visitInt8=Xa,K.prototype.visitInt16=Xa,K.prototype.visitInt32=Xa,K.prototype.visitInt64=Xa,K.prototype.visitUint8=Xa,K.prototype.visitUint16=Xa,K.prototype.visitUint32=Xa,K.prototype.visitUint64=Xa,K.prototype.visitFloat=Za,K.prototype.visitFloat16=Za,K.prototype.visitFloat32=Za,K.prototype.visitFloat64=Za,K.prototype.visitUtf8=Ya,K.prototype.visitLargeUtf8=Ya,K.prototype.visitBinary=Ya,K.prototype.visitLargeBinary=Ya,K.prototype.visitFixedSizeBinary=Qa,K.prototype.visitDate=$a,K.prototype.visitDateDay=$a,K.prototype.visitDateMillisecond=$a,K.prototype.visitTimestamp=eo,K.prototype.visitTimestampSecond=eo,K.prototype.visitTimestampMillisecond=eo,K.prototype.visitTimestampMicrosecond=eo,K.prototype.visitTimestampNanosecond=eo,K.prototype.visitTime=to,K.prototype.visitTimeSecond=to,K.prototype.visitTimeMillisecond=to,K.prototype.visitTimeMicrosecond=to,K.prototype.visitTimeNanosecond=to,K.prototype.visitDecimal=Ya,K.prototype.visitList=no,K.prototype.visitStruct=ro,K.prototype.visitUnion=io,K.prototype.visitDenseUnion=io,K.prototype.visitSparseUnion=io,K.prototype.visitDictionary=ao,K.prototype.visitInterval=oo,K.prototype.visitIntervalDayTime=oo,K.prototype.visitIntervalYearMonth=oo,K.prototype.visitDuration=so,K.prototype.visitDurationSecond=so,K.prototype.visitDurationMillisecond=so,K.prototype.visitDurationMicrosecond=so,K.prototype.visitDurationNanosecond=so,K.prototype.visitFixedSizeList=co,K.prototype.visitMap=lo;let uo=new K;function fo(e,t){return uo.compareSchemas(e,t)}function po(e,t){return mo(e,t.map(e=>e.data.concat()))}function mo(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=ho(n,o,u,t,i),o>0&&(r[a++]=I({type:new D(n),length:o,nullCount:0,children:u.slice()})))}return[e=e.assign(n),r.map(t=>new J(e,t))]}function ho(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)??I({type:r.type,length:t,nullCount:t,nullBitmap:new Uint8Array(a)})}}return n}var go,_o=class e{constructor(...t){if(t.length===0)return this.batches=[],this.schema=new H([]),this._offsets=[0],this;let n,r;t[0]instanceof H&&(n=t.shift()),t.at(-1)instanceof Uint32Array&&(r=t.pop());let i=t=>{if(t){if(t instanceof J)return[t];if(t instanceof e)return t.batches;if(t instanceof F){if(t.type instanceof D)return[new J(new H(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 V([t[e]])),[,i]=po(n??new H(e.map((e,t)=>new U(String(e),r[t].type,r[t].nullable))),r);return i.length===0?[new J(t)]:i}}return[]},a=t.flatMap(e=>i(e));if(n=n??a[0]?.schema??new H([]),!(n instanceof H))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);for(let e of a){if(!(e instanceof J))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);if(!fo(n,e.schema))throw TypeError(`Table and inner RecordBatch schemas must be equivalent.`)}this.schema=n,this.batches=a,this._offsets=r??aa(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=ia(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(Ii(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?_a.visit(new V(this.data)):[][Symbol.iterator]()}toArray(){return[...this]}toString(){return`[\n ${this.toArray().join(`,
2
+ `)}\n]`}concat(...t){let n=this.schema;return new e(n,this.data.concat(t.flatMap(({data:e})=>e)).map(e=>new J(n,e)))}slice(t,n){let r=this.schema;return[t,n]=Fi({length:this.numRows},t,n),new e(r,oa(this.data,this._offsets,t,n).map(e=>new J(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=I({type:n,length:0,nullCount:0});t.push(r._changeLengthAndBackfillNullBitmap(this.numRows))}return new V(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 V([I({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]=po(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){return new e(this.schema.selectAt(t),this.batches.map(e=>e.selectAt(t)))}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},[[],[]]);return new e(...po(this.schema.assign(t.schema),[...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)))}};go=Symbol.toStringTag,_o[go]=(e=>(e.schema=null,e.batches=[],e._offsets=new Uint32Array([0]),e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,e.isValid=la(ca),e.get=la(P.getVisitFn(C.Struct)),e.set=ua(j.getVisitFn(C.Struct)),e.indexOf=da(ha.getVisitFn(C.Struct)),`Table`))(_o.prototype);var vo,J=class e{constructor(...e){switch(e.length){case 2:if([this.schema]=e,!(this.schema instanceof H)||([,this.data=I({nullCount:0,type:new D(this.schema.fields),children:this.schema.fields.map(e=>I({type:e.type,nullCount:0}))})]=e,!(this.data instanceof F)))throw TypeError(`RecordBatch constructor expects a [Schema, Data] pair.`);[this.schema,this.data]=yo(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]=U.new({name:n,type:t[n].type,nullable:!0}),e),{length:0,fields:[],children:[]}),a=new H(n),o=I({type:new D(n),length:i,children:r,nullCount:0});[this.schema,this.data]=yo(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||=bo(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 P.visit(this.data,e)}at(e){return this.get(Ii(e,this.numRows))}set(e,t){return j.visit(this.data,e,t)}indexOf(e,t){return ha.visit(this.data,e,t)}[Symbol.iterator](){return _a.visit(new V([this.data]))}toArray(){return[...this]}concat(...e){return new _o(this.schema,[this,...e])}slice(t,n){let[r]=new V([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 V([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 V([I({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 H(e,new Map(this.schema.metadata)),i=I({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,I({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);return new e(n,I({type:new D(n.fields),length:this.numRows,children:r}))}};vo=Symbol.toStringTag,J[vo]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,`RecordBatch`))(J.prototype);function yo(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)??I({type:s.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[e.assign(r),I({type:new D(r),length:n,children:i})]}function bo(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||[]])bo(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 xo=class extends J{constructor(e){let t=e.fields.map(e=>I({type:e.type})),n=I({type:new D(e.fields),nullCount:0,children:t});super(e,n)}},So=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)}};let Co=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 wo(e,t=new Map){return new H(Do(e,t),No(e.metadata),t)}function To(e){return new Y(e.count,ko(e.columns),Ao(e.columns))}function Eo(e){return new zo(To(e.data),e.id,e.isDelta)}function Do(e,t){return(e.fields||[]).filter(Boolean).map(e=>U.fromJSON(e,t))}function Oo(e,t){return(e.children||[]).filter(Boolean).map(e=>U.fromJSON(e,t))}function ko(e){return(e||[]).reduce((e,t)=>[...e,new Vo(t.count,jo(t.VALIDITY)),...ko(t.children)],[])}function Ao(e,t=[]){for(let n=-1,r=(e||[]).length;++n<r;){let r=e[n];r.VALIDITY&&t.push(new Bo(t.length,r.VALIDITY.length)),r.TYPE_ID&&t.push(new Bo(t.length,r.TYPE_ID.length)),r.OFFSET&&t.push(new Bo(t.length,r.OFFSET.length)),r.DATA&&t.push(new Bo(t.length,r.DATA.length)),t=Ao(r.children,t)}return t}function jo(e){return(e||[]).reduce((e,t)=>e+ +(t===0),0)}function Mo(e,t){let n,r,i,a,o,s;return!t||!(a=e.dictionary)?(o=Fo(e,Oo(e,t)),i=new U(e.name,o,e.nullable,No(e.metadata))):t.has(n=a.id)?(r=(r=a.indexType)?Po(r):new cn,s=new Fn(t.get(n),r,n,a.isOrdered),i=new U(e.name,s,e.nullable,No(e.metadata))):(r=(r=a.indexType)?Po(r):new cn,t.set(n,o=Fo(e,Oo(e,t))),s=new Fn(o,r,n,a.isOrdered),i=new U(e.name,s,e.nullable,No(e.metadata))),i||null}function No(e=[]){return new Map(e.map(({key:e,value:t})=>[e,t]))}function Po(e){return new E(e.isSigned,e.bitWidth)}function Fo(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();return new An(g[r.toUpperCase()+i.join(``)],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 Io=We,Lo=Ue,Ro=class e{static fromJSON(t,n){let r=new e(0,h.V5,n);return r._createHeader=Ho(t,n),r}static decode(t){t=new Lo(m(t));let n=So.getRootAsMessage(t),r=n.bodyLength(),i=n.version(),a=n.headerType(),o=new e(r,i,a);return o._createHeader=Uo(n,a),o}static encode(e){let t=new Io,n=-1;return e.isSchema()?n=H.encode(t,e.header()):e.isRecordBatch()?n=Y.encode(t,e.header()):e.isDictionaryBatch()&&(n=zo.encode(t,e.header())),So.startMessage(t),So.addVersion(t,h.V5),So.addHeader(t,n),So.addHeaderType(t,e.headerType),So.addBodyLength(t,BigInt(e.bodyLength)),So.finishMessageBuffer(t,So.endMessage(t)),t.asUint8Array()}static from(t,n=0){if(t instanceof H)return new e(0,h.V5,S.Schema,t);if(t instanceof Y)return new e(n,h.V5,S.RecordBatch,t);if(t instanceof zo)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)}},Y=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)}},zo=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)}},Bo=class{constructor(e,t){this.offset=w(e),this.length=w(t)}},Vo=class{constructor(e,t){this.length=w(e),this.nullCount=w(t)}};function Ho(e,t){return(()=>{switch(t){case S.Schema:return H.fromJSON(e);case S.RecordBatch:return Y.fromJSON(e);case S.DictionaryBatch:return zo.fromJSON(e)}throw Error(`Unrecognized Message type: { name: ${S[t]}, type: ${t} }`)})}function Uo(e,t){return(()=>{switch(t){case S.Schema:return H.decode(e.header(new xt),new Map,e.version());case S.RecordBatch:return Y.decode(e.header(new Xe),e.version());case S.DictionaryBatch:return zo.decode(e.header(new Ze),e.version())}throw Error(`Unrecognized Message type: { name: ${S[t]}, type: ${t} }`)})}U.encode=is,U.decode=$o,U.fromJSON=Mo,H.encode=rs,H.decode=Wo,H.fromJSON=wo,Y.encode=as,Y.decode=Go,Y.fromJSON=To,zo.encode=os,zo.decode=Ko,zo.fromJSON=Eo,Vo.encode=ss,Vo.decode=Jo,Bo.encode=cs,Bo.decode=qo;function Wo(e,t=new Map,n=h.V5){return new H(Zo(e,t),es(e),t,n)}function Go(e,t=h.V5){if(e.compression()!==null)throw Error(`Record batch compression not implemented`);return new Y(e.length(),Yo(e),Xo(e,t))}function Ko(e,t=h.V5){return new zo(Y.decode(e.data(),t),e.id(),e.isDelta())}function qo(e){return new Bo(e.offset(),e.length())}function Jo(e){return new Vo(e.length(),e.nullCount())}function Yo(e){let t=[];for(let n,r=-1,i=-1,a=e.nodesLength();++r<a;)(n=e.nodes(r))&&(t[++i]=Vo.decode(n));return t}function Xo(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]=Bo.decode(r));return n}function Zo(e,t){let n=[];for(let r,i=-1,a=-1,o=e.fieldsLength();++i<o;)(r=e.fields(i))&&(n[++a]=U.decode(r,t));return n}function Qo(e,t){let n=[];for(let r,i=-1,a=-1,o=e.childrenLength();++i<o;)(r=e.children(i))&&(n[++a]=U.decode(r,t));return n}function $o(e,t){let n,r,i,a,o,s;return!t||!(s=e.dictionary())?(i=ns(e,Qo(e,t)),r=new U(e.name(),i,e.nullable(),es(e))):t.has(n=w(s.id()))?(a=(a=s.indexType())?ts(a):new cn,o=new Fn(t.get(n),a,n,s.isOrdered()),r=new U(e.name(),o,e.nullable(),es(e))):(a=(a=s.indexType())?ts(a):new cn,t.set(n,i=ns(e,Qo(e,t))),o=new Fn(i,a,n,s.isOrdered()),r=new U(e.name(),o,e.nullable(),es(e))),r||null}function es(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 ts(e){return new E(e.isSigned(),e.bitWidth())}function ns(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 rs(e,t){let n=t.fields.map(t=>U.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,ls?Qe.Little:Qe.Big),i!==-1&&xt.addCustomMetadata(e,i),xt.endSchema(e)}function is(e,t){let n=-1,r=-1,i=-1,a=t.type,o=t.typeId;T.isDictionary(a)?(o=a.dictionary.typeId,i=Co.visit(a,e),r=Co.visit(a.dictionary,e)):r=Co.visit(a,e);let s=(a.children||[]).map(t=>U.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 as(e,t){let n=t.nodes||[],r=t.buffers||[];Xe.startNodesVector(e,n.length);for(let t of n.slice().reverse())Vo.encode(e,t);let i=e.endVector();Xe.startBuffersVector(e,r.length);for(let t of r.slice().reverse())Bo.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 os(e,t){let n=Y.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 ss(e,t){return Ye.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function cs(e,t){return Je.createBuffer(e,BigInt(t.offset),BigInt(t.length))}let ls=(()=>{let e=new ArrayBuffer(2);return new DataView(e).setInt16(0,256,!0),new Int16Array(e)[0]===256})(),us=e=>`Expected ${S[e]} Message in stream, but was null or length 0.`,ds=e=>`Header pointer of flatbuffer-encoded ${S[e]} Message is null or length 0.`,fs=(e,t)=>`Expected to read ${e} metadata bytes, but only read ${t}.`,ps=(e,t)=>`Expected to read ${e} bytes for message body, but only read ${t}.`;var ms=class{constructor(e){this.source=e instanceof Fa?e:new Fa(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?W: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(us(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(ps(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(ds(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 W;if(t.byteLength<e)throw Error(fs(e,t.byteLength));return{done:!1,value:Ro.decode(t)}}},hs=class{constructor(e,t){this.source=e instanceof Ia?e:se(e)?new Ba(e,t):new Ia(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?W: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(us(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(ps(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(ds(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 W;if(t.byteLength<e)throw Error(fs(e,t.byteLength));return{done:!1,value:Ro.decode(t)}})}},gs=class extends ms{constructor(e){super(new Uint8Array),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=e instanceof ja?e:new ja(e)}next(){let{_json:e}=this;if(!this._schema)return this._schema=!0,{done:!1,value:Ro.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:Ro.fromJSON(t,S.DictionaryBatch)}}if(this._batchIndex<e.batches.length){let t=e.batches[this._batchIndex++];return this._body=t.columns,{done:!1,value:Ro.fromJSON(t,S.RecordBatch)}}return this._body=[],W}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(us(e));return t.value}readSchema(){let e=S.Schema,t=this.readMessage(e),n=t?.header();if(!t||!n)throw Error(ds(e));return n}};let _s=new Uint8Array(6);for(let e=0;e<6;e+=1)_s[e]=`ARROW1`.codePointAt(e);function vs(e,t=0){for(let n=-1,r=_s.length;++n<r;)if(_s[n]!==e[t+n])return!1;return!0}let ys=_s.length,bs=ys+4,xs=ys*2+4;var Ss=class e extends Ma{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)?Is(n):se(n)?zs(n):ne(n)?t(this,void 0,void 0,function*(){return yield e.from(yield n)}):ce(n)||de(n)||pe(n)||ie(n)?Rs(new Ia(n)):Ls(new Fa(n))}static readAll(t){return t instanceof e?t.isSync()?Ps(t):Fs(t):ae(t)||ArrayBuffer.isView(t)||re(t)||oe(t)?Ps(t):Fs(t)}},Cs=class extends Ss{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]())))})}},ws=class extends Ss{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]()}},Ts=class extends Cs{constructor(e){super(e),this._impl=e}},Es=class extends ws{constructor(e){super(e),this._impl=e}},Ds=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=I({type:new D(this.schema.fields),length:e.length,children:n});return new J(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 V(c)):new V(c)).memoize()}_loadVectors(e,t,n){return new Ka(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},Os=class extends Ds{constructor(e,t){super(t),this._reader=ae(e)?new gs(this._handle=e):new ms(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=Ns(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):W}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):W}next(){if(this.closed)return W;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 xo(this.schema)}):this.return()}_readNextMessageAndValidate(e){return this._reader.readMessage(e)}},ks=class extends Ds{constructor(e,t){super(t),this._reader=new hs(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=Ns(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):W})}return(e){return t(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(e):W})}next(){return t(this,void 0,void 0,function*(){if(this.closed)return W;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 xo(this.schema)}):yield this.return()})}_readNextMessageAndValidate(e){return t(this,void 0,void 0,function*(){return yield this._reader.readMessage(e)})}},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){super(e instanceof za?e:new za(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-bs,n=e.readInt32(t),r=e.readAt(t-n,n);return Oa.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}},js=class extends ks{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 Ba?e:new Ba(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-bs,n=yield e.readInt32(t),r=yield e.readAt(t-n,n);return Oa.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})}},Ms=class extends Os{constructor(e,t){super(e,t)}_loadVectors(e,t,n){return new qa(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function Ns(e,t){return t&&typeof t.autoDestroy==`boolean`?t.autoDestroy:e.autoDestroy}function*Ps(e){let t=Ss.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Fs(e){return i(this,arguments,function*(){let t=yield r(Ss.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 Is(e){return new Cs(new Ms(e))}function Ls(e){let t=e.peek(ys+7&-8);return t&&t.byteLength>=4?vs(t)?new Ts(new As(e.read())):new Cs(new Os(e)):new Cs(new Os(function*(){}()))}function Rs(e){return t(this,void 0,void 0,function*(){let t=yield e.peek(ys+7&-8);return t&&t.byteLength>=4?vs(t)?new Ts(new As(yield e.read())):new ws(new ks(e)):new ws(new ks(function(){return i(this,arguments,function*(){})}()))})}function zs(e){return t(this,void 0,void 0,function*(){let{size:t}=yield e.stat(),n=new Ba(e,t);return t>=xs&&vs(yield n.readAt(0,ys+7&-8))?new Es(new js(n)):new ws(new ks(n))})}var X=class e extends O{static assemble(...t){let n=e=>e.flatMap(e=>Array.isArray(e)?n(e):e instanceof J?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 V)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 Vo(n,0));else{let{nullCount:r}=e;T.isNull(t)||Bs.call(this,r<=0?new Uint8Array:Yi(e.offset,n,e.nullBitmap)),this.nodes.push(new Vo(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 Bs(e){let t=e.byteLength+7&-8;return this.buffers.push(e),this.bufferRegions.push(new Bo(this._byteLength,t)),this._byteLength+=t,this}function Vs(e){let{type:t,length:n,typeIds:r,valueOffsets:i}=e;if(Bs.call(this,r),t.mode===g.Sparse)return Ks.call(this,e);if(t.mode===g.Dense){if(e.offset<=0)return Bs.call(this,i),Ks.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);Bs.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 Hs(e){let t;return e.nullCount>=e.length?Bs.call(this,new Uint8Array):(t=e.values)instanceof Uint8Array?Bs.call(this,Yi(e.offset,e.length,t)):Bs.call(this,Xi(e.values))}function Us(e){return Bs.call(this,e.values.subarray(0,e.length*e.stride))}function Ws(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 Bs.call(this,Ee(-i,t+1,r)),Bs.call(this,n.subarray(i,i+o)),this}function Gs(e){let{length:t,valueOffsets:n}=e;if(n){let{0:r,[t]:i}=n;return Bs.call(this,Ee(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function Ks(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}X.prototype.visitBool=Hs,X.prototype.visitInt=Us,X.prototype.visitFloat=Us,X.prototype.visitUtf8=Ws,X.prototype.visitLargeUtf8=Ws,X.prototype.visitBinary=Ws,X.prototype.visitLargeBinary=Ws,X.prototype.visitFixedSizeBinary=Us,X.prototype.visitDate=Us,X.prototype.visitTimestamp=Us,X.prototype.visitTime=Us,X.prototype.visitDecimal=Us,X.prototype.visitList=Gs,X.prototype.visitStruct=Ks,X.prototype.visitUnion=Vs,X.prototype.visitInterval=Us,X.prototype.visitDuration=Us,X.prototype.visitFixedSizeList=Gs,X.prototype.visitMap=Gs;var qs=class extends Ma{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 Pa,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:!0,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat==`boolean`?e.writeLegacyIpcFormat:!1}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)?Zs(this,e):Xs(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 Pa?this._sink=e:(this._sink=new Pa,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||!fo(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 _o&&!(t=e.schema)||e instanceof J&&!(t=e.schema))return this.finish()&&void 0;if(t&&!fo(t,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,t)}e instanceof J?e instanceof xo||this._writeRecordBatch(e):e instanceof _o?this.writeAll(e.batches):re(e)&&this.writeAll(e)}_writeMessage(e,t=8){let n=t-1,r=Ro.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 Aa(o,e.bodyLength,this._position)):e.headerType===S.DictionaryBatch&&this._dictionaryBlocks.push(new Aa(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(Ro.from(e))}_writeFooter(e){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(_s)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:t,nodes:n,bufferRegions:r,buffers:i}=X.assemble(e),a=new Y(e.numRows,n,r),o=Ro.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}=X.assemble(new V([e])),s=new zo(new Y(e.length,i,a),t,n),c=Ro.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}},Js=class e extends qs{static writeAll(t,n){let r=new e(n);return ne(t)?t.then(e=>r.writeAll(e)):ie(t)?Zs(r,t):Xs(r,t)}},Ys=class e extends qs{static writeAll(t){let n=new e;return ne(t)?t.then(e=>n.writeAll(e)):ie(t)?Zs(n,t):Xs(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=Oa.encode(new Oa(e,h.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(t)._write(Int32Array.of(t.byteLength))._writeMagic()}};function Xs(e,t){let n=t;t instanceof _o&&(n=t.batches,e.reset(void 0,t.schema));for(let t of n)e.write(t);return e.finish()}function Zs(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 Qs(e,t=`stream`){return(t===`stream`?Js:Ys).writeAll(e).toUint8Array(!0)}var $s=Object.create,ec=Object.defineProperty,tc=Object.getOwnPropertyDescriptor,nc=Object.getOwnPropertyNames,rc=Object.getPrototypeOf,ic=Object.prototype.hasOwnProperty,ac=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),oc=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of nc(t))!ic.call(e,i)&&i!==n&&ec(e,i,{get:()=>t[i],enumerable:!(r=tc(t,i))||r.enumerable});return e},sc=(e,t,n)=>(n=e==null?{}:$s(rc(e)),oc(t||!e||!e.__esModule?ec(n,`default`,{value:e,enumerable:!0}):n,e)),cc=ac((e,t)=>{t.exports=Worker}),lc=(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))(lc||{}),uc=(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))(uc||{}),dc=(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))(dc||{}),fc=(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))(fc||{}),pc=(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))(pc||{}),mc=(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))(mc||{}),hc=class{log(e){}},gc=(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))(gc||{}),_c=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=Ss.from(t);return console.assert(n.isSync(),`Reader is not sync`),console.assert(n.isFile(),`Reader is not file`),new _o(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 vc(this._bindings,this._conn,n),i=await Ss.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 yc(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=Qs(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)}},vc=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}},yc=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=Ss.from(t);return console.assert(n.isSync()),console.assert(n.isFile()),new _o(n)}async send(...e){let t=await this.bindings.sendPrepared(this.connectionId,this.statementId,e),n=new vc(this.bindings,this.connectionId,t),r=await Ss.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},bc=(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))(bc||{}),xc=(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))(xc||{}),Z=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 Sc(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:Sc(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=>Cc(e.name,e.type))};case C.Map:{let t=e;return{sqlType:`map`,keyType:Sc(t.keyType),valueType:Sc(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 Cc(e,t){let n=Sc(t);return n.name=e,n}var wc=/'(opfs:\/\/\S*?)'/g,Tc=/(opfs:\/\/\S*?)/g;function Ec(e){return e.search(Tc)>-1}function Dc(e){return[...e.matchAll(wc)].map(e=>e[1])}var Oc=new TextEncoder,kc=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}break}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 Z(`RESET`,null);return await this.postTask(e)}async ping(){let e=new Z(`PING`,null);await this.postTask(e)}async dropFile(e){let t=new Z(`DROP_FILE`,e);return await this.postTask(t)}async dropFiles(e){let t=new Z(`DROP_FILES`,e);return await this.postTask(t)}async flushFiles(){let e=new Z(`FLUSH_FILES`,null);return await this.postTask(e)}async instantiate(e,t=null,n=e=>{}){this._onInstantiationProgress.push(n);let r=new Z(`INSTANTIATE`,[e,t]);return await this.postTask(r)}async getVersion(){let e=new Z(`GET_VERSION`,null);return await this.postTask(e)}async getFeatureFlags(){let e=new Z(`GET_FEATURE_FLAGS`,null);return await this.postTask(e)}async open(e){this._config=e;let t=new Z(`OPEN`,e);await this.postTask(t)}async tokenize(e){let t=new Z(`TOKENIZE`,e);return await this.postTask(t)}async connectInternal(){let e=new Z(`CONNECT`,null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new _c(this,e)}async disconnect(e){let t=new Z(`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)}}else return await this._runQueryAsync(e,t)}async _runQueryAsync(e,t){let n=new Z(`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)}}else return await this._startPendingQueryAsync(e,t,n)}async _startPendingQueryAsync(e,t,n=!1){let r=new Z(`START_PENDING_QUERY`,[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new Z(`POLL_PENDING_QUERY`,e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new Z(`CANCEL_PENDING_QUERY`,e);return await this.postTask(t)}async fetchQueryResults(e){let t=new Z(`FETCH_QUERY_RESULTS`,e);return await this.postTask(t)}async getTableNames(e,t){let n=new Z(`GET_TABLE_NAMES`,[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new Z(`CREATE_PREPARED`,[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new Z(`CLOSE_PREPARED`,[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new Z(`RUN_PREPARED`,[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new Z(`SEND_PREPARED`,[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new Z(`GLOB_FILE_INFOS`,e);return await this.postTask(t)}async registerFileText(e,t){let n=Oc.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new Z(`REGISTER_FILE_URL`,[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new Z(`REGISTER_FILE_BUFFER`,[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new Z(`REGISTER_FILE_HANDLE`,[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new Z(`REGISTER_OPFS_FILE_NAME`,[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new Z(`COLLECT_FILE_STATISTICS`,[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new Z(`EXPORT_FILE_STATISTICS`,e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new Z(`COPY_FILE_TO_BUFFER`,e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new Z(`COPY_FILE_TO_PATH`,[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new Z(`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(Cc(t,r))}n.columnsFlat=e,delete n.columns}let r=new Z(`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(Cc(t,r))}n.columnsFlat=e,delete n.columns}let r=new Z(`IMPORT_JSON_FROM_PATH`,[e,t,n]);await this.postTask(r)}shouldOPFSFileHandling(){return Ec(this.config.path??``)?this.config.opfs?.fileHandling==`auto`:!1}async registerOPFSFileFromSQL(e){let t=Dc(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 Ac(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<`u`&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}Ac();var jc=(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))(jc||{}),Mc=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])),Nc=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),Pc=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),Fc=()=>(async e=>{try{return typeof MessageChannel<`u`&&new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)}catch{return!1}})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11])),Ic={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`}}},Lc=Ic.name,Rc=Ic.version,zc=Ic.version.split(`.`);zc[0],zc[1],zc[2];var Bc=()=>typeof navigator>`u`;function Vc(){let e=`https://cdn.jsdelivr.net/npm/${Lc}@${Rc}/dist/`;return{mvp:{mainModule:`${e}duckdb-mvp.wasm`,mainWorker:`${e}duckdb-browser-mvp.worker.js`},eh:{mainModule:`${e}duckdb-eh.wasm`,mainWorker:`${e}duckdb-browser-eh.worker.js`}}}var Hc=null,Uc=null,Wc=null,Gc=null,Kc=null;async function qc(){return Hc??=typeof BigInt64Array<`u`,Uc??=await Nc(),Wc??=await Fc(),Gc??=await Pc(),Kc??=await Mc(),{bigInt64Array:Hc,crossOriginIsolated:Bc()||globalThis.crossOriginIsolated||!1,wasmExceptions:Uc,wasmSIMD:Gc,wasmThreads:Wc,wasmBulkMemory:Kc}}async function Jc(e){let t=await qc();if(t.wasmExceptions){if(t.wasmSIMD&&t.wasmThreads&&t.crossOriginIsolated&&e.coi)return{mainModule:e.coi.mainModule,mainWorker:e.coi.mainWorker,pthreadWorker:e.coi.pthreadWorker};if(e.eh)return{mainModule:e.eh.mainModule,mainWorker:e.eh.mainWorker,pthreadWorker:null}}return{mainModule:e.mvp.mainModule,mainWorker:e.mvp.mainWorker,pthreadWorker:null}}sc(cc());let Yc=null;function Xc(){return Yc||(Yc=(async()=>{let e=await Jc(Vc()),t=URL.createObjectURL(new Blob([`importScripts("${e.mainWorker}");`],{type:`text/javascript`})),n=new Worker(t),r=new kc(new hc,n);return await r.instantiate(e.mainModule,e.pthreadWorker),URL.revokeObjectURL(t),r})(),Yc)}function Zc(e){let t=e.columns.map(e=>`${e.name} ${e.type}`).join(`, `);return`CREATE OR REPLACE TABLE ${e.tableName} (${t})`}let Qc=e=>e==null||!Number.isFinite(e)?`NULL`:String(e);function $c(e,t){return t.length===0?``:`INSERT INTO ${e} VALUES ${t.map(e=>`(${e.map(Qc).join(`,`)})`).join(`,`)}`}function el(e,t,n,r){let i=[];t!=null&&i.push(`t >= ${t}`),r!=null&&i.push(`t <= ${r}`);let a=i.length>0?`WHERE ${i.join(` AND `)}`:``,o=n??0,s=e.derived.map(e=>`${e.sql} AS ${e.name}`).join(`, `),c=s?`t, ${s}`:`t`,l=e.columns.map(e=>e.name).join(`, `);if(o<=0)return`SELECT ${c} FROM ${e.tableName} ${a} ORDER BY t`;let u=r==null?`MAX(t) AS t_hi`:`${r} AS t_hi`;return`WITH filtered AS (SELECT ${l} FROM ${e.tableName} ${a}), bounds AS (SELECT MIN(t) AS t_lo, ${u}, COUNT(*) AS total FROM filtered), bucketed AS (SELECT f.*, CASE WHEN b.t_hi = b.t_lo THEN 0 ELSE LEAST(GREATEST(CAST(FLOOR((CAST(f.t AS DOUBLE) - CAST(b.t_lo AS DOUBLE)) * ${o}.0 / (CAST(b.t_hi AS DOUBLE) - CAST(b.t_lo AS DOUBLE))) AS INTEGER), 0), ${o} - 1) END AS bucket, b.total FROM filtered f, bounds b), ranked AS (SELECT *, ROW_NUMBER() OVER (PARTITION BY bucket ORDER BY t) AS rn FROM bucketed) SELECT ${c} FROM (SELECT * FROM ranked WHERE total <= ${o} OR rn = 1 UNION SELECT * FROM ranked WHERE t = (SELECT MAX(t) FROM filtered)) sub ORDER BY t`}function tl(e,t,n){return`CREATE TEMP TABLE IF NOT EXISTS _compact_keepers AS WITH old_data AS (SELECT t, NTILE(${n}) OVER (ORDER BY t) AS bucket FROM ${e} WHERE t < ${t}) SELECT MIN(t) AS t FROM old_data GROUP BY bucket`}function nl(e,t){return`DELETE FROM ${e} WHERE t < ${t} AND t NOT IN (SELECT t FROM _compact_keepers)`}async function rl(e,t){await e.query(Zc(t))}async function il(e,t){await e.query(`DELETE FROM ${t.tableName}`)}async function al(e,t,n,r,i){let a=el(t,n,r,i),o=await e.query(a),s={t:o.getChildAt(0).toArray()};for(let e=0;e<t.derived.length;e++){let n=o.getChildAt(e+1).toArray();s[t.derived[e].name]=n}return s}function ol(e,t){let n=e.derived.map(e=>`${e.sql} AS ${e.name}`);return`SELECT ${n.length>0?`t, ${n.join(`, `)}`:`t`} FROM ${e.tableName} WHERE t > ${t} ORDER BY t`}async function sl(e,t,n){let r=ol(t,n),i=await e.query(r),a={t:i.getChildAt(0).toArray()};for(let e=0;e<t.derived.length;e++){let n=i.getChildAt(e+1).toArray();a[t.derived[e].name]=n}return a}let cl={maxRows:5e4,keepRecentRows:1e4,targetOldRows:5e3};async function ll(e,t,n=cl){let r=await e.query(`SELECT COUNT(*) AS total FROM ${t.tableName}`),i=Number(r.getChildAt(0).get(0));if(i<=n.maxRows||n.keepRecentRows>=i)return!1;let a=await e.query(`SELECT t FROM (SELECT t, ROW_NUMBER() OVER (ORDER BY t DESC) AS rn FROM ${t.tableName}) sub WHERE rn = ${n.keepRecentRows} LIMIT 1`),o=Number(a.getChildAt(0).get(0));try{await e.query(tl(t.tableName,o,n.targetOldRows)),await e.query(nl(t.tableName,o))}finally{await e.query(`DROP TABLE IF EXISTS _compact_keepers`)}return!0}
3
+ /**
4
+ * @license React
5
+ * react.production.js
6
+ *
7
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ var ul=e((e=>{var t={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},n=Object.assign,r={};function i(e,n,i){this.props=e,this.context=n,this.refs=r,this.updater=i||t}i.prototype.isReactComponent={},i.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},i.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function a(){}a.prototype=i.prototype;function o(e,n,i){this.props=e,this.context=n,this.refs=r,this.updater=i||t}var s=o.prototype=new a;s.constructor=o,n(s,i.prototype),s.isPureReactComponent=!0,Array.isArray}));e(((e,t)=>{t.exports=ul()}))();function dl(e,t,n,r){for(;n<r;){let i=n+r>>>1;e[i]<t?n=i+1:r=i}return n}function fl(e,t,n){if(!t||t.t.length===0)return e;let r=[`t`,...n],i={t:new Float64Array};for(let n of r){let r=e[n],a=t[n];if(!r&&!a)continue;if(!r){i[n]=a;continue}if(!a){i[n]=r;continue}let o=new Float64Array(r.length+a.length);o.set(r,0),o.set(a,r.length),i[n]=o}return i}function pl(e,t,n){let r=e.t;if(r.length===0)return e;let i=dl(r,t,0,r.length);if(i===0)return e;let a=[`t`,...n],o={t:new Float64Array};for(let t of a){let n=e[t];n&&(o[t]=n.subarray(i))}return o}function ml(e,t){if(e!=null)return t-e}let Q=null,$=null,hl=!1,gl=null,_l=2e3,vl=-1/0,yl=1/0,bl=null,xl=null,Sl=-1/0,Cl=null,wl=0,Tl=!0,El=0,Dl=!1,Ol=250,kl=20,Al=500,jl=!0,Ml=0,Nl=[],Pl=0,Fl=1e3;function Il(e,t){t?postMessage(e,{transfer:t}):postMessage(e)}function Ll(e){let t=[],n=[];for(let r of Object.keys(e)){let i=e[r];if(!i)continue;let a=new Float64Array(i.length);a.set(i),t.push(r),n.push(a.buffer)}Il({type:`chart-data`,keys:t,buffers:n},n)}function Rl(e){return{...e,toRow:()=>{throw Error(`toRow should not be called in worker`)}}}function zl(e){if(e!=null||!jl)return kl;let t=vl-yl;if(!Number.isFinite(t)||t<=0)return kl;let n=Math.ceil(t/200/(Ol/1e3));return Math.max(kl,n)}async function Bl(){if(!Q||!$)return;let e=Rl($);if(Nl.length>0){let e=Nl;Nl=[];try{for(let t=0;t<e.length;t+=Fl){let n=e.slice(t,t+Fl),r=$c($.tableName,n);r&&await Q.query(r)}Dl=!0,Pl=0}catch(t){console.warn(`chartDataWorker: insert failed:`,t),Pl<3?(Nl=e.concat(Nl),Pl++):(console.warn(`chartDataWorker: dropping`,e.length,`rows after`,3,`retries`),Pl=0)}}if(!Dl)return;wl++;let t=$.derived.map(e=>e.name),n=zl(gl);if(Tl||wl>=n||Cl!=null&&Cl.t.length>Al)try{let t=ml(gl,vl);xl=await al(Q,e,t,_l),Sl=xl.t.length>0?xl.t[xl.t.length-1]:-1/0,Cl=null,wl=0,Tl=!1,El++,Ml>0?Ml--:El%5==0&&await ll(Q,e,cl)&&(Tl=!0)}catch(e){console.warn(`chartDataWorker: cold query failed:`,e)}else if(gl!=null)try{let t=ml(gl,vl);Cl=await sl(Q,e,t==null?Sl:Math.max(Sl,t))}catch(e){console.warn(`chartDataWorker: hot query failed:`,e)}if(xl!=null){let e=fl(xl,Cl,t);gl!=null&&(e=pl(e,vl-gl,t)),Ll(e)}}function Vl(){bl=setTimeout(()=>{Bl().catch(e=>{console.warn(`chartDataWorker: tick error:`,e)}).finally(()=>{bl!==null&&Vl()})},Ol)}self.onmessage=async e=>{let t=e.data;if(!(hl&&t.type!==`dispose`))switch(t.type){case`init`:try{$=t.schema,t.tickInterval!=null&&(Ol=t.tickInterval),t.coldRefreshEveryN!=null&&(kl=t.coldRefreshEveryN,jl=!1),t.hotRowBudget!=null&&(Al=t.hotRowBudget),Q=await(await Xc()).connect(),await rl(Q,Rl($)),Vl(),Il({type:`ready`})}catch(e){Il({type:`error`,message:e instanceof Error?e.message:String(e)})}break;case`ingest`:Nl=Nl.concat(t.rows),vl=t.latestT,yl===1/0&&t.rows.length>0&&t.rows[0][0]!=null&&(yl=t.rows[0][0]);break;case`rebuild`:if(!Q||!$)break;try{await il(Q,Rl($));for(let e=0;e<t.rows.length;e+=Fl){let n=t.rows.slice(e,e+Fl),r=$c($.tableName,n);r&&await Q.query(r)}Dl=t.rows.length>0,vl=t.latestT,t.rows.length>0&&t.rows[0][0]!=null&&(yl=t.rows[0][0]),Ml=5,Tl=!0,Cl=null,Nl=[]}catch(e){console.warn(`chartDataWorker: rebuild failed:`,e)}break;case`configure`:{let e=t.timeRange!==gl,n=t.maxPoints!==_l;gl=t.timeRange,_l=t.maxPoints,(e||n)&&(Tl=!0);break}case`debug-query`:if(!Q||!$){Il({type:`debug-result`,id:t.id,result:0});break}try{let e=await Q.query(`SELECT COUNT(*) AS cnt FROM ${$.tableName}`),n=Number(e.getChildAt(0).get(0));Il({type:`debug-result`,id:t.id,result:n})}catch{Il({type:`debug-result`,id:t.id,result:-1})}break;case`zoom-query`:if(!Q||!$){Il({type:`zoom-result`,id:t.id,keys:[],buffers:[]});break}try{let e=Rl($),n=await al(Q,e,t.tMin,t.maxPoints,t.tMax),r=[],i=[];for(let e of Object.keys(n)){let t=n[e];if(!t)continue;let a=new Float64Array(t.length);a.set(t),r.push(e),i.push(a.buffer)}Il({type:`zoom-result`,id:t.id,keys:r,buffers:i},i)}catch{Il({type:`zoom-result`,id:t.id,keys:[],buffers:[]})}break;case`dispose`:if(hl=!0,bl!=null&&(clearTimeout(bl),bl=null),Q){try{await Q.close()}catch{}Q=null}break}}})();