@loaders.gl/json 4.4.0-alpha.2 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/dist.dev.js +3338 -2755
  2. package/dist/dist.min.js +11 -11
  3. package/dist/geojson-loader.d.ts.map +1 -1
  4. package/dist/geojson-loader.js +4 -2
  5. package/dist/geojson-loader.js.map +1 -0
  6. package/dist/geojson-worker.js +3312 -2748
  7. package/dist/geojson-writer.js +1 -0
  8. package/dist/geojson-writer.js.map +1 -0
  9. package/dist/index.cjs +222 -30
  10. package/dist/index.cjs.map +4 -4
  11. package/dist/index.js +1 -0
  12. package/dist/index.js.map +1 -0
  13. package/dist/json-loader.js +2 -1
  14. package/dist/json-loader.js.map +1 -0
  15. package/dist/json-writer.d.ts +1 -1
  16. package/dist/json-writer.js +1 -0
  17. package/dist/json-writer.js.map +1 -0
  18. package/dist/lib/clarinet/clarinet.js +1 -0
  19. package/dist/lib/clarinet/clarinet.js.map +1 -0
  20. package/dist/lib/encoder-utils/encode-table-row.js +1 -0
  21. package/dist/lib/encoder-utils/encode-table-row.js.map +1 -0
  22. package/dist/lib/encoder-utils/encode-utils.js +1 -0
  23. package/dist/lib/encoder-utils/encode-utils.js.map +1 -0
  24. package/dist/lib/encoder-utils/utf8-encoder.d.ts +1 -1
  25. package/dist/lib/encoder-utils/utf8-encoder.d.ts.map +1 -1
  26. package/dist/lib/encoder-utils/utf8-encoder.js +3 -1
  27. package/dist/lib/encoder-utils/utf8-encoder.js.map +1 -0
  28. package/dist/lib/encoders/geojson-encoder.js +1 -0
  29. package/dist/lib/encoders/geojson-encoder.js.map +1 -0
  30. package/dist/lib/encoders/json-encoder.js +1 -0
  31. package/dist/lib/encoders/json-encoder.js.map +1 -0
  32. package/dist/lib/json-parser/json-parser.js +1 -0
  33. package/dist/lib/json-parser/json-parser.js.map +1 -0
  34. package/dist/lib/json-parser/streaming-json-parser.js +1 -0
  35. package/dist/lib/json-parser/streaming-json-parser.js.map +1 -0
  36. package/dist/lib/jsonpath/jsonpath.d.ts.map +1 -1
  37. package/dist/lib/jsonpath/jsonpath.js +213 -18
  38. package/dist/lib/jsonpath/jsonpath.js.map +1 -0
  39. package/dist/lib/parsers/parse-json-in-batches.d.ts +1 -1
  40. package/dist/lib/parsers/parse-json-in-batches.d.ts.map +1 -1
  41. package/dist/lib/parsers/parse-json-in-batches.js +5 -4
  42. package/dist/lib/parsers/parse-json-in-batches.js.map +1 -0
  43. package/dist/lib/parsers/parse-json.js +1 -0
  44. package/dist/lib/parsers/parse-json.js.map +1 -0
  45. package/dist/lib/parsers/parse-ndjson-in-batches.d.ts +1 -1
  46. package/dist/lib/parsers/parse-ndjson-in-batches.d.ts.map +1 -1
  47. package/dist/lib/parsers/parse-ndjson-in-batches.js +4 -3
  48. package/dist/lib/parsers/parse-ndjson-in-batches.js.map +1 -0
  49. package/dist/lib/parsers/parse-ndjson.js +1 -0
  50. package/dist/lib/parsers/parse-ndjson.js.map +1 -0
  51. package/dist/ndgeoson-loader.js +2 -1
  52. package/dist/ndgeoson-loader.js.map +1 -0
  53. package/dist/ndjson-loader.js +2 -1
  54. package/dist/ndjson-loader.js.map +1 -0
  55. package/dist/workers/geojson-worker.js +1 -0
  56. package/dist/workers/geojson-worker.js.map +1 -0
  57. package/package.json +9 -6
  58. package/src/geojson-loader.ts +2 -1
  59. package/src/json-loader.ts +3 -1
  60. package/src/lib/encoder-utils/utf8-encoder.ts +4 -2
  61. package/src/lib/jsonpath/jsonpath.ts +268 -21
  62. package/src/lib/parsers/parse-json-in-batches.ts +7 -5
  63. package/src/lib/parsers/parse-ndjson-in-batches.ts +7 -4
package/dist/dist.min.js CHANGED
@@ -4,27 +4,27 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['loaders'] = factory();
6
6
  else root['loaders'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var hu=Object.create;var Ln=Object.defineProperty;var fu=Object.getOwnPropertyDescriptor;var du=Object.getOwnPropertyNames;var pu=Object.getPrototypeOf,mu=Object.prototype.hasOwnProperty;var yu=(r,t,e)=>t in r?Ln(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var gu=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ur=(r,t)=>{for(var e in t)Ln(r,e,{get:t[e],enumerable:!0})},Mi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of du(t))!mu.call(r,i)&&i!==e&&Ln(r,i,{get:()=>t[i],enumerable:!(n=fu(t,i))||n.enumerable});return r},Ei=(r,t,e)=>(Mi(r,t,"default"),e&&Mi(e,t,"default")),bu=(r,t,e)=>(e=r!=null?hu(pu(r)):{},Mi(t||!r||!r.__esModule?Ln(e,"default",{value:r,enumerable:!0}):e,r)),_u=r=>Mi(Ln({},"__esModule",{value:!0}),r);var La=(r,t,e)=>(yu(r,typeof t!="symbol"?t+"":t,e),e);var Ma=gu((rp,Ua)=>{Ua.exports=globalThis.loaders});var Ui={};ur(Ui,{JSONLoader:()=>lo,JSONWriter:()=>Yl,NDJSONLoader:()=>Hl,_ClarinetParser:()=>Xr,_GeoJSONLoader:()=>Nn,_GeoJSONWorkerLoader:()=>Ta,_GeoJSONWriter:()=>uu,_JSONPath:()=>Dt,_rebuildJsonObject:()=>Gl});Ei(Ui,bu(Ma(),1));function Ci(r,t="float32"){return r instanceof Date?"date-millisecond":r instanceof Number?t:typeof r=="string"?"utf8":(r===null||r==="undefined","null")}function Ea(r){let t=wu(r);return t!=="null"?{type:t,nullable:!1}:r.length>0?(t=Ci(r[0]),{type:t,nullable:!0}):{type:"null",nullable:!0}}function wu(r){switch(r.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function Ca(r,t){if(!t)switch(r){case"int8":return Int8Array;case"uint8":return Uint8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;default:break}return Array}function Pa(r,t){var e={};for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(r);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(r,n[i])&&(e[n[i]]=r[n[i]]);return e}function y(r,t,e,n){function i(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(u){try{l(n.next(u))}catch(f){o(f)}}function c(u){try{l(n.throw(u))}catch(f){o(f)}}function l(u){u.done?s(u.value):i(u.value).then(a,c)}l((n=n.apply(r,t||[])).next())})}function Ra(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],n=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function C(r){return this instanceof C?(this.v=r,this):new C(r)}function Ht(r,t,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(r,t||[]),i,s=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),a("next"),a("throw"),a("return",o),i[Symbol.asyncIterator]=function(){return this},i;function o(p){return function(g){return Promise.resolve(g).then(p,f)}}function a(p,g){n[p]&&(i[p]=function(G){return new Promise(function(nt,Ft){s.push([p,G,nt,Ft])>1||c(p,G)})},g&&(i[p]=g(i[p])))}function c(p,g){try{l(n[p](g))}catch(G){d(s[0][3],G)}}function l(p){p.value instanceof C?Promise.resolve(p.value.v).then(u,f):d(s[0][2],p)}function u(p){c("next",p)}function f(p){c("throw",p)}function d(p,g){p(g),s.shift(),s.length&&c(s[0][0],s[0][1])}}function Qr(r){var t,e;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=r[i]?function(o){return(e=!e)?{value:C(r[i](o)),done:!1}:s?s(o):o}:s}}function ce(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=r[Symbol.asyncIterator],e;return t?t.call(r):(r=typeof Ra=="function"?Ra(r):r[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(s){e[s]=r[s]&&function(o){return new Promise(function(a,c){o=r[s](o),i(a,c,o.done,o.value)})}}function i(s,o,a,c){Promise.resolve(c).then(function(l){s({value:l,done:a})},o)}}var wo={};ur(wo,{compareArrayLike:()=>_o,joinUint8Arrays:()=>Yt,memcpy:()=>En,rebaseValueOffsets:()=>Gi,toArrayBufferView:()=>R,toArrayBufferViewAsyncIterator:()=>he,toArrayBufferViewIterator:()=>Ie,toBigInt64Array:()=>Wi,toBigUint64Array:()=>Fu,toFloat32Array:()=>Tu,toFloat32ArrayAsyncIterator:()=>$u,toFloat32ArrayIterator:()=>Pu,toFloat64Array:()=>Nu,toFloat64ArrayAsyncIterator:()=>Hu,toFloat64ArrayIterator:()=>ju,toInt16Array:()=>Au,toInt16ArrayAsyncIterator:()=>zu,toInt16ArrayIterator:()=>Mu,toInt32Array:()=>vr,toInt32ArrayAsyncIterator:()=>Wu,toInt32ArrayIterator:()=>Eu,toInt8Array:()=>Bu,toInt8ArrayAsyncIterator:()=>Vu,toInt8ArrayIterator:()=>Uu,toUint16Array:()=>Ou,toUint16ArrayAsyncIterator:()=>Gu,toUint16ArrayIterator:()=>Cu,toUint32Array:()=>Du,toUint32ArrayAsyncIterator:()=>Ju,toUint32ArrayIterator:()=>Ru,toUint8Array:()=>T,toUint8ArrayAsyncIterator:()=>bo,toUint8ArrayIterator:()=>go,toUint8ClampedArray:()=>Lu,toUint8ClampedArrayAsyncIterator:()=>Yu,toUint8ClampedArrayIterator:()=>ku});var vu=new TextDecoder("utf-8"),Un=r=>vu.decode(r),Iu=new TextEncoder,ve=r=>Iu.encode(r);var xu=r=>typeof r=="number",ja=r=>typeof r=="boolean",pt=r=>typeof r=="function",Tt=r=>r!=null&&Object(r)===r,le=r=>Tt(r)&&pt(r.then);var ue=r=>Tt(r)&&pt(r[Symbol.iterator]),Qt=r=>Tt(r)&&pt(r[Symbol.asyncIterator]),Ri=r=>Tt(r)&&Tt(r.schema);var Pi=r=>Tt(r)&&"done"in r&&"value"in r;var ji=r=>Tt(r)&&pt(r.stat)&&xu(r.fd);var ki=r=>Tt(r)&&Mn(r.body),Vi=r=>"_getDOMStream"in r&&"_getNodeStream"in r,ka=r=>Tt(r)&&pt(r.abort)&&pt(r.getWriter)&&!Vi(r),Mn=r=>Tt(r)&&pt(r.cancel)&&pt(r.getReader)&&!Vi(r),Va=r=>Tt(r)&&pt(r.end)&&pt(r.write)&&ja(r.writable)&&!Vi(r),zi=r=>Tt(r)&&pt(r.read)&&pt(r.pipe)&&ja(r.readable)&&!Vi(r),za=r=>Tt(r)&&pt(r.clear)&&pt(r.bytes)&&pt(r.position)&&pt(r.setPosition)&&pt(r.capacity)&&pt(r.getBufferIdentifier)&&pt(r.createLong);var yo=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Su(r){let t=r[0]?[r[0]]:[],e,n,i,s;for(let o,a,c=0,l=0,u=r.length;++c<u;){if(o=t[l],a=r[c],!o||!a||o.buffer!==a.buffer||a.byteOffset<o.byteOffset){a&&(t[++l]=a);continue}if({byteOffset:e,byteLength:i}=o,{byteOffset:n,byteLength:s}=a,e+i<n||n+s<e){a&&(t[++l]=a);continue}t[l]=new Uint8Array(o.buffer,e,n-e+s)}return t}function En(r,t,e=0,n=t.byteLength){let i=r.byteLength,s=new Uint8Array(r.buffer,r.byteOffset,i),o=new Uint8Array(t.buffer,t.byteOffset,Math.min(n,i));return s.set(o,e),r}function Yt(r,t){let e=Su(r),n=e.reduce((u,f)=>u+f.byteLength,0),i,s,o,a=0,c=-1,l=Math.min(t||Number.POSITIVE_INFINITY,n);for(let u=e.length;++c<u;){if(i=e[c],s=i.subarray(0,Math.min(i.length,l-a)),l<=a+s.length){s.length<i.length?e[c]=i.subarray(s.length):s.length===i.length&&c++,o?En(o,s,a):o=s;break}En(o||(o=new Uint8Array(l)),s,a),a+=s.length}return[o||new Uint8Array(0),e.slice(c),n-(o?o.byteLength:0)]}function R(r,t){let e=Pi(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=ve(e)),e instanceof ArrayBuffer?new r(e):e instanceof yo?new r(e):za(e)?R(r,e.bytes()):ArrayBuffer.isView(e)?e.byteLength<=0?new r(0):new r(e.buffer,e.byteOffset,e.byteLength/r.BYTES_PER_ELEMENT):r.from(e)):new r(0)}var Bu=r=>R(Int8Array,r),Au=r=>R(Int16Array,r),vr=r=>R(Int32Array,r),Wi=r=>R(BigInt64Array,r),T=r=>R(Uint8Array,r),Ou=r=>R(Uint16Array,r),Du=r=>R(Uint32Array,r),Fu=r=>R(BigUint64Array,r),Tu=r=>R(Float32Array,r),Nu=r=>R(Float64Array,r),Lu=r=>R(Uint8ClampedArray,r),mo=r=>(r.next(),r);function*Ie(r,t){let e=function*(i){yield i},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof yo?e(t):ue(t)?t:e(t);return yield*mo(function*(i){let s=null;do s=i.next(yield R(r,s));while(!s.done)}(n[Symbol.iterator]())),new r}var Uu=r=>Ie(Int8Array,r),Mu=r=>Ie(Int16Array,r),Eu=r=>Ie(Int32Array,r),go=r=>Ie(Uint8Array,r),Cu=r=>Ie(Uint16Array,r),Ru=r=>Ie(Uint32Array,r),Pu=r=>Ie(Float32Array,r),ju=r=>Ie(Float64Array,r),ku=r=>Ie(Uint8ClampedArray,r);function he(r,t){return Ht(this,arguments,function*(){if(le(t))return yield C(yield C(yield*Qr(ce(he(r,yield C(t))))));let n=function(o){return Ht(this,arguments,function*(){yield yield C(yield C(o))})},i=function(o){return Ht(this,arguments,function*(){yield C(yield*Qr(ce(mo(function*(a){let c=null;do c=a.next(yield c?.value);while(!c.done)}(o[Symbol.iterator]())))))})},s=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof yo?n(t):ue(t)?i(t):Qt(t)?t:n(t);return yield C(yield*Qr(ce(mo(function(o){return Ht(this,arguments,function*(){let a=null;do a=yield C(o.next(yield yield C(R(r,a))));while(!a.done)})}(s[Symbol.asyncIterator]()))))),yield C(new r)})}var Vu=r=>he(Int8Array,r),zu=r=>he(Int16Array,r),Wu=r=>he(Int32Array,r),bo=r=>he(Uint8Array,r),Gu=r=>he(Uint16Array,r),Ju=r=>he(Uint32Array,r),$u=r=>he(Float32Array,r),Hu=r=>he(Float64Array,r),Yu=r=>he(Uint8ClampedArray,r);function Gi(r,t,e){if(r!==0){e=e.slice(0,t);for(let n=-1,i=e.length;++n<i;)e[n]+=r}return e.subarray(0,t)}function _o(r,t){let e=0,n=r.length;if(n!==t.length)return!1;if(n>0)do if(r[e]!==t[e])return!1;while(++e<n);return!0}var wt={fromIterable(r){return Ji(Zu(r))},fromAsyncIterable(r){return Ji(Ku(r))},fromDOMStream(r){return Ji(Xu(r))},fromNodeStream(r){return Ji(qu(r))},toDOMStream(r,t){throw new Error('"toDOMStream" not available in this environment')},toNodeStream(r,t){throw new Error('"toNodeStream" not available in this environment')}},Ji=r=>(r.next(),r);function*Zu(r){let t,e=!1,n=[],i,s,o,a=0;function c(){return s==="peek"?Yt(n,o)[0]:([i,n,a]=Yt(n,o),i)}({cmd:s,size:o}=(yield(()=>null)())||{cmd:"read",size:0});let l=go(r)[Symbol.iterator]();try{do if({done:t,value:i}=Number.isNaN(o-a)?l.next():l.next(o-a),!t&&i.byteLength>0&&(n.push(i),a+=i.byteLength),t||o<=a)do({cmd:s,size:o}=yield c());while(o<a);while(!t)}catch(u){(e=!0)&&typeof l.throw=="function"&&l.throw(u)}finally{e===!1&&typeof l.return=="function"&&l.return(null)}return null}function Ku(r){return Ht(this,arguments,function*(){let e,n=!1,i=[],s,o,a,c=0;function l(){return o==="peek"?Yt(i,a)[0]:([s,i,c]=Yt(i,a),s)}({cmd:o,size:a}=(yield yield C((()=>null)()))||{cmd:"read",size:0});let u=bo(r)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(a-c)?yield C(u.next()):yield C(u.next(a-c)),!e&&s.byteLength>0&&(i.push(s),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield C(l()));while(a<c);while(!e)}catch(f){(n=!0)&&typeof u.throw=="function"&&(yield C(u.throw(f)))}finally{n===!1&&typeof u.return=="function"&&(yield C(u.return(new Uint8Array(0))))}return yield C(null)})}function Xu(r){return Ht(this,arguments,function*(){let e=!1,n=!1,i=[],s,o,a,c=0;function l(){return o==="peek"?Yt(i,a)[0]:([s,i,c]=Yt(i,a),s)}({cmd:o,size:a}=(yield yield C((()=>null)()))||{cmd:"read",size:0});let u=new Io(r);try{do if({done:e,value:s}=Number.isNaN(a-c)?yield C(u.read()):yield C(u.read(a-c)),!e&&s.byteLength>0&&(i.push(T(s)),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield C(l()));while(a<c);while(!e)}catch(f){(n=!0)&&(yield C(u.cancel(f)))}finally{n===!1?yield C(u.cancel()):r.locked&&u.releaseLock()}return yield C(null)})}var Io=class{constructor(t){this.source=t,this.reader=null,this.reader=this.source.getReader(),this.reader.closed.catch(()=>{})}get closed(){return this.reader?this.reader.closed.catch(()=>{}):Promise.resolve()}releaseLock(){this.reader&&this.reader.releaseLock(),this.reader=null}cancel(t){return y(this,void 0,void 0,function*(){let{reader:e,source:n}=this;e&&(yield e.cancel(t).catch(()=>{})),n&&n.locked&&this.releaseLock()})}read(t){return y(this,void 0,void 0,function*(){if(t===0)return{done:this.reader==null,value:new Uint8Array(0)};let e=yield this.reader.read();return!e.done&&(e.value=T(e)),e})}},vo=(r,t)=>{let e=i=>n([t,i]),n;return[t,e,new Promise(i=>(n=i)&&r.once(t,e))]};function qu(r){return Ht(this,arguments,function*(){let e=[],n="error",i=!1,s=null,o,a,c=0,l=[],u;function f(){return o==="peek"?Yt(l,a)[0]:([u,l,c]=Yt(l,a),u)}if({cmd:o,size:a}=(yield yield C((()=>null)()))||{cmd:"read",size:0},r.isTTY)return yield yield C(new Uint8Array(0)),yield C(null);try{e[0]=vo(r,"end"),e[1]=vo(r,"error");do{if(e[2]=vo(r,"readable"),[n,s]=yield C(Promise.race(e.map(p=>p[2]))),n==="error")break;if((i=n==="end")||(Number.isFinite(a-c)?(u=T(r.read(a-c)),u.byteLength<a-c&&(u=T(r.read()))):u=T(r.read()),u.byteLength>0&&(l.push(u),c+=u.byteLength)),i||a<=c)do({cmd:o,size:a}=yield yield C(f()));while(a<c)}while(!i)}finally{yield C(d(e,n==="error"?s:null))}return yield C(null);function d(p,g){return u=l=null,new Promise((G,nt)=>{for(let[Ft,or]of p)r.off(Ft,or);try{let Ft=r.destroy;Ft&&Ft.call(r,g),g=void 0}catch(Ft){g=Ft||g}finally{g!=null?nt(g):G()}})}})}var H;(function(r){r[r.V1=0]="V1",r[r.V2=1]="V2",r[r.V3=2]="V3",r[r.V4=3]="V4",r[r.V5=4]="V5"})(H||(H={}));var q;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(q||(q={}));var K;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(K||(K={}));var at;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(at||(at={}));var v;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(v||(v={}));var mt;(function(r){r[r.YEAR_MONTH=0]="YEAR_MONTH",r[r.DAY_TIME=1]="DAY_TIME",r[r.MONTH_DAY_NANO=2]="MONTH_DAY_NANO"})(mt||(mt={}));var xe=new Int32Array(2),$i=new Float32Array(xe.buffer),Hi=new Float64Array(xe.buffer),tn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var Cn;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(Cn||(Cn={}));var Nt=class{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new Nt(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return xe[0]=this.readInt32(t),$i[0]}readFloat64(t){return xe[tn?0:1]=this.readInt32(t),xe[tn?1:0]=this.readInt32(t+4),Hi[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){$i[0]=e,this.writeInt32(t,xe[0])}writeFloat64(t,e){Hi[0]=e,this.writeInt32(t,xe[tn?0:1]),this.writeInt32(t+4,xe[tn?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){let n=t-this.readInt32(t);return e<this.readInt16(n)?this.readInt16(n+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);let n=this.readInt32(t);t+=4;let i=this.bytes_.subarray(t,t+n);return e===Cn.UTF8_BYTES?i:this.text_decoder_.decode(i)}__union_with_string(t,e){return typeof t=="string"?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(t.length!=4)throw new Error("FlatBuffers: file identifier must be length "+4);for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createScalarList(t,e){let n=[];for(let i=0;i<e;++i){let s=t(i);s!==null&&n.push(s)}return n}createObjList(t,e){let n=[];for(let i=0;i<e;++i){let s=t(i);s!==null&&n.push(s.unpack())}return n}};var Ye=class{constructor(t){this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,this.text_encoder=new TextEncoder;let e;t?e=t:e=1024,this.bb=Nt.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);let n=~(this.bb.capacity()-this.space+e)+1&t-1;for(;this.space<n+t+e;){let i=this.bb.capacity();this.bb=Ye.growByteBuffer(this.bb),this.space+=this.bb.capacity()-i}this.pad(n)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,n){(this.force_defaults||e!=n)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,n){(this.force_defaults||e!=n)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,n){(this.force_defaults||e!=n)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,n){(this.force_defaults||e!==n)&&(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,n){(this.force_defaults||e!=n)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,n){(this.force_defaults||e!=n)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,n){e!=n&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("FlatBuffers: object serialization must not be nested.")}slot(t){this.vtable!==null&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){let e=t.capacity();if(e&3221225472)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");let n=e<<1,i=Nt.allocate(n);return i.setPosition(n-e),i.bytes().set(t.bytes(),n-e),i}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);let t=this.offset(),e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);let n=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);let i=2;this.addInt16(t-this.object_start);let s=(n+i)*2;this.addInt16(s);let o=0,a=this.space;t:for(e=0;e<this.vtables.length;e++){let c=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(c)){for(let l=2;l<s;l+=2)if(this.bb.readInt16(a+l)!=this.bb.readInt16(c+l))continue t;o=this.vtables[e];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,n){let i=n?4:0;if(e){let s=e;if(this.prep(this.minalign,4+4+i),s.length!=4)throw new TypeError("FlatBuffers: file identifier must be length "+4);for(let o=4-1;o>=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,4+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){let n=this.bb.capacity()-t,i=n-this.bb.readInt32(n);if(!(e<this.bb.readInt16(i)&&this.bb.readInt16(i+e)!=0))throw new TypeError("FlatBuffers: field "+e+" must be set")}startVector(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(n,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);let e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(t==null)return 0;let e;return t instanceof Uint8Array?e=t:e=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){let e=[];for(let n=0;n<t.length;++n){let i=t[n];if(i!==null)e.push(this.createObjectOffset(i));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var Rn;(function(r){r[r.BUFFER=0]="BUFFER"})(Rn||(Rn={}));var Pn;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(Pn||(Pn={}));var de=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBodyCompression(t,e){return(e||new de).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new de).__init(t.readInt32(t.position())+t.position(),t)}codec(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt8(this.bb_pos+t):Pn.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Rn.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,Pn.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,Rn.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return de.startBodyCompression(t),de.addCodec(t,e),de.addMethod(t,n),de.endBodyCompression(t)}};var en=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}length(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createBuffer(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n??0)),t.writeInt64(BigInt(e??0)),t.offset()}};var rn=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}length(){return this.bb.readInt64(this.bb_pos)}nullCount(){return this.bb.readInt64(this.bb_pos+8)}static sizeOf(){return 16}static createFieldNode(t,e,n){return t.prep(8,16),t.writeInt64(BigInt(n??0)),t.writeInt64(BigInt(e??0)),t.offset()}};var xt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsRecordBatch(t,e){return(e||new xt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new xt).__init(t.readInt32(t.position())+t.position(),t)}length(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}nodes(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new rn).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}nodesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}buffers(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new en).__init(this.bb.__vector(this.bb_pos+n)+t*16,this.bb):null}buffersLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}compression(t){let e=this.bb.__offset(this.bb_pos,10);return e?(t||new de).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}static startRecordBatch(t){t.startObject(4)}static addLength(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addNodes(t,e){t.addFieldOffset(1,e,0)}static startNodesVector(t,e){t.startVector(16,e,8)}static addBuffers(t,e){t.addFieldOffset(2,e,0)}static startBuffersVector(t,e){t.startVector(16,e,8)}static addCompression(t,e){t.addFieldOffset(3,e,0)}static endRecordBatch(t){return t.endObject()}};var ee=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryBatch(t,e){return(e||new ee).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new ee).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}data(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new xt).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}};var hr;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(hr||(hr={}));var jn;(function(r){r[r.DenseArray=0]="DenseArray"})(jn||(jn={}));var yt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInt(t,e){return(e||new yt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInt(t,e){return t.setPosition(t.position()+4),(e||new yt).__init(t.readInt32(t.position())+t.position(),t)}bitWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}isSigned(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startInt(t){t.startObject(2)}static addBitWidth(t,e){t.addFieldInt32(0,e,0)}static addIsSigned(t,e){t.addFieldInt8(1,+e,0)}static endInt(t){return t.endObject()}static createInt(t,e,n){return yt.startInt(t),yt.addBitWidth(t,e),yt.addIsSigned(t,n),yt.endInt(t)}};var Zt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDictionaryEncoding(t,e){return(e||new Zt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+4),(e||new Zt).__init(t.readInt32(t.position())+t.position(),t)}id(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}indexType(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new yt).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isOrdered(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}dictionaryKind(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt16(this.bb_pos+t):jn.DenseArray}static startDictionaryEncoding(t){t.startObject(4)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addIndexType(t,e){t.addFieldOffset(1,e,0)}static addIsOrdered(t,e){t.addFieldInt8(2,+e,0)}static addDictionaryKind(t,e){t.addFieldInt16(3,e,jn.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}};var Q=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsKeyValue(t,e){return(e||new Q).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+4),(e||new Q).__init(t.readInt32(t.position())+t.position(),t)}key(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}value(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startKeyValue(t){t.startObject(2)}static addKey(t,e){t.addFieldOffset(0,e,0)}static addValue(t,e){t.addFieldOffset(1,e,0)}static endKeyValue(t){return t.endObject()}static createKeyValue(t,e,n){return Q.startKeyValue(t),Q.addKey(t,e),Q.addValue(t,n),Q.endKeyValue(t)}};var Se=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinary(t,e){return(e||new Se).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+4),(e||new Se).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return Se.startBinary(t),Se.endBinary(t)}};var Be=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBool(t,e){return(e||new Be).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+4),(e||new Be).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return Be.startBool(t),Be.endBool(t)}};var Mt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDate(t,e){return(e||new Mt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+4),(e||new Mt).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):at.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,at.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return Mt.startDate(t),Mt.addUnit(t,e),Mt.endDate(t)}};var gt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDecimal(t,e){return(e||new gt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+4),(e||new gt).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}scale(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}bitWidth(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readInt32(this.bb_pos+t):128}static startDecimal(t){t.startObject(3)}static addPrecision(t,e){t.addFieldInt32(0,e,0)}static addScale(t,e){t.addFieldInt32(1,e,0)}static addBitWidth(t,e){t.addFieldInt32(2,e,128)}static endDecimal(t){return t.endObject()}static createDecimal(t,e,n,i){return gt.startDecimal(t),gt.addPrecision(t,e),gt.addScale(t,n),gt.addBitWidth(t,i),gt.endDecimal(t)}};var Et=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDuration(t,e){return(e||new Et).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+4),(e||new Et).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):v.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,v.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return Et.startDuration(t),Et.addUnit(t,e),Et.endDuration(t)}};var Ct=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeBinary(t,e){return(e||new Ct).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+4),(e||new Ct).__init(t.readInt32(t.position())+t.position(),t)}byteWidth(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeBinary(t){t.startObject(1)}static addByteWidth(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeBinary(t){return t.endObject()}static createFixedSizeBinary(t,e){return Ct.startFixedSizeBinary(t),Ct.addByteWidth(t,e),Ct.endFixedSizeBinary(t)}};var Rt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFixedSizeList(t,e){return(e||new Rt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+4),(e||new Rt).__init(t.readInt32(t.position())+t.position(),t)}listSize(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt32(this.bb_pos+t):0}static startFixedSizeList(t){t.startObject(1)}static addListSize(t,e){t.addFieldInt32(0,e,0)}static endFixedSizeList(t){return t.endObject()}static createFixedSizeList(t,e){return Rt.startFixedSizeList(t),Rt.addListSize(t,e),Rt.endFixedSizeList(t)}};var Pt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFloatingPoint(t,e){return(e||new Pt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+4),(e||new Pt).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):K.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,K.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return Pt.startFloatingPoint(t),Pt.addPrecision(t,e),Pt.endFloatingPoint(t)}};var jt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsInterval(t,e){return(e||new jt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+4),(e||new jt).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):mt.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,mt.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return jt.startInterval(t),jt.addUnit(t,e),jt.endInterval(t)}};var Ae=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeBinary(t,e){return(e||new Ae).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+4),(e||new Ae).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return Ae.startLargeBinary(t),Ae.endLargeBinary(t)}};var Oe=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeUtf8(t,e){return(e||new Oe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+4),(e||new Oe).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return Oe.startLargeUtf8(t),Oe.endLargeUtf8(t)}};var De=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsList(t,e){return(e||new De).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+4),(e||new De).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return De.startList(t),De.endList(t)}};var kt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMap(t,e){return(e||new kt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMap(t,e){return t.setPosition(t.position()+4),(e||new kt).__init(t.readInt32(t.position())+t.position(),t)}keysSorted(){let t=this.bb.__offset(this.bb_pos,4);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startMap(t){t.startObject(1)}static addKeysSorted(t,e){t.addFieldInt8(0,+e,0)}static endMap(t){return t.endObject()}static createMap(t,e){return kt.startMap(t),kt.addKeysSorted(t,e),kt.endMap(t)}};var Fe=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNull(t,e){return(e||new Fe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+4),(e||new Fe).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return Fe.startNull(t),Fe.endNull(t)}};var Te=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsStruct_(t,e){return(e||new Te).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+4),(e||new Te).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return Te.startStruct_(t),Te.endStruct_(t)}};var St=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTime(t,e){return(e||new St).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+4),(e||new St).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):v.MILLISECOND}bitWidth(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,v.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return St.startTime(t),St.addUnit(t,e),St.addBitWidth(t,n),St.endTime(t)}};var Bt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsTimestamp(t,e){return(e||new Bt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+4),(e||new Bt).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):v.SECOND}timezone(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,v.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return Bt.startTimestamp(t),Bt.addUnit(t,e),Bt.addTimezone(t,n),Bt.endTimestamp(t)}};var bt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUnion(t,e){return(e||new bt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUnion(t,e){return t.setPosition(t.position()+4),(e||new bt).__init(t.readInt32(t.position())+t.position(),t)}mode(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):q.Sparse}typeIds(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+t*4):0}typeIdsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,e){t.addFieldInt16(0,e,q.Sparse)}static addTypeIds(t,e){t.addFieldOffset(1,e,0)}static createTypeIdsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addInt32(e[n]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,n){return bt.startUnion(t),bt.addMode(t,e),bt.addTypeIds(t,n),bt.endUnion(t)}};var Ne=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsUtf8(t,e){return(e||new Ne).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new Ne).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Ne.startUtf8(t),Ne.endUtf8(t)}};var X;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.FloatingPoint=3]="FloatingPoint",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct_=13]="Struct_",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.LargeList=21]="LargeList",r[r.RunEndEncoded=22]="RunEndEncoded"})(X||(X={}));var lt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsField(t,e){return(e||new lt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+4),(e||new lt).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}nullable(){let t=this.bb.__offset(this.bb_pos,6);return t?!!this.bb.readInt8(this.bb_pos+t):!1}typeType(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):X.NONE}type(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__union(t,this.bb_pos+e):null}dictionary(t){let e=this.bb.__offset(this.bb_pos,12);return e?(t||new Zt).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}children(t,e){let n=this.bb.__offset(this.bb_pos,14);return n?(e||new lt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}childrenLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,16);return n?(e||new Q).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.__vector_len(this.bb_pos+t):0}static startField(t){t.startObject(7)}static addName(t,e){t.addFieldOffset(0,e,0)}static addNullable(t,e){t.addFieldInt8(1,+e,0)}static addTypeType(t,e){t.addFieldInt8(2,e,X.NONE)}static addType(t,e){t.addFieldOffset(3,e,0)}static addDictionary(t,e){t.addFieldOffset(4,e,0)}static addChildren(t,e){t.addFieldOffset(5,e,0)}static createChildrenVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startChildrenVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(6,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endField(t){return t.endObject()}};var it=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsSchema(t,e){return(e||new it).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+4),(e||new it).__init(t.readInt32(t.position())+t.position(),t)}endianness(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):hr.Little}fields(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new lt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}fieldsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new Q).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}featuresLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,hr.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(t,e,n,i,s){return it.startSchema(t),it.addEndianness(t,e),it.addFields(t,n),it.addCustomMetadata(t,i),it.addFeatures(t,s),it.endSchema(t)}};var j;(function(r){r[r.NONE=0]="NONE",r[r.Schema=1]="Schema",r[r.DictionaryBatch=2]="DictionaryBatch",r[r.RecordBatch=3]="RecordBatch",r[r.Tensor=4]="Tensor",r[r.SparseTensor=5]="SparseTensor"})(j||(j={}));var h;(function(r){r[r.NONE=0]="NONE",r[r.Null=1]="Null",r[r.Int=2]="Int",r[r.Float=3]="Float",r[r.Binary=4]="Binary",r[r.Utf8=5]="Utf8",r[r.Bool=6]="Bool",r[r.Decimal=7]="Decimal",r[r.Date=8]="Date",r[r.Time=9]="Time",r[r.Timestamp=10]="Timestamp",r[r.Interval=11]="Interval",r[r.List=12]="List",r[r.Struct=13]="Struct",r[r.Union=14]="Union",r[r.FixedSizeBinary=15]="FixedSizeBinary",r[r.FixedSizeList=16]="FixedSizeList",r[r.Map=17]="Map",r[r.Duration=18]="Duration",r[r.LargeBinary=19]="LargeBinary",r[r.LargeUtf8=20]="LargeUtf8",r[r.Dictionary=-1]="Dictionary",r[r.Int8=-2]="Int8",r[r.Int16=-3]="Int16",r[r.Int32=-4]="Int32",r[r.Int64=-5]="Int64",r[r.Uint8=-6]="Uint8",r[r.Uint16=-7]="Uint16",r[r.Uint32=-8]="Uint32",r[r.Uint64=-9]="Uint64",r[r.Float16=-10]="Float16",r[r.Float32=-11]="Float32",r[r.Float64=-12]="Float64",r[r.DateDay=-13]="DateDay",r[r.DateMillisecond=-14]="DateMillisecond",r[r.TimestampSecond=-15]="TimestampSecond",r[r.TimestampMillisecond=-16]="TimestampMillisecond",r[r.TimestampMicrosecond=-17]="TimestampMicrosecond",r[r.TimestampNanosecond=-18]="TimestampNanosecond",r[r.TimeSecond=-19]="TimeSecond",r[r.TimeMillisecond=-20]="TimeMillisecond",r[r.TimeMicrosecond=-21]="TimeMicrosecond",r[r.TimeNanosecond=-22]="TimeNanosecond",r[r.DenseUnion=-23]="DenseUnion",r[r.SparseUnion=-24]="SparseUnion",r[r.IntervalDayTime=-25]="IntervalDayTime",r[r.IntervalYearMonth=-26]="IntervalYearMonth",r[r.DurationSecond=-27]="DurationSecond",r[r.DurationMillisecond=-28]="DurationMillisecond",r[r.DurationMicrosecond=-29]="DurationMicrosecond",r[r.DurationNanosecond=-30]="DurationNanosecond"})(h||(h={}));var pe;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(pe||(pe={}));var zo={};ur(zo,{clampRange:()=>Wn,createElementComparator:()=>mr,wrapIndex:()=>Nr});var xo={};ur(xo,{valueToString:()=>me});function me(r){if(r===null)return"null";if(r===void 0)return"undefined";switch(typeof r){case"number":return`${r}`;case"bigint":return`${r}`;case"string":return`"${r}"`}return typeof r[Symbol.toPrimitive]=="function"?r[Symbol.toPrimitive]("string"):ArrayBuffer.isView(r)?r instanceof BigInt64Array||r instanceof BigUint64Array?`[${[...r].map(t=>me(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}var Oo={};ur(Oo,{BN:()=>Ir,bigNumToBigInt:()=>Ga,bigNumToNumber:()=>Ao,bigNumToString:()=>on,isArrowBigNumSymbol:()=>Wa});function W(r){if(typeof r=="bigint"&&(r<Number.MIN_SAFE_INTEGER||r>Number.MAX_SAFE_INTEGER))throw new TypeError(`${r} is not safe to convert to a number.`);return Number(r)}function So(r,t){return W(r/t)+W(r%t)/W(t)}var Wa=Symbol.for("isArrowBigNum");function ye(r,...t){return t.length===0?Object.setPrototypeOf(R(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}ye.prototype[Wa]=!0;ye.prototype.toJSON=function(){return`"${on(this)}"`};ye.prototype.valueOf=function(r){return Ao(this,r)};ye.prototype.toString=function(){return on(this)};ye.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Ao(this);case"string":return on(this);case"default":return Ga(this)}return on(this)};function nn(...r){return ye.apply(this,r)}function sn(...r){return ye.apply(this,r)}function kn(...r){return ye.apply(this,r)}Object.setPrototypeOf(nn.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(sn.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(kn.prototype,Object.create(Uint32Array.prototype));Object.assign(nn.prototype,ye.prototype,{constructor:nn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(sn.prototype,ye.prototype,{constructor:sn,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(kn.prototype,ye.prototype,{constructor:kn,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var Qu=BigInt(4294967296)*BigInt(4294967296),th=Qu-BigInt(1);function Ao(r,t){let{buffer:e,byteOffset:n,byteLength:i,signed:s}=r,o=new BigUint64Array(e,n,i/8),a=s&&o.at(-1)&BigInt(1)<<BigInt(63),c=BigInt(0),l=0;if(a){for(let u of o)c|=(u^th)*(BigInt(1)<<BigInt(64*l++));c*=BigInt(-1),c-=BigInt(1)}else for(let u of o)c|=u*(BigInt(1)<<BigInt(64*l++));if(typeof t=="number"){let u=BigInt(Math.pow(10,t)),f=c/u,d=c%u;return W(f)+W(d)/W(u)}return W(c)}function on(r){if(r.byteLength===8)return`${new r.BigIntArray(r.buffer,r.byteOffset,1)[0]}`;if(!r.signed)return Bo(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Bo(r);t=t.slice();let n=1;for(let s=0;s<t.length;s++){let o=t[s],a=~o+n;t[s]=a,n&=o===0?1:0}return`-${Bo(t)}`}function Ga(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:on(r)}function Bo(r){let t="",e=new Uint32Array(2),n=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2),i=new Uint32Array((n=new Uint16Array(n).reverse()).buffer),s=-1,o=n.length-1;do{for(e[0]=n[s=0];s<o;)n[s++]=e[1]=e[0]/10,e[0]=(e[0]-e[1]*10<<16)+n[s];n[s]=e[1]=e[0]/10,e[0]=e[0]-e[1]*10,t=`${e[0]}${t}`}while(i[0]||i[1]||i[2]||i[3]);return t??"0"}var Ir=class{static new(t,e){switch(e){case!0:return new nn(t);case!1:return new sn(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new nn(t)}return t.byteLength===16?new kn(t):new sn(t)}static signed(t){return new nn(t)}static unsigned(t){return new sn(t)}static decimal(t){return new kn(t)}constructor(t,e){return Ir.new(t,e)}};var Ja,$a,Ha,Ya,Za,Ka,Xa,qa,Qa,tc,ec,rc,nc,ic,sc,oc,ac,cc,lc,uc,hc,fc,m=class{static isNull(t){return t?.typeId===h.Null}static isInt(t){return t?.typeId===h.Int}static isFloat(t){return t?.typeId===h.Float}static isBinary(t){return t?.typeId===h.Binary}static isLargeBinary(t){return t?.typeId===h.LargeBinary}static isUtf8(t){return t?.typeId===h.Utf8}static isLargeUtf8(t){return t?.typeId===h.LargeUtf8}static isBool(t){return t?.typeId===h.Bool}static isDecimal(t){return t?.typeId===h.Decimal}static isDate(t){return t?.typeId===h.Date}static isTime(t){return t?.typeId===h.Time}static isTimestamp(t){return t?.typeId===h.Timestamp}static isInterval(t){return t?.typeId===h.Interval}static isDuration(t){return t?.typeId===h.Duration}static isList(t){return t?.typeId===h.List}static isStruct(t){return t?.typeId===h.Struct}static isUnion(t){return t?.typeId===h.Union}static isFixedSizeBinary(t){return t?.typeId===h.FixedSizeBinary}static isFixedSizeList(t){return t?.typeId===h.FixedSizeList}static isMap(t){return t?.typeId===h.Map}static isDictionary(t){return t?.typeId===h.Dictionary}static isDenseUnion(t){return m.isUnion(t)&&t.mode===q.Dense}static isSparseUnion(t){return m.isUnion(t)&&t.mode===q.Sparse}constructor(t){this.typeId=t}};Ja=Symbol.toStringTag;m[Ja]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(m.prototype);var At=class extends m{constructor(){super(h.Null)}toString(){return"Null"}};$a=Symbol.toStringTag;At[$a]=(r=>r[Symbol.toStringTag]="Null")(At.prototype);var ut=class extends m{constructor(t,e){super(h.Int),this.isSigned=t,this.bitWidth=e}get ArrayType(){switch(this.bitWidth){case 8:return this.isSigned?Int8Array:Uint8Array;case 16:return this.isSigned?Int16Array:Uint16Array;case 32:return this.isSigned?Int32Array:Uint32Array;case 64:return this.isSigned?BigInt64Array:BigUint64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}};Ha=Symbol.toStringTag;ut[Ha]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(ut.prototype);var xr=class extends ut{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},Sr=class extends ut{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},Kt=class extends ut{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Br=class extends ut{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Ar=class extends ut{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},Or=class extends ut{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Dr=class extends ut{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Fr=class extends ut{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(xr.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(Sr.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(Kt.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(Br.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(Ar.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(Or.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Dr.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(Fr.prototype,"ArrayType",{value:BigUint64Array});var Xt=class extends m{constructor(t){super(h.Float),this.precision=t}get ArrayType(){switch(this.precision){case K.HALF:return Uint16Array;case K.SINGLE:return Float32Array;case K.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};Ya=Symbol.toStringTag;Xt[Ya]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(Xt.prototype);var Vn=class extends Xt{constructor(){super(K.HALF)}},Ze=class extends Xt{constructor(){super(K.SINGLE)}},Tr=class extends Xt{constructor(){super(K.DOUBLE)}};Object.defineProperty(Vn.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Ze.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(Tr.prototype,"ArrayType",{value:Float64Array});var Le=class extends m{constructor(){super(h.Binary)}toString(){return"Binary"}};Za=Symbol.toStringTag;Le[Za]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(Le.prototype);var Ue=class extends m{constructor(){super(h.LargeBinary)}toString(){return"LargeBinary"}};Ka=Symbol.toStringTag;Ue[Ka]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(Ue.prototype);var Me=class extends m{constructor(){super(h.Utf8)}toString(){return"Utf8"}};Xa=Symbol.toStringTag;Me[Xa]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(Me.prototype);var Ee=class extends m{constructor(){super(h.LargeUtf8)}toString(){return"LargeUtf8"}};qa=Symbol.toStringTag;Ee[qa]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Ee.prototype);var Ce=class extends m{constructor(){super(h.Bool)}toString(){return"Bool"}};Qa=Symbol.toStringTag;Ce[Qa]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(Ce.prototype);var Re=class extends m{constructor(t,e,n=128){super(h.Decimal),this.scale=t,this.precision=e,this.bitWidth=n}toString(){return`Decimal[${this.precision}e${this.scale>0?"+":""}${this.scale}]`}};tc=Symbol.toStringTag;Re[tc]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(Re.prototype);var Pe=class extends m{constructor(t){super(h.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${at[this.unit]}>`}get ArrayType(){return this.unit===at.DAY?Int32Array:BigInt64Array}};ec=Symbol.toStringTag;Pe[ec]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(Pe.prototype);var je=class extends m{constructor(t,e){super(h.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${v[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};rc=Symbol.toStringTag;je[rc]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(je.prototype);var ke=class extends m{constructor(t,e){super(h.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${v[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};nc=Symbol.toStringTag;ke[nc]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(ke.prototype);var Ve=class extends m{constructor(t){super(h.Interval),this.unit=t}toString(){return`Interval<${mt[this.unit]}>`}};ic=Symbol.toStringTag;Ve[ic]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(Ve.prototype);var ze=class extends m{constructor(t){super(h.Duration),this.unit=t}toString(){return`Duration<${v[this.unit]}>`}};sc=Symbol.toStringTag;ze[sc]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(ze.prototype);var re=class extends m{constructor(t){super(h.List),this.children=[t]}toString(){return`List<${this.valueType}>`}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}};oc=Symbol.toStringTag;re[oc]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(re.prototype);var Z=class extends m{constructor(t){super(h.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};ac=Symbol.toStringTag;Z[ac]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(Z.prototype);var ne=class extends m{constructor(t,e,n){super(h.Union),this.mode=t,this.children=n,this.typeIds=e=Int32Array.from(e),this.typeIdToChildIndex=e.reduce((i,s,o)=>(i[s]=o)&&i||i,Object.create(null))}toString(){return`${this[Symbol.toStringTag]}<${this.children.map(t=>`${t.type}`).join(" | ")}>`}};cc=Symbol.toStringTag;ne[cc]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(ne.prototype);var We=class extends m{constructor(t){super(h.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};lc=Symbol.toStringTag;We[lc]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(We.prototype);var ie=class extends m{constructor(t,e){super(h.FixedSizeList),this.listSize=t,this.children=[e]}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get ArrayType(){return this.valueType.ArrayType}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}};uc=Symbol.toStringTag;ie[uc]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(ie.prototype);var se=class extends m{constructor(t,e=!1){var n,i,s;if(super(h.Map),this.children=[t],this.keysSorted=e,t&&(t.name="entries",!((n=t?.type)===null||n===void 0)&&n.children)){let o=(i=t?.type)===null||i===void 0?void 0:i.children[0];o&&(o.name="key");let a=(s=t?.type)===null||s===void 0?void 0:s.children[1];a&&(a.name="value")}}get keyType(){return this.children[0].type.children[0].type}get valueType(){return this.children[0].type.children[1].type}get childType(){return this.children[0].type}toString(){return`Map<{${this.children[0].type.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};hc=Symbol.toStringTag;se[hc]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(se.prototype);var eh=(r=>()=>++r)(-1),Vt=class extends m{constructor(t,e,n,i){super(h.Dictionary),this.indices=e,this.dictionary=t,this.isOrdered=i||!1,this.id=n==null?eh():W(n)}get children(){return this.dictionary.children}get valueType(){return this.dictionary}get ArrayType(){return this.dictionary.ArrayType}toString(){return`Dictionary<${this.indices}, ${this.dictionary}>`}};fc=Symbol.toStringTag;Vt[fc]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(Vt.prototype);function qt(r){let t=r;switch(r.typeId){case h.Decimal:return r.bitWidth/32;case h.Interval:return 1+t.unit;case h.FixedSizeList:return t.listSize;case h.FixedSizeBinary:return t.byteWidth;default:return 1}}var x=class{visitMany(t,...e){return t.map((n,i)=>this.visit(n,...e.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return nh(this,t,e)}getVisitFnByTypeId(t,e=!0){return an(this,t,e)}visitNull(t,...e){return null}visitBool(t,...e){return null}visitInt(t,...e){return null}visitFloat(t,...e){return null}visitUtf8(t,...e){return null}visitLargeUtf8(t,...e){return null}visitBinary(t,...e){return null}visitLargeBinary(t,...e){return null}visitFixedSizeBinary(t,...e){return null}visitDate(t,...e){return null}visitTimestamp(t,...e){return null}visitTime(t,...e){return null}visitDecimal(t,...e){return null}visitList(t,...e){return null}visitStruct(t,...e){return null}visitUnion(t,...e){return null}visitDictionary(t,...e){return null}visitInterval(t,...e){return null}visitDuration(t,...e){return null}visitFixedSizeList(t,...e){return null}visitMap(t,...e){return null}};function nh(r,t,e=!0){return typeof t=="number"?an(r,t,e):typeof t=="string"&&t in h?an(r,h[t],e):t&&t instanceof m?an(r,dc(t),e):t?.type&&t.type instanceof m?an(r,dc(t.type),e):an(r,h.NONE,e)}function an(r,t,e=!0){let n=null;switch(t){case h.Null:n=r.visitNull;break;case h.Bool:n=r.visitBool;break;case h.Int:n=r.visitInt;break;case h.Int8:n=r.visitInt8||r.visitInt;break;case h.Int16:n=r.visitInt16||r.visitInt;break;case h.Int32:n=r.visitInt32||r.visitInt;break;case h.Int64:n=r.visitInt64||r.visitInt;break;case h.Uint8:n=r.visitUint8||r.visitInt;break;case h.Uint16:n=r.visitUint16||r.visitInt;break;case h.Uint32:n=r.visitUint32||r.visitInt;break;case h.Uint64:n=r.visitUint64||r.visitInt;break;case h.Float:n=r.visitFloat;break;case h.Float16:n=r.visitFloat16||r.visitFloat;break;case h.Float32:n=r.visitFloat32||r.visitFloat;break;case h.Float64:n=r.visitFloat64||r.visitFloat;break;case h.Utf8:n=r.visitUtf8;break;case h.LargeUtf8:n=r.visitLargeUtf8;break;case h.Binary:n=r.visitBinary;break;case h.LargeBinary:n=r.visitLargeBinary;break;case h.FixedSizeBinary:n=r.visitFixedSizeBinary;break;case h.Date:n=r.visitDate;break;case h.DateDay:n=r.visitDateDay||r.visitDate;break;case h.DateMillisecond:n=r.visitDateMillisecond||r.visitDate;break;case h.Timestamp:n=r.visitTimestamp;break;case h.TimestampSecond:n=r.visitTimestampSecond||r.visitTimestamp;break;case h.TimestampMillisecond:n=r.visitTimestampMillisecond||r.visitTimestamp;break;case h.TimestampMicrosecond:n=r.visitTimestampMicrosecond||r.visitTimestamp;break;case h.TimestampNanosecond:n=r.visitTimestampNanosecond||r.visitTimestamp;break;case h.Time:n=r.visitTime;break;case h.TimeSecond:n=r.visitTimeSecond||r.visitTime;break;case h.TimeMillisecond:n=r.visitTimeMillisecond||r.visitTime;break;case h.TimeMicrosecond:n=r.visitTimeMicrosecond||r.visitTime;break;case h.TimeNanosecond:n=r.visitTimeNanosecond||r.visitTime;break;case h.Decimal:n=r.visitDecimal;break;case h.List:n=r.visitList;break;case h.Struct:n=r.visitStruct;break;case h.Union:n=r.visitUnion;break;case h.DenseUnion:n=r.visitDenseUnion||r.visitUnion;break;case h.SparseUnion:n=r.visitSparseUnion||r.visitUnion;break;case h.Dictionary:n=r.visitDictionary;break;case h.Interval:n=r.visitInterval;break;case h.IntervalDayTime:n=r.visitIntervalDayTime||r.visitInterval;break;case h.IntervalYearMonth:n=r.visitIntervalYearMonth||r.visitInterval;break;case h.Duration:n=r.visitDuration;break;case h.DurationSecond:n=r.visitDurationSecond||r.visitDuration;break;case h.DurationMillisecond:n=r.visitDurationMillisecond||r.visitDuration;break;case h.DurationMicrosecond:n=r.visitDurationMicrosecond||r.visitDuration;break;case h.DurationNanosecond:n=r.visitDurationNanosecond||r.visitDuration;break;case h.FixedSizeList:n=r.visitFixedSizeList;break;case h.Map:n=r.visitMap;break}if(typeof n=="function")return n;if(!e)return()=>null;throw new Error(`Unrecognized type '${h[t]}'`)}function dc(r){switch(r.typeId){case h.Null:return h.Null;case h.Int:{let{bitWidth:t,isSigned:e}=r;switch(t){case 8:return e?h.Int8:h.Uint8;case 16:return e?h.Int16:h.Uint16;case 32:return e?h.Int32:h.Uint32;case 64:return e?h.Int64:h.Uint64}return h.Int}case h.Float:switch(r.precision){case K.HALF:return h.Float16;case K.SINGLE:return h.Float32;case K.DOUBLE:return h.Float64}return h.Float;case h.Binary:return h.Binary;case h.LargeBinary:return h.LargeBinary;case h.Utf8:return h.Utf8;case h.LargeUtf8:return h.LargeUtf8;case h.Bool:return h.Bool;case h.Decimal:return h.Decimal;case h.Time:switch(r.unit){case v.SECOND:return h.TimeSecond;case v.MILLISECOND:return h.TimeMillisecond;case v.MICROSECOND:return h.TimeMicrosecond;case v.NANOSECOND:return h.TimeNanosecond}return h.Time;case h.Timestamp:switch(r.unit){case v.SECOND:return h.TimestampSecond;case v.MILLISECOND:return h.TimestampMillisecond;case v.MICROSECOND:return h.TimestampMicrosecond;case v.NANOSECOND:return h.TimestampNanosecond}return h.Timestamp;case h.Date:switch(r.unit){case at.DAY:return h.DateDay;case at.MILLISECOND:return h.DateMillisecond}return h.Date;case h.Interval:switch(r.unit){case mt.DAY_TIME:return h.IntervalDayTime;case mt.YEAR_MONTH:return h.IntervalYearMonth}return h.Interval;case h.Duration:switch(r.unit){case v.SECOND:return h.DurationSecond;case v.MILLISECOND:return h.DurationMillisecond;case v.MICROSECOND:return h.DurationMicrosecond;case v.NANOSECOND:return h.DurationNanosecond}return h.Duration;case h.Map:return h.Map;case h.List:return h.List;case h.Struct:return h.Struct;case h.Union:switch(r.mode){case q.Dense:return h.DenseUnion;case q.Sparse:return h.SparseUnion}return h.Union;case h.FixedSizeBinary:return h.FixedSizeBinary;case h.FixedSizeList:return h.FixedSizeList;case h.Dictionary:return h.Dictionary}throw new Error(`Unrecognized type '${h[r.typeId]}'`)}x.prototype.visitInt8=null;x.prototype.visitInt16=null;x.prototype.visitInt32=null;x.prototype.visitInt64=null;x.prototype.visitUint8=null;x.prototype.visitUint16=null;x.prototype.visitUint32=null;x.prototype.visitUint64=null;x.prototype.visitFloat16=null;x.prototype.visitFloat32=null;x.prototype.visitFloat64=null;x.prototype.visitDateDay=null;x.prototype.visitDateMillisecond=null;x.prototype.visitTimestampSecond=null;x.prototype.visitTimestampMillisecond=null;x.prototype.visitTimestampMicrosecond=null;x.prototype.visitTimestampNanosecond=null;x.prototype.visitTimeSecond=null;x.prototype.visitTimeMillisecond=null;x.prototype.visitTimeMicrosecond=null;x.prototype.visitTimeNanosecond=null;x.prototype.visitDenseUnion=null;x.prototype.visitSparseUnion=null;x.prototype.visitIntervalDayTime=null;x.prototype.visitIntervalYearMonth=null;x.prototype.visitDuration=null;x.prototype.visitDurationSecond=null;x.prototype.visitDurationMillisecond=null;x.prototype.visitDurationMicrosecond=null;x.prototype.visitDurationNanosecond=null;var Do={};ur(Do,{float64ToUint16:()=>zn,uint16ToFloat64:()=>Zi});var pc=new Float64Array(1),cn=new Uint32Array(pc.buffer);function Zi(r){let t=(r&31744)>>10,e=(r&1023)/1024,n=Math.pow(-1,(r&32768)>>15);switch(t){case 31:return n*(e?Number.NaN:1/0);case 0:return n*(e?6103515625e-14*e:0)}return n*Math.pow(2,t-15)*(1+e)}function zn(r){if(r!==r)return 32256;pc[0]=r;let t=(cn[1]&2147483648)>>16&65535,e=cn[1]&2146435072,n=0;return e>=1089470464?cn[0]>0?e=31744:(e=(e&2080374784)>>16,n=(cn[1]&1048575)>>10):e<=1056964608?(n=1048576+(cn[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(cn[1]&1048575)+512>>10),t|e|n&65535}var D=class extends x{};function U(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}var ih=(r,t,e)=>{r[t]=Math.floor(e/864e5)},mc=(r,t,e,n)=>{if(e+1<t.length){let i=W(t[e]),s=W(t[e+1]);r.set(n.subarray(0,s-i),i)}},sh=({offset:r,values:t},e,n)=>{let i=r+e;n?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},Ke=({values:r},t,e)=>{r[t]=e},Fo=({values:r},t,e)=>{r[t]=e},yc=({values:r},t,e)=>{r[t]=zn(e)},oh=(r,t,e)=>{switch(r.type.precision){case K.HALF:return yc(r,t,e);case K.SINGLE:case K.DOUBLE:return Fo(r,t,e)}},Ki=({values:r},t,e)=>{ih(r,t,e.valueOf())},Xi=({values:r},t,e)=>{r[t]=BigInt(e)},To=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},gc=({values:r,valueOffsets:t},e,n)=>mc(r,t,e,n),bc=({values:r,valueOffsets:t},e,n)=>mc(r,t,e,ve(n)),No=(r,t,e)=>{r.type.unit===at.DAY?Ki(r,t,e):Xi(r,t,e)},qi=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},Qi=({values:r},t,e)=>{r[t]=BigInt(e)},ts=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},es=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},Lo=(r,t,e)=>{switch(r.type.unit){case v.SECOND:return qi(r,t,e);case v.MILLISECOND:return Qi(r,t,e);case v.MICROSECOND:return ts(r,t,e);case v.NANOSECOND:return es(r,t,e)}},rs=({values:r},t,e)=>{r[t]=e},ns=({values:r},t,e)=>{r[t]=e},is=({values:r},t,e)=>{r[t]=e},ss=({values:r},t,e)=>{r[t]=e},Uo=(r,t,e)=>{switch(r.type.unit){case v.SECOND:return rs(r,t,e);case v.MILLISECOND:return ns(r,t,e);case v.MICROSECOND:return is(r,t,e);case v.NANOSECOND:return ss(r,t,e)}},Mo=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},ah=(r,t,e)=>{let n=r.children[0],i=r.valueOffsets,s=vt.getVisitFn(n);if(Array.isArray(e))for(let o=-1,a=i[t],c=i[t+1];a<c;)s(n,a++,e[++o]);else for(let o=-1,a=i[t],c=i[t+1];a<c;)s(n,a++,e.get(++o))},ch=(r,t,e)=>{let n=r.children[0],{valueOffsets:i}=r,s=vt.getVisitFn(n),{[t]:o,[t+1]:a}=i,c=e instanceof Map?e.entries():Object.entries(e);for(let l of c)if(s(n,o,l),++o>=a)break},lh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[s]),uh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(s)),hh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(i.name)),fh=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[i.name]),dh=(r,t,e)=>{let n=r.type.children.map(s=>vt.getVisitFn(s.type)),i=e instanceof Map?hh(t,e):e instanceof _?uh(t,e):Array.isArray(e)?lh(t,e):fh(t,e);r.type.children.forEach((s,o)=>i(n[o],r.children[o],s,o))},ph=(r,t,e)=>{r.type.mode===q.Dense?_c(r,t,e):wc(r,t,e)},_c=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];vt.visit(i,r.valueOffsets[t],e)},wc=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];vt.visit(i,t,e)},mh=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},Eo=(r,t,e)=>{r.type.unit===mt.DAY_TIME?os(r,t,e):as(r,t,e)},os=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},as=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},cs=({values:r},t,e)=>{r[t]=e},ls=({values:r},t,e)=>{r[t]=e},us=({values:r},t,e)=>{r[t]=e},hs=({values:r},t,e)=>{r[t]=e},Co=(r,t,e)=>{switch(r.type.unit){case v.SECOND:return cs(r,t,e);case v.MILLISECOND:return ls(r,t,e);case v.MICROSECOND:return us(r,t,e);case v.NANOSECOND:return hs(r,t,e)}},yh=(r,t,e)=>{let{stride:n}=r,i=r.children[0],s=vt.getVisitFn(i);if(Array.isArray(e))for(let o=-1,a=t*n;++o<n;)s(i,a+o,e[o]);else for(let o=-1,a=t*n;++o<n;)s(i,a+o,e.get(o))};D.prototype.visitBool=U(sh);D.prototype.visitInt=U(Ke);D.prototype.visitInt8=U(Ke);D.prototype.visitInt16=U(Ke);D.prototype.visitInt32=U(Ke);D.prototype.visitInt64=U(Ke);D.prototype.visitUint8=U(Ke);D.prototype.visitUint16=U(Ke);D.prototype.visitUint32=U(Ke);D.prototype.visitUint64=U(Ke);D.prototype.visitFloat=U(oh);D.prototype.visitFloat16=U(yc);D.prototype.visitFloat32=U(Fo);D.prototype.visitFloat64=U(Fo);D.prototype.visitUtf8=U(bc);D.prototype.visitLargeUtf8=U(bc);D.prototype.visitBinary=U(gc);D.prototype.visitLargeBinary=U(gc);D.prototype.visitFixedSizeBinary=U(To);D.prototype.visitDate=U(No);D.prototype.visitDateDay=U(Ki);D.prototype.visitDateMillisecond=U(Xi);D.prototype.visitTimestamp=U(Lo);D.prototype.visitTimestampSecond=U(qi);D.prototype.visitTimestampMillisecond=U(Qi);D.prototype.visitTimestampMicrosecond=U(ts);D.prototype.visitTimestampNanosecond=U(es);D.prototype.visitTime=U(Uo);D.prototype.visitTimeSecond=U(rs);D.prototype.visitTimeMillisecond=U(ns);D.prototype.visitTimeMicrosecond=U(is);D.prototype.visitTimeNanosecond=U(ss);D.prototype.visitDecimal=U(Mo);D.prototype.visitList=U(ah);D.prototype.visitStruct=U(dh);D.prototype.visitUnion=U(ph);D.prototype.visitDenseUnion=U(_c);D.prototype.visitSparseUnion=U(wc);D.prototype.visitDictionary=U(mh);D.prototype.visitInterval=U(Eo);D.prototype.visitIntervalDayTime=U(os);D.prototype.visitIntervalYearMonth=U(as);D.prototype.visitDuration=U(Co);D.prototype.visitDurationSecond=U(cs);D.prototype.visitDurationMillisecond=U(ls);D.prototype.visitDurationMicrosecond=U(us);D.prototype.visitDurationNanosecond=U(hs);D.prototype.visitFixedSizeList=U(yh);D.prototype.visitMap=U(ch);var vt=new D;var ge=Symbol.for("parent"),ln=Symbol.for("rowIndex"),fr=class{constructor(t,e){return this[ge]=t,this[ln]=e,new Proxy(this,new Po)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[ln],e=this[ge],n=e.type.children,i={};for(let s=-1,o=n.length;++s<o;)i[n[s].name]=ht.visit(e.children[s],t);return i}toString(){return`{${[...this].map(([t,e])=>`${me(t)}: ${me(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Ro(this[ge],this[ln])}},Ro=class{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,ht.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(fr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[ge]:{writable:!0,enumerable:!1,configurable:!1,value:null},[ln]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var Po=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[ge].type.children.map(e=>e.name)}has(t,e){return t[ge].type.children.findIndex(n=>n.name===e)!==-1}getOwnPropertyDescriptor(t,e){if(t[ge].type.children.findIndex(n=>n.name===e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[ge].type.children.findIndex(i=>i.name===e);if(n!==-1){let i=ht.visit(t[ge].children[n],t[ln]);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[ge].type.children.findIndex(s=>s.name===e);return i!==-1?(vt.visit(t[ge].children[i],t[ln],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}};var S=class extends x{};function N(r){return(t,e)=>t.getValid(e)?r(t,e):null}var gh=(r,t)=>864e5*r[t],bh=(r,t)=>null,vc=(r,t,e)=>{if(e+1>=t.length)return null;let n=W(t[e]),i=W(t[e+1]);return r.subarray(n,i)},_h=({offset:r,values:t},e)=>{let n=r+e;return(t[n>>3]&1<<n%8)!==0},Ic=({values:r},t)=>gh(r,t),xc=({values:r},t)=>W(r[t]),dr=({stride:r,values:t},e)=>t[r*e],wh=({stride:r,values:t},e)=>Zi(t[r*e]),Sc=({values:r},t)=>r[t],vh=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Bc=({values:r,valueOffsets:t},e)=>vc(r,t,e),Ac=({values:r,valueOffsets:t},e)=>{let n=vc(r,t,e);return n!==null?Un(n):null},Ih=({values:r},t)=>r[t],xh=({type:r,values:t},e)=>r.precision!==K.HALF?t[e]:Zi(t[e]),Sh=(r,t)=>r.type.unit===at.DAY?Ic(r,t):xc(r,t),Oc=({values:r},t)=>1e3*W(r[t]),Dc=({values:r},t)=>W(r[t]),Fc=({values:r},t)=>So(r[t],BigInt(1e3)),Tc=({values:r},t)=>So(r[t],BigInt(1e6)),Bh=(r,t)=>{switch(r.type.unit){case v.SECOND:return Oc(r,t);case v.MILLISECOND:return Dc(r,t);case v.MICROSECOND:return Fc(r,t);case v.NANOSECOND:return Tc(r,t)}},Nc=({values:r},t)=>r[t],Lc=({values:r},t)=>r[t],Uc=({values:r},t)=>r[t],Mc=({values:r},t)=>r[t],Ah=(r,t)=>{switch(r.type.unit){case v.SECOND:return Nc(r,t);case v.MILLISECOND:return Lc(r,t);case v.MICROSECOND:return Uc(r,t);case v.NANOSECOND:return Mc(r,t)}},Oh=({values:r,stride:t},e)=>Ir.decimal(r.subarray(t*e,t*(e+1))),Dh=(r,t)=>{let{valueOffsets:e,stride:n,children:i}=r,{[t*n]:s,[t*n+1]:o}=e,c=i[0].slice(s,o-s);return new _([c])},Fh=(r,t)=>{let{valueOffsets:e,children:n}=r,{[t]:i,[t+1]:s}=e,o=n[0];return new Ge(o.slice(i,s-i))},Th=(r,t)=>new fr(r,t),Nh=(r,t)=>r.type.mode===q.Dense?Ec(r,t):Cc(r,t),Ec=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return ht.visit(n,r.valueOffsets[t])},Cc=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return ht.visit(n,t)},Lh=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},Uh=(r,t)=>r.type.unit===mt.DAY_TIME?Rc(r,t):Pc(r,t),Rc=({values:r},t)=>r.subarray(2*t,2*(t+1)),Pc=({values:r},t)=>{let e=r[t],n=new Int32Array(2);return n[0]=Math.trunc(e/12),n[1]=Math.trunc(e%12),n},jc=({values:r},t)=>r[t],kc=({values:r},t)=>r[t],Vc=({values:r},t)=>r[t],zc=({values:r},t)=>r[t],Mh=(r,t)=>{switch(r.type.unit){case v.SECOND:return jc(r,t);case v.MILLISECOND:return kc(r,t);case v.MICROSECOND:return Vc(r,t);case v.NANOSECOND:return zc(r,t)}},Eh=(r,t)=>{let{stride:e,children:n}=r,s=n[0].slice(t*e,e);return new _([s])};S.prototype.visitNull=N(bh);S.prototype.visitBool=N(_h);S.prototype.visitInt=N(Ih);S.prototype.visitInt8=N(dr);S.prototype.visitInt16=N(dr);S.prototype.visitInt32=N(dr);S.prototype.visitInt64=N(Sc);S.prototype.visitUint8=N(dr);S.prototype.visitUint16=N(dr);S.prototype.visitUint32=N(dr);S.prototype.visitUint64=N(Sc);S.prototype.visitFloat=N(xh);S.prototype.visitFloat16=N(wh);S.prototype.visitFloat32=N(dr);S.prototype.visitFloat64=N(dr);S.prototype.visitUtf8=N(Ac);S.prototype.visitLargeUtf8=N(Ac);S.prototype.visitBinary=N(Bc);S.prototype.visitLargeBinary=N(Bc);S.prototype.visitFixedSizeBinary=N(vh);S.prototype.visitDate=N(Sh);S.prototype.visitDateDay=N(Ic);S.prototype.visitDateMillisecond=N(xc);S.prototype.visitTimestamp=N(Bh);S.prototype.visitTimestampSecond=N(Oc);S.prototype.visitTimestampMillisecond=N(Dc);S.prototype.visitTimestampMicrosecond=N(Fc);S.prototype.visitTimestampNanosecond=N(Tc);S.prototype.visitTime=N(Ah);S.prototype.visitTimeSecond=N(Nc);S.prototype.visitTimeMillisecond=N(Lc);S.prototype.visitTimeMicrosecond=N(Uc);S.prototype.visitTimeNanosecond=N(Mc);S.prototype.visitDecimal=N(Oh);S.prototype.visitList=N(Dh);S.prototype.visitStruct=N(Th);S.prototype.visitUnion=N(Nh);S.prototype.visitDenseUnion=N(Ec);S.prototype.visitSparseUnion=N(Cc);S.prototype.visitDictionary=N(Lh);S.prototype.visitInterval=N(Uh);S.prototype.visitIntervalDayTime=N(Rc);S.prototype.visitIntervalYearMonth=N(Pc);S.prototype.visitDuration=N(Mh);S.prototype.visitDurationSecond=N(jc);S.prototype.visitDurationMillisecond=N(kc);S.prototype.visitDurationMicrosecond=N(Vc);S.prototype.visitDurationNanosecond=N(zc);S.prototype.visitFixedSizeList=N(Eh);S.prototype.visitMap=N(Fh);var ht=new S;var pr=Symbol.for("keys"),hn=Symbol.for("vals"),un=Symbol.for("kKeysAsStrings"),jo=Symbol.for("_kKeysAsStrings"),Ge=class{constructor(t){return this[pr]=new _([t.children[0]]).memoize(),this[hn]=t.children[1],new Proxy(this,new Vo)}get[un](){return this[jo]||(this[jo]=Array.from(this[pr].toArray(),String))}[Symbol.iterator](){return new ko(this[pr],this[hn])}get size(){return this[pr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[pr],e=this[hn],n={};for(let i=-1,s=t.length;++i<s;)n[t.get(i)]=ht.visit(e,i);return n}toString(){return`{${[...this].map(([t,e])=>`${me(t)}: ${me(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},ko=class{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){let t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),ht.visit(this.vals,t)]})}},Vo=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[un]}has(t,e){return t[un].includes(e)}getOwnPropertyDescriptor(t,e){if(t[un].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[un].indexOf(e);if(n!==-1){let i=ht.visit(Reflect.get(t,hn),n);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[un].indexOf(e);return i!==-1?(vt.visit(Reflect.get(t,hn),i,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}};Object.defineProperties(Ge.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[pr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[hn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[jo]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var Wc;function Wn(r,t,e,n){let{length:i=0}=r,s=typeof t!="number"?0:t,o=typeof e!="number"?i:e;return s<0&&(s=(s%i+i)%i),o<0&&(o=(o%i+i)%i),o<s&&(Wc=s,s=o,o=Wc),o>i&&(o=i),n?n(r,s,o):[s,o]}var Nr=(r,t)=>r<0?t+r:r,Gc=r=>r!==r;function mr(r){if(typeof r!=="object"||r===null)return Gc(r)?Gc:e=>e===r;if(r instanceof Date){let e=r.valueOf();return n=>n instanceof Date?n.valueOf()===e:!1}return ArrayBuffer.isView(r)?e=>e?_o(r,e):!1:r instanceof Map?Rh(r):Array.isArray(r)?Ch(r):r instanceof _?Ph(r):jh(r,!0)}function Ch(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=mr(r[e]);return fs(t)}function Rh(r){let t=-1,e=[];for(let n of r.values())e[++t]=mr(n);return fs(e)}function Ph(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=mr(r.get(e));return fs(t)}function jh(r,t=!1){let e=Object.keys(r);if(!t&&e.length===0)return()=>!1;let n=[];for(let i=-1,s=e.length;++i<s;)n[i]=mr(r[e[i]]);return fs(n,e)}function fs(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return kh(r,e);case Map:return Jc(r,e,e.keys());case Ge:case fr:case Object:case void 0:return Jc(r,e,t||Object.keys(e))}return e instanceof _?Vh(r,e):!1}}function kh(r,t){let e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t[n]))return!1;return!0}function Vh(r,t){let e=r.length;if(t.length!==e)return!1;for(let n=-1;++n<e;)if(!r[n](t.get(n)))return!1;return!0}function Jc(r,t,e){let n=e[Symbol.iterator](),i=t instanceof Map?t.keys():Object.keys(t)[Symbol.iterator](),s=t instanceof Map?t.values():Object.values(t)[Symbol.iterator](),o=0,a=r.length,c=s.next(),l=n.next(),u=i.next();for(;o<a&&!l.done&&!u.done&&!c.done&&!(l.value!==u.value||!r[o](c.value));++o,l=n.next(),u=i.next(),c=s.next());return o===a&&l.done&&u.done&&c.done?!0:(n.return&&n.return(),i.return&&i.return(),s.return&&s.return(),!1)}var Wo={};ur(Wo,{BitIterator:()=>Lr,getBit:()=>$c,getBool:()=>ps,packBools:()=>Mr,popcnt_array:()=>Hc,popcnt_bit_range:()=>Gn,popcnt_uint32:()=>ds,setBool:()=>zh,truncateBitmap:()=>Ur});function ps(r,t,e,n){return(e&1<<n)!==0}function $c(r,t,e,n){return(e&1<<n)>>n}function zh(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function Ur(r,t,e){let n=e.byteLength+7&-8;if(r>0||e.byteLength<n){let i=new Uint8Array(n);return i.set(r%8===0?e.subarray(r>>3):Mr(new Lr(e,r,t,null,ps)).subarray(0,n)),i}return e}function Mr(r){let t=[],e=0,n=0,i=0;for(let o of r)o&&(i|=1<<n),++n===8&&(t[e++]=i,i=n=0);(e===0||n>0)&&(t[e++]=i);let s=new Uint8Array(t.length+7&-8);return s.set(t),s}var Lr=class{constructor(t,e,n,i,s){this.bytes=t,this.length=n,this.context=i,this.get=s,this.bit=e%8,this.byteIndex=e>>3,this.byte=t[this.byteIndex++],this.index=0}next(){return this.index<this.length?(this.bit===8&&(this.bit=0,this.byte=this.bytes[this.byteIndex++]),{value:this.get(this.context,this.index++,this.byte,this.bit++)}):{done:!0,value:null}}[Symbol.iterator](){return this}};function Gn(r,t,e){if(e-t<=0)return 0;if(e-t<8){let s=0;for(let o of new Lr(r,t,e-t,r,$c))s+=o;return s}let n=e>>3<<3,i=t+(t%8===0?0:8-t%8);return Gn(r,t,i)+Gn(r,n,e)+Hc(r,i>>3,n-i>>3)}function Hc(r,t,e){let n=0,i=Math.trunc(t),s=new DataView(r.buffer,r.byteOffset,r.byteLength),o=e===void 0?r.byteLength:i+e;for(;o-i>=4;)n+=ds(s.getUint32(i)),i+=4;for(;o-i>=2;)n+=ds(s.getUint16(i)),i+=2;for(;o-i>=1;)n+=ds(s.getUint8(i)),i+=1;return n}function ds(r){let t=Math.trunc(r);return t=t-(t>>>1&1431655765),t=(t&858993459)+(t>>>2&858993459),(t+(t>>>4)&252645135)*16843009>>>24}var Wh=-1,k=class{get typeId(){return this.type.typeId}get ArrayType(){return this.type.ArrayType}get buffers(){return[this.valueOffsets,this.values,this.nullBitmap,this.typeIds]}get nullable(){if(this._nullCount!==0){let{type:t}=this;return m.isSparseUnion(t)?this.children.some(e=>e.nullable):m.isDenseUnion(t)?this.children.some(e=>e.nullable):this.nullBitmap&&this.nullBitmap.byteLength>0}return!0}get byteLength(){let t=0,{valueOffsets:e,values:n,nullBitmap:i,typeIds:s}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),this.children.reduce((o,a)=>o+a.byteLength,t)}get nullCount(){if(m.isUnion(this.type))return this.children.reduce((n,i)=>n+i.nullCount,0);let t=this._nullCount,e;return t<=Wh&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Gn(e,this.offset,this.offset+this.length)),t}constructor(t,e,n,i,s,o=[],a){this.type=t,this.children=o,this.dictionary=a,this.offset=Math.floor(Math.max(e||0,0)),this.length=Math.floor(Math.max(n||0,0)),this._nullCount=Math.floor(Math.max(i||0,-1));let c;s instanceof k?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=qt(t),s&&((c=s[0])&&(this.valueOffsets=c),(c=s[1])&&(this.values=c),(c=s[2])&&(this.nullBitmap=c),(c=s[3])&&(this.typeIds=c)))}getValid(t){let{type:e}=this;if(m.isUnion(e)){let n=e,i=this.children[n.typeIdToChildIndex[this.typeIds[t]]],s=n.mode===q.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){let n=this.offset+t;return(this.nullBitmap[n>>3]&1<<n%8)!==0}return!0}setValid(t,e){let n,{type:i}=this;if(m.isUnion(i)){let s=i,o=this.children[s.typeIdToChildIndex[this.typeIds[t]]],a=s.mode===q.Dense?this.valueOffsets[t]:t;n=o.getValid(a),o.setValid(a,e)}else{let{nullBitmap:s}=this,{offset:o,length:a}=this,c=o+t,l=1<<c%8,u=c>>3;(!s||s.byteLength<=u)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(Ur(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let f=s[u];n=(f&l)!==0,s[u]=e?f|l:f&~l}return n!==!!e&&(this._nullCount=this.nullCount+(e?-1:1)),e}clone(t=this.type,e=this.offset,n=this.length,i=this._nullCount,s=this,o=this.children){return new k(t,e,n,i,s,o,this.dictionary)}slice(t,e){let{stride:n,typeId:i,children:s}=this,o=+(this._nullCount===0)-1,a=i===16?n:1,c=this._sliceBuffers(t,e,n,i);return this.clone(this.type,this.offset+t,e,o,c,s.length===0||this.valueOffsets?s:this._sliceChildren(s,a*t,a*e))}_changeLengthAndBackfillNullBitmap(t){if(this.typeId===h.Null)return this.clone(this.type,0,t,0);let{length:e,nullCount:n}=this,i=new Uint8Array((t+63&-64)>>3).fill(255,0,e>>3);i[e>>3]=(1<<e-(e&-8))-1,n>0&&i.set(Ur(this.offset,e,this.nullBitmap),0);let s=this.buffers;return s[pe.VALIDITY]=i,this.clone(this.type,0,t,n+(t-e),s)}_sliceBuffers(t,e,n,i){let s,{buffers:o}=this;return(s=o[pe.TYPE])&&(o[pe.TYPE]=s.subarray(t,t+e)),(s=o[pe.OFFSET])&&(o[pe.OFFSET]=s.subarray(t,t+e+1))||(s=o[pe.DATA])&&(o[pe.DATA]=i===6?s:s.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map(i=>i.slice(e,n))}};k.prototype.children=Object.freeze([]);var Er=class extends x{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:e,["offset"]:n=0,["length"]:i=0}=t;return new k(e,n,i,i)}visitBool(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitInt(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitFloat(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.data),s=T(t.nullBitmap),o=vr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[o,i,s])}visitLargeUtf8(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.data),s=T(t.nullBitmap),o=Wi(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[o,i,s])}visitBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.data),s=T(t.nullBitmap),o=vr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[o,i,s])}visitLargeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.data),s=T(t.nullBitmap),o=Wi(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[o,i,s])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitDate(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitTimestamp(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitTime(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitDecimal(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitList(t){let{["type"]:e,["offset"]:n=0,["child"]:i}=t,s=T(t.nullBitmap),o=vr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[o,void 0,s],[i])}visitStruct(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=T(t.nullBitmap),{length:o=i.reduce((c,{length:l})=>Math.max(c,l),0),nullCount:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,void 0,s],i)}visitUnion(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=R(e.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=t;if(m.isSparseUnion(e))return new k(e,n,o,a,[void 0,void 0,void 0,s],i);let c=vr(t.valueOffsets);return new k(e,n,o,a,[c,void 0,void 0,s],i)}visitDictionary(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.indices.ArrayType,t.data),{["dictionary"]:o=new _([new Er().visit({type:e.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[void 0,s,i],[],o)}visitInterval(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitDuration(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,s,i])}visitFixedSizeList(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new Er().visit({type:e.valueType})}=t,s=T(t.nullBitmap),{["length"]:o=i.length/qt(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new k(e,n,o,a,[void 0,void 0,s],[i])}visitMap(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new Er().visit({type:e.childType})}=t,s=T(t.nullBitmap),o=vr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new k(e,n,a,c,[o,void 0,s],[i])}},Gh=new Er;function w(r){return Gh.visit(r)}var Jn=class{constructor(t=0,e){this.numChunks=t,this.getChunkIterator=e,this.chunkIndex=0,this.chunkIterator=this.getChunkIterator(0)}next(){for(;this.chunkIndex<this.numChunks;){let t=this.chunkIterator.next();if(!t.done)return t;++this.chunkIndex<this.numChunks&&(this.chunkIterator=this.getChunkIterator(this.chunkIndex))}return{done:!0,value:null}}[Symbol.iterator](){return this}};function Yc(r){return r.some(t=>t.nullable)}function ms(r){return r.reduce((t,e)=>t+e.nullCount,0)}function ys(r){return r.reduce((t,e,n)=>(t[n+1]=t[n]+e.length,t),new Uint32Array(r.length+1))}function gs(r,t,e,n){let i=[];for(let s=-1,o=r.length;++s<o;){let a=r[s],c=t[s],{length:l}=a;if(c>=n)break;if(e>=c+l)continue;if(c>=e&&c+l<=n){i.push(a);continue}let u=Math.max(0,e-c),f=Math.min(n-c,l);i.push(a.slice(u,f-u))}return i.length===0&&i.push(r[0].slice(0,0)),i}function Go(r,t,e,n){let i=0,s=0,o=t.length-1;do{if(i>=o-1)return e<t[o]?n(r,i,e-t[i]):null;s=i+Math.trunc((o-i)*.5),e<t[s]?o=s:i=s}while(i<o)}function $n(r,t){return r.getValid(t)}function fn(r){function t(e,n,i){return r(e[n],i)}return function(e){let n=this.data;return Go(n,this._offsets,e,t)}}function bs(r){let t;function e(n,i,s){return r(n[i],s,t)}return function(n,i){let s=this.data;t=i;let o=Go(s,this._offsets,n,e);return t=void 0,o}}function _s(r){let t;function e(n,i,s){let o=s,a=0,c=0;for(let l=i-1,u=n.length;++l<u;){let f=n[l];if(~(a=r(f,t,o)))return c+a;o=0,c+=f.length}return-1}return function(n,i){t=n;let s=this.data,o=typeof i!="number"?e(s,0,0):Go(s,this._offsets,i,e);return t=void 0,o}}var B=class extends x{};function Jh(r,t){return t===null&&r.length>0?0:-1}function $h(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(let i of new Lr(e,r.offset+(t||0),r.length,e,ps)){if(!i)return n;++n}return-1}function M(r,t,e){if(t===void 0)return-1;if(t===null)switch(r.typeId){case h.Union:break;case h.Dictionary:break;default:return $h(r,e)}let n=ht.getVisitFn(r),i=mr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}function Zc(r,t,e){let n=ht.getVisitFn(r),i=mr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}B.prototype.visitNull=Jh;B.prototype.visitBool=M;B.prototype.visitInt=M;B.prototype.visitInt8=M;B.prototype.visitInt16=M;B.prototype.visitInt32=M;B.prototype.visitInt64=M;B.prototype.visitUint8=M;B.prototype.visitUint16=M;B.prototype.visitUint32=M;B.prototype.visitUint64=M;B.prototype.visitFloat=M;B.prototype.visitFloat16=M;B.prototype.visitFloat32=M;B.prototype.visitFloat64=M;B.prototype.visitUtf8=M;B.prototype.visitLargeUtf8=M;B.prototype.visitBinary=M;B.prototype.visitLargeBinary=M;B.prototype.visitFixedSizeBinary=M;B.prototype.visitDate=M;B.prototype.visitDateDay=M;B.prototype.visitDateMillisecond=M;B.prototype.visitTimestamp=M;B.prototype.visitTimestampSecond=M;B.prototype.visitTimestampMillisecond=M;B.prototype.visitTimestampMicrosecond=M;B.prototype.visitTimestampNanosecond=M;B.prototype.visitTime=M;B.prototype.visitTimeSecond=M;B.prototype.visitTimeMillisecond=M;B.prototype.visitTimeMicrosecond=M;B.prototype.visitTimeNanosecond=M;B.prototype.visitDecimal=M;B.prototype.visitList=M;B.prototype.visitStruct=M;B.prototype.visitUnion=M;B.prototype.visitDenseUnion=Zc;B.prototype.visitSparseUnion=Zc;B.prototype.visitDictionary=M;B.prototype.visitInterval=M;B.prototype.visitIntervalDayTime=M;B.prototype.visitIntervalYearMonth=M;B.prototype.visitDuration=M;B.prototype.visitDurationSecond=M;B.prototype.visitDurationMillisecond=M;B.prototype.visitDurationMicrosecond=M;B.prototype.visitDurationNanosecond=M;B.prototype.visitFixedSizeList=M;B.prototype.visitMap=M;var Cr=new B;var A=class extends x{};function L(r){let{type:t}=r;if(r.nullCount===0&&r.stride===1&&(m.isInt(t)&&t.bitWidth!==64||m.isTime(t)&&t.bitWidth!==64||m.isFloat(t)&&t.precision!==K.HALF))return new Jn(r.data.length,n=>{let i=r.data[n];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new Jn(r.data.length,n=>{let s=r.data[n].length,o=r.slice(e,e+s);return e+=s,new Jo(o)})}var Jo=class{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}};A.prototype.visitNull=L;A.prototype.visitBool=L;A.prototype.visitInt=L;A.prototype.visitInt8=L;A.prototype.visitInt16=L;A.prototype.visitInt32=L;A.prototype.visitInt64=L;A.prototype.visitUint8=L;A.prototype.visitUint16=L;A.prototype.visitUint32=L;A.prototype.visitUint64=L;A.prototype.visitFloat=L;A.prototype.visitFloat16=L;A.prototype.visitFloat32=L;A.prototype.visitFloat64=L;A.prototype.visitUtf8=L;A.prototype.visitLargeUtf8=L;A.prototype.visitBinary=L;A.prototype.visitLargeBinary=L;A.prototype.visitFixedSizeBinary=L;A.prototype.visitDate=L;A.prototype.visitDateDay=L;A.prototype.visitDateMillisecond=L;A.prototype.visitTimestamp=L;A.prototype.visitTimestampSecond=L;A.prototype.visitTimestampMillisecond=L;A.prototype.visitTimestampMicrosecond=L;A.prototype.visitTimestampNanosecond=L;A.prototype.visitTime=L;A.prototype.visitTimeSecond=L;A.prototype.visitTimeMillisecond=L;A.prototype.visitTimeMicrosecond=L;A.prototype.visitTimeNanosecond=L;A.prototype.visitDecimal=L;A.prototype.visitList=L;A.prototype.visitStruct=L;A.prototype.visitUnion=L;A.prototype.visitDenseUnion=L;A.prototype.visitSparseUnion=L;A.prototype.visitDictionary=L;A.prototype.visitInterval=L;A.prototype.visitIntervalDayTime=L;A.prototype.visitIntervalYearMonth=L;A.prototype.visitDuration=L;A.prototype.visitDurationSecond=L;A.prototype.visitDurationMillisecond=L;A.prototype.visitDurationMicrosecond=L;A.prototype.visitDurationNanosecond=L;A.prototype.visitFixedSizeList=L;A.prototype.visitMap=L;var dn=new A;var Kc,Xc={},qc={},_=class{constructor(t){var e,n,i;let s=t[0]instanceof _?t.flatMap(a=>a.data):t;if(s.length===0||s.some(a=>!(a instanceof k)))throw new TypeError("Vector constructor expects an Array of Data instances.");let o=(e=s[0])===null||e===void 0?void 0:e.type;switch(s.length){case 0:this._offsets=[0];break;case 1:{let{get:a,set:c,indexOf:l}=Xc[o.typeId],u=s[0];this.isValid=f=>$n(u,f),this.get=f=>a(u,f),this.set=(f,d)=>c(u,f,d),this.indexOf=f=>l(u,f),this._offsets=[0,u.length];break}default:Object.setPrototypeOf(this,qc[o.typeId]),this._offsets=ys(s);break}this.data=s,this.type=o,this.stride=qt(o),this.numChildren=(i=(n=o.children)===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0,this.length=this._offsets.at(-1)}get byteLength(){return this.data.reduce((t,e)=>t+e.byteLength,0)}get nullable(){return Yc(this.data)}get nullCount(){return ms(this.data)}get ArrayType(){return this.type.ArrayType}get[Symbol.toStringTag](){return`${this.VectorName}<${this.type[Symbol.toStringTag]}>`}get VectorName(){return`${h[this.type.typeId]}Vector`}isValid(t){return!1}get(t){return null}at(t){return this.get(Nr(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return dn.visit(this)}concat(...t){return new _(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new _(Wn(this,t,e,({data:n,_offsets:i},s,o)=>gs(n,i,s,o)))}toJSON(){return[...this]}toArray(){let{type:t,data:e,length:n,stride:i,ArrayType:s}=this;switch(t.typeId){case h.Int:case h.Float:case h.Decimal:case h.Time:case h.Timestamp:switch(e.length){case 0:return new s;case 1:return e[0].values.subarray(0,n*i);default:return e.reduce((o,{values:a,length:c})=>(o.array.set(a.subarray(0,c*i),o.offset),o.offset+=c*i,o),{array:new s(n*i),offset:0}).array}}return[...this]}toString(){return`[${[...this].join(",")}]`}getChild(t){var e;return this.getChildAt((e=this.type.children)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.numChildren?new _(this.data.map(({children:e})=>e[t])):null}get isMemoized(){return m.isDictionary(this.type)?this.data[0].dictionary.isMemoized:!1}memoize(){if(m.isDictionary(this.type)){let t=new pn(this.data[0].dictionary),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new _(e)}return new pn(this)}unmemoize(){if(m.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new _(e)}return this}};Kc=Symbol.toStringTag;_[Kc]=(r=>{r.type=m.prototype,r.data=[],r.length=0,r.stride=1,r.numChildren=0,r._offsets=new Uint32Array([0]),r[Symbol.isConcatSpreadable]=!0;let t=Object.keys(h).map(e=>h[e]).filter(e=>typeof e=="number"&&e!==h.NONE);for(let e of t){let n=ht.getVisitFnByTypeId(e),i=vt.getVisitFnByTypeId(e),s=Cr.getVisitFnByTypeId(e);Xc[e]={get:n,set:i,indexOf:s},qc[e]=Object.create(r,{isValid:{value:fn($n)},get:{value:fn(ht.getVisitFnByTypeId(e))},set:{value:bs(vt.getVisitFnByTypeId(e))},indexOf:{value:_s(Cr.getVisitFnByTypeId(e))}})}return"Vector"})(_.prototype);var pn=class extends _{constructor(t){super(t.data);let e=this.get,n=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=s[o];if(a!==void 0)return a;let c=e.call(this,o);return s[o]=c,c}}),Object.defineProperty(this,"set",{value(o,a){n.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new pn(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new _(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function mn(r){if(r){if(r instanceof k)return new _([r]);if(r instanceof _)return new _(r.data);if(r.type instanceof m)return new _([w(r)]);if(Array.isArray(r))return new _(r.flatMap(t=>Hh(t)));if(ArrayBuffer.isView(r)){r instanceof DataView&&(r=new Uint8Array(r.buffer));let t={offset:0,length:r.length,nullCount:-1,data:r};if(r instanceof Int8Array)return new _([w(Object.assign(Object.assign({},t),{type:new xr}))]);if(r instanceof Int16Array)return new _([w(Object.assign(Object.assign({},t),{type:new Sr}))]);if(r instanceof Int32Array)return new _([w(Object.assign(Object.assign({},t),{type:new Kt}))]);if(r instanceof BigInt64Array)return new _([w(Object.assign(Object.assign({},t),{type:new Br}))]);if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return new _([w(Object.assign(Object.assign({},t),{type:new Ar}))]);if(r instanceof Uint16Array)return new _([w(Object.assign(Object.assign({},t),{type:new Or}))]);if(r instanceof Uint32Array)return new _([w(Object.assign(Object.assign({},t),{type:new Dr}))]);if(r instanceof BigUint64Array)return new _([w(Object.assign(Object.assign({},t),{type:new Fr}))]);if(r instanceof Float32Array)return new _([w(Object.assign(Object.assign({},t),{type:new Ze}))]);if(r instanceof Float64Array)return new _([w(Object.assign(Object.assign({},t),{type:new Tr}))]);throw new Error("Unrecognized input")}}throw new Error("Unrecognized input")}function Hh(r){return r instanceof k?[r]:r instanceof _?r.data:mn(r).data}function Qc(r){if(!r||r.length<=0)return function(i){return!0};let t="",e=r.filter(n=>n===n);return e.length>0&&(t=`
7
+ "use strict";var __exports__=(()=>{var Uu=Object.create;var Rn=Object.defineProperty;var Cu=Object.getOwnPropertyDescriptor;var Ru=Object.getOwnPropertyNames;var Pu=Object.getPrototypeOf,ju=Object.prototype.hasOwnProperty;var Vu=(r,t,e)=>t in r?Rn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var ku=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),Ze=(r,t)=>{for(var e in t)Rn(r,e,{get:t[e],enumerable:!0})},Pi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ru(t))!ju.call(r,i)&&i!==e&&Rn(r,i,{get:()=>t[i],enumerable:!(n=Cu(t,i))||n.enumerable});return r},ji=(r,t,e)=>(Pi(r,t,"default"),e&&Pi(e,t,"default")),zu=(r,t,e)=>(e=r!=null?Uu(Pu(r)):{},Pi(t||!r||!r.__esModule?Rn(e,"default",{value:r,enumerable:!0}):e,r)),Wu=r=>Pi(Rn({},"__esModule",{value:!0}),r);var $a=(r,t,e)=>(Vu(r,typeof t!="symbol"?t+"":t,e),e);var Ya=ku((jp,Ha)=>{Ha.exports=globalThis.loaders});var Ri={};Ze(Ri,{JSONLoader:()=>go,JSONWriter:()=>bu,NDJSONLoader:()=>gu,_ClarinetParser:()=>tn,_GeoJSONLoader:()=>rn,_GeoJSONWorkerLoader:()=>Ja,_GeoJSONWriter:()=>Eu,_JSONPath:()=>Lt,_rebuildJsonObject:()=>pu});ji(Ri,zu(Ya(),1));function Vi(r,t="float32"){return r instanceof Date?"date-millisecond":r instanceof Number?t:typeof r=="string"?"utf8":(r===null||r==="undefined","null")}function Za(r){let t=Ju(r);return t!=="null"?{type:t,nullable:!1}:r.length>0?(t=Vi(r[0]),{type:t,nullable:!0}):{type:"null",nullable:!0}}function Ju(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 Ka(r,t){if(!t)switch(r){case"int8":return Int8Array;case"uint8":return Uint8Array;case"int16":return Int16Array;case"uint16":return Uint16Array;case"int32":return Int32Array;case"uint32":return Uint32Array;case"float32":return Float32Array;case"float64":return Float64Array;default:break}return Array}function qa(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 Xa(r){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&r[t],n=0;if(e)return e.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&n>=r.length&&(r=void 0),{value:r&&r[n++],done:!r}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function C(r){return this instanceof C?(this.v=r,this):new C(r)}function Zt(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(y){return Promise.resolve(y).then(p,h)}}function a(p,y){n[p]&&(i[p]=function(z){return new Promise(function(it,Mt){s.push([p,z,it,Mt])>1||c(p,z)})},y&&(i[p]=y(i[p])))}function c(p,y){try{l(n[p](y))}catch(z){d(s[0][3],z)}}function l(p){p.value instanceof C?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,y){p(y),s.shift(),s.length&&c(s[0][0],s[0][1])}}function nn(r){var t,e;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=r[i]?function(o){return(e=!e)?{value:C(r[i](o)),done:!1}:s?s(o):o}:s}}function ue(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 Xa=="function"?Xa(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 Oo={};Ze(Oo,{compareArrayLike:()=>Ao,joinUint8Arrays:()=>Kt,memcpy:()=>Vn,rebaseValueOffsets:()=>Yi,toArrayBufferView:()=>R,toArrayBufferViewAsyncIterator:()=>de,toArrayBufferViewIterator:()=>xe,toBigInt64Array:()=>Hi,toBigUint64Array:()=>qu,toFloat32Array:()=>Qu,toFloat32ArrayAsyncIterator:()=>yf,toFloat32ArrayIterator:()=>cf,toFloat64Array:()=>tf,toFloat64ArrayAsyncIterator:()=>gf,toFloat64ArrayIterator:()=>lf,toInt16Array:()=>Zu,toInt16ArrayAsyncIterator:()=>hf,toInt16ArrayIterator:()=>nf,toInt32Array:()=>xr,toInt32ArrayAsyncIterator:()=>df,toInt32ArrayIterator:()=>sf,toInt8Array:()=>Yu,toInt8ArrayAsyncIterator:()=>ff,toInt8ArrayIterator:()=>rf,toUint16Array:()=>Ku,toUint16ArrayAsyncIterator:()=>pf,toUint16ArrayIterator:()=>of,toUint32Array:()=>Xu,toUint32ArrayAsyncIterator:()=>mf,toUint32ArrayIterator:()=>af,toUint8Array:()=>T,toUint8ArrayAsyncIterator:()=>Bo,toUint8ArrayIterator:()=>So,toUint8ClampedArray:()=>ef,toUint8ClampedArrayAsyncIterator:()=>bf,toUint8ClampedArrayIterator:()=>uf});var Qa=new TextDecoder("utf-8"),Pn=Qa.decode.bind(Qa),Gu=new TextEncoder,Ie=r=>Gu.encode(r);var $u=r=>typeof r=="number",tc=r=>typeof r=="boolean",gt=r=>typeof r=="function",Et=r=>r!=null&&Object(r)===r,fe=r=>Et(r)&&gt(r.then);var he=r=>Et(r)&&gt(r[Symbol.iterator]),ee=r=>Et(r)&&gt(r[Symbol.asyncIterator]),ki=r=>Et(r)&&Et(r.schema);var zi=r=>Et(r)&&"done"in r&&"value"in r;var Wi=r=>Et(r)&&gt(r.stat)&&$u(r.fd);var Ji=r=>Et(r)&&jn(r.body),Gi=r=>"_getDOMStream"in r&&"_getNodeStream"in r,ec=r=>Et(r)&&gt(r.abort)&&gt(r.getWriter)&&!Gi(r),jn=r=>Et(r)&&gt(r.cancel)&&gt(r.getReader)&&!Gi(r),rc=r=>Et(r)&&gt(r.end)&&gt(r.write)&&tc(r.writable)&&!Gi(r),$i=r=>Et(r)&&gt(r.read)&&gt(r.pipe)&&tc(r.readable)&&!Gi(r),nc=r=>Et(r)&&gt(r.clear)&&gt(r.bytes)&&gt(r.position)&&gt(r.setPosition)&&gt(r.capacity)&&gt(r.getBufferIdentifier)&&gt(r.createLong);var xo=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:ArrayBuffer;function Hu(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 Vn(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 Kt(r,t){let e=Hu(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?Vn(o,s,a):o=s;break}Vn(o||(o=new Uint8Array(l)),s,a),a+=s.length}return[o||new Uint8Array(0),e.slice(c),n-(o?o.byteLength:0)]}function R(r,t){let e=zi(t)?t.value:t;return e instanceof r?r===Uint8Array?new r(e.buffer,e.byteOffset,e.byteLength):e:e?(typeof e=="string"&&(e=Ie(e)),e instanceof ArrayBuffer?new r(e):e instanceof xo?new r(e):nc(e)?R(r,e.bytes()):ArrayBuffer.isView(e)?e.byteLength<=0?new r(0):new r(e.buffer,e.byteOffset,e.byteLength/r.BYTES_PER_ELEMENT):r.from(e)):new r(0)}var Yu=r=>R(Int8Array,r),Zu=r=>R(Int16Array,r),xr=r=>R(Int32Array,r),Hi=r=>R(BigInt64Array,r),T=r=>R(Uint8Array,r),Ku=r=>R(Uint16Array,r),Xu=r=>R(Uint32Array,r),qu=r=>R(BigUint64Array,r),Qu=r=>R(Float32Array,r),tf=r=>R(Float64Array,r),ef=r=>R(Uint8ClampedArray,r),Io=r=>(r.next(),r);function*xe(r,t){let e=function*(i){yield i},n=typeof t=="string"||ArrayBuffer.isView(t)||t instanceof ArrayBuffer||t instanceof xo?e(t):he(t)?t:e(t);return yield*Io(function*(i){let s=null;do s=i.next(yield R(r,s));while(!s.done)}(n[Symbol.iterator]())),new r}var rf=r=>xe(Int8Array,r),nf=r=>xe(Int16Array,r),sf=r=>xe(Int32Array,r),So=r=>xe(Uint8Array,r),of=r=>xe(Uint16Array,r),af=r=>xe(Uint32Array,r),cf=r=>xe(Float32Array,r),lf=r=>xe(Float64Array,r),uf=r=>xe(Uint8ClampedArray,r);function de(r,t){return Zt(this,arguments,function*(){if(fe(t))return yield C(yield C(yield*nn(ue(de(r,yield C(t))))));let n=function(o){return Zt(this,arguments,function*(){yield yield C(yield C(o))})},i=function(o){return Zt(this,arguments,function*(){yield C(yield*nn(ue(Io(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 xo?n(t):he(t)?i(t):ee(t)?t:n(t);return yield C(yield*nn(ue(Io(function(o){return Zt(this,arguments,function*(){let a=null;do a=yield C(o.next(yield yield C(R(r,a))));while(!a.done)})}(s[Symbol.asyncIterator]()))))),yield C(new r)})}var ff=r=>de(Int8Array,r),hf=r=>de(Int16Array,r),df=r=>de(Int32Array,r),Bo=r=>de(Uint8Array,r),pf=r=>de(Uint16Array,r),mf=r=>de(Uint32Array,r),yf=r=>de(Float32Array,r),gf=r=>de(Float64Array,r),bf=r=>de(Uint8ClampedArray,r);function Yi(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 Ao(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 xt={fromIterable(r){return Zi(_f(r))},fromAsyncIterable(r){return Zi(wf(r))},fromDOMStream(r){return Zi(vf(r))},fromNodeStream(r){return Zi(If(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')}},Zi=r=>(r.next(),r);function*_f(r){let t,e=!1,n=[],i,s,o,a=0;function c(){return s==="peek"?Kt(n,o)[0]:([i,n,a]=Kt(n,o),i)}({cmd:s,size:o}=(yield(()=>null)())||{cmd:"read",size:0});let l=So(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 wf(r){return Zt(this,arguments,function*(){let e,n=!1,i=[],s,o,a,c=0;function l(){return o==="peek"?Kt(i,a)[0]:([s,i,c]=Kt(i,a),s)}({cmd:o,size:a}=(yield yield C((()=>null)()))||{cmd:"read",size:0});let u=Bo(r)[Symbol.asyncIterator]();try{do if({done:e,value:s}=Number.isNaN(a-c)?yield C(u.next()):yield C(u.next(a-c)),!e&&s.byteLength>0&&(i.push(s),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield C(l()));while(a<c);while(!e)}catch(h){n=!0,typeof u.throw=="function"&&(yield C(u.throw(h)))}finally{n===!1&&typeof u.return=="function"&&(yield C(u.return(new Uint8Array(0))))}return yield C(null)})}function vf(r){return Zt(this,arguments,function*(){let e=!1,n=!1,i=[],s,o,a,c=0;function l(){return o==="peek"?Kt(i,a)[0]:([s,i,c]=Kt(i,a),s)}({cmd:o,size:a}=(yield yield C((()=>null)()))||{cmd:"read",size:0});let u=new To(r);try{do if({done:e,value:s}=Number.isNaN(a-c)?yield C(u.read()):yield C(u.read(a-c)),!e&&s.byteLength>0&&(i.push(T(s)),c+=s.byteLength),e||a<=c)do({cmd:o,size:a}=yield yield C(l()));while(a<c);while(!e)}catch(h){n=!0,yield C(u.cancel(h))}finally{n===!1?yield C(u.cancel()):r.locked&&u.releaseLock()}return yield C(null)})}var To=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=T(e)),e})}},Do=(r,t)=>{let e=i=>n([t,i]),n;return[t,e,new Promise(i=>(n=i)&&r.once(t,e))]};function If(r){return Zt(this,arguments,function*(){let e=[],n="error",i=!1,s=null,o,a,c=0,l=[],u;function h(){return o==="peek"?Kt(l,a)[0]:([u,l,c]=Kt(l,a),u)}if({cmd:o,size:a}=(yield yield C((()=>null)()))||{cmd:"read",size:0},r.isTTY)return yield yield C(new Uint8Array(0)),yield C(null);try{e[0]=Do(r,"end"),e[1]=Do(r,"error");do{if(e[2]=Do(r,"readable"),[n,s]=yield C(Promise.race(e.map(p=>p[2]))),n==="error")break;if((i=n==="end")||(Number.isFinite(a-c)?(u=T(r.read(a-c)),u.byteLength<a-c&&(u=T(r.read()))):u=T(r.read()),u.byteLength>0&&(l.push(u),c+=u.byteLength)),i||a<=c)do({cmd:o,size:a}=yield yield C(h()));while(a<c)}while(!i)}finally{yield C(d(e,n==="error"?s:null))}return yield C(null);function d(p,y){return u=l=null,new Promise((z,it)=>{for(let[Mt,cr]of p)r.off(Mt,cr);try{let Mt=r.destroy;Mt&&Mt.call(r,y),y=void 0}catch(Mt){y=Mt||y}finally{y!=null?it(y):z()}})}})}var H;(function(r){r[r.V1=0]="V1",r[r.V2=1]="V2",r[r.V3=2]="V3",r[r.V4=3]="V4",r[r.V5=4]="V5"})(H||(H={}));var q;(function(r){r[r.Sparse=0]="Sparse",r[r.Dense=1]="Dense"})(q||(q={}));var K;(function(r){r[r.HALF=0]="HALF",r[r.SINGLE=1]="SINGLE",r[r.DOUBLE=2]="DOUBLE"})(K||(K={}));var ct;(function(r){r[r.DAY=0]="DAY",r[r.MILLISECOND=1]="MILLISECOND"})(ct||(ct={}));var v;(function(r){r[r.SECOND=0]="SECOND",r[r.MILLISECOND=1]="MILLISECOND",r[r.MICROSECOND=2]="MICROSECOND",r[r.NANOSECOND=3]="NANOSECOND"})(v||(v={}));var Q;(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"})(Q||(Q={}));var Se=new Int32Array(2),Ki=new Float32Array(Se.buffer),Xi=new Float64Array(Se.buffer),sn=new Uint16Array(new Uint8Array([1,0]).buffer)[0]===1;var kn;(function(r){r[r.UTF8_BYTES=1]="UTF8_BYTES",r[r.UTF16_STRING=2]="UTF16_STRING"})(kn||(kn={}));var bt=class{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new bt(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 Se[0]=this.readInt32(t),Ki[0]}readFloat64(t){return Se[sn?0:1]=this.readInt32(t),Se[sn?1:0]=this.readInt32(t+4),Xi[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){Ki[0]=e,this.writeInt32(t,Se[0])}writeFloat64(t,e){Xi[0]=e,this.writeInt32(t,Se[sn?0:1]),this.writeInt32(t+4,Se[sn?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===kn.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 Ke=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=bt.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=Ke.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=bt.allocate(n);return i.setPosition(n-e),i.bytes().set(t.bytes(),n-e),i}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),this.vtable==null&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(this.vtable==null||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);let t=this.offset(),e=this.vtable_in_use-1;for(;e>=0&&this.vtable[e]==0;e--);let n=e+1;for(;e>=0;e--)this.addInt16(this.vtable[e]!=0?t-this.vtable[e]:0);let i=2;this.addInt16(t-this.object_start);let s=(n+i)*2;this.addInt16(s);let o=0,a=this.space;t:for(e=0;e<this.vtables.length;e++){let c=this.bb.capacity()-this.vtables[e];if(s==this.bb.readInt16(c)){for(let l=2;l<s;l+=2)if(this.bb.readInt16(a+l)!=this.bb.readInt16(c+l))continue t;o=this.vtables[e];break}}return o?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,o-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,n){let i=n?4:0;if(e){let s=e;if(this.prep(this.minalign,4+4+i),s.length!=4)throw new TypeError("FlatBuffers: file identifier must be length "+4);for(let o=4-1;o>=0;o--)this.writeInt8(s.charCodeAt(o))}this.prep(this.minalign,4+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){let n=this.bb.capacity()-t,i=n-this.bb.readInt32(n);if(!(e<this.bb.readInt16(i)&&this.bb.readInt16(i+e)!=0))throw new TypeError("FlatBuffers: field "+e+" must be set")}startVector(t,e,n){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(n,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);let e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(t==null)return 0;let e;return t instanceof Uint8Array?e=t:e=this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector()}createByteVector(t){return t==null?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}createObjectOffset(t){return t===null?0:typeof t=="string"?this.createString(t):t.pack(this)}createObjectOffsetList(t){let e=[];for(let n=0;n<t.length;++n){let i=t[n];if(i!==null)e.push(this.createObjectOffset(i));else throw new TypeError("FlatBuffers: Argument for createObjectOffsetList cannot contain null.")}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t.slice().reverse()),this.endVector()}};var Sr;(function(r){r[r.BUFFER=0]="BUFFER"})(Sr||(Sr={}));var Ut;(function(r){r[r.LZ4_FRAME=0]="LZ4_FRAME",r[r.ZSTD=1]="ZSTD"})(Ut||(Ut={}));var At=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 At).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBodyCompression(t,e){return t.setPosition(t.position()+4),(e||new At).__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):Ut.LZ4_FRAME}method(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt8(this.bb_pos+t):Sr.BUFFER}static startBodyCompression(t){t.startObject(2)}static addCodec(t,e){t.addFieldInt8(0,e,Ut.LZ4_FRAME)}static addMethod(t,e){t.addFieldInt8(1,e,Sr.BUFFER)}static endBodyCompression(t){return t.endObject()}static createBodyCompression(t,e,n){return At.startBodyCompression(t),At.addCodec(t,e),At.addMethod(t,n),At.endBodyCompression(t)}};var on=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 an=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 St=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 St).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsRecordBatch(t,e){return t.setPosition(t.position()+4),(e||new St).__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 an).__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 on).__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 At).__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 ne=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 ne).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryBatch(t,e){return t.setPosition(t.position()+4),(e||new ne).__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 St).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}isDelta(){let t=this.bb.__offset(this.bb_pos,8);return t?!!this.bb.readInt8(this.bb_pos+t):!1}static startDictionaryBatch(t){t.startObject(3)}static addId(t,e){t.addFieldInt64(0,e,BigInt("0"))}static addData(t,e){t.addFieldOffset(1,e,0)}static addIsDelta(t,e){t.addFieldInt8(2,+e,0)}static endDictionaryBatch(t){return t.endObject()}};var hr;(function(r){r[r.Little=0]="Little",r[r.Big=1]="Big"})(hr||(hr={}));var zn;(function(r){r[r.DenseArray=0]="DenseArray"})(zn||(zn={}));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 Xt=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 Xt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDictionaryEncoding(t,e){return t.setPosition(t.position()+4),(e||new Xt).__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):zn.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,zn.DenseArray)}static endDictionaryEncoding(t){return t.endObject()}};var tt=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 tt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsKeyValue(t,e){return t.setPosition(t.position()+4),(e||new tt).__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 tt.startKeyValue(t),tt.addKey(t,e),tt.addValue(t,n),tt.endKeyValue(t)}};var Be=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsBinary(t,e){return(e||new Be).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBinary(t,e){return t.setPosition(t.position()+4),(e||new Be).__init(t.readInt32(t.position())+t.position(),t)}static startBinary(t){t.startObject(0)}static endBinary(t){return t.endObject()}static createBinary(t){return Be.startBinary(t),Be.endBinary(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 getRootAsBool(t,e){return(e||new Ae).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsBool(t,e){return t.setPosition(t.position()+4),(e||new Ae).__init(t.readInt32(t.position())+t.position(),t)}static startBool(t){t.startObject(0)}static endBool(t){return t.endObject()}static createBool(t){return Ae.startBool(t),Ae.endBool(t)}};var Pt=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsDate(t,e){return(e||new Pt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDate(t,e){return t.setPosition(t.position()+4),(e||new Pt).__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):ct.MILLISECOND}static startDate(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,ct.MILLISECOND)}static endDate(t){return t.endObject()}static createDate(t,e){return Pt.startDate(t),Pt.addUnit(t,e),Pt.endDate(t)}};var wt=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 wt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDecimal(t,e){return t.setPosition(t.position()+4),(e||new wt).__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 wt.startDecimal(t),wt.addPrecision(t,e),wt.addScale(t,n),wt.addBitWidth(t,i),wt.endDecimal(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 getRootAsDuration(t,e){return(e||new jt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsDuration(t,e){return t.setPosition(t.position()+4),(e||new jt).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):v.MILLISECOND}static startDuration(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,v.MILLISECOND)}static endDuration(t){return t.endObject()}static createDuration(t,e){return jt.startDuration(t),jt.addUnit(t,e),jt.endDuration(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 getRootAsFixedSizeBinary(t,e){return(e||new Vt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeBinary(t,e){return t.setPosition(t.position()+4),(e||new Vt).__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 Vt.startFixedSizeBinary(t),Vt.addByteWidth(t,e),Vt.endFixedSizeBinary(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 getRootAsFixedSizeList(t,e){return(e||new kt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFixedSizeList(t,e){return t.setPosition(t.position()+4),(e||new kt).__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 kt.startFixedSizeList(t),kt.addListSize(t,e),kt.endFixedSizeList(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 getRootAsFloatingPoint(t,e){return(e||new zt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFloatingPoint(t,e){return t.setPosition(t.position()+4),(e||new zt).__init(t.readInt32(t.position())+t.position(),t)}precision(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):K.HALF}static startFloatingPoint(t){t.startObject(1)}static addPrecision(t,e){t.addFieldInt16(0,e,K.HALF)}static endFloatingPoint(t){return t.endObject()}static createFloatingPoint(t,e){return zt.startFloatingPoint(t),zt.addPrecision(t,e),zt.endFloatingPoint(t)}};var Wt=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 Wt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsInterval(t,e){return t.setPosition(t.position()+4),(e||new Wt).__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):Q.YEAR_MONTH}static startInterval(t){t.startObject(1)}static addUnit(t,e){t.addFieldInt16(0,e,Q.YEAR_MONTH)}static endInterval(t){return t.endObject()}static createInterval(t,e){return Wt.startInterval(t),Wt.addUnit(t,e),Wt.endInterval(t)}};var Oe=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeBinary(t,e){return(e||new Oe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeBinary(t,e){return t.setPosition(t.position()+4),(e||new Oe).__init(t.readInt32(t.position())+t.position(),t)}static startLargeBinary(t){t.startObject(0)}static endLargeBinary(t){return t.endObject()}static createLargeBinary(t){return Oe.startLargeBinary(t),Oe.endLargeBinary(t)}};var De=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsLargeUtf8(t,e){return(e||new De).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsLargeUtf8(t,e){return t.setPosition(t.position()+4),(e||new De).__init(t.readInt32(t.position())+t.position(),t)}static startLargeUtf8(t){t.startObject(0)}static endLargeUtf8(t){return t.endObject()}static createLargeUtf8(t){return De.startLargeUtf8(t),De.endLargeUtf8(t)}};var Te=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsList(t,e){return(e||new Te).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsList(t,e){return t.setPosition(t.position()+4),(e||new Te).__init(t.readInt32(t.position())+t.position(),t)}static startList(t){t.startObject(0)}static endList(t){return t.endObject()}static createList(t){return Te.startList(t),Te.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 Fe=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsNull(t,e){return(e||new Fe).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsNull(t,e){return t.setPosition(t.position()+4),(e||new Fe).__init(t.readInt32(t.position())+t.position(),t)}static startNull(t){t.startObject(0)}static endNull(t){return t.endObject()}static createNull(t){return Fe.startNull(t),Fe.endNull(t)}};var Ne=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 Ne).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsStruct_(t,e){return t.setPosition(t.position()+4),(e||new Ne).__init(t.readInt32(t.position())+t.position(),t)}static startStruct_(t){t.startObject(0)}static endStruct_(t){return t.endObject()}static createStruct_(t){return Ne.startStruct_(t),Ne.endStruct_(t)}};var Ot=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 Ot).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTime(t,e){return t.setPosition(t.position()+4),(e||new Ot).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):v.MILLISECOND}bitWidth(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):32}static startTime(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,v.MILLISECOND)}static addBitWidth(t,e){t.addFieldInt32(1,e,32)}static endTime(t){return t.endObject()}static createTime(t,e,n){return Ot.startTime(t),Ot.addUnit(t,e),Ot.addBitWidth(t,n),Ot.endTime(t)}};var Dt=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 Dt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsTimestamp(t,e){return t.setPosition(t.position()+4),(e||new Dt).__init(t.readInt32(t.position())+t.position(),t)}unit(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):v.SECOND}timezone(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.__string(this.bb_pos+e,t):null}static startTimestamp(t){t.startObject(2)}static addUnit(t,e){t.addFieldInt16(0,e,v.SECOND)}static addTimezone(t,e){t.addFieldOffset(1,e,0)}static endTimestamp(t){return t.endObject()}static createTimestamp(t,e,n){return Dt.startTimestamp(t),Dt.addUnit(t,e),Dt.addTimezone(t,n),Dt.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):q.Sparse}typeIds(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readInt32(this.bb.__vector(this.bb_pos+e)+t*4):0}typeIdsLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}typeIdsArray(){let t=this.bb.__offset(this.bb_pos,6);return t?new Int32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}static startUnion(t){t.startObject(2)}static addMode(t,e){t.addFieldInt16(0,e,q.Sparse)}static addTypeIds(t,e){t.addFieldOffset(1,e,0)}static createTypeIdsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addInt32(e[n]);return t.endVector()}static startTypeIdsVector(t,e){t.startVector(4,e,4)}static endUnion(t){return t.endObject()}static createUnion(t,e,n){return vt.startUnion(t),vt.addMode(t,e),vt.addTypeIds(t,n),vt.endUnion(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 getRootAsUtf8(t,e){return(e||new Le).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsUtf8(t,e){return t.setPosition(t.position()+4),(e||new Le).__init(t.readInt32(t.position())+t.position(),t)}static startUtf8(t){t.startObject(0)}static endUtf8(t){return t.endObject()}static createUtf8(t){return Le.startUtf8(t),Le.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 ut=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 ut).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsField(t,e){return t.setPosition(t.position()+4),(e||new ut).__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 Xt).__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 ut).__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 tt).__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 st=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 st).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsSchema(t,e){return t.setPosition(t.position()+4),(e||new st).__init(t.readInt32(t.position())+t.position(),t)}endianness(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):hr.Little}fields(t,e){let n=this.bb.__offset(this.bb_pos,6);return n?(e||new ut).__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 tt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}features(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readInt64(this.bb.__vector(this.bb_pos+e)+t*8):BigInt(0)}featuresLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}static startSchema(t){t.startObject(4)}static addEndianness(t,e){t.addFieldInt16(0,e,hr.Little)}static addFields(t,e){t.addFieldOffset(1,e,0)}static createFieldsVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startFieldsVector(t,e){t.startVector(4,e,4)}static addCustomMetadata(t,e){t.addFieldOffset(2,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static addFeatures(t,e){t.addFieldOffset(3,e,0)}static createFeaturesVector(t,e){t.startVector(8,e.length,8);for(let n=e.length-1;n>=0;n--)t.addInt64(e[n]);return t.endVector()}static startFeaturesVector(t,e){t.startVector(8,e,8)}static endSchema(t){return t.endObject()}static finishSchemaBuffer(t,e){t.finish(e)}static finishSizePrefixedSchemaBuffer(t,e){t.finish(e,void 0,!0)}static createSchema(t,e,n,i,s){return st.startSchema(t),st.addEndianness(t,e),st.addFields(t,n),st.addCustomMetadata(t,i),st.addFeatures(t,s),st.endSchema(t)}};var j;(function(r){r[r.NONE=0]="NONE",r[r.Schema=1]="Schema",r[r.DictionaryBatch=2]="DictionaryBatch",r[r.RecordBatch=3]="RecordBatch",r[r.Tensor=4]="Tensor",r[r.SparseTensor=5]="SparseTensor"})(j||(j={}));var 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",r[r.IntervalMonthDayNano=-31]="IntervalMonthDayNano"})(f||(f={}));var me;(function(r){r[r.OFFSET=0]="OFFSET",r[r.DATA=1]="DATA",r[r.VALIDITY=2]="VALIDITY",r[r.TYPE=3]="TYPE"})(me||(me={}));var Zo={};Ze(Zo,{clampRange:()=>$n,createElementComparator:()=>yr,wrapIndex:()=>Er});var Fo={};Ze(Fo,{valueToString:()=>ye});function ye(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=>ye(t))}]`:`[${r}]`:ArrayBuffer.isView(r)?`[${r}]`:JSON.stringify(r,(t,e)=>typeof e=="bigint"?`${e}`:e)}var Eo={};Ze(Eo,{BN:()=>Br,bigNumToBigInt:()=>sc,bigNumToNumber:()=>Mo,bigNumToString:()=>un,isArrowBigNumSymbol:()=>ic});function J(r){if(typeof r=="bigint"&&(r<Number.MIN_SAFE_INTEGER||r>Number.MAX_SAFE_INTEGER))throw new TypeError(`${r} is not safe to convert to a number.`);return Number(r)}function No(r,t){return J(r/t)+J(r%t)/J(t)}var ic=Symbol.for("isArrowBigNum");function ge(r,...t){return t.length===0?Object.setPrototypeOf(R(this.TypedArray,r),this.constructor.prototype):Object.setPrototypeOf(new this.TypedArray(r,...t),this.constructor.prototype)}ge.prototype[ic]=!0;ge.prototype.toJSON=function(){return`"${un(this)}"`};ge.prototype.valueOf=function(r){return Mo(this,r)};ge.prototype.toString=function(){return un(this)};ge.prototype[Symbol.toPrimitive]=function(r="default"){switch(r){case"number":return Mo(this);case"string":return un(this);case"default":return sc(this)}return un(this)};function cn(...r){return ge.apply(this,r)}function ln(...r){return ge.apply(this,r)}function Wn(...r){return ge.apply(this,r)}Object.setPrototypeOf(cn.prototype,Object.create(Int32Array.prototype));Object.setPrototypeOf(ln.prototype,Object.create(Uint32Array.prototype));Object.setPrototypeOf(Wn.prototype,Object.create(Uint32Array.prototype));Object.assign(cn.prototype,ge.prototype,{constructor:cn,signed:!0,TypedArray:Int32Array,BigIntArray:BigInt64Array});Object.assign(ln.prototype,ge.prototype,{constructor:ln,signed:!1,TypedArray:Uint32Array,BigIntArray:BigUint64Array});Object.assign(Wn.prototype,ge.prototype,{constructor:Wn,signed:!0,TypedArray:Uint32Array,BigIntArray:BigUint64Array});var xf=BigInt(4294967296)*BigInt(4294967296),Sf=xf-BigInt(1);function Mo(r,t){let{buffer:e,byteOffset:n,byteLength:i,signed:s}=r,o=new BigUint64Array(e,n,i/8),a=s&&o.at(-1)&BigInt(1)<<BigInt(63),c=BigInt(0),l=0;if(a){for(let u of o)c|=(u^Sf)*(BigInt(1)<<BigInt(64*l++));c*=BigInt(-1),c-=BigInt(1)}else for(let u of o)c|=u*(BigInt(1)<<BigInt(64*l++));if(typeof t=="number"&&t>0){let u=BigInt("1".padEnd(t+1,"0")),h=c/u,d=a?-(c%u):c%u,p=J(h),y=`${d}`.padStart(t,"0");return+`${a&&p===0?"-":""}${p}.${y}`}return J(c)}function un(r){if(r.byteLength===8)return`${new r.BigIntArray(r.buffer,r.byteOffset,1)[0]}`;if(!r.signed)return Lo(r);let t=new Uint16Array(r.buffer,r.byteOffset,r.byteLength/2);if(new Int16Array([t.at(-1)])[0]>=0)return Lo(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`-${Lo(t)}`}function sc(r){return r.byteLength===8?new r.BigIntArray(r.buffer,r.byteOffset,1)[0]:un(r)}function Lo(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 Br=class{static new(t,e){switch(e){case!0:return new cn(t);case!1:return new ln(t)}switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:case BigInt64Array:return new cn(t)}return t.byteLength===16?new Wn(t):new ln(t)}static signed(t){return new cn(t)}static unsigned(t){return new ln(t)}static decimal(t){return new Wn(t)}constructor(t,e){return Br.new(t,e)}};var oc,ac,cc,lc,uc,fc,hc,dc,pc,mc,yc,gc,bc,_c,wc,vc,Ic,xc,Sc,Bc,Ac,Oc,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===q.Dense}static isSparseUnion(t){return m.isUnion(t)&&t.mode===q.Sparse}constructor(t){this.typeId=t}};oc=Symbol.toStringTag;m[oc]=(r=>(r.children=null,r.ArrayType=Array,r.OffsetArrayType=Int32Array,r[Symbol.toStringTag]="DataType"))(m.prototype);var Tt=class extends m{constructor(){super(f.Null)}toString(){return"Null"}};ac=Symbol.toStringTag;Tt[ac]=(r=>r[Symbol.toStringTag]="Null")(Tt.prototype);var ft=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}`}};cc=Symbol.toStringTag;ft[cc]=(r=>(r.isSigned=null,r.bitWidth=null,r[Symbol.toStringTag]="Int"))(ft.prototype);var Ar=class extends ft{constructor(){super(!0,8)}get ArrayType(){return Int8Array}},Or=class extends ft{constructor(){super(!0,16)}get ArrayType(){return Int16Array}},qt=class extends ft{constructor(){super(!0,32)}get ArrayType(){return Int32Array}},Dr=class extends ft{constructor(){super(!0,64)}get ArrayType(){return BigInt64Array}},Tr=class extends ft{constructor(){super(!1,8)}get ArrayType(){return Uint8Array}},Fr=class extends ft{constructor(){super(!1,16)}get ArrayType(){return Uint16Array}},Nr=class extends ft{constructor(){super(!1,32)}get ArrayType(){return Uint32Array}},Lr=class extends ft{constructor(){super(!1,64)}get ArrayType(){return BigUint64Array}};Object.defineProperty(Ar.prototype,"ArrayType",{value:Int8Array});Object.defineProperty(Or.prototype,"ArrayType",{value:Int16Array});Object.defineProperty(qt.prototype,"ArrayType",{value:Int32Array});Object.defineProperty(Dr.prototype,"ArrayType",{value:BigInt64Array});Object.defineProperty(Tr.prototype,"ArrayType",{value:Uint8Array});Object.defineProperty(Fr.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Nr.prototype,"ArrayType",{value:Uint32Array});Object.defineProperty(Lr.prototype,"ArrayType",{value:BigUint64Array});var Qt=class extends m{constructor(t){super(f.Float),this.precision=t}get ArrayType(){switch(this.precision){case K.HALF:return Uint16Array;case K.SINGLE:return Float32Array;case K.DOUBLE:return Float64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}toString(){return`Float${this.precision<<5||16}`}};lc=Symbol.toStringTag;Qt[lc]=(r=>(r.precision=null,r[Symbol.toStringTag]="Float"))(Qt.prototype);var Jn=class extends Qt{constructor(){super(K.HALF)}},Xe=class extends Qt{constructor(){super(K.SINGLE)}},Mr=class extends Qt{constructor(){super(K.DOUBLE)}};Object.defineProperty(Jn.prototype,"ArrayType",{value:Uint16Array});Object.defineProperty(Xe.prototype,"ArrayType",{value:Float32Array});Object.defineProperty(Mr.prototype,"ArrayType",{value:Float64Array});var Me=class extends m{constructor(){super(f.Binary)}toString(){return"Binary"}};uc=Symbol.toStringTag;Me[uc]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Binary"))(Me.prototype);var Ee=class extends m{constructor(){super(f.LargeBinary)}toString(){return"LargeBinary"}};fc=Symbol.toStringTag;Ee[fc]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeBinary"))(Ee.prototype);var Ue=class extends m{constructor(){super(f.Utf8)}toString(){return"Utf8"}};hc=Symbol.toStringTag;Ue[hc]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Utf8"))(Ue.prototype);var Ce=class extends m{constructor(){super(f.LargeUtf8)}toString(){return"LargeUtf8"}};dc=Symbol.toStringTag;Ce[dc]=(r=>(r.ArrayType=Uint8Array,r.OffsetArrayType=BigInt64Array,r[Symbol.toStringTag]="LargeUtf8"))(Ce.prototype);var Re=class extends m{constructor(){super(f.Bool)}toString(){return"Bool"}};pc=Symbol.toStringTag;Re[pc]=(r=>(r.ArrayType=Uint8Array,r[Symbol.toStringTag]="Bool"))(Re.prototype);var Pe=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}]`}};mc=Symbol.toStringTag;Pe[mc]=(r=>(r.scale=null,r.precision=null,r.ArrayType=Uint32Array,r[Symbol.toStringTag]="Decimal"))(Pe.prototype);var je=class extends m{constructor(t){super(f.Date),this.unit=t}toString(){return`Date${(this.unit+1)*32}<${ct[this.unit]}>`}get ArrayType(){return this.unit===ct.DAY?Int32Array:BigInt64Array}};yc=Symbol.toStringTag;je[yc]=(r=>(r.unit=null,r[Symbol.toStringTag]="Date"))(je.prototype);var Ve=class extends m{constructor(t,e){super(f.Time),this.unit=t,this.bitWidth=e}toString(){return`Time${this.bitWidth}<${v[this.unit]}>`}get ArrayType(){switch(this.bitWidth){case 32:return Int32Array;case 64:return BigInt64Array}throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`)}};gc=Symbol.toStringTag;Ve[gc]=(r=>(r.unit=null,r.bitWidth=null,r[Symbol.toStringTag]="Time"))(Ve.prototype);var ke=class extends m{constructor(t,e){super(f.Timestamp),this.unit=t,this.timezone=e}toString(){return`Timestamp<${v[this.unit]}${this.timezone?`, ${this.timezone}`:""}>`}};bc=Symbol.toStringTag;ke[bc]=(r=>(r.unit=null,r.timezone=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Timestamp"))(ke.prototype);var ze=class extends m{constructor(t){super(f.Interval),this.unit=t}toString(){return`Interval<${Q[this.unit]}>`}};_c=Symbol.toStringTag;ze[_c]=(r=>(r.unit=null,r.ArrayType=Int32Array,r[Symbol.toStringTag]="Interval"))(ze.prototype);var We=class extends m{constructor(t){super(f.Duration),this.unit=t}toString(){return`Duration<${v[this.unit]}>`}};wc=Symbol.toStringTag;We[wc]=(r=>(r.unit=null,r.ArrayType=BigInt64Array,r[Symbol.toStringTag]="Duration"))(We.prototype);var ie=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}};vc=Symbol.toStringTag;ie[vc]=(r=>(r.children=null,r[Symbol.toStringTag]="List"))(ie.prototype);var Z=class extends m{constructor(t){super(f.Struct),this.children=t}toString(){return`Struct<{${this.children.map(t=>`${t.name}:${t.type}`).join(", ")}}>`}};Ic=Symbol.toStringTag;Z[Ic]=(r=>(r.children=null,r[Symbol.toStringTag]="Struct"))(Z.prototype);var se=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(" | ")}>`}};xc=Symbol.toStringTag;se[xc]=(r=>(r.mode=null,r.typeIds=null,r.children=null,r.typeIdToChildIndex=null,r.ArrayType=Int8Array,r[Symbol.toStringTag]="Union"))(se.prototype);var Je=class extends m{constructor(t){super(f.FixedSizeBinary),this.byteWidth=t}toString(){return`FixedSizeBinary[${this.byteWidth}]`}};Sc=Symbol.toStringTag;Je[Sc]=(r=>(r.byteWidth=null,r.ArrayType=Uint8Array,r[Symbol.toStringTag]="FixedSizeBinary"))(Je.prototype);var oe=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}>`}};Bc=Symbol.toStringTag;oe[Bc]=(r=>(r.children=null,r.listSize=null,r[Symbol.toStringTag]="FixedSizeList"))(oe.prototype);var ae=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(", ")}}>`}};Ac=Symbol.toStringTag;ae[Ac]=(r=>(r.children=null,r.keysSorted=null,r[Symbol.toStringTag]="Map_"))(ae.prototype);var Bf=(r=>()=>++r)(-1),Gt=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?Bf():J(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}>`}};Oc=Symbol.toStringTag;Gt[Oc]=(r=>(r.id=null,r.indices=null,r.isOrdered=null,r.dictionary=null,r[Symbol.toStringTag]="Dictionary"))(Gt.prototype);function te(r){let t=r;switch(r.typeId){case f.Decimal:return r.bitWidth/32;case f.Interval:return t.unit===Q.MONTH_DAY_NANO?4:1+t.unit;case f.FixedSizeList:return t.listSize;case f.FixedSizeBinary:return t.byteWidth;default:return 1}}var x=class{visitMany(t,...e){return t.map((n,i)=>this.visit(n,...e.map(s=>s[i])))}visit(...t){return this.getVisitFn(t[0],!1).apply(this,t)}getVisitFn(t,e=!0){return Of(this,t,e)}getVisitFnByTypeId(t,e=!0){return fn(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 Of(r,t,e=!0){return typeof t=="number"?fn(r,t,e):typeof t=="string"&&t in f?fn(r,f[t],e):t&&t instanceof m?fn(r,Dc(t),e):t?.type&&t.type instanceof m?fn(r,Dc(t.type),e):fn(r,f.NONE,e)}function fn(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.IntervalMonthDayNano:n=r.visitIntervalMonthDayNano||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 Dc(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 K.HALF:return f.Float16;case K.SINGLE:return f.Float32;case K.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 v.SECOND:return f.TimeSecond;case v.MILLISECOND:return f.TimeMillisecond;case v.MICROSECOND:return f.TimeMicrosecond;case v.NANOSECOND:return f.TimeNanosecond}return f.Time;case f.Timestamp:switch(r.unit){case v.SECOND:return f.TimestampSecond;case v.MILLISECOND:return f.TimestampMillisecond;case v.MICROSECOND:return f.TimestampMicrosecond;case v.NANOSECOND:return f.TimestampNanosecond}return f.Timestamp;case f.Date:switch(r.unit){case ct.DAY:return f.DateDay;case ct.MILLISECOND:return f.DateMillisecond}return f.Date;case f.Interval:switch(r.unit){case Q.DAY_TIME:return f.IntervalDayTime;case Q.YEAR_MONTH:return f.IntervalYearMonth;case Q.MONTH_DAY_NANO:return f.IntervalMonthDayNano}return f.Interval;case f.Duration:switch(r.unit){case v.SECOND:return f.DurationSecond;case v.MILLISECOND:return f.DurationMillisecond;case v.MICROSECOND:return f.DurationMicrosecond;case v.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 q.Dense:return f.DenseUnion;case q.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]}'`)}x.prototype.visitInt8=null;x.prototype.visitInt16=null;x.prototype.visitInt32=null;x.prototype.visitInt64=null;x.prototype.visitUint8=null;x.prototype.visitUint16=null;x.prototype.visitUint32=null;x.prototype.visitUint64=null;x.prototype.visitFloat16=null;x.prototype.visitFloat32=null;x.prototype.visitFloat64=null;x.prototype.visitDateDay=null;x.prototype.visitDateMillisecond=null;x.prototype.visitTimestampSecond=null;x.prototype.visitTimestampMillisecond=null;x.prototype.visitTimestampMicrosecond=null;x.prototype.visitTimestampNanosecond=null;x.prototype.visitTimeSecond=null;x.prototype.visitTimeMillisecond=null;x.prototype.visitTimeMicrosecond=null;x.prototype.visitTimeNanosecond=null;x.prototype.visitDenseUnion=null;x.prototype.visitSparseUnion=null;x.prototype.visitIntervalDayTime=null;x.prototype.visitIntervalYearMonth=null;x.prototype.visitIntervalMonthDayNano=null;x.prototype.visitDuration=null;x.prototype.visitDurationSecond=null;x.prototype.visitDurationMillisecond=null;x.prototype.visitDurationMicrosecond=null;x.prototype.visitDurationNanosecond=null;var Uo={};Ze(Uo,{float64ToUint16:()=>Gn,uint16ToFloat64:()=>Qi});var Tc=new Float64Array(1),hn=new Uint32Array(Tc.buffer);function Qi(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 Gn(r){if(r!==r)return 32256;Tc[0]=r;let t=(hn[1]&2147483648)>>16&65535,e=hn[1]&2146435072,n=0;return e>=1089470464?hn[0]>0?e=31744:(e=(e&2080374784)>>16,n=(hn[1]&1048575)>>10):e<=1056964608?(n=1048576+(hn[1]&1048575),n=1048576+(n<<(e>>20)-998)>>21,e=0):(e=e-1056964608>>10,n=(hn[1]&1048575)+512>>10),t|e|n&65535}var D=class extends x{};function M(r){return(t,e,n)=>{if(t.setValid(e,n!=null))return r(t,e,n)}}var Df=(r,t,e)=>{r[t]=Math.floor(e/864e5)},Fc=(r,t,e,n)=>{if(e+1<t.length){let i=J(t[e]),s=J(t[e+1]);r.set(n.subarray(0,s-i),i)}},Tf=({offset:r,values:t},e,n)=>{let i=r+e;n?t[i>>3]|=1<<i%8:t[i>>3]&=~(1<<i%8)},qe=({values:r},t,e)=>{r[t]=e},Co=({values:r},t,e)=>{r[t]=e},Nc=({values:r},t,e)=>{r[t]=Gn(e)},Ff=(r,t,e)=>{switch(r.type.precision){case K.HALF:return Nc(r,t,e);case K.SINGLE:case K.DOUBLE:return Co(r,t,e)}},ts=({values:r},t,e)=>{Df(r,t,e.valueOf())},es=({values:r},t,e)=>{r[t]=BigInt(e)},Ro=({stride:r,values:t},e,n)=>{t.set(n.subarray(0,r),r*e)},Lc=({values:r,valueOffsets:t},e,n)=>Fc(r,t,e,n),Mc=({values:r,valueOffsets:t},e,n)=>Fc(r,t,e,Ie(n)),Po=(r,t,e)=>{r.type.unit===ct.DAY?ts(r,t,e):es(r,t,e)},rs=({values:r},t,e)=>{r[t]=BigInt(e/1e3)},ns=({values:r},t,e)=>{r[t]=BigInt(e)},is=({values:r},t,e)=>{r[t]=BigInt(e*1e3)},ss=({values:r},t,e)=>{r[t]=BigInt(e*1e6)},jo=(r,t,e)=>{switch(r.type.unit){case v.SECOND:return rs(r,t,e);case v.MILLISECOND:return ns(r,t,e);case v.MICROSECOND:return is(r,t,e);case v.NANOSECOND:return ss(r,t,e)}},os=({values:r},t,e)=>{r[t]=e},as=({values:r},t,e)=>{r[t]=e},cs=({values:r},t,e)=>{r[t]=e},ls=({values:r},t,e)=>{r[t]=e},Vo=(r,t,e)=>{switch(r.type.unit){case v.SECOND:return os(r,t,e);case v.MILLISECOND:return as(r,t,e);case v.MICROSECOND:return cs(r,t,e);case v.NANOSECOND:return ls(r,t,e)}},ko=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},Nf=(r,t,e)=>{let n=r.children[0],i=r.valueOffsets,s=Bt.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))},Lf=(r,t,e)=>{let n=r.children[0],{valueOffsets:i}=r,s=Bt.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},Mf=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[s]),Ef=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(s)),Uf=(r,t)=>(e,n,i,s)=>n&&e(n,r,t.get(i.name)),Cf=(r,t)=>(e,n,i,s)=>n&&e(n,r,t[i.name]),Rf=(r,t,e)=>{let n=r.type.children.map(s=>Bt.getVisitFn(s.type)),i=e instanceof Map?Uf(t,e):e instanceof _?Ef(t,e):Array.isArray(e)?Mf(t,e):Cf(t,e);r.type.children.forEach((s,o)=>i(n[o],r.children[o],s,o))},Pf=(r,t,e)=>{r.type.mode===q.Dense?Ec(r,t,e):Uc(r,t,e)},Ec=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Bt.visit(i,r.valueOffsets[t],e)},Uc=(r,t,e)=>{let n=r.type.typeIdToChildIndex[r.typeIds[t]],i=r.children[n];Bt.visit(i,t,e)},jf=(r,t,e)=>{var n;(n=r.dictionary)===null||n===void 0||n.set(r.values[t],e)},zo=(r,t,e)=>{switch(r.type.unit){case Q.YEAR_MONTH:return fs(r,t,e);case Q.DAY_TIME:return us(r,t,e);case Q.MONTH_DAY_NANO:return hs(r,t,e)}},us=({values:r},t,e)=>{r.set(e.subarray(0,2),2*t)},fs=({values:r},t,e)=>{r[t]=e[0]*12+e[1]%12},hs=({values:r,stride:t},e,n)=>{r.set(n.subarray(0,t),t*e)},ds=({values:r},t,e)=>{r[t]=e},ps=({values:r},t,e)=>{r[t]=e},ms=({values:r},t,e)=>{r[t]=e},ys=({values:r},t,e)=>{r[t]=e},Wo=(r,t,e)=>{switch(r.type.unit){case v.SECOND:return ds(r,t,e);case v.MILLISECOND:return ps(r,t,e);case v.MICROSECOND:return ms(r,t,e);case v.NANOSECOND:return ys(r,t,e)}},Vf=(r,t,e)=>{let{stride:n}=r,i=r.children[0],s=Bt.getVisitFn(i);if(Array.isArray(e))for(let o=-1,a=t*n;++o<n;)s(i,a+o,e[o]);else for(let o=-1,a=t*n;++o<n;)s(i,a+o,e.get(o))};D.prototype.visitBool=M(Tf);D.prototype.visitInt=M(qe);D.prototype.visitInt8=M(qe);D.prototype.visitInt16=M(qe);D.prototype.visitInt32=M(qe);D.prototype.visitInt64=M(qe);D.prototype.visitUint8=M(qe);D.prototype.visitUint16=M(qe);D.prototype.visitUint32=M(qe);D.prototype.visitUint64=M(qe);D.prototype.visitFloat=M(Ff);D.prototype.visitFloat16=M(Nc);D.prototype.visitFloat32=M(Co);D.prototype.visitFloat64=M(Co);D.prototype.visitUtf8=M(Mc);D.prototype.visitLargeUtf8=M(Mc);D.prototype.visitBinary=M(Lc);D.prototype.visitLargeBinary=M(Lc);D.prototype.visitFixedSizeBinary=M(Ro);D.prototype.visitDate=M(Po);D.prototype.visitDateDay=M(ts);D.prototype.visitDateMillisecond=M(es);D.prototype.visitTimestamp=M(jo);D.prototype.visitTimestampSecond=M(rs);D.prototype.visitTimestampMillisecond=M(ns);D.prototype.visitTimestampMicrosecond=M(is);D.prototype.visitTimestampNanosecond=M(ss);D.prototype.visitTime=M(Vo);D.prototype.visitTimeSecond=M(os);D.prototype.visitTimeMillisecond=M(as);D.prototype.visitTimeMicrosecond=M(cs);D.prototype.visitTimeNanosecond=M(ls);D.prototype.visitDecimal=M(ko);D.prototype.visitList=M(Nf);D.prototype.visitStruct=M(Rf);D.prototype.visitUnion=M(Pf);D.prototype.visitDenseUnion=M(Ec);D.prototype.visitSparseUnion=M(Uc);D.prototype.visitDictionary=M(jf);D.prototype.visitInterval=M(zo);D.prototype.visitIntervalDayTime=M(us);D.prototype.visitIntervalYearMonth=M(fs);D.prototype.visitIntervalMonthDayNano=M(hs);D.prototype.visitDuration=M(Wo);D.prototype.visitDurationSecond=M(ds);D.prototype.visitDurationMillisecond=M(ps);D.prototype.visitDurationMicrosecond=M(ms);D.prototype.visitDurationNanosecond=M(ys);D.prototype.visitFixedSizeList=M(Vf);D.prototype.visitMap=M(Lf);var Bt=new D;var be=Symbol.for("parent"),dn=Symbol.for("rowIndex"),dr=class{constructor(t,e){return this[be]=t,this[dn]=e,new Proxy(this,kf)}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[dn],e=this[be],n=e.type.children,i={};for(let s=-1,o=n.length;++s<o;)i[n[s].name]=ht.visit(e.children[s],t);return i}toString(){return`{${[...this].map(([t,e])=>`${ye(t)}: ${ye(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}[Symbol.iterator](){return new Jo(this[be],this[dn])}},Jo=class{constructor(t,e){this.childIndex=0,this.children=t.children,this.rowIndex=e,this.childFields=t.type.children,this.numChildren=this.childFields.length}[Symbol.iterator](){return this}next(){let t=this.childIndex;return t<this.numChildren?(this.childIndex=t+1,{done:!1,value:[this.childFields[t].name,ht.visit(this.children[t],this.rowIndex)]}):{done:!0,value:null}}};Object.defineProperties(dr.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[be]:{writable:!0,enumerable:!1,configurable:!1,value:null},[dn]:{writable:!0,enumerable:!1,configurable:!1,value:-1}});var Go=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[be].type.children.map(e=>e.name)}has(t,e){return t[be].type.children.some(n=>n.name===e)}getOwnPropertyDescriptor(t,e){if(t[be].type.children.some(n=>n.name===e))return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[be].type.children.findIndex(i=>i.name===e);if(n!==-1){let i=ht.visit(t[be].children[n],t[dn]);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[be].type.children.findIndex(s=>s.name===e);return i!==-1?(Bt.visit(t[be].children[i],t[dn],n),Reflect.set(t,e,n)):Reflect.has(t,e)||typeof e=="symbol"?Reflect.set(t,e,n):!1}},kf=new Go;var S=class extends x{};function N(r){return(t,e)=>t.getValid(e)?r(t,e):null}var zf=(r,t)=>864e5*r[t],Wf=(r,t)=>null,Cc=(r,t,e)=>{if(e+1>=t.length)return null;let n=J(t[e]),i=J(t[e+1]);return r.subarray(n,i)},Jf=({offset:r,values:t},e)=>{let n=r+e;return(t[n>>3]&1<<n%8)!==0},Rc=({values:r},t)=>zf(r,t),Pc=({values:r},t)=>J(r[t]),pr=({stride:r,values:t},e)=>t[r*e],Gf=({stride:r,values:t},e)=>Qi(t[r*e]),jc=({values:r},t)=>r[t],$f=({stride:r,values:t},e)=>t.subarray(r*e,r*(e+1)),Vc=({values:r,valueOffsets:t},e)=>Cc(r,t,e),kc=({values:r,valueOffsets:t},e)=>{let n=Cc(r,t,e);return n!==null?Pn(n):null},Hf=({values:r},t)=>r[t],Yf=({type:r,values:t},e)=>r.precision!==K.HALF?t[e]:Qi(t[e]),Zf=(r,t)=>r.type.unit===ct.DAY?Rc(r,t):Pc(r,t),zc=({values:r},t)=>1e3*J(r[t]),Wc=({values:r},t)=>J(r[t]),Jc=({values:r},t)=>No(r[t],BigInt(1e3)),Gc=({values:r},t)=>No(r[t],BigInt(1e6)),Kf=(r,t)=>{switch(r.type.unit){case v.SECOND:return zc(r,t);case v.MILLISECOND:return Wc(r,t);case v.MICROSECOND:return Jc(r,t);case v.NANOSECOND:return Gc(r,t)}},$c=({values:r},t)=>r[t],Hc=({values:r},t)=>r[t],Yc=({values:r},t)=>r[t],Zc=({values:r},t)=>r[t],Xf=(r,t)=>{switch(r.type.unit){case v.SECOND:return $c(r,t);case v.MILLISECOND:return Hc(r,t);case v.MICROSECOND:return Yc(r,t);case v.NANOSECOND:return Zc(r,t)}},qf=({values:r,stride:t},e)=>Br.decimal(r.subarray(t*e,t*(e+1))),Qf=(r,t)=>{let{valueOffsets:e,stride:n,children:i}=r,{[t*n]:s,[t*n+1]:o}=e,c=i[0].slice(s,o-s);return new _([c])},th=(r,t)=>{let{valueOffsets:e,children:n}=r,{[t]:i,[t+1]:s}=e,o=n[0];return new Ge(o.slice(i,s-i))},eh=(r,t)=>new dr(r,t),rh=(r,t)=>r.type.mode===q.Dense?Kc(r,t):Xc(r,t),Kc=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return ht.visit(n,r.valueOffsets[t])},Xc=(r,t)=>{let e=r.type.typeIdToChildIndex[r.typeIds[t]],n=r.children[e];return ht.visit(n,t)},nh=(r,t)=>{var e;return(e=r.dictionary)===null||e===void 0?void 0:e.get(r.values[t])},ih=(r,t)=>r.type.unit===Q.MONTH_DAY_NANO?tl(r,t):r.type.unit===Q.DAY_TIME?qc(r,t):Qc(r,t),qc=({values:r},t)=>r.subarray(2*t,2*(t+1)),Qc=({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},tl=({values:r},t)=>r.subarray(4*t,4*(t+1)),el=({values:r},t)=>r[t],rl=({values:r},t)=>r[t],nl=({values:r},t)=>r[t],il=({values:r},t)=>r[t],sh=(r,t)=>{switch(r.type.unit){case v.SECOND:return el(r,t);case v.MILLISECOND:return rl(r,t);case v.MICROSECOND:return nl(r,t);case v.NANOSECOND:return il(r,t)}},oh=(r,t)=>{let{stride:e,children:n}=r,s=n[0].slice(t*e,e);return new _([s])};S.prototype.visitNull=N(Wf);S.prototype.visitBool=N(Jf);S.prototype.visitInt=N(Hf);S.prototype.visitInt8=N(pr);S.prototype.visitInt16=N(pr);S.prototype.visitInt32=N(pr);S.prototype.visitInt64=N(jc);S.prototype.visitUint8=N(pr);S.prototype.visitUint16=N(pr);S.prototype.visitUint32=N(pr);S.prototype.visitUint64=N(jc);S.prototype.visitFloat=N(Yf);S.prototype.visitFloat16=N(Gf);S.prototype.visitFloat32=N(pr);S.prototype.visitFloat64=N(pr);S.prototype.visitUtf8=N(kc);S.prototype.visitLargeUtf8=N(kc);S.prototype.visitBinary=N(Vc);S.prototype.visitLargeBinary=N(Vc);S.prototype.visitFixedSizeBinary=N($f);S.prototype.visitDate=N(Zf);S.prototype.visitDateDay=N(Rc);S.prototype.visitDateMillisecond=N(Pc);S.prototype.visitTimestamp=N(Kf);S.prototype.visitTimestampSecond=N(zc);S.prototype.visitTimestampMillisecond=N(Wc);S.prototype.visitTimestampMicrosecond=N(Jc);S.prototype.visitTimestampNanosecond=N(Gc);S.prototype.visitTime=N(Xf);S.prototype.visitTimeSecond=N($c);S.prototype.visitTimeMillisecond=N(Hc);S.prototype.visitTimeMicrosecond=N(Yc);S.prototype.visitTimeNanosecond=N(Zc);S.prototype.visitDecimal=N(qf);S.prototype.visitList=N(Qf);S.prototype.visitStruct=N(eh);S.prototype.visitUnion=N(rh);S.prototype.visitDenseUnion=N(Kc);S.prototype.visitSparseUnion=N(Xc);S.prototype.visitDictionary=N(nh);S.prototype.visitInterval=N(ih);S.prototype.visitIntervalDayTime=N(qc);S.prototype.visitIntervalYearMonth=N(Qc);S.prototype.visitIntervalMonthDayNano=N(tl);S.prototype.visitDuration=N(sh);S.prototype.visitDurationSecond=N(el);S.prototype.visitDurationMillisecond=N(rl);S.prototype.visitDurationMicrosecond=N(nl);S.prototype.visitDurationNanosecond=N(il);S.prototype.visitFixedSizeList=N(oh);S.prototype.visitMap=N(th);var ht=new S;var mr=Symbol.for("keys"),mn=Symbol.for("vals"),pn=Symbol.for("kKeysAsStrings"),$o=Symbol.for("_kKeysAsStrings"),Ge=class{constructor(t){return this[mr]=new _([t.children[0]]).memoize(),this[mn]=t.children[1],new Proxy(this,new Yo)}get[pn](){return this[$o]||(this[$o]=Array.from(this[mr].toArray(),String))}[Symbol.iterator](){return new Ho(this[mr],this[mn])}get size(){return this[mr].length}toArray(){return Object.values(this.toJSON())}toJSON(){let t=this[mr],e=this[mn],n={};for(let i=-1,s=t.length;++i<s;)n[t.get(i)]=ht.visit(e,i);return n}toString(){return`{${[...this].map(([t,e])=>`${ye(t)}: ${ye(e)}`).join(", ")}}`}[Symbol.for("nodejs.util.inspect.custom")](){return this.toString()}},Ho=class{constructor(t,e){this.keys=t,this.vals=e,this.keyIndex=0,this.numKeys=t.length}[Symbol.iterator](){return this}next(){let t=this.keyIndex;return t===this.numKeys?{done:!0,value:null}:(this.keyIndex++,{done:!1,value:[this.keys.get(t),ht.visit(this.vals,t)]})}},Yo=class{isExtensible(){return!1}deleteProperty(){return!1}preventExtensions(){return!0}ownKeys(t){return t[pn]}has(t,e){return t[pn].includes(e)}getOwnPropertyDescriptor(t,e){if(t[pn].indexOf(e)!==-1)return{writable:!0,enumerable:!0,configurable:!0}}get(t,e){if(Reflect.has(t,e))return t[e];let n=t[pn].indexOf(e);if(n!==-1){let i=ht.visit(Reflect.get(t,mn),n);return Reflect.set(t,e,i),i}}set(t,e,n){let i=t[pn].indexOf(e);return i!==-1?(Bt.visit(Reflect.get(t,mn),i,n),Reflect.set(t,e,n)):Reflect.has(t,e)?Reflect.set(t,e,n):!1}};Object.defineProperties(Ge.prototype,{[Symbol.toStringTag]:{enumerable:!1,configurable:!1,value:"Row"},[mr]:{writable:!0,enumerable:!1,configurable:!1,value:null},[mn]:{writable:!0,enumerable:!1,configurable:!1,value:null},[$o]:{writable:!0,enumerable:!1,configurable:!1,value:null}});var sl;function $n(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&&(sl=s,s=o,o=sl),o>i&&(o=i),n?n(r,s,o):[s,o]}var Er=(r,t)=>r<0?t+r:r,ol=r=>r!==r;function yr(r){if(typeof r!=="object"||r===null)return ol(r)?ol: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?Ao(r,e):!1:r instanceof Map?ch(r):Array.isArray(r)?ah(r):r instanceof _?lh(r):uh(r,!0)}function ah(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=yr(r[e]);return gs(t)}function ch(r){let t=-1,e=[];for(let n of r.values())e[++t]=yr(n);return gs(e)}function lh(r){let t=[];for(let e=-1,n=r.length;++e<n;)t[e]=yr(r.get(e));return gs(t)}function uh(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]=yr(r[e[i]]);return gs(n,e)}function gs(r,t){return e=>{if(!e||typeof e!="object")return!1;switch(e.constructor){case Array:return fh(r,e);case Map:return al(r,e,e.keys());case Ge:case dr:case Object:case void 0:return al(r,e,t||Object.keys(e))}return e instanceof _?hh(r,e):!1}}function fh(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 hh(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 al(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 Ko={};Ze(Ko,{BitIterator:()=>Ur,getBit:()=>cl,getBool:()=>_s,packBools:()=>Rr,popcnt_array:()=>ll,popcnt_bit_range:()=>Hn,popcnt_uint32:()=>bs,setBool:()=>dh,truncateBitmap:()=>Cr});function _s(r,t,e,n){return(e&1<<n)!==0}function cl(r,t,e,n){return(e&1<<n)>>n}function dh(r,t,e){return e?!!(r[t>>3]|=1<<t%8)||!0:!(r[t>>3]&=~(1<<t%8))&&!1}function Cr(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):Rr(new Ur(e,r,t,null,_s)).subarray(0,n)),i}return e}function Rr(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 Ur=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 Hn(r,t,e){if(e-t<=0)return 0;if(e-t<8){let s=0;for(let o of new Ur(r,t,e-t,r,cl))s+=o;return s}let n=e>>3<<3,i=t+(t%8===0?0:8-t%8);return Hn(r,t,i)+Hn(r,n,e)+ll(r,i>>3,n-i>>3)}function ll(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+=bs(s.getUint32(i)),i+=4;for(;o-i>=2;)n+=bs(s.getUint16(i)),i+=2;for(;o-i>=1;)n+=bs(s.getUint8(i)),i+=1;return n}function bs(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 ph=-1,V=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<=ph&&(e=this.nullBitmap)&&(this._nullCount=t=e.length===0?0:this.length-Hn(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 V?(this.stride=s.stride,this.values=s.values,this.typeIds=s.typeIds,this.nullBitmap=s.nullBitmap,this.valueOffsets=s.valueOffsets):(this.stride=te(t),s&&((c=s[0])&&(this.valueOffsets=c),(c=s[1])&&(this.values=c),(c=s[2])&&(this.nullBitmap=c),(c=s[3])&&(this.typeIds=c)))}getValid(t){let{type:e}=this;if(m.isUnion(e)){let n=e,i=this.children[n.typeIdToChildIndex[this.typeIds[t]]],s=n.mode===q.Dense?this.valueOffsets[t]:t;return i.getValid(s)}if(this.nullable&&this.nullCount>0){let n=this.offset+t;return(this.nullBitmap[n>>3]&1<<n%8)!==0}return!0}setValid(t,e){let n,{type:i}=this;if(m.isUnion(i)){let s=i,o=this.children[s.typeIdToChildIndex[this.typeIds[t]]],a=s.mode===q.Dense?this.valueOffsets[t]:t;n=o.getValid(a),o.setValid(a,e)}else{let{nullBitmap:s}=this,{offset:o,length:a}=this,c=o+t,l=1<<c%8,u=c>>3;(!s||s.byteLength<=u)&&(s=new Uint8Array((o+a+63&-64)>>3).fill(255),this.nullCount>0?(s.set(Cr(o,a,this.nullBitmap),0),Object.assign(this,{nullBitmap:s})):Object.assign(this,{nullBitmap:s,_nullCount:0}));let h=s[u];n=(h&l)!==0,s[u]=e?h|l: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 V(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(Cr(this.offset,e,this.nullBitmap),0);let s=this.buffers;return s[me.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[me.TYPE])&&(o[me.TYPE]=s.subarray(t,t+e)),(s=o[me.OFFSET])&&(o[me.OFFSET]=s.subarray(t,t+e+1))||(s=o[me.DATA])&&(o[me.DATA]=i===6?s:s.subarray(n*t,n*(t+e))),o}_sliceChildren(t,e,n){return t.map(i=>i.slice(e,n))}};V.prototype.children=Object.freeze([]);var Pr=class extends x{visit(t){return this.getVisitFn(t.type).call(this,t)}visitNull(t){let{["type"]:e,["offset"]:n=0,["length"]:i=0}=t;return new V(e,n,i,i)}visitBool(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length>>3,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new V(e,n,o,a,[void 0,s,i])}visitInt(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new V(e,n,o,a,[void 0,s,i])}visitFloat(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new V(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=xr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new V(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=Hi(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new V(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=xr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new V(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=Hi(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new V(e,n,a,c,[o,i,s])}visitFixedSizeBinary(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/te(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new V(e,n,o,a,[void 0,s,i])}visitDate(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/te(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new V(e,n,o,a,[void 0,s,i])}visitTimestamp(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/te(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new V(e,n,o,a,[void 0,s,i])}visitTime(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/te(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new V(e,n,o,a,[void 0,s,i])}visitDecimal(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/te(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new V(e,n,o,a,[void 0,s,i])}visitList(t){let{["type"]:e,["offset"]:n=0,["child"]:i}=t,s=T(t.nullBitmap),o=xr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new V(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 V(e,n,o,a,[void 0,void 0,s],i)}visitUnion(t){let{["type"]:e,["offset"]:n=0,["children"]:i=[]}=t,s=R(e.ArrayType,t.typeIds),{["length"]:o=s.length,["nullCount"]:a=-1}=t;if(m.isSparseUnion(e))return new V(e,n,o,a,[void 0,void 0,void 0,s],i);let c=xr(t.valueOffsets);return new V(e,n,o,a,[c,void 0,void 0,s],i)}visitDictionary(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.indices.ArrayType,t.data),{["dictionary"]:o=new _([new Pr().visit({type:e.dictionary})])}=t,{["length"]:a=s.length,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new V(e,n,a,c,[void 0,s,i],[],o)}visitInterval(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length/te(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new V(e,n,o,a,[void 0,s,i])}visitDuration(t){let{["type"]:e,["offset"]:n=0}=t,i=T(t.nullBitmap),s=R(e.ArrayType,t.data),{["length"]:o=s.length,["nullCount"]:a=t.nullBitmap?-1:0}=t;return new V(e,n,o,a,[void 0,s,i])}visitFixedSizeList(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new Pr().visit({type:e.valueType})}=t,s=T(t.nullBitmap),{["length"]:o=i.length/te(e),["nullCount"]:a=t.nullBitmap?-1:0}=t;return new V(e,n,o,a,[void 0,void 0,s],[i])}visitMap(t){let{["type"]:e,["offset"]:n=0,["child"]:i=new Pr().visit({type:e.childType})}=t,s=T(t.nullBitmap),o=xr(t.valueOffsets),{["length"]:a=o.length-1,["nullCount"]:c=t.nullBitmap?-1:0}=t;return new V(e,n,a,c,[o,void 0,s],[i])}},mh=new Pr;function w(r){return mh.visit(r)}var Yn=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 ul(r){return r.some(t=>t.nullable)}function ws(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 Is(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 Xo(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 Zn(r,t){return r.getValid(t)}function yn(r){function t(e,n,i){return r(e[n],i)}return function(e){let n=this.data;return Xo(n,this._offsets,e,t)}}function xs(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=Xo(s,this._offsets,n,e);return t=void 0,o}}function Ss(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):Xo(s,this._offsets,i,e);return t=void 0,o}}var B=class extends x{};function yh(r,t){return t===null&&r.length>0?0:-1}function gh(r,t){let{nullBitmap:e}=r;if(!e||r.nullCount<=0)return-1;let n=0;for(let i of new Ur(e,r.offset+(t||0),r.length,e,_s)){if(!i)return n;++n}return-1}function E(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 gh(r,e)}let n=ht.getVisitFn(r),i=yr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}function fl(r,t,e){let n=ht.getVisitFn(r),i=yr(t);for(let s=(e||0)-1,o=r.length;++s<o;)if(i(n(r,s)))return s;return-1}B.prototype.visitNull=yh;B.prototype.visitBool=E;B.prototype.visitInt=E;B.prototype.visitInt8=E;B.prototype.visitInt16=E;B.prototype.visitInt32=E;B.prototype.visitInt64=E;B.prototype.visitUint8=E;B.prototype.visitUint16=E;B.prototype.visitUint32=E;B.prototype.visitUint64=E;B.prototype.visitFloat=E;B.prototype.visitFloat16=E;B.prototype.visitFloat32=E;B.prototype.visitFloat64=E;B.prototype.visitUtf8=E;B.prototype.visitLargeUtf8=E;B.prototype.visitBinary=E;B.prototype.visitLargeBinary=E;B.prototype.visitFixedSizeBinary=E;B.prototype.visitDate=E;B.prototype.visitDateDay=E;B.prototype.visitDateMillisecond=E;B.prototype.visitTimestamp=E;B.prototype.visitTimestampSecond=E;B.prototype.visitTimestampMillisecond=E;B.prototype.visitTimestampMicrosecond=E;B.prototype.visitTimestampNanosecond=E;B.prototype.visitTime=E;B.prototype.visitTimeSecond=E;B.prototype.visitTimeMillisecond=E;B.prototype.visitTimeMicrosecond=E;B.prototype.visitTimeNanosecond=E;B.prototype.visitDecimal=E;B.prototype.visitList=E;B.prototype.visitStruct=E;B.prototype.visitUnion=E;B.prototype.visitDenseUnion=fl;B.prototype.visitSparseUnion=fl;B.prototype.visitDictionary=E;B.prototype.visitInterval=E;B.prototype.visitIntervalDayTime=E;B.prototype.visitIntervalYearMonth=E;B.prototype.visitIntervalMonthDayNano=E;B.prototype.visitDuration=E;B.prototype.visitDurationSecond=E;B.prototype.visitDurationMillisecond=E;B.prototype.visitDurationMicrosecond=E;B.prototype.visitDurationNanosecond=E;B.prototype.visitFixedSizeList=E;B.prototype.visitMap=E;var jr=new B;var A=class extends x{};function L(r){let{type:t}=r;if(r.nullCount===0&&r.stride===1&&(m.isInt(t)&&t.bitWidth!==64||m.isTime(t)&&t.bitWidth!==64||m.isFloat(t)&&t.precision!==K.HALF))return new Yn(r.data.length,n=>{let i=r.data[n];return i.values.subarray(0,i.length)[Symbol.iterator]()});let e=0;return new Yn(r.data.length,n=>{let s=r.data[n].length,o=r.slice(e,e+s);return e+=s,new qo(o)})}var qo=class{constructor(t){this.vector=t,this.index=0}next(){return this.index<this.vector.length?{value:this.vector.get(this.index++)}:{done:!0,value:null}}[Symbol.iterator](){return this}};A.prototype.visitNull=L;A.prototype.visitBool=L;A.prototype.visitInt=L;A.prototype.visitInt8=L;A.prototype.visitInt16=L;A.prototype.visitInt32=L;A.prototype.visitInt64=L;A.prototype.visitUint8=L;A.prototype.visitUint16=L;A.prototype.visitUint32=L;A.prototype.visitUint64=L;A.prototype.visitFloat=L;A.prototype.visitFloat16=L;A.prototype.visitFloat32=L;A.prototype.visitFloat64=L;A.prototype.visitUtf8=L;A.prototype.visitLargeUtf8=L;A.prototype.visitBinary=L;A.prototype.visitLargeBinary=L;A.prototype.visitFixedSizeBinary=L;A.prototype.visitDate=L;A.prototype.visitDateDay=L;A.prototype.visitDateMillisecond=L;A.prototype.visitTimestamp=L;A.prototype.visitTimestampSecond=L;A.prototype.visitTimestampMillisecond=L;A.prototype.visitTimestampMicrosecond=L;A.prototype.visitTimestampNanosecond=L;A.prototype.visitTime=L;A.prototype.visitTimeSecond=L;A.prototype.visitTimeMillisecond=L;A.prototype.visitTimeMicrosecond=L;A.prototype.visitTimeNanosecond=L;A.prototype.visitDecimal=L;A.prototype.visitList=L;A.prototype.visitStruct=L;A.prototype.visitUnion=L;A.prototype.visitDenseUnion=L;A.prototype.visitSparseUnion=L;A.prototype.visitDictionary=L;A.prototype.visitInterval=L;A.prototype.visitIntervalDayTime=L;A.prototype.visitIntervalYearMonth=L;A.prototype.visitIntervalMonthDayNano=L;A.prototype.visitDuration=L;A.prototype.visitDurationSecond=L;A.prototype.visitDurationMillisecond=L;A.prototype.visitDurationMicrosecond=L;A.prototype.visitDurationNanosecond=L;A.prototype.visitFixedSizeList=L;A.prototype.visitMap=L;var gn=new A;var hl,dl={},pl={},_=class{constructor(t){var e,n,i;let s=t[0]instanceof _?t.flatMap(a=>a.data):t;if(s.length===0||s.some(a=>!(a instanceof V)))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}=dl[o.typeId],u=s[0];this.isValid=h=>Zn(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,pl[o.typeId]),this._offsets=vs(s);break}this.data=s,this.type=o,this.stride=te(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 ul(this.data)}get nullCount(){return ws(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}at(t){return this.get(Er(t,this.length))}set(t,e){}indexOf(t,e){return-1}includes(t,e){return this.indexOf(t,e)>-1}[Symbol.iterator](){return gn.visit(this)}concat(...t){return new _(this.data.concat(t.flatMap(e=>e.data).flat(Number.POSITIVE_INFINITY)))}slice(t,e){return new _($n(this,t,e,({data:n,_offsets:i},s,o)=>Is(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 _(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 bn(this.data[0].dictionary),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new _(e)}return new bn(this)}unmemoize(){if(m.isDictionary(this.type)&&this.isMemoized){let t=this.data[0].dictionary.unmemoize(),e=this.data.map(n=>{let i=n.clone();return i.dictionary=t,i});return new _(e)}return this}};hl=Symbol.toStringTag;_[hl]=(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=ht.getVisitFnByTypeId(e),i=Bt.getVisitFnByTypeId(e),s=jr.getVisitFnByTypeId(e);dl[e]={get:n,set:i,indexOf:s},pl[e]=Object.create(r,{isValid:{value:yn(Zn)},get:{value:yn(ht.getVisitFnByTypeId(e))},set:{value:xs(Bt.getVisitFnByTypeId(e))},indexOf:{value:Ss(jr.getVisitFnByTypeId(e))}})}return"Vector"})(_.prototype);var bn=class extends _{constructor(t){super(t.data);let e=this.get,n=this.set,i=this.slice,s=new Array(this.length);Object.defineProperty(this,"get",{value(o){let a=s[o];if(a!==void 0)return a;let c=e.call(this,o);return s[o]=c,c}}),Object.defineProperty(this,"set",{value(o,a){n.call(this,o,a),s[o]=a}}),Object.defineProperty(this,"slice",{value:(o,a)=>new bn(i.call(this,o,a))}),Object.defineProperty(this,"isMemoized",{value:!0}),Object.defineProperty(this,"unmemoize",{value:()=>new _(this.data)}),Object.defineProperty(this,"memoize",{value:()=>this})}};function _n(r){if(r){if(r instanceof V)return new _([r]);if(r instanceof _)return new _(r.data);if(r.type instanceof m)return new _([w(r)]);if(Array.isArray(r))return new _(r.flatMap(t=>bh(t)));if(ArrayBuffer.isView(r)){r instanceof DataView&&(r=new Uint8Array(r.buffer));let t={offset:0,length:r.length,nullCount:-1,data:r};if(r instanceof Int8Array)return new _([w(Object.assign(Object.assign({},t),{type:new Ar}))]);if(r instanceof Int16Array)return new _([w(Object.assign(Object.assign({},t),{type:new Or}))]);if(r instanceof Int32Array)return new _([w(Object.assign(Object.assign({},t),{type:new qt}))]);if(r instanceof BigInt64Array)return new _([w(Object.assign(Object.assign({},t),{type:new Dr}))]);if(r instanceof Uint8Array||r instanceof Uint8ClampedArray)return new _([w(Object.assign(Object.assign({},t),{type:new Tr}))]);if(r instanceof Uint16Array)return new _([w(Object.assign(Object.assign({},t),{type:new Fr}))]);if(r instanceof Uint32Array)return new _([w(Object.assign(Object.assign({},t),{type:new Nr}))]);if(r instanceof BigUint64Array)return new _([w(Object.assign(Object.assign({},t),{type:new Lr}))]);if(r instanceof Float32Array)return new _([w(Object.assign(Object.assign({},t),{type:new Xe}))]);if(r instanceof Float64Array)return new _([w(Object.assign(Object.assign({},t),{type:new Mr}))]);throw new Error("Unrecognized input")}}throw new Error("Unrecognized input")}function bh(r){return r instanceof V?[r]:r instanceof _?r.data:_n(r).data}function ml(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 ${Yh(n)}:`).join("")}
9
+ case ${_h(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 Yh(r){return typeof r!="bigint"?me(r):`${me(r)}n`}function $o(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function tl(r,t=0){return r.length>=t?r.subarray(0,t):En(new r.constructor(t),r,0)}var be=class{constructor(t,e=0,n=1){this.length=Math.ceil(e/n),this.buffer=new t(this.length),this.stride=n,this.BYTES_PER_ELEMENT=t.BYTES_PER_ELEMENT,this.ArrayType=t}get byteLength(){return Math.ceil(this.length*this.stride)*this.BYTES_PER_ELEMENT}get reservedLength(){return this.buffer.length/this.stride}get reservedByteLength(){return this.buffer.byteLength}set(t,e){return this}append(t){return this.set(this.length,t)}reserve(t){if(t>0){this.length+=t;let e=this.stride,n=this.length*e,i=this.buffer.length;n>=i&&this._resize(i===0?$o(n*1,this.BYTES_PER_ELEMENT):$o(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=$o(t*this.stride,this.BYTES_PER_ELEMENT);let e=tl(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=tl(this.buffer,t)}},Xe=class extends be{last(){return this.get(this.length-1)}get(t){return this.buffer[t]}set(t,e){return this.reserve(t-this.length+1),this.buffer[t*this.stride]=e,this}},yn=class extends Xe{constructor(){super(Uint8Array,0,1/8),this.numValid=0}get numInvalid(){return this.length-this.numValid}get(t){return this.buffer[t>>3]>>t%8&1}set(t,e){let{buffer:n}=this.reserve(t-this.length+1),i=t>>3,s=t%8,o=n[i]>>s&1;return e?o===0&&(n[i]|=1<<s,++this.numValid):o===1&&(n[i]&=~(1<<s),--this.numValid),this}clear(){return this.numValid=0,super.clear()}},gn=class extends Xe{constructor(t){super(t.OffsetArrayType,1,1)}append(t){return this.set(this.length-1,t)}set(t,e){let n=this.length-1,i=this.reserve(t-n+1).buffer;return n<t++&&n>=0&&i.fill(i[n],n,t),i[t]=i[t-1]+e,this}flush(t=this.length-1){return t>this.length&&this.set(t-1,this.BYTES_PER_ELEMENT>4?BigInt(0):0),super.flush(t+1)}};var rt=class{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t){throw new Error('"throughDOM" not available in this environment')}constructor({type:t,nullValues:e}){this.length=0,this.finished=!1,this.type=t,this.children=[],this.nullValues=e,this.stride=qt(t),this._nulls=new yn,e&&e.length>0&&(this._isValid=Qc(e))}toVector(){return new _([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0,{_offsets:e,_values:n,_nulls:i,_typeIds:s,children:o}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),o.reduce((a,c)=>a+c.byteLength,t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((e,n)=>e+n.reservedByteLength,t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(t){return this.children[t]||null}flush(){let t,e,n,i,{type:s,length:o,nullCount:a,_typeIds:c,_offsets:l,_values:u,_nulls:f}=this;(e=c?.flush(o))?i=l?.flush(o):(i=l?.flush(o))?t=u?.flush(l.last()):t=u?.flush(o),a>0&&(n=f?.flush(o));let d=this.children.map(p=>p.flush());return this.clear(),w({type:s,length:o,nullCount:a,children:d,child:d[0],data:t,typeIds:e,nullBitmap:n,valueOffsets:i})}finish(){this.finished=!0;for(let t of this.children)t.finish();return this}clear(){var t,e,n,i;this.length=0,(t=this._nulls)===null||t===void 0||t.clear(),(e=this._values)===null||e===void 0||e.clear(),(n=this._offsets)===null||n===void 0||n.clear(),(i=this._typeIds)===null||i===void 0||i.clear();for(let s of this.children)s.clear();return this}};rt.prototype.length=1;rt.prototype.stride=1;rt.prototype.children=null;rt.prototype.finished=!1;rt.prototype.nullValues=null;rt.prototype._isValid=()=>!0;var ft=class extends rt{constructor(t){super(t),this._values=new Xe(this.ArrayType,0,this.stride)}setValue(t,e){let n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}},zt=class extends rt{constructor(t){super(t),this._pendingLength=0,this._offsets=new gn(t.type)}setValue(t,e){let n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.length),this._pendingLength+=e instanceof Ge?e[pr].length:e.length,n.set(t,e)}setValid(t,e){return super.setValid(t,e)?!0:((this._pending||(this._pending=new Map)).set(t,void 0),!1)}clear(){return this._pendingLength=0,this._pending=void 0,super.clear()}flush(){return this._flush(),super.flush()}finish(){return this._flush(),super.finish()}_flush(){let t=this._pending,e=this._pendingLength;return this._pendingLength=0,this._pending=void 0,t&&t.size>0&&this._flushPending(t,e),this}};var Rr=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}offset(){return this.bb.readInt64(this.bb_pos)}metaDataLength(){return this.bb.readInt32(this.bb_pos+8)}bodyLength(){return this.bb.readInt64(this.bb_pos+16)}static sizeOf(){return 24}static createBlock(t,e,n,i){return t.prep(8,24),t.writeInt64(BigInt(i??0)),t.pad(4),t.writeInt32(n),t.writeInt64(BigInt(e??0)),t.offset()}};var Ot=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFooter(t,e){return(e||new Ot).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(t,e){return t.setPosition(t.position()+4),(e||new Ot).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):H.V1}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new it).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}dictionaries(t,e){let n=this.bb.__offset(this.bb_pos,8);return n?(e||new Rr).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}dictionariesLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}recordBatches(t,e){let n=this.bb.__offset(this.bb_pos,10);return n?(e||new Rr).__init(this.bb.__vector(this.bb_pos+n)+t*24,this.bb):null}recordBatchesLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Q).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,H.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}};var P=class{constructor(t=[],e,n,i=H.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=Ho(this.fields)),this.dictionaries=n,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,e)=>`${e}: ${t}`).join(", ")} }>`}select(t){let e=new Set(t),n=this.fields.filter(i=>e.has(i.name));return new P(n,this.metadata)}selectAt(t){let e=t.map(n=>this.fields[n]).filter(Boolean);return new P(e,this.metadata)}assign(...t){let e=t[0]instanceof P?t[0]:Array.isArray(t[0])?new P(t[0]):new P(t),n=[...this.fields],i=ws(ws(new Map,this.metadata),e.metadata),s=e.fields.filter(a=>{let c=n.findIndex(l=>l.name===a.name);return~c?(n[c]=a.clone({metadata:ws(ws(new Map,n[c].metadata),a.metadata)}))&&!1:!0}),o=Ho(s,new Map);return new P([...n,...s],i,new Map([...this.dictionaries,...o]))}};P.prototype.fields=null;P.prototype.metadata=null;P.prototype.dictionaries=null;var E=class{static new(...t){let[e,n,i,s]=t;return t[0]&&typeof t[0]=="object"&&({name:e}=t[0],n===void 0&&(n=t[0].type),i===void 0&&(i=t[0].nullable),s===void 0&&(s=t[0].metadata)),new E(`${e}`,n,i,s)}constructor(t,e,n=!1,i){this.name=t,this.type=e,this.nullable=n,this.metadata=i||new Map}get typeId(){return this.type.typeId}get[Symbol.toStringTag](){return"Field"}toString(){return`${this.name}: ${this.type}`}clone(...t){let[e,n,i,s]=t;return!t[0]||typeof t[0]!="object"?[e=this.name,n=this.type,i=this.nullable,s=this.metadata]=t:{name:e=this.name,type:n=this.type,nullable:i=this.nullable,metadata:s=this.metadata}=t[0],E.new(e,n,i,s)}};E.prototype.type=null;E.prototype.name=null;E.prototype.nullable=null;E.prototype.metadata=null;function ws(r,t){return new Map([...r||new Map,...t||new Map])}function Ho(r,t=new Map){for(let e=-1,n=r.length;++e<n;){let s=r[e].type;if(m.isDictionary(s)){if(!t.has(s.id))t.set(s.id,s.dictionary);else if(t.get(s.id)!==s.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}s.children&&s.children.length>0&&Ho(s.children,t)}return t}var Zh=Ye,Kh=Nt,qe=class{static decode(t){t=new Kh(T(t));let e=Ot.getRootAsFooter(t),n=P.decode(e.schema(),new Map,e.version());return new Yo(n,e)}static encode(t){let e=new Zh,n=P.encode(e,t.schema);Ot.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())_e.encode(e,o);let i=e.endVector();Ot.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())_e.encode(e,o);let s=e.endVector();return Ot.startFooter(e),Ot.addSchema(e,n),Ot.addVersion(e,H.V5),Ot.addRecordBatches(e,i),Ot.addDictionaries(e,s),Ot.finishFooterBuffer(e,Ot.endFooter(e)),e.asUint8Array()}get numRecordBatches(){return this._recordBatches.length}get numDictionaries(){return this._dictionaryBatches.length}constructor(t,e=H.V5,n,i){this.schema=t,this.version=e,n&&(this._recordBatches=n),i&&(this._dictionaryBatches=i)}*recordBatches(){for(let t,e=-1,n=this.numRecordBatches;++e<n;)(t=this.getRecordBatch(e))&&(yield t)}*dictionaryBatches(){for(let t,e=-1,n=this.numDictionaries;++e<n;)(t=this.getDictionaryBatch(e))&&(yield t)}getRecordBatch(t){return t>=0&&t<this.numRecordBatches&&this._recordBatches[t]||null}getDictionaryBatch(t){return t>=0&&t<this.numDictionaries&&this._dictionaryBatches[t]||null}};var Yo=class extends qe{get numRecordBatches(){return this._footer.recordBatchesLength()}get numDictionaries(){return this._footer.dictionariesLength()}constructor(t,e){super(t,e.version()),this._footer=e}getRecordBatch(t){if(t>=0&&t<this.numRecordBatches){let e=this._footer.recordBatches(t);if(e)return _e.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return _e.decode(e)}return null}},_e=class{static decode(t){return new _e(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){let{metaDataLength:n}=e,i=BigInt(e.offset),s=BigInt(e.bodyLength);return Rr.createBlock(t,i,n,s)}constructor(t,e,n){this.metaDataLength=t,this.offset=W(n),this.bodyLength=W(e)}};var tt=Object.freeze({done:!0,value:void 0}),Hn=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},Pr=class{tee(){return this._getDOMStream().tee()}pipe(t,e){return this._getNodeStream().pipe(t,e)}pipeTo(t,e){return this._getDOMStream().pipeTo(t,e)}pipeThrough(t,e){return this._getDOMStream().pipeThrough(t,e)}_getDOMStream(){return this._DOMStream||(this._DOMStream=this.toDOMStream())}_getNodeStream(){return this._nodeStream||(this._nodeStream=this.toNodeStream())}},vs=class extends Pr{constructor(){super(),this._values=[],this.resolvers=[],this._closedPromise=new Promise(t=>this._closedPromiseResolve=t)}get closed(){return this._closedPromise}cancel(t){return y(this,void 0,void 0,function*(){yield this.return(t)})}write(t){this._ensureOpen()&&(this.resolvers.length<=0?this._values.push(t):this.resolvers.shift().resolve({done:!1,value:t}))}abort(t){this._closedPromiseResolve&&(this.resolvers.length<=0?this._error={error:t}:this.resolvers.shift().reject({done:!0,value:t}))}close(){if(this._closedPromiseResolve){let{resolvers:t}=this;for(;t.length>0;)t.shift().resolve(tt);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return wt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return wt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return y(this,void 0,void 0,function*(){return yield this.abort(t),tt})}return(t){return y(this,void 0,void 0,function*(){return yield this.close(),tt})}read(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(...t){return this._values.length>0?Promise.resolve({done:!1,value:this._values.shift()}):this._error?Promise.reject({done:!0,value:this._error.error}):this._closedPromiseResolve?new Promise((e,n)=>{this.resolvers.push({resolve:e,reject:n})}):Promise.resolve(tt)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var Je=class extends vs{write(t){if((t=T(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Un(this.toUint8Array(!0)):this.toUint8Array(!1).then(Un)}toUint8Array(t=!1){return t?Yt(this._values)[0]:(()=>y(this,void 0,void 0,function*(){var e,n,i,s;let o=[],a=0;try{for(var c=!0,l=ce(this),u;u=yield l.next(),e=u.done,!e;c=!0){s=u.value,c=!1;let f=s;o.push(f),a+=f.byteLength}}catch(f){n={error:f}}finally{try{!c&&!e&&(i=l.return)&&(yield i.call(l))}finally{if(n)throw n.error}}return Yt(o,a)[0]}))()}},$e=class{constructor(t){t&&(this.source=new Zo(wt.fromIterable(t)))}[Symbol.iterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},Wt=class{constructor(t){t instanceof Wt?this.source=t.source:t instanceof Je?this.source=new Qe(wt.fromAsyncIterable(t)):zi(t)?this.source=new Qe(wt.fromNodeStream(t)):Mn(t)?this.source=new Qe(wt.fromDOMStream(t)):ki(t)?this.source=new Qe(wt.fromDOMStream(t.body)):ue(t)?this.source=new Qe(wt.fromIterable(t)):le(t)?this.source=new Qe(wt.fromAsyncIterable(t)):Qt(t)&&(this.source=new Qe(wt.fromAsyncIterable(t)))}[Symbol.asyncIterator](){return this}next(t){return this.source.next(t)}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}get closed(){return this.source.closed}cancel(t){return this.source.cancel(t)}peek(t){return this.source.peek(t)}read(t){return this.source.read(t)}},Zo=class{constructor(t){this.source=t}cancel(t){this.return(t)}peek(t){return this.next(t,"peek").value}read(t){return this.next(t,"read").value}next(t,e="read"){return this.source.next({cmd:e,size:t})}throw(t){return Object.create(this.source.throw&&this.source.throw(t)||tt)}return(t){return Object.create(this.source.return&&this.source.return(t)||tt)}},Qe=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return y(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return y(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return y(this,arguments,void 0,function*(e,n="read"){return yield this.source.next({cmd:n,size:e})})}throw(t){return y(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||tt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}return(t){return y(this,void 0,void 0,function*(){let e=this.source.return&&(yield this.source.return(t))||tt;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var Yn=class extends $e{constructor(t,e){super(),this.position=0,this.buffer=T(t),this.size=e===void 0?this.buffer.byteLength:e}readInt32(t){let{buffer:e,byteOffset:n}=this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)}seek(t){return this.position=Math.min(t,this.size),t<this.size}read(t){let{buffer:e,size:n,position:i}=this;return e&&i<n?(typeof t!="number"&&(t=Number.POSITIVE_INFINITY),this.position=Math.min(n,i+Math.min(n-i,t)),e.subarray(i,this.position)):null}readAt(t,e){let n=this.buffer,i=Math.min(this.size,t+e);return n?n.subarray(t,i):new Uint8Array(e)}close(){this.buffer&&(this.buffer=null)}throw(t){return this.close(),{done:!0,value:t}}return(t){return this.close(),{done:!0,value:t}}},yr=class extends Wt{constructor(t,e){super(),this.position=0,this._handle=t,typeof e=="number"?this.size=e:this._pending=(()=>y(this,void 0,void 0,function*(){this.size=(yield t.stat()).size,delete this._pending}))()}readInt32(t){return y(this,void 0,void 0,function*(){let{buffer:e,byteOffset:n}=yield this.readAt(t,4);return new DataView(e,n).getInt32(0,!0)})}seek(t){return y(this,void 0,void 0,function*(){return this._pending&&(yield this._pending),this.position=Math.min(t,this.size),t<this.size})}read(t){return y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:e,size:n,position:i}=this;if(e&&i<n){typeof t!="number"&&(t=Number.POSITIVE_INFINITY);let s=i,o=0,a=0,c=Math.min(n,s+Math.min(n-s,t)),l=new Uint8Array(Math.max(0,(this.position=c)-s));for(;(s+=a)<c&&(o+=a)<l.byteLength;)({bytesRead:a}=yield e.read(l,o,l.byteLength-o,s));return l}return null})}readAt(t,e){return y(this,void 0,void 0,function*(){this._pending&&(yield this._pending);let{_handle:n,size:i}=this;if(n&&t+e<i){let s=Math.min(i,t+e),o=new Uint8Array(s-t);return(yield n.read(o,0,e,t)).buffer}return new Uint8Array(e)})}close(){return y(this,void 0,void 0,function*(){let t=this._handle;this._handle=null,t&&(yield t.close())})}throw(t){return y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}return(t){return y(this,void 0,void 0,function*(){return yield this.close(),{done:!0,value:t}})}};var Xo={};ur(Xo,{BaseInt64:()=>Zn,Int128:()=>Gt,Int64:()=>_t,Uint64:()=>J});function bn(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var _n=8,Ko=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],Zn=class{constructor(t){this.buffer=t}high(){return this.buffer[1]}low(){return this.buffer[0]}_times(t){let e=new Uint32Array([this.buffer[1]>>>16,this.buffer[1]&65535,this.buffer[0]>>>16,this.buffer[0]&65535]),n=new Uint32Array([t.buffer[1]>>>16,t.buffer[1]&65535,t.buffer[0]>>>16,t.buffer[0]&65535]),i=e[3]*n[3];this.buffer[0]=i&65535;let s=i>>>16;return i=e[2]*n[3],s+=i,i=e[3]*n[2]>>>0,s+=i,this.buffer[0]+=s<<16,this.buffer[1]=s>>>0<i?65536:0,this.buffer[1]+=s>>>16,this.buffer[1]+=e[1]*n[3]+e[2]*n[2]+e[3]*n[1],this.buffer[1]+=e[0]*n[3]+e[1]*n[2]+e[2]*n[1]+e[3]*n[0]<<16,this}_plus(t){let e=this.buffer[0]+t.buffer[0]>>>0;this.buffer[1]+=t.buffer[1],e<this.buffer[0]>>>0&&++this.buffer[1],this.buffer[0]=e}lessThan(t){return this.buffer[1]<t.buffer[1]||this.buffer[1]===t.buffer[1]&&this.buffer[0]<t.buffer[0]}equals(t){return this.buffer[1]===t.buffer[1]&&this.buffer[0]==t.buffer[0]}greaterThan(t){return t.lessThan(this)}hex(){return`${bn(this.buffer[1])} ${bn(this.buffer[0])}`}},J=class extends Zn{times(t){return this._times(t),this}plus(t){return this._plus(t),this}static from(t,e=new Uint32Array(2)){return J.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return J.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.length,i=new J(e);for(let s=0;s<n;){let o=_n<n-s?_n:n-s,a=new J(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new J(new Uint32Array([Ko[o],0]));i.times(c),i.plus(a),s+=o}return i}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)J.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new J(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new J(new Uint32Array(t.buffer)).plus(e)}},_t=class extends Zn{negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[0]==0&&++this.buffer[1],this}times(t){return this._times(t),this}plus(t){return this._plus(t),this}lessThan(t){let e=this.buffer[1]<<0,n=t.buffer[1]<<0;return e<n||e===n&&this.buffer[0]<t.buffer[0]}static from(t,e=new Uint32Array(2)){return _t.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return _t.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.startsWith("-"),i=t.length,s=new _t(e);for(let o=n?1:0;o<i;){let a=_n<i-o?_n:i-o,c=new _t(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new _t(new Uint32Array([Ko[a],0]));s.times(l),s.plus(c),o+=a}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*2);for(let n=-1,i=t.length;++n<i;)_t.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new _t(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new _t(new Uint32Array(t.buffer)).plus(e)}},Gt=class{constructor(t){this.buffer=t}high(){return new _t(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new _t(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset,2))}negate(){return this.buffer[0]=~this.buffer[0]+1,this.buffer[1]=~this.buffer[1],this.buffer[2]=~this.buffer[2],this.buffer[3]=~this.buffer[3],this.buffer[0]==0&&++this.buffer[1],this.buffer[1]==0&&++this.buffer[2],this.buffer[2]==0&&++this.buffer[3],this}times(t){let e=new J(new Uint32Array([this.buffer[3],0])),n=new J(new Uint32Array([this.buffer[2],0])),i=new J(new Uint32Array([this.buffer[1],0])),s=new J(new Uint32Array([this.buffer[0],0])),o=new J(new Uint32Array([t.buffer[3],0])),a=new J(new Uint32Array([t.buffer[2],0])),c=new J(new Uint32Array([t.buffer[1],0])),l=new J(new Uint32Array([t.buffer[0],0])),u=J.multiply(s,l);this.buffer[0]=u.low();let f=new J(new Uint32Array([u.high(),0]));return u=J.multiply(i,l),f.plus(u),u=J.multiply(s,c),f.plus(u),this.buffer[1]=f.low(),this.buffer[3]=f.lessThan(u)?1:0,this.buffer[2]=f.high(),new J(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2)).plus(J.multiply(n,l)).plus(J.multiply(i,c)).plus(J.multiply(s,a)),this.buffer[3]+=J.multiply(e,l).plus(J.multiply(n,c)).plus(J.multiply(i,a)).plus(J.multiply(s,o)).low(),this}plus(t){let e=new Uint32Array(4);return e[3]=this.buffer[3]+t.buffer[3]>>>0,e[2]=this.buffer[2]+t.buffer[2]>>>0,e[1]=this.buffer[1]+t.buffer[1]>>>0,e[0]=this.buffer[0]+t.buffer[0]>>>0,e[0]<this.buffer[0]>>>0&&++e[1],e[1]<this.buffer[1]>>>0&&++e[2],e[2]<this.buffer[2]>>>0&&++e[3],this.buffer[3]=e[3],this.buffer[2]=e[2],this.buffer[1]=e[1],this.buffer[0]=e[0],this}hex(){return`${bn(this.buffer[3])} ${bn(this.buffer[2])} ${bn(this.buffer[1])} ${bn(this.buffer[0])}`}static multiply(t,e){return new Gt(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new Gt(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return Gt.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return Gt.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let n=t.startsWith("-"),i=t.length,s=new Gt(e);for(let o=n?1:0;o<i;){let a=_n<i-o?_n:i-o,c=new Gt(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new Gt(new Uint32Array([Ko[a],0,0,0]));s.times(l),s.plus(c),o+=a}return n?s.negate():s}static convertArray(t){let e=new Uint32Array(t.length*4);for(let n=-1,i=t.length;++n<i;)Gt.from(t[n],new Uint32Array(e.buffer,e.byteOffset+4*4*n,4));return e}};var Kn=class extends x{constructor(t,e,n,i,s=H.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=e,this.buffers=n,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof E?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return w({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),children:this.visitMany(t.children)})}visitUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return this.metadataVersion<H.V5&&this.readNullBitmap(t,n),t.mode===q.Sparse?this.visitSparseUnion(t,{length:e,nullCount:n}):this.visitDenseUnion(t,{length:e,nullCount:n})}visitDenseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),child:this.visit(t.children[0])})}visitMap(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,e,n=this.nextBufferRange()){return e>0&&this.readData(t,n)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+e)}readDictionary(t){return this.dictionaries.get(t.id)}},Is=class extends Kn{constructor(t,e,n,i,s){super(new Uint8Array(0),e,n,i,s),this.sources=t}readNullBitmap(t,e,{offset:n}=this.nextBufferRange()){return e<=0?new Uint8Array(0):Mr(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return R(Uint8Array,R(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return R(Uint8Array,R(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;return m.isTimestamp(t)?R(Uint8Array,_t.convertArray(n[e])):(m.isInt(t)||m.isTime(t))&&t.bitWidth===64||m.isDuration(t)?R(Uint8Array,_t.convertArray(n[e])):m.isDate(t)&&t.unit===at.MILLISECOND?R(Uint8Array,_t.convertArray(n[e])):m.isDecimal(t)?R(Uint8Array,Gt.convertArray(n[e])):m.isBinary(t)||m.isLargeBinary(t)||m.isFixedSizeBinary(t)?Xh(n[e]):m.isBool(t)?Mr(n[e]):m.isUtf8(t)||m.isLargeUtf8(t)?ve(n[e].join("")):R(Uint8Array,R(t.ArrayType,n[e].map(i=>+i)))}};function Xh(r){let t=r.join(""),e=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)e[n>>1]=Number.parseInt(t.slice(n,n+2),16);return e}var wn=class extends zt{constructor(t){super(t),this._values=new be(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,T(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)n.set(o,0);else{let c=a.length;i.set(a,s),n.set(o,c),s+=c}}};var vn=class extends zt{constructor(t){super(t),this._values=new be(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,T(e))}_flushPending(t,e){let n=this._offsets,i=this._values.reserve(e).buffer,s=0;for(let[o,a]of t)if(a===void 0)n.set(o,BigInt(0));else{let c=a.length;i.set(a,s),n.set(o,BigInt(c)),s+=c}}};var xs=class extends rt{constructor(t){super(t),this._values=new yn}setValue(t,e){this._values.set(t,+e)}};var jr=class extends ft{};jr.prototype._setValue=No;var Xn=class extends jr{};Xn.prototype._setValue=Ki;var qn=class extends jr{};qn.prototype._setValue=Xi;var Qn=class extends ft{};Qn.prototype._setValue=Mo;var Ss=class extends rt{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new Vt(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=kr({type:this.type.indices,nullValues:e}),this.dictionary=kr({type:this.type.dictionary,nullValues:null}),typeof n=="function"&&(this.valueToKey=n)}get values(){return this.indices.values}get nullCount(){return this.indices.nullCount}get nullBitmap(){return this.indices.nullBitmap}get byteLength(){return this.indices.byteLength+this.dictionary.byteLength}get reservedLength(){return this.indices.reservedLength+this.dictionary.reservedLength}get reservedByteLength(){return this.indices.reservedByteLength+this.dictionary.reservedByteLength}isValid(t){return this.indices.isValid(t)}setValid(t,e){let n=this.indices;return e=n.setValid(t,e),this.length=n.length,e}setValue(t,e){let n=this._keysToIndices,i=this.valueToKey(e),s=n[i];return s===void 0&&(n[i]=s=this._dictionaryOffset+this.dictionary.append(e).length-1),this.indices.setValue(t,s)}flush(){let t=this.type,e=this._dictionary,n=this.dictionary.toVector(),i=this.indices.flush().clone(t);return i.dictionary=e?e.concat(n):n,this.finished||(this._dictionaryOffset+=n.length),this._dictionary=i.dictionary,this.clear(),i}finish(){return this.indices.finish(),this.dictionary.finish(),this._dictionaryOffset=0,this._keysToIndices=Object.create(null),super.finish()}clear(){return this.indices.clear(),this.dictionary.clear(),super.clear()}valueToKey(t){return typeof t=="string"?t:`${t}`}};var ti=class extends ft{};ti.prototype._setValue=To;var Bs=class extends rt{setValue(t,e){let[n]=this.children,i=t*this.stride;for(let s=-1,o=e.length;++s<o;)n.set(i+s,e[s])}addChild(t,e="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");let n=this.children.push(t);return this.type=new ie(this.type.listSize,new E(e,t.type,!0)),n}};var Vr=class extends ft{setValue(t,e){this._values.set(t,e)}},As=class extends Vr{setValue(t,e){super.setValue(t,zn(e))}},Os=class extends Vr{},Ds=class extends Vr{};var zr=class extends ft{};zr.prototype._setValue=Eo;var ei=class extends zr{};ei.prototype._setValue=os;var ri=class extends zr{};ri.prototype._setValue=as;var tr=class extends ft{};tr.prototype._setValue=Co;var ni=class extends tr{};ni.prototype._setValue=cs;var ii=class extends tr{};ii.prototype._setValue=ls;var si=class extends tr{};si.prototype._setValue=us;var oi=class extends tr{};oi.prototype._setValue=hs;var oe=class extends ft{setValue(t,e){this._values.set(t,e)}},Fs=class extends oe{},Ts=class extends oe{},Ns=class extends oe{},Ls=class extends oe{},Us=class extends oe{},Ms=class extends oe{},Es=class extends oe{},Cs=class extends oe{};var Rs=class extends zt{constructor(t){super(t),this._offsets=new gn(t.type)}addChild(t,e="0"){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new re(new E(e,t.type,!0)),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(typeof s>"u")e.set(i,0);else{let o=s,a=o.length,c=e.set(i,a).buffer[i];for(let l=-1;++l<a;)n.set(c+l,o[l])}}};var Ps=class extends zt{set(t,e){return super.set(t,e)}setValue(t,e){let n=e instanceof Map?e:new Map(Object.entries(e)),i=this._pending||(this._pending=new Map),s=i.get(t);s&&(this._pendingLength-=s.size),this._pendingLength+=n.size,i.set(t,n)}addChild(t,e=`${this.numChildren}`){if(this.numChildren>0)throw new Error("ListBuilder can only have one child.");return this.children[this.numChildren]=t,this.type=new se(new E(e,t.type,!0),this.type.keysSorted),this.numChildren-1}_flushPending(t){let e=this._offsets,[n]=this.children;for(let[i,s]of t)if(s===void 0)e.set(i,0);else{let{[i]:o,[i+1]:a}=e.set(i,s.size).buffer;for(let c of s.entries())if(n.set(o,c),++o>=a)break}}};var js=class extends rt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var ks=class extends rt{setValue(t,e){let{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach((s,o)=>n[o].set(t,e[o]));case Map:return i.children.forEach((s,o)=>n[o].set(t,e.get(s.name)));default:return i.children.forEach((s,o)=>n[o].set(t,e[s.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(n=>n.setValid(t,e)),e}addChild(t,e=`${this.numChildren}`){let n=this.children.push(t);return this.type=new Z([...this.type.children,new E(e,t.type,!0)]),n}};var er=class extends ft{};er.prototype._setValue=Lo;var ai=class extends er{};ai.prototype._setValue=qi;var ci=class extends er{};ci.prototype._setValue=Qi;var li=class extends er{};li.prototype._setValue=ts;var ui=class extends er{};ui.prototype._setValue=es;var rr=class extends ft{};rr.prototype._setValue=Uo;var hi=class extends rr{};hi.prototype._setValue=rs;var fi=class extends rr{};fi.prototype._setValue=ns;var di=class extends rr{};di.prototype._setValue=is;var pi=class extends rr{};pi.prototype._setValue=ss;var In=class extends rt{constructor(t){super(t),this._typeIds=new Xe(Int8Array,0,1),typeof t.valueToChildTypeId=="function"&&(this._valueToChildTypeId=t.valueToChildTypeId)}get typeIdToChildIndex(){return this.type.typeIdToChildIndex}append(t,e){return this.set(this.length,t,e)}set(t,e,n){return n===void 0&&(n=this._valueToChildTypeId(this,e,t)),this.setValue(t,e,n),this}setValue(t,e,n){this._typeIds.set(t,n);let i=this.type.typeIdToChildIndex[n],s=this.children[i];s?.set(t,e)}addChild(t,e=`${this.children.length}`){let n=this.children.push(t),{type:{children:i,mode:s,typeIds:o}}=this,a=[...i,new E(e,t.type)];return this.type=new ne(s,[...o,n],a),n}_valueToChildTypeId(t,e,n){throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.")}},Vs=class extends In{},zs=class extends In{constructor(t){super(t),this._offsets=new Xe(Int32Array)}setValue(t,e,n){let i=this._typeIds.set(t,n).buffer[t],s=this.getChildAt(this.type.typeIdToChildIndex[i]),o=this._offsets.set(t,s.length).buffer[t];s?.set(o,e)}};var mi=class extends zt{constructor(t){super(t),this._values=new be(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,ve(e))}_flushPending(t,e){}};mi.prototype._flushPending=wn.prototype._flushPending;var yi=class extends zt{constructor(t){super(t),this._values=new be(Uint8Array)}get byteLength(){let t=this._pendingLength+this.length*4;return this._offsets&&(t+=this._offsets.byteLength),this._values&&(t+=this._values.byteLength),this._nulls&&(t+=this._nulls.byteLength),t}setValue(t,e){return super.setValue(t,ve(e))}_flushPending(t,e){}};yi.prototype._flushPending=vn.prototype._flushPending;var qo=class extends x{visitNull(){return js}visitBool(){return xs}visitInt(){return oe}visitInt8(){return Fs}visitInt16(){return Ts}visitInt32(){return Ns}visitInt64(){return Ls}visitUint8(){return Us}visitUint16(){return Ms}visitUint32(){return Es}visitUint64(){return Cs}visitFloat(){return Vr}visitFloat16(){return As}visitFloat32(){return Os}visitFloat64(){return Ds}visitUtf8(){return mi}visitLargeUtf8(){return yi}visitBinary(){return wn}visitLargeBinary(){return vn}visitFixedSizeBinary(){return ti}visitDate(){return jr}visitDateDay(){return Xn}visitDateMillisecond(){return qn}visitTimestamp(){return er}visitTimestampSecond(){return ai}visitTimestampMillisecond(){return ci}visitTimestampMicrosecond(){return li}visitTimestampNanosecond(){return ui}visitTime(){return rr}visitTimeSecond(){return hi}visitTimeMillisecond(){return fi}visitTimeMicrosecond(){return di}visitTimeNanosecond(){return pi}visitDecimal(){return Qn}visitList(){return Rs}visitStruct(){return ks}visitUnion(){return In}visitDenseUnion(){return zs}visitSparseUnion(){return Vs}visitDictionary(){return Ss}visitInterval(){return zr}visitIntervalDayTime(){return ei}visitIntervalYearMonth(){return ri}visitDuration(){return tr}visitDurationSecond(){return ni}visitDurationMillisecond(){return ii}visitDurationMicrosecond(){return si}visitDurationNanosecond(){return oi}visitFixedSizeList(){return Bs}visitMap(){return Ps}},el=new qo;var O=class extends x{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((n,i)=>this.compareFields(n,e[i]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}};function Lt(r,t){return t instanceof r.constructor}function Wr(r,t){return r===t||Lt(r,t)}function nr(r,t){return r===t||Lt(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function Ws(r,t){return r===t||Lt(r,t)&&r.precision===t.precision}function qh(r,t){return r===t||Lt(r,t)&&r.byteWidth===t.byteWidth}function Qo(r,t){return r===t||Lt(r,t)&&r.unit===t.unit}function gi(r,t){return r===t||Lt(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function bi(r,t){return r===t||Lt(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function Qh(r,t){return r===t||Lt(r,t)&&r.children.length===t.children.length&&He.compareManyFields(r.children,t.children)}function tf(r,t){return r===t||Lt(r,t)&&r.children.length===t.children.length&&He.compareManyFields(r.children,t.children)}function ta(r,t){return r===t||Lt(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&He.compareManyFields(r.children,t.children)}function ef(r,t){return r===t||Lt(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&He.visit(r.indices,t.indices)&&He.visit(r.dictionary,t.dictionary)}function ea(r,t){return r===t||Lt(r,t)&&r.unit===t.unit}function _i(r,t){return r===t||Lt(r,t)&&r.unit===t.unit}function rf(r,t){return r===t||Lt(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&He.compareManyFields(r.children,t.children)}function nf(r,t){return r===t||Lt(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&He.compareManyFields(r.children,t.children)}O.prototype.visitNull=Wr;O.prototype.visitBool=Wr;O.prototype.visitInt=nr;O.prototype.visitInt8=nr;O.prototype.visitInt16=nr;O.prototype.visitInt32=nr;O.prototype.visitInt64=nr;O.prototype.visitUint8=nr;O.prototype.visitUint16=nr;O.prototype.visitUint32=nr;O.prototype.visitUint64=nr;O.prototype.visitFloat=Ws;O.prototype.visitFloat16=Ws;O.prototype.visitFloat32=Ws;O.prototype.visitFloat64=Ws;O.prototype.visitUtf8=Wr;O.prototype.visitLargeUtf8=Wr;O.prototype.visitBinary=Wr;O.prototype.visitLargeBinary=Wr;O.prototype.visitFixedSizeBinary=qh;O.prototype.visitDate=Qo;O.prototype.visitDateDay=Qo;O.prototype.visitDateMillisecond=Qo;O.prototype.visitTimestamp=gi;O.prototype.visitTimestampSecond=gi;O.prototype.visitTimestampMillisecond=gi;O.prototype.visitTimestampMicrosecond=gi;O.prototype.visitTimestampNanosecond=gi;O.prototype.visitTime=bi;O.prototype.visitTimeSecond=bi;O.prototype.visitTimeMillisecond=bi;O.prototype.visitTimeMicrosecond=bi;O.prototype.visitTimeNanosecond=bi;O.prototype.visitDecimal=Wr;O.prototype.visitList=Qh;O.prototype.visitStruct=tf;O.prototype.visitUnion=ta;O.prototype.visitDenseUnion=ta;O.prototype.visitSparseUnion=ta;O.prototype.visitDictionary=ef;O.prototype.visitInterval=ea;O.prototype.visitIntervalDayTime=ea;O.prototype.visitIntervalYearMonth=ea;O.prototype.visitDuration=_i;O.prototype.visitDurationSecond=_i;O.prototype.visitDurationMillisecond=_i;O.prototype.visitDurationMicrosecond=_i;O.prototype.visitDurationNanosecond=_i;O.prototype.visitFixedSizeList=rf;O.prototype.visitMap=nf;var He=new O;function Gr(r,t){return He.compareSchemas(r,t)}function rl(r,t){return He.compareFields(r,t)}function nl(r,t){return He.visit(r,t)}function kr(r){let t=r.type,e=new(el.getVisitFn(t)())(r);if(t.children&&t.children.length>0){let n=r.children||[],i={nullValues:r.nullValues},s=Array.isArray(n)?(o,a)=>n[a]||i:({name:o})=>n[o]||i;for(let[o,a]of t.children.entries()){let{type:c}=a,l=s(a,o);e.children.push(kr(Object.assign(Object.assign({},l),{type:c})))}}return e}function Gs(r,t){return sf(r,t.map(e=>e.data.concat()))}function sf(r,t){let e=[...r.fields],n=[],i={numBatches:t.reduce((f,d)=>Math.max(f,d.length),0)},s=0,o=0,a=-1,c=t.length,l,u=[];for(;i.numBatches-- >0;){for(o=Number.POSITIVE_INFINITY,a=-1;++a<c;)u[a]=l=t[a].shift(),o=Math.min(o,l?l.length:o);Number.isFinite(o)&&(u=of(e,o,u,t,i),o>0&&(n[s++]=w({type:new Z(e),length:o,nullCount:0,children:u.slice()})))}return[r=r.assign(e),n.map(f=>new Y(r,f))]}function of(r,t,e,n,i){var s;let o=(t+63&-64)>>3;for(let a=-1,c=n.length;++a<c;){let l=e[a],u=l?.length;if(u>=t)u===t?e[a]=l:(e[a]=l.slice(0,t),i.numBatches=Math.max(i.numBatches,n[a].unshift(l.slice(t,u-t))));else{let f=r[a];r[a]=f.clone({nullable:!0}),e[a]=(s=l?._changeLengthAndBackfillNullBitmap(t))!==null&&s!==void 0?s:w({type:f.type,length:t,nullCount:t,nullBitmap:new Uint8Array(o)})}}return e}var il,st=class{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new P([]),this._offsets=[0],this;let i,s;t[0]instanceof P&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=c=>{if(c){if(c instanceof Y)return[c];if(c instanceof st)return c.batches;if(c instanceof k){if(c.type instanceof Z)return[new Y(new P(c.type.children),c)]}else{if(Array.isArray(c))return c.flatMap(l=>o(l));if(typeof c[Symbol.iterator]=="function")return[...c].flatMap(l=>o(l));if(typeof c=="object"){let l=Object.keys(c),u=l.map(p=>new _([c[p]])),f=i??new P(l.map((p,g)=>new E(String(p),u[g].type,u[g].nullable))),[,d]=Gs(f,u);return d.length===0?[new Y(c)]:d}}}return[]},a=t.flatMap(c=>o(c));if(i=(n=i??((e=a[0])===null||e===void 0?void 0:e.schema))!==null&&n!==void 0?n:new P([]),!(i instanceof P))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof Y))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Gr(i,c.schema))throw new TypeError("Table and inner RecordBatch schemas must be equivalent.")}this.schema=i,this.batches=a,this._offsets=s??ys(this.data)}get data(){return this.batches.map(({data:t})=>t)}get numCols(){return this.schema.fields.length}get numRows(){return this.data.reduce((t,e)=>t+e.length,0)}get nullCount(){return this._nullCount===-1&&(this._nullCount=ms(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(Nr(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?dn.visit(new _(this.data)):new Array(0)[Symbol.iterator]()}toArray(){return[...this]}toString(){return`[
13
+ return true;`)}function _h(r){return typeof r!="bigint"?ye(r):`${ye(r)}n`}function Qo(r,t){let e=Math.ceil(r)*t-1;return(e-e%64+64||64)/t}function yl(r,t=0){return r.length>=t?r.subarray(0,t):Vn(new r.constructor(t),r,0)}var _e=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?Qo(n*1,this.BYTES_PER_ELEMENT):Qo(n*2,this.BYTES_PER_ELEMENT))}return this}flush(t=this.length){t=Qo(t*this.stride,this.BYTES_PER_ELEMENT);let e=yl(this.buffer,t);return this.clear(),e}clear(){return this.length=0,this.buffer=new this.ArrayType,this}_resize(t){return this.buffer=yl(this.buffer,t)}},Qe=class extends _e{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}},wn=class extends Qe{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()}},vn=class extends Qe{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=te(t),this._nulls=new wn,e&&e.length>0&&(this._isValid=ml(e))}toVector(){return new _([this.flush()])}get ArrayType(){return this.type.ArrayType}get nullCount(){return this._nulls.numInvalid}get numChildren(){return this.children.length}get byteLength(){let t=0,{_offsets:e,_values:n,_nulls:i,_typeIds:s,children:o}=this;return e&&(t+=e.byteLength),n&&(t+=n.byteLength),i&&(t+=i.byteLength),s&&(t+=s.byteLength),o.reduce((a,c)=>a+c.byteLength,t)}get reservedLength(){return this._nulls.reservedLength}get reservedByteLength(){let t=0;return this._offsets&&(t+=this._offsets.reservedByteLength),this._values&&(t+=this._values.reservedByteLength),this._nulls&&(t+=this._nulls.reservedByteLength),this._typeIds&&(t+=this._typeIds.reservedByteLength),this.children.reduce((e,n)=>e+n.reservedByteLength,t)}get valueOffsets(){return this._offsets?this._offsets.buffer:null}get values(){return this._values?this._values.buffer:null}get nullBitmap(){return this._nulls?this._nulls.buffer:null}get typeIds(){return this._typeIds?this._typeIds.buffer:null}append(t){return this.set(this.length,t)}isValid(t){return this._isValid(t)}set(t,e){return this.setValid(t,this.isValid(e))&&this.setValue(t,e),this}setValue(t,e){this._setValue(this,t,e)}setValid(t,e){return this.length=this._nulls.set(t,+e).length,e}addChild(t,e=`${this.numChildren}`){throw new Error(`Cannot append children to non-nested type "${this.type}"`)}getChildAt(t){return this.children[t]||null}flush(){let t,e,n,i,{type:s,length:o,nullCount:a,_typeIds:c,_offsets:l,_values:u,_nulls: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}};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 dt=class extends rt{constructor(t){super(t),this._values=new Qe(this.ArrayType,0,this.stride)}setValue(t,e){let n=this._values;return n.reserve(t-n.length+1),super.setValue(t,e)}},$t=class extends rt{constructor(t){super(t),this._pendingLength=0,this._offsets=new vn(t.type)}setValue(t,e){let n=this._pending||(this._pending=new Map),i=n.get(t);i&&(this._pendingLength-=i.length),this._pendingLength+=e instanceof Ge?e[mr].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 Vr=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 Ft=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 Ft).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFooter(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}schema(t){let e=this.bb.__offset(this.bb_pos,6);return e?(t||new st).__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 Vr).__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 Vr).__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 tt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFooter(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,H.V1)}static addSchema(t,e){t.addFieldOffset(1,e,0)}static addDictionaries(t,e){t.addFieldOffset(2,e,0)}static startDictionariesVector(t,e){t.startVector(24,e,8)}static addRecordBatches(t,e){t.addFieldOffset(3,e,0)}static startRecordBatchesVector(t,e){t.startVector(24,e,8)}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endFooter(t){return t.endObject()}static finishFooterBuffer(t,e){t.finish(e)}static finishSizePrefixedFooterBuffer(t,e){t.finish(e,void 0,!0)}};var P=class{constructor(t=[],e,n,i=H.V5){this.fields=t||[],this.metadata=e||new Map,n||(n=ta(this.fields)),this.dictionaries=n,this.metadataVersion=i}get[Symbol.toStringTag](){return"Schema"}get names(){return this.fields.map(t=>t.name)}toString(){return`Schema<{ ${this.fields.map((t,e)=>`${e}: ${t}`).join(", ")} }>`}select(t){let e=new Set(t),n=this.fields.filter(i=>e.has(i.name));return new P(n,this.metadata)}selectAt(t){let e=t.map(n=>this.fields[n]).filter(Boolean);return new P(e,this.metadata)}assign(...t){let e=t[0]instanceof P?t[0]:Array.isArray(t[0])?new P(t[0]):new P(t),n=[...this.fields],i=Bs(Bs(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:Bs(Bs(new Map,n[c].metadata),a.metadata)}))&&!1:!0}),o=ta(s,new Map);return new P([...n,...s],i,new Map([...this.dictionaries,...o]))}};P.prototype.fields=null;P.prototype.metadata=null;P.prototype.dictionaries=null;var U=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 U(`${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],U.new(e,n,i,s)}};U.prototype.type=null;U.prototype.name=null;U.prototype.nullable=null;U.prototype.metadata=null;function Bs(r,t){return new Map([...r||new Map,...t||new Map])}function ta(r,t=new Map){for(let e=-1,n=r.length;++e<n;){let s=r[e].type;if(m.isDictionary(s)){if(!t.has(s.id))t.set(s.id,s.dictionary);else if(t.get(s.id)!==s.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}s.children&&s.children.length>0&&ta(s.children,t)}return t}var wh=Ke,vh=bt,tr=class{static decode(t){t=new vh(T(t));let e=Ft.getRootAsFooter(t),n=P.decode(e.schema(),new Map,e.version());return new ea(n,e)}static encode(t){let e=new wh,n=P.encode(e,t.schema);Ft.startRecordBatchesVector(e,t.numRecordBatches);for(let o of[...t.recordBatches()].slice().reverse())we.encode(e,o);let i=e.endVector();Ft.startDictionariesVector(e,t.numDictionaries);for(let o of[...t.dictionaryBatches()].slice().reverse())we.encode(e,o);let s=e.endVector();return Ft.startFooter(e),Ft.addSchema(e,n),Ft.addVersion(e,H.V5),Ft.addRecordBatches(e,i),Ft.addDictionaries(e,s),Ft.finishFooterBuffer(e,Ft.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 ea=class extends tr{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 we.decode(e)}return null}getDictionaryBatch(t){if(t>=0&&t<this.numDictionaries){let e=this._footer.dictionaries(t);if(e)return we.decode(e)}return null}},we=class{static decode(t){return new we(t.metaDataLength(),t.bodyLength(),t.offset())}static encode(t,e){let{metaDataLength:n}=e,i=BigInt(e.offset),s=BigInt(e.bodyLength);return Vr.createBlock(t,i,n,s)}constructor(t,e,n){this.metaDataLength=t,this.offset=J(n),this.bodyLength=J(e)}};var lt=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 lt).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new lt).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):H.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):j.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new tt).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,H.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,j.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,n,i,s,o){return lt.startMessage(t),lt.addVersion(t,e),lt.addHeaderType(t,n),lt.addHeader(t,i),lt.addBodyLength(t,s),lt.addCustomMetadata(t,o),lt.endMessage(t)}};var ra=class extends x{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Fe.startNull(e),Fe.endNull(e)}visitInt(t,e){return _t.startInt(e),_t.addBitWidth(e,t.bitWidth),_t.addIsSigned(e,t.isSigned),_t.endInt(e)}visitFloat(t,e){return zt.startFloatingPoint(e),zt.addPrecision(e,t.precision),zt.endFloatingPoint(e)}visitBinary(t,e){return Be.startBinary(e),Be.endBinary(e)}visitLargeBinary(t,e){return Oe.startLargeBinary(e),Oe.endLargeBinary(e)}visitBool(t,e){return Ae.startBool(e),Ae.endBool(e)}visitUtf8(t,e){return Le.startUtf8(e),Le.endUtf8(e)}visitLargeUtf8(t,e){return De.startLargeUtf8(e),De.endLargeUtf8(e)}visitDecimal(t,e){return wt.startDecimal(e),wt.addScale(e,t.scale),wt.addPrecision(e,t.precision),wt.addBitWidth(e,t.bitWidth),wt.endDecimal(e)}visitDate(t,e){return Pt.startDate(e),Pt.addUnit(e,t.unit),Pt.endDate(e)}visitTime(t,e){return Ot.startTime(e),Ot.addUnit(e,t.unit),Ot.addBitWidth(e,t.bitWidth),Ot.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return Dt.startTimestamp(e),Dt.addUnit(e,t.unit),n!==void 0&&Dt.addTimezone(e,n),Dt.endTimestamp(e)}visitInterval(t,e){return Wt.startInterval(e),Wt.addUnit(e,t.unit),Wt.endInterval(e)}visitDuration(t,e){return jt.startDuration(e),jt.addUnit(e,t.unit),jt.endDuration(e)}visitList(t,e){return Te.startList(e),Te.endList(e)}visitStruct(t,e){return Ne.startStruct_(e),Ne.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 Xt.startDictionaryEncoding(e),Xt.addId(e,BigInt(t.id)),Xt.addIsOrdered(e,t.isOrdered),n!==void 0&&Xt.addIndexType(e,n),Xt.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Vt.startFixedSizeBinary(e),Vt.addByteWidth(e,t.byteWidth),Vt.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return kt.startFixedSizeList(e),kt.addListSize(e,t.listSize),kt.endFixedSizeList(e)}visitMap(t,e){return Jt.startMap(e),Jt.addKeysSorted(e,t.keysSorted),Jt.endMap(e)}},As=new ra;function wl(r,t=new Map){return new P(Ih(r,t),Os(r.metadata),t)}function na(r){return new mt(r.count,Il(r.columns),xl(r.columns),null)}function vl(r){return new Nt(na(r.data),r.id,r.isDelta)}function Ih(r,t){return(r.fields||[]).filter(Boolean).map(e=>U.fromJSON(e,t))}function gl(r,t){return(r.children||[]).filter(Boolean).map(e=>U.fromJSON(e,t))}function Il(r){return(r||[]).reduce((t,e)=>[...t,new ce(e.count,xh(e.VALIDITY)),...Il(e.children)],[])}function xl(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new pt(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new pt(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new pt(t.length,i.OFFSET.length)),i.DATA&&t.push(new pt(t.length,i.DATA.length)),t=xl(i.children,t)}return t}function xh(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function Sl(r,t){let e,n,i,s,o,a;return!t||!(s=r.dictionary)?(o=_l(r,gl(r,t)),i=new U(r.name,o,r.nullable,Os(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?bl(n):new qt,a=new Gt(t.get(e),n,e,s.isOrdered),i=new U(r.name,a,r.nullable,Os(r.metadata))):(n=(n=s.indexType)?bl(n):new qt,t.set(e,o=_l(r,gl(r,t))),a=new Gt(o,n,e,s.isOrdered),i=new U(r.name,a,r.nullable,Os(r.metadata))),i||null}function Os(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function bl(r){return new ft(r.isSigned,r.bitWidth)}function _l(r,t){let e=r.type.name;switch(e){case"NONE":return new Tt;case"null":return new Tt;case"binary":return new Me;case"largebinary":return new Ee;case"utf8":return new Ue;case"largeutf8":return new Ce;case"bool":return new Re;case"list":return new ie((t||[])[0]);case"struct":return new Z(t||[]);case"struct_":return new Z(t||[])}switch(e){case"int":{let n=r.type;return new ft(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new Qt(K[n.precision])}case"decimal":{let n=r.type;return new Pe(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new je(ct[n.unit])}case"time":{let n=r.type;return new Ve(v[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new ke(v[n.unit],n.timezone)}case"interval":{let n=r.type;return new ze(Q[n.unit])}case"duration":{let n=r.type;return new We(v[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new se(q[o],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new Je(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new oe(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new ae((t||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var Sh=Ke,Bh=bt,yt=class{static fromJSON(t,e){let n=new yt(0,H.V5,e);return n._createHeader=Ah(t,e),n}static decode(t){t=new Bh(T(t));let e=lt.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new yt(n,i,s);return o._createHeader=Oh(e,s),o}static encode(t){let e=new Sh,n=-1;return t.isSchema()?n=P.encode(e,t.header()):t.isRecordBatch()?n=mt.encode(e,t.header()):t.isDictionaryBatch()&&(n=Nt.encode(e,t.header())),lt.startMessage(e),lt.addVersion(e,H.V5),lt.addHeader(e,n),lt.addHeaderType(e,t.headerType),lt.addBodyLength(e,BigInt(t.bodyLength)),lt.finishMessageBuffer(e,lt.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof P)return new yt(0,H.V5,j.Schema,t);if(t instanceof mt)return new yt(e,H.V5,j.RecordBatch,t);if(t instanceof Nt)return new yt(e,H.V5,j.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get compression(){return this._compression}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===j.Schema}isRecordBatch(){return this.headerType===j.RecordBatch}isDictionaryBatch(){return this.headerType===j.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),this._compression=i?.compression,i&&(this._createHeader=()=>i),this._bodyLength=J(t)}},mt=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}get compression(){return this._compression}constructor(t,e,n,i){this._nodes=e,this._buffers=n,this._length=J(t),this._compression=i}},Nt=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=J(e)}},pt=class{constructor(t,e){this.offset=J(t),this.length=J(e)}},ce=class{constructor(t,e){this.length=J(t),this.nullCount=J(e)}},kr=class{constructor(t,e=Sr.BUFFER){this.type=t,this.method=e}};function Ah(r,t){return()=>{switch(t){case j.Schema:return P.fromJSON(r);case j.RecordBatch:return mt.fromJSON(r);case j.DictionaryBatch:return Nt.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${j[t]}, type: ${t} }`)}}function Oh(r,t){return()=>{switch(t){case j.Schema:return P.decode(r.header(new st),new Map,r.version());case j.RecordBatch:return mt.decode(r.header(new St),r.version());case j.DictionaryBatch:return Nt.decode(r.header(new ne),r.version())}throw new Error(`Unrecognized Message type: { name: ${j[t]}, type: ${t} }`)}}U.encode=Ph;U.decode=Ch;U.fromJSON=Sl;P.encode=Rh;P.decode=Dh;P.fromJSON=wl;mt.encode=jh;mt.decode=Th;mt.fromJSON=na;Nt.encode=Vh;Nt.decode=Fh;Nt.fromJSON=vl;ce.encode=kh;ce.decode=Lh;pt.encode=zh;pt.decode=Nh;kr.encode=Tl;kr.decode=Dl;function Dh(r,t=new Map,e=H.V5){let n=Uh(r,t);return new P(n,Ds(r),t,e)}function Th(r,t=H.V5){return new mt(r.length(),Mh(r),Eh(r,t),Dl(r.compression()))}function Fh(r,t=H.V5){return new Nt(mt.decode(r.data(),t),r.id(),r.isDelta())}function Nh(r){return new pt(r.offset(),r.length())}function Lh(r){return new ce(r.length(),r.nullCount())}function Mh(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=ce.decode(e));return t}function Eh(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]=pt.decode(n));return e}function Uh(r,t){let e=[];for(let n,i=-1,s=-1,o=r.fieldsLength();++i<o;)(n=r.fields(i))&&(e[++s]=U.decode(n,t));return e}function Bl(r,t){let e=[];for(let n,i=-1,s=-1,o=r.childrenLength();++i<o;)(n=r.children(i))&&(e[++s]=U.decode(n,t));return e}function Ch(r,t){let e,n,i,s,o,a;return!t||!(a=r.dictionary())?(i=Ol(r,Bl(r,t)),n=new U(r.name(),i,r.nullable(),Ds(r))):t.has(e=J(a.id()))?(s=(s=a.indexType())?Al(s):new qt,o=new Gt(t.get(e),s,e,a.isOrdered()),n=new U(r.name(),o,r.nullable(),Ds(r))):(s=(s=a.indexType())?Al(s):new qt,t.set(e,i=Ol(r,Bl(r,t))),o=new Gt(i,s,e,a.isOrdered()),n=new U(r.name(),o,r.nullable(),Ds(r))),n||null}function Ds(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 Al(r){return new ft(r.isSigned(),r.bitWidth())}function Ol(r,t){let e=r.typeType();switch(e){case X.NONE:return new Tt;case X.Null:return new Tt;case X.Binary:return new Me;case X.LargeBinary:return new Ee;case X.Utf8:return new Ue;case X.LargeUtf8:return new Ce;case X.Bool:return new Re;case X.List:return new ie((t||[])[0]);case X.Struct_:return new Z(t||[])}switch(e){case X.Int:{let n=r.type(new _t);return new ft(n.isSigned(),n.bitWidth())}case X.FloatingPoint:{let n=r.type(new zt);return new Qt(n.precision())}case X.Decimal:{let n=r.type(new wt);return new Pe(n.scale(),n.precision(),n.bitWidth())}case X.Date:{let n=r.type(new Pt);return new je(n.unit())}case X.Time:{let n=r.type(new Ot);return new Ve(n.unit(),n.bitWidth())}case X.Timestamp:{let n=r.type(new Dt);return new ke(n.unit(),n.timezone())}case X.Interval:{let n=r.type(new Wt);return new ze(n.unit())}case X.Duration:{let n=r.type(new jt);return new We(n.unit())}case X.Union:{let n=r.type(new vt);return new se(n.mode(),n.typeIdsArray()||[],t||[])}case X.FixedSizeBinary:{let n=r.type(new Vt);return new Je(n.byteWidth())}case X.FixedSizeList:{let n=r.type(new kt);return new oe(n.listSize(),(t||[])[0])}case X.Map:{let n=r.type(new Jt);return new ae((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${X[e]}" (${e})`)}function Dl(r){return r?new kr(r.codec(),r.method()):null}function Rh(r,t){let e=t.fields.map(s=>U.encode(r,s));st.startFieldsVector(r,e.length);let n=st.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?st.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString(`${s}`),c=r.createString(`${o}`);return tt.startKeyValue(r),tt.addKey(r,a),tt.addValue(r,c),tt.endKeyValue(r)})):-1;return st.startSchema(r),st.addFields(r,n),st.addEndianness(r,Wh?hr.Little:hr.Big),i!==-1&&st.addCustomMetadata(r,i),st.endSchema(r)}function Ph(r,t){let e=-1,n=-1,i=-1,s=t.type,o=t.typeId;m.isDictionary(s)?(o=s.dictionary.typeId,i=As.visit(s,r),n=As.visit(s.dictionary,r)):n=As.visit(s,r);let a=(s.children||[]).map(u=>U.encode(r,u)),c=ut.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?ut.createCustomMetadataVector(r,[...t.metadata].map(([u,h])=>{let d=r.createString(`${u}`),p=r.createString(`${h}`);return tt.startKeyValue(r),tt.addKey(r,d),tt.addValue(r,p),tt.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),ut.startField(r),ut.addType(r,n),ut.addTypeType(r,o),ut.addChildren(r,c),ut.addNullable(r,!!t.nullable),e!==-1&&ut.addName(r,e),i!==-1&&ut.addDictionary(r,i),l!==-1&&ut.addCustomMetadata(r,l),ut.endField(r)}function jh(r,t){let e=t.nodes||[],n=t.buffers||[];St.startNodesVector(r,e.length);for(let a of e.slice().reverse())ce.encode(r,a);let i=r.endVector();St.startBuffersVector(r,n.length);for(let a of n.slice().reverse())pt.encode(r,a);let s=r.endVector(),o=null;return t.compression!==null&&(o=Tl(r,t.compression)),St.startRecordBatch(r),St.addLength(r,BigInt(t.length)),St.addNodes(r,i),St.addBuffers(r,s),t.compression!==null&&o&&St.addCompression(r,o),St.endRecordBatch(r)}function Tl(r,t){return At.startBodyCompression(r),At.addCodec(r,t.type),At.addMethod(r,t.method),At.endBodyCompression(r)}function Vh(r,t){let e=mt.encode(r,t.data);return ne.startDictionaryBatch(r),ne.addId(r,BigInt(t.id)),ne.addIsDelta(r,t.isDelta),ne.addData(r,e),ne.endDictionaryBatch(r)}function kh(r,t){return an.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function zh(r,t){return on.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var Wh=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var et=Object.freeze({done:!0,value:void 0}),Kn=class{constructor(t){this._json=t}get schema(){return this._json.schema}get batches(){return this._json.batches||[]}get dictionaries(){return this._json.dictionaries||[]}},zr=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())}},Ts=class extends zr{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(et);this._closedPromiseResolve(),this._closedPromiseResolve=void 0}}[Symbol.asyncIterator](){return this}toDOMStream(t){return xt.toDOMStream(this._closedPromiseResolve||this._error?this:this._values,t)}toNodeStream(t){return xt.toNodeStream(this._closedPromiseResolve||this._error?this:this._values,t)}throw(t){return g(this,void 0,void 0,function*(){return yield this.abort(t),et})}return(t){return g(this,void 0,void 0,function*(){return yield this.close(),et})}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(et)}_ensureOpen(){if(this._closedPromiseResolve)return!0;throw new Error("AsyncQueue is closed")}};var $e=class extends Ts{write(t){if((t=T(t)).byteLength>0)return super.write(t)}toString(t=!1){return t?Pn(this.toUint8Array(!0)):this.toUint8Array(!1).then(Pn)}toUint8Array(t=!1){return t?Kt(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=ue(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 Kt(o,a)[0]}))()}},He=class{constructor(t){t&&(this.source=new ia(xt.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)}},Ht=class{constructor(t){t instanceof Ht?this.source=t.source:t instanceof $e?this.source=new er(xt.fromAsyncIterable(t)):$i(t)?this.source=new er(xt.fromNodeStream(t)):jn(t)?this.source=new er(xt.fromDOMStream(t)):Ji(t)?this.source=new er(xt.fromDOMStream(t.body)):he(t)?this.source=new er(xt.fromIterable(t)):fe(t)?this.source=new er(xt.fromAsyncIterable(t)):ee(t)&&(this.source=new er(xt.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)}},ia=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)||et)}return(t){return Object.create(this.source.return&&this.source.return(t)||et)}},er=class{constructor(t){this.source=t,this._closedPromise=new Promise(e=>this._closedPromiseResolve=e)}cancel(t){return g(this,void 0,void 0,function*(){yield this.return(t)})}get closed(){return this._closedPromise}read(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"read")).value})}peek(t){return g(this,void 0,void 0,function*(){return(yield this.next(t,"peek")).value})}next(t){return g(this,arguments,void 0,function*(e,n="read"){return yield this.source.next({cmd:n,size:e})})}throw(t){return g(this,void 0,void 0,function*(){let e=this.source.throw&&(yield this.source.throw(t))||et;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))||et;return this._closedPromiseResolve&&this._closedPromiseResolve(),this._closedPromiseResolve=void 0,Object.create(e)})}};var Xn=class extends He{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}}},gr=class extends Ht{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 oa={};Ze(oa,{BaseInt64:()=>qn,Int128:()=>Yt,Int64:()=>It,Uint64:()=>$});function In(r){return r<0&&(r=4294967295+r+1),`0x${r.toString(16)}`}var xn=8,sa=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8],qn=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`${In(this.buffer[1])} ${In(this.buffer[0])}`}},$=class extends qn{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=xn<n-s?xn:n-s,a=new $(new Uint32Array([Number.parseInt(t.slice(s,s+o),10),0])),c=new $(new Uint32Array([sa[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)}},It=class extends qn{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 It.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(2)){return It.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(2)){let n=t.startsWith("-"),i=t.length,s=new It(e);for(let o=n?1:0;o<i;){let a=xn<i-o?xn:i-o,c=new It(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0])),l=new It(new Uint32Array([sa[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;)It.from(t[n],new Uint32Array(e.buffer,e.byteOffset+2*n*4,2));return e}static multiply(t,e){return new It(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new It(new Uint32Array(t.buffer)).plus(e)}},Yt=class{constructor(t){this.buffer=t}high(){return new It(new Uint32Array(this.buffer.buffer,this.buffer.byteOffset+8,2))}low(){return new It(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`${In(this.buffer[3])} ${In(this.buffer[2])} ${In(this.buffer[1])} ${In(this.buffer[0])}`}static multiply(t,e){return new Yt(new Uint32Array(t.buffer)).times(e)}static add(t,e){return new Yt(new Uint32Array(t.buffer)).plus(e)}static from(t,e=new Uint32Array(4)){return Yt.fromString(typeof t=="string"?t:t.toString(),e)}static fromNumber(t,e=new Uint32Array(4)){return Yt.fromString(t.toString(),e)}static fromString(t,e=new Uint32Array(4)){let n=t.startsWith("-"),i=t.length,s=new Yt(e);for(let o=n?1:0;o<i;){let a=xn<i-o?xn:i-o,c=new Yt(new Uint32Array([Number.parseInt(t.slice(o,o+a),10),0,0,0])),l=new Yt(new Uint32Array([sa[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;)Yt.from(t[n],new Uint32Array(e.buffer,e.byteOffset+4*4*n,4));return e}};var la={};Ze(la,{toIntervalDayTimeInt32Array:()=>aa,toIntervalDayTimeObjects:()=>Jh,toIntervalMonthDayNanoInt32Array:()=>ca,toIntervalMonthDayNanoObjects:()=>Gh});function aa(r){var t,e;let n=r.length,i=new Int32Array(n*2);for(let s=0,o=0;s<n;s++){let a=r[s];i[o++]=(t=a.days)!==null&&t!==void 0?t:0,i[o++]=(e=a.milliseconds)!==null&&e!==void 0?e:0}return i}function ca(r){var t,e;let n=r.length,i=new Int32Array(n*4);for(let s=0,o=0;s<n;s++){let a=r[s];i[o++]=(t=a.months)!==null&&t!==void 0?t:0,i[o++]=(e=a.days)!==null&&e!==void 0?e:0;let c=a.nanoseconds;c?(i[o++]=Number(BigInt(c)&BigInt(4294967295)),i[o++]=Number(BigInt(c)>>BigInt(32))):o+=2}return i}function Jh(r){let t=r.length,e=new Array(t/2);for(let n=0,i=0;n<t;n+=2)e[i++]={days:r[n],milliseconds:r[n+1]};return e}function Gh(r,t){let e=r.length,n=new Array(e/4);for(let i=0,s=0;i<e;i+=4){let o=BigInt(r[i+3])<<BigInt(32)|BigInt(r[i+2]>>>0);n[s++]={months:r[i],days:r[i+1],nanoseconds:t?`${o}`:o}}return n}var Sn=class extends x{constructor(t,e,n,i,s=H.V5){super(),this.nodesIndex=-1,this.buffersIndex=-1,this.bytes=t,this.nodes=e,this.buffers=n,this.dictionaries=i,this.metadataVersion=s}visit(t){return super.visit(t instanceof U?t.type:t)}visitNull(t,{length:e}=this.nextFieldNode()){return w({type:t,length:e})}visitBool(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitInt(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFloat(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeUtf8(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitLargeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),data:this.readData(t)})}visitFixedSizeBinary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDate(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTimestamp(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitTime(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDecimal(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitList(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}visitStruct(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),children:this.visitMany(t.children)})}visitUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return this.metadataVersion<H.V5&&this.readNullBitmap(t,n),t.mode===q.Sparse?this.visitSparseUnion(t,{length:e,nullCount:n}):this.visitDenseUnion(t,{length:e,nullCount:n})}visitDenseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),valueOffsets:this.readOffsets(t),children:this.visitMany(t.children)})}visitSparseUnion(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,typeIds:this.readTypeIds(t),children:this.visitMany(t.children)})}visitDictionary(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t.indices),dictionary:this.readDictionary(t)})}visitInterval(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitDuration(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),data:this.readData(t)})}visitFixedSizeList(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),child:this.visit(t.children[0])})}visitMap(t,{length:e,nullCount:n}=this.nextFieldNode()){return w({type:t,length:e,nullCount:n,nullBitmap:this.readNullBitmap(t,n),valueOffsets:this.readOffsets(t),child:this.visit(t.children[0])})}nextFieldNode(){return this.nodes[++this.nodesIndex]}nextBufferRange(){return this.buffers[++this.buffersIndex]}readNullBitmap(t,e,n=this.nextBufferRange()){return e>0&&this.readData(t,n)||new Uint8Array(0)}readOffsets(t,e){return this.readData(t,e)}readTypeIds(t,e){return this.readData(t,e)}readData(t,{length:e,offset:n}=this.nextBufferRange()){return this.bytes.subarray(n,n+e)}readDictionary(t){return this.dictionaries.get(t.id)}},Fs=class extends Sn{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):Rr(this.sources[n])}readOffsets(t,{offset:e}=this.nextBufferRange()){return R(Uint8Array,R(t.OffsetArrayType,this.sources[e]))}readTypeIds(t,{offset:e}=this.nextBufferRange()){return R(Uint8Array,R(t.ArrayType,this.sources[e]))}readData(t,{offset:e}=this.nextBufferRange()){let{sources:n}=this;if(m.isTimestamp(t))return R(Uint8Array,It.convertArray(n[e]));if((m.isInt(t)||m.isTime(t))&&t.bitWidth===64||m.isDuration(t))return R(Uint8Array,It.convertArray(n[e]));if(m.isDate(t)&&t.unit===ct.MILLISECOND)return R(Uint8Array,It.convertArray(n[e]));if(m.isDecimal(t))return R(Uint8Array,Yt.convertArray(n[e]));if(m.isBinary(t)||m.isLargeBinary(t)||m.isFixedSizeBinary(t))return $h(n[e]);if(m.isBool(t))return Rr(n[e]);if(m.isUtf8(t)||m.isLargeUtf8(t))return Ie(n[e].join(""));if(m.isInterval(t))switch(t.unit){case Q.DAY_TIME:return aa(n[e]);case Q.MONTH_DAY_NANO:return ca(n[e]);default:break}return R(Uint8Array,R(t.ArrayType,n[e].map(i=>+i)))}};function $h(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 Ns=class extends Sn{constructor(t,e,n,i,s){super(new Uint8Array(0),e,n,i,s),this.bodyChunks=t}readData(t,e=this.nextBufferRange()){return this.bodyChunks[this.buffersIndex]}};var Bn=class extends $t{constructor(t){super(t),this._values=new _e(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 An=class extends $t{constructor(t){super(t),this._values=new _e(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 Ls=class extends rt{constructor(t){super(t),this._values=new wn}setValue(t,e){this._values.set(t,+e)}};var Wr=class extends dt{};Wr.prototype._setValue=Po;var Qn=class extends Wr{};Qn.prototype._setValue=ts;var ti=class extends Wr{};ti.prototype._setValue=es;var ei=class extends dt{};ei.prototype._setValue=ko;var Ms=class extends rt{constructor({type:t,nullValues:e,dictionaryHashFunction:n}){super({type:new Gt(t.dictionary,t.indices,t.id,t.isOrdered)}),this._nulls=null,this._dictionaryOffset=0,this._keysToIndices=Object.create(null),this.indices=Jr({type:this.type.indices,nullValues:e}),this.dictionary=Jr({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 ri=class extends dt{};ri.prototype._setValue=Ro;var Es=class extends rt{setValue(t,e){let[n]=this.children,i=t*this.stride;for(let s=-1,o=this.stride;++s<o;)n.set(i+s,e[s])}setValid(t,e){return super.setValid(t,e)||this.children[0].setValid((t+1)*this.stride-1,!1),e}addChild(t,e="0"){if(this.numChildren>0)throw new Error("FixedSizeListBuilder can only have one child.");let n=this.children.push(t);return this.type=new oe(this.type.listSize,new U(e,t.type,!0)),n}};var Gr=class extends dt{setValue(t,e){this._values.set(t,e)}},Us=class extends Gr{setValue(t,e){super.setValue(t,Gn(e))}},Cs=class extends Gr{},Rs=class extends Gr{};var br=class extends dt{};br.prototype._setValue=zo;var ni=class extends br{};ni.prototype._setValue=us;var ii=class extends br{};ii.prototype._setValue=fs;var si=class extends br{};si.prototype._setValue=hs;var rr=class extends dt{};rr.prototype._setValue=Wo;var oi=class extends rr{};oi.prototype._setValue=ds;var ai=class extends rr{};ai.prototype._setValue=ps;var ci=class extends rr{};ci.prototype._setValue=ms;var li=class extends rr{};li.prototype._setValue=ys;var le=class extends dt{setValue(t,e){this._values.set(t,e)}},Ps=class extends le{},js=class extends le{},Vs=class extends le{},ks=class extends le{},zs=class extends le{},Ws=class extends le{},Js=class extends le{},Gs=class extends le{};var $s=class extends $t{constructor(t){super(t),this._offsets=new vn(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 ie(new U(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 Hs=class extends $t{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 ae(new U(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 Ys=class extends rt{setValue(t,e){}setValid(t,e){return this.length=Math.max(t+1,this.length),e}};var Zs=class extends rt{setValue(t,e){let{children:n,type:i}=this;switch(Array.isArray(e)||e.constructor){case!0:return i.children.forEach((s,o)=>n[o].set(t,e[o]));case Map:return i.children.forEach((s,o)=>n[o].set(t,e.get(s.name)));default:return i.children.forEach((s,o)=>n[o].set(t,e[s.name]))}}setValid(t,e){return super.setValid(t,e)||this.children.forEach(n=>n.setValid(t,e)),e}addChild(t,e=`${this.numChildren}`){let n=this.children.push(t);return this.type=new Z([...this.type.children,new U(e,t.type,!0)]),n}};var nr=class extends dt{};nr.prototype._setValue=jo;var ui=class extends nr{};ui.prototype._setValue=rs;var fi=class extends nr{};fi.prototype._setValue=ns;var hi=class extends nr{};hi.prototype._setValue=is;var di=class extends nr{};di.prototype._setValue=ss;var ir=class extends dt{};ir.prototype._setValue=Vo;var pi=class extends ir{};pi.prototype._setValue=os;var mi=class extends ir{};mi.prototype._setValue=as;var yi=class extends ir{};yi.prototype._setValue=cs;var gi=class extends ir{};gi.prototype._setValue=ls;var On=class extends rt{constructor(t){super(t),this._typeIds=new Qe(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),this.length=Math.max(t+1,this.length)}addChild(t,e=`${this.children.length}`){let n=this.children.push(t),{type:{children:i,mode:s,typeIds:o}}=this,a=[...i,new U(e,t.type)];return this.type=new se(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.")}},Ks=class extends On{},Xs=class extends On{constructor(t){super(t),this._offsets=new Qe(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),this.length=Math.max(t+1,this.length)}};var bi=class extends $t{constructor(t){super(t),this._values=new _e(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,Ie(e))}_flushPending(t,e){}};bi.prototype._flushPending=Bn.prototype._flushPending;var _i=class extends $t{constructor(t){super(t),this._values=new _e(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,Ie(e))}_flushPending(t,e){}};_i.prototype._flushPending=An.prototype._flushPending;var ua=class extends x{visitNull(){return Ys}visitBool(){return Ls}visitInt(){return le}visitInt8(){return Ps}visitInt16(){return js}visitInt32(){return Vs}visitInt64(){return ks}visitUint8(){return zs}visitUint16(){return Ws}visitUint32(){return Js}visitUint64(){return Gs}visitFloat(){return Gr}visitFloat16(){return Us}visitFloat32(){return Cs}visitFloat64(){return Rs}visitUtf8(){return bi}visitLargeUtf8(){return _i}visitBinary(){return Bn}visitLargeBinary(){return An}visitFixedSizeBinary(){return ri}visitDate(){return Wr}visitDateDay(){return Qn}visitDateMillisecond(){return ti}visitTimestamp(){return nr}visitTimestampSecond(){return ui}visitTimestampMillisecond(){return fi}visitTimestampMicrosecond(){return hi}visitTimestampNanosecond(){return di}visitTime(){return ir}visitTimeSecond(){return pi}visitTimeMillisecond(){return mi}visitTimeMicrosecond(){return yi}visitTimeNanosecond(){return gi}visitDecimal(){return ei}visitList(){return $s}visitStruct(){return Zs}visitUnion(){return On}visitDenseUnion(){return Xs}visitSparseUnion(){return Ks}visitDictionary(){return Ms}visitInterval(){return br}visitIntervalDayTime(){return ni}visitIntervalYearMonth(){return ii}visitIntervalMonthDayNano(){return si}visitDuration(){return rr}visitDurationSecond(){return oi}visitDurationMillisecond(){return ai}visitDurationMicrosecond(){return ci}visitDurationNanosecond(){return li}visitFixedSizeList(){return Es}visitMap(){return Hs}},Nl=new ua;var O=class extends x{compareSchemas(t,e){return t===e||e instanceof t.constructor&&this.compareManyFields(t.fields,e.fields)}compareManyFields(t,e){return t===e||Array.isArray(t)&&Array.isArray(e)&&t.length===e.length&&t.every((n,i)=>this.compareFields(n,e[i]))}compareFields(t,e){return t===e||e instanceof t.constructor&&t.name===e.name&&t.nullable===e.nullable&&this.visit(t.type,e.type)}};function Ct(r,t){return t instanceof r.constructor}function $r(r,t){return r===t||Ct(r,t)}function sr(r,t){return r===t||Ct(r,t)&&r.bitWidth===t.bitWidth&&r.isSigned===t.isSigned}function qs(r,t){return r===t||Ct(r,t)&&r.precision===t.precision}function Hh(r,t){return r===t||Ct(r,t)&&r.byteWidth===t.byteWidth}function fa(r,t){return r===t||Ct(r,t)&&r.unit===t.unit}function wi(r,t){return r===t||Ct(r,t)&&r.unit===t.unit&&r.timezone===t.timezone}function vi(r,t){return r===t||Ct(r,t)&&r.unit===t.unit&&r.bitWidth===t.bitWidth}function Yh(r,t){return r===t||Ct(r,t)&&r.children.length===t.children.length&&Ye.compareManyFields(r.children,t.children)}function Zh(r,t){return r===t||Ct(r,t)&&r.children.length===t.children.length&&Ye.compareManyFields(r.children,t.children)}function ha(r,t){return r===t||Ct(r,t)&&r.mode===t.mode&&r.typeIds.every((e,n)=>e===t.typeIds[n])&&Ye.compareManyFields(r.children,t.children)}function Kh(r,t){return r===t||Ct(r,t)&&r.id===t.id&&r.isOrdered===t.isOrdered&&Ye.visit(r.indices,t.indices)&&Ye.visit(r.dictionary,t.dictionary)}function Qs(r,t){return r===t||Ct(r,t)&&r.unit===t.unit}function Ii(r,t){return r===t||Ct(r,t)&&r.unit===t.unit}function Xh(r,t){return r===t||Ct(r,t)&&r.listSize===t.listSize&&r.children.length===t.children.length&&Ye.compareManyFields(r.children,t.children)}function qh(r,t){return r===t||Ct(r,t)&&r.keysSorted===t.keysSorted&&r.children.length===t.children.length&&Ye.compareManyFields(r.children,t.children)}O.prototype.visitNull=$r;O.prototype.visitBool=$r;O.prototype.visitInt=sr;O.prototype.visitInt8=sr;O.prototype.visitInt16=sr;O.prototype.visitInt32=sr;O.prototype.visitInt64=sr;O.prototype.visitUint8=sr;O.prototype.visitUint16=sr;O.prototype.visitUint32=sr;O.prototype.visitUint64=sr;O.prototype.visitFloat=qs;O.prototype.visitFloat16=qs;O.prototype.visitFloat32=qs;O.prototype.visitFloat64=qs;O.prototype.visitUtf8=$r;O.prototype.visitLargeUtf8=$r;O.prototype.visitBinary=$r;O.prototype.visitLargeBinary=$r;O.prototype.visitFixedSizeBinary=Hh;O.prototype.visitDate=fa;O.prototype.visitDateDay=fa;O.prototype.visitDateMillisecond=fa;O.prototype.visitTimestamp=wi;O.prototype.visitTimestampSecond=wi;O.prototype.visitTimestampMillisecond=wi;O.prototype.visitTimestampMicrosecond=wi;O.prototype.visitTimestampNanosecond=wi;O.prototype.visitTime=vi;O.prototype.visitTimeSecond=vi;O.prototype.visitTimeMillisecond=vi;O.prototype.visitTimeMicrosecond=vi;O.prototype.visitTimeNanosecond=vi;O.prototype.visitDecimal=$r;O.prototype.visitList=Yh;O.prototype.visitStruct=Zh;O.prototype.visitUnion=ha;O.prototype.visitDenseUnion=ha;O.prototype.visitSparseUnion=ha;O.prototype.visitDictionary=Kh;O.prototype.visitInterval=Qs;O.prototype.visitIntervalDayTime=Qs;O.prototype.visitIntervalYearMonth=Qs;O.prototype.visitIntervalMonthDayNano=Qs;O.prototype.visitDuration=Ii;O.prototype.visitDurationSecond=Ii;O.prototype.visitDurationMillisecond=Ii;O.prototype.visitDurationMicrosecond=Ii;O.prototype.visitDurationNanosecond=Ii;O.prototype.visitFixedSizeList=Xh;O.prototype.visitMap=qh;var Ye=new O;function Hr(r,t){return Ye.compareSchemas(r,t)}function Ll(r,t){return Ye.compareFields(r,t)}function Ml(r,t){return Ye.visit(r,t)}function Jr(r){let t=r.type,e=new(Nl.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(Jr(Object.assign(Object.assign({},l),{type:c})))}}return e}function to(r,t){return Qh(r,t.map(e=>e.data.concat()))}function Qh(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=td(e,o,u,t,i),o>0&&(n[s++]=w({type:new Z(e),length:o,nullCount:0,children:u.slice()})))}return[r=r.assign(e),n.map(h=>new Y(r,h))]}function td(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 El,ot=class{constructor(...t){var e,n;if(t.length===0)return this.batches=[],this.schema=new P([]),this._offsets=[0],this;let i,s;t[0]instanceof P&&(i=t.shift()),t.at(-1)instanceof Uint32Array&&(s=t.pop());let o=c=>{if(c){if(c instanceof Y)return[c];if(c instanceof ot)return c.batches;if(c instanceof V){if(c.type instanceof Z)return[new Y(new P(c.type.children),c)]}else{if(Array.isArray(c))return c.flatMap(l=>o(l));if(typeof c[Symbol.iterator]=="function")return[...c].flatMap(l=>o(l));if(typeof c=="object"){let l=Object.keys(c),u=l.map(p=>new _([c[p]])),h=i??new P(l.map((p,y)=>new U(String(p),u[y].type,u[y].nullable))),[,d]=to(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 P([]),!(i instanceof P))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");for(let c of a){if(!(c instanceof Y))throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");if(!Hr(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=ws(this.data)),this._nullCount}isValid(t){return!1}get(t){return null}at(t){return this.get(Er(t,this.numRows))}set(t,e){}indexOf(t,e){return-1}[Symbol.iterator](){return this.batches.length>0?gn.visit(new _(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 st(e,n.map(i=>new Y(e,i)))}slice(t,e){let n=this.schema;[t,e]=Wn({length:this.numRows},t,e);let i=gs(this.data,this._offsets,t,e);return new st(n,i.map(s=>new Y(n,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){let e=this.data.map(n=>n.children[t]);if(e.length===0){let{type:n}=this.schema.fields[t],i=w({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new _(e)}return null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new _([w({type:new At,length:this.numRows})]));let s=n.fields.slice(),o=s[t].clone({type:e.type}),a=this.schema.fields.map((c,l)=>this.getChildAt(l));[s[t],a[t]]=[o,e],[n,i]=Gs(n,a)}return new st(n,i)}select(t){let e=this.schema.fields.reduce((n,i,s)=>n.set(i.name,s),new Map);return this.selectAt(t.map(n=>e.get(n)).filter(n=>n>-1))}selectAt(t){let e=this.schema.selectAt(t),n=this.batches.map(i=>i.selectAt(t));return new st(e,n)}assign(t){let e=this.schema.fields,[n,i]=t.schema.fields.reduce((a,c,l)=>{let[u,f]=a,d=e.findIndex(p=>p.name===c.name);return~d?f[d]=l:u.push(l),a},[[],[]]),s=this.schema.assign(t.schema),o=[...e.map((a,c)=>[c,i[c]]).map(([a,c])=>c===void 0?this.getChildAt(a):t.getChildAt(c)),...n.map(a=>t.getChildAt(a))].filter(Boolean);return new st(...Gs(s,o))}};il=Symbol.toStringTag;st[il]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=fn($n),r.get=fn(ht.getVisitFn(h.Struct)),r.set=bs(vt.getVisitFn(h.Struct)),r.indexOf=_s(Cr.getVisitFn(h.Struct)),"Table"))(st.prototype);var ol,Y=class{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof P))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=w({nullCount:0,type:new Z(this.schema.fields),children:this.schema.fields.map(e=>w({type:e.type,nullCount:0}))})]=t,!(this.data instanceof k))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=sl(this.schema,this.data.children);break}case 1:{let[e]=t,{fields:n,children:i,length:s}=Object.keys(e).reduce((c,l,u)=>(c.children[u]=e[l],c.length=Math.max(c.length,e[l].length),c.fields[u]=E.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new P(n),a=w({type:new Z(n),length:s,children:i,nullCount:0});[this.schema,this.data]=sl(o,a.children,s);break}default:throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.")}}get dictionaries(){return this._dictionaries||(this._dictionaries=al(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return ht.visit(this.data,t)}at(t){return this.get(Nr(t,this.numRows))}set(t,e){return vt.visit(this.data,t,e)}indexOf(t,e){return Cr.visit(this.data,t,e)}[Symbol.iterator](){return dn.visit(new _([this.data]))}toArray(){return[...this]}concat(...t){return new st(this.schema,[this,...t])}slice(t,e){let[n]=new _([this.data]).slice(t,e).data;return new Y(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new _([this.data.children[t]]):null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=this.data;if(t>-1&&t<this.numCols){e||(e=new _([w({type:new At,length:this.numRows})]));let s=n.fields.slice(),o=i.children.slice(),a=s[t].clone({type:e.type});[s[t],o[t]]=[a,e.data[0]],n=new P(s,new Map(this.schema.metadata)),i=w({type:new Z(s),children:o})}return new Y(n,i)}select(t){let e=this.schema.select(t),n=new Z(e.fields),i=[];for(let s of t){let o=this.schema.fields.findIndex(a=>a.name===s);~o&&(i[o]=this.data.children[o])}return new Y(e,w({type:n,length:this.numRows,children:i}))}selectAt(t){let e=this.schema.selectAt(t),n=t.map(s=>this.data.children[s]).filter(Boolean),i=w({type:new Z(e.fields),length:this.numRows,children:n});return new Y(e,i)}};ol=Symbol.toStringTag;Y[ol]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Y.prototype);function sl(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;let i=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(let[a,c]of r.fields.entries()){let l=t[a];(!l||l.length!==e)&&(i[a]=c.clone({nullable:!0}),s[a]=(n=l?._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:w({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(i),w({type:new Z(i),length:e,children:s})]}function al(r,t,e=new Map){var n,i;if(((n=r?.length)!==null&&n!==void 0?n:0)>0&&r?.length===t?.length)for(let s=-1,o=r.length;++s<o;){let{type:a}=r[s],c=t[s];for(let l of[c,...((i=c?.dictionary)===null||i===void 0?void 0:i.data)||[]])al(a.children,l?.children,e);if(m.isDictionary(a)){let{id:l}=a;if(!e.has(l))c?.dictionary&&e.set(l,c.dictionary);else if(e.get(l)!==c.dictionary)throw new Error("Cannot create Schema containing two different dictionaries with the same Id")}}return e}var Jr=class extends Y{constructor(t){let e=t.fields.map(i=>w({type:i.type})),n=w({type:new Z(t.fields),nullCount:0,children:e});super(t,n)}};var ct=class{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsMessage(t,e){return(e||new ct).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsMessage(t,e){return t.setPosition(t.position()+4),(e||new ct).__init(t.readInt32(t.position())+t.position(),t)}version(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.readInt16(this.bb_pos+t):H.V1}headerType(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):j.NONE}header(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__union(t,this.bb_pos+e):null}bodyLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.readInt64(this.bb_pos+t):BigInt("0")}customMetadata(t,e){let n=this.bb.__offset(this.bb_pos,12);return n?(e||new Q).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+n)+t*4),this.bb):null}customMetadataLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}static startMessage(t){t.startObject(5)}static addVersion(t,e){t.addFieldInt16(0,e,H.V1)}static addHeaderType(t,e){t.addFieldInt8(1,e,j.NONE)}static addHeader(t,e){t.addFieldOffset(2,e,0)}static addBodyLength(t,e){t.addFieldInt64(3,e,BigInt("0"))}static addCustomMetadata(t,e){t.addFieldOffset(4,e,0)}static createCustomMetadataVector(t,e){t.startVector(4,e.length,4);for(let n=e.length-1;n>=0;n--)t.addOffset(e[n]);return t.endVector()}static startCustomMetadataVector(t,e){t.startVector(4,e,4)}static endMessage(t){return t.endObject()}static finishMessageBuffer(t,e){t.finish(e)}static finishSizePrefixedMessageBuffer(t,e){t.finish(e,void 0,!0)}static createMessage(t,e,n,i,s,o){return ct.startMessage(t),ct.addVersion(t,e),ct.addHeaderType(t,n),ct.addHeader(t,i),ct.addBodyLength(t,s),ct.addCustomMetadata(t,o),ct.endMessage(t)}};var ra=class extends x{visit(t,e){return t==null||e==null?void 0:super.visit(t,e)}visitNull(t,e){return Fe.startNull(e),Fe.endNull(e)}visitInt(t,e){return yt.startInt(e),yt.addBitWidth(e,t.bitWidth),yt.addIsSigned(e,t.isSigned),yt.endInt(e)}visitFloat(t,e){return Pt.startFloatingPoint(e),Pt.addPrecision(e,t.precision),Pt.endFloatingPoint(e)}visitBinary(t,e){return Se.startBinary(e),Se.endBinary(e)}visitLargeBinary(t,e){return Ae.startLargeBinary(e),Ae.endLargeBinary(e)}visitBool(t,e){return Be.startBool(e),Be.endBool(e)}visitUtf8(t,e){return Ne.startUtf8(e),Ne.endUtf8(e)}visitLargeUtf8(t,e){return Oe.startLargeUtf8(e),Oe.endLargeUtf8(e)}visitDecimal(t,e){return gt.startDecimal(e),gt.addScale(e,t.scale),gt.addPrecision(e,t.precision),gt.addBitWidth(e,t.bitWidth),gt.endDecimal(e)}visitDate(t,e){return Mt.startDate(e),Mt.addUnit(e,t.unit),Mt.endDate(e)}visitTime(t,e){return St.startTime(e),St.addUnit(e,t.unit),St.addBitWidth(e,t.bitWidth),St.endTime(e)}visitTimestamp(t,e){let n=t.timezone&&e.createString(t.timezone)||void 0;return Bt.startTimestamp(e),Bt.addUnit(e,t.unit),n!==void 0&&Bt.addTimezone(e,n),Bt.endTimestamp(e)}visitInterval(t,e){return jt.startInterval(e),jt.addUnit(e,t.unit),jt.endInterval(e)}visitDuration(t,e){return Et.startDuration(e),Et.addUnit(e,t.unit),Et.endDuration(e)}visitList(t,e){return De.startList(e),De.endList(e)}visitStruct(t,e){return Te.startStruct_(e),Te.endStruct_(e)}visitUnion(t,e){bt.startTypeIdsVector(e,t.typeIds.length);let n=bt.createTypeIdsVector(e,t.typeIds);return bt.startUnion(e),bt.addMode(e,t.mode),bt.addTypeIds(e,n),bt.endUnion(e)}visitDictionary(t,e){let n=this.visit(t.indices,e);return Zt.startDictionaryEncoding(e),Zt.addId(e,BigInt(t.id)),Zt.addIsOrdered(e,t.isOrdered),n!==void 0&&Zt.addIndexType(e,n),Zt.endDictionaryEncoding(e)}visitFixedSizeBinary(t,e){return Ct.startFixedSizeBinary(e),Ct.addByteWidth(e,t.byteWidth),Ct.endFixedSizeBinary(e)}visitFixedSizeList(t,e){return Rt.startFixedSizeList(e),Rt.addListSize(e,t.listSize),Rt.endFixedSizeList(e)}visitMap(t,e){return kt.startMap(e),kt.addKeysSorted(e,t.keysSorted),kt.endMap(e)}},Js=new ra;function hl(r,t=new Map){return new P(af(r,t),$s(r.metadata),t)}function na(r){return new It(r.count,dl(r.columns),pl(r.columns))}function fl(r){return new $t(na(r.data),r.id,r.isDelta)}function af(r,t){return(r.fields||[]).filter(Boolean).map(e=>E.fromJSON(e,t))}function cl(r,t){return(r.children||[]).filter(Boolean).map(e=>E.fromJSON(e,t))}function dl(r){return(r||[]).reduce((t,e)=>[...t,new ae(e.count,cf(e.VALIDITY)),...dl(e.children)],[])}function pl(r,t=[]){for(let e=-1,n=(r||[]).length;++e<n;){let i=r[e];i.VALIDITY&&t.push(new Jt(t.length,i.VALIDITY.length)),i.TYPE_ID&&t.push(new Jt(t.length,i.TYPE_ID.length)),i.OFFSET&&t.push(new Jt(t.length,i.OFFSET.length)),i.DATA&&t.push(new Jt(t.length,i.DATA.length)),t=pl(i.children,t)}return t}function cf(r){return(r||[]).reduce((t,e)=>t+ +(e===0),0)}function ml(r,t){let e,n,i,s,o,a;return!t||!(s=r.dictionary)?(o=ul(r,cl(r,t)),i=new E(r.name,o,r.nullable,$s(r.metadata))):t.has(e=s.id)?(n=(n=s.indexType)?ll(n):new Kt,a=new Vt(t.get(e),n,e,s.isOrdered),i=new E(r.name,a,r.nullable,$s(r.metadata))):(n=(n=s.indexType)?ll(n):new Kt,t.set(e,o=ul(r,cl(r,t))),a=new Vt(o,n,e,s.isOrdered),i=new E(r.name,a,r.nullable,$s(r.metadata))),i||null}function $s(r=[]){return new Map(r.map(({key:t,value:e})=>[t,e]))}function ll(r){return new ut(r.isSigned,r.bitWidth)}function ul(r,t){let e=r.type.name;switch(e){case"NONE":return new At;case"null":return new At;case"binary":return new Le;case"largebinary":return new Ue;case"utf8":return new Me;case"largeutf8":return new Ee;case"bool":return new Ce;case"list":return new re((t||[])[0]);case"struct":return new Z(t||[]);case"struct_":return new Z(t||[])}switch(e){case"int":{let n=r.type;return new ut(n.isSigned,n.bitWidth)}case"floatingpoint":{let n=r.type;return new Xt(K[n.precision])}case"decimal":{let n=r.type;return new Re(n.scale,n.precision,n.bitWidth)}case"date":{let n=r.type;return new Pe(at[n.unit])}case"time":{let n=r.type;return new je(v[n.unit],n.bitWidth)}case"timestamp":{let n=r.type;return new ke(v[n.unit],n.timezone)}case"interval":{let n=r.type;return new Ve(mt[n.unit])}case"duration":{let n=r.type;return new ze(v[n.unit])}case"union":{let n=r.type,[i,...s]=(n.mode+"").toLowerCase(),o=i.toUpperCase()+s.join("");return new ne(q[o],n.typeIds||[],t||[])}case"fixedsizebinary":{let n=r.type;return new We(n.byteWidth)}case"fixedsizelist":{let n=r.type;return new ie(n.listSize,(t||[])[0])}case"map":{let n=r.type;return new se((t||[])[0],n.keysSorted)}}throw new Error(`Unrecognized type: "${e}"`)}var lf=Ye,uf=Nt,dt=class{static fromJSON(t,e){let n=new dt(0,H.V5,e);return n._createHeader=hf(t,e),n}static decode(t){t=new uf(T(t));let e=ct.getRootAsMessage(t),n=e.bodyLength(),i=e.version(),s=e.headerType(),o=new dt(n,i,s);return o._createHeader=ff(e,s),o}static encode(t){let e=new lf,n=-1;return t.isSchema()?n=P.encode(e,t.header()):t.isRecordBatch()?n=It.encode(e,t.header()):t.isDictionaryBatch()&&(n=$t.encode(e,t.header())),ct.startMessage(e),ct.addVersion(e,H.V5),ct.addHeader(e,n),ct.addHeaderType(e,t.headerType),ct.addBodyLength(e,BigInt(t.bodyLength)),ct.finishMessageBuffer(e,ct.endMessage(e)),e.asUint8Array()}static from(t,e=0){if(t instanceof P)return new dt(0,H.V5,j.Schema,t);if(t instanceof It)return new dt(e,H.V5,j.RecordBatch,t);if(t instanceof $t)return new dt(e,H.V5,j.DictionaryBatch,t);throw new Error(`Unrecognized Message header: ${t}`)}get type(){return this.headerType}get version(){return this._version}get headerType(){return this._headerType}get bodyLength(){return this._bodyLength}header(){return this._createHeader()}isSchema(){return this.headerType===j.Schema}isRecordBatch(){return this.headerType===j.RecordBatch}isDictionaryBatch(){return this.headerType===j.DictionaryBatch}constructor(t,e,n,i){this._version=e,this._headerType=n,this.body=new Uint8Array(0),i&&(this._createHeader=()=>i),this._bodyLength=W(t)}},It=class{get nodes(){return this._nodes}get length(){return this._length}get buffers(){return this._buffers}constructor(t,e,n){this._nodes=e,this._buffers=n,this._length=W(t)}},$t=class{get id(){return this._id}get data(){return this._data}get isDelta(){return this._isDelta}get length(){return this.data.length}get nodes(){return this.data.nodes}get buffers(){return this.data.buffers}constructor(t,e,n=!1){this._data=t,this._isDelta=n,this._id=W(e)}},Jt=class{constructor(t,e){this.offset=W(t),this.length=W(e)}},ae=class{constructor(t,e){this.length=W(t),this.nullCount=W(e)}};function hf(r,t){return()=>{switch(t){case j.Schema:return P.fromJSON(r);case j.RecordBatch:return It.fromJSON(r);case j.DictionaryBatch:return $t.fromJSON(r)}throw new Error(`Unrecognized Message type: { name: ${j[t]}, type: ${t} }`)}}function ff(r,t){return()=>{switch(t){case j.Schema:return P.decode(r.header(new it),new Map,r.version());case j.RecordBatch:return It.decode(r.header(new xt),r.version());case j.DictionaryBatch:return $t.decode(r.header(new ee),r.version())}throw new Error(`Unrecognized Message type: { name: ${j[t]}, type: ${t} }`)}}E.encode=xf;E.decode=vf;E.fromJSON=ml;P.encode=If;P.decode=df;P.fromJSON=hl;It.encode=Sf;It.decode=pf;It.fromJSON=na;$t.encode=Bf;$t.decode=mf;$t.fromJSON=fl;ae.encode=Af;ae.decode=gf;Jt.encode=Of;Jt.decode=yf;function df(r,t=new Map,e=H.V5){let n=wf(r,t);return new P(n,Hs(r),t,e)}function pf(r,t=H.V5){if(r.compression()!==null)throw new Error("Record batch compression not implemented");return new It(r.length(),bf(r),_f(r,t))}function mf(r,t=H.V5){return new $t(It.decode(r.data(),t),r.id(),r.isDelta())}function yf(r){return new Jt(r.offset(),r.length())}function gf(r){return new ae(r.length(),r.nullCount())}function bf(r){let t=[];for(let e,n=-1,i=-1,s=r.nodesLength();++n<s;)(e=r.nodes(n))&&(t[++i]=ae.decode(e));return t}function _f(r,t){let e=[];for(let n,i=-1,s=-1,o=r.buffersLength();++i<o;)(n=r.buffers(i))&&(t<H.V4&&(n.bb_pos+=8*(i+1)),e[++s]=Jt.decode(n));return e}function wf(r,t){let e=[];for(let n,i=-1,s=-1,o=r.fieldsLength();++i<o;)(n=r.fields(i))&&(e[++s]=E.decode(n,t));return e}function yl(r,t){let e=[];for(let n,i=-1,s=-1,o=r.childrenLength();++i<o;)(n=r.children(i))&&(e[++s]=E.decode(n,t));return e}function vf(r,t){let e,n,i,s,o,a;return!t||!(a=r.dictionary())?(i=bl(r,yl(r,t)),n=new E(r.name(),i,r.nullable(),Hs(r))):t.has(e=W(a.id()))?(s=(s=a.indexType())?gl(s):new Kt,o=new Vt(t.get(e),s,e,a.isOrdered()),n=new E(r.name(),o,r.nullable(),Hs(r))):(s=(s=a.indexType())?gl(s):new Kt,t.set(e,i=bl(r,yl(r,t))),o=new Vt(i,s,e,a.isOrdered()),n=new E(r.name(),o,r.nullable(),Hs(r))),n||null}function Hs(r){let t=new Map;if(r)for(let e,n,i=-1,s=Math.trunc(r.customMetadataLength());++i<s;)(e=r.customMetadata(i))&&(n=e.key())!=null&&t.set(n,e.value());return t}function gl(r){return new ut(r.isSigned(),r.bitWidth())}function bl(r,t){let e=r.typeType();switch(e){case X.NONE:return new At;case X.Null:return new At;case X.Binary:return new Le;case X.LargeBinary:return new Ue;case X.Utf8:return new Me;case X.LargeUtf8:return new Ee;case X.Bool:return new Ce;case X.List:return new re((t||[])[0]);case X.Struct_:return new Z(t||[])}switch(e){case X.Int:{let n=r.type(new yt);return new ut(n.isSigned(),n.bitWidth())}case X.FloatingPoint:{let n=r.type(new Pt);return new Xt(n.precision())}case X.Decimal:{let n=r.type(new gt);return new Re(n.scale(),n.precision(),n.bitWidth())}case X.Date:{let n=r.type(new Mt);return new Pe(n.unit())}case X.Time:{let n=r.type(new St);return new je(n.unit(),n.bitWidth())}case X.Timestamp:{let n=r.type(new Bt);return new ke(n.unit(),n.timezone())}case X.Interval:{let n=r.type(new jt);return new Ve(n.unit())}case X.Duration:{let n=r.type(new Et);return new ze(n.unit())}case X.Union:{let n=r.type(new bt);return new ne(n.mode(),n.typeIdsArray()||[],t||[])}case X.FixedSizeBinary:{let n=r.type(new Ct);return new We(n.byteWidth())}case X.FixedSizeList:{let n=r.type(new Rt);return new ie(n.listSize(),(t||[])[0])}case X.Map:{let n=r.type(new kt);return new se((t||[])[0],n.keysSorted())}}throw new Error(`Unrecognized type: "${X[e]}" (${e})`)}function If(r,t){let e=t.fields.map(s=>E.encode(r,s));it.startFieldsVector(r,e.length);let n=it.createFieldsVector(r,e),i=t.metadata&&t.metadata.size>0?it.createCustomMetadataVector(r,[...t.metadata].map(([s,o])=>{let a=r.createString(`${s}`),c=r.createString(`${o}`);return Q.startKeyValue(r),Q.addKey(r,a),Q.addValue(r,c),Q.endKeyValue(r)})):-1;return it.startSchema(r),it.addFields(r,n),it.addEndianness(r,Df?hr.Little:hr.Big),i!==-1&&it.addCustomMetadata(r,i),it.endSchema(r)}function xf(r,t){let e=-1,n=-1,i=-1,s=t.type,o=t.typeId;m.isDictionary(s)?(o=s.dictionary.typeId,i=Js.visit(s,r),n=Js.visit(s.dictionary,r)):n=Js.visit(s,r);let a=(s.children||[]).map(u=>E.encode(r,u)),c=lt.createChildrenVector(r,a),l=t.metadata&&t.metadata.size>0?lt.createCustomMetadataVector(r,[...t.metadata].map(([u,f])=>{let d=r.createString(`${u}`),p=r.createString(`${f}`);return Q.startKeyValue(r),Q.addKey(r,d),Q.addValue(r,p),Q.endKeyValue(r)})):-1;return t.name&&(e=r.createString(t.name)),lt.startField(r),lt.addType(r,n),lt.addTypeType(r,o),lt.addChildren(r,c),lt.addNullable(r,!!t.nullable),e!==-1&&lt.addName(r,e),i!==-1&&lt.addDictionary(r,i),l!==-1&&lt.addCustomMetadata(r,l),lt.endField(r)}function Sf(r,t){let e=t.nodes||[],n=t.buffers||[];xt.startNodesVector(r,e.length);for(let o of e.slice().reverse())ae.encode(r,o);let i=r.endVector();xt.startBuffersVector(r,n.length);for(let o of n.slice().reverse())Jt.encode(r,o);let s=r.endVector();return xt.startRecordBatch(r),xt.addLength(r,BigInt(t.length)),xt.addNodes(r,i),xt.addBuffers(r,s),xt.endRecordBatch(r)}function Bf(r,t){let e=It.encode(r,t.data);return ee.startDictionaryBatch(r),ee.addId(r,BigInt(t.id)),ee.addIsDelta(r,t.isDelta),ee.addData(r,e),ee.endDictionaryBatch(r)}function Af(r,t){return rn.createFieldNode(r,BigInt(t.length),BigInt(t.nullCount))}function Of(r,t){return en.createBuffer(r,BigInt(t.offset),BigInt(t.length))}var Df=(()=>{let r=new ArrayBuffer(2);return new DataView(r).setInt16(0,256,!0),new Int16Array(r)[0]===256})();var sa=r=>`Expected ${j[r]} Message in stream, but was null or length 0.`,oa=r=>`Header pointer of flatbuffer-encoded ${j[r]} Message is null or length 0.`,_l=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,wl=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,xn=class{constructor(t){this.source=t instanceof $e?t:new $e(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?tt:t.value===-1&&(t=this.readMetadataLength()).done?tt:(t=this.readMetadata(t.value)).done?tt:t}throw(t){return this.source.throw(t)}return(t){return this.source.return(t)}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(sa(t));return e.value}readMessageBody(t){if(t<=0)return new Uint8Array(0);let e=T(this.source.read(t));if(e.byteLength<t)throw new Error(wl(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=j.Schema,n=this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(oa(e));return i}readMetadataLength(){let t=this.source.read(Ys),e=t&&new Nt(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}}readMetadata(t){let e=this.source.read(t);if(!e)return tt;if(e.byteLength<t)throw new Error(_l(t,e.byteLength));return{done:!1,value:dt.decode(e)}}},wi=class{constructor(t,e){this.source=t instanceof Wt?t:ji(t)?new yr(t,e):new Wt(t)}[Symbol.asyncIterator](){return this}next(){return y(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?tt:t.value===-1&&(t=yield this.readMetadataLength()).done?tt:(t=yield this.readMetadata(t.value)).done?tt:t})}throw(t){return y(this,void 0,void 0,function*(){return yield this.source.throw(t)})}return(t){return y(this,void 0,void 0,function*(){return yield this.source.return(t)})}readMessage(t){return y(this,void 0,void 0,function*(){let e;if((e=yield this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(sa(t));return e.value})}readMessageBody(t){return y(this,void 0,void 0,function*(){if(t<=0)return new Uint8Array(0);let e=T(yield this.source.read(t));if(e.byteLength<t)throw new Error(wl(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return y(this,arguments,void 0,function*(t=!1){let e=j.Schema,n=yield this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(oa(e));return i})}readMetadataLength(){return y(this,void 0,void 0,function*(){let t=yield this.source.read(Ys),e=t&&new Nt(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}})}readMetadata(t){return y(this,void 0,void 0,function*(){let e=yield this.source.read(t);if(!e)return tt;if(e.byteLength<t)throw new Error(_l(t,e.byteLength));return{done:!1,value:dt.decode(e)}})}},vi=class extends xn{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Hn?t:new Hn(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:dt.fromJSON(t.schema,j.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:dt.fromJSON(e,j.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:dt.fromJSON(e,j.RecordBatch)}}return this._body=[],tt}readMessageBody(t){return e(this._body);function e(n){return(n||[]).reduce((i,s)=>[...i,...s.VALIDITY&&[s.VALIDITY]||[],...s.TYPE_ID&&[s.TYPE_ID]||[],...s.OFFSET&&[s.OFFSET]||[],...s.DATA&&[s.DATA]||[],...e(s.children)],[])}}readMessage(t){let e;if((e=this.next()).done)return null;if(t!=null&&e.value.headerType!==t)throw new Error(sa(t));return e.value}readSchema(){let t=j.Schema,e=this.readMessage(t),n=e?.header();if(!e||!n)throw new Error(oa(t));return n}},Ys=4,ia="ARROW1",Sn=new Uint8Array(ia.length);for(let r=0;r<ia.length;r+=1)Sn[r]=ia.codePointAt(r);function Zs(r,t=0){for(let e=-1,n=Sn.length;++e<n;)if(Sn[e]!==r[t+e])return!1;return!0}var Bn=Sn.length,aa=Bn+Ys,vl=Bn*2+Ys;var Ut=class extends Pr{constructor(t){super(),this._impl=t}get closed(){return this._impl.closed}get schema(){return this._impl.schema}get autoDestroy(){return this._impl.autoDestroy}get dictionaries(){return this._impl.dictionaries}get numDictionaries(){return this._impl.numDictionaries}get numRecordBatches(){return this._impl.numRecordBatches}get footer(){return this._impl.isFile()?this._impl.footer:null}isSync(){return this._impl.isSync()}isAsync(){return this._impl.isAsync()}isFile(){return this._impl.isFile()}isStream(){return this._impl.isStream()}next(){return this._impl.next()}throw(t){return this._impl.throw(t)}return(t){return this._impl.return(t)}cancel(){return this._impl.cancel()}reset(t){return this._impl.reset(t),this._DOMStream=void 0,this._nodeStream=void 0,this}open(t){let e=this._impl.open(t);return le(e)?e.then(()=>this):this}readRecordBatch(t){return this._impl.isFile()?this._impl.readRecordBatch(t):null}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}toDOMStream(){return wt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return wt.toNodeStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this},{objectMode:!0})}static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}static from(t){return t instanceof Ut?t:Ri(t)?Tf(t):ji(t)?Uf(t):le(t)?(()=>y(this,void 0,void 0,function*(){return yield Ut.from(yield t)}))():ki(t)||Mn(t)||zi(t)||Qt(t)?Lf(new Wt(t)):Nf(new $e(t))}static readAll(t){return t instanceof Ut?t.isSync()?Il(t):xl(t):Ri(t)||ArrayBuffer.isView(t)||ue(t)||Pi(t)?Il(t):xl(t)}},ir=class extends Ut{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Ht(this,arguments,function*(){yield C(yield*Qr(ce(this[Symbol.iterator]())))})}},$r=class extends Ut{constructor(t){super(t),this._impl=t}readAll(){return y(this,void 0,void 0,function*(){var t,e,n,i;let s=new Array;try{for(var o=!0,a=ce(this),c;c=yield a.next(),t=c.done,!t;o=!0){i=c.value,o=!1;let l=i;s.push(l)}}catch(l){e={error:l}}finally{try{!o&&!t&&(n=a.return)&&(yield n.call(a))}finally{if(e)throw e.error}}return s})}[Symbol.iterator](){throw new Error("AsyncRecordBatchStreamReader is not Iterable")}[Symbol.asyncIterator](){return this._impl[Symbol.asyncIterator]()}},Hr=class extends ir{constructor(t){super(t),this._impl=t}},Ks=class extends $r{constructor(t){super(t),this._impl=t}},Xs=class{get numDictionaries(){return this._dictionaryIndex}get numRecordBatches(){return this._recordBatchIndex}constructor(t=new Map){this.closed=!1,this.autoDestroy=!0,this._dictionaryIndex=0,this._recordBatchIndex=0,this.dictionaries=t}isSync(){return!1}isAsync(){return!1}isFile(){return!1}isStream(){return!1}reset(t){return this._dictionaryIndex=0,this._recordBatchIndex=0,this.schema=t,this.dictionaries=new Map,this}_loadRecordBatch(t,e){let n=this._loadVectors(t,e,this.schema.fields),i=w({type:new Z(this.schema.fields),length:t.length,children:n});return new Y(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:o}=this,a=s.get(n),c=o.dictionaries.get(n),l=this._loadVectors(t.data,e,[c]);return(a&&i?a.concat(new _(l)):new _(l)).memoize()}_loadVectors(t,e,n){return new Kn(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}},An=class extends Xs{constructor(t,e){super(e),this._reader=Ri(t)?new vi(this._handle=t):new xn(this._handle=t)}isSync(){return!0}isStream(){return!0}[Symbol.iterator](){return this}cancel(){!this.closed&&(this.closed=!0)&&(this.reset()._reader.return(),this._reader=null,this.dictionaries=null)}open(t){return this.closed||(this.autoDestroy=Sl(this,t),this.schema||(this.schema=this._reader.readSchema())||this.cancel()),this}throw(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.throw(t):tt}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):tt}next(){if(this.closed)return tt;let t,{_reader:e}=this;for(;t=this._readNextMessageAndValidate();)if(t.isSchema())this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Jr(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},On=class extends Xs{constructor(t,e){super(e),this._reader=new wi(this._handle=t)}isAsync(){return!0}isStream(){return!0}[Symbol.asyncIterator](){return this}cancel(){return y(this,void 0,void 0,function*(){!this.closed&&(this.closed=!0)&&(yield this.reset()._reader.return(),this._reader=null,this.dictionaries=null)})}open(t){return y(this,void 0,void 0,function*(){return this.closed||(this.autoDestroy=Sl(this,t),this.schema||(this.schema=yield this._reader.readSchema())||(yield this.cancel())),this})}throw(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.throw(t):tt})}return(t){return y(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):tt})}next(){return y(this,void 0,void 0,function*(){if(this.closed)return tt;let t,{_reader:e}=this;for(;t=yield this._readNextMessageAndValidate();)if(t.isSchema())yield this.reset(t.header());else if(t.isRecordBatch()){this._recordBatchIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength);return{done:!1,value:this._loadRecordBatch(n,i)}}else if(t.isDictionaryBatch()){this._dictionaryIndex++;let n=t.header(),i=yield e.readMessageBody(t.bodyLength),s=this._loadDictionaryBatch(n,i);this.dictionaries.set(n.id,s)}return this.schema&&this._recordBatchIndex===0?(this._recordBatchIndex++,{done:!1,value:new Jr(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return y(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},qs=class extends An{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,e){super(t instanceof Yn?t:new Yn(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(j.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(j.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-aa,n=t.readInt32(e),i=t.readAt(e-n,n);return qe.decode(i)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(n&&this._handle.seek(n.offset))return this._reader.readMessage(t)}return null}},ca=class extends On{get footer(){return this._footer}get numDictionaries(){return this._footer?this._footer.numDictionaries:0}get numRecordBatches(){return this._footer?this._footer.numRecordBatches:0}constructor(t,...e){let n=typeof e[0]!="number"?e.shift():void 0,i=e[0]instanceof Map?e.shift():void 0;super(t instanceof yr?t:new yr(t,n),i)}isFile(){return!0}isAsync(){return!0}open(t){let e=Object.create(null,{open:{get:()=>super.open}});return y(this,void 0,void 0,function*(){if(!this.closed&&!this._footer){this.schema=(this._footer=yield this._readFooter()).schema;for(let n of this._footer.dictionaryBatches())n&&(yield this._readDictionaryBatch(this._dictionaryIndex++))}return yield e.open.call(this,t)})}readRecordBatch(t){return y(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(j.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return y(this,void 0,void 0,function*(){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(j.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return y(this,void 0,void 0,function*(){let{_handle:t}=this;t._pending&&(yield t._pending);let e=t.size-aa,n=yield t.readInt32(e),i=yield t.readAt(e-n,n);return qe.decode(i)})}_readNextMessageAndValidate(t){return y(this,void 0,void 0,function*(){if(this._footer||(yield this.open()),this._footer&&this._recordBatchIndex<this.numRecordBatches){let e=this._footer.getRecordBatch(this._recordBatchIndex);if(e&&(yield this._handle.seek(e.offset)))return yield this._reader.readMessage(t)}return null})}},la=class extends An{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new Is(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function Sl(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*Il(r){let t=Ut.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function xl(r){return Ht(this,arguments,function*(){let e=yield C(Ut.from(r));try{if(!(yield C(e.open({autoDestroy:!1}))).closed)do yield yield C(e);while(!(yield C(e.reset().open())).closed)}finally{yield C(e.cancel())}})}function Tf(r){return new ir(new la(r))}function Nf(r){let t=r.peek(Bn+7&-8);return t&&t.byteLength>=4?Zs(t)?new Hr(new qs(r.read())):new ir(new An(r)):new ir(new An(function*(){}()))}function Lf(r){return y(this,void 0,void 0,function*(){let t=yield r.peek(Bn+7&-8);return t&&t.byteLength>=4?Zs(t)?new Hr(new qs(yield r.read())):new $r(new On(r)):new $r(new On(function(){return Ht(this,arguments,function*(){})}()))})}function Uf(r){return y(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new yr(r,t);return t>=vl&&Zs(yield e.readAt(0,Bn+7&-8))?new Ks(new ca(e)):new $r(new On(e))})}var et=class extends x{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof Y?s.data.children:s.data),n=new et;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof _)return this.visitMany(t.data),this;let{type:e}=t;if(!m.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(m.isUnion(e))this.nodes.push(new ae(n,0));else{let{nullCount:i}=t;m.isNull(e)||we.call(this,i<=0?new Uint8Array(0):Ur(t.offset,n,t.nullBitmap)),this.nodes.push(new ae(n,i))}}return super.visit(t)}visitNull(t){return this}visitDictionary(t){return this.visit(t.clone(t.type.indices))}get nodes(){return this._nodes}get buffers(){return this._buffers}get byteLength(){return this._byteLength}get bufferRegions(){return this._bufferRegions}};function we(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new Jt(this._byteLength,t)),this._byteLength+=t,this}function Mf(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(we.call(this,i),e.mode===q.Sparse)return ua.call(this,r);if(e.mode===q.Dense){if(r.offset<=0)return we.call(this,s),ua.call(this,r);{let o=new Int32Array(n),a=Object.create(null),c=Object.create(null);for(let l,u,f=-1;++f<n;)(l=i[f])!==void 0&&((u=a[l])===void 0&&(u=a[l]=s[f]),o[f]=s[f]-u,c[l]=((t=c[l])!==null&&t!==void 0?t:0)+1);we.call(this,o),this.visitMany(r.children.map((l,u)=>{let f=e.typeIds[u],d=a[f],p=c[f];return l.slice(d,Math.min(n,p))}))}}return this}function Ef(r){let t;return r.nullCount>=r.length?we.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?we.call(this,Ur(r.offset,r.length,t)):we.call(this,Mr(r.values))}function sr(r){return we.call(this,r.values.subarray(0,r.length*r.stride))}function Qs(r){let{length:t,values:e,valueOffsets:n}=r,i=W(n[0]),s=W(n[t]),o=Math.min(s-i,e.byteLength-i);return we.call(this,Gi(-i,t+1,n)),we.call(this,e.subarray(i,i+o)),this}function ha(r){let{length:t,valueOffsets:e}=r;if(e){let{[0]:n,[t]:i}=e;return we.call(this,Gi(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function ua(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}et.prototype.visitBool=Ef;et.prototype.visitInt=sr;et.prototype.visitFloat=sr;et.prototype.visitUtf8=Qs;et.prototype.visitLargeUtf8=Qs;et.prototype.visitBinary=Qs;et.prototype.visitLargeBinary=Qs;et.prototype.visitFixedSizeBinary=sr;et.prototype.visitDate=sr;et.prototype.visitTimestamp=sr;et.prototype.visitTime=sr;et.prototype.visitDecimal=sr;et.prototype.visitList=ha;et.prototype.visitStruct=ua;et.prototype.visitUnion=Mf;et.prototype.visitInterval=sr;et.prototype.visitDuration=sr;et.prototype.visitFixedSizeList=ha;et.prototype.visitMap=ha;var Yr=class extends Pr{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){super(),this._position=0,this._started=!1,this._sink=new Je,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Tt(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return le(t)?t.then(e=>this.writeAll(e)):Qt(t)?da(this,t):fa(this,t)}get closed(){return this._sink.closed}[Symbol.asyncIterator](){return this._sink[Symbol.asyncIterator]()}toDOMStream(t){return this._sink.toDOMStream(t)}toNodeStream(t){return this._sink.toNodeStream(t)}close(){return this.reset()._sink.close()}abort(t){return this.reset()._sink.abort(t)}finish(){return this._autoDestroy?this.close():this.reset(this._sink,this._schema),this}reset(t=this._sink,e=null){return t===this._sink||t instanceof Je?this._sink=t:(this._sink=new Je,t&&ka(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&Va(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!e||!Gr(e,this._schema))&&(e==null?(this._position=0,this._schema=null):(this._started=!0,this._schema=e,this._writeSchema(e))),this}write(t){let e=null;if(this._sink){if(t==null)return this.finish()&&void 0;if(t instanceof st&&!(e=t.schema))return this.finish()&&void 0;if(t instanceof Y&&!(e=t.schema))return this.finish()&&void 0}else throw new Error("RecordBatchWriter is closed");if(e&&!Gr(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Y?t instanceof Jr||this._writeRecordBatch(t):t instanceof st?this.writeAll(t.batches):ue(t)&&this.writeAll(t)}_writeMessage(t,e=8){let n=e-1,i=dt.encode(t),s=i.byteLength,o=this._writeLegacyIpcFormat?4:8,a=s+o+n&~n,c=a-s-o;return t.headerType===j.RecordBatch?this._recordBatchBlocks.push(new _e(a,t.bodyLength,this._position)):t.headerType===j.DictionaryBatch&&this._dictionaryBlocks.push(new _e(a,t.bodyLength,this._position)),this._writeLegacyIpcFormat||this._write(Int32Array.of(-1)),this._write(Int32Array.of(a-o)),s>0&&this._write(i),this._writePadding(c)}_write(t){if(this._started){let e=T(t);e&&e.byteLength>0&&(this._sink.write(e),this._position+=e.byteLength)}return this}_writeSchema(t){return this._writeMessage(dt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Sn)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=et.assemble(t),o=new It(t.numRows,n,i),a=dt.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_writeDictionaryBatch(t,e,n=!1){let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=et.assemble(new _([t])),c=new It(t.length,s,o),l=new $t(c,e,n),u=dt.from(l,i);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e,n,i;for(let s=-1,o=t.length;++s<o;)(e=t[s])&&(n=e.byteLength)>0&&(this._write(e),(i=(n+7&-8)-n)>0&&this._writePadding(i));return this}_writeDictionaries(t){var e,n;for(let[i,s]of t.dictionaries){let o=(e=s?.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(i),c=(n=this._dictionaryDeltaOffsets.get(i))!==null&&n!==void 0?n:0;if(!a||a.data[0]!==o[0])for(let[l,u]of o.entries())this._writeDictionaryBatch(u,i,l>0);else if(c<o.length)for(let l of o.slice(c))this._writeDictionaryBatch(l,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,o.length)}return this}},Zr=class extends Yr{static writeAll(t,e){let n=new Zr(e);return le(t)?t.then(i=>n.writeAll(i)):Qt(t)?da(n,t):fa(n,t)}},Kr=class extends Yr{static writeAll(t){let e=new Kr;return le(t)?t.then(n=>e.writeAll(n)):Qt(t)?da(e,t):fa(e,t)}constructor(){super(),this._autoDestroy=!0}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,n=!1){if(!n&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,n)}_writeFooter(t){let e=qe.encode(new qe(t,H.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function fa(r,t){let e=t;t instanceof st&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function da(r,t){return y(this,void 0,void 0,function*(){var e,n,i,s,o,a,c;try{for(e=!0,n=ce(t);i=yield n.next(),s=i.done,!s;e=!0){c=i.value,e=!1;let l=c;r.write(l)}}catch(l){o={error:l}}finally{try{!e&&!s&&(a=n.return)&&(yield a.call(n))}finally{if(o)throw o.error}}return r.finish()})}function Bl(r,t){if(Qt(r))return Rf(r,t);if(ue(r))return Cf(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function Cf(r,t){let e=null,n=t?.type==="bytes"||!1,i=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){s(o,e||(e=r[Symbol.iterator]()))},pull(o){e?s(o,e):o.close()},cancel(){(e?.return&&e.return()||!0)&&(e=null)}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){let c,l=null,u=o.desiredSize||null;for(;!(l=a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=T(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()}}function Rf(r,t){let e=null,n=t?.type==="bytes"||!1,i=t?.highWaterMark||Math.pow(2,24);return new ReadableStream(Object.assign(Object.assign({},t),{start(o){return y(this,void 0,void 0,function*(){yield s(o,e||(e=r[Symbol.asyncIterator]()))})},pull(o){return y(this,void 0,void 0,function*(){e?yield s(o,e):o.close()})},cancel(){return y(this,void 0,void 0,function*(){(e?.return&&(yield e.return())||!0)&&(e=null)})}}),Object.assign({highWaterMark:n?i:void 0},t));function s(o,a){return y(this,void 0,void 0,function*(){let c,l=null,u=o.desiredSize||null;for(;!(l=yield a.next(n?u:null)).done;)if(ArrayBuffer.isView(l.value)&&(c=T(l.value))&&(u!=null&&n&&(u=u-c.byteLength+1),l.value=c),o.enqueue(l.value),u!=null&&--u<=0)return;o.close()})}}function Dl(r){return new pa(r)}var pa=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=Pa(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=kr(s),this._getSize=i!=="bytes"?Al:Ol;let{["highWaterMark"]:o=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},e),{["highWaterMark"]:a=i==="bytes"?Math.pow(2,14):1e3}=Object.assign({},n);this.readable=new ReadableStream({cancel:()=>{this._builder.clear()},pull:c=>{this._maybeFlush(this._builder,this._controller=c)},start:c=>{this._maybeFlush(this._builder,this._controller=c)}},{highWaterMark:o,size:i!=="bytes"?Al:Ol}),this.writable=new WritableStream({abort:()=>{this._builder.clear()},write:()=>{this._maybeFlush(this._builder,this._controller)},close:()=>{this._maybeFlush(this._builder.finish(),this._controller)}},{highWaterMark:a,size:c=>this._writeValueAndReturnChunkSize(c)})}_writeValueAndReturnChunkSize(t){let e=this._bufferedSize;return this._bufferedSize=this._getSize(this._builder.append(t)),this._bufferedSize-e}_maybeFlush(t,e){e!=null&&(this._bufferedSize>=e.desiredSize&&++this._numChunks&&this._enqueue(e,t.toVector()),t.finished&&((t.length>0||this._numChunks===0)&&++this._numChunks&&this._enqueue(e,t.toVector()),!this._finished&&(this._finished=!0)&&this._enqueue(e,null)))}_enqueue(t,e){this._bufferedSize=0,this._controller=null,e==null?t.close():t.enqueue(e)}},Al=r=>{var t;return(t=r?.length)!==null&&t!==void 0?t:0},Ol=r=>{var t;return(t=r?.byteLength)!==null&&t!==void 0?t:0};function to(r,t){let e=new Je,n=null,i=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield e.close()})},start(a){return y(this,void 0,void 0,function*(){yield o(a,n||(n=yield s()))})},pull(a){return y(this,void 0,void 0,function*(){n?yield o(a,n):a.close()})}});return{writable:new WritableStream(e,Object.assign({highWaterMark:Math.pow(2,14)},r)),readable:i};function s(){return y(this,void 0,void 0,function*(){return yield(yield Ut.from(e)).open(t)})}function o(a,c){return y(this,void 0,void 0,function*(){let l=a.desiredSize,u=null;for(;!(u=yield c.next()).done;)if(a.enqueue(u.value),l!=null&&--l<=0)return;a.close()})}}function eo(r,t){let e=new this(r),n=new Wt(e),i=new ReadableStream({cancel(){return y(this,void 0,void 0,function*(){yield n.cancel()})},pull(o){return y(this,void 0,void 0,function*(){yield s(o)})},start(o){return y(this,void 0,void 0,function*(){yield s(o)})}},Object.assign({highWaterMark:Math.pow(2,14)},t));return{writable:new WritableStream(e,r),readable:i};function s(o){return y(this,void 0,void 0,function*(){let a=null,c=o.desiredSize;for(;a=yield n.read(c||null);)if(o.enqueue(a),c!=null&&(c-=a.byteLength)<=0)return;o.close()})}}var id=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Oo),Xo),Wo),Do),wo),zo),xo),{compareSchemas:Gr,compareFields:rl,compareTypes:nl});wt.toDOMStream=Bl;rt.throughDOM=Dl;Ut.throughDOM=to;Hr.throughDOM=to;ir.throughDOM=to;Yr.throughDOM=eo;Kr.throughDOM=eo;Zr.throughDOM=eo;function Tl(r){switch(r.shape){case"array-row-table":case"object-row-table":return od(r.data);case"geojson-table":return ad(r.features);case"columnar-table":return sd(r.data);case"arrow-table":default:throw new Error("Deduce schema")}}function sd(r){let t=[];for(let[e,n]of Object.entries(r)){let i=cd(n,e);t.push(i)}return{fields:t,metadata:{}}}function od(r){if(!r.length)throw new Error("deduce from empty table");let t=[],e=r[0];for(let[n,i]of Object.entries(e))t.push(Nl(i,n));return{fields:t,metadata:{}}}function ad(r){if(!r.length)throw new Error("deduce from empty table");let t=[],e=r[0].properties||{};for(let[n,i]of Object.entries(e))t.push(Nl(i,n));return{fields:t,metadata:{}}}function cd(r,t){if(ArrayBuffer.isView(r)){let e=Ea(r);return{name:t,type:e.type||"null",nullable:e.nullable}}if(Array.isArray(r)&&r.length>0){let e=r[0],n=Ci(e);return{name:t,type:n,nullable:!0}}throw new Error("empty table")}function Nl(r,t){let e=Ci(r);return{name:t,type:e,nullable:!0}}function Ii(r){let t;switch(ld(r)){case"array-row-table":t={shape:"array-row-table",data:r};break;case"object-row-table":t={shape:"object-row-table",data:r};break;case"columnar-table":t={shape:"columnar-table",data:r};break;case"arrow-table":t={shape:"arrow-table",data:r};break;default:throw new Error("table")}let e=Tl(t);return{...t,schema:e}}function ld(r){if(r instanceof st)return"arrow-table";if(Array.isArray(r)){if(r.length===0)throw new Error("cannot deduce type of empty table");let t=r[0];if(Array.isArray(t))return"array-row-table";if(t&&typeof t=="object")return"object-row-table"}if(r&&typeof r=="object")return"columnar-table";throw new Error("invalid table")}function gr(r){switch(r.shape){case"array-row-table":case"object-row-table":return r.data.length;case"geojson-table":return r.features.length;case"arrow-table":return r.data.numRows;case"columnar-table":for(let e of Object.values(r.data))return e.length||0;return 0;default:throw new Error("table")}}function ro(r){if(r.schema)return r.schema.fields.length;if(gr(r)===0)throw new Error("empty table");switch(r.shape){case"array-row-table":return r.data[0].length;case"object-row-table":return Object.keys(r.data[0]).length;case"geojson-table":return Object.keys(r.features[0]).length;case"columnar-table":return Object.keys(r.data).length;case"arrow-table":return r.data.numCols;default:throw new Error("table")}}function no(r,t,e,n){switch(r.shape){case"object-row-table":return n?Object.fromEntries(Object.entries(r.data[t])):r.data[t];case"array-row-table":if(r.schema){let c=e||{};for(let l=0;l<r.schema.fields.length;l++)c[r.schema.fields[l].name]=r.data[t][l];return c}throw new Error("no schema");case"geojson-table":if(r.schema){let c=e||{};for(let l=0;l<r.schema.fields.length;l++)c[r.schema.fields[l].name]=r.features[t][l];return c}throw new Error("no schema");case"columnar-table":if(r.schema){let c=e||{};for(let l=0;l<r.schema.fields.length;l++)c[r.schema.fields[l].name]=r.data[r.schema.fields[l].name][t];return c}else{let c=e||{};for(let[l,u]of Object.entries(r.data))c[l]=u[t];return c}case"arrow-table":let i=r.data,s=e||{},o=i.get(t),a=i.schema;for(let c=0;c<a.fields.length;c++)s[a.fields[c].name]=o?.[a.fields[c].name];return s;default:throw new Error("shape")}}function io(r,t,e,n){switch(r.shape){case"array-row-table":return n?Array.from(r.data[t]):r.data[t];case"object-row-table":if(r.schema){let c=e||[];for(let l=0;l<r.schema.fields.length;l++)c[l]=r.data[t][r.schema.fields[l].name];return c}return Object.values(r.data[t]);case"geojson-table":if(r.schema){let c=e||[];for(let l=0;l<r.schema.fields.length;l++)c[l]=r.features[t][r.schema.fields[l].name];return c}return Object.values(r.features[t]);case"columnar-table":if(r.schema){let c=e||[];for(let l=0;l<r.schema.fields.length;l++)c[l]=r.data[r.schema.fields[l].name][t];return c}else{let c=e||[],l=0;for(let u of Object.values(r.data))c[l]=u[t],l++;return c}case"arrow-table":let i=r.data,s=e||[],o=i.get(t),a=i.schema;for(let c=0;c<a.fields.length;c++)s[c]=o?.[a.fields[c].name];return s;default:throw new Error("shape")}}function*ma(r,t){switch(t){case"array-row-table":yield*Ll(r);break;case"object-row-table":yield*Ul(r);break;default:throw new Error(`Unknown row type ${t}`)}}function*Ll(r,t=[]){let e=gr(r);for(let n=0;n<e;n++)yield io(r,n,t)}function*Ul(r,t={}){let e=gr(r);for(let n=0;n<e;n++)yield no(r,n,t)}function Ml(r,t){if(!r)throw new Error("null row");let e={};if(t)for(let n=0;n<t.length;n++)e[t[n]]=r[n];else for(let n=0;n<r.length;n++){let i=`column-${n}`;e[i]=r[n]}return e}function El(r,t){if(!r)throw new Error("null row");if(t){let e=new Array(t.length);for(let n=0;n<t.length;n++)e[n]=r[t[n]];return e}return Object.values(r)}function Cl(r){let t=[];for(let e=0;e<r.length;e++){let n=`column-${e}`;t.push(n)}return t}function Rl(r){return Object.keys(r)}var so=class{schema;options;shape;length=0;rows=null;cursor=0;_headers=[];constructor(t,e){if(this.options=e,this.schema=t,!Array.isArray(t)){this._headers=[];for(let n in t)this._headers[t[n].index]=t[n].name}}rowCount(){return this.length}addArrayRow(t,e){Number.isFinite(e)&&(this.cursor=e),this.shape="array-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=t,this.length++}addObjectRow(t,e){Number.isFinite(e)&&(this.cursor=e),this.shape="object-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=t,this.length++}getBatch(){let t=this.rows;return t?(t=t.slice(0,this.length),this.rows=null,{shape:this.shape||"array-row-table",batchType:"data",data:t,length:this.length,schema:this.schema,cursor:this.cursor}):null}};var Pl=100,oo=class{schema;options;length=0;objectRows=null;arrayRows=null;cursor=0;_headers=null;constructor(t,e){if(this.options=e,this.schema=t,t){this._headers=[];for(let n=0;n<t.fields.length;n++)this._headers[n]=t.fields[n].name}}rowCount(){return this.length}addArrayRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this._headers||=Cl(t),this.options.shape){case"object-row-table":let n=Ml(t,this._headers);this.addObjectRow(n,e);break;case"array-row-table":this.arrayRows=this.arrayRows||new Array(Pl),this.arrayRows[this.length]=t,this.length++;break}}addObjectRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this._headers||=Rl(t),this.options.shape){case"array-row-table":let n=El(t,this._headers);this.addArrayRow(n,e);break;case"object-row-table":this.objectRows=this.objectRows||new Array(Pl),this.objectRows[this.length]=t,this.length++;break}}getBatch(){let t=this.arrayRows||this.objectRows;return t?(t=t.slice(0,this.length),this.arrayRows=null,this.objectRows=null,{shape:this.options.shape,batchType:"data",data:t,length:this.length,schema:this.schema,cursor:this.cursor}):null}};function ya(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var ud=100,Dn=class{schema;length=0;allocated=0;columns={};constructor(t,e){this.schema=t,this._reallocateColumns()}rowCount(){return this.length}addArrayRow(t){this._reallocateColumns();let e=0;for(let n in this.columns)this.columns[n][this.length]=t[e++];this.length++}addObjectRow(t){this._reallocateColumns();for(let e in t)this.columns[e][this.length]=t[e];this.length++}getBatch(){return this._pruneColumns(),{shape:"columnar-table",batchType:"data",data:this.columns,schema:this.schema,length:this.length}}_reallocateColumns(){if(!(this.length<this.allocated)){this.allocated=this.allocated>0?this.allocated*=2:ud,this.columns={};for(let t of this.schema.fields){let e=Ca(t.type,t.nullable),n=this.columns[t.name];if(!n)this.columns[t.name]=new e(this.allocated);else if(Array.isArray(n))n.length=this.allocated;else if(ya(n)){let i=new e(this.allocated);i.set(n),this.columns[t.name]=i}else throw new Error("Invalid column type")}}}_pruneColumns(){for(let[t,e]of Object.entries(this.columns))this.columns[t]=e.slice(0,this.length)}};var ao=class extends Dn{arrowSchema;constructor(t,e){super(t,e),this.arrowSchema=null}getBatch(){let t=super.getBatch();if(t){this.arrowSchema=this.arrowSchema||hd(t.schema);let e=fd(this.arrowSchema,t.data),n=new Y(this.arrowSchema,w({type:new Z(this.arrowSchema.fields),children:e.map(({data:i})=>i[0])}));return{shape:"arrow-table",batchType:"data",data:new st([n]),length:t.length}}return null}};function hd(r){let t=[];for(let e in r){let n=r[e];if(n.type===Float32Array){let i=new Map,s=new E(n.name,new Ze,n.nullable,i);t.push(s)}}if(t.length===0)throw new Error("No arrow convertible fields");return new P(t)}function fd(r,t){let e=[];for(let n of r.fields){let i=t[n.name];if(i instanceof Float32Array){let s=mn(i);e.push(s)}}if(r.fields.length!==e.length)throw new Error("Some columns not arrow convertible");return e}var dd={shape:void 0,batchSize:"auto",batchDebounceMs:0,limit:0,_limitMB:0},br=class{schema;options;aggregator=null;batchCount=0;bytesUsed=0;isChunkComplete=!1;lastBatchEmittedMs=Date.now();totalLength=0;totalBytes=0;rowBytes=0;constructor(t,e){this.schema=t,this.options={...dd,...e}}limitReached(){return!!(Boolean(this.options?.limit)&&this.totalLength>=this.options.limit||Boolean(this.options?._limitMB)&&this.totalBytes/1e6>=this.options._limitMB)}addRow(t){this.limitReached()||(this.totalLength++,this.rowBytes=this.rowBytes||this._estimateRowMB(t),this.totalBytes+=this.rowBytes,Array.isArray(t)?this.addArrayRow(t):this.addObjectRow(t))}addArrayRow(t){if(!this.aggregator){let e=this._getTableBatchType();this.aggregator=new e(this.schema,this.options)}this.aggregator.addArrayRow(t)}addObjectRow(t){if(!this.aggregator){let e=this._getTableBatchType();this.aggregator=new e(this.schema,this.options)}this.aggregator.addObjectRow(t)}chunkComplete(t){t instanceof ArrayBuffer&&(this.bytesUsed+=t.byteLength),typeof t=="string"&&(this.bytesUsed+=t.length),this.isChunkComplete=!0}getFullBatch(t){return this._isFull()?this._getBatch(t):null}getFinalBatch(t){return this._getBatch(t)}_estimateRowMB(t){return Array.isArray(t)?t.length*8:Object.keys(t).length*8}_isFull(){if(!this.aggregator||this.aggregator.rowCount()===0)return!1;if(this.options.batchSize==="auto"){if(!this.isChunkComplete)return!1}else if(this.options.batchSize>this.aggregator.rowCount())return!1;return this.options.batchDebounceMs>Date.now()-this.lastBatchEmittedMs?!1:(this.isChunkComplete=!1,this.lastBatchEmittedMs=Date.now(),!0)}_getBatch(t){if(!this.aggregator)return null;t?.bytesUsed&&(this.bytesUsed=t.bytesUsed);let e=this.aggregator.getBatch();return e.count=this.batchCount,e.bytesUsed=this.bytesUsed,Object.assign(e,t),this.batchCount++,this.aggregator=null,e}_getTableBatchType(){switch(this.options.shape){case"array-row-table":case"object-row-table":return oo;case"columnar-table":return Dn;case"arrow-table":return ao;default:return so}}};La(br,"ArrowBatch");function jl(r,t){try{let e=JSON.parse(r);if(t.json?.table){let n=kl(e)||e;return Ii(n)}return e}catch{throw new Error("JSONLoader: failed to parse JSON")}}function kl(r){if(Array.isArray(r))return r;if(r&&typeof r=="object")for(let t of Object.values(r)){let e=kl(t);if(e)return e}return null}function ga(r,t){if(!r)throw new Error(t||"loader assertion failed.")}function Vl(...r){return pd(r)}function pd(r){let t=r.map(s=>s instanceof ArrayBuffer?new Uint8Array(s):s),e=t.reduce((s,o)=>s+o.byteLength,0),n=new Uint8Array(e),i=0;for(let s of t)n.set(s,i),i+=s.byteLength;return n.buffer}async function*xi(r,t={}){let e=new TextDecoder(void 0,t);for await(let n of r)yield typeof n=="string"?n:e.decode(n,{stream:!0})}async function*ba(r){let t="";for await(let e of r){t+=e;let n;for(;(n=t.indexOf(`
17
- `))>=0;){let i=t.slice(0,n+1);t=t.slice(n+1),yield i}}t.length>0&&(yield t)}async function*_a(r){let t=1;for await(let e of r)yield{counter:t,line:e},t++}async function wa(r){let t=[];for await(let e of r)t.push(e);return Vl(...t)}var va=Number.MAX_SAFE_INTEGER,b;(function(r){r[r.BEGIN=0]="BEGIN",r[r.VALUE=1]="VALUE",r[r.OPEN_OBJECT=2]="OPEN_OBJECT",r[r.CLOSE_OBJECT=3]="CLOSE_OBJECT",r[r.OPEN_ARRAY=4]="OPEN_ARRAY",r[r.CLOSE_ARRAY=5]="CLOSE_ARRAY",r[r.TEXT_ESCAPE=6]="TEXT_ESCAPE",r[r.STRING=7]="STRING",r[r.BACKSLASH=8]="BACKSLASH",r[r.END=9]="END",r[r.OPEN_KEY=10]="OPEN_KEY",r[r.CLOSE_KEY=11]="CLOSE_KEY",r[r.TRUE=12]="TRUE",r[r.TRUE2=13]="TRUE2",r[r.TRUE3=14]="TRUE3",r[r.FALSE=15]="FALSE",r[r.FALSE2=16]="FALSE2",r[r.FALSE3=17]="FALSE3",r[r.FALSE4=18]="FALSE4",r[r.NULL=19]="NULL",r[r.NULL2=20]="NULL2",r[r.NULL3=21]="NULL3",r[r.NUMBER_DECIMAL_POINT=22]="NUMBER_DECIMAL_POINT",r[r.NUMBER_DIGIT=23]="NUMBER_DIGIT"})(b||(b={}));var F={tab:9,lineFeed:10,carriageReturn:13,space:32,doubleQuote:34,plus:43,comma:44,minus:45,period:46,_0:48,_9:57,colon:58,E:69,openBracket:91,backslash:92,closeBracket:93,a:97,b:98,e:101,f:102,l:108,n:110,r:114,s:115,t:116,u:117,openBrace:123,closeBrace:125},zl=/[\\"\n]/g,Wl={onready:()=>{},onopenobject:()=>{},onkey:()=>{},oncloseobject:()=>{},onopenarray:()=>{},onclosearray:()=>{},onvalue:()=>{},onerror:()=>{},onend:()=>{},onchunkparsed:()=>{}},Xr=class{options=Wl;bufferCheckPosition=va;q="";c="";p="";closed=!1;closedRoot=!1;sawRoot=!1;error=null;state=b.BEGIN;stack=[];position=0;column=0;line=1;slashed=!1;unicodeI=0;unicodeS=null;depth=0;textNode;numberNode;constructor(t={}){this.options={...Wl,...t},this.textNode=void 0,this.numberNode="",this.emit("onready")}end(){return(this.state!==b.VALUE||this.depth!==0)&&this._error("Unexpected end"),this._closeValue(),this.c="",this.closed=!0,this.emit("onend"),this}resume(){return this.error=null,this}close(){return this.write(null)}emit(t,e){this.options[t]?.(e,this)}emitNode(t,e){this._closeValue(),this.emit(t,e)}write(t){if(this.error)throw this.error;if(this.closed)return this._error("Cannot write after close. Assign an onready handler.");if(t===null)return this.end();let e=0,n=t.charCodeAt(0),i=this.p;for(;n&&(i=n,this.c=n=t.charCodeAt(e++),i!==n?this.p=i:i=this.p,!!n);)switch(this.position++,n===F.lineFeed?(this.line++,this.column=0):this.column++,this.state){case b.BEGIN:n===F.openBrace?this.state=b.OPEN_OBJECT:n===F.openBracket?this.state=b.OPEN_ARRAY:Si(n)||this._error("Non-whitespace before {[.");continue;case b.OPEN_KEY:case b.OPEN_OBJECT:if(Si(n))continue;if(this.state===b.OPEN_KEY)this.stack.push(b.CLOSE_KEY);else if(n===F.closeBrace){this.emit("onopenobject"),this.depth++,this.emit("oncloseobject"),this.depth--,this.state=this.stack.pop()||b.VALUE;continue}else this.stack.push(b.CLOSE_OBJECT);n===F.doubleQuote?this.state=b.STRING:this._error('Malformed object key should start with "');continue;case b.CLOSE_KEY:case b.CLOSE_OBJECT:if(Si(n))continue;n===F.colon?(this.state===b.CLOSE_OBJECT?(this.stack.push(b.CLOSE_OBJECT),this._closeValue("onopenobject"),this.depth++):this._closeValue("onkey"),this.state=b.VALUE):n===F.closeBrace?(this.emitNode("oncloseobject"),this.depth--,this.state=this.stack.pop()||b.VALUE):n===F.comma?(this.state===b.CLOSE_OBJECT&&this.stack.push(b.CLOSE_OBJECT),this._closeValue(),this.state=b.OPEN_KEY):this._error("Bad object");continue;case b.OPEN_ARRAY:case b.VALUE:if(Si(n))continue;if(this.state===b.OPEN_ARRAY)if(this.emit("onopenarray"),this.depth++,this.state=b.VALUE,n===F.closeBracket){this.emit("onclosearray"),this.depth--,this.state=this.stack.pop()||b.VALUE;continue}else this.stack.push(b.CLOSE_ARRAY);n===F.doubleQuote?this.state=b.STRING:n===F.openBrace?this.state=b.OPEN_OBJECT:n===F.openBracket?this.state=b.OPEN_ARRAY:n===F.t?this.state=b.TRUE:n===F.f?this.state=b.FALSE:n===F.n?this.state=b.NULL:n===F.minus?this.numberNode+="-":F._0<=n&&n<=F._9?(this.numberNode+=String.fromCharCode(n),this.state=b.NUMBER_DIGIT):this._error("Bad value");continue;case b.CLOSE_ARRAY:if(n===F.comma)this.stack.push(b.CLOSE_ARRAY),this._closeValue("onvalue"),this.state=b.VALUE;else if(n===F.closeBracket)this.emitNode("onclosearray"),this.depth--,this.state=this.stack.pop()||b.VALUE;else{if(Si(n))continue;this._error("Bad array")}continue;case b.STRING:this.textNode===void 0&&(this.textNode="");let s=e-1,o=this.slashed,a=this.unicodeI;t:for(;;){for(;a>0;)if(this.unicodeS+=String.fromCharCode(n),n=t.charCodeAt(e++),this.position++,a===4?(this.textNode+=String.fromCharCode(parseInt(this.unicodeS,16)),a=0,s=e-1):a++,!n)break t;if(n===F.doubleQuote&&!o){this.state=this.stack.pop()||b.VALUE,this.textNode+=t.substring(s,e-1),this.position+=e-1-s;break}if(n===F.backslash&&!o&&(o=!0,this.textNode+=t.substring(s,e-1),this.position+=e-1-s,n=t.charCodeAt(e++),this.position++,!n))break;if(o){if(o=!1,n===F.n?this.textNode+=`
18
- `:n===F.r?this.textNode+="\r":n===F.t?this.textNode+=" ":n===F.f?this.textNode+="\f":n===F.b?this.textNode+="\b":n===F.u?(a=1,this.unicodeS=""):this.textNode+=String.fromCharCode(n),n=t.charCodeAt(e++),this.position++,s=e-1,n)continue;break}zl.lastIndex=e;let c=zl.exec(t);if(c===null){e=t.length+1,this.textNode+=t.substring(s,e-1),this.position+=e-1-s;break}if(e=c.index+1,n=t.charCodeAt(c.index),!n){this.textNode+=t.substring(s,e-1),this.position+=e-1-s;break}}this.slashed=o,this.unicodeI=a;continue;case b.TRUE:n===F.r?this.state=b.TRUE2:this._error(`Invalid true started with t${n}`);continue;case b.TRUE2:n===F.u?this.state=b.TRUE3:this._error(`Invalid true started with tr${n}`);continue;case b.TRUE3:n===F.e?(this.emit("onvalue",!0),this.state=this.stack.pop()||b.VALUE):this._error(`Invalid true started with tru${n}`);continue;case b.FALSE:n===F.a?this.state=b.FALSE2:this._error(`Invalid false started with f${n}`);continue;case b.FALSE2:n===F.l?this.state=b.FALSE3:this._error(`Invalid false started with fa${n}`);continue;case b.FALSE3:n===F.s?this.state=b.FALSE4:this._error(`Invalid false started with fal${n}`);continue;case b.FALSE4:n===F.e?(this.emit("onvalue",!1),this.state=this.stack.pop()||b.VALUE):this._error(`Invalid false started with fals${n}`);continue;case b.NULL:n===F.u?this.state=b.NULL2:this._error(`Invalid null started with n${n}`);continue;case b.NULL2:n===F.l?this.state=b.NULL3:this._error(`Invalid null started with nu${n}`);continue;case b.NULL3:n===F.l?(this.emit("onvalue",null),this.state=this.stack.pop()||b.VALUE):this._error(`Invalid null started with nul${n}`);continue;case b.NUMBER_DECIMAL_POINT:n===F.period?(this.numberNode+=".",this.state=b.NUMBER_DIGIT):this._error("Leading zero not followed by .");continue;case b.NUMBER_DIGIT:F._0<=n&&n<=F._9?this.numberNode+=String.fromCharCode(n):n===F.period?(this.numberNode.indexOf(".")!==-1&&this._error("Invalid number has two dots"),this.numberNode+="."):n===F.e||n===F.E?((this.numberNode.indexOf("e")!==-1||this.numberNode.indexOf("E")!==-1)&&this._error("Invalid number has two exponential"),this.numberNode+="e"):n===F.plus||n===F.minus?(i===F.e||i===F.E||this._error("Invalid symbol in number"),this.numberNode+=String.fromCharCode(n)):(this._closeNumber(),e--,this.state=this.stack.pop()||b.VALUE);continue;default:this._error(`Unknown state: ${this.state}`)}return this.position>=this.bufferCheckPosition&&md(this),this.emit("onchunkparsed"),this}_closeValue(t="onvalue"){this.textNode!==void 0&&this.emit(t,this.textNode),this.textNode=void 0}_closeNumber(){this.numberNode&&this.emit("onvalue",parseFloat(this.numberNode)),this.numberNode=""}_error(t=""){this._closeValue(),t+=`
16
+ ]`}concat(...t){let e=this.schema,n=this.data.concat(t.flatMap(({data:i})=>i));return new ot(e,n.map(i=>new Y(e,i)))}slice(t,e){let n=this.schema;[t,e]=$n({length:this.numRows},t,e);let i=Is(this.data,this._offsets,t,e);return new ot(n,i.map(s=>new Y(n,s)))}getChild(t){return this.getChildAt(this.schema.fields.findIndex(e=>e.name===t))}getChildAt(t){if(t>-1&&t<this.schema.fields.length){let e=this.data.map(n=>n.children[t]);if(e.length===0){let{type:n}=this.schema.fields[t],i=w({type:n,length:0,nullCount:0});e.push(i._changeLengthAndBackfillNullBitmap(this.numRows))}return new _(e)}return null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=[...this.batches];if(t>-1&&t<this.numCols){e||(e=new _([w({type:new Tt,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]=to(n,a)}return new ot(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 ot(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 ot(...to(s,o))}};El=Symbol.toStringTag;ot[El]=(r=>(r.schema=null,r.batches=[],r._offsets=new Uint32Array([0]),r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,r.isValid=yn(Zn),r.get=yn(ht.getVisitFn(f.Struct)),r.set=xs(Bt.getVisitFn(f.Struct)),r.indexOf=Ss(jr.getVisitFn(f.Struct)),"Table"))(ot.prototype);var Cl,Y=class{constructor(...t){switch(t.length){case 2:{if([this.schema]=t,!(this.schema instanceof P))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");if([,this.data=w({nullCount:0,type:new Z(this.schema.fields),children:this.schema.fields.map(e=>w({type:e.type,nullCount:0}))})]=t,!(this.data instanceof V))throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");[this.schema,this.data]=Ul(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]=U.new({name:l,type:e[l].type,nullable:!0}),c),{length:0,fields:new Array,children:new Array}),o=new P(n),a=w({type:new Z(n),length:s,children:i,nullCount:0});[this.schema,this.data]=Ul(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=Rl(this.schema.fields,this.data.children))}get numCols(){return this.schema.fields.length}get numRows(){return this.data.length}get nullCount(){return this.data.nullCount}isValid(t){return this.data.getValid(t)}get(t){return ht.visit(this.data,t)}at(t){return this.get(Er(t,this.numRows))}set(t,e){return Bt.visit(this.data,t,e)}indexOf(t,e){return jr.visit(this.data,t,e)}[Symbol.iterator](){return gn.visit(new _([this.data]))}toArray(){return[...this]}concat(...t){return new ot(this.schema,[this,...t])}slice(t,e){let[n]=new _([this.data]).slice(t,e).data;return new Y(this.schema,n)}getChild(t){var e;return this.getChildAt((e=this.schema.fields)===null||e===void 0?void 0:e.findIndex(n=>n.name===t))}getChildAt(t){return t>-1&&t<this.schema.fields.length?new _([this.data.children[t]]):null}setChild(t,e){var n;return this.setChildAt((n=this.schema.fields)===null||n===void 0?void 0:n.findIndex(i=>i.name===t),e)}setChildAt(t,e){let n=this.schema,i=this.data;if(t>-1&&t<this.numCols){e||(e=new _([w({type:new Tt,length:this.numRows})]));let s=n.fields.slice(),o=i.children.slice(),a=s[t].clone({type:e.type});[s[t],o[t]]=[a,e.data[0]],n=new P(s,new Map(this.schema.metadata)),i=w({type:new Z(s),children:o})}return new Y(n,i)}select(t){let e=this.schema.select(t),n=new Z(e.fields),i=[];for(let s of t){let o=this.schema.fields.findIndex(a=>a.name===s);~o&&(i[o]=this.data.children[o])}return new Y(e,w({type:n,length:this.numRows,children:i}))}selectAt(t){let e=this.schema.selectAt(t),n=t.map(s=>this.data.children[s]).filter(Boolean),i=w({type:new Z(e.fields),length:this.numRows,children:n});return new Y(e,i)}};Cl=Symbol.toStringTag;Y[Cl]=(r=>(r._nullCount=-1,r[Symbol.isConcatSpreadable]=!0,"RecordBatch"))(Y.prototype);function Ul(r,t,e=t.reduce((n,i)=>Math.max(n,i.length),0)){var n;let i=[...r.fields],s=[...t],o=(e+63&-64)>>3;for(let[a,c]of r.fields.entries()){let l=t[a];(!l||l.length!==e)&&(i[a]=c.clone({nullable:!0}),s[a]=(n=l?._changeLengthAndBackfillNullBitmap(e))!==null&&n!==void 0?n:w({type:c.type,length:e,nullCount:e,nullBitmap:new Uint8Array(o)}))}return[r.assign(i),w({type:new Z(i),length:e,children:s})]}function Rl(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)||[]])Rl(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 Yr=class extends Y{constructor(t){let e=t.fields.map(i=>w({type:i.type})),n=w({type:new Z(t.fields),nullCount:0,children:e});super(t,n)}};var pa=r=>`Expected ${j[r]} Message in stream, but was null or length 0.`,ma=r=>`Header pointer of flatbuffer-encoded ${j[r]} Message is null or length 0.`,Pl=(r,t)=>`Expected to read ${r} metadata bytes, but only read ${t}.`,jl=(r,t)=>`Expected to read ${r} bytes for message body, but only read ${t}.`,Dn=class{constructor(t){this.source=t instanceof He?t:new He(t)}[Symbol.iterator](){return this}next(){let t;return(t=this.readMetadataLength()).done?et:t.value===-1&&(t=this.readMetadataLength()).done?et:(t=this.readMetadata(t.value)).done?et: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(jl(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()}readSchema(t=!1){let e=j.Schema,n=this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(ma(e));return i}readMetadataLength(){let t=this.source.read(eo),e=t&&new bt(t),n=e?.readInt32(0)||0;return{done:n===0,value:n}}readMetadata(t){let e=this.source.read(t);if(!e)return et;if(e.byteLength<t)throw new Error(Pl(t,e.byteLength));return{done:!1,value:yt.decode(e)}}},xi=class{constructor(t,e){this.source=t instanceof Ht?t:Wi(t)?new gr(t,e):new Ht(t)}[Symbol.asyncIterator](){return this}next(){return g(this,void 0,void 0,function*(){let t;return(t=yield this.readMetadataLength()).done?et:t.value===-1&&(t=yield this.readMetadataLength()).done?et:(t=yield this.readMetadata(t.value)).done?et: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(pa(t));return e.value})}readMessageBody(t){return g(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(jl(t,e.byteLength));return e.byteOffset%8===0&&e.byteOffset+e.byteLength<=e.buffer.byteLength?e:e.slice()})}readSchema(){return g(this,arguments,void 0,function*(t=!1){let e=j.Schema,n=yield this.readMessage(e),i=n?.header();if(t&&!i)throw new Error(ma(e));return i})}readMetadataLength(){return g(this,void 0,void 0,function*(){let t=yield this.source.read(eo),e=t&&new bt(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 et;if(e.byteLength<t)throw new Error(Pl(t,e.byteLength));return{done:!1,value:yt.decode(e)}})}},Si=class extends Dn{constructor(t){super(new Uint8Array(0)),this._schema=!1,this._body=[],this._batchIndex=0,this._dictionaryIndex=0,this._json=t instanceof Kn?t:new Kn(t)}next(){let{_json:t}=this;if(!this._schema)return this._schema=!0,{done:!1,value:yt.fromJSON(t.schema,j.Schema)};if(this._dictionaryIndex<t.dictionaries.length){let e=t.dictionaries[this._dictionaryIndex++];return this._body=e.data.columns,{done:!1,value:yt.fromJSON(e,j.DictionaryBatch)}}if(this._batchIndex<t.batches.length){let e=t.batches[this._batchIndex++];return this._body=e.columns,{done:!1,value:yt.fromJSON(e,j.RecordBatch)}}return this._body=[],et}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=j.Schema,e=this.readMessage(t),n=e?.header();if(!e||!n)throw new Error(ma(t));return n}},eo=4,da="ARROW1",Tn=new Uint8Array(da.length);for(let r=0;r<da.length;r+=1)Tn[r]=da.codePointAt(r);function ro(r,t=0){for(let e=-1,n=Tn.length;++e<n;)if(Tn[e]!==r[t+e])return!1;return!0}var Fn=Tn.length,ya=Fn+eo,Vl=Fn*2+eo;var ga=class{constructor(){this.LZ4_FRAME_MAGIC=new Uint8Array([4,34,77,24]),this.MIN_HEADER_LENGTH=7}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),n=t.encode(e);return this._isValidCompressed(n)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)&&this._hasValidVersion(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.LZ4_FRAME_MAGIC.every((e,n)=>t[n]===e)}_hasValidVersion(t){return(t[4]&192)>>6===1}},ba=class{constructor(){this.ZSTD_MAGIC=new Uint8Array([40,181,47,253]),this.MIN_HEADER_LENGTH=6}isValidCodecEncode(t){let e=new Uint8Array([1,2,3,4,5,6,7,8]),n=t.encode(e);return this._isValidCompressed(n)}_isValidCompressed(t){return this._hasMinimumLength(t)&&this._hasValidMagicNumber(t)}_hasMinimumLength(t){return t.length>=this.MIN_HEADER_LENGTH}_hasValidMagicNumber(t){return this.ZSTD_MAGIC.every((e,n)=>t[n]===e)}},kl={[Ut.LZ4_FRAME]:new ga,[Ut.ZSTD]:new ba};var _a=class{constructor(){this.registry={}}set(t,e){if(e?.encode&&typeof e.encode=="function"&&!kl[t].isValidCodecEncode(e))throw new Error(`Encoder for ${Ut[t]} is not valid.`);this.registry[t]=e}get(t){var e;return((e=this.registry)===null||e===void 0?void 0:e[t])||null}},Nn=new _a;var Rt=class extends zr{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 fe(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 xt.toDOMStream(this.isSync()?{[Symbol.iterator]:()=>this}:{[Symbol.asyncIterator]:()=>this})}toNodeStream(){return xt.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 Rt?t:ki(t)?rd(t):Wi(t)?sd(t):fe(t)?(()=>g(this,void 0,void 0,function*(){return yield Rt.from(yield t)}))():Ji(t)||jn(t)||$i(t)||ee(t)?id(new Ht(t)):nd(new He(t))}static readAll(t){return t instanceof Rt?t.isSync()?zl(t):Wl(t):ki(t)||ArrayBuffer.isView(t)||he(t)||zi(t)?zl(t):Wl(t)}},or=class extends Rt{constructor(t){super(t),this._impl=t}readAll(){return[...this]}[Symbol.iterator](){return this._impl[Symbol.iterator]()}[Symbol.asyncIterator](){return Zt(this,arguments,function*(){yield C(yield*nn(ue(this[Symbol.iterator]())))})}},Zr=class extends Rt{constructor(t){super(t),this._impl=t}readAll(){return g(this,void 0,void 0,function*(){var t,e,n,i;let s=new Array;try{for(var o=!0,a=ue(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]()}},Kr=class extends or{constructor(t){super(t),this._impl=t}},no=class extends Zr{constructor(t){super(t),this._impl=t}},io=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;if(t.compression!=null){let s=Nn.get(t.compression.type);if(s?.decode&&typeof s.decode=="function"){let{decommpressedBody:o,buffers:a}=this._decompressBuffers(t,e,s);n=this._loadCompressedVectors(t,o,this.schema.fields),t=new mt(t.length,t.nodes,a,null)}else throw new Error("Record batch is compressed but codec not found")}else n=this._loadVectors(t,e,this.schema.fields);let i=w({type:new Z(this.schema.fields),length:t.length,children:n});return new Y(this.schema,i)}_loadDictionaryBatch(t,e){let{id:n,isDelta:i}=t,{dictionaries:s,schema:o}=this,a=s.get(n),c=o.dictionaries.get(n),l;if(t.data.compression!=null){let u=Nn.get(t.data.compression.type);if(u?.decode&&typeof u.decode=="function"){let{decommpressedBody:h,buffers:d}=this._decompressBuffers(t.data,e,u);l=this._loadCompressedVectors(t.data,h,[c]),t=new Nt(new mt(t.data.length,t.data.nodes,d,null),n,i)}else throw new Error("Dictionary batch is compressed but codec not found")}else l=this._loadVectors(t.data,e,[c]);return(a&&i?a.concat(new _(l)):new _(l)).memoize()}_loadVectors(t,e,n){return new Sn(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}_loadCompressedVectors(t,e,n){return new Ns(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}_decompressBuffers(t,e,n){let i=[],s=[],o=0;for(let{offset:a,length:c}of t.buffers){if(c===0){i.push(new Uint8Array(0)),s.push(new pt(o,0));continue}let l=new bt(e.subarray(a,a+c)),u=J(l.readInt64(0)),h=l.bytes().subarray(8),d=u===-1?h:n.decode(h);i.push(d);let p=(o+7&-8)-o;o+=p,s.push(new pt(o,d.length)),o+=d.length}return{decommpressedBody:i,buffers:s}}},Ln=class extends io{constructor(t,e){super(e),this._reader=ki(t)?new Si(this._handle=t):new Dn(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=Gl(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):et}return(t){return!this.closed&&this.autoDestroy&&(this.closed=!0)?this.reset()._reader.return(t):et}next(){if(this.closed)return et;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 Yr(this.schema)}):this.return()}_readNextMessageAndValidate(t){return this._reader.readMessage(t)}},Mn=class extends io{constructor(t,e){super(e),this._reader=new xi(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=Gl(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):et})}return(t){return g(this,void 0,void 0,function*(){return!this.closed&&this.autoDestroy&&(this.closed=!0)?yield this.reset()._reader.return(t):et})}next(){return g(this,void 0,void 0,function*(){if(this.closed)return et;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 Yr(this.schema)}):yield this.return()})}_readNextMessageAndValidate(t){return g(this,void 0,void 0,function*(){return yield this._reader.readMessage(t)})}},so=class extends Ln{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 Xn?t:new Xn(t),e)}isSync(){return!0}isFile(){return!0}open(t){if(!this.closed&&!this._footer){this.schema=(this._footer=this._readFooter()).schema;for(let e of this._footer.dictionaryBatches())e&&this._readDictionaryBatch(this._dictionaryIndex++)}return super.open(t)}readRecordBatch(t){var e;if(this.closed)return null;this._footer||this.open();let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(j.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null}_readDictionaryBatch(t){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&this._handle.seek(n.offset)){let i=this._reader.readMessage(j.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}}_readFooter(){let{_handle:t}=this,e=t.size-ya,n=t.readInt32(e),i=t.readAt(e-n,n);return tr.decode(i)}_readNextMessageAndValidate(t){var e;if(this._footer||this.open(),this._footer&&this._recordBatchIndex<this.numRecordBatches){let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(this._recordBatchIndex);if(n&&this._handle.seek(n.offset))return this._reader.readMessage(t)}return null}},wa=class extends Mn{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 gr?t:new gr(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){return g(this,void 0,void 0,function*(){var e;if(this.closed)return null;this._footer||(yield this.open());let n=(e=this._footer)===null||e===void 0?void 0:e.getRecordBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(j.RecordBatch);if(i?.isRecordBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength);return this._loadRecordBatch(s,o)}}return null})}_readDictionaryBatch(t){return g(this,void 0,void 0,function*(){var e;let n=(e=this._footer)===null||e===void 0?void 0:e.getDictionaryBatch(t);if(n&&(yield this._handle.seek(n.offset))){let i=yield this._reader.readMessage(j.DictionaryBatch);if(i?.isDictionaryBatch()){let s=i.header(),o=yield this._reader.readMessageBody(i.bodyLength),a=this._loadDictionaryBatch(s,o);this.dictionaries.set(s.id,a)}}})}_readFooter(){return 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 tr.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})}},va=class extends Ln{constructor(t,e){super(t,e)}_loadVectors(t,e,n){return new Fs(e,t.nodes,t.buffers,this.dictionaries,this.schema.metadataVersion).visitMany(n)}};function Gl(r,t){return t&&typeof t.autoDestroy=="boolean"?t.autoDestroy:r.autoDestroy}function*zl(r){let t=Rt.from(r);try{if(!t.open({autoDestroy:!1}).closed)do yield t;while(!t.reset().open().closed)}finally{t.cancel()}}function Wl(r){return Zt(this,arguments,function*(){let e=yield C(Rt.from(r));try{if(!(yield C(e.open({autoDestroy:!1}))).closed)do yield yield C(e);while(!(yield C(e.reset().open())).closed)}finally{yield C(e.cancel())}})}function rd(r){return new or(new va(r))}function nd(r){let t=r.peek(Fn+7&-8);return t&&t.byteLength>=4?ro(t)?new Kr(new so(r.read())):new or(new Ln(r)):new or(new Ln(function*(){}()))}function id(r){return g(this,void 0,void 0,function*(){let t=yield r.peek(Fn+7&-8);return t&&t.byteLength>=4?ro(t)?new Kr(new so(yield r.read())):new Zr(new Mn(r)):new Zr(new Mn(function(){return Zt(this,arguments,function*(){})}()))})}function sd(r){return g(this,void 0,void 0,function*(){let{size:t}=yield r.stat(),e=new gr(r,t);return t>=Vl&&ro(yield e.readAt(0,Fn+7&-8))?new no(new wa(e)):new Zr(new Mn(e))})}var nt=class extends x{static assemble(...t){let e=i=>i.flatMap(s=>Array.isArray(s)?e(s):s instanceof Y?s.data.children:s.data),n=new nt;return n.visitMany(e(t)),n}constructor(){super(),this._byteLength=0,this._nodes=[],this._buffers=[],this._bufferRegions=[]}visit(t){if(t instanceof _)return this.visitMany(t.data),this;let{type:e}=t;if(!m.isDictionary(e)){let{length:n}=t;if(n>2147483647)throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");if(m.isUnion(e))this.nodes.push(new ce(n,0));else{let{nullCount:i}=t;m.isNull(e)||ve.call(this,i<=0?new Uint8Array(0):Cr(t.offset,n,t.nullBitmap)),this.nodes.push(new ce(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 ve(r){let t=r.byteLength+7&-8;return this.buffers.push(r),this.bufferRegions.push(new pt(this._byteLength,t)),this._byteLength+=t,this}function od(r){var t;let{type:e,length:n,typeIds:i,valueOffsets:s}=r;if(ve.call(this,i),e.mode===q.Sparse)return Ia.call(this,r);if(e.mode===q.Dense){if(r.offset<=0)return ve.call(this,s),Ia.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);ve.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 ad(r){let t;return r.nullCount>=r.length?ve.call(this,new Uint8Array(0)):(t=r.values)instanceof Uint8Array?ve.call(this,Cr(r.offset,r.length,t)):ve.call(this,Rr(r.values))}function ar(r){return ve.call(this,r.values.subarray(0,r.length*r.stride))}function oo(r){let{length:t,values:e,valueOffsets:n}=r,i=J(n[0]),s=J(n[t]),o=Math.min(s-i,e.byteLength-i);return ve.call(this,Yi(-i,t+1,n)),ve.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 ve.call(this,Yi(-n,t+1,e)),this.visit(r.children[0].slice(n,i-n))}return this.visit(r.children[0])}function Ia(r){return this.visitMany(r.type.children.map((t,e)=>r.children[e]).filter(Boolean))[0]}nt.prototype.visitBool=ad;nt.prototype.visitInt=ar;nt.prototype.visitFloat=ar;nt.prototype.visitUtf8=oo;nt.prototype.visitLargeUtf8=oo;nt.prototype.visitBinary=oo;nt.prototype.visitLargeBinary=oo;nt.prototype.visitFixedSizeBinary=ar;nt.prototype.visitDate=ar;nt.prototype.visitTimestamp=ar;nt.prototype.visitTime=ar;nt.prototype.visitDecimal=ar;nt.prototype.visitList=xa;nt.prototype.visitStruct=Ia;nt.prototype.visitUnion=od;nt.prototype.visitInterval=ar;nt.prototype.visitDuration=ar;nt.prototype.visitFixedSizeList=xa;nt.prototype.visitMap=xa;var Xr=class extends zr{static throughNode(t){throw new Error('"throughNode" not available in this environment')}static throughDOM(t,e){throw new Error('"throughDOM" not available in this environment')}constructor(t){if(super(),this._position=0,this._started=!1,this._compression=null,this._sink=new $e,this._schema=null,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,Et(t)||(t={autoDestroy:!0,writeLegacyIpcFormat:!1,compressionType:null}),this._autoDestroy=typeof t.autoDestroy=="boolean"?t.autoDestroy:!0,this._writeLegacyIpcFormat=typeof t.writeLegacyIpcFormat=="boolean"?t.writeLegacyIpcFormat:!1,t.compressionType!=null){if(this._writeLegacyIpcFormat)throw new Error("Legacy IPC format does not support columnar compression. Use modern IPC format (writeLegacyIpcFormat=false).");if(Object.values(Ut).includes(t.compressionType))this._compression=new kr(t.compressionType);else{let e=Object.values(Ut).filter(n=>typeof n=="string");throw new Error(`Unsupported compressionType: ${t.compressionType} Available types: ${e.join(", ")}`)}}else this._compression=null}toString(t=!1){return this._sink.toString(t)}toUint8Array(t=!1){return this._sink.toUint8Array(t)}writeAll(t){return fe(t)?t.then(e=>this.writeAll(e)):ee(t)?Ba(this,t):Sa(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 $e?this._sink=t:(this._sink=new $e,t&&ec(t)?this.toDOMStream({type:"bytes"}).pipeTo(t):t&&rc(t)&&this.toNodeStream({objectMode:!1}).pipe(t)),this._started&&this._schema&&this._writeFooter(this._schema),this._started=!1,this._dictionaryBlocks=[],this._recordBatchBlocks=[],this._seenDictionaries=new Map,this._dictionaryDeltaOffsets=new Map,(!e||!Hr(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 ot&&!(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&&!Hr(e,this._schema)){if(this._started&&this._autoDestroy)return this.close();this.reset(this._sink,e)}t instanceof Y?t instanceof Yr||this._writeRecordBatch(t):t instanceof ot?this.writeAll(t.batches):he(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===j.RecordBatch?this._recordBatchBlocks.push(new we(a,t.bodyLength,this._position)):t.headerType===j.DictionaryBatch&&this._dictionaryBlocks.push(new we(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(yt.from(t))}_writeFooter(t){return this._writeLegacyIpcFormat?this._write(Int32Array.of(0)):this._write(Int32Array.of(-1,0))}_writeMagic(){return this._write(Tn)}_writePadding(t){return t>0?this._write(new Uint8Array(t)):this}_writeRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=this._assembleRecordBatch(t),o=new mt(t.numRows,n,i,this._compression),a=yt.from(o,e);return this._writeDictionaries(t)._writeMessage(a)._writeBodyBuffers(s)}_assembleRecordBatch(t){let{byteLength:e,nodes:n,bufferRegions:i,buffers:s}=nt.assemble(t);return this._compression!=null&&({byteLength:e,bufferRegions:i,buffers:s}=this._compressBodyBuffers(s)),{byteLength:e,nodes:n,bufferRegions:i,buffers:s}}_compressBodyBuffers(t){let e=Nn.get(this._compression.type);if(!e?.encode||typeof e.encode!="function")throw new Error(`Codec for compression type "${Ut[this._compression.type]}" has invalid encode method`);let n=0,i=[],s=[];for(let a of t){let c=T(a);if(c.length===0){i.push(new Uint8Array(0),new Uint8Array(0)),s.push(new pt(n,0));continue}let l=e.encode(c),u=l.length<c.length,h=u?l:c,d=u?h.length:-1,p=new bt(new Uint8Array(8));p.writeInt64(0,BigInt(d)),i.push(p.bytes(),new Uint8Array(h));let y=(n+7&-8)-n;n+=y;let z=8+h.length;s.push(new pt(n,z)),n+=z}let o=(n+7&-8)-n;return n+=o,{byteLength:n,bufferRegions:s,buffers:i}}_writeDictionaryBatch(t,e,n=!1){let{byteLength:i,nodes:s,bufferRegions:o,buffers:a}=this._assembleRecordBatch(new _([t])),c=new mt(t.length,s,o,this._compression),l=new Nt(c,e,n),u=yt.from(l,i);return this._writeMessage(u)._writeBodyBuffers(a)}_writeBodyBuffers(t){let e=this._compression!=null?2:1,n=new Array(e);for(let i=0;i<t.length;i+=e){let s=0;for(let a=-1;++a<e;)n[a]=t[i+a],s+=n[a].byteLength;if(s===0)continue;for(let a of n)this._write(a);let o=(s+7&-8)-s;o>0&&this._writePadding(o)}return this}_writeDictionaries(t){var e,n;for(let[i,s]of t.dictionaries){let o=(e=s?.data)!==null&&e!==void 0?e:[],a=this._seenDictionaries.get(i),c=(n=this._dictionaryDeltaOffsets.get(i))!==null&&n!==void 0?n:0;if(!a||a.data[0]!==o[0])for(let[l,u]of o.entries())this._writeDictionaryBatch(u,i,l>0);else if(c<o.length)for(let l of o.slice(c))this._writeDictionaryBatch(l,i,!0);this._seenDictionaries.set(i,s),this._dictionaryDeltaOffsets.set(i,o.length)}return this}},qr=class extends Xr{static writeAll(t,e){let n=new qr(e);return fe(t)?t.then(i=>n.writeAll(i)):ee(t)?Ba(n,t):Sa(n,t)}},Qr=class extends Xr{static writeAll(t,e){let n=new Qr(e);return fe(t)?t.then(i=>n.writeAll(i)):ee(t)?Ba(n,t):Sa(n,t)}constructor(t){super(t),this._autoDestroy=!0,this._writeLegacyIpcFormat=!1}_writeSchema(t){return this._writeMagic()._writePadding(2)}_writeDictionaryBatch(t,e,n=!1){if(!n&&this._seenDictionaries.has(e))throw new Error("The Arrow File format does not support replacement dictionaries. ");return super._writeDictionaryBatch(t,e,n)}_writeFooter(t){let e=tr.encode(new tr(t,H.V5,this._recordBatchBlocks,this._dictionaryBlocks));return super._writeFooter(t)._write(e)._write(Int32Array.of(e.byteLength))._writeMagic()}};function Sa(r,t){let e=t;t instanceof ot&&(e=t.batches,r.reset(void 0,t.schema));for(let n of e)r.write(n);return r.finish()}function Ba(r,t){return g(this,void 0,void 0,function*(){var e,n,i,s,o,a,c;try{for(e=!0,n=ue(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 $l(r,t){if(ee(r))return ld(r,t);if(he(r))return cd(r,t);throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable")}function cd(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(),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 ld(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()),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=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 Zl(r){return new Aa(r)}var Aa=class{constructor(t){this._numChunks=0,this._finished=!1,this._bufferedSize=0;let{["readableStrategy"]:e,["writableStrategy"]:n,["queueingStrategy"]:i="count"}=t,s=qa(t,["readableStrategy","writableStrategy","queueingStrategy"]);this._controller=null,this._builder=Jr(s),this._getSize=i!=="bytes"?Hl:Yl;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"?Hl:Yl}),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)}},Hl=r=>{var t;return(t=r?.length)!==null&&t!==void 0?t:0},Yl=r=>{var t;return(t=r?.byteLength)!==null&&t!==void 0?t:0};function ao(r,t){let e=new $e,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 Rt.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 co(r,t){let e=new this(r),n=new Ht(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()})}}var Nd=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Eo),oa),Ko),Uo),Oo),Zo),Fo),la),{compareSchemas:Hr,compareFields:Ll,compareTypes:Ml});xt.toDOMStream=$l;rt.throughDOM=Zl;Rt.throughDOM=ao;Kr.throughDOM=ao;or.throughDOM=ao;Xr.throughDOM=co;Qr.throughDOM=co;qr.throughDOM=co;function Xl(r){switch(r.shape){case"array-row-table":case"object-row-table":return Md(r.data);case"geojson-table":return Ed(r.features);case"columnar-table":return Ld(r.data);case"arrow-table":default:throw new Error("Deduce schema")}}function Ld(r){let t=[];for(let[e,n]of Object.entries(r)){let i=Ud(n,e);t.push(i)}return{fields:t,metadata:{}}}function Md(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(ql(i,n));return{fields:t,metadata:{}}}function Ed(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(ql(i,n));return{fields:t,metadata:{}}}function Ud(r,t){if(ArrayBuffer.isView(r)){let e=Za(r);return{name:t,type:e.type||"null",nullable:e.nullable}}if(Array.isArray(r)&&r.length>0){let e=r[0],n=Vi(e);return{name:t,type:n,nullable:!0}}throw new Error("empty table")}function ql(r,t){let e=Vi(r);return{name:t,type:e,nullable:!0}}function Bi(r){let t;switch(Cd(r)){case"array-row-table":t={shape:"array-row-table",data:r};break;case"object-row-table":t={shape:"object-row-table",data:r};break;case"columnar-table":t={shape:"columnar-table",data:r};break;case"arrow-table":t={shape:"arrow-table",data:r};break;default:throw new Error("table")}let e=Xl(t);return{...t,schema:e}}function Cd(r){if(r instanceof ot)return"arrow-table";if(Array.isArray(r)){if(r.length===0)throw new Error("cannot deduce type of empty table");let t=r[0];if(Array.isArray(t))return"array-row-table";if(t&&typeof t=="object")return"object-row-table"}if(r&&typeof r=="object")return"columnar-table";throw new Error("invalid table")}function _r(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 lo(r){if(r.schema)return r.schema.fields.length;if(_r(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 uo(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 fo(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*Oa(r,t){switch(t){case"array-row-table":yield*Ql(r);break;case"object-row-table":yield*tu(r);break;default:throw new Error(`Unknown row type ${t}`)}}function*Ql(r,t=[]){let e=_r(r);for(let n=0;n<e;n++)yield fo(r,n,t)}function*tu(r,t={}){let e=_r(r);for(let n=0;n<e;n++)yield uo(r,n,t)}function eu(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 ru(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 nu(r){let t=[];for(let e=0;e<r.length;e++){let n=`column-${e}`;t.push(n)}return t}function iu(r){return Object.keys(r)}var ho=class{schema;options;shape;length=0;rows=null;cursor=0;_headers=[];constructor(t,e){if(this.options=e,this.schema=t,!Array.isArray(t)){this._headers=[];for(let n in t)this._headers[t[n].index]=t[n].name}}rowCount(){return this.length}addArrayRow(t,e){Number.isFinite(e)&&(this.cursor=e),this.shape="array-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=t,this.length++}addObjectRow(t,e){Number.isFinite(e)&&(this.cursor=e),this.shape="object-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=t,this.length++}getBatch(){let t=this.rows;return t?(t=t.slice(0,this.length),this.rows=null,{shape:this.shape||"array-row-table",batchType:"data",data:t,length:this.length,schema:this.schema,cursor:this.cursor}):null}};var su=100,po=class{schema;options;length=0;objectRows=null;arrayRows=null;cursor=0;_headers=null;constructor(t,e){if(this.options=e,this.schema=t,t){this._headers=[];for(let n=0;n<t.fields.length;n++)this._headers[n]=t.fields[n].name}}rowCount(){return this.length}addArrayRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this._headers||=nu(t),this.options.shape){case"object-row-table":let n=eu(t,this._headers);this.addObjectRow(n,e);break;case"array-row-table":this.arrayRows=this.arrayRows||new Array(su),this.arrayRows[this.length]=t,this.length++;break}}addObjectRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this._headers||=iu(t),this.options.shape){case"array-row-table":let n=ru(t,this._headers);this.addArrayRow(n,e);break;case"object-row-table":this.objectRows=this.objectRows||new Array(su),this.objectRows[this.length]=t,this.length++;break}}getBatch(){let t=this.arrayRows||this.objectRows;return t?(t=t.slice(0,this.length),this.arrayRows=null,this.objectRows=null,{shape:this.options.shape,batchType:"data",data:t,length:this.length,schema:this.schema,cursor:this.cursor}):null}};function Da(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var Rd=100,En=class{schema;length=0;allocated=0;columns={};constructor(t,e){this.schema=t,this._reallocateColumns()}rowCount(){return this.length}addArrayRow(t){this._reallocateColumns();let e=0;for(let n in this.columns)this.columns[n][this.length]=t[e++];this.length++}addObjectRow(t){this._reallocateColumns();for(let e in t)this.columns[e][this.length]=t[e];this.length++}getBatch(){return this._pruneColumns(),{shape:"columnar-table",batchType:"data",data:this.columns,schema:this.schema,length:this.length}}_reallocateColumns(){if(!(this.length<this.allocated)){this.allocated=this.allocated>0?this.allocated*=2:Rd,this.columns={};for(let t of this.schema.fields){let e=Ka(t.type,t.nullable),n=this.columns[t.name];if(!n)this.columns[t.name]=new e(this.allocated);else if(Array.isArray(n))n.length=this.allocated;else if(Da(n)){let i=new e(this.allocated);i.set(n),this.columns[t.name]=i}else throw new Error("Invalid column type")}}}_pruneColumns(){for(let[t,e]of Object.entries(this.columns))this.columns[t]=e.slice(0,this.length)}};var mo=class extends En{arrowSchema;constructor(t,e){super(t,e),this.arrowSchema=null}getBatch(){let t=super.getBatch();if(t){this.arrowSchema=this.arrowSchema||Pd(t.schema);let e=jd(this.arrowSchema,t.data),n=new Y(this.arrowSchema,w({type:new Z(this.arrowSchema.fields),children:e.map(({data:i})=>i[0])}));return{shape:"arrow-table",batchType:"data",data:new ot([n]),length:t.length}}return null}};function Pd(r){let t=[];for(let e in r){let n=r[e];if(n.type===Float32Array){let i=new Map,s=new U(n.name,new Xe,n.nullable,i);t.push(s)}}if(t.length===0)throw new Error("No arrow convertible fields");return new P(t)}function jd(r,t){let e=[];for(let n of r.fields){let i=t[n.name];if(i instanceof Float32Array){let s=_n(i);e.push(s)}}if(r.fields.length!==e.length)throw new Error("Some columns not arrow convertible");return e}var Vd={shape:void 0,batchSize:"auto",batchDebounceMs:0,limit:0,_limitMB:0},wr=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={...Vd,...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 po;case"columnar-table":return En;case"arrow-table":return mo;default:return ho}}};$a(wr,"ArrowBatch");function ou(r,t){try{let e=JSON.parse(r);if(t.json?.table){let n=au(e)||e;return Bi(n)}return e}catch{throw new Error("JSONLoader: failed to parse JSON")}}function au(r){if(Array.isArray(r))return r;if(r&&typeof r=="object")for(let t of Object.values(r)){let e=au(t);if(e)return e}return null}function Ta(r,t){if(!r)throw new Error(t||"loader assertion failed.")}var cu=r=>typeof SharedArrayBuffer<"u"&&r instanceof SharedArrayBuffer;function lu(...r){return kd(r)}function kd(r){let t=r.map(s=>s instanceof ArrayBuffer?new Uint8Array(s):s),e=t.reduce((s,o)=>s+o.byteLength,0),n=new Uint8Array(e),i=0;for(let s of t)n.set(s,i),i+=s.byteLength;return n.buffer}async function*Ai(r,t={}){let e=new TextDecoder(void 0,t);for await(let n of r)yield typeof n=="string"?n:e.decode(n,{stream:!0})}async function*Fa(r){let t="";for await(let e of r){t+=e;let n;for(;(n=t.indexOf(`
17
+ `))>=0;){let i=t.slice(0,n+1);t=t.slice(n+1),yield i}}t.length>0&&(yield t)}async function*Na(r){let t=1;for await(let e of r)yield{counter:t,line:e},t++}async function La(r){let t=[];for await(let e of r)t.push(fu(e));return lu(...t)}async function*Oi(r){for await(let t of r)yield fu(t)}function fu(r){if(r instanceof ArrayBuffer)return r;if(ArrayBuffer.isView(r)){let{buffer:t,byteOffset:e,byteLength:n}=r;return uu(t,e,n)}return uu(r)}function uu(r,t=0,e=r.byteLength-t){let n=new Uint8Array(r,t,e),i=new Uint8Array(n.length);return i.set(n),i.buffer}function Ea(r){if(r instanceof ArrayBuffer)return r;if(cu(r))return Ma(r);let{buffer:t,byteOffset:e,byteLength:n}=r;return t instanceof ArrayBuffer&&e===0&&n===t.byteLength?t:Ma(t,e,n)}function Ma(r,t=0,e=r.byteLength-t){let n=new Uint8Array(r,t,e),i=new Uint8Array(n.length);return i.set(n),i.buffer}var Ua=Number.MAX_SAFE_INTEGER,b;(function(r){r[r.BEGIN=0]="BEGIN",r[r.VALUE=1]="VALUE",r[r.OPEN_OBJECT=2]="OPEN_OBJECT",r[r.CLOSE_OBJECT=3]="CLOSE_OBJECT",r[r.OPEN_ARRAY=4]="OPEN_ARRAY",r[r.CLOSE_ARRAY=5]="CLOSE_ARRAY",r[r.TEXT_ESCAPE=6]="TEXT_ESCAPE",r[r.STRING=7]="STRING",r[r.BACKSLASH=8]="BACKSLASH",r[r.END=9]="END",r[r.OPEN_KEY=10]="OPEN_KEY",r[r.CLOSE_KEY=11]="CLOSE_KEY",r[r.TRUE=12]="TRUE",r[r.TRUE2=13]="TRUE2",r[r.TRUE3=14]="TRUE3",r[r.FALSE=15]="FALSE",r[r.FALSE2=16]="FALSE2",r[r.FALSE3=17]="FALSE3",r[r.FALSE4=18]="FALSE4",r[r.NULL=19]="NULL",r[r.NULL2=20]="NULL2",r[r.NULL3=21]="NULL3",r[r.NUMBER_DECIMAL_POINT=22]="NUMBER_DECIMAL_POINT",r[r.NUMBER_DIGIT=23]="NUMBER_DIGIT"})(b||(b={}));var F={tab:9,lineFeed:10,carriageReturn:13,space:32,doubleQuote:34,plus:43,comma:44,minus:45,period:46,_0:48,_9:57,colon:58,E:69,openBracket:91,backslash:92,closeBracket:93,a:97,b:98,e:101,f:102,l:108,n:110,r:114,s:115,t:116,u:117,openBrace:123,closeBrace:125},hu=/[\\"\n]/g,du={onready:()=>{},onopenobject:()=>{},onkey:()=>{},oncloseobject:()=>{},onopenarray:()=>{},onclosearray:()=>{},onvalue:()=>{},onerror:()=>{},onend:()=>{},onchunkparsed:()=>{}},tn=class{options=du;bufferCheckPosition=Ua;q="";c="";p="";closed=!1;closedRoot=!1;sawRoot=!1;error=null;state=b.BEGIN;stack=[];position=0;column=0;line=1;slashed=!1;unicodeI=0;unicodeS=null;depth=0;textNode;numberNode;constructor(t={}){this.options={...du,...t},this.textNode=void 0,this.numberNode="",this.emit("onready")}end(){return(this.state!==b.VALUE||this.depth!==0)&&this._error("Unexpected end"),this._closeValue(),this.c="",this.closed=!0,this.emit("onend"),this}resume(){return this.error=null,this}close(){return this.write(null)}emit(t,e){this.options[t]?.(e,this)}emitNode(t,e){this._closeValue(),this.emit(t,e)}write(t){if(this.error)throw this.error;if(this.closed)return this._error("Cannot write after close. Assign an onready handler.");if(t===null)return this.end();let e=0,n=t.charCodeAt(0),i=this.p;for(;n&&(i=n,this.c=n=t.charCodeAt(e++),i!==n?this.p=i:i=this.p,!!n);)switch(this.position++,n===F.lineFeed?(this.line++,this.column=0):this.column++,this.state){case b.BEGIN:n===F.openBrace?this.state=b.OPEN_OBJECT:n===F.openBracket?this.state=b.OPEN_ARRAY:Di(n)||this._error("Non-whitespace before {[.");continue;case b.OPEN_KEY:case b.OPEN_OBJECT:if(Di(n))continue;if(this.state===b.OPEN_KEY)this.stack.push(b.CLOSE_KEY);else if(n===F.closeBrace){this.emit("onopenobject"),this.depth++,this.emit("oncloseobject"),this.depth--,this.state=this.stack.pop()||b.VALUE;continue}else this.stack.push(b.CLOSE_OBJECT);n===F.doubleQuote?this.state=b.STRING:this._error('Malformed object key should start with "');continue;case b.CLOSE_KEY:case b.CLOSE_OBJECT:if(Di(n))continue;n===F.colon?(this.state===b.CLOSE_OBJECT?(this.stack.push(b.CLOSE_OBJECT),this._closeValue("onopenobject"),this.depth++):this._closeValue("onkey"),this.state=b.VALUE):n===F.closeBrace?(this.emitNode("oncloseobject"),this.depth--,this.state=this.stack.pop()||b.VALUE):n===F.comma?(this.state===b.CLOSE_OBJECT&&this.stack.push(b.CLOSE_OBJECT),this._closeValue(),this.state=b.OPEN_KEY):this._error("Bad object");continue;case b.OPEN_ARRAY:case b.VALUE:if(Di(n))continue;if(this.state===b.OPEN_ARRAY)if(this.emit("onopenarray"),this.depth++,this.state=b.VALUE,n===F.closeBracket){this.emit("onclosearray"),this.depth--,this.state=this.stack.pop()||b.VALUE;continue}else this.stack.push(b.CLOSE_ARRAY);n===F.doubleQuote?this.state=b.STRING:n===F.openBrace?this.state=b.OPEN_OBJECT:n===F.openBracket?this.state=b.OPEN_ARRAY:n===F.t?this.state=b.TRUE:n===F.f?this.state=b.FALSE:n===F.n?this.state=b.NULL:n===F.minus?this.numberNode+="-":F._0<=n&&n<=F._9?(this.numberNode+=String.fromCharCode(n),this.state=b.NUMBER_DIGIT):this._error("Bad value");continue;case b.CLOSE_ARRAY:if(n===F.comma)this.stack.push(b.CLOSE_ARRAY),this._closeValue("onvalue"),this.state=b.VALUE;else if(n===F.closeBracket)this.emitNode("onclosearray"),this.depth--,this.state=this.stack.pop()||b.VALUE;else{if(Di(n))continue;this._error("Bad array")}continue;case b.STRING:this.textNode===void 0&&(this.textNode="");let s=e-1,o=this.slashed,a=this.unicodeI;t:for(;;){for(;a>0;)if(this.unicodeS+=String.fromCharCode(n),n=t.charCodeAt(e++),this.position++,a===4?(this.textNode+=String.fromCharCode(parseInt(this.unicodeS,16)),a=0,s=e-1):a++,!n)break t;if(n===F.doubleQuote&&!o){this.state=this.stack.pop()||b.VALUE,this.textNode+=t.substring(s,e-1),this.position+=e-1-s;break}if(n===F.backslash&&!o&&(o=!0,this.textNode+=t.substring(s,e-1),this.position+=e-1-s,n=t.charCodeAt(e++),this.position++,!n))break;if(o){if(o=!1,n===F.n?this.textNode+=`
18
+ `:n===F.r?this.textNode+="\r":n===F.t?this.textNode+=" ":n===F.f?this.textNode+="\f":n===F.b?this.textNode+="\b":n===F.u?(a=1,this.unicodeS=""):this.textNode+=String.fromCharCode(n),n=t.charCodeAt(e++),this.position++,s=e-1,n)continue;break}hu.lastIndex=e;let c=hu.exec(t);if(c===null){e=t.length+1,this.textNode+=t.substring(s,e-1),this.position+=e-1-s;break}if(e=c.index+1,n=t.charCodeAt(c.index),!n){this.textNode+=t.substring(s,e-1),this.position+=e-1-s;break}}this.slashed=o,this.unicodeI=a;continue;case b.TRUE:n===F.r?this.state=b.TRUE2:this._error(`Invalid true started with t${n}`);continue;case b.TRUE2:n===F.u?this.state=b.TRUE3:this._error(`Invalid true started with tr${n}`);continue;case b.TRUE3:n===F.e?(this.emit("onvalue",!0),this.state=this.stack.pop()||b.VALUE):this._error(`Invalid true started with tru${n}`);continue;case b.FALSE:n===F.a?this.state=b.FALSE2:this._error(`Invalid false started with f${n}`);continue;case b.FALSE2:n===F.l?this.state=b.FALSE3:this._error(`Invalid false started with fa${n}`);continue;case b.FALSE3:n===F.s?this.state=b.FALSE4:this._error(`Invalid false started with fal${n}`);continue;case b.FALSE4:n===F.e?(this.emit("onvalue",!1),this.state=this.stack.pop()||b.VALUE):this._error(`Invalid false started with fals${n}`);continue;case b.NULL:n===F.u?this.state=b.NULL2:this._error(`Invalid null started with n${n}`);continue;case b.NULL2:n===F.l?this.state=b.NULL3:this._error(`Invalid null started with nu${n}`);continue;case b.NULL3:n===F.l?(this.emit("onvalue",null),this.state=this.stack.pop()||b.VALUE):this._error(`Invalid null started with nul${n}`);continue;case b.NUMBER_DECIMAL_POINT:n===F.period?(this.numberNode+=".",this.state=b.NUMBER_DIGIT):this._error("Leading zero not followed by .");continue;case b.NUMBER_DIGIT:F._0<=n&&n<=F._9?this.numberNode+=String.fromCharCode(n):n===F.period?(this.numberNode.indexOf(".")!==-1&&this._error("Invalid number has two dots"),this.numberNode+="."):n===F.e||n===F.E?((this.numberNode.indexOf("e")!==-1||this.numberNode.indexOf("E")!==-1)&&this._error("Invalid number has two exponential"),this.numberNode+="e"):n===F.plus||n===F.minus?(i===F.e||i===F.E||this._error("Invalid symbol in number"),this.numberNode+=String.fromCharCode(n)):(this._closeNumber(),e--,this.state=this.stack.pop()||b.VALUE);continue;default:this._error(`Unknown state: ${this.state}`)}return this.position>=this.bufferCheckPosition&&zd(this),this.emit("onchunkparsed"),this}_closeValue(t="onvalue"){this.textNode!==void 0&&this.emit(t,this.textNode),this.textNode=void 0}_closeNumber(){this.numberNode&&this.emit("onvalue",parseFloat(this.numberNode)),this.numberNode=""}_error(t=""){this._closeValue(),t+=`
19
19
  Line: ${this.line}
20
20
  Column: ${this.column}
21
- Char: ${this.c}`;let e=new Error(t);this.error=e,this.emit("onerror",e)}};function Si(r){return r===F.carriageReturn||r===F.lineFeed||r===F.space||r===F.tab}function md(r){let t=Math.max(va,10),e=0;for(let n of["textNode","numberNode"]){let i=r[n]===void 0?0:r[n].length;if(i>t)switch(n){case"text":break;default:r._error(`Max buffer length exceeded: ${n}`)}e=Math.max(e,i)}r.bufferCheckPosition=va-e+r.position}var Dt=class{path;constructor(t=null){if(this.path=["$"],t instanceof Dt){this.path=[...t.path];return}if(Array.isArray(t)){this.path.push(...t);return}if(typeof t=="string"&&(this.path=t.split("."),this.path[0]!=="$"))throw new Error("JSONPaths must start with $")}clone(){return new Dt(this)}toString(){return this.path.join(".")}push(t){this.path.push(t)}pop(){return this.path.pop()}set(t){this.path[this.path.length-1]=t}equals(t){if(!this||!t||this.path.length!==t.path.length)return!1;for(let e=0;e<this.path.length;++e)if(this.path[e]!==t.path[e])return!1;return!0}setFieldAtPath(t,e){let n=[...this.path];n.shift();let i=n.pop();for(let s of n)t=t[s];t[i]=e}getFieldAtPath(t){let e=[...this.path];e.shift();let n=e.pop();for(let i of e)t=t[i];return t[n]}};var Bi=class{parser;result=void 0;previousStates=[];currentState=Object.freeze({container:[],key:null});jsonpath=new Dt;constructor(t){this.reset(),this.parser=new Xr({onready:()=>{this.jsonpath=new Dt,this.previousStates.length=0,this.currentState.container.length=0},onopenobject:e=>{this._openObject({}),typeof e<"u"&&this.parser.emit("onkey",e)},onkey:e=>{this.jsonpath.set(e),this.currentState.key=e},oncloseobject:()=>{this._closeObject()},onopenarray:()=>{this._openArray()},onclosearray:()=>{this._closeArray()},onvalue:e=>{this._pushOrSet(e)},onerror:e=>{throw e},onend:()=>{this.result=this.currentState.container.pop()},...t})}reset(){this.result=void 0,this.previousStates=[],this.currentState=Object.freeze({container:[],key:null}),this.jsonpath=new Dt}write(t){this.parser.write(t)}close(){this.parser.close()}_pushOrSet(t){let{container:e,key:n}=this.currentState;n!==null?(e[n]=t,this.currentState.key=null):e.push(t)}_openArray(t=[]){this.jsonpath.push(null),this._pushOrSet(t),this.previousStates.push(this.currentState),this.currentState={container:t,isArray:!0,key:null}}_closeArray(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}_openObject(t={}){this.jsonpath.push(null),this._pushOrSet(t),this.previousStates.push(this.currentState),this.currentState={container:t,isArray:!1,key:null}}_closeObject(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}};var Ai=class extends Bi{jsonPaths;streamingJsonPath=null;streamingArray=null;topLevelObject=null;constructor(t={}){super({onopenarray:()=>{if(!this.streamingArray&&this._matchJSONPath()){this.streamingJsonPath=this.getJsonPath().clone(),this.streamingArray=[],this._openArray(this.streamingArray);return}this._openArray()},onopenobject:n=>{this.topLevelObject?this._openObject({}):(this.topLevelObject={},this._openObject(this.topLevelObject)),typeof n<"u"&&this.parser.emit("onkey",n)}});let e=t.jsonpaths||[];this.jsonPaths=e.map(n=>new Dt(n))}write(t){super.write(t);let e=[];return this.streamingArray&&(e=[...this.streamingArray],this.streamingArray.length=0),e}getPartialResult(){return this.topLevelObject}getStreamingJsonPath(){return this.streamingJsonPath}getStreamingJsonPathAsString(){return this.streamingJsonPath&&this.streamingJsonPath.toString()}getJsonPath(){return this.jsonpath}_matchJSONPath(){let t=this.getJsonPath();if(this.jsonPaths.length===0)return!0;for(let e of this.jsonPaths)if(e.equals(t))return!0;return!1}};async function*co(r,t){let e=xi(r),{metadata:n}=t,{jsonpaths:i}=t.json||{},s=!0,o=null,a=new br(o,t),c=new Ai({jsonpaths:i});for await(let f of e){let d=c.write(f),p=d.length>0&&c.getStreamingJsonPathAsString();d.length>0&&s&&(n&&(yield{shape:t?.json?.shape||"array-row-table",batchType:"partial-result",data:[],length:0,bytesUsed:0,container:c.getPartialResult(),jsonpath:p}),s=!1);for(let G of d){a.addRow(G);let nt=a.getFullBatch({jsonpath:p});nt&&(yield nt)}a.chunkComplete(f);let g=a.getFullBatch({jsonpath:p});g&&(yield g)}let l=c.getStreamingJsonPathAsString(),u=a.getFinalBatch({jsonpath:l});u&&(yield u),n&&(yield{shape:"json",batchType:"final-result",container:c.getPartialResult(),jsonpath:c.getStreamingJsonPathAsString(),data:[],length:0})}function Gl(r,t){if(ga(r.batchType==="final-result"),r.jsonpath==="$")return t;if(r.jsonpath&&r.jsonpath.length>1){let e=r.container;return new Dt(r.jsonpath).setFieldAtPath(e,t),e}return r.container}var yd="4.4.0-alpha.1",lo={dataType:null,batchType:null,name:"JSON",id:"json",module:"json",version:yd,extensions:["json","geojson"],mimeTypes:["application/json"],category:"table",text:!0,options:{json:{shape:void 0,table:!1,jsonpaths:[]}},parse:gd,parseTextSync:Jl,parseInBatches:bd};async function gd(r,t){return Jl(new TextDecoder().decode(r),t)}function Jl(r,t){let e={...t,json:{...lo.options.json,...t?.json}};return jl(r,e)}function bd(r,t){let e={...t,json:{...lo.options.json,...t?.json}};return co(r,e)}function Ia(r){let e=r.trim().split(`
22
- `).map((n,i)=>{try{return JSON.parse(n)}catch{throw new Error(`NDJSONLoader: failed to parse JSON on line ${i+1}`)}});return Ii(e)}async function*$l(r,t){let e=xi(r),n=ba(e),i=_a(n),s=null,o="row-table",a=new br(s,{...t,shape:o});for await(let{counter:l,line:u}of i)try{let f=JSON.parse(u);a.addRow(f),a.chunkComplete(u);let d=a.getFullBatch();d&&(yield d)}catch{throw new Error(`NDJSONLoader: failed to parse JSON on line ${l}`)}let c=a.getFinalBatch();c&&(yield c)}var _d="4.4.0-alpha.1",Hl={dataType:null,batchType:null,name:"NDJSON",id:"ndjson",module:"json",version:_d,extensions:["ndjson","jsonl"],mimeTypes:["application/x-ndjson","application/jsonlines","application/json-seq"],category:"table",text:!0,parse:async r=>Ia(new TextDecoder().decode(r)),parseTextSync:Ia,parseInBatches:$l,options:{}};function xa(r,t){let e=t?.json?.shape||"object-row-table",n=[],i=ma(r,e);for(let s of i)n.push(JSON.stringify(s));return`[${n.join(",")}]`}var Yl={id:"json",version:"latest",module:"json",name:"JSON",extensions:["json"],mimeTypes:["application/json"],options:{},text:!0,encode:async(r,t)=>new TextEncoder().encode(xa(r,t)).buffer,encodeTextSync:(r,t)=>xa(r,t)};function Zl(r){let t=0,e=0,n=0,i=0,s=0,o=0,a=0,c=0,l=0,u=new Set;for(let f of r){let d=f.geometry;switch(d.type){case"Point":e++,t++,u.add(d.coordinates.length);break;case"MultiPoint":e++,t+=d.coordinates.length;for(let g of d.coordinates)u.add(g.length);break;case"LineString":s++,n+=d.coordinates.length,i++;for(let g of d.coordinates)u.add(g.length);break;case"MultiLineString":s++;for(let g of d.coordinates){n+=g.length,i++;for(let G of g)u.add(G.length)}break;case"Polygon":l++,a++,c+=d.coordinates.length;let p=d.coordinates.flat();o+=p.length;for(let g of p)u.add(g.length);break;case"MultiPolygon":l++;for(let g of d.coordinates){a++,c+=g.length;let G=g.flat();o+=G.length;for(let nt of G)u.add(nt.length)}break;default:throw new Error(`Unsupported geometry type: ${d.type}`)}}return{coordLength:u.size>0?Math.max(...u):2,pointPositionsCount:t,pointFeaturesCount:e,linePositionsCount:n,linePathsCount:i,lineFeaturesCount:s,polygonPositionsCount:o,polygonObjectsCount:a,polygonRingsCount:c,polygonFeaturesCount:l}}var Oi={x:0,y:1,z:2};function Fn(r,t={}){let{start:e=0,end:n=r.length,plane:i="xy"}=t,s=t.size||2,o=0,a=Oi[i[0]],c=Oi[i[1]];for(let l=e,u=n-s;l<n;l+=s)o+=(r[l+a]-r[u+a])*(r[l+c]+r[u+c]),u=l;return o/2}function Ba(r,t,e=2,n,i="xy"){let s=t&&t.length,o=s?t[0]*e:r.length,a=Xl(r,0,o,e,!0,n&&n[0],i),c=[];if(!a||a.next===a.prev)return c;let l,u,f,d,p,g,G;if(s&&(a=Ad(r,t,a,e,n,i)),r.length>80*e){d=u=r[0],p=f=r[1];for(let nt=e;nt<o;nt+=e)g=r[nt],G=r[nt+1],g<d&&(d=g),G<p&&(p=G),g>u&&(u=g),G>f&&(f=G);l=Math.max(u-d,f-p),l=l!==0?32767/l:0}return Di(a,c,e,d,p,l,0),c}function Xl(r,t,e,n,i,s,o){let a,c;s===void 0&&(s=Fn(r,{start:t,end:e,size:n,plane:o}));let l=Oi[o[0]],u=Oi[o[1]];if(i===s<0)for(a=t;a<e;a+=n)c=Kl(a,r[a+l],r[a+u],c);else for(a=e-n;a>=t;a-=n)c=Kl(a,r[a+l],r[a+u],c);return c&&fo(c,c.next)&&(Ti(c),c=c.next),c}function qr(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(fo(e,e.next)||ot(e.prev,e,e.next)===0)){if(Ti(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Di(r,t,e,n,i,s,o){if(!r)return;!o&&s&&Nd(r,n,i,s);let a=r,c,l;for(;r.prev!==r.next;){if(c=r.prev,l=r.next,s?xd(r,n,i,s):Id(r)){t.push(c.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),Ti(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=Sd(qr(r),t,e),Di(r,t,e,n,i,s,2)):o===2&&Bd(r,t,e,n,i,s):Di(qr(r),t,e,n,i,s,1);break}}}function Id(r){let t=r.prev,e=r,n=r.next;if(ot(t,e,n)>=0)return!1;let i=t.x,s=e.x,o=n.x,a=t.y,c=e.y,l=n.y,u=i<s?i<o?i:o:s<o?s:o,f=a<c?a<l?a:l:c<l?c:l,d=i>s?i>o?i:o:s>o?s:o,p=a>c?a>l?a:l:c>l?c:l,g=n.next;for(;g!==t;){if(g.x>=u&&g.x<=d&&g.y>=f&&g.y<=p&&Tn(i,a,s,c,o,l,g.x,g.y)&&ot(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function xd(r,t,e,n){let i=r.prev,s=r,o=r.next;if(ot(i,s,o)>=0)return!1;let a=i.x,c=s.x,l=o.x,u=i.y,f=s.y,d=o.y,p=a<c?a<l?a:l:c<l?c:l,g=u<f?u<d?u:d:f<d?f:d,G=a>c?a>l?a:l:c>l?c:l,nt=u>f?u>d?u:d:f>d?f:d,Ft=Sa(p,g,t,e,n),or=Sa(G,nt,t,e,n),z=r.prevZ,V=r.nextZ;for(;z&&z.z>=Ft&&V&&V.z<=or;){if(z.x>=p&&z.x<=G&&z.y>=g&&z.y<=nt&&z!==i&&z!==o&&Tn(a,u,c,f,l,d,z.x,z.y)&&ot(z.prev,z,z.next)>=0||(z=z.prevZ,V.x>=p&&V.x<=G&&V.y>=g&&V.y<=nt&&V!==i&&V!==o&&Tn(a,u,c,f,l,d,V.x,V.y)&&ot(V.prev,V,V.next)>=0))return!1;V=V.nextZ}for(;z&&z.z>=Ft;){if(z.x>=p&&z.x<=G&&z.y>=g&&z.y<=nt&&z!==i&&z!==o&&Tn(a,u,c,f,l,d,z.x,z.y)&&ot(z.prev,z,z.next)>=0)return!1;z=z.prevZ}for(;V&&V.z<=or;){if(V.x>=p&&V.x<=G&&V.y>=g&&V.y<=nt&&V!==i&&V!==o&&Tn(a,u,c,f,l,d,V.x,V.y)&&ot(V.prev,V,V.next)>=0)return!1;V=V.nextZ}return!0}function Sd(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!fo(i,s)&&ql(i,n,n.next,s)&&Fi(i,s)&&Fi(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Ti(n),Ti(n.next),n=r=s),n=n.next}while(n!==r);return qr(n)}function Bd(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Md(o,a)){let c=Ql(o,a);o=qr(o,o.next),c=qr(c,c.next),Di(o,t,e,n,i,s,0),Di(c,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function Ad(r,t,e,n,i,s){let o=[],a,c,l,u,f;for(a=0,c=t.length;a<c;a++)l=t[a]*n,u=a<c-1?t[a+1]*n:r.length,f=Xl(r,l,u,n,!1,i&&i[a+1],s),f===f.next&&(f.steiner=!0),o.push(Ud(f));for(o.sort(Od),a=0;a<o.length;a++)e=Dd(o[a],e);return e}function Od(r,t){return r.x-t.x}function Dd(r,t){let e=Fd(r,t);if(!e)return t;let n=Ql(e,r);return qr(n,n.next),qr(e,e.next)}function Fd(r,t){let e=t,n=r.x,i=r.y,s=-1/0,o;do{if(i<=e.y&&i>=e.next.y&&e.next.y!==e.y){let d=e.x+(i-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=n&&d>s&&(s=d,o=e.x<e.next.x?e:e.next,d===n))return o}e=e.next}while(e!==t);if(!o)return null;let a=o,c=o.x,l=o.y,u=1/0,f;e=o;do n>=e.x&&e.x>=c&&n!==e.x&&Tn(i<l?n:s,i,c,l,i<l?s:n,i,e.x,e.y)&&(f=Math.abs(i-e.y)/(n-e.x),Fi(e,r)&&(f<u||f===u&&(e.x>o.x||e.x===o.x&&Td(o,e)))&&(o=e,u=f)),e=e.next;while(e!==a);return o}function Td(r,t){return ot(r.prev,r,t.prev)<0&&ot(t.next,r,r.next)<0}function Nd(r,t,e,n){let i=r;do i.z===0&&(i.z=Sa(i.x,i.y,t,e,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next;while(i!==r);i.prevZ.nextZ=null,i.prevZ=null,Ld(i)}function Ld(r){let t,e,n=1,i,s,o,a,c,l;do{for(s=r,r=null,l=null,i=0;s;){for(i++,a=s,o=0,e=0;e<n&&(o++,a=a.nextZ,!!a);e++);for(c=n;o>0||c>0&&a;)o!==0&&(c===0||!a||s.z<=a.z)?(t=s,s=s.nextZ,o--):(t=a,a=a.nextZ,c--),l?l.nextZ=t:r=t,t.prevZ=l,l=t;s=a}l.nextZ=null,n*=2}while(i>1);return r}function Sa(r,t,e,n,i){return r=(r-e)*i|0,t=(t-n)*i|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function Ud(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function Tn(r,t,e,n,i,s,o,a){return(i-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(n-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(i-o)*(n-a)}function Md(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Ed(r,t)&&(Fi(r,t)&&Fi(t,r)&&Cd(r,t)&&(ot(r.prev,r,t.prev)||ot(r,t.prev,t))||fo(r,t)&&ot(r.prev,r,r.next)>0&&ot(t.prev,t,t.next)>0)}function ot(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function fo(r,t){return r.x===t.x&&r.y===t.y}function ql(r,t,e,n){let i=ho(ot(r,t,e)),s=ho(ot(r,t,n)),o=ho(ot(e,n,r)),a=ho(ot(e,n,t));return!!(i!==s&&o!==a||i===0&&uo(r,e,t)||s===0&&uo(r,n,t)||o===0&&uo(e,r,n)||a===0&&uo(e,t,n))}function uo(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function ho(r){return r>0?1:r<0?-1:0}function Ed(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&ql(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Fi(r,t){return ot(r.prev,r,r.next)<0?ot(r,t,r.next)>=0&&ot(r,r.prev,t)>=0:ot(r,t,r.prev)<0||ot(r,r.next,t)<0}function Cd(r,t){let e=r,n=!1,i=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==r);return n}function Ql(r,t){let e=new Ni(r.i,r.x,r.y),n=new Ni(t.i,t.x,t.y),i=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=i,i.prev=e,n.next=e,e.prev=n,s.next=n,n.prev=s,n}function Kl(r,t,e,n){let i=new Ni(r,t,e);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function Ti(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}var Ni=class{constructor(t,e,n){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=t,this.x=e,this.y=n}};function ru(r,t,e){let n=Vd(r),i=Object.keys(n).filter(s=>n[s]!==Array);return zd(r,{propArrayTypes:n,...t},{numericPropKeys:e&&e.numericPropKeys||i,PositionDataType:e?e.PositionDataType:Float32Array,triangulate:e?e.triangulate:!0})}function Vd(r){let t={};for(let e of r)if(e.properties)for(let n in e.properties){let i=e.properties[n];t[n]=Yd(i,t[n])}return t}function zd(r,t,e){let{pointPositionsCount:n,pointFeaturesCount:i,linePositionsCount:s,linePathsCount:o,lineFeaturesCount:a,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:u,polygonFeaturesCount:f,propArrayTypes:d,coordLength:p}=t,{numericPropKeys:g=[],PositionDataType:G=Float32Array,triangulate:nt=!0}=e,Ft=r[0]&&"id"in r[0],or=r.length>65535?Uint32Array:Uint16Array,z={type:"Point",positions:new G(n*p),globalFeatureIds:new or(n),featureIds:i>65535?new Uint32Array(n):new Uint16Array(n),numericProps:{},properties:[],fields:[]},V={type:"LineString",pathIndices:s>65535?new Uint32Array(o+1):new Uint16Array(o+1),positions:new G(s*p),globalFeatureIds:new or(s),featureIds:a>65535?new Uint32Array(s):new Uint16Array(s),numericProps:{},properties:[],fields:[]},ar={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(u+1):new Uint16Array(u+1),positions:new G(c*p),globalFeatureIds:new or(c),featureIds:f>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};nt&&(ar.triangles=[]);for(let cr of[z,V,ar])for(let wr of g){let lr=d[wr];cr.numericProps[wr]=new lr(cr.positions.length/p)}V.pathIndices[o]=s,ar.polygonIndices[l]=c,ar.primitivePolygonIndices[u]=c;let _r={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let cr of r){let wr=cr.geometry,lr=cr.properties||{};switch(wr.type){case"Point":Wd(wr,z,_r,p,lr),z.properties.push(Oa(lr,g)),Ft&&z.fields.push({id:cr.id}),_r.pointFeature++;break;case"LineString":Gd(wr,V,_r,p,lr),V.properties.push(Oa(lr,g)),Ft&&V.fields.push({id:cr.id}),_r.lineFeature++;break;case"Polygon":Jd(wr,ar,_r,p,lr),ar.properties.push(Oa(lr,g)),Ft&&ar.fields.push({id:cr.id}),_r.polygonFeature++;break;default:throw new Error("Invalid geometry type")}_r.feature++}return Hd(z,V,ar,p)}function Wd(r,t,e,n,i){t.positions.set(r.data,e.pointPosition*n);let s=r.data.length/n;Da(t,i,e.pointPosition,s),t.globalFeatureIds.fill(e.feature,e.pointPosition,e.pointPosition+s),t.featureIds.fill(e.pointFeature,e.pointPosition,e.pointPosition+s),e.pointPosition+=s}function Gd(r,t,e,n,i){t.positions.set(r.data,e.linePosition*n);let s=r.data.length/n;Da(t,i,e.linePosition,s),t.globalFeatureIds.fill(e.feature,e.linePosition,e.linePosition+s),t.featureIds.fill(e.lineFeature,e.linePosition,e.linePosition+s);for(let o=0,a=r.indices.length;o<a;++o){let c=r.indices[o],l=o===a-1?r.data.length:r.indices[o+1];t.pathIndices[e.linePath++]=e.linePosition,e.linePosition+=(l-c)/n}}function Jd(r,t,e,n,i){t.positions.set(r.data,e.polygonPosition*n);let s=r.data.length/n;Da(t,i,e.polygonPosition,s),t.globalFeatureIds.fill(e.feature,e.polygonPosition,e.polygonPosition+s),t.featureIds.fill(e.polygonFeature,e.polygonPosition,e.polygonPosition+s);for(let o=0,a=r.indices.length;o<a;++o){let c=e.polygonPosition;t.polygonIndices[e.polygonObject++]=c;let l=r.areas[o],u=r.indices[o],f=r.indices[o+1];for(let p=0,g=u.length;p<g;++p){let G=u[p],nt=p===g-1?f===void 0?r.data.length:f[0]:u[p+1];t.primitivePolygonIndices[e.polygonRing++]=e.polygonPosition,e.polygonPosition+=(nt-G)/n}let d=e.polygonPosition;$d(t,l,u,{startPosition:c,endPosition:d,coordLength:n})}}function $d(r,t,e,{startPosition:n,endPosition:i,coordLength:s}){if(!r.triangles)return;let o=n*s,a=i*s,c=r.positions.subarray(o,a),l=e[0],u=e.slice(1).map(d=>(d-l)/s),f=Ba(c,u,s,t);for(let d=0,p=f.length;d<p;++d)r.triangles.push(n+f[d])}function Aa(r,t){let e={};for(let n in r)e[n]={value:r[n],size:t};return e}function Hd(r,t,e,n){let i={shape:"binary-feature-collection",points:{...r,positions:{value:r.positions,size:n},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:Aa(r.numericProps,1)},lines:{...t,positions:{value:t.positions,size:n},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:Aa(t.numericProps,1)},polygons:{...e,positions:{value:e.positions,size:n},polygonIndices:{value:e.polygonIndices,size:1},primitivePolygonIndices:{value:e.primitivePolygonIndices,size:1},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:Aa(e.numericProps,1)}};return i.polygons&&e.triangles&&(i.polygons.triangles={value:new Uint32Array(e.triangles),size:1}),i}function Da(r,t,e,n){for(let i in r.numericProps)if(i in t){let s=t[i];r.numericProps[i].fill(s,e,e+n)}}function Oa(r,t){let e={};for(let n in r)t.includes(n)||(e[n]=r[n]);return e}function Yd(r,t){return t===Array||!Number.isFinite(r)?Array:t===Float64Array||Math.fround(r)!==r?Float64Array:Float32Array}function su(r,t={coordLength:2,fixRingWinding:!0}){return r.map(e=>Zd(e,t))}function nu(r,t,e,n){e.push(t.length),t.push(...r);for(let i=r.length;i<n.coordLength;i++)t.push(0)}function Fa(r,t,e,n){e.push(t.length);for(let i of r){t.push(...i);for(let s=i.length;s<n.coordLength;s++)t.push(0)}}function iu(r,t,e,n,i){let s=0,o=[],a=[];for(let c of r){let l=c.map(d=>d.slice(0,2)),u=Fn(l.flat()),f=u<0;i.fixRingWinding&&(s===0&&!f||s>0&&f)&&(c.reverse(),u=-u),o.push(u),Fa(c,t,a,i),s++}s>0&&(n.push(o),e.push(a))}function Zd(r,t){let{geometry:e}=r;if(e.type==="GeometryCollection")throw new Error("GeometryCollection type not supported");let n=[],i=[],s,o;switch(e.type){case"Point":o="Point",nu(e.coordinates,n,i,t);break;case"MultiPoint":o="Point",e.coordinates.map(a=>nu(a,n,i,t));break;case"LineString":o="LineString",Fa(e.coordinates,n,i,t);break;case"MultiLineString":o="LineString",e.coordinates.map(a=>Fa(a,n,i,t));break;case"Polygon":o="Polygon",s=[],iu(e.coordinates,n,i,s,t);break;case"MultiPolygon":o="Polygon",s=[],e.coordinates.map(a=>iu(a,n,i,s,t));break;default:throw new Error(`Unknown type: ${o}`)}return{...r,geometry:{type:o,indices:i,data:n,areas:s}}}function Li(r,t={fixRingWinding:!0,triangulate:!0}){let e=Zl(r),n=e.coordLength,{fixRingWinding:i}=t,s=su(r,{coordLength:n,fixRingWinding:i});return ru(s,e,{numericPropKeys:t.numericPropKeys,PositionDataType:t.PositionDataType||Float32Array,triangulate:t.triangulate})}var Kd="4.4.0-alpha.1",Ta={dataType:null,batchType:null,name:"GeoJSON",id:"geojson",module:"geojson",version:Kd,worker:!0,extensions:["geojson"],mimeTypes:["application/geo+json"],category:"geometry",text:!0,options:{geojson:{shape:"geojson-table"},json:{shape:"object-row-table",jsonpaths:["$","$.features"]},gis:{format:"geojson"}}},Nn={...Ta,parse:Xd,parseTextSync:ou,parseInBatches:qd};async function Xd(r,t){return ou(new TextDecoder().decode(r),t)}function ou(r,t){t={...Nn.options,...t},t.geojson={...Nn.options.geojson,...t.geojson},t.gis=t.gis||{};let e;try{e=JSON.parse(r)}catch{e={}}let n={shape:"geojson-table",type:"FeatureCollection",features:e?.features||[]};switch(t.gis.format){case"binary":return Li(n.features);default:return n}}function qd(r,t){t={...Nn.options,...t},t.json={...Nn.options.geojson,...t.geojson};let e=co(r,t);switch(t.gis.format){case"binary":return Qd(e);default:return e}}async function*Qd(r){for await(let t of r)t.data=Li(t.data),yield t}function au(r){let t=r.schema?.fields.findIndex(e=>e.name==="geometry")??-1;if(t>-1)return t;if(gr(r)>0){let e=io(r,0);for(let n=0;n<ro(r);n++){let i=e?.[n];if(i&&typeof i=="object")return n}}throw new Error("Failed to detect geometry column")}function cu(r,t,e=[]){let n={};for(let i=0;i<ro(r);++i){let s=r.schema?.fields[i].name;s&&!e.includes(i)&&(n[s]=t[s])}return n}function lu(r,t,e,n){let i=no(r,t);if(!i)return;let s=tp(r,i,e),o=JSON.stringify(s);n.push(o)}function tp(r,t,e){let n=cu(r,t,[e]),i=r.schema?.fields[e].name,s=i&&t[i];if(!s)return{type:"Feature",geometry:null,properties:n};if(typeof s=="string")try{s=JSON.parse(s)}catch{throw new Error("Invalid string geometry")}if(typeof s!="object"||typeof s?.type!="string")throw new Error("invalid geometry column value");return s?.type==="Feature"?{...s,properties:n}:{type:"Feature",geometry:s,properties:n}}var po=class{chunkSize;strings=[];totalLength=0;textEncoder=new TextEncoder;constructor(t){this.chunkSize=t}push(...t){for(let e of t)this.strings.push(e),this.totalLength+=e.length}isFull(){return this.totalLength>=this.chunkSize}getArrayBufferBatch(){return this.textEncoder.encode(this.getStringBatch()).buffer}getStringBatch(){let t=this.strings.join("");return this.strings=[],this.totalLength=0,t}};async function*Na(r,t={}){let e={geojson:{},chunkSize:1e4,...t},n=new po(e.chunkSize);e.geojson.featureArray||n.push(`{
21
+ Char: ${this.c}`;let e=new Error(t);this.error=e,this.emit("onerror",e)}};function Di(r){return r===F.carriageReturn||r===F.lineFeed||r===F.space||r===F.tab}function zd(r){let t=Math.max(Ua,10),e=0;for(let n of["textNode","numberNode"]){let i=r[n]===void 0?0:r[n].length;if(i>t)switch(n){case"text":break;default:r._error(`Max buffer length exceeded: ${n}`)}e=Math.max(e,i)}r.bufferCheckPosition=Ua-e+r.position}var Lt=class{path;constructor(t=null){this.path=Wd(t)}clone(){return new Lt(this)}toString(){return qd(this.path)}push(t){this.path.push(t)}pop(){return this.path.pop()}set(t){this.path[this.path.length-1]=t}equals(t){if(!this||!t||this.path.length!==t.path.length)return!1;for(let e=0;e<this.path.length;++e)if(this.path[e]!==t.path[e])return!1;return!0}setFieldAtPath(t,e){let n=[...this.path];n.shift();let i=n.pop();for(let s of n)t=t[s];t[i]=e}getFieldAtPath(t){let e=[...this.path];e.shift();let n=e.pop();for(let i of e)t=t[i];return t[n]}};function Wd(r){return r instanceof Lt?[...r.path]:Array.isArray(r)?["$"].concat(r):typeof r=="string"?Jd(r):["$"]}function Jd(r){let t=r.trim();if(!t.startsWith("$"))throw new Error("JSONPath must start with $");let e=["$"],n=1,i=!1;for(;n<t.length;){let s=t[n];if(s==="."){if(i)throw new Error("JSONPath cannot select fields after array element selectors");if(n+=1,t[n]===".")throw new Error("JSONPath descendant selectors (..) are not supported");let{value:o,nextIndex:a,isWildcard:c}=Gd(t,n);if(c){if(a<t.length)throw new Error("JSONPath wildcard selectors must terminate the path");i=!0,n=a;continue}e.push(o),n=a;continue}if(s==="["){let o=$d(t,n);if(o.type==="property"){if(i)throw new Error("JSONPath cannot select fields after array element selectors");e.push(o.value)}else i=!0;n=o.nextIndex;continue}if(s==="@")throw new Error("JSONPath current node selector (@) is not supported");if(s.trim()===""){n+=1;continue}throw new Error(`Unexpected character "${s}" in JSONPath`)}return e}function Gd(r,t){if(t>=r.length)throw new Error("JSONPath cannot end with a period");if(r[t]==="*")return{value:"*",nextIndex:t+1,isWildcard:!0};let e=r[t];if(e==="@")throw new Error("JSONPath current node selector (@) is not supported");if(!Kd(e))throw new Error("JSONPath property names after period must start with a letter, $ or _");let n=t+1;for(;n<r.length&&Zd(r[n]);)n++;if(n===t)throw new Error("JSONPath is missing a property name after period");return{value:r.slice(t,n),nextIndex:n,isWildcard:!1}}function $d(r,t){let e=t+1;if(e>=r.length)throw new Error("JSONPath has unterminated bracket");let n=r[e];if(n==="'"||n==='"'){let{value:a,nextIndex:c}=Yd(r,e);return{type:"property",value:a,nextIndex:c}}let i=r.indexOf("]",e);if(i===-1)throw new Error("JSONPath has unterminated bracket");let s=r.slice(e,i).trim(),o=Hd(s);if(o)throw new Error(o);if(s==="*")return{type:"array-selector",nextIndex:i+1};if(/^\d+$/.test(s))throw new Error("JSONPath array index selectors are not supported");if(/^\d*\s*:\s*\d*(\s*:\s*\d*)?$/.test(s))return{type:"array-selector",nextIndex:i+1};throw new Error(`Unsupported bracket selector "[${s}]" in JSONPath`)}function Hd(r){return r.length?r.startsWith("(")?"JSONPath script selectors are not supported":r.startsWith("?")?"JSONPath filter selectors are not supported":r.includes(",")?"JSONPath union selectors are not supported":r.startsWith("@")||r.includes("@.")?"JSONPath current node selector (@) is not supported":null:"JSONPath bracket selectors cannot be empty"}function Yd(r,t){let e=r[t],n=t+1,i="",s=!1;for(;n<r.length;){let o=r[n];if(o==="\\"){if(n+=1,n>=r.length)break;i+=r[n],n+=1;continue}if(o===e){s=!0,n+=1;break}i+=o,n+=1}if(!s)throw new Error("JSONPath string in bracket property selector is unterminated");for(;n<r.length&&r[n].trim()==="";)n+=1;if(r[n]!=="]")throw new Error("JSONPath property selectors must end with ]");if(!i.length)throw new Error("JSONPath property selectors cannot be empty");return{value:i,nextIndex:n+1}}function Zd(r){return/[a-zA-Z0-9$_]/.test(r)}function Kd(r){return/[a-zA-Z_$]/.test(r)}function Xd(r){return/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(r)}function qd(r){return r.map((t,e)=>e===0?t:t==="*"?".*":Xd(t)?`.${t}`:`['${t.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}']`).join("")}var Ti=class{parser;result=void 0;previousStates=[];currentState=Object.freeze({container:[],key:null});jsonpath=new Lt;constructor(t){this.reset(),this.parser=new tn({onready:()=>{this.jsonpath=new Lt,this.previousStates.length=0,this.currentState.container.length=0},onopenobject:e=>{this._openObject({}),typeof e<"u"&&this.parser.emit("onkey",e)},onkey:e=>{this.jsonpath.set(e),this.currentState.key=e},oncloseobject:()=>{this._closeObject()},onopenarray:()=>{this._openArray()},onclosearray:()=>{this._closeArray()},onvalue:e=>{this._pushOrSet(e)},onerror:e=>{throw e},onend:()=>{this.result=this.currentState.container.pop()},...t})}reset(){this.result=void 0,this.previousStates=[],this.currentState=Object.freeze({container:[],key:null}),this.jsonpath=new Lt}write(t){this.parser.write(t)}close(){this.parser.close()}_pushOrSet(t){let{container:e,key:n}=this.currentState;n!==null?(e[n]=t,this.currentState.key=null):e.push(t)}_openArray(t=[]){this.jsonpath.push(null),this._pushOrSet(t),this.previousStates.push(this.currentState),this.currentState={container:t,isArray:!0,key:null}}_closeArray(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}_openObject(t={}){this.jsonpath.push(null),this._pushOrSet(t),this.previousStates.push(this.currentState),this.currentState={container:t,isArray:!1,key:null}}_closeObject(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}};var Fi=class extends Ti{jsonPaths;streamingJsonPath=null;streamingArray=null;topLevelObject=null;constructor(t={}){super({onopenarray:()=>{if(!this.streamingArray&&this._matchJSONPath()){this.streamingJsonPath=this.getJsonPath().clone(),this.streamingArray=[],this._openArray(this.streamingArray);return}this._openArray()},onopenobject:n=>{this.topLevelObject?this._openObject({}):(this.topLevelObject={},this._openObject(this.topLevelObject)),typeof n<"u"&&this.parser.emit("onkey",n)}});let e=t.jsonpaths||[];this.jsonPaths=e.map(n=>new Lt(n))}write(t){super.write(t);let e=[];return this.streamingArray&&(e=[...this.streamingArray],this.streamingArray.length=0),e}getPartialResult(){return this.topLevelObject}getStreamingJsonPath(){return this.streamingJsonPath}getStreamingJsonPathAsString(){return this.streamingJsonPath&&this.streamingJsonPath.toString()}getJsonPath(){return this.jsonpath}_matchJSONPath(){let t=this.getJsonPath();if(this.jsonPaths.length===0)return!0;for(let e of this.jsonPaths)if(e.equals(t))return!0;return!1}};async function*yo(r,t){let e=Ai(Oi(r)),n=Boolean(t?.core?.metadata||t?.metadata),{jsonpaths:i}=t.json||{},s=!0,o=null,a=new wr(o,t?.core),c=new Fi({jsonpaths:i});for await(let h of e){let d=c.write(h),p=d.length>0&&c.getStreamingJsonPathAsString();d.length>0&&s&&(n&&(yield{shape:t?.json?.shape||"array-row-table",batchType:"partial-result",data:[],length:0,bytesUsed:0,container:c.getPartialResult(),jsonpath:p}),s=!1);for(let z of d){a.addRow(z);let it=a.getFullBatch({jsonpath:p});it&&(yield it)}a.chunkComplete(h);let y=a.getFullBatch({jsonpath:p});y&&(yield y)}let l=c.getStreamingJsonPathAsString(),u=a.getFinalBatch({jsonpath:l});u&&(yield u),n&&(yield{shape:"json",batchType:"final-result",container:c.getPartialResult(),jsonpath:c.getStreamingJsonPathAsString(),data:[],length:0})}function pu(r,t){if(Ta(r.batchType==="final-result"),r.jsonpath==="$")return t;if(r.jsonpath&&r.jsonpath.length>1){let e=r.container;return new Lt(r.jsonpath).setFieldAtPath(e,t),e}return r.container}var Qd="4.4.0",go={dataType:null,batchType:null,name:"JSON",id:"json",module:"json",version:Qd,extensions:["json","geojson"],mimeTypes:["application/json"],category:"table",text:!0,options:{json:{shape:void 0,table:!1,jsonpaths:[]}},parse:tp,parseTextSync:mu,parseInBatches:ep};async function tp(r,t){return mu(new TextDecoder().decode(r),t)}function mu(r,t){let e={...t,json:{...go.options.json,...t?.json}};return ou(r,e)}function ep(r,t){let e={...t,json:{...go.options.json,...t?.json}};return yo(r,e)}function Ca(r){let e=r.trim().split(`
22
+ `).map((n,i)=>{try{return JSON.parse(n)}catch{throw new Error(`NDJSONLoader: failed to parse JSON on line ${i+1}`)}});return Bi(e)}async function*yu(r,t){let e=Ai(Oi(r)),n=Fa(e),i=Na(n),s=null,o="row-table",a=new wr(s,{...t?.core||t,shape:o});for await(let{counter:l,line:u}of i)try{let h=JSON.parse(u);a.addRow(h),a.chunkComplete(u);let d=a.getFullBatch();d&&(yield d)}catch{throw new Error(`NDJSONLoader: failed to parse JSON on line ${l}`)}let c=a.getFinalBatch();c&&(yield c)}var rp="4.4.0",gu={dataType:null,batchType:null,name:"NDJSON",id:"ndjson",module:"json",version:rp,extensions:["ndjson","jsonl"],mimeTypes:["application/x-ndjson","application/jsonlines","application/json-seq"],category:"table",text:!0,parse:async r=>Ca(new TextDecoder().decode(r)),parseTextSync:Ca,parseInBatches:yu,options:{}};function Ra(r,t){let e=t?.json?.shape||"object-row-table",n=[],i=Oa(r,e);for(let s of i)n.push(JSON.stringify(s));return`[${n.join(",")}]`}var bu={id:"json",version:"latest",module:"json",name:"JSON",extensions:["json"],mimeTypes:["application/json"],options:{},text:!0,encode:async(r,t)=>new TextEncoder().encode(Ra(r,t)).buffer,encodeTextSync:(r,t)=>Ra(r,t)};function _u(r){let t=0,e=0,n=0,i=0,s=0,o=0,a=0,c=0,l=0,u=new Set;for(let h of r){let d=h.geometry;switch(d.type){case"Point":e++,t++,u.add(d.coordinates.length);break;case"MultiPoint":e++,t+=d.coordinates.length;for(let y of d.coordinates)u.add(y.length);break;case"LineString":s++,n+=d.coordinates.length,i++;for(let y of d.coordinates)u.add(y.length);break;case"MultiLineString":s++;for(let y of d.coordinates){n+=y.length,i++;for(let z of y)u.add(z.length)}break;case"Polygon":l++,a++,c+=d.coordinates.length;let p=d.coordinates.flat();o+=p.length;for(let y of p)u.add(y.length);break;case"MultiPolygon":l++;for(let y of d.coordinates){a++,c+=y.length;let z=y.flat();o+=z.length;for(let it of z)u.add(it.length)}break;default:throw new Error(`Unsupported geometry type: ${d.type}`)}}return{coordLength:u.size>0?Math.max(...u):2,pointPositionsCount:t,pointFeaturesCount:e,linePositionsCount:n,linePathsCount:i,lineFeaturesCount:s,polygonPositionsCount:o,polygonObjectsCount:a,polygonRingsCount:c,polygonFeaturesCount:l}}var Ni={x:0,y:1,z:2};function Un(r,t={}){let{start:e=0,end:n=r.length,plane:i="xy"}=t,s=t.size||2,o=0,a=Ni[i[0]],c=Ni[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 ja(r,t,e=2,n,i="xy"){let s=t&&t.length,o=s?t[0]*e:r.length,a=vu(r,0,o,e,!0,n&&n[0],i),c=[];if(!a||a.next===a.prev)return c;let l,u,h,d,p,y,z;if(s&&(a=lp(r,t,a,e,n,i)),r.length>80*e){d=u=r[0],p=h=r[1];for(let it=e;it<o;it+=e)y=r[it],z=r[it+1],y<d&&(d=y),z<p&&(p=z),y>u&&(u=y),z>h&&(h=z);l=Math.max(u-d,h-p),l=l!==0?32767/l:0}return Li(a,c,e,d,p,l,0),c}function vu(r,t,e,n,i,s,o){let a,c;s===void 0&&(s=Un(r,{start:t,end:e,size:n,plane:o}));let l=Ni[o[0]],u=Ni[o[1]];if(i===s<0)for(a=t;a<e;a+=n)c=wu(a,r[a+l],r[a+u],c);else for(a=e-n;a>=t;a-=n)c=wu(a,r[a+l],r[a+u],c);return c&&wo(c,c.next)&&(Ei(c),c=c.next),c}function en(r,t){if(!r)return r;t||(t=r);let e=r,n;do if(n=!1,!e.steiner&&(wo(e,e.next)||at(e.prev,e,e.next)===0)){if(Ei(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function Li(r,t,e,n,i,s,o){if(!r)return;!o&&s&&pp(r,n,i,s);let a=r,c,l;for(;r.prev!==r.next;){if(c=r.prev,l=r.next,s?op(r,n,i,s):sp(r)){t.push(c.i/e|0),t.push(r.i/e|0),t.push(l.i/e|0),Ei(r),r=l.next,a=l.next;continue}if(r=l,r===a){o?o===1?(r=ap(en(r),t,e),Li(r,t,e,n,i,s,2)):o===2&&cp(r,t,e,n,i,s):Li(en(r),t,e,n,i,s,1);break}}}function sp(r){let t=r.prev,e=r,n=r.next;if(at(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,y=n.next;for(;y!==t;){if(y.x>=u&&y.x<=d&&y.y>=h&&y.y<=p&&Cn(i,a,s,c,o,l,y.x,y.y)&&at(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function op(r,t,e,n){let i=r.prev,s=r,o=r.next;if(at(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,y=u<h?u<d?u:d:h<d?h:d,z=a>c?a>l?a:l:c>l?c:l,it=u>h?u>d?u:d:h>d?h:d,Mt=Pa(p,y,t,e,n),cr=Pa(z,it,t,e,n),W=r.prevZ,k=r.nextZ;for(;W&&W.z>=Mt&&k&&k.z<=cr;){if(W.x>=p&&W.x<=z&&W.y>=y&&W.y<=it&&W!==i&&W!==o&&Cn(a,u,c,h,l,d,W.x,W.y)&&at(W.prev,W,W.next)>=0||(W=W.prevZ,k.x>=p&&k.x<=z&&k.y>=y&&k.y<=it&&k!==i&&k!==o&&Cn(a,u,c,h,l,d,k.x,k.y)&&at(k.prev,k,k.next)>=0))return!1;k=k.nextZ}for(;W&&W.z>=Mt;){if(W.x>=p&&W.x<=z&&W.y>=y&&W.y<=it&&W!==i&&W!==o&&Cn(a,u,c,h,l,d,W.x,W.y)&&at(W.prev,W,W.next)>=0)return!1;W=W.prevZ}for(;k&&k.z<=cr;){if(k.x>=p&&k.x<=z&&k.y>=y&&k.y<=it&&k!==i&&k!==o&&Cn(a,u,c,h,l,d,k.x,k.y)&&at(k.prev,k,k.next)>=0)return!1;k=k.nextZ}return!0}function ap(r,t,e){let n=r;do{let i=n.prev,s=n.next.next;!wo(i,s)&&Iu(i,n,n.next,s)&&Mi(i,s)&&Mi(s,i)&&(t.push(i.i/e|0),t.push(n.i/e|0),t.push(s.i/e|0),Ei(n),Ei(n.next),n=r=s),n=n.next}while(n!==r);return en(n)}function cp(r,t,e,n,i,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&gp(o,a)){let c=xu(o,a);o=en(o,o.next),c=en(c,c.next),Li(o,t,e,n,i,s,0),Li(c,t,e,n,i,s,0);return}a=a.next}o=o.next}while(o!==r)}function lp(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=vu(r,l,u,n,!1,i&&i[a+1],s),h===h.next&&(h.steiner=!0),o.push(yp(h));for(o.sort(up),a=0;a<o.length;a++)e=fp(o[a],e);return e}function up(r,t){return r.x-t.x}function fp(r,t){let e=hp(r,t);if(!e)return t;let n=xu(e,r);return en(n,n.next),en(e,e.next)}function hp(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&&Cn(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),Mi(e,r)&&(h<u||h===u&&(e.x>o.x||e.x===o.x&&dp(o,e)))&&(o=e,u=h)),e=e.next;while(e!==a);return o}function dp(r,t){return at(r.prev,r,t.prev)<0&&at(t.next,r,r.next)<0}function pp(r,t,e,n){let i=r;do i.z===0&&(i.z=Pa(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,mp(i)}function mp(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 Pa(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 yp(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 Cn(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 gp(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!bp(r,t)&&(Mi(r,t)&&Mi(t,r)&&_p(r,t)&&(at(r.prev,r,t.prev)||at(r,t.prev,t))||wo(r,t)&&at(r.prev,r,r.next)>0&&at(t.prev,t,t.next)>0)}function at(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function wo(r,t){return r.x===t.x&&r.y===t.y}function Iu(r,t,e,n){let i=_o(at(r,t,e)),s=_o(at(r,t,n)),o=_o(at(e,n,r)),a=_o(at(e,n,t));return!!(i!==s&&o!==a||i===0&&bo(r,e,t)||s===0&&bo(r,n,t)||o===0&&bo(e,r,n)||a===0&&bo(e,t,n))}function bo(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 _o(r){return r>0?1:r<0?-1:0}function bp(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&&Iu(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Mi(r,t){return at(r.prev,r,r.next)<0?at(r,t,r.next)>=0&&at(r,r.prev,t)>=0:at(r,t,r.prev)<0||at(r,r.next,t)<0}function _p(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 xu(r,t){let e=new Ui(r.i,r.x,r.y),n=new Ui(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 wu(r,t,e,n){let i=new Ui(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 Ei(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 Ui=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 Au(r,t,e){let n=Sp(r),i=Object.keys(n).filter(s=>n[s]!==Array);return Bp(r,{propArrayTypes:n,...t},{numericPropKeys:e&&e.numericPropKeys||i,PositionDataType:e?e.PositionDataType:Float32Array,triangulate:e?e.triangulate:!0})}function Sp(r){let t={};for(let e of r)if(e.properties)for(let n in e.properties){let i=e.properties[n];t[n]=Np(i,t[n])}return t}function Bp(r,t,e){let{pointPositionsCount:n,pointFeaturesCount:i,linePositionsCount:s,linePathsCount:o,lineFeaturesCount:a,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:u,polygonFeaturesCount:h,propArrayTypes:d,coordLength:p}=t,{numericPropKeys:y=[],PositionDataType:z=Float32Array,triangulate:it=!0}=e,Mt=r[0]&&"id"in r[0],cr=r.length>65535?Uint32Array:Uint16Array,W={type:"Point",positions:new z(n*p),globalFeatureIds:new cr(n),featureIds:i>65535?new Uint32Array(n):new Uint16Array(n),numericProps:{},properties:[],fields:[]},k={type:"LineString",pathIndices:s>65535?new Uint32Array(o+1):new Uint16Array(o+1),positions:new z(s*p),globalFeatureIds:new cr(s),featureIds:a>65535?new Uint32Array(s):new Uint16Array(s),numericProps:{},properties:[],fields:[]},lr={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(u+1):new Uint16Array(u+1),positions:new z(c*p),globalFeatureIds:new cr(c),featureIds:h>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};it&&(lr.triangles=[]);for(let ur of[W,k,lr])for(let Ir of y){let fr=d[Ir];ur.numericProps[Ir]=new fr(ur.positions.length/p)}k.pathIndices[o]=s,lr.polygonIndices[l]=c,lr.primitivePolygonIndices[u]=c;let vr={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let ur of r){let Ir=ur.geometry,fr=ur.properties||{};switch(Ir.type){case"Point":Ap(Ir,W,vr,p,fr),W.properties.push(ka(fr,y)),Mt&&W.fields.push({id:ur.id}),vr.pointFeature++;break;case"LineString":Op(Ir,k,vr,p,fr),k.properties.push(ka(fr,y)),Mt&&k.fields.push({id:ur.id}),vr.lineFeature++;break;case"Polygon":Dp(Ir,lr,vr,p,fr),lr.properties.push(ka(fr,y)),Mt&&lr.fields.push({id:ur.id}),vr.polygonFeature++;break;default:throw new Error("Invalid geometry type")}vr.feature++}return Fp(W,k,lr,p)}function Ap(r,t,e,n,i){t.positions.set(r.data,e.pointPosition*n);let s=r.data.length/n;za(t,i,e.pointPosition,s),t.globalFeatureIds.fill(e.feature,e.pointPosition,e.pointPosition+s),t.featureIds.fill(e.pointFeature,e.pointPosition,e.pointPosition+s),e.pointPosition+=s}function Op(r,t,e,n,i){t.positions.set(r.data,e.linePosition*n);let s=r.data.length/n;za(t,i,e.linePosition,s),t.globalFeatureIds.fill(e.feature,e.linePosition,e.linePosition+s),t.featureIds.fill(e.lineFeature,e.linePosition,e.linePosition+s);for(let o=0,a=r.indices.length;o<a;++o){let c=r.indices[o],l=o===a-1?r.data.length:r.indices[o+1];t.pathIndices[e.linePath++]=e.linePosition,e.linePosition+=(l-c)/n}}function Dp(r,t,e,n,i){t.positions.set(r.data,e.polygonPosition*n);let s=r.data.length/n;za(t,i,e.polygonPosition,s),t.globalFeatureIds.fill(e.feature,e.polygonPosition,e.polygonPosition+s),t.featureIds.fill(e.polygonFeature,e.polygonPosition,e.polygonPosition+s);for(let o=0,a=r.indices.length;o<a;++o){let c=e.polygonPosition;t.polygonIndices[e.polygonObject++]=c;let l=r.areas[o],u=r.indices[o],h=r.indices[o+1];for(let p=0,y=u.length;p<y;++p){let z=u[p],it=p===y-1?h===void 0?r.data.length:h[0]:u[p+1];t.primitivePolygonIndices[e.polygonRing++]=e.polygonPosition,e.polygonPosition+=(it-z)/n}let d=e.polygonPosition;Tp(t,l,u,{startPosition:c,endPosition:d,coordLength:n})}}function Tp(r,t,e,{startPosition:n,endPosition:i,coordLength:s}){if(!r.triangles)return;let o=n*s,a=i*s,c=r.positions.subarray(o,a),l=e[0],u=e.slice(1).map(d=>(d-l)/s),h=ja(c,u,s,t);for(let d=0,p=h.length;d<p;++d)r.triangles.push(n+h[d])}function Va(r,t){let e={};for(let n in r)e[n]={value:r[n],size:t};return e}function Fp(r,t,e,n){let i={shape:"binary-feature-collection",points:{...r,positions:{value:r.positions,size:n},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:Va(r.numericProps,1)},lines:{...t,positions:{value:t.positions,size:n},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:Va(t.numericProps,1)},polygons:{...e,positions:{value:e.positions,size:n},polygonIndices:{value:e.polygonIndices,size:1},primitivePolygonIndices:{value:e.primitivePolygonIndices,size:1},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:Va(e.numericProps,1)}};return i.polygons&&e.triangles&&(i.polygons.triangles={value:new Uint32Array(e.triangles),size:1}),i}function za(r,t,e,n){for(let i in r.numericProps)if(i in t){let s=t[i];r.numericProps[i].fill(s,e,e+n)}}function ka(r,t){let e={};for(let n in r)t.includes(n)||(e[n]=r[n]);return e}function Np(r,t){return t===Array||!Number.isFinite(r)?Array:t===Float64Array||Math.fround(r)!==r?Float64Array:Float32Array}function Tu(r,t={coordLength:2,fixRingWinding:!0}){return r.map(e=>Lp(e,t))}function Ou(r,t,e,n){e.push(t.length),t.push(...r);for(let i=r.length;i<n.coordLength;i++)t.push(0)}function Wa(r,t,e,n){e.push(t.length);for(let i of r){t.push(...i);for(let s=i.length;s<n.coordLength;s++)t.push(0)}}function Du(r,t,e,n,i){let s=0,o=[],a=[];for(let c of r){let l=c.map(d=>d.slice(0,2)),u=Un(l.flat()),h=u<0;i.fixRingWinding&&(s===0&&!h||s>0&&h)&&(c.reverse(),u=-u),o.push(u),Wa(c,t,a,i),s++}s>0&&(n.push(o),e.push(a))}function Lp(r,t){let{geometry:e}=r;if(e.type==="GeometryCollection")throw new Error("GeometryCollection type not supported");let n=[],i=[],s,o;switch(e.type){case"Point":o="Point",Ou(e.coordinates,n,i,t);break;case"MultiPoint":o="Point",e.coordinates.map(a=>Ou(a,n,i,t));break;case"LineString":o="LineString",Wa(e.coordinates,n,i,t);break;case"MultiLineString":o="LineString",e.coordinates.map(a=>Wa(a,n,i,t));break;case"Polygon":o="Polygon",s=[],Du(e.coordinates,n,i,s,t);break;case"MultiPolygon":o="Polygon",s=[],e.coordinates.map(a=>Du(a,n,i,s,t));break;default:throw new Error(`Unknown type: ${o}`)}return{...r,geometry:{type:o,indices:i,data:n,areas:s}}}function Ci(r,t={fixRingWinding:!0,triangulate:!0}){let e=_u(r),n=e.coordLength,{fixRingWinding:i}=t,s=Tu(r,{coordLength:n,fixRingWinding:i});return Au(s,e,{numericPropKeys:t.numericPropKeys,PositionDataType:t.PositionDataType||Float32Array,triangulate:t.triangulate})}var Mp="4.4.0",Ja={dataType:null,batchType:null,name:"GeoJSON",id:"geojson",module:"geojson",version:Mp,worker:!0,extensions:["geojson"],mimeTypes:["application/geo+json"],category:"geometry",text:!0,options:{geojson:{shape:"geojson-table"},json:{shape:"object-row-table",jsonpaths:["$","$.features"]},gis:{format:"geojson"}}},rn={...Ja,parse:Ep,parseTextSync:Fu,parseInBatches:Up};async function Ep(r,t){return Fu(new TextDecoder().decode(r),t)}function Fu(r,t){t={...rn.options,...t},t.geojson={...rn.options.geojson,...t.geojson},t.gis=t.gis||{};let e;try{e=JSON.parse(r)}catch{e={}}let n={shape:"geojson-table",type:"FeatureCollection",features:e?.features||[]};switch(t.gis.format){case"binary":return Ci(n.features);default:return n}}function Up(r,t){t={...rn.options,...t},t.json={...rn.options.json,...t.json},t.geojson={...rn.options.geojson,...t.geojson};let e=yo(r,t);switch(t.gis.format){case"binary":return Cp(e);default:return e}}async function*Cp(r){for await(let t of r)t.data=Ci(t.data),yield t}function Nu(r){let t=r.schema?.fields.findIndex(e=>e.name==="geometry")??-1;if(t>-1)return t;if(_r(r)>0){let e=fo(r,0);for(let n=0;n<lo(r);n++){let i=e?.[n];if(i&&typeof i=="object")return n}}throw new Error("Failed to detect geometry column")}function Lu(r,t,e=[]){let n={};for(let i=0;i<lo(r);++i){let s=r.schema?.fields[i].name;s&&!e.includes(i)&&(n[s]=t[s])}return n}function Mu(r,t,e,n){let i=uo(r,t);if(!i)return;let s=Rp(r,i,e),o=JSON.stringify(s);n.push(o)}function Rp(r,t,e){let n=Lu(r,t,[e]),i=r.schema?.fields[e].name,s=i&&t[i];if(!s)return{type:"Feature",geometry:null,properties:n};if(typeof s=="string")try{s=JSON.parse(s)}catch{throw new Error("Invalid string geometry")}if(typeof s!="object"||typeof s?.type!="string")throw new Error("invalid geometry column value");return s?.type==="Feature"?{...s,properties:n}:{type:"Feature",geometry:s,properties:n}}var vo=class{chunkSize;strings=[];totalLength=0;textEncoder=new TextEncoder;constructor(t){this.chunkSize=t}push(...t){for(let e of t)this.strings.push(e),this.totalLength+=e.length}isFull(){return this.totalLength>=this.chunkSize}getArrayBufferBatch(){return Ea(this.textEncoder.encode(this.getStringBatch()).buffer)}getStringBatch(){let t=this.strings.join("");return this.strings=[],this.totalLength=0,t}};async function*Ga(r,t={}){let e={geojson:{},chunkSize:1e4,...t},n=new vo(e.chunkSize);e.geojson.featureArray||n.push(`{
23
23
  `,`"type": "FeatureCollection",
24
24
  `,`"features":
25
- `),n.push("[");let i=e.geojson.geometryColumn,s=!0,o=0;for await(let a of r){let c=o+gr(a);i||(i=i||au(a));for(let u=o;u<c;++u)s||n.push(","),n.push(`
26
- `),s=!1,lu(a,u,i,n),n.isFull()&&(yield n.getArrayBufferBatch()),o=c;let l=n.getArrayBufferBatch();l.byteLength>0&&(yield l)}n.push(`
25
+ `),n.push("[");let i=e.geojson.geometryColumn,s=!0,o=0;for await(let a of r){let c=o+_r(a);i||(i=i||Nu(a));for(let u=o;u<c;++u)s||n.push(","),n.push(`
26
+ `),s=!1,Mu(a,u,i,n),n.isFull()&&(yield n.getArrayBufferBatch()),o=c;let l=n.getArrayBufferBatch();l.byteLength>0&&(yield l)}n.push(`
27
27
  `),n.push(`]
28
- `),e.geojson.featureArray||n.push("}"),yield n.getArrayBufferBatch()}var uu={id:"geojson",version:"latest",module:"geojson",name:"GeoJSON",extensions:["geojson"],mimeTypes:["application/geo+json"],text:!0,options:{geojson:{featureArray:!1,geometryColumn:null}},async encode(r,t){let n=Na([r],t);return await wa(n)},encodeInBatches:(r,t)=>Na(r,t)};return _u(Ui);})();
28
+ `),e.geojson.featureArray||n.push("}"),yield n.getArrayBufferBatch()}var Eu={id:"geojson",version:"latest",module:"geojson",name:"GeoJSON",extensions:["geojson"],mimeTypes:["application/geo+json"],text:!0,options:{geojson:{featureArray:!1,geometryColumn:null}},async encode(r,t){let n=Ga([r],t);return await La(n)},encodeInBatches:(r,t)=>Ga(r,t)};return Wu(Ri);})();
29
29
  return __exports__;
30
30
  });