@uwdata/mosaic-core 0.4.0 → 0.5.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.
@@ -4,6 +4,149 @@ var __export = (target, all2) => {
4
4
  __defProp(target, name, { get: all2[name], enumerable: true });
5
5
  };
6
6
 
7
+ // src/util/throttle.js
8
+ var NIL = {};
9
+ function throttle(callback, debounce = false) {
10
+ let curr;
11
+ let next;
12
+ let pending = NIL;
13
+ function invoke(event) {
14
+ curr = callback(event).then(() => {
15
+ if (next) {
16
+ const { value } = next;
17
+ next = null;
18
+ invoke(value);
19
+ } else {
20
+ curr = null;
21
+ }
22
+ });
23
+ }
24
+ function enqueue(event) {
25
+ next = { event };
26
+ }
27
+ function process(event) {
28
+ curr ? enqueue(event) : invoke(event);
29
+ }
30
+ function delay(event) {
31
+ if (pending !== event) {
32
+ requestAnimationFrame(() => {
33
+ const e = pending;
34
+ pending = NIL;
35
+ process(e);
36
+ });
37
+ }
38
+ pending = event;
39
+ }
40
+ return debounce ? delay : process;
41
+ }
42
+
43
+ // src/MosaicClient.js
44
+ var MosaicClient = class {
45
+ /**
46
+ * Constructor.
47
+ * @param {*} filterSelection An optional selection to interactively filter
48
+ * this client's data. If provided, a coordinator will re-query and update
49
+ * the client when the selection updates.
50
+ */
51
+ constructor(filterSelection) {
52
+ this._filterBy = filterSelection;
53
+ this._requestUpdate = throttle(() => this.requestQuery(), true);
54
+ this._coordinator = null;
55
+ }
56
+ /**
57
+ * Return this client's connected coordinator.
58
+ */
59
+ get coordinator() {
60
+ return this._coordinator;
61
+ }
62
+ /**
63
+ * Set this client's connected coordinator.
64
+ */
65
+ set coordinator(coordinator2) {
66
+ this._coordinator = coordinator2;
67
+ }
68
+ /**
69
+ * Return this client's filter selection.
70
+ */
71
+ get filterBy() {
72
+ return this._filterBy;
73
+ }
74
+ /**
75
+ * Return a boolean indicating if the client query can be indexed. Should
76
+ * return true if changes to the filterBy selection does not change the
77
+ * groupby domain of the client query.
78
+ */
79
+ get filterIndexable() {
80
+ return true;
81
+ }
82
+ /**
83
+ * Return an array of fields queried by this client.
84
+ */
85
+ fields() {
86
+ return null;
87
+ }
88
+ /**
89
+ * Called by the coordinator to set the field info for this client.
90
+ * @returns {this}
91
+ */
92
+ fieldInfo() {
93
+ return this;
94
+ }
95
+ /**
96
+ * Return a query specifying the data needed by this client.
97
+ */
98
+ query() {
99
+ return null;
100
+ }
101
+ /**
102
+ * Called by the coordinator to inform the client that a query is pending.
103
+ */
104
+ queryPending() {
105
+ return this;
106
+ }
107
+ /**
108
+ * Called by the coordinator to return a query result.
109
+ *
110
+ * @param {*} data the query result
111
+ * @returns {this}
112
+ */
113
+ queryResult() {
114
+ return this;
115
+ }
116
+ /**
117
+ * Called by the coordinator to report a query execution error.
118
+ */
119
+ queryError(error) {
120
+ console.error(error);
121
+ return this;
122
+ }
123
+ /**
124
+ * Request the coordinator to execute a query for this client.
125
+ * If an explicit query is not provided, the client query method will
126
+ * be called, filtered by the current filterBy selection.
127
+ */
128
+ requestQuery(query) {
129
+ const q2 = query || this.query(this.filterBy?.predicate(this));
130
+ return this._coordinator.requestQuery(this, q2);
131
+ }
132
+ /**
133
+ * Request that the coordinator perform a throttled update of this client
134
+ * using the default query. Unlike requestQuery, for which every call will
135
+ * result in an executed query, multiple calls to requestUpdate may be
136
+ * consolidated into a single update.
137
+ */
138
+ requestUpdate() {
139
+ this._requestUpdate();
140
+ }
141
+ /**
142
+ * Requests a client update.
143
+ * For example to (re-)render an interface component.
144
+ */
145
+ update() {
146
+ return this;
147
+ }
148
+ };
149
+
7
150
  // ../../node_modules/apache-arrow/node_modules/tslib/tslib.es6.mjs
8
151
  function __rest(s, e) {
9
152
  var t = {};
@@ -179,46 +322,46 @@ var encoder = new TextEncoder();
179
322
  var encodeUtf8 = (value) => encoder.encode(value);
180
323
 
181
324
  // ../../node_modules/apache-arrow/util/compat.mjs
182
- var isNumber = (x2) => typeof x2 === "number";
183
- var isBoolean = (x2) => typeof x2 === "boolean";
184
- var isFunction = (x2) => typeof x2 === "function";
185
- var isObject = (x2) => x2 != null && Object(x2) === x2;
186
- var isPromise = (x2) => {
187
- return isObject(x2) && isFunction(x2.then);
325
+ var isNumber = (x3) => typeof x3 === "number";
326
+ var isBoolean = (x3) => typeof x3 === "boolean";
327
+ var isFunction = (x3) => typeof x3 === "function";
328
+ var isObject = (x3) => x3 != null && Object(x3) === x3;
329
+ var isPromise = (x3) => {
330
+ return isObject(x3) && isFunction(x3.then);
188
331
  };
189
- var isIterable = (x2) => {
190
- return isObject(x2) && isFunction(x2[Symbol.iterator]);
332
+ var isIterable = (x3) => {
333
+ return isObject(x3) && isFunction(x3[Symbol.iterator]);
191
334
  };
192
- var isAsyncIterable = (x2) => {
193
- return isObject(x2) && isFunction(x2[Symbol.asyncIterator]);
335
+ var isAsyncIterable = (x3) => {
336
+ return isObject(x3) && isFunction(x3[Symbol.asyncIterator]);
194
337
  };
195
- var isArrowJSON = (x2) => {
196
- return isObject(x2) && isObject(x2["schema"]);
338
+ var isArrowJSON = (x3) => {
339
+ return isObject(x3) && isObject(x3["schema"]);
197
340
  };
198
- var isIteratorResult = (x2) => {
199
- return isObject(x2) && "done" in x2 && "value" in x2;
341
+ var isIteratorResult = (x3) => {
342
+ return isObject(x3) && "done" in x3 && "value" in x3;
200
343
  };
201
- var isFileHandle = (x2) => {
202
- return isObject(x2) && isFunction(x2["stat"]) && isNumber(x2["fd"]);
344
+ var isFileHandle = (x3) => {
345
+ return isObject(x3) && isFunction(x3["stat"]) && isNumber(x3["fd"]);
203
346
  };
204
- var isFetchResponse = (x2) => {
205
- return isObject(x2) && isReadableDOMStream(x2["body"]);
347
+ var isFetchResponse = (x3) => {
348
+ return isObject(x3) && isReadableDOMStream(x3["body"]);
206
349
  };
207
- var isReadableInterop = (x2) => "_getDOMStream" in x2 && "_getNodeStream" in x2;
208
- var isWritableDOMStream = (x2) => {
209
- return isObject(x2) && isFunction(x2["abort"]) && isFunction(x2["getWriter"]) && !isReadableInterop(x2);
350
+ var isReadableInterop = (x3) => "_getDOMStream" in x3 && "_getNodeStream" in x3;
351
+ var isWritableDOMStream = (x3) => {
352
+ return isObject(x3) && isFunction(x3["abort"]) && isFunction(x3["getWriter"]) && !isReadableInterop(x3);
210
353
  };
211
- var isReadableDOMStream = (x2) => {
212
- return isObject(x2) && isFunction(x2["cancel"]) && isFunction(x2["getReader"]) && !isReadableInterop(x2);
354
+ var isReadableDOMStream = (x3) => {
355
+ return isObject(x3) && isFunction(x3["cancel"]) && isFunction(x3["getReader"]) && !isReadableInterop(x3);
213
356
  };
214
- var isWritableNodeStream = (x2) => {
215
- return isObject(x2) && isFunction(x2["end"]) && isFunction(x2["write"]) && isBoolean(x2["writable"]) && !isReadableInterop(x2);
357
+ var isWritableNodeStream = (x3) => {
358
+ return isObject(x3) && isFunction(x3["end"]) && isFunction(x3["write"]) && isBoolean(x3["writable"]) && !isReadableInterop(x3);
216
359
  };
217
- var isReadableNodeStream = (x2) => {
218
- return isObject(x2) && isFunction(x2["read"]) && isFunction(x2["pipe"]) && isBoolean(x2["readable"]) && !isReadableInterop(x2);
360
+ var isReadableNodeStream = (x3) => {
361
+ return isObject(x3) && isFunction(x3["read"]) && isFunction(x3["pipe"]) && isBoolean(x3["readable"]) && !isReadableInterop(x3);
219
362
  };
220
- var isFlatbuffersByteBuffer = (x2) => {
221
- return isObject(x2) && isFunction(x2["clear"]) && isFunction(x2["bytes"]) && isFunction(x2["position"]) && isFunction(x2["setPosition"]) && isFunction(x2["capacity"]) && isFunction(x2["getBufferIdentifier"]) && isFunction(x2["createLong"]);
363
+ var isFlatbuffersByteBuffer = (x3) => {
364
+ return isObject(x3) && isFunction(x3["clear"]) && isFunction(x3["bytes"]) && isFunction(x3["position"]) && isFunction(x3["setPosition"]) && isFunction(x3["capacity"]) && isFunction(x3["getBufferIdentifier"]) && isFunction(x3["createLong"]);
222
365
  };
223
366
 
224
367
  // ../../node_modules/apache-arrow/util/buffer.mjs
@@ -226,20 +369,20 @@ var SharedArrayBuf = typeof SharedArrayBuffer !== "undefined" ? SharedArrayBuffe
226
369
  function collapseContiguousByteRanges(chunks) {
227
370
  const result = chunks[0] ? [chunks[0]] : [];
228
371
  let xOffset, yOffset, xLen, yLen;
229
- for (let x2, y2, i = 0, j2 = 0, n = chunks.length; ++i < n; ) {
230
- x2 = result[j2];
231
- y2 = chunks[i];
232
- if (!x2 || !y2 || x2.buffer !== y2.buffer || y2.byteOffset < x2.byteOffset) {
233
- y2 && (result[++j2] = y2);
372
+ for (let x3, y3, i = 0, j2 = 0, n = chunks.length; ++i < n; ) {
373
+ x3 = result[j2];
374
+ y3 = chunks[i];
375
+ if (!x3 || !y3 || x3.buffer !== y3.buffer || y3.byteOffset < x3.byteOffset) {
376
+ y3 && (result[++j2] = y3);
234
377
  continue;
235
378
  }
236
- ({ byteOffset: xOffset, byteLength: xLen } = x2);
237
- ({ byteOffset: yOffset, byteLength: yLen } = y2);
379
+ ({ byteOffset: xOffset, byteLength: xLen } = x3);
380
+ ({ byteOffset: yOffset, byteLength: yLen } = y3);
238
381
  if (xOffset + xLen < yOffset || yOffset + yLen < xOffset) {
239
- y2 && (result[++j2] = y2);
382
+ y3 && (result[++j2] = y3);
240
383
  continue;
241
384
  }
242
- result[j2] = new Uint8Array(x2.buffer, xOffset, yOffset - xOffset + yLen);
385
+ result[j2] = new Uint8Array(x3.buffer, xOffset, yOffset - xOffset + yLen);
243
386
  }
244
387
  return result;
245
388
  }
@@ -252,7 +395,7 @@ function memcpy(target, source, targetByteOffset = 0, sourceByteLength = source.
252
395
  }
253
396
  function joinUint8Arrays(chunks, size) {
254
397
  const result = collapseContiguousByteRanges(chunks);
255
- const byteLength = result.reduce((x2, b2) => x2 + b2.byteLength, 0);
398
+ const byteLength = result.reduce((x3, b2) => x3 + b2.byteLength, 0);
256
399
  let source, sliced, buffer;
257
400
  let offset = 0, index = -1;
258
401
  const length2 = Math.min(size || Number.POSITIVE_INFINITY, byteLength);
@@ -314,8 +457,8 @@ var pump = (iterator) => {
314
457
  return iterator;
315
458
  };
316
459
  function* toArrayBufferViewIterator(ArrayCtor, source) {
317
- const wrap = function* (x2) {
318
- yield x2;
460
+ const wrap = function* (x3) {
461
+ yield x3;
319
462
  };
320
463
  const buffers = typeof source === "string" ? wrap(source) : ArrayBuffer.isView(source) ? wrap(source) : source instanceof ArrayBuffer ? wrap(source) : source instanceof SharedArrayBuf ? wrap(source) : !isIterable(source) ? wrap(source) : source;
321
464
  yield* pump(function* (it) {
@@ -340,9 +483,9 @@ function toArrayBufferViewAsyncIterator(ArrayCtor, source) {
340
483
  if (isPromise(source)) {
341
484
  return yield __await(yield __await(yield* __asyncDelegator(__asyncValues(toArrayBufferViewAsyncIterator(ArrayCtor, yield __await(source))))));
342
485
  }
343
- const wrap = function(x2) {
486
+ const wrap = function(x3) {
344
487
  return __asyncGenerator(this, arguments, function* () {
345
- yield yield __await(yield __await(x2));
488
+ yield yield __await(yield __await(x3));
346
489
  });
347
490
  };
348
491
  const emit = function(source2) {
@@ -381,12 +524,12 @@ var toFloat64ArrayAsyncIterator = (input) => toArrayBufferViewAsyncIterator(Floa
381
524
  var toUint8ClampedArrayAsyncIterator = (input) => toArrayBufferViewAsyncIterator(Uint8ClampedArray, input);
382
525
  function rebaseValueOffsets(offset, length2, valueOffsets) {
383
526
  if (offset !== 0) {
384
- valueOffsets = valueOffsets.slice(0, length2 + 1);
385
- for (let i = -1; ++i <= length2; ) {
527
+ valueOffsets = valueOffsets.slice(0, length2);
528
+ for (let i = -1, n = valueOffsets.length; ++i < n; ) {
386
529
  valueOffsets[i] += offset;
387
530
  }
388
531
  }
389
- return valueOffsets;
532
+ return valueOffsets.subarray(0, length2);
390
533
  }
391
534
  function compareArrayLike(a2, b2) {
392
535
  let i = 0;
@@ -600,7 +743,7 @@ function fromNodeStream(stream) {
600
743
  events[1] = onEvent(stream, "error");
601
744
  do {
602
745
  events[2] = onEvent(stream, "readable");
603
- [event, err] = yield __await(Promise.race(events.map((x2) => x2[2])));
746
+ [event, err] = yield __await(Promise.race(events.map((x3) => x3[2])));
604
747
  if (event === "error") {
605
748
  break;
606
749
  }
@@ -715,6 +858,7 @@ var Type;
715
858
  Type3[Type3["FixedSizeBinary"] = 15] = "FixedSizeBinary";
716
859
  Type3[Type3["FixedSizeList"] = 16] = "FixedSizeList";
717
860
  Type3[Type3["Map"] = 17] = "Map";
861
+ Type3[Type3["Duration"] = 18] = "Duration";
718
862
  Type3[Type3["Dictionary"] = -1] = "Dictionary";
719
863
  Type3[Type3["Int8"] = -2] = "Int8";
720
864
  Type3[Type3["Int16"] = -3] = "Int16";
@@ -741,6 +885,10 @@ var Type;
741
885
  Type3[Type3["SparseUnion"] = -24] = "SparseUnion";
742
886
  Type3[Type3["IntervalDayTime"] = -25] = "IntervalDayTime";
743
887
  Type3[Type3["IntervalYearMonth"] = -26] = "IntervalYearMonth";
888
+ Type3[Type3["DurationSecond"] = -27] = "DurationSecond";
889
+ Type3[Type3["DurationMillisecond"] = -28] = "DurationMillisecond";
890
+ Type3[Type3["DurationMicrosecond"] = -29] = "DurationMicrosecond";
891
+ Type3[Type3["DurationNanosecond"] = -30] = "DurationNanosecond";
744
892
  })(Type || (Type = {}));
745
893
  var BufferType;
746
894
  (function(BufferType2) {
@@ -759,32 +907,36 @@ __export(vector_exports, {
759
907
  });
760
908
 
761
909
  // ../../node_modules/apache-arrow/util/pretty.mjs
910
+ var pretty_exports = {};
911
+ __export(pretty_exports, {
912
+ valueToString: () => valueToString
913
+ });
762
914
  var undf = void 0;
763
- function valueToString(x2) {
764
- if (x2 === null) {
915
+ function valueToString(x3) {
916
+ if (x3 === null) {
765
917
  return "null";
766
918
  }
767
- if (x2 === undf) {
919
+ if (x3 === undf) {
768
920
  return "undefined";
769
921
  }
770
- switch (typeof x2) {
922
+ switch (typeof x3) {
771
923
  case "number":
772
- return `${x2}`;
924
+ return `${x3}`;
773
925
  case "bigint":
774
- return `${x2}`;
926
+ return `${x3}`;
775
927
  case "string":
776
- return `"${x2}"`;
928
+ return `"${x3}"`;
777
929
  }
778
- if (typeof x2[Symbol.toPrimitive] === "function") {
779
- return x2[Symbol.toPrimitive]("string");
930
+ if (typeof x3[Symbol.toPrimitive] === "function") {
931
+ return x3[Symbol.toPrimitive]("string");
780
932
  }
781
- if (ArrayBuffer.isView(x2)) {
782
- if (x2 instanceof BigInt64Array || x2 instanceof BigUint64Array) {
783
- return `[${[...x2].map((x3) => valueToString(x3))}]`;
933
+ if (ArrayBuffer.isView(x3)) {
934
+ if (x3 instanceof BigInt64Array || x3 instanceof BigUint64Array) {
935
+ return `[${[...x3].map((x4) => valueToString(x4))}]`;
784
936
  }
785
- return `[${x2}]`;
937
+ return `[${x3}]`;
786
938
  }
787
- return ArrayBuffer.isView(x2) ? `[${x2}]` : JSON.stringify(x2, (_2, y2) => typeof y2 === "bigint" ? `${y2}` : y2);
939
+ return ArrayBuffer.isView(x3) ? `[${x3}]` : JSON.stringify(x3, (_2, y3) => typeof y3 === "bigint" ? `${y3}` : y3);
788
940
  }
789
941
 
790
942
  // ../../node_modules/apache-arrow/util/bn.mjs
@@ -796,11 +948,11 @@ __export(bn_exports, {
796
948
  isArrowBigNumSymbol: () => isArrowBigNumSymbol
797
949
  });
798
950
  var isArrowBigNumSymbol = Symbol.for("isArrowBigNum");
799
- function BigNum(x2, ...xs) {
951
+ function BigNum(x3, ...xs) {
800
952
  if (xs.length === 0) {
801
- return Object.setPrototypeOf(toArrayBufferView(this["TypedArray"], x2), this.constructor.prototype);
953
+ return Object.setPrototypeOf(toArrayBufferView(this["TypedArray"], x3), this.constructor.prototype);
802
954
  }
803
- return Object.setPrototypeOf(new this["TypedArray"](x2, ...xs), this.constructor.prototype);
955
+ return Object.setPrototypeOf(new this["TypedArray"](x3, ...xs), this.constructor.prototype);
804
956
  }
805
957
  BigNum.prototype[isArrowBigNumSymbol] = true;
806
958
  BigNum.prototype.toJSON = function() {
@@ -972,86 +1124,91 @@ var _r;
972
1124
  var _s;
973
1125
  var _t;
974
1126
  var _u;
1127
+ var _v;
975
1128
  var DataType = class _DataType {
976
1129
  /** @nocollapse */
977
- static isNull(x2) {
978
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Null;
1130
+ static isNull(x3) {
1131
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Null;
1132
+ }
1133
+ /** @nocollapse */
1134
+ static isInt(x3) {
1135
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Int;
979
1136
  }
980
1137
  /** @nocollapse */
981
- static isInt(x2) {
982
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Int;
1138
+ static isFloat(x3) {
1139
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Float;
983
1140
  }
984
1141
  /** @nocollapse */
985
- static isFloat(x2) {
986
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Float;
1142
+ static isBinary(x3) {
1143
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Binary;
987
1144
  }
988
1145
  /** @nocollapse */
989
- static isBinary(x2) {
990
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Binary;
1146
+ static isUtf8(x3) {
1147
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Utf8;
991
1148
  }
992
1149
  /** @nocollapse */
993
- static isUtf8(x2) {
994
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Utf8;
1150
+ static isBool(x3) {
1151
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Bool;
995
1152
  }
996
1153
  /** @nocollapse */
997
- static isBool(x2) {
998
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Bool;
1154
+ static isDecimal(x3) {
1155
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Decimal;
999
1156
  }
1000
1157
  /** @nocollapse */
1001
- static isDecimal(x2) {
1002
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Decimal;
1158
+ static isDate(x3) {
1159
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Date;
1003
1160
  }
1004
1161
  /** @nocollapse */
1005
- static isDate(x2) {
1006
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Date;
1162
+ static isTime(x3) {
1163
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Time;
1007
1164
  }
1008
1165
  /** @nocollapse */
1009
- static isTime(x2) {
1010
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Time;
1166
+ static isTimestamp(x3) {
1167
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Timestamp;
1011
1168
  }
1012
1169
  /** @nocollapse */
1013
- static isTimestamp(x2) {
1014
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Timestamp;
1170
+ static isInterval(x3) {
1171
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Interval;
1015
1172
  }
1016
1173
  /** @nocollapse */
1017
- static isInterval(x2) {
1018
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Interval;
1174
+ static isDuration(x3) {
1175
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Duration;
1019
1176
  }
1020
1177
  /** @nocollapse */
1021
- static isList(x2) {
1022
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.List;
1178
+ static isList(x3) {
1179
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.List;
1023
1180
  }
1024
1181
  /** @nocollapse */
1025
- static isStruct(x2) {
1026
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Struct;
1182
+ static isStruct(x3) {
1183
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Struct;
1027
1184
  }
1028
1185
  /** @nocollapse */
1029
- static isUnion(x2) {
1030
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Union;
1186
+ static isUnion(x3) {
1187
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Union;
1031
1188
  }
1032
1189
  /** @nocollapse */
1033
- static isFixedSizeBinary(x2) {
1034
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.FixedSizeBinary;
1190
+ static isFixedSizeBinary(x3) {
1191
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.FixedSizeBinary;
1035
1192
  }
1036
1193
  /** @nocollapse */
1037
- static isFixedSizeList(x2) {
1038
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.FixedSizeList;
1194
+ static isFixedSizeList(x3) {
1195
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.FixedSizeList;
1039
1196
  }
1040
1197
  /** @nocollapse */
1041
- static isMap(x2) {
1042
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Map;
1198
+ static isMap(x3) {
1199
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Map;
1043
1200
  }
1044
1201
  /** @nocollapse */
1045
- static isDictionary(x2) {
1046
- return (x2 === null || x2 === void 0 ? void 0 : x2.typeId) === Type.Dictionary;
1202
+ static isDictionary(x3) {
1203
+ return (x3 === null || x3 === void 0 ? void 0 : x3.typeId) === Type.Dictionary;
1047
1204
  }
1048
1205
  /** @nocollapse */
1049
- static isDenseUnion(x2) {
1050
- return _DataType.isUnion(x2) && x2.mode === UnionMode.Dense;
1206
+ static isDenseUnion(x3) {
1207
+ return _DataType.isUnion(x3) && x3.mode === UnionMode.Dense;
1051
1208
  }
1052
1209
  /** @nocollapse */
1053
- static isSparseUnion(x2) {
1054
- return _DataType.isUnion(x2) && x2.mode === UnionMode.Sparse;
1210
+ static isSparseUnion(x3) {
1211
+ return _DataType.isUnion(x3) && x3.mode === UnionMode.Sparse;
1055
1212
  }
1056
1213
  get typeId() {
1057
1214
  return Type.NONE;
@@ -1376,6 +1533,24 @@ Interval_[_m] = ((proto) => {
1376
1533
  proto.ArrayType = Int32Array;
1377
1534
  return proto[Symbol.toStringTag] = "Interval";
1378
1535
  })(Interval_.prototype);
1536
+ var Duration = class extends DataType {
1537
+ constructor(unit) {
1538
+ super();
1539
+ this.unit = unit;
1540
+ }
1541
+ get typeId() {
1542
+ return Type.Duration;
1543
+ }
1544
+ toString() {
1545
+ return `Duration<${TimeUnit[this.unit]}>`;
1546
+ }
1547
+ };
1548
+ _o = Symbol.toStringTag;
1549
+ Duration[_o] = ((proto) => {
1550
+ proto.unit = null;
1551
+ proto.ArrayType = BigInt64Array;
1552
+ return proto[Symbol.toStringTag] = "Duration";
1553
+ })(Duration.prototype);
1379
1554
  var List = class extends DataType {
1380
1555
  constructor(child) {
1381
1556
  super();
@@ -1397,8 +1572,8 @@ var List = class extends DataType {
1397
1572
  return this.valueType.ArrayType;
1398
1573
  }
1399
1574
  };
1400
- _o = Symbol.toStringTag;
1401
- List[_o] = ((proto) => {
1575
+ _p = Symbol.toStringTag;
1576
+ List[_p] = ((proto) => {
1402
1577
  proto.children = null;
1403
1578
  return proto[Symbol.toStringTag] = "List";
1404
1579
  })(List.prototype);
@@ -1414,8 +1589,8 @@ var Struct = class extends DataType {
1414
1589
  return `Struct<{${this.children.map((f2) => `${f2.name}:${f2.type}`).join(`, `)}}>`;
1415
1590
  }
1416
1591
  };
1417
- _p = Symbol.toStringTag;
1418
- Struct[_p] = ((proto) => {
1592
+ _q = Symbol.toStringTag;
1593
+ Struct[_q] = ((proto) => {
1419
1594
  proto.children = null;
1420
1595
  return proto[Symbol.toStringTag] = "Struct";
1421
1596
  })(Struct.prototype);
@@ -1431,11 +1606,11 @@ var Union_ = class extends DataType {
1431
1606
  return Type.Union;
1432
1607
  }
1433
1608
  toString() {
1434
- return `${this[Symbol.toStringTag]}<${this.children.map((x2) => `${x2.type}`).join(` | `)}>`;
1609
+ return `${this[Symbol.toStringTag]}<${this.children.map((x3) => `${x3.type}`).join(` | `)}>`;
1435
1610
  }
1436
1611
  };
1437
- _q = Symbol.toStringTag;
1438
- Union_[_q] = ((proto) => {
1612
+ _r = Symbol.toStringTag;
1613
+ Union_[_r] = ((proto) => {
1439
1614
  proto.mode = null;
1440
1615
  proto.typeIds = null;
1441
1616
  proto.children = null;
@@ -1455,8 +1630,8 @@ var FixedSizeBinary = class extends DataType {
1455
1630
  return `FixedSizeBinary[${this.byteWidth}]`;
1456
1631
  }
1457
1632
  };
1458
- _r = Symbol.toStringTag;
1459
- FixedSizeBinary[_r] = ((proto) => {
1633
+ _s = Symbol.toStringTag;
1634
+ FixedSizeBinary[_s] = ((proto) => {
1460
1635
  proto.byteWidth = null;
1461
1636
  proto.ArrayType = Uint8Array;
1462
1637
  return proto[Symbol.toStringTag] = "FixedSizeBinary";
@@ -1483,17 +1658,31 @@ var FixedSizeList = class extends DataType {
1483
1658
  return `FixedSizeList[${this.listSize}]<${this.valueType}>`;
1484
1659
  }
1485
1660
  };
1486
- _s = Symbol.toStringTag;
1487
- FixedSizeList[_s] = ((proto) => {
1661
+ _t = Symbol.toStringTag;
1662
+ FixedSizeList[_t] = ((proto) => {
1488
1663
  proto.children = null;
1489
1664
  proto.listSize = null;
1490
1665
  return proto[Symbol.toStringTag] = "FixedSizeList";
1491
1666
  })(FixedSizeList.prototype);
1492
1667
  var Map_ = class extends DataType {
1493
- constructor(child, keysSorted = false) {
1668
+ constructor(entries, keysSorted = false) {
1669
+ var _w, _x, _y;
1494
1670
  super();
1495
- this.children = [child];
1671
+ this.children = [entries];
1496
1672
  this.keysSorted = keysSorted;
1673
+ if (entries) {
1674
+ entries["name"] = "entries";
1675
+ if ((_w = entries === null || entries === void 0 ? void 0 : entries.type) === null || _w === void 0 ? void 0 : _w.children) {
1676
+ const key = (_x = entries === null || entries === void 0 ? void 0 : entries.type) === null || _x === void 0 ? void 0 : _x.children[0];
1677
+ if (key) {
1678
+ key["name"] = "key";
1679
+ }
1680
+ const val = (_y = entries === null || entries === void 0 ? void 0 : entries.type) === null || _y === void 0 ? void 0 : _y.children[1];
1681
+ if (val) {
1682
+ val["name"] = "value";
1683
+ }
1684
+ }
1685
+ }
1497
1686
  }
1498
1687
  get typeId() {
1499
1688
  return Type.Map;
@@ -1511,8 +1700,8 @@ var Map_ = class extends DataType {
1511
1700
  return `Map<{${this.children[0].type.children.map((f2) => `${f2.name}:${f2.type}`).join(`, `)}}>`;
1512
1701
  }
1513
1702
  };
1514
- _t = Symbol.toStringTag;
1515
- Map_[_t] = ((proto) => {
1703
+ _u = Symbol.toStringTag;
1704
+ Map_[_u] = ((proto) => {
1516
1705
  proto.children = null;
1517
1706
  proto.keysSorted = null;
1518
1707
  return proto[Symbol.toStringTag] = "Map_";
@@ -1542,8 +1731,8 @@ var Dictionary = class extends DataType {
1542
1731
  return `Dictionary<${this.indices}, ${this.dictionary}>`;
1543
1732
  }
1544
1733
  };
1545
- _u = Symbol.toStringTag;
1546
- Dictionary[_u] = ((proto) => {
1734
+ _v = Symbol.toStringTag;
1735
+ Dictionary[_v] = ((proto) => {
1547
1736
  proto.id = null;
1548
1737
  proto.indices = null;
1549
1738
  proto.isOrdered = null;
@@ -1573,7 +1762,7 @@ function strideForType(type) {
1573
1762
  // ../../node_modules/apache-arrow/visitor.mjs
1574
1763
  var Visitor = class {
1575
1764
  visitMany(nodes, ...args) {
1576
- return nodes.map((node, i) => this.visit(node, ...args.map((x2) => x2[i])));
1765
+ return nodes.map((node, i) => this.visit(node, ...args.map((x3) => x3[i])));
1577
1766
  }
1578
1767
  visit(...args) {
1579
1768
  return this.getVisitFn(args[0], false).apply(this, args);
@@ -1632,6 +1821,9 @@ var Visitor = class {
1632
1821
  visitInterval(_node, ..._args) {
1633
1822
  return null;
1634
1823
  }
1824
+ visitDuration(_node, ..._args) {
1825
+ return null;
1826
+ }
1635
1827
  visitFixedSizeList(_node, ..._args) {
1636
1828
  return null;
1637
1829
  }
@@ -1780,6 +1972,21 @@ function getVisitFnByTypeId(visitor, dtype, throwIfNotFound = true) {
1780
1972
  case Type.IntervalYearMonth:
1781
1973
  fn = visitor.visitIntervalYearMonth || visitor.visitInterval;
1782
1974
  break;
1975
+ case Type.Duration:
1976
+ fn = visitor.visitDuration;
1977
+ break;
1978
+ case Type.DurationSecond:
1979
+ fn = visitor.visitDurationSecond || visitor.visitDuration;
1980
+ break;
1981
+ case Type.DurationMillisecond:
1982
+ fn = visitor.visitDurationMillisecond || visitor.visitDuration;
1983
+ break;
1984
+ case Type.DurationMicrosecond:
1985
+ fn = visitor.visitDurationMicrosecond || visitor.visitDuration;
1986
+ break;
1987
+ case Type.DurationNanosecond:
1988
+ fn = visitor.visitDurationNanosecond || visitor.visitDuration;
1989
+ break;
1783
1990
  case Type.FixedSizeList:
1784
1991
  fn = visitor.visitFixedSizeList;
1785
1992
  break;
@@ -1869,6 +2076,18 @@ function inferDType(type) {
1869
2076
  return Type.IntervalYearMonth;
1870
2077
  }
1871
2078
  return Type.Interval;
2079
+ case Type.Duration:
2080
+ switch (type.unit) {
2081
+ case TimeUnit.SECOND:
2082
+ return Type.DurationSecond;
2083
+ case TimeUnit.MILLISECOND:
2084
+ return Type.DurationMillisecond;
2085
+ case TimeUnit.MICROSECOND:
2086
+ return Type.DurationMicrosecond;
2087
+ case TimeUnit.NANOSECOND:
2088
+ return Type.DurationNanosecond;
2089
+ }
2090
+ return Type.Duration;
1872
2091
  case Type.Map:
1873
2092
  return Type.Map;
1874
2093
  case Type.List:
@@ -1917,6 +2136,11 @@ Visitor.prototype.visitDenseUnion = null;
1917
2136
  Visitor.prototype.visitSparseUnion = null;
1918
2137
  Visitor.prototype.visitIntervalDayTime = null;
1919
2138
  Visitor.prototype.visitIntervalYearMonth = null;
2139
+ Visitor.prototype.visitDuration = null;
2140
+ Visitor.prototype.visitDurationSecond = null;
2141
+ Visitor.prototype.visitDurationMillisecond = null;
2142
+ Visitor.prototype.visitDurationMicrosecond = null;
2143
+ Visitor.prototype.visitDurationNanosecond = null;
1920
2144
 
1921
2145
  // ../../node_modules/apache-arrow/util/math.mjs
1922
2146
  var math_exports = {};
@@ -1990,8 +2214,8 @@ var setEpochMsToNanosecondsLong = (data, index, epochMs) => {
1990
2214
  };
1991
2215
  var setVariableWidthBytes = (values, valueOffsets, index, value) => {
1992
2216
  if (index + 1 < valueOffsets.length) {
1993
- const { [index]: x2, [index + 1]: y2 } = valueOffsets;
1994
- values.set(value.subarray(0, y2 - x2), x2);
2217
+ const { [index]: x3, [index + 1]: y3 } = valueOffsets;
2218
+ values.set(value.subarray(0, y3 - x3), x3);
1995
2219
  }
1996
2220
  };
1997
2221
  var setBool = ({ offset, values }, index, val) => {
@@ -2136,6 +2360,30 @@ var setIntervalDayTime = ({ values }, index, value) => {
2136
2360
  var setIntervalYearMonth = ({ values }, index, value) => {
2137
2361
  values[index] = value[0] * 12 + value[1] % 12;
2138
2362
  };
2363
+ var setDurationSecond = ({ values }, index, value) => {
2364
+ values[index] = value;
2365
+ };
2366
+ var setDurationMillisecond = ({ values }, index, value) => {
2367
+ values[index] = value;
2368
+ };
2369
+ var setDurationMicrosecond = ({ values }, index, value) => {
2370
+ values[index] = value;
2371
+ };
2372
+ var setDurationNanosecond = ({ values }, index, value) => {
2373
+ values[index] = value;
2374
+ };
2375
+ var setDuration = (data, index, value) => {
2376
+ switch (data.type.unit) {
2377
+ case TimeUnit.SECOND:
2378
+ return setDurationSecond(data, index, value);
2379
+ case TimeUnit.MILLISECOND:
2380
+ return setDurationMillisecond(data, index, value);
2381
+ case TimeUnit.MICROSECOND:
2382
+ return setDurationMicrosecond(data, index, value);
2383
+ case TimeUnit.NANOSECOND:
2384
+ return setDurationNanosecond(data, index, value);
2385
+ }
2386
+ };
2139
2387
  var setFixedSizeList = (data, index, value) => {
2140
2388
  const { stride } = data;
2141
2389
  const child = data.children[0];
@@ -2190,6 +2438,11 @@ SetVisitor.prototype.visitDictionary = wrapSet(setDictionary);
2190
2438
  SetVisitor.prototype.visitInterval = wrapSet(setIntervalValue);
2191
2439
  SetVisitor.prototype.visitIntervalDayTime = wrapSet(setIntervalDayTime);
2192
2440
  SetVisitor.prototype.visitIntervalYearMonth = wrapSet(setIntervalYearMonth);
2441
+ SetVisitor.prototype.visitDuration = wrapSet(setDuration);
2442
+ SetVisitor.prototype.visitDurationSecond = wrapSet(setDurationSecond);
2443
+ SetVisitor.prototype.visitDurationMillisecond = wrapSet(setDurationMillisecond);
2444
+ SetVisitor.prototype.visitDurationMicrosecond = wrapSet(setDurationMicrosecond);
2445
+ SetVisitor.prototype.visitDurationNanosecond = wrapSet(setDurationNanosecond);
2193
2446
  SetVisitor.prototype.visitFixedSizeList = wrapSet(setFixedSizeList);
2194
2447
  SetVisitor.prototype.visitMap = wrapSet(setMap);
2195
2448
  var instance = new SetVisitor();
@@ -2320,9 +2573,9 @@ var getVariableWidthBytes = (values, valueOffsets, index) => {
2320
2573
  if (index + 1 >= valueOffsets.length) {
2321
2574
  return null;
2322
2575
  }
2323
- const x2 = valueOffsets[index];
2324
- const y2 = valueOffsets[index + 1];
2325
- return values.subarray(x2, y2);
2576
+ const x3 = valueOffsets[index];
2577
+ const y3 = valueOffsets[index + 1];
2578
+ return values.subarray(x3, y3);
2326
2579
  };
2327
2580
  var getBool = ({ offset, values }, index) => {
2328
2581
  const idx = offset + index;
@@ -2418,6 +2671,22 @@ var getIntervalYearMonth = ({ values }, index) => {
2418
2671
  int32s[1] = Math.trunc(interval % 12);
2419
2672
  return int32s;
2420
2673
  };
2674
+ var getDurationSecond = ({ values }, index) => values[index];
2675
+ var getDurationMillisecond = ({ values }, index) => values[index];
2676
+ var getDurationMicrosecond = ({ values }, index) => values[index];
2677
+ var getDurationNanosecond = ({ values }, index) => values[index];
2678
+ var getDuration = (data, index) => {
2679
+ switch (data.type.unit) {
2680
+ case TimeUnit.SECOND:
2681
+ return getDurationSecond(data, index);
2682
+ case TimeUnit.MILLISECOND:
2683
+ return getDurationMillisecond(data, index);
2684
+ case TimeUnit.MICROSECOND:
2685
+ return getDurationMicrosecond(data, index);
2686
+ case TimeUnit.NANOSECOND:
2687
+ return getDurationNanosecond(data, index);
2688
+ }
2689
+ };
2421
2690
  var getFixedSizeList = (data, index) => {
2422
2691
  const { stride, children } = data;
2423
2692
  const child = children[0];
@@ -2465,6 +2734,11 @@ GetVisitor.prototype.visitDictionary = wrapGet(getDictionary);
2465
2734
  GetVisitor.prototype.visitInterval = wrapGet(getInterval);
2466
2735
  GetVisitor.prototype.visitIntervalDayTime = wrapGet(getIntervalDayTime);
2467
2736
  GetVisitor.prototype.visitIntervalYearMonth = wrapGet(getIntervalYearMonth);
2737
+ GetVisitor.prototype.visitDuration = wrapGet(getDuration);
2738
+ GetVisitor.prototype.visitDurationSecond = wrapGet(getDurationSecond);
2739
+ GetVisitor.prototype.visitDurationMillisecond = wrapGet(getDurationMillisecond);
2740
+ GetVisitor.prototype.visitDurationMicrosecond = wrapGet(getDurationMicrosecond);
2741
+ GetVisitor.prototype.visitDurationNanosecond = wrapGet(getDurationNanosecond);
2468
2742
  GetVisitor.prototype.visitFixedSizeList = wrapGet(getFixedSizeList);
2469
2743
  GetVisitor.prototype.visitMap = wrapGet(getMap);
2470
2744
  var instance2 = new GetVisitor();
@@ -2856,6 +3130,18 @@ var Data = class _Data {
2856
3130
  get buffers() {
2857
3131
  return [this.valueOffsets, this.values, this.nullBitmap, this.typeIds];
2858
3132
  }
3133
+ get nullable() {
3134
+ if (this._nullCount !== 0) {
3135
+ const { type } = this;
3136
+ if (DataType.isSparseUnion(type)) {
3137
+ return this.children.some((child) => child.nullable);
3138
+ } else if (DataType.isDenseUnion(type)) {
3139
+ return this.children.some((child) => child.nullable);
3140
+ }
3141
+ return this.nullBitmap && this.nullBitmap.byteLength > 0;
3142
+ }
3143
+ return true;
3144
+ }
2859
3145
  get byteLength() {
2860
3146
  let byteLength = 0;
2861
3147
  const { valueOffsets, values, nullBitmap, typeIds } = this;
@@ -2866,6 +3152,9 @@ var Data = class _Data {
2866
3152
  return this.children.reduce((byteLength2, child) => byteLength2 + child.byteLength, byteLength);
2867
3153
  }
2868
3154
  get nullCount() {
3155
+ if (DataType.isUnion(this.type)) {
3156
+ return this.children.reduce((nullCount2, child) => nullCount2 + child.nullCount, 0);
3157
+ }
2869
3158
  let nullCount = this._nullCount;
2870
3159
  let nullBitmap;
2871
3160
  if (nullCount <= kUnknownNullCount && (nullBitmap = this.nullBitmap)) {
@@ -2896,9 +3185,15 @@ var Data = class _Data {
2896
3185
  (buffer = buffers[3]) && (this.typeIds = buffer);
2897
3186
  }
2898
3187
  }
2899
- this.nullable = this._nullCount !== 0 && this.nullBitmap && this.nullBitmap.byteLength > 0;
2900
3188
  }
2901
3189
  getValid(index) {
3190
+ const { type } = this;
3191
+ if (DataType.isUnion(type)) {
3192
+ const union = type;
3193
+ const child = this.children[union.typeIdToChildIndex[this.typeIds[index]]];
3194
+ const indexInChild = union.mode === UnionMode.Dense ? this.valueOffsets[index] : index;
3195
+ return child.getValid(indexInChild);
3196
+ }
2902
3197
  if (this.nullable && this.nullCount > 0) {
2903
3198
  const pos = this.offset + index;
2904
3199
  const val = this.nullBitmap[pos >> 3];
@@ -2907,18 +3202,34 @@ var Data = class _Data {
2907
3202
  return true;
2908
3203
  }
2909
3204
  setValid(index, value) {
2910
- if (!this.nullable) {
2911
- return value;
3205
+ let prev;
3206
+ const { type } = this;
3207
+ if (DataType.isUnion(type)) {
3208
+ const union = type;
3209
+ const child = this.children[union.typeIdToChildIndex[this.typeIds[index]]];
3210
+ const indexInChild = union.mode === UnionMode.Dense ? this.valueOffsets[index] : index;
3211
+ prev = child.getValid(indexInChild);
3212
+ child.setValid(indexInChild, value);
3213
+ } else {
3214
+ let { nullBitmap } = this;
3215
+ const { offset, length: length2 } = this;
3216
+ const idx = offset + index;
3217
+ const mask = 1 << idx % 8;
3218
+ const byteOffset = idx >> 3;
3219
+ if (!nullBitmap || nullBitmap.byteLength <= byteOffset) {
3220
+ nullBitmap = new Uint8Array((offset + length2 + 63 & ~63) >> 3).fill(255);
3221
+ if (this.nullCount > 0) {
3222
+ nullBitmap.set(truncateBitmap(offset, length2, this.nullBitmap), 0);
3223
+ }
3224
+ Object.assign(this, { nullBitmap, _nullCount: -1 });
3225
+ }
3226
+ const byte = nullBitmap[byteOffset];
3227
+ prev = (byte & mask) !== 0;
3228
+ value ? nullBitmap[byteOffset] = byte | mask : nullBitmap[byteOffset] = byte & ~mask;
2912
3229
  }
2913
- if (!this.nullBitmap || this.nullBitmap.byteLength <= index >> 3) {
2914
- const { nullBitmap: nullBitmap2 } = this._changeLengthAndBackfillNullBitmap(this.length);
2915
- Object.assign(this, { nullBitmap: nullBitmap2, _nullCount: 0 });
3230
+ if (prev !== !!value) {
3231
+ this._nullCount = this.nullCount + (value ? -1 : 1);
2916
3232
  }
2917
- const { nullBitmap, offset } = this;
2918
- const pos = offset + index >> 3;
2919
- const bit = (offset + index) % 8;
2920
- const val = nullBitmap[pos] >> bit & 1;
2921
- value ? val === 0 && (nullBitmap[pos] |= 1 << bit, this._nullCount = this.nullCount + 1) : val === 1 && (nullBitmap[pos] &= ~(1 << bit), this._nullCount = this.nullCount - 1);
2922
3233
  return value;
2923
3234
  }
2924
3235
  clone(type = this.type, offset = this.offset, length2 = this.length, nullCount = this._nullCount, buffers = this, children = this.children) {
@@ -2972,7 +3283,7 @@ var MakeDataVisitor = class _MakeDataVisitor extends Visitor {
2972
3283
  }
2973
3284
  visitNull(props) {
2974
3285
  const { ["type"]: type, ["offset"]: offset = 0, ["length"]: length2 = 0 } = props;
2975
- return new Data(type, offset, length2, 0);
3286
+ return new Data(type, offset, length2, length2);
2976
3287
  }
2977
3288
  visitBool(props) {
2978
3289
  const { ["type"]: type, ["offset"]: offset = 0 } = props;
@@ -3061,14 +3372,13 @@ var MakeDataVisitor = class _MakeDataVisitor extends Visitor {
3061
3372
  }
3062
3373
  visitUnion(props) {
3063
3374
  const { ["type"]: type, ["offset"]: offset = 0, ["children"]: children = [] } = props;
3064
- const nullBitmap = toUint8Array(props["nullBitmap"]);
3065
3375
  const typeIds = toArrayBufferView(type.ArrayType, props["typeIds"]);
3066
- const { ["length"]: length2 = typeIds.length, ["nullCount"]: nullCount = props["nullBitmap"] ? -1 : 0 } = props;
3376
+ const { ["length"]: length2 = typeIds.length, ["nullCount"]: nullCount = -1 } = props;
3067
3377
  if (DataType.isSparseUnion(type)) {
3068
- return new Data(type, offset, length2, nullCount, [void 0, void 0, nullBitmap, typeIds], children);
3378
+ return new Data(type, offset, length2, nullCount, [void 0, void 0, void 0, typeIds], children);
3069
3379
  }
3070
3380
  const valueOffsets = toInt32Array(props["valueOffsets"]);
3071
- return new Data(type, offset, length2, nullCount, [valueOffsets, void 0, nullBitmap, typeIds], children);
3381
+ return new Data(type, offset, length2, nullCount, [valueOffsets, void 0, void 0, typeIds], children);
3072
3382
  }
3073
3383
  visitDictionary(props) {
3074
3384
  const { ["type"]: type, ["offset"]: offset = 0 } = props;
@@ -3085,6 +3395,13 @@ var MakeDataVisitor = class _MakeDataVisitor extends Visitor {
3085
3395
  const { ["length"]: length2 = data.length / strideForType(type), ["nullCount"]: nullCount = props["nullBitmap"] ? -1 : 0 } = props;
3086
3396
  return new Data(type, offset, length2, nullCount, [void 0, data, nullBitmap]);
3087
3397
  }
3398
+ visitDuration(props) {
3399
+ const { ["type"]: type, ["offset"]: offset = 0 } = props;
3400
+ const nullBitmap = toUint8Array(props["nullBitmap"]);
3401
+ const data = toArrayBufferView(type.ArrayType, props["data"]);
3402
+ const { ["length"]: length2 = data.length, ["nullCount"]: nullCount = props["nullBitmap"] ? -1 : 0 } = props;
3403
+ return new Data(type, offset, length2, nullCount, [void 0, data, nullBitmap]);
3404
+ }
3088
3405
  visitFixedSizeList(props) {
3089
3406
  const { ["type"]: type, ["offset"]: offset = 0, ["child"]: child = new _MakeDataVisitor().visit({ type: type.valueType }) } = props;
3090
3407
  const nullBitmap = toUint8Array(props["nullBitmap"]);
@@ -3099,8 +3416,9 @@ var MakeDataVisitor = class _MakeDataVisitor extends Visitor {
3099
3416
  return new Data(type, offset, length2, nullCount, [valueOffsets, void 0, nullBitmap], [child]);
3100
3417
  }
3101
3418
  };
3419
+ var makeDataVisitor = new MakeDataVisitor();
3102
3420
  function makeData(props) {
3103
- return new MakeDataVisitor().visit(props);
3421
+ return makeDataVisitor.visit(props);
3104
3422
  }
3105
3423
 
3106
3424
  // ../../node_modules/apache-arrow/util/chunk.mjs
@@ -3244,7 +3562,14 @@ function indexOfValue(data, searchElement, fromIndex) {
3244
3562
  return -1;
3245
3563
  }
3246
3564
  if (searchElement === null) {
3247
- return indexOfNull(data, fromIndex);
3565
+ switch (data.typeId) {
3566
+ case Type.Union:
3567
+ break;
3568
+ case Type.Dictionary:
3569
+ break;
3570
+ default:
3571
+ return indexOfNull(data, fromIndex);
3572
+ }
3248
3573
  }
3249
3574
  const get = instance2.getVisitFn(data);
3250
3575
  const compare = createElementComparator(searchElement);
@@ -3306,6 +3631,11 @@ IndexOfVisitor.prototype.visitDictionary = indexOfValue;
3306
3631
  IndexOfVisitor.prototype.visitInterval = indexOfValue;
3307
3632
  IndexOfVisitor.prototype.visitIntervalDayTime = indexOfValue;
3308
3633
  IndexOfVisitor.prototype.visitIntervalYearMonth = indexOfValue;
3634
+ IndexOfVisitor.prototype.visitDuration = indexOfValue;
3635
+ IndexOfVisitor.prototype.visitDurationSecond = indexOfValue;
3636
+ IndexOfVisitor.prototype.visitDurationMillisecond = indexOfValue;
3637
+ IndexOfVisitor.prototype.visitDurationMicrosecond = indexOfValue;
3638
+ IndexOfVisitor.prototype.visitDurationNanosecond = indexOfValue;
3309
3639
  IndexOfVisitor.prototype.visitFixedSizeList = indexOfValue;
3310
3640
  IndexOfVisitor.prototype.visitMap = indexOfValue;
3311
3641
  var instance3 = new IndexOfVisitor();
@@ -3388,12 +3718,17 @@ IteratorVisitor.prototype.visitDictionary = vectorIterator;
3388
3718
  IteratorVisitor.prototype.visitInterval = vectorIterator;
3389
3719
  IteratorVisitor.prototype.visitIntervalDayTime = vectorIterator;
3390
3720
  IteratorVisitor.prototype.visitIntervalYearMonth = vectorIterator;
3721
+ IteratorVisitor.prototype.visitDuration = vectorIterator;
3722
+ IteratorVisitor.prototype.visitDurationSecond = vectorIterator;
3723
+ IteratorVisitor.prototype.visitDurationMillisecond = vectorIterator;
3724
+ IteratorVisitor.prototype.visitDurationMicrosecond = vectorIterator;
3725
+ IteratorVisitor.prototype.visitDurationNanosecond = vectorIterator;
3391
3726
  IteratorVisitor.prototype.visitFixedSizeList = vectorIterator;
3392
3727
  IteratorVisitor.prototype.visitMap = vectorIterator;
3393
3728
  var instance4 = new IteratorVisitor();
3394
3729
 
3395
3730
  // ../../node_modules/apache-arrow/visitor/bytelength.mjs
3396
- var sum = (x2, y2) => x2 + y2;
3731
+ var sum = (x3, y3) => x3 + y3;
3397
3732
  var GetByteLengthVisitor = class extends Visitor {
3398
3733
  visitNull(____, _2) {
3399
3734
  return 0;
@@ -3422,6 +3757,9 @@ var GetByteLengthVisitor = class extends Visitor {
3422
3757
  visitInterval(data, _2) {
3423
3758
  return (data.type.unit + 1) * 4;
3424
3759
  }
3760
+ visitDuration(____, _2) {
3761
+ return 8;
3762
+ }
3425
3763
  visitStruct(data, i) {
3426
3764
  return data.children.reduce((total, child) => total + instance5.visit(child, i), 0);
3427
3765
  }
@@ -3490,8 +3828,8 @@ var vectorPrototypesByTypeId = {};
3490
3828
  var Vector = class _Vector {
3491
3829
  constructor(input) {
3492
3830
  var _b2, _c2, _d2;
3493
- const data = input[0] instanceof _Vector ? input.flatMap((x2) => x2.data) : input;
3494
- if (data.length === 0 || data.some((x2) => !(x2 instanceof Data))) {
3831
+ const data = input[0] instanceof _Vector ? input.flatMap((x3) => x3.data) : input;
3832
+ if (data.length === 0 || data.some((x3) => !(x3 instanceof Data))) {
3495
3833
  throw new TypeError("Vector constructor expects an Array of Data instances.");
3496
3834
  }
3497
3835
  const type = (_b2 = data[0]) === null || _b2 === void 0 ? void 0 : _b2.type;
@@ -3525,19 +3863,13 @@ var Vector = class _Vector {
3525
3863
  * The aggregate size (in bytes) of this Vector's buffers and/or child Vectors.
3526
3864
  */
3527
3865
  get byteLength() {
3528
- if (this._byteLength === -1) {
3529
- this._byteLength = this.data.reduce((byteLength, data) => byteLength + data.byteLength, 0);
3530
- }
3531
- return this._byteLength;
3866
+ return this.data.reduce((byteLength, data) => byteLength + data.byteLength, 0);
3532
3867
  }
3533
3868
  /**
3534
3869
  * The number of null elements in this Vector.
3535
3870
  */
3536
3871
  get nullCount() {
3537
- if (this._nullCount === -1) {
3538
- this._nullCount = computeChunkNullCounts(this.data);
3539
- }
3540
- return this._nullCount;
3872
+ return computeChunkNullCounts(this.data);
3541
3873
  }
3542
3874
  /**
3543
3875
  * The Array or TypedArray constructor used for the JS representation
@@ -3593,7 +3925,7 @@ var Vector = class _Vector {
3593
3925
  return -1;
3594
3926
  }
3595
3927
  includes(element, offset) {
3596
- return this.indexOf(element, offset) > 0;
3928
+ return this.indexOf(element, offset) > -1;
3597
3929
  }
3598
3930
  /**
3599
3931
  * Get the size in bytes of an element by index.
@@ -3614,7 +3946,7 @@ var Vector = class _Vector {
3614
3946
  * @param others Additional Vectors to add to the end of this Vector.
3615
3947
  */
3616
3948
  concat(...others) {
3617
- return new _Vector(this.data.concat(others.flatMap((x2) => x2.data).flat(Number.POSITIVE_INFINITY)));
3949
+ return new _Vector(this.data.concat(others.flatMap((x3) => x3.data).flat(Number.POSITIVE_INFINITY)));
3618
3950
  }
3619
3951
  /**
3620
3952
  * Return a zero-copy sub-section of this Vector.
@@ -3742,8 +4074,6 @@ Vector[_a2] = ((proto) => {
3742
4074
  proto.length = 0;
3743
4075
  proto.stride = 1;
3744
4076
  proto.numChildren = 0;
3745
- proto._nullCount = -1;
3746
- proto._byteLength = -1;
3747
4077
  proto._offsets = new Uint32Array([0]);
3748
4078
  proto[Symbol.isConcatSpreadable] = true;
3749
4079
  const typeIds = Object.keys(Type).map((T) => Type[T]).filter((T) => typeof T === "number" && T !== Type.NONE);
@@ -3808,11 +4138,11 @@ function createIsValidFunction(nullValues) {
3808
4138
  };
3809
4139
  }
3810
4140
  let fnBody = "";
3811
- const noNaNs = nullValues.filter((x2) => x2 === x2);
4141
+ const noNaNs = nullValues.filter((x3) => x3 === x3);
3812
4142
  if (noNaNs.length > 0) {
3813
4143
  fnBody = `
3814
- switch (x) {${noNaNs.map((x2) => `
3815
- case ${valueToCase(x2)}:`).join("")}
4144
+ switch (x) {${noNaNs.map((x3) => `
4145
+ case ${valueToCase(x3)}:`).join("")}
3816
4146
  return false;
3817
4147
  }`;
3818
4148
  }
@@ -3823,11 +4153,11 @@ ${fnBody}`;
3823
4153
  return new Function(`x`, `${fnBody}
3824
4154
  return true;`);
3825
4155
  }
3826
- function valueToCase(x2) {
3827
- if (typeof x2 !== "bigint") {
3828
- return valueToString(x2);
4156
+ function valueToCase(x3) {
4157
+ if (typeof x3 !== "bigint") {
4158
+ return valueToString(x3);
3829
4159
  }
3830
- return `${valueToString(x2)}n`;
4160
+ return `${valueToString(x3)}n`;
3831
4161
  }
3832
4162
 
3833
4163
  // ../../node_modules/apache-arrow/builder/buffer.mjs
@@ -5374,6 +5704,45 @@ var TimeUnit2;
5374
5704
  TimeUnit3[TimeUnit3["NANOSECOND"] = 3] = "NANOSECOND";
5375
5705
  })(TimeUnit2 || (TimeUnit2 = {}));
5376
5706
 
5707
+ // ../../node_modules/apache-arrow/fb/duration.mjs
5708
+ var Duration2 = class _Duration {
5709
+ constructor() {
5710
+ this.bb = null;
5711
+ this.bb_pos = 0;
5712
+ }
5713
+ __init(i, bb) {
5714
+ this.bb_pos = i;
5715
+ this.bb = bb;
5716
+ return this;
5717
+ }
5718
+ static getRootAsDuration(bb, obj) {
5719
+ return (obj || new _Duration()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
5720
+ }
5721
+ static getSizePrefixedRootAsDuration(bb, obj) {
5722
+ bb.setPosition(bb.position() + SIZE_PREFIX_LENGTH);
5723
+ return (obj || new _Duration()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
5724
+ }
5725
+ unit() {
5726
+ const offset = this.bb.__offset(this.bb_pos, 4);
5727
+ return offset ? this.bb.readInt16(this.bb_pos + offset) : TimeUnit2.MILLISECOND;
5728
+ }
5729
+ static startDuration(builder) {
5730
+ builder.startObject(1);
5731
+ }
5732
+ static addUnit(builder, unit) {
5733
+ builder.addFieldInt16(0, unit, TimeUnit2.MILLISECOND);
5734
+ }
5735
+ static endDuration(builder) {
5736
+ const offset = builder.endObject();
5737
+ return offset;
5738
+ }
5739
+ static createDuration(builder, unit) {
5740
+ _Duration.startDuration(builder);
5741
+ _Duration.addUnit(builder, unit);
5742
+ return _Duration.endDuration(builder);
5743
+ }
5744
+ };
5745
+
5377
5746
  // ../../node_modules/apache-arrow/fb/fixed-size-binary.mjs
5378
5747
  var FixedSizeBinary2 = class _FixedSizeBinary {
5379
5748
  constructor() {
@@ -6252,13 +6621,14 @@ var Footer = class _Footer {
6252
6621
 
6253
6622
  // ../../node_modules/apache-arrow/schema.mjs
6254
6623
  var Schema2 = class _Schema {
6255
- constructor(fields = [], metadata, dictionaries) {
6624
+ constructor(fields = [], metadata, dictionaries, metadataVersion = MetadataVersion.V5) {
6256
6625
  this.fields = fields || [];
6257
6626
  this.metadata = metadata || /* @__PURE__ */ new Map();
6258
6627
  if (!dictionaries) {
6259
6628
  dictionaries = generateDictionaryMap(fields);
6260
6629
  }
6261
6630
  this.dictionaries = dictionaries;
6631
+ this.metadataVersion = metadataVersion;
6262
6632
  }
6263
6633
  get [Symbol.toStringTag]() {
6264
6634
  return "Schema";
@@ -6373,7 +6743,7 @@ var Footer_ = class {
6373
6743
  static decode(buf) {
6374
6744
  buf = new ByteBuffer2(toUint8Array(buf));
6375
6745
  const footer = Footer.getRootAsFooter(buf);
6376
- const schema = Schema2.decode(footer.schema());
6746
+ const schema = Schema2.decode(footer.schema(), /* @__PURE__ */ new Map(), footer.version());
6377
6747
  return new OffHeapFooter(schema, footer);
6378
6748
  }
6379
6749
  /** @nocollapse */
@@ -6392,7 +6762,7 @@ var Footer_ = class {
6392
6762
  const dictionaryBatchesOffset = b2.endVector();
6393
6763
  Footer.startFooter(b2);
6394
6764
  Footer.addSchema(b2, schemaOffset);
6395
- Footer.addVersion(b2, MetadataVersion.V4);
6765
+ Footer.addVersion(b2, MetadataVersion.V5);
6396
6766
  Footer.addRecordBatches(b2, recordBatchesOffset);
6397
6767
  Footer.addDictionaries(b2, dictionaryBatchesOffset);
6398
6768
  Footer.finishFooterBuffer(b2, Footer.endFooter(b2));
@@ -6404,7 +6774,7 @@ var Footer_ = class {
6404
6774
  get numDictionaries() {
6405
6775
  return this._dictionaryBatches.length;
6406
6776
  }
6407
- constructor(schema, version = MetadataVersion.V4, recordBatches, dictionaryBatches) {
6777
+ constructor(schema, version = MetadataVersion.V5, recordBatches, dictionaryBatches) {
6408
6778
  this.schema = schema;
6409
6779
  this.version = version;
6410
6780
  recordBatches && (this._recordBatches = recordBatches);
@@ -7221,7 +7591,7 @@ var Int128 = class _Int128 {
7221
7591
 
7222
7592
  // ../../node_modules/apache-arrow/visitor/vectorloader.mjs
7223
7593
  var VectorLoader = class extends Visitor {
7224
- constructor(bytes, nodes, buffers, dictionaries) {
7594
+ constructor(bytes, nodes, buffers, dictionaries, metadataVersion = MetadataVersion.V5) {
7225
7595
  super();
7226
7596
  this.nodesIndex = -1;
7227
7597
  this.buffersIndex = -1;
@@ -7229,6 +7599,7 @@ var VectorLoader = class extends Visitor {
7229
7599
  this.nodes = nodes;
7230
7600
  this.buffers = buffers;
7231
7601
  this.dictionaries = dictionaries;
7602
+ this.metadataVersion = metadataVersion;
7232
7603
  }
7233
7604
  visit(node) {
7234
7605
  return super.visit(node instanceof Field2 ? node.type : node);
@@ -7272,14 +7643,17 @@ var VectorLoader = class extends Visitor {
7272
7643
  visitStruct(type, { length: length2, nullCount } = this.nextFieldNode()) {
7273
7644
  return makeData({ type, length: length2, nullCount, nullBitmap: this.readNullBitmap(type, nullCount), children: this.visitMany(type.children) });
7274
7645
  }
7275
- visitUnion(type) {
7276
- return type.mode === UnionMode.Sparse ? this.visitSparseUnion(type) : this.visitDenseUnion(type);
7646
+ visitUnion(type, { length: length2, nullCount } = this.nextFieldNode()) {
7647
+ if (this.metadataVersion < MetadataVersion.V5) {
7648
+ this.readNullBitmap(type, nullCount);
7649
+ }
7650
+ return type.mode === UnionMode.Sparse ? this.visitSparseUnion(type, { length: length2, nullCount }) : this.visitDenseUnion(type, { length: length2, nullCount });
7277
7651
  }
7278
7652
  visitDenseUnion(type, { length: length2, nullCount } = this.nextFieldNode()) {
7279
- return makeData({ type, length: length2, nullCount, nullBitmap: this.readNullBitmap(type, nullCount), typeIds: this.readTypeIds(type), valueOffsets: this.readOffsets(type), children: this.visitMany(type.children) });
7653
+ return makeData({ type, length: length2, nullCount, typeIds: this.readTypeIds(type), valueOffsets: this.readOffsets(type), children: this.visitMany(type.children) });
7280
7654
  }
7281
7655
  visitSparseUnion(type, { length: length2, nullCount } = this.nextFieldNode()) {
7282
- return makeData({ type, length: length2, nullCount, nullBitmap: this.readNullBitmap(type, nullCount), typeIds: this.readTypeIds(type), children: this.visitMany(type.children) });
7656
+ return makeData({ type, length: length2, nullCount, typeIds: this.readTypeIds(type), children: this.visitMany(type.children) });
7283
7657
  }
7284
7658
  visitDictionary(type, { length: length2, nullCount } = this.nextFieldNode()) {
7285
7659
  return makeData({ type, length: length2, nullCount, nullBitmap: this.readNullBitmap(type, nullCount), data: this.readData(type.indices), dictionary: this.readDictionary(type) });
@@ -7287,6 +7661,9 @@ var VectorLoader = class extends Visitor {
7287
7661
  visitInterval(type, { length: length2, nullCount } = this.nextFieldNode()) {
7288
7662
  return makeData({ type, length: length2, nullCount, nullBitmap: this.readNullBitmap(type, nullCount), data: this.readData(type) });
7289
7663
  }
7664
+ visitDuration(type, { length: length2, nullCount } = this.nextFieldNode()) {
7665
+ return makeData({ type, length: length2, nullCount, nullBitmap: this.readNullBitmap(type, nullCount), data: this.readData(type) });
7666
+ }
7290
7667
  visitFixedSizeList(type, { length: length2, nullCount } = this.nextFieldNode()) {
7291
7668
  return makeData({ type, length: length2, nullCount, nullBitmap: this.readNullBitmap(type, nullCount), "child": this.visit(type.children[0]) });
7292
7669
  }
@@ -7316,8 +7693,8 @@ var VectorLoader = class extends Visitor {
7316
7693
  }
7317
7694
  };
7318
7695
  var JSONVectorLoader = class extends VectorLoader {
7319
- constructor(sources, nodes, buffers, dictionaries) {
7320
- super(new Uint8Array(0), nodes, buffers, dictionaries);
7696
+ constructor(sources, nodes, buffers, dictionaries, metadataVersion) {
7697
+ super(new Uint8Array(0), nodes, buffers, dictionaries, metadataVersion);
7321
7698
  this.sources = sources;
7322
7699
  }
7323
7700
  readNullBitmap(_type, nullCount, { offset } = this.nextBufferRange()) {
@@ -7333,7 +7710,7 @@ var JSONVectorLoader = class extends VectorLoader {
7333
7710
  const { sources } = this;
7334
7711
  if (DataType.isTimestamp(type)) {
7335
7712
  return toArrayBufferView(Uint8Array, Int642.convertArray(sources[offset]));
7336
- } else if ((DataType.isInt(type) || DataType.isTime(type)) && type.bitWidth === 64) {
7713
+ } else if ((DataType.isInt(type) || DataType.isTime(type)) && type.bitWidth === 64 || DataType.isDuration(type)) {
7337
7714
  return toArrayBufferView(Uint8Array, Int642.convertArray(sources[offset]));
7338
7715
  } else if (DataType.isDate(type) && type.unit === DateUnit.MILLISECOND) {
7339
7716
  return toArrayBufferView(Uint8Array, Int642.convertArray(sources[offset]));
@@ -7346,7 +7723,7 @@ var JSONVectorLoader = class extends VectorLoader {
7346
7723
  } else if (DataType.isUtf8(type)) {
7347
7724
  return encodeUtf8(sources[offset].join(""));
7348
7725
  }
7349
- return toArrayBufferView(Uint8Array, toArrayBufferView(type.ArrayType, sources[offset].map((x2) => +x2)));
7726
+ return toArrayBufferView(Uint8Array, toArrayBufferView(type.ArrayType, sources[offset].map((x3) => +x3)));
7350
7727
  }
7351
7728
  };
7352
7729
  function binaryDataFromJSON(values) {
@@ -7546,6 +7923,23 @@ var IntervalYearMonthBuilder = class extends IntervalBuilder {
7546
7923
  };
7547
7924
  IntervalYearMonthBuilder.prototype._setValue = setIntervalYearMonth;
7548
7925
 
7926
+ // ../../node_modules/apache-arrow/builder/duration.mjs
7927
+ var DurationBuilder = class extends FixedWidthBuilder {
7928
+ };
7929
+ DurationBuilder.prototype._setValue = setDuration;
7930
+ var DurationSecondBuilder = class extends DurationBuilder {
7931
+ };
7932
+ DurationSecondBuilder.prototype._setValue = setDurationSecond;
7933
+ var DurationMillisecondBuilder = class extends DurationBuilder {
7934
+ };
7935
+ DurationMillisecondBuilder.prototype._setValue = setDurationMillisecond;
7936
+ var DurationMicrosecondBuilder = class extends DurationBuilder {
7937
+ };
7938
+ DurationMicrosecondBuilder.prototype._setValue = setDurationMicrosecond;
7939
+ var DurationNanosecondBuilder = class extends DurationBuilder {
7940
+ };
7941
+ DurationNanosecondBuilder.prototype._setValue = setDurationNanosecond;
7942
+
7549
7943
  // ../../node_modules/apache-arrow/builder/int.mjs
7550
7944
  var IntBuilder = class extends FixedWidthBuilder {
7551
7945
  setValue(index, value) {
@@ -7731,9 +8125,7 @@ var UnionBuilder = class extends Builder {
7731
8125
  if (childTypeId === void 0) {
7732
8126
  childTypeId = this._valueToChildTypeId(this, value, index);
7733
8127
  }
7734
- if (this.setValid(index, this.isValid(value))) {
7735
- this.setValue(index, value, childTypeId);
7736
- }
8128
+ this.setValue(index, value, childTypeId);
7737
8129
  return this;
7738
8130
  }
7739
8131
  setValue(index, value, childTypeId) {
@@ -7918,6 +8310,21 @@ var GetBuilderCtor = class extends Visitor {
7918
8310
  visitIntervalYearMonth() {
7919
8311
  return IntervalYearMonthBuilder;
7920
8312
  }
8313
+ visitDuration() {
8314
+ return DurationBuilder;
8315
+ }
8316
+ visitDurationSecond() {
8317
+ return DurationSecondBuilder;
8318
+ }
8319
+ visitDurationMillisecond() {
8320
+ return DurationMillisecondBuilder;
8321
+ }
8322
+ visitDurationMicrosecond() {
8323
+ return DurationMicrosecondBuilder;
8324
+ }
8325
+ visistDurationNanosecond() {
8326
+ return DurationNanosecondBuilder;
8327
+ }
7921
8328
  visitFixedSizeList() {
7922
8329
  return FixedSizeListBuilder;
7923
8330
  }
@@ -7970,7 +8377,7 @@ function compareStruct(type, other) {
7970
8377
  return type === other || compareConstructor(type, other) && type.children.length === other.children.length && instance7.compareManyFields(type.children, other.children);
7971
8378
  }
7972
8379
  function compareUnion(type, other) {
7973
- return type === other || compareConstructor(type, other) && type.mode === other.mode && type.typeIds.every((x2, i) => x2 === other.typeIds[i]) && instance7.compareManyFields(type.children, other.children);
8380
+ return type === other || compareConstructor(type, other) && type.mode === other.mode && type.typeIds.every((x3, i) => x3 === other.typeIds[i]) && instance7.compareManyFields(type.children, other.children);
7974
8381
  }
7975
8382
  function compareDictionary(type, other) {
7976
8383
  return type === other || compareConstructor(type, other) && type.id === other.id && type.isOrdered === other.isOrdered && instance7.visit(type.indices, other.indices) && instance7.visit(type.dictionary, other.dictionary);
@@ -7978,6 +8385,9 @@ function compareDictionary(type, other) {
7978
8385
  function compareInterval(type, other) {
7979
8386
  return type === other || compareConstructor(type, other) && type.unit === other.unit;
7980
8387
  }
8388
+ function compareDuration(type, other) {
8389
+ return type === other || compareConstructor(type, other) && type.unit === other.unit;
8390
+ }
7981
8391
  function compareFixedSizeList(type, other) {
7982
8392
  return type === other || compareConstructor(type, other) && type.listSize === other.listSize && type.children.length === other.children.length && instance7.compareManyFields(type.children, other.children);
7983
8393
  }
@@ -8025,6 +8435,11 @@ TypeComparator.prototype.visitDictionary = compareDictionary;
8025
8435
  TypeComparator.prototype.visitInterval = compareInterval;
8026
8436
  TypeComparator.prototype.visitIntervalDayTime = compareInterval;
8027
8437
  TypeComparator.prototype.visitIntervalYearMonth = compareInterval;
8438
+ TypeComparator.prototype.visitDuration = compareDuration;
8439
+ TypeComparator.prototype.visitDurationSecond = compareDuration;
8440
+ TypeComparator.prototype.visitDurationMillisecond = compareDuration;
8441
+ TypeComparator.prototype.visitDurationMicrosecond = compareDuration;
8442
+ TypeComparator.prototype.visitDurationNanosecond = compareDuration;
8028
8443
  TypeComparator.prototype.visitFixedSizeList = compareFixedSizeList;
8029
8444
  TypeComparator.prototype.visitMap = compareMap;
8030
8445
  var instance7 = new TypeComparator();
@@ -8135,26 +8550,26 @@ var Table = class _Table {
8135
8550
  if (args.at(-1) instanceof Uint32Array) {
8136
8551
  offsets = args.pop();
8137
8552
  }
8138
- const unwrap = (x2) => {
8139
- if (x2) {
8140
- if (x2 instanceof RecordBatch) {
8141
- return [x2];
8142
- } else if (x2 instanceof _Table) {
8143
- return x2.batches;
8144
- } else if (x2 instanceof Data) {
8145
- if (x2.type instanceof Struct) {
8146
- return [new RecordBatch(new Schema2(x2.type.children), x2)];
8553
+ const unwrap = (x3) => {
8554
+ if (x3) {
8555
+ if (x3 instanceof RecordBatch) {
8556
+ return [x3];
8557
+ } else if (x3 instanceof _Table) {
8558
+ return x3.batches;
8559
+ } else if (x3 instanceof Data) {
8560
+ if (x3.type instanceof Struct) {
8561
+ return [new RecordBatch(new Schema2(x3.type.children), x3)];
8147
8562
  }
8148
- } else if (Array.isArray(x2)) {
8149
- return x2.flatMap((v2) => unwrap(v2));
8150
- } else if (typeof x2[Symbol.iterator] === "function") {
8151
- return [...x2].flatMap((v2) => unwrap(v2));
8152
- } else if (typeof x2 === "object") {
8153
- const keys = Object.keys(x2);
8154
- const vecs = keys.map((k2) => new Vector([x2[k2]]));
8563
+ } else if (Array.isArray(x3)) {
8564
+ return x3.flatMap((v2) => unwrap(v2));
8565
+ } else if (typeof x3[Symbol.iterator] === "function") {
8566
+ return [...x3].flatMap((v2) => unwrap(v2));
8567
+ } else if (typeof x3 === "object") {
8568
+ const keys = Object.keys(x3);
8569
+ const vecs = keys.map((k2) => new Vector([x3[k2]]));
8155
8570
  const schema2 = new Schema2(keys.map((k2, i) => new Field2(String(k2), vecs[i].type)));
8156
8571
  const [, batches2] = distributeVectorsIntoRecordBatches(schema2, vecs);
8157
- return batches2.length === 0 ? [new RecordBatch(x2)] : batches2;
8572
+ return batches2.length === 0 ? [new RecordBatch(x3)] : batches2;
8158
8573
  }
8159
8574
  }
8160
8575
  return [];
@@ -8356,7 +8771,7 @@ var Table = class _Table {
8356
8771
  */
8357
8772
  select(columnNames) {
8358
8773
  const nameToIndex = this.schema.fields.reduce((m2, f2, i) => m2.set(f2.name, i), /* @__PURE__ */ new Map());
8359
- return this.selectAt(columnNames.map((columnName) => nameToIndex.get(columnName)).filter((x2) => x2 > -1));
8774
+ return this.selectAt(columnNames.map((columnName) => nameToIndex.get(columnName)).filter((x3) => x3 > -1));
8360
8775
  }
8361
8776
  /**
8362
8777
  * Construct a new Table containing only columns at the specified indices.
@@ -8635,22 +9050,25 @@ function ensureSameLengthData(schema, chunks, maxLength = chunks.reduce((max2, c
8635
9050
  ];
8636
9051
  }
8637
9052
  function collectDictionaries(fields, children, dictionaries = /* @__PURE__ */ new Map()) {
8638
- for (let i = -1, n = fields.length; ++i < n; ) {
8639
- const field = fields[i];
8640
- const type = field.type;
8641
- const data = children[i];
8642
- if (DataType.isDictionary(type)) {
8643
- if (!dictionaries.has(type.id)) {
8644
- if (data.dictionary) {
8645
- dictionaries.set(type.id, data.dictionary);
9053
+ var _b2, _c2;
9054
+ if (((_b2 = fields === null || fields === void 0 ? void 0 : fields.length) !== null && _b2 !== void 0 ? _b2 : 0) > 0 && (fields === null || fields === void 0 ? void 0 : fields.length) === (children === null || children === void 0 ? void 0 : children.length)) {
9055
+ for (let i = -1, n = fields.length; ++i < n; ) {
9056
+ const { type } = fields[i];
9057
+ const data = children[i];
9058
+ for (const next of [data, ...((_c2 = data === null || data === void 0 ? void 0 : data.dictionary) === null || _c2 === void 0 ? void 0 : _c2.data) || []]) {
9059
+ collectDictionaries(type.children, next === null || next === void 0 ? void 0 : next.children, dictionaries);
9060
+ }
9061
+ if (DataType.isDictionary(type)) {
9062
+ const { id } = type;
9063
+ if (!dictionaries.has(id)) {
9064
+ if (data === null || data === void 0 ? void 0 : data.dictionary) {
9065
+ dictionaries.set(id, data.dictionary);
9066
+ }
9067
+ } else if (dictionaries.get(id) !== data.dictionary) {
9068
+ throw new Error(`Cannot create Schema containing two different dictionaries with the same Id`);
8646
9069
  }
8647
- } else if (dictionaries.get(type.id) !== data.dictionary) {
8648
- throw new Error(`Cannot create Schema containing two different dictionaries with the same Id`);
8649
9070
  }
8650
9071
  }
8651
- if (type.children && type.children.length > 0) {
8652
- collectDictionaries(type.children, data.children, dictionaries);
8653
- }
8654
9072
  }
8655
9073
  return dictionaries;
8656
9074
  }
@@ -9111,6 +9529,11 @@ var TypeAssembler = class extends Visitor {
9111
9529
  Interval.addUnit(b2, node.unit);
9112
9530
  return Interval.endInterval(b2);
9113
9531
  }
9532
+ visitDuration(node, b2) {
9533
+ Duration2.startDuration(b2);
9534
+ Duration2.addUnit(b2, node.unit);
9535
+ return Duration2.endDuration(b2);
9536
+ }
9114
9537
  visitList(_node, b2) {
9115
9538
  List2.startList(b2);
9116
9539
  return List2.endList(b2);
@@ -9157,7 +9580,7 @@ var instance8 = new TypeAssembler();
9157
9580
 
9158
9581
  // ../../node_modules/apache-arrow/ipc/metadata/json.mjs
9159
9582
  function schemaFromJSON(_schema, dictionaries = /* @__PURE__ */ new Map()) {
9160
- return new Schema2(schemaFieldsFromJSON(_schema, dictionaries), customMetadataFromJSON(_schema["customMetadata"]), dictionaries);
9583
+ return new Schema2(schemaFieldsFromJSON(_schema, dictionaries), customMetadataFromJSON(_schema["metadata"]), dictionaries);
9161
9584
  }
9162
9585
  function recordBatchFromJSON(b2) {
9163
9586
  return new RecordBatch3(b2["count"], fieldNodesFromJSON(b2["columns"]), buffersFromJSON(b2["columns"]));
@@ -9182,7 +9605,7 @@ function buffersFromJSON(xs, buffers = []) {
9182
9605
  for (let i = -1, n = (xs || []).length; ++i < n; ) {
9183
9606
  const column2 = xs[i];
9184
9607
  column2["VALIDITY"] && buffers.push(new BufferRegion(buffers.length, column2["VALIDITY"].length));
9185
- column2["TYPE"] && buffers.push(new BufferRegion(buffers.length, column2["TYPE"].length));
9608
+ column2["TYPE_ID"] && buffers.push(new BufferRegion(buffers.length, column2["TYPE_ID"].length));
9186
9609
  column2["OFFSET"] && buffers.push(new BufferRegion(buffers.length, column2["OFFSET"].length));
9187
9610
  column2["DATA"] && buffers.push(new BufferRegion(buffers.length, column2["DATA"].length));
9188
9611
  buffers = buffersFromJSON(column2["children"], buffers);
@@ -9201,21 +9624,21 @@ function fieldFromJSON(_field, dictionaries) {
9201
9624
  let dictType;
9202
9625
  if (!dictionaries || !(dictMeta = _field["dictionary"])) {
9203
9626
  type = typeFromJSON(_field, fieldChildrenFromJSON(_field, dictionaries));
9204
- field = new Field2(_field["name"], type, _field["nullable"], customMetadataFromJSON(_field["customMetadata"]));
9627
+ field = new Field2(_field["name"], type, _field["nullable"], customMetadataFromJSON(_field["metadata"]));
9205
9628
  } else if (!dictionaries.has(id = dictMeta["id"])) {
9206
9629
  keys = (keys = dictMeta["indexType"]) ? indexTypeFromJSON(keys) : new Int32();
9207
9630
  dictionaries.set(id, type = typeFromJSON(_field, fieldChildrenFromJSON(_field, dictionaries)));
9208
9631
  dictType = new Dictionary(type, keys, id, dictMeta["isOrdered"]);
9209
- field = new Field2(_field["name"], dictType, _field["nullable"], customMetadataFromJSON(_field["customMetadata"]));
9632
+ field = new Field2(_field["name"], dictType, _field["nullable"], customMetadataFromJSON(_field["metadata"]));
9210
9633
  } else {
9211
9634
  keys = (keys = dictMeta["indexType"]) ? indexTypeFromJSON(keys) : new Int32();
9212
9635
  dictType = new Dictionary(dictionaries.get(id), keys, id, dictMeta["isOrdered"]);
9213
- field = new Field2(_field["name"], dictType, _field["nullable"], customMetadataFromJSON(_field["customMetadata"]));
9636
+ field = new Field2(_field["name"], dictType, _field["nullable"], customMetadataFromJSON(_field["metadata"]));
9214
9637
  }
9215
9638
  return field || null;
9216
9639
  }
9217
- function customMetadataFromJSON(_metadata) {
9218
- return new Map(Object.entries(_metadata || {}));
9640
+ function customMetadataFromJSON(metadata = []) {
9641
+ return new Map(metadata.map(({ key, value }) => [key, value]));
9219
9642
  }
9220
9643
  function indexTypeFromJSON(_type) {
9221
9644
  return new Int_(_type["isSigned"], _type["bitWidth"]);
@@ -9269,9 +9692,15 @@ function typeFromJSON(f2, children) {
9269
9692
  const t = f2["type"];
9270
9693
  return new Interval_(IntervalUnit[t["unit"]]);
9271
9694
  }
9695
+ case "duration": {
9696
+ const t = f2["type"];
9697
+ return new Duration(TimeUnit[t["unit"]]);
9698
+ }
9272
9699
  case "union": {
9273
9700
  const t = f2["type"];
9274
- return new Union_(UnionMode[t["mode"]], t["typeIds"] || [], children || []);
9701
+ const [m2, ...ms] = (t["mode"] + "").toLowerCase();
9702
+ const mode2 = m2.toUpperCase() + ms.join("");
9703
+ return new Union_(UnionMode[mode2], t["typeIds"] || [], children || []);
9275
9704
  }
9276
9705
  case "fixedsizebinary": {
9277
9706
  const t = f2["type"];
@@ -9295,7 +9724,7 @@ var ByteBuffer3 = ByteBuffer;
9295
9724
  var Message2 = class _Message {
9296
9725
  /** @nocollapse */
9297
9726
  static fromJSON(msg, headerType) {
9298
- const message = new _Message(0, MetadataVersion.V4, headerType);
9727
+ const message = new _Message(0, MetadataVersion.V5, headerType);
9299
9728
  message._createHeader = messageHeaderFromJSON(msg, headerType);
9300
9729
  return message;
9301
9730
  }
@@ -9322,7 +9751,7 @@ var Message2 = class _Message {
9322
9751
  headerOffset = DictionaryBatch2.encode(b2, message.header());
9323
9752
  }
9324
9753
  Message.startMessage(b2);
9325
- Message.addVersion(b2, MetadataVersion.V4);
9754
+ Message.addVersion(b2, MetadataVersion.V5);
9326
9755
  Message.addHeader(b2, headerOffset);
9327
9756
  Message.addHeaderType(b2, message.headerType);
9328
9757
  Message.addBodyLength(b2, BigInt(message.bodyLength));
@@ -9332,13 +9761,13 @@ var Message2 = class _Message {
9332
9761
  /** @nocollapse */
9333
9762
  static from(header, bodyLength = 0) {
9334
9763
  if (header instanceof Schema2) {
9335
- return new _Message(0, MetadataVersion.V4, MessageHeader.Schema, header);
9764
+ return new _Message(0, MetadataVersion.V5, MessageHeader.Schema, header);
9336
9765
  }
9337
9766
  if (header instanceof RecordBatch3) {
9338
- return new _Message(bodyLength, MetadataVersion.V4, MessageHeader.RecordBatch, header);
9767
+ return new _Message(bodyLength, MetadataVersion.V5, MessageHeader.RecordBatch, header);
9339
9768
  }
9340
9769
  if (header instanceof DictionaryBatch2) {
9341
- return new _Message(bodyLength, MetadataVersion.V4, MessageHeader.DictionaryBatch, header);
9770
+ return new _Message(bodyLength, MetadataVersion.V5, MessageHeader.DictionaryBatch, header);
9342
9771
  }
9343
9772
  throw new Error(`Unrecognized Message header: ${header}`);
9344
9773
  }
@@ -9444,7 +9873,7 @@ function decodeMessageHeader(message, type) {
9444
9873
  return () => {
9445
9874
  switch (type) {
9446
9875
  case MessageHeader.Schema:
9447
- return Schema2.decode(message.header(new Schema()));
9876
+ return Schema2.decode(message.header(new Schema()), /* @__PURE__ */ new Map(), message.version());
9448
9877
  case MessageHeader.RecordBatch:
9449
9878
  return RecordBatch3.decode(message.header(new RecordBatch2()), message.version());
9450
9879
  case MessageHeader.DictionaryBatch:
@@ -9469,17 +9898,17 @@ FieldNode2["encode"] = encodeFieldNode;
9469
9898
  FieldNode2["decode"] = decodeFieldNode;
9470
9899
  BufferRegion["encode"] = encodeBufferRegion;
9471
9900
  BufferRegion["decode"] = decodeBufferRegion;
9472
- function decodeSchema(_schema, dictionaries = /* @__PURE__ */ new Map()) {
9901
+ function decodeSchema(_schema, dictionaries = /* @__PURE__ */ new Map(), version = MetadataVersion.V5) {
9473
9902
  const fields = decodeSchemaFields(_schema, dictionaries);
9474
- return new Schema2(fields, decodeCustomMetadata(_schema), dictionaries);
9903
+ return new Schema2(fields, decodeCustomMetadata(_schema), dictionaries, version);
9475
9904
  }
9476
- function decodeRecordBatch(batch, version = MetadataVersion.V4) {
9905
+ function decodeRecordBatch(batch, version = MetadataVersion.V5) {
9477
9906
  if (batch.compression() !== null) {
9478
9907
  throw new Error("Record batch compression not implemented");
9479
9908
  }
9480
9909
  return new RecordBatch3(batch.length(), decodeFieldNodes(batch), decodeBuffers(batch, version));
9481
9910
  }
9482
- function decodeDictionaryBatch(batch, version = MetadataVersion.V4) {
9911
+ function decodeDictionaryBatch(batch, version = MetadataVersion.V5) {
9483
9912
  return new DictionaryBatch2(RecordBatch3.decode(batch.data(), version), batch.id(), batch.isDelta());
9484
9913
  }
9485
9914
  function decodeBufferRegion(b2) {
@@ -9610,6 +10039,10 @@ function decodeFieldType(f2, children) {
9610
10039
  const t = f2.type(new Interval());
9611
10040
  return new Interval_(t.unit());
9612
10041
  }
10042
+ case Type2["Duration"]: {
10043
+ const t = f2.type(new Duration2());
10044
+ return new Duration(t.unit());
10045
+ }
9613
10046
  case Type2["Union"]: {
9614
10047
  const t = f2.type(new Union());
9615
10048
  return new Union_(t.mode(), t.typeIdsArray() || [], children || []);
@@ -9943,7 +10376,7 @@ var JSONMessageReader = class extends MessageReader {
9943
10376
  return (xs || []).reduce((buffers, column2) => [
9944
10377
  ...buffers,
9945
10378
  ...column2["VALIDITY"] && [column2["VALIDITY"]] || [],
9946
- ...column2["TYPE"] && [column2["TYPE"]] || [],
10379
+ ...column2["TYPE_ID"] && [column2["TYPE_ID"]] || [],
9947
10380
  ...column2["OFFSET"] && [column2["OFFSET"]] || [],
9948
10381
  ...column2["DATA"] && [column2["DATA"]] || [],
9949
10382
  ...flattenDataSources(column2["children"])
@@ -10216,7 +10649,7 @@ var RecordBatchReaderImpl = class {
10216
10649
  return dictionary.memoize();
10217
10650
  }
10218
10651
  _loadVectors(header, body, types) {
10219
- return new VectorLoader(body, header.nodes, header.buffers, this.dictionaries).visitMany(types);
10652
+ return new VectorLoader(body, header.nodes, header.buffers, this.dictionaries, this.schema.metadataVersion).visitMany(types);
10220
10653
  }
10221
10654
  };
10222
10655
  var RecordBatchStreamReaderImpl = class extends RecordBatchReaderImpl {
@@ -10565,7 +10998,7 @@ var RecordBatchJSONReaderImpl = class extends RecordBatchStreamReaderImpl {
10565
10998
  super(source, dictionaries);
10566
10999
  }
10567
11000
  _loadVectors(header, body, types) {
10568
- return new JSONVectorLoader(body, header.nodes, header.buffers, this.dictionaries).visitMany(types);
11001
+ return new JSONVectorLoader(body, header.nodes, header.buffers, this.dictionaries, this.schema.metadataVersion).visitMany(types);
10569
11002
  }
10570
11003
  };
10571
11004
  function shouldAutoDestroy(self, options) {
@@ -10648,14 +11081,19 @@ var VectorAssembler = class _VectorAssembler extends Visitor {
10648
11081
  }
10649
11082
  const { type } = data;
10650
11083
  if (!DataType.isDictionary(type)) {
10651
- const { length: length2, nullCount } = data;
11084
+ const { length: length2 } = data;
10652
11085
  if (length2 > 2147483647) {
10653
11086
  throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");
10654
11087
  }
10655
- if (!DataType.isNull(type)) {
10656
- addBuffer.call(this, nullCount <= 0 ? new Uint8Array(0) : truncateBitmap(data.offset, length2, data.nullBitmap));
11088
+ if (DataType.isUnion(type)) {
11089
+ this.nodes.push(new FieldNode2(length2, 0));
11090
+ } else {
11091
+ const { nullCount } = data;
11092
+ if (!DataType.isNull(type)) {
11093
+ addBuffer.call(this, nullCount <= 0 ? new Uint8Array(0) : truncateBitmap(data.offset, length2, data.nullBitmap));
11094
+ }
11095
+ this.nodes.push(new FieldNode2(length2, nullCount));
10657
11096
  }
10658
- this.nodes.push(new FieldNode2(length2, nullCount));
10659
11097
  }
10660
11098
  return super.visit(data);
10661
11099
  }
@@ -10686,6 +11124,7 @@ function addBuffer(values) {
10686
11124
  return this;
10687
11125
  }
10688
11126
  function assembleUnion(data) {
11127
+ var _a5;
10689
11128
  const { type, length: length2, typeIds, valueOffsets } = data;
10690
11129
  addBuffer.call(this, typeIds);
10691
11130
  if (type.mode === UnionMode.Sparse) {
@@ -10695,26 +11134,26 @@ function assembleUnion(data) {
10695
11134
  addBuffer.call(this, valueOffsets);
10696
11135
  return assembleNestedVector.call(this, data);
10697
11136
  } else {
10698
- const maxChildTypeId = typeIds.reduce((x2, y2) => Math.max(x2, y2), typeIds[0]);
10699
- const childLengths = new Int32Array(maxChildTypeId + 1);
10700
- const childOffsets = new Int32Array(maxChildTypeId + 1).fill(-1);
10701
11137
  const shiftedOffsets = new Int32Array(length2);
10702
- const unshiftedOffsets = rebaseValueOffsets(-valueOffsets[0], length2, valueOffsets);
11138
+ const childOffsets = /* @__PURE__ */ Object.create(null);
11139
+ const childLengths = /* @__PURE__ */ Object.create(null);
10703
11140
  for (let typeId, shift, index = -1; ++index < length2; ) {
10704
- if ((shift = childOffsets[typeId = typeIds[index]]) === -1) {
10705
- shift = childOffsets[typeId] = unshiftedOffsets[typeId];
11141
+ if ((typeId = typeIds[index]) === void 0) {
11142
+ continue;
10706
11143
  }
10707
- shiftedOffsets[index] = unshiftedOffsets[index] - shift;
10708
- ++childLengths[typeId];
10709
- }
10710
- addBuffer.call(this, shiftedOffsets);
10711
- for (let child, childIndex = -1, numChildren = type.children.length; ++childIndex < numChildren; ) {
10712
- if (child = data.children[childIndex]) {
10713
- const typeId = type.typeIds[childIndex];
10714
- const childLength = Math.min(length2, childLengths[typeId]);
10715
- this.visit(child.slice(childOffsets[typeId], childLength));
11144
+ if ((shift = childOffsets[typeId]) === void 0) {
11145
+ shift = childOffsets[typeId] = valueOffsets[index];
10716
11146
  }
11147
+ shiftedOffsets[index] = valueOffsets[index] - shift;
11148
+ childLengths[typeId] = ((_a5 = childLengths[typeId]) !== null && _a5 !== void 0 ? _a5 : 0) + 1;
10717
11149
  }
11150
+ addBuffer.call(this, shiftedOffsets);
11151
+ this.visitMany(data.children.map((child, childIndex) => {
11152
+ const typeId = type.typeIds[childIndex];
11153
+ const childOffset = childOffsets[typeId];
11154
+ const childLength = childLengths[typeId];
11155
+ return child.slice(childOffset, Math.min(length2, childLength));
11156
+ }));
10718
11157
  }
10719
11158
  }
10720
11159
  return this;
@@ -10733,17 +11172,18 @@ function assembleFlatVector(data) {
10733
11172
  }
10734
11173
  function assembleFlatListVector(data) {
10735
11174
  const { length: length2, values, valueOffsets } = data;
10736
- const firstOffset = valueOffsets[0];
10737
- const lastOffset = valueOffsets[length2];
10738
- const byteLength = Math.min(lastOffset - firstOffset, values.byteLength - firstOffset);
10739
- addBuffer.call(this, rebaseValueOffsets(-valueOffsets[0], length2, valueOffsets));
10740
- addBuffer.call(this, values.subarray(firstOffset, firstOffset + byteLength));
11175
+ const { [0]: begin, [length2]: end } = valueOffsets;
11176
+ const byteLength = Math.min(end - begin, values.byteLength - begin);
11177
+ addBuffer.call(this, rebaseValueOffsets(-begin, length2 + 1, valueOffsets));
11178
+ addBuffer.call(this, values.subarray(begin, begin + byteLength));
10741
11179
  return this;
10742
11180
  }
10743
11181
  function assembleListVector(data) {
10744
11182
  const { length: length2, valueOffsets } = data;
10745
11183
  if (valueOffsets) {
10746
- addBuffer.call(this, rebaseValueOffsets(valueOffsets[0], length2, valueOffsets));
11184
+ const { [0]: begin, [length2]: end } = valueOffsets;
11185
+ addBuffer.call(this, rebaseValueOffsets(-begin, length2 + 1, valueOffsets));
11186
+ return this.visit(data.children[0].slice(begin, end - begin));
10747
11187
  }
10748
11188
  return this.visit(data.children[0]);
10749
11189
  }
@@ -10764,6 +11204,7 @@ VectorAssembler.prototype.visitList = assembleListVector;
10764
11204
  VectorAssembler.prototype.visitStruct = assembleNestedVector;
10765
11205
  VectorAssembler.prototype.visitUnion = assembleUnion;
10766
11206
  VectorAssembler.prototype.visitInterval = assembleFlatVector;
11207
+ VectorAssembler.prototype.visitDuration = assembleFlatVector;
10767
11208
  VectorAssembler.prototype.visitFixedSizeList = assembleListVector;
10768
11209
  VectorAssembler.prototype.visitMap = assembleListVector;
10769
11210
 
@@ -10799,7 +11240,7 @@ var RecordBatchWriter = class extends ReadableInterop {
10799
11240
  }
10800
11241
  writeAll(input) {
10801
11242
  if (isPromise(input)) {
10802
- return input.then((x2) => this.writeAll(x2));
11243
+ return input.then((x3) => this.writeAll(x3));
10803
11244
  } else if (isAsyncIterable(input)) {
10804
11245
  return writeAllAsync(this, input);
10805
11246
  }
@@ -10973,7 +11414,7 @@ var RecordBatchStreamWriter = class _RecordBatchStreamWriter extends RecordBatch
10973
11414
  static writeAll(input, options) {
10974
11415
  const writer = new _RecordBatchStreamWriter(options);
10975
11416
  if (isPromise(input)) {
10976
- return input.then((x2) => writer.writeAll(x2));
11417
+ return input.then((x3) => writer.writeAll(x3));
10977
11418
  } else if (isAsyncIterable(input)) {
10978
11419
  return writeAllAsync(writer, input);
10979
11420
  }
@@ -10985,7 +11426,7 @@ var RecordBatchFileWriter = class _RecordBatchFileWriter extends RecordBatchWrit
10985
11426
  static writeAll(input) {
10986
11427
  const writer = new _RecordBatchFileWriter();
10987
11428
  if (isPromise(input)) {
10988
- return input.then((x2) => writer.writeAll(x2));
11429
+ return input.then((x3) => writer.writeAll(x3));
10989
11430
  } else if (isAsyncIterable(input)) {
10990
11431
  return writeAllAsync(writer, input);
10991
11432
  }
@@ -11000,7 +11441,7 @@ var RecordBatchFileWriter = class _RecordBatchFileWriter extends RecordBatchWrit
11000
11441
  return this._writeMagic()._writePadding(2);
11001
11442
  }
11002
11443
  _writeFooter(schema) {
11003
- const buffer = Footer_.encode(new Footer_(schema, MetadataVersion.V4, this._recordBatchBlocks, this._dictionaryBlocks));
11444
+ const buffer = Footer_.encode(new Footer_(schema, MetadataVersion.V5, this._recordBatchBlocks, this._dictionaryBlocks));
11004
11445
  return super._writeFooter(schema)._write(buffer)._write(Int32Array.of(buffer.byteLength))._writeMagic();
11005
11446
  }
11006
11447
  };
@@ -11300,7 +11741,7 @@ function tableToIPC(table, type = "stream") {
11300
11741
  }
11301
11742
 
11302
11743
  // ../../node_modules/apache-arrow/Arrow.mjs
11303
- var util = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, bn_exports), int_exports), bit_exports), math_exports), buffer_exports), vector_exports), {
11744
+ var util = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, bn_exports), int_exports), bit_exports), math_exports), buffer_exports), vector_exports), pretty_exports), {
11304
11745
  compareSchemas,
11305
11746
  compareFields,
11306
11747
  compareTypes
@@ -11470,10 +11911,10 @@ function literalToSQL(value) {
11470
11911
  const ts = +value;
11471
11912
  if (Number.isNaN(ts))
11472
11913
  return "NULL";
11473
- const y2 = value.getUTCFullYear();
11914
+ const y3 = value.getUTCFullYear();
11474
11915
  const m2 = value.getUTCMonth();
11475
11916
  const d = value.getUTCDate();
11476
- return ts === Date.UTC(y2, m2, d) ? `MAKE_DATE(${y2}, ${m2 + 1}, ${d})` : `EPOCH_MS(${ts})`;
11917
+ return ts === Date.UTC(y3, m2, d) ? `MAKE_DATE(${y3}, ${m2 + 1}, ${d})` : `EPOCH_MS(${ts})`;
11477
11918
  } else if (value instanceof RegExp) {
11478
11919
  return `'${value.source}'`;
11479
11920
  } else {
@@ -11608,7 +12049,7 @@ function visit(callback) {
11608
12049
  this.children?.forEach((v2) => v2.visit(callback));
11609
12050
  }
11610
12051
  function logical(op, clauses) {
11611
- const children = clauses.filter((x2) => x2 != null).map(asColumn);
12052
+ const children = clauses.filter((x3) => x3 != null).map(asColumn);
11612
12053
  const strings = children.map((c, i) => i ? ` ${op} ` : "");
11613
12054
  if (children.length === 1) {
11614
12055
  strings.push("");
@@ -11697,7 +12138,7 @@ var WindowFunction = class _WindowFunction extends SQLExpression {
11697
12138
  return new _WindowFunction(op, func, type, name, group, order, frame);
11698
12139
  }
11699
12140
  partitionby(...expr) {
11700
- const exprs = expr.flat().filter((x2) => x2).map(asColumn);
12141
+ const exprs = expr.flat().filter((x3) => x3).map(asColumn);
11701
12142
  const group = sql(
11702
12143
  ["PARTITION BY ", repeat(exprs.length - 1, ", "), ""],
11703
12144
  ...exprs
@@ -11706,7 +12147,7 @@ var WindowFunction = class _WindowFunction extends SQLExpression {
11706
12147
  return new _WindowFunction(op, func, type, name, group, order, frame);
11707
12148
  }
11708
12149
  orderby(...expr) {
11709
- const exprs = expr.flat().filter((x2) => x2).map(asColumn);
12150
+ const exprs = expr.flat().filter((x3) => x3).map(asColumn);
11710
12151
  const order = sql(
11711
12152
  ["ORDER BY ", repeat(exprs.length - 1, ", "), ""],
11712
12153
  ...exprs
@@ -11865,6 +12306,12 @@ var epoch_ms = (expr) => {
11865
12306
  return sql`(1000 * (epoch(${d}) - second(${d})) + millisecond(${d}))::DOUBLE`;
11866
12307
  };
11867
12308
 
12309
+ // ../sql/src/spatial.js
12310
+ var geojson = functionCall("ST_AsGeoJSON");
12311
+ var x = functionCall("ST_X");
12312
+ var y = functionCall("ST_Y");
12313
+ var centroid = functionCall("ST_CENTROID");
12314
+
11868
12315
  // ../sql/src/Query.js
11869
12316
  var Query = class _Query {
11870
12317
  static select(...expr) {
@@ -12012,7 +12459,7 @@ var Query = class _Query {
12012
12459
  return query.where;
12013
12460
  } else {
12014
12461
  query.where = query.where.concat(
12015
- expr.flat().filter((x2) => x2)
12462
+ expr.flat().filter((x3) => x3)
12016
12463
  );
12017
12464
  return this;
12018
12465
  }
@@ -12027,7 +12474,7 @@ var Query = class _Query {
12027
12474
  return query.groupby;
12028
12475
  } else {
12029
12476
  query.groupby = query.groupby.concat(
12030
- expr.flat().filter((x2) => x2).map(asColumn)
12477
+ expr.flat().filter((x3) => x3).map(asColumn)
12031
12478
  );
12032
12479
  return this;
12033
12480
  }
@@ -12042,7 +12489,7 @@ var Query = class _Query {
12042
12489
  return query.having;
12043
12490
  } else {
12044
12491
  query.having = query.having.concat(
12045
- expr.flat().filter((x2) => x2)
12492
+ expr.flat().filter((x3) => x3)
12046
12493
  );
12047
12494
  return this;
12048
12495
  }
@@ -12071,7 +12518,7 @@ var Query = class _Query {
12071
12518
  return query.qualify;
12072
12519
  } else {
12073
12520
  query.qualify = query.qualify.concat(
12074
- expr.flat().filter((x2) => x2)
12521
+ expr.flat().filter((x3) => x3)
12075
12522
  );
12076
12523
  return this;
12077
12524
  }
@@ -12082,7 +12529,7 @@ var Query = class _Query {
12082
12529
  return query.orderby;
12083
12530
  } else {
12084
12531
  query.orderby = query.orderby.concat(
12085
- expr.flat().filter((x2) => x2).map(asColumn)
12532
+ expr.flat().filter((x3) => x3).map(asColumn)
12086
12533
  );
12087
12534
  return this;
12088
12535
  }
@@ -12153,7 +12600,7 @@ var Query = class _Query {
12153
12600
  sql2.push(`FROM ${rels.join(", ")}`);
12154
12601
  }
12155
12602
  if (where.length) {
12156
- const clauses = where.map(String).filter((x2) => x2).join(" AND ");
12603
+ const clauses = where.map(String).filter((x3) => x3).join(" AND ");
12157
12604
  if (clauses)
12158
12605
  sql2.push(`WHERE ${clauses}`);
12159
12606
  }
@@ -12167,7 +12614,7 @@ var Query = class _Query {
12167
12614
  sql2.push(`GROUP BY ${groupby.join(", ")}`);
12168
12615
  }
12169
12616
  if (having.length) {
12170
- const clauses = having.map(String).filter((x2) => x2).join(" AND ");
12617
+ const clauses = having.map(String).filter((x3) => x3).join(" AND ");
12171
12618
  if (clauses)
12172
12619
  sql2.push(`HAVING ${clauses}`);
12173
12620
  }
@@ -12176,7 +12623,7 @@ var Query = class _Query {
12176
12623
  sql2.push(`WINDOW ${windows.join(", ")}`);
12177
12624
  }
12178
12625
  if (qualify.length) {
12179
- const clauses = qualify.map(String).filter((x2) => x2).join(" AND ");
12626
+ const clauses = qualify.map(String).filter((x3) => x3).join(" AND ");
12180
12627
  if (clauses)
12181
12628
  sql2.push(`QUALIFY ${clauses}`);
12182
12629
  }
@@ -12209,7 +12656,7 @@ var SetOperation = class _SetOperation {
12209
12656
  return query.orderby;
12210
12657
  } else {
12211
12658
  query.orderby = query.orderby.concat(
12212
- expr.flat().filter((x2) => x2).map(asColumn)
12659
+ expr.flat().filter((x3) => x3).map(asColumn)
12213
12660
  );
12214
12661
  return this;
12215
12662
  }
@@ -12373,7 +12820,7 @@ var Catalog = class {
12373
12820
  async queryFields(fields) {
12374
12821
  const list = await resolveFields(this, fields);
12375
12822
  const data = await Promise.all(list.map((f2) => this.fieldInfo(f2)));
12376
- return data.filter((x2) => x2);
12823
+ return data.filter((x3) => x3);
12377
12824
  }
12378
12825
  };
12379
12826
  async function getTableInfo(mc, table) {
@@ -12422,7 +12869,7 @@ function fnv_mix(a2) {
12422
12869
  }
12423
12870
 
12424
12871
  // src/DataCubeIndexer.js
12425
- var identity = (x2) => x2;
12872
+ var identity = (x3) => x3;
12426
12873
  var DataCubeIndexer = class {
12427
12874
  /**
12428
12875
  *
@@ -12551,7 +12998,7 @@ function binInterval(scale, pixelSize) {
12551
12998
  toSql = (c) => sql`LN(${asColumn(c)})`;
12552
12999
  break;
12553
13000
  case "symlog":
12554
- lift = (x2) => Math.sign(x2) * Math.log1p(Math.abs(x2));
13001
+ lift = (x3) => Math.sign(x3) * Math.log1p(Math.abs(x3));
12555
13002
  toSql = (c) => (c = asColumn(c), sql`SIGN(${c}) * LN(1 + ABS(${c}))`);
12556
13003
  break;
12557
13004
  case "sqrt":
@@ -12560,7 +13007,7 @@ function binInterval(scale, pixelSize) {
12560
13007
  break;
12561
13008
  case "utc":
12562
13009
  case "time":
12563
- lift = (x2) => +x2;
13010
+ lift = (x3) => +x3;
12564
13011
  toSql = (c) => c instanceof Date ? +c : epoch_ms(asColumn(c));
12565
13012
  break;
12566
13013
  }
@@ -12714,6 +13161,10 @@ function queryResult() {
12714
13161
  }
12715
13162
 
12716
13163
  // src/QueryConsolidator.js
13164
+ function wait(callback) {
13165
+ const method = typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : typeof setImmediate !== "undefined" ? setImmediate : setTimeout;
13166
+ return method(callback);
13167
+ }
12717
13168
  function consolidator(enqueue, cache, record) {
12718
13169
  let pending = [];
12719
13170
  let id = 0;
@@ -12729,7 +13180,7 @@ function consolidator(enqueue, cache, record) {
12729
13180
  return {
12730
13181
  add(entry, priority) {
12731
13182
  if (entry.request.type === "arrow") {
12732
- id = id || requestAnimationFrame(() => run());
13183
+ id = id || wait(() => run());
12733
13184
  pending.push({ entry, priority, index: pending.length });
12734
13185
  } else {
12735
13186
  enqueue(entry, priority);
@@ -13092,7 +13543,7 @@ function QueryManager() {
13092
13543
  return state.slice();
13093
13544
  },
13094
13545
  stop() {
13095
- recorders = recorders.filter((x2) => x2 !== recorder);
13546
+ recorders = recorders.filter((x3) => x3 !== recorder);
13096
13547
  return state;
13097
13548
  }
13098
13549
  };
@@ -13130,9 +13581,13 @@ function coordinator(instance9) {
13130
13581
  }
13131
13582
  var Coordinator = class {
13132
13583
  constructor(db = socketConnector(), options = {}) {
13584
+ const {
13585
+ logger = console,
13586
+ manager = QueryManager()
13587
+ } = options;
13133
13588
  this.catalog = new Catalog(this);
13134
- this.manager = options.manager || QueryManager();
13135
- this.logger(options.logger || console);
13589
+ this.manager = manager;
13590
+ this.logger(logger);
13136
13591
  this.configure(options);
13137
13592
  this.databaseConnector(db);
13138
13593
  this.clear();
@@ -13170,6 +13625,7 @@ var Coordinator = class {
13170
13625
  this.manager.cancel(requests);
13171
13626
  }
13172
13627
  exec(query, { priority = Priority.Normal } = {}) {
13628
+ query = Array.isArray(query) ? query.join(";\n") : query;
13173
13629
  return this.manager.request({ type: "exec", query }, priority);
13174
13630
  }
13175
13631
  query(query, {
@@ -13217,6 +13673,7 @@ var Coordinator = class {
13217
13673
  throw new Error("Client already connected.");
13218
13674
  }
13219
13675
  clients.add(client);
13676
+ client.coordinator = this;
13220
13677
  const fields = client.fields();
13221
13678
  if (fields?.length) {
13222
13679
  client.fieldInfo(await catalog.queryFields(fields));
@@ -13243,136 +13700,7 @@ var Coordinator = class {
13243
13700
  return;
13244
13701
  clients.delete(client);
13245
13702
  filterGroups.get(client.filterBy)?.remove(client);
13246
- }
13247
- };
13248
-
13249
- // src/util/throttle.js
13250
- var NIL = {};
13251
- function throttle(callback, debounce = false) {
13252
- let curr;
13253
- let next;
13254
- let pending = NIL;
13255
- function invoke(event) {
13256
- curr = callback(event).then(() => {
13257
- if (next) {
13258
- const { value } = next;
13259
- next = null;
13260
- invoke(value);
13261
- } else {
13262
- curr = null;
13263
- }
13264
- });
13265
- }
13266
- function enqueue(event) {
13267
- next = { event };
13268
- }
13269
- function process(event) {
13270
- curr ? enqueue(event) : invoke(event);
13271
- }
13272
- function delay(event) {
13273
- if (pending !== event) {
13274
- requestAnimationFrame(() => {
13275
- const e = pending;
13276
- pending = NIL;
13277
- process(e);
13278
- });
13279
- }
13280
- pending = event;
13281
- }
13282
- return debounce ? delay : process;
13283
- }
13284
-
13285
- // src/MosaicClient.js
13286
- var MosaicClient = class {
13287
- /**
13288
- * Constructor.
13289
- * @param {*} filterSelection An optional selection to interactively filter
13290
- * this client's data. If provided, a coordinator will re-query and update
13291
- * the client when the selection updates.
13292
- */
13293
- constructor(filterSelection) {
13294
- this._filterBy = filterSelection;
13295
- this._requestUpdate = throttle(() => this.requestQuery(), true);
13296
- }
13297
- /**
13298
- * Return this client's filter selection.
13299
- */
13300
- get filterBy() {
13301
- return this._filterBy;
13302
- }
13303
- /**
13304
- * Return a boolean indicating if the client query can be indexed. Should
13305
- * return true if changes to the filterBy selection does not change the
13306
- * groupby domain of the client query.
13307
- */
13308
- get filterIndexable() {
13309
- return true;
13310
- }
13311
- /**
13312
- * Return an array of fields queried by this client.
13313
- */
13314
- fields() {
13315
- return null;
13316
- }
13317
- /**
13318
- * Called by the coordinator to set the field info for this client.
13319
- * @returns {this}
13320
- */
13321
- fieldInfo() {
13322
- return this;
13323
- }
13324
- /**
13325
- * Return a query specifying the data needed by this client.
13326
- */
13327
- query() {
13328
- return null;
13329
- }
13330
- /**
13331
- * Called by the coordinator to inform the client that a query is pending.
13332
- */
13333
- queryPending() {
13334
- return this;
13335
- }
13336
- /**
13337
- * Called by the coordinator to return a query result.
13338
- *
13339
- * @param {*} data the query result
13340
- * @returns {this}
13341
- */
13342
- queryResult() {
13343
- return this;
13344
- }
13345
- /**
13346
- * Called by the coordinator to report a query execution error.
13347
- */
13348
- queryError(error) {
13349
- console.error(error);
13350
- return this;
13351
- }
13352
- /**
13353
- * Request the coordinator to execute a query for this client.
13354
- * If an explicit query is not provided, the client query method will
13355
- * be called, filtered by the current filterBy selection.
13356
- */
13357
- requestQuery(query) {
13358
- const q2 = query || this.query(this.filterBy?.predicate(this));
13359
- return coordinator().requestQuery(this, q2);
13360
- }
13361
- /**
13362
- * Request that the coordinator perform a throttled update of this client
13363
- * using the default query. Unlike requestQuery, for which every call will
13364
- * result in an executed query, multiple calls to requestUpdate may be
13365
- * consolidated into a single update.
13366
- */
13367
- requestUpdate() {
13368
- this._requestUpdate();
13369
- }
13370
- /**
13371
- * Requests a client update.
13372
- * For example to (re-)render an interface component.
13373
- */
13374
- update() {
13375
- return this;
13703
+ client.coordinator = null;
13376
13704
  }
13377
13705
  };
13378
13706
 
@@ -13548,8 +13876,8 @@ function distinctArray(a2, b2) {
13548
13876
  }
13549
13877
 
13550
13878
  // src/Param.js
13551
- function isParam(x2) {
13552
- return x2 instanceof Param;
13879
+ function isParam(x3) {
13880
+ return x3 instanceof Param;
13553
13881
  }
13554
13882
  var Param = class _Param extends AsyncDispatch {
13555
13883
  /**
@@ -13623,8 +13951,8 @@ var Param = class _Param extends AsyncDispatch {
13623
13951
  };
13624
13952
 
13625
13953
  // src/Selection.js
13626
- function isSelection(x2) {
13627
- return x2 instanceof Selection;
13954
+ function isSelection(x3) {
13955
+ return x3 instanceof Selection;
13628
13956
  }
13629
13957
  var Selection = class _Selection extends Param {
13630
13958
  /**
@@ -13896,7 +14224,7 @@ var J = (s, e, r, t) => {
13896
14224
  return s;
13897
14225
  };
13898
14226
  var $ = (s, e, r) => (r = s != null ? Y(K(s)) : {}, J(e || !s || !s.__esModule ? N(r, "default", { value: s, enumerable: true }) : r, s));
13899
- var x = z((qe, G) => {
14227
+ var x2 = z((qe, G) => {
13900
14228
  G.exports = Worker;
13901
14229
  });
13902
14230
  var Z = ((o) => (o[o.UNDEFINED = 0] = "UNDEFINED", o[o.AUTOMATIC = 1] = "AUTOMATIC", o[o.READ_ONLY = 2] = "READ_ONLY", o[o.READ_WRITE = 3] = "READ_WRITE", o))(Z || {});
@@ -14016,7 +14344,7 @@ var a = class {
14016
14344
  });
14017
14345
  }
14018
14346
  };
14019
- function R(s) {
14347
+ function m(s) {
14020
14348
  switch (s.typeId) {
14021
14349
  case Type.Binary:
14022
14350
  return { sqlType: "binary" };
@@ -14061,7 +14389,7 @@ function R(s) {
14061
14389
  case Type.IntervalYearMonth:
14062
14390
  return { sqlType: "interval[m]" };
14063
14391
  case Type.List:
14064
- return { sqlType: "list", valueType: R(s.valueType) };
14392
+ return { sqlType: "list", valueType: m(s.valueType) };
14065
14393
  case Type.FixedSizeBinary:
14066
14394
  return { sqlType: "fixedsizebinary", byteWidth: s.byteWidth };
14067
14395
  case Type.Null:
@@ -14069,10 +14397,10 @@ function R(s) {
14069
14397
  case Type.Utf8:
14070
14398
  return { sqlType: "utf8" };
14071
14399
  case Type.Struct:
14072
- return { sqlType: "struct", fields: s.children.map((r) => _(r.name, r.type)) };
14400
+ return { sqlType: "struct", fields: s.children.map((r) => R(r.name, r.type)) };
14073
14401
  case Type.Map: {
14074
14402
  let e = s;
14075
- return { sqlType: "map", keyType: R(e.keyType), valueType: R(e.valueType) };
14403
+ return { sqlType: "map", keyType: m(e.keyType), valueType: m(e.valueType) };
14076
14404
  }
14077
14405
  case Type.Time:
14078
14406
  return { sqlType: "time[s]" };
@@ -14097,8 +14425,8 @@ function R(s) {
14097
14425
  }
14098
14426
  throw new Error("unsupported arrow type: ".concat(s.toString()));
14099
14427
  }
14100
- function _(s, e) {
14101
- let r = R(e);
14428
+ function R(s, e) {
14429
+ let r = m(e);
14102
14430
  return r.name = s, r;
14103
14431
  }
14104
14432
  var oe = new TextEncoder();
@@ -14439,7 +14767,7 @@ var O = class {
14439
14767
  let i = [];
14440
14768
  for (let n in t.columns) {
14441
14769
  let T = t.columns[n];
14442
- i.push(_(n, T));
14770
+ i.push(R(n, T));
14443
14771
  }
14444
14772
  t.columnsFlat = i, delete t.columns;
14445
14773
  }
@@ -14451,7 +14779,7 @@ var O = class {
14451
14779
  let i = [];
14452
14780
  for (let n in t.columns) {
14453
14781
  let T = t.columns[n];
14454
- i.push(_(n, T));
14782
+ i.push(R(n, T));
14455
14783
  }
14456
14784
  t.columnsFlat = i, delete t.columns;
14457
14785
  }
@@ -14461,33 +14789,33 @@ var O = class {
14461
14789
  };
14462
14790
  var F = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 5, 3, 1, 0, 1, 10, 14, 1, 12, 0, 65, 0, 65, 0, 65, 0, 252, 10, 0, 0, 11]));
14463
14791
  var f = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 8, 1, 6, 0, 6, 64, 25, 11, 11]));
14464
- var C = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 123, 3, 2, 1, 0, 10, 10, 1, 8, 0, 65, 0, 253, 15, 253, 98, 11]));
14465
- var U = () => (async (s) => {
14792
+ var U = async () => WebAssembly.validate(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 5, 1, 96, 0, 1, 123, 3, 2, 1, 0, 10, 10, 1, 8, 0, 65, 0, 253, 15, 253, 98, 11]));
14793
+ var C = () => (async (s) => {
14466
14794
  try {
14467
14795
  return typeof MessageChannel < "u" && new MessageChannel().port1.postMessage(new SharedArrayBuffer(1)), WebAssembly.validate(s);
14468
14796
  } catch (e) {
14469
14797
  return false;
14470
14798
  }
14471
14799
  })(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 5, 4, 1, 3, 1, 1, 10, 11, 1, 9, 0, 65, 0, 254, 16, 2, 0, 26, 11]));
14472
- var m = { name: "@duckdb/duckdb-wasm", version: "1.28.0", description: "DuckDB powered by WebAssembly", license: "MIT", repository: { type: "git", url: "https://github.com/duckdb/duckdb-wasm.git" }, keywords: ["sql", "duckdb", "relational", "database", "data", "query", "wasm", "analytics", "olap", "arrow", "parquet", "json", "csv"], dependencies: { "apache-arrow": "^13.0.0" }, devDependencies: { "@types/emscripten": "^1.39.8", "@types/jasmine": "^4.3.1", "@typescript-eslint/eslint-plugin": "^6.5.0", "@typescript-eslint/parser": "^6.7.3", esbuild: "^0.19.5", eslint: "^8.50.0", "eslint-plugin-jasmine": "^4.1.3", "eslint-plugin-react": "^7.33.2", "fast-glob": "^3.3.1", jasmine: "^5.1.0", "jasmine-core": "^5.1.1", "jasmine-spec-reporter": "^7.0.0", "js-sha256": "^0.9.0", karma: "^6.4.2", "karma-chrome-launcher": "^3.2.0", "karma-coverage": "^2.2.1", "karma-firefox-launcher": "^2.1.2", "karma-jasmine": "^5.1.0", "karma-jasmine-html-reporter": "^2.1.0", "karma-sourcemap-loader": "^0.4.0", "karma-spec-reporter": "^0.0.36", "make-dir": "^4.0.0", nyc: "^15.1.0", prettier: "^3.0.2", puppeteer: "^21.1.1", rimraf: "^5.0.5", s3rver: "^3.7.1", typedoc: "^0.25.2", typescript: "^5.2.2", "wasm-feature-detect": "^1.5.1", "web-worker": "^1.2.0" }, scripts: { "build:debug": "node bundle.mjs debug && tsc --emitDeclarationOnly", "build:release": "node bundle.mjs release && tsc --emitDeclarationOnly", docs: "typedoc", report: "node ./coverage.mjs", "test:node": "node --enable-source-maps ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs", "test:node:debug": "node --inspect-brk --enable-source-maps ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs", "test:node:coverage": "nyc -r json --report-dir ./coverage/node node ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs", "test:firefox": "karma start ./karma/tests-firefox.cjs", "test:chrome": "karma start ./karma/tests-chrome.cjs", "test:chrome:eh": "karma start ./karma/tests-chrome-eh.cjs", "test:chrome:coverage": "karma start ./karma/tests-chrome-coverage.cjs", "test:browser": "karma start ./karma/tests-all.cjs", "test:browser:debug": "karma start ./karma/tests-debug.cjs", test: "npm run test:chrome && npm run test:node", "test:coverage": "npm run test:chrome:coverage && npm run test:node:coverage && npm run report", lint: "eslint src test" }, files: ["dist", "!dist/types/test"], main: "dist/duckdb-browser.cjs", module: "dist/duckdb-browser.mjs", types: "dist/duckdb-browser.d.ts", jsdelivr: "dist/duckdb-browser.cjs", unpkg: "dist/duckdb-browser.mjs", sideEffects: false, browser: { fs: false, path: false, perf_hooks: false, os: false, worker_threads: false }, exports: { "./dist/duckdb-mvp.wasm": "./dist/duckdb-mvp.wasm", "./dist/duckdb-eh.wasm": "./dist/duckdb-eh.wasm", "./dist/duckdb-coi.wasm": "./dist/duckdb-coi.wasm", "./dist/duckdb-browser": "./dist/duckdb-browser.mjs", "./dist/duckdb-browser.cjs": "./dist/duckdb-browser.cjs", "./dist/duckdb-browser.mjs": "./dist/duckdb-browser.mjs", "./dist/duckdb-browser-blocking": "./dist/duckdb-browser-blocking.mjs", "./dist/duckdb-browser-blocking.mjs": "./dist/duckdb-browser-blocking.mjs", "./dist/duckdb-browser-blocking.cjs": "./dist/duckdb-browser-blocking.cjs", "./dist/duckdb-browser-coi.pthread.worker.js": "./dist/duckdb-browser-coi.pthread.worker.js", "./dist/duckdb-browser-coi.worker.js": "./dist/duckdb-browser-coi.worker.js", "./dist/duckdb-browser-eh.worker.js": "./dist/duckdb-browser-eh.worker.js", "./dist/duckdb-browser-mvp.worker.js": "./dist/duckdb-browser-mvp.worker.js", "./dist/duckdb-node": "./dist/duckdb-node.cjs", "./dist/duckdb-node.cjs": "./dist/duckdb-node.cjs", "./dist/duckdb-node-blocking": "./dist/duckdb-node-blocking.cjs", "./dist/duckdb-node-blocking.cjs": "./dist/duckdb-node-blocking.cjs", "./dist/duckdb-node-eh.worker.cjs": "./dist/duckdb-node-eh.worker.cjs", "./dist/duckdb-node-mvp.worker.cjs": "./dist/duckdb-node-mvp.worker.cjs", "./blocking": { browser: { types: "./dist/duckdb-browser-blocking.d.ts", import: "./dist/duckdb-browser-blocking.mjs", require: "./dist/duckdb-browser-blocking.cjs" }, node: { types: "./dist/duckdb-node-blocking.d.ts", require: "./dist/duckdb-node-blocking.cjs", import: "./dist/duckdb-node-blocking.cjs" }, types: "./dist/duckdb-browser-blocking.d.ts", import: "./dist/duckdb-browser-blocking.mjs", require: "./dist/duckdb-browser-blocking.cjs" }, ".": { browser: { types: "./dist/duckdb-browser.d.ts", import: "./dist/duckdb-browser.mjs", require: "./dist/duckdb-browser.cjs" }, node: { types: "./dist/duckdb-node.d.ts", import: "./dist/duckdb-node.cjs", require: "./dist/duckdb-node.cjs" }, types: "./dist/duckdb-browser.d.ts", import: "./dist/duckdb-browser.mjs", require: "./dist/duckdb-browser.cjs" } } };
14473
- var W = m.name;
14474
- var v = m.version;
14475
- var I = m.version.split(".");
14800
+ var _ = { name: "@duckdb/duckdb-wasm", version: "1.28.1-dev99.0", description: "DuckDB powered by WebAssembly", license: "MIT", repository: { type: "git", url: "https://github.com/duckdb/duckdb-wasm.git" }, keywords: ["sql", "duckdb", "relational", "database", "data", "query", "wasm", "analytics", "olap", "arrow", "parquet", "json", "csv"], dependencies: { "apache-arrow": "^14.0.1" }, devDependencies: { "@types/emscripten": "^1.39.10", "@types/jasmine": "^5.1.4", "@typescript-eslint/eslint-plugin": "^6.18.0", "@typescript-eslint/parser": "^6.18.0", esbuild: "^0.19.10", eslint: "^8.56.0", "eslint-plugin-jasmine": "^4.1.3", "eslint-plugin-react": "^7.33.2", "fast-glob": "^3.3.2", jasmine: "^5.1.0", "jasmine-core": "^5.1.1", "jasmine-spec-reporter": "^7.0.0", "js-sha256": "^0.10.1", karma: "^6.4.2", "karma-chrome-launcher": "^3.2.0", "karma-coverage": "^2.2.1", "karma-firefox-launcher": "^2.1.2", "karma-jasmine": "^5.1.0", "karma-jasmine-html-reporter": "^2.1.0", "karma-sourcemap-loader": "^0.4.0", "karma-spec-reporter": "^0.0.36", "make-dir": "^4.0.0", nyc: "^15.1.0", prettier: "^3.2.2", puppeteer: "^21.7.0", rimraf: "^5.0.5", s3rver: "^3.7.1", typedoc: "^0.25.7", typescript: "^5.3.3", "wasm-feature-detect": "^1.6.1", "web-worker": "^1.2.0" }, scripts: { "build:debug": "node bundle.mjs debug && tsc --emitDeclarationOnly", "build:release": "node bundle.mjs release && tsc --emitDeclarationOnly", docs: "typedoc", report: "node ./coverage.mjs", "test:node": "node --enable-source-maps ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs", "test:node:debug": "node --inspect-brk --enable-source-maps ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs", "test:node:coverage": "nyc -r json --report-dir ./coverage/node node ../../node_modules/jasmine/bin/jasmine ./dist/tests-node.cjs", "test:firefox": "karma start ./karma/tests-firefox.cjs", "test:chrome": "karma start ./karma/tests-chrome.cjs", "test:chrome:eh": "karma start ./karma/tests-chrome-eh.cjs", "test:chrome:coverage": "karma start ./karma/tests-chrome-coverage.cjs", "test:browser": "karma start ./karma/tests-all.cjs", "test:browser:debug": "karma start ./karma/tests-debug.cjs", test: "npm run test:chrome && npm run test:node", "test:coverage": "npm run test:chrome:coverage && npm run test:node:coverage && npm run report", lint: "eslint src test" }, files: ["dist", "!dist/types/test"], main: "dist/duckdb-browser.cjs", module: "dist/duckdb-browser.mjs", types: "dist/duckdb-browser.d.ts", jsdelivr: "dist/duckdb-browser.cjs", unpkg: "dist/duckdb-browser.mjs", sideEffects: false, browser: { fs: false, path: false, perf_hooks: false, os: false, worker_threads: false }, exports: { "./dist/duckdb-mvp.wasm": "./dist/duckdb-mvp.wasm", "./dist/duckdb-eh.wasm": "./dist/duckdb-eh.wasm", "./dist/duckdb-coi.wasm": "./dist/duckdb-coi.wasm", "./dist/duckdb-browser": "./dist/duckdb-browser.mjs", "./dist/duckdb-browser.cjs": "./dist/duckdb-browser.cjs", "./dist/duckdb-browser.mjs": "./dist/duckdb-browser.mjs", "./dist/duckdb-browser-blocking": "./dist/duckdb-browser-blocking.mjs", "./dist/duckdb-browser-blocking.mjs": "./dist/duckdb-browser-blocking.mjs", "./dist/duckdb-browser-blocking.cjs": "./dist/duckdb-browser-blocking.cjs", "./dist/duckdb-browser-coi.pthread.worker.js": "./dist/duckdb-browser-coi.pthread.worker.js", "./dist/duckdb-browser-coi.worker.js": "./dist/duckdb-browser-coi.worker.js", "./dist/duckdb-browser-eh.worker.js": "./dist/duckdb-browser-eh.worker.js", "./dist/duckdb-browser-mvp.worker.js": "./dist/duckdb-browser-mvp.worker.js", "./dist/duckdb-node": "./dist/duckdb-node.cjs", "./dist/duckdb-node.cjs": "./dist/duckdb-node.cjs", "./dist/duckdb-node-blocking": "./dist/duckdb-node-blocking.cjs", "./dist/duckdb-node-blocking.cjs": "./dist/duckdb-node-blocking.cjs", "./dist/duckdb-node-eh.worker.cjs": "./dist/duckdb-node-eh.worker.cjs", "./dist/duckdb-node-mvp.worker.cjs": "./dist/duckdb-node-mvp.worker.cjs", "./blocking": { browser: { types: "./dist/duckdb-browser-blocking.d.ts", import: "./dist/duckdb-browser-blocking.mjs", require: "./dist/duckdb-browser-blocking.cjs" }, node: { types: "./dist/duckdb-node-blocking.d.ts", require: "./dist/duckdb-node-blocking.cjs", import: "./dist/duckdb-node-blocking.cjs" }, types: "./dist/duckdb-browser-blocking.d.ts", import: "./dist/duckdb-browser-blocking.mjs", require: "./dist/duckdb-browser-blocking.cjs" }, ".": { browser: { types: "./dist/duckdb-browser.d.ts", import: "./dist/duckdb-browser.mjs", require: "./dist/duckdb-browser.cjs" }, node: { types: "./dist/duckdb-node.d.ts", import: "./dist/duckdb-node.cjs", require: "./dist/duckdb-node.cjs" }, types: "./dist/duckdb-browser.d.ts", import: "./dist/duckdb-browser.mjs", require: "./dist/duckdb-browser.cjs" } } };
14801
+ var W = _.name;
14802
+ var v = _.version;
14803
+ var I = _.version.split(".");
14476
14804
  var fe = I[0];
14477
- var Ce = I[1];
14478
- var Ue = I[2];
14805
+ var Ue = I[1];
14806
+ var Ce = I[2];
14479
14807
  var M = () => typeof navigator > "u";
14480
14808
  function Ge() {
14481
14809
  let s = "https://cdn.jsdelivr.net/npm/".concat(W, "@").concat(v, "/dist/");
14482
14810
  return { mvp: { mainModule: "".concat(s, "duckdb-mvp.wasm"), mainWorker: "".concat(s, "duckdb-browser-mvp.worker.js") }, eh: { mainModule: "".concat(s, "duckdb-eh.wasm"), mainWorker: "".concat(s, "duckdb-browser-eh.worker.js") } };
14483
14811
  }
14484
14812
  var k = null;
14485
- var y = null;
14813
+ var y2 = null;
14486
14814
  var g = null;
14487
14815
  var S = null;
14488
14816
  var h = null;
14489
14817
  async function de() {
14490
- return k == null && (k = typeof BigInt64Array < "u"), y == null && (y = await f()), g == null && (g = await U()), S == null && (S = await C()), h == null && (h = await F()), { bigInt64Array: k, crossOriginIsolated: M() || globalThis.crossOriginIsolated || false, wasmExceptions: y, wasmSIMD: S, wasmThreads: g, wasmBulkMemory: h };
14818
+ return k == null && (k = typeof BigInt64Array < "u"), y2 == null && (y2 = await f()), g == null && (g = await C()), S == null && (S = await U()), h == null && (h = await F()), { bigInt64Array: k, crossOriginIsolated: M() || globalThis.crossOriginIsolated || false, wasmExceptions: y2, wasmSIMD: S, wasmThreads: g, wasmBulkMemory: h };
14491
14819
  }
14492
14820
  async function xe(s) {
14493
14821
  let e = await de();
@@ -14499,7 +14827,7 @@ async function xe(s) {
14499
14827
  }
14500
14828
  return { mainModule: s.mvp.mainModule, mainWorker: s.mvp.mainWorker, pthreadWorker: null };
14501
14829
  }
14502
- var Q = $(x());
14830
+ var Q = $(x2());
14503
14831
  function ce() {
14504
14832
  let s = new TextDecoder();
14505
14833
  return (e) => (typeof SharedArrayBuffer < "u" && e.buffer instanceof SharedArrayBuffer && (e = new Uint8Array(e)), s.decode(e));
@@ -14508,15 +14836,41 @@ var je = ce();
14508
14836
  var q = ((n) => (n[n.BUFFER = 0] = "BUFFER", n[n.NODE_FS = 1] = "NODE_FS", n[n.BROWSER_FILEREADER = 2] = "BROWSER_FILEREADER", n[n.BROWSER_FSACCESS = 3] = "BROWSER_FSACCESS", n[n.HTTP = 4] = "HTTP", n[n.S3 = 5] = "S3", n))(q || {});
14509
14837
 
14510
14838
  // src/connectors/wasm.js
14511
- async function wasmConnector(options) {
14512
- const db = await initDatabase(options);
14513
- const con = await db.connect();
14839
+ function wasmConnector(options = {}) {
14840
+ const { duckdb, connection, ...opts } = options;
14841
+ let db = duckdb;
14842
+ let con = connection;
14843
+ let loadPromise;
14844
+ function load() {
14845
+ if (!loadPromise) {
14846
+ loadPromise = (db ? Promise.resolve(db) : initDatabase(opts).then((result) => db = result)).then((db2) => db2.connect()).then((result) => con = result);
14847
+ }
14848
+ return loadPromise;
14849
+ }
14850
+ async function getDuckDB() {
14851
+ if (!db)
14852
+ await load();
14853
+ return db;
14854
+ }
14855
+ async function getConnection() {
14856
+ if (!con)
14857
+ await load();
14858
+ return con;
14859
+ }
14514
14860
  return {
14515
- db,
14516
- con,
14861
+ getDuckDB,
14862
+ getConnection,
14863
+ /**
14864
+ * Query the DuckDB-WASM instance.
14865
+ * @param {object} query
14866
+ * @param {string} [query.type] The query type: 'exec', 'arrow', or 'json'.
14867
+ * @param {string} query.sql A SQL query string.
14868
+ * @returns the query result
14869
+ */
14517
14870
  query: async (query) => {
14518
14871
  const { type, sql: sql2 } = query;
14519
- const result = await con.query(sql2);
14872
+ const con2 = await getConnection();
14873
+ const result = await con2.query(sql2);
14520
14874
  return type === "exec" ? void 0 : type === "arrow" ? result : Array.from(result);
14521
14875
  }
14522
14876
  };