@loaders.gl/json 4.3.2 → 4.4.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.dev.js +12457 -635
- package/dist/dist.min.js +18 -9
- package/dist/geojson-loader.js +1 -1
- package/dist/geojson-worker.js +12048 -226
- package/dist/index.cjs +22 -22
- package/dist/index.cjs.map +3 -3
- package/dist/json-loader.js +1 -1
- package/dist/lib/encoder-utils/encode-table-row.d.ts +1 -1
- package/dist/lib/encoder-utils/encode-table-row.d.ts.map +1 -1
- package/dist/lib/encoder-utils/encode-table-row.js +1 -1
- package/dist/lib/encoder-utils/encode-utils.d.ts +1 -1
- package/dist/lib/encoder-utils/encode-utils.d.ts.map +1 -1
- package/dist/lib/encoder-utils/encode-utils.js +1 -1
- package/dist/lib/encoders/geojson-encoder.js +1 -1
- package/dist/lib/encoders/json-encoder.d.ts +1 -1
- package/dist/lib/encoders/json-encoder.d.ts.map +1 -1
- package/dist/lib/encoders/json-encoder.js +1 -1
- package/dist/lib/parsers/parse-json-in-batches.d.ts.map +1 -1
- package/dist/lib/parsers/parse-json-in-batches.js +1 -1
- package/dist/lib/parsers/parse-json.js +1 -1
- package/dist/lib/parsers/parse-ndjson-in-batches.js +1 -1
- package/dist/lib/parsers/parse-ndjson.js +1 -1
- package/dist/ndgeoson-loader.js +1 -1
- package/dist/ndjson-loader.js +1 -1
- package/package.json +7 -6
- package/src/lib/encoder-utils/encode-table-row.ts +2 -1
- package/src/lib/encoder-utils/encode-utils.ts +2 -1
- package/src/lib/encoders/geojson-encoder.ts +1 -1
- package/src/lib/encoders/json-encoder.ts +2 -1
- package/src/lib/parsers/parse-json-in-batches.ts +2 -1
- package/src/lib/parsers/parse-json.ts +1 -1
- package/src/lib/parsers/parse-ndjson-in-batches.ts +1 -1
- package/src/lib/parsers/parse-ndjson.ts +1 -1
package/dist/dist.min.js
CHANGED
|
@@ -4,18 +4,27 @@
|
|
|
4
4
|
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
5
|
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
6
6
|
else root['loaders'] = factory();})(globalThis, function () {
|
|
7
|
-
"use strict";var __exports__=(()=>{var pt=Object.create;var v=Object.defineProperty;var dt=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,gt=Object.prototype.hasOwnProperty;var xt=(t,e,r)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var wt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),bt=(t,e)=>{for(var r in e)v(t,r,{get:e[r],enumerable:!0})},K=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of mt(e))!gt.call(t,n)&&n!==r&&v(t,n,{get:()=>e[n],enumerable:!(o=dt(e,n))||o.enumerable});return t},H=(t,e,r)=>(K(t,e,"default"),r&&K(r,e,"default")),At=(t,e,r)=>(r=t!=null?pt(yt(t)):{},K(e||!t||!t.__esModule?v(r,"default",{value:t,enumerable:!0}):r,t)),Pt=t=>K(v({},"__esModule",{value:!0}),t);var Be=(t,e,r)=>(xt(t,typeof e!="symbol"?e+"":e,r),r);var Ce=wt((wr,Ee)=>{Ee.exports=globalThis.loaders});var Y={};bt(Y,{JSONLoader:()=>ie,JSONWriter:()=>He,NDJSONLoader:()=>Ke,_ClarinetParser:()=>C,_GeoJSONLoader:()=>T,_GeoJSONWorkerLoader:()=>Se,_GeoJSONWriter:()=>ft,_JSONPath:()=>P,_rebuildJsonObject:()=>$e});H(Y,At(Ce(),1));function Q(t,e="float32"){return t instanceof Date?"date-millisecond":t instanceof Number?e:typeof t=="string"?"utf8":(t===null||t==="undefined","null")}function Le(t){let e=jt(t);return e!=="null"?{type:e,nullable:!1}:t.length>0?(e=Q(t[0]),{type:e,nullable:!0}):{type:"null",nullable:!0}}function jt(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}var X=class{schema;options;shape;length=0;rows=null;cursor=0;_headers=[];constructor(e,r){if(this.options=r,this.schema=e,!Array.isArray(e)){this._headers=[];for(let o in e)this._headers[e[o].index]=e[o].name}}rowCount(){return this.length}addArrayRow(e,r){Number.isFinite(r)&&(this.cursor=r),this.shape="array-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=e,this.length++}addObjectRow(e,r){Number.isFinite(r)&&(this.cursor=r),this.shape="object-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=e,this.length++}getBatch(){let e=this.rows;return e?(e=e.slice(0,this.length),this.rows=null,{shape:this.shape||"array-row-table",batchType:"data",data:e,length:this.length,schema:this.schema,cursor:this.cursor}):null}};function Fe(t,e){if(!t)throw new Error("null row");let r={};if(e)for(let o=0;o<e.length;o++)r[e[o]]=t[o];else for(let o=0;o<t.length;o++){let n=`column-${o}`;r[n]=t[o]}return r}function _e(t,e){if(!t)throw new Error("null row");if(e){let r=new Array(e.length);for(let o=0;o<e.length;o++)r[o]=t[e[o]];return r}return Object.values(t)}function ke(t){let e=[];for(let r=0;r<t.length;r++){let o=`column-${r}`;e.push(o)}return e}function Re(t){return Object.keys(t)}var Te=100,q=class{schema;options;length=0;objectRows=null;arrayRows=null;cursor=0;_headers=null;constructor(e,r){if(this.options=r,this.schema=e,e){this._headers=[];for(let o in e)this._headers[e[o].index]=e[o].name}}rowCount(){return this.length}addArrayRow(e,r){switch(Number.isFinite(r)&&(this.cursor=r),this._headers||=ke(e),this.options.shape){case"object-row-table":let o=Fe(e,this._headers);this.addObjectRow(o,r);break;case"array-row-table":this.arrayRows=this.arrayRows||new Array(Te),this.arrayRows[this.length]=e,this.length++;break}}addObjectRow(e,r){switch(Number.isFinite(r)&&(this.cursor=r),this._headers||=Re(e),this.options.shape){case"array-row-table":let o=_e(e,this._headers);this.addArrayRow(o,r);break;case"object-row-table":this.objectRows=this.objectRows||new Array(Te),this.objectRows[this.length]=e,this.length++;break}}getBatch(){let e=this.arrayRows||this.objectRows;return e?(e=e.slice(0,this.length),this.arrayRows=null,this.objectRows=null,{shape:this.options.shape,batchType:"data",data:e,length:this.length,schema:this.schema,cursor:this.cursor}):null}};var ee=class{schema;length=0;allocated=0;columns={};constructor(e,r){this.schema=e,this._reallocateColumns()}rowCount(){return this.length}addArrayRow(e){this._reallocateColumns();let r=0;for(let o in this.columns)this.columns[o][this.length]=e[r++];this.length++}addObjectRow(e){this._reallocateColumns();for(let r in e)this.columns[r][this.length]=e[r];this.length++}getBatch(){this._pruneColumns();let e=Array.isArray(this.schema)?this.columns:{};if(!Array.isArray(this.schema))for(let o in this.schema){let n=this.schema[o];e[n.name]=this.columns[n.index]}return this.columns={},{shape:"columnar-table",batchType:"data",data:e,schema:this.schema,length:this.length}}_reallocateColumns(){if(!(this.length<this.allocated)){this.allocated=this.allocated>0?this.allocated*=2:100,this.columns={};for(let e in this.schema){let r=this.schema[e],o=r.type||Float32Array,n=this.columns[r.index];if(n&&ArrayBuffer.isView(n)){let s=new o(this.allocated);s.set(n),this.columns[r.index]=s}else n?(n.length=this.allocated,this.columns[r.index]=n):this.columns[r.index]=new o(this.allocated)}}}_pruneColumns(){for(let[e,r]of Object.entries(this.columns))this.columns[e]=r.slice(0,this.length)}};var Nt={shape:void 0,batchSize:"auto",batchDebounceMs:0,limit:0,_limitMB:0},Ot="TableBatchBuilder",te=class{schema;options;aggregator=null;batchCount=0;bytesUsed=0;isChunkComplete=!1;lastBatchEmittedMs=Date.now();totalLength=0;totalBytes=0;rowBytes=0;constructor(e,r){this.schema=e,this.options={...Nt,...r}}limitReached(){return!!(Boolean(this.options?.limit)&&this.totalLength>=this.options.limit||Boolean(this.options?._limitMB)&&this.totalBytes/1e6>=this.options._limitMB)}addRow(e){this.limitReached()||(this.totalLength++,this.rowBytes=this.rowBytes||this._estimateRowMB(e),this.totalBytes+=this.rowBytes,Array.isArray(e)?this.addArrayRow(e):this.addObjectRow(e))}addArrayRow(e){if(!this.aggregator){let r=this._getTableBatchType();this.aggregator=new r(this.schema,this.options)}this.aggregator.addArrayRow(e)}addObjectRow(e){if(!this.aggregator){let r=this._getTableBatchType();this.aggregator=new r(this.schema,this.options)}this.aggregator.addObjectRow(e)}chunkComplete(e){e instanceof ArrayBuffer&&(this.bytesUsed+=e.byteLength),typeof e=="string"&&(this.bytesUsed+=e.length),this.isChunkComplete=!0}getFullBatch(e){return this._isFull()?this._getBatch(e):null}getFinalBatch(e){return this._getBatch(e)}_estimateRowMB(e){return Array.isArray(e)?e.length*8:Object.keys(e).length*8}_isFull(){if(!this.aggregator||this.aggregator.rowCount()===0)return!1;if(this.options.batchSize==="auto"){if(!this.isChunkComplete)return!1}else if(this.options.batchSize>this.aggregator.rowCount())return!1;return this.options.batchDebounceMs>Date.now()-this.lastBatchEmittedMs?!1:(this.isChunkComplete=!1,this.lastBatchEmittedMs=Date.now(),!0)}_getBatch(e){if(!this.aggregator)return null;e?.bytesUsed&&(this.bytesUsed=e.bytesUsed);let r=this.aggregator.getBatch();return r.count=this.batchCount,r.bytesUsed=this.bytesUsed,Object.assign(r,e),this.batchCount++,this.aggregator=null,r}_getTableBatchType(){switch(this.options.shape){case"array-row-table":case"object-row-table":return q;case"columnar-table":return ee;case"arrow-table":if(!te.ArrowBatch)throw new Error(Ot);return te.ArrowBatch;default:return X}}},S=te;Be(S,"ArrowBatch");function I(t){switch(t.shape){case"array-row-table":case"object-row-table":return t.data.length;case"geojson-table":return t.features.length;case"arrow-table":return t.data.numRows;case"columnar-table":for(let r of Object.values(t.data))return r.length||0;return 0;default:throw new Error("table")}}function re(t){if(t.schema)return t.schema.fields.length;if(I(t)===0)throw new Error("empty table");switch(t.shape){case"array-row-table":return t.data[0].length;case"object-row-table":return Object.keys(t.data[0]).length;case"geojson-table":return Object.keys(t.features[0]).length;case"columnar-table":return Object.keys(t.data).length;case"arrow-table":return t.data.numCols;default:throw new Error("table")}}function oe(t,e,r,o){switch(t.shape){case"object-row-table":return o?Object.fromEntries(Object.entries(t.data[e])):t.data[e];case"array-row-table":if(t.schema){let c=r||{};for(let l=0;l<t.schema.fields.length;l++)c[t.schema.fields[l].name]=t.data[e][l];return c}throw new Error("no schema");case"geojson-table":if(t.schema){let c=r||{};for(let l=0;l<t.schema.fields.length;l++)c[t.schema.fields[l].name]=t.features[e][l];return c}throw new Error("no schema");case"columnar-table":if(t.schema){let c=r||{};for(let l=0;l<t.schema.fields.length;l++)c[t.schema.fields[l].name]=t.data[t.schema.fields[l].name][e];return c}else{let c=r||{};for(let[l,u]of Object.entries(t.data))c[l]=u[e];return c}case"arrow-table":let n=t.data,s=r||{},a=n.get(e),i=n.schema;for(let c=0;c<i.fields.length;c++)s[i.fields[c].name]=a?.[i.fields[c].name];return s;default:throw new Error("shape")}}function ne(t,e,r,o){switch(t.shape){case"array-row-table":return o?Array.from(t.data[e]):t.data[e];case"object-row-table":if(t.schema){let c=r||[];for(let l=0;l<t.schema.fields.length;l++)c[l]=t.data[e][t.schema.fields[l].name];return c}return Object.values(t.data[e]);case"geojson-table":if(t.schema){let c=r||[];for(let l=0;l<t.schema.fields.length;l++)c[l]=t.features[e][t.schema.fields[l].name];return c}return Object.values(t.features[e]);case"columnar-table":if(t.schema){let c=r||[];for(let l=0;l<t.schema.fields.length;l++)c[l]=t.data[t.schema.fields[l].name][e];return c}else{let c=r||[],l=0;for(let u of Object.values(t.data))c[l]=u[e],l++;return c}case"arrow-table":let n=t.data,s=r||[],a=n.get(e),i=n.schema;for(let c=0;c<i.fields.length;c++)s[c]=a?.[i.fields[c].name];return s;default:throw new Error("shape")}}function*fe(t,e){switch(e){case"array-row-table":yield*ve(t);break;case"object-row-table":yield*Ue(t);break;default:throw new Error(`Unknown row type ${e}`)}}function*ve(t,e=[]){let r=I(t);for(let o=0;o<r;o++)yield ne(t,o,e)}function*Ue(t,e={}){let r=I(t);for(let o=0;o<r;o++)yield oe(t,o,e)}function De(t){switch(t.shape){case"array-row-table":case"object-row-table":return It(t.data);case"geojson-table":return Bt(t.features);case"columnar-table":return St(t.data);case"arrow-table":default:throw new Error("Deduce schema")}}function St(t){let e=[];for(let[r,o]of Object.entries(t)){let n=Et(o,r);e.push(n)}return{fields:e,metadata:{}}}function It(t){if(!t.length)throw new Error("deduce from empty table");let e=[],r=t[0];for(let[o,n]of Object.entries(r))e.push(Je(n,o));return{fields:e,metadata:{}}}function Bt(t){if(!t.length)throw new Error("deduce from empty table");let e=[],r=t[0].properties||{};for(let[o,n]of Object.entries(r))e.push(Je(n,o));return{fields:e,metadata:{}}}function Et(t,e){if(ArrayBuffer.isView(t)){let r=Le(t);return{name:e,type:r.type||"null",nullable:r.nullable}}if(Array.isArray(t)&&t.length>0){let r=t[0],o=Q(r);return{name:e,type:o,nullable:!0}}throw new Error("empty table")}function Je(t,e){let r=Q(t);return{name:e,type:r,nullable:!0}}function U(t){let e;switch(Ct(t)){case"array-row-table":e={shape:"array-row-table",data:t};break;case"object-row-table":e={shape:"object-row-table",data:t};break;case"columnar-table":e={shape:"columnar-table",data:t};break;default:throw new Error("table")}let r=De(e);return{...e,schema:r}}function Ct(t){if(Array.isArray(t)){if(t.length===0)throw new Error("cannot deduce type of empty table");let e=t[0];if(Array.isArray(e))return"array-row-table";if(e&&typeof e=="object")return"object-row-table"}if(t&&typeof t=="object")return"columnar-table";throw new Error("invalid table")}function Ge(t,e){try{let r=JSON.parse(t);if(e.json?.table){let o=Me(r)||r;return U(o)}return r}catch{throw new Error("JSONLoader: failed to parse JSON")}}function Me(t){if(Array.isArray(t))return t;if(t&&typeof t=="object")for(let e of Object.values(t)){let r=Me(e);if(r)return r}return null}function pe(t,e){if(!t)throw new Error(e||"loader assertion failed.")}function ze(...t){return Lt(t)}function Lt(t){let e=t.map(s=>s instanceof ArrayBuffer?new Uint8Array(s):s),r=e.reduce((s,a)=>s+a.byteLength,0),o=new Uint8Array(r),n=0;for(let s of e)o.set(s,n),n+=s.byteLength;return o.buffer}async function*D(t,e={}){let r=new TextDecoder(void 0,e);for await(let o of t)yield typeof o=="string"?o:r.decode(o,{stream:!0})}async function*de(t){let e="";for await(let r of t){e+=r;let o;for(;(o=e.indexOf(`
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
"use strict";var __exports__=(()=>{var hu=Object.create;var Ln=Object.defineProperty;var fu=Object.getOwnPropertyDescriptor;var du=Object.getOwnPropertyNames;var pu=Object.getPrototypeOf,mu=Object.prototype.hasOwnProperty;var yu=(r,t,e)=>t in r?Ln(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var gu=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ur=(r,t)=>{for(var e in t)Ln(r,e,{get:t[e],enumerable:!0})},Mi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of du(t))!mu.call(r,i)&&i!==e&&Ln(r,i,{get:()=>t[i],enumerable:!(n=fu(t,i))||n.enumerable});return r},Ei=(r,t,e)=>(Mi(r,t,"default"),e&&Mi(e,t,"default")),bu=(r,t,e)=>(e=r!=null?hu(pu(r)):{},Mi(t||!r||!r.__esModule?Ln(e,"default",{value:r,enumerable:!0}):e,r)),_u=r=>Mi(Ln({},"__esModule",{value:!0}),r);var La=(r,t,e)=>(yu(r,typeof t!="symbol"?t+"":t,e),e);var Ma=gu((rp,Ua)=>{Ua.exports=globalThis.loaders});var Ui={};ur(Ui,{JSONLoader:()=>lo,JSONWriter:()=>Yl,NDJSONLoader:()=>Hl,_ClarinetParser:()=>Xr,_GeoJSONLoader:()=>Nn,_GeoJSONWorkerLoader:()=>Ta,_GeoJSONWriter:()=>uu,_JSONPath:()=>Dt,_rebuildJsonObject:()=>Gl});Ei(Ui,bu(Ma(),1));function Ci(r,t="float32"){return r instanceof Date?"date-millisecond":r instanceof Number?t:typeof r=="string"?"utf8":(r===null||r==="undefined","null")}function Ea(r){let t=wu(r);return t!=="null"?{type:t,nullable:!1}:r.length>0?(t=Ci(r[0]),{type:t,nullable:!0}):{type:"null",nullable:!0}}function wu(r){switch(r.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function Ca(r,t){if(!t)switch(r){case"int8":return Int8Array;case"uint8":return Uint8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;default:break}return Array}function Pa(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e}function y(r,t,e,n){function i(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{l(n.next(u))}catch(f){o(f)}}function c(u){try{l(n.throw(u))}catch(f){o(f)}}function l(u){u.done?s(u.value):i(u.value).then(a,c)}l((n=n.apply(r,t||[])).next())})}function Ra(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],n=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function C(r){return this instanceof C?(this.v=r,this):new C(r)}function Ht(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(r,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(p){return function(g){return Promise.resolve(g).then(p,f)}}function a(p,g){n[p]&&(i[p]=function(G){return new Promise(function(nt,Ft){s.push([p,G,nt,Ft])>1||c(p,G)})},g&&(i[p]=g(i[p])))}function c(p,g){try{l(n[p](g))}catch(G){d(s[0][3],G)}}function l(p){p.value instanceof C?Promise.resolve(p.value.v).then(u,f):d(s[0][2],p)}function u(p){c("next",p)}function f(p){c("throw",p)}function d(p,g){p(g),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Qr(r){var t,e;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=r[i]?function(o){return(e=!e)?{value:C(r[i](o)),done:!1}:s?s(o):o}:s}}function ce(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof Ra=="function"?Ra(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=r[s]&&function(o){return new Promise(function(a,c){o=r[s](o),i(a,c,o.done,o.value)})}}function i(s,o,a,c){Promise.resolve(c).then(function(l){s({value:l,done:a})},o)}}var wo={};ur(wo,{compareArrayLike:()=>_o,joinUint8Arrays:()=>Yt,memcpy:()=>En,rebaseValueOffsets:()=>Gi,toArrayBufferView:()=>R,toArrayBufferViewAsyncIterator:()=>he,toArrayBufferViewIterator:()=>Ie,toBigInt64Array:()=>Wi,toBigUint64Array:()=>Fu,toFloat32Array:()=>Tu,toFloat32ArrayAsyncIterator:()=>$u,toFloat32ArrayIterator:()=>Pu,toFloat64Array:()=>Nu,toFloat64ArrayAsyncIterator:()=>Hu,toFloat64ArrayIterator:()=>ju,toInt16Array:()=>Au,toInt16ArrayAsyncIterator:()=>zu,toInt16ArrayIterator:()=>Mu,toInt32Array:()=>vr,toInt32ArrayAsyncIterator:()=>Wu,toInt32ArrayIterator:()=>Eu,toInt8Array:()=>Bu,toInt8ArrayAsyncIterator:()=>Vu,toInt8ArrayIterator:()=>Uu,toUint16Array:()=>Ou,toUint16ArrayAsyncIterator:()=>Gu,toUint16ArrayIterator:()=>Cu,toUint32Array:()=>Du,toUint32ArrayAsyncIterator:()=>Ju,toUint32ArrayIterator:()=>Ru,toUint8Array:()=>T,toUint8ArrayAsyncIterator:()=>bo,toUint8ArrayIterator:()=>go,toUint8ClampedArray:()=>Lu,toUint8ClampedArrayAsyncIterator:()=>Yu,toUint8ClampedArrayIterator:()=>ku});var vu=new TextDecoder("utf-8"),Un=r=>vu.decode(r),Iu=new TextEncoder,ve=r=>Iu.encode(r);var xu=r=>typeof r=="number",ja=r=>typeof r=="boolean",pt=r=>typeof r=="function",Tt=r=>r!=null&&Object(r)===r,le=r=>Tt(r)&&pt(r.then);var ue=r=>Tt(r)&&pt(r[Symbol.iterator]),Qt=r=>Tt(r)&&pt(r[Symbol.asyncIterator]),Ri=r=>Tt(r)&&Tt(r.schema);var Pi=r=>Tt(r)&&"done"in r&&"value"in r;var ji=r=>Tt(r)&&pt(r.stat)&&xu(r.fd);var ki=r=>Tt(r)&&Mn(r.body),Vi=r=>"_getDOMStream"in r&&"_getNodeStream"in r,ka=r=>Tt(r)&&pt(r.abort)&&pt(r.getWriter)&&!Vi(r),Mn=r=>Tt(r)&&pt(r.cancel)&&pt(r.getReader)&&!Vi(r),Va=r=>Tt(r)&&pt(r.end)&&pt(r.write)&&ja(r.writable)&&!Vi(r),zi=r=>Tt(r)&&pt(r.read)&&pt(r.pipe)&&ja(r.readable)&&!Vi(r),za=r=>Tt(r)&&pt(r.clear)&&pt(r.bytes)&&pt(r.position)&&pt(r.setPosition)&&pt(r.capacity)&&pt(r.getBufferIdentifier)&&pt(r.createLong);var yo=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Su(r){let t=r[0]?[r[0]]:[],e,n,i,s;for(let o,a,c=0,l=0,u=r.length;++c<u;){if(o=t[l],a=r[c],!o||!a||o.buffer!==a.buffer||a.byteOffset<o.byteOffset){a&&(t[++l]=a);continue}if({byteOffset:e,byteLength:i}=o,{byteOffset:n,byteLength:s}=a,e+i<n||n+s<e){a&&(t[++l]=a);continue}t[l]=new Uint8Array(o.buffer,e,n-e+s)}return t}function En(r,t,e=0,n=t.byteLength){let i=r.byteLength,s=new Uint8Array(r.buffer,r.byteOffset,i),o=new Uint8Array(t.buffer,t.byteOffset,Math.min(n,i));return s.set(o,e),r}function Yt(r,t){let e=Su(r),n=e.reduce((u,f)=>u+f.byteLength,0),i,s,o,a=0,c=-1,l=Math.min(t||Number.POSITIVE_INFINITY,n);for(let u=e.length;++c<u;){if(i=e[c],s=i.subarray(0,Math.min(i.length,l-a)),l<=a+s.length){s.length<i.length?e[c]=i.subarray(s.length):s.length===i.length&&c++,o?En(o,s,a):o=s;break}En(o||(o=new Uint8Array(l)),s,a),a+=s.length}return[o||new Uint8Array(0),e.slice(c),n-(o?o.byteLength:0)]}function R(r,t){let e=Pi(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=ve(e)),e instanceof ArrayBuffer?new r(e):e instanceof yo?new r(e):za(e)?R(r,e.bytes()):ArrayBuffer.isView(e)?e.byteLength<=0?new r(0):new r(e.buffer,e.byteOffset,e.byteLength/r.BYTES_PER_ELEMENT):r.from(e)):new r(0)}var Bu=r=>R(Int8Array,r),Au=r=>R(Int16Array,r),vr=r=>R(Int32Array,r),Wi=r=>R(BigInt64Array,r),T=r=>R(Uint8Array,r),Ou=r=>R(Uint16Array,r),Du=r=>R(Uint32Array,r),Fu=r=>R(BigUint64Array,r),Tu=r=>R(Float32Array,r),Nu=r=>R(Float64Array,r),Lu=r=>R(Uint8ClampedArray,r),mo=r=>(r.next(),r);function*Ie(r,t){let e=function*(i){yield i},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof yo?e(t):ue(t)?t:e(t);return yield*mo(function*(i){let s=null;do s=i.next(yield R(r,s));while(!s.done)}(n[Symbol.iterator]())),new r}var Uu=r=>Ie(Int8Array,r),Mu=r=>Ie(Int16Array,r),Eu=r=>Ie(Int32Array,r),go=r=>Ie(Uint8Array,r),Cu=r=>Ie(Uint16Array,r),Ru=r=>Ie(Uint32Array,r),Pu=r=>Ie(Float32Array,r),ju=r=>Ie(Float64Array,r),ku=r=>Ie(Uint8ClampedArray,r);function he(r,t){return Ht(this,arguments,function*(){if(le(t))return yield C(yield C(yield*Qr(ce(he(r,yield C(t))))));let n=function(o){return Ht(this,arguments,function*(){yield yield C(yield C(o))})},i=function(o){return Ht(this,arguments,function*(){yield C(yield*Qr(ce(mo(function*(a){let c=null;do c=a.next(yield c?.value);while(!c.done)}(o[Symbol.iterator]())))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof yo?n(t):ue(t)?i(t):Qt(t)?t:n(t);return yield C(yield*Qr(ce(mo(function(o){return Ht(this,arguments,function*(){let a=null;do a=yield C(o.next(yield yield C(R(r,a))));while(!a.done)})}(s[Symbol.asyncIterator]()))))),yield C(new r)})}var Vu=r=>he(Int8Array,r),zu=r=>he(Int16Array,r),Wu=r=>he(Int32Array,r),bo=r=>he(Uint8Array,r),Gu=r=>he(Uint16Array,r),Ju=r=>he(Uint32Array,r),$u=r=>he(Float32Array,r),Hu=r=>he(Float64Array,r),Yu=r=>he(Uint8ClampedArray,r);function Gi(r,t,e){if(r!==0){e=e.slice(0,t);for(let n=-1,i=e.length;++n<i;)e[n]+=r}return e.subarray(0,t)}function _o(r,t){let e=0,n=r.length;if(n!==t.length)return!1;if(n>0)do if(r[e]!==t[e])return!1;while(++e<n);return!0}var wt={fromIterable(r){return Ji(Zu(r))},fromAsyncIterable(r){return Ji(Ku(r))},fromDOMStream(r){return Ji(Xu(r))},fromNodeStream(r){return Ji(qu(r))},toDOMStream(r,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(r,t){throw new Error('"toNodeStream" not available in this environment')}},Ji=r=>(r.next(),r);function*Zu(r){let t,e=!1,n=[],i,s,o,a=0;function c(){return s==="peek"?Yt(n,o)[0]:([i,n,a]=Yt(n,o),i)}({cmd:s,size:o}=(yield(()=>null)())||{cmd:"read",size:0});let l=go(r)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-a)?l.next():l.next(o-a),!t&&i.byteLength>0&&(n.push(i),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield c());while(o<a);while(!t)}catch(u){(e=!0)&&typeof l.throw=="function"&&l.throw(u)}finally{e===!1&&typeof l.return=="function"&&l.return(null)}return null}function Ku(r){return Ht(this,arguments,function*(){let e,n=!1,i=[],s,o,a,c=0;function l(){return o==="peek"?Yt(i,a)[0]:([s,i,c]=Yt(i,a),s)}({cmd:o,size:a}=(yield yield C((()=>null)()))||{cmd:"read",size:0});let u=bo(r)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(a-c)?yield C(u.next()):yield C(u.next(a-c)),!e&&s.byteLength>0&&(i.push(s),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield C(l()));while(a<c);while(!e)}catch(f){(n=!0)&&typeof u.throw=="function"&&(yield C(u.throw(f)))}finally{n===!1&&typeof u.return=="function"&&(yield C(u.return(new Uint8Array(0))))}return yield C(null)})}function Xu(r){return Ht(this,arguments,function*(){let e=!1,n=!1,i=[],s,o,a,c=0;function l(){return o==="peek"?Yt(i,a)[0]:([s,i,c]=Yt(i,a),s)}({cmd:o,size:a}=(yield yield C((()=>null)()))||{cmd:"read",size:0});let u=new Io(r);try{do if({done:e,value:s}=Number.isNaN(a-c)?yield C(u.read()):yield C(u.read(a-c)),!e&&s.byteLength>0&&(i.push(T(s)),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield C(l()));while(a<c);while(!e)}catch(f){(n=!0)&&(yield C(u.cancel(f)))}finally{n===!1?yield C(u.cancel()):r.locked&&u.releaseLock()}return yield C(null)})}var Io=class{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return y(this,void 0,void 0,function*(){let{reader:e,source:n}=this;e&&(yield e.cancel(t).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(t){return y(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};let e=yield this.reader.read();return!e.done&&(e.value=T(e)),e})}},vo=(r,t)=>{let e=i=>n([t,i]),n;return[t,e,new Promise(i=>(n=i)&&r.once(t,e))]};function qu(r){return Ht(this,arguments,function*(){let e=[],n="error",i=!1,s=null,o,a,c=0,l=[],u;function f(){return o==="peek"?Yt(l,a)[0]:([u,l,c]=Yt(l,a),u)}if({cmd:o,size:a}=(yield yield C((()=>null)()))||{cmd:"read",size:0},r.isTTY)return yield yield C(new Uint8Array(0)),yield C(null);try{e[0]=vo(r,"end"),e[1]=vo(r,"error");do{if(e[2]=vo(r,"readable"),[n,s]=yield C(Promise.race(e.map(p=>p[2]))),n==="error")break;if((i=n==="end")||(Number.isFinite(a-c)?(u=T(r.read(a-c)),u.byteLength<a-c&&(u=T(r.read()))):u=T(r.read()),u.byteLength>0&&(l.push(u),c+=u.byteLength)),i||a<=c)do({cmd:o,size:a}=yield yield C(f()));while(a<c)}while(!i)}finally{yield C(d(e,n==="error"?s:null))}return yield C(null);function d(p,g){return u=l=null,new Promise((G,nt)=>{for(let[Ft,or]of p)r.off(Ft,or);try{let Ft=r.destroy;Ft&&Ft.call(r,g),g=void 0}catch(Ft){g=Ft||g}finally{g!=null?nt(g):G()}})}})}var H;(function(r){r[r.V1=0]="V1",r[r.V2=1]="V2",r[r.V3=2]="V3",r[r.V4=3]="V4",r[r.V5=4]="V5"})(H||(H={}));var q;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(q||(q={}));var K;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(K||(K={}));var at;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(at||(at={}));var v;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(v||(v={}));var mt;(function(r){r[r.YEAR_MONTH=0]="YEAR_MONTH",r[r.DAY_TIME=1]="DAY_TIME",r[r.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(mt||(mt={}));var xe=new Int32Array(2),$i=new Float32Array(xe.buffer),Hi=new Float64Array(xe.buffer),tn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Cn;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Cn||(Cn={}));var Nt=class{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new Nt(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return xe[0]=this.readInt32(t),$i[0]}readFloat64(t){return xe[tn?0:1]=this.readInt32(t),xe[tn?1:0]=this.readInt32(t+4),Hi[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){$i[0]=e,this.writeInt32(t,xe[0])}writeFloat64(t,e){Hi[0]=e,this.writeInt32(t,xe[tn?0:1]),this.writeInt32(t+4,xe[tn?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){let n=t-this.readInt32(t);return e<this.readInt16(n)?this.readInt16(n+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);let n=this.readInt32(t);t+=4;let i=this.bytes_.subarray(t,t+n);return e===Cn.UTF8_BYTES?i:this.text_decoder_.decode(i)}__union_with_string(t,e){return typeof t=="string"?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=4)throw new Error("FlatBuffers: file identifier must be length "+4);for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createScalarList(t,e){let n=[];for(let i=0;i<e;++i){let s=t(i);s!==null&&n.push(s)}return n}createObjList(t,e){let n=[];for(let i=0;i<e;++i){let s=t(i);s!==null&&n.push(s.unpack())}return n}};var Ye=class{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let e;t?e=t:e=1024,this.bb=Nt.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);let n=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<n+t+e;){let i=this.bb.capacity();this.bb=Ye.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(n)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,n){(this.force_defaults||e!=n)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,n){(this.force_defaults||e!=n)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,n){(this.force_defaults||e!=n)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,n){(this.force_defaults||e!==n)&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,n){(this.force_defaults||e!=n)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,n){e!=n&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){let e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");let n=e<<1,i=Nt.allocate(n);return i.setPosition(n-e),i.bytes().set(t.bytes(),n-e),i}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);let t=this.offset(),e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);let n=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);let i=2;this.addInt16(t-this.object_start);let s=(n+i)*2;this.addInt16(s);let o=0,a=this.space;t:for(e=0;e<this.vtables.length;e++){let c=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(c)){for(let l=2;l<s;l+=2)if(this.bb.readInt16(a+l)!=this.bb.readInt16(c+l))continue t;o=this.vtables[e];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,n){let i=n?4:0;if(e){let s=e;if(this.prep(this.minalign,4+4+i),s.length!=4)throw new TypeError("FlatBuffers: file identifier must be length "+4);for(let o=4-1;o>=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,4+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){let n=this.bb.capacity()-t,i=n-this.bb.readInt32(n);if(!(e<this.bb.readInt16(i)&&this.bb.readInt16(i+e)!=0))throw new TypeError("FlatBuffers: field "+e+" must be set")}startVector(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(n,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);let e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(t==null)return 0;let e;return t instanceof Uint8Array?e=t:e=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){let e=[];for(let n=0;n<t.length;++n){let i=t[n];if(i!==null)e.push(this.createObjectOffset(i));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var Rn;(function(r){r[r.BUFFER=0]="BUFFER"})(Rn||(Rn={}));var Pn;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(Pn||(Pn={}));var de=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new de).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new de).__init(t.readInt32(t.position())+t.position(),t)}codec(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):Pn.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Rn.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,Pn.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,Rn.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return de.startBodyCompression(t),de.addCodec(t,e),de.addMethod(t,n),de.endBodyCompression(t)}};var en=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)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n??0)),t.writeInt64(BigInt(e??0)),t.offset()}};var rn=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n??0)),t.writeInt64(BigInt(e??0)),t.offset()}};var xt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(t,e){return(e||new xt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new xt).__init(t.readInt32(t.position())+t.position(),t)}length(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new rn).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}nodesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new en).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}buffersLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){let e=this.bb.__offset(this.bb_pos,10);return e?(t||new de).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addNodes(t,e){t.addFieldOffset(1,e,0)}static startNodesVector(t,e){t.startVector(16,e,8)}static addBuffers(t,e){t.addFieldOffset(2,e,0)}static startBuffersVector(t,e){t.startVector(16,e,8)}static addCompression(t,e){t.addFieldOffset(3,e,0)}static endRecordBatch(t){return t.endObject()}};var ee=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(t,e){return(e||new ee).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new ee).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new xt).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}};var hr;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(hr||(hr={}));var jn;(function(r){r[r.DenseArray=0]="DenseArray"})(jn||(jn={}));var yt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInt(t,e){return(e||new yt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+4),(e||new yt).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,e){t.addFieldInt32(0,e,0)}static addIsSigned(t,e){t.addFieldInt8(1,+e,0)}static endInt(t){return t.endObject()}static createInt(t,e,n){return yt.startInt(t),yt.addBitWidth(t,e),yt.addIsSigned(t,n),yt.endInt(t)}};var Zt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryEncoding(t,e){return(e||new Zt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+4),(e||new Zt).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new yt).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isOrdered(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):jn.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addIndexType(t,e){t.addFieldOffset(1,e,0)}static addIsOrdered(t,e){t.addFieldInt8(2,+e,0)}static addDictionaryKind(t,e){t.addFieldInt16(3,e,jn.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}};var Q=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsKeyValue(t,e){return(e||new Q).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+4),(e||new Q).__init(t.readInt32(t.position())+t.position(),t)}key(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}value(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,e){t.addFieldOffset(0,e,0)}static addValue(t,e){t.addFieldOffset(1,e,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,e,n){return Q.startKeyValue(t),Q.addKey(t,e),Q.addValue(t,n),Q.endKeyValue(t)}};var Se=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinary(t,e){return(e||new Se).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+4),(e||new Se).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return Se.startBinary(t),Se.endBinary(t)}};var Be=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBool(t,e){return(e||new Be).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+4),(e||new Be).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return Be.startBool(t),Be.endBool(t)}};var Mt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDate(t,e){return(e||new Mt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+4),(e||new Mt).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):at.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,at.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return Mt.startDate(t),Mt.addUnit(t,e),Mt.endDate(t)}};var gt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDecimal(t,e){return(e||new gt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+4),(e||new gt).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,e){t.addFieldInt32(0,e,0)}static addScale(t,e){t.addFieldInt32(1,e,0)}static addBitWidth(t,e){t.addFieldInt32(2,e,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,e,n,i){return gt.startDecimal(t),gt.addPrecision(t,e),gt.addScale(t,n),gt.addBitWidth(t,i),gt.endDecimal(t)}};var Et=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDuration(t,e){return(e||new Et).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+4),(e||new Et).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):v.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,v.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return Et.startDuration(t),Et.addUnit(t,e),Et.endDuration(t)}};var Ct=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeBinary(t,e){return(e||new Ct).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+4),(e||new Ct).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,e){return Ct.startFixedSizeBinary(t),Ct.addByteWidth(t,e),Ct.endFixedSizeBinary(t)}};var Rt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeList(t,e){return(e||new Rt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+4),(e||new Rt).__init(t.readInt32(t.position())+t.position(),t)}listSize(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,e){return Rt.startFixedSizeList(t),Rt.addListSize(t,e),Rt.endFixedSizeList(t)}};var Pt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFloatingPoint(t,e){return(e||new Pt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+4),(e||new Pt).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):K.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,K.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return Pt.startFloatingPoint(t),Pt.addPrecision(t,e),Pt.endFloatingPoint(t)}};var jt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInterval(t,e){return(e||new jt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+4),(e||new jt).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):mt.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,mt.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return jt.startInterval(t),jt.addUnit(t,e),jt.endInterval(t)}};var Ae=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeBinary(t,e){return(e||new Ae).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+4),(e||new Ae).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return Ae.startLargeBinary(t),Ae.endLargeBinary(t)}};var Oe=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeUtf8(t,e){return(e||new Oe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+4),(e||new Oe).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return Oe.startLargeUtf8(t),Oe.endLargeUtf8(t)}};var De=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsList(t,e){return(e||new De).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+4),(e||new De).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return De.startList(t),De.endList(t)}};var kt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMap(t,e){return(e||new kt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+4),(e||new kt).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){let t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,e){t.addFieldInt8(0,+e,0)}static endMap(t){return t.endObject()}static createMap(t,e){return kt.startMap(t),kt.addKeysSorted(t,e),kt.endMap(t)}};var Fe=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNull(t,e){return(e||new Fe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+4),(e||new Fe).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return Fe.startNull(t),Fe.endNull(t)}};var Te=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsStruct_(t,e){return(e||new Te).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+4),(e||new Te).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return Te.startStruct_(t),Te.endStruct_(t)}};var St=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTime(t,e){return(e||new St).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+4),(e||new St).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):v.MILLISECOND}bitWidth(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,v.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return St.startTime(t),St.addUnit(t,e),St.addBitWidth(t,n),St.endTime(t)}};var Bt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTimestamp(t,e){return(e||new Bt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+4),(e||new Bt).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):v.SECOND}timezone(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,v.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return Bt.startTimestamp(t),Bt.addUnit(t,e),Bt.addTimezone(t,n),Bt.endTimestamp(t)}};var bt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUnion(t,e){return(e||new bt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+4),(e||new bt).__init(t.readInt32(t.position())+t.position(),t)}mode(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):q.Sparse}typeIds(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+t*4):0}typeIdsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,e){t.addFieldInt16(0,e,q.Sparse)}static addTypeIds(t,e){t.addFieldOffset(1,e,0)}static createTypeIdsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addInt32(e[n]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,n){return bt.startUnion(t),bt.addMode(t,e),bt.addTypeIds(t,n),bt.endUnion(t)}};var Ne=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new Ne).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new Ne).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Ne.startUtf8(t),Ne.endUtf8(t)}};var X;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.FloatingPoint=3]="FloatingPoint",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct_=13]="Struct_",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.LargeList=21]="LargeList",r[r.RunEndEncoded=22]="RunEndEncoded"})(X||(X={}));var lt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(t,e){return(e||new lt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+4),(e||new lt).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):X.NONE}type(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){let e=this.bb.__offset(this.bb_pos,12);return e?(t||new Zt).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){let n=this.bb.__offset(this.bb_pos,14);return n?(e||new lt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}childrenLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,16);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,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,X.NONE)}static addType(t,e){t.addFieldOffset(3,e,0)}static addDictionary(t,e){t.addFieldOffset(4,e,0)}static addChildren(t,e){t.addFieldOffset(5,e,0)}static createChildrenVector(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 startChildrenVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(6,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 endField(t){return t.endObject()}};var it=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(t,e){return(e||new it).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+4),(e||new it).__init(t.readInt32(t.position())+t.position(),t)}endianness(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):hr.Little}fields(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new lt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}fieldsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,8);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,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}featuresLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,hr.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(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 startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,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 addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(t,e,n,i,s){return it.startSchema(t),it.addEndianness(t,e),it.addFields(t,n),it.addCustomMetadata(t,i),it.addFeatures(t,s),it.endSchema(t)}};var j;(function(r){r[r.NONE=0]="NONE",r[r.Schema=1]="Schema",r[r.DictionaryBatch=2]="DictionaryBatch",r[r.RecordBatch=3]="RecordBatch",r[r.Tensor=4]="Tensor",r[r.SparseTensor=5]="SparseTensor"})(j||(j={}));var h;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.Float=3]="Float",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct=13]="Struct",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.Dictionary=-1]="Dictionary",r[r.Int8=-2]="Int8",r[r.Int16=-3]="Int16",r[r.Int32=-4]="Int32",r[r.Int64=-5]="Int64",r[r.Uint8=-6]="Uint8",r[r.Uint16=-7]="Uint16",r[r.Uint32=-8]="Uint32",r[r.Uint64=-9]="Uint64",r[r.Float16=-10]="Float16",r[r.Float32=-11]="Float32",r[r.Float64=-12]="Float64",r[r.DateDay=-13]="DateDay",r[r.DateMillisecond=-14]="DateMillisecond",r[r.TimestampSecond=-15]="TimestampSecond",r[r.TimestampMillisecond=-16]="TimestampMillisecond",r[r.TimestampMicrosecond=-17]="TimestampMicrosecond",r[r.TimestampNanosecond=-18]="TimestampNanosecond",r[r.TimeSecond=-19]="TimeSecond",r[r.TimeMillisecond=-20]="TimeMillisecond",r[r.TimeMicrosecond=-21]="TimeMicrosecond",r[r.TimeNanosecond=-22]="TimeNanosecond",r[r.DenseUnion=-23]="DenseUnion",r[r.SparseUnion=-24]="SparseUnion",r[r.IntervalDayTime=-25]="IntervalDayTime",r[r.IntervalYearMonth=-26]="IntervalYearMonth",r[r.DurationSecond=-27]="DurationSecond",r[r.DurationMillisecond=-28]="DurationMillisecond",r[r.DurationMicrosecond=-29]="DurationMicrosecond",r[r.DurationNanosecond=-30]="DurationNanosecond"})(h||(h={}));var pe;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(pe||(pe={}));var zo={};ur(zo,{clampRange:()=>Wn,createElementComparator:()=>mr,wrapIndex:()=>Nr});var xo={};ur(xo,{valueToString:()=>me});function me(r){if(r===null)return"null";if(r===void 0)return"undefined";switch(typeof r){case"number":return`${r}`;case"bigint":return`${r}`;case"string":return`"${r}"`}return typeof r[Symbol.toPrimitive]=="function"?r[Symbol.toPrimitive]("string"):ArrayBuffer.isView(r)?r instanceof BigInt64Array||r instanceof BigUint64Array?`[${[...r].map(t=>me(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}var Oo={};ur(Oo,{BN:()=>Ir,bigNumToBigInt:()=>Ga,bigNumToNumber:()=>Ao,bigNumToString:()=>on,isArrowBigNumSymbol:()=>Wa});function W(r){if(typeof r=="bigint"&&(r<Number.MIN_SAFE_INTEGER||r>Number.MAX_SAFE_INTEGER))throw new TypeError(`${r} is not safe to convert to a number.`);return Number(r)}function So(r,t){return W(r/t)+W(r%t)/W(t)}var Wa=Symbol.for("isArrowBigNum");function ye(r,...t){return t.length===0?Object.setPrototypeOf(R(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}ye.prototype[Wa]=!0;ye.prototype.toJSON=function(){return`"${on(this)}"`};ye.prototype.valueOf=function(r){return Ao(this,r)};ye.prototype.toString=function(){return on(this)};ye.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Ao(this);case"string":return on(this);case"default":return Ga(this)}return on(this)};function nn(...r){return ye.apply(this,r)}function sn(...r){return ye.apply(this,r)}function kn(...r){return ye.apply(this,r)}Object.setPrototypeOf(nn.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(sn.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(kn.prototype,Object.create(Uint32Array.prototype));Object.assign(nn.prototype,ye.prototype,{constructor:nn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(sn.prototype,ye.prototype,{constructor:sn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(kn.prototype,ye.prototype,{constructor:kn,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var Qu=BigInt(4294967296)*BigInt(4294967296),th=Qu-BigInt(1);function Ao(r,t){let{buffer:e,byteOffset:n,byteLength:i,signed:s}=r,o=new BigUint64Array(e,n,i/8),a=s&&o.at(-1)&BigInt(1)<<BigInt(63),c=BigInt(0),l=0;if(a){for(let u of o)c|=(u^th)*(BigInt(1)<<BigInt(64*l++));c*=BigInt(-1),c-=BigInt(1)}else for(let u of o)c|=u*(BigInt(1)<<BigInt(64*l++));if(typeof t=="number"){let u=BigInt(Math.pow(10,t)),f=c/u,d=c%u;return W(f)+W(d)/W(u)}return W(c)}function on(r){if(r.byteLength===8)return`${new r.BigIntArray(r.buffer,r.byteOffset,1)[0]}`;if(!r.signed)return Bo(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Bo(r);t=t.slice();let n=1;for(let s=0;s<t.length;s++){let o=t[s],a=~o+n;t[s]=a,n&=o===0?1:0}return`-${Bo(t)}`}function Ga(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:on(r)}function Bo(r){let t="",e=new Uint32Array(2),n=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),i=new Uint32Array((n=new Uint16Array(n).reverse()).buffer),s=-1,o=n.length-1;do{for(e[0]=n[s=0];s<o;)n[s++]=e[1]=e[0]/10,e[0]=(e[0]-e[1]*10<<16)+n[s];n[s]=e[1]=e[0]/10,e[0]=e[0]-e[1]*10,t=`${e[0]}${t}`}while(i[0]||i[1]||i[2]||i[3]);return t??"0"}var Ir=class{static new(t,e){switch(e){case!0:return new nn(t);case!1:return new sn(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new nn(t)}return t.byteLength===16?new kn(t):new sn(t)}static signed(t){return new nn(t)}static unsigned(t){return new sn(t)}static decimal(t){return new kn(t)}constructor(t,e){return Ir.new(t,e)}};var Ja,$a,Ha,Ya,Za,Ka,Xa,qa,Qa,tc,ec,rc,nc,ic,sc,oc,ac,cc,lc,uc,hc,fc,m=class{static isNull(t){return t?.typeId===h.Null}static isInt(t){return t?.typeId===h.Int}static isFloat(t){return t?.typeId===h.Float}static isBinary(t){return t?.typeId===h.Binary}static isLargeBinary(t){return t?.typeId===h.LargeBinary}static isUtf8(t){return t?.typeId===h.Utf8}static isLargeUtf8(t){return t?.typeId===h.LargeUtf8}static isBool(t){return t?.typeId===h.Bool}static isDecimal(t){return t?.typeId===h.Decimal}static isDate(t){return t?.typeId===h.Date}static isTime(t){return t?.typeId===h.Time}static isTimestamp(t){return t?.typeId===h.Timestamp}static isInterval(t){return t?.typeId===h.Interval}static isDuration(t){return t?.typeId===h.Duration}static isList(t){return t?.typeId===h.List}static isStruct(t){return t?.typeId===h.Struct}static isUnion(t){return t?.typeId===h.Union}static isFixedSizeBinary(t){return t?.typeId===h.FixedSizeBinary}static isFixedSizeList(t){return t?.typeId===h.FixedSizeList}static isMap(t){return t?.typeId===h.Map}static isDictionary(t){return t?.typeId===h.Dictionary}static isDenseUnion(t){return m.isUnion(t)&&t.mode===q.Dense}static isSparseUnion(t){return m.isUnion(t)&&t.mode===q.Sparse}constructor(t){this.typeId=t}};Ja=Symbol.toStringTag;m[Ja]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(m.prototype);var At=class extends m{constructor(){super(h.Null)}toString(){return"Null"}};$a=Symbol.toStringTag;At[$a]=(r=>r[Symbol.toStringTag]="Null")(At.prototype);var ut=class extends m{constructor(t,e){super(h.Int),this.isSigned=t,this.bitWidth=e}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}};Ha=Symbol.toStringTag;ut[Ha]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(ut.prototype);var xr=class extends ut{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},Sr=class extends ut{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},Kt=class extends ut{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Br=class extends ut{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Ar=class extends ut{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},Or=class extends ut{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Dr=class extends ut{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Fr=class extends ut{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(xr.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(Sr.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(Kt.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(Br.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(Ar.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(Or.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Dr.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(Fr.prototype,"ArrayType",{value:BigUint64Array});var Xt=class extends m{constructor(t){super(h.Float),this.precision=t}get ArrayType(){switch(this.precision){case K.HALF:return Uint16Array;case K.SINGLE:return Float32Array;case K.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};Ya=Symbol.toStringTag;Xt[Ya]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(Xt.prototype);var Vn=class extends Xt{constructor(){super(K.HALF)}},Ze=class extends Xt{constructor(){super(K.SINGLE)}},Tr=class extends Xt{constructor(){super(K.DOUBLE)}};Object.defineProperty(Vn.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Ze.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(Tr.prototype,"ArrayType",{value:Float64Array});var Le=class extends m{constructor(){super(h.Binary)}toString(){return"Binary"}};Za=Symbol.toStringTag;Le[Za]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(Le.prototype);var Ue=class extends m{constructor(){super(h.LargeBinary)}toString(){return"LargeBinary"}};Ka=Symbol.toStringTag;Ue[Ka]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(Ue.prototype);var Me=class extends m{constructor(){super(h.Utf8)}toString(){return"Utf8"}};Xa=Symbol.toStringTag;Me[Xa]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(Me.prototype);var Ee=class extends m{constructor(){super(h.LargeUtf8)}toString(){return"LargeUtf8"}};qa=Symbol.toStringTag;Ee[qa]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Ee.prototype);var Ce=class extends m{constructor(){super(h.Bool)}toString(){return"Bool"}};Qa=Symbol.toStringTag;Ce[Qa]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(Ce.prototype);var Re=class extends m{constructor(t,e,n=128){super(h.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};tc=Symbol.toStringTag;Re[tc]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(Re.prototype);var Pe=class extends m{constructor(t){super(h.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${at[this.unit]}>`}get ArrayType(){return this.unit===at.DAY?Int32Array:BigInt64Array}};ec=Symbol.toStringTag;Pe[ec]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(Pe.prototype);var je=class extends m{constructor(t,e){super(h.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${v[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};rc=Symbol.toStringTag;je[rc]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(je.prototype);var ke=class extends m{constructor(t,e){super(h.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${v[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};nc=Symbol.toStringTag;ke[nc]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(ke.prototype);var Ve=class extends m{constructor(t){super(h.Interval),this.unit=t}toString(){return`Interval<${mt[this.unit]}>`}};ic=Symbol.toStringTag;Ve[ic]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Ve.prototype);var ze=class extends m{constructor(t){super(h.Duration),this.unit=t}toString(){return`Duration<${v[this.unit]}>`}};sc=Symbol.toStringTag;ze[sc]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(ze.prototype);var re=class extends m{constructor(t){super(h.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};oc=Symbol.toStringTag;re[oc]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(re.prototype);var Z=class extends m{constructor(t){super(h.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};ac=Symbol.toStringTag;Z[ac]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(Z.prototype);var ne=class extends m{constructor(t,e,n){super(h.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}};cc=Symbol.toStringTag;ne[cc]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(ne.prototype);var We=class extends m{constructor(t){super(h.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};lc=Symbol.toStringTag;We[lc]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(We.prototype);var ie=class extends m{constructor(t,e){super(h.FixedSizeList),this.listSize=t,this.children=[e]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};uc=Symbol.toStringTag;ie[uc]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(ie.prototype);var se=class extends m{constructor(t,e=!1){var n,i,s;if(super(h.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((n=t?.type)===null||n===void 0)&&n.children)){let o=(i=t?.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");let a=(s=t?.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};hc=Symbol.toStringTag;se[hc]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(se.prototype);var eh=(r=>()=>++r)(-1),Vt=class extends m{constructor(t,e,n,i){super(h.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=n==null?eh():W(n)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};fc=Symbol.toStringTag;Vt[fc]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(Vt.prototype);function qt(r){let t=r;switch(r.typeId){case h.Decimal:return r.bitWidth/32;case h.Interval:return 1+t.unit;case h.FixedSizeList:return t.listSize;case h.FixedSizeBinary:return t.byteWidth;default:return 1}}var x=class{visitMany(t,...e){return t.map((n,i)=>this.visit(n,...e.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return nh(this,t,e)}getVisitFnByTypeId(t,e=!0){return an(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitLargeUtf8(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}};function nh(r,t,e=!0){return typeof t=="number"?an(r,t,e):typeof t=="string"&&t in h?an(r,h[t],e):t&&t instanceof m?an(r,dc(t),e):t?.type&&t.type instanceof m?an(r,dc(t.type),e):an(r,h.NONE,e)}function an(r,t,e=!0){let n=null;switch(t){case h.Null:n=r.visitNull;break;case h.Bool:n=r.visitBool;break;case h.Int:n=r.visitInt;break;case h.Int8:n=r.visitInt8||r.visitInt;break;case h.Int16:n=r.visitInt16||r.visitInt;break;case h.Int32:n=r.visitInt32||r.visitInt;break;case h.Int64:n=r.visitInt64||r.visitInt;break;case h.Uint8:n=r.visitUint8||r.visitInt;break;case h.Uint16:n=r.visitUint16||r.visitInt;break;case h.Uint32:n=r.visitUint32||r.visitInt;break;case h.Uint64:n=r.visitUint64||r.visitInt;break;case h.Float:n=r.visitFloat;break;case h.Float16:n=r.visitFloat16||r.visitFloat;break;case h.Float32:n=r.visitFloat32||r.visitFloat;break;case h.Float64:n=r.visitFloat64||r.visitFloat;break;case h.Utf8:n=r.visitUtf8;break;case h.LargeUtf8:n=r.visitLargeUtf8;break;case h.Binary:n=r.visitBinary;break;case h.LargeBinary:n=r.visitLargeBinary;break;case h.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case h.Date:n=r.visitDate;break;case h.DateDay:n=r.visitDateDay||r.visitDate;break;case h.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case h.Timestamp:n=r.visitTimestamp;break;case h.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case h.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case h.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case h.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case h.Time:n=r.visitTime;break;case h.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case h.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case h.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case h.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case h.Decimal:n=r.visitDecimal;break;case h.List:n=r.visitList;break;case h.Struct:n=r.visitStruct;break;case h.Union:n=r.visitUnion;break;case h.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case h.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case h.Dictionary:n=r.visitDictionary;break;case h.Interval:n=r.visitInterval;break;case h.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case h.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case h.Duration:n=r.visitDuration;break;case h.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case h.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case h.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case h.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case h.FixedSizeList:n=r.visitFixedSizeList;break;case h.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error(`Unrecognized type '${h[t]}'`)}function dc(r){switch(r.typeId){case h.Null:return h.Null;case h.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?h.Int8:h.Uint8;case 16:return e?h.Int16:h.Uint16;case 32:return e?h.Int32:h.Uint32;case 64:return e?h.Int64:h.Uint64}return h.Int}case h.Float:switch(r.precision){case K.HALF:return h.Float16;case K.SINGLE:return h.Float32;case K.DOUBLE:return h.Float64}return h.Float;case h.Binary:return h.Binary;case h.LargeBinary:return h.LargeBinary;case h.Utf8:return h.Utf8;case h.LargeUtf8:return h.LargeUtf8;case h.Bool:return h.Bool;case h.Decimal:return h.Decimal;case h.Time:switch(r.unit){case v.SECOND:return h.TimeSecond;case v.MILLISECOND:return h.TimeMillisecond;case v.MICROSECOND:return h.TimeMicrosecond;case v.NANOSECOND:return h.TimeNanosecond}return h.Time;case h.Timestamp:switch(r.unit){case v.SECOND:return h.TimestampSecond;case v.MILLISECOND:return h.TimestampMillisecond;case v.MICROSECOND:return h.TimestampMicrosecond;case v.NANOSECOND:return h.TimestampNanosecond}return h.Timestamp;case h.Date:switch(r.unit){case at.DAY:return h.DateDay;case at.MILLISECOND:return h.DateMillisecond}return h.Date;case h.Interval:switch(r.unit){case mt.DAY_TIME:return h.IntervalDayTime;case mt.YEAR_MONTH:return h.IntervalYearMonth}return h.Interval;case h.Duration:switch(r.unit){case v.SECOND:return h.DurationSecond;case v.MILLISECOND:return h.DurationMillisecond;case v.MICROSECOND:return h.DurationMicrosecond;case v.NANOSECOND:return h.DurationNanosecond}return h.Duration;case h.Map:return h.Map;case h.List:return h.List;case h.Struct:return h.Struct;case h.Union:switch(r.mode){case q.Dense:return h.DenseUnion;case q.Sparse:return h.SparseUnion}return h.Union;case h.FixedSizeBinary:return h.FixedSizeBinary;case h.FixedSizeList:return h.FixedSizeList;case h.Dictionary:return h.Dictionary}throw new Error(`Unrecognized type '${h[r.typeId]}'`)}x.prototype.visitInt8=null;x.prototype.visitInt16=null;x.prototype.visitInt32=null;x.prototype.visitInt64=null;x.prototype.visitUint8=null;x.prototype.visitUint16=null;x.prototype.visitUint32=null;x.prototype.visitUint64=null;x.prototype.visitFloat16=null;x.prototype.visitFloat32=null;x.prototype.visitFloat64=null;x.prototype.visitDateDay=null;x.prototype.visitDateMillisecond=null;x.prototype.visitTimestampSecond=null;x.prototype.visitTimestampMillisecond=null;x.prototype.visitTimestampMicrosecond=null;x.prototype.visitTimestampNanosecond=null;x.prototype.visitTimeSecond=null;x.prototype.visitTimeMillisecond=null;x.prototype.visitTimeMicrosecond=null;x.prototype.visitTimeNanosecond=null;x.prototype.visitDenseUnion=null;x.prototype.visitSparseUnion=null;x.prototype.visitIntervalDayTime=null;x.prototype.visitIntervalYearMonth=null;x.prototype.visitDuration=null;x.prototype.visitDurationSecond=null;x.prototype.visitDurationMillisecond=null;x.prototype.visitDurationMicrosecond=null;x.prototype.visitDurationNanosecond=null;var Do={};ur(Do,{float64ToUint16:()=>zn,uint16ToFloat64:()=>Zi});var pc=new Float64Array(1),cn=new Uint32Array(pc.buffer);function Zi(r){let t=(r&31744)>>10,e=(r&1023)/1024,n=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return n*(e?Number.NaN:1/0);case 0:return n*(e?6103515625e-14*e:0)}return n*Math.pow(2,t-15)*(1+e)}function zn(r){if(r!==r)return 32256;pc[0]=r;let t=(cn[1]&2147483648)>>16&65535,e=cn[1]&2146435072,n=0;return e>=1089470464?cn[0]>0?e=31744:(e=(e&2080374784)>>16,n=(cn[1]&1048575)>>10):e<=1056964608?(n=1048576+(cn[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(cn[1]&1048575)+512>>10),t|e|n&65535}var D=class extends x{};function U(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}var ih=(r,t,e)=>{r[t]=Math.floor(e/864e5)},mc=(r,t,e,n)=>{if(e+1<t.length){let i=W(t[e]),s=W(t[e+1]);r.set(n.subarray(0,s-i),i)}},sh=({offset:r,values:t},e,n)=>{let i=r+e;n?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Ke=({values:r},t,e)=>{r[t]=e},Fo=({values:r},t,e)=>{r[t]=e},yc=({values:r},t,e)=>{r[t]=zn(e)},oh=(r,t,e)=>{switch(r.type.precision){case K.HALF:return yc(r,t,e);case K.SINGLE:case K.DOUBLE:return Fo(r,t,e)}},Ki=({values:r},t,e)=>{ih(r,t,e.valueOf())},Xi=({values:r},t,e)=>{r[t]=BigInt(e)},To=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},gc=({values:r,valueOffsets:t},e,n)=>mc(r,t,e,n),bc=({values:r,valueOffsets:t},e,n)=>mc(r,t,e,ve(n)),No=(r,t,e)=>{r.type.unit===at.DAY?Ki(r,t,e):Xi(r,t,e)},qi=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},Qi=({values:r},t,e)=>{r[t]=BigInt(e)},ts=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},es=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},Lo=(r,t,e)=>{switch(r.type.unit){case v.SECOND:return qi(r,t,e);case v.MILLISECOND:return Qi(r,t,e);case v.MICROSECOND:return ts(r,t,e);case v.NANOSECOND:return es(r,t,e)}},rs=({values:r},t,e)=>{r[t]=e},ns=({values:r},t,e)=>{r[t]=e},is=({values:r},t,e)=>{r[t]=e},ss=({values:r},t,e)=>{r[t]=e},Uo=(r,t,e)=>{switch(r.type.unit){case v.SECOND:return rs(r,t,e);case v.MILLISECOND:return ns(r,t,e);case v.MICROSECOND:return is(r,t,e);case v.NANOSECOND:return ss(r,t,e)}},Mo=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},ah=(r,t,e)=>{let n=r.children[0],i=r.valueOffsets,s=vt.getVisitFn(n);if(Array.isArray(e))for(let o=-1,a=i[t],c=i[t+1];a<c;)s(n,a++,e[++o]);else for(let o=-1,a=i[t],c=i[t+1];a<c;)s(n,a++,e.get(++o))},ch=(r,t,e)=>{let n=r.children[0],{valueOffsets:i}=r,s=vt.getVisitFn(n),{[t]:o,[t+1]:a}=i,c=e instanceof Map?e.entries():Object.entries(e);for(let l of c)if(s(n,o,l),++o>=a)break},lh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[s]),uh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(s)),hh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(i.name)),fh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[i.name]),dh=(r,t,e)=>{let n=r.type.children.map(s=>vt.getVisitFn(s.type)),i=e instanceof Map?hh(t,e):e instanceof _?uh(t,e):Array.isArray(e)?lh(t,e):fh(t,e);r.type.children.forEach((s,o)=>i(n[o],r.children[o],s,o))},ph=(r,t,e)=>{r.type.mode===q.Dense?_c(r,t,e):wc(r,t,e)},_c=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];vt.visit(i,r.valueOffsets[t],e)},wc=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];vt.visit(i,t,e)},mh=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},Eo=(r,t,e)=>{r.type.unit===mt.DAY_TIME?os(r,t,e):as(r,t,e)},os=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},as=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},cs=({values:r},t,e)=>{r[t]=e},ls=({values:r},t,e)=>{r[t]=e},us=({values:r},t,e)=>{r[t]=e},hs=({values:r},t,e)=>{r[t]=e},Co=(r,t,e)=>{switch(r.type.unit){case v.SECOND:return cs(r,t,e);case v.MILLISECOND:return ls(r,t,e);case v.MICROSECOND:return us(r,t,e);case v.NANOSECOND:return hs(r,t,e)}},yh=(r,t,e)=>{let{stride:n}=r,i=r.children[0],s=vt.getVisitFn(i);if(Array.isArray(e))for(let o=-1,a=t*n;++o<n;)s(i,a+o,e[o]);else for(let o=-1,a=t*n;++o<n;)s(i,a+o,e.get(o))};D.prototype.visitBool=U(sh);D.prototype.visitInt=U(Ke);D.prototype.visitInt8=U(Ke);D.prototype.visitInt16=U(Ke);D.prototype.visitInt32=U(Ke);D.prototype.visitInt64=U(Ke);D.prototype.visitUint8=U(Ke);D.prototype.visitUint16=U(Ke);D.prototype.visitUint32=U(Ke);D.prototype.visitUint64=U(Ke);D.prototype.visitFloat=U(oh);D.prototype.visitFloat16=U(yc);D.prototype.visitFloat32=U(Fo);D.prototype.visitFloat64=U(Fo);D.prototype.visitUtf8=U(bc);D.prototype.visitLargeUtf8=U(bc);D.prototype.visitBinary=U(gc);D.prototype.visitLargeBinary=U(gc);D.prototype.visitFixedSizeBinary=U(To);D.prototype.visitDate=U(No);D.prototype.visitDateDay=U(Ki);D.prototype.visitDateMillisecond=U(Xi);D.prototype.visitTimestamp=U(Lo);D.prototype.visitTimestampSecond=U(qi);D.prototype.visitTimestampMillisecond=U(Qi);D.prototype.visitTimestampMicrosecond=U(ts);D.prototype.visitTimestampNanosecond=U(es);D.prototype.visitTime=U(Uo);D.prototype.visitTimeSecond=U(rs);D.prototype.visitTimeMillisecond=U(ns);D.prototype.visitTimeMicrosecond=U(is);D.prototype.visitTimeNanosecond=U(ss);D.prototype.visitDecimal=U(Mo);D.prototype.visitList=U(ah);D.prototype.visitStruct=U(dh);D.prototype.visitUnion=U(ph);D.prototype.visitDenseUnion=U(_c);D.prototype.visitSparseUnion=U(wc);D.prototype.visitDictionary=U(mh);D.prototype.visitInterval=U(Eo);D.prototype.visitIntervalDayTime=U(os);D.prototype.visitIntervalYearMonth=U(as);D.prototype.visitDuration=U(Co);D.prototype.visitDurationSecond=U(cs);D.prototype.visitDurationMillisecond=U(ls);D.prototype.visitDurationMicrosecond=U(us);D.prototype.visitDurationNanosecond=U(hs);D.prototype.visitFixedSizeList=U(yh);D.prototype.visitMap=U(ch);var vt=new D;var ge=Symbol.for("parent"),ln=Symbol.for("rowIndex"),fr=class{constructor(t,e){return this[ge]=t,this[ln]=e,new Proxy(this,new Po)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[ln],e=this[ge],n=e.type.children,i={};for(let s=-1,o=n.length;++s<o;)i[n[s].name]=ht.visit(e.children[s],t);return i}toString(){return`{${[...this].map(([t,e])=>`${me(t)}: ${me(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Ro(this[ge],this[ln])}},Ro=class{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,ht.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(fr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[ge]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ln]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var Po=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[ge].type.children.map(e=>e.name)}has(t,e){return t[ge].type.children.findIndex(n=>n.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[ge].type.children.findIndex(n=>n.name===e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[ge].type.children.findIndex(i=>i.name===e);if(n!==-1){let i=ht.visit(t[ge].children[n],t[ln]);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[ge].type.children.findIndex(s=>s.name===e);return i!==-1?(vt.visit(t[ge].children[i],t[ln],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}};var S=class extends x{};function N(r){return(t,e)=>t.getValid(e)?r(t,e):null}var gh=(r,t)=>864e5*r[t],bh=(r,t)=>null,vc=(r,t,e)=>{if(e+1>=t.length)return null;let n=W(t[e]),i=W(t[e+1]);return r.subarray(n,i)},_h=({offset:r,values:t},e)=>{let n=r+e;return(t[n>>3]&1<<n%8)!==0},Ic=({values:r},t)=>gh(r,t),xc=({values:r},t)=>W(r[t]),dr=({stride:r,values:t},e)=>t[r*e],wh=({stride:r,values:t},e)=>Zi(t[r*e]),Sc=({values:r},t)=>r[t],vh=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Bc=({values:r,valueOffsets:t},e)=>vc(r,t,e),Ac=({values:r,valueOffsets:t},e)=>{let n=vc(r,t,e);return n!==null?Un(n):null},Ih=({values:r},t)=>r[t],xh=({type:r,values:t},e)=>r.precision!==K.HALF?t[e]:Zi(t[e]),Sh=(r,t)=>r.type.unit===at.DAY?Ic(r,t):xc(r,t),Oc=({values:r},t)=>1e3*W(r[t]),Dc=({values:r},t)=>W(r[t]),Fc=({values:r},t)=>So(r[t],BigInt(1e3)),Tc=({values:r},t)=>So(r[t],BigInt(1e6)),Bh=(r,t)=>{switch(r.type.unit){case v.SECOND:return Oc(r,t);case v.MILLISECOND:return Dc(r,t);case v.MICROSECOND:return Fc(r,t);case v.NANOSECOND:return Tc(r,t)}},Nc=({values:r},t)=>r[t],Lc=({values:r},t)=>r[t],Uc=({values:r},t)=>r[t],Mc=({values:r},t)=>r[t],Ah=(r,t)=>{switch(r.type.unit){case v.SECOND:return Nc(r,t);case v.MILLISECOND:return Lc(r,t);case v.MICROSECOND:return Uc(r,t);case v.NANOSECOND:return Mc(r,t)}},Oh=({values:r,stride:t},e)=>Ir.decimal(r.subarray(t*e,t*(e+1))),Dh=(r,t)=>{let{valueOffsets:e,stride:n,children:i}=r,{[t*n]:s,[t*n+1]:o}=e,c=i[0].slice(s,o-s);return new _([c])},Fh=(r,t)=>{let{valueOffsets:e,children:n}=r,{[t]:i,[t+1]:s}=e,o=n[0];return new Ge(o.slice(i,s-i))},Th=(r,t)=>new fr(r,t),Nh=(r,t)=>r.type.mode===q.Dense?Ec(r,t):Cc(r,t),Ec=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return ht.visit(n,r.valueOffsets[t])},Cc=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return ht.visit(n,t)},Lh=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},Uh=(r,t)=>r.type.unit===mt.DAY_TIME?Rc(r,t):Pc(r,t),Rc=({values:r},t)=>r.subarray(2*t,2*(t+1)),Pc=({values:r},t)=>{let e=r[t],n=new Int32Array(2);return n[0]=Math.trunc(e/12),n[1]=Math.trunc(e%12),n},jc=({values:r},t)=>r[t],kc=({values:r},t)=>r[t],Vc=({values:r},t)=>r[t],zc=({values:r},t)=>r[t],Mh=(r,t)=>{switch(r.type.unit){case v.SECOND:return jc(r,t);case v.MILLISECOND:return kc(r,t);case v.MICROSECOND:return Vc(r,t);case v.NANOSECOND:return zc(r,t)}},Eh=(r,t)=>{let{stride:e,children:n}=r,s=n[0].slice(t*e,e);return new _([s])};S.prototype.visitNull=N(bh);S.prototype.visitBool=N(_h);S.prototype.visitInt=N(Ih);S.prototype.visitInt8=N(dr);S.prototype.visitInt16=N(dr);S.prototype.visitInt32=N(dr);S.prototype.visitInt64=N(Sc);S.prototype.visitUint8=N(dr);S.prototype.visitUint16=N(dr);S.prototype.visitUint32=N(dr);S.prototype.visitUint64=N(Sc);S.prototype.visitFloat=N(xh);S.prototype.visitFloat16=N(wh);S.prototype.visitFloat32=N(dr);S.prototype.visitFloat64=N(dr);S.prototype.visitUtf8=N(Ac);S.prototype.visitLargeUtf8=N(Ac);S.prototype.visitBinary=N(Bc);S.prototype.visitLargeBinary=N(Bc);S.prototype.visitFixedSizeBinary=N(vh);S.prototype.visitDate=N(Sh);S.prototype.visitDateDay=N(Ic);S.prototype.visitDateMillisecond=N(xc);S.prototype.visitTimestamp=N(Bh);S.prototype.visitTimestampSecond=N(Oc);S.prototype.visitTimestampMillisecond=N(Dc);S.prototype.visitTimestampMicrosecond=N(Fc);S.prototype.visitTimestampNanosecond=N(Tc);S.prototype.visitTime=N(Ah);S.prototype.visitTimeSecond=N(Nc);S.prototype.visitTimeMillisecond=N(Lc);S.prototype.visitTimeMicrosecond=N(Uc);S.prototype.visitTimeNanosecond=N(Mc);S.prototype.visitDecimal=N(Oh);S.prototype.visitList=N(Dh);S.prototype.visitStruct=N(Th);S.prototype.visitUnion=N(Nh);S.prototype.visitDenseUnion=N(Ec);S.prototype.visitSparseUnion=N(Cc);S.prototype.visitDictionary=N(Lh);S.prototype.visitInterval=N(Uh);S.prototype.visitIntervalDayTime=N(Rc);S.prototype.visitIntervalYearMonth=N(Pc);S.prototype.visitDuration=N(Mh);S.prototype.visitDurationSecond=N(jc);S.prototype.visitDurationMillisecond=N(kc);S.prototype.visitDurationMicrosecond=N(Vc);S.prototype.visitDurationNanosecond=N(zc);S.prototype.visitFixedSizeList=N(Eh);S.prototype.visitMap=N(Fh);var ht=new S;var pr=Symbol.for("keys"),hn=Symbol.for("vals"),un=Symbol.for("kKeysAsStrings"),jo=Symbol.for("_kKeysAsStrings"),Ge=class{constructor(t){return this[pr]=new _([t.children[0]]).memoize(),this[hn]=t.children[1],new Proxy(this,new Vo)}get[un](){return this[jo]||(this[jo]=Array.from(this[pr].toArray(),String))}[Symbol.iterator](){return new ko(this[pr],this[hn])}get size(){return this[pr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[pr],e=this[hn],n={};for(let i=-1,s=t.length;++i<s;)n[t.get(i)]=ht.visit(e,i);return n}toString(){return`{${[...this].map(([t,e])=>`${me(t)}: ${me(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},ko=class{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){let t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),ht.visit(this.vals,t)]})}},Vo=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[un]}has(t,e){return t[un].includes(e)}getOwnPropertyDescriptor(t,e){if(t[un].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[un].indexOf(e);if(n!==-1){let i=ht.visit(Reflect.get(t,hn),n);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[un].indexOf(e);return i!==-1?(vt.visit(Reflect.get(t,hn),i,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}};Object.defineProperties(Ge.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[pr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[hn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[jo]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var Wc;function Wn(r,t,e,n){let{length:i=0}=r,s=typeof t!="number"?0:t,o=typeof e!="number"?i:e;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),o<s&&(Wc=s,s=o,o=Wc),o>i&&(o=i),n?n(r,s,o):[s,o]}var Nr=(r,t)=>r<0?t+r:r,Gc=r=>r!==r;function mr(r){if(typeof r!=="object"||r===null)return Gc(r)?Gc:e=>e===r;if(r instanceof Date){let e=r.valueOf();return n=>n instanceof Date?n.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?_o(r,e):!1:r instanceof Map?Rh(r):Array.isArray(r)?Ch(r):r instanceof _?Ph(r):jh(r,!0)}function Ch(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=mr(r[e]);return fs(t)}function Rh(r){let t=-1,e=[];for(let n of r.values())e[++t]=mr(n);return fs(e)}function Ph(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=mr(r.get(e));return fs(t)}function jh(r,t=!1){let e=Object.keys(r);if(!t&&e.length===0)return()=>!1;let n=[];for(let i=-1,s=e.length;++i<s;)n[i]=mr(r[e[i]]);return fs(n,e)}function fs(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return kh(r,e);case Map:return Jc(r,e,e.keys());case Ge:case fr:case Object:case void 0:return Jc(r,e,t||Object.keys(e))}return e instanceof _?Vh(r,e):!1}}function kh(r,t){let e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t[n]))return!1;return!0}function Vh(r,t){let e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t.get(n)))return!1;return!0}function Jc(r,t,e){let n=e[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator](),o=0,a=r.length,c=s.next(),l=n.next(),u=i.next();for(;o<a&&!l.done&&!u.done&&!c.done&&!(l.value!==u.value||!r[o](c.value));++o,l=n.next(),u=i.next(),c=s.next());return o===a&&l.done&&u.done&&c.done?!0:(n.return&&n.return(),i.return&&i.return(),s.return&&s.return(),!1)}var Wo={};ur(Wo,{BitIterator:()=>Lr,getBit:()=>$c,getBool:()=>ps,packBools:()=>Mr,popcnt_array:()=>Hc,popcnt_bit_range:()=>Gn,popcnt_uint32:()=>ds,setBool:()=>zh,truncateBitmap:()=>Ur});function ps(r,t,e,n){return(e&1<<n)!==0}function $c(r,t,e,n){return(e&1<<n)>>n}function zh(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function Ur(r,t,e){let n=e.byteLength+7&-8;if(r>0||e.byteLength<n){let i=new Uint8Array(n);return i.set(r%8===0?e.subarray(r>>3):Mr(new Lr(e,r,t,null,ps)).subarray(0,n)),i}return e}function Mr(r){let t=[],e=0,n=0,i=0;for(let o of r)o&&(i|=1<<n),++n===8&&(t[e++]=i,i=n=0);(e===0||n>0)&&(t[e++]=i);let s=new Uint8Array(t.length+7&-8);return s.set(t),s}var Lr=class{constructor(t,e,n,i,s){this.bytes=t,this.length=n,this.context=i,this.get=s,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}};function Gn(r,t,e){if(e-t<=0)return 0;if(e-t<8){let s=0;for(let o of new Lr(r,t,e-t,r,$c))s+=o;return s}let n=e>>3<<3,i=t+(t%8===0?0:8-t%8);return Gn(r,t,i)+Gn(r,n,e)+Hc(r,i>>3,n-i>>3)}function Hc(r,t,e){let n=0,i=Math.trunc(t),s=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:i+e;for(;o-i>=4;)n+=ds(s.getUint32(i)),i+=4;for(;o-i>=2;)n+=ds(s.getUint16(i)),i+=2;for(;o-i>=1;)n+=ds(s.getUint8(i)),i+=1;return n}function ds(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var Wh=-1,k=class{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:t}=this;return m.isSparseUnion(t)?this.children.some(e=>e.nullable):m.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0,{valueOffsets:e,values:n,nullBitmap:i,typeIds:s}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(m.isUnion(this.type))return this.children.reduce((n,i)=>n+i.nullCount,0);let t=this._nullCount,e;return t<=Wh&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Gn(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,i,s,o=[],a){this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let c;s instanceof k?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=qt(t),s&&((c=s[0])&&(this.valueOffsets=c),(c=s[1])&&(this.values=c),(c=s[2])&&(this.nullBitmap=c),(c=s[3])&&(this.typeIds=c)))}getValid(t){let{type:e}=this;if(m.isUnion(e)){let n=e,i=this.children[n.typeIdToChildIndex[this.typeIds[t]]],s=n.mode===q.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){let n=this.offset+t;return(this.nullBitmap[n>>3]&1<<n%8)!==0}return!0}setValid(t,e){let n,{type:i}=this;if(m.isUnion(i)){let s=i,o=this.children[s.typeIdToChildIndex[this.typeIds[t]]],a=s.mode===q.Dense?this.valueOffsets[t]:t;n=o.getValid(a),o.setValid(a,e)}else{let{nullBitmap:s}=this,{offset:o,length:a}=this,c=o+t,l=1<<c%8,u=c>>3;(!s||s.byteLength<=u)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(Ur(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let f=s[u];n=(f&l)!==0,s[u]=e?f|l:f&~l}return n!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,n=this.length,i=this._nullCount,s=this,o=this.children){return new k(t,e,n,i,s,o,this.dictionary)}slice(t,e){let{stride:n,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?n:1,c=this._sliceBuffers(t,e,n,i);return this.clone(this.type,this.offset+t,e,o,c,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*t,a*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===h.Null)return this.clone(this.type,0,t,0);let{length:e,nullCount:n}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);i[e>>3]=(1<<e-(e&-8))-1,n>0&&i.set(Ur(this.offset,e,this.nullBitmap),0);let s=this.buffers;return s[pe.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),s)}_sliceBuffers(t,e,n,i){let s,{buffers:o}=this;return(s=o[pe.TYPE])&&(o[pe.TYPE]=s.subarray(t,t+e)),(s=o[pe.OFFSET])&&(o[pe.OFFSET]=s.subarray(t,t+e+1))||(s=o[pe.DATA])&&(o[pe.DATA]=i===6?s:s.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map(i=>i.slice(e,n))}};k.prototype.children=Object.freeze([]);var Er=class extends x{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:e,["offset"]:n=0,["length"]:i=0}=t;return new k(e,n,i,i)}visitBool(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitInt(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitFloat(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.data),s=T(t.nullBitmap),o=vr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[o,i,s])}visitLargeUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.data),s=T(t.nullBitmap),o=Wi(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[o,i,s])}visitBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.data),s=T(t.nullBitmap),o=vr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[o,i,s])}visitLargeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.data),s=T(t.nullBitmap),o=Wi(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[o,i,s])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitDate(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitTimestamp(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitTime(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitDecimal(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitList(t){let{["type"]:e,["offset"]:n=0,["child"]:i}=t,s=T(t.nullBitmap),o=vr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[o,void 0,s],[i])}visitStruct(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=T(t.nullBitmap),{length:o=i.reduce((c,{length:l})=>Math.max(c,l),0),nullCount:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,void 0,s],i)}visitUnion(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=R(e.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=t;if(m.isSparseUnion(e))return new k(e,n,o,a,[void 0,void 0,void 0,s],i);let c=vr(t.valueOffsets);return new k(e,n,o,a,[c,void 0,void 0,s],i)}visitDictionary(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.indices.ArrayType,t.data),{["dictionary"]:o=new _([new Er().visit({type:e.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[void 0,s,i],[],o)}visitInterval(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitDuration(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitFixedSizeList(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new Er().visit({type:e.valueType})}=t,s=T(t.nullBitmap),{["length"]:o=i.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,void 0,s],[i])}visitMap(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new Er().visit({type:e.childType})}=t,s=T(t.nullBitmap),o=vr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[o,void 0,s],[i])}},Gh=new Er;function w(r){return Gh.visit(r)}var Jn=class{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){let t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}};function Yc(r){return r.some(t=>t.nullable)}function ms(r){return r.reduce((t,e)=>t+e.nullCount,0)}function ys(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function gs(r,t,e,n){let i=[];for(let s=-1,o=r.length;++s<o;){let a=r[s],c=t[s],{length:l}=a;if(c>=n)break;if(e>=c+l)continue;if(c>=e&&c+l<=n){i.push(a);continue}let u=Math.max(0,e-c),f=Math.min(n-c,l);i.push(a.slice(u,f-u))}return i.length===0&&i.push(r[0].slice(0,0)),i}function Go(r,t,e,n){let i=0,s=0,o=t.length-1;do{if(i>=o-1)return e<t[o]?n(r,i,e-t[i]):null;s=i+Math.trunc((o-i)*.5),e<t[s]?o=s:i=s}while(i<o)}function $n(r,t){return r.getValid(t)}function fn(r){function t(e,n,i){return r(e[n],i)}return function(e){let n=this.data;return Go(n,this._offsets,e,t)}}function bs(r){let t;function e(n,i,s){return r(n[i],s,t)}return function(n,i){let s=this.data;t=i;let o=Go(s,this._offsets,n,e);return t=void 0,o}}function _s(r){let t;function e(n,i,s){let o=s,a=0,c=0;for(let l=i-1,u=n.length;++l<u;){let f=n[l];if(~(a=r(f,t,o)))return c+a;o=0,c+=f.length}return-1}return function(n,i){t=n;let s=this.data,o=typeof i!="number"?e(s,0,0):Go(s,this._offsets,i,e);return t=void 0,o}}var B=class extends x{};function Jh(r,t){return t===null&&r.length>0?0:-1}function $h(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(let i of new Lr(e,r.offset+(t||0),r.length,e,ps)){if(!i)return n;++n}return-1}function M(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case h.Union:break;case h.Dictionary:break;default:return $h(r,e)}let n=ht.getVisitFn(r),i=mr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}function Zc(r,t,e){let n=ht.getVisitFn(r),i=mr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}B.prototype.visitNull=Jh;B.prototype.visitBool=M;B.prototype.visitInt=M;B.prototype.visitInt8=M;B.prototype.visitInt16=M;B.prototype.visitInt32=M;B.prototype.visitInt64=M;B.prototype.visitUint8=M;B.prototype.visitUint16=M;B.prototype.visitUint32=M;B.prototype.visitUint64=M;B.prototype.visitFloat=M;B.prototype.visitFloat16=M;B.prototype.visitFloat32=M;B.prototype.visitFloat64=M;B.prototype.visitUtf8=M;B.prototype.visitLargeUtf8=M;B.prototype.visitBinary=M;B.prototype.visitLargeBinary=M;B.prototype.visitFixedSizeBinary=M;B.prototype.visitDate=M;B.prototype.visitDateDay=M;B.prototype.visitDateMillisecond=M;B.prototype.visitTimestamp=M;B.prototype.visitTimestampSecond=M;B.prototype.visitTimestampMillisecond=M;B.prototype.visitTimestampMicrosecond=M;B.prototype.visitTimestampNanosecond=M;B.prototype.visitTime=M;B.prototype.visitTimeSecond=M;B.prototype.visitTimeMillisecond=M;B.prototype.visitTimeMicrosecond=M;B.prototype.visitTimeNanosecond=M;B.prototype.visitDecimal=M;B.prototype.visitList=M;B.prototype.visitStruct=M;B.prototype.visitUnion=M;B.prototype.visitDenseUnion=Zc;B.prototype.visitSparseUnion=Zc;B.prototype.visitDictionary=M;B.prototype.visitInterval=M;B.prototype.visitIntervalDayTime=M;B.prototype.visitIntervalYearMonth=M;B.prototype.visitDuration=M;B.prototype.visitDurationSecond=M;B.prototype.visitDurationMillisecond=M;B.prototype.visitDurationMicrosecond=M;B.prototype.visitDurationNanosecond=M;B.prototype.visitFixedSizeList=M;B.prototype.visitMap=M;var Cr=new B;var A=class extends x{};function L(r){let{type:t}=r;if(r.nullCount===0&&r.stride===1&&(m.isInt(t)&&t.bitWidth!==64||m.isTime(t)&&t.bitWidth!==64||m.isFloat(t)&&t.precision!==K.HALF))return new Jn(r.data.length,n=>{let i=r.data[n];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new Jn(r.data.length,n=>{let s=r.data[n].length,o=r.slice(e,e+s);return e+=s,new Jo(o)})}var Jo=class{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}};A.prototype.visitNull=L;A.prototype.visitBool=L;A.prototype.visitInt=L;A.prototype.visitInt8=L;A.prototype.visitInt16=L;A.prototype.visitInt32=L;A.prototype.visitInt64=L;A.prototype.visitUint8=L;A.prototype.visitUint16=L;A.prototype.visitUint32=L;A.prototype.visitUint64=L;A.prototype.visitFloat=L;A.prototype.visitFloat16=L;A.prototype.visitFloat32=L;A.prototype.visitFloat64=L;A.prototype.visitUtf8=L;A.prototype.visitLargeUtf8=L;A.prototype.visitBinary=L;A.prototype.visitLargeBinary=L;A.prototype.visitFixedSizeBinary=L;A.prototype.visitDate=L;A.prototype.visitDateDay=L;A.prototype.visitDateMillisecond=L;A.prototype.visitTimestamp=L;A.prototype.visitTimestampSecond=L;A.prototype.visitTimestampMillisecond=L;A.prototype.visitTimestampMicrosecond=L;A.prototype.visitTimestampNanosecond=L;A.prototype.visitTime=L;A.prototype.visitTimeSecond=L;A.prototype.visitTimeMillisecond=L;A.prototype.visitTimeMicrosecond=L;A.prototype.visitTimeNanosecond=L;A.prototype.visitDecimal=L;A.prototype.visitList=L;A.prototype.visitStruct=L;A.prototype.visitUnion=L;A.prototype.visitDenseUnion=L;A.prototype.visitSparseUnion=L;A.prototype.visitDictionary=L;A.prototype.visitInterval=L;A.prototype.visitIntervalDayTime=L;A.prototype.visitIntervalYearMonth=L;A.prototype.visitDuration=L;A.prototype.visitDurationSecond=L;A.prototype.visitDurationMillisecond=L;A.prototype.visitDurationMicrosecond=L;A.prototype.visitDurationNanosecond=L;A.prototype.visitFixedSizeList=L;A.prototype.visitMap=L;var dn=new A;var Kc,Xc={},qc={},_=class{constructor(t){var e,n,i;let s=t[0]instanceof _?t.flatMap(a=>a.data):t;if(s.length===0||s.some(a=>!(a instanceof k)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:a,set:c,indexOf:l}=Xc[o.typeId],u=s[0];this.isValid=f=>$n(u,f),this.get=f=>a(u,f),this.set=(f,d)=>c(u,f,d),this.indexOf=f=>l(u,f),this._offsets=[0,u.length];break}default:Object.setPrototypeOf(this,qc[o.typeId]),this._offsets=ys(s);break}this.data=s,this.type=o,this.stride=qt(o),this.numChildren=(i=(n=o.children)===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return Yc(this.data)}get nullCount(){return ms(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${h[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(Nr(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return dn.visit(this)}concat(...t){return new _(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new _(Wn(this,t,e,({data:n,_offsets:i},s,o)=>gs(n,i,s,o)))}toJSON(){return[...this]}toArray(){let{type:t,data:e,length:n,stride:i,ArrayType:s}=this;switch(t.typeId){case h.Int:case h.Float:case h.Decimal:case h.Time:case h.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,n*i);default:return e.reduce((o,{values:a,length:c})=>(o.array.set(a.subarray(0,c*i),o.offset),o.offset+=c*i,o),{array:new s(n*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt((e=this.type.children)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new _(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return m.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(m.isDictionary(this.type)){let t=new pn(this.data[0].dictionary),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new _(e)}return new pn(this)}unmemoize(){if(m.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new _(e)}return this}};Kc=Symbol.toStringTag;_[Kc]=(r=>{r.type=m.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;let t=Object.keys(h).map(e=>h[e]).filter(e=>typeof e=="number"&&e!==h.NONE);for(let e of t){let n=ht.getVisitFnByTypeId(e),i=vt.getVisitFnByTypeId(e),s=Cr.getVisitFnByTypeId(e);Xc[e]={get:n,set:i,indexOf:s},qc[e]=Object.create(r,{isValid:{value:fn($n)},get:{value:fn(ht.getVisitFnByTypeId(e))},set:{value:bs(vt.getVisitFnByTypeId(e))},indexOf:{value:_s(Cr.getVisitFnByTypeId(e))}})}return"Vector"})(_.prototype);var pn=class extends _{constructor(t){super(t.data);let e=this.get,n=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=s[o];if(a!==void 0)return a;let c=e.call(this,o);return s[o]=c,c}}),Object.defineProperty(this,"set",{value(o,a){n.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new pn(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new _(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function mn(r){if(r){if(r instanceof k)return new _([r]);if(r instanceof _)return new _(r.data);if(r.type instanceof m)return new _([w(r)]);if(Array.isArray(r))return new _(r.flatMap(t=>Hh(t)));if(ArrayBuffer.isView(r)){r instanceof DataView&&(r=new Uint8Array(r.buffer));let t={offset:0,length:r.length,nullCount:-1,data:r};if(r instanceof Int8Array)return new _([w(Object.assign(Object.assign({},t),{type:new xr}))]);if(r instanceof Int16Array)return new _([w(Object.assign(Object.assign({},t),{type:new Sr}))]);if(r instanceof Int32Array)return new _([w(Object.assign(Object.assign({},t),{type:new Kt}))]);if(r instanceof BigInt64Array)return new _([w(Object.assign(Object.assign({},t),{type:new Br}))]);if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return new _([w(Object.assign(Object.assign({},t),{type:new Ar}))]);if(r instanceof Uint16Array)return new _([w(Object.assign(Object.assign({},t),{type:new Or}))]);if(r instanceof Uint32Array)return new _([w(Object.assign(Object.assign({},t),{type:new Dr}))]);if(r instanceof BigUint64Array)return new _([w(Object.assign(Object.assign({},t),{type:new Fr}))]);if(r instanceof Float32Array)return new _([w(Object.assign(Object.assign({},t),{type:new Ze}))]);if(r instanceof Float64Array)return new _([w(Object.assign(Object.assign({},t),{type:new Tr}))]);throw new Error("Unrecognized input")}}throw new Error("Unrecognized input")}function Hh(r){return r instanceof k?[r]:r instanceof _?r.data:mn(r).data}function Qc(r){if(!r||r.length<=0)return function(i){return!0};let t="",e=r.filter(n=>n===n);return e.length>0&&(t=`
|
|
8
|
+
switch (x) {${e.map(n=>`
|
|
9
|
+
case ${Yh(n)}:`).join("")}
|
|
10
|
+
return false;
|
|
11
|
+
}`),r.length!==e.length&&(t=`if (x !== x) return false;
|
|
12
|
+
${t}`),new Function("x",`${t}
|
|
13
|
+
return true;`)}function Yh(r){return typeof r!="bigint"?me(r):`${me(r)}n`}function $o(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function tl(r,t=0){return r.length>=t?r.subarray(0,t):En(new r.constructor(t),r,0)}var be=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?$o(n*1,this.BYTES_PER_ELEMENT):$o(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=$o(t*this.stride,this.BYTES_PER_ELEMENT);let e=tl(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=tl(this.buffer,t)}},Xe=class extends be{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}},yn=class extends Xe{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()}},gn=class extends Xe{constructor(t){super(t.OffsetArrayType,1,1)}append(t){return this.set(this.length-1,t)}set(t,e){let n=this.length-1,i=this.reserve(t-n+1).buffer;return n<t++&&n>=0&&i.fill(i[n],n,t),i[t]=i[t-1]+e,this}flush(t=this.length-1){return t>this.length&&this.set(t-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(t+1)}};var rt=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=qt(t),this._nulls=new yn,e&&e.length>0&&(this._isValid=Qc(e))}toVector(){return new _([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:f}=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=f?.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}};rt.prototype.length=1;rt.prototype.stride=1;rt.prototype.children=null;rt.prototype.finished=!1;rt.prototype.nullValues=null;rt.prototype._isValid=()=>!0;var ft=class extends rt{constructor(t){super(t),this._values=new Xe(this.ArrayType,0,this.stride)}setValue(t,e){let n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}},zt=class extends rt{constructor(t){super(t),this._pendingLength=0,this._offsets=new gn(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 Ge?e[pr].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 Rr=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 Ot=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 Ot).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new Ot).__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 it).__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 Rr).__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 Rr).__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 P=class{constructor(t=[],e,n,i=H.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=Ho(this.fields)),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 P(n,this.metadata)}selectAt(t){let e=t.map(n=>this.fields[n]).filter(Boolean);return new P(e,this.metadata)}assign(...t){let e=t[0]instanceof P?t[0]:Array.isArray(t[0])?new P(t[0]):new P(t),n=[...this.fields],i=ws(ws(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:ws(ws(new Map,n[c].metadata),a.metadata)}))&&!1:!0}),o=Ho(s,new Map);return new P([...n,...s],i,new Map([...this.dictionaries,...o]))}};P.prototype.fields=null;P.prototype.metadata=null;P.prototype.dictionaries=null;var E=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 E(`${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],E.new(e,n,i,s)}};E.prototype.type=null;E.prototype.name=null;E.prototype.nullable=null;E.prototype.metadata=null;function ws(r,t){return new Map([...r||new Map,...t||new Map])}function Ho(r,t=new Map){for(let e=-1,n=r.length;++e<n;){let s=r[e].type;if(m.isDictionary(s)){if(!t.has(s.id))t.set(s.id,s.dictionary);else if(t.get(s.id)!==s.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}s.children&&s.children.length>0&&Ho(s.children,t)}return t}var Zh=Ye,Kh=Nt,qe=class{static decode(t){t=new Kh(T(t));let e=Ot.getRootAsFooter(t),n=P.decode(e.schema(),new Map,e.version());return new Yo(n,e)}static encode(t){let e=new Zh,n=P.encode(e,t.schema);Ot.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())_e.encode(e,o);let i=e.endVector();Ot.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())_e.encode(e,o);let s=e.endVector();return Ot.startFooter(e),Ot.addSchema(e,n),Ot.addVersion(e,H.V5),Ot.addRecordBatches(e,i),Ot.addDictionaries(e,s),Ot.finishFooterBuffer(e,Ot.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 Yo=class extends qe{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 _e.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return _e.decode(e)}return null}},_e=class{static decode(t){return new _e(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){let{metaDataLength:n}=e,i=BigInt(e.offset),s=BigInt(e.bodyLength);return Rr.createBlock(t,i,n,s)}constructor(t,e,n){this.metaDataLength=t,this.offset=W(n),this.bodyLength=W(e)}};var tt=Object.freeze({done:!0,value:void 0}),Hn=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},Pr=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())}},vs=class extends Pr{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return y(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){let{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(tt);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return wt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return wt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return y(this,void 0,void 0,function*(){return yield this.abort(t),tt})}return(t){return y(this,void 0,void 0,function*(){return yield this.close(),tt})}read(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,n)=>{this.resolvers.push({resolve:e,reject:n})}):Promise.resolve(tt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var Je=class extends vs{write(t){if((t=T(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Un(this.toUint8Array(!0)):this.toUint8Array(!1).then(Un)}toUint8Array(t=!1){return t?Yt(this._values)[0]:(()=>y(this,void 0,void 0,function*(){var e,n,i,s;let o=[],a=0;try{for(var c=!0,l=ce(this),u;u=yield l.next(),e=u.done,!e;c=!0){s=u.value,c=!1;let f=s;o.push(f),a+=f.byteLength}}catch(f){n={error:f}}finally{try{!c&&!e&&(i=l.return)&&(yield i.call(l))}finally{if(n)throw n.error}}return Yt(o,a)[0]}))()}},$e=class{constructor(t){t&&(this.source=new Zo(wt.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)}},Wt=class{constructor(t){t instanceof Wt?this.source=t.source:t instanceof Je?this.source=new Qe(wt.fromAsyncIterable(t)):zi(t)?this.source=new Qe(wt.fromNodeStream(t)):Mn(t)?this.source=new Qe(wt.fromDOMStream(t)):ki(t)?this.source=new Qe(wt.fromDOMStream(t.body)):ue(t)?this.source=new Qe(wt.fromIterable(t)):le(t)?this.source=new Qe(wt.fromAsyncIterable(t)):Qt(t)&&(this.source=new Qe(wt.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)}},Zo=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)||tt)}return(t){return Object.create(this.source.return&&this.source.return(t)||tt)}},Qe=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return y(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return y(this,arguments,void 0,function*(e,n="read"){return yield this.source.next({cmd:n,size:e})})}throw(t){return y(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||tt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return y(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||tt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var Yn=class extends $e{constructor(t,e){super(),this.position=0,this.buffer=T(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){let{buffer:e,byteOffset:n}=this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){let{buffer:e,size:n,position:i}=this;return e&&i<n?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(n,i+Math.min(n-i,t)),e.subarray(i,this.position)):null}readAt(t,e){let n=this.buffer,i=Math.min(this.size,t+e);return n?n.subarray(t,i):new Uint8Array(e)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}},yr=class extends Wt{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=(()=>y(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending}))()}readInt32(t){return y(this,void 0,void 0,function*(){let{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return y(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:n,position:i}=this;if(e&&i<n){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,o=0,a=0,c=Math.min(n,s+Math.min(n-s,t)),l=new Uint8Array(Math.max(0,(this.position=c)-s));for(;(s+=a)<c&&(o+=a)<l.byteLength;)({bytesRead:a}=yield e.read(l,o,l.byteLength-o,s));return l}return null})}readAt(t,e){return y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:n,size:i}=this;if(n&&t+e<i){let s=Math.min(i,t+e),o=new Uint8Array(s-t);return(yield n.read(o,0,e,t)).buffer}return new Uint8Array(e)})}close(){return y(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var Xo={};ur(Xo,{BaseInt64:()=>Zn,Int128:()=>Gt,Int64:()=>_t,Uint64:()=>J});function bn(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var _n=8,Ko=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],Zn=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`${bn(this.buffer[1])} ${bn(this.buffer[0])}`}},J=class extends Zn{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return J.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return J.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.length,i=new J(e);for(let s=0;s<n;){let o=_n<n-s?_n:n-s,a=new J(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new J(new Uint32Array([Ko[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;)J.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new J(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new J(new Uint32Array(t.buffer)).plus(e)}},_t=class extends Zn{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 _t.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return _t.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.startsWith("-"),i=t.length,s=new _t(e);for(let o=n?1:0;o<i;){let a=_n<i-o?_n:i-o,c=new _t(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new _t(new Uint32Array([Ko[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;)_t.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new _t(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new _t(new Uint32Array(t.buffer)).plus(e)}},Gt=class{constructor(t){this.buffer=t}high(){return new _t(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new _t(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 J(new Uint32Array([this.buffer[3],0])),n=new J(new Uint32Array([this.buffer[2],0])),i=new J(new Uint32Array([this.buffer[1],0])),s=new J(new Uint32Array([this.buffer[0],0])),o=new J(new Uint32Array([t.buffer[3],0])),a=new J(new Uint32Array([t.buffer[2],0])),c=new J(new Uint32Array([t.buffer[1],0])),l=new J(new Uint32Array([t.buffer[0],0])),u=J.multiply(s,l);this.buffer[0]=u.low();let f=new J(new Uint32Array([u.high(),0]));return u=J.multiply(i,l),f.plus(u),u=J.multiply(s,c),f.plus(u),this.buffer[1]=f.low(),this.buffer[3]=f.lessThan(u)?1:0,this.buffer[2]=f.high(),new J(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(J.multiply(n,l)).plus(J.multiply(i,c)).plus(J.multiply(s,a)),this.buffer[3]+=J.multiply(e,l).plus(J.multiply(n,c)).plus(J.multiply(i,a)).plus(J.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`${bn(this.buffer[3])} ${bn(this.buffer[2])} ${bn(this.buffer[1])} ${bn(this.buffer[0])}`}static multiply(t,e){return new Gt(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new Gt(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return Gt.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return Gt.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let n=t.startsWith("-"),i=t.length,s=new Gt(e);for(let o=n?1:0;o<i;){let a=_n<i-o?_n:i-o,c=new Gt(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new Gt(new Uint32Array([Ko[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;)Gt.from(t[n],new Uint32Array(e.buffer,e.byteOffset+4*4*n,4));return e}};var Kn=class extends x{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 E?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===q.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)}},Is=class extends Kn{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):Mr(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return R(Uint8Array,R(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return R(Uint8Array,R(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;return m.isTimestamp(t)?R(Uint8Array,_t.convertArray(n[e])):(m.isInt(t)||m.isTime(t))&&t.bitWidth===64||m.isDuration(t)?R(Uint8Array,_t.convertArray(n[e])):m.isDate(t)&&t.unit===at.MILLISECOND?R(Uint8Array,_t.convertArray(n[e])):m.isDecimal(t)?R(Uint8Array,Gt.convertArray(n[e])):m.isBinary(t)||m.isLargeBinary(t)||m.isFixedSizeBinary(t)?Xh(n[e]):m.isBool(t)?Mr(n[e]):m.isUtf8(t)||m.isLargeUtf8(t)?ve(n[e].join("")):R(Uint8Array,R(t.ArrayType,n[e].map(i=>+i)))}};function Xh(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 wn=class extends zt{constructor(t){super(t),this._values=new be(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,T(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)n.set(o,0);else{let c=a.length;i.set(a,s),n.set(o,c),s+=c}}};var vn=class extends zt{constructor(t){super(t),this._values=new be(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,T(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)n.set(o,BigInt(0));else{let c=a.length;i.set(a,s),n.set(o,BigInt(c)),s+=c}}};var xs=class extends rt{constructor(t){super(t),this._values=new yn}setValue(t,e){this._values.set(t,+e)}};var jr=class extends ft{};jr.prototype._setValue=No;var Xn=class extends jr{};Xn.prototype._setValue=Ki;var qn=class extends jr{};qn.prototype._setValue=Xi;var Qn=class extends ft{};Qn.prototype._setValue=Mo;var Ss=class extends rt{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new Vt(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=kr({type:this.type.indices,nullValues:e}),this.dictionary=kr({type:this.type.dictionary,nullValues:null}),typeof 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 ti=class extends ft{};ti.prototype._setValue=To;var Bs=class extends rt{setValue(t,e){let[n]=this.children,i=t*this.stride;for(let s=-1,o=e.length;++s<o;)n.set(i+s,e[s])}addChild(t,e="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");let n=this.children.push(t);return this.type=new ie(this.type.listSize,new E(e,t.type,!0)),n}};var Vr=class extends ft{setValue(t,e){this._values.set(t,e)}},As=class extends Vr{setValue(t,e){super.setValue(t,zn(e))}},Os=class extends Vr{},Ds=class extends Vr{};var zr=class extends ft{};zr.prototype._setValue=Eo;var ei=class extends zr{};ei.prototype._setValue=os;var ri=class extends zr{};ri.prototype._setValue=as;var tr=class extends ft{};tr.prototype._setValue=Co;var ni=class extends tr{};ni.prototype._setValue=cs;var ii=class extends tr{};ii.prototype._setValue=ls;var si=class extends tr{};si.prototype._setValue=us;var oi=class extends tr{};oi.prototype._setValue=hs;var oe=class extends ft{setValue(t,e){this._values.set(t,e)}},Fs=class extends oe{},Ts=class extends oe{},Ns=class extends oe{},Ls=class extends oe{},Us=class extends oe{},Ms=class extends oe{},Es=class extends oe{},Cs=class extends oe{};var Rs=class extends zt{constructor(t){super(t),this._offsets=new gn(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 re(new E(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 Ps=class extends zt{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 se(new E(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 js=class extends rt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var ks=class extends rt{setValue(t,e){let{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach((s,o)=>n[o].set(t,e[o]));case Map:return i.children.forEach((s,o)=>n[o].set(t,e.get(s.name)));default:return i.children.forEach((s,o)=>n[o].set(t,e[s.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(n=>n.setValid(t,e)),e}addChild(t,e=`${this.numChildren}`){let n=this.children.push(t);return this.type=new Z([...this.type.children,new E(e,t.type,!0)]),n}};var er=class extends ft{};er.prototype._setValue=Lo;var ai=class extends er{};ai.prototype._setValue=qi;var ci=class extends er{};ci.prototype._setValue=Qi;var li=class extends er{};li.prototype._setValue=ts;var ui=class extends er{};ui.prototype._setValue=es;var rr=class extends ft{};rr.prototype._setValue=Uo;var hi=class extends rr{};hi.prototype._setValue=rs;var fi=class extends rr{};fi.prototype._setValue=ns;var di=class extends rr{};di.prototype._setValue=is;var pi=class extends rr{};pi.prototype._setValue=ss;var In=class extends rt{constructor(t){super(t),this._typeIds=new Xe(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 E(e,t.type)];return this.type=new ne(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.")}},Vs=class extends In{},zs=class extends In{constructor(t){super(t),this._offsets=new Xe(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 mi=class extends zt{constructor(t){super(t),this._values=new be(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,ve(e))}_flushPending(t,e){}};mi.prototype._flushPending=wn.prototype._flushPending;var yi=class extends zt{constructor(t){super(t),this._values=new be(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,ve(e))}_flushPending(t,e){}};yi.prototype._flushPending=vn.prototype._flushPending;var qo=class extends x{visitNull(){return js}visitBool(){return xs}visitInt(){return oe}visitInt8(){return Fs}visitInt16(){return Ts}visitInt32(){return Ns}visitInt64(){return Ls}visitUint8(){return Us}visitUint16(){return Ms}visitUint32(){return Es}visitUint64(){return Cs}visitFloat(){return Vr}visitFloat16(){return As}visitFloat32(){return Os}visitFloat64(){return Ds}visitUtf8(){return mi}visitLargeUtf8(){return yi}visitBinary(){return wn}visitLargeBinary(){return vn}visitFixedSizeBinary(){return ti}visitDate(){return jr}visitDateDay(){return Xn}visitDateMillisecond(){return qn}visitTimestamp(){return er}visitTimestampSecond(){return ai}visitTimestampMillisecond(){return ci}visitTimestampMicrosecond(){return li}visitTimestampNanosecond(){return ui}visitTime(){return rr}visitTimeSecond(){return hi}visitTimeMillisecond(){return fi}visitTimeMicrosecond(){return di}visitTimeNanosecond(){return pi}visitDecimal(){return Qn}visitList(){return Rs}visitStruct(){return ks}visitUnion(){return In}visitDenseUnion(){return zs}visitSparseUnion(){return Vs}visitDictionary(){return Ss}visitInterval(){return zr}visitIntervalDayTime(){return ei}visitIntervalYearMonth(){return ri}visitDuration(){return tr}visitDurationSecond(){return ni}visitDurationMillisecond(){return ii}visitDurationMicrosecond(){return si}visitDurationNanosecond(){return oi}visitFixedSizeList(){return Bs}visitMap(){return Ps}},el=new qo;var O=class extends x{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 Lt(r,t){return t instanceof r.constructor}function Wr(r,t){return r===t||Lt(r,t)}function nr(r,t){return r===t||Lt(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function Ws(r,t){return r===t||Lt(r,t)&&r.precision===t.precision}function qh(r,t){return r===t||Lt(r,t)&&r.byteWidth===t.byteWidth}function Qo(r,t){return r===t||Lt(r,t)&&r.unit===t.unit}function gi(r,t){return r===t||Lt(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function bi(r,t){return r===t||Lt(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function Qh(r,t){return r===t||Lt(r,t)&&r.children.length===t.children.length&&He.compareManyFields(r.children,t.children)}function tf(r,t){return r===t||Lt(r,t)&&r.children.length===t.children.length&&He.compareManyFields(r.children,t.children)}function ta(r,t){return r===t||Lt(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&He.compareManyFields(r.children,t.children)}function ef(r,t){return r===t||Lt(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&He.visit(r.indices,t.indices)&&He.visit(r.dictionary,t.dictionary)}function ea(r,t){return r===t||Lt(r,t)&&r.unit===t.unit}function _i(r,t){return r===t||Lt(r,t)&&r.unit===t.unit}function rf(r,t){return r===t||Lt(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&He.compareManyFields(r.children,t.children)}function nf(r,t){return r===t||Lt(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&He.compareManyFields(r.children,t.children)}O.prototype.visitNull=Wr;O.prototype.visitBool=Wr;O.prototype.visitInt=nr;O.prototype.visitInt8=nr;O.prototype.visitInt16=nr;O.prototype.visitInt32=nr;O.prototype.visitInt64=nr;O.prototype.visitUint8=nr;O.prototype.visitUint16=nr;O.prototype.visitUint32=nr;O.prototype.visitUint64=nr;O.prototype.visitFloat=Ws;O.prototype.visitFloat16=Ws;O.prototype.visitFloat32=Ws;O.prototype.visitFloat64=Ws;O.prototype.visitUtf8=Wr;O.prototype.visitLargeUtf8=Wr;O.prototype.visitBinary=Wr;O.prototype.visitLargeBinary=Wr;O.prototype.visitFixedSizeBinary=qh;O.prototype.visitDate=Qo;O.prototype.visitDateDay=Qo;O.prototype.visitDateMillisecond=Qo;O.prototype.visitTimestamp=gi;O.prototype.visitTimestampSecond=gi;O.prototype.visitTimestampMillisecond=gi;O.prototype.visitTimestampMicrosecond=gi;O.prototype.visitTimestampNanosecond=gi;O.prototype.visitTime=bi;O.prototype.visitTimeSecond=bi;O.prototype.visitTimeMillisecond=bi;O.prototype.visitTimeMicrosecond=bi;O.prototype.visitTimeNanosecond=bi;O.prototype.visitDecimal=Wr;O.prototype.visitList=Qh;O.prototype.visitStruct=tf;O.prototype.visitUnion=ta;O.prototype.visitDenseUnion=ta;O.prototype.visitSparseUnion=ta;O.prototype.visitDictionary=ef;O.prototype.visitInterval=ea;O.prototype.visitIntervalDayTime=ea;O.prototype.visitIntervalYearMonth=ea;O.prototype.visitDuration=_i;O.prototype.visitDurationSecond=_i;O.prototype.visitDurationMillisecond=_i;O.prototype.visitDurationMicrosecond=_i;O.prototype.visitDurationNanosecond=_i;O.prototype.visitFixedSizeList=rf;O.prototype.visitMap=nf;var He=new O;function Gr(r,t){return He.compareSchemas(r,t)}function rl(r,t){return He.compareFields(r,t)}function nl(r,t){return He.visit(r,t)}function kr(r){let t=r.type,e=new(el.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(kr(Object.assign(Object.assign({},l),{type:c})))}}return e}function Gs(r,t){return sf(r,t.map(e=>e.data.concat()))}function sf(r,t){let e=[...r.fields],n=[],i={numBatches:t.reduce((f,d)=>Math.max(f,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=of(e,o,u,t,i),o>0&&(n[s++]=w({type:new Z(e),length:o,nullCount:0,children:u.slice()})))}return[r=r.assign(e),n.map(f=>new Y(r,f))]}function of(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 f=r[a];r[a]=f.clone({nullable:!0}),e[a]=(s=l?._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:w({type:f.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var il,st=class{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new P([]),this._offsets=[0],this;let i,s;t[0]instanceof P&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=c=>{if(c){if(c instanceof Y)return[c];if(c instanceof st)return c.batches;if(c instanceof k){if(c.type instanceof Z)return[new Y(new P(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 _([c[p]])),f=i??new P(l.map((p,g)=>new E(String(p),u[g].type,u[g].nullable))),[,d]=Gs(f,u);return d.length===0?[new Y(c)]:d}}}return[]},a=t.flatMap(c=>o(c));if(i=(n=i??((e=a[0])===null||e===void 0?void 0:e.schema))!==null&&n!==void 0?n:new P([]),!(i instanceof P))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof Y))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Gr(i,c.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??ys(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=ms(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(Nr(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?dn.visit(new _(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
|
|
14
|
+
${this.toArray().join(`,
|
|
15
|
+
`)}
|
|
16
|
+
]`}concat(...t){let e=this.schema,n=this.data.concat(t.flatMap(({data:i})=>i));return new st(e,n.map(i=>new Y(e,i)))}slice(t,e){let n=this.schema;[t,e]=Wn({length:this.numRows},t,e);let i=gs(this.data,this._offsets,t,e);return new st(n,i.map(s=>new Y(n,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){let e=this.data.map(n=>n.children[t]);if(e.length===0){let{type:n}=this.schema.fields[t],i=w({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new _(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 _([w({type:new At,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]=Gs(n,a)}return new st(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 st(e,n)}assign(t){let e=this.schema.fields,[n,i]=t.schema.fields.reduce((a,c,l)=>{let[u,f]=a,d=e.findIndex(p=>p.name===c.name);return~d?f[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 st(...Gs(s,o))}};il=Symbol.toStringTag;st[il]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=fn($n),r.get=fn(ht.getVisitFn(h.Struct)),r.set=bs(vt.getVisitFn(h.Struct)),r.indexOf=_s(Cr.getVisitFn(h.Struct)),"Table"))(st.prototype);var ol,Y=class{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof P))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=w({nullCount:0,type:new Z(this.schema.fields),children:this.schema.fields.map(e=>w({type:e.type,nullCount:0}))})]=t,!(this.data instanceof k))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=sl(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]=E.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new P(n),a=w({type:new Z(n),length:s,children:i,nullCount:0});[this.schema,this.data]=sl(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=al(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 ht.visit(this.data,t)}at(t){return this.get(Nr(t,this.numRows))}set(t,e){return vt.visit(this.data,t,e)}indexOf(t,e){return Cr.visit(this.data,t,e)}[Symbol.iterator](){return dn.visit(new _([this.data]))}toArray(){return[...this]}concat(...t){return new st(this.schema,[this,...t])}slice(t,e){let[n]=new _([this.data]).slice(t,e).data;return new Y(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new _([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 _([w({type:new At,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 P(s,new Map(this.schema.metadata)),i=w({type:new Z(s),children:o})}return new Y(n,i)}select(t){let e=this.schema.select(t),n=new Z(e.fields),i=[];for(let s of t){let o=this.schema.fields.findIndex(a=>a.name===s);~o&&(i[o]=this.data.children[o])}return new Y(e,w({type:n,length:this.numRows,children:i}))}selectAt(t){let e=this.schema.selectAt(t),n=t.map(s=>this.data.children[s]).filter(Boolean),i=w({type:new Z(e.fields),length:this.numRows,children:n});return new Y(e,i)}};ol=Symbol.toStringTag;Y[ol]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Y.prototype);function sl(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 Z(i),length:e,children:s})]}function al(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)||[]])al(a.children,l?.children,e);if(m.isDictionary(a)){let{id:l}=a;if(!e.has(l))c?.dictionary&&e.set(l,c.dictionary);else if(e.get(l)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var Jr=class extends Y{constructor(t){let e=t.fields.map(i=>w({type:i.type})),n=w({type:new Z(t.fields),nullCount:0,children:e});super(t,n)}};var ct=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 ct).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new ct).__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):j.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,j.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 ct.startMessage(t),ct.addVersion(t,e),ct.addHeaderType(t,n),ct.addHeader(t,i),ct.addBodyLength(t,s),ct.addCustomMetadata(t,o),ct.endMessage(t)}};var ra=class extends x{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Fe.startNull(e),Fe.endNull(e)}visitInt(t,e){return yt.startInt(e),yt.addBitWidth(e,t.bitWidth),yt.addIsSigned(e,t.isSigned),yt.endInt(e)}visitFloat(t,e){return Pt.startFloatingPoint(e),Pt.addPrecision(e,t.precision),Pt.endFloatingPoint(e)}visitBinary(t,e){return Se.startBinary(e),Se.endBinary(e)}visitLargeBinary(t,e){return Ae.startLargeBinary(e),Ae.endLargeBinary(e)}visitBool(t,e){return Be.startBool(e),Be.endBool(e)}visitUtf8(t,e){return Ne.startUtf8(e),Ne.endUtf8(e)}visitLargeUtf8(t,e){return Oe.startLargeUtf8(e),Oe.endLargeUtf8(e)}visitDecimal(t,e){return gt.startDecimal(e),gt.addScale(e,t.scale),gt.addPrecision(e,t.precision),gt.addBitWidth(e,t.bitWidth),gt.endDecimal(e)}visitDate(t,e){return Mt.startDate(e),Mt.addUnit(e,t.unit),Mt.endDate(e)}visitTime(t,e){return St.startTime(e),St.addUnit(e,t.unit),St.addBitWidth(e,t.bitWidth),St.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return Bt.startTimestamp(e),Bt.addUnit(e,t.unit),n!==void 0&&Bt.addTimezone(e,n),Bt.endTimestamp(e)}visitInterval(t,e){return jt.startInterval(e),jt.addUnit(e,t.unit),jt.endInterval(e)}visitDuration(t,e){return Et.startDuration(e),Et.addUnit(e,t.unit),Et.endDuration(e)}visitList(t,e){return De.startList(e),De.endList(e)}visitStruct(t,e){return Te.startStruct_(e),Te.endStruct_(e)}visitUnion(t,e){bt.startTypeIdsVector(e,t.typeIds.length);let n=bt.createTypeIdsVector(e,t.typeIds);return bt.startUnion(e),bt.addMode(e,t.mode),bt.addTypeIds(e,n),bt.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return Zt.startDictionaryEncoding(e),Zt.addId(e,BigInt(t.id)),Zt.addIsOrdered(e,t.isOrdered),n!==void 0&&Zt.addIndexType(e,n),Zt.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Ct.startFixedSizeBinary(e),Ct.addByteWidth(e,t.byteWidth),Ct.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Rt.startFixedSizeList(e),Rt.addListSize(e,t.listSize),Rt.endFixedSizeList(e)}visitMap(t,e){return kt.startMap(e),kt.addKeysSorted(e,t.keysSorted),kt.endMap(e)}},Js=new ra;function hl(r,t=new Map){return new P(af(r,t),$s(r.metadata),t)}function na(r){return new It(r.count,dl(r.columns),pl(r.columns))}function fl(r){return new $t(na(r.data),r.id,r.isDelta)}function af(r,t){return(r.fields||[]).filter(Boolean).map(e=>E.fromJSON(e,t))}function cl(r,t){return(r.children||[]).filter(Boolean).map(e=>E.fromJSON(e,t))}function dl(r){return(r||[]).reduce((t,e)=>[...t,new ae(e.count,cf(e.VALIDITY)),...dl(e.children)],[])}function pl(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new Jt(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new Jt(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new Jt(t.length,i.OFFSET.length)),i.DATA&&t.push(new Jt(t.length,i.DATA.length)),t=pl(i.children,t)}return t}function cf(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function ml(r,t){let e,n,i,s,o,a;return!t||!(s=r.dictionary)?(o=ul(r,cl(r,t)),i=new E(r.name,o,r.nullable,$s(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?ll(n):new Kt,a=new Vt(t.get(e),n,e,s.isOrdered),i=new E(r.name,a,r.nullable,$s(r.metadata))):(n=(n=s.indexType)?ll(n):new Kt,t.set(e,o=ul(r,cl(r,t))),a=new Vt(o,n,e,s.isOrdered),i=new E(r.name,a,r.nullable,$s(r.metadata))),i||null}function $s(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function ll(r){return new ut(r.isSigned,r.bitWidth)}function ul(r,t){let e=r.type.name;switch(e){case"NONE":return new At;case"null":return new At;case"binary":return new Le;case"largebinary":return new Ue;case"utf8":return new Me;case"largeutf8":return new Ee;case"bool":return new Ce;case"list":return new re((t||[])[0]);case"struct":return new Z(t||[]);case"struct_":return new Z(t||[])}switch(e){case"int":{let n=r.type;return new ut(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new Xt(K[n.precision])}case"decimal":{let n=r.type;return new Re(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new Pe(at[n.unit])}case"time":{let n=r.type;return new je(v[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new ke(v[n.unit],n.timezone)}case"interval":{let n=r.type;return new Ve(mt[n.unit])}case"duration":{let n=r.type;return new ze(v[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new ne(q[o],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new We(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new ie(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new se((t||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var lf=Ye,uf=Nt,dt=class{static fromJSON(t,e){let n=new dt(0,H.V5,e);return n._createHeader=hf(t,e),n}static decode(t){t=new uf(T(t));let e=ct.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new dt(n,i,s);return o._createHeader=ff(e,s),o}static encode(t){let e=new lf,n=-1;return t.isSchema()?n=P.encode(e,t.header()):t.isRecordBatch()?n=It.encode(e,t.header()):t.isDictionaryBatch()&&(n=$t.encode(e,t.header())),ct.startMessage(e),ct.addVersion(e,H.V5),ct.addHeader(e,n),ct.addHeaderType(e,t.headerType),ct.addBodyLength(e,BigInt(t.bodyLength)),ct.finishMessageBuffer(e,ct.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof P)return new dt(0,H.V5,j.Schema,t);if(t instanceof It)return new dt(e,H.V5,j.RecordBatch,t);if(t instanceof $t)return new dt(e,H.V5,j.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===j.Schema}isRecordBatch(){return this.headerType===j.RecordBatch}isDictionaryBatch(){return this.headerType===j.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=W(t)}},It=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=W(t)}},$t=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=W(e)}},Jt=class{constructor(t,e){this.offset=W(t),this.length=W(e)}},ae=class{constructor(t,e){this.length=W(t),this.nullCount=W(e)}};function hf(r,t){return()=>{switch(t){case j.Schema:return P.fromJSON(r);case j.RecordBatch:return It.fromJSON(r);case j.DictionaryBatch:return $t.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${j[t]}, type: ${t} }`)}}function ff(r,t){return()=>{switch(t){case j.Schema:return P.decode(r.header(new it),new Map,r.version());case j.RecordBatch:return It.decode(r.header(new xt),r.version());case j.DictionaryBatch:return $t.decode(r.header(new ee),r.version())}throw new Error(`Unrecognized Message type: { name: ${j[t]}, type: ${t} }`)}}E.encode=xf;E.decode=vf;E.fromJSON=ml;P.encode=If;P.decode=df;P.fromJSON=hl;It.encode=Sf;It.decode=pf;It.fromJSON=na;$t.encode=Bf;$t.decode=mf;$t.fromJSON=fl;ae.encode=Af;ae.decode=gf;Jt.encode=Of;Jt.decode=yf;function df(r,t=new Map,e=H.V5){let n=wf(r,t);return new P(n,Hs(r),t,e)}function pf(r,t=H.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new It(r.length(),bf(r),_f(r,t))}function mf(r,t=H.V5){return new $t(It.decode(r.data(),t),r.id(),r.isDelta())}function yf(r){return new Jt(r.offset(),r.length())}function gf(r){return new ae(r.length(),r.nullCount())}function bf(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=ae.decode(e));return t}function _f(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]=Jt.decode(n));return e}function wf(r,t){let e=[];for(let n,i=-1,s=-1,o=r.fieldsLength();++i<o;)(n=r.fields(i))&&(e[++s]=E.decode(n,t));return e}function yl(r,t){let e=[];for(let n,i=-1,s=-1,o=r.childrenLength();++i<o;)(n=r.children(i))&&(e[++s]=E.decode(n,t));return e}function vf(r,t){let e,n,i,s,o,a;return!t||!(a=r.dictionary())?(i=bl(r,yl(r,t)),n=new E(r.name(),i,r.nullable(),Hs(r))):t.has(e=W(a.id()))?(s=(s=a.indexType())?gl(s):new Kt,o=new Vt(t.get(e),s,e,a.isOrdered()),n=new E(r.name(),o,r.nullable(),Hs(r))):(s=(s=a.indexType())?gl(s):new Kt,t.set(e,i=bl(r,yl(r,t))),o=new Vt(i,s,e,a.isOrdered()),n=new E(r.name(),o,r.nullable(),Hs(r))),n||null}function Hs(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 gl(r){return new ut(r.isSigned(),r.bitWidth())}function bl(r,t){let e=r.typeType();switch(e){case X.NONE:return new At;case X.Null:return new At;case X.Binary:return new Le;case X.LargeBinary:return new Ue;case X.Utf8:return new Me;case X.LargeUtf8:return new Ee;case X.Bool:return new Ce;case X.List:return new re((t||[])[0]);case X.Struct_:return new Z(t||[])}switch(e){case X.Int:{let n=r.type(new yt);return new ut(n.isSigned(),n.bitWidth())}case X.FloatingPoint:{let n=r.type(new Pt);return new Xt(n.precision())}case X.Decimal:{let n=r.type(new gt);return new Re(n.scale(),n.precision(),n.bitWidth())}case X.Date:{let n=r.type(new Mt);return new Pe(n.unit())}case X.Time:{let n=r.type(new St);return new je(n.unit(),n.bitWidth())}case X.Timestamp:{let n=r.type(new Bt);return new ke(n.unit(),n.timezone())}case X.Interval:{let n=r.type(new jt);return new Ve(n.unit())}case X.Duration:{let n=r.type(new Et);return new ze(n.unit())}case X.Union:{let n=r.type(new bt);return new ne(n.mode(),n.typeIdsArray()||[],t||[])}case X.FixedSizeBinary:{let n=r.type(new Ct);return new We(n.byteWidth())}case X.FixedSizeList:{let n=r.type(new Rt);return new ie(n.listSize(),(t||[])[0])}case X.Map:{let n=r.type(new kt);return new se((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${X[e]}" (${e})`)}function If(r,t){let e=t.fields.map(s=>E.encode(r,s));it.startFieldsVector(r,e.length);let n=it.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?it.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 it.startSchema(r),it.addFields(r,n),it.addEndianness(r,Df?hr.Little:hr.Big),i!==-1&&it.addCustomMetadata(r,i),it.endSchema(r)}function xf(r,t){let e=-1,n=-1,i=-1,s=t.type,o=t.typeId;m.isDictionary(s)?(o=s.dictionary.typeId,i=Js.visit(s,r),n=Js.visit(s.dictionary,r)):n=Js.visit(s,r);let a=(s.children||[]).map(u=>E.encode(r,u)),c=lt.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?lt.createCustomMetadataVector(r,[...t.metadata].map(([u,f])=>{let d=r.createString(`${u}`),p=r.createString(`${f}`);return Q.startKeyValue(r),Q.addKey(r,d),Q.addValue(r,p),Q.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),lt.startField(r),lt.addType(r,n),lt.addTypeType(r,o),lt.addChildren(r,c),lt.addNullable(r,!!t.nullable),e!==-1&<.addName(r,e),i!==-1&<.addDictionary(r,i),l!==-1&<.addCustomMetadata(r,l),lt.endField(r)}function Sf(r,t){let e=t.nodes||[],n=t.buffers||[];xt.startNodesVector(r,e.length);for(let o of e.slice().reverse())ae.encode(r,o);let i=r.endVector();xt.startBuffersVector(r,n.length);for(let o of n.slice().reverse())Jt.encode(r,o);let s=r.endVector();return xt.startRecordBatch(r),xt.addLength(r,BigInt(t.length)),xt.addNodes(r,i),xt.addBuffers(r,s),xt.endRecordBatch(r)}function Bf(r,t){let e=It.encode(r,t.data);return ee.startDictionaryBatch(r),ee.addId(r,BigInt(t.id)),ee.addIsDelta(r,t.isDelta),ee.addData(r,e),ee.endDictionaryBatch(r)}function Af(r,t){return rn.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function Of(r,t){return en.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var Df=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var sa=r=>`Expected ${j[r]} Message in stream, but was null or length 0.`,oa=r=>`Header pointer of flatbuffer-encoded ${j[r]} Message is null or length 0.`,_l=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,wl=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,xn=class{constructor(t){this.source=t instanceof $e?t:new $e(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?tt:t.value===-1&&(t=this.readMetadataLength()).done?tt:(t=this.readMetadata(t.value)).done?tt: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(sa(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=T(this.source.read(t));if(e.byteLength<t)throw new Error(wl(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=j.Schema,n=this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(oa(e));return i}readMetadataLength(){let t=this.source.read(Ys),e=t&&new Nt(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}}readMetadata(t){let e=this.source.read(t);if(!e)return tt;if(e.byteLength<t)throw new Error(_l(t,e.byteLength));return{done:!1,value:dt.decode(e)}}},wi=class{constructor(t,e){this.source=t instanceof Wt?t:ji(t)?new yr(t,e):new Wt(t)}[Symbol.asyncIterator](){return this}next(){return y(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?tt:t.value===-1&&(t=yield this.readMetadataLength()).done?tt:(t=yield this.readMetadata(t.value)).done?tt:t})}throw(t){return y(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return y(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return y(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(sa(t));return e.value})}readMessageBody(t){return y(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=T(yield this.source.read(t));if(e.byteLength<t)throw new Error(wl(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return y(this,arguments,void 0,function*(t=!1){let e=j.Schema,n=yield this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(oa(e));return i})}readMetadataLength(){return y(this,void 0,void 0,function*(){let t=yield this.source.read(Ys),e=t&&new Nt(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}})}readMetadata(t){return y(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return tt;if(e.byteLength<t)throw new Error(_l(t,e.byteLength));return{done:!1,value:dt.decode(e)}})}},vi=class extends xn{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Hn?t:new Hn(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:dt.fromJSON(t.schema,j.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:dt.fromJSON(e,j.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:dt.fromJSON(e,j.RecordBatch)}}return this._body=[],tt}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(sa(t));return e.value}readSchema(){let t=j.Schema,e=this.readMessage(t),n=e?.header();if(!e||!n)throw new Error(oa(t));return n}},Ys=4,ia="ARROW1",Sn=new Uint8Array(ia.length);for(let r=0;r<ia.length;r+=1)Sn[r]=ia.codePointAt(r);function Zs(r,t=0){for(let e=-1,n=Sn.length;++e<n;)if(Sn[e]!==r[t+e])return!1;return!0}var Bn=Sn.length,aa=Bn+Ys,vl=Bn*2+Ys;var Ut=class extends Pr{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 le(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 wt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return wt.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 Ut?t:Ri(t)?Tf(t):ji(t)?Uf(t):le(t)?(()=>y(this,void 0,void 0,function*(){return yield Ut.from(yield t)}))():ki(t)||Mn(t)||zi(t)||Qt(t)?Lf(new Wt(t)):Nf(new $e(t))}static readAll(t){return t instanceof Ut?t.isSync()?Il(t):xl(t):Ri(t)||ArrayBuffer.isView(t)||ue(t)||Pi(t)?Il(t):xl(t)}},ir=class extends Ut{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Ht(this,arguments,function*(){yield C(yield*Qr(ce(this[Symbol.iterator]())))})}},$r=class extends Ut{constructor(t){super(t),this._impl=t}readAll(){return y(this,void 0,void 0,function*(){var t,e,n,i;let s=new Array;try{for(var o=!0,a=ce(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]()}},Hr=class extends ir{constructor(t){super(t),this._impl=t}},Ks=class extends $r{constructor(t){super(t),this._impl=t}},Xs=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 Z(this.schema.fields),length:t.length,children:n});return new Y(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:o}=this,a=s.get(n),c=o.dictionaries.get(n),l=this._loadVectors(t.data,e,[c]);return(a&&i?a.concat(new _(l)):new _(l)).memoize()}_loadVectors(t,e,n){return new Kn(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},An=class extends Xs{constructor(t,e){super(e),this._reader=Ri(t)?new vi(this._handle=t):new xn(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=Sl(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):tt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):tt}next(){if(this.closed)return tt;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 Jr(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},On=class extends Xs{constructor(t,e){super(e),this._reader=new wi(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return y(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return y(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Sl(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):tt})}return(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):tt})}next(){return y(this,void 0,void 0,function*(){if(this.closed)return tt;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 Jr(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return y(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},qs=class extends An{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 Yn?t:new Yn(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(j.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(j.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-aa,n=t.readInt32(e),i=t.readAt(e-n,n);return qe.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}},ca=class extends On{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 yr?t:new yr(t,n),i)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return y(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return y(this,void 0,void 0,function*(){var e;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(j.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return y(this,void 0,void 0,function*(){var e;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(j.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return y(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-aa,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return qe.decode(i)})}_readNextMessageAndValidate(t){return y(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},la=class extends An{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new Is(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function Sl(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Il(r){let t=Ut.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function xl(r){return Ht(this,arguments,function*(){let e=yield C(Ut.from(r));try{if(!(yield C(e.open({autoDestroy:!1}))).closed)do yield yield C(e);while(!(yield C(e.reset().open())).closed)}finally{yield C(e.cancel())}})}function Tf(r){return new ir(new la(r))}function Nf(r){let t=r.peek(Bn+7&-8);return t&&t.byteLength>=4?Zs(t)?new Hr(new qs(r.read())):new ir(new An(r)):new ir(new An(function*(){}()))}function Lf(r){return y(this,void 0,void 0,function*(){let t=yield r.peek(Bn+7&-8);return t&&t.byteLength>=4?Zs(t)?new Hr(new qs(yield r.read())):new $r(new On(r)):new $r(new On(function(){return Ht(this,arguments,function*(){})}()))})}function Uf(r){return y(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new yr(r,t);return t>=vl&&Zs(yield e.readAt(0,Bn+7&-8))?new Ks(new ca(e)):new $r(new On(e))})}var et=class extends x{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof Y?s.data.children:s.data),n=new et;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof _)return this.visitMany(t.data),this;let{type:e}=t;if(!m.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(m.isUnion(e))this.nodes.push(new ae(n,0));else{let{nullCount:i}=t;m.isNull(e)||we.call(this,i<=0?new Uint8Array(0):Ur(t.offset,n,t.nullBitmap)),this.nodes.push(new ae(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 we(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new Jt(this._byteLength,t)),this._byteLength+=t,this}function Mf(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(we.call(this,i),e.mode===q.Sparse)return ua.call(this,r);if(e.mode===q.Dense){if(r.offset<=0)return we.call(this,s),ua.call(this,r);{let o=new Int32Array(n),a=Object.create(null),c=Object.create(null);for(let l,u,f=-1;++f<n;)(l=i[f])!==void 0&&((u=a[l])===void 0&&(u=a[l]=s[f]),o[f]=s[f]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);we.call(this,o),this.visitMany(r.children.map((l,u)=>{let f=e.typeIds[u],d=a[f],p=c[f];return l.slice(d,Math.min(n,p))}))}}return this}function Ef(r){let t;return r.nullCount>=r.length?we.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?we.call(this,Ur(r.offset,r.length,t)):we.call(this,Mr(r.values))}function sr(r){return we.call(this,r.values.subarray(0,r.length*r.stride))}function Qs(r){let{length:t,values:e,valueOffsets:n}=r,i=W(n[0]),s=W(n[t]),o=Math.min(s-i,e.byteLength-i);return we.call(this,Gi(-i,t+1,n)),we.call(this,e.subarray(i,i+o)),this}function ha(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return we.call(this,Gi(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function ua(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}et.prototype.visitBool=Ef;et.prototype.visitInt=sr;et.prototype.visitFloat=sr;et.prototype.visitUtf8=Qs;et.prototype.visitLargeUtf8=Qs;et.prototype.visitBinary=Qs;et.prototype.visitLargeBinary=Qs;et.prototype.visitFixedSizeBinary=sr;et.prototype.visitDate=sr;et.prototype.visitTimestamp=sr;et.prototype.visitTime=sr;et.prototype.visitDecimal=sr;et.prototype.visitList=ha;et.prototype.visitStruct=ua;et.prototype.visitUnion=Mf;et.prototype.visitInterval=sr;et.prototype.visitDuration=sr;et.prototype.visitFixedSizeList=ha;et.prototype.visitMap=ha;var Yr=class extends Pr{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 Je,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Tt(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 le(t)?t.then(e=>this.writeAll(e)):Qt(t)?da(this,t):fa(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 Je?this._sink=t:(this._sink=new Je,t&&ka(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Va(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!e||!Gr(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 st&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Y&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!Gr(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Y?t instanceof Jr||this._writeRecordBatch(t):t instanceof st?this.writeAll(t.batches):ue(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=dt.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+n&~n,c=a-s-o;return t.headerType===j.RecordBatch?this._recordBatchBlocks.push(new _e(a,t.bodyLength,this._position)):t.headerType===j.DictionaryBatch&&this._dictionaryBlocks.push(new _e(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(c)}_write(t){if(this._started){let e=T(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(dt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Sn)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=et.assemble(t),o=new It(t.numRows,n,i),a=dt.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=et.assemble(new _([t])),c=new It(t.length,s,o),l=new $t(c,e,n),u=dt.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){var e,n;for(let[i,s]of t.dictionaries){let o=(e=s?.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(i),c=(n=this._dictionaryDeltaOffsets.get(i))!==null&&n!==void 0?n:0;if(!a||a.data[0]!==o[0])for(let[l,u]of o.entries())this._writeDictionaryBatch(u,i,l>0);else if(c<o.length)for(let l of o.slice(c))this._writeDictionaryBatch(l,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,o.length)}return this}},Zr=class extends Yr{static writeAll(t,e){let n=new Zr(e);return le(t)?t.then(i=>n.writeAll(i)):Qt(t)?da(n,t):fa(n,t)}},Kr=class extends Yr{static writeAll(t){let e=new Kr;return le(t)?t.then(n=>e.writeAll(n)):Qt(t)?da(e,t):fa(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,n=!1){if(!n&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,n)}_writeFooter(t){let e=qe.encode(new qe(t,H.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function fa(r,t){let e=t;t instanceof st&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function da(r,t){return y(this,void 0,void 0,function*(){var e,n,i,s,o,a,c;try{for(e=!0,n=ce(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 Bl(r,t){if(Qt(r))return Rf(r,t);if(ue(r))return Cf(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Cf(r,t){let e=null,n=t?.type==="bytes"||!1,i=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){s(o,e||(e=r[Symbol.iterator]()))},pull(o){e?s(o,e):o.close()},cancel(){(e?.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){let c,l=null,u=o.desiredSize||null;for(;!(l=a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=T(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()}}function Rf(r,t){let e=null,n=t?.type==="bytes"||!1,i=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return y(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return y(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return y(this,void 0,void 0,function*(){(e?.return&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){return y(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=T(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()})}}function Dl(r){return new pa(r)}var pa=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=Pa(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=kr(s),this._getSize=i!=="bytes"?Al:Ol;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"?Al:Ol}),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)}},Al=r=>{var t;return(t=r?.length)!==null&&t!==void 0?t:0},Ol=r=>{var t;return(t=r?.byteLength)!==null&&t!==void 0?t:0};function to(r,t){let e=new Je,n=null,i=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield e.close()})},start(a){return y(this,void 0,void 0,function*(){yield o(a,n||(n=yield s()))})},pull(a){return y(this,void 0,void 0,function*(){n?yield o(a,n):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:i};function s(){return y(this,void 0,void 0,function*(){return yield(yield Ut.from(e)).open(t)})}function o(a,c){return y(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}function eo(r,t){let e=new this(r),n=new Wt(e),i=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return y(this,void 0,void 0,function*(){yield s(o)})},start(o){return y(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(o){return y(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield n.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}var id=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Oo),Xo),Wo),Do),wo),zo),xo),{compareSchemas:Gr,compareFields:rl,compareTypes:nl});wt.toDOMStream=Bl;rt.throughDOM=Dl;Ut.throughDOM=to;Hr.throughDOM=to;ir.throughDOM=to;Yr.throughDOM=eo;Kr.throughDOM=eo;Zr.throughDOM=eo;function Tl(r){switch(r.shape){case"array-row-table":case"object-row-table":return od(r.data);case"geojson-table":return ad(r.features);case"columnar-table":return sd(r.data);case"arrow-table":default:throw new Error("Deduce schema")}}function sd(r){let t=[];for(let[e,n]of Object.entries(r)){let i=cd(n,e);t.push(i)}return{fields:t,metadata:{}}}function od(r){if(!r.length)throw new Error("deduce from empty table");let t=[],e=r[0];for(let[n,i]of Object.entries(e))t.push(Nl(i,n));return{fields:t,metadata:{}}}function ad(r){if(!r.length)throw new Error("deduce from empty table");let t=[],e=r[0].properties||{};for(let[n,i]of Object.entries(e))t.push(Nl(i,n));return{fields:t,metadata:{}}}function cd(r,t){if(ArrayBuffer.isView(r)){let e=Ea(r);return{name:t,type:e.type||"null",nullable:e.nullable}}if(Array.isArray(r)&&r.length>0){let e=r[0],n=Ci(e);return{name:t,type:n,nullable:!0}}throw new Error("empty table")}function Nl(r,t){let e=Ci(r);return{name:t,type:e,nullable:!0}}function Ii(r){let t;switch(ld(r)){case"array-row-table":t={shape:"array-row-table",data:r};break;case"object-row-table":t={shape:"object-row-table",data:r};break;case"columnar-table":t={shape:"columnar-table",data:r};break;case"arrow-table":t={shape:"arrow-table",data:r};break;default:throw new Error("table")}let e=Tl(t);return{...t,schema:e}}function ld(r){if(r instanceof st)return"arrow-table";if(Array.isArray(r)){if(r.length===0)throw new Error("cannot deduce type of empty table");let t=r[0];if(Array.isArray(t))return"array-row-table";if(t&&typeof t=="object")return"object-row-table"}if(r&&typeof r=="object")return"columnar-table";throw new Error("invalid table")}function gr(r){switch(r.shape){case"array-row-table":case"object-row-table":return r.data.length;case"geojson-table":return r.features.length;case"arrow-table":return r.data.numRows;case"columnar-table":for(let e of Object.values(r.data))return e.length||0;return 0;default:throw new Error("table")}}function ro(r){if(r.schema)return r.schema.fields.length;if(gr(r)===0)throw new Error("empty table");switch(r.shape){case"array-row-table":return r.data[0].length;case"object-row-table":return Object.keys(r.data[0]).length;case"geojson-table":return Object.keys(r.features[0]).length;case"columnar-table":return Object.keys(r.data).length;case"arrow-table":return r.data.numCols;default:throw new Error("table")}}function no(r,t,e,n){switch(r.shape){case"object-row-table":return n?Object.fromEntries(Object.entries(r.data[t])):r.data[t];case"array-row-table":if(r.schema){let c=e||{};for(let l=0;l<r.schema.fields.length;l++)c[r.schema.fields[l].name]=r.data[t][l];return c}throw new Error("no schema");case"geojson-table":if(r.schema){let c=e||{};for(let l=0;l<r.schema.fields.length;l++)c[r.schema.fields[l].name]=r.features[t][l];return c}throw new Error("no schema");case"columnar-table":if(r.schema){let c=e||{};for(let l=0;l<r.schema.fields.length;l++)c[r.schema.fields[l].name]=r.data[r.schema.fields[l].name][t];return c}else{let c=e||{};for(let[l,u]of Object.entries(r.data))c[l]=u[t];return c}case"arrow-table":let i=r.data,s=e||{},o=i.get(t),a=i.schema;for(let c=0;c<a.fields.length;c++)s[a.fields[c].name]=o?.[a.fields[c].name];return s;default:throw new Error("shape")}}function io(r,t,e,n){switch(r.shape){case"array-row-table":return n?Array.from(r.data[t]):r.data[t];case"object-row-table":if(r.schema){let c=e||[];for(let l=0;l<r.schema.fields.length;l++)c[l]=r.data[t][r.schema.fields[l].name];return c}return Object.values(r.data[t]);case"geojson-table":if(r.schema){let c=e||[];for(let l=0;l<r.schema.fields.length;l++)c[l]=r.features[t][r.schema.fields[l].name];return c}return Object.values(r.features[t]);case"columnar-table":if(r.schema){let c=e||[];for(let l=0;l<r.schema.fields.length;l++)c[l]=r.data[r.schema.fields[l].name][t];return c}else{let c=e||[],l=0;for(let u of Object.values(r.data))c[l]=u[t],l++;return c}case"arrow-table":let i=r.data,s=e||[],o=i.get(t),a=i.schema;for(let c=0;c<a.fields.length;c++)s[c]=o?.[a.fields[c].name];return s;default:throw new Error("shape")}}function*ma(r,t){switch(t){case"array-row-table":yield*Ll(r);break;case"object-row-table":yield*Ul(r);break;default:throw new Error(`Unknown row type ${t}`)}}function*Ll(r,t=[]){let e=gr(r);for(let n=0;n<e;n++)yield io(r,n,t)}function*Ul(r,t={}){let e=gr(r);for(let n=0;n<e;n++)yield no(r,n,t)}function Ml(r,t){if(!r)throw new Error("null row");let e={};if(t)for(let n=0;n<t.length;n++)e[t[n]]=r[n];else for(let n=0;n<r.length;n++){let i=`column-${n}`;e[i]=r[n]}return e}function El(r,t){if(!r)throw new Error("null row");if(t){let e=new Array(t.length);for(let n=0;n<t.length;n++)e[n]=r[t[n]];return e}return Object.values(r)}function Cl(r){let t=[];for(let e=0;e<r.length;e++){let n=`column-${e}`;t.push(n)}return t}function Rl(r){return Object.keys(r)}var so=class{schema;options;shape;length=0;rows=null;cursor=0;_headers=[];constructor(t,e){if(this.options=e,this.schema=t,!Array.isArray(t)){this._headers=[];for(let n in t)this._headers[t[n].index]=t[n].name}}rowCount(){return this.length}addArrayRow(t,e){Number.isFinite(e)&&(this.cursor=e),this.shape="array-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=t,this.length++}addObjectRow(t,e){Number.isFinite(e)&&(this.cursor=e),this.shape="object-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=t,this.length++}getBatch(){let t=this.rows;return t?(t=t.slice(0,this.length),this.rows=null,{shape:this.shape||"array-row-table",batchType:"data",data:t,length:this.length,schema:this.schema,cursor:this.cursor}):null}};var Pl=100,oo=class{schema;options;length=0;objectRows=null;arrayRows=null;cursor=0;_headers=null;constructor(t,e){if(this.options=e,this.schema=t,t){this._headers=[];for(let n=0;n<t.fields.length;n++)this._headers[n]=t.fields[n].name}}rowCount(){return this.length}addArrayRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this._headers||=Cl(t),this.options.shape){case"object-row-table":let n=Ml(t,this._headers);this.addObjectRow(n,e);break;case"array-row-table":this.arrayRows=this.arrayRows||new Array(Pl),this.arrayRows[this.length]=t,this.length++;break}}addObjectRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this._headers||=Rl(t),this.options.shape){case"array-row-table":let n=El(t,this._headers);this.addArrayRow(n,e);break;case"object-row-table":this.objectRows=this.objectRows||new Array(Pl),this.objectRows[this.length]=t,this.length++;break}}getBatch(){let t=this.arrayRows||this.objectRows;return t?(t=t.slice(0,this.length),this.arrayRows=null,this.objectRows=null,{shape:this.options.shape,batchType:"data",data:t,length:this.length,schema:this.schema,cursor:this.cursor}):null}};function ya(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var ud=100,Dn=class{schema;length=0;allocated=0;columns={};constructor(t,e){this.schema=t,this._reallocateColumns()}rowCount(){return this.length}addArrayRow(t){this._reallocateColumns();let e=0;for(let n in this.columns)this.columns[n][this.length]=t[e++];this.length++}addObjectRow(t){this._reallocateColumns();for(let e in t)this.columns[e][this.length]=t[e];this.length++}getBatch(){return this._pruneColumns(),{shape:"columnar-table",batchType:"data",data:this.columns,schema:this.schema,length:this.length}}_reallocateColumns(){if(!(this.length<this.allocated)){this.allocated=this.allocated>0?this.allocated*=2:ud,this.columns={};for(let t of this.schema.fields){let e=Ca(t.type,t.nullable),n=this.columns[t.name];if(!n)this.columns[t.name]=new e(this.allocated);else if(Array.isArray(n))n.length=this.allocated;else if(ya(n)){let i=new e(this.allocated);i.set(n),this.columns[t.name]=i}else throw new Error("Invalid column type")}}}_pruneColumns(){for(let[t,e]of Object.entries(this.columns))this.columns[t]=e.slice(0,this.length)}};var ao=class extends Dn{arrowSchema;constructor(t,e){super(t,e),this.arrowSchema=null}getBatch(){let t=super.getBatch();if(t){this.arrowSchema=this.arrowSchema||hd(t.schema);let e=fd(this.arrowSchema,t.data),n=new Y(this.arrowSchema,w({type:new Z(this.arrowSchema.fields),children:e.map(({data:i})=>i[0])}));return{shape:"arrow-table",batchType:"data",data:new st([n]),length:t.length}}return null}};function hd(r){let t=[];for(let e in r){let n=r[e];if(n.type===Float32Array){let i=new Map,s=new E(n.name,new Ze,n.nullable,i);t.push(s)}}if(t.length===0)throw new Error("No arrow convertible fields");return new P(t)}function fd(r,t){let e=[];for(let n of r.fields){let i=t[n.name];if(i instanceof Float32Array){let s=mn(i);e.push(s)}}if(r.fields.length!==e.length)throw new Error("Some columns not arrow convertible");return e}var dd={shape:void 0,batchSize:"auto",batchDebounceMs:0,limit:0,_limitMB:0},br=class{schema;options;aggregator=null;batchCount=0;bytesUsed=0;isChunkComplete=!1;lastBatchEmittedMs=Date.now();totalLength=0;totalBytes=0;rowBytes=0;constructor(t,e){this.schema=t,this.options={...dd,...e}}limitReached(){return!!(Boolean(this.options?.limit)&&this.totalLength>=this.options.limit||Boolean(this.options?._limitMB)&&this.totalBytes/1e6>=this.options._limitMB)}addRow(t){this.limitReached()||(this.totalLength++,this.rowBytes=this.rowBytes||this._estimateRowMB(t),this.totalBytes+=this.rowBytes,Array.isArray(t)?this.addArrayRow(t):this.addObjectRow(t))}addArrayRow(t){if(!this.aggregator){let e=this._getTableBatchType();this.aggregator=new e(this.schema,this.options)}this.aggregator.addArrayRow(t)}addObjectRow(t){if(!this.aggregator){let e=this._getTableBatchType();this.aggregator=new e(this.schema,this.options)}this.aggregator.addObjectRow(t)}chunkComplete(t){t instanceof ArrayBuffer&&(this.bytesUsed+=t.byteLength),typeof t=="string"&&(this.bytesUsed+=t.length),this.isChunkComplete=!0}getFullBatch(t){return this._isFull()?this._getBatch(t):null}getFinalBatch(t){return this._getBatch(t)}_estimateRowMB(t){return Array.isArray(t)?t.length*8:Object.keys(t).length*8}_isFull(){if(!this.aggregator||this.aggregator.rowCount()===0)return!1;if(this.options.batchSize==="auto"){if(!this.isChunkComplete)return!1}else if(this.options.batchSize>this.aggregator.rowCount())return!1;return this.options.batchDebounceMs>Date.now()-this.lastBatchEmittedMs?!1:(this.isChunkComplete=!1,this.lastBatchEmittedMs=Date.now(),!0)}_getBatch(t){if(!this.aggregator)return null;t?.bytesUsed&&(this.bytesUsed=t.bytesUsed);let e=this.aggregator.getBatch();return e.count=this.batchCount,e.bytesUsed=this.bytesUsed,Object.assign(e,t),this.batchCount++,this.aggregator=null,e}_getTableBatchType(){switch(this.options.shape){case"array-row-table":case"object-row-table":return oo;case"columnar-table":return Dn;case"arrow-table":return ao;default:return so}}};La(br,"ArrowBatch");function jl(r,t){try{let e=JSON.parse(r);if(t.json?.table){let n=kl(e)||e;return Ii(n)}return e}catch{throw new Error("JSONLoader: failed to parse JSON")}}function kl(r){if(Array.isArray(r))return r;if(r&&typeof r=="object")for(let t of Object.values(r)){let e=kl(t);if(e)return e}return null}function ga(r,t){if(!r)throw new Error(t||"loader assertion failed.")}function Vl(...r){return pd(r)}function pd(r){let t=r.map(s=>s instanceof ArrayBuffer?new Uint8Array(s):s),e=t.reduce((s,o)=>s+o.byteLength,0),n=new Uint8Array(e),i=0;for(let s of t)n.set(s,i),i+=s.byteLength;return n.buffer}async function*xi(r,t={}){let e=new TextDecoder(void 0,t);for await(let n of r)yield typeof n=="string"?n:e.decode(n,{stream:!0})}async function*ba(r){let t="";for await(let e of r){t+=e;let n;for(;(n=t.indexOf(`
|
|
17
|
+
`))>=0;){let i=t.slice(0,n+1);t=t.slice(n+1),yield i}}t.length>0&&(yield t)}async function*_a(r){let t=1;for await(let e of r)yield{counter:t,line:e},t++}async function wa(r){let t=[];for await(let e of r)t.push(e);return Vl(...t)}var va=Number.MAX_SAFE_INTEGER,b;(function(r){r[r.BEGIN=0]="BEGIN",r[r.VALUE=1]="VALUE",r[r.OPEN_OBJECT=2]="OPEN_OBJECT",r[r.CLOSE_OBJECT=3]="CLOSE_OBJECT",r[r.OPEN_ARRAY=4]="OPEN_ARRAY",r[r.CLOSE_ARRAY=5]="CLOSE_ARRAY",r[r.TEXT_ESCAPE=6]="TEXT_ESCAPE",r[r.STRING=7]="STRING",r[r.BACKSLASH=8]="BACKSLASH",r[r.END=9]="END",r[r.OPEN_KEY=10]="OPEN_KEY",r[r.CLOSE_KEY=11]="CLOSE_KEY",r[r.TRUE=12]="TRUE",r[r.TRUE2=13]="TRUE2",r[r.TRUE3=14]="TRUE3",r[r.FALSE=15]="FALSE",r[r.FALSE2=16]="FALSE2",r[r.FALSE3=17]="FALSE3",r[r.FALSE4=18]="FALSE4",r[r.NULL=19]="NULL",r[r.NULL2=20]="NULL2",r[r.NULL3=21]="NULL3",r[r.NUMBER_DECIMAL_POINT=22]="NUMBER_DECIMAL_POINT",r[r.NUMBER_DIGIT=23]="NUMBER_DIGIT"})(b||(b={}));var F={tab:9,lineFeed:10,carriageReturn:13,space:32,doubleQuote:34,plus:43,comma:44,minus:45,period:46,_0:48,_9:57,colon:58,E:69,openBracket:91,backslash:92,closeBracket:93,a:97,b:98,e:101,f:102,l:108,n:110,r:114,s:115,t:116,u:117,openBrace:123,closeBrace:125},zl=/[\\"\n]/g,Wl={onready:()=>{},onopenobject:()=>{},onkey:()=>{},oncloseobject:()=>{},onopenarray:()=>{},onclosearray:()=>{},onvalue:()=>{},onerror:()=>{},onend:()=>{},onchunkparsed:()=>{}},Xr=class{options=Wl;bufferCheckPosition=va;q="";c="";p="";closed=!1;closedRoot=!1;sawRoot=!1;error=null;state=b.BEGIN;stack=[];position=0;column=0;line=1;slashed=!1;unicodeI=0;unicodeS=null;depth=0;textNode;numberNode;constructor(t={}){this.options={...Wl,...t},this.textNode=void 0,this.numberNode="",this.emit("onready")}end(){return(this.state!==b.VALUE||this.depth!==0)&&this._error("Unexpected end"),this._closeValue(),this.c="",this.closed=!0,this.emit("onend"),this}resume(){return this.error=null,this}close(){return this.write(null)}emit(t,e){this.options[t]?.(e,this)}emitNode(t,e){this._closeValue(),this.emit(t,e)}write(t){if(this.error)throw this.error;if(this.closed)return this._error("Cannot write after close. Assign an onready handler.");if(t===null)return this.end();let e=0,n=t.charCodeAt(0),i=this.p;for(;n&&(i=n,this.c=n=t.charCodeAt(e++),i!==n?this.p=i:i=this.p,!!n);)switch(this.position++,n===F.lineFeed?(this.line++,this.column=0):this.column++,this.state){case b.BEGIN:n===F.openBrace?this.state=b.OPEN_OBJECT:n===F.openBracket?this.state=b.OPEN_ARRAY:Si(n)||this._error("Non-whitespace before {[.");continue;case b.OPEN_KEY:case b.OPEN_OBJECT:if(Si(n))continue;if(this.state===b.OPEN_KEY)this.stack.push(b.CLOSE_KEY);else if(n===F.closeBrace){this.emit("onopenobject"),this.depth++,this.emit("oncloseobject"),this.depth--,this.state=this.stack.pop()||b.VALUE;continue}else this.stack.push(b.CLOSE_OBJECT);n===F.doubleQuote?this.state=b.STRING:this._error('Malformed object key should start with "');continue;case b.CLOSE_KEY:case b.CLOSE_OBJECT:if(Si(n))continue;n===F.colon?(this.state===b.CLOSE_OBJECT?(this.stack.push(b.CLOSE_OBJECT),this._closeValue("onopenobject"),this.depth++):this._closeValue("onkey"),this.state=b.VALUE):n===F.closeBrace?(this.emitNode("oncloseobject"),this.depth--,this.state=this.stack.pop()||b.VALUE):n===F.comma?(this.state===b.CLOSE_OBJECT&&this.stack.push(b.CLOSE_OBJECT),this._closeValue(),this.state=b.OPEN_KEY):this._error("Bad object");continue;case b.OPEN_ARRAY:case b.VALUE:if(Si(n))continue;if(this.state===b.OPEN_ARRAY)if(this.emit("onopenarray"),this.depth++,this.state=b.VALUE,n===F.closeBracket){this.emit("onclosearray"),this.depth--,this.state=this.stack.pop()||b.VALUE;continue}else this.stack.push(b.CLOSE_ARRAY);n===F.doubleQuote?this.state=b.STRING:n===F.openBrace?this.state=b.OPEN_OBJECT:n===F.openBracket?this.state=b.OPEN_ARRAY:n===F.t?this.state=b.TRUE:n===F.f?this.state=b.FALSE:n===F.n?this.state=b.NULL:n===F.minus?this.numberNode+="-":F._0<=n&&n<=F._9?(this.numberNode+=String.fromCharCode(n),this.state=b.NUMBER_DIGIT):this._error("Bad value");continue;case b.CLOSE_ARRAY:if(n===F.comma)this.stack.push(b.CLOSE_ARRAY),this._closeValue("onvalue"),this.state=b.VALUE;else if(n===F.closeBracket)this.emitNode("onclosearray"),this.depth--,this.state=this.stack.pop()||b.VALUE;else{if(Si(n))continue;this._error("Bad array")}continue;case b.STRING:this.textNode===void 0&&(this.textNode="");let s=e-1,o=this.slashed,a=this.unicodeI;t:for(;;){for(;a>0;)if(this.unicodeS+=String.fromCharCode(n),n=t.charCodeAt(e++),this.position++,a===4?(this.textNode+=String.fromCharCode(parseInt(this.unicodeS,16)),a=0,s=e-1):a++,!n)break t;if(n===F.doubleQuote&&!o){this.state=this.stack.pop()||b.VALUE,this.textNode+=t.substring(s,e-1),this.position+=e-1-s;break}if(n===F.backslash&&!o&&(o=!0,this.textNode+=t.substring(s,e-1),this.position+=e-1-s,n=t.charCodeAt(e++),this.position++,!n))break;if(o){if(o=!1,n===F.n?this.textNode+=`
|
|
18
|
+
`:n===F.r?this.textNode+="\r":n===F.t?this.textNode+=" ":n===F.f?this.textNode+="\f":n===F.b?this.textNode+="\b":n===F.u?(a=1,this.unicodeS=""):this.textNode+=String.fromCharCode(n),n=t.charCodeAt(e++),this.position++,s=e-1,n)continue;break}zl.lastIndex=e;let c=zl.exec(t);if(c===null){e=t.length+1,this.textNode+=t.substring(s,e-1),this.position+=e-1-s;break}if(e=c.index+1,n=t.charCodeAt(c.index),!n){this.textNode+=t.substring(s,e-1),this.position+=e-1-s;break}}this.slashed=o,this.unicodeI=a;continue;case b.TRUE:n===F.r?this.state=b.TRUE2:this._error(`Invalid true started with t${n}`);continue;case b.TRUE2:n===F.u?this.state=b.TRUE3:this._error(`Invalid true started with tr${n}`);continue;case b.TRUE3:n===F.e?(this.emit("onvalue",!0),this.state=this.stack.pop()||b.VALUE):this._error(`Invalid true started with tru${n}`);continue;case b.FALSE:n===F.a?this.state=b.FALSE2:this._error(`Invalid false started with f${n}`);continue;case b.FALSE2:n===F.l?this.state=b.FALSE3:this._error(`Invalid false started with fa${n}`);continue;case b.FALSE3:n===F.s?this.state=b.FALSE4:this._error(`Invalid false started with fal${n}`);continue;case b.FALSE4:n===F.e?(this.emit("onvalue",!1),this.state=this.stack.pop()||b.VALUE):this._error(`Invalid false started with fals${n}`);continue;case b.NULL:n===F.u?this.state=b.NULL2:this._error(`Invalid null started with n${n}`);continue;case b.NULL2:n===F.l?this.state=b.NULL3:this._error(`Invalid null started with nu${n}`);continue;case b.NULL3:n===F.l?(this.emit("onvalue",null),this.state=this.stack.pop()||b.VALUE):this._error(`Invalid null started with nul${n}`);continue;case b.NUMBER_DECIMAL_POINT:n===F.period?(this.numberNode+=".",this.state=b.NUMBER_DIGIT):this._error("Leading zero not followed by .");continue;case b.NUMBER_DIGIT:F._0<=n&&n<=F._9?this.numberNode+=String.fromCharCode(n):n===F.period?(this.numberNode.indexOf(".")!==-1&&this._error("Invalid number has two dots"),this.numberNode+="."):n===F.e||n===F.E?((this.numberNode.indexOf("e")!==-1||this.numberNode.indexOf("E")!==-1)&&this._error("Invalid number has two exponential"),this.numberNode+="e"):n===F.plus||n===F.minus?(i===F.e||i===F.E||this._error("Invalid symbol in number"),this.numberNode+=String.fromCharCode(n)):(this._closeNumber(),e--,this.state=this.stack.pop()||b.VALUE);continue;default:this._error(`Unknown state: ${this.state}`)}return this.position>=this.bufferCheckPosition&&md(this),this.emit("onchunkparsed"),this}_closeValue(t="onvalue"){this.textNode!==void 0&&this.emit(t,this.textNode),this.textNode=void 0}_closeNumber(){this.numberNode&&this.emit("onvalue",parseFloat(this.numberNode)),this.numberNode=""}_error(t=""){this._closeValue(),t+=`
|
|
10
19
|
Line: ${this.line}
|
|
11
20
|
Column: ${this.column}
|
|
12
|
-
Char: ${this.c}`;let
|
|
13
|
-
`).map((o,n)=>{try{return JSON.parse(o)}catch{throw new Error(`NDJSONLoader: failed to parse JSON on line ${n+1}`)}});return U(r)}async function*Ye(t,e){let r=D(t),o=de(r),n=me(o),s=null,a="row-table",i=new S(s,{...e,shape:a});for await(let{counter:l,line:u}of n)try{let d=JSON.parse(u);i.addRow(d),i.chunkComplete(u);let f=i.getFullBatch();f&&(yield f)}catch{throw new Error(`NDJSONLoader: failed to parse JSON on line ${l}`)}let c=i.getFinalBatch();c&&(yield c)}var Tt="4.3.1",Ke={dataType:null,batchType:null,name:"NDJSON",id:"ndjson",module:"json",version:Tt,extensions:["ndjson","jsonl"],mimeTypes:["application/x-ndjson","application/jsonlines","application/json-seq"],category:"table",text:!0,parse:async t=>xe(new TextDecoder().decode(t)),parseTextSync:xe,parseInBatches:Ye,options:{}};function we(t,e){let r=e?.json?.shape||"object-row-table",o=[],n=fe(t,r);for(let s of n)o.push(JSON.stringify(s));return`[${o.join(",")}]`}var He={id:"json",version:"latest",module:"json",name:"JSON",extensions:["json"],mimeTypes:["application/json"],options:{},text:!0,encode:async(t,e)=>new TextEncoder().encode(we(t,e)).buffer,encodeTextSync:(t,e)=>we(t,e)};var z={x:0,y:1,z:2};function k(t,e={}){let{start:r=0,end:o=t.length,plane:n="xy"}=e,s=e.size||2,a=0,i=z[n[0]],c=z[n[1]];for(let l=r,u=o-s;l<o;l+=s)a+=(t[l+i]-t[u+i])*(t[l+c]+t[u+c]),u=l;return a/2}function Ae(t,e,r=2,o,n="xy"){let s=e&&e.length,a=s?e[0]*r:t.length,i=Xe(t,0,a,r,!0,o&&o[0],n),c=[];if(!i||i.next===i.prev)return c;let l,u,d,f,y,m,w;if(s&&(i=zt(t,e,i,r,o,n)),t.length>80*r){f=u=t[0],y=d=t[1];for(let A=r;A<a;A+=r)m=t[A],w=t[A+1],m<f&&(f=m),w<y&&(y=w),m>u&&(u=m),w>d&&(d=w);l=Math.max(u-f,d-y),l=l!==0?32767/l:0}return W(i,c,r,f,y,l,0),c}function Xe(t,e,r,o,n,s,a){let i,c;s===void 0&&(s=k(t,{start:e,end:r,size:o,plane:a}));let l=z[a[0]],u=z[a[1]];if(n===s<0)for(i=e;i<r;i+=o)c=Qe(i,t[i+l],t[i+u],c);else for(i=r-o;i>=e;i-=o)c=Qe(i,t[i+l],t[i+u],c);return c&&le(c,c.next)&&($(c),c=c.next),c}function L(t,e){if(!t)return t;e||(e=t);let r=t,o;do if(o=!1,!r.steiner&&(le(r,r.next)||b(r.prev,r,r.next)===0)){if($(r),r=e=r.prev,r===r.next)break;o=!0}else r=r.next;while(o||r!==e);return e}function W(t,e,r,o,n,s,a){if(!t)return;!a&&s&&Yt(t,o,n,s);let i=t,c,l;for(;t.prev!==t.next;){if(c=t.prev,l=t.next,s?Jt(t,o,n,s):Dt(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),$(t),t=l.next,i=l.next;continue}if(t=l,t===i){a?a===1?(t=Gt(L(t),e,r),W(t,e,r,o,n,s,2)):a===2&&Mt(t,e,r,o,n,s):W(L(t),e,r,o,n,s,1);break}}}function Dt(t){let e=t.prev,r=t,o=t.next;if(b(e,r,o)>=0)return!1;let n=e.x,s=r.x,a=o.x,i=e.y,c=r.y,l=o.y,u=n<s?n<a?n:a:s<a?s:a,d=i<c?i<l?i:l:c<l?c:l,f=n>s?n>a?n:a:s>a?s:a,y=i>c?i>l?i:l:c>l?c:l,m=o.next;for(;m!==e;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=y&&R(n,i,s,c,a,l,m.x,m.y)&&b(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Jt(t,e,r,o){let n=t.prev,s=t,a=t.next;if(b(n,s,a)>=0)return!1;let i=n.x,c=s.x,l=a.x,u=n.y,d=s.y,f=a.y,y=i<c?i<l?i:l:c<l?c:l,m=u<d?u<f?u:f:d<f?d:f,w=i>c?i>l?i:l:c>l?c:l,A=u>d?u>f?u:f:d>f?d:f,F=be(y,m,e,r,o),_=be(w,A,e,r,o),x=t.prevZ,g=t.nextZ;for(;x&&x.z>=F&&g&&g.z<=_;){if(x.x>=y&&x.x<=w&&x.y>=m&&x.y<=A&&x!==n&&x!==a&&R(i,u,c,d,l,f,x.x,x.y)&&b(x.prev,x,x.next)>=0||(x=x.prevZ,g.x>=y&&g.x<=w&&g.y>=m&&g.y<=A&&g!==n&&g!==a&&R(i,u,c,d,l,f,g.x,g.y)&&b(g.prev,g,g.next)>=0))return!1;g=g.nextZ}for(;x&&x.z>=F;){if(x.x>=y&&x.x<=w&&x.y>=m&&x.y<=A&&x!==n&&x!==a&&R(i,u,c,d,l,f,x.x,x.y)&&b(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;g&&g.z<=_;){if(g.x>=y&&g.x<=w&&g.y>=m&&g.y<=A&&g!==n&&g!==a&&R(i,u,c,d,l,f,g.x,g.y)&&b(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function Gt(t,e,r){let o=t;do{let n=o.prev,s=o.next.next;!le(n,s)&&qe(n,o,o.next,s)&&V(n,s)&&V(s,n)&&(e.push(n.i/r|0),e.push(o.i/r|0),e.push(s.i/r|0),$(o),$(o.next),o=t=s),o=o.next}while(o!==t);return L(o)}function Mt(t,e,r,o,n,s){let a=t;do{let i=a.next.next;for(;i!==a.prev;){if(a.i!==i.i&&Qt(a,i)){let c=et(a,i);a=L(a,a.next),c=L(c,c.next),W(a,e,r,o,n,s,0),W(c,e,r,o,n,s,0);return}i=i.next}a=a.next}while(a!==t)}function zt(t,e,r,o,n,s){let a=[],i,c,l,u,d;for(i=0,c=e.length;i<c;i++)l=e[i]*o,u=i<c-1?e[i+1]*o:t.length,d=Xe(t,l,u,o,!1,n&&n[i+1],s),d===d.next&&(d.steiner=!0),a.push(Ht(d));for(a.sort(Wt),i=0;i<a.length;i++)r=Vt(a[i],r);return r}function Wt(t,e){return t.x-e.x}function Vt(t,e){let r=$t(t,e);if(!r)return e;let o=et(r,t);return L(o,o.next),L(r,r.next)}function $t(t,e){let r=e,o=t.x,n=t.y,s=-1/0,a;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){let f=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(f<=o&&f>s&&(s=f,a=r.x<r.next.x?r:r.next,f===o))return a}r=r.next}while(r!==e);if(!a)return null;let i=a,c=a.x,l=a.y,u=1/0,d;r=a;do o>=r.x&&r.x>=c&&o!==r.x&&R(n<l?o:s,n,c,l,n<l?s:o,n,r.x,r.y)&&(d=Math.abs(n-r.y)/(o-r.x),V(r,t)&&(d<u||d===u&&(r.x>a.x||r.x===a.x&&Zt(a,r)))&&(a=r,u=d)),r=r.next;while(r!==i);return a}function Zt(t,e){return b(t.prev,t,e.prev)<0&&b(e.next,t,t.next)<0}function Yt(t,e,r,o){let n=t;do n.z===0&&(n.z=be(n.x,n.y,e,r,o)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,Kt(n)}function Kt(t){let e,r,o=1,n,s,a,i,c,l;do{for(s=t,t=null,l=null,n=0;s;){for(n++,i=s,a=0,r=0;r<o&&(a++,i=i.nextZ,!!i);r++);for(c=o;a>0||c>0&&i;)a!==0&&(c===0||!i||s.z<=i.z)?(e=s,s=s.nextZ,a--):(e=i,i=i.nextZ,c--),l?l.nextZ=e:t=e,e.prevZ=l,l=e;s=i}l.nextZ=null,o*=2}while(n>1);return t}function be(t,e,r,o,n){return t=(t-r)*n|0,e=(e-o)*n|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function Ht(t){let e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function R(t,e,r,o,n,s,a,i){return(n-a)*(e-i)>=(t-a)*(s-i)&&(t-a)*(o-i)>=(r-a)*(e-i)&&(r-a)*(s-i)>=(n-a)*(o-i)}function Qt(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!Xt(t,e)&&(V(t,e)&&V(e,t)&&qt(t,e)&&(b(t.prev,t,e.prev)||b(t,e.prev,e))||le(t,e)&&b(t.prev,t,t.next)>0&&b(e.prev,e,e.next)>0)}function b(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function le(t,e){return t.x===e.x&&t.y===e.y}function qe(t,e,r,o){let n=ce(b(t,e,r)),s=ce(b(t,e,o)),a=ce(b(r,o,t)),i=ce(b(r,o,e));return!!(n!==s&&a!==i||n===0&&ae(t,r,e)||s===0&&ae(t,o,e)||a===0&&ae(r,t,o)||i===0&&ae(r,e,o))}function ae(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function ce(t){return t>0?1:t<0?-1:0}function Xt(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&qe(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function V(t,e){return b(t.prev,t,t.next)<0?b(t,e,t.next)>=0&&b(t,t.prev,e)>=0:b(t,e,t.prev)<0||b(t,t.next,e)<0}function qt(t,e){let r=t,o=!1,n=(t.x+e.x)/2,s=(t.y+e.y)/2;do r.y>s!=r.next.y>s&&r.next.y!==r.y&&n<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(o=!o),r=r.next;while(r!==t);return o}function et(t,e){let r=new Z(t.i,t.x,t.y),o=new Z(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,o.next=r,r.prev=o,s.next=o,o.prev=s,o}function Qe(t,e,r,o){let n=new Z(t,e,r);return o?(n.next=o.next,n.prev=o,o.next.prev=n,o.next=n):(n.prev=n,n.next=n),n}function $(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}var Z=class{constructor(e,r,o){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=e,this.x=r,this.y=o}};function ot(t,e,r){let o=nr(t),n=Object.keys(o).filter(s=>o[s]!==Array);return sr(t,{propArrayTypes:o,...e},{numericPropKeys:r&&r.numericPropKeys||n,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function nr(t){let e={};for(let r of t)if(r.properties)for(let o in r.properties){let n=r.properties[o];e[o]=hr(n,e[o])}return e}function sr(t,e,r){let{pointPositionsCount:o,pointFeaturesCount:n,linePositionsCount:s,linePathsCount:a,lineFeaturesCount:i,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:u,polygonFeaturesCount:d,propArrayTypes:f,coordLength:y}=e,{numericPropKeys:m=[],PositionDataType:w=Float32Array,triangulate:A=!0}=r,F=t[0]&&"id"in t[0],_=t.length>65535?Uint32Array:Uint16Array,x={type:"Point",positions:new w(o*y),globalFeatureIds:new _(o),featureIds:n>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:[],fields:[]},g={type:"LineString",pathIndices:s>65535?new Uint32Array(a+1):new Uint16Array(a+1),positions:new w(s*y),globalFeatureIds:new _(s),featureIds:i>65535?new Uint32Array(s):new Uint16Array(s),numericProps:{},properties:[],fields:[]},j={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(u+1):new Uint16Array(u+1),positions:new w(c*y),globalFeatureIds:new _(c),featureIds:d>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};A&&(j.triangles=[]);for(let N of[x,g,j])for(let E of m){let O=f[E];N.numericProps[E]=new O(N.positions.length/y)}g.pathIndices[a]=s,j.polygonIndices[l]=c,j.primitivePolygonIndices[u]=c;let B={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let N of t){let E=N.geometry,O=N.properties||{};switch(E.type){case"Point":ir(E,x,B,y,O),x.properties.push(je(O,m)),F&&x.fields.push({id:N.id}),B.pointFeature++;break;case"LineString":ar(E,g,B,y,O),g.properties.push(je(O,m)),F&&g.fields.push({id:N.id}),B.lineFeature++;break;case"Polygon":cr(E,j,B,y,O),j.properties.push(je(O,m)),F&&j.fields.push({id:N.id}),B.polygonFeature++;break;default:throw new Error("Invalid geometry type")}B.feature++}return ur(x,g,j,y)}function ir(t,e,r,o,n){e.positions.set(t.data,r.pointPosition*o);let s=t.data.length/o;Ne(e,n,r.pointPosition,s),e.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+s),e.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+s),r.pointPosition+=s}function ar(t,e,r,o,n){e.positions.set(t.data,r.linePosition*o);let s=t.data.length/o;Ne(e,n,r.linePosition,s),e.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+s),e.featureIds.fill(r.lineFeature,r.linePosition,r.linePosition+s);for(let a=0,i=t.indices.length;a<i;++a){let c=t.indices[a],l=a===i-1?t.data.length:t.indices[a+1];e.pathIndices[r.linePath++]=r.linePosition,r.linePosition+=(l-c)/o}}function cr(t,e,r,o,n){e.positions.set(t.data,r.polygonPosition*o);let s=t.data.length/o;Ne(e,n,r.polygonPosition,s),e.globalFeatureIds.fill(r.feature,r.polygonPosition,r.polygonPosition+s),e.featureIds.fill(r.polygonFeature,r.polygonPosition,r.polygonPosition+s);for(let a=0,i=t.indices.length;a<i;++a){let c=r.polygonPosition;e.polygonIndices[r.polygonObject++]=c;let l=t.areas[a],u=t.indices[a],d=t.indices[a+1];for(let y=0,m=u.length;y<m;++y){let w=u[y],A=y===m-1?d===void 0?t.data.length:d[0]:u[y+1];e.primitivePolygonIndices[r.polygonRing++]=r.polygonPosition,r.polygonPosition+=(A-w)/o}let f=r.polygonPosition;lr(e,l,u,{startPosition:c,endPosition:f,coordLength:o})}}function lr(t,e,r,{startPosition:o,endPosition:n,coordLength:s}){if(!t.triangles)return;let a=o*s,i=n*s,c=t.positions.subarray(a,i),l=r[0],u=r.slice(1).map(f=>(f-l)/s),d=Ae(c,u,s,e);for(let f=0,y=d.length;f<y;++f)t.triangles.push(o+d[f])}function Pe(t,e){let r={};for(let o in t)r[o]={value:t[o],size:e};return r}function ur(t,e,r,o){let n={shape:"binary-feature-collection",points:{...t,positions:{value:t.positions,size:o},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:Pe(t.numericProps,1)},lines:{...e,positions:{value:e.positions,size:o},pathIndices:{value:e.pathIndices,size:1},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:Pe(e.numericProps,1)},polygons:{...r,positions:{value:r.positions,size:o},polygonIndices:{value:r.polygonIndices,size:1},primitivePolygonIndices:{value:r.primitivePolygonIndices,size:1},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:Pe(r.numericProps,1)}};return n.polygons&&r.triangles&&(n.polygons.triangles={value:new Uint32Array(r.triangles),size:1}),n}function Ne(t,e,r,o){for(let n in t.numericProps)if(n in e){let s=e[n];t.numericProps[n].fill(s,r,r+o)}}function je(t,e){let r={};for(let o in t)e.includes(o)||(r[o]=t[o]);return r}function hr(t,e){return e===Array||!Number.isFinite(t)?Array:e===Float64Array||Math.fround(t)!==t?Float64Array:Float32Array}function nt(t){let e=0,r=0,o=0,n=0,s=0,a=0,i=0,c=0,l=0,u=new Set;for(let d of t){let f=d.geometry;switch(f.type){case"Point":r++,e++,u.add(f.coordinates.length);break;case"MultiPoint":r++,e+=f.coordinates.length;for(let m of f.coordinates)u.add(m.length);break;case"LineString":s++,o+=f.coordinates.length,n++;for(let m of f.coordinates)u.add(m.length);break;case"MultiLineString":s++;for(let m of f.coordinates){o+=m.length,n++;for(let w of m)u.add(w.length)}break;case"Polygon":l++,i++,c+=f.coordinates.length;let y=f.coordinates.flat();a+=y.length;for(let m of y)u.add(m.length);break;case"MultiPolygon":l++;for(let m of f.coordinates){i++,c+=m.length;let w=m.flat();a+=w.length;for(let A of w)u.add(A.length)}break;default:throw new Error(`Unsupported geometry type: ${f.type}`)}}return{coordLength:u.size>0?Math.max(...u):2,pointPositionsCount:e,pointFeaturesCount:r,linePositionsCount:o,linePathsCount:n,lineFeaturesCount:s,polygonPositionsCount:a,polygonObjectsCount:i,polygonRingsCount:c,polygonFeaturesCount:l}}function at(t,e={coordLength:2,fixRingWinding:!0}){return t.map(r=>fr(r,e))}function st(t,e,r,o){r.push(e.length),e.push(...t);for(let n=t.length;n<o.coordLength;n++)e.push(0)}function Oe(t,e,r,o){r.push(e.length);for(let n of t){e.push(...n);for(let s=n.length;s<o.coordLength;s++)e.push(0)}}function it(t,e,r,o,n){let s=0,a=[],i=[];for(let c of t){let l=c.map(f=>f.slice(0,2)),u=k(l.flat()),d=u<0;n.fixRingWinding&&(s===0&&!d||s>0&&d)&&(c.reverse(),u=-u),a.push(u),Oe(c,e,i,n),s++}s>0&&(o.push(a),r.push(i))}function fr(t,e){let{geometry:r}=t;if(r.type==="GeometryCollection")throw new Error("GeometryCollection type not supported");let o=[],n=[],s,a;switch(r.type){case"Point":a="Point",st(r.coordinates,o,n,e);break;case"MultiPoint":a="Point",r.coordinates.map(i=>st(i,o,n,e));break;case"LineString":a="LineString",Oe(r.coordinates,o,n,e);break;case"MultiLineString":a="LineString",r.coordinates.map(i=>Oe(i,o,n,e));break;case"Polygon":a="Polygon",s=[],it(r.coordinates,o,n,s,e);break;case"MultiPolygon":a="Polygon",s=[],r.coordinates.map(i=>it(i,o,n,s,e));break;default:throw new Error(`Unknown type: ${a}`)}return{...t,geometry:{type:a,indices:n,data:o,areas:s}}}function ue(t,e={fixRingWinding:!0,triangulate:!0}){let r=nt(t),o=r.coordLength,{fixRingWinding:n}=e,s=at(t,{coordLength:o,fixRingWinding:n});return ot(s,r,{numericPropKeys:e.numericPropKeys,PositionDataType:e.PositionDataType||Float32Array,triangulate:e.triangulate})}var pr="4.3.1",Se={dataType:null,batchType:null,name:"GeoJSON",id:"geojson",module:"geojson",version:pr,worker:!0,extensions:["geojson"],mimeTypes:["application/geo+json"],category:"geometry",text:!0,options:{geojson:{shape:"geojson-table"},json:{shape:"object-row-table",jsonpaths:["$","$.features"]},gis:{format:"geojson"}}},T={...Se,parse:dr,parseTextSync:ct,parseInBatches:mr};async function dr(t,e){return ct(new TextDecoder().decode(t),e)}function ct(t,e){e={...T.options,...e},e.geojson={...T.options.geojson,...e.geojson},e.gis=e.gis||{};let r;try{r=JSON.parse(t)}catch{r={}}let o={shape:"geojson-table",type:"FeatureCollection",features:r?.features||[]};switch(e.gis.format){case"binary":return ue(o.features);default:return o}}function mr(t,e){e={...T.options,...e},e.json={...T.options.geojson,...e.geojson};let r=se(t,e);switch(e.gis.format){case"binary":return yr(r);default:return r}}async function*yr(t){for await(let e of t)e.data=ue(e.data),yield e}function lt(t){let e=t.schema?.fields.findIndex(r=>r.name==="geometry")??-1;if(e>-1)return e;if(I(t)>0){let r=ne(t,0);for(let o=0;o<re(t);o++){let n=r?.[o];if(n&&typeof n=="object")return o}}throw new Error("Failed to detect geometry column")}function ut(t,e,r=[]){let o={};for(let n=0;n<re(t);++n){let s=t.schema?.fields[n].name;s&&!r.includes(n)&&(o[s]=e[s])}return o}function ht(t,e,r,o){let n=oe(t,e);if(!n)return;let s=gr(t,n,r),a=JSON.stringify(s);o.push(a)}function gr(t,e,r){let o=ut(t,e,[r]),n=t.schema?.fields[r].name,s=n&&e[n];if(!s)return{type:"Feature",geometry:null,properties:o};if(typeof s=="string")try{s=JSON.parse(s)}catch{throw new Error("Invalid string geometry")}if(typeof s!="object"||typeof s?.type!="string")throw new Error("invalid geometry column value");return s?.type==="Feature"?{...s,properties:o}:{type:"Feature",geometry:s,properties:o}}var he=class{chunkSize;strings=[];totalLength=0;textEncoder=new TextEncoder;constructor(e){this.chunkSize=e}push(...e){for(let r of e)this.strings.push(r),this.totalLength+=r.length}isFull(){return this.totalLength>=this.chunkSize}getArrayBufferBatch(){return this.textEncoder.encode(this.getStringBatch()).buffer}getStringBatch(){let e=this.strings.join("");return this.strings=[],this.totalLength=0,e}};async function*Ie(t,e={}){let r={geojson:{},chunkSize:1e4,...e},o=new he(r.chunkSize);r.geojson.featureArray||o.push(`{
|
|
21
|
+
Char: ${this.c}`;let e=new Error(t);this.error=e,this.emit("onerror",e)}};function Si(r){return r===F.carriageReturn||r===F.lineFeed||r===F.space||r===F.tab}function md(r){let t=Math.max(va,10),e=0;for(let n of["textNode","numberNode"]){let i=r[n]===void 0?0:r[n].length;if(i>t)switch(n){case"text":break;default:r._error(`Max buffer length exceeded: ${n}`)}e=Math.max(e,i)}r.bufferCheckPosition=va-e+r.position}var Dt=class{path;constructor(t=null){if(this.path=["$"],t instanceof Dt){this.path=[...t.path];return}if(Array.isArray(t)){this.path.push(...t);return}if(typeof t=="string"&&(this.path=t.split("."),this.path[0]!=="$"))throw new Error("JSONPaths must start with $")}clone(){return new Dt(this)}toString(){return this.path.join(".")}push(t){this.path.push(t)}pop(){return this.path.pop()}set(t){this.path[this.path.length-1]=t}equals(t){if(!this||!t||this.path.length!==t.path.length)return!1;for(let e=0;e<this.path.length;++e)if(this.path[e]!==t.path[e])return!1;return!0}setFieldAtPath(t,e){let n=[...this.path];n.shift();let i=n.pop();for(let s of n)t=t[s];t[i]=e}getFieldAtPath(t){let e=[...this.path];e.shift();let n=e.pop();for(let i of e)t=t[i];return t[n]}};var Bi=class{parser;result=void 0;previousStates=[];currentState=Object.freeze({container:[],key:null});jsonpath=new Dt;constructor(t){this.reset(),this.parser=new Xr({onready:()=>{this.jsonpath=new Dt,this.previousStates.length=0,this.currentState.container.length=0},onopenobject:e=>{this._openObject({}),typeof e<"u"&&this.parser.emit("onkey",e)},onkey:e=>{this.jsonpath.set(e),this.currentState.key=e},oncloseobject:()=>{this._closeObject()},onopenarray:()=>{this._openArray()},onclosearray:()=>{this._closeArray()},onvalue:e=>{this._pushOrSet(e)},onerror:e=>{throw e},onend:()=>{this.result=this.currentState.container.pop()},...t})}reset(){this.result=void 0,this.previousStates=[],this.currentState=Object.freeze({container:[],key:null}),this.jsonpath=new Dt}write(t){this.parser.write(t)}close(){this.parser.close()}_pushOrSet(t){let{container:e,key:n}=this.currentState;n!==null?(e[n]=t,this.currentState.key=null):e.push(t)}_openArray(t=[]){this.jsonpath.push(null),this._pushOrSet(t),this.previousStates.push(this.currentState),this.currentState={container:t,isArray:!0,key:null}}_closeArray(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}_openObject(t={}){this.jsonpath.push(null),this._pushOrSet(t),this.previousStates.push(this.currentState),this.currentState={container:t,isArray:!1,key:null}}_closeObject(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}};var Ai=class extends Bi{jsonPaths;streamingJsonPath=null;streamingArray=null;topLevelObject=null;constructor(t={}){super({onopenarray:()=>{if(!this.streamingArray&&this._matchJSONPath()){this.streamingJsonPath=this.getJsonPath().clone(),this.streamingArray=[],this._openArray(this.streamingArray);return}this._openArray()},onopenobject:n=>{this.topLevelObject?this._openObject({}):(this.topLevelObject={},this._openObject(this.topLevelObject)),typeof n<"u"&&this.parser.emit("onkey",n)}});let e=t.jsonpaths||[];this.jsonPaths=e.map(n=>new Dt(n))}write(t){super.write(t);let e=[];return this.streamingArray&&(e=[...this.streamingArray],this.streamingArray.length=0),e}getPartialResult(){return this.topLevelObject}getStreamingJsonPath(){return this.streamingJsonPath}getStreamingJsonPathAsString(){return this.streamingJsonPath&&this.streamingJsonPath.toString()}getJsonPath(){return this.jsonpath}_matchJSONPath(){let t=this.getJsonPath();if(this.jsonPaths.length===0)return!0;for(let e of this.jsonPaths)if(e.equals(t))return!0;return!1}};async function*co(r,t){let e=xi(r),{metadata:n}=t,{jsonpaths:i}=t.json||{},s=!0,o=null,a=new br(o,t),c=new Ai({jsonpaths:i});for await(let f of e){let d=c.write(f),p=d.length>0&&c.getStreamingJsonPathAsString();d.length>0&&s&&(n&&(yield{shape:t?.json?.shape||"array-row-table",batchType:"partial-result",data:[],length:0,bytesUsed:0,container:c.getPartialResult(),jsonpath:p}),s=!1);for(let G of d){a.addRow(G);let nt=a.getFullBatch({jsonpath:p});nt&&(yield nt)}a.chunkComplete(f);let g=a.getFullBatch({jsonpath:p});g&&(yield g)}let l=c.getStreamingJsonPathAsString(),u=a.getFinalBatch({jsonpath:l});u&&(yield u),n&&(yield{shape:"json",batchType:"final-result",container:c.getPartialResult(),jsonpath:c.getStreamingJsonPathAsString(),data:[],length:0})}function Gl(r,t){if(ga(r.batchType==="final-result"),r.jsonpath==="$")return t;if(r.jsonpath&&r.jsonpath.length>1){let e=r.container;return new Dt(r.jsonpath).setFieldAtPath(e,t),e}return r.container}var yd="4.4.0-alpha.1",lo={dataType:null,batchType:null,name:"JSON",id:"json",module:"json",version:yd,extensions:["json","geojson"],mimeTypes:["application/json"],category:"table",text:!0,options:{json:{shape:void 0,table:!1,jsonpaths:[]}},parse:gd,parseTextSync:Jl,parseInBatches:bd};async function gd(r,t){return Jl(new TextDecoder().decode(r),t)}function Jl(r,t){let e={...t,json:{...lo.options.json,...t?.json}};return jl(r,e)}function bd(r,t){let e={...t,json:{...lo.options.json,...t?.json}};return co(r,e)}function Ia(r){let e=r.trim().split(`
|
|
22
|
+
`).map((n,i)=>{try{return JSON.parse(n)}catch{throw new Error(`NDJSONLoader: failed to parse JSON on line ${i+1}`)}});return Ii(e)}async function*$l(r,t){let e=xi(r),n=ba(e),i=_a(n),s=null,o="row-table",a=new br(s,{...t,shape:o});for await(let{counter:l,line:u}of i)try{let f=JSON.parse(u);a.addRow(f),a.chunkComplete(u);let d=a.getFullBatch();d&&(yield d)}catch{throw new Error(`NDJSONLoader: failed to parse JSON on line ${l}`)}let c=a.getFinalBatch();c&&(yield c)}var _d="4.4.0-alpha.1",Hl={dataType:null,batchType:null,name:"NDJSON",id:"ndjson",module:"json",version:_d,extensions:["ndjson","jsonl"],mimeTypes:["application/x-ndjson","application/jsonlines","application/json-seq"],category:"table",text:!0,parse:async r=>Ia(new TextDecoder().decode(r)),parseTextSync:Ia,parseInBatches:$l,options:{}};function xa(r,t){let e=t?.json?.shape||"object-row-table",n=[],i=ma(r,e);for(let s of i)n.push(JSON.stringify(s));return`[${n.join(",")}]`}var Yl={id:"json",version:"latest",module:"json",name:"JSON",extensions:["json"],mimeTypes:["application/json"],options:{},text:!0,encode:async(r,t)=>new TextEncoder().encode(xa(r,t)).buffer,encodeTextSync:(r,t)=>xa(r,t)};function Zl(r){let t=0,e=0,n=0,i=0,s=0,o=0,a=0,c=0,l=0,u=new Set;for(let f of r){let d=f.geometry;switch(d.type){case"Point":e++,t++,u.add(d.coordinates.length);break;case"MultiPoint":e++,t+=d.coordinates.length;for(let g of d.coordinates)u.add(g.length);break;case"LineString":s++,n+=d.coordinates.length,i++;for(let g of d.coordinates)u.add(g.length);break;case"MultiLineString":s++;for(let g of d.coordinates){n+=g.length,i++;for(let G of g)u.add(G.length)}break;case"Polygon":l++,a++,c+=d.coordinates.length;let p=d.coordinates.flat();o+=p.length;for(let g of p)u.add(g.length);break;case"MultiPolygon":l++;for(let g of d.coordinates){a++,c+=g.length;let G=g.flat();o+=G.length;for(let nt of G)u.add(nt.length)}break;default:throw new Error(`Unsupported geometry type: ${d.type}`)}}return{coordLength:u.size>0?Math.max(...u):2,pointPositionsCount:t,pointFeaturesCount:e,linePositionsCount:n,linePathsCount:i,lineFeaturesCount:s,polygonPositionsCount:o,polygonObjectsCount:a,polygonRingsCount:c,polygonFeaturesCount:l}}var Oi={x:0,y:1,z:2};function Fn(r,t={}){let{start:e=0,end:n=r.length,plane:i="xy"}=t,s=t.size||2,o=0,a=Oi[i[0]],c=Oi[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 Ba(r,t,e=2,n,i="xy"){let s=t&&t.length,o=s?t[0]*e:r.length,a=Xl(r,0,o,e,!0,n&&n[0],i),c=[];if(!a||a.next===a.prev)return c;let l,u,f,d,p,g,G;if(s&&(a=Ad(r,t,a,e,n,i)),r.length>80*e){d=u=r[0],p=f=r[1];for(let nt=e;nt<o;nt+=e)g=r[nt],G=r[nt+1],g<d&&(d=g),G<p&&(p=G),g>u&&(u=g),G>f&&(f=G);l=Math.max(u-d,f-p),l=l!==0?32767/l:0}return Di(a,c,e,d,p,l,0),c}function Xl(r,t,e,n,i,s,o){let a,c;s===void 0&&(s=Fn(r,{start:t,end:e,size:n,plane:o}));let l=Oi[o[0]],u=Oi[o[1]];if(i===s<0)for(a=t;a<e;a+=n)c=Kl(a,r[a+l],r[a+u],c);else for(a=e-n;a>=t;a-=n)c=Kl(a,r[a+l],r[a+u],c);return c&&fo(c,c.next)&&(Ti(c),c=c.next),c}function qr(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(fo(e,e.next)||ot(e.prev,e,e.next)===0)){if(Ti(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Di(r,t,e,n,i,s,o){if(!r)return;!o&&s&&Nd(r,n,i,s);let a=r,c,l;for(;r.prev!==r.next;){if(c=r.prev,l=r.next,s?xd(r,n,i,s):Id(r)){t.push(c.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),Ti(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=Sd(qr(r),t,e),Di(r,t,e,n,i,s,2)):o===2&&Bd(r,t,e,n,i,s):Di(qr(r),t,e,n,i,s,1);break}}}function Id(r){let t=r.prev,e=r,n=r.next;if(ot(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,f=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,g=n.next;for(;g!==t;){if(g.x>=u&&g.x<=d&&g.y>=f&&g.y<=p&&Tn(i,a,s,c,o,l,g.x,g.y)&&ot(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function xd(r,t,e,n){let i=r.prev,s=r,o=r.next;if(ot(i,s,o)>=0)return!1;let a=i.x,c=s.x,l=o.x,u=i.y,f=s.y,d=o.y,p=a<c?a<l?a:l:c<l?c:l,g=u<f?u<d?u:d:f<d?f:d,G=a>c?a>l?a:l:c>l?c:l,nt=u>f?u>d?u:d:f>d?f:d,Ft=Sa(p,g,t,e,n),or=Sa(G,nt,t,e,n),z=r.prevZ,V=r.nextZ;for(;z&&z.z>=Ft&&V&&V.z<=or;){if(z.x>=p&&z.x<=G&&z.y>=g&&z.y<=nt&&z!==i&&z!==o&&Tn(a,u,c,f,l,d,z.x,z.y)&&ot(z.prev,z,z.next)>=0||(z=z.prevZ,V.x>=p&&V.x<=G&&V.y>=g&&V.y<=nt&&V!==i&&V!==o&&Tn(a,u,c,f,l,d,V.x,V.y)&&ot(V.prev,V,V.next)>=0))return!1;V=V.nextZ}for(;z&&z.z>=Ft;){if(z.x>=p&&z.x<=G&&z.y>=g&&z.y<=nt&&z!==i&&z!==o&&Tn(a,u,c,f,l,d,z.x,z.y)&&ot(z.prev,z,z.next)>=0)return!1;z=z.prevZ}for(;V&&V.z<=or;){if(V.x>=p&&V.x<=G&&V.y>=g&&V.y<=nt&&V!==i&&V!==o&&Tn(a,u,c,f,l,d,V.x,V.y)&&ot(V.prev,V,V.next)>=0)return!1;V=V.nextZ}return!0}function Sd(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!fo(i,s)&&ql(i,n,n.next,s)&&Fi(i,s)&&Fi(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Ti(n),Ti(n.next),n=r=s),n=n.next}while(n!==r);return qr(n)}function Bd(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Md(o,a)){let c=Ql(o,a);o=qr(o,o.next),c=qr(c,c.next),Di(o,t,e,n,i,s,0),Di(c,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function Ad(r,t,e,n,i,s){let o=[],a,c,l,u,f;for(a=0,c=t.length;a<c;a++)l=t[a]*n,u=a<c-1?t[a+1]*n:r.length,f=Xl(r,l,u,n,!1,i&&i[a+1],s),f===f.next&&(f.steiner=!0),o.push(Ud(f));for(o.sort(Od),a=0;a<o.length;a++)e=Dd(o[a],e);return e}function Od(r,t){return r.x-t.x}function Dd(r,t){let e=Fd(r,t);if(!e)return t;let n=Ql(e,r);return qr(n,n.next),qr(e,e.next)}function Fd(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,f;e=o;do n>=e.x&&e.x>=c&&n!==e.x&&Tn(i<l?n:s,i,c,l,i<l?s:n,i,e.x,e.y)&&(f=Math.abs(i-e.y)/(n-e.x),Fi(e,r)&&(f<u||f===u&&(e.x>o.x||e.x===o.x&&Td(o,e)))&&(o=e,u=f)),e=e.next;while(e!==a);return o}function Td(r,t){return ot(r.prev,r,t.prev)<0&&ot(t.next,r,r.next)<0}function Nd(r,t,e,n){let i=r;do i.z===0&&(i.z=Sa(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,Ld(i)}function Ld(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 Sa(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 Ud(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 Tn(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 Md(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Ed(r,t)&&(Fi(r,t)&&Fi(t,r)&&Cd(r,t)&&(ot(r.prev,r,t.prev)||ot(r,t.prev,t))||fo(r,t)&&ot(r.prev,r,r.next)>0&&ot(t.prev,t,t.next)>0)}function ot(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function fo(r,t){return r.x===t.x&&r.y===t.y}function ql(r,t,e,n){let i=ho(ot(r,t,e)),s=ho(ot(r,t,n)),o=ho(ot(e,n,r)),a=ho(ot(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 ho(r){return r>0?1:r<0?-1:0}function Ed(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&&ql(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Fi(r,t){return ot(r.prev,r,r.next)<0?ot(r,t,r.next)>=0&&ot(r,r.prev,t)>=0:ot(r,t,r.prev)<0||ot(r,r.next,t)<0}function Cd(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 Ql(r,t){let e=new Ni(r.i,r.x,r.y),n=new Ni(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 Kl(r,t,e,n){let i=new Ni(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 Ti(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 Ni=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 ru(r,t,e){let n=Vd(r),i=Object.keys(n).filter(s=>n[s]!==Array);return zd(r,{propArrayTypes:n,...t},{numericPropKeys:e&&e.numericPropKeys||i,PositionDataType:e?e.PositionDataType:Float32Array,triangulate:e?e.triangulate:!0})}function Vd(r){let t={};for(let e of r)if(e.properties)for(let n in e.properties){let i=e.properties[n];t[n]=Yd(i,t[n])}return t}function zd(r,t,e){let{pointPositionsCount:n,pointFeaturesCount:i,linePositionsCount:s,linePathsCount:o,lineFeaturesCount:a,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:u,polygonFeaturesCount:f,propArrayTypes:d,coordLength:p}=t,{numericPropKeys:g=[],PositionDataType:G=Float32Array,triangulate:nt=!0}=e,Ft=r[0]&&"id"in r[0],or=r.length>65535?Uint32Array:Uint16Array,z={type:"Point",positions:new G(n*p),globalFeatureIds:new or(n),featureIds:i>65535?new Uint32Array(n):new Uint16Array(n),numericProps:{},properties:[],fields:[]},V={type:"LineString",pathIndices:s>65535?new Uint32Array(o+1):new Uint16Array(o+1),positions:new G(s*p),globalFeatureIds:new or(s),featureIds:a>65535?new Uint32Array(s):new Uint16Array(s),numericProps:{},properties:[],fields:[]},ar={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(u+1):new Uint16Array(u+1),positions:new G(c*p),globalFeatureIds:new or(c),featureIds:f>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};nt&&(ar.triangles=[]);for(let cr of[z,V,ar])for(let wr of g){let lr=d[wr];cr.numericProps[wr]=new lr(cr.positions.length/p)}V.pathIndices[o]=s,ar.polygonIndices[l]=c,ar.primitivePolygonIndices[u]=c;let _r={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let cr of r){let wr=cr.geometry,lr=cr.properties||{};switch(wr.type){case"Point":Wd(wr,z,_r,p,lr),z.properties.push(Oa(lr,g)),Ft&&z.fields.push({id:cr.id}),_r.pointFeature++;break;case"LineString":Gd(wr,V,_r,p,lr),V.properties.push(Oa(lr,g)),Ft&&V.fields.push({id:cr.id}),_r.lineFeature++;break;case"Polygon":Jd(wr,ar,_r,p,lr),ar.properties.push(Oa(lr,g)),Ft&&ar.fields.push({id:cr.id}),_r.polygonFeature++;break;default:throw new Error("Invalid geometry type")}_r.feature++}return Hd(z,V,ar,p)}function Wd(r,t,e,n,i){t.positions.set(r.data,e.pointPosition*n);let s=r.data.length/n;Da(t,i,e.pointPosition,s),t.globalFeatureIds.fill(e.feature,e.pointPosition,e.pointPosition+s),t.featureIds.fill(e.pointFeature,e.pointPosition,e.pointPosition+s),e.pointPosition+=s}function Gd(r,t,e,n,i){t.positions.set(r.data,e.linePosition*n);let s=r.data.length/n;Da(t,i,e.linePosition,s),t.globalFeatureIds.fill(e.feature,e.linePosition,e.linePosition+s),t.featureIds.fill(e.lineFeature,e.linePosition,e.linePosition+s);for(let o=0,a=r.indices.length;o<a;++o){let c=r.indices[o],l=o===a-1?r.data.length:r.indices[o+1];t.pathIndices[e.linePath++]=e.linePosition,e.linePosition+=(l-c)/n}}function Jd(r,t,e,n,i){t.positions.set(r.data,e.polygonPosition*n);let s=r.data.length/n;Da(t,i,e.polygonPosition,s),t.globalFeatureIds.fill(e.feature,e.polygonPosition,e.polygonPosition+s),t.featureIds.fill(e.polygonFeature,e.polygonPosition,e.polygonPosition+s);for(let o=0,a=r.indices.length;o<a;++o){let c=e.polygonPosition;t.polygonIndices[e.polygonObject++]=c;let l=r.areas[o],u=r.indices[o],f=r.indices[o+1];for(let p=0,g=u.length;p<g;++p){let G=u[p],nt=p===g-1?f===void 0?r.data.length:f[0]:u[p+1];t.primitivePolygonIndices[e.polygonRing++]=e.polygonPosition,e.polygonPosition+=(nt-G)/n}let d=e.polygonPosition;$d(t,l,u,{startPosition:c,endPosition:d,coordLength:n})}}function $d(r,t,e,{startPosition:n,endPosition:i,coordLength:s}){if(!r.triangles)return;let o=n*s,a=i*s,c=r.positions.subarray(o,a),l=e[0],u=e.slice(1).map(d=>(d-l)/s),f=Ba(c,u,s,t);for(let d=0,p=f.length;d<p;++d)r.triangles.push(n+f[d])}function Aa(r,t){let e={};for(let n in r)e[n]={value:r[n],size:t};return e}function Hd(r,t,e,n){let i={shape:"binary-feature-collection",points:{...r,positions:{value:r.positions,size:n},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:Aa(r.numericProps,1)},lines:{...t,positions:{value:t.positions,size:n},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:Aa(t.numericProps,1)},polygons:{...e,positions:{value:e.positions,size:n},polygonIndices:{value:e.polygonIndices,size:1},primitivePolygonIndices:{value:e.primitivePolygonIndices,size:1},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:Aa(e.numericProps,1)}};return i.polygons&&e.triangles&&(i.polygons.triangles={value:new Uint32Array(e.triangles),size:1}),i}function Da(r,t,e,n){for(let i in r.numericProps)if(i in t){let s=t[i];r.numericProps[i].fill(s,e,e+n)}}function Oa(r,t){let e={};for(let n in r)t.includes(n)||(e[n]=r[n]);return e}function Yd(r,t){return t===Array||!Number.isFinite(r)?Array:t===Float64Array||Math.fround(r)!==r?Float64Array:Float32Array}function su(r,t={coordLength:2,fixRingWinding:!0}){return r.map(e=>Zd(e,t))}function nu(r,t,e,n){e.push(t.length),t.push(...r);for(let i=r.length;i<n.coordLength;i++)t.push(0)}function Fa(r,t,e,n){e.push(t.length);for(let i of r){t.push(...i);for(let s=i.length;s<n.coordLength;s++)t.push(0)}}function iu(r,t,e,n,i){let s=0,o=[],a=[];for(let c of r){let l=c.map(d=>d.slice(0,2)),u=Fn(l.flat()),f=u<0;i.fixRingWinding&&(s===0&&!f||s>0&&f)&&(c.reverse(),u=-u),o.push(u),Fa(c,t,a,i),s++}s>0&&(n.push(o),e.push(a))}function Zd(r,t){let{geometry:e}=r;if(e.type==="GeometryCollection")throw new Error("GeometryCollection type not supported");let n=[],i=[],s,o;switch(e.type){case"Point":o="Point",nu(e.coordinates,n,i,t);break;case"MultiPoint":o="Point",e.coordinates.map(a=>nu(a,n,i,t));break;case"LineString":o="LineString",Fa(e.coordinates,n,i,t);break;case"MultiLineString":o="LineString",e.coordinates.map(a=>Fa(a,n,i,t));break;case"Polygon":o="Polygon",s=[],iu(e.coordinates,n,i,s,t);break;case"MultiPolygon":o="Polygon",s=[],e.coordinates.map(a=>iu(a,n,i,s,t));break;default:throw new Error(`Unknown type: ${o}`)}return{...r,geometry:{type:o,indices:i,data:n,areas:s}}}function Li(r,t={fixRingWinding:!0,triangulate:!0}){let e=Zl(r),n=e.coordLength,{fixRingWinding:i}=t,s=su(r,{coordLength:n,fixRingWinding:i});return ru(s,e,{numericPropKeys:t.numericPropKeys,PositionDataType:t.PositionDataType||Float32Array,triangulate:t.triangulate})}var Kd="4.4.0-alpha.1",Ta={dataType:null,batchType:null,name:"GeoJSON",id:"geojson",module:"geojson",version:Kd,worker:!0,extensions:["geojson"],mimeTypes:["application/geo+json"],category:"geometry",text:!0,options:{geojson:{shape:"geojson-table"},json:{shape:"object-row-table",jsonpaths:["$","$.features"]},gis:{format:"geojson"}}},Nn={...Ta,parse:Xd,parseTextSync:ou,parseInBatches:qd};async function Xd(r,t){return ou(new TextDecoder().decode(r),t)}function ou(r,t){t={...Nn.options,...t},t.geojson={...Nn.options.geojson,...t.geojson},t.gis=t.gis||{};let e;try{e=JSON.parse(r)}catch{e={}}let n={shape:"geojson-table",type:"FeatureCollection",features:e?.features||[]};switch(t.gis.format){case"binary":return Li(n.features);default:return n}}function qd(r,t){t={...Nn.options,...t},t.json={...Nn.options.geojson,...t.geojson};let e=co(r,t);switch(t.gis.format){case"binary":return Qd(e);default:return e}}async function*Qd(r){for await(let t of r)t.data=Li(t.data),yield t}function au(r){let t=r.schema?.fields.findIndex(e=>e.name==="geometry")??-1;if(t>-1)return t;if(gr(r)>0){let e=io(r,0);for(let n=0;n<ro(r);n++){let i=e?.[n];if(i&&typeof i=="object")return n}}throw new Error("Failed to detect geometry column")}function cu(r,t,e=[]){let n={};for(let i=0;i<ro(r);++i){let s=r.schema?.fields[i].name;s&&!e.includes(i)&&(n[s]=t[s])}return n}function lu(r,t,e,n){let i=no(r,t);if(!i)return;let s=tp(r,i,e),o=JSON.stringify(s);n.push(o)}function tp(r,t,e){let n=cu(r,t,[e]),i=r.schema?.fields[e].name,s=i&&t[i];if(!s)return{type:"Feature",geometry:null,properties:n};if(typeof s=="string")try{s=JSON.parse(s)}catch{throw new Error("Invalid string geometry")}if(typeof s!="object"||typeof s?.type!="string")throw new Error("invalid geometry column value");return s?.type==="Feature"?{...s,properties:n}:{type:"Feature",geometry:s,properties:n}}var po=class{chunkSize;strings=[];totalLength=0;textEncoder=new TextEncoder;constructor(t){this.chunkSize=t}push(...t){for(let e of t)this.strings.push(e),this.totalLength+=e.length}isFull(){return this.totalLength>=this.chunkSize}getArrayBufferBatch(){return this.textEncoder.encode(this.getStringBatch()).buffer}getStringBatch(){let t=this.strings.join("");return this.strings=[],this.totalLength=0,t}};async function*Na(r,t={}){let e={geojson:{},chunkSize:1e4,...t},n=new po(e.chunkSize);e.geojson.featureArray||n.push(`{
|
|
14
23
|
`,`"type": "FeatureCollection",
|
|
15
24
|
`,`"features":
|
|
16
|
-
`),
|
|
17
|
-
`),s=!1,
|
|
18
|
-
`),
|
|
19
|
-
`),
|
|
25
|
+
`),n.push("[");let i=e.geojson.geometryColumn,s=!0,o=0;for await(let a of r){let c=o+gr(a);i||(i=i||au(a));for(let u=o;u<c;++u)s||n.push(","),n.push(`
|
|
26
|
+
`),s=!1,lu(a,u,i,n),n.isFull()&&(yield n.getArrayBufferBatch()),o=c;let l=n.getArrayBufferBatch();l.byteLength>0&&(yield l)}n.push(`
|
|
27
|
+
`),n.push(`]
|
|
28
|
+
`),e.geojson.featureArray||n.push("}"),yield n.getArrayBufferBatch()}var uu={id:"geojson",version:"latest",module:"geojson",name:"GeoJSON",extensions:["geojson"],mimeTypes:["application/geo+json"],text:!0,options:{geojson:{featureArray:!1,geometryColumn:null}},async encode(r,t){let n=Na([r],t);return await wa(n)},encodeInBatches:(r,t)=>Na(r,t)};return _u(Ui);})();
|
|
20
29
|
return __exports__;
|
|
21
30
|
});
|