@loaders.gl/arrow 4.3.0-alpha.6 → 4.3.0-alpha.7

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.
@@ -5,7 +5,7 @@ import { parseArrowSync } from "./parsers/parse-arrow-sync.js";
5
5
  import { parseArrowInBatches } from "./parsers/parse-arrow-in-batches.js";
6
6
  // __VERSION__ is injected by babel-plugin-version-inline
7
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
- const VERSION = typeof "4.3.0-alpha.5" !== 'undefined' ? "4.3.0-alpha.5" : 'latest';
8
+ const VERSION = typeof "4.3.0-alpha.6" !== 'undefined' ? "4.3.0-alpha.6" : 'latest';
9
9
  /** ArrowJS table loader */
10
10
  export const ArrowWorkerLoader = {
11
11
  dataType: null,
@@ -12512,7 +12512,7 @@ return true;`);
12512
12512
  }
12513
12513
 
12514
12514
  // src/arrow-loader.ts
12515
- var VERSION = true ? "4.3.0-alpha.5" : "latest";
12515
+ var VERSION = true ? "4.3.0-alpha.6" : "latest";
12516
12516
  var ArrowWorkerLoader = {
12517
12517
  dataType: null,
12518
12518
  batchType: null,
@@ -2,7 +2,7 @@
2
2
  import { encodeArrowSync } from "./lib/encode-arrow.js";
3
3
  // __VERSION__ is injected by babel-plugin-version-inline
4
4
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
5
- const VERSION = typeof "4.3.0-alpha.5" !== 'undefined' ? "4.3.0-alpha.5" : 'latest';
5
+ const VERSION = typeof "4.3.0-alpha.6" !== 'undefined' ? "4.3.0-alpha.6" : 'latest';
6
6
  /** Apache Arrow writer */
7
7
  export const ArrowWriter = {
8
8
  name: 'Apache Arrow',
package/dist/dist.min.js CHANGED
@@ -13,11 +13,11 @@ ${t}`),new Function("x",`${t}
13
13
  return true;`)}function ld(r){return typeof r!="bigint"?Le(r):`${Le(r)}n`}function Aa(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function eu(r,t=0){return r.length>=t?r.subarray(0,t):qn(new r.constructor(t),r,0)}var Ee=class{constructor(t,e=0,n=1){this.length=Math.ceil(e/n),this.buffer=new t(this.length),this.stride=n,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,n=this.length*e,i=this.buffer.length;n>=i&&this._resize(i===0?Aa(n*1,this.BYTES_PER_ELEMENT):Aa(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=Aa(t*this.stride,this.BYTES_PER_ELEMENT);let e=eu(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=eu(this.buffer,t)}},ur=class extends Ee{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}},Ln=class extends ur{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:n}=this.reserve(t-this.length+1),i=t>>3,s=t%8,o=n[i]>>s&1;return e?o===0&&(n[i]|=1<<s,++this.numValid):o===1&&(n[i]&=~(1<<s),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},Nn=class extends ur{constructor(t){super(t.OffsetArrayType,1,1)}append(t){return this.set(this.length-1,t)}set(t,e){let n=this.length-1,i=this.reserve(t-n+1).buffer;return n<t++&&n>=0&&i.fill(i[n],n,t),i[t]=i[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 rt=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=he(t),this._nulls=new Ln,e&&e.length>0&&(this._isValid=tu(e))}toVector(){return new g([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:n,_nulls:i,_typeIds:s,children:o}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.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,n)=>e+n.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,n,i,{type:s,length:o,nullCount:a,_typeIds:c,_offsets:l,_values:u,_nulls:h}=this;(e=c?.flush(o))?i=l?.flush(o):(i=l?.flush(o))?t=u?.flush(l.last()):t=u?.flush(o),a>0&&(n=h?.flush(o));let d=this.children.map(b=>b.flush());return this.clear(),w({type:s,length:o,nullCount:a,children:d,child:d[0],data:t,typeIds:e,nullBitmap:n,valueOffsets:i})}finish(){this.finished=!0;for(let t of this.children)t.finish();return this}clear(){var t,e,n,i;this.length=0,(t=this._nulls)===null||t===void 0||t.clear(),(e=this._values)===null||e===void 0||e.clear(),(n=this._offsets)===null||n===void 0||n.clear(),(i=this._typeIds)===null||i===void 0||i.clear();for(let s of this.children)s.clear();return this}};rt.prototype.length=1;rt.prototype.stride=1;rt.prototype.children=null;rt.prototype.finished=!1;rt.prototype.nullValues=null;rt.prototype._isValid=()=>!0;var yt=class extends rt{constructor(t){super(t),this._values=new ur(this.ArrayType,0,this.stride)}setValue(t,e){let n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}},ee=class extends rt{constructor(t){super(t),this._pendingLength=0,this._offsets=new Nn(t.type)}setValue(t,e){let n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.length),this._pendingLength+=e instanceof tr?e[xe].length:e.length,n.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 tn=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,n,i){return t.prep(8,24),t.writeInt64(BigInt(i??0)),t.pad(4),t.writeInt32(n),t.writeInt64(BigInt(e??0)),t.offset()}};var Et=class{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 Et).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new Et).__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):$.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new ot).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new tn).__init(this.bb.__vector(this.bb_pos+n)+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 n=this.bb.__offset(this.bb_pos,10);return n?(e||new tn).__init(this.bb.__vector(this.bb_pos+n)+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 n=this.bb.__offset(this.bb_pos,12);return n?(e||new Q).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+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,$.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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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 E=class{constructor(t=[],e,n,i=$.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=Ta(t)),this.dictionaries=n,this.metadataVersion=i}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),n=this.fields.filter(i=>e.has(i.name));return new E(n,this.metadata)}selectAt(t){let e=t.map(n=>this.fields[n]).filter(Boolean);return new E(e,this.metadata)}assign(...t){let e=t[0]instanceof E?t[0]:Array.isArray(t[0])?new E(t[0]):new E(t),n=[...this.fields],i=Hs(Hs(new Map,this.metadata),e.metadata),s=e.fields.filter(a=>{let c=n.findIndex(l=>l.name===a.name);return~c?(n[c]=a.clone({metadata:Hs(Hs(new Map,n[c].metadata),a.metadata)}))&&!1:!0}),o=Ta(s,new Map);return new E([...n,...s],i,new Map([...this.dictionaries,...o]))}};E.prototype.fields=null;E.prototype.metadata=null;E.prototype.dictionaries=null;var D=class{static new(...t){let[e,n,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],n===void 0&&(n=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new D(`${e}`,n,i,s)}constructor(t,e,n=!1,i){this.name=t,this.type=e,this.nullable=n,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,n,i,s]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,n=this.type,i=this.nullable,s=this.metadata]=t:{name:e=this.name,type:n=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],D.new(e,n,i,s)}};D.prototype.type=null;D.prototype.name=null;D.prototype.nullable=null;D.prototype.metadata=null;function Hs(r,t){return new Map([...r||new Map,...t||new Map])}function Ta(r,t=new Map){for(let e=-1,n=r.length;++e<n;){let s=r[e].type;if(m.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&&Ta(s.children,t)}return t}var ud=ar,fd=Ct,fr=class{static decode(t){t=new fd(T(t));let e=Et.getRootAsFooter(t),n=E.decode(e.schema(),new Map,e.version());return new Da(n,e)}static encode(t){let e=new ud,n=E.encode(e,t.schema);Et.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())Re.encode(e,o);let i=e.endVector();Et.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())Re.encode(e,o);let s=e.endVector();return Et.startFooter(e),Et.addSchema(e,n),Et.addVersion(e,$.V5),Et.addRecordBatches(e,i),Et.addDictionaries(e,s),Et.finishFooterBuffer(e,Et.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=$.V5,n,i){this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e<n;)(t=this.getRecordBatch(e))&&(yield t)}*dictionaryBatches(){for(let t,e=-1,n=this.numDictionaries;++e<n;)(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 Da=class extends fr{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 Re.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return Re.decode(e)}return null}},Re=class{static decode(t){return new Re(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){let{metaDataLength:n}=e,i=BigInt(e.offset),s=BigInt(e.bodyLength);return tn.createBlock(t,i,n,s)}constructor(t,e,n){this.metaDataLength=t,this.offset=at(n),this.bodyLength=at(e)}};var q=Object.freeze({done:!0,value:void 0}),ui=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},en=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())}},Ys=class extends en{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return y(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(q);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Bt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Bt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return y(this,void 0,void 0,function*(){return yield this.abort(t),q})}return(t){return y(this,void 0,void 0,function*(){return yield this.close(),q})}read(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return y(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,n)=>{this.resolvers.push({resolve:e,reject:n})}):Promise.resolve(q)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var er=class extends Ys{write(t){if((t=T(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Xn(this.toUint8Array(!0)):this.toUint8Array(!1).then(Xn)}toUint8Array(t=!1){return t?ce(this._values)[0]:(()=>y(this,void 0,void 0,function*(){var e,n,i,s;let o=[],a=0;try{for(var c=!0,l=Te(this),u;u=yield l.next(),e=u.done,!e;c=!0){s=u.value,c=!1;let h=s;o.push(h),a+=h.byteLength}}catch(h){n={error:h}}finally{try{!c&&!e&&(i=l.return)&&(yield i.call(l))}finally{if(n)throw n.error}}return ce(o,a)[0]}))()}},rr=class{constructor(t){t&&(this.source=new Oa(Bt.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)}},re=class{constructor(t){t instanceof re?this.source=t.source:t instanceof er?this.source=new hr(Bt.fromAsyncIterable(t)):ps(t)?this.source=new hr(Bt.fromNodeStream(t)):Qn(t)?this.source=new hr(Bt.fromDOMStream(t)):hs(t)?this.source=new hr(Bt.fromDOMStream(t.body)):De(t)?this.source=new hr(Bt.fromIterable(t)):ae(t)?this.source=new hr(Bt.fromAsyncIterable(t)):de(t)&&(this.source=new hr(Bt.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)}},Oa=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)||q)}return(t){return Object.create(this.source.return&&this.source.return(t)||q)}},hr=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return y(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t,e="read"){return y(this,void 0,void 0,function*(){return yield this.source.next({cmd:e,size:t})})}throw(t){return y(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||q;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return y(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||q;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var fi=class extends rr{constructor(t,e){super(),this.position=0,this.buffer=T(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){let{buffer:e,byteOffset:n}=this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){let{buffer:e,size:n,position:i}=this;return e&&i<n?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(n,i+Math.min(n-i,t)),e.subarray(i,this.position)):null}readAt(t,e){let n=this.buffer,i=Math.min(this.size,t+e);return n?n.subarray(t,i):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}}},Fr=class extends re{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=(()=>y(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending}))()}readInt32(t){return y(this,void 0,void 0,function*(){let{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return y(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 y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:n,position:i}=this;if(e&&i<n){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,o=0,a=0,c=Math.min(n,s+Math.min(n-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 y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:n,size:i}=this;if(n&&t+e<i){let s=Math.min(i,t+e),o=new Uint8Array(s-t);return(yield n.read(o,0,e,t)).buffer}return new Uint8Array(e)})}close(){return y(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var Ma={};xr(Ma,{BaseInt64:()=>hi,Int128:()=>ne,Int64:()=>St,Uint64:()=>G});function Un(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var En=8,Fa=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],hi=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]),n=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]),i=e[3]*n[3];this.buffer[0]=i&65535;let s=i>>>16;return i=e[2]*n[3],s+=i,i=e[3]*n[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?65536:0,this.buffer[1]+=s>>>16,this.buffer[1]+=e[1]*n[3]+e[2]*n[2]+e[3]*n[1],this.buffer[1]+=e[0]*n[3]+e[1]*n[2]+e[2]*n[1]+e[3]*n[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`${Un(this.buffer[1])} ${Un(this.buffer[0])}`}},G=class extends hi{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return G.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return G.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.length,i=new G(e);for(let s=0;s<n;){let o=En<n-s?En:n-s,a=new G(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new G(new Uint32Array([Fa[o],0]));i.times(c),i.plus(a),s+=o}return i}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)G.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new G(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new G(new Uint32Array(t.buffer)).plus(e)}},St=class extends hi{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,n=t.buffer[1]<<0;return e<n||e===n&&this.buffer[0]<t.buffer[0]}static from(t,e=new Uint32Array(2)){return St.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return St.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.startsWith("-"),i=t.length,s=new St(e);for(let o=n?1:0;o<i;){let a=En<i-o?En:i-o,c=new St(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new St(new Uint32Array([Fa[a],0]));s.times(l),s.plus(c),o+=a}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)St.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new St(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new St(new Uint32Array(t.buffer)).plus(e)}},ne=class{constructor(t){this.buffer=t}high(){return new St(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new St(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 G(new Uint32Array([this.buffer[3],0])),n=new G(new Uint32Array([this.buffer[2],0])),i=new G(new Uint32Array([this.buffer[1],0])),s=new G(new Uint32Array([this.buffer[0],0])),o=new G(new Uint32Array([t.buffer[3],0])),a=new G(new Uint32Array([t.buffer[2],0])),c=new G(new Uint32Array([t.buffer[1],0])),l=new G(new Uint32Array([t.buffer[0],0])),u=G.multiply(s,l);this.buffer[0]=u.low();let h=new G(new Uint32Array([u.high(),0]));return u=G.multiply(i,l),h.plus(u),u=G.multiply(s,c),h.plus(u),this.buffer[1]=h.low(),this.buffer[3]=h.lessThan(u)?1:0,this.buffer[2]=h.high(),new G(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(G.multiply(n,l)).plus(G.multiply(i,c)).plus(G.multiply(s,a)),this.buffer[3]+=G.multiply(e,l).plus(G.multiply(n,c)).plus(G.multiply(i,a)).plus(G.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`${Un(this.buffer[3])} ${Un(this.buffer[2])} ${Un(this.buffer[1])} ${Un(this.buffer[0])}`}static multiply(t,e){return new ne(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new ne(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return ne.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return ne.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let n=t.startsWith("-"),i=t.length,s=new ne(e);for(let o=n?1:0;o<i;){let a=En<i-o?En:i-o,c=new ne(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new ne(new Uint32Array([Fa[a],0,0,0]));s.times(l),s.plus(c),o+=a}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*4);for(let n=-1,i=t.length;++n<i;)ne.from(t[n],new Uint32Array(e.buffer,e.byteOffset+4*4*n,4));return e}};var di=class extends v{constructor(t,e,n,i,s=$.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=e,this.buffers=n,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof D?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return w({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),children:this.visitMany(t.children)})}visitUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return this.metadataVersion<$.V5&&this.readNullBitmap(t,n),t.mode===K.Sparse?this.visitSparseUnion(t,{length:e,nullCount:n}):this.visitDenseUnion(t,{length:e,nullCount:n})}visitDenseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),child:this.visit(t.children[0])})}visitMap(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),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,n=this.nextBufferRange()){return e>0&&this.readData(t,n)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+e)}readDictionary(t){return this.dictionaries.get(t.id)}},Ks=class extends di{constructor(t,e,n,i,s){super(new Uint8Array(0),e,n,i,s),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):Xr(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return C(Uint8Array,C(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return C(Uint8Array,C(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;return m.isTimestamp(t)?C(Uint8Array,St.convertArray(n[e])):(m.isInt(t)||m.isTime(t))&&t.bitWidth===64||m.isDuration(t)?C(Uint8Array,St.convertArray(n[e])):m.isDate(t)&&t.unit===et.MILLISECOND?C(Uint8Array,St.convertArray(n[e])):m.isDecimal(t)?C(Uint8Array,ne.convertArray(n[e])):m.isBinary(t)||m.isLargeBinary(t)||m.isFixedSizeBinary(t)?hd(n[e]):m.isBool(t)?Xr(n[e]):m.isUtf8(t)||m.isLargeUtf8(t)?Pe(n[e].join("")):C(Uint8Array,C(t.ArrayType,n[e].map(i=>+i)))}};function hd(r){let t=r.join(""),e=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)e[n>>1]=Number.parseInt(t.slice(n,n+2),16);return e}var Rn=class extends ee{constructor(t){super(t),this._values=new Ee(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,T(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)n.set(o,0);else{let c=a.length;i.set(a,s),n.set(o,c),s+=c}}};var Cn=class extends ee{constructor(t){super(t),this._values=new Ee(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,T(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)n.set(o,BigInt(0));else{let c=a.length;i.set(a,s),n.set(o,BigInt(c)),s+=c}}};var Zs=class extends rt{constructor(t){super(t),this._values=new Ln}setValue(t,e){this._values.set(t,+e)}};var rn=class extends yt{};rn.prototype._setValue=fa;var pi=class extends rn{};pi.prototype._setValue=Is;var mi=class extends rn{};mi.prototype._setValue=xs;var yi=class extends yt{};yi.prototype._setValue=pa;var Js=class extends rt{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new Ut(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=dr({type:this.type.indices,nullValues:e}),this.dictionary=dr({type:this.type.dictionary,nullValues:null}),typeof n=="function"&&(this.valueToKey=n)}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 n=this.indices;return e=n.setValid(t,e),this.length=n.length,e}setValue(t,e){let n=this._keysToIndices,i=this.valueToKey(e),s=n[i];return s===void 0&&(n[i]=s=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,s)}flush(){let t=this.type,e=this._dictionary,n=this.dictionary.toVector(),i=this.indices.flush().clone(t);return i.dictionary=e?e.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=i.dictionary,this.clear(),i}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 gi=class extends yt{};gi.prototype._setValue=ua;var Xs=class extends rt{setValue(t,e){let[n]=this.children,i=t*this.stride;for(let s=-1,o=e.length;++s<o;)n.set(i+s,e[s])}addChild(t,e="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");let n=this.children.push(t);return this.type=new Vt(this.type.listSize,new D(e,t.type,!0)),n}};var nn=class extends yt{setValue(t,e){this._values.set(t,e)}},Qs=class extends nn{setValue(t,e){super.setValue(t,si(e))}},qs=class extends nn{},to=class extends nn{};var sn=class extends yt{};sn.prototype._setValue=ma;var bi=class extends sn{};bi.prototype._setValue=Ls;var wi=class extends sn{};wi.prototype._setValue=Ns;var pr=class extends yt{};pr.prototype._setValue=ya;var _i=class extends pr{};_i.prototype._setValue=Us;var vi=class extends pr{};vi.prototype._setValue=Es;var Ii=class extends pr{};Ii.prototype._setValue=Rs;var xi=class extends pr{};xi.prototype._setValue=Cs;var Se=class extends yt{setValue(t,e){this._values.set(t,e)}},eo=class extends Se{},ro=class extends Se{},no=class extends Se{},io=class extends Se{},so=class extends Se{},oo=class extends Se{},ao=class extends Se{},co=class extends Se{};var lo=class extends ee{constructor(t){super(t),this._offsets=new Nn(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 Tt(new D(e,t.type,!0)),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(typeof s>"u")e.set(i,0);else{let o=s,a=o.length,c=e.set(i,a).buffer[i];for(let l=-1;++l<a;)n.set(c+l,o[l])}}};var uo=class extends ee{set(t,e){return super.set(t,e)}setValue(t,e){let n=e instanceof Map?e:new Map(Object.entries(e)),i=this._pending||(this._pending=new Map),s=i.get(t);s&&(this._pendingLength-=s.size),this._pendingLength+=n.size,i.set(t,n)}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 jt(new D(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(s===void 0)e.set(i,0);else{let{[i]:o,[i+1]:a}=e.set(i,s.size).buffer;for(let c of s.entries())if(n.set(o,c),++o>=a)break}}};var fo=class extends rt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var ho=class extends rt{setValue(t,e){let{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach((s,o)=>n[o].set(t,e[o]));case Map:return i.children.forEach((s,o)=>n[o].set(t,e.get(s.name)));default:return i.children.forEach((s,o)=>n[o].set(t,e[s.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(n=>n.setValid(t,e)),e}addChild(t,e=`${this.numChildren}`){let n=this.children.push(t);return this.type=new V([...this.type.children,new D(e,t.type,!0)]),n}};var mr=class extends yt{};mr.prototype._setValue=ha;var Si=class extends mr{};Si.prototype._setValue=Ss;var Bi=class extends mr{};Bi.prototype._setValue=Bs;var Ai=class extends mr{};Ai.prototype._setValue=As;var Ti=class extends mr{};Ti.prototype._setValue=Ts;var yr=class extends yt{};yr.prototype._setValue=da;var Di=class extends yr{};Di.prototype._setValue=Ds;var Oi=class extends yr{};Oi.prototype._setValue=Os;var Fi=class extends yr{};Fi.prototype._setValue=Fs;var Mi=class extends yr{};Mi.prototype._setValue=Ms;var Pn=class extends rt{constructor(t){super(t),this._typeIds=new ur(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,n){return n===void 0&&(n=this._valueToChildTypeId(this,e,t)),this.setValue(t,e,n),this}setValue(t,e,n){this._typeIds.set(t,n);let i=this.type.typeIdToChildIndex[n],s=this.children[i];s?.set(t,e)}addChild(t,e=`${this.children.length}`){let n=this.children.push(t),{type:{children:i,mode:s,typeIds:o}}=this,a=[...i,new D(e,t.type)];return this.type=new Ie(s,[...o,n],a),n}_valueToChildTypeId(t,e,n){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.")}},po=class extends Pn{},mo=class extends Pn{constructor(t){super(t),this._offsets=new ur(Int32Array)}setValue(t,e,n){let i=this._typeIds.set(t,n).buffer[t],s=this.getChildAt(this.type.typeIdToChildIndex[i]),o=this._offsets.set(t,s.length).buffer[t];s?.set(o,e)}};var Li=class extends ee{constructor(t){super(t),this._values=new Ee(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,Pe(e))}_flushPending(t,e){}};Li.prototype._flushPending=Rn.prototype._flushPending;var Ni=class extends ee{constructor(t){super(t),this._values=new Ee(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,Pe(e))}_flushPending(t,e){}};Ni.prototype._flushPending=Cn.prototype._flushPending;var La=class extends v{visitNull(){return fo}visitBool(){return Zs}visitInt(){return Se}visitInt8(){return eo}visitInt16(){return ro}visitInt32(){return no}visitInt64(){return io}visitUint8(){return so}visitUint16(){return oo}visitUint32(){return ao}visitUint64(){return co}visitFloat(){return nn}visitFloat16(){return Qs}visitFloat32(){return qs}visitFloat64(){return to}visitUtf8(){return Li}visitLargeUtf8(){return Ni}visitBinary(){return Rn}visitLargeBinary(){return Cn}visitFixedSizeBinary(){return gi}visitDate(){return rn}visitDateDay(){return pi}visitDateMillisecond(){return mi}visitTimestamp(){return mr}visitTimestampSecond(){return Si}visitTimestampMillisecond(){return Bi}visitTimestampMicrosecond(){return Ai}visitTimestampNanosecond(){return Ti}visitTime(){return yr}visitTimeSecond(){return Di}visitTimeMillisecond(){return Oi}visitTimeMicrosecond(){return Fi}visitTimeNanosecond(){return Mi}visitDecimal(){return yi}visitList(){return lo}visitStruct(){return ho}visitUnion(){return Pn}visitDenseUnion(){return mo}visitSparseUnion(){return po}visitDictionary(){return Js}visitInterval(){return sn}visitIntervalDayTime(){return bi}visitIntervalYearMonth(){return wi}visitDuration(){return pr}visitDurationSecond(){return _i}visitDurationMillisecond(){return vi}visitDurationMicrosecond(){return Ii}visitDurationNanosecond(){return xi}visitFixedSizeList(){return Xs}visitMap(){return uo}},ru=new La;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((n,i)=>this.compareFields(n,e[i]))}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 zt(r,t){return t instanceof r.constructor}function on(r,t){return r===t||zt(r,t)}function gr(r,t){return r===t||zt(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function yo(r,t){return r===t||zt(r,t)&&r.precision===t.precision}function dd(r,t){return r===t||zt(r,t)&&r.byteWidth===t.byteWidth}function Na(r,t){return r===t||zt(r,t)&&r.unit===t.unit}function Ui(r,t){return r===t||zt(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function Ei(r,t){return r===t||zt(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function pd(r,t){return r===t||zt(r,t)&&r.children.length===t.children.length&&nr.compareManyFields(r.children,t.children)}function md(r,t){return r===t||zt(r,t)&&r.children.length===t.children.length&&nr.compareManyFields(r.children,t.children)}function Ua(r,t){return r===t||zt(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&nr.compareManyFields(r.children,t.children)}function yd(r,t){return r===t||zt(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&nr.visit(r.indices,t.indices)&&nr.visit(r.dictionary,t.dictionary)}function Ea(r,t){return r===t||zt(r,t)&&r.unit===t.unit}function Ri(r,t){return r===t||zt(r,t)&&r.unit===t.unit}function gd(r,t){return r===t||zt(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&nr.compareManyFields(r.children,t.children)}function bd(r,t){return r===t||zt(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&nr.compareManyFields(r.children,t.children)}B.prototype.visitNull=on;B.prototype.visitBool=on;B.prototype.visitInt=gr;B.prototype.visitInt8=gr;B.prototype.visitInt16=gr;B.prototype.visitInt32=gr;B.prototype.visitInt64=gr;B.prototype.visitUint8=gr;B.prototype.visitUint16=gr;B.prototype.visitUint32=gr;B.prototype.visitUint64=gr;B.prototype.visitFloat=yo;B.prototype.visitFloat16=yo;B.prototype.visitFloat32=yo;B.prototype.visitFloat64=yo;B.prototype.visitUtf8=on;B.prototype.visitLargeUtf8=on;B.prototype.visitBinary=on;B.prototype.visitLargeBinary=on;B.prototype.visitFixedSizeBinary=dd;B.prototype.visitDate=Na;B.prototype.visitDateDay=Na;B.prototype.visitDateMillisecond=Na;B.prototype.visitTimestamp=Ui;B.prototype.visitTimestampSecond=Ui;B.prototype.visitTimestampMillisecond=Ui;B.prototype.visitTimestampMicrosecond=Ui;B.prototype.visitTimestampNanosecond=Ui;B.prototype.visitTime=Ei;B.prototype.visitTimeSecond=Ei;B.prototype.visitTimeMillisecond=Ei;B.prototype.visitTimeMicrosecond=Ei;B.prototype.visitTimeNanosecond=Ei;B.prototype.visitDecimal=on;B.prototype.visitList=pd;B.prototype.visitStruct=md;B.prototype.visitUnion=Ua;B.prototype.visitDenseUnion=Ua;B.prototype.visitSparseUnion=Ua;B.prototype.visitDictionary=yd;B.prototype.visitInterval=Ea;B.prototype.visitIntervalDayTime=Ea;B.prototype.visitIntervalYearMonth=Ea;B.prototype.visitDuration=Ri;B.prototype.visitDurationSecond=Ri;B.prototype.visitDurationMillisecond=Ri;B.prototype.visitDurationMicrosecond=Ri;B.prototype.visitDurationNanosecond=Ri;B.prototype.visitFixedSizeList=gd;B.prototype.visitMap=bd;var nr=new B;function an(r,t){return nr.compareSchemas(r,t)}function nu(r,t){return nr.compareFields(r,t)}function go(r,t){return nr.visit(r,t)}function dr(r){let t=r.type,e=new(ru.getVisitFn(t)())(r);if(t.children&&t.children.length>0){let n=r.children||[],i={nullValues:r.nullValues},s=Array.isArray(n)?(o,a)=>n[a]||i:({name:o})=>n[o]||i;for(let[o,a]of t.children.entries()){let{type:c}=a,l=s(a,o);e.children.push(dr(Object.assign(Object.assign({},l),{type:c})))}}return e}function Ci(r,t){if(r instanceof R||r instanceof g||r.type instanceof m||ArrayBuffer.isView(r))return Or(r);let e={type:t??bo(r),nullValues:[null]},n=[...Ra(e)(r)],i=n.length===1?n[0]:n.reduce((s,o)=>s.concat(o));return m.isDictionary(i.type)?i.memoize():i}function bo(r){if(r.length===0)return new ut;let t=0,e=0,n=0,i=0,s=0,o=0,a=0,c=0;for(let l of r){if(l==null){++t;continue}switch(typeof l){case"bigint":++o;continue;case"boolean":++a;continue;case"number":++i;continue;case"string":++s;continue;case"object":Array.isArray(l)?++e:Object.prototype.toString.call(l)==="[object Date]"?++c:++n;continue}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}if(i+t===r.length)return new Qt;if(s+t===r.length)return new Ut(new Pt,new pt);if(o+t===r.length)return new be;if(a+t===r.length)return new kt;if(c+t===r.length)return new cr;if(e+t===r.length){let l=r,u=bo(l[l.findIndex(h=>h!=null)]);if(l.every(h=>h==null||go(u,bo(h))))return new Tt(new D("",u,!0))}else if(n+t===r.length){let l=new Map;for(let u of r)for(let h of Object.keys(u))!l.has(h)&&u[h]!=null&&l.set(h,new D(h,bo([u[h]]),!0));return new V([...l.values()])}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}function Ra(r){let{["queueingStrategy"]:t="count"}=r,{["highWaterMark"]:e=t!=="bytes"?Number.POSITIVE_INFINITY:Math.pow(2,14)}=r,n=t!=="bytes"?"length":"byteLength";return function*(i){let s=0,o=dr(r);for(let a of i)o.append(a)[n]>=e&&++s&&(yield o.toVector());(o.finish().length>0||s===0)&&(yield o.toVector())}}function wo(r,t){return wd(r,t.map(e=>e.data.concat()))}function wd(r,t){let e=[...r.fields],n=[],i={numBatches:t.reduce((h,d)=>Math.max(h,d.length),0)},s=0,o=0,a=-1,c=t.length,l,u=[];for(;i.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=_d(e,o,u,t,i),o>0&&(n[s++]=w({type:new V(e),length:o,nullCount:0,children:u.slice()})))}return[r=r.assign(e),n.map(h=>new Y(r,h))]}function _d(r,t,e,n,i){var s;let o=(t+63&-64)>>3;for(let a=-1,c=n.length;++a<c;){let l=e[a],u=l?.length;if(u>=t)u===t?e[a]=l:(e[a]=l.slice(0,t),i.numBatches=Math.max(i.numBatches,n[a].unshift(l.slice(t,u-t))));else{let h=r[a];r[a]=h.clone({nullable:!0}),e[a]=(s=l?._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:w({type:h.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var iu,J=class{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new E([]),this._offsets=[0],this;let i,s;t[0]instanceof E&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=c=>{if(c){if(c instanceof Y)return[c];if(c instanceof J)return c.batches;if(c instanceof R){if(c.type instanceof V)return[new Y(new E(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(b=>new g([c[b]])),h=i??new E(l.map((b,M)=>new D(String(b),u[M].type,u[M].nullable))),[,d]=wo(h,u);return d.length===0?[new Y(c)]:d}}}return[]},a=t.flatMap(c=>o(c));if(i=(n=i??((e=a[0])===null||e===void 0?void 0:e.schema))!==null&&n!==void 0?n:new E([]),!(i instanceof E))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof Y))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!an(i,c.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??zs(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=js(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?Fn.visit(new g(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
14
14
  ${this.toArray().join(`,
15
15
  `)}
16
- ]`}concat(...t){let e=this.schema,n=this.data.concat(t.flatMap(({data:i})=>i));return new J(e,n.map(i=>new Y(e,i)))}slice(t,e){let n=this.schema;[t,e]=oi({length:this.numRows},t,e);let i=Ws(this.data,this._offsets,t,e);return new J(n,i.map(s=>new Y(n,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(n=>n.children[t]);if(e.length===0){let{type:n}=this.schema.fields[t],i=w({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new g(e)}return null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new g([w({type:new ut,length:this.numRows})]));let s=n.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],[n,i]=wo(n,a)}return new J(n,i)}select(t){let e=this.schema.fields.reduce((n,i,s)=>n.set(i.name,s),new Map);return this.selectAt(t.map(n=>e.get(n)).filter(n=>n>-1))}selectAt(t){let e=this.schema.selectAt(t),n=this.batches.map(i=>i.selectAt(t));return new J(e,n)}assign(t){let e=this.schema.fields,[n,i]=t.schema.fields.reduce((a,c,l)=>{let[u,h]=a,d=e.findIndex(b=>b.name===c.name);return~d?h[d]=l:u.push(l),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,i[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...n.map(a=>t.getChildAt(a))].filter(Boolean);return new J(...wo(s,o))}};iu=Symbol.toStringTag;J[iu]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=On(li),r.get=On(mt.getVisitFn(f.Struct)),r.set=Gs(Dt.getVisitFn(f.Struct)),r.indexOf=$s(qr.getVisitFn(f.Struct)),"Table"))(J.prototype);var ou,Y=class{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof E))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=w({nullCount:0,type:new V(this.schema.fields),children:this.schema.fields.map(e=>w({type:e.type,nullCount:0}))})]=t,!(this.data instanceof R))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=su(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:n,children:i,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]=D.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new E(n),a=w({type:new V(n),length:s,children:i,nullCount:0});[this.schema,this.data]=su(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=au(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)}set(t,e){return Dt.visit(this.data,t,e)}indexOf(t,e){return qr.visit(this.data,t,e)}[Symbol.iterator](){return Fn.visit(new g([this.data]))}toArray(){return[...this]}concat(...t){return new J(this.schema,[this,...t])}slice(t,e){let[n]=new g([this.data]).slice(t,e).data;return new Y(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new g([this.data.children[t]]):null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=this.data;if(t>-1&&t<this.numCols){e||(e=new g([w({type:new ut,length:this.numRows})]));let s=n.fields.slice(),o=i.children.slice(),a=s[t].clone({type:e.type});[s[t],o[t]]=[a,e.data[0]],n=new E(s,new Map(this.schema.metadata)),i=w({type:new V(s),children:o})}return new Y(n,i)}select(t){let e=this.schema.select(t),n=new V(e.fields),i=[];for(let s of t){let o=this.schema.fields.findIndex(a=>a.name===s);~o&&(i[o]=this.data.children[o])}return new Y(e,w({type:n,length:this.numRows,children:i}))}selectAt(t){let e=this.schema.selectAt(t),n=t.map(s=>this.data.children[s]).filter(Boolean),i=w({type:new V(e.fields),length:this.numRows,children:n});return new Y(e,i)}};ou=Symbol.toStringTag;Y[ou]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Y.prototype);function su(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;let i=[...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)&&(i[a]=c.clone({nullable:!0}),s[a]=(n=l?._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:w({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(i),w({type:new V(i),length:e,children:s})]}function au(r,t,e=new Map){var n,i;if(((n=r?.length)!==null&&n!==void 0?n:0)>0&&r?.length===t?.length)for(let s=-1,o=r.length;++s<o;){let{type:a}=r[s],c=t[s];for(let l of[c,...((i=c?.dictionary)===null||i===void 0?void 0:i.data)||[]])au(a.children,l?.children,e);if(m.isDictionary(a)){let{id:l}=a;if(!e.has(l))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 cn=class extends Y{constructor(t){let e=t.fields.map(i=>w({type:i.type})),n=w({type:new V(t.fields),nullCount:0,children:e});super(t,n)}};var ft=class{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 ft).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new ft).__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):$.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):P.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 n=this.bb.__offset(this.bb_pos,12);return n?(e||new Q).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+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,$.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,P.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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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,n,i,s,o){return ft.startMessage(t),ft.addVersion(t,e),ft.addHeaderType(t,n),ft.addHeader(t,i),ft.addBodyLength(t,s),ft.addCustomMetadata(t,o),ft.endMessage(t)}};var Ca=class extends v{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return He.startNull(e),He.endNull(e)}visitInt(t,e){return _t.startInt(e),_t.addBitWidth(e,t.bitWidth),_t.addIsSigned(e,t.isSigned),_t.endInt(e)}visitFloat(t,e){return Kt.startFloatingPoint(e),Kt.addPrecision(e,t.precision),Kt.endFloatingPoint(e)}visitBinary(t,e){return je.startBinary(e),je.endBinary(e)}visitLargeBinary(t,e){return We.startLargeBinary(e),We.endLargeBinary(e)}visitBool(t,e){return ze.startBool(e),ze.endBool(e)}visitUtf8(t,e){return Ke.startUtf8(e),Ke.endUtf8(e)}visitLargeUtf8(t,e){return Ge.startLargeUtf8(e),Ge.endLargeUtf8(e)}visitDecimal(t,e){return vt.startDecimal(e),vt.addScale(e,t.scale),vt.addPrecision(e,t.precision),vt.addBitWidth(e,t.bitWidth),vt.endDecimal(e)}visitDate(t,e){return Gt.startDate(e),Gt.addUnit(e,t.unit),Gt.endDate(e)}visitTime(t,e){return Mt.startTime(e),Mt.addUnit(e,t.unit),Mt.addBitWidth(e,t.bitWidth),Mt.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return Lt.startTimestamp(e),Lt.addUnit(e,t.unit),n!==void 0&&Lt.addTimezone(e,n),Lt.endTimestamp(e)}visitInterval(t,e){return Zt.startInterval(e),Zt.addUnit(e,t.unit),Zt.endInterval(e)}visitDuration(t,e){return $t.startDuration(e),$t.addUnit(e,t.unit),$t.endDuration(e)}visitList(t,e){return $e.startList(e),$e.endList(e)}visitStruct(t,e){return Ye.startStruct_(e),Ye.endStruct_(e)}visitUnion(t,e){It.startTypeIdsVector(e,t.typeIds.length);let n=It.createTypeIdsVector(e,t.typeIds);return It.startUnion(e),It.addMode(e,t.mode),It.addTypeIds(e,n),It.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return le.startDictionaryEncoding(e),le.addId(e,BigInt(t.id)),le.addIsOrdered(e,t.isOrdered),n!==void 0&&le.addIndexType(e,n),le.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Ht.startFixedSizeBinary(e),Ht.addByteWidth(e,t.byteWidth),Ht.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Yt.startFixedSizeList(e),Yt.addListSize(e,t.listSize),Yt.endFixedSizeList(e)}visitMap(t,e){return Jt.startMap(e),Jt.addKeysSorted(e,t.keysSorted),Jt.endMap(e)}},_o=new Ca;function fu(r,t=new Map){return new E(vd(r,t),vo(r.metadata),t)}function Pa(r){return new Ot(r.count,du(r.columns),pu(r.columns))}function hu(r){return new se(Pa(r.data),r.id,r.isDelta)}function vd(r,t){return(r.fields||[]).filter(Boolean).map(e=>D.fromJSON(e,t))}function cu(r,t){return(r.children||[]).filter(Boolean).map(e=>D.fromJSON(e,t))}function du(r){return(r||[]).reduce((t,e)=>[...t,new Be(e.count,Id(e.VALIDITY)),...du(e.children)],[])}function pu(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new ie(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new ie(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new ie(t.length,i.OFFSET.length)),i.DATA&&t.push(new ie(t.length,i.DATA.length)),t=pu(i.children,t)}return t}function Id(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function mu(r,t){let e,n,i,s,o,a;return!t||!(s=r.dictionary)?(o=uu(r,cu(r,t)),i=new D(r.name,o,r.nullable,vo(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?lu(n):new pt,a=new Ut(t.get(e),n,e,s.isOrdered),i=new D(r.name,a,r.nullable,vo(r.metadata))):(n=(n=s.indexType)?lu(n):new pt,t.set(e,o=uu(r,cu(r,t))),a=new Ut(o,n,e,s.isOrdered),i=new D(r.name,a,r.nullable,vo(r.metadata))),i||null}function vo(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function lu(r){return new it(r.isSigned,r.bitWidth)}function uu(r,t){let e=r.type.name;switch(e){case"NONE":return new ut;case"null":return new ut;case"binary":return new ue;case"largebinary":return new Je;case"utf8":return new Pt;case"largeutf8":return new Xe;case"bool":return new kt;case"list":return new Tt((t||[])[0]);case"struct":return new V(t||[]);case"struct_":return new V(t||[])}switch(e){case"int":{let n=r.type;return new it(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new At(j[n.precision])}case"decimal":{let n=r.type;return new fe(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new qt(et[n.unit])}case"time":{let n=r.type;return new xt(p[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new Nt(p[n.unit],n.timezone)}case"interval":{let n=r.type;return new te(nt[n.unit])}case"duration":{let n=r.type;return new Qe(p[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new Ie(K[o],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new qe(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new Vt(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new jt((t||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var xd=ar,Sd=Ct,gt=class{static fromJSON(t,e){let n=new gt(0,$.V5,e);return n._createHeader=Bd(t,e),n}static decode(t){t=new Sd(T(t));let e=ft.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new gt(n,i,s);return o._createHeader=Ad(e,s),o}static encode(t){let e=new xd,n=-1;return t.isSchema()?n=E.encode(e,t.header()):t.isRecordBatch()?n=Ot.encode(e,t.header()):t.isDictionaryBatch()&&(n=se.encode(e,t.header())),ft.startMessage(e),ft.addVersion(e,$.V5),ft.addHeader(e,n),ft.addHeaderType(e,t.headerType),ft.addBodyLength(e,BigInt(t.bodyLength)),ft.finishMessageBuffer(e,ft.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof E)return new gt(0,$.V5,P.Schema,t);if(t instanceof Ot)return new gt(e,$.V5,P.RecordBatch,t);if(t instanceof se)return new gt(e,$.V5,P.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 bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===P.Schema}isRecordBatch(){return this.headerType===P.RecordBatch}isDictionaryBatch(){return this.headerType===P.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=at(t)}},Ot=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=at(t)}},se=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,n=!1){this._data=t,this._isDelta=n,this._id=at(e)}},ie=class{constructor(t,e){this.offset=at(t),this.length=at(e)}},Be=class{constructor(t,e){this.length=at(t),this.nullCount=at(e)}};function Bd(r,t){return()=>{switch(t){case P.Schema:return E.fromJSON(r);case P.RecordBatch:return Ot.fromJSON(r);case P.DictionaryBatch:return se.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${P[t]}, type: ${t} }`)}}function Ad(r,t){return()=>{switch(t){case P.Schema:return E.decode(r.header(new ot),new Map,r.version());case P.RecordBatch:return Ot.decode(r.header(new Ft),r.version());case P.DictionaryBatch:return se.decode(r.header(new me),r.version())}throw new Error(`Unrecognized Message type: { name: ${P[t]}, type: ${t} }`)}}D.encode=Cd;D.decode=Ed;D.fromJSON=mu;E.encode=Rd;E.decode=Td;E.fromJSON=fu;Ot.encode=Pd;Ot.decode=Dd;Ot.fromJSON=Pa;se.encode=kd;se.decode=Od;se.fromJSON=hu;Be.encode=Vd;Be.decode=Md;ie.encode=jd;ie.decode=Fd;function Td(r,t=new Map,e=$.V5){let n=Ud(r,t);return new E(n,Io(r),t,e)}function Dd(r,t=$.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Ot(r.length(),Ld(r),Nd(r,t))}function Od(r,t=$.V5){return new se(Ot.decode(r.data(),t),r.id(),r.isDelta())}function Fd(r){return new ie(r.offset(),r.length())}function Md(r){return new Be(r.length(),r.nullCount())}function Ld(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=Be.decode(e));return t}function Nd(r,t){let e=[];for(let n,i=-1,s=-1,o=r.buffersLength();++i<o;)(n=r.buffers(i))&&(t<$.V4&&(n.bb_pos+=8*(i+1)),e[++s]=ie.decode(n));return e}function Ud(r,t){let e=[];for(let n,i=-1,s=-1,o=r.fieldsLength();++i<o;)(n=r.fields(i))&&(e[++s]=D.decode(n,t));return e}function yu(r,t){let e=[];for(let n,i=-1,s=-1,o=r.childrenLength();++i<o;)(n=r.children(i))&&(e[++s]=D.decode(n,t));return e}function Ed(r,t){let e,n,i,s,o,a;return!t||!(a=r.dictionary())?(i=bu(r,yu(r,t)),n=new D(r.name(),i,r.nullable(),Io(r))):t.has(e=at(a.id()))?(s=(s=a.indexType())?gu(s):new pt,o=new Ut(t.get(e),s,e,a.isOrdered()),n=new D(r.name(),o,r.nullable(),Io(r))):(s=(s=a.indexType())?gu(s):new pt,t.set(e,i=bu(r,yu(r,t))),o=new Ut(i,s,e,a.isOrdered()),n=new D(r.name(),o,r.nullable(),Io(r))),n||null}function Io(r){let t=new Map;if(r)for(let e,n,i=-1,s=Math.trunc(r.customMetadataLength());++i<s;)(e=r.customMetadata(i))&&(n=e.key())!=null&&t.set(n,e.value());return t}function gu(r){return new it(r.isSigned(),r.bitWidth())}function bu(r,t){let e=r.typeType();switch(e){case Z.NONE:return new ut;case Z.Null:return new ut;case Z.Binary:return new ue;case Z.LargeBinary:return new Je;case Z.Utf8:return new Pt;case Z.LargeUtf8:return new Xe;case Z.Bool:return new kt;case Z.List:return new Tt((t||[])[0]);case Z.Struct_:return new V(t||[])}switch(e){case Z.Int:{let n=r.type(new _t);return new it(n.isSigned(),n.bitWidth())}case Z.FloatingPoint:{let n=r.type(new Kt);return new At(n.precision())}case Z.Decimal:{let n=r.type(new vt);return new fe(n.scale(),n.precision(),n.bitWidth())}case Z.Date:{let n=r.type(new Gt);return new qt(n.unit())}case Z.Time:{let n=r.type(new Mt);return new xt(n.unit(),n.bitWidth())}case Z.Timestamp:{let n=r.type(new Lt);return new Nt(n.unit(),n.timezone())}case Z.Interval:{let n=r.type(new Zt);return new te(n.unit())}case Z.Duration:{let n=r.type(new $t);return new Qe(n.unit())}case Z.Union:{let n=r.type(new It);return new Ie(n.mode(),n.typeIdsArray()||[],t||[])}case Z.FixedSizeBinary:{let n=r.type(new Ht);return new qe(n.byteWidth())}case Z.FixedSizeList:{let n=r.type(new Yt);return new Vt(n.listSize(),(t||[])[0])}case Z.Map:{let n=r.type(new Jt);return new jt((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${Z[e]}" (${e})`)}function Rd(r,t){let e=t.fields.map(s=>D.encode(r,s));ot.startFieldsVector(r,e.length);let n=ot.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?ot.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString(`${s}`),c=r.createString(`${o}`);return Q.startKeyValue(r),Q.addKey(r,a),Q.addValue(r,c),Q.endKeyValue(r)})):-1;return ot.startSchema(r),ot.addFields(r,n),ot.addEndianness(r,zd?Sr.Little:Sr.Big),i!==-1&&ot.addCustomMetadata(r,i),ot.endSchema(r)}function Cd(r,t){let e=-1,n=-1,i=-1,s=t.type,o=t.typeId;m.isDictionary(s)?(o=s.dictionary.typeId,i=_o.visit(s,r),n=_o.visit(s.dictionary,r)):n=_o.visit(s,r);let a=(s.children||[]).map(u=>D.encode(r,u)),c=dt.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?dt.createCustomMetadataVector(r,[...t.metadata].map(([u,h])=>{let d=r.createString(`${u}`),b=r.createString(`${h}`);return Q.startKeyValue(r),Q.addKey(r,d),Q.addValue(r,b),Q.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),dt.startField(r),dt.addType(r,n),dt.addTypeType(r,o),dt.addChildren(r,c),dt.addNullable(r,!!t.nullable),e!==-1&&dt.addName(r,e),i!==-1&&dt.addDictionary(r,i),l!==-1&&dt.addCustomMetadata(r,l),dt.endField(r)}function Pd(r,t){let e=t.nodes||[],n=t.buffers||[];Ft.startNodesVector(r,e.length);for(let o of e.slice().reverse())Be.encode(r,o);let i=r.endVector();Ft.startBuffersVector(r,n.length);for(let o of n.slice().reverse())ie.encode(r,o);let s=r.endVector();return Ft.startRecordBatch(r),Ft.addLength(r,BigInt(t.length)),Ft.addNodes(r,i),Ft.addBuffers(r,s),Ft.endRecordBatch(r)}function kd(r,t){let e=Ot.encode(r,t.data);return me.startDictionaryBatch(r),me.addId(r,BigInt(t.id)),me.addIsDelta(r,t.isDelta),me.addData(r,e),me.endDictionaryBatch(r)}function Vd(r,t){return vn.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function jd(r,t){return _n.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var zd=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var Va=r=>`Expected ${P[r]} Message in stream, but was null or length 0.`,ja=r=>`Header pointer of flatbuffer-encoded ${P[r]} Message is null or length 0.`,wu=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,_u=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,kn=class{constructor(t){this.source=t instanceof rr?t:new rr(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?q:t.value===-1&&(t=this.readMetadataLength()).done?q:(t=this.readMetadata(t.value)).done?q: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(Va(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=T(this.source.read(t));if(e.byteLength<t)throw new Error(_u(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=P.Schema,n=this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(ja(e));return i}readMetadataLength(){let t=this.source.read(xo),e=t&&new Ct(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}}readMetadata(t){let e=this.source.read(t);if(!e)return q;if(e.byteLength<t)throw new Error(wu(t,e.byteLength));return{done:!1,value:gt.decode(e)}}},Pi=class{constructor(t,e){this.source=t instanceof re?t:fs(t)?new Fr(t,e):new re(t)}[Symbol.asyncIterator](){return this}next(){return y(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?q:t.value===-1&&(t=yield this.readMetadataLength()).done?q:(t=yield this.readMetadata(t.value)).done?q:t})}throw(t){return y(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return y(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return y(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(Va(t));return e.value})}readMessageBody(t){return y(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=T(yield this.source.read(t));if(e.byteLength<t)throw new Error(_u(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(t=!1){return y(this,void 0,void 0,function*(){let e=P.Schema,n=yield this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(ja(e));return i})}readMetadataLength(){return y(this,void 0,void 0,function*(){let t=yield this.source.read(xo),e=t&&new Ct(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}})}readMetadata(t){return y(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return q;if(e.byteLength<t)throw new Error(wu(t,e.byteLength));return{done:!1,value:gt.decode(e)}})}},ki=class extends kn{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof ui?t:new ui(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:gt.fromJSON(t.schema,P.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:gt.fromJSON(e,P.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:gt.fromJSON(e,P.RecordBatch)}}return this._body=[],q}readMessageBody(t){return e(this._body);function e(n){return(n||[]).reduce((i,s)=>[...i,...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(Va(t));return e.value}readSchema(){let t=P.Schema,e=this.readMessage(t),n=e?.header();if(!e||!n)throw new Error(ja(t));return n}},xo=4,ka="ARROW1",Vn=new Uint8Array(ka.length);for(let r=0;r<ka.length;r+=1)Vn[r]=ka.codePointAt(r);function So(r,t=0){for(let e=-1,n=Vn.length;++e<n;)if(Vn[e]!==r[t+e])return!1;return!0}var jn=Vn.length,za=jn+xo,vu=jn*2+xo;var bt=class extends en{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 ae(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 Bt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Bt.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 bt?t:ls(t)?Gd(t):fs(t)?Yd(t):ae(t)?(()=>y(this,void 0,void 0,function*(){return yield bt.from(yield t)}))():hs(t)||Qn(t)||ps(t)||de(t)?Hd(new re(t)):$d(new rr(t))}static readAll(t){return t instanceof bt?t.isSync()?Iu(t):xu(t):ls(t)||ArrayBuffer.isView(t)||De(t)||us(t)?Iu(t):xu(t)}},ir=class extends bt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return oe(this,arguments,function*(){yield U(yield*bn(Te(this[Symbol.iterator]())))})}},Mr=class extends bt{constructor(t){super(t),this._impl=t}readAll(){var t,e,n,i;return y(this,void 0,void 0,function*(){let s=new Array;try{for(var o=!0,a=Te(this),c;c=yield a.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let l=i;s.push(l)}}catch(l){e={error:l}}finally{try{!o&&!t&&(n=a.return)&&(yield n.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]()}},Lr=class extends ir{constructor(t){super(t),this._impl=t}},Vi=class extends Mr{constructor(t){super(t),this._impl=t}},Bo=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 n=this._loadVectors(t,e,this.schema.fields),i=w({type:new V(this.schema.fields),length:t.length,children:n});return new Y(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:o}=this,a=s.get(n);if(i||!a){let c=o.dictionaries.get(n),l=this._loadVectors(t.data,e,[c]);return(a&&i?a.concat(new g(l)):new g(l)).memoize()}return a.memoize()}_loadVectors(t,e,n){return new di(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},zn=class extends Bo{constructor(t,e){super(e),this._reader=ls(t)?new ki(this._handle=t):new kn(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=Su(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):q}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):q}next(){if(this.closed)return q;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new cn(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Wn=class extends Bo{constructor(t,e){super(e),this._reader=new Pi(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return y(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 y(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Su(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):q})}return(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):q})}next(){return y(this,void 0,void 0,function*(){if(this.closed)return q;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 n=t.header(),i=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new cn(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return y(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Ao=class extends zn{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 fi?t:new fi(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 n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(P.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(P.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-za,n=t.readInt32(e),i=t.readAt(e-n,n);return fr.decode(i)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(n&&this._handle.seek(n.offset))return this._reader.readMessage(t)}return null}},Wa=class extends Wn{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 n=typeof e[0]!="number"?e.shift():void 0,i=e[0]instanceof Map?e.shift():void 0;super(t instanceof Fr?t:new Fr(t,n),i)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return y(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){var e;return y(this,void 0,void 0,function*(){if(this.closed)return null;this._footer||(yield this.open());let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(P.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){var e;return y(this,void 0,void 0,function*(){let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(P.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return y(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-za,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return fr.decode(i)})}_readNextMessageAndValidate(t){return y(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})}},Ga=class extends zn{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new Ks(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function Su(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Iu(r){let t=bt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function xu(r){return oe(this,arguments,function*(){let e=yield U(bt.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 Gd(r){return new ir(new Ga(r))}function $d(r){let t=r.peek(jn+7&-8);return t&&t.byteLength>=4?So(t)?new Lr(new Ao(r.read())):new ir(new zn(r)):new ir(new zn(function*(){}()))}function Hd(r){return y(this,void 0,void 0,function*(){let t=yield r.peek(jn+7&-8);return t&&t.byteLength>=4?So(t)?new Lr(new Ao(yield r.read())):new Mr(new Wn(r)):new Mr(new Wn(function(){return oe(this,arguments,function*(){})}()))})}function Yd(r){return y(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Fr(r,t);return t>=vu&&So(yield e.readAt(0,jn+7&-8))?new Vi(new Wa(e)):new Mr(new Wn(e))})}var tt=class extends v{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof Y?s.data.children:s.data),n=new tt;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof g)return this.visitMany(t.data),this;let{type:e}=t;if(!m.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(m.isUnion(e))this.nodes.push(new Be(n,0));else{let{nullCount:i}=t;m.isNull(e)||Ce.call(this,i<=0?new Uint8Array(0):Jr(t.offset,n,t.nullBitmap)),this.nodes.push(new Be(n,i))}}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 Ce(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new ie(this._byteLength,t)),this._byteLength+=t,this}function Kd(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(Ce.call(this,i),e.mode===K.Sparse)return $a.call(this,r);if(e.mode===K.Dense){if(r.offset<=0)return Ce.call(this,s),$a.call(this,r);{let o=new Int32Array(n),a=Object.create(null),c=Object.create(null);for(let l,u,h=-1;++h<n;)(l=i[h])!==void 0&&((u=a[l])===void 0&&(u=a[l]=s[h]),o[h]=s[h]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);Ce.call(this,o),this.visitMany(r.children.map((l,u)=>{let h=e.typeIds[u],d=a[h],b=c[h];return l.slice(d,Math.min(n,b))}))}}return this}function Zd(r){let t;return r.nullCount>=r.length?Ce.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?Ce.call(this,Jr(r.offset,r.length,t)):Ce.call(this,Xr(r.values))}function br(r){return Ce.call(this,r.values.subarray(0,r.length*r.stride))}function To(r){let{length:t,values:e,valueOffsets:n}=r,i=at(n[0]),s=at(n[t]),o=Math.min(s-i,e.byteLength-i);return Ce.call(this,ys(-i,t+1,n)),Ce.call(this,e.subarray(i,i+o)),this}function Ha(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return Ce.call(this,ys(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function $a(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}tt.prototype.visitBool=Zd;tt.prototype.visitInt=br;tt.prototype.visitFloat=br;tt.prototype.visitUtf8=To;tt.prototype.visitLargeUtf8=To;tt.prototype.visitBinary=To;tt.prototype.visitLargeBinary=To;tt.prototype.visitFixedSizeBinary=br;tt.prototype.visitDate=br;tt.prototype.visitTimestamp=br;tt.prototype.visitTime=br;tt.prototype.visitDecimal=br;tt.prototype.visitList=Ha;tt.prototype.visitStruct=$a;tt.prototype.visitUnion=Kd;tt.prototype.visitInterval=br;tt.prototype.visitDuration=br;tt.prototype.visitFixedSizeList=Ha;tt.prototype.visitMap=Ha;var ln=class extends en{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){super(),this._position=0,this._started=!1,this._sink=new er,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,Rt(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return ae(t)?t.then(e=>this.writeAll(e)):de(t)?Ka(this,t):Ya(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 er?this._sink=t:(this._sink=new er,t&&Pc(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&kc(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,(!e||!an(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 J&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Y&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!an(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Y?t instanceof cn||this._writeRecordBatch(t):t instanceof J?this.writeAll(t.batches):De(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=gt.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+n&~n,c=a-s-o;return t.headerType===P.RecordBatch?this._recordBatchBlocks.push(new Re(a,t.bodyLength,this._position)):t.headerType===P.DictionaryBatch&&this._dictionaryBlocks.push(new Re(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(c)}_write(t){if(this._started){let e=T(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(gt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Vn)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=tt.assemble(t),o=new Ot(t.numRows,n,i),a=gt.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0));let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=tt.assemble(new g([t])),c=new Ot(t.length,s,o),l=new se(c,e,n),u=gt.from(l,i);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,n,i;for(let s=-1,o=t.length;++s<o;)(e=t[s])&&(n=e.byteLength)>0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this}_writeDictionaries(t){for(let[e,n]of t.dictionaries){let i=this._dictionaryDeltaOffsets.get(e)||0;if(i===0||(n=n?.slice(i)).length>0)for(let s of n.data)this._writeDictionaryBatch(s,e,i>0),i+=s.length}return this}},wr=class extends ln{static writeAll(t,e){let n=new wr(e);return ae(t)?t.then(i=>n.writeAll(i)):de(t)?Ka(n,t):Ya(n,t)}},_r=class extends ln{static writeAll(t){let e=new _r;return ae(t)?t.then(n=>e.writeAll(n)):de(t)?Ka(e,t):Ya(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){let e=fr.encode(new fr(t,$.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Ya(r,t){let e=t;t instanceof J&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function Ka(r,t){var e,n,i,s,o,a,c;return y(this,void 0,void 0,function*(){try{for(e=!0,n=Te(t);i=yield n.next(),s=i.done,!s;e=!0){c=i.value,e=!1;let l=c;r.write(l)}}catch(l){o={error:l}}finally{try{!e&&!s&&(a=n.return)&&(yield a.call(n))}finally{if(o)throw o.error}}return r.finish()})}function Bu(r,t){if(de(r))return Xd(r,t);if(De(r))return Jd(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Jd(r,t){let e=null,n=t?.type==="bytes"||!1,i=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?.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){let c,l=null,u=o.desiredSize||null;for(;!(l=a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=T(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()}}function Xd(r,t){let e=null,n=t?.type==="bytes"||!1,i=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return y(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return y(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return y(this,void 0,void 0,function*(){(e?.return&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){return y(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=T(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()})}}function Du(r){return new Za(r)}var Za=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=Rc(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=dr(s),this._getSize=i!=="bytes"?Au:Tu;let{["highWaterMark"]:o=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n);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:i!=="bytes"?Au:Tu}),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)}},Au=r=>{var t;return(t=r?.length)!==null&&t!==void 0?t:0},Tu=r=>{var t;return(t=r?.byteLength)!==null&&t!==void 0?t:0};function Do(r,t){let e=new er,n=null,i=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield e.close()})},start(a){return y(this,void 0,void 0,function*(){yield o(a,n||(n=yield s()))})},pull(a){return y(this,void 0,void 0,function*(){n?yield o(a,n):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:i};function s(){return y(this,void 0,void 0,function*(){return yield(yield bt.from(e)).open(t)})}function o(a,c){return y(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 Oo(r,t){let e=new this(r),n=new re(e),i=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return y(this,void 0,void 0,function*(){yield s(o)})},start(o){return y(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(o){return y(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield n.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}function ji(r){let t=bt.from(r);return ae(t)?t.then(e=>ji(e)):t.isAsync()?t.readAll().then(e=>new J(e)):new J(t.readAll())}function Fo(r,t="stream"){return(t==="stream"?wr:_r).writeAll(r).toUint8Array(!0)}var cp=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},oa),Ma),xa),aa),ea),Ia),ia),{compareSchemas:an,compareFields:nu,compareTypes:go});Bt.toDOMStream=Bu;rt.throughDOM=Du;bt.throughDOM=Do;Lr.throughDOM=Do;ir.throughDOM=Do;ln.throughDOM=Oo;_r.throughDOM=Oo;wr.throughDOM=Oo;var Mo=class extends Er{arrowSchema;constructor(t,e){super(t,e),this.arrowSchema=null}getBatch(){let t=super.getBatch();if(t){this.arrowSchema=this.arrowSchema||lp(t.schema);let e=up(this.arrowSchema,t.data),n=new Y(this.arrowSchema,w({type:new V(this.arrowSchema.fields),children:e.map(({data:i})=>i[0])}));return{shape:"arrow-table",batchType:"data",data:new J([n]),length:t.length}}return null}};function lp(r){let t=[];for(let e in r){let n=r[e];if(n.type===Float32Array){let i=new Map,s=new D(n.name,new Xt,n.nullable,i);t.push(s)}}if(t.length===0)throw new Error("No arrow convertible fields");return new E(t)}function up(r,t){let e=[];for(let n of r.fields){let i=t[n.name];if(i instanceof Float32Array){let s=Or(i);e.push(s)}}if(r.fields.length!==e.length)throw new Error("Some columns not arrow convertible");return e}function Ou(r){switch(r.constructor){case Int8Array:return new ye;case Uint8Array:return new we;case Int16Array:return new ge;case Uint16Array:return new _e;case Int32Array:return new pt;case Uint32Array:return new ve;case Float32Array:return new Xt;case Float64Array:return new Qt;default:throw new Error("array type not supported")}}var fn;(function(r){r[r.FLOAT=0]="FLOAT",r[r.DATE=1]="DATE"})(fn||(fn={}));function Lo(r){let t=r.data,e={};for(let n of t.schema.fields){let s=t.getChild(n.name)?.toArray();e[n.name]=s}return{shape:"columnar-table",schema:r.schema,data:e}}function Gn(r){return{fields:r.fields.map(t=>hn(t)),metadata:No(r.metadata)}}function Fu(r){return new E(r.fields.map(t=>dn(t)),Uo(r.metadata))}function No(r){return Object.fromEntries(r)}function Uo(r){return r?new Map(Object.entries(r)):new Map}function hn(r){return{name:r.name,type:Ja(r.type),nullable:r.nullable,metadata:No(r.metadata)}}function dn(r){return new D(r.name,Xa(r.type),r.nullable,Uo(r.metadata))}function Ja(r){switch(r.constructor){case ut:return"null";case ue:return"binary";case kt:return"bool";case it:let t=r;return`${t.isSigned?"u":""}int${t.bitWidth}`;case ye:return"int8";case ge:return"int16";case pt:return"int32";case be:return"int64";case we:return"uint8";case _e:return"uint16";case ve:return"uint32";case Ze:return"uint64";case At:switch(r.precision){case j.HALF:return"float16";case j.SINGLE:return"float32";case j.DOUBLE:return"float64";default:return"float16"}case Br:return"float16";case Xt:return"float32";case Qt:return"float64";case Pt:return"utf8";case fe:let n=r;return{type:"decimal",bitWidth:n.bitWidth,precision:n.precision,scale:n.scale};case qt:return r.unit===et.DAY?"date-day":"date-millisecond";case Pr:return"date-day";case cr:return"date-millisecond";case xt:switch(r.unit){case p.SECOND:return"time-second";case p.MILLISECOND:return"time-millisecond";case p.MICROSECOND:return"time-microsecond";case p.NANOSECOND:return"time-nanosecond";default:return"time-second"}case Vr:return"time-millisecond";case kr:return"time-second";case jr:return"time-microsecond";case zr:return"time-nanosecond";case Nt:switch(r.unit){case p.SECOND:return"timestamp-second";case p.MILLISECOND:return"timestamp-millisecond";case p.MICROSECOND:return"timestamp-microsecond";case p.NANOSECOND:return"timestamp-nanosecond";default:return"timestamp-second"}case Wr:return"timestamp-second";case Gr:return"timestamp-millisecond";case $r:return"timestamp-microsecond";case Hr:return"timestamp-nanosecond";case te:switch(r.unit){case nt.DAY_TIME:return"interval-daytime";case nt.YEAR_MONTH:return"interval-yearmonth";default:return"interval-daytime"}case Yr:return"interval-daytime";case Kr:return"interval-yearmonth";case jt:let c=r;return{type:"map",keysSorted:c.keysSorted,children:c.children.map(b=>hn(b))};case Tt:let u=r.valueField;return{type:"list",children:[hn(u)]};case Vt:let h=r;return{type:"fixed-size-list",listSize:h.listSize,children:[hn(h.children[0])]};case V:return{type:"struct",children:r.children.map(b=>hn(b))};default:throw new Error(`arrow type not supported: ${r.constructor.name}`)}}function Xa(r){if(typeof r=="object")switch(r.type){case"decimal":return new fe(r.precision,r.scale,r.bitWidth);case"map":let t=r.children.map(i=>dn(i));return new jt(t,r.keysSorted);case"list":let e=dn(r.children[0]);return new Tt(e);case"fixed-size-list":let n=dn(r.children[0]);return new Vt(r.listSize,n);case"struct":return t=r.children.map(i=>dn(i)),new V(t);default:throw new Error("array type not supported")}switch(r){case"null":return new ut;case"binary":return new ue;case"bool":return new kt;case"int8":return new ye;case"int16":return new ge;case"int32":return new pt;case"int64":return new be;case"uint8":return new we;case"uint16":return new _e;case"uint32":return new ve;case"uint64":return new Ze;case"float16":return new Br;case"float32":return new Xt;case"float64":return new Qt;case"utf8":return new Pt;case"date-day":return new Pr;case"date-millisecond":return new cr;case"time-second":return new kr;case"time-millisecond":return new Vr;case"time-microsecond":return new jr;case"time-nanosecond":return new zr;case"timestamp-second":return new Wr;case"timestamp-millisecond":return new Gr;case"timestamp-microsecond":return new $r;case"timestamp-nanosecond":return new Hr;case"interval-daytime":return new Yr;case"interval-yearmonth":return new Kr;default:throw new Error("array type not supported")}}function zi(r,t){let e=ji([new Uint8Array(r)]),n={shape:"arrow-table",schema:Gn(e.schema),data:e},i=t?.shape||"arrow-table";switch(i){case"arrow-table":return n;case"columnar-table":return Lo(n);case"object-row-table":let s=Lo(n);return cs(s,"object-row-table");case"array-row-table":return s=Lo(n),cs(s,"array-row-table");default:throw new Error(i)}}function Eo(r,t){async function*e(){let n=bt.readAll(r);for await(let i of n){for await(let s of i)t?.arrow?.batchDebounceMs!==void 0&&t?.arrow?.batchDebounceMs>0&&await new Promise(a=>setTimeout(a,t.arrow?.batchDebounceMs||0)),yield{shape:"arrow-table",batchType:"data",data:new J([s]),length:s.data.length};break}}return e()}var fp="4.3.0-alpha.5",Wi={dataType:null,batchType:null,name:"Apache Arrow",id:"arrow",module:"arrow",version:fp,category:"table",extensions:["arrow","feather"],mimeTypes:["application/vnd.apache.arrow.file","application/vnd.apache.arrow.stream","application/octet-stream"],binary:!0,tests:["ARROW"],options:{arrow:{shape:"columnar-table"}}},Mu={...Wi,parse:async(r,t)=>zi(r,t?.arrow),parseSync:(r,t)=>zi(r,t?.arrow),parseInBatches:Eo};function Qa(r){let t={};for(let i of r){let s=hp(i.array,i.type);t[i.name]=s}let e=new J(t);return Fo(e)}function hp(r,t){switch(t){case fn.DATE:return Ci(r);case fn.FLOAT:default:return Ci(r)}}var dp="4.3.0-alpha.5",Lu={name:"Apache Arrow",id:"arrow",module:"arrow",version:dp,extensions:["arrow","feather"],mimeTypes:["application/vnd.apache.arrow.file","application/vnd.apache.arrow.stream","application/octet-stream"],binary:!0,options:{},encode:async function(t,e){return Qa(t)},encodeSync(r,t){return Qa(r)}};var pp=["geoarrow.multipolygon","geoarrow.polygon","geoarrow.multilinestring","geoarrow.linestring","geoarrow.multipoint","geoarrow.point","geoarrow.wkb","geoarrow.wkt"],mp="ARROW:extension:name",yp="ARROW:extension:metadata";function qa(r){let t={};for(let e of r.fields){let n=gp(e);n&&(t[e.name]=n)}return t}function gp(r){let t=null,e=r.metadata?.[mp];e&&(e=e.toLowerCase(),e==="wkb"&&(e="geoarrow.wkb"),e==="wkt"&&(e="geoarrow.wkt"),pp.includes(e)?(t=t||{},t.encoding=e):console.warn(`Invalid GeoArrow encoding: ${e}`));let n=r.metadata?.[yp];if(n)try{t=JSON.parse(n)}catch(i){console.warn("Failed to parse GeoArrow metadata",i)}return t||null}function Nr(r){return Nr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nr(r)}function tc(r,t){if(Nr(r)!=="object"||r===null)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t||"default");if(Nr(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function ec(r){var t=tc(r,"string");return Nr(t)==="symbol"?t:String(t)}function Ae(r,t,e){return t=ec(t),t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}var Gi={x:0,y:1,z:2};function Ro(r,t={}){let{start:e=0,end:n=r.length,plane:i="xy"}=t,s=t.size||2,o=0,a=Gi[i[0]],c=Gi[i[1]];for(let l=e,u=n-s;l<n;l+=s)o+=(r[l+a]-r[u+a])*(r[l+c]+r[u+c]),u=l;return o/2}function nc(r,t,e=2,n,i="xy"){let s=t&&t.length,o=s?t[0]*e:r.length,a=Uu(r,0,o,e,!0,n&&n[0],i),c=[];if(!a||a.next===a.prev)return c;let l,u,h,d,b,M,z;if(s&&(a=Sp(r,t,a,e,n,i)),r.length>80*e){d=u=r[0],b=h=r[1];for(let X=e;X<o;X+=e)M=r[X],z=r[X+1],M<d&&(d=M),z<b&&(b=z),M>u&&(u=M),z>h&&(h=z);l=Math.max(u-d,h-b),l=l!==0?32767/l:0}return $i(a,c,e,d,b,l,0),c}function Uu(r,t,e,n,i,s,o){let a,c;s===void 0&&(s=Ro(r,{start:t,end:e,size:n,plane:o}));let l=Gi[o[0]],u=Gi[o[1]];if(i===s<0)for(a=t;a<e;a+=n)c=Nu(a,r[a+l],r[a+u],c);else for(a=e-n;a>=t;a-=n)c=Nu(a,r[a+l],r[a+u],c);return c&&ko(c,c.next)&&(Yi(c),c=c.next),c}function pn(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(ko(e,e.next)||ct(e.prev,e,e.next)===0)){if(Yi(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function $i(r,t,e,n,i,s,o){if(!r)return;!o&&s&&Op(r,n,i,s);let a=r,c,l;for(;r.prev!==r.next;){if(c=r.prev,l=r.next,s?vp(r,n,i,s):_p(r)){t.push(c.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),Yi(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=Ip(pn(r),t,e),$i(r,t,e,n,i,s,2)):o===2&&xp(r,t,e,n,i,s):$i(pn(r),t,e,n,i,s,1);break}}}function _p(r){let t=r.prev,e=r,n=r.next;if(ct(t,e,n)>=0)return!1;let i=t.x,s=e.x,o=n.x,a=t.y,c=e.y,l=n.y,u=i<s?i<o?i:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,d=i>s?i>o?i:o:s>o?s:o,b=a>c?a>l?a:l:c>l?c:l,M=n.next;for(;M!==t;){if(M.x>=u&&M.x<=d&&M.y>=h&&M.y<=b&&$n(i,a,s,c,o,l,M.x,M.y)&&ct(M.prev,M,M.next)>=0)return!1;M=M.next}return!0}function vp(r,t,e,n){let i=r.prev,s=r,o=r.next;if(ct(i,s,o)>=0)return!1;let a=i.x,c=s.x,l=o.x,u=i.y,h=s.y,d=o.y,b=a<c?a<l?a:l:c<l?c:l,M=u<h?u<d?u:d:h<d?h:d,z=a>c?a>l?a:l:c>l?c:l,X=u>h?u>d?u:d:h>d?h:d,st=rc(b,M,t,e,n),yn=rc(z,X,t,e,n),W=r.prevZ,k=r.nextZ;for(;W&&W.z>=st&&k&&k.z<=yn;){if(W.x>=b&&W.x<=z&&W.y>=M&&W.y<=X&&W!==i&&W!==o&&$n(a,u,c,h,l,d,W.x,W.y)&&ct(W.prev,W,W.next)>=0||(W=W.prevZ,k.x>=b&&k.x<=z&&k.y>=M&&k.y<=X&&k!==i&&k!==o&&$n(a,u,c,h,l,d,k.x,k.y)&&ct(k.prev,k,k.next)>=0))return!1;k=k.nextZ}for(;W&&W.z>=st;){if(W.x>=b&&W.x<=z&&W.y>=M&&W.y<=X&&W!==i&&W!==o&&$n(a,u,c,h,l,d,W.x,W.y)&&ct(W.prev,W,W.next)>=0)return!1;W=W.prevZ}for(;k&&k.z<=yn;){if(k.x>=b&&k.x<=z&&k.y>=M&&k.y<=X&&k!==i&&k!==o&&$n(a,u,c,h,l,d,k.x,k.y)&&ct(k.prev,k,k.next)>=0)return!1;k=k.nextZ}return!0}function Ip(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!ko(i,s)&&Eu(i,n,n.next,s)&&Hi(i,s)&&Hi(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Yi(n),Yi(n.next),n=r=s),n=n.next}while(n!==r);return pn(n)}function xp(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Lp(o,a)){let c=Ru(o,a);o=pn(o,o.next),c=pn(c,c.next),$i(o,t,e,n,i,s,0),$i(c,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function Sp(r,t,e,n,i,s){let o=[],a,c,l,u,h;for(a=0,c=t.length;a<c;a++)l=t[a]*n,u=a<c-1?t[a+1]*n:r.length,h=Uu(r,l,u,n,!1,i&&i[a+1],s),h===h.next&&(h.steiner=!0),o.push(Mp(h));for(o.sort(Bp),a=0;a<o.length;a++)e=Ap(o[a],e);return e}function Bp(r,t){return r.x-t.x}function Ap(r,t){let e=Tp(r,t);if(!e)return t;let n=Ru(e,r);return pn(n,n.next),pn(e,e.next)}function Tp(r,t){let e=t,n=r.x,i=r.y,s=-1/0,o;do{if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){let d=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=n&&d>s&&(s=d,o=e.x<e.next.x?e:e.next,d===n))return o}e=e.next}while(e!==t);if(!o)return null;let a=o,c=o.x,l=o.y,u=1/0,h;e=o;do n>=e.x&&e.x>=c&&n!==e.x&&$n(i<l?n:s,i,c,l,i<l?s:n,i,e.x,e.y)&&(h=Math.abs(i-e.y)/(n-e.x),Hi(e,r)&&(h<u||h===u&&(e.x>o.x||e.x===o.x&&Dp(o,e)))&&(o=e,u=h)),e=e.next;while(e!==a);return o}function Dp(r,t){return ct(r.prev,r,t.prev)<0&&ct(t.next,r,r.next)<0}function Op(r,t,e,n){let i=r;do i.z===0&&(i.z=rc(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,Fp(i)}function Fp(r){let t,e,n=1,i,s,o,a,c,l;do{for(s=r,r=null,l=null,i=0;s;){for(i++,a=s,o=0,e=0;e<n&&(o++,a=a.nextZ,!!a);e++);for(c=n;o>0||c>0&&a;)o!==0&&(c===0||!a||s.z<=a.z)?(t=s,s=s.nextZ,o--):(t=a,a=a.nextZ,c--),l?l.nextZ=t:r=t,t.prevZ=l,l=t;s=a}l.nextZ=null,n*=2}while(i>1);return r}function rc(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function Mp(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function $n(r,t,e,n,i,s,o,a){return(i-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(n-a)}function Lp(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Np(r,t)&&(Hi(r,t)&&Hi(t,r)&&Up(r,t)&&(ct(r.prev,r,t.prev)||ct(r,t.prev,t))||ko(r,t)&&ct(r.prev,r,r.next)>0&&ct(t.prev,t,t.next)>0)}function ct(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function ko(r,t){return r.x===t.x&&r.y===t.y}function Eu(r,t,e,n){let i=Po(ct(r,t,e)),s=Po(ct(r,t,n)),o=Po(ct(e,n,r)),a=Po(ct(e,n,t));return!!(i!==s&&o!==a||i===0&&Co(r,e,t)||s===0&&Co(r,n,t)||o===0&&Co(e,r,n)||a===0&&Co(e,t,n))}function Co(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Po(r){return r>0?1:r<0?-1:0}function Np(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&Eu(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Hi(r,t){return ct(r.prev,r,r.next)<0?ct(r,t,r.next)>=0&&ct(r,r.prev,t)>=0:ct(r,t,r.prev)<0||ct(r,r.next,t)<0}function Up(r,t){let e=r,n=!1,i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function Ru(r,t){let e=new Ki(r.i,r.x,r.y),n=new Ki(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function Nu(r,t,e,n){let i=new Ki(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Yi(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}var Ki=class{constructor(t,e,n){Ae(this,"i",void 0),Ae(this,"x",void 0),Ae(this,"y",void 0),Ae(this,"prev",null),Ae(this,"next",null),Ae(this,"z",0),Ae(this,"prevZ",null),Ae(this,"nextZ",null),Ae(this,"steiner",!1),this.i=t,this.x=e,this.y=n}};function Hn(r,t,e){switch(r.type){case"Point":return Vp(r,t,e);case"LineString":return kp(r,t,e);case"Polygon":return ku(r,t,e);default:let n=r;throw new Error(`Unsupported geometry type: ${n?.type}`)}}function ku(r,t=-1/0,e=1/0){let{positions:n}=r,i=r.polygonIndices.value.filter(c=>c>=t&&c<=e),s=r.primitivePolygonIndices.value.filter(c=>c>=t&&c<=e);if(!(i.length>2)){let c=[];for(let l=0;l<s.length-1;l++){let u=s[l],h=s[l+1],d=Vo(n,u,h);c.push(d)}return{type:"Polygon",coordinates:c}}let a=[];for(let c=0;c<i.length-1;c++){let l=i[c],u=i[c+1],h=ku(r,l,u).coordinates;a.push(h)}return{type:"MultiPolygon",coordinates:a}}function kp(r,t=-1/0,e=1/0){let{positions:n}=r,i=r.pathIndices.value.filter(a=>a>=t&&a<=e);if(!(i.length>2))return{type:"LineString",coordinates:Vo(n,i[0],i[1])};let o=[];for(let a=0;a<i.length-1;a++){let c=Vo(n,i[a],i[a+1]);o.push(c)}return{type:"MultiLineString",coordinates:o}}function Vp(r,t,e){let{positions:n}=r,i=Vo(n,t,e);return i.length>1?{type:"MultiPoint",coordinates:i}:{type:"Point",coordinates:i[0]}}function Vo(r,t,e){t=t||0,e=e||r.value.length/r.size;let n=[];for(let i=t;i<e;i++){let s=Array();for(let o=i*r.size;o<(i+1)*r.size;o++)s.push(Number(r.value[o]));n.push(s)}return n}function jo(r){let t=r.data,e=Gn(t.schema),n=qa(e),i=n.geometry.encoding,s=[],o=t.schema.fields.map(l=>l.name).filter(l=>!(l in n)),a=t.select(o),c=t.getChild("geometry");for(let l=0;l<t.numRows;l++){let u=c?.get(l),h=zo(u,i);if(h){let d=a.get(l)?.toJSON()||{};s.push({type:"Feature",geometry:h,properties:d})}}return{shape:"geojson-table",type:"FeatureCollection",schema:r.schema,features:s}}function ic(r,t){let e=zi(r,{shape:"arrow-table"});switch(t?.shape){case"geojson-table":return jo(e);default:return e}}function Vu(r){return Eo(r)}var sc={...Wi,options:{arrow:{shape:"arrow-table"}}},ju={...sc,parse:async(r,t)=>ic(r,t?.arrow),parseSync:(r,t)=>ic(r,t?.arrow),parseInBatches:Vu};function Wo(r,t,e,n=100){let i=r.length/t,s=Math.max(Math.floor(i/n),1),o=[...e];for(let a=0;a<i;a+=s){let c=r[a*t],l=r[a*t+1];c<o[0]&&(o[0]=c),l<o[1]&&(o[1]=l),c>o[2]&&(o[2]=c),l>o[3]&&(o[3]=l)}return o}var Yn;(function(r){r.points="points",r.lines="lines",r.polygons="polygons"})(Yn||(Yn={}));function Zi(){return{globalFeatureIds:{value:new Uint32Array(0),size:1},positions:{value:new Float32Array(0),size:2},properties:[],numericProps:{},featureIds:{value:new Uint32Array(0),size:1}}}function zu(r,t,e){let n={polygon:t==="geoarrow.multipolygon"||t==="geoarrow.polygon",point:t==="geoarrow.multipoint"||t==="geoarrow.point",line:t==="geoarrow.multilinestring"||t==="geoarrow.linestring"},i=e?.chunkIndex!==void 0&&e?.chunkIndex>=0?[r.data[e?.chunkIndex]]:r.data,s=[1/0,1/0,-1/0,-1/0],o=e?.chunkOffset||0,a=[];return i.forEach(c=>{let{featureIds:l,flatCoordinateArray:u,nDim:h,geomOffset:d,triangles:b}=zp(c,t,e),M=new Uint32Array(l.length);for(let X=0;X<l.length;X++)M[X]=l[X]+o;let z={globalFeatureIds:{value:M,size:1},positions:{value:u,size:h},featureIds:{value:l,size:1},properties:[...Array(c.length).keys()].map(X=>({index:X+o}))};o+=c.length,a.push({shape:"binary-feature-collection",points:{type:"Point",...Zi(),...n.point?z:{}},lines:{type:"LineString",...Zi(),...n.line?z:{},pathIndices:{value:n.line?d:new Uint16Array(0),size:1}},polygons:{type:"Polygon",...Zi(),...n.polygon?z:{},polygonIndices:{value:n.polygon?d:new Uint16Array(0),size:1},primitivePolygonIndices:{value:n.polygon?d:new Uint16Array(0),size:1},...b?{triangles:{value:b,size:1}}:{}}}),s=Wo(u,h,s)}),{binaryGeometries:a,bounds:s,featureTypes:n,...e?.calculateMeanCenters?{meanCenters:oc(a)}:{}}}function oc(r){let t=[];return r.forEach(e=>{let n=null;e.points&&e.points.positions.value.length>0?n=Yn.points:e.lines&&e.lines.positions.value.length>0?n=Yn.lines:e.polygons&&e.polygons.positions.value.length>0&&(n=Yn.polygons);let i=n?e[n]:null;if(i&&n!==null){let s=i.featureIds.value,o=i.positions.value,a=i.positions.size,c=i.type==="Polygon"?i.primitivePolygonIndices?.value:void 0;jp(s,o,a,n,c).forEach(u=>{t.push(u)})}}),t}function jp(r,t,e,n,i){let s=[],o=t.length,a=0,c=0,l=0;for(;a<o;){let u=r[a/e],h=[0,0],d=0;for(;a<o&&r[c]===u;)n===Yn.polygons&&i?.[l]===c?(a+=e,l++):(h[0]+=t[a],h[1]+=t[a+1],a+=e,d++),c+=1;h[0]/=d,h[1]/=d,s.push(h)}return s}function zp(r,t,e){switch(t){case"geoarrow.point":case"geoarrow.multipoint":return $p(r,t);case"geoarrow.linestring":case"geoarrow.multilinestring":return Gp(r,t);case"geoarrow.polygon":case"geoarrow.multipolygon":return Wp(r,t,e);default:throw Error("invalid geoarrow encoding")}}function ac(r,t,e,n){try{let i=0,s=[];for(let a=0;a<r.length-1;a++){let c=r[a],l=r[a+1],u=e.subarray(c*n,l*n),h=[];for(;t[i]<l;)t[i]>c&&h.push(t[i]-c),i++;let d=nc(u,h.length>0?h:void 0,n);if(d.length===0)throw Error("earcut failed e.g. invalid polygon");for(let b=0;b<d.length;b++)s.push(d[b]+c)}let o=new Uint32Array(s.length);for(let a=0;a<s.length;a++)o[a]=s[a];return o}catch{return null}}function Wp(r,t,e){let n=t==="geoarrow.multipolygon",i=n?r.children[0]:r,s=i.valueOffsets,o=n?r.valueOffsets.map(st=>s.at(st)||st):r.valueOffsets,a=i.children[0],c=a.children[0],l=c.children[0],u=c.stride,h=a.valueOffsets,d=l.values,b=new Uint16Array(s.length);for(let st=0;st<s.length;st++)b[st]=h[s[st]];let M=d.length/u,z=new Uint32Array(M);for(let st=0;st<o.length-1;st++){let yn=h[o[st]],W=h[o[st+1]];for(let k=yn;k<W;k++)z[k]=st}let X=e?.triangulate?ac(b,h,d,u):null;return{featureIds:z,nDim:u,flatCoordinateArray:d,geomOffset:h,geometryIndicies:b,...e?.triangulate&&X?{triangles:X}:{}}}function Gp(r,t){let e=t==="geoarrow.multilinestring",n=e?r.children[0]:r,i=n.children[0],s=i.children[0],o=i.stride,a=n.valueOffsets,c=s.values,l=new Uint16Array(0),u=c.length/o,h=new Uint32Array(u);if(e){let d=r.valueOffsets;for(let b=0;b<d.length-1;b++){let M=a[d[b]],z=a[d[b+1]];for(let X=M;X<z;X++)h[X]=b}}else for(let d=0;d<r.length;d++){let b=a[d],M=a[d+1];for(let z=b;z<M;z++)h[z]=d}return{featureIds:h,flatCoordinateArray:c,nDim:o,geomOffset:a,geometryIndicies:l}}function $p(r,t){let e=t==="geoarrow.multipoint",n=e?r.children[0]:r,i=n.children[0],s=n.stride,o=i.values,a=new Uint16Array(0),c=new Int32Array(0),l=o.length/s,u=new Uint32Array(l);if(e){let h=r.valueOffsets;for(let d=0;d<h.length-1;d++){let b=h[d],M=h[d+1];for(let z=b;z<M;z++)u[z]=d}}else for(let h=0;h<r.length;h++)u[h]=h;return{featureIds:u,flatCoordinateArray:o,nDim:s,geomOffset:c,geometryIndicies:a}}var Go="4.3.0-alpha.5";var Wu=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,Gu=new RegExp("^"+Wu.source+"(\\s"+Wu.source+"){1,}"),cc=["POINT(","LINESTRING(","POLYGON(","MULTIPOINT(","MULTILINESTRING(","MULTIPOLYGON(","GEOMETRYCOLLECTION("];function $u(r){return cc.some(t=>r.startsWith(t))}function lc(r,t){return Hp(r,t)}function Hp(r,t){let e=r.split(";"),n=e.pop(),i=(e.shift()||"").split("=").pop(),o=Hu({parts:e,_:n,i:0});return t?.wkt?.crs?Yp(o,i):o}function Hu(r){return Kp(r)||Jp(r)||Qp(r)||Zp(r)||Xp(r)||qp(r)||tm(r)}function Yp(r,t){if(r&&t?.match(/\d+/)){let e={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+t}};r.crs=e}return r}function Kp(r){if(!ht(/^(POINT(\sz)?)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;let t=Yu(r);return!t||(Wt(r),!ht(/^(\))/,r))?null:{type:"Point",coordinates:t[0]}}function Zp(r){if(!ht(/^(MULTIPOINT)/i,r))return null;Wt(r);let t=r._?.substring(r._?.indexOf("(")+1,r._.length-1).replace(/\(/g,"").replace(/\)/g,"");r._="MULTIPOINT ("+t+")";let e=$o(r);return e?(Wt(r),{type:"MultiPoint",coordinates:e}):null}function Jp(r){if(!ht(/^(LINESTRING(\sz)?)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;let t=Yu(r);return!t||!ht(/^(\))/,r)?null:{type:"LineString",coordinates:t}}function Xp(r){if(!ht(/^(MULTILINESTRING)/i,r))return null;Wt(r);let t=$o(r);return t?(Wt(r),{type:"MultiLineString",coordinates:t}):null}function Qp(r){if(!ht(/^(POLYGON(\sz)?)/i,r))return null;Wt(r);let t=$o(r);return t?{type:"Polygon",coordinates:t}:null}function qp(r){if(!ht(/^(MULTIPOLYGON)/i,r))return null;Wt(r);let t=$o(r);return t?{type:"MultiPolygon",coordinates:t}:null}function tm(r){let t=[],e;if(!ht(/^(GEOMETRYCOLLECTION)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;for(;e=Hu(r);)t.push(e),Wt(r),ht(/^(,)/,r),Wt(r);return ht(/^(\))/,r)?{type:"GeometryCollection",geometries:t}:null}function $o(r){Wt(r);let t=0,e=[],n=[e],i=e,s;for(;s=ht(/^(\()/,r)||ht(/^(\))/,r)||ht(/^(,)/,r)||ht(Gu,r);){if(s==="(")n.push(i),i=[],n[n.length-1].push(i),t++;else if(s===")"){if(i.length===0||(i=n.pop(),!i))return null;if(t--,t===0)break}else if(s===",")i=[],n[n.length-1].push(i);else if(!s.split(/\s/g).some(isNaN))Array.prototype.push.apply(i,s.split(/\s/g).map(parseFloat));else return null;Wt(r)}return t!==0?null:e}function Yu(r){let t=[],e,n;for(;n=ht(Gu,r)||ht(/^(,)/,r);)n===","?(t.push(e),e=[]):n.split(/\s/g).some(isNaN)||(e||(e=[]),Array.prototype.push.apply(e,n.split(/\s/g).map(parseFloat))),Wt(r);if(e)t.push(e);else return null;return t.length?t:null}function ht(r,t){let e=t._?.substring(t.i).match(r);return e?(t.i+=e[0].length,e[0]):null}function Wt(r){ht(/^\s*/,r)}var Ku={dataType:null,batchType:null,name:"WKT (Well-Known Text)",id:"wkt",module:"wkt",version:Go,worker:!0,extensions:["wkt"],mimeTypes:["text/plain"],category:"geometry",text:!0,tests:cc,testText:$u,options:{wkt:{shape:"geojson-geometry",crs:!0}}},uc={...Ku,parse:async(r,t)=>lc(new TextDecoder().decode(r),t),parseTextSync:(r,t)=>lc(r,t)};var vr;(function(r){r[r.Point=1]="Point",r[r.LineString=2]="LineString",r[r.Polygon=3]="Polygon",r[r.MultiPoint=4]="MultiPoint",r[r.MultiLineString=5]="MultiLineString",r[r.MultiPolygon=6]="MultiPolygon",r[r.GeometryCollection=7]="GeometryCollection"})(vr||(vr={}));function Zu(r){let t=new DataView(r),e=0,n=t.getUint8(e);if(e+=1,n>1)return!1;let i=n===1,s=t.getUint32(e,i);e+=4;let o=s&7;if(o===0||o>7)return!1;let a=s-o;if(a===0||a===1e3||a===2e3||a===3e3)return!0;if(a&536870911)return!1;if(a&536870912){let c=t.getUint32(e,i);if(e+=4,c>1e4)return!1}return!0}function Ju(r,t){let e=Object.assign(t||{},{type:"wkb",geometryType:1,dimensions:2,coordinates:"xy",littleEndian:!0,byteOffset:0});e.littleEndian=r.getUint8(e.byteOffset)===1,e.byteOffset++;let n=r.getUint32(e.byteOffset,e.littleEndian);e.byteOffset+=4,e.geometryType=n&7;let i=(n-e.geometryType)/1e3;switch(i){case 0:break;case 1:e.type="iso-wkb",e.dimensions=3,e.coordinates="xyz";break;case 2:e.type="iso-wkb",e.dimensions=3,e.coordinates="xym";break;case 3:e.type="iso-wkb",e.dimensions=4,e.coordinates="xyzm";break;default:throw new Error(`WKB: Unsupported iso-wkb type: ${i}`)}let s=n&2147483648,o=n&1073741824,a=n&536870912;return s&&o?(e.type="ewkb",e.dimensions=4,e.coordinates="xyzm"):s?(e.type="ewkb",e.dimensions=3,e.coordinates="xyz"):o&&(e.type="ewkb",e.dimensions=3,e.coordinates="xym"),a&&(e.type="ewkb",e.srid=r.getUint32(e.byteOffset,e.littleEndian),e.byteOffset+=4),e}function fc(r,t){let e=em(r,t),n=t?.wkb?.shape||"binary-geometry";switch(n){case"binary-geometry":return e;case"geojson-geometry":return Hn(e);case"geometry":return console.error('WKBLoader: "geometry" shape is deprecated, use "binary-geometry" instead'),Hn(e);default:throw new Error(n)}}function em(r,t){let e=new DataView(r),n=Ju(e),{geometryType:i,dimensions:s,littleEndian:o}=n,a=n.byteOffset;switch(i){case vr.Point:return Xu(e,a,s,o).geometry;case vr.LineString:return hc(e,a,s,o).geometry;case vr.Polygon:return Qu(e,a,s,o).geometry;case vr.MultiPoint:let h=rm(e,a,s,o);return h.type="Point",h;case vr.MultiLineString:let d=nm(e,a,s,o);return d.type="LineString",d;case vr.MultiPolygon:let b=im(e,a,s,o);return b.type="Polygon",b;default:throw new Error(`WKB: Unsupported geometry type: ${i}`)}}function Xu(r,t,e,n){let i=new Float64Array(e);for(let s=0;s<e;s++)i[s]=r.getFloat64(t,n),t+=8;return{geometry:{type:"Point",positions:{value:i,size:e}},offset:t}}function hc(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=new Float64Array(i*e);for(let a=0;a<i*e;a++)s[a]=r.getFloat64(t,n),t+=8;let o=[0];return i>0&&o.push(i),{geometry:{type:"LineString",positions:{value:s,size:e},pathIndices:{value:new Uint32Array(o),size:1}},offset:t}}var dc=r=>t=>r+=t;function Qu(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let l=0;l<i;l++){let u=hc(r,t,e,n),{positions:h}=u.geometry;t=u.offset,s.push(h.value)}let o=new Float64Array(Ho(s).buffer),a=[0];o.length>0&&a.push(o.length/e);let c=s.map(l=>l.length/e).map(dc(0));return c.unshift(0),{geometry:{type:"Polygon",positions:{value:o,size:e},polygonIndices:{value:new Uint32Array(a),size:1},primitivePolygonIndices:{value:new Uint32Array(c),size:1}},offset:t}}function rm(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let o=0;o<i;o++){let a=r.getUint8(t)===1;if(t++,r.getUint32(t,a)%1e3!==1)throw new Error("WKB: Inner geometries of MultiPoint not of type Point");t+=4;let c=Xu(r,t,e,a);t=c.offset,s.push(c.geometry)}return sm(s,e)}function nm(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let o=0;o<i;o++){let a=r.getUint8(t)===1;if(t++,r.getUint32(t,a)%1e3!==2)throw new Error("WKB: Inner geometries of MultiLineString not of type LineString");t+=4;let c=hc(r,t,e,a);t=c.offset,s.push(c.geometry)}return om(s,e)}function im(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let o=0;o<i;o++){let a=r.getUint8(t)===1;if(t++,r.getUint32(t,a)%1e3!==3)throw new Error("WKB: Inner geometries of MultiPolygon not of type Polygon");t+=4;let c=Qu(r,t,e,a);t=c.offset,s.push(c.geometry)}return am(s,e)}function sm(r,t){let e=r.map(i=>i.positions.value);return{type:"Point",positions:{value:new Float64Array(Ho(e).buffer),size:t}}}function om(r,t){let e=r.map(s=>s.positions.value),n=new Float64Array(Ho(e).buffer),i=e.map(s=>s.length/t).map(dc(0));return i.unshift(0),{type:"LineString",positions:{value:n,size:t},pathIndices:{value:new Uint32Array(i),size:1}}}function am(r,t){let e=[],n=[];for(let a of r){let{positions:c,primitivePolygonIndices:l}=a;e.push(c.value),n.push(l.value)}let i=new Float64Array(Ho(e).buffer),s=e.map(a=>a.length/t).map(dc(0));s.unshift(0);let o=[0];for(let a of n)o.push(...a.filter(c=>c>0).map(c=>c+o[o.length-1]));return{type:"Polygon",positions:{value:i,size:t},polygonIndices:{value:new Uint32Array(s),size:1},primitivePolygonIndices:{value:new Uint32Array(o),size:1}}}function Ho(r){let t=0;for(let i=0;i<r.length;++i)t+=r[i].byteLength;let e=new Uint8Array(t),n=0;for(let i=0;i<r.length;++i){let s=new Uint8Array(r[i].buffer);t=s.length;for(let o=0;o<t;++o)e[n++]=s[o]}return e}var qu={dataType:null,batchType:null,name:"WKB",id:"wkb",module:"wkt",version:Go,worker:!0,category:"geometry",extensions:["wkb"],mimeTypes:[],tests:[Zu],options:{wkb:{shape:"binary-geometry"}}},pc={...qu,parse:async r=>fc(r),parseSync:fc};function zo(r,t){if(t=t?.toLowerCase(),!t||!r)return null;let e;switch(t){case"geoarrow.multipolygon":e=um(r);break;case"geoarrow.polygon":e=fm(r);break;case"geoarrow.multipoint":e=hm(r);break;case"geoarrow.point":e=dm(r);break;case"geoarrow.multilinestring":e=pm(r);break;case"geoarrow.linestring":e=mm(r);break;case"geoarrow.wkb":e=cm(r);break;case"geoarrow.wkt":e=lm(r);break;default:throw Error(`GeoArrow encoding not supported ${t}`)}return e}function cm(r){let t=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),e=pc.parseSync?.(t);return Hn(e)}function lm(r){let t=r;return uc.parseTextSync?.(t)}function um(r){let t=[];for(let n=0;n<r.length;n++){let i=r.get(n),s=[];for(let o=0;i&&o<i?.length;o++){let a=i?.get(o),c=[];for(let l=0;a&&l<a.length;l++){let u=a.get(l),h=Array.from(u);c.push(h)}s.push(c)}t.push(s)}return{type:"MultiPolygon",coordinates:t}}function fm(r){let t=[];for(let n=0;r&&n<r.length;n++){let i=r.get(n),s=[];for(let o=0;i&&o<i.length;o++){let a=i.get(o),c=Array.from(a);s.push(c)}t.push(s)}return{type:"Polygon",coordinates:t}}function hm(r){let t=[];for(let e=0;r&&e<r.length;e++){let n=r.get(e);if(n){let i=Array.from(n);t.push(i)}}return{type:"MultiPoint",coordinates:t}}function dm(r){return{type:"Point",coordinates:Array.from(r)}}function pm(r){let t=[];for(let e=0;r&&e<r.length;e++){let n=r.get(e),i=[];for(let s=0;n&&s<n.length;s++){let o=n.get(s);if(o){let a=Array.from(o);i.push(a)}}t.push(i)}return{type:"MultiLineString",coordinates:t}}function mm(r){let t=[];for(let e=0;r&&e<r.length;e++){let n=r.get(e);if(n){let i=Array.from(n);t.push(i)}}return{type:"LineString",coordinates:t}}function Ji(r,t=!1){if("data"in r)return new g(r.data.map(s=>Ji(s,t)));let e=[];for(let s of r.children)e.push(Ji(s,t));let n;r.dictionary!==void 0&&(n=Ji(r.dictionary,t));let i={[lt.OFFSET]:Yo(r.buffers[lt.OFFSET],t),[lt.DATA]:Yo(r.buffers[lt.DATA],t),[lt.VALIDITY]:Yo(r.buffers[lt.VALIDITY],t),[lt.TYPE]:Yo(r.buffers[lt.TYPE],t)};return new R(r.type,r.offset,r.length,r._nullCount,i,e,n)}function ym(r){return!(r.byteOffset===0&&r.byteLength===r.buffer.byteLength)}function Yo(r,t){return r===void 0||!t&&!ym(r)?r:r.slice()}var tf="latest";function gm(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.0-alpha.5"),globalThis._loadersgl_.version}var mc=gm();function sr(r,t){if(!r)throw new Error(t||"loaders.gl assertion failed.")}var or={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},cA=or.self||or.window||or.global||{},lA=or.window||or.self||or.global||{},uA=or.global||or.self||or.window||{},fA=or.document||{};var Ir=typeof process!="object"||String(process)!=="[object process]"||process.browser;var rf=typeof window<"u"&&typeof window.orientation<"u",ef=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),hA=ef&&parseFloat(ef[1])||0;var Xi=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(t,e){this.name=t,this.workerThread=e,this.result=new Promise((n,i)=>{this._resolve=n,this._reject=i})}postMessage(t,e){this.workerThread.postMessage({source:"loaders.gl",type:t,payload:e})}done(t){sr(this.isRunning),this.isRunning=!1,this._resolve(t)}error(t){sr(this.isRunning),this.isRunning=!1,this._reject(t)}};var Kn=class{terminate(){}};var yc=new Map;function nf(r){sr(r.source&&!r.url||!r.source&&r.url);let t=yc.get(r.source||r.url);return t||(r.url&&(t=bm(r.url),yc.set(r.url,t)),r.source&&(t=sf(r.source),yc.set(r.source,t))),sr(t),t}function bm(r){if(!r.startsWith("http"))return r;let t=wm(r);return sf(t)}function sf(r){let t=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(t)}function wm(r){return`try {
16
+ ]`}concat(...t){let e=this.schema,n=this.data.concat(t.flatMap(({data:i})=>i));return new J(e,n.map(i=>new Y(e,i)))}slice(t,e){let n=this.schema;[t,e]=oi({length:this.numRows},t,e);let i=Ws(this.data,this._offsets,t,e);return new J(n,i.map(s=>new Y(n,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(n=>n.children[t]);if(e.length===0){let{type:n}=this.schema.fields[t],i=w({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new g(e)}return null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new g([w({type:new ut,length:this.numRows})]));let s=n.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],[n,i]=wo(n,a)}return new J(n,i)}select(t){let e=this.schema.fields.reduce((n,i,s)=>n.set(i.name,s),new Map);return this.selectAt(t.map(n=>e.get(n)).filter(n=>n>-1))}selectAt(t){let e=this.schema.selectAt(t),n=this.batches.map(i=>i.selectAt(t));return new J(e,n)}assign(t){let e=this.schema.fields,[n,i]=t.schema.fields.reduce((a,c,l)=>{let[u,h]=a,d=e.findIndex(b=>b.name===c.name);return~d?h[d]=l:u.push(l),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,i[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...n.map(a=>t.getChildAt(a))].filter(Boolean);return new J(...wo(s,o))}};iu=Symbol.toStringTag;J[iu]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=On(li),r.get=On(mt.getVisitFn(f.Struct)),r.set=Gs(Dt.getVisitFn(f.Struct)),r.indexOf=$s(qr.getVisitFn(f.Struct)),"Table"))(J.prototype);var ou,Y=class{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof E))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=w({nullCount:0,type:new V(this.schema.fields),children:this.schema.fields.map(e=>w({type:e.type,nullCount:0}))})]=t,!(this.data instanceof R))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=su(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:n,children:i,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]=D.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new E(n),a=w({type:new V(n),length:s,children:i,nullCount:0});[this.schema,this.data]=su(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=au(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)}set(t,e){return Dt.visit(this.data,t,e)}indexOf(t,e){return qr.visit(this.data,t,e)}[Symbol.iterator](){return Fn.visit(new g([this.data]))}toArray(){return[...this]}concat(...t){return new J(this.schema,[this,...t])}slice(t,e){let[n]=new g([this.data]).slice(t,e).data;return new Y(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new g([this.data.children[t]]):null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=this.data;if(t>-1&&t<this.numCols){e||(e=new g([w({type:new ut,length:this.numRows})]));let s=n.fields.slice(),o=i.children.slice(),a=s[t].clone({type:e.type});[s[t],o[t]]=[a,e.data[0]],n=new E(s,new Map(this.schema.metadata)),i=w({type:new V(s),children:o})}return new Y(n,i)}select(t){let e=this.schema.select(t),n=new V(e.fields),i=[];for(let s of t){let o=this.schema.fields.findIndex(a=>a.name===s);~o&&(i[o]=this.data.children[o])}return new Y(e,w({type:n,length:this.numRows,children:i}))}selectAt(t){let e=this.schema.selectAt(t),n=t.map(s=>this.data.children[s]).filter(Boolean),i=w({type:new V(e.fields),length:this.numRows,children:n});return new Y(e,i)}};ou=Symbol.toStringTag;Y[ou]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Y.prototype);function su(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;let i=[...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)&&(i[a]=c.clone({nullable:!0}),s[a]=(n=l?._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:w({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(i),w({type:new V(i),length:e,children:s})]}function au(r,t,e=new Map){var n,i;if(((n=r?.length)!==null&&n!==void 0?n:0)>0&&r?.length===t?.length)for(let s=-1,o=r.length;++s<o;){let{type:a}=r[s],c=t[s];for(let l of[c,...((i=c?.dictionary)===null||i===void 0?void 0:i.data)||[]])au(a.children,l?.children,e);if(m.isDictionary(a)){let{id:l}=a;if(!e.has(l))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 cn=class extends Y{constructor(t){let e=t.fields.map(i=>w({type:i.type})),n=w({type:new V(t.fields),nullCount:0,children:e});super(t,n)}};var ft=class{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 ft).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new ft).__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):$.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):P.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 n=this.bb.__offset(this.bb_pos,12);return n?(e||new Q).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+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,$.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,P.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 n=e.length-1;n>=0;n--)t.addOffset(e[n]);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,n,i,s,o){return ft.startMessage(t),ft.addVersion(t,e),ft.addHeaderType(t,n),ft.addHeader(t,i),ft.addBodyLength(t,s),ft.addCustomMetadata(t,o),ft.endMessage(t)}};var Ca=class extends v{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return He.startNull(e),He.endNull(e)}visitInt(t,e){return _t.startInt(e),_t.addBitWidth(e,t.bitWidth),_t.addIsSigned(e,t.isSigned),_t.endInt(e)}visitFloat(t,e){return Kt.startFloatingPoint(e),Kt.addPrecision(e,t.precision),Kt.endFloatingPoint(e)}visitBinary(t,e){return je.startBinary(e),je.endBinary(e)}visitLargeBinary(t,e){return We.startLargeBinary(e),We.endLargeBinary(e)}visitBool(t,e){return ze.startBool(e),ze.endBool(e)}visitUtf8(t,e){return Ke.startUtf8(e),Ke.endUtf8(e)}visitLargeUtf8(t,e){return Ge.startLargeUtf8(e),Ge.endLargeUtf8(e)}visitDecimal(t,e){return vt.startDecimal(e),vt.addScale(e,t.scale),vt.addPrecision(e,t.precision),vt.addBitWidth(e,t.bitWidth),vt.endDecimal(e)}visitDate(t,e){return Gt.startDate(e),Gt.addUnit(e,t.unit),Gt.endDate(e)}visitTime(t,e){return Mt.startTime(e),Mt.addUnit(e,t.unit),Mt.addBitWidth(e,t.bitWidth),Mt.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return Lt.startTimestamp(e),Lt.addUnit(e,t.unit),n!==void 0&&Lt.addTimezone(e,n),Lt.endTimestamp(e)}visitInterval(t,e){return Zt.startInterval(e),Zt.addUnit(e,t.unit),Zt.endInterval(e)}visitDuration(t,e){return $t.startDuration(e),$t.addUnit(e,t.unit),$t.endDuration(e)}visitList(t,e){return $e.startList(e),$e.endList(e)}visitStruct(t,e){return Ye.startStruct_(e),Ye.endStruct_(e)}visitUnion(t,e){It.startTypeIdsVector(e,t.typeIds.length);let n=It.createTypeIdsVector(e,t.typeIds);return It.startUnion(e),It.addMode(e,t.mode),It.addTypeIds(e,n),It.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return le.startDictionaryEncoding(e),le.addId(e,BigInt(t.id)),le.addIsOrdered(e,t.isOrdered),n!==void 0&&le.addIndexType(e,n),le.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Ht.startFixedSizeBinary(e),Ht.addByteWidth(e,t.byteWidth),Ht.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Yt.startFixedSizeList(e),Yt.addListSize(e,t.listSize),Yt.endFixedSizeList(e)}visitMap(t,e){return Jt.startMap(e),Jt.addKeysSorted(e,t.keysSorted),Jt.endMap(e)}},_o=new Ca;function fu(r,t=new Map){return new E(vd(r,t),vo(r.metadata),t)}function Pa(r){return new Ot(r.count,du(r.columns),pu(r.columns))}function hu(r){return new se(Pa(r.data),r.id,r.isDelta)}function vd(r,t){return(r.fields||[]).filter(Boolean).map(e=>D.fromJSON(e,t))}function cu(r,t){return(r.children||[]).filter(Boolean).map(e=>D.fromJSON(e,t))}function du(r){return(r||[]).reduce((t,e)=>[...t,new Be(e.count,Id(e.VALIDITY)),...du(e.children)],[])}function pu(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new ie(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new ie(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new ie(t.length,i.OFFSET.length)),i.DATA&&t.push(new ie(t.length,i.DATA.length)),t=pu(i.children,t)}return t}function Id(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function mu(r,t){let e,n,i,s,o,a;return!t||!(s=r.dictionary)?(o=uu(r,cu(r,t)),i=new D(r.name,o,r.nullable,vo(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?lu(n):new pt,a=new Ut(t.get(e),n,e,s.isOrdered),i=new D(r.name,a,r.nullable,vo(r.metadata))):(n=(n=s.indexType)?lu(n):new pt,t.set(e,o=uu(r,cu(r,t))),a=new Ut(o,n,e,s.isOrdered),i=new D(r.name,a,r.nullable,vo(r.metadata))),i||null}function vo(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function lu(r){return new it(r.isSigned,r.bitWidth)}function uu(r,t){let e=r.type.name;switch(e){case"NONE":return new ut;case"null":return new ut;case"binary":return new ue;case"largebinary":return new Je;case"utf8":return new Pt;case"largeutf8":return new Xe;case"bool":return new kt;case"list":return new Tt((t||[])[0]);case"struct":return new V(t||[]);case"struct_":return new V(t||[])}switch(e){case"int":{let n=r.type;return new it(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new At(j[n.precision])}case"decimal":{let n=r.type;return new fe(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new qt(et[n.unit])}case"time":{let n=r.type;return new xt(p[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new Nt(p[n.unit],n.timezone)}case"interval":{let n=r.type;return new te(nt[n.unit])}case"duration":{let n=r.type;return new Qe(p[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new Ie(K[o],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new qe(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new Vt(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new jt((t||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var xd=ar,Sd=Ct,gt=class{static fromJSON(t,e){let n=new gt(0,$.V5,e);return n._createHeader=Bd(t,e),n}static decode(t){t=new Sd(T(t));let e=ft.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new gt(n,i,s);return o._createHeader=Ad(e,s),o}static encode(t){let e=new xd,n=-1;return t.isSchema()?n=E.encode(e,t.header()):t.isRecordBatch()?n=Ot.encode(e,t.header()):t.isDictionaryBatch()&&(n=se.encode(e,t.header())),ft.startMessage(e),ft.addVersion(e,$.V5),ft.addHeader(e,n),ft.addHeaderType(e,t.headerType),ft.addBodyLength(e,BigInt(t.bodyLength)),ft.finishMessageBuffer(e,ft.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof E)return new gt(0,$.V5,P.Schema,t);if(t instanceof Ot)return new gt(e,$.V5,P.RecordBatch,t);if(t instanceof se)return new gt(e,$.V5,P.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 bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===P.Schema}isRecordBatch(){return this.headerType===P.RecordBatch}isDictionaryBatch(){return this.headerType===P.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=at(t)}},Ot=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=at(t)}},se=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,n=!1){this._data=t,this._isDelta=n,this._id=at(e)}},ie=class{constructor(t,e){this.offset=at(t),this.length=at(e)}},Be=class{constructor(t,e){this.length=at(t),this.nullCount=at(e)}};function Bd(r,t){return()=>{switch(t){case P.Schema:return E.fromJSON(r);case P.RecordBatch:return Ot.fromJSON(r);case P.DictionaryBatch:return se.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${P[t]}, type: ${t} }`)}}function Ad(r,t){return()=>{switch(t){case P.Schema:return E.decode(r.header(new ot),new Map,r.version());case P.RecordBatch:return Ot.decode(r.header(new Ft),r.version());case P.DictionaryBatch:return se.decode(r.header(new me),r.version())}throw new Error(`Unrecognized Message type: { name: ${P[t]}, type: ${t} }`)}}D.encode=Cd;D.decode=Ed;D.fromJSON=mu;E.encode=Rd;E.decode=Td;E.fromJSON=fu;Ot.encode=Pd;Ot.decode=Dd;Ot.fromJSON=Pa;se.encode=kd;se.decode=Od;se.fromJSON=hu;Be.encode=Vd;Be.decode=Md;ie.encode=jd;ie.decode=Fd;function Td(r,t=new Map,e=$.V5){let n=Ud(r,t);return new E(n,Io(r),t,e)}function Dd(r,t=$.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Ot(r.length(),Ld(r),Nd(r,t))}function Od(r,t=$.V5){return new se(Ot.decode(r.data(),t),r.id(),r.isDelta())}function Fd(r){return new ie(r.offset(),r.length())}function Md(r){return new Be(r.length(),r.nullCount())}function Ld(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=Be.decode(e));return t}function Nd(r,t){let e=[];for(let n,i=-1,s=-1,o=r.buffersLength();++i<o;)(n=r.buffers(i))&&(t<$.V4&&(n.bb_pos+=8*(i+1)),e[++s]=ie.decode(n));return e}function Ud(r,t){let e=[];for(let n,i=-1,s=-1,o=r.fieldsLength();++i<o;)(n=r.fields(i))&&(e[++s]=D.decode(n,t));return e}function yu(r,t){let e=[];for(let n,i=-1,s=-1,o=r.childrenLength();++i<o;)(n=r.children(i))&&(e[++s]=D.decode(n,t));return e}function Ed(r,t){let e,n,i,s,o,a;return!t||!(a=r.dictionary())?(i=bu(r,yu(r,t)),n=new D(r.name(),i,r.nullable(),Io(r))):t.has(e=at(a.id()))?(s=(s=a.indexType())?gu(s):new pt,o=new Ut(t.get(e),s,e,a.isOrdered()),n=new D(r.name(),o,r.nullable(),Io(r))):(s=(s=a.indexType())?gu(s):new pt,t.set(e,i=bu(r,yu(r,t))),o=new Ut(i,s,e,a.isOrdered()),n=new D(r.name(),o,r.nullable(),Io(r))),n||null}function Io(r){let t=new Map;if(r)for(let e,n,i=-1,s=Math.trunc(r.customMetadataLength());++i<s;)(e=r.customMetadata(i))&&(n=e.key())!=null&&t.set(n,e.value());return t}function gu(r){return new it(r.isSigned(),r.bitWidth())}function bu(r,t){let e=r.typeType();switch(e){case Z.NONE:return new ut;case Z.Null:return new ut;case Z.Binary:return new ue;case Z.LargeBinary:return new Je;case Z.Utf8:return new Pt;case Z.LargeUtf8:return new Xe;case Z.Bool:return new kt;case Z.List:return new Tt((t||[])[0]);case Z.Struct_:return new V(t||[])}switch(e){case Z.Int:{let n=r.type(new _t);return new it(n.isSigned(),n.bitWidth())}case Z.FloatingPoint:{let n=r.type(new Kt);return new At(n.precision())}case Z.Decimal:{let n=r.type(new vt);return new fe(n.scale(),n.precision(),n.bitWidth())}case Z.Date:{let n=r.type(new Gt);return new qt(n.unit())}case Z.Time:{let n=r.type(new Mt);return new xt(n.unit(),n.bitWidth())}case Z.Timestamp:{let n=r.type(new Lt);return new Nt(n.unit(),n.timezone())}case Z.Interval:{let n=r.type(new Zt);return new te(n.unit())}case Z.Duration:{let n=r.type(new $t);return new Qe(n.unit())}case Z.Union:{let n=r.type(new It);return new Ie(n.mode(),n.typeIdsArray()||[],t||[])}case Z.FixedSizeBinary:{let n=r.type(new Ht);return new qe(n.byteWidth())}case Z.FixedSizeList:{let n=r.type(new Yt);return new Vt(n.listSize(),(t||[])[0])}case Z.Map:{let n=r.type(new Jt);return new jt((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${Z[e]}" (${e})`)}function Rd(r,t){let e=t.fields.map(s=>D.encode(r,s));ot.startFieldsVector(r,e.length);let n=ot.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?ot.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString(`${s}`),c=r.createString(`${o}`);return Q.startKeyValue(r),Q.addKey(r,a),Q.addValue(r,c),Q.endKeyValue(r)})):-1;return ot.startSchema(r),ot.addFields(r,n),ot.addEndianness(r,zd?Sr.Little:Sr.Big),i!==-1&&ot.addCustomMetadata(r,i),ot.endSchema(r)}function Cd(r,t){let e=-1,n=-1,i=-1,s=t.type,o=t.typeId;m.isDictionary(s)?(o=s.dictionary.typeId,i=_o.visit(s,r),n=_o.visit(s.dictionary,r)):n=_o.visit(s,r);let a=(s.children||[]).map(u=>D.encode(r,u)),c=dt.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?dt.createCustomMetadataVector(r,[...t.metadata].map(([u,h])=>{let d=r.createString(`${u}`),b=r.createString(`${h}`);return Q.startKeyValue(r),Q.addKey(r,d),Q.addValue(r,b),Q.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),dt.startField(r),dt.addType(r,n),dt.addTypeType(r,o),dt.addChildren(r,c),dt.addNullable(r,!!t.nullable),e!==-1&&dt.addName(r,e),i!==-1&&dt.addDictionary(r,i),l!==-1&&dt.addCustomMetadata(r,l),dt.endField(r)}function Pd(r,t){let e=t.nodes||[],n=t.buffers||[];Ft.startNodesVector(r,e.length);for(let o of e.slice().reverse())Be.encode(r,o);let i=r.endVector();Ft.startBuffersVector(r,n.length);for(let o of n.slice().reverse())ie.encode(r,o);let s=r.endVector();return Ft.startRecordBatch(r),Ft.addLength(r,BigInt(t.length)),Ft.addNodes(r,i),Ft.addBuffers(r,s),Ft.endRecordBatch(r)}function kd(r,t){let e=Ot.encode(r,t.data);return me.startDictionaryBatch(r),me.addId(r,BigInt(t.id)),me.addIsDelta(r,t.isDelta),me.addData(r,e),me.endDictionaryBatch(r)}function Vd(r,t){return vn.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function jd(r,t){return _n.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var zd=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var Va=r=>`Expected ${P[r]} Message in stream, but was null or length 0.`,ja=r=>`Header pointer of flatbuffer-encoded ${P[r]} Message is null or length 0.`,wu=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,_u=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,kn=class{constructor(t){this.source=t instanceof rr?t:new rr(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?q:t.value===-1&&(t=this.readMetadataLength()).done?q:(t=this.readMetadata(t.value)).done?q: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(Va(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=T(this.source.read(t));if(e.byteLength<t)throw new Error(_u(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=P.Schema,n=this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(ja(e));return i}readMetadataLength(){let t=this.source.read(xo),e=t&&new Ct(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}}readMetadata(t){let e=this.source.read(t);if(!e)return q;if(e.byteLength<t)throw new Error(wu(t,e.byteLength));return{done:!1,value:gt.decode(e)}}},Pi=class{constructor(t,e){this.source=t instanceof re?t:fs(t)?new Fr(t,e):new re(t)}[Symbol.asyncIterator](){return this}next(){return y(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?q:t.value===-1&&(t=yield this.readMetadataLength()).done?q:(t=yield this.readMetadata(t.value)).done?q:t})}throw(t){return y(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return y(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return y(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(Va(t));return e.value})}readMessageBody(t){return y(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=T(yield this.source.read(t));if(e.byteLength<t)throw new Error(_u(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(t=!1){return y(this,void 0,void 0,function*(){let e=P.Schema,n=yield this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(ja(e));return i})}readMetadataLength(){return y(this,void 0,void 0,function*(){let t=yield this.source.read(xo),e=t&&new Ct(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}})}readMetadata(t){return y(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return q;if(e.byteLength<t)throw new Error(wu(t,e.byteLength));return{done:!1,value:gt.decode(e)}})}},ki=class extends kn{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof ui?t:new ui(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:gt.fromJSON(t.schema,P.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:gt.fromJSON(e,P.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:gt.fromJSON(e,P.RecordBatch)}}return this._body=[],q}readMessageBody(t){return e(this._body);function e(n){return(n||[]).reduce((i,s)=>[...i,...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(Va(t));return e.value}readSchema(){let t=P.Schema,e=this.readMessage(t),n=e?.header();if(!e||!n)throw new Error(ja(t));return n}},xo=4,ka="ARROW1",Vn=new Uint8Array(ka.length);for(let r=0;r<ka.length;r+=1)Vn[r]=ka.codePointAt(r);function So(r,t=0){for(let e=-1,n=Vn.length;++e<n;)if(Vn[e]!==r[t+e])return!1;return!0}var jn=Vn.length,za=jn+xo,vu=jn*2+xo;var bt=class extends en{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 ae(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 Bt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Bt.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 bt?t:ls(t)?Gd(t):fs(t)?Yd(t):ae(t)?(()=>y(this,void 0,void 0,function*(){return yield bt.from(yield t)}))():hs(t)||Qn(t)||ps(t)||de(t)?Hd(new re(t)):$d(new rr(t))}static readAll(t){return t instanceof bt?t.isSync()?Iu(t):xu(t):ls(t)||ArrayBuffer.isView(t)||De(t)||us(t)?Iu(t):xu(t)}},ir=class extends bt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return oe(this,arguments,function*(){yield U(yield*bn(Te(this[Symbol.iterator]())))})}},Mr=class extends bt{constructor(t){super(t),this._impl=t}readAll(){var t,e,n,i;return y(this,void 0,void 0,function*(){let s=new Array;try{for(var o=!0,a=Te(this),c;c=yield a.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let l=i;s.push(l)}}catch(l){e={error:l}}finally{try{!o&&!t&&(n=a.return)&&(yield n.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]()}},Lr=class extends ir{constructor(t){super(t),this._impl=t}},Vi=class extends Mr{constructor(t){super(t),this._impl=t}},Bo=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 n=this._loadVectors(t,e,this.schema.fields),i=w({type:new V(this.schema.fields),length:t.length,children:n});return new Y(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:o}=this,a=s.get(n);if(i||!a){let c=o.dictionaries.get(n),l=this._loadVectors(t.data,e,[c]);return(a&&i?a.concat(new g(l)):new g(l)).memoize()}return a.memoize()}_loadVectors(t,e,n){return new di(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},zn=class extends Bo{constructor(t,e){super(e),this._reader=ls(t)?new ki(this._handle=t):new kn(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=Su(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):q}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):q}next(){if(this.closed)return q;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new cn(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Wn=class extends Bo{constructor(t,e){super(e),this._reader=new Pi(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return y(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 y(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Su(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):q})}return(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):q})}next(){return y(this,void 0,void 0,function*(){if(this.closed)return q;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 n=t.header(),i=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new cn(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return y(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},Ao=class extends zn{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 fi?t:new fi(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 n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(P.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(P.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-za,n=t.readInt32(e),i=t.readAt(e-n,n);return fr.decode(i)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(n&&this._handle.seek(n.offset))return this._reader.readMessage(t)}return null}},Wa=class extends Wn{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 n=typeof e[0]!="number"?e.shift():void 0,i=e[0]instanceof Map?e.shift():void 0;super(t instanceof Fr?t:new Fr(t,n),i)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return y(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){var e;return y(this,void 0,void 0,function*(){if(this.closed)return null;this._footer||(yield this.open());let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(P.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){var e;return y(this,void 0,void 0,function*(){let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(P.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return y(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-za,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return fr.decode(i)})}_readNextMessageAndValidate(t){return y(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})}},Ga=class extends zn{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new Ks(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function Su(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Iu(r){let t=bt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function xu(r){return oe(this,arguments,function*(){let e=yield U(bt.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 Gd(r){return new ir(new Ga(r))}function $d(r){let t=r.peek(jn+7&-8);return t&&t.byteLength>=4?So(t)?new Lr(new Ao(r.read())):new ir(new zn(r)):new ir(new zn(function*(){}()))}function Hd(r){return y(this,void 0,void 0,function*(){let t=yield r.peek(jn+7&-8);return t&&t.byteLength>=4?So(t)?new Lr(new Ao(yield r.read())):new Mr(new Wn(r)):new Mr(new Wn(function(){return oe(this,arguments,function*(){})}()))})}function Yd(r){return y(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Fr(r,t);return t>=vu&&So(yield e.readAt(0,jn+7&-8))?new Vi(new Wa(e)):new Mr(new Wn(e))})}var tt=class extends v{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof Y?s.data.children:s.data),n=new tt;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof g)return this.visitMany(t.data),this;let{type:e}=t;if(!m.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(m.isUnion(e))this.nodes.push(new Be(n,0));else{let{nullCount:i}=t;m.isNull(e)||Ce.call(this,i<=0?new Uint8Array(0):Jr(t.offset,n,t.nullBitmap)),this.nodes.push(new Be(n,i))}}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 Ce(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new ie(this._byteLength,t)),this._byteLength+=t,this}function Kd(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(Ce.call(this,i),e.mode===K.Sparse)return $a.call(this,r);if(e.mode===K.Dense){if(r.offset<=0)return Ce.call(this,s),$a.call(this,r);{let o=new Int32Array(n),a=Object.create(null),c=Object.create(null);for(let l,u,h=-1;++h<n;)(l=i[h])!==void 0&&((u=a[l])===void 0&&(u=a[l]=s[h]),o[h]=s[h]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);Ce.call(this,o),this.visitMany(r.children.map((l,u)=>{let h=e.typeIds[u],d=a[h],b=c[h];return l.slice(d,Math.min(n,b))}))}}return this}function Zd(r){let t;return r.nullCount>=r.length?Ce.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?Ce.call(this,Jr(r.offset,r.length,t)):Ce.call(this,Xr(r.values))}function br(r){return Ce.call(this,r.values.subarray(0,r.length*r.stride))}function To(r){let{length:t,values:e,valueOffsets:n}=r,i=at(n[0]),s=at(n[t]),o=Math.min(s-i,e.byteLength-i);return Ce.call(this,ys(-i,t+1,n)),Ce.call(this,e.subarray(i,i+o)),this}function Ha(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return Ce.call(this,ys(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function $a(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}tt.prototype.visitBool=Zd;tt.prototype.visitInt=br;tt.prototype.visitFloat=br;tt.prototype.visitUtf8=To;tt.prototype.visitLargeUtf8=To;tt.prototype.visitBinary=To;tt.prototype.visitLargeBinary=To;tt.prototype.visitFixedSizeBinary=br;tt.prototype.visitDate=br;tt.prototype.visitTimestamp=br;tt.prototype.visitTime=br;tt.prototype.visitDecimal=br;tt.prototype.visitList=Ha;tt.prototype.visitStruct=$a;tt.prototype.visitUnion=Kd;tt.prototype.visitInterval=br;tt.prototype.visitDuration=br;tt.prototype.visitFixedSizeList=Ha;tt.prototype.visitMap=Ha;var ln=class extends en{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){super(),this._position=0,this._started=!1,this._sink=new er,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,Rt(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return ae(t)?t.then(e=>this.writeAll(e)):de(t)?Ka(this,t):Ya(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 er?this._sink=t:(this._sink=new er,t&&Pc(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&kc(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,(!e||!an(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 J&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Y&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!an(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Y?t instanceof cn||this._writeRecordBatch(t):t instanceof J?this.writeAll(t.batches):De(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=gt.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+n&~n,c=a-s-o;return t.headerType===P.RecordBatch?this._recordBatchBlocks.push(new Re(a,t.bodyLength,this._position)):t.headerType===P.DictionaryBatch&&this._dictionaryBlocks.push(new Re(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(c)}_write(t){if(this._started){let e=T(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(gt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Vn)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=tt.assemble(t),o=new Ot(t.numRows,n,i),a=gt.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0));let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=tt.assemble(new g([t])),c=new Ot(t.length,s,o),l=new se(c,e,n),u=gt.from(l,i);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,n,i;for(let s=-1,o=t.length;++s<o;)(e=t[s])&&(n=e.byteLength)>0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this}_writeDictionaries(t){for(let[e,n]of t.dictionaries){let i=this._dictionaryDeltaOffsets.get(e)||0;if(i===0||(n=n?.slice(i)).length>0)for(let s of n.data)this._writeDictionaryBatch(s,e,i>0),i+=s.length}return this}},wr=class extends ln{static writeAll(t,e){let n=new wr(e);return ae(t)?t.then(i=>n.writeAll(i)):de(t)?Ka(n,t):Ya(n,t)}},_r=class extends ln{static writeAll(t){let e=new _r;return ae(t)?t.then(n=>e.writeAll(n)):de(t)?Ka(e,t):Ya(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){let e=fr.encode(new fr(t,$.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Ya(r,t){let e=t;t instanceof J&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function Ka(r,t){var e,n,i,s,o,a,c;return y(this,void 0,void 0,function*(){try{for(e=!0,n=Te(t);i=yield n.next(),s=i.done,!s;e=!0){c=i.value,e=!1;let l=c;r.write(l)}}catch(l){o={error:l}}finally{try{!e&&!s&&(a=n.return)&&(yield a.call(n))}finally{if(o)throw o.error}}return r.finish()})}function Bu(r,t){if(de(r))return Xd(r,t);if(De(r))return Jd(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Jd(r,t){let e=null,n=t?.type==="bytes"||!1,i=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?.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){let c,l=null,u=o.desiredSize||null;for(;!(l=a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=T(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()}}function Xd(r,t){let e=null,n=t?.type==="bytes"||!1,i=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return y(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return y(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return y(this,void 0,void 0,function*(){(e?.return&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){return y(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=T(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()})}}function Du(r){return new Za(r)}var Za=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=Rc(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=dr(s),this._getSize=i!=="bytes"?Au:Tu;let{["highWaterMark"]:o=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n);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:i!=="bytes"?Au:Tu}),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)}},Au=r=>{var t;return(t=r?.length)!==null&&t!==void 0?t:0},Tu=r=>{var t;return(t=r?.byteLength)!==null&&t!==void 0?t:0};function Do(r,t){let e=new er,n=null,i=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield e.close()})},start(a){return y(this,void 0,void 0,function*(){yield o(a,n||(n=yield s()))})},pull(a){return y(this,void 0,void 0,function*(){n?yield o(a,n):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:i};function s(){return y(this,void 0,void 0,function*(){return yield(yield bt.from(e)).open(t)})}function o(a,c){return y(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 Oo(r,t){let e=new this(r),n=new re(e),i=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return y(this,void 0,void 0,function*(){yield s(o)})},start(o){return y(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(o){return y(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield n.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}function ji(r){let t=bt.from(r);return ae(t)?t.then(e=>ji(e)):t.isAsync()?t.readAll().then(e=>new J(e)):new J(t.readAll())}function Fo(r,t="stream"){return(t==="stream"?wr:_r).writeAll(r).toUint8Array(!0)}var cp=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},oa),Ma),xa),aa),ea),Ia),ia),{compareSchemas:an,compareFields:nu,compareTypes:go});Bt.toDOMStream=Bu;rt.throughDOM=Du;bt.throughDOM=Do;Lr.throughDOM=Do;ir.throughDOM=Do;ln.throughDOM=Oo;_r.throughDOM=Oo;wr.throughDOM=Oo;var Mo=class extends Er{arrowSchema;constructor(t,e){super(t,e),this.arrowSchema=null}getBatch(){let t=super.getBatch();if(t){this.arrowSchema=this.arrowSchema||lp(t.schema);let e=up(this.arrowSchema,t.data),n=new Y(this.arrowSchema,w({type:new V(this.arrowSchema.fields),children:e.map(({data:i})=>i[0])}));return{shape:"arrow-table",batchType:"data",data:new J([n]),length:t.length}}return null}};function lp(r){let t=[];for(let e in r){let n=r[e];if(n.type===Float32Array){let i=new Map,s=new D(n.name,new Xt,n.nullable,i);t.push(s)}}if(t.length===0)throw new Error("No arrow convertible fields");return new E(t)}function up(r,t){let e=[];for(let n of r.fields){let i=t[n.name];if(i instanceof Float32Array){let s=Or(i);e.push(s)}}if(r.fields.length!==e.length)throw new Error("Some columns not arrow convertible");return e}function Ou(r){switch(r.constructor){case Int8Array:return new ye;case Uint8Array:return new we;case Int16Array:return new ge;case Uint16Array:return new _e;case Int32Array:return new pt;case Uint32Array:return new ve;case Float32Array:return new Xt;case Float64Array:return new Qt;default:throw new Error("array type not supported")}}var fn;(function(r){r[r.FLOAT=0]="FLOAT",r[r.DATE=1]="DATE"})(fn||(fn={}));function Lo(r){let t=r.data,e={};for(let n of t.schema.fields){let s=t.getChild(n.name)?.toArray();e[n.name]=s}return{shape:"columnar-table",schema:r.schema,data:e}}function Gn(r){return{fields:r.fields.map(t=>hn(t)),metadata:No(r.metadata)}}function Fu(r){return new E(r.fields.map(t=>dn(t)),Uo(r.metadata))}function No(r){return Object.fromEntries(r)}function Uo(r){return r?new Map(Object.entries(r)):new Map}function hn(r){return{name:r.name,type:Ja(r.type),nullable:r.nullable,metadata:No(r.metadata)}}function dn(r){return new D(r.name,Xa(r.type),r.nullable,Uo(r.metadata))}function Ja(r){switch(r.constructor){case ut:return"null";case ue:return"binary";case kt:return"bool";case it:let t=r;return`${t.isSigned?"u":""}int${t.bitWidth}`;case ye:return"int8";case ge:return"int16";case pt:return"int32";case be:return"int64";case we:return"uint8";case _e:return"uint16";case ve:return"uint32";case Ze:return"uint64";case At:switch(r.precision){case j.HALF:return"float16";case j.SINGLE:return"float32";case j.DOUBLE:return"float64";default:return"float16"}case Br:return"float16";case Xt:return"float32";case Qt:return"float64";case Pt:return"utf8";case fe:let n=r;return{type:"decimal",bitWidth:n.bitWidth,precision:n.precision,scale:n.scale};case qt:return r.unit===et.DAY?"date-day":"date-millisecond";case Pr:return"date-day";case cr:return"date-millisecond";case xt:switch(r.unit){case p.SECOND:return"time-second";case p.MILLISECOND:return"time-millisecond";case p.MICROSECOND:return"time-microsecond";case p.NANOSECOND:return"time-nanosecond";default:return"time-second"}case Vr:return"time-millisecond";case kr:return"time-second";case jr:return"time-microsecond";case zr:return"time-nanosecond";case Nt:switch(r.unit){case p.SECOND:return"timestamp-second";case p.MILLISECOND:return"timestamp-millisecond";case p.MICROSECOND:return"timestamp-microsecond";case p.NANOSECOND:return"timestamp-nanosecond";default:return"timestamp-second"}case Wr:return"timestamp-second";case Gr:return"timestamp-millisecond";case $r:return"timestamp-microsecond";case Hr:return"timestamp-nanosecond";case te:switch(r.unit){case nt.DAY_TIME:return"interval-daytime";case nt.YEAR_MONTH:return"interval-yearmonth";default:return"interval-daytime"}case Yr:return"interval-daytime";case Kr:return"interval-yearmonth";case jt:let c=r;return{type:"map",keysSorted:c.keysSorted,children:c.children.map(b=>hn(b))};case Tt:let u=r.valueField;return{type:"list",children:[hn(u)]};case Vt:let h=r;return{type:"fixed-size-list",listSize:h.listSize,children:[hn(h.children[0])]};case V:return{type:"struct",children:r.children.map(b=>hn(b))};default:throw new Error(`arrow type not supported: ${r.constructor.name}`)}}function Xa(r){if(typeof r=="object")switch(r.type){case"decimal":return new fe(r.precision,r.scale,r.bitWidth);case"map":let t=r.children.map(i=>dn(i));return new jt(t,r.keysSorted);case"list":let e=dn(r.children[0]);return new Tt(e);case"fixed-size-list":let n=dn(r.children[0]);return new Vt(r.listSize,n);case"struct":return t=r.children.map(i=>dn(i)),new V(t);default:throw new Error("array type not supported")}switch(r){case"null":return new ut;case"binary":return new ue;case"bool":return new kt;case"int8":return new ye;case"int16":return new ge;case"int32":return new pt;case"int64":return new be;case"uint8":return new we;case"uint16":return new _e;case"uint32":return new ve;case"uint64":return new Ze;case"float16":return new Br;case"float32":return new Xt;case"float64":return new Qt;case"utf8":return new Pt;case"date-day":return new Pr;case"date-millisecond":return new cr;case"time-second":return new kr;case"time-millisecond":return new Vr;case"time-microsecond":return new jr;case"time-nanosecond":return new zr;case"timestamp-second":return new Wr;case"timestamp-millisecond":return new Gr;case"timestamp-microsecond":return new $r;case"timestamp-nanosecond":return new Hr;case"interval-daytime":return new Yr;case"interval-yearmonth":return new Kr;default:throw new Error("array type not supported")}}function zi(r,t){let e=ji([new Uint8Array(r)]),n={shape:"arrow-table",schema:Gn(e.schema),data:e},i=t?.shape||"arrow-table";switch(i){case"arrow-table":return n;case"columnar-table":return Lo(n);case"object-row-table":let s=Lo(n);return cs(s,"object-row-table");case"array-row-table":return s=Lo(n),cs(s,"array-row-table");default:throw new Error(i)}}function Eo(r,t){async function*e(){let n=bt.readAll(r);for await(let i of n){for await(let s of i)t?.arrow?.batchDebounceMs!==void 0&&t?.arrow?.batchDebounceMs>0&&await new Promise(a=>setTimeout(a,t.arrow?.batchDebounceMs||0)),yield{shape:"arrow-table",batchType:"data",data:new J([s]),length:s.data.length};break}}return e()}var fp="4.3.0-alpha.6",Wi={dataType:null,batchType:null,name:"Apache Arrow",id:"arrow",module:"arrow",version:fp,category:"table",extensions:["arrow","feather"],mimeTypes:["application/vnd.apache.arrow.file","application/vnd.apache.arrow.stream","application/octet-stream"],binary:!0,tests:["ARROW"],options:{arrow:{shape:"columnar-table"}}},Mu={...Wi,parse:async(r,t)=>zi(r,t?.arrow),parseSync:(r,t)=>zi(r,t?.arrow),parseInBatches:Eo};function Qa(r){let t={};for(let i of r){let s=hp(i.array,i.type);t[i.name]=s}let e=new J(t);return Fo(e)}function hp(r,t){switch(t){case fn.DATE:return Ci(r);case fn.FLOAT:default:return Ci(r)}}var dp="4.3.0-alpha.6",Lu={name:"Apache Arrow",id:"arrow",module:"arrow",version:dp,extensions:["arrow","feather"],mimeTypes:["application/vnd.apache.arrow.file","application/vnd.apache.arrow.stream","application/octet-stream"],binary:!0,options:{},encode:async function(t,e){return Qa(t)},encodeSync(r,t){return Qa(r)}};var pp=["geoarrow.multipolygon","geoarrow.polygon","geoarrow.multilinestring","geoarrow.linestring","geoarrow.multipoint","geoarrow.point","geoarrow.wkb","geoarrow.wkt"],mp="ARROW:extension:name",yp="ARROW:extension:metadata";function qa(r){let t={};for(let e of r.fields){let n=gp(e);n&&(t[e.name]=n)}return t}function gp(r){let t=null,e=r.metadata?.[mp];e&&(e=e.toLowerCase(),e==="wkb"&&(e="geoarrow.wkb"),e==="wkt"&&(e="geoarrow.wkt"),pp.includes(e)?(t=t||{},t.encoding=e):console.warn(`Invalid GeoArrow encoding: ${e}`));let n=r.metadata?.[yp];if(n)try{t=JSON.parse(n)}catch(i){console.warn("Failed to parse GeoArrow metadata",i)}return t||null}function Nr(r){return Nr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Nr(r)}function tc(r,t){if(Nr(r)!=="object"||r===null)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t||"default");if(Nr(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function ec(r){var t=tc(r,"string");return Nr(t)==="symbol"?t:String(t)}function Ae(r,t,e){return t=ec(t),t in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}var Gi={x:0,y:1,z:2};function Ro(r,t={}){let{start:e=0,end:n=r.length,plane:i="xy"}=t,s=t.size||2,o=0,a=Gi[i[0]],c=Gi[i[1]];for(let l=e,u=n-s;l<n;l+=s)o+=(r[l+a]-r[u+a])*(r[l+c]+r[u+c]),u=l;return o/2}function nc(r,t,e=2,n,i="xy"){let s=t&&t.length,o=s?t[0]*e:r.length,a=Uu(r,0,o,e,!0,n&&n[0],i),c=[];if(!a||a.next===a.prev)return c;let l,u,h,d,b,M,z;if(s&&(a=Sp(r,t,a,e,n,i)),r.length>80*e){d=u=r[0],b=h=r[1];for(let X=e;X<o;X+=e)M=r[X],z=r[X+1],M<d&&(d=M),z<b&&(b=z),M>u&&(u=M),z>h&&(h=z);l=Math.max(u-d,h-b),l=l!==0?32767/l:0}return $i(a,c,e,d,b,l,0),c}function Uu(r,t,e,n,i,s,o){let a,c;s===void 0&&(s=Ro(r,{start:t,end:e,size:n,plane:o}));let l=Gi[o[0]],u=Gi[o[1]];if(i===s<0)for(a=t;a<e;a+=n)c=Nu(a,r[a+l],r[a+u],c);else for(a=e-n;a>=t;a-=n)c=Nu(a,r[a+l],r[a+u],c);return c&&ko(c,c.next)&&(Yi(c),c=c.next),c}function pn(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(ko(e,e.next)||ct(e.prev,e,e.next)===0)){if(Yi(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function $i(r,t,e,n,i,s,o){if(!r)return;!o&&s&&Op(r,n,i,s);let a=r,c,l;for(;r.prev!==r.next;){if(c=r.prev,l=r.next,s?vp(r,n,i,s):_p(r)){t.push(c.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),Yi(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=Ip(pn(r),t,e),$i(r,t,e,n,i,s,2)):o===2&&xp(r,t,e,n,i,s):$i(pn(r),t,e,n,i,s,1);break}}}function _p(r){let t=r.prev,e=r,n=r.next;if(ct(t,e,n)>=0)return!1;let i=t.x,s=e.x,o=n.x,a=t.y,c=e.y,l=n.y,u=i<s?i<o?i:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,d=i>s?i>o?i:o:s>o?s:o,b=a>c?a>l?a:l:c>l?c:l,M=n.next;for(;M!==t;){if(M.x>=u&&M.x<=d&&M.y>=h&&M.y<=b&&$n(i,a,s,c,o,l,M.x,M.y)&&ct(M.prev,M,M.next)>=0)return!1;M=M.next}return!0}function vp(r,t,e,n){let i=r.prev,s=r,o=r.next;if(ct(i,s,o)>=0)return!1;let a=i.x,c=s.x,l=o.x,u=i.y,h=s.y,d=o.y,b=a<c?a<l?a:l:c<l?c:l,M=u<h?u<d?u:d:h<d?h:d,z=a>c?a>l?a:l:c>l?c:l,X=u>h?u>d?u:d:h>d?h:d,st=rc(b,M,t,e,n),yn=rc(z,X,t,e,n),W=r.prevZ,k=r.nextZ;for(;W&&W.z>=st&&k&&k.z<=yn;){if(W.x>=b&&W.x<=z&&W.y>=M&&W.y<=X&&W!==i&&W!==o&&$n(a,u,c,h,l,d,W.x,W.y)&&ct(W.prev,W,W.next)>=0||(W=W.prevZ,k.x>=b&&k.x<=z&&k.y>=M&&k.y<=X&&k!==i&&k!==o&&$n(a,u,c,h,l,d,k.x,k.y)&&ct(k.prev,k,k.next)>=0))return!1;k=k.nextZ}for(;W&&W.z>=st;){if(W.x>=b&&W.x<=z&&W.y>=M&&W.y<=X&&W!==i&&W!==o&&$n(a,u,c,h,l,d,W.x,W.y)&&ct(W.prev,W,W.next)>=0)return!1;W=W.prevZ}for(;k&&k.z<=yn;){if(k.x>=b&&k.x<=z&&k.y>=M&&k.y<=X&&k!==i&&k!==o&&$n(a,u,c,h,l,d,k.x,k.y)&&ct(k.prev,k,k.next)>=0)return!1;k=k.nextZ}return!0}function Ip(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!ko(i,s)&&Eu(i,n,n.next,s)&&Hi(i,s)&&Hi(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Yi(n),Yi(n.next),n=r=s),n=n.next}while(n!==r);return pn(n)}function xp(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Lp(o,a)){let c=Ru(o,a);o=pn(o,o.next),c=pn(c,c.next),$i(o,t,e,n,i,s,0),$i(c,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function Sp(r,t,e,n,i,s){let o=[],a,c,l,u,h;for(a=0,c=t.length;a<c;a++)l=t[a]*n,u=a<c-1?t[a+1]*n:r.length,h=Uu(r,l,u,n,!1,i&&i[a+1],s),h===h.next&&(h.steiner=!0),o.push(Mp(h));for(o.sort(Bp),a=0;a<o.length;a++)e=Ap(o[a],e);return e}function Bp(r,t){return r.x-t.x}function Ap(r,t){let e=Tp(r,t);if(!e)return t;let n=Ru(e,r);return pn(n,n.next),pn(e,e.next)}function Tp(r,t){let e=t,n=r.x,i=r.y,s=-1/0,o;do{if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){let d=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=n&&d>s&&(s=d,o=e.x<e.next.x?e:e.next,d===n))return o}e=e.next}while(e!==t);if(!o)return null;let a=o,c=o.x,l=o.y,u=1/0,h;e=o;do n>=e.x&&e.x>=c&&n!==e.x&&$n(i<l?n:s,i,c,l,i<l?s:n,i,e.x,e.y)&&(h=Math.abs(i-e.y)/(n-e.x),Hi(e,r)&&(h<u||h===u&&(e.x>o.x||e.x===o.x&&Dp(o,e)))&&(o=e,u=h)),e=e.next;while(e!==a);return o}function Dp(r,t){return ct(r.prev,r,t.prev)<0&&ct(t.next,r,r.next)<0}function Op(r,t,e,n){let i=r;do i.z===0&&(i.z=rc(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,Fp(i)}function Fp(r){let t,e,n=1,i,s,o,a,c,l;do{for(s=r,r=null,l=null,i=0;s;){for(i++,a=s,o=0,e=0;e<n&&(o++,a=a.nextZ,!!a);e++);for(c=n;o>0||c>0&&a;)o!==0&&(c===0||!a||s.z<=a.z)?(t=s,s=s.nextZ,o--):(t=a,a=a.nextZ,c--),l?l.nextZ=t:r=t,t.prevZ=l,l=t;s=a}l.nextZ=null,n*=2}while(i>1);return r}function rc(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function Mp(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function $n(r,t,e,n,i,s,o,a){return(i-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(n-a)}function Lp(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Np(r,t)&&(Hi(r,t)&&Hi(t,r)&&Up(r,t)&&(ct(r.prev,r,t.prev)||ct(r,t.prev,t))||ko(r,t)&&ct(r.prev,r,r.next)>0&&ct(t.prev,t,t.next)>0)}function ct(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function ko(r,t){return r.x===t.x&&r.y===t.y}function Eu(r,t,e,n){let i=Po(ct(r,t,e)),s=Po(ct(r,t,n)),o=Po(ct(e,n,r)),a=Po(ct(e,n,t));return!!(i!==s&&o!==a||i===0&&Co(r,e,t)||s===0&&Co(r,n,t)||o===0&&Co(e,r,n)||a===0&&Co(e,t,n))}function Co(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Po(r){return r>0?1:r<0?-1:0}function Np(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&Eu(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Hi(r,t){return ct(r.prev,r,r.next)<0?ct(r,t,r.next)>=0&&ct(r,r.prev,t)>=0:ct(r,t,r.prev)<0||ct(r,r.next,t)<0}function Up(r,t){let e=r,n=!1,i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function Ru(r,t){let e=new Ki(r.i,r.x,r.y),n=new Ki(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function Nu(r,t,e,n){let i=new Ki(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Yi(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}var Ki=class{constructor(t,e,n){Ae(this,"i",void 0),Ae(this,"x",void 0),Ae(this,"y",void 0),Ae(this,"prev",null),Ae(this,"next",null),Ae(this,"z",0),Ae(this,"prevZ",null),Ae(this,"nextZ",null),Ae(this,"steiner",!1),this.i=t,this.x=e,this.y=n}};function Hn(r,t,e){switch(r.type){case"Point":return Vp(r,t,e);case"LineString":return kp(r,t,e);case"Polygon":return ku(r,t,e);default:let n=r;throw new Error(`Unsupported geometry type: ${n?.type}`)}}function ku(r,t=-1/0,e=1/0){let{positions:n}=r,i=r.polygonIndices.value.filter(c=>c>=t&&c<=e),s=r.primitivePolygonIndices.value.filter(c=>c>=t&&c<=e);if(!(i.length>2)){let c=[];for(let l=0;l<s.length-1;l++){let u=s[l],h=s[l+1],d=Vo(n,u,h);c.push(d)}return{type:"Polygon",coordinates:c}}let a=[];for(let c=0;c<i.length-1;c++){let l=i[c],u=i[c+1],h=ku(r,l,u).coordinates;a.push(h)}return{type:"MultiPolygon",coordinates:a}}function kp(r,t=-1/0,e=1/0){let{positions:n}=r,i=r.pathIndices.value.filter(a=>a>=t&&a<=e);if(!(i.length>2))return{type:"LineString",coordinates:Vo(n,i[0],i[1])};let o=[];for(let a=0;a<i.length-1;a++){let c=Vo(n,i[a],i[a+1]);o.push(c)}return{type:"MultiLineString",coordinates:o}}function Vp(r,t,e){let{positions:n}=r,i=Vo(n,t,e);return i.length>1?{type:"MultiPoint",coordinates:i}:{type:"Point",coordinates:i[0]}}function Vo(r,t,e){t=t||0,e=e||r.value.length/r.size;let n=[];for(let i=t;i<e;i++){let s=Array();for(let o=i*r.size;o<(i+1)*r.size;o++)s.push(Number(r.value[o]));n.push(s)}return n}function jo(r){let t=r.data,e=Gn(t.schema),n=qa(e),i=n.geometry.encoding,s=[],o=t.schema.fields.map(l=>l.name).filter(l=>!(l in n)),a=t.select(o),c=t.getChild("geometry");for(let l=0;l<t.numRows;l++){let u=c?.get(l),h=zo(u,i);if(h){let d=a.get(l)?.toJSON()||{};s.push({type:"Feature",geometry:h,properties:d})}}return{shape:"geojson-table",type:"FeatureCollection",schema:r.schema,features:s}}function ic(r,t){let e=zi(r,{shape:"arrow-table"});switch(t?.shape){case"geojson-table":return jo(e);default:return e}}function Vu(r){return Eo(r)}var sc={...Wi,options:{arrow:{shape:"arrow-table"}}},ju={...sc,parse:async(r,t)=>ic(r,t?.arrow),parseSync:(r,t)=>ic(r,t?.arrow),parseInBatches:Vu};function Wo(r,t,e,n=100){let i=r.length/t,s=Math.max(Math.floor(i/n),1),o=[...e];for(let a=0;a<i;a+=s){let c=r[a*t],l=r[a*t+1];c<o[0]&&(o[0]=c),l<o[1]&&(o[1]=l),c>o[2]&&(o[2]=c),l>o[3]&&(o[3]=l)}return o}var Yn;(function(r){r.points="points",r.lines="lines",r.polygons="polygons"})(Yn||(Yn={}));function Zi(){return{globalFeatureIds:{value:new Uint32Array(0),size:1},positions:{value:new Float32Array(0),size:2},properties:[],numericProps:{},featureIds:{value:new Uint32Array(0),size:1}}}function zu(r,t,e){let n={polygon:t==="geoarrow.multipolygon"||t==="geoarrow.polygon",point:t==="geoarrow.multipoint"||t==="geoarrow.point",line:t==="geoarrow.multilinestring"||t==="geoarrow.linestring"},i=e?.chunkIndex!==void 0&&e?.chunkIndex>=0?[r.data[e?.chunkIndex]]:r.data,s=[1/0,1/0,-1/0,-1/0],o=e?.chunkOffset||0,a=[];return i.forEach(c=>{let{featureIds:l,flatCoordinateArray:u,nDim:h,geomOffset:d,triangles:b}=zp(c,t,e),M=new Uint32Array(l.length);for(let X=0;X<l.length;X++)M[X]=l[X]+o;let z={globalFeatureIds:{value:M,size:1},positions:{value:u,size:h},featureIds:{value:l,size:1},properties:[...Array(c.length).keys()].map(X=>({index:X+o}))};o+=c.length,a.push({shape:"binary-feature-collection",points:{type:"Point",...Zi(),...n.point?z:{}},lines:{type:"LineString",...Zi(),...n.line?z:{},pathIndices:{value:n.line?d:new Uint16Array(0),size:1}},polygons:{type:"Polygon",...Zi(),...n.polygon?z:{},polygonIndices:{value:n.polygon?d:new Uint16Array(0),size:1},primitivePolygonIndices:{value:n.polygon?d:new Uint16Array(0),size:1},...b?{triangles:{value:b,size:1}}:{}}}),s=Wo(u,h,s)}),{binaryGeometries:a,bounds:s,featureTypes:n,...e?.calculateMeanCenters?{meanCenters:oc(a)}:{}}}function oc(r){let t=[];return r.forEach(e=>{let n=null;e.points&&e.points.positions.value.length>0?n=Yn.points:e.lines&&e.lines.positions.value.length>0?n=Yn.lines:e.polygons&&e.polygons.positions.value.length>0&&(n=Yn.polygons);let i=n?e[n]:null;if(i&&n!==null){let s=i.featureIds.value,o=i.positions.value,a=i.positions.size,c=i.type==="Polygon"?i.primitivePolygonIndices?.value:void 0;jp(s,o,a,n,c).forEach(u=>{t.push(u)})}}),t}function jp(r,t,e,n,i){let s=[],o=t.length,a=0,c=0,l=0;for(;a<o;){let u=r[a/e],h=[0,0],d=0;for(;a<o&&r[c]===u;)n===Yn.polygons&&i?.[l]===c?(a+=e,l++):(h[0]+=t[a],h[1]+=t[a+1],a+=e,d++),c+=1;h[0]/=d,h[1]/=d,s.push(h)}return s}function zp(r,t,e){switch(t){case"geoarrow.point":case"geoarrow.multipoint":return $p(r,t);case"geoarrow.linestring":case"geoarrow.multilinestring":return Gp(r,t);case"geoarrow.polygon":case"geoarrow.multipolygon":return Wp(r,t,e);default:throw Error("invalid geoarrow encoding")}}function ac(r,t,e,n){try{let i=0,s=[];for(let a=0;a<r.length-1;a++){let c=r[a],l=r[a+1],u=e.subarray(c*n,l*n),h=[];for(;t[i]<l;)t[i]>c&&h.push(t[i]-c),i++;let d=nc(u,h.length>0?h:void 0,n);if(d.length===0)throw Error("earcut failed e.g. invalid polygon");for(let b=0;b<d.length;b++)s.push(d[b]+c)}let o=new Uint32Array(s.length);for(let a=0;a<s.length;a++)o[a]=s[a];return o}catch{return null}}function Wp(r,t,e){let n=t==="geoarrow.multipolygon",i=n?r.children[0]:r,s=i.valueOffsets,o=n?r.valueOffsets.map(st=>s.at(st)||st):r.valueOffsets,a=i.children[0],c=a.children[0],l=c.children[0],u=c.stride,h=a.valueOffsets,d=l.values,b=new Uint16Array(s.length);for(let st=0;st<s.length;st++)b[st]=h[s[st]];let M=d.length/u,z=new Uint32Array(M);for(let st=0;st<o.length-1;st++){let yn=h[o[st]],W=h[o[st+1]];for(let k=yn;k<W;k++)z[k]=st}let X=e?.triangulate?ac(b,h,d,u):null;return{featureIds:z,nDim:u,flatCoordinateArray:d,geomOffset:h,geometryIndicies:b,...e?.triangulate&&X?{triangles:X}:{}}}function Gp(r,t){let e=t==="geoarrow.multilinestring",n=e?r.children[0]:r,i=n.children[0],s=i.children[0],o=i.stride,a=n.valueOffsets,c=s.values,l=new Uint16Array(0),u=c.length/o,h=new Uint32Array(u);if(e){let d=r.valueOffsets;for(let b=0;b<d.length-1;b++){let M=a[d[b]],z=a[d[b+1]];for(let X=M;X<z;X++)h[X]=b}}else for(let d=0;d<r.length;d++){let b=a[d],M=a[d+1];for(let z=b;z<M;z++)h[z]=d}return{featureIds:h,flatCoordinateArray:c,nDim:o,geomOffset:a,geometryIndicies:l}}function $p(r,t){let e=t==="geoarrow.multipoint",n=e?r.children[0]:r,i=n.children[0],s=n.stride,o=i.values,a=new Uint16Array(0),c=new Int32Array(0),l=o.length/s,u=new Uint32Array(l);if(e){let h=r.valueOffsets;for(let d=0;d<h.length-1;d++){let b=h[d],M=h[d+1];for(let z=b;z<M;z++)u[z]=d}}else for(let h=0;h<r.length;h++)u[h]=h;return{featureIds:u,flatCoordinateArray:o,nDim:s,geomOffset:c,geometryIndicies:a}}var Go="4.3.0-alpha.6";var Wu=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,Gu=new RegExp("^"+Wu.source+"(\\s"+Wu.source+"){1,}"),cc=["POINT(","LINESTRING(","POLYGON(","MULTIPOINT(","MULTILINESTRING(","MULTIPOLYGON(","GEOMETRYCOLLECTION("];function $u(r){return cc.some(t=>r.startsWith(t))}function lc(r,t){return Hp(r,t)}function Hp(r,t){let e=r.split(";"),n=e.pop(),i=(e.shift()||"").split("=").pop(),o=Hu({parts:e,_:n,i:0});return t?.wkt?.crs?Yp(o,i):o}function Hu(r){return Kp(r)||Jp(r)||Qp(r)||Zp(r)||Xp(r)||qp(r)||tm(r)}function Yp(r,t){if(r&&t?.match(/\d+/)){let e={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+t}};r.crs=e}return r}function Kp(r){if(!ht(/^(POINT(\sz)?)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;let t=Yu(r);return!t||(Wt(r),!ht(/^(\))/,r))?null:{type:"Point",coordinates:t[0]}}function Zp(r){if(!ht(/^(MULTIPOINT)/i,r))return null;Wt(r);let t=r._?.substring(r._?.indexOf("(")+1,r._.length-1).replace(/\(/g,"").replace(/\)/g,"");r._="MULTIPOINT ("+t+")";let e=$o(r);return e?(Wt(r),{type:"MultiPoint",coordinates:e}):null}function Jp(r){if(!ht(/^(LINESTRING(\sz)?)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;let t=Yu(r);return!t||!ht(/^(\))/,r)?null:{type:"LineString",coordinates:t}}function Xp(r){if(!ht(/^(MULTILINESTRING)/i,r))return null;Wt(r);let t=$o(r);return t?(Wt(r),{type:"MultiLineString",coordinates:t}):null}function Qp(r){if(!ht(/^(POLYGON(\sz)?)/i,r))return null;Wt(r);let t=$o(r);return t?{type:"Polygon",coordinates:t}:null}function qp(r){if(!ht(/^(MULTIPOLYGON)/i,r))return null;Wt(r);let t=$o(r);return t?{type:"MultiPolygon",coordinates:t}:null}function tm(r){let t=[],e;if(!ht(/^(GEOMETRYCOLLECTION)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;for(;e=Hu(r);)t.push(e),Wt(r),ht(/^(,)/,r),Wt(r);return ht(/^(\))/,r)?{type:"GeometryCollection",geometries:t}:null}function $o(r){Wt(r);let t=0,e=[],n=[e],i=e,s;for(;s=ht(/^(\()/,r)||ht(/^(\))/,r)||ht(/^(,)/,r)||ht(Gu,r);){if(s==="(")n.push(i),i=[],n[n.length-1].push(i),t++;else if(s===")"){if(i.length===0||(i=n.pop(),!i))return null;if(t--,t===0)break}else if(s===",")i=[],n[n.length-1].push(i);else if(!s.split(/\s/g).some(isNaN))Array.prototype.push.apply(i,s.split(/\s/g).map(parseFloat));else return null;Wt(r)}return t!==0?null:e}function Yu(r){let t=[],e,n;for(;n=ht(Gu,r)||ht(/^(,)/,r);)n===","?(t.push(e),e=[]):n.split(/\s/g).some(isNaN)||(e||(e=[]),Array.prototype.push.apply(e,n.split(/\s/g).map(parseFloat))),Wt(r);if(e)t.push(e);else return null;return t.length?t:null}function ht(r,t){let e=t._?.substring(t.i).match(r);return e?(t.i+=e[0].length,e[0]):null}function Wt(r){ht(/^\s*/,r)}var Ku={dataType:null,batchType:null,name:"WKT (Well-Known Text)",id:"wkt",module:"wkt",version:Go,worker:!0,extensions:["wkt"],mimeTypes:["text/plain"],category:"geometry",text:!0,tests:cc,testText:$u,options:{wkt:{shape:"geojson-geometry",crs:!0}}},uc={...Ku,parse:async(r,t)=>lc(new TextDecoder().decode(r),t),parseTextSync:(r,t)=>lc(r,t)};var vr;(function(r){r[r.Point=1]="Point",r[r.LineString=2]="LineString",r[r.Polygon=3]="Polygon",r[r.MultiPoint=4]="MultiPoint",r[r.MultiLineString=5]="MultiLineString",r[r.MultiPolygon=6]="MultiPolygon",r[r.GeometryCollection=7]="GeometryCollection"})(vr||(vr={}));function Zu(r){let t=new DataView(r),e=0,n=t.getUint8(e);if(e+=1,n>1)return!1;let i=n===1,s=t.getUint32(e,i);e+=4;let o=s&7;if(o===0||o>7)return!1;let a=s-o;if(a===0||a===1e3||a===2e3||a===3e3)return!0;if(a&536870911)return!1;if(a&536870912){let c=t.getUint32(e,i);if(e+=4,c>1e4)return!1}return!0}function Ju(r,t){let e=Object.assign(t||{},{type:"wkb",geometryType:1,dimensions:2,coordinates:"xy",littleEndian:!0,byteOffset:0});e.littleEndian=r.getUint8(e.byteOffset)===1,e.byteOffset++;let n=r.getUint32(e.byteOffset,e.littleEndian);e.byteOffset+=4,e.geometryType=n&7;let i=(n-e.geometryType)/1e3;switch(i){case 0:break;case 1:e.type="iso-wkb",e.dimensions=3,e.coordinates="xyz";break;case 2:e.type="iso-wkb",e.dimensions=3,e.coordinates="xym";break;case 3:e.type="iso-wkb",e.dimensions=4,e.coordinates="xyzm";break;default:throw new Error(`WKB: Unsupported iso-wkb type: ${i}`)}let s=n&2147483648,o=n&1073741824,a=n&536870912;return s&&o?(e.type="ewkb",e.dimensions=4,e.coordinates="xyzm"):s?(e.type="ewkb",e.dimensions=3,e.coordinates="xyz"):o&&(e.type="ewkb",e.dimensions=3,e.coordinates="xym"),a&&(e.type="ewkb",e.srid=r.getUint32(e.byteOffset,e.littleEndian),e.byteOffset+=4),e}function fc(r,t){let e=em(r,t),n=t?.wkb?.shape||"binary-geometry";switch(n){case"binary-geometry":return e;case"geojson-geometry":return Hn(e);case"geometry":return console.error('WKBLoader: "geometry" shape is deprecated, use "binary-geometry" instead'),Hn(e);default:throw new Error(n)}}function em(r,t){let e=new DataView(r),n=Ju(e),{geometryType:i,dimensions:s,littleEndian:o}=n,a=n.byteOffset;switch(i){case vr.Point:return Xu(e,a,s,o).geometry;case vr.LineString:return hc(e,a,s,o).geometry;case vr.Polygon:return Qu(e,a,s,o).geometry;case vr.MultiPoint:let h=rm(e,a,s,o);return h.type="Point",h;case vr.MultiLineString:let d=nm(e,a,s,o);return d.type="LineString",d;case vr.MultiPolygon:let b=im(e,a,s,o);return b.type="Polygon",b;default:throw new Error(`WKB: Unsupported geometry type: ${i}`)}}function Xu(r,t,e,n){let i=new Float64Array(e);for(let s=0;s<e;s++)i[s]=r.getFloat64(t,n),t+=8;return{geometry:{type:"Point",positions:{value:i,size:e}},offset:t}}function hc(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=new Float64Array(i*e);for(let a=0;a<i*e;a++)s[a]=r.getFloat64(t,n),t+=8;let o=[0];return i>0&&o.push(i),{geometry:{type:"LineString",positions:{value:s,size:e},pathIndices:{value:new Uint32Array(o),size:1}},offset:t}}var dc=r=>t=>r+=t;function Qu(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let l=0;l<i;l++){let u=hc(r,t,e,n),{positions:h}=u.geometry;t=u.offset,s.push(h.value)}let o=new Float64Array(Ho(s).buffer),a=[0];o.length>0&&a.push(o.length/e);let c=s.map(l=>l.length/e).map(dc(0));return c.unshift(0),{geometry:{type:"Polygon",positions:{value:o,size:e},polygonIndices:{value:new Uint32Array(a),size:1},primitivePolygonIndices:{value:new Uint32Array(c),size:1}},offset:t}}function rm(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let o=0;o<i;o++){let a=r.getUint8(t)===1;if(t++,r.getUint32(t,a)%1e3!==1)throw new Error("WKB: Inner geometries of MultiPoint not of type Point");t+=4;let c=Xu(r,t,e,a);t=c.offset,s.push(c.geometry)}return sm(s,e)}function nm(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let o=0;o<i;o++){let a=r.getUint8(t)===1;if(t++,r.getUint32(t,a)%1e3!==2)throw new Error("WKB: Inner geometries of MultiLineString not of type LineString");t+=4;let c=hc(r,t,e,a);t=c.offset,s.push(c.geometry)}return om(s,e)}function im(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let o=0;o<i;o++){let a=r.getUint8(t)===1;if(t++,r.getUint32(t,a)%1e3!==3)throw new Error("WKB: Inner geometries of MultiPolygon not of type Polygon");t+=4;let c=Qu(r,t,e,a);t=c.offset,s.push(c.geometry)}return am(s,e)}function sm(r,t){let e=r.map(i=>i.positions.value);return{type:"Point",positions:{value:new Float64Array(Ho(e).buffer),size:t}}}function om(r,t){let e=r.map(s=>s.positions.value),n=new Float64Array(Ho(e).buffer),i=e.map(s=>s.length/t).map(dc(0));return i.unshift(0),{type:"LineString",positions:{value:n,size:t},pathIndices:{value:new Uint32Array(i),size:1}}}function am(r,t){let e=[],n=[];for(let a of r){let{positions:c,primitivePolygonIndices:l}=a;e.push(c.value),n.push(l.value)}let i=new Float64Array(Ho(e).buffer),s=e.map(a=>a.length/t).map(dc(0));s.unshift(0);let o=[0];for(let a of n)o.push(...a.filter(c=>c>0).map(c=>c+o[o.length-1]));return{type:"Polygon",positions:{value:i,size:t},polygonIndices:{value:new Uint32Array(s),size:1},primitivePolygonIndices:{value:new Uint32Array(o),size:1}}}function Ho(r){let t=0;for(let i=0;i<r.length;++i)t+=r[i].byteLength;let e=new Uint8Array(t),n=0;for(let i=0;i<r.length;++i){let s=new Uint8Array(r[i].buffer);t=s.length;for(let o=0;o<t;++o)e[n++]=s[o]}return e}var qu={dataType:null,batchType:null,name:"WKB",id:"wkb",module:"wkt",version:Go,worker:!0,category:"geometry",extensions:["wkb"],mimeTypes:[],tests:[Zu],options:{wkb:{shape:"binary-geometry"}}},pc={...qu,parse:async r=>fc(r),parseSync:fc};function zo(r,t){if(t=t?.toLowerCase(),!t||!r)return null;let e;switch(t){case"geoarrow.multipolygon":e=um(r);break;case"geoarrow.polygon":e=fm(r);break;case"geoarrow.multipoint":e=hm(r);break;case"geoarrow.point":e=dm(r);break;case"geoarrow.multilinestring":e=pm(r);break;case"geoarrow.linestring":e=mm(r);break;case"geoarrow.wkb":e=cm(r);break;case"geoarrow.wkt":e=lm(r);break;default:throw Error(`GeoArrow encoding not supported ${t}`)}return e}function cm(r){let t=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),e=pc.parseSync?.(t);return Hn(e)}function lm(r){let t=r;return uc.parseTextSync?.(t)}function um(r){let t=[];for(let n=0;n<r.length;n++){let i=r.get(n),s=[];for(let o=0;i&&o<i?.length;o++){let a=i?.get(o),c=[];for(let l=0;a&&l<a.length;l++){let u=a.get(l),h=Array.from(u);c.push(h)}s.push(c)}t.push(s)}return{type:"MultiPolygon",coordinates:t}}function fm(r){let t=[];for(let n=0;r&&n<r.length;n++){let i=r.get(n),s=[];for(let o=0;i&&o<i.length;o++){let a=i.get(o),c=Array.from(a);s.push(c)}t.push(s)}return{type:"Polygon",coordinates:t}}function hm(r){let t=[];for(let e=0;r&&e<r.length;e++){let n=r.get(e);if(n){let i=Array.from(n);t.push(i)}}return{type:"MultiPoint",coordinates:t}}function dm(r){return{type:"Point",coordinates:Array.from(r)}}function pm(r){let t=[];for(let e=0;r&&e<r.length;e++){let n=r.get(e),i=[];for(let s=0;n&&s<n.length;s++){let o=n.get(s);if(o){let a=Array.from(o);i.push(a)}}t.push(i)}return{type:"MultiLineString",coordinates:t}}function mm(r){let t=[];for(let e=0;r&&e<r.length;e++){let n=r.get(e);if(n){let i=Array.from(n);t.push(i)}}return{type:"LineString",coordinates:t}}function Ji(r,t=!1){if("data"in r)return new g(r.data.map(s=>Ji(s,t)));let e=[];for(let s of r.children)e.push(Ji(s,t));let n;r.dictionary!==void 0&&(n=Ji(r.dictionary,t));let i={[lt.OFFSET]:Yo(r.buffers[lt.OFFSET],t),[lt.DATA]:Yo(r.buffers[lt.DATA],t),[lt.VALIDITY]:Yo(r.buffers[lt.VALIDITY],t),[lt.TYPE]:Yo(r.buffers[lt.TYPE],t)};return new R(r.type,r.offset,r.length,r._nullCount,i,e,n)}function ym(r){return!(r.byteOffset===0&&r.byteLength===r.buffer.byteLength)}function Yo(r,t){return r===void 0||!t&&!ym(r)?r:r.slice()}var tf="latest";function gm(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.0-alpha.6"),globalThis._loadersgl_.version}var mc=gm();function sr(r,t){if(!r)throw new Error(t||"loaders.gl assertion failed.")}var or={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},cA=or.self||or.window||or.global||{},lA=or.window||or.self||or.global||{},uA=or.global||or.self||or.window||{},fA=or.document||{};var Ir=typeof process!="object"||String(process)!=="[object process]"||process.browser;var rf=typeof window<"u"&&typeof window.orientation<"u",ef=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),hA=ef&&parseFloat(ef[1])||0;var Xi=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(t,e){this.name=t,this.workerThread=e,this.result=new Promise((n,i)=>{this._resolve=n,this._reject=i})}postMessage(t,e){this.workerThread.postMessage({source:"loaders.gl",type:t,payload:e})}done(t){sr(this.isRunning),this.isRunning=!1,this._resolve(t)}error(t){sr(this.isRunning),this.isRunning=!1,this._reject(t)}};var Kn=class{terminate(){}};var yc=new Map;function nf(r){sr(r.source&&!r.url||!r.source&&r.url);let t=yc.get(r.source||r.url);return t||(r.url&&(t=bm(r.url),yc.set(r.url,t)),r.source&&(t=sf(r.source),yc.set(r.source,t))),sr(t),t}function bm(r){if(!r.startsWith("http"))return r;let t=wm(r);return sf(t)}function sf(r){let t=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(t)}function wm(r){return`try {
17
17
  importScripts('${r}');
18
18
  } catch (error) {
19
19
  console.error(error);
20
20
  throw error;
21
- }`}function gc(r,t=!0,e){let n=e||new Set;if(r){if(of(r))n.add(r);else if(of(r.buffer))n.add(r.buffer);else if(!ArrayBuffer.isView(r)){if(t&&typeof r=="object")for(let i in r)gc(r[i],t,n)}}return e===void 0?Array.from(n):[]}function of(r){return r?r instanceof ArrayBuffer||typeof MessagePort<"u"&&r instanceof MessagePort||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas:!1}function bc(r){if(r===null)return{};let t=Object.assign({},r);return Object.keys(t).forEach(e=>{typeof r[e]=="object"&&!ArrayBuffer.isView(r[e])&&!(r[e]instanceof Array)?t[e]=bc(r[e]):typeof t[e]=="function"||t[e]instanceof RegExp?t[e]={}:t[e]=r[e]}),t}var wc=()=>{},Ur=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&Ir||typeof Kn<"u"&&!Ir}constructor(t){let{name:e,source:n,url:i}=t;sr(n||i),this.name=e,this.source=n,this.url=i,this.onMessage=wc,this.onError=s=>console.log(s),this.worker=Ir?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=wc,this.onError=wc,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(t,e){e=e||gc(t),this.worker.postMessage(t,e)}_getErrorFromErrorEvent(t){let e="Failed to load ";return e+=`worker ${this.name} from ${this.url}. `,t.message&&(e+=`${t.message} in `),t.lineno&&(e+=`:${t.lineno}:${t.colno}`),new Error(e)}_createBrowserWorker(){this._loadableURL=nf({source:this.source,url:this.url});let t=new Worker(this._loadableURL,{name:this.name});return t.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},t.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},t.onmessageerror=e=>console.error(e),t}_createNodeWorker(){let t;if(this.url){let n=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;t=new Kn(n,{eval:!1})}else if(this.source)t=new Kn(this.source,{eval:!0});else throw new Error("no worker");return t.on("message",e=>{this.onMessage(e)}),t.on("error",e=>{this.onError(e)}),t.on("exit",e=>{}),t}};var Qi=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return Ur.isSupported()}constructor(t){this.source=t.source,this.url=t.url,this.setProps(t)}destroy(){this.idleQueue.forEach(t=>t.destroy()),this.isDestroyed=!0}setProps(t){this.props={...this.props,...t},t.name!==void 0&&(this.name=t.name),t.maxConcurrency!==void 0&&(this.maxConcurrency=t.maxConcurrency),t.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=t.maxMobileConcurrency),t.reuseWorkers!==void 0&&(this.reuseWorkers=t.reuseWorkers),t.onDebug!==void 0&&(this.onDebug=t.onDebug)}async startJob(t,e=(i,s,o)=>i.done(o),n=(i,s)=>i.error(s)){let i=new Promise(s=>(this.jobQueue.push({name:t,onMessage:e,onError:n,onStart:s}),this));return this._startQueuedJob(),await i}async _startQueuedJob(){if(!this.jobQueue.length)return;let t=this._getAvailableWorker();if(!t)return;let e=this.jobQueue.shift();if(e){this.onDebug({message:"Starting job",name:e.name,workerThread:t,backlog:this.jobQueue.length});let n=new Xi(e.name,t);t.onMessage=i=>e.onMessage(n,i.type,i.payload),t.onError=i=>e.onError(n,i),e.onStart(n);try{await n.result}catch(i){console.error(`Worker exception: ${i}`)}finally{this.returnWorkerToQueue(t)}}}returnWorkerToQueue(t){!Ir||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(t.destroy(),this.count--):this.idleQueue.push(t),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;let t=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new Ur({name:t,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return rf?this.maxMobileConcurrency:this.maxConcurrency}};var _m={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},mn=class{props;workerPools=new Map;static isSupported(){return Ur.isSupported()}static getWorkerFarm(t={}){return mn._workerFarm=mn._workerFarm||new mn({}),mn._workerFarm.setProps(t),mn._workerFarm}constructor(t){this.props={..._m},this.setProps(t),this.workerPools=new Map}destroy(){for(let t of this.workerPools.values())t.destroy();this.workerPools=new Map}setProps(t){this.props={...this.props,...t};for(let e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(t){let{name:e,source:n,url:i}=t,s=this.workerPools.get(e);return s||(s=new Qi({name:e,source:n,url:i}),s.setProps(this._getWorkerPoolProps()),this.workerPools.set(e,s)),s}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},Zn=mn;rs(Zn,"_workerFarm");function af(r){let t=r.version!==mc?` (worker-utils@${mc})`:"";return`${r.name}@${r.version}${t}`}function cf(r,t={}){let e=t[r.id]||{},n=Ir?`${r.id}-worker.js`:`${r.id}-worker-node.js`,i=e.workerUrl;if(!i&&r.id==="compression"&&(i=t.workerUrl),t._workerType==="test"&&(Ir?i=`modules/${r.module}/dist/${n}`:i=`modules/${r.module}/src/workers/${r.id}-worker-node.ts`),!i){let s=r.version;s==="latest"&&(s=tf);let o=s?`@${s}`:"";i=`https://unpkg.com/@loaders.gl/${r.module}${o}/dist/${n}`}return sr(i),i}async function Ko(r,t,e={},n={}){let i=af(r),s=Zn.getWorkerFarm(e),{source:o}=e,a={name:i,source:o};o||(a.url=cf(r,e));let c=s.getWorkerPool(a),l=e.jobName||r.name,u=await c.startJob(l,vm.bind(null,n)),h=bc(e);return u.postMessage("process",{input:t,options:h}),(await u.result).result}async function vm(r,t,e,n){switch(e){case"done":t.done(n);break;case"error":t.error(new Error(n.error));break;case"process":let{id:i,input:s,options:o}=n;try{if(!r.process){t.postMessage("error",{id:i,error:"Worker not set up to process on main thread"});return}let a=await r.process(s,o);t.postMessage("done",{id:i,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";t.postMessage("error",{id:i,error:c})}break;default:console.warn(`process-on-worker: unknown message ${e}`)}}var Im="4.3.0-alpha.5",Zo={id:"triangulation",name:"Triangulate",module:"arrow",version:Im,options:{}};function lf(r,t={}){return Ko(Zo,{...r,operation:"triangulate"},t)}function uf(r,t={}){return Ko(Zo,{...r,operation:"parse-geoarrow"},t)}gn.ArrowBatch=Mo;return wf(qi);})();
21
+ }`}function gc(r,t=!0,e){let n=e||new Set;if(r){if(of(r))n.add(r);else if(of(r.buffer))n.add(r.buffer);else if(!ArrayBuffer.isView(r)){if(t&&typeof r=="object")for(let i in r)gc(r[i],t,n)}}return e===void 0?Array.from(n):[]}function of(r){return r?r instanceof ArrayBuffer||typeof MessagePort<"u"&&r instanceof MessagePort||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas:!1}function bc(r){if(r===null)return{};let t=Object.assign({},r);return Object.keys(t).forEach(e=>{typeof r[e]=="object"&&!ArrayBuffer.isView(r[e])&&!(r[e]instanceof Array)?t[e]=bc(r[e]):typeof t[e]=="function"||t[e]instanceof RegExp?t[e]={}:t[e]=r[e]}),t}var wc=()=>{},Ur=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&Ir||typeof Kn<"u"&&!Ir}constructor(t){let{name:e,source:n,url:i}=t;sr(n||i),this.name=e,this.source=n,this.url=i,this.onMessage=wc,this.onError=s=>console.log(s),this.worker=Ir?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=wc,this.onError=wc,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(t,e){e=e||gc(t),this.worker.postMessage(t,e)}_getErrorFromErrorEvent(t){let e="Failed to load ";return e+=`worker ${this.name} from ${this.url}. `,t.message&&(e+=`${t.message} in `),t.lineno&&(e+=`:${t.lineno}:${t.colno}`),new Error(e)}_createBrowserWorker(){this._loadableURL=nf({source:this.source,url:this.url});let t=new Worker(this._loadableURL,{name:this.name});return t.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},t.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},t.onmessageerror=e=>console.error(e),t}_createNodeWorker(){let t;if(this.url){let n=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;t=new Kn(n,{eval:!1})}else if(this.source)t=new Kn(this.source,{eval:!0});else throw new Error("no worker");return t.on("message",e=>{this.onMessage(e)}),t.on("error",e=>{this.onError(e)}),t.on("exit",e=>{}),t}};var Qi=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return Ur.isSupported()}constructor(t){this.source=t.source,this.url=t.url,this.setProps(t)}destroy(){this.idleQueue.forEach(t=>t.destroy()),this.isDestroyed=!0}setProps(t){this.props={...this.props,...t},t.name!==void 0&&(this.name=t.name),t.maxConcurrency!==void 0&&(this.maxConcurrency=t.maxConcurrency),t.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=t.maxMobileConcurrency),t.reuseWorkers!==void 0&&(this.reuseWorkers=t.reuseWorkers),t.onDebug!==void 0&&(this.onDebug=t.onDebug)}async startJob(t,e=(i,s,o)=>i.done(o),n=(i,s)=>i.error(s)){let i=new Promise(s=>(this.jobQueue.push({name:t,onMessage:e,onError:n,onStart:s}),this));return this._startQueuedJob(),await i}async _startQueuedJob(){if(!this.jobQueue.length)return;let t=this._getAvailableWorker();if(!t)return;let e=this.jobQueue.shift();if(e){this.onDebug({message:"Starting job",name:e.name,workerThread:t,backlog:this.jobQueue.length});let n=new Xi(e.name,t);t.onMessage=i=>e.onMessage(n,i.type,i.payload),t.onError=i=>e.onError(n,i),e.onStart(n);try{await n.result}catch(i){console.error(`Worker exception: ${i}`)}finally{this.returnWorkerToQueue(t)}}}returnWorkerToQueue(t){!Ir||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(t.destroy(),this.count--):this.idleQueue.push(t),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;let t=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new Ur({name:t,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return rf?this.maxMobileConcurrency:this.maxConcurrency}};var _m={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},mn=class{props;workerPools=new Map;static isSupported(){return Ur.isSupported()}static getWorkerFarm(t={}){return mn._workerFarm=mn._workerFarm||new mn({}),mn._workerFarm.setProps(t),mn._workerFarm}constructor(t){this.props={..._m},this.setProps(t),this.workerPools=new Map}destroy(){for(let t of this.workerPools.values())t.destroy();this.workerPools=new Map}setProps(t){this.props={...this.props,...t};for(let e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(t){let{name:e,source:n,url:i}=t,s=this.workerPools.get(e);return s||(s=new Qi({name:e,source:n,url:i}),s.setProps(this._getWorkerPoolProps()),this.workerPools.set(e,s)),s}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},Zn=mn;rs(Zn,"_workerFarm");function af(r){let t=r.version!==mc?` (worker-utils@${mc})`:"";return`${r.name}@${r.version}${t}`}function cf(r,t={}){let e=t[r.id]||{},n=Ir?`${r.id}-worker.js`:`${r.id}-worker-node.js`,i=e.workerUrl;if(!i&&r.id==="compression"&&(i=t.workerUrl),t._workerType==="test"&&(Ir?i=`modules/${r.module}/dist/${n}`:i=`modules/${r.module}/src/workers/${r.id}-worker-node.ts`),!i){let s=r.version;s==="latest"&&(s=tf);let o=s?`@${s}`:"";i=`https://unpkg.com/@loaders.gl/${r.module}${o}/dist/${n}`}return sr(i),i}async function Ko(r,t,e={},n={}){let i=af(r),s=Zn.getWorkerFarm(e),{source:o}=e,a={name:i,source:o};o||(a.url=cf(r,e));let c=s.getWorkerPool(a),l=e.jobName||r.name,u=await c.startJob(l,vm.bind(null,n)),h=bc(e);return u.postMessage("process",{input:t,options:h}),(await u.result).result}async function vm(r,t,e,n){switch(e){case"done":t.done(n);break;case"error":t.error(new Error(n.error));break;case"process":let{id:i,input:s,options:o}=n;try{if(!r.process){t.postMessage("error",{id:i,error:"Worker not set up to process on main thread"});return}let a=await r.process(s,o);t.postMessage("done",{id:i,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";t.postMessage("error",{id:i,error:c})}break;default:console.warn(`process-on-worker: unknown message ${e}`)}}var Im="4.3.0-alpha.6",Zo={id:"triangulation",name:"Triangulate",module:"arrow",version:Im,options:{}};function lf(r,t={}){return Ko(Zo,{...r,operation:"triangulate"},t)}function uf(r,t={}){return Ko(Zo,{...r,operation:"parse-geoarrow"},t)}gn.ArrowBatch=Mo;return wf(qi);})();
22
22
  return __exports__;
23
23
  });
@@ -2,7 +2,7 @@
2
2
  import { encodeGeoArrowSync } from "./lib/encode-geoarrow.js";
3
3
  // __VERSION__ is injected by babel-plugin-version-inline
4
4
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
5
- const VERSION = typeof "4.3.0-alpha.5" !== 'undefined' ? "4.3.0-alpha.5" : 'latest';
5
+ const VERSION = typeof "4.3.0-alpha.6" !== 'undefined' ? "4.3.0-alpha.6" : 'latest';
6
6
  /** Apache Arrow writer */
7
7
  export const GeoArrowWriter = {
8
8
  name: 'Apache Arrow',
package/dist/index.cjs CHANGED
@@ -484,7 +484,7 @@ function parseArrowInBatches(asyncIterator, options) {
484
484
  }
485
485
 
486
486
  // dist/arrow-loader.js
487
- var VERSION = true ? "4.3.0-alpha.5" : "latest";
487
+ var VERSION = true ? "4.3.0-alpha.6" : "latest";
488
488
  var ArrowWorkerLoader = {
489
489
  dataType: null,
490
490
  batchType: null,
@@ -538,7 +538,7 @@ function createVector(array, type) {
538
538
  }
539
539
 
540
540
  // dist/arrow-writer.js
541
- var VERSION2 = true ? "4.3.0-alpha.5" : "latest";
541
+ var VERSION2 = true ? "4.3.0-alpha.6" : "latest";
542
542
  var ArrowWriter = {
543
543
  name: "Apache Arrow",
544
544
  id: "arrow",
@@ -1131,7 +1131,7 @@ function cloneBuffer(arr, force) {
1131
1131
 
1132
1132
  // dist/triangulate-on-worker.js
1133
1133
  var import_worker_utils = require("@loaders.gl/worker-utils");
1134
- var VERSION3 = true ? "4.3.0-alpha.5" : "latest";
1134
+ var VERSION3 = true ? "4.3.0-alpha.6" : "latest";
1135
1135
  var TriangulationWorker = {
1136
1136
  id: "triangulation",
1137
1137
  name: "Triangulate",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["index.js", "lib/arrow-table-batch.js", "schema/arrow-type-utils.js", "types.js", "parsers/parse-arrow-sync.js", "tables/convert-arrow-to-columnar-table.js", "schema/convert-arrow-schema.js", "parsers/parse-arrow-in-batches.js", "arrow-loader.js", "lib/encode-arrow.js", "arrow-writer.js", "tables/convert-arrow-to-geojson-table.js", "parsers/parse-geoarrow-sync.js", "parsers/parse-geoarrow-in-batches.js", "geoarrow-loader.js", "geoarrow/convert-geoarrow-to-binary-geometry.js", "geoarrow/get-arrow-bounds.js", "geoarrow/convert-geoarrow-to-geojson-geometry.js", "workers/hard-clone.js", "triangulate-on-worker.js"],
4
- "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { TableBatchBuilder } from '@loaders.gl/schema';\nimport { ArrowTableBatchAggregator } from \"./lib/arrow-table-batch.js\";\n// Make the ArrowBatch type available\nTableBatchBuilder.ArrowBatch = ArrowTableBatchAggregator;\n// TYPES\nexport { getArrowType } from \"./schema/arrow-type-utils.js\";\nexport { VECTOR_TYPES } from \"./types.js\";\nexport { ArrowLoader, ArrowWorkerLoader } from \"./arrow-loader.js\";\nexport { ArrowWriter } from \"./arrow-writer.js\";\n// Geoarrow loader\nexport { GeoArrowLoader, GeoArrowWorkerLoader } from \"./geoarrow-loader.js\";\n// Schema utils\nexport { serializeArrowSchema, deserializeArrowSchema, serializeArrowMetadata, deserializeArrowMetadata, serializeArrowField, deserializeArrowField, serializeArrowType, deserializeArrowType } from \"./schema/convert-arrow-schema.js\";\nexport { getBinaryGeometryTemplate, getBinaryGeometriesFromArrow, getTriangleIndices, getMeanCentersFromBinaryGeometries } from \"./geoarrow/convert-geoarrow-to-binary-geometry.js\";\nexport { updateBoundsFromGeoArrowSamples } from \"./geoarrow/get-arrow-bounds.js\";\nexport { parseGeometryFromArrow } from \"./geoarrow/convert-geoarrow-to-geojson-geometry.js\";\nexport { convertArrowToGeoJSONTable } from \"./tables/convert-arrow-to-geojson-table.js\";\n// EXPERIMENTAL WORKER\nexport { hardClone } from \"./workers/hard-clone.js\";\nexport { TriangulationWorker, triangulateOnWorker, parseGeoArrowOnWorker } from \"./triangulate-on-worker.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ColumnarTableBatchAggregator } from '@loaders.gl/schema';\nimport * as arrow from 'apache-arrow';\nexport class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {\n arrowSchema;\n constructor(schema, options) {\n super(schema, options);\n this.arrowSchema = null;\n }\n getBatch() {\n const batch = super.getBatch();\n if (batch) {\n // Get the arrow schema\n this.arrowSchema = this.arrowSchema || getArrowSchema(batch.schema);\n // Get arrow format vectors\n const arrowVectors = getArrowVectors(this.arrowSchema, batch.data);\n // Create the record batch\n const recordBatch = new arrow.RecordBatch(this.arrowSchema, arrow.makeData({\n type: new arrow.Struct(this.arrowSchema.fields),\n children: arrowVectors.map(({ data }) => data[0])\n }));\n return {\n shape: 'arrow-table',\n batchType: 'data',\n data: new arrow.Table([recordBatch]),\n length: batch.length\n };\n }\n return null;\n }\n}\n// Convert from a simple loaders.gl schema to an Arrow schema\nfunction getArrowSchema(schema) {\n const arrowFields = [];\n for (const key in schema) {\n const field = schema[key];\n if (field.type === Float32Array) {\n // TODO - just store the original field as metadata?\n const metadata = new Map(); // field;\n // arrow: new arrow.Field(name, nullable, metadata)\n const arrowField = new arrow.Field(field.name, new arrow.Float32(), field.nullable, metadata);\n arrowFields.push(arrowField);\n }\n }\n if (arrowFields.length === 0) {\n throw new Error('No arrow convertible fields');\n }\n return new arrow.Schema(arrowFields);\n}\n// Convert from simple loaders.gl arrays to arrow vectors\nfunction getArrowVectors(arrowSchema, data) {\n const arrowVectors = [];\n for (const field of arrowSchema.fields) {\n const vector = data[field.name];\n if (vector instanceof Float32Array) {\n const arrowVector = arrow.makeVector(vector);\n arrowVectors.push(arrowVector);\n }\n }\n if (arrowSchema.fields.length !== arrowVectors.length) {\n throw new Error('Some columns not arrow convertible');\n }\n return arrowVectors;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport * as arrow from 'apache-arrow';\n/** Return an Apache Arrow Type instance that corresponds to the type of the elements in the supplied Typed Array */\nexport function getArrowType(array) {\n switch (array.constructor) {\n case Int8Array:\n return new arrow.Int8();\n case Uint8Array:\n return new arrow.Uint8();\n case Int16Array:\n return new arrow.Int16();\n case Uint16Array:\n return new arrow.Uint16();\n case Int32Array:\n return new arrow.Int32();\n case Uint32Array:\n return new arrow.Uint32();\n case Float32Array:\n return new arrow.Float32();\n case Float64Array:\n return new arrow.Float64();\n default:\n throw new Error('array type not supported');\n }\n}\n/*\nexport function getArrowVector(array: TypedArray): AbstractVector {\n switch (array.constructor) {\n case Int8Array:\n return Int8Vector.from(array);\n case Uint8Array:\n return Uint8Vector.from(array);\n case Int16Array:\n return Int16Vector.from(array);\n case Uint16Array:\n return Uint16Vector.from(array);\n case Int32Array:\n return Int32Vector.from(array);\n case Uint32Array:\n return Uint32Vector.from(array);\n case Float32Array:\n return Float32Vector.from(array);\n case Float64Array:\n return Float64Vector.from(array);\n default:\n throw new Error('array type not supported');\n }\n}\n*/\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport var VECTOR_TYPES;\n(function (VECTOR_TYPES) {\n VECTOR_TYPES[VECTOR_TYPES[\"FLOAT\"] = 0] = \"FLOAT\";\n VECTOR_TYPES[VECTOR_TYPES[\"DATE\"] = 1] = \"DATE\";\n})(VECTOR_TYPES || (VECTOR_TYPES = {}));\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { convertTable } from '@loaders.gl/schema';\nimport * as arrow from 'apache-arrow';\nimport { convertArrowToColumnarTable } from \"../tables/convert-arrow-to-columnar-table.js\";\nimport { serializeArrowSchema } from \"../schema/convert-arrow-schema.js\";\n// Parses arrow to a columnar table\nexport function parseArrowSync(arrayBuffer, options) {\n const apacheArrowTable = arrow.tableFromIPC([new Uint8Array(arrayBuffer)]);\n const arrowTable = {\n shape: 'arrow-table',\n schema: serializeArrowSchema(apacheArrowTable.schema),\n data: apacheArrowTable\n };\n const shape = options?.shape || 'arrow-table';\n switch (shape) {\n case 'arrow-table':\n return arrowTable;\n case 'columnar-table':\n return convertArrowToColumnarTable(arrowTable);\n case 'object-row-table':\n let columnarTable = convertArrowToColumnarTable(arrowTable);\n return convertTable(columnarTable, 'object-row-table');\n case 'array-row-table':\n columnarTable = convertArrowToColumnarTable(arrowTable);\n return convertTable(columnarTable, 'array-row-table');\n default:\n // TODO\n throw new Error(shape);\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/**\n * Convert an Apache Arrow table to a ColumnarTable\n * @note Currently does not convert schema\n */\nexport function convertArrowToColumnarTable(table) {\n // TODO - avoid calling `getColumn` on columns we are not interested in?\n // Add options object?\n const arrowTable = table.data;\n const columnarTable = {};\n for (const field of arrowTable.schema.fields) {\n // This (is intended to) coalesce all record batches into a single typed array\n const arrowColumn = arrowTable.getChild(field.name);\n const values = arrowColumn?.toArray();\n columnarTable[field.name] = values;\n }\n return {\n shape: 'columnar-table',\n schema: table.schema,\n data: columnarTable\n };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport * as arrow from 'apache-arrow';\n/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */\nexport function serializeArrowSchema(arrowSchema) {\n return {\n fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),\n metadata: serializeArrowMetadata(arrowSchema.metadata)\n };\n}\n/** Convert a serialized Schema (plain data) to an Apache Arrow Schema (class instance) */\nexport function deserializeArrowSchema(schema) {\n return new arrow.Schema(schema.fields.map((field) => deserializeArrowField(field)), deserializeArrowMetadata(schema.metadata));\n}\n/** Convert Apache Arrow Schema metadata (Map<string, string>) to serialized metadata (Record<string, string> */\nexport function serializeArrowMetadata(arrowMetadata) {\n return Object.fromEntries(arrowMetadata);\n}\n/** Convert serialized metadata (Record<string, string> to Apache Arrow Schema metadata (Map<string, string>) to */\nexport function deserializeArrowMetadata(metadata) {\n return metadata ? new Map(Object.entries(metadata)) : new Map();\n}\n/** Convert Apache Arrow Field (class instance) to serialized Field (plain data) */\nexport function serializeArrowField(field) {\n return {\n name: field.name,\n type: serializeArrowType(field.type),\n nullable: field.nullable,\n metadata: serializeArrowMetadata(field.metadata)\n };\n}\n/** Convert a serialized Field (plain data) to an Apache Arrow Field (class instance)*/\nexport function deserializeArrowField(field) {\n return new arrow.Field(field.name, deserializeArrowType(field.type), field.nullable, deserializeArrowMetadata(field.metadata));\n}\n/** Converts a serializable loaders.gl data type to hydrated arrow data type */\n// eslint-disable-next-line complexity\nexport function serializeArrowType(arrowType) {\n switch (arrowType.constructor) {\n case arrow.Null:\n return 'null';\n case arrow.Binary:\n return 'binary';\n case arrow.Bool:\n return 'bool';\n case arrow.Int:\n const intType = arrowType;\n return `${intType.isSigned ? 'u' : ''}int${intType.bitWidth}`;\n case arrow.Int8:\n return 'int8';\n case arrow.Int16:\n return 'int16';\n case arrow.Int32:\n return 'int32';\n case arrow.Int64:\n return 'int64';\n case arrow.Uint8:\n return 'uint8';\n case arrow.Uint16:\n return 'uint16';\n case arrow.Uint32:\n return 'uint32';\n case arrow.Uint64:\n return 'uint64';\n case arrow.Float:\n const precision = arrowType.precision;\n // return `float(precision + 1) * 16`;\n switch (precision) {\n case arrow.Precision.HALF:\n return 'float16';\n case arrow.Precision.SINGLE:\n return 'float32';\n case arrow.Precision.DOUBLE:\n return 'float64';\n default:\n return 'float16';\n }\n case arrow.Float16:\n return 'float16';\n case arrow.Float32:\n return 'float32';\n case arrow.Float64:\n return 'float64';\n case arrow.Utf8:\n return 'utf8';\n case arrow.Decimal:\n const decimal = arrowType;\n return {\n type: 'decimal',\n bitWidth: decimal.bitWidth,\n precision: decimal.precision,\n scale: decimal.scale\n };\n case arrow.Date_:\n const dateUnit = arrowType.unit;\n return dateUnit === arrow.DateUnit.DAY ? 'date-day' : 'date-millisecond';\n case arrow.DateDay:\n return 'date-day';\n case arrow.DateMillisecond:\n return 'date-millisecond';\n case arrow.Time:\n const timeUnit = arrowType.unit;\n switch (timeUnit) {\n case arrow.TimeUnit.SECOND:\n return 'time-second';\n case arrow.TimeUnit.MILLISECOND:\n return 'time-millisecond';\n case arrow.TimeUnit.MICROSECOND:\n return 'time-microsecond';\n case arrow.TimeUnit.NANOSECOND:\n return 'time-nanosecond';\n default:\n return 'time-second';\n }\n case arrow.TimeMillisecond:\n return 'time-millisecond';\n case arrow.TimeSecond:\n return 'time-second';\n case arrow.TimeMicrosecond:\n return 'time-microsecond';\n case arrow.TimeNanosecond:\n return 'time-nanosecond';\n case arrow.Timestamp:\n const timeStampUnit = arrowType.unit;\n switch (timeStampUnit) {\n case arrow.TimeUnit.SECOND:\n return 'timestamp-second';\n case arrow.TimeUnit.MILLISECOND:\n return 'timestamp-millisecond';\n case arrow.TimeUnit.MICROSECOND:\n return 'timestamp-microsecond';\n case arrow.TimeUnit.NANOSECOND:\n return 'timestamp-nanosecond';\n default:\n return 'timestamp-second';\n }\n case arrow.TimestampSecond:\n return 'timestamp-second';\n case arrow.TimestampMillisecond:\n return 'timestamp-millisecond';\n case arrow.TimestampMicrosecond:\n return 'timestamp-microsecond';\n case arrow.TimestampNanosecond:\n return 'timestamp-nanosecond';\n case arrow.Interval:\n const intervalUnit = arrowType.unit;\n switch (intervalUnit) {\n case arrow.IntervalUnit.DAY_TIME:\n return 'interval-daytime';\n case arrow.IntervalUnit.YEAR_MONTH:\n return 'interval-yearmonth';\n default:\n return 'interval-daytime';\n }\n case arrow.IntervalDayTime:\n return 'interval-daytime';\n case arrow.IntervalYearMonth:\n return 'interval-yearmonth';\n case arrow.Map_:\n const mapType = arrowType;\n return {\n type: 'map',\n keysSorted: mapType.keysSorted,\n children: mapType.children.map((arrowField) => serializeArrowField(arrowField))\n };\n case arrow.List:\n const listType = arrowType;\n const listField = listType.valueField;\n return {\n type: 'list',\n children: [serializeArrowField(listField)]\n };\n case arrow.FixedSizeList:\n const fixedSizeList = arrowType;\n return {\n type: 'fixed-size-list',\n listSize: fixedSizeList.listSize,\n children: [serializeArrowField(fixedSizeList.children[0])]\n };\n case arrow.Struct:\n const structType = arrowType;\n return {\n type: 'struct',\n children: structType.children.map((arrowField) => serializeArrowField(arrowField))\n };\n default:\n throw new Error(`arrow type not supported: ${arrowType.constructor.name}`);\n }\n}\n/** Converts a serializable loaders.gl data type to hydrated arrow data type */\n// eslint-disable-next-line complexity\nexport function deserializeArrowType(dataType) {\n if (typeof dataType === 'object') {\n switch (dataType.type) {\n case 'decimal':\n return new arrow.Decimal(dataType.precision, dataType.scale, dataType.bitWidth);\n case 'map':\n let children = dataType.children.map((arrowField) => deserializeArrowField(arrowField));\n return new arrow.Map_(children, dataType.keysSorted);\n case 'list':\n const field = deserializeArrowField(dataType.children[0]);\n return new arrow.List(field);\n case 'fixed-size-list':\n const child = deserializeArrowField(dataType.children[0]);\n return new arrow.FixedSizeList(dataType.listSize, child);\n case 'struct':\n children = dataType.children.map((arrowField) => deserializeArrowField(arrowField));\n return new arrow.Struct(children);\n default:\n throw new Error('array type not supported');\n }\n }\n switch (dataType) {\n case 'null':\n return new arrow.Null();\n case 'binary':\n return new arrow.Binary();\n case 'bool':\n return new arrow.Bool();\n case 'int8':\n return new arrow.Int8();\n case 'int16':\n return new arrow.Int16();\n case 'int32':\n return new arrow.Int32();\n case 'int64':\n return new arrow.Int64();\n case 'uint8':\n return new arrow.Uint8();\n case 'uint16':\n return new arrow.Uint16();\n case 'uint32':\n return new arrow.Uint32();\n case 'uint64':\n return new arrow.Uint64();\n case 'float16':\n return new arrow.Float16();\n case 'float32':\n return new arrow.Float32();\n case 'float64':\n return new arrow.Float64();\n case 'utf8':\n return new arrow.Utf8();\n case 'date-day':\n return new arrow.DateDay();\n case 'date-millisecond':\n return new arrow.DateMillisecond();\n case 'time-second':\n return new arrow.TimeSecond();\n case 'time-millisecond':\n return new arrow.TimeMillisecond();\n case 'time-microsecond':\n return new arrow.TimeMicrosecond();\n case 'time-nanosecond':\n return new arrow.TimeNanosecond();\n case 'timestamp-second':\n return new arrow.TimestampSecond();\n case 'timestamp-millisecond':\n return new arrow.TimestampMillisecond();\n case 'timestamp-microsecond':\n return new arrow.TimestampMicrosecond();\n case 'timestamp-nanosecond':\n return new arrow.TimestampNanosecond();\n case 'interval-daytime':\n return new arrow.IntervalDayTime();\n case 'interval-yearmonth':\n return new arrow.IntervalYearMonth();\n default:\n throw new Error('array type not supported');\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport * as arrow from 'apache-arrow';\n// import {isIterable} from '@loaders.gl/core';\n/**\n */\nexport function parseArrowInBatches(asyncIterator, options) {\n // Creates the appropriate arrow.RecordBatchReader subclasses from the input\n // This will also close the underlying source in case of early termination or errors\n // As an optimization, return a non-async iterator\n /*\n if (isIterable(readers)) {\n function* makeArrowIterator() {\n for (const reader of readers) {\n for (const batch of reader) {\n yield processBatch(batch, reader);\n }\n break; // only processing one stream of batches\n }\n }\n const arrowIterator = makeArrowIterator();\n }\n */\n async function* makeArrowAsyncIterator() {\n // @ts-ignore\n const readers = arrow.RecordBatchReader.readAll(asyncIterator);\n for await (const reader of readers) {\n for await (const recordBatch of reader) {\n // use options.batchDebounceMs to add a delay between batches if needed (use case: incremental loading)\n if (options?.arrow?.batchDebounceMs !== undefined && options?.arrow?.batchDebounceMs > 0) {\n await new Promise((resolve) => setTimeout(resolve, options.arrow?.batchDebounceMs || 0));\n }\n const arrowTabledBatch = {\n shape: 'arrow-table',\n batchType: 'data',\n data: new arrow.Table([recordBatch]),\n length: recordBatch.data.length\n };\n // processBatch(recordBatch);\n yield arrowTabledBatch;\n }\n break; // only processing one stream of batches\n }\n }\n return makeArrowAsyncIterator(); // as AsyncIterator<ArrowTableBatch>;\n}\n// function processBatch(batch: RecordBatch): ArrowTableBatch {\n// const values = {};\n// batch.schema.fields.forEach(({name}, index) => {\n// values[name] = batch.getChildAt(index)?.toArray();\n// });\n// return {\n// };\n// }\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseArrowSync } from \"./parsers/parse-arrow-sync.js\";\nimport { parseArrowInBatches } from \"./parsers/parse-arrow-in-batches.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.5\" !== 'undefined' ? \"4.3.0-alpha.5\" : 'latest';\n/** ArrowJS table loader */\nexport const ArrowWorkerLoader = {\n dataType: null,\n batchType: null,\n name: 'Apache Arrow',\n id: 'arrow',\n module: 'arrow',\n version: VERSION,\n // worker: true,\n category: 'table',\n extensions: ['arrow', 'feather'],\n mimeTypes: [\n 'application/vnd.apache.arrow.file',\n 'application/vnd.apache.arrow.stream',\n 'application/octet-stream'\n ],\n binary: true,\n tests: ['ARROW'],\n options: {\n arrow: {\n shape: 'columnar-table'\n }\n }\n};\n/** ArrowJS table loader */\nexport const ArrowLoader = {\n ...ArrowWorkerLoader,\n parse: async (arraybuffer, options) => parseArrowSync(arraybuffer, options?.arrow),\n parseSync: (arraybuffer, options) => parseArrowSync(arraybuffer, options?.arrow),\n parseInBatches: parseArrowInBatches\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport * as arrow from 'apache-arrow';\nimport { VECTOR_TYPES } from \"../types.js\";\n/**\n * Encodes set of arrays into the Apache Arrow columnar format\n * https://arrow.apache.org/docs/format/Columnar.html#ipc-file-format\n * @param data - columns data\n * @param options - the writer options\n * @returns - encoded ArrayBuffer\n */\nexport function encodeArrowSync(data) {\n const vectors = {};\n for (const arrayData of data) {\n const arrayVector = createVector(arrayData.array, arrayData.type);\n vectors[arrayData.name] = arrayVector;\n }\n const table = new arrow.Table(vectors);\n const arrowBuffer = arrow.tableToIPC(table);\n return arrowBuffer;\n}\n/**\n * Create Arrow arrow.Vector from given data and vector type\n * @param array {import('../types').AnyArrayType} - columns data\n * @param type {number} - the writer options\n * @return a vector of one of vector's types defined in the Apache Arrow library\n */\nfunction createVector(array, type) {\n switch (type) {\n case VECTOR_TYPES.DATE:\n return arrow.vectorFromArray(array);\n case VECTOR_TYPES.FLOAT:\n default:\n return arrow.vectorFromArray(array);\n }\n}\n", "// import type {} from '@loaders.gl/loader-utils';\nimport { encodeArrowSync } from \"./lib/encode-arrow.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.5\" !== 'undefined' ? \"4.3.0-alpha.5\" : 'latest';\n/** Apache Arrow writer */\nexport const ArrowWriter = {\n name: 'Apache Arrow',\n id: 'arrow',\n module: 'arrow',\n version: VERSION,\n extensions: ['arrow', 'feather'],\n mimeTypes: [\n 'application/vnd.apache.arrow.file',\n 'application/vnd.apache.arrow.stream',\n 'application/octet-stream'\n ],\n binary: true,\n options: {},\n encode: async function encodeArrow(data, options) {\n return encodeArrowSync(data);\n },\n encodeSync(data, options) {\n return encodeArrowSync(data);\n }\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { serializeArrowSchema, parseGeometryFromArrow } from '@loaders.gl/arrow';\nimport { getGeometryColumnsFromSchema } from '@loaders.gl/gis';\n/**\n * Wrap an apache arrow table in a loaders.gl table wrapper.\n * From this additional conversions are available.\n * @param arrowTable\n * @returns\n */\nexport function convertApacheArrowToArrowTable(arrowTable) {\n return {\n shape: 'arrow-table',\n schema: serializeArrowSchema(arrowTable.schema),\n data: arrowTable\n };\n}\n/**\n * Convert an Apache Arrow table to a GeoJSONTable\n * @note Currently does not convert schema\n */\nexport function convertArrowToGeoJSONTable(table) {\n const arrowTable = table.data;\n const schema = serializeArrowSchema(arrowTable.schema);\n const geometryColumns = getGeometryColumnsFromSchema(schema);\n // get encoding from geometryColumns['geometry']\n const encoding = geometryColumns.geometry.encoding;\n const features = [];\n // Remove geometry columns\n const propertyColumnNames = arrowTable.schema.fields\n .map((field) => field.name)\n // TODO - this deletes all geometry columns\n .filter((name) => !(name in geometryColumns));\n const propertiesTable = arrowTable.select(propertyColumnNames);\n const arrowGeometryColumn = arrowTable.getChild('geometry');\n for (let row = 0; row < arrowTable.numRows; row++) {\n // get the geometry value from arrow geometry column\n // Note that type can vary\n const arrowGeometry = arrowGeometryColumn?.get(row);\n // parse arrow geometry to geojson feature\n const feature = parseGeometryFromArrow(arrowGeometry, encoding);\n if (feature) {\n const properties = propertiesTable.get(row)?.toJSON() || {};\n features.push({ type: 'Feature', geometry: feature, properties });\n }\n }\n return {\n shape: 'geojson-table',\n type: 'FeatureCollection',\n schema: table.schema,\n features\n };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseArrowSync } from \"./parse-arrow-sync.js\";\nimport { convertArrowToGeoJSONTable } from \"../tables/convert-arrow-to-geojson-table.js\";\n// Parses arrow to a columnar table\nexport function parseGeoArrowSync(arrayBuffer, options) {\n // | BinaryGeometry\n const table = parseArrowSync(arrayBuffer, { shape: 'arrow-table' });\n switch (options?.shape) {\n case 'geojson-table':\n return convertArrowToGeoJSONTable(table);\n default:\n return table;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseArrowInBatches } from \"./parse-arrow-in-batches.js\";\n/**\n */\nexport function parseGeoArrowInBatches(asyncIterator) {\n // | BinaryGeometry\n return parseArrowInBatches(asyncIterator);\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ArrowWorkerLoader } from \"./arrow-loader.js\";\nimport { parseGeoArrowSync } from \"./parsers/parse-geoarrow-sync.js\";\nimport { parseGeoArrowInBatches } from \"./parsers/parse-geoarrow-in-batches.js\";\n/** ArrowJS table loader */\nexport const GeoArrowWorkerLoader = {\n ...ArrowWorkerLoader,\n options: {\n arrow: {\n shape: 'arrow-table'\n }\n }\n};\n/**\n * GeoArrowLoader loads an Apache Arrow table, parses GeoArrow type extension data\n * to convert it to a GeoJSON table or a BinaryGeometry\n */\nexport const GeoArrowLoader = {\n ...GeoArrowWorkerLoader,\n parse: async (arraybuffer, options) => parseGeoArrowSync(arraybuffer, options?.arrow),\n parseSync: (arraybuffer, options) => parseGeoArrowSync(arraybuffer, options?.arrow),\n parseInBatches: parseGeoArrowInBatches\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { earcut } from '@math.gl/polygon';\nimport { updateBoundsFromGeoArrowSamples } from \"./get-arrow-bounds.js\";\n/**\n * Binary geometry type\n */\nvar BinaryGeometryType;\n(function (BinaryGeometryType) {\n BinaryGeometryType[\"points\"] = \"points\";\n BinaryGeometryType[\"lines\"] = \"lines\";\n BinaryGeometryType[\"polygons\"] = \"polygons\";\n})(BinaryGeometryType || (BinaryGeometryType = {}));\n/**\n * binary geometry template, see deck.gl BinaryGeometry\n */\nexport function getBinaryGeometryTemplate() {\n return {\n globalFeatureIds: { value: new Uint32Array(0), size: 1 },\n positions: { value: new Float32Array(0), size: 2 },\n properties: [],\n numericProps: {},\n featureIds: { value: new Uint32Array(0), size: 1 }\n };\n}\n/**\n * get binary geometries from geoarrow column\n *\n * @param geoColumn the geoarrow column, e.g. arrowTable.getChildAt(geoColumnIndex)\n * @param geoEncoding the geo encoding of the geoarrow column, e.g. getGeoArrowEncoding(arrowTable.schema, geoColumnName)\n * @param options options for getting binary geometries {meanCenter: boolean}\n * @returns BinaryDataFromGeoArrow\n */\nexport function getBinaryGeometriesFromArrow(geoColumn, geoEncoding, options) {\n const featureTypes = {\n polygon: geoEncoding === 'geoarrow.multipolygon' || geoEncoding === 'geoarrow.polygon',\n point: geoEncoding === 'geoarrow.multipoint' || geoEncoding === 'geoarrow.point',\n line: geoEncoding === 'geoarrow.multilinestring' || geoEncoding === 'geoarrow.linestring'\n };\n const chunks = options?.chunkIndex !== undefined && options?.chunkIndex >= 0\n ? [geoColumn.data[options?.chunkIndex]]\n : geoColumn.data;\n let bounds = [Infinity, Infinity, -Infinity, -Infinity];\n let globalFeatureIdOffset = options?.chunkOffset || 0;\n const binaryGeometries = [];\n chunks.forEach((chunk) => {\n const { featureIds, flatCoordinateArray, nDim, geomOffset, triangles } = getBinaryGeometriesFromChunk(chunk, geoEncoding, options);\n const globalFeatureIds = new Uint32Array(featureIds.length);\n for (let i = 0; i < featureIds.length; i++) {\n globalFeatureIds[i] = featureIds[i] + globalFeatureIdOffset;\n }\n const binaryContent = {\n globalFeatureIds: { value: globalFeatureIds, size: 1 },\n positions: {\n value: flatCoordinateArray,\n size: nDim\n },\n featureIds: { value: featureIds, size: 1 },\n // eslint-disable-next-line no-loop-func\n properties: [...Array(chunk.length).keys()].map((i) => ({\n index: i + globalFeatureIdOffset\n }))\n };\n // TODO: check if chunks are sequentially accessed\n globalFeatureIdOffset += chunk.length;\n // NOTE: deck.gl defines the BinaryFeatures structure must have points, lines, polygons even if they are empty\n binaryGeometries.push({\n shape: 'binary-feature-collection',\n points: {\n type: 'Point',\n ...getBinaryGeometryTemplate(),\n ...(featureTypes.point ? binaryContent : {})\n },\n lines: {\n type: 'LineString',\n ...getBinaryGeometryTemplate(),\n ...(featureTypes.line ? binaryContent : {}),\n pathIndices: { value: featureTypes.line ? geomOffset : new Uint16Array(0), size: 1 }\n },\n polygons: {\n type: 'Polygon',\n ...getBinaryGeometryTemplate(),\n ...(featureTypes.polygon ? binaryContent : {}),\n polygonIndices: {\n // use geomOffset as polygonIndices same as primitivePolygonIndices since we are using earcut to get triangule indices\n value: featureTypes.polygon ? geomOffset : new Uint16Array(0),\n size: 1\n },\n primitivePolygonIndices: {\n value: featureTypes.polygon ? geomOffset : new Uint16Array(0),\n size: 1\n },\n ...(triangles ? { triangles: { value: triangles, size: 1 } } : {})\n }\n });\n bounds = updateBoundsFromGeoArrowSamples(flatCoordinateArray, nDim, bounds);\n });\n return {\n binaryGeometries,\n bounds,\n featureTypes,\n ...(options?.calculateMeanCenters\n ? { meanCenters: getMeanCentersFromBinaryGeometries(binaryGeometries) }\n : {})\n };\n}\n/**\n * Get mean centers from binary geometries\n * @param binaryGeometries binary geometries from geoarrow column, an array of BinaryFeatureCollection\n * @returns mean centers of the binary geometries\n */\nexport function getMeanCentersFromBinaryGeometries(binaryGeometries) {\n const globalMeanCenters = [];\n binaryGeometries.forEach((binaryGeometry) => {\n let binaryGeometryType = null;\n if (binaryGeometry.points && binaryGeometry.points.positions.value.length > 0) {\n binaryGeometryType = BinaryGeometryType.points;\n }\n else if (binaryGeometry.lines && binaryGeometry.lines.positions.value.length > 0) {\n binaryGeometryType = BinaryGeometryType.lines;\n }\n else if (binaryGeometry.polygons && binaryGeometry.polygons.positions.value.length > 0) {\n binaryGeometryType = BinaryGeometryType.polygons;\n }\n const binaryContent = binaryGeometryType ? binaryGeometry[binaryGeometryType] : null;\n if (binaryContent && binaryGeometryType !== null) {\n const featureIds = binaryContent.featureIds.value;\n const flatCoordinateArray = binaryContent.positions.value;\n const nDim = binaryContent.positions.size;\n const primitivePolygonIndices = binaryContent.type === 'Polygon' ? binaryContent.primitivePolygonIndices?.value : undefined;\n const meanCenters = getMeanCentersFromGeometry(featureIds, flatCoordinateArray, nDim, binaryGeometryType, primitivePolygonIndices);\n meanCenters.forEach((center) => {\n globalMeanCenters.push(center);\n });\n }\n });\n return globalMeanCenters;\n}\n/**\n * Get mean centers from raw coordinates and feature ids\n * @param featureIds Array of feature ids indexes by vertex\n * @param flatCoordinateArray Array of vertex, e.g. x, y or x, y, z, positions\n * @param nDim number of dimensions per position\n * @returns - mean centers of each polygon\n */\nfunction getMeanCentersFromGeometry(featureIds, flatCoordinateArray, nDim, geometryType, primitivePolygonIndices) {\n const meanCenters = [];\n const vertexCount = flatCoordinateArray.length;\n let vertexIndex = 0;\n let coordIdx = 0;\n let primitiveIdx = 0;\n while (vertexIndex < vertexCount) {\n const featureId = featureIds[vertexIndex / nDim];\n const center = [0, 0];\n let vertexCountInFeature = 0;\n while (vertexIndex < vertexCount && featureIds[coordIdx] === featureId) {\n if (geometryType === BinaryGeometryType.polygons &&\n primitivePolygonIndices?.[primitiveIdx] === coordIdx) {\n // skip the first point since it is the same as the last point in each ring for polygons\n vertexIndex += nDim;\n primitiveIdx++;\n }\n else {\n center[0] += flatCoordinateArray[vertexIndex];\n center[1] += flatCoordinateArray[vertexIndex + 1];\n vertexIndex += nDim;\n vertexCountInFeature++;\n }\n coordIdx += 1;\n }\n center[0] /= vertexCountInFeature;\n center[1] /= vertexCountInFeature;\n meanCenters.push(center);\n }\n return meanCenters;\n}\n/**\n * get binary geometries from geoarrow column\n * @param chunk one chunk/batch of geoarrow column\n * @param geoEncoding geo encoding of the geoarrow column\n * @param options options for getting binary geometries\n * @returns BinaryGeometryContent\n */\nfunction getBinaryGeometriesFromChunk(chunk, geoEncoding, options) {\n switch (geoEncoding) {\n case 'geoarrow.point':\n case 'geoarrow.multipoint':\n return getBinaryPointsFromChunk(chunk, geoEncoding);\n case 'geoarrow.linestring':\n case 'geoarrow.multilinestring':\n return getBinaryLinesFromChunk(chunk, geoEncoding);\n case 'geoarrow.polygon':\n case 'geoarrow.multipolygon':\n return getBinaryPolygonsFromChunk(chunk, geoEncoding, options);\n default:\n throw Error('invalid geoarrow encoding');\n }\n}\n/**\n * get triangle indices. Allows deck.gl to skip performing costly triangulation on main thread.\n * @param polygonIndices Indices within positions of the start of each simple Polygon\n * @param primitivePolygonIndices Indices within positions of the start of each primitive Polygon/ring\n * @param flatCoordinateArray Array of x, y or x, y, z positions\n * @param nDim - number of dimensions per position\n * @returns triangle indices or null if invalid polygon and earcut fails\n */\nexport function getTriangleIndices(polygonIndices, primitivePolygonIndices, flatCoordinateArray, nDim) {\n try {\n let primitiveIndex = 0;\n const triangles = [];\n // loop polygonIndices to get triangles\n for (let i = 0; i < polygonIndices.length - 1; i++) {\n const startIdx = polygonIndices[i];\n const endIdx = polygonIndices[i + 1];\n // get subarray of flatCoordinateArray\n const slicedFlatCoords = flatCoordinateArray.subarray(startIdx * nDim, endIdx * nDim);\n // get holeIndices for earcut\n const holeIndices = [];\n while (primitivePolygonIndices[primitiveIndex] < endIdx) {\n if (primitivePolygonIndices[primitiveIndex] > startIdx) {\n holeIndices.push(primitivePolygonIndices[primitiveIndex] - startIdx);\n }\n primitiveIndex++;\n }\n // TODO check if each ring is closed\n const triangleIndices = earcut(slicedFlatCoords, holeIndices.length > 0 ? holeIndices : undefined, nDim);\n if (triangleIndices.length === 0) {\n throw Error('earcut failed e.g. invalid polygon');\n }\n for (let j = 0; j < triangleIndices.length; j++) {\n triangles.push(triangleIndices[j] + startIdx);\n }\n }\n // convert traingles to Uint32Array\n const trianglesUint32 = new Uint32Array(triangles.length);\n for (let i = 0; i < triangles.length; i++) {\n trianglesUint32[i] = triangles[i];\n }\n return trianglesUint32;\n }\n catch (error) {\n // if earcut fails, return null\n return null;\n }\n}\n/**\n * get binary polygons from geoarrow polygon column\n * @param chunk one chunk of geoarrow polygon column\n * @param geoEncoding the geo encoding of the geoarrow polygon column\n * @param options options for getting binary geometries\n * @returns BinaryGeometryContent\n */\nfunction getBinaryPolygonsFromChunk(chunk, geoEncoding, options) {\n const isMultiPolygon = geoEncoding === 'geoarrow.multipolygon';\n const polygonData = isMultiPolygon ? chunk.children[0] : chunk;\n const polygonOffset = polygonData.valueOffsets;\n const partData = isMultiPolygon\n ? chunk.valueOffsets.map((i) => polygonOffset.at(i) || i)\n : chunk.valueOffsets;\n const ringData = polygonData.children[0];\n const pointData = ringData.children[0];\n const coordData = pointData.children[0];\n const nDim = pointData.stride;\n const geomOffset = ringData.valueOffsets;\n const flatCoordinateArray = coordData.values;\n const geometryIndicies = new Uint16Array(polygonOffset.length);\n for (let i = 0; i < polygonOffset.length; i++) {\n geometryIndicies[i] = geomOffset[polygonOffset[i]];\n }\n const numOfVertices = flatCoordinateArray.length / nDim;\n const featureIds = new Uint32Array(numOfVertices);\n for (let i = 0; i < partData.length - 1; i++) {\n const startIdx = geomOffset[partData[i]];\n const endIdx = geomOffset[partData[i + 1]];\n for (let j = startIdx; j < endIdx; j++) {\n featureIds[j] = i;\n }\n }\n const triangles = options?.triangulate\n ? getTriangleIndices(geometryIndicies, geomOffset, flatCoordinateArray, nDim)\n : null;\n return {\n featureIds,\n nDim,\n flatCoordinateArray,\n geomOffset,\n geometryIndicies,\n ...(options?.triangulate && triangles ? { triangles } : {})\n };\n}\n/**\n * get binary lines from geoarrow line column\n * @param chunk one chunk/batch of geoarrow column\n * @param geoEncoding the geo encoding of the geoarrow column\n * @returns BinaryGeometryContent\n */\nfunction getBinaryLinesFromChunk(chunk, geoEncoding) {\n const isMultiLineString = geoEncoding === 'geoarrow.multilinestring';\n const lineData = isMultiLineString ? chunk.children[0] : chunk;\n const pointData = lineData.children[0];\n const coordData = pointData.children[0];\n const nDim = pointData.stride;\n const geomOffset = lineData.valueOffsets;\n const flatCoordinateArray = coordData.values;\n // geometryIndicies is not needed for line string\n const geometryIndicies = new Uint16Array(0);\n const numOfVertices = flatCoordinateArray.length / nDim;\n const featureIds = new Uint32Array(numOfVertices);\n if (isMultiLineString) {\n const partData = chunk.valueOffsets;\n for (let i = 0; i < partData.length - 1; i++) {\n const startIdx = geomOffset[partData[i]];\n const endIdx = geomOffset[partData[i + 1]];\n for (let j = startIdx; j < endIdx; j++) {\n featureIds[j] = i;\n }\n }\n }\n else {\n for (let i = 0; i < chunk.length; i++) {\n const startIdx = geomOffset[i];\n const endIdx = geomOffset[i + 1];\n for (let j = startIdx; j < endIdx; j++) {\n featureIds[j] = i;\n }\n }\n }\n return {\n featureIds,\n flatCoordinateArray,\n nDim,\n geomOffset,\n geometryIndicies\n };\n}\n/**\n * get binary points from geoarrow point column\n * @param chunk one chunk/batch of geoarrow column\n * @param geoEncoding geo encoding of the geoarrow column\n * @returns BinaryGeometryContent\n */\nfunction getBinaryPointsFromChunk(chunk, geoEncoding) {\n const isMultiPoint = geoEncoding === 'geoarrow.multipoint';\n const pointData = isMultiPoint ? chunk.children[0] : chunk;\n const coordData = pointData.children[0];\n const nDim = pointData.stride;\n const flatCoordinateArray = coordData.values;\n // geometryIndices is not needed for point\n const geometryIndicies = new Uint16Array(0);\n // geomOffset is not needed for point\n const geomOffset = new Int32Array(0);\n const numOfVertices = flatCoordinateArray.length / nDim;\n const featureIds = new Uint32Array(numOfVertices);\n if (isMultiPoint) {\n const partData = chunk.valueOffsets;\n for (let i = 0; i < partData.length - 1; i++) {\n const startIdx = partData[i];\n const endIdx = partData[i + 1];\n for (let j = startIdx; j < endIdx; j++) {\n featureIds[j] = i;\n }\n }\n }\n else {\n for (let i = 0; i < chunk.length; i++) {\n featureIds[i] = i;\n }\n }\n return {\n featureIds,\n flatCoordinateArray,\n nDim,\n geomOffset,\n geometryIndicies\n };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/**\n * Update bounds from geoarrow sample data\n *\n * @param flatCoords the flattend coordinates array from one chunk of geoarrow column\n * @param nDim the number of dimensions of the coordinates\n * @param bounds the bounds to be updated\n * @param sampleSize how many samples to be used to update the bounds, default is 1000 per chunk\n * @returns the updated bounds\n */\nexport function updateBoundsFromGeoArrowSamples(flatCoords, nDim, bounds, sampleSize = 100) {\n const numberOfFeatures = flatCoords.length / nDim;\n const sampleStep = Math.max(Math.floor(numberOfFeatures / sampleSize), 1);\n const newBounds = [...bounds];\n for (let i = 0; i < numberOfFeatures; i += sampleStep) {\n const lng = flatCoords[i * nDim];\n const lat = flatCoords[i * nDim + 1];\n if (lng < newBounds[0]) {\n newBounds[0] = lng;\n }\n if (lat < newBounds[1]) {\n newBounds[1] = lat;\n }\n if (lng > newBounds[2]) {\n newBounds[2] = lng;\n }\n if (lat > newBounds[3]) {\n newBounds[3] = lat;\n }\n }\n return newBounds;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { binaryToGeometry } from '@loaders.gl/gis';\nimport { WKBLoader, WKTLoader } from '@loaders.gl/wkt';\n/**\n * parse geometry from arrow data that is returned from processArrowData()\n * NOTE: this function could be deduplicated with the binaryToFeature() in deck.gl,\n * it is currently used for deck.gl picking because currently deck.gl returns only the index of the feature\n *\n * @param data data extraced from arrow vector representing a geometry\n * @param encoding the geoarrow encoding of the geometry column\n * @returns Feature or null\n */\nexport function parseGeometryFromArrow(arrowCellValue, encoding) {\n // sanity\n encoding = encoding?.toLowerCase();\n if (!encoding || !arrowCellValue) {\n return null;\n }\n let geometry;\n switch (encoding) {\n case 'geoarrow.multipolygon':\n geometry = arrowMultiPolygonToFeature(arrowCellValue);\n break;\n case 'geoarrow.polygon':\n geometry = arrowPolygonToFeature(arrowCellValue);\n break;\n case 'geoarrow.multipoint':\n geometry = arrowMultiPointToFeature(arrowCellValue);\n break;\n case 'geoarrow.point':\n geometry = arrowPointToFeature(arrowCellValue);\n break;\n case 'geoarrow.multilinestring':\n geometry = arrowMultiLineStringToFeature(arrowCellValue);\n break;\n case 'geoarrow.linestring':\n geometry = arrowLineStringToFeature(arrowCellValue);\n break;\n case 'geoarrow.wkb':\n geometry = arrowWKBToFeature(arrowCellValue);\n break;\n case 'geoarrow.wkt':\n geometry = arrowWKTToFeature(arrowCellValue);\n break;\n default: {\n throw Error(`GeoArrow encoding not supported ${encoding}`);\n }\n }\n return geometry;\n}\nfunction arrowWKBToFeature(arrowCellValue) {\n // The actual WKB array buffer starts from byteOffset and ends at byteOffset + byteLength\n const arrayBuffer = arrowCellValue.buffer.slice(arrowCellValue.byteOffset, arrowCellValue.byteOffset + arrowCellValue.byteLength);\n const binaryGeometry = WKBLoader.parseSync?.(arrayBuffer);\n const geometry = binaryToGeometry(binaryGeometry);\n return geometry;\n}\nfunction arrowWKTToFeature(arrowCellValue) {\n const string = arrowCellValue;\n return WKTLoader.parseTextSync?.(string);\n}\n/**\n * convert Arrow MultiPolygon to geojson Feature\n */\nfunction arrowMultiPolygonToFeature(arrowMultiPolygon) {\n const multiPolygon = [];\n for (let m = 0; m < arrowMultiPolygon.length; m++) {\n const arrowPolygon = arrowMultiPolygon.get(m);\n const polygon = [];\n for (let i = 0; arrowPolygon && i < arrowPolygon?.length; i++) {\n const arrowRing = arrowPolygon?.get(i);\n const ring = [];\n for (let j = 0; arrowRing && j < arrowRing.length; j++) {\n const arrowCoord = arrowRing.get(j);\n const coord = Array.from(arrowCoord);\n ring.push(coord);\n }\n polygon.push(ring);\n }\n multiPolygon.push(polygon);\n }\n const geometry = {\n type: 'MultiPolygon',\n coordinates: multiPolygon\n };\n return geometry;\n}\n/**\n * convert Arrow Polygon to geojson Feature\n */\nfunction arrowPolygonToFeature(arrowPolygon) {\n const polygon = [];\n for (let i = 0; arrowPolygon && i < arrowPolygon.length; i++) {\n const arrowRing = arrowPolygon.get(i);\n const ring = [];\n for (let j = 0; arrowRing && j < arrowRing.length; j++) {\n const arrowCoord = arrowRing.get(j);\n const coords = Array.from(arrowCoord);\n ring.push(coords);\n }\n polygon.push(ring);\n }\n const geometry = {\n type: 'Polygon',\n coordinates: polygon\n };\n return geometry;\n}\n/**\n * convert Arrow MultiPoint to geojson MultiPoint\n */\nfunction arrowMultiPointToFeature(arrowMultiPoint) {\n const multiPoint = [];\n for (let i = 0; arrowMultiPoint && i < arrowMultiPoint.length; i++) {\n const arrowPoint = arrowMultiPoint.get(i);\n if (arrowPoint) {\n const coord = Array.from(arrowPoint);\n multiPoint.push(coord);\n }\n }\n return {\n type: 'MultiPoint',\n coordinates: multiPoint\n };\n}\n/**\n * convert Arrow Point to geojson Point\n */\nfunction arrowPointToFeature(arrowPoint) {\n const point = Array.from(arrowPoint);\n return {\n type: 'Point',\n coordinates: point\n };\n}\n/**\n * convert Arrow MultiLineString to geojson MultiLineString\n */\nfunction arrowMultiLineStringToFeature(arrowMultiLineString) {\n const multiLineString = [];\n for (let i = 0; arrowMultiLineString && i < arrowMultiLineString.length; i++) {\n const arrowLineString = arrowMultiLineString.get(i);\n const lineString = [];\n for (let j = 0; arrowLineString && j < arrowLineString.length; j++) {\n const arrowCoord = arrowLineString.get(j);\n if (arrowCoord) {\n const coords = Array.from(arrowCoord);\n lineString.push(coords);\n }\n }\n multiLineString.push(lineString);\n }\n return {\n type: 'MultiLineString',\n coordinates: multiLineString\n };\n}\n/**\n * convert Arrow LineString to geojson LineString\n */\nfunction arrowLineStringToFeature(arrowLineString) {\n const lineString = [];\n for (let i = 0; arrowLineString && i < arrowLineString.length; i++) {\n const arrowCoord = arrowLineString.get(i);\n if (arrowCoord) {\n const coords = Array.from(arrowCoord);\n lineString.push(coords);\n }\n }\n return {\n type: 'LineString',\n coordinates: lineString\n };\n}\n", "import * as arrow from 'apache-arrow';\nexport function hardClone(data, force = false) {\n // Check if `data` is an arrow.Vector\n if ('data' in data) {\n return new arrow.Vector(data.data.map((data) => hardClone(data, force)));\n }\n // Clone each of the children, recursively\n const clonedChildren = [];\n for (const childData of data.children) {\n clonedChildren.push(hardClone(childData, force));\n }\n // Clone the dictionary if there is one\n let clonedDictionary;\n if (data.dictionary !== undefined) {\n clonedDictionary = hardClone(data.dictionary, force);\n }\n // Buffers can have up to four entries. Each of these can be `undefined` for\n // one or more array types.\n //\n // - OFFSET: value offsets for variable size list types\n // - DATA: the underlying data\n // - VALIDITY: the null buffer. This may be empty or undefined if all elements\n // are non-null/valid.\n // - TYPE: type ids for a union type.\n const clonedBuffers = {\n [arrow.BufferType.OFFSET]: cloneBuffer(data.buffers[arrow.BufferType.OFFSET], force),\n [arrow.BufferType.DATA]: cloneBuffer(data.buffers[arrow.BufferType.DATA], force),\n [arrow.BufferType.VALIDITY]: cloneBuffer(data.buffers[arrow.BufferType.VALIDITY], force),\n [arrow.BufferType.TYPE]: cloneBuffer(data.buffers[arrow.BufferType.TYPE], force)\n };\n // Note: the data.offset is passed on so that a sliced Data instance will not\n // be \"un-sliced\". However keep in mind that this means we're cloning the\n // _original backing buffer_, not only the portion of the Data that was\n // sliced.\n return new arrow.Data(data.type, data.offset, data.length, \n // @ts-expect-error _nullCount is protected. We're using it here to mimic\n // `Data.clone`\n data._nullCount, clonedBuffers, clonedChildren, clonedDictionary);\n}\n/**\n * Test whether an arrow.Data instance is a slice of a larger `ArrayBuffer`.\n */\nexport function isShared(data) {\n // Loop over arrow.Vector\n if ('data' in data) {\n return data.data.some((data) => isShared(data));\n }\n // Check child data\n for (const childData of data.children) {\n if (isShared(childData)) {\n return true;\n }\n }\n // Check dictionary\n if (data.dictionary !== undefined) {\n if (isShared(data.dictionary)) {\n return true;\n }\n }\n const bufferTypes = [\n arrow.BufferType.OFFSET,\n arrow.BufferType.DATA,\n arrow.BufferType.VALIDITY,\n arrow.BufferType.TYPE\n ];\n for (const bufferType of bufferTypes) {\n if (data.buffers[bufferType] !== undefined && isTypedArraySliced(data.buffers[bufferType])) {\n return true;\n }\n }\n return false;\n}\n/**\n * Returns true if the current typed array is a partial slice on a larger\n * ArrayBuffer\n */\nfunction isTypedArraySliced(arr) {\n return !(arr.byteOffset === 0 && arr.byteLength === arr.buffer.byteLength);\n}\n/**\n * If a slice of a larger ArrayBuffer, clone to a fresh `ArrayBuffer`.\n *\n * If `force` is `true`, always clone the array, even if not shared.\n */\nfunction cloneBuffer(arr, force) {\n // Not all buffer types are defined for every type of Arrow array. E.g.\n // `arrow.BufferType.TYPE` is only defined for the Union type.\n if (arr === undefined) {\n return arr;\n }\n // The current array is not a part of a larger ArrayBuffer, don't clone it\n if (!force && !isTypedArraySliced(arr)) {\n return arr;\n }\n // Note: TypedArray.slice() **copies** into a new ArrayBuffer\n // @ts-expect-error 'Uint8Array' is assignable to the constraint of type 'A',\n // but 'A' could be instantiated with a different subtype of constraint\n // 'TypedArray'\n // We know from arr.slice that it will always return the same\n return arr.slice();\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { processOnWorker } from '@loaders.gl/worker-utils';\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.5\" !== 'undefined' ? \"4.3.0-alpha.5\" : 'latest';\n/**\n * Worker for tessellating geometries. Normally called through triangulateOnWorker\n */\nexport const TriangulationWorker = {\n id: 'triangulation',\n name: 'Triangulate',\n module: 'arrow',\n version: VERSION,\n options: {}\n};\n/**\n * Triangulate a set of polygons on worker, type safe API\n */\nexport function triangulateOnWorker(data, options = {}) {\n return processOnWorker(TriangulationWorker, { ...data, operation: 'triangulate' }, options);\n}\n/**\n * Parse GeoArrow geometry colum on worker, type safe API\n */\nexport function parseGeoArrowOnWorker(data, options = {}) {\n return processOnWorker(TriangulationWorker, { ...data, operation: 'parse-geoarrow' }, options);\n}\n"],
4
+ "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { TableBatchBuilder } from '@loaders.gl/schema';\nimport { ArrowTableBatchAggregator } from \"./lib/arrow-table-batch.js\";\n// Make the ArrowBatch type available\nTableBatchBuilder.ArrowBatch = ArrowTableBatchAggregator;\n// TYPES\nexport { getArrowType } from \"./schema/arrow-type-utils.js\";\nexport { VECTOR_TYPES } from \"./types.js\";\nexport { ArrowLoader, ArrowWorkerLoader } from \"./arrow-loader.js\";\nexport { ArrowWriter } from \"./arrow-writer.js\";\n// Geoarrow loader\nexport { GeoArrowLoader, GeoArrowWorkerLoader } from \"./geoarrow-loader.js\";\n// Schema utils\nexport { serializeArrowSchema, deserializeArrowSchema, serializeArrowMetadata, deserializeArrowMetadata, serializeArrowField, deserializeArrowField, serializeArrowType, deserializeArrowType } from \"./schema/convert-arrow-schema.js\";\nexport { getBinaryGeometryTemplate, getBinaryGeometriesFromArrow, getTriangleIndices, getMeanCentersFromBinaryGeometries } from \"./geoarrow/convert-geoarrow-to-binary-geometry.js\";\nexport { updateBoundsFromGeoArrowSamples } from \"./geoarrow/get-arrow-bounds.js\";\nexport { parseGeometryFromArrow } from \"./geoarrow/convert-geoarrow-to-geojson-geometry.js\";\nexport { convertArrowToGeoJSONTable } from \"./tables/convert-arrow-to-geojson-table.js\";\n// EXPERIMENTAL WORKER\nexport { hardClone } from \"./workers/hard-clone.js\";\nexport { TriangulationWorker, triangulateOnWorker, parseGeoArrowOnWorker } from \"./triangulate-on-worker.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ColumnarTableBatchAggregator } from '@loaders.gl/schema';\nimport * as arrow from 'apache-arrow';\nexport class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {\n arrowSchema;\n constructor(schema, options) {\n super(schema, options);\n this.arrowSchema = null;\n }\n getBatch() {\n const batch = super.getBatch();\n if (batch) {\n // Get the arrow schema\n this.arrowSchema = this.arrowSchema || getArrowSchema(batch.schema);\n // Get arrow format vectors\n const arrowVectors = getArrowVectors(this.arrowSchema, batch.data);\n // Create the record batch\n const recordBatch = new arrow.RecordBatch(this.arrowSchema, arrow.makeData({\n type: new arrow.Struct(this.arrowSchema.fields),\n children: arrowVectors.map(({ data }) => data[0])\n }));\n return {\n shape: 'arrow-table',\n batchType: 'data',\n data: new arrow.Table([recordBatch]),\n length: batch.length\n };\n }\n return null;\n }\n}\n// Convert from a simple loaders.gl schema to an Arrow schema\nfunction getArrowSchema(schema) {\n const arrowFields = [];\n for (const key in schema) {\n const field = schema[key];\n if (field.type === Float32Array) {\n // TODO - just store the original field as metadata?\n const metadata = new Map(); // field;\n // arrow: new arrow.Field(name, nullable, metadata)\n const arrowField = new arrow.Field(field.name, new arrow.Float32(), field.nullable, metadata);\n arrowFields.push(arrowField);\n }\n }\n if (arrowFields.length === 0) {\n throw new Error('No arrow convertible fields');\n }\n return new arrow.Schema(arrowFields);\n}\n// Convert from simple loaders.gl arrays to arrow vectors\nfunction getArrowVectors(arrowSchema, data) {\n const arrowVectors = [];\n for (const field of arrowSchema.fields) {\n const vector = data[field.name];\n if (vector instanceof Float32Array) {\n const arrowVector = arrow.makeVector(vector);\n arrowVectors.push(arrowVector);\n }\n }\n if (arrowSchema.fields.length !== arrowVectors.length) {\n throw new Error('Some columns not arrow convertible');\n }\n return arrowVectors;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport * as arrow from 'apache-arrow';\n/** Return an Apache Arrow Type instance that corresponds to the type of the elements in the supplied Typed Array */\nexport function getArrowType(array) {\n switch (array.constructor) {\n case Int8Array:\n return new arrow.Int8();\n case Uint8Array:\n return new arrow.Uint8();\n case Int16Array:\n return new arrow.Int16();\n case Uint16Array:\n return new arrow.Uint16();\n case Int32Array:\n return new arrow.Int32();\n case Uint32Array:\n return new arrow.Uint32();\n case Float32Array:\n return new arrow.Float32();\n case Float64Array:\n return new arrow.Float64();\n default:\n throw new Error('array type not supported');\n }\n}\n/*\nexport function getArrowVector(array: TypedArray): AbstractVector {\n switch (array.constructor) {\n case Int8Array:\n return Int8Vector.from(array);\n case Uint8Array:\n return Uint8Vector.from(array);\n case Int16Array:\n return Int16Vector.from(array);\n case Uint16Array:\n return Uint16Vector.from(array);\n case Int32Array:\n return Int32Vector.from(array);\n case Uint32Array:\n return Uint32Vector.from(array);\n case Float32Array:\n return Float32Vector.from(array);\n case Float64Array:\n return Float64Vector.from(array);\n default:\n throw new Error('array type not supported');\n }\n}\n*/\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport var VECTOR_TYPES;\n(function (VECTOR_TYPES) {\n VECTOR_TYPES[VECTOR_TYPES[\"FLOAT\"] = 0] = \"FLOAT\";\n VECTOR_TYPES[VECTOR_TYPES[\"DATE\"] = 1] = \"DATE\";\n})(VECTOR_TYPES || (VECTOR_TYPES = {}));\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { convertTable } from '@loaders.gl/schema';\nimport * as arrow from 'apache-arrow';\nimport { convertArrowToColumnarTable } from \"../tables/convert-arrow-to-columnar-table.js\";\nimport { serializeArrowSchema } from \"../schema/convert-arrow-schema.js\";\n// Parses arrow to a columnar table\nexport function parseArrowSync(arrayBuffer, options) {\n const apacheArrowTable = arrow.tableFromIPC([new Uint8Array(arrayBuffer)]);\n const arrowTable = {\n shape: 'arrow-table',\n schema: serializeArrowSchema(apacheArrowTable.schema),\n data: apacheArrowTable\n };\n const shape = options?.shape || 'arrow-table';\n switch (shape) {\n case 'arrow-table':\n return arrowTable;\n case 'columnar-table':\n return convertArrowToColumnarTable(arrowTable);\n case 'object-row-table':\n let columnarTable = convertArrowToColumnarTable(arrowTable);\n return convertTable(columnarTable, 'object-row-table');\n case 'array-row-table':\n columnarTable = convertArrowToColumnarTable(arrowTable);\n return convertTable(columnarTable, 'array-row-table');\n default:\n // TODO\n throw new Error(shape);\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/**\n * Convert an Apache Arrow table to a ColumnarTable\n * @note Currently does not convert schema\n */\nexport function convertArrowToColumnarTable(table) {\n // TODO - avoid calling `getColumn` on columns we are not interested in?\n // Add options object?\n const arrowTable = table.data;\n const columnarTable = {};\n for (const field of arrowTable.schema.fields) {\n // This (is intended to) coalesce all record batches into a single typed array\n const arrowColumn = arrowTable.getChild(field.name);\n const values = arrowColumn?.toArray();\n columnarTable[field.name] = values;\n }\n return {\n shape: 'columnar-table',\n schema: table.schema,\n data: columnarTable\n };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport * as arrow from 'apache-arrow';\n/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */\nexport function serializeArrowSchema(arrowSchema) {\n return {\n fields: arrowSchema.fields.map((arrowField) => serializeArrowField(arrowField)),\n metadata: serializeArrowMetadata(arrowSchema.metadata)\n };\n}\n/** Convert a serialized Schema (plain data) to an Apache Arrow Schema (class instance) */\nexport function deserializeArrowSchema(schema) {\n return new arrow.Schema(schema.fields.map((field) => deserializeArrowField(field)), deserializeArrowMetadata(schema.metadata));\n}\n/** Convert Apache Arrow Schema metadata (Map<string, string>) to serialized metadata (Record<string, string> */\nexport function serializeArrowMetadata(arrowMetadata) {\n return Object.fromEntries(arrowMetadata);\n}\n/** Convert serialized metadata (Record<string, string> to Apache Arrow Schema metadata (Map<string, string>) to */\nexport function deserializeArrowMetadata(metadata) {\n return metadata ? new Map(Object.entries(metadata)) : new Map();\n}\n/** Convert Apache Arrow Field (class instance) to serialized Field (plain data) */\nexport function serializeArrowField(field) {\n return {\n name: field.name,\n type: serializeArrowType(field.type),\n nullable: field.nullable,\n metadata: serializeArrowMetadata(field.metadata)\n };\n}\n/** Convert a serialized Field (plain data) to an Apache Arrow Field (class instance)*/\nexport function deserializeArrowField(field) {\n return new arrow.Field(field.name, deserializeArrowType(field.type), field.nullable, deserializeArrowMetadata(field.metadata));\n}\n/** Converts a serializable loaders.gl data type to hydrated arrow data type */\n// eslint-disable-next-line complexity\nexport function serializeArrowType(arrowType) {\n switch (arrowType.constructor) {\n case arrow.Null:\n return 'null';\n case arrow.Binary:\n return 'binary';\n case arrow.Bool:\n return 'bool';\n case arrow.Int:\n const intType = arrowType;\n return `${intType.isSigned ? 'u' : ''}int${intType.bitWidth}`;\n case arrow.Int8:\n return 'int8';\n case arrow.Int16:\n return 'int16';\n case arrow.Int32:\n return 'int32';\n case arrow.Int64:\n return 'int64';\n case arrow.Uint8:\n return 'uint8';\n case arrow.Uint16:\n return 'uint16';\n case arrow.Uint32:\n return 'uint32';\n case arrow.Uint64:\n return 'uint64';\n case arrow.Float:\n const precision = arrowType.precision;\n // return `float(precision + 1) * 16`;\n switch (precision) {\n case arrow.Precision.HALF:\n return 'float16';\n case arrow.Precision.SINGLE:\n return 'float32';\n case arrow.Precision.DOUBLE:\n return 'float64';\n default:\n return 'float16';\n }\n case arrow.Float16:\n return 'float16';\n case arrow.Float32:\n return 'float32';\n case arrow.Float64:\n return 'float64';\n case arrow.Utf8:\n return 'utf8';\n case arrow.Decimal:\n const decimal = arrowType;\n return {\n type: 'decimal',\n bitWidth: decimal.bitWidth,\n precision: decimal.precision,\n scale: decimal.scale\n };\n case arrow.Date_:\n const dateUnit = arrowType.unit;\n return dateUnit === arrow.DateUnit.DAY ? 'date-day' : 'date-millisecond';\n case arrow.DateDay:\n return 'date-day';\n case arrow.DateMillisecond:\n return 'date-millisecond';\n case arrow.Time:\n const timeUnit = arrowType.unit;\n switch (timeUnit) {\n case arrow.TimeUnit.SECOND:\n return 'time-second';\n case arrow.TimeUnit.MILLISECOND:\n return 'time-millisecond';\n case arrow.TimeUnit.MICROSECOND:\n return 'time-microsecond';\n case arrow.TimeUnit.NANOSECOND:\n return 'time-nanosecond';\n default:\n return 'time-second';\n }\n case arrow.TimeMillisecond:\n return 'time-millisecond';\n case arrow.TimeSecond:\n return 'time-second';\n case arrow.TimeMicrosecond:\n return 'time-microsecond';\n case arrow.TimeNanosecond:\n return 'time-nanosecond';\n case arrow.Timestamp:\n const timeStampUnit = arrowType.unit;\n switch (timeStampUnit) {\n case arrow.TimeUnit.SECOND:\n return 'timestamp-second';\n case arrow.TimeUnit.MILLISECOND:\n return 'timestamp-millisecond';\n case arrow.TimeUnit.MICROSECOND:\n return 'timestamp-microsecond';\n case arrow.TimeUnit.NANOSECOND:\n return 'timestamp-nanosecond';\n default:\n return 'timestamp-second';\n }\n case arrow.TimestampSecond:\n return 'timestamp-second';\n case arrow.TimestampMillisecond:\n return 'timestamp-millisecond';\n case arrow.TimestampMicrosecond:\n return 'timestamp-microsecond';\n case arrow.TimestampNanosecond:\n return 'timestamp-nanosecond';\n case arrow.Interval:\n const intervalUnit = arrowType.unit;\n switch (intervalUnit) {\n case arrow.IntervalUnit.DAY_TIME:\n return 'interval-daytime';\n case arrow.IntervalUnit.YEAR_MONTH:\n return 'interval-yearmonth';\n default:\n return 'interval-daytime';\n }\n case arrow.IntervalDayTime:\n return 'interval-daytime';\n case arrow.IntervalYearMonth:\n return 'interval-yearmonth';\n case arrow.Map_:\n const mapType = arrowType;\n return {\n type: 'map',\n keysSorted: mapType.keysSorted,\n children: mapType.children.map((arrowField) => serializeArrowField(arrowField))\n };\n case arrow.List:\n const listType = arrowType;\n const listField = listType.valueField;\n return {\n type: 'list',\n children: [serializeArrowField(listField)]\n };\n case arrow.FixedSizeList:\n const fixedSizeList = arrowType;\n return {\n type: 'fixed-size-list',\n listSize: fixedSizeList.listSize,\n children: [serializeArrowField(fixedSizeList.children[0])]\n };\n case arrow.Struct:\n const structType = arrowType;\n return {\n type: 'struct',\n children: structType.children.map((arrowField) => serializeArrowField(arrowField))\n };\n default:\n throw new Error(`arrow type not supported: ${arrowType.constructor.name}`);\n }\n}\n/** Converts a serializable loaders.gl data type to hydrated arrow data type */\n// eslint-disable-next-line complexity\nexport function deserializeArrowType(dataType) {\n if (typeof dataType === 'object') {\n switch (dataType.type) {\n case 'decimal':\n return new arrow.Decimal(dataType.precision, dataType.scale, dataType.bitWidth);\n case 'map':\n let children = dataType.children.map((arrowField) => deserializeArrowField(arrowField));\n return new arrow.Map_(children, dataType.keysSorted);\n case 'list':\n const field = deserializeArrowField(dataType.children[0]);\n return new arrow.List(field);\n case 'fixed-size-list':\n const child = deserializeArrowField(dataType.children[0]);\n return new arrow.FixedSizeList(dataType.listSize, child);\n case 'struct':\n children = dataType.children.map((arrowField) => deserializeArrowField(arrowField));\n return new arrow.Struct(children);\n default:\n throw new Error('array type not supported');\n }\n }\n switch (dataType) {\n case 'null':\n return new arrow.Null();\n case 'binary':\n return new arrow.Binary();\n case 'bool':\n return new arrow.Bool();\n case 'int8':\n return new arrow.Int8();\n case 'int16':\n return new arrow.Int16();\n case 'int32':\n return new arrow.Int32();\n case 'int64':\n return new arrow.Int64();\n case 'uint8':\n return new arrow.Uint8();\n case 'uint16':\n return new arrow.Uint16();\n case 'uint32':\n return new arrow.Uint32();\n case 'uint64':\n return new arrow.Uint64();\n case 'float16':\n return new arrow.Float16();\n case 'float32':\n return new arrow.Float32();\n case 'float64':\n return new arrow.Float64();\n case 'utf8':\n return new arrow.Utf8();\n case 'date-day':\n return new arrow.DateDay();\n case 'date-millisecond':\n return new arrow.DateMillisecond();\n case 'time-second':\n return new arrow.TimeSecond();\n case 'time-millisecond':\n return new arrow.TimeMillisecond();\n case 'time-microsecond':\n return new arrow.TimeMicrosecond();\n case 'time-nanosecond':\n return new arrow.TimeNanosecond();\n case 'timestamp-second':\n return new arrow.TimestampSecond();\n case 'timestamp-millisecond':\n return new arrow.TimestampMillisecond();\n case 'timestamp-microsecond':\n return new arrow.TimestampMicrosecond();\n case 'timestamp-nanosecond':\n return new arrow.TimestampNanosecond();\n case 'interval-daytime':\n return new arrow.IntervalDayTime();\n case 'interval-yearmonth':\n return new arrow.IntervalYearMonth();\n default:\n throw new Error('array type not supported');\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport * as arrow from 'apache-arrow';\n// import {isIterable} from '@loaders.gl/core';\n/**\n */\nexport function parseArrowInBatches(asyncIterator, options) {\n // Creates the appropriate arrow.RecordBatchReader subclasses from the input\n // This will also close the underlying source in case of early termination or errors\n // As an optimization, return a non-async iterator\n /*\n if (isIterable(readers)) {\n function* makeArrowIterator() {\n for (const reader of readers) {\n for (const batch of reader) {\n yield processBatch(batch, reader);\n }\n break; // only processing one stream of batches\n }\n }\n const arrowIterator = makeArrowIterator();\n }\n */\n async function* makeArrowAsyncIterator() {\n // @ts-ignore\n const readers = arrow.RecordBatchReader.readAll(asyncIterator);\n for await (const reader of readers) {\n for await (const recordBatch of reader) {\n // use options.batchDebounceMs to add a delay between batches if needed (use case: incremental loading)\n if (options?.arrow?.batchDebounceMs !== undefined && options?.arrow?.batchDebounceMs > 0) {\n await new Promise((resolve) => setTimeout(resolve, options.arrow?.batchDebounceMs || 0));\n }\n const arrowTabledBatch = {\n shape: 'arrow-table',\n batchType: 'data',\n data: new arrow.Table([recordBatch]),\n length: recordBatch.data.length\n };\n // processBatch(recordBatch);\n yield arrowTabledBatch;\n }\n break; // only processing one stream of batches\n }\n }\n return makeArrowAsyncIterator(); // as AsyncIterator<ArrowTableBatch>;\n}\n// function processBatch(batch: RecordBatch): ArrowTableBatch {\n// const values = {};\n// batch.schema.fields.forEach(({name}, index) => {\n// values[name] = batch.getChildAt(index)?.toArray();\n// });\n// return {\n// };\n// }\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseArrowSync } from \"./parsers/parse-arrow-sync.js\";\nimport { parseArrowInBatches } from \"./parsers/parse-arrow-in-batches.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.6\" !== 'undefined' ? \"4.3.0-alpha.6\" : 'latest';\n/** ArrowJS table loader */\nexport const ArrowWorkerLoader = {\n dataType: null,\n batchType: null,\n name: 'Apache Arrow',\n id: 'arrow',\n module: 'arrow',\n version: VERSION,\n // worker: true,\n category: 'table',\n extensions: ['arrow', 'feather'],\n mimeTypes: [\n 'application/vnd.apache.arrow.file',\n 'application/vnd.apache.arrow.stream',\n 'application/octet-stream'\n ],\n binary: true,\n tests: ['ARROW'],\n options: {\n arrow: {\n shape: 'columnar-table'\n }\n }\n};\n/** ArrowJS table loader */\nexport const ArrowLoader = {\n ...ArrowWorkerLoader,\n parse: async (arraybuffer, options) => parseArrowSync(arraybuffer, options?.arrow),\n parseSync: (arraybuffer, options) => parseArrowSync(arraybuffer, options?.arrow),\n parseInBatches: parseArrowInBatches\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport * as arrow from 'apache-arrow';\nimport { VECTOR_TYPES } from \"../types.js\";\n/**\n * Encodes set of arrays into the Apache Arrow columnar format\n * https://arrow.apache.org/docs/format/Columnar.html#ipc-file-format\n * @param data - columns data\n * @param options - the writer options\n * @returns - encoded ArrayBuffer\n */\nexport function encodeArrowSync(data) {\n const vectors = {};\n for (const arrayData of data) {\n const arrayVector = createVector(arrayData.array, arrayData.type);\n vectors[arrayData.name] = arrayVector;\n }\n const table = new arrow.Table(vectors);\n const arrowBuffer = arrow.tableToIPC(table);\n return arrowBuffer;\n}\n/**\n * Create Arrow arrow.Vector from given data and vector type\n * @param array {import('../types').AnyArrayType} - columns data\n * @param type {number} - the writer options\n * @return a vector of one of vector's types defined in the Apache Arrow library\n */\nfunction createVector(array, type) {\n switch (type) {\n case VECTOR_TYPES.DATE:\n return arrow.vectorFromArray(array);\n case VECTOR_TYPES.FLOAT:\n default:\n return arrow.vectorFromArray(array);\n }\n}\n", "// import type {} from '@loaders.gl/loader-utils';\nimport { encodeArrowSync } from \"./lib/encode-arrow.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.6\" !== 'undefined' ? \"4.3.0-alpha.6\" : 'latest';\n/** Apache Arrow writer */\nexport const ArrowWriter = {\n name: 'Apache Arrow',\n id: 'arrow',\n module: 'arrow',\n version: VERSION,\n extensions: ['arrow', 'feather'],\n mimeTypes: [\n 'application/vnd.apache.arrow.file',\n 'application/vnd.apache.arrow.stream',\n 'application/octet-stream'\n ],\n binary: true,\n options: {},\n encode: async function encodeArrow(data, options) {\n return encodeArrowSync(data);\n },\n encodeSync(data, options) {\n return encodeArrowSync(data);\n }\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { serializeArrowSchema, parseGeometryFromArrow } from '@loaders.gl/arrow';\nimport { getGeometryColumnsFromSchema } from '@loaders.gl/gis';\n/**\n * Wrap an apache arrow table in a loaders.gl table wrapper.\n * From this additional conversions are available.\n * @param arrowTable\n * @returns\n */\nexport function convertApacheArrowToArrowTable(arrowTable) {\n return {\n shape: 'arrow-table',\n schema: serializeArrowSchema(arrowTable.schema),\n data: arrowTable\n };\n}\n/**\n * Convert an Apache Arrow table to a GeoJSONTable\n * @note Currently does not convert schema\n */\nexport function convertArrowToGeoJSONTable(table) {\n const arrowTable = table.data;\n const schema = serializeArrowSchema(arrowTable.schema);\n const geometryColumns = getGeometryColumnsFromSchema(schema);\n // get encoding from geometryColumns['geometry']\n const encoding = geometryColumns.geometry.encoding;\n const features = [];\n // Remove geometry columns\n const propertyColumnNames = arrowTable.schema.fields\n .map((field) => field.name)\n // TODO - this deletes all geometry columns\n .filter((name) => !(name in geometryColumns));\n const propertiesTable = arrowTable.select(propertyColumnNames);\n const arrowGeometryColumn = arrowTable.getChild('geometry');\n for (let row = 0; row < arrowTable.numRows; row++) {\n // get the geometry value from arrow geometry column\n // Note that type can vary\n const arrowGeometry = arrowGeometryColumn?.get(row);\n // parse arrow geometry to geojson feature\n const feature = parseGeometryFromArrow(arrowGeometry, encoding);\n if (feature) {\n const properties = propertiesTable.get(row)?.toJSON() || {};\n features.push({ type: 'Feature', geometry: feature, properties });\n }\n }\n return {\n shape: 'geojson-table',\n type: 'FeatureCollection',\n schema: table.schema,\n features\n };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseArrowSync } from \"./parse-arrow-sync.js\";\nimport { convertArrowToGeoJSONTable } from \"../tables/convert-arrow-to-geojson-table.js\";\n// Parses arrow to a columnar table\nexport function parseGeoArrowSync(arrayBuffer, options) {\n // | BinaryGeometry\n const table = parseArrowSync(arrayBuffer, { shape: 'arrow-table' });\n switch (options?.shape) {\n case 'geojson-table':\n return convertArrowToGeoJSONTable(table);\n default:\n return table;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseArrowInBatches } from \"./parse-arrow-in-batches.js\";\n/**\n */\nexport function parseGeoArrowInBatches(asyncIterator) {\n // | BinaryGeometry\n return parseArrowInBatches(asyncIterator);\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { ArrowWorkerLoader } from \"./arrow-loader.js\";\nimport { parseGeoArrowSync } from \"./parsers/parse-geoarrow-sync.js\";\nimport { parseGeoArrowInBatches } from \"./parsers/parse-geoarrow-in-batches.js\";\n/** ArrowJS table loader */\nexport const GeoArrowWorkerLoader = {\n ...ArrowWorkerLoader,\n options: {\n arrow: {\n shape: 'arrow-table'\n }\n }\n};\n/**\n * GeoArrowLoader loads an Apache Arrow table, parses GeoArrow type extension data\n * to convert it to a GeoJSON table or a BinaryGeometry\n */\nexport const GeoArrowLoader = {\n ...GeoArrowWorkerLoader,\n parse: async (arraybuffer, options) => parseGeoArrowSync(arraybuffer, options?.arrow),\n parseSync: (arraybuffer, options) => parseGeoArrowSync(arraybuffer, options?.arrow),\n parseInBatches: parseGeoArrowInBatches\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { earcut } from '@math.gl/polygon';\nimport { updateBoundsFromGeoArrowSamples } from \"./get-arrow-bounds.js\";\n/**\n * Binary geometry type\n */\nvar BinaryGeometryType;\n(function (BinaryGeometryType) {\n BinaryGeometryType[\"points\"] = \"points\";\n BinaryGeometryType[\"lines\"] = \"lines\";\n BinaryGeometryType[\"polygons\"] = \"polygons\";\n})(BinaryGeometryType || (BinaryGeometryType = {}));\n/**\n * binary geometry template, see deck.gl BinaryGeometry\n */\nexport function getBinaryGeometryTemplate() {\n return {\n globalFeatureIds: { value: new Uint32Array(0), size: 1 },\n positions: { value: new Float32Array(0), size: 2 },\n properties: [],\n numericProps: {},\n featureIds: { value: new Uint32Array(0), size: 1 }\n };\n}\n/**\n * get binary geometries from geoarrow column\n *\n * @param geoColumn the geoarrow column, e.g. arrowTable.getChildAt(geoColumnIndex)\n * @param geoEncoding the geo encoding of the geoarrow column, e.g. getGeoArrowEncoding(arrowTable.schema, geoColumnName)\n * @param options options for getting binary geometries {meanCenter: boolean}\n * @returns BinaryDataFromGeoArrow\n */\nexport function getBinaryGeometriesFromArrow(geoColumn, geoEncoding, options) {\n const featureTypes = {\n polygon: geoEncoding === 'geoarrow.multipolygon' || geoEncoding === 'geoarrow.polygon',\n point: geoEncoding === 'geoarrow.multipoint' || geoEncoding === 'geoarrow.point',\n line: geoEncoding === 'geoarrow.multilinestring' || geoEncoding === 'geoarrow.linestring'\n };\n const chunks = options?.chunkIndex !== undefined && options?.chunkIndex >= 0\n ? [geoColumn.data[options?.chunkIndex]]\n : geoColumn.data;\n let bounds = [Infinity, Infinity, -Infinity, -Infinity];\n let globalFeatureIdOffset = options?.chunkOffset || 0;\n const binaryGeometries = [];\n chunks.forEach((chunk) => {\n const { featureIds, flatCoordinateArray, nDim, geomOffset, triangles } = getBinaryGeometriesFromChunk(chunk, geoEncoding, options);\n const globalFeatureIds = new Uint32Array(featureIds.length);\n for (let i = 0; i < featureIds.length; i++) {\n globalFeatureIds[i] = featureIds[i] + globalFeatureIdOffset;\n }\n const binaryContent = {\n globalFeatureIds: { value: globalFeatureIds, size: 1 },\n positions: {\n value: flatCoordinateArray,\n size: nDim\n },\n featureIds: { value: featureIds, size: 1 },\n // eslint-disable-next-line no-loop-func\n properties: [...Array(chunk.length).keys()].map((i) => ({\n index: i + globalFeatureIdOffset\n }))\n };\n // TODO: check if chunks are sequentially accessed\n globalFeatureIdOffset += chunk.length;\n // NOTE: deck.gl defines the BinaryFeatures structure must have points, lines, polygons even if they are empty\n binaryGeometries.push({\n shape: 'binary-feature-collection',\n points: {\n type: 'Point',\n ...getBinaryGeometryTemplate(),\n ...(featureTypes.point ? binaryContent : {})\n },\n lines: {\n type: 'LineString',\n ...getBinaryGeometryTemplate(),\n ...(featureTypes.line ? binaryContent : {}),\n pathIndices: { value: featureTypes.line ? geomOffset : new Uint16Array(0), size: 1 }\n },\n polygons: {\n type: 'Polygon',\n ...getBinaryGeometryTemplate(),\n ...(featureTypes.polygon ? binaryContent : {}),\n polygonIndices: {\n // use geomOffset as polygonIndices same as primitivePolygonIndices since we are using earcut to get triangule indices\n value: featureTypes.polygon ? geomOffset : new Uint16Array(0),\n size: 1\n },\n primitivePolygonIndices: {\n value: featureTypes.polygon ? geomOffset : new Uint16Array(0),\n size: 1\n },\n ...(triangles ? { triangles: { value: triangles, size: 1 } } : {})\n }\n });\n bounds = updateBoundsFromGeoArrowSamples(flatCoordinateArray, nDim, bounds);\n });\n return {\n binaryGeometries,\n bounds,\n featureTypes,\n ...(options?.calculateMeanCenters\n ? { meanCenters: getMeanCentersFromBinaryGeometries(binaryGeometries) }\n : {})\n };\n}\n/**\n * Get mean centers from binary geometries\n * @param binaryGeometries binary geometries from geoarrow column, an array of BinaryFeatureCollection\n * @returns mean centers of the binary geometries\n */\nexport function getMeanCentersFromBinaryGeometries(binaryGeometries) {\n const globalMeanCenters = [];\n binaryGeometries.forEach((binaryGeometry) => {\n let binaryGeometryType = null;\n if (binaryGeometry.points && binaryGeometry.points.positions.value.length > 0) {\n binaryGeometryType = BinaryGeometryType.points;\n }\n else if (binaryGeometry.lines && binaryGeometry.lines.positions.value.length > 0) {\n binaryGeometryType = BinaryGeometryType.lines;\n }\n else if (binaryGeometry.polygons && binaryGeometry.polygons.positions.value.length > 0) {\n binaryGeometryType = BinaryGeometryType.polygons;\n }\n const binaryContent = binaryGeometryType ? binaryGeometry[binaryGeometryType] : null;\n if (binaryContent && binaryGeometryType !== null) {\n const featureIds = binaryContent.featureIds.value;\n const flatCoordinateArray = binaryContent.positions.value;\n const nDim = binaryContent.positions.size;\n const primitivePolygonIndices = binaryContent.type === 'Polygon' ? binaryContent.primitivePolygonIndices?.value : undefined;\n const meanCenters = getMeanCentersFromGeometry(featureIds, flatCoordinateArray, nDim, binaryGeometryType, primitivePolygonIndices);\n meanCenters.forEach((center) => {\n globalMeanCenters.push(center);\n });\n }\n });\n return globalMeanCenters;\n}\n/**\n * Get mean centers from raw coordinates and feature ids\n * @param featureIds Array of feature ids indexes by vertex\n * @param flatCoordinateArray Array of vertex, e.g. x, y or x, y, z, positions\n * @param nDim number of dimensions per position\n * @returns - mean centers of each polygon\n */\nfunction getMeanCentersFromGeometry(featureIds, flatCoordinateArray, nDim, geometryType, primitivePolygonIndices) {\n const meanCenters = [];\n const vertexCount = flatCoordinateArray.length;\n let vertexIndex = 0;\n let coordIdx = 0;\n let primitiveIdx = 0;\n while (vertexIndex < vertexCount) {\n const featureId = featureIds[vertexIndex / nDim];\n const center = [0, 0];\n let vertexCountInFeature = 0;\n while (vertexIndex < vertexCount && featureIds[coordIdx] === featureId) {\n if (geometryType === BinaryGeometryType.polygons &&\n primitivePolygonIndices?.[primitiveIdx] === coordIdx) {\n // skip the first point since it is the same as the last point in each ring for polygons\n vertexIndex += nDim;\n primitiveIdx++;\n }\n else {\n center[0] += flatCoordinateArray[vertexIndex];\n center[1] += flatCoordinateArray[vertexIndex + 1];\n vertexIndex += nDim;\n vertexCountInFeature++;\n }\n coordIdx += 1;\n }\n center[0] /= vertexCountInFeature;\n center[1] /= vertexCountInFeature;\n meanCenters.push(center);\n }\n return meanCenters;\n}\n/**\n * get binary geometries from geoarrow column\n * @param chunk one chunk/batch of geoarrow column\n * @param geoEncoding geo encoding of the geoarrow column\n * @param options options for getting binary geometries\n * @returns BinaryGeometryContent\n */\nfunction getBinaryGeometriesFromChunk(chunk, geoEncoding, options) {\n switch (geoEncoding) {\n case 'geoarrow.point':\n case 'geoarrow.multipoint':\n return getBinaryPointsFromChunk(chunk, geoEncoding);\n case 'geoarrow.linestring':\n case 'geoarrow.multilinestring':\n return getBinaryLinesFromChunk(chunk, geoEncoding);\n case 'geoarrow.polygon':\n case 'geoarrow.multipolygon':\n return getBinaryPolygonsFromChunk(chunk, geoEncoding, options);\n default:\n throw Error('invalid geoarrow encoding');\n }\n}\n/**\n * get triangle indices. Allows deck.gl to skip performing costly triangulation on main thread.\n * @param polygonIndices Indices within positions of the start of each simple Polygon\n * @param primitivePolygonIndices Indices within positions of the start of each primitive Polygon/ring\n * @param flatCoordinateArray Array of x, y or x, y, z positions\n * @param nDim - number of dimensions per position\n * @returns triangle indices or null if invalid polygon and earcut fails\n */\nexport function getTriangleIndices(polygonIndices, primitivePolygonIndices, flatCoordinateArray, nDim) {\n try {\n let primitiveIndex = 0;\n const triangles = [];\n // loop polygonIndices to get triangles\n for (let i = 0; i < polygonIndices.length - 1; i++) {\n const startIdx = polygonIndices[i];\n const endIdx = polygonIndices[i + 1];\n // get subarray of flatCoordinateArray\n const slicedFlatCoords = flatCoordinateArray.subarray(startIdx * nDim, endIdx * nDim);\n // get holeIndices for earcut\n const holeIndices = [];\n while (primitivePolygonIndices[primitiveIndex] < endIdx) {\n if (primitivePolygonIndices[primitiveIndex] > startIdx) {\n holeIndices.push(primitivePolygonIndices[primitiveIndex] - startIdx);\n }\n primitiveIndex++;\n }\n // TODO check if each ring is closed\n const triangleIndices = earcut(slicedFlatCoords, holeIndices.length > 0 ? holeIndices : undefined, nDim);\n if (triangleIndices.length === 0) {\n throw Error('earcut failed e.g. invalid polygon');\n }\n for (let j = 0; j < triangleIndices.length; j++) {\n triangles.push(triangleIndices[j] + startIdx);\n }\n }\n // convert traingles to Uint32Array\n const trianglesUint32 = new Uint32Array(triangles.length);\n for (let i = 0; i < triangles.length; i++) {\n trianglesUint32[i] = triangles[i];\n }\n return trianglesUint32;\n }\n catch (error) {\n // if earcut fails, return null\n return null;\n }\n}\n/**\n * get binary polygons from geoarrow polygon column\n * @param chunk one chunk of geoarrow polygon column\n * @param geoEncoding the geo encoding of the geoarrow polygon column\n * @param options options for getting binary geometries\n * @returns BinaryGeometryContent\n */\nfunction getBinaryPolygonsFromChunk(chunk, geoEncoding, options) {\n const isMultiPolygon = geoEncoding === 'geoarrow.multipolygon';\n const polygonData = isMultiPolygon ? chunk.children[0] : chunk;\n const polygonOffset = polygonData.valueOffsets;\n const partData = isMultiPolygon\n ? chunk.valueOffsets.map((i) => polygonOffset.at(i) || i)\n : chunk.valueOffsets;\n const ringData = polygonData.children[0];\n const pointData = ringData.children[0];\n const coordData = pointData.children[0];\n const nDim = pointData.stride;\n const geomOffset = ringData.valueOffsets;\n const flatCoordinateArray = coordData.values;\n const geometryIndicies = new Uint16Array(polygonOffset.length);\n for (let i = 0; i < polygonOffset.length; i++) {\n geometryIndicies[i] = geomOffset[polygonOffset[i]];\n }\n const numOfVertices = flatCoordinateArray.length / nDim;\n const featureIds = new Uint32Array(numOfVertices);\n for (let i = 0; i < partData.length - 1; i++) {\n const startIdx = geomOffset[partData[i]];\n const endIdx = geomOffset[partData[i + 1]];\n for (let j = startIdx; j < endIdx; j++) {\n featureIds[j] = i;\n }\n }\n const triangles = options?.triangulate\n ? getTriangleIndices(geometryIndicies, geomOffset, flatCoordinateArray, nDim)\n : null;\n return {\n featureIds,\n nDim,\n flatCoordinateArray,\n geomOffset,\n geometryIndicies,\n ...(options?.triangulate && triangles ? { triangles } : {})\n };\n}\n/**\n * get binary lines from geoarrow line column\n * @param chunk one chunk/batch of geoarrow column\n * @param geoEncoding the geo encoding of the geoarrow column\n * @returns BinaryGeometryContent\n */\nfunction getBinaryLinesFromChunk(chunk, geoEncoding) {\n const isMultiLineString = geoEncoding === 'geoarrow.multilinestring';\n const lineData = isMultiLineString ? chunk.children[0] : chunk;\n const pointData = lineData.children[0];\n const coordData = pointData.children[0];\n const nDim = pointData.stride;\n const geomOffset = lineData.valueOffsets;\n const flatCoordinateArray = coordData.values;\n // geometryIndicies is not needed for line string\n const geometryIndicies = new Uint16Array(0);\n const numOfVertices = flatCoordinateArray.length / nDim;\n const featureIds = new Uint32Array(numOfVertices);\n if (isMultiLineString) {\n const partData = chunk.valueOffsets;\n for (let i = 0; i < partData.length - 1; i++) {\n const startIdx = geomOffset[partData[i]];\n const endIdx = geomOffset[partData[i + 1]];\n for (let j = startIdx; j < endIdx; j++) {\n featureIds[j] = i;\n }\n }\n }\n else {\n for (let i = 0; i < chunk.length; i++) {\n const startIdx = geomOffset[i];\n const endIdx = geomOffset[i + 1];\n for (let j = startIdx; j < endIdx; j++) {\n featureIds[j] = i;\n }\n }\n }\n return {\n featureIds,\n flatCoordinateArray,\n nDim,\n geomOffset,\n geometryIndicies\n };\n}\n/**\n * get binary points from geoarrow point column\n * @param chunk one chunk/batch of geoarrow column\n * @param geoEncoding geo encoding of the geoarrow column\n * @returns BinaryGeometryContent\n */\nfunction getBinaryPointsFromChunk(chunk, geoEncoding) {\n const isMultiPoint = geoEncoding === 'geoarrow.multipoint';\n const pointData = isMultiPoint ? chunk.children[0] : chunk;\n const coordData = pointData.children[0];\n const nDim = pointData.stride;\n const flatCoordinateArray = coordData.values;\n // geometryIndices is not needed for point\n const geometryIndicies = new Uint16Array(0);\n // geomOffset is not needed for point\n const geomOffset = new Int32Array(0);\n const numOfVertices = flatCoordinateArray.length / nDim;\n const featureIds = new Uint32Array(numOfVertices);\n if (isMultiPoint) {\n const partData = chunk.valueOffsets;\n for (let i = 0; i < partData.length - 1; i++) {\n const startIdx = partData[i];\n const endIdx = partData[i + 1];\n for (let j = startIdx; j < endIdx; j++) {\n featureIds[j] = i;\n }\n }\n }\n else {\n for (let i = 0; i < chunk.length; i++) {\n featureIds[i] = i;\n }\n }\n return {\n featureIds,\n flatCoordinateArray,\n nDim,\n geomOffset,\n geometryIndicies\n };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n/**\n * Update bounds from geoarrow sample data\n *\n * @param flatCoords the flattend coordinates array from one chunk of geoarrow column\n * @param nDim the number of dimensions of the coordinates\n * @param bounds the bounds to be updated\n * @param sampleSize how many samples to be used to update the bounds, default is 1000 per chunk\n * @returns the updated bounds\n */\nexport function updateBoundsFromGeoArrowSamples(flatCoords, nDim, bounds, sampleSize = 100) {\n const numberOfFeatures = flatCoords.length / nDim;\n const sampleStep = Math.max(Math.floor(numberOfFeatures / sampleSize), 1);\n const newBounds = [...bounds];\n for (let i = 0; i < numberOfFeatures; i += sampleStep) {\n const lng = flatCoords[i * nDim];\n const lat = flatCoords[i * nDim + 1];\n if (lng < newBounds[0]) {\n newBounds[0] = lng;\n }\n if (lat < newBounds[1]) {\n newBounds[1] = lat;\n }\n if (lng > newBounds[2]) {\n newBounds[2] = lng;\n }\n if (lat > newBounds[3]) {\n newBounds[3] = lat;\n }\n }\n return newBounds;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { binaryToGeometry } from '@loaders.gl/gis';\nimport { WKBLoader, WKTLoader } from '@loaders.gl/wkt';\n/**\n * parse geometry from arrow data that is returned from processArrowData()\n * NOTE: this function could be deduplicated with the binaryToFeature() in deck.gl,\n * it is currently used for deck.gl picking because currently deck.gl returns only the index of the feature\n *\n * @param data data extraced from arrow vector representing a geometry\n * @param encoding the geoarrow encoding of the geometry column\n * @returns Feature or null\n */\nexport function parseGeometryFromArrow(arrowCellValue, encoding) {\n // sanity\n encoding = encoding?.toLowerCase();\n if (!encoding || !arrowCellValue) {\n return null;\n }\n let geometry;\n switch (encoding) {\n case 'geoarrow.multipolygon':\n geometry = arrowMultiPolygonToFeature(arrowCellValue);\n break;\n case 'geoarrow.polygon':\n geometry = arrowPolygonToFeature(arrowCellValue);\n break;\n case 'geoarrow.multipoint':\n geometry = arrowMultiPointToFeature(arrowCellValue);\n break;\n case 'geoarrow.point':\n geometry = arrowPointToFeature(arrowCellValue);\n break;\n case 'geoarrow.multilinestring':\n geometry = arrowMultiLineStringToFeature(arrowCellValue);\n break;\n case 'geoarrow.linestring':\n geometry = arrowLineStringToFeature(arrowCellValue);\n break;\n case 'geoarrow.wkb':\n geometry = arrowWKBToFeature(arrowCellValue);\n break;\n case 'geoarrow.wkt':\n geometry = arrowWKTToFeature(arrowCellValue);\n break;\n default: {\n throw Error(`GeoArrow encoding not supported ${encoding}`);\n }\n }\n return geometry;\n}\nfunction arrowWKBToFeature(arrowCellValue) {\n // The actual WKB array buffer starts from byteOffset and ends at byteOffset + byteLength\n const arrayBuffer = arrowCellValue.buffer.slice(arrowCellValue.byteOffset, arrowCellValue.byteOffset + arrowCellValue.byteLength);\n const binaryGeometry = WKBLoader.parseSync?.(arrayBuffer);\n const geometry = binaryToGeometry(binaryGeometry);\n return geometry;\n}\nfunction arrowWKTToFeature(arrowCellValue) {\n const string = arrowCellValue;\n return WKTLoader.parseTextSync?.(string);\n}\n/**\n * convert Arrow MultiPolygon to geojson Feature\n */\nfunction arrowMultiPolygonToFeature(arrowMultiPolygon) {\n const multiPolygon = [];\n for (let m = 0; m < arrowMultiPolygon.length; m++) {\n const arrowPolygon = arrowMultiPolygon.get(m);\n const polygon = [];\n for (let i = 0; arrowPolygon && i < arrowPolygon?.length; i++) {\n const arrowRing = arrowPolygon?.get(i);\n const ring = [];\n for (let j = 0; arrowRing && j < arrowRing.length; j++) {\n const arrowCoord = arrowRing.get(j);\n const coord = Array.from(arrowCoord);\n ring.push(coord);\n }\n polygon.push(ring);\n }\n multiPolygon.push(polygon);\n }\n const geometry = {\n type: 'MultiPolygon',\n coordinates: multiPolygon\n };\n return geometry;\n}\n/**\n * convert Arrow Polygon to geojson Feature\n */\nfunction arrowPolygonToFeature(arrowPolygon) {\n const polygon = [];\n for (let i = 0; arrowPolygon && i < arrowPolygon.length; i++) {\n const arrowRing = arrowPolygon.get(i);\n const ring = [];\n for (let j = 0; arrowRing && j < arrowRing.length; j++) {\n const arrowCoord = arrowRing.get(j);\n const coords = Array.from(arrowCoord);\n ring.push(coords);\n }\n polygon.push(ring);\n }\n const geometry = {\n type: 'Polygon',\n coordinates: polygon\n };\n return geometry;\n}\n/**\n * convert Arrow MultiPoint to geojson MultiPoint\n */\nfunction arrowMultiPointToFeature(arrowMultiPoint) {\n const multiPoint = [];\n for (let i = 0; arrowMultiPoint && i < arrowMultiPoint.length; i++) {\n const arrowPoint = arrowMultiPoint.get(i);\n if (arrowPoint) {\n const coord = Array.from(arrowPoint);\n multiPoint.push(coord);\n }\n }\n return {\n type: 'MultiPoint',\n coordinates: multiPoint\n };\n}\n/**\n * convert Arrow Point to geojson Point\n */\nfunction arrowPointToFeature(arrowPoint) {\n const point = Array.from(arrowPoint);\n return {\n type: 'Point',\n coordinates: point\n };\n}\n/**\n * convert Arrow MultiLineString to geojson MultiLineString\n */\nfunction arrowMultiLineStringToFeature(arrowMultiLineString) {\n const multiLineString = [];\n for (let i = 0; arrowMultiLineString && i < arrowMultiLineString.length; i++) {\n const arrowLineString = arrowMultiLineString.get(i);\n const lineString = [];\n for (let j = 0; arrowLineString && j < arrowLineString.length; j++) {\n const arrowCoord = arrowLineString.get(j);\n if (arrowCoord) {\n const coords = Array.from(arrowCoord);\n lineString.push(coords);\n }\n }\n multiLineString.push(lineString);\n }\n return {\n type: 'MultiLineString',\n coordinates: multiLineString\n };\n}\n/**\n * convert Arrow LineString to geojson LineString\n */\nfunction arrowLineStringToFeature(arrowLineString) {\n const lineString = [];\n for (let i = 0; arrowLineString && i < arrowLineString.length; i++) {\n const arrowCoord = arrowLineString.get(i);\n if (arrowCoord) {\n const coords = Array.from(arrowCoord);\n lineString.push(coords);\n }\n }\n return {\n type: 'LineString',\n coordinates: lineString\n };\n}\n", "import * as arrow from 'apache-arrow';\nexport function hardClone(data, force = false) {\n // Check if `data` is an arrow.Vector\n if ('data' in data) {\n return new arrow.Vector(data.data.map((data) => hardClone(data, force)));\n }\n // Clone each of the children, recursively\n const clonedChildren = [];\n for (const childData of data.children) {\n clonedChildren.push(hardClone(childData, force));\n }\n // Clone the dictionary if there is one\n let clonedDictionary;\n if (data.dictionary !== undefined) {\n clonedDictionary = hardClone(data.dictionary, force);\n }\n // Buffers can have up to four entries. Each of these can be `undefined` for\n // one or more array types.\n //\n // - OFFSET: value offsets for variable size list types\n // - DATA: the underlying data\n // - VALIDITY: the null buffer. This may be empty or undefined if all elements\n // are non-null/valid.\n // - TYPE: type ids for a union type.\n const clonedBuffers = {\n [arrow.BufferType.OFFSET]: cloneBuffer(data.buffers[arrow.BufferType.OFFSET], force),\n [arrow.BufferType.DATA]: cloneBuffer(data.buffers[arrow.BufferType.DATA], force),\n [arrow.BufferType.VALIDITY]: cloneBuffer(data.buffers[arrow.BufferType.VALIDITY], force),\n [arrow.BufferType.TYPE]: cloneBuffer(data.buffers[arrow.BufferType.TYPE], force)\n };\n // Note: the data.offset is passed on so that a sliced Data instance will not\n // be \"un-sliced\". However keep in mind that this means we're cloning the\n // _original backing buffer_, not only the portion of the Data that was\n // sliced.\n return new arrow.Data(data.type, data.offset, data.length, \n // @ts-expect-error _nullCount is protected. We're using it here to mimic\n // `Data.clone`\n data._nullCount, clonedBuffers, clonedChildren, clonedDictionary);\n}\n/**\n * Test whether an arrow.Data instance is a slice of a larger `ArrayBuffer`.\n */\nexport function isShared(data) {\n // Loop over arrow.Vector\n if ('data' in data) {\n return data.data.some((data) => isShared(data));\n }\n // Check child data\n for (const childData of data.children) {\n if (isShared(childData)) {\n return true;\n }\n }\n // Check dictionary\n if (data.dictionary !== undefined) {\n if (isShared(data.dictionary)) {\n return true;\n }\n }\n const bufferTypes = [\n arrow.BufferType.OFFSET,\n arrow.BufferType.DATA,\n arrow.BufferType.VALIDITY,\n arrow.BufferType.TYPE\n ];\n for (const bufferType of bufferTypes) {\n if (data.buffers[bufferType] !== undefined && isTypedArraySliced(data.buffers[bufferType])) {\n return true;\n }\n }\n return false;\n}\n/**\n * Returns true if the current typed array is a partial slice on a larger\n * ArrayBuffer\n */\nfunction isTypedArraySliced(arr) {\n return !(arr.byteOffset === 0 && arr.byteLength === arr.buffer.byteLength);\n}\n/**\n * If a slice of a larger ArrayBuffer, clone to a fresh `ArrayBuffer`.\n *\n * If `force` is `true`, always clone the array, even if not shared.\n */\nfunction cloneBuffer(arr, force) {\n // Not all buffer types are defined for every type of Arrow array. E.g.\n // `arrow.BufferType.TYPE` is only defined for the Union type.\n if (arr === undefined) {\n return arr;\n }\n // The current array is not a part of a larger ArrayBuffer, don't clone it\n if (!force && !isTypedArraySliced(arr)) {\n return arr;\n }\n // Note: TypedArray.slice() **copies** into a new ArrayBuffer\n // @ts-expect-error 'Uint8Array' is assignable to the constraint of type 'A',\n // but 'A' could be instantiated with a different subtype of constraint\n // 'TypedArray'\n // We know from arr.slice that it will always return the same\n return arr.slice();\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { processOnWorker } from '@loaders.gl/worker-utils';\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.6\" !== 'undefined' ? \"4.3.0-alpha.6\" : 'latest';\n/**\n * Worker for tessellating geometries. Normally called through triangulateOnWorker\n */\nexport const TriangulationWorker = {\n id: 'triangulation',\n name: 'Triangulate',\n module: 'arrow',\n version: VERSION,\n options: {}\n};\n/**\n * Triangulate a set of polygons on worker, type safe API\n */\nexport function triangulateOnWorker(data, options = {}) {\n return processOnWorker(TriangulationWorker, { ...data, operation: 'triangulate' }, options);\n}\n/**\n * Parse GeoArrow geometry colum on worker, type safe API\n */\nexport function parseGeoArrowOnWorker(data, options = {}) {\n return processOnWorker(TriangulationWorker, { ...data, operation: 'parse-geoarrow' }, options);\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,IAAAC,iBAAkC;;;ACAlC,oBAA6C;AAC7C,YAAuB;AAChB,IAAM,4BAAN,cAAwC,2CAA6B;AAAA,EACxE;AAAA,EACA,Y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ACvF,CAAO,kBAAW,IAAI,GAAG,YAAY,KAAK,QAAc,kBAAW,IAAI,GAAG,KAAK;AAAA,EACnF;AAKA,SAAO,IAAU;AAAA,IAAK,KAAK;AAAA,IAAM,KAAK;AAAA,IAAQ,KAAK;AAAA;AAAA;AAAA,IAGnD,KAAK;AAAA,IAAY;AAAA,IAAe;AAAA,IAAgB;AAAA,EAAgB;AACpE;AAsCA,SAAS,mBAAmB,KAAK;AAC7B,SAAO,EAAE,IAAI,eAAe,KAAK,IAAI,eAAe,IAAI,OAAO;AACnE;AAMA,SAAS,YAAY,KAAK,OAAO;AAG7B,MAAI,QAAQ,QAAW;AACnB,WAAO;AAAA,EACX;AAEA,MAAI,CAAC,SAAS,CAAC,mBAAmB,GAAG,GAAG;AACpC,WAAO;AAAA,EACX;AAMA,SAAO,IAAI,MAAM;AACrB;;;ACjGA,0BAAgC;AAGhC,IAAMC,WAAU,OAAyC,kBAAkB;AAIpE,IAAM,sBAAsB;AAAA,EAC/B,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,SAASA;AAAA,EACT,SAAS,CAAC;AACd;AAIO,SAAS,oBAAoB,MAAM,UAAU,CAAC,GAAG;AACpD,aAAO,qCAAgB,qBAAqB,EAAE,GAAG,MAAM,WAAW,cAAc,GAAG,OAAO;AAC9F;AAIO,SAAS,sBAAsB,MAAM,UAAU,CAAC,GAAG;AACtD,aAAO,qCAAgB,qBAAqB,EAAE,GAAG,MAAM,WAAW,iBAAiB,GAAG,OAAO;AACjG;;;AnBtBA,iCAAkB,aAAa;",
6
6
  "names": ["parseGeometryFromArrow", "import_schema", "arrow", "VECTOR_TYPES", "import_schema", "arrow", "arrow", "arrow", "_a", "arrow", "VERSION", "BinaryGeometryType", "import_gis", "parseGeometryFromArrow", "arrow", "data", "VERSION"]
7
7
  }
@@ -4,7 +4,7 @@
4
4
  import { processOnWorker } from '@loaders.gl/worker-utils';
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
6
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof "4.3.0-alpha.5" !== 'undefined' ? "4.3.0-alpha.5" : 'latest';
7
+ const VERSION = typeof "4.3.0-alpha.6" !== 'undefined' ? "4.3.0-alpha.6" : 'latest';
8
8
  /**
9
9
  * Worker for tessellating geometries. Normally called through triangulateOnWorker
10
10
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/arrow",
3
- "version": "4.3.0-alpha.6",
3
+ "version": "4.3.0-alpha.7",
4
4
  "description": "Simple columnar table loader for the Apache Arrow format",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -53,16 +53,16 @@
53
53
  "build-worker2": "esbuild src/workers/arrow-worker.ts --bundle --outfile=dist/arrow-worker.js --platform=browser --external:{stream}"
54
54
  },
55
55
  "dependencies": {
56
- "@loaders.gl/gis": "4.3.0-alpha.6",
57
- "@loaders.gl/loader-utils": "4.3.0-alpha.6",
58
- "@loaders.gl/schema": "4.3.0-alpha.6",
59
- "@loaders.gl/wkt": "4.3.0-alpha.6",
60
- "@loaders.gl/worker-utils": "4.3.0-alpha.6",
56
+ "@loaders.gl/gis": "4.3.0-alpha.7",
57
+ "@loaders.gl/loader-utils": "4.3.0-alpha.7",
58
+ "@loaders.gl/schema": "4.3.0-alpha.7",
59
+ "@loaders.gl/wkt": "4.3.0-alpha.7",
60
+ "@loaders.gl/worker-utils": "4.3.0-alpha.7",
61
61
  "@math.gl/polygon": "4.0.0",
62
62
  "apache-arrow": ">= 15.0.0"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "@loaders.gl/core": "^4.0.0"
66
66
  },
67
- "gitHead": "315f2e232fc4e6a477c41de800a54d3e3d957e8c"
67
+ "gitHead": "73fb27872d89f3804dca37ebd568c6ba9609a98f"
68
68
  }