@uwdata/mosaic-inputs 0.1.0 → 0.2.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.
@@ -131,7 +131,7 @@ function __asyncValues(o) {
131
131
  }
132
132
  }
133
133
 
134
- // ../../node_modules/apache-arrow/util/buffer.mjs
134
+ // ../core/node_modules/apache-arrow/util/buffer.mjs
135
135
  var buffer_exports = {};
136
136
  __export(buffer_exports, {
137
137
  compareArrayLike: () => compareArrayLike,
@@ -172,28 +172,13 @@ __export(buffer_exports, {
172
172
  toUint8ClampedArrayIterator: () => toUint8ClampedArrayIterator
173
173
  });
174
174
 
175
- // ../../node_modules/apache-arrow/util/utf8.mjs
175
+ // ../core/node_modules/apache-arrow/util/utf8.mjs
176
176
  var decoder = new TextDecoder("utf-8");
177
177
  var decodeUtf8 = (buffer) => decoder.decode(buffer);
178
178
  var encoder = new TextEncoder();
179
179
  var encodeUtf8 = (value) => encoder.encode(value);
180
180
 
181
- // ../../node_modules/apache-arrow/util/compat.mjs
182
- var [BigIntCtor, BigIntAvailable] = (() => {
183
- const BigIntUnavailableError = () => {
184
- throw new Error("BigInt is not available in this environment");
185
- };
186
- function BigIntUnavailable() {
187
- throw BigIntUnavailableError();
188
- }
189
- BigIntUnavailable.asIntN = () => {
190
- throw BigIntUnavailableError();
191
- };
192
- BigIntUnavailable.asUintN = () => {
193
- throw BigIntUnavailableError();
194
- };
195
- return typeof BigInt !== "undefined" ? [BigInt, true] : [BigIntUnavailable, false];
196
- })();
181
+ // ../core/node_modules/apache-arrow/util/compat.mjs
197
182
  var [BigInt64ArrayCtor, BigInt64ArrayAvailable] = (() => {
198
183
  const BigInt64ArrayUnavailableError = () => {
199
184
  throw new Error("BigInt64Array is not available in this environment");
@@ -276,7 +261,7 @@ var isFlatbuffersByteBuffer = (x) => {
276
261
  return isObject(x) && isFunction(x["clear"]) && isFunction(x["bytes"]) && isFunction(x["position"]) && isFunction(x["setPosition"]) && isFunction(x["capacity"]) && isFunction(x["getBufferIdentifier"]) && isFunction(x["createLong"]);
277
262
  };
278
263
 
279
- // ../../node_modules/apache-arrow/util/buffer.mjs
264
+ // ../core/node_modules/apache-arrow/util/buffer.mjs
280
265
  var SharedArrayBuf = typeof SharedArrayBuffer !== "undefined" ? SharedArrayBuffer : ArrayBuffer;
281
266
  function collapseContiguousByteRanges(chunks) {
282
267
  const result = chunks[0] ? [chunks[0]] : [];
@@ -459,7 +444,7 @@ function compareArrayLike(a, b) {
459
444
  return true;
460
445
  }
461
446
 
462
- // ../../node_modules/apache-arrow/io/adapters.mjs
447
+ // ../core/node_modules/apache-arrow/io/adapters.mjs
463
448
  var adapters_default = {
464
449
  fromIterable(source) {
465
450
  return pump2(fromIterable(source));
@@ -703,7 +688,7 @@ function fromNodeStream(stream) {
703
688
  });
704
689
  }
705
690
 
706
- // ../../node_modules/apache-arrow/enum.mjs
691
+ // ../core/node_modules/apache-arrow/enum.mjs
707
692
  var MetadataVersion;
708
693
  (function(MetadataVersion3) {
709
694
  MetadataVersion3[MetadataVersion3["V1"] = 0] = "V1";
@@ -805,7 +790,7 @@ var BufferType;
805
790
  BufferType2[BufferType2["TYPE"] = 3] = "TYPE";
806
791
  })(BufferType || (BufferType = {}));
807
792
 
808
- // ../../node_modules/apache-arrow/util/vector.mjs
793
+ // ../core/node_modules/apache-arrow/util/vector.mjs
809
794
  var vector_exports = {};
810
795
  __export(vector_exports, {
811
796
  clampIndex: () => clampIndex,
@@ -813,7 +798,7 @@ __export(vector_exports, {
813
798
  createElementComparator: () => createElementComparator
814
799
  });
815
800
 
816
- // ../../node_modules/apache-arrow/util/pretty.mjs
801
+ // ../core/node_modules/apache-arrow/util/pretty.mjs
817
802
  var undf = void 0;
818
803
  function valueToString(x) {
819
804
  if (x === null) {
@@ -842,7 +827,7 @@ function valueToString(x) {
842
827
  return ArrayBuffer.isView(x) ? `[${x}]` : JSON.stringify(x, (_, y) => typeof y === "bigint" ? `${y}` : y);
843
828
  }
844
829
 
845
- // ../../node_modules/apache-arrow/util/bn.mjs
830
+ // ../core/node_modules/apache-arrow/util/bn.mjs
846
831
  var bn_exports = {};
847
832
  __export(bn_exports, {
848
833
  BN: () => BN,
@@ -911,15 +896,8 @@ function bignumToNumber(bn) {
911
896
  }
912
897
  return number;
913
898
  }
914
- var bignumToString;
915
- var bignumToBigInt;
916
- if (!BigIntAvailable) {
917
- bignumToString = decimalToString;
918
- bignumToBigInt = bignumToString;
919
- } else {
920
- bignumToBigInt = (a) => a.byteLength === 8 ? new a["BigIntArray"](a.buffer, a.byteOffset, 1)[0] : decimalToString(a);
921
- bignumToString = (a) => a.byteLength === 8 ? `${new a["BigIntArray"](a.buffer, a.byteOffset, 1)[0]}` : decimalToString(a);
922
- }
899
+ var bignumToString = (a) => a.byteLength === 8 ? `${new a["BigIntArray"](a.buffer, a.byteOffset, 1)[0]}` : decimalToString(a);
900
+ var bignumToBigInt = (a) => a.byteLength === 8 ? new a["BigIntArray"](a.buffer, a.byteOffset, 1)[0] : decimalToString(a);
923
901
  function decimalToString(a) {
924
902
  let digits = "";
925
903
  const base64 = new Uint32Array(2);
@@ -976,7 +954,15 @@ var BN = class {
976
954
  }
977
955
  };
978
956
 
979
- // ../../node_modules/apache-arrow/type.mjs
957
+ // ../core/node_modules/apache-arrow/util/bigint.mjs
958
+ function bigIntToNumber(number) {
959
+ if (typeof number === "bigint" && (number < Number.MIN_SAFE_INTEGER || number > Number.MAX_SAFE_INTEGER)) {
960
+ throw new TypeError(`${number} is not safe to convert to a number.`);
961
+ }
962
+ return Number(number);
963
+ }
964
+
965
+ // ../core/node_modules/apache-arrow/type.mjs
980
966
  var _a;
981
967
  var _b;
982
968
  var _c;
@@ -1548,7 +1534,7 @@ var Dictionary = class extends DataType {
1548
1534
  this.indices = indices;
1549
1535
  this.dictionary = dictionary;
1550
1536
  this.isOrdered = isOrdered || false;
1551
- this.id = id == null ? getId() : typeof id === "number" ? id : id.low;
1537
+ this.id = id == null ? getId() : bigIntToNumber(id);
1552
1538
  }
1553
1539
  get typeId() {
1554
1540
  return Type.Dictionary;
@@ -1594,7 +1580,7 @@ function strideForType(type) {
1594
1580
  }
1595
1581
  }
1596
1582
 
1597
- // ../../node_modules/apache-arrow/visitor.mjs
1583
+ // ../core/node_modules/apache-arrow/visitor.mjs
1598
1584
  var Visitor = class {
1599
1585
  visitMany(nodes, ...args) {
1600
1586
  return nodes.map((node, i) => this.visit(node, ...args.map((x) => x[i])));
@@ -1942,7 +1928,7 @@ Visitor.prototype.visitSparseUnion = null;
1942
1928
  Visitor.prototype.visitIntervalDayTime = null;
1943
1929
  Visitor.prototype.visitIntervalYearMonth = null;
1944
1930
 
1945
- // ../../node_modules/apache-arrow/util/math.mjs
1931
+ // ../core/node_modules/apache-arrow/util/math.mjs
1946
1932
  var math_exports = {};
1947
1933
  __export(math_exports, {
1948
1934
  float64ToUint16: () => float64ToUint16,
@@ -1987,7 +1973,7 @@ function float64ToUint16(d) {
1987
1973
  return sign | expo | sigf & 65535;
1988
1974
  }
1989
1975
 
1990
- // ../../node_modules/apache-arrow/visitor/set.mjs
1976
+ // ../core/node_modules/apache-arrow/visitor/set.mjs
1991
1977
  var SetVisitor = class extends Visitor {
1992
1978
  };
1993
1979
  function wrapSet(fn) {
@@ -2218,7 +2204,7 @@ SetVisitor.prototype.visitFixedSizeList = wrapSet(setFixedSizeList);
2218
2204
  SetVisitor.prototype.visitMap = wrapSet(setMap);
2219
2205
  var instance = new SetVisitor();
2220
2206
 
2221
- // ../../node_modules/apache-arrow/row/struct.mjs
2207
+ // ../core/node_modules/apache-arrow/row/struct.mjs
2222
2208
  var kParent = Symbol.for("parent");
2223
2209
  var kRowIndex = Symbol.for("rowIndex");
2224
2210
  var StructRow = class {
@@ -2326,7 +2312,7 @@ var StructRowProxyHandler = class {
2326
2312
  }
2327
2313
  };
2328
2314
 
2329
- // ../../node_modules/apache-arrow/visitor/get.mjs
2315
+ // ../core/node_modules/apache-arrow/visitor/get.mjs
2330
2316
  var GetVisitor = class extends Visitor {
2331
2317
  };
2332
2318
  function wrapGet(fn) {
@@ -2493,7 +2479,7 @@ GetVisitor.prototype.visitFixedSizeList = wrapGet(getFixedSizeList);
2493
2479
  GetVisitor.prototype.visitMap = wrapGet(getMap);
2494
2480
  var instance2 = new GetVisitor();
2495
2481
 
2496
- // ../../node_modules/apache-arrow/row/map.mjs
2482
+ // ../core/node_modules/apache-arrow/row/map.mjs
2497
2483
  var kKeys = Symbol.for("keys");
2498
2484
  var kVals = Symbol.for("vals");
2499
2485
  var MapRow = class {
@@ -2603,7 +2589,7 @@ Object.defineProperties(MapRow.prototype, {
2603
2589
  [kVals]: { writable: true, enumerable: false, configurable: false, value: null }
2604
2590
  });
2605
2591
 
2606
- // ../../node_modules/apache-arrow/util/vector.mjs
2592
+ // ../core/node_modules/apache-arrow/util/vector.mjs
2607
2593
  function clampIndex(source, index, then) {
2608
2594
  const length2 = source.length;
2609
2595
  const adjust = index > -1 ? index : length2 + index % length2;
@@ -2745,7 +2731,7 @@ function compareObject(comparators, obj, keys) {
2745
2731
  return false;
2746
2732
  }
2747
2733
 
2748
- // ../../node_modules/apache-arrow/util/bit.mjs
2734
+ // ../core/node_modules/apache-arrow/util/bit.mjs
2749
2735
  var bit_exports = {};
2750
2736
  __export(bit_exports, {
2751
2737
  BitIterator: () => BitIterator,
@@ -2868,34 +2854,9 @@ function popcnt_uint32(uint32) {
2868
2854
  return (i + (i >>> 4) & 252645135) * 16843009 >>> 24;
2869
2855
  }
2870
2856
 
2871
- // ../../node_modules/apache-arrow/data.mjs
2857
+ // ../core/node_modules/apache-arrow/data.mjs
2872
2858
  var kUnknownNullCount = -1;
2873
2859
  var Data = class {
2874
- constructor(type, offset, length2, nullCount, buffers, children = [], dictionary) {
2875
- this.type = type;
2876
- this.children = children;
2877
- this.dictionary = dictionary;
2878
- this.offset = Math.floor(Math.max(offset || 0, 0));
2879
- this.length = Math.floor(Math.max(length2 || 0, 0));
2880
- this._nullCount = Math.floor(Math.max(nullCount || 0, -1));
2881
- let buffer;
2882
- if (buffers instanceof Data) {
2883
- this.stride = buffers.stride;
2884
- this.values = buffers.values;
2885
- this.typeIds = buffers.typeIds;
2886
- this.nullBitmap = buffers.nullBitmap;
2887
- this.valueOffsets = buffers.valueOffsets;
2888
- } else {
2889
- this.stride = strideForType(type);
2890
- if (buffers) {
2891
- (buffer = buffers[0]) && (this.valueOffsets = buffer);
2892
- (buffer = buffers[1]) && (this.values = buffer);
2893
- (buffer = buffers[2]) && (this.nullBitmap = buffer);
2894
- (buffer = buffers[3]) && (this.typeIds = buffer);
2895
- }
2896
- }
2897
- this.nullable = this._nullCount !== 0 && this.nullBitmap && this.nullBitmap.byteLength > 0;
2898
- }
2899
2860
  get typeId() {
2900
2861
  return this.type.typeId;
2901
2862
  }
@@ -2922,6 +2883,31 @@ var Data = class {
2922
2883
  }
2923
2884
  return nullCount;
2924
2885
  }
2886
+ constructor(type, offset, length2, nullCount, buffers, children = [], dictionary) {
2887
+ this.type = type;
2888
+ this.children = children;
2889
+ this.dictionary = dictionary;
2890
+ this.offset = Math.floor(Math.max(offset || 0, 0));
2891
+ this.length = Math.floor(Math.max(length2 || 0, 0));
2892
+ this._nullCount = Math.floor(Math.max(nullCount || 0, -1));
2893
+ let buffer;
2894
+ if (buffers instanceof Data) {
2895
+ this.stride = buffers.stride;
2896
+ this.values = buffers.values;
2897
+ this.typeIds = buffers.typeIds;
2898
+ this.nullBitmap = buffers.nullBitmap;
2899
+ this.valueOffsets = buffers.valueOffsets;
2900
+ } else {
2901
+ this.stride = strideForType(type);
2902
+ if (buffers) {
2903
+ (buffer = buffers[0]) && (this.valueOffsets = buffer);
2904
+ (buffer = buffers[1]) && (this.values = buffer);
2905
+ (buffer = buffers[2]) && (this.nullBitmap = buffer);
2906
+ (buffer = buffers[3]) && (this.typeIds = buffer);
2907
+ }
2908
+ }
2909
+ this.nullable = this._nullCount !== 0 && this.nullBitmap && this.nullBitmap.byteLength > 0;
2910
+ }
2925
2911
  getValid(index) {
2926
2912
  if (this.nullable && this.nullCount > 0) {
2927
2913
  const pos = this.offset + index;
@@ -3127,7 +3113,7 @@ function makeData(props) {
3127
3113
  return new MakeDataVisitor().visit(props);
3128
3114
  }
3129
3115
 
3130
- // ../../node_modules/apache-arrow/util/chunk.mjs
3116
+ // ../core/node_modules/apache-arrow/util/chunk.mjs
3131
3117
  var ChunkedIterator = class {
3132
3118
  constructor(numChunks = 0, getChunkIterator) {
3133
3119
  this.numChunks = numChunks;
@@ -3243,7 +3229,7 @@ function wrapChunkedIndexOf(indexOf) {
3243
3229
  };
3244
3230
  }
3245
3231
 
3246
- // ../../node_modules/apache-arrow/visitor/indexof.mjs
3232
+ // ../core/node_modules/apache-arrow/visitor/indexof.mjs
3247
3233
  var IndexOfVisitor = class extends Visitor {
3248
3234
  };
3249
3235
  function nullIndexOf(data, searchElement) {
@@ -3334,7 +3320,7 @@ IndexOfVisitor.prototype.visitFixedSizeList = indexOfValue;
3334
3320
  IndexOfVisitor.prototype.visitMap = indexOfValue;
3335
3321
  var instance3 = new IndexOfVisitor();
3336
3322
 
3337
- // ../../node_modules/apache-arrow/visitor/iterator.mjs
3323
+ // ../core/node_modules/apache-arrow/visitor/iterator.mjs
3338
3324
  var IteratorVisitor = class extends Visitor {
3339
3325
  };
3340
3326
  function vectorIterator(vector) {
@@ -3416,7 +3402,7 @@ IteratorVisitor.prototype.visitFixedSizeList = vectorIterator;
3416
3402
  IteratorVisitor.prototype.visitMap = vectorIterator;
3417
3403
  var instance4 = new IteratorVisitor();
3418
3404
 
3419
- // ../../node_modules/apache-arrow/visitor/bytelength.mjs
3405
+ // ../core/node_modules/apache-arrow/visitor/bytelength.mjs
3420
3406
  var sum = (x, y) => x + y;
3421
3407
  var GetByteLengthVisitor = class extends Visitor {
3422
3408
  visitNull(____, _) {
@@ -3470,21 +3456,21 @@ var getListByteLength = ({ valueOffsets, stride, children }, index) => {
3470
3456
  const child = children[0];
3471
3457
  const { [index * stride]: start } = valueOffsets;
3472
3458
  const { [index * stride + 1]: end } = valueOffsets;
3473
- const visit = instance5.getVisitFn(child.type);
3459
+ const visit2 = instance5.getVisitFn(child.type);
3474
3460
  const slice = child.slice(start, end - start);
3475
3461
  let size = 8;
3476
3462
  for (let idx = -1, len = end - start; ++idx < len; ) {
3477
- size += visit(slice, idx);
3463
+ size += visit2(slice, idx);
3478
3464
  }
3479
3465
  return size;
3480
3466
  };
3481
3467
  var getFixedSizeListByteLength = ({ stride, children }, index) => {
3482
3468
  const child = children[0];
3483
3469
  const slice = child.slice(index * stride, stride);
3484
- const visit = instance5.getVisitFn(child.type);
3470
+ const visit2 = instance5.getVisitFn(child.type);
3485
3471
  let size = 0;
3486
3472
  for (let idx = -1, len = slice.length; ++idx < len; ) {
3487
- size += visit(slice, idx);
3473
+ size += visit2(slice, idx);
3488
3474
  }
3489
3475
  return size;
3490
3476
  };
@@ -3507,7 +3493,7 @@ GetByteLengthVisitor.prototype.visitDenseUnion = getDenseUnionByteLength;
3507
3493
  GetByteLengthVisitor.prototype.visitSparseUnion = getSparseUnionByteLength;
3508
3494
  var instance5 = new GetByteLengthVisitor();
3509
3495
 
3510
- // ../../node_modules/apache-arrow/vector.mjs
3496
+ // ../core/node_modules/apache-arrow/vector.mjs
3511
3497
  var _a2;
3512
3498
  var visitorsByTypeId = {};
3513
3499
  var vectorPrototypesByTypeId = {};
@@ -3824,7 +3810,7 @@ var MemoizedVector = class extends Vector {
3824
3810
  }
3825
3811
  };
3826
3812
 
3827
- // ../../node_modules/apache-arrow/builder/valid.mjs
3813
+ // ../core/node_modules/apache-arrow/builder/valid.mjs
3828
3814
  function createIsValidFunction(nullValues) {
3829
3815
  if (!nullValues || nullValues.length <= 0) {
3830
3816
  return function isValid(value) {
@@ -3850,13 +3836,11 @@ return true;`);
3850
3836
  function valueToCase(x) {
3851
3837
  if (typeof x !== "bigint") {
3852
3838
  return valueToString(x);
3853
- } else if (BigIntAvailable) {
3854
- return `${valueToString(x)}n`;
3855
3839
  }
3856
- return `"${valueToString(x)}"`;
3840
+ return `${valueToString(x)}n`;
3857
3841
  }
3858
3842
 
3859
- // ../../node_modules/apache-arrow/builder/buffer.mjs
3843
+ // ../core/node_modules/apache-arrow/builder/buffer.mjs
3860
3844
  var roundLengthUpToNearest64Bytes = (len, BPE) => (Math.ceil(len) * BPE + 63 & ~63 || 64) / BPE;
3861
3845
  var sliceOrExtendArray = (arr, len = 0) => arr.length >= len ? arr.subarray(0, len) : memcpy(new arr.constructor(len), arr, 0);
3862
3846
  var BufferBuilder = class {
@@ -3970,8 +3954,18 @@ var OffsetsBufferBuilder = class extends DataBufferBuilder {
3970
3954
  }
3971
3955
  };
3972
3956
 
3973
- // ../../node_modules/apache-arrow/builder.mjs
3957
+ // ../core/node_modules/apache-arrow/builder.mjs
3974
3958
  var Builder = class {
3959
+ /** @nocollapse */
3960
+ // @ts-ignore
3961
+ static throughNode(options) {
3962
+ throw new Error(`"throughNode" not available in this environment`);
3963
+ }
3964
+ /** @nocollapse */
3965
+ // @ts-ignore
3966
+ static throughDOM(options) {
3967
+ throw new Error(`"throughDOM" not available in this environment`);
3968
+ }
3975
3969
  /**
3976
3970
  * Construct a builder with the given Arrow DataType with optional null values,
3977
3971
  * which will be interpreted as "null" when set or appended to the `Builder`.
@@ -3989,16 +3983,6 @@ var Builder = class {
3989
3983
  this._isValid = createIsValidFunction(nulls);
3990
3984
  }
3991
3985
  }
3992
- /** @nocollapse */
3993
- // @ts-ignore
3994
- static throughNode(options) {
3995
- throw new Error(`"throughNode" not available in this environment`);
3996
- }
3997
- /** @nocollapse */
3998
- // @ts-ignore
3999
- static throughDOM(options) {
4000
- throw new Error(`"throughDOM" not available in this environment`);
4001
- }
4002
3986
  /**
4003
3987
  * Flush the `Builder` and return a `Vector<T>`.
4004
3988
  * @returns {Vector<T>} A `Vector<T>` of the flushed values.
@@ -4237,7 +4221,7 @@ var VariableWidthBuilder = class extends Builder {
4237
4221
  }
4238
4222
  };
4239
4223
 
4240
- // ../../node_modules/apache-arrow/fb/block.mjs
4224
+ // ../core/node_modules/apache-arrow/fb/block.mjs
4241
4225
  var Block = class {
4242
4226
  constructor() {
4243
4227
  this.bb = null;
@@ -4272,52 +4256,34 @@ var Block = class {
4272
4256
  }
4273
4257
  static createBlock(builder, offset, metaDataLength, bodyLength) {
4274
4258
  builder.prep(8, 24);
4275
- builder.writeInt64(bodyLength);
4259
+ builder.writeInt64(BigInt(bodyLength !== null && bodyLength !== void 0 ? bodyLength : 0));
4276
4260
  builder.pad(4);
4277
4261
  builder.writeInt32(metaDataLength);
4278
- builder.writeInt64(offset);
4262
+ builder.writeInt64(BigInt(offset !== null && offset !== void 0 ? offset : 0));
4279
4263
  return builder.offset();
4280
4264
  }
4281
4265
  };
4282
4266
 
4283
- // ../../node_modules/flatbuffers/mjs/constants.js
4267
+ // ../core/node_modules/flatbuffers/mjs/constants.js
4284
4268
  var SIZEOF_SHORT = 2;
4285
4269
  var SIZEOF_INT = 4;
4286
4270
  var FILE_IDENTIFIER_LENGTH = 4;
4287
4271
  var SIZE_PREFIX_LENGTH = 4;
4288
4272
 
4289
- // ../../node_modules/flatbuffers/mjs/utils.js
4273
+ // ../core/node_modules/flatbuffers/mjs/utils.js
4290
4274
  var int32 = new Int32Array(2);
4291
4275
  var float32 = new Float32Array(int32.buffer);
4292
4276
  var float64 = new Float64Array(int32.buffer);
4293
4277
  var isLittleEndian = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
4294
4278
 
4295
- // ../../node_modules/flatbuffers/mjs/long.js
4296
- var Long = class {
4297
- constructor(low, high) {
4298
- this.low = low | 0;
4299
- this.high = high | 0;
4300
- }
4301
- static create(low, high) {
4302
- return low == 0 && high == 0 ? Long.ZERO : new Long(low, high);
4303
- }
4304
- toFloat64() {
4305
- return (this.low >>> 0) + this.high * 4294967296;
4306
- }
4307
- equals(other) {
4308
- return this.low == other.low && this.high == other.high;
4309
- }
4310
- };
4311
- Long.ZERO = new Long(0, 0);
4312
-
4313
- // ../../node_modules/flatbuffers/mjs/encoding.js
4279
+ // ../core/node_modules/flatbuffers/mjs/encoding.js
4314
4280
  var Encoding;
4315
4281
  (function(Encoding2) {
4316
4282
  Encoding2[Encoding2["UTF8_BYTES"] = 1] = "UTF8_BYTES";
4317
4283
  Encoding2[Encoding2["UTF16_STRING"] = 2] = "UTF16_STRING";
4318
4284
  })(Encoding || (Encoding = {}));
4319
4285
 
4320
- // ../../node_modules/flatbuffers/mjs/byte-buffer.js
4286
+ // ../core/node_modules/flatbuffers/mjs/byte-buffer.js
4321
4287
  var ByteBuffer = class {
4322
4288
  /**
4323
4289
  * Create a new ByteBuffer with a given array of bytes (`Uint8Array`)
@@ -4325,6 +4291,7 @@ var ByteBuffer = class {
4325
4291
  constructor(bytes_) {
4326
4292
  this.bytes_ = bytes_;
4327
4293
  this.position_ = 0;
4294
+ this.text_decoder_ = new TextDecoder();
4328
4295
  }
4329
4296
  /**
4330
4297
  * Create and allocate a new ByteBuffer with a given size.
@@ -4378,10 +4345,10 @@ var ByteBuffer = class {
4378
4345
  return this.readInt32(offset) >>> 0;
4379
4346
  }
4380
4347
  readInt64(offset) {
4381
- return new Long(this.readInt32(offset), this.readInt32(offset + 4));
4348
+ return BigInt.asIntN(64, BigInt(this.readUint32(offset)) + (BigInt(this.readUint32(offset + 4)) << BigInt(32)));
4382
4349
  }
4383
4350
  readUint64(offset) {
4384
- return new Long(this.readUint32(offset), this.readUint32(offset + 4));
4351
+ return BigInt.asUintN(64, BigInt(this.readUint32(offset)) + (BigInt(this.readUint32(offset + 4)) << BigInt(32)));
4385
4352
  }
4386
4353
  readFloat32(offset) {
4387
4354
  int32[0] = this.readInt32(offset);
@@ -4419,12 +4386,12 @@ var ByteBuffer = class {
4419
4386
  this.bytes_[offset + 3] = value >> 24;
4420
4387
  }
4421
4388
  writeInt64(offset, value) {
4422
- this.writeInt32(offset, value.low);
4423
- this.writeInt32(offset + 4, value.high);
4389
+ this.writeInt32(offset, Number(BigInt.asIntN(32, value)));
4390
+ this.writeInt32(offset + 4, Number(BigInt.asIntN(32, value >> BigInt(32))));
4424
4391
  }
4425
4392
  writeUint64(offset, value) {
4426
- this.writeUint32(offset, value.low);
4427
- this.writeUint32(offset + 4, value.high);
4393
+ this.writeUint32(offset, Number(BigInt.asUintN(32, value)));
4394
+ this.writeUint32(offset + 4, Number(BigInt.asUintN(32, value >> BigInt(32))));
4428
4395
  }
4429
4396
  writeFloat32(offset, value) {
4430
4397
  float32[0] = value;
@@ -4470,10 +4437,9 @@ var ByteBuffer = class {
4470
4437
  * Create a JavaScript string from UTF-8 data stored inside the FlatBuffer.
4471
4438
  * This allocates a new string and converts to wide chars upon each access.
4472
4439
  *
4473
- * To avoid the conversion to UTF-16, pass Encoding.UTF8_BYTES as
4474
- * the "optionalEncoding" argument. This is useful for avoiding conversion to
4475
- * and from UTF-16 when the data will just be packaged back up in another
4476
- * FlatBuffer later on.
4440
+ * To avoid the conversion to string, pass Encoding.UTF8_BYTES as the
4441
+ * "optionalEncoding" argument. This is useful for avoiding conversion when
4442
+ * the data will just be packaged back up in another FlatBuffer later on.
4477
4443
  *
4478
4444
  * @param offset
4479
4445
  * @param opt_encoding Defaults to UTF16_STRING
@@ -4481,39 +4447,12 @@ var ByteBuffer = class {
4481
4447
  __string(offset, opt_encoding) {
4482
4448
  offset += this.readInt32(offset);
4483
4449
  const length2 = this.readInt32(offset);
4484
- let result = "";
4485
- let i = 0;
4486
4450
  offset += SIZEOF_INT;
4487
- if (opt_encoding === Encoding.UTF8_BYTES) {
4488
- return this.bytes_.subarray(offset, offset + length2);
4489
- }
4490
- while (i < length2) {
4491
- let codePoint;
4492
- const a = this.readUint8(offset + i++);
4493
- if (a < 192) {
4494
- codePoint = a;
4495
- } else {
4496
- const b = this.readUint8(offset + i++);
4497
- if (a < 224) {
4498
- codePoint = (a & 31) << 6 | b & 63;
4499
- } else {
4500
- const c = this.readUint8(offset + i++);
4501
- if (a < 240) {
4502
- codePoint = (a & 15) << 12 | (b & 63) << 6 | c & 63;
4503
- } else {
4504
- const d = this.readUint8(offset + i++);
4505
- codePoint = (a & 7) << 18 | (b & 63) << 12 | (c & 63) << 6 | d & 63;
4506
- }
4507
- }
4508
- }
4509
- if (codePoint < 65536) {
4510
- result += String.fromCharCode(codePoint);
4511
- } else {
4512
- codePoint -= 65536;
4513
- result += String.fromCharCode((codePoint >> 10) + 55296, (codePoint & (1 << 10) - 1) + 56320);
4514
- }
4515
- }
4516
- return result;
4451
+ const utf8bytes = this.bytes_.subarray(offset, offset + length2);
4452
+ if (opt_encoding === Encoding.UTF8_BYTES)
4453
+ return utf8bytes;
4454
+ else
4455
+ return this.text_decoder_.decode(utf8bytes);
4517
4456
  }
4518
4457
  /**
4519
4458
  * Handle unions that can contain string as its member, if a Table-derived type then initialize it,
@@ -4557,20 +4496,15 @@ var ByteBuffer = class {
4557
4496
  }
4558
4497
  return true;
4559
4498
  }
4560
- /**
4561
- * A helper function to avoid generated code depending on this file directly.
4562
- */
4563
- createLong(low, high) {
4564
- return Long.create(low, high);
4565
- }
4566
4499
  /**
4567
4500
  * A helper function for generating list for obj api
4568
4501
  */
4569
4502
  createScalarList(listAccessor, listLength) {
4570
4503
  const ret = [];
4571
4504
  for (let i = 0; i < listLength; ++i) {
4572
- if (listAccessor(i) !== null) {
4573
- ret.push(listAccessor(i));
4505
+ const val = listAccessor(i);
4506
+ if (val !== null) {
4507
+ ret.push(val);
4574
4508
  }
4575
4509
  }
4576
4510
  return ret;
@@ -4593,7 +4527,7 @@ var ByteBuffer = class {
4593
4527
  }
4594
4528
  };
4595
4529
 
4596
- // ../../node_modules/flatbuffers/mjs/builder.js
4530
+ // ../core/node_modules/flatbuffers/mjs/builder.js
4597
4531
  var Builder2 = class {
4598
4532
  /**
4599
4533
  * Create a FlatBufferBuilder.
@@ -4608,6 +4542,7 @@ var Builder2 = class {
4608
4542
  this.vector_num_elems = 0;
4609
4543
  this.force_defaults = false;
4610
4544
  this.string_maps = null;
4545
+ this.text_encoder = new TextEncoder();
4611
4546
  let initial_size;
4612
4547
  if (!opt_initial_size) {
4613
4548
  initial_size = 1024;
@@ -4701,7 +4636,7 @@ var Builder2 = class {
4701
4636
  }
4702
4637
  /**
4703
4638
  * Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).
4704
- * @param value The `int8` to add the the buffer.
4639
+ * @param value The `int8` to add the buffer.
4705
4640
  */
4706
4641
  addInt8(value) {
4707
4642
  this.prep(1, 0);
@@ -4709,7 +4644,7 @@ var Builder2 = class {
4709
4644
  }
4710
4645
  /**
4711
4646
  * Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).
4712
- * @param value The `int16` to add the the buffer.
4647
+ * @param value The `int16` to add the buffer.
4713
4648
  */
4714
4649
  addInt16(value) {
4715
4650
  this.prep(2, 0);
@@ -4717,7 +4652,7 @@ var Builder2 = class {
4717
4652
  }
4718
4653
  /**
4719
4654
  * Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).
4720
- * @param value The `int32` to add the the buffer.
4655
+ * @param value The `int32` to add the buffer.
4721
4656
  */
4722
4657
  addInt32(value) {
4723
4658
  this.prep(4, 0);
@@ -4725,7 +4660,7 @@ var Builder2 = class {
4725
4660
  }
4726
4661
  /**
4727
4662
  * Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
4728
- * @param value The `int64` to add the the buffer.
4663
+ * @param value The `int64` to add the buffer.
4729
4664
  */
4730
4665
  addInt64(value) {
4731
4666
  this.prep(8, 0);
@@ -4733,7 +4668,7 @@ var Builder2 = class {
4733
4668
  }
4734
4669
  /**
4735
4670
  * Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).
4736
- * @param value The `float32` to add the the buffer.
4671
+ * @param value The `float32` to add the buffer.
4737
4672
  */
4738
4673
  addFloat32(value) {
4739
4674
  this.prep(4, 0);
@@ -4741,7 +4676,7 @@ var Builder2 = class {
4741
4676
  }
4742
4677
  /**
4743
4678
  * Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).
4744
- * @param value The `float64` to add the the buffer.
4679
+ * @param value The `float64` to add the buffer.
4745
4680
  */
4746
4681
  addFloat64(value) {
4747
4682
  this.prep(8, 0);
@@ -4766,7 +4701,7 @@ var Builder2 = class {
4766
4701
  }
4767
4702
  }
4768
4703
  addFieldInt64(voffset, value, defaultValue) {
4769
- if (this.force_defaults || !value.equals(defaultValue)) {
4704
+ if (this.force_defaults || value !== defaultValue) {
4770
4705
  this.addInt64(value);
4771
4706
  this.slot(voffset);
4772
4707
  }
@@ -4961,7 +4896,7 @@ var Builder2 = class {
4961
4896
  requiredField(table, field) {
4962
4897
  const table_start = this.bb.capacity() - table;
4963
4898
  const vtable_start = table_start - this.bb.readInt32(table_start);
4964
- const ok = this.bb.readInt16(vtable_start + field) != 0;
4899
+ const ok = field < this.bb.readInt16(vtable_start) && this.bb.readInt16(vtable_start + field) != 0;
4965
4900
  if (!ok) {
4966
4901
  throw new Error("FlatBuffers: field " + field + " must be set");
4967
4902
  }
@@ -5021,40 +4956,14 @@ var Builder2 = class {
5021
4956
  * @return The offset in the buffer where the encoded string starts
5022
4957
  */
5023
4958
  createString(s) {
5024
- if (!s) {
4959
+ if (s === null || s === void 0) {
5025
4960
  return 0;
5026
4961
  }
5027
4962
  let utf8;
5028
4963
  if (s instanceof Uint8Array) {
5029
4964
  utf8 = s;
5030
4965
  } else {
5031
- utf8 = [];
5032
- let i = 0;
5033
- while (i < s.length) {
5034
- let codePoint;
5035
- const a = s.charCodeAt(i++);
5036
- if (a < 55296 || a >= 56320) {
5037
- codePoint = a;
5038
- } else {
5039
- const b = s.charCodeAt(i++);
5040
- codePoint = (a << 10) + b + (65536 - (55296 << 10) - 56320);
5041
- }
5042
- if (codePoint < 128) {
5043
- utf8.push(codePoint);
5044
- } else {
5045
- if (codePoint < 2048) {
5046
- utf8.push(codePoint >> 6 & 31 | 192);
5047
- } else {
5048
- if (codePoint < 65536) {
5049
- utf8.push(codePoint >> 12 & 15 | 224);
5050
- } else {
5051
- utf8.push(codePoint >> 18 & 7 | 240, codePoint >> 12 & 63 | 128);
5052
- }
5053
- utf8.push(codePoint >> 6 & 63 | 128);
5054
- }
5055
- utf8.push(codePoint & 63 | 128);
5056
- }
5057
- }
4966
+ utf8 = this.text_encoder.encode(s);
5058
4967
  }
5059
4968
  this.addInt8(0);
5060
4969
  this.startVector(1, utf8.length, 1);
@@ -5064,12 +4973,6 @@ var Builder2 = class {
5064
4973
  }
5065
4974
  return this.endVector();
5066
4975
  }
5067
- /**
5068
- * A helper function to avoid generated code depending on this file directly.
5069
- */
5070
- createLong(low, high) {
5071
- return Long.create(low, high);
5072
- }
5073
4976
  /**
5074
4977
  * A helper function to pack an object
5075
4978
  *
@@ -5104,12 +5007,12 @@ var Builder2 = class {
5104
5007
  }
5105
5008
  createStructOffsetList(list, startFunc) {
5106
5009
  startFunc(this, list.length);
5107
- this.createObjectOffsetList(list);
5010
+ this.createObjectOffsetList(list.slice().reverse());
5108
5011
  return this.endVector();
5109
5012
  }
5110
5013
  };
5111
5014
 
5112
- // ../../node_modules/apache-arrow/fb/key-value.mjs
5015
+ // ../core/node_modules/apache-arrow/fb/key-value.mjs
5113
5016
  var KeyValue = class {
5114
5017
  constructor() {
5115
5018
  this.bb = null;
@@ -5156,7 +5059,7 @@ var KeyValue = class {
5156
5059
  }
5157
5060
  };
5158
5061
 
5159
- // ../../node_modules/apache-arrow/fb/metadata-version.mjs
5062
+ // ../core/node_modules/apache-arrow/fb/metadata-version.mjs
5160
5063
  var MetadataVersion2;
5161
5064
  (function(MetadataVersion3) {
5162
5065
  MetadataVersion3[MetadataVersion3["V1"] = 0] = "V1";
@@ -5166,20 +5069,20 @@ var MetadataVersion2;
5166
5069
  MetadataVersion3[MetadataVersion3["V5"] = 4] = "V5";
5167
5070
  })(MetadataVersion2 || (MetadataVersion2 = {}));
5168
5071
 
5169
- // ../../node_modules/apache-arrow/fb/endianness.mjs
5072
+ // ../core/node_modules/apache-arrow/fb/endianness.mjs
5170
5073
  var Endianness;
5171
5074
  (function(Endianness2) {
5172
5075
  Endianness2[Endianness2["Little"] = 0] = "Little";
5173
5076
  Endianness2[Endianness2["Big"] = 1] = "Big";
5174
5077
  })(Endianness || (Endianness = {}));
5175
5078
 
5176
- // ../../node_modules/apache-arrow/fb/dictionary-kind.mjs
5079
+ // ../core/node_modules/apache-arrow/fb/dictionary-kind.mjs
5177
5080
  var DictionaryKind;
5178
5081
  (function(DictionaryKind2) {
5179
5082
  DictionaryKind2[DictionaryKind2["DenseArray"] = 0] = "DenseArray";
5180
5083
  })(DictionaryKind || (DictionaryKind = {}));
5181
5084
 
5182
- // ../../node_modules/apache-arrow/fb/int.mjs
5085
+ // ../core/node_modules/apache-arrow/fb/int.mjs
5183
5086
  var Int = class {
5184
5087
  constructor() {
5185
5088
  this.bb = null;
@@ -5226,7 +5129,7 @@ var Int = class {
5226
5129
  }
5227
5130
  };
5228
5131
 
5229
- // ../../node_modules/apache-arrow/fb/dictionary-encoding.mjs
5132
+ // ../core/node_modules/apache-arrow/fb/dictionary-encoding.mjs
5230
5133
  var DictionaryEncoding = class {
5231
5134
  constructor() {
5232
5135
  this.bb = null;
@@ -5251,7 +5154,7 @@ var DictionaryEncoding = class {
5251
5154
  */
5252
5155
  id() {
5253
5156
  const offset = this.bb.__offset(this.bb_pos, 4);
5254
- return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);
5157
+ return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt("0");
5255
5158
  }
5256
5159
  /**
5257
5160
  * The dictionary indices are constrained to be non-negative integers. If
@@ -5282,7 +5185,7 @@ var DictionaryEncoding = class {
5282
5185
  builder.startObject(4);
5283
5186
  }
5284
5187
  static addId(builder, id) {
5285
- builder.addFieldInt64(0, id, builder.createLong(0, 0));
5188
+ builder.addFieldInt64(0, id, BigInt("0"));
5286
5189
  }
5287
5190
  static addIndexType(builder, indexTypeOffset) {
5288
5191
  builder.addFieldOffset(1, indexTypeOffset, 0);
@@ -5299,7 +5202,7 @@ var DictionaryEncoding = class {
5299
5202
  }
5300
5203
  };
5301
5204
 
5302
- // ../../node_modules/apache-arrow/fb/binary.mjs
5205
+ // ../core/node_modules/apache-arrow/fb/binary.mjs
5303
5206
  var Binary2 = class {
5304
5207
  constructor() {
5305
5208
  this.bb = null;
@@ -5330,7 +5233,7 @@ var Binary2 = class {
5330
5233
  }
5331
5234
  };
5332
5235
 
5333
- // ../../node_modules/apache-arrow/fb/bool.mjs
5236
+ // ../core/node_modules/apache-arrow/fb/bool.mjs
5334
5237
  var Bool2 = class {
5335
5238
  constructor() {
5336
5239
  this.bb = null;
@@ -5361,14 +5264,14 @@ var Bool2 = class {
5361
5264
  }
5362
5265
  };
5363
5266
 
5364
- // ../../node_modules/apache-arrow/fb/date-unit.mjs
5267
+ // ../core/node_modules/apache-arrow/fb/date-unit.mjs
5365
5268
  var DateUnit2;
5366
5269
  (function(DateUnit3) {
5367
5270
  DateUnit3[DateUnit3["DAY"] = 0] = "DAY";
5368
5271
  DateUnit3[DateUnit3["MILLISECOND"] = 1] = "MILLISECOND";
5369
5272
  })(DateUnit2 || (DateUnit2 = {}));
5370
5273
 
5371
- // ../../node_modules/apache-arrow/fb/date.mjs
5274
+ // ../core/node_modules/apache-arrow/fb/date.mjs
5372
5275
  var Date2 = class {
5373
5276
  constructor() {
5374
5277
  this.bb = null;
@@ -5407,7 +5310,7 @@ var Date2 = class {
5407
5310
  }
5408
5311
  };
5409
5312
 
5410
- // ../../node_modules/apache-arrow/fb/decimal.mjs
5313
+ // ../core/node_modules/apache-arrow/fb/decimal.mjs
5411
5314
  var Decimal2 = class {
5412
5315
  constructor() {
5413
5316
  this.bb = null;
@@ -5472,7 +5375,7 @@ var Decimal2 = class {
5472
5375
  }
5473
5376
  };
5474
5377
 
5475
- // ../../node_modules/apache-arrow/fb/time-unit.mjs
5378
+ // ../core/node_modules/apache-arrow/fb/time-unit.mjs
5476
5379
  var TimeUnit2;
5477
5380
  (function(TimeUnit3) {
5478
5381
  TimeUnit3[TimeUnit3["SECOND"] = 0] = "SECOND";
@@ -5481,7 +5384,7 @@ var TimeUnit2;
5481
5384
  TimeUnit3[TimeUnit3["NANOSECOND"] = 3] = "NANOSECOND";
5482
5385
  })(TimeUnit2 || (TimeUnit2 = {}));
5483
5386
 
5484
- // ../../node_modules/apache-arrow/fb/fixed-size-binary.mjs
5387
+ // ../core/node_modules/apache-arrow/fb/fixed-size-binary.mjs
5485
5388
  var FixedSizeBinary2 = class {
5486
5389
  constructor() {
5487
5390
  this.bb = null;
@@ -5523,7 +5426,7 @@ var FixedSizeBinary2 = class {
5523
5426
  }
5524
5427
  };
5525
5428
 
5526
- // ../../node_modules/apache-arrow/fb/fixed-size-list.mjs
5429
+ // ../core/node_modules/apache-arrow/fb/fixed-size-list.mjs
5527
5430
  var FixedSizeList2 = class {
5528
5431
  constructor() {
5529
5432
  this.bb = null;
@@ -5565,7 +5468,7 @@ var FixedSizeList2 = class {
5565
5468
  }
5566
5469
  };
5567
5470
 
5568
- // ../../node_modules/apache-arrow/fb/precision.mjs
5471
+ // ../core/node_modules/apache-arrow/fb/precision.mjs
5569
5472
  var Precision2;
5570
5473
  (function(Precision3) {
5571
5474
  Precision3[Precision3["HALF"] = 0] = "HALF";
@@ -5573,7 +5476,7 @@ var Precision2;
5573
5476
  Precision3[Precision3["DOUBLE"] = 2] = "DOUBLE";
5574
5477
  })(Precision2 || (Precision2 = {}));
5575
5478
 
5576
- // ../../node_modules/apache-arrow/fb/floating-point.mjs
5479
+ // ../core/node_modules/apache-arrow/fb/floating-point.mjs
5577
5480
  var FloatingPoint = class {
5578
5481
  constructor() {
5579
5482
  this.bb = null;
@@ -5612,7 +5515,7 @@ var FloatingPoint = class {
5612
5515
  }
5613
5516
  };
5614
5517
 
5615
- // ../../node_modules/apache-arrow/fb/interval-unit.mjs
5518
+ // ../core/node_modules/apache-arrow/fb/interval-unit.mjs
5616
5519
  var IntervalUnit2;
5617
5520
  (function(IntervalUnit3) {
5618
5521
  IntervalUnit3[IntervalUnit3["YEAR_MONTH"] = 0] = "YEAR_MONTH";
@@ -5620,7 +5523,7 @@ var IntervalUnit2;
5620
5523
  IntervalUnit3[IntervalUnit3["MONTH_DAY_NANO"] = 2] = "MONTH_DAY_NANO";
5621
5524
  })(IntervalUnit2 || (IntervalUnit2 = {}));
5622
5525
 
5623
- // ../../node_modules/apache-arrow/fb/interval.mjs
5526
+ // ../core/node_modules/apache-arrow/fb/interval.mjs
5624
5527
  var Interval = class {
5625
5528
  constructor() {
5626
5529
  this.bb = null;
@@ -5659,7 +5562,7 @@ var Interval = class {
5659
5562
  }
5660
5563
  };
5661
5564
 
5662
- // ../../node_modules/apache-arrow/fb/list.mjs
5565
+ // ../core/node_modules/apache-arrow/fb/list.mjs
5663
5566
  var List2 = class {
5664
5567
  constructor() {
5665
5568
  this.bb = null;
@@ -5690,7 +5593,7 @@ var List2 = class {
5690
5593
  }
5691
5594
  };
5692
5595
 
5693
- // ../../node_modules/apache-arrow/fb/map.mjs
5596
+ // ../core/node_modules/apache-arrow/fb/map.mjs
5694
5597
  var Map2 = class {
5695
5598
  constructor() {
5696
5599
  this.bb = null;
@@ -5732,7 +5635,7 @@ var Map2 = class {
5732
5635
  }
5733
5636
  };
5734
5637
 
5735
- // ../../node_modules/apache-arrow/fb/null.mjs
5638
+ // ../core/node_modules/apache-arrow/fb/null.mjs
5736
5639
  var Null2 = class {
5737
5640
  constructor() {
5738
5641
  this.bb = null;
@@ -5763,7 +5666,7 @@ var Null2 = class {
5763
5666
  }
5764
5667
  };
5765
5668
 
5766
- // ../../node_modules/apache-arrow/fb/struct_.mjs
5669
+ // ../core/node_modules/apache-arrow/fb/struct-.mjs
5767
5670
  var Struct_ = class {
5768
5671
  constructor() {
5769
5672
  this.bb = null;
@@ -5794,7 +5697,7 @@ var Struct_ = class {
5794
5697
  }
5795
5698
  };
5796
5699
 
5797
- // ../../node_modules/apache-arrow/fb/time.mjs
5700
+ // ../core/node_modules/apache-arrow/fb/time.mjs
5798
5701
  var Time = class {
5799
5702
  constructor() {
5800
5703
  this.bb = null;
@@ -5841,7 +5744,7 @@ var Time = class {
5841
5744
  }
5842
5745
  };
5843
5746
 
5844
- // ../../node_modules/apache-arrow/fb/timestamp.mjs
5747
+ // ../core/node_modules/apache-arrow/fb/timestamp.mjs
5845
5748
  var Timestamp = class {
5846
5749
  constructor() {
5847
5750
  this.bb = null;
@@ -5888,14 +5791,14 @@ var Timestamp = class {
5888
5791
  }
5889
5792
  };
5890
5793
 
5891
- // ../../node_modules/apache-arrow/fb/union-mode.mjs
5794
+ // ../core/node_modules/apache-arrow/fb/union-mode.mjs
5892
5795
  var UnionMode2;
5893
5796
  (function(UnionMode3) {
5894
5797
  UnionMode3[UnionMode3["Sparse"] = 0] = "Sparse";
5895
5798
  UnionMode3[UnionMode3["Dense"] = 1] = "Dense";
5896
5799
  })(UnionMode2 || (UnionMode2 = {}));
5897
5800
 
5898
- // ../../node_modules/apache-arrow/fb/union.mjs
5801
+ // ../core/node_modules/apache-arrow/fb/union.mjs
5899
5802
  var Union = class {
5900
5803
  constructor() {
5901
5804
  this.bb = null;
@@ -5960,7 +5863,7 @@ var Union = class {
5960
5863
  }
5961
5864
  };
5962
5865
 
5963
- // ../../node_modules/apache-arrow/fb/utf8.mjs
5866
+ // ../core/node_modules/apache-arrow/fb/utf8.mjs
5964
5867
  var Utf82 = class {
5965
5868
  constructor() {
5966
5869
  this.bb = null;
@@ -5991,7 +5894,7 @@ var Utf82 = class {
5991
5894
  }
5992
5895
  };
5993
5896
 
5994
- // ../../node_modules/apache-arrow/fb/type.mjs
5897
+ // ../core/node_modules/apache-arrow/fb/type.mjs
5995
5898
  var Type2;
5996
5899
  (function(Type3) {
5997
5900
  Type3[Type3["NONE"] = 0] = "NONE";
@@ -6016,9 +5919,10 @@ var Type2;
6016
5919
  Type3[Type3["LargeBinary"] = 19] = "LargeBinary";
6017
5920
  Type3[Type3["LargeUtf8"] = 20] = "LargeUtf8";
6018
5921
  Type3[Type3["LargeList"] = 21] = "LargeList";
5922
+ Type3[Type3["RunEndEncoded"] = 22] = "RunEndEncoded";
6019
5923
  })(Type2 || (Type2 = {}));
6020
5924
 
6021
- // ../../node_modules/apache-arrow/fb/field.mjs
5925
+ // ../core/node_modules/apache-arrow/fb/field.mjs
6022
5926
  var Field = class {
6023
5927
  constructor() {
6024
5928
  this.bb = null;
@@ -6054,7 +5958,6 @@ var Field = class {
6054
5958
  /**
6055
5959
  * This is the type of the decoded value if the field is dictionary encoded.
6056
5960
  */
6057
- // @ts-ignore
6058
5961
  type(obj) {
6059
5962
  const offset = this.bb.__offset(this.bb_pos, 10);
6060
5963
  return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
@@ -6139,7 +6042,7 @@ var Field = class {
6139
6042
  }
6140
6043
  };
6141
6044
 
6142
- // ../../node_modules/apache-arrow/fb/schema.mjs
6045
+ // ../core/node_modules/apache-arrow/fb/schema.mjs
6143
6046
  var Schema = class {
6144
6047
  constructor() {
6145
6048
  this.bb = null;
@@ -6187,7 +6090,7 @@ var Schema = class {
6187
6090
  */
6188
6091
  features(index) {
6189
6092
  const offset = this.bb.__offset(this.bb_pos, 10);
6190
- return offset ? this.bb.readInt64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0);
6093
+ return offset ? this.bb.readInt64(this.bb.__vector(this.bb_pos + offset) + index * 8) : BigInt(0);
6191
6094
  }
6192
6095
  featuresLength() {
6193
6096
  const offset = this.bb.__offset(this.bb_pos, 10);
@@ -6258,7 +6161,7 @@ var Schema = class {
6258
6161
  }
6259
6162
  };
6260
6163
 
6261
- // ../../node_modules/apache-arrow/fb/footer.mjs
6164
+ // ../core/node_modules/apache-arrow/fb/footer.mjs
6262
6165
  var Footer = class {
6263
6166
  constructor() {
6264
6167
  this.bb = null;
@@ -6357,7 +6260,7 @@ var Footer = class {
6357
6260
  }
6358
6261
  };
6359
6262
 
6360
- // ../../node_modules/apache-arrow/schema.mjs
6263
+ // ../core/node_modules/apache-arrow/schema.mjs
6361
6264
  var Schema2 = class {
6362
6265
  constructor(fields = [], metadata, dictionaries) {
6363
6266
  this.fields = fields || [];
@@ -6415,12 +6318,6 @@ Schema2.prototype.fields = null;
6415
6318
  Schema2.prototype.metadata = null;
6416
6319
  Schema2.prototype.dictionaries = null;
6417
6320
  var Field2 = class {
6418
- constructor(name, type, nullable = false, metadata) {
6419
- this.name = name;
6420
- this.type = type;
6421
- this.nullable = nullable;
6422
- this.metadata = metadata || /* @__PURE__ */ new Map();
6423
- }
6424
6321
  /** @nocollapse */
6425
6322
  static new(...args) {
6426
6323
  let [name, type, nullable, metadata] = args;
@@ -6432,6 +6329,12 @@ var Field2 = class {
6432
6329
  }
6433
6330
  return new Field2(`${name}`, type, nullable, metadata);
6434
6331
  }
6332
+ constructor(name, type, nullable = false, metadata) {
6333
+ this.name = name;
6334
+ this.type = type;
6335
+ this.nullable = nullable;
6336
+ this.metadata = metadata || /* @__PURE__ */ new Map();
6337
+ }
6435
6338
  get typeId() {
6436
6339
  return this.type.typeId;
6437
6340
  }
@@ -6472,17 +6375,10 @@ function generateDictionaryMap(fields, dictionaries = /* @__PURE__ */ new Map())
6472
6375
  return dictionaries;
6473
6376
  }
6474
6377
 
6475
- // ../../node_modules/apache-arrow/ipc/metadata/file.mjs
6476
- var Long2 = Long;
6378
+ // ../core/node_modules/apache-arrow/ipc/metadata/file.mjs
6477
6379
  var Builder3 = Builder2;
6478
6380
  var ByteBuffer2 = ByteBuffer;
6479
6381
  var Footer_ = class {
6480
- constructor(schema, version = MetadataVersion.V4, recordBatches, dictionaryBatches) {
6481
- this.schema = schema;
6482
- this.version = version;
6483
- recordBatches && (this._recordBatches = recordBatches);
6484
- dictionaryBatches && (this._dictionaryBatches = dictionaryBatches);
6485
- }
6486
6382
  /** @nocollapse */
6487
6383
  static decode(buf) {
6488
6384
  buf = new ByteBuffer2(toUint8Array(buf));
@@ -6518,6 +6414,12 @@ var Footer_ = class {
6518
6414
  get numDictionaries() {
6519
6415
  return this._dictionaryBatches.length;
6520
6416
  }
6417
+ constructor(schema, version = MetadataVersion.V4, recordBatches, dictionaryBatches) {
6418
+ this.schema = schema;
6419
+ this.version = version;
6420
+ recordBatches && (this._recordBatches = recordBatches);
6421
+ dictionaryBatches && (this._dictionaryBatches = dictionaryBatches);
6422
+ }
6521
6423
  *recordBatches() {
6522
6424
  for (let block, i = -1, n = this.numRecordBatches; ++i < n; ) {
6523
6425
  if (block = this.getRecordBatch(i)) {
@@ -6540,16 +6442,16 @@ var Footer_ = class {
6540
6442
  }
6541
6443
  };
6542
6444
  var OffHeapFooter = class extends Footer_ {
6543
- constructor(schema, _footer) {
6544
- super(schema, _footer.version());
6545
- this._footer = _footer;
6546
- }
6547
6445
  get numRecordBatches() {
6548
6446
  return this._footer.recordBatchesLength();
6549
6447
  }
6550
6448
  get numDictionaries() {
6551
6449
  return this._footer.dictionariesLength();
6552
6450
  }
6451
+ constructor(schema, _footer) {
6452
+ super(schema, _footer.version());
6453
+ this._footer = _footer;
6454
+ }
6553
6455
  getRecordBatch(index) {
6554
6456
  if (index >= 0 && index < this.numRecordBatches) {
6555
6457
  const fileBlock = this._footer.recordBatches(index);
@@ -6570,11 +6472,6 @@ var OffHeapFooter = class extends Footer_ {
6570
6472
  }
6571
6473
  };
6572
6474
  var FileBlock = class {
6573
- constructor(metaDataLength, bodyLength, offset) {
6574
- this.metaDataLength = metaDataLength;
6575
- this.offset = typeof offset === "number" ? offset : offset.low;
6576
- this.bodyLength = typeof bodyLength === "number" ? bodyLength : bodyLength.low;
6577
- }
6578
6475
  /** @nocollapse */
6579
6476
  static decode(block) {
6580
6477
  return new FileBlock(block.metaDataLength(), block.bodyLength(), block.offset());
@@ -6582,13 +6479,18 @@ var FileBlock = class {
6582
6479
  /** @nocollapse */
6583
6480
  static encode(b, fileBlock) {
6584
6481
  const { metaDataLength } = fileBlock;
6585
- const offset = new Long2(fileBlock.offset, 0);
6586
- const bodyLength = new Long2(fileBlock.bodyLength, 0);
6482
+ const offset = BigInt(fileBlock.offset);
6483
+ const bodyLength = BigInt(fileBlock.bodyLength);
6587
6484
  return Block.createBlock(b, offset, metaDataLength, bodyLength);
6588
6485
  }
6486
+ constructor(metaDataLength, bodyLength, offset) {
6487
+ this.metaDataLength = metaDataLength;
6488
+ this.offset = bigIntToNumber(offset);
6489
+ this.bodyLength = bigIntToNumber(bodyLength);
6490
+ }
6589
6491
  };
6590
6492
 
6591
- // ../../node_modules/apache-arrow/io/interfaces.mjs
6493
+ // ../core/node_modules/apache-arrow/io/interfaces.mjs
6592
6494
  var ITERATOR_DONE = Object.freeze({ done: true, value: void 0 });
6593
6495
  var ArrowJSON = class {
6594
6496
  constructor(_json) {
@@ -6711,7 +6613,7 @@ var AsyncQueue = class extends ReadableInterop {
6711
6613
  }
6712
6614
  };
6713
6615
 
6714
- // ../../node_modules/apache-arrow/io/stream.mjs
6616
+ // ../core/node_modules/apache-arrow/io/stream.mjs
6715
6617
  var AsyncByteQueue = class extends AsyncQueue {
6716
6618
  write(value) {
6717
6619
  if ((value = toUint8Array(value)).byteLength > 0) {
@@ -6723,21 +6625,27 @@ var AsyncByteQueue = class extends AsyncQueue {
6723
6625
  }
6724
6626
  toUint8Array(sync = false) {
6725
6627
  return sync ? joinUint8Arrays(this._values)[0] : (() => __awaiter(this, void 0, void 0, function* () {
6726
- var e_1, _a5;
6628
+ var _a5, e_1, _b2, _c2;
6727
6629
  const buffers = [];
6728
6630
  let byteLength = 0;
6729
6631
  try {
6730
- for (var _b2 = __asyncValues(this), _c2; _c2 = yield _b2.next(), !_c2.done; ) {
6731
- const chunk = _c2.value;
6732
- buffers.push(chunk);
6733
- byteLength += chunk.byteLength;
6632
+ for (var _d2 = true, _e2 = __asyncValues(this), _f2; _f2 = yield _e2.next(), _a5 = _f2.done, !_a5; ) {
6633
+ _c2 = _f2.value;
6634
+ _d2 = false;
6635
+ try {
6636
+ const chunk = _c2;
6637
+ buffers.push(chunk);
6638
+ byteLength += chunk.byteLength;
6639
+ } finally {
6640
+ _d2 = true;
6641
+ }
6734
6642
  }
6735
6643
  } catch (e_1_1) {
6736
6644
  e_1 = { error: e_1_1 };
6737
6645
  } finally {
6738
6646
  try {
6739
- if (_c2 && !_c2.done && (_a5 = _b2.return))
6740
- yield _a5.call(_b2);
6647
+ if (!_d2 && !_a5 && (_b2 = _e2.return))
6648
+ yield _b2.call(_e2);
6741
6649
  } finally {
6742
6650
  if (e_1)
6743
6651
  throw e_1.error;
@@ -6886,13 +6794,13 @@ var AsyncByteStreamSource = class {
6886
6794
  }
6887
6795
  };
6888
6796
 
6889
- // ../../node_modules/apache-arrow/io/file.mjs
6797
+ // ../core/node_modules/apache-arrow/io/file.mjs
6890
6798
  var RandomAccessFile = class extends ByteStream {
6891
6799
  constructor(buffer, byteLength) {
6892
6800
  super();
6893
6801
  this.position = 0;
6894
6802
  this.buffer = toUint8Array(buffer);
6895
- this.size = typeof byteLength === "undefined" ? this.buffer.byteLength : byteLength;
6803
+ this.size = byteLength === void 0 ? this.buffer.byteLength : byteLength;
6896
6804
  }
6897
6805
  readInt32(position) {
6898
6806
  const { buffer, byteOffset } = this.readAt(position, 4);
@@ -7009,7 +6917,7 @@ var AsyncRandomAccessFile = class extends AsyncByteStream {
7009
6917
  }
7010
6918
  };
7011
6919
 
7012
- // ../../node_modules/apache-arrow/util/int.mjs
6920
+ // ../core/node_modules/apache-arrow/util/int.mjs
7013
6921
  var int_exports = {};
7014
6922
  __export(int_exports, {
7015
6923
  BaseInt64: () => BaseInt64,
@@ -7325,7 +7233,7 @@ var Int128 = class {
7325
7233
  }
7326
7234
  };
7327
7235
 
7328
- // ../../node_modules/apache-arrow/visitor/vectorloader.mjs
7236
+ // ../core/node_modules/apache-arrow/visitor/vectorloader.mjs
7329
7237
  var VectorLoader = class extends Visitor {
7330
7238
  constructor(bytes, nodes, buffers, dictionaries) {
7331
7239
  super();
@@ -7464,7 +7372,7 @@ function binaryDataFromJSON(values) {
7464
7372
  return data;
7465
7373
  }
7466
7374
 
7467
- // ../../node_modules/apache-arrow/builder/binary.mjs
7375
+ // ../core/node_modules/apache-arrow/builder/binary.mjs
7468
7376
  var BinaryBuilder = class extends VariableWidthBuilder {
7469
7377
  constructor(opts) {
7470
7378
  super(opts);
@@ -7497,7 +7405,7 @@ var BinaryBuilder = class extends VariableWidthBuilder {
7497
7405
  }
7498
7406
  };
7499
7407
 
7500
- // ../../node_modules/apache-arrow/builder/bool.mjs
7408
+ // ../core/node_modules/apache-arrow/builder/bool.mjs
7501
7409
  var BoolBuilder = class extends Builder {
7502
7410
  constructor(options) {
7503
7411
  super(options);
@@ -7508,7 +7416,7 @@ var BoolBuilder = class extends Builder {
7508
7416
  }
7509
7417
  };
7510
7418
 
7511
- // ../../node_modules/apache-arrow/builder/date.mjs
7419
+ // ../core/node_modules/apache-arrow/builder/date.mjs
7512
7420
  var DateBuilder = class extends FixedWidthBuilder {
7513
7421
  };
7514
7422
  DateBuilder.prototype._setValue = setDate;
@@ -7519,12 +7427,12 @@ var DateMillisecondBuilder = class extends DateBuilder {
7519
7427
  };
7520
7428
  DateMillisecondBuilder.prototype._setValue = setDateMillisecond;
7521
7429
 
7522
- // ../../node_modules/apache-arrow/builder/decimal.mjs
7430
+ // ../core/node_modules/apache-arrow/builder/decimal.mjs
7523
7431
  var DecimalBuilder = class extends FixedWidthBuilder {
7524
7432
  };
7525
7433
  DecimalBuilder.prototype._setValue = setDecimal;
7526
7434
 
7527
- // ../../node_modules/apache-arrow/builder/dictionary.mjs
7435
+ // ../core/node_modules/apache-arrow/builder/dictionary.mjs
7528
7436
  var DictionaryBuilder = class extends Builder {
7529
7437
  constructor({ "type": type, "nullValues": nulls, "dictionaryHashFunction": hashFn }) {
7530
7438
  super({ type: new Dictionary(type.dictionary, type.indices, type.id, type.isOrdered) });
@@ -7601,12 +7509,12 @@ var DictionaryBuilder = class extends Builder {
7601
7509
  }
7602
7510
  };
7603
7511
 
7604
- // ../../node_modules/apache-arrow/builder/fixedsizebinary.mjs
7512
+ // ../core/node_modules/apache-arrow/builder/fixedsizebinary.mjs
7605
7513
  var FixedSizeBinaryBuilder = class extends FixedWidthBuilder {
7606
7514
  };
7607
7515
  FixedSizeBinaryBuilder.prototype._setValue = setFixedSizeBinary;
7608
7516
 
7609
- // ../../node_modules/apache-arrow/builder/fixedsizelist.mjs
7517
+ // ../core/node_modules/apache-arrow/builder/fixedsizelist.mjs
7610
7518
  var FixedSizeListBuilder = class extends Builder {
7611
7519
  setValue(index, value) {
7612
7520
  const [child] = this.children;
@@ -7625,7 +7533,7 @@ var FixedSizeListBuilder = class extends Builder {
7625
7533
  }
7626
7534
  };
7627
7535
 
7628
- // ../../node_modules/apache-arrow/builder/float.mjs
7536
+ // ../core/node_modules/apache-arrow/builder/float.mjs
7629
7537
  var FloatBuilder = class extends FixedWidthBuilder {
7630
7538
  setValue(index, value) {
7631
7539
  this._values.set(index, value);
@@ -7641,7 +7549,7 @@ var Float32Builder = class extends FloatBuilder {
7641
7549
  var Float64Builder = class extends FloatBuilder {
7642
7550
  };
7643
7551
 
7644
- // ../../node_modules/apache-arrow/builder/interval.mjs
7552
+ // ../core/node_modules/apache-arrow/builder/interval.mjs
7645
7553
  var IntervalBuilder = class extends FixedWidthBuilder {
7646
7554
  };
7647
7555
  IntervalBuilder.prototype._setValue = setIntervalValue;
@@ -7652,7 +7560,7 @@ var IntervalYearMonthBuilder = class extends IntervalBuilder {
7652
7560
  };
7653
7561
  IntervalYearMonthBuilder.prototype._setValue = setIntervalYearMonth;
7654
7562
 
7655
- // ../../node_modules/apache-arrow/builder/int.mjs
7563
+ // ../core/node_modules/apache-arrow/builder/int.mjs
7656
7564
  var IntBuilder = class extends FixedWidthBuilder {
7657
7565
  setValue(index, value) {
7658
7566
  this._values.set(index, value);
@@ -7675,7 +7583,7 @@ var Uint32Builder = class extends IntBuilder {
7675
7583
  var Uint64Builder = class extends IntBuilder {
7676
7584
  };
7677
7585
 
7678
- // ../../node_modules/apache-arrow/builder/list.mjs
7586
+ // ../core/node_modules/apache-arrow/builder/list.mjs
7679
7587
  var ListBuilder = class extends VariableWidthBuilder {
7680
7588
  constructor(opts) {
7681
7589
  super(opts);
@@ -7706,7 +7614,7 @@ var ListBuilder = class extends VariableWidthBuilder {
7706
7614
  }
7707
7615
  };
7708
7616
 
7709
- // ../../node_modules/apache-arrow/builder/map.mjs
7617
+ // ../core/node_modules/apache-arrow/builder/map.mjs
7710
7618
  var MapBuilder = class extends VariableWidthBuilder {
7711
7619
  set(index, value) {
7712
7620
  return super.set(index, value);
@@ -7745,7 +7653,7 @@ var MapBuilder = class extends VariableWidthBuilder {
7745
7653
  }
7746
7654
  };
7747
7655
 
7748
- // ../../node_modules/apache-arrow/builder/null.mjs
7656
+ // ../core/node_modules/apache-arrow/builder/null.mjs
7749
7657
  var NullBuilder = class extends Builder {
7750
7658
  // @ts-ignore
7751
7659
  setValue(index, value) {
@@ -7756,7 +7664,7 @@ var NullBuilder = class extends Builder {
7756
7664
  }
7757
7665
  };
7758
7666
 
7759
- // ../../node_modules/apache-arrow/builder/struct.mjs
7667
+ // ../core/node_modules/apache-arrow/builder/struct.mjs
7760
7668
  var StructBuilder = class extends Builder {
7761
7669
  setValue(index, value) {
7762
7670
  const { children, type } = this;
@@ -7783,7 +7691,7 @@ var StructBuilder = class extends Builder {
7783
7691
  }
7784
7692
  };
7785
7693
 
7786
- // ../../node_modules/apache-arrow/builder/timestamp.mjs
7694
+ // ../core/node_modules/apache-arrow/builder/timestamp.mjs
7787
7695
  var TimestampBuilder = class extends FixedWidthBuilder {
7788
7696
  };
7789
7697
  TimestampBuilder.prototype._setValue = setTimestamp;
@@ -7800,7 +7708,7 @@ var TimestampNanosecondBuilder = class extends TimestampBuilder {
7800
7708
  };
7801
7709
  TimestampNanosecondBuilder.prototype._setValue = setTimestampNanosecond;
7802
7710
 
7803
- // ../../node_modules/apache-arrow/builder/time.mjs
7711
+ // ../core/node_modules/apache-arrow/builder/time.mjs
7804
7712
  var TimeBuilder = class extends FixedWidthBuilder {
7805
7713
  };
7806
7714
  TimeBuilder.prototype._setValue = setTime;
@@ -7817,7 +7725,7 @@ var TimeNanosecondBuilder = class extends TimeBuilder {
7817
7725
  };
7818
7726
  TimeNanosecondBuilder.prototype._setValue = setTimeNanosecond;
7819
7727
 
7820
- // ../../node_modules/apache-arrow/builder/union.mjs
7728
+ // ../core/node_modules/apache-arrow/builder/union.mjs
7821
7729
  var UnionBuilder = class extends Builder {
7822
7730
  constructor(options) {
7823
7731
  super(options);
@@ -7876,7 +7784,7 @@ var DenseUnionBuilder = class extends UnionBuilder {
7876
7784
  }
7877
7785
  };
7878
7786
 
7879
- // ../../node_modules/apache-arrow/builder/utf8.mjs
7787
+ // ../core/node_modules/apache-arrow/builder/utf8.mjs
7880
7788
  var Utf8Builder = class extends VariableWidthBuilder {
7881
7789
  constructor(opts) {
7882
7790
  super(opts);
@@ -7898,7 +7806,7 @@ var Utf8Builder = class extends VariableWidthBuilder {
7898
7806
  };
7899
7807
  Utf8Builder.prototype._flushPending = BinaryBuilder.prototype._flushPending;
7900
7808
 
7901
- // ../../node_modules/apache-arrow/visitor/builderctor.mjs
7809
+ // ../core/node_modules/apache-arrow/visitor/builderctor.mjs
7902
7810
  var GetBuilderCtor = class extends Visitor {
7903
7811
  visitNull() {
7904
7812
  return NullBuilder;
@@ -8032,7 +7940,7 @@ var GetBuilderCtor = class extends Visitor {
8032
7940
  };
8033
7941
  var instance6 = new GetBuilderCtor();
8034
7942
 
8035
- // ../../node_modules/apache-arrow/visitor/typecomparator.mjs
7943
+ // ../core/node_modules/apache-arrow/visitor/typecomparator.mjs
8036
7944
  var TypeComparator = class extends Visitor {
8037
7945
  compareSchemas(schema, other) {
8038
7946
  return schema === other || other instanceof schema.constructor && this.compareManyFields(schema.fields, other.fields);
@@ -8143,7 +8051,7 @@ function compareTypes(type, other) {
8143
8051
  return instance7.visit(type, other);
8144
8052
  }
8145
8053
 
8146
- // ../../node_modules/apache-arrow/factories.mjs
8054
+ // ../core/node_modules/apache-arrow/factories.mjs
8147
8055
  function makeBuilder(options) {
8148
8056
  const type = options.type;
8149
8057
  const builder = new (instance6.getVisitFn(type)())(options);
@@ -8160,7 +8068,7 @@ function makeBuilder(options) {
8160
8068
  return builder;
8161
8069
  }
8162
8070
 
8163
- // ../../node_modules/apache-arrow/util/recordbatch.mjs
8071
+ // ../core/node_modules/apache-arrow/util/recordbatch.mjs
8164
8072
  function distributeVectorsIntoRecordBatches(schema, vecs) {
8165
8073
  return uniformlyDistributeChunksAcrossRecordBatches(schema, vecs.map((v) => v.data.concat()));
8166
8074
  }
@@ -8221,7 +8129,7 @@ function distributeChildren(fields, batchLength, children, columns, memo) {
8221
8129
  return children;
8222
8130
  }
8223
8131
 
8224
- // ../../node_modules/apache-arrow/table.mjs
8132
+ // ../core/node_modules/apache-arrow/table.mjs
8225
8133
  var _a3;
8226
8134
  var Table = class {
8227
8135
  constructor(...args) {
@@ -8505,7 +8413,7 @@ Table[_a3] = ((proto) => {
8505
8413
  return "Table";
8506
8414
  })(Table.prototype);
8507
8415
 
8508
- // ../../node_modules/apache-arrow/recordbatch.mjs
8416
+ // ../core/node_modules/apache-arrow/recordbatch.mjs
8509
8417
  var _a4;
8510
8418
  var RecordBatch = class {
8511
8419
  constructor(...args) {
@@ -8767,20 +8675,20 @@ var _InternalEmptyPlaceholderRecordBatch = class extends RecordBatch {
8767
8675
  }
8768
8676
  };
8769
8677
 
8770
- // ../../node_modules/apache-arrow/fb/body-compression-method.mjs
8678
+ // ../core/node_modules/apache-arrow/fb/body-compression-method.mjs
8771
8679
  var BodyCompressionMethod;
8772
8680
  (function(BodyCompressionMethod2) {
8773
8681
  BodyCompressionMethod2[BodyCompressionMethod2["BUFFER"] = 0] = "BUFFER";
8774
8682
  })(BodyCompressionMethod || (BodyCompressionMethod = {}));
8775
8683
 
8776
- // ../../node_modules/apache-arrow/fb/compression-type.mjs
8684
+ // ../core/node_modules/apache-arrow/fb/compression-type.mjs
8777
8685
  var CompressionType;
8778
8686
  (function(CompressionType2) {
8779
8687
  CompressionType2[CompressionType2["LZ4_FRAME"] = 0] = "LZ4_FRAME";
8780
8688
  CompressionType2[CompressionType2["ZSTD"] = 1] = "ZSTD";
8781
8689
  })(CompressionType || (CompressionType = {}));
8782
8690
 
8783
- // ../../node_modules/apache-arrow/fb/body-compression.mjs
8691
+ // ../core/node_modules/apache-arrow/fb/body-compression.mjs
8784
8692
  var BodyCompression = class {
8785
8693
  constructor() {
8786
8694
  this.bb = null;
@@ -8834,7 +8742,7 @@ var BodyCompression = class {
8834
8742
  }
8835
8743
  };
8836
8744
 
8837
- // ../../node_modules/apache-arrow/fb/buffer.mjs
8745
+ // ../core/node_modules/apache-arrow/fb/buffer.mjs
8838
8746
  var Buffer2 = class {
8839
8747
  constructor() {
8840
8748
  this.bb = null;
@@ -8867,13 +8775,13 @@ var Buffer2 = class {
8867
8775
  }
8868
8776
  static createBuffer(builder, offset, length2) {
8869
8777
  builder.prep(8, 16);
8870
- builder.writeInt64(length2);
8871
- builder.writeInt64(offset);
8778
+ builder.writeInt64(BigInt(length2 !== null && length2 !== void 0 ? length2 : 0));
8779
+ builder.writeInt64(BigInt(offset !== null && offset !== void 0 ? offset : 0));
8872
8780
  return builder.offset();
8873
8781
  }
8874
8782
  };
8875
8783
 
8876
- // ../../node_modules/apache-arrow/fb/field-node.mjs
8784
+ // ../core/node_modules/apache-arrow/fb/field-node.mjs
8877
8785
  var FieldNode = class {
8878
8786
  constructor() {
8879
8787
  this.bb = null;
@@ -8904,13 +8812,13 @@ var FieldNode = class {
8904
8812
  }
8905
8813
  static createFieldNode(builder, length2, null_count) {
8906
8814
  builder.prep(8, 16);
8907
- builder.writeInt64(null_count);
8908
- builder.writeInt64(length2);
8815
+ builder.writeInt64(BigInt(null_count !== null && null_count !== void 0 ? null_count : 0));
8816
+ builder.writeInt64(BigInt(length2 !== null && length2 !== void 0 ? length2 : 0));
8909
8817
  return builder.offset();
8910
8818
  }
8911
8819
  };
8912
8820
 
8913
- // ../../node_modules/apache-arrow/fb/record-batch.mjs
8821
+ // ../core/node_modules/apache-arrow/fb/record-batch.mjs
8914
8822
  var RecordBatch2 = class {
8915
8823
  constructor() {
8916
8824
  this.bb = null;
@@ -8934,7 +8842,7 @@ var RecordBatch2 = class {
8934
8842
  */
8935
8843
  length() {
8936
8844
  const offset = this.bb.__offset(this.bb_pos, 4);
8937
- return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);
8845
+ return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt("0");
8938
8846
  }
8939
8847
  /**
8940
8848
  * Nodes correspond to the pre-ordered flattened logical schema
@@ -8974,7 +8882,7 @@ var RecordBatch2 = class {
8974
8882
  builder.startObject(4);
8975
8883
  }
8976
8884
  static addLength(builder, length2) {
8977
- builder.addFieldInt64(0, length2, builder.createLong(0, 0));
8885
+ builder.addFieldInt64(0, length2, BigInt("0"));
8978
8886
  }
8979
8887
  static addNodes(builder, nodesOffset) {
8980
8888
  builder.addFieldOffset(1, nodesOffset, 0);
@@ -8997,7 +8905,7 @@ var RecordBatch2 = class {
8997
8905
  }
8998
8906
  };
8999
8907
 
9000
- // ../../node_modules/apache-arrow/fb/dictionary-batch.mjs
8908
+ // ../core/node_modules/apache-arrow/fb/dictionary-batch.mjs
9001
8909
  var DictionaryBatch = class {
9002
8910
  constructor() {
9003
8911
  this.bb = null;
@@ -9017,7 +8925,7 @@ var DictionaryBatch = class {
9017
8925
  }
9018
8926
  id() {
9019
8927
  const offset = this.bb.__offset(this.bb_pos, 4);
9020
- return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);
8928
+ return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt("0");
9021
8929
  }
9022
8930
  data(obj) {
9023
8931
  const offset = this.bb.__offset(this.bb_pos, 6);
@@ -9036,7 +8944,7 @@ var DictionaryBatch = class {
9036
8944
  builder.startObject(3);
9037
8945
  }
9038
8946
  static addId(builder, id) {
9039
- builder.addFieldInt64(0, id, builder.createLong(0, 0));
8947
+ builder.addFieldInt64(0, id, BigInt("0"));
9040
8948
  }
9041
8949
  static addData(builder, dataOffset) {
9042
8950
  builder.addFieldOffset(1, dataOffset, 0);
@@ -9050,7 +8958,7 @@ var DictionaryBatch = class {
9050
8958
  }
9051
8959
  };
9052
8960
 
9053
- // ../../node_modules/apache-arrow/fb/message-header.mjs
8961
+ // ../core/node_modules/apache-arrow/fb/message-header.mjs
9054
8962
  var MessageHeader2;
9055
8963
  (function(MessageHeader3) {
9056
8964
  MessageHeader3[MessageHeader3["NONE"] = 0] = "NONE";
@@ -9061,7 +8969,7 @@ var MessageHeader2;
9061
8969
  MessageHeader3[MessageHeader3["SparseTensor"] = 5] = "SparseTensor";
9062
8970
  })(MessageHeader2 || (MessageHeader2 = {}));
9063
8971
 
9064
- // ../../node_modules/apache-arrow/fb/message.mjs
8972
+ // ../core/node_modules/apache-arrow/fb/message.mjs
9065
8973
  var Message = class {
9066
8974
  constructor() {
9067
8975
  this.bb = null;
@@ -9087,14 +8995,13 @@ var Message = class {
9087
8995
  const offset = this.bb.__offset(this.bb_pos, 6);
9088
8996
  return offset ? this.bb.readUint8(this.bb_pos + offset) : MessageHeader2.NONE;
9089
8997
  }
9090
- // @ts-ignore
9091
8998
  header(obj) {
9092
8999
  const offset = this.bb.__offset(this.bb_pos, 8);
9093
9000
  return offset ? this.bb.__union(obj, this.bb_pos + offset) : null;
9094
9001
  }
9095
9002
  bodyLength() {
9096
9003
  const offset = this.bb.__offset(this.bb_pos, 10);
9097
- return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);
9004
+ return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt("0");
9098
9005
  }
9099
9006
  customMetadata(index, obj) {
9100
9007
  const offset = this.bb.__offset(this.bb_pos, 12);
@@ -9117,7 +9024,7 @@ var Message = class {
9117
9024
  builder.addFieldOffset(2, headerOffset, 0);
9118
9025
  }
9119
9026
  static addBodyLength(builder, bodyLength) {
9120
- builder.addFieldInt64(3, bodyLength, builder.createLong(0, 0));
9027
+ builder.addFieldInt64(3, bodyLength, BigInt("0"));
9121
9028
  }
9122
9029
  static addCustomMetadata(builder, customMetadataOffset) {
9123
9030
  builder.addFieldOffset(4, customMetadataOffset, 0);
@@ -9153,8 +9060,7 @@ var Message = class {
9153
9060
  }
9154
9061
  };
9155
9062
 
9156
- // ../../node_modules/apache-arrow/visitor/typeassembler.mjs
9157
- var Long3 = Long;
9063
+ // ../core/node_modules/apache-arrow/visitor/typeassembler.mjs
9158
9064
  var TypeAssembler = class extends Visitor {
9159
9065
  visit(node, builder) {
9160
9066
  return node == null || builder == null ? void 0 : super.visit(node, builder);
@@ -9237,7 +9143,7 @@ var TypeAssembler = class extends Visitor {
9237
9143
  visitDictionary(node, b) {
9238
9144
  const indexType = this.visit(node.indices, b);
9239
9145
  DictionaryEncoding.startDictionaryEncoding(b);
9240
- DictionaryEncoding.addId(b, new Long3(node.id, 0));
9146
+ DictionaryEncoding.addId(b, BigInt(node.id));
9241
9147
  DictionaryEncoding.addIsOrdered(b, node.isOrdered);
9242
9148
  if (indexType !== void 0) {
9243
9149
  DictionaryEncoding.addIndexType(b, indexType);
@@ -9262,7 +9168,7 @@ var TypeAssembler = class extends Visitor {
9262
9168
  };
9263
9169
  var instance8 = new TypeAssembler();
9264
9170
 
9265
- // ../../node_modules/apache-arrow/ipc/metadata/json.mjs
9171
+ // ../core/node_modules/apache-arrow/ipc/metadata/json.mjs
9266
9172
  function schemaFromJSON(_schema, dictionaries = /* @__PURE__ */ new Map()) {
9267
9173
  return new Schema2(schemaFieldsFromJSON(_schema, dictionaries), customMetadataFromJSON(_schema["customMetadata"]), dictionaries);
9268
9174
  }
@@ -9396,18 +9302,10 @@ function typeFromJSON(f, children) {
9396
9302
  throw new Error(`Unrecognized type: "${typeId}"`);
9397
9303
  }
9398
9304
 
9399
- // ../../node_modules/apache-arrow/ipc/metadata/message.mjs
9400
- var Long4 = Long;
9305
+ // ../core/node_modules/apache-arrow/ipc/metadata/message.mjs
9401
9306
  var Builder4 = Builder2;
9402
9307
  var ByteBuffer3 = ByteBuffer;
9403
9308
  var Message2 = class {
9404
- constructor(bodyLength, version, headerType, header) {
9405
- this._version = version;
9406
- this._headerType = headerType;
9407
- this.body = new Uint8Array(0);
9408
- header && (this._createHeader = () => header);
9409
- this._bodyLength = typeof bodyLength === "number" ? bodyLength : bodyLength.low;
9410
- }
9411
9309
  /** @nocollapse */
9412
9310
  static fromJSON(msg, headerType) {
9413
9311
  const message = new Message2(0, MetadataVersion.V4, headerType);
@@ -9440,7 +9338,7 @@ var Message2 = class {
9440
9338
  Message.addVersion(b, MetadataVersion.V4);
9441
9339
  Message.addHeader(b, headerOffset);
9442
9340
  Message.addHeaderType(b, message.headerType);
9443
- Message.addBodyLength(b, new Long4(message.bodyLength, 0));
9341
+ Message.addBodyLength(b, BigInt(message.bodyLength));
9444
9342
  Message.finishMessageBuffer(b, Message.endMessage(b));
9445
9343
  return b.asUint8Array();
9446
9344
  }
@@ -9481,13 +9379,15 @@ var Message2 = class {
9481
9379
  isDictionaryBatch() {
9482
9380
  return this.headerType === MessageHeader.DictionaryBatch;
9483
9381
  }
9382
+ constructor(bodyLength, version, headerType, header) {
9383
+ this._version = version;
9384
+ this._headerType = headerType;
9385
+ this.body = new Uint8Array(0);
9386
+ header && (this._createHeader = () => header);
9387
+ this._bodyLength = bigIntToNumber(bodyLength);
9388
+ }
9484
9389
  };
9485
9390
  var RecordBatch3 = class {
9486
- constructor(length2, nodes, buffers) {
9487
- this._nodes = nodes;
9488
- this._buffers = buffers;
9489
- this._length = typeof length2 === "number" ? length2 : length2.low;
9490
- }
9491
9391
  get nodes() {
9492
9392
  return this._nodes;
9493
9393
  }
@@ -9497,13 +9397,13 @@ var RecordBatch3 = class {
9497
9397
  get buffers() {
9498
9398
  return this._buffers;
9499
9399
  }
9400
+ constructor(length2, nodes, buffers) {
9401
+ this._nodes = nodes;
9402
+ this._buffers = buffers;
9403
+ this._length = bigIntToNumber(length2);
9404
+ }
9500
9405
  };
9501
9406
  var DictionaryBatch2 = class {
9502
- constructor(data, id, isDelta = false) {
9503
- this._data = data;
9504
- this._isDelta = isDelta;
9505
- this._id = typeof id === "number" ? id : id.low;
9506
- }
9507
9407
  get id() {
9508
9408
  return this._id;
9509
9409
  }
@@ -9522,17 +9422,22 @@ var DictionaryBatch2 = class {
9522
9422
  get buffers() {
9523
9423
  return this.data.buffers;
9524
9424
  }
9425
+ constructor(data, id, isDelta = false) {
9426
+ this._data = data;
9427
+ this._isDelta = isDelta;
9428
+ this._id = bigIntToNumber(id);
9429
+ }
9525
9430
  };
9526
9431
  var BufferRegion = class {
9527
9432
  constructor(offset, length2) {
9528
- this.offset = typeof offset === "number" ? offset : offset.low;
9529
- this.length = typeof length2 === "number" ? length2 : length2.low;
9433
+ this.offset = bigIntToNumber(offset);
9434
+ this.length = bigIntToNumber(length2);
9530
9435
  }
9531
9436
  };
9532
9437
  var FieldNode2 = class {
9533
9438
  constructor(length2, nullCount) {
9534
- this.length = typeof length2 === "number" ? length2 : length2.low;
9535
- this.nullCount = typeof nullCount === "number" ? nullCount : nullCount.low;
9439
+ this.length = bigIntToNumber(length2);
9440
+ this.nullCount = bigIntToNumber(nullCount);
9536
9441
  }
9537
9442
  };
9538
9443
  function messageHeaderFromJSON(message, type) {
@@ -9645,7 +9550,7 @@ function decodeField(f, dictionaries) {
9645
9550
  if (!dictionaries || !(dictMeta = f.dictionary())) {
9646
9551
  type = decodeFieldType(f, decodeFieldChildren(f, dictionaries));
9647
9552
  field = new Field2(f.name(), type, f.nullable(), decodeCustomMetadata(f));
9648
- } else if (!dictionaries.has(id = dictMeta.id().low)) {
9553
+ } else if (!dictionaries.has(id = bigIntToNumber(dictMeta.id()))) {
9649
9554
  keys = (keys = dictMeta.indexType()) ? decodeIndexType(keys) : new Int32();
9650
9555
  dictionaries.set(id, type = decodeFieldType(f, decodeFieldChildren(f, dictionaries)));
9651
9556
  dictType = new Dictionary(type, keys, id, dictMeta.isOrdered());
@@ -9811,7 +9716,7 @@ function encodeRecordBatch(b, recordBatch) {
9811
9716
  BufferRegion.encode(b, b_);
9812
9717
  const buffersVectorOffset = b.endVector();
9813
9718
  RecordBatch2.startRecordBatch(b);
9814
- RecordBatch2.addLength(b, new Long4(recordBatch.length, 0));
9719
+ RecordBatch2.addLength(b, BigInt(recordBatch.length));
9815
9720
  RecordBatch2.addNodes(b, nodesVectorOffset);
9816
9721
  RecordBatch2.addBuffers(b, buffersVectorOffset);
9817
9722
  return RecordBatch2.endRecordBatch(b);
@@ -9819,16 +9724,16 @@ function encodeRecordBatch(b, recordBatch) {
9819
9724
  function encodeDictionaryBatch(b, dictionaryBatch) {
9820
9725
  const dataOffset = RecordBatch3.encode(b, dictionaryBatch.data);
9821
9726
  DictionaryBatch.startDictionaryBatch(b);
9822
- DictionaryBatch.addId(b, new Long4(dictionaryBatch.id, 0));
9727
+ DictionaryBatch.addId(b, BigInt(dictionaryBatch.id));
9823
9728
  DictionaryBatch.addIsDelta(b, dictionaryBatch.isDelta);
9824
9729
  DictionaryBatch.addData(b, dataOffset);
9825
9730
  return DictionaryBatch.endDictionaryBatch(b);
9826
9731
  }
9827
9732
  function encodeFieldNode(b, node) {
9828
- return FieldNode.createFieldNode(b, new Long4(node.length, 0), new Long4(node.nullCount, 0));
9733
+ return FieldNode.createFieldNode(b, BigInt(node.length), BigInt(node.nullCount));
9829
9734
  }
9830
9735
  function encodeBufferRegion(b, node) {
9831
- return Buffer2.createBuffer(b, new Long4(node.offset, 0), new Long4(node.length, 0));
9736
+ return Buffer2.createBuffer(b, BigInt(node.offset), BigInt(node.length));
9832
9737
  }
9833
9738
  var platformIsLittleEndian = (() => {
9834
9739
  const buffer = new ArrayBuffer(2);
@@ -9841,7 +9746,7 @@ var platformIsLittleEndian = (() => {
9841
9746
  return new Int16Array(buffer)[0] === 256;
9842
9747
  })();
9843
9748
 
9844
- // ../../node_modules/apache-arrow/ipc/message.mjs
9749
+ // ../core/node_modules/apache-arrow/ipc/message.mjs
9845
9750
  var invalidMessageType = (type) => `Expected ${MessageHeader[type]} Message in stream, but was null or length 0.`;
9846
9751
  var nullMessage = (type) => `Header pointer of flatbuffer-encoded ${MessageHeader[type]} Message is null or length 0.`;
9847
9752
  var invalidMessageMetadata = (expected, actual) => `Expected to read ${expected} metadata bytes, but only read ${actual}.`;
@@ -10096,7 +10001,7 @@ var magicLength = MAGIC.length;
10096
10001
  var magicAndPadding = magicLength + PADDING;
10097
10002
  var magicX2AndPadding = magicLength * 2 + PADDING;
10098
10003
 
10099
- // ../../node_modules/apache-arrow/ipc/reader.mjs
10004
+ // ../core/node_modules/apache-arrow/ipc/reader.mjs
10100
10005
  var RecordBatchReader = class extends ReadableInterop {
10101
10006
  constructor(impl) {
10102
10007
  super();
@@ -10231,20 +10136,26 @@ var AsyncRecordBatchStreamReader = class extends RecordBatchReader {
10231
10136
  this._impl = _impl;
10232
10137
  }
10233
10138
  readAll() {
10234
- var e_1, _a5;
10139
+ var _a5, e_1, _b2, _c2;
10235
10140
  return __awaiter(this, void 0, void 0, function* () {
10236
10141
  const batches = new Array();
10237
10142
  try {
10238
- for (var _b2 = __asyncValues(this), _c2; _c2 = yield _b2.next(), !_c2.done; ) {
10239
- const batch = _c2.value;
10240
- batches.push(batch);
10143
+ for (var _d2 = true, _e2 = __asyncValues(this), _f2; _f2 = yield _e2.next(), _a5 = _f2.done, !_a5; ) {
10144
+ _c2 = _f2.value;
10145
+ _d2 = false;
10146
+ try {
10147
+ const batch = _c2;
10148
+ batches.push(batch);
10149
+ } finally {
10150
+ _d2 = true;
10151
+ }
10241
10152
  }
10242
10153
  } catch (e_1_1) {
10243
10154
  e_1 = { error: e_1_1 };
10244
10155
  } finally {
10245
10156
  try {
10246
- if (_c2 && !_c2.done && (_a5 = _b2.return))
10247
- yield _a5.call(_b2);
10157
+ if (!_d2 && !_a5 && (_b2 = _e2.return))
10158
+ yield _b2.call(_e2);
10248
10159
  } finally {
10249
10160
  if (e_1)
10250
10161
  throw e_1.error;
@@ -10273,6 +10184,12 @@ var AsyncRecordBatchFileReader = class extends AsyncRecordBatchStreamReader {
10273
10184
  }
10274
10185
  };
10275
10186
  var RecordBatchReaderImpl = class {
10187
+ get numDictionaries() {
10188
+ return this._dictionaryIndex;
10189
+ }
10190
+ get numRecordBatches() {
10191
+ return this._recordBatchIndex;
10192
+ }
10276
10193
  constructor(dictionaries = /* @__PURE__ */ new Map()) {
10277
10194
  this.closed = false;
10278
10195
  this.autoDestroy = true;
@@ -10280,12 +10197,6 @@ var RecordBatchReaderImpl = class {
10280
10197
  this._recordBatchIndex = 0;
10281
10198
  this.dictionaries = dictionaries;
10282
10199
  }
10283
- get numDictionaries() {
10284
- return this._dictionaryIndex;
10285
- }
10286
- get numRecordBatches() {
10287
- return this._recordBatchIndex;
10288
- }
10289
10200
  isSync() {
10290
10201
  return false;
10291
10202
  }
@@ -10488,9 +10399,6 @@ var AsyncRecordBatchStreamReaderImpl = class extends RecordBatchReaderImpl {
10488
10399
  }
10489
10400
  };
10490
10401
  var RecordBatchFileReaderImpl = class extends RecordBatchStreamReaderImpl {
10491
- constructor(source, dictionaries) {
10492
- super(source instanceof RandomAccessFile ? source : new RandomAccessFile(source), dictionaries);
10493
- }
10494
10402
  get footer() {
10495
10403
  return this._footer;
10496
10404
  }
@@ -10500,6 +10408,9 @@ var RecordBatchFileReaderImpl = class extends RecordBatchStreamReaderImpl {
10500
10408
  get numRecordBatches() {
10501
10409
  return this._footer ? this._footer.numRecordBatches : 0;
10502
10410
  }
10411
+ constructor(source, dictionaries) {
10412
+ super(source instanceof RandomAccessFile ? source : new RandomAccessFile(source), dictionaries);
10413
+ }
10503
10414
  isSync() {
10504
10415
  return true;
10505
10416
  }
@@ -10570,11 +10481,6 @@ var RecordBatchFileReaderImpl = class extends RecordBatchStreamReaderImpl {
10570
10481
  }
10571
10482
  };
10572
10483
  var AsyncRecordBatchFileReaderImpl = class extends AsyncRecordBatchStreamReaderImpl {
10573
- constructor(source, ...rest) {
10574
- const byteLength = typeof rest[0] !== "number" ? rest.shift() : void 0;
10575
- const dictionaries = rest[0] instanceof Map ? rest.shift() : void 0;
10576
- super(source instanceof AsyncRandomAccessFile ? source : new AsyncRandomAccessFile(source, byteLength), dictionaries);
10577
- }
10578
10484
  get footer() {
10579
10485
  return this._footer;
10580
10486
  }
@@ -10584,6 +10490,11 @@ var AsyncRecordBatchFileReaderImpl = class extends AsyncRecordBatchStreamReaderI
10584
10490
  get numRecordBatches() {
10585
10491
  return this._footer ? this._footer.numRecordBatches : 0;
10586
10492
  }
10493
+ constructor(source, ...rest) {
10494
+ const byteLength = typeof rest[0] !== "number" ? rest.shift() : void 0;
10495
+ const dictionaries = rest[0] instanceof Map ? rest.shift() : void 0;
10496
+ super(source instanceof AsyncRandomAccessFile ? source : new AsyncRandomAccessFile(source, byteLength), dictionaries);
10497
+ }
10587
10498
  isFile() {
10588
10499
  return true;
10589
10500
  }
@@ -10731,15 +10642,8 @@ function fromFileHandle(source) {
10731
10642
  });
10732
10643
  }
10733
10644
 
10734
- // ../../node_modules/apache-arrow/visitor/vectorassembler.mjs
10645
+ // ../core/node_modules/apache-arrow/visitor/vectorassembler.mjs
10735
10646
  var VectorAssembler = class extends Visitor {
10736
- constructor() {
10737
- super();
10738
- this._byteLength = 0;
10739
- this._nodes = [];
10740
- this._buffers = [];
10741
- this._bufferRegions = [];
10742
- }
10743
10647
  /** @nocollapse */
10744
10648
  static assemble(...args) {
10745
10649
  const unwrap = (nodes) => nodes.flatMap((node) => Array.isArray(node) ? unwrap(node) : node instanceof RecordBatch ? node.data.children : node.data);
@@ -10747,6 +10651,13 @@ var VectorAssembler = class extends Visitor {
10747
10651
  assembler.visitMany(unwrap(args));
10748
10652
  return assembler;
10749
10653
  }
10654
+ constructor() {
10655
+ super();
10656
+ this._byteLength = 0;
10657
+ this._nodes = [];
10658
+ this._buffers = [];
10659
+ this._bufferRegions = [];
10660
+ }
10750
10661
  visit(data) {
10751
10662
  if (data instanceof Vector) {
10752
10663
  this.visitMany(data.data);
@@ -10873,8 +10784,17 @@ VectorAssembler.prototype.visitInterval = assembleFlatVector;
10873
10784
  VectorAssembler.prototype.visitFixedSizeList = assembleListVector;
10874
10785
  VectorAssembler.prototype.visitMap = assembleListVector;
10875
10786
 
10876
- // ../../node_modules/apache-arrow/ipc/writer.mjs
10787
+ // ../core/node_modules/apache-arrow/ipc/writer.mjs
10877
10788
  var RecordBatchWriter = class extends ReadableInterop {
10789
+ /** @nocollapse */
10790
+ // @ts-ignore
10791
+ static throughNode(options) {
10792
+ throw new Error(`"throughNode" not available in this environment`);
10793
+ }
10794
+ /** @nocollapse */
10795
+ static throughDOM(writableStrategy, readableStrategy) {
10796
+ throw new Error(`"throughDOM" not available in this environment`);
10797
+ }
10878
10798
  constructor(options) {
10879
10799
  super();
10880
10800
  this._position = 0;
@@ -10888,15 +10808,6 @@ var RecordBatchWriter = class extends ReadableInterop {
10888
10808
  this._autoDestroy = typeof options.autoDestroy === "boolean" ? options.autoDestroy : true;
10889
10809
  this._writeLegacyIpcFormat = typeof options.writeLegacyIpcFormat === "boolean" ? options.writeLegacyIpcFormat : false;
10890
10810
  }
10891
- /** @nocollapse */
10892
- // @ts-ignore
10893
- static throughNode(options) {
10894
- throw new Error(`"throughNode" not available in this environment`);
10895
- }
10896
- /** @nocollapse */
10897
- static throughDOM(writableStrategy, readableStrategy) {
10898
- throw new Error(`"throughDOM" not available in this environment`);
10899
- }
10900
10811
  toString(sync = false) {
10901
10812
  return this._sink.toString(sync);
10902
10813
  }
@@ -11122,20 +11033,26 @@ function writeAll(writer, input) {
11122
11033
  return writer.finish();
11123
11034
  }
11124
11035
  function writeAllAsync(writer, batches) {
11125
- var batches_1, batches_1_1;
11126
- var e_1, _a5;
11036
+ var _a5, batches_1, batches_1_1;
11037
+ var _b2, e_1, _c2, _d2;
11127
11038
  return __awaiter(this, void 0, void 0, function* () {
11128
11039
  try {
11129
- for (batches_1 = __asyncValues(batches); batches_1_1 = yield batches_1.next(), !batches_1_1.done; ) {
11130
- const batch = batches_1_1.value;
11131
- writer.write(batch);
11040
+ for (_a5 = true, batches_1 = __asyncValues(batches); batches_1_1 = yield batches_1.next(), _b2 = batches_1_1.done, !_b2; ) {
11041
+ _d2 = batches_1_1.value;
11042
+ _a5 = false;
11043
+ try {
11044
+ const batch = _d2;
11045
+ writer.write(batch);
11046
+ } finally {
11047
+ _a5 = true;
11048
+ }
11132
11049
  }
11133
11050
  } catch (e_1_1) {
11134
11051
  e_1 = { error: e_1_1 };
11135
11052
  } finally {
11136
11053
  try {
11137
- if (batches_1_1 && !batches_1_1.done && (_a5 = batches_1.return))
11138
- yield _a5.call(batches_1);
11054
+ if (!_a5 && !_b2 && (_c2 = batches_1.return))
11055
+ yield _c2.call(batches_1);
11139
11056
  } finally {
11140
11057
  if (e_1)
11141
11058
  throw e_1.error;
@@ -11145,7 +11062,7 @@ function writeAllAsync(writer, batches) {
11145
11062
  });
11146
11063
  }
11147
11064
 
11148
- // ../../node_modules/apache-arrow/io/whatwg/iterable.mjs
11065
+ // ../core/node_modules/apache-arrow/io/whatwg/iterable.mjs
11149
11066
  function toDOMStream(source, options) {
11150
11067
  if (isAsyncIterable(source)) {
11151
11068
  return asyncIterableAsReadableDOMStream(source, options);
@@ -11228,7 +11145,7 @@ function asyncIterableAsReadableDOMStream(source, options) {
11228
11145
  }
11229
11146
  }
11230
11147
 
11231
- // ../../node_modules/apache-arrow/io/whatwg/builder.mjs
11148
+ // ../core/node_modules/apache-arrow/io/whatwg/builder.mjs
11232
11149
  function builderThroughDOMStream(options) {
11233
11150
  return new BuilderTransform(options);
11234
11151
  }
@@ -11308,7 +11225,7 @@ var chunkByteLength = (chunk) => {
11308
11225
  return (_a5 = chunk === null || chunk === void 0 ? void 0 : chunk.byteLength) !== null && _a5 !== void 0 ? _a5 : 0;
11309
11226
  };
11310
11227
 
11311
- // ../../node_modules/apache-arrow/io/whatwg/reader.mjs
11228
+ // ../core/node_modules/apache-arrow/io/whatwg/reader.mjs
11312
11229
  function recordBatchReaderThroughDOMStream(writableStrategy, readableStrategy) {
11313
11230
  const queue = new AsyncByteQueue();
11314
11231
  let reader = null;
@@ -11350,7 +11267,7 @@ function recordBatchReaderThroughDOMStream(writableStrategy, readableStrategy) {
11350
11267
  }
11351
11268
  }
11352
11269
 
11353
- // ../../node_modules/apache-arrow/io/whatwg/writer.mjs
11270
+ // ../core/node_modules/apache-arrow/io/whatwg/writer.mjs
11354
11271
  function recordBatchWriterThroughDOMStream(writableStrategy, readableStrategy) {
11355
11272
  const writer = new this(writableStrategy);
11356
11273
  const reader = new AsyncByteStream(writer);
@@ -11388,7 +11305,7 @@ function recordBatchWriterThroughDOMStream(writableStrategy, readableStrategy) {
11388
11305
  }
11389
11306
  }
11390
11307
 
11391
- // ../../node_modules/apache-arrow/ipc/serialization.mjs
11308
+ // ../core/node_modules/apache-arrow/ipc/serialization.mjs
11392
11309
  function tableFromIPC(input) {
11393
11310
  const reader = RecordBatchReader.from(input);
11394
11311
  if (isPromise(reader)) {
@@ -11400,14 +11317,14 @@ function tableFromIPC(input) {
11400
11317
  return new Table(reader.readAll());
11401
11318
  }
11402
11319
 
11403
- // ../../node_modules/apache-arrow/Arrow.mjs
11320
+ // ../core/node_modules/apache-arrow/Arrow.mjs
11404
11321
  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), {
11405
11322
  compareSchemas,
11406
11323
  compareFields,
11407
11324
  compareTypes
11408
11325
  });
11409
11326
 
11410
- // ../../node_modules/apache-arrow/Arrow.dom.mjs
11327
+ // ../core/node_modules/apache-arrow/Arrow.dom.mjs
11411
11328
  adapters_default.toDOMStream = toDOMStream;
11412
11329
  Builder["throughDOM"] = builderThroughDOMStream;
11413
11330
  RecordBatchReader["throughDOM"] = recordBatchReaderThroughDOMStream;
@@ -11417,8 +11334,8 @@ RecordBatchWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
11417
11334
  RecordBatchFileWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
11418
11335
  RecordBatchStreamWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
11419
11336
 
11420
- // ../core/src/clients/socket.js
11421
- function socketClient(uri = "ws://localhost:3000/") {
11337
+ // ../core/src/connectors/socket.js
11338
+ function socketConnector(uri = "ws://localhost:3000/") {
11422
11339
  const queue = [];
11423
11340
  let connected = false;
11424
11341
  let request = null;
@@ -11537,22 +11454,35 @@ function jsType(type) {
11537
11454
 
11538
11455
  // ../sql/src/ref.js
11539
11456
  var Ref = class {
11457
+ /**
11458
+ * Create a new Ref instance.
11459
+ * @param {string|Ref|null} table The table name.
11460
+ * @param {string|null} column The column name.
11461
+ */
11540
11462
  constructor(table, column2) {
11541
11463
  if (table)
11542
11464
  this.table = String(table);
11543
11465
  if (column2)
11544
11466
  this.column = column2;
11545
11467
  }
11468
+ /**
11469
+ * Get the list of referenced columns. Either a single element array
11470
+ * if column is non-null, otherwise an empty array.
11471
+ */
11546
11472
  get columns() {
11547
11473
  return this.column ? [this.column] : [];
11548
11474
  }
11475
+ /**
11476
+ * Generate a SQL string for this reference.
11477
+ * @returns {string} The SQL string.
11478
+ */
11549
11479
  toString() {
11550
11480
  const { table, column: column2 } = this;
11551
11481
  if (column2) {
11552
- const col = column2 === "*" ? column2 : `"${column2}"`;
11553
- return (table ? `"${table}".` : "") + col;
11482
+ const col = column2.startsWith("*") ? column2 : `"${column2}"`;
11483
+ return `${table ? `"${table}".` : ""}${col}`;
11554
11484
  } else {
11555
- return `"${table}"`;
11485
+ return table ? `"${table}"` : "NULL";
11556
11486
  }
11557
11487
  }
11558
11488
  };
@@ -11569,24 +11499,33 @@ function relation(name) {
11569
11499
  return new Ref(name);
11570
11500
  }
11571
11501
  function column(table, column2) {
11572
- return arguments.length === 1 ? new Ref(null, table) : new Ref(table, column2);
11502
+ if (arguments.length === 1) {
11503
+ column2 = table;
11504
+ table = null;
11505
+ }
11506
+ return new Ref(table, column2);
11573
11507
  }
11574
11508
 
11575
11509
  // ../sql/src/to-sql.js
11576
- function toSQL(value) {
11577
- return typeof value === "string" ? `"${value}"` : literalToSQL(value);
11578
- }
11579
11510
  function literalToSQL(value) {
11580
11511
  switch (typeof value) {
11581
11512
  case "boolean":
11582
11513
  return value ? "TRUE" : "FALSE";
11583
11514
  case "string":
11584
11515
  return `'${value}'`;
11516
+ case "number":
11517
+ return Number.isFinite(value) ? String(value) : "NULL";
11585
11518
  default:
11586
11519
  if (value == null) {
11587
11520
  return "NULL";
11588
11521
  } else if (value instanceof Date) {
11589
- return `MAKE_DATE(${value.getUTCFullYear()}, ${value.getUTCMonth() + 1}, ${value.getUTCDate()})`;
11522
+ const ts = +value;
11523
+ if (Number.isNaN(ts))
11524
+ return "NULL";
11525
+ const y = value.getUTCFullYear();
11526
+ const m = value.getUTCMonth();
11527
+ const d = value.getUTCDate();
11528
+ return ts === Date.UTC(y, m, d) ? `MAKE_DATE(${y}, ${m + 1}, ${d})` : `EPOCH_MS(${ts})`;
11590
11529
  } else if (value instanceof RegExp) {
11591
11530
  return `'${value.source}'`;
11592
11531
  } else {
@@ -11596,263 +11535,406 @@ function literalToSQL(value) {
11596
11535
  }
11597
11536
 
11598
11537
  // ../sql/src/expression.js
11599
- function isExpression(e) {
11600
- return e instanceof SQLExpression;
11538
+ var isParamLike = (value) => typeof value?.addEventListener === "function";
11539
+ function isSQLExpression(value) {
11540
+ return value instanceof SQLExpression;
11601
11541
  }
11602
11542
  var SQLExpression = class {
11603
- constructor(sql2, columns, label) {
11604
- this.expr = sql2;
11605
- this.label = label;
11606
- this.columns = columns || [];
11607
- }
11608
- toString() {
11609
- return `${this.expr}`;
11610
- }
11611
- };
11612
- function expr(sql2, columns, label) {
11613
- return new SQLExpression(sql2, columns, label);
11614
- }
11615
- function desc(e) {
11616
- return Object.assign(
11617
- expr(`${asColumn(e)} DESC NULLS LAST`, e?.columns, e?.label),
11618
- { desc: true }
11619
- );
11620
- }
11621
- function transform(func2, label) {
11622
- return (value) => expr(func2(value), asColumn(value).columns, label);
11623
- }
11624
-
11625
- // ../sql/src/literal.js
11626
- var Literal = class {
11627
- constructor(value) {
11628
- this.value = value;
11629
- }
11630
- toString() {
11631
- return literalToSQL(this.value);
11543
+ /**
11544
+ * Create a new SQL expression instance.
11545
+ * @param {(string|SQLExpression|Ref)[]} parts The parts of the expression.
11546
+ * @param {string[]} [columns=[]] The column dependencies
11547
+ * @param {object} [props] Additional properties for this expression.
11548
+ */
11549
+ constructor(parts, columns, props) {
11550
+ this._expr = Array.isArray(parts) ? parts : [parts];
11551
+ this._deps = columns || [];
11552
+ this.annotate(props);
11553
+ const params = this._expr.filter((part) => isParamLike(part));
11554
+ if (params.length > 0) {
11555
+ this._params = Array.from(new Set(params));
11556
+ this._params.forEach((param) => {
11557
+ param.addEventListener("value", () => update(this, this.map?.get("value")));
11558
+ });
11559
+ } else {
11560
+ this.addEventListener = void 0;
11561
+ }
11632
11562
  }
11633
- };
11634
- var literal = (value) => new Literal(value);
11635
-
11636
- // ../sql/src/compare.js
11637
- function extractColumns(...args) {
11638
- return args.flat().flatMap((arg) => arg?.columns || []);
11639
- }
11640
- var Compare1 = class {
11641
- constructor(op, a) {
11642
- this.op = op;
11643
- this.a = asColumn(a);
11563
+ /**
11564
+ * A reference to this expression.
11565
+ * Provides compatibility with param-like objects.
11566
+ */
11567
+ get value() {
11568
+ return this;
11644
11569
  }
11570
+ /**
11571
+ * The column dependencies of this expression.
11572
+ * @returns {string[]} The columns dependencies.
11573
+ */
11645
11574
  get columns() {
11646
- return extractColumns(this.a);
11647
- }
11648
- visit(callback) {
11649
- callback(this.op, this);
11650
- }
11651
- toString() {
11652
- const { op, a } = this;
11653
- return `(${toSQL(a)} ${op})`;
11654
- }
11655
- };
11656
- function compare1(op) {
11657
- return (a) => new Compare1(op, a);
11658
- }
11659
- var not = compare1("NOT");
11660
- var isNull = compare1("IS NULL");
11661
- var isNotNull = compare1("IS NOT NULL");
11662
- var Compare2 = class {
11663
- constructor(op, a, b) {
11664
- this.op = op;
11665
- this.a = asColumn(a);
11666
- this.b = asColumn(b);
11575
+ const { _params, _deps } = this;
11576
+ if (_params) {
11577
+ const pset = new Set(_params.flatMap((p) => {
11578
+ const cols = p.value?.columns;
11579
+ return Array.isArray(cols) ? cols : [];
11580
+ }));
11581
+ if (pset.size) {
11582
+ const set = new Set(_deps);
11583
+ pset.forEach((col) => set.add(col));
11584
+ return Array.from(set);
11585
+ }
11586
+ }
11587
+ return _deps;
11667
11588
  }
11668
- get columns() {
11669
- return extractColumns(this.a, this.b);
11589
+ /**
11590
+ * The first column dependency in this expression, or undefined if none.
11591
+ * @returns {string} The first column dependency.
11592
+ */
11593
+ get column() {
11594
+ return this._deps.length ? this._deps[0] : this.columns[0];
11670
11595
  }
11671
- visit(callback) {
11672
- callback(this.op, this);
11596
+ /**
11597
+ * Annotate this expression instance with additional properties.
11598
+ * @param {object[]} [props] One or more objects with properties to add.
11599
+ * @returns {this} This SQL expression.
11600
+ */
11601
+ annotate(...props) {
11602
+ return Object.assign(this, ...props);
11673
11603
  }
11604
+ /**
11605
+ * Generate a SQL code string corresponding to this expression.
11606
+ * @returns {string} A SQL code string.
11607
+ */
11674
11608
  toString() {
11675
- const { op, a, b } = this;
11676
- return `(${toSQL(a)} ${op} ${toSQL(b)})`;
11677
- }
11678
- };
11679
- function compare2(op) {
11680
- return (a, b) => new Compare2(op, a, b);
11681
- }
11682
- var eq = compare2("=");
11683
- var neq = compare2("<>");
11684
- var lt = compare2("<");
11685
- var gt = compare2(">");
11686
- var lte = compare2("<=");
11687
- var gte = compare2(">=");
11688
- var isDistinct = compare2("IS DISTINCT FROM");
11689
- var isNotDistinct = compare2("IS NOT DISTINCT FROM");
11690
- var Range = class {
11691
- constructor(op, expr2, value) {
11692
- this.op = op;
11693
- this.expr = asColumn(expr2);
11694
- this.value = value?.map(asColumn);
11609
+ return this._expr.map((p) => isParamLike(p) && !isSQLExpression(p) ? literalToSQL(p.value) : p).join("");
11695
11610
  }
11696
- get columns() {
11697
- return extractColumns(this.expr, this.value);
11698
- }
11699
- visit(callback) {
11700
- callback(this.op, this);
11701
- }
11702
- toString() {
11703
- const { op, expr: expr2, value } = this;
11704
- if (!value)
11705
- return "";
11706
- const [a, b] = value;
11707
- return `(${toSQL(expr2)} ${op} ${toSQL(a)} AND ${toSQL(b)})`;
11611
+ /**
11612
+ * Add an event listener callback for the provided event type.
11613
+ * @param {string} type The event type to listen for (for example, "value").
11614
+ * @param {(a: SQLExpression) => Promise?} callback The callback function to
11615
+ * invoke upon updates. A callback may optionally return a Promise that
11616
+ * upstream listeners may await before proceeding.
11617
+ */
11618
+ addEventListener(type, callback) {
11619
+ const map = this.map || (this.map = /* @__PURE__ */ new Map());
11620
+ const set = map.get(type) || (map.set(type, /* @__PURE__ */ new Set()), map.get(type));
11621
+ set.add(callback);
11708
11622
  }
11709
11623
  };
11710
- function range(op) {
11711
- return (a, range2) => new Range(op, a, range2);
11712
- }
11713
- var isBetween = range("BETWEEN");
11714
- var isNotBetween = range("NOT BETWEEN");
11715
- var CompareN = class {
11716
- constructor(op, value) {
11717
- this.op = op;
11718
- this.value = value.map(asColumn);
11719
- }
11720
- get columns() {
11721
- return extractColumns(this.value);
11624
+ function update(expr, callbacks) {
11625
+ if (callbacks?.size) {
11626
+ return Promise.allSettled(Array.from(callbacks, (fn) => fn(expr)));
11722
11627
  }
11723
- visit(callback) {
11724
- callback(this.op, this);
11725
- this.value?.forEach((v) => v.visit(callback));
11726
- }
11727
- toString() {
11728
- const { op, value } = this;
11729
- return !value || value.length === 0 ? "" : value.length === 1 ? toSQL(value[0]) : `(${value.map(toSQL).filter((x) => x).join(` ${op} `)})`;
11628
+ }
11629
+ function parseSQL(strings, exprs) {
11630
+ const spans = [strings[0]];
11631
+ const cols = /* @__PURE__ */ new Set();
11632
+ const n = exprs.length;
11633
+ for (let i = 0, k = 0; i < n; ) {
11634
+ const e = exprs[i];
11635
+ if (isParamLike(e)) {
11636
+ spans[++k] = e;
11637
+ } else {
11638
+ if (Array.isArray(e?.columns)) {
11639
+ e.columns.forEach((col) => cols.add(col));
11640
+ }
11641
+ spans[k] += typeof e === "string" ? e : literalToSQL(e);
11642
+ }
11643
+ const s = strings[++i];
11644
+ if (isParamLike(spans[k])) {
11645
+ spans[++k] = s;
11646
+ } else {
11647
+ spans[k] += s;
11648
+ }
11730
11649
  }
11731
- };
11732
- function and(...clauses) {
11733
- return new CompareN("AND", clauses.flat());
11650
+ return { spans, cols: Array.from(cols) };
11734
11651
  }
11735
- function or(...clauses) {
11736
- return new CompareN("OR", clauses.flat());
11652
+ function sql(strings, ...exprs) {
11653
+ const { spans, cols } = parseSQL(strings, exprs);
11654
+ return new SQLExpression(spans, cols);
11737
11655
  }
11738
11656
 
11739
- // ../sql/src/function-call.js
11740
- var FunctionCall = class {
11741
- constructor(func2, args) {
11742
- this.func = func2;
11743
- this.args = (args || []).map(asColumn);
11744
- }
11745
- get column() {
11746
- return this.columns[0];
11657
+ // ../sql/src/desc.js
11658
+ function desc(expr) {
11659
+ const e = asColumn(expr);
11660
+ return sql`${e} DESC NULLS LAST`.annotate({ label: e?.label, desc: true });
11661
+ }
11662
+
11663
+ // ../sql/src/literal.js
11664
+ var literal = (value) => ({
11665
+ value,
11666
+ toString: () => literalToSQL(value)
11667
+ });
11668
+
11669
+ // ../sql/src/operators.js
11670
+ function visit(callback) {
11671
+ callback(this.op, this);
11672
+ this.children?.forEach((v) => v.visit(callback));
11673
+ }
11674
+ function logical(op, clauses) {
11675
+ const children = clauses.filter((x) => x != null).map(asColumn);
11676
+ const strings = children.map((c, i) => i ? ` ${op} ` : "");
11677
+ if (clauses.length)
11678
+ strings.push("");
11679
+ return sql(strings, ...children).annotate({ op, children, visit });
11680
+ }
11681
+ var and = (...clauses) => logical("AND", clauses.flat());
11682
+ var or = (...clauses) => logical("OR", clauses.flat());
11683
+ var unaryOp = (op) => (a) => sql`(${op} ${asColumn(a)})`.annotate({ op, a, visit });
11684
+ var not = unaryOp("NOT");
11685
+ var unaryPostOp = (op) => (a) => sql`(${asColumn(a)} ${op})`.annotate({ op, a, visit });
11686
+ var isNull = unaryPostOp("IS NULL");
11687
+ var isNotNull = unaryPostOp("IS NOT NULL");
11688
+ var binaryOp = (op) => (a, b) => sql`(${asColumn(a)} ${op} ${asColumn(b)})`.annotate({ op, a, b, visit });
11689
+ var eq = binaryOp("=");
11690
+ var neq = binaryOp("<>");
11691
+ var lt = binaryOp("<");
11692
+ var gt = binaryOp(">");
11693
+ var lte = binaryOp("<=");
11694
+ var gte = binaryOp(">=");
11695
+ var isDistinct = binaryOp("IS DISTINCT FROM");
11696
+ var isNotDistinct = binaryOp("IS NOT DISTINCT FROM");
11697
+ function rangeOp(op, a, range, exclusive) {
11698
+ a = asColumn(a);
11699
+ const prefix2 = op.startsWith("NOT ") ? "NOT " : "";
11700
+ const expr = !range ? sql`` : exclusive ? sql`${prefix2}(${range[0]} <= ${a} AND ${a} < ${range[1]})` : sql`(${a} ${op} ${range[0]} AND ${range[1]})`;
11701
+ return expr.annotate({ op, visit, field: a, range });
11702
+ }
11703
+ var isBetween = (a, range, exclusive) => rangeOp("BETWEEN", a, range, exclusive);
11704
+
11705
+ // ../sql/src/repeat.js
11706
+ function repeat(length2, str) {
11707
+ return Array.from({ length: length2 }, () => str);
11708
+ }
11709
+
11710
+ // ../sql/src/functions.js
11711
+ function functionCall(op, type) {
11712
+ return (...values) => {
11713
+ const args = values.map(asColumn);
11714
+ const cast2 = type ? `::${type}` : "";
11715
+ const expr = args.length ? sql([`${op}(`, ...repeat(args.length - 1, ", "), `)${cast2}`], ...args) : sql`${op}()${cast2}`;
11716
+ return expr.annotate({ func: op, args });
11717
+ };
11718
+ }
11719
+ var regexp_matches = functionCall("REGEXP_MATCHES");
11720
+ var contains = functionCall("CONTAINS");
11721
+ var prefix = functionCall("PREFIX");
11722
+ var suffix = functionCall("SUFFIX");
11723
+ var lower = functionCall("LOWER");
11724
+ var upper = functionCall("UPPER");
11725
+ var length = functionCall("LENGTH");
11726
+ var isNaN2 = functionCall("ISNAN");
11727
+ var isFinite = functionCall("ISFINITE");
11728
+ var isInfinite = functionCall("ISINF");
11729
+
11730
+ // ../sql/src/windows.js
11731
+ var WindowFunction = class extends SQLExpression {
11732
+ constructor(op, func, type, name, group = "", order = "", frame = "") {
11733
+ let expr;
11734
+ const noWindowParams = !(group || order || frame);
11735
+ if (name && noWindowParams) {
11736
+ expr = name ? sql`${func} OVER "${name}"` : sql`${func} OVER ()`;
11737
+ } else {
11738
+ const s1 = group && order ? " " : "";
11739
+ const s2 = (group || order) && frame ? " " : "";
11740
+ expr = sql`${func} OVER (${name ? `"${name}" ` : ""}${group}${s1}${order}${s2}${frame})`;
11741
+ }
11742
+ if (type) {
11743
+ expr = sql`(${expr})::${type}`;
11744
+ }
11745
+ const { _expr, _deps } = expr;
11746
+ super(_expr, _deps, { window: op, func, type, name, group, order, frame });
11747
11747
  }
11748
- get columns() {
11749
- return this.args.flatMap((a) => a.columns || []);
11748
+ get basis() {
11749
+ return this.column;
11750
11750
  }
11751
- toString() {
11752
- const { func: func2, args } = this;
11753
- return `${func2}(${args.map(toSQL).join(", ")})`;
11754
- }
11755
- };
11756
- function func(op) {
11757
- return (...args) => new FunctionCall(op, args);
11758
- }
11759
- var regexp_matches = func("regexp_matches");
11760
- var contains = func("contains");
11761
- var prefix = func("prefix");
11762
- var suffix = func("suffix");
11763
- var lower = func("lower");
11764
- var upper = func("upper");
11765
- var length = func("length");
11766
- var isNaN2 = func("isnan");
11767
- var isFinite = func("isfinite");
11768
- var isInfinite = func("isinf");
11769
-
11770
- // ../sql/src/aggregate.js
11771
- var Aggregate = class {
11772
- constructor(op, args) {
11773
- this.aggregate = op;
11774
- this.args = (args || []).map(asColumn);
11751
+ get label() {
11752
+ const { func } = this;
11753
+ return func.label ?? func.toString();
11754
+ }
11755
+ over(name) {
11756
+ const { window: op, func, type, group, order, frame } = this;
11757
+ return new WindowFunction(op, func, type, name, group, order, frame);
11758
+ }
11759
+ partitionby(...expr) {
11760
+ const exprs = expr.flat().filter((x) => x).map(asColumn);
11761
+ const group = sql(
11762
+ ["PARTITION BY ", repeat(exprs.length - 1, ", "), ""],
11763
+ ...exprs
11764
+ );
11765
+ const { window: op, func, type, name, order, frame } = this;
11766
+ return new WindowFunction(op, func, type, name, group, order, frame);
11767
+ }
11768
+ orderby(...expr) {
11769
+ const exprs = expr.flat().filter((x) => x).map(asColumn);
11770
+ const order = sql(
11771
+ ["ORDER BY ", repeat(exprs.length - 1, ", "), ""],
11772
+ ...exprs
11773
+ );
11774
+ const { window: op, func, type, name, group, frame } = this;
11775
+ return new WindowFunction(op, func, type, name, group, order, frame);
11776
+ }
11777
+ rows(expr) {
11778
+ const frame = windowFrame("ROWS", expr);
11779
+ const { window: op, func, type, name, group, order } = this;
11780
+ return new WindowFunction(op, func, type, name, group, order, frame);
11781
+ }
11782
+ range(expr) {
11783
+ const frame = windowFrame("RANGE", expr);
11784
+ const { window: op, func, type, name, group, order } = this;
11785
+ return new WindowFunction(op, func, type, name, group, order, frame);
11786
+ }
11787
+ };
11788
+ function windowFrame(type, frame) {
11789
+ if (isParamLike(frame)) {
11790
+ const expr = sql`${frame}`;
11791
+ expr.toString = () => `${type} ${frameToSQL(frame.value)}`;
11792
+ return expr;
11793
+ }
11794
+ return `${type} ${frameToSQL(frame)}`;
11795
+ }
11796
+ function frameToSQL(frame) {
11797
+ const [prev, next] = frame;
11798
+ const a = prev === 0 ? "CURRENT ROW" : Number.isFinite(prev) ? `${Math.abs(prev)} PRECEDING` : "UNBOUNDED PRECEDING";
11799
+ const b = next === 0 ? "CURRENT ROW" : Number.isFinite(next) ? `${Math.abs(next)} FOLLOWING` : "UNBOUNDED FOLLOWING";
11800
+ return `BETWEEN ${a} AND ${b}`;
11801
+ }
11802
+ function winf(op, type) {
11803
+ return (...values) => {
11804
+ const func = functionCall(op)(...values);
11805
+ return new WindowFunction(op, func, type);
11806
+ };
11807
+ }
11808
+ var row_number = winf("ROW_NUMBER", "INTEGER");
11809
+ var rank = winf("RANK", "INTEGER");
11810
+ var dense_rank = winf("DENSE_RANK", "INTEGER");
11811
+ var percent_rank = winf("PERCENT_RANK");
11812
+ var cume_dist = winf("CUME_DIST");
11813
+ var ntile = winf("NTILE");
11814
+ var lag = winf("LAG");
11815
+ var lead = winf("LEAD");
11816
+ var first_value = winf("FIRST_VALUE");
11817
+ var last_value = winf("LAST_VALUE");
11818
+ var nth_value = winf("NTH_VALUE");
11819
+
11820
+ // ../sql/src/aggregates.js
11821
+ var AggregateFunction = class extends SQLExpression {
11822
+ constructor(op, args, type, isDistinct2, filter) {
11823
+ args = (args || []).map(asColumn);
11824
+ const { strings, exprs } = aggExpr(op, args, type, isDistinct2, filter);
11825
+ const { spans, cols } = parseSQL(strings, exprs);
11826
+ super(spans, cols, { aggregate: op, args, type, isDistinct: isDistinct2, filter });
11827
+ }
11828
+ get basis() {
11829
+ return this.column;
11775
11830
  }
11776
11831
  get label() {
11777
- return this.aggregate.toLowerCase() + (this.args.length ? ` ${this.columns.join(", ")}` : "");
11832
+ const { aggregate: op, args, isDistinct: isDistinct2 } = this;
11833
+ const dist = isDistinct2 ? "DISTINCT" + (args.length ? " " : "") : "";
11834
+ const tail = args.length ? `(${dist}${args.map(unquoted).join(", ")})` : "";
11835
+ return `${op.toLowerCase()}${tail}`;
11778
11836
  }
11779
- get column() {
11780
- return this.columns[0];
11837
+ distinct() {
11838
+ const { aggregate: op, args, type, filter } = this;
11839
+ return new AggregateFunction(op, args, type, true, filter);
11781
11840
  }
11782
- get columns() {
11783
- return this.args.flatMap((a) => a.columns || []);
11841
+ where(filter) {
11842
+ const { aggregate: op, args, type, isDistinct: isDistinct2 } = this;
11843
+ return new AggregateFunction(op, args, type, isDistinct2, filter);
11784
11844
  }
11785
- distinct() {
11786
- this.isDistinct = true;
11787
- return this;
11845
+ window() {
11846
+ const { aggregate: op, args, type, isDistinct: isDistinct2 } = this;
11847
+ const func = new AggregateFunction(op, args, null, isDistinct2);
11848
+ return new WindowFunction(op, func, type);
11788
11849
  }
11789
- where(expr2) {
11790
- this.filter = expr2;
11791
- return this;
11850
+ partitionby(...expr) {
11851
+ return this.window().partitionby(...expr);
11792
11852
  }
11793
- toString() {
11794
- const { aggregate, args, isDistinct: isDistinct2, filter } = this;
11795
- const arg = args.length === 0 ? "*" : args.map(toSQL).join(", ");
11796
- const distinct2 = isDistinct2 ? "DISTINCT " : "";
11797
- const where = filter ? ` FILTER (WHERE ${toSQL(filter)})` : "";
11798
- const cast = aggregate === "COUNT" ? "::INTEGER" : "";
11799
- return where && cast ? `(${aggregate}(${distinct2}${arg})${where})${cast}` : `${aggregate}(${distinct2}${arg})${where}${cast}`;
11800
- }
11801
- };
11802
- function agg(op) {
11803
- return (...args) => new Aggregate(op, args);
11804
- }
11805
- var count = agg("COUNT");
11806
- var avg = agg("AVG");
11807
- var mean = agg("AVG");
11808
- var mad = agg("MAD");
11809
- var max = agg("MAX");
11810
- var min = agg("MIN");
11811
- var sum2 = agg("SUM");
11812
- var product = agg("PRODUCT");
11813
- var median = agg("MEDIAN");
11814
- var quantile = agg("QUANTILE");
11815
- var mode = agg("MODE");
11816
- var variance = agg("VARIANCE");
11817
- var stddev = agg("STDDEV");
11818
- var skewness = agg("SKEWNESS");
11819
- var kurtosis = agg("KURTOSIS");
11820
- var entropy = agg("ENTROPY");
11821
- var varPop = agg("VAR_POP");
11822
- var stddevPop = agg("STDDEV_POP");
11823
- var corr = agg("CORR");
11824
- var covarPop = agg("COVAR_POP");
11825
- var regrIntercept = agg("REGR_INTERCEPT");
11826
- var regrSlope = agg("REGR_SLOPE");
11827
- var regrCount = agg("REGR_COUNT");
11828
- var regrR2 = agg("REGR_R2");
11829
- var regrSYY = agg("REGR_SYY");
11830
- var regrSXX = agg("REGR_SXX");
11831
- var regrSXY = agg("REGR_SXY");
11832
- var regrAvgX = agg("REGR_AVGX");
11833
- var regrAvgY = agg("REGR_AVGY");
11834
- var first = agg("FIRST");
11835
- var last = agg("LAST");
11836
- var argmin = agg("ARG_MIN");
11837
- var argmax = agg("ARG_MAX");
11838
- var stringAgg = agg("STRING_AGG");
11839
- var arrayAgg = agg("ARRAY_AGG");
11853
+ orderby(...expr) {
11854
+ return this.window().orderby(...expr);
11855
+ }
11856
+ rows(prev, next) {
11857
+ return this.window().rows(prev, next);
11858
+ }
11859
+ range(prev, next) {
11860
+ return this.window().range(prev, next);
11861
+ }
11862
+ };
11863
+ function aggExpr(op, args, type, isDistinct2, filter) {
11864
+ const close = `)${type ? `::${type}` : ""}`;
11865
+ let strings = [`${op}(${isDistinct2 ? "DISTINCT " : ""}`];
11866
+ let exprs = [];
11867
+ if (args.length) {
11868
+ strings = strings.concat([
11869
+ ...repeat(args.length - 1, ", "),
11870
+ `${close}${filter ? " FILTER (WHERE " : ""}`,
11871
+ ...filter ? [")"] : []
11872
+ ]);
11873
+ exprs = [...args, ...filter ? [filter] : []];
11874
+ } else {
11875
+ strings[0] += "*" + close;
11876
+ }
11877
+ return { exprs, strings };
11878
+ }
11879
+ function unquoted(value) {
11880
+ const s = literalToSQL(value);
11881
+ return s && s.startsWith('"') && s.endsWith('"') ? s.slice(1, -1) : s;
11882
+ }
11883
+ function aggf(op, type) {
11884
+ return (...args) => new AggregateFunction(op, args, type);
11885
+ }
11886
+ var count = aggf("COUNT", "INTEGER");
11887
+ var avg = aggf("AVG");
11888
+ var mean = aggf("AVG");
11889
+ var mad = aggf("MAD");
11890
+ var max = aggf("MAX");
11891
+ var min = aggf("MIN");
11892
+ var sum2 = aggf("SUM", "DOUBLE");
11893
+ var product = aggf("PRODUCT");
11894
+ var median = aggf("MEDIAN");
11895
+ var quantile = aggf("QUANTILE");
11896
+ var mode = aggf("MODE");
11897
+ var variance = aggf("VARIANCE");
11898
+ var stddev = aggf("STDDEV");
11899
+ var skewness = aggf("SKEWNESS");
11900
+ var kurtosis = aggf("KURTOSIS");
11901
+ var entropy = aggf("ENTROPY");
11902
+ var varPop = aggf("VAR_POP");
11903
+ var stddevPop = aggf("STDDEV_POP");
11904
+ var corr = aggf("CORR");
11905
+ var covarPop = aggf("COVAR_POP");
11906
+ var regrIntercept = aggf("REGR_INTERCEPT");
11907
+ var regrSlope = aggf("REGR_SLOPE");
11908
+ var regrCount = aggf("REGR_COUNT");
11909
+ var regrR2 = aggf("REGR_R2");
11910
+ var regrSYY = aggf("REGR_SYY");
11911
+ var regrSXX = aggf("REGR_SXX");
11912
+ var regrSXY = aggf("REGR_SXY");
11913
+ var regrAvgX = aggf("REGR_AVGX");
11914
+ var regrAvgY = aggf("REGR_AVGY");
11915
+ var first = aggf("FIRST");
11916
+ var last = aggf("LAST");
11917
+ var argmin = aggf("ARG_MIN");
11918
+ var argmax = aggf("ARG_MAX");
11919
+ var stringAgg = aggf("STRING_AGG");
11920
+ var arrayAgg = aggf("ARRAY_AGG");
11840
11921
 
11841
11922
  // ../sql/src/datetime.js
11842
- var epoch_ms = transform(
11843
- (d) => `(1000 * (epoch(${d}) - second(${d})) + millisecond(${d}))::DOUBLE`
11844
- );
11923
+ var epoch_ms = (expr) => {
11924
+ const d = asColumn(expr);
11925
+ return sql`(1000 * (epoch(${d}) - second(${d})) + millisecond(${d}))::DOUBLE`;
11926
+ };
11845
11927
 
11846
11928
  // ../sql/src/Query.js
11847
11929
  var Query = class {
11848
- static select(...expr2) {
11849
- return new Query().select(...expr2);
11930
+ static select(...expr) {
11931
+ return new Query().select(...expr);
11850
11932
  }
11851
- static from(...expr2) {
11852
- return new Query().from(...expr2);
11933
+ static from(...expr) {
11934
+ return new Query().from(...expr);
11853
11935
  }
11854
- static with(...expr2) {
11855
- return new Query().with(...expr2);
11936
+ static with(...expr) {
11937
+ return new Query().with(...expr);
11856
11938
  }
11857
11939
  static union(...queries) {
11858
11940
  return new SetOperation("UNION", queries.flat());
@@ -11884,9 +11966,9 @@ var Query = class {
11884
11966
  q.query = { ...this.query };
11885
11967
  return q;
11886
11968
  }
11887
- with(...expr2) {
11969
+ with(...expr) {
11888
11970
  const { query } = this;
11889
- if (expr2.length === 0) {
11971
+ if (expr.length === 0) {
11890
11972
  return query.with;
11891
11973
  } else {
11892
11974
  const list = [];
@@ -11895,7 +11977,7 @@ var Query = class {
11895
11977
  query2.cteFor = this;
11896
11978
  list.push({ as, query: query2 });
11897
11979
  };
11898
- expr2.flat().forEach((e) => {
11980
+ expr.flat().forEach((e) => {
11899
11981
  if (e == null) {
11900
11982
  } else if (e.as && e.query) {
11901
11983
  add(e.as, e.query);
@@ -11909,13 +11991,13 @@ var Query = class {
11909
11991
  return this;
11910
11992
  }
11911
11993
  }
11912
- select(...expr2) {
11994
+ select(...expr) {
11913
11995
  const { query } = this;
11914
- if (expr2.length === 0) {
11996
+ if (expr.length === 0) {
11915
11997
  return query.select;
11916
11998
  } else {
11917
11999
  const list = [];
11918
- expr2.flat().forEach((e) => {
12000
+ for (const e of expr.flat()) {
11919
12001
  if (e == null) {
11920
12002
  } else if (typeof e === "string") {
11921
12003
  list.push({ as: e, expr: asColumn(e) });
@@ -11928,32 +12010,32 @@ var Query = class {
11928
12010
  list.push({ as: unquote(as), expr: asColumn(e[as]) });
11929
12011
  }
11930
12012
  }
11931
- });
12013
+ }
11932
12014
  query.select = query.select.concat(list);
11933
12015
  return this;
11934
12016
  }
11935
12017
  }
11936
- $select(...expr2) {
12018
+ $select(...expr) {
11937
12019
  this.query.select = [];
11938
- return this.select(...expr2);
12020
+ return this.select(...expr);
11939
12021
  }
11940
12022
  distinct(value = true) {
11941
12023
  this.query.distinct = !!value;
11942
12024
  return this;
11943
12025
  }
11944
- from(...expr2) {
12026
+ from(...expr) {
11945
12027
  const { query } = this;
11946
- if (expr2.length === 0) {
12028
+ if (expr.length === 0) {
11947
12029
  return query.from;
11948
12030
  } else {
11949
12031
  const list = [];
11950
- expr2.flat().forEach((e) => {
12032
+ expr.flat().forEach((e) => {
11951
12033
  if (e == null) {
11952
12034
  } else if (typeof e === "string") {
11953
12035
  list.push({ as: e, from: asRelation(e) });
11954
12036
  } else if (e instanceof Ref) {
11955
12037
  list.push({ as: e.table, from: e });
11956
- } else if (isQuery(e) || isExpression(e)) {
12038
+ } else if (isQuery(e) || isSQLExpression(e)) {
11957
12039
  list.push({ from: e });
11958
12040
  } else if (Array.isArray(e)) {
11959
12041
  list.push({ as: unquote(e[0]), from: asRelation(e[1]) });
@@ -11967,67 +12049,67 @@ var Query = class {
11967
12049
  return this;
11968
12050
  }
11969
12051
  }
11970
- $from(...expr2) {
12052
+ $from(...expr) {
11971
12053
  this.query.from = [];
11972
- return this.from(...expr2);
12054
+ return this.from(...expr);
11973
12055
  }
11974
- sample(value) {
12056
+ sample(value, method) {
11975
12057
  const { query } = this;
11976
12058
  if (arguments.length === 0) {
11977
12059
  return query.sample;
11978
12060
  } else {
11979
12061
  let spec = value;
11980
12062
  if (typeof value === "number") {
11981
- spec = value > 0 && value < 1 ? { perc: 100 * value } : { rows: Math.round(value) };
12063
+ spec = value > 0 && value < 1 ? { perc: 100 * value, method } : { rows: Math.round(value, method) };
11982
12064
  }
11983
12065
  query.sample = spec;
11984
12066
  return this;
11985
12067
  }
11986
12068
  }
11987
- where(...expr2) {
12069
+ where(...expr) {
11988
12070
  const { query } = this;
11989
- if (expr2.length === 0) {
12071
+ if (expr.length === 0) {
11990
12072
  return query.where;
11991
12073
  } else {
11992
12074
  query.where = query.where.concat(
11993
- expr2.flat().filter((x) => x)
12075
+ expr.flat().filter((x) => x)
11994
12076
  );
11995
12077
  return this;
11996
12078
  }
11997
12079
  }
11998
- $where(...expr2) {
12080
+ $where(...expr) {
11999
12081
  this.query.where = [];
12000
- return this.where(...expr2);
12082
+ return this.where(...expr);
12001
12083
  }
12002
- groupby(...expr2) {
12084
+ groupby(...expr) {
12003
12085
  const { query } = this;
12004
- if (expr2.length === 0) {
12086
+ if (expr.length === 0) {
12005
12087
  return query.groupby;
12006
12088
  } else {
12007
12089
  query.groupby = query.groupby.concat(
12008
- expr2.flat().filter((x) => x).map(asColumn)
12090
+ expr.flat().filter((x) => x).map(asColumn)
12009
12091
  );
12010
12092
  return this;
12011
12093
  }
12012
12094
  }
12013
- having(...expr2) {
12095
+ having(...expr) {
12014
12096
  const { query } = this;
12015
- if (expr2.length === 0) {
12097
+ if (expr.length === 0) {
12016
12098
  return query.having;
12017
12099
  } else {
12018
12100
  query.having = query.having.concat(
12019
- expr2.flat().filter((x) => x)
12101
+ expr.flat().filter((x) => x)
12020
12102
  );
12021
12103
  return this;
12022
12104
  }
12023
12105
  }
12024
- window(...expr2) {
12106
+ window(...expr) {
12025
12107
  const { query } = this;
12026
- if (expr2.length === 0) {
12108
+ if (expr.length === 0) {
12027
12109
  return query.window;
12028
12110
  } else {
12029
12111
  const list = [];
12030
- expr2.flat().forEach((e) => {
12112
+ expr.flat().forEach((e) => {
12031
12113
  if (e == null) {
12032
12114
  } else {
12033
12115
  for (const as in e) {
@@ -12039,24 +12121,24 @@ var Query = class {
12039
12121
  return this;
12040
12122
  }
12041
12123
  }
12042
- qualify(...expr2) {
12124
+ qualify(...expr) {
12043
12125
  const { query } = this;
12044
- if (expr2.length === 0) {
12126
+ if (expr.length === 0) {
12045
12127
  return query.qualify;
12046
12128
  } else {
12047
12129
  query.qualify = query.qualify.concat(
12048
- expr2.flat().filter((x) => x)
12130
+ expr.flat().filter((x) => x)
12049
12131
  );
12050
12132
  return this;
12051
12133
  }
12052
12134
  }
12053
- orderby(...expr2) {
12135
+ orderby(...expr) {
12054
12136
  const { query } = this;
12055
- if (expr2.length === 0) {
12137
+ if (expr.length === 0) {
12056
12138
  return query.orderby;
12057
12139
  } else {
12058
12140
  query.orderby = query.orderby.concat(
12059
- expr2.flat().filter((x) => x).map(asColumn)
12141
+ expr.flat().filter((x) => x).map(asColumn)
12060
12142
  );
12061
12143
  return this;
12062
12144
  }
@@ -12116,7 +12198,7 @@ var Query = class {
12116
12198
  sql2.push(`WITH ${list.join(", ")}`);
12117
12199
  }
12118
12200
  const sels = select.map(
12119
- ({ as, expr: expr2 }) => isColumnRefFor(expr2, as) && !expr2.table ? `${expr2}` : `${expr2} AS "${as}"`
12201
+ ({ as, expr }) => isColumnRefFor(expr, as) && !expr.table ? `${expr}` : `${expr} AS "${as}"`
12120
12202
  );
12121
12203
  sql2.push(`SELECT${distinct2 ? " DISTINCT" : ""} ${sels.join(", ")}`);
12122
12204
  if (from.length) {
@@ -12126,17 +12208,17 @@ var Query = class {
12126
12208
  });
12127
12209
  sql2.push(`FROM ${rels.join(", ")}`);
12128
12210
  }
12211
+ if (where.length) {
12212
+ const clauses = where.map(String).filter((x) => x).join(" AND ");
12213
+ if (clauses)
12214
+ sql2.push(`WHERE ${clauses}`);
12215
+ }
12129
12216
  if (sample) {
12130
12217
  const { rows, perc, method, seed } = sample;
12131
12218
  const size = rows ? `${rows} ROWS` : `${perc} PERCENT`;
12132
12219
  const how = method ? ` (${method}${seed != null ? `, ${seed}` : ""})` : "";
12133
12220
  sql2.push(`USING SAMPLE ${size}${how}`);
12134
12221
  }
12135
- if (where.length) {
12136
- const clauses = where.map(String).filter((x) => x).join(" AND ");
12137
- if (clauses)
12138
- sql2.push(`WHERE ${clauses}`);
12139
- }
12140
12222
  if (groupby.length) {
12141
12223
  sql2.push(`GROUP BY ${groupby.join(", ")}`);
12142
12224
  }
@@ -12146,7 +12228,7 @@ var Query = class {
12146
12228
  sql2.push(`HAVING ${clauses}`);
12147
12229
  }
12148
12230
  if (window.length) {
12149
- const windows = window.map(({ as, expr: expr2 }) => `"${as}" AS (${expr2})`);
12231
+ const windows = window.map(({ as, expr }) => `"${as}" AS (${expr})`);
12150
12232
  sql2.push(`WINDOW ${windows.join(", ")}`);
12151
12233
  }
12152
12234
  if (qualify.length) {
@@ -12177,13 +12259,13 @@ var SetOperation = class {
12177
12259
  q.query = { ...this.query };
12178
12260
  return q;
12179
12261
  }
12180
- orderby(...expr2) {
12262
+ orderby(...expr) {
12181
12263
  const { query } = this;
12182
- if (expr2.length === 0) {
12264
+ if (expr.length === 0) {
12183
12265
  return query.orderby;
12184
12266
  } else {
12185
12267
  query.orderby = query.orderby.concat(
12186
- expr2.flat().filter((x) => x).map(asColumn)
12268
+ expr.flat().filter((x) => x).map(asColumn)
12187
12269
  );
12188
12270
  return this;
12189
12271
  }
@@ -12294,8 +12376,17 @@ var Catalog = class {
12294
12376
  return;
12295
12377
  if (!stats?.length)
12296
12378
  return colInfo;
12297
- const result = await this.mc.query(summarize(colInfo, stats));
12379
+ const result = await this.mc.query(
12380
+ summarize(colInfo, stats),
12381
+ { persist: true }
12382
+ );
12298
12383
  const info = { ...colInfo, ...Array.from(result)[0] };
12384
+ for (const key in info) {
12385
+ const value = info[key];
12386
+ if (typeof value === "bigint") {
12387
+ info[key] = Number(value);
12388
+ }
12389
+ }
12299
12390
  return info;
12300
12391
  }
12301
12392
  async queryFields(fields) {
@@ -12332,11 +12423,6 @@ function fnv_mix(a) {
12332
12423
  return a & 4294967295;
12333
12424
  }
12334
12425
 
12335
- // ../core/src/util/skip-client.js
12336
- function skipClient(client, clause) {
12337
- return clause?.clients?.has(client);
12338
- }
12339
-
12340
12426
  // ../core/src/DataTileIndexer.js
12341
12427
  var identity = (x) => x;
12342
12428
  var DataTileIndexer = class {
@@ -12351,32 +12437,38 @@ var DataTileIndexer = class {
12351
12437
  this.indices = null;
12352
12438
  this.activeView = null;
12353
12439
  }
12440
+ clear() {
12441
+ if (this.indices) {
12442
+ this.mc.cancel(Array.from(this.indices.values(), (index) => index.result));
12443
+ this.indices = null;
12444
+ }
12445
+ }
12354
12446
  index(clients, active) {
12355
12447
  if (this.clients !== clients) {
12356
- const cols = Array.from(clients).map(getIndexColumns);
12448
+ const cols = Array.from(clients, getIndexColumns);
12357
12449
  const from = cols[0]?.from;
12358
12450
  this.enabled = cols.every((c) => c && c.from === from);
12359
12451
  this.clients = clients;
12360
- this.indices = null;
12361
12452
  this.activeView = null;
12453
+ this.clear();
12362
12454
  }
12363
12455
  if (!this.enabled)
12364
12456
  return false;
12365
12457
  active = active || this.selection.active;
12366
12458
  const { source } = active;
12459
+ if (source && source === this.activeView?.source)
12460
+ return true;
12461
+ this.clear();
12367
12462
  if (!source)
12368
12463
  return false;
12369
- if (source === this.activeView?.source)
12370
- return true;
12371
12464
  const activeView = this.activeView = getActiveView(active);
12372
12465
  if (!activeView)
12373
12466
  return false;
12374
12467
  this.mc.logger().warn("DATA TILE INDEX CONSTRUCTION");
12375
- const sel = this.selection.clone().update({ source });
12468
+ const sel = this.selection.remove(source);
12376
12469
  const indices = this.indices = /* @__PURE__ */ new Map();
12377
- const promises = [];
12378
12470
  for (const client of clients) {
12379
- if (sel.cross && skipClient(client, active))
12471
+ if (sel.skip(client, active))
12380
12472
  continue;
12381
12473
  const index = getIndexColumns(client);
12382
12474
  const query = client.query(sel.predicate(client)).select({ ...activeView.columns, ...index.count }).groupby(Object.keys(activeView.columns));
@@ -12388,10 +12480,9 @@ var DataTileIndexer = class {
12388
12480
  const sql2 = query.toString();
12389
12481
  const id = (fnv_hash(sql2) >>> 0).toString(16);
12390
12482
  const table = `tile_index_${id}`;
12391
- indices.set(client, { table, ...index });
12392
- promises.push(createIndex(this.mc, table, sql2));
12483
+ const result = createIndex(this.mc, table, sql2);
12484
+ indices.set(client, { table, result, ...index });
12393
12485
  }
12394
- return promises;
12395
12486
  }
12396
12487
  async update() {
12397
12488
  const { clients, selection, activeView } = this;
@@ -12408,10 +12499,8 @@ var DataTileIndexer = class {
12408
12499
  filter = this.activeView.predicate(this.selection.active.predicate);
12409
12500
  }
12410
12501
  const { table, dims, aggr } = index;
12411
- return this.mc.updateClient(
12412
- client,
12413
- Query.select(dims, aggr).from(table).groupby(dims).where(filter)
12414
- );
12502
+ const query = Query.select(dims, aggr).from(table).groupby(dims).where(filter);
12503
+ return this.mc.updateClient(client, query);
12415
12504
  }
12416
12505
  };
12417
12506
  function getActiveView(clause) {
@@ -12419,19 +12508,19 @@ function getActiveView(clause) {
12419
12508
  let columns = clause.predicate?.columns;
12420
12509
  if (!schema || !columns)
12421
12510
  return null;
12422
- const { type, scales } = schema;
12511
+ const { type, scales, pixelSize = 1 } = schema;
12423
12512
  let predicate;
12424
12513
  if (type === "interval" && scales) {
12425
- const bins = scales.map((s) => binInterval(s));
12514
+ const bins = scales.map((s) => binInterval(s, pixelSize));
12426
12515
  if (bins.some((b) => b == null))
12427
12516
  return null;
12428
12517
  if (bins.length === 1) {
12429
- predicate = (p) => p ? isBetween("active0", p.value.map(bins[0])) : [];
12430
- columns = { active0: bins[0](clause.predicate.expr) };
12518
+ predicate = (p) => p ? isBetween("active0", p.range.map(bins[0])) : [];
12519
+ columns = { active0: bins[0](clause.predicate.field) };
12431
12520
  } else {
12432
- predicate = (p) => p ? and(p.value.map(({ value }, i) => isBetween(`active${i}`, value.map(bins[i])))) : [];
12521
+ predicate = (p) => p ? and(p.children.map(({ range }, i) => isBetween(`active${i}`, range.map(bins[i])))) : [];
12433
12522
  columns = Object.fromEntries(
12434
- clause.predicate.value.map((p, i) => [`active${i}`, bins[i](p.expr)])
12523
+ clause.predicate.children.map((p, i) => [`active${i}`, bins[i](p.field)])
12435
12524
  );
12436
12525
  }
12437
12526
  } else if (type === "point") {
@@ -12442,49 +12531,43 @@ function getActiveView(clause) {
12442
12531
  }
12443
12532
  return { source, columns, predicate };
12444
12533
  }
12445
- function binInterval(scale) {
12446
- const { type, domain, range: range2 } = scale;
12447
- let lift, sql2;
12534
+ function binInterval(scale, pixelSize) {
12535
+ const { type, domain, range } = scale;
12536
+ let lift, toSql;
12448
12537
  switch (type) {
12449
12538
  case "linear":
12450
12539
  lift = identity;
12451
- sql2 = asColumn;
12540
+ toSql = asColumn;
12452
12541
  break;
12453
12542
  case "log":
12454
12543
  lift = Math.log;
12455
- sql2 = (c) => `LN(${asColumn(c)})`;
12544
+ toSql = (c) => sql`LN(${asColumn(c)})`;
12456
12545
  break;
12457
12546
  case "symlog":
12458
12547
  lift = (x) => Math.sign(x) * Math.log1p(Math.abs(x));
12459
- sql2 = (c) => (c = asColumn(c), `SIGN(${c}) * LN(1 + ABS(${c}))`);
12548
+ toSql = (c) => (c = asColumn(c), sql`SIGN(${c}) * LN(1 + ABS(${c}))`);
12460
12549
  break;
12461
12550
  case "sqrt":
12462
12551
  lift = Math.sqrt;
12463
- sql2 = (c) => `SQRT(${asColumn(c)})`;
12552
+ toSql = (c) => sql`SQRT(${asColumn(c)})`;
12464
12553
  break;
12465
12554
  case "utc":
12466
12555
  case "time":
12467
12556
  lift = (x) => +x;
12468
- sql2 = (c) => c instanceof Date ? +c : epoch_ms(asColumn(c));
12557
+ toSql = (c) => c instanceof Date ? +c : epoch_ms(asColumn(c));
12469
12558
  break;
12470
12559
  }
12471
- return lift ? binFunction(domain, range2, lift, sql2) : null;
12560
+ return lift ? binFunction(domain, range, pixelSize, lift, toSql) : null;
12472
12561
  }
12473
- function binFunction(domain, range2, lift, sql2) {
12562
+ function binFunction(domain, range, pixelSize, lift, toSql) {
12474
12563
  const lo = lift(Math.min(domain[0], domain[1]));
12475
12564
  const hi = lift(Math.max(domain[0], domain[1]));
12476
- const a = Math.abs(lift(range2[1]) - lift(range2[0])) / (hi - lo);
12477
- return (value) => expr(
12478
- `FLOOR(${a}::DOUBLE * (${sql2(value)} - ${lo}::DOUBLE))`,
12479
- asColumn(value).columns
12480
- );
12565
+ const a = Math.abs(lift(range[1]) - lift(range[0])) / (hi - lo) / pixelSize;
12566
+ const s = pixelSize === 1 ? "" : `${pixelSize}::INTEGER * `;
12567
+ return (value) => sql`${s}FLOOR(${a}::DOUBLE * (${toSql(value)} - ${lo}::DOUBLE))::INTEGER`;
12481
12568
  }
12482
- async function createIndex(mc, table, query) {
12483
- try {
12484
- await mc.exec(`CREATE TEMP TABLE IF NOT EXISTS ${table} AS ${query}`);
12485
- } catch (err) {
12486
- mc.logger().error(err);
12487
- }
12569
+ function createIndex(mc, table, query) {
12570
+ return mc.exec(`CREATE TEMP TABLE IF NOT EXISTS ${table} AS ${query}`);
12488
12571
  }
12489
12572
  var NO_INDEX = { from: NaN };
12490
12573
  function getIndexColumns(client) {
@@ -12495,24 +12578,24 @@ function getIndexColumns(client) {
12495
12578
  if (!from || !q.groupby)
12496
12579
  return NO_INDEX;
12497
12580
  const g = new Set(q.groupby().map((c) => c.column));
12498
- let aggr = [];
12499
- let dims = [];
12581
+ const aggr = [];
12582
+ const dims = [];
12500
12583
  let count2;
12501
12584
  for (const { as, expr: { aggregate } } of q.select()) {
12502
12585
  switch (aggregate?.toUpperCase()) {
12503
12586
  case "COUNT":
12504
12587
  case "SUM":
12505
- aggr.push({ [as]: expr(`SUM("${as}")::DOUBLE`) });
12588
+ aggr.push({ [as]: sql`SUM("${as}")::DOUBLE` });
12506
12589
  break;
12507
12590
  case "AVG":
12508
12591
  count2 = "_count_";
12509
- aggr.push({ [as]: expr(`(SUM("${as}" * ${count2}) / SUM(${count2}))::DOUBLE`) });
12592
+ aggr.push({ [as]: sql`(SUM("${as}" * ${count2}) / SUM(${count2}))::DOUBLE` });
12510
12593
  break;
12511
12594
  case "MAX":
12512
- aggr.push({ [as]: expr(`MAX("${as}")`) });
12595
+ aggr.push({ [as]: sql`MAX("${as}")` });
12513
12596
  break;
12514
12597
  case "MIN":
12515
- aggr.push({ [as]: expr(`MIN("${as}")`) });
12598
+ aggr.push({ [as]: sql`MIN("${as}")` });
12516
12599
  break;
12517
12600
  default:
12518
12601
  if (g.has(as))
@@ -12524,7 +12607,7 @@ function getIndexColumns(client) {
12524
12607
  return {
12525
12608
  aggr,
12526
12609
  dims,
12527
- count: count2 ? { [count2]: expr("COUNT(*)") } : {},
12610
+ count: count2 ? { [count2]: sql`COUNT(*)` } : {},
12528
12611
  from
12529
12612
  };
12530
12613
  }
@@ -12537,7 +12620,7 @@ function getBaseTable(query) {
12537
12620
  if (subq.length === 0)
12538
12621
  return from[0].from.table;
12539
12622
  }
12540
- let base = getBaseTable(subq[0]);
12623
+ const base = getBaseTable(subq[0]);
12541
12624
  for (let i = 1; i < subq.length; ++i) {
12542
12625
  const from = getBaseTable(subq[i]);
12543
12626
  if (from === void 0)
@@ -12561,42 +12644,6 @@ function subqueryPushdown(query, cols) {
12561
12644
  pushdown(query);
12562
12645
  }
12563
12646
 
12564
- // ../core/src/util/throttle.js
12565
- var NIL = {};
12566
- function throttle(callback, debounce = false) {
12567
- let curr;
12568
- let next;
12569
- let pending = NIL;
12570
- function invoke(event) {
12571
- curr = callback(event).then(() => {
12572
- if (next) {
12573
- const { value } = next;
12574
- next = null;
12575
- invoke(value);
12576
- } else {
12577
- curr = null;
12578
- }
12579
- });
12580
- }
12581
- function enqueue(event) {
12582
- next = { event };
12583
- }
12584
- function process(event) {
12585
- curr ? enqueue(event) : invoke(event);
12586
- }
12587
- function delay(event) {
12588
- if (pending !== event) {
12589
- requestAnimationFrame(() => {
12590
- const e = pending;
12591
- pending = NIL;
12592
- process(e);
12593
- });
12594
- }
12595
- pending = event;
12596
- }
12597
- return debounce ? delay : process;
12598
- }
12599
-
12600
12647
  // ../core/src/FilterGroup.js
12601
12648
  var FilterGroup = class {
12602
12649
  constructor(coordinator2, selection, index = true) {
@@ -12605,10 +12652,8 @@ var FilterGroup = class {
12605
12652
  this.clients = /* @__PURE__ */ new Set();
12606
12653
  this.indexer = index ? new DataTileIndexer(this.mc, selection) : null;
12607
12654
  const { value, activate } = this.handlers = {
12608
- value: throttle(() => this.update()),
12609
- activate: (clause) => {
12610
- this.indexer?.index(this.clients, clause);
12611
- }
12655
+ value: () => this.update(),
12656
+ activate: (clause) => this.indexer?.index(this.clients, clause)
12612
12657
  };
12613
12658
  selection.addEventListener("value", value);
12614
12659
  selection.addEventListener("activate", activate);
@@ -12631,7 +12676,7 @@ var FilterGroup = class {
12631
12676
  }
12632
12677
  return this;
12633
12678
  }
12634
- async update() {
12679
+ update() {
12635
12680
  const { mc, indexer, clients, selection } = this;
12636
12681
  return indexer?.index(clients) ? indexer.update() : defaultUpdate(mc, clients, selection);
12637
12682
  }
@@ -12645,61 +12690,233 @@ function defaultUpdate(mc, clients, selection) {
12645
12690
  }));
12646
12691
  }
12647
12692
 
12648
- // ../core/src/QueryCache.js
12693
+ // ../core/src/util/cache.js
12649
12694
  var requestIdle = typeof requestIdleCallback !== "undefined" ? requestIdleCallback : setTimeout;
12650
12695
  var voidCache = () => ({
12651
12696
  get: () => void 0,
12652
- set: (key, result) => result,
12697
+ set: (key, value) => value,
12653
12698
  clear: () => {
12654
12699
  }
12655
12700
  });
12656
- var QueryCache = class {
12657
- constructor({
12658
- max: max2 = 1e3,
12659
- // max entries
12660
- ttl = 3 * 60 * 60 * 1e3
12661
- // time-to-live, default 3 hours
12662
- } = {}) {
12663
- this.max = max2;
12664
- this.ttl = ttl;
12665
- this.clear();
12666
- }
12667
- clear() {
12668
- this.cache = /* @__PURE__ */ new Map();
12669
- }
12670
- get(key) {
12671
- const entry = this.cache.get(key);
12672
- if (entry) {
12673
- entry.last = performance.now();
12674
- return entry.promise;
12675
- }
12676
- }
12677
- set(key, promise) {
12678
- const { cache, max: max2 } = this;
12679
- cache.set(key, { last: performance.now(), promise });
12680
- if (cache.size > max2)
12681
- requestIdle(() => this.evict());
12682
- return promise;
12683
- }
12684
- evict() {
12685
- const expire = performance.now() - this.ttl;
12701
+ function lruCache({
12702
+ max: max2 = 1e3,
12703
+ // max entries
12704
+ ttl = 3 * 60 * 60 * 1e3
12705
+ // time-to-live, default 3 hours
12706
+ } = {}) {
12707
+ let cache = /* @__PURE__ */ new Map();
12708
+ function evict() {
12709
+ const expire = performance.now() - ttl;
12686
12710
  let lruKey = null;
12687
12711
  let lruLast = Infinity;
12688
- for (const [key, value] of this.cache) {
12712
+ for (const [key, value] of cache) {
12689
12713
  const { last: last2 } = value;
12690
12714
  if (last2 < lruLast) {
12691
12715
  lruKey = key;
12692
12716
  lruLast = last2;
12693
12717
  }
12694
12718
  if (expire > last2) {
12695
- this.cache.delete(key);
12719
+ cache.delete(key);
12696
12720
  }
12697
12721
  }
12698
12722
  if (lruKey) {
12699
- this.cache.delete(lruKey);
12723
+ cache.delete(lruKey);
12700
12724
  }
12701
12725
  }
12702
- };
12726
+ return {
12727
+ get(key) {
12728
+ const entry = cache.get(key);
12729
+ if (entry) {
12730
+ entry.last = performance.now();
12731
+ return entry.value;
12732
+ }
12733
+ },
12734
+ set(key, value) {
12735
+ cache.set(key, { last: performance.now(), value });
12736
+ if (cache.size > max2)
12737
+ requestIdle(evict);
12738
+ return value;
12739
+ },
12740
+ clear() {
12741
+ cache = /* @__PURE__ */ new Map();
12742
+ }
12743
+ };
12744
+ }
12745
+
12746
+ // ../core/src/util/priority-queue.js
12747
+ function priorityQueue(ranks) {
12748
+ const queue = Array.from(
12749
+ { length: ranks },
12750
+ () => ({ head: null, tail: null })
12751
+ );
12752
+ return {
12753
+ /**
12754
+ * Indicate if the queue is empty.
12755
+ * @returns [boolean] true if empty, false otherwise.
12756
+ */
12757
+ isEmpty() {
12758
+ return queue.every((list) => !list.head);
12759
+ },
12760
+ /**
12761
+ * Insert an item into the queue with a given priority rank.
12762
+ * @param {*} item The item to add.
12763
+ * @param {number} rank The integer priority rank.
12764
+ * Priority ranks are integers starting at zero.
12765
+ * Lower ranks indicate higher priority.
12766
+ */
12767
+ insert(item, rank2) {
12768
+ const list = queue[rank2];
12769
+ if (!list) {
12770
+ throw new Error(`Invalid queue priority rank: ${rank2}`);
12771
+ }
12772
+ const node = { item, next: null };
12773
+ if (list.head === null) {
12774
+ list.head = list.tail = node;
12775
+ } else {
12776
+ list.tail = list.tail.next = node;
12777
+ }
12778
+ },
12779
+ /**
12780
+ * Remove a set of items from the queue, regardless of priority rank.
12781
+ * If a provided item is not in the queue it will be ignored.
12782
+ * @param {(item: *) => boolean} test A predicate function to test
12783
+ * if an item should be removed (true to drop, false to keep).
12784
+ */
12785
+ remove(test) {
12786
+ for (const list of queue) {
12787
+ let { head, tail } = list;
12788
+ for (let prev = null, curr = head; curr; prev = curr, curr = curr.next) {
12789
+ if (test(curr.item)) {
12790
+ if (curr === head) {
12791
+ head = curr.next;
12792
+ } else {
12793
+ prev.next = curr.next;
12794
+ }
12795
+ if (curr === tail)
12796
+ tail = prev || head;
12797
+ }
12798
+ }
12799
+ list.head = head;
12800
+ list.tail = tail;
12801
+ }
12802
+ },
12803
+ /**
12804
+ * Remove and return the next highest priority item.
12805
+ * @returns {*} The next item in the queue,
12806
+ * or undefined if this queue is empty.
12807
+ */
12808
+ next() {
12809
+ for (const list of queue) {
12810
+ const { head } = list;
12811
+ if (head !== null) {
12812
+ list.head = head.next;
12813
+ if (list.tail === head) {
12814
+ list.tail = null;
12815
+ }
12816
+ return head.item;
12817
+ }
12818
+ }
12819
+ }
12820
+ };
12821
+ }
12822
+
12823
+ // ../core/src/QueryManager.js
12824
+ var Priority = { High: 0, Normal: 1, Low: 2 };
12825
+ function QueryManager() {
12826
+ const queue = priorityQueue(3);
12827
+ let db;
12828
+ let clientCache;
12829
+ let logger;
12830
+ let recorders = [];
12831
+ let pending = null;
12832
+ function next() {
12833
+ if (pending || queue.isEmpty())
12834
+ return;
12835
+ const { request, result } = queue.next();
12836
+ pending = submit(request, result);
12837
+ pending.finally(() => {
12838
+ pending = null;
12839
+ next();
12840
+ });
12841
+ }
12842
+ async function submit(request, result) {
12843
+ try {
12844
+ const { query, type, cache = false, options } = request;
12845
+ const sql2 = query ? String(query) : null;
12846
+ if (recorders.length && sql2) {
12847
+ recorders.forEach((rec) => rec.add(sql2));
12848
+ }
12849
+ if (cache) {
12850
+ const cached = clientCache.get(sql2);
12851
+ if (cached) {
12852
+ logger.debug("Cache");
12853
+ result.fulfill(cached);
12854
+ return;
12855
+ }
12856
+ }
12857
+ const t0 = performance.now();
12858
+ const data = await db.query({ type, sql: sql2, ...options });
12859
+ if (cache)
12860
+ clientCache.set(sql2, data);
12861
+ logger.debug(`Request: ${(performance.now() - t0).toFixed(1)}`);
12862
+ result.fulfill(data);
12863
+ } catch (err) {
12864
+ result.reject(err);
12865
+ }
12866
+ }
12867
+ return {
12868
+ cache(value) {
12869
+ return value !== void 0 ? clientCache = value === true ? lruCache() : value || voidCache() : clientCache;
12870
+ },
12871
+ logger(value) {
12872
+ return value ? logger = value : logger;
12873
+ },
12874
+ connector(connector) {
12875
+ return connector ? db = connector : db;
12876
+ },
12877
+ request(request, priority = Priority.Normal) {
12878
+ const result = queryResult();
12879
+ queue.insert({ request, result }, priority);
12880
+ next();
12881
+ return result;
12882
+ },
12883
+ cancel(requests) {
12884
+ const set = new Set(requests);
12885
+ queue.remove(({ result }) => set.has(result));
12886
+ },
12887
+ record() {
12888
+ let state = [];
12889
+ const recorder = {
12890
+ add(query) {
12891
+ state.push(query);
12892
+ },
12893
+ reset() {
12894
+ state = [];
12895
+ },
12896
+ snapshot() {
12897
+ return state.slice();
12898
+ },
12899
+ stop() {
12900
+ recorders = recorders.filter((x) => x !== recorder);
12901
+ return state;
12902
+ }
12903
+ };
12904
+ recorders.push(recorder);
12905
+ return recorder;
12906
+ }
12907
+ };
12908
+ }
12909
+ function queryResult() {
12910
+ let resolve;
12911
+ let reject;
12912
+ const p = new Promise((r, e) => {
12913
+ resolve = r;
12914
+ reject = e;
12915
+ });
12916
+ p.fulfill = (value) => (resolve(value), p);
12917
+ p.reject = (err) => (reject(err), p);
12918
+ return p;
12919
+ }
12703
12920
 
12704
12921
  // ../core/src/util/void-logger.js
12705
12922
  function voidLogger() {
@@ -12728,18 +12945,24 @@ function coordinator(instance9) {
12728
12945
  return _instance;
12729
12946
  }
12730
12947
  var Coordinator = class {
12731
- constructor(db = socketClient(), options = {}) {
12948
+ constructor(db = socketConnector(), options = {}) {
12732
12949
  this.catalog = new Catalog(this);
12950
+ this.manager = options.manager || QueryManager();
12733
12951
  this.logger(options.logger || console);
12734
12952
  this.configure(options);
12735
- this.databaseClient(db);
12953
+ this.databaseConnector(db);
12736
12954
  this.clear();
12955
+ this._recorders = [];
12737
12956
  }
12738
12957
  logger(logger) {
12739
- return arguments.length ? this._logger = logger || voidLogger() : this._logger;
12958
+ if (arguments.length) {
12959
+ this._logger = logger || voidLogger();
12960
+ this.manager.logger(this._logger);
12961
+ }
12962
+ return this._logger;
12740
12963
  }
12741
12964
  configure({ cache = true, indexes = true }) {
12742
- this.cache = cache ? new QueryCache() : voidCache();
12965
+ this.manager.cache(cache);
12743
12966
  this.indexes = indexes;
12744
12967
  }
12745
12968
  clear({ clients = true, cache = true, catalog = false } = {}) {
@@ -12750,54 +12973,51 @@ var Coordinator = class {
12750
12973
  this.filterGroups = /* @__PURE__ */ new Map();
12751
12974
  }
12752
12975
  if (cache)
12753
- this.cache.clear();
12976
+ this.manager.cache().clear();
12754
12977
  if (catalog)
12755
12978
  this.catalog.clear();
12756
12979
  }
12757
- databaseClient(db) {
12758
- if (arguments.length > 0) {
12759
- this.db = db;
12760
- }
12761
- return this.db;
12980
+ databaseConnector(db) {
12981
+ return this.manager.connector(db);
12762
12982
  }
12763
- async exec(sql2) {
12764
- try {
12765
- await this.db.query({ type: "exec", sql: sql2 });
12766
- } catch (err) {
12767
- this._logger.error(err);
12768
- }
12983
+ // -- Query Management ----
12984
+ cancel(requests) {
12985
+ this.manager.cancel(requests);
12769
12986
  }
12770
- query(query, { type = "arrow", cache = true } = {}) {
12771
- const sql2 = String(query);
12772
- const t0 = performance.now();
12773
- const cached = this.cache.get(sql2);
12774
- if (cached) {
12775
- this._logger.debug("Cache");
12776
- return cached;
12777
- } else {
12778
- const request = this.db.query({ type, sql: sql2 });
12779
- const result = cache ? this.cache.set(sql2, request) : request;
12780
- result.then(() => this._logger.debug(`Query: ${performance.now() - t0}`));
12781
- return result;
12782
- }
12987
+ exec(query, { priority = Priority.Normal } = {}) {
12988
+ return this.manager.request({ type: "exec", query }, priority);
12783
12989
  }
12784
- async updateClient(client, query) {
12785
- let result;
12786
- try {
12787
- client.queryPending();
12788
- result = await this.query(query);
12789
- } catch (err) {
12790
- this._logger.error(err);
12791
- client.queryError(err);
12792
- return;
12793
- }
12794
- try {
12795
- client.queryResult(result).update();
12796
- } catch (err) {
12797
- this._logger.error(err);
12798
- }
12990
+ query(query, {
12991
+ type = "arrow",
12992
+ cache = true,
12993
+ priority = Priority.Normal,
12994
+ ...options
12995
+ } = {}) {
12996
+ return this.manager.request({ type, query, cache, options }, priority);
12997
+ }
12998
+ prefetch(query, options = {}) {
12999
+ return this.query(query, { ...options, cache: true, priority: Priority.Low });
12799
13000
  }
12800
- async requestQuery(client, query) {
13001
+ createBundle(name, queries, priority = Priority.Low) {
13002
+ const options = { name, queries };
13003
+ return this.manager.request({ type: "create-bundle", options }, priority);
13004
+ }
13005
+ loadBundle(name, priority = Priority.High) {
13006
+ const options = { name };
13007
+ return this.manager.request({ type: "load-bundle", options }, priority);
13008
+ }
13009
+ // -- Client Management ----
13010
+ updateClient(client, query, priority = Priority.Normal) {
13011
+ client.queryPending();
13012
+ return this.query(query, { priority }).then(
13013
+ (data) => client.queryResult(data).update(),
13014
+ (err) => {
13015
+ client.queryError(err);
13016
+ this._logger.error(err);
13017
+ }
13018
+ );
13019
+ }
13020
+ requestQuery(client, query) {
12801
13021
  this.filterGroups.get(client.filterBy)?.reset();
12802
13022
  return query ? this.updateClient(client, query) : client.update();
12803
13023
  }
@@ -12809,7 +13029,7 @@ var Coordinator = class {
12809
13029
  clients.add(client);
12810
13030
  const fields = client.fields();
12811
13031
  if (fields?.length) {
12812
- client.fieldStats(await catalog.queryFields(fields));
13032
+ client.fieldInfo(await catalog.queryFields(fields));
12813
13033
  }
12814
13034
  const filter = client.filterBy;
12815
13035
  if (filter) {
@@ -12831,6 +13051,42 @@ var Coordinator = class {
12831
13051
  }
12832
13052
  };
12833
13053
 
13054
+ // ../core/src/util/throttle.js
13055
+ var NIL = {};
13056
+ function throttle(callback, debounce = false) {
13057
+ let curr;
13058
+ let next;
13059
+ let pending = NIL;
13060
+ function invoke(event) {
13061
+ curr = callback(event).then(() => {
13062
+ if (next) {
13063
+ const { value } = next;
13064
+ next = null;
13065
+ invoke(value);
13066
+ } else {
13067
+ curr = null;
13068
+ }
13069
+ });
13070
+ }
13071
+ function enqueue(event) {
13072
+ next = { event };
13073
+ }
13074
+ function process(event) {
13075
+ curr ? enqueue(event) : invoke(event);
13076
+ }
13077
+ function delay(event) {
13078
+ if (pending !== event) {
13079
+ requestAnimationFrame(() => {
13080
+ const e = pending;
13081
+ pending = NIL;
13082
+ process(e);
13083
+ });
13084
+ }
13085
+ pending = event;
13086
+ }
13087
+ return debounce ? delay : process;
13088
+ }
13089
+
12834
13090
  // ../core/src/MosaicClient.js
12835
13091
  var MosaicClient = class {
12836
13092
  /**
@@ -12922,6 +13178,163 @@ var MosaicClient = class {
12922
13178
  }
12923
13179
  };
12924
13180
 
13181
+ // ../core/src/util/AsyncDispatch.js
13182
+ var AsyncDispatch = class {
13183
+ /**
13184
+ * Create a new asynchronous dispatcher instance.
13185
+ */
13186
+ constructor() {
13187
+ this._callbacks = /* @__PURE__ */ new Map();
13188
+ }
13189
+ /**
13190
+ * Add an event listener callback for the provided event type.
13191
+ * @param {string} type The event type.
13192
+ * @param {(value: *) => Promise?} callback The event handler
13193
+ * callback function to add. If the callback has already been
13194
+ * added for the event type, this method has no effect.
13195
+ */
13196
+ addEventListener(type, callback) {
13197
+ if (!this._callbacks.has(type)) {
13198
+ this._callbacks.set(type, {
13199
+ callbacks: /* @__PURE__ */ new Set(),
13200
+ pending: null,
13201
+ queue: new DispatchQueue()
13202
+ });
13203
+ }
13204
+ const entry = this._callbacks.get(type);
13205
+ entry.callbacks.add(callback);
13206
+ }
13207
+ /**
13208
+ * Remove an event listener callback for the provided event type.
13209
+ * @param {string} type The event type.
13210
+ * @param {(value: *) => Promise?} callback The event handler
13211
+ * callback function to remove.
13212
+ */
13213
+ removeEventListener(type, callback) {
13214
+ const entry = this._callbacks.get(type);
13215
+ if (entry) {
13216
+ entry.callbacks.delete(callback);
13217
+ }
13218
+ }
13219
+ /**
13220
+ * Lifecycle method that returns the event value to emit.
13221
+ * This default implementation simply returns the input value as-is.
13222
+ * Subclasses may override this method to implement custom transformations
13223
+ * prior to emitting an event value to all listeners.
13224
+ * @param {string} type The event type.
13225
+ * @param {*} value The event value.
13226
+ * @returns The (possibly transformed) event value to emit.
13227
+ */
13228
+ willEmit(type, value) {
13229
+ return value;
13230
+ }
13231
+ /**
13232
+ * Lifecycle method that returns a filter function for updating the
13233
+ * queue of unemitted event values prior to enqueueing a new value.
13234
+ * This default implementation simply returns null, indicating that
13235
+ * any other unemitted event values should be dropped (that is, all
13236
+ * queued events are filtered)
13237
+ * @param {*} value The new event value that will be enqueued.
13238
+ * @returns {(value: *) => boolean|null} A dispatch queue filter
13239
+ * function, or null if all unemitted event values should be filtered.
13240
+ */
13241
+ emitQueueFilter() {
13242
+ return null;
13243
+ }
13244
+ /**
13245
+ * Cancel all unemitted event values for the given event type.
13246
+ * @param {string} type The event type.
13247
+ */
13248
+ cancel(type) {
13249
+ const entry = this._callbacks.get(type);
13250
+ entry?.queue.clear();
13251
+ }
13252
+ /**
13253
+ * Emit an event value to listeners for the given event type.
13254
+ * If a previous emit has not yet resolved, the event value
13255
+ * will be queued to be emitted later.
13256
+ * The actual event value given to listeners will be the result
13257
+ * of passing the input value through the emitValue() method.
13258
+ * @param {string} type The event type.
13259
+ * @param {*} value The event value.
13260
+ */
13261
+ emit(type, value) {
13262
+ const entry = this._callbacks.get(type) || {};
13263
+ if (entry.pending) {
13264
+ entry.queue.enqueue(value, this.emitQueueFilter(type, value));
13265
+ } else {
13266
+ const event = this.willEmit(type, value);
13267
+ const { callbacks, queue } = entry;
13268
+ if (callbacks?.size) {
13269
+ const promise = Promise.allSettled(Array.from(callbacks, (callback) => callback(event))).then(() => {
13270
+ entry.pending = null;
13271
+ if (!queue.isEmpty()) {
13272
+ this.emit(type, queue.dequeue());
13273
+ }
13274
+ });
13275
+ entry.pending = promise;
13276
+ }
13277
+ }
13278
+ }
13279
+ };
13280
+ var DispatchQueue = class {
13281
+ /**
13282
+ * Create a new dispatch queue instance.
13283
+ */
13284
+ constructor() {
13285
+ this.clear();
13286
+ }
13287
+ /**
13288
+ * Clear the queue state of all event values.
13289
+ */
13290
+ clear() {
13291
+ this.next = null;
13292
+ }
13293
+ /**
13294
+ * Indicate if the queue is empty.
13295
+ * @returns {boolean} True if queue is empty, false otherwise.
13296
+ */
13297
+ isEmpty() {
13298
+ return !this.next;
13299
+ }
13300
+ /**
13301
+ * Add a new value to the queue, and optionally filter the
13302
+ * current queue content in response.
13303
+ * @param {*} value The value to add.
13304
+ * @param {(value: *) => boolean} [filter] An optional filter
13305
+ * function to apply to existing queue content. If unspecified
13306
+ * or falsy, all previously queued values are removed. Otherwise,
13307
+ * the provided function is applied to all queue entries. The
13308
+ * entry is retained if the filter function returns a truthy value,
13309
+ * otherwise the entry is removed.
13310
+ */
13311
+ enqueue(value, filter) {
13312
+ const tail = { value };
13313
+ if (filter && this.next) {
13314
+ let curr = this;
13315
+ while (curr.next) {
13316
+ if (filter(curr.next.value)) {
13317
+ curr = curr.next;
13318
+ } else {
13319
+ curr.next = curr.next.next;
13320
+ }
13321
+ }
13322
+ curr.next = tail;
13323
+ } else {
13324
+ this.next = tail;
13325
+ }
13326
+ }
13327
+ /**
13328
+ * Remove and return the next queued event value.
13329
+ * @returns {*} The next event value in the queue.
13330
+ */
13331
+ dequeue() {
13332
+ const { next } = this;
13333
+ this.next = next?.next;
13334
+ return next?.value;
13335
+ }
13336
+ };
13337
+
12925
13338
  // ../core/src/util/distinct.js
12926
13339
  function distinct(a, b) {
12927
13340
  return a === b ? false : a instanceof Date && b instanceof Date ? +a !== +b : Array.isArray(a) && Array.isArray(b) ? distinctArray(a, b) : true;
@@ -12940,40 +13353,74 @@ function distinctArray(a, b) {
12940
13353
  function isParam(x) {
12941
13354
  return x instanceof Param;
12942
13355
  }
12943
- var Param = class {
13356
+ var Param = class extends AsyncDispatch {
13357
+ /**
13358
+ * Create a new Param instance.
13359
+ * @param {*} value The initial value of the Param.
13360
+ */
12944
13361
  constructor(value) {
13362
+ super();
12945
13363
  this._value = value;
12946
- this._listeners = /* @__PURE__ */ new Map();
12947
13364
  }
13365
+ /**
13366
+ * Create a new Param instance with the given initial value.
13367
+ * @param {*} value The initial value of the Param.
13368
+ * @returns {Param} The new Param instance.
13369
+ */
12948
13370
  static value(value) {
12949
13371
  return new Param(value);
12950
13372
  }
13373
+ /**
13374
+ * Create a new Param instance over an array of initial values,
13375
+ * which may contain nested Params.
13376
+ * @param {*} values The initial values of the Param.
13377
+ * @returns {Param} The new Param instance.
13378
+ */
13379
+ static array(values) {
13380
+ if (values.some((v) => isParam(v))) {
13381
+ const p = new Param();
13382
+ const update2 = () => p.update(values.map((v) => isParam(v) ? v.value : v));
13383
+ update2();
13384
+ values.forEach((v) => isParam(v) ? v.addEventListener("value", update2) : 0);
13385
+ return p;
13386
+ }
13387
+ return new Param(values);
13388
+ }
13389
+ /**
13390
+ * The current value of the Param.
13391
+ */
12951
13392
  get value() {
12952
13393
  return this._value;
12953
13394
  }
13395
+ /**
13396
+ * Update the Param value
13397
+ * @param {*} value The new value of the Param.
13398
+ * @param {object} [options] The update options.
13399
+ * @param {boolean} [options.force] A boolean flag indicating if the Param
13400
+ * should emit a 'value' event even if the internal value is unchanged.
13401
+ * @returns {this} This Param instance.
13402
+ */
12954
13403
  update(value, { force } = {}) {
12955
- const changed = distinct(this._value, value);
12956
- if (changed)
12957
- this._value = value;
12958
- if (changed || force)
12959
- this.emit("value", this.value);
12960
- return this;
12961
- }
12962
- addEventListener(type, callback) {
12963
- let list = this._listeners.get(type) || [];
12964
- if (!list.includes(callback)) {
12965
- list = list.concat(callback);
13404
+ const shouldEmit = distinct(this._value, value) || force;
13405
+ if (shouldEmit) {
13406
+ this.emit("value", value);
13407
+ } else {
13408
+ this.cancel("value");
12966
13409
  }
12967
- this._listeners.set(type, list);
13410
+ return this;
12968
13411
  }
12969
- removeEventListener(type, callback) {
12970
- const list = this._listeners.get(type);
12971
- if (list?.length) {
12972
- this._listeners.set(type, list.filter((x) => x !== callback));
13412
+ /**
13413
+ * Upon value-typed updates, sets the current value to the input value
13414
+ * immediately prior to the event value being emitted to listeners.
13415
+ * @param {string} type The event type.
13416
+ * @param {*} value The input event value.
13417
+ * @returns {*} The input event value.
13418
+ */
13419
+ willEmit(type, value) {
13420
+ if (type === "value") {
13421
+ this._value = value;
12973
13422
  }
12974
- }
12975
- emit(type, event) {
12976
- this._listeners.get(type)?.forEach((l) => l(event));
13423
+ return value;
12977
13424
  }
12978
13425
  };
12979
13426
 
@@ -12982,57 +13429,230 @@ function isSelection(x) {
12982
13429
  return x instanceof Selection;
12983
13430
  }
12984
13431
  var Selection = class extends Param {
12985
- static intersect() {
12986
- return new Selection();
13432
+ /**
13433
+ * Create a new Selection instance with an
13434
+ * intersect (conjunction) resolution strategy.
13435
+ * @param {object} [options] The selection options.
13436
+ * @param {boolean} [options.cross=false] Boolean flag indicating
13437
+ * cross-filtered resolution. If true, selection clauses will not
13438
+ * be applied to the clients they are associated with.
13439
+ * @returns {Selection} The new Selection instance.
13440
+ */
13441
+ static intersect({ cross = false } = {}) {
13442
+ return new Selection(new SelectionResolver({ cross }));
12987
13443
  }
12988
- static crossfilter() {
12989
- return new Selection({ cross: true });
13444
+ /**
13445
+ * Create a new Selection instance with a
13446
+ * union (disjunction) resolution strategy.
13447
+ * @param {object} [options] The selection options.
13448
+ * @param {boolean} [options.cross=false] Boolean flag indicating
13449
+ * cross-filtered resolution. If true, selection clauses will not
13450
+ * be applied to the clients they are associated with.
13451
+ * @returns {Selection} The new Selection instance.
13452
+ */
13453
+ static union({ cross = false } = {}) {
13454
+ return new Selection(new SelectionResolver({ cross, union: true }));
12990
13455
  }
12991
- static union() {
12992
- return new Selection({ union: true });
13456
+ /**
13457
+ * Create a new Selection instance with a singular resolution strategy
13458
+ * that keeps only the most recent selection clause.
13459
+ * @param {object} [options] The selection options.
13460
+ * @param {boolean} [options.cross=false] Boolean flag indicating
13461
+ * cross-filtered resolution. If true, selection clauses will not
13462
+ * be applied to the clients they are associated with.
13463
+ * @returns {Selection} The new Selection instance.
13464
+ */
13465
+ static single({ cross = false } = {}) {
13466
+ return new Selection(new SelectionResolver({ cross, single: true }));
12993
13467
  }
12994
- static single() {
12995
- return new Selection({ single: true });
13468
+ /**
13469
+ * Create a new Selection instance with a
13470
+ * cross-filtered intersect resolution strategy.
13471
+ * @returns {Selection} The new Selection instance.
13472
+ */
13473
+ static crossfilter() {
13474
+ return new Selection(new SelectionResolver({ cross: true }));
12996
13475
  }
12997
- constructor({ union, cross, single } = {}) {
13476
+ /**
13477
+ * Create a new Selection instance.
13478
+ * @param {SelectionResolver} resolver The selection resolution
13479
+ * strategy to apply.
13480
+ */
13481
+ constructor(resolver = new SelectionResolver()) {
12998
13482
  super([]);
12999
- this.active = null;
13000
- this.union = !!union;
13001
- this.cross = !!cross;
13002
- this.single = !!single;
13483
+ this._resolved = this._value;
13484
+ this._resolver = resolver;
13003
13485
  }
13486
+ /**
13487
+ * Create a cloned copy of this Selection instance.
13488
+ * @returns {this} A clone of this selection.
13489
+ */
13004
13490
  clone() {
13005
- const s = new Selection();
13006
- s.active = this.active;
13007
- s.union = this.union;
13008
- s.cross = this.cross;
13009
- s._value = this._value;
13491
+ const s = new Selection(this._resolver);
13492
+ s._value = s._resolved = this._value;
13010
13493
  return s;
13011
13494
  }
13495
+ /**
13496
+ * Create a clone of this Selection with clauses corresponding
13497
+ * to provided source removed.
13498
+ * @param {*} source The clause source to remove.
13499
+ * @returns {this} A cloned and updated Selection.
13500
+ */
13501
+ remove(source) {
13502
+ const s = this.clone();
13503
+ s._value = s._resolved = s._resolver.resolve(this._resolved, { source });
13504
+ s._value.active = { source };
13505
+ return s;
13506
+ }
13507
+ /**
13508
+ * The current active (most recently updated) selection clause.
13509
+ */
13510
+ get active() {
13511
+ return this.clauses.active;
13512
+ }
13513
+ /**
13514
+ * The value corresponding to the current active selection clause.
13515
+ * This method ensures compatibility where a normal Param is expected.
13516
+ */
13012
13517
  get value() {
13013
- const { clauses } = this;
13014
- return clauses[clauses.length - 1]?.value;
13518
+ return this.active?.value;
13015
13519
  }
13520
+ /**
13521
+ * The current array of selection clauses.
13522
+ */
13016
13523
  get clauses() {
13017
13524
  return super.value;
13018
13525
  }
13526
+ /**
13527
+ * Emit an activate event with the given selection clause.
13528
+ * @param {*} clause The clause repesenting the potential activation.
13529
+ */
13019
13530
  activate(clause) {
13020
13531
  this.emit("activate", clause);
13021
13532
  }
13533
+ /**
13534
+ * Update the selection with a new selection clause.
13535
+ * @param {*} clause The selection clause to add.
13536
+ * @returns {this} This Selection instance.
13537
+ */
13022
13538
  update(clause) {
13539
+ this._resolved = this._resolver.resolve(this._resolved, clause, true);
13540
+ this._resolved.active = clause;
13541
+ return super.update(this._resolved);
13542
+ }
13543
+ /**
13544
+ * Upon value-typed updates, sets the current clause list to the
13545
+ * input value and returns the active clause value.
13546
+ * @param {string} type The event type.
13547
+ * @param {*} value The input event value.
13548
+ * @returns {*} For value-typed events, returns the active clause
13549
+ * values. Otherwise returns the input event value as-is.
13550
+ */
13551
+ willEmit(type, value) {
13552
+ if (type === "value") {
13553
+ this._value = value;
13554
+ return this.value;
13555
+ }
13556
+ return value;
13557
+ }
13558
+ /**
13559
+ * Upon value-typed updates, returns a dispatch queue filter function.
13560
+ * The return value depends on the selection resolution strategy.
13561
+ * @param {string} type The event type.
13562
+ * @param {*} value The input event value.
13563
+ * @returns {*} For value-typed events, returns a dispatch queue filter
13564
+ * function. Otherwise returns null.
13565
+ */
13566
+ emitQueueFilter(type, value) {
13567
+ return type === "value" ? this._resolver.queueFilter(value) : null;
13568
+ }
13569
+ /**
13570
+ * Indicates if a selection clause should not be applied to a given client.
13571
+ * The return value depends on the selection resolution strategy.
13572
+ * @param {*} client The selection clause.
13573
+ * @param {*} clause The client to test.
13574
+ * @returns True if the client should be skipped, false otherwise.
13575
+ */
13576
+ skip(client, clause) {
13577
+ return this._resolver.skip(client, clause);
13578
+ }
13579
+ /**
13580
+ * Return a selection query predicate for the given client.
13581
+ * @param {*} client The client whose data may be filtered.
13582
+ * @returns {*} The query predicate for filtering client data,
13583
+ * based on the current state of this selection.
13584
+ */
13585
+ predicate(client) {
13586
+ const { clauses } = this;
13587
+ return this._resolver.predicate(clauses, clauses.active, client);
13588
+ }
13589
+ };
13590
+ var SelectionResolver = class {
13591
+ /**
13592
+ * Create a new selection resolved instance.
13593
+ * @param {object} [options] The resolution strategy options.
13594
+ * @param {boolean} [options.union=false] Boolean flag to indicate a union strategy.
13595
+ * If false, an intersection strategy is used.
13596
+ * @param {boolean} [options.cross=false] Boolean flag to indicate cross-filtering.
13597
+ * @param {boolean} [options.single=false] Boolean flag to indicate single clauses only.
13598
+ */
13599
+ constructor({ union, cross, single } = {}) {
13600
+ this.union = !!union;
13601
+ this.cross = !!cross;
13602
+ this.single = !!single;
13603
+ }
13604
+ /**
13605
+ * Resolve a list of selection clauses according to the resolution strategy.
13606
+ * @param {*[]} clauseList An array of selection clauses.
13607
+ * @param {*} clause A new selection clause to add.
13608
+ * @returns {*[]} An updated array of selection clauses.
13609
+ */
13610
+ resolve(clauseList, clause, reset = false) {
13023
13611
  const { source, predicate } = clause;
13024
- this.active = clause;
13025
- const clauses = this.single ? [] : this.clauses.filter((c) => source !== c.source);
13612
+ const filtered = clauseList.filter((c) => source !== c.source);
13613
+ const clauses = this.single ? [] : filtered;
13614
+ if (this.single && reset)
13615
+ filtered.forEach((c) => c.source?.reset?.());
13026
13616
  if (predicate)
13027
13617
  clauses.push(clause);
13028
- return super.update(clauses);
13618
+ return clauses;
13029
13619
  }
13030
- predicate(client) {
13031
- const { active, clauses, cross, union } = this;
13032
- if (cross && skipClient(client, active))
13620
+ /**
13621
+ * Indicates if a selection clause should not be applied to a given client.
13622
+ * The return value depends on the resolution strategy.
13623
+ * @param {*} client The selection clause.
13624
+ * @param {*} clause The client to test.
13625
+ * @returns True if the client should be skipped, false otherwise.
13626
+ */
13627
+ skip(client, clause) {
13628
+ return this.cross && clause?.clients?.has(client);
13629
+ }
13630
+ /**
13631
+ * Return a selection query predicate for the given client.
13632
+ * @param {*[]} clauseList An array of selection clauses.
13633
+ * @param {*} active The current active selection clause.
13634
+ * @param {*} client The client whose data may be filtered.
13635
+ * @returns {*} The query predicate for filtering client data,
13636
+ * based on the current state of this selection.
13637
+ */
13638
+ predicate(clauseList, active, client) {
13639
+ const { union } = this;
13640
+ if (this.skip(client, active))
13033
13641
  return void 0;
13034
- const list = (cross ? clauses.filter((clause) => !skipClient(client, clause)) : clauses).map((s) => s.predicate);
13035
- return union && list.length > 1 ? or(list) : list;
13642
+ const predicates = clauseList.filter((clause) => !this.skip(client, clause)).map((clause) => clause.predicate);
13643
+ return union && predicates.length > 1 ? or(predicates) : predicates;
13644
+ }
13645
+ /**
13646
+ * Returns a filter function for queued selection updates.
13647
+ * @param {*} value The new event value that will be enqueued.
13648
+ * @returns {(value: *) => boolean|null} A dispatch queue filter
13649
+ * function, or null if all unemitted event values should be filtered.
13650
+ */
13651
+ queueFilter(value) {
13652
+ if (this.cross) {
13653
+ const source = value.active?.source;
13654
+ return (clauses) => clauses.active?.source !== source;
13655
+ }
13036
13656
  }
13037
13657
  };
13038
13658
 
@@ -13069,13 +13689,12 @@ var Menu = class extends MosaicClient {
13069
13689
  this.update();
13070
13690
  }
13071
13691
  value = value ?? this.selection?.value ?? this.data?.[0]?.value;
13072
- this.select.value = value;
13073
13692
  if (this.selection?.value === void 0)
13074
13693
  this.publish(value);
13075
13694
  this.element.appendChild(this.select);
13076
13695
  if (this.selection) {
13077
13696
  this.select.addEventListener("input", () => {
13078
- this.publish(this.selectedValue() || null);
13697
+ this.publish(this.selectedValue() ?? null);
13079
13698
  });
13080
13699
  if (!isSelection(this.selection)) {
13081
13700
  this.selection.addEventListener("value", (value2) => {
@@ -13091,9 +13710,17 @@ var Menu = class extends MosaicClient {
13091
13710
  const index = this.select.selectedIndex;
13092
13711
  return this.data[index].value;
13093
13712
  } else {
13094
- this.select.value = String(value);
13713
+ const index = this.data?.findIndex((opt) => opt.value === value);
13714
+ if (index >= 0) {
13715
+ this.select.selectedIndex = index;
13716
+ } else {
13717
+ this.select.value = String(value);
13718
+ }
13095
13719
  }
13096
13720
  }
13721
+ reset() {
13722
+ this.select.selectedIndex = this.from ? 0 : -1;
13723
+ }
13097
13724
  publish(value) {
13098
13725
  const { selection, column: column2 } = this;
13099
13726
  if (isSelection(selection)) {
@@ -13127,7 +13754,7 @@ var Menu = class extends MosaicClient {
13127
13754
  this.select.appendChild(opt);
13128
13755
  }
13129
13756
  if (this.selection) {
13130
- this.select.value = this.selection?.value || "";
13757
+ this.selectedValue(this.selection?.value ?? "");
13131
13758
  }
13132
13759
  return this;
13133
13760
  }
@@ -13178,6 +13805,9 @@ var Search = class extends MosaicClient {
13178
13805
  }
13179
13806
  }
13180
13807
  }
13808
+ reset() {
13809
+ this.searchbox.value = "";
13810
+ }
13181
13811
  publish(value) {
13182
13812
  const { selection, column: column2, type } = this;
13183
13813
  if (isSelection(selection)) {
@@ -13230,7 +13860,8 @@ var Slider = class extends MosaicClient {
13230
13860
  from,
13231
13861
  column: column2,
13232
13862
  label = column2,
13233
- value = as?.value
13863
+ value = as?.value,
13864
+ width
13234
13865
  } = {}) {
13235
13866
  super(filterBy);
13236
13867
  this.id = "slider_" + ++_id2;
@@ -13252,6 +13883,8 @@ var Slider = class extends MosaicClient {
13252
13883
  this.slider = document.createElement("input");
13253
13884
  this.slider.setAttribute("id", this.id);
13254
13885
  this.slider.setAttribute("type", "range");
13886
+ if (width != null)
13887
+ this.slider.style.width = `${+width}px`;
13255
13888
  if (min2 != null)
13256
13889
  this.slider.setAttribute("min", min2);
13257
13890
  if (max2 != null)
@@ -13352,16 +13985,20 @@ var Table2 = class extends MosaicClient {
13352
13985
  filterBy,
13353
13986
  from,
13354
13987
  columns = ["*"],
13988
+ align = {},
13355
13989
  format: format2,
13356
- rowBatch = 100,
13357
13990
  width,
13358
- height = 500
13991
+ maxWidth,
13992
+ height = 500,
13993
+ rowBatch = 100
13359
13994
  } = {}) {
13360
13995
  super(filterBy);
13361
13996
  this.id = `table-${++_id3}`;
13362
13997
  this.from = from;
13363
13998
  this.columns = columns;
13364
13999
  this.format = format2;
14000
+ this.align = align;
14001
+ this.widths = typeof width === "object" ? width : {};
13365
14002
  this.offset = 0;
13366
14003
  this.limit = +rowBatch;
13367
14004
  this.pending = false;
@@ -13371,9 +14008,10 @@ var Table2 = class extends MosaicClient {
13371
14008
  this.element = document.createElement("div");
13372
14009
  this.element.setAttribute("id", this.id);
13373
14010
  this.element.value = this;
13374
- if (width) {
13375
- this.element.style.maxWidth = `${width}px`;
13376
- }
14011
+ if (typeof width === "number")
14012
+ this.element.style.width = `${width}px`;
14013
+ if (maxWidth)
14014
+ this.element.style.maxWidth = `${maxWidth}px`;
13377
14015
  this.element.style.maxHeight = `${height}px`;
13378
14016
  this.element.style.overflow = "auto";
13379
14017
  let prevScrollTop = -1;
@@ -13403,12 +14041,12 @@ var Table2 = class extends MosaicClient {
13403
14041
  fields() {
13404
14042
  return this.columns.map((name) => column(this.from, name));
13405
14043
  }
13406
- fieldStats(stats) {
13407
- this.stats = stats;
14044
+ fieldInfo(info) {
14045
+ this.schema = info;
13408
14046
  const thead = this.head;
13409
14047
  thead.innerHTML = "";
13410
14048
  const tr = document.createElement("tr");
13411
- for (const { column: column2 } of stats) {
14049
+ for (const { column: column2 } of info) {
13412
14050
  const th = document.createElement("th");
13413
14051
  th.addEventListener("click", (evt) => this.sort(evt, column2));
13414
14052
  th.appendChild(document.createElement("span"));
@@ -13416,8 +14054,12 @@ var Table2 = class extends MosaicClient {
13416
14054
  tr.appendChild(th);
13417
14055
  }
13418
14056
  thead.appendChild(tr);
13419
- this.formats = formatof(this.format, stats);
13420
- this.style.innerText = tableCSS(this.id, alignof({}, stats));
14057
+ this.formats = formatof(this.format, info);
14058
+ this.style.innerText = tableCSS(
14059
+ this.id,
14060
+ alignof(this.align, info),
14061
+ widthof(this.widths, info)
14062
+ );
13421
14063
  return this;
13422
14064
  }
13423
14065
  query(filter) {
@@ -13425,8 +14067,8 @@ var Table2 = class extends MosaicClient {
13425
14067
  return this.queryInternal(filter);
13426
14068
  }
13427
14069
  queryInternal(filter = []) {
13428
- const { from, limit, offset, stats, sortColumn, sortDesc } = this;
13429
- return Query.from(from).select(stats.map((s) => s.column)).where(filter).orderby(sortColumn ? sortDesc ? desc(sortColumn) : sortColumn : []).limit(limit).offset(offset);
14070
+ const { from, limit, offset, schema, sortColumn, sortDesc } = this;
14071
+ return Query.from(from).select(schema.map((s) => s.column)).where(filter).orderby(sortColumn ? sortDesc ? desc(sortColumn) : sortColumn : []).limit(limit).offset(offset);
13430
14072
  }
13431
14073
  queryResult(data) {
13432
14074
  if (!this.pending) {
@@ -13437,14 +14079,14 @@ var Table2 = class extends MosaicClient {
13437
14079
  return this;
13438
14080
  }
13439
14081
  update() {
13440
- const { body, formats, data, stats, limit } = this;
13441
- const nf = stats.length;
14082
+ const { body, formats, data, schema, limit } = this;
14083
+ const nf = schema.length;
13442
14084
  let count2 = 0;
13443
14085
  for (const row of data) {
13444
14086
  ++count2;
13445
14087
  const tr = document.createElement("tr");
13446
14088
  for (let i = 0; i < nf; ++i) {
13447
- const value = row[stats[i].column];
14089
+ const value = row[schema[i].column];
13448
14090
  const td = document.createElement("td");
13449
14091
  td.innerText = value == null ? "" : formats[i](value);
13450
14092
  tr.appendChild(td);
@@ -13480,8 +14122,8 @@ var Table2 = class extends MosaicClient {
13480
14122
  this.requestQuery(query);
13481
14123
  }
13482
14124
  };
13483
- function formatof(base = {}, stats, locale) {
13484
- return stats.map(({ column: column2, type }) => {
14125
+ function formatof(base = {}, schema, locale) {
14126
+ return schema.map(({ column: column2, type }) => {
13485
14127
  if (column2 in base) {
13486
14128
  return base[column2];
13487
14129
  } else {
@@ -13496,8 +14138,8 @@ function formatof(base = {}, stats, locale) {
13496
14138
  }
13497
14139
  });
13498
14140
  }
13499
- function alignof(base = {}, stats) {
13500
- return stats.map(({ column: column2, type }) => {
14141
+ function alignof(base = {}, schema) {
14142
+ return schema.map(({ column: column2, type }) => {
13501
14143
  if (column2 in base) {
13502
14144
  return base[column2];
13503
14145
  } else if (type === "number") {
@@ -13507,11 +14149,17 @@ function alignof(base = {}, stats) {
13507
14149
  }
13508
14150
  });
13509
14151
  }
13510
- function tableCSS(id, align) {
14152
+ function widthof(base = {}, schema) {
14153
+ return schema.map(({ column: column2 }) => base[column2]);
14154
+ }
14155
+ function tableCSS(id, aligns, widths) {
13511
14156
  const styles = [];
13512
- align.forEach((a, i) => {
13513
- if (a !== "left") {
13514
- styles.push(`#${id} tr>:nth-child(${i + 1}) {text-align:${a}}`);
14157
+ aligns.forEach((a, i) => {
14158
+ const w = +widths[i];
14159
+ if (a !== "left" || w) {
14160
+ const align = a !== "left" ? `text-align:${a};` : "";
14161
+ const width = w ? `width:${w}px;max-width:${w}px;` : "";
14162
+ styles.push(`#${id} tr>:nth-child(${i + 1}) {${align}${width}}`);
13515
14163
  }
13516
14164
  });
13517
14165
  return styles.join(" ");