Files
crdc-demo/assets/duckdb-browser-CTRvhmYS.js
T
2026-08-23 00:29:53 +00:00

2 lines
196 KiB
JavaScript

function e(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 t(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 n(e){return this instanceof n?(this.v=e,this):new n(e)}function r(e,t,r){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var i=r.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,d)}}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){f(o[0][3],e)}}function u(e){e.value instanceof n?Promise.resolve(e.value.v).then(ee,d):f(o[0][2],e)}function ee(e){l(`next`,e)}function d(e){l(`throw`,e)}function f(e,t){e(t),o.shift(),o.length&&l(o[0][0],o[0][1])}}function i(e){var t,r;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(r=!r)?{value:n(e[i](t)),done:!1}:a?a(t):t}:a}}function a(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var n=e[Symbol.asyncIterator],r;return n?n.call(e):(e=typeof t==`function`?t(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)}}var o=new TextDecoder(`utf-8`),s=e=>o.decode(e),c=new TextEncoder,l=e=>c.encode(e),u=e=>typeof e==`number`,ee=e=>typeof e==`boolean`,d=e=>typeof e==`function`,f=e=>e!=null&&Object(e)===e,te=e=>f(e)&&d(e.then),ne=e=>f(e)&&d(e[Symbol.iterator]),re=e=>f(e)&&d(e[Symbol.asyncIterator]),ie=e=>f(e)&&f(e.schema),ae=e=>f(e)&&`done`in e&&`value`in e,oe=e=>f(e)&&d(e.stat)&&u(e.fd),se=e=>f(e)&&ue(e.body),ce=e=>`_getDOMStream`in e&&`_getNodeStream`in e,le=e=>f(e)&&d(e.abort)&&d(e.getWriter)&&!ce(e),ue=e=>f(e)&&d(e.cancel)&&d(e.getReader)&&!ce(e),de=e=>f(e)&&d(e.end)&&d(e.write)&&ee(e.writable)&&!ce(e),fe=e=>f(e)&&d(e.read)&&d(e.pipe)&&ee(e.readable)&&!ce(e),pe=e=>f(e)&&d(e.clear)&&d(e.bytes)&&d(e.position)&&d(e.setPosition)&&d(e.capacity)&&d(e.getBufferIdentifier)&&d(e.createLong),me=typeof SharedArrayBuffer<`u`?SharedArrayBuffer:ArrayBuffer;function he(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 ge(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 _e(e,t){let n=he(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?ge(o,a,s):o=a;break}ge(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=ae(t)?t.value:t;return n instanceof e?e===Uint8Array?new e(n.buffer,n.byteOffset,n.byteLength):n:n?(typeof n==`string`&&(n=l(n)),n instanceof ArrayBuffer||n instanceof me?new e(n):pe(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)}var ve=e=>p(Int32Array,e),ye=e=>p(BigInt64Array,e),m=e=>p(Uint8Array,e),be=e=>(e.next(),e);function*xe(e,t){let n=function*(e){yield e};return yield*be((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 me?n(t):ne(t)?t:n(t))[Symbol.iterator]())),new e}var Se=e=>xe(Uint8Array,e);function Ce(e,t){return r(this,arguments,function*(){if(te(t))return yield n(yield n(yield*i(a(Ce(e,yield n(t))))));let o=function(e){return r(this,arguments,function*(){yield yield n(yield n(e))})};return yield n(yield*i(a(be((function(t){return r(this,arguments,function*(){let r=null;do r=yield n(t.next(yield yield n(p(e,r))));while(!r.done)})})((typeof t==`string`||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof me?o(t):ne(t)?function(e){return r(this,arguments,function*(){yield n(yield*i(a(be((function*(e){let t=null;do t=e.next(yield t?.value);while(!t.done)})(e[Symbol.iterator]())))))})}(t):re(t)?t:o(t))[Symbol.asyncIterator]()))))),yield n(new e)})}var we=e=>Ce(Uint8Array,e);function Te(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 Ee(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 De={fromIterable(e){return Oe(ke(e))},fromAsyncIterable(e){return Oe(Ae(e))},fromDOMStream(e){return Oe(je(e))},fromNodeStream(e){return Oe(Pe(e))},toDOMStream(e,t){throw Error(`"toDOMStream" not available in this environment`)},toNodeStream(e,t){throw Error(`"toNodeStream" not available in this environment`)}},Oe=e=>(e.next(),e);function*ke(e){let t,n=!1,r=[],i,a,o,s=0;function c(){return a===`peek`?_e(r,o)[0]:([i,r,s]=_e(r,o),i)}({cmd:a,size:o}=(yield null)||{cmd:`read`,size:0});let l=Se(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 Ae(e){return r(this,arguments,function*(){let t,r=!1,i=[],a,o,s,c=0;function l(){return o===`peek`?_e(i,s)[0]:([a,i,c]=_e(i,s),a)}({cmd:o,size:s}=(yield yield n(null))||{cmd:`read`,size:0});let u=we(e)[Symbol.asyncIterator]();try{do if({done:t,value:a}=Number.isNaN(s-c)?yield n(u.next()):yield n(u.next(s-c)),!t&&a.byteLength>0&&(i.push(a),c+=a.byteLength),t||s<=c)do({cmd:o,size:s}=yield yield n(l()));while(s<c);while(!t)}catch(e){(r=!0)&&typeof u.throw==`function`&&(yield n(u.throw(e)))}finally{r===!1&&typeof u.return==`function`&&(yield n(u.return(new Uint8Array)))}return yield n(null)})}function je(e){return r(this,arguments,function*(){let t=!1,r=!1,i=[],a,o,s,c=0;function l(){return o===`peek`?_e(i,s)[0]:([a,i,c]=_e(i,s),a)}({cmd:o,size:s}=(yield yield n(null))||{cmd:`read`,size:0});let u=new Me(e);try{do if({done:t,value:a}=Number.isNaN(s-c)?yield n(u.read()):yield n(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 n(l()));while(s<c);while(!t)}catch(e){(r=!0)&&(yield n(u.cancel(e)))}finally{r===!1?yield n(u.cancel()):e.locked&&u.releaseLock()}return yield n(null)})}var Me=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(t){return e(this,void 0,void 0,function*(){let{reader:e,source:n}=this;e&&(yield e.cancel(t).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(t){return e(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array};let e=yield this.reader.read();return!e.done&&(e.value=m(e)),e})}},Ne=(e,t)=>{let n=e=>r([t,e]),r;return[t,n,new Promise(i=>(r=i)&&e.once(t,n))]};function Pe(e){return r(this,arguments,function*(){let t=[],r=`error`,i=!1,a=null,o,s,c=0,l=[],u;function ee(){return o===`peek`?_e(l,s)[0]:([u,l,c]=_e(l,s),u)}if({cmd:o,size:s}=(yield yield n(null))||{cmd:`read`,size:0},e.isTTY)return yield yield n(new Uint8Array),yield n(null);try{t[0]=Ne(e,`end`),t[1]=Ne(e,`error`);do{if(t[2]=Ne(e,`readable`),[r,a]=yield n(Promise.race(t.map(e=>e[2]))),r===`error`)break;if((i=r===`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 n(ee()));while(s<c)}while(!i)}finally{yield n(d(t,r===`error`?a:null))}return yield n(null);function d(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 Fe;(function(e){e[e.DAY=0]=`DAY`,e[e.MILLISECOND=1]=`MILLISECOND`})(Fe||={});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 Ie;(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`})(Ie||={});var Le=new Int32Array(2),Re=new Float32Array(Le.buffer),ze=new Float64Array(Le.buffer),Be=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1,Ve;(function(e){e[e.UTF8_BYTES=1]=`UTF8_BYTES`,e[e.UTF16_STRING=2]=`UTF16_STRING`})(Ve||={});var He=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 Le[0]=this.readInt32(e),Re[0]}readFloat64(e){return Le[+!Be]=this.readInt32(e),Le[+!!Be]=this.readInt32(e+4),ze[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){Re[0]=t,this.writeInt32(e,Le[0])}writeFloat64(e,t){ze[0]=t,this.writeInt32(e,Le[+!Be]),this.writeInt32(e+4,Le[+!!Be])}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===Ve.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}},Ue=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=He.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=He.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()}},We;(function(e){e[e.BUFFER=0]=`BUFFER`})(We||={});var Ge;(function(e){e[e.LZ4_FRAME=0]=`LZ4_FRAME`,e[e.ZSTD=1]=`ZSTD`})(Ge||={});var Ke=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):Ge.LZ4_FRAME}method(){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt8(this.bb_pos+e):We.BUFFER}static startBodyCompression(e){e.startObject(2)}static addCodec(e,t){e.addFieldInt8(0,t,Ge.LZ4_FRAME)}static addMethod(e,t){e.addFieldInt8(1,t,We.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)}},qe=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()}},Je=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()}},Ye=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 Je).__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 qe).__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 Ke).__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()}},Xe=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 Ye).__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()}},Ze;(function(e){e[e.Little=0]=`Little`,e[e.Big=1]=`Big`})(Ze||={});var Qe;(function(e){e[e.DenseArray=0]=`DenseArray`})(Qe||={});var $e=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)}},et=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 $e).__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):Qe.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,Qe.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)}},tt=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)}},nt=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)}},rt=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):Fe.MILLISECOND}static startDate(e){e.startObject(1)}static addUnit(e,t){e.addFieldInt16(0,t,Fe.MILLISECOND)}static endDate(e){return e.endObject()}static createDate(t,n){return e.startDate(t),e.addUnit(t,n),e.endDate(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 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)}},at=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)}},ot=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)}},st=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)}},ct=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)}},lt=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):Ie.YEAR_MONTH}static startInterval(e){e.startObject(1)}static addUnit(e,t){e.addFieldInt16(0,t,Ie.YEAR_MONTH)}static endInterval(e){return e.endObject()}static createInterval(t,n){return e.startInterval(t),e.addUnit(t,n),e.endInterval(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 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)}},dt=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)}},ft=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)}},pt=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)}},mt=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)}},ht=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)}},gt=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)}},_t=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)}},vt=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)}},yt=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 et).__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()}},bt=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):Ze.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,Ze.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 xt;(function(e){e[e.OFFSET=0]=`OFFSET`,e[e.DATA=1]=`DATA`,e[e.VALIDITY=2]=`VALIDITY`,e[e.TYPE=3]=`TYPE`})(xt||={});var St=void 0;function Ct(e){if(e===null)return`null`;if(e===St)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)}var Tt=Symbol.for(`isArrowBigNum`);function T(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)}T.prototype[Tt]=!0,T.prototype.toJSON=function(){return`"${jt(this)}"`},T.prototype.valueOf=function(e){return At(this,e)},T.prototype.toString=function(){return jt(this)},T.prototype[Symbol.toPrimitive]=function(e=`default`){switch(e){case`number`:return At(this);case`string`:return jt(this);case`default`:return Mt(this)}return jt(this)};function Et(...e){return T.apply(this,e)}function Dt(...e){return T.apply(this,e)}function Ot(...e){return T.apply(this,e)}Object.setPrototypeOf(Et.prototype,Object.create(Int32Array.prototype)),Object.setPrototypeOf(Dt.prototype,Object.create(Uint32Array.prototype)),Object.setPrototypeOf(Ot.prototype,Object.create(Uint32Array.prototype)),Object.assign(Et.prototype,T.prototype,{constructor:Et,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array}),Object.assign(Dt.prototype,T.prototype,{constructor:Dt,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array}),Object.assign(Ot.prototype,T.prototype,{constructor:Ot,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var kt=BigInt(4294967296)*BigInt(4294967296)-BigInt(1);function At(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^kt)*(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 jt(e){if(e.byteLength===8)return`${new e.BigIntArray(e.buffer,e.byteOffset,1)[0]}`;if(!e.signed)return Nt(e);let t=new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Nt(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`-${Nt(t)}`}function Mt(e){return e.byteLength===8?new e.BigIntArray(e.buffer,e.byteOffset,1)[0]:jt(e)}function Nt(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 Pt=class e{static new(e,t){switch(t){case!0:return new Et(e);case!1:return new Dt(e)}switch(e.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new Et(e)}return e.byteLength===16?new Ot(e):new Dt(e)}static signed(e){return new Et(e)}static unsigned(e){return new Dt(e)}static decimal(e){return new Ot(e)}constructor(t,n){return e.new(t,n)}},Ft,It,Lt,Rt,zt,Bt,Vt,Ht,Ut,Wt,Gt,Kt,qt,Jt,Yt,Xt,Zt,Qt,$t,en,tn,nn,E=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}};Ft=Symbol.toStringTag,E[Ft]=(e=>(e.children=null,e.ArrayType=Array,e.OffsetArrayType=Int32Array,e[Symbol.toStringTag]=`DataType`))(E.prototype);var rn=class extends E{constructor(){super(C.Null)}toString(){return`Null`}};It=Symbol.toStringTag,rn[It]=(e=>e[Symbol.toStringTag]=`Null`)(rn.prototype);var D=class extends E{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}`}};Lt=Symbol.toStringTag,D[Lt]=(e=>(e.isSigned=null,e.bitWidth=null,e[Symbol.toStringTag]=`Int`))(D.prototype);var an=class extends D{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},on=class extends D{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},sn=class extends D{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},cn=class extends D{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},ln=class extends D{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},un=class extends D{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},dn=class extends D{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},fn=class extends D{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(an.prototype,"ArrayType",{value:Int8Array}),Object.defineProperty(on.prototype,"ArrayType",{value:Int16Array}),Object.defineProperty(sn.prototype,"ArrayType",{value:Int32Array}),Object.defineProperty(cn.prototype,"ArrayType",{value:BigInt64Array}),Object.defineProperty(ln.prototype,"ArrayType",{value:Uint8Array}),Object.defineProperty(un.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(dn.prototype,"ArrayType",{value:Uint32Array}),Object.defineProperty(fn.prototype,"ArrayType",{value:BigUint64Array});var pn=class extends E{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}`}};Rt=Symbol.toStringTag,pn[Rt]=(e=>(e.precision=null,e[Symbol.toStringTag]=`Float`))(pn.prototype);var mn=class extends pn{constructor(){super(_.HALF)}},hn=class extends pn{constructor(){super(_.SINGLE)}},gn=class extends pn{constructor(){super(_.DOUBLE)}};Object.defineProperty(mn.prototype,"ArrayType",{value:Uint16Array}),Object.defineProperty(hn.prototype,"ArrayType",{value:Float32Array}),Object.defineProperty(gn.prototype,"ArrayType",{value:Float64Array});var _n=class extends E{constructor(){super(C.Binary)}toString(){return`Binary`}};zt=Symbol.toStringTag,_n[zt]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Binary`))(_n.prototype);var vn=class extends E{constructor(){super(C.LargeBinary)}toString(){return`LargeBinary`}};Bt=Symbol.toStringTag,vn[Bt]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeBinary`))(vn.prototype);var yn=class extends E{constructor(){super(C.Utf8)}toString(){return`Utf8`}};Vt=Symbol.toStringTag,yn[Vt]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Utf8`))(yn.prototype);var bn=class extends E{constructor(){super(C.LargeUtf8)}toString(){return`LargeUtf8`}};Ht=Symbol.toStringTag,bn[Ht]=(e=>(e.ArrayType=Uint8Array,e.OffsetArrayType=BigInt64Array,e[Symbol.toStringTag]=`LargeUtf8`))(bn.prototype);var xn=class extends E{constructor(){super(C.Bool)}toString(){return`Bool`}};Ut=Symbol.toStringTag,xn[Ut]=(e=>(e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`Bool`))(xn.prototype);var Sn=class extends E{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}]`}};Wt=Symbol.toStringTag,Sn[Wt]=(e=>(e.scale=null,e.precision=null,e.ArrayType=Uint32Array,e[Symbol.toStringTag]=`Decimal`))(Sn.prototype);var Cn=class extends E{constructor(e){super(C.Date),this.unit=e}toString(){return`Date${(this.unit+1)*32}<${Fe[this.unit]}>`}get ArrayType(){return this.unit===Fe.DAY?Int32Array:BigInt64Array}};Gt=Symbol.toStringTag,Cn[Gt]=(e=>(e.unit=null,e[Symbol.toStringTag]=`Date`))(Cn.prototype);var wn=class extends E{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`)}};Kt=Symbol.toStringTag,wn[Kt]=(e=>(e.unit=null,e.bitWidth=null,e[Symbol.toStringTag]=`Time`))(wn.prototype);var Tn=class extends E{constructor(e,t){super(C.Timestamp),this.unit=e,this.timezone=t}toString(){return`Timestamp<${v[this.unit]}${this.timezone?`, ${this.timezone}`:``}>`}};qt=Symbol.toStringTag,Tn[qt]=(e=>(e.unit=null,e.timezone=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Timestamp`))(Tn.prototype);var En=class extends E{constructor(e){super(C.Interval),this.unit=e}toString(){return`Interval<${Ie[this.unit]}>`}};Jt=Symbol.toStringTag,En[Jt]=(e=>(e.unit=null,e.ArrayType=Int32Array,e[Symbol.toStringTag]=`Interval`))(En.prototype);var Dn=class extends E{constructor(e){super(C.Duration),this.unit=e}toString(){return`Duration<${v[this.unit]}>`}};Yt=Symbol.toStringTag,Dn[Yt]=(e=>(e.unit=null,e.ArrayType=BigInt64Array,e[Symbol.toStringTag]=`Duration`))(Dn.prototype);var On=class extends E{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}};Xt=Symbol.toStringTag,On[Xt]=(e=>(e.children=null,e[Symbol.toStringTag]=`List`))(On.prototype);var O=class extends E{constructor(e){super(C.Struct),this.children=e}toString(){return`Struct<{${this.children.map(e=>`${e.name}:${e.type}`).join(`, `)}}>`}};Zt=Symbol.toStringTag,O[Zt]=(e=>(e.children=null,e[Symbol.toStringTag]=`Struct`))(O.prototype);var kn=class extends E{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(` | `)}>`}};Qt=Symbol.toStringTag,kn[Qt]=(e=>(e.mode=null,e.typeIds=null,e.children=null,e.typeIdToChildIndex=null,e.ArrayType=Int8Array,e[Symbol.toStringTag]=`Union`))(kn.prototype);var An=class extends E{constructor(e){super(C.FixedSizeBinary),this.byteWidth=e}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};$t=Symbol.toStringTag,An[$t]=(e=>(e.byteWidth=null,e.ArrayType=Uint8Array,e[Symbol.toStringTag]=`FixedSizeBinary`))(An.prototype);var jn=class extends E{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}>`}};en=Symbol.toStringTag,jn[en]=(e=>(e.children=null,e.listSize=null,e[Symbol.toStringTag]=`FixedSizeList`))(jn.prototype);var Mn=class extends E{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(`, `)}}>`}};tn=Symbol.toStringTag,Mn[tn]=(e=>(e.children=null,e.keysSorted=null,e[Symbol.toStringTag]=`Map_`))(Mn.prototype);var Nn=(e=>()=>++e)(-1),Pn=class extends E{constructor(e,t,n,r){super(C.Dictionary),this.indices=t,this.dictionary=e,this.isOrdered=r||!1,this.id=n==null?Nn():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}>`}};nn=Symbol.toStringTag,Pn[nn]=(e=>(e.id=null,e.indices=null,e.isOrdered=null,e.dictionary=null,e[Symbol.toStringTag]=`Dictionary`))(Pn.prototype);function Fn(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 k=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 In(this,e,t)}getVisitFnByTypeId(e,t=!0){return Ln(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 In(e,t,n=!0){return typeof t==`number`?Ln(e,t,n):typeof t==`string`&&t in C?Ln(e,C[t],n):t&&t instanceof E?Ln(e,Rn(t),n):t?.type&&t.type instanceof E?Ln(e,Rn(t.type),n):Ln(e,C.NONE,n)}function Ln(e,t,n=!0){let r=null;switch(t){case C.Null:r=e.visitNull;break;case C.Bool:r=e.visitBool;break;case C.Int:r=e.visitInt;break;case C.Int8:r=e.visitInt8||e.visitInt;break;case C.Int16:r=e.visitInt16||e.visitInt;break;case C.Int32:r=e.visitInt32||e.visitInt;break;case C.Int64:r=e.visitInt64||e.visitInt;break;case C.Uint8:r=e.visitUint8||e.visitInt;break;case C.Uint16:r=e.visitUint16||e.visitInt;break;case C.Uint32:r=e.visitUint32||e.visitInt;break;case C.Uint64:r=e.visitUint64||e.visitInt;break;case C.Float:r=e.visitFloat;break;case C.Float16:r=e.visitFloat16||e.visitFloat;break;case C.Float32:r=e.visitFloat32||e.visitFloat;break;case C.Float64:r=e.visitFloat64||e.visitFloat;break;case C.Utf8:r=e.visitUtf8;break;case C.LargeUtf8:r=e.visitLargeUtf8;break;case C.Binary:r=e.visitBinary;break;case C.LargeBinary:r=e.visitLargeBinary;break;case C.FixedSizeBinary:r=e.visitFixedSizeBinary;break;case C.Date:r=e.visitDate;break;case C.DateDay:r=e.visitDateDay||e.visitDate;break;case C.DateMillisecond:r=e.visitDateMillisecond||e.visitDate;break;case C.Timestamp:r=e.visitTimestamp;break;case C.TimestampSecond:r=e.visitTimestampSecond||e.visitTimestamp;break;case C.TimestampMillisecond:r=e.visitTimestampMillisecond||e.visitTimestamp;break;case C.TimestampMicrosecond:r=e.visitTimestampMicrosecond||e.visitTimestamp;break;case C.TimestampNanosecond:r=e.visitTimestampNanosecond||e.visitTimestamp;break;case C.Time:r=e.visitTime;break;case C.TimeSecond:r=e.visitTimeSecond||e.visitTime;break;case C.TimeMillisecond:r=e.visitTimeMillisecond||e.visitTime;break;case C.TimeMicrosecond:r=e.visitTimeMicrosecond||e.visitTime;break;case C.TimeNanosecond:r=e.visitTimeNanosecond||e.visitTime;break;case C.Decimal:r=e.visitDecimal;break;case C.List:r=e.visitList;break;case C.Struct:r=e.visitStruct;break;case C.Union:r=e.visitUnion;break;case C.DenseUnion:r=e.visitDenseUnion||e.visitUnion;break;case C.SparseUnion:r=e.visitSparseUnion||e.visitUnion;break;case C.Dictionary:r=e.visitDictionary;break;case C.Interval:r=e.visitInterval;break;case C.IntervalDayTime:r=e.visitIntervalDayTime||e.visitInterval;break;case C.IntervalYearMonth:r=e.visitIntervalYearMonth||e.visitInterval;break;case C.Duration:r=e.visitDuration;break;case C.DurationSecond:r=e.visitDurationSecond||e.visitDuration;break;case C.DurationMillisecond:r=e.visitDurationMillisecond||e.visitDuration;break;case C.DurationMicrosecond:r=e.visitDurationMicrosecond||e.visitDuration;break;case C.DurationNanosecond:r=e.visitDurationNanosecond||e.visitDuration;break;case C.FixedSizeList:r=e.visitFixedSizeList;break;case C.Map:r=e.visitMap}if(typeof r==`function`)return r;if(!n)return()=>null;throw Error(`Unrecognized type '${C[t]}'`)}function Rn(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 Fe.DAY:return C.DateDay;case Fe.MILLISECOND:return C.DateMillisecond}return C.Date;case C.Interval:switch(e.unit){case Ie.DAY_TIME:return C.IntervalDayTime;case Ie.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]}'`)}k.prototype.visitInt8=null,k.prototype.visitInt16=null,k.prototype.visitInt32=null,k.prototype.visitInt64=null,k.prototype.visitUint8=null,k.prototype.visitUint16=null,k.prototype.visitUint32=null,k.prototype.visitUint64=null,k.prototype.visitFloat16=null,k.prototype.visitFloat32=null,k.prototype.visitFloat64=null,k.prototype.visitDateDay=null,k.prototype.visitDateMillisecond=null,k.prototype.visitTimestampSecond=null,k.prototype.visitTimestampMillisecond=null,k.prototype.visitTimestampMicrosecond=null,k.prototype.visitTimestampNanosecond=null,k.prototype.visitTimeSecond=null,k.prototype.visitTimeMillisecond=null,k.prototype.visitTimeMicrosecond=null,k.prototype.visitTimeNanosecond=null,k.prototype.visitDenseUnion=null,k.prototype.visitSparseUnion=null,k.prototype.visitIntervalDayTime=null,k.prototype.visitIntervalYearMonth=null,k.prototype.visitDuration=null,k.prototype.visitDurationSecond=null,k.prototype.visitDurationMillisecond=null,k.prototype.visitDurationMicrosecond=null,k.prototype.visitDurationNanosecond=null;var zn=new Float64Array(1),Bn=new Uint32Array(zn.buffer);function Vn(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 Hn(e){if(e!==e)return 32256;zn[0]=e;let t=(Bn[1]&2147483648)>>16&65535,n=Bn[1]&2146435072,r=0;return n>=1089470464?Bn[0]>0?n=31744:(n=(n&2080374784)>>16,r=(Bn[1]&1048575)>>10):n<=1056964608?(r=1048576+(Bn[1]&1048575),r=1048576+(r<<(n>>20)-998)>>21,n=0):(n=n-1056964608>>10,r=(Bn[1]&1048575)+512>>10),t|n|r&65535}var A=class extends k{};function j(e){return(t,n,r)=>{if(t.setValid(n,r!=null))return e(t,n,r)}}var Un=(e,t,n)=>{e[t]=Math.floor(n/864e5)},Wn=(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)}},Gn=({offset:e,values:t},n,r)=>{let i=e+n;r?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Kn=({values:e},t,n)=>{e[t]=n},qn=({values:e},t,n)=>{e[t]=n},Jn=({values:e},t,n)=>{e[t]=Hn(n)},Yn=(e,t,n)=>{switch(e.type.precision){case _.HALF:return Jn(e,t,n);case _.SINGLE:case _.DOUBLE:return qn(e,t,n)}},Xn=({values:e},t,n)=>{Un(e,t,n.valueOf())},Zn=({values:e},t,n)=>{e[t]=BigInt(n)},Qn=({stride:e,values:t},n,r)=>{t.set(r.subarray(0,e),e*n)},$n=({values:e,valueOffsets:t},n,r)=>Wn(e,t,n,r),er=({values:e,valueOffsets:t},n,r)=>Wn(e,t,n,l(r)),tr=(e,t,n)=>{e.type.unit===Fe.DAY?Xn(e,t,n):Zn(e,t,n)},nr=({values:e},t,n)=>{e[t]=BigInt(n/1e3)},rr=({values:e},t,n)=>{e[t]=BigInt(n)},ir=({values:e},t,n)=>{e[t]=BigInt(n*1e3)},ar=({values:e},t,n)=>{e[t]=BigInt(n*1e6)},or=(e,t,n)=>{switch(e.type.unit){case v.SECOND:return nr(e,t,n);case v.MILLISECOND:return rr(e,t,n);case v.MICROSECOND:return ir(e,t,n);case v.NANOSECOND:return ar(e,t,n)}},sr=({values:e},t,n)=>{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=(e,t,n)=>{switch(e.type.unit){case v.SECOND:return sr(e,t,n);case v.MILLISECOND:return cr(e,t,n);case v.MICROSECOND:return lr(e,t,n);case v.NANOSECOND:return ur(e,t,n)}},fr=({values:e,stride:t},n,r)=>{e.set(r.subarray(0,t),t*n)},pr=(e,t,n)=>{let r=e.children[0],i=e.valueOffsets,a=M.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))},mr=(e,t,n)=>{let r=e.children[0],{valueOffsets:i}=e,a=M.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},hr=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[a]),gr=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(a)),_r=(e,t)=>(n,r,i,a)=>r&&n(r,e,t.get(i.name)),vr=(e,t)=>(n,r,i,a)=>r&&n(r,e,t[i.name]),yr=(e,t,n)=>{let r=e.type.children.map(e=>M.getVisitFn(e.type)),i=n instanceof Map?_r(t,n):n instanceof U?gr(t,n):Array.isArray(n)?hr(t,n):vr(t,n);e.type.children.forEach((t,n)=>i(r[n],e.children[n],t,n))},br=(e,t,n)=>{e.type.mode===g.Dense?xr(e,t,n):Sr(e,t,n)},xr=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];M.visit(i,e.valueOffsets[t],n)},Sr=(e,t,n)=>{let r=e.type.typeIdToChildIndex[e.typeIds[t]],i=e.children[r];M.visit(i,t,n)},Cr=(e,t,n)=>{var r;(r=e.dictionary)==null||r.set(e.values[t],n)},wr=(e,t,n)=>{e.type.unit===Ie.DAY_TIME?Tr(e,t,n):Er(e,t,n)},Tr=({values:e},t,n)=>{e.set(n.subarray(0,2),2*t)},Er=({values:e},t,n)=>{e[t]=n[0]*12+n[1]%12},Dr=({values:e},t,n)=>{e[t]=n},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=(e,t,n)=>{switch(e.type.unit){case v.SECOND:return Dr(e,t,n);case v.MILLISECOND:return Or(e,t,n);case v.MICROSECOND:return kr(e,t,n);case v.NANOSECOND:return Ar(e,t,n)}},Mr=(e,t,n)=>{let{stride:r}=e,i=e.children[0],a=M.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))};A.prototype.visitBool=j(Gn),A.prototype.visitInt=j(Kn),A.prototype.visitInt8=j(Kn),A.prototype.visitInt16=j(Kn),A.prototype.visitInt32=j(Kn),A.prototype.visitInt64=j(Kn),A.prototype.visitUint8=j(Kn),A.prototype.visitUint16=j(Kn),A.prototype.visitUint32=j(Kn),A.prototype.visitUint64=j(Kn),A.prototype.visitFloat=j(Yn),A.prototype.visitFloat16=j(Jn),A.prototype.visitFloat32=j(qn),A.prototype.visitFloat64=j(qn),A.prototype.visitUtf8=j(er),A.prototype.visitLargeUtf8=j(er),A.prototype.visitBinary=j($n),A.prototype.visitLargeBinary=j($n),A.prototype.visitFixedSizeBinary=j(Qn),A.prototype.visitDate=j(tr),A.prototype.visitDateDay=j(Xn),A.prototype.visitDateMillisecond=j(Zn),A.prototype.visitTimestamp=j(or),A.prototype.visitTimestampSecond=j(nr),A.prototype.visitTimestampMillisecond=j(rr),A.prototype.visitTimestampMicrosecond=j(ir),A.prototype.visitTimestampNanosecond=j(ar),A.prototype.visitTime=j(dr),A.prototype.visitTimeSecond=j(sr),A.prototype.visitTimeMillisecond=j(cr),A.prototype.visitTimeMicrosecond=j(lr),A.prototype.visitTimeNanosecond=j(ur),A.prototype.visitDecimal=j(fr),A.prototype.visitList=j(pr),A.prototype.visitStruct=j(yr),A.prototype.visitUnion=j(br),A.prototype.visitDenseUnion=j(xr),A.prototype.visitSparseUnion=j(Sr),A.prototype.visitDictionary=j(Cr),A.prototype.visitInterval=j(wr),A.prototype.visitIntervalDayTime=j(Tr),A.prototype.visitIntervalYearMonth=j(Er),A.prototype.visitDuration=j(jr),A.prototype.visitDurationSecond=j(Dr),A.prototype.visitDurationMillisecond=j(Or),A.prototype.visitDurationMicrosecond=j(kr),A.prototype.visitDurationNanosecond=j(Ar),A.prototype.visitFixedSizeList=j(Mr),A.prototype.visitMap=j(mr);var M=new A,N=Symbol.for(`parent`),Nr=Symbol.for(`rowIndex`),Pr=class{constructor(e,t){return this[N]=e,this[Nr]=t,new Proxy(this,new Ir)}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[Nr],t=this[N],n=t.type.children,r={};for(let i=-1,a=n.length;++i<a;)r[n[i].name]=I.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 Fr(this[N],this[Nr])}},Fr=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,I.visit(this.children[e],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(Pr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[N]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Nr]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var Ir=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[N].type.children.map(e=>e.name)}has(e,t){return e[N].type.children.findIndex(e=>e.name===t)!==-1}getOwnPropertyDescriptor(e,t){if(e[N].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[N].type.children.findIndex(e=>e.name===t);if(n!==-1){let r=I.visit(e[N].children[n],e[Nr]);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[N].type.children.findIndex(e=>e.name===t);return r===-1?Reflect.has(e,t)||typeof t==`symbol`?Reflect.set(e,t,n):!1:(M.visit(e[N].children[r],e[Nr],n),Reflect.set(e,t,n))}},P=class extends k{};function F(e){return(t,n)=>t.getValid(n)?e(t,n):null}var Lr=(e,t)=>864e5*e[t],Rr=(e,t)=>null,zr=(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)},Br=({offset:e,values:t},n)=>{let r=e+n;return!!(t[r>>3]&1<<r%8)},Vr=({values:e},t)=>Lr(e,t),Hr=({values:e},t)=>w(e[t]),Ur=({stride:e,values:t},n)=>t[e*n],Wr=({stride:e,values:t},n)=>Vn(t[e*n]),Gr=({values:e},t)=>e[t],Kr=({stride:e,values:t},n)=>t.subarray(e*n,e*(n+1)),qr=({values:e,valueOffsets:t},n)=>zr(e,t,n),Jr=({values:e,valueOffsets:t},n)=>{let r=zr(e,t,n);return r===null?null:s(r)},Yr=({values:e},t)=>e[t],Xr=({type:e,values:t},n)=>e.precision===_.HALF?Vn(t[n]):t[n],Zr=(e,t)=>e.type.unit===Fe.DAY?Vr(e,t):Hr(e,t),Qr=({values:e},t)=>1e3*w(e[t]),$r=({values:e},t)=>w(e[t]),ei=({values:e},t)=>wt(e[t],BigInt(1e3)),ti=({values:e},t)=>wt(e[t],BigInt(1e6)),ni=(e,t)=>{switch(e.type.unit){case v.SECOND:return Qr(e,t);case v.MILLISECOND:return $r(e,t);case v.MICROSECOND:return ei(e,t);case v.NANOSECOND:return ti(e,t)}},ri=({values:e},t)=>e[t],ii=({values:e},t)=>e[t],ai=({values:e},t)=>e[t],oi=({values:e},t)=>e[t],si=(e,t)=>{switch(e.type.unit){case v.SECOND:return ri(e,t);case v.MILLISECOND:return ii(e,t);case v.MICROSECOND:return ai(e,t);case v.NANOSECOND:return oi(e,t)}},ci=({values:e,stride:t},n)=>Pt.decimal(e.subarray(t*n,t*(n+1))),li=(e,t)=>{let{valueOffsets:n,stride:r,children:i}=e,{[t*r]:a,[t*r+1]:o}=n;return new U([i[0].slice(a,o-a)])},ui=(e,t)=>{let{valueOffsets:n,children:r}=e,{[t]:i,[t+1]:a}=n,o=r[0];return new ki(o.slice(i,a-i))},di=(e,t)=>new Pr(e,t),fi=(e,t)=>e.type.mode===g.Dense?pi(e,t):mi(e,t),pi=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return I.visit(r,e.valueOffsets[t])},mi=(e,t)=>{let n=e.type.typeIdToChildIndex[e.typeIds[t]],r=e.children[n];return I.visit(r,t)},hi=(e,t)=>e.dictionary?.get(e.values[t]),gi=(e,t)=>e.type.unit===Ie.DAY_TIME?_i(e,t):vi(e,t),_i=({values:e},t)=>e.subarray(2*t,2*(t+1)),vi=({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},yi=({values:e},t)=>e[t],bi=({values:e},t)=>e[t],xi=({values:e},t)=>e[t],Si=({values:e},t)=>e[t],Ci=(e,t)=>{switch(e.type.unit){case v.SECOND:return yi(e,t);case v.MILLISECOND:return bi(e,t);case v.MICROSECOND:return xi(e,t);case v.NANOSECOND:return Si(e,t)}},wi=(e,t)=>{let{stride:n,children:r}=e;return new U([r[0].slice(t*n,n)])};P.prototype.visitNull=F(Rr),P.prototype.visitBool=F(Br),P.prototype.visitInt=F(Yr),P.prototype.visitInt8=F(Ur),P.prototype.visitInt16=F(Ur),P.prototype.visitInt32=F(Ur),P.prototype.visitInt64=F(Gr),P.prototype.visitUint8=F(Ur),P.prototype.visitUint16=F(Ur),P.prototype.visitUint32=F(Ur),P.prototype.visitUint64=F(Gr),P.prototype.visitFloat=F(Xr),P.prototype.visitFloat16=F(Wr),P.prototype.visitFloat32=F(Ur),P.prototype.visitFloat64=F(Ur),P.prototype.visitUtf8=F(Jr),P.prototype.visitLargeUtf8=F(Jr),P.prototype.visitBinary=F(qr),P.prototype.visitLargeBinary=F(qr),P.prototype.visitFixedSizeBinary=F(Kr),P.prototype.visitDate=F(Zr),P.prototype.visitDateDay=F(Vr),P.prototype.visitDateMillisecond=F(Hr),P.prototype.visitTimestamp=F(ni),P.prototype.visitTimestampSecond=F(Qr),P.prototype.visitTimestampMillisecond=F($r),P.prototype.visitTimestampMicrosecond=F(ei),P.prototype.visitTimestampNanosecond=F(ti),P.prototype.visitTime=F(si),P.prototype.visitTimeSecond=F(ri),P.prototype.visitTimeMillisecond=F(ii),P.prototype.visitTimeMicrosecond=F(ai),P.prototype.visitTimeNanosecond=F(oi),P.prototype.visitDecimal=F(ci),P.prototype.visitList=F(li),P.prototype.visitStruct=F(di),P.prototype.visitUnion=F(fi),P.prototype.visitDenseUnion=F(pi),P.prototype.visitSparseUnion=F(mi),P.prototype.visitDictionary=F(hi),P.prototype.visitInterval=F(gi),P.prototype.visitIntervalDayTime=F(_i),P.prototype.visitIntervalYearMonth=F(vi),P.prototype.visitDuration=F(Ci),P.prototype.visitDurationSecond=F(yi),P.prototype.visitDurationMillisecond=F(bi),P.prototype.visitDurationMicrosecond=F(xi),P.prototype.visitDurationNanosecond=F(Si),P.prototype.visitFixedSizeList=F(wi),P.prototype.visitMap=F(ui);var I=new P,Ti=Symbol.for(`keys`),Ei=Symbol.for(`vals`),Di=Symbol.for(`kKeysAsStrings`),Oi=Symbol.for(`_kKeysAsStrings`),ki=class{constructor(e){return this[Ti]=new U([e.children[0]]).memoize(),this[Ei]=e.children[1],new Proxy(this,new ji)}get[Di](){return this[Oi]||(this[Oi]=Array.from(this[Ti].toArray(),String))}[Symbol.iterator](){return new Ai(this[Ti],this[Ei])}get size(){return this[Ti].length}toArray(){return Object.values(this.toJSON())}toJSON(){let e=this[Ti],t=this[Ei],n={};for(let r=-1,i=e.length;++r<i;)n[e.get(r)]=I.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()}},Ai=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),I.visit(this.vals,e)]})}},ji=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(e){return e[Di]}has(e,t){return e[Di].includes(t)}getOwnPropertyDescriptor(e,t){if(e[Di].indexOf(t)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(e,t){if(Reflect.has(e,t))return e[t];let n=e[Di].indexOf(t);if(n!==-1){let r=I.visit(Reflect.get(e,Ei),n);return Reflect.set(e,t,r),r}}set(e,t,n){let r=e[Di].indexOf(t);return r===-1?Reflect.has(e,t)?Reflect.set(e,t,n):!1:(M.visit(Reflect.get(e,Ei),r,n),Reflect.set(e,t,n))}};Object.defineProperties(ki.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:`Row`},[Ti]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Ei]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Oi]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var Mi;function Ni(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&&(Mi=a,a=o,o=Mi),o>i&&(o=i),r?r(e,a,o):[a,o]}var Pi=(e,t)=>e<0?t+e:e,Fi=e=>e!==e;function Ii(e){if(typeof e!=`object`||!e)return Fi(e)?Fi:t=>t===e;if(e instanceof Date){let t=e.valueOf();return e=>e instanceof Date&&e.valueOf()===t}return ArrayBuffer.isView(e)?t=>t?Ee(e,t):!1:e instanceof Map?Ri(e):Array.isArray(e)?Li(e):e instanceof U?zi(e):Bi(e,!0)}function Li(e){let t=[];for(let n=-1,r=e.length;++n<r;)t[n]=Ii(e[n]);return Vi(t)}function Ri(e){let t=-1,n=[];for(let r of e.values())n[++t]=Ii(r);return Vi(n)}function zi(e){let t=[];for(let n=-1,r=e.length;++n<r;)t[n]=Ii(e.get(n));return Vi(t)}function Bi(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]=Ii(e[n[t]]);return Vi(r,n)}function Vi(e,t){return n=>{if(!n||typeof n!=`object`)return!1;switch(n.constructor){case Array:return Hi(e,n);case Map:return Wi(e,n,n.keys());case ki:case Pr:case Object:case void 0:return Wi(e,n,t||Object.keys(n))}return n instanceof U&&Ui(e,n)}}function Hi(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 Ui(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 Wi(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 Gi(e,t,n,r){return!!(n&1<<r)}function Ki(e,t,n,r){return(n&1<<r)>>r}function qi(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):Ji(new Yi(n,e,t,null,Gi)).subarray(0,r)),i}return n}function Ji(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 Yi=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 Xi(e,t,n){if(n-t<=0)return 0;if(n-t<8){let r=0;for(let i of new Yi(e,t,n-t,e,Ki))r+=i;return r}let r=n>>3<<3,i=t+(t%8==0?0:8-t%8);return Xi(e,t,i)+Xi(e,r,n)+Zi(e,i>>3,r-i>>3)}function Zi(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+=Qi(a.getUint32(i)),i+=4;for(;o-i>=2;)r+=Qi(a.getUint16(i)),i+=2;for(;o-i>=1;)r+=Qi(a.getUint8(i)),i+=1;return r}function Qi(e){let t=Math.trunc(e);return t-=t>>>1&1431655765,t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var L=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 E.isSparseUnion(e)||E.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(E.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-Xi(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=Fn(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(E.isUnion(t)){let n=t,r=this.children[n.typeIdToChildIndex[this.typeIds[e]]],i=n.mode===g.Dense?this.valueOffsets[e]:e;return r.getValid(i)}if(this.nullable&&this.nullCount>0){let t=this.offset+e;return!!(this.nullBitmap[t>>3]&1<<t%8)}return!0}setValid(e,t){let n,{type:r}=this;if(E.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(qi(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(qi(this.offset,t,this.nullBitmap),0);let i=this.buffers;return i[xt.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[xt.TYPE])&&(a[xt.TYPE]=i.subarray(e,e+t)),(i=a[xt.OFFSET])&&(a[xt.OFFSET]=i.subarray(e,e+t+1))||(i=a[xt.DATA])&&(a[xt.DATA]=r===6?i:i.subarray(n*e,n*(e+t))),a}_sliceChildren(e,t,n){return e.map(e=>e.slice(t,n))}};L.prototype.children=Object.freeze([]);var $i=new class e extends k{visit(e){return this.getVisitFn(e.type).call(this,e)}visitNull(e){let{type:t,offset:n=0,length:r=0}=e;return new L(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 L(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 L(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 L(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=ve(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new L(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=ye(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new L(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=ve(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new L(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=ye(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new L(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/Fn(t),nullCount:o=e.nullBitmap?-1:0}=e;return new L(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/Fn(t),nullCount:o=e.nullBitmap?-1:0}=e;return new L(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/Fn(t),nullCount:o=e.nullBitmap?-1:0}=e;return new L(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/Fn(t),nullCount:o=e.nullBitmap?-1:0}=e;return new L(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/Fn(t),nullCount:o=e.nullBitmap?-1:0}=e;return new L(t,n,a,o,[void 0,i,r])}visitList(e){let{type:t,offset:n=0,child:r}=e,i=m(e.nullBitmap),a=ve(e.valueOffsets),{length:o=a.length-1,nullCount:s=e.nullBitmap?-1:0}=e;return new L(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 L(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 E.isSparseUnion(t)?new L(t,n,a,o,[void 0,void 0,void 0,i],r):new L(t,n,a,o,[ve(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 U([new e().visit({type:n.dictionary})])}=t,{length:s=a.length,nullCount:c=t.nullBitmap?-1:0}=t;return new L(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/Fn(t),nullCount:o=e.nullBitmap?-1:0}=e;return new L(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 L(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/Fn(n),nullCount:s=t.nullBitmap?-1:0}=t;return new L(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=ve(t.valueOffsets),{length:s=o.length-1,nullCount:c=t.nullBitmap?-1:0}=t;return new L(n,r,s,c,[o,void 0,a],[i])}};function R(e){return $i.visit(e)}var ea=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 ta(e){return e.some(e=>e.nullable)}function na(e){return e.reduce((e,t)=>e+t.nullCount,0)}function ra(e){return e.reduce((e,t,n)=>(e[n+1]=e[n]+t.length,e),new Uint32Array(e.length+1))}function ia(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 aa(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 oa(e,t){return e.getValid(t)}function sa(e){function t(t,n,r){return e(t[n],r)}return function(e){let n=this.data;return aa(n,this._offsets,e,t)}}function ca(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=aa(i,this._offsets,e,n);return t=void 0,a}}function la(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`?aa(i,this._offsets,r,n):n(i,0,0);return t=void 0,a}}var z=class extends k{};function ua(e,t){return t===null&&e.length>0?0:-1}function da(e,t){let{nullBitmap:n}=e;if(!n||e.nullCount<=0)return-1;let r=0;for(let i of new Yi(n,e.offset+(t||0),e.length,n,Gi)){if(!i)return r;++r}return-1}function B(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 da(e,n)}let r=I.getVisitFn(e),i=Ii(t);for(let t=(n||0)-1,a=e.length;++t<a;)if(i(r(e,t)))return t;return-1}function fa(e,t,n){let r=I.getVisitFn(e),i=Ii(t);for(let t=(n||0)-1,a=e.length;++t<a;)if(i(r(e,t)))return t;return-1}z.prototype.visitNull=ua,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=fa,z.prototype.visitSparseUnion=fa,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;var pa=new z,V=class extends k{};function H(e){let{type:t}=e;if(e.nullCount===0&&e.stride===1&&(E.isInt(t)&&t.bitWidth!==64||E.isTime(t)&&t.bitWidth!==64||E.isFloat(t)&&t.precision!==_.HALF))return new ea(e.data.length,t=>{let n=e.data[t];return n.values.subarray(0,n.length)[Symbol.iterator]()});let n=0;return new ea(e.data.length,t=>{let r=e.data[t].length,i=e.slice(n,n+r);return n+=r,new ma(i)})}var ma=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}};V.prototype.visitNull=H,V.prototype.visitBool=H,V.prototype.visitInt=H,V.prototype.visitInt8=H,V.prototype.visitInt16=H,V.prototype.visitInt32=H,V.prototype.visitInt64=H,V.prototype.visitUint8=H,V.prototype.visitUint16=H,V.prototype.visitUint32=H,V.prototype.visitUint64=H,V.prototype.visitFloat=H,V.prototype.visitFloat16=H,V.prototype.visitFloat32=H,V.prototype.visitFloat64=H,V.prototype.visitUtf8=H,V.prototype.visitLargeUtf8=H,V.prototype.visitBinary=H,V.prototype.visitLargeBinary=H,V.prototype.visitFixedSizeBinary=H,V.prototype.visitDate=H,V.prototype.visitDateDay=H,V.prototype.visitDateMillisecond=H,V.prototype.visitTimestamp=H,V.prototype.visitTimestampSecond=H,V.prototype.visitTimestampMillisecond=H,V.prototype.visitTimestampMicrosecond=H,V.prototype.visitTimestampNanosecond=H,V.prototype.visitTime=H,V.prototype.visitTimeSecond=H,V.prototype.visitTimeMillisecond=H,V.prototype.visitTimeMicrosecond=H,V.prototype.visitTimeNanosecond=H,V.prototype.visitDecimal=H,V.prototype.visitList=H,V.prototype.visitStruct=H,V.prototype.visitUnion=H,V.prototype.visitDenseUnion=H,V.prototype.visitSparseUnion=H,V.prototype.visitDictionary=H,V.prototype.visitInterval=H,V.prototype.visitIntervalDayTime=H,V.prototype.visitIntervalYearMonth=H,V.prototype.visitDuration=H,V.prototype.visitDurationSecond=H,V.prototype.visitDurationMillisecond=H,V.prototype.visitDurationMicrosecond=H,V.prototype.visitDurationNanosecond=H,V.prototype.visitFixedSizeList=H,V.prototype.visitMap=H;var ha=new V,ga,_a={},va={},U=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 L)))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}=_a[r.typeId],a=n[0];this.isValid=e=>oa(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,va[r.typeId]),this._offsets=ra(n)}this.data=n,this.type=r,this.stride=Fn(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 ta(this.data)}get nullCount(){return na(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(Pi(e,this.length))}set(e,t){}indexOf(e,t){return-1}includes(e,t){return this.indexOf(e,t)>-1}[Symbol.iterator](){return ha.visit(this)}concat(...t){return new e(this.data.concat(t.flatMap(e=>e.data).flat(1/0)))}slice(t,n){return new e(Ni(this,t,n,({data:e,_offsets:t},n,r)=>ia(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 E.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(E.isDictionary(this.type)){let t=new ya(this.data[0].dictionary),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return new ya(this)}unmemoize(){if(E.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),n=this.data.map(e=>{let n=e.clone();return n.dictionary=t,n});return new e(n)}return this}};ga=Symbol.toStringTag,U[ga]=(e=>{e.type=E.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)_a[n]={get:I.getVisitFnByTypeId(n),set:M.getVisitFnByTypeId(n),indexOf:pa.getVisitFnByTypeId(n)},va[n]=Object.create(e,{isValid:{value:sa(oa)},get:{value:sa(I.getVisitFnByTypeId(n))},set:{value:ca(M.getVisitFnByTypeId(n))},indexOf:{value:la(pa.getVisitFnByTypeId(n))}});return`Vector`})(U.prototype);var ya=class e extends U{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 U(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}},ba=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()}},xa=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 bt).__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 ba).__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 ba).__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)}},W=class e{constructor(e=[],t,n,r=h.V5){this.fields=e||[],this.metadata=t||new Map,n||=Ca(this.fields),this.dictionaries=n,this.metadataVersion=r}get[Symbol.toStringTag](){return`Schema`}get names(){return this.fields.map(e=>e.name)}toString(){return`Schema<{ ${this.fields.map((e,t)=>`${t}: ${e}`).join(`, `)} }>`}select(t){let n=new Set(t),r=this.fields.filter(e=>n.has(e.name));return new e(r,this.metadata)}selectAt(t){let n=t.map(e=>this.fields[e]).filter(Boolean);return new e(n,this.metadata)}assign(...t){let n=t[0]instanceof e?t[0]:Array.isArray(t[0])?new e(t[0]):new e(t),r=[...this.fields],i=Sa(Sa(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:Sa(Sa(new Map,r[t].metadata),e.metadata)}))&&!1}),o=Ca(a,new Map);return new e([...r,...a],i,new Map([...this.dictionaries,...o]))}};W.prototype.fields=null,W.prototype.metadata=null,W.prototype.dictionaries=null;var G=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)}};G.prototype.type=null,G.prototype.name=null,G.prototype.nullable=null,G.prototype.metadata=null;function Sa(e,t){return new Map([...e||new Map,...t||new Map])}function Ca(e,t=new Map){for(let n=-1,r=e.length;++n<r;){let r=e[n].type;if(E.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&&Ca(r.children,t)}return t}var wa=Ue,Ta=He,Ea=class{static decode(e){e=new Ta(m(e));let t=xa.getRootAsFooter(e);return new Da(W.decode(t.schema(),new Map,t.version()),t)}static encode(e){let t=new wa,n=W.encode(t,e.schema);xa.startRecordBatchesVector(t,e.numRecordBatches);for(let n of[...e.recordBatches()].slice().reverse())Oa.encode(t,n);let r=t.endVector();xa.startDictionariesVector(t,e.numDictionaries);for(let n of[...e.dictionaryBatches()].slice().reverse())Oa.encode(t,n);let i=t.endVector();return xa.startFooter(t),xa.addSchema(t,n),xa.addVersion(t,h.V5),xa.addRecordBatches(t,r),xa.addDictionaries(t,i),xa.finishFooterBuffer(t,xa.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}},Da=class extends Ea{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 Oa.decode(t)}return null}getDictionaryBatch(e){if(e>=0&&e<this.numDictionaries){let t=this._footer.dictionaries(e);if(t)return Oa.decode(t)}return null}},Oa=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 ba.createBlock(e,r,n,i)}constructor(e,t,n){this.metaDataLength=e,this.offset=w(n),this.bodyLength=w(t)}},K=Object.freeze({done:!0,value:void 0}),ka=class{constructor(e){this._json=e}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},Aa=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()}},ja=class extends Aa{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}get closed(){return this._closedPromise}cancel(t){return e(this,void 0,void 0,function*(){yield this.return(t)})}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(K);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(e){return De.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,e)}toNodeStream(e){return De.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,e)}throw(t){return e(this,void 0,void 0,function*(){return yield this.abort(t),K})}return(t){return e(this,void 0,void 0,function*(){return yield this.close(),K})}read(t){return e(this,void 0,void 0,function*(){return(yield this.next(t,`read`)).value})}peek(t){return e(this,void 0,void 0,function*(){return(yield this.next(t,`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(K)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw Error(`AsyncQueue is closed`)}},Ma=class extends ja{write(e){if((e=m(e)).byteLength>0)return super.write(e)}toString(e=!1){return e?s(this.toUint8Array(!0)):this.toUint8Array(!1).then(s)}toUint8Array(t=!1){return t?_e(this._values)[0]:e(this,void 0,void 0,function*(){var e,t,n,r;let i=[],o=0;try{for(var s=!0,c=a(this),l;l=yield c.next(),e=l.done,!e;s=!0){r=l.value,s=!1;let e=r;i.push(e),o+=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 _e(i,o)[0]})}},Na=class{constructor(e){e&&(this.source=new Fa(De.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)}},Pa=class e{constructor(t){t instanceof e?this.source=t.source:t instanceof Ma?this.source=new Ia(De.fromAsyncIterable(t)):fe(t)?this.source=new Ia(De.fromNodeStream(t)):ue(t)?this.source=new Ia(De.fromDOMStream(t)):se(t)?this.source=new Ia(De.fromDOMStream(t.body)):ne(t)?this.source=new Ia(De.fromIterable(t)):(te(t)||re(t))&&(this.source=new Ia(De.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)}},Fa=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)||K)}return(e){return Object.create(this.source.return&&this.source.return(e)||K)}},Ia=class{constructor(e){this.source=e,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return e(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return e(this,void 0,void 0,function*(){return(yield this.next(t,`read`)).value})}peek(t){return e(this,void 0,void 0,function*(){return(yield this.next(t,`peek`)).value})}next(t){return e(this,arguments,void 0,function*(e,t=`read`){return yield this.source.next({cmd:t,size:e})})}throw(t){return e(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||K;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return e(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||K;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}},La=class extends Na{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}}},Ra=class extends Pa{constructor(t,n){super(),this.position=0,this._handle=t,typeof n==`number`?this.size=n:this._pending=e(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return e(this,void 0,void 0,function*(){let{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return e(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return e(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:n,position:r}=this;if(e&&r<n){typeof t!=`number`&&(t=1/0);let i=r,a=0,o=0,s=Math.min(n,i+Math.min(n-i,t)),c=new Uint8Array(Math.max(0,(this.position=s)-i));for(;(i+=o)<s&&(a+=o)<c.byteLength;)({bytesRead:o}=yield e.read(c,a,c.byteLength-a,i));return c}return null})}readAt(t,n){return e(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:r}=this;if(e&&t+n<r){let i=Math.min(r,t+n),a=new Uint8Array(i-t);return(yield e.read(a,0,n,t)).buffer}return new Uint8Array(n)})}close(){return e(this,void 0,void 0,function*(){let e=this._handle;this._handle=null,e&&(yield e.close())})}throw(t){return e(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return e(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}},za=65536;function Ba(e){return e<0&&(e=4294967295+e+1),`0x${e.toString(16)}`}var Va=8,Ha=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],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?za:0,this.buffer[1]+=i>>>16,this.buffer[1]+=t[1]*n[3]+t[2]*n[2]+t[3]*n[1],this.buffer[1]+=t[0]*n[3]+t[1]*n[2]+t[2]*n[1]+t[3]*n[0]<<16,this}_plus(e){let t=this.buffer[0]+e.buffer[0]>>>0;this.buffer[1]+=e.buffer[1],t<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=t}lessThan(e){return this.buffer[1]<e.buffer[1]||this.buffer[1]===e.buffer[1]&&this.buffer[0]<e.buffer[0]}equals(e){return this.buffer[1]===e.buffer[1]&&this.buffer[0]==e.buffer[0]}greaterThan(e){return e.lessThan(this)}hex(){return`${Ba(this.buffer[1])} ${Ba(this.buffer[0])}`}},q=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=Va<r-n?Va: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=Va<i-n?Va: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 q(new Uint32Array([this.buffer[3],0])),n=new q(new Uint32Array([this.buffer[2],0])),r=new q(new Uint32Array([this.buffer[1],0])),i=new q(new Uint32Array([this.buffer[0],0])),a=new q(new Uint32Array([e.buffer[3],0])),o=new q(new Uint32Array([e.buffer[2],0])),s=new q(new Uint32Array([e.buffer[1],0])),c=new q(new Uint32Array([e.buffer[0],0])),l=q.multiply(i,c);this.buffer[0]=l.low();let u=new q(new Uint32Array([l.high(),0]));return l=q.multiply(r,c),u.plus(l),l=q.multiply(i,s),u.plus(l),this.buffer[1]=u.low(),this.buffer[3]=+!!u.lessThan(l),this.buffer[2]=u.high(),new q(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(q.multiply(n,c)).plus(q.multiply(r,s)).plus(q.multiply(i,o)),this.buffer[3]+=q.multiply(t,c).plus(q.multiply(n,s)).plus(q.multiply(r,o)).plus(q.multiply(i,a)).low(),this}plus(e){let t=new Uint32Array(4);return t[3]=this.buffer[3]+e.buffer[3]>>>0,t[2]=this.buffer[2]+e.buffer[2]>>>0,t[1]=this.buffer[1]+e.buffer[1]>>>0,t[0]=this.buffer[0]+e.buffer[0]>>>0,t[0]<this.buffer[0]>>>0&&++t[1],t[1]<this.buffer[1]>>>0&&++t[2],t[2]<this.buffer[2]>>>0&&++t[3],this.buffer[3]=t[3],this.buffer[2]=t[2],this.buffer[1]=t[1],this.buffer[0]=t[0],this}hex(){return`${Ba(this.buffer[3])} ${Ba(this.buffer[2])} ${Ba(this.buffer[1])} ${Ba(this.buffer[0])}`}static multiply(t,n){return new e(new Uint32Array(t.buffer)).times(n)}static add(t,n){return new e(new Uint32Array(t.buffer)).plus(n)}static from(t,n=new Uint32Array(4)){return e.fromString(typeof t==`string`?t:t.toString(),n)}static fromNumber(t,n=new Uint32Array(4)){return e.fromString(t.toString(),n)}static fromString(t,n=new Uint32Array(4)){let r=t.startsWith(`-`),i=t.length,a=new e(n);for(let n=+!!r;n<i;){let r=Va<i-n?Va: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 k{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 G?e.type:e)}visitNull(e,{length:t}=this.nextFieldNode()){return R({type:e,length:t})}visitBool(e,{length:t,nullCount:n}=this.nextFieldNode()){return R({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitInt(e,{length:t,nullCount:n}=this.nextFieldNode()){return R({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitFloat(e,{length:t,nullCount:n}=this.nextFieldNode()){return R({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitUtf8(e,{length:t,nullCount:n}=this.nextFieldNode()){return R({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 R({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 R({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 R({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 R({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDate(e,{length:t,nullCount:n}=this.nextFieldNode()){return R({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitTimestamp(e,{length:t,nullCount:n}=this.nextFieldNode()){return R({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitTime(e,{length:t,nullCount:n}=this.nextFieldNode()){return R({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDecimal(e,{length:t,nullCount:n}=this.nextFieldNode()){return R({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitList(e,{length:t,nullCount:n}=this.nextFieldNode()){return R({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 R({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 R({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 R({type:e,length:t,nullCount:n,typeIds:this.readTypeIds(e),children:this.visitMany(e.children)})}visitDictionary(e,{length:t,nullCount:n}=this.nextFieldNode()){return R({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 R({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitDuration(e,{length:t,nullCount:n}=this.nextFieldNode()){return R({type:e,length:t,nullCount:n,nullBitmap:this.readNullBitmap(e,n),data:this.readData(e)})}visitFixedSizeList(e,{length:t,nullCount:n}=this.nextFieldNode()){return R({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 R({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:Ji(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 E.isTimestamp(e)||(E.isInt(e)||E.isTime(e))&&e.bitWidth===64||E.isDuration(e)||E.isDate(e)&&e.unit===Fe.MILLISECOND?p(Uint8Array,Wa.convertArray(n[t])):E.isDecimal(e)?p(Uint8Array,Ga.convertArray(n[t])):E.isBinary(e)||E.isLargeBinary(e)||E.isFixedSizeBinary(e)?Ja(n[t]):E.isBool(e)?Ji(n[t]):E.isUtf8(e)||E.isLargeUtf8(e)?l(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 J=class extends k{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 Y(e,t){return t instanceof e.constructor}function Ya(e,t){return e===t||Y(e,t)}function Xa(e,t){return e===t||Y(e,t)&&e.bitWidth===t.bitWidth&&e.isSigned===t.isSigned}function Za(e,t){return e===t||Y(e,t)&&e.precision===t.precision}function Qa(e,t){return e===t||Y(e,t)&&e.byteWidth===t.byteWidth}function $a(e,t){return e===t||Y(e,t)&&e.unit===t.unit}function eo(e,t){return e===t||Y(e,t)&&e.unit===t.unit&&e.timezone===t.timezone}function to(e,t){return e===t||Y(e,t)&&e.unit===t.unit&&e.bitWidth===t.bitWidth}function no(e,t){return e===t||Y(e,t)&&e.children.length===t.children.length&&uo.compareManyFields(e.children,t.children)}function ro(e,t){return e===t||Y(e,t)&&e.children.length===t.children.length&&uo.compareManyFields(e.children,t.children)}function io(e,t){return e===t||Y(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||Y(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||Y(e,t)&&e.unit===t.unit}function so(e,t){return e===t||Y(e,t)&&e.unit===t.unit}function co(e,t){return e===t||Y(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||Y(e,t)&&e.keysSorted===t.keysSorted&&e.children.length===t.children.length&&uo.compareManyFields(e.children,t.children)}J.prototype.visitNull=Ya,J.prototype.visitBool=Ya,J.prototype.visitInt=Xa,J.prototype.visitInt8=Xa,J.prototype.visitInt16=Xa,J.prototype.visitInt32=Xa,J.prototype.visitInt64=Xa,J.prototype.visitUint8=Xa,J.prototype.visitUint16=Xa,J.prototype.visitUint32=Xa,J.prototype.visitUint64=Xa,J.prototype.visitFloat=Za,J.prototype.visitFloat16=Za,J.prototype.visitFloat32=Za,J.prototype.visitFloat64=Za,J.prototype.visitUtf8=Ya,J.prototype.visitLargeUtf8=Ya,J.prototype.visitBinary=Ya,J.prototype.visitLargeBinary=Ya,J.prototype.visitFixedSizeBinary=Qa,J.prototype.visitDate=$a,J.prototype.visitDateDay=$a,J.prototype.visitDateMillisecond=$a,J.prototype.visitTimestamp=eo,J.prototype.visitTimestampSecond=eo,J.prototype.visitTimestampMillisecond=eo,J.prototype.visitTimestampMicrosecond=eo,J.prototype.visitTimestampNanosecond=eo,J.prototype.visitTime=to,J.prototype.visitTimeSecond=to,J.prototype.visitTimeMillisecond=to,J.prototype.visitTimeMicrosecond=to,J.prototype.visitTimeNanosecond=to,J.prototype.visitDecimal=Ya,J.prototype.visitList=no,J.prototype.visitStruct=ro,J.prototype.visitUnion=io,J.prototype.visitDenseUnion=io,J.prototype.visitSparseUnion=io,J.prototype.visitDictionary=ao,J.prototype.visitInterval=oo,J.prototype.visitIntervalDayTime=oo,J.prototype.visitIntervalYearMonth=oo,J.prototype.visitDuration=so,J.prototype.visitDurationSecond=so,J.prototype.visitDurationMillisecond=so,J.prototype.visitDurationMicrosecond=so,J.prototype.visitDurationNanosecond=so,J.prototype.visitFixedSizeList=co,J.prototype.visitMap=lo;var uo=new J;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++]=R({type:new O(n),length:o,nullCount:0,children:u.slice()})))}return[e=e.assign(n),r.map(t=>new X(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)??R({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 W([]),this._offsets=[0],this;let n,r;t[0]instanceof W&&(n=t.shift()),t.at(-1)instanceof Uint32Array&&(r=t.pop());let i=t=>{if(t){if(t instanceof X)return[t];if(t instanceof e)return t.batches;if(t instanceof L){if(t.type instanceof O)return[new X(new W(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 U([t[e]])),[,i]=po(n??new W(e.map((e,t)=>new G(String(e),r[t].type,r[t].nullable))),r);return i.length===0?[new X(t)]:i}}return[]},a=t.flatMap(e=>i(e));if(n=n??a[0]?.schema??new W([]),!(n instanceof W))throw TypeError(`Table constructor expects a [Schema, RecordBatch[]] pair.`);for(let e of a){if(!(e instanceof X))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??ra(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=na(this.data)),this._nullCount}isValid(e){return!1}get(e){return null}at(e){return this.get(Pi(e,this.numRows))}set(e,t){}indexOf(e,t){return-1}[Symbol.iterator](){return this.batches.length>0?ha.visit(new U(this.data)):[][Symbol.iterator]()}toArray(){return[...this]}toString(){return`[\n ${this.toArray().join(`,
`)}\n]`}concat(...t){let n=this.schema,r=this.data.concat(t.flatMap(({data:e})=>e));return new e(n,r.map(e=>new X(n,e)))}slice(t,n){let r=this.schema;[t,n]=Ni({length:this.numRows},t,n);let i=ia(this.data,this._offsets,t,n);return new e(r,i.map(e=>new X(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=R({type:n,length:0,nullCount:0});t.push(r._changeLengthAndBackfillNullBitmap(this.numRows))}return new U(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 U([R({type:new rn,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){let n=this.schema.selectAt(t),r=this.batches.map(e=>e.selectAt(t));return new e(n,r)}assign(t){let n=this.schema.fields,[r,i]=t.schema.fields.reduce((e,t,r)=>{let[i,a]=e,o=n.findIndex(e=>e.name===t.name);return~o?a[o]=r:i.push(r),e},[[],[]]),a=this.schema.assign(t.schema),o=[...n.map((e,t)=>[t,i[t]]).map(([e,n])=>n===void 0?this.getChildAt(e):t.getChildAt(n)),...r.map(e=>t.getChildAt(e))].filter(Boolean);return new e(...po(a,o))}};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=sa(oa),e.get=sa(I.getVisitFn(C.Struct)),e.set=ca(M.getVisitFn(C.Struct)),e.indexOf=la(pa.getVisitFn(C.Struct)),`Table`))(_o.prototype);var vo,X=class e{constructor(...e){switch(e.length){case 2:if([this.schema]=e,!(this.schema instanceof W)||([,this.data=R({nullCount:0,type:new O(this.schema.fields),children:this.schema.fields.map(e=>R({type:e.type,nullCount:0}))})]=e,!(this.data instanceof L)))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]=G.new({name:n,type:t[n].type,nullable:!0}),e),{length:0,fields:[],children:[]}),a=new W(n),o=R({type:new O(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 I.visit(this.data,e)}at(e){return this.get(Pi(e,this.numRows))}set(e,t){return M.visit(this.data,e,t)}indexOf(e,t){return pa.visit(this.data,e,t)}[Symbol.iterator](){return ha.visit(new U([this.data]))}toArray(){return[...this]}concat(...e){return new _o(this.schema,[this,...e])}slice(t,n){let[r]=new U([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 U([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 U([R({type:new rn,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 W(e,new Map(this.schema.metadata)),i=R({type:new O(e),children:a})}return new e(r,i)}select(t){let n=this.schema.select(t),r=new O(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,R({type:r,length:this.numRows,children:i}))}selectAt(t){let n=this.schema.selectAt(t),r=t.map(e=>this.data.children[e]).filter(Boolean),i=R({type:new O(n.fields),length:this.numRows,children:r});return new e(n,i)}};vo=Symbol.toStringTag,X[vo]=(e=>(e._nullCount=-1,e[Symbol.isConcatSpreadable]=!0,`RecordBatch`))(X.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)??R({type:s.type,length:n,nullCount:n,nullBitmap:new Uint8Array(a)}))}return[e.assign(r),R({type:new O(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(E.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 X{constructor(e){let t=e.fields.map(e=>R({type:e.type})),n=R({type:new O(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)}},Co=new class extends k{visit(e,t){return e==null||t==null?void 0:super.visit(e,t)}visitNull(e,t){return mt.startNull(t),mt.endNull(t)}visitInt(e,t){return $e.startInt(t),$e.addBitWidth(t,e.bitWidth),$e.addIsSigned(t,e.isSigned),$e.endInt(t)}visitFloat(e,t){return ct.startFloatingPoint(t),ct.addPrecision(t,e.precision),ct.endFloatingPoint(t)}visitBinary(e,t){return tt.startBinary(t),tt.endBinary(t)}visitLargeBinary(e,t){return ut.startLargeBinary(t),ut.endLargeBinary(t)}visitBool(e,t){return nt.startBool(t),nt.endBool(t)}visitUtf8(e,t){return yt.startUtf8(t),yt.endUtf8(t)}visitLargeUtf8(e,t){return dt.startLargeUtf8(t),dt.endLargeUtf8(t)}visitDecimal(e,t){return it.startDecimal(t),it.addScale(t,e.scale),it.addPrecision(t,e.precision),it.addBitWidth(t,e.bitWidth),it.endDecimal(t)}visitDate(e,t){return rt.startDate(t),rt.addUnit(t,e.unit),rt.endDate(t)}visitTime(e,t){return gt.startTime(t),gt.addUnit(t,e.unit),gt.addBitWidth(t,e.bitWidth),gt.endTime(t)}visitTimestamp(e,t){let n=e.timezone&&t.createString(e.timezone)||void 0;return _t.startTimestamp(t),_t.addUnit(t,e.unit),n!==void 0&&_t.addTimezone(t,n),_t.endTimestamp(t)}visitInterval(e,t){return lt.startInterval(t),lt.addUnit(t,e.unit),lt.endInterval(t)}visitDuration(e,t){return at.startDuration(t),at.addUnit(t,e.unit),at.endDuration(t)}visitList(e,t){return ft.startList(t),ft.endList(t)}visitStruct(e,t){return ht.startStruct_(t),ht.endStruct_(t)}visitUnion(e,t){vt.startTypeIdsVector(t,e.typeIds.length);let n=vt.createTypeIdsVector(t,e.typeIds);return vt.startUnion(t),vt.addMode(t,e.mode),vt.addTypeIds(t,n),vt.endUnion(t)}visitDictionary(e,t){let n=this.visit(e.indices,t);return et.startDictionaryEncoding(t),et.addId(t,BigInt(e.id)),et.addIsOrdered(t,e.isOrdered),n!==void 0&&et.addIndexType(t,n),et.endDictionaryEncoding(t)}visitFixedSizeBinary(e,t){return ot.startFixedSizeBinary(t),ot.addByteWidth(t,e.byteWidth),ot.endFixedSizeBinary(t)}visitFixedSizeList(e,t){return st.startFixedSizeList(t),st.addListSize(t,e.listSize),st.endFixedSizeList(t)}visitMap(e,t){return pt.startMap(t),pt.addKeysSorted(t,e.keysSorted),pt.endMap(t)}};function wo(e,t=new Map){return new W(Do(e,t),No(e.metadata),t)}function To(e){return new Z(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=>G.fromJSON(e,t))}function Oo(e,t){return(e.children||[]).filter(Boolean).map(e=>G.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 G(e.name,o,e.nullable,No(e.metadata))):t.has(n=a.id)?(r=(r=a.indexType)?Po(r):new sn,s=new Pn(t.get(n),r,n,a.isOrdered),i=new G(e.name,s,e.nullable,No(e.metadata))):(r=(r=a.indexType)?Po(r):new sn,t.set(n,o=Fo(e,Oo(e,t))),s=new Pn(o,r,n,a.isOrdered),i=new G(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 D(e.isSigned,e.bitWidth)}function Fo(e,t){let n=e.type.name;switch(n){case`NONE`:return new rn;case`null`:return new rn;case`binary`:return new _n;case`largebinary`:return new vn;case`utf8`:return new yn;case`largeutf8`:return new bn;case`bool`:return new xn;case`list`:return new On((t||[])[0]);case`struct`:return new O(t||[]);case`struct_`:return new O(t||[])}switch(n){case`int`:{let t=e.type;return new D(t.isSigned,t.bitWidth)}case`floatingpoint`:{let t=e.type;return new pn(_[t.precision])}case`decimal`:{let t=e.type;return new Sn(t.scale,t.precision,t.bitWidth)}case`date`:{let t=e.type;return new Cn(Fe[t.unit])}case`time`:{let t=e.type;return new wn(v[t.unit],t.bitWidth)}case`timestamp`:{let t=e.type;return new Tn(v[t.unit],t.timezone)}case`interval`:{let t=e.type;return new En(Ie[t.unit])}case`duration`:{let t=e.type;return new Dn(v[t.unit])}case`union`:{let n=e.type,[r,...i]=(n.mode+``).toLowerCase(),a=r.toUpperCase()+i.join(``);return new kn(g[a],n.typeIds||[],t||[])}case`fixedsizebinary`:{let t=e.type;return new An(t.byteWidth)}case`fixedsizelist`:{let n=e.type;return new jn(n.listSize,(t||[])[0])}case`map`:{let n=e.type;return new Mn((t||[])[0],n.keysSorted)}}throw Error(`Unrecognized type: "${n}"`)}var Io=Ue,Lo=He,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=W.encode(t,e.header()):e.isRecordBatch()?n=Z.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 W)return new e(0,h.V5,S.Schema,t);if(t instanceof Z)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)}},Z=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 W.fromJSON(e);case S.RecordBatch:return Z.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 W.decode(e.header(new bt),new Map,e.version());case S.RecordBatch:return Z.decode(e.header(new Ye),e.version());case S.DictionaryBatch:return zo.decode(e.header(new Xe),e.version())}throw Error(`Unrecognized Message type: { name: ${S[t]}, type: ${t} }`)})}G.encode=is,G.decode=$o,G.fromJSON=Mo,W.encode=rs,W.decode=Wo,W.fromJSON=wo,Z.encode=as,Z.decode=Go,Z.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 W(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 Z(e.length(),Yo(e),Xo(e,t))}function Ko(e,t=h.V5){return new zo(Z.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]=G.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]=G.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 G(e.name(),i,e.nullable(),es(e))):t.has(n=w(s.id()))?(a=(a=s.indexType())?ts(a):new sn,o=new Pn(t.get(n),a,n,s.isOrdered()),r=new G(e.name(),o,e.nullable(),es(e))):(a=(a=s.indexType())?ts(a):new sn,t.set(n,i=ns(e,Qo(e,t))),o=new Pn(i,a,n,s.isOrdered()),r=new G(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 D(e.isSigned(),e.bitWidth())}function ns(e,t){let n=e.typeType();switch(n){case b.NONE:return new rn;case b.Null:return new rn;case b.Binary:return new _n;case b.LargeBinary:return new vn;case b.Utf8:return new yn;case b.LargeUtf8:return new bn;case b.Bool:return new xn;case b.List:return new On((t||[])[0]);case b.Struct_:return new O(t||[])}switch(n){case b.Int:{let t=e.type(new $e);return new D(t.isSigned(),t.bitWidth())}case b.FloatingPoint:return new pn(e.type(new ct).precision());case b.Decimal:{let t=e.type(new it);return new Sn(t.scale(),t.precision(),t.bitWidth())}case b.Date:return new Cn(e.type(new rt).unit());case b.Time:{let t=e.type(new gt);return new wn(t.unit(),t.bitWidth())}case b.Timestamp:{let t=e.type(new _t);return new Tn(t.unit(),t.timezone())}case b.Interval:return new En(e.type(new lt).unit());case b.Duration:return new Dn(e.type(new at).unit());case b.Union:{let n=e.type(new vt);return new kn(n.mode(),n.typeIdsArray()||[],t||[])}case b.FixedSizeBinary:return new An(e.type(new ot).byteWidth());case b.FixedSizeList:return new jn(e.type(new st).listSize(),(t||[])[0]);case b.Map:{let n=e.type(new pt);return new Mn((t||[])[0],n.keysSorted())}}throw Error(`Unrecognized type: "${b[n]}" (${n})`)}function rs(e,t){let n=t.fields.map(t=>G.encode(e,t));bt.startFieldsVector(e,n.length);let r=bt.createFieldsVector(e,n),i=t.metadata&&t.metadata.size>0?bt.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 bt.startSchema(e),bt.addFields(e,r),bt.addEndianness(e,ls?Ze.Little:Ze.Big),i!==-1&&bt.addCustomMetadata(e,i),bt.endSchema(e)}function is(e,t){let n=-1,r=-1,i=-1,a=t.type,o=t.typeId;E.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=>G.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||[];Ye.startNodesVector(e,n.length);for(let t of n.slice().reverse())Vo.encode(e,t);let i=e.endVector();Ye.startBuffersVector(e,r.length);for(let t of r.slice().reverse())Bo.encode(e,t);let a=e.endVector();return Ye.startRecordBatch(e),Ye.addLength(e,BigInt(t.length)),Ye.addNodes(e,i),Ye.addBuffers(e,a),Ye.endRecordBatch(e)}function os(e,t){let n=Z.encode(e,t.data);return Xe.startDictionaryBatch(e),Xe.addId(e,BigInt(t.id)),Xe.addIsDelta(e,t.isDelta),Xe.addData(e,n),Xe.endDictionaryBatch(e)}function ss(e,t){return Je.createFieldNode(e,BigInt(t.length),BigInt(t.nullCount))}function cs(e,t){return qe.createBuffer(e,BigInt(t.offset),BigInt(t.length))}var 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}.`,ms=class{constructor(e){this.source=e instanceof Na?e:new Na(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?K: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 He(e))?.readInt32(0)||0;return{done:t===0,value:t}}readMetadata(e){let t=this.source.read(e);if(!t)return K;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 Pa?e:oe(e)?new Ra(e,t):new Pa(e)}[Symbol.asyncIterator](){return this}next(){return e(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?K:e})}throw(t){return e(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return e(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return e(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw Error(us(t));return e.value})}readMessageBody(t){return e(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array;let e=m(yield this.source.read(t));if(e.byteLength<t)throw Error(ps(t,e.byteLength));return e.byteOffset%8==0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return e(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 e(this,void 0,void 0,function*(){let e=yield this.source.read(4),t=(e&&new He(e))?.readInt32(0)||0;return{done:t===0,value:t}})}readMetadata(t){return e(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return K;if(e.byteLength<t)throw Error(fs(t,e.byteLength));return{done:!1,value:Ro.decode(e)}})}},gs=class extends ms{constructor(e){super(new Uint8Array),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=e instanceof ka?e:new ka(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=[],K}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}},_s=`ARROW1`,vs=new Uint8Array(6);for(let e=0;e<6;e+=1)vs[e]=_s.codePointAt(e);function ys(e,t=0){for(let n=-1,r=vs.length;++n<r;)if(vs[n]!==e[t+n])return!1;return!0}var bs=vs.length,xs=bs+4,Ss=bs*2+4,Cs=class t extends Aa{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 te(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 De.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return De.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 t?n:ie(n)?Ls(n):oe(n)?Bs(n):te(n)?e(this,void 0,void 0,function*(){return yield t.from(yield n)}):se(n)||ue(n)||fe(n)||re(n)?zs(new Pa(n)):Rs(new Na(n))}static readAll(e){return e instanceof t?e.isSync()?Fs(e):Is(e):ie(e)||ArrayBuffer.isView(e)||ne(e)||ae(e)?Fs(e):Is(e)}},ws=class extends Cs{constructor(e){super(e),this._impl=e}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return r(this,arguments,function*(){yield n(yield*i(a(this[Symbol.iterator]())))})}},Ts=class extends Cs{constructor(e){super(e),this._impl=e}readAll(){return e(this,void 0,void 0,function*(){var e,t,n,r;let i=[];try{for(var o=!0,s=a(this),c;c=yield s.next(),e=c.done,!e;o=!0){r=c.value,o=!1;let e=r;i.push(e)}}catch(e){t={error:e}}finally{try{!o&&!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]()}},Es=class extends ws{constructor(e){super(e),this._impl=e}},Ds=class extends Ts{constructor(e){super(e),this._impl=e}},Os=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=R({type:new O(this.schema.fields),length:e.length,children:n});return new X(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 U(c)):new U(c)).memoize()}_loadVectors(e,t,n){return new Ka(t,e.nodes,e.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},ks=class extends Os{constructor(e,t){super(t),this._reader=ie(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=Ps(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):K}return(e){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(e):K}next(){if(this.closed)return K;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)}},As=class extends Os{constructor(e,t){super(t),this._reader=new hs(this._handle=e)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return e(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return e(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Ps(this,t),(this.schema||=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return e(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):K})}return(t){return e(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):K})}next(){return e(this,void 0,void 0,function*(){if(this.closed)return K;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(t){return e(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},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){super(e instanceof La?e:new La(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-xs,n=e.readInt32(t),r=e.readAt(t-n,n);return Ea.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}},Ms=class extends As{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 Ra?e:new Ra(e,n),r)}isFile(){return!0}isAsync(){return!0}open(t){let n=Object.create(null,{open:{get:()=>super.open}});return e(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,t)})}readRecordBatch(t){return e(this,void 0,void 0,function*(){if(this.closed)return null;this._footer||(yield this.open());let e=this._footer?.getRecordBatch(t);if(e&&(yield this._handle.seek(e.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(t){return e(this,void 0,void 0,function*(){let e=this._footer?.getDictionaryBatch(t);if(e&&(yield this._handle.seek(e.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 e(this,void 0,void 0,function*(){let{_handle:e}=this;e._pending&&(yield e._pending);let t=e.size-xs,n=yield e.readInt32(t),r=yield e.readAt(t-n,n);return Ea.decode(r)})}_readNextMessageAndValidate(t){return e(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},Ns=class extends ks{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 Ps(e,t){return t&&typeof t.autoDestroy==`boolean`?t.autoDestroy:e.autoDestroy}function*Fs(e){let t=Cs.from(e);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Is(e){return r(this,arguments,function*(){let t=yield n(Cs.from(e));try{if(!(yield n(t.open({autoDestroy:!1}))).closed)do yield yield n(t);while(!(yield n(t.reset().open())).closed)}finally{yield n(t.cancel())}})}function Ls(e){return new ws(new Ns(e))}function Rs(e){let t=e.peek(bs+7&-8);return t&&t.byteLength>=4?ys(t)?new Es(new js(e.read())):new ws(new ks(e)):new ws(new ks(function*(){}()))}function zs(t){return e(this,void 0,void 0,function*(){let e=yield t.peek(bs+7&-8);return e&&e.byteLength>=4?ys(e)?new Es(new js(yield t.read())):new Ts(new As(t)):new Ts(new As(function(){return r(this,arguments,function*(){})}()))})}function Bs(t){return e(this,void 0,void 0,function*(){let{size:e}=yield t.stat(),n=new Ra(t,e);return e>=Ss&&ys(yield n.readAt(0,bs+7&-8))?new Ds(new Ms(n)):new Ts(new As(n))})}var Q=class e extends k{static assemble(...t){let n=e=>e.flatMap(e=>Array.isArray(e)?n(e):e instanceof X?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 U)return this.visitMany(e.data),this;let{type:t}=e;if(!E.isDictionary(t)){let{length:n}=e;if(n>2147483647)throw RangeError(`Cannot write arrays larger than 2^31 - 1 in length`);if(E.isUnion(t))this.nodes.push(new Vo(n,0));else{let{nullCount:r}=e;E.isNull(t)||Vs.call(this,r<=0?new Uint8Array:qi(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 Vs(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 Hs(e){let{type:t,length:n,typeIds:r,valueOffsets:i}=e;if(Vs.call(this,r),t.mode===g.Sparse)return qs.call(this,e);if(t.mode===g.Dense){if(e.offset<=0)return Vs.call(this,i),qs.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);Vs.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 Us(e){let t;return e.nullCount>=e.length?Vs.call(this,new Uint8Array):(t=e.values)instanceof Uint8Array?Vs.call(this,qi(e.offset,e.length,t)):Vs.call(this,Ji(e.values))}function Ws(e){return Vs.call(this,e.values.subarray(0,e.length*e.stride))}function Gs(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 Vs.call(this,Te(-i,t+1,r)),Vs.call(this,n.subarray(i,i+o)),this}function Ks(e){let{length:t,valueOffsets:n}=e;if(n){let{0:r,[t]:i}=n;return Vs.call(this,Te(-r,t+1,n)),this.visit(e.children[0].slice(r,i-r))}return this.visit(e.children[0])}function qs(e){return this.visitMany(e.type.children.map((t,n)=>e.children[n]).filter(Boolean))[0]}Q.prototype.visitBool=Us,Q.prototype.visitInt=Ws,Q.prototype.visitFloat=Ws,Q.prototype.visitUtf8=Gs,Q.prototype.visitLargeUtf8=Gs,Q.prototype.visitBinary=Gs,Q.prototype.visitLargeBinary=Gs,Q.prototype.visitFixedSizeBinary=Ws,Q.prototype.visitDate=Ws,Q.prototype.visitTimestamp=Ws,Q.prototype.visitTime=Ws,Q.prototype.visitDecimal=Ws,Q.prototype.visitList=Ks,Q.prototype.visitStruct=qs,Q.prototype.visitUnion=Hs,Q.prototype.visitInterval=Ws,Q.prototype.visitDuration=Ws,Q.prototype.visitFixedSizeList=Ks,Q.prototype.visitMap=Ks;var Js=class extends Aa{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 Ma,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,f(e)||(e={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof e.autoDestroy!=`boolean`||e.autoDestroy,this._writeLegacyIpcFormat=typeof e.writeLegacyIpcFormat==`boolean`&&e.writeLegacyIpcFormat}toString(e=!1){return this._sink.toString(e)}toUint8Array(e=!1){return this._sink.toUint8Array(e)}writeAll(e){return te(e)?e.then(e=>this.writeAll(e)):re(e)?Qs(this,e):Zs(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 Ma?this._sink=e:(this._sink=new Ma,e&&le(e)?this.toDOMStream({type:`bytes`}).pipeTo(e):e&&de(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 X&&!(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 X?e instanceof xo||this._writeRecordBatch(e):e instanceof _o?this.writeAll(e.batches):ne(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 Oa(o,e.bodyLength,this._position)):e.headerType===S.DictionaryBatch&&this._dictionaryBlocks.push(new Oa(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(vs)}_writePadding(e){return e>0?this._write(new Uint8Array(e)):this}_writeRecordBatch(e){let{byteLength:t,nodes:n,bufferRegions:r,buffers:i}=Q.assemble(e),a=new Z(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}=Q.assemble(new U([e])),s=new zo(new Z(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}},Ys=class e extends Js{static writeAll(t,n){let r=new e(n);return te(t)?t.then(e=>r.writeAll(e)):re(t)?Qs(r,t):Zs(r,t)}},Xs=class e extends Js{static writeAll(t){let n=new e;return te(t)?t.then(e=>n.writeAll(e)):re(t)?Qs(n,t):Zs(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=Ea.encode(new Ea(e,h.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(e)._write(t)._write(Int32Array.of(t.byteLength))._writeMagic()}};function Zs(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 Qs(t,n){return e(this,void 0,void 0,function*(){var e,r,i,o,s,c,l;try{for(e=!0,r=a(n);i=yield r.next(),o=i.done,!o;e=!0){l=i.value,e=!1;let n=l;t.write(n)}}catch(e){s={error:e}}finally{try{!e&&!o&&(c=r.return)&&(yield c.call(r))}finally{if(s)throw s.error}}return t.finish()})}function $s(e,t=`stream`){return(t===`stream`?Ys:Xs).writeAll(e).toUint8Array(!0)}var ec=Object.create,tc=Object.defineProperty,nc=Object.getOwnPropertyDescriptor,rc=Object.getOwnPropertyNames,ic=Object.getPrototypeOf,ac=Object.prototype.hasOwnProperty,oc=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),sc=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of rc(t))!ac.call(e,i)&&i!==n&&tc(e,i,{get:()=>t[i],enumerable:!(r=nc(t,i))||r.enumerable});return e},cc=(e,t,n)=>(n=e==null?{}:ec(ic(e)),sc(t||!e||!e.__esModule?tc(n,`default`,{value:e,enumerable:!0}):n,e)),lc=oc((e,t)=>{t.exports=Worker}),uc=(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))(uc||{}),dc=(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))(dc||{}),fc=(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))(fc||{}),pc=(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))(pc||{}),mc=(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))(mc||{}),hc=(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))(hc||{}),gc=class{log(e){}},_c=class{constructor(e=2){this.level=e}log(e){e.level>=this.level&&console.log(e)}};function vc(e){switch(e){case 0:return`NONE`;case 1:return`DEBUG`;case 2:return`INFO`;case 3:return`WARNING`;case 4:return`ERROR`;default:return`?`}}function yc(e){switch(e){case 0:return`NONE`;case 1:return`OK`;case 2:return`ERROR`;case 3:return`START`;case 4:return`RUN`;case 5:return`CAPTURE`;default:return`?`}}function bc(e){switch(e){case 1:return`CONNECT`;case 2:return`DISCONNECT`;case 5:return`INSTANTIATE`;case 3:return`OPEN`;case 4:return`QUERY`;default:return`?`}}function xc(e){switch(e){case 0:return`NONE`;case 1:return`WEB WORKER`;case 2:return`NODE WORKER`;case 3:return`DUCKDB BINDINGS`;case 4:return`DUCKDB`;default:return`?`}}var Sc=(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))(Sc||{});function Cc(e){return e<=255}function wc(e){return e===256}var Tc=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=Cs.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 Ec(this._bindings,this._conn,n),i=await Cs.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 Dc(this._bindings,this._conn,t)}async insertArrowTable(e,t){let n=$s(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)}},Ec=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}},Dc=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=Cs.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 Ec(this.bindings,this.connectionId,t),r=await Cs.from(n);return console.assert(r.isAsync()),console.assert(r.isStream()),r}},Oc=(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))(Oc||{}),kc=(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))(kc||{}),$=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 Ac(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:Ac(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=>jc(e.name,e.type))};case C.Map:{let t=e;return{sqlType:`map`,keyType:Ac(t.keyType),valueType:Ac(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 jc(e,t){let n=Ac(t);return n.name=e,n}var Mc=/'(opfs:\/\/\S*?)'/g,Nc=/(opfs:\/\/\S*?)/g;function Pc(e){return e.search(Nc)>-1}function Fc(e){return[...e.matchAll(Mc)].map(e=>e[1])}var Ic=new TextEncoder,Lc=class{constructor(e,t=null){this._onInstantiationProgress=[],this._onExecutionProgress=[],this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{},this._nextMessageId=0,this._pendingRequests=new Map,this._config={},this._logger=e,this._onMessageHandler=this.onMessage.bind(this),this._onErrorHandler=this.onError.bind(this),this._onCloseHandler=this.onClose.bind(this),t!=null&&this.attach(t)}get logger(){return this._logger}get config(){return this._config}attach(e){this._worker=e,this._worker.addEventListener(`message`,this._onMessageHandler),this._worker.addEventListener(`error`,this._onErrorHandler),this._worker.addEventListener(`close`,this._onCloseHandler),this._workerShutdownPromise=new Promise((e,t)=>{this._workerShutdownResolver=e})}detach(){this._worker&&(this._worker.removeEventListener(`message`,this._onMessageHandler),this._worker.removeEventListener(`error`,this._onErrorHandler),this._worker.removeEventListener(`close`,this._onCloseHandler),this._worker=null,this._workerShutdownResolver(null),this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async terminate(){this._worker&&(this._worker.terminate(),this._worker=null,this._workerShutdownPromise=null,this._workerShutdownResolver=()=>{})}async postTask(e,t=[]){if(!this._worker){console.error(`cannot send a message since the worker is not set!:`+e.type+`,`+e.data);return}let n=this._nextMessageId++;return this._pendingRequests.set(n,e),this._worker.postMessage({messageId:n,type:e.type,data:e.data},t),await e.promise}onMessage(e){var t;let n=e.data;switch(n.type){case`PROGRESS_UPDATE`:for(let e of this._onExecutionProgress)e(n.data);return;case`LOG`:this._logger.log(n.data);return;case`INSTANTIATE_PROGRESS`:for(let e of this._onInstantiationProgress)e(n.data);return}let r=this._pendingRequests.get(n.requestId);if(!r){console.warn(`unassociated response: [${n.requestId}, ${n.type.toString()}]`);return}if(this._pendingRequests.delete(n.requestId),n.type==`ERROR`){let e=Error(n.data.message);e.name=n.data.name,(t=Object.getOwnPropertyDescriptor(e,`stack`))!=null&&t.writable&&(e.stack=n.data.stack),r.promiseRejecter(e);return}switch(r.type){case`CLOSE_PREPARED`:case`COLLECT_FILE_STATISTICS`:case`REGISTER_OPFS_FILE_NAME`:case`COPY_FILE_TO_PATH`:case`DISCONNECT`:case`DROP_FILE`:case`DROP_FILES`:case`FLUSH_FILES`:case`INSERT_ARROW_FROM_IPC_STREAM`:case`IMPORT_CSV_FROM_PATH`:case`IMPORT_JSON_FROM_PATH`:case`OPEN`:case`PING`:case`REGISTER_FILE_BUFFER`:case`REGISTER_FILE_HANDLE`:case`REGISTER_FILE_URL`:case`RESET`:if(n.type==`OK`){r.promiseResolver(n.data);return}break;case`INSTANTIATE`:if(this._onInstantiationProgress=[],n.type==`OK`){r.promiseResolver(n.data);return}break;case`GLOB_FILE_INFOS`:if(n.type==`FILE_INFOS`){r.promiseResolver(n.data);return}break;case`GET_VERSION`:if(n.type==`VERSION_STRING`){r.promiseResolver(n.data);return}break;case`GET_FEATURE_FLAGS`:if(n.type==`FEATURE_FLAGS`){r.promiseResolver(n.data);return}break;case`GET_TABLE_NAMES`:if(n.type==`TABLE_NAMES`){r.promiseResolver(n.data);return}break;case`TOKENIZE`:if(n.type==`SCRIPT_TOKENS`){r.promiseResolver(n.data);return}break;case`COPY_FILE_TO_BUFFER`:if(n.type==`FILE_BUFFER`){r.promiseResolver(n.data);return}break;case`EXPORT_FILE_STATISTICS`:if(n.type==`FILE_STATISTICS`){r.promiseResolver(n.data);return}break;case`CONNECT`:if(n.type==`CONNECTION_INFO`){r.promiseResolver(n.data);return}break;case`RUN_PREPARED`:case`RUN_QUERY`:if(n.type==`QUERY_RESULT`){r.promiseResolver(n.data);return}break;case`SEND_PREPARED`:if(n.type==`QUERY_RESULT_HEADER`){r.promiseResolver(n.data);return}break;case`START_PENDING_QUERY`:if(n.type==`QUERY_RESULT_HEADER_OR_NULL`){r.promiseResolver(n.data);return}break;case`POLL_PENDING_QUERY`:if(n.type==`QUERY_RESULT_HEADER_OR_NULL`){r.promiseResolver(n.data);return}break;case`CANCEL_PENDING_QUERY`:if(this._onInstantiationProgress=[],n.type==`SUCCESS`){r.promiseResolver(n.data);return}break;case`FETCH_QUERY_RESULTS`:if(n.type==`QUERY_RESULT_CHUNK`){r.promiseResolver(n.data);return}break;case`CREATE_PREPARED`:if(n.type==`PREPARED_STATEMENT_ID`){r.promiseResolver(n.data);return}}r.promiseRejecter(Error(`unexpected response type: ${n.type.toString()}`))}onError(e){console.error(e),console.error(`error in duckdb worker: ${e.message}`),this._pendingRequests.clear()}onClose(){if(this._workerShutdownResolver(null),this._pendingRequests.size!=0){console.warn(`worker terminated with ${this._pendingRequests.size} pending requests`);return}this._pendingRequests.clear()}isDetached(){return!this._worker}async reset(){let e=new $(`RESET`,null);return await this.postTask(e)}async ping(){let e=new $(`PING`,null);await this.postTask(e)}async dropFile(e){let t=new $(`DROP_FILE`,e);return await this.postTask(t)}async dropFiles(e){let t=new $(`DROP_FILES`,e);return await this.postTask(t)}async flushFiles(){let e=new $(`FLUSH_FILES`,null);return await this.postTask(e)}async instantiate(e,t=null,n=e=>{}){this._onInstantiationProgress.push(n);let r=new $(`INSTANTIATE`,[e,t]);return await this.postTask(r)}async getVersion(){let e=new $(`GET_VERSION`,null);return await this.postTask(e)}async getFeatureFlags(){let e=new $(`GET_FEATURE_FLAGS`,null);return await this.postTask(e)}async open(e){this._config=e;let t=new $(`OPEN`,e);await this.postTask(t)}async tokenize(e){let t=new $(`TOKENIZE`,e);return await this.postTask(t)}async connectInternal(){let e=new $(`CONNECT`,null);return await this.postTask(e)}async connect(){let e=await this.connectInternal();return new Tc(this,e)}async disconnect(e){let t=new $(`DISCONNECT`,e);await this.postTask(t)}async runQuery(e,t){if(this.shouldOPFSFileHandling()){let n=await this.registerOPFSFileFromSQL(t);try{return await this._runQueryAsync(e,t)}finally{n.length>0&&await this.dropFiles(n)}}return await this._runQueryAsync(e,t)}async _runQueryAsync(e,t){let n=new $(`RUN_QUERY`,[e,t]);return await this.postTask(n)}async startPendingQuery(e,t,n=!1){if(this.shouldOPFSFileHandling()){let r=await this.registerOPFSFileFromSQL(t);try{return await this._startPendingQueryAsync(e,t,n)}finally{r.length>0&&await this.dropFiles(r)}}return await this._startPendingQueryAsync(e,t,n)}async _startPendingQueryAsync(e,t,n=!1){let r=new $(`START_PENDING_QUERY`,[e,t,n]);return await this.postTask(r)}async pollPendingQuery(e){let t=new $(`POLL_PENDING_QUERY`,e);return await this.postTask(t)}async cancelPendingQuery(e){let t=new $(`CANCEL_PENDING_QUERY`,e);return await this.postTask(t)}async fetchQueryResults(e){let t=new $(`FETCH_QUERY_RESULTS`,e);return await this.postTask(t)}async getTableNames(e,t){let n=new $(`GET_TABLE_NAMES`,[e,t]);return await this.postTask(n)}async createPrepared(e,t){let n=new $(`CREATE_PREPARED`,[e,t]);return await this.postTask(n)}async closePrepared(e,t){let n=new $(`CLOSE_PREPARED`,[e,t]);await this.postTask(n)}async runPrepared(e,t,n){let r=new $(`RUN_PREPARED`,[e,t,n]);return await this.postTask(r)}async sendPrepared(e,t,n){let r=new $(`SEND_PREPARED`,[e,t,n]);return await this.postTask(r)}async globFiles(e){let t=new $(`GLOB_FILE_INFOS`,e);return await this.postTask(t)}async registerFileText(e,t){let n=Ic.encode(t);await this.registerFileBuffer(e,n)}async registerFileURL(e,t,n,r){t===void 0&&(t=e);let i=new $(`REGISTER_FILE_URL`,[e,t,n,r]);await this.postTask(i)}async registerEmptyFileBuffer(e){}async registerFileBuffer(e,t){let n=new $(`REGISTER_FILE_BUFFER`,[e,t]);await this.postTask(n,[t.buffer])}async registerFileHandle(e,t,n,r){let i=new $(`REGISTER_FILE_HANDLE`,[e,t,n,r]);await this.postTask(i,[])}async registerOPFSFileName(e){let t=new $(`REGISTER_OPFS_FILE_NAME`,[e]);await this.postTask(t,[])}async collectFileStatistics(e,t){let n=new $(`COLLECT_FILE_STATISTICS`,[e,t]);await this.postTask(n,[])}async exportFileStatistics(e){let t=new $(`EXPORT_FILE_STATISTICS`,e);return await this.postTask(t,[])}async copyFileToBuffer(e){let t=new $(`COPY_FILE_TO_BUFFER`,e);return await this.postTask(t)}async copyFileToPath(e,t){let n=new $(`COPY_FILE_TO_PATH`,[e,t]);await this.postTask(n)}async insertArrowFromIPCStream(e,t,n){if(t.length==0)return;let r=new $(`INSERT_ARROW_FROM_IPC_STREAM`,[e,t,n]);await this.postTask(r,[t.buffer])}async insertCSVFromPath(e,t,n){if(n.columns!==void 0){let e=[];for(let t in n.columns){let r=n.columns[t];e.push(jc(t,r))}n.columnsFlat=e,delete n.columns}let r=new $(`IMPORT_CSV_FROM_PATH`,[e,t,n]);await this.postTask(r)}async insertJSONFromPath(e,t,n){if(n.columns!==void 0){let e=[];for(let t in n.columns){let r=n.columns[t];e.push(jc(t,r))}n.columnsFlat=e,delete n.columns}let r=new $(`IMPORT_JSON_FROM_PATH`,[e,t,n]);await this.postTask(r)}shouldOPFSFileHandling(){return Pc(this.config.path??``)?this.config.opfs?.fileHandling==`auto`:!1}async registerOPFSFileFromSQL(e){let t=Fc(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 Rc(){let e=new TextDecoder;return t=>(typeof SharedArrayBuffer<`u`&&t.buffer instanceof SharedArrayBuffer&&(t=new Uint8Array(t)),e.decode(t))}Rc();var zc=(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))(zc||{}),Bc=class{constructor(){this._bindings=null,this._nextMessageId=0}log(e){this.postMessage({messageId:this._nextMessageId++,requestId:0,type:`LOG`,data:e},[])}sendOK(e){this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`OK`,data:null},[])}failWith(e,t){let n={name:t.name,message:t.message,stack:t.stack||void 0};this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`ERROR`,data:n},[])}async onMessage(e){switch(e.type){case`PING`:this.sendOK(e);return;case`INSTANTIATE`:this._bindings!=null&&this.failWith(e,Error(`duckdb already initialized`));try{this._bindings=await this.instantiate(e.data[0],e.data[1],t=>{this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`INSTANTIATE_PROGRESS`,data:t},[])}),this.sendOK(e)}catch(t){console.log(t),this._bindings=null,this.failWith(e,t)}return}if(!this._bindings)return this.failWith(e,Error(`duckdb is not initialized`));try{switch(e.type){case`GET_VERSION`:this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`VERSION_STRING`,data:this._bindings.getVersion()},[]);break;case`GET_FEATURE_FLAGS`:this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`FEATURE_FLAGS`,data:this._bindings.getFeatureFlags()},[]);break;case`RESET`:this._bindings.reset(),this.sendOK(e);break;case`OPEN`:{let t=e.data.path;t!=null&&t.startsWith(`opfs://`)&&(await this._bindings.prepareDBFileHandle(t,3),e.data.useDirectIO=!0),this._bindings.open(e.data),this.sendOK(e);break}case`DROP_FILE`:this._bindings.dropFile(e.data),this.sendOK(e);break;case`DROP_FILES`:this._bindings.dropFiles(e.data),this.sendOK(e);break;case`FLUSH_FILES`:this._bindings.flushFiles(),this.sendOK(e);break;case`CONNECT`:{let t=this._bindings.connect();this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`CONNECTION_INFO`,data:t.useUnsafe((e,t)=>t)},[]);break}case`DISCONNECT`:this._bindings.disconnect(e.data),this.sendOK(e);break;case`CREATE_PREPARED`:{let t=this._bindings.createPrepared(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`PREPARED_STATEMENT_ID`,data:t},[]);break}case`CLOSE_PREPARED`:this._bindings.closePrepared(e.data[0],e.data[1]),this.sendOK(e);break;case`RUN_PREPARED`:{let t=this._bindings.runPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`QUERY_RESULT`,data:t},[t.buffer]);break}case`RUN_QUERY`:{let t=this._bindings.runQuery(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`QUERY_RESULT`,data:t},[t.buffer]);break}case`SEND_PREPARED`:{let t=this._bindings.sendPrepared(e.data[0],e.data[1],e.data[2]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`QUERY_RESULT_HEADER`,data:t},[t.buffer]);break}case`START_PENDING_QUERY`:{let t=this._bindings.startPendingQuery(e.data[0],e.data[1],e.data[2]),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`QUERY_RESULT_HEADER_OR_NULL`,data:t},n);break}case`POLL_PENDING_QUERY`:{let t=this._bindings.pollPendingQuery(e.data),n=[];t&&n.push(t.buffer),this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`QUERY_RESULT_HEADER_OR_NULL`,data:t},n);break}case`CANCEL_PENDING_QUERY`:{let t=this._bindings.cancelPendingQuery(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`SUCCESS`,data:t},[]);break}case`FETCH_QUERY_RESULTS`:{let t=this._bindings.fetchQueryResults(e.data),n=t?[t.buffer]:[];this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`QUERY_RESULT_CHUNK`,data:t},n);break}case`GET_TABLE_NAMES`:{let t=this._bindings.getTableNames(e.data[0],e.data[1]);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`TABLE_NAMES`,data:t},[]);break}case`GLOB_FILE_INFOS`:{let t=this._bindings.globFiles(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`FILE_INFOS`,data:t},[]);break}case`REGISTER_FILE_URL`:this._bindings.registerFileURL(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case`REGISTER_FILE_BUFFER`:this._bindings.registerFileBuffer(e.data[0],e.data[1]),this.sendOK(e);break;case`REGISTER_FILE_HANDLE`:await this._bindings.registerFileHandleAsync(e.data[0],e.data[1],e.data[2],e.data[3]),this.sendOK(e);break;case`COPY_FILE_TO_PATH`:this._bindings.copyFileToPath(e.data[0],e.data[1]),this.sendOK(e);break;case`COPY_FILE_TO_BUFFER`:{let t=this._bindings.copyFileToBuffer(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`FILE_BUFFER`,data:t},[]);break}case`COLLECT_FILE_STATISTICS`:this._bindings.collectFileStatistics(e.data[0],e.data[1]),this.sendOK(e);break;case`REGISTER_OPFS_FILE_NAME`:await this._bindings.registerOPFSFileName(e.data[0]),this.sendOK(e);break;case`EXPORT_FILE_STATISTICS`:this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`FILE_STATISTICS`,data:this._bindings.exportFileStatistics(e.data)},[]);break;case`INSERT_ARROW_FROM_IPC_STREAM`:this._bindings.insertArrowFromIPCStream(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break;case`IMPORT_CSV_FROM_PATH`:this._bindings.insertCSVFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break;case`IMPORT_JSON_FROM_PATH`:this._bindings.insertJSONFromPath(e.data[0],e.data[1],e.data[2]),this.sendOK(e);break;case`TOKENIZE`:{let t=this._bindings.tokenize(e.data);this.postMessage({messageId:this._nextMessageId++,requestId:e.messageId,type:`SCRIPT_TOKENS`,data:t},[]);break}}}catch(t){return console.log(t),this.failWith(e,t)}}},Vc=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])),Hc=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])),Uc=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])),Wc=()=>(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])),Gc={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`}}},Kc=Gc.name,qc=Gc.version,Jc=Gc.version.split(`.`),Yc=Jc[0],Xc=Jc[1],Zc=Jc[2],Qc=()=>typeof navigator>`u`,$c=()=>Qc()?`node`:navigator.userAgent,el=()=>$c().includes(`Firefox`),tl=()=>/^((?!chrome|android).)*safari/i.test($c());function nl(){let e=`https://cdn.jsdelivr.net/npm/${Kc}@${qc}/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 rl=null,il=null,al=null,ol=null,sl=null;async function cl(){return rl??=typeof BigInt64Array<`u`,il??=await Hc(),al??=await Wc(),ol??=await Uc(),sl??=await Vc(),{bigInt64Array:rl,crossOriginIsolated:Qc()||globalThis.crossOriginIsolated||!1,wasmExceptions:il,wasmSIMD:ol,wasmThreads:al,wasmBulkMemory:sl}}async function ll(e){let t=await cl();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}}var ul=cc(lc());async function dl(e){let t=new Request(e),n=await fetch(t),r=URL.createObjectURL(await n.blob());return new ul.default(r)}export{Lc as AsyncDuckDB,Tc as AsyncDuckDBConnection,Bc as AsyncDuckDBDispatcher,Dc as AsyncPreparedStatement,Ec as AsyncResultStreamIterator,_c as ConsoleLogger,uc as DuckDBAccessMode,zc as DuckDBDataProtocol,Cc as IsArrowBuffer,wc as IsDuckDBWasmRetry,mc as LogEvent,fc as LogLevel,hc as LogOrigin,pc as LogTopic,Kc as PACKAGE_NAME,qc as PACKAGE_VERSION,Yc as PACKAGE_VERSION_MAJOR,Xc as PACKAGE_VERSION_MINOR,Zc as PACKAGE_VERSION_PATCH,Sc as StatusCode,dc as TokenType,gc as VoidLogger,Oc as WorkerRequestType,kc as WorkerResponseType,$ as WorkerTask,dl as createWorker,nl as getJsDelivrBundles,yc as getLogEventLabel,vc as getLogLevelLabel,xc as getLogOriginLabel,bc as getLogTopicLabel,cl as getPlatformFeatures,el as isFirefox,Qc as isNode,tl as isSafari,ll as selectBundle};