supercat666's picture
add igv
78c921d
raw
history blame
158 kB
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory(global.Arrow = global.Arrow || {}));
}(this, (function (exports) {var h;const aa=new TextDecoder("utf-8"),ba=a=>aa.decode(a),ca=new TextEncoder;const [,da]=(()=>{function a(){throw b();}const b=()=>{throw Error("BigInt is not available in this environment");};a.asIntN=()=>{throw b();};a.asUintN=()=>{throw b();};return"undefined"!==typeof BigInt?[BigInt,!0]:[a,!1]})(),[ea]=(()=>{const a=()=>{throw Error("BigInt64Array is not available in this environment");};class b{static get BYTES_PER_ELEMENT(){return 8}static of(){throw a();}static from(){throw a();}constructor(){throw a();}}return"undefined"!==typeof BigInt64Array?[BigInt64Array,!0]:[b,
!1]})(),[fa]=(()=>{const a=()=>{throw Error("BigUint64Array is not available in this environment");};class b{static get BYTES_PER_ELEMENT(){return 8}static of(){throw a();}static from(){throw a();}constructor(){throw a();}}return"undefined"!==typeof BigUint64Array?[BigUint64Array,!0]:[b,!1]})(),l=a=>"function"===typeof a,m=a=>null!=a&&Object(a)===a,ha=a=>"_getDOMStream"in a&&"_getNodeStream"in a,ia=a=>m(a)&&l(a.cancel)&&l(a.getReader)&&!ha(a),ja=a=>m(a)&&l(a.read)&&l(a.pipe)&&"boolean"===typeof a.readable&&
!ha(a);const ka="undefined"!==typeof SharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;function la(a){const b=a[0]?[a[0]]:[];let c,d,e,f;for(let g,k,n=0,p=0,x=a.length;++n<x;)g=b[p],k=a[n],!g||!k||g.buffer!==k.buffer||k.byteOffset<g.byteOffset?k&&(b[++p]=k):({byteOffset:c,byteLength:e}=g,{byteOffset:d,byteLength:f}=k,c+e<d||d+f<c?k&&(b[++p]=k):b[p]=new Uint8Array(g.buffer,c,d-c+f));return b}
function ma(a,b,c=0,d=b.byteLength){const e=a.byteLength,f=new Uint8Array(a.buffer,a.byteOffset,e);b=new Uint8Array(b.buffer,b.byteOffset,Math.min(d,e));f.set(b,c);return a}
function na(a,b){a=la(a);const c=a.reduce((n,p)=>n+p.byteLength,0);let d,e,f=0,g=-1;const k=Math.min(b||Number.POSITIVE_INFINITY,c);for(const n=a.length;++g<n;){b=a[g];d=b.subarray(0,Math.min(b.length,k-f));if(k<=f+d.length){d.length<b.length?a[g]=b.subarray(d.length):d.length===b.length&&g++;e?ma(e,d,f):e=d;break}ma(e||=new Uint8Array(k),d,f);f+=d.length}return[e||new Uint8Array(0),a.slice(g),c-(e?e.byteLength:0)]}
function q(a,b){b=m(b)&&"done"in b&&"value"in b?b.value:b;if(b instanceof a)return a===Uint8Array?new a(b.buffer,b.byteOffset,b.byteLength):b;if(!b)return new a(0);"string"===typeof b&&(b=ca.encode(b));return b instanceof ArrayBuffer||b instanceof ka?new a(b):m(b)&&l(b.clear)&&l(b.bytes)&&l(b.position)&&l(b.setPosition)&&l(b.capacity)&&l(b.getBufferIdentifier)&&l(b.createLong)?q(a,b.P()):ArrayBuffer.isView(b)?0>=b.byteLength?new a(0):new a(b.buffer,b.byteOffset,b.byteLength/a.BYTES_PER_ELEMENT):a.from(b)}
const oa=a=>{a.next();return a};function*pa(a,b){function*c(d){yield d}b="string"===typeof b?c(b):ArrayBuffer.isView(b)?c(b):b instanceof ArrayBuffer?c(b):b instanceof ka?c(b):m(b)&&l(b[Symbol.iterator])?b:c(b);yield*oa(function*(d){let e=null;do e=d.next(yield q(a,e));while(!e.done)}(b[Symbol.iterator]()));return new a}
async function*qa(a,b){async function*c(e){yield*oa(function*(f){let g=null;do g=f.next(yield g?.value);while(!g.done)}(e[Symbol.iterator]()))}async function*d(e){yield await e}if(m(b)&&l(b.then))return yield*qa(a,await b);b="string"===typeof b?d(b):ArrayBuffer.isView(b)?d(b):b instanceof ArrayBuffer?d(b):b instanceof ka?d(b):m(b)&&l(b[Symbol.iterator])?c(b):m(b)&&l(b[Symbol.asyncIterator])?b:d(b);yield*oa(async function*(e){let f=null;do f=await e.next(yield q(a,f));while(!f.done)}(b[Symbol.asyncIterator]()));
return new a}function ra(a,b,c){if(0!==a){c=c.slice(0,b+1);for(let d=-1;++d<=b;)c[d]+=a}return c}function sa(a,b){let c=0;const d=a.length;if(d!==b.length)return!1;if(0<d){do if(a[c]!==b[c])return!1;while(++c<d)}return!0}var r={};r.compareArrayLike=sa;r.joinUint8Arrays=na;r.memcpy=ma;r.rebaseValueOffsets=ra;r.toArrayBufferView=q;r.toArrayBufferViewAsyncIterator=qa;r.toArrayBufferViewIterator=pa;r.toBigInt64Array=a=>q(ea,a);r.toBigUint64Array=a=>q(fa,a);r.toFloat32Array=a=>q(Float32Array,a);
r.toFloat32ArrayAsyncIterator=a=>qa(Float32Array,a);r.toFloat32ArrayIterator=a=>pa(Float32Array,a);r.toFloat64Array=a=>q(Float64Array,a);r.toFloat64ArrayAsyncIterator=a=>qa(Float64Array,a);r.toFloat64ArrayIterator=a=>pa(Float64Array,a);r.toInt16Array=a=>q(Int16Array,a);r.toInt16ArrayAsyncIterator=a=>qa(Int16Array,a);r.toInt16ArrayIterator=a=>pa(Int16Array,a);r.toInt32Array=a=>q(Int32Array,a);r.toInt32ArrayAsyncIterator=a=>qa(Int32Array,a);r.toInt32ArrayIterator=a=>pa(Int32Array,a);
r.toInt8Array=a=>q(Int8Array,a);r.toInt8ArrayAsyncIterator=a=>qa(Int8Array,a);r.toInt8ArrayIterator=a=>pa(Int8Array,a);r.toUint16Array=a=>q(Uint16Array,a);r.toUint16ArrayAsyncIterator=a=>qa(Uint16Array,a);r.toUint16ArrayIterator=a=>pa(Uint16Array,a);r.toUint32Array=a=>q(Uint32Array,a);r.toUint32ArrayAsyncIterator=a=>qa(Uint32Array,a);r.toUint32ArrayIterator=a=>pa(Uint32Array,a);r.toUint8Array=a=>q(Uint8Array,a);r.toUint8ArrayAsyncIterator=a=>qa(Uint8Array,a);
r.toUint8ArrayIterator=a=>pa(Uint8Array,a);r.toUint8ClampedArray=a=>q(Uint8ClampedArray,a);r.toUint8ClampedArrayAsyncIterator=a=>qa(Uint8ClampedArray,a);r.toUint8ClampedArrayIterator=a=>pa(Uint8ClampedArray,a);function ta(){throw Error('"toDOMStream" not available in this environment');}function ua(){throw Error('"toNodeStream" not available in this environment');}const va=a=>{a.next();return a};
function*wa(a){let b,c=!1,d=[],e,f,g,k=0;({X:f,size:g}=yield null);a=pa(Uint8Array,a)[Symbol.iterator]();try{do if({done:b,value:e}=Number.isNaN(g-k)?a.next():a.next(g-k),!b&&0<e.byteLength&&(d.push(e),k+=e.byteLength),b||g<=k){do{if("peek"===f)var n=na(d,g)[0];else[e,d,k]=na(d,g),n=e;({X:f,size:g}=yield n)}while(g<k)}while(!b)}catch(p){(c=!0,"function"===typeof a.throw)&&a.throw(p)}finally{!1===c&&"function"===typeof a.return&&a.return(null)}return null}
async function*xa(a){let b,c=!1,d=[],e,f,g,k=0;({X:f,size:g}=yield null);a=qa(Uint8Array,a)[Symbol.asyncIterator]();try{do if({done:b,value:e}=Number.isNaN(g-k)?await a.next():await a.next(g-k),!b&&0<e.byteLength&&(d.push(e),k+=e.byteLength),b||g<=k){do{if("peek"===f)var n=na(d,g)[0];else[e,d,k]=na(d,g),n=e;({X:f,size:g}=yield n)}while(g<k)}while(!b)}catch(p){(c=!0,"function"===typeof a.throw)&&await a.throw(p)}finally{!1===c&&"function"===typeof a.return&&await a.return(new Uint8Array(0))}return null}
async function*ya(a){let b=!1,c=!1,d=[],e,f,g,k=0;({X:f,size:g}=yield null);const n=new za(a);try{do if({done:b,value:e}=Number.isNaN(g-k)?await n.read():await n.read(g-k),!b&&0<e.byteLength&&(d.push(q(Uint8Array,e)),k+=e.byteLength),b||g<=k){do{if("peek"===f)var p=na(d,g)[0];else[e,d,k]=na(d,g),p=e;({X:f,size:g}=yield p)}while(g<k)}while(!b)}catch(x){c=!0,await n.cancel(x)}finally{!1===c?await n.cancel():a.locked&&n.releaseLock()}return null}
class za{constructor(a){this.source=a;this.S=null;this.S=this.source.getReader();this.S.closed.catch(()=>{})}get closed(){return this.S?this.S.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.S&&this.S.releaseLock();this.S=null}async cancel(a){const b=this.S,c=this.source;b&&await b.cancel(a).catch(()=>{});c&&c.locked&&this.releaseLock()}async read(a){if(0===a)return{done:null==this.S,value:new Uint8Array(0)};a=await this.S.read();!a.done&&(a.value=q(Uint8Array,a));return a}}
const Aa=(a,b)=>{const c=e=>d([b,e]);let d;return[b,c,new Promise(e=>(d=e)&&a.once(b,c))]};
async function*Ba(a){function b(mb,zb){x=p=null;return new Promise((xi,yi)=>{for(const [Ab,zi]of mb)a.off(Ab,zi);try{const Ab=a.destroy;Ab&&Ab.call(a,zb);zb=void 0}catch(Ab){zb=Ab||zb}finally{null!=zb?yi(zb):xi()}})}const c=[];let d="error",e=!1,f=null,g,k,n=0,p=[],x;({X:g,size:k}=yield null);if(a.isTTY)return yield new Uint8Array(0),null;try{c[0]=Aa(a,"end");c[1]=Aa(a,"error");do{c[2]=Aa(a,"readable");[d,f]=await Promise.race(c.map(mb=>mb[2]));if("error"===d)break;(e="end"===d)||(Number.isFinite(k-
n)?(x=q(Uint8Array,a.read(k-n)),x.byteLength<k-n&&(x=q(Uint8Array,a.read()))):x=q(Uint8Array,a.read()),0<x.byteLength&&(p.push(x),n+=x.byteLength));if(e||k<=n){do{if("peek"===g)var Ua=na(p,k)[0];else[x,p,n]=na(p,k),Ua=x;({X:g,size:k}=yield Ua)}while(k<n)}}while(!e)}finally{await b(c,"error"===d?f:null)}return null};var Ca,Da=Ca||={};Da[Da.V1=0]="V1";Da[Da.V2=1]="V2";Da[Da.V3=2]="V3";Da[Da.V4=3]="V4";Da[Da.V5=4]="V5";var t,Ea=t||={};Ea[Ea.Sparse=0]="Sparse";Ea[Ea.Dense=1]="Dense";var u,Fa=u||={};Fa[Fa.HALF=0]="HALF";Fa[Fa.SINGLE=1]="SINGLE";Fa[Fa.DOUBLE=2]="DOUBLE";var Ga,Ha=Ga||={};Ha[Ha.DAY=0]="DAY";Ha[Ha.MILLISECOND=1]="MILLISECOND";var v,Ia=v||={};Ia[Ia.SECOND=0]="SECOND";Ia[Ia.MILLISECOND=1]="MILLISECOND";Ia[Ia.MICROSECOND=2]="MICROSECOND";Ia[Ia.NANOSECOND=3]="NANOSECOND";var Ja,Ka=Ja||={};
Ka[Ka.YEAR_MONTH=0]="YEAR_MONTH";Ka[Ka.DAY_TIME=1]="DAY_TIME";Ka[Ka.MONTH_DAY_NANO=2]="MONTH_DAY_NANO";var w,La=w||={};La[La.NONE=0]="NONE";La[La.Schema=1]="Schema";La[La.DictionaryBatch=2]="DictionaryBatch";La[La.RecordBatch=3]="RecordBatch";La[La.Tensor=4]="Tensor";La[La.SparseTensor=5]="SparseTensor";var y,z=y||={};z[z.NONE=0]="NONE";z[z.Null=1]="Null";z[z.Int=2]="Int";z[z.Float=3]="Float";z[z.Binary=4]="Binary";z[z.Utf8=5]="Utf8";z[z.Bool=6]="Bool";z[z.Decimal=7]="Decimal";z[z.Date=8]="Date";
z[z.Time=9]="Time";z[z.Timestamp=10]="Timestamp";z[z.Interval=11]="Interval";z[z.List=12]="List";z[z.Struct=13]="Struct";z[z.Union=14]="Union";z[z.FixedSizeBinary=15]="FixedSizeBinary";z[z.FixedSizeList=16]="FixedSizeList";z[z.Map=17]="Map";z[z.Dictionary=-1]="Dictionary";z[z.Int8=-2]="Int8";z[z.Int16=-3]="Int16";z[z.Int32=-4]="Int32";z[z.Int64=-5]="Int64";z[z.Uint8=-6]="Uint8";z[z.Uint16=-7]="Uint16";z[z.Uint32=-8]="Uint32";z[z.Uint64=-9]="Uint64";z[z.Float16=-10]="Float16";z[z.Float32=-11]="Float32";
z[z.Float64=-12]="Float64";z[z.DateDay=-13]="DateDay";z[z.DateMillisecond=-14]="DateMillisecond";z[z.TimestampSecond=-15]="TimestampSecond";z[z.TimestampMillisecond=-16]="TimestampMillisecond";z[z.TimestampMicrosecond=-17]="TimestampMicrosecond";z[z.TimestampNanosecond=-18]="TimestampNanosecond";z[z.TimeSecond=-19]="TimeSecond";z[z.TimeMillisecond=-20]="TimeMillisecond";z[z.TimeMicrosecond=-21]="TimeMicrosecond";z[z.TimeNanosecond=-22]="TimeNanosecond";z[z.DenseUnion=-23]="DenseUnion";
z[z.SparseUnion=-24]="SparseUnion";z[z.IntervalDayTime=-25]="IntervalDayTime";z[z.IntervalYearMonth=-26]="IntervalYearMonth";var Ma,Na=Ma||={};Na[Na.OFFSET=0]="OFFSET";Na[Na.DATA=1]="DATA";Na[Na.VALIDITY=2]="VALIDITY";Na[Na.TYPE=3]="TYPE";function Oa(a){if(null===a)return"null";if(void 0===a)return"undefined";switch(typeof a){case "number":return`${a}`;case "bigint":return`${a}`;case "string":return`"${a}"`}return"function"===typeof a[Symbol.toPrimitive]?a[Symbol.toPrimitive]("string"):ArrayBuffer.isView(a)?a instanceof ea||a instanceof fa?`[${[...a].map(b=>Oa(b))}]`:`[${a}]`:ArrayBuffer.isView(a)?`[${a}]`:JSON.stringify(a,(b,c)=>"bigint"===typeof c?`${c}`:c)};const Pa=Symbol.for("isArrowBigNum");function Qa(a,...b){return 0===b.length?Object.setPrototypeOf(q(this.TypedArray,a),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(a,...b),this.constructor.prototype)}Qa.prototype[Pa]=!0;Qa.prototype.toJSON=function(){return`"${Ra(this)}"`};Qa.prototype.valueOf=function(){return Sa(this)};Qa.prototype.toString=function(){return Ra(this)};Qa.prototype[Symbol.toPrimitive]=function(a="default"){switch(a){case "number":return Sa(this);case "default":return Ta(this)}return Ra(this)};
function Va(...a){return Qa.apply(this,a)}function Wa(...a){return Qa.apply(this,a)}function Xa(...a){return Qa.apply(this,a)}Object.setPrototypeOf(Va.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(Wa.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Xa.prototype,Object.create(Uint32Array.prototype));Object.assign(Va.prototype,Qa.prototype,{constructor:Va,signed:!0,TypedArray:Int32Array,BigIntArray:ea});
Object.assign(Wa.prototype,Qa.prototype,{constructor:Wa,signed:!1,TypedArray:Uint32Array,BigIntArray:fa});Object.assign(Xa.prototype,Qa.prototype,{constructor:Xa,signed:!0,TypedArray:Uint32Array,BigIntArray:fa});
function Sa(a){const {buffer:b,byteOffset:c,length:d,signed:e}=a;a=new fa(b,c,d);const f=e&&a[a.length-1]&BigInt(1)<<BigInt(63);let g=f?BigInt(1):BigInt(0),k=BigInt(0);if(f){for(const n of a)g+=~n*(BigInt(1)<<BigInt(32)*k++);g*=BigInt(-1)}else for(const n of a)g+=n*(BigInt(1)<<BigInt(32)*k++);return g}let Ra,Ta;da?(Ta=a=>8===a.byteLength?(new a.BigIntArray(a.buffer,a.byteOffset,1))[0]:Ya(a),Ra=a=>8===a.byteLength?`${(new a.BigIntArray(a.buffer,a.byteOffset,1))[0]}`:Ya(a)):Ta=Ra=Ya;
function Ya(a){let b="";const c=new Uint32Array(2);a=new Uint16Array(a.buffer,a.byteOffset,a.byteLength/2);const d=new Uint32Array((a=(new Uint16Array(a)).reverse()).buffer);let e;const f=a.length-1;do{for(c[0]=a[e=0];e<f;)a[e++]=c[1]=c[0]/10,c[0]=(c[0]-10*c[1]<<16)+a[e];a[e]=c[1]=c[0]/10;c[0]-=10*c[1];b=`${c[0]}${b}`}while(d[0]||d[1]||d[2]||d[3]);return b??"0"}
class Za{static new(a,b){switch(b){case !0:return new Va(a);case !1:return new Wa(a)}switch(a.constructor){case Int8Array:case Int16Array:case Int32Array:case ea:return new Va(a)}return 16===a.byteLength?new Xa(a):new Wa(a)}static Ub(a){return new Va(a)}constructor(a,b){return Za.new(a,b)}}var $a={};$a.BN=Za;$a.bignumToBigInt=Ta;$a.bignumToString=Ra;$a.isArrowBigNumSymbol=Pa;class A{static isNull(a){return a?.typeId===y.Null}static isInt(a){return a?.typeId===y.Int}static isFloat(a){return a?.typeId===y.Float}static isBinary(a){return a?.typeId===y.Binary}static isUtf8(a){return a?.typeId===y.Utf8}static isBool(a){return a?.typeId===y.Bool}static isDecimal(a){return a?.typeId===y.Decimal}static isDate(a){return a?.typeId===y.Date}static isTime(a){return a?.typeId===y.Time}static isTimestamp(a){return a?.typeId===y.Timestamp}static isInterval(a){return a?.typeId===y.Interval}static isList(a){return a?.typeId===
y.List}static isStruct(a){return a?.typeId===y.Struct}static isUnion(a){return a?.typeId===y.Union}static isFixedSizeBinary(a){return a?.typeId===y.FixedSizeBinary}static isFixedSizeList(a){return a?.typeId===y.FixedSizeList}static isMap(a){return a?.typeId===y.Map}static isDictionary(a){return a?.typeId===y.Dictionary}static isDenseUnion(a){return A.isUnion(a)&&a.mode===t.Dense}static isSparseUnion(a){return A.isUnion(a)&&a.mode===t.Sparse}get typeId(){return y.NONE}}
var ab=Symbol.toStringTag,bb,cb=A.prototype;cb.children=null;cb.ArrayType=Array;bb=cb[Symbol.toStringTag]="DataType";A[ab]=bb;class db extends A{toString(){return"Null"}get typeId(){return y.Null}}db[Symbol.toStringTag]=db.prototype[Symbol.toStringTag]="Null";
class B extends A{constructor(a,b){super();this.isSigned=a;this.bitWidth=b}get typeId(){return y.Int}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?ea:fa}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`);}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}var eb=Symbol.toStringTag,fb,gb=B.prototype;
gb.isSigned=null;gb.bitWidth=null;fb=gb[Symbol.toStringTag]="Int";B[eb]=fb;class hb extends B{constructor(){super(!0,8)}get ArrayType(){return Int8Array}}class ib extends B{constructor(){super(!0,16)}get ArrayType(){return Int16Array}}class jb extends B{constructor(){super(!0,32)}get ArrayType(){return Int32Array}}class kb extends B{constructor(){super(!0,64)}get ArrayType(){return ea}}class lb extends B{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}}
class nb extends B{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}}class ob extends B{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}}class pb extends B{constructor(){super(!1,64)}get ArrayType(){return fa}}Object.defineProperty(hb.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(ib.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(jb.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(kb.prototype,"ArrayType",{value:ea});
Object.defineProperty(lb.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(nb.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(ob.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(pb.prototype,"ArrayType",{value:fa});
class qb extends A{constructor(a){super();this.precision=a}get typeId(){return y.Float}get ArrayType(){switch(this.precision){case u.HALF:return Uint16Array;case u.SINGLE:return Float32Array;case u.DOUBLE:return Float64Array}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`);}toString(){return`Float${this.precision<<5||16}`}}var rb=Symbol.toStringTag,sb,tb=qb.prototype;tb.precision=null;sb=tb[Symbol.toStringTag]="Float";qb[rb]=sb;class ub extends qb{constructor(){super(u.HALF)}}
class vb extends qb{constructor(){super(u.SINGLE)}}class wb extends qb{constructor(){super(u.DOUBLE)}}Object.defineProperty(ub.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(vb.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(wb.prototype,"ArrayType",{value:Float64Array});class xb extends A{constructor(){super()}get typeId(){return y.Binary}toString(){return"Binary"}}var yb=Symbol.toStringTag,Bb,Cb=xb.prototype;Cb.ArrayType=Uint8Array;Bb=Cb[Symbol.toStringTag]="Binary";
xb[yb]=Bb;class Db extends A{constructor(){super()}get typeId(){return y.Utf8}toString(){return"Utf8"}}var Eb=Symbol.toStringTag,Fb,Gb=Db.prototype;Gb.ArrayType=Uint8Array;Fb=Gb[Symbol.toStringTag]="Utf8";Db[Eb]=Fb;class Hb extends A{constructor(){super()}get typeId(){return y.Bool}toString(){return"Bool"}}var Ib=Symbol.toStringTag,Jb,Kb=Hb.prototype;Kb.ArrayType=Uint8Array;Jb=Kb[Symbol.toStringTag]="Bool";Hb[Ib]=Jb;
class Lb extends A{constructor(a,b,c=128){super();this.scale=a;this.precision=b;this.bitWidth=c}get typeId(){return y.Decimal}toString(){return`Decimal[${this.precision}e${0<this.scale?"+":""}${this.scale}]`}}var Mb=Symbol.toStringTag,Nb,Ob=Lb.prototype;Ob.scale=null;Ob.precision=null;Ob.ArrayType=Uint32Array;Nb=Ob[Symbol.toStringTag]="Decimal";Lb[Mb]=Nb;class Pb extends A{constructor(a){super();this.unit=a}get typeId(){return y.Date}toString(){return`Date${32*(this.unit+1)}<${Ga[this.unit]}>`}}
var Qb=Symbol.toStringTag,Rb,Sb=Pb.prototype;Sb.unit=null;Sb.ArrayType=Int32Array;Rb=Sb[Symbol.toStringTag]="Date";Pb[Qb]=Rb;class Tb extends Pb{constructor(){super(Ga.DAY)}}class Ub extends Pb{constructor(){super(Ga.MILLISECOND)}}
class Vb extends A{constructor(a,b){super();this.unit=a;this.bitWidth=b}get typeId(){return y.Time}toString(){return`Time${this.bitWidth}<${v[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return ea}throw Error(`Unrecognized ${this[Symbol.toStringTag]} type`);}}var Wb=Symbol.toStringTag,Xb,Yb=Vb.prototype;Yb.unit=null;Yb.bitWidth=null;Xb=Yb[Symbol.toStringTag]="Time";Vb[Wb]=Xb;class Zb extends Vb{constructor(){super(v.SECOND,32)}}
class $b extends Vb{constructor(){super(v.MILLISECOND,32)}}class ac extends Vb{constructor(){super(v.MICROSECOND,64)}}class bc extends Vb{constructor(){super(v.NANOSECOND,64)}}class cc extends A{constructor(a,b){super();this.unit=a;this.timezone=b}get typeId(){return y.Timestamp}toString(){return`Timestamp<${v[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}}var dc=Symbol.toStringTag,ec,fc=cc.prototype;fc.unit=null;fc.timezone=null;fc.ArrayType=Int32Array;ec=fc[Symbol.toStringTag]="Timestamp";
cc[dc]=ec;class gc extends cc{constructor(a){super(v.SECOND,a)}}class hc extends cc{constructor(a){super(v.MILLISECOND,a)}}class ic extends cc{constructor(a){super(v.MICROSECOND,a)}}class jc extends cc{constructor(a){super(v.NANOSECOND,a)}}class kc extends A{constructor(a){super();this.unit=a}get typeId(){return y.Interval}toString(){return`Interval<${Ja[this.unit]}>`}}var lc=Symbol.toStringTag,mc,nc=kc.prototype;nc.unit=null;nc.ArrayType=Int32Array;mc=nc[Symbol.toStringTag]="Interval";kc[lc]=mc;
class oc extends kc{constructor(){super(Ja.DAY_TIME)}}class pc extends kc{constructor(){super(Ja.YEAR_MONTH)}}class qc extends A{constructor(a){super();this.children=[a]}get typeId(){return y.List}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}}var rc=Symbol.toStringTag,sc,tc=qc.prototype;tc.children=null;sc=tc[Symbol.toStringTag]="List";qc[rc]=sc;
class C extends A{constructor(a){super();this.children=a}get typeId(){return y.Struct}toString(){return`Struct<{${this.children.map(a=>`${a.name}:${a.type}`).join(", ")}}>`}}var uc=Symbol.toStringTag,vc,wc=C.prototype;wc.children=null;vc=wc[Symbol.toStringTag]="Struct";C[uc]=vc;
class xc extends A{constructor(a,b,c){super();this.mode=a;this.children=c;this.typeIds=b=Int32Array.from(b);this.typeIdToChildIndex=b.reduce((d,e,f)=>(d[e]=f)&&d||d,Object.create(null))}get typeId(){return y.Union}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(a=>`${a.type}`).join(" | ")}>`}}var yc=Symbol.toStringTag,zc,Ac=xc.prototype;Ac.mode=null;Ac.typeIds=null;Ac.children=null;Ac.typeIdToChildIndex=null;Ac.ArrayType=Int8Array;zc=Ac[Symbol.toStringTag]="Union";xc[yc]=zc;
class Bc extends xc{constructor(a,b){super(t.Dense,a,b)}}class Cc extends xc{constructor(a,b){super(t.Sparse,a,b)}}class Dc extends A{constructor(a){super();this.byteWidth=a}get typeId(){return y.FixedSizeBinary}toString(){return`FixedSizeBinary[${this.byteWidth}]`}}var Ec=Symbol.toStringTag,Fc,Gc=Dc.prototype;Gc.byteWidth=null;Gc.ArrayType=Uint8Array;Fc=Gc[Symbol.toStringTag]="FixedSizeBinary";Dc[Ec]=Fc;
class Hc extends A{constructor(a,b){super();this.listSize=a;this.children=[b]}get typeId(){return y.FixedSizeList}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}>`}}var Ic=Symbol.toStringTag,Jc,Kc=Hc.prototype;Kc.children=null;Kc.listSize=null;Jc=Kc[Symbol.toStringTag]="FixedSizeList";Hc[Ic]=Jc;
class Lc extends A{constructor(a,b=!1){super();this.children=[a];this.keysSorted=b}get typeId(){return y.Map}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(a=>`${a.name}:${a.type}`).join(", ")}}>`}}var Mc=Symbol.toStringTag,Nc,Oc=Lc.prototype;Oc.children=null;Oc.keysSorted=null;Nc=Oc[Symbol.toStringTag]="Map_";Lc[Mc]=Nc;
const Pc=(a=>()=>++a)(-1);class Qc extends A{constructor(a,b,c,d){super();this.indices=b;this.dictionary=a;this.isOrdered=d||!1;this.id=null==c?Pc():"number"===typeof c?c:c.low}get typeId(){return y.Dictionary}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}}var Rc=Symbol.toStringTag,Sc,Tc=Qc.prototype;Tc.id=null;Tc.indices=null;Tc.isOrdered=null;
Tc.dictionary=null;Sc=Tc[Symbol.toStringTag]="Dictionary";Qc[Rc]=Sc;function Uc(a){switch(a.typeId){case y.Decimal:return a.bitWidth/32;case y.Timestamp:return 2;case y.Date:return 1+a.unit;case y.Interval:return 1+a.unit;case y.FixedSizeList:return a.listSize;case y.FixedSizeBinary:return a.byteWidth;default:return 1}};class D{visitMany(a,...b){return a.map((c,d)=>this.visit(c,...b.map(e=>e[d])))}visit(...a){return this.getVisitFn(a[0],!1).apply(this,a)}getVisitFn(a,b=!0){return Vc(this,a,b)}getVisitFnByTypeId(a,b=!0){return Wc(this,a,b)}visitNull(){return null}visitBool(){return null}visitInt(){return null}visitFloat(){return null}visitUtf8(){return null}visitBinary(){return null}visitFixedSizeBinary(){return null}visitDate(){return null}visitTimestamp(){return null}visitTime(){return null}visitDecimal(){return null}visitList(){return null}visitStruct(){return null}visitUnion(){return null}visitDictionary(){return null}visitInterval(){return null}visitFixedSizeList(){return null}visitMap(){return null}}
function Vc(a,b,c=!0){return"number"===typeof b?Wc(a,b,c):"string"===typeof b&&b in y?Wc(a,y[b],c):b&&b instanceof A?Wc(a,Xc(b),c):b?.type&&b.type instanceof A?Wc(a,Xc(b.type),c):Wc(a,y.NONE,c)}
function Wc(a,b,c=!0){let d=null;switch(b){case y.Null:d=a.visitNull;break;case y.Bool:d=a.visitBool;break;case y.Int:d=a.visitInt;break;case y.Int8:d=a.visitInt8||a.visitInt;break;case y.Int16:d=a.visitInt16||a.visitInt;break;case y.Int32:d=a.visitInt32||a.visitInt;break;case y.Int64:d=a.visitInt64||a.visitInt;break;case y.Uint8:d=a.visitUint8||a.visitInt;break;case y.Uint16:d=a.visitUint16||a.visitInt;break;case y.Uint32:d=a.visitUint32||a.visitInt;break;case y.Uint64:d=a.visitUint64||a.visitInt;
break;case y.Float:d=a.visitFloat;break;case y.Float16:d=a.visitFloat16||a.visitFloat;break;case y.Float32:d=a.visitFloat32||a.visitFloat;break;case y.Float64:d=a.visitFloat64||a.visitFloat;break;case y.Utf8:d=a.visitUtf8;break;case y.Binary:d=a.visitBinary;break;case y.FixedSizeBinary:d=a.visitFixedSizeBinary;break;case y.Date:d=a.visitDate;break;case y.DateDay:d=a.visitDateDay||a.visitDate;break;case y.DateMillisecond:d=a.visitDateMillisecond||a.visitDate;break;case y.Timestamp:d=a.visitTimestamp;
break;case y.TimestampSecond:d=a.visitTimestampSecond||a.visitTimestamp;break;case y.TimestampMillisecond:d=a.visitTimestampMillisecond||a.visitTimestamp;break;case y.TimestampMicrosecond:d=a.visitTimestampMicrosecond||a.visitTimestamp;break;case y.TimestampNanosecond:d=a.visitTimestampNanosecond||a.visitTimestamp;break;case y.Time:d=a.visitTime;break;case y.TimeSecond:d=a.visitTimeSecond||a.visitTime;break;case y.TimeMillisecond:d=a.visitTimeMillisecond||a.visitTime;break;case y.TimeMicrosecond:d=
a.visitTimeMicrosecond||a.visitTime;break;case y.TimeNanosecond:d=a.visitTimeNanosecond||a.visitTime;break;case y.Decimal:d=a.visitDecimal;break;case y.List:d=a.visitList;break;case y.Struct:d=a.visitStruct;break;case y.Union:d=a.visitUnion;break;case y.DenseUnion:d=a.visitDenseUnion||a.visitUnion;break;case y.SparseUnion:d=a.visitSparseUnion||a.visitUnion;break;case y.Dictionary:d=a.visitDictionary;break;case y.Interval:d=a.visitInterval;break;case y.IntervalDayTime:d=a.visitIntervalDayTime||a.visitInterval;
break;case y.IntervalYearMonth:d=a.visitIntervalYearMonth||a.visitInterval;break;case y.FixedSizeList:d=a.visitFixedSizeList;break;case y.Map:d=a.visitMap}if("function"===typeof d)return d;if(!c)return()=>null;throw Error(`Unrecognized type '${y[b]}'`);}
function Xc(a){switch(a.typeId){case y.Null:return y.Null;case y.Int:const b=a.isSigned;switch(a.bitWidth){case 8:return b?y.Int8:y.Uint8;case 16:return b?y.Int16:y.Uint16;case 32:return b?y.Int32:y.Uint32;case 64:return b?y.Int64:y.Uint64}return y.Int;case y.Float:switch(a.precision){case u.HALF:return y.Float16;case u.SINGLE:return y.Float32;case u.DOUBLE:return y.Float64}return y.Float;case y.Binary:return y.Binary;case y.Utf8:return y.Utf8;case y.Bool:return y.Bool;case y.Decimal:return y.Decimal;
case y.Time:switch(a.unit){case v.SECOND:return y.TimeSecond;case v.MILLISECOND:return y.TimeMillisecond;case v.MICROSECOND:return y.TimeMicrosecond;case v.NANOSECOND:return y.TimeNanosecond}return y.Time;case y.Timestamp:switch(a.unit){case v.SECOND:return y.TimestampSecond;case v.MILLISECOND:return y.TimestampMillisecond;case v.MICROSECOND:return y.TimestampMicrosecond;case v.NANOSECOND:return y.TimestampNanosecond}return y.Timestamp;case y.Date:switch(a.unit){case Ga.DAY:return y.DateDay;case Ga.MILLISECOND:return y.DateMillisecond}return y.Date;
case y.Interval:switch(a.unit){case Ja.DAY_TIME:return y.IntervalDayTime;case Ja.YEAR_MONTH:return y.IntervalYearMonth}return y.Interval;case y.Map:return y.Map;case y.List:return y.List;case y.Struct:return y.Struct;case y.Union:switch(a.mode){case t.Dense:return y.DenseUnion;case t.Sparse:return y.SparseUnion}return y.Union;case y.FixedSizeBinary:return y.FixedSizeBinary;case y.FixedSizeList:return y.FixedSizeList;case y.Dictionary:return y.Dictionary}throw Error(`Unrecognized type '${y[a.typeId]}'`);
}h=D.prototype;h.visitInt8=null;h.visitInt16=null;h.visitInt32=null;h.visitInt64=null;h.visitUint8=null;h.visitUint16=null;h.visitUint32=null;h.visitUint64=null;h.visitFloat16=null;h.visitFloat32=null;h.visitFloat64=null;h.visitDateDay=null;h.visitDateMillisecond=null;h.visitTimestampSecond=null;h.visitTimestampMillisecond=null;h.visitTimestampMicrosecond=null;h.visitTimestampNanosecond=null;h.visitTimeSecond=null;h.visitTimeMillisecond=null;h.visitTimeMicrosecond=null;h.visitTimeNanosecond=null;
h.visitDenseUnion=null;h.visitSparseUnion=null;h.visitIntervalDayTime=null;h.visitIntervalYearMonth=null;const Yc=new Float64Array(1),Zc=new Uint32Array(Yc.buffer);function $c(a){const b=(a&31744)>>10,c=(a&1023)/1024;a=(-1)**((a&32768)>>15);switch(b){case 31:return a*(c?Number.NaN:1/0);case 0:return a*(c?6.103515625E-5*c:0)}return a*2**(b-15)*(1+c)}
function ad(a){if(a!==a)return 32256;Yc[0]=a;a=(Zc[1]&2147483648)>>16&65535;let b=Zc[1]&2146435072,c=0;1089470464<=b?0<Zc[0]?b=31744:(b=(b&2080374784)>>16,c=(Zc[1]&1048575)>>10):1056964608>=b?(c=1048576+(Zc[1]&1048575),c=1048576+(c<<(b>>20)-998)>>21,b=0):(b=b-1056964608>>10,c=(Zc[1]&1048575)+512>>10);return a|b|c&65535}var bd={};bd.float64ToUint16=ad;bd.uint16ToFloat64=$c;class cd extends D{}function E(a){return(b,c,d)=>{if(b.setValid(c,null!=d))return a(b,c,d)}}
const dd=(a,b,c)=>{a[b]=Math.trunc(c%4294967296);a[b+1]=Math.trunc(c/4294967296)},ed=(a,b,c,d)=>{if(c+1<b.length){const {[c]:e,[c+1]:f}=b;a.set(d.subarray(0,f-e),e)}},fd=({values:a},b,c)=>{a[b]=c},gd=({values:a},b,c)=>{a[b]=c},hd=({values:a},b,c)=>{a[b]=ad(c)},id=({values:a},b,c)=>{a[b]=Math.trunc(c.valueOf()/864E5)},jd=({values:a},b,c)=>{dd(a,2*b,c.valueOf())},kd=({stride:a,values:b},c,d)=>{b.set(d.subarray(0,a),a*c)},ld=(a,b,c)=>{a.type.unit===Ga.DAY?id(a,b,c):jd(a,b,c)},md=({values:a},b,c)=>dd(a,
2*b,c/1E3),nd=({values:a},b,c)=>dd(a,2*b,c),od=({values:a},b,c)=>{b*=2;a[b]=Math.trunc(1E3*c%4294967296);a[b+1]=Math.trunc(1E3*c/4294967296)},pd=({values:a},b,c)=>{b*=2;a[b]=Math.trunc(1E6*c%4294967296);a[b+1]=Math.trunc(1E6*c/4294967296)},qd=(a,b,c)=>{switch(a.type.unit){case v.SECOND:return md(a,b,c);case v.MILLISECOND:return nd(a,b,c);case v.MICROSECOND:return od(a,b,c);case v.NANOSECOND:return pd(a,b,c)}},rd=({values:a},b,c)=>{a[b]=c},sd=({values:a},b,c)=>{a[b]=c},td=({values:a},b,c)=>{a[b]=c},
ud=({values:a},b,c)=>{a[b]=c},vd=(a,b,c)=>{switch(a.type.unit){case v.SECOND:return rd(a,b,c);case v.MILLISECOND:return sd(a,b,c);case v.MICROSECOND:return td(a,b,c);case v.NANOSECOND:return ud(a,b,c)}},wd=({values:a,stride:b},c,d)=>{a.set(d.subarray(0,b),b*c)},xd=(a,b)=>(c,d,e,f)=>d&&c(d,a,b[f]),yd=(a,b)=>(c,d,e,f)=>d&&c(d,a,b.get(f)),zd=(a,b)=>(c,d,e)=>d&&c(d,a,b.get(e.name)),Ad=(a,b)=>(c,d,e)=>d&&c(d,a,b[e.name]),Cd=(a,b,c)=>{Bd.visit(a.children[a.type.typeIdToChildIndex[a.typeIds[b]]],a.valueOffsets[b],
c)},Dd=(a,b,c)=>{Bd.visit(a.children[a.type.typeIdToChildIndex[a.typeIds[b]]],b,c)},Gd=(a,b,c)=>{a.type.unit===Ja.DAY_TIME?Ed(a,b,c):Fd(a,b,c)},Ed=({values:a},b,c)=>{a.set(c.subarray(0,2),2*b)},Fd=({values:a},b,c)=>{a[b]=12*c[0]+c[1]%12};h=cd.prototype;h.visitBool=E(({offset:a,values:b},c,d)=>{a+=c;d?b[a>>3]|=1<<a%8:b[a>>3]&=~(1<<a%8)});h.visitInt=E(fd);h.visitInt8=E(fd);h.visitInt16=E(fd);h.visitInt32=E(fd);h.visitInt64=E(fd);h.visitUint8=E(fd);h.visitUint16=E(fd);h.visitUint32=E(fd);
h.visitUint64=E(fd);h.visitFloat=E((a,b,c)=>{switch(a.type.precision){case u.HALF:return hd(a,b,c);case u.SINGLE:case u.DOUBLE:return gd(a,b,c)}});h.visitFloat16=E(hd);h.visitFloat32=E(gd);h.visitFloat64=E(gd);h.visitUtf8=E(({values:a,valueOffsets:b},c,d)=>{ed(a,b,c,ca.encode(d))});h.visitBinary=E(({values:a,valueOffsets:b},c,d)=>ed(a,b,c,d));h.visitFixedSizeBinary=E(kd);h.visitDate=E(ld);h.visitDateDay=E(id);h.visitDateMillisecond=E(jd);h.visitTimestamp=E(qd);h.visitTimestampSecond=E(md);
h.visitTimestampMillisecond=E(nd);h.visitTimestampMicrosecond=E(od);h.visitTimestampNanosecond=E(pd);h.visitTime=E(vd);h.visitTimeSecond=E(rd);h.visitTimeMillisecond=E(sd);h.visitTimeMicrosecond=E(td);h.visitTimeNanosecond=E(ud);h.visitDecimal=E(wd);h.visitList=E((a,b,c)=>{const d=a.children[0];a=a.valueOffsets;const e=Bd.getVisitFn(d);if(Array.isArray(c))for(let f=-1,g=a[b],k=a[b+1];g<k;)e(d,g++,c[++f]);else for(let f=-1,g=a[b],k=a[b+1];g<k;)e(d,g++,c.get(++f))});
h.visitStruct=E((a,b,c)=>{const d=a.type.children.map(f=>Bd.getVisitFn(f.type)),e=c instanceof Map?zd(b,c):c instanceof F?yd(b,c):Array.isArray(c)?xd(b,c):Ad(b,c);a.type.children.forEach((f,g)=>e(d[g],a.children[g],f,g))});h.visitUnion=E((a,b,c)=>{a.type.mode===t.Dense?Cd(a,b,c):Dd(a,b,c)});h.visitDenseUnion=E(Cd);h.visitSparseUnion=E(Dd);h.visitDictionary=E((a,b,c)=>{a.dictionary?.set(a.values[b],c)});h.visitInterval=E(Gd);h.visitIntervalDayTime=E(Ed);h.visitIntervalYearMonth=E(Fd);
h.visitFixedSizeList=E((a,b,c)=>{const d=a.stride;a=a.children[0];const e=Bd.getVisitFn(a);if(Array.isArray(c))for(let f=-1,g=b*d;++f<d;)e(a,g+f,c[f]);else for(let f=-1,g=b*d;++f<d;)e(a,g+f,c.get(f))});h.visitMap=E((a,b,c)=>{const d=a.children[0],e=a.valueOffsets;a=Bd.getVisitFn(d);let {[b]:f,[b+1]:g}=e;b=c instanceof Map?c.entries():Object.entries(c);for(const k of b)if(a(d,f,k),++f>=g)break});const Bd=new cd;const Hd=Symbol.for("parent"),Id=Symbol.for("rowIndex");
class Jd{constructor(a,b){this[Hd]=a;this[Id]=b;return new Proxy(this,new Kd)}toArray(){return Object.values(this.toJSON())}toJSON(){const a=this[Id],b=this[Hd],c=b.type.children,d={};for(let e=-1,f=c.length;++e<f;)d[c[e].name]=Ld.visit(b.children[e],a);return d}toString(){return`{${[...this].map(([a,b])=>`${Oa(a)}: ${Oa(b)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Md(this[Hd],this[Id])}}
class Md{constructor(a,b){this.tb=0;this.children=a.children;this.rowIndex=b;this.sb=a.type.children;this.numChildren=this.sb.length}[Symbol.iterator](){return this}next(){const a=this.tb;return a<this.numChildren?(this.tb=a+1,{done:!1,value:[this.sb[a].name,Ld.visit(this.children[a],this.rowIndex)]}):{done:!0,value:null}}}
Object.defineProperties(Jd.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Hd]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Id]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});
class Kd{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(a){return a[Hd].type.children.map(b=>b.name)}has(a,b){return-1!==a[Hd].type.children.findIndex(c=>c.name===b)}getOwnPropertyDescriptor(a,b){if(-1!==a[Hd].type.children.findIndex(c=>c.name===b))return{writable:!0,enumerable:!0,configurable:!0}}get(a,b){if(Reflect.has(a,b))return a[b];var c=a[Hd].type.children.findIndex(d=>d.name===b);if(-1!==c)return c=Ld.visit(a[Hd].children[c],a[Id]),Reflect.set(a,b,c),
c}set(a,b,c){const d=a[Hd].type.children.findIndex(e=>e.name===b);return-1!==d?(Bd.visit(a[Hd].children[d],a[Id],c),Reflect.set(a,b,c)):Reflect.has(a,b)||"symbol"===typeof b?Reflect.set(a,b,c):!1}};class Nd extends D{}function G(a){return(b,c)=>b.getValid(c)?a(b,c):null}
const Od=(a,b)=>4294967296*a[b+1]+(a[b]>>>0),Pd=({values:a},b)=>new Date(864E5*a[b]),Qd=({values:a},b)=>new Date(Od(a,2*b)),Rd=({stride:a,values:b},c)=>b[a*c],Sd=({values:a},b)=>a[b],Td=({values:a},b)=>1E3*Od(a,2*b),Ud=({values:a},b)=>Od(a,2*b),Vd=({values:a},b)=>{b*=2;return a[b+1]/1E3*4294967296+(a[b]>>>0)/1E3},Wd=({values:a},b)=>{b*=2;return a[b+1]/1E6*4294967296+(a[b]>>>0)/1E6},Xd=({values:a},b)=>a[b],Yd=({values:a},b)=>a[b],Zd=({values:a},b)=>a[b],$d=({values:a},b)=>a[b],ae=(a,b)=>Ld.visit(a.children[a.type.typeIdToChildIndex[a.typeIds[b]]],
a.valueOffsets[b]),be=(a,b)=>Ld.visit(a.children[a.type.typeIdToChildIndex[a.typeIds[b]]],b),ce=({values:a},b)=>a.subarray(2*b,2*(b+1)),de=({values:a},b)=>{a=a[b];b=new Int32Array(2);b[0]=Math.trunc(a/12);b[1]=Math.trunc(a%12);return b};h=Nd.prototype;h.visitNull=G(()=>null);h.visitBool=G(({offset:a,values:b},c)=>{a+=c;return 0!==(b[a>>3]&1<<a%8)});h.visitInt=G(({values:a},b)=>a[b]);h.visitInt8=G(Rd);h.visitInt16=G(Rd);h.visitInt32=G(Rd);h.visitInt64=G(Sd);h.visitUint8=G(Rd);h.visitUint16=G(Rd);
h.visitUint32=G(Rd);h.visitUint64=G(Sd);h.visitFloat=G(({type:a,values:b},c)=>a.precision!==u.HALF?b[c]:$c(b[c]));h.visitFloat16=G(({stride:a,values:b},c)=>$c(b[a*c]));h.visitFloat32=G(Rd);h.visitFloat64=G(Rd);h.visitUtf8=G(({values:a,valueOffsets:b},c)=>{a=c+1>=b.length?null:a.subarray(b[c],b[c+1]);return null!==a?aa.decode(a):null});h.visitBinary=G(({values:a,valueOffsets:b},c)=>c+1>=b.length?null:a.subarray(b[c],b[c+1]));h.visitFixedSizeBinary=G(({stride:a,values:b},c)=>b.subarray(a*c,a*(c+1)));
h.visitDate=G((a,b)=>a.type.unit===Ga.DAY?Pd(a,b):Qd(a,b));h.visitDateDay=G(Pd);h.visitDateMillisecond=G(Qd);h.visitTimestamp=G((a,b)=>{switch(a.type.unit){case v.SECOND:return Td(a,b);case v.MILLISECOND:return Ud(a,b);case v.MICROSECOND:return Vd(a,b);case v.NANOSECOND:return Wd(a,b)}});h.visitTimestampSecond=G(Td);h.visitTimestampMillisecond=G(Ud);h.visitTimestampMicrosecond=G(Vd);h.visitTimestampNanosecond=G(Wd);
h.visitTime=G((a,b)=>{switch(a.type.unit){case v.SECOND:return Xd(a,b);case v.MILLISECOND:return Yd(a,b);case v.MICROSECOND:return Zd(a,b);case v.NANOSECOND:return $d(a,b)}});h.visitTimeSecond=G(Xd);h.visitTimeMillisecond=G(Yd);h.visitTimeMicrosecond=G(Zd);h.visitTimeNanosecond=G($d);h.visitDecimal=G(({values:a,stride:b},c)=>new Xa(a.subarray(b*c,b*(c+1))));h.visitList=G((a,b)=>{const c=a.stride,d=a.children,{[b*c]:e,[b*c+1]:f}=a.valueOffsets;a=d[0].slice(e,f-e);return new F([a])});
h.visitStruct=G((a,b)=>new Jd(a,b));h.visitUnion=G((a,b)=>a.type.mode===t.Dense?ae(a,b):be(a,b));h.visitDenseUnion=G(ae);h.visitSparseUnion=G(be);h.visitDictionary=G((a,b)=>a.dictionary?.get(a.values[b]));h.visitInterval=G((a,b)=>a.type.unit===Ja.DAY_TIME?ce(a,b):de(a,b));h.visitIntervalDayTime=G(ce);h.visitIntervalYearMonth=G(de);h.visitFixedSizeList=G((a,b)=>{const c=a.stride;a=a.children[0].slice(b*c,c);return new F([a])});
h.visitMap=G((a,b)=>{const c=a.children,{[b]:d,[b+1]:e}=a.valueOffsets;return new ee(c[0].slice(d,e-d))});const Ld=new Nd;const fe=Symbol.for("keys"),ge=Symbol.for("vals");
class ee{constructor(a){this[fe]=(new F([a.children[0]])).memoize();this[ge]=a.children[1];return new Proxy(this,new he)}[Symbol.iterator](){return new ie(this[fe],this[ge])}get size(){return this[fe].length}toArray(){return Object.values(this.toJSON())}toJSON(){const a=this[fe],b=this[ge],c={};for(let d=-1,e=a.length;++d<e;)c[a.get(d)]=Ld.visit(b,d);return c}toString(){return`{${[...this].map(([a,b])=>`${Oa(a)}: ${Oa(b)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}}
class ie{constructor(a,b){this.keys=a;this.Pb=b;this.wb=0;this.Ob=a.length}[Symbol.iterator](){return this}next(){const a=this.wb;if(a===this.Ob)return{done:!0,value:null};this.wb++;return{done:!1,value:[this.keys.get(a),Ld.visit(this.Pb,a)]}}}
class he{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(a){return a[fe].toArray().map(String)}has(a,b){return a[fe].includes(b)}getOwnPropertyDescriptor(a,b){if(-1!==a[fe].indexOf(b))return{writable:!0,enumerable:!0,configurable:!0}}get(a,b){if(Reflect.has(a,b))return a[b];var c=a[fe].indexOf(b);if(-1!==c)return c=Ld.visit(Reflect.get(a,ge),c),Reflect.set(a,b,c),c}set(a,b,c){const d=a[fe].indexOf(b);return-1!==d?(Bd.visit(Reflect.get(a,ge),d,c),Reflect.set(a,
b,c)):Reflect.has(a,b)?Reflect.set(a,b,c):!1}}Object.defineProperties(ee.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[fe]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ge]:{writable:!0,enumerable:!1,configurable:!1,value:null}});let je;function ke(a,b,c,d){const {length:e=0}=a;b="number"!==typeof b?0:b;c="number"!==typeof c?e:c;0>b&&(b=(b%e+e)%e);0>c&&(c=(c%e+e)%e);c<b&&(je=b,b=c,c=je);c>e&&(c=e);return d?d(a,b,c):[b,c]}const le=a=>a!==a;function me(a){if("object"!==typeof a||null===a)return a!==a?le:b=>b===a;if(a instanceof Date){const b=a.valueOf();return c=>c instanceof Date?c.valueOf()===b:!1}return ArrayBuffer.isView(a)?b=>b?sa(a,b):!1:a instanceof Map?ne(a):Array.isArray(a)?oe(a):a instanceof F?pe(a):qe(a)}
function oe(a){const b=[];for(let c=-1,d=a.length;++c<d;)b[c]=me(a[c]);return re(b)}function ne(a){let b=-1;const c=[];for(const d of a.values())c[++b]=me(d);return re(c)}function pe(a){const b=[];for(let c=-1,d=a.length;++c<d;)b[c]=me(a.get(c));return re(b)}function qe(a){const b=Object.keys(a),c=[];for(let d=-1,e=b.length;++d<e;)c[d]=me(a[b[d]]);return re(c,b)}
function re(a,b){return c=>{if(!c||"object"!==typeof c)return!1;switch(c.constructor){case Array:a:{var d=a.length;if(c.length!==d)c=!1;else{for(var e=-1;++e<d;)if(!a[e](c[e])){c=!1;break a}c=!0}}return c;case Map:return se(a,c,c.keys());case ee:case Jd:case Object:case void 0:return se(a,c,b||Object.keys(c))}if(c instanceof F)a:if(d=a.length,c.length!==d)c=!1;else{for(e=-1;++e<d;)if(!a[e](c.get(e))){c=!1;break a}c=!0}else c=!1;return c}}
function se(a,b,c){c=c[Symbol.iterator]();const d=b instanceof Map?b.keys():Object.keys(b)[Symbol.iterator]();b=b instanceof Map?b.values():Object.values(b)[Symbol.iterator]();let e=0;const f=a.length;let g=b.next(),k=c.next(),n=d.next();for(;e<f&&!k.done&&!n.done&&!g.done&&k.value===n.value&&a[e](g.value);++e,k=c.next(),n=d.next(),g=b.next());if(e===f&&k.done&&n.done&&g.done)return!0;c.return&&c.return();d.return&&d.return();b.return&&b.return();return!1}
var te={clampIndex:function(a,b,c){const d=a.length;b=-1<b?b:d+b%d;return c?c(a,b):b}};te.clampRange=ke;te.createElementComparator=me;function ue(a,b,c,d){return 0!==(c&1<<d)}function ve(a,b,c,d){return(c&1<<d)>>d}function we(a,b,c){const d=c.byteLength+7&-8;if(0<a||c.byteLength<d){const e=new Uint8Array(d);e.set(0===a%8?c.subarray(a>>3):xe(new ye(c,a,b,null,ue)).subarray(0,d));return e}return c}function xe(a){const b=[];let c=0,d=0,e=0;for(const f of a)f&&(e|=1<<d),8===++d&&(b[c++]=e,e=d=0);if(0===c||0<d)b[c++]=e;a=new Uint8Array(b.length+7&-8);a.set(b);return a}
class ye{constructor(a,b,c,d,e){this.P=a;this.length=c;this.context=d;this.get=e;this.Ta=b%8;this.rb=b>>3;this.qb=a[this.rb++];this.index=0}next(){return this.index<this.length?(8===this.Ta&&(this.Ta=0,this.qb=this.P[this.rb++]),{value:this.get(this.context,this.index++,this.qb,this.Ta++)}):{done:!0,value:null}}[Symbol.iterator](){return this}}
function ze(a,b,c){if(0>=c-b)return 0;if(8>c-b){var d=0;for(var e of new ye(a,b,c-b,a,ve))d+=e;return d}d=c>>3<<3;e=b+(0===b%8?0:8-b%8);return ze(a,b,e)+ze(a,d,c)+Ae(a,e>>3,d-e>>3)}function Ae(a,b,c){let d=0;b=Math.trunc(b);const e=new DataView(a.buffer,a.byteOffset,a.byteLength);for(a=void 0===c?a.byteLength:b+c;4<=a-b;)d+=Be(e.getUint32(b)),b+=4;for(;2<=a-b;)d+=Be(e.getUint16(b)),b+=2;for(;1<=a-b;)d+=Be(e.getUint8(b)),b+=1;return d}
function Be(a){a=Math.trunc(a);a-=a>>>1&1431655765;a=(a&858993459)+(a>>>2&858993459);return 16843009*(a+(a>>>4)&252645135)>>>24}var Ce={};Ce.BitIterator=ye;Ce.getBit=ve;Ce.getBool=ue;Ce.packBools=xe;Ce.popcnt_array=Ae;Ce.popcnt_bit_range=ze;Ce.popcnt_uint32=Be;Ce.setBool=function(a,b,c){return c?!!(a[b>>3]|=1<<b%8)||!0:!(a[b>>3]&=~(1<<b%8))&&!1};Ce.truncateBitmap=we;function De(a,b,c){return a.map(d=>d.slice(b,c))}
class H{constructor(a,b,c,d,e,f=[],g){this.type=a;this.children=f;this.dictionary=g;this.offset=Math.floor(Math.max(b||0,0));this.length=Math.floor(Math.max(c||0,0));this.F=Math.floor(Math.max(d||0,-1));let k;e instanceof H?(this.stride=e.stride,this.values=e.values,this.typeIds=e.typeIds,this.nullBitmap=e.nullBitmap,this.valueOffsets=e.valueOffsets):(this.stride=Uc(a),e&&((k=e[0])&&(this.valueOffsets=k),(k=e[1])&&(this.values=k),(k=e[2])&&(this.nullBitmap=k),(k=e[3])&&(this.typeIds=k)));this.nullable=
0!==this.F&&this.nullBitmap&&0<this.nullBitmap.byteLength}get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get byteLength(){let a=0;const b=this.valueOffsets,c=this.values,d=this.nullBitmap,e=this.typeIds;b&&(a+=b.byteLength);c&&(a+=c.byteLength);d&&(a+=d.byteLength);e&&(a+=e.byteLength);return this.children.reduce((f,g)=>f+g.byteLength,a)}get nullCount(){let a=this.F,b;-1>=a&&(b=this.nullBitmap)&&
(this.F=a=this.length-ze(b,this.offset,this.offset+this.length));return a}getValid(a){return this.nullable&&0<this.nullCount?(a=this.offset+a,0!==(this.nullBitmap[a>>3]&1<<a%8)):!0}setValid(a,b){if(!this.nullable)return b;if(!this.nullBitmap||this.nullBitmap.byteLength<=a>>3){var {nullBitmap:c}=this.xa(this.length);Object.assign(this,{nullBitmap:c,F:0})}c=this.nullBitmap;var d=this.offset;const e=d+a>>3;a=(d+a)%8;d=c[e]>>a&1;b?0===d&&(c[e]|=1<<a,this.F=this.nullCount+1):1===d&&(c[e]&=~(1<<a),this.F=
this.nullCount-1);return b}clone(a=this.type,b=this.offset,c=this.length,d=this.F,e=this,f=this.children){return new H(a,b,c,d,e,f,this.dictionary)}slice(a,b){const c=this.stride,d=this.typeId,e=this.children,f=+(0===this.F)-1,g=16===d?c:1;let k;const n=this.buffers;(k=n[Ma.TYPE])&&(n[Ma.TYPE]=k.subarray(a,a+b));(k=n[Ma.OFFSET])&&(n[Ma.OFFSET]=k.subarray(a,a+b+1))||(k=n[Ma.DATA])&&(n[Ma.DATA]=6===d?k:k.subarray(c*a,c*(a+b)));return this.clone(this.type,this.offset+a,b,f,n,0===e.length||this.valueOffsets?
e:De(e,g*a,g*b))}xa(a){if(this.typeId===y.Null)return this.clone(this.type,0,a,0);const b=this.length,c=this.nullCount,d=(new Uint8Array((a+63&-64)>>3)).fill(255,0,b>>3);d[b>>3]=(1<<b-(b&-8))-1;0<c&&d.set(we(this.offset,b,this.nullBitmap),0);const e=this.buffers;e[Ma.VALIDITY]=d;return this.clone(this.type,0,a,c+(a-b),e)}}H.prototype.children=Object.freeze([]);
class Ee extends D{visit(a){return this.getVisitFn(a.type).call(this,a)}visitNull(a){const {type:b,offset:c=0,length:d=0}=a;return new H(b,c,d,0)}visitBool(a){const {type:b,offset:c=0}=a,d=q(Uint8Array,a.nullBitmap),e=q(b.ArrayType,a.data),{length:f=e.length>>3,nullCount:g=a.nullBitmap?-1:0}=a;return new H(b,c,f,g,[void 0,e,d])}visitInt(a){const {type:b,offset:c=0}=a,d=q(Uint8Array,a.nullBitmap),e=q(b.ArrayType,a.data),{length:f=e.length,nullCount:g=a.nullBitmap?-1:0}=a;return new H(b,c,f,g,[void 0,
e,d])}visitFloat(a){const {type:b,offset:c=0}=a,d=q(Uint8Array,a.nullBitmap),e=q(b.ArrayType,a.data),{length:f=e.length,nullCount:g=a.nullBitmap?-1:0}=a;return new H(b,c,f,g,[void 0,e,d])}visitUtf8(a){const {type:b,offset:c=0}=a,d=q(Uint8Array,a.data),e=q(Uint8Array,a.nullBitmap),f=q(Int32Array,a.valueOffsets),{length:g=f.length-1,nullCount:k=a.nullBitmap?-1:0}=a;return new H(b,c,g,k,[f,d,e])}visitBinary(a){const {type:b,offset:c=0}=a,d=q(Uint8Array,a.data),e=q(Uint8Array,a.nullBitmap),f=q(Int32Array,
a.valueOffsets),{length:g=f.length-1,nullCount:k=a.nullBitmap?-1:0}=a;return new H(b,c,g,k,[f,d,e])}visitFixedSizeBinary(a){const {type:b,offset:c=0}=a,d=q(Uint8Array,a.nullBitmap),e=q(b.ArrayType,a.data),{length:f=e.length/Uc(b),nullCount:g=a.nullBitmap?-1:0}=a;return new H(b,c,f,g,[void 0,e,d])}visitDate(a){const {type:b,offset:c=0}=a,d=q(Uint8Array,a.nullBitmap),e=q(b.ArrayType,a.data),{length:f=e.length/Uc(b),nullCount:g=a.nullBitmap?-1:0}=a;return new H(b,c,f,g,[void 0,e,d])}visitTimestamp(a){const {type:b,
offset:c=0}=a,d=q(Uint8Array,a.nullBitmap),e=q(b.ArrayType,a.data),{length:f=e.length/Uc(b),nullCount:g=a.nullBitmap?-1:0}=a;return new H(b,c,f,g,[void 0,e,d])}visitTime(a){const {type:b,offset:c=0}=a,d=q(Uint8Array,a.nullBitmap),e=q(b.ArrayType,a.data),{length:f=e.length/Uc(b),nullCount:g=a.nullBitmap?-1:0}=a;return new H(b,c,f,g,[void 0,e,d])}visitDecimal(a){const {type:b,offset:c=0}=a,d=q(Uint8Array,a.nullBitmap),e=q(b.ArrayType,a.data),{length:f=e.length/Uc(b),nullCount:g=a.nullBitmap?-1:0}=a;
return new H(b,c,f,g,[void 0,e,d])}visitList(a){const {type:b,offset:c=0,child:d}=a,e=q(Uint8Array,a.nullBitmap),f=q(Int32Array,a.valueOffsets),{length:g=f.length-1,nullCount:k=a.nullBitmap?-1:0}=a;return new H(b,c,g,k,[f,void 0,e],[d])}visitStruct(a){const {type:b,offset:c=0,children:d=[]}=a,e=q(Uint8Array,a.nullBitmap),{length:f=d.reduce((k,{length:n})=>Math.max(k,n),0),nullCount:g=a.nullBitmap?-1:0}=a;return new H(b,c,f,g,[void 0,void 0,e],d)}visitUnion(a){const {type:b,offset:c=0,children:d=[]}=
a,e=q(Uint8Array,a.nullBitmap),f=q(b.ArrayType,a.typeIds),{length:g=f.length,nullCount:k=a.nullBitmap?-1:0}=a;if(A.isSparseUnion(b))return new H(b,c,g,k,[void 0,void 0,e,f],d);a=q(Int32Array,a.valueOffsets);return new H(b,c,g,k,[a,void 0,e,f],d)}visitDictionary(a){const {type:b,offset:c=0}=a,d=q(Uint8Array,a.nullBitmap),e=q(b.indices.ArrayType,a.data),{dictionary:f=new F([(new Ee).visit({type:b.dictionary})])}=a,{length:g=e.length,nullCount:k=a.nullBitmap?-1:0}=a;return new H(b,c,g,k,[void 0,e,d],
[],f)}visitInterval(a){const {type:b,offset:c=0}=a,d=q(Uint8Array,a.nullBitmap),e=q(b.ArrayType,a.data),{length:f=e.length/Uc(b),nullCount:g=a.nullBitmap?-1:0}=a;return new H(b,c,f,g,[void 0,e,d])}visitFixedSizeList(a){const {type:b,offset:c=0,child:d=(new Ee).visit({type:b.valueType})}=a,e=q(Uint8Array,a.nullBitmap),{length:f=d.length/Uc(b),nullCount:g=a.nullBitmap?-1:0}=a;return new H(b,c,f,g,[void 0,void 0,e],[d])}visitMap(a){const {type:b,offset:c=0,child:d=(new Ee).visit({type:b.childType})}=
a,e=q(Uint8Array,a.nullBitmap),f=q(Int32Array,a.valueOffsets),{length:g=f.length-1,nullCount:k=a.nullBitmap?-1:0}=a;return new H(b,c,g,k,[f,void 0,e],[d])}}function I(a){return(new Ee).visit(a)};class Fe{constructor(a=0,b){this.xb=a;this.vb=b;this.Va=0;this.ub=this.vb(0)}next(){for(;this.Va<this.xb;){const a=this.ub.next();if(!a.done)return a;++this.Va<this.xb&&(this.ub=this.vb(this.Va))}return{done:!0,value:null}}[Symbol.iterator](){return this}}function Ge(a){return a.reduce((b,c)=>b+c.nullCount,0)}function He(a){return a.reduce((b,c,d)=>{b[d+1]=b[d]+c.length;return b},new Uint32Array(a.length+1))}
function Ie(a,b,c,d){const e=[];for(let f=-1,g=a.length;++f<g;){const k=a[f],n=b[f],p=k.length;if(n>=d)break;if(c>=n+p)continue;if(n>=c&&n+p<=d){e.push(k);continue}const x=Math.max(0,c-n);e.push(k.slice(x,Math.min(d-n,p)-x))}0===e.length&&e.push(a[0].slice(0,0));return e}function Je(a,b,c,d){let e=0,f,g=b.length-1;do{if(e>=g-1)return c<b[g]?d(a,e,c-b[e]):null;f=e+Math.trunc(.5*(g-e));c<b[f]?g=f:e=f}while(e<g)}function Ke(a,b){return a.getValid(b)}
function Le(a){function b(c,d,e){return a(c[d],e)}return function(c){return Je(this.data,this.m,c,b)}}function Me(a){function b(d,e,f){return a(d[e],f,c)}let c;return function(d,e){const f=this.data;c=e;d=Je(f,this.m,d,b);c=void 0;return d}}function Ne(a){function b(d,e,f){var g=f;f=0;for(let k=e-1,n=d.length;++k<n;){e=d[k];if(~(g=a(e,c,g)))return f+g;g=0;f+=e.length}return-1}let c;return function(d,e){c=d;d=this.data;e="number"!==typeof e?b(d,0,0):Je(d,this.m,e,b);c=void 0;return e}};class Oe extends D{}function J(a,b,c){if(void 0===b)return-1;if(null===b){a:{const e=a.nullBitmap;if(e&&!(0>=a.nullCount)){b=0;for(var d of new ye(e,a.offset+(c||0),a.length,e,ue)){if(!d){a=b;break a}++b}}a=-1}return a}d=Ld.getVisitFn(a);b=me(b);for(let e=(c||0)-1,f=a.length;++e<f;)if(b(d(a,e)))return e;return-1}function Pe(a,b,c){const d=Ld.getVisitFn(a);b=me(b);for(let e=(c||0)-1,f=a.length;++e<f;)if(b(d(a,e)))return e;return-1}h=Oe.prototype;
h.visitNull=function(a,b){return null===b&&0<a.length?0:-1};h.visitBool=J;h.visitInt=J;h.visitInt8=J;h.visitInt16=J;h.visitInt32=J;h.visitInt64=J;h.visitUint8=J;h.visitUint16=J;h.visitUint32=J;h.visitUint64=J;h.visitFloat=J;h.visitFloat16=J;h.visitFloat32=J;h.visitFloat64=J;h.visitUtf8=J;h.visitBinary=J;h.visitFixedSizeBinary=J;h.visitDate=J;h.visitDateDay=J;h.visitDateMillisecond=J;h.visitTimestamp=J;h.visitTimestampSecond=J;h.visitTimestampMillisecond=J;h.visitTimestampMicrosecond=J;
h.visitTimestampNanosecond=J;h.visitTime=J;h.visitTimeSecond=J;h.visitTimeMillisecond=J;h.visitTimeMicrosecond=J;h.visitTimeNanosecond=J;h.visitDecimal=J;h.visitList=J;h.visitStruct=J;h.visitUnion=J;h.visitDenseUnion=Pe;h.visitSparseUnion=Pe;h.visitDictionary=J;h.visitInterval=J;h.visitIntervalDayTime=J;h.visitIntervalYearMonth=J;h.visitFixedSizeList=J;h.visitMap=J;const Qe=new Oe;class Re extends D{}function K(a){const b=a.type;if(0===a.nullCount&&1===a.stride&&(b.typeId===y.Timestamp||b instanceof B&&64!==b.bitWidth||b instanceof Vb&&64!==b.bitWidth||b instanceof qb&&b.precision!==u.HALF))return new Fe(a.data.length,d=>{d=a.data[d];return d.values.subarray(0,d.length)[Symbol.iterator]()});let c=0;return new Fe(a.data.length,d=>{d=a.data[d].length;const e=a.slice(c,c+d);c+=d;return new Se(e)})}
class Se{constructor(a){this.yb=a;this.index=0}next(){return this.index<this.yb.length?{value:this.yb.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}}h=Re.prototype;h.visitNull=K;h.visitBool=K;h.visitInt=K;h.visitInt8=K;h.visitInt16=K;h.visitInt32=K;h.visitInt64=K;h.visitUint8=K;h.visitUint16=K;h.visitUint32=K;h.visitUint64=K;h.visitFloat=K;h.visitFloat16=K;h.visitFloat32=K;h.visitFloat64=K;h.visitUtf8=K;h.visitBinary=K;h.visitFixedSizeBinary=K;h.visitDate=K;
h.visitDateDay=K;h.visitDateMillisecond=K;h.visitTimestamp=K;h.visitTimestampSecond=K;h.visitTimestampMillisecond=K;h.visitTimestampMicrosecond=K;h.visitTimestampNanosecond=K;h.visitTime=K;h.visitTimeSecond=K;h.visitTimeMillisecond=K;h.visitTimeMicrosecond=K;h.visitTimeNanosecond=K;h.visitDecimal=K;h.visitList=K;h.visitStruct=K;h.visitUnion=K;h.visitDenseUnion=K;h.visitSparseUnion=K;h.visitDictionary=K;h.visitInterval=K;h.visitIntervalDayTime=K;h.visitIntervalYearMonth=K;h.visitFixedSizeList=K;
h.visitMap=K;const Te=new Re;const Ue=(a,b)=>a+b;
class Ve extends D{visitNull(){return 0}visitInt(a){return a.type.bitWidth/8}visitFloat(a){return a.type.ArrayType.BYTES_PER_ELEMENT}visitBool(){return.125}visitDecimal(a){return a.type.bitWidth/8}visitDate(a){return 4*(a.type.unit+1)}visitTime(a){return a.type.bitWidth/8}visitTimestamp(a){return a.type.unit===v.SECOND?4:8}visitInterval(a){return 4*(a.type.unit+1)}visitStruct(a,b){return a.children.reduce((c,d)=>c+We.visit(d,b),0)}visitFixedSizeBinary(a){return a.type.byteWidth}visitMap(a,b){return 8+
a.children.reduce((c,d)=>c+We.visit(d,b),0)}visitDictionary(a,b){return a.type.indices.bitWidth/8+(a.dictionary?.getByteLength(a.values[b])||0)}}const Xe=({type:a,children:b,typeIds:c,valueOffsets:d},e)=>8+We.visit(b[a.typeIdToChildIndex[c[e]]],d[e]),Ye=({children:a},b)=>4+We.visitMany(a,a.map(()=>b)).reduce(Ue,0);h=Ve.prototype;h.visitUtf8=({valueOffsets:a},b)=>8+(a[b+1]-a[b]);h.visitBinary=({valueOffsets:a},b)=>8+(a[b+1]-a[b]);
h.visitList=({valueOffsets:a,stride:b,children:c},d)=>{var e=c[0];({[d*b]:c}=a);({[d*b+1]:a}=a);b=We.getVisitFn(e.type);e=e.slice(c,a-c);d=8;for(let f=-1,g=a-c;++f<g;)d+=b(e,f);return d};h.visitFixedSizeList=({stride:a,children:b},c)=>{b=b[0];a=b.slice(c*a,a);c=We.getVisitFn(b.type);b=0;for(let d=-1,e=a.length;++d<e;)b+=c(a,d);return b};h.visitUnion=(a,b)=>a.type.mode===t.Dense?Xe(a,b):Ye(a,b);h.visitDenseUnion=Xe;h.visitSparseUnion=Ye;const We=new Ve;const Ze={},$e={};
class F{constructor(a){a=a[0]instanceof F?a.flatMap(c=>c.data):a;if(0===a.length||a.some(c=>!(c instanceof H)))throw new TypeError("Vector constructor expects an Array of Data instances.");const b=a[0]?.type;switch(a.length){case 0:this.m=[0];break;case 1:const {get:c,set:d,indexOf:e,byteLength:f}=Ze[b.typeId],g=a[0];this.isValid=k=>g.getValid(k);this.get=k=>c(g,k);this.set=(k,n)=>d(g,k,n);this.indexOf=k=>e(g,k);this.getByteLength=k=>f(g,k);this.m=[0,g.length];break;default:Object.setPrototypeOf(this,$e[b.typeId]),
this.m=He(a)}this.data=a;this.type=b;this.stride=Uc(b);this.numChildren=b.children?.length??0;this.length=this.m[this.m.length-1]}get byteLength(){-1===this.Z&&(this.Z=this.data.reduce((a,b)=>a+b.byteLength,0));return this.Z}get nullCount(){-1===this.F&&(this.F=Ge(this.data));return this.F}get ArrayType(){return this.type.ArrayType}get [Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${y[this.type.typeId]}Vector`}isValid(){return!1}get(){return null}set(){}indexOf(){return-1}includes(a,
b){return 0<this.indexOf(a,b)}getByteLength(){return 0}[Symbol.iterator](){return Te.visit(this)}concat(...a){return new F(this.data.concat(a.flatMap(b=>b.data).flat(Number.POSITIVE_INFINITY)))}slice(a,b){return new F(ke(this,a,b,({data:c,m:d},e,f)=>Ie(c,d,e,f)))}toJSON(){return[...this]}toArray(){const a=this.data,b=this.length,c=this.stride,d=this.ArrayType;switch(this.type.typeId){case y.Int:case y.Float:case y.Decimal:case y.Time:case y.Timestamp:switch(a.length){case 0:return new d;case 1:return a[0].values.subarray(0,
b*c);default:return a.reduce((e,{values:f,length:g})=>{e.pb.set(f.subarray(0,g*c),e.offset);e.offset+=g*c;return e},{pb:new d(b*c),offset:0}).pb}}return[...this]}toString(){return`[${[...this].join()}]`}getChild(a){return this.getChildAt(this.type.children?.findIndex(b=>b.name===a))}getChildAt(a){return-1<a&&a<this.numChildren?new F(this.data.map(({children:b})=>b[a])):null}get isMemoized(){return A.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(A.isDictionary(this.type)){const a=
new af(this.data[0].dictionary),b=this.data.map(c=>{c=c.clone();c.dictionary=a;return c});return new F(b)}return new af(this)}unmemoize(){if(A.isDictionary(this.type)&&this.isMemoized){const a=this.data[0].dictionary.unmemoize(),b=this.data.map(c=>{c=c.clone();c.dictionary=a;return c});return new F(b)}return this}}
F[Symbol.toStringTag]=(a=>{a.type=A.prototype;a.data=[];a.length=0;a.stride=1;a.numChildren=0;a.F=-1;a.Z=-1;a.m=new Uint32Array([0]);a[Symbol.isConcatSpreadable]=!0;var b=Object.keys(y).map(c=>y[c]).filter(c=>"number"===typeof c&&c!==y.NONE);for(const c of b){b=Ld.getVisitFnByTypeId(c);const d=Bd.getVisitFnByTypeId(c),e=Qe.getVisitFnByTypeId(c),f=We.getVisitFnByTypeId(c);Ze[c]={get:b,set:d,indexOf:e,byteLength:f};$e[c]=Object.create(a,{isValid:{value:Le(Ke)},get:{value:Le(Ld.getVisitFnByTypeId(c))},
set:{value:Me(Bd.getVisitFnByTypeId(c))},indexOf:{value:Ne(Qe.getVisitFnByTypeId(c))},getByteLength:{value:Le(We.getVisitFnByTypeId(c))}})}return"Vector"})(F.prototype);
class af extends F{constructor(a){super(a.data);const b=this.get,c=this.set,d=this.slice,e=Array(this.length);Object.defineProperty(this,"get",{value(f){var g=e[f];if(void 0!==g)return g;g=b.call(this,f);return e[f]=g}});Object.defineProperty(this,"set",{value(f,g){c.call(this,f,g);e[f]=g}});Object.defineProperty(this,"slice",{value:(f,g)=>new af(d.call(this,f,g))});Object.defineProperty(this,"isMemoized",{value:!0});Object.defineProperty(this,"unmemoize",{value:()=>new F(this.data)});Object.defineProperty(this,
"memoize",{value:()=>this})}}
function bf(a){if(a){if(a instanceof H)return new F([a]);if(a instanceof F)return new F(a.data);if(a.type instanceof A)return new F([I(a)]);if(Array.isArray(a))return new F(a.flatMap(b=>b instanceof H?[b]:b instanceof F?b.data:bf(b).data));if(ArrayBuffer.isView(a)){a instanceof DataView&&(a=new Uint8Array(a.buffer));const b={offset:0,length:a.length,nullCount:0,data:a};if(a instanceof Int8Array)return new F([I({...b,type:new hb})]);if(a instanceof Int16Array)return new F([I({...b,type:new ib})]);
if(a instanceof Int32Array)return new F([I({...b,type:new jb})]);if(a instanceof ea)return new F([I({...b,type:new kb})]);if(a instanceof Uint8Array||a instanceof Uint8ClampedArray)return new F([I({...b,type:new lb})]);if(a instanceof Uint16Array)return new F([I({...b,type:new nb})]);if(a instanceof Uint32Array)return new F([I({...b,type:new ob})]);if(a instanceof fa)return new F([I({...b,type:new pb})]);if(a instanceof Float32Array)return new F([I({...b,type:new vb})]);if(a instanceof Float64Array)return new F([I({...b,
type:new wb})])}}throw Error("Unrecognized input");};function cf(a){if(!a||0>=a.length)return function(){return!0};let b="";const c=a.filter(d=>d===d);0<c.length&&(b=`
switch (x) {${c.map(d=>`
case ${"bigint"!==typeof d?Oa(d):da?`${Oa(d)}n`:`"${Oa(d)}"`}:`).join("")}
return false;
}`);a.length!==c.length&&(b=`if (x !== x) return false;\n${b}`);return new Function("x",`${b}\nreturn true;`)};const df=(a,b)=>(Math.ceil(a)*b+63&-64||64)/b,ef=(a,b=0)=>a.length>=b?a.subarray(0,b):ma(new a.constructor(b),a,0);function ff(a,b){a.buffer=ma(new a.ArrayType(b),a.buffer)}function gf(a,b){if(0<b){a.length+=b;b=a.length*a.stride;const c=a.buffer.length;b>=c&&ff(a,0===c?df(1*b,a.BYTES_PER_ELEMENT):df(2*b,a.BYTES_PER_ELEMENT))}return a}
class hf{constructor(a,b=1){this.buffer=a;this.stride=b;this.BYTES_PER_ELEMENT=a.BYTES_PER_ELEMENT;this.ArrayType=a.constructor;ff(this,this.length=Math.ceil(a.length/b))}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(){return this}append(a){return this.set(this.length,a)}flush(a=this.length){a=df(a*this.stride,this.BYTES_PER_ELEMENT);a=ef(this.buffer,
a);this.clear();return a}clear(){this.length=0;ff(this,0);return this}}hf.prototype.offset=0;class jf extends hf{get(a){return this.buffer[a]}set(a,b){gf(this,a-this.length+1);this.buffer[a*this.stride]=b;return this}}
class kf extends jf{constructor(){super(new Uint8Array(0),.125);this.Ha=0}get Nb(){return this.length-this.Ha}get(a){return this.buffer[a>>3]>>a%8&1}set(a,b){const {buffer:c}=gf(this,a-this.length+1),d=a>>3;a%=8;const e=c[d]>>a&1;b?0===e&&(c[d]|=1<<a,++this.Ha):1===e&&(c[d]&=~(1<<a),--this.Ha);return this}clear(){this.Ha=0;return super.clear()}}
class lf extends jf{constructor(){super(new Int32Array(1),1)}append(a){return this.set(this.length-1,a)}set(a,b){const c=this.length-1,d=gf(this,a-c+1).buffer;c<a++&&d.fill(d[c],c,a);d[a]=d[a-1]+b;return this}flush(a=this.length-1){a>this.length&&this.set(a-1,0);return super.flush(a+1)}};class mf{constructor({type:a,nullValues:b}){this.length=0;this.finished=!1;this.type=a;this.children=[];this.nullValues=b;this.stride=Uc(a);this.J=new kf;b&&0<b.length&&(this.jb=cf(b))}static throughNode(){throw Error('"throughNode" not available in this environment');}static throughDOM(){throw Error('"throughDOM" not available in this environment');}toVector(){return new F([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this.J.Nb}get numChildren(){return this.children.length}get byteLength(){let a=
0;const b=this.m,c=this.v,d=this.J,e=this.W,f=this.children;b&&(a+=b.byteLength);c&&(a+=c.byteLength);d&&(a+=d.byteLength);e&&(a+=e.byteLength);return f.reduce((g,k)=>g+k.byteLength,a)}get reservedLength(){return this.J.reservedLength}get reservedByteLength(){let a=0;this.m&&(a+=this.m.reservedByteLength);this.v&&(a+=this.v.reservedByteLength);this.J&&(a+=this.J.reservedByteLength);this.W&&(a+=this.W.reservedByteLength);return this.children.reduce((b,c)=>b+c.reservedByteLength,a)}get valueOffsets(){return this.m?
this.m.buffer:null}get values(){return this.v?this.v.buffer:null}get nullBitmap(){return this.J?this.J.buffer:null}get typeIds(){return this.W?this.W.buffer:null}append(a){return this.set(this.length,a)}isValid(a){return this.jb(a)}set(a,b){this.setValid(a,this.isValid(b))&&this.setValue(a,b);return this}setValue(a,b){this.D(this,a,b)}setValid(a,b){this.length=this.J.set(a,+b).length;return b}addChild(){throw Error(`Cannot append children to non-nested type "${this.type}"`);}getChildAt(a){return this.children[a]||
null}flush(){let a,b,c,d;const e=this.type,f=this.length,g=this.nullCount;var k=this.m;const n=this.v,p=this.J;(b=this.W?.flush(f))?d=k?.flush(f):a=(d=k?.flush(f))?n?.flush(k.get(k.length-1)):n?.flush(f);0<g&&(c=p?.flush(f));k=this.children.map(x=>x.flush());this.clear();return I({type:e,length:f,nullCount:g,children:k,child:k[0],data:a,typeIds:b,nullBitmap:c,valueOffsets:d})}finish(){this.finished=!0;for(const a of this.children)a.finish();return this}clear(){this.length=0;this.J?.clear();this.v?.clear();
this.m?.clear();this.W?.clear();for(const a of this.children)a.clear();return this}}h=mf.prototype;h.length=1;h.stride=1;h.children=null;h.finished=!1;h.nullValues=null;h.jb=()=>!0;class nf extends mf{constructor(a){super(a);this.v=new jf(new this.ArrayType(0),this.stride)}setValue(a,b){const c=this.v;gf(c,a-c.length+1);return super.setValue(a,b)}}function of(a){const b=a.C,c=a.L;a.L=0;a.C=void 0;b&&0<b.size&&a.da(b,c)}
class pf extends mf{constructor(a){super(a);this.L=0;this.m=new lf}setValue(a,b){const c=this.C||(this.C=new Map),d=c.get(a);d&&(this.L-=d.length);this.L+=b instanceof ee?b[fe].length:b.length;c.set(a,b)}setValid(a,b){return super.setValid(a,b)?!0:((this.C||(this.C=new Map)).set(a,void 0),!1)}clear(){this.L=0;this.C=void 0;return super.clear()}flush(){of(this);return super.flush()}finish(){of(this);return super.finish()}};class qf{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}offset(){return rf(this.g,this.h)}Wa(){return this.g.s(this.h+8)}bodyLength(){return rf(this.g,this.h+16)}};const sf=new Int32Array(2);new Float32Array(sf.buffer);new Float64Array(sf.buffer);new Uint16Array((new Uint8Array([1,0])).buffer);class tf{constructor(a,b){this.low=a|0;this.high=b|0}equals(a){return this.low==a.low&&this.high==a.high}}var uf=new tf(0,0);var vf,wf=vf||={};wf[wf.UTF8_BYTES=1]="UTF8_BYTES";wf[wf.UTF16_STRING=2]="UTF16_STRING";function rf(a,b){return new tf(a.s(b),a.s(b+4))}function xf(a,b){return a.j[b]}function yf(a,b){return(a.j[b]|a.j[b+1]<<8)<<16>>16}function L(a,b,c){b-=a.s(b);return c<yf(a,b)?yf(a,b+c):0}function zf(a,b,c){b.h=c+a.s(c);b.g=a;return b}
function Af(a,b,c){b+=a.s(b);const d=a.s(b);let e="",f=0;b+=4;if(c===vf.UTF8_BYTES)return a.j.subarray(b,b+d);for(;f<d;){c=xf(a,b+f++);if(!(192>c)){const g=xf(a,b+f++);if(224>c)c=(c&31)<<6|g&63;else{const k=xf(a,b+f++);if(240>c)c=(c&15)<<12|(g&63)<<6|k&63;else{const n=xf(a,b+f++);c=(c&7)<<18|(g&63)<<12|(k&63)<<6|n&63}}}65536>c?e+=String.fromCharCode(c):(c-=65536,e+=String.fromCharCode((c>>10)+55296,(c&1023)+56320))}return e}function Bf(a,b){return b+a.s(b)}function Cf(a,b){return b+a.s(b)+4}
function Df(a,b){return a.s(b+a.s(b))}class Ef{constructor(a){this.j=a;this.Za=0}clear(){this.Za=0}P(){return this.j}position(){return this.Za}setPosition(a){this.Za=a}s(a){return this.j[a]|this.j[a+1]<<8|this.j[a+2]<<16|this.j[a+3]<<24}ja(a,b){this.j[a]=b}eb(a,b){this.j[a]=b;this.j[a+1]=b>>8}U(a,b){this.j[a]=b;this.j[a+1]=b>>8;this.j[a+2]=b>>16;this.j[a+3]=b>>24}Y(a,b){this.U(a,b.low);this.U(a+4,b.high)}R(a,b){return 0==a&&0==b?uf:new tf(a,b)}};function Ff(a,b,c){b>a.ta&&(a.ta=b);const d=~(a.g.j.length-a.A+c)+1&b-1;for(;a.A<d+b+c;){const g=a.g.j.length;var e=a,f=a.g;const k=f.j.length;if(k&3221225472)throw Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const n=k<<1,p=new Ef(new Uint8Array(n));p.setPosition(n-k);p.P().set(f.P(),n-k);e.g=p;a.A+=a.g.j.length-g}Gf(a,d)}function Gf(a,b){for(let c=0;c<b;c++)a.g.ja(--a.A,0)}function Hf(a){return a.g.P().subarray(a.g.position(),a.g.position()+a.offset())}
function If(a,b){Ff(a,2,0);a.eb(b)}function Jf(a,b){Ff(a,4,0);a.U(b)}function Kf(a,b,c,d){if(a.ea||c!=d)Ff(a,1,0),a.ja(c),a.slot(b)}function Lf(a,b,c){if(a.ea||b!=c)If(a,b),a.slot(0)}function Mf(a,b,c,d){if(a.ea||c!=d)Jf(a,c),a.slot(b)}function Nf(a,b,c,d){if(a.ea||!c.equals(d))Ff(a,8,0),a.Y(c),a.slot(b)}function Of(a,b){Ff(a,4,0);a.U(a.offset()-b+4)}function M(a,b,c){if(a.ea||0!=c)Of(a,c),a.slot(b)}function Pf(a){if(a.sa)throw Error("FlatBuffers: object serialization must not be nested.");}
function N(a,b){Pf(a);null==a.T&&(a.T=[]);a.cb=b;for(let c=0;c<b;c++)a.T[c]=0;a.sa=!0;a.Ya=a.offset()}
function O(a){if(null==a.T||!a.sa)throw Error("FlatBuffers: endObject called without startObject");Jf(a,0);const b=a.offset();let c=a.cb-1;for(;0<=c&&0==a.T[c];c--);for(var d=c+1;0<=c;c--)If(a,0!=a.T[c]?b-a.T[c]:0);If(a,b-a.Ya);d=2*(d+2);If(a,d);let e=0;const f=a.A;c=0;a:for(;c<a.ua.length;c++){const g=a.g.j.length-a.ua[c];if(d==yf(a.g,g)){for(let k=2;k<d;k+=2)if(yf(a.g,f+k)!=yf(a.g,g+k))continue a;e=a.ua[c];break}}e?(a.A=a.g.j.length-b,a.g.U(a.A,e-b)):(a.ua.push(a.offset()),a.g.U(a.g.j.length-b,
a.offset()-b));a.sa=!1;return b}function Qf(a,b,c,d){Pf(a);a.bb=c;Ff(a,4,b*c);Ff(a,d,b*c)}function Rf(a){a.U(a.bb);return a.offset()}
function Sf(a,b){if(!b)return 0;let c;if(b instanceof Uint8Array)c=b;else{c=[];let e=0;for(;e<b.length;){var d=void 0;d=b.charCodeAt(e++);if(!(55296>d||56320<=d)){const f=b.charCodeAt(e++);d=(d<<10)+f+-56613888}128>d?c.push(d):(2048>d?c.push(d>>6&31|192):(65536>d?c.push(d>>12&15|224):c.push(d>>18&7|240,d>>12&63|128),c.push(d>>6&63|128)),c.push(d&63|128))}}Ff(a,1,0);a.ja(0);Qf(a,1,c.length,1);a.g.setPosition(a.A-=c.length);for(let e=0,f=a.A,g=a.g.P();e<c.length;e++)g[f++]=c[e];return Rf(a)}
class Tf{constructor(){this.ta=1;this.T=null;this.cb=0;this.sa=!1;this.Ya=0;this.ua=[];this.bb=0;this.ea=!1;this.g=new Ef(new Uint8Array(1024));this.A=1024}clear(){this.g.clear();this.A=this.g.j.length;this.ta=1;this.T=null;this.cb=0;this.sa=!1;this.Ya=0;this.ua=[];this.bb=0;this.ea=!1}ja(a){this.g.ja(--this.A,a)}eb(a){this.g.eb(this.A-=2,a)}U(a){this.g.U(this.A-=4,a)}Y(a){this.g.Y(this.A-=8,a)}slot(a){null!==this.T&&(this.T[a]=this.offset())}offset(){return this.g.j.length-this.A}finish(a,b,c){c=
c?4:0;if(b){Ff(this,this.ta,8+c);if(4!=b.length)throw Error("FlatBuffers: file identifier must be length 4");for(let d=3;0<=d;d--)this.ja(b.charCodeAt(d))}Ff(this,this.ta,4+c);Of(this,a);c&&Jf(this,this.g.j.length-this.A);this.g.setPosition(this.A)}R(a,b){return 0==a&&0==b?uf:new tf(a,b)}};class Uf{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}key(a){const b=L(this.g,this.h,4);return b?Af(this.g,this.h+b,a):null}value(a){const b=L(this.g,this.h,6);return b?Af(this.g,this.h+b,a):null}};var Vf,Wf=Vf||={};Wf[Wf.V1=0]="V1";Wf[Wf.V2=1]="V2";Wf[Wf.V3=2]="V3";Wf[Wf.V4=3]="V4";Wf[Wf.V5=4]="V5";var Xf,Yf=Xf||={};Yf[Yf.Little=0]="Little";Yf[Yf.Big=1]="Big";var Zf,$f=Zf||={};$f[$f.DenseArray=0]="DenseArray";class ag{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}bitWidth(){const a=L(this.g,this.h,4);return a?this.g.s(this.h+a):0}isSigned(){const a=L(this.g,this.h,6);return a?!!(this.g.j[this.h+a]<<24>>24):!1}};function bg(a){const b=L(a.g,a.h,6);return b?(new ag).i(Bf(a.g,a.h+b),a.g):null}class cg{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}id(){const a=L(this.g,this.h,4);return a?rf(this.g,this.h+a):this.g.R(0,0)}isOrdered(){const a=L(this.g,this.h,8);return a?!!(this.g.j[this.h+a]<<24>>24):!1}};var dg,eg=dg||={};eg[eg.DAY=0]="DAY";eg[eg.MILLISECOND=1]="MILLISECOND";class fg{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}unit(){const a=L(this.g,this.h,4);return a?yf(this.g,this.h+a):dg.MILLISECOND}};class gg{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}precision(){const a=L(this.g,this.h,4);return a?this.g.s(this.h+a):0}scale(){const a=L(this.g,this.h,6);return a?this.g.s(this.h+a):0}bitWidth(){const a=L(this.g,this.h,8);return a?this.g.s(this.h+a):128}};var hg,ig=hg||={};ig[ig.SECOND=0]="SECOND";ig[ig.MILLISECOND=1]="MILLISECOND";ig[ig.MICROSECOND=2]="MICROSECOND";ig[ig.NANOSECOND=3]="NANOSECOND";class jg{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}byteWidth(){const a=L(this.g,this.h,4);return a?this.g.s(this.h+a):0}};class kg{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}listSize(){const a=L(this.g,this.h,4);return a?this.g.s(this.h+a):0}};var lg,mg=lg||={};mg[mg.HALF=0]="HALF";mg[mg.SINGLE=1]="SINGLE";mg[mg.DOUBLE=2]="DOUBLE";class ng{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}precision(){const a=L(this.g,this.h,4);return a?yf(this.g,this.h+a):lg.HALF}};var og,pg=og||={};pg[pg.YEAR_MONTH=0]="YEAR_MONTH";pg[pg.DAY_TIME=1]="DAY_TIME";pg[pg.MONTH_DAY_NANO=2]="MONTH_DAY_NANO";class qg{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}unit(){const a=L(this.g,this.h,4);return a?yf(this.g,this.h+a):og.YEAR_MONTH}};class rg{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}keysSorted(){const a=L(this.g,this.h,4);return a?!!(this.g.j[this.h+a]<<24>>24):!1}};class sg{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}unit(){const a=L(this.g,this.h,4);return a?yf(this.g,this.h+a):hg.MILLISECOND}bitWidth(){const a=L(this.g,this.h,6);return a?this.g.s(this.h+a):32}};class tg{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}unit(){const a=L(this.g,this.h,4);return a?yf(this.g,this.h+a):hg.SECOND}timezone(a){const b=L(this.g,this.h,6);return b?Af(this.g,this.h+b,a):null}};var ug,vg=ug||={};vg[vg.Sparse=0]="Sparse";vg[vg.Dense=1]="Dense";class wg{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}mode(){const a=L(this.g,this.h,4);return a?yf(this.g,this.h+a):ug.Sparse}typeIds(a){const b=L(this.g,this.h,6);return b?this.g.s(Cf(this.g,this.h+b)+4*a):0}};var P,Q=P||={};Q[Q.NONE=0]="NONE";Q[Q.Null=1]="Null";Q[Q.Int=2]="Int";Q[Q.FloatingPoint=3]="FloatingPoint";Q[Q.Binary=4]="Binary";Q[Q.Utf8=5]="Utf8";Q[Q.Bool=6]="Bool";Q[Q.Decimal=7]="Decimal";Q[Q.Date=8]="Date";Q[Q.Time=9]="Time";Q[Q.Timestamp=10]="Timestamp";Q[Q.Interval=11]="Interval";Q[Q.List=12]="List";Q[Q.Struct_=13]="Struct_";Q[Q.Union=14]="Union";Q[Q.FixedSizeBinary=15]="FixedSizeBinary";Q[Q.FixedSizeList=16]="FixedSizeList";Q[Q.Map=17]="Map";Q[Q.Duration=18]="Duration";
Q[Q.LargeBinary=19]="LargeBinary";Q[Q.LargeUtf8=20]="LargeUtf8";Q[Q.LargeList=21]="LargeList";function xg(a,b){Qf(a,4,b.length,4);for(let c=b.length-1;0<=c;c--)Of(a,b[c]);return Rf(a)}function yg(a,b){Qf(a,4,b.length,4);for(let c=b.length-1;0<=c;c--)Of(a,b[c]);return Rf(a)}function zg(a){const b=L(a.g,a.h,14);return b?Df(a.g,a.h+b):0}
class Ag{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}name(a){const b=L(this.g,this.h,4);return b?Af(this.g,this.h+b,a):null}nullable(){const a=L(this.g,this.h,6);return a?!!(this.g.j[this.h+a]<<24>>24):!1}type(a){const b=L(this.g,this.h,10);return b?zf(this.g,a,this.h+b):null}dictionary(a){const b=L(this.g,this.h,12);return b?(a||new cg).i(Bf(this.g,this.h+b),this.g):null}children(a,b){const c=L(this.g,this.h,14);return c?(b||new Ag).i(Bf(this.g,Cf(this.g,this.h+c)+4*a),
this.g):null}Da(a){const b=L(this.g,this.h,16);return b?(new Uf).i(Bf(this.g,Cf(this.g,this.h+b)+4*a),this.g):null}Ea(){const a=L(this.g,this.h,16);return a?Df(this.g,this.h+a):0}};function Bg(a,b){Qf(a,4,b.length,4);for(let c=b.length-1;0<=c;c--)Of(a,b[c]);return Rf(a)}function Cg(a,b){Qf(a,4,b.length,4);for(let c=b.length-1;0<=c;c--)Of(a,b[c]);return Rf(a)}function Dg(a){const b=L(a.g,a.h,6);return b?Df(a.g,a.h+b):0}
class Eg{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}fields(a,b){const c=L(this.g,this.h,6);return c?(b||new Ag).i(Bf(this.g,Cf(this.g,this.h+c)+4*a),this.g):null}Da(a){const b=L(this.g,this.h,8);return b?(new Uf).i(Bf(this.g,Cf(this.g,this.h+b)+4*a),this.g):null}Ea(){const a=L(this.g,this.h,8);return a?Df(this.g,this.h+a):0}features(a){const b=L(this.g,this.h,10);return b?rf(this.g,Cf(this.g,this.h+b)+8*a):this.g.R(0,0)}};class Fg{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}version(){const a=L(this.g,this.h,4);return a?yf(this.g,this.h+a):Vf.V1}schema(a){const b=L(this.g,this.h,6);return b?(a||new Eg).i(Bf(this.g,this.h+b),this.g):null}dictionaries(a,b){const c=L(this.g,this.h,8);return c?(b||new qf).i(Cf(this.g,this.h+c)+24*a,this.g):null}ab(a){const b=L(this.g,this.h,10);return b?(new qf).i(Cf(this.g,this.h+b)+24*a,this.g):null}Da(a){const b=L(this.g,this.h,12);return b?(new Uf).i(Bf(this.g,
Cf(this.g,this.h+b)+4*a),this.g):null}Ea(){const a=L(this.g,this.h,12);return a?Df(this.g,this.h+a):0}};class R{constructor(a=[],b,c){this.fields=a||[];this.metadata=b||new Map;c||=Gg(a);this.dictionaries=c}get [Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(a=>a.name)}toString(){return`Schema<{ ${this.fields.map((a,b)=>`${b}: ${a}`).join(", ")} }>`}select(a){const b=new Set(a);a=this.fields.filter(c=>b.has(c.name));return new R(a,this.metadata)}selectAt(a){a=a.map(b=>this.fields[b]).filter(Boolean);return new R(a,this.metadata)}assign(...a){var b=a[0]instanceof R?a[0]:Array.isArray(a[0])?
new R(a[0]):new R(a);const c=[...this.fields];a=Hg(Hg(new Map,this.metadata),b.metadata);b=b.fields.filter(e=>{const f=c.findIndex(g=>g.name===e.name);return~f?(c[f]=e.clone({metadata:Hg(Hg(new Map,c[f].metadata),e.metadata)}))&&!1:!0});const d=Gg(b,new Map);return new R([...c,...b],a,new Map([...this.dictionaries,...d]))}}R.prototype.fields=null;R.prototype.metadata=null;R.prototype.dictionaries=null;
class S{constructor(a,b,c=!1,d){this.name=a;this.type=b;this.nullable=c;this.metadata=d||new Map}static new(...a){let [b,c,d,e]=a;a[0]&&"object"===typeof a[0]&&({name:b}=a[0],void 0===c&&(c=a[0].type),void 0===d&&(d=a[0].nullable),void 0===e&&(e=a[0].metadata));return new S(`${b}`,c,d,e)}get typeId(){return this.type.typeId}get [Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...a){let [b,c,d,e]=a;a[0]&&"object"===typeof a[0]?{name:b=this.name,type:c=this.type,
nullable:d=this.nullable,metadata:e=this.metadata}=a[0]:[b=this.name,c=this.type,d=this.nullable,e=this.metadata]=a;return S.new(b,c,d,e)}}S.prototype.type=null;S.prototype.name=null;S.prototype.nullable=null;S.prototype.metadata=null;function Hg(a,b){return new Map([...(a||new Map),...(b||new Map)])}
function Gg(a,b=new Map){for(let c=-1,d=a.length;++c<d;){const e=a[c].type;if(A.isDictionary(e))if(!b.has(e.id))b.set(e.id,e.dictionary);else if(b.get(e.id)!==e.dictionary)throw Error("Cannot create Schema containing two different dictionaries with the same Id");e.children&&0<e.children.length&&Gg(e.children,b)}return b};function*Ig(a){for(let b,c=-1,d=a.numDictionaries;++c<d;)if(b=a.Fa(c))yield b}
class Jg{constructor(a,b=Ca.V4,c,d){this.schema=a;this.version=b;c&&(this.$=c);d&&(this.hb=d)}static decode(a){a=new Ef(q(Uint8Array,a));a=(new Fg).i(a.s(a.position())+a.position(),a);const b=R.decode(a.schema());return new Kg(b,a)}static encode(a){const b=new Tf;var c=R.encode(b,a.schema);Qf(b,24,a.numRecordBatches,8);for(var d of[...a.ab()].slice().reverse())Lg.encode(b,d);d=Rf(b);Qf(b,24,a.numDictionaries,8);for(const e of[...Ig(a)].slice().reverse())Lg.encode(b,e);a=Rf(b);N(b,5);M(b,1,c);Lf(b,
Ca.V4,Vf.V1);M(b,3,d);M(b,2,a);c=O(b);b.finish(c);return Hf(b)}get numRecordBatches(){return this.$.length}get numDictionaries(){return this.hb.length}*ab(){for(let a,b=-1,c=this.numRecordBatches;++b<c;)if(a=this.fa(b))yield a}fa(a){return 0<=a&&a<this.numRecordBatches&&this.$[a]||null}Fa(a){return 0<=a&&a<this.numDictionaries&&this.hb[a]||null}}
class Kg extends Jg{constructor(a,b){super(a,b.version());this.l=b}get numRecordBatches(){var a=this.l;const b=L(a.g,a.h,10);return b?Df(a.g,a.h+b):0}get numDictionaries(){var a=this.l;const b=L(a.g,a.h,8);return b?Df(a.g,a.h+b):0}fa(a){return 0<=a&&a<this.numRecordBatches&&(a=this.l.ab(a))?Lg.decode(a):null}Fa(a){return 0<=a&&a<this.numDictionaries&&(a=this.l.dictionaries(a))?Lg.decode(a):null}}
class Lg{constructor(a,b,c){this.Wa=a;this.offset="number"===typeof c?c:c.low;this.bodyLength="number"===typeof b?b:b.low}static decode(a){return new Lg(a.Wa(),a.bodyLength(),a.offset())}static encode(a,b){var c=new tf(b.offset,0),d=b.Wa;b=new tf(b.bodyLength,0);Ff(a,8,24);a.Y(b);Gf(a,4);a.U(d);a.Y(c);return a.offset()}};const T=Object.freeze({done:!0,value:void 0});class Mg{constructor(a){this.na=a}get schema(){return this.na.schema}get batches(){return this.na.batches||[]}get dictionaries(){return this.na.dictionaries||[]}}function Ng(a){return a.fb||(a.fb=a.toDOMStream())}function Og(a,b,c){return Og(a.lb||(a.lb=a.toNodeStream()),b,c)}class Pg{tee(){return Ng(this).tee()}pipeTo(a,b){return Ng(this).pipeTo(a,b)}pipeThrough(a,b){return Ng(this).pipeThrough(a,b)}}
class Qg extends Pg{constructor(){super();this.v=[];this.ia=[];this.Ja=new Promise(a=>this.K=a)}get closed(){return this.Ja}async cancel(a){await this.return(a)}write(a){if(!this.K)throw Error("AsyncQueue is closed");0>=this.ia.length?this.v.push(a):this.ia.shift().resolve({done:!1,value:a})}abort(a){this.K&&(0>=this.ia.length?this.La={error:a}:this.ia.shift().reject({done:!0,value:a}))}close(){if(this.K){const a=this.ia;for(;0<a.length;)a.shift().resolve(T);this.K();this.K=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(a){return ta(this.K||
this.La?this:this.v,a)}toNodeStream(){return ua()}async throw(a){await this.abort(a);return T}async return(){await this.close();return T}async read(a){return(await this.next(a,"read")).value}async peek(a){return(await this.next(a,"peek")).value}next(){return 0<this.v.length?Promise.resolve({done:!1,value:this.v.shift()}):this.La?Promise.reject({done:!0,value:this.La.error}):this.K?new Promise((a,b)=>{this.ia.push({resolve:a,reject:b})}):Promise.resolve(T)}};class Rg extends Qg{write(a){if(0<(a=q(Uint8Array,a)).byteLength)return super.write(a)}toString(a=!1){return a?aa.decode(this.toUint8Array(!0)):this.toUint8Array(!1).then(ba)}toUint8Array(a=!1){return a?na(this.v)[0]:(async()=>{const b=[];let c=0;for await(const d of this)b.push(d),c+=d.byteLength;return na(b,c)[0]})()}}
class Sg{constructor(a){a&&(this.source=new Tg(va(wa(a))))}[Symbol.iterator](){return this}next(a){return this.source.next(a)}throw(a){return this.source.throw(a)}return(a){return this.source.return(a)}peek(a){return this.source.peek(a)}read(a){return this.source.read(a)}}
class Ug{constructor(a){a instanceof Ug?this.source=a.source:a instanceof Rg?this.source=new Vg(va(xa(a))):ja(a)?this.source=new Vg(va(Ba(a))):ia(a)?this.source=new Vg(va(ya(a))):m(a)&&ia(a.body)?this.source=new Vg(va(ya(a.body))):m(a)&&l(a[Symbol.iterator])?this.source=new Vg(va(wa(a))):m(a)&&l(a.then)?this.source=new Vg(va(xa(a))):m(a)&&l(a[Symbol.asyncIterator])&&(this.source=new Vg(va(xa(a))))}[Symbol.asyncIterator](){return this}next(a){return this.source.next(a)}throw(a){return this.source.throw(a)}return(a){return this.source.return(a)}get closed(){return this.source.closed}cancel(a){return this.source.cancel(a)}peek(a){return this.source.peek(a)}read(a){return this.source.read(a)}}
class Tg{constructor(a){this.source=a}cancel(a){this.return(a)}peek(a){return this.next(a,"peek").value}read(a){return this.next(a,"read").value}next(a,b="read"){return this.source.next({X:b,size:a})}throw(a){return Object.create(this.source.throw&&this.source.throw(a)||T)}return(a){return Object.create(this.source.return&&this.source.return(a)||T)}}
class Vg{constructor(a){this.source=a;this.Ja=new Promise(b=>this.K=b)}async cancel(a){await this.return(a)}get closed(){return this.Ja}async read(a){return(await this.next(a,"read")).value}async peek(a){return(await this.next(a,"peek")).value}async next(a,b="read"){return await this.source.next({X:b,size:a})}async throw(a){a=this.source.throw&&await this.source.throw(a)||T;this.K&&this.K();this.K=void 0;return Object.create(a)}async return(a){a=this.source.return&&await this.source.return(a)||T;
this.K&&this.K();this.K=void 0;return Object.create(a)}};class Wg extends Sg{constructor(a){super();this.position=0;this.buffer=q(Uint8Array,a);this.size=this.buffer.byteLength}s(a){const {buffer:b,byteOffset:c}=this.ga(a,4);return(new DataView(b,c)).getInt32(0,!0)}seek(a){this.position=Math.min(a,this.size);return a<this.size}read(a){const b=this.buffer,c=this.size,d=this.position;return b&&d<c?("number"!==typeof a&&(a=Number.POSITIVE_INFINITY),this.position=Math.min(c,d+Math.min(c-d,a)),b.subarray(d,this.position)):null}ga(a,b){const c=this.buffer,d=
Math.min(this.size,a+b);return c?c.subarray(a,d):new Uint8Array(b)}close(){this.buffer&&(this.buffer=null)}throw(a){this.close();return{done:!0,value:a}}return(a){this.close();return{done:!0,value:a}}}
class Xg extends Ug{constructor(a,b){super();this.position=0;this.I=a;"number"===typeof b?this.size=b:this.C=(async()=>{this.size=(await a.stat()).size;delete this.C})()}async s(a){const {buffer:b,byteOffset:c}=await this.ga(a,4);return(new DataView(b,c)).getInt32(0,!0)}async seek(a){this.C&&await this.C;this.position=Math.min(a,this.size);return a<this.size}async read(a){this.C&&await this.C;const b=this.I;var c=this.size,d=this.position;if(b&&d<c){"number"!==typeof a&&(a=Number.POSITIVE_INFINITY);
let e=0,f=0;a=Math.min(c,d+Math.min(c-d,a));for(c=new Uint8Array(Math.max(0,(this.position=a)-d));(d+=f)<a&&(e+=f)<c.byteLength;)({Sb:f}=await b.read(c,e,c.byteLength-e,d));return c}return null}async ga(a,b){this.C&&await this.C;const c=this.I;var d=this.size;return c&&a+b<d?(d=new Uint8Array(Math.min(d,a+b)-a),(await c.read(d,0,b,a)).buffer):new Uint8Array(b)}async close(){const a=this.I;this.I=null;a&&await a.close()}async throw(a){await this.close();return{done:!0,value:a}}async return(a){await this.close();
return{done:!0,value:a}}};function Yg(a){0>a&&(a=4294967295+a+1);return`0x${a.toString(16)}`}const Zg=[1,10,100,1E3,1E4,1E5,1E6,1E7,1E8];
function $g(a,b){const c=new Uint32Array([a.buffer[1]>>>16,a.buffer[1]&65535,a.buffer[0]>>>16,a.buffer[0]&65535]);b=new Uint32Array([b.buffer[1]>>>16,b.buffer[1]&65535,b.buffer[0]>>>16,b.buffer[0]&65535]);let d=c[3]*b[3];a.buffer[0]=d&65535;let e=d>>>16;d=c[2]*b[3];e+=d;d=c[3]*b[2]>>>0;e+=d;a.buffer[0]+=e<<16;a.buffer[1]=e>>>0<d?65536:0;a.buffer[1]+=e>>>16;a.buffer[1]+=c[1]*b[3]+c[2]*b[2]+c[3]*b[1];a.buffer[1]+=c[0]*b[3]+c[1]*b[2]+c[2]*b[1]+c[3]*b[0]<<16}
function ah(a,b){const c=a.buffer[0]+b.buffer[0]>>>0;a.buffer[1]+=b.buffer[1];c<a.buffer[0]>>>0&&++a.buffer[1];a.buffer[0]=c}class bh{constructor(a){this.buffer=a}high(){return this.buffer[1]}low(){return this.buffer[0]}lessThan(a){return this.buffer[1]<a.buffer[1]||this.buffer[1]===a.buffer[1]&&this.buffer[0]<a.buffer[0]}equals(a){return this.buffer[1]===a.buffer[1]&&this.buffer[0]==a.buffer[0]}greaterThan(a){return a.lessThan(this)}hex(){return`${Yg(this.buffer[1])} ${Yg(this.buffer[0])}`}}
class U extends bh{times(a){$g(this,a);return this}plus(a){ah(this,a);return this}static from(a,b=new Uint32Array(2)){return U.fromString("string"===typeof a?a:a.toString(),b)}static fromNumber(a,b=new Uint32Array(2)){return U.fromString(a.toString(),b)}static fromString(a,b=new Uint32Array(2)){const c=a.length;b=new U(b);for(let d=0;d<c;){const e=8<c-d?8:c-d,f=new U(new Uint32Array([Number.parseInt(a.slice(d,d+e),10),0])),g=new U(new Uint32Array([Zg[e],0]));b.times(g);b.plus(f);d+=e}return b}static convertArray(a){const b=
new Uint32Array(2*a.length);for(let c=-1,d=a.length;++c<d;)U.from(a[c],new Uint32Array(b.buffer,b.byteOffset+8*c,2));return b}static multiply(a,b){return(new U(new Uint32Array(a.buffer))).times(b)}static add(a,b){return(new U(new Uint32Array(a.buffer))).plus(b)}}
class ch extends bh{negate(){this.buffer[0]=~this.buffer[0]+1;this.buffer[1]=~this.buffer[1];0==this.buffer[0]&&++this.buffer[1];return this}times(a){$g(this,a);return this}plus(a){ah(this,a);return this}lessThan(a){const b=this.buffer[1]<<0,c=a.buffer[1]<<0;return b<c||b===c&&this.buffer[0]<a.buffer[0]}static from(a,b=new Uint32Array(2)){return ch.fromString("string"===typeof a?a:a.toString(),b)}static fromNumber(a,b=new Uint32Array(2)){return ch.fromString(a.toString(),b)}static fromString(a,b=
new Uint32Array(2)){const c=a.startsWith("-"),d=a.length;b=new ch(b);for(let e=c?1:0;e<d;){const f=8<d-e?8:d-e,g=new ch(new Uint32Array([Number.parseInt(a.slice(e,e+f),10),0])),k=new ch(new Uint32Array([Zg[f],0]));b.times(k);b.plus(g);e+=f}return c?b.negate():b}static convertArray(a){const b=new Uint32Array(2*a.length);for(let c=-1,d=a.length;++c<d;)ch.from(a[c],new Uint32Array(b.buffer,b.byteOffset+8*c,2));return b}static multiply(a,b){return(new ch(new Uint32Array(a.buffer))).times(b)}static add(a,
b){return(new ch(new Uint32Array(a.buffer))).plus(b)}}
class dh{constructor(a){this.buffer=a}high(){return new ch(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new ch(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){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];0==this.buffer[0]&&++this.buffer[1];0==this.buffer[1]&&++this.buffer[2];0==this.buffer[2]&&++this.buffer[3];return this}times(a){const b=new U(new Uint32Array([this.buffer[3],
0])),c=new U(new Uint32Array([this.buffer[2],0])),d=new U(new Uint32Array([this.buffer[1],0])),e=new U(new Uint32Array([this.buffer[0],0])),f=new U(new Uint32Array([a.buffer[3],0])),g=new U(new Uint32Array([a.buffer[2],0])),k=new U(new Uint32Array([a.buffer[1],0]));a=new U(new Uint32Array([a.buffer[0],0]));let n=U.multiply(e,a);this.buffer[0]=n.low();const p=new U(new Uint32Array([n.high(),0]));n=U.multiply(d,a);p.plus(n);n=U.multiply(e,k);p.plus(n);this.buffer[1]=p.low();this.buffer[3]=p.lessThan(n)?
1:0;this.buffer[2]=p.high();(new U(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))).plus(U.multiply(c,a)).plus(U.multiply(d,k)).plus(U.multiply(e,g));this.buffer[3]+=U.multiply(b,a).plus(U.multiply(c,k)).plus(U.multiply(d,g)).plus(U.multiply(e,f)).low();return this}plus(a){const b=new Uint32Array(4);b[3]=this.buffer[3]+a.buffer[3]>>>0;b[2]=this.buffer[2]+a.buffer[2]>>>0;b[1]=this.buffer[1]+a.buffer[1]>>>0;b[0]=this.buffer[0]+a.buffer[0]>>>0;b[0]<this.buffer[0]>>>0&&++b[1];b[1]<this.buffer[1]>>>
0&&++b[2];b[2]<this.buffer[2]>>>0&&++b[3];this.buffer[3]=b[3];this.buffer[2]=b[2];this.buffer[1]=b[1];this.buffer[0]=b[0];return this}hex(){return`${Yg(this.buffer[3])} ${Yg(this.buffer[2])} ${Yg(this.buffer[1])} ${Yg(this.buffer[0])}`}static multiply(a,b){return(new dh(new Uint32Array(a.buffer))).times(b)}static add(a,b){return(new dh(new Uint32Array(a.buffer))).plus(b)}static from(a,b=new Uint32Array(4)){return dh.fromString("string"===typeof a?a:a.toString(),b)}static fromNumber(a,b=new Uint32Array(4)){return dh.fromString(a.toString(),
b)}static fromString(a,b=new Uint32Array(4)){const c=a.startsWith("-"),d=a.length;b=new dh(b);for(let e=c?1:0;e<d;){const f=8<d-e?8:d-e,g=new dh(new Uint32Array([Number.parseInt(a.slice(e,e+f),10),0,0,0])),k=new dh(new Uint32Array([Zg[f],0,0,0]));b.times(k);b.plus(g);e+=f}return c?b.negate():b}static convertArray(a){const b=new Uint32Array(4*a.length);for(let c=-1,d=a.length;++c<d;)dh.from(a[c],new Uint32Array(b.buffer,b.byteOffset+16*c,4));return b}}var eh={};eh.BaseInt64=bh;eh.Int128=dh;
eh.Int64=ch;eh.Uint64=U;function V(a){return a.M[++a.Mb]}function fh(a){return a.buffers[++a.Lb]}
class gh extends D{constructor(a,b,c,d){super();this.Lb=this.Mb=-1;this.P=a;this.M=b;this.buffers=c;this.dictionaries=d}visit(a){return super.visit(a instanceof S?a.type:a)}visitNull(a,{length:b}=V(this)){return I({type:a,length:b})}visitBool(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),data:this.H(a)})}visitInt(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),data:this.H(a)})}visitFloat(a,{length:b,nullCount:c}=
V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),data:this.H(a)})}visitUtf8(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),valueOffsets:this.ha(a),data:this.H(a)})}visitBinary(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),valueOffsets:this.ha(a),data:this.H(a)})}visitFixedSizeBinary(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),data:this.H(a)})}visitDate(a,
{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),data:this.H(a)})}visitTimestamp(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),data:this.H(a)})}visitTime(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),data:this.H(a)})}visitDecimal(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),data:this.H(a)})}visitList(a,{length:b,
nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),valueOffsets:this.ha(a),child:this.visit(a.children[0])})}visitStruct(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),children:this.visitMany(a.children)})}visitUnion(a){return a.mode===t.Sparse?this.visitSparseUnion(a):this.visitDenseUnion(a)}visitDenseUnion(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),typeIds:this.$a(a),
valueOffsets:this.ha(a),children:this.visitMany(a.children)})}visitSparseUnion(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),typeIds:this.$a(a),children:this.visitMany(a.children)})}visitDictionary(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),data:this.H(a.indices),dictionary:this.dictionaries.get(a.id)})}visitInterval(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,
c),data:this.H(a)})}visitFixedSizeList(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),child:this.visit(a.children[0])})}visitMap(a,{length:b,nullCount:c}=V(this)){return I({type:a,length:b,nullCount:c,nullBitmap:this.B(a,c),valueOffsets:this.ha(a),child:this.visit(a.children[0])})}B(a,b){var c=fh(this);return 0<b&&this.H(a,c)||new Uint8Array(0)}ha(a){return this.H(a)}$a(a){return this.H(a)}H(a,{length:b,offset:c}=fh(this)){return this.P.subarray(c,c+
b)}}
class hh extends gh{constructor(a,b,c,d){super(new Uint8Array(0),b,c,d);this.sources=a}B(a,b){({offset:a}=fh(this));return 0>=b?new Uint8Array(0):xe(this.sources[a])}ha(){var {offset:a}=fh(this);return q(Uint8Array,q(Int32Array,this.sources[a]))}$a(a){var {offset:b}=fh(this);return q(Uint8Array,q(a.ArrayType,this.sources[b]))}H(a,{offset:b}=fh(this)){const c=this.sources;return A.isTimestamp(a)||(A.isInt(a)||A.isTime(a))&&64===a.bitWidth||A.isDate(a)&&a.unit===Ga.MILLISECOND?q(Uint8Array,ch.convertArray(c[b])):A.isDecimal(a)?
q(Uint8Array,dh.convertArray(c[b])):A.isBinary(a)||A.isFixedSizeBinary(a)?ih(c[b]):A.isBool(a)?xe(c[b]):A.isUtf8(a)?ca.encode(c[b].join("")):q(Uint8Array,q(a.ArrayType,c[b].map(d=>+d)))}}function ih(a){a=a.join("");const b=new Uint8Array(a.length/2);for(let c=0;c<a.length;c+=2)b[c>>1]=Number.parseInt(a.slice(c,c+2),16);return b};class jh extends pf{constructor(a){super(a);this.v=new hf(new Uint8Array(0))}get byteLength(){let a=this.L+4*this.length;this.m&&(a+=this.m.byteLength);this.v&&(a+=this.v.byteLength);this.J&&(a+=this.J.byteLength);return a}setValue(a,b){return super.setValue(a,q(Uint8Array,b))}da(a,b){const c=this.m;b=gf(this.v,b).buffer;let d=0;for(const [e,f]of a)void 0===f?c.set(e,0):(a=f.length,b.set(f,d),c.set(e,a),d+=a)}};class kh extends mf{constructor(a){super(a);this.v=new kf}setValue(a,b){this.v.set(a,+b)}};class lh extends nf{}lh.prototype.D=ld;class mh extends lh{}mh.prototype.D=id;class nh extends lh{}nh.prototype.D=jd;class oh extends nf{}oh.prototype.D=wd;class ph extends mf{constructor({type:a,nullValues:b,dictionaryHashFunction:c}){super({type:new Qc(a.dictionary,a.indices,a.id,a.isOrdered)});this.J=null;this.ya=0;this.kb=Object.create(null);this.indices=qh({type:this.type.indices,nullValues:b});this.dictionary=qh({type:this.type.dictionary,nullValues:null});"function"===typeof c&&(this.valueToKey=c)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+
this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(a){return this.indices.isValid(a)}setValid(a,b){const c=this.indices;b=c.setValid(a,b);this.length=c.length;return b}setValue(a,b){const c=this.kb,d=this.valueToKey(b);let e=c[d];void 0===e&&(c[d]=e=this.ya+this.dictionary.append(b).length-1);return this.indices.setValue(a,e)}flush(){var a=
this.type;const b=this.Eb,c=this.dictionary.toVector();a=this.indices.flush().clone(a);a.dictionary=b?b.concat(c):c;this.finished||(this.ya+=c.length);this.Eb=a.dictionary;this.clear();return a}finish(){this.indices.finish();this.dictionary.finish();this.ya=0;this.kb=Object.create(null);return super.finish()}clear(){this.indices.clear();this.dictionary.clear();return super.clear()}valueToKey(a){return"string"===typeof a?a:`${a}`}};class rh extends nf{}rh.prototype.D=kd;class sh extends mf{setValue(a,b){const [c]=this.children;a*=this.stride;for(let d=-1,e=b.length;++d<e;)c.set(a+d,b[d])}addChild(a,b="0"){if(0<this.numChildren)throw Error("FixedSizeListBuilder can only have one child.");const c=this.children.push(a);this.type=new Hc(this.type.listSize,new S(b,a.type,!0));return c}};class th extends nf{setValue(a,b){this.v.set(a,b)}}class uh extends th{setValue(a,b){super.setValue(a,ad(b))}}class vh extends th{}class wh extends th{};class xh extends nf{}xh.prototype.D=Gd;class yh extends xh{}yh.prototype.D=Ed;class zh extends xh{}zh.prototype.D=Fd;class Ah extends nf{setValue(a,b){this.v.set(a,b)}}class Bh extends Ah{}class Ch extends Ah{}class Dh extends Ah{}class Eh extends Ah{}class Fh extends Ah{}class Gh extends Ah{}class Hh extends Ah{}class Ih extends Ah{};class Jh extends pf{constructor(a){super(a);this.m=new lf}addChild(a,b="0"){if(0<this.numChildren)throw Error("ListBuilder can only have one child.");this.children[this.numChildren]=a;this.type=new qc(new S(b,a.type,!0));return this.numChildren-1}da(a){const b=this.m,[c]=this.children;for(const [d,e]of a)if("undefined"===typeof e)b.set(d,0);else{a=e.length;const f=b.set(d,a).buffer[d];for(let g=-1;++g<a;)c.set(f+g,e[g])}}};class Kh extends pf{set(a,b){return super.set(a,b)}setValue(a,b){b=b instanceof Map?b:new Map(Object.entries(b));const c=this.C||(this.C=new Map),d=c.get(a);d&&(this.L-=d.size);this.L+=b.size;c.set(a,b)}addChild(a,b=`${this.numChildren}`){if(0<this.numChildren)throw Error("ListBuilder can only have one child.");this.children[this.numChildren]=a;this.type=new Lc(new S(b,a.type,!0),this.type.keysSorted);return this.numChildren-1}da(a){const b=this.m,[c]=this.children;for(const [d,e]of a)if(void 0===
e)b.set(d,0);else{let {[d]:f,[d+1]:g}=b.set(d,e.size).buffer;for(const k of e.entries())if(c.set(f,k),++f>=g)break}}};class Lh extends mf{setValue(){}setValid(a,b){this.length=Math.max(a+1,this.length);return b}};class Mh extends mf{setValue(a,b){const c=this.children,d=this.type;switch(Array.isArray(b)||b.constructor){case !0:return d.children.forEach((e,f)=>c[f].set(a,b[f]));case Map:return d.children.forEach((e,f)=>c[f].set(a,b.get(e.name)));default:return d.children.forEach((e,f)=>c[f].set(a,b[e.name]))}}setValid(a,b){super.setValid(a,b)||this.children.forEach(c=>c.setValid(a,b));return b}addChild(a,b=`${this.numChildren}`){const c=this.children.push(a);this.type=new C([...this.type.children,new S(b,a.type,
!0)]);return c}};class Nh extends nf{}Nh.prototype.D=qd;class Oh extends Nh{}Oh.prototype.D=md;class Ph extends Nh{}Ph.prototype.D=nd;class Qh extends Nh{}Qh.prototype.D=od;class Rh extends Nh{}Rh.prototype.D=pd;class Sh extends nf{}Sh.prototype.D=vd;class Th extends Sh{}Th.prototype.D=rd;class Uh extends Sh{}Uh.prototype.D=sd;class Vh extends Sh{}Vh.prototype.D=td;class Wh extends Sh{}Wh.prototype.D=ud;class Xh extends mf{constructor(a){super(a);this.W=new jf(new Int8Array(0),1);"function"===typeof a.valueToChildTypeId&&(this.mb=a.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(a,b){return this.set(this.length,a,b)}set(a,b,c){void 0===c&&(c=this.mb(this,b,a));this.setValid(a,this.isValid(b))&&this.setValue(a,b,c);return this}setValue(a,b,c){this.W.set(a,c);this.children[this.type.typeIdToChildIndex[c]]?.set(a,b)}addChild(a,b=`${this.children.length}`){const c=
this.children.push(a),{type:{children:d,mode:e,typeIds:f}}=this;a=[...d,new S(b,a.type)];this.type=new xc(e,[...f,c],a);return c}mb(){throw Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.");}}class Yh extends Xh{}
class Zh extends Xh{constructor(a){super(a);this.m=new jf(new Int32Array(0))}setValue(a,b,c){c=this.W.set(a,c).buffer[a];c=this.getChildAt(this.type.typeIdToChildIndex[c]);a=this.m.set(a,c.length).buffer[a];c?.set(a,b)}};class $h extends pf{constructor(a){super(a);this.v=new hf(new Uint8Array(0))}get byteLength(){let a=this.L+4*this.length;this.m&&(a+=this.m.byteLength);this.v&&(a+=this.v.byteLength);this.J&&(a+=this.J.byteLength);return a}setValue(a,b){return super.setValue(a,ca.encode(b))}da(){}}$h.prototype.da=jh.prototype.da;class ai extends D{visitNull(){return Lh}visitBool(){return kh}visitInt(){return Ah}visitInt8(){return Bh}visitInt16(){return Ch}visitInt32(){return Dh}visitInt64(){return Eh}visitUint8(){return Fh}visitUint16(){return Gh}visitUint32(){return Hh}visitUint64(){return Ih}visitFloat(){return th}visitFloat16(){return uh}visitFloat32(){return vh}visitFloat64(){return wh}visitUtf8(){return $h}visitBinary(){return jh}visitFixedSizeBinary(){return rh}visitDate(){return lh}visitDateDay(){return mh}visitDateMillisecond(){return nh}visitTimestamp(){return Nh}visitTimestampSecond(){return Oh}visitTimestampMillisecond(){return Ph}visitTimestampMicrosecond(){return Qh}visitTimestampNanosecond(){return Rh}visitTime(){return Sh}visitTimeSecond(){return Th}visitTimeMillisecond(){return Uh}visitTimeMicrosecond(){return Vh}visitTimeNanosecond(){return Wh}visitDecimal(){return oh}visitList(){return Jh}visitStruct(){return Mh}visitUnion(){return Xh}visitDenseUnion(){return Zh}visitSparseUnion(){return Yh}visitDictionary(){return ph}visitInterval(){return xh}visitIntervalDayTime(){return yh}visitIntervalYearMonth(){return zh}visitFixedSizeList(){return sh}visitMap(){return Kh}}
const bi=new ai;function ci(a,b,c){return b===c||Array.isArray(b)&&Array.isArray(c)&&b.length===c.length&&b.every((d,e)=>a.compareFields(d,c[e]))}class di extends D{compareSchemas(a,b){return a===b||b instanceof a.constructor&&ci(this,a.fields,b.fields)}compareFields(a,b){return a===b||b instanceof a.constructor&&a.name===b.name&&a.nullable===b.nullable&&this.visit(a.type,b.type)}}function ei(a,b){return b instanceof a.constructor}function fi(a,b){return a===b||ei(a,b)}
function gi(a,b){return a===b||ei(a,b)&&a.bitWidth===b.bitWidth&&a.isSigned===b.isSigned}function hi(a,b){return a===b||ei(a,b)&&a.precision===b.precision}function ii(a,b){return a===b||ei(a,b)&&a.unit===b.unit}function ji(a,b){return a===b||ei(a,b)&&a.unit===b.unit&&a.timezone===b.timezone}function ki(a,b){return a===b||ei(a,b)&&a.unit===b.unit&&a.bitWidth===b.bitWidth}
function li(a,b){return a===b||ei(a,b)&&a.mode===b.mode&&a.typeIds.every((c,d)=>c===b.typeIds[d])&&ci(mi,a.children,b.children)}function ni(a,b){return a===b||ei(a,b)&&a.unit===b.unit}h=di.prototype;h.visitNull=fi;h.visitBool=fi;h.visitInt=gi;h.visitInt8=gi;h.visitInt16=gi;h.visitInt32=gi;h.visitInt64=gi;h.visitUint8=gi;h.visitUint16=gi;h.visitUint32=gi;h.visitUint64=gi;h.visitFloat=hi;h.visitFloat16=hi;h.visitFloat32=hi;h.visitFloat64=hi;h.visitUtf8=fi;h.visitBinary=fi;
h.visitFixedSizeBinary=function(a,b){return a===b||ei(a,b)&&a.byteWidth===b.byteWidth};h.visitDate=ii;h.visitDateDay=ii;h.visitDateMillisecond=ii;h.visitTimestamp=ji;h.visitTimestampSecond=ji;h.visitTimestampMillisecond=ji;h.visitTimestampMicrosecond=ji;h.visitTimestampNanosecond=ji;h.visitTime=ki;h.visitTimeSecond=ki;h.visitTimeMillisecond=ki;h.visitTimeMicrosecond=ki;h.visitTimeNanosecond=ki;h.visitDecimal=fi;
h.visitList=function(a,b){return a===b||ei(a,b)&&a.children.length===b.children.length&&ci(mi,a.children,b.children)};h.visitStruct=function(a,b){return a===b||ei(a,b)&&a.children.length===b.children.length&&ci(mi,a.children,b.children)};h.visitUnion=li;h.visitDenseUnion=li;h.visitSparseUnion=li;h.visitDictionary=function(a,b){return a===b||ei(a,b)&&a.id===b.id&&a.isOrdered===b.isOrdered&&mi.visit(a.indices,b.indices)&&mi.visit(a.dictionary,b.dictionary)};h.visitInterval=ni;
h.visitIntervalDayTime=ni;h.visitIntervalYearMonth=ni;h.visitFixedSizeList=function(a,b){return a===b||ei(a,b)&&a.listSize===b.listSize&&a.children.length===b.children.length&&ci(mi,a.children,b.children)};h.visitMap=function(a,b){return a===b||ei(a,b)&&a.keysSorted===b.keysSorted&&a.children.length===b.children.length&&ci(mi,a.children,b.children)};const mi=new di;function oi(a,b){return mi.compareSchemas(a,b)}function pi(a,b){return mi.visit(a,b)};function qh(a){var b=a.type;const c=new (bi.getVisitFn(b)())(a);if(b.children&&0<b.children.length){const d=a.children||[],e={nullValues:a.nullValues};a=Array.isArray(d)?(f,g)=>d[g]||e:({name:f})=>d[f]||e;for(const [f,g]of b.children.entries()){b=g.type;const k=a(g,f);c.children.push(qh({...k,type:b}))}}return c}
function qi(a,b){if(a instanceof H||a instanceof F||a.type instanceof A||ArrayBuffer.isView(a))return bf(a);b={type:b??ri(a),nullValues:[null]};a=[...si(b)(a)];a=1===a.length?a[0]:a.reduce((c,d)=>c.concat(d));return A.isDictionary(a.type)?a.memoize():a}
function ri(a){if(0===a.length)return new db;var b=0;let c=0,d=0,e=0,f=0,g=0,k=0,n=0;for(const p of a)if(null==p)++b;else{switch(typeof p){case "bigint":++g;continue;case "boolean":++k;continue;case "number":++e;continue;case "string":++f;continue;case "object":Array.isArray(p)?++c:"[object Date]"===Object.prototype.toString.call(p)?++n:++d;continue}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected");}if(e+b===a.length)return new wb;if(f+b===a.length)return new Qc(new Db,
new jb);if(g+b===a.length)return new kb;if(k+b===a.length)return new Hb;if(n+b===a.length)return new Ub;if(c+b===a.length){const p=ri(a[a.findIndex(x=>null!=x)]);if(a.every(x=>null==x||pi(p,ri(x))))return new qc(new S("",p,!0))}else if(d+b===a.length){b=new Map;for(const p of a)for(const x of Object.keys(p))b.has(x)||null==p[x]||b.set(x,new S(x,ri([p[x]]),!0));return new C([...b.values()])}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected");}
function si(a){const {queueingStrategy:b="count"}=a,{highWaterMark:c="bytes"!==b?Number.POSITIVE_INFINITY:16384}=a,d="bytes"!==b?"length":"byteLength";return function*(e){let f=0;const g=qh(a);for(const k of e)g.append(k)[d]>=c&&++f&&(yield g.toVector());if(0<g.finish().length||0===f)yield g.toVector()}};function ti(a,b){return ui(a,b.map(c=>c.data.concat()))}function ui(a,b){const c=[...a.fields],d=[],e={Xa:b.reduce((Ua,mb)=>Math.max(Ua,mb.length),0)};let f=0,g=0,k=-1;const n=b.length;let p,x=[];for(;0<e.Xa--;){g=Number.POSITIVE_INFINITY;for(k=-1;++k<n;)x[k]=p=b[k].shift(),g=Math.min(g,p?p.length:g);Number.isFinite(g)&&(x=vi(c,g,x,b,e),0<g&&(d[f++]=I({type:new C(c),length:g,nullCount:0,children:x.slice()})))}return[a=a.assign(c),d.map(Ua=>new W(a,Ua))]}
function vi(a,b,c,d,e){const f=(b+63&-64)>>3;for(let k=-1,n=d.length;++k<n;){const p=c[k];var g=p?.length;g>=b?g===b?c[k]=p:(c[k]=p.slice(0,b),e.Xa=Math.max(e.Xa,d[k].unshift(p.slice(b,g-b)))):(g=a[k],a[k]=g.clone({nullable:!0}),c[k]=p?.xa(b)??I({type:g.type,length:b,nullCount:b,nullBitmap:new Uint8Array(f)}))}return c};class X{constructor(...a){if(0===a.length)return this.batches=[],this.schema=new R([]),this.m=[0],this;let b,c;a[0]instanceof R&&(b=a.shift());a[a.length-1]instanceof Uint32Array&&(c=a.pop());const d=e=>{if(e){if(e instanceof W)return[e];if(e instanceof X)return e.batches;if(e instanceof H){if(e.type instanceof C)return[new W(new R(e.type.children),e)]}else{if(Array.isArray(e))return e.flatMap(g=>d(g));if("function"===typeof e[Symbol.iterator])return[...e].flatMap(g=>d(g));if("object"===typeof e){var f=
Object.keys(e);const g=f.map(k=>new F([e[k]]));f=new R(f.map((k,n)=>new S(String(k),g[n].type)));[,f]=ti(f,g);return 0===f.length?[new W(e)]:f}}}return[]};a=a.flatMap(e=>d(e));b=b??a[0]?.schema??new R([]);if(!(b instanceof R))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(const e of a){if(!(e instanceof W))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!oi(b,e.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.");
}this.schema=b;this.batches=a;this.m=c??He(this.data)}get data(){return this.batches.map(({data:a})=>a)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((a,b)=>a+b.length,0)}get nullCount(){-1===this.F&&(this.F=Ge(this.data));return this.F}isValid(){return!1}get(){return null}set(){}indexOf(){return-1}getByteLength(){return 0}[Symbol.iterator](){return 0<this.batches.length?Te.visit(new F(this.data)):[][Symbol.iterator]()}toArray(){return[...this]}toString(){return`[\n ${this.toArray().join(",\n ")}\n]`}concat(...a){const b=
this.schema;a=this.data.concat(a.flatMap(({data:c})=>c));return new X(b,a.map(c=>new W(b,c)))}slice(a,b){const c=this.schema;[a,b]=ke({length:this.numRows},a,b);a=Ie(this.data,this.m,a,b);return new X(c,a.map(d=>new W(c,d)))}getChild(a){return this.getChildAt(this.schema.fields.findIndex(b=>b.name===a))}getChildAt(a){if(-1<a&&a<this.schema.fields.length){const c=this.data.map(d=>d.children[a]);if(0===c.length){var {type:b}=this.schema.fields[a];b=I({type:b,length:0,nullCount:0});c.push(b.xa(this.numRows))}return new F(c)}return null}setChild(a,
b){return this.setChildAt(this.schema.fields?.findIndex(c=>c.name===a),b)}setChildAt(a,b){let c=this.schema;var d=[...this.batches];if(-1<a&&a<this.numCols){b||=new F([I({type:new db,length:this.numRows})]);d=c.fields.slice();const e=d[a].clone({type:b.type}),f=this.schema.fields.map((g,k)=>this.getChildAt(k));[d[a],f[a]]=[e,b];[c,d]=ti(c,f)}return new X(c,d)}select(a){const b=this.schema.fields.reduce((c,d,e)=>c.set(d.name,e),new Map);return this.selectAt(a.map(c=>b.get(c)).filter(c=>-1<c))}selectAt(a){const b=
this.schema.selectAt(a),c=this.batches.map(d=>d.selectAt(a));return new X(b,c)}assign(a){const b=this.schema.fields,[c,d]=a.schema.fields.reduce((g,k,n)=>{const [p,x]=g,Ua=b.findIndex(mb=>mb.name===k.name);~Ua?x[Ua]=n:p.push(n);return g},[[],[]]),e=this.schema.assign(a.schema),f=[...b.map((g,k)=>[k,d[k]]).map(([g,k])=>void 0===k?this.getChildAt(g):a.getChildAt(k)),...c.map(g=>a.getChildAt(g))].filter(Boolean);return new X(...ti(e,f))}}var wi=Symbol.toStringTag,Ai=X.prototype;Ai.schema=null;
Ai.batches=[];Ai.m=new Uint32Array([0]);Ai.F=-1;Ai[Symbol.isConcatSpreadable]=!0;Ai.isValid=Le(Ke);Ai.get=Le(Ld.getVisitFn(y.Struct));Ai.set=Me(Bd.getVisitFn(y.Struct));Ai.indexOf=Ne(Qe.getVisitFn(y.Struct));Ai.getByteLength=Le(We.getVisitFn(y.Struct));X[wi]="Table";class W{constructor(...a){switch(a.length){case 2:[this.schema]=a;if(!(this.schema instanceof R))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[,this.data=I({nullCount:0,type:new C(this.schema.fields),children:this.schema.fields.map(g=>I({type:g.type,nullCount:0}))})]=a;if(!(this.data instanceof H))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Bi(this.schema,this.data.children);break;case 1:const [b]=a,{fields:c,
children:d,length:e}=Object.keys(b).reduce((g,k,n)=>{g.children[n]=b[k];g.length=Math.max(g.length,b[k].length);g.fields[n]=S.new({name:k,type:b[k].type,nullable:!0});return g},{length:0,fields:[],children:[]});a=new R(c);const f=I({type:new C(c),length:e,children:d,nullCount:0});[this.schema,this.data]=Bi(a,f.children,e);break;default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.");}}get dictionaries(){return this.ba||(this.ba=
Ci(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(a){return this.data.getValid(a)}get(a){return Ld.visit(this.data,a)}set(a,b){return Bd.visit(this.data,a,b)}indexOf(a,b){return Qe.visit(this.data,a,b)}getByteLength(a){return We.visit(this.data,a)}[Symbol.iterator](){return Te.visit(new F([this.data]))}toArray(){return[...this]}concat(...a){return new X(this.schema,[this,
...a])}slice(a,b){[a]=(new F([this.data])).slice(a,b).data;return new W(this.schema,a)}getChild(a){return this.getChildAt(this.schema.fields?.findIndex(b=>b.name===a))}getChildAt(a){return-1<a&&a<this.schema.fields.length?new F([this.data.children[a]]):null}setChild(a,b){return this.setChildAt(this.schema.fields?.findIndex(c=>c.name===a),b)}setChildAt(a,b){var c=this.schema,d=this.data;if(-1<a&&a<this.numCols){b||=new F([I({type:new db,length:this.numRows})]);const e=c.fields.slice();d=d.children.slice();
c=e[a].clone({type:b.type});[e[a],d[a]]=[c,b.data[0]];c=new R(e,new Map(this.schema.metadata));d=I({type:new C(e),children:d})}return new W(c,d)}select(a){const b=this.schema.select(a),c=new C(b.fields),d=[];for(const e of a)a=this.schema.fields.findIndex(f=>f.name===e),~a&&(d[a]=this.data.children[a]);return new W(b,I({type:c,length:this.numRows,children:d}))}selectAt(a){const b=this.schema.selectAt(a);a=a.map(c=>this.data.children[c]).filter(Boolean);a=I({type:new C(b.fields),length:this.numRows,
children:a});return new W(b,a)}}var Di=Symbol.toStringTag,Ei=W.prototype;Ei.F=-1;Ei[Symbol.isConcatSpreadable]=!0;W[Di]="RecordBatch";function Bi(a,b,c=b.reduce((d,e)=>Math.max(d,e.length),0)){const d=[...a.fields],e=[...b],f=(c+63&-64)>>3;for(const [g,k]of a.fields.entries()){const n=b[g];n&&n.length===c||(d[g]=k.clone({nullable:!0}),e[g]=n?.xa(c)??I({type:k.type,length:c,nullCount:c,nullBitmap:new Uint8Array(f)}))}return[a.assign(d),I({type:new C(d),length:c,children:e})]}
function Ci(a,b,c=new Map){for(let d=-1,e=a.length;++d<e;){const f=a[d].type,g=b[d];if(A.isDictionary(f))if(!c.has(f.id))g.dictionary&&c.set(f.id,g.dictionary);else if(c.get(f.id)!==g.dictionary)throw Error("Cannot create Schema containing two different dictionaries with the same Id");f.children&&0<f.children.length&&Ci(f.children,g.children,c)}return c}class Fi extends W{constructor(a){var b=a.fields.map(c=>I({type:c.type}));b=I({type:new C(a.fields),nullCount:0,children:b});super(a,b)}};var Gi,Hi=Gi||={};Hi[Hi.BUFFER=0]="BUFFER";var Ii,Ji=Ii||={};Ji[Ji.LZ4_FRAME=0]="LZ4_FRAME";Ji[Ji.ZSTD=1]="ZSTD";class Ki{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}method(){const a=L(this.g,this.h,6);return a?this.g.j[this.h+a]<<24>>24:Gi.Qb}};class Li{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}offset(){return rf(this.g,this.h)}length(){return rf(this.g,this.h+8)}};class Mi{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}length(){return rf(this.g,this.h)}nullCount(){return rf(this.g,this.h+8)}};function Ni(a){const b=L(a.g,a.h,6);return b?Df(a.g,a.h+b):0}function Oi(a){const b=L(a.g,a.h,8);return b?Df(a.g,a.h+b):0}class Pi{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}length(){const a=L(this.g,this.h,4);return a?rf(this.g,this.h+a):this.g.R(0,0)}M(a,b){const c=L(this.g,this.h,6);return c?(b||new Mi).i(Cf(this.g,this.h+c)+16*a,this.g):null}buffers(a,b){const c=L(this.g,this.h,8);return c?(b||new Li).i(Cf(this.g,this.h+c)+16*a,this.g):null}};class Qi{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}id(){const a=L(this.g,this.h,4);return a?rf(this.g,this.h+a):this.g.R(0,0)}data(a){const b=L(this.g,this.h,6);return b?(a||new Pi).i(Bf(this.g,this.h+b),this.g):null}Ga(){const a=L(this.g,this.h,8);return a?!!(this.g.j[this.h+a]<<24>>24):!1}};var Ri,Si=Ri||={};Si[Si.Row=0]="Row";Si[Si.Column=1]="Column";var Ti,Ui=Ti||={};Ui[Ui.NONE=0]="NONE";Ui[Ui.SparseTensorIndexCOO=1]="SparseTensorIndexCOO";Ui[Ui.SparseMatrixIndexCSX=2]="SparseMatrixIndexCSX";Ui[Ui.SparseTensorIndexCSF=3]="SparseTensorIndexCSF";var Vi,Wi=Vi||={};Wi[Wi.NONE=0]="NONE";Wi[Wi.Schema=1]="Schema";Wi[Wi.DictionaryBatch=2]="DictionaryBatch";Wi[Wi.RecordBatch=3]="RecordBatch";Wi[Wi.Tensor=4]="Tensor";Wi[Wi.SparseTensor=5]="SparseTensor";class Xi{constructor(){this.g=null;this.h=0}i(a,b){this.h=a;this.g=b;return this}version(){const a=L(this.g,this.h,4);return a?yf(this.g,this.h+a):Vf.V1}headerType(){const a=L(this.g,this.h,6);return a?this.g.j[this.h+a]:Vi.NONE}header(a){const b=L(this.g,this.h,8);return b?zf(this.g,a,this.h+b):null}bodyLength(){const a=L(this.g,this.h,10);return a?rf(this.g,this.h+a):this.g.R(0,0)}Da(a){const b=L(this.g,this.h,12);return b?(new Uf).i(Bf(this.g,Cf(this.g,this.h+b)+4*a),this.g):null}Ea(){const a=
L(this.g,this.h,12);return a?Df(this.g,this.h+a):0}};class Yi extends D{visit(a,b){return null==a||null==b?void 0:super.visit(a,b)}visitNull(a,b){N(b,0);return O(b)}visitInt(a,b){N(b,2);Mf(b,0,a.bitWidth,0);Kf(b,1,+a.isSigned,0);return O(b)}visitFloat(a,b){N(b,1);Lf(b,a.precision,lg.HALF);return O(b)}visitBinary(a,b){N(b,0);return O(b)}visitBool(a,b){N(b,0);return O(b)}visitUtf8(a,b){N(b,0);return O(b)}visitDecimal(a,b){N(b,3);Mf(b,1,a.scale,0);Mf(b,0,a.precision,0);Mf(b,2,a.bitWidth,128);return O(b)}visitDate(a,b){N(b,1);Lf(b,a.unit,dg.MILLISECOND);
return O(b)}visitTime(a,b){N(b,2);Lf(b,a.unit,hg.MILLISECOND);Mf(b,1,a.bitWidth,32);return O(b)}visitTimestamp(a,b){const c=a.timezone&&Sf(b,a.timezone)||void 0;N(b,2);Lf(b,a.unit,hg.SECOND);void 0!==c&&M(b,1,c);return O(b)}visitInterval(a,b){N(b,1);Lf(b,a.unit,og.YEAR_MONTH);return O(b)}visitList(a,b){N(b,0);return O(b)}visitStruct(a,b){N(b,0);return O(b)}visitUnion(a,b){Qf(b,4,a.typeIds.length,4);var c=a.typeIds;Qf(b,4,c.length,4);for(let d=c.length-1;0<=d;d--)Jf(b,c[d]);c=Rf(b);N(b,2);Lf(b,a.mode,
ug.Sparse);M(b,1,c);return O(b)}visitDictionary(a,b){const c=this.visit(a.indices,b);N(b,4);Nf(b,0,new tf(a.id,0),b.R(0,0));Kf(b,2,+a.isOrdered,0);void 0!==c&&M(b,1,c);return O(b)}visitFixedSizeBinary(a,b){N(b,1);Mf(b,0,a.byteWidth,0);return O(b)}visitFixedSizeList(a,b){N(b,1);Mf(b,0,a.listSize,0);return O(b)}visitMap(a,b){N(b,1);Kf(b,0,+a.keysSorted,0);return O(b)}}const Zi=new Yi;function $i(a){return new aj(a.count,bj(a.columns),cj(a.columns))}function dj(a,b){return(a.fields||[]).filter(Boolean).map(c=>S.fromJSON(c,b))}function ej(a,b){return(a.children||[]).filter(Boolean).map(c=>S.fromJSON(c,b))}function bj(a){return(a||[]).reduce((b,c)=>[...b,new fj(c.count,gj(c.VALIDITY)),...bj(c.children)],[])}
function cj(a,b=[]){for(let c=-1,d=(a||[]).length;++c<d;){const e=a[c];e.VALIDITY&&b.push(new hj(b.length,e.VALIDITY.length));e.TYPE&&b.push(new hj(b.length,e.TYPE.length));e.OFFSET&&b.push(new hj(b.length,e.OFFSET.length));e.DATA&&b.push(new hj(b.length,e.DATA.length));b=cj(e.children,b)}return b}function gj(a){return(a||[]).reduce((b,c)=>b+ +(0===c),0)}function ij(a){return new B(a.isSigned,a.bitWidth)}
function jj(a,b){const c=a.type.name;switch(c){case "NONE":return new db;case "null":return new db;case "binary":return new xb;case "utf8":return new Db;case "bool":return new Hb;case "list":return new qc((b||[])[0]);case "struct":return new C(b||[]);case "struct_":return new C(b||[])}switch(c){case "int":return b=a.type,new B(b.isSigned,b.bitWidth);case "floatingpoint":return new qb(u[a.type.precision]);case "decimal":return b=a.type,new Lb(b.scale,b.precision,b.bitWidth);case "date":return new Pb(Ga[a.type.unit]);
case "time":return b=a.type,new Vb(v[b.unit],b.bitWidth);case "timestamp":return b=a.type,new cc(v[b.unit],b.timezone);case "interval":return new kc(Ja[a.type.unit]);case "union":return a=a.type,new xc(t[a.mode],a.typeIds||[],b||[]);case "fixedsizebinary":return new Dc(a.type.byteWidth);case "fixedsizelist":return new Hc(a.type.listSize,(b||[])[0]);case "map":return new Lc((b||[])[0],a.type.keysSorted)}throw Error(`Unrecognized type: "${c}"`);};class kj{constructor(a,b,c,d){this.Kb=b;this.Gb=c;this.body=new Uint8Array(0);d&&(this.Ka=()=>d);this.Bb="number"===typeof a?a:a.low}static fromJSON(a,b){const c=new kj(0,Ca.V4,b);c.Ka=lj(a,b);return c}static decode(a){a=new Ef(q(Uint8Array,a));a=(new Xi).i(a.s(a.position())+a.position(),a);var b=a.bodyLength();const c=a.version(),d=a.headerType();b=new kj(b,c,d);b.Ka=mj(a,d);return b}static encode(a){const b=new Tf;let c=-1;a.isSchema()?c=R.encode(b,a.header()):a.isRecordBatch()?c=aj.encode(b,a.header()):
a.isDictionaryBatch()&&(c=nj.encode(b,a.header()));N(b,5);Lf(b,Ca.V4,Vf.V1);M(b,2,c);Kf(b,1,a.headerType,Vi.NONE);Nf(b,3,new tf(a.bodyLength,0),b.R(0,0));a=O(b);b.finish(a);return Hf(b)}static from(a,b=0){if(a instanceof R)return new kj(0,Ca.V4,w.Schema,a);if(a instanceof aj)return new kj(b,Ca.V4,w.RecordBatch,a);if(a instanceof nj)return new kj(b,Ca.V4,w.DictionaryBatch,a);throw Error(`Unrecognized Message header: ${a}`);}get type(){return this.headerType}get version(){return this.Kb}get headerType(){return this.Gb}get bodyLength(){return this.Bb}header(){return this.Ka()}isSchema(){return this.headerType===
w.Schema}isRecordBatch(){return this.headerType===w.RecordBatch}isDictionaryBatch(){return this.headerType===w.DictionaryBatch}}class aj{constructor(a,b,c){this.Na=b;this.Ia=c;this.Jb="number"===typeof a?a:a.low}get M(){return this.Na}get length(){return this.Jb}get buffers(){return this.Ia}}
class nj{constructor(a,b,c=!1){this.Db=a;this.Ib=c;this.Hb="number"===typeof b?b:b.low}get id(){return this.Hb}get data(){return this.Db}get Ga(){return this.Ib}get length(){return this.data.length}get M(){return this.data.M}get buffers(){return this.data.buffers}}class hj{constructor(a,b){this.offset="number"===typeof a?a:a.low;this.length="number"===typeof b?b:b.low}}class fj{constructor(a,b){this.length="number"===typeof a?a:a.low;this.nullCount="number"===typeof b?b:b.low}}
function lj(a,b){return()=>{switch(b){case w.Schema:return R.fromJSON(a);case w.RecordBatch:return aj.fromJSON(a);case w.DictionaryBatch:return nj.fromJSON(a)}throw Error(`Unrecognized Message type: { name: ${w[b]}, type: ${b} }`);}}
function mj(a,b){return()=>{switch(b){case w.Schema:return R.decode(a.header(new Eg));case w.RecordBatch:return aj.decode(a.header(new Pi),a.version());case w.DictionaryBatch:return nj.decode(a.header(new Qi),a.version())}throw Error(`Unrecognized Message type: { name: ${w[b]}, type: ${b} }`);}}S.encode=oj;S.decode=pj;
S.fromJSON=function(a,b){var c;let d,e;b&&(e=a.dictionary)?(b.has(c=e.id)?(d=(d=e.indexType)?ij(d):new jb,c=new Qc(b.get(c),d,c,e.isOrdered)):(d=(d=e.indexType)?ij(d):new jb,b.set(c,b=jj(a,ej(a,b))),c=new Qc(b,d,c,e.isOrdered)),a=new S(a.name,c,a.nullable,new Map(Object.entries(a.customMetadata||{})))):(b=jj(a,ej(a,b)),a=new S(a.name,b,a.nullable,new Map(Object.entries(a.customMetadata||{}))));return a||null};R.encode=qj;R.decode=rj;
R.fromJSON=function(a,b=new Map){return new R(dj(a,b),new Map(Object.entries(a.customMetadata||{})),b)};aj.encode=sj;aj.decode=tj;aj.fromJSON=$i;nj.encode=uj;nj.decode=vj;nj.fromJSON=function(a){return new nj($i(a.data),a.id,a.isDelta)};fj.encode=wj;fj.decode=xj;hj.encode=yj;hj.decode=zj;function rj(a,b=new Map){const c=[];for(let d,e=-1,f=-1,g=Dg(a);++e<g;)if(d=a.fields(e))c[++f]=S.decode(d,b);return new R(c,Aj(a),b)}
function tj(a,b=Ca.V4){var c=L(a.g,a.h,10);if(null!==(c?(new Ki).i(Bf(a.g,a.h+c),a.g):null))throw Error("Record batch compression not implemented");c=a.length();const d=[];for(let f,g=-1,k=-1,n=Ni(a);++g<n;)if(f=a.M(g))d[++k]=fj.decode(f);const e=[];for(let f,g=-1,k=-1,n=Oi(a);++g<n;)if(f=a.buffers(g))b<Ca.V4&&(f.h+=8*(g+1)),e[++k]=hj.decode(f);return new aj(c,d,e)}function vj(a,b=Ca.V4){return new nj(aj.decode(a.data(),b),a.id(),a.Ga())}function zj(a){return new hj(a.offset(),a.length())}
function xj(a){return new fj(a.length(),a.nullCount())}function Bj(a,b){const c=[];for(let d,e=-1,f=-1,g=zg(a);++e<g;)if(d=a.children(e))c[++f]=S.decode(d,b);return c}function pj(a,b){var c;let d,e;b&&(e=a.dictionary())?(b.has(c=e.id().low)?(d=(d=bg(e))?Cj(d):new jb,c=new Qc(b.get(c),d,c,e.isOrdered())):(d=(d=bg(e))?Cj(d):new jb,b.set(c,b=Dj(a,Bj(a,b))),c=new Qc(b,d,c,e.isOrdered())),a=new S(a.name(),c,a.nullable(),Aj(a))):(b=Dj(a,Bj(a,b)),a=new S(a.name(),b,a.nullable(),Aj(a)));return a||null}
function Aj(a){const b=new Map;if(a)for(let c,d,e=-1,f=Math.trunc(a.Ea());++e<f;)(c=a.Da(e))&&null!=(d=c.key())&&b.set(d,c.value());return b}function Cj(a){return new B(a.isSigned(),a.bitWidth())}
function Dj(a,b){var c=(c=L(a.g,a.h,8))?a.g.j[a.h+c]:P.NONE;switch(c){case P.NONE:return new db;case P.Null:return new db;case P.Binary:return new xb;case P.Utf8:return new Db;case P.Bool:return new Hb;case P.List:return new qc((b||[])[0]);case P.Struct_:return new C(b||[])}switch(c){case P.Int:return b=a.type(new ag),new B(b.isSigned(),b.bitWidth());case P.FloatingPoint:return b=a.type(new ng),new qb(b.precision());case P.Decimal:return b=a.type(new gg),new Lb(b.scale(),b.precision(),b.bitWidth());
case P.Date:return b=a.type(new fg),new Pb(b.unit());case P.Time:return b=a.type(new sg),new Vb(b.unit(),b.bitWidth());case P.Timestamp:return b=a.type(new tg),new cc(b.unit(),b.timezone());case P.Interval:return b=a.type(new qg),new kc(b.unit());case P.Union:c=a.type(new wg);a=c.mode();const d=L(c.g,c.h,6);c=d?new Int32Array(c.g.P().buffer,c.g.P().byteOffset+Cf(c.g,c.h+d),Df(c.g,c.h+d)):null;return new xc(a,c||[],b||[]);case P.FixedSizeBinary:return b=a.type(new jg),new Dc(b.byteWidth());case P.FixedSizeList:return a=
a.type(new kg),new Hc(a.listSize(),(b||[])[0]);case P.Map:return a=a.type(new rg),new Lc((b||[])[0],a.keysSorted())}throw Error(`Unrecognized type: "${P[c]}" (${c})`);}function qj(a,b){var c=b.fields.map(d=>S.encode(a,d));Qf(a,4,c.length,4);c=Bg(a,c);b=b.metadata&&0<b.metadata.size?Cg(a,[...b.metadata].map(([d,e])=>{d=Sf(a,`${d}`);e=Sf(a,`${e}`);N(a,2);M(a,0,d);M(a,1,e);return O(a)})):-1;N(a,4);M(a,1,c);Lf(a,Ej?Xf.Ab:Xf.Rb,Xf.Ab);-1!==b&&M(a,2,b);return O(a)}
function oj(a,b){let c=-1,d=-1,e=-1;var f=b.type;let g=b.typeId;A.isDictionary(f)?(g=f.dictionary.typeId,e=Zi.visit(f,a),d=Zi.visit(f.dictionary,a)):d=Zi.visit(f,a);f=(f.children||[]).map(n=>S.encode(a,n));f=xg(a,f);const k=b.metadata&&0<b.metadata.size?yg(a,[...b.metadata].map(([n,p])=>{n=Sf(a,`${n}`);p=Sf(a,`${p}`);N(a,2);M(a,0,n);M(a,1,p);return O(a)})):-1;b.name&&(c=Sf(a,b.name));N(a,7);M(a,3,d);Kf(a,2,g,P.NONE);M(a,5,f);Kf(a,1,+!!b.nullable,0);-1!==c&&M(a,0,c);-1!==e&&M(a,4,e);-1!==k&&M(a,6,
k);return O(a)}function sj(a,b){var c=b.M||[],d=b.buffers||[];Qf(a,16,c.length,8);for(const e of c.slice().reverse())fj.encode(a,e);c=Rf(a);Qf(a,16,d.length,8);for(const e of d.slice().reverse())hj.encode(a,e);d=Rf(a);N(a,4);Nf(a,0,new tf(b.length,0),a.R(0,0));M(a,1,c);M(a,2,d);return O(a)}function uj(a,b){const c=aj.encode(a,b.data);N(a,3);Nf(a,0,new tf(b.id,0),a.R(0,0));Kf(a,2,+b.Ga,0);M(a,1,c);return O(a)}
function wj(a,b){var c=new tf(b.length,0);b=new tf(b.nullCount,0);Ff(a,8,16);a.Y(b);a.Y(c);return a.offset()}function yj(a,b){var c=new tf(b.offset,0);b=new tf(b.length,0);Ff(a,8,16);a.Y(b);a.Y(c);return a.offset()}const Fj=new ArrayBuffer(2);(new DataView(Fj)).setInt16(0,256,!0);const Ej=256===(new Int16Array(Fj))[0];const Gj=a=>`Expected ${w[a]} Message in stream, but was null or length 0.`,Hj=a=>`Header pointer of flatbuffer-encoded ${w[a]} Message is null or length 0.`,Ij=(a,b)=>`Expected to read ${a} metadata bytes, but only read ${b}.`,Jj=(a,b)=>`Expected to read ${a} bytes for message body, but only read ${b}.`;
class Kj{constructor(a){this.source=a instanceof Sg?a:new Sg(a)}[Symbol.iterator](){return this}next(){let a;return(a=this.readMetadataLength()).done||-1===a.value&&(a=this.readMetadataLength()).done||(a=this.readMetadata(a.value)).done?T:a}throw(a){return this.source.throw(a)}return(a){return this.source.return(a)}readMessage(a){let b;if((b=this.next()).done)return null;if(null!=a&&b.value.headerType!==a)throw Error(Gj(a));return b.value}readMessageBody(a){if(0>=a)return new Uint8Array(0);const b=
q(Uint8Array,this.source.read(a));if(b.byteLength<a)throw Error(Jj(a,b.byteLength));return 0===b.byteOffset%8&&b.byteOffset+b.byteLength<=b.buffer.byteLength?b:b.slice()}readSchema(a=!1){const b=w.Schema,c=this.readMessage(b)?.header();if(a&&!c)throw Error(Hj(b));return c}readMetadataLength(){var a=this.source.read(4);a=(a&&new Ef(a))?.s(0)||0;return{done:0===a,value:a}}readMetadata(a){const b=this.source.read(a);if(!b)return T;if(b.byteLength<a)throw Error(Ij(a,b.byteLength));return{done:!1,value:kj.decode(b)}}}
class Lj{constructor(a,b){this.source=a instanceof Ug?a:m(a)&&l(a.stat)&&"number"===typeof a.fd?new Xg(a,b):new Ug(a)}[Symbol.asyncIterator](){return this}async next(){let a;return(a=await this.readMetadataLength()).done||-1===a.value&&(a=await this.readMetadataLength()).done||(a=await this.readMetadata(a.value)).done?T:a}async throw(a){return await this.source.throw(a)}async return(a){return await this.source.return(a)}async readMessage(a){let b;if((b=await this.next()).done)return null;if(null!=
a&&b.value.headerType!==a)throw Error(Gj(a));return b.value}async readMessageBody(a){if(0>=a)return new Uint8Array(0);const b=q(Uint8Array,await this.source.read(a));if(b.byteLength<a)throw Error(Jj(a,b.byteLength));return 0===b.byteOffset%8&&b.byteOffset+b.byteLength<=b.buffer.byteLength?b:b.slice()}async readSchema(a=!1){const b=w.Schema,c=(await this.readMessage(b))?.header();if(a&&!c)throw Error(Hj(b));return c}async readMetadataLength(){var a=await this.source.read(4);a=(a&&new Ef(a))?.s(0)||
0;return{done:0===a,value:a}}async readMetadata(a){const b=await this.source.read(a);if(!b)return T;if(b.byteLength<a)throw Error(Ij(a,b.byteLength));return{done:!1,value:kj.decode(b)}}}
class Mj extends Kj{constructor(a){super(new Uint8Array(0));this.O=!1;this.wa=[];this.V=this.gb=0;this.na=a instanceof Mg?a:new Mg(a)}next(){var a=this.na;if(!this.O)return this.O=!0,{done:!1,value:kj.fromJSON(a.schema,w.Schema)};if(this.V<a.dictionaries.length)return a=a.dictionaries[this.V++],this.wa=a.data.columns,{done:!1,value:kj.fromJSON(a,w.DictionaryBatch)};if(this.gb<a.batches.length)return a=a.batches[this.gb++],this.wa=a.columns,{done:!1,value:kj.fromJSON(a,w.RecordBatch)};this.wa=[];return T}readMessageBody(){function a(b){return(b||
[]).reduce((c,d)=>[...c,...(d.VALIDITY&&[d.VALIDITY]||[]),...(d.TYPE&&[d.TYPE]||[]),...(d.OFFSET&&[d.OFFSET]||[]),...(d.DATA&&[d.DATA]||[]),...a(d.children)],[])}return a(this.wa)}readMessage(a){let b;if((b=this.next()).done)return null;if(null!=a&&b.value.headerType!==a)throw Error(Gj(a));return b.value}readSchema(){const a=w.Schema,b=this.readMessage(a),c=b?.header();if(!b||!c)throw Error(Hj(a));return c}}const Nj=new Uint8Array(6);for(let a=0;6>a;a+=1)Nj[a]="ARROW1".codePointAt(a);
function Oj(a){for(let b=-1,c=Nj.length;++b<c;)if(Nj[b]!==a[0+b])return!1;return!0}const Pj=Nj.length,Qj=Pj+4,Rj=2*Pj+4;class Sj extends Pg{constructor(a){super();this.o=a}get closed(){return this.o.closed}get schema(){return this.o.schema}get autoDestroy(){return this.o.autoDestroy}get dictionaries(){return this.o.dictionaries}get numDictionaries(){return this.o.numDictionaries}get numRecordBatches(){return this.o.numRecordBatches}get footer(){return this.o.isFile()?this.o.footer:null}isSync(){return this.o.isSync()}isAsync(){return this.o.isAsync()}isFile(){return this.o.isFile()}isStream(){return this.o.isStream()}next(){return this.o.next()}throw(a){return this.o.throw(a)}return(a){return this.o.return(a)}cancel(){return this.o.cancel()}reset(a){this.o.reset(a);
this.lb=this.fb=void 0;return this}open(a){a=this.o.open(a);return m(a)&&l(a.then)?a.then(()=>this):this}readRecordBatch(a){return this.o.isFile()?this.o.readRecordBatch(a):null}[Symbol.iterator](){return this.o[Symbol.iterator]()}[Symbol.asyncIterator](){return this.o[Symbol.asyncIterator]()}toDOMStream(){return ta(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return ua(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}static throughNode(){throw Error('"throughNode" not available in this environment');
}static throughDOM(){throw Error('"throughDOM" not available in this environment');}static from(a){return a instanceof Sj?a:m(a)&&m(a.schema)?new Tj(new Uj(a)):m(a)&&l(a.stat)&&"number"===typeof a.fd?Vj(a):m(a)&&l(a.then)?(async()=>await Sj.from(await a))():m(a)&&ia(a.body)||ia(a)||ja(a)||m(a)&&l(a[Symbol.asyncIterator])?Wj(new Ug(a)):Xj(new Sg(a))}static readAll(a){return a instanceof Sj?a.isSync()?Yj(a):Zj(a):m(a)&&m(a.schema)||ArrayBuffer.isView(a)||m(a)&&l(a[Symbol.iterator])||m(a)&&"done"in a&&
"value"in a?Yj(a):Zj(a)}}class Tj extends Sj{constructor(a){super(a);this.o=a}readAll(){return[...this]}[Symbol.iterator](){return this.o[Symbol.iterator]()}async*[Symbol.asyncIterator](){yield*this[Symbol.iterator]()}}class ak extends Sj{constructor(a){super(a);this.o=a}async readAll(){const a=[];for await(const b of this)a.push(b);return a}[Symbol.iterator](){throw Error("AsyncRecordBatchStreamReader is not Iterable");}[Symbol.asyncIterator](){return this.o[Symbol.asyncIterator]()}}
class bk extends Tj{constructor(a){super(a);this.o=a}}class ck extends ak{constructor(a){super(a);this.o=a}}function dk(a,b,c){c=a.Ma(b,c,a.schema.fields);b=I({type:new C(a.schema.fields),length:b.length,children:c});return new W(a.schema,b)}function ek(a,b,c){var d=b.id;const e=b.Ga,f=a.schema,g=a.dictionaries.get(d);return e||!g?(d=f.dictionaries.get(d),a=a.Ma(b.data,c,[d]),(g&&e?g.concat(new F(a)):new F(a)).memoize()):g.memoize()}
class fk{constructor(a=new Map){this.closed=!1;this.autoDestroy=!0;this.N=this.V=0;this.dictionaries=a}get numDictionaries(){return this.V}get numRecordBatches(){return this.N}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(a){this.N=this.V=0;this.schema=a;this.dictionaries=new Map;return this}Ma(a,b,c){return(new gh(b,a.M,a.buffers,this.dictionaries)).visitMany(c)}}
class gk extends fk{constructor(a){super();this.u=m(a)&&m(a.schema)?new Mj(this.I=a):new Kj(this.I=a)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset().u.return(),this.dictionaries=this.u=null)}open(a){this.closed||(this.autoDestroy=hk(this,a),this.schema||(this.schema=this.u.readSchema())||this.cancel());return this}throw(a){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset().u.throw(a):T}return(a){return!this.closed&&
this.autoDestroy&&(this.closed=!0)?this.reset().u.return(a):T}next(){if(this.closed)return T;for(var a,b=this.u;a=this.pa();)if(a.isSchema())this.reset(a.header());else{if(a.isRecordBatch()){this.N++;var c=a.header();b=b.readMessageBody(a.bodyLength);return{done:!1,value:dk(this,c,b)}}a.isDictionaryBatch()&&(this.V++,c=a.header(),a=b.readMessageBody(a.bodyLength),a=ek(this,c,a),this.dictionaries.set(c.id,a))}return this.schema&&0===this.N?(this.N++,{done:!1,value:new Fi(this.schema)}):this.return()}pa(){return this.u.readMessage(void 0)}}
class ik extends fk{constructor(a,b){super(b);this.u=new Lj(this.I=a)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}async cancel(){!this.closed&&(this.closed=!0)&&(await this.reset().u.return(),this.dictionaries=this.u=null)}async open(a){this.closed||(this.autoDestroy=hk(this,a),this.schema||(this.schema=await this.u.readSchema())||await this.cancel());return this}async throw(a){return!this.closed&&this.autoDestroy&&(this.closed=!0)?await this.reset().u.throw(a):T}async return(a){return!this.closed&&
this.autoDestroy&&(this.closed=!0)?await this.reset().u.return(a):T}async next(){if(this.closed)return T;for(var a,b=this.u;a=await this.pa();)if(a.isSchema())await this.reset(a.header());else{if(a.isRecordBatch()){this.N++;var c=a.header();b=await b.readMessageBody(a.bodyLength);return{done:!1,value:dk(this,c,b)}}a.isDictionaryBatch()&&(this.V++,c=a.header(),a=await b.readMessageBody(a.bodyLength),a=ek(this,c,a),this.dictionaries.set(c.id,a))}return this.schema&&0===this.N?(this.N++,{done:!1,value:new Fi(this.schema)}):
await this.return()}async pa(){return await this.u.readMessage(void 0)}}
class jk extends gk{constructor(a){super(a instanceof Wg?a:new Wg(a))}get footer(){return this.l}get numDictionaries(){return this.l?this.l.numDictionaries:0}get numRecordBatches(){return this.l?this.l.numRecordBatches:0}isSync(){return!0}isFile(){return!0}open(a){if(!this.closed&&!this.l){this.schema=(this.l=this.Qa()).schema;for(const b of Ig(this.l))b&&this.Pa(this.V++)}return super.open(a)}readRecordBatch(a){if(this.closed)return null;this.l||this.open();if((a=this.l?.fa(a))&&this.I.seek(a.offset)){var b=
this.u.readMessage(w.RecordBatch);if(b?.isRecordBatch())return a=b.header(),b=this.u.readMessageBody(b.bodyLength),dk(this,a,b)}return null}Pa(a){if((a=this.l?.Fa(a))&&this.I.seek(a.offset)){var b=this.u.readMessage(w.DictionaryBatch);b?.isDictionaryBatch()&&(a=b.header(),b=this.u.readMessageBody(b.bodyLength),b=ek(this,a,b),this.dictionaries.set(a.id,b))}}Qa(){var a=this.I;const b=a.size-Qj,c=a.s(b);a=a.ga(b-c,c);return Jg.decode(a)}pa(){this.l||this.open();if(this.l&&this.N<this.numRecordBatches){const a=
this.l?.fa(this.N);if(a&&this.I.seek(a.offset))return this.u.readMessage(void 0)}return null}}
class kk extends ik{constructor(a){var b=[];const c="number"!==typeof b[0]?b.shift():void 0;b=b[0]instanceof Map?b.shift():void 0;super(a instanceof Xg?a:new Xg(a,c),b)}get footer(){return this.l}get numDictionaries(){return this.l?this.l.numDictionaries:0}get numRecordBatches(){return this.l?this.l.numRecordBatches:0}isFile(){return!0}isAsync(){return!0}async open(a){if(!this.closed&&!this.l){this.schema=(this.l=await this.Qa()).schema;for(const b of Ig(this.l))b&&await this.Pa(this.V++)}return await super.open(a)}async readRecordBatch(a){if(this.closed)return null;
this.l||await this.open();if((a=this.l?.fa(a))&&await this.I.seek(a.offset)){var b=await this.u.readMessage(w.RecordBatch);if(b?.isRecordBatch())return a=b.header(),b=await this.u.readMessageBody(b.bodyLength),dk(this,a,b)}return null}async Pa(a){if((a=this.l?.Fa(a))&&await this.I.seek(a.offset)){var b=await this.u.readMessage(w.DictionaryBatch);b?.isDictionaryBatch()&&(a=b.header(),b=await this.u.readMessageBody(b.bodyLength),b=ek(this,a,b),this.dictionaries.set(a.id,b))}}async Qa(){var a=this.I;
a.C&&await a.C;const b=a.size-Qj,c=await a.s(b);a=await a.ga(b-c,c);return Jg.decode(a)}async pa(){this.l||await this.open();if(this.l&&this.N<this.numRecordBatches){const a=this.l.fa(this.N);if(a&&await this.I.seek(a.offset))return await this.u.readMessage(void 0)}return null}}class Uj extends gk{Ma(a,b,c){return(new hh(b,a.M,a.buffers,this.dictionaries)).visitMany(c)}}function hk(a,b){return b&&"boolean"===typeof b.autoDestroy?b.autoDestroy:a.autoDestroy}
function*Yj(a){a=Sj.from(a);try{if(!a.open({autoDestroy:!1}).closed){do yield a;while(!a.reset().open().closed)}}finally{a.cancel()}}async function*Zj(a){a=await Sj.from(a);try{if(!(await a.open({autoDestroy:!1})).closed){do yield a;while(!(await a.reset().open()).closed)}}finally{await a.cancel()}}function Xj(a){const b=a.peek(Pj+7&-8);return b&&4<=b.byteLength?Oj(b)?new bk(new jk(a.read())):new Tj(new gk(a)):new Tj(new gk(function*(){}()))}
async function Wj(a){const b=await a.peek(Pj+7&-8);return b&&4<=b.byteLength?Oj(b)?new bk(new jk(await a.read())):new ak(new ik(a)):new ak(new ik(async function*(){}()))}async function Vj(a){const {size:b}=await a.stat();a=new Xg(a,b);return b>=Rj&&Oj(await a.ga(0,Pj+7&-8))?new ck(new kk(a)):new ak(new ik(a))};class lk extends D{constructor(){super();this.Z=0;this.Na=[];this.Ia=[];this.Cb=[]}static ra(...a){const b=d=>d.flatMap(e=>Array.isArray(e)?b(e):e instanceof W?e.data.children:e.data),c=new lk;c.visitMany(b(a));return c}visit(a){if(a instanceof F)return this.visitMany(a.data),this;const b=a.type;if(!A.isDictionary(b)){const c=a.length,d=a.nullCount;if(2147483647<c)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");A.isNull(b)||mk.call(this,0>=d?new Uint8Array(0):we(a.offset,
c,a.nullBitmap));this.M.push(new fj(c,d))}return super.visit(a)}visitNull(){return this}visitDictionary(a){return this.visit(a.clone(a.type.indices))}get M(){return this.Na}get buffers(){return this.Ia}get byteLength(){return this.Z}get Ua(){return this.Cb}}function mk(a){const b=a.byteLength+7&-8;this.buffers.push(a);this.Ua.push(new hj(this.Z,b));this.Z+=b;return this}function nk(a){return mk.call(this,a.values.subarray(0,a.length*a.stride))}
function ok(a){const b=a.length,c=a.values;a=a.valueOffsets;const d=a[0],e=Math.min(a[b]-d,c.byteLength-d);mk.call(this,ra(-a[0],b,a));mk.call(this,c.subarray(d,d+e));return this}function pk(a){const b=a.length,c=a.valueOffsets;c&&mk.call(this,ra(c[0],b,c));return this.visit(a.children[0])}function qk(a){return this.visitMany(a.type.children.map((b,c)=>a.children[c]).filter(Boolean))[0]}h=lk.prototype;
h.visitBool=function(a){let b;return a.nullCount>=a.length?mk.call(this,new Uint8Array(0)):(b=a.values)instanceof Uint8Array?mk.call(this,we(a.offset,a.length,b)):mk.call(this,xe(a.values))};h.visitInt=nk;h.visitFloat=nk;h.visitUtf8=ok;h.visitBinary=ok;h.visitFixedSizeBinary=nk;h.visitDate=nk;h.visitTimestamp=nk;h.visitTime=nk;h.visitDecimal=nk;h.visitList=pk;h.visitStruct=qk;
h.visitUnion=function(a){const b=a.type,c=a.length;var d=a.typeIds,e=a.valueOffsets;mk.call(this,d);if(b.mode===t.Sparse)return qk.call(this,a);if(b.mode===t.Dense){if(0>=a.offset)return mk.call(this,e),qk.call(this,a);var f=d.reduce((n,p)=>Math.max(n,p),d[0]);const g=new Int32Array(f+1);f=(new Int32Array(f+1)).fill(-1);const k=new Int32Array(c);e=ra(-e[0],c,e);for(let n,p,x=-1;++x<c;)-1===(p=f[n=d[x]])&&(p=f[n]=e[n]),k[x]=e[x]-p,++g[n];mk.call(this,k);for(let n,p=-1,x=b.children.length;++p<x;)if(n=
a.children[p])d=b.typeIds[p],this.visit(n.slice(f[d],Math.min(c,g[d])))}return this};h.visitInterval=nk;h.visitFixedSizeList=pk;h.visitMap=pk;class rk extends D{visit(a){return null==a?void 0:super.visit(a)}visitNull({typeId:a}){return{name:P[a].toLowerCase()}}visitInt({typeId:a,bitWidth:b,isSigned:c}){return{name:P[a].toLowerCase(),bitWidth:b,isSigned:c}}visitFloat({typeId:a,precision:b}){return{name:P[a].toLowerCase(),precision:u[b]}}visitBinary({typeId:a}){return{name:P[a].toLowerCase()}}visitBool({typeId:a}){return{name:P[a].toLowerCase()}}visitUtf8({typeId:a}){return{name:P[a].toLowerCase()}}visitDecimal({typeId:a,scale:b,precision:c,
bitWidth:d}){return{name:P[a].toLowerCase(),scale:b,precision:c,bitWidth:d}}visitDate({typeId:a,unit:b}){return{name:P[a].toLowerCase(),unit:Ga[b]}}visitTime({typeId:a,unit:b,bitWidth:c}){return{name:P[a].toLowerCase(),unit:v[b],bitWidth:c}}visitTimestamp({typeId:a,timezone:b,unit:c}){return{name:P[a].toLowerCase(),unit:v[c],timezone:b}}visitInterval({typeId:a,unit:b}){return{name:P[a].toLowerCase(),unit:Ja[b]}}visitList({typeId:a}){return{name:P[a].toLowerCase()}}visitStruct({typeId:a}){return{name:P[a].toLowerCase()}}visitUnion({typeId:a,
mode:b,typeIds:c}){return{name:P[a].toLowerCase(),mode:t[b],typeIds:[...c]}}visitDictionary(a){return this.visit(a.dictionary)}visitFixedSizeBinary({typeId:a,byteWidth:b}){return{name:P[a].toLowerCase(),byteWidth:b}}visitFixedSizeList({typeId:a,listSize:b}){return{name:P[a].toLowerCase(),listSize:b}}visitMap({typeId:a,keysSorted:b}){return{name:P[a].toLowerCase(),keysSorted:b}}};class sk extends D{static ra(...a){const b=new sk;return a.map(({schema:c,data:d})=>b.visitMany(c.fields,d.children))}visit({name:a},b){const c=b.length,d=b.offset,e=b.nullCount,f=b.nullBitmap,g=A.isDictionary(b.type)?b.type.indices:b.type,k=Object.assign([],b.buffers,{[Ma.VALIDITY]:void 0});return{name:a,count:c,VALIDITY:A.isNull(g)?void 0:0>=e?Array.from({length:c},()=>1):[...(new ye(f,d,c,null,ve))],...super.visit(b.clone(g,d,c,0,k))}}visitNull(){return{}}visitBool({values:a,offset:b,length:c}){return{DATA:[...(new ye(a,
b,c,null,ue))]}}visitInt(a){return{DATA:64>a.type.bitWidth?[...a.values]:[...tk(a.values,2)]}}visitFloat(a){return{DATA:[...a.values]}}visitUtf8(a){return{DATA:[...(new F([a]))],OFFSET:[...a.valueOffsets]}}visitBinary(a){return{DATA:[...uk(new F([a]))],OFFSET:[...a.valueOffsets]}}visitFixedSizeBinary(a){return{DATA:[...uk(new F([a]))]}}visitDate(a){return{DATA:a.type.unit===Ga.DAY?[...a.values]:[...tk(a.values,2)]}}visitTimestamp(a){return{DATA:[...tk(a.values,2)]}}visitTime(a){return{DATA:a.type.unit<
v.MICROSECOND?[...a.values]:[...tk(a.values,2)]}}visitDecimal(a){return{DATA:[...tk(a.values,4)]}}visitList(a){return{OFFSET:[...a.valueOffsets],children:this.visitMany(a.type.children,a.children)}}visitStruct(a){return{children:this.visitMany(a.type.children,a.children)}}visitUnion(a){return{TYPE:[...a.typeIds],OFFSET:a.type.mode===t.Dense?[...a.valueOffsets]:void 0,children:this.visitMany(a.type.children,a.children)}}visitInterval(a){return{DATA:[...a.values]}}visitFixedSizeList(a){return{children:this.visitMany(a.type.children,
a.children)}}visitMap(a){return{OFFSET:[...a.valueOffsets],children:this.visitMany(a.type.children,a.children)}}}function*uk(a){for(const b of a)yield b.reduce((c,d)=>`${c}${("0"+(d&255).toString(16)).slice(-2)}`,"").toUpperCase()}function*tk(a,b){a=new Uint32Array(a.buffer);for(let c=-1,d=a.length/b;++c<d;)yield`${Za.new(a.subarray((c+0)*b,(c+1)*b),!1)}`};function Y(a,b){a.qa&&(b=q(Uint8Array,b))&&0<b.byteLength&&(a.G.write(b),a.oa+=b.byteLength);return a}function vk(a,b){return 0<b?Y(a,new Uint8Array(b)):a}function wk(a,b){let c,d,e;for(let f=-1,g=b.length;++f<g;)(c=b[f])&&0<(d=c.byteLength)&&(Y(a,c),0<(e=(d+7&-8)-d)&&vk(a,e))}
class xk extends Pg{constructor(a){super();this.oa=0;this.qa=!1;this.G=new Rg;this.O=null;this.ma=[];this.za=[];this.ca=new Map;m(a)||(a={autoDestroy:!0,zb:!1});this.va="boolean"===typeof a.autoDestroy?a.autoDestroy:!0;this.Ra="boolean"===typeof a.zb?a.zb:!1}static throughNode(){throw Error('"throughNode" not available in this environment');}static throughDOM(){throw Error('"throughDOM" not available in this environment');}toString(a=!1){return this.G.toString(a)}toUint8Array(a=!1){return this.G.toUint8Array(a)}writeAll(a){return m(a)&&
l(a.then)?a.then(b=>this.writeAll(b)):m(a)&&l(a[Symbol.asyncIterator])?yk(this,a):zk(this,a)}get closed(){return this.G.closed}[Symbol.asyncIterator](){return this.G[Symbol.asyncIterator]()}toDOMStream(a){return this.G.toDOMStream(a)}toNodeStream(a){return this.G.toNodeStream(a)}close(){return this.reset().G.close()}abort(a){return this.reset().G.abort(a)}finish(){this.va?this.close():this.reset(this.G,this.O);return this}reset(a=this.G,b=null){a===this.G||a instanceof Rg?this.G=a:(this.G=new Rg,
a&&m(a)&&l(a.abort)&&l(a.getWriter)&&!ha(a)?this.toDOMStream({type:"bytes"}).pipeTo(a):a&&m(a)&&l(a.end)&&l(a.write)&&"boolean"===typeof a.writable&&!ha(a)&&Og(this.toNodeStream({Tb:!1}),a));this.qa&&this.O&&this.Ba(this.O);this.qa=!1;this.ma=[];this.za=[];this.ca=new Map;b&&oi(b,this.O)||(null==b?(this.oa=0,this.O=null):(this.qa=!0,this.O=b,this.Sa(b)));return this}write(a){let b=null;if(this.G){if(null==a||a instanceof X&&!(b=a.schema)||a instanceof W&&!(b=a.schema))return this.finish()&&void 0}else throw Error("RecordBatchWriter is closed");
if(b&&!oi(b,this.O)){if(this.qa&&this.va)return this.close();this.reset(this.G,b)}a instanceof W?a instanceof Fi||this.ob(a):a instanceof X?this.writeAll(a.batches):m(a)&&l(a[Symbol.iterator])&&this.writeAll(a)}Ca(a){const b=kj.encode(a),c=b.byteLength,d=this.Ra?4:8,e=c+d+7&-8,f=e-c-d;a.headerType===w.RecordBatch?this.za.push(new Lg(e,a.bodyLength,this.oa)):a.headerType===w.DictionaryBatch&&this.ma.push(new Lg(e,a.bodyLength,this.oa));this.Ra||Y(this,Int32Array.of(-1));Y(this,Int32Array.of(e-d));
0<c&&Y(this,b);return vk(this,f)}Sa(a){this.Ca(kj.from(a))}Ba(){return this.Ra?Y(this,Int32Array.of(0)):Y(this,Int32Array.of(-1,0))}ob(a){const {byteLength:b,M:c,Ua:d,buffers:e}=lk.ra(a),f=kj.from(new aj(a.numRows,c,d),b);wk(this.Aa(a).Ca(f),e)}nb(a,b,c=!1){this.ca.set(b,a.length+(this.ca.get(b)||0));const {byteLength:d,M:e,Ua:f,buffers:g}=lk.ra(new F([a]));a=kj.from(new nj(new aj(a.length,e,f),b,c),d);wk(this.Ca(a),g)}Aa(a){for(let [b,c]of a.dictionaries)if(a=this.ca.get(b)||0,0===a||0<(c=c?.slice(a)).length)for(const d of c.data)this.nb(d,
b,0<a),a+=d.length;return this}}class Ak extends xk{static writeAll(a,b){const c=new Ak(b);return m(a)&&l(a.then)?a.then(d=>c.writeAll(d)):m(a)&&l(a[Symbol.asyncIterator])?yk(c,a):zk(c,a)}}
class Bk extends xk{static writeAll(a){const b=new Bk;return m(a)&&l(a.then)?a.then(c=>b.writeAll(c)):m(a)&&l(a[Symbol.asyncIterator])?yk(b,a):zk(b,a)}constructor(){super();this.va=!0}Sa(){vk(Y(this,Nj),2)}Ba(a){const b=Jg.encode(new Jg(a,Ca.V4,this.za,this.ma));return Y(Y(Y(super.Ba(a),b),Int32Array.of(b.byteLength)),Nj)}}
class Ck extends xk{constructor(){super();this.va=!0;this.$=[];this.ba=[]}static writeAll(a){return(new Ck).writeAll(a)}Ca(){return this}Ba(){return this}Sa(a){Y(this,`{\n "schema": ${JSON.stringify({fields:a.fields.map(b=>Dk(b))},null,2)}`)}Aa(a){0<a.dictionaries.size&&this.ba.push(a);return this}nb(a,b,c=!1){this.ca.set(b,a.length+(this.ca.get(b)||0));Y(this,0===this.ma.length?" ":",\n ");Y(this,`${Ek(a,b,c)}`);this.ma.push(new Lg(0,0,0))}ob(a){this.Aa(a);this.$.push(a)}close(){if(0<this.ba.length){Y(this,
',\n "dictionaries": [\n');for(var a of this.ba)super.Aa(a);Y(this,"\n ]")}if(0<this.$.length){for(let b=-1,c=this.$.length;++b<c;){Y(this,0===b?',\n "batches": [\n ':",\n ");a=this.$[b];const [d]=sk.ra(a);a=JSON.stringify({count:a.numRows,columns:d},null,2);Y(this,`${a}`);this.za.push(new Lg(0,0,0))}Y(this,"\n ]")}this.O&&Y(this,"\n}");this.ba=[];this.$=[];return super.close()}}
function zk(a,b){let c=b;b instanceof X&&(c=b.batches,a.reset(void 0,b.schema));for(const d of c)a.write(d);return a.finish()}async function yk(a,b){for await(const c of b)a.write(c);return a.finish()}function Dk({name:a,type:b,nullable:c}){const d=new rk;return{name:a,nullable:c,type:d.visit(b),children:(b.children||[]).map(e=>Dk(e)),dictionary:A.isDictionary(b)?{id:b.id,isOrdered:b.isOrdered,indexType:d.visit(b.indices)}:void 0}}
function Ek(a,b,c=!1){const [d]=sk.ra(new W({[b]:a}));return JSON.stringify({id:b,isDelta:c,data:{count:a.length,columns:d}},null,2)};function Fk(a,b){function c(f,g){let k,n,p=f.desiredSize||null;for(;!(n=g.next(e?p:null)).done;)if(ArrayBuffer.isView(n.value)&&(k=q(Uint8Array,n.value))&&(null!=p&&e&&(p=p-k.byteLength+1),n.value=k),f.enqueue(n.value),null!=p&&0>=--p)return;f.close()}let d=null;const e="bytes"===b?.type||!1;return new ReadableStream({...b,start(f){c(f,d||=a[Symbol.iterator]())},pull(f){d?c(f,d):f.close()},cancel(){d?.return&&d.return();d=null}},{highWaterMark:e?b?.highWaterMark||2**24:void 0,...b})}
function Gk(a,b){async function c(f,g){let k,n,p=f.desiredSize||null;for(;!(n=await g.next(e?p:null)).done;)if(ArrayBuffer.isView(n.value)&&(k=q(Uint8Array,n.value))&&(null!=p&&e&&(p=p-k.byteLength+1),n.value=k),f.enqueue(n.value),null!=p&&0>=--p)return;f.close()}let d=null;const e="bytes"===b?.type||!1;return new ReadableStream({...b,async start(f){await c(f,d||=a[Symbol.asyncIterator]())},async pull(f){d?await c(f,d):f.close()},async cancel(){d?.return&&await d.return();d=null}},{highWaterMark:e?
b?.highWaterMark||2**24:void 0,...b})};function Hk(a,b,c){null!=c&&(a.ka>=c.desiredSize&&++a.Oa&&Ik(a,c,b.toVector()),b.finished&&((0<b.length||0===a.Oa)&&++a.Oa&&Ik(a,c,b.toVector()),!a.ib&&(a.ib=!0)&&Ik(a,c,null)))}function Ik(a,b,c){a.ka=0;a.la=null;null==c?b.close():b.enqueue(c)}
class Jk{constructor(a){this.Oa=0;this.ib=!1;this.ka=0;const {readableStrategy:b,writableStrategy:c,queueingStrategy:d="count",...e}=a;this.la=null;this.aa=qh(e);this.Fb="bytes"!==d?Kk:Lk;({highWaterMark:a="bytes"===d?16384:1E3}={...b});const {highWaterMark:f="bytes"===d?16384:1E3}={...c};this.readable=new ReadableStream({cancel:()=>{this.aa.clear()},pull:g=>{Hk(this,this.aa,this.la=g)},start:g=>{Hk(this,this.aa,this.la=g)}},{highWaterMark:a,size:"bytes"!==d?Kk:Lk});this.writable=new WritableStream({abort:()=>
{this.aa.clear()},write:()=>{Hk(this,this.aa,this.la)},close:()=>{Hk(this,this.aa.finish(),this.la)}},{highWaterMark:f,size:g=>{const k=this.ka;this.ka=this.Fb(this.aa.append(g));return this.ka-k}})}}const Kk=a=>a?.length??0,Lk=a=>a?.byteLength??0;function Mk(a,b){async function c(){return await (await Sj.from(e)).open(b)}async function d(k,n){let p=k.desiredSize,x;for(;!(x=await n.next()).done;)if(k.enqueue(x.value),null!=p&&0>=--p)return;k.close()}const e=new Rg;let f=null;const g=new ReadableStream({async cancel(){await e.close()},async start(k){await d(k,f||=await c())},async pull(k){f?await d(k,f):k.close()}});return{writable:new WritableStream(e,{highWaterMark:16384,...a}),readable:g}};function Nk(a,b){async function c(f){let g,k=f.desiredSize;for(;g=await e.read(k||null);)if(f.enqueue(g),null!=k&&0>=(k-=g.byteLength))return;f.close()}const d=new this(a),e=new Ug(d);b=new ReadableStream({async cancel(){await e.cancel()},async pull(f){await c(f)},async start(f){await c(f)}},{highWaterMark:16384,...b});return{writable:new WritableStream(d,a),readable:b}};function Ok(a){a=Sj.from(a);return m(a)&&l(a.then)?a.then(b=>Ok(b)):a.isAsync()?a.readAll().then(b=>new X(b)):new X(a.readAll())};const Pk={...$a,...eh,...Ce,...bd,...r,...te,compareSchemas:oi,compareFields:function(a,b){return mi.compareFields(a,b)},compareTypes:pi};ta=function(a,b){if(m(a)&&l(a[Symbol.asyncIterator]))return Gk(a,b);if(m(a)&&l(a[Symbol.iterator]))return Fk(a,b);throw Error("toDOMStream() must be called with an Iterable or AsyncIterable");};mf.throughDOM=function(a){return new Jk(a)};Sj.throughDOM=Mk;bk.throughDOM=Mk;Tj.throughDOM=Mk;xk.throughDOM=Nk;Bk.throughDOM=Nk;Ak.throughDOM=Nk;var Z={};Z.AsyncByteQueue=Rg;Z.AsyncByteStream=Ug;Z.AsyncMessageReader=Lj;Z.AsyncRecordBatchFileReader=ck;Z.AsyncRecordBatchStreamReader=ak;Z.Binary=xb;
Z.BinaryBuilder=jh;Z.Bool=Hb;Z.BoolBuilder=kh;Z.BufferType=Ma;Z.Builder=mf;Z.ByteStream=Sg;Z.Data=H;Z.DataType=A;Z.DateBuilder=lh;Z.DateDay=Tb;Z.DateDayBuilder=mh;Z.DateMillisecond=Ub;Z.DateMillisecondBuilder=nh;Z.DateUnit=Ga;Z.Date_=Pb;Z.Decimal=Lb;Z.DecimalBuilder=oh;Z.DenseUnion=Bc;Z.DenseUnionBuilder=Zh;Z.Dictionary=Qc;Z.DictionaryBuilder=ph;Z.Field=S;Z.FixedSizeBinary=Dc;Z.FixedSizeBinaryBuilder=rh;Z.FixedSizeList=Hc;Z.FixedSizeListBuilder=sh;Z.Float=qb;Z.Float16=ub;Z.Float16Builder=uh;
Z.Float32=vb;Z.Float32Builder=vh;Z.Float64=wb;Z.Float64Builder=wh;Z.FloatBuilder=th;Z.Int=B;Z.Int16=ib;Z.Int16Builder=Ch;Z.Int32=jb;Z.Int32Builder=Dh;Z.Int64=kb;Z.Int64Builder=Eh;Z.Int8=hb;Z.Int8Builder=Bh;Z.IntBuilder=Ah;Z.Interval=kc;Z.IntervalBuilder=xh;Z.IntervalDayTime=oc;Z.IntervalDayTimeBuilder=yh;Z.IntervalUnit=Ja;Z.IntervalYearMonth=pc;Z.IntervalYearMonthBuilder=zh;Z.JSONMessageReader=Mj;Z.List=qc;Z.ListBuilder=Jh;Z.MapBuilder=Kh;Z.MapRow=ee;Z.Map_=Lc;Z.Message=kj;Z.MessageHeader=Vi;
Z.MessageReader=Kj;Z.MetadataVersion=Ca;Z.Null=db;Z.NullBuilder=Lh;Z.Precision=u;Z.RecordBatch=W;Z.RecordBatchFileReader=bk;Z.RecordBatchFileWriter=Bk;Z.RecordBatchJSONWriter=Ck;Z.RecordBatchReader=Sj;Z.RecordBatchStreamReader=Tj;Z.RecordBatchStreamWriter=Ak;Z.RecordBatchWriter=xk;Z.Schema=R;Z.SparseUnion=Cc;Z.SparseUnionBuilder=Yh;Z.Struct=C;Z.StructBuilder=Mh;Z.StructRow=Jd;Z.Table=X;Z.Time=Vb;Z.TimeBuilder=Sh;Z.TimeMicrosecond=ac;Z.TimeMicrosecondBuilder=Vh;Z.TimeMillisecond=$b;
Z.TimeMillisecondBuilder=Uh;Z.TimeNanosecond=bc;Z.TimeNanosecondBuilder=Wh;Z.TimeSecond=Zb;Z.TimeSecondBuilder=Th;Z.TimeUnit=v;Z.Timestamp=cc;Z.TimestampBuilder=Nh;Z.TimestampMicrosecond=ic;Z.TimestampMicrosecondBuilder=Qh;Z.TimestampMillisecond=hc;Z.TimestampMillisecondBuilder=Ph;Z.TimestampNanosecond=jc;Z.TimestampNanosecondBuilder=Rh;Z.TimestampSecond=gc;Z.TimestampSecondBuilder=Oh;Z.Type=y;Z.Uint16=nb;Z.Uint16Builder=Gh;Z.Uint32=ob;Z.Uint32Builder=Hh;Z.Uint64=pb;Z.Uint64Builder=Ih;Z.Uint8=lb;
Z.Uint8Builder=Fh;Z.Union=xc;Z.UnionBuilder=Xh;Z.UnionMode=t;Z.Utf8=Db;Z.Utf8Builder=$h;Z.Vector=F;Z.Visitor=D;Z.builderThroughAsyncIterable=function(a){const {queueingStrategy:b="count"}=a,{highWaterMark:c="bytes"!==b?Number.POSITIVE_INFINITY:16384}=a,d="bytes"!==b?"length":"byteLength";return async function*(e){let f=0;const g=qh(a);for await(const k of e)g.append(k)[d]>=c&&++f&&(yield g.toVector());if(0<g.finish().length||0===f)yield g.toVector()}};Z.builderThroughIterable=si;Z.makeBuilder=qh;
Z.makeData=I;Z.makeTable=function(a){const b={};a=Object.entries(a);for(const [c,d]of a)b[c]=bf(d);return new X(b)};Z.makeVector=bf;Z.tableFromArrays=function(a){const b={};a=Object.entries(a);for(const [c,d]of a)b[c]=qi(d);return new X(b)};Z.tableFromIPC=Ok;Z.tableFromJSON=function(a){a=qi(a);a=new W(new R(a.type.children),a.data[0]);return new X(a)};Z.tableToIPC=function(a,b="stream"){return("stream"===b?Ak:Bk).writeAll(a).toUint8Array(!0)};Z.util=Pk;Z.vectorFromArray=qi;Object.assign(arguments[0],Z);}.bind(this))));
//# sourceMappingURL=Arrow.esnext.min.js.map