@loaders.gl/arrow 4.3.0-alpha.8 → 4.3.0-beta.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.
Files changed (132) hide show
  1. package/dist/arrow-loader.d.ts +6 -38
  2. package/dist/arrow-loader.d.ts.map +1 -1
  3. package/dist/arrow-loader.js +2 -29
  4. package/dist/arrow-worker.js +2654 -1710
  5. package/dist/arrow-writer.d.ts +1 -1
  6. package/dist/arrow-writer.d.ts.map +1 -1
  7. package/dist/arrow-writer.js +2 -2
  8. package/dist/dist.dev.js +1863 -1768
  9. package/dist/dist.min.js +5 -5
  10. package/dist/exports/arrow-loader.d.ts +34 -0
  11. package/dist/exports/arrow-loader.d.ts.map +1 -0
  12. package/dist/exports/arrow-loader.js +30 -0
  13. package/dist/exports/geoarrow-loader.d.ts +27 -0
  14. package/dist/exports/geoarrow-loader.d.ts.map +1 -0
  15. package/dist/exports/geoarrow-loader.js +13 -0
  16. package/dist/geoarrow-loader.d.ts +3 -27
  17. package/dist/geoarrow-loader.d.ts.map +1 -1
  18. package/dist/geoarrow-loader.js +2 -12
  19. package/dist/geoarrow-writer.d.ts +2 -2
  20. package/dist/geoarrow-writer.d.ts.map +1 -1
  21. package/dist/geoarrow-writer.js +2 -2
  22. package/dist/index.cjs +426 -387
  23. package/dist/index.cjs.map +4 -4
  24. package/dist/index.d.ts +14 -13
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +16 -12
  27. package/dist/lib/encoders/encode-arrow.d.ts.map +1 -0
  28. package/dist/lib/encoders/encode-geoarrow.d.ts.map +1 -0
  29. package/dist/lib/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +1 -0
  30. package/dist/lib/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts.map +1 -0
  31. package/dist/lib/geoarrow/get-arrow-bounds.d.ts.map +1 -0
  32. package/dist/lib/parsers/parse-arrow.d.ts +9 -0
  33. package/dist/lib/parsers/parse-arrow.d.ts.map +1 -0
  34. package/dist/{parsers/parse-arrow-in-batches.js → lib/parsers/parse-arrow.js} +7 -3
  35. package/dist/lib/parsers/parse-geoarrow.d.ts +9 -0
  36. package/dist/lib/parsers/parse-geoarrow.d.ts.map +1 -0
  37. package/dist/{parsers/parse-geoarrow-sync.js → lib/parsers/parse-geoarrow.js} +9 -3
  38. package/dist/{schema → lib/tables}/convert-arrow-schema.d.ts +4 -0
  39. package/dist/lib/tables/convert-arrow-schema.d.ts.map +1 -0
  40. package/dist/{schema → lib/tables}/convert-arrow-schema.js +8 -0
  41. package/dist/lib/tables/convert-arrow-to-table.d.ts +15 -0
  42. package/dist/lib/tables/convert-arrow-to-table.d.ts.map +1 -0
  43. package/dist/lib/tables/convert-arrow-to-table.js +104 -0
  44. package/dist/lib/tables/convert-table-to-arrow.d.ts +16 -0
  45. package/dist/lib/tables/convert-table-to-arrow.d.ts.map +1 -0
  46. package/dist/lib/tables/convert-table-to-arrow.js +56 -0
  47. package/dist/lib/types.d.ts.map +1 -0
  48. package/dist/{lib → schema}/arrow-table-batch.d.ts +2 -1
  49. package/dist/schema/arrow-table-batch.d.ts.map +1 -0
  50. package/dist/{lib → schema}/arrow-table-batch.js +1 -0
  51. package/dist/{lib/arrow-table.d.ts → schema/arrow-table-type.d.ts} +3 -1
  52. package/dist/schema/arrow-table-type.d.ts.map +1 -0
  53. package/dist/triangulate-on-worker.js +1 -1
  54. package/dist/triangulation-worker.js +13 -5
  55. package/dist/workers/triangulation-worker.js +1 -1
  56. package/package.json +11 -7
  57. package/src/arrow-loader.ts +6 -57
  58. package/src/arrow-writer.ts +1 -2
  59. package/src/exports/arrow-loader.ts +49 -0
  60. package/src/exports/geoarrow-loader.ts +24 -0
  61. package/src/geoarrow-loader.ts +6 -22
  62. package/src/geoarrow-writer.ts +1 -1
  63. package/src/index.ts +23 -23
  64. package/src/{parsers/parse-arrow-in-batches.ts → lib/parsers/parse-arrow.ts} +11 -5
  65. package/src/lib/parsers/parse-geoarrow.ts +32 -0
  66. package/src/{schema → lib/tables}/convert-arrow-schema.ts +10 -0
  67. package/src/lib/tables/convert-arrow-to-table.ts +144 -0
  68. package/src/lib/tables/convert-table-to-arrow.ts +72 -0
  69. package/src/{lib → schema}/arrow-table-batch.ts +2 -1
  70. package/src/{lib/arrow-table.ts → schema/arrow-table-type.ts} +2 -0
  71. package/src/workers/triangulation-worker.ts +1 -1
  72. package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +0 -1
  73. package/dist/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts.map +0 -1
  74. package/dist/geoarrow/get-arrow-bounds.d.ts.map +0 -1
  75. package/dist/lib/arrow-table-batch.d.ts.map +0 -1
  76. package/dist/lib/arrow-table.d.ts.map +0 -1
  77. package/dist/lib/encode-arrow.d.ts.map +0 -1
  78. package/dist/lib/encode-geoarrow.d.ts.map +0 -1
  79. package/dist/parsers/parse-arrow-in-batches.d.ts +0 -6
  80. package/dist/parsers/parse-arrow-in-batches.d.ts.map +0 -1
  81. package/dist/parsers/parse-arrow-sync.d.ts +0 -6
  82. package/dist/parsers/parse-arrow-sync.d.ts.map +0 -1
  83. package/dist/parsers/parse-arrow-sync.js +0 -32
  84. package/dist/parsers/parse-geoarrow-in-batches.d.ts +0 -6
  85. package/dist/parsers/parse-geoarrow-in-batches.d.ts.map +0 -1
  86. package/dist/parsers/parse-geoarrow-in-batches.js +0 -10
  87. package/dist/parsers/parse-geoarrow-sync.d.ts +0 -6
  88. package/dist/parsers/parse-geoarrow-sync.d.ts.map +0 -1
  89. package/dist/schema/arrow-type-utils.d.ts +0 -5
  90. package/dist/schema/arrow-type-utils.d.ts.map +0 -1
  91. package/dist/schema/arrow-type-utils.js +0 -51
  92. package/dist/schema/convert-arrow-schema.d.ts.map +0 -1
  93. package/dist/tables/convert-arrow-to-columnar-table.d.ts +0 -8
  94. package/dist/tables/convert-arrow-to-columnar-table.d.ts.map +0 -1
  95. package/dist/tables/convert-arrow-to-columnar-table.js +0 -24
  96. package/dist/tables/convert-arrow-to-geojson-table.d.ts +0 -16
  97. package/dist/tables/convert-arrow-to-geojson-table.d.ts.map +0 -1
  98. package/dist/tables/convert-arrow-to-geojson-table.js +0 -54
  99. package/dist/tables/convert-columnar-to-row-table.d.ts +0 -7
  100. package/dist/tables/convert-columnar-to-row-table.d.ts.map +0 -1
  101. package/dist/tables/convert-columnar-to-row-table.js +0 -25
  102. package/dist/tables/convert-table-to-arrow.d.ts +0 -42
  103. package/dist/tables/convert-table-to-arrow.d.ts.map +0 -1
  104. package/dist/tables/convert-table-to-arrow.js +0 -59
  105. package/dist/types.d.ts.map +0 -1
  106. package/src/parsers/parse-arrow-sync.ts +0 -44
  107. package/src/parsers/parse-geoarrow-in-batches.ts +0 -16
  108. package/src/parsers/parse-geoarrow-sync.ts +0 -23
  109. package/src/schema/arrow-type-utils.ts +0 -55
  110. package/src/tables/convert-arrow-to-columnar-table.ts +0 -31
  111. package/src/tables/convert-arrow-to-geojson-table.ts +0 -66
  112. package/src/tables/convert-columnar-to-row-table.ts +0 -31
  113. package/src/tables/convert-table-to-arrow.ts +0 -61
  114. /package/dist/lib/{encode-arrow.d.ts → encoders/encode-arrow.d.ts} +0 -0
  115. /package/dist/lib/{encode-arrow.js → encoders/encode-arrow.js} +0 -0
  116. /package/dist/lib/{encode-geoarrow.d.ts → encoders/encode-geoarrow.d.ts} +0 -0
  117. /package/dist/lib/{encode-geoarrow.js → encoders/encode-geoarrow.js} +0 -0
  118. /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-binary-geometry.d.ts +0 -0
  119. /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-binary-geometry.js +0 -0
  120. /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-geojson-geometry.d.ts +0 -0
  121. /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-geojson-geometry.js +0 -0
  122. /package/dist/{geoarrow → lib/geoarrow}/get-arrow-bounds.d.ts +0 -0
  123. /package/dist/{geoarrow → lib/geoarrow}/get-arrow-bounds.js +0 -0
  124. /package/dist/{types.d.ts → lib/types.d.ts} +0 -0
  125. /package/dist/{types.js → lib/types.js} +0 -0
  126. /package/dist/{lib/arrow-table.js → schema/arrow-table-type.js} +0 -0
  127. /package/src/lib/{encode-arrow.ts → encoders/encode-arrow.ts} +0 -0
  128. /package/src/lib/{encode-geoarrow.ts → encoders/encode-geoarrow.ts} +0 -0
  129. /package/src/{geoarrow → lib/geoarrow}/convert-geoarrow-to-binary-geometry.ts +0 -0
  130. /package/src/{geoarrow → lib/geoarrow}/convert-geoarrow-to-geojson-geometry.ts +0 -0
  131. /package/src/{geoarrow → lib/geoarrow}/get-arrow-bounds.ts +0 -0
  132. /package/src/{types.ts → lib/types.ts} +0 -0
package/dist/dist.min.js CHANGED
@@ -4,20 +4,20 @@
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 af=Object.create;var Kn=Object.defineProperty;var cf=Object.getOwnPropertyDescriptor;var lf=Object.getOwnPropertyNames;var uf=Object.getPrototypeOf,ff=Object.prototype.hasOwnProperty;var hf=(r,t,e)=>t in r?Kn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var df=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Ir=(r,t)=>{for(var e in t)Kn(r,e,{get:t[e],enumerable:!0})},Qi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of lf(t))!ff.call(r,i)&&i!==e&&Kn(r,i,{get:()=>t[i],enumerable:!(n=cf(t,i))||n.enumerable});return r},qi=(r,t,e)=>(Qi(r,t,"default"),e&&Qi(e,t,"default")),pf=(r,t,e)=>(e=r!=null?af(uf(r)):{},Qi(t||!r||!r.__esModule?Kn(e,"default",{value:r,enumerable:!0}):e,r)),mf=r=>Qi(Kn({},"__esModule",{value:!0}),r);var ts=(r,t,e)=>(hf(r,typeof t!="symbol"?t+"":t,e),e);var gc=df((_m,yc)=>{yc.exports=globalThis.loaders});var Xi={};Ir(Xi,{ArrowLoader:()=>Tu,ArrowWorkerLoader:()=>ji,ArrowWriter:()=>Du,GeoArrowLoader:()=>Cu,GeoArrowWorkerLoader:()=>ec,TriangulationWorker:()=>Yo,VECTOR_TYPES:()=>ln,convertArrowToGeoJSONTable:()=>ko,deserializeArrowField:()=>fn,deserializeArrowMetadata:()=>Lo,deserializeArrowSchema:()=>Au,deserializeArrowType:()=>Za,getArrowType:()=>Bu,getBinaryGeometriesFromArrow:()=>Pu,getBinaryGeometryTemplate:()=>Yi,getMeanCentersFromBinaryGeometries:()=>rc,getTriangleIndices:()=>nc,hardClone:()=>Ki,parseGeoArrowOnWorker:()=>of,parseGeometryFromArrow:()=>Vo,serializeArrowField:()=>un,serializeArrowMetadata:()=>Mo,serializeArrowSchema:()=>zn,serializeArrowType:()=>Ka,triangulateOnWorker:()=>sf,updateBoundsFromGeoArrowSamples:()=>jo});qi(Xi,pf(gc(),1));function es(r,t="float32"){return r instanceof Date?"date-millisecond":r instanceof Number?t:typeof r=="string"?"utf8":(r===null||r==="undefined","null")}function bc(r){let t=yf(r);return t!=="null"?{type:t,nullable:!1}:r.length>0?(t=es(r[0]),{type:t,nullable:!0}):{type:"null",nullable:!0}}function yf(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 wc(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}var rs=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}};function _c(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 vc(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 Ic(r){let t=[];for(let e=0;e<r.length;e++){let n=`column-${e}`;t.push(n)}return t}function xc(r){return Object.keys(r)}var Sc=100,ns=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 in t)this._headers[t[n].index]=t[n].name}}rowCount(){return this.length}addArrayRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this._headers||=Ic(t),this.options.shape){case"object-row-table":let n=_c(t,this._headers);this.addObjectRow(n,e);break;case"array-row-table":this.arrayRows=this.arrayRows||new Array(Sc),this.arrayRows[this.length]=t,this.length++;break}}addObjectRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this._headers||=xc(t),this.options.shape){case"array-row-table":let n=vc(t,this._headers);this.addArrayRow(n,e);break;case"object-row-table":this.objectRows=this.objectRows||new Array(Sc),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}};var Nr=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(){this._pruneColumns();let t=Array.isArray(this.schema)?this.columns:{};if(!Array.isArray(this.schema))for(let n in this.schema){let i=this.schema[n];t[i.name]=this.columns[i.index]}return this.columns={},{shape:"columnar-table",batchType:"data",data:t,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 t in this.schema){let e=this.schema[t],n=e.type||Float32Array,i=this.columns[e.index];if(i&&ArrayBuffer.isView(i)){let s=new n(this.allocated);s.set(i),this.columns[e.index]=s}else i?(i.length=this.allocated,this.columns[e.index]=i):this.columns[e.index]=new n(this.allocated)}}}_pruneColumns(){for(let[t,e]of Object.entries(this.columns))this.columns[t]=e.slice(0,this.length)}};var gf={shape:void 0,batchSize:"auto",batchDebounceMs:0,limit:0,_limitMB:0},bf="TableBatchBuilder",is=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={...gf,...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 ns;case"columnar-table":return Nr;case"arrow-table":if(!is.ArrowBatch)throw new Error(bf);return is.ArrowBatch;default:return rs}}},mn=is;ts(mn,"ArrowBatch");function ss(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 Bc(r,t,e){switch(r.shape){case"array-row-table":let n=wf(r,e);return r.data[t][n];case"object-row-table":return r.data[t][e];case"geojson-table":return r.features[t][e];case"columnar-table":return r.data[e][t];case"arrow-table":let s=r.data,o=s.schema.fields.findIndex(a=>a.name===e);return s.getChildAt(o)?.get(t);default:throw new Error("todo")}}function wf(r,t){let e=r.schema?.fields.findIndex(n=>n.name===t);if(e===void 0)throw new Error(t);return e}function Ac(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 Tc(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 Dc(r){switch(r.shape){case"array-row-table":case"object-row-table":return vf(r.data);case"geojson-table":return If(r.features);case"columnar-table":return _f(r.data);case"arrow-table":default:throw new Error("Deduce schema")}}function _f(r){let t=[];for(let[e,n]of Object.entries(r)){let i=xf(n,e);t.push(i)}return{fields:t,metadata:{}}}function vf(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(Oc(i,n));return{fields:t,metadata:{}}}function If(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(Oc(i,n));return{fields:t,metadata:{}}}function xf(r,t){if(ArrayBuffer.isView(r)){let e=bc(r);return{name:t,type:e.type||"null",nullable:e.nullable}}if(Array.isArray(r)&&r.length>0){let e=r[0],n=es(e);return{name:t,type:n,nullable:!0}}throw new Error("empty table")}function Oc(r,t){let e=es(r);return{name:t,type:e,nullable:!0}}function Fc(r,t){let e=wc(r.type,r.nullable);return new e(t)}function os(r,t){switch(t){case"object-row-table":return Tf(r);case"array-row-table":return Af(r);case"columnar-table":return Bf(r);case"arrow-table":return Sf(r);default:throw new Error(t)}}function Sf(r){let t=globalThis.__loaders?._makeArrowTable;if(!t)throw new Error("");return t(r)}function Bf(r){let t=r.schema||Dc(r),e=r.schema?.fields||[];if(r.shape==="columnar-table")return{...r,schema:t};let n=ss(r),i={};for(let s of e){let o=Fc(s,n);i[s.name]=o;for(let a=0;a<n;a++)o[a]=Bc(r,a,s.name)}return{shape:"columnar-table",schema:t,data:i}}function Af(r){if(r.shape==="array-row-table")return r;let t=ss(r),e=new Array(t);for(let n=0;n<t;n++)e[n]=Tc(r,n);return{shape:"array-row-table",schema:r.schema,data:e}}function Tf(r){if(r.shape==="object-row-table")return r;let t=ss(r),e=new Array(t);for(let n=0;n<t;n++)e[n]=Ac(r,n);return{shape:"object-row-table",schema:r.schema,data:e}}function Lc(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(h){o(h)}}function c(u){try{l(n.throw(u))}catch(h){o(h)}}function l(u){u.done?s(u.value):i(u.value).then(a,c)}l((n=n.apply(r,t||[])).next())})}function Mc(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 U(r){return this instanceof U?(this.v=r,this):new U(r)}function oe(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(r,t||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(d){n[d]&&(i[d]=function(b){return new Promise(function(M,z){s.push([d,b,M,z])>1||a(d,b)})})}function a(d,b){try{c(n[d](b))}catch(M){h(s[0][3],M)}}function c(d){d.value instanceof U?Promise.resolve(d.value.v).then(l,u):h(s[0][2],d)}function l(d){a("next",d)}function u(d){a("throw",d)}function h(d,b){d(b),s.shift(),s.length&&a(s[0][0],s[0][1])}}function yn(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:U(r[i](o)),done:!1}:s?s(o):o}:s}}function Ae(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 Mc=="function"?Mc(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 qo={};Ir(qo,{compareArrayLike:()=>Qo,joinUint8Arrays:()=>ce,memcpy:()=>Xn,rebaseValueOffsets:()=>ps,toArrayBufferView:()=>C,toArrayBufferViewAsyncIterator:()=>De,toArrayBufferViewIterator:()=>Pe,toBigInt64Array:()=>ds,toBigUint64Array:()=>Rf,toFloat32Array:()=>Cf,toFloat32ArrayAsyncIterator:()=>qf,toFloat32ArrayIterator:()=>$f,toFloat64Array:()=>Pf,toFloat64ArrayAsyncIterator:()=>th,toFloat64ArrayIterator:()=>Hf,toInt16Array:()=>Nf,toInt16ArrayAsyncIterator:()=>Zf,toInt16ArrayIterator:()=>jf,toInt32Array:()=>Ur,toInt32ArrayAsyncIterator:()=>Jf,toInt32ArrayIterator:()=>zf,toInt8Array:()=>Lf,toInt8ArrayAsyncIterator:()=>Kf,toInt8ArrayIterator:()=>Vf,toUint16Array:()=>Uf,toUint16ArrayAsyncIterator:()=>Xf,toUint16ArrayIterator:()=>Wf,toUint32Array:()=>Ef,toUint32ArrayAsyncIterator:()=>Qf,toUint32ArrayIterator:()=>Gf,toUint8Array:()=>T,toUint8ArrayAsyncIterator:()=>Xo,toUint8ArrayIterator:()=>Jo,toUint8ClampedArray:()=>kf,toUint8ClampedArrayAsyncIterator:()=>eh,toUint8ClampedArrayIterator:()=>Yf});var Df=new TextDecoder("utf-8"),Zn=r=>Df.decode(r),Of=new TextEncoder,Ce=r=>Of.encode(r);var Ff=r=>typeof r=="number",Nc=r=>typeof r=="boolean",wt=r=>typeof r=="function",Rt=r=>r!=null&&Object(r)===r,ae=r=>Rt(r)&&wt(r.then);var Te=r=>Rt(r)&&wt(r[Symbol.iterator]),de=r=>Rt(r)&&wt(r[Symbol.asyncIterator]),as=r=>Rt(r)&&Rt(r.schema);var cs=r=>Rt(r)&&"done"in r&&"value"in r;var ls=r=>Rt(r)&&wt(r.stat)&&Ff(r.fd);var us=r=>Rt(r)&&Jn(r.body),fs=r=>"_getDOMStream"in r&&"_getNodeStream"in r,Uc=r=>Rt(r)&&wt(r.abort)&&wt(r.getWriter)&&!fs(r),Jn=r=>Rt(r)&&wt(r.cancel)&&wt(r.getReader)&&!fs(r),Ec=r=>Rt(r)&&wt(r.end)&&wt(r.write)&&Nc(r.writable)&&!fs(r),hs=r=>Rt(r)&&wt(r.read)&&wt(r.pipe)&&Nc(r.readable)&&!fs(r),Rc=r=>Rt(r)&&wt(r.clear)&&wt(r.bytes)&&wt(r.position)&&wt(r.setPosition)&&wt(r.capacity)&&wt(r.getBufferIdentifier)&&wt(r.createLong);var Zo=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Mf(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 Xn(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 ce(r,t){let e=Mf(r),n=e.reduce((u,h)=>u+h.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?Xn(o,s,a):o=s;break}Xn(o||(o=new Uint8Array(l)),s,a),a+=s.length}return[o||new Uint8Array(0),e.slice(c),n-(o?o.byteLength:0)]}function C(r,t){let e=cs(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=Ce(e)),e instanceof ArrayBuffer?new r(e):e instanceof Zo?new r(e):Rc(e)?C(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 Lf=r=>C(Int8Array,r),Nf=r=>C(Int16Array,r),Ur=r=>C(Int32Array,r),ds=r=>C(BigInt64Array,r),T=r=>C(Uint8Array,r),Uf=r=>C(Uint16Array,r),Ef=r=>C(Uint32Array,r),Rf=r=>C(BigUint64Array,r),Cf=r=>C(Float32Array,r),Pf=r=>C(Float64Array,r),kf=r=>C(Uint8ClampedArray,r),Ko=r=>(r.next(),r);function*Pe(r,t){let e=function*(i){yield i},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof Zo?e(t):Te(t)?t:e(t);return yield*Ko(function*(i){let s=null;do s=i.next(yield C(r,s));while(!s.done)}(n[Symbol.iterator]())),new r}var Vf=r=>Pe(Int8Array,r),jf=r=>Pe(Int16Array,r),zf=r=>Pe(Int32Array,r),Jo=r=>Pe(Uint8Array,r),Wf=r=>Pe(Uint16Array,r),Gf=r=>Pe(Uint32Array,r),$f=r=>Pe(Float32Array,r),Hf=r=>Pe(Float64Array,r),Yf=r=>Pe(Uint8ClampedArray,r);function De(r,t){return oe(this,arguments,function*(){if(ae(t))return yield U(yield U(yield*yn(Ae(De(r,yield U(t))))));let n=function(o){return oe(this,arguments,function*(){yield yield U(yield U(o))})},i=function(o){return oe(this,arguments,function*(){yield U(yield*yn(Ae(Ko(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 Zo?n(t):Te(t)?i(t):de(t)?t:n(t);return yield U(yield*yn(Ae(Ko(function(o){return oe(this,arguments,function*(){let a=null;do a=yield U(o.next(yield yield U(C(r,a))));while(!a.done)})}(s[Symbol.asyncIterator]()))))),yield U(new r)})}var Kf=r=>De(Int8Array,r),Zf=r=>De(Int16Array,r),Jf=r=>De(Int32Array,r),Xo=r=>De(Uint8Array,r),Xf=r=>De(Uint16Array,r),Qf=r=>De(Uint32Array,r),qf=r=>De(Float32Array,r),th=r=>De(Float64Array,r),eh=r=>De(Uint8ClampedArray,r);function ps(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 Qo(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 Bt={fromIterable(r){return ms(rh(r))},fromAsyncIterable(r){return ms(nh(r))},fromDOMStream(r){return ms(ih(r))},fromNodeStream(r){return ms(sh(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')}},ms=r=>(r.next(),r);function*rh(r){let t,e=!1,n=[],i,s,o,a=0;function c(){return s==="peek"?ce(n,o)[0]:([i,n,a]=ce(n,o),i)}({cmd:s,size:o}=(yield(()=>null)())||{cmd:"read",size:0});let l=Jo(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 nh(r){return oe(this,arguments,function*(){let e,n=!1,i=[],s,o,a,c=0;function l(){return o==="peek"?ce(i,a)[0]:([s,i,c]=ce(i,a),s)}({cmd:o,size:a}=(yield yield U((()=>null)()))||{cmd:"read",size:0});let u=Xo(r)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(a-c)?yield U(u.next()):yield U(u.next(a-c)),!e&&s.byteLength>0&&(i.push(s),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield U(l()));while(a<c);while(!e)}catch(h){(n=!0)&&typeof u.throw=="function"&&(yield U(u.throw(h)))}finally{n===!1&&typeof u.return=="function"&&(yield U(u.return(new Uint8Array(0))))}return yield U(null)})}function ih(r){return oe(this,arguments,function*(){let e=!1,n=!1,i=[],s,o,a,c=0;function l(){return o==="peek"?ce(i,a)[0]:([s,i,c]=ce(i,a),s)}({cmd:o,size:a}=(yield yield U((()=>null)()))||{cmd:"read",size:0});let u=new ea(r);try{do if({done:e,value:s}=Number.isNaN(a-c)?yield U(u.read()):yield U(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 U(l()));while(a<c);while(!e)}catch(h){(n=!0)&&(yield U(u.cancel(h)))}finally{n===!1?yield U(u.cancel()):r.locked&&u.releaseLock()}return yield U(null)})}var ea=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})}},ta=(r,t)=>{let e=i=>n([t,i]),n;return[t,e,new Promise(i=>(n=i)&&r.once(t,e))]};function sh(r){return oe(this,arguments,function*(){let e=[],n="error",i=!1,s=null,o,a,c=0,l=[],u;function h(){return o==="peek"?ce(l,a)[0]:([u,l,c]=ce(l,a),u)}if({cmd:o,size:a}=(yield yield U((()=>null)()))||{cmd:"read",size:0},r.isTTY)return yield yield U(new Uint8Array(0)),yield U(null);try{e[0]=ta(r,"end"),e[1]=ta(r,"error");do{if(e[2]=ta(r,"readable"),[n,s]=yield U(Promise.race(e.map(b=>b[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 U(h()));while(a<c)}while(!i)}finally{yield U(d(e,n==="error"?s:null))}return yield U(null);function d(b,M){return u=l=null,new Promise((z,X)=>{for(let[st,pn]of b)r.off(st,pn);try{let st=r.destroy;st&&st.call(r,M),M=void 0}catch(st){M=st||M}finally{M!=null?X(M):z()}})}})}var $;(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"})($||($={}));var K;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(K||(K={}));var j;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(j||(j={}));var et;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(et||(et={}));var p;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(p||(p={}));var nt;(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"})(nt||(nt={}));var ke=new Int32Array(2),ys=new Float32Array(ke.buffer),gs=new Float64Array(ke.buffer),gn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Qn;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Qn||(Qn={}));var Ct=class{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new Ct(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 ke[0]=this.readInt32(t),ys[0]}readFloat64(t){return ke[gn?0:1]=this.readInt32(t),ke[gn?1:0]=this.readInt32(t+4),gs[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){ys[0]=e,this.writeInt32(t,ke[0])}writeFloat64(t,e){gs[0]=e,this.writeInt32(t,ke[gn?0:1]),this.writeInt32(t+4,ke[gn?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===Qn.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 or=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=Ct.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=or.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=Ct.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;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);for(let n=0,i=this.space,s=this.bb.bytes();n<e.length;n++)s[i++]=e[n];return 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 qn;(function(r){r[r.BUFFER=0]="BUFFER"})(qn||(qn={}));var ti;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(ti||(ti={}));var Fe=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 Fe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new Fe).__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):ti.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):qn.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,ti.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,qn.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return Fe.startBodyCompression(t),Fe.addCodec(t,e),Fe.addMethod(t,n),Fe.endBodyCompression(t)}};var bn=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 wn=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 Ft=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 Ft).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new Ft).__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 wn).__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 bn).__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 Fe).__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 me=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 me).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new me).__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 Ft).__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 xr;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(xr||(xr={}));var ei;(function(r){r[r.DenseArray=0]="DenseArray"})(ei||(ei={}));var _t=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 _t).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+4),(e||new _t).__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 _t.startInt(t),_t.addBitWidth(t,e),_t.addIsSigned(t,n),_t.endInt(t)}};var le=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 le).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+4),(e||new le).__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 _t).__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):ei.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,ei.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 Ve=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 Ve).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+4),(e||new Ve).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return Ve.startBinary(t),Ve.endBinary(t)}};var je=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 je).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+4),(e||new je).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return je.startBool(t),je.endBool(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 getRootAsDate(t,e){return(e||new Gt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+4),(e||new Gt).__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):et.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,et.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return Gt.startDate(t),Gt.addUnit(t,e),Gt.endDate(t)}};var vt=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 vt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+4),(e||new vt).__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 vt.startDecimal(t),vt.addPrecision(t,e),vt.addScale(t,n),vt.addBitWidth(t,i),vt.endDecimal(t)}};var $t=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 $t).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+4),(e||new $t).__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):p.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,p.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return $t.startDuration(t),$t.addUnit(t,e),$t.endDuration(t)}};var Ht=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 Ht).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+4),(e||new Ht).__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 Ht.startFixedSizeBinary(t),Ht.addByteWidth(t,e),Ht.endFixedSizeBinary(t)}};var Yt=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 Yt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+4),(e||new Yt).__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 Yt.startFixedSizeList(t),Yt.addListSize(t,e),Yt.endFixedSizeList(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 getRootAsFloatingPoint(t,e){return(e||new Kt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+4),(e||new Kt).__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):j.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,j.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return Kt.startFloatingPoint(t),Kt.addPrecision(t,e),Kt.endFloatingPoint(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 getRootAsInterval(t,e){return(e||new Zt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+4),(e||new Zt).__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):nt.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,nt.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return Zt.startInterval(t),Zt.addUnit(t,e),Zt.endInterval(t)}};var ze=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 ze).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+4),(e||new ze).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return ze.startLargeBinary(t),ze.endLargeBinary(t)}};var We=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 We).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+4),(e||new We).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return We.startLargeUtf8(t),We.endLargeUtf8(t)}};var Ge=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 Ge).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+4),(e||new Ge).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return Ge.startList(t),Ge.endList(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 getRootAsMap(t,e){return(e||new Jt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+4),(e||new Jt).__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 Jt.startMap(t),Jt.addKeysSorted(t,e),Jt.endMap(t)}};var $e=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 $e).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+4),(e||new $e).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return $e.startNull(t),$e.endNull(t)}};var He=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 He).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+4),(e||new He).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return He.startStruct_(t),He.endStruct_(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 getRootAsTime(t,e){return(e||new Mt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(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):p.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,p.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return Mt.startTime(t),Mt.addUnit(t,e),Mt.addBitWidth(t,n),Mt.endTime(t)}};var Lt=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 Lt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+4),(e||new Lt).__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):p.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,p.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return Lt.startTimestamp(t),Lt.addUnit(t,e),Lt.addTimezone(t,n),Lt.endTimestamp(t)}};var It=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 It).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+4),(e||new It).__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):K.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,K.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 It.startUnion(t),It.addMode(t,e),It.addTypeIds(t,n),It.endUnion(t)}};var Ye=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 Ye).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new Ye).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Ye.startUtf8(t),Ye.endUtf8(t)}};var Z;(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"})(Z||(Z={}));var dt=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 dt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+4),(e||new dt).__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):Z.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 le).__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 dt).__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,Z.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 ot=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 ot).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+4),(e||new ot).__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):xr.Little}fields(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new dt).__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,xr.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 ot.startSchema(t),ot.addEndianness(t,e),ot.addFields(t,n),ot.addCustomMetadata(t,i),ot.addFeatures(t,s),ot.endSchema(t)}};var P;(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"})(P||(P={}));var f;(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"})(f||(f={}));var lt;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(lt||(lt={}));var _a={};Ir(_a,{clampIndex:()=>Hh,clampRange:()=>ii,createElementComparator:()=>Tr});var ra={};Ir(ra,{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 ia={};Ir(ia,{BN:()=>Er,bigNumToBigInt:()=>kc,bigNumToString:()=>In,isArrowBigNumSymbol:()=>Cc});var Cc=Symbol.for("isArrowBigNum");function Le(r,...t){return t.length===0?Object.setPrototypeOf(C(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}Le.prototype[Cc]=!0;Le.prototype.toJSON=function(){return`"${In(this)}"`};Le.prototype.valueOf=function(){return Pc(this)};Le.prototype.toString=function(){return In(this)};Le.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Pc(this);case"string":return In(this);case"default":return kc(this)}return In(this)};function _n(...r){return Le.apply(this,r)}function vn(...r){return Le.apply(this,r)}function ri(...r){return Le.apply(this,r)}Object.setPrototypeOf(_n.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(vn.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(ri.prototype,Object.create(Uint32Array.prototype));Object.assign(_n.prototype,Le.prototype,{constructor:_n,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(vn.prototype,Le.prototype,{constructor:vn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(ri.prototype,Le.prototype,{constructor:ri,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});function Pc(r){let{buffer:t,byteOffset:e,length:n,signed:i}=r,s=new BigUint64Array(t,e,n),o=i&&s.at(-1)&BigInt(1)<<BigInt(63),a=BigInt(o?1:0),c=BigInt(0);if(o){for(let l of s)a+=~l*(BigInt(1)<<BigInt(32)*c++);a*=BigInt(-1)}else for(let l of s)a+=l*(BigInt(1)<<BigInt(32)*c++);return a}var In=r=>{if(r.byteLength===8)return`${new r.BigIntArray(r.buffer,r.byteOffset,1)[0]}`;if(!r.signed)return na(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return na(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`-${na(t)}`},kc=r=>r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:In(r);function na(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 Er=class{static new(t,e){switch(e){case!0:return new _n(t);case!1:return new vn(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new _n(t)}return t.byteLength===16?new ri(t):new vn(t)}static signed(t){return new _n(t)}static unsigned(t){return new vn(t)}static decimal(t){return new ri(t)}constructor(t,e){return Er.new(t,e)}};function at(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)}var Vc,jc,zc,Wc,Gc,$c,Hc,Yc,Kc,Zc,Jc,Xc,Qc,qc,tl,el,rl,nl,il,sl,ol,al,m=class{static isNull(t){return t?.typeId===f.Null}static isInt(t){return t?.typeId===f.Int}static isFloat(t){return t?.typeId===f.Float}static isBinary(t){return t?.typeId===f.Binary}static isLargeBinary(t){return t?.typeId===f.LargeBinary}static isUtf8(t){return t?.typeId===f.Utf8}static isLargeUtf8(t){return t?.typeId===f.LargeUtf8}static isBool(t){return t?.typeId===f.Bool}static isDecimal(t){return t?.typeId===f.Decimal}static isDate(t){return t?.typeId===f.Date}static isTime(t){return t?.typeId===f.Time}static isTimestamp(t){return t?.typeId===f.Timestamp}static isInterval(t){return t?.typeId===f.Interval}static isDuration(t){return t?.typeId===f.Duration}static isList(t){return t?.typeId===f.List}static isStruct(t){return t?.typeId===f.Struct}static isUnion(t){return t?.typeId===f.Union}static isFixedSizeBinary(t){return t?.typeId===f.FixedSizeBinary}static isFixedSizeList(t){return t?.typeId===f.FixedSizeList}static isMap(t){return t?.typeId===f.Map}static isDictionary(t){return t?.typeId===f.Dictionary}static isDenseUnion(t){return m.isUnion(t)&&t.mode===K.Dense}static isSparseUnion(t){return m.isUnion(t)&&t.mode===K.Sparse}constructor(t){this.typeId=t}};Vc=Symbol.toStringTag;m[Vc]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(m.prototype);var ut=class extends m{constructor(){super(f.Null)}toString(){return"Null"}};jc=Symbol.toStringTag;ut[jc]=(r=>r[Symbol.toStringTag]="Null")(ut.prototype);var it=class extends m{constructor(t,e){super(f.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}`}};zc=Symbol.toStringTag;it[zc]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(it.prototype);var ye=class extends it{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},ge=class extends it{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},pt=class extends it{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},be=class extends it{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},we=class extends it{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},_e=class extends it{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},ve=class extends it{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Ke=class extends it{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(ye.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(ge.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(pt.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(be.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(we.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(_e.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(ve.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(Ke.prototype,"ArrayType",{value:BigUint64Array});var At=class extends m{constructor(t){super(f.Float),this.precision=t}get ArrayType(){switch(this.precision){case j.HALF:return Uint16Array;case j.SINGLE:return Float32Array;case j.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};Wc=Symbol.toStringTag;At[Wc]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(At.prototype);var Sr=class extends At{constructor(){super(j.HALF)}},Xt=class extends At{constructor(){super(j.SINGLE)}},Qt=class extends At{constructor(){super(j.DOUBLE)}};Object.defineProperty(Sr.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Xt.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(Qt.prototype,"ArrayType",{value:Float64Array});var ue=class extends m{constructor(){super(f.Binary)}toString(){return"Binary"}};Gc=Symbol.toStringTag;ue[Gc]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(ue.prototype);var Ze=class extends m{constructor(){super(f.LargeBinary)}toString(){return"LargeBinary"}};$c=Symbol.toStringTag;Ze[$c]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(Ze.prototype);var Pt=class extends m{constructor(){super(f.Utf8)}toString(){return"Utf8"}};Hc=Symbol.toStringTag;Pt[Hc]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(Pt.prototype);var Je=class extends m{constructor(){super(f.LargeUtf8)}toString(){return"LargeUtf8"}};Yc=Symbol.toStringTag;Je[Yc]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Je.prototype);var kt=class extends m{constructor(){super(f.Bool)}toString(){return"Bool"}};Kc=Symbol.toStringTag;kt[Kc]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(kt.prototype);var fe=class extends m{constructor(t,e,n=128){super(f.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};Zc=Symbol.toStringTag;fe[Zc]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(fe.prototype);var qt=class extends m{constructor(t){super(f.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${et[this.unit]}>`}};Jc=Symbol.toStringTag;qt[Jc]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Date"))(qt.prototype);var Rr=class extends qt{constructor(){super(et.DAY)}},ar=class extends qt{constructor(){super(et.MILLISECOND)}},xt=class extends m{constructor(t,e){super(f.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${p[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};Xc=Symbol.toStringTag;xt[Xc]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(xt.prototype);var Cr=class extends xt{constructor(){super(p.SECOND,32)}},Pr=class extends xt{constructor(){super(p.MILLISECOND,32)}},kr=class extends xt{constructor(){super(p.MICROSECOND,64)}},Vr=class extends xt{constructor(){super(p.NANOSECOND,64)}},Nt=class extends m{constructor(t,e){super(f.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${p[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};Qc=Symbol.toStringTag;Nt[Qc]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Timestamp"))(Nt.prototype);var jr=class extends Nt{constructor(t){super(p.SECOND,t)}},zr=class extends Nt{constructor(t){super(p.MILLISECOND,t)}},Wr=class extends Nt{constructor(t){super(p.MICROSECOND,t)}},Gr=class extends Nt{constructor(t){super(p.NANOSECOND,t)}},te=class extends m{constructor(t){super(f.Interval),this.unit=t}toString(){return`Interval<${nt[this.unit]}>`}};qc=Symbol.toStringTag;te[qc]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(te.prototype);var $r=class extends te{constructor(){super(nt.DAY_TIME)}},Hr=class extends te{constructor(){super(nt.YEAR_MONTH)}},Xe=class extends m{constructor(t){super(f.Duration),this.unit=t}toString(){return`Duration<${p[this.unit]}>`}};tl=Symbol.toStringTag;Xe[tl]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(Xe.prototype);var Tt=class extends m{constructor(t){super(f.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}};el=Symbol.toStringTag;Tt[el]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(Tt.prototype);var V=class extends m{constructor(t){super(f.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};rl=Symbol.toStringTag;V[rl]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(V.prototype);var Ie=class extends m{constructor(t,e,n){super(f.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(" | ")}>`}};nl=Symbol.toStringTag;Ie[nl]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(Ie.prototype);var Qe=class extends m{constructor(t){super(f.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};il=Symbol.toStringTag;Qe[il]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Qe.prototype);var Vt=class extends m{constructor(t,e){super(f.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}>`}};sl=Symbol.toStringTag;Vt[sl]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(Vt.prototype);var jt=class extends m{constructor(t,e=!1){var n,i,s;if(super(f.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(", ")}}>`}};ol=Symbol.toStringTag;jt[ol]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(jt.prototype);var oh=(r=>()=>++r)(-1),Ut=class extends m{constructor(t,e,n,i){super(f.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=n==null?oh():at(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}>`}};al=Symbol.toStringTag;Ut[al]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(Ut.prototype);function he(r){let t=r;switch(r.typeId){case f.Decimal:return r.bitWidth/32;case f.Timestamp:return 2;case f.Date:return 1+t.unit;case f.Interval:return 1+t.unit;case f.FixedSizeList:return t.listSize;case f.FixedSizeBinary:return t.byteWidth;default:return 1}}var v=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 ah(this,t,e)}getVisitFnByTypeId(t,e=!0){return xn(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 ah(r,t,e=!0){return typeof t=="number"?xn(r,t,e):typeof t=="string"&&t in f?xn(r,f[t],e):t&&t instanceof m?xn(r,ll(t),e):t?.type&&t.type instanceof m?xn(r,ll(t.type),e):xn(r,f.NONE,e)}function xn(r,t,e=!0){let n=null;switch(t){case f.Null:n=r.visitNull;break;case f.Bool:n=r.visitBool;break;case f.Int:n=r.visitInt;break;case f.Int8:n=r.visitInt8||r.visitInt;break;case f.Int16:n=r.visitInt16||r.visitInt;break;case f.Int32:n=r.visitInt32||r.visitInt;break;case f.Int64:n=r.visitInt64||r.visitInt;break;case f.Uint8:n=r.visitUint8||r.visitInt;break;case f.Uint16:n=r.visitUint16||r.visitInt;break;case f.Uint32:n=r.visitUint32||r.visitInt;break;case f.Uint64:n=r.visitUint64||r.visitInt;break;case f.Float:n=r.visitFloat;break;case f.Float16:n=r.visitFloat16||r.visitFloat;break;case f.Float32:n=r.visitFloat32||r.visitFloat;break;case f.Float64:n=r.visitFloat64||r.visitFloat;break;case f.Utf8:n=r.visitUtf8;break;case f.LargeUtf8:n=r.visitLargeUtf8;break;case f.Binary:n=r.visitBinary;break;case f.LargeBinary:n=r.visitLargeBinary;break;case f.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case f.Date:n=r.visitDate;break;case f.DateDay:n=r.visitDateDay||r.visitDate;break;case f.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case f.Timestamp:n=r.visitTimestamp;break;case f.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case f.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case f.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case f.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case f.Time:n=r.visitTime;break;case f.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case f.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case f.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case f.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case f.Decimal:n=r.visitDecimal;break;case f.List:n=r.visitList;break;case f.Struct:n=r.visitStruct;break;case f.Union:n=r.visitUnion;break;case f.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case f.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case f.Dictionary:n=r.visitDictionary;break;case f.Interval:n=r.visitInterval;break;case f.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case f.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case f.Duration:n=r.visitDuration;break;case f.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case f.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case f.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case f.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case f.FixedSizeList:n=r.visitFixedSizeList;break;case f.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error(`Unrecognized type '${f[t]}'`)}function ll(r){switch(r.typeId){case f.Null:return f.Null;case f.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?f.Int8:f.Uint8;case 16:return e?f.Int16:f.Uint16;case 32:return e?f.Int32:f.Uint32;case 64:return e?f.Int64:f.Uint64}return f.Int}case f.Float:switch(r.precision){case j.HALF:return f.Float16;case j.SINGLE:return f.Float32;case j.DOUBLE:return f.Float64}return f.Float;case f.Binary:return f.Binary;case f.LargeBinary:return f.LargeBinary;case f.Utf8:return f.Utf8;case f.LargeUtf8:return f.LargeUtf8;case f.Bool:return f.Bool;case f.Decimal:return f.Decimal;case f.Time:switch(r.unit){case p.SECOND:return f.TimeSecond;case p.MILLISECOND:return f.TimeMillisecond;case p.MICROSECOND:return f.TimeMicrosecond;case p.NANOSECOND:return f.TimeNanosecond}return f.Time;case f.Timestamp:switch(r.unit){case p.SECOND:return f.TimestampSecond;case p.MILLISECOND:return f.TimestampMillisecond;case p.MICROSECOND:return f.TimestampMicrosecond;case p.NANOSECOND:return f.TimestampNanosecond}return f.Timestamp;case f.Date:switch(r.unit){case et.DAY:return f.DateDay;case et.MILLISECOND:return f.DateMillisecond}return f.Date;case f.Interval:switch(r.unit){case nt.DAY_TIME:return f.IntervalDayTime;case nt.YEAR_MONTH:return f.IntervalYearMonth}return f.Interval;case f.Duration:switch(r.unit){case p.SECOND:return f.DurationSecond;case p.MILLISECOND:return f.DurationMillisecond;case p.MICROSECOND:return f.DurationMicrosecond;case p.NANOSECOND:return f.DurationNanosecond}return f.Duration;case f.Map:return f.Map;case f.List:return f.List;case f.Struct:return f.Struct;case f.Union:switch(r.mode){case K.Dense:return f.DenseUnion;case K.Sparse:return f.SparseUnion}return f.Union;case f.FixedSizeBinary:return f.FixedSizeBinary;case f.FixedSizeList:return f.FixedSizeList;case f.Dictionary:return f.Dictionary}throw new Error(`Unrecognized type '${f[r.typeId]}'`)}v.prototype.visitInt8=null;v.prototype.visitInt16=null;v.prototype.visitInt32=null;v.prototype.visitInt64=null;v.prototype.visitUint8=null;v.prototype.visitUint16=null;v.prototype.visitUint32=null;v.prototype.visitUint64=null;v.prototype.visitFloat16=null;v.prototype.visitFloat32=null;v.prototype.visitFloat64=null;v.prototype.visitDateDay=null;v.prototype.visitDateMillisecond=null;v.prototype.visitTimestampSecond=null;v.prototype.visitTimestampMillisecond=null;v.prototype.visitTimestampMicrosecond=null;v.prototype.visitTimestampNanosecond=null;v.prototype.visitTimeSecond=null;v.prototype.visitTimeMillisecond=null;v.prototype.visitTimeMicrosecond=null;v.prototype.visitTimeNanosecond=null;v.prototype.visitDenseUnion=null;v.prototype.visitSparseUnion=null;v.prototype.visitIntervalDayTime=null;v.prototype.visitIntervalYearMonth=null;v.prototype.visitDuration=null;v.prototype.visitDurationSecond=null;v.prototype.visitDurationMillisecond=null;v.prototype.visitDurationMicrosecond=null;v.prototype.visitDurationNanosecond=null;var sa={};Ir(sa,{float64ToUint16:()=>ni,uint16ToFloat64:()=>ws});var ul=new Float64Array(1),Sn=new Uint32Array(ul.buffer);function ws(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 ni(r){if(r!==r)return 32256;ul[0]=r;let t=(Sn[1]&2147483648)>>16&65535,e=Sn[1]&2146435072,n=0;return e>=1089470464?Sn[0]>0?e=31744:(e=(e&2080374784)>>16,n=(Sn[1]&1048575)>>10):e<=1056964608?(n=1048576+(Sn[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(Sn[1]&1048575)+512>>10),t|e|n&65535}var A=class extends v{};function L(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}var ch=(r,t,e)=>{r[t]=Math.trunc(e/864e5)},oa=(r,t,e)=>{r[t]=Math.trunc(e%4294967296),r[t+1]=Math.trunc(e/4294967296)},lh=(r,t,e)=>{r[t]=Math.trunc(e*1e3%4294967296),r[t+1]=Math.trunc(e*1e3/4294967296)},uh=(r,t,e)=>{r[t]=Math.trunc(e*1e6%4294967296),r[t+1]=Math.trunc(e*1e6/4294967296)},fl=(r,t,e,n)=>{if(e+1<t.length){let i=at(t[e]),s=at(t[e+1]);r.set(n.subarray(0,s-i),i)}},fh=({offset:r,values:t},e,n)=>{let i=r+e;n?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},cr=({values:r},t,e)=>{r[t]=e},aa=({values:r},t,e)=>{r[t]=e},hl=({values:r},t,e)=>{r[t]=ni(e)},hh=(r,t,e)=>{switch(r.type.precision){case j.HALF:return hl(r,t,e);case j.SINGLE:case j.DOUBLE:return aa(r,t,e)}},_s=({values:r},t,e)=>{ch(r,t,e.valueOf())},vs=({values:r},t,e)=>{oa(r,t*2,e.valueOf())},ca=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},dl=({values:r,valueOffsets:t},e,n)=>fl(r,t,e,n),pl=({values:r,valueOffsets:t},e,n)=>fl(r,t,e,Ce(n)),la=(r,t,e)=>{r.type.unit===et.DAY?_s(r,t,e):vs(r,t,e)},Is=({values:r},t,e)=>oa(r,t*2,e/1e3),xs=({values:r},t,e)=>oa(r,t*2,e),Ss=({values:r},t,e)=>lh(r,t*2,e),Bs=({values:r},t,e)=>uh(r,t*2,e),ua=(r,t,e)=>{switch(r.type.unit){case p.SECOND:return Is(r,t,e);case p.MILLISECOND:return xs(r,t,e);case p.MICROSECOND:return Ss(r,t,e);case p.NANOSECOND:return Bs(r,t,e)}},As=({values:r},t,e)=>{r[t]=e},Ts=({values:r},t,e)=>{r[t]=e},Ds=({values:r},t,e)=>{r[t]=e},Os=({values:r},t,e)=>{r[t]=e},fa=(r,t,e)=>{switch(r.type.unit){case p.SECOND:return As(r,t,e);case p.MILLISECOND:return Ts(r,t,e);case p.MICROSECOND:return Ds(r,t,e);case p.NANOSECOND:return Os(r,t,e)}},ha=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},dh=(r,t,e)=>{let n=r.children[0],i=r.valueOffsets,s=Dt.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))},ph=(r,t,e)=>{let n=r.children[0],{valueOffsets:i}=r,s=Dt.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},mh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[s]),yh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(s)),gh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(i.name)),bh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[i.name]),wh=(r,t,e)=>{let n=r.type.children.map(s=>Dt.getVisitFn(s.type)),i=e instanceof Map?gh(t,e):e instanceof g?yh(t,e):Array.isArray(e)?mh(t,e):bh(t,e);r.type.children.forEach((s,o)=>i(n[o],r.children[o],s,o))},_h=(r,t,e)=>{r.type.mode===K.Dense?ml(r,t,e):yl(r,t,e)},ml=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Dt.visit(i,r.valueOffsets[t],e)},yl=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Dt.visit(i,t,e)},vh=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},da=(r,t,e)=>{r.type.unit===nt.DAY_TIME?Fs(r,t,e):Ms(r,t,e)},Fs=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},Ms=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},Ls=({values:r},t,e)=>{r[t]=e},Ns=({values:r},t,e)=>{r[t]=e},Us=({values:r},t,e)=>{r[t]=e},Es=({values:r},t,e)=>{r[t]=e},pa=(r,t,e)=>{switch(r.type.unit){case p.SECOND:return Ls(r,t,e);case p.MILLISECOND:return Ns(r,t,e);case p.MICROSECOND:return Us(r,t,e);case p.NANOSECOND:return Es(r,t,e)}},Ih=(r,t,e)=>{let{stride:n}=r,i=r.children[0],s=Dt.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))};A.prototype.visitBool=L(fh);A.prototype.visitInt=L(cr);A.prototype.visitInt8=L(cr);A.prototype.visitInt16=L(cr);A.prototype.visitInt32=L(cr);A.prototype.visitInt64=L(cr);A.prototype.visitUint8=L(cr);A.prototype.visitUint16=L(cr);A.prototype.visitUint32=L(cr);A.prototype.visitUint64=L(cr);A.prototype.visitFloat=L(hh);A.prototype.visitFloat16=L(hl);A.prototype.visitFloat32=L(aa);A.prototype.visitFloat64=L(aa);A.prototype.visitUtf8=L(pl);A.prototype.visitLargeUtf8=L(pl);A.prototype.visitBinary=L(dl);A.prototype.visitLargeBinary=L(dl);A.prototype.visitFixedSizeBinary=L(ca);A.prototype.visitDate=L(la);A.prototype.visitDateDay=L(_s);A.prototype.visitDateMillisecond=L(vs);A.prototype.visitTimestamp=L(ua);A.prototype.visitTimestampSecond=L(Is);A.prototype.visitTimestampMillisecond=L(xs);A.prototype.visitTimestampMicrosecond=L(Ss);A.prototype.visitTimestampNanosecond=L(Bs);A.prototype.visitTime=L(fa);A.prototype.visitTimeSecond=L(As);A.prototype.visitTimeMillisecond=L(Ts);A.prototype.visitTimeMicrosecond=L(Ds);A.prototype.visitTimeNanosecond=L(Os);A.prototype.visitDecimal=L(ha);A.prototype.visitList=L(dh);A.prototype.visitStruct=L(wh);A.prototype.visitUnion=L(_h);A.prototype.visitDenseUnion=L(ml);A.prototype.visitSparseUnion=L(yl);A.prototype.visitDictionary=L(vh);A.prototype.visitInterval=L(da);A.prototype.visitIntervalDayTime=L(Fs);A.prototype.visitIntervalYearMonth=L(Ms);A.prototype.visitDuration=L(pa);A.prototype.visitDurationSecond=L(Ls);A.prototype.visitDurationMillisecond=L(Ns);A.prototype.visitDurationMicrosecond=L(Us);A.prototype.visitDurationNanosecond=L(Es);A.prototype.visitFixedSizeList=L(Ih);A.prototype.visitMap=L(ph);var Dt=new A;var Ne=Symbol.for("parent"),Bn=Symbol.for("rowIndex"),Br=class{constructor(t,e){return this[Ne]=t,this[Bn]=e,new Proxy(this,new ya)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[Bn],e=this[Ne],n=e.type.children,i={};for(let s=-1,o=n.length;++s<o;)i[n[s].name]=mt.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 ma(this[Ne],this[Bn])}},ma=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,mt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(Br.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[Ne]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Bn]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var ya=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[Ne].type.children.map(e=>e.name)}has(t,e){return t[Ne].type.children.findIndex(n=>n.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[Ne].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[Ne].type.children.findIndex(i=>i.name===e);if(n!==-1){let i=mt.visit(t[Ne].children[n],t[Bn]);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[Ne].type.children.findIndex(s=>s.name===e);return i!==-1?(Dt.visit(t[Ne].children[i],t[Bn],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}};var I=class extends v{};function O(r){return(t,e)=>t.getValid(e)?r(t,e):null}var xh=(r,t)=>864e5*r[t],ga=(r,t)=>4294967296*r[t+1]+(r[t]>>>0),Sh=(r,t)=>4294967296*(r[t+1]/1e3)+(r[t]>>>0)/1e3,Bh=(r,t)=>4294967296*(r[t+1]/1e6)+(r[t]>>>0)/1e6,gl=r=>new Date(r),Ah=(r,t)=>gl(xh(r,t)),Th=(r,t)=>gl(ga(r,t)),Dh=(r,t)=>null,bl=(r,t,e)=>{if(e+1>=t.length)return null;let n=at(t[e]),i=at(t[e+1]);return r.subarray(n,i)},Oh=({offset:r,values:t},e)=>{let n=r+e;return(t[n>>3]&1<<n%8)!==0},wl=({values:r},t)=>Ah(r,t),_l=({values:r},t)=>Th(r,t*2),Ar=({stride:r,values:t},e)=>t[r*e],Fh=({stride:r,values:t},e)=>ws(t[r*e]),vl=({values:r},t)=>r[t],Mh=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Il=({values:r,valueOffsets:t},e)=>bl(r,t,e),xl=({values:r,valueOffsets:t},e)=>{let n=bl(r,t,e);return n!==null?Zn(n):null},Lh=({values:r},t)=>r[t],Nh=({type:r,values:t},e)=>r.precision!==j.HALF?t[e]:ws(t[e]),Uh=(r,t)=>r.type.unit===et.DAY?wl(r,t):_l(r,t),Sl=({values:r},t)=>1e3*ga(r,t*2),Bl=({values:r},t)=>ga(r,t*2),Al=({values:r},t)=>Sh(r,t*2),Tl=({values:r},t)=>Bh(r,t*2),Eh=(r,t)=>{switch(r.type.unit){case p.SECOND:return Sl(r,t);case p.MILLISECOND:return Bl(r,t);case p.MICROSECOND:return Al(r,t);case p.NANOSECOND:return Tl(r,t)}},Dl=({values:r},t)=>r[t],Ol=({values:r},t)=>r[t],Fl=({values:r},t)=>r[t],Ml=({values:r},t)=>r[t],Rh=(r,t)=>{switch(r.type.unit){case p.SECOND:return Dl(r,t);case p.MILLISECOND:return Ol(r,t);case p.MICROSECOND:return Fl(r,t);case p.NANOSECOND:return Ml(r,t)}},Ch=({values:r,stride:t},e)=>Er.decimal(r.subarray(t*e,t*(e+1))),Ph=(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 g([c])},kh=(r,t)=>{let{valueOffsets:e,children:n}=r,{[t]:i,[t+1]:s}=e,o=n[0];return new qe(o.slice(i,s-i))},Vh=(r,t)=>new Br(r,t),jh=(r,t)=>r.type.mode===K.Dense?Ll(r,t):Nl(r,t),Ll=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return mt.visit(n,r.valueOffsets[t])},Nl=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return mt.visit(n,t)},zh=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},Wh=(r,t)=>r.type.unit===nt.DAY_TIME?Ul(r,t):El(r,t),Ul=({values:r},t)=>r.subarray(2*t,2*(t+1)),El=({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},Rl=({values:r},t)=>r[t],Cl=({values:r},t)=>r[t],Pl=({values:r},t)=>r[t],kl=({values:r},t)=>r[t],Gh=(r,t)=>{switch(r.type.unit){case p.SECOND:return Rl(r,t);case p.MILLISECOND:return Cl(r,t);case p.MICROSECOND:return Pl(r,t);case p.NANOSECOND:return kl(r,t)}},$h=(r,t)=>{let{stride:e,children:n}=r,s=n[0].slice(t*e,e);return new g([s])};I.prototype.visitNull=O(Dh);I.prototype.visitBool=O(Oh);I.prototype.visitInt=O(Lh);I.prototype.visitInt8=O(Ar);I.prototype.visitInt16=O(Ar);I.prototype.visitInt32=O(Ar);I.prototype.visitInt64=O(vl);I.prototype.visitUint8=O(Ar);I.prototype.visitUint16=O(Ar);I.prototype.visitUint32=O(Ar);I.prototype.visitUint64=O(vl);I.prototype.visitFloat=O(Nh);I.prototype.visitFloat16=O(Fh);I.prototype.visitFloat32=O(Ar);I.prototype.visitFloat64=O(Ar);I.prototype.visitUtf8=O(xl);I.prototype.visitLargeUtf8=O(xl);I.prototype.visitBinary=O(Il);I.prototype.visitLargeBinary=O(Il);I.prototype.visitFixedSizeBinary=O(Mh);I.prototype.visitDate=O(Uh);I.prototype.visitDateDay=O(wl);I.prototype.visitDateMillisecond=O(_l);I.prototype.visitTimestamp=O(Eh);I.prototype.visitTimestampSecond=O(Sl);I.prototype.visitTimestampMillisecond=O(Bl);I.prototype.visitTimestampMicrosecond=O(Al);I.prototype.visitTimestampNanosecond=O(Tl);I.prototype.visitTime=O(Rh);I.prototype.visitTimeSecond=O(Dl);I.prototype.visitTimeMillisecond=O(Ol);I.prototype.visitTimeMicrosecond=O(Fl);I.prototype.visitTimeNanosecond=O(Ml);I.prototype.visitDecimal=O(Ch);I.prototype.visitList=O(Ph);I.prototype.visitStruct=O(Vh);I.prototype.visitUnion=O(jh);I.prototype.visitDenseUnion=O(Ll);I.prototype.visitSparseUnion=O(Nl);I.prototype.visitDictionary=O(zh);I.prototype.visitInterval=O(Wh);I.prototype.visitIntervalDayTime=O(Ul);I.prototype.visitIntervalYearMonth=O(El);I.prototype.visitDuration=O(Gh);I.prototype.visitDurationSecond=O(Rl);I.prototype.visitDurationMillisecond=O(Cl);I.prototype.visitDurationMicrosecond=O(Pl);I.prototype.visitDurationNanosecond=O(kl);I.prototype.visitFixedSizeList=O($h);I.prototype.visitMap=O(kh);var mt=new I;var xe=Symbol.for("keys"),An=Symbol.for("vals"),qe=class{constructor(t){return this[xe]=new g([t.children[0]]).memoize(),this[An]=t.children[1],new Proxy(this,new wa)}[Symbol.iterator](){return new ba(this[xe],this[An])}get size(){return this[xe].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[xe],e=this[An],n={};for(let i=-1,s=t.length;++i<s;)n[t.get(i)]=mt.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()}},ba=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),mt.visit(this.vals,t)]})}},wa=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[xe].toArray().map(String)}has(t,e){return t[xe].includes(e)}getOwnPropertyDescriptor(t,e){if(t[xe].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[xe].indexOf(e);if(n!==-1){let i=mt.visit(Reflect.get(t,An),n);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[xe].indexOf(e);return i!==-1?(Dt.visit(Reflect.get(t,An),i,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}};Object.defineProperties(qe.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[xe]:{writable:!0,enumerable:!1,configurable:!1,value:null},[An]:{writable:!0,enumerable:!1,configurable:!1,value:null}});function Hh(r,t,e){let n=r.length,i=t>-1?t:n+t%n;return e?e(r,i):i}var Vl;function ii(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&&(Vl=s,s=o,o=Vl),o>i&&(o=i),n?n(r,s,o):[s,o]}var jl=r=>r!==r;function Tr(r){if(typeof r!=="object"||r===null)return jl(r)?jl: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?Qo(r,e):!1:r instanceof Map?Kh(r):Array.isArray(r)?Yh(r):r instanceof g?Zh(r):Jh(r,!0)}function Yh(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Tr(r[e]);return Rs(t)}function Kh(r){let t=-1,e=[];for(let n of r.values())e[++t]=Tr(n);return Rs(e)}function Zh(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Tr(r.get(e));return Rs(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]=Tr(r[e[i]]);return Rs(n,e)}function Rs(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return Xh(r,e);case Map:return zl(r,e,e.keys());case qe:case Br:case Object:case void 0:return zl(r,e,t||Object.keys(e))}return e instanceof g?Qh(r,e):!1}}function Xh(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 Qh(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 zl(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 va={};Ir(va,{BitIterator:()=>Yr,getBit:()=>Wl,getBool:()=>Ps,packBools:()=>Zr,popcnt_array:()=>Gl,popcnt_bit_range:()=>si,popcnt_uint32:()=>Cs,setBool:()=>qh,truncateBitmap:()=>Kr});function Ps(r,t,e,n){return(e&1<<n)!==0}function Wl(r,t,e,n){return(e&1<<n)>>n}function qh(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function Kr(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):Zr(new Yr(e,r,t,null,Ps)).subarray(0,n)),i}return e}function Zr(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 Yr=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 si(r,t,e){if(e-t<=0)return 0;if(e-t<8){let s=0;for(let o of new Yr(r,t,e-t,r,Wl))s+=o;return s}let n=e>>3<<3,i=t+(t%8===0?0:8-t%8);return si(r,t,i)+si(r,n,e)+Gl(r,i>>3,n-i>>3)}function Gl(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+=Cs(s.getUint32(i)),i+=4;for(;o-i>=2;)n+=Cs(s.getUint16(i)),i+=2;for(;o-i>=1;)n+=Cs(s.getUint8(i)),i+=1;return n}function Cs(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 td=-1,R=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<=td&&(e=this.nullBitmap)&&(this._nullCount=t=this.length-si(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 R?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=he(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===K.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===K.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(Kr(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s,_nullCount:-1}));let h=s[u];n=(h&l)!==0,e?s[u]=h|l:s[u]=h&~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 R(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===f.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(Kr(this.offset,e,this.nullBitmap),0);let s=this.buffers;return s[lt.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[lt.TYPE])&&(o[lt.TYPE]=s.subarray(t,t+e)),(s=o[lt.OFFSET])&&(o[lt.OFFSET]=s.subarray(t,t+e+1))||(s=o[lt.DATA])&&(o[lt.DATA]=i===6?s:s.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map(i=>i.slice(e,n))}};R.prototype.children=Object.freeze([]);var Jr=class extends v{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:e,["offset"]:n=0,["length"]:i=0}=t;return new R(e,n,i,i)}visitBool(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new R(e,n,o,a,[void 0,s,i])}visitInt(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new R(e,n,o,a,[void 0,s,i])}visitFloat(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new R(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=Ur(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new R(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=ds(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new R(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=Ur(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new R(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=ds(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new R(e,n,a,c,[o,i,s])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length/he(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new R(e,n,o,a,[void 0,s,i])}visitDate(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length/he(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new R(e,n,o,a,[void 0,s,i])}visitTimestamp(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length/he(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new R(e,n,o,a,[void 0,s,i])}visitTime(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length/he(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new R(e,n,o,a,[void 0,s,i])}visitDecimal(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length/he(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new R(e,n,o,a,[void 0,s,i])}visitList(t){let{["type"]:e,["offset"]:n=0,["child"]:i}=t,s=T(t.nullBitmap),o=Ur(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new R(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 R(e,n,o,a,[void 0,void 0,s],i)}visitUnion(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=C(e.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=t;if(m.isSparseUnion(e))return new R(e,n,o,a,[void 0,void 0,void 0,s],i);let c=Ur(t.valueOffsets);return new R(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=C(e.indices.ArrayType,t.data),{["dictionary"]:o=new g([new Jr().visit({type:e.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new R(e,n,a,c,[void 0,s,i],[],o)}visitInterval(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length/he(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new R(e,n,o,a,[void 0,s,i])}visitDuration(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new R(e,n,o,a,[void 0,s,i])}visitFixedSizeList(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new Jr().visit({type:e.valueType})}=t,s=T(t.nullBitmap),{["length"]:o=i.length/he(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new R(e,n,o,a,[void 0,void 0,s],[i])}visitMap(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new Jr().visit({type:e.childType})}=t,s=T(t.nullBitmap),o=Ur(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new R(e,n,a,c,[o,void 0,s],[i])}},ed=new Jr;function w(r){return ed.visit(r)}var oi=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 $l(r){return r.some(t=>t.nullable)}function ks(r){return r.reduce((t,e)=>t+e.nullCount,0)}function Vs(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function js(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),h=Math.min(n-c,l);i.push(a.slice(u,h-u))}return i.length===0&&i.push(r[0].slice(0,0)),i}function Ia(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 ai(r,t){return r.getValid(t)}function Tn(r){function t(e,n,i){return r(e[n],i)}return function(e){let n=this.data;return Ia(n,this._offsets,e,t)}}function zs(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=Ia(s,this._offsets,n,e);return t=void 0,o}}function Ws(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 h=n[l];if(~(a=r(h,t,o)))return c+a;o=0,c+=h.length}return-1}return function(n,i){t=n;let s=this.data,o=typeof i!="number"?e(s,0,0):Ia(s,this._offsets,i,e);return t=void 0,o}}var x=class extends v{};function rd(r,t){return t===null&&r.length>0?0:-1}function nd(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(let i of new Yr(e,r.offset+(t||0),r.length,e,Ps)){if(!i)return n;++n}return-1}function N(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case f.Union:break;case f.Dictionary:break;default:return nd(r,e)}let n=mt.getVisitFn(r),i=Tr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}function Hl(r,t,e){let n=mt.getVisitFn(r),i=Tr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}x.prototype.visitNull=rd;x.prototype.visitBool=N;x.prototype.visitInt=N;x.prototype.visitInt8=N;x.prototype.visitInt16=N;x.prototype.visitInt32=N;x.prototype.visitInt64=N;x.prototype.visitUint8=N;x.prototype.visitUint16=N;x.prototype.visitUint32=N;x.prototype.visitUint64=N;x.prototype.visitFloat=N;x.prototype.visitFloat16=N;x.prototype.visitFloat32=N;x.prototype.visitFloat64=N;x.prototype.visitUtf8=N;x.prototype.visitLargeUtf8=N;x.prototype.visitBinary=N;x.prototype.visitLargeBinary=N;x.prototype.visitFixedSizeBinary=N;x.prototype.visitDate=N;x.prototype.visitDateDay=N;x.prototype.visitDateMillisecond=N;x.prototype.visitTimestamp=N;x.prototype.visitTimestampSecond=N;x.prototype.visitTimestampMillisecond=N;x.prototype.visitTimestampMicrosecond=N;x.prototype.visitTimestampNanosecond=N;x.prototype.visitTime=N;x.prototype.visitTimeSecond=N;x.prototype.visitTimeMillisecond=N;x.prototype.visitTimeMicrosecond=N;x.prototype.visitTimeNanosecond=N;x.prototype.visitDecimal=N;x.prototype.visitList=N;x.prototype.visitStruct=N;x.prototype.visitUnion=N;x.prototype.visitDenseUnion=Hl;x.prototype.visitSparseUnion=Hl;x.prototype.visitDictionary=N;x.prototype.visitInterval=N;x.prototype.visitIntervalDayTime=N;x.prototype.visitIntervalYearMonth=N;x.prototype.visitDuration=N;x.prototype.visitDurationSecond=N;x.prototype.visitDurationMillisecond=N;x.prototype.visitDurationMicrosecond=N;x.prototype.visitDurationNanosecond=N;x.prototype.visitFixedSizeList=N;x.prototype.visitMap=N;var Xr=new x;var S=class extends v{};function F(r){let{type:t}=r;if(r.nullCount===0&&r.stride===1&&(t.typeId===f.Timestamp||t instanceof it&&t.bitWidth!==64||t instanceof xt&&t.bitWidth!==64||t instanceof At&&t.precision!==j.HALF))return new oi(r.data.length,n=>{let i=r.data[n];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new oi(r.data.length,n=>{let s=r.data[n].length,o=r.slice(e,e+s);return e+=s,new xa(o)})}var xa=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}};S.prototype.visitNull=F;S.prototype.visitBool=F;S.prototype.visitInt=F;S.prototype.visitInt8=F;S.prototype.visitInt16=F;S.prototype.visitInt32=F;S.prototype.visitInt64=F;S.prototype.visitUint8=F;S.prototype.visitUint16=F;S.prototype.visitUint32=F;S.prototype.visitUint64=F;S.prototype.visitFloat=F;S.prototype.visitFloat16=F;S.prototype.visitFloat32=F;S.prototype.visitFloat64=F;S.prototype.visitUtf8=F;S.prototype.visitLargeUtf8=F;S.prototype.visitBinary=F;S.prototype.visitLargeBinary=F;S.prototype.visitFixedSizeBinary=F;S.prototype.visitDate=F;S.prototype.visitDateDay=F;S.prototype.visitDateMillisecond=F;S.prototype.visitTimestamp=F;S.prototype.visitTimestampSecond=F;S.prototype.visitTimestampMillisecond=F;S.prototype.visitTimestampMicrosecond=F;S.prototype.visitTimestampNanosecond=F;S.prototype.visitTime=F;S.prototype.visitTimeSecond=F;S.prototype.visitTimeMillisecond=F;S.prototype.visitTimeMicrosecond=F;S.prototype.visitTimeNanosecond=F;S.prototype.visitDecimal=F;S.prototype.visitList=F;S.prototype.visitStruct=F;S.prototype.visitUnion=F;S.prototype.visitDenseUnion=F;S.prototype.visitSparseUnion=F;S.prototype.visitDictionary=F;S.prototype.visitInterval=F;S.prototype.visitIntervalDayTime=F;S.prototype.visitIntervalYearMonth=F;S.prototype.visitDuration=F;S.prototype.visitDurationSecond=F;S.prototype.visitDurationMillisecond=F;S.prototype.visitDurationMicrosecond=F;S.prototype.visitDurationNanosecond=F;S.prototype.visitFixedSizeList=F;S.prototype.visitMap=F;var Dn=new S;var Yl,Kl={},Zl={},g=class{constructor(t){var e,n,i;let s=t[0]instanceof g?t.flatMap(a=>a.data):t;if(s.length===0||s.some(a=>!(a instanceof R)))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}=Kl[o.typeId],u=s[0];this.isValid=h=>ai(u,h),this.get=h=>a(u,h),this.set=(h,d)=>c(u,h,d),this.indexOf=h=>l(u,h),this._offsets=[0,u.length];break}default:Object.setPrototypeOf(this,Zl[o.typeId]),this._offsets=Vs(s);break}this.data=s,this.type=o,this.stride=he(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 $l(this.data)}get nullCount(){return ks(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${f[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}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 g(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new g(ii(this,t,e,({data:n,_offsets:i},s,o)=>js(n,i,s,o)))}toJSON(){return[...this]}toArray(){let{type:t,data:e,length:n,stride:i,ArrayType:s}=this;switch(t.typeId){case f.Int:case f.Float:case f.Decimal:case f.Time:case f.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 g(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 On(this.data[0].dictionary),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new g(e)}return new On(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 g(e)}return this}};Yl=Symbol.toStringTag;g[Yl]=(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(f).map(e=>f[e]).filter(e=>typeof e=="number"&&e!==f.NONE);for(let e of t){let n=mt.getVisitFnByTypeId(e),i=Dt.getVisitFnByTypeId(e),s=Xr.getVisitFnByTypeId(e);Kl[e]={get:n,set:i,indexOf:s},Zl[e]=Object.create(r,{isValid:{value:Tn(ai)},get:{value:Tn(mt.getVisitFnByTypeId(e))},set:{value:zs(Dt.getVisitFnByTypeId(e))},indexOf:{value:Ws(Xr.getVisitFnByTypeId(e))}})}return"Vector"})(g.prototype);var On=class extends g{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 On(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new g(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function Dr(r){if(r){if(r instanceof R)return new g([r]);if(r instanceof g)return new g(r.data);if(r.type instanceof m)return new g([w(r)]);if(Array.isArray(r))return new g(r.flatMap(t=>id(t)));if(ArrayBuffer.isView(r)){r instanceof DataView&&(r=new Uint8Array(r.buffer));let t={offset:0,length:r.length,nullCount:0,data:r};if(r instanceof Int8Array)return new g([w(Object.assign(Object.assign({},t),{type:new ye}))]);if(r instanceof Int16Array)return new g([w(Object.assign(Object.assign({},t),{type:new ge}))]);if(r instanceof Int32Array)return new g([w(Object.assign(Object.assign({},t),{type:new pt}))]);if(r instanceof BigInt64Array)return new g([w(Object.assign(Object.assign({},t),{type:new be}))]);if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return new g([w(Object.assign(Object.assign({},t),{type:new we}))]);if(r instanceof Uint16Array)return new g([w(Object.assign(Object.assign({},t),{type:new _e}))]);if(r instanceof Uint32Array)return new g([w(Object.assign(Object.assign({},t),{type:new ve}))]);if(r instanceof BigUint64Array)return new g([w(Object.assign(Object.assign({},t),{type:new Ke}))]);if(r instanceof Float32Array)return new g([w(Object.assign(Object.assign({},t),{type:new Xt}))]);if(r instanceof Float64Array)return new g([w(Object.assign(Object.assign({},t),{type:new Qt}))]);throw new Error("Unrecognized input")}}throw new Error("Unrecognized input")}function id(r){return r instanceof R?[r]:r instanceof g?r.data:Dr(r).data}function Jl(r){if(!r||r.length<=0)return function(i){return!0};let t="",e=r.filter(n=>n===n);return e.length>0&&(t=`
7
+ "use strict";var __exports__=(()=>{var df=Object.create;var Xn=Object.defineProperty;var pf=Object.getOwnPropertyDescriptor;var mf=Object.getOwnPropertyNames;var yf=Object.getPrototypeOf,gf=Object.prototype.hasOwnProperty;var bf=(r,t,e)=>t in r?Xn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var wf=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Ir=(r,t)=>{for(var e in t)Xn(r,e,{get:t[e],enumerable:!0})},es=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of mf(t))!gf.call(r,i)&&i!==e&&Xn(r,i,{get:()=>t[i],enumerable:!(n=pf(t,i))||n.enumerable});return r},rs=(r,t,e)=>(es(r,t,"default"),e&&es(e,t,"default")),_f=(r,t,e)=>(e=r!=null?df(yf(r)):{},es(t||!r||!r.__esModule?Xn(e,"default",{value:r,enumerable:!0}):e,r)),vf=r=>es(Xn({},"__esModule",{value:!0}),r);var ns=(r,t,e)=>(bf(r,typeof t!="symbol"?t+"":t,e),e);var Bc=wf((Fm,Sc)=>{Sc.exports=globalThis.loaders});var ts={};Ir(ts,{ArrowLoader:()=>Ju,ArrowWorkerLoader:()=>Wn,ArrowWriter:()=>Xu,GeoArrowLoader:()=>qu,GeoArrowWorkerLoader:()=>$o,TriangulationWorker:()=>Zo,VECTOR_TYPES:()=>Ur,convertArrowToSchema:()=>Hn,convertArrowToTable:()=>Yn,convertSchemaToArrow:()=>Pu,convertTableToArrow:()=>tf,deserializeArrowField:()=>hn,deserializeArrowMetadata:()=>ko,deserializeArrowSchema:()=>Ki,deserializeArrowType:()=>oc,getBinaryGeometriesFromArrow:()=>ef,getBinaryGeometryTemplate:()=>Ji,getMeanCentersFromBinaryGeometries:()=>gc,getTriangleIndices:()=>bc,hardClone:()=>Xi,parseGeoArrowOnWorker:()=>hf,parseGeometryFromArrow:()=>Wo,serializeArrowField:()=>fn,serializeArrowMetadata:()=>Po,serializeArrowSchema:()=>ic,serializeArrowType:()=>sc,triangulateOnWorker:()=>ff,updateBoundsFromGeoArrowSamples:()=>Ho});rs(ts,_f(Bc(),1));var Ur;(function(r){r[r.FLOAT=0]="FLOAT",r[r.DATE=1]="DATE"})(Ur||(Ur={}));function is(r,t="float32"){return r instanceof Date?"date-millisecond":r instanceof Number?t:typeof r=="string"?"utf8":(r===null||r==="undefined","null")}function Ac(r){let t=If(r);return t!=="null"?{type:t,nullable:!1}:r.length>0?(t=is(r[0]),{type:t,nullable:!0}):{type:"null",nullable:!0}}function If(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 Tc(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}var ss=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}};function Dc(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 Oc(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 Fc(r){let t=[];for(let e=0;e<r.length;e++){let n=`column-${e}`;t.push(n)}return t}function Mc(r){return Object.keys(r)}var Lc=100,os=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 in t)this._headers[t[n].index]=t[n].name}}rowCount(){return this.length}addArrayRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this._headers||=Fc(t),this.options.shape){case"object-row-table":let n=Dc(t,this._headers);this.addObjectRow(n,e);break;case"array-row-table":this.arrayRows=this.arrayRows||new Array(Lc),this.arrayRows[this.length]=t,this.length++;break}}addObjectRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this._headers||=Mc(t),this.options.shape){case"array-row-table":let n=Oc(t,this._headers);this.addArrayRow(n,e);break;case"object-row-table":this.objectRows=this.objectRows||new Array(Lc),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}};var Er=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(){this._pruneColumns();let t=Array.isArray(this.schema)?this.columns:{};if(!Array.isArray(this.schema))for(let n in this.schema){let i=this.schema[n];t[i.name]=this.columns[i.index]}return this.columns={},{shape:"columnar-table",batchType:"data",data:t,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 t in this.schema){let e=this.schema[t],n=e.type||Float32Array,i=this.columns[e.index];if(i&&ArrayBuffer.isView(i)){let s=new n(this.allocated);s.set(i),this.columns[e.index]=s}else i?(i.length=this.allocated,this.columns[e.index]=i):this.columns[e.index]=new n(this.allocated)}}}_pruneColumns(){for(let[t,e]of Object.entries(this.columns))this.columns[t]=e.slice(0,this.length)}};var xf={shape:void 0,batchSize:"auto",batchDebounceMs:0,limit:0,_limitMB:0},Sf="TableBatchBuilder",as=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={...xf,...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 os;case"columnar-table":return Er;case"arrow-table":if(!as.ArrowBatch)throw new Error(Sf);return as.ArrowBatch;default:return ss}}},mn=as;ns(mn,"ArrowBatch");function xr(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 Jo(r){if(r.schema)return r.schema.fields.length;if(xr(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 Xo(r,t,e){switch(r.shape){case"array-row-table":let n=Nc(r,e);return r.data[t][n];case"object-row-table":return r.data[t][e];case"geojson-table":return r.features[t][e];case"columnar-table":return r.data[e][t];case"arrow-table":let s=r.data,o=s.schema.fields.findIndex(a=>a.name===e);return s.getChildAt(o)?.get(t);default:throw new Error("todo")}}function Qo(r,t,e){switch(r.shape){case"array-row-table":return r.data[t][e];case"object-row-table":let n=cs(r,e);return r.data[t][n];case"geojson-table":let i=cs(r,e);return r.features[t][i];case"columnar-table":let s=cs(r,e);return r.data[s][t];case"arrow-table":return r.data.getChildAt(e)?.get(t);default:throw new Error("todo")}}function Nc(r,t){let e=r.schema?.fields.findIndex(n=>n.name===t);if(e===void 0)throw new Error(t);return e}function cs(r,t){let e=r.schema?.fields[t]?.name;if(!e)throw new Error(`${t}`);return e}function qo(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 ta(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 Uc(r){switch(r.shape){case"array-row-table":case"object-row-table":return Af(r.data);case"geojson-table":return Tf(r.features);case"columnar-table":return Bf(r.data);case"arrow-table":default:throw new Error("Deduce schema")}}function Bf(r){let t=[];for(let[e,n]of Object.entries(r)){let i=Df(n,e);t.push(i)}return{fields:t,metadata:{}}}function Af(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(Ec(i,n));return{fields:t,metadata:{}}}function Tf(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(Ec(i,n));return{fields:t,metadata:{}}}function Df(r,t){if(ArrayBuffer.isView(r)){let e=Ac(r);return{name:t,type:e.type||"null",nullable:e.nullable}}if(Array.isArray(r)&&r.length>0){let e=r[0],n=is(e);return{name:t,type:n,nullable:!0}}throw new Error("empty table")}function Ec(r,t){let e=is(r);return{name:t,type:e,nullable:!0}}function Rc(r,t){let e=Tc(r.type,r.nullable);return new e(t)}function ls(r,t){switch(t){case"object-row-table":return Lf(r);case"array-row-table":return Mf(r);case"columnar-table":return Ff(r);case"arrow-table":return Of(r);default:throw new Error(t)}}function Of(r){let t=globalThis.__loaders?._makeArrowTable;if(!t)throw new Error("");return t(r)}function Ff(r){let t=r.schema||Uc(r),e=r.schema?.fields||[];if(r.shape==="columnar-table")return{...r,schema:t};let n=xr(r),i={};for(let s of e){let o=Rc(s,n);i[s.name]=o;for(let a=0;a<n;a++)o[a]=Xo(r,a,s.name)}return{shape:"columnar-table",schema:t,data:i}}function Mf(r){if(r.shape==="array-row-table")return r;let t=xr(r),e=new Array(t);for(let n=0;n<t;n++)e[n]=ta(r,n);return{shape:"array-row-table",schema:r.schema,data:e}}function Lf(r){if(r.shape==="object-row-table")return r;let t=xr(r),e=new Array(t);for(let n=0;n<t;n++)e[n]=qo(r,n);return{shape:"object-row-table",schema:r.schema,data:e}}function Pc(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 g(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(h){o(h)}}function c(u){try{l(n.throw(u))}catch(h){o(h)}}function l(u){u.done?s(u.value):i(u.value).then(a,c)}l((n=n.apply(r,t||[])).next())})}function Cc(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 E(r){return this instanceof E?(this.v=r,this):new E(r)}function ie(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(v){return Promise.resolve(v).then(p,h)}}function a(p,v){n[p]&&(i[p]=function(k){return new Promise(function(Z,et){s.push([p,k,Z,et])>1||c(p,k)})},v&&(i[p]=v(i[p])))}function c(p,v){try{l(n[p](v))}catch(k){d(s[0][3],k)}}function l(p){p.value instanceof E?Promise.resolve(p.value.v).then(u,h):d(s[0][2],p)}function u(p){c("next",p)}function h(p){c("throw",p)}function d(p,v){p(v),s.shift(),s.length&&c(s[0][0],s[0][1])}}function yn(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:E(r[i](o)),done:!1}:s?s(o):o}:s}}function ve(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 Cc=="function"?Cc(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 oa={};Ir(oa,{compareArrayLike:()=>sa,joinUint8Arrays:()=>oe,memcpy:()=>ti,rebaseValueOffsets:()=>gs,toArrayBufferView:()=>C,toArrayBufferViewAsyncIterator:()=>xe,toArrayBufferViewIterator:()=>Ue,toBigInt64Array:()=>ys,toBigUint64Array:()=>jf,toFloat32Array:()=>zf,toFloat32ArrayAsyncIterator:()=>ih,toFloat32ArrayIterator:()=>Jf,toFloat64Array:()=>Wf,toFloat64ArrayAsyncIterator:()=>sh,toFloat64ArrayIterator:()=>Xf,toInt16Array:()=>Pf,toInt16ArrayAsyncIterator:()=>th,toInt16ArrayIterator:()=>Hf,toInt32Array:()=>Rr,toInt32ArrayAsyncIterator:()=>eh,toInt32ArrayIterator:()=>Yf,toInt8Array:()=>Cf,toInt8ArrayAsyncIterator:()=>qf,toInt8ArrayIterator:()=>$f,toUint16Array:()=>kf,toUint16ArrayAsyncIterator:()=>rh,toUint16ArrayIterator:()=>Kf,toUint32Array:()=>Vf,toUint32ArrayAsyncIterator:()=>nh,toUint32ArrayIterator:()=>Zf,toUint8Array:()=>D,toUint8ArrayAsyncIterator:()=>ia,toUint8ArrayIterator:()=>na,toUint8ClampedArray:()=>Gf,toUint8ClampedArrayAsyncIterator:()=>oh,toUint8ClampedArrayIterator:()=>Qf});var Nf=new TextDecoder("utf-8"),Qn=r=>Nf.decode(r),Uf=new TextEncoder,Ne=r=>Uf.encode(r);var Ef=r=>typeof r=="number",kc=r=>typeof r=="boolean",bt=r=>typeof r=="function",Rt=r=>r!=null&&Object(r)===r,se=r=>Rt(r)&&bt(r.then);var Ie=r=>Rt(r)&&bt(r[Symbol.iterator]),fe=r=>Rt(r)&&bt(r[Symbol.asyncIterator]),us=r=>Rt(r)&&Rt(r.schema);var fs=r=>Rt(r)&&"done"in r&&"value"in r;var hs=r=>Rt(r)&&bt(r.stat)&&Ef(r.fd);var ds=r=>Rt(r)&&qn(r.body),ps=r=>"_getDOMStream"in r&&"_getNodeStream"in r,Vc=r=>Rt(r)&&bt(r.abort)&&bt(r.getWriter)&&!ps(r),qn=r=>Rt(r)&&bt(r.cancel)&&bt(r.getReader)&&!ps(r),jc=r=>Rt(r)&&bt(r.end)&&bt(r.write)&&kc(r.writable)&&!ps(r),ms=r=>Rt(r)&&bt(r.read)&&bt(r.pipe)&&kc(r.readable)&&!ps(r),zc=r=>Rt(r)&&bt(r.clear)&&bt(r.bytes)&&bt(r.position)&&bt(r.setPosition)&&bt(r.capacity)&&bt(r.getBufferIdentifier)&&bt(r.createLong);var ra=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Rf(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 ti(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 oe(r,t){let e=Rf(r),n=e.reduce((u,h)=>u+h.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?ti(o,s,a):o=s;break}ti(o||(o=new Uint8Array(l)),s,a),a+=s.length}return[o||new Uint8Array(0),e.slice(c),n-(o?o.byteLength:0)]}function C(r,t){let e=fs(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=Ne(e)),e instanceof ArrayBuffer?new r(e):e instanceof ra?new r(e):zc(e)?C(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 Cf=r=>C(Int8Array,r),Pf=r=>C(Int16Array,r),Rr=r=>C(Int32Array,r),ys=r=>C(BigInt64Array,r),D=r=>C(Uint8Array,r),kf=r=>C(Uint16Array,r),Vf=r=>C(Uint32Array,r),jf=r=>C(BigUint64Array,r),zf=r=>C(Float32Array,r),Wf=r=>C(Float64Array,r),Gf=r=>C(Uint8ClampedArray,r),ea=r=>(r.next(),r);function*Ue(r,t){let e=function*(i){yield i},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof ra?e(t):Ie(t)?t:e(t);return yield*ea(function*(i){let s=null;do s=i.next(yield C(r,s));while(!s.done)}(n[Symbol.iterator]())),new r}var $f=r=>Ue(Int8Array,r),Hf=r=>Ue(Int16Array,r),Yf=r=>Ue(Int32Array,r),na=r=>Ue(Uint8Array,r),Kf=r=>Ue(Uint16Array,r),Zf=r=>Ue(Uint32Array,r),Jf=r=>Ue(Float32Array,r),Xf=r=>Ue(Float64Array,r),Qf=r=>Ue(Uint8ClampedArray,r);function xe(r,t){return ie(this,arguments,function*(){if(se(t))return yield E(yield E(yield*yn(ve(xe(r,yield E(t))))));let n=function(o){return ie(this,arguments,function*(){yield yield E(yield E(o))})},i=function(o){return ie(this,arguments,function*(){yield E(yield*yn(ve(ea(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 ra?n(t):Ie(t)?i(t):fe(t)?t:n(t);return yield E(yield*yn(ve(ea(function(o){return ie(this,arguments,function*(){let a=null;do a=yield E(o.next(yield yield E(C(r,a))));while(!a.done)})}(s[Symbol.asyncIterator]()))))),yield E(new r)})}var qf=r=>xe(Int8Array,r),th=r=>xe(Int16Array,r),eh=r=>xe(Int32Array,r),ia=r=>xe(Uint8Array,r),rh=r=>xe(Uint16Array,r),nh=r=>xe(Uint32Array,r),ih=r=>xe(Float32Array,r),sh=r=>xe(Float64Array,r),oh=r=>xe(Uint8ClampedArray,r);function gs(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 sa(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 Bt={fromIterable(r){return bs(ah(r))},fromAsyncIterable(r){return bs(ch(r))},fromDOMStream(r){return bs(lh(r))},fromNodeStream(r){return bs(uh(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')}},bs=r=>(r.next(),r);function*ah(r){let t,e=!1,n=[],i,s,o,a=0;function c(){return s==="peek"?oe(n,o)[0]:([i,n,a]=oe(n,o),i)}({cmd:s,size:o}=(yield(()=>null)())||{cmd:"read",size:0});let l=na(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 ch(r){return ie(this,arguments,function*(){let e,n=!1,i=[],s,o,a,c=0;function l(){return o==="peek"?oe(i,a)[0]:([s,i,c]=oe(i,a),s)}({cmd:o,size:a}=(yield yield E((()=>null)()))||{cmd:"read",size:0});let u=ia(r)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(a-c)?yield E(u.next()):yield E(u.next(a-c)),!e&&s.byteLength>0&&(i.push(s),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield E(l()));while(a<c);while(!e)}catch(h){(n=!0)&&typeof u.throw=="function"&&(yield E(u.throw(h)))}finally{n===!1&&typeof u.return=="function"&&(yield E(u.return(new Uint8Array(0))))}return yield E(null)})}function lh(r){return ie(this,arguments,function*(){let e=!1,n=!1,i=[],s,o,a,c=0;function l(){return o==="peek"?oe(i,a)[0]:([s,i,c]=oe(i,a),s)}({cmd:o,size:a}=(yield yield E((()=>null)()))||{cmd:"read",size:0});let u=new ca(r);try{do if({done:e,value:s}=Number.isNaN(a-c)?yield E(u.read()):yield E(u.read(a-c)),!e&&s.byteLength>0&&(i.push(D(s)),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield E(l()));while(a<c);while(!e)}catch(h){(n=!0)&&(yield E(u.cancel(h)))}finally{n===!1?yield E(u.cancel()):r.locked&&u.releaseLock()}return yield E(null)})}var ca=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 g(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 g(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=D(e)),e})}},aa=(r,t)=>{let e=i=>n([t,i]),n;return[t,e,new Promise(i=>(n=i)&&r.once(t,e))]};function uh(r){return ie(this,arguments,function*(){let e=[],n="error",i=!1,s=null,o,a,c=0,l=[],u;function h(){return o==="peek"?oe(l,a)[0]:([u,l,c]=oe(l,a),u)}if({cmd:o,size:a}=(yield yield E((()=>null)()))||{cmd:"read",size:0},r.isTTY)return yield yield E(new Uint8Array(0)),yield E(null);try{e[0]=aa(r,"end"),e[1]=aa(r,"error");do{if(e[2]=aa(r,"readable"),[n,s]=yield E(Promise.race(e.map(p=>p[2]))),n==="error")break;if((i=n==="end")||(Number.isFinite(a-c)?(u=D(r.read(a-c)),u.byteLength<a-c&&(u=D(r.read()))):u=D(r.read()),u.byteLength>0&&(l.push(u),c+=u.byteLength)),i||a<=c)do({cmd:o,size:a}=yield yield E(h()));while(a<c)}while(!i)}finally{yield E(d(e,n==="error"?s:null))}return yield E(null);function d(p,v){return u=l=null,new Promise((k,Z)=>{for(let[et,pn]of p)r.off(et,pn);try{let et=r.destroy;et&&et.call(r,v),v=void 0}catch(et){v=et||v}finally{v!=null?Z(v):k()}})}})}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 J;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(J||(J={}));var z;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(z||(z={}));var rt;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(rt||(rt={}));var m;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(m||(m={}));var it;(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"})(it||(it={}));var Ee=new Int32Array(2),ws=new Float32Array(Ee.buffer),_s=new Float64Array(Ee.buffer),gn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var ei;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(ei||(ei={}));var Ct=class{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new Ct(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 Ee[0]=this.readInt32(t),ws[0]}readFloat64(t){return Ee[gn?0:1]=this.readInt32(t),Ee[gn?1:0]=this.readInt32(t+4),_s[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){ws[0]=e,this.writeInt32(t,Ee[0])}writeFloat64(t,e){_s[0]=e,this.writeInt32(t,Ee[gn?0:1]),this.writeInt32(t+4,Ee[gn?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===ei.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 ar=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=Ct.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=ar.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=Ct.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;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);for(let n=0,i=this.space,s=this.bb.bytes();n<e.length;n++)s[i++]=e[n];return 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 ri;(function(r){r[r.BUFFER=0]="BUFFER"})(ri||(ri={}));var ni;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(ni||(ni={}));var Be=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 Be).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new Be).__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):ni.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):ri.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,ni.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,ri.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return Be.startBodyCompression(t),Be.addCodec(t,e),Be.addMethod(t,n),Be.endBodyCompression(t)}};var bn=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 wn=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 Ft=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 Ft).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new Ft).__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 wn).__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 bn).__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 Be).__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 de=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 de).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new de).__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 Ft).__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 Sr;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(Sr||(Sr={}));var ii;(function(r){r[r.DenseArray=0]="DenseArray"})(ii||(ii={}));var wt=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 wt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+4),(e||new wt).__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 wt.startInt(t),wt.addBitWidth(t,e),wt.addIsSigned(t,n),wt.endInt(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 getRootAsDictionaryEncoding(t,e){return(e||new ae).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+4),(e||new ae).__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 wt).__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):ii.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,ii.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 Re=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 Re).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+4),(e||new Re).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return Re.startBinary(t),Re.endBinary(t)}};var Ce=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 Ce).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+4),(e||new Ce).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return Ce.startBool(t),Ce.endBool(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 getRootAsDate(t,e){return(e||new Gt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+4),(e||new Gt).__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):rt.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,rt.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return Gt.startDate(t),Gt.addUnit(t,e),Gt.endDate(t)}};var _t=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 _t).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+4),(e||new _t).__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 _t.startDecimal(t),_t.addPrecision(t,e),_t.addScale(t,n),_t.addBitWidth(t,i),_t.endDecimal(t)}};var $t=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 $t).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+4),(e||new $t).__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):m.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,m.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return $t.startDuration(t),$t.addUnit(t,e),$t.endDuration(t)}};var Ht=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 Ht).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+4),(e||new Ht).__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 Ht.startFixedSizeBinary(t),Ht.addByteWidth(t,e),Ht.endFixedSizeBinary(t)}};var Yt=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 Yt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+4),(e||new Yt).__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 Yt.startFixedSizeList(t),Yt.addListSize(t,e),Yt.endFixedSizeList(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 getRootAsFloatingPoint(t,e){return(e||new Kt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+4),(e||new Kt).__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):z.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,z.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return Kt.startFloatingPoint(t),Kt.addPrecision(t,e),Kt.endFloatingPoint(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 getRootAsInterval(t,e){return(e||new Zt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+4),(e||new Zt).__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):it.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,it.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return Zt.startInterval(t),Zt.addUnit(t,e),Zt.endInterval(t)}};var Pe=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 Pe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+4),(e||new Pe).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return Pe.startLargeBinary(t),Pe.endLargeBinary(t)}};var ke=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 ke).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+4),(e||new ke).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return ke.startLargeUtf8(t),ke.endLargeUtf8(t)}};var Ve=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 Ve).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+4),(e||new Ve).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return Ve.startList(t),Ve.endList(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 getRootAsMap(t,e){return(e||new Jt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+4),(e||new Jt).__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 Jt.startMap(t),Jt.addKeysSorted(t,e),Jt.endMap(t)}};var je=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 je).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+4),(e||new je).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return je.startNull(t),je.endNull(t)}};var ze=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 ze).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+4),(e||new ze).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return ze.startStruct_(t),ze.endStruct_(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 getRootAsTime(t,e){return(e||new Mt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(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):m.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,m.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return Mt.startTime(t),Mt.addUnit(t,e),Mt.addBitWidth(t,n),Mt.endTime(t)}};var Lt=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 Lt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+4),(e||new Lt).__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):m.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,m.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return Lt.startTimestamp(t),Lt.addUnit(t,e),Lt.addTimezone(t,n),Lt.endTimestamp(t)}};var vt=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 vt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+4),(e||new vt).__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):J.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,J.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 vt.startUnion(t),vt.addMode(t,e),vt.addTypeIds(t,n),vt.endUnion(t)}};var We=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 We).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new We).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return We.startUtf8(t),We.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 dt=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 dt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+4),(e||new dt).__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 ae).__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 dt).__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 ot=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 ot).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+4),(e||new ot).__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):Sr.Little}fields(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new dt).__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,Sr.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 ot.startSchema(t),ot.addEndianness(t,e),ot.addFields(t,n),ot.addCustomMetadata(t,i),ot.addFeatures(t,s),ot.endSchema(t)}};var P;(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"})(P||(P={}));var f;(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"})(f||(f={}));var lt;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(lt||(lt={}));var Ta={};Ir(Ta,{clampIndex:()=>Xh,clampRange:()=>ai,createElementComparator:()=>Dr});var la={};Ir(la,{valueToString:()=>Ae});function Ae(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=>Ae(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}var fa={};Ir(fa,{BN:()=>Cr,bigNumToBigInt:()=>$c,bigNumToString:()=>In,isArrowBigNumSymbol:()=>Wc});var Wc=Symbol.for("isArrowBigNum");function Te(r,...t){return t.length===0?Object.setPrototypeOf(C(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}Te.prototype[Wc]=!0;Te.prototype.toJSON=function(){return`"${In(this)}"`};Te.prototype.valueOf=function(){return Gc(this)};Te.prototype.toString=function(){return In(this)};Te.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Gc(this);case"string":return In(this);case"default":return $c(this)}return In(this)};function _n(...r){return Te.apply(this,r)}function vn(...r){return Te.apply(this,r)}function si(...r){return Te.apply(this,r)}Object.setPrototypeOf(_n.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(vn.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(si.prototype,Object.create(Uint32Array.prototype));Object.assign(_n.prototype,Te.prototype,{constructor:_n,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(vn.prototype,Te.prototype,{constructor:vn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(si.prototype,Te.prototype,{constructor:si,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});function Gc(r){let{buffer:t,byteOffset:e,length:n,signed:i}=r,s=new BigUint64Array(t,e,n),o=i&&s.at(-1)&BigInt(1)<<BigInt(63),a=BigInt(o?1:0),c=BigInt(0);if(o){for(let l of s)a+=~l*(BigInt(1)<<BigInt(32)*c++);a*=BigInt(-1)}else for(let l of s)a+=l*(BigInt(1)<<BigInt(32)*c++);return a}var In=r=>{if(r.byteLength===8)return`${new r.BigIntArray(r.buffer,r.byteOffset,1)[0]}`;if(!r.signed)return ua(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return ua(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`-${ua(t)}`},$c=r=>r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:In(r);function ua(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 Cr=class{static new(t,e){switch(e){case!0:return new _n(t);case!1:return new vn(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new _n(t)}return t.byteLength===16?new si(t):new vn(t)}static signed(t){return new _n(t)}static unsigned(t){return new vn(t)}static decimal(t){return new si(t)}constructor(t,e){return Cr.new(t,e)}};function at(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)}var Hc,Yc,Kc,Zc,Jc,Xc,Qc,qc,tl,el,rl,nl,il,sl,ol,al,cl,ll,ul,fl,hl,dl,y=class{static isNull(t){return t?.typeId===f.Null}static isInt(t){return t?.typeId===f.Int}static isFloat(t){return t?.typeId===f.Float}static isBinary(t){return t?.typeId===f.Binary}static isLargeBinary(t){return t?.typeId===f.LargeBinary}static isUtf8(t){return t?.typeId===f.Utf8}static isLargeUtf8(t){return t?.typeId===f.LargeUtf8}static isBool(t){return t?.typeId===f.Bool}static isDecimal(t){return t?.typeId===f.Decimal}static isDate(t){return t?.typeId===f.Date}static isTime(t){return t?.typeId===f.Time}static isTimestamp(t){return t?.typeId===f.Timestamp}static isInterval(t){return t?.typeId===f.Interval}static isDuration(t){return t?.typeId===f.Duration}static isList(t){return t?.typeId===f.List}static isStruct(t){return t?.typeId===f.Struct}static isUnion(t){return t?.typeId===f.Union}static isFixedSizeBinary(t){return t?.typeId===f.FixedSizeBinary}static isFixedSizeList(t){return t?.typeId===f.FixedSizeList}static isMap(t){return t?.typeId===f.Map}static isDictionary(t){return t?.typeId===f.Dictionary}static isDenseUnion(t){return y.isUnion(t)&&t.mode===J.Dense}static isSparseUnion(t){return y.isUnion(t)&&t.mode===J.Sparse}constructor(t){this.typeId=t}};Hc=Symbol.toStringTag;y[Hc]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(y.prototype);var ut=class extends y{constructor(){super(f.Null)}toString(){return"Null"}};Yc=Symbol.toStringTag;ut[Yc]=(r=>r[Symbol.toStringTag]="Null")(ut.prototype);var st=class extends y{constructor(t,e){super(f.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}`}};Kc=Symbol.toStringTag;st[Kc]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(st.prototype);var Ge=class extends st{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},$e=class extends st{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},It=class extends st{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},pe=class extends st{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},He=class extends st{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},Ye=class extends st{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Ke=class extends st{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Ze=class extends st{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(Ge.prototype,"ArrayType",{value:Int8Array});Object.defineProperty($e.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(It.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(pe.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(He.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(Ye.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Ke.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(Ze.prototype,"ArrayType",{value:BigUint64Array});var At=class extends y{constructor(t){super(f.Float),this.precision=t}get ArrayType(){switch(this.precision){case z.HALF:return Uint16Array;case z.SINGLE:return Float32Array;case z.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};Zc=Symbol.toStringTag;At[Zc]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(At.prototype);var Br=class extends At{constructor(){super(z.HALF)}},me=class extends At{constructor(){super(z.SINGLE)}},ye=class extends At{constructor(){super(z.DOUBLE)}};Object.defineProperty(Br.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(me.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(ye.prototype,"ArrayType",{value:Float64Array});var ce=class extends y{constructor(){super(f.Binary)}toString(){return"Binary"}};Jc=Symbol.toStringTag;ce[Jc]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(ce.prototype);var Je=class extends y{constructor(){super(f.LargeBinary)}toString(){return"LargeBinary"}};Xc=Symbol.toStringTag;Je[Xc]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(Je.prototype);var Pt=class extends y{constructor(){super(f.Utf8)}toString(){return"Utf8"}};Qc=Symbol.toStringTag;Pt[Qc]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(Pt.prototype);var Xe=class extends y{constructor(){super(f.LargeUtf8)}toString(){return"LargeUtf8"}};qc=Symbol.toStringTag;Xe[qc]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Xe.prototype);var kt=class extends y{constructor(){super(f.Bool)}toString(){return"Bool"}};tl=Symbol.toStringTag;kt[tl]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(kt.prototype);var le=class extends y{constructor(t,e,n=128){super(f.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};el=Symbol.toStringTag;le[el]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(le.prototype);var Xt=class extends y{constructor(t){super(f.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${rt[this.unit]}>`}};rl=Symbol.toStringTag;Xt[rl]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Date"))(Xt.prototype);var Pr=class extends Xt{constructor(){super(rt.DAY)}},cr=class extends Xt{constructor(){super(rt.MILLISECOND)}},xt=class extends y{constructor(t,e){super(f.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${m[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};nl=Symbol.toStringTag;xt[nl]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(xt.prototype);var kr=class extends xt{constructor(){super(m.SECOND,32)}},Vr=class extends xt{constructor(){super(m.MILLISECOND,32)}},jr=class extends xt{constructor(){super(m.MICROSECOND,64)}},zr=class extends xt{constructor(){super(m.NANOSECOND,64)}},Nt=class extends y{constructor(t,e){super(f.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${m[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};il=Symbol.toStringTag;Nt[il]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Timestamp"))(Nt.prototype);var Wr=class extends Nt{constructor(t){super(m.SECOND,t)}},Gr=class extends Nt{constructor(t){super(m.MILLISECOND,t)}},$r=class extends Nt{constructor(t){super(m.MICROSECOND,t)}},Hr=class extends Nt{constructor(t){super(m.NANOSECOND,t)}},Qt=class extends y{constructor(t){super(f.Interval),this.unit=t}toString(){return`Interval<${it[this.unit]}>`}};sl=Symbol.toStringTag;Qt[sl]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Qt.prototype);var Yr=class extends Qt{constructor(){super(it.DAY_TIME)}},Kr=class extends Qt{constructor(){super(it.YEAR_MONTH)}},Qe=class extends y{constructor(t){super(f.Duration),this.unit=t}toString(){return`Duration<${m[this.unit]}>`}};ol=Symbol.toStringTag;Qe[ol]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(Qe.prototype);var Tt=class extends y{constructor(t){super(f.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}};al=Symbol.toStringTag;Tt[al]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(Tt.prototype);var V=class extends y{constructor(t){super(f.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};cl=Symbol.toStringTag;V[cl]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(V.prototype);var ge=class extends y{constructor(t,e,n){super(f.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(" | ")}>`}};ll=Symbol.toStringTag;ge[ll]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(ge.prototype);var qe=class extends y{constructor(t){super(f.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};ul=Symbol.toStringTag;qe[ul]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(qe.prototype);var Vt=class extends y{constructor(t,e){super(f.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}>`}};fl=Symbol.toStringTag;Vt[fl]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(Vt.prototype);var jt=class extends y{constructor(t,e=!1){var n,i,s;if(super(f.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(", ")}}>`}};hl=Symbol.toStringTag;jt[hl]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(jt.prototype);var fh=(r=>()=>++r)(-1),Ut=class extends y{constructor(t,e,n,i){super(f.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=n==null?fh():at(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}>`}};dl=Symbol.toStringTag;Ut[dl]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(Ut.prototype);function ue(r){let t=r;switch(r.typeId){case f.Decimal:return r.bitWidth/32;case f.Timestamp:return 2;case f.Date:return 1+t.unit;case f.Interval:return 1+t.unit;case f.FixedSizeList:return t.listSize;case f.FixedSizeBinary:return t.byteWidth;default:return 1}}var I=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 hh(this,t,e)}getVisitFnByTypeId(t,e=!0){return xn(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 hh(r,t,e=!0){return typeof t=="number"?xn(r,t,e):typeof t=="string"&&t in f?xn(r,f[t],e):t&&t instanceof y?xn(r,ml(t),e):t?.type&&t.type instanceof y?xn(r,ml(t.type),e):xn(r,f.NONE,e)}function xn(r,t,e=!0){let n=null;switch(t){case f.Null:n=r.visitNull;break;case f.Bool:n=r.visitBool;break;case f.Int:n=r.visitInt;break;case f.Int8:n=r.visitInt8||r.visitInt;break;case f.Int16:n=r.visitInt16||r.visitInt;break;case f.Int32:n=r.visitInt32||r.visitInt;break;case f.Int64:n=r.visitInt64||r.visitInt;break;case f.Uint8:n=r.visitUint8||r.visitInt;break;case f.Uint16:n=r.visitUint16||r.visitInt;break;case f.Uint32:n=r.visitUint32||r.visitInt;break;case f.Uint64:n=r.visitUint64||r.visitInt;break;case f.Float:n=r.visitFloat;break;case f.Float16:n=r.visitFloat16||r.visitFloat;break;case f.Float32:n=r.visitFloat32||r.visitFloat;break;case f.Float64:n=r.visitFloat64||r.visitFloat;break;case f.Utf8:n=r.visitUtf8;break;case f.LargeUtf8:n=r.visitLargeUtf8;break;case f.Binary:n=r.visitBinary;break;case f.LargeBinary:n=r.visitLargeBinary;break;case f.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case f.Date:n=r.visitDate;break;case f.DateDay:n=r.visitDateDay||r.visitDate;break;case f.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case f.Timestamp:n=r.visitTimestamp;break;case f.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case f.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case f.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case f.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case f.Time:n=r.visitTime;break;case f.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case f.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case f.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case f.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case f.Decimal:n=r.visitDecimal;break;case f.List:n=r.visitList;break;case f.Struct:n=r.visitStruct;break;case f.Union:n=r.visitUnion;break;case f.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case f.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case f.Dictionary:n=r.visitDictionary;break;case f.Interval:n=r.visitInterval;break;case f.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case f.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case f.Duration:n=r.visitDuration;break;case f.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case f.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case f.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case f.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case f.FixedSizeList:n=r.visitFixedSizeList;break;case f.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error(`Unrecognized type '${f[t]}'`)}function ml(r){switch(r.typeId){case f.Null:return f.Null;case f.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?f.Int8:f.Uint8;case 16:return e?f.Int16:f.Uint16;case 32:return e?f.Int32:f.Uint32;case 64:return e?f.Int64:f.Uint64}return f.Int}case f.Float:switch(r.precision){case z.HALF:return f.Float16;case z.SINGLE:return f.Float32;case z.DOUBLE:return f.Float64}return f.Float;case f.Binary:return f.Binary;case f.LargeBinary:return f.LargeBinary;case f.Utf8:return f.Utf8;case f.LargeUtf8:return f.LargeUtf8;case f.Bool:return f.Bool;case f.Decimal:return f.Decimal;case f.Time:switch(r.unit){case m.SECOND:return f.TimeSecond;case m.MILLISECOND:return f.TimeMillisecond;case m.MICROSECOND:return f.TimeMicrosecond;case m.NANOSECOND:return f.TimeNanosecond}return f.Time;case f.Timestamp:switch(r.unit){case m.SECOND:return f.TimestampSecond;case m.MILLISECOND:return f.TimestampMillisecond;case m.MICROSECOND:return f.TimestampMicrosecond;case m.NANOSECOND:return f.TimestampNanosecond}return f.Timestamp;case f.Date:switch(r.unit){case rt.DAY:return f.DateDay;case rt.MILLISECOND:return f.DateMillisecond}return f.Date;case f.Interval:switch(r.unit){case it.DAY_TIME:return f.IntervalDayTime;case it.YEAR_MONTH:return f.IntervalYearMonth}return f.Interval;case f.Duration:switch(r.unit){case m.SECOND:return f.DurationSecond;case m.MILLISECOND:return f.DurationMillisecond;case m.MICROSECOND:return f.DurationMicrosecond;case m.NANOSECOND:return f.DurationNanosecond}return f.Duration;case f.Map:return f.Map;case f.List:return f.List;case f.Struct:return f.Struct;case f.Union:switch(r.mode){case J.Dense:return f.DenseUnion;case J.Sparse:return f.SparseUnion}return f.Union;case f.FixedSizeBinary:return f.FixedSizeBinary;case f.FixedSizeList:return f.FixedSizeList;case f.Dictionary:return f.Dictionary}throw new Error(`Unrecognized type '${f[r.typeId]}'`)}I.prototype.visitInt8=null;I.prototype.visitInt16=null;I.prototype.visitInt32=null;I.prototype.visitInt64=null;I.prototype.visitUint8=null;I.prototype.visitUint16=null;I.prototype.visitUint32=null;I.prototype.visitUint64=null;I.prototype.visitFloat16=null;I.prototype.visitFloat32=null;I.prototype.visitFloat64=null;I.prototype.visitDateDay=null;I.prototype.visitDateMillisecond=null;I.prototype.visitTimestampSecond=null;I.prototype.visitTimestampMillisecond=null;I.prototype.visitTimestampMicrosecond=null;I.prototype.visitTimestampNanosecond=null;I.prototype.visitTimeSecond=null;I.prototype.visitTimeMillisecond=null;I.prototype.visitTimeMicrosecond=null;I.prototype.visitTimeNanosecond=null;I.prototype.visitDenseUnion=null;I.prototype.visitSparseUnion=null;I.prototype.visitIntervalDayTime=null;I.prototype.visitIntervalYearMonth=null;I.prototype.visitDuration=null;I.prototype.visitDurationSecond=null;I.prototype.visitDurationMillisecond=null;I.prototype.visitDurationMicrosecond=null;I.prototype.visitDurationNanosecond=null;var ha={};Ir(ha,{float64ToUint16:()=>oi,uint16ToFloat64:()=>Is});var yl=new Float64Array(1),Sn=new Uint32Array(yl.buffer);function Is(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 oi(r){if(r!==r)return 32256;yl[0]=r;let t=(Sn[1]&2147483648)>>16&65535,e=Sn[1]&2146435072,n=0;return e>=1089470464?Sn[0]>0?e=31744:(e=(e&2080374784)>>16,n=(Sn[1]&1048575)>>10):e<=1056964608?(n=1048576+(Sn[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(Sn[1]&1048575)+512>>10),t|e|n&65535}var T=class extends I{};function L(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}var dh=(r,t,e)=>{r[t]=Math.trunc(e/864e5)},da=(r,t,e)=>{r[t]=Math.trunc(e%4294967296),r[t+1]=Math.trunc(e/4294967296)},ph=(r,t,e)=>{r[t]=Math.trunc(e*1e3%4294967296),r[t+1]=Math.trunc(e*1e3/4294967296)},mh=(r,t,e)=>{r[t]=Math.trunc(e*1e6%4294967296),r[t+1]=Math.trunc(e*1e6/4294967296)},gl=(r,t,e,n)=>{if(e+1<t.length){let i=at(t[e]),s=at(t[e+1]);r.set(n.subarray(0,s-i),i)}},yh=({offset:r,values:t},e,n)=>{let i=r+e;n?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},lr=({values:r},t,e)=>{r[t]=e},pa=({values:r},t,e)=>{r[t]=e},bl=({values:r},t,e)=>{r[t]=oi(e)},gh=(r,t,e)=>{switch(r.type.precision){case z.HALF:return bl(r,t,e);case z.SINGLE:case z.DOUBLE:return pa(r,t,e)}},xs=({values:r},t,e)=>{dh(r,t,e.valueOf())},Ss=({values:r},t,e)=>{da(r,t*2,e.valueOf())},ma=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},wl=({values:r,valueOffsets:t},e,n)=>gl(r,t,e,n),_l=({values:r,valueOffsets:t},e,n)=>gl(r,t,e,Ne(n)),ya=(r,t,e)=>{r.type.unit===rt.DAY?xs(r,t,e):Ss(r,t,e)},Bs=({values:r},t,e)=>da(r,t*2,e/1e3),As=({values:r},t,e)=>da(r,t*2,e),Ts=({values:r},t,e)=>ph(r,t*2,e),Ds=({values:r},t,e)=>mh(r,t*2,e),ga=(r,t,e)=>{switch(r.type.unit){case m.SECOND:return Bs(r,t,e);case m.MILLISECOND:return As(r,t,e);case m.MICROSECOND:return Ts(r,t,e);case m.NANOSECOND:return Ds(r,t,e)}},Os=({values:r},t,e)=>{r[t]=e},Fs=({values:r},t,e)=>{r[t]=e},Ms=({values:r},t,e)=>{r[t]=e},Ls=({values:r},t,e)=>{r[t]=e},ba=(r,t,e)=>{switch(r.type.unit){case m.SECOND:return Os(r,t,e);case m.MILLISECOND:return Fs(r,t,e);case m.MICROSECOND:return Ms(r,t,e);case m.NANOSECOND:return Ls(r,t,e)}},wa=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},bh=(r,t,e)=>{let n=r.children[0],i=r.valueOffsets,s=Dt.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))},wh=(r,t,e)=>{let n=r.children[0],{valueOffsets:i}=r,s=Dt.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},_h=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[s]),vh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(s)),Ih=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(i.name)),xh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[i.name]),Sh=(r,t,e)=>{let n=r.type.children.map(s=>Dt.getVisitFn(s.type)),i=e instanceof Map?Ih(t,e):e instanceof b?vh(t,e):Array.isArray(e)?_h(t,e):xh(t,e);r.type.children.forEach((s,o)=>i(n[o],r.children[o],s,o))},Bh=(r,t,e)=>{r.type.mode===J.Dense?vl(r,t,e):Il(r,t,e)},vl=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Dt.visit(i,r.valueOffsets[t],e)},Il=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Dt.visit(i,t,e)},Ah=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},_a=(r,t,e)=>{r.type.unit===it.DAY_TIME?Ns(r,t,e):Us(r,t,e)},Ns=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},Us=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},Es=({values:r},t,e)=>{r[t]=e},Rs=({values:r},t,e)=>{r[t]=e},Cs=({values:r},t,e)=>{r[t]=e},Ps=({values:r},t,e)=>{r[t]=e},va=(r,t,e)=>{switch(r.type.unit){case m.SECOND:return Es(r,t,e);case m.MILLISECOND:return Rs(r,t,e);case m.MICROSECOND:return Cs(r,t,e);case m.NANOSECOND:return Ps(r,t,e)}},Th=(r,t,e)=>{let{stride:n}=r,i=r.children[0],s=Dt.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))};T.prototype.visitBool=L(yh);T.prototype.visitInt=L(lr);T.prototype.visitInt8=L(lr);T.prototype.visitInt16=L(lr);T.prototype.visitInt32=L(lr);T.prototype.visitInt64=L(lr);T.prototype.visitUint8=L(lr);T.prototype.visitUint16=L(lr);T.prototype.visitUint32=L(lr);T.prototype.visitUint64=L(lr);T.prototype.visitFloat=L(gh);T.prototype.visitFloat16=L(bl);T.prototype.visitFloat32=L(pa);T.prototype.visitFloat64=L(pa);T.prototype.visitUtf8=L(_l);T.prototype.visitLargeUtf8=L(_l);T.prototype.visitBinary=L(wl);T.prototype.visitLargeBinary=L(wl);T.prototype.visitFixedSizeBinary=L(ma);T.prototype.visitDate=L(ya);T.prototype.visitDateDay=L(xs);T.prototype.visitDateMillisecond=L(Ss);T.prototype.visitTimestamp=L(ga);T.prototype.visitTimestampSecond=L(Bs);T.prototype.visitTimestampMillisecond=L(As);T.prototype.visitTimestampMicrosecond=L(Ts);T.prototype.visitTimestampNanosecond=L(Ds);T.prototype.visitTime=L(ba);T.prototype.visitTimeSecond=L(Os);T.prototype.visitTimeMillisecond=L(Fs);T.prototype.visitTimeMicrosecond=L(Ms);T.prototype.visitTimeNanosecond=L(Ls);T.prototype.visitDecimal=L(wa);T.prototype.visitList=L(bh);T.prototype.visitStruct=L(Sh);T.prototype.visitUnion=L(Bh);T.prototype.visitDenseUnion=L(vl);T.prototype.visitSparseUnion=L(Il);T.prototype.visitDictionary=L(Ah);T.prototype.visitInterval=L(_a);T.prototype.visitIntervalDayTime=L(Ns);T.prototype.visitIntervalYearMonth=L(Us);T.prototype.visitDuration=L(va);T.prototype.visitDurationSecond=L(Es);T.prototype.visitDurationMillisecond=L(Rs);T.prototype.visitDurationMicrosecond=L(Cs);T.prototype.visitDurationNanosecond=L(Ps);T.prototype.visitFixedSizeList=L(Th);T.prototype.visitMap=L(wh);var Dt=new T;var De=Symbol.for("parent"),Bn=Symbol.for("rowIndex"),Ar=class{constructor(t,e){return this[De]=t,this[Bn]=e,new Proxy(this,new xa)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[Bn],e=this[De],n=e.type.children,i={};for(let s=-1,o=n.length;++s<o;)i[n[s].name]=pt.visit(e.children[s],t);return i}toString(){return`{${[...this].map(([t,e])=>`${Ae(t)}: ${Ae(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Ia(this[De],this[Bn])}},Ia=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,pt.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(Ar.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[De]:{writable:!0,enumerable:!1,configurable:!1,value:null},[Bn]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var xa=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[De].type.children.map(e=>e.name)}has(t,e){return t[De].type.children.findIndex(n=>n.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[De].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[De].type.children.findIndex(i=>i.name===e);if(n!==-1){let i=pt.visit(t[De].children[n],t[Bn]);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[De].type.children.findIndex(s=>s.name===e);return i!==-1?(Dt.visit(t[De].children[i],t[Bn],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}};var x=class extends I{};function F(r){return(t,e)=>t.getValid(e)?r(t,e):null}var Dh=(r,t)=>864e5*r[t],Sa=(r,t)=>4294967296*r[t+1]+(r[t]>>>0),Oh=(r,t)=>4294967296*(r[t+1]/1e3)+(r[t]>>>0)/1e3,Fh=(r,t)=>4294967296*(r[t+1]/1e6)+(r[t]>>>0)/1e6,xl=r=>new Date(r),Mh=(r,t)=>xl(Dh(r,t)),Lh=(r,t)=>xl(Sa(r,t)),Nh=(r,t)=>null,Sl=(r,t,e)=>{if(e+1>=t.length)return null;let n=at(t[e]),i=at(t[e+1]);return r.subarray(n,i)},Uh=({offset:r,values:t},e)=>{let n=r+e;return(t[n>>3]&1<<n%8)!==0},Bl=({values:r},t)=>Mh(r,t),Al=({values:r},t)=>Lh(r,t*2),Tr=({stride:r,values:t},e)=>t[r*e],Eh=({stride:r,values:t},e)=>Is(t[r*e]),Tl=({values:r},t)=>r[t],Rh=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Dl=({values:r,valueOffsets:t},e)=>Sl(r,t,e),Ol=({values:r,valueOffsets:t},e)=>{let n=Sl(r,t,e);return n!==null?Qn(n):null},Ch=({values:r},t)=>r[t],Ph=({type:r,values:t},e)=>r.precision!==z.HALF?t[e]:Is(t[e]),kh=(r,t)=>r.type.unit===rt.DAY?Bl(r,t):Al(r,t),Fl=({values:r},t)=>1e3*Sa(r,t*2),Ml=({values:r},t)=>Sa(r,t*2),Ll=({values:r},t)=>Oh(r,t*2),Nl=({values:r},t)=>Fh(r,t*2),Vh=(r,t)=>{switch(r.type.unit){case m.SECOND:return Fl(r,t);case m.MILLISECOND:return Ml(r,t);case m.MICROSECOND:return Ll(r,t);case m.NANOSECOND:return Nl(r,t)}},Ul=({values:r},t)=>r[t],El=({values:r},t)=>r[t],Rl=({values:r},t)=>r[t],Cl=({values:r},t)=>r[t],jh=(r,t)=>{switch(r.type.unit){case m.SECOND:return Ul(r,t);case m.MILLISECOND:return El(r,t);case m.MICROSECOND:return Rl(r,t);case m.NANOSECOND:return Cl(r,t)}},zh=({values:r,stride:t},e)=>Cr.decimal(r.subarray(t*e,t*(e+1))),Wh=(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 b([c])},Gh=(r,t)=>{let{valueOffsets:e,children:n}=r,{[t]:i,[t+1]:s}=e,o=n[0];return new tr(o.slice(i,s-i))},$h=(r,t)=>new Ar(r,t),Hh=(r,t)=>r.type.mode===J.Dense?Pl(r,t):kl(r,t),Pl=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return pt.visit(n,r.valueOffsets[t])},kl=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return pt.visit(n,t)},Yh=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},Kh=(r,t)=>r.type.unit===it.DAY_TIME?Vl(r,t):jl(r,t),Vl=({values:r},t)=>r.subarray(2*t,2*(t+1)),jl=({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},zl=({values:r},t)=>r[t],Wl=({values:r},t)=>r[t],Gl=({values:r},t)=>r[t],$l=({values:r},t)=>r[t],Zh=(r,t)=>{switch(r.type.unit){case m.SECOND:return zl(r,t);case m.MILLISECOND:return Wl(r,t);case m.MICROSECOND:return Gl(r,t);case m.NANOSECOND:return $l(r,t)}},Jh=(r,t)=>{let{stride:e,children:n}=r,s=n[0].slice(t*e,e);return new b([s])};x.prototype.visitNull=F(Nh);x.prototype.visitBool=F(Uh);x.prototype.visitInt=F(Ch);x.prototype.visitInt8=F(Tr);x.prototype.visitInt16=F(Tr);x.prototype.visitInt32=F(Tr);x.prototype.visitInt64=F(Tl);x.prototype.visitUint8=F(Tr);x.prototype.visitUint16=F(Tr);x.prototype.visitUint32=F(Tr);x.prototype.visitUint64=F(Tl);x.prototype.visitFloat=F(Ph);x.prototype.visitFloat16=F(Eh);x.prototype.visitFloat32=F(Tr);x.prototype.visitFloat64=F(Tr);x.prototype.visitUtf8=F(Ol);x.prototype.visitLargeUtf8=F(Ol);x.prototype.visitBinary=F(Dl);x.prototype.visitLargeBinary=F(Dl);x.prototype.visitFixedSizeBinary=F(Rh);x.prototype.visitDate=F(kh);x.prototype.visitDateDay=F(Bl);x.prototype.visitDateMillisecond=F(Al);x.prototype.visitTimestamp=F(Vh);x.prototype.visitTimestampSecond=F(Fl);x.prototype.visitTimestampMillisecond=F(Ml);x.prototype.visitTimestampMicrosecond=F(Ll);x.prototype.visitTimestampNanosecond=F(Nl);x.prototype.visitTime=F(jh);x.prototype.visitTimeSecond=F(Ul);x.prototype.visitTimeMillisecond=F(El);x.prototype.visitTimeMicrosecond=F(Rl);x.prototype.visitTimeNanosecond=F(Cl);x.prototype.visitDecimal=F(zh);x.prototype.visitList=F(Wh);x.prototype.visitStruct=F($h);x.prototype.visitUnion=F(Hh);x.prototype.visitDenseUnion=F(Pl);x.prototype.visitSparseUnion=F(kl);x.prototype.visitDictionary=F(Yh);x.prototype.visitInterval=F(Kh);x.prototype.visitIntervalDayTime=F(Vl);x.prototype.visitIntervalYearMonth=F(jl);x.prototype.visitDuration=F(Zh);x.prototype.visitDurationSecond=F(zl);x.prototype.visitDurationMillisecond=F(Wl);x.prototype.visitDurationMicrosecond=F(Gl);x.prototype.visitDurationNanosecond=F($l);x.prototype.visitFixedSizeList=F(Jh);x.prototype.visitMap=F(Gh);var pt=new x;var be=Symbol.for("keys"),An=Symbol.for("vals"),tr=class{constructor(t){return this[be]=new b([t.children[0]]).memoize(),this[An]=t.children[1],new Proxy(this,new Aa)}[Symbol.iterator](){return new Ba(this[be],this[An])}get size(){return this[be].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[be],e=this[An],n={};for(let i=-1,s=t.length;++i<s;)n[t.get(i)]=pt.visit(e,i);return n}toString(){return`{${[...this].map(([t,e])=>`${Ae(t)}: ${Ae(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},Ba=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),pt.visit(this.vals,t)]})}},Aa=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[be].toArray().map(String)}has(t,e){return t[be].includes(e)}getOwnPropertyDescriptor(t,e){if(t[be].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[be].indexOf(e);if(n!==-1){let i=pt.visit(Reflect.get(t,An),n);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[be].indexOf(e);return i!==-1?(Dt.visit(Reflect.get(t,An),i,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}};Object.defineProperties(tr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[be]:{writable:!0,enumerable:!1,configurable:!1,value:null},[An]:{writable:!0,enumerable:!1,configurable:!1,value:null}});function Xh(r,t,e){let n=r.length,i=t>-1?t:n+t%n;return e?e(r,i):i}var Hl;function ai(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&&(Hl=s,s=o,o=Hl),o>i&&(o=i),n?n(r,s,o):[s,o]}var Yl=r=>r!==r;function Dr(r){if(typeof r!=="object"||r===null)return Yl(r)?Yl: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?sa(r,e):!1:r instanceof Map?qh(r):Array.isArray(r)?Qh(r):r instanceof b?td(r):ed(r,!0)}function Qh(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Dr(r[e]);return ks(t)}function qh(r){let t=-1,e=[];for(let n of r.values())e[++t]=Dr(n);return ks(e)}function td(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=Dr(r.get(e));return ks(t)}function ed(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]=Dr(r[e[i]]);return ks(n,e)}function ks(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return rd(r,e);case Map:return Kl(r,e,e.keys());case tr:case Ar:case Object:case void 0:return Kl(r,e,t||Object.keys(e))}return e instanceof b?nd(r,e):!1}}function rd(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 nd(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 Kl(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 Da={};Ir(Da,{BitIterator:()=>Zr,getBit:()=>Zl,getBool:()=>js,packBools:()=>Xr,popcnt_array:()=>Jl,popcnt_bit_range:()=>ci,popcnt_uint32:()=>Vs,setBool:()=>id,truncateBitmap:()=>Jr});function js(r,t,e,n){return(e&1<<n)!==0}function Zl(r,t,e,n){return(e&1<<n)>>n}function id(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function Jr(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):Xr(new Zr(e,r,t,null,js)).subarray(0,n)),i}return e}function Xr(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 Zr=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 ci(r,t,e){if(e-t<=0)return 0;if(e-t<8){let s=0;for(let o of new Zr(r,t,e-t,r,Zl))s+=o;return s}let n=e>>3<<3,i=t+(t%8===0?0:8-t%8);return ci(r,t,i)+ci(r,n,e)+Jl(r,i>>3,n-i>>3)}function Jl(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+=Vs(s.getUint32(i)),i+=4;for(;o-i>=2;)n+=Vs(s.getUint16(i)),i+=2;for(;o-i>=1;)n+=Vs(s.getUint8(i)),i+=1;return n}function Vs(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 sd=-1,U=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 y.isSparseUnion(t)?this.children.some(e=>e.nullable):y.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(y.isUnion(this.type))return this.children.reduce((n,i)=>n+i.nullCount,0);let t=this._nullCount,e;return t<=sd&&(e=this.nullBitmap)&&(this._nullCount=t=this.length-ci(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 U?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=ue(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(y.isUnion(e)){let n=e,i=this.children[n.typeIdToChildIndex[this.typeIds[t]]],s=n.mode===J.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(y.isUnion(i)){let s=i,o=this.children[s.typeIdToChildIndex[this.typeIds[t]]],a=s.mode===J.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(Jr(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s,_nullCount:-1}));let h=s[u];n=(h&l)!==0,e?s[u]=h|l:s[u]=h&~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 U(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===f.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(Jr(this.offset,e,this.nullBitmap),0);let s=this.buffers;return s[lt.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[lt.TYPE])&&(o[lt.TYPE]=s.subarray(t,t+e)),(s=o[lt.OFFSET])&&(o[lt.OFFSET]=s.subarray(t,t+e+1))||(s=o[lt.DATA])&&(o[lt.DATA]=i===6?s:s.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map(i=>i.slice(e,n))}};U.prototype.children=Object.freeze([]);var Qr=class extends I{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:e,["offset"]:n=0,["length"]:i=0}=t;return new U(e,n,i,i)}visitBool(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new U(e,n,o,a,[void 0,s,i])}visitInt(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new U(e,n,o,a,[void 0,s,i])}visitFloat(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new U(e,n,o,a,[void 0,s,i])}visitUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.data),s=D(t.nullBitmap),o=Rr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new U(e,n,a,c,[o,i,s])}visitLargeUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.data),s=D(t.nullBitmap),o=ys(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new U(e,n,a,c,[o,i,s])}visitBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.data),s=D(t.nullBitmap),o=Rr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new U(e,n,a,c,[o,i,s])}visitLargeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.data),s=D(t.nullBitmap),o=ys(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new U(e,n,a,c,[o,i,s])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length/ue(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new U(e,n,o,a,[void 0,s,i])}visitDate(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length/ue(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new U(e,n,o,a,[void 0,s,i])}visitTimestamp(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length/ue(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new U(e,n,o,a,[void 0,s,i])}visitTime(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length/ue(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new U(e,n,o,a,[void 0,s,i])}visitDecimal(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length/ue(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new U(e,n,o,a,[void 0,s,i])}visitList(t){let{["type"]:e,["offset"]:n=0,["child"]:i}=t,s=D(t.nullBitmap),o=Rr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new U(e,n,a,c,[o,void 0,s],[i])}visitStruct(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=D(t.nullBitmap),{length:o=i.reduce((c,{length:l})=>Math.max(c,l),0),nullCount:a=t.nullBitmap?-1:0}=t;return new U(e,n,o,a,[void 0,void 0,s],i)}visitUnion(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=C(e.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=t;if(y.isSparseUnion(e))return new U(e,n,o,a,[void 0,void 0,void 0,s],i);let c=Rr(t.valueOffsets);return new U(e,n,o,a,[c,void 0,void 0,s],i)}visitDictionary(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.nullBitmap),s=C(e.indices.ArrayType,t.data),{["dictionary"]:o=new b([new Qr().visit({type:e.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new U(e,n,a,c,[void 0,s,i],[],o)}visitInterval(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length/ue(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new U(e,n,o,a,[void 0,s,i])}visitDuration(t){let{["type"]:e,["offset"]:n=0}=t,i=D(t.nullBitmap),s=C(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new U(e,n,o,a,[void 0,s,i])}visitFixedSizeList(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new Qr().visit({type:e.valueType})}=t,s=D(t.nullBitmap),{["length"]:o=i.length/ue(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new U(e,n,o,a,[void 0,void 0,s],[i])}visitMap(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new Qr().visit({type:e.childType})}=t,s=D(t.nullBitmap),o=Rr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new U(e,n,a,c,[o,void 0,s],[i])}},od=new Qr;function w(r){return od.visit(r)}var li=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 Xl(r){return r.some(t=>t.nullable)}function zs(r){return r.reduce((t,e)=>t+e.nullCount,0)}function Ws(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),h=Math.min(n-c,l);i.push(a.slice(u,h-u))}return i.length===0&&i.push(r[0].slice(0,0)),i}function Oa(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 ui(r,t){return r.getValid(t)}function Tn(r){function t(e,n,i){return r(e[n],i)}return function(e){let n=this.data;return Oa(n,this._offsets,e,t)}}function $s(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=Oa(s,this._offsets,n,e);return t=void 0,o}}function Hs(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 h=n[l];if(~(a=r(h,t,o)))return c+a;o=0,c+=h.length}return-1}return function(n,i){t=n;let s=this.data,o=typeof i!="number"?e(s,0,0):Oa(s,this._offsets,i,e);return t=void 0,o}}var S=class extends I{};function ad(r,t){return t===null&&r.length>0?0:-1}function cd(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(let i of new Zr(e,r.offset+(t||0),r.length,e,js)){if(!i)return n;++n}return-1}function N(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case f.Union:break;case f.Dictionary:break;default:return cd(r,e)}let n=pt.getVisitFn(r),i=Dr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}function Ql(r,t,e){let n=pt.getVisitFn(r),i=Dr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}S.prototype.visitNull=ad;S.prototype.visitBool=N;S.prototype.visitInt=N;S.prototype.visitInt8=N;S.prototype.visitInt16=N;S.prototype.visitInt32=N;S.prototype.visitInt64=N;S.prototype.visitUint8=N;S.prototype.visitUint16=N;S.prototype.visitUint32=N;S.prototype.visitUint64=N;S.prototype.visitFloat=N;S.prototype.visitFloat16=N;S.prototype.visitFloat32=N;S.prototype.visitFloat64=N;S.prototype.visitUtf8=N;S.prototype.visitLargeUtf8=N;S.prototype.visitBinary=N;S.prototype.visitLargeBinary=N;S.prototype.visitFixedSizeBinary=N;S.prototype.visitDate=N;S.prototype.visitDateDay=N;S.prototype.visitDateMillisecond=N;S.prototype.visitTimestamp=N;S.prototype.visitTimestampSecond=N;S.prototype.visitTimestampMillisecond=N;S.prototype.visitTimestampMicrosecond=N;S.prototype.visitTimestampNanosecond=N;S.prototype.visitTime=N;S.prototype.visitTimeSecond=N;S.prototype.visitTimeMillisecond=N;S.prototype.visitTimeMicrosecond=N;S.prototype.visitTimeNanosecond=N;S.prototype.visitDecimal=N;S.prototype.visitList=N;S.prototype.visitStruct=N;S.prototype.visitUnion=N;S.prototype.visitDenseUnion=Ql;S.prototype.visitSparseUnion=Ql;S.prototype.visitDictionary=N;S.prototype.visitInterval=N;S.prototype.visitIntervalDayTime=N;S.prototype.visitIntervalYearMonth=N;S.prototype.visitDuration=N;S.prototype.visitDurationSecond=N;S.prototype.visitDurationMillisecond=N;S.prototype.visitDurationMicrosecond=N;S.prototype.visitDurationNanosecond=N;S.prototype.visitFixedSizeList=N;S.prototype.visitMap=N;var qr=new S;var B=class extends I{};function M(r){let{type:t}=r;if(r.nullCount===0&&r.stride===1&&(t.typeId===f.Timestamp||t instanceof st&&t.bitWidth!==64||t instanceof xt&&t.bitWidth!==64||t instanceof At&&t.precision!==z.HALF))return new li(r.data.length,n=>{let i=r.data[n];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new li(r.data.length,n=>{let s=r.data[n].length,o=r.slice(e,e+s);return e+=s,new Fa(o)})}var Fa=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}};B.prototype.visitNull=M;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=M;B.prototype.visitSparseUnion=M;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 Dn=new B;var ql,tu={},eu={},b=class{constructor(t){var e,n,i;let s=t[0]instanceof b?t.flatMap(a=>a.data):t;if(s.length===0||s.some(a=>!(a instanceof U)))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}=tu[o.typeId],u=s[0];this.isValid=h=>ui(u,h),this.get=h=>a(u,h),this.set=(h,d)=>c(u,h,d),this.indexOf=h=>l(u,h),this._offsets=[0,u.length];break}default:Object.setPrototypeOf(this,eu[o.typeId]),this._offsets=Ws(s);break}this.data=s,this.type=o,this.stride=ue(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 Xl(this.data)}get nullCount(){return zs(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${f[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}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 b(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new b(ai(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 f.Int:case f.Float:case f.Decimal:case f.Time:case f.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 b(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return y.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(y.isDictionary(this.type)){let t=new On(this.data[0].dictionary),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new b(e)}return new On(this)}unmemoize(){if(y.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 b(e)}return this}};ql=Symbol.toStringTag;b[ql]=(r=>{r.type=y.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(f).map(e=>f[e]).filter(e=>typeof e=="number"&&e!==f.NONE);for(let e of t){let n=pt.getVisitFnByTypeId(e),i=Dt.getVisitFnByTypeId(e),s=qr.getVisitFnByTypeId(e);tu[e]={get:n,set:i,indexOf:s},eu[e]=Object.create(r,{isValid:{value:Tn(ui)},get:{value:Tn(pt.getVisitFnByTypeId(e))},set:{value:$s(Dt.getVisitFnByTypeId(e))},indexOf:{value:Hs(qr.getVisitFnByTypeId(e))}})}return"Vector"})(b.prototype);var On=class extends b{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 On(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new b(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function Or(r){if(r){if(r instanceof U)return new b([r]);if(r instanceof b)return new b(r.data);if(r.type instanceof y)return new b([w(r)]);if(Array.isArray(r))return new b(r.flatMap(t=>ld(t)));if(ArrayBuffer.isView(r)){r instanceof DataView&&(r=new Uint8Array(r.buffer));let t={offset:0,length:r.length,nullCount:0,data:r};if(r instanceof Int8Array)return new b([w(Object.assign(Object.assign({},t),{type:new Ge}))]);if(r instanceof Int16Array)return new b([w(Object.assign(Object.assign({},t),{type:new $e}))]);if(r instanceof Int32Array)return new b([w(Object.assign(Object.assign({},t),{type:new It}))]);if(r instanceof BigInt64Array)return new b([w(Object.assign(Object.assign({},t),{type:new pe}))]);if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return new b([w(Object.assign(Object.assign({},t),{type:new He}))]);if(r instanceof Uint16Array)return new b([w(Object.assign(Object.assign({},t),{type:new Ye}))]);if(r instanceof Uint32Array)return new b([w(Object.assign(Object.assign({},t),{type:new Ke}))]);if(r instanceof BigUint64Array)return new b([w(Object.assign(Object.assign({},t),{type:new Ze}))]);if(r instanceof Float32Array)return new b([w(Object.assign(Object.assign({},t),{type:new me}))]);if(r instanceof Float64Array)return new b([w(Object.assign(Object.assign({},t),{type:new ye}))]);throw new Error("Unrecognized input")}}throw new Error("Unrecognized input")}function ld(r){return r instanceof U?[r]:r instanceof b?r.data:Or(r).data}function ru(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
8
  switch (x) {${e.map(n=>`
9
- case ${sd(n)}:`).join("")}
9
+ case ${ud(n)}:`).join("")}
10
10
  return false;
11
11
  }`),r.length!==e.length&&(t=`if (x !== x) return false;
12
12
  ${t}`),new Function("x",`${t}
13
- return true;`)}function sd(r){return typeof r!="bigint"?Me(r):`${Me(r)}n`}function Sa(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function Xl(r,t=0){return r.length>=t?r.subarray(0,t):Xn(new r.constructor(t),r,0)}var Ue=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?Sa(n*1,this.BYTES_PER_ELEMENT):Sa(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=Sa(t*this.stride,this.BYTES_PER_ELEMENT);let e=Xl(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=Xl(this.buffer,t)}},lr=class extends Ue{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}},Fn=class extends lr{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){let{buffer:n}=this.reserve(t-this.length+1),i=t>>3,s=t%8,o=n[i]>>s&1;return e?o===0&&(n[i]|=1<<s,++this.numValid):o===1&&(n[i]&=~(1<<s),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},Mn=class extends lr{constructor(t){super(t.OffsetArrayType,1,1)}append(t){return this.set(this.length-1,t)}set(t,e){let n=this.length-1,i=this.reserve(t-n+1).buffer;return n<t++&&n>=0&&i.fill(i[n],n,t),i[t]=i[t-1]+e,this}flush(t=this.length-1){return t>this.length&&this.set(t-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(t+1)}};var rt=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=he(t),this._nulls=new Fn,e&&e.length>0&&(this._isValid=Jl(e))}toVector(){return new g([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0,{_offsets:e,_values:n,_nulls:i,_typeIds:s,children:o}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),o.reduce((a,c)=>a+c.byteLength,t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((e,n)=>e+n.reservedByteLength,t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(t){return this.children[t]||null}flush(){let t,e,n,i,{type:s,length:o,nullCount:a,_typeIds:c,_offsets:l,_values:u,_nulls:h}=this;(e=c?.flush(o))?i=l?.flush(o):(i=l?.flush(o))?t=u?.flush(l.last()):t=u?.flush(o),a>0&&(n=h?.flush(o));let d=this.children.map(b=>b.flush());return this.clear(),w({type:s,length:o,nullCount:a,children:d,child:d[0],data:t,typeIds:e,nullBitmap:n,valueOffsets:i})}finish(){this.finished=!0;for(let t of this.children)t.finish();return this}clear(){var t,e,n,i;this.length=0,(t=this._nulls)===null||t===void 0||t.clear(),(e=this._values)===null||e===void 0||e.clear(),(n=this._offsets)===null||n===void 0||n.clear(),(i=this._typeIds)===null||i===void 0||i.clear();for(let s of this.children)s.clear();return this}};rt.prototype.length=1;rt.prototype.stride=1;rt.prototype.children=null;rt.prototype.finished=!1;rt.prototype.nullValues=null;rt.prototype._isValid=()=>!0;var yt=class extends rt{constructor(t){super(t),this._values=new lr(this.ArrayType,0,this.stride)}setValue(t,e){let n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}},ee=class extends rt{constructor(t){super(t),this._pendingLength=0,this._offsets=new Mn(t.type)}setValue(t,e){let n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.length),this._pendingLength+=e instanceof qe?e[xe].length:e.length,n.set(t,e)}setValid(t,e){return super.setValid(t,e)?!0:((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}};var Qr=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,n,i){return t.prep(8,24),t.writeInt64(BigInt(i??0)),t.pad(4),t.writeInt32(n),t.writeInt64(BigInt(e??0)),t.offset()}};var Et=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new Et).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new Et).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):$.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new ot).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new Qr).__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 Qr).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}recordBatchesLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Q).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,$.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}};var E=class{constructor(t=[],e,n,i=$.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=Ba(t)),this.dictionaries=n,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,e)=>`${e}: ${t}`).join(", ")} }>`}select(t){let e=new Set(t),n=this.fields.filter(i=>e.has(i.name));return new E(n,this.metadata)}selectAt(t){let e=t.map(n=>this.fields[n]).filter(Boolean);return new E(e,this.metadata)}assign(...t){let e=t[0]instanceof E?t[0]:Array.isArray(t[0])?new E(t[0]):new E(t),n=[...this.fields],i=Gs(Gs(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:Gs(Gs(new Map,n[c].metadata),a.metadata)}))&&!1:!0}),o=Ba(s,new Map);return new E([...n,...s],i,new Map([...this.dictionaries,...o]))}};E.prototype.fields=null;E.prototype.metadata=null;E.prototype.dictionaries=null;var D=class{static new(...t){let[e,n,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],n===void 0&&(n=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new D(`${e}`,n,i,s)}constructor(t,e,n=!1,i){this.name=t,this.type=e,this.nullable=n,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,n,i,s]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,n=this.type,i=this.nullable,s=this.metadata]=t:{name:e=this.name,type:n=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],D.new(e,n,i,s)}};D.prototype.type=null;D.prototype.name=null;D.prototype.nullable=null;D.prototype.metadata=null;function Gs(r,t){return new Map([...r||new Map,...t||new Map])}function Ba(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&&Ba(s.children,t)}return t}var od=or,ad=Ct,ur=class{static decode(t){t=new ad(T(t));let e=Et.getRootAsFooter(t),n=E.decode(e.schema(),new Map,e.version());return new Aa(n,e)}static encode(t){let e=new od,n=E.encode(e,t.schema);Et.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())Ee.encode(e,o);let i=e.endVector();Et.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())Ee.encode(e,o);let s=e.endVector();return Et.startFooter(e),Et.addSchema(e,n),Et.addVersion(e,$.V5),Et.addRecordBatches(e,i),Et.addDictionaries(e,s),Et.finishFooterBuffer(e,Et.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=$.V5,n,i){this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e<n;)(t=this.getRecordBatch(e))&&(yield t)}*dictionaryBatches(){for(let t,e=-1,n=this.numDictionaries;++e<n;)(t=this.getDictionaryBatch(e))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}};var Aa=class extends ur{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 Ee.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return Ee.decode(e)}return null}},Ee=class{static decode(t){return new Ee(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){let{metaDataLength:n}=e,i=BigInt(e.offset),s=BigInt(e.bodyLength);return Qr.createBlock(t,i,n,s)}constructor(t,e,n){this.metaDataLength=t,this.offset=at(n),this.bodyLength=at(e)}};var q=Object.freeze({done:!0,value:void 0}),ci=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},qr=class{tee(){return this._getDOMStream().tee()}pipe(t,e){return this._getNodeStream().pipe(t,e)}pipeTo(t,e){return this._getDOMStream().pipeTo(t,e)}pipeThrough(t,e){return this._getDOMStream().pipeThrough(t,e)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}},$s=class extends qr{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return y(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){let{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(q);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Bt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Bt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return y(this,void 0,void 0,function*(){return yield this.abort(t),q})}return(t){return y(this,void 0,void 0,function*(){return yield this.close(),q})}read(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,n)=>{this.resolvers.push({resolve:e,reject:n})}):Promise.resolve(q)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var tr=class extends $s{write(t){if((t=T(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Zn(this.toUint8Array(!0)):this.toUint8Array(!1).then(Zn)}toUint8Array(t=!1){return t?ce(this._values)[0]:(()=>y(this,void 0,void 0,function*(){var e,n,i,s;let o=[],a=0;try{for(var c=!0,l=Ae(this),u;u=yield l.next(),e=u.done,!e;c=!0){s=u.value,c=!1;let h=s;o.push(h),a+=h.byteLength}}catch(h){n={error:h}}finally{try{!c&&!e&&(i=l.return)&&(yield i.call(l))}finally{if(n)throw n.error}}return ce(o,a)[0]}))()}},er=class{constructor(t){t&&(this.source=new Ta(Bt.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},re=class{constructor(t){t instanceof re?this.source=t.source:t instanceof tr?this.source=new fr(Bt.fromAsyncIterable(t)):hs(t)?this.source=new fr(Bt.fromNodeStream(t)):Jn(t)?this.source=new fr(Bt.fromDOMStream(t)):us(t)?this.source=new fr(Bt.fromDOMStream(t.body)):Te(t)?this.source=new fr(Bt.fromIterable(t)):ae(t)?this.source=new fr(Bt.fromAsyncIterable(t)):de(t)&&(this.source=new fr(Bt.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},Ta=class{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||q)}return(t){return Object.create(this.source.return&&this.source.return(t)||q)}},fr=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return y(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t,e="read"){return y(this,void 0,void 0,function*(){return yield this.source.next({cmd:e,size:t})})}throw(t){return y(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||q;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return y(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||q;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var li=class extends er{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}}},Or=class extends re{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=(()=>y(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending}))()}readInt32(t){return y(this,void 0,void 0,function*(){let{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return y(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:n,position:i}=this;if(e&&i<n){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,o=0,a=0,c=Math.min(n,s+Math.min(n-s,t)),l=new Uint8Array(Math.max(0,(this.position=c)-s));for(;(s+=a)<c&&(o+=a)<l.byteLength;)({bytesRead:a}=yield e.read(l,o,l.byteLength-o,s));return l}return null})}readAt(t,e){return y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:n,size:i}=this;if(n&&t+e<i){let s=Math.min(i,t+e),o=new Uint8Array(s-t);return(yield n.read(o,0,e,t)).buffer}return new Uint8Array(e)})}close(){return y(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var Oa={};Ir(Oa,{BaseInt64:()=>ui,Int128:()=>ne,Int64:()=>St,Uint64:()=>G});function Ln(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var Nn=8,Da=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],ui=class{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){let e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]),i=e[3]*n[3];this.buffer[0]=i&65535;let s=i>>>16;return i=e[2]*n[3],s+=i,i=e[3]*n[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?65536:0,this.buffer[1]+=s>>>16,this.buffer[1]+=e[1]*n[3]+e[2]*n[2]+e[3]*n[1],this.buffer[1]+=e[0]*n[3]+e[1]*n[2]+e[2]*n[1]+e[3]*n[0]<<16,this}_plus(t){let e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return`${Ln(this.buffer[1])} ${Ln(this.buffer[0])}`}},G=class extends ui{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return G.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return G.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.length,i=new G(e);for(let s=0;s<n;){let o=Nn<n-s?Nn:n-s,a=new G(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new G(new Uint32Array([Da[o],0]));i.times(c),i.plus(a),s+=o}return i}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)G.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new G(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new G(new Uint32Array(t.buffer)).plus(e)}},St=class extends ui{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){let e=this.buffer[1]<<0,n=t.buffer[1]<<0;return e<n||e===n&&this.buffer[0]<t.buffer[0]}static from(t,e=new Uint32Array(2)){return St.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return St.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.startsWith("-"),i=t.length,s=new St(e);for(let o=n?1:0;o<i;){let a=Nn<i-o?Nn:i-o,c=new St(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new St(new Uint32Array([Da[a],0]));s.times(l),s.plus(c),o+=a}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)St.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new St(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new St(new Uint32Array(t.buffer)).plus(e)}},ne=class{constructor(t){this.buffer=t}high(){return new St(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new St(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){let e=new G(new Uint32Array([this.buffer[3],0])),n=new G(new Uint32Array([this.buffer[2],0])),i=new G(new Uint32Array([this.buffer[1],0])),s=new G(new Uint32Array([this.buffer[0],0])),o=new G(new Uint32Array([t.buffer[3],0])),a=new G(new Uint32Array([t.buffer[2],0])),c=new G(new Uint32Array([t.buffer[1],0])),l=new G(new Uint32Array([t.buffer[0],0])),u=G.multiply(s,l);this.buffer[0]=u.low();let h=new G(new Uint32Array([u.high(),0]));return u=G.multiply(i,l),h.plus(u),u=G.multiply(s,c),h.plus(u),this.buffer[1]=h.low(),this.buffer[3]=h.lessThan(u)?1:0,this.buffer[2]=h.high(),new G(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(G.multiply(n,l)).plus(G.multiply(i,c)).plus(G.multiply(s,a)),this.buffer[3]+=G.multiply(e,l).plus(G.multiply(n,c)).plus(G.multiply(i,a)).plus(G.multiply(s,o)).low(),this}plus(t){let e=new Uint32Array(4);return e[3]=this.buffer[3]+t.buffer[3]>>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]<this.buffer[0]>>>0&&++e[1],e[1]<this.buffer[1]>>>0&&++e[2],e[2]<this.buffer[2]>>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${Ln(this.buffer[3])} ${Ln(this.buffer[2])} ${Ln(this.buffer[1])} ${Ln(this.buffer[0])}`}static multiply(t,e){return new ne(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new ne(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return ne.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return ne.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let n=t.startsWith("-"),i=t.length,s=new ne(e);for(let o=n?1:0;o<i;){let a=Nn<i-o?Nn:i-o,c=new ne(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new ne(new Uint32Array([Da[a],0,0,0]));s.times(l),s.plus(c),o+=a}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*4);for(let n=-1,i=t.length;++n<i;)ne.from(t[n],new Uint32Array(e.buffer,e.byteOffset+4*4*n,4));return e}};var fi=class extends v{constructor(t,e,n,i,s=$.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=e,this.buffers=n,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof D?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return w({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),children:this.visitMany(t.children)})}visitUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return this.metadataVersion<$.V5&&this.readNullBitmap(t,n),t.mode===K.Sparse?this.visitSparseUnion(t,{length:e,nullCount:n}):this.visitDenseUnion(t,{length:e,nullCount:n})}visitDenseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),child:this.visit(t.children[0])})}visitMap(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,e,n=this.nextBufferRange()){return e>0&&this.readData(t,n)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+e)}readDictionary(t){return this.dictionaries.get(t.id)}},Hs=class extends fi{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):Zr(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return C(Uint8Array,C(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return C(Uint8Array,C(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;return m.isTimestamp(t)?C(Uint8Array,St.convertArray(n[e])):(m.isInt(t)||m.isTime(t))&&t.bitWidth===64||m.isDuration(t)?C(Uint8Array,St.convertArray(n[e])):m.isDate(t)&&t.unit===et.MILLISECOND?C(Uint8Array,St.convertArray(n[e])):m.isDecimal(t)?C(Uint8Array,ne.convertArray(n[e])):m.isBinary(t)||m.isLargeBinary(t)||m.isFixedSizeBinary(t)?cd(n[e]):m.isBool(t)?Zr(n[e]):m.isUtf8(t)||m.isLargeUtf8(t)?Ce(n[e].join("")):C(Uint8Array,C(t.ArrayType,n[e].map(i=>+i)))}};function cd(r){let t=r.join(""),e=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)e[n>>1]=Number.parseInt(t.slice(n,n+2),16);return e}var Un=class extends ee{constructor(t){super(t),this._values=new Ue(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 En=class extends ee{constructor(t){super(t),this._values=new Ue(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 Ys=class extends rt{constructor(t){super(t),this._values=new Fn}setValue(t,e){this._values.set(t,+e)}};var tn=class extends yt{};tn.prototype._setValue=la;var hi=class extends tn{};hi.prototype._setValue=_s;var di=class extends tn{};di.prototype._setValue=vs;var pi=class extends yt{};pi.prototype._setValue=ha;var Ks=class extends rt{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new Ut(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=hr({type:this.type.indices,nullValues:e}),this.dictionary=hr({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 mi=class extends yt{};mi.prototype._setValue=ca;var Zs=class extends rt{setValue(t,e){let[n]=this.children,i=t*this.stride;for(let s=-1,o=e.length;++s<o;)n.set(i+s,e[s])}addChild(t,e="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");let n=this.children.push(t);return this.type=new Vt(this.type.listSize,new D(e,t.type,!0)),n}};var en=class extends yt{setValue(t,e){this._values.set(t,e)}},Js=class extends en{setValue(t,e){super.setValue(t,ni(e))}},Xs=class extends en{},Qs=class extends en{};var rn=class extends yt{};rn.prototype._setValue=da;var yi=class extends rn{};yi.prototype._setValue=Fs;var gi=class extends rn{};gi.prototype._setValue=Ms;var dr=class extends yt{};dr.prototype._setValue=pa;var bi=class extends dr{};bi.prototype._setValue=Ls;var wi=class extends dr{};wi.prototype._setValue=Ns;var _i=class extends dr{};_i.prototype._setValue=Us;var vi=class extends dr{};vi.prototype._setValue=Es;var Se=class extends yt{setValue(t,e){this._values.set(t,e)}},qs=class extends Se{},to=class extends Se{},eo=class extends Se{},ro=class extends Se{},no=class extends Se{},io=class extends Se{},so=class extends Se{},oo=class extends Se{};var ao=class extends ee{constructor(t){super(t),this._offsets=new Mn(t.type)}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new Tt(new D(e,t.type,!0)),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(typeof s>"u")e.set(i,0);else{let o=s,a=o.length,c=e.set(i,a).buffer[i];for(let l=-1;++l<a;)n.set(c+l,o[l])}}};var co=class extends ee{set(t,e){return super.set(t,e)}setValue(t,e){let n=e instanceof Map?e:new Map(Object.entries(e)),i=this._pending||(this._pending=new Map),s=i.get(t);s&&(this._pendingLength-=s.size),this._pendingLength+=n.size,i.set(t,n)}addChild(t,e=`${this.numChildren}`){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new jt(new D(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(s===void 0)e.set(i,0);else{let{[i]:o,[i+1]:a}=e.set(i,s.size).buffer;for(let c of s.entries())if(n.set(o,c),++o>=a)break}}};var lo=class extends rt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var uo=class extends rt{setValue(t,e){let{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach((s,o)=>n[o].set(t,e[o]));case Map:return i.children.forEach((s,o)=>n[o].set(t,e.get(s.name)));default:return i.children.forEach((s,o)=>n[o].set(t,e[s.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(n=>n.setValid(t,e)),e}addChild(t,e=`${this.numChildren}`){let n=this.children.push(t);return this.type=new V([...this.type.children,new D(e,t.type,!0)]),n}};var pr=class extends yt{};pr.prototype._setValue=ua;var Ii=class extends pr{};Ii.prototype._setValue=Is;var xi=class extends pr{};xi.prototype._setValue=xs;var Si=class extends pr{};Si.prototype._setValue=Ss;var Bi=class extends pr{};Bi.prototype._setValue=Bs;var mr=class extends yt{};mr.prototype._setValue=fa;var Ai=class extends mr{};Ai.prototype._setValue=As;var Ti=class extends mr{};Ti.prototype._setValue=Ts;var Di=class extends mr{};Di.prototype._setValue=Ds;var Oi=class extends mr{};Oi.prototype._setValue=Os;var Rn=class extends rt{constructor(t){super(t),this._typeIds=new lr(Int8Array,0,1),typeof t.valueToChildTypeId=="function"&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,n){return n===void 0&&(n=this._valueToChildTypeId(this,e,t)),this.setValue(t,e,n),this}setValue(t,e,n){this._typeIds.set(t,n);let i=this.type.typeIdToChildIndex[n],s=this.children[i];s?.set(t,e)}addChild(t,e=`${this.children.length}`){let n=this.children.push(t),{type:{children:i,mode:s,typeIds:o}}=this,a=[...i,new D(e,t.type)];return this.type=new Ie(s,[...o,n],a),n}_valueToChildTypeId(t,e,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},fo=class extends Rn{},ho=class extends Rn{constructor(t){super(t),this._offsets=new lr(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 Fi=class extends ee{constructor(t){super(t),this._values=new Ue(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,Ce(e))}_flushPending(t,e){}};Fi.prototype._flushPending=Un.prototype._flushPending;var Mi=class extends ee{constructor(t){super(t),this._values=new Ue(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,Ce(e))}_flushPending(t,e){}};Mi.prototype._flushPending=En.prototype._flushPending;var Fa=class extends v{visitNull(){return lo}visitBool(){return Ys}visitInt(){return Se}visitInt8(){return qs}visitInt16(){return to}visitInt32(){return eo}visitInt64(){return ro}visitUint8(){return no}visitUint16(){return io}visitUint32(){return so}visitUint64(){return oo}visitFloat(){return en}visitFloat16(){return Js}visitFloat32(){return Xs}visitFloat64(){return Qs}visitUtf8(){return Fi}visitLargeUtf8(){return Mi}visitBinary(){return Un}visitLargeBinary(){return En}visitFixedSizeBinary(){return mi}visitDate(){return tn}visitDateDay(){return hi}visitDateMillisecond(){return di}visitTimestamp(){return pr}visitTimestampSecond(){return Ii}visitTimestampMillisecond(){return xi}visitTimestampMicrosecond(){return Si}visitTimestampNanosecond(){return Bi}visitTime(){return mr}visitTimeSecond(){return Ai}visitTimeMillisecond(){return Ti}visitTimeMicrosecond(){return Di}visitTimeNanosecond(){return Oi}visitDecimal(){return pi}visitList(){return ao}visitStruct(){return uo}visitUnion(){return Rn}visitDenseUnion(){return ho}visitSparseUnion(){return fo}visitDictionary(){return Ks}visitInterval(){return rn}visitIntervalDayTime(){return yi}visitIntervalYearMonth(){return gi}visitDuration(){return dr}visitDurationSecond(){return bi}visitDurationMillisecond(){return wi}visitDurationMicrosecond(){return _i}visitDurationNanosecond(){return vi}visitFixedSizeList(){return Zs}visitMap(){return co}},Ql=new Fa;var B=class extends v{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((n,i)=>this.compareFields(n,e[i]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}};function zt(r,t){return t instanceof r.constructor}function nn(r,t){return r===t||zt(r,t)}function yr(r,t){return r===t||zt(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function po(r,t){return r===t||zt(r,t)&&r.precision===t.precision}function ld(r,t){return r===t||zt(r,t)&&r.byteWidth===t.byteWidth}function Ma(r,t){return r===t||zt(r,t)&&r.unit===t.unit}function Li(r,t){return r===t||zt(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function Ni(r,t){return r===t||zt(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function ud(r,t){return r===t||zt(r,t)&&r.children.length===t.children.length&&rr.compareManyFields(r.children,t.children)}function fd(r,t){return r===t||zt(r,t)&&r.children.length===t.children.length&&rr.compareManyFields(r.children,t.children)}function La(r,t){return r===t||zt(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&rr.compareManyFields(r.children,t.children)}function hd(r,t){return r===t||zt(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&rr.visit(r.indices,t.indices)&&rr.visit(r.dictionary,t.dictionary)}function Na(r,t){return r===t||zt(r,t)&&r.unit===t.unit}function Ui(r,t){return r===t||zt(r,t)&&r.unit===t.unit}function dd(r,t){return r===t||zt(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&rr.compareManyFields(r.children,t.children)}function pd(r,t){return r===t||zt(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&rr.compareManyFields(r.children,t.children)}B.prototype.visitNull=nn;B.prototype.visitBool=nn;B.prototype.visitInt=yr;B.prototype.visitInt8=yr;B.prototype.visitInt16=yr;B.prototype.visitInt32=yr;B.prototype.visitInt64=yr;B.prototype.visitUint8=yr;B.prototype.visitUint16=yr;B.prototype.visitUint32=yr;B.prototype.visitUint64=yr;B.prototype.visitFloat=po;B.prototype.visitFloat16=po;B.prototype.visitFloat32=po;B.prototype.visitFloat64=po;B.prototype.visitUtf8=nn;B.prototype.visitLargeUtf8=nn;B.prototype.visitBinary=nn;B.prototype.visitLargeBinary=nn;B.prototype.visitFixedSizeBinary=ld;B.prototype.visitDate=Ma;B.prototype.visitDateDay=Ma;B.prototype.visitDateMillisecond=Ma;B.prototype.visitTimestamp=Li;B.prototype.visitTimestampSecond=Li;B.prototype.visitTimestampMillisecond=Li;B.prototype.visitTimestampMicrosecond=Li;B.prototype.visitTimestampNanosecond=Li;B.prototype.visitTime=Ni;B.prototype.visitTimeSecond=Ni;B.prototype.visitTimeMillisecond=Ni;B.prototype.visitTimeMicrosecond=Ni;B.prototype.visitTimeNanosecond=Ni;B.prototype.visitDecimal=nn;B.prototype.visitList=ud;B.prototype.visitStruct=fd;B.prototype.visitUnion=La;B.prototype.visitDenseUnion=La;B.prototype.visitSparseUnion=La;B.prototype.visitDictionary=hd;B.prototype.visitInterval=Na;B.prototype.visitIntervalDayTime=Na;B.prototype.visitIntervalYearMonth=Na;B.prototype.visitDuration=Ui;B.prototype.visitDurationSecond=Ui;B.prototype.visitDurationMillisecond=Ui;B.prototype.visitDurationMicrosecond=Ui;B.prototype.visitDurationNanosecond=Ui;B.prototype.visitFixedSizeList=dd;B.prototype.visitMap=pd;var rr=new B;function sn(r,t){return rr.compareSchemas(r,t)}function ql(r,t){return rr.compareFields(r,t)}function mo(r,t){return rr.visit(r,t)}function hr(r){let t=r.type,e=new(Ql.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(hr(Object.assign(Object.assign({},l),{type:c})))}}return e}function Ei(r,t){if(r instanceof R||r instanceof g||r.type instanceof m||ArrayBuffer.isView(r))return Dr(r);let e={type:t??yo(r),nullValues:[null]},n=[...Ua(e)(r)],i=n.length===1?n[0]:n.reduce((s,o)=>s.concat(o));return m.isDictionary(i.type)?i.memoize():i}function yo(r){if(r.length===0)return new ut;let t=0,e=0,n=0,i=0,s=0,o=0,a=0,c=0;for(let l of r){if(l==null){++t;continue}switch(typeof l){case"bigint":++o;continue;case"boolean":++a;continue;case"number":++i;continue;case"string":++s;continue;case"object":Array.isArray(l)?++e:Object.prototype.toString.call(l)==="[object Date]"?++c:++n;continue}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}if(i+t===r.length)return new Qt;if(s+t===r.length)return new Ut(new Pt,new pt);if(o+t===r.length)return new be;if(a+t===r.length)return new kt;if(c+t===r.length)return new ar;if(e+t===r.length){let l=r,u=yo(l[l.findIndex(h=>h!=null)]);if(l.every(h=>h==null||mo(u,yo(h))))return new Tt(new D("",u,!0))}else if(n+t===r.length){let l=new Map;for(let u of r)for(let h of Object.keys(u))!l.has(h)&&u[h]!=null&&l.set(h,new D(h,yo([u[h]]),!0));return new V([...l.values()])}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}function Ua(r){let{["queueingStrategy"]:t="count"}=r,{["highWaterMark"]:e=t!=="bytes"?Number.POSITIVE_INFINITY:Math.pow(2,14)}=r,n=t!=="bytes"?"length":"byteLength";return function*(i){let s=0,o=hr(r);for(let a of i)o.append(a)[n]>=e&&++s&&(yield o.toVector());(o.finish().length>0||s===0)&&(yield o.toVector())}}function go(r,t){return md(r,t.map(e=>e.data.concat()))}function md(r,t){let e=[...r.fields],n=[],i={numBatches:t.reduce((h,d)=>Math.max(h,d.length),0)},s=0,o=0,a=-1,c=t.length,l,u=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a<c;)u[a]=l=t[a].shift(),o=Math.min(o,l?l.length:o);Number.isFinite(o)&&(u=yd(e,o,u,t,i),o>0&&(n[s++]=w({type:new V(e),length:o,nullCount:0,children:u.slice()})))}return[r=r.assign(e),n.map(h=>new Y(r,h))]}function yd(r,t,e,n,i){var s;let o=(t+63&-64)>>3;for(let a=-1,c=n.length;++a<c;){let l=e[a],u=l?.length;if(u>=t)u===t?e[a]=l:(e[a]=l.slice(0,t),i.numBatches=Math.max(i.numBatches,n[a].unshift(l.slice(t,u-t))));else{let h=r[a];r[a]=h.clone({nullable:!0}),e[a]=(s=l?._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:w({type:h.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var tu,J=class{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new E([]),this._offsets=[0],this;let i,s;t[0]instanceof E&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=c=>{if(c){if(c instanceof Y)return[c];if(c instanceof J)return c.batches;if(c instanceof R){if(c.type instanceof V)return[new Y(new E(c.type.children),c)]}else{if(Array.isArray(c))return c.flatMap(l=>o(l));if(typeof c[Symbol.iterator]=="function")return[...c].flatMap(l=>o(l));if(typeof c=="object"){let l=Object.keys(c),u=l.map(b=>new g([c[b]])),h=i??new E(l.map((b,M)=>new D(String(b),u[M].type,u[M].nullable))),[,d]=go(h,u);return d.length===0?[new Y(c)]:d}}}return[]},a=t.flatMap(c=>o(c));if(i=(n=i??((e=a[0])===null||e===void 0?void 0:e.schema))!==null&&n!==void 0?n:new E([]),!(i instanceof E))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof Y))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!sn(i,c.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??Vs(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=ks(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?Dn.visit(new g(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
13
+ return true;`)}function ud(r){return typeof r!="bigint"?Ae(r):`${Ae(r)}n`}function Ma(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function nu(r,t=0){return r.length>=t?r.subarray(0,t):ti(new r.constructor(t),r,0)}var Oe=class{constructor(t,e=0,n=1){this.length=Math.ceil(e/n),this.buffer=new t(this.length),this.stride=n,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=t}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(t,e){return this}append(t){return this.set(this.length,t)}reserve(t){if(t>0){this.length+=t;let e=this.stride,n=this.length*e,i=this.buffer.length;n>=i&&this._resize(i===0?Ma(n*1,this.BYTES_PER_ELEMENT):Ma(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=Ma(t*this.stride,this.BYTES_PER_ELEMENT);let e=nu(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=nu(this.buffer,t)}},ur=class extends Oe{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}},Fn=class extends ur{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){let{buffer:n}=this.reserve(t-this.length+1),i=t>>3,s=t%8,o=n[i]>>s&1;return e?o===0&&(n[i]|=1<<s,++this.numValid):o===1&&(n[i]&=~(1<<s),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},Mn=class extends ur{constructor(t){super(t.OffsetArrayType,1,1)}append(t){return this.set(this.length-1,t)}set(t,e){let n=this.length-1,i=this.reserve(t-n+1).buffer;return n<t++&&n>=0&&i.fill(i[n],n,t),i[t]=i[t-1]+e,this}flush(t=this.length-1){return t>this.length&&this.set(t-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(t+1)}};var nt=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=ue(t),this._nulls=new Fn,e&&e.length>0&&(this._isValid=ru(e))}toVector(){return new b([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0,{_offsets:e,_values:n,_nulls:i,_typeIds:s,children:o}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),o.reduce((a,c)=>a+c.byteLength,t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((e,n)=>e+n.reservedByteLength,t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(t){return this.children[t]||null}flush(){let t,e,n,i,{type:s,length:o,nullCount:a,_typeIds:c,_offsets:l,_values:u,_nulls:h}=this;(e=c?.flush(o))?i=l?.flush(o):(i=l?.flush(o))?t=u?.flush(l.last()):t=u?.flush(o),a>0&&(n=h?.flush(o));let d=this.children.map(p=>p.flush());return this.clear(),w({type:s,length:o,nullCount:a,children:d,child:d[0],data:t,typeIds:e,nullBitmap:n,valueOffsets:i})}finish(){this.finished=!0;for(let t of this.children)t.finish();return this}clear(){var t,e,n,i;this.length=0,(t=this._nulls)===null||t===void 0||t.clear(),(e=this._values)===null||e===void 0||e.clear(),(n=this._offsets)===null||n===void 0||n.clear(),(i=this._typeIds)===null||i===void 0||i.clear();for(let s of this.children)s.clear();return this}};nt.prototype.length=1;nt.prototype.stride=1;nt.prototype.children=null;nt.prototype.finished=!1;nt.prototype.nullValues=null;nt.prototype._isValid=()=>!0;var mt=class extends nt{constructor(t){super(t),this._values=new ur(this.ArrayType,0,this.stride)}setValue(t,e){let n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}},qt=class extends nt{constructor(t){super(t),this._pendingLength=0,this._offsets=new Mn(t.type)}setValue(t,e){let n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.length),this._pendingLength+=e instanceof tr?e[be].length:e.length,n.set(t,e)}setValid(t,e){return super.setValid(t,e)?!0:((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}};var tn=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,n,i){return t.prep(8,24),t.writeInt64(BigInt(i??0)),t.pad(4),t.writeInt32(n),t.writeInt64(BigInt(e??0)),t.offset()}};var Et=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new Et).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new Et).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):H.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new ot).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new tn).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}dictionariesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){let n=this.bb.__offset(this.bb_pos,10);return n?(e||new tn).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}recordBatchesLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Q).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,H.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}};var R=class{constructor(t=[],e,n,i=H.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=La(t)),this.dictionaries=n,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,e)=>`${e}: ${t}`).join(", ")} }>`}select(t){let e=new Set(t),n=this.fields.filter(i=>e.has(i.name));return new R(n,this.metadata)}selectAt(t){let e=t.map(n=>this.fields[n]).filter(Boolean);return new R(e,this.metadata)}assign(...t){let e=t[0]instanceof R?t[0]:Array.isArray(t[0])?new R(t[0]):new R(t),n=[...this.fields],i=Ys(Ys(new Map,this.metadata),e.metadata),s=e.fields.filter(a=>{let c=n.findIndex(l=>l.name===a.name);return~c?(n[c]=a.clone({metadata:Ys(Ys(new Map,n[c].metadata),a.metadata)}))&&!1:!0}),o=La(s,new Map);return new R([...n,...s],i,new Map([...this.dictionaries,...o]))}};R.prototype.fields=null;R.prototype.metadata=null;R.prototype.dictionaries=null;var O=class{static new(...t){let[e,n,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],n===void 0&&(n=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new O(`${e}`,n,i,s)}constructor(t,e,n=!1,i){this.name=t,this.type=e,this.nullable=n,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,n,i,s]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,n=this.type,i=this.nullable,s=this.metadata]=t:{name:e=this.name,type:n=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],O.new(e,n,i,s)}};O.prototype.type=null;O.prototype.name=null;O.prototype.nullable=null;O.prototype.metadata=null;function Ys(r,t){return new Map([...r||new Map,...t||new Map])}function La(r,t=new Map){for(let e=-1,n=r.length;++e<n;){let s=r[e].type;if(y.isDictionary(s)){if(!t.has(s.id))t.set(s.id,s.dictionary);else if(t.get(s.id)!==s.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}s.children&&s.children.length>0&&La(s.children,t)}return t}var fd=ar,hd=Ct,fr=class{static decode(t){t=new hd(D(t));let e=Et.getRootAsFooter(t),n=R.decode(e.schema(),new Map,e.version());return new Na(n,e)}static encode(t){let e=new fd,n=R.encode(e,t.schema);Et.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())Fe.encode(e,o);let i=e.endVector();Et.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())Fe.encode(e,o);let s=e.endVector();return Et.startFooter(e),Et.addSchema(e,n),Et.addVersion(e,H.V5),Et.addRecordBatches(e,i),Et.addDictionaries(e,s),Et.finishFooterBuffer(e,Et.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=H.V5,n,i){this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e<n;)(t=this.getRecordBatch(e))&&(yield t)}*dictionaryBatches(){for(let t,e=-1,n=this.numDictionaries;++e<n;)(t=this.getDictionaryBatch(e))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}};var Na=class extends fr{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,e){super(t,e.version()),this._footer=e}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){let e=this._footer.recordBatches(t);if(e)return Fe.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return Fe.decode(e)}return null}},Fe=class{static decode(t){return new Fe(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){let{metaDataLength:n}=e,i=BigInt(e.offset),s=BigInt(e.bodyLength);return tn.createBlock(t,i,n,s)}constructor(t,e,n){this.metaDataLength=t,this.offset=at(n),this.bodyLength=at(e)}};var q=Object.freeze({done:!0,value:void 0}),fi=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},en=class{tee(){return this._getDOMStream().tee()}pipe(t,e){return this._getNodeStream().pipe(t,e)}pipeTo(t,e){return this._getDOMStream().pipeTo(t,e)}pipeThrough(t,e){return this._getDOMStream().pipeThrough(t,e)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}},Ks=class extends en{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return g(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){let{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(q);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return Bt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return Bt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return g(this,void 0,void 0,function*(){return yield this.abort(t),q})}return(t){return g(this,void 0,void 0,function*(){return yield this.close(),q})}read(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,n)=>{this.resolvers.push({resolve:e,reject:n})}):Promise.resolve(q)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var er=class extends Ks{write(t){if((t=D(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Qn(this.toUint8Array(!0)):this.toUint8Array(!1).then(Qn)}toUint8Array(t=!1){return t?oe(this._values)[0]:(()=>g(this,void 0,void 0,function*(){var e,n,i,s;let o=[],a=0;try{for(var c=!0,l=ve(this),u;u=yield l.next(),e=u.done,!e;c=!0){s=u.value,c=!1;let h=s;o.push(h),a+=h.byteLength}}catch(h){n={error:h}}finally{try{!c&&!e&&(i=l.return)&&(yield i.call(l))}finally{if(n)throw n.error}}return oe(o,a)[0]}))()}},rr=class{constructor(t){t&&(this.source=new Ua(Bt.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},te=class{constructor(t){t instanceof te?this.source=t.source:t instanceof er?this.source=new hr(Bt.fromAsyncIterable(t)):ms(t)?this.source=new hr(Bt.fromNodeStream(t)):qn(t)?this.source=new hr(Bt.fromDOMStream(t)):ds(t)?this.source=new hr(Bt.fromDOMStream(t.body)):Ie(t)?this.source=new hr(Bt.fromIterable(t)):se(t)?this.source=new hr(Bt.fromAsyncIterable(t)):fe(t)&&(this.source=new hr(Bt.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},Ua=class{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||q)}return(t){return Object.create(this.source.return&&this.source.return(t)||q)}},hr=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return g(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t,e="read"){return g(this,void 0,void 0,function*(){return yield this.source.next({cmd:e,size:t})})}throw(t){return g(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||q;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return g(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||q;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var hi=class extends rr{constructor(t,e){super(),this.position=0,this.buffer=D(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){let{buffer:e,byteOffset:n}=this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){let{buffer:e,size:n,position:i}=this;return e&&i<n?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(n,i+Math.min(n-i,t)),e.subarray(i,this.position)):null}readAt(t,e){let n=this.buffer,i=Math.min(this.size,t+e);return n?n.subarray(t,i):new Uint8Array(e)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}},Fr=class extends te{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=(()=>g(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending}))()}readInt32(t){return g(this,void 0,void 0,function*(){let{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return g(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return g(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:n,position:i}=this;if(e&&i<n){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,o=0,a=0,c=Math.min(n,s+Math.min(n-s,t)),l=new Uint8Array(Math.max(0,(this.position=c)-s));for(;(s+=a)<c&&(o+=a)<l.byteLength;)({bytesRead:a}=yield e.read(l,o,l.byteLength-o,s));return l}return null})}readAt(t,e){return g(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:n,size:i}=this;if(n&&t+e<i){let s=Math.min(i,t+e),o=new Uint8Array(s-t);return(yield n.read(o,0,e,t)).buffer}return new Uint8Array(e)})}close(){return g(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return g(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return g(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var Ra={};Ir(Ra,{BaseInt64:()=>di,Int128:()=>ee,Int64:()=>St,Uint64:()=>$});function Ln(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var Nn=8,Ea=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],di=class{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){let e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]),i=e[3]*n[3];this.buffer[0]=i&65535;let s=i>>>16;return i=e[2]*n[3],s+=i,i=e[3]*n[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?65536:0,this.buffer[1]+=s>>>16,this.buffer[1]+=e[1]*n[3]+e[2]*n[2]+e[3]*n[1],this.buffer[1]+=e[0]*n[3]+e[1]*n[2]+e[2]*n[1]+e[3]*n[0]<<16,this}_plus(t){let e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return`${Ln(this.buffer[1])} ${Ln(this.buffer[0])}`}},$=class extends di{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return $.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return $.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.length,i=new $(e);for(let s=0;s<n;){let o=Nn<n-s?Nn:n-s,a=new $(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new $(new Uint32Array([Ea[o],0]));i.times(c),i.plus(a),s+=o}return i}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)$.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new $(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new $(new Uint32Array(t.buffer)).plus(e)}},St=class extends di{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){let e=this.buffer[1]<<0,n=t.buffer[1]<<0;return e<n||e===n&&this.buffer[0]<t.buffer[0]}static from(t,e=new Uint32Array(2)){return St.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return St.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.startsWith("-"),i=t.length,s=new St(e);for(let o=n?1:0;o<i;){let a=Nn<i-o?Nn:i-o,c=new St(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new St(new Uint32Array([Ea[a],0]));s.times(l),s.plus(c),o+=a}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)St.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new St(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new St(new Uint32Array(t.buffer)).plus(e)}},ee=class{constructor(t){this.buffer=t}high(){return new St(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new St(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){let e=new $(new Uint32Array([this.buffer[3],0])),n=new $(new Uint32Array([this.buffer[2],0])),i=new $(new Uint32Array([this.buffer[1],0])),s=new $(new Uint32Array([this.buffer[0],0])),o=new $(new Uint32Array([t.buffer[3],0])),a=new $(new Uint32Array([t.buffer[2],0])),c=new $(new Uint32Array([t.buffer[1],0])),l=new $(new Uint32Array([t.buffer[0],0])),u=$.multiply(s,l);this.buffer[0]=u.low();let h=new $(new Uint32Array([u.high(),0]));return u=$.multiply(i,l),h.plus(u),u=$.multiply(s,c),h.plus(u),this.buffer[1]=h.low(),this.buffer[3]=h.lessThan(u)?1:0,this.buffer[2]=h.high(),new $(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus($.multiply(n,l)).plus($.multiply(i,c)).plus($.multiply(s,a)),this.buffer[3]+=$.multiply(e,l).plus($.multiply(n,c)).plus($.multiply(i,a)).plus($.multiply(s,o)).low(),this}plus(t){let e=new Uint32Array(4);return e[3]=this.buffer[3]+t.buffer[3]>>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]<this.buffer[0]>>>0&&++e[1],e[1]<this.buffer[1]>>>0&&++e[2],e[2]<this.buffer[2]>>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${Ln(this.buffer[3])} ${Ln(this.buffer[2])} ${Ln(this.buffer[1])} ${Ln(this.buffer[0])}`}static multiply(t,e){return new ee(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new ee(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return ee.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return ee.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let n=t.startsWith("-"),i=t.length,s=new ee(e);for(let o=n?1:0;o<i;){let a=Nn<i-o?Nn:i-o,c=new ee(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new ee(new Uint32Array([Ea[a],0,0,0]));s.times(l),s.plus(c),o+=a}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*4);for(let n=-1,i=t.length;++n<i;)ee.from(t[n],new Uint32Array(e.buffer,e.byteOffset+4*4*n,4));return e}};var pi=class extends I{constructor(t,e,n,i,s=H.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=e,this.buffers=n,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof O?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return w({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),children:this.visitMany(t.children)})}visitUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return this.metadataVersion<H.V5&&this.readNullBitmap(t,n),t.mode===J.Sparse?this.visitSparseUnion(t,{length:e,nullCount:n}):this.visitDenseUnion(t,{length:e,nullCount:n})}visitDenseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),child:this.visit(t.children[0])})}visitMap(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,e,n=this.nextBufferRange()){return e>0&&this.readData(t,n)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+e)}readDictionary(t){return this.dictionaries.get(t.id)}},Zs=class extends pi{constructor(t,e,n,i,s){super(new Uint8Array(0),e,n,i,s),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):Xr(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return C(Uint8Array,C(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return C(Uint8Array,C(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;return y.isTimestamp(t)?C(Uint8Array,St.convertArray(n[e])):(y.isInt(t)||y.isTime(t))&&t.bitWidth===64||y.isDuration(t)?C(Uint8Array,St.convertArray(n[e])):y.isDate(t)&&t.unit===rt.MILLISECOND?C(Uint8Array,St.convertArray(n[e])):y.isDecimal(t)?C(Uint8Array,ee.convertArray(n[e])):y.isBinary(t)||y.isLargeBinary(t)||y.isFixedSizeBinary(t)?dd(n[e]):y.isBool(t)?Xr(n[e]):y.isUtf8(t)||y.isLargeUtf8(t)?Ne(n[e].join("")):C(Uint8Array,C(t.ArrayType,n[e].map(i=>+i)))}};function dd(r){let t=r.join(""),e=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)e[n>>1]=Number.parseInt(t.slice(n,n+2),16);return e}var Un=class extends qt{constructor(t){super(t),this._values=new Oe(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,D(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)n.set(o,0);else{let c=a.length;i.set(a,s),n.set(o,c),s+=c}}};var En=class extends qt{constructor(t){super(t),this._values=new Oe(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,D(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)n.set(o,BigInt(0));else{let c=a.length;i.set(a,s),n.set(o,BigInt(c)),s+=c}}};var Js=class extends nt{constructor(t){super(t),this._values=new Fn}setValue(t,e){this._values.set(t,+e)}};var rn=class extends mt{};rn.prototype._setValue=ya;var mi=class extends rn{};mi.prototype._setValue=xs;var yi=class extends rn{};yi.prototype._setValue=Ss;var gi=class extends mt{};gi.prototype._setValue=wa;var Xs=class extends nt{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new Ut(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=Me({type:this.type.indices,nullValues:e}),this.dictionary=Me({type:this.type.dictionary,nullValues:null}),typeof n=="function"&&(this.valueToKey=n)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(t){return this.indices.isValid(t)}setValid(t,e){let n=this.indices;return e=n.setValid(t,e),this.length=n.length,e}setValue(t,e){let n=this._keysToIndices,i=this.valueToKey(e),s=n[i];return s===void 0&&(n[i]=s=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,s)}flush(){let t=this.type,e=this._dictionary,n=this.dictionary.toVector(),i=this.indices.flush().clone(t);return i.dictionary=e?e.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=i.dictionary,this.clear(),i}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(t){return typeof t=="string"?t:`${t}`}};var bi=class extends mt{};bi.prototype._setValue=ma;var Qs=class extends nt{setValue(t,e){let[n]=this.children,i=t*this.stride;for(let s=-1,o=e.length;++s<o;)n.set(i+s,e[s])}addChild(t,e="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");let n=this.children.push(t);return this.type=new Vt(this.type.listSize,new O(e,t.type,!0)),n}};var nn=class extends mt{setValue(t,e){this._values.set(t,e)}},qs=class extends nn{setValue(t,e){super.setValue(t,oi(e))}},to=class extends nn{},eo=class extends nn{};var sn=class extends mt{};sn.prototype._setValue=_a;var wi=class extends sn{};wi.prototype._setValue=Ns;var _i=class extends sn{};_i.prototype._setValue=Us;var dr=class extends mt{};dr.prototype._setValue=va;var vi=class extends dr{};vi.prototype._setValue=Es;var Ii=class extends dr{};Ii.prototype._setValue=Rs;var xi=class extends dr{};xi.prototype._setValue=Cs;var Si=class extends dr{};Si.prototype._setValue=Ps;var we=class extends mt{setValue(t,e){this._values.set(t,e)}},ro=class extends we{},no=class extends we{},io=class extends we{},so=class extends we{},oo=class extends we{},ao=class extends we{},co=class extends we{},lo=class extends we{};var uo=class extends qt{constructor(t){super(t),this._offsets=new Mn(t.type)}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new Tt(new O(e,t.type,!0)),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(typeof s>"u")e.set(i,0);else{let o=s,a=o.length,c=e.set(i,a).buffer[i];for(let l=-1;++l<a;)n.set(c+l,o[l])}}};var fo=class extends qt{set(t,e){return super.set(t,e)}setValue(t,e){let n=e instanceof Map?e:new Map(Object.entries(e)),i=this._pending||(this._pending=new Map),s=i.get(t);s&&(this._pendingLength-=s.size),this._pendingLength+=n.size,i.set(t,n)}addChild(t,e=`${this.numChildren}`){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new jt(new O(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(s===void 0)e.set(i,0);else{let{[i]:o,[i+1]:a}=e.set(i,s.size).buffer;for(let c of s.entries())if(n.set(o,c),++o>=a)break}}};var ho=class extends nt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var po=class extends nt{setValue(t,e){let{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach((s,o)=>n[o].set(t,e[o]));case Map:return i.children.forEach((s,o)=>n[o].set(t,e.get(s.name)));default:return i.children.forEach((s,o)=>n[o].set(t,e[s.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(n=>n.setValid(t,e)),e}addChild(t,e=`${this.numChildren}`){let n=this.children.push(t);return this.type=new V([...this.type.children,new O(e,t.type,!0)]),n}};var pr=class extends mt{};pr.prototype._setValue=ga;var Bi=class extends pr{};Bi.prototype._setValue=Bs;var Ai=class extends pr{};Ai.prototype._setValue=As;var Ti=class extends pr{};Ti.prototype._setValue=Ts;var Di=class extends pr{};Di.prototype._setValue=Ds;var mr=class extends mt{};mr.prototype._setValue=ba;var Oi=class extends mr{};Oi.prototype._setValue=Os;var Fi=class extends mr{};Fi.prototype._setValue=Fs;var Mi=class extends mr{};Mi.prototype._setValue=Ms;var Li=class extends mr{};Li.prototype._setValue=Ls;var Rn=class extends nt{constructor(t){super(t),this._typeIds=new ur(Int8Array,0,1),typeof t.valueToChildTypeId=="function"&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,n){return n===void 0&&(n=this._valueToChildTypeId(this,e,t)),this.setValue(t,e,n),this}setValue(t,e,n){this._typeIds.set(t,n);let i=this.type.typeIdToChildIndex[n],s=this.children[i];s?.set(t,e)}addChild(t,e=`${this.children.length}`){let n=this.children.push(t),{type:{children:i,mode:s,typeIds:o}}=this,a=[...i,new O(e,t.type)];return this.type=new ge(s,[...o,n],a),n}_valueToChildTypeId(t,e,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},mo=class extends Rn{},yo=class extends Rn{constructor(t){super(t),this._offsets=new ur(Int32Array)}setValue(t,e,n){let i=this._typeIds.set(t,n).buffer[t],s=this.getChildAt(this.type.typeIdToChildIndex[i]),o=this._offsets.set(t,s.length).buffer[t];s?.set(o,e)}};var Ni=class extends qt{constructor(t){super(t),this._values=new Oe(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Ne(e))}_flushPending(t,e){}};Ni.prototype._flushPending=Un.prototype._flushPending;var Ui=class extends qt{constructor(t){super(t),this._values=new Oe(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,Ne(e))}_flushPending(t,e){}};Ui.prototype._flushPending=En.prototype._flushPending;var Ca=class extends I{visitNull(){return ho}visitBool(){return Js}visitInt(){return we}visitInt8(){return ro}visitInt16(){return no}visitInt32(){return io}visitInt64(){return so}visitUint8(){return oo}visitUint16(){return ao}visitUint32(){return co}visitUint64(){return lo}visitFloat(){return nn}visitFloat16(){return qs}visitFloat32(){return to}visitFloat64(){return eo}visitUtf8(){return Ni}visitLargeUtf8(){return Ui}visitBinary(){return Un}visitLargeBinary(){return En}visitFixedSizeBinary(){return bi}visitDate(){return rn}visitDateDay(){return mi}visitDateMillisecond(){return yi}visitTimestamp(){return pr}visitTimestampSecond(){return Bi}visitTimestampMillisecond(){return Ai}visitTimestampMicrosecond(){return Ti}visitTimestampNanosecond(){return Di}visitTime(){return mr}visitTimeSecond(){return Oi}visitTimeMillisecond(){return Fi}visitTimeMicrosecond(){return Mi}visitTimeNanosecond(){return Li}visitDecimal(){return gi}visitList(){return uo}visitStruct(){return po}visitUnion(){return Rn}visitDenseUnion(){return yo}visitSparseUnion(){return mo}visitDictionary(){return Xs}visitInterval(){return sn}visitIntervalDayTime(){return wi}visitIntervalYearMonth(){return _i}visitDuration(){return dr}visitDurationSecond(){return vi}visitDurationMillisecond(){return Ii}visitDurationMicrosecond(){return xi}visitDurationNanosecond(){return Si}visitFixedSizeList(){return Qs}visitMap(){return fo}},iu=new Ca;var A=class extends I{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((n,i)=>this.compareFields(n,e[i]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}};function zt(r,t){return t instanceof r.constructor}function on(r,t){return r===t||zt(r,t)}function yr(r,t){return r===t||zt(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function go(r,t){return r===t||zt(r,t)&&r.precision===t.precision}function pd(r,t){return r===t||zt(r,t)&&r.byteWidth===t.byteWidth}function Pa(r,t){return r===t||zt(r,t)&&r.unit===t.unit}function Ei(r,t){return r===t||zt(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function Ri(r,t){return r===t||zt(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function md(r,t){return r===t||zt(r,t)&&r.children.length===t.children.length&&nr.compareManyFields(r.children,t.children)}function yd(r,t){return r===t||zt(r,t)&&r.children.length===t.children.length&&nr.compareManyFields(r.children,t.children)}function ka(r,t){return r===t||zt(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&nr.compareManyFields(r.children,t.children)}function gd(r,t){return r===t||zt(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&nr.visit(r.indices,t.indices)&&nr.visit(r.dictionary,t.dictionary)}function Va(r,t){return r===t||zt(r,t)&&r.unit===t.unit}function Ci(r,t){return r===t||zt(r,t)&&r.unit===t.unit}function bd(r,t){return r===t||zt(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&nr.compareManyFields(r.children,t.children)}function wd(r,t){return r===t||zt(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&nr.compareManyFields(r.children,t.children)}A.prototype.visitNull=on;A.prototype.visitBool=on;A.prototype.visitInt=yr;A.prototype.visitInt8=yr;A.prototype.visitInt16=yr;A.prototype.visitInt32=yr;A.prototype.visitInt64=yr;A.prototype.visitUint8=yr;A.prototype.visitUint16=yr;A.prototype.visitUint32=yr;A.prototype.visitUint64=yr;A.prototype.visitFloat=go;A.prototype.visitFloat16=go;A.prototype.visitFloat32=go;A.prototype.visitFloat64=go;A.prototype.visitUtf8=on;A.prototype.visitLargeUtf8=on;A.prototype.visitBinary=on;A.prototype.visitLargeBinary=on;A.prototype.visitFixedSizeBinary=pd;A.prototype.visitDate=Pa;A.prototype.visitDateDay=Pa;A.prototype.visitDateMillisecond=Pa;A.prototype.visitTimestamp=Ei;A.prototype.visitTimestampSecond=Ei;A.prototype.visitTimestampMillisecond=Ei;A.prototype.visitTimestampMicrosecond=Ei;A.prototype.visitTimestampNanosecond=Ei;A.prototype.visitTime=Ri;A.prototype.visitTimeSecond=Ri;A.prototype.visitTimeMillisecond=Ri;A.prototype.visitTimeMicrosecond=Ri;A.prototype.visitTimeNanosecond=Ri;A.prototype.visitDecimal=on;A.prototype.visitList=md;A.prototype.visitStruct=yd;A.prototype.visitUnion=ka;A.prototype.visitDenseUnion=ka;A.prototype.visitSparseUnion=ka;A.prototype.visitDictionary=gd;A.prototype.visitInterval=Va;A.prototype.visitIntervalDayTime=Va;A.prototype.visitIntervalYearMonth=Va;A.prototype.visitDuration=Ci;A.prototype.visitDurationSecond=Ci;A.prototype.visitDurationMillisecond=Ci;A.prototype.visitDurationMicrosecond=Ci;A.prototype.visitDurationNanosecond=Ci;A.prototype.visitFixedSizeList=bd;A.prototype.visitMap=wd;var nr=new A;function an(r,t){return nr.compareSchemas(r,t)}function su(r,t){return nr.compareFields(r,t)}function bo(r,t){return nr.visit(r,t)}function Me(r){let t=r.type,e=new(iu.getVisitFn(t)())(r);if(t.children&&t.children.length>0){let n=r.children||[],i={nullValues:r.nullValues},s=Array.isArray(n)?(o,a)=>n[a]||i:({name:o})=>n[o]||i;for(let[o,a]of t.children.entries()){let{type:c}=a,l=s(a,o);e.children.push(Me(Object.assign(Object.assign({},l),{type:c})))}}return e}function Pi(r,t){if(r instanceof U||r instanceof b||r.type instanceof y||ArrayBuffer.isView(r))return Or(r);let e={type:t??wo(r),nullValues:[null]},n=[...ja(e)(r)],i=n.length===1?n[0]:n.reduce((s,o)=>s.concat(o));return y.isDictionary(i.type)?i.memoize():i}function wo(r){if(r.length===0)return new ut;let t=0,e=0,n=0,i=0,s=0,o=0,a=0,c=0;for(let l of r){if(l==null){++t;continue}switch(typeof l){case"bigint":++o;continue;case"boolean":++a;continue;case"number":++i;continue;case"string":++s;continue;case"object":Array.isArray(l)?++e:Object.prototype.toString.call(l)==="[object Date]"?++c:++n;continue}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}if(i+t===r.length)return new ye;if(s+t===r.length)return new Ut(new Pt,new It);if(o+t===r.length)return new pe;if(a+t===r.length)return new kt;if(c+t===r.length)return new cr;if(e+t===r.length){let l=r,u=wo(l[l.findIndex(h=>h!=null)]);if(l.every(h=>h==null||bo(u,wo(h))))return new Tt(new O("",u,!0))}else if(n+t===r.length){let l=new Map;for(let u of r)for(let h of Object.keys(u))!l.has(h)&&u[h]!=null&&l.set(h,new O(h,wo([u[h]]),!0));return new V([...l.values()])}throw new TypeError("Unable to infer Vector type from input values, explicit type declaration expected.")}function ja(r){let{["queueingStrategy"]:t="count"}=r,{["highWaterMark"]:e=t!=="bytes"?Number.POSITIVE_INFINITY:Math.pow(2,14)}=r,n=t!=="bytes"?"length":"byteLength";return function*(i){let s=0,o=Me(r);for(let a of i)o.append(a)[n]>=e&&++s&&(yield o.toVector());(o.finish().length>0||s===0)&&(yield o.toVector())}}function _o(r,t){return _d(r,t.map(e=>e.data.concat()))}function _d(r,t){let e=[...r.fields],n=[],i={numBatches:t.reduce((h,d)=>Math.max(h,d.length),0)},s=0,o=0,a=-1,c=t.length,l,u=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a<c;)u[a]=l=t[a].shift(),o=Math.min(o,l?l.length:o);Number.isFinite(o)&&(u=vd(e,o,u,t,i),o>0&&(n[s++]=w({type:new V(e),length:o,nullCount:0,children:u.slice()})))}return[r=r.assign(e),n.map(h=>new W(r,h))]}function vd(r,t,e,n,i){var s;let o=(t+63&-64)>>3;for(let a=-1,c=n.length;++a<c;){let l=e[a],u=l?.length;if(u>=t)u===t?e[a]=l:(e[a]=l.slice(0,t),i.numBatches=Math.max(i.numBatches,n[a].unshift(l.slice(t,u-t))));else{let h=r[a];r[a]=h.clone({nullable:!0}),e[a]=(s=l?._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:w({type:h.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var ou,K=class{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new R([]),this._offsets=[0],this;let i,s;t[0]instanceof R&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=c=>{if(c){if(c instanceof W)return[c];if(c instanceof K)return c.batches;if(c instanceof U){if(c.type instanceof V)return[new W(new R(c.type.children),c)]}else{if(Array.isArray(c))return c.flatMap(l=>o(l));if(typeof c[Symbol.iterator]=="function")return[...c].flatMap(l=>o(l));if(typeof c=="object"){let l=Object.keys(c),u=l.map(p=>new b([c[p]])),h=i??new R(l.map((p,v)=>new O(String(p),u[v].type,u[v].nullable))),[,d]=_o(h,u);return d.length===0?[new W(c)]:d}}}return[]},a=t.flatMap(c=>o(c));if(i=(n=i??((e=a[0])===null||e===void 0?void 0:e.schema))!==null&&n!==void 0?n:new R([]),!(i instanceof R))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof W))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!an(i,c.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??Ws(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,e)=>t+e.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=zs(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?Dn.visit(new b(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
14
14
  ${this.toArray().join(`,
15
15
  `)}
16
- ]`}concat(...t){let e=this.schema,n=this.data.concat(t.flatMap(({data:i})=>i));return new J(e,n.map(i=>new Y(e,i)))}slice(t,e){let n=this.schema;[t,e]=ii({length:this.numRows},t,e);let i=js(this.data,this._offsets,t,e);return new J(n,i.map(s=>new Y(n,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){let e=this.data.map(n=>n.children[t]);if(e.length===0){let{type:n}=this.schema.fields[t],i=w({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new g(e)}return null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new g([w({type:new ut,length:this.numRows})]));let s=n.fields.slice(),o=s[t].clone({type:e.type}),a=this.schema.fields.map((c,l)=>this.getChildAt(l));[s[t],a[t]]=[o,e],[n,i]=go(n,a)}return new J(n,i)}select(t){let e=this.schema.fields.reduce((n,i,s)=>n.set(i.name,s),new Map);return this.selectAt(t.map(n=>e.get(n)).filter(n=>n>-1))}selectAt(t){let e=this.schema.selectAt(t),n=this.batches.map(i=>i.selectAt(t));return new J(e,n)}assign(t){let e=this.schema.fields,[n,i]=t.schema.fields.reduce((a,c,l)=>{let[u,h]=a,d=e.findIndex(b=>b.name===c.name);return~d?h[d]=l:u.push(l),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,i[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...n.map(a=>t.getChildAt(a))].filter(Boolean);return new J(...go(s,o))}};tu=Symbol.toStringTag;J[tu]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Tn(ai),r.get=Tn(mt.getVisitFn(f.Struct)),r.set=zs(Dt.getVisitFn(f.Struct)),r.indexOf=Ws(Xr.getVisitFn(f.Struct)),"Table"))(J.prototype);var ru,Y=class{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof E))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=w({nullCount:0,type:new V(this.schema.fields),children:this.schema.fields.map(e=>w({type:e.type,nullCount:0}))})]=t,!(this.data instanceof R))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=eu(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:n,children:i,length:s}=Object.keys(e).reduce((c,l,u)=>(c.children[u]=e[l],c.length=Math.max(c.length,e[l].length),c.fields[u]=D.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new E(n),a=w({type:new V(n),length:s,children:i,nullCount:0});[this.schema,this.data]=eu(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=nu(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return mt.visit(this.data,t)}set(t,e){return Dt.visit(this.data,t,e)}indexOf(t,e){return Xr.visit(this.data,t,e)}[Symbol.iterator](){return Dn.visit(new g([this.data]))}toArray(){return[...this]}concat(...t){return new J(this.schema,[this,...t])}slice(t,e){let[n]=new g([this.data]).slice(t,e).data;return new Y(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new g([this.data.children[t]]):null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=this.data;if(t>-1&&t<this.numCols){e||(e=new g([w({type:new ut,length:this.numRows})]));let s=n.fields.slice(),o=i.children.slice(),a=s[t].clone({type:e.type});[s[t],o[t]]=[a,e.data[0]],n=new E(s,new Map(this.schema.metadata)),i=w({type:new V(s),children:o})}return new Y(n,i)}select(t){let e=this.schema.select(t),n=new V(e.fields),i=[];for(let s of t){let o=this.schema.fields.findIndex(a=>a.name===s);~o&&(i[o]=this.data.children[o])}return new Y(e,w({type:n,length:this.numRows,children:i}))}selectAt(t){let e=this.schema.selectAt(t),n=t.map(s=>this.data.children[s]).filter(Boolean),i=w({type:new V(e.fields),length:this.numRows,children:n});return new Y(e,i)}};ru=Symbol.toStringTag;Y[ru]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Y.prototype);function eu(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;let i=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(let[a,c]of r.fields.entries()){let l=t[a];(!l||l.length!==e)&&(i[a]=c.clone({nullable:!0}),s[a]=(n=l?._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:w({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(i),w({type:new V(i),length:e,children:s})]}function nu(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)||[]])nu(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 on=class extends Y{constructor(t){let e=t.fields.map(i=>w({type:i.type})),n=w({type:new V(t.fields),nullCount:0,children:e});super(t,n)}};var ft=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new ft).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new ft).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):$.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):P.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Q).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,$.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,P.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,n,i,s,o){return ft.startMessage(t),ft.addVersion(t,e),ft.addHeaderType(t,n),ft.addHeader(t,i),ft.addBodyLength(t,s),ft.addCustomMetadata(t,o),ft.endMessage(t)}};var Ea=class extends v{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return $e.startNull(e),$e.endNull(e)}visitInt(t,e){return _t.startInt(e),_t.addBitWidth(e,t.bitWidth),_t.addIsSigned(e,t.isSigned),_t.endInt(e)}visitFloat(t,e){return Kt.startFloatingPoint(e),Kt.addPrecision(e,t.precision),Kt.endFloatingPoint(e)}visitBinary(t,e){return Ve.startBinary(e),Ve.endBinary(e)}visitLargeBinary(t,e){return ze.startLargeBinary(e),ze.endLargeBinary(e)}visitBool(t,e){return je.startBool(e),je.endBool(e)}visitUtf8(t,e){return Ye.startUtf8(e),Ye.endUtf8(e)}visitLargeUtf8(t,e){return We.startLargeUtf8(e),We.endLargeUtf8(e)}visitDecimal(t,e){return vt.startDecimal(e),vt.addScale(e,t.scale),vt.addPrecision(e,t.precision),vt.addBitWidth(e,t.bitWidth),vt.endDecimal(e)}visitDate(t,e){return Gt.startDate(e),Gt.addUnit(e,t.unit),Gt.endDate(e)}visitTime(t,e){return Mt.startTime(e),Mt.addUnit(e,t.unit),Mt.addBitWidth(e,t.bitWidth),Mt.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return Lt.startTimestamp(e),Lt.addUnit(e,t.unit),n!==void 0&&Lt.addTimezone(e,n),Lt.endTimestamp(e)}visitInterval(t,e){return Zt.startInterval(e),Zt.addUnit(e,t.unit),Zt.endInterval(e)}visitDuration(t,e){return $t.startDuration(e),$t.addUnit(e,t.unit),$t.endDuration(e)}visitList(t,e){return Ge.startList(e),Ge.endList(e)}visitStruct(t,e){return He.startStruct_(e),He.endStruct_(e)}visitUnion(t,e){It.startTypeIdsVector(e,t.typeIds.length);let n=It.createTypeIdsVector(e,t.typeIds);return It.startUnion(e),It.addMode(e,t.mode),It.addTypeIds(e,n),It.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return le.startDictionaryEncoding(e),le.addId(e,BigInt(t.id)),le.addIsOrdered(e,t.isOrdered),n!==void 0&&le.addIndexType(e,n),le.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Ht.startFixedSizeBinary(e),Ht.addByteWidth(e,t.byteWidth),Ht.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Yt.startFixedSizeList(e),Yt.addListSize(e,t.listSize),Yt.endFixedSizeList(e)}visitMap(t,e){return Jt.startMap(e),Jt.addKeysSorted(e,t.keysSorted),Jt.endMap(e)}},bo=new Ea;function au(r,t=new Map){return new E(gd(r,t),wo(r.metadata),t)}function Ra(r){return new Ot(r.count,lu(r.columns),uu(r.columns))}function cu(r){return new se(Ra(r.data),r.id,r.isDelta)}function gd(r,t){return(r.fields||[]).filter(Boolean).map(e=>D.fromJSON(e,t))}function iu(r,t){return(r.children||[]).filter(Boolean).map(e=>D.fromJSON(e,t))}function lu(r){return(r||[]).reduce((t,e)=>[...t,new Be(e.count,bd(e.VALIDITY)),...lu(e.children)],[])}function uu(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new ie(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new ie(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new ie(t.length,i.OFFSET.length)),i.DATA&&t.push(new ie(t.length,i.DATA.length)),t=uu(i.children,t)}return t}function bd(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function fu(r,t){let e,n,i,s,o,a;return!t||!(s=r.dictionary)?(o=ou(r,iu(r,t)),i=new D(r.name,o,r.nullable,wo(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?su(n):new pt,a=new Ut(t.get(e),n,e,s.isOrdered),i=new D(r.name,a,r.nullable,wo(r.metadata))):(n=(n=s.indexType)?su(n):new pt,t.set(e,o=ou(r,iu(r,t))),a=new Ut(o,n,e,s.isOrdered),i=new D(r.name,a,r.nullable,wo(r.metadata))),i||null}function wo(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function su(r){return new it(r.isSigned,r.bitWidth)}function ou(r,t){let e=r.type.name;switch(e){case"NONE":return new ut;case"null":return new ut;case"binary":return new ue;case"largebinary":return new Ze;case"utf8":return new Pt;case"largeutf8":return new Je;case"bool":return new kt;case"list":return new Tt((t||[])[0]);case"struct":return new V(t||[]);case"struct_":return new V(t||[])}switch(e){case"int":{let n=r.type;return new it(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new At(j[n.precision])}case"decimal":{let n=r.type;return new fe(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new qt(et[n.unit])}case"time":{let n=r.type;return new xt(p[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new Nt(p[n.unit],n.timezone)}case"interval":{let n=r.type;return new te(nt[n.unit])}case"duration":{let n=r.type;return new Xe(p[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new Ie(K[o],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new Qe(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new Vt(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new jt((t||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var wd=or,_d=Ct,gt=class{static fromJSON(t,e){let n=new gt(0,$.V5,e);return n._createHeader=vd(t,e),n}static decode(t){t=new _d(T(t));let e=ft.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new gt(n,i,s);return o._createHeader=Id(e,s),o}static encode(t){let e=new wd,n=-1;return t.isSchema()?n=E.encode(e,t.header()):t.isRecordBatch()?n=Ot.encode(e,t.header()):t.isDictionaryBatch()&&(n=se.encode(e,t.header())),ft.startMessage(e),ft.addVersion(e,$.V5),ft.addHeader(e,n),ft.addHeaderType(e,t.headerType),ft.addBodyLength(e,BigInt(t.bodyLength)),ft.finishMessageBuffer(e,ft.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof E)return new gt(0,$.V5,P.Schema,t);if(t instanceof Ot)return new gt(e,$.V5,P.RecordBatch,t);if(t instanceof se)return new gt(e,$.V5,P.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===P.Schema}isRecordBatch(){return this.headerType===P.RecordBatch}isDictionaryBatch(){return this.headerType===P.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=at(t)}},Ot=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=at(t)}},se=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,n=!1){this._data=t,this._isDelta=n,this._id=at(e)}},ie=class{constructor(t,e){this.offset=at(t),this.length=at(e)}},Be=class{constructor(t,e){this.length=at(t),this.nullCount=at(e)}};function vd(r,t){return()=>{switch(t){case P.Schema:return E.fromJSON(r);case P.RecordBatch:return Ot.fromJSON(r);case P.DictionaryBatch:return se.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${P[t]}, type: ${t} }`)}}function Id(r,t){return()=>{switch(t){case P.Schema:return E.decode(r.header(new ot),new Map,r.version());case P.RecordBatch:return Ot.decode(r.header(new Ft),r.version());case P.DictionaryBatch:return se.decode(r.header(new me),r.version())}throw new Error(`Unrecognized Message type: { name: ${P[t]}, type: ${t} }`)}}D.encode=Nd;D.decode=Md;D.fromJSON=fu;E.encode=Ld;E.decode=xd;E.fromJSON=au;Ot.encode=Ud;Ot.decode=Sd;Ot.fromJSON=Ra;se.encode=Ed;se.decode=Bd;se.fromJSON=cu;Be.encode=Rd;Be.decode=Td;ie.encode=Cd;ie.decode=Ad;function xd(r,t=new Map,e=$.V5){let n=Fd(r,t);return new E(n,_o(r),t,e)}function Sd(r,t=$.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Ot(r.length(),Dd(r),Od(r,t))}function Bd(r,t=$.V5){return new se(Ot.decode(r.data(),t),r.id(),r.isDelta())}function Ad(r){return new ie(r.offset(),r.length())}function Td(r){return new Be(r.length(),r.nullCount())}function Dd(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=Be.decode(e));return t}function Od(r,t){let e=[];for(let n,i=-1,s=-1,o=r.buffersLength();++i<o;)(n=r.buffers(i))&&(t<$.V4&&(n.bb_pos+=8*(i+1)),e[++s]=ie.decode(n));return e}function Fd(r,t){let e=[];for(let n,i=-1,s=-1,o=r.fieldsLength();++i<o;)(n=r.fields(i))&&(e[++s]=D.decode(n,t));return e}function hu(r,t){let e=[];for(let n,i=-1,s=-1,o=r.childrenLength();++i<o;)(n=r.children(i))&&(e[++s]=D.decode(n,t));return e}function Md(r,t){let e,n,i,s,o,a;return!t||!(a=r.dictionary())?(i=pu(r,hu(r,t)),n=new D(r.name(),i,r.nullable(),_o(r))):t.has(e=at(a.id()))?(s=(s=a.indexType())?du(s):new pt,o=new Ut(t.get(e),s,e,a.isOrdered()),n=new D(r.name(),o,r.nullable(),_o(r))):(s=(s=a.indexType())?du(s):new pt,t.set(e,i=pu(r,hu(r,t))),o=new Ut(i,s,e,a.isOrdered()),n=new D(r.name(),o,r.nullable(),_o(r))),n||null}function _o(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 du(r){return new it(r.isSigned(),r.bitWidth())}function pu(r,t){let e=r.typeType();switch(e){case Z.NONE:return new ut;case Z.Null:return new ut;case Z.Binary:return new ue;case Z.LargeBinary:return new Ze;case Z.Utf8:return new Pt;case Z.LargeUtf8:return new Je;case Z.Bool:return new kt;case Z.List:return new Tt((t||[])[0]);case Z.Struct_:return new V(t||[])}switch(e){case Z.Int:{let n=r.type(new _t);return new it(n.isSigned(),n.bitWidth())}case Z.FloatingPoint:{let n=r.type(new Kt);return new At(n.precision())}case Z.Decimal:{let n=r.type(new vt);return new fe(n.scale(),n.precision(),n.bitWidth())}case Z.Date:{let n=r.type(new Gt);return new qt(n.unit())}case Z.Time:{let n=r.type(new Mt);return new xt(n.unit(),n.bitWidth())}case Z.Timestamp:{let n=r.type(new Lt);return new Nt(n.unit(),n.timezone())}case Z.Interval:{let n=r.type(new Zt);return new te(n.unit())}case Z.Duration:{let n=r.type(new $t);return new Xe(n.unit())}case Z.Union:{let n=r.type(new It);return new Ie(n.mode(),n.typeIdsArray()||[],t||[])}case Z.FixedSizeBinary:{let n=r.type(new Ht);return new Qe(n.byteWidth())}case Z.FixedSizeList:{let n=r.type(new Yt);return new Vt(n.listSize(),(t||[])[0])}case Z.Map:{let n=r.type(new Jt);return new jt((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${Z[e]}" (${e})`)}function Ld(r,t){let e=t.fields.map(s=>D.encode(r,s));ot.startFieldsVector(r,e.length);let n=ot.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?ot.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString(`${s}`),c=r.createString(`${o}`);return Q.startKeyValue(r),Q.addKey(r,a),Q.addValue(r,c),Q.endKeyValue(r)})):-1;return ot.startSchema(r),ot.addFields(r,n),ot.addEndianness(r,Pd?xr.Little:xr.Big),i!==-1&&ot.addCustomMetadata(r,i),ot.endSchema(r)}function Nd(r,t){let e=-1,n=-1,i=-1,s=t.type,o=t.typeId;m.isDictionary(s)?(o=s.dictionary.typeId,i=bo.visit(s,r),n=bo.visit(s.dictionary,r)):n=bo.visit(s,r);let a=(s.children||[]).map(u=>D.encode(r,u)),c=dt.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?dt.createCustomMetadataVector(r,[...t.metadata].map(([u,h])=>{let d=r.createString(`${u}`),b=r.createString(`${h}`);return Q.startKeyValue(r),Q.addKey(r,d),Q.addValue(r,b),Q.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),dt.startField(r),dt.addType(r,n),dt.addTypeType(r,o),dt.addChildren(r,c),dt.addNullable(r,!!t.nullable),e!==-1&&dt.addName(r,e),i!==-1&&dt.addDictionary(r,i),l!==-1&&dt.addCustomMetadata(r,l),dt.endField(r)}function Ud(r,t){let e=t.nodes||[],n=t.buffers||[];Ft.startNodesVector(r,e.length);for(let o of e.slice().reverse())Be.encode(r,o);let i=r.endVector();Ft.startBuffersVector(r,n.length);for(let o of n.slice().reverse())ie.encode(r,o);let s=r.endVector();return Ft.startRecordBatch(r),Ft.addLength(r,BigInt(t.length)),Ft.addNodes(r,i),Ft.addBuffers(r,s),Ft.endRecordBatch(r)}function Ed(r,t){let e=Ot.encode(r,t.data);return me.startDictionaryBatch(r),me.addId(r,BigInt(t.id)),me.addIsDelta(r,t.isDelta),me.addData(r,e),me.endDictionaryBatch(r)}function Rd(r,t){return wn.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function Cd(r,t){return bn.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var Pd=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var Pa=r=>`Expected ${P[r]} Message in stream, but was null or length 0.`,ka=r=>`Header pointer of flatbuffer-encoded ${P[r]} Message is null or length 0.`,mu=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,yu=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Cn=class{constructor(t){this.source=t instanceof er?t:new er(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?q:t.value===-1&&(t=this.readMetadataLength()).done?q:(t=this.readMetadata(t.value)).done?q:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(Pa(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(yu(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=P.Schema,n=this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(ka(e));return i}readMetadataLength(){let t=this.source.read(vo),e=t&&new Ct(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}}readMetadata(t){let e=this.source.read(t);if(!e)return q;if(e.byteLength<t)throw new Error(mu(t,e.byteLength));return{done:!1,value:gt.decode(e)}}},Ri=class{constructor(t,e){this.source=t instanceof re?t:ls(t)?new Or(t,e):new re(t)}[Symbol.asyncIterator](){return this}next(){return y(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?q:t.value===-1&&(t=yield this.readMetadataLength()).done?q:(t=yield this.readMetadata(t.value)).done?q:t})}throw(t){return y(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return y(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return y(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(Pa(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(yu(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(t=!1){return y(this,void 0,void 0,function*(){let e=P.Schema,n=yield this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(ka(e));return i})}readMetadataLength(){return y(this,void 0,void 0,function*(){let t=yield this.source.read(vo),e=t&&new Ct(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}})}readMetadata(t){return y(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return q;if(e.byteLength<t)throw new Error(mu(t,e.byteLength));return{done:!1,value:gt.decode(e)}})}},Ci=class extends Cn{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof ci?t:new ci(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:gt.fromJSON(t.schema,P.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:gt.fromJSON(e,P.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:gt.fromJSON(e,P.RecordBatch)}}return this._body=[],q}readMessageBody(t){return e(this._body);function e(n){return(n||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(Pa(t));return e.value}readSchema(){let t=P.Schema,e=this.readMessage(t),n=e?.header();if(!e||!n)throw new Error(ka(t));return n}},vo=4,Ca="ARROW1",Pn=new Uint8Array(Ca.length);for(let r=0;r<Ca.length;r+=1)Pn[r]=Ca.codePointAt(r);function Io(r,t=0){for(let e=-1,n=Pn.length;++e<n;)if(Pn[e]!==r[t+e])return!1;return!0}var kn=Pn.length,Va=kn+vo,gu=kn*2+vo;var bt=class extends qr{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){let e=this._impl.open(t);return ae(e)?e.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Bt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Bt.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof bt?t:as(t)?Vd(t):ls(t)?Wd(t):ae(t)?(()=>y(this,void 0,void 0,function*(){return yield bt.from(yield t)}))():us(t)||Jn(t)||hs(t)||de(t)?zd(new re(t)):jd(new er(t))}static readAll(t){return t instanceof bt?t.isSync()?bu(t):wu(t):as(t)||ArrayBuffer.isView(t)||Te(t)||cs(t)?bu(t):wu(t)}},nr=class extends bt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return oe(this,arguments,function*(){yield U(yield*yn(Ae(this[Symbol.iterator]())))})}},Fr=class extends bt{constructor(t){super(t),this._impl=t}readAll(){var t,e,n,i;return y(this,void 0,void 0,function*(){let s=new Array;try{for(var o=!0,a=Ae(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]()}},Mr=class extends nr{constructor(t){super(t),this._impl=t}},Pi=class extends Fr{constructor(t){super(t),this._impl=t}},xo=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){let n=this._loadVectors(t,e,this.schema.fields),i=w({type:new V(this.schema.fields),length:t.length,children:n});return new Y(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:o}=this,a=s.get(n);if(i||!a){let c=o.dictionaries.get(n),l=this._loadVectors(t.data,e,[c]);return(a&&i?a.concat(new g(l)):new g(l)).memoize()}return a.memoize()}_loadVectors(t,e,n){return new fi(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},Vn=class extends xo{constructor(t,e){super(e),this._reader=as(t)?new Ci(this._handle=t):new Cn(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=_u(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):q}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):q}next(){if(this.closed)return q;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new on(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},jn=class extends xo{constructor(t,e){super(e),this._reader=new Ri(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=_u(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):q})}return(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):q})}next(){return y(this,void 0,void 0,function*(){if(this.closed)return q;let t,{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new on(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return y(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},So=class extends Vn{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof li?t:new li(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(P.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(P.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-Va,n=t.readInt32(e),i=t.readAt(e-n,n);return ur.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}},ja=class extends jn{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let n=typeof e[0]!="number"?e.shift():void 0,i=e[0]instanceof Map?e.shift():void 0;super(t instanceof Or?t:new Or(t,n),i)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return y(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){var e;return y(this,void 0,void 0,function*(){if(this.closed)return null;this._footer||(yield this.open());let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(P.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){var e;return y(this,void 0,void 0,function*(){let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(P.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return y(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Va,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return ur.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})}},za=class extends Vn{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new Hs(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function _u(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*bu(r){let t=bt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function wu(r){return oe(this,arguments,function*(){let e=yield U(bt.from(r));try{if(!(yield U(e.open({autoDestroy:!1}))).closed)do yield yield U(e);while(!(yield U(e.reset().open())).closed)}finally{yield U(e.cancel())}})}function Vd(r){return new nr(new za(r))}function jd(r){let t=r.peek(kn+7&-8);return t&&t.byteLength>=4?Io(t)?new Mr(new So(r.read())):new nr(new Vn(r)):new nr(new Vn(function*(){}()))}function zd(r){return y(this,void 0,void 0,function*(){let t=yield r.peek(kn+7&-8);return t&&t.byteLength>=4?Io(t)?new Mr(new So(yield r.read())):new Fr(new jn(r)):new Fr(new jn(function(){return oe(this,arguments,function*(){})}()))})}function Wd(r){return y(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Or(r,t);return t>=gu&&Io(yield e.readAt(0,kn+7&-8))?new Pi(new ja(e)):new Fr(new jn(e))})}var tt=class extends v{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof Y?s.data.children:s.data),n=new tt;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof g)return this.visitMany(t.data),this;let{type:e}=t;if(!m.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(m.isUnion(e))this.nodes.push(new Be(n,0));else{let{nullCount:i}=t;m.isNull(e)||Re.call(this,i<=0?new Uint8Array(0):Kr(t.offset,n,t.nullBitmap)),this.nodes.push(new Be(n,i))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function Re(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new ie(this._byteLength,t)),this._byteLength+=t,this}function Gd(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(Re.call(this,i),e.mode===K.Sparse)return Wa.call(this,r);if(e.mode===K.Dense){if(r.offset<=0)return Re.call(this,s),Wa.call(this,r);{let o=new Int32Array(n),a=Object.create(null),c=Object.create(null);for(let l,u,h=-1;++h<n;)(l=i[h])!==void 0&&((u=a[l])===void 0&&(u=a[l]=s[h]),o[h]=s[h]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);Re.call(this,o),this.visitMany(r.children.map((l,u)=>{let h=e.typeIds[u],d=a[h],b=c[h];return l.slice(d,Math.min(n,b))}))}}return this}function $d(r){let t;return r.nullCount>=r.length?Re.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?Re.call(this,Kr(r.offset,r.length,t)):Re.call(this,Zr(r.values))}function gr(r){return Re.call(this,r.values.subarray(0,r.length*r.stride))}function Bo(r){let{length:t,values:e,valueOffsets:n}=r,i=at(n[0]),s=at(n[t]),o=Math.min(s-i,e.byteLength-i);return Re.call(this,ps(-i,t+1,n)),Re.call(this,e.subarray(i,i+o)),this}function Ga(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return Re.call(this,ps(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function Wa(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}tt.prototype.visitBool=$d;tt.prototype.visitInt=gr;tt.prototype.visitFloat=gr;tt.prototype.visitUtf8=Bo;tt.prototype.visitLargeUtf8=Bo;tt.prototype.visitBinary=Bo;tt.prototype.visitLargeBinary=Bo;tt.prototype.visitFixedSizeBinary=gr;tt.prototype.visitDate=gr;tt.prototype.visitTimestamp=gr;tt.prototype.visitTime=gr;tt.prototype.visitDecimal=gr;tt.prototype.visitList=Ga;tt.prototype.visitStruct=Wa;tt.prototype.visitUnion=Gd;tt.prototype.visitInterval=gr;tt.prototype.visitDuration=gr;tt.prototype.visitFixedSizeList=Ga;tt.prototype.visitMap=Ga;var an=class extends qr{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new tr,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,Rt(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return ae(t)?t.then(e=>this.writeAll(e)):de(t)?Ha(this,t):$a(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 tr?this._sink=t:(this._sink=new tr,t&&Uc(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Ec(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,(!e||!sn(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof J&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Y&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!sn(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Y?t instanceof on||this._writeRecordBatch(t):t instanceof J?this.writeAll(t.batches):Te(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=gt.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+n&~n,c=a-s-o;return t.headerType===P.RecordBatch?this._recordBatchBlocks.push(new Ee(a,t.bodyLength,this._position)):t.headerType===P.DictionaryBatch&&this._dictionaryBlocks.push(new Ee(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(c)}_write(t){if(this._started){let e=T(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(gt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Pn)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=tt.assemble(t),o=new Ot(t.numRows,n,i),a=gt.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0));let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=tt.assemble(new g([t])),c=new Ot(t.length,s,o),l=new se(c,e,n),u=gt.from(l,i);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,n,i;for(let s=-1,o=t.length;++s<o;)(e=t[s])&&(n=e.byteLength)>0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this}_writeDictionaries(t){for(let[e,n]of t.dictionaries){let i=this._dictionaryDeltaOffsets.get(e)||0;if(i===0||(n=n?.slice(i)).length>0)for(let s of n.data)this._writeDictionaryBatch(s,e,i>0),i+=s.length}return this}},br=class extends an{static writeAll(t,e){let n=new br(e);return ae(t)?t.then(i=>n.writeAll(i)):de(t)?Ha(n,t):$a(n,t)}},wr=class extends an{static writeAll(t){let e=new wr;return ae(t)?t.then(n=>e.writeAll(n)):de(t)?Ha(e,t):$a(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){let e=ur.encode(new ur(t,$.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function $a(r,t){let e=t;t instanceof J&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function Ha(r,t){var e,n,i,s,o,a,c;return y(this,void 0,void 0,function*(){try{for(e=!0,n=Ae(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 vu(r,t){if(de(r))return Yd(r,t);if(Te(r))return Hd(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Hd(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 Yd(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 Su(r){return new Ya(r)}var Ya=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=Lc(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=hr(s),this._getSize=i!=="bytes"?Iu:xu;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"?Iu:xu}),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)}},Iu=r=>{var t;return(t=r?.length)!==null&&t!==void 0?t:0},xu=r=>{var t;return(t=r?.byteLength)!==null&&t!==void 0?t:0};function Ao(r,t){let e=new tr,n=null,i=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield e.close()})},start(a){return y(this,void 0,void 0,function*(){yield o(a,n||(n=yield s()))})},pull(a){return y(this,void 0,void 0,function*(){n?yield o(a,n):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:i};function s(){return y(this,void 0,void 0,function*(){return yield(yield bt.from(e)).open(t)})}function o(a,c){return y(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}function To(r,t){let e=new this(r),n=new re(e),i=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return y(this,void 0,void 0,function*(){yield s(o)})},start(o){return y(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(o){return y(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield n.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}function ki(r){let t=bt.from(r);return ae(t)?t.then(e=>ki(e)):t.isAsync()?t.readAll().then(e=>new J(e)):new J(t.readAll())}function Do(r,t="stream"){return(t==="stream"?br:wr).writeAll(r).toUint8Array(!0)}var ip=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},ia),Oa),va),sa),qo),_a),ra),{compareSchemas:sn,compareFields:ql,compareTypes:mo});Bt.toDOMStream=vu;rt.throughDOM=Su;bt.throughDOM=Ao;Mr.throughDOM=Ao;nr.throughDOM=Ao;an.throughDOM=To;wr.throughDOM=To;br.throughDOM=To;var Oo=class extends Nr{arrowSchema;constructor(t,e){super(t,e),this.arrowSchema=null}getBatch(){let t=super.getBatch();if(t){this.arrowSchema=this.arrowSchema||sp(t.schema);let e=op(this.arrowSchema,t.data),n=new Y(this.arrowSchema,w({type:new V(this.arrowSchema.fields),children:e.map(({data:i})=>i[0])}));return{shape:"arrow-table",batchType:"data",data:new J([n]),length:t.length}}return null}};function sp(r){let t=[];for(let e in r){let n=r[e];if(n.type===Float32Array){let i=new Map,s=new D(n.name,new Xt,n.nullable,i);t.push(s)}}if(t.length===0)throw new Error("No arrow convertible fields");return new E(t)}function op(r,t){let e=[];for(let n of r.fields){let i=t[n.name];if(i instanceof Float32Array){let s=Dr(i);e.push(s)}}if(r.fields.length!==e.length)throw new Error("Some columns not arrow convertible");return e}function Bu(r){switch(r.constructor){case Int8Array:return new ye;case Uint8Array:return new we;case Int16Array:return new ge;case Uint16Array:return new _e;case Int32Array:return new pt;case Uint32Array:return new ve;case Float32Array:return new Xt;case Float64Array:return new Qt;default:throw new Error("array type not supported")}}var ln;(function(r){r[r.FLOAT=0]="FLOAT",r[r.DATE=1]="DATE"})(ln||(ln={}));function Fo(r){let t=r.data,e={};for(let n of t.schema.fields){let s=t.getChild(n.name)?.toArray();e[n.name]=s}return{shape:"columnar-table",schema:r.schema,data:e}}function zn(r){return{fields:r.fields.map(t=>un(t)),metadata:Mo(r.metadata)}}function Au(r){return new E(r.fields.map(t=>fn(t)),Lo(r.metadata))}function Mo(r){return Object.fromEntries(r)}function Lo(r){return r?new Map(Object.entries(r)):new Map}function un(r){return{name:r.name,type:Ka(r.type),nullable:r.nullable,metadata:Mo(r.metadata)}}function fn(r){return new D(r.name,Za(r.type),r.nullable,Lo(r.metadata))}function Ka(r){switch(r.constructor){case ut:return"null";case ue:return"binary";case kt:return"bool";case it:let t=r;return`${t.isSigned?"u":""}int${t.bitWidth}`;case ye:return"int8";case ge:return"int16";case pt:return"int32";case be:return"int64";case we:return"uint8";case _e:return"uint16";case ve:return"uint32";case Ke:return"uint64";case At:switch(r.precision){case j.HALF:return"float16";case j.SINGLE:return"float32";case j.DOUBLE:return"float64";default:return"float16"}case Sr:return"float16";case Xt:return"float32";case Qt:return"float64";case Pt:return"utf8";case fe:let n=r;return{type:"decimal",bitWidth:n.bitWidth,precision:n.precision,scale:n.scale};case qt:return r.unit===et.DAY?"date-day":"date-millisecond";case Rr:return"date-day";case ar:return"date-millisecond";case xt:switch(r.unit){case p.SECOND:return"time-second";case p.MILLISECOND:return"time-millisecond";case p.MICROSECOND:return"time-microsecond";case p.NANOSECOND:return"time-nanosecond";default:return"time-second"}case Pr:return"time-millisecond";case Cr:return"time-second";case kr:return"time-microsecond";case Vr:return"time-nanosecond";case Nt:switch(r.unit){case p.SECOND:return"timestamp-second";case p.MILLISECOND:return"timestamp-millisecond";case p.MICROSECOND:return"timestamp-microsecond";case p.NANOSECOND:return"timestamp-nanosecond";default:return"timestamp-second"}case jr:return"timestamp-second";case zr:return"timestamp-millisecond";case Wr:return"timestamp-microsecond";case Gr:return"timestamp-nanosecond";case te:switch(r.unit){case nt.DAY_TIME:return"interval-daytime";case nt.YEAR_MONTH:return"interval-yearmonth";default:return"interval-daytime"}case $r:return"interval-daytime";case Hr:return"interval-yearmonth";case jt:let c=r;return{type:"map",keysSorted:c.keysSorted,children:c.children.map(b=>un(b))};case Tt:let u=r.valueField;return{type:"list",children:[un(u)]};case Vt:let h=r;return{type:"fixed-size-list",listSize:h.listSize,children:[un(h.children[0])]};case V:return{type:"struct",children:r.children.map(b=>un(b))};default:throw new Error(`arrow type not supported: ${r.constructor.name}`)}}function Za(r){if(typeof r=="object")switch(r.type){case"decimal":return new fe(r.precision,r.scale,r.bitWidth);case"map":let t=r.children.map(i=>fn(i));return new jt(t,r.keysSorted);case"list":let e=fn(r.children[0]);return new Tt(e);case"fixed-size-list":let n=fn(r.children[0]);return new Vt(r.listSize,n);case"struct":return t=r.children.map(i=>fn(i)),new V(t);default:throw new Error("array type not supported")}switch(r){case"null":return new ut;case"binary":return new ue;case"bool":return new kt;case"int8":return new ye;case"int16":return new ge;case"int32":return new pt;case"int64":return new be;case"uint8":return new we;case"uint16":return new _e;case"uint32":return new ve;case"uint64":return new Ke;case"float16":return new Sr;case"float32":return new Xt;case"float64":return new Qt;case"utf8":return new Pt;case"date-day":return new Rr;case"date-millisecond":return new ar;case"time-second":return new Cr;case"time-millisecond":return new Pr;case"time-microsecond":return new kr;case"time-nanosecond":return new Vr;case"timestamp-second":return new jr;case"timestamp-millisecond":return new zr;case"timestamp-microsecond":return new Wr;case"timestamp-nanosecond":return new Gr;case"interval-daytime":return new $r;case"interval-yearmonth":return new Hr;default:throw new Error("array type not supported")}}function Vi(r,t){let e=ki([new Uint8Array(r)]),n={shape:"arrow-table",schema:zn(e.schema),data:e},i=t?.shape||"arrow-table";switch(i){case"arrow-table":return n;case"columnar-table":return Fo(n);case"object-row-table":let s=Fo(n);return os(s,"object-row-table");case"array-row-table":return s=Fo(n),os(s,"array-row-table");default:throw new Error(i)}}function No(r,t){async function*e(){let n=bt.readAll(r);for await(let i of n){for await(let s of i)t?.arrow?.batchDebounceMs!==void 0&&t?.arrow?.batchDebounceMs>0&&await new Promise(a=>setTimeout(a,t.arrow?.batchDebounceMs||0)),yield{shape:"arrow-table",batchType:"data",data:new J([s]),length:s.data.length};break}}return e()}var ap="4.3.0-alpha.7",ji={dataType:null,batchType:null,name:"Apache Arrow",id:"arrow",module:"arrow",version:ap,category:"table",extensions:["arrow","feather"],mimeTypes:["application/vnd.apache.arrow.file","application/vnd.apache.arrow.stream","application/octet-stream"],binary:!0,tests:["ARROW"],options:{arrow:{shape:"columnar-table"}}},Tu={...ji,parse:async(r,t)=>Vi(r,t?.arrow),parseSync:(r,t)=>Vi(r,t?.arrow),parseInBatches:No};function Ja(r){let t={};for(let i of r){let s=cp(i.array,i.type);t[i.name]=s}let e=new J(t);return Do(e)}function cp(r,t){switch(t){case ln.DATE:return Ei(r);case ln.FLOAT:default:return Ei(r)}}var lp="4.3.0-alpha.7",Du={name:"Apache Arrow",id:"arrow",module:"arrow",version:lp,extensions:["arrow","feather"],mimeTypes:["application/vnd.apache.arrow.file","application/vnd.apache.arrow.stream","application/octet-stream"],binary:!0,options:{},encode:async function(t,e){return Ja(t)},encodeSync(r,t){return Ja(r)}};var up=["geoarrow.multipolygon","geoarrow.polygon","geoarrow.multilinestring","geoarrow.linestring","geoarrow.multipoint","geoarrow.point","geoarrow.wkb","geoarrow.wkt"],fp="ARROW:extension:name",hp="ARROW:extension:metadata";function Xa(r){let t={};for(let e of r.fields){let n=dp(e);n&&(t[e.name]=n)}return t}function dp(r){let t=null,e=r.metadata?.[fp];e&&(e=e.toLowerCase(),e==="wkb"&&(e="geoarrow.wkb"),e==="wkt"&&(e="geoarrow.wkt"),up.includes(e)?(t=t||{},t.encoding=e):console.warn(`Invalid GeoArrow encoding: ${e}`));let n=r.metadata?.[hp];if(n)try{t=JSON.parse(n)}catch(i){console.warn("Failed to parse GeoArrow metadata",i)}return t||null}var zi={x:0,y:1,z:2};function Uo(r,t={}){let{start:e=0,end:n=r.length,plane:i="xy"}=t,s=t.size||2,o=0,a=zi[i[0]],c=zi[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 qa(r,t,e=2,n,i="xy"){let s=t&&t.length,o=s?t[0]*e:r.length,a=Fu(r,0,o,e,!0,n&&n[0],i),c=[];if(!a||a.next===a.prev)return c;let l,u,h,d,b,M,z;if(s&&(a=_p(r,t,a,e,n,i)),r.length>80*e){d=u=r[0],b=h=r[1];for(let X=e;X<o;X+=e)M=r[X],z=r[X+1],M<d&&(d=M),z<b&&(b=z),M>u&&(u=M),z>h&&(h=z);l=Math.max(u-d,h-b),l=l!==0?32767/l:0}return Wi(a,c,e,d,b,l,0),c}function Fu(r,t,e,n,i,s,o){let a,c;s===void 0&&(s=Uo(r,{start:t,end:e,size:n,plane:o}));let l=zi[o[0]],u=zi[o[1]];if(i===s<0)for(a=t;a<e;a+=n)c=Ou(a,r[a+l],r[a+u],c);else for(a=e-n;a>=t;a-=n)c=Ou(a,r[a+l],r[a+u],c);return c&&Co(c,c.next)&&($i(c),c=c.next),c}function hn(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(Co(e,e.next)||ct(e.prev,e,e.next)===0)){if($i(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Wi(r,t,e,n,i,s,o){if(!r)return;!o&&s&&Bp(r,n,i,s);let a=r,c,l;for(;r.prev!==r.next;){if(c=r.prev,l=r.next,s?gp(r,n,i,s):yp(r)){t.push(c.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),$i(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=bp(hn(r),t,e),Wi(r,t,e,n,i,s,2)):o===2&&wp(r,t,e,n,i,s):Wi(hn(r),t,e,n,i,s,1);break}}}function yp(r){let t=r.prev,e=r,n=r.next;if(ct(t,e,n)>=0)return!1;let i=t.x,s=e.x,o=n.x,a=t.y,c=e.y,l=n.y,u=i<s?i<o?i:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,d=i>s?i>o?i:o:s>o?s:o,b=a>c?a>l?a:l:c>l?c:l,M=n.next;for(;M!==t;){if(M.x>=u&&M.x<=d&&M.y>=h&&M.y<=b&&Wn(i,a,s,c,o,l,M.x,M.y)&&ct(M.prev,M,M.next)>=0)return!1;M=M.next}return!0}function gp(r,t,e,n){let i=r.prev,s=r,o=r.next;if(ct(i,s,o)>=0)return!1;let a=i.x,c=s.x,l=o.x,u=i.y,h=s.y,d=o.y,b=a<c?a<l?a:l:c<l?c:l,M=u<h?u<d?u:d:h<d?h:d,z=a>c?a>l?a:l:c>l?c:l,X=u>h?u>d?u:d:h>d?h:d,st=Qa(b,M,t,e,n),pn=Qa(z,X,t,e,n),W=r.prevZ,k=r.nextZ;for(;W&&W.z>=st&&k&&k.z<=pn;){if(W.x>=b&&W.x<=z&&W.y>=M&&W.y<=X&&W!==i&&W!==o&&Wn(a,u,c,h,l,d,W.x,W.y)&&ct(W.prev,W,W.next)>=0||(W=W.prevZ,k.x>=b&&k.x<=z&&k.y>=M&&k.y<=X&&k!==i&&k!==o&&Wn(a,u,c,h,l,d,k.x,k.y)&&ct(k.prev,k,k.next)>=0))return!1;k=k.nextZ}for(;W&&W.z>=st;){if(W.x>=b&&W.x<=z&&W.y>=M&&W.y<=X&&W!==i&&W!==o&&Wn(a,u,c,h,l,d,W.x,W.y)&&ct(W.prev,W,W.next)>=0)return!1;W=W.prevZ}for(;k&&k.z<=pn;){if(k.x>=b&&k.x<=z&&k.y>=M&&k.y<=X&&k!==i&&k!==o&&Wn(a,u,c,h,l,d,k.x,k.y)&&ct(k.prev,k,k.next)>=0)return!1;k=k.nextZ}return!0}function bp(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!Co(i,s)&&Mu(i,n,n.next,s)&&Gi(i,s)&&Gi(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),$i(n),$i(n.next),n=r=s),n=n.next}while(n!==r);return hn(n)}function wp(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Dp(o,a)){let c=Lu(o,a);o=hn(o,o.next),c=hn(c,c.next),Wi(o,t,e,n,i,s,0),Wi(c,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function _p(r,t,e,n,i,s){let o=[],a,c,l,u,h;for(a=0,c=t.length;a<c;a++)l=t[a]*n,u=a<c-1?t[a+1]*n:r.length,h=Fu(r,l,u,n,!1,i&&i[a+1],s),h===h.next&&(h.steiner=!0),o.push(Tp(h));for(o.sort(vp),a=0;a<o.length;a++)e=Ip(o[a],e);return e}function vp(r,t){return r.x-t.x}function Ip(r,t){let e=xp(r,t);if(!e)return t;let n=Lu(e,r);return hn(n,n.next),hn(e,e.next)}function xp(r,t){let e=t,n=r.x,i=r.y,s=-1/0,o;do{if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){let d=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=n&&d>s&&(s=d,o=e.x<e.next.x?e:e.next,d===n))return o}e=e.next}while(e!==t);if(!o)return null;let a=o,c=o.x,l=o.y,u=1/0,h;e=o;do n>=e.x&&e.x>=c&&n!==e.x&&Wn(i<l?n:s,i,c,l,i<l?s:n,i,e.x,e.y)&&(h=Math.abs(i-e.y)/(n-e.x),Gi(e,r)&&(h<u||h===u&&(e.x>o.x||e.x===o.x&&Sp(o,e)))&&(o=e,u=h)),e=e.next;while(e!==a);return o}function Sp(r,t){return ct(r.prev,r,t.prev)<0&&ct(t.next,r,r.next)<0}function Bp(r,t,e,n){let i=r;do i.z===0&&(i.z=Qa(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,Ap(i)}function Ap(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 Qa(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 Tp(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 Wn(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 Dp(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Op(r,t)&&(Gi(r,t)&&Gi(t,r)&&Fp(r,t)&&(ct(r.prev,r,t.prev)||ct(r,t.prev,t))||Co(r,t)&&ct(r.prev,r,r.next)>0&&ct(t.prev,t,t.next)>0)}function ct(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Co(r,t){return r.x===t.x&&r.y===t.y}function Mu(r,t,e,n){let i=Ro(ct(r,t,e)),s=Ro(ct(r,t,n)),o=Ro(ct(e,n,r)),a=Ro(ct(e,n,t));return!!(i!==s&&o!==a||i===0&&Eo(r,e,t)||s===0&&Eo(r,n,t)||o===0&&Eo(e,r,n)||a===0&&Eo(e,t,n))}function Eo(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 Ro(r){return r>0?1:r<0?-1:0}function Op(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&&Mu(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Gi(r,t){return ct(r.prev,r,r.next)<0?ct(r,t,r.next)>=0&&ct(r,r.prev,t)>=0:ct(r,t,r.prev)<0||ct(r,r.next,t)<0}function Fp(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 Lu(r,t){let e=new Hi(r.i,r.x,r.y),n=new Hi(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 Ou(r,t,e,n){let i=new Hi(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 $i(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 Hi=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 Gn(r,t,e){switch(r.type){case"Point":return Rp(r,t,e);case"LineString":return Ep(r,t,e);case"Polygon":return Eu(r,t,e);default:let n=r;throw new Error(`Unsupported geometry type: ${n?.type}`)}}function Eu(r,t=-1/0,e=1/0){let{positions:n}=r,i=r.polygonIndices.value.filter(c=>c>=t&&c<=e),s=r.primitivePolygonIndices.value.filter(c=>c>=t&&c<=e);if(!(i.length>2)){let c=[];for(let l=0;l<s.length-1;l++){let u=s[l],h=s[l+1],d=Po(n,u,h);c.push(d)}return{type:"Polygon",coordinates:c}}let a=[];for(let c=0;c<i.length-1;c++){let l=i[c],u=i[c+1],h=Eu(r,l,u).coordinates;a.push(h)}return{type:"MultiPolygon",coordinates:a}}function Ep(r,t=-1/0,e=1/0){let{positions:n}=r,i=r.pathIndices.value.filter(a=>a>=t&&a<=e);if(!(i.length>2))return{type:"LineString",coordinates:Po(n,i[0],i[1])};let o=[];for(let a=0;a<i.length-1;a++){let c=Po(n,i[a],i[a+1]);o.push(c)}return{type:"MultiLineString",coordinates:o}}function Rp(r,t,e){let{positions:n}=r,i=Po(n,t,e);return i.length>1?{type:"MultiPoint",coordinates:i}:{type:"Point",coordinates:i[0]}}function Po(r,t,e){t=t||0,e=e||r.value.length/r.size;let n=[];for(let i=t;i<e;i++){let s=Array();for(let o=i*r.size;o<(i+1)*r.size;o++)s.push(Number(r.value[o]));n.push(s)}return n}function ko(r){let t=r.data,e=zn(t.schema),n=Xa(e),i=n.geometry.encoding,s=[],o=t.schema.fields.map(l=>l.name).filter(l=>!(l in n)),a=t.select(o),c=t.getChild("geometry");for(let l=0;l<t.numRows;l++){let u=c?.get(l),h=Vo(u,i);if(h){let d=a.get(l)?.toJSON()||{};s.push({type:"Feature",geometry:h,properties:d})}}return{shape:"geojson-table",type:"FeatureCollection",schema:r.schema,features:s}}function tc(r,t){let e=Vi(r,{shape:"arrow-table"});switch(t?.shape){case"geojson-table":return ko(e);default:return e}}function Ru(r){return No(r)}var ec={...ji,options:{arrow:{shape:"arrow-table"}}},Cu={...ec,parse:async(r,t)=>tc(r,t?.arrow),parseSync:(r,t)=>tc(r,t?.arrow),parseInBatches:Ru};function jo(r,t,e,n=100){let i=r.length/t,s=Math.max(Math.floor(i/n),1),o=[...e];for(let a=0;a<i;a+=s){let c=r[a*t],l=r[a*t+1];c<o[0]&&(o[0]=c),l<o[1]&&(o[1]=l),c>o[2]&&(o[2]=c),l>o[3]&&(o[3]=l)}return o}var $n;(function(r){r.points="points",r.lines="lines",r.polygons="polygons"})($n||($n={}));function Yi(){return{globalFeatureIds:{value:new Uint32Array(0),size:1},positions:{value:new Float32Array(0),size:2},properties:[],numericProps:{},featureIds:{value:new Uint32Array(0),size:1}}}function Pu(r,t,e){let n={polygon:t==="geoarrow.multipolygon"||t==="geoarrow.polygon",point:t==="geoarrow.multipoint"||t==="geoarrow.point",line:t==="geoarrow.multilinestring"||t==="geoarrow.linestring"},i=e?.chunkIndex!==void 0&&e?.chunkIndex>=0?[r.data[e?.chunkIndex]]:r.data,s=[1/0,1/0,-1/0,-1/0],o=e?.chunkOffset||0,a=[];return i.forEach(c=>{let{featureIds:l,flatCoordinateArray:u,nDim:h,geomOffset:d,triangles:b}=Pp(c,t,e),M=new Uint32Array(l.length);for(let X=0;X<l.length;X++)M[X]=l[X]+o;let z={globalFeatureIds:{value:M,size:1},positions:{value:u,size:h},featureIds:{value:l,size:1},properties:[...Array(c.length).keys()].map(X=>({index:X+o}))};o+=c.length,a.push({shape:"binary-feature-collection",points:{type:"Point",...Yi(),...n.point?z:{}},lines:{type:"LineString",...Yi(),...n.line?z:{},pathIndices:{value:n.line?d:new Uint16Array(0),size:1}},polygons:{type:"Polygon",...Yi(),...n.polygon?z:{},polygonIndices:{value:n.polygon?d:new Uint16Array(0),size:1},primitivePolygonIndices:{value:n.polygon?d:new Uint16Array(0),size:1},...b?{triangles:{value:b,size:1}}:{}}}),s=jo(u,h,s)}),{binaryGeometries:a,bounds:s,featureTypes:n,...e?.calculateMeanCenters?{meanCenters:rc(a)}:{}}}function rc(r){let t=[];return r.forEach(e=>{let n=null;e.points&&e.points.positions.value.length>0?n=$n.points:e.lines&&e.lines.positions.value.length>0?n=$n.lines:e.polygons&&e.polygons.positions.value.length>0&&(n=$n.polygons);let i=n?e[n]:null;if(i&&n!==null){let s=i.featureIds.value,o=i.positions.value,a=i.positions.size,c=i.type==="Polygon"?i.primitivePolygonIndices?.value:void 0;Cp(s,o,a,n,c).forEach(u=>{t.push(u)})}}),t}function Cp(r,t,e,n,i){let s=[],o=t.length,a=0,c=0,l=0;for(;a<o;){let u=r[a/e],h=[0,0],d=0;for(;a<o&&r[c]===u;)n===$n.polygons&&i?.[l]===c?(a+=e,l++):(h[0]+=t[a],h[1]+=t[a+1],a+=e,d++),c+=1;h[0]/=d,h[1]/=d,s.push(h)}return s}function Pp(r,t,e){switch(t){case"geoarrow.point":case"geoarrow.multipoint":return jp(r,t);case"geoarrow.linestring":case"geoarrow.multilinestring":return Vp(r,t);case"geoarrow.polygon":case"geoarrow.multipolygon":return kp(r,t,e);default:throw Error("invalid geoarrow encoding")}}function nc(r,t,e,n){try{let i=0,s=[];for(let a=0;a<r.length-1;a++){let c=r[a],l=r[a+1],u=e.subarray(c*n,l*n),h=[];for(;t[i]<l;)t[i]>c&&h.push(t[i]-c),i++;let d=qa(u,h.length>0?h:void 0,n);if(d.length===0)throw Error("earcut failed e.g. invalid polygon");for(let b=0;b<d.length;b++)s.push(d[b]+c)}let o=new Uint32Array(s.length);for(let a=0;a<s.length;a++)o[a]=s[a];return o}catch{return null}}function kp(r,t,e){let n=t==="geoarrow.multipolygon",i=n?r.children[0]:r,s=i.valueOffsets,o=n?r.valueOffsets.map(st=>s.at(st)||st):r.valueOffsets,a=i.children[0],c=a.children[0],l=c.children[0],u=c.stride,h=a.valueOffsets,d=l.values,b=new Uint16Array(s.length);for(let st=0;st<s.length;st++)b[st]=h[s[st]];let M=d.length/u,z=new Uint32Array(M);for(let st=0;st<o.length-1;st++){let pn=h[o[st]],W=h[o[st+1]];for(let k=pn;k<W;k++)z[k]=st}let X=e?.triangulate?nc(b,h,d,u):null;return{featureIds:z,nDim:u,flatCoordinateArray:d,geomOffset:h,geometryIndicies:b,...e?.triangulate&&X?{triangles:X}:{}}}function Vp(r,t){let e=t==="geoarrow.multilinestring",n=e?r.children[0]:r,i=n.children[0],s=i.children[0],o=i.stride,a=n.valueOffsets,c=s.values,l=new Uint16Array(0),u=c.length/o,h=new Uint32Array(u);if(e){let d=r.valueOffsets;for(let b=0;b<d.length-1;b++){let M=a[d[b]],z=a[d[b+1]];for(let X=M;X<z;X++)h[X]=b}}else for(let d=0;d<r.length;d++){let b=a[d],M=a[d+1];for(let z=b;z<M;z++)h[z]=d}return{featureIds:h,flatCoordinateArray:c,nDim:o,geomOffset:a,geometryIndicies:l}}function jp(r,t){let e=t==="geoarrow.multipoint",n=e?r.children[0]:r,i=n.children[0],s=n.stride,o=i.values,a=new Uint16Array(0),c=new Int32Array(0),l=o.length/s,u=new Uint32Array(l);if(e){let h=r.valueOffsets;for(let d=0;d<h.length-1;d++){let b=h[d],M=h[d+1];for(let z=b;z<M;z++)u[z]=d}}else for(let h=0;h<r.length;h++)u[h]=h;return{featureIds:u,flatCoordinateArray:o,nDim:s,geomOffset:c,geometryIndicies:a}}var zo="4.3.0-alpha.7";var ku=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,Vu=new RegExp("^"+ku.source+"(\\s"+ku.source+"){1,}"),ic=["POINT(","LINESTRING(","POLYGON(","MULTIPOINT(","MULTILINESTRING(","MULTIPOLYGON(","GEOMETRYCOLLECTION("];function ju(r){return ic.some(t=>r.startsWith(t))}function sc(r,t){return zp(r,t)}function zp(r,t){let e=r.split(";"),n=e.pop(),i=(e.shift()||"").split("=").pop(),o=zu({parts:e,_:n,i:0});return t?.wkt?.crs?Wp(o,i):o}function zu(r){return Gp(r)||Hp(r)||Kp(r)||$p(r)||Yp(r)||Zp(r)||Jp(r)}function Wp(r,t){if(r&&t?.match(/\d+/)){let e={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+t}};r.crs=e}return r}function Gp(r){if(!ht(/^(POINT(\sz)?)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;let t=Wu(r);return!t||(Wt(r),!ht(/^(\))/,r))?null:{type:"Point",coordinates:t[0]}}function $p(r){if(!ht(/^(MULTIPOINT)/i,r))return null;Wt(r);let t=r._?.substring(r._?.indexOf("(")+1,r._.length-1).replace(/\(/g,"").replace(/\)/g,"");r._="MULTIPOINT ("+t+")";let e=Wo(r);return e?(Wt(r),{type:"MultiPoint",coordinates:e}):null}function Hp(r){if(!ht(/^(LINESTRING(\sz)?)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;let t=Wu(r);return!t||!ht(/^(\))/,r)?null:{type:"LineString",coordinates:t}}function Yp(r){if(!ht(/^(MULTILINESTRING)/i,r))return null;Wt(r);let t=Wo(r);return t?(Wt(r),{type:"MultiLineString",coordinates:t}):null}function Kp(r){if(!ht(/^(POLYGON(\sz)?)/i,r))return null;Wt(r);let t=Wo(r);return t?{type:"Polygon",coordinates:t}:null}function Zp(r){if(!ht(/^(MULTIPOLYGON)/i,r))return null;Wt(r);let t=Wo(r);return t?{type:"MultiPolygon",coordinates:t}:null}function Jp(r){let t=[],e;if(!ht(/^(GEOMETRYCOLLECTION)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;for(;e=zu(r);)t.push(e),Wt(r),ht(/^(,)/,r),Wt(r);return ht(/^(\))/,r)?{type:"GeometryCollection",geometries:t}:null}function Wo(r){Wt(r);let t=0,e=[],n=[e],i=e,s;for(;s=ht(/^(\()/,r)||ht(/^(\))/,r)||ht(/^(,)/,r)||ht(Vu,r);){if(s==="(")n.push(i),i=[],n[n.length-1].push(i),t++;else if(s===")"){if(i.length===0||(i=n.pop(),!i))return null;if(t--,t===0)break}else if(s===",")i=[],n[n.length-1].push(i);else if(!s.split(/\s/g).some(isNaN))Array.prototype.push.apply(i,s.split(/\s/g).map(parseFloat));else return null;Wt(r)}return t!==0?null:e}function Wu(r){let t=[],e,n;for(;n=ht(Vu,r)||ht(/^(,)/,r);)n===","?(t.push(e),e=[]):n.split(/\s/g).some(isNaN)||(e||(e=[]),Array.prototype.push.apply(e,n.split(/\s/g).map(parseFloat))),Wt(r);if(e)t.push(e);else return null;return t.length?t:null}function ht(r,t){let e=t._?.substring(t.i).match(r);return e?(t.i+=e[0].length,e[0]):null}function Wt(r){ht(/^\s*/,r)}var Gu={dataType:null,batchType:null,name:"WKT (Well-Known Text)",id:"wkt",module:"wkt",version:zo,worker:!0,extensions:["wkt"],mimeTypes:["text/plain"],category:"geometry",text:!0,tests:ic,testText:ju,options:{wkt:{shape:"geojson-geometry",crs:!0}}},oc={...Gu,parse:async(r,t)=>sc(new TextDecoder().decode(r),t),parseTextSync:(r,t)=>sc(r,t)};var _r;(function(r){r[r.Point=1]="Point",r[r.LineString=2]="LineString",r[r.Polygon=3]="Polygon",r[r.MultiPoint=4]="MultiPoint",r[r.MultiLineString=5]="MultiLineString",r[r.MultiPolygon=6]="MultiPolygon",r[r.GeometryCollection=7]="GeometryCollection"})(_r||(_r={}));function $u(r){let t=new DataView(r),e=0,n=t.getUint8(e);if(e+=1,n>1)return!1;let i=n===1,s=t.getUint32(e,i);e+=4;let o=s&7;if(o===0||o>7)return!1;let a=s-o;if(a===0||a===1e3||a===2e3||a===3e3)return!0;if(a&536870911)return!1;if(a&536870912){let c=t.getUint32(e,i);if(e+=4,c>1e4)return!1}return!0}function Hu(r,t){let e=Object.assign(t||{},{type:"wkb",geometryType:1,dimensions:2,coordinates:"xy",littleEndian:!0,byteOffset:0});e.littleEndian=r.getUint8(e.byteOffset)===1,e.byteOffset++;let n=r.getUint32(e.byteOffset,e.littleEndian);e.byteOffset+=4,e.geometryType=n&7;let i=(n-e.geometryType)/1e3;switch(i){case 0:break;case 1:e.type="iso-wkb",e.dimensions=3,e.coordinates="xyz";break;case 2:e.type="iso-wkb",e.dimensions=3,e.coordinates="xym";break;case 3:e.type="iso-wkb",e.dimensions=4,e.coordinates="xyzm";break;default:throw new Error(`WKB: Unsupported iso-wkb type: ${i}`)}let s=n&2147483648,o=n&1073741824,a=n&536870912;return s&&o?(e.type="ewkb",e.dimensions=4,e.coordinates="xyzm"):s?(e.type="ewkb",e.dimensions=3,e.coordinates="xyz"):o&&(e.type="ewkb",e.dimensions=3,e.coordinates="xym"),a&&(e.type="ewkb",e.srid=r.getUint32(e.byteOffset,e.littleEndian),e.byteOffset+=4),e}function ac(r,t){let e=Xp(r,t),n=t?.wkb?.shape||"binary-geometry";switch(n){case"binary-geometry":return e;case"geojson-geometry":return Gn(e);case"geometry":return console.error('WKBLoader: "geometry" shape is deprecated, use "binary-geometry" instead'),Gn(e);default:throw new Error(n)}}function Xp(r,t){let e=new DataView(r),n=Hu(e),{geometryType:i,dimensions:s,littleEndian:o}=n,a=n.byteOffset;switch(i){case _r.Point:return Yu(e,a,s,o).geometry;case _r.LineString:return cc(e,a,s,o).geometry;case _r.Polygon:return Ku(e,a,s,o).geometry;case _r.MultiPoint:let h=Qp(e,a,s,o);return h.type="Point",h;case _r.MultiLineString:let d=qp(e,a,s,o);return d.type="LineString",d;case _r.MultiPolygon:let b=tm(e,a,s,o);return b.type="Polygon",b;default:throw new Error(`WKB: Unsupported geometry type: ${i}`)}}function Yu(r,t,e,n){let i=new Float64Array(e);for(let s=0;s<e;s++)i[s]=r.getFloat64(t,n),t+=8;return{geometry:{type:"Point",positions:{value:i,size:e}},offset:t}}function cc(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=new Float64Array(i*e);for(let a=0;a<i*e;a++)s[a]=r.getFloat64(t,n),t+=8;let o=[0];return i>0&&o.push(i),{geometry:{type:"LineString",positions:{value:s,size:e},pathIndices:{value:new Uint32Array(o),size:1}},offset:t}}var lc=r=>t=>r+=t;function Ku(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let l=0;l<i;l++){let u=cc(r,t,e,n),{positions:h}=u.geometry;t=u.offset,s.push(h.value)}let o=new Float64Array(Go(s).buffer),a=[0];o.length>0&&a.push(o.length/e);let c=s.map(l=>l.length/e).map(lc(0));return c.unshift(0),{geometry:{type:"Polygon",positions:{value:o,size:e},polygonIndices:{value:new Uint32Array(a),size:1},primitivePolygonIndices:{value:new Uint32Array(c),size:1}},offset:t}}function Qp(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let o=0;o<i;o++){let a=r.getUint8(t)===1;if(t++,r.getUint32(t,a)%1e3!==1)throw new Error("WKB: Inner geometries of MultiPoint not of type Point");t+=4;let c=Yu(r,t,e,a);t=c.offset,s.push(c.geometry)}return em(s,e)}function qp(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let o=0;o<i;o++){let a=r.getUint8(t)===1;if(t++,r.getUint32(t,a)%1e3!==2)throw new Error("WKB: Inner geometries of MultiLineString not of type LineString");t+=4;let c=cc(r,t,e,a);t=c.offset,s.push(c.geometry)}return rm(s,e)}function tm(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let o=0;o<i;o++){let a=r.getUint8(t)===1;if(t++,r.getUint32(t,a)%1e3!==3)throw new Error("WKB: Inner geometries of MultiPolygon not of type Polygon");t+=4;let c=Ku(r,t,e,a);t=c.offset,s.push(c.geometry)}return nm(s,e)}function em(r,t){let e=r.map(i=>i.positions.value);return{type:"Point",positions:{value:new Float64Array(Go(e).buffer),size:t}}}function rm(r,t){let e=r.map(s=>s.positions.value),n=new Float64Array(Go(e).buffer),i=e.map(s=>s.length/t).map(lc(0));return i.unshift(0),{type:"LineString",positions:{value:n,size:t},pathIndices:{value:new Uint32Array(i),size:1}}}function nm(r,t){let e=[],n=[];for(let a of r){let{positions:c,primitivePolygonIndices:l}=a;e.push(c.value),n.push(l.value)}let i=new Float64Array(Go(e).buffer),s=e.map(a=>a.length/t).map(lc(0));s.unshift(0);let o=[0];for(let a of n)o.push(...a.filter(c=>c>0).map(c=>c+o[o.length-1]));return{type:"Polygon",positions:{value:i,size:t},polygonIndices:{value:new Uint32Array(s),size:1},primitivePolygonIndices:{value:new Uint32Array(o),size:1}}}function Go(r){let t=0;for(let i=0;i<r.length;++i)t+=r[i].byteLength;let e=new Uint8Array(t),n=0;for(let i=0;i<r.length;++i){let s=new Uint8Array(r[i].buffer);t=s.length;for(let o=0;o<t;++o)e[n++]=s[o]}return e}var Zu={dataType:null,batchType:null,name:"WKB",id:"wkb",module:"wkt",version:zo,worker:!0,category:"geometry",extensions:["wkb"],mimeTypes:[],tests:[$u],options:{wkb:{shape:"binary-geometry"}}},uc={...Zu,parse:async r=>ac(r),parseSync:ac};function Vo(r,t){if(t=t?.toLowerCase(),!t||!r)return null;let e;switch(t){case"geoarrow.multipolygon":e=om(r);break;case"geoarrow.polygon":e=am(r);break;case"geoarrow.multipoint":e=cm(r);break;case"geoarrow.point":e=lm(r);break;case"geoarrow.multilinestring":e=um(r);break;case"geoarrow.linestring":e=fm(r);break;case"geoarrow.wkb":e=im(r);break;case"geoarrow.wkt":e=sm(r);break;default:throw Error(`GeoArrow encoding not supported ${t}`)}return e}function im(r){let t=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),e=uc.parseSync?.(t);return Gn(e)}function sm(r){let t=r;return oc.parseTextSync?.(t)}function om(r){let t=[];for(let n=0;n<r.length;n++){let i=r.get(n),s=[];for(let o=0;i&&o<i?.length;o++){let a=i?.get(o),c=[];for(let l=0;a&&l<a.length;l++){let u=a.get(l),h=Array.from(u);c.push(h)}s.push(c)}t.push(s)}return{type:"MultiPolygon",coordinates:t}}function am(r){let t=[];for(let n=0;r&&n<r.length;n++){let i=r.get(n),s=[];for(let o=0;i&&o<i.length;o++){let a=i.get(o),c=Array.from(a);s.push(c)}t.push(s)}return{type:"Polygon",coordinates:t}}function cm(r){let t=[];for(let e=0;r&&e<r.length;e++){let n=r.get(e);if(n){let i=Array.from(n);t.push(i)}}return{type:"MultiPoint",coordinates:t}}function lm(r){return{type:"Point",coordinates:Array.from(r)}}function um(r){let t=[];for(let e=0;r&&e<r.length;e++){let n=r.get(e),i=[];for(let s=0;n&&s<n.length;s++){let o=n.get(s);if(o){let a=Array.from(o);i.push(a)}}t.push(i)}return{type:"MultiLineString",coordinates:t}}function fm(r){let t=[];for(let e=0;r&&e<r.length;e++){let n=r.get(e);if(n){let i=Array.from(n);t.push(i)}}return{type:"LineString",coordinates:t}}function Ki(r,t=!1){if("data"in r)return new g(r.data.map(s=>Ki(s,t)));let e=[];for(let s of r.children)e.push(Ki(s,t));let n;r.dictionary!==void 0&&(n=Ki(r.dictionary,t));let i={[lt.OFFSET]:$o(r.buffers[lt.OFFSET],t),[lt.DATA]:$o(r.buffers[lt.DATA],t),[lt.VALIDITY]:$o(r.buffers[lt.VALIDITY],t),[lt.TYPE]:$o(r.buffers[lt.TYPE],t)};return new R(r.type,r.offset,r.length,r._nullCount,i,e,n)}function hm(r){return!(r.byteOffset===0&&r.byteLength===r.buffer.byteLength)}function $o(r,t){return r===void 0||!t&&!hm(r)?r:r.slice()}var Ju="latest";function dm(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.0-alpha.7"),globalThis._loadersgl_.version}var fc=dm();function ir(r,t){if(!r)throw new Error(t||"loaders.gl assertion failed.")}var sr={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},KB=sr.self||sr.window||sr.global||{},ZB=sr.window||sr.self||sr.global||{},JB=sr.global||sr.self||sr.window||{},XB=sr.document||{};var vr=typeof process!="object"||String(process)!=="[object process]"||process.browser;var Qu=typeof window<"u"&&typeof window.orientation<"u",Xu=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),QB=Xu&&parseFloat(Xu[1])||0;var Zi=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(t,e){this.name=t,this.workerThread=e,this.result=new Promise((n,i)=>{this._resolve=n,this._reject=i})}postMessage(t,e){this.workerThread.postMessage({source:"loaders.gl",type:t,payload:e})}done(t){ir(this.isRunning),this.isRunning=!1,this._resolve(t)}error(t){ir(this.isRunning),this.isRunning=!1,this._reject(t)}};var Hn=class{terminate(){}};var hc=new Map;function qu(r){ir(r.source&&!r.url||!r.source&&r.url);let t=hc.get(r.source||r.url);return t||(r.url&&(t=pm(r.url),hc.set(r.url,t)),r.source&&(t=tf(r.source),hc.set(r.source,t))),ir(t),t}function pm(r){if(!r.startsWith("http"))return r;let t=mm(r);return tf(t)}function tf(r){let t=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(t)}function mm(r){return`try {
16
+ ]`}concat(...t){let e=this.schema,n=this.data.concat(t.flatMap(({data:i})=>i));return new K(e,n.map(i=>new W(e,i)))}slice(t,e){let n=this.schema;[t,e]=ai({length:this.numRows},t,e);let i=Gs(this.data,this._offsets,t,e);return new K(n,i.map(s=>new W(n,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){let e=this.data.map(n=>n.children[t]);if(e.length===0){let{type:n}=this.schema.fields[t],i=w({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new b(e)}return null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new b([w({type:new ut,length:this.numRows})]));let s=n.fields.slice(),o=s[t].clone({type:e.type}),a=this.schema.fields.map((c,l)=>this.getChildAt(l));[s[t],a[t]]=[o,e],[n,i]=_o(n,a)}return new K(n,i)}select(t){let e=this.schema.fields.reduce((n,i,s)=>n.set(i.name,s),new Map);return this.selectAt(t.map(n=>e.get(n)).filter(n=>n>-1))}selectAt(t){let e=this.schema.selectAt(t),n=this.batches.map(i=>i.selectAt(t));return new K(e,n)}assign(t){let e=this.schema.fields,[n,i]=t.schema.fields.reduce((a,c,l)=>{let[u,h]=a,d=e.findIndex(p=>p.name===c.name);return~d?h[d]=l:u.push(l),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,i[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...n.map(a=>t.getChildAt(a))].filter(Boolean);return new K(..._o(s,o))}};ou=Symbol.toStringTag;K[ou]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=Tn(ui),r.get=Tn(pt.getVisitFn(f.Struct)),r.set=$s(Dt.getVisitFn(f.Struct)),r.indexOf=Hs(qr.getVisitFn(f.Struct)),"Table"))(K.prototype);var cu,W=class{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof R))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=w({nullCount:0,type:new V(this.schema.fields),children:this.schema.fields.map(e=>w({type:e.type,nullCount:0}))})]=t,!(this.data instanceof U))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=au(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:n,children:i,length:s}=Object.keys(e).reduce((c,l,u)=>(c.children[u]=e[l],c.length=Math.max(c.length,e[l].length),c.fields[u]=O.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new R(n),a=w({type:new V(n),length:s,children:i,nullCount:0});[this.schema,this.data]=au(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=lu(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return pt.visit(this.data,t)}set(t,e){return Dt.visit(this.data,t,e)}indexOf(t,e){return qr.visit(this.data,t,e)}[Symbol.iterator](){return Dn.visit(new b([this.data]))}toArray(){return[...this]}concat(...t){return new K(this.schema,[this,...t])}slice(t,e){let[n]=new b([this.data]).slice(t,e).data;return new W(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new b([this.data.children[t]]):null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=this.data;if(t>-1&&t<this.numCols){e||(e=new b([w({type:new ut,length:this.numRows})]));let s=n.fields.slice(),o=i.children.slice(),a=s[t].clone({type:e.type});[s[t],o[t]]=[a,e.data[0]],n=new R(s,new Map(this.schema.metadata)),i=w({type:new V(s),children:o})}return new W(n,i)}select(t){let e=this.schema.select(t),n=new V(e.fields),i=[];for(let s of t){let o=this.schema.fields.findIndex(a=>a.name===s);~o&&(i[o]=this.data.children[o])}return new W(e,w({type:n,length:this.numRows,children:i}))}selectAt(t){let e=this.schema.selectAt(t),n=t.map(s=>this.data.children[s]).filter(Boolean),i=w({type:new V(e.fields),length:this.numRows,children:n});return new W(e,i)}};cu=Symbol.toStringTag;W[cu]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(W.prototype);function au(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;let i=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(let[a,c]of r.fields.entries()){let l=t[a];(!l||l.length!==e)&&(i[a]=c.clone({nullable:!0}),s[a]=(n=l?._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:w({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(i),w({type:new V(i),length:e,children:s})]}function lu(r,t,e=new Map){var n,i;if(((n=r?.length)!==null&&n!==void 0?n:0)>0&&r?.length===t?.length)for(let s=-1,o=r.length;++s<o;){let{type:a}=r[s],c=t[s];for(let l of[c,...((i=c?.dictionary)===null||i===void 0?void 0:i.data)||[]])lu(a.children,l?.children,e);if(y.isDictionary(a)){let{id:l}=a;if(!e.has(l))c?.dictionary&&e.set(l,c.dictionary);else if(e.get(l)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var cn=class extends W{constructor(t){let e=t.fields.map(i=>w({type:i.type})),n=w({type:new V(t.fields),nullCount:0,children:e});super(t,n)}};var ft=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new ft).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new ft).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):H.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):P.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Q).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,H.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,P.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,n,i,s,o){return ft.startMessage(t),ft.addVersion(t,e),ft.addHeaderType(t,n),ft.addHeader(t,i),ft.addBodyLength(t,s),ft.addCustomMetadata(t,o),ft.endMessage(t)}};var za=class extends I{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return je.startNull(e),je.endNull(e)}visitInt(t,e){return wt.startInt(e),wt.addBitWidth(e,t.bitWidth),wt.addIsSigned(e,t.isSigned),wt.endInt(e)}visitFloat(t,e){return Kt.startFloatingPoint(e),Kt.addPrecision(e,t.precision),Kt.endFloatingPoint(e)}visitBinary(t,e){return Re.startBinary(e),Re.endBinary(e)}visitLargeBinary(t,e){return Pe.startLargeBinary(e),Pe.endLargeBinary(e)}visitBool(t,e){return Ce.startBool(e),Ce.endBool(e)}visitUtf8(t,e){return We.startUtf8(e),We.endUtf8(e)}visitLargeUtf8(t,e){return ke.startLargeUtf8(e),ke.endLargeUtf8(e)}visitDecimal(t,e){return _t.startDecimal(e),_t.addScale(e,t.scale),_t.addPrecision(e,t.precision),_t.addBitWidth(e,t.bitWidth),_t.endDecimal(e)}visitDate(t,e){return Gt.startDate(e),Gt.addUnit(e,t.unit),Gt.endDate(e)}visitTime(t,e){return Mt.startTime(e),Mt.addUnit(e,t.unit),Mt.addBitWidth(e,t.bitWidth),Mt.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return Lt.startTimestamp(e),Lt.addUnit(e,t.unit),n!==void 0&&Lt.addTimezone(e,n),Lt.endTimestamp(e)}visitInterval(t,e){return Zt.startInterval(e),Zt.addUnit(e,t.unit),Zt.endInterval(e)}visitDuration(t,e){return $t.startDuration(e),$t.addUnit(e,t.unit),$t.endDuration(e)}visitList(t,e){return Ve.startList(e),Ve.endList(e)}visitStruct(t,e){return ze.startStruct_(e),ze.endStruct_(e)}visitUnion(t,e){vt.startTypeIdsVector(e,t.typeIds.length);let n=vt.createTypeIdsVector(e,t.typeIds);return vt.startUnion(e),vt.addMode(e,t.mode),vt.addTypeIds(e,n),vt.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return ae.startDictionaryEncoding(e),ae.addId(e,BigInt(t.id)),ae.addIsOrdered(e,t.isOrdered),n!==void 0&&ae.addIndexType(e,n),ae.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Ht.startFixedSizeBinary(e),Ht.addByteWidth(e,t.byteWidth),Ht.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Yt.startFixedSizeList(e),Yt.addListSize(e,t.listSize),Yt.endFixedSizeList(e)}visitMap(t,e){return Jt.startMap(e),Jt.addKeysSorted(e,t.keysSorted),Jt.endMap(e)}},vo=new za;function du(r,t=new Map){return new R(Id(r,t),Io(r.metadata),t)}function Wa(r){return new Ot(r.count,mu(r.columns),yu(r.columns))}function pu(r){return new ne(Wa(r.data),r.id,r.isDelta)}function Id(r,t){return(r.fields||[]).filter(Boolean).map(e=>O.fromJSON(e,t))}function uu(r,t){return(r.children||[]).filter(Boolean).map(e=>O.fromJSON(e,t))}function mu(r){return(r||[]).reduce((t,e)=>[...t,new _e(e.count,xd(e.VALIDITY)),...mu(e.children)],[])}function yu(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new re(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new re(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new re(t.length,i.OFFSET.length)),i.DATA&&t.push(new re(t.length,i.DATA.length)),t=yu(i.children,t)}return t}function xd(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function gu(r,t){let e,n,i,s,o,a;return!t||!(s=r.dictionary)?(o=hu(r,uu(r,t)),i=new O(r.name,o,r.nullable,Io(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?fu(n):new It,a=new Ut(t.get(e),n,e,s.isOrdered),i=new O(r.name,a,r.nullable,Io(r.metadata))):(n=(n=s.indexType)?fu(n):new It,t.set(e,o=hu(r,uu(r,t))),a=new Ut(o,n,e,s.isOrdered),i=new O(r.name,a,r.nullable,Io(r.metadata))),i||null}function Io(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function fu(r){return new st(r.isSigned,r.bitWidth)}function hu(r,t){let e=r.type.name;switch(e){case"NONE":return new ut;case"null":return new ut;case"binary":return new ce;case"largebinary":return new Je;case"utf8":return new Pt;case"largeutf8":return new Xe;case"bool":return new kt;case"list":return new Tt((t||[])[0]);case"struct":return new V(t||[]);case"struct_":return new V(t||[])}switch(e){case"int":{let n=r.type;return new st(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new At(z[n.precision])}case"decimal":{let n=r.type;return new le(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new Xt(rt[n.unit])}case"time":{let n=r.type;return new xt(m[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new Nt(m[n.unit],n.timezone)}case"interval":{let n=r.type;return new Qt(it[n.unit])}case"duration":{let n=r.type;return new Qe(m[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new ge(J[o],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new qe(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new Vt(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new jt((t||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var Sd=ar,Bd=Ct,yt=class{static fromJSON(t,e){let n=new yt(0,H.V5,e);return n._createHeader=Ad(t,e),n}static decode(t){t=new Bd(D(t));let e=ft.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new yt(n,i,s);return o._createHeader=Td(e,s),o}static encode(t){let e=new Sd,n=-1;return t.isSchema()?n=R.encode(e,t.header()):t.isRecordBatch()?n=Ot.encode(e,t.header()):t.isDictionaryBatch()&&(n=ne.encode(e,t.header())),ft.startMessage(e),ft.addVersion(e,H.V5),ft.addHeader(e,n),ft.addHeaderType(e,t.headerType),ft.addBodyLength(e,BigInt(t.bodyLength)),ft.finishMessageBuffer(e,ft.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof R)return new yt(0,H.V5,P.Schema,t);if(t instanceof Ot)return new yt(e,H.V5,P.RecordBatch,t);if(t instanceof ne)return new yt(e,H.V5,P.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===P.Schema}isRecordBatch(){return this.headerType===P.RecordBatch}isDictionaryBatch(){return this.headerType===P.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=at(t)}},Ot=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=at(t)}},ne=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,n=!1){this._data=t,this._isDelta=n,this._id=at(e)}},re=class{constructor(t,e){this.offset=at(t),this.length=at(e)}},_e=class{constructor(t,e){this.length=at(t),this.nullCount=at(e)}};function Ad(r,t){return()=>{switch(t){case P.Schema:return R.fromJSON(r);case P.RecordBatch:return Ot.fromJSON(r);case P.DictionaryBatch:return ne.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${P[t]}, type: ${t} }`)}}function Td(r,t){return()=>{switch(t){case P.Schema:return R.decode(r.header(new ot),new Map,r.version());case P.RecordBatch:return Ot.decode(r.header(new Ft),r.version());case P.DictionaryBatch:return ne.decode(r.header(new de),r.version())}throw new Error(`Unrecognized Message type: { name: ${P[t]}, type: ${t} }`)}}O.encode=Pd;O.decode=Rd;O.fromJSON=gu;R.encode=Cd;R.decode=Dd;R.fromJSON=du;Ot.encode=kd;Ot.decode=Od;Ot.fromJSON=Wa;ne.encode=Vd;ne.decode=Fd;ne.fromJSON=pu;_e.encode=jd;_e.decode=Ld;re.encode=zd;re.decode=Md;function Dd(r,t=new Map,e=H.V5){let n=Ed(r,t);return new R(n,xo(r),t,e)}function Od(r,t=H.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new Ot(r.length(),Nd(r),Ud(r,t))}function Fd(r,t=H.V5){return new ne(Ot.decode(r.data(),t),r.id(),r.isDelta())}function Md(r){return new re(r.offset(),r.length())}function Ld(r){return new _e(r.length(),r.nullCount())}function Nd(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=_e.decode(e));return t}function Ud(r,t){let e=[];for(let n,i=-1,s=-1,o=r.buffersLength();++i<o;)(n=r.buffers(i))&&(t<H.V4&&(n.bb_pos+=8*(i+1)),e[++s]=re.decode(n));return e}function Ed(r,t){let e=[];for(let n,i=-1,s=-1,o=r.fieldsLength();++i<o;)(n=r.fields(i))&&(e[++s]=O.decode(n,t));return e}function bu(r,t){let e=[];for(let n,i=-1,s=-1,o=r.childrenLength();++i<o;)(n=r.children(i))&&(e[++s]=O.decode(n,t));return e}function Rd(r,t){let e,n,i,s,o,a;return!t||!(a=r.dictionary())?(i=_u(r,bu(r,t)),n=new O(r.name(),i,r.nullable(),xo(r))):t.has(e=at(a.id()))?(s=(s=a.indexType())?wu(s):new It,o=new Ut(t.get(e),s,e,a.isOrdered()),n=new O(r.name(),o,r.nullable(),xo(r))):(s=(s=a.indexType())?wu(s):new It,t.set(e,i=_u(r,bu(r,t))),o=new Ut(i,s,e,a.isOrdered()),n=new O(r.name(),o,r.nullable(),xo(r))),n||null}function xo(r){let t=new Map;if(r)for(let e,n,i=-1,s=Math.trunc(r.customMetadataLength());++i<s;)(e=r.customMetadata(i))&&(n=e.key())!=null&&t.set(n,e.value());return t}function wu(r){return new st(r.isSigned(),r.bitWidth())}function _u(r,t){let e=r.typeType();switch(e){case X.NONE:return new ut;case X.Null:return new ut;case X.Binary:return new ce;case X.LargeBinary:return new Je;case X.Utf8:return new Pt;case X.LargeUtf8:return new Xe;case X.Bool:return new kt;case X.List:return new Tt((t||[])[0]);case X.Struct_:return new V(t||[])}switch(e){case X.Int:{let n=r.type(new wt);return new st(n.isSigned(),n.bitWidth())}case X.FloatingPoint:{let n=r.type(new Kt);return new At(n.precision())}case X.Decimal:{let n=r.type(new _t);return new le(n.scale(),n.precision(),n.bitWidth())}case X.Date:{let n=r.type(new Gt);return new Xt(n.unit())}case X.Time:{let n=r.type(new Mt);return new xt(n.unit(),n.bitWidth())}case X.Timestamp:{let n=r.type(new Lt);return new Nt(n.unit(),n.timezone())}case X.Interval:{let n=r.type(new Zt);return new Qt(n.unit())}case X.Duration:{let n=r.type(new $t);return new Qe(n.unit())}case X.Union:{let n=r.type(new vt);return new ge(n.mode(),n.typeIdsArray()||[],t||[])}case X.FixedSizeBinary:{let n=r.type(new Ht);return new qe(n.byteWidth())}case X.FixedSizeList:{let n=r.type(new Yt);return new Vt(n.listSize(),(t||[])[0])}case X.Map:{let n=r.type(new Jt);return new jt((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${X[e]}" (${e})`)}function Cd(r,t){let e=t.fields.map(s=>O.encode(r,s));ot.startFieldsVector(r,e.length);let n=ot.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?ot.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString(`${s}`),c=r.createString(`${o}`);return Q.startKeyValue(r),Q.addKey(r,a),Q.addValue(r,c),Q.endKeyValue(r)})):-1;return ot.startSchema(r),ot.addFields(r,n),ot.addEndianness(r,Wd?Sr.Little:Sr.Big),i!==-1&&ot.addCustomMetadata(r,i),ot.endSchema(r)}function Pd(r,t){let e=-1,n=-1,i=-1,s=t.type,o=t.typeId;y.isDictionary(s)?(o=s.dictionary.typeId,i=vo.visit(s,r),n=vo.visit(s.dictionary,r)):n=vo.visit(s,r);let a=(s.children||[]).map(u=>O.encode(r,u)),c=dt.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?dt.createCustomMetadataVector(r,[...t.metadata].map(([u,h])=>{let d=r.createString(`${u}`),p=r.createString(`${h}`);return Q.startKeyValue(r),Q.addKey(r,d),Q.addValue(r,p),Q.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),dt.startField(r),dt.addType(r,n),dt.addTypeType(r,o),dt.addChildren(r,c),dt.addNullable(r,!!t.nullable),e!==-1&&dt.addName(r,e),i!==-1&&dt.addDictionary(r,i),l!==-1&&dt.addCustomMetadata(r,l),dt.endField(r)}function kd(r,t){let e=t.nodes||[],n=t.buffers||[];Ft.startNodesVector(r,e.length);for(let o of e.slice().reverse())_e.encode(r,o);let i=r.endVector();Ft.startBuffersVector(r,n.length);for(let o of n.slice().reverse())re.encode(r,o);let s=r.endVector();return Ft.startRecordBatch(r),Ft.addLength(r,BigInt(t.length)),Ft.addNodes(r,i),Ft.addBuffers(r,s),Ft.endRecordBatch(r)}function Vd(r,t){let e=Ot.encode(r,t.data);return de.startDictionaryBatch(r),de.addId(r,BigInt(t.id)),de.addIsDelta(r,t.isDelta),de.addData(r,e),de.endDictionaryBatch(r)}function jd(r,t){return wn.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function zd(r,t){return bn.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var Wd=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var $a=r=>`Expected ${P[r]} Message in stream, but was null or length 0.`,Ha=r=>`Header pointer of flatbuffer-encoded ${P[r]} Message is null or length 0.`,vu=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,Iu=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Cn=class{constructor(t){this.source=t instanceof rr?t:new rr(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?q:t.value===-1&&(t=this.readMetadataLength()).done?q:(t=this.readMetadata(t.value)).done?q:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error($a(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=D(this.source.read(t));if(e.byteLength<t)throw new Error(Iu(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=P.Schema,n=this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(Ha(e));return i}readMetadataLength(){let t=this.source.read(So),e=t&&new Ct(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}}readMetadata(t){let e=this.source.read(t);if(!e)return q;if(e.byteLength<t)throw new Error(vu(t,e.byteLength));return{done:!1,value:yt.decode(e)}}},ki=class{constructor(t,e){this.source=t instanceof te?t:hs(t)?new Fr(t,e):new te(t)}[Symbol.asyncIterator](){return this}next(){return g(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?q:t.value===-1&&(t=yield this.readMetadataLength()).done?q:(t=yield this.readMetadata(t.value)).done?q:t})}throw(t){return g(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return g(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return g(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error($a(t));return e.value})}readMessageBody(t){return g(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=D(yield this.source.read(t));if(e.byteLength<t)throw new Error(Iu(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(t=!1){return g(this,void 0,void 0,function*(){let e=P.Schema,n=yield this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(Ha(e));return i})}readMetadataLength(){return g(this,void 0,void 0,function*(){let t=yield this.source.read(So),e=t&&new Ct(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}})}readMetadata(t){return g(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return q;if(e.byteLength<t)throw new Error(vu(t,e.byteLength));return{done:!1,value:yt.decode(e)}})}},Vi=class extends Cn{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof fi?t:new fi(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:yt.fromJSON(t.schema,P.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:yt.fromJSON(e,P.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:yt.fromJSON(e,P.RecordBatch)}}return this._body=[],q}readMessageBody(t){return e(this._body);function e(n){return(n||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error($a(t));return e.value}readSchema(){let t=P.Schema,e=this.readMessage(t),n=e?.header();if(!e||!n)throw new Error(Ha(t));return n}},So=4,Ga="ARROW1",Pn=new Uint8Array(Ga.length);for(let r=0;r<Ga.length;r+=1)Pn[r]=Ga.codePointAt(r);function Bo(r,t=0){for(let e=-1,n=Pn.length;++e<n;)if(Pn[e]!==r[t+e])return!1;return!0}var kn=Pn.length,Ya=kn+So,xu=kn*2+So;var gt=class extends en{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){let e=this._impl.open(t);return se(e)?e.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return Bt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return Bt.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof gt?t:us(t)?$d(t):hs(t)?Kd(t):se(t)?(()=>g(this,void 0,void 0,function*(){return yield gt.from(yield t)}))():ds(t)||qn(t)||ms(t)||fe(t)?Yd(new te(t)):Hd(new rr(t))}static readAll(t){return t instanceof gt?t.isSync()?Su(t):Bu(t):us(t)||ArrayBuffer.isView(t)||Ie(t)||fs(t)?Su(t):Bu(t)}},ir=class extends gt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return ie(this,arguments,function*(){yield E(yield*yn(ve(this[Symbol.iterator]())))})}},Mr=class extends gt{constructor(t){super(t),this._impl=t}readAll(){var t,e,n,i;return g(this,void 0,void 0,function*(){let s=new Array;try{for(var o=!0,a=ve(this),c;c=yield a.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let l=i;s.push(l)}}catch(l){e={error:l}}finally{try{!o&&!t&&(n=a.return)&&(yield n.call(a))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Lr=class extends ir{constructor(t){super(t),this._impl=t}},ji=class extends Mr{constructor(t){super(t),this._impl=t}},Ao=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){let n=this._loadVectors(t,e,this.schema.fields),i=w({type:new V(this.schema.fields),length:t.length,children:n});return new W(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:o}=this,a=s.get(n);if(i||!a){let c=o.dictionaries.get(n),l=this._loadVectors(t.data,e,[c]);return(a&&i?a.concat(new b(l)):new b(l)).memoize()}return a.memoize()}_loadVectors(t,e,n){return new pi(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},Vn=class extends Ao{constructor(t,e){super(e),this._reader=us(t)?new Vi(this._handle=t):new Cn(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=Au(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):q}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):q}next(){if(this.closed)return q;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new cn(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},jn=class extends Ao{constructor(t,e){super(e),this._reader=new ki(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return g(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return g(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Au(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):q})}return(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):q})}next(){return g(this,void 0,void 0,function*(){if(this.closed)return q;let t,{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new cn(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},To=class extends Vn{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof hi?t:new hi(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(P.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(P.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-Ya,n=t.readInt32(e),i=t.readAt(e-n,n);return fr.decode(i)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(n&&this._handle.seek(n.offset))return this._reader.readMessage(t)}return null}},Ka=class extends jn{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let n=typeof e[0]!="number"?e.shift():void 0,i=e[0]instanceof Map?e.shift():void 0;super(t instanceof Fr?t:new Fr(t,n),i)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return g(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){var e;return g(this,void 0,void 0,function*(){if(this.closed)return null;this._footer||(yield this.open());let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(P.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){var e;return g(this,void 0,void 0,function*(){let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(P.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return g(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-Ya,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return fr.decode(i)})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},Za=class extends Vn{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new Zs(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function Au(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Su(r){let t=gt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Bu(r){return ie(this,arguments,function*(){let e=yield E(gt.from(r));try{if(!(yield E(e.open({autoDestroy:!1}))).closed)do yield yield E(e);while(!(yield E(e.reset().open())).closed)}finally{yield E(e.cancel())}})}function $d(r){return new ir(new Za(r))}function Hd(r){let t=r.peek(kn+7&-8);return t&&t.byteLength>=4?Bo(t)?new Lr(new To(r.read())):new ir(new Vn(r)):new ir(new Vn(function*(){}()))}function Yd(r){return g(this,void 0,void 0,function*(){let t=yield r.peek(kn+7&-8);return t&&t.byteLength>=4?Bo(t)?new Lr(new To(yield r.read())):new Mr(new jn(r)):new Mr(new jn(function(){return ie(this,arguments,function*(){})}()))})}function Kd(r){return g(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new Fr(r,t);return t>=xu&&Bo(yield e.readAt(0,kn+7&-8))?new ji(new Ka(e)):new Mr(new jn(e))})}var tt=class extends I{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof W?s.data.children:s.data),n=new tt;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof b)return this.visitMany(t.data),this;let{type:e}=t;if(!y.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(y.isUnion(e))this.nodes.push(new _e(n,0));else{let{nullCount:i}=t;y.isNull(e)||Le.call(this,i<=0?new Uint8Array(0):Jr(t.offset,n,t.nullBitmap)),this.nodes.push(new _e(n,i))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function Le(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new re(this._byteLength,t)),this._byteLength+=t,this}function Zd(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(Le.call(this,i),e.mode===J.Sparse)return Ja.call(this,r);if(e.mode===J.Dense){if(r.offset<=0)return Le.call(this,s),Ja.call(this,r);{let o=new Int32Array(n),a=Object.create(null),c=Object.create(null);for(let l,u,h=-1;++h<n;)(l=i[h])!==void 0&&((u=a[l])===void 0&&(u=a[l]=s[h]),o[h]=s[h]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);Le.call(this,o),this.visitMany(r.children.map((l,u)=>{let h=e.typeIds[u],d=a[h],p=c[h];return l.slice(d,Math.min(n,p))}))}}return this}function Jd(r){let t;return r.nullCount>=r.length?Le.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?Le.call(this,Jr(r.offset,r.length,t)):Le.call(this,Xr(r.values))}function gr(r){return Le.call(this,r.values.subarray(0,r.length*r.stride))}function Do(r){let{length:t,values:e,valueOffsets:n}=r,i=at(n[0]),s=at(n[t]),o=Math.min(s-i,e.byteLength-i);return Le.call(this,gs(-i,t+1,n)),Le.call(this,e.subarray(i,i+o)),this}function Xa(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return Le.call(this,gs(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function Ja(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}tt.prototype.visitBool=Jd;tt.prototype.visitInt=gr;tt.prototype.visitFloat=gr;tt.prototype.visitUtf8=Do;tt.prototype.visitLargeUtf8=Do;tt.prototype.visitBinary=Do;tt.prototype.visitLargeBinary=Do;tt.prototype.visitFixedSizeBinary=gr;tt.prototype.visitDate=gr;tt.prototype.visitTimestamp=gr;tt.prototype.visitTime=gr;tt.prototype.visitDecimal=gr;tt.prototype.visitList=Xa;tt.prototype.visitStruct=Ja;tt.prototype.visitUnion=Zd;tt.prototype.visitInterval=gr;tt.prototype.visitDuration=gr;tt.prototype.visitFixedSizeList=Xa;tt.prototype.visitMap=Xa;var ln=class extends en{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new er,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,Rt(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return se(t)?t.then(e=>this.writeAll(e)):fe(t)?qa(this,t):Qa(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){return t===this._sink||t instanceof er?this._sink=t:(this._sink=new er,t&&Vc(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&jc(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._dictionaryDeltaOffsets=new Map,(!e||!an(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof K&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof W&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!an(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof W?t instanceof cn||this._writeRecordBatch(t):t instanceof K?this.writeAll(t.batches):Ie(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=yt.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+n&~n,c=a-s-o;return t.headerType===P.RecordBatch?this._recordBatchBlocks.push(new Fe(a,t.bodyLength,this._position)):t.headerType===P.DictionaryBatch&&this._dictionaryBlocks.push(new Fe(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(c)}_write(t){if(this._started){let e=D(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(yt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Pn)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=tt.assemble(t),o=new Ot(t.numRows,n,i),a=yt.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){this._dictionaryDeltaOffsets.set(e,t.length+(this._dictionaryDeltaOffsets.get(e)||0));let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=tt.assemble(new b([t])),c=new Ot(t.length,s,o),l=new ne(c,e,n),u=yt.from(l,i);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,n,i;for(let s=-1,o=t.length;++s<o;)(e=t[s])&&(n=e.byteLength)>0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this}_writeDictionaries(t){for(let[e,n]of t.dictionaries){let i=this._dictionaryDeltaOffsets.get(e)||0;if(i===0||(n=n?.slice(i)).length>0)for(let s of n.data)this._writeDictionaryBatch(s,e,i>0),i+=s.length}return this}},br=class extends ln{static writeAll(t,e){let n=new br(e);return se(t)?t.then(i=>n.writeAll(i)):fe(t)?qa(n,t):Qa(n,t)}},wr=class extends ln{static writeAll(t){let e=new wr;return se(t)?t.then(n=>e.writeAll(n)):fe(t)?qa(e,t):Qa(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeFooter(t){let e=fr.encode(new fr(t,H.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Qa(r,t){let e=t;t instanceof K&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function qa(r,t){var e,n,i,s,o,a,c;return g(this,void 0,void 0,function*(){try{for(e=!0,n=ve(t);i=yield n.next(),s=i.done,!s;e=!0){c=i.value,e=!1;let l=c;r.write(l)}}catch(l){o={error:l}}finally{try{!e&&!s&&(a=n.return)&&(yield a.call(n))}finally{if(o)throw o.error}}return r.finish()})}function Tu(r,t){if(fe(r))return Qd(r,t);if(Ie(r))return Xd(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Xd(r,t){let e=null,n=t?.type==="bytes"||!1,i=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){s(o,e||(e=r[Symbol.iterator]()))},pull(o){e?s(o,e):o.close()},cancel(){(e?.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){let c,l=null,u=o.desiredSize||null;for(;!(l=a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=D(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()}}function Qd(r,t){let e=null,n=t?.type==="bytes"||!1,i=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return g(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return g(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return g(this,void 0,void 0,function*(){(e?.return&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){return g(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=D(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()})}}function Fu(r){return new tc(r)}var tc=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=Pc(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Me(s),this._getSize=i!=="bytes"?Du:Ou;let{["highWaterMark"]:o=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:c=>{this._maybeFlush(this._builder,this._controller=c)},start:c=>{this._maybeFlush(this._builder,this._controller=c)}},{highWaterMark:o,size:i!=="bytes"?Du:Ou}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:c=>this._writeValueAndReturnChunkSize(c)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},Du=r=>{var t;return(t=r?.length)!==null&&t!==void 0?t:0},Ou=r=>{var t;return(t=r?.byteLength)!==null&&t!==void 0?t:0};function Oo(r,t){let e=new er,n=null,i=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield e.close()})},start(a){return g(this,void 0,void 0,function*(){yield o(a,n||(n=yield s()))})},pull(a){return g(this,void 0,void 0,function*(){n?yield o(a,n):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:i};function s(){return g(this,void 0,void 0,function*(){return yield(yield gt.from(e)).open(t)})}function o(a,c){return g(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}function Fo(r,t){let e=new this(r),n=new te(e),i=new ReadableStream({cancel(){return g(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return g(this,void 0,void 0,function*(){yield s(o)})},start(o){return g(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(o){return g(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield n.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}function zi(r){let t=gt.from(r);return se(t)?t.then(e=>zi(e)):t.isAsync()?t.readAll().then(e=>new K(e)):new K(t.readAll())}function Mo(r,t="stream"){return(t==="stream"?br:wr).writeAll(r).toUint8Array(!0)}var lp=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},fa),Ra),Da),ha),oa),Ta),la),{compareSchemas:an,compareFields:su,compareTypes:bo});Bt.toDOMStream=Tu;nt.throughDOM=Fu;gt.throughDOM=Oo;Lr.throughDOM=Oo;ir.throughDOM=Oo;ln.throughDOM=Fo;wr.throughDOM=Fo;br.throughDOM=Fo;var Lo=class extends Er{arrowSchema;constructor(t,e){super(t,e),this.arrowSchema=null}getBatch(){let t=super.getBatch();if(t){this.arrowSchema=this.arrowSchema||up(t.schema);let e=fp(this.arrowSchema,t.data),n=new W(this.arrowSchema,w({type:new V(this.arrowSchema.fields),children:e.map(({data:i})=>i[0])}));return{shape:"arrow-table",batchType:"data",data:new K([n]),length:t.length}}return null}};function up(r){let t=[];for(let e in r){let n=r[e];if(n.type===Float32Array){let i=new Map,s=new O(n.name,new me,n.nullable,i);t.push(s)}}if(t.length===0)throw new Error("No arrow convertible fields");return new R(t)}function fp(r,t){let e=[];for(let n of r.fields){let i=t[n.name];if(i instanceof Float32Array){let s=Or(i);e.push(s)}}if(r.fields.length!==e.length)throw new Error("Some columns not arrow convertible");return e}var hp="4.3.0-beta.1",Wn={dataType:null,batchType:null,name:"Apache Arrow",id:"arrow",module:"arrow",version:hp,category:"table",extensions:["arrow","feather"],mimeTypes:["application/vnd.apache.arrow.file","application/vnd.apache.arrow.stream","application/octet-stream"],binary:!0,tests:["ARROW"],options:{arrow:{shape:"columnar-table"}}};var dp=["geoarrow.multipolygon","geoarrow.polygon","geoarrow.multilinestring","geoarrow.linestring","geoarrow.multipoint","geoarrow.point","geoarrow.wkb","geoarrow.wkt"],pp="ARROW:extension:name",mp="ARROW:extension:metadata";function ec(r){let t={};for(let e of r.fields){let n=yp(e);n&&(t[e.name]=n)}return t}function yp(r){let t=null,e=r.metadata?.[pp];e&&(e=e.toLowerCase(),e==="wkb"&&(e="geoarrow.wkb"),e==="wkt"&&(e="geoarrow.wkt"),dp.includes(e)?(t=t||{},t.encoding=e):console.warn(`Invalid GeoArrow encoding: ${e}`));let n=r.metadata?.[mp];if(n)try{t=JSON.parse(n)}catch(i){console.warn("Failed to parse GeoArrow metadata",i)}return t||null}var Wi={x:0,y:1,z:2};function No(r,t={}){let{start:e=0,end:n=r.length,plane:i="xy"}=t,s=t.size||2,o=0,a=Wi[i[0]],c=Wi[i[1]];for(let l=e,u=n-s;l<n;l+=s)o+=(r[l+a]-r[u+a])*(r[l+c]+r[u+c]),u=l;return o/2}function nc(r,t,e=2,n,i="xy"){let s=t&&t.length,o=s?t[0]*e:r.length,a=Lu(r,0,o,e,!0,n&&n[0],i),c=[];if(!a||a.next===a.prev)return c;let l,u,h,d,p,v,k;if(s&&(a=xp(r,t,a,e,n,i)),r.length>80*e){d=u=r[0],p=h=r[1];for(let Z=e;Z<o;Z+=e)v=r[Z],k=r[Z+1],v<d&&(d=v),k<p&&(p=k),v>u&&(u=v),k>h&&(h=k);l=Math.max(u-d,h-p),l=l!==0?32767/l:0}return Gi(a,c,e,d,p,l,0),c}function Lu(r,t,e,n,i,s,o){let a,c;s===void 0&&(s=No(r,{start:t,end:e,size:n,plane:o}));let l=Wi[o[0]],u=Wi[o[1]];if(i===s<0)for(a=t;a<e;a+=n)c=Mu(a,r[a+l],r[a+u],c);else for(a=e-n;a>=t;a-=n)c=Mu(a,r[a+l],r[a+u],c);return c&&Ro(c,c.next)&&(Hi(c),c=c.next),c}function un(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(Ro(e,e.next)||ct(e.prev,e,e.next)===0)){if(Hi(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Gi(r,t,e,n,i,s,o){if(!r)return;!o&&s&&Dp(r,n,i,s);let a=r,c,l;for(;r.prev!==r.next;){if(c=r.prev,l=r.next,s?_p(r,n,i,s):wp(r)){t.push(c.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),Hi(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=vp(un(r),t,e),Gi(r,t,e,n,i,s,2)):o===2&&Ip(r,t,e,n,i,s):Gi(un(r),t,e,n,i,s,1);break}}}function wp(r){let t=r.prev,e=r,n=r.next;if(ct(t,e,n)>=0)return!1;let i=t.x,s=e.x,o=n.x,a=t.y,c=e.y,l=n.y,u=i<s?i<o?i:o:s<o?s:o,h=a<c?a<l?a:l:c<l?c:l,d=i>s?i>o?i:o:s>o?s:o,p=a>c?a>l?a:l:c>l?c:l,v=n.next;for(;v!==t;){if(v.x>=u&&v.x<=d&&v.y>=h&&v.y<=p&&Gn(i,a,s,c,o,l,v.x,v.y)&&ct(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function _p(r,t,e,n){let i=r.prev,s=r,o=r.next;if(ct(i,s,o)>=0)return!1;let a=i.x,c=s.x,l=o.x,u=i.y,h=s.y,d=o.y,p=a<c?a<l?a:l:c<l?c:l,v=u<h?u<d?u:d:h<d?h:d,k=a>c?a>l?a:l:c>l?c:l,Z=u>h?u>d?u:d:h>d?h:d,et=rc(p,v,t,e,n),pn=rc(k,Z,t,e,n),G=r.prevZ,j=r.nextZ;for(;G&&G.z>=et&&j&&j.z<=pn;){if(G.x>=p&&G.x<=k&&G.y>=v&&G.y<=Z&&G!==i&&G!==o&&Gn(a,u,c,h,l,d,G.x,G.y)&&ct(G.prev,G,G.next)>=0||(G=G.prevZ,j.x>=p&&j.x<=k&&j.y>=v&&j.y<=Z&&j!==i&&j!==o&&Gn(a,u,c,h,l,d,j.x,j.y)&&ct(j.prev,j,j.next)>=0))return!1;j=j.nextZ}for(;G&&G.z>=et;){if(G.x>=p&&G.x<=k&&G.y>=v&&G.y<=Z&&G!==i&&G!==o&&Gn(a,u,c,h,l,d,G.x,G.y)&&ct(G.prev,G,G.next)>=0)return!1;G=G.prevZ}for(;j&&j.z<=pn;){if(j.x>=p&&j.x<=k&&j.y>=v&&j.y<=Z&&j!==i&&j!==o&&Gn(a,u,c,h,l,d,j.x,j.y)&&ct(j.prev,j,j.next)>=0)return!1;j=j.nextZ}return!0}function vp(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!Ro(i,s)&&Nu(i,n,n.next,s)&&$i(i,s)&&$i(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Hi(n),Hi(n.next),n=r=s),n=n.next}while(n!==r);return un(n)}function Ip(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Mp(o,a)){let c=Uu(o,a);o=un(o,o.next),c=un(c,c.next),Gi(o,t,e,n,i,s,0),Gi(c,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function xp(r,t,e,n,i,s){let o=[],a,c,l,u,h;for(a=0,c=t.length;a<c;a++)l=t[a]*n,u=a<c-1?t[a+1]*n:r.length,h=Lu(r,l,u,n,!1,i&&i[a+1],s),h===h.next&&(h.steiner=!0),o.push(Fp(h));for(o.sort(Sp),a=0;a<o.length;a++)e=Bp(o[a],e);return e}function Sp(r,t){return r.x-t.x}function Bp(r,t){let e=Ap(r,t);if(!e)return t;let n=Uu(e,r);return un(n,n.next),un(e,e.next)}function Ap(r,t){let e=t,n=r.x,i=r.y,s=-1/0,o;do{if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){let d=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=n&&d>s&&(s=d,o=e.x<e.next.x?e:e.next,d===n))return o}e=e.next}while(e!==t);if(!o)return null;let a=o,c=o.x,l=o.y,u=1/0,h;e=o;do n>=e.x&&e.x>=c&&n!==e.x&&Gn(i<l?n:s,i,c,l,i<l?s:n,i,e.x,e.y)&&(h=Math.abs(i-e.y)/(n-e.x),$i(e,r)&&(h<u||h===u&&(e.x>o.x||e.x===o.x&&Tp(o,e)))&&(o=e,u=h)),e=e.next;while(e!==a);return o}function Tp(r,t){return ct(r.prev,r,t.prev)<0&&ct(t.next,r,r.next)<0}function Dp(r,t,e,n){let i=r;do i.z===0&&(i.z=rc(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,Op(i)}function Op(r){let t,e,n=1,i,s,o,a,c,l;do{for(s=r,r=null,l=null,i=0;s;){for(i++,a=s,o=0,e=0;e<n&&(o++,a=a.nextZ,!!a);e++);for(c=n;o>0||c>0&&a;)o!==0&&(c===0||!a||s.z<=a.z)?(t=s,s=s.nextZ,o--):(t=a,a=a.nextZ,c--),l?l.nextZ=t:r=t,t.prevZ=l,l=t;s=a}l.nextZ=null,n*=2}while(i>1);return r}function rc(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function Fp(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function Gn(r,t,e,n,i,s,o,a){return(i-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(n-a)}function Mp(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Lp(r,t)&&($i(r,t)&&$i(t,r)&&Np(r,t)&&(ct(r.prev,r,t.prev)||ct(r,t.prev,t))||Ro(r,t)&&ct(r.prev,r,r.next)>0&&ct(t.prev,t,t.next)>0)}function ct(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Ro(r,t){return r.x===t.x&&r.y===t.y}function Nu(r,t,e,n){let i=Eo(ct(r,t,e)),s=Eo(ct(r,t,n)),o=Eo(ct(e,n,r)),a=Eo(ct(e,n,t));return!!(i!==s&&o!==a||i===0&&Uo(r,e,t)||s===0&&Uo(r,n,t)||o===0&&Uo(e,r,n)||a===0&&Uo(e,t,n))}function Uo(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Eo(r){return r>0?1:r<0?-1:0}function Lp(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&Nu(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function $i(r,t){return ct(r.prev,r,r.next)<0?ct(r,t,r.next)>=0&&ct(r,r.prev,t)>=0:ct(r,t,r.prev)<0||ct(r,r.next,t)<0}function Np(r,t){let e=r,n=!1,i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function Uu(r,t){let e=new Yi(r.i,r.x,r.y),n=new Yi(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function Mu(r,t,e,n){let i=new Yi(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Hi(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}var Yi=class{constructor(t,e,n){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=t,this.x=e,this.y=n}};function $n(r,t,e){switch(r.type){case"Point":return kp(r,t,e);case"LineString":return Pp(r,t,e);case"Polygon":return Cu(r,t,e);default:let n=r;throw new Error(`Unsupported geometry type: ${n?.type}`)}}function Cu(r,t=-1/0,e=1/0){let{positions:n}=r,i=r.polygonIndices.value.filter(c=>c>=t&&c<=e),s=r.primitivePolygonIndices.value.filter(c=>c>=t&&c<=e);if(!(i.length>2)){let c=[];for(let l=0;l<s.length-1;l++){let u=s[l],h=s[l+1],d=Co(n,u,h);c.push(d)}return{type:"Polygon",coordinates:c}}let a=[];for(let c=0;c<i.length-1;c++){let l=i[c],u=i[c+1],h=Cu(r,l,u).coordinates;a.push(h)}return{type:"MultiPolygon",coordinates:a}}function Pp(r,t=-1/0,e=1/0){let{positions:n}=r,i=r.pathIndices.value.filter(a=>a>=t&&a<=e);if(!(i.length>2))return{type:"LineString",coordinates:Co(n,i[0],i[1])};let o=[];for(let a=0;a<i.length-1;a++){let c=Co(n,i[a],i[a+1]);o.push(c)}return{type:"MultiLineString",coordinates:o}}function kp(r,t,e){let{positions:n}=r,i=Co(n,t,e);return i.length>1?{type:"MultiPoint",coordinates:i}:{type:"Point",coordinates:i[0]}}function Co(r,t,e){t=t||0,e=e||r.value.length/r.size;let n=[];for(let i=t;i<e;i++){let s=Array();for(let o=i*r.size;o<(i+1)*r.size;o++)s.push(Number(r.value[o]));n.push(s)}return n}function Hn(r){return ic(r)}function Pu(r){return Ki(r)}function ic(r){return{fields:r.fields.map(t=>fn(t)),metadata:Po(r.metadata)}}function Ki(r){return new R(r.fields.map(t=>hn(t)),ko(r.metadata))}function Po(r){return Object.fromEntries(r)}function ko(r){return r?new Map(Object.entries(r)):new Map}function fn(r){return{name:r.name,type:sc(r.type),nullable:r.nullable,metadata:Po(r.metadata)}}function hn(r){return new O(r.name,oc(r.type),r.nullable,ko(r.metadata))}function sc(r){switch(r.constructor){case ut:return"null";case ce:return"binary";case kt:return"bool";case st:let t=r;return`${t.isSigned?"u":""}int${t.bitWidth}`;case Ge:return"int8";case $e:return"int16";case It:return"int32";case pe:return"int64";case He:return"uint8";case Ye:return"uint16";case Ke:return"uint32";case Ze:return"uint64";case At:switch(r.precision){case z.HALF:return"float16";case z.SINGLE:return"float32";case z.DOUBLE:return"float64";default:return"float16"}case Br:return"float16";case me:return"float32";case ye:return"float64";case Pt:return"utf8";case le:let n=r;return{type:"decimal",bitWidth:n.bitWidth,precision:n.precision,scale:n.scale};case Xt:return r.unit===rt.DAY?"date-day":"date-millisecond";case Pr:return"date-day";case cr:return"date-millisecond";case xt:switch(r.unit){case m.SECOND:return"time-second";case m.MILLISECOND:return"time-millisecond";case m.MICROSECOND:return"time-microsecond";case m.NANOSECOND:return"time-nanosecond";default:return"time-second"}case Vr:return"time-millisecond";case kr:return"time-second";case jr:return"time-microsecond";case zr:return"time-nanosecond";case Nt:switch(r.unit){case m.SECOND:return"timestamp-second";case m.MILLISECOND:return"timestamp-millisecond";case m.MICROSECOND:return"timestamp-microsecond";case m.NANOSECOND:return"timestamp-nanosecond";default:return"timestamp-second"}case Wr:return"timestamp-second";case Gr:return"timestamp-millisecond";case $r:return"timestamp-microsecond";case Hr:return"timestamp-nanosecond";case Qt:switch(r.unit){case it.DAY_TIME:return"interval-daytime";case it.YEAR_MONTH:return"interval-yearmonth";default:return"interval-daytime"}case Yr:return"interval-daytime";case Kr:return"interval-yearmonth";case jt:let c=r;return{type:"map",keysSorted:c.keysSorted,children:c.children.map(p=>fn(p))};case Tt:let u=r.valueField;return{type:"list",children:[fn(u)]};case Vt:let h=r;return{type:"fixed-size-list",listSize:h.listSize,children:[fn(h.children[0])]};case V:return{type:"struct",children:r.children.map(p=>fn(p))};default:throw new Error(`arrow type not supported: ${r.constructor.name}`)}}function oc(r){if(typeof r=="object")switch(r.type){case"decimal":return new le(r.precision,r.scale,r.bitWidth);case"map":let t=r.children.map(i=>hn(i));return new jt(t,r.keysSorted);case"list":let e=hn(r.children[0]);return new Tt(e);case"fixed-size-list":let n=hn(r.children[0]);return new Vt(r.listSize,n);case"struct":return t=r.children.map(i=>hn(i)),new V(t);default:throw new Error("array type not supported")}switch(r){case"null":return new ut;case"binary":return new ce;case"bool":return new kt;case"int8":return new Ge;case"int16":return new $e;case"int32":return new It;case"int64":return new pe;case"uint8":return new He;case"uint16":return new Ye;case"uint32":return new Ke;case"uint64":return new Ze;case"float16":return new Br;case"float32":return new me;case"float64":return new ye;case"utf8":return new Pt;case"date-day":return new Pr;case"date-millisecond":return new cr;case"time-second":return new kr;case"time-millisecond":return new Vr;case"time-microsecond":return new jr;case"time-nanosecond":return new zr;case"timestamp-second":return new Wr;case"timestamp-millisecond":return new Gr;case"timestamp-microsecond":return new $r;case"timestamp-nanosecond":return new Hr;case"interval-daytime":return new Yr;case"interval-yearmonth":return new Kr;default:throw new Error("array type not supported")}}var Vo="4.3.0-beta.1";var ku=/[-+]?([0-9]*\.[0-9]+|[0-9]+)([eE][-+]?[0-9]+)?/,Vu=new RegExp("^"+ku.source+"(\\s"+ku.source+"){1,}"),ac=["POINT(","LINESTRING(","POLYGON(","MULTIPOINT(","MULTILINESTRING(","MULTIPOLYGON(","GEOMETRYCOLLECTION("];function ju(r){return ac.some(t=>r.startsWith(t))}function cc(r,t){return Vp(r,t)}function Vp(r,t){let e=r.split(";"),n=e.pop(),i=(e.shift()||"").split("=").pop(),o=zu({parts:e,_:n,i:0});return t?.wkt?.crs?jp(o,i):o}function zu(r){return zp(r)||Gp(r)||Hp(r)||Wp(r)||$p(r)||Yp(r)||Kp(r)}function jp(r,t){if(r&&t?.match(/\d+/)){let e={type:"name",properties:{name:"urn:ogc:def:crs:EPSG::"+t}};r.crs=e}return r}function zp(r){if(!ht(/^(POINT(\sz)?)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;let t=Wu(r);return!t||(Wt(r),!ht(/^(\))/,r))?null:{type:"Point",coordinates:t[0]}}function Wp(r){if(!ht(/^(MULTIPOINT)/i,r))return null;Wt(r);let t=r._?.substring(r._?.indexOf("(")+1,r._.length-1).replace(/\(/g,"").replace(/\)/g,"");r._="MULTIPOINT ("+t+")";let e=jo(r);return e?(Wt(r),{type:"MultiPoint",coordinates:e}):null}function Gp(r){if(!ht(/^(LINESTRING(\sz)?)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;let t=Wu(r);return!t||!ht(/^(\))/,r)?null:{type:"LineString",coordinates:t}}function $p(r){if(!ht(/^(MULTILINESTRING)/i,r))return null;Wt(r);let t=jo(r);return t?(Wt(r),{type:"MultiLineString",coordinates:t}):null}function Hp(r){if(!ht(/^(POLYGON(\sz)?)/i,r))return null;Wt(r);let t=jo(r);return t?{type:"Polygon",coordinates:t}:null}function Yp(r){if(!ht(/^(MULTIPOLYGON)/i,r))return null;Wt(r);let t=jo(r);return t?{type:"MultiPolygon",coordinates:t}:null}function Kp(r){let t=[],e;if(!ht(/^(GEOMETRYCOLLECTION)/i,r)||(Wt(r),!ht(/^(\()/,r)))return null;for(;e=zu(r);)t.push(e),Wt(r),ht(/^(,)/,r),Wt(r);return ht(/^(\))/,r)?{type:"GeometryCollection",geometries:t}:null}function jo(r){Wt(r);let t=0,e=[],n=[e],i=e,s;for(;s=ht(/^(\()/,r)||ht(/^(\))/,r)||ht(/^(,)/,r)||ht(Vu,r);){if(s==="(")n.push(i),i=[],n[n.length-1].push(i),t++;else if(s===")"){if(i.length===0||(i=n.pop(),!i))return null;if(t--,t===0)break}else if(s===",")i=[],n[n.length-1].push(i);else if(!s.split(/\s/g).some(isNaN))Array.prototype.push.apply(i,s.split(/\s/g).map(parseFloat));else return null;Wt(r)}return t!==0?null:e}function Wu(r){let t=[],e,n;for(;n=ht(Vu,r)||ht(/^(,)/,r);)n===","?(t.push(e),e=[]):n.split(/\s/g).some(isNaN)||(e||(e=[]),Array.prototype.push.apply(e,n.split(/\s/g).map(parseFloat))),Wt(r);if(e)t.push(e);else return null;return t.length?t:null}function ht(r,t){let e=t._?.substring(t.i).match(r);return e?(t.i+=e[0].length,e[0]):null}function Wt(r){ht(/^\s*/,r)}var Gu={dataType:null,batchType:null,name:"WKT (Well-Known Text)",id:"wkt",module:"wkt",version:Vo,worker:!0,extensions:["wkt"],mimeTypes:["text/plain"],category:"geometry",text:!0,tests:ac,testText:ju,options:{wkt:{shape:"geojson-geometry",crs:!0}}},lc={...Gu,parse:async(r,t)=>cc(new TextDecoder().decode(r),t),parseTextSync:(r,t)=>cc(r,t)};var _r;(function(r){r[r.Point=1]="Point",r[r.LineString=2]="LineString",r[r.Polygon=3]="Polygon",r[r.MultiPoint=4]="MultiPoint",r[r.MultiLineString=5]="MultiLineString",r[r.MultiPolygon=6]="MultiPolygon",r[r.GeometryCollection=7]="GeometryCollection"})(_r||(_r={}));function $u(r){let t=new DataView(r),e=0,n=t.getUint8(e);if(e+=1,n>1)return!1;let i=n===1,s=t.getUint32(e,i);e+=4;let o=s&7;if(o===0||o>7)return!1;let a=s-o;if(a===0||a===1e3||a===2e3||a===3e3)return!0;if(a&536870911)return!1;if(a&536870912){let c=t.getUint32(e,i);if(e+=4,c>1e4)return!1}return!0}function Hu(r,t){let e=Object.assign(t||{},{type:"wkb",geometryType:1,dimensions:2,coordinates:"xy",littleEndian:!0,byteOffset:0});e.littleEndian=r.getUint8(e.byteOffset)===1,e.byteOffset++;let n=r.getUint32(e.byteOffset,e.littleEndian);e.byteOffset+=4,e.geometryType=n&7;let i=(n-e.geometryType)/1e3;switch(i){case 0:break;case 1:e.type="iso-wkb",e.dimensions=3,e.coordinates="xyz";break;case 2:e.type="iso-wkb",e.dimensions=3,e.coordinates="xym";break;case 3:e.type="iso-wkb",e.dimensions=4,e.coordinates="xyzm";break;default:throw new Error(`WKB: Unsupported iso-wkb type: ${i}`)}let s=n&2147483648,o=n&1073741824,a=n&536870912;return s&&o?(e.type="ewkb",e.dimensions=4,e.coordinates="xyzm"):s?(e.type="ewkb",e.dimensions=3,e.coordinates="xyz"):o&&(e.type="ewkb",e.dimensions=3,e.coordinates="xym"),a&&(e.type="ewkb",e.srid=r.getUint32(e.byteOffset,e.littleEndian),e.byteOffset+=4),e}function uc(r,t){let e=Zp(r,t),n=t?.wkb?.shape||"binary-geometry";switch(n){case"binary-geometry":return e;case"geojson-geometry":return $n(e);case"geometry":return console.error('WKBLoader: "geometry" shape is deprecated, use "binary-geometry" instead'),$n(e);default:throw new Error(n)}}function Zp(r,t){let e=new DataView(r),n=Hu(e),{geometryType:i,dimensions:s,littleEndian:o}=n,a=n.byteOffset;switch(i){case _r.Point:return Yu(e,a,s,o).geometry;case _r.LineString:return fc(e,a,s,o).geometry;case _r.Polygon:return Ku(e,a,s,o).geometry;case _r.MultiPoint:let h=Jp(e,a,s,o);return h.type="Point",h;case _r.MultiLineString:let d=Xp(e,a,s,o);return d.type="LineString",d;case _r.MultiPolygon:let p=Qp(e,a,s,o);return p.type="Polygon",p;default:throw new Error(`WKB: Unsupported geometry type: ${i}`)}}function Yu(r,t,e,n){let i=new Float64Array(e);for(let s=0;s<e;s++)i[s]=r.getFloat64(t,n),t+=8;return{geometry:{type:"Point",positions:{value:i,size:e}},offset:t}}function fc(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=new Float64Array(i*e);for(let a=0;a<i*e;a++)s[a]=r.getFloat64(t,n),t+=8;let o=[0];return i>0&&o.push(i),{geometry:{type:"LineString",positions:{value:s,size:e},pathIndices:{value:new Uint32Array(o),size:1}},offset:t}}var hc=r=>t=>r+=t;function Ku(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let l=0;l<i;l++){let u=fc(r,t,e,n),{positions:h}=u.geometry;t=u.offset,s.push(h.value)}let o=new Float64Array(zo(s).buffer),a=[0];o.length>0&&a.push(o.length/e);let c=s.map(l=>l.length/e).map(hc(0));return c.unshift(0),{geometry:{type:"Polygon",positions:{value:o,size:e},polygonIndices:{value:new Uint32Array(a),size:1},primitivePolygonIndices:{value:new Uint32Array(c),size:1}},offset:t}}function Jp(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let o=0;o<i;o++){let a=r.getUint8(t)===1;if(t++,r.getUint32(t,a)%1e3!==1)throw new Error("WKB: Inner geometries of MultiPoint not of type Point");t+=4;let c=Yu(r,t,e,a);t=c.offset,s.push(c.geometry)}return qp(s,e)}function Xp(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let o=0;o<i;o++){let a=r.getUint8(t)===1;if(t++,r.getUint32(t,a)%1e3!==2)throw new Error("WKB: Inner geometries of MultiLineString not of type LineString");t+=4;let c=fc(r,t,e,a);t=c.offset,s.push(c.geometry)}return tm(s,e)}function Qp(r,t,e,n){let i=r.getUint32(t,n);t+=4;let s=[];for(let o=0;o<i;o++){let a=r.getUint8(t)===1;if(t++,r.getUint32(t,a)%1e3!==3)throw new Error("WKB: Inner geometries of MultiPolygon not of type Polygon");t+=4;let c=Ku(r,t,e,a);t=c.offset,s.push(c.geometry)}return em(s,e)}function qp(r,t){let e=r.map(i=>i.positions.value);return{type:"Point",positions:{value:new Float64Array(zo(e).buffer),size:t}}}function tm(r,t){let e=r.map(s=>s.positions.value),n=new Float64Array(zo(e).buffer),i=e.map(s=>s.length/t).map(hc(0));return i.unshift(0),{type:"LineString",positions:{value:n,size:t},pathIndices:{value:new Uint32Array(i),size:1}}}function em(r,t){let e=[],n=[];for(let a of r){let{positions:c,primitivePolygonIndices:l}=a;e.push(c.value),n.push(l.value)}let i=new Float64Array(zo(e).buffer),s=e.map(a=>a.length/t).map(hc(0));s.unshift(0);let o=[0];for(let a of n)o.push(...a.filter(c=>c>0).map(c=>c+o[o.length-1]));return{type:"Polygon",positions:{value:i,size:t},polygonIndices:{value:new Uint32Array(s),size:1},primitivePolygonIndices:{value:new Uint32Array(o),size:1}}}function zo(r){let t=0;for(let i=0;i<r.length;++i)t+=r[i].byteLength;let e=new Uint8Array(t),n=0;for(let i=0;i<r.length;++i){let s=new Uint8Array(r[i].buffer);t=s.length;for(let o=0;o<t;++o)e[n++]=s[o]}return e}var Zu={dataType:null,batchType:null,name:"WKB",id:"wkb",module:"wkt",version:Vo,worker:!0,category:"geometry",extensions:["wkb"],mimeTypes:[],tests:[$u],options:{wkb:{shape:"binary-geometry"}}},dc={...Zu,parse:async r=>uc(r),parseSync:uc};function Wo(r,t){if(t=t?.toLowerCase(),!t||!r)return null;let e;switch(t){case"geoarrow.multipolygon":e=im(r);break;case"geoarrow.polygon":e=sm(r);break;case"geoarrow.multipoint":e=om(r);break;case"geoarrow.point":e=am(r);break;case"geoarrow.multilinestring":e=cm(r);break;case"geoarrow.linestring":e=lm(r);break;case"geoarrow.wkb":e=rm(r);break;case"geoarrow.wkt":e=nm(r);break;default:throw Error(`GeoArrow encoding not supported ${t}`)}return e}function rm(r){let t=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),e=dc.parseSync?.(t);return $n(e)}function nm(r){let t=r;return lc.parseTextSync?.(t)}function im(r){let t=[];for(let n=0;n<r.length;n++){let i=r.get(n),s=[];for(let o=0;i&&o<i?.length;o++){let a=i?.get(o),c=[];for(let l=0;a&&l<a.length;l++){let u=a.get(l),h=Array.from(u);c.push(h)}s.push(c)}t.push(s)}return{type:"MultiPolygon",coordinates:t}}function sm(r){let t=[];for(let n=0;r&&n<r.length;n++){let i=r.get(n),s=[];for(let o=0;i&&o<i.length;o++){let a=i.get(o),c=Array.from(a);s.push(c)}t.push(s)}return{type:"Polygon",coordinates:t}}function om(r){let t=[];for(let e=0;r&&e<r.length;e++){let n=r.get(e);if(n){let i=Array.from(n);t.push(i)}}return{type:"MultiPoint",coordinates:t}}function am(r){return{type:"Point",coordinates:Array.from(r)}}function cm(r){let t=[];for(let e=0;r&&e<r.length;e++){let n=r.get(e),i=[];for(let s=0;n&&s<n.length;s++){let o=n.get(s);if(o){let a=Array.from(o);i.push(a)}}t.push(i)}return{type:"MultiLineString",coordinates:t}}function lm(r){let t=[];for(let e=0;r&&e<r.length;e++){let n=r.get(e);if(n){let i=Array.from(n);t.push(i)}}return{type:"LineString",coordinates:t}}function Yn(r,t){switch(t){case"arrow-table":return um(r);case"array-row-table":return fm(r);case"object-row-table":return hm(r);case"columnar-table":return pc(r);case"geojson-table":return dm(r);default:throw new Error(t)}}function um(r){return{shape:"arrow-table",schema:Hn(r.schema),data:r}}function fm(r){let t=pc(r);return ls(t,"array-row-table")}function hm(r){let t=pc(r);return ls(t,"object-row-table")}function pc(r){let t={};for(let n of r.schema.fields){let s=r.getChild(n.name)?.toArray();t[n.name]=s}return{shape:"columnar-table",schema:Hn(r.schema),data:t}}function dm(r){let t=Hn(r.schema),e=ec(t),n=e.geometry.encoding,i=[],s=r.schema.fields.map(c=>c.name).filter(c=>!(c in e)),o=r.select(s),a=r.getChild("geometry");for(let c=0;c<r.numRows;c++){let l=a?.get(c),u=Wo(l,n);if(u){let h=o.get(c)?.toJSON()||{};i.push({type:"Feature",geometry:u,properties:h})}}return{shape:"geojson-table",type:"FeatureCollection",schema:t,features:i}}function Zi(r,t){let e=t?.shape||"arrow-table",n=zi([new Uint8Array(r)]);return Yn(n,e)}function Go(r,t){async function*e(){let n=gt.readAll(r);for await(let i of n){for await(let s of i)t?.arrow?.batchDebounceMs!==void 0&&t?.arrow?.batchDebounceMs>0&&await new Promise(a=>setTimeout(a,t.arrow?.batchDebounceMs||0)),yield{shape:"arrow-table",batchType:"data",data:new K([s]),length:s.data.length};break}}return e()}var Ju={...Wn,parse:async(r,t)=>Zi(r,t?.arrow),parseSync:(r,t)=>Zi(r,t?.arrow),parseInBatches:Go};function mc(r){let t={};for(let i of r){let s=pm(i.array,i.type);t[i.name]=s}let e=new K(t);return Mo(e)}function pm(r,t){switch(t){case Ur.DATE:return Pi(r);case Ur.FLOAT:default:return Pi(r)}}var mm="4.3.0-beta.1",Xu={name:"Apache Arrow",id:"arrow",module:"arrow",version:mm,extensions:["arrow","feather"],mimeTypes:["application/vnd.apache.arrow.file","application/vnd.apache.arrow.stream","application/octet-stream"],binary:!0,options:{},encode:async function(t,e){return mc(t)},encodeSync(r,t){return mc(r)}};var $o={...Wn,options:{arrow:{shape:"arrow-table"}}};function yc(r,t){let e=Zi(r,{shape:"arrow-table"});switch(t?.shape){case"geojson-table":return Yn(e.data,"geojson-table");default:return e}}function Qu(r){return Go(r)}var qu={...$o,parse:async(r,t)=>yc(r,t?.arrow),parseSync:(r,t)=>yc(r,t?.arrow),parseInBatches:Qu};function tf(r,t){switch(r.shape){case"arrow-table":return r.data;case"columnar-table":default:let e=ym(r,t);return new K(e)}}function*ym(r,t){let e=Ki(r.schema),n=xr(r),i=Jo(r),s=t?.batchSize||n,o=e?.fields.map(l=>Me(l)),a=new V(e.fields),c=0;for(let l=0;l<n;l++)for(let u=0;u<i;++u){let h=Qo(r,l,u);if(o[u].append(h),c++,c>=s){let p=o.map(k=>k.flush()),v=new U(a,0,c,0,void 0,p);yield new W(e,v),c=0}}if(c>0){let l=o.map(h=>h.flush()),u=new U(a,0,c,0,void 0,l);yield new W(e,u),c=0}o.map(l=>l.finish())}function Ho(r,t,e,n=100){let i=r.length/t,s=Math.max(Math.floor(i/n),1),o=[...e];for(let a=0;a<i;a+=s){let c=r[a*t],l=r[a*t+1];c<o[0]&&(o[0]=c),l<o[1]&&(o[1]=l),c>o[2]&&(o[2]=c),l>o[3]&&(o[3]=l)}return o}var Kn;(function(r){r.points="points",r.lines="lines",r.polygons="polygons"})(Kn||(Kn={}));function Ji(){return{globalFeatureIds:{value:new Uint32Array(0),size:1},positions:{value:new Float32Array(0),size:2},properties:[],numericProps:{},featureIds:{value:new Uint32Array(0),size:1}}}function ef(r,t,e){let n={polygon:t==="geoarrow.multipolygon"||t==="geoarrow.polygon",point:t==="geoarrow.multipoint"||t==="geoarrow.point",line:t==="geoarrow.multilinestring"||t==="geoarrow.linestring"},i=e?.chunkIndex!==void 0&&e?.chunkIndex>=0?[r.data[e?.chunkIndex]]:r.data,s=[1/0,1/0,-1/0,-1/0],o=e?.chunkOffset||0,a=[];return i.forEach(c=>{let{featureIds:l,flatCoordinateArray:u,nDim:h,geomOffset:d,triangles:p}=bm(c,t,e),v=new Uint32Array(l.length);for(let Z=0;Z<l.length;Z++)v[Z]=l[Z]+o;let k={globalFeatureIds:{value:v,size:1},positions:{value:u,size:h},featureIds:{value:l,size:1},properties:[...Array(c.length).keys()].map(Z=>({index:Z+o}))};o+=c.length,a.push({shape:"binary-feature-collection",points:{type:"Point",...Ji(),...n.point?k:{}},lines:{type:"LineString",...Ji(),...n.line?k:{},pathIndices:{value:n.line?d:new Uint16Array(0),size:1}},polygons:{type:"Polygon",...Ji(),...n.polygon?k:{},polygonIndices:{value:n.polygon?d:new Uint16Array(0),size:1},primitivePolygonIndices:{value:n.polygon?d:new Uint16Array(0),size:1},...p?{triangles:{value:p,size:1}}:{}}}),s=Ho(u,h,s)}),{binaryGeometries:a,bounds:s,featureTypes:n,...e?.calculateMeanCenters?{meanCenters:gc(a)}:{}}}function gc(r){let t=[];return r.forEach(e=>{let n=null;e.points&&e.points.positions.value.length>0?n=Kn.points:e.lines&&e.lines.positions.value.length>0?n=Kn.lines:e.polygons&&e.polygons.positions.value.length>0&&(n=Kn.polygons);let i=n?e[n]:null;if(i&&n!==null){let s=i.featureIds.value,o=i.positions.value,a=i.positions.size,c=i.type==="Polygon"?i.primitivePolygonIndices?.value:void 0;gm(s,o,a,n,c).forEach(u=>{t.push(u)})}}),t}function gm(r,t,e,n,i){let s=[],o=t.length,a=0,c=0,l=0;for(;a<o;){let u=r[a/e],h=[0,0],d=0;for(;a<o&&r[c]===u;)n===Kn.polygons&&i?.[l]===c?(a+=e,l++):(h[0]+=t[a],h[1]+=t[a+1],a+=e,d++),c+=1;h[0]/=d,h[1]/=d,s.push(h)}return s}function bm(r,t,e){switch(t){case"geoarrow.point":case"geoarrow.multipoint":return vm(r,t);case"geoarrow.linestring":case"geoarrow.multilinestring":return _m(r,t);case"geoarrow.polygon":case"geoarrow.multipolygon":return wm(r,t,e);default:throw Error("invalid geoarrow encoding")}}function bc(r,t,e,n){try{let i=0,s=[];for(let a=0;a<r.length-1;a++){let c=r[a],l=r[a+1],u=e.subarray(c*n,l*n),h=[];for(;t[i]<l;)t[i]>c&&h.push(t[i]-c),i++;let d=nc(u,h.length>0?h:void 0,n);if(d.length===0)throw Error("earcut failed e.g. invalid polygon");for(let p=0;p<d.length;p++)s.push(d[p]+c)}let o=new Uint32Array(s.length);for(let a=0;a<s.length;a++)o[a]=s[a];return o}catch{return null}}function wm(r,t,e){let n=t==="geoarrow.multipolygon",i=n?r.children[0]:r,s=i.valueOffsets,o=n?r.valueOffsets.map(et=>s.at(et)||et):r.valueOffsets,a=i.children[0],c=a.children[0],l=c.children[0],u=c.stride,h=a.valueOffsets,d=l.values,p=new Uint16Array(s.length);for(let et=0;et<s.length;et++)p[et]=h[s[et]];let v=d.length/u,k=new Uint32Array(v);for(let et=0;et<o.length-1;et++){let pn=h[o[et]],G=h[o[et+1]];for(let j=pn;j<G;j++)k[j]=et}let Z=e?.triangulate?bc(p,h,d,u):null;return{featureIds:k,nDim:u,flatCoordinateArray:d,geomOffset:h,geometryIndicies:p,...e?.triangulate&&Z?{triangles:Z}:{}}}function _m(r,t){let e=t==="geoarrow.multilinestring",n=e?r.children[0]:r,i=n.children[0],s=i.children[0],o=i.stride,a=n.valueOffsets,c=s.values,l=new Uint16Array(0),u=c.length/o,h=new Uint32Array(u);if(e){let d=r.valueOffsets;for(let p=0;p<d.length-1;p++){let v=a[d[p]],k=a[d[p+1]];for(let Z=v;Z<k;Z++)h[Z]=p}}else for(let d=0;d<r.length;d++){let p=a[d],v=a[d+1];for(let k=p;k<v;k++)h[k]=d}return{featureIds:h,flatCoordinateArray:c,nDim:o,geomOffset:a,geometryIndicies:l}}function vm(r,t){let e=t==="geoarrow.multipoint",n=e?r.children[0]:r,i=n.children[0],s=n.stride,o=i.values,a=new Uint16Array(0),c=new Int32Array(0),l=o.length/s,u=new Uint32Array(l);if(e){let h=r.valueOffsets;for(let d=0;d<h.length-1;d++){let p=h[d],v=h[d+1];for(let k=p;k<v;k++)u[k]=d}}else for(let h=0;h<r.length;h++)u[h]=h;return{featureIds:u,flatCoordinateArray:o,nDim:s,geomOffset:c,geometryIndicies:a}}function Xi(r,t=!1){if("data"in r)return new b(r.data.map(s=>Xi(s,t)));let e=[];for(let s of r.children)e.push(Xi(s,t));let n;r.dictionary!==void 0&&(n=Xi(r.dictionary,t));let i={[lt.OFFSET]:Yo(r.buffers[lt.OFFSET],t),[lt.DATA]:Yo(r.buffers[lt.DATA],t),[lt.VALIDITY]:Yo(r.buffers[lt.VALIDITY],t),[lt.TYPE]:Yo(r.buffers[lt.TYPE],t)};return new U(r.type,r.offset,r.length,r._nullCount,i,e,n)}function Im(r){return!(r.byteOffset===0&&r.byteLength===r.buffer.byteLength)}function Yo(r,t){return r===void 0||!t&&!Im(r)?r:r.slice()}var rf="latest";function xm(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.0-beta.1"),globalThis._loadersgl_.version}var wc=xm();function sr(r,t){if(!r)throw new Error(t||"loaders.gl assertion failed.")}var or={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},lA=or.self||or.window||or.global||{},uA=or.window||or.self||or.global||{},fA=or.global||or.self||or.window||{},hA=or.document||{};var vr=typeof process!="object"||String(process)!=="[object process]"||process.browser;var sf=typeof window<"u"&&typeof window.orientation<"u",nf=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),dA=nf&&parseFloat(nf[1])||0;var Qi=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(t,e){this.name=t,this.workerThread=e,this.result=new Promise((n,i)=>{this._resolve=n,this._reject=i})}postMessage(t,e){this.workerThread.postMessage({source:"loaders.gl",type:t,payload:e})}done(t){sr(this.isRunning),this.isRunning=!1,this._resolve(t)}error(t){sr(this.isRunning),this.isRunning=!1,this._reject(t)}};var Zn=class{terminate(){}};var _c=new Map;function of(r){sr(r.source&&!r.url||!r.source&&r.url);let t=_c.get(r.source||r.url);return t||(r.url&&(t=Sm(r.url),_c.set(r.url,t)),r.source&&(t=af(r.source),_c.set(r.source,t))),sr(t),t}function Sm(r){if(!r.startsWith("http"))return r;let t=Bm(r);return af(t)}function af(r){let t=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(t)}function Bm(r){return`try {
17
17
  importScripts('${r}');
18
18
  } catch (error) {
19
19
  console.error(error);
20
20
  throw error;
21
- }`}function dc(r,t=!0,e){let n=e||new Set;if(r){if(ef(r))n.add(r);else if(ef(r.buffer))n.add(r.buffer);else if(!ArrayBuffer.isView(r)){if(t&&typeof r=="object")for(let i in r)dc(r[i],t,n)}}return e===void 0?Array.from(n):[]}function ef(r){return r?r instanceof ArrayBuffer||typeof MessagePort<"u"&&r instanceof MessagePort||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas:!1}function pc(r){if(r===null)return{};let t=Object.assign({},r);return Object.keys(t).forEach(e=>{typeof r[e]=="object"&&!ArrayBuffer.isView(r[e])&&!(r[e]instanceof Array)?t[e]=pc(r[e]):typeof t[e]=="function"||t[e]instanceof RegExp?t[e]={}:t[e]=r[e]}),t}var mc=()=>{},Lr=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&vr||typeof Hn<"u"&&!vr}constructor(t){let{name:e,source:n,url:i}=t;ir(n||i),this.name=e,this.source=n,this.url=i,this.onMessage=mc,this.onError=s=>console.log(s),this.worker=vr?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=mc,this.onError=mc,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(t,e){e=e||dc(t),this.worker.postMessage(t,e)}_getErrorFromErrorEvent(t){let e="Failed to load ";return e+=`worker ${this.name} from ${this.url}. `,t.message&&(e+=`${t.message} in `),t.lineno&&(e+=`:${t.lineno}:${t.colno}`),new Error(e)}_createBrowserWorker(){this._loadableURL=qu({source:this.source,url:this.url});let t=new Worker(this._loadableURL,{name:this.name});return t.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},t.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},t.onmessageerror=e=>console.error(e),t}_createNodeWorker(){let t;if(this.url){let n=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;t=new Hn(n,{eval:!1})}else if(this.source)t=new Hn(this.source,{eval:!0});else throw new Error("no worker");return t.on("message",e=>{this.onMessage(e)}),t.on("error",e=>{this.onError(e)}),t.on("exit",e=>{}),t}};var Ji=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return Lr.isSupported()}constructor(t){this.source=t.source,this.url=t.url,this.setProps(t)}destroy(){this.idleQueue.forEach(t=>t.destroy()),this.isDestroyed=!0}setProps(t){this.props={...this.props,...t},t.name!==void 0&&(this.name=t.name),t.maxConcurrency!==void 0&&(this.maxConcurrency=t.maxConcurrency),t.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=t.maxMobileConcurrency),t.reuseWorkers!==void 0&&(this.reuseWorkers=t.reuseWorkers),t.onDebug!==void 0&&(this.onDebug=t.onDebug)}async startJob(t,e=(i,s,o)=>i.done(o),n=(i,s)=>i.error(s)){let i=new Promise(s=>(this.jobQueue.push({name:t,onMessage:e,onError:n,onStart:s}),this));return this._startQueuedJob(),await i}async _startQueuedJob(){if(!this.jobQueue.length)return;let t=this._getAvailableWorker();if(!t)return;let e=this.jobQueue.shift();if(e){this.onDebug({message:"Starting job",name:e.name,workerThread:t,backlog:this.jobQueue.length});let n=new Zi(e.name,t);t.onMessage=i=>e.onMessage(n,i.type,i.payload),t.onError=i=>e.onError(n,i),e.onStart(n);try{await n.result}catch(i){console.error(`Worker exception: ${i}`)}finally{this.returnWorkerToQueue(t)}}}returnWorkerToQueue(t){!vr||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(t.destroy(),this.count--):this.idleQueue.push(t),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;let t=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new Lr({name:t,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return Qu?this.maxMobileConcurrency:this.maxConcurrency}};var ym={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},dn=class{props;workerPools=new Map;static isSupported(){return Lr.isSupported()}static getWorkerFarm(t={}){return dn._workerFarm=dn._workerFarm||new dn({}),dn._workerFarm.setProps(t),dn._workerFarm}constructor(t){this.props={...ym},this.setProps(t),this.workerPools=new Map}destroy(){for(let t of this.workerPools.values())t.destroy();this.workerPools=new Map}setProps(t){this.props={...this.props,...t};for(let e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(t){let{name:e,source:n,url:i}=t,s=this.workerPools.get(e);return s||(s=new Ji({name:e,source:n,url:i}),s.setProps(this._getWorkerPoolProps()),this.workerPools.set(e,s)),s}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},Yn=dn;ts(Yn,"_workerFarm");function rf(r){let t=r.version!==fc?` (worker-utils@${fc})`:"";return`${r.name}@${r.version}${t}`}function nf(r,t={}){let e=t[r.id]||{},n=vr?`${r.id}-worker.js`:`${r.id}-worker-node.js`,i=e.workerUrl;if(!i&&r.id==="compression"&&(i=t.workerUrl),t._workerType==="test"&&(vr?i=`modules/${r.module}/dist/${n}`:i=`modules/${r.module}/src/workers/${r.id}-worker-node.ts`),!i){let s=r.version;s==="latest"&&(s=Ju);let o=s?`@${s}`:"";i=`https://unpkg.com/@loaders.gl/${r.module}${o}/dist/${n}`}return ir(i),i}async function Ho(r,t,e={},n={}){let i=rf(r),s=Yn.getWorkerFarm(e),{source:o}=e,a={name:i,source:o};o||(a.url=nf(r,e));let c=s.getWorkerPool(a),l=e.jobName||r.name,u=await c.startJob(l,gm.bind(null,n)),h=pc(e);return u.postMessage("process",{input:t,options:h}),(await u.result).result}async function gm(r,t,e,n){switch(e){case"done":t.done(n);break;case"error":t.error(new Error(n.error));break;case"process":let{id:i,input:s,options:o}=n;try{if(!r.process){t.postMessage("error",{id:i,error:"Worker not set up to process on main thread"});return}let a=await r.process(s,o);t.postMessage("done",{id:i,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";t.postMessage("error",{id:i,error:c})}break;default:console.warn(`process-on-worker: unknown message ${e}`)}}var bm="4.3.0-alpha.7",Yo={id:"triangulation",name:"Triangulate",module:"arrow",version:bm,options:{}};function sf(r,t={}){return Ho(Yo,{...r,operation:"triangulate"},t)}function of(r,t={}){return Ho(Yo,{...r,operation:"parse-geoarrow"},t)}mn.ArrowBatch=Oo;return mf(Xi);})();
21
+ }`}function vc(r,t=!0,e){let n=e||new Set;if(r){if(cf(r))n.add(r);else if(cf(r.buffer))n.add(r.buffer);else if(!ArrayBuffer.isView(r)){if(t&&typeof r=="object")for(let i in r)vc(r[i],t,n)}}return e===void 0?Array.from(n):[]}function cf(r){return r?r instanceof ArrayBuffer||typeof MessagePort<"u"&&r instanceof MessagePort||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas:!1}function Ic(r){if(r===null)return{};let t=Object.assign({},r);return Object.keys(t).forEach(e=>{typeof r[e]=="object"&&!ArrayBuffer.isView(r[e])&&!(r[e]instanceof Array)?t[e]=Ic(r[e]):typeof t[e]=="function"||t[e]instanceof RegExp?t[e]={}:t[e]=r[e]}),t}var xc=()=>{},Nr=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&vr||typeof Zn<"u"&&!vr}constructor(t){let{name:e,source:n,url:i}=t;sr(n||i),this.name=e,this.source=n,this.url=i,this.onMessage=xc,this.onError=s=>console.log(s),this.worker=vr?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=xc,this.onError=xc,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(t,e){e=e||vc(t),this.worker.postMessage(t,e)}_getErrorFromErrorEvent(t){let e="Failed to load ";return e+=`worker ${this.name} from ${this.url}. `,t.message&&(e+=`${t.message} in `),t.lineno&&(e+=`:${t.lineno}:${t.colno}`),new Error(e)}_createBrowserWorker(){this._loadableURL=of({source:this.source,url:this.url});let t=new Worker(this._loadableURL,{name:this.name});return t.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},t.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},t.onmessageerror=e=>console.error(e),t}_createNodeWorker(){let t;if(this.url){let n=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;t=new Zn(n,{eval:!1})}else if(this.source)t=new Zn(this.source,{eval:!0});else throw new Error("no worker");return t.on("message",e=>{this.onMessage(e)}),t.on("error",e=>{this.onError(e)}),t.on("exit",e=>{}),t}};var qi=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return Nr.isSupported()}constructor(t){this.source=t.source,this.url=t.url,this.setProps(t)}destroy(){this.idleQueue.forEach(t=>t.destroy()),this.isDestroyed=!0}setProps(t){this.props={...this.props,...t},t.name!==void 0&&(this.name=t.name),t.maxConcurrency!==void 0&&(this.maxConcurrency=t.maxConcurrency),t.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=t.maxMobileConcurrency),t.reuseWorkers!==void 0&&(this.reuseWorkers=t.reuseWorkers),t.onDebug!==void 0&&(this.onDebug=t.onDebug)}async startJob(t,e=(i,s,o)=>i.done(o),n=(i,s)=>i.error(s)){let i=new Promise(s=>(this.jobQueue.push({name:t,onMessage:e,onError:n,onStart:s}),this));return this._startQueuedJob(),await i}async _startQueuedJob(){if(!this.jobQueue.length)return;let t=this._getAvailableWorker();if(!t)return;let e=this.jobQueue.shift();if(e){this.onDebug({message:"Starting job",name:e.name,workerThread:t,backlog:this.jobQueue.length});let n=new Qi(e.name,t);t.onMessage=i=>e.onMessage(n,i.type,i.payload),t.onError=i=>e.onError(n,i),e.onStart(n);try{await n.result}catch(i){console.error(`Worker exception: ${i}`)}finally{this.returnWorkerToQueue(t)}}}returnWorkerToQueue(t){!vr||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(t.destroy(),this.count--):this.idleQueue.push(t),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;let t=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new Nr({name:t,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return sf?this.maxMobileConcurrency:this.maxConcurrency}};var Am={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},dn=class{props;workerPools=new Map;static isSupported(){return Nr.isSupported()}static getWorkerFarm(t={}){return dn._workerFarm=dn._workerFarm||new dn({}),dn._workerFarm.setProps(t),dn._workerFarm}constructor(t){this.props={...Am},this.setProps(t),this.workerPools=new Map}destroy(){for(let t of this.workerPools.values())t.destroy();this.workerPools=new Map}setProps(t){this.props={...this.props,...t};for(let e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(t){let{name:e,source:n,url:i}=t,s=this.workerPools.get(e);return s||(s=new qi({name:e,source:n,url:i}),s.setProps(this._getWorkerPoolProps()),this.workerPools.set(e,s)),s}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},Jn=dn;ns(Jn,"_workerFarm");function lf(r){let t=r.version!==wc?` (worker-utils@${wc})`:"";return`${r.name}@${r.version}${t}`}function uf(r,t={}){let e=t[r.id]||{},n=vr?`${r.id}-worker.js`:`${r.id}-worker-node.js`,i=e.workerUrl;if(!i&&r.id==="compression"&&(i=t.workerUrl),t._workerType==="test"&&(vr?i=`modules/${r.module}/dist/${n}`:i=`modules/${r.module}/src/workers/${r.id}-worker-node.ts`),!i){let s=r.version;s==="latest"&&(s=rf);let o=s?`@${s}`:"";i=`https://unpkg.com/@loaders.gl/${r.module}${o}/dist/${n}`}return sr(i),i}async function Ko(r,t,e={},n={}){let i=lf(r),s=Jn.getWorkerFarm(e),{source:o}=e,a={name:i,source:o};o||(a.url=uf(r,e));let c=s.getWorkerPool(a),l=e.jobName||r.name,u=await c.startJob(l,Tm.bind(null,n)),h=Ic(e);return u.postMessage("process",{input:t,options:h}),(await u.result).result}async function Tm(r,t,e,n){switch(e){case"done":t.done(n);break;case"error":t.error(new Error(n.error));break;case"process":let{id:i,input:s,options:o}=n;try{if(!r.process){t.postMessage("error",{id:i,error:"Worker not set up to process on main thread"});return}let a=await r.process(s,o);t.postMessage("done",{id:i,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";t.postMessage("error",{id:i,error:c})}break;default:console.warn(`process-on-worker: unknown message ${e}`)}}var Dm="4.3.0-beta.1",Zo={id:"triangulation",name:"Triangulate",module:"arrow",version:Dm,options:{}};function ff(r,t={}){return Ko(Zo,{...r,operation:"triangulate"},t)}function hf(r,t={}){return Ko(Zo,{...r,operation:"parse-geoarrow"},t)}mn.ArrowBatch=Lo;return vf(ts);})();
22
22
  return __exports__;
23
23
  });