@influxdata/influxdb3-client-browser 2.2.0-nightly.16311 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.gz +0 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.mjs +1 -1
- package/dist/index.browser.mjs.gz +0 -0
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.gz +0 -0
- package/dist/index.mjs.map +1 -1
- package/dist/influxdb.js +1 -1
- package/dist/influxdb.js.gz +0 -0
- package/dist/influxdb.js.map +1 -1
- package/package.json +3 -3
package/dist/influxdb.js
CHANGED
|
@@ -17,6 +17,6 @@ ${t}`),new Function("x",`${t}
|
|
|
17
17
|
return true;`)}function Zh(r){return typeof r!="bigint"?ue(r):`${ue(r)}n`}function lc(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function ff(r,t=0){return r.length>=t?r.subarray(0,t):Ji(new r.constructor(t),r,0)}var ge=class{constructor(t,e=0,i=1){this.length=Math.ceil(e/i),this.buffer=new t(this.length),this.stride=i,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=t}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(t,e){return this}append(t){return this.set(this.length,t)}reserve(t){if(t>0){this.length+=t;let e=this.stride,i=this.length*e,n=this.buffer.length;i>=n&&this._resize(n===0?lc(i*1,this.BYTES_PER_ELEMENT):lc(i*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=lc(t*this.stride,this.BYTES_PER_ELEMENT);let e=ff(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=ff(this.buffer,t)}},tr=class extends ge{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}},bi=class extends tr{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){let{buffer:i}=this.reserve(t-this.length+1),n=t>>3,s=t%8,o=i[n]>>s&1;return e?o===0&&(i[n]|=1<<s,++this.numValid):o===1&&(i[n]&=~(1<<s),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},_i=class extends tr{constructor(t){super(t.OffsetArrayType,1,1)}append(t){return this.set(this.length-1,t)}set(t,e){let i=this.length-1,n=this.reserve(t-i+1).buffer;return i<t++&&i>=0&&n.fill(n[i],i,t),n[t]=n[t-1]+e,this}flush(t=this.length-1){return t>this.length&&this.set(t-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(t+1)}};var ot=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=Ht(t),this._nulls=new bi,e&&e.length>0&&(this._isValid=uf(e))}toVector(){return new P([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0,{_offsets:e,_values:i,_nulls:n,_typeIds:s,children:o}=this;return e&&(t+=e.byteLength),i&&(t+=i.byteLength),n&&(t+=n.byteLength),s&&(t+=s.byteLength),o.reduce((a,c)=>a+c.byteLength,t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((e,i)=>e+i.reservedByteLength,t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(t){return this.children[t]||null}flush(){let t,e,i,n,{type:s,length:o,nullCount:a,_typeIds:c,_offsets:l,_values:u,_nulls:d}=this;(e=c==null?void 0:c.flush(o))?n=l==null?void 0:l.flush(o):(n=l==null?void 0:l.flush(o))?t=u==null?void 0:u.flush(l.last()):t=u==null?void 0:u.flush(o),a>0&&(i=d==null?void 0:d.flush(o));let p=this.children.map(m=>m.flush());return this.clear(),L({type:s,length:o,nullCount:a,children:p,child:p[0],data:t,typeIds:e,nullBitmap:i,valueOffsets:n})}finish(){this.finished=!0;for(let t of this.children)t.finish();return this}clear(){var t,e,i,n;this.length=0,(t=this._nulls)===null||t===void 0||t.clear(),(e=this._values)===null||e===void 0||e.clear(),(i=this._offsets)===null||i===void 0||i.clear(),(n=this._typeIds)===null||n===void 0||n.clear();for(let s of this.children)s.clear();return this}};ot.prototype.length=1;ot.prototype.stride=1;ot.prototype.children=null;ot.prototype.finished=!1;ot.prototype.nullValues=null;ot.prototype._isValid=()=>!0;var yt=class extends ot{constructor(t){super(t),this._values=new tr(this.ArrayType,0,this.stride)}setValue(t,e){let i=this._values;return i.reserve(t-i.length+1),super.setValue(t,e)}},Ct=class extends ot{constructor(t){super(t),this._pendingLength=0,this._offsets=new _i(t.type)}setValue(t,e){let i=this._pending||(this._pending=new Map),n=i.get(t);n&&(this._pendingLength-=n.length),this._pendingLength+=e instanceof De?e[Sr].length:e.length,i.set(t,e)}setValid(t,e){return super.setValid(t,e)?!0:((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}};var Hr=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,i,n){return t.prep(8,24),t.writeInt64(BigInt(n!=null?n:0)),t.pad(4),t.writeInt32(i),t.writeInt64(BigInt(e!=null?e:0)),t.offset()}};var Gt=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):J.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new Rt).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){let i=this.bb.__offset(this.bb_pos,8);return i?(e||new Hr).__init(this.bb.__vector(this.bb_pos+i)+t*24,this.bb):null}dictionariesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){let i=this.bb.__offset(this.bb_pos,10);return i?(e||new Hr).__init(this.bb.__vector(this.bb_pos+i)+t*24,this.bb):null}recordBatchesLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let i=this.bb.__offset(this.bb_pos,12);return i?(e||new It).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,J.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}};var K=class r{constructor(t=[],e,i,n=J.V5){this.fields=t||[],this.metadata=e||new Map,i||(i=uc(this.fields)),this.dictionaries=i,this.metadataVersion=n}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,e)=>`${e}: ${t}`).join(", ")} }>`}select(t){let e=new Set(t),i=this.fields.filter(n=>e.has(n.name));return new r(i,this.metadata)}selectAt(t){let e=t.map(i=>this.fields[i]).filter(Boolean);return new r(e,this.metadata)}assign(...t){let e=t[0]instanceof r?t[0]:Array.isArray(t[0])?new r(t[0]):new r(t),i=[...this.fields],n=fo(fo(new Map,this.metadata),e.metadata),s=e.fields.filter(a=>{let c=i.findIndex(l=>l.name===a.name);return~c?(i[c]=a.clone({metadata:fo(fo(new Map,i[c].metadata),a.metadata)}))&&!1:!0}),o=uc(s,new Map);return new r([...i,...s],n,new Map([...this.dictionaries,...o]))}};K.prototype.fields=null;K.prototype.metadata=null;K.prototype.dictionaries=null;var C=class r{static new(...t){let[e,i,n,s]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],i===void 0&&(i=t[0].type),n===void 0&&(n=t[0].nullable),s===void 0&&(s=t[0].metadata)),new r(`${e}`,i,n,s)}constructor(t,e,i=!1,n){this.name=t,this.type=e,this.nullable=i,this.metadata=n||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,i,n,s]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,i=this.type,n=this.nullable,s=this.metadata]=t:{name:e=this.name,type:i=this.type,nullable:n=this.nullable,metadata:s=this.metadata}=t[0],r.new(e,i,n,s)}};C.prototype.type=null;C.prototype.name=null;C.prototype.nullable=null;C.prototype.metadata=null;function fo(r,t){return new Map([...r||new Map,...t||new Map])}function uc(r,t=new Map){for(let e=-1,i=r.length;++e<i;){let s=r[e].type;if(b.isDictionary(s)){if(!t.has(s.id))t.set(s.id,s.dictionary);else if(t.get(s.id)!==s.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}s.children&&s.children.length>0&&uc(s.children,t)}return t}var Qh=kr,tp=xt,er=class{static decode(t){t=new tp(D(t));let e=Gt.getRootAsFooter(t),i=K.decode(e.schema(),new Map,e.version());return new fc(i,e)}static encode(t){let e=new Qh,i=K.encode(e,t.schema);Gt.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())rr.encode(e,o);let n=e.endVector();Gt.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())rr.encode(e,o);let s=e.endVector();return Gt.startFooter(e),Gt.addSchema(e,i),Gt.addVersion(e,J.V5),Gt.addRecordBatches(e,n),Gt.addDictionaries(e,s),Gt.finishFooterBuffer(e,Gt.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=J.V5,i,n){this.schema=t,this.version=e,i&&(this._recordBatches=i),n&&(this._dictionaryBatches=n)}*recordBatches(){for(let t,e=-1,i=this.numRecordBatches;++e<i;)(t=this.getRecordBatch(e))&&(yield t)}*dictionaryBatches(){for(let t,e=-1,i=this.numDictionaries;++e<i;)(t=this.getDictionaryBatch(e))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}};var fc=class extends er{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,e){super(t,e.version()),this._footer=e}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){let e=this._footer.recordBatches(t);if(e)return rr.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return rr.decode(e)}return null}},rr=class r{static decode(t){return new r(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){let{metaDataLength:i}=e,n=BigInt(e.offset),s=BigInt(e.bodyLength);return Hr.createBlock(t,n,i,s)}constructor(t,e,i){this.metaDataLength=t,this.offset=W(i),this.bodyLength=W(e)}};var be=class r{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new r).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new r).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):J.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):V.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){let i=this.bb.__offset(this.bb_pos,12);return i?(e||new It).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+i)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,J.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,V.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let i=e.length-1;i>=0;i--)t.addOffset(e[i]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,i,n,s,o){return r.startMessage(t),r.addVersion(t,e),r.addHeaderType(t,i),r.addHeader(t,n),r.addBodyLength(t,s),r.addCustomMetadata(t,o),r.endMessage(t)}};var dc=class extends v{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return rn.startNull(e),rn.endNull(e)}visitInt(t,e){return ce.startInt(e),ce.addBitWidth(e,t.bitWidth),ce.addIsSigned(e,t.isSigned),ce.endInt(e)}visitFloat(t,e){return br.startFloatingPoint(e),br.addPrecision(e,t.precision),br.endFloatingPoint(e)}visitBinary(t,e){return Yi.startBinary(e),Yi.endBinary(e)}visitLargeBinary(t,e){return Qi.startLargeBinary(e),Qi.endLargeBinary(e)}visitBool(t,e){return Zi.startBool(e),Zi.endBool(e)}visitUtf8(t,e){return sn.startUtf8(e),sn.endUtf8(e)}visitLargeUtf8(t,e){return tn.startLargeUtf8(e),tn.endLargeUtf8(e)}visitDecimal(t,e){return Be.startDecimal(e),Be.addScale(e,t.scale),Be.addPrecision(e,t.precision),Be.addBitWidth(e,t.bitWidth),Be.endDecimal(e)}visitDate(t,e){return pr.startDate(e),pr.addUnit(e,t.unit),pr.endDate(e)}visitTime(t,e){return Ve.startTime(e),Ve.addUnit(e,t.unit),Ve.addBitWidth(e,t.bitWidth),Ve.endTime(e)}visitTimestamp(t,e){let i=t.timezone&&e.createString(t.timezone)||void 0;return Pe.startTimestamp(e),Pe.addUnit(e,t.unit),i!==void 0&&Pe.addTimezone(e,i),Pe.endTimestamp(e)}visitInterval(t,e){return _r.startInterval(e),_r.addUnit(e,t.unit),_r.endInterval(e)}visitDuration(t,e){return mr.startDuration(e),mr.addUnit(e,t.unit),mr.endDuration(e)}visitList(t,e){return en.startList(e),en.endList(e)}visitStruct(t,e){return nn.startStruct_(e),nn.endStruct_(e)}visitUnion(t,e){le.startTypeIdsVector(e,t.typeIds.length);let i=le.createTypeIdsVector(e,t.typeIds);return le.startUnion(e),le.addMode(e,t.mode),le.addTypeIds(e,i),le.endUnion(e)}visitDictionary(t,e){let i=this.visit(t.indices,e);return Te.startDictionaryEncoding(e),Te.addId(e,BigInt(t.id)),Te.addIsOrdered(e,t.isOrdered),i!==void 0&&Te.addIndexType(e,i),Te.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return yr.startFixedSizeBinary(e),yr.addByteWidth(e,t.byteWidth),yr.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return gr.startFixedSizeList(e),gr.addListSize(e,t.listSize),gr.endFixedSizeList(e)}visitMap(t,e){return wr.startMap(e),wr.addKeysSorted(e,t.keysSorted),wr.endMap(e)}},ho=new dc;function mf(r,t=new Map){return new K(ep(r,t),po(r.metadata),t)}function hc(r){return new bt(r.count,gf(r.columns),bf(r.columns),null)}function yf(r){return new Ot(hc(r.data),r.id,r.isDelta)}function ep(r,t){return(r.fields||[]).filter(Boolean).map(e=>C.fromJSON(e,t))}function df(r,t){return(r.children||[]).filter(Boolean).map(e=>C.fromJSON(e,t))}function gf(r){return(r||[]).reduce((t,e)=>[...t,new Qt(e.count,rp(e.VALIDITY)),...gf(e.children)],[])}function bf(r,t=[]){for(let e=-1,i=(r||[]).length;++e<i;){let n=r[e];n.VALIDITY&&t.push(new gt(t.length,n.VALIDITY.length)),n.TYPE_ID&&t.push(new gt(t.length,n.TYPE_ID.length)),n.OFFSET&&t.push(new gt(t.length,n.OFFSET.length)),n.DATA&&t.push(new gt(t.length,n.DATA.length)),t=bf(n.children,t)}return t}function rp(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function _f(r,t){let e,i,n,s,o,a;return!t||!(s=r.dictionary)?(o=pf(r,df(r,t)),n=new C(r.name,o,r.nullable,po(r.metadata))):t.has(e=s.id)?(i=(i=s.indexType)?hf(i):new Oe,a=new $t(t.get(e),i,e,s.isOrdered),n=new C(r.name,a,r.nullable,po(r.metadata))):(i=(i=s.indexType)?hf(i):new Oe,t.set(e,o=pf(r,df(r,t))),a=new $t(o,i,e,s.isOrdered),n=new C(r.name,a,r.nullable,po(r.metadata))),n||null}function po(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function hf(r){return new vt(r.isSigned,r.bitWidth)}function pf(r,t){let e=r.type.name;switch(e){case"NONE":return new Nt;case"null":return new Nt;case"binary":return new je;case"largebinary":return new ze;case"utf8":return new We;case"largeutf8":return new $e;case"bool":return new He;case"list":return new de((t||[])[0]);case"struct":return new it(t||[]);case"struct_":return new it(t||[])}switch(e){case"int":{let i=r.type;return new vt(i.isSigned,i.bitWidth)}case"floatingpoint":{let i=r.type;return new Zt(Y[i.precision])}case"decimal":{let i=r.type;return new Ge(i.scale,i.precision,i.bitWidth)}case"date":{let i=r.type;return new qe(ut[i.unit])}case"time":{let i=r.type;return new Je(w[i.unit],i.bitWidth)}case"timestamp":{let i=r.type;return new Ke(w[i.unit],i.timezone)}case"interval":{let i=r.type;return new Xe(et[i.unit])}case"duration":{let i=r.type;return new Ye(w[i.unit])}case"union":{let i=r.type,[n,...s]=(i.mode+"").toLowerCase(),o=n.toUpperCase()+s.join("");return new he(Z[o],i.typeIds||[],t||[])}case"fixedsizebinary":{let i=r.type;return new Ze(i.byteWidth)}case"fixedsizelist":{let i=r.type;return new pe(i.listSize,(t||[])[0])}case"map":{let i=r.type;return new me((t||[])[0],i.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var ip=kr,np=xt,kt=class r{static fromJSON(t,e){let i=new r(0,J.V5,e);return i._createHeader=sp(t,e),i}static decode(t){t=new np(D(t));let e=be.getRootAsMessage(t),i=e.bodyLength(),n=e.version(),s=e.headerType(),o=new r(i,n,s);return o._createHeader=op(e,s),o}static encode(t){let e=new ip,i=-1;return t.isSchema()?i=K.encode(e,t.header()):t.isRecordBatch()?i=bt.encode(e,t.header()):t.isDictionaryBatch()&&(i=Ot.encode(e,t.header())),be.startMessage(e),be.addVersion(e,J.V5),be.addHeader(e,i),be.addHeaderType(e,t.headerType),be.addBodyLength(e,BigInt(t.bodyLength)),be.finishMessageBuffer(e,be.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof K)return new r(0,J.V5,V.Schema,t);if(t instanceof bt)return new r(e,J.V5,V.RecordBatch,t);if(t instanceof Ot)return new r(e,J.V5,V.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get compression(){return this._compression}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===V.Schema}isRecordBatch(){return this.headerType===V.RecordBatch}isDictionaryBatch(){return this.headerType===V.DictionaryBatch}constructor(t,e,i,n){this._version=e,this._headerType=i,this.body=new Uint8Array(0),this._compression=n==null?void 0:n.compression,n&&(this._createHeader=()=>n),this._bodyLength=W(t)}},bt=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}get compression(){return this._compression}constructor(t,e,i,n){this._nodes=e,this._buffers=i,this._length=W(t),this._compression=n}},Ot=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,i=!1){this._data=t,this._isDelta=i,this._id=W(e)}},gt=class{constructor(t,e){this.offset=W(t),this.length=W(e)}},Qt=class{constructor(t,e){this.length=W(t),this.nullCount=W(e)}},Gr=class{constructor(t,e=Vr.BUFFER){this.type=t,this.method=e}};function sp(r,t){return(()=>{switch(t){case V.Schema:return K.fromJSON(r);case V.RecordBatch:return bt.fromJSON(r);case V.DictionaryBatch:return Ot.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${V[t]}, type: ${t} }`)})}function op(r,t){return(()=>{switch(t){case V.Schema:return K.decode(r.header(new Rt),new Map,r.version());case V.RecordBatch:return bt.decode(r.header(new Mt),r.version());case V.DictionaryBatch:return Ot.decode(r.header(new ke),r.version())}throw new Error(`Unrecognized Message type: { name: ${V[t]}, type: ${t} }`)})}C.encode=gp;C.decode=mp;C.fromJSON=_f;K.encode=yp;K.decode=ap;K.fromJSON=mf;bt.encode=bp;bt.decode=cp;bt.fromJSON=hc;Ot.encode=_p;Ot.decode=lp;Ot.fromJSON=yf;Qt.encode=wp;Qt.decode=fp;gt.encode=Ip;gt.decode=up;Gr.encode=xf;Gr.decode=Sf;function ap(r,t=new Map,e=J.V5){let i=pp(r,t);return new K(i,mo(r),t,e)}function cp(r,t=J.V5){return new bt(r.length(),dp(r),hp(r,t),Sf(r.compression()))}function lp(r,t=J.V5){return new Ot(bt.decode(r.data(),t),r.id(),r.isDelta())}function up(r){return new gt(r.offset(),r.length())}function fp(r){return new Qt(r.length(),r.nullCount())}function dp(r){let t=[];for(let e,i=-1,n=-1,s=r.nodesLength();++i<s;)(e=r.nodes(i))&&(t[++n]=Qt.decode(e));return t}function hp(r,t){let e=[];for(let i,n=-1,s=-1,o=r.buffersLength();++n<o;)(i=r.buffers(n))&&(t<J.V4&&(i.bb_pos+=8*(n+1)),e[++s]=gt.decode(i));return e}function pp(r,t){let e=[];for(let i,n=-1,s=-1,o=r.fieldsLength();++n<o;)(i=r.fields(n))&&(e[++s]=C.decode(i,t));return e}function wf(r,t){let e=[];for(let i,n=-1,s=-1,o=r.childrenLength();++n<o;)(i=r.children(n))&&(e[++s]=C.decode(i,t));return e}function mp(r,t){let e,i,n,s,o,a;return!t||!(a=r.dictionary())?(n=vf(r,wf(r,t)),i=new C(r.name(),n,r.nullable(),mo(r))):t.has(e=W(a.id()))?(s=(s=a.indexType())?If(s):new Oe,o=new $t(t.get(e),s,e,a.isOrdered()),i=new C(r.name(),o,r.nullable(),mo(r))):(s=(s=a.indexType())?If(s):new Oe,t.set(e,n=vf(r,wf(r,t))),o=new $t(n,s,e,a.isOrdered()),i=new C(r.name(),o,r.nullable(),mo(r))),i||null}function mo(r){let t=new Map;if(r)for(let e,i,n=-1,s=Math.trunc(r.customMetadataLength());++n<s;)(e=r.customMetadata(n))&&(i=e.key())!=null&&t.set(i,e.value());return t}function If(r){return new vt(r.isSigned(),r.bitWidth())}function vf(r,t){let e=r.typeType();switch(e){case Q.NONE:return new Nt;case Q.Null:return new Nt;case Q.Binary:return new je;case Q.LargeBinary:return new ze;case Q.Utf8:return new We;case Q.LargeUtf8:return new $e;case Q.Bool:return new He;case Q.List:return new de((t||[])[0]);case Q.Struct_:return new it(t||[])}switch(e){case Q.Int:{let i=r.type(new ce);return new vt(i.isSigned(),i.bitWidth())}case Q.FloatingPoint:{let i=r.type(new br);return new Zt(i.precision())}case Q.Decimal:{let i=r.type(new Be);return new Ge(i.scale(),i.precision(),i.bitWidth())}case Q.Date:{let i=r.type(new pr);return new qe(i.unit())}case Q.Time:{let i=r.type(new Ve);return new Je(i.unit(),i.bitWidth())}case Q.Timestamp:{let i=r.type(new Pe);return new Ke(i.unit(),i.timezone())}case Q.Interval:{let i=r.type(new _r);return new Xe(i.unit())}case Q.Duration:{let i=r.type(new mr);return new Ye(i.unit())}case Q.Union:{let i=r.type(new le);return new he(i.mode(),i.typeIdsArray()||[],t||[])}case Q.FixedSizeBinary:{let i=r.type(new yr);return new Ze(i.byteWidth())}case Q.FixedSizeList:{let i=r.type(new gr);return new pe(i.listSize(),(t||[])[0])}case Q.Map:{let i=r.type(new wr);return new me((t||[])[0],i.keysSorted())}}throw new Error(`Unrecognized type: "${Q[e]}" (${e})`)}function Sf(r){return r?new Gr(r.codec(),r.method()):null}function yp(r,t){let e=t.fields.map(s=>C.encode(r,s));Rt.startFieldsVector(r,e.length);let i=Rt.createFieldsVector(r,e),n=t.metadata&&t.metadata.size>0?Rt.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString(`${s}`),c=r.createString(`${o}`);return It.startKeyValue(r),It.addKey(r,a),It.addValue(r,c),It.endKeyValue(r)})):-1;return Rt.startSchema(r),Rt.addFields(r,i),Rt.addEndianness(r,vp?hr.Little:hr.Big),n!==-1&&Rt.addCustomMetadata(r,n),Rt.endSchema(r)}function gp(r,t){let e=-1,i=-1,n=-1,s=t.type,o=t.typeId;b.isDictionary(s)?(o=s.dictionary.typeId,n=ho.visit(s,r),i=ho.visit(s.dictionary,r)):i=ho.visit(s,r);let a=(s.children||[]).map(u=>C.encode(r,u)),c=Bt.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?Bt.createCustomMetadataVector(r,[...t.metadata].map(([u,d])=>{let p=r.createString(`${u}`),m=r.createString(`${d}`);return It.startKeyValue(r),It.addKey(r,p),It.addValue(r,m),It.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),Bt.startField(r),Bt.addType(r,i),Bt.addTypeType(r,o),Bt.addChildren(r,c),Bt.addNullable(r,!!t.nullable),e!==-1&&Bt.addName(r,e),n!==-1&&Bt.addDictionary(r,n),l!==-1&&Bt.addCustomMetadata(r,l),Bt.endField(r)}function bp(r,t){let e=t.nodes||[],i=t.buffers||[];Mt.startNodesVector(r,e.length);for(let a of e.slice().reverse())Qt.encode(r,a);let n=r.endVector();Mt.startBuffersVector(r,i.length);for(let a of i.slice().reverse())gt.encode(r,a);let s=r.endVector(),o=null;return t.compression!==null&&(o=xf(r,t.compression)),Mt.startRecordBatch(r),Mt.addLength(r,BigInt(t.length)),Mt.addNodes(r,n),Mt.addBuffers(r,s),t.compression!==null&&o&&Mt.addCompression(r,o),Mt.endRecordBatch(r)}function xf(r,t){return Ce.startBodyCompression(r),Ce.addCodec(r,t.type),Ce.addMethod(r,t.method),Ce.endBodyCompression(r)}function _p(r,t){let e=bt.encode(r,t.data);return ke.startDictionaryBatch(r),ke.addId(r,BigInt(t.id)),ke.addIsDelta(r,t.isDelta),ke.addData(r,e),ke.endDictionaryBatch(r)}function wp(r,t){return ai.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function Ip(r,t){return oi.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var vp=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var nt=Object.freeze({done:!0,value:void 0}),hn=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},qr=class{tee(){return this._getDOMStream().tee()}pipe(t,e){return this._getNodeStream().pipe(t,e)}pipeTo(t,e){return this._getDOMStream().pipeTo(t,e)}pipeThrough(t,e){return this._getDOMStream().pipeThrough(t,e)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}},yo=class extends qr{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return g(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){let{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(nt);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return St.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return St.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return g(this,void 0,void 0,function*(){return yield this.abort(t),nt})}return(t){return g(this,void 0,void 0,function*(){return yield this.close(),nt})}read(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,i)=>{this.resolvers.push({resolve:e,reject:i})}):Promise.resolve(nt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var Ae=class extends yo{write(t){if((t=D(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Gi(this.toUint8Array(!0)):this.toUint8Array(!1).then(Gi)}toUint8Array(t=!1){return t?Wt(this._values)[0]:g(this,void 0,void 0,function*(){var e,i,n,s;let o=[],a=0;try{for(var c=!0,l=ie(this),u;u=yield l.next(),e=u.done,!e;c=!0){s=u.value,c=!1;let d=s;o.push(d),a+=d.byteLength}}catch(d){i={error:d}}finally{try{!c&&!e&&(n=l.return)&&(yield n.call(l))}finally{if(i)throw i.error}}return Wt(o,a)[0]})}},Fe=class{constructor(t){t&&(this.source=new pc(St.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},te=class r{constructor(t){t instanceof r?this.source=t.source:t instanceof Ae?this.source=new ir(St.fromAsyncIterable(t)):Is(t)?this.source=new ir(St.fromNodeStream(t)):qi(t)?this.source=new ir(St.fromDOMStream(t)):_s(t)?this.source=new ir(St.fromDOMStream(t.body)):se(t)?this.source=new ir(St.fromIterable(t)):ne(t)?this.source=new ir(St.fromAsyncIterable(t)):Kt(t)&&(this.source=new ir(St.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},pc=class{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||nt)}return(t){return Object.create(this.source.return&&this.source.return(t)||nt)}},ir=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return g(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return g(this,arguments,void 0,function*(e,i="read"){return yield this.source.next({cmd:i,size:e})})}throw(t){return g(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||nt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return g(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||nt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var pn=class extends Fe{constructor(t,e){super(),this.position=0,this.buffer=D(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){let{buffer:e,byteOffset:i}=this.readAt(t,4);return new DataView(e,i).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){let{buffer:e,size:i,position:n}=this;return e&&n<i?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(i,n+Math.min(i-n,t)),e.subarray(n,this.position)):null}readAt(t,e){let i=this.buffer,n=Math.min(this.size,t+e);return i?i.subarray(t,n):new Uint8Array(e)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}},Tr=class extends te{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=g(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending})}readInt32(t){return g(this,void 0,void 0,function*(){let{buffer:e,byteOffset:i}=yield this.readAt(t,4);return new DataView(e,i).getInt32(0,!0)})}seek(t){return g(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return g(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:i,position:n}=this;if(e&&n<i){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=n,o=0,a=0,c=Math.min(i,s+Math.min(i-s,t)),l=new Uint8Array(Math.max(0,(this.position=c)-s));for(;(s+=a)<c&&(o+=a)<l.byteLength;)({bytesRead:a}=yield e.read(l,o,l.byteLength-o,s));return l}return null})}readAt(t,e){return g(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:i,size:n}=this;if(i&&t+e<n){let s=Math.min(n,t+e),o=new Uint8Array(s-t);return(yield i.read(o,0,e,t)).buffer}return new Uint8Array(e)})}close(){return g(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return g(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return g(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var yc={};Ue(yc,{BaseInt64:()=>mn,Int128:()=>yn,Int64:()=>nr,Uint64:()=>ct});function wi(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var Ii=8,mc=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],mn=class{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){let e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),i=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]),n=e[3]*i[3];this.buffer[0]=n&65535;let s=n>>>16;return n=e[2]*i[3],s+=n,n=e[3]*i[2]>>>0,s+=n,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<n?65536:0,this.buffer[1]+=s>>>16,this.buffer[1]+=e[1]*i[3]+e[2]*i[2]+e[3]*i[1],this.buffer[1]+=e[0]*i[3]+e[1]*i[2]+e[2]*i[1]+e[3]*i[0]<<16,this}_plus(t){let e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return`${wi(this.buffer[1])} ${wi(this.buffer[0])}`}},ct=class r extends mn{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let i=t.length,n=new r(e);for(let s=0;s<i;){let o=Ii<i-s?Ii:i-s,a=new r(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new r(new Uint32Array([mc[o],0]));n.times(c),n.plus(a),s+=o}return n}static convertArray(t){let e=new Uint32Array(t.length*2);for(let i=-1,n=t.length;++i<n;)r.from(t[i],new Uint32Array(e.buffer,e.byteOffset+2*i*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},nr=class r extends mn{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){let e=this.buffer[1]<<0,i=t.buffer[1]<<0;return e<i||e===i&&this.buffer[0]<t.buffer[0]}static from(t,e=new Uint32Array(2)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let i=t.startsWith("-"),n=t.length,s=new r(e);for(let o=i?1:0;o<n;){let a=Ii<n-o?Ii:n-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new r(new Uint32Array([mc[a],0]));s.times(l),s.plus(c),o+=a}return i?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*2);for(let i=-1,n=t.length;++i<n;)r.from(t[i],new Uint32Array(e.buffer,e.byteOffset+2*i*4,2));return e}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}},yn=class r{constructor(t){this.buffer=t}high(){return new nr(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new nr(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){let e=new ct(new Uint32Array([this.buffer[3],0])),i=new ct(new Uint32Array([this.buffer[2],0])),n=new ct(new Uint32Array([this.buffer[1],0])),s=new ct(new Uint32Array([this.buffer[0],0])),o=new ct(new Uint32Array([t.buffer[3],0])),a=new ct(new Uint32Array([t.buffer[2],0])),c=new ct(new Uint32Array([t.buffer[1],0])),l=new ct(new Uint32Array([t.buffer[0],0])),u=ct.multiply(s,l);this.buffer[0]=u.low();let d=new ct(new Uint32Array([u.high(),0]));return u=ct.multiply(n,l),d.plus(u),u=ct.multiply(s,c),d.plus(u),this.buffer[1]=d.low(),this.buffer[3]=d.lessThan(u)?1:0,this.buffer[2]=d.high(),new ct(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(ct.multiply(i,l)).plus(ct.multiply(n,c)).plus(ct.multiply(s,a)),this.buffer[3]+=ct.multiply(e,l).plus(ct.multiply(i,c)).plus(ct.multiply(n,a)).plus(ct.multiply(s,o)).low(),this}plus(t){let e=new Uint32Array(4);return e[3]=this.buffer[3]+t.buffer[3]>>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]<this.buffer[0]>>>0&&++e[1],e[1]<this.buffer[1]>>>0&&++e[2],e[2]<this.buffer[2]>>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${wi(this.buffer[3])} ${wi(this.buffer[2])} ${wi(this.buffer[1])} ${wi(this.buffer[0])}`}static multiply(t,e){return new r(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new r(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return r.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return r.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let i=t.startsWith("-"),n=t.length,s=new r(e);for(let o=i?1:0;o<n;){let a=Ii<n-o?Ii:n-o,c=new r(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new r(new Uint32Array([mc[a],0,0,0]));s.times(l),s.plus(c),o+=a}return i?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*4);for(let i=-1,n=t.length;++i<n;)r.from(t[i],new Uint32Array(e.buffer,e.byteOffset+16*i,4));return e}};var _c={};Ue(_c,{toIntervalDayTimeInt32Array:()=>gc,toIntervalDayTimeObjects:()=>Sp,toIntervalMonthDayNanoInt32Array:()=>bc,toIntervalMonthDayNanoObjects:()=>xp});function gc(r){var t,e;let i=r.length,n=new Int32Array(i*2);for(let s=0,o=0;s<i;s++){let a=r[s];n[o++]=(t=a.days)!==null&&t!==void 0?t:0,n[o++]=(e=a.milliseconds)!==null&&e!==void 0?e:0}return n}function bc(r){var t,e;let i=r.length,n=new Int32Array(i*4);for(let s=0,o=0;s<i;s++){let a=r[s];n[o++]=(t=a.months)!==null&&t!==void 0?t:0,n[o++]=(e=a.days)!==null&&e!==void 0?e:0;let c=a.nanoseconds;c?(n[o++]=Number(BigInt(c)&BigInt(4294967295)),n[o++]=Number(BigInt(c)>>BigInt(32))):o+=2}return n}function Sp(r){let t=r.length,e=new Array(t/2);for(let i=0,n=0;i<t;i+=2)e[n++]={days:r[i],milliseconds:r[i+1]};return e}function xp(r,t){let e=r.length,i=new Array(e/4);for(let n=0,s=0;n<e;n+=4){let o=BigInt(r[n+3])<<BigInt(32)|BigInt(r[n+2]>>>0);i[s++]={months:r[n],days:r[n+1],nanoseconds:t?`${o}`:o}}return i}var vi=class extends v{constructor(t,e,i,n,s=J.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=e,this.buffers=i,this.dictionaries=n,this.metadataVersion=s}visit(t){return super.visit(t instanceof C?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return L({type:t,length:e})}visitBool(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitInt(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitDate(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitTime(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitList(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),children:this.visitMany(t.children)})}visitUnion(t,{length:e,nullCount:i}=this.nextFieldNode()){return this.metadataVersion<J.V5&&this.readNullBitmap(t,i),t.mode===Z.Sparse?this.visitSparseUnion(t,{length:e,nullCount:i}):this.visitDenseUnion(t,{length:e,nullCount:i})}visitDenseUnion(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),child:this.visit(t.children[0])})}visitMap(t,{length:e,nullCount:i}=this.nextFieldNode()){return L({type:t,length:e,nullCount:i,nullBitmap:this.readNullBitmap(t,i),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,e,i=this.nextBufferRange()){return e>0&&this.readData(t,i)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:i}=this.nextBufferRange()){return this.bytes.subarray(i,i+e)}readDictionary(t){return this.dictionaries.get(t.id)}},go=class extends vi{constructor(t,e,i,n,s){super(new Uint8Array(0),e,i,n,s),this.sources=t}readNullBitmap(t,e,{offset:i}=this.nextBufferRange()){return e<=0?new Uint8Array(0):Wr(this.sources[i])}readOffsets(t,{offset:e}=this.nextBufferRange()){return R(Uint8Array,R(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return R(Uint8Array,R(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:i}=this;if(b.isTimestamp(t))return R(Uint8Array,nr.convertArray(i[e]));if((b.isInt(t)||b.isTime(t))&&t.bitWidth===64||b.isDuration(t))return R(Uint8Array,nr.convertArray(i[e]));if(b.isDate(t)&&t.unit===ut.MILLISECOND)return R(Uint8Array,nr.convertArray(i[e]));if(b.isDecimal(t))return R(Uint8Array,yn.convertArray(i[e]));if(b.isBinary(t)||b.isLargeBinary(t)||b.isFixedSizeBinary(t))return Tp(i[e]);if(b.isBool(t))return Wr(i[e]);if(b.isUtf8(t)||b.isLargeUtf8(t))return ve(i[e].join(""));if(b.isInterval(t))switch(t.unit){case et.DAY_TIME:return gc(i[e]);case et.MONTH_DAY_NANO:return bc(i[e]);default:break}return R(Uint8Array,R(t.ArrayType,i[e].map(n=>+n)))}};function Tp(r){let t=r.join(""),e=new Uint8Array(t.length/2);for(let i=0;i<t.length;i+=2)e[i>>1]=Number.parseInt(t.slice(i,i+2),16);return e}var bo=class extends vi{constructor(t,e,i,n,s){super(new Uint8Array(0),e,i,n,s),this.bodyChunks=t}readData(t,e=this.nextBufferRange()){return this.bodyChunks[this.buffersIndex]}};var Si=class extends Ct{constructor(t){super(t),this._values=new ge(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,D(e))}_flushPending(t,e){let i=this._offsets,n=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)i.set(o,0);else{let c=a.length;n.set(a,s),i.set(o,c),s+=c}}};var xi=class extends Ct{constructor(t){super(t),this._values=new ge(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,D(e))}_flushPending(t,e){let i=this._offsets,n=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)i.set(o,BigInt(0));else{let c=a.length;n.set(a,s),i.set(o,BigInt(c)),s+=c}}};var _o=class extends ot{constructor(t){super(t),this._values=new bi}setValue(t,e){this._values.set(t,+e)}};var Jr=class extends yt{};Jr.prototype._setValue=qa;var gn=class extends Jr{};gn.prototype._setValue=Vs;var bn=class extends Jr{};bn.prototype._setValue=Ps;var _n=class extends yt{};_n.prototype._setValue=Xa;var wo=class extends ot{constructor({type:t,nullValues:e,dictionaryHashFunction:i}){super({type:new $t(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=Kr({type:this.type.indices,nullValues:e}),this.dictionary=Kr({type:this.type.dictionary,nullValues:null}),typeof i=="function"&&(this.valueToKey=i)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(t){return this.indices.isValid(t)}setValid(t,e){let i=this.indices;return e=i.setValid(t,e),this.length=i.length,e}setValue(t,e){let i=this._keysToIndices,n=this.valueToKey(e),s=i[n];return s===void 0&&(i[n]=s=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,s)}flush(){let t=this.type,e=this._dictionary,i=this.dictionary.toVector(),n=this.indices.flush().clone(t);return n.dictionary=e?e.concat(i):i,this.finished||(this._dictionaryOffset+=i.length),this._dictionary=n.dictionary,this.clear(),n}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(t){return typeof t=="string"?t:`${t}`}};var wn=class extends yt{};wn.prototype._setValue=Ga;var Io=class extends ot{setValue(t,e){let[i]=this.children,n=t*this.stride;for(let s=-1,o=this.stride;++s<o;)i.set(n+s,e[s])}setValid(t,e){return super.setValid(t,e)||this.children[0].setValid((t+1)*this.stride-1,!1),e}addChild(t,e="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");let i=this.children.push(t);return this.type=new pe(this.type.listSize,new C(e,t.type,!0)),i}};var Xr=class extends yt{setValue(t,e){this._values.set(t,e)}},vo=class extends Xr{setValue(t,e){super.setValue(t,cn(e))}},So=class extends Xr{},xo=class extends Xr{};var Br=class extends yt{};Br.prototype._setValue=Ya;var In=class extends Br{};In.prototype._setValue=Ks;var vn=class extends Br{};vn.prototype._setValue=Xs;var Sn=class extends Br{};Sn.prototype._setValue=Ys;var sr=class extends yt{};sr.prototype._setValue=Za;var xn=class extends sr{};xn.prototype._setValue=Zs;var Tn=class extends sr{};Tn.prototype._setValue=Qs;var Bn=class extends sr{};Bn.prototype._setValue=to;var On=class extends sr{};On.prototype._setValue=eo;var ee=class extends yt{setValue(t,e){this._values.set(t,e)}},To=class extends ee{},Bo=class extends ee{},Oo=class extends ee{},Do=class extends ee{},Ao=class extends ee{},Fo=class extends ee{},No=class extends ee{},Eo=class extends ee{};var Lo=class extends Ct{constructor(t){super(t),this._offsets=new _i(t.type)}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new de(new C(e,t.type,!0)),this.numChildren-1}_flushPending(t){let e=this._offsets,[i]=this.children;for(let[n,s]of t)if(typeof s=="undefined")e.set(n,0);else{let o=s,a=o.length,c=e.set(n,a).buffer[n];for(let l=-1;++l<a;)i.set(c+l,o[l])}}};var Uo=class extends Ct{set(t,e){return super.set(t,e)}setValue(t,e){let i=e instanceof Map?e:new Map(Object.entries(e)),n=this._pending||(this._pending=new Map),s=n.get(t);s&&(this._pendingLength-=s.size),this._pendingLength+=i.size,n.set(t,i)}addChild(t,e=`${this.numChildren}`){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new me(new C(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){let e=this._offsets,[i]=this.children;for(let[n,s]of t)if(s===void 0)e.set(n,0);else{let{[n]:o,[n+1]:a}=e.set(n,s.size).buffer;for(let c of s.entries())if(i.set(o,c),++o>=a)break}}};var Mo=class extends ot{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var Ro=class extends ot{setValue(t,e){let{children:i,type:n}=this;switch(Array.isArray(e)||e.constructor){case!0:return n.children.forEach((s,o)=>i[o].set(t,e[o]));case Map:return n.children.forEach((s,o)=>i[o].set(t,e.get(s.name)));default:return n.children.forEach((s,o)=>i[o].set(t,e[s.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(i=>i.setValid(t,e)),e}addChild(t,e=`${this.numChildren}`){let i=this.children.push(t);return this.type=new it([...this.type.children,new C(e,t.type,!0)]),i}};var or=class extends yt{};or.prototype._setValue=Ja;var Dn=class extends or{};Dn.prototype._setValue=js;var An=class extends or{};An.prototype._setValue=zs;var Fn=class extends or{};Fn.prototype._setValue=Ws;var Nn=class extends or{};Nn.prototype._setValue=$s;var ar=class extends yt{};ar.prototype._setValue=Ka;var En=class extends ar{};En.prototype._setValue=Hs;var Ln=class extends ar{};Ln.prototype._setValue=Gs;var Un=class extends ar{};Un.prototype._setValue=qs;var Mn=class extends ar{};Mn.prototype._setValue=Js;var Ti=class extends ot{constructor(t){super(t),this._typeIds=new tr(Int8Array,0,1),typeof t.valueToChildTypeId=="function"&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,i){return i===void 0&&(i=this._valueToChildTypeId(this,e,t)),this.setValue(t,e,i),this}setValue(t,e,i){this._typeIds.set(t,i);let n=this.type.typeIdToChildIndex[i],s=this.children[n];s==null||s.set(t,e),this.length=Math.max(t+1,this.length)}addChild(t,e=`${this.children.length}`){let i=this.children.push(t),{type:{children:n,mode:s,typeIds:o}}=this,a=[...n,new C(e,t.type)];return this.type=new he(s,[...o,i],a),i}_valueToChildTypeId(t,e,i){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},Co=class extends Ti{},ko=class extends Ti{constructor(t){super(t),this._offsets=new tr(Int32Array)}setValue(t,e,i){let n=this._typeIds.set(t,i).buffer[t],s=this.getChildAt(this.type.typeIdToChildIndex[n]),o=this._offsets.set(t,s.length).buffer[t];s==null||s.set(o,e),this.length=Math.max(t+1,this.length)}};var Rn=class extends Ct{constructor(t){super(t),this._values=new ge(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,ve(e))}_flushPending(t,e){}};Rn.prototype._flushPending=Si.prototype._flushPending;var Cn=class extends Ct{constructor(t){super(t),this._values=new ge(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,ve(e))}_flushPending(t,e){}};Cn.prototype._flushPending=xi.prototype._flushPending;var wc=class extends v{visitNull(){return Mo}visitBool(){return _o}visitInt(){return ee}visitInt8(){return To}visitInt16(){return Bo}visitInt32(){return Oo}visitInt64(){return Do}visitUint8(){return Ao}visitUint16(){return Fo}visitUint32(){return No}visitUint64(){return Eo}visitFloat(){return Xr}visitFloat16(){return vo}visitFloat32(){return So}visitFloat64(){return xo}visitUtf8(){return Rn}visitLargeUtf8(){return Cn}visitBinary(){return Si}visitLargeBinary(){return xi}visitFixedSizeBinary(){return wn}visitDate(){return Jr}visitDateDay(){return gn}visitDateMillisecond(){return bn}visitTimestamp(){return or}visitTimestampSecond(){return Dn}visitTimestampMillisecond(){return An}visitTimestampMicrosecond(){return Fn}visitTimestampNanosecond(){return Nn}visitTime(){return ar}visitTimeSecond(){return En}visitTimeMillisecond(){return Ln}visitTimeMicrosecond(){return Un}visitTimeNanosecond(){return Mn}visitDecimal(){return _n}visitList(){return Lo}visitStruct(){return Ro}visitUnion(){return Ti}visitDenseUnion(){return ko}visitSparseUnion(){return Co}visitDictionary(){return wo}visitInterval(){return Br}visitIntervalDayTime(){return In}visitIntervalYearMonth(){return vn}visitIntervalMonthDayNano(){return Sn}visitDuration(){return sr}visitDurationSecond(){return xn}visitDurationMillisecond(){return Tn}visitDurationMicrosecond(){return Bn}visitDurationNanosecond(){return On}visitFixedSizeList(){return Io}visitMap(){return Uo}},Bf=new wc;var B=class extends v{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((i,n)=>this.compareFields(i,e[n]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}};function Et(r,t){return t instanceof r.constructor}function Yr(r,t){return r===t||Et(r,t)}function cr(r,t){return r===t||Et(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function Vo(r,t){return r===t||Et(r,t)&&r.precision===t.precision}function Bp(r,t){return r===t||Et(r,t)&&r.byteWidth===t.byteWidth}function Ic(r,t){return r===t||Et(r,t)&&r.unit===t.unit}function kn(r,t){return r===t||Et(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function Vn(r,t){return r===t||Et(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function Op(r,t){return r===t||Et(r,t)&&r.children.length===t.children.length&&Ne.compareManyFields(r.children,t.children)}function Dp(r,t){return r===t||Et(r,t)&&r.children.length===t.children.length&&Ne.compareManyFields(r.children,t.children)}function vc(r,t){return r===t||Et(r,t)&&r.mode===t.mode&&r.typeIds.every((e,i)=>e===t.typeIds[i])&&Ne.compareManyFields(r.children,t.children)}function Ap(r,t){return r===t||Et(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&Ne.visit(r.indices,t.indices)&&Ne.visit(r.dictionary,t.dictionary)}function Po(r,t){return r===t||Et(r,t)&&r.unit===t.unit}function Pn(r,t){return r===t||Et(r,t)&&r.unit===t.unit}function Fp(r,t){return r===t||Et(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&Ne.compareManyFields(r.children,t.children)}function Np(r,t){return r===t||Et(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&Ne.compareManyFields(r.children,t.children)}B.prototype.visitNull=Yr;B.prototype.visitBool=Yr;B.prototype.visitInt=cr;B.prototype.visitInt8=cr;B.prototype.visitInt16=cr;B.prototype.visitInt32=cr;B.prototype.visitInt64=cr;B.prototype.visitUint8=cr;B.prototype.visitUint16=cr;B.prototype.visitUint32=cr;B.prototype.visitUint64=cr;B.prototype.visitFloat=Vo;B.prototype.visitFloat16=Vo;B.prototype.visitFloat32=Vo;B.prototype.visitFloat64=Vo;B.prototype.visitUtf8=Yr;B.prototype.visitLargeUtf8=Yr;B.prototype.visitBinary=Yr;B.prototype.visitLargeBinary=Yr;B.prototype.visitFixedSizeBinary=Bp;B.prototype.visitDate=Ic;B.prototype.visitDateDay=Ic;B.prototype.visitDateMillisecond=Ic;B.prototype.visitTimestamp=kn;B.prototype.visitTimestampSecond=kn;B.prototype.visitTimestampMillisecond=kn;B.prototype.visitTimestampMicrosecond=kn;B.prototype.visitTimestampNanosecond=kn;B.prototype.visitTime=Vn;B.prototype.visitTimeSecond=Vn;B.prototype.visitTimeMillisecond=Vn;B.prototype.visitTimeMicrosecond=Vn;B.prototype.visitTimeNanosecond=Vn;B.prototype.visitDecimal=Yr;B.prototype.visitList=Op;B.prototype.visitStruct=Dp;B.prototype.visitUnion=vc;B.prototype.visitDenseUnion=vc;B.prototype.visitSparseUnion=vc;B.prototype.visitDictionary=Ap;B.prototype.visitInterval=Po;B.prototype.visitIntervalDayTime=Po;B.prototype.visitIntervalYearMonth=Po;B.prototype.visitIntervalMonthDayNano=Po;B.prototype.visitDuration=Pn;B.prototype.visitDurationSecond=Pn;B.prototype.visitDurationMillisecond=Pn;B.prototype.visitDurationMicrosecond=Pn;B.prototype.visitDurationNanosecond=Pn;B.prototype.visitFixedSizeList=Fp;B.prototype.visitMap=Np;var Ne=new B;function Zr(r,t){return Ne.compareSchemas(r,t)}function Of(r,t){return Ne.compareFields(r,t)}function Df(r,t){return Ne.visit(r,t)}function Kr(r){let t=r.type,e=new(Bf.getVisitFn(t)())(r);if(t.children&&t.children.length>0){let i=r.children||[],n={nullValues:r.nullValues},s=Array.isArray(i)?((o,a)=>i[a]||n):(({name:o})=>i[o]||n);for(let[o,a]of t.children.entries()){let{type:c}=a,l=s(a,o);e.children.push(Kr(Object.assign(Object.assign({},l),{type:c})))}}return e}function jo(r,t){return Ep(r,t.map(e=>e.data.concat()))}function Ep(r,t){let e=[...r.fields],i=[],n={numBatches:t.reduce((d,p)=>Math.max(d,p.length),0)},s=0,o=0,a=-1,c=t.length,l,u=[];for(;n.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a<c;)u[a]=l=t[a].shift(),o=Math.min(o,l?l.length:o);Number.isFinite(o)&&(u=Lp(e,o,u,t,n),o>0&&(i[s++]=L({type:new it(e),length:o,nullCount:0,children:u.slice()})))}return[r=r.assign(e),i.map(d=>new ft(r,d))]}function Lp(r,t,e,i,n){var s;let o=(t+63&-64)>>3;for(let a=-1,c=i.length;++a<c;){let l=e[a],u=l==null?void 0:l.length;if(u>=t)u===t?e[a]=l:(e[a]=l.slice(0,t),n.numBatches=Math.max(n.numBatches,i[a].unshift(l.slice(t,u-t))));else{let d=r[a];r[a]=d.clone({nullable:!0}),e[a]=(s=l==null?void 0:l._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:L({type:d.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var Af,_e=class r{constructor(...t){var e,i;if(t.length===0)return this.batches=[],this.schema=new K([]),this._offsets=[0],this;let n,s;t[0]instanceof K&&(n=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=c=>{if(c){if(c instanceof ft)return[c];if(c instanceof r)return c.batches;if(c instanceof G){if(c.type instanceof it)return[new ft(new K(c.type.children),c)]}else{if(Array.isArray(c))return c.flatMap(l=>o(l));if(typeof c[Symbol.iterator]=="function")return[...c].flatMap(l=>o(l));if(typeof c=="object"){let l=Object.keys(c),u=l.map(m=>new P([c[m]])),d=n!=null?n:new K(l.map((m,_)=>new C(String(m),u[_].type,u[_].nullable))),[,p]=jo(d,u);return p.length===0?[new ft(c)]:p}}}return[]},a=t.flatMap(c=>o(c));if(n=(i=n!=null?n:(e=a[0])===null||e===void 0?void 0:e.schema)!==null&&i!==void 0?i:new K([]),!(n instanceof K))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof ft))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Zr(n,c.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=n,this.batches=a,this._offsets=s!=null?s:oo(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,e)=>t+e.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=so(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(Pr(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?gi.visit(new P(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
|
|
18
18
|
${this.toArray().join(`,
|
|
19
19
|
`)}
|
|
20
|
-
]`}concat(...t){let e=this.schema,i=this.data.concat(t.flatMap(({data:n})=>n));return new r(e,i.map(n=>new ft(e,n)))}slice(t,e){let i=this.schema;[t,e]=ln({length:this.numRows},t,e);let n=ao(this.data,this._offsets,t,e);return new r(i,n.map(s=>new ft(i,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){let e=this.data.map(i=>i.children[t]);if(e.length===0){let{type:i}=this.schema.fields[t],n=L({type:i,length:0,nullCount:0});e.push(n._changeLengthAndBackfillNullBitmap(this.numRows))}return new P(e)}return null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new P([L({type:new Nt,length:this.numRows})]));let s=i.fields.slice(),o=s[t].clone({type:e.type}),a=this.schema.fields.map((c,l)=>this.getChildAt(l));[s[t],a[t]]=[o,e],[i,n]=jo(i,a)}return new r(i,n)}select(t){let e=this.schema.fields.reduce((i,n,s)=>i.set(n.name,s),new Map);return this.selectAt(t.map(i=>e.get(i)).filter(i=>i>-1))}selectAt(t){let e=this.schema.selectAt(t),i=this.batches.map(n=>n.selectAt(t));return new r(e,i)}assign(t){let e=this.schema.fields,[i,n]=t.schema.fields.reduce((a,c,l)=>{let[u,d]=a,p=e.findIndex(m=>m.name===c.name);return~p?d[p]=l:u.push(l),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,n[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...i.map(a=>t.getChildAt(a))].filter(Boolean);return new r(...jo(s,o))}};Af=Symbol.toStringTag;_e[Af]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=yi(dn),r.get=yi(mt.getVisitFn(f.Struct)),r.set=co(Tt.getVisitFn(f.Struct)),r.indexOf=lo($r.getVisitFn(f.Struct)),"Table"))(_e.prototype);var Nf,ft=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof K))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=L({nullCount:0,type:new it(this.schema.fields),children:this.schema.fields.map(e=>L({type:e.type,nullCount:0}))})]=t,!(this.data instanceof G))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Ff(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:i,children:n,length:s}=Object.keys(e).reduce((c,l,u)=>(c.children[u]=e[l],c.length=Math.max(c.length,e[l].length),c.fields[u]=C.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new K(i),a=L({type:new it(i),length:s,children:n,nullCount:0});[this.schema,this.data]=Ff(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=Ef(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return mt.visit(this.data,t)}at(t){return this.get(Pr(t,this.numRows))}set(t,e){return Tt.visit(this.data,t,e)}indexOf(t,e){return $r.visit(this.data,t,e)}[Symbol.iterator](){return gi.visit(new P([this.data]))}toArray(){return[...this]}concat(...t){return new _e(this.schema,[this,...t])}slice(t,e){let[i]=new P([this.data]).slice(t,e).data;return new r(this.schema,i)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(i=>i.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new P([this.data.children[t]]):null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=this.data;if(t>-1&&t<this.numCols){e||(e=new P([L({type:new Nt,length:this.numRows})]));let s=i.fields.slice(),o=n.children.slice(),a=s[t].clone({type:e.type});[s[t],o[t]]=[a,e.data[0]],i=new K(s,new Map(this.schema.metadata)),n=L({type:new it(s),children:o})}return new r(i,n)}select(t){let e=this.schema.select(t),i=new it(e.fields),n=[];for(let s of t){let o=this.schema.fields.findIndex(a=>a.name===s);~o&&(n[o]=this.data.children[o])}return new r(e,L({type:i,length:this.numRows,children:n}))}selectAt(t){let e=this.schema.selectAt(t),i=t.map(s=>this.data.children[s]).filter(Boolean),n=L({type:new it(e.fields),length:this.numRows,children:i});return new r(e,n)}};Nf=Symbol.toStringTag;ft[Nf]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(ft.prototype);function Ff(r,t,e=t.reduce((i,n)=>Math.max(i,n.length),0)){var i;let n=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(let[a,c]of r.fields.entries()){let l=t[a];(!l||l.length!==e)&&(n[a]=c.clone({nullable:!0}),s[a]=(i=l==null?void 0:l._changeLengthAndBackfillNullBitmap(e))!==null&&i!==void 0?i:L({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(n),L({type:new it(n),length:e,children:s})]}function Ef(r,t,e=new Map){var i,n;if(((i=r==null?void 0:r.length)!==null&&i!==void 0?i:0)>0&&(r==null?void 0:r.length)===(t==null?void 0:t.length))for(let s=-1,o=r.length;++s<o;){let{type:a}=r[s],c=t[s];for(let l of[c,...((n=c==null?void 0:c.dictionary)===null||n===void 0?void 0:n.data)||[]])Ef(a.children,l==null?void 0:l.children,e);if(b.isDictionary(a)){let{id:l}=a;if(!e.has(l))c!=null&&c.dictionary&&e.set(l,c.dictionary);else if(e.get(l)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var Qr=class extends ft{constructor(t){let e=t.fields.map(n=>L({type:n.type})),i=L({type:new it(t.fields),nullCount:0,children:e});super(t,i)}};var xc=r=>`Expected ${V[r]} Message in stream, but was null or length 0.`,Tc=r=>`Header pointer of flatbuffer-encoded ${V[r]} Message is null or length 0.`,Lf=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,Uf=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Bi=class{constructor(t){this.source=t instanceof Fe?t:new Fe(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?nt:t.value===-1&&(t=this.readMetadataLength()).done?nt:(t=this.readMetadata(t.value)).done?nt:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(xc(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=D(this.source.read(t));if(e.byteLength<t)throw new Error(Uf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=V.Schema,i=this.readMessage(e),n=i==null?void 0:i.header();if(t&&!n)throw new Error(Tc(e));return n}readMetadataLength(){let t=this.source.read(zo),e=t&&new xt(t),i=(e==null?void 0:e.readInt32(0))||0;return{done:i===0,value:i}}readMetadata(t){let e=this.source.read(t);if(!e)return nt;if(e.byteLength<t)throw new Error(Lf(t,e.byteLength));return{done:!1,value:kt.decode(e)}}},jn=class{constructor(t,e){this.source=t instanceof te?t:bs(t)?new Tr(t,e):new te(t)}[Symbol.asyncIterator](){return this}next(){return g(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?nt:t.value===-1&&(t=yield this.readMetadataLength()).done?nt:(t=yield this.readMetadata(t.value)).done?nt:t})}throw(t){return g(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return g(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return g(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(xc(t));return e.value})}readMessageBody(t){return g(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=D(yield this.source.read(t));if(e.byteLength<t)throw new Error(Uf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return g(this,arguments,void 0,function*(t=!1){let e=V.Schema,i=yield this.readMessage(e),n=i==null?void 0:i.header();if(t&&!n)throw new Error(Tc(e));return n})}readMetadataLength(){return g(this,void 0,void 0,function*(){let t=yield this.source.read(zo),e=t&&new xt(t),i=(e==null?void 0:e.readInt32(0))||0;return{done:i===0,value:i}})}readMetadata(t){return g(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return nt;if(e.byteLength<t)throw new Error(Lf(t,e.byteLength));return{done:!1,value:kt.decode(e)}})}},zn=class extends Bi{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof hn?t:new hn(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:kt.fromJSON(t.schema,V.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:kt.fromJSON(e,V.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:kt.fromJSON(e,V.RecordBatch)}}return this._body=[],nt}readMessageBody(t){return e(this._body);function e(i){return(i||[]).reduce((n,s)=>[...n,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(xc(t));return e.value}readSchema(){let t=V.Schema,e=this.readMessage(t),i=e==null?void 0:e.header();if(!e||!i)throw new Error(Tc(t));return i}},zo=4,Sc="ARROW1",Oi=new Uint8Array(Sc.length);for(let r=0;r<Sc.length;r+=1)Oi[r]=Sc.codePointAt(r);function Wo(r,t=0){for(let e=-1,i=Oi.length;++e<i;)if(Oi[e]!==r[t+e])return!1;return!0}var Di=Oi.length,Bc=Di+zo,Mf=Di*2+zo;var Oc=class{constructor(){this.LZ4_FRAME_MAGIC=new Uint8Array([4,34,77,24]),this.MIN_HEADER_LENGTH=7}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),i=t.encode(e);return this._isValidCompressed(i)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)&&this._hasValidVersion(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.LZ4_FRAME_MAGIC.every((e,i)=>t[i]===e)}_hasValidVersion(t){return(t[4]&192)>>6===1}},Dc=class{constructor(){this.ZSTD_MAGIC=new Uint8Array([40,181,47,253]),this.MIN_HEADER_LENGTH=6}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),i=t.encode(e);return this._isValidCompressed(i)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.ZSTD_MAGIC.every((e,i)=>t[i]===e)}},Rf={[Ft.LZ4_FRAME]:new Oc,[Ft.ZSTD]:new Dc};var Ac=class{constructor(){this.registry={}}set(t,e){if(e!=null&&e.encode&&typeof e.encode=="function"&&!Rf[t].isValidCodecEncode(e))throw new Error(`Encoder for ${Ft[t]} is not valid.`);this.registry[t]=e}get(t){var e;return((e=this.registry)===null||e===void 0?void 0:e[t])||null}},Ai=new Ac;var Vt=class r extends qr{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){let e=this._impl.open(t);return ne(e)?e.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return St.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return St.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof r?t:ys(t)?Rp(t):bs(t)?Vp(t):ne(t)?g(this,void 0,void 0,function*(){return yield r.from(yield t)}):_s(t)||qi(t)||Is(t)||Kt(t)?kp(new te(t)):Cp(new Fe(t))}static readAll(t){return t instanceof r?t.isSync()?Cf(t):kf(t):ys(t)||ArrayBuffer.isView(t)||se(t)||gs(t)?Cf(t):kf(t)}},Ee=class extends Vt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return zt(this,arguments,function*(){yield U(yield*ni(ie(this[Symbol.iterator]())))})}},Or=class extends Vt{constructor(t){super(t),this._impl=t}readAll(){return g(this,void 0,void 0,function*(){var t,e,i,n;let s=new Array;try{for(var o=!0,a=ie(this),c;c=yield a.next(),t=c.done,!t;o=!0){n=c.value,o=!1;let l=n;s.push(l)}}catch(l){e={error:l}}finally{try{!o&&!t&&(i=a.return)&&(yield i.call(a))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Dr=class extends Ee{constructor(t){super(t),this._impl=t}},Wn=class extends Or{constructor(t){super(t),this._impl=t}},$o=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){let i;if(t.compression!=null){let s=Ai.get(t.compression.type);if(s!=null&&s.decode&&typeof s.decode=="function"){let{decommpressedBody:o,buffers:a}=this._decompressBuffers(t,e,s);i=this._loadCompressedVectors(t,o,this.schema.fields),t=new bt(t.length,t.nodes,a,null)}else throw new Error("Record batch is compressed but codec not found")}else i=this._loadVectors(t,e,this.schema.fields);let n=L({type:new it(this.schema.fields),length:t.length,children:i});return new ft(this.schema,n)}_loadDictionaryBatch(t,e){let{id:i,isDelta:n}=t,{dictionaries:s,schema:o}=this,a=s.get(i),c=o.dictionaries.get(i),l;if(t.data.compression!=null){let u=Ai.get(t.data.compression.type);if(u!=null&&u.decode&&typeof u.decode=="function"){let{decommpressedBody:d,buffers:p}=this._decompressBuffers(t.data,e,u);l=this._loadCompressedVectors(t.data,d,[c]),t=new Ot(new bt(t.data.length,t.data.nodes,p,null),i,n)}else throw new Error("Dictionary batch is compressed but codec not found")}else l=this._loadVectors(t.data,e,[c]);return(a&&n?a.concat(new P(l)):new P(l)).memoize()}_loadVectors(t,e,i){return new vi(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}_loadCompressedVectors(t,e,i){return new bo(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}_decompressBuffers(t,e,i){let n=[],s=[],o=0;for(let{offset:a,length:c}of t.buffers){if(c===0){n.push(new Uint8Array(0)),s.push(new gt(o,0));continue}let l=new xt(e.subarray(a,a+c)),u=W(l.readInt64(0)),d=l.bytes().subarray(8),p=u===-1?d:i.decode(d);n.push(p);let m=(o+7&-8)-o;o+=m,s.push(new gt(o,p.length)),o+=p.length}return{decommpressedBody:n,buffers:s}}},Fi=class extends $o{constructor(t,e){super(e),this._reader=ys(t)?new zn(this._handle=t):new Bi(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=Pf(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):nt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):nt}next(){if(this.closed)return nt;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let i=t.header(),n=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let i=t.header(),n=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Qr(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Ni=class extends $o{constructor(t,e){super(e),this._reader=new jn(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return g(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return g(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Pf(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):nt})}return(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):nt})}next(){return g(this,void 0,void 0,function*(){if(this.closed)return nt;let t,{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let i=t.header(),n=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let i=t.header(),n=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Qr(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Ho=class extends Fi{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof pn?t:new pn(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(V.RecordBatch);if(n!=null&&n.isRecordBatch()){let s=n.header(),o=this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(V.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let s=n.header(),o=this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-Bc,i=t.readInt32(e),n=t.readAt(e-i,i);return er.decode(n)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(i&&this._handle.seek(i.offset))return this._reader.readMessage(t)}return null}},Fc=class extends Ni{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let i=typeof e[0]!="number"?e.shift():void 0,n=e[0]instanceof Map?e.shift():void 0;super(t instanceof Tr?t:new Tr(t,i),n)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return g(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return g(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.RecordBatch);if(n!=null&&n.isRecordBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return g(this,void 0,void 0,function*(){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return g(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Bc,i=yield t.readInt32(e),n=yield t.readAt(e-i,i);return er.decode(n)})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},Nc=class extends Fi{constructor(t,e){super(t,e)}_loadVectors(t,e,i){return new go(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}};function Pf(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Cf(r){let t=Vt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function kf(r){return zt(this,arguments,function*(){let e=yield U(Vt.from(r));try{if(!(yield U(e.open({autoDestroy:!1}))).closed)do yield yield U(e);while(!(yield U(e.reset().open())).closed)}finally{yield U(e.cancel())}})}function Rp(r){return new Ee(new Nc(r))}function Cp(r){let t=r.peek(Di+7&-8);return t&&t.byteLength>=4?Wo(t)?new Dr(new Ho(r.read())):new Ee(new Fi(r)):new Ee(new Fi((function*(){})()))}function kp(r){return g(this,void 0,void 0,function*(){let t=yield r.peek(Di+7&-8);return t&&t.byteLength>=4?Wo(t)?new Dr(new Ho(yield r.read())):new Or(new Ni(r)):new Or(new Ni((function(){return zt(this,arguments,function*(){})})()))})}function Vp(r){return g(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Tr(r,t);return t>=Mf&&Wo(yield e.readAt(0,Di+7&-8))?new Wn(new Fc(e)):new Or(new Ni(e))})}var lt=class r extends v{static assemble(...t){let e=n=>n.flatMap(s=>Array.isArray(s)?e(s):s instanceof ft?s.data.children:s.data),i=new r;return i.visitMany(e(t)),i}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof P)return this.visitMany(t.data),this;let{type:e}=t;if(!b.isDictionary(e)){let{length:i}=t;if(i>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(b.isUnion(e))this.nodes.push(new Qt(i,0));else{let{nullCount:n}=t;b.isNull(e)||we.call(this,n<=0?new Uint8Array(0):zr(t.offset,i,t.nullBitmap)),this.nodes.push(new Qt(i,n))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function we(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new gt(this._byteLength,t)),this._byteLength+=t,this}function Pp(r){var t;let{type:e,length:i,typeIds:n,valueOffsets:s}=r;if(we.call(this,n),e.mode===Z.Sparse)return Ec.call(this,r);if(e.mode===Z.Dense){if(r.offset<=0)return we.call(this,s),Ec.call(this,r);{let o=new Int32Array(i),a=Object.create(null),c=Object.create(null);for(let l,u,d=-1;++d<i;)(l=n[d])!==void 0&&((u=a[l])===void 0&&(u=a[l]=s[d]),o[d]=s[d]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);we.call(this,o),this.visitMany(r.children.map((l,u)=>{let d=e.typeIds[u],p=a[d],m=c[d];return l.slice(p,Math.min(i,m))}))}}return this}function jp(r){let t;return r.nullCount>=r.length?we.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?we.call(this,zr(r.offset,r.length,t)):we.call(this,Wr(r.values))}function lr(r){return we.call(this,r.values.subarray(0,r.length*r.stride))}function Go(r){let{length:t,values:e,valueOffsets:i}=r,n=W(i[0]),s=W(i[t]),o=Math.min(s-n,e.byteLength-n);return we.call(this,Ss(-n,t+1,i)),we.call(this,e.subarray(n,n+o)),this}function Lc(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:i,[t]:n}=e;return we.call(this,Ss(-i,t+1,e)),this.visit(r.children[0].slice(i,n-i))}return this.visit(r.children[0])}function Ec(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}lt.prototype.visitBool=jp;lt.prototype.visitInt=lr;lt.prototype.visitFloat=lr;lt.prototype.visitUtf8=Go;lt.prototype.visitLargeUtf8=Go;lt.prototype.visitBinary=Go;lt.prototype.visitLargeBinary=Go;lt.prototype.visitFixedSizeBinary=lr;lt.prototype.visitDate=lr;lt.prototype.visitTimestamp=lr;lt.prototype.visitTime=lr;lt.prototype.visitDecimal=lr;lt.prototype.visitList=Lc;lt.prototype.visitStruct=Ec;lt.prototype.visitUnion=Pp;lt.prototype.visitInterval=lr;lt.prototype.visitDuration=lr;lt.prototype.visitFixedSizeList=Lc;lt.prototype.visitMap=Lc;var ti=class extends qr{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){if(super(),this._position=0,this._started=!1,this._compression=null,this._sink=new Ae,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,At(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1,compressionType:null}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1,t.compressionType!=null){if(this._writeLegacyIpcFormat)throw new Error("Legacy IPC format does not support columnar compression. Use modern IPC format (writeLegacyIpcFormat=false).");if(Object.values(Ft).includes(t.compressionType))this._compression=new Gr(t.compressionType);else{let e=Object.values(Ft).filter(i=>typeof i=="string");throw new Error(`Unsupported compressionType: ${t.compressionType} Available types: ${e.join(", ")}`)}}else this._compression=null}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return ne(t)?t.then(e=>this.writeAll(e)):Kt(t)?Mc(this,t):Uc(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){return t===this._sink||t instanceof Ae?this._sink=t:(this._sink=new Ae,t&&Kl(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Xl(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!e||!Zr(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof _e&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof ft&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!Zr(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof ft?t instanceof Qr||this._writeRecordBatch(t):t instanceof _e?this.writeAll(t.batches):se(t)&&this.writeAll(t)}_writeMessage(t,e=8){let i=e-1,n=kt.encode(t),s=n.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+i&~i,c=a-s-o;return t.headerType===V.RecordBatch?this._recordBatchBlocks.push(new rr(a,t.bodyLength,this._position)):t.headerType===V.DictionaryBatch&&this._dictionaryBlocks.push(new rr(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(n),this._writePadding(c)}_write(t){if(this._started){let e=D(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(kt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Oi)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:i,bufferRegions:n,buffers:s}=this._assembleRecordBatch(t),o=new bt(t.numRows,i,n,this._compression),a=kt.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_assembleRecordBatch(t){let{byteLength:e,nodes:i,bufferRegions:n,buffers:s}=lt.assemble(t);return this._compression!=null&&({byteLength:e,bufferRegions:n,buffers:s}=this._compressBodyBuffers(s)),{byteLength:e,nodes:i,bufferRegions:n,buffers:s}}_compressBodyBuffers(t){let e=Ai.get(this._compression.type);if(!(e!=null&&e.encode)||typeof e.encode!="function")throw new Error(`Codec for compression type "${Ft[this._compression.type]}" has invalid encode method`);let i=0,n=[],s=[];for(let a of t){let c=D(a);if(c.length===0){n.push(new Uint8Array(0),new Uint8Array(0)),s.push(new gt(i,0));continue}let l=e.encode(c),u=l.length<c.length,d=u?l:c,p=u?d.length:-1,m=new xt(new Uint8Array(8));m.writeInt64(0,BigInt(p)),n.push(m.bytes(),new Uint8Array(d));let _=(i+7&-8)-i;i+=_;let j=8+d.length;s.push(new gt(i,j)),i+=j}let o=(i+7&-8)-i;return i+=o,{byteLength:i,bufferRegions:s,buffers:n}}_writeDictionaryBatch(t,e,i=!1){let{byteLength:n,nodes:s,bufferRegions:o,buffers:a}=this._assembleRecordBatch(new P([t])),c=new bt(t.length,s,o,this._compression),l=new Ot(c,e,i),u=kt.from(l,n);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e=this._compression!=null?2:1,i=new Array(e);for(let n=0;n<t.length;n+=e){let s=0;for(let a=-1;++a<e;)i[a]=t[n+a],s+=i[a].byteLength;if(s===0)continue;for(let a of i)this._write(a);let o=(s+7&-8)-s;o>0&&this._writePadding(o)}return this}_writeDictionaries(t){var e,i;for(let[n,s]of t.dictionaries){let o=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(n),c=(i=this._dictionaryDeltaOffsets.get(n))!==null&&i!==void 0?i:0;if(!a||a.data[0]!==o[0])for(let[l,u]of o.entries())this._writeDictionaryBatch(u,n,l>0);else if(c<o.length)for(let l of o.slice(c))this._writeDictionaryBatch(l,n,!0);this._seenDictionaries.set(n,s),this._dictionaryDeltaOffsets.set(n,o.length)}return this}},$n=class r extends ti{static writeAll(t,e){let i=new r(e);return ne(t)?t.then(n=>i.writeAll(n)):Kt(t)?Mc(i,t):Uc(i,t)}},Hn=class r extends ti{static writeAll(t,e){let i=new r(e);return ne(t)?t.then(n=>i.writeAll(n)):Kt(t)?Mc(i,t):Uc(i,t)}constructor(t){super(t),this._autoDestroy=!0,this._writeLegacyIpcFormat=!1}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,i=!1){if(!i&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,i)}_writeFooter(t){let e=er.encode(new er(t,J.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Uc(r,t){let e=t;t instanceof _e&&(e=t.batches,r.reset(void 0,t.schema));for(let i of e)r.write(i);return r.finish()}function Mc(r,t){return g(this,void 0,void 0,function*(){var e,i,n,s,o,a,c;try{for(e=!0,i=ie(t);n=yield i.next(),s=n.done,!s;e=!0){c=n.value,e=!1;let l=c;r.write(l)}}catch(l){o={error:l}}finally{try{!e&&!s&&(a=i.return)&&(yield a.call(i))}finally{if(o)throw o.error}}return r.finish()})}function jf(r,t){if(Kt(r))return Wp(r,t);if(se(r))return zp(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function zp(r,t){let e=null,i=(t==null?void 0:t.type)==="bytes"||!1,n=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){s(o,e||(e=r[Symbol.iterator]()))},pull(o){e?s(o,e):o.close()},cancel(){e!=null&&e.return&&e.return(),e=null}}),Object.assign({highWaterMark:i?n:void 0},t));function s(o,a){let c,l=null,u=o.desiredSize||null;for(;!(l=a.next(i?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=D(l.value))&&(u!=null&&i&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()}}function Wp(r,t){let e=null,i=(t==null?void 0:t.type)==="bytes"||!1,n=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return g(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return g(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return g(this,void 0,void 0,function*(){e!=null&&e.return&&(yield e.return()),e=null})}}),Object.assign({highWaterMark:i?n:void 0},t));function s(o,a){return g(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(i?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=D(l.value))&&(u!=null&&i&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()})}}function $f(r){return new Rc(r)}var Rc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:i,["queueingStrategy"]:n="count"}=t,s=Gl(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Kr(s),this._getSize=n!=="bytes"?zf:Wf;let{["highWaterMark"]:o=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},i);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:c=>{this._maybeFlush(this._builder,this._controller=c)},start:c=>{this._maybeFlush(this._builder,this._controller=c)}},{highWaterMark:o,size:n!=="bytes"?zf:Wf}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:c=>this._writeValueAndReturnChunkSize(c)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},zf=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Wf=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function qo(r,t){let e=new Ae,i=null,n=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield e.close()})},start(a){return g(this,void 0,void 0,function*(){yield o(a,i||(i=yield s()))})},pull(a){return g(this,void 0,void 0,function*(){i?yield o(a,i):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:n};function s(){return g(this,void 0,void 0,function*(){return yield(yield Vt.from(e)).open(t)})}function o(a,c){return g(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}function Jo(r,t){let e=new this(r),i=new te(e),n=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield i.cancel()})},pull(o){return g(this,void 0,void 0,function*(){yield s(o)})},start(o){return g(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:n};function s(o){return g(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield i.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}var $p=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Wa),yc),sc),$a),Ra),nc),Va),_c),{compareSchemas:Zr,compareFields:Of,compareTypes:Df});St.toDOMStream=jf;ot.throughDOM=$f;Vt.throughDOM=qo;Dr.throughDOM=qo;Ee.throughDOM=qo;ti.throughDOM=Jo;Hn.throughDOM=Jo;$n.throughDOM=Jo;var Cc=class extends rt{constructor(){super("google.protobuf.Timestamp",[{no:1,name:"seconds",kind:"scalar",T:3,L:0},{no:2,name:"nanos",kind:"scalar",T:5}])}now(){let t=this.create(),e=Date.now();return t.seconds=X.from(Math.floor(e/1e3)).toBigInt(),t.nanos=e%1e3*1e6,t}toDate(t){return new Date(X.from(t.seconds).toNumber()*1e3+Math.ceil(t.nanos/1e6))}fromDate(t){let e=this.create(),i=t.getTime();return e.seconds=X.from(Math.floor(i/1e3)).toBigInt(),e.nanos=i%1e3*1e6,e}internalJsonWrite(t,e){let i=X.from(t.seconds).toNumber()*1e3;if(i<Date.parse("0001-01-01T00:00:00Z")||i>Date.parse("9999-12-31T23:59:59Z"))throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");if(t.nanos<0)throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");let n="Z";if(t.nanos>0){let s=(t.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?n="."+s.substring(0,3)+"Z":s.substring(6)==="000"?n="."+s.substring(0,6)+"Z":n="."+s+"Z"}return new Date(i).toISOString().replace(".000Z",n)}internalJsonRead(t,e,i){if(typeof t!="string")throw new Error("Unable to parse Timestamp from JSON "+Lr(t)+".");let n=t.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw new Error("Unable to parse Timestamp from JSON. Invalid format.");let s=Date.parse(n[1]+"-"+n[2]+"-"+n[3]+"T"+n[4]+":"+n[5]+":"+n[6]+(n[8]?n[8]:"Z"));if(Number.isNaN(s))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(s<Date.parse("0001-01-01T00:00:00Z")||s>Date.parse("9999-12-31T23:59:59Z"))throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");return i||(i=this.create()),i.seconds=X.from(s/1e3).toBigInt(),i.nanos=0,n[7]&&(i.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),i}},kc=new Cc;var Hf=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.PATH=1]="PATH",i[i.CMD=2]="CMD",i))(Hf||{}),Gf=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.CANCELLED=1]="CANCELLED",n[n.CANCELLING=2]="CANCELLING",n[n.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",n))(Gf||{}),Vc=class extends rt{constructor(){super("arrow.flight.protocol.HandshakeRequest",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},Hp=new Vc,Pc=class extends rt{constructor(){super("arrow.flight.protocol.HandshakeResponse",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},Gp=new Pc,jc=class extends rt{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}},nO=new jc,zc=class extends rt{constructor(){super("arrow.flight.protocol.Empty",[])}},qp=new zc,Wc=class extends rt{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}},Jp=new Wc,$c=class extends rt{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},Kp=new $c,Hc=class extends rt{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}},Xp=new Hc,Gc=class extends rt{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>Xo}])}},sO=new Gc,qc=class extends rt{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>qf}])}},oO=new qc,Jc=class extends rt{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},Yp=new Jc,Kc=class extends rt{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",Gf,"CANCEL_STATUS_"]}])}},aO=new Kc,Xc=class extends rt{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},Zp=new Xc,Yc=class extends rt{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",Hf]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},Ei=new Yc,Zc=class extends rt{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>Ei},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>qf},{no:4,name:"total_records",kind:"scalar",T:3,L:0},{no:5,name:"total_bytes",kind:"scalar",T:3,L:0},{no:6,name:"ordered",kind:"scalar",T:8},{no:7,name:"app_metadata",kind:"scalar",T:12}])}},Xo=new Zc,Qc=class extends rt{constructor(){super("arrow.flight.protocol.PollInfo",[{no:1,name:"info",kind:"message",T:()=>Xo},{no:2,name:"flight_descriptor",kind:"message",T:()=>Ei},{no:3,name:"progress",kind:"scalar",opt:!0,T:1},{no:4,name:"expiration_time",kind:"message",T:()=>kc}])}},Qp=new Qc,tl=class extends rt{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>Yo},{no:2,name:"location",kind:"message",repeat:1,T:()=>tm},{no:3,name:"expiration_time",kind:"message",T:()=>kc},{no:4,name:"app_metadata",kind:"scalar",T:12}])}},qf=new tl,el=class extends rt{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},tm=new el,rl=class extends rt{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},Yo=new rl,il=class extends rt{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>Ei},{no:2,name:"data_header",kind:"scalar",T:12},{no:3,name:"app_metadata",kind:"scalar",T:12},{no:1e3,name:"data_body",kind:"scalar",T:12}])}},Ko=new il,nl=class extends rt{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},em=new nl,Zo=new Pi("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:Hp,O:Gp},{name:"ListFlights",serverStreaming:!0,options:{},I:Kp,O:Xo},{name:"GetFlightInfo",options:{},I:Ei,O:Xo},{name:"PollFlightInfo",options:{},I:Ei,O:Qp},{name:"GetSchema",options:{},I:Ei,O:Zp},{name:"DoGet",serverStreaming:!0,options:{},I:Yo,O:Ko},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:Ko,O:em},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:Ko,O:Ko},{name:"DoAction",serverStreaming:!0,options:{},I:Xp,O:Yp},{name:"ListActions",serverStreaming:!0,options:{},I:qp,O:Jp}]);var Qo=class{constructor(t){this._transport=t;z(this,"typeName",Zo.typeName);z(this,"methods",Zo.methods);z(this,"options",Zo.options)}_transport;handshake(t){let e=this.methods[0],i=this._transport.mergeOptions(t);return qt("duplex",this._transport,e,i)}listFlights(t,e){let i=this.methods[1],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}getFlightInfo(t,e){let i=this.methods[2],n=this._transport.mergeOptions(e);return qt("unary",this._transport,i,n,t)}pollFlightInfo(t,e){let i=this.methods[3],n=this._transport.mergeOptions(e);return qt("unary",this._transport,i,n,t)}getSchema(t,e){let i=this.methods[4],n=this._transport.mergeOptions(e);return qt("unary",this._transport,i,n,t)}doGet(t,e){let i=this.methods[5],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}doPut(t){let e=this.methods[6],i=this._transport.mergeOptions(t);return qt("duplex",this._transport,e,i)}doExchange(t){let e=this.methods[7],i=this._transport.mergeOptions(t);return qt("duplex",this._transport,e,i)}doAction(t,e){let i=this.methods[8],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}listActions(t,e){let i=this.methods[9],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}};var Jf=/\$(\w+)/g;function Kf(r){return!!r.match(Jf)}function Xf(r,t){let e=r.match(Jf);if(e)for(let i of e)t[i.trim().replace("$","")]||ei(new Error(`No parameter matching ${i} provided in the query params map`));return!0}var rm="2.2.0.nightly",Yf=`influxdb3-js/${rm}`;function sl(r,t){if(t==null)return null;let e=r.metadata.get("iox::column::type");if(!e||r.typeId===f.Timestamp)return t;let[,,i,n]=e.split("::");if(i==="field")switch(n){case"integer":return ri(t)?parseInt(t):(console.warn(`Value ${t} is not an integer`),t);case"uinteger":return Il(t)?parseInt(t):(console.warn(`Value ${t} is not an unsigned integer`),t);case"float":return ri(t)?parseFloat(t):(console.warn(`Value ${t} is not a float`),t);case"boolean":return typeof t=="boolean"||console.warn(`Value ${t} is not a boolean`),t;case"string":return typeof t=="string"?String(t):(console.warn(`Value ${t} is not a string`),t);default:return t}return t}var Gn=class{constructor(t){this._options=t;z(this,"_closed",!1);z(this,"_flightClient");z(this,"_transport");z(this,"_defaultHeaders");let{host:e,queryTimeout:i,grpcOptions:n}=this._options;this._defaultHeaders=this._options.headers;let s={};n!==void 0&&(s=n),this._transport=Rr.queryTransport({host:e,timeout:i,clientOptions:{...s}}),this._flightClient=new Qo(this._transport)}_options;prepareTicket(t,e,i){let n={database:t,sql_query:e,query_type:i.type};if(i.params){let s={};for(let o of Object.keys(i.params))i.params[o]&&(s[o]=i.params[o]);n.params=s}return Yo.create({ticket:new TextEncoder().encode(JSON.stringify(n))})}prepareMetadata(t){let e={"User-Agent":Yf,...this._defaultHeaders,...t},i=this._options.token;return i&&(e.authorization=`Bearer ${i}`),e}async*_queryRawBatches(t,e,i){var d;if(i.params&&Kf(t)&&Xf(t,i.params),this._closed)throw new Error("queryApi: already closed!");let n=this._flightClient,s=this.prepareTicket(e,t,i),a={meta:this.prepareMetadata(i.headers)};a.timeout=(d=i.timeout)!=null?d:this._options.queryTimeout;let c=n.doGet(s,a),l=(async function*(){for await(let p of c.responses)yield _l(p.dataHeader.length),yield p.dataHeader,yield p.dataBody})();yield*await Vt.from(l)}async*query(t,e,i){let n=this._queryRawBatches(t,e,i);for await(let s of n)for(let o of s){let a={};for(let c of s.schema.fields){let l=o[c.name];a[c.name]=sl(c,l)}yield a}}async*queryPoints(t,e,i){var s;let n=this._queryRawBatches(t,e,i);for await(let o of n)for(let a=0;a<o.numRows;a++){let c=new fr;for(let l=0;l<o.numCols;l++){let u=o.schema.fields[l],d=u.name,p=(s=o.getChildAt(l))==null?void 0:s.get(a),m=u.typeId,_=u.metadata.get("iox::column::type");if(p==null)continue;if((d==="measurement"||d=="iox::measurement")&&typeof p=="string"){c.setMeasurement(p);continue}if(!_){d==="time"&&m===f.Timestamp?c.setTimestamp(p):c.setField(d,p);continue}let[,,j,at]=_.split("::");if(j==="field"){if(at&&p!==void 0&&p!==null){let dt=sl(u,p);c.setField(d,dt,at)}}else j==="tag"?c.setTag(d,p):j==="timestamp"&&c.setTimestamp(p)}yield c}}async close(){var t,e;this._closed=!0,(e=(t=this._transport).close)==null||e.call(t)}};var ol=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
|
|
20
|
+
]`}concat(...t){let e=this.schema,i=this.data.concat(t.flatMap(({data:n})=>n));return new r(e,i.map(n=>new ft(e,n)))}slice(t,e){let i=this.schema;[t,e]=ln({length:this.numRows},t,e);let n=ao(this.data,this._offsets,t,e);return new r(i,n.map(s=>new ft(i,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){let e=this.data.map(i=>i.children[t]);if(e.length===0){let{type:i}=this.schema.fields[t],n=L({type:i,length:0,nullCount:0});e.push(n._changeLengthAndBackfillNullBitmap(this.numRows))}return new P(e)}return null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new P([L({type:new Nt,length:this.numRows})]));let s=i.fields.slice(),o=s[t].clone({type:e.type}),a=this.schema.fields.map((c,l)=>this.getChildAt(l));[s[t],a[t]]=[o,e],[i,n]=jo(i,a)}return new r(i,n)}select(t){let e=this.schema.fields.reduce((i,n,s)=>i.set(n.name,s),new Map);return this.selectAt(t.map(i=>e.get(i)).filter(i=>i>-1))}selectAt(t){let e=this.schema.selectAt(t),i=this.batches.map(n=>n.selectAt(t));return new r(e,i)}assign(t){let e=this.schema.fields,[i,n]=t.schema.fields.reduce((a,c,l)=>{let[u,d]=a,p=e.findIndex(m=>m.name===c.name);return~p?d[p]=l:u.push(l),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,n[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...i.map(a=>t.getChildAt(a))].filter(Boolean);return new r(...jo(s,o))}};Af=Symbol.toStringTag;_e[Af]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=yi(dn),r.get=yi(mt.getVisitFn(f.Struct)),r.set=co(Tt.getVisitFn(f.Struct)),r.indexOf=lo($r.getVisitFn(f.Struct)),"Table"))(_e.prototype);var Nf,ft=class r{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof K))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=L({nullCount:0,type:new it(this.schema.fields),children:this.schema.fields.map(e=>L({type:e.type,nullCount:0}))})]=t,!(this.data instanceof G))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Ff(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:i,children:n,length:s}=Object.keys(e).reduce((c,l,u)=>(c.children[u]=e[l],c.length=Math.max(c.length,e[l].length),c.fields[u]=C.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new K(i),a=L({type:new it(i),length:s,children:n,nullCount:0});[this.schema,this.data]=Ff(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=Ef(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return mt.visit(this.data,t)}at(t){return this.get(Pr(t,this.numRows))}set(t,e){return Tt.visit(this.data,t,e)}indexOf(t,e){return $r.visit(this.data,t,e)}[Symbol.iterator](){return gi.visit(new P([this.data]))}toArray(){return[...this]}concat(...t){return new _e(this.schema,[this,...t])}slice(t,e){let[i]=new P([this.data]).slice(t,e).data;return new r(this.schema,i)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(i=>i.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new P([this.data.children[t]]):null}setChild(t,e){var i;return this.setChildAt((i=this.schema.fields)===null||i===void 0?void 0:i.findIndex(n=>n.name===t),e)}setChildAt(t,e){let i=this.schema,n=this.data;if(t>-1&&t<this.numCols){e||(e=new P([L({type:new Nt,length:this.numRows})]));let s=i.fields.slice(),o=n.children.slice(),a=s[t].clone({type:e.type});[s[t],o[t]]=[a,e.data[0]],i=new K(s,new Map(this.schema.metadata)),n=L({type:new it(s),children:o})}return new r(i,n)}select(t){let e=this.schema.select(t),i=new it(e.fields),n=[];for(let s of t){let o=this.schema.fields.findIndex(a=>a.name===s);~o&&(n[o]=this.data.children[o])}return new r(e,L({type:i,length:this.numRows,children:n}))}selectAt(t){let e=this.schema.selectAt(t),i=t.map(s=>this.data.children[s]).filter(Boolean),n=L({type:new it(e.fields),length:this.numRows,children:i});return new r(e,n)}};Nf=Symbol.toStringTag;ft[Nf]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(ft.prototype);function Ff(r,t,e=t.reduce((i,n)=>Math.max(i,n.length),0)){var i;let n=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(let[a,c]of r.fields.entries()){let l=t[a];(!l||l.length!==e)&&(n[a]=c.clone({nullable:!0}),s[a]=(i=l==null?void 0:l._changeLengthAndBackfillNullBitmap(e))!==null&&i!==void 0?i:L({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(n),L({type:new it(n),length:e,children:s})]}function Ef(r,t,e=new Map){var i,n;if(((i=r==null?void 0:r.length)!==null&&i!==void 0?i:0)>0&&(r==null?void 0:r.length)===(t==null?void 0:t.length))for(let s=-1,o=r.length;++s<o;){let{type:a}=r[s],c=t[s];for(let l of[c,...((n=c==null?void 0:c.dictionary)===null||n===void 0?void 0:n.data)||[]])Ef(a.children,l==null?void 0:l.children,e);if(b.isDictionary(a)){let{id:l}=a;if(!e.has(l))c!=null&&c.dictionary&&e.set(l,c.dictionary);else if(e.get(l)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var Qr=class extends ft{constructor(t){let e=t.fields.map(n=>L({type:n.type})),i=L({type:new it(t.fields),nullCount:0,children:e});super(t,i)}};var xc=r=>`Expected ${V[r]} Message in stream, but was null or length 0.`,Tc=r=>`Header pointer of flatbuffer-encoded ${V[r]} Message is null or length 0.`,Lf=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,Uf=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Bi=class{constructor(t){this.source=t instanceof Fe?t:new Fe(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?nt:t.value===-1&&(t=this.readMetadataLength()).done?nt:(t=this.readMetadata(t.value)).done?nt:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(xc(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=D(this.source.read(t));if(e.byteLength<t)throw new Error(Uf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=V.Schema,i=this.readMessage(e),n=i==null?void 0:i.header();if(t&&!n)throw new Error(Tc(e));return n}readMetadataLength(){let t=this.source.read(zo),e=t&&new xt(t),i=(e==null?void 0:e.readInt32(0))||0;return{done:i===0,value:i}}readMetadata(t){let e=this.source.read(t);if(!e)return nt;if(e.byteLength<t)throw new Error(Lf(t,e.byteLength));return{done:!1,value:kt.decode(e)}}},jn=class{constructor(t,e){this.source=t instanceof te?t:bs(t)?new Tr(t,e):new te(t)}[Symbol.asyncIterator](){return this}next(){return g(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?nt:t.value===-1&&(t=yield this.readMetadataLength()).done?nt:(t=yield this.readMetadata(t.value)).done?nt:t})}throw(t){return g(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return g(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return g(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(xc(t));return e.value})}readMessageBody(t){return g(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=D(yield this.source.read(t));if(e.byteLength<t)throw new Error(Uf(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return g(this,arguments,void 0,function*(t=!1){let e=V.Schema,i=yield this.readMessage(e),n=i==null?void 0:i.header();if(t&&!n)throw new Error(Tc(e));return n})}readMetadataLength(){return g(this,void 0,void 0,function*(){let t=yield this.source.read(zo),e=t&&new xt(t),i=(e==null?void 0:e.readInt32(0))||0;return{done:i===0,value:i}})}readMetadata(t){return g(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return nt;if(e.byteLength<t)throw new Error(Lf(t,e.byteLength));return{done:!1,value:kt.decode(e)}})}},zn=class extends Bi{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof hn?t:new hn(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:kt.fromJSON(t.schema,V.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:kt.fromJSON(e,V.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:kt.fromJSON(e,V.RecordBatch)}}return this._body=[],nt}readMessageBody(t){return e(this._body);function e(i){return(i||[]).reduce((n,s)=>[...n,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(xc(t));return e.value}readSchema(){let t=V.Schema,e=this.readMessage(t),i=e==null?void 0:e.header();if(!e||!i)throw new Error(Tc(t));return i}},zo=4,Sc="ARROW1",Oi=new Uint8Array(Sc.length);for(let r=0;r<Sc.length;r+=1)Oi[r]=Sc.codePointAt(r);function Wo(r,t=0){for(let e=-1,i=Oi.length;++e<i;)if(Oi[e]!==r[t+e])return!1;return!0}var Di=Oi.length,Bc=Di+zo,Mf=Di*2+zo;var Oc=class{constructor(){this.LZ4_FRAME_MAGIC=new Uint8Array([4,34,77,24]),this.MIN_HEADER_LENGTH=7}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),i=t.encode(e);return this._isValidCompressed(i)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)&&this._hasValidVersion(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.LZ4_FRAME_MAGIC.every((e,i)=>t[i]===e)}_hasValidVersion(t){return(t[4]&192)>>6===1}},Dc=class{constructor(){this.ZSTD_MAGIC=new Uint8Array([40,181,47,253]),this.MIN_HEADER_LENGTH=6}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),i=t.encode(e);return this._isValidCompressed(i)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.ZSTD_MAGIC.every((e,i)=>t[i]===e)}},Rf={[Ft.LZ4_FRAME]:new Oc,[Ft.ZSTD]:new Dc};var Ac=class{constructor(){this.registry={}}set(t,e){if(e!=null&&e.encode&&typeof e.encode=="function"&&!Rf[t].isValidCodecEncode(e))throw new Error(`Encoder for ${Ft[t]} is not valid.`);this.registry[t]=e}get(t){var e;return((e=this.registry)===null||e===void 0?void 0:e[t])||null}},Ai=new Ac;var Vt=class r extends qr{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){let e=this._impl.open(t);return ne(e)?e.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return St.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return St.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof r?t:ys(t)?Rp(t):bs(t)?Vp(t):ne(t)?g(this,void 0,void 0,function*(){return yield r.from(yield t)}):_s(t)||qi(t)||Is(t)||Kt(t)?kp(new te(t)):Cp(new Fe(t))}static readAll(t){return t instanceof r?t.isSync()?Cf(t):kf(t):ys(t)||ArrayBuffer.isView(t)||se(t)||gs(t)?Cf(t):kf(t)}},Ee=class extends Vt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return zt(this,arguments,function*(){yield U(yield*ni(ie(this[Symbol.iterator]())))})}},Or=class extends Vt{constructor(t){super(t),this._impl=t}readAll(){return g(this,void 0,void 0,function*(){var t,e,i,n;let s=new Array;try{for(var o=!0,a=ie(this),c;c=yield a.next(),t=c.done,!t;o=!0){n=c.value,o=!1;let l=n;s.push(l)}}catch(l){e={error:l}}finally{try{!o&&!t&&(i=a.return)&&(yield i.call(a))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Dr=class extends Ee{constructor(t){super(t),this._impl=t}},Wn=class extends Or{constructor(t){super(t),this._impl=t}},$o=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){let i;if(t.compression!=null){let s=Ai.get(t.compression.type);if(s!=null&&s.decode&&typeof s.decode=="function"){let{decommpressedBody:o,buffers:a}=this._decompressBuffers(t,e,s);i=this._loadCompressedVectors(t,o,this.schema.fields),t=new bt(t.length,t.nodes,a,null)}else throw new Error("Record batch is compressed but codec not found")}else i=this._loadVectors(t,e,this.schema.fields);let n=L({type:new it(this.schema.fields),length:t.length,children:i});return new ft(this.schema,n)}_loadDictionaryBatch(t,e){let{id:i,isDelta:n}=t,{dictionaries:s,schema:o}=this,a=s.get(i),c=o.dictionaries.get(i),l;if(t.data.compression!=null){let u=Ai.get(t.data.compression.type);if(u!=null&&u.decode&&typeof u.decode=="function"){let{decommpressedBody:d,buffers:p}=this._decompressBuffers(t.data,e,u);l=this._loadCompressedVectors(t.data,d,[c]),t=new Ot(new bt(t.data.length,t.data.nodes,p,null),i,n)}else throw new Error("Dictionary batch is compressed but codec not found")}else l=this._loadVectors(t.data,e,[c]);return(a&&n?a.concat(new P(l)):new P(l)).memoize()}_loadVectors(t,e,i){return new vi(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}_loadCompressedVectors(t,e,i){return new bo(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}_decompressBuffers(t,e,i){let n=[],s=[],o=0;for(let{offset:a,length:c}of t.buffers){if(c===0){n.push(new Uint8Array(0)),s.push(new gt(o,0));continue}let l=new xt(e.subarray(a,a+c)),u=W(l.readInt64(0)),d=l.bytes().subarray(8),p=u===-1?d:i.decode(d);n.push(p);let m=(o+7&-8)-o;o+=m,s.push(new gt(o,p.length)),o+=p.length}return{decommpressedBody:n,buffers:s}}},Fi=class extends $o{constructor(t,e){super(e),this._reader=ys(t)?new zn(this._handle=t):new Bi(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=Pf(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):nt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):nt}next(){if(this.closed)return nt;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let i=t.header(),n=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let i=t.header(),n=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Qr(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Ni=class extends $o{constructor(t,e){super(e),this._reader=new jn(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return g(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return g(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Pf(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):nt})}return(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):nt})}next(){return g(this,void 0,void 0,function*(){if(this.closed)return nt;let t,{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let i=t.header(),n=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(i,n)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let i=t.header(),n=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(i,n);this.dictionaries.set(i.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Qr(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Ho=class extends Fi{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof pn?t:new pn(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(V.RecordBatch);if(n!=null&&n.isRecordBatch()){let s=n.header(),o=this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&this._handle.seek(i.offset)){let n=this._reader.readMessage(V.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let s=n.header(),o=this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-Bc,i=t.readInt32(e),n=t.readAt(e-i,i);return er.decode(n)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(i&&this._handle.seek(i.offset))return this._reader.readMessage(t)}return null}},Fc=class extends Ni{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let i=typeof e[0]!="number"?e.shift():void 0,n=e[0]instanceof Map?e.shift():void 0;super(t instanceof Tr?t:new Tr(t,i),n)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return g(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let i of this._footer.dictionaryBatches())i&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return g(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let i=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.RecordBatch);if(n!=null&&n.isRecordBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return g(this,void 0,void 0,function*(){var e;let i=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(i&&(yield this._handle.seek(i.offset))){let n=yield this._reader.readMessage(V.DictionaryBatch);if(n!=null&&n.isDictionaryBatch()){let s=n.header(),o=yield this._reader.readMessageBody(n.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return g(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Bc,i=yield t.readInt32(e),n=yield t.readAt(e-i,i);return er.decode(n)})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},Nc=class extends Fi{constructor(t,e){super(t,e)}_loadVectors(t,e,i){return new go(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(i)}};function Pf(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Cf(r){let t=Vt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function kf(r){return zt(this,arguments,function*(){let e=yield U(Vt.from(r));try{if(!(yield U(e.open({autoDestroy:!1}))).closed)do yield yield U(e);while(!(yield U(e.reset().open())).closed)}finally{yield U(e.cancel())}})}function Rp(r){return new Ee(new Nc(r))}function Cp(r){let t=r.peek(Di+7&-8);return t&&t.byteLength>=4?Wo(t)?new Dr(new Ho(r.read())):new Ee(new Fi(r)):new Ee(new Fi((function*(){})()))}function kp(r){return g(this,void 0,void 0,function*(){let t=yield r.peek(Di+7&-8);return t&&t.byteLength>=4?Wo(t)?new Dr(new Ho(yield r.read())):new Or(new Ni(r)):new Or(new Ni((function(){return zt(this,arguments,function*(){})})()))})}function Vp(r){return g(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Tr(r,t);return t>=Mf&&Wo(yield e.readAt(0,Di+7&-8))?new Wn(new Fc(e)):new Or(new Ni(e))})}var lt=class r extends v{static assemble(...t){let e=n=>n.flatMap(s=>Array.isArray(s)?e(s):s instanceof ft?s.data.children:s.data),i=new r;return i.visitMany(e(t)),i}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof P)return this.visitMany(t.data),this;let{type:e}=t;if(!b.isDictionary(e)){let{length:i}=t;if(i>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(b.isUnion(e))this.nodes.push(new Qt(i,0));else{let{nullCount:n}=t;b.isNull(e)||we.call(this,n<=0?new Uint8Array(0):zr(t.offset,i,t.nullBitmap)),this.nodes.push(new Qt(i,n))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function we(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new gt(this._byteLength,t)),this._byteLength+=t,this}function Pp(r){var t;let{type:e,length:i,typeIds:n,valueOffsets:s}=r;if(we.call(this,n),e.mode===Z.Sparse)return Ec.call(this,r);if(e.mode===Z.Dense){if(r.offset<=0)return we.call(this,s),Ec.call(this,r);{let o=new Int32Array(i),a=Object.create(null),c=Object.create(null);for(let l,u,d=-1;++d<i;)(l=n[d])!==void 0&&((u=a[l])===void 0&&(u=a[l]=s[d]),o[d]=s[d]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);we.call(this,o),this.visitMany(r.children.map((l,u)=>{let d=e.typeIds[u],p=a[d],m=c[d];return l.slice(p,Math.min(i,m))}))}}return this}function jp(r){let t;return r.nullCount>=r.length?we.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?we.call(this,zr(r.offset,r.length,t)):we.call(this,Wr(r.values))}function lr(r){return we.call(this,r.values.subarray(0,r.length*r.stride))}function Go(r){let{length:t,values:e,valueOffsets:i}=r,n=W(i[0]),s=W(i[t]),o=Math.min(s-n,e.byteLength-n);return we.call(this,Ss(-n,t+1,i)),we.call(this,e.subarray(n,n+o)),this}function Lc(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:i,[t]:n}=e;return we.call(this,Ss(-i,t+1,e)),this.visit(r.children[0].slice(i,n-i))}return this.visit(r.children[0])}function Ec(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}lt.prototype.visitBool=jp;lt.prototype.visitInt=lr;lt.prototype.visitFloat=lr;lt.prototype.visitUtf8=Go;lt.prototype.visitLargeUtf8=Go;lt.prototype.visitBinary=Go;lt.prototype.visitLargeBinary=Go;lt.prototype.visitFixedSizeBinary=lr;lt.prototype.visitDate=lr;lt.prototype.visitTimestamp=lr;lt.prototype.visitTime=lr;lt.prototype.visitDecimal=lr;lt.prototype.visitList=Lc;lt.prototype.visitStruct=Ec;lt.prototype.visitUnion=Pp;lt.prototype.visitInterval=lr;lt.prototype.visitDuration=lr;lt.prototype.visitFixedSizeList=Lc;lt.prototype.visitMap=Lc;var ti=class extends qr{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){if(super(),this._position=0,this._started=!1,this._compression=null,this._sink=new Ae,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,At(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1,compressionType:null}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1,t.compressionType!=null){if(this._writeLegacyIpcFormat)throw new Error("Legacy IPC format does not support columnar compression. Use modern IPC format (writeLegacyIpcFormat=false).");if(Object.values(Ft).includes(t.compressionType))this._compression=new Gr(t.compressionType);else{let e=Object.values(Ft).filter(i=>typeof i=="string");throw new Error(`Unsupported compressionType: ${t.compressionType} Available types: ${e.join(", ")}`)}}else this._compression=null}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return ne(t)?t.then(e=>this.writeAll(e)):Kt(t)?Mc(this,t):Uc(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){return t===this._sink||t instanceof Ae?this._sink=t:(this._sink=new Ae,t&&Kl(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Xl(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!e||!Zr(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof _e&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof ft&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!Zr(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof ft?t instanceof Qr||this._writeRecordBatch(t):t instanceof _e?this.writeAll(t.batches):se(t)&&this.writeAll(t)}_writeMessage(t,e=8){let i=e-1,n=kt.encode(t),s=n.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+i&~i,c=a-s-o;return t.headerType===V.RecordBatch?this._recordBatchBlocks.push(new rr(a,t.bodyLength,this._position)):t.headerType===V.DictionaryBatch&&this._dictionaryBlocks.push(new rr(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(n),this._writePadding(c)}_write(t){if(this._started){let e=D(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(kt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Oi)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:i,bufferRegions:n,buffers:s}=this._assembleRecordBatch(t),o=new bt(t.numRows,i,n,this._compression),a=kt.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_assembleRecordBatch(t){let{byteLength:e,nodes:i,bufferRegions:n,buffers:s}=lt.assemble(t);return this._compression!=null&&({byteLength:e,bufferRegions:n,buffers:s}=this._compressBodyBuffers(s)),{byteLength:e,nodes:i,bufferRegions:n,buffers:s}}_compressBodyBuffers(t){let e=Ai.get(this._compression.type);if(!(e!=null&&e.encode)||typeof e.encode!="function")throw new Error(`Codec for compression type "${Ft[this._compression.type]}" has invalid encode method`);let i=0,n=[],s=[];for(let a of t){let c=D(a);if(c.length===0){n.push(new Uint8Array(0),new Uint8Array(0)),s.push(new gt(i,0));continue}let l=e.encode(c),u=l.length<c.length,d=u?l:c,p=u?d.length:-1,m=new xt(new Uint8Array(8));m.writeInt64(0,BigInt(p)),n.push(m.bytes(),new Uint8Array(d));let _=(i+7&-8)-i;i+=_;let j=8+d.length;s.push(new gt(i,j)),i+=j}let o=(i+7&-8)-i;return i+=o,{byteLength:i,bufferRegions:s,buffers:n}}_writeDictionaryBatch(t,e,i=!1){let{byteLength:n,nodes:s,bufferRegions:o,buffers:a}=this._assembleRecordBatch(new P([t])),c=new bt(t.length,s,o,this._compression),l=new Ot(c,e,i),u=kt.from(l,n);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e=this._compression!=null?2:1,i=new Array(e);for(let n=0;n<t.length;n+=e){let s=0;for(let a=-1;++a<e;)i[a]=t[n+a],s+=i[a].byteLength;if(s===0)continue;for(let a of i)this._write(a);let o=(s+7&-8)-s;o>0&&this._writePadding(o)}return this}_writeDictionaries(t){var e,i;for(let[n,s]of t.dictionaries){let o=(e=s==null?void 0:s.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(n),c=(i=this._dictionaryDeltaOffsets.get(n))!==null&&i!==void 0?i:0;if(!a||a.data[0]!==o[0])for(let[l,u]of o.entries())this._writeDictionaryBatch(u,n,l>0);else if(c<o.length)for(let l of o.slice(c))this._writeDictionaryBatch(l,n,!0);this._seenDictionaries.set(n,s),this._dictionaryDeltaOffsets.set(n,o.length)}return this}},$n=class r extends ti{static writeAll(t,e){let i=new r(e);return ne(t)?t.then(n=>i.writeAll(n)):Kt(t)?Mc(i,t):Uc(i,t)}},Hn=class r extends ti{static writeAll(t,e){let i=new r(e);return ne(t)?t.then(n=>i.writeAll(n)):Kt(t)?Mc(i,t):Uc(i,t)}constructor(t){super(t),this._autoDestroy=!0,this._writeLegacyIpcFormat=!1}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,i=!1){if(!i&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,i)}_writeFooter(t){let e=er.encode(new er(t,J.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Uc(r,t){let e=t;t instanceof _e&&(e=t.batches,r.reset(void 0,t.schema));for(let i of e)r.write(i);return r.finish()}function Mc(r,t){return g(this,void 0,void 0,function*(){var e,i,n,s,o,a,c;try{for(e=!0,i=ie(t);n=yield i.next(),s=n.done,!s;e=!0){c=n.value,e=!1;let l=c;r.write(l)}}catch(l){o={error:l}}finally{try{!e&&!s&&(a=i.return)&&(yield a.call(i))}finally{if(o)throw o.error}}return r.finish()})}function jf(r,t){if(Kt(r))return Wp(r,t);if(se(r))return zp(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function zp(r,t){let e=null,i=(t==null?void 0:t.type)==="bytes"||!1,n=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){s(o,e||(e=r[Symbol.iterator]()))},pull(o){e?s(o,e):o.close()},cancel(){e!=null&&e.return&&e.return(),e=null}}),Object.assign({highWaterMark:i?n:void 0},t));function s(o,a){let c,l=null,u=o.desiredSize||null;for(;!(l=a.next(i?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=D(l.value))&&(u!=null&&i&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()}}function Wp(r,t){let e=null,i=(t==null?void 0:t.type)==="bytes"||!1,n=(t==null?void 0:t.highWaterMark)||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return g(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return g(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return g(this,void 0,void 0,function*(){e!=null&&e.return&&(yield e.return()),e=null})}}),Object.assign({highWaterMark:i?n:void 0},t));function s(o,a){return g(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(i?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=D(l.value))&&(u!=null&&i&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()})}}function $f(r){return new Rc(r)}var Rc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:i,["queueingStrategy"]:n="count"}=t,s=Gl(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Kr(s),this._getSize=n!=="bytes"?zf:Wf;let{["highWaterMark"]:o=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=n==="bytes"?Math.pow(2,14):1e3}=Object.assign({},i);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:c=>{this._maybeFlush(this._builder,this._controller=c)},start:c=>{this._maybeFlush(this._builder,this._controller=c)}},{highWaterMark:o,size:n!=="bytes"?zf:Wf}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:c=>this._writeValueAndReturnChunkSize(c)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},zf=r=>{var t;return(t=r==null?void 0:r.length)!==null&&t!==void 0?t:0},Wf=r=>{var t;return(t=r==null?void 0:r.byteLength)!==null&&t!==void 0?t:0};function qo(r,t){let e=new Ae,i=null,n=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield e.close()})},start(a){return g(this,void 0,void 0,function*(){yield o(a,i||(i=yield s()))})},pull(a){return g(this,void 0,void 0,function*(){i?yield o(a,i):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:n};function s(){return g(this,void 0,void 0,function*(){return yield(yield Vt.from(e)).open(t)})}function o(a,c){return g(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}function Jo(r,t){let e=new this(r),i=new te(e),n=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield i.cancel()})},pull(o){return g(this,void 0,void 0,function*(){yield s(o)})},start(o){return g(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:n};function s(o){return g(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield i.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}var $p=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Wa),yc),sc),$a),Ra),nc),Va),_c),{compareSchemas:Zr,compareFields:Of,compareTypes:Df});St.toDOMStream=jf;ot.throughDOM=$f;Vt.throughDOM=qo;Dr.throughDOM=qo;Ee.throughDOM=qo;ti.throughDOM=Jo;Hn.throughDOM=Jo;$n.throughDOM=Jo;var Cc=class extends rt{constructor(){super("google.protobuf.Timestamp",[{no:1,name:"seconds",kind:"scalar",T:3,L:0},{no:2,name:"nanos",kind:"scalar",T:5}])}now(){let t=this.create(),e=Date.now();return t.seconds=X.from(Math.floor(e/1e3)).toBigInt(),t.nanos=e%1e3*1e6,t}toDate(t){return new Date(X.from(t.seconds).toNumber()*1e3+Math.ceil(t.nanos/1e6))}fromDate(t){let e=this.create(),i=t.getTime();return e.seconds=X.from(Math.floor(i/1e3)).toBigInt(),e.nanos=i%1e3*1e6,e}internalJsonWrite(t,e){let i=X.from(t.seconds).toNumber()*1e3;if(i<Date.parse("0001-01-01T00:00:00Z")||i>Date.parse("9999-12-31T23:59:59Z"))throw new Error("Unable to encode Timestamp to JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");if(t.nanos<0)throw new Error("Unable to encode invalid Timestamp to JSON. Nanos must not be negative.");let n="Z";if(t.nanos>0){let s=(t.nanos+1e9).toString().substring(1);s.substring(3)==="000000"?n="."+s.substring(0,3)+"Z":s.substring(6)==="000"?n="."+s.substring(0,6)+"Z":n="."+s+"Z"}return new Date(i).toISOString().replace(".000Z",n)}internalJsonRead(t,e,i){if(typeof t!="string")throw new Error("Unable to parse Timestamp from JSON "+Lr(t)+".");let n=t.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw new Error("Unable to parse Timestamp from JSON. Invalid format.");let s=Date.parse(n[1]+"-"+n[2]+"-"+n[3]+"T"+n[4]+":"+n[5]+":"+n[6]+(n[8]?n[8]:"Z"));if(Number.isNaN(s))throw new Error("Unable to parse Timestamp from JSON. Invalid value.");if(s<Date.parse("0001-01-01T00:00:00Z")||s>Date.parse("9999-12-31T23:59:59Z"))throw new globalThis.Error("Unable to parse Timestamp from JSON. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.");return i||(i=this.create()),i.seconds=X.from(s/1e3).toBigInt(),i.nanos=0,n[7]&&(i.nanos=parseInt("1"+n[7]+"0".repeat(9-n[7].length))-1e9),i}},kc=new Cc;var Hf=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.PATH=1]="PATH",i[i.CMD=2]="CMD",i))(Hf||{}),Gf=(n=>(n[n.UNSPECIFIED=0]="UNSPECIFIED",n[n.CANCELLED=1]="CANCELLED",n[n.CANCELLING=2]="CANCELLING",n[n.NOT_CANCELLABLE=3]="NOT_CANCELLABLE",n))(Gf||{}),Vc=class extends rt{constructor(){super("arrow.flight.protocol.HandshakeRequest",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},Hp=new Vc,Pc=class extends rt{constructor(){super("arrow.flight.protocol.HandshakeResponse",[{no:1,name:"protocol_version",kind:"scalar",T:4,L:0},{no:2,name:"payload",kind:"scalar",T:12}])}},Gp=new Pc,jc=class extends rt{constructor(){super("arrow.flight.protocol.BasicAuth",[{no:2,name:"username",kind:"scalar",T:9},{no:3,name:"password",kind:"scalar",T:9}])}},nO=new jc,zc=class extends rt{constructor(){super("arrow.flight.protocol.Empty",[])}},qp=new zc,Wc=class extends rt{constructor(){super("arrow.flight.protocol.ActionType",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"description",kind:"scalar",T:9}])}},Jp=new Wc,$c=class extends rt{constructor(){super("arrow.flight.protocol.Criteria",[{no:1,name:"expression",kind:"scalar",T:12}])}},Kp=new $c,Hc=class extends rt{constructor(){super("arrow.flight.protocol.Action",[{no:1,name:"type",kind:"scalar",T:9},{no:2,name:"body",kind:"scalar",T:12}])}},Xp=new Hc,Gc=class extends rt{constructor(){super("arrow.flight.protocol.CancelFlightInfoRequest",[{no:1,name:"info",kind:"message",T:()=>Xo}])}},sO=new Gc,qc=class extends rt{constructor(){super("arrow.flight.protocol.RenewFlightEndpointRequest",[{no:1,name:"endpoint",kind:"message",T:()=>qf}])}},oO=new qc,Jc=class extends rt{constructor(){super("arrow.flight.protocol.Result",[{no:1,name:"body",kind:"scalar",T:12}])}},Yp=new Jc,Kc=class extends rt{constructor(){super("arrow.flight.protocol.CancelFlightInfoResult",[{no:1,name:"status",kind:"enum",T:()=>["arrow.flight.protocol.CancelStatus",Gf,"CANCEL_STATUS_"]}])}},aO=new Kc,Xc=class extends rt{constructor(){super("arrow.flight.protocol.SchemaResult",[{no:1,name:"schema",kind:"scalar",T:12}])}},Zp=new Xc,Yc=class extends rt{constructor(){super("arrow.flight.protocol.FlightDescriptor",[{no:1,name:"type",kind:"enum",T:()=>["arrow.flight.protocol.FlightDescriptor.DescriptorType",Hf]},{no:2,name:"cmd",kind:"scalar",T:12},{no:3,name:"path",kind:"scalar",repeat:2,T:9}])}},Ei=new Yc,Zc=class extends rt{constructor(){super("arrow.flight.protocol.FlightInfo",[{no:1,name:"schema",kind:"scalar",T:12},{no:2,name:"flight_descriptor",kind:"message",T:()=>Ei},{no:3,name:"endpoint",kind:"message",repeat:1,T:()=>qf},{no:4,name:"total_records",kind:"scalar",T:3,L:0},{no:5,name:"total_bytes",kind:"scalar",T:3,L:0},{no:6,name:"ordered",kind:"scalar",T:8},{no:7,name:"app_metadata",kind:"scalar",T:12}])}},Xo=new Zc,Qc=class extends rt{constructor(){super("arrow.flight.protocol.PollInfo",[{no:1,name:"info",kind:"message",T:()=>Xo},{no:2,name:"flight_descriptor",kind:"message",T:()=>Ei},{no:3,name:"progress",kind:"scalar",opt:!0,T:1},{no:4,name:"expiration_time",kind:"message",T:()=>kc}])}},Qp=new Qc,tl=class extends rt{constructor(){super("arrow.flight.protocol.FlightEndpoint",[{no:1,name:"ticket",kind:"message",T:()=>Yo},{no:2,name:"location",kind:"message",repeat:1,T:()=>tm},{no:3,name:"expiration_time",kind:"message",T:()=>kc},{no:4,name:"app_metadata",kind:"scalar",T:12}])}},qf=new tl,el=class extends rt{constructor(){super("arrow.flight.protocol.Location",[{no:1,name:"uri",kind:"scalar",T:9}])}},tm=new el,rl=class extends rt{constructor(){super("arrow.flight.protocol.Ticket",[{no:1,name:"ticket",kind:"scalar",T:12}])}},Yo=new rl,il=class extends rt{constructor(){super("arrow.flight.protocol.FlightData",[{no:1,name:"flight_descriptor",kind:"message",T:()=>Ei},{no:2,name:"data_header",kind:"scalar",T:12},{no:3,name:"app_metadata",kind:"scalar",T:12},{no:1e3,name:"data_body",kind:"scalar",T:12}])}},Ko=new il,nl=class extends rt{constructor(){super("arrow.flight.protocol.PutResult",[{no:1,name:"app_metadata",kind:"scalar",T:12}])}},em=new nl,Zo=new Pi("arrow.flight.protocol.FlightService",[{name:"Handshake",serverStreaming:!0,clientStreaming:!0,options:{},I:Hp,O:Gp},{name:"ListFlights",serverStreaming:!0,options:{},I:Kp,O:Xo},{name:"GetFlightInfo",options:{},I:Ei,O:Xo},{name:"PollFlightInfo",options:{},I:Ei,O:Qp},{name:"GetSchema",options:{},I:Ei,O:Zp},{name:"DoGet",serverStreaming:!0,options:{},I:Yo,O:Ko},{name:"DoPut",serverStreaming:!0,clientStreaming:!0,options:{},I:Ko,O:em},{name:"DoExchange",serverStreaming:!0,clientStreaming:!0,options:{},I:Ko,O:Ko},{name:"DoAction",serverStreaming:!0,options:{},I:Xp,O:Yp},{name:"ListActions",serverStreaming:!0,options:{},I:qp,O:Jp}]);var Qo=class{constructor(t){this._transport=t;z(this,"typeName",Zo.typeName);z(this,"methods",Zo.methods);z(this,"options",Zo.options)}_transport;handshake(t){let e=this.methods[0],i=this._transport.mergeOptions(t);return qt("duplex",this._transport,e,i)}listFlights(t,e){let i=this.methods[1],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}getFlightInfo(t,e){let i=this.methods[2],n=this._transport.mergeOptions(e);return qt("unary",this._transport,i,n,t)}pollFlightInfo(t,e){let i=this.methods[3],n=this._transport.mergeOptions(e);return qt("unary",this._transport,i,n,t)}getSchema(t,e){let i=this.methods[4],n=this._transport.mergeOptions(e);return qt("unary",this._transport,i,n,t)}doGet(t,e){let i=this.methods[5],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}doPut(t){let e=this.methods[6],i=this._transport.mergeOptions(t);return qt("duplex",this._transport,e,i)}doExchange(t){let e=this.methods[7],i=this._transport.mergeOptions(t);return qt("duplex",this._transport,e,i)}doAction(t,e){let i=this.methods[8],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}listActions(t,e){let i=this.methods[9],n=this._transport.mergeOptions(e);return qt("serverStreaming",this._transport,i,n,t)}};var Jf=/\$(\w+)/g;function Kf(r){return!!r.match(Jf)}function Xf(r,t){let e=r.match(Jf);if(e)for(let i of e)t[i.trim().replace("$","")]||ei(new Error(`No parameter matching ${i} provided in the query params map`));return!0}var rm="2.2.0",Yf=`influxdb3-js/${rm}`;function sl(r,t){if(t==null)return null;let e=r.metadata.get("iox::column::type");if(!e||r.typeId===f.Timestamp)return t;let[,,i,n]=e.split("::");if(i==="field")switch(n){case"integer":return ri(t)?parseInt(t):(console.warn(`Value ${t} is not an integer`),t);case"uinteger":return Il(t)?parseInt(t):(console.warn(`Value ${t} is not an unsigned integer`),t);case"float":return ri(t)?parseFloat(t):(console.warn(`Value ${t} is not a float`),t);case"boolean":return typeof t=="boolean"||console.warn(`Value ${t} is not a boolean`),t;case"string":return typeof t=="string"?String(t):(console.warn(`Value ${t} is not a string`),t);default:return t}return t}var Gn=class{constructor(t){this._options=t;z(this,"_closed",!1);z(this,"_flightClient");z(this,"_transport");z(this,"_defaultHeaders");let{host:e,queryTimeout:i,grpcOptions:n}=this._options;this._defaultHeaders=this._options.headers;let s={};n!==void 0&&(s=n),this._transport=Rr.queryTransport({host:e,timeout:i,clientOptions:{...s}}),this._flightClient=new Qo(this._transport)}_options;prepareTicket(t,e,i){let n={database:t,sql_query:e,query_type:i.type};if(i.params){let s={};for(let o of Object.keys(i.params))i.params[o]&&(s[o]=i.params[o]);n.params=s}return Yo.create({ticket:new TextEncoder().encode(JSON.stringify(n))})}prepareMetadata(t){let e={"User-Agent":Yf,...this._defaultHeaders,...t},i=this._options.token;return i&&(e.authorization=`Bearer ${i}`),e}async*_queryRawBatches(t,e,i){var d;if(i.params&&Kf(t)&&Xf(t,i.params),this._closed)throw new Error("queryApi: already closed!");let n=this._flightClient,s=this.prepareTicket(e,t,i),a={meta:this.prepareMetadata(i.headers)};a.timeout=(d=i.timeout)!=null?d:this._options.queryTimeout;let c=n.doGet(s,a),l=(async function*(){for await(let p of c.responses)yield _l(p.dataHeader.length),yield p.dataHeader,yield p.dataBody})();yield*await Vt.from(l)}async*query(t,e,i){let n=this._queryRawBatches(t,e,i);for await(let s of n)for(let o of s){let a={};for(let c of s.schema.fields){let l=o[c.name];a[c.name]=sl(c,l)}yield a}}async*queryPoints(t,e,i){var s;let n=this._queryRawBatches(t,e,i);for await(let o of n)for(let a=0;a<o.numRows;a++){let c=new fr;for(let l=0;l<o.numCols;l++){let u=o.schema.fields[l],d=u.name,p=(s=o.getChildAt(l))==null?void 0:s.get(a),m=u.typeId,_=u.metadata.get("iox::column::type");if(p==null)continue;if((d==="measurement"||d=="iox::measurement")&&typeof p=="string"){c.setMeasurement(p);continue}if(!_){d==="time"&&m===f.Timestamp?c.setTimestamp(p):c.setField(d,p);continue}let[,,j,at]=_.split("::");if(j==="field"){if(at&&p!==void 0&&p!==null){let dt=sl(u,p);c.setField(d,dt,at)}}else j==="tag"?c.setTag(d,p):j==="timestamp"&&c.setTimestamp(p)}yield c}}async close(){var t,e;this._closed=!0,(e=(t=this._transport).close)==null||e.call(t)}};var ol=`Please specify the 'database' as a method parameter or use default configuration at 'ClientOptions.database'
|
|
21
21
|
`,qn=class{constructor(...t){z(this,"_options");z(this,"_writeApi");z(this,"_queryApi");z(this,"_transport");z(this,"_mergeWriteOptions",t=>{var n;let e={...(n=this._options.writeOptions)==null?void 0:n.headers,...t==null?void 0:t.headers},i={...this._options.writeOptions,...t};return i.headers=e,i});z(this,"_mergeQueryOptions",t=>{var s,o;let e={...(s=this._options.queryOptions)==null?void 0:s.headers,...t==null?void 0:t.headers},i={...(o=this._options.queryOptions)==null?void 0:o.params,...t==null?void 0:t.params},n={...this._options.queryOptions,...t};return n.headers=e,n.params=i,n});var s,o,a,c,l,u,d,p;let e;switch(t.length){case 0:{e=sa();break}case 1:{if(t[0]==null)throw new ur("No configuration specified!");typeof t[0]=="string"?e=na(t[0]):e=t[0];break}default:throw new ur("Multiple arguments specified!")}this._options={...ra,...e},this._options.grpcOptions?this._options.queryOptions={...e.queryOptions,grpcOptions:{...this._options.grpcOptions}}:(s=e.queryOptions)!=null&&s.grpcOptions&&(this._options.grpcOptions=(o=e.queryOptions)==null?void 0:o.grpcOptions);let i=this._options.host;if(typeof i!="string")throw new ur("No host specified!");if(i.endsWith("/")&&(this._options.host=i.substring(0,i.length-1)),typeof this._options.token!="string")throw new ur("No token specified!");this._queryApi=new Gn({...this._options,queryTimeout:(l=(a=this._options.queryOptions)==null?void 0:a.timeout)!=null?l:(c=this._options)==null?void 0:c.queryTimeout});let n=(p=(d=this._options.timeout)!=null?d:(u=this._options.writeOptions)==null?void 0:u.timeout)!=null?p:this._options.writeTimeout;this._transport=Rr.writeTransport({...this._options,writeTimeout:n}),this._writeApi=new Hi({transport:this._transport,...this._options})}async write(t,e,i,n){var o;let s=this._mergeWriteOptions(n);await this._writeApi.doWrite(pa(t,s==null?void 0:s.defaultTags,s==null?void 0:s.tagOrder),(o=e!=null?e:this._options.database)!=null?o:ei(new Error(ol)),i,s)}query(t,e,i=(n=>(n=this._options.queryOptions)!=null?n:Kn)()){var o;let s=this._mergeQueryOptions(i);return this._queryApi.query(t,(o=e!=null?e:this._options.database)!=null?o:ei(new Error(ol)),s)}queryPoints(t,e,i=(n=>(n=this._options.queryOptions)!=null?n:Kn)()){var o;let s=this._mergeQueryOptions(i);return this._queryApi.queryPoints(t,(o=e!=null?e:this._options.database)!=null?o:ei(new Error(ol)),s)}async getServerVersion(){let t;try{let e=await this._transport.request("/ping",null,{method:"GET"},(i,n)=>{var s;t=(s=i["X-Influxdb-Version"])!=null?s:i["x-influxdb-version"]});e&&!t&&(t=e.version)}catch(e){return Promise.reject(e)}return Promise.resolve(t)}async close(){await this._writeApi.close(),await this._queryApi.close()}};return id(im);})();
|
|
22
22
|
//# sourceMappingURL=influxdb.js.map
|
package/dist/influxdb.js.gz
CHANGED
|
Binary file
|