@loaders.gl/arrow 4.3.2 → 4.3.3

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.
@@ -12593,7 +12593,7 @@ return true;`);
12593
12593
  }
12594
12594
 
12595
12595
  // ../wkt/src/lib/utils/version.ts
12596
- var VERSION = true ? "4.3.1" : "latest";
12596
+ var VERSION = true ? "4.3.2" : "latest";
12597
12597
 
12598
12598
  // ../wkt/src/lib/parse-wkt.ts
12599
12599
  var numberRegexp = /[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/;
@@ -13454,7 +13454,7 @@ return true;`);
13454
13454
  }
13455
13455
 
13456
13456
  // src/exports/arrow-loader.ts
13457
- var VERSION2 = true ? "4.3.1" : "latest";
13457
+ var VERSION2 = true ? "4.3.2" : "latest";
13458
13458
  var ArrowWorkerLoader = {
13459
13459
  dataType: null,
13460
13460
  batchType: null,
@@ -2,7 +2,7 @@
2
2
  import { encodeArrowSync } from "./lib/encoders/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.1" !== 'undefined' ? "4.3.1" : 'latest';
5
+ const VERSION = typeof "4.3.2" !== 'undefined' ? "4.3.2" : '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 ud(r){return typeof r!="bigint"?Ae(r):`${Ae(r)}n`}function Ma(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function nu(r,t=0){return r.length>=t?r.subarray(0,t):ti(new r.constructor(t),r,0)}var Oe=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?Ma(n*1,this.BYTES_PER_ELEMENT):Ma(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=Ma(t*this.stride,this.BYTES_PER_ELEMENT);let e=nu(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=nu(this.buffer,t)}},ur=class extends Oe{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}},Fn=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()}},Mn=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 nt=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=ue(t),this._nulls=new Fn,e&&e.length>0&&(this._isValid=ru(e))}toVector(){return new b([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(p=>p.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}};nt.prototype.length=1;nt.prototype.stride=1;nt.prototype.children=null;nt.prototype.finished=!1;nt.prototype.nullValues=null;nt.prototype._isValid=()=>!0;var mt=class extends nt{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)}},qt=class extends nt{constructor(t){super(t),this._pendingLength=0,this._offsets=new Mn(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[be].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):H.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,H.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 R=class{constructor(t=[],e,n,i=H.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=La(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 R(n,this.metadata)}selectAt(t){let e=t.map(n=>this.fields[n]).filter(Boolean);return new R(e,this.metadata)}assign(...t){let e=t[0]instanceof R?t[0]:Array.isArray(t[0])?new R(t[0]):new R(t),n=[...this.fields],i=Ys(Ys(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:Ys(Ys(new Map,n[c].metadata),a.metadata)}))&&!1:!0}),o=La(s,new Map);return new R([...n,...s],i,new Map([...this.dictionaries,...o]))}};R.prototype.fields=null;R.prototype.metadata=null;R.prototype.dictionaries=null;var O=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 O(`${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],O.new(e,n,i,s)}};O.prototype.type=null;O.prototype.name=null;O.prototype.nullable=null;O.prototype.metadata=null;function Ys(r,t){return new Map([...r||new Map,...t||new Map])}function La(r,t=new Map){for(let e=-1,n=r.length;++e<n;){let s=r[e].type;if(y.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&&La(s.children,t)}return t}var fd=ar,hd=Ct,fr=class{static decode(t){t=new hd(D(t));let e=Et.getRootAsFooter(t),n=R.decode(e.schema(),new Map,e.version());return new Na(n,e)}static encode(t){let e=new fd,n=R.encode(e,t.schema);Et.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())Fe.encode(e,o);let i=e.endVector();Et.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())Fe.encode(e,o);let s=e.endVector();return Et.startFooter(e),Et.addSchema(e,n),Et.addVersion(e,H.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=H.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 Na=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 Fe.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return Fe.decode(e)}return null}},Fe=class{static decode(t){return new Fe(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}),fi=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())}},Ks=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 g(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){let{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(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 g(this,void 0,void 0,function*(){return yield this.abort(t),q})}return(t){return g(this,void 0,void 0,function*(){return yield this.close(),q})}read(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,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 Ks{write(t){if((t=D(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Qn(this.toUint8Array(!0)):this.toUint8Array(!1).then(Qn)}toUint8Array(t=!1){return t?oe(this._values)[0]:(()=>g(this,void 0,void 0,function*(){var e,n,i,s;let o=[],a=0;try{for(var c=!0,l=ve(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 oe(o,a)[0]}))()}},rr=class{constructor(t){t&&(this.source=new Ua(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)}},te=class{constructor(t){t instanceof te?this.source=t.source:t instanceof er?this.source=new hr(Bt.fromAsyncIterable(t)):ms(t)?this.source=new hr(Bt.fromNodeStream(t)):qn(t)?this.source=new hr(Bt.fromDOMStream(t)):ds(t)?this.source=new hr(Bt.fromDOMStream(t.body)):Ie(t)?this.source=new hr(Bt.fromIterable(t)):se(t)?this.source=new hr(Bt.fromAsyncIterable(t)):fe(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)}},Ua=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 g(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t,e="read"){return g(this,void 0,void 0,function*(){return yield this.source.next({cmd:e,size:t})})}throw(t){return g(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 g(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 hi=class extends rr{constructor(t,e){super(),this.position=0,this.buffer=D(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){let{buffer:e,byteOffset: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 te{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=(()=>g(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending}))()}readInt32(t){return g(this,void 0,void 0,function*(){let{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return g(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return g(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size: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 g(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 g(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return g(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return g(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var Ra={};Ir(Ra,{BaseInt64:()=>di,Int128:()=>ee,Int64:()=>St,Uint64:()=>$});function Ln(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var Nn=8,Ea=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],di=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`${Ln(this.buffer[1])} ${Ln(this.buffer[0])}`}},$=class extends di{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return $.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return $.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.length,i=new $(e);for(let s=0;s<n;){let o=Nn<n-s?Nn:n-s,a=new $(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new $(new Uint32Array([Ea[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;)$.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new $(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new $(new Uint32Array(t.buffer)).plus(e)}},St=class extends di{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=Nn<i-o?Nn:i-o,c=new St(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new St(new Uint32Array([Ea[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)}},ee=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 $(new Uint32Array([this.buffer[3],0])),n=new $(new Uint32Array([this.buffer[2],0])),i=new $(new Uint32Array([this.buffer[1],0])),s=new $(new Uint32Array([this.buffer[0],0])),o=new $(new Uint32Array([t.buffer[3],0])),a=new $(new Uint32Array([t.buffer[2],0])),c=new $(new Uint32Array([t.buffer[1],0])),l=new $(new Uint32Array([t.buffer[0],0])),u=$.multiply(s,l);this.buffer[0]=u.low();let h=new $(new Uint32Array([u.high(),0]));return u=$.multiply(i,l),h.plus(u),u=$.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 $(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus($.multiply(n,l)).plus($.multiply(i,c)).plus($.multiply(s,a)),this.buffer[3]+=$.multiply(e,l).plus($.multiply(n,c)).plus($.multiply(i,a)).plus($.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`${Ln(this.buffer[3])} ${Ln(this.buffer[2])} ${Ln(this.buffer[1])} ${Ln(this.buffer[0])}`}static multiply(t,e){return new ee(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new ee(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return ee.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return ee.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let n=t.startsWith("-"),i=t.length,s=new ee(e);for(let o=n?1:0;o<i;){let a=Nn<i-o?Nn:i-o,c=new ee(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new ee(new Uint32Array([Ea[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;)ee.from(t[n],new Uint32Array(e.buffer,e.byteOffset+4*4*n,4));return e}};var pi=class extends I{constructor(t,e,n,i,s=H.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 O?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<H.V5&&this.readNullBitmap(t,n),t.mode===J.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)}},Zs=class extends pi{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 y.isTimestamp(t)?C(Uint8Array,St.convertArray(n[e])):(y.isInt(t)||y.isTime(t))&&t.bitWidth===64||y.isDuration(t)?C(Uint8Array,St.convertArray(n[e])):y.isDate(t)&&t.unit===rt.MILLISECOND?C(Uint8Array,St.convertArray(n[e])):y.isDecimal(t)?C(Uint8Array,ee.convertArray(n[e])):y.isBinary(t)||y.isLargeBinary(t)||y.isFixedSizeBinary(t)?dd(n[e]):y.isBool(t)?Xr(n[e]):y.isUtf8(t)||y.isLargeUtf8(t)?Ne(n[e].join("")):C(Uint8Array,C(t.ArrayType,n[e].map(i=>+i)))}};function dd(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 Un=class extends qt{constructor(t){super(t),this._values=new Oe(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,D(e))}_flushPending(t,e){let 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 En=class extends qt{constructor(t){super(t),this._values=new Oe(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,D(e))}_flushPending(t,e){let 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 Js=class extends nt{constructor(t){super(t),this._values=new Fn}setValue(t,e){this._values.set(t,+e)}};var rn=class extends mt{};rn.prototype._setValue=ya;var mi=class extends rn{};mi.prototype._setValue=xs;var yi=class extends rn{};yi.prototype._setValue=Ss;var gi=class extends mt{};gi.prototype._setValue=wa;var Xs=class extends nt{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=Me({type:this.type.indices,nullValues:e}),this.dictionary=Me({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 bi=class extends mt{};bi.prototype._setValue=ma;var Qs=class extends nt{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 O(e,t.type,!0)),n}};var nn=class extends mt{setValue(t,e){this._values.set(t,e)}},qs=class extends nn{setValue(t,e){super.setValue(t,oi(e))}},to=class extends nn{},eo=class extends nn{};var sn=class extends mt{};sn.prototype._setValue=_a;var wi=class extends sn{};wi.prototype._setValue=Ns;var _i=class extends sn{};_i.prototype._setValue=Us;var dr=class extends mt{};dr.prototype._setValue=va;var vi=class extends dr{};vi.prototype._setValue=Es;var Ii=class extends dr{};Ii.prototype._setValue=Rs;var xi=class extends dr{};xi.prototype._setValue=Cs;var Si=class extends dr{};Si.prototype._setValue=Ps;var we=class extends mt{setValue(t,e){this._values.set(t,e)}},ro=class extends we{},no=class extends we{},io=class extends we{},so=class extends we{},oo=class extends we{},ao=class extends we{},co=class extends we{},lo=class extends we{};var uo=class extends qt{constructor(t){super(t),this._offsets=new Mn(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 O(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 fo=class extends qt{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 O(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 ho=class extends nt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var po=class extends nt{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 O(e,t.type,!0)]),n}};var pr=class extends mt{};pr.prototype._setValue=ga;var Bi=class extends pr{};Bi.prototype._setValue=Bs;var Ai=class extends pr{};Ai.prototype._setValue=As;var Ti=class extends pr{};Ti.prototype._setValue=Ts;var Di=class extends pr{};Di.prototype._setValue=Ds;var mr=class extends mt{};mr.prototype._setValue=ba;var Oi=class extends mr{};Oi.prototype._setValue=Os;var Fi=class extends mr{};Fi.prototype._setValue=Fs;var Mi=class extends mr{};Mi.prototype._setValue=Ms;var Li=class extends mr{};Li.prototype._setValue=Ls;var Rn=class extends nt{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 O(e,t.type)];return this.type=new ge(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.")}},mo=class extends Rn{},yo=class extends Rn{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 Ni=class extends qt{constructor(t){super(t),this._values=new Oe(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,Ne(e))}_flushPending(t,e){}};Ni.prototype._flushPending=Un.prototype._flushPending;var Ui=class extends qt{constructor(t){super(t),this._values=new Oe(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,Ne(e))}_flushPending(t,e){}};Ui.prototype._flushPending=En.prototype._flushPending;var Ca=class extends I{visitNull(){return ho}visitBool(){return Js}visitInt(){return we}visitInt8(){return ro}visitInt16(){return no}visitInt32(){return io}visitInt64(){return so}visitUint8(){return oo}visitUint16(){return ao}visitUint32(){return co}visitUint64(){return lo}visitFloat(){return nn}visitFloat16(){return qs}visitFloat32(){return to}visitFloat64(){return eo}visitUtf8(){return Ni}visitLargeUtf8(){return Ui}visitBinary(){return Un}visitLargeBinary(){return En}visitFixedSizeBinary(){return bi}visitDate(){return rn}visitDateDay(){return mi}visitDateMillisecond(){return yi}visitTimestamp(){return pr}visitTimestampSecond(){return Bi}visitTimestampMillisecond(){return Ai}visitTimestampMicrosecond(){return Ti}visitTimestampNanosecond(){return Di}visitTime(){return mr}visitTimeSecond(){return Oi}visitTimeMillisecond(){return Fi}visitTimeMicrosecond(){return Mi}visitTimeNanosecond(){return Li}visitDecimal(){return gi}visitList(){return uo}visitStruct(){return po}visitUnion(){return Rn}visitDenseUnion(){return yo}visitSparseUnion(){return mo}visitDictionary(){return Xs}visitInterval(){return sn}visitIntervalDayTime(){return wi}visitIntervalYearMonth(){return _i}visitDuration(){return dr}visitDurationSecond(){return vi}visitDurationMillisecond(){return Ii}visitDurationMicrosecond(){return xi}visitDurationNanosecond(){return Si}visitFixedSizeList(){return Qs}visitMap(){return fo}},iu=new Ca;var A=class extends I{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 yr(r,t){return r===t||zt(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function go(r,t){return r===t||zt(r,t)&&r.precision===t.precision}function pd(r,t){return r===t||zt(r,t)&&r.byteWidth===t.byteWidth}function Pa(r,t){return r===t||zt(r,t)&&r.unit===t.unit}function Ei(r,t){return r===t||zt(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function Ri(r,t){return r===t||zt(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function md(r,t){return r===t||zt(r,t)&&r.children.length===t.children.length&&nr.compareManyFields(r.children,t.children)}function yd(r,t){return r===t||zt(r,t)&&r.children.length===t.children.length&&nr.compareManyFields(r.children,t.children)}function ka(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 gd(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 Va(r,t){return r===t||zt(r,t)&&r.unit===t.unit}function Ci(r,t){return r===t||zt(r,t)&&r.unit===t.unit}function bd(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 wd(r,t){return r===t||zt(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&nr.compareManyFields(r.children,t.children)}A.prototype.visitNull=on;A.prototype.visitBool=on;A.prototype.visitInt=yr;A.prototype.visitInt8=yr;A.prototype.visitInt16=yr;A.prototype.visitInt32=yr;A.prototype.visitInt64=yr;A.prototype.visitUint8=yr;A.prototype.visitUint16=yr;A.prototype.visitUint32=yr;A.prototype.visitUint64=yr;A.prototype.visitFloat=go;A.prototype.visitFloat16=go;A.prototype.visitFloat32=go;A.prototype.visitFloat64=go;A.prototype.visitUtf8=on;A.prototype.visitLargeUtf8=on;A.prototype.visitBinary=on;A.prototype.visitLargeBinary=on;A.prototype.visitFixedSizeBinary=pd;A.prototype.visitDate=Pa;A.prototype.visitDateDay=Pa;A.prototype.visitDateMillisecond=Pa;A.prototype.visitTimestamp=Ei;A.prototype.visitTimestampSecond=Ei;A.prototype.visitTimestampMillisecond=Ei;A.prototype.visitTimestampMicrosecond=Ei;A.prototype.visitTimestampNanosecond=Ei;A.prototype.visitTime=Ri;A.prototype.visitTimeSecond=Ri;A.prototype.visitTimeMillisecond=Ri;A.prototype.visitTimeMicrosecond=Ri;A.prototype.visitTimeNanosecond=Ri;A.prototype.visitDecimal=on;A.prototype.visitList=md;A.prototype.visitStruct=yd;A.prototype.visitUnion=ka;A.prototype.visitDenseUnion=ka;A.prototype.visitSparseUnion=ka;A.prototype.visitDictionary=gd;A.prototype.visitInterval=Va;A.prototype.visitIntervalDayTime=Va;A.prototype.visitIntervalYearMonth=Va;A.prototype.visitDuration=Ci;A.prototype.visitDurationSecond=Ci;A.prototype.visitDurationMillisecond=Ci;A.prototype.visitDurationMicrosecond=Ci;A.prototype.visitDurationNanosecond=Ci;A.prototype.visitFixedSizeList=bd;A.prototype.visitMap=wd;var nr=new A;function an(r,t){return nr.compareSchemas(r,t)}function su(r,t){return nr.compareFields(r,t)}function bo(r,t){return nr.visit(r,t)}function Me(r){let t=r.type,e=new(iu.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(Me(Object.assign(Object.assign({},l),{type:c})))}}return e}function Pi(r,t){if(r instanceof U||r instanceof b||r.type instanceof y||ArrayBuffer.isView(r))return Or(r);let e={type:t??wo(r),nullValues:[null]},n=[...ja(e)(r)],i=n.length===1?n[0]:n.reduce((s,o)=>s.concat(o));return y.isDictionary(i.type)?i.memoize():i}function wo(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 ye;if(s+t===r.length)return new Ut(new Pt,new It);if(o+t===r.length)return new pe;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=wo(l[l.findIndex(h=>h!=null)]);if(l.every(h=>h==null||bo(u,wo(h))))return new Tt(new O("",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 O(h,wo([u[h]]),!0));return new V([...l.values()])}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}function ja(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=Me(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 _o(r,t){return _d(r,t.map(e=>e.data.concat()))}function _d(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=vd(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 W(r,h))]}function vd(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 ou,K=class{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new R([]),this._offsets=[0],this;let i,s;t[0]instanceof R&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=c=>{if(c){if(c instanceof W)return[c];if(c instanceof K)return c.batches;if(c instanceof U){if(c.type instanceof V)return[new W(new R(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(p=>new b([c[p]])),h=i??new R(l.map((p,v)=>new O(String(p),u[v].type,u[v].nullable))),[,d]=_o(h,u);return d.length===0?[new W(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 R([]),!(i instanceof R))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof W))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??Ws(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=zs(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?Dn.visit(new b(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 K(e,n.map(i=>new W(e,i)))}slice(t,e){let n=this.schema;[t,e]=ai({length:this.numRows},t,e);let i=Gs(this.data,this._offsets,t,e);return new K(n,i.map(s=>new W(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 b(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 b([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]=_o(n,a)}return new K(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 K(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(p=>p.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 K(..._o(s,o))}};ou=Symbol.toStringTag;K[ou]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Tn(ui),r.get=Tn(pt.getVisitFn(f.Struct)),r.set=$s(Dt.getVisitFn(f.Struct)),r.indexOf=Hs(qr.getVisitFn(f.Struct)),"Table"))(K.prototype);var cu,W=class{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof R))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 U))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=au(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]=O.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new R(n),a=w({type:new V(n),length:s,children:i,nullCount:0});[this.schema,this.data]=au(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=lu(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 pt.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 Dn.visit(new b([this.data]))}toArray(){return[...this]}concat(...t){return new K(this.schema,[this,...t])}slice(t,e){let[n]=new b([this.data]).slice(t,e).data;return new W(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 b([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 b([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 R(s,new Map(this.schema.metadata)),i=w({type:new V(s),children:o})}return new W(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 W(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 W(e,i)}};cu=Symbol.toStringTag;W[cu]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(W.prototype);function au(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 lu(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)||[]])lu(a.children,l?.children,e);if(y.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 W{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):H.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,H.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 za=class extends I{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return je.startNull(e),je.endNull(e)}visitInt(t,e){return wt.startInt(e),wt.addBitWidth(e,t.bitWidth),wt.addIsSigned(e,t.isSigned),wt.endInt(e)}visitFloat(t,e){return Kt.startFloatingPoint(e),Kt.addPrecision(e,t.precision),Kt.endFloatingPoint(e)}visitBinary(t,e){return Re.startBinary(e),Re.endBinary(e)}visitLargeBinary(t,e){return Pe.startLargeBinary(e),Pe.endLargeBinary(e)}visitBool(t,e){return Ce.startBool(e),Ce.endBool(e)}visitUtf8(t,e){return We.startUtf8(e),We.endUtf8(e)}visitLargeUtf8(t,e){return ke.startLargeUtf8(e),ke.endLargeUtf8(e)}visitDecimal(t,e){return _t.startDecimal(e),_t.addScale(e,t.scale),_t.addPrecision(e,t.precision),_t.addBitWidth(e,t.bitWidth),_t.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 Ve.startList(e),Ve.endList(e)}visitStruct(t,e){return ze.startStruct_(e),ze.endStruct_(e)}visitUnion(t,e){vt.startTypeIdsVector(e,t.typeIds.length);let n=vt.createTypeIdsVector(e,t.typeIds);return vt.startUnion(e),vt.addMode(e,t.mode),vt.addTypeIds(e,n),vt.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return ae.startDictionaryEncoding(e),ae.addId(e,BigInt(t.id)),ae.addIsOrdered(e,t.isOrdered),n!==void 0&&ae.addIndexType(e,n),ae.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)}},vo=new za;function du(r,t=new Map){return new R(Id(r,t),Io(r.metadata),t)}function Wa(r){return new Ot(r.count,mu(r.columns),yu(r.columns))}function pu(r){return new ne(Wa(r.data),r.id,r.isDelta)}function Id(r,t){return(r.fields||[]).filter(Boolean).map(e=>O.fromJSON(e,t))}function uu(r,t){return(r.children||[]).filter(Boolean).map(e=>O.fromJSON(e,t))}function mu(r){return(r||[]).reduce((t,e)=>[...t,new _e(e.count,xd(e.VALIDITY)),...mu(e.children)],[])}function yu(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new re(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new re(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new re(t.length,i.OFFSET.length)),i.DATA&&t.push(new re(t.length,i.DATA.length)),t=yu(i.children,t)}return t}function xd(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function gu(r,t){let e,n,i,s,o,a;return!t||!(s=r.dictionary)?(o=hu(r,uu(r,t)),i=new O(r.name,o,r.nullable,Io(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?fu(n):new It,a=new Ut(t.get(e),n,e,s.isOrdered),i=new O(r.name,a,r.nullable,Io(r.metadata))):(n=(n=s.indexType)?fu(n):new It,t.set(e,o=hu(r,uu(r,t))),a=new Ut(o,n,e,s.isOrdered),i=new O(r.name,a,r.nullable,Io(r.metadata))),i||null}function Io(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function fu(r){return new st(r.isSigned,r.bitWidth)}function hu(r,t){let e=r.type.name;switch(e){case"NONE":return new ut;case"null":return new ut;case"binary":return new ce;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 st(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new At(z[n.precision])}case"decimal":{let n=r.type;return new le(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new Xt(rt[n.unit])}case"time":{let n=r.type;return new xt(m[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new Nt(m[n.unit],n.timezone)}case"interval":{let n=r.type;return new Qt(it[n.unit])}case"duration":{let n=r.type;return new Qe(m[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new ge(J[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 Sd=ar,Bd=Ct,yt=class{static fromJSON(t,e){let n=new yt(0,H.V5,e);return n._createHeader=Ad(t,e),n}static decode(t){t=new Bd(D(t));let e=ft.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new yt(n,i,s);return o._createHeader=Td(e,s),o}static encode(t){let e=new Sd,n=-1;return t.isSchema()?n=R.encode(e,t.header()):t.isRecordBatch()?n=Ot.encode(e,t.header()):t.isDictionaryBatch()&&(n=ne.encode(e,t.header())),ft.startMessage(e),ft.addVersion(e,H.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 R)return new yt(0,H.V5,P.Schema,t);if(t instanceof Ot)return new yt(e,H.V5,P.RecordBatch,t);if(t instanceof ne)return new yt(e,H.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)}},ne=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)}},re=class{constructor(t,e){this.offset=at(t),this.length=at(e)}},_e=class{constructor(t,e){this.length=at(t),this.nullCount=at(e)}};function Ad(r,t){return()=>{switch(t){case P.Schema:return R.fromJSON(r);case P.RecordBatch:return Ot.fromJSON(r);case P.DictionaryBatch:return ne.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${P[t]}, type: ${t} }`)}}function Td(r,t){return()=>{switch(t){case P.Schema:return R.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 ne.decode(r.header(new de),r.version())}throw new Error(`Unrecognized Message type: { name: ${P[t]}, type: ${t} }`)}}O.encode=Pd;O.decode=Rd;O.fromJSON=gu;R.encode=Cd;R.decode=Dd;R.fromJSON=du;Ot.encode=kd;Ot.decode=Od;Ot.fromJSON=Wa;ne.encode=Vd;ne.decode=Fd;ne.fromJSON=pu;_e.encode=jd;_e.decode=Ld;re.encode=zd;re.decode=Md;function Dd(r,t=new Map,e=H.V5){let n=Ed(r,t);return new R(n,xo(r),t,e)}function Od(r,t=H.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Ot(r.length(),Nd(r),Ud(r,t))}function Fd(r,t=H.V5){return new ne(Ot.decode(r.data(),t),r.id(),r.isDelta())}function Md(r){return new re(r.offset(),r.length())}function Ld(r){return new _e(r.length(),r.nullCount())}function Nd(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=_e.decode(e));return t}function Ud(r,t){let e=[];for(let n,i=-1,s=-1,o=r.buffersLength();++i<o;)(n=r.buffers(i))&&(t<H.V4&&(n.bb_pos+=8*(i+1)),e[++s]=re.decode(n));return e}function Ed(r,t){let e=[];for(let n,i=-1,s=-1,o=r.fieldsLength();++i<o;)(n=r.fields(i))&&(e[++s]=O.decode(n,t));return e}function bu(r,t){let e=[];for(let n,i=-1,s=-1,o=r.childrenLength();++i<o;)(n=r.children(i))&&(e[++s]=O.decode(n,t));return e}function Rd(r,t){let e,n,i,s,o,a;return!t||!(a=r.dictionary())?(i=_u(r,bu(r,t)),n=new O(r.name(),i,r.nullable(),xo(r))):t.has(e=at(a.id()))?(s=(s=a.indexType())?wu(s):new It,o=new Ut(t.get(e),s,e,a.isOrdered()),n=new O(r.name(),o,r.nullable(),xo(r))):(s=(s=a.indexType())?wu(s):new It,t.set(e,i=_u(r,bu(r,t))),o=new Ut(i,s,e,a.isOrdered()),n=new O(r.name(),o,r.nullable(),xo(r))),n||null}function xo(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 wu(r){return new st(r.isSigned(),r.bitWidth())}function _u(r,t){let e=r.typeType();switch(e){case X.NONE:return new ut;case X.Null:return new ut;case X.Binary:return new ce;case X.LargeBinary:return new Je;case X.Utf8:return new Pt;case X.LargeUtf8:return new Xe;case X.Bool:return new kt;case X.List:return new Tt((t||[])[0]);case X.Struct_:return new V(t||[])}switch(e){case X.Int:{let n=r.type(new wt);return new st(n.isSigned(),n.bitWidth())}case X.FloatingPoint:{let n=r.type(new Kt);return new At(n.precision())}case X.Decimal:{let n=r.type(new _t);return new le(n.scale(),n.precision(),n.bitWidth())}case X.Date:{let n=r.type(new Gt);return new Xt(n.unit())}case X.Time:{let n=r.type(new Mt);return new xt(n.unit(),n.bitWidth())}case X.Timestamp:{let n=r.type(new Lt);return new Nt(n.unit(),n.timezone())}case X.Interval:{let n=r.type(new Zt);return new Qt(n.unit())}case X.Duration:{let n=r.type(new $t);return new Qe(n.unit())}case X.Union:{let n=r.type(new vt);return new ge(n.mode(),n.typeIdsArray()||[],t||[])}case X.FixedSizeBinary:{let n=r.type(new Ht);return new qe(n.byteWidth())}case X.FixedSizeList:{let n=r.type(new Yt);return new Vt(n.listSize(),(t||[])[0])}case X.Map:{let n=r.type(new Jt);return new jt((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${X[e]}" (${e})`)}function Cd(r,t){let e=t.fields.map(s=>O.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,Wd?Sr.Little:Sr.Big),i!==-1&&ot.addCustomMetadata(r,i),ot.endSchema(r)}function Pd(r,t){let e=-1,n=-1,i=-1,s=t.type,o=t.typeId;y.isDictionary(s)?(o=s.dictionary.typeId,i=vo.visit(s,r),n=vo.visit(s.dictionary,r)):n=vo.visit(s,r);let a=(s.children||[]).map(u=>O.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}`),p=r.createString(`${h}`);return Q.startKeyValue(r),Q.addKey(r,d),Q.addValue(r,p),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 kd(r,t){let e=t.nodes||[],n=t.buffers||[];Ft.startNodesVector(r,e.length);for(let o of e.slice().reverse())_e.encode(r,o);let i=r.endVector();Ft.startBuffersVector(r,n.length);for(let o of n.slice().reverse())re.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 Vd(r,t){let e=Ot.encode(r,t.data);return de.startDictionaryBatch(r),de.addId(r,BigInt(t.id)),de.addIsDelta(r,t.isDelta),de.addData(r,e),de.endDictionaryBatch(r)}function jd(r,t){return wn.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function zd(r,t){return bn.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var Wd=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var $a=r=>`Expected ${P[r]} Message in stream, but was null or length 0.`,Ha=r=>`Header pointer of flatbuffer-encoded ${P[r]} Message is null or length 0.`,vu=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,Iu=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Cn=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($a(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=D(this.source.read(t));if(e.byteLength<t)throw new Error(Iu(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(Ha(e));return i}readMetadataLength(){let t=this.source.read(So),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(vu(t,e.byteLength));return{done:!1,value:yt.decode(e)}}},ki=class{constructor(t,e){this.source=t instanceof te?t:hs(t)?new Fr(t,e):new te(t)}[Symbol.asyncIterator](){return this}next(){return g(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?q:t.value===-1&&(t=yield this.readMetadataLength()).done?q:(t=yield this.readMetadata(t.value)).done?q:t})}throw(t){return g(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return g(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return g(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error($a(t));return e.value})}readMessageBody(t){return g(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=D(yield this.source.read(t));if(e.byteLength<t)throw new Error(Iu(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(t=!1){return g(this,void 0,void 0,function*(){let e=P.Schema,n=yield this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(Ha(e));return i})}readMetadataLength(){return g(this,void 0,void 0,function*(){let t=yield this.source.read(So),e=t&&new Ct(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}})}readMetadata(t){return g(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return q;if(e.byteLength<t)throw new Error(vu(t,e.byteLength));return{done:!1,value:yt.decode(e)}})}},Vi=class extends Cn{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof fi?t:new fi(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:yt.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:yt.fromJSON(e,P.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:yt.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($a(t));return e.value}readSchema(){let t=P.Schema,e=this.readMessage(t),n=e?.header();if(!e||!n)throw new Error(Ha(t));return n}},So=4,Ga="ARROW1",Pn=new Uint8Array(Ga.length);for(let r=0;r<Ga.length;r+=1)Pn[r]=Ga.codePointAt(r);function Bo(r,t=0){for(let e=-1,n=Pn.length;++e<n;)if(Pn[e]!==r[t+e])return!1;return!0}var kn=Pn.length,Ya=kn+So,xu=kn*2+So;var gt=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 se(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 gt?t:us(t)?$d(t):hs(t)?Kd(t):se(t)?(()=>g(this,void 0,void 0,function*(){return yield gt.from(yield t)}))():ds(t)||qn(t)||ms(t)||fe(t)?Yd(new te(t)):Hd(new rr(t))}static readAll(t){return t instanceof gt?t.isSync()?Su(t):Bu(t):us(t)||ArrayBuffer.isView(t)||Ie(t)||fs(t)?Su(t):Bu(t)}},ir=class extends gt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return ie(this,arguments,function*(){yield E(yield*yn(ve(this[Symbol.iterator]())))})}},Mr=class extends gt{constructor(t){super(t),this._impl=t}readAll(){var t,e,n,i;return g(this,void 0,void 0,function*(){let s=new Array;try{for(var o=!0,a=ve(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}},ji=class extends Mr{constructor(t){super(t),this._impl=t}},Ao=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 W(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 b(l)):new b(l)).memoize()}return a.memoize()}_loadVectors(t,e,n){return new pi(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},Vn=class extends Ao{constructor(t,e){super(e),this._reader=us(t)?new Vi(this._handle=t):new Cn(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=Au(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)}},jn=class extends Ao{constructor(t,e){super(e),this._reader=new ki(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return g(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return g(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Au(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):q})}return(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):q})}next(){return g(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 g(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},To=class extends Vn{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 hi?t:new hi(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-Ya,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}},Ka=class extends jn{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 g(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 g(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 g(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 g(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Ya,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return fr.decode(i)})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},Za=class extends Vn{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new Zs(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function Au(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Su(r){let t=gt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Bu(r){return ie(this,arguments,function*(){let e=yield E(gt.from(r));try{if(!(yield E(e.open({autoDestroy:!1}))).closed)do yield yield E(e);while(!(yield E(e.reset().open())).closed)}finally{yield E(e.cancel())}})}function $d(r){return new ir(new Za(r))}function Hd(r){let t=r.peek(kn+7&-8);return t&&t.byteLength>=4?Bo(t)?new Lr(new To(r.read())):new ir(new Vn(r)):new ir(new Vn(function*(){}()))}function Yd(r){return g(this,void 0,void 0,function*(){let t=yield r.peek(kn+7&-8);return t&&t.byteLength>=4?Bo(t)?new Lr(new To(yield r.read())):new Mr(new jn(r)):new Mr(new jn(function(){return ie(this,arguments,function*(){})}()))})}function Kd(r){return g(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Fr(r,t);return t>=xu&&Bo(yield e.readAt(0,kn+7&-8))?new ji(new Ka(e)):new Mr(new jn(e))})}var tt=class extends I{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof W?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 b)return this.visitMany(t.data),this;let{type:e}=t;if(!y.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(y.isUnion(e))this.nodes.push(new _e(n,0));else{let{nullCount:i}=t;y.isNull(e)||Le.call(this,i<=0?new Uint8Array(0):Jr(t.offset,n,t.nullBitmap)),this.nodes.push(new _e(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 Le(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new re(this._byteLength,t)),this._byteLength+=t,this}function Zd(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(Le.call(this,i),e.mode===J.Sparse)return Ja.call(this,r);if(e.mode===J.Dense){if(r.offset<=0)return Le.call(this,s),Ja.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);Le.call(this,o),this.visitMany(r.children.map((l,u)=>{let h=e.typeIds[u],d=a[h],p=c[h];return l.slice(d,Math.min(n,p))}))}}return this}function Jd(r){let t;return r.nullCount>=r.length?Le.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?Le.call(this,Jr(r.offset,r.length,t)):Le.call(this,Xr(r.values))}function gr(r){return Le.call(this,r.values.subarray(0,r.length*r.stride))}function Do(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 Le.call(this,gs(-i,t+1,n)),Le.call(this,e.subarray(i,i+o)),this}function Xa(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return Le.call(this,gs(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function Ja(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}tt.prototype.visitBool=Jd;tt.prototype.visitInt=gr;tt.prototype.visitFloat=gr;tt.prototype.visitUtf8=Do;tt.prototype.visitLargeUtf8=Do;tt.prototype.visitBinary=Do;tt.prototype.visitLargeBinary=Do;tt.prototype.visitFixedSizeBinary=gr;tt.prototype.visitDate=gr;tt.prototype.visitTimestamp=gr;tt.prototype.visitTime=gr;tt.prototype.visitDecimal=gr;tt.prototype.visitList=Xa;tt.prototype.visitStruct=Ja;tt.prototype.visitUnion=Zd;tt.prototype.visitInterval=gr;tt.prototype.visitDuration=gr;tt.prototype.visitFixedSizeList=Xa;tt.prototype.visitMap=Xa;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 se(t)?t.then(e=>this.writeAll(e)):fe(t)?qa(this,t):Qa(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&&Vc(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&jc(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 K&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof W&&!(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 W?t instanceof cn||this._writeRecordBatch(t):t instanceof K?this.writeAll(t.batches):Ie(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=yt.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 Fe(a,t.bodyLength,this._position)):t.headerType===P.DictionaryBatch&&this._dictionaryBlocks.push(new Fe(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=D(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(yt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Pn)}_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=yt.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 b([t])),c=new Ot(t.length,s,o),l=new ne(c,e,n),u=yt.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}},br=class extends ln{static writeAll(t,e){let n=new br(e);return se(t)?t.then(i=>n.writeAll(i)):fe(t)?qa(n,t):Qa(n,t)}},wr=class extends ln{static writeAll(t){let e=new wr;return se(t)?t.then(n=>e.writeAll(n)):fe(t)?qa(e,t):Qa(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){let e=fr.encode(new fr(t,H.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Qa(r,t){let e=t;t instanceof K&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function qa(r,t){var e,n,i,s,o,a,c;return g(this,void 0,void 0,function*(){try{for(e=!0,n=ve(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 Tu(r,t){if(fe(r))return Qd(r,t);if(Ie(r))return Xd(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}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){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=D(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 Qd(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 g(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return g(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return g(this,void 0,void 0,function*(){(e?.return&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){return g(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=D(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 Fu(r){return new tc(r)}var tc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=Pc(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Me(s),this._getSize=i!=="bytes"?Du:Ou;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"?Du:Ou}),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)}},Du=r=>{var t;return(t=r?.length)!==null&&t!==void 0?t:0},Ou=r=>{var t;return(t=r?.byteLength)!==null&&t!==void 0?t:0};function Oo(r,t){let e=new er,n=null,i=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield e.close()})},start(a){return g(this,void 0,void 0,function*(){yield o(a,n||(n=yield s()))})},pull(a){return g(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 g(this,void 0,void 0,function*(){return yield(yield gt.from(e)).open(t)})}function o(a,c){return g(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}function Fo(r,t){let e=new this(r),n=new te(e),i=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return g(this,void 0,void 0,function*(){yield s(o)})},start(o){return g(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(o){return g(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 zi(r){let t=gt.from(r);return se(t)?t.then(e=>zi(e)):t.isAsync()?t.readAll().then(e=>new K(e)):new K(t.readAll())}function Mo(r,t="stream"){return(t==="stream"?br:wr).writeAll(r).toUint8Array(!0)}var lp=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},fa),Ra),Da),ha),oa),Ta),la),{compareSchemas:an,compareFields:su,compareTypes:bo});Bt.toDOMStream=Tu;nt.throughDOM=Fu;gt.throughDOM=Oo;Lr.throughDOM=Oo;ir.throughDOM=Oo;ln.throughDOM=Fo;wr.throughDOM=Fo;br.throughDOM=Fo;var Lo=class extends Er{arrowSchema;constructor(t,e){super(t,e),this.arrowSchema=null}getBatch(){let t=super.getBatch();if(t){this.arrowSchema=this.arrowSchema||up(t.schema);let e=fp(this.arrowSchema,t.data),n=new W(this.arrowSchema,w({type:new V(this.arrowSchema.fields),children:e.map(({data:i})=>i[0])}));return{shape:"arrow-table",batchType:"data",data:new K([n]),length:t.length}}return null}};function up(r){let t=[];for(let e in r){let n=r[e];if(n.type===Float32Array){let i=new Map,s=new O(n.name,new me,n.nullable,i);t.push(s)}}if(t.length===0)throw new Error("No arrow convertible fields");return new R(t)}function fp(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}var hp="4.3.1",Wn={dataType:null,batchType:null,name:"Apache Arrow",id:"arrow",module:"arrow",version:hp,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"}}};var dp=["geoarrow.multipolygon","geoarrow.polygon","geoarrow.multilinestring","geoarrow.linestring","geoarrow.multipoint","geoarrow.point","geoarrow.wkb","geoarrow.wkt"],pp="ARROW:extension:name",mp="ARROW:extension:metadata";function ec(r){let t={};for(let e of r.fields){let n=yp(e);n&&(t[e.name]=n)}return t}function yp(r){let t=null,e=r.metadata?.[pp];e&&(e=e.toLowerCase(),e==="wkb"&&(e="geoarrow.wkb"),e==="wkt"&&(e="geoarrow.wkt"),dp.includes(e)?(t=t||{},t.encoding=e):console.warn(`Invalid GeoArrow encoding: ${e}`));let n=r.metadata?.[mp];if(n)try{t=JSON.parse(n)}catch(i){console.warn("Failed to parse GeoArrow metadata",i)}return t||null}var Wi={x:0,y:1,z:2};function No(r,t={}){let{start:e=0,end:n=r.length,plane:i="xy"}=t,s=t.size||2,o=0,a=Wi[i[0]],c=Wi[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=Lu(r,0,o,e,!0,n&&n[0],i),c=[];if(!a||a.next===a.prev)return c;let l,u,h,d,p,v,k;if(s&&(a=xp(r,t,a,e,n,i)),r.length>80*e){d=u=r[0],p=h=r[1];for(let Z=e;Z<o;Z+=e)v=r[Z],k=r[Z+1],v<d&&(d=v),k<p&&(p=k),v>u&&(u=v),k>h&&(h=k);l=Math.max(u-d,h-p),l=l!==0?32767/l:0}return Gi(a,c,e,d,p,l,0),c}function Lu(r,t,e,n,i,s,o){let a,c;s===void 0&&(s=No(r,{start:t,end:e,size:n,plane:o}));let l=Wi[o[0]],u=Wi[o[1]];if(i===s<0)for(a=t;a<e;a+=n)c=Mu(a,r[a+l],r[a+u],c);else for(a=e-n;a>=t;a-=n)c=Mu(a,r[a+l],r[a+u],c);return c&&Ro(c,c.next)&&(Hi(c),c=c.next),c}function un(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(Ro(e,e.next)||ct(e.prev,e,e.next)===0)){if(Hi(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Gi(r,t,e,n,i,s,o){if(!r)return;!o&&s&&Dp(r,n,i,s);let a=r,c,l;for(;r.prev!==r.next;){if(c=r.prev,l=r.next,s?_p(r,n,i,s):wp(r)){t.push(c.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),Hi(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=vp(un(r),t,e),Gi(r,t,e,n,i,s,2)):o===2&&Ip(r,t,e,n,i,s):Gi(un(r),t,e,n,i,s,1);break}}}function wp(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,p=a>c?a>l?a:l:c>l?c:l,v=n.next;for(;v!==t;){if(v.x>=u&&v.x<=d&&v.y>=h&&v.y<=p&&Gn(i,a,s,c,o,l,v.x,v.y)&&ct(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function _p(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,p=a<c?a<l?a:l:c<l?c:l,v=u<h?u<d?u:d:h<d?h:d,k=a>c?a>l?a:l:c>l?c:l,Z=u>h?u>d?u:d:h>d?h:d,et=rc(p,v,t,e,n),pn=rc(k,Z,t,e,n),G=r.prevZ,j=r.nextZ;for(;G&&G.z>=et&&j&&j.z<=pn;){if(G.x>=p&&G.x<=k&&G.y>=v&&G.y<=Z&&G!==i&&G!==o&&Gn(a,u,c,h,l,d,G.x,G.y)&&ct(G.prev,G,G.next)>=0||(G=G.prevZ,j.x>=p&&j.x<=k&&j.y>=v&&j.y<=Z&&j!==i&&j!==o&&Gn(a,u,c,h,l,d,j.x,j.y)&&ct(j.prev,j,j.next)>=0))return!1;j=j.nextZ}for(;G&&G.z>=et;){if(G.x>=p&&G.x<=k&&G.y>=v&&G.y<=Z&&G!==i&&G!==o&&Gn(a,u,c,h,l,d,G.x,G.y)&&ct(G.prev,G,G.next)>=0)return!1;G=G.prevZ}for(;j&&j.z<=pn;){if(j.x>=p&&j.x<=k&&j.y>=v&&j.y<=Z&&j!==i&&j!==o&&Gn(a,u,c,h,l,d,j.x,j.y)&&ct(j.prev,j,j.next)>=0)return!1;j=j.nextZ}return!0}function vp(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!Ro(i,s)&&Nu(i,n,n.next,s)&&$i(i,s)&&$i(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Hi(n),Hi(n.next),n=r=s),n=n.next}while(n!==r);return un(n)}function Ip(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Mp(o,a)){let c=Uu(o,a);o=un(o,o.next),c=un(c,c.next),Gi(o,t,e,n,i,s,0),Gi(c,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function xp(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=Lu(r,l,u,n,!1,i&&i[a+1],s),h===h.next&&(h.steiner=!0),o.push(Fp(h));for(o.sort(Sp),a=0;a<o.length;a++)e=Bp(o[a],e);return e}function Sp(r,t){return r.x-t.x}function Bp(r,t){let e=Ap(r,t);if(!e)return t;let n=Uu(e,r);return un(n,n.next),un(e,e.next)}function Ap(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&&Gn(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),$i(e,r)&&(h<u||h===u&&(e.x>o.x||e.x===o.x&&Tp(o,e)))&&(o=e,u=h)),e=e.next;while(e!==a);return o}function Tp(r,t){return ct(r.prev,r,t.prev)<0&&ct(t.next,r,r.next)<0}function Dp(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,Op(i)}function Op(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 Fp(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 Gn(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 Mp(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Lp(r,t)&&($i(r,t)&&$i(t,r)&&Np(r,t)&&(ct(r.prev,r,t.prev)||ct(r,t.prev,t))||Ro(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 Ro(r,t){return r.x===t.x&&r.y===t.y}function Nu(r,t,e,n){let i=Eo(ct(r,t,e)),s=Eo(ct(r,t,n)),o=Eo(ct(e,n,r)),a=Eo(ct(e,n,t));return!!(i!==s&&o!==a||i===0&&Uo(r,e,t)||s===0&&Uo(r,n,t)||o===0&&Uo(e,r,n)||a===0&&Uo(e,t,n))}function Uo(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 Eo(r){return r>0?1:r<0?-1:0}function Lp(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&&Nu(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function $i(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 Np(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 Uu(r,t){let e=new Yi(r.i,r.x,r.y),n=new Yi(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 Mu(r,t,e,n){let i=new Yi(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 Hi(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 Yi=class{constructor(t,e,n){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=t,this.x=e,this.y=n}};function $n(r,t,e){switch(r.type){case"Point":return kp(r,t,e);case"LineString":return Pp(r,t,e);case"Polygon":return Cu(r,t,e);default:let n=r;throw new Error(`Unsupported geometry type: ${n?.type}`)}}function Cu(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=Co(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=Cu(r,l,u).coordinates;a.push(h)}return{type:"MultiPolygon",coordinates:a}}function Pp(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:Co(n,i[0],i[1])};let o=[];for(let a=0;a<i.length-1;a++){let c=Co(n,i[a],i[a+1]);o.push(c)}return{type:"MultiLineString",coordinates:o}}function kp(r,t,e){let{positions:n}=r,i=Co(n,t,e);return i.length>1?{type:"MultiPoint",coordinates:i}:{type:"Point",coordinates:i[0]}}function Co(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 Hn(r){return ic(r)}function Pu(r){return Ki(r)}function ic(r){return{fields:r.fields.map(t=>fn(t)),metadata:Po(r.metadata)}}function Ki(r){return new R(r.fields.map(t=>hn(t)),ko(r.metadata))}function Po(r){return Object.fromEntries(r)}function ko(r){return r?new Map(Object.entries(r)):new Map}function fn(r){return{name:r.name,type:sc(r.type),nullable:r.nullable,metadata:Po(r.metadata)}}function hn(r){return new O(r.name,oc(r.type),r.nullable,ko(r.metadata))}function sc(r){switch(r.constructor){case ut:return"null";case ce:return"binary";case kt:return"bool";case st:let t=r;return`${t.isSigned?"u":""}int${t.bitWidth}`;case Ge:return"int8";case $e:return"int16";case It:return"int32";case pe:return"int64";case He:return"uint8";case Ye:return"uint16";case Ke:return"uint32";case Ze:return"uint64";case At:switch(r.precision){case z.HALF:return"float16";case z.SINGLE:return"float32";case z.DOUBLE:return"float64";default:return"float16"}case Br:return"float16";case me:return"float32";case ye:return"float64";case Pt:return"utf8";case le:let n=r;return{type:"decimal",bitWidth:n.bitWidth,precision:n.precision,scale:n.scale};case Xt:return r.unit===rt.DAY?"date-day":"date-millisecond";case Pr:return"date-day";case cr:return"date-millisecond";case xt:switch(r.unit){case m.SECOND:return"time-second";case m.MILLISECOND:return"time-millisecond";case m.MICROSECOND:return"time-microsecond";case m.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 m.SECOND:return"timestamp-second";case m.MILLISECOND:return"timestamp-millisecond";case m.MICROSECOND:return"timestamp-microsecond";case m.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 Qt:switch(r.unit){case it.DAY_TIME:return"interval-daytime";case it.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(p=>fn(p))};case Tt:let u=r.valueField;return{type:"list",children:[fn(u)]};case Vt:let h=r;return{type:"fixed-size-list",listSize:h.listSize,children:[fn(h.children[0])]};case V:return{type:"struct",children:r.children.map(p=>fn(p))};default:throw new Error(`arrow type not supported: ${r.constructor.name}`)}}function oc(r){if(typeof r=="object")switch(r.type){case"decimal":return new le(r.precision,r.scale,r.bitWidth);case"map":let t=r.children.map(i=>hn(i));return new jt(t,r.keysSorted);case"list":let e=hn(r.children[0]);return new Tt(e);case"fixed-size-list":let n=hn(r.children[0]);return new Vt(r.listSize,n);case"struct":return t=r.children.map(i=>hn(i)),new V(t);default:throw new Error("array type not supported")}switch(r){case"null":return new ut;case"binary":return new ce;case"bool":return new kt;case"int8":return new Ge;case"int16":return new $e;case"int32":return new It;case"int64":return new pe;case"uint8":return new He;case"uint16":return new Ye;case"uint32":return new Ke;case"uint64":return new Ze;case"float16":return new Br;case"float32":return new me;case"float64":return new ye;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")}}var Vo="4.3.1";var ku=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,Vu=new RegExp("^"+ku.source+"(\\s"+ku.source+"){1,}"),ac=["POINT(","LINESTRING(","POLYGON(","MULTIPOINT(","MULTILINESTRING(","MULTIPOLYGON(","GEOMETRYCOLLECTION("];function ju(r){return ac.some(t=>r.startsWith(t))}function cc(r,t){return Vp(r,t)}function Vp(r,t){let e=r.split(";"),n=e.pop(),i=(e.shift()||"").split("=").pop(),o=zu({parts:e,_:n,i:0});return t?.wkt?.crs?jp(o,i):o}function zu(r){return zp(r)||Gp(r)||Hp(r)||Wp(r)||$p(r)||Yp(r)||Kp(r)}function jp(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 zp(r){if(!ht(/^(POINT(\sz)?)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;let t=Wu(r);return!t||(Wt(r),!ht(/^(\))/,r))?null:{type:"Point",coordinates:t[0]}}function Wp(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=jo(r);return e?(Wt(r),{type:"MultiPoint",coordinates:e}):null}function Gp(r){if(!ht(/^(LINESTRING(\sz)?)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;let t=Wu(r);return!t||!ht(/^(\))/,r)?null:{type:"LineString",coordinates:t}}function $p(r){if(!ht(/^(MULTILINESTRING)/i,r))return null;Wt(r);let t=jo(r);return t?(Wt(r),{type:"MultiLineString",coordinates:t}):null}function Hp(r){if(!ht(/^(POLYGON(\sz)?)/i,r))return null;Wt(r);let t=jo(r);return t?{type:"Polygon",coordinates:t}:null}function Yp(r){if(!ht(/^(MULTIPOLYGON)/i,r))return null;Wt(r);let t=jo(r);return t?{type:"MultiPolygon",coordinates:t}:null}function Kp(r){let t=[],e;if(!ht(/^(GEOMETRYCOLLECTION)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;for(;e=zu(r);)t.push(e),Wt(r),ht(/^(,)/,r),Wt(r);return ht(/^(\))/,r)?{type:"GeometryCollection",geometries:t}:null}function jo(r){Wt(r);let t=0,e=[],n=[e],i=e,s;for(;s=ht(/^(\()/,r)||ht(/^(\))/,r)||ht(/^(,)/,r)||ht(Vu,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 Wu(r){let t=[],e,n;for(;n=ht(Vu,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 Gu={dataType:null,batchType:null,name:"WKT (Well-Known Text)",id:"wkt",module:"wkt",version:Vo,worker:!0,extensions:["wkt"],mimeTypes:["text/plain"],category:"geometry",text:!0,tests:ac,testText:ju,options:{wkt:{shape:"geojson-geometry",crs:!0}}},lc={...Gu,parse:async(r,t)=>cc(new TextDecoder().decode(r),t),parseTextSync:(r,t)=>cc(r,t)};var _r;(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"})(_r||(_r={}));function $u(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 Hu(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 uc(r,t){let e=Zp(r,t),n=t?.wkb?.shape||"binary-geometry";switch(n){case"binary-geometry":return e;case"geojson-geometry":return $n(e);case"geometry":return console.error('WKBLoader: "geometry" shape is deprecated, use "binary-geometry" instead'),$n(e);default:throw new Error(n)}}function Zp(r,t){let e=new DataView(r),n=Hu(e),{geometryType:i,dimensions:s,littleEndian:o}=n,a=n.byteOffset;switch(i){case _r.Point:return Yu(e,a,s,o).geometry;case _r.LineString:return fc(e,a,s,o).geometry;case _r.Polygon:return Ku(e,a,s,o).geometry;case _r.MultiPoint:let h=Jp(e,a,s,o);return h.type="Point",h;case _r.MultiLineString:let d=Xp(e,a,s,o);return d.type="LineString",d;case _r.MultiPolygon:let p=Qp(e,a,s,o);return p.type="Polygon",p;default:throw new Error(`WKB: Unsupported geometry type: ${i}`)}}function Yu(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 fc(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 hc=r=>t=>r+=t;function Ku(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let l=0;l<i;l++){let u=fc(r,t,e,n),{positions:h}=u.geometry;t=u.offset,s.push(h.value)}let o=new Float64Array(zo(s).buffer),a=[0];o.length>0&&a.push(o.length/e);let c=s.map(l=>l.length/e).map(hc(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 Jp(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=Yu(r,t,e,a);t=c.offset,s.push(c.geometry)}return qp(s,e)}function Xp(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=fc(r,t,e,a);t=c.offset,s.push(c.geometry)}return tm(s,e)}function Qp(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=Ku(r,t,e,a);t=c.offset,s.push(c.geometry)}return em(s,e)}function qp(r,t){let e=r.map(i=>i.positions.value);return{type:"Point",positions:{value:new Float64Array(zo(e).buffer),size:t}}}function tm(r,t){let e=r.map(s=>s.positions.value),n=new Float64Array(zo(e).buffer),i=e.map(s=>s.length/t).map(hc(0));return i.unshift(0),{type:"LineString",positions:{value:n,size:t},pathIndices:{value:new Uint32Array(i),size:1}}}function em(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(zo(e).buffer),s=e.map(a=>a.length/t).map(hc(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 zo(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 Zu={dataType:null,batchType:null,name:"WKB",id:"wkb",module:"wkt",version:Vo,worker:!0,category:"geometry",extensions:["wkb"],mimeTypes:[],tests:[$u],options:{wkb:{shape:"binary-geometry"}}},dc={...Zu,parse:async r=>uc(r),parseSync:uc};function Wo(r,t){if(t=t?.toLowerCase(),!t||!r)return null;let e;switch(t){case"geoarrow.multipolygon":e=im(r);break;case"geoarrow.polygon":e=sm(r);break;case"geoarrow.multipoint":e=om(r);break;case"geoarrow.point":e=am(r);break;case"geoarrow.multilinestring":e=cm(r);break;case"geoarrow.linestring":e=lm(r);break;case"geoarrow.wkb":e=rm(r);break;case"geoarrow.wkt":e=nm(r);break;default:throw Error(`GeoArrow encoding not supported ${t}`)}return e}function rm(r){let t=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),e=dc.parseSync?.(t);return $n(e)}function nm(r){let t=r;return lc.parseTextSync?.(t)}function im(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 sm(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 om(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 am(r){return{type:"Point",coordinates:Array.from(r)}}function cm(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 lm(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 Yn(r,t){switch(t){case"arrow-table":return um(r);case"array-row-table":return fm(r);case"object-row-table":return hm(r);case"columnar-table":return pc(r);case"geojson-table":return dm(r);default:throw new Error(t)}}function um(r){return{shape:"arrow-table",schema:Hn(r.schema),data:r}}function fm(r){let t=pc(r);return ls(t,"array-row-table")}function hm(r){let t=pc(r);return ls(t,"object-row-table")}function pc(r){let t={};for(let n of r.schema.fields){let s=r.getChild(n.name)?.toArray();t[n.name]=s}return{shape:"columnar-table",schema:Hn(r.schema),data:t}}function dm(r){let t=Hn(r.schema),e=ec(t),n=e.geometry.encoding,i=[],s=r.schema.fields.map(c=>c.name).filter(c=>!(c in e)),o=r.select(s),a=r.getChild("geometry");for(let c=0;c<r.numRows;c++){let l=a?.get(c),u=Wo(l,n);if(u){let h=o.get(c)?.toJSON()||{};i.push({type:"Feature",geometry:u,properties:h})}}return{shape:"geojson-table",type:"FeatureCollection",schema:t,features:i}}function Zi(r,t){let e=t?.shape||"arrow-table",n=zi([new Uint8Array(r)]);return Yn(n,e)}function Go(r,t){async function*e(){let n=gt.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 K([s]),length:s.data.length};break}}return e()}var Ju={...Wn,parse:async(r,t)=>Zi(r,t?.arrow),parseSync:(r,t)=>Zi(r,t?.arrow),parseInBatches:Go};function mc(r){let t={};for(let i of r){let s=pm(i.array,i.type);t[i.name]=s}let e=new K(t);return Mo(e)}function pm(r,t){switch(t){case Ur.DATE:return Pi(r);case Ur.FLOAT:default:return Pi(r)}}var mm="4.3.1",Xu={name:"Apache Arrow",id:"arrow",module:"arrow",version:mm,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 mc(t)},encodeSync(r,t){return mc(r)}};var $o={...Wn,options:{arrow:{shape:"arrow-table"}}};function yc(r,t){let e=Zi(r,{shape:"arrow-table"});switch(t?.shape){case"geojson-table":return Yn(e.data,"geojson-table");default:return e}}function Qu(r){return Go(r)}var qu={...$o,parse:async(r,t)=>yc(r,t?.arrow),parseSync:(r,t)=>yc(r,t?.arrow),parseInBatches:Qu};function tf(r,t){switch(r.shape){case"arrow-table":return r.data;case"columnar-table":default:let e=ym(r,t);return new K(e)}}function*ym(r,t){let e=Ki(r.schema),n=xr(r),i=Jo(r),s=t?.batchSize||n,o=e?.fields.map(l=>Me(l)),a=new V(e.fields),c=0;for(let l=0;l<n;l++)for(let u=0;u<i;++u){let h=Qo(r,l,u);if(o[u].append(h),c++,c>=s){let p=o.map(k=>k.flush()),v=new U(a,0,c,0,void 0,p);yield new W(e,v),c=0}}if(c>0){let l=o.map(h=>h.flush()),u=new U(a,0,c,0,void 0,l);yield new W(e,u),c=0}o.map(l=>l.finish())}function Ho(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 Kn;(function(r){r.points="points",r.lines="lines",r.polygons="polygons"})(Kn||(Kn={}));function Ji(){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 ef(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:p}=bm(c,t,e),v=new Uint32Array(l.length);for(let Z=0;Z<l.length;Z++)v[Z]=l[Z]+o;let k={globalFeatureIds:{value:v,size:1},positions:{value:u,size:h},featureIds:{value:l,size:1},properties:[...Array(c.length).keys()].map(Z=>({index:Z+o}))};o+=c.length,a.push({shape:"binary-feature-collection",points:{type:"Point",...Ji(),...n.point?k:{}},lines:{type:"LineString",...Ji(),...n.line?k:{},pathIndices:{value:n.line?d:new Uint16Array(0),size:1}},polygons:{type:"Polygon",...Ji(),...n.polygon?k:{},polygonIndices:{value:n.polygon?d:new Uint16Array(0),size:1},primitivePolygonIndices:{value:n.polygon?d:new Uint16Array(0),size:1},...p?{triangles:{value:p,size:1}}:{}}}),s=Ho(u,h,s)}),{binaryGeometries:a,bounds:s,featureTypes:n,...e?.calculateMeanCenters?{meanCenters:gc(a)}:{}}}function gc(r){let t=[];return r.forEach(e=>{let n=null;e.points&&e.points.positions.value.length>0?n=Kn.points:e.lines&&e.lines.positions.value.length>0?n=Kn.lines:e.polygons&&e.polygons.positions.value.length>0&&(n=Kn.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;gm(s,o,a,n,c).forEach(u=>{t.push(u)})}}),t}function gm(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===Kn.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 bm(r,t,e){switch(t){case"geoarrow.point":case"geoarrow.multipoint":return vm(r,t);case"geoarrow.linestring":case"geoarrow.multilinestring":return _m(r,t);case"geoarrow.polygon":case"geoarrow.multipolygon":return wm(r,t,e);default:throw Error("invalid geoarrow encoding")}}function bc(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 p=0;p<d.length;p++)s.push(d[p]+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 wm(r,t,e){let n=t==="geoarrow.multipolygon",i=n?r.children[0]:r,s=i.valueOffsets,o=n?r.valueOffsets.map(et=>s.at(et)||et):r.valueOffsets,a=i.children[0],c=a.children[0],l=c.children[0],u=c.stride,h=a.valueOffsets,d=l.values,p=new Uint16Array(s.length);for(let et=0;et<s.length;et++)p[et]=h[s[et]];let v=d.length/u,k=new Uint32Array(v);for(let et=0;et<o.length-1;et++){let pn=h[o[et]],G=h[o[et+1]];for(let j=pn;j<G;j++)k[j]=et}let Z=e?.triangulate?bc(p,h,d,u):null;return{featureIds:k,nDim:u,flatCoordinateArray:d,geomOffset:h,geometryIndicies:p,...e?.triangulate&&Z?{triangles:Z}:{}}}function _m(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 p=0;p<d.length-1;p++){let v=a[d[p]],k=a[d[p+1]];for(let Z=v;Z<k;Z++)h[Z]=p}}else for(let d=0;d<r.length;d++){let p=a[d],v=a[d+1];for(let k=p;k<v;k++)h[k]=d}return{featureIds:h,flatCoordinateArray:c,nDim:o,geomOffset:a,geometryIndicies:l}}function vm(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 p=h[d],v=h[d+1];for(let k=p;k<v;k++)u[k]=d}}else for(let h=0;h<r.length;h++)u[h]=h;return{featureIds:u,flatCoordinateArray:o,nDim:s,geomOffset:c,geometryIndicies:a}}function Xi(r,t=!1){if("data"in r)return new b(r.data.map(s=>Xi(s,t)));let e=[];for(let s of r.children)e.push(Xi(s,t));let n;r.dictionary!==void 0&&(n=Xi(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 U(r.type,r.offset,r.length,r._nullCount,i,e,n)}function Im(r){return!(r.byteOffset===0&&r.byteLength===r.buffer.byteLength)}function Yo(r,t){return r===void 0||!t&&!Im(r)?r:r.slice()}var rf="latest";function xm(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.1"),globalThis._loadersgl_.version}var wc=xm();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},lA=or.self||or.window||or.global||{},uA=or.window||or.self||or.global||{},fA=or.global||or.self||or.window||{},hA=or.document||{};var vr=typeof process!="object"||String(process)!=="[object process]"||process.browser;var sf=typeof window<"u"&&typeof window.orientation<"u",nf=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),dA=nf&&parseFloat(nf[1])||0;var Qi=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 Zn=class{terminate(){}};var _c=new Map;function of(r){sr(r.source&&!r.url||!r.source&&r.url);let t=_c.get(r.source||r.url);return t||(r.url&&(t=Sm(r.url),_c.set(r.url,t)),r.source&&(t=af(r.source),_c.set(r.source,t))),sr(t),t}function Sm(r){if(!r.startsWith("http"))return r;let t=Bm(r);return af(t)}function af(r){let t=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(t)}function Bm(r){return`try {
16
+ ]`}concat(...t){let e=this.schema,n=this.data.concat(t.flatMap(({data:i})=>i));return new K(e,n.map(i=>new W(e,i)))}slice(t,e){let n=this.schema;[t,e]=ai({length:this.numRows},t,e);let i=Gs(this.data,this._offsets,t,e);return new K(n,i.map(s=>new W(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 b(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 b([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]=_o(n,a)}return new K(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 K(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(p=>p.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 K(..._o(s,o))}};ou=Symbol.toStringTag;K[ou]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Tn(ui),r.get=Tn(pt.getVisitFn(f.Struct)),r.set=$s(Dt.getVisitFn(f.Struct)),r.indexOf=Hs(qr.getVisitFn(f.Struct)),"Table"))(K.prototype);var cu,W=class{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof R))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 U))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=au(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]=O.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new R(n),a=w({type:new V(n),length:s,children:i,nullCount:0});[this.schema,this.data]=au(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=lu(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 pt.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 Dn.visit(new b([this.data]))}toArray(){return[...this]}concat(...t){return new K(this.schema,[this,...t])}slice(t,e){let[n]=new b([this.data]).slice(t,e).data;return new W(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 b([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 b([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 R(s,new Map(this.schema.metadata)),i=w({type:new V(s),children:o})}return new W(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 W(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 W(e,i)}};cu=Symbol.toStringTag;W[cu]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(W.prototype);function au(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 lu(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)||[]])lu(a.children,l?.children,e);if(y.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 W{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):H.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,H.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 za=class extends I{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return je.startNull(e),je.endNull(e)}visitInt(t,e){return wt.startInt(e),wt.addBitWidth(e,t.bitWidth),wt.addIsSigned(e,t.isSigned),wt.endInt(e)}visitFloat(t,e){return Kt.startFloatingPoint(e),Kt.addPrecision(e,t.precision),Kt.endFloatingPoint(e)}visitBinary(t,e){return Re.startBinary(e),Re.endBinary(e)}visitLargeBinary(t,e){return Pe.startLargeBinary(e),Pe.endLargeBinary(e)}visitBool(t,e){return Ce.startBool(e),Ce.endBool(e)}visitUtf8(t,e){return We.startUtf8(e),We.endUtf8(e)}visitLargeUtf8(t,e){return ke.startLargeUtf8(e),ke.endLargeUtf8(e)}visitDecimal(t,e){return _t.startDecimal(e),_t.addScale(e,t.scale),_t.addPrecision(e,t.precision),_t.addBitWidth(e,t.bitWidth),_t.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 Ve.startList(e),Ve.endList(e)}visitStruct(t,e){return ze.startStruct_(e),ze.endStruct_(e)}visitUnion(t,e){vt.startTypeIdsVector(e,t.typeIds.length);let n=vt.createTypeIdsVector(e,t.typeIds);return vt.startUnion(e),vt.addMode(e,t.mode),vt.addTypeIds(e,n),vt.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return ae.startDictionaryEncoding(e),ae.addId(e,BigInt(t.id)),ae.addIsOrdered(e,t.isOrdered),n!==void 0&&ae.addIndexType(e,n),ae.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)}},vo=new za;function du(r,t=new Map){return new R(Id(r,t),Io(r.metadata),t)}function Wa(r){return new Ot(r.count,mu(r.columns),yu(r.columns))}function pu(r){return new ne(Wa(r.data),r.id,r.isDelta)}function Id(r,t){return(r.fields||[]).filter(Boolean).map(e=>O.fromJSON(e,t))}function uu(r,t){return(r.children||[]).filter(Boolean).map(e=>O.fromJSON(e,t))}function mu(r){return(r||[]).reduce((t,e)=>[...t,new _e(e.count,xd(e.VALIDITY)),...mu(e.children)],[])}function yu(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new re(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new re(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new re(t.length,i.OFFSET.length)),i.DATA&&t.push(new re(t.length,i.DATA.length)),t=yu(i.children,t)}return t}function xd(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function gu(r,t){let e,n,i,s,o,a;return!t||!(s=r.dictionary)?(o=hu(r,uu(r,t)),i=new O(r.name,o,r.nullable,Io(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?fu(n):new It,a=new Ut(t.get(e),n,e,s.isOrdered),i=new O(r.name,a,r.nullable,Io(r.metadata))):(n=(n=s.indexType)?fu(n):new It,t.set(e,o=hu(r,uu(r,t))),a=new Ut(o,n,e,s.isOrdered),i=new O(r.name,a,r.nullable,Io(r.metadata))),i||null}function Io(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function fu(r){return new st(r.isSigned,r.bitWidth)}function hu(r,t){let e=r.type.name;switch(e){case"NONE":return new ut;case"null":return new ut;case"binary":return new ce;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 st(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new At(z[n.precision])}case"decimal":{let n=r.type;return new le(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new Xt(rt[n.unit])}case"time":{let n=r.type;return new xt(m[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new Nt(m[n.unit],n.timezone)}case"interval":{let n=r.type;return new Qt(it[n.unit])}case"duration":{let n=r.type;return new Qe(m[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new ge(J[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 Sd=ar,Bd=Ct,yt=class{static fromJSON(t,e){let n=new yt(0,H.V5,e);return n._createHeader=Ad(t,e),n}static decode(t){t=new Bd(D(t));let e=ft.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new yt(n,i,s);return o._createHeader=Td(e,s),o}static encode(t){let e=new Sd,n=-1;return t.isSchema()?n=R.encode(e,t.header()):t.isRecordBatch()?n=Ot.encode(e,t.header()):t.isDictionaryBatch()&&(n=ne.encode(e,t.header())),ft.startMessage(e),ft.addVersion(e,H.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 R)return new yt(0,H.V5,P.Schema,t);if(t instanceof Ot)return new yt(e,H.V5,P.RecordBatch,t);if(t instanceof ne)return new yt(e,H.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)}},ne=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)}},re=class{constructor(t,e){this.offset=at(t),this.length=at(e)}},_e=class{constructor(t,e){this.length=at(t),this.nullCount=at(e)}};function Ad(r,t){return()=>{switch(t){case P.Schema:return R.fromJSON(r);case P.RecordBatch:return Ot.fromJSON(r);case P.DictionaryBatch:return ne.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${P[t]}, type: ${t} }`)}}function Td(r,t){return()=>{switch(t){case P.Schema:return R.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 ne.decode(r.header(new de),r.version())}throw new Error(`Unrecognized Message type: { name: ${P[t]}, type: ${t} }`)}}O.encode=Pd;O.decode=Rd;O.fromJSON=gu;R.encode=Cd;R.decode=Dd;R.fromJSON=du;Ot.encode=kd;Ot.decode=Od;Ot.fromJSON=Wa;ne.encode=Vd;ne.decode=Fd;ne.fromJSON=pu;_e.encode=jd;_e.decode=Ld;re.encode=zd;re.decode=Md;function Dd(r,t=new Map,e=H.V5){let n=Ed(r,t);return new R(n,xo(r),t,e)}function Od(r,t=H.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Ot(r.length(),Nd(r),Ud(r,t))}function Fd(r,t=H.V5){return new ne(Ot.decode(r.data(),t),r.id(),r.isDelta())}function Md(r){return new re(r.offset(),r.length())}function Ld(r){return new _e(r.length(),r.nullCount())}function Nd(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=_e.decode(e));return t}function Ud(r,t){let e=[];for(let n,i=-1,s=-1,o=r.buffersLength();++i<o;)(n=r.buffers(i))&&(t<H.V4&&(n.bb_pos+=8*(i+1)),e[++s]=re.decode(n));return e}function Ed(r,t){let e=[];for(let n,i=-1,s=-1,o=r.fieldsLength();++i<o;)(n=r.fields(i))&&(e[++s]=O.decode(n,t));return e}function bu(r,t){let e=[];for(let n,i=-1,s=-1,o=r.childrenLength();++i<o;)(n=r.children(i))&&(e[++s]=O.decode(n,t));return e}function Rd(r,t){let e,n,i,s,o,a;return!t||!(a=r.dictionary())?(i=_u(r,bu(r,t)),n=new O(r.name(),i,r.nullable(),xo(r))):t.has(e=at(a.id()))?(s=(s=a.indexType())?wu(s):new It,o=new Ut(t.get(e),s,e,a.isOrdered()),n=new O(r.name(),o,r.nullable(),xo(r))):(s=(s=a.indexType())?wu(s):new It,t.set(e,i=_u(r,bu(r,t))),o=new Ut(i,s,e,a.isOrdered()),n=new O(r.name(),o,r.nullable(),xo(r))),n||null}function xo(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 wu(r){return new st(r.isSigned(),r.bitWidth())}function _u(r,t){let e=r.typeType();switch(e){case X.NONE:return new ut;case X.Null:return new ut;case X.Binary:return new ce;case X.LargeBinary:return new Je;case X.Utf8:return new Pt;case X.LargeUtf8:return new Xe;case X.Bool:return new kt;case X.List:return new Tt((t||[])[0]);case X.Struct_:return new V(t||[])}switch(e){case X.Int:{let n=r.type(new wt);return new st(n.isSigned(),n.bitWidth())}case X.FloatingPoint:{let n=r.type(new Kt);return new At(n.precision())}case X.Decimal:{let n=r.type(new _t);return new le(n.scale(),n.precision(),n.bitWidth())}case X.Date:{let n=r.type(new Gt);return new Xt(n.unit())}case X.Time:{let n=r.type(new Mt);return new xt(n.unit(),n.bitWidth())}case X.Timestamp:{let n=r.type(new Lt);return new Nt(n.unit(),n.timezone())}case X.Interval:{let n=r.type(new Zt);return new Qt(n.unit())}case X.Duration:{let n=r.type(new $t);return new Qe(n.unit())}case X.Union:{let n=r.type(new vt);return new ge(n.mode(),n.typeIdsArray()||[],t||[])}case X.FixedSizeBinary:{let n=r.type(new Ht);return new qe(n.byteWidth())}case X.FixedSizeList:{let n=r.type(new Yt);return new Vt(n.listSize(),(t||[])[0])}case X.Map:{let n=r.type(new Jt);return new jt((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${X[e]}" (${e})`)}function Cd(r,t){let e=t.fields.map(s=>O.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,Wd?Sr.Little:Sr.Big),i!==-1&&ot.addCustomMetadata(r,i),ot.endSchema(r)}function Pd(r,t){let e=-1,n=-1,i=-1,s=t.type,o=t.typeId;y.isDictionary(s)?(o=s.dictionary.typeId,i=vo.visit(s,r),n=vo.visit(s.dictionary,r)):n=vo.visit(s,r);let a=(s.children||[]).map(u=>O.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}`),p=r.createString(`${h}`);return Q.startKeyValue(r),Q.addKey(r,d),Q.addValue(r,p),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 kd(r,t){let e=t.nodes||[],n=t.buffers||[];Ft.startNodesVector(r,e.length);for(let o of e.slice().reverse())_e.encode(r,o);let i=r.endVector();Ft.startBuffersVector(r,n.length);for(let o of n.slice().reverse())re.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 Vd(r,t){let e=Ot.encode(r,t.data);return de.startDictionaryBatch(r),de.addId(r,BigInt(t.id)),de.addIsDelta(r,t.isDelta),de.addData(r,e),de.endDictionaryBatch(r)}function jd(r,t){return wn.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function zd(r,t){return bn.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var Wd=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var $a=r=>`Expected ${P[r]} Message in stream, but was null or length 0.`,Ha=r=>`Header pointer of flatbuffer-encoded ${P[r]} Message is null or length 0.`,vu=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,Iu=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Cn=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($a(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=D(this.source.read(t));if(e.byteLength<t)throw new Error(Iu(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(Ha(e));return i}readMetadataLength(){let t=this.source.read(So),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(vu(t,e.byteLength));return{done:!1,value:yt.decode(e)}}},ki=class{constructor(t,e){this.source=t instanceof te?t:hs(t)?new Fr(t,e):new te(t)}[Symbol.asyncIterator](){return this}next(){return g(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?q:t.value===-1&&(t=yield this.readMetadataLength()).done?q:(t=yield this.readMetadata(t.value)).done?q:t})}throw(t){return g(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return g(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return g(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error($a(t));return e.value})}readMessageBody(t){return g(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=D(yield this.source.read(t));if(e.byteLength<t)throw new Error(Iu(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(t=!1){return g(this,void 0,void 0,function*(){let e=P.Schema,n=yield this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(Ha(e));return i})}readMetadataLength(){return g(this,void 0,void 0,function*(){let t=yield this.source.read(So),e=t&&new Ct(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}})}readMetadata(t){return g(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return q;if(e.byteLength<t)throw new Error(vu(t,e.byteLength));return{done:!1,value:yt.decode(e)}})}},Vi=class extends Cn{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof fi?t:new fi(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:yt.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:yt.fromJSON(e,P.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:yt.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($a(t));return e.value}readSchema(){let t=P.Schema,e=this.readMessage(t),n=e?.header();if(!e||!n)throw new Error(Ha(t));return n}},So=4,Ga="ARROW1",Pn=new Uint8Array(Ga.length);for(let r=0;r<Ga.length;r+=1)Pn[r]=Ga.codePointAt(r);function Bo(r,t=0){for(let e=-1,n=Pn.length;++e<n;)if(Pn[e]!==r[t+e])return!1;return!0}var kn=Pn.length,Ya=kn+So,xu=kn*2+So;var gt=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 se(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 gt?t:us(t)?$d(t):hs(t)?Kd(t):se(t)?(()=>g(this,void 0,void 0,function*(){return yield gt.from(yield t)}))():ds(t)||qn(t)||ms(t)||fe(t)?Yd(new te(t)):Hd(new rr(t))}static readAll(t){return t instanceof gt?t.isSync()?Su(t):Bu(t):us(t)||ArrayBuffer.isView(t)||Ie(t)||fs(t)?Su(t):Bu(t)}},ir=class extends gt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return ie(this,arguments,function*(){yield E(yield*yn(ve(this[Symbol.iterator]())))})}},Mr=class extends gt{constructor(t){super(t),this._impl=t}readAll(){var t,e,n,i;return g(this,void 0,void 0,function*(){let s=new Array;try{for(var o=!0,a=ve(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}},ji=class extends Mr{constructor(t){super(t),this._impl=t}},Ao=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 W(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 b(l)):new b(l)).memoize()}return a.memoize()}_loadVectors(t,e,n){return new pi(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},Vn=class extends Ao{constructor(t,e){super(e),this._reader=us(t)?new Vi(this._handle=t):new Cn(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=Au(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)}},jn=class extends Ao{constructor(t,e){super(e),this._reader=new ki(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return g(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return g(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Au(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):q})}return(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):q})}next(){return g(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 g(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},To=class extends Vn{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 hi?t:new hi(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-Ya,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}},Ka=class extends jn{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 g(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 g(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 g(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 g(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Ya,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return fr.decode(i)})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},Za=class extends Vn{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new Zs(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function Au(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Su(r){let t=gt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Bu(r){return ie(this,arguments,function*(){let e=yield E(gt.from(r));try{if(!(yield E(e.open({autoDestroy:!1}))).closed)do yield yield E(e);while(!(yield E(e.reset().open())).closed)}finally{yield E(e.cancel())}})}function $d(r){return new ir(new Za(r))}function Hd(r){let t=r.peek(kn+7&-8);return t&&t.byteLength>=4?Bo(t)?new Lr(new To(r.read())):new ir(new Vn(r)):new ir(new Vn(function*(){}()))}function Yd(r){return g(this,void 0,void 0,function*(){let t=yield r.peek(kn+7&-8);return t&&t.byteLength>=4?Bo(t)?new Lr(new To(yield r.read())):new Mr(new jn(r)):new Mr(new jn(function(){return ie(this,arguments,function*(){})}()))})}function Kd(r){return g(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Fr(r,t);return t>=xu&&Bo(yield e.readAt(0,kn+7&-8))?new ji(new Ka(e)):new Mr(new jn(e))})}var tt=class extends I{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof W?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 b)return this.visitMany(t.data),this;let{type:e}=t;if(!y.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(y.isUnion(e))this.nodes.push(new _e(n,0));else{let{nullCount:i}=t;y.isNull(e)||Le.call(this,i<=0?new Uint8Array(0):Jr(t.offset,n,t.nullBitmap)),this.nodes.push(new _e(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 Le(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new re(this._byteLength,t)),this._byteLength+=t,this}function Zd(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(Le.call(this,i),e.mode===J.Sparse)return Ja.call(this,r);if(e.mode===J.Dense){if(r.offset<=0)return Le.call(this,s),Ja.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);Le.call(this,o),this.visitMany(r.children.map((l,u)=>{let h=e.typeIds[u],d=a[h],p=c[h];return l.slice(d,Math.min(n,p))}))}}return this}function Jd(r){let t;return r.nullCount>=r.length?Le.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?Le.call(this,Jr(r.offset,r.length,t)):Le.call(this,Xr(r.values))}function gr(r){return Le.call(this,r.values.subarray(0,r.length*r.stride))}function Do(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 Le.call(this,gs(-i,t+1,n)),Le.call(this,e.subarray(i,i+o)),this}function Xa(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return Le.call(this,gs(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function Ja(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}tt.prototype.visitBool=Jd;tt.prototype.visitInt=gr;tt.prototype.visitFloat=gr;tt.prototype.visitUtf8=Do;tt.prototype.visitLargeUtf8=Do;tt.prototype.visitBinary=Do;tt.prototype.visitLargeBinary=Do;tt.prototype.visitFixedSizeBinary=gr;tt.prototype.visitDate=gr;tt.prototype.visitTimestamp=gr;tt.prototype.visitTime=gr;tt.prototype.visitDecimal=gr;tt.prototype.visitList=Xa;tt.prototype.visitStruct=Ja;tt.prototype.visitUnion=Zd;tt.prototype.visitInterval=gr;tt.prototype.visitDuration=gr;tt.prototype.visitFixedSizeList=Xa;tt.prototype.visitMap=Xa;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 se(t)?t.then(e=>this.writeAll(e)):fe(t)?qa(this,t):Qa(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&&Vc(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&jc(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 K&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof W&&!(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 W?t instanceof cn||this._writeRecordBatch(t):t instanceof K?this.writeAll(t.batches):Ie(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=yt.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 Fe(a,t.bodyLength,this._position)):t.headerType===P.DictionaryBatch&&this._dictionaryBlocks.push(new Fe(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=D(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(yt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Pn)}_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=yt.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 b([t])),c=new Ot(t.length,s,o),l=new ne(c,e,n),u=yt.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}},br=class extends ln{static writeAll(t,e){let n=new br(e);return se(t)?t.then(i=>n.writeAll(i)):fe(t)?qa(n,t):Qa(n,t)}},wr=class extends ln{static writeAll(t){let e=new wr;return se(t)?t.then(n=>e.writeAll(n)):fe(t)?qa(e,t):Qa(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){let e=fr.encode(new fr(t,H.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Qa(r,t){let e=t;t instanceof K&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function qa(r,t){var e,n,i,s,o,a,c;return g(this,void 0,void 0,function*(){try{for(e=!0,n=ve(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 Tu(r,t){if(fe(r))return Qd(r,t);if(Ie(r))return Xd(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}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){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=D(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 Qd(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 g(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return g(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return g(this,void 0,void 0,function*(){(e?.return&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){return g(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=D(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 Fu(r){return new tc(r)}var tc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=Pc(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Me(s),this._getSize=i!=="bytes"?Du:Ou;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"?Du:Ou}),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)}},Du=r=>{var t;return(t=r?.length)!==null&&t!==void 0?t:0},Ou=r=>{var t;return(t=r?.byteLength)!==null&&t!==void 0?t:0};function Oo(r,t){let e=new er,n=null,i=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield e.close()})},start(a){return g(this,void 0,void 0,function*(){yield o(a,n||(n=yield s()))})},pull(a){return g(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 g(this,void 0,void 0,function*(){return yield(yield gt.from(e)).open(t)})}function o(a,c){return g(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}function Fo(r,t){let e=new this(r),n=new te(e),i=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return g(this,void 0,void 0,function*(){yield s(o)})},start(o){return g(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(o){return g(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 zi(r){let t=gt.from(r);return se(t)?t.then(e=>zi(e)):t.isAsync()?t.readAll().then(e=>new K(e)):new K(t.readAll())}function Mo(r,t="stream"){return(t==="stream"?br:wr).writeAll(r).toUint8Array(!0)}var lp=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},fa),Ra),Da),ha),oa),Ta),la),{compareSchemas:an,compareFields:su,compareTypes:bo});Bt.toDOMStream=Tu;nt.throughDOM=Fu;gt.throughDOM=Oo;Lr.throughDOM=Oo;ir.throughDOM=Oo;ln.throughDOM=Fo;wr.throughDOM=Fo;br.throughDOM=Fo;var Lo=class extends Er{arrowSchema;constructor(t,e){super(t,e),this.arrowSchema=null}getBatch(){let t=super.getBatch();if(t){this.arrowSchema=this.arrowSchema||up(t.schema);let e=fp(this.arrowSchema,t.data),n=new W(this.arrowSchema,w({type:new V(this.arrowSchema.fields),children:e.map(({data:i})=>i[0])}));return{shape:"arrow-table",batchType:"data",data:new K([n]),length:t.length}}return null}};function up(r){let t=[];for(let e in r){let n=r[e];if(n.type===Float32Array){let i=new Map,s=new O(n.name,new me,n.nullable,i);t.push(s)}}if(t.length===0)throw new Error("No arrow convertible fields");return new R(t)}function fp(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}var hp="4.3.2",Wn={dataType:null,batchType:null,name:"Apache Arrow",id:"arrow",module:"arrow",version:hp,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"}}};var dp=["geoarrow.multipolygon","geoarrow.polygon","geoarrow.multilinestring","geoarrow.linestring","geoarrow.multipoint","geoarrow.point","geoarrow.wkb","geoarrow.wkt"],pp="ARROW:extension:name",mp="ARROW:extension:metadata";function ec(r){let t={};for(let e of r.fields){let n=yp(e);n&&(t[e.name]=n)}return t}function yp(r){let t=null,e=r.metadata?.[pp];e&&(e=e.toLowerCase(),e==="wkb"&&(e="geoarrow.wkb"),e==="wkt"&&(e="geoarrow.wkt"),dp.includes(e)?(t=t||{},t.encoding=e):console.warn(`Invalid GeoArrow encoding: ${e}`));let n=r.metadata?.[mp];if(n)try{t=JSON.parse(n)}catch(i){console.warn("Failed to parse GeoArrow metadata",i)}return t||null}var Wi={x:0,y:1,z:2};function No(r,t={}){let{start:e=0,end:n=r.length,plane:i="xy"}=t,s=t.size||2,o=0,a=Wi[i[0]],c=Wi[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=Lu(r,0,o,e,!0,n&&n[0],i),c=[];if(!a||a.next===a.prev)return c;let l,u,h,d,p,v,k;if(s&&(a=xp(r,t,a,e,n,i)),r.length>80*e){d=u=r[0],p=h=r[1];for(let Z=e;Z<o;Z+=e)v=r[Z],k=r[Z+1],v<d&&(d=v),k<p&&(p=k),v>u&&(u=v),k>h&&(h=k);l=Math.max(u-d,h-p),l=l!==0?32767/l:0}return Gi(a,c,e,d,p,l,0),c}function Lu(r,t,e,n,i,s,o){let a,c;s===void 0&&(s=No(r,{start:t,end:e,size:n,plane:o}));let l=Wi[o[0]],u=Wi[o[1]];if(i===s<0)for(a=t;a<e;a+=n)c=Mu(a,r[a+l],r[a+u],c);else for(a=e-n;a>=t;a-=n)c=Mu(a,r[a+l],r[a+u],c);return c&&Ro(c,c.next)&&(Hi(c),c=c.next),c}function un(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(Ro(e,e.next)||ct(e.prev,e,e.next)===0)){if(Hi(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Gi(r,t,e,n,i,s,o){if(!r)return;!o&&s&&Dp(r,n,i,s);let a=r,c,l;for(;r.prev!==r.next;){if(c=r.prev,l=r.next,s?_p(r,n,i,s):wp(r)){t.push(c.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),Hi(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=vp(un(r),t,e),Gi(r,t,e,n,i,s,2)):o===2&&Ip(r,t,e,n,i,s):Gi(un(r),t,e,n,i,s,1);break}}}function wp(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,p=a>c?a>l?a:l:c>l?c:l,v=n.next;for(;v!==t;){if(v.x>=u&&v.x<=d&&v.y>=h&&v.y<=p&&Gn(i,a,s,c,o,l,v.x,v.y)&&ct(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function _p(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,p=a<c?a<l?a:l:c<l?c:l,v=u<h?u<d?u:d:h<d?h:d,k=a>c?a>l?a:l:c>l?c:l,Z=u>h?u>d?u:d:h>d?h:d,et=rc(p,v,t,e,n),pn=rc(k,Z,t,e,n),G=r.prevZ,j=r.nextZ;for(;G&&G.z>=et&&j&&j.z<=pn;){if(G.x>=p&&G.x<=k&&G.y>=v&&G.y<=Z&&G!==i&&G!==o&&Gn(a,u,c,h,l,d,G.x,G.y)&&ct(G.prev,G,G.next)>=0||(G=G.prevZ,j.x>=p&&j.x<=k&&j.y>=v&&j.y<=Z&&j!==i&&j!==o&&Gn(a,u,c,h,l,d,j.x,j.y)&&ct(j.prev,j,j.next)>=0))return!1;j=j.nextZ}for(;G&&G.z>=et;){if(G.x>=p&&G.x<=k&&G.y>=v&&G.y<=Z&&G!==i&&G!==o&&Gn(a,u,c,h,l,d,G.x,G.y)&&ct(G.prev,G,G.next)>=0)return!1;G=G.prevZ}for(;j&&j.z<=pn;){if(j.x>=p&&j.x<=k&&j.y>=v&&j.y<=Z&&j!==i&&j!==o&&Gn(a,u,c,h,l,d,j.x,j.y)&&ct(j.prev,j,j.next)>=0)return!1;j=j.nextZ}return!0}function vp(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!Ro(i,s)&&Nu(i,n,n.next,s)&&$i(i,s)&&$i(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Hi(n),Hi(n.next),n=r=s),n=n.next}while(n!==r);return un(n)}function Ip(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Mp(o,a)){let c=Uu(o,a);o=un(o,o.next),c=un(c,c.next),Gi(o,t,e,n,i,s,0),Gi(c,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function xp(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=Lu(r,l,u,n,!1,i&&i[a+1],s),h===h.next&&(h.steiner=!0),o.push(Fp(h));for(o.sort(Sp),a=0;a<o.length;a++)e=Bp(o[a],e);return e}function Sp(r,t){return r.x-t.x}function Bp(r,t){let e=Ap(r,t);if(!e)return t;let n=Uu(e,r);return un(n,n.next),un(e,e.next)}function Ap(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&&Gn(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),$i(e,r)&&(h<u||h===u&&(e.x>o.x||e.x===o.x&&Tp(o,e)))&&(o=e,u=h)),e=e.next;while(e!==a);return o}function Tp(r,t){return ct(r.prev,r,t.prev)<0&&ct(t.next,r,r.next)<0}function Dp(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,Op(i)}function Op(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 Fp(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 Gn(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 Mp(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Lp(r,t)&&($i(r,t)&&$i(t,r)&&Np(r,t)&&(ct(r.prev,r,t.prev)||ct(r,t.prev,t))||Ro(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 Ro(r,t){return r.x===t.x&&r.y===t.y}function Nu(r,t,e,n){let i=Eo(ct(r,t,e)),s=Eo(ct(r,t,n)),o=Eo(ct(e,n,r)),a=Eo(ct(e,n,t));return!!(i!==s&&o!==a||i===0&&Uo(r,e,t)||s===0&&Uo(r,n,t)||o===0&&Uo(e,r,n)||a===0&&Uo(e,t,n))}function Uo(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 Eo(r){return r>0?1:r<0?-1:0}function Lp(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&&Nu(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function $i(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 Np(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 Uu(r,t){let e=new Yi(r.i,r.x,r.y),n=new Yi(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 Mu(r,t,e,n){let i=new Yi(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 Hi(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 Yi=class{constructor(t,e,n){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=t,this.x=e,this.y=n}};function $n(r,t,e){switch(r.type){case"Point":return kp(r,t,e);case"LineString":return Pp(r,t,e);case"Polygon":return Cu(r,t,e);default:let n=r;throw new Error(`Unsupported geometry type: ${n?.type}`)}}function Cu(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=Co(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=Cu(r,l,u).coordinates;a.push(h)}return{type:"MultiPolygon",coordinates:a}}function Pp(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:Co(n,i[0],i[1])};let o=[];for(let a=0;a<i.length-1;a++){let c=Co(n,i[a],i[a+1]);o.push(c)}return{type:"MultiLineString",coordinates:o}}function kp(r,t,e){let{positions:n}=r,i=Co(n,t,e);return i.length>1?{type:"MultiPoint",coordinates:i}:{type:"Point",coordinates:i[0]}}function Co(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 Hn(r){return ic(r)}function Pu(r){return Ki(r)}function ic(r){return{fields:r.fields.map(t=>fn(t)),metadata:Po(r.metadata)}}function Ki(r){return new R(r.fields.map(t=>hn(t)),ko(r.metadata))}function Po(r){return Object.fromEntries(r)}function ko(r){return r?new Map(Object.entries(r)):new Map}function fn(r){return{name:r.name,type:sc(r.type),nullable:r.nullable,metadata:Po(r.metadata)}}function hn(r){return new O(r.name,oc(r.type),r.nullable,ko(r.metadata))}function sc(r){switch(r.constructor){case ut:return"null";case ce:return"binary";case kt:return"bool";case st:let t=r;return`${t.isSigned?"u":""}int${t.bitWidth}`;case Ge:return"int8";case $e:return"int16";case It:return"int32";case pe:return"int64";case He:return"uint8";case Ye:return"uint16";case Ke:return"uint32";case Ze:return"uint64";case At:switch(r.precision){case z.HALF:return"float16";case z.SINGLE:return"float32";case z.DOUBLE:return"float64";default:return"float16"}case Br:return"float16";case me:return"float32";case ye:return"float64";case Pt:return"utf8";case le:let n=r;return{type:"decimal",bitWidth:n.bitWidth,precision:n.precision,scale:n.scale};case Xt:return r.unit===rt.DAY?"date-day":"date-millisecond";case Pr:return"date-day";case cr:return"date-millisecond";case xt:switch(r.unit){case m.SECOND:return"time-second";case m.MILLISECOND:return"time-millisecond";case m.MICROSECOND:return"time-microsecond";case m.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 m.SECOND:return"timestamp-second";case m.MILLISECOND:return"timestamp-millisecond";case m.MICROSECOND:return"timestamp-microsecond";case m.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 Qt:switch(r.unit){case it.DAY_TIME:return"interval-daytime";case it.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(p=>fn(p))};case Tt:let u=r.valueField;return{type:"list",children:[fn(u)]};case Vt:let h=r;return{type:"fixed-size-list",listSize:h.listSize,children:[fn(h.children[0])]};case V:return{type:"struct",children:r.children.map(p=>fn(p))};default:throw new Error(`arrow type not supported: ${r.constructor.name}`)}}function oc(r){if(typeof r=="object")switch(r.type){case"decimal":return new le(r.precision,r.scale,r.bitWidth);case"map":let t=r.children.map(i=>hn(i));return new jt(t,r.keysSorted);case"list":let e=hn(r.children[0]);return new Tt(e);case"fixed-size-list":let n=hn(r.children[0]);return new Vt(r.listSize,n);case"struct":return t=r.children.map(i=>hn(i)),new V(t);default:throw new Error("array type not supported")}switch(r){case"null":return new ut;case"binary":return new ce;case"bool":return new kt;case"int8":return new Ge;case"int16":return new $e;case"int32":return new It;case"int64":return new pe;case"uint8":return new He;case"uint16":return new Ye;case"uint32":return new Ke;case"uint64":return new Ze;case"float16":return new Br;case"float32":return new me;case"float64":return new ye;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")}}var Vo="4.3.2";var ku=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,Vu=new RegExp("^"+ku.source+"(\\s"+ku.source+"){1,}"),ac=["POINT(","LINESTRING(","POLYGON(","MULTIPOINT(","MULTILINESTRING(","MULTIPOLYGON(","GEOMETRYCOLLECTION("];function ju(r){return ac.some(t=>r.startsWith(t))}function cc(r,t){return Vp(r,t)}function Vp(r,t){let e=r.split(";"),n=e.pop(),i=(e.shift()||"").split("=").pop(),o=zu({parts:e,_:n,i:0});return t?.wkt?.crs?jp(o,i):o}function zu(r){return zp(r)||Gp(r)||Hp(r)||Wp(r)||$p(r)||Yp(r)||Kp(r)}function jp(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 zp(r){if(!ht(/^(POINT(\sz)?)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;let t=Wu(r);return!t||(Wt(r),!ht(/^(\))/,r))?null:{type:"Point",coordinates:t[0]}}function Wp(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=jo(r);return e?(Wt(r),{type:"MultiPoint",coordinates:e}):null}function Gp(r){if(!ht(/^(LINESTRING(\sz)?)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;let t=Wu(r);return!t||!ht(/^(\))/,r)?null:{type:"LineString",coordinates:t}}function $p(r){if(!ht(/^(MULTILINESTRING)/i,r))return null;Wt(r);let t=jo(r);return t?(Wt(r),{type:"MultiLineString",coordinates:t}):null}function Hp(r){if(!ht(/^(POLYGON(\sz)?)/i,r))return null;Wt(r);let t=jo(r);return t?{type:"Polygon",coordinates:t}:null}function Yp(r){if(!ht(/^(MULTIPOLYGON)/i,r))return null;Wt(r);let t=jo(r);return t?{type:"MultiPolygon",coordinates:t}:null}function Kp(r){let t=[],e;if(!ht(/^(GEOMETRYCOLLECTION)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;for(;e=zu(r);)t.push(e),Wt(r),ht(/^(,)/,r),Wt(r);return ht(/^(\))/,r)?{type:"GeometryCollection",geometries:t}:null}function jo(r){Wt(r);let t=0,e=[],n=[e],i=e,s;for(;s=ht(/^(\()/,r)||ht(/^(\))/,r)||ht(/^(,)/,r)||ht(Vu,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 Wu(r){let t=[],e,n;for(;n=ht(Vu,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 Gu={dataType:null,batchType:null,name:"WKT (Well-Known Text)",id:"wkt",module:"wkt",version:Vo,worker:!0,extensions:["wkt"],mimeTypes:["text/plain"],category:"geometry",text:!0,tests:ac,testText:ju,options:{wkt:{shape:"geojson-geometry",crs:!0}}},lc={...Gu,parse:async(r,t)=>cc(new TextDecoder().decode(r),t),parseTextSync:(r,t)=>cc(r,t)};var _r;(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"})(_r||(_r={}));function $u(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 Hu(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 uc(r,t){let e=Zp(r,t),n=t?.wkb?.shape||"binary-geometry";switch(n){case"binary-geometry":return e;case"geojson-geometry":return $n(e);case"geometry":return console.error('WKBLoader: "geometry" shape is deprecated, use "binary-geometry" instead'),$n(e);default:throw new Error(n)}}function Zp(r,t){let e=new DataView(r),n=Hu(e),{geometryType:i,dimensions:s,littleEndian:o}=n,a=n.byteOffset;switch(i){case _r.Point:return Yu(e,a,s,o).geometry;case _r.LineString:return fc(e,a,s,o).geometry;case _r.Polygon:return Ku(e,a,s,o).geometry;case _r.MultiPoint:let h=Jp(e,a,s,o);return h.type="Point",h;case _r.MultiLineString:let d=Xp(e,a,s,o);return d.type="LineString",d;case _r.MultiPolygon:let p=Qp(e,a,s,o);return p.type="Polygon",p;default:throw new Error(`WKB: Unsupported geometry type: ${i}`)}}function Yu(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 fc(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 hc=r=>t=>r+=t;function Ku(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let l=0;l<i;l++){let u=fc(r,t,e,n),{positions:h}=u.geometry;t=u.offset,s.push(h.value)}let o=new Float64Array(zo(s).buffer),a=[0];o.length>0&&a.push(o.length/e);let c=s.map(l=>l.length/e).map(hc(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 Jp(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=Yu(r,t,e,a);t=c.offset,s.push(c.geometry)}return qp(s,e)}function Xp(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=fc(r,t,e,a);t=c.offset,s.push(c.geometry)}return tm(s,e)}function Qp(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=Ku(r,t,e,a);t=c.offset,s.push(c.geometry)}return em(s,e)}function qp(r,t){let e=r.map(i=>i.positions.value);return{type:"Point",positions:{value:new Float64Array(zo(e).buffer),size:t}}}function tm(r,t){let e=r.map(s=>s.positions.value),n=new Float64Array(zo(e).buffer),i=e.map(s=>s.length/t).map(hc(0));return i.unshift(0),{type:"LineString",positions:{value:n,size:t},pathIndices:{value:new Uint32Array(i),size:1}}}function em(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(zo(e).buffer),s=e.map(a=>a.length/t).map(hc(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 zo(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 Zu={dataType:null,batchType:null,name:"WKB",id:"wkb",module:"wkt",version:Vo,worker:!0,category:"geometry",extensions:["wkb"],mimeTypes:[],tests:[$u],options:{wkb:{shape:"binary-geometry"}}},dc={...Zu,parse:async r=>uc(r),parseSync:uc};function Wo(r,t){if(t=t?.toLowerCase(),!t||!r)return null;let e;switch(t){case"geoarrow.multipolygon":e=im(r);break;case"geoarrow.polygon":e=sm(r);break;case"geoarrow.multipoint":e=om(r);break;case"geoarrow.point":e=am(r);break;case"geoarrow.multilinestring":e=cm(r);break;case"geoarrow.linestring":e=lm(r);break;case"geoarrow.wkb":e=rm(r);break;case"geoarrow.wkt":e=nm(r);break;default:throw Error(`GeoArrow encoding not supported ${t}`)}return e}function rm(r){let t=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),e=dc.parseSync?.(t);return $n(e)}function nm(r){let t=r;return lc.parseTextSync?.(t)}function im(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 sm(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 om(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 am(r){return{type:"Point",coordinates:Array.from(r)}}function cm(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 lm(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 Yn(r,t){switch(t){case"arrow-table":return um(r);case"array-row-table":return fm(r);case"object-row-table":return hm(r);case"columnar-table":return pc(r);case"geojson-table":return dm(r);default:throw new Error(t)}}function um(r){return{shape:"arrow-table",schema:Hn(r.schema),data:r}}function fm(r){let t=pc(r);return ls(t,"array-row-table")}function hm(r){let t=pc(r);return ls(t,"object-row-table")}function pc(r){let t={};for(let n of r.schema.fields){let s=r.getChild(n.name)?.toArray();t[n.name]=s}return{shape:"columnar-table",schema:Hn(r.schema),data:t}}function dm(r){let t=Hn(r.schema),e=ec(t),n=e.geometry.encoding,i=[],s=r.schema.fields.map(c=>c.name).filter(c=>!(c in e)),o=r.select(s),a=r.getChild("geometry");for(let c=0;c<r.numRows;c++){let l=a?.get(c),u=Wo(l,n);if(u){let h=o.get(c)?.toJSON()||{};i.push({type:"Feature",geometry:u,properties:h})}}return{shape:"geojson-table",type:"FeatureCollection",schema:t,features:i}}function Zi(r,t){let e=t?.shape||"arrow-table",n=zi([new Uint8Array(r)]);return Yn(n,e)}function Go(r,t){async function*e(){let n=gt.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 K([s]),length:s.data.length};break}}return e()}var Ju={...Wn,parse:async(r,t)=>Zi(r,t?.arrow),parseSync:(r,t)=>Zi(r,t?.arrow),parseInBatches:Go};function mc(r){let t={};for(let i of r){let s=pm(i.array,i.type);t[i.name]=s}let e=new K(t);return Mo(e)}function pm(r,t){switch(t){case Ur.DATE:return Pi(r);case Ur.FLOAT:default:return Pi(r)}}var mm="4.3.2",Xu={name:"Apache Arrow",id:"arrow",module:"arrow",version:mm,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 mc(t)},encodeSync(r,t){return mc(r)}};var $o={...Wn,options:{arrow:{shape:"arrow-table"}}};function yc(r,t){let e=Zi(r,{shape:"arrow-table"});switch(t?.shape){case"geojson-table":return Yn(e.data,"geojson-table");default:return e}}function Qu(r){return Go(r)}var qu={...$o,parse:async(r,t)=>yc(r,t?.arrow),parseSync:(r,t)=>yc(r,t?.arrow),parseInBatches:Qu};function tf(r,t){switch(r.shape){case"arrow-table":return r.data;case"columnar-table":default:let e=ym(r,t);return new K(e)}}function*ym(r,t){let e=Ki(r.schema),n=xr(r),i=Jo(r),s=t?.batchSize||n,o=e?.fields.map(l=>Me(l)),a=new V(e.fields),c=0;for(let l=0;l<n;l++)for(let u=0;u<i;++u){let h=Qo(r,l,u);if(o[u].append(h),c++,c>=s){let p=o.map(k=>k.flush()),v=new U(a,0,c,0,void 0,p);yield new W(e,v),c=0}}if(c>0){let l=o.map(h=>h.flush()),u=new U(a,0,c,0,void 0,l);yield new W(e,u),c=0}o.map(l=>l.finish())}function Ho(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 Kn;(function(r){r.points="points",r.lines="lines",r.polygons="polygons"})(Kn||(Kn={}));function Ji(){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 ef(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:p}=bm(c,t,e),v=new Uint32Array(l.length);for(let Z=0;Z<l.length;Z++)v[Z]=l[Z]+o;let k={globalFeatureIds:{value:v,size:1},positions:{value:u,size:h},featureIds:{value:l,size:1},properties:[...Array(c.length).keys()].map(Z=>({index:Z+o}))};o+=c.length,a.push({shape:"binary-feature-collection",points:{type:"Point",...Ji(),...n.point?k:{}},lines:{type:"LineString",...Ji(),...n.line?k:{},pathIndices:{value:n.line?d:new Uint16Array(0),size:1}},polygons:{type:"Polygon",...Ji(),...n.polygon?k:{},polygonIndices:{value:n.polygon?d:new Uint16Array(0),size:1},primitivePolygonIndices:{value:n.polygon?d:new Uint16Array(0),size:1},...p?{triangles:{value:p,size:1}}:{}}}),s=Ho(u,h,s)}),{binaryGeometries:a,bounds:s,featureTypes:n,...e?.calculateMeanCenters?{meanCenters:gc(a)}:{}}}function gc(r){let t=[];return r.forEach(e=>{let n=null;e.points&&e.points.positions.value.length>0?n=Kn.points:e.lines&&e.lines.positions.value.length>0?n=Kn.lines:e.polygons&&e.polygons.positions.value.length>0&&(n=Kn.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;gm(s,o,a,n,c).forEach(u=>{t.push(u)})}}),t}function gm(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===Kn.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 bm(r,t,e){switch(t){case"geoarrow.point":case"geoarrow.multipoint":return vm(r,t);case"geoarrow.linestring":case"geoarrow.multilinestring":return _m(r,t);case"geoarrow.polygon":case"geoarrow.multipolygon":return wm(r,t,e);default:throw Error("invalid geoarrow encoding")}}function bc(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 p=0;p<d.length;p++)s.push(d[p]+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 wm(r,t,e){let n=t==="geoarrow.multipolygon",i=n?r.children[0]:r,s=i.valueOffsets,o=n?r.valueOffsets.map(et=>s.at(et)||et):r.valueOffsets,a=i.children[0],c=a.children[0],l=c.children[0],u=c.stride,h=a.valueOffsets,d=l.values,p=new Uint16Array(s.length);for(let et=0;et<s.length;et++)p[et]=h[s[et]];let v=d.length/u,k=new Uint32Array(v);for(let et=0;et<o.length-1;et++){let pn=h[o[et]],G=h[o[et+1]];for(let j=pn;j<G;j++)k[j]=et}let Z=e?.triangulate?bc(p,h,d,u):null;return{featureIds:k,nDim:u,flatCoordinateArray:d,geomOffset:h,geometryIndicies:p,...e?.triangulate&&Z?{triangles:Z}:{}}}function _m(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 p=0;p<d.length-1;p++){let v=a[d[p]],k=a[d[p+1]];for(let Z=v;Z<k;Z++)h[Z]=p}}else for(let d=0;d<r.length;d++){let p=a[d],v=a[d+1];for(let k=p;k<v;k++)h[k]=d}return{featureIds:h,flatCoordinateArray:c,nDim:o,geomOffset:a,geometryIndicies:l}}function vm(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 p=h[d],v=h[d+1];for(let k=p;k<v;k++)u[k]=d}}else for(let h=0;h<r.length;h++)u[h]=h;return{featureIds:u,flatCoordinateArray:o,nDim:s,geomOffset:c,geometryIndicies:a}}function Xi(r,t=!1){if("data"in r)return new b(r.data.map(s=>Xi(s,t)));let e=[];for(let s of r.children)e.push(Xi(s,t));let n;r.dictionary!==void 0&&(n=Xi(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 U(r.type,r.offset,r.length,r._nullCount,i,e,n)}function Im(r){return!(r.byteOffset===0&&r.byteLength===r.buffer.byteLength)}function Yo(r,t){return r===void 0||!t&&!Im(r)?r:r.slice()}var rf="latest";function xm(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.2"),globalThis._loadersgl_.version}var wc=xm();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},lA=or.self||or.window||or.global||{},uA=or.window||or.self||or.global||{},fA=or.global||or.self||or.window||{},hA=or.document||{};var vr=typeof process!="object"||String(process)!=="[object process]"||process.browser;var sf=typeof window<"u"&&typeof window.orientation<"u",nf=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),dA=nf&&parseFloat(nf[1])||0;var Qi=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 Zn=class{terminate(){}};var _c=new Map;function of(r){sr(r.source&&!r.url||!r.source&&r.url);let t=_c.get(r.source||r.url);return t||(r.url&&(t=Sm(r.url),_c.set(r.url,t)),r.source&&(t=af(r.source),_c.set(r.source,t))),sr(t),t}function Sm(r){if(!r.startsWith("http"))return r;let t=Bm(r);return af(t)}function af(r){let t=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(t)}function Bm(r){return`try {
17
17
  importScripts('${r}');
18
18
  } catch (error) {
19
19
  console.error(error);
20
20
  throw error;
21
- }`}function vc(r,t=!0,e){let n=e||new Set;if(r){if(cf(r))n.add(r);else if(cf(r.buffer))n.add(r.buffer);else if(!ArrayBuffer.isView(r)){if(t&&typeof r=="object")for(let i in r)vc(r[i],t,n)}}return e===void 0?Array.from(n):[]}function cf(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 Ic(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]=Ic(r[e]):typeof t[e]=="function"||t[e]instanceof RegExp?t[e]={}:t[e]=r[e]}),t}var xc=()=>{},Nr=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&vr||typeof Zn<"u"&&!vr}constructor(t){let{name:e,source:n,url:i}=t;sr(n||i),this.name=e,this.source=n,this.url=i,this.onMessage=xc,this.onError=s=>console.log(s),this.worker=vr?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=xc,this.onError=xc,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(t,e){e=e||vc(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=of({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 Zn(n,{eval:!1})}else if(this.source)t=new Zn(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 Nr.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 Qi(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){!vr||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 Nr({name:t,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return sf?this.maxMobileConcurrency:this.maxConcurrency}};var Am={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},dn=class{props;workerPools=new Map;static isSupported(){return Nr.isSupported()}static getWorkerFarm(t={}){return dn._workerFarm=dn._workerFarm||new dn({}),dn._workerFarm.setProps(t),dn._workerFarm}constructor(t){this.props={...Am},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}}},Jn=dn;ns(Jn,"_workerFarm");function lf(r){let t=r.version!==wc?` (worker-utils@${wc})`:"";return`${r.name}@${r.version}${t}`}function uf(r,t={}){let e=t[r.id]||{},n=vr?`${r.id}-worker.js`:`${r.id}-worker-node.js`,i=e.workerUrl;if(!i&&r.id==="compression"&&(i=t.workerUrl),t._workerType==="test"&&(vr?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=rf);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=lf(r),s=Jn.getWorkerFarm(e),{source:o}=e,a={name:i,source:o};o||(a.url=uf(r,e));let c=s.getWorkerPool(a),l=e.jobName||r.name,u=await c.startJob(l,Tm.bind(null,n)),h=Ic(e);return u.postMessage("process",{input:t,options:h}),(await u.result).result}async function Tm(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 Dm="4.3.1",Zo={id:"triangulation",name:"Triangulate",module:"arrow",version:Dm,options:{}};function ff(r,t={}){return Ko(Zo,{...r,operation:"triangulate"},t)}function hf(r,t={}){return Ko(Zo,{...r,operation:"parse-geoarrow"},t)}mn.ArrowBatch=Lo;return vf(ts);})();
21
+ }`}function vc(r,t=!0,e){let n=e||new Set;if(r){if(cf(r))n.add(r);else if(cf(r.buffer))n.add(r.buffer);else if(!ArrayBuffer.isView(r)){if(t&&typeof r=="object")for(let i in r)vc(r[i],t,n)}}return e===void 0?Array.from(n):[]}function cf(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 Ic(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]=Ic(r[e]):typeof t[e]=="function"||t[e]instanceof RegExp?t[e]={}:t[e]=r[e]}),t}var xc=()=>{},Nr=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&vr||typeof Zn<"u"&&!vr}constructor(t){let{name:e,source:n,url:i}=t;sr(n||i),this.name=e,this.source=n,this.url=i,this.onMessage=xc,this.onError=s=>console.log(s),this.worker=vr?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=xc,this.onError=xc,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(t,e){e=e||vc(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=of({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 Zn(n,{eval:!1})}else if(this.source)t=new Zn(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 Nr.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 Qi(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){!vr||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 Nr({name:t,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return sf?this.maxMobileConcurrency:this.maxConcurrency}};var Am={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},dn=class{props;workerPools=new Map;static isSupported(){return Nr.isSupported()}static getWorkerFarm(t={}){return dn._workerFarm=dn._workerFarm||new dn({}),dn._workerFarm.setProps(t),dn._workerFarm}constructor(t){this.props={...Am},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}}},Jn=dn;ns(Jn,"_workerFarm");function lf(r){let t=r.version!==wc?` (worker-utils@${wc})`:"";return`${r.name}@${r.version}${t}`}function uf(r,t={}){let e=t[r.id]||{},n=vr?`${r.id}-worker.js`:`${r.id}-worker-node.js`,i=e.workerUrl;if(!i&&r.id==="compression"&&(i=t.workerUrl),t._workerType==="test"&&(vr?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=rf);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=lf(r),s=Jn.getWorkerFarm(e),{source:o}=e,a={name:i,source:o};o||(a.url=uf(r,e));let c=s.getWorkerPool(a),l=e.jobName||r.name,u=await c.startJob(l,Tm.bind(null,n)),h=Ic(e);return u.postMessage("process",{input:t,options:h}),(await u.result).result}async function Tm(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 Dm="4.3.2",Zo={id:"triangulation",name:"Triangulate",module:"arrow",version:Dm,options:{}};function ff(r,t={}){return Ko(Zo,{...r,operation:"triangulate"},t)}function hf(r,t={}){return Ko(Zo,{...r,operation:"parse-geoarrow"},t)}mn.ArrowBatch=Lo;return vf(ts);})();
22
22
  return __exports__;
23
23
  });
@@ -3,7 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
  // __VERSION__ is injected by babel-plugin-version-inline
5
5
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
6
- const VERSION = typeof "4.3.1" !== 'undefined' ? "4.3.1" : 'latest';
6
+ const VERSION = typeof "4.3.2" !== 'undefined' ? "4.3.2" : 'latest';
7
7
  /** ArrowJS table loader */
8
8
  export const ArrowWorkerLoader = {
9
9
  dataType: null,
@@ -2,7 +2,7 @@
2
2
  import { encodeGeoArrowSync } from "./lib/encoders/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.1" !== 'undefined' ? "4.3.1" : 'latest';
5
+ const VERSION = typeof "4.3.2" !== 'undefined' ? "4.3.2" : 'latest';
6
6
  /** Apache Arrow writer */
7
7
  export const GeoArrowWriter = {
8
8
  name: 'Apache Arrow',
package/dist/index.cjs CHANGED
@@ -130,7 +130,7 @@ function getArrowVectors(arrowSchema, data) {
130
130
  var import_schema4 = require("@loaders.gl/schema");
131
131
 
132
132
  // dist/exports/arrow-loader.js
133
- var VERSION = true ? "4.3.1" : "latest";
133
+ var VERSION = true ? "4.3.2" : "latest";
134
134
  var ArrowWorkerLoader = {
135
135
  dataType: null,
136
136
  batchType: null,
@@ -710,7 +710,7 @@ function createVector(array, type) {
710
710
  }
711
711
 
712
712
  // dist/arrow-writer.js
713
- var VERSION2 = true ? "4.3.1" : "latest";
713
+ var VERSION2 = true ? "4.3.2" : "latest";
714
714
  var ArrowWriter = {
715
715
  name: "Apache Arrow",
716
716
  id: "arrow",
@@ -1170,7 +1170,7 @@ function cloneBuffer(arr, force) {
1170
1170
 
1171
1171
  // dist/triangulate-on-worker.js
1172
1172
  var import_worker_utils = require("@loaders.gl/worker-utils");
1173
- var VERSION3 = true ? "4.3.1" : "latest";
1173
+ var VERSION3 = true ? "4.3.2" : "latest";
1174
1174
  var TriangulationWorker = {
1175
1175
  id: "triangulation",
1176
1176
  name: "Triangulate",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["index.js", "lib/types.js", "schema/arrow-table-batch.js", "exports/arrow-loader.js", "lib/parsers/parse-arrow.js", "lib/tables/convert-arrow-to-table.js", "lib/tables/convert-arrow-schema.js", "lib/geoarrow/convert-geoarrow-to-geojson-geometry.js", "arrow-loader.js", "lib/encoders/encode-arrow.js", "arrow-writer.js", "exports/geoarrow-loader.js", "lib/parsers/parse-geoarrow.js", "geoarrow-loader.js", "lib/tables/convert-table-to-arrow.js", "lib/geoarrow/convert-geoarrow-to-binary-geometry.js", "lib/geoarrow/get-arrow-bounds.js", "workers/hard-clone.js", "triangulate-on-worker.js"],
4
- "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { VECTOR_TYPES } from \"./lib/types.js\";\nimport { ArrowTableBatchAggregator } from \"./schema/arrow-table-batch.js\";\n// Make the ArrowBatch type available\nimport { TableBatchBuilder } from '@loaders.gl/schema';\nTableBatchBuilder.ArrowBatch = ArrowTableBatchAggregator;\nexport { ArrowWorkerLoader } from \"./exports/arrow-loader.js\";\nexport { ArrowLoader } from \"./arrow-loader.js\";\nexport { ArrowWriter } from \"./arrow-writer.js\";\n// Geoarrow loader\nexport { GeoArrowWorkerLoader } from \"./exports/geoarrow-loader.js\";\nexport { GeoArrowLoader } from \"./geoarrow-loader.js\";\n// Schema utils\nexport { convertArrowToSchema, convertSchemaToArrow, \n// DETAILED FUNCTIONS\nserializeArrowSchema, deserializeArrowSchema, serializeArrowMetadata, deserializeArrowMetadata, serializeArrowField, deserializeArrowField, serializeArrowType, deserializeArrowType } from \"./lib//tables/convert-arrow-schema.js\";\n// Table utils\nexport { convertArrowToTable } from \"./lib/tables/convert-arrow-to-table.js\";\nexport { convertTableToArrow } from \"./lib/tables/convert-table-to-arrow.js\";\nexport { getBinaryGeometryTemplate, getBinaryGeometriesFromArrow, getTriangleIndices, getMeanCentersFromBinaryGeometries } from \"./lib/geoarrow/convert-geoarrow-to-binary-geometry.js\";\nexport { updateBoundsFromGeoArrowSamples } from \"./lib/geoarrow/get-arrow-bounds.js\";\nexport { parseGeometryFromArrow } from \"./lib/geoarrow/convert-geoarrow-to-geojson-geometry.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\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 { ColumnarTableBatchAggregator } from '@loaders.gl/schema';\nimport * as arrow from 'apache-arrow';\n/** @note Should be part of @loaders.gl/schema - kept separate to avoid hard arrow dependency */\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\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.1\" !== 'undefined' ? \"4.3.1\" : '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", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport * as arrow from 'apache-arrow';\nimport { convertArrowToTable } from \"../tables/convert-arrow-to-table.js\";\n/** Parses arrow to a loaders.gl table. Defaults to `arrow-table` */\nexport function parseArrowSync(arrayBuffer, options) {\n const shape = options?.shape || 'arrow-table';\n const arrowTable = arrow.tableFromIPC([new Uint8Array(arrayBuffer)]);\n return convertArrowToTable(arrowTable, shape);\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 { convertTable } from '@loaders.gl/schema';\nimport { getGeometryColumnsFromSchema } from '@loaders.gl/gis';\nimport { convertArrowToSchema } from \"../tables/convert-arrow-schema.js\";\nimport { parseGeometryFromArrow } from \"../geoarrow/convert-geoarrow-to-geojson-geometry.js\";\n/**\n * Convert an Apache Arrow table to a loaders.gl Table\n * @note Currently does not convert schema\n */\nexport function convertArrowToTable(arrowTable, shape) {\n switch (shape) {\n case 'arrow-table':\n return convertArrowToArrowTable(arrowTable);\n case 'array-row-table':\n return convertArrowToArrayRowTable(arrowTable);\n case 'object-row-table':\n return convertArrowToObjectRowTable(arrowTable);\n case 'columnar-table':\n return convertArrowToColumnarTable(arrowTable);\n case 'geojson-table':\n return convertArrowToGeoJSONTable(arrowTable);\n default:\n throw new Error(shape);\n }\n}\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 */\nfunction convertArrowToArrowTable(arrowTable) {\n return {\n shape: 'arrow-table',\n schema: convertArrowToSchema(arrowTable.schema),\n data: arrowTable\n };\n}\nfunction convertArrowToArrayRowTable(arrowTable) {\n const columnarTable = convertArrowToColumnarTable(arrowTable);\n return convertTable(columnarTable, 'array-row-table');\n}\nfunction convertArrowToObjectRowTable(arrowTable) {\n const columnarTable = convertArrowToColumnarTable(arrowTable);\n return convertTable(columnarTable, 'object-row-table');\n}\n/**\n * Convert an Apache Arrow table to a ColumnarTable\n * @note Currently does not convert schema\n */\nfunction convertArrowToColumnarTable(arrowTable) {\n // TODO - avoid calling `getColumn` on columns we are not interested in?\n // Add options object?\n const columns = {};\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 columns[field.name] = values;\n }\n const schema = convertArrowToSchema(arrowTable.schema);\n return {\n shape: 'columnar-table',\n schema,\n data: columns\n };\n}\n/**\n * Convert an Apache Arrow table to a GeoJSONTable\n * @note Currently does not convert schema\n */\nfunction convertArrowToGeoJSONTable(arrowTable) {\n const schema = convertArrowToSchema(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,\n features\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 convertArrowToSchema(arrowSchema) {\n return serializeArrowSchema(arrowSchema);\n}\n/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */\nexport function convertSchemaToArrow(schema) {\n return deserializeArrowSchema(schema);\n}\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 { 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", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseArrowSync, parseArrowInBatches } from \"./lib/parsers/parse-arrow.js\";\nimport { ArrowWorkerLoader } from \"./exports/arrow-loader.js\";\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/encoders/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.1\" !== 'undefined' ? \"4.3.1\" : '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 { ArrowWorkerLoader } from \"./arrow-loader.js\";\n/** ArrowJS table loader */\nexport const GeoArrowWorkerLoader = {\n ...ArrowWorkerLoader,\n options: {\n arrow: {\n shape: 'arrow-table'\n }\n }\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseArrowSync, parseArrowInBatches } from \"./parse-arrow.js\";\nimport { convertArrowToTable } from \"../tables/convert-arrow-to-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 convertArrowToTable(table.data, 'geojson-table');\n default:\n return table;\n }\n}\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 { parseGeoArrowSync, parseGeoArrowInBatches } from \"./lib/parsers/parse-geoarrow.js\";\nimport { GeoArrowWorkerLoader } from \"./exports/geoarrow-loader.js\";\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 * as arrow from 'apache-arrow';\nimport { getTableLength, getTableNumCols, getTableCellAt } from '@loaders.gl/schema';\nimport { deserializeArrowSchema } from \"../tables/convert-arrow-schema.js\";\n/**\n * * Convert a loaders.gl Table to an Apache Arrow Table\n * @param mesh\n * @param metadata\n * @param batchSize\n * @returns\n */\nexport function convertTableToArrow(table, options) {\n switch (table.shape) {\n case 'arrow-table':\n return table.data;\n case 'columnar-table':\n // TODO - optimized implementation is possible\n // return convertColumnarTableToArrow(table, options);\n // fall through\n default:\n const arrowBatchIterator = makeTableToArrowBatchesIterator(table, options);\n return new arrow.Table(arrowBatchIterator);\n }\n}\nexport function* makeTableToArrowBatchesIterator(table, options) {\n const arrowSchema = deserializeArrowSchema(table.schema);\n const length = getTableLength(table);\n const numColumns = getTableNumCols(table);\n const batchSize = options?.batchSize || length;\n const builders = arrowSchema?.fields.map((arrowField) => arrow.makeBuilder(arrowField));\n const structField = new arrow.Struct(arrowSchema.fields);\n let batchLength = 0;\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n for (let columnIndex = 0; columnIndex < numColumns; ++columnIndex) {\n const value = getTableCellAt(table, rowIndex, columnIndex);\n const builder = builders[columnIndex];\n builder.append(value);\n batchLength++;\n if (batchLength >= batchSize) {\n const datas = builders.map((builder) => builder.flush());\n const structData = new arrow.Data(structField, 0, batchLength, 0, undefined, datas);\n yield new arrow.RecordBatch(arrowSchema, structData);\n batchLength = 0;\n }\n }\n }\n if (batchLength > 0) {\n const datas = builders.map((builder) => builder.flush());\n const structData = new arrow.Data(structField, 0, batchLength, 0, undefined, datas);\n yield new arrow.RecordBatch(arrowSchema, structData);\n batchLength = 0;\n }\n builders.map((builder) => builder.finish());\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", "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.1\" !== 'undefined' ? \"4.3.1\" : '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\nexport { VECTOR_TYPES } from \"./lib/types.js\";\nimport { ArrowTableBatchAggregator } from \"./schema/arrow-table-batch.js\";\n// Make the ArrowBatch type available\nimport { TableBatchBuilder } from '@loaders.gl/schema';\nTableBatchBuilder.ArrowBatch = ArrowTableBatchAggregator;\nexport { ArrowWorkerLoader } from \"./exports/arrow-loader.js\";\nexport { ArrowLoader } from \"./arrow-loader.js\";\nexport { ArrowWriter } from \"./arrow-writer.js\";\n// Geoarrow loader\nexport { GeoArrowWorkerLoader } from \"./exports/geoarrow-loader.js\";\nexport { GeoArrowLoader } from \"./geoarrow-loader.js\";\n// Schema utils\nexport { convertArrowToSchema, convertSchemaToArrow, \n// DETAILED FUNCTIONS\nserializeArrowSchema, deserializeArrowSchema, serializeArrowMetadata, deserializeArrowMetadata, serializeArrowField, deserializeArrowField, serializeArrowType, deserializeArrowType } from \"./lib//tables/convert-arrow-schema.js\";\n// Table utils\nexport { convertArrowToTable } from \"./lib/tables/convert-arrow-to-table.js\";\nexport { convertTableToArrow } from \"./lib/tables/convert-table-to-arrow.js\";\nexport { getBinaryGeometryTemplate, getBinaryGeometriesFromArrow, getTriangleIndices, getMeanCentersFromBinaryGeometries } from \"./lib/geoarrow/convert-geoarrow-to-binary-geometry.js\";\nexport { updateBoundsFromGeoArrowSamples } from \"./lib/geoarrow/get-arrow-bounds.js\";\nexport { parseGeometryFromArrow } from \"./lib/geoarrow/convert-geoarrow-to-geojson-geometry.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\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 { ColumnarTableBatchAggregator } from '@loaders.gl/schema';\nimport * as arrow from 'apache-arrow';\n/** @note Should be part of @loaders.gl/schema - kept separate to avoid hard arrow dependency */\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\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.2\" !== 'undefined' ? \"4.3.2\" : '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", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport * as arrow from 'apache-arrow';\nimport { convertArrowToTable } from \"../tables/convert-arrow-to-table.js\";\n/** Parses arrow to a loaders.gl table. Defaults to `arrow-table` */\nexport function parseArrowSync(arrayBuffer, options) {\n const shape = options?.shape || 'arrow-table';\n const arrowTable = arrow.tableFromIPC([new Uint8Array(arrayBuffer)]);\n return convertArrowToTable(arrowTable, shape);\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 { convertTable } from '@loaders.gl/schema';\nimport { getGeometryColumnsFromSchema } from '@loaders.gl/gis';\nimport { convertArrowToSchema } from \"../tables/convert-arrow-schema.js\";\nimport { parseGeometryFromArrow } from \"../geoarrow/convert-geoarrow-to-geojson-geometry.js\";\n/**\n * Convert an Apache Arrow table to a loaders.gl Table\n * @note Currently does not convert schema\n */\nexport function convertArrowToTable(arrowTable, shape) {\n switch (shape) {\n case 'arrow-table':\n return convertArrowToArrowTable(arrowTable);\n case 'array-row-table':\n return convertArrowToArrayRowTable(arrowTable);\n case 'object-row-table':\n return convertArrowToObjectRowTable(arrowTable);\n case 'columnar-table':\n return convertArrowToColumnarTable(arrowTable);\n case 'geojson-table':\n return convertArrowToGeoJSONTable(arrowTable);\n default:\n throw new Error(shape);\n }\n}\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 */\nfunction convertArrowToArrowTable(arrowTable) {\n return {\n shape: 'arrow-table',\n schema: convertArrowToSchema(arrowTable.schema),\n data: arrowTable\n };\n}\nfunction convertArrowToArrayRowTable(arrowTable) {\n const columnarTable = convertArrowToColumnarTable(arrowTable);\n return convertTable(columnarTable, 'array-row-table');\n}\nfunction convertArrowToObjectRowTable(arrowTable) {\n const columnarTable = convertArrowToColumnarTable(arrowTable);\n return convertTable(columnarTable, 'object-row-table');\n}\n/**\n * Convert an Apache Arrow table to a ColumnarTable\n * @note Currently does not convert schema\n */\nfunction convertArrowToColumnarTable(arrowTable) {\n // TODO - avoid calling `getColumn` on columns we are not interested in?\n // Add options object?\n const columns = {};\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 columns[field.name] = values;\n }\n const schema = convertArrowToSchema(arrowTable.schema);\n return {\n shape: 'columnar-table',\n schema,\n data: columns\n };\n}\n/**\n * Convert an Apache Arrow table to a GeoJSONTable\n * @note Currently does not convert schema\n */\nfunction convertArrowToGeoJSONTable(arrowTable) {\n const schema = convertArrowToSchema(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,\n features\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 convertArrowToSchema(arrowSchema) {\n return serializeArrowSchema(arrowSchema);\n}\n/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */\nexport function convertSchemaToArrow(schema) {\n return deserializeArrowSchema(schema);\n}\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 { 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", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseArrowSync, parseArrowInBatches } from \"./lib/parsers/parse-arrow.js\";\nimport { ArrowWorkerLoader } from \"./exports/arrow-loader.js\";\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/encoders/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.2\" !== 'undefined' ? \"4.3.2\" : '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 { ArrowWorkerLoader } from \"./arrow-loader.js\";\n/** ArrowJS table loader */\nexport const GeoArrowWorkerLoader = {\n ...ArrowWorkerLoader,\n options: {\n arrow: {\n shape: 'arrow-table'\n }\n }\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseArrowSync, parseArrowInBatches } from \"./parse-arrow.js\";\nimport { convertArrowToTable } from \"../tables/convert-arrow-to-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 convertArrowToTable(table.data, 'geojson-table');\n default:\n return table;\n }\n}\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 { parseGeoArrowSync, parseGeoArrowInBatches } from \"./lib/parsers/parse-geoarrow.js\";\nimport { GeoArrowWorkerLoader } from \"./exports/geoarrow-loader.js\";\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 * as arrow from 'apache-arrow';\nimport { getTableLength, getTableNumCols, getTableCellAt } from '@loaders.gl/schema';\nimport { deserializeArrowSchema } from \"../tables/convert-arrow-schema.js\";\n/**\n * * Convert a loaders.gl Table to an Apache Arrow Table\n * @param mesh\n * @param metadata\n * @param batchSize\n * @returns\n */\nexport function convertTableToArrow(table, options) {\n switch (table.shape) {\n case 'arrow-table':\n return table.data;\n case 'columnar-table':\n // TODO - optimized implementation is possible\n // return convertColumnarTableToArrow(table, options);\n // fall through\n default:\n const arrowBatchIterator = makeTableToArrowBatchesIterator(table, options);\n return new arrow.Table(arrowBatchIterator);\n }\n}\nexport function* makeTableToArrowBatchesIterator(table, options) {\n const arrowSchema = deserializeArrowSchema(table.schema);\n const length = getTableLength(table);\n const numColumns = getTableNumCols(table);\n const batchSize = options?.batchSize || length;\n const builders = arrowSchema?.fields.map((arrowField) => arrow.makeBuilder(arrowField));\n const structField = new arrow.Struct(arrowSchema.fields);\n let batchLength = 0;\n for (let rowIndex = 0; rowIndex < length; rowIndex++) {\n for (let columnIndex = 0; columnIndex < numColumns; ++columnIndex) {\n const value = getTableCellAt(table, rowIndex, columnIndex);\n const builder = builders[columnIndex];\n builder.append(value);\n batchLength++;\n if (batchLength >= batchSize) {\n const datas = builders.map((builder) => builder.flush());\n const structData = new arrow.Data(structField, 0, batchLength, 0, undefined, datas);\n yield new arrow.RecordBatch(arrowSchema, structData);\n batchLength = 0;\n }\n }\n }\n if (batchLength > 0) {\n const datas = builders.map((builder) => builder.flush());\n const structData = new arrow.Data(structField, 0, batchLength, 0, undefined, datas);\n yield new arrow.RecordBatch(arrowSchema, structData);\n batchLength = 0;\n }\n builders.map((builder) => builder.finish());\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", "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.2\" !== 'undefined' ? \"4.3.2\" : '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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAI;AAAA,CACV,SAAUA,eAAc;AACrB,EAAAA,cAAaA,cAAa,OAAO,IAAI,CAAC,IAAI;AAC1C,EAAAA,cAAaA,cAAa,MAAM,IAAI,CAAC,IAAI;AAC7C,GAAG,iBAAiB,eAAe,CAAC,EAAE;;;ACJtC,oBAA6C;AAC7C,YAA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AAA,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,OAAiC,UAAU;AAIpD,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;;;AlBrBA,iCAAkB,aAAa;",
6
6
  "names": ["VECTOR_TYPES", "import_schema", "arrow", "import_schema", "import_gis", "arrow", "_a", "arrow", "VERSION", "arrow", "import_schema", "builder", "BinaryGeometryType", "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.1" !== 'undefined' ? "4.3.1" : 'latest';
7
+ const VERSION = typeof "4.3.2" !== 'undefined' ? "4.3.2" : '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.2",
3
+ "version": "4.3.3",
4
4
  "description": "Simple columnar table loader for the Apache Arrow format",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -57,16 +57,16 @@
57
57
  "build-worker2": "esbuild src/workers/arrow-worker.ts --bundle --outfile=dist/arrow-worker.js --platform=browser --external:{stream}"
58
58
  },
59
59
  "dependencies": {
60
- "@loaders.gl/gis": "4.3.2",
61
- "@loaders.gl/loader-utils": "4.3.2",
62
- "@loaders.gl/schema": "4.3.2",
63
- "@loaders.gl/wkt": "4.3.2",
64
- "@loaders.gl/worker-utils": "4.3.2",
60
+ "@loaders.gl/gis": "4.3.3",
61
+ "@loaders.gl/loader-utils": "4.3.3",
62
+ "@loaders.gl/schema": "4.3.3",
63
+ "@loaders.gl/wkt": "4.3.3",
64
+ "@loaders.gl/worker-utils": "4.3.3",
65
65
  "@math.gl/polygon": "^4.1.0",
66
66
  "apache-arrow": ">= 15.0.0"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@loaders.gl/core": "^4.3.0"
70
70
  },
71
- "gitHead": "b4203b8703f64a38d6f79a3113bc7bb51d45c93a"
71
+ "gitHead": "65cb9a984f8aa95d11f50e92189d7fb32786dc41"
72
72
  }