@vuu-ui/vuu-table 0.7.6-debug → 0.8.0-debug

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/index.js CHANGED
@@ -26,19 +26,95 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var __accessCheck = (obj, member, msg) => {
30
+ if (!member.has(obj))
31
+ throw TypeError("Cannot " + msg);
32
+ };
33
+ var __privateGet = (obj, member, getter) => {
34
+ __accessCheck(obj, member, "read from private field");
35
+ return getter ? getter.call(obj) : member.get(obj);
36
+ };
37
+ var __privateAdd = (obj, member, value) => {
38
+ if (member.has(obj))
39
+ throw TypeError("Cannot add the same private member more than once");
40
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
41
+ };
42
+ var __privateSet = (obj, member, value, setter) => {
43
+ __accessCheck(obj, member, "write to private field");
44
+ setter ? setter.call(obj, value) : member.set(obj, value);
45
+ return value;
46
+ };
29
47
 
30
48
  // src/index.ts
31
49
  var src_exports = {};
32
50
  __export(src_exports, {
51
+ ColumnResizer: () => ColumnResizer,
33
52
  Table: () => Table,
34
53
  buildContextMenuDescriptors: () => buildContextMenuDescriptors,
54
+ isShowSettings: () => isShowSettings,
35
55
  useMeasuredContainer: () => useMeasuredContainer,
56
+ useSelection: () => useSelection,
57
+ useTableColumnResize: () => useTableColumnResize,
36
58
  useTableContextMenu: () => useTableContextMenu,
37
59
  useTableModel: () => useTableModel,
38
60
  useTableViewport: () => useTableViewport
39
61
  });
40
62
  module.exports = __toCommonJS(src_exports);
41
63
 
64
+ // src/ColumnResizer.tsx
65
+ var import_react = require("react");
66
+ var import_jsx_runtime = require("react/jsx-runtime");
67
+ var NOOP = () => void 0;
68
+ var baseClass = "vuuColumnResizer";
69
+ var ColumnResizer = ({
70
+ onDrag,
71
+ onDragEnd = NOOP,
72
+ onDragStart = NOOP
73
+ }) => {
74
+ const position = (0, import_react.useRef)(0);
75
+ const onMouseMove = (0, import_react.useCallback)(
76
+ (e) => {
77
+ if (e.stopPropagation) {
78
+ e.stopPropagation();
79
+ }
80
+ if (e.preventDefault) {
81
+ e.preventDefault();
82
+ }
83
+ const x = Math.round(e.clientX);
84
+ const moveBy = x - position.current;
85
+ position.current = x;
86
+ if (moveBy !== 0) {
87
+ onDrag(e, moveBy);
88
+ }
89
+ },
90
+ [onDrag]
91
+ );
92
+ const onMouseUp = (0, import_react.useCallback)(
93
+ (e) => {
94
+ window.removeEventListener("mouseup", onMouseUp);
95
+ window.removeEventListener("mousemove", onMouseMove);
96
+ onDragEnd(e);
97
+ },
98
+ [onDragEnd, onMouseMove]
99
+ );
100
+ const handleMouseDown = (0, import_react.useCallback)(
101
+ (e) => {
102
+ onDragStart(e);
103
+ position.current = Math.round(e.clientX);
104
+ window.addEventListener("mouseup", onMouseUp);
105
+ window.addEventListener("mousemove", onMouseMove);
106
+ if (e.stopPropagation) {
107
+ e.stopPropagation();
108
+ }
109
+ if (e.preventDefault) {
110
+ e.preventDefault();
111
+ }
112
+ },
113
+ [onDragStart, onMouseMove, onMouseUp]
114
+ );
115
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: baseClass, "data-align": "end", onMouseDown: handleMouseDown });
116
+ };
117
+
42
118
  // src/context-menu/buildContextMenuDescriptors.ts
43
119
  var import_vuu_utils = require("@vuu-ui/vuu-utils");
44
120
  var buildContextMenuDescriptors = (dataSource) => (location, options) => {
@@ -57,6 +133,12 @@ var buildContextMenuDescriptors = (dataSource) => (location, options) => {
57
133
  ...buildAggregationMenuItems(options, dataSource)
58
134
  );
59
135
  descriptors.push(...buildColumnDisplayMenuItems(options));
136
+ descriptors.push({
137
+ action: "column-settings",
138
+ icon: "cog",
139
+ label: `Column Settings`,
140
+ options
141
+ });
60
142
  } else if (location === "filter") {
61
143
  const { column, filter } = options;
62
144
  const colIsOnlyFilter = (filter == null ? void 0 : filter.column) === (column == null ? void 0 : column.name);
@@ -258,11 +340,11 @@ function buildGroupMenuItems(options, { groupBy }) {
258
340
  }
259
341
 
260
342
  // src/context-menu/useTableContextMenu.ts
261
- var import_vuu_filters = require("@vuu-ui/vuu-filters");
262
343
  var import_vuu_utils2 = require("@vuu-ui/vuu-utils");
344
+ var import_vuu_utils3 = require("@vuu-ui/vuu-utils");
263
345
  var removeFilterColumn = (dataSourceFilter, column) => {
264
346
  if (dataSourceFilter.filterStruct && column) {
265
- const [filterStruct, filter] = (0, import_vuu_filters.removeColumnFromFilter)(
347
+ const [filterStruct, filter] = (0, import_vuu_utils2.removeColumnFromFilter)(
266
348
  column,
267
349
  dataSourceFilter.filterStruct
268
350
  );
@@ -274,7 +356,7 @@ var removeFilterColumn = (dataSourceFilter, column) => {
274
356
  return dataSourceFilter;
275
357
  }
276
358
  };
277
- var { Average, Count, Distinct, High, Low, Sum } = import_vuu_utils2.AggregationType;
359
+ var { Average, Count, Distinct, High, Low, Sum } = import_vuu_utils3.AggregationType;
278
360
  var useTableContextMenu = ({
279
361
  dataSource,
280
362
  onPersistentColumnOperation
@@ -285,17 +367,17 @@ var useTableContextMenu = ({
285
367
  const { column } = gridOptions;
286
368
  switch (type) {
287
369
  case "sort-asc":
288
- return dataSource.sort = (0, import_vuu_utils2.setSortColumn)(dataSource.sort, column, "A"), true;
370
+ return dataSource.sort = (0, import_vuu_utils3.setSortColumn)(dataSource.sort, column, "A"), true;
289
371
  case "sort-dsc":
290
- return dataSource.sort = (0, import_vuu_utils2.setSortColumn)(dataSource.sort, column, "D"), true;
372
+ return dataSource.sort = (0, import_vuu_utils3.setSortColumn)(dataSource.sort, column, "D"), true;
291
373
  case "sort-add-asc":
292
- return dataSource.sort = (0, import_vuu_utils2.addSortColumn)(dataSource.sort, column, "A"), true;
374
+ return dataSource.sort = (0, import_vuu_utils3.addSortColumn)(dataSource.sort, column, "A"), true;
293
375
  case "sort-add-dsc":
294
- return dataSource.sort = (0, import_vuu_utils2.addSortColumn)(dataSource.sort, column, "D"), true;
376
+ return dataSource.sort = (0, import_vuu_utils3.addSortColumn)(dataSource.sort, column, "D"), true;
295
377
  case "group":
296
- return dataSource.groupBy = (0, import_vuu_utils2.addGroupColumn)(dataSource.groupBy, column), true;
378
+ return dataSource.groupBy = (0, import_vuu_utils3.addGroupColumn)(dataSource.groupBy, column), true;
297
379
  case "group-add":
298
- return dataSource.groupBy = (0, import_vuu_utils2.addGroupColumn)(dataSource.groupBy, column), true;
380
+ return dataSource.groupBy = (0, import_vuu_utils3.addGroupColumn)(dataSource.groupBy, column), true;
299
381
  case "column-hide":
300
382
  return onPersistentColumnOperation({ type: "hideColumns", columns: [column] }), true;
301
383
  case "column-remove":
@@ -305,17 +387,17 @@ var useTableContextMenu = ({
305
387
  case "remove-filters":
306
388
  return dataSource.filter = { filter: "" }, true;
307
389
  case "agg-avg":
308
- return dataSource.aggregations = (0, import_vuu_utils2.setAggregations)(dataSource.aggregations, column, Average), true;
390
+ return dataSource.aggregations = (0, import_vuu_utils3.setAggregations)(dataSource.aggregations, column, Average), true;
309
391
  case "agg-high":
310
- return dataSource.aggregations = (0, import_vuu_utils2.setAggregations)(dataSource.aggregations, column, High), true;
392
+ return dataSource.aggregations = (0, import_vuu_utils3.setAggregations)(dataSource.aggregations, column, High), true;
311
393
  case "agg-low":
312
- return dataSource.aggregations = (0, import_vuu_utils2.setAggregations)(dataSource.aggregations, column, Low), true;
394
+ return dataSource.aggregations = (0, import_vuu_utils3.setAggregations)(dataSource.aggregations, column, Low), true;
313
395
  case "agg-count":
314
- return dataSource.aggregations = (0, import_vuu_utils2.setAggregations)(dataSource.aggregations, column, Count), true;
396
+ return dataSource.aggregations = (0, import_vuu_utils3.setAggregations)(dataSource.aggregations, column, Count), true;
315
397
  case "agg-distinct":
316
- return dataSource.aggregations = (0, import_vuu_utils2.setAggregations)(dataSource.aggregations, column, Distinct), true;
398
+ return dataSource.aggregations = (0, import_vuu_utils3.setAggregations)(dataSource.aggregations, column, Distinct), true;
317
399
  case "agg-sum":
318
- return dataSource.aggregations = (0, import_vuu_utils2.setAggregations)(dataSource.aggregations, column, Sum), true;
400
+ return dataSource.aggregations = (0, import_vuu_utils3.setAggregations)(dataSource.aggregations, column, Sum), true;
319
401
  case "column-pin-floating":
320
402
  return onPersistentColumnOperation({ type: "pinColumn", column, pin: "floating" }), true;
321
403
  case "column-pin-left":
@@ -324,6 +406,8 @@ var useTableContextMenu = ({
324
406
  return onPersistentColumnOperation({ type: "pinColumn", column, pin: "right" }), true;
325
407
  case "column-unpin":
326
408
  return onPersistentColumnOperation({ type: "pinColumn", column, pin: void 0 }), true;
409
+ case "column-settings":
410
+ return onPersistentColumnOperation({ type: "columnSettings", column }), true;
327
411
  default:
328
412
  }
329
413
  }
@@ -337,22 +421,22 @@ var import_vuu_popups4 = require("@vuu-ui/vuu-popups");
337
421
  var import_core = require("@salt-ds/core");
338
422
 
339
423
  // src/RowBasedTable.tsx
340
- var import_vuu_utils6 = require("@vuu-ui/vuu-utils");
424
+ var import_vuu_utils7 = require("@vuu-ui/vuu-utils");
341
425
  var import_react9 = require("react");
342
426
 
343
427
  // src/TableRow.tsx
344
- var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
428
+ var import_vuu_utils6 = require("@vuu-ui/vuu-utils");
345
429
  var import_classnames2 = __toESM(require("classnames"));
346
- var import_react3 = require("react");
430
+ var import_react4 = require("react");
347
431
 
348
432
  // src/TableCell.tsx
349
- var import_vuu_utils3 = require("@vuu-ui/vuu-utils");
433
+ var import_vuu_utils4 = require("@vuu-ui/vuu-utils");
350
434
  var import_salt_lab = require("@heswell/salt-lab");
351
435
  var import_classnames = __toESM(require("classnames"));
352
- var import_react = require("react");
353
- var import_jsx_runtime = require("react/jsx-runtime");
354
- var { KEY } = import_vuu_utils3.metadataKeys;
355
- var TableCell = (0, import_react.memo)(
436
+ var import_react2 = require("react");
437
+ var import_jsx_runtime2 = require("react/jsx-runtime");
438
+ var { KEY } = import_vuu_utils4.metadataKeys;
439
+ var TableCell = (0, import_react2.memo)(
356
440
  ({
357
441
  className: classNameProp,
358
442
  column,
@@ -360,7 +444,7 @@ var TableCell = (0, import_react.memo)(
360
444
  onClick,
361
445
  row
362
446
  }) => {
363
- const labelFieldRef = (0, import_react.useRef)(null);
447
+ const labelFieldRef = (0, import_react2.useRef)(null);
364
448
  const {
365
449
  align,
366
450
  CellRenderer,
@@ -370,9 +454,9 @@ var TableCell = (0, import_react.memo)(
370
454
  resizing,
371
455
  valueFormatter
372
456
  } = column;
373
- const [editing, setEditing] = (0, import_react.useState)(false);
457
+ const [editing, setEditing] = (0, import_react2.useState)(false);
374
458
  const value = valueFormatter(row[key]);
375
- const [editableValue, setEditableValue] = (0, import_react.useState)(value);
459
+ const [editableValue, setEditableValue] = (0, import_react2.useState)(value);
376
460
  const handleTitleMouseDown = () => {
377
461
  var _a;
378
462
  (_a = labelFieldRef.current) == null ? void 0 : _a.focus();
@@ -382,7 +466,7 @@ var TableCell = (0, import_react.memo)(
382
466
  setEditing(true);
383
467
  }
384
468
  };
385
- const handleClick = (0, import_react.useCallback)(
469
+ const handleClick = (0, import_react2.useCallback)(
386
470
  (evt) => {
387
471
  onClick == null ? void 0 : onClick(evt, column);
388
472
  },
@@ -410,8 +494,8 @@ var TableCell = (0, import_react.memo)(
410
494
  vuuPinRight: pin === "right",
411
495
  "vuuTableCell-resizing": resizing
412
496
  }) || void 0;
413
- const style = (0, import_vuu_utils3.getColumnStyle)(column);
414
- return editable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
497
+ const style = (0, import_vuu_utils4.getColumnStyle)(column);
498
+ return editable ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
415
499
  "div",
416
500
  {
417
501
  className,
@@ -419,7 +503,7 @@ var TableCell = (0, import_react.memo)(
419
503
  role: "cell",
420
504
  style,
421
505
  onKeyDown: handleTitleKeyDown,
422
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
506
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
423
507
  import_salt_lab.EditableLabel,
424
508
  {
425
509
  editing,
@@ -435,14 +519,14 @@ var TableCell = (0, import_react.memo)(
435
519
  "title"
436
520
  )
437
521
  }
438
- ) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
522
+ ) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
439
523
  "div",
440
524
  {
441
525
  className,
442
526
  role: "cell",
443
527
  style,
444
528
  onClick: handleClick,
445
- children: CellRenderer ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CellRenderer, { column, columnMap, row }) : value
529
+ children: CellRenderer ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(CellRenderer, { column, columnMap, row }) : value
446
530
  }
447
531
  );
448
532
  },
@@ -454,35 +538,23 @@ function cellValuesAreEqual(prev, next) {
454
538
  }
455
539
 
456
540
  // src/TableGroupCell.tsx
457
- var import_vuu_utils4 = require("@vuu-ui/vuu-utils");
458
- var import_react2 = require("react");
459
- var import_jsx_runtime2 = require("react/jsx-runtime");
460
- var { DEPTH, IS_LEAF } = import_vuu_utils4.metadataKeys;
461
- var getGroupValueAndOffset = (columns, row) => {
462
- const { [DEPTH]: depth, [IS_LEAF]: isLeaf } = row;
463
- if (isLeaf || depth > columns.length) {
464
- return [null, depth === null ? 0 : Math.max(0, depth - 1)];
465
- } else if (depth === 0) {
466
- return ["$root", 0];
467
- } else {
468
- const { key, valueFormatter } = columns[depth - 1];
469
- const value = valueFormatter(row[key]);
470
- return [value, depth - 1];
471
- }
472
- };
541
+ var import_vuu_utils5 = require("@vuu-ui/vuu-utils");
542
+ var import_react3 = require("react");
543
+ var import_jsx_runtime3 = require("react/jsx-runtime");
544
+ var { IS_LEAF } = import_vuu_utils5.metadataKeys;
473
545
  var TableGroupCell = ({ column, onClick, row }) => {
474
546
  const { columns } = column;
475
- const [value, offset] = getGroupValueAndOffset(columns, row);
476
- const handleClick = (0, import_react2.useCallback)(
547
+ const [value, offset] = (0, import_vuu_utils5.getGroupValueAndOffset)(columns, row);
548
+ const handleClick = (0, import_react3.useCallback)(
477
549
  (evt) => {
478
550
  onClick == null ? void 0 : onClick(evt, column);
479
551
  },
480
552
  [column, onClick]
481
553
  );
482
- const style = (0, import_vuu_utils4.getColumnStyle)(column);
554
+ const style = (0, import_vuu_utils5.getColumnStyle)(column);
483
555
  const isLeaf = row[IS_LEAF];
484
- const spacers = Array(offset).fill(0).map((n, i) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "vuuTableGroupCell-spacer" }, i));
485
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
556
+ const spacers = Array(offset).fill(0).map((n, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "vuuTableGroupCell-spacer" }, i));
557
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
486
558
  "div",
487
559
  {
488
560
  className: "vuuTableGroupCell vuuPinLeft",
@@ -491,18 +563,18 @@ var TableGroupCell = ({ column, onClick, row }) => {
491
563
  style,
492
564
  children: [
493
565
  spacers,
494
- isLeaf ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "vuuTableGroupCell-toggle", "data-icon": "triangle-right" }),
495
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: value })
566
+ isLeaf ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "vuuTableGroupCell-toggle", "data-icon": "triangle-right" }),
567
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: value })
496
568
  ]
497
569
  }
498
570
  );
499
571
  };
500
572
 
501
573
  // src/TableRow.tsx
502
- var import_jsx_runtime3 = require("react/jsx-runtime");
503
- var { IDX, IS_EXPANDED, SELECTED } = import_vuu_utils5.metadataKeys;
574
+ var import_jsx_runtime4 = require("react/jsx-runtime");
575
+ var { IDX, IS_EXPANDED, SELECTED } = import_vuu_utils6.metadataKeys;
504
576
  var classBase = "vuuTableRow";
505
- var TableRow = (0, import_react3.memo)(function Row({
577
+ var TableRow = (0, import_react4.memo)(function Row({
506
578
  columnMap,
507
579
  columns,
508
580
  offset,
@@ -521,7 +593,7 @@ var TableRow = (0, import_react3.memo)(function Row({
521
593
  [`${classBase}-expanded`]: isExpanded,
522
594
  [`${classBase}-preSelected`]: isSelected === 2
523
595
  });
524
- const handleRowClick = (0, import_react3.useCallback)(
596
+ const handleRowClick = (0, import_react4.useCallback)(
525
597
  (evt) => {
526
598
  const rangeSelect = evt.shiftKey;
527
599
  const keepExistingSelection = evt.ctrlKey || evt.metaKey;
@@ -529,16 +601,16 @@ var TableRow = (0, import_react3.memo)(function Row({
529
601
  },
530
602
  [onClick, row]
531
603
  );
532
- const handleGroupCellClick = (0, import_react3.useCallback)(
604
+ const handleGroupCellClick = (0, import_react4.useCallback)(
533
605
  (evt, column) => {
534
- if ((0, import_vuu_utils5.isGroupColumn)(column) || (0, import_vuu_utils5.isJsonGroup)(column, row)) {
606
+ if ((0, import_vuu_utils6.isGroupColumn)(column) || (0, import_vuu_utils6.isJsonGroup)(column, row)) {
535
607
  evt.stopPropagation();
536
608
  onToggleGroup == null ? void 0 : onToggleGroup(row, column);
537
609
  }
538
610
  },
539
611
  [onToggleGroup, row]
540
612
  );
541
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
613
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
542
614
  "div",
543
615
  {
544
616
  "aria-selected": isSelected === 1 ? true : void 0,
@@ -550,12 +622,12 @@ var TableRow = (0, import_react3.memo)(function Row({
550
622
  transform: `translate3d(0px, ${offset}px, 0px)`
551
623
  },
552
624
  children: [
553
- virtualColSpan > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { role: "cell", style: { width: virtualColSpan } }) : null,
554
- columns.filter(import_vuu_utils5.notHidden).map((column) => {
555
- const isGroup = (0, import_vuu_utils5.isGroupColumn)(column);
556
- const isJsonCell = (0, import_vuu_utils5.isJsonColumn)(column);
625
+ virtualColSpan > 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { role: "cell", style: { width: virtualColSpan } }) : null,
626
+ columns.filter(import_vuu_utils6.notHidden).map((column) => {
627
+ const isGroup = (0, import_vuu_utils6.isGroupColumn)(column);
628
+ const isJsonCell = (0, import_vuu_utils6.isJsonColumn)(column);
557
629
  const Cell = isGroup ? TableGroupCell : TableCell;
558
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
630
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
559
631
  Cell,
560
632
  {
561
633
  column,
@@ -575,60 +647,6 @@ var TableRow = (0, import_react3.memo)(function Row({
575
647
  var import_classnames3 = __toESM(require("classnames"));
576
648
  var import_react6 = require("react");
577
649
 
578
- // src/ColumnResizer.tsx
579
- var import_react4 = require("react");
580
- var import_jsx_runtime4 = require("react/jsx-runtime");
581
- var NOOP = () => void 0;
582
- var baseClass = "vuuColumnResizer";
583
- var ColumnResizer = ({
584
- onDrag,
585
- onDragEnd = NOOP,
586
- onDragStart = NOOP
587
- }) => {
588
- const position = (0, import_react4.useRef)(0);
589
- const onMouseMove = (0, import_react4.useCallback)(
590
- (e) => {
591
- if (e.stopPropagation) {
592
- e.stopPropagation();
593
- }
594
- if (e.preventDefault) {
595
- e.preventDefault();
596
- }
597
- const x = Math.round(e.clientX);
598
- const moveBy = x - position.current;
599
- position.current = x;
600
- if (moveBy !== 0) {
601
- onDrag(e, moveBy);
602
- }
603
- },
604
- [onDrag]
605
- );
606
- const onMouseUp = (0, import_react4.useCallback)(
607
- (e) => {
608
- window.removeEventListener("mouseup", onMouseUp);
609
- window.removeEventListener("mousemove", onMouseMove);
610
- onDragEnd(e);
611
- },
612
- [onDragEnd, onMouseMove]
613
- );
614
- const handleMouseDown = (0, import_react4.useCallback)(
615
- (e) => {
616
- onDragStart(e);
617
- position.current = Math.round(e.clientX);
618
- window.addEventListener("mouseup", onMouseUp);
619
- window.addEventListener("mousemove", onMouseMove);
620
- if (e.stopPropagation) {
621
- e.stopPropagation();
622
- }
623
- if (e.preventDefault) {
624
- e.preventDefault();
625
- }
626
- },
627
- [onDragStart, onMouseMove, onMouseUp]
628
- );
629
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: baseClass, "data-align": "end", onMouseDown: handleMouseDown });
630
- };
631
-
632
650
  // src/useTableColumnResize.tsx
633
651
  var import_react5 = require("react");
634
652
  var useTableColumnResize = ({
@@ -641,6 +659,7 @@ var useTableColumnResize = ({
641
659
  const { name } = column;
642
660
  const handleResizeStart = (0, import_react5.useCallback)(() => {
643
661
  if (onResize && rootRef.current) {
662
+ console.log("handleResizeStart");
644
663
  const { width } = rootRef.current.getBoundingClientRect();
645
664
  widthRef.current = Math.round(width);
646
665
  isResizing.current = true;
@@ -819,146 +838,3198 @@ var TableHeaderCell = ({
819
838
  window.clearTimeout(dragTimerRef.current);
820
839
  dragTimerRef.current = null;
821
840
  }
822
- }, []);
823
- const className = (0, import_classnames6.default)(classBase4, classNameProp, {
824
- vuuPinFloating: column.pin === "floating",
825
- vuuPinLeft: column.pin === "left",
826
- vuuPinRight: column.pin === "right",
827
- vuuEndPin: column.endPin,
828
- [`${classBase4}-resizing`]: column.resizing,
829
- [`${classBase4}-right`]: column.align === "right"
830
- });
831
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
832
- "div",
833
- {
834
- className,
835
- ...props,
836
- onClick: handleClick,
837
- onContextMenu: handleContextMenu,
838
- onMouseDown: handleMouseDown,
839
- onMouseUp: handleMouseUp,
840
- ref: rootRef,
841
- children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `${classBase4}-inner`, children: [
842
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FilterIndicator, { column }),
843
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `${classBase4}-label`, children: column.label }),
844
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SortIndicator, { sorted: column.sorted }),
845
- column.resizeable !== false ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ColumnResizer, { ...resizeProps }) : null
846
- ] })
841
+ }, []);
842
+ const className = (0, import_classnames6.default)(classBase4, classNameProp, {
843
+ vuuPinFloating: column.pin === "floating",
844
+ vuuPinLeft: column.pin === "left",
845
+ vuuPinRight: column.pin === "right",
846
+ vuuEndPin: column.endPin,
847
+ [`${classBase4}-resizing`]: column.resizing,
848
+ [`${classBase4}-right`]: column.align === "right"
849
+ });
850
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
851
+ "div",
852
+ {
853
+ className,
854
+ ...props,
855
+ onClick: handleClick,
856
+ onContextMenu: handleContextMenu,
857
+ onMouseDown: handleMouseDown,
858
+ onMouseUp: handleMouseUp,
859
+ ref: rootRef,
860
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: `${classBase4}-inner`, children: [
861
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FilterIndicator, { column }),
862
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `${classBase4}-label`, children: column.label }),
863
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SortIndicator, { sorted: column.sorted }),
864
+ column.resizeable !== false ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ColumnResizer, { ...resizeProps }) : null
865
+ ] })
866
+ }
867
+ );
868
+ };
869
+
870
+ // src/RowBasedTable.tsx
871
+ var import_jsx_runtime9 = require("react/jsx-runtime");
872
+ var classBase5 = "vuuTable";
873
+ var { RENDER_IDX } = import_vuu_utils7.metadataKeys;
874
+ var RowBasedTable = ({
875
+ columns,
876
+ columnsWithinViewport,
877
+ data,
878
+ getRowOffset,
879
+ headings,
880
+ onColumnResize,
881
+ onHeaderCellDragStart,
882
+ onContextMenu,
883
+ onRemoveColumnFromGroupBy,
884
+ onRowClick,
885
+ onSort,
886
+ onToggleGroup,
887
+ tableId,
888
+ virtualColSpan = 0,
889
+ rowCount
890
+ }) => {
891
+ const handleDragStart = (0, import_react9.useCallback)(
892
+ (evt) => {
893
+ onHeaderCellDragStart == null ? void 0 : onHeaderCellDragStart(evt);
894
+ },
895
+ [onHeaderCellDragStart]
896
+ );
897
+ const visibleColumns = (0, import_react9.useMemo)(() => {
898
+ return columns.filter(import_vuu_utils7.notHidden);
899
+ }, [columns]);
900
+ const columnMap = (0, import_react9.useMemo)(() => (0, import_vuu_utils7.buildColumnMap)(columns), [columns]);
901
+ const handleHeaderClick = (0, import_react9.useCallback)(
902
+ (evt) => {
903
+ var _a;
904
+ const targetElement = evt.target;
905
+ const headerCell = targetElement.closest(
906
+ ".vuuTable-headerCell"
907
+ );
908
+ const colIdx = parseInt((_a = headerCell == null ? void 0 : headerCell.dataset.idx) != null ? _a : "-1");
909
+ const column = (0, import_vuu_utils7.visibleColumnAtIndex)(columns, colIdx);
910
+ const isAdditive = evt.shiftKey;
911
+ column && onSort(column, isAdditive);
912
+ },
913
+ [columns, onSort]
914
+ );
915
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { "aria-rowcount": rowCount, className: `${classBase5}-table`, role: "table", children: [
916
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `${classBase5}-headers`, role: "rowGroup", children: [
917
+ headings.map((colHeaders, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "vuuTable-heading", children: colHeaders.map(({ label, width }, j) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "vuuTable-headingCell", style: { width }, children: label }, j)) }, i)),
918
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { role: "row", children: visibleColumns.map((column, i) => {
919
+ const style = (0, import_vuu_utils7.getColumnStyle)(column);
920
+ return (0, import_vuu_utils7.isGroupColumn)(column) ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
921
+ TableGroupHeaderCell,
922
+ {
923
+ column,
924
+ "data-idx": i,
925
+ onRemoveColumn: onRemoveColumnFromGroupBy,
926
+ onResize: onColumnResize,
927
+ role: "columnHeader",
928
+ style
929
+ },
930
+ i
931
+ ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
932
+ TableHeaderCell,
933
+ {
934
+ column,
935
+ "data-idx": i,
936
+ id: `${tableId}-${i}`,
937
+ onClick: handleHeaderClick,
938
+ onDragStart: handleDragStart,
939
+ onResize: onColumnResize,
940
+ role: "columnHeader",
941
+ style
942
+ },
943
+ i
944
+ );
945
+ }) })
946
+ ] }),
947
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
948
+ "div",
949
+ {
950
+ className: `${classBase5}-body`,
951
+ onContextMenu,
952
+ role: "rowGroup",
953
+ children: data == null ? void 0 : data.map((row) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
954
+ TableRow,
955
+ {
956
+ columnMap,
957
+ columns: columnsWithinViewport,
958
+ offset: getRowOffset(row),
959
+ onClick: onRowClick,
960
+ virtualColSpan,
961
+ onToggleGroup,
962
+ row
963
+ },
964
+ row[RENDER_IDX]
965
+ ))
966
+ }
967
+ )
968
+ ] });
969
+ };
970
+
971
+ // src/useTable.ts
972
+ var import_vuu_popups3 = require("@vuu-ui/vuu-popups");
973
+ var import_vuu_utils18 = require("@vuu-ui/vuu-utils");
974
+ var import_react26 = require("react");
975
+
976
+ // ../vuu-data-react/src/hooks/useDataSource.ts
977
+ var import_vuu_utils8 = require("@vuu-ui/vuu-utils");
978
+ var import_react10 = require("react");
979
+ var { SELECTED: SELECTED2 } = import_vuu_utils8.metadataKeys;
980
+
981
+ // ../vuu-data-react/src/hooks/useServerConnectionStatus.ts
982
+ var import_react11 = require("react");
983
+ var import_vuu_data = require("@vuu-ui/vuu-data");
984
+
985
+ // ../vuu-data-react/src/hooks/useServerConnectionQuality.ts
986
+ var import_react12 = require("react");
987
+ var import_vuu_data2 = require("@vuu-ui/vuu-data");
988
+
989
+ // ../vuu-data-react/src/hooks/useTypeaheadSuggestions.ts
990
+ var import_react13 = require("react");
991
+ var import_vuu_data3 = require("@vuu-ui/vuu-data");
992
+
993
+ // ../../node_modules/@lezer/common/dist/index.js
994
+ var DefaultBufferLength = 1024;
995
+ var nextPropID = 0;
996
+ var Range = class {
997
+ constructor(from, to) {
998
+ this.from = from;
999
+ this.to = to;
1000
+ }
1001
+ };
1002
+ var NodeProp = class {
1003
+ /// Create a new node prop type.
1004
+ constructor(config = {}) {
1005
+ this.id = nextPropID++;
1006
+ this.perNode = !!config.perNode;
1007
+ this.deserialize = config.deserialize || (() => {
1008
+ throw new Error("This node type doesn't define a deserialize function");
1009
+ });
1010
+ }
1011
+ /// This is meant to be used with
1012
+ /// [`NodeSet.extend`](#common.NodeSet.extend) or
1013
+ /// [`LRParser.configure`](#lr.ParserConfig.props) to compute
1014
+ /// prop values for each node type in the set. Takes a [match
1015
+ /// object](#common.NodeType^match) or function that returns undefined
1016
+ /// if the node type doesn't get this prop, and the prop's value if
1017
+ /// it does.
1018
+ add(match) {
1019
+ if (this.perNode)
1020
+ throw new RangeError("Can't add per-node props to node types");
1021
+ if (typeof match != "function")
1022
+ match = NodeType.match(match);
1023
+ return (type) => {
1024
+ let result = match(type);
1025
+ return result === void 0 ? null : [this, result];
1026
+ };
1027
+ }
1028
+ };
1029
+ NodeProp.closedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
1030
+ NodeProp.openedBy = new NodeProp({ deserialize: (str) => str.split(" ") });
1031
+ NodeProp.group = new NodeProp({ deserialize: (str) => str.split(" ") });
1032
+ NodeProp.contextHash = new NodeProp({ perNode: true });
1033
+ NodeProp.lookAhead = new NodeProp({ perNode: true });
1034
+ NodeProp.mounted = new NodeProp({ perNode: true });
1035
+ var noProps = /* @__PURE__ */ Object.create(null);
1036
+ var NodeType = class {
1037
+ /// @internal
1038
+ constructor(name, props, id, flags = 0) {
1039
+ this.name = name;
1040
+ this.props = props;
1041
+ this.id = id;
1042
+ this.flags = flags;
1043
+ }
1044
+ /// Define a node type.
1045
+ static define(spec) {
1046
+ let props = spec.props && spec.props.length ? /* @__PURE__ */ Object.create(null) : noProps;
1047
+ let flags = (spec.top ? 1 : 0) | (spec.skipped ? 2 : 0) | (spec.error ? 4 : 0) | (spec.name == null ? 8 : 0);
1048
+ let type = new NodeType(spec.name || "", props, spec.id, flags);
1049
+ if (spec.props)
1050
+ for (let src of spec.props) {
1051
+ if (!Array.isArray(src))
1052
+ src = src(type);
1053
+ if (src) {
1054
+ if (src[0].perNode)
1055
+ throw new RangeError("Can't store a per-node prop on a node type");
1056
+ props[src[0].id] = src[1];
1057
+ }
1058
+ }
1059
+ return type;
1060
+ }
1061
+ /// Retrieves a node prop for this type. Will return `undefined` if
1062
+ /// the prop isn't present on this node.
1063
+ prop(prop) {
1064
+ return this.props[prop.id];
1065
+ }
1066
+ /// True when this is the top node of a grammar.
1067
+ get isTop() {
1068
+ return (this.flags & 1) > 0;
1069
+ }
1070
+ /// True when this node is produced by a skip rule.
1071
+ get isSkipped() {
1072
+ return (this.flags & 2) > 0;
1073
+ }
1074
+ /// Indicates whether this is an error node.
1075
+ get isError() {
1076
+ return (this.flags & 4) > 0;
1077
+ }
1078
+ /// When true, this node type doesn't correspond to a user-declared
1079
+ /// named node, for example because it is used to cache repetition.
1080
+ get isAnonymous() {
1081
+ return (this.flags & 8) > 0;
1082
+ }
1083
+ /// Returns true when this node's name or one of its
1084
+ /// [groups](#common.NodeProp^group) matches the given string.
1085
+ is(name) {
1086
+ if (typeof name == "string") {
1087
+ if (this.name == name)
1088
+ return true;
1089
+ let group = this.prop(NodeProp.group);
1090
+ return group ? group.indexOf(name) > -1 : false;
1091
+ }
1092
+ return this.id == name;
1093
+ }
1094
+ /// Create a function from node types to arbitrary values by
1095
+ /// specifying an object whose property names are node or
1096
+ /// [group](#common.NodeProp^group) names. Often useful with
1097
+ /// [`NodeProp.add`](#common.NodeProp.add). You can put multiple
1098
+ /// names, separated by spaces, in a single property name to map
1099
+ /// multiple node names to a single value.
1100
+ static match(map) {
1101
+ let direct = /* @__PURE__ */ Object.create(null);
1102
+ for (let prop in map)
1103
+ for (let name of prop.split(" "))
1104
+ direct[name] = map[prop];
1105
+ return (node) => {
1106
+ for (let groups = node.prop(NodeProp.group), i = -1; i < (groups ? groups.length : 0); i++) {
1107
+ let found = direct[i < 0 ? node.name : groups[i]];
1108
+ if (found)
1109
+ return found;
1110
+ }
1111
+ };
1112
+ }
1113
+ };
1114
+ NodeType.none = new NodeType(
1115
+ "",
1116
+ /* @__PURE__ */ Object.create(null),
1117
+ 0,
1118
+ 8
1119
+ /* NodeFlag.Anonymous */
1120
+ );
1121
+ var NodeSet = class {
1122
+ /// Create a set with the given types. The `id` property of each
1123
+ /// type should correspond to its position within the array.
1124
+ constructor(types) {
1125
+ this.types = types;
1126
+ for (let i = 0; i < types.length; i++)
1127
+ if (types[i].id != i)
1128
+ throw new RangeError("Node type ids should correspond to array positions when creating a node set");
1129
+ }
1130
+ /// Create a copy of this set with some node properties added. The
1131
+ /// arguments to this method can be created with
1132
+ /// [`NodeProp.add`](#common.NodeProp.add).
1133
+ extend(...props) {
1134
+ let newTypes = [];
1135
+ for (let type of this.types) {
1136
+ let newProps = null;
1137
+ for (let source of props) {
1138
+ let add = source(type);
1139
+ if (add) {
1140
+ if (!newProps)
1141
+ newProps = Object.assign({}, type.props);
1142
+ newProps[add[0].id] = add[1];
1143
+ }
1144
+ }
1145
+ newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);
1146
+ }
1147
+ return new NodeSet(newTypes);
1148
+ }
1149
+ };
1150
+ var CachedNode = /* @__PURE__ */ new WeakMap();
1151
+ var CachedInnerNode = /* @__PURE__ */ new WeakMap();
1152
+ var IterMode;
1153
+ (function(IterMode2) {
1154
+ IterMode2[IterMode2["ExcludeBuffers"] = 1] = "ExcludeBuffers";
1155
+ IterMode2[IterMode2["IncludeAnonymous"] = 2] = "IncludeAnonymous";
1156
+ IterMode2[IterMode2["IgnoreMounts"] = 4] = "IgnoreMounts";
1157
+ IterMode2[IterMode2["IgnoreOverlays"] = 8] = "IgnoreOverlays";
1158
+ })(IterMode || (IterMode = {}));
1159
+ var Tree = class {
1160
+ /// Construct a new tree. See also [`Tree.build`](#common.Tree^build).
1161
+ constructor(type, children, positions, length, props) {
1162
+ this.type = type;
1163
+ this.children = children;
1164
+ this.positions = positions;
1165
+ this.length = length;
1166
+ this.props = null;
1167
+ if (props && props.length) {
1168
+ this.props = /* @__PURE__ */ Object.create(null);
1169
+ for (let [prop, value] of props)
1170
+ this.props[typeof prop == "number" ? prop : prop.id] = value;
1171
+ }
1172
+ }
1173
+ /// @internal
1174
+ toString() {
1175
+ let mounted = this.prop(NodeProp.mounted);
1176
+ if (mounted && !mounted.overlay)
1177
+ return mounted.tree.toString();
1178
+ let children = "";
1179
+ for (let ch of this.children) {
1180
+ let str = ch.toString();
1181
+ if (str) {
1182
+ if (children)
1183
+ children += ",";
1184
+ children += str;
1185
+ }
1186
+ }
1187
+ return !this.type.name ? children : (/\W/.test(this.type.name) && !this.type.isError ? JSON.stringify(this.type.name) : this.type.name) + (children.length ? "(" + children + ")" : "");
1188
+ }
1189
+ /// Get a [tree cursor](#common.TreeCursor) positioned at the top of
1190
+ /// the tree. Mode can be used to [control](#common.IterMode) which
1191
+ /// nodes the cursor visits.
1192
+ cursor(mode = 0) {
1193
+ return new TreeCursor(this.topNode, mode);
1194
+ }
1195
+ /// Get a [tree cursor](#common.TreeCursor) pointing into this tree
1196
+ /// at the given position and side (see
1197
+ /// [`moveTo`](#common.TreeCursor.moveTo).
1198
+ cursorAt(pos, side = 0, mode = 0) {
1199
+ let scope = CachedNode.get(this) || this.topNode;
1200
+ let cursor = new TreeCursor(scope);
1201
+ cursor.moveTo(pos, side);
1202
+ CachedNode.set(this, cursor._tree);
1203
+ return cursor;
1204
+ }
1205
+ /// Get a [syntax node](#common.SyntaxNode) object for the top of the
1206
+ /// tree.
1207
+ get topNode() {
1208
+ return new TreeNode(this, 0, 0, null);
1209
+ }
1210
+ /// Get the [syntax node](#common.SyntaxNode) at the given position.
1211
+ /// If `side` is -1, this will move into nodes that end at the
1212
+ /// position. If 1, it'll move into nodes that start at the
1213
+ /// position. With 0, it'll only enter nodes that cover the position
1214
+ /// from both sides.
1215
+ ///
1216
+ /// Note that this will not enter
1217
+ /// [overlays](#common.MountedTree.overlay), and you often want
1218
+ /// [`resolveInner`](#common.Tree.resolveInner) instead.
1219
+ resolve(pos, side = 0) {
1220
+ let node = resolveNode(CachedNode.get(this) || this.topNode, pos, side, false);
1221
+ CachedNode.set(this, node);
1222
+ return node;
1223
+ }
1224
+ /// Like [`resolve`](#common.Tree.resolve), but will enter
1225
+ /// [overlaid](#common.MountedTree.overlay) nodes, producing a syntax node
1226
+ /// pointing into the innermost overlaid tree at the given position
1227
+ /// (with parent links going through all parent structure, including
1228
+ /// the host trees).
1229
+ resolveInner(pos, side = 0) {
1230
+ let node = resolveNode(CachedInnerNode.get(this) || this.topNode, pos, side, true);
1231
+ CachedInnerNode.set(this, node);
1232
+ return node;
1233
+ }
1234
+ /// Iterate over the tree and its children, calling `enter` for any
1235
+ /// node that touches the `from`/`to` region (if given) before
1236
+ /// running over such a node's children, and `leave` (if given) when
1237
+ /// leaving the node. When `enter` returns `false`, that node will
1238
+ /// not have its children iterated over (or `leave` called).
1239
+ iterate(spec) {
1240
+ let { enter, leave, from = 0, to = this.length } = spec;
1241
+ let mode = spec.mode || 0, anon = (mode & IterMode.IncludeAnonymous) > 0;
1242
+ for (let c = this.cursor(mode | IterMode.IncludeAnonymous); ; ) {
1243
+ let entered = false;
1244
+ if (c.from <= to && c.to >= from && (!anon && c.type.isAnonymous || enter(c) !== false)) {
1245
+ if (c.firstChild())
1246
+ continue;
1247
+ entered = true;
1248
+ }
1249
+ for (; ; ) {
1250
+ if (entered && leave && (anon || !c.type.isAnonymous))
1251
+ leave(c);
1252
+ if (c.nextSibling())
1253
+ break;
1254
+ if (!c.parent())
1255
+ return;
1256
+ entered = true;
1257
+ }
1258
+ }
1259
+ }
1260
+ /// Get the value of the given [node prop](#common.NodeProp) for this
1261
+ /// node. Works with both per-node and per-type props.
1262
+ prop(prop) {
1263
+ return !prop.perNode ? this.type.prop(prop) : this.props ? this.props[prop.id] : void 0;
1264
+ }
1265
+ /// Returns the node's [per-node props](#common.NodeProp.perNode) in a
1266
+ /// format that can be passed to the [`Tree`](#common.Tree)
1267
+ /// constructor.
1268
+ get propValues() {
1269
+ let result = [];
1270
+ if (this.props)
1271
+ for (let id in this.props)
1272
+ result.push([+id, this.props[id]]);
1273
+ return result;
1274
+ }
1275
+ /// Balance the direct children of this tree, producing a copy of
1276
+ /// which may have children grouped into subtrees with type
1277
+ /// [`NodeType.none`](#common.NodeType^none).
1278
+ balance(config = {}) {
1279
+ return this.children.length <= 8 ? this : balanceRange(NodeType.none, this.children, this.positions, 0, this.children.length, 0, this.length, (children, positions, length) => new Tree(this.type, children, positions, length, this.propValues), config.makeTree || ((children, positions, length) => new Tree(NodeType.none, children, positions, length)));
1280
+ }
1281
+ /// Build a tree from a postfix-ordered buffer of node information,
1282
+ /// or a cursor over such a buffer.
1283
+ static build(data) {
1284
+ return buildTree(data);
1285
+ }
1286
+ };
1287
+ Tree.empty = new Tree(NodeType.none, [], [], 0);
1288
+ var FlatBufferCursor = class {
1289
+ constructor(buffer, index) {
1290
+ this.buffer = buffer;
1291
+ this.index = index;
1292
+ }
1293
+ get id() {
1294
+ return this.buffer[this.index - 4];
1295
+ }
1296
+ get start() {
1297
+ return this.buffer[this.index - 3];
1298
+ }
1299
+ get end() {
1300
+ return this.buffer[this.index - 2];
1301
+ }
1302
+ get size() {
1303
+ return this.buffer[this.index - 1];
1304
+ }
1305
+ get pos() {
1306
+ return this.index;
1307
+ }
1308
+ next() {
1309
+ this.index -= 4;
1310
+ }
1311
+ fork() {
1312
+ return new FlatBufferCursor(this.buffer, this.index);
1313
+ }
1314
+ };
1315
+ var TreeBuffer = class {
1316
+ /// Create a tree buffer.
1317
+ constructor(buffer, length, set) {
1318
+ this.buffer = buffer;
1319
+ this.length = length;
1320
+ this.set = set;
1321
+ }
1322
+ /// @internal
1323
+ get type() {
1324
+ return NodeType.none;
1325
+ }
1326
+ /// @internal
1327
+ toString() {
1328
+ let result = [];
1329
+ for (let index = 0; index < this.buffer.length; ) {
1330
+ result.push(this.childString(index));
1331
+ index = this.buffer[index + 3];
1332
+ }
1333
+ return result.join(",");
1334
+ }
1335
+ /// @internal
1336
+ childString(index) {
1337
+ let id = this.buffer[index], endIndex = this.buffer[index + 3];
1338
+ let type = this.set.types[id], result = type.name;
1339
+ if (/\W/.test(result) && !type.isError)
1340
+ result = JSON.stringify(result);
1341
+ index += 4;
1342
+ if (endIndex == index)
1343
+ return result;
1344
+ let children = [];
1345
+ while (index < endIndex) {
1346
+ children.push(this.childString(index));
1347
+ index = this.buffer[index + 3];
1348
+ }
1349
+ return result + "(" + children.join(",") + ")";
1350
+ }
1351
+ /// @internal
1352
+ findChild(startIndex, endIndex, dir, pos, side) {
1353
+ let { buffer } = this, pick = -1;
1354
+ for (let i = startIndex; i != endIndex; i = buffer[i + 3]) {
1355
+ if (checkSide(side, pos, buffer[i + 1], buffer[i + 2])) {
1356
+ pick = i;
1357
+ if (dir > 0)
1358
+ break;
1359
+ }
1360
+ }
1361
+ return pick;
1362
+ }
1363
+ /// @internal
1364
+ slice(startI, endI, from) {
1365
+ let b = this.buffer;
1366
+ let copy = new Uint16Array(endI - startI), len = 0;
1367
+ for (let i = startI, j = 0; i < endI; ) {
1368
+ copy[j++] = b[i++];
1369
+ copy[j++] = b[i++] - from;
1370
+ let to = copy[j++] = b[i++] - from;
1371
+ copy[j++] = b[i++] - startI;
1372
+ len = Math.max(len, to);
1373
+ }
1374
+ return new TreeBuffer(copy, len, this.set);
1375
+ }
1376
+ };
1377
+ function checkSide(side, pos, from, to) {
1378
+ switch (side) {
1379
+ case -2:
1380
+ return from < pos;
1381
+ case -1:
1382
+ return to >= pos && from < pos;
1383
+ case 0:
1384
+ return from < pos && to > pos;
1385
+ case 1:
1386
+ return from <= pos && to > pos;
1387
+ case 2:
1388
+ return to > pos;
1389
+ case 4:
1390
+ return true;
1391
+ }
1392
+ }
1393
+ function enterUnfinishedNodesBefore(node, pos) {
1394
+ let scan = node.childBefore(pos);
1395
+ while (scan) {
1396
+ let last = scan.lastChild;
1397
+ if (!last || last.to != scan.to)
1398
+ break;
1399
+ if (last.type.isError && last.from == last.to) {
1400
+ node = scan;
1401
+ scan = last.prevSibling;
1402
+ } else {
1403
+ scan = last;
1404
+ }
1405
+ }
1406
+ return node;
1407
+ }
1408
+ function resolveNode(node, pos, side, overlays) {
1409
+ var _a;
1410
+ while (node.from == node.to || (side < 1 ? node.from >= pos : node.from > pos) || (side > -1 ? node.to <= pos : node.to < pos)) {
1411
+ let parent = !overlays && node instanceof TreeNode && node.index < 0 ? null : node.parent;
1412
+ if (!parent)
1413
+ return node;
1414
+ node = parent;
1415
+ }
1416
+ let mode = overlays ? 0 : IterMode.IgnoreOverlays;
1417
+ if (overlays)
1418
+ for (let scan = node, parent = scan.parent; parent; scan = parent, parent = scan.parent) {
1419
+ if (scan instanceof TreeNode && scan.index < 0 && ((_a = parent.enter(pos, side, mode)) === null || _a === void 0 ? void 0 : _a.from) != scan.from)
1420
+ node = parent;
1421
+ }
1422
+ for (; ; ) {
1423
+ let inner = node.enter(pos, side, mode);
1424
+ if (!inner)
1425
+ return node;
1426
+ node = inner;
1427
+ }
1428
+ }
1429
+ var TreeNode = class {
1430
+ constructor(_tree, from, index, _parent) {
1431
+ this._tree = _tree;
1432
+ this.from = from;
1433
+ this.index = index;
1434
+ this._parent = _parent;
1435
+ }
1436
+ get type() {
1437
+ return this._tree.type;
1438
+ }
1439
+ get name() {
1440
+ return this._tree.type.name;
1441
+ }
1442
+ get to() {
1443
+ return this.from + this._tree.length;
1444
+ }
1445
+ nextChild(i, dir, pos, side, mode = 0) {
1446
+ for (let parent = this; ; ) {
1447
+ for (let { children, positions } = parent._tree, e = dir > 0 ? children.length : -1; i != e; i += dir) {
1448
+ let next = children[i], start = positions[i] + parent.from;
1449
+ if (!checkSide(side, pos, start, start + next.length))
1450
+ continue;
1451
+ if (next instanceof TreeBuffer) {
1452
+ if (mode & IterMode.ExcludeBuffers)
1453
+ continue;
1454
+ let index = next.findChild(0, next.buffer.length, dir, pos - start, side);
1455
+ if (index > -1)
1456
+ return new BufferNode(new BufferContext(parent, next, i, start), null, index);
1457
+ } else if (mode & IterMode.IncludeAnonymous || (!next.type.isAnonymous || hasChild(next))) {
1458
+ let mounted;
1459
+ if (!(mode & IterMode.IgnoreMounts) && next.props && (mounted = next.prop(NodeProp.mounted)) && !mounted.overlay)
1460
+ return new TreeNode(mounted.tree, start, i, parent);
1461
+ let inner = new TreeNode(next, start, i, parent);
1462
+ return mode & IterMode.IncludeAnonymous || !inner.type.isAnonymous ? inner : inner.nextChild(dir < 0 ? next.children.length - 1 : 0, dir, pos, side);
1463
+ }
1464
+ }
1465
+ if (mode & IterMode.IncludeAnonymous || !parent.type.isAnonymous)
1466
+ return null;
1467
+ if (parent.index >= 0)
1468
+ i = parent.index + dir;
1469
+ else
1470
+ i = dir < 0 ? -1 : parent._parent._tree.children.length;
1471
+ parent = parent._parent;
1472
+ if (!parent)
1473
+ return null;
1474
+ }
1475
+ }
1476
+ get firstChild() {
1477
+ return this.nextChild(
1478
+ 0,
1479
+ 1,
1480
+ 0,
1481
+ 4
1482
+ /* Side.DontCare */
1483
+ );
1484
+ }
1485
+ get lastChild() {
1486
+ return this.nextChild(
1487
+ this._tree.children.length - 1,
1488
+ -1,
1489
+ 0,
1490
+ 4
1491
+ /* Side.DontCare */
1492
+ );
1493
+ }
1494
+ childAfter(pos) {
1495
+ return this.nextChild(
1496
+ 0,
1497
+ 1,
1498
+ pos,
1499
+ 2
1500
+ /* Side.After */
1501
+ );
1502
+ }
1503
+ childBefore(pos) {
1504
+ return this.nextChild(
1505
+ this._tree.children.length - 1,
1506
+ -1,
1507
+ pos,
1508
+ -2
1509
+ /* Side.Before */
1510
+ );
1511
+ }
1512
+ enter(pos, side, mode = 0) {
1513
+ let mounted;
1514
+ if (!(mode & IterMode.IgnoreOverlays) && (mounted = this._tree.prop(NodeProp.mounted)) && mounted.overlay) {
1515
+ let rPos = pos - this.from;
1516
+ for (let { from, to } of mounted.overlay) {
1517
+ if ((side > 0 ? from <= rPos : from < rPos) && (side < 0 ? to >= rPos : to > rPos))
1518
+ return new TreeNode(mounted.tree, mounted.overlay[0].from + this.from, -1, this);
1519
+ }
1520
+ }
1521
+ return this.nextChild(0, 1, pos, side, mode);
1522
+ }
1523
+ nextSignificantParent() {
1524
+ let val = this;
1525
+ while (val.type.isAnonymous && val._parent)
1526
+ val = val._parent;
1527
+ return val;
1528
+ }
1529
+ get parent() {
1530
+ return this._parent ? this._parent.nextSignificantParent() : null;
1531
+ }
1532
+ get nextSibling() {
1533
+ return this._parent && this.index >= 0 ? this._parent.nextChild(
1534
+ this.index + 1,
1535
+ 1,
1536
+ 0,
1537
+ 4
1538
+ /* Side.DontCare */
1539
+ ) : null;
1540
+ }
1541
+ get prevSibling() {
1542
+ return this._parent && this.index >= 0 ? this._parent.nextChild(
1543
+ this.index - 1,
1544
+ -1,
1545
+ 0,
1546
+ 4
1547
+ /* Side.DontCare */
1548
+ ) : null;
1549
+ }
1550
+ cursor(mode = 0) {
1551
+ return new TreeCursor(this, mode);
1552
+ }
1553
+ get tree() {
1554
+ return this._tree;
1555
+ }
1556
+ toTree() {
1557
+ return this._tree;
1558
+ }
1559
+ resolve(pos, side = 0) {
1560
+ return resolveNode(this, pos, side, false);
1561
+ }
1562
+ resolveInner(pos, side = 0) {
1563
+ return resolveNode(this, pos, side, true);
1564
+ }
1565
+ enterUnfinishedNodesBefore(pos) {
1566
+ return enterUnfinishedNodesBefore(this, pos);
1567
+ }
1568
+ getChild(type, before = null, after = null) {
1569
+ let r = getChildren(this, type, before, after);
1570
+ return r.length ? r[0] : null;
1571
+ }
1572
+ getChildren(type, before = null, after = null) {
1573
+ return getChildren(this, type, before, after);
1574
+ }
1575
+ /// @internal
1576
+ toString() {
1577
+ return this._tree.toString();
1578
+ }
1579
+ get node() {
1580
+ return this;
1581
+ }
1582
+ matchContext(context) {
1583
+ return matchNodeContext(this, context);
1584
+ }
1585
+ };
1586
+ function getChildren(node, type, before, after) {
1587
+ let cur = node.cursor(), result = [];
1588
+ if (!cur.firstChild())
1589
+ return result;
1590
+ if (before != null) {
1591
+ while (!cur.type.is(before))
1592
+ if (!cur.nextSibling())
1593
+ return result;
1594
+ }
1595
+ for (; ; ) {
1596
+ if (after != null && cur.type.is(after))
1597
+ return result;
1598
+ if (cur.type.is(type))
1599
+ result.push(cur.node);
1600
+ if (!cur.nextSibling())
1601
+ return after == null ? result : [];
1602
+ }
1603
+ }
1604
+ function matchNodeContext(node, context, i = context.length - 1) {
1605
+ for (let p = node.parent; i >= 0; p = p.parent) {
1606
+ if (!p)
1607
+ return false;
1608
+ if (!p.type.isAnonymous) {
1609
+ if (context[i] && context[i] != p.name)
1610
+ return false;
1611
+ i--;
1612
+ }
1613
+ }
1614
+ return true;
1615
+ }
1616
+ var BufferContext = class {
1617
+ constructor(parent, buffer, index, start) {
1618
+ this.parent = parent;
1619
+ this.buffer = buffer;
1620
+ this.index = index;
1621
+ this.start = start;
1622
+ }
1623
+ };
1624
+ var BufferNode = class {
1625
+ get name() {
1626
+ return this.type.name;
1627
+ }
1628
+ get from() {
1629
+ return this.context.start + this.context.buffer.buffer[this.index + 1];
1630
+ }
1631
+ get to() {
1632
+ return this.context.start + this.context.buffer.buffer[this.index + 2];
1633
+ }
1634
+ constructor(context, _parent, index) {
1635
+ this.context = context;
1636
+ this._parent = _parent;
1637
+ this.index = index;
1638
+ this.type = context.buffer.set.types[context.buffer.buffer[index]];
1639
+ }
1640
+ child(dir, pos, side) {
1641
+ let { buffer } = this.context;
1642
+ let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.context.start, side);
1643
+ return index < 0 ? null : new BufferNode(this.context, this, index);
1644
+ }
1645
+ get firstChild() {
1646
+ return this.child(
1647
+ 1,
1648
+ 0,
1649
+ 4
1650
+ /* Side.DontCare */
1651
+ );
1652
+ }
1653
+ get lastChild() {
1654
+ return this.child(
1655
+ -1,
1656
+ 0,
1657
+ 4
1658
+ /* Side.DontCare */
1659
+ );
1660
+ }
1661
+ childAfter(pos) {
1662
+ return this.child(
1663
+ 1,
1664
+ pos,
1665
+ 2
1666
+ /* Side.After */
1667
+ );
1668
+ }
1669
+ childBefore(pos) {
1670
+ return this.child(
1671
+ -1,
1672
+ pos,
1673
+ -2
1674
+ /* Side.Before */
1675
+ );
1676
+ }
1677
+ enter(pos, side, mode = 0) {
1678
+ if (mode & IterMode.ExcludeBuffers)
1679
+ return null;
1680
+ let { buffer } = this.context;
1681
+ let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], side > 0 ? 1 : -1, pos - this.context.start, side);
1682
+ return index < 0 ? null : new BufferNode(this.context, this, index);
1683
+ }
1684
+ get parent() {
1685
+ return this._parent || this.context.parent.nextSignificantParent();
1686
+ }
1687
+ externalSibling(dir) {
1688
+ return this._parent ? null : this.context.parent.nextChild(
1689
+ this.context.index + dir,
1690
+ dir,
1691
+ 0,
1692
+ 4
1693
+ /* Side.DontCare */
1694
+ );
1695
+ }
1696
+ get nextSibling() {
1697
+ let { buffer } = this.context;
1698
+ let after = buffer.buffer[this.index + 3];
1699
+ if (after < (this._parent ? buffer.buffer[this._parent.index + 3] : buffer.buffer.length))
1700
+ return new BufferNode(this.context, this._parent, after);
1701
+ return this.externalSibling(1);
1702
+ }
1703
+ get prevSibling() {
1704
+ let { buffer } = this.context;
1705
+ let parentStart = this._parent ? this._parent.index + 4 : 0;
1706
+ if (this.index == parentStart)
1707
+ return this.externalSibling(-1);
1708
+ return new BufferNode(this.context, this._parent, buffer.findChild(
1709
+ parentStart,
1710
+ this.index,
1711
+ -1,
1712
+ 0,
1713
+ 4
1714
+ /* Side.DontCare */
1715
+ ));
1716
+ }
1717
+ cursor(mode = 0) {
1718
+ return new TreeCursor(this, mode);
1719
+ }
1720
+ get tree() {
1721
+ return null;
1722
+ }
1723
+ toTree() {
1724
+ let children = [], positions = [];
1725
+ let { buffer } = this.context;
1726
+ let startI = this.index + 4, endI = buffer.buffer[this.index + 3];
1727
+ if (endI > startI) {
1728
+ let from = buffer.buffer[this.index + 1];
1729
+ children.push(buffer.slice(startI, endI, from));
1730
+ positions.push(0);
1731
+ }
1732
+ return new Tree(this.type, children, positions, this.to - this.from);
1733
+ }
1734
+ resolve(pos, side = 0) {
1735
+ return resolveNode(this, pos, side, false);
1736
+ }
1737
+ resolveInner(pos, side = 0) {
1738
+ return resolveNode(this, pos, side, true);
1739
+ }
1740
+ enterUnfinishedNodesBefore(pos) {
1741
+ return enterUnfinishedNodesBefore(this, pos);
1742
+ }
1743
+ /// @internal
1744
+ toString() {
1745
+ return this.context.buffer.childString(this.index);
1746
+ }
1747
+ getChild(type, before = null, after = null) {
1748
+ let r = getChildren(this, type, before, after);
1749
+ return r.length ? r[0] : null;
1750
+ }
1751
+ getChildren(type, before = null, after = null) {
1752
+ return getChildren(this, type, before, after);
1753
+ }
1754
+ get node() {
1755
+ return this;
1756
+ }
1757
+ matchContext(context) {
1758
+ return matchNodeContext(this, context);
1759
+ }
1760
+ };
1761
+ var TreeCursor = class {
1762
+ /// Shorthand for `.type.name`.
1763
+ get name() {
1764
+ return this.type.name;
1765
+ }
1766
+ /// @internal
1767
+ constructor(node, mode = 0) {
1768
+ this.mode = mode;
1769
+ this.buffer = null;
1770
+ this.stack = [];
1771
+ this.index = 0;
1772
+ this.bufferNode = null;
1773
+ if (node instanceof TreeNode) {
1774
+ this.yieldNode(node);
1775
+ } else {
1776
+ this._tree = node.context.parent;
1777
+ this.buffer = node.context;
1778
+ for (let n = node._parent; n; n = n._parent)
1779
+ this.stack.unshift(n.index);
1780
+ this.bufferNode = node;
1781
+ this.yieldBuf(node.index);
1782
+ }
1783
+ }
1784
+ yieldNode(node) {
1785
+ if (!node)
1786
+ return false;
1787
+ this._tree = node;
1788
+ this.type = node.type;
1789
+ this.from = node.from;
1790
+ this.to = node.to;
1791
+ return true;
1792
+ }
1793
+ yieldBuf(index, type) {
1794
+ this.index = index;
1795
+ let { start, buffer } = this.buffer;
1796
+ this.type = type || buffer.set.types[buffer.buffer[index]];
1797
+ this.from = start + buffer.buffer[index + 1];
1798
+ this.to = start + buffer.buffer[index + 2];
1799
+ return true;
1800
+ }
1801
+ yield(node) {
1802
+ if (!node)
1803
+ return false;
1804
+ if (node instanceof TreeNode) {
1805
+ this.buffer = null;
1806
+ return this.yieldNode(node);
1807
+ }
1808
+ this.buffer = node.context;
1809
+ return this.yieldBuf(node.index, node.type);
1810
+ }
1811
+ /// @internal
1812
+ toString() {
1813
+ return this.buffer ? this.buffer.buffer.childString(this.index) : this._tree.toString();
1814
+ }
1815
+ /// @internal
1816
+ enterChild(dir, pos, side) {
1817
+ if (!this.buffer)
1818
+ return this.yield(this._tree.nextChild(dir < 0 ? this._tree._tree.children.length - 1 : 0, dir, pos, side, this.mode));
1819
+ let { buffer } = this.buffer;
1820
+ let index = buffer.findChild(this.index + 4, buffer.buffer[this.index + 3], dir, pos - this.buffer.start, side);
1821
+ if (index < 0)
1822
+ return false;
1823
+ this.stack.push(this.index);
1824
+ return this.yieldBuf(index);
1825
+ }
1826
+ /// Move the cursor to this node's first child. When this returns
1827
+ /// false, the node has no child, and the cursor has not been moved.
1828
+ firstChild() {
1829
+ return this.enterChild(
1830
+ 1,
1831
+ 0,
1832
+ 4
1833
+ /* Side.DontCare */
1834
+ );
1835
+ }
1836
+ /// Move the cursor to this node's last child.
1837
+ lastChild() {
1838
+ return this.enterChild(
1839
+ -1,
1840
+ 0,
1841
+ 4
1842
+ /* Side.DontCare */
1843
+ );
1844
+ }
1845
+ /// Move the cursor to the first child that ends after `pos`.
1846
+ childAfter(pos) {
1847
+ return this.enterChild(
1848
+ 1,
1849
+ pos,
1850
+ 2
1851
+ /* Side.After */
1852
+ );
1853
+ }
1854
+ /// Move to the last child that starts before `pos`.
1855
+ childBefore(pos) {
1856
+ return this.enterChild(
1857
+ -1,
1858
+ pos,
1859
+ -2
1860
+ /* Side.Before */
1861
+ );
1862
+ }
1863
+ /// Move the cursor to the child around `pos`. If side is -1 the
1864
+ /// child may end at that position, when 1 it may start there. This
1865
+ /// will also enter [overlaid](#common.MountedTree.overlay)
1866
+ /// [mounted](#common.NodeProp^mounted) trees unless `overlays` is
1867
+ /// set to false.
1868
+ enter(pos, side, mode = this.mode) {
1869
+ if (!this.buffer)
1870
+ return this.yield(this._tree.enter(pos, side, mode));
1871
+ return mode & IterMode.ExcludeBuffers ? false : this.enterChild(1, pos, side);
1872
+ }
1873
+ /// Move to the node's parent node, if this isn't the top node.
1874
+ parent() {
1875
+ if (!this.buffer)
1876
+ return this.yieldNode(this.mode & IterMode.IncludeAnonymous ? this._tree._parent : this._tree.parent);
1877
+ if (this.stack.length)
1878
+ return this.yieldBuf(this.stack.pop());
1879
+ let parent = this.mode & IterMode.IncludeAnonymous ? this.buffer.parent : this.buffer.parent.nextSignificantParent();
1880
+ this.buffer = null;
1881
+ return this.yieldNode(parent);
1882
+ }
1883
+ /// @internal
1884
+ sibling(dir) {
1885
+ if (!this.buffer)
1886
+ return !this._tree._parent ? false : this.yield(this._tree.index < 0 ? null : this._tree._parent.nextChild(this._tree.index + dir, dir, 0, 4, this.mode));
1887
+ let { buffer } = this.buffer, d = this.stack.length - 1;
1888
+ if (dir < 0) {
1889
+ let parentStart = d < 0 ? 0 : this.stack[d] + 4;
1890
+ if (this.index != parentStart)
1891
+ return this.yieldBuf(buffer.findChild(
1892
+ parentStart,
1893
+ this.index,
1894
+ -1,
1895
+ 0,
1896
+ 4
1897
+ /* Side.DontCare */
1898
+ ));
1899
+ } else {
1900
+ let after = buffer.buffer[this.index + 3];
1901
+ if (after < (d < 0 ? buffer.buffer.length : buffer.buffer[this.stack[d] + 3]))
1902
+ return this.yieldBuf(after);
1903
+ }
1904
+ return d < 0 ? this.yield(this.buffer.parent.nextChild(this.buffer.index + dir, dir, 0, 4, this.mode)) : false;
1905
+ }
1906
+ /// Move to this node's next sibling, if any.
1907
+ nextSibling() {
1908
+ return this.sibling(1);
1909
+ }
1910
+ /// Move to this node's previous sibling, if any.
1911
+ prevSibling() {
1912
+ return this.sibling(-1);
1913
+ }
1914
+ atLastNode(dir) {
1915
+ let index, parent, { buffer } = this;
1916
+ if (buffer) {
1917
+ if (dir > 0) {
1918
+ if (this.index < buffer.buffer.buffer.length)
1919
+ return false;
1920
+ } else {
1921
+ for (let i = 0; i < this.index; i++)
1922
+ if (buffer.buffer.buffer[i + 3] < this.index)
1923
+ return false;
1924
+ }
1925
+ ({ index, parent } = buffer);
1926
+ } else {
1927
+ ({ index, _parent: parent } = this._tree);
1928
+ }
1929
+ for (; parent; { index, _parent: parent } = parent) {
1930
+ if (index > -1)
1931
+ for (let i = index + dir, e = dir < 0 ? -1 : parent._tree.children.length; i != e; i += dir) {
1932
+ let child = parent._tree.children[i];
1933
+ if (this.mode & IterMode.IncludeAnonymous || child instanceof TreeBuffer || !child.type.isAnonymous || hasChild(child))
1934
+ return false;
1935
+ }
1936
+ }
1937
+ return true;
1938
+ }
1939
+ move(dir, enter) {
1940
+ if (enter && this.enterChild(
1941
+ dir,
1942
+ 0,
1943
+ 4
1944
+ /* Side.DontCare */
1945
+ ))
1946
+ return true;
1947
+ for (; ; ) {
1948
+ if (this.sibling(dir))
1949
+ return true;
1950
+ if (this.atLastNode(dir) || !this.parent())
1951
+ return false;
1952
+ }
1953
+ }
1954
+ /// Move to the next node in a
1955
+ /// [pre-order](https://en.wikipedia.org/wiki/Tree_traversal#Pre-order,_NLR)
1956
+ /// traversal, going from a node to its first child or, if the
1957
+ /// current node is empty or `enter` is false, its next sibling or
1958
+ /// the next sibling of the first parent node that has one.
1959
+ next(enter = true) {
1960
+ return this.move(1, enter);
1961
+ }
1962
+ /// Move to the next node in a last-to-first pre-order traveral. A
1963
+ /// node is followed by its last child or, if it has none, its
1964
+ /// previous sibling or the previous sibling of the first parent
1965
+ /// node that has one.
1966
+ prev(enter = true) {
1967
+ return this.move(-1, enter);
1968
+ }
1969
+ /// Move the cursor to the innermost node that covers `pos`. If
1970
+ /// `side` is -1, it will enter nodes that end at `pos`. If it is 1,
1971
+ /// it will enter nodes that start at `pos`.
1972
+ moveTo(pos, side = 0) {
1973
+ while (this.from == this.to || (side < 1 ? this.from >= pos : this.from > pos) || (side > -1 ? this.to <= pos : this.to < pos))
1974
+ if (!this.parent())
1975
+ break;
1976
+ while (this.enterChild(1, pos, side)) {
1977
+ }
1978
+ return this;
1979
+ }
1980
+ /// Get a [syntax node](#common.SyntaxNode) at the cursor's current
1981
+ /// position.
1982
+ get node() {
1983
+ if (!this.buffer)
1984
+ return this._tree;
1985
+ let cache = this.bufferNode, result = null, depth = 0;
1986
+ if (cache && cache.context == this.buffer) {
1987
+ scan:
1988
+ for (let index = this.index, d = this.stack.length; d >= 0; ) {
1989
+ for (let c = cache; c; c = c._parent)
1990
+ if (c.index == index) {
1991
+ if (index == this.index)
1992
+ return c;
1993
+ result = c;
1994
+ depth = d + 1;
1995
+ break scan;
1996
+ }
1997
+ index = this.stack[--d];
1998
+ }
1999
+ }
2000
+ for (let i = depth; i < this.stack.length; i++)
2001
+ result = new BufferNode(this.buffer, result, this.stack[i]);
2002
+ return this.bufferNode = new BufferNode(this.buffer, result, this.index);
2003
+ }
2004
+ /// Get the [tree](#common.Tree) that represents the current node, if
2005
+ /// any. Will return null when the node is in a [tree
2006
+ /// buffer](#common.TreeBuffer).
2007
+ get tree() {
2008
+ return this.buffer ? null : this._tree._tree;
2009
+ }
2010
+ /// Iterate over the current node and all its descendants, calling
2011
+ /// `enter` when entering a node and `leave`, if given, when leaving
2012
+ /// one. When `enter` returns `false`, any children of that node are
2013
+ /// skipped, and `leave` isn't called for it.
2014
+ iterate(enter, leave) {
2015
+ for (let depth = 0; ; ) {
2016
+ let mustLeave = false;
2017
+ if (this.type.isAnonymous || enter(this) !== false) {
2018
+ if (this.firstChild()) {
2019
+ depth++;
2020
+ continue;
2021
+ }
2022
+ if (!this.type.isAnonymous)
2023
+ mustLeave = true;
2024
+ }
2025
+ for (; ; ) {
2026
+ if (mustLeave && leave)
2027
+ leave(this);
2028
+ mustLeave = this.type.isAnonymous;
2029
+ if (this.nextSibling())
2030
+ break;
2031
+ if (!depth)
2032
+ return;
2033
+ this.parent();
2034
+ depth--;
2035
+ mustLeave = true;
2036
+ }
2037
+ }
2038
+ }
2039
+ /// Test whether the current node matches a given context—a sequence
2040
+ /// of direct parent node names. Empty strings in the context array
2041
+ /// are treated as wildcards.
2042
+ matchContext(context) {
2043
+ if (!this.buffer)
2044
+ return matchNodeContext(this.node, context);
2045
+ let { buffer } = this.buffer, { types } = buffer.set;
2046
+ for (let i = context.length - 1, d = this.stack.length - 1; i >= 0; d--) {
2047
+ if (d < 0)
2048
+ return matchNodeContext(this.node, context, i);
2049
+ let type = types[buffer.buffer[this.stack[d]]];
2050
+ if (!type.isAnonymous) {
2051
+ if (context[i] && context[i] != type.name)
2052
+ return false;
2053
+ i--;
2054
+ }
2055
+ }
2056
+ return true;
2057
+ }
2058
+ };
2059
+ function hasChild(tree) {
2060
+ return tree.children.some((ch) => ch instanceof TreeBuffer || !ch.type.isAnonymous || hasChild(ch));
2061
+ }
2062
+ function buildTree(data) {
2063
+ var _a;
2064
+ let { buffer, nodeSet, maxBufferLength = DefaultBufferLength, reused = [], minRepeatType = nodeSet.types.length } = data;
2065
+ let cursor = Array.isArray(buffer) ? new FlatBufferCursor(buffer, buffer.length) : buffer;
2066
+ let types = nodeSet.types;
2067
+ let contextHash = 0, lookAhead = 0;
2068
+ function takeNode(parentStart, minPos, children2, positions2, inRepeat) {
2069
+ let { id, start, end, size } = cursor;
2070
+ let lookAheadAtStart = lookAhead;
2071
+ while (size < 0) {
2072
+ cursor.next();
2073
+ if (size == -1) {
2074
+ let node2 = reused[id];
2075
+ children2.push(node2);
2076
+ positions2.push(start - parentStart);
2077
+ return;
2078
+ } else if (size == -3) {
2079
+ contextHash = id;
2080
+ return;
2081
+ } else if (size == -4) {
2082
+ lookAhead = id;
2083
+ return;
2084
+ } else {
2085
+ throw new RangeError(`Unrecognized record size: ${size}`);
2086
+ }
2087
+ }
2088
+ let type = types[id], node, buffer2;
2089
+ let startPos = start - parentStart;
2090
+ if (end - start <= maxBufferLength && (buffer2 = findBufferSize(cursor.pos - minPos, inRepeat))) {
2091
+ let data2 = new Uint16Array(buffer2.size - buffer2.skip);
2092
+ let endPos = cursor.pos - buffer2.size, index = data2.length;
2093
+ while (cursor.pos > endPos)
2094
+ index = copyToBuffer(buffer2.start, data2, index);
2095
+ node = new TreeBuffer(data2, end - buffer2.start, nodeSet);
2096
+ startPos = buffer2.start - parentStart;
2097
+ } else {
2098
+ let endPos = cursor.pos - size;
2099
+ cursor.next();
2100
+ let localChildren = [], localPositions = [];
2101
+ let localInRepeat = id >= minRepeatType ? id : -1;
2102
+ let lastGroup = 0, lastEnd = end;
2103
+ while (cursor.pos > endPos) {
2104
+ if (localInRepeat >= 0 && cursor.id == localInRepeat && cursor.size >= 0) {
2105
+ if (cursor.end <= lastEnd - maxBufferLength) {
2106
+ makeRepeatLeaf(localChildren, localPositions, start, lastGroup, cursor.end, lastEnd, localInRepeat, lookAheadAtStart);
2107
+ lastGroup = localChildren.length;
2108
+ lastEnd = cursor.end;
2109
+ }
2110
+ cursor.next();
2111
+ } else {
2112
+ takeNode(start, endPos, localChildren, localPositions, localInRepeat);
2113
+ }
2114
+ }
2115
+ if (localInRepeat >= 0 && lastGroup > 0 && lastGroup < localChildren.length)
2116
+ makeRepeatLeaf(localChildren, localPositions, start, lastGroup, start, lastEnd, localInRepeat, lookAheadAtStart);
2117
+ localChildren.reverse();
2118
+ localPositions.reverse();
2119
+ if (localInRepeat > -1 && lastGroup > 0) {
2120
+ let make = makeBalanced(type);
2121
+ node = balanceRange(type, localChildren, localPositions, 0, localChildren.length, 0, end - start, make, make);
2122
+ } else {
2123
+ node = makeTree(type, localChildren, localPositions, end - start, lookAheadAtStart - end);
2124
+ }
2125
+ }
2126
+ children2.push(node);
2127
+ positions2.push(startPos);
2128
+ }
2129
+ function makeBalanced(type) {
2130
+ return (children2, positions2, length2) => {
2131
+ let lookAhead2 = 0, lastI = children2.length - 1, last, lookAheadProp;
2132
+ if (lastI >= 0 && (last = children2[lastI]) instanceof Tree) {
2133
+ if (!lastI && last.type == type && last.length == length2)
2134
+ return last;
2135
+ if (lookAheadProp = last.prop(NodeProp.lookAhead))
2136
+ lookAhead2 = positions2[lastI] + last.length + lookAheadProp;
2137
+ }
2138
+ return makeTree(type, children2, positions2, length2, lookAhead2);
2139
+ };
2140
+ }
2141
+ function makeRepeatLeaf(children2, positions2, base, i, from, to, type, lookAhead2) {
2142
+ let localChildren = [], localPositions = [];
2143
+ while (children2.length > i) {
2144
+ localChildren.push(children2.pop());
2145
+ localPositions.push(positions2.pop() + base - from);
2146
+ }
2147
+ children2.push(makeTree(nodeSet.types[type], localChildren, localPositions, to - from, lookAhead2 - to));
2148
+ positions2.push(from - base);
2149
+ }
2150
+ function makeTree(type, children2, positions2, length2, lookAhead2 = 0, props) {
2151
+ if (contextHash) {
2152
+ let pair2 = [NodeProp.contextHash, contextHash];
2153
+ props = props ? [pair2].concat(props) : [pair2];
2154
+ }
2155
+ if (lookAhead2 > 25) {
2156
+ let pair2 = [NodeProp.lookAhead, lookAhead2];
2157
+ props = props ? [pair2].concat(props) : [pair2];
2158
+ }
2159
+ return new Tree(type, children2, positions2, length2, props);
2160
+ }
2161
+ function findBufferSize(maxSize, inRepeat) {
2162
+ let fork = cursor.fork();
2163
+ let size = 0, start = 0, skip = 0, minStart = fork.end - maxBufferLength;
2164
+ let result = { size: 0, start: 0, skip: 0 };
2165
+ scan:
2166
+ for (let minPos = fork.pos - maxSize; fork.pos > minPos; ) {
2167
+ let nodeSize2 = fork.size;
2168
+ if (fork.id == inRepeat && nodeSize2 >= 0) {
2169
+ result.size = size;
2170
+ result.start = start;
2171
+ result.skip = skip;
2172
+ skip += 4;
2173
+ size += 4;
2174
+ fork.next();
2175
+ continue;
2176
+ }
2177
+ let startPos = fork.pos - nodeSize2;
2178
+ if (nodeSize2 < 0 || startPos < minPos || fork.start < minStart)
2179
+ break;
2180
+ let localSkipped = fork.id >= minRepeatType ? 4 : 0;
2181
+ let nodeStart = fork.start;
2182
+ fork.next();
2183
+ while (fork.pos > startPos) {
2184
+ if (fork.size < 0) {
2185
+ if (fork.size == -3)
2186
+ localSkipped += 4;
2187
+ else
2188
+ break scan;
2189
+ } else if (fork.id >= minRepeatType) {
2190
+ localSkipped += 4;
2191
+ }
2192
+ fork.next();
2193
+ }
2194
+ start = nodeStart;
2195
+ size += nodeSize2;
2196
+ skip += localSkipped;
2197
+ }
2198
+ if (inRepeat < 0 || size == maxSize) {
2199
+ result.size = size;
2200
+ result.start = start;
2201
+ result.skip = skip;
2202
+ }
2203
+ return result.size > 4 ? result : void 0;
2204
+ }
2205
+ function copyToBuffer(bufferStart, buffer2, index) {
2206
+ let { id, start, end, size } = cursor;
2207
+ cursor.next();
2208
+ if (size >= 0 && id < minRepeatType) {
2209
+ let startIndex = index;
2210
+ if (size > 4) {
2211
+ let endPos = cursor.pos - (size - 4);
2212
+ while (cursor.pos > endPos)
2213
+ index = copyToBuffer(bufferStart, buffer2, index);
2214
+ }
2215
+ buffer2[--index] = startIndex;
2216
+ buffer2[--index] = end - bufferStart;
2217
+ buffer2[--index] = start - bufferStart;
2218
+ buffer2[--index] = id;
2219
+ } else if (size == -3) {
2220
+ contextHash = id;
2221
+ } else if (size == -4) {
2222
+ lookAhead = id;
2223
+ }
2224
+ return index;
2225
+ }
2226
+ let children = [], positions = [];
2227
+ while (cursor.pos > 0)
2228
+ takeNode(data.start || 0, data.bufferStart || 0, children, positions, -1);
2229
+ let length = (_a = data.length) !== null && _a !== void 0 ? _a : children.length ? positions[0] + children[0].length : 0;
2230
+ return new Tree(types[data.topID], children.reverse(), positions.reverse(), length);
2231
+ }
2232
+ var nodeSizeCache = /* @__PURE__ */ new WeakMap();
2233
+ function nodeSize(balanceType, node) {
2234
+ if (!balanceType.isAnonymous || node instanceof TreeBuffer || node.type != balanceType)
2235
+ return 1;
2236
+ let size = nodeSizeCache.get(node);
2237
+ if (size == null) {
2238
+ size = 1;
2239
+ for (let child of node.children) {
2240
+ if (child.type != balanceType || !(child instanceof Tree)) {
2241
+ size = 1;
2242
+ break;
2243
+ }
2244
+ size += nodeSize(balanceType, child);
2245
+ }
2246
+ nodeSizeCache.set(node, size);
2247
+ }
2248
+ return size;
2249
+ }
2250
+ function balanceRange(balanceType, children, positions, from, to, start, length, mkTop, mkTree) {
2251
+ let total = 0;
2252
+ for (let i = from; i < to; i++)
2253
+ total += nodeSize(balanceType, children[i]);
2254
+ let maxChild = Math.ceil(
2255
+ total * 1.5 / 8
2256
+ /* Balance.BranchFactor */
2257
+ );
2258
+ let localChildren = [], localPositions = [];
2259
+ function divide(children2, positions2, from2, to2, offset) {
2260
+ for (let i = from2; i < to2; ) {
2261
+ let groupFrom = i, groupStart = positions2[i], groupSize = nodeSize(balanceType, children2[i]);
2262
+ i++;
2263
+ for (; i < to2; i++) {
2264
+ let nextSize = nodeSize(balanceType, children2[i]);
2265
+ if (groupSize + nextSize >= maxChild)
2266
+ break;
2267
+ groupSize += nextSize;
2268
+ }
2269
+ if (i == groupFrom + 1) {
2270
+ if (groupSize > maxChild) {
2271
+ let only = children2[groupFrom];
2272
+ divide(only.children, only.positions, 0, only.children.length, positions2[groupFrom] + offset);
2273
+ continue;
2274
+ }
2275
+ localChildren.push(children2[groupFrom]);
2276
+ } else {
2277
+ let length2 = positions2[i - 1] + children2[i - 1].length - groupStart;
2278
+ localChildren.push(balanceRange(balanceType, children2, positions2, groupFrom, i, groupStart, length2, null, mkTree));
2279
+ }
2280
+ localPositions.push(groupStart + offset - start);
2281
+ }
2282
+ }
2283
+ divide(children, positions, from, to, 0);
2284
+ return (mkTop || mkTree)(localChildren, localPositions, length);
2285
+ }
2286
+ var Parser = class {
2287
+ /// Start a parse, returning a [partial parse](#common.PartialParse)
2288
+ /// object. [`fragments`](#common.TreeFragment) can be passed in to
2289
+ /// make the parse incremental.
2290
+ ///
2291
+ /// By default, the entire input is parsed. You can pass `ranges`,
2292
+ /// which should be a sorted array of non-empty, non-overlapping
2293
+ /// ranges, to parse only those ranges. The tree returned in that
2294
+ /// case will start at `ranges[0].from`.
2295
+ startParse(input, fragments, ranges) {
2296
+ if (typeof input == "string")
2297
+ input = new StringInput(input);
2298
+ ranges = !ranges ? [new Range(0, input.length)] : ranges.length ? ranges.map((r) => new Range(r.from, r.to)) : [new Range(0, 0)];
2299
+ return this.createParse(input, fragments || [], ranges);
2300
+ }
2301
+ /// Run a full parse, returning the resulting tree.
2302
+ parse(input, fragments, ranges) {
2303
+ let parse = this.startParse(input, fragments, ranges);
2304
+ for (; ; ) {
2305
+ let done = parse.advance();
2306
+ if (done)
2307
+ return done;
2308
+ }
2309
+ }
2310
+ };
2311
+ var StringInput = class {
2312
+ constructor(string) {
2313
+ this.string = string;
2314
+ }
2315
+ get length() {
2316
+ return this.string.length;
2317
+ }
2318
+ chunk(from) {
2319
+ return this.string.slice(from);
2320
+ }
2321
+ get lineChunks() {
2322
+ return false;
2323
+ }
2324
+ read(from, to) {
2325
+ return this.string.slice(from, to);
2326
+ }
2327
+ };
2328
+ var stoppedInner = new NodeProp({ perNode: true });
2329
+
2330
+ // ../../node_modules/@lezer/lr/dist/index.js
2331
+ var Stack = class {
2332
+ /// @internal
2333
+ constructor(p, stack, state, reducePos, pos, score, buffer, bufferBase, curContext, lookAhead = 0, parent) {
2334
+ this.p = p;
2335
+ this.stack = stack;
2336
+ this.state = state;
2337
+ this.reducePos = reducePos;
2338
+ this.pos = pos;
2339
+ this.score = score;
2340
+ this.buffer = buffer;
2341
+ this.bufferBase = bufferBase;
2342
+ this.curContext = curContext;
2343
+ this.lookAhead = lookAhead;
2344
+ this.parent = parent;
2345
+ }
2346
+ /// @internal
2347
+ toString() {
2348
+ return `[${this.stack.filter((_, i) => i % 3 == 0).concat(this.state)}]@${this.pos}${this.score ? "!" + this.score : ""}`;
2349
+ }
2350
+ // Start an empty stack
2351
+ /// @internal
2352
+ static start(p, state, pos = 0) {
2353
+ let cx9 = p.parser.context;
2354
+ return new Stack(p, [], state, pos, pos, 0, [], 0, cx9 ? new StackContext(cx9, cx9.start) : null, 0, null);
2355
+ }
2356
+ /// The stack's current [context](#lr.ContextTracker) value, if
2357
+ /// any. Its type will depend on the context tracker's type
2358
+ /// parameter, or it will be `null` if there is no context
2359
+ /// tracker.
2360
+ get context() {
2361
+ return this.curContext ? this.curContext.context : null;
2362
+ }
2363
+ // Push a state onto the stack, tracking its start position as well
2364
+ // as the buffer base at that point.
2365
+ /// @internal
2366
+ pushState(state, start) {
2367
+ this.stack.push(this.state, start, this.bufferBase + this.buffer.length);
2368
+ this.state = state;
2369
+ }
2370
+ // Apply a reduce action
2371
+ /// @internal
2372
+ reduce(action) {
2373
+ var _a;
2374
+ let depth = action >> 19, type = action & 65535;
2375
+ let { parser: parser2 } = this.p;
2376
+ let dPrec = parser2.dynamicPrecedence(type);
2377
+ if (dPrec)
2378
+ this.score += dPrec;
2379
+ if (depth == 0) {
2380
+ this.pushState(parser2.getGoto(this.state, type, true), this.reducePos);
2381
+ if (type < parser2.minRepeatTerm)
2382
+ this.storeNode(type, this.reducePos, this.reducePos, 4, true);
2383
+ this.reduceContext(type, this.reducePos);
2384
+ return;
2385
+ }
2386
+ let base = this.stack.length - (depth - 1) * 3 - (action & 262144 ? 6 : 0);
2387
+ let start = base ? this.stack[base - 2] : this.p.ranges[0].from, size = this.reducePos - start;
2388
+ if (size >= 2e3 && !((_a = this.p.parser.nodeSet.types[type]) === null || _a === void 0 ? void 0 : _a.isAnonymous)) {
2389
+ if (start == this.p.lastBigReductionStart) {
2390
+ this.p.bigReductionCount++;
2391
+ this.p.lastBigReductionSize = size;
2392
+ } else if (this.p.lastBigReductionSize < size) {
2393
+ this.p.bigReductionCount = 1;
2394
+ this.p.lastBigReductionStart = start;
2395
+ this.p.lastBigReductionSize = size;
2396
+ }
2397
+ }
2398
+ let bufferBase = base ? this.stack[base - 1] : 0, count = this.bufferBase + this.buffer.length - bufferBase;
2399
+ if (type < parser2.minRepeatTerm || action & 131072) {
2400
+ let pos = parser2.stateFlag(
2401
+ this.state,
2402
+ 1
2403
+ /* StateFlag.Skipped */
2404
+ ) ? this.pos : this.reducePos;
2405
+ this.storeNode(type, start, pos, count + 4, true);
2406
+ }
2407
+ if (action & 262144) {
2408
+ this.state = this.stack[base];
2409
+ } else {
2410
+ let baseStateID = this.stack[base - 3];
2411
+ this.state = parser2.getGoto(baseStateID, type, true);
2412
+ }
2413
+ while (this.stack.length > base)
2414
+ this.stack.pop();
2415
+ this.reduceContext(type, start);
2416
+ }
2417
+ // Shift a value into the buffer
2418
+ /// @internal
2419
+ storeNode(term, start, end, size = 4, isReduce = false) {
2420
+ if (term == 0 && (!this.stack.length || this.stack[this.stack.length - 1] < this.buffer.length + this.bufferBase)) {
2421
+ let cur = this, top = this.buffer.length;
2422
+ if (top == 0 && cur.parent) {
2423
+ top = cur.bufferBase - cur.parent.bufferBase;
2424
+ cur = cur.parent;
2425
+ }
2426
+ if (top > 0 && cur.buffer[top - 4] == 0 && cur.buffer[top - 1] > -1) {
2427
+ if (start == end)
2428
+ return;
2429
+ if (cur.buffer[top - 2] >= start) {
2430
+ cur.buffer[top - 2] = end;
2431
+ return;
2432
+ }
2433
+ }
2434
+ }
2435
+ if (!isReduce || this.pos == end) {
2436
+ this.buffer.push(term, start, end, size);
2437
+ } else {
2438
+ let index = this.buffer.length;
2439
+ if (index > 0 && this.buffer[index - 4] != 0)
2440
+ while (index > 0 && this.buffer[index - 2] > end) {
2441
+ this.buffer[index] = this.buffer[index - 4];
2442
+ this.buffer[index + 1] = this.buffer[index - 3];
2443
+ this.buffer[index + 2] = this.buffer[index - 2];
2444
+ this.buffer[index + 3] = this.buffer[index - 1];
2445
+ index -= 4;
2446
+ if (size > 4)
2447
+ size -= 4;
2448
+ }
2449
+ this.buffer[index] = term;
2450
+ this.buffer[index + 1] = start;
2451
+ this.buffer[index + 2] = end;
2452
+ this.buffer[index + 3] = size;
2453
+ }
2454
+ }
2455
+ // Apply a shift action
2456
+ /// @internal
2457
+ shift(action, next, nextEnd) {
2458
+ let start = this.pos;
2459
+ if (action & 131072) {
2460
+ this.pushState(action & 65535, this.pos);
2461
+ } else if ((action & 262144) == 0) {
2462
+ let nextState = action, { parser: parser2 } = this.p;
2463
+ if (nextEnd > this.pos || next <= parser2.maxNode) {
2464
+ this.pos = nextEnd;
2465
+ if (!parser2.stateFlag(
2466
+ nextState,
2467
+ 1
2468
+ /* StateFlag.Skipped */
2469
+ ))
2470
+ this.reducePos = nextEnd;
2471
+ }
2472
+ this.pushState(nextState, start);
2473
+ this.shiftContext(next, start);
2474
+ if (next <= parser2.maxNode)
2475
+ this.buffer.push(next, start, nextEnd, 4);
2476
+ } else {
2477
+ this.pos = nextEnd;
2478
+ this.shiftContext(next, start);
2479
+ if (next <= this.p.parser.maxNode)
2480
+ this.buffer.push(next, start, nextEnd, 4);
2481
+ }
2482
+ }
2483
+ // Apply an action
2484
+ /// @internal
2485
+ apply(action, next, nextEnd) {
2486
+ if (action & 65536)
2487
+ this.reduce(action);
2488
+ else
2489
+ this.shift(action, next, nextEnd);
2490
+ }
2491
+ // Add a prebuilt (reused) node into the buffer.
2492
+ /// @internal
2493
+ useNode(value, next) {
2494
+ let index = this.p.reused.length - 1;
2495
+ if (index < 0 || this.p.reused[index] != value) {
2496
+ this.p.reused.push(value);
2497
+ index++;
2498
+ }
2499
+ let start = this.pos;
2500
+ this.reducePos = this.pos = start + value.length;
2501
+ this.pushState(next, start);
2502
+ this.buffer.push(
2503
+ index,
2504
+ start,
2505
+ this.reducePos,
2506
+ -1
2507
+ /* size == -1 means this is a reused value */
2508
+ );
2509
+ if (this.curContext)
2510
+ this.updateContext(this.curContext.tracker.reuse(this.curContext.context, value, this, this.p.stream.reset(this.pos - value.length)));
2511
+ }
2512
+ // Split the stack. Due to the buffer sharing and the fact
2513
+ // that `this.stack` tends to stay quite shallow, this isn't very
2514
+ // expensive.
2515
+ /// @internal
2516
+ split() {
2517
+ let parent = this;
2518
+ let off = parent.buffer.length;
2519
+ while (off > 0 && parent.buffer[off - 2] > parent.reducePos)
2520
+ off -= 4;
2521
+ let buffer = parent.buffer.slice(off), base = parent.bufferBase + off;
2522
+ while (parent && base == parent.bufferBase)
2523
+ parent = parent.parent;
2524
+ return new Stack(this.p, this.stack.slice(), this.state, this.reducePos, this.pos, this.score, buffer, base, this.curContext, this.lookAhead, parent);
2525
+ }
2526
+ // Try to recover from an error by 'deleting' (ignoring) one token.
2527
+ /// @internal
2528
+ recoverByDelete(next, nextEnd) {
2529
+ let isNode = next <= this.p.parser.maxNode;
2530
+ if (isNode)
2531
+ this.storeNode(next, this.pos, nextEnd, 4);
2532
+ this.storeNode(0, this.pos, nextEnd, isNode ? 8 : 4);
2533
+ this.pos = this.reducePos = nextEnd;
2534
+ this.score -= 190;
2535
+ }
2536
+ /// Check if the given term would be able to be shifted (optionally
2537
+ /// after some reductions) on this stack. This can be useful for
2538
+ /// external tokenizers that want to make sure they only provide a
2539
+ /// given token when it applies.
2540
+ canShift(term) {
2541
+ for (let sim = new SimulatedStack(this); ; ) {
2542
+ let action = this.p.parser.stateSlot(
2543
+ sim.state,
2544
+ 4
2545
+ /* ParseState.DefaultReduce */
2546
+ ) || this.p.parser.hasAction(sim.state, term);
2547
+ if (action == 0)
2548
+ return false;
2549
+ if ((action & 65536) == 0)
2550
+ return true;
2551
+ sim.reduce(action);
2552
+ }
2553
+ }
2554
+ // Apply up to Recover.MaxNext recovery actions that conceptually
2555
+ // inserts some missing token or rule.
2556
+ /// @internal
2557
+ recoverByInsert(next) {
2558
+ if (this.stack.length >= 300)
2559
+ return [];
2560
+ let nextStates = this.p.parser.nextStates(this.state);
2561
+ if (nextStates.length > 4 << 1 || this.stack.length >= 120) {
2562
+ let best = [];
2563
+ for (let i = 0, s; i < nextStates.length; i += 2) {
2564
+ if ((s = nextStates[i + 1]) != this.state && this.p.parser.hasAction(s, next))
2565
+ best.push(nextStates[i], s);
2566
+ }
2567
+ if (this.stack.length < 120)
2568
+ for (let i = 0; best.length < 4 << 1 && i < nextStates.length; i += 2) {
2569
+ let s = nextStates[i + 1];
2570
+ if (!best.some((v, i2) => i2 & 1 && v == s))
2571
+ best.push(nextStates[i], s);
2572
+ }
2573
+ nextStates = best;
2574
+ }
2575
+ let result = [];
2576
+ for (let i = 0; i < nextStates.length && result.length < 4; i += 2) {
2577
+ let s = nextStates[i + 1];
2578
+ if (s == this.state)
2579
+ continue;
2580
+ let stack = this.split();
2581
+ stack.pushState(s, this.pos);
2582
+ stack.storeNode(0, stack.pos, stack.pos, 4, true);
2583
+ stack.shiftContext(nextStates[i], this.pos);
2584
+ stack.score -= 200;
2585
+ result.push(stack);
2586
+ }
2587
+ return result;
2588
+ }
2589
+ // Force a reduce, if possible. Return false if that can't
2590
+ // be done.
2591
+ /// @internal
2592
+ forceReduce() {
2593
+ let reduce = this.p.parser.stateSlot(
2594
+ this.state,
2595
+ 5
2596
+ /* ParseState.ForcedReduce */
2597
+ );
2598
+ if ((reduce & 65536) == 0)
2599
+ return false;
2600
+ let { parser: parser2 } = this.p;
2601
+ if (!parser2.validAction(this.state, reduce)) {
2602
+ let depth = reduce >> 19, term = reduce & 65535;
2603
+ let target = this.stack.length - depth * 3;
2604
+ if (target < 0 || parser2.getGoto(this.stack[target], term, false) < 0)
2605
+ return false;
2606
+ this.storeNode(0, this.reducePos, this.reducePos, 4, true);
2607
+ this.score -= 100;
2608
+ }
2609
+ this.reducePos = this.pos;
2610
+ this.reduce(reduce);
2611
+ return true;
2612
+ }
2613
+ /// @internal
2614
+ forceAll() {
2615
+ while (!this.p.parser.stateFlag(
2616
+ this.state,
2617
+ 2
2618
+ /* StateFlag.Accepting */
2619
+ )) {
2620
+ if (!this.forceReduce()) {
2621
+ this.storeNode(0, this.pos, this.pos, 4, true);
2622
+ break;
2623
+ }
2624
+ }
2625
+ return this;
2626
+ }
2627
+ /// Check whether this state has no further actions (assumed to be a direct descendant of the
2628
+ /// top state, since any other states must be able to continue
2629
+ /// somehow). @internal
2630
+ get deadEnd() {
2631
+ if (this.stack.length != 3)
2632
+ return false;
2633
+ let { parser: parser2 } = this.p;
2634
+ return parser2.data[parser2.stateSlot(
2635
+ this.state,
2636
+ 1
2637
+ /* ParseState.Actions */
2638
+ )] == 65535 && !parser2.stateSlot(
2639
+ this.state,
2640
+ 4
2641
+ /* ParseState.DefaultReduce */
2642
+ );
2643
+ }
2644
+ /// Restart the stack (put it back in its start state). Only safe
2645
+ /// when this.stack.length == 3 (state is directly below the top
2646
+ /// state). @internal
2647
+ restart() {
2648
+ this.state = this.stack[0];
2649
+ this.stack.length = 0;
2650
+ }
2651
+ /// @internal
2652
+ sameState(other) {
2653
+ if (this.state != other.state || this.stack.length != other.stack.length)
2654
+ return false;
2655
+ for (let i = 0; i < this.stack.length; i += 3)
2656
+ if (this.stack[i] != other.stack[i])
2657
+ return false;
2658
+ return true;
2659
+ }
2660
+ /// Get the parser used by this stack.
2661
+ get parser() {
2662
+ return this.p.parser;
2663
+ }
2664
+ /// Test whether a given dialect (by numeric ID, as exported from
2665
+ /// the terms file) is enabled.
2666
+ dialectEnabled(dialectID) {
2667
+ return this.p.parser.dialect.flags[dialectID];
2668
+ }
2669
+ shiftContext(term, start) {
2670
+ if (this.curContext)
2671
+ this.updateContext(this.curContext.tracker.shift(this.curContext.context, term, this, this.p.stream.reset(start)));
2672
+ }
2673
+ reduceContext(term, start) {
2674
+ if (this.curContext)
2675
+ this.updateContext(this.curContext.tracker.reduce(this.curContext.context, term, this, this.p.stream.reset(start)));
2676
+ }
2677
+ /// @internal
2678
+ emitContext() {
2679
+ let last = this.buffer.length - 1;
2680
+ if (last < 0 || this.buffer[last] != -3)
2681
+ this.buffer.push(this.curContext.hash, this.reducePos, this.reducePos, -3);
2682
+ }
2683
+ /// @internal
2684
+ emitLookAhead() {
2685
+ let last = this.buffer.length - 1;
2686
+ if (last < 0 || this.buffer[last] != -4)
2687
+ this.buffer.push(this.lookAhead, this.reducePos, this.reducePos, -4);
2688
+ }
2689
+ updateContext(context) {
2690
+ if (context != this.curContext.context) {
2691
+ let newCx = new StackContext(this.curContext.tracker, context);
2692
+ if (newCx.hash != this.curContext.hash)
2693
+ this.emitContext();
2694
+ this.curContext = newCx;
2695
+ }
2696
+ }
2697
+ /// @internal
2698
+ setLookAhead(lookAhead) {
2699
+ if (lookAhead > this.lookAhead) {
2700
+ this.emitLookAhead();
2701
+ this.lookAhead = lookAhead;
2702
+ }
2703
+ }
2704
+ /// @internal
2705
+ close() {
2706
+ if (this.curContext && this.curContext.tracker.strict)
2707
+ this.emitContext();
2708
+ if (this.lookAhead > 0)
2709
+ this.emitLookAhead();
2710
+ }
2711
+ };
2712
+ var StackContext = class {
2713
+ constructor(tracker, context) {
2714
+ this.tracker = tracker;
2715
+ this.context = context;
2716
+ this.hash = tracker.strict ? tracker.hash(context) : 0;
2717
+ }
2718
+ };
2719
+ var Recover;
2720
+ (function(Recover2) {
2721
+ Recover2[Recover2["Insert"] = 200] = "Insert";
2722
+ Recover2[Recover2["Delete"] = 190] = "Delete";
2723
+ Recover2[Recover2["Reduce"] = 100] = "Reduce";
2724
+ Recover2[Recover2["MaxNext"] = 4] = "MaxNext";
2725
+ Recover2[Recover2["MaxInsertStackDepth"] = 300] = "MaxInsertStackDepth";
2726
+ Recover2[Recover2["DampenInsertStackDepth"] = 120] = "DampenInsertStackDepth";
2727
+ Recover2[Recover2["MinBigReduction"] = 2e3] = "MinBigReduction";
2728
+ })(Recover || (Recover = {}));
2729
+ var SimulatedStack = class {
2730
+ constructor(start) {
2731
+ this.start = start;
2732
+ this.state = start.state;
2733
+ this.stack = start.stack;
2734
+ this.base = this.stack.length;
2735
+ }
2736
+ reduce(action) {
2737
+ let term = action & 65535, depth = action >> 19;
2738
+ if (depth == 0) {
2739
+ if (this.stack == this.start.stack)
2740
+ this.stack = this.stack.slice();
2741
+ this.stack.push(this.state, 0, 0);
2742
+ this.base += 3;
2743
+ } else {
2744
+ this.base -= (depth - 1) * 3;
2745
+ }
2746
+ let goto = this.start.p.parser.getGoto(this.stack[this.base - 3], term, true);
2747
+ this.state = goto;
2748
+ }
2749
+ };
2750
+ var StackBufferCursor = class {
2751
+ constructor(stack, pos, index) {
2752
+ this.stack = stack;
2753
+ this.pos = pos;
2754
+ this.index = index;
2755
+ this.buffer = stack.buffer;
2756
+ if (this.index == 0)
2757
+ this.maybeNext();
2758
+ }
2759
+ static create(stack, pos = stack.bufferBase + stack.buffer.length) {
2760
+ return new StackBufferCursor(stack, pos, pos - stack.bufferBase);
2761
+ }
2762
+ maybeNext() {
2763
+ let next = this.stack.parent;
2764
+ if (next != null) {
2765
+ this.index = this.stack.bufferBase - next.bufferBase;
2766
+ this.stack = next;
2767
+ this.buffer = next.buffer;
2768
+ }
2769
+ }
2770
+ get id() {
2771
+ return this.buffer[this.index - 4];
2772
+ }
2773
+ get start() {
2774
+ return this.buffer[this.index - 3];
2775
+ }
2776
+ get end() {
2777
+ return this.buffer[this.index - 2];
2778
+ }
2779
+ get size() {
2780
+ return this.buffer[this.index - 1];
2781
+ }
2782
+ next() {
2783
+ this.index -= 4;
2784
+ this.pos -= 4;
2785
+ if (this.index == 0)
2786
+ this.maybeNext();
2787
+ }
2788
+ fork() {
2789
+ return new StackBufferCursor(this.stack, this.pos, this.index);
2790
+ }
2791
+ };
2792
+ function decodeArray(input, Type = Uint16Array) {
2793
+ if (typeof input != "string")
2794
+ return input;
2795
+ let array = null;
2796
+ for (let pos = 0, out = 0; pos < input.length; ) {
2797
+ let value = 0;
2798
+ for (; ; ) {
2799
+ let next = input.charCodeAt(pos++), stop = false;
2800
+ if (next == 126) {
2801
+ value = 65535;
2802
+ break;
2803
+ }
2804
+ if (next >= 92)
2805
+ next--;
2806
+ if (next >= 34)
2807
+ next--;
2808
+ let digit = next - 32;
2809
+ if (digit >= 46) {
2810
+ digit -= 46;
2811
+ stop = true;
2812
+ }
2813
+ value += digit;
2814
+ if (stop)
2815
+ break;
2816
+ value *= 46;
2817
+ }
2818
+ if (array)
2819
+ array[out++] = value;
2820
+ else
2821
+ array = new Type(value);
2822
+ }
2823
+ return array;
2824
+ }
2825
+ var CachedToken = class {
2826
+ constructor() {
2827
+ this.start = -1;
2828
+ this.value = -1;
2829
+ this.end = -1;
2830
+ this.extended = -1;
2831
+ this.lookAhead = 0;
2832
+ this.mask = 0;
2833
+ this.context = 0;
2834
+ }
2835
+ };
2836
+ var nullToken = new CachedToken();
2837
+ var InputStream = class {
2838
+ /// @internal
2839
+ constructor(input, ranges) {
2840
+ this.input = input;
2841
+ this.ranges = ranges;
2842
+ this.chunk = "";
2843
+ this.chunkOff = 0;
2844
+ this.chunk2 = "";
2845
+ this.chunk2Pos = 0;
2846
+ this.next = -1;
2847
+ this.token = nullToken;
2848
+ this.rangeIndex = 0;
2849
+ this.pos = this.chunkPos = ranges[0].from;
2850
+ this.range = ranges[0];
2851
+ this.end = ranges[ranges.length - 1].to;
2852
+ this.readNext();
2853
+ }
2854
+ /// @internal
2855
+ resolveOffset(offset, assoc) {
2856
+ let range = this.range, index = this.rangeIndex;
2857
+ let pos = this.pos + offset;
2858
+ while (pos < range.from) {
2859
+ if (!index)
2860
+ return null;
2861
+ let next = this.ranges[--index];
2862
+ pos -= range.from - next.to;
2863
+ range = next;
2864
+ }
2865
+ while (assoc < 0 ? pos > range.to : pos >= range.to) {
2866
+ if (index == this.ranges.length - 1)
2867
+ return null;
2868
+ let next = this.ranges[++index];
2869
+ pos += next.from - range.to;
2870
+ range = next;
2871
+ }
2872
+ return pos;
2873
+ }
2874
+ /// @internal
2875
+ clipPos(pos) {
2876
+ if (pos >= this.range.from && pos < this.range.to)
2877
+ return pos;
2878
+ for (let range of this.ranges)
2879
+ if (range.to > pos)
2880
+ return Math.max(pos, range.from);
2881
+ return this.end;
2882
+ }
2883
+ /// Look at a code unit near the stream position. `.peek(0)` equals
2884
+ /// `.next`, `.peek(-1)` gives you the previous character, and so
2885
+ /// on.
2886
+ ///
2887
+ /// Note that looking around during tokenizing creates dependencies
2888
+ /// on potentially far-away content, which may reduce the
2889
+ /// effectiveness incremental parsing—when looking forward—or even
2890
+ /// cause invalid reparses when looking backward more than 25 code
2891
+ /// units, since the library does not track lookbehind.
2892
+ peek(offset) {
2893
+ let idx = this.chunkOff + offset, pos, result;
2894
+ if (idx >= 0 && idx < this.chunk.length) {
2895
+ pos = this.pos + offset;
2896
+ result = this.chunk.charCodeAt(idx);
2897
+ } else {
2898
+ let resolved = this.resolveOffset(offset, 1);
2899
+ if (resolved == null)
2900
+ return -1;
2901
+ pos = resolved;
2902
+ if (pos >= this.chunk2Pos && pos < this.chunk2Pos + this.chunk2.length) {
2903
+ result = this.chunk2.charCodeAt(pos - this.chunk2Pos);
2904
+ } else {
2905
+ let i = this.rangeIndex, range = this.range;
2906
+ while (range.to <= pos)
2907
+ range = this.ranges[++i];
2908
+ this.chunk2 = this.input.chunk(this.chunk2Pos = pos);
2909
+ if (pos + this.chunk2.length > range.to)
2910
+ this.chunk2 = this.chunk2.slice(0, range.to - pos);
2911
+ result = this.chunk2.charCodeAt(0);
2912
+ }
2913
+ }
2914
+ if (pos >= this.token.lookAhead)
2915
+ this.token.lookAhead = pos + 1;
2916
+ return result;
2917
+ }
2918
+ /// Accept a token. By default, the end of the token is set to the
2919
+ /// current stream position, but you can pass an offset (relative to
2920
+ /// the stream position) to change that.
2921
+ acceptToken(token, endOffset = 0) {
2922
+ let end = endOffset ? this.resolveOffset(endOffset, -1) : this.pos;
2923
+ if (end == null || end < this.token.start)
2924
+ throw new RangeError("Token end out of bounds");
2925
+ this.token.value = token;
2926
+ this.token.end = end;
2927
+ }
2928
+ getChunk() {
2929
+ if (this.pos >= this.chunk2Pos && this.pos < this.chunk2Pos + this.chunk2.length) {
2930
+ let { chunk, chunkPos } = this;
2931
+ this.chunk = this.chunk2;
2932
+ this.chunkPos = this.chunk2Pos;
2933
+ this.chunk2 = chunk;
2934
+ this.chunk2Pos = chunkPos;
2935
+ this.chunkOff = this.pos - this.chunkPos;
2936
+ } else {
2937
+ this.chunk2 = this.chunk;
2938
+ this.chunk2Pos = this.chunkPos;
2939
+ let nextChunk = this.input.chunk(this.pos);
2940
+ let end = this.pos + nextChunk.length;
2941
+ this.chunk = end > this.range.to ? nextChunk.slice(0, this.range.to - this.pos) : nextChunk;
2942
+ this.chunkPos = this.pos;
2943
+ this.chunkOff = 0;
2944
+ }
2945
+ }
2946
+ readNext() {
2947
+ if (this.chunkOff >= this.chunk.length) {
2948
+ this.getChunk();
2949
+ if (this.chunkOff == this.chunk.length)
2950
+ return this.next = -1;
2951
+ }
2952
+ return this.next = this.chunk.charCodeAt(this.chunkOff);
2953
+ }
2954
+ /// Move the stream forward N (defaults to 1) code units. Returns
2955
+ /// the new value of [`next`](#lr.InputStream.next).
2956
+ advance(n = 1) {
2957
+ this.chunkOff += n;
2958
+ while (this.pos + n >= this.range.to) {
2959
+ if (this.rangeIndex == this.ranges.length - 1)
2960
+ return this.setDone();
2961
+ n -= this.range.to - this.pos;
2962
+ this.range = this.ranges[++this.rangeIndex];
2963
+ this.pos = this.range.from;
2964
+ }
2965
+ this.pos += n;
2966
+ if (this.pos >= this.token.lookAhead)
2967
+ this.token.lookAhead = this.pos + 1;
2968
+ return this.readNext();
2969
+ }
2970
+ setDone() {
2971
+ this.pos = this.chunkPos = this.end;
2972
+ this.range = this.ranges[this.rangeIndex = this.ranges.length - 1];
2973
+ this.chunk = "";
2974
+ return this.next = -1;
2975
+ }
2976
+ /// @internal
2977
+ reset(pos, token) {
2978
+ if (token) {
2979
+ this.token = token;
2980
+ token.start = pos;
2981
+ token.lookAhead = pos + 1;
2982
+ token.value = token.extended = -1;
2983
+ } else {
2984
+ this.token = nullToken;
2985
+ }
2986
+ if (this.pos != pos) {
2987
+ this.pos = pos;
2988
+ if (pos == this.end) {
2989
+ this.setDone();
2990
+ return this;
2991
+ }
2992
+ while (pos < this.range.from)
2993
+ this.range = this.ranges[--this.rangeIndex];
2994
+ while (pos >= this.range.to)
2995
+ this.range = this.ranges[++this.rangeIndex];
2996
+ if (pos >= this.chunkPos && pos < this.chunkPos + this.chunk.length) {
2997
+ this.chunkOff = pos - this.chunkPos;
2998
+ } else {
2999
+ this.chunk = "";
3000
+ this.chunkOff = 0;
3001
+ }
3002
+ this.readNext();
3003
+ }
3004
+ return this;
3005
+ }
3006
+ /// @internal
3007
+ read(from, to) {
3008
+ if (from >= this.chunkPos && to <= this.chunkPos + this.chunk.length)
3009
+ return this.chunk.slice(from - this.chunkPos, to - this.chunkPos);
3010
+ if (from >= this.chunk2Pos && to <= this.chunk2Pos + this.chunk2.length)
3011
+ return this.chunk2.slice(from - this.chunk2Pos, to - this.chunk2Pos);
3012
+ if (from >= this.range.from && to <= this.range.to)
3013
+ return this.input.read(from, to);
3014
+ let result = "";
3015
+ for (let r of this.ranges) {
3016
+ if (r.from >= to)
3017
+ break;
3018
+ if (r.to > from)
3019
+ result += this.input.read(Math.max(r.from, from), Math.min(r.to, to));
3020
+ }
3021
+ return result;
3022
+ }
3023
+ };
3024
+ var TokenGroup = class {
3025
+ constructor(data, id) {
3026
+ this.data = data;
3027
+ this.id = id;
3028
+ }
3029
+ token(input, stack) {
3030
+ let { parser: parser2 } = stack.p;
3031
+ readToken(this.data, input, stack, this.id, parser2.data, parser2.tokenPrecTable);
3032
+ }
3033
+ };
3034
+ TokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
3035
+ var LocalTokenGroup = class {
3036
+ constructor(data, precTable, elseToken) {
3037
+ this.precTable = precTable;
3038
+ this.elseToken = elseToken;
3039
+ this.data = typeof data == "string" ? decodeArray(data) : data;
3040
+ }
3041
+ token(input, stack) {
3042
+ let start = input.pos, skipped = 0;
3043
+ for (; ; ) {
3044
+ readToken(this.data, input, stack, 0, this.data, this.precTable);
3045
+ if (input.token.value > -1)
3046
+ break;
3047
+ if (this.elseToken == null)
3048
+ return;
3049
+ if (input.next < 0)
3050
+ break;
3051
+ input.advance();
3052
+ input.reset(input.pos, input.token);
3053
+ skipped++;
3054
+ }
3055
+ if (skipped) {
3056
+ input.reset(start, input.token);
3057
+ input.acceptToken(this.elseToken, skipped);
3058
+ }
3059
+ }
3060
+ };
3061
+ LocalTokenGroup.prototype.contextual = TokenGroup.prototype.fallback = TokenGroup.prototype.extend = false;
3062
+ function readToken(data, input, stack, group, precTable, precOffset) {
3063
+ let state = 0, groupMask = 1 << group, { dialect } = stack.p.parser;
3064
+ scan:
3065
+ for (; ; ) {
3066
+ if ((groupMask & data[state]) == 0)
3067
+ break;
3068
+ let accEnd = data[state + 1];
3069
+ for (let i = state + 3; i < accEnd; i += 2)
3070
+ if ((data[i + 1] & groupMask) > 0) {
3071
+ let term = data[i];
3072
+ if (dialect.allows(term) && (input.token.value == -1 || input.token.value == term || overrides(term, input.token.value, precTable, precOffset))) {
3073
+ input.acceptToken(term);
3074
+ break;
3075
+ }
3076
+ }
3077
+ let next = input.next, low = 0, high = data[state + 2];
3078
+ if (input.next < 0 && high > low && data[accEnd + high * 3 - 3] == 65535 && data[accEnd + high * 3 - 3] == 65535) {
3079
+ state = data[accEnd + high * 3 - 1];
3080
+ continue scan;
3081
+ }
3082
+ for (; low < high; ) {
3083
+ let mid = low + high >> 1;
3084
+ let index = accEnd + mid + (mid << 1);
3085
+ let from = data[index], to = data[index + 1] || 65536;
3086
+ if (next < from)
3087
+ high = mid;
3088
+ else if (next >= to)
3089
+ low = mid + 1;
3090
+ else {
3091
+ state = data[index + 2];
3092
+ input.advance();
3093
+ continue scan;
3094
+ }
3095
+ }
3096
+ break;
3097
+ }
3098
+ }
3099
+ function findOffset(data, start, term) {
3100
+ for (let i = start, next; (next = data[i]) != 65535; i++)
3101
+ if (next == term)
3102
+ return i - start;
3103
+ return -1;
3104
+ }
3105
+ function overrides(token, prev, tableData, tableOffset) {
3106
+ let iPrev = findOffset(tableData, tableOffset, prev);
3107
+ return iPrev < 0 || findOffset(tableData, tableOffset, token) < iPrev;
3108
+ }
3109
+ var verbose = typeof process != "undefined" && process.env && /\bparse\b/.test(process.env.LOG);
3110
+ var stackIDs = null;
3111
+ var Safety;
3112
+ (function(Safety2) {
3113
+ Safety2[Safety2["Margin"] = 25] = "Margin";
3114
+ })(Safety || (Safety = {}));
3115
+ function cutAt(tree, pos, side) {
3116
+ let cursor = tree.cursor(IterMode.IncludeAnonymous);
3117
+ cursor.moveTo(pos);
3118
+ for (; ; ) {
3119
+ if (!(side < 0 ? cursor.childBefore(pos) : cursor.childAfter(pos)))
3120
+ for (; ; ) {
3121
+ if ((side < 0 ? cursor.to < pos : cursor.from > pos) && !cursor.type.isError)
3122
+ return side < 0 ? Math.max(0, Math.min(
3123
+ cursor.to - 1,
3124
+ pos - 25
3125
+ /* Safety.Margin */
3126
+ )) : Math.min(tree.length, Math.max(
3127
+ cursor.from + 1,
3128
+ pos + 25
3129
+ /* Safety.Margin */
3130
+ ));
3131
+ if (side < 0 ? cursor.prevSibling() : cursor.nextSibling())
3132
+ break;
3133
+ if (!cursor.parent())
3134
+ return side < 0 ? 0 : tree.length;
3135
+ }
3136
+ }
3137
+ }
3138
+ var FragmentCursor = class {
3139
+ constructor(fragments, nodeSet) {
3140
+ this.fragments = fragments;
3141
+ this.nodeSet = nodeSet;
3142
+ this.i = 0;
3143
+ this.fragment = null;
3144
+ this.safeFrom = -1;
3145
+ this.safeTo = -1;
3146
+ this.trees = [];
3147
+ this.start = [];
3148
+ this.index = [];
3149
+ this.nextFragment();
3150
+ }
3151
+ nextFragment() {
3152
+ let fr = this.fragment = this.i == this.fragments.length ? null : this.fragments[this.i++];
3153
+ if (fr) {
3154
+ this.safeFrom = fr.openStart ? cutAt(fr.tree, fr.from + fr.offset, 1) - fr.offset : fr.from;
3155
+ this.safeTo = fr.openEnd ? cutAt(fr.tree, fr.to + fr.offset, -1) - fr.offset : fr.to;
3156
+ while (this.trees.length) {
3157
+ this.trees.pop();
3158
+ this.start.pop();
3159
+ this.index.pop();
3160
+ }
3161
+ this.trees.push(fr.tree);
3162
+ this.start.push(-fr.offset);
3163
+ this.index.push(0);
3164
+ this.nextStart = this.safeFrom;
3165
+ } else {
3166
+ this.nextStart = 1e9;
3167
+ }
3168
+ }
3169
+ // `pos` must be >= any previously given `pos` for this cursor
3170
+ nodeAt(pos) {
3171
+ if (pos < this.nextStart)
3172
+ return null;
3173
+ while (this.fragment && this.safeTo <= pos)
3174
+ this.nextFragment();
3175
+ if (!this.fragment)
3176
+ return null;
3177
+ for (; ; ) {
3178
+ let last = this.trees.length - 1;
3179
+ if (last < 0) {
3180
+ this.nextFragment();
3181
+ return null;
3182
+ }
3183
+ let top = this.trees[last], index = this.index[last];
3184
+ if (index == top.children.length) {
3185
+ this.trees.pop();
3186
+ this.start.pop();
3187
+ this.index.pop();
3188
+ continue;
3189
+ }
3190
+ let next = top.children[index];
3191
+ let start = this.start[last] + top.positions[index];
3192
+ if (start > pos) {
3193
+ this.nextStart = start;
3194
+ return null;
3195
+ }
3196
+ if (next instanceof Tree) {
3197
+ if (start == pos) {
3198
+ if (start < this.safeFrom)
3199
+ return null;
3200
+ let end = start + next.length;
3201
+ if (end <= this.safeTo) {
3202
+ let lookAhead = next.prop(NodeProp.lookAhead);
3203
+ if (!lookAhead || end + lookAhead < this.fragment.to)
3204
+ return next;
3205
+ }
3206
+ }
3207
+ this.index[last]++;
3208
+ if (start + next.length >= Math.max(this.safeFrom, pos)) {
3209
+ this.trees.push(next);
3210
+ this.start.push(start);
3211
+ this.index.push(0);
3212
+ }
3213
+ } else {
3214
+ this.index[last]++;
3215
+ this.nextStart = start + next.length;
3216
+ }
3217
+ }
3218
+ }
3219
+ };
3220
+ var TokenCache = class {
3221
+ constructor(parser2, stream) {
3222
+ this.stream = stream;
3223
+ this.tokens = [];
3224
+ this.mainToken = null;
3225
+ this.actions = [];
3226
+ this.tokens = parser2.tokenizers.map((_) => new CachedToken());
3227
+ }
3228
+ getActions(stack) {
3229
+ let actionIndex = 0;
3230
+ let main = null;
3231
+ let { parser: parser2 } = stack.p, { tokenizers } = parser2;
3232
+ let mask = parser2.stateSlot(
3233
+ stack.state,
3234
+ 3
3235
+ /* ParseState.TokenizerMask */
3236
+ );
3237
+ let context = stack.curContext ? stack.curContext.hash : 0;
3238
+ let lookAhead = 0;
3239
+ for (let i = 0; i < tokenizers.length; i++) {
3240
+ if ((1 << i & mask) == 0)
3241
+ continue;
3242
+ let tokenizer = tokenizers[i], token = this.tokens[i];
3243
+ if (main && !tokenizer.fallback)
3244
+ continue;
3245
+ if (tokenizer.contextual || token.start != stack.pos || token.mask != mask || token.context != context) {
3246
+ this.updateCachedToken(token, tokenizer, stack);
3247
+ token.mask = mask;
3248
+ token.context = context;
3249
+ }
3250
+ if (token.lookAhead > token.end + 25)
3251
+ lookAhead = Math.max(token.lookAhead, lookAhead);
3252
+ if (token.value != 0) {
3253
+ let startIndex = actionIndex;
3254
+ if (token.extended > -1)
3255
+ actionIndex = this.addActions(stack, token.extended, token.end, actionIndex);
3256
+ actionIndex = this.addActions(stack, token.value, token.end, actionIndex);
3257
+ if (!tokenizer.extend) {
3258
+ main = token;
3259
+ if (actionIndex > startIndex)
3260
+ break;
3261
+ }
3262
+ }
3263
+ }
3264
+ while (this.actions.length > actionIndex)
3265
+ this.actions.pop();
3266
+ if (lookAhead)
3267
+ stack.setLookAhead(lookAhead);
3268
+ if (!main && stack.pos == this.stream.end) {
3269
+ main = new CachedToken();
3270
+ main.value = stack.p.parser.eofTerm;
3271
+ main.start = main.end = stack.pos;
3272
+ actionIndex = this.addActions(stack, main.value, main.end, actionIndex);
3273
+ }
3274
+ this.mainToken = main;
3275
+ return this.actions;
3276
+ }
3277
+ getMainToken(stack) {
3278
+ if (this.mainToken)
3279
+ return this.mainToken;
3280
+ let main = new CachedToken(), { pos, p } = stack;
3281
+ main.start = pos;
3282
+ main.end = Math.min(pos + 1, p.stream.end);
3283
+ main.value = pos == p.stream.end ? p.parser.eofTerm : 0;
3284
+ return main;
3285
+ }
3286
+ updateCachedToken(token, tokenizer, stack) {
3287
+ let start = this.stream.clipPos(stack.pos);
3288
+ tokenizer.token(this.stream.reset(start, token), stack);
3289
+ if (token.value > -1) {
3290
+ let { parser: parser2 } = stack.p;
3291
+ for (let i = 0; i < parser2.specialized.length; i++)
3292
+ if (parser2.specialized[i] == token.value) {
3293
+ let result = parser2.specializers[i](this.stream.read(token.start, token.end), stack);
3294
+ if (result >= 0 && stack.p.parser.dialect.allows(result >> 1)) {
3295
+ if ((result & 1) == 0)
3296
+ token.value = result >> 1;
3297
+ else
3298
+ token.extended = result >> 1;
3299
+ break;
3300
+ }
3301
+ }
3302
+ } else {
3303
+ token.value = 0;
3304
+ token.end = this.stream.clipPos(start + 1);
3305
+ }
3306
+ }
3307
+ putAction(action, token, end, index) {
3308
+ for (let i = 0; i < index; i += 3)
3309
+ if (this.actions[i] == action)
3310
+ return index;
3311
+ this.actions[index++] = action;
3312
+ this.actions[index++] = token;
3313
+ this.actions[index++] = end;
3314
+ return index;
3315
+ }
3316
+ addActions(stack, token, end, index) {
3317
+ let { state } = stack, { parser: parser2 } = stack.p, { data } = parser2;
3318
+ for (let set = 0; set < 2; set++) {
3319
+ for (let i = parser2.stateSlot(
3320
+ state,
3321
+ set ? 2 : 1
3322
+ /* ParseState.Actions */
3323
+ ); ; i += 3) {
3324
+ if (data[i] == 65535) {
3325
+ if (data[i + 1] == 1) {
3326
+ i = pair(data, i + 2);
3327
+ } else {
3328
+ if (index == 0 && data[i + 1] == 2)
3329
+ index = this.putAction(pair(data, i + 2), token, end, index);
3330
+ break;
3331
+ }
3332
+ }
3333
+ if (data[i] == token)
3334
+ index = this.putAction(pair(data, i + 1), token, end, index);
3335
+ }
3336
+ }
3337
+ return index;
3338
+ }
3339
+ };
3340
+ var Rec;
3341
+ (function(Rec2) {
3342
+ Rec2[Rec2["Distance"] = 5] = "Distance";
3343
+ Rec2[Rec2["MaxRemainingPerStep"] = 3] = "MaxRemainingPerStep";
3344
+ Rec2[Rec2["MinBufferLengthPrune"] = 500] = "MinBufferLengthPrune";
3345
+ Rec2[Rec2["ForceReduceLimit"] = 10] = "ForceReduceLimit";
3346
+ Rec2[Rec2["CutDepth"] = 15e3] = "CutDepth";
3347
+ Rec2[Rec2["CutTo"] = 9e3] = "CutTo";
3348
+ Rec2[Rec2["MaxLeftAssociativeReductionCount"] = 300] = "MaxLeftAssociativeReductionCount";
3349
+ Rec2[Rec2["MaxStackCount"] = 12] = "MaxStackCount";
3350
+ })(Rec || (Rec = {}));
3351
+ var Parse = class {
3352
+ constructor(parser2, input, fragments, ranges) {
3353
+ this.parser = parser2;
3354
+ this.input = input;
3355
+ this.ranges = ranges;
3356
+ this.recovering = 0;
3357
+ this.nextStackID = 9812;
3358
+ this.minStackPos = 0;
3359
+ this.reused = [];
3360
+ this.stoppedAt = null;
3361
+ this.lastBigReductionStart = -1;
3362
+ this.lastBigReductionSize = 0;
3363
+ this.bigReductionCount = 0;
3364
+ this.stream = new InputStream(input, ranges);
3365
+ this.tokens = new TokenCache(parser2, this.stream);
3366
+ this.topTerm = parser2.top[1];
3367
+ let { from } = ranges[0];
3368
+ this.stacks = [Stack.start(this, parser2.top[0], from)];
3369
+ this.fragments = fragments.length && this.stream.end - from > parser2.bufferLength * 4 ? new FragmentCursor(fragments, parser2.nodeSet) : null;
3370
+ }
3371
+ get parsedPos() {
3372
+ return this.minStackPos;
3373
+ }
3374
+ // Move the parser forward. This will process all parse stacks at
3375
+ // `this.pos` and try to advance them to a further position. If no
3376
+ // stack for such a position is found, it'll start error-recovery.
3377
+ //
3378
+ // When the parse is finished, this will return a syntax tree. When
3379
+ // not, it returns `null`.
3380
+ advance() {
3381
+ let stacks = this.stacks, pos = this.minStackPos;
3382
+ let newStacks = this.stacks = [];
3383
+ let stopped, stoppedTokens;
3384
+ if (this.bigReductionCount > 300 && stacks.length == 1) {
3385
+ let [s] = stacks;
3386
+ while (s.forceReduce() && s.stack.length && s.stack[s.stack.length - 2] >= this.lastBigReductionStart) {
3387
+ }
3388
+ this.bigReductionCount = this.lastBigReductionSize = 0;
3389
+ }
3390
+ for (let i = 0; i < stacks.length; i++) {
3391
+ let stack = stacks[i];
3392
+ for (; ; ) {
3393
+ this.tokens.mainToken = null;
3394
+ if (stack.pos > pos) {
3395
+ newStacks.push(stack);
3396
+ } else if (this.advanceStack(stack, newStacks, stacks)) {
3397
+ continue;
3398
+ } else {
3399
+ if (!stopped) {
3400
+ stopped = [];
3401
+ stoppedTokens = [];
3402
+ }
3403
+ stopped.push(stack);
3404
+ let tok = this.tokens.getMainToken(stack);
3405
+ stoppedTokens.push(tok.value, tok.end);
3406
+ }
3407
+ break;
3408
+ }
3409
+ }
3410
+ if (!newStacks.length) {
3411
+ let finished = stopped && findFinished(stopped);
3412
+ if (finished)
3413
+ return this.stackToTree(finished);
3414
+ if (this.parser.strict) {
3415
+ if (verbose && stopped)
3416
+ console.log("Stuck with token " + (this.tokens.mainToken ? this.parser.getName(this.tokens.mainToken.value) : "none"));
3417
+ throw new SyntaxError("No parse at " + pos);
3418
+ }
3419
+ if (!this.recovering)
3420
+ this.recovering = 5;
3421
+ }
3422
+ if (this.recovering && stopped) {
3423
+ let finished = this.stoppedAt != null && stopped[0].pos > this.stoppedAt ? stopped[0] : this.runRecovery(stopped, stoppedTokens, newStacks);
3424
+ if (finished)
3425
+ return this.stackToTree(finished.forceAll());
3426
+ }
3427
+ if (this.recovering) {
3428
+ let maxRemaining = this.recovering == 1 ? 1 : this.recovering * 3;
3429
+ if (newStacks.length > maxRemaining) {
3430
+ newStacks.sort((a, b) => b.score - a.score);
3431
+ while (newStacks.length > maxRemaining)
3432
+ newStacks.pop();
3433
+ }
3434
+ if (newStacks.some((s) => s.reducePos > pos))
3435
+ this.recovering--;
3436
+ } else if (newStacks.length > 1) {
3437
+ outer:
3438
+ for (let i = 0; i < newStacks.length - 1; i++) {
3439
+ let stack = newStacks[i];
3440
+ for (let j = i + 1; j < newStacks.length; j++) {
3441
+ let other = newStacks[j];
3442
+ if (stack.sameState(other) || stack.buffer.length > 500 && other.buffer.length > 500) {
3443
+ if ((stack.score - other.score || stack.buffer.length - other.buffer.length) > 0) {
3444
+ newStacks.splice(j--, 1);
3445
+ } else {
3446
+ newStacks.splice(i--, 1);
3447
+ continue outer;
3448
+ }
3449
+ }
3450
+ }
3451
+ }
3452
+ if (newStacks.length > 12)
3453
+ newStacks.splice(
3454
+ 12,
3455
+ newStacks.length - 12
3456
+ /* Rec.MaxStackCount */
3457
+ );
3458
+ }
3459
+ this.minStackPos = newStacks[0].pos;
3460
+ for (let i = 1; i < newStacks.length; i++)
3461
+ if (newStacks[i].pos < this.minStackPos)
3462
+ this.minStackPos = newStacks[i].pos;
3463
+ return null;
3464
+ }
3465
+ stopAt(pos) {
3466
+ if (this.stoppedAt != null && this.stoppedAt < pos)
3467
+ throw new RangeError("Can't move stoppedAt forward");
3468
+ this.stoppedAt = pos;
3469
+ }
3470
+ // Returns an updated version of the given stack, or null if the
3471
+ // stack can't advance normally. When `split` and `stacks` are
3472
+ // given, stacks split off by ambiguous operations will be pushed to
3473
+ // `split`, or added to `stacks` if they move `pos` forward.
3474
+ advanceStack(stack, stacks, split) {
3475
+ let start = stack.pos, { parser: parser2 } = this;
3476
+ let base = verbose ? this.stackID(stack) + " -> " : "";
3477
+ if (this.stoppedAt != null && start > this.stoppedAt)
3478
+ return stack.forceReduce() ? stack : null;
3479
+ if (this.fragments) {
3480
+ let strictCx = stack.curContext && stack.curContext.tracker.strict, cxHash = strictCx ? stack.curContext.hash : 0;
3481
+ for (let cached = this.fragments.nodeAt(start); cached; ) {
3482
+ let match = this.parser.nodeSet.types[cached.type.id] == cached.type ? parser2.getGoto(stack.state, cached.type.id) : -1;
3483
+ if (match > -1 && cached.length && (!strictCx || (cached.prop(NodeProp.contextHash) || 0) == cxHash)) {
3484
+ stack.useNode(cached, match);
3485
+ if (verbose)
3486
+ console.log(base + this.stackID(stack) + ` (via reuse of ${parser2.getName(cached.type.id)})`);
3487
+ return true;
3488
+ }
3489
+ if (!(cached instanceof Tree) || cached.children.length == 0 || cached.positions[0] > 0)
3490
+ break;
3491
+ let inner = cached.children[0];
3492
+ if (inner instanceof Tree && cached.positions[0] == 0)
3493
+ cached = inner;
3494
+ else
3495
+ break;
3496
+ }
3497
+ }
3498
+ let defaultReduce = parser2.stateSlot(
3499
+ stack.state,
3500
+ 4
3501
+ /* ParseState.DefaultReduce */
3502
+ );
3503
+ if (defaultReduce > 0) {
3504
+ stack.reduce(defaultReduce);
3505
+ if (verbose)
3506
+ console.log(base + this.stackID(stack) + ` (via always-reduce ${parser2.getName(
3507
+ defaultReduce & 65535
3508
+ /* Action.ValueMask */
3509
+ )})`);
3510
+ return true;
3511
+ }
3512
+ if (stack.stack.length >= 15e3) {
3513
+ while (stack.stack.length > 9e3 && stack.forceReduce()) {
3514
+ }
3515
+ }
3516
+ let actions = this.tokens.getActions(stack);
3517
+ for (let i = 0; i < actions.length; ) {
3518
+ let action = actions[i++], term = actions[i++], end = actions[i++];
3519
+ let last = i == actions.length || !split;
3520
+ let localStack = last ? stack : stack.split();
3521
+ localStack.apply(action, term, end);
3522
+ if (verbose)
3523
+ console.log(base + this.stackID(localStack) + ` (via ${(action & 65536) == 0 ? "shift" : `reduce of ${parser2.getName(
3524
+ action & 65535
3525
+ /* Action.ValueMask */
3526
+ )}`} for ${parser2.getName(term)} @ ${start}${localStack == stack ? "" : ", split"})`);
3527
+ if (last)
3528
+ return true;
3529
+ else if (localStack.pos > start)
3530
+ stacks.push(localStack);
3531
+ else
3532
+ split.push(localStack);
3533
+ }
3534
+ return false;
3535
+ }
3536
+ // Advance a given stack forward as far as it will go. Returns the
3537
+ // (possibly updated) stack if it got stuck, or null if it moved
3538
+ // forward and was given to `pushStackDedup`.
3539
+ advanceFully(stack, newStacks) {
3540
+ let pos = stack.pos;
3541
+ for (; ; ) {
3542
+ if (!this.advanceStack(stack, null, null))
3543
+ return false;
3544
+ if (stack.pos > pos) {
3545
+ pushStackDedup(stack, newStacks);
3546
+ return true;
3547
+ }
3548
+ }
3549
+ }
3550
+ runRecovery(stacks, tokens, newStacks) {
3551
+ let finished = null, restarted = false;
3552
+ for (let i = 0; i < stacks.length; i++) {
3553
+ let stack = stacks[i], token = tokens[i << 1], tokenEnd = tokens[(i << 1) + 1];
3554
+ let base = verbose ? this.stackID(stack) + " -> " : "";
3555
+ if (stack.deadEnd) {
3556
+ if (restarted)
3557
+ continue;
3558
+ restarted = true;
3559
+ stack.restart();
3560
+ if (verbose)
3561
+ console.log(base + this.stackID(stack) + " (restarted)");
3562
+ let done = this.advanceFully(stack, newStacks);
3563
+ if (done)
3564
+ continue;
3565
+ }
3566
+ let force = stack.split(), forceBase = base;
3567
+ for (let j = 0; force.forceReduce() && j < 10; j++) {
3568
+ if (verbose)
3569
+ console.log(forceBase + this.stackID(force) + " (via force-reduce)");
3570
+ let done = this.advanceFully(force, newStacks);
3571
+ if (done)
3572
+ break;
3573
+ if (verbose)
3574
+ forceBase = this.stackID(force) + " -> ";
3575
+ }
3576
+ for (let insert of stack.recoverByInsert(token)) {
3577
+ if (verbose)
3578
+ console.log(base + this.stackID(insert) + " (via recover-insert)");
3579
+ this.advanceFully(insert, newStacks);
3580
+ }
3581
+ if (this.stream.end > stack.pos) {
3582
+ if (tokenEnd == stack.pos) {
3583
+ tokenEnd++;
3584
+ token = 0;
3585
+ }
3586
+ stack.recoverByDelete(token, tokenEnd);
3587
+ if (verbose)
3588
+ console.log(base + this.stackID(stack) + ` (via recover-delete ${this.parser.getName(token)})`);
3589
+ pushStackDedup(stack, newStacks);
3590
+ } else if (!finished || finished.score < stack.score) {
3591
+ finished = stack;
3592
+ }
3593
+ }
3594
+ return finished;
3595
+ }
3596
+ // Convert the stack's buffer to a syntax tree.
3597
+ stackToTree(stack) {
3598
+ stack.close();
3599
+ return Tree.build({
3600
+ buffer: StackBufferCursor.create(stack),
3601
+ nodeSet: this.parser.nodeSet,
3602
+ topID: this.topTerm,
3603
+ maxBufferLength: this.parser.bufferLength,
3604
+ reused: this.reused,
3605
+ start: this.ranges[0].from,
3606
+ length: stack.pos - this.ranges[0].from,
3607
+ minRepeatType: this.parser.minRepeatTerm
3608
+ });
3609
+ }
3610
+ stackID(stack) {
3611
+ let id = (stackIDs || (stackIDs = /* @__PURE__ */ new WeakMap())).get(stack);
3612
+ if (!id)
3613
+ stackIDs.set(stack, id = String.fromCodePoint(this.nextStackID++));
3614
+ return id + stack;
3615
+ }
3616
+ };
3617
+ function pushStackDedup(stack, newStacks) {
3618
+ for (let i = 0; i < newStacks.length; i++) {
3619
+ let other = newStacks[i];
3620
+ if (other.pos == stack.pos && other.sameState(stack)) {
3621
+ if (newStacks[i].score < stack.score)
3622
+ newStacks[i] = stack;
3623
+ return;
3624
+ }
3625
+ }
3626
+ newStacks.push(stack);
3627
+ }
3628
+ var Dialect = class {
3629
+ constructor(source, flags, disabled) {
3630
+ this.source = source;
3631
+ this.flags = flags;
3632
+ this.disabled = disabled;
3633
+ }
3634
+ allows(term) {
3635
+ return !this.disabled || this.disabled[term] == 0;
3636
+ }
3637
+ };
3638
+ var LRParser = class extends Parser {
3639
+ /// @internal
3640
+ constructor(spec) {
3641
+ super();
3642
+ this.wrappers = [];
3643
+ if (spec.version != 14)
3644
+ throw new RangeError(`Parser version (${spec.version}) doesn't match runtime version (${14})`);
3645
+ let nodeNames = spec.nodeNames.split(" ");
3646
+ this.minRepeatTerm = nodeNames.length;
3647
+ for (let i = 0; i < spec.repeatNodeCount; i++)
3648
+ nodeNames.push("");
3649
+ let topTerms = Object.keys(spec.topRules).map((r) => spec.topRules[r][1]);
3650
+ let nodeProps = [];
3651
+ for (let i = 0; i < nodeNames.length; i++)
3652
+ nodeProps.push([]);
3653
+ function setProp(nodeID, prop, value) {
3654
+ nodeProps[nodeID].push([prop, prop.deserialize(String(value))]);
3655
+ }
3656
+ if (spec.nodeProps)
3657
+ for (let propSpec of spec.nodeProps) {
3658
+ let prop = propSpec[0];
3659
+ if (typeof prop == "string")
3660
+ prop = NodeProp[prop];
3661
+ for (let i = 1; i < propSpec.length; ) {
3662
+ let next = propSpec[i++];
3663
+ if (next >= 0) {
3664
+ setProp(next, prop, propSpec[i++]);
3665
+ } else {
3666
+ let value = propSpec[i + -next];
3667
+ for (let j = -next; j > 0; j--)
3668
+ setProp(propSpec[i++], prop, value);
3669
+ i++;
3670
+ }
3671
+ }
3672
+ }
3673
+ this.nodeSet = new NodeSet(nodeNames.map((name, i) => NodeType.define({
3674
+ name: i >= this.minRepeatTerm ? void 0 : name,
3675
+ id: i,
3676
+ props: nodeProps[i],
3677
+ top: topTerms.indexOf(i) > -1,
3678
+ error: i == 0,
3679
+ skipped: spec.skippedNodes && spec.skippedNodes.indexOf(i) > -1
3680
+ })));
3681
+ if (spec.propSources)
3682
+ this.nodeSet = this.nodeSet.extend(...spec.propSources);
3683
+ this.strict = false;
3684
+ this.bufferLength = DefaultBufferLength;
3685
+ let tokenArray = decodeArray(spec.tokenData);
3686
+ this.context = spec.context;
3687
+ this.specializerSpecs = spec.specialized || [];
3688
+ this.specialized = new Uint16Array(this.specializerSpecs.length);
3689
+ for (let i = 0; i < this.specializerSpecs.length; i++)
3690
+ this.specialized[i] = this.specializerSpecs[i].term;
3691
+ this.specializers = this.specializerSpecs.map(getSpecializer);
3692
+ this.states = decodeArray(spec.states, Uint32Array);
3693
+ this.data = decodeArray(spec.stateData);
3694
+ this.goto = decodeArray(spec.goto);
3695
+ this.maxTerm = spec.maxTerm;
3696
+ this.tokenizers = spec.tokenizers.map((value) => typeof value == "number" ? new TokenGroup(tokenArray, value) : value);
3697
+ this.topRules = spec.topRules;
3698
+ this.dialects = spec.dialects || {};
3699
+ this.dynamicPrecedences = spec.dynamicPrecedences || null;
3700
+ this.tokenPrecTable = spec.tokenPrec;
3701
+ this.termNames = spec.termNames || null;
3702
+ this.maxNode = this.nodeSet.types.length - 1;
3703
+ this.dialect = this.parseDialect();
3704
+ this.top = this.topRules[Object.keys(this.topRules)[0]];
3705
+ }
3706
+ createParse(input, fragments, ranges) {
3707
+ let parse = new Parse(this, input, fragments, ranges);
3708
+ for (let w of this.wrappers)
3709
+ parse = w(parse, input, fragments, ranges);
3710
+ return parse;
3711
+ }
3712
+ /// Get a goto table entry @internal
3713
+ getGoto(state, term, loose = false) {
3714
+ let table = this.goto;
3715
+ if (term >= table[0])
3716
+ return -1;
3717
+ for (let pos = table[term + 1]; ; ) {
3718
+ let groupTag = table[pos++], last = groupTag & 1;
3719
+ let target = table[pos++];
3720
+ if (last && loose)
3721
+ return target;
3722
+ for (let end = pos + (groupTag >> 1); pos < end; pos++)
3723
+ if (table[pos] == state)
3724
+ return target;
3725
+ if (last)
3726
+ return -1;
847
3727
  }
848
- );
3728
+ }
3729
+ /// Check if this state has an action for a given terminal @internal
3730
+ hasAction(state, terminal) {
3731
+ let data = this.data;
3732
+ for (let set = 0; set < 2; set++) {
3733
+ for (let i = this.stateSlot(
3734
+ state,
3735
+ set ? 2 : 1
3736
+ /* ParseState.Actions */
3737
+ ), next; ; i += 3) {
3738
+ if ((next = data[i]) == 65535) {
3739
+ if (data[i + 1] == 1)
3740
+ next = data[i = pair(data, i + 2)];
3741
+ else if (data[i + 1] == 2)
3742
+ return pair(data, i + 2);
3743
+ else
3744
+ break;
3745
+ }
3746
+ if (next == terminal || next == 0)
3747
+ return pair(data, i + 1);
3748
+ }
3749
+ }
3750
+ return 0;
3751
+ }
3752
+ /// @internal
3753
+ stateSlot(state, slot) {
3754
+ return this.states[state * 6 + slot];
3755
+ }
3756
+ /// @internal
3757
+ stateFlag(state, flag) {
3758
+ return (this.stateSlot(
3759
+ state,
3760
+ 0
3761
+ /* ParseState.Flags */
3762
+ ) & flag) > 0;
3763
+ }
3764
+ /// @internal
3765
+ validAction(state, action) {
3766
+ if (action == this.stateSlot(
3767
+ state,
3768
+ 4
3769
+ /* ParseState.DefaultReduce */
3770
+ ))
3771
+ return true;
3772
+ for (let i = this.stateSlot(
3773
+ state,
3774
+ 1
3775
+ /* ParseState.Actions */
3776
+ ); ; i += 3) {
3777
+ if (this.data[i] == 65535) {
3778
+ if (this.data[i + 1] == 1)
3779
+ i = pair(this.data, i + 2);
3780
+ else
3781
+ return false;
3782
+ }
3783
+ if (action == pair(this.data, i + 1))
3784
+ return true;
3785
+ }
3786
+ }
3787
+ /// Get the states that can follow this one through shift actions or
3788
+ /// goto jumps. @internal
3789
+ nextStates(state) {
3790
+ let result = [];
3791
+ for (let i = this.stateSlot(
3792
+ state,
3793
+ 1
3794
+ /* ParseState.Actions */
3795
+ ); ; i += 3) {
3796
+ if (this.data[i] == 65535) {
3797
+ if (this.data[i + 1] == 1)
3798
+ i = pair(this.data, i + 2);
3799
+ else
3800
+ break;
3801
+ }
3802
+ if ((this.data[i + 2] & 65536 >> 16) == 0) {
3803
+ let value = this.data[i + 1];
3804
+ if (!result.some((v, i2) => i2 & 1 && v == value))
3805
+ result.push(this.data[i], value);
3806
+ }
3807
+ }
3808
+ return result;
3809
+ }
3810
+ /// Configure the parser. Returns a new parser instance that has the
3811
+ /// given settings modified. Settings not provided in `config` are
3812
+ /// kept from the original parser.
3813
+ configure(config) {
3814
+ let copy = Object.assign(Object.create(LRParser.prototype), this);
3815
+ if (config.props)
3816
+ copy.nodeSet = this.nodeSet.extend(...config.props);
3817
+ if (config.top) {
3818
+ let info2 = this.topRules[config.top];
3819
+ if (!info2)
3820
+ throw new RangeError(`Invalid top rule name ${config.top}`);
3821
+ copy.top = info2;
3822
+ }
3823
+ if (config.tokenizers)
3824
+ copy.tokenizers = this.tokenizers.map((t) => {
3825
+ let found = config.tokenizers.find((r) => r.from == t);
3826
+ return found ? found.to : t;
3827
+ });
3828
+ if (config.specializers) {
3829
+ copy.specializers = this.specializers.slice();
3830
+ copy.specializerSpecs = this.specializerSpecs.map((s, i) => {
3831
+ let found = config.specializers.find((r) => r.from == s.external);
3832
+ if (!found)
3833
+ return s;
3834
+ let spec = Object.assign(Object.assign({}, s), { external: found.to });
3835
+ copy.specializers[i] = getSpecializer(spec);
3836
+ return spec;
3837
+ });
3838
+ }
3839
+ if (config.contextTracker)
3840
+ copy.context = config.contextTracker;
3841
+ if (config.dialect)
3842
+ copy.dialect = this.parseDialect(config.dialect);
3843
+ if (config.strict != null)
3844
+ copy.strict = config.strict;
3845
+ if (config.wrap)
3846
+ copy.wrappers = copy.wrappers.concat(config.wrap);
3847
+ if (config.bufferLength != null)
3848
+ copy.bufferLength = config.bufferLength;
3849
+ return copy;
3850
+ }
3851
+ /// Tells you whether any [parse wrappers](#lr.ParserConfig.wrap)
3852
+ /// are registered for this parser.
3853
+ hasWrappers() {
3854
+ return this.wrappers.length > 0;
3855
+ }
3856
+ /// Returns the name associated with a given term. This will only
3857
+ /// work for all terms when the parser was generated with the
3858
+ /// `--names` option. By default, only the names of tagged terms are
3859
+ /// stored.
3860
+ getName(term) {
3861
+ return this.termNames ? this.termNames[term] : String(term <= this.maxNode && this.nodeSet.types[term].name || term);
3862
+ }
3863
+ /// The eof term id is always allocated directly after the node
3864
+ /// types. @internal
3865
+ get eofTerm() {
3866
+ return this.maxNode + 1;
3867
+ }
3868
+ /// The type of top node produced by the parser.
3869
+ get topNode() {
3870
+ return this.nodeSet.types[this.top[1]];
3871
+ }
3872
+ /// @internal
3873
+ dynamicPrecedence(term) {
3874
+ let prec = this.dynamicPrecedences;
3875
+ return prec == null ? 0 : prec[term] || 0;
3876
+ }
3877
+ /// @internal
3878
+ parseDialect(dialect) {
3879
+ let values = Object.keys(this.dialects), flags = values.map(() => false);
3880
+ if (dialect)
3881
+ for (let part of dialect.split(" ")) {
3882
+ let id = values.indexOf(part);
3883
+ if (id >= 0)
3884
+ flags[id] = true;
3885
+ }
3886
+ let disabled = null;
3887
+ for (let i = 0; i < values.length; i++)
3888
+ if (!flags[i]) {
3889
+ for (let j = this.dialects[values[i]], id; (id = this.data[j++]) != 65535; )
3890
+ (disabled || (disabled = new Uint8Array(this.maxTerm + 1)))[id] = 1;
3891
+ }
3892
+ return new Dialect(dialect, flags, disabled);
3893
+ }
3894
+ /// Used by the output of the parser generator. Not available to
3895
+ /// user code. @hide
3896
+ static deserialize(spec) {
3897
+ return new LRParser(spec);
3898
+ }
849
3899
  };
3900
+ function pair(data, off) {
3901
+ return data[off] | data[off + 1] << 16;
3902
+ }
3903
+ function findFinished(stacks) {
3904
+ let best = null;
3905
+ for (let stack of stacks) {
3906
+ let stopped = stack.p.stoppedAt;
3907
+ if ((stack.pos == stack.p.stream.end || stopped != null && stack.pos > stopped) && stack.p.parser.stateFlag(
3908
+ stack.state,
3909
+ 2
3910
+ /* StateFlag.Accepting */
3911
+ ) && (!best || best.score < stack.score))
3912
+ best = stack;
3913
+ }
3914
+ return best;
3915
+ }
3916
+ function getSpecializer(spec) {
3917
+ if (spec.external) {
3918
+ let mask = spec.extend ? 1 : 0;
3919
+ return (value, stack) => spec.external(value, stack) << 1 | mask;
3920
+ }
3921
+ return spec.get;
3922
+ }
850
3923
 
851
- // src/RowBasedTable.tsx
852
- var import_jsx_runtime9 = require("react/jsx-runtime");
853
- var classBase5 = "vuuTable";
854
- var { RENDER_IDX } = import_vuu_utils6.metadataKeys;
855
- var RowBasedTable = ({
856
- columns,
857
- columnsWithinViewport,
858
- data,
859
- getRowOffset,
860
- headings,
861
- onColumnResize,
862
- onHeaderCellDragStart,
863
- onContextMenu,
864
- onRemoveColumnFromGroupBy,
865
- onRowClick,
866
- onSort,
867
- onToggleGroup,
868
- tableId,
869
- virtualColSpan = 0,
870
- rowCount
871
- }) => {
872
- const handleDragStart = (0, import_react9.useCallback)(
873
- (evt) => {
874
- onHeaderCellDragStart == null ? void 0 : onHeaderCellDragStart(evt);
875
- },
876
- [onHeaderCellDragStart]
877
- );
878
- const visibleColumns = (0, import_react9.useMemo)(() => {
879
- return columns.filter(import_vuu_utils6.notHidden);
880
- }, [columns]);
881
- const columnMap = (0, import_react9.useMemo)(() => (0, import_vuu_utils6.buildColumnMap)(columns), [columns]);
882
- const handleHeaderClick = (0, import_react9.useCallback)(
883
- (evt) => {
884
- var _a;
885
- const targetElement = evt.target;
886
- const headerCell = targetElement.closest(
887
- ".vuuTable-headerCell"
888
- );
889
- const colIdx = parseInt((_a = headerCell == null ? void 0 : headerCell.dataset.idx) != null ? _a : "-1");
890
- const column = (0, import_vuu_utils6.visibleColumnAtIndex)(columns, colIdx);
891
- const isAdditive = evt.shiftKey;
892
- column && onSort(column, isAdditive);
893
- },
894
- [columns, onSort]
895
- );
896
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { "aria-rowcount": rowCount, className: `${classBase5}-table`, role: "table", children: [
897
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: `${classBase5}-headers`, role: "rowGroup", children: [
898
- headings.map((colHeaders, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "vuuTable-heading", children: colHeaders.map(({ label, width }, j) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "vuuTable-headingCell", style: { width }, children: label }, j)) }, i)),
899
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { role: "row", children: visibleColumns.map((column, i) => {
900
- const style = (0, import_vuu_utils6.getColumnStyle)(column);
901
- return (0, import_vuu_utils6.isGroupColumn)(column) ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
902
- TableGroupHeaderCell,
903
- {
904
- column,
905
- "data-idx": i,
906
- onRemoveColumn: onRemoveColumnFromGroupBy,
907
- onResize: onColumnResize,
908
- role: "columnHeader",
909
- style
910
- },
911
- i
912
- ) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
913
- TableHeaderCell,
914
- {
915
- column,
916
- "data-idx": i,
917
- id: `${tableId}-${i}`,
918
- onClick: handleHeaderClick,
919
- onDragStart: handleDragStart,
920
- onResize: onColumnResize,
921
- role: "columnHeader",
922
- style
923
- },
924
- i
925
- );
926
- }) })
927
- ] }),
928
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
929
- "div",
930
- {
931
- className: `${classBase5}-body`,
932
- onContextMenu,
933
- role: "rowGroup",
934
- children: data == null ? void 0 : data.map((row) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
935
- TableRow,
936
- {
937
- columnMap,
938
- columns: columnsWithinViewport,
939
- offset: getRowOffset(row),
940
- onClick: onRowClick,
941
- virtualColSpan,
942
- onToggleGroup,
943
- row
944
- },
945
- row[RENDER_IDX]
946
- ))
3924
+ // ../vuu-filter-parser/src/generated/filter-parser.js
3925
+ var parser = LRParser.deserialize({
3926
+ version: 14,
3927
+ states: "%QOVQPOOOOQO'#C_'#C_O_QQO'#C^OOQO'#DO'#DOOvQQO'#C|OOQO'#DR'#DROVQPO'#CuOOQO'#C}'#C}QOQPOOOOQO'#C`'#C`O!UQQO,58xO!dQPO,59VOVQPO,59]OVQPO,59_O!iQPO,59hO!nQQO,59aOOQO'#DQ'#DQOOQO1G.d1G.dO!UQQO1G.qO!yQQO1G.wOOQO1G.y1G.yOOQO'#Cw'#CwOOQO1G/S1G/SOOQO1G.{1G.{O#[QPO'#CnO#dQPO7+$]O!UQQO'#CxO#iQPO,59YOOQO<<Gw<<GwOOQO,59d,59dOOQO-E6v-E6v",
3928
+ stateData: "#q~OoOS~OsPOvUO~OTXOUXOVXOWXOXXOYXO`ZO~Of[Oh]Oj^OmpX~OZ`O[`O]`O^`O~OabO~OseO~Of[Oh]OwgO~Oh]Ofeijeimeiwei~OcjOdbX~OdlO~OcjOdba~O",
3929
+ goto: "#YvPPw}!TPPPPPPPPPPwPP!WPP!ZP!ZP!aP!g!jPPP!p!s!aP#P!aXROU[]XQOU[]RYQRibXTOU[]XVOU[]Rf^QkhRnkRWOQSOQ_UQc[Rd]QaYQhbRmj",
3930
+ nodeNames: "\u26A0 Filter ColumnValueExpression Column Operator Eq NotEq Gt Lt Starts Ends Number String True False ColumnSetExpression In LBrack Values Comma RBrack AndExpression And OrExpression Or ParenthesizedExpression As FilterName",
3931
+ maxTerm: 39,
3932
+ skippedNodes: [0],
3933
+ repeatNodeCount: 1,
3934
+ tokenData: "6p~RnXY#PYZ#P]^#Ppq#Pqr#brs#mxy$eyz$j|}$o!O!P$t!Q![%S!^!_%_!_!`%d!`!a%i!c!}%n!}#O&V#P#Q&[#R#S%n#T#U&a#U#X%n#X#Y(w#Y#Z+]#Z#]%n#]#^.]#^#c%n#c#d/e#d#g%n#g#h0m#h#i4[#i#o%n~#USo~XY#PYZ#P]^#Ppq#P~#eP!_!`#h~#mOU~~#pWOX#mZ]#m^r#mrs$Ys#O#m#P;'S#m;'S;=`$_<%lO#m~$_O[~~$bP;=`<%l#m~$jOv~~$oOw~~$tOc~~$wP!Q![$z~%PPZ~!Q![$z~%XQZ~!O!P$t!Q![%S~%dOW~~%iOT~~%nOV~P%sUsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n~&[Oa~~&aOd~R&fYsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c'U#c#g%n#g#h(^#h#o%nR'ZWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X's#X#o%nR'zUfQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(eUjQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR(|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c)f#c#o%nR)kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#W%n#W#X*T#X#o%nR*YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h*r#h#o%nR*yUYQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR+bVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U+w#U#o%nR+|WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#`%n#`#a,f#a#o%nR,kWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h-T#h#o%nR-YWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y-r#Y#o%nR-yU^QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR.bWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#b%n#b#c.z#c#o%nR/RU`QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR/jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g0S#g#o%nR0ZUhQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR0rWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i1[#i#o%nR1aVsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#U1v#U#o%nR1{WsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g2e#g#o%nR2jWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#h%n#h#i3S#i#o%nR3XWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#g%n#g#h3q#h#o%nR3xUXQsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%nR4aWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#f%n#f#g4y#g#o%nR5OWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#i%n#i#j5h#j#o%nR5mWsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#X%n#X#Y6V#Y#o%nR6^U]QsP}!O%n!O!P%n!Q![%n!c!}%n#R#S%n#T#o%n",
3935
+ tokenizers: [0, 1],
3936
+ topRules: { "Filter": [0, 1] },
3937
+ tokenPrec: 0
3938
+ });
3939
+
3940
+ // ../vuu-filter-parser/src/FilterTreeWalker.ts
3941
+ var import_vuu_utils9 = require("@vuu-ui/vuu-utils");
3942
+ var _filter;
3943
+ var FilterExpression = class {
3944
+ constructor() {
3945
+ __privateAdd(this, _filter, void 0);
3946
+ }
3947
+ setFilterCombinatorOp(op, filter = __privateGet(this, _filter)) {
3948
+ if ((0, import_vuu_utils9.isMultiClauseFilter)(filter) && filter.op === op) {
3949
+ return;
3950
+ } else {
3951
+ __privateSet(this, _filter, {
3952
+ op,
3953
+ filters: [__privateGet(this, _filter)]
3954
+ });
3955
+ }
3956
+ }
3957
+ add(filter) {
3958
+ if (__privateGet(this, _filter) === void 0) {
3959
+ __privateSet(this, _filter, filter);
3960
+ } else if ((0, import_vuu_utils9.isMultiClauseFilter)(__privateGet(this, _filter))) {
3961
+ __privateGet(this, _filter).filters.push(filter);
3962
+ } else {
3963
+ throw Error(`Invalid filter passed to FilterExpression`);
3964
+ }
3965
+ }
3966
+ setColumn(column, filter = __privateGet(this, _filter)) {
3967
+ if ((0, import_vuu_utils9.isMultiClauseFilter)(filter)) {
3968
+ const target = filter.filters.at(-1);
3969
+ if (target) {
3970
+ this.setColumn(column, target);
947
3971
  }
948
- )
949
- ] });
3972
+ } else if (filter) {
3973
+ filter.column = column;
3974
+ }
3975
+ }
3976
+ setOp(value, filter = __privateGet(this, _filter)) {
3977
+ if ((0, import_vuu_utils9.isMultiClauseFilter)(filter)) {
3978
+ const target = filter.filters.at(-1);
3979
+ if (target) {
3980
+ this.setOp(value, target);
3981
+ }
3982
+ } else if (filter) {
3983
+ filter.op = value;
3984
+ }
3985
+ }
3986
+ setValue(value, filter = __privateGet(this, _filter)) {
3987
+ var _a;
3988
+ if ((0, import_vuu_utils9.isMultiClauseFilter)(filter)) {
3989
+ const target = filter.filters.at(-1);
3990
+ if (target) {
3991
+ this.setValue(value, target);
3992
+ }
3993
+ } else if ((0, import_vuu_utils9.isMultiValueFilter)(filter)) {
3994
+ (_a = filter.values) != null ? _a : filter.values = [];
3995
+ filter.values.push(value);
3996
+ } else if ((0, import_vuu_utils9.isSingleValueFilter)(filter)) {
3997
+ filter.value = value;
3998
+ }
3999
+ }
4000
+ toJSON(filter = __privateGet(this, _filter)) {
4001
+ if (this.name) {
4002
+ return {
4003
+ ...filter,
4004
+ name: this.name
4005
+ };
4006
+ } else {
4007
+ return filter;
4008
+ }
4009
+ }
950
4010
  };
4011
+ _filter = new WeakMap();
951
4012
 
952
- // src/useTable.ts
953
- var import_vuu_popups3 = require("@vuu-ui/vuu-popups");
954
- var import_vuu_utils14 = require("@vuu-ui/vuu-utils");
955
- var import_react20 = require("react");
4013
+ // ../vuu-filter-parser/src/FilterParser.ts
4014
+ var strictParser = parser.configure({ strict: true });
4015
+
4016
+ // ../vuu-data-react/src/hooks/useVuuMenuActions.ts
4017
+ var import_vuu_utils10 = require("@vuu-ui/vuu-utils");
4018
+ var import_react14 = require("react");
4019
+ var { KEY: KEY2 } = import_vuu_utils10.metadataKeys;
4020
+ var isVisualLinksAction = (action) => action.type === "vuu-links";
4021
+ var isViewportMenusAction = (action) => action.type === "vuu-menu";
4022
+ var isVuuFeatureAction = (action) => isViewportMenusAction(action) || isVisualLinksAction(action);
4023
+ var isVuuFeatureInvocation = (action) => action.type === "vuu-link-created" || action.type === "vuu-link-removed";
4024
+
4025
+ // ../vuu-data-react/src/hooks/useVuuTables.ts
4026
+ var import_react15 = require("react");
4027
+ var import_vuu_data4 = require("@vuu-ui/vuu-data");
956
4028
 
957
4029
  // src/useDataSource.ts
958
- var import_vuu_data = require("@vuu-ui/vuu-data");
959
- var import_vuu_utils7 = require("@vuu-ui/vuu-utils");
960
- var import_react10 = require("react");
961
- var { SELECTED: SELECTED2 } = import_vuu_utils7.metadataKeys;
4030
+ var import_vuu_utils11 = require("@vuu-ui/vuu-utils");
4031
+ var import_react16 = require("react");
4032
+ var { SELECTED: SELECTED3 } = import_vuu_utils11.metadataKeys;
962
4033
  function useDataSource({
963
4034
  dataSource,
964
4035
  onConfigChange,
@@ -970,18 +4041,18 @@ function useDataSource({
970
4041
  renderBufferSize = 0,
971
4042
  viewportRowCount
972
4043
  }) {
973
- const [, forceUpdate] = (0, import_react10.useState)(null);
974
- const isMounted = (0, import_react10.useRef)(true);
975
- const hasUpdated = (0, import_react10.useRef)(false);
976
- const rangeRef = (0, import_react10.useRef)({ from: 0, to: 0 });
977
- const rafHandle = (0, import_react10.useRef)(null);
978
- const data = (0, import_react10.useRef)([]);
979
- const dataWindow = (0, import_react10.useMemo)(
980
- () => new MovingWindow((0, import_vuu_utils7.getFullRange)(range)),
4044
+ const [, forceUpdate] = (0, import_react16.useState)(null);
4045
+ const isMounted = (0, import_react16.useRef)(true);
4046
+ const hasUpdated = (0, import_react16.useRef)(false);
4047
+ const rangeRef = (0, import_react16.useRef)({ from: 0, to: 0 });
4048
+ const rafHandle = (0, import_react16.useRef)(null);
4049
+ const data = (0, import_react16.useRef)([]);
4050
+ const dataWindow = (0, import_react16.useMemo)(
4051
+ () => new MovingWindow((0, import_vuu_utils11.getFullRange)(range)),
981
4052
  // eslint-disable-next-line react-hooks/exhaustive-deps
982
4053
  []
983
4054
  );
984
- const setData = (0, import_react10.useCallback)(
4055
+ const setData = (0, import_react16.useCallback)(
985
4056
  (updates) => {
986
4057
  for (const row of updates) {
987
4058
  dataWindow.add(row);
@@ -991,7 +4062,7 @@ function useDataSource({
991
4062
  },
992
4063
  [dataWindow]
993
4064
  );
994
- const datasourceMessageHandler = (0, import_react10.useCallback)(
4065
+ const datasourceMessageHandler = (0, import_react16.useCallback)(
995
4066
  (message) => {
996
4067
  if (message.type === "subscribed") {
997
4068
  onSubscribed == null ? void 0 : onSubscribed(message);
@@ -1006,9 +4077,9 @@ function useDataSource({
1006
4077
  data.current = dataWindow.data;
1007
4078
  hasUpdated.current = true;
1008
4079
  }
1009
- } else if ((0, import_vuu_data.isVuuFeatureAction)(message)) {
4080
+ } else if (isVuuFeatureAction(message)) {
1010
4081
  onFeatureEnabled == null ? void 0 : onFeatureEnabled(message);
1011
- } else if ((0, import_vuu_data.isVuuFeatureInvocation)(message)) {
4082
+ } else if (isVuuFeatureInvocation(message)) {
1012
4083
  onFeatureInvocation == null ? void 0 : onFeatureInvocation(message);
1013
4084
  } else {
1014
4085
  console.log(`useDataSource unexpected message ${message.type}`);
@@ -1023,7 +4094,7 @@ function useDataSource({
1023
4094
  setData
1024
4095
  ]
1025
4096
  );
1026
- (0, import_react10.useEffect)(
4097
+ (0, import_react16.useEffect)(
1027
4098
  () => () => {
1028
4099
  if (rafHandle.current) {
1029
4100
  cancelAnimationFrame(rafHandle.current);
@@ -1033,7 +4104,7 @@ function useDataSource({
1033
4104
  },
1034
4105
  []
1035
4106
  );
1036
- const refreshIfUpdated = (0, import_react10.useCallback)(() => {
4107
+ const refreshIfUpdated = (0, import_react16.useCallback)(() => {
1037
4108
  if (isMounted.current) {
1038
4109
  if (hasUpdated.current) {
1039
4110
  forceUpdate({});
@@ -1042,33 +4113,33 @@ function useDataSource({
1042
4113
  rafHandle.current = requestAnimationFrame(refreshIfUpdated);
1043
4114
  }
1044
4115
  }, [forceUpdate]);
1045
- (0, import_react10.useEffect)(() => {
4116
+ (0, import_react16.useEffect)(() => {
1046
4117
  rafHandle.current = requestAnimationFrame(refreshIfUpdated);
1047
4118
  }, [refreshIfUpdated]);
1048
- const adjustRange = (0, import_react10.useCallback)(
4119
+ const adjustRange = (0, import_react16.useCallback)(
1049
4120
  (rowCount) => {
1050
4121
  const { from } = dataSource.range;
1051
4122
  const rowRange = { from, to: from + rowCount };
1052
- const fullRange = (0, import_vuu_utils7.getFullRange)(rowRange, renderBufferSize);
4123
+ const fullRange = (0, import_vuu_utils11.getFullRange)(rowRange, renderBufferSize);
1053
4124
  dataWindow.setRange(fullRange);
1054
4125
  dataSource.range = rangeRef.current = fullRange;
1055
4126
  dataSource.emit("range", rowRange);
1056
4127
  },
1057
4128
  [dataSource, dataWindow, renderBufferSize]
1058
4129
  );
1059
- const setRange = (0, import_react10.useCallback)(
4130
+ const setRange = (0, import_react16.useCallback)(
1060
4131
  (range2) => {
1061
- const fullRange = (0, import_vuu_utils7.getFullRange)(range2, renderBufferSize);
4132
+ const fullRange = (0, import_vuu_utils11.getFullRange)(range2, renderBufferSize);
1062
4133
  dataWindow.setRange(fullRange);
1063
4134
  dataSource.range = rangeRef.current = fullRange;
1064
4135
  dataSource.emit("range", range2);
1065
4136
  },
1066
4137
  [dataSource, dataWindow, renderBufferSize]
1067
4138
  );
1068
- const getSelectedRows = (0, import_react10.useCallback)(() => {
4139
+ const getSelectedRows = (0, import_react16.useCallback)(() => {
1069
4140
  return dataWindow.getSelectedRows();
1070
4141
  }, [dataWindow]);
1071
- (0, import_react10.useEffect)(() => {
4142
+ (0, import_react16.useEffect)(() => {
1072
4143
  dataSource == null ? void 0 : dataSource.subscribe(
1073
4144
  {
1074
4145
  range: rangeRef.current
@@ -1076,7 +4147,7 @@ function useDataSource({
1076
4147
  datasourceMessageHandler
1077
4148
  );
1078
4149
  }, [dataSource, datasourceMessageHandler, onConfigChange]);
1079
- (0, import_react10.useEffect)(() => {
4150
+ (0, import_react16.useEffect)(() => {
1080
4151
  adjustRange(viewportRowCount);
1081
4152
  }, [adjustRange, viewportRowCount]);
1082
4153
  return {
@@ -1096,7 +4167,7 @@ var MovingWindow = class {
1096
4167
  }
1097
4168
  this.rowCount = rowCount;
1098
4169
  };
1099
- this.range = new import_vuu_utils7.WindowRange(from, to);
4170
+ this.range = new import_vuu_utils11.WindowRange(from, to);
1100
4171
  this.data = new Array(to - from);
1101
4172
  this.rowCount = 0;
1102
4173
  }
@@ -1106,12 +4177,12 @@ var MovingWindow = class {
1106
4177
  if (this.isWithinRange(index)) {
1107
4178
  const internalIndex = index - this.range.from;
1108
4179
  this.data[internalIndex] = data;
1109
- const isSelected = data[SELECTED2];
1110
- const preSelected = (_a = this.data[internalIndex - 1]) == null ? void 0 : _a[SELECTED2];
4180
+ const isSelected = data[SELECTED3];
4181
+ const preSelected = (_a = this.data[internalIndex - 1]) == null ? void 0 : _a[SELECTED3];
1111
4182
  if (preSelected === 0 && isSelected) {
1112
- this.data[internalIndex - 1][SELECTED2] = 2;
4183
+ this.data[internalIndex - 1][SELECTED3] = 2;
1113
4184
  } else if (preSelected === 2 && !isSelected) {
1114
- this.data[internalIndex - 1][SELECTED2] = 0;
4185
+ this.data[internalIndex - 1][SELECTED3] = 0;
1115
4186
  }
1116
4187
  }
1117
4188
  }
@@ -1138,17 +4209,17 @@ var MovingWindow = class {
1138
4209
  }
1139
4210
  }
1140
4211
  getSelectedRows() {
1141
- return this.data.filter((row) => row[SELECTED2] === 1);
4212
+ return this.data.filter((row) => row[SELECTED3] === 1);
1142
4213
  }
1143
4214
  };
1144
4215
 
1145
4216
  // src/useDraggableColumn.ts
1146
4217
  var import_salt_lab2 = require("@heswell/salt-lab");
1147
- var import_react11 = require("react");
4218
+ var import_react17 = require("react");
1148
4219
  var useDraggableColumn = ({ onDrop }) => {
1149
- const mousePosRef = (0, import_react11.useRef)();
1150
- const containerRef = (0, import_react11.useRef)(null);
1151
- const handleDropSettle = (0, import_react11.useCallback)(() => {
4220
+ const mousePosRef = (0, import_react17.useRef)();
4221
+ const containerRef = (0, import_react17.useRef)(null);
4222
+ const handleDropSettle = (0, import_react17.useCallback)(() => {
1152
4223
  console.log(`handleDropSettle`);
1153
4224
  mousePosRef.current = void 0;
1154
4225
  containerRef.current = null;
@@ -1163,7 +4234,7 @@ var useDraggableColumn = ({ onDrop }) => {
1163
4234
  onDrop,
1164
4235
  onDropSettle: handleDropSettle
1165
4236
  });
1166
- const onHeaderCellDragStart = (0, import_react11.useCallback)(
4237
+ const onHeaderCellDragStart = (0, import_react17.useCallback)(
1167
4238
  (evt) => {
1168
4239
  const { clientX, clientY } = evt;
1169
4240
  console.log(
@@ -1194,8 +4265,8 @@ var useDraggableColumn = ({ onDrop }) => {
1194
4265
  };
1195
4266
 
1196
4267
  // src/useKeyboardNavigation.ts
1197
- var import_vuu_utils8 = require("@vuu-ui/vuu-utils");
1198
- var import_react12 = require("react");
4268
+ var import_vuu_utils12 = require("@vuu-ui/vuu-utils");
4269
+ var import_react18 = require("react");
1199
4270
 
1200
4271
  // src/keyUtils.ts
1201
4272
  function union(set1, ...sets) {
@@ -1300,10 +4371,10 @@ var useKeyboardNavigation = ({
1300
4371
  }) => {
1301
4372
  var _a;
1302
4373
  const { from: viewportFirstRow, to: viewportLastRow } = viewportRange;
1303
- const focusedCellPos = (0, import_react12.useRef)([-1, -1]);
1304
- const focusableCell = (0, import_react12.useRef)();
1305
- const activeCellPos = (0, import_react12.useRef)([-1, 0]);
1306
- const getTableCell = (0, import_react12.useCallback)(
4374
+ const focusedCellPos = (0, import_react18.useRef)([-1, -1]);
4375
+ const focusableCell = (0, import_react18.useRef)();
4376
+ const activeCellPos = (0, import_react18.useRef)([-1, 0]);
4377
+ const getTableCell = (0, import_react18.useCallback)(
1307
4378
  ([rowIdx, colIdx]) => {
1308
4379
  var _a2;
1309
4380
  const cssQuery = rowIdx === -1 ? headerCellQuery(colIdx) : dataCellQuery(rowIdx, colIdx);
@@ -1331,7 +4402,7 @@ var useKeyboardNavigation = ({
1331
4402
  }
1332
4403
  return NULL_CELL_POS;
1333
4404
  };
1334
- const focusCell = (0, import_react12.useCallback)(
4405
+ const focusCell = (0, import_react18.useCallback)(
1335
4406
  (cellPos) => {
1336
4407
  var _a2;
1337
4408
  if (containerRef.current) {
@@ -1343,7 +4414,7 @@ var useKeyboardNavigation = ({
1343
4414
  activeCell.setAttribute("tabindex", "0");
1344
4415
  }
1345
4416
  activeCell.focus();
1346
- } else if (!(0, import_vuu_utils8.withinRange)(cellPos[0], viewportRange)) {
4417
+ } else if (!(0, import_vuu_utils12.withinRange)(cellPos[0], viewportRange)) {
1347
4418
  focusableCell.current = void 0;
1348
4419
  requestScroll == null ? void 0 : requestScroll({ type: "scroll-page", direction: "up" });
1349
4420
  }
@@ -1353,7 +4424,7 @@ var useKeyboardNavigation = ({
1353
4424
  // be often whilst scrolling - store range in a a ref ?
1354
4425
  [containerRef, getTableCell, requestScroll, viewportRange]
1355
4426
  );
1356
- const setActiveCell = (0, import_react12.useCallback)(
4427
+ const setActiveCell = (0, import_react18.useCallback)(
1357
4428
  (rowIdx, colIdx, fromKeyboard = false) => {
1358
4429
  const pos = [rowIdx, colIdx];
1359
4430
  activeCellPos.current = pos;
@@ -1364,12 +4435,12 @@ var useKeyboardNavigation = ({
1364
4435
  },
1365
4436
  [focusCell]
1366
4437
  );
1367
- const virtualizeActiveCell = (0, import_react12.useCallback)(() => {
4438
+ const virtualizeActiveCell = (0, import_react18.useCallback)(() => {
1368
4439
  var _a2;
1369
4440
  (_a2 = focusableCell.current) == null ? void 0 : _a2.setAttribute("tabindex", "");
1370
4441
  focusableCell.current = void 0;
1371
4442
  }, []);
1372
- const nextPageItemIdx = (0, import_react12.useCallback)(
4443
+ const nextPageItemIdx = (0, import_react18.useCallback)(
1373
4444
  async (key, cellPos) => {
1374
4445
  switch (key) {
1375
4446
  case PageDown:
@@ -1389,7 +4460,7 @@ var useKeyboardNavigation = ({
1389
4460
  },
1390
4461
  [requestScroll]
1391
4462
  );
1392
- const handleFocus = (0, import_react12.useCallback)(() => {
4463
+ const handleFocus = (0, import_react18.useCallback)(() => {
1393
4464
  var _a2;
1394
4465
  if (disableHighlightOnFocus !== true) {
1395
4466
  if ((_a2 = containerRef.current) == null ? void 0 : _a2.contains(document.activeElement)) {
@@ -1400,7 +4471,7 @@ var useKeyboardNavigation = ({
1400
4471
  }
1401
4472
  }
1402
4473
  }, [disableHighlightOnFocus, containerRef]);
1403
- const navigateChildItems = (0, import_react12.useCallback)(
4474
+ const navigateChildItems = (0, import_react18.useCallback)(
1404
4475
  async (key) => {
1405
4476
  const [nextRowIdx, nextColIdx] = isPagingKey(key) ? await nextPageItemIdx(key, activeCellPos.current) : nextCellPos(key, activeCellPos.current, columnCount, rowCount);
1406
4477
  const [rowIdx, colIdx] = activeCellPos.current;
@@ -1410,7 +4481,7 @@ var useKeyboardNavigation = ({
1410
4481
  },
1411
4482
  [columnCount, nextPageItemIdx, rowCount, setActiveCell]
1412
4483
  );
1413
- const handleKeyDown = (0, import_react12.useCallback)(
4484
+ const handleKeyDown = (0, import_react18.useCallback)(
1414
4485
  (e) => {
1415
4486
  if (data.length > 0 && isNavigationKey(e.key)) {
1416
4487
  e.preventDefault();
@@ -1420,7 +4491,7 @@ var useKeyboardNavigation = ({
1420
4491
  },
1421
4492
  [data, navigateChildItems]
1422
4493
  );
1423
- const handleClick = (0, import_react12.useCallback)(
4494
+ const handleClick = (0, import_react18.useCallback)(
1424
4495
  // Might not be a cell e.g the Settings button
1425
4496
  (evt) => {
1426
4497
  const target = evt.target;
@@ -1432,14 +4503,14 @@ var useKeyboardNavigation = ({
1432
4503
  },
1433
4504
  [setActiveCell]
1434
4505
  );
1435
- const containerProps = (0, import_react12.useMemo)(() => {
4506
+ const containerProps = (0, import_react18.useMemo)(() => {
1436
4507
  return {
1437
4508
  onClick: handleClick,
1438
4509
  onFocus: handleFocus,
1439
4510
  onKeyDown: handleKeyDown
1440
4511
  };
1441
4512
  }, [handleClick, handleFocus, handleKeyDown]);
1442
- (0, import_react12.useLayoutEffect)(() => {
4513
+ (0, import_react18.useLayoutEffect)(() => {
1443
4514
  const { current: cellPos } = activeCellPos;
1444
4515
  const withinViewport = cellPos[0] >= viewportFirstRow && cellPos[0] <= viewportLastRow;
1445
4516
  if (focusableCell.current && !withinViewport) {
@@ -1449,7 +4520,7 @@ var useKeyboardNavigation = ({
1449
4520
  }
1450
4521
  }, [focusCell, viewportFirstRow, viewportLastRow, virtualizeActiveCell]);
1451
4522
  const fullyRendered = ((_a = containerRef.current) == null ? void 0 : _a.firstChild) != null;
1452
- (0, import_react12.useEffect)(() => {
4523
+ (0, import_react18.useEffect)(() => {
1453
4524
  var _a2;
1454
4525
  if (fullyRendered && focusableCell.current === void 0) {
1455
4526
  const headerCell = (_a2 = containerRef.current) == null ? void 0 : _a2.querySelector(
@@ -1465,11 +4536,11 @@ var useKeyboardNavigation = ({
1465
4536
  };
1466
4537
 
1467
4538
  // src/useMeasuredContainer.ts
1468
- var import_vuu_utils9 = require("@vuu-ui/vuu-utils");
1469
- var import_react14 = require("react");
4539
+ var import_vuu_utils13 = require("@vuu-ui/vuu-utils");
4540
+ var import_react20 = require("react");
1470
4541
 
1471
4542
  // src/useResizeObserver.ts
1472
- var import_react13 = require("react");
4543
+ var import_react19 = require("react");
1473
4544
  var observedMap = /* @__PURE__ */ new Map();
1474
4545
  var getTargetSize = (element, size, dimension) => {
1475
4546
  switch (dimension) {
@@ -1520,8 +4591,8 @@ var resizeObserver = new ResizeObserver((entries) => {
1520
4591
  }
1521
4592
  });
1522
4593
  function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false) {
1523
- const dimensionsRef = (0, import_react13.useRef)(dimensions);
1524
- const measure = (0, import_react13.useCallback)((target) => {
4594
+ const dimensionsRef = (0, import_react19.useRef)(dimensions);
4595
+ const measure = (0, import_react19.useCallback)((target) => {
1525
4596
  const { width, height } = target.getBoundingClientRect();
1526
4597
  const { clientWidth: contentWidth, clientHeight: contentHeight } = target;
1527
4598
  return dimensionsRef.current.reduce(
@@ -1536,7 +4607,7 @@ function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false)
1536
4607
  {}
1537
4608
  );
1538
4609
  }, []);
1539
- (0, import_react13.useEffect)(() => {
4610
+ (0, import_react19.useEffect)(() => {
1540
4611
  const target = ref.current;
1541
4612
  async function registerObserver() {
1542
4613
  observedMap.set(target, { measurements: {} });
@@ -1571,7 +4642,7 @@ function useResizeObserver(ref, dimensions, onResize, reportInitialSize = false)
1571
4642
  }
1572
4643
  };
1573
4644
  }, [measure, ref]);
1574
- (0, import_react13.useEffect)(() => {
4645
+ (0, import_react19.useEffect)(() => {
1575
4646
  const target = ref.current;
1576
4647
  const record = observedMap.get(target);
1577
4648
  if (record) {
@@ -1590,7 +4661,7 @@ var ClientWidthHeight = ["clientHeight", "clientWidth"];
1590
4661
  var isNumber = (val) => Number.isFinite(val);
1591
4662
  var FULL_SIZE = { height: "100%", width: "100%" };
1592
4663
  var getInitialCssSize = (height, width) => {
1593
- if ((0, import_vuu_utils9.isValidNumber)(height) && (0, import_vuu_utils9.isValidNumber)(width)) {
4664
+ if ((0, import_vuu_utils13.isValidNumber)(height) && (0, import_vuu_utils13.isValidNumber)(width)) {
1594
4665
  return {
1595
4666
  height: `${height}px`,
1596
4667
  width: `${width}px`
@@ -1600,7 +4671,7 @@ var getInitialCssSize = (height, width) => {
1600
4671
  }
1601
4672
  };
1602
4673
  var getInitialInnerSize = (height, width) => {
1603
- if ((0, import_vuu_utils9.isValidNumber)(height) && (0, import_vuu_utils9.isValidNumber)(width)) {
4674
+ if ((0, import_vuu_utils13.isValidNumber)(height) && (0, import_vuu_utils13.isValidNumber)(width)) {
1604
4675
  return {
1605
4676
  height,
1606
4677
  width
@@ -1613,8 +4684,8 @@ var useMeasuredContainer = ({
1613
4684
  height,
1614
4685
  width
1615
4686
  }) => {
1616
- const containerRef = (0, import_react14.useRef)(null);
1617
- const [size, setSize] = (0, import_react14.useState)({
4687
+ const containerRef = (0, import_react20.useRef)(null);
4688
+ const [size, setSize] = (0, import_react20.useState)({
1618
4689
  css: getInitialCssSize(height, width),
1619
4690
  inner: getInitialInnerSize(height, width),
1620
4691
  outer: {
@@ -1622,15 +4693,15 @@ var useMeasuredContainer = ({
1622
4693
  width: width != null ? width : "100%"
1623
4694
  }
1624
4695
  });
1625
- (0, import_react14.useMemo)(() => {
4696
+ (0, import_react20.useMemo)(() => {
1626
4697
  setSize((currentSize) => {
1627
4698
  const { inner, outer } = currentSize;
1628
- if ((0, import_vuu_utils9.isValidNumber)(height) && (0, import_vuu_utils9.isValidNumber)(width) && inner && outer) {
4699
+ if ((0, import_vuu_utils13.isValidNumber)(height) && (0, import_vuu_utils13.isValidNumber)(width) && inner && outer) {
1629
4700
  const { height: innerHeight, width: innerWidth } = inner;
1630
4701
  const { height: outerHeight, width: outerWidth } = outer;
1631
4702
  if (outerHeight !== height || outerWidth !== width) {
1632
- const heightDiff = (0, import_vuu_utils9.isValidNumber)(outerHeight) ? outerHeight - innerHeight : 0;
1633
- const widthDiff = (0, import_vuu_utils9.isValidNumber)(outerWidth) ? outerWidth - innerWidth : 0;
4703
+ const heightDiff = (0, import_vuu_utils13.isValidNumber)(outerHeight) ? outerHeight - innerHeight : 0;
4704
+ const widthDiff = (0, import_vuu_utils13.isValidNumber)(outerWidth) ? outerWidth - innerWidth : 0;
1634
4705
  return {
1635
4706
  ...currentSize,
1636
4707
  outer: { height, width },
@@ -1641,7 +4712,7 @@ var useMeasuredContainer = ({
1641
4712
  return currentSize;
1642
4713
  });
1643
4714
  }, [height, width]);
1644
- const onResize = (0, import_react14.useCallback)(
4715
+ const onResize = (0, import_react20.useCallback)(
1645
4716
  ({ clientWidth, clientHeight }) => {
1646
4717
  setSize((currentSize) => {
1647
4718
  const { css, inner, outer } = currentSize;
@@ -1667,23 +4738,23 @@ var useMeasuredContainer = ({
1667
4738
  };
1668
4739
 
1669
4740
  // src/useSelection.ts
1670
- var import_vuu_utils10 = require("@vuu-ui/vuu-utils");
1671
- var import_react15 = require("react");
1672
- var { IDX: IDX2, SELECTED: SELECTED3 } = import_vuu_utils10.metadataKeys;
4741
+ var import_vuu_utils14 = require("@vuu-ui/vuu-utils");
4742
+ var import_react21 = require("react");
4743
+ var { IDX: IDX2 } = import_vuu_utils14.metadataKeys;
1673
4744
  var NO_SELECTION = [];
1674
4745
  var useSelection = ({
1675
4746
  selectionModel,
1676
4747
  onSelectionChange
1677
4748
  }) => {
1678
4749
  selectionModel === "extended" || selectionModel === "checkbox";
1679
- const lastActiveRef = (0, import_react15.useRef)(-1);
1680
- const selectedRef = (0, import_react15.useRef)(NO_SELECTION);
1681
- const handleSelectionChange = (0, import_react15.useCallback)(
4750
+ const lastActiveRef = (0, import_react21.useRef)(-1);
4751
+ const selectedRef = (0, import_react21.useRef)(NO_SELECTION);
4752
+ const handleSelectionChange = (0, import_react21.useCallback)(
1682
4753
  (row, rangeSelect, keepExistingSelection) => {
1683
- const { [IDX2]: idx, [SELECTED3]: isSelected } = row;
4754
+ const { [IDX2]: idx } = row;
1684
4755
  const { current: active } = lastActiveRef;
1685
4756
  const { current: selected } = selectedRef;
1686
- const selectOperation = isSelected ? import_vuu_utils10.deselectItem : import_vuu_utils10.selectItem;
4757
+ const selectOperation = (0, import_vuu_utils14.isRowSelected)(row) ? import_vuu_utils14.deselectItem : import_vuu_utils14.selectItem;
1687
4758
  const newSelected = selectOperation(
1688
4759
  selectionModel,
1689
4760
  selected,
@@ -1705,16 +4776,16 @@ var useSelection = ({
1705
4776
 
1706
4777
  // src/useTableModel.ts
1707
4778
  var import_salt_lab3 = require("@heswell/salt-lab");
1708
- var import_vuu_utils11 = require("@vuu-ui/vuu-utils");
1709
- var import_react16 = require("react");
1710
- var { info } = (0, import_vuu_utils11.logger)("useTableModel");
4779
+ var import_vuu_utils15 = require("@vuu-ui/vuu-utils");
4780
+ var import_react22 = require("react");
4781
+ var { info } = (0, import_vuu_utils15.logger)("useTableModel");
1711
4782
  var DEFAULT_COLUMN_WIDTH = 100;
1712
- var KEY_OFFSET = import_vuu_utils11.metadataKeys.count;
4783
+ var KEY_OFFSET = import_vuu_utils15.metadataKeys.count;
1713
4784
  var columnWithoutDataType = ({ serverDataType }) => serverDataType === void 0;
1714
4785
  var getCellRendererForColumn = (column) => {
1715
4786
  var _a;
1716
- if ((0, import_vuu_utils11.isTypeDescriptor)(column.type)) {
1717
- return (0, import_vuu_utils11.getCellRenderer)((_a = column.type) == null ? void 0 : _a.renderer);
4787
+ if ((0, import_vuu_utils15.isTypeDescriptor)(column.type)) {
4788
+ return (0, import_vuu_utils15.getCellRenderer)((_a = column.type) == null ? void 0 : _a.renderer);
1718
4789
  }
1719
4790
  };
1720
4791
  var getServerDataTypeForColumn = (column, tableSchema) => {
@@ -1732,8 +4803,8 @@ var getServerDataTypeForColumn = (column, tableSchema) => {
1732
4803
  };
1733
4804
  var numericTypes = ["int", "long", "double"];
1734
4805
  var getDefaultAlignment = (serverDataType) => serverDataType === void 0 ? void 0 : numericTypes.includes(serverDataType) ? "right" : "left";
4806
+ var isShowSettings = (action) => action.type === "columnSettings";
1735
4807
  var columnReducer = (state, action) => {
1736
- info == null ? void 0 : info(`GridModelReducer ${action.type}`);
1737
4808
  switch (action.type) {
1738
4809
  case "init":
1739
4810
  return init(action);
@@ -1759,7 +4830,7 @@ var columnReducer = (state, action) => {
1759
4830
  }
1760
4831
  };
1761
4832
  var useTableModel = (tableConfig, dataSourceConfig) => {
1762
- const [state, dispatchColumnAction] = (0, import_react16.useReducer)(columnReducer, { tableConfig, dataSourceConfig }, init);
4833
+ const [state, dispatchColumnAction] = (0, import_react22.useReducer)(columnReducer, { tableConfig, dataSourceConfig }, init);
1763
4834
  return {
1764
4835
  columns: state.columns,
1765
4836
  dispatchColumnAction,
@@ -1770,10 +4841,10 @@ function init({ dataSourceConfig, tableConfig }) {
1770
4841
  const columns = tableConfig.columns.map(
1771
4842
  toKeyedColumWithDefaults(tableConfig)
1772
4843
  );
1773
- const maybePinnedColumns = columns.some(import_vuu_utils11.isPinned) ? (0, import_vuu_utils11.sortPinnedColumns)(columns) : columns;
4844
+ const maybePinnedColumns = columns.some(import_vuu_utils15.isPinned) ? (0, import_vuu_utils15.sortPinnedColumns)(columns) : columns;
1774
4845
  const state = {
1775
4846
  columns: maybePinnedColumns,
1776
- headings: (0, import_vuu_utils11.getTableHeadings)(maybePinnedColumns)
4847
+ headings: (0, import_vuu_utils15.getTableHeadings)(maybePinnedColumns)
1777
4848
  };
1778
4849
  if (dataSourceConfig) {
1779
4850
  const { columns: columns2, ...rest } = dataSourceConfig;
@@ -1816,10 +4887,10 @@ var toKeyedColumWithDefaults = (options) => (column, index) => {
1816
4887
  name,
1817
4888
  originalIdx: index,
1818
4889
  serverDataType,
1819
- valueFormatter: (0, import_vuu_utils11.getValueFormatter)(column),
4890
+ valueFormatter: (0, import_vuu_utils15.getValueFormatter)(column),
1820
4891
  width
1821
4892
  };
1822
- if ((0, import_vuu_utils11.isGroupColumn)(keyedColumnWithDefaults)) {
4893
+ if ((0, import_vuu_utils15.isGroupColumn)(keyedColumnWithDefaults)) {
1823
4894
  keyedColumnWithDefaults.columns = keyedColumnWithDefaults.columns.map(
1824
4895
  (col) => toKeyedColumWithDefaults(options)(col, col.key)
1825
4896
  );
@@ -1885,8 +4956,9 @@ function resizeColumn(state, { column, phase, width }) {
1885
4956
  const resizing = phase !== "end";
1886
4957
  switch (phase) {
1887
4958
  case "begin":
1888
- case "end":
1889
4959
  return updateColumnProp(state, { type, column, resizing });
4960
+ case "end":
4961
+ return updateColumnProp(state, { type, column, resizing, width });
1890
4962
  case "resize":
1891
4963
  return updateColumnProp(state, { type, column, width });
1892
4964
  default:
@@ -1920,39 +4992,34 @@ function setTableSchema(state, { tableSchema }) {
1920
4992
  function pinColumn2(state, action) {
1921
4993
  let { columns } = state;
1922
4994
  const { column, pin } = action;
1923
- const targetColumn = columns.find((col) => col.name === column.name);
1924
- if (targetColumn) {
1925
- columns = replaceColumn(columns, { ...targetColumn, pin });
1926
- columns = (0, import_vuu_utils11.sortPinnedColumns)(columns);
1927
- return {
1928
- ...state,
1929
- columns
1930
- };
1931
- } else {
1932
- return state;
1933
- }
4995
+ columns = (0, import_vuu_utils15.updateColumn)(columns, column.name, { pin });
4996
+ columns = (0, import_vuu_utils15.sortPinnedColumns)(columns);
4997
+ console.log({ withPins: columns });
4998
+ return {
4999
+ ...state,
5000
+ columns
5001
+ };
1934
5002
  }
1935
5003
  function updateColumnProp(state, action) {
1936
5004
  let { columns } = state;
1937
5005
  const { align, column, hidden, label, resizing, width } = action;
1938
- const targetColumn = columns.find((col) => col.name === column.name);
1939
- if (targetColumn) {
1940
- if (align === "left" || align === "right") {
1941
- columns = replaceColumn(columns, { ...targetColumn, align });
1942
- }
1943
- if (typeof label === "string") {
1944
- columns = replaceColumn(columns, { ...targetColumn, label });
1945
- }
1946
- if (typeof resizing === "boolean") {
1947
- columns = replaceColumn(columns, { ...targetColumn, resizing });
1948
- }
1949
- if (typeof hidden === "boolean") {
1950
- columns = replaceColumn(columns, { ...targetColumn, hidden });
1951
- }
1952
- if (typeof width === "number") {
1953
- columns = replaceColumn(columns, { ...targetColumn, width });
1954
- }
5006
+ const options = {};
5007
+ if (align === "left" || align === "right") {
5008
+ options.align = align;
5009
+ }
5010
+ if (typeof label === "string") {
5011
+ options.label = label;
5012
+ }
5013
+ if (typeof resizing === "boolean") {
5014
+ options.resizing = resizing;
5015
+ }
5016
+ if (typeof hidden === "boolean") {
5017
+ options.hidden = hidden;
1955
5018
  }
5019
+ if (typeof width === "number") {
5020
+ options.width = width;
5021
+ }
5022
+ columns = (0, import_vuu_utils15.updateColumn)(columns, column.name, options);
1956
5023
  return {
1957
5024
  ...state,
1958
5025
  columns
@@ -1968,9 +5035,9 @@ function updateTableConfig(state, { columns, confirmed, filter, groupBy, sort })
1968
5035
  result = {
1969
5036
  ...state,
1970
5037
  columns: columns.map((colName, index) => {
1971
- const columnName = (0, import_vuu_utils11.getColumnName)(colName);
5038
+ const columnName = (0, import_vuu_utils15.getColumnName)(colName);
1972
5039
  const key = index + KEY_OFFSET;
1973
- const col = (0, import_vuu_utils11.findColumn)(result.columns, columnName);
5040
+ const col = (0, import_vuu_utils15.findColumn)(result.columns, columnName);
1974
5041
  if (col) {
1975
5042
  if (col.key === key) {
1976
5043
  return col;
@@ -1995,34 +5062,31 @@ function updateTableConfig(state, { columns, confirmed, filter, groupBy, sort })
1995
5062
  if (hasGroupBy) {
1996
5063
  result = {
1997
5064
  ...state,
1998
- columns: (0, import_vuu_utils11.applyGroupByToColumns)(result.columns, groupBy, confirmed)
5065
+ columns: (0, import_vuu_utils15.applyGroupByToColumns)(result.columns, groupBy, confirmed)
1999
5066
  };
2000
5067
  }
2001
5068
  if (hasSort) {
2002
5069
  result = {
2003
5070
  ...state,
2004
- columns: (0, import_vuu_utils11.applySortToColumns)(result.columns, sort)
5071
+ columns: (0, import_vuu_utils15.applySortToColumns)(result.columns, sort)
2005
5072
  };
2006
5073
  }
2007
5074
  if (hasFilter) {
2008
5075
  result = {
2009
5076
  ...state,
2010
- columns: (0, import_vuu_utils11.applyFilterToColumns)(result.columns, filter)
5077
+ columns: (0, import_vuu_utils15.applyFilterToColumns)(result.columns, filter)
2011
5078
  };
2012
- } else if (result.columns.some(import_vuu_utils11.isFilteredColumn)) {
5079
+ } else if (result.columns.some(import_vuu_utils15.isFilteredColumn)) {
2013
5080
  result = {
2014
5081
  ...state,
2015
- columns: (0, import_vuu_utils11.stripFilterFromColumns)(result.columns)
5082
+ columns: (0, import_vuu_utils15.stripFilterFromColumns)(result.columns)
2016
5083
  };
2017
5084
  }
2018
5085
  return result;
2019
5086
  }
2020
- function replaceColumn(state, column) {
2021
- return state.map((col) => col.name === column.name ? column : col);
2022
- }
2023
5087
 
2024
5088
  // src/useTableScroll.ts
2025
- var import_react17 = require("react");
5089
+ var import_react23 = require("react");
2026
5090
  var getPctScroll = (container) => {
2027
5091
  const { scrollLeft, scrollTop } = container;
2028
5092
  const { clientHeight, clientWidth, scrollHeight, scrollWidth } = container;
@@ -2038,8 +5102,8 @@ var useCallbackRef = ({
2038
5102
  onAttach,
2039
5103
  onDetach
2040
5104
  }) => {
2041
- const ref = (0, import_react17.useRef)(null);
2042
- const callbackRef = (0, import_react17.useCallback)(
5105
+ const ref = (0, import_react23.useRef)(null);
5106
+ const callbackRef = (0, import_react23.useCallback)(
2043
5107
  (el) => {
2044
5108
  if (el) {
2045
5109
  ref.current = el;
@@ -2059,15 +5123,15 @@ var useTableScroll = ({
2059
5123
  onVerticalScroll,
2060
5124
  viewport
2061
5125
  }) => {
2062
- const contentContainerScrolledRef = (0, import_react17.useRef)(false);
2063
- const scrollPosRef = (0, import_react17.useRef)({ scrollTop: 0, scrollLeft: 0 });
2064
- const scrollbarContainerRef = (0, import_react17.useRef)(null);
2065
- const contentContainerRef = (0, import_react17.useRef)(null);
5126
+ const contentContainerScrolledRef = (0, import_react23.useRef)(false);
5127
+ const scrollPosRef = (0, import_react23.useRef)({ scrollTop: 0, scrollLeft: 0 });
5128
+ const scrollbarContainerRef = (0, import_react23.useRef)(null);
5129
+ const contentContainerRef = (0, import_react23.useRef)(null);
2066
5130
  const {
2067
5131
  maxScrollContainerScrollHorizontal: maxScrollLeft,
2068
5132
  maxScrollContainerScrollVertical: maxScrollTop
2069
5133
  } = viewport;
2070
- const handleScrollbarContainerScroll = (0, import_react17.useCallback)(() => {
5134
+ const handleScrollbarContainerScroll = (0, import_react23.useCallback)(() => {
2071
5135
  const { current: contentContainer } = contentContainerRef;
2072
5136
  const { current: scrollbarContainer } = scrollbarContainerRef;
2073
5137
  const { current: contentContainerScrolled } = contentContainerScrolledRef;
@@ -2078,6 +5142,9 @@ var useTableScroll = ({
2078
5142
  const [maxScrollLeft2, maxScrollTop2] = getMaxScroll(contentContainer);
2079
5143
  const rootScrollLeft = Math.round(pctScrollLeft * maxScrollLeft2);
2080
5144
  const rootScrollTop = Math.round(pctScrollTop * maxScrollTop2);
5145
+ console.log(
5146
+ `pctScrollTop ${pctScrollTop}, maxScrollTop ${maxScrollTop2} rootScrollTop ${rootScrollTop}`
5147
+ );
2081
5148
  contentContainer.scrollTo({
2082
5149
  left: rootScrollLeft,
2083
5150
  top: rootScrollTop,
@@ -2085,7 +5152,7 @@ var useTableScroll = ({
2085
5152
  });
2086
5153
  }
2087
5154
  }, []);
2088
- const handleContentContainerScroll = (0, import_react17.useCallback)(() => {
5155
+ const handleContentContainerScroll = (0, import_react23.useCallback)(() => {
2089
5156
  const { current: contentContainer } = contentContainerRef;
2090
5157
  const { current: scrollbarContainer } = scrollbarContainerRef;
2091
5158
  const { current: scrollPos } = scrollPosRef;
@@ -2105,7 +5172,7 @@ var useTableScroll = ({
2105
5172
  }
2106
5173
  }
2107
5174
  }, [maxScrollLeft, maxScrollTop, onHorizontalScroll, onVerticalScroll]);
2108
- const handleAttachScrollbarContainer = (0, import_react17.useCallback)(
5175
+ const handleAttachScrollbarContainer = (0, import_react23.useCallback)(
2109
5176
  (el) => {
2110
5177
  scrollbarContainerRef.current = el;
2111
5178
  el.addEventListener("scroll", handleScrollbarContainerScroll, {
@@ -2114,14 +5181,14 @@ var useTableScroll = ({
2114
5181
  },
2115
5182
  [handleScrollbarContainerScroll]
2116
5183
  );
2117
- const handleDetachScrollbarContainer = (0, import_react17.useCallback)(
5184
+ const handleDetachScrollbarContainer = (0, import_react23.useCallback)(
2118
5185
  (el) => {
2119
5186
  scrollbarContainerRef.current = null;
2120
5187
  el.removeEventListener("scroll", handleScrollbarContainerScroll);
2121
5188
  },
2122
5189
  [handleScrollbarContainerScroll]
2123
5190
  );
2124
- const handleAttachContentContainer = (0, import_react17.useCallback)(
5191
+ const handleAttachContentContainer = (0, import_react23.useCallback)(
2125
5192
  (el) => {
2126
5193
  contentContainerRef.current = el;
2127
5194
  el.addEventListener("scroll", handleContentContainerScroll, {
@@ -2130,7 +5197,7 @@ var useTableScroll = ({
2130
5197
  },
2131
5198
  [handleContentContainerScroll]
2132
5199
  );
2133
- const handleDetachContentContainer = (0, import_react17.useCallback)(
5200
+ const handleDetachContentContainer = (0, import_react23.useCallback)(
2134
5201
  (el) => {
2135
5202
  contentContainerRef.current = null;
2136
5203
  el.removeEventListener("scroll", handleContentContainerScroll);
@@ -2145,7 +5212,7 @@ var useTableScroll = ({
2145
5212
  onAttach: handleAttachScrollbarContainer,
2146
5213
  onDetach: handleDetachScrollbarContainer
2147
5214
  });
2148
- const requestScroll = (0, import_react17.useCallback)(
5215
+ const requestScroll = (0, import_react23.useCallback)(
2149
5216
  (scrollRequest) => {
2150
5217
  const { current: scrollbarContainer } = contentContainerRef;
2151
5218
  if (scrollbarContainer) {
@@ -2187,8 +5254,8 @@ var useTableScroll = ({
2187
5254
  };
2188
5255
 
2189
5256
  // src/useTableViewport.ts
2190
- var import_react18 = require("react");
2191
- var import_vuu_utils12 = require("@vuu-ui/vuu-utils");
5257
+ var import_react24 = require("react");
5258
+ var import_vuu_utils16 = require("@vuu-ui/vuu-utils");
2192
5259
  var MAX_RAW_ROWS = 15e5;
2193
5260
  var UNMEASURED_VIEWPORT = {
2194
5261
  contentHeight: 0,
@@ -2221,7 +5288,11 @@ var measurePinnedColumns = (columns) => {
2221
5288
  unpinnedWidth += visibleWidth;
2222
5289
  }
2223
5290
  }
2224
- return { pinnedWidthLeft, pinnedWidthRight, unpinnedWidth };
5291
+ return {
5292
+ pinnedWidthLeft: pinnedWidthLeft + 4,
5293
+ pinnedWidthRight: pinnedWidthRight + 4,
5294
+ unpinnedWidth
5295
+ };
2225
5296
  };
2226
5297
  var useTableViewport = ({
2227
5298
  columns,
@@ -2231,22 +5302,22 @@ var useTableViewport = ({
2231
5302
  rowHeight,
2232
5303
  size
2233
5304
  }) => {
2234
- const pctScrollTopRef = (0, import_react18.useRef)(0);
5305
+ const pctScrollTopRef = (0, import_react24.useRef)(0);
2235
5306
  const appliedRowCount = Math.min(rowCount, MAX_RAW_ROWS);
2236
5307
  const appliedContentHeight = appliedRowCount * rowHeight;
2237
5308
  const virtualContentHeight = rowCount * rowHeight;
2238
5309
  const virtualisedExtent = virtualContentHeight - appliedContentHeight;
2239
- const { pinnedWidthLeft, pinnedWidthRight, unpinnedWidth } = (0, import_react18.useMemo)(
5310
+ const { pinnedWidthLeft, pinnedWidthRight, unpinnedWidth } = (0, import_react24.useMemo)(
2240
5311
  () => measurePinnedColumns(columns),
2241
5312
  [columns]
2242
5313
  );
2243
- const [actualRowOffset, actualRowAtPosition] = (0, import_react18.useMemo)(
2244
- () => (0, import_vuu_utils12.actualRowPositioning)(rowHeight),
5314
+ const [actualRowOffset, actualRowAtPosition] = (0, import_react24.useMemo)(
5315
+ () => (0, import_vuu_utils16.actualRowPositioning)(rowHeight),
2245
5316
  [rowHeight]
2246
5317
  );
2247
- const [getRowOffset, getRowAtPosition] = (0, import_react18.useMemo)(() => {
5318
+ const [getRowOffset, getRowAtPosition] = (0, import_react24.useMemo)(() => {
2248
5319
  if (virtualisedExtent) {
2249
- return (0, import_vuu_utils12.virtualRowPositioning)(
5320
+ return (0, import_vuu_utils16.virtualRowPositioning)(
2250
5321
  rowHeight,
2251
5322
  virtualisedExtent,
2252
5323
  pctScrollTopRef
@@ -2255,10 +5326,10 @@ var useTableViewport = ({
2255
5326
  return [actualRowOffset, actualRowAtPosition];
2256
5327
  }
2257
5328
  }, [actualRowAtPosition, actualRowOffset, virtualisedExtent, rowHeight]);
2258
- const setPctScrollTop = (0, import_react18.useCallback)((scrollPct) => {
5329
+ const setPctScrollTop = (0, import_react24.useCallback)((scrollPct) => {
2259
5330
  pctScrollTopRef.current = scrollPct;
2260
5331
  }, []);
2261
- return (0, import_react18.useMemo)(() => {
5332
+ return (0, import_react24.useMemo)(() => {
2262
5333
  var _a;
2263
5334
  if (size) {
2264
5335
  const headingsDepth = headings.length;
@@ -2307,51 +5378,51 @@ var useTableViewport = ({
2307
5378
  };
2308
5379
 
2309
5380
  // src/useVirtualViewport.ts
2310
- var import_vuu_utils13 = require("@vuu-ui/vuu-utils");
2311
- var import_react19 = require("react");
5381
+ var import_vuu_utils17 = require("@vuu-ui/vuu-utils");
5382
+ var import_react25 = require("react");
2312
5383
  var useVirtualViewport = ({
2313
5384
  columns,
2314
5385
  getRowAtPosition,
2315
5386
  setRange,
2316
5387
  viewportMeasurements
2317
5388
  }) => {
2318
- const firstRowRef = (0, import_react19.useRef)(-1);
5389
+ const firstRowRef = (0, import_react25.useRef)(-1);
2319
5390
  const {
2320
5391
  rowCount: viewportRowCount,
2321
5392
  contentWidth,
2322
5393
  maxScrollContainerScrollHorizontal
2323
5394
  } = viewportMeasurements;
2324
5395
  const availableWidth = contentWidth - maxScrollContainerScrollHorizontal;
2325
- const scrollLeftRef = (0, import_react19.useRef)(0);
2326
- const [visibleColumns, preSpan] = (0, import_react19.useMemo)(
2327
- () => (0, import_vuu_utils13.getColumnsInViewport)(
5396
+ const scrollLeftRef = (0, import_react25.useRef)(0);
5397
+ const [visibleColumns, preSpan] = (0, import_react25.useMemo)(
5398
+ () => (0, import_vuu_utils17.getColumnsInViewport)(
2328
5399
  columns,
2329
5400
  scrollLeftRef.current,
2330
5401
  scrollLeftRef.current + availableWidth
2331
5402
  ),
2332
5403
  [availableWidth, columns]
2333
5404
  );
2334
- const preSpanRef = (0, import_react19.useRef)(preSpan);
2335
- (0, import_react19.useEffect)(() => {
5405
+ const preSpanRef = (0, import_react25.useRef)(preSpan);
5406
+ (0, import_react25.useEffect)(() => {
2336
5407
  setColumnsWithinViewport(visibleColumns);
2337
5408
  }, [visibleColumns]);
2338
- const [columnsWithinViewport, setColumnsWithinViewport] = (0, import_react19.useState)(visibleColumns);
2339
- const handleHorizontalScroll = (0, import_react19.useCallback)(
5409
+ const [columnsWithinViewport, setColumnsWithinViewport] = (0, import_react25.useState)(visibleColumns);
5410
+ const handleHorizontalScroll = (0, import_react25.useCallback)(
2340
5411
  (scrollLeft) => {
2341
5412
  scrollLeftRef.current = scrollLeft;
2342
- const [visibleColumns2, pre] = (0, import_vuu_utils13.getColumnsInViewport)(
5413
+ const [visibleColumns2, pre] = (0, import_vuu_utils17.getColumnsInViewport)(
2343
5414
  columns,
2344
5415
  scrollLeft,
2345
5416
  scrollLeft + availableWidth
2346
5417
  );
2347
- if ((0, import_vuu_utils13.itemsChanged)(columnsWithinViewport, visibleColumns2)) {
5418
+ if ((0, import_vuu_utils17.itemsChanged)(columnsWithinViewport, visibleColumns2)) {
2348
5419
  preSpanRef.current = pre;
2349
5420
  setColumnsWithinViewport(visibleColumns2);
2350
5421
  }
2351
5422
  },
2352
5423
  [availableWidth, columns, columnsWithinViewport]
2353
5424
  );
2354
- const handleVerticalScroll = (0, import_react19.useCallback)(
5425
+ const handleVerticalScroll = (0, import_react25.useCallback)(
2355
5426
  (scrollTop) => {
2356
5427
  const firstRow = getRowAtPosition(scrollTop);
2357
5428
  if (firstRow !== firstRowRef.current) {
@@ -2372,7 +5443,7 @@ var useVirtualViewport = ({
2372
5443
 
2373
5444
  // src/useTable.ts
2374
5445
  var NO_ROWS = [];
2375
- var { KEY: KEY2, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } = import_vuu_utils14.metadataKeys;
5446
+ var { KEY: KEY3, IS_EXPANDED: IS_EXPANDED2, IS_LEAF: IS_LEAF2 } = import_vuu_utils18.metadataKeys;
2376
5447
  var useTable = ({
2377
5448
  config,
2378
5449
  dataSource,
@@ -2387,15 +5458,15 @@ var useTable = ({
2387
5458
  ...measuredProps
2388
5459
  }) => {
2389
5460
  var _a, _b;
2390
- const [rowCount, setRowCount] = (0, import_react20.useState)(dataSource.size);
2391
- const expectConfigChangeRef = (0, import_react20.useRef)(false);
2392
- const dataSourceRef = (0, import_react20.useRef)();
5461
+ const [rowCount, setRowCount] = (0, import_react26.useState)(dataSource.size);
5462
+ const expectConfigChangeRef = (0, import_react26.useRef)(false);
5463
+ const dataSourceRef = (0, import_react26.useRef)();
2393
5464
  dataSourceRef.current = dataSource;
2394
5465
  if (dataSource === void 0) {
2395
5466
  throw Error("no data source provided to Vuu Table");
2396
5467
  }
2397
5468
  const containerMeasurements = useMeasuredContainer(measuredProps);
2398
- const onDataRowcountChange = (0, import_react20.useCallback)((size) => {
5469
+ const onDataRowcountChange = (0, import_react26.useCallback)((size) => {
2399
5470
  setRowCount(size);
2400
5471
  }, []);
2401
5472
  const { columns, dispatchColumnAction, headings } = useTableModel(
@@ -2415,7 +5486,7 @@ var useTable = ({
2415
5486
  rowHeight,
2416
5487
  size: containerMeasurements.innerSize
2417
5488
  });
2418
- const onSubscribed = (0, import_react20.useCallback)(
5489
+ const onSubscribed = (0, import_react26.useCallback)(
2419
5490
  ({ tableSchema }) => {
2420
5491
  if (tableSchema) {
2421
5492
  expectConfigChangeRef.current = true;
@@ -2429,7 +5500,7 @@ var useTable = ({
2429
5500
  },
2430
5501
  [dispatchColumnAction]
2431
5502
  );
2432
- const handleSelectionChange = (0, import_react20.useCallback)(
5503
+ const handleSelectionChange = (0, import_react26.useCallback)(
2433
5504
  (selected) => {
2434
5505
  dataSource.select(selected);
2435
5506
  onSelectionChange == null ? void 0 : onSelectionChange(selected);
@@ -2449,9 +5520,9 @@ var useTable = ({
2449
5520
  renderBufferSize,
2450
5521
  viewportRowCount: viewportMeasurements.rowCount
2451
5522
  });
2452
- const dataRef = (0, import_react20.useRef)();
5523
+ const dataRef = (0, import_react26.useRef)();
2453
5524
  dataRef.current = data;
2454
- const onPersistentColumnOperation = (0, import_react20.useCallback)(
5525
+ const onPersistentColumnOperation = (0, import_react26.useCallback)(
2455
5526
  (action) => {
2456
5527
  expectConfigChangeRef.current = true;
2457
5528
  dispatchColumnAction(action);
@@ -2462,10 +5533,10 @@ var useTable = ({
2462
5533
  dataSource,
2463
5534
  onPersistentColumnOperation
2464
5535
  });
2465
- const handleSort = (0, import_react20.useCallback)(
5536
+ const handleSort = (0, import_react26.useCallback)(
2466
5537
  (column, extendSort = false, sortType) => {
2467
5538
  if (dataSource) {
2468
- dataSource.sort = (0, import_vuu_utils14.applySort)(
5539
+ dataSource.sort = (0, import_vuu_utils18.applySort)(
2469
5540
  dataSource.sort,
2470
5541
  column,
2471
5542
  extendSort,
@@ -2475,7 +5546,7 @@ var useTable = ({
2475
5546
  },
2476
5547
  [dataSource]
2477
5548
  );
2478
- const handleColumnResize = (0, import_react20.useCallback)(
5549
+ const handleColumnResize = (0, import_react26.useCallback)(
2479
5550
  (phase, columnName, width) => {
2480
5551
  const column = columns.find((column2) => column2.name === columnName);
2481
5552
  if (column) {
@@ -2496,10 +5567,10 @@ var useTable = ({
2496
5567
  },
2497
5568
  [columns, dispatchColumnAction]
2498
5569
  );
2499
- const handleToggleGroup = (0, import_react20.useCallback)(
5570
+ const handleToggleGroup = (0, import_react26.useCallback)(
2500
5571
  (row, column) => {
2501
- const isJson = (0, import_vuu_utils14.isJsonGroup)(column, row);
2502
- const key = row[KEY2];
5572
+ const isJson = (0, import_vuu_utils18.isJsonGroup)(column, row);
5573
+ const key = row[KEY3];
2503
5574
  if (row[IS_EXPANDED2]) {
2504
5575
  dataSource.closeTreeNode(key, true);
2505
5576
  if (isJson) {
@@ -2543,7 +5614,7 @@ var useTable = ({
2543
5614
  setRange,
2544
5615
  viewportMeasurements
2545
5616
  });
2546
- const handleVerticalScroll = (0, import_react20.useCallback)(
5617
+ const handleVerticalScroll = (0, import_react26.useCallback)(
2547
5618
  (scrollTop, pctScrollTop) => {
2548
5619
  setPctScrollTop(pctScrollTop);
2549
5620
  onVerticalScroll(scrollTop);
@@ -2564,7 +5635,7 @@ var useTable = ({
2564
5635
  rowCount: dataSource == null ? void 0 : dataSource.size,
2565
5636
  viewportRange: range
2566
5637
  });
2567
- const handleRemoveColumnFromGroupBy = (0, import_react20.useCallback)(
5638
+ const handleRemoveColumnFromGroupBy = (0, import_react26.useCallback)(
2568
5639
  (column) => {
2569
5640
  if (column) {
2570
5641
  if (dataSource && dataSource.groupBy.includes(column.name)) {
@@ -2578,10 +5649,10 @@ var useTable = ({
2578
5649
  },
2579
5650
  [dataSource]
2580
5651
  );
2581
- const handleDropColumn = (0, import_react20.useCallback)(
5652
+ const handleDropColumn = (0, import_react26.useCallback)(
2582
5653
  (fromIndex, toIndex) => {
2583
5654
  const column = dataSource.columns[fromIndex];
2584
- const columns2 = (0, import_vuu_utils14.moveItem)(dataSource.columns, column, toIndex);
5655
+ const columns2 = (0, import_vuu_utils18.moveItem)(dataSource.columns, column, toIndex);
2585
5656
  if (columns2 !== dataSource.columns) {
2586
5657
  dataSource.columns = columns2;
2587
5658
  dispatchColumnAction({ type: "tableConfig", columns: columns2 });
@@ -2592,7 +5663,7 @@ var useTable = ({
2592
5663
  const draggableHook = useDraggableColumn({
2593
5664
  onDrop: handleDropColumn
2594
5665
  });
2595
- (0, import_react20.useEffect)(() => {
5666
+ (0, import_react26.useEffect)(() => {
2596
5667
  if (dataSourceRef.current) {
2597
5668
  expectConfigChangeRef.current = true;
2598
5669
  dispatchColumnAction({
@@ -2602,7 +5673,7 @@ var useTable = ({
2602
5673
  });
2603
5674
  }
2604
5675
  }, [config, dispatchColumnAction]);
2605
- (0, import_react20.useEffect)(() => {
5676
+ (0, import_react26.useEffect)(() => {
2606
5677
  dataSource.on("config", (config2, confirmed) => {
2607
5678
  expectConfigChangeRef.current = true;
2608
5679
  dispatchColumnAction({
@@ -2612,7 +5683,7 @@ var useTable = ({
2612
5683
  });
2613
5684
  });
2614
5685
  }, [dataSource, dispatchColumnAction]);
2615
- (0, import_react20.useMemo)(() => {
5686
+ (0, import_react26.useMemo)(() => {
2616
5687
  if (expectConfigChangeRef.current) {
2617
5688
  onConfigChange == null ? void 0 : onConfigChange({
2618
5689
  ...config,
@@ -2622,7 +5693,7 @@ var useTable = ({
2622
5693
  }
2623
5694
  }, [columns, config, onConfigChange]);
2624
5695
  const showContextMenu = (0, import_vuu_popups3.useContextMenu)();
2625
- const onContextMenu = (0, import_react20.useCallback)(
5696
+ const onContextMenu = (0, import_react26.useCallback)(
2626
5697
  (evt) => {
2627
5698
  var _a2;
2628
5699
  const { current: currentData } = dataRef;
@@ -2632,7 +5703,7 @@ var useTable = ({
2632
5703
  const rowEl = target == null ? void 0 : target.closest(".vuuTableRow");
2633
5704
  if (cellEl && rowEl && currentData && currentDataSource) {
2634
5705
  const { columns: columns2, selectedRowsCount } = currentDataSource;
2635
- const columnMap = (0, import_vuu_utils14.buildColumnMap)(columns2);
5706
+ const columnMap = (0, import_vuu_utils18.buildColumnMap)(columns2);
2636
5707
  const rowIndex = parseInt((_a2 = rowEl.ariaRowIndex) != null ? _a2 : "-1");
2637
5708
  const cellIndex = Array.from(rowEl.childNodes).indexOf(cellEl);
2638
5709
  const row = currentData.find(([idx]) => idx === rowIndex);
@@ -2674,7 +5745,7 @@ var useTable = ({
2674
5745
 
2675
5746
  // src/Table.tsx
2676
5747
  var import_classnames7 = __toESM(require("classnames"));
2677
- var import_vuu_utils15 = require("@vuu-ui/vuu-utils");
5748
+ var import_vuu_utils19 = require("@vuu-ui/vuu-utils");
2678
5749
  var import_jsx_runtime10 = require("react/jsx-runtime");
2679
5750
  var classBase6 = "vuuTable";
2680
5751
  var Table = ({
@@ -2740,7 +5811,7 @@ var Table = ({
2740
5811
  };
2741
5812
  const className = (0, import_classnames7.default)(classBase6, classNameProp, {
2742
5813
  [`${classBase6}-zebra`]: zebraStripes,
2743
- [`${classBase6}-loading`]: (0, import_vuu_utils15.isDataLoading)(tableProps.columns)
5814
+ [`${classBase6}-loading`]: (0, import_vuu_utils19.isDataLoading)(tableProps.columns)
2744
5815
  });
2745
5816
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2746
5817
  import_vuu_popups4.ContextMenuProvider,
@@ -2802,10 +5873,10 @@ var Table = ({
2802
5873
 
2803
5874
  // src/cell-renderers/json-cell/JsonCell.tsx
2804
5875
  var import_classnames8 = __toESM(require("classnames"));
2805
- var import_vuu_utils16 = require("@vuu-ui/vuu-utils");
5876
+ var import_vuu_utils20 = require("@vuu-ui/vuu-utils");
2806
5877
  var import_jsx_runtime11 = require("react/jsx-runtime");
2807
5878
  var classBase7 = "vuuJsonCell";
2808
- var { IS_EXPANDED: IS_EXPANDED3, KEY: KEY3 } = import_vuu_utils16.metadataKeys;
5879
+ var { IS_EXPANDED: IS_EXPANDED3, KEY: KEY4 } = import_vuu_utils20.metadataKeys;
2809
5880
  var localKey = (key) => {
2810
5881
  const pos = key.lastIndexOf("|");
2811
5882
  if (pos === -1) {
@@ -2821,11 +5892,11 @@ var JsonCell = ({ column, row }) => {
2821
5892
  } = column;
2822
5893
  let value = row[columnKey];
2823
5894
  let isToggle = false;
2824
- if ((0, import_vuu_utils16.isJsonAttribute)(value)) {
5895
+ if ((0, import_vuu_utils20.isJsonAttribute)(value)) {
2825
5896
  value = value.slice(0, -1);
2826
5897
  isToggle = true;
2827
5898
  }
2828
- const rowKey = localKey(row[KEY3]);
5899
+ const rowKey = localKey(row[KEY4]);
2829
5900
  const className = (0, import_classnames8.default)({
2830
5901
  [`${classBase7}-name`]: rowKey === value,
2831
5902
  [`${classBase7}-value`]: rowKey !== value,
@@ -2843,5 +5914,5 @@ var JsonCell = ({ column, row }) => {
2843
5914
  return null;
2844
5915
  }
2845
5916
  };
2846
- (0, import_vuu_utils16.registerComponent)("json", JsonCell, "cell-renderer", {});
5917
+ (0, import_vuu_utils20.registerComponent)("json", JsonCell, "cell-renderer", {});
2847
5918
  //# sourceMappingURL=index.js.map