@vitessce/sets-utils 3.3.3 → 3.3.5

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/dist/index.js CHANGED
@@ -2426,9 +2426,6 @@ var pluralizeExports = pluralize.exports;
2426
2426
  const plur = /* @__PURE__ */ getDefaultExportFromCjs(pluralizeExports);
2427
2427
  plur.addPluralRule("glomerulus", "glomeruli");
2428
2428
  plur.addPluralRule("interstitium", "interstitia");
2429
- function fromEntries(iterable) {
2430
- return [...iterable].reduce((obj, { 0: key, 1: val }) => Object.assign(obj, { [key]: val }), {});
2431
- }
2432
2429
  function capitalize(word) {
2433
2430
  return word ? word.charAt(0).toUpperCase() + word.slice(1) : "";
2434
2431
  }
@@ -9050,6 +9047,7 @@ const FileType$1 = {
9050
9047
  OBS_SEGMENTATIONS_OME_ZARR: "obsSegmentations.ome-zarr",
9051
9048
  // AnnData
9052
9049
  OBS_FEATURE_MATRIX_ANNDATA_ZARR: "obsFeatureMatrix.anndata.zarr",
9050
+ OBS_FEATURE_COLUMNS_ANNDATA_ZARR: "obsFeatureColumns.anndata.zarr",
9053
9051
  OBS_SETS_ANNDATA_ZARR: "obsSets.anndata.zarr",
9054
9052
  OBS_EMBEDDING_ANNDATA_ZARR: "obsEmbedding.anndata.zarr",
9055
9053
  OBS_SPOTS_ANNDATA_ZARR: "obsSpots.anndata.zarr",
@@ -9406,7 +9404,7 @@ function configSchemaToVersion(zodSchema) {
9406
9404
  return zodSchema.shape.version._def.value;
9407
9405
  }
9408
9406
  ({
9409
- ...fromEntries(SCHEMA_HANDLERS.map(([zodSchema]) => {
9407
+ ...Object.fromEntries(SCHEMA_HANDLERS.map(([zodSchema]) => {
9410
9408
  const version = configSchemaToVersion(zodSchema);
9411
9409
  return [version, zodSchema];
9412
9410
  })),
@@ -9482,6 +9480,9 @@ const annDataObsSets = z.array(z.object({
9482
9480
  ]),
9483
9481
  scorePath: z.string().optional().describe("The location in the AnnData store for the set confidence scores, like 'obs/celltype_prediction_score.'")
9484
9482
  }));
9483
+ z.array(z.object({
9484
+ path: z.string()
9485
+ }));
9485
9486
  const annDataObsSpots = annDataObsm;
9486
9487
  const annDataObsPoints = annDataObsm;
9487
9488
  const annDataObsLocations = annDataObsm;
@@ -9671,6 +9672,20 @@ z.object({
9671
9672
  radius: z.number(),
9672
9673
  opacity: z.number()
9673
9674
  });
9675
+ const FILE_EXTENSION_JSON = "json";
9676
+ const MIME_TYPE_JSON = "application/json";
9677
+ const FILE_EXTENSION_TABULAR = "csv";
9678
+ const MIME_TYPE_TABULAR = "text/csv";
9679
+ const SEPARATOR_TABULAR = ",";
9680
+ const NA_VALUE_TABULAR = "NA";
9681
+ const SETS_DATATYPE_OBS = "obs";
9682
+ const HIERARCHICAL_SCHEMAS = {
9683
+ latestVersion: "0.1.3",
9684
+ schema: obsSetsSchema
9685
+ };
9686
+ const TABULAR_SCHEMAS = {
9687
+ schema: obsSetsTabularSchema
9688
+ };
9674
9689
  var tinycolor$1 = { exports: {} };
9675
9690
  (function(module2) {
9676
9691
  (function(Math2) {
@@ -10585,930 +10600,1567 @@ var tinycolor$1 = { exports: {} };
10585
10600
  })(tinycolor$1);
10586
10601
  var tinycolorExports = tinycolor$1.exports;
10587
10602
  const tinycolor = /* @__PURE__ */ getDefaultExportFromCjs(tinycolorExports);
10588
- var EOL = {}, EOF = {}, QUOTE = 34, NEWLINE = 10, RETURN = 13;
10589
- function objectConverter(columns) {
10590
- return new Function("d", "return {" + columns.map(function(name, i) {
10591
- return JSON.stringify(name) + ": d[" + i + '] || ""';
10592
- }).join(",") + "}");
10593
- }
10594
- function customConverter(columns, f) {
10595
- var object = objectConverter(columns);
10596
- return function(row, i) {
10597
- return f(object(row), i, columns);
10598
- };
10603
+ function callbackOnKeyPress(event, key, callback) {
10604
+ if (event.key === key) {
10605
+ event.preventDefault();
10606
+ callback();
10607
+ }
10599
10608
  }
10600
- function inferColumns(rows) {
10601
- var columnSet = /* @__PURE__ */ Object.create(null), columns = [];
10602
- rows.forEach(function(row) {
10603
- for (var column in row) {
10604
- if (!(column in columnSet)) {
10605
- columns.push(columnSet[column] = column);
10606
- }
10607
- }
10608
- });
10609
- return columns;
10609
+ function colorArrayToString(rgbArray2) {
10610
+ return tinycolor({ r: rgbArray2[0], g: rgbArray2[1], b: rgbArray2[2] }).toHexString();
10610
10611
  }
10611
- function pad(value, width) {
10612
- var s = value + "", length = s.length;
10613
- return length < width ? new Array(width - length + 1).join(0) + s : s;
10612
+ function colorStringToArray(colorString) {
10613
+ const colorObj = tinycolor(colorString).toRgb();
10614
+ return [colorObj.r, colorObj.g, colorObj.b];
10614
10615
  }
10615
- function formatYear(year) {
10616
- return year < 0 ? "-" + pad(-year, 6) : year > 9999 ? "+" + pad(year, 6) : pad(year, 4);
10616
+ function getLevelTooltipText(i) {
10617
+ if (i === 0)
10618
+ return "Color by hierarchy";
10619
+ if (i <= 2) {
10620
+ const subs = (j) => "sub".repeat(j);
10621
+ return `Color by ${subs(i - 1)}cluster`;
10622
+ }
10623
+ return `Color by cluster level ${i}`;
10617
10624
  }
10618
- function formatDate(date) {
10619
- var hours = date.getUTCHours(), minutes = date.getUTCMinutes(), seconds = date.getUTCSeconds(), milliseconds = date.getUTCMilliseconds();
10620
- return isNaN(date) ? "Invalid Date" : formatYear(date.getUTCFullYear()) + "-" + pad(date.getUTCMonth() + 1, 2) + "-" + pad(date.getUTCDate(), 2) + (milliseconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "." + pad(milliseconds, 3) + "Z" : seconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "Z" : minutes || hours ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + "Z" : "");
10625
+ function isEqualOrPrefix(targetPath, testPath) {
10626
+ if (targetPath.length <= testPath.length) {
10627
+ return isEqual(targetPath, testPath.slice(0, targetPath.length));
10628
+ }
10629
+ return false;
10621
10630
  }
10622
- function dsvFormat(delimiter) {
10623
- var reFormat = new RegExp('["' + delimiter + "\n\r]"), DELIMITER = delimiter.charCodeAt(0);
10624
- function parse2(text, f) {
10625
- var convert, columns, rows = parseRows(text, function(row, i) {
10626
- if (convert)
10627
- return convert(row, i - 1);
10628
- columns = row, convert = f ? customConverter(row, f) : objectConverter(row);
10629
- });
10630
- rows.columns = columns || [];
10631
- return rows;
10631
+ function tryRenamePath(targetPath, testPath, nextTargetPath) {
10632
+ if (isEqualOrPrefix(targetPath, testPath)) {
10633
+ return [...nextTargetPath, ...testPath.slice(nextTargetPath.length)];
10632
10634
  }
10633
- function parseRows(text, f) {
10634
- var rows = [], N = text.length, I = 0, n = 0, t2, eof = N <= 0, eol = false;
10635
- if (text.charCodeAt(N - 1) === NEWLINE)
10636
- --N;
10637
- if (text.charCodeAt(N - 1) === RETURN)
10638
- --N;
10639
- function token() {
10640
- if (eof)
10641
- return EOF;
10642
- if (eol)
10643
- return eol = false, EOL;
10644
- var i, j = I, c;
10645
- if (text.charCodeAt(j) === QUOTE) {
10646
- while (I++ < N && text.charCodeAt(I) !== QUOTE || text.charCodeAt(++I) === QUOTE)
10647
- ;
10648
- if ((i = I) >= N)
10649
- eof = true;
10650
- else if ((c = text.charCodeAt(I++)) === NEWLINE)
10651
- eol = true;
10652
- else if (c === RETURN) {
10653
- eol = true;
10654
- if (text.charCodeAt(I) === NEWLINE)
10655
- ++I;
10656
- }
10657
- return text.slice(j + 1, i - 1).replace(/""/g, '"');
10658
- }
10659
- while (I < N) {
10660
- if ((c = text.charCodeAt(i = I++)) === NEWLINE)
10661
- eol = true;
10662
- else if (c === RETURN) {
10663
- eol = true;
10664
- if (text.charCodeAt(I) === NEWLINE)
10665
- ++I;
10666
- } else if (c !== DELIMITER)
10667
- continue;
10668
- return text.slice(j, i);
10669
- }
10670
- return eof = true, text.slice(j, N);
10671
- }
10672
- while ((t2 = token()) !== EOF) {
10673
- var row = [];
10674
- while (t2 !== EOL && t2 !== EOF)
10675
- row.push(t2), t2 = token();
10676
- if (f && (row = f(row, n++)) == null)
10677
- continue;
10678
- rows.push(row);
10635
+ return testPath;
10636
+ }
10637
+ const PATH_SEP = "___";
10638
+ function pathToKey(path) {
10639
+ return path.join(PATH_SEP);
10640
+ }
10641
+ function getNextNumberedNodeName(nodes, prefix, suffix) {
10642
+ let i = 1;
10643
+ if (nodes) {
10644
+ while (nodes.find((n) => n.name.includes(`${prefix}${i}`))) {
10645
+ i++;
10679
10646
  }
10680
- return rows;
10681
10647
  }
10682
- function preformatBody(rows, columns) {
10683
- return rows.map(function(row) {
10684
- return columns.map(function(column) {
10685
- return formatValue(row[column]);
10686
- }).join(delimiter);
10648
+ return `${prefix}${i}${suffix}`;
10649
+ }
10650
+ function setObsSelection(cellSelection, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding, prefix = "Selection ", suffix = "") {
10651
+ const CELL_SELECTIONS_LEVEL_ZERO_NAME = "My Selections";
10652
+ const selectionsLevelZeroNode = additionalCellSets == null ? void 0 : additionalCellSets.tree.find(
10653
+ (n) => n.name === CELL_SELECTIONS_LEVEL_ZERO_NAME
10654
+ );
10655
+ const nextAdditionalCellSets = {
10656
+ version: HIERARCHICAL_SCHEMAS.latestVersion,
10657
+ datatype: SETS_DATATYPE_OBS,
10658
+ tree: [...additionalCellSets ? additionalCellSets.tree : []]
10659
+ };
10660
+ const nextName = getNextNumberedNodeName(selectionsLevelZeroNode == null ? void 0 : selectionsLevelZeroNode.children, prefix, suffix);
10661
+ let colorIndex = 0;
10662
+ if (selectionsLevelZeroNode) {
10663
+ colorIndex = selectionsLevelZeroNode.children.length;
10664
+ selectionsLevelZeroNode.children.push({
10665
+ name: nextName,
10666
+ set: cellSelection.map((d) => [d, null])
10667
+ });
10668
+ } else {
10669
+ nextAdditionalCellSets.tree.push({
10670
+ name: CELL_SELECTIONS_LEVEL_ZERO_NAME,
10671
+ children: [
10672
+ {
10673
+ name: nextName,
10674
+ set: cellSelection.map((d) => [d, null])
10675
+ }
10676
+ ]
10687
10677
  });
10688
10678
  }
10689
- function format(rows, columns) {
10690
- if (columns == null)
10691
- columns = inferColumns(rows);
10692
- return [columns.map(formatValue).join(delimiter)].concat(preformatBody(rows, columns)).join("\n");
10679
+ setAdditionalCellSets(nextAdditionalCellSets);
10680
+ const nextPath = ["My Selections", nextName];
10681
+ setCellSetColor([
10682
+ ...cellSetColor || [],
10683
+ {
10684
+ path: nextPath,
10685
+ color: PALETTE[colorIndex % PALETTE.length]
10686
+ }
10687
+ ]);
10688
+ setCellSetSelection([nextPath]);
10689
+ setCellColorEncoding("cellSetSelection");
10690
+ }
10691
+ function mergeObsSets(cellSets, additionalCellSets) {
10692
+ return {
10693
+ version: HIERARCHICAL_SCHEMAS.latestVersion,
10694
+ datatype: SETS_DATATYPE_OBS,
10695
+ tree: [
10696
+ ...cellSets ? cellSets.tree : [],
10697
+ ...additionalCellSets ? additionalCellSets.tree : []
10698
+ ]
10699
+ };
10700
+ }
10701
+ function getObsInfoFromDataWithinRange(range2, data) {
10702
+ const [lowerBound, upperBound] = range2;
10703
+ const cellIds = data.filter((item) => item.value >= lowerBound && item.value <= upperBound).map((item) => item.cellId);
10704
+ return cellIds;
10705
+ }
10706
+ function generateKey() {
10707
+ return v4();
10708
+ }
10709
+ function nodeToSet(currNode) {
10710
+ if (!currNode) {
10711
+ return [];
10693
10712
  }
10694
- function formatBody(rows, columns) {
10695
- if (columns == null)
10696
- columns = inferColumns(rows);
10697
- return preformatBody(rows, columns).join("\n");
10713
+ if (!currNode.children) {
10714
+ return currNode.set || [];
10698
10715
  }
10699
- function formatRows(rows) {
10700
- return rows.map(formatRow).join("\n");
10716
+ return currNode.children.flatMap((c) => nodeToSet(c));
10717
+ }
10718
+ function nodeToHeight(currNode, level = 0) {
10719
+ if (!currNode.children) {
10720
+ return level;
10701
10721
  }
10702
- function formatRow(row) {
10703
- return row.map(formatValue).join(delimiter);
10722
+ const newLevel = level + 1;
10723
+ const childrenHeights = currNode.children.map((c) => nodeToHeight(c, newLevel));
10724
+ return Math.max(...childrenHeights, newLevel);
10725
+ }
10726
+ function getNodeLength(currNode) {
10727
+ var _a;
10728
+ if (!currNode) {
10729
+ return 0;
10704
10730
  }
10705
- function formatValue(value) {
10706
- return value == null ? "" : value instanceof Date ? formatDate(value) : reFormat.test(value += "") ? '"' + value.replace(/"/g, '""') + '"' : value;
10731
+ if (!currNode.children) {
10732
+ return ((_a = currNode.set) == null ? void 0 : _a.length) || 0;
10707
10733
  }
10708
- return {
10709
- parse: parse2,
10710
- parseRows,
10711
- format,
10712
- formatBody,
10713
- formatRows,
10714
- formatRow,
10715
- formatValue
10716
- };
10734
+ return currNode.children.reduce((acc, curr) => acc + getNodeLength(curr), 0);
10717
10735
  }
10718
- var json2csv_umd = { exports: {} };
10719
- (function(module2, exports2) {
10720
- (function(global2, factory) {
10721
- factory(exports2);
10722
- })(commonjsGlobal, function(exports3) {
10723
- var domain;
10724
- function EventHandlers() {
10725
- }
10726
- EventHandlers.prototype = /* @__PURE__ */ Object.create(null);
10727
- function EventEmitter() {
10728
- EventEmitter.init.call(this);
10736
+ function nodeFindNodeByNamePath(node, path, currLevelIndex) {
10737
+ const currNodeName = path[currLevelIndex];
10738
+ if (node.name === currNodeName) {
10739
+ if (currLevelIndex === path.length - 1) {
10740
+ return node;
10729
10741
  }
10730
- EventEmitter.EventEmitter = EventEmitter;
10731
- EventEmitter.usingDomains = false;
10732
- EventEmitter.prototype.domain = void 0;
10733
- EventEmitter.prototype._events = void 0;
10734
- EventEmitter.prototype._maxListeners = void 0;
10735
- EventEmitter.defaultMaxListeners = 10;
10736
- EventEmitter.init = function() {
10737
- this.domain = null;
10738
- if (EventEmitter.usingDomains) {
10739
- if (domain.active)
10740
- ;
10741
- }
10742
- if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
10743
- this._events = new EventHandlers();
10744
- this._eventsCount = 0;
10742
+ if (node.children) {
10743
+ const foundNodes = node.children.map((child) => nodeFindNodeByNamePath(child, path, currLevelIndex + 1)).filter(Boolean);
10744
+ if (foundNodes.length === 1) {
10745
+ return foundNodes[0];
10745
10746
  }
10746
- this._maxListeners = this._maxListeners || void 0;
10747
+ }
10748
+ }
10749
+ return null;
10750
+ }
10751
+ function treeFindNodeByNamePath(currTree, targetNamePath) {
10752
+ const foundNodes = currTree.tree.map((levelZeroNode) => nodeFindNodeByNamePath(levelZeroNode, targetNamePath, 0)).filter(Boolean);
10753
+ if (foundNodes.length === 1) {
10754
+ return foundNodes[0];
10755
+ }
10756
+ return null;
10757
+ }
10758
+ function nodeTransform(node, predicate, transform, transformedPaths, currPath) {
10759
+ let newPath;
10760
+ if (!currPath) {
10761
+ newPath = [node.name];
10762
+ } else {
10763
+ newPath = [...currPath];
10764
+ }
10765
+ if (predicate(node, newPath)) {
10766
+ transformedPaths.push(newPath);
10767
+ return transform(node, newPath);
10768
+ }
10769
+ if (node.children) {
10770
+ return {
10771
+ ...node,
10772
+ children: node.children.map(
10773
+ (child) => nodeTransform(
10774
+ child,
10775
+ predicate,
10776
+ transform,
10777
+ transformedPaths,
10778
+ newPath.concat([child.name])
10779
+ )
10780
+ )
10747
10781
  };
10748
- EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
10749
- if (typeof n !== "number" || n < 0 || isNaN(n))
10750
- throw new TypeError('"n" argument must be a positive number');
10751
- this._maxListeners = n;
10752
- return this;
10782
+ }
10783
+ return node;
10784
+ }
10785
+ function nodeTransformAll(node, predicate, transform, transformedPaths, currPath) {
10786
+ let newPath;
10787
+ if (!currPath) {
10788
+ newPath = [node.name];
10789
+ } else {
10790
+ newPath = [...currPath];
10791
+ }
10792
+ let newNode = node;
10793
+ if (predicate(node, newPath)) {
10794
+ transformedPaths.push(newPath);
10795
+ newNode = transform(node, newPath);
10796
+ }
10797
+ if (node.children) {
10798
+ return {
10799
+ ...newNode,
10800
+ children: newNode.children.map(
10801
+ (child) => nodeTransformAll(
10802
+ child,
10803
+ predicate,
10804
+ transform,
10805
+ transformedPaths,
10806
+ newPath.concat([child.name])
10807
+ )
10808
+ )
10753
10809
  };
10754
- function $getMaxListeners(that) {
10755
- if (that._maxListeners === void 0)
10756
- return EventEmitter.defaultMaxListeners;
10757
- return that._maxListeners;
10810
+ }
10811
+ return newNode;
10812
+ }
10813
+ function nodeAppendChild(currNode, newChild) {
10814
+ return {
10815
+ ...currNode,
10816
+ children: [...currNode.children, newChild]
10817
+ };
10818
+ }
10819
+ function nodePrependChild(currNode, newChild) {
10820
+ return {
10821
+ ...currNode,
10822
+ children: [newChild, ...currNode.children]
10823
+ };
10824
+ }
10825
+ function nodeInsertChild(currNode, newChild, insertIndex) {
10826
+ const newChildren = Array.from(currNode.children);
10827
+ newChildren.splice(insertIndex, 0, newChild);
10828
+ return {
10829
+ ...currNode,
10830
+ children: newChildren
10831
+ };
10832
+ }
10833
+ function treeToUnion(currTree, checkedPaths) {
10834
+ const nodes = checkedPaths.map((path) => treeFindNodeByNamePath(currTree, path));
10835
+ const nodeSets = nodes.map((node) => nodeToSet(node).map(([cellId]) => cellId));
10836
+ return nodeSets.reduce((a, h) => a.concat(h.filter((hEl) => !a.includes(hEl))), nodeSets[0] || []);
10837
+ }
10838
+ function treeToIntersection(currTree, checkedPaths) {
10839
+ const nodes = checkedPaths.map((path) => treeFindNodeByNamePath(currTree, path));
10840
+ const nodeSets = nodes.map((node) => nodeToSet(node).map(([cellId]) => cellId));
10841
+ return nodeSets.reduce((a, h) => h.filter((hEl) => a.includes(hEl)), nodeSets[0] || []);
10842
+ }
10843
+ function treeToComplement(currTree, checkedPaths, items) {
10844
+ const primaryUnion = treeToUnion(currTree, checkedPaths);
10845
+ return items.filter((el) => !primaryUnion.includes(el));
10846
+ }
10847
+ function nodeToLevelDescendantNamePaths(node, level, prevPath, stopEarly = false) {
10848
+ if (!node.children) {
10849
+ if (!stopEarly) {
10850
+ return null;
10758
10851
  }
10759
- EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
10760
- return $getMaxListeners(this);
10852
+ return [[...prevPath, node.name]];
10853
+ }
10854
+ if (level === 0) {
10855
+ return [[...prevPath, node.name]];
10856
+ }
10857
+ return node.children.flatMap((c) => nodeToLevelDescendantNamePaths(c, level - 1, [...prevPath, node.name], stopEarly)).filter(Boolean);
10858
+ }
10859
+ function treeExport(currTree, datatype) {
10860
+ return {
10861
+ version: HIERARCHICAL_SCHEMAS.latestVersion,
10862
+ datatype,
10863
+ tree: currTree.tree
10864
+ };
10865
+ }
10866
+ function treeExportLevelZeroNode(currTree, nodePath, datatype, cellSetColors, theme) {
10867
+ const node = treeFindNodeByNamePath(currTree, nodePath);
10868
+ const nodeWithColors = nodeTransformAll(node, () => true, (n, nPath) => {
10869
+ var _a;
10870
+ const nodeColor = ((_a = cellSetColors == null ? void 0 : cellSetColors.find((c) => isEqual(c.path, nPath))) == null ? void 0 : _a.color) ?? getDefaultColor(theme);
10871
+ return {
10872
+ ...n,
10873
+ color: nodeColor.slice(0, 3)
10761
10874
  };
10762
- function emitNone(handler, isFn, self2) {
10763
- if (isFn)
10764
- handler.call(self2);
10765
- else {
10766
- var len = handler.length;
10767
- var listeners = arrayClone(handler, len);
10768
- for (var i = 0; i < len; ++i)
10769
- listeners[i].call(self2);
10770
- }
10875
+ }, []);
10876
+ const treeWithOneLevelZeroNode = {
10877
+ ...currTree,
10878
+ tree: [nodeWithColors]
10879
+ };
10880
+ return {
10881
+ treeToExport: treeExport(treeWithOneLevelZeroNode, datatype),
10882
+ nodeName: node.name
10883
+ };
10884
+ }
10885
+ function treeExportSet(currTree, nodePath) {
10886
+ const node = treeFindNodeByNamePath(currTree, nodePath);
10887
+ return { setToExport: nodeToSet(node), nodeName: node.name };
10888
+ }
10889
+ function treeInitialize(datatype) {
10890
+ return {
10891
+ version: HIERARCHICAL_SCHEMAS.latestVersion,
10892
+ datatype,
10893
+ tree: []
10894
+ };
10895
+ }
10896
+ function nodeToRenderProps(node, path, cellSetColor) {
10897
+ var _a;
10898
+ const level = path.length - 1;
10899
+ return {
10900
+ title: node.name,
10901
+ nodeKey: pathToKey(path),
10902
+ path,
10903
+ size: getNodeLength(node),
10904
+ color: (_a = cellSetColor == null ? void 0 : cellSetColor.find((d) => isEqual(d.path, path))) == null ? void 0 : _a.color,
10905
+ level,
10906
+ isLeaf: (!node.children || node.children.length === 0) && Boolean(node.set),
10907
+ height: nodeToHeight(node)
10908
+ };
10909
+ }
10910
+ function colorMixWithUncertainty(originalColor, p, mixingColor = [128, 128, 128]) {
10911
+ return [
10912
+ (originalColor[0] - mixingColor[0]) * p + mixingColor[0],
10913
+ (originalColor[1] - mixingColor[1]) * p + mixingColor[1],
10914
+ (originalColor[2] - mixingColor[2]) * p + mixingColor[2]
10915
+ ];
10916
+ }
10917
+ function treeToCellColorsBySetNames(currTree, selectedNamePaths, cellSetColor, theme) {
10918
+ let cellColorsArray = [];
10919
+ selectedNamePaths.forEach((setNamePath) => {
10920
+ var _a;
10921
+ const node = treeFindNodeByNamePath(currTree, setNamePath);
10922
+ if (node) {
10923
+ const nodeSet = nodeToSet(node);
10924
+ const nodeColor = ((_a = cellSetColor == null ? void 0 : cellSetColor.find((d) => isEqual(d.path, setNamePath))) == null ? void 0 : _a.color) || getDefaultColor(theme);
10925
+ cellColorsArray = [
10926
+ ...cellColorsArray,
10927
+ ...nodeSet.map(([cellId, prob]) => [
10928
+ cellId,
10929
+ isNil(prob) ? nodeColor : colorMixWithUncertainty(nodeColor, prob)
10930
+ ])
10931
+ ];
10771
10932
  }
10772
- function emitOne(handler, isFn, self2, arg1) {
10773
- if (isFn)
10774
- handler.call(self2, arg1);
10775
- else {
10776
- var len = handler.length;
10777
- var listeners = arrayClone(handler, len);
10778
- for (var i = 0; i < len; ++i)
10779
- listeners[i].call(self2, arg1);
10780
- }
10933
+ });
10934
+ return new Map(cellColorsArray);
10935
+ }
10936
+ function treeToCellSetColorIndicesBySetNames(currTree, selectedNamePaths, cellSetColor) {
10937
+ let cellColorsArray = [];
10938
+ selectedNamePaths == null ? void 0 : selectedNamePaths.forEach((setNamePath) => {
10939
+ const node = treeFindNodeByNamePath(currTree, setNamePath);
10940
+ if (node) {
10941
+ const nodeSet = nodeToSet(node);
10942
+ const nodeColorIndex = cellSetColor == null ? void 0 : cellSetColor.findIndex((d) => isEqual(d.path, setNamePath));
10943
+ cellColorsArray = [
10944
+ ...cellColorsArray,
10945
+ ...nodeSet.map(([cellId]) => [
10946
+ cellId,
10947
+ nodeColorIndex
10948
+ ])
10949
+ ];
10781
10950
  }
10782
- function emitTwo(handler, isFn, self2, arg1, arg2) {
10783
- if (isFn)
10784
- handler.call(self2, arg1, arg2);
10785
- else {
10786
- var len = handler.length;
10787
- var listeners = arrayClone(handler, len);
10788
- for (var i = 0; i < len; ++i)
10789
- listeners[i].call(self2, arg1, arg2);
10790
- }
10951
+ });
10952
+ return new Map(cellColorsArray);
10953
+ }
10954
+ function treeToObjectsBySetNames(currTree, selectedNamePaths, setColor, theme) {
10955
+ var _a;
10956
+ let cellsArray = [];
10957
+ for (let i = 0; i < selectedNamePaths.length; i += 1) {
10958
+ const setNamePath = selectedNamePaths[i];
10959
+ const node = treeFindNodeByNamePath(currTree, setNamePath);
10960
+ if (node) {
10961
+ const nodeSet = nodeToSet(node);
10962
+ const nodeColor = ((_a = setColor == null ? void 0 : setColor.find((d) => isEqual(d.path, setNamePath))) == null ? void 0 : _a.color) || getDefaultColor(theme);
10963
+ cellsArray = cellsArray.concat(nodeSet.map(([cellId]) => ({
10964
+ obsId: cellId,
10965
+ name: node.name,
10966
+ color: nodeColor
10967
+ })));
10791
10968
  }
10792
- function emitThree(handler, isFn, self2, arg1, arg2, arg3) {
10793
- if (isFn)
10794
- handler.call(self2, arg1, arg2, arg3);
10795
- else {
10796
- var len = handler.length;
10797
- var listeners = arrayClone(handler, len);
10798
- for (var i = 0; i < len; ++i)
10799
- listeners[i].call(self2, arg1, arg2, arg3);
10969
+ }
10970
+ return cellsArray;
10971
+ }
10972
+ function treeToCellPolygonsBySetNames(currTree, obsIndex, obsEmbedding, selectedNamePaths, cellSetColor, theme) {
10973
+ const obsIndexMap = new Map(obsIndex.map((key, i) => [key, i]));
10974
+ const cellSetPolygons = [];
10975
+ selectedNamePaths.forEach((setNamePath) => {
10976
+ var _a;
10977
+ const node = treeFindNodeByNamePath(currTree, setNamePath);
10978
+ if (node) {
10979
+ const nodeSet = nodeToSet(node);
10980
+ const nodeColor = ((_a = cellSetColor == null ? void 0 : cellSetColor.find((d) => isEqual(d.path, setNamePath))) == null ? void 0 : _a.color) || getDefaultColor(theme);
10981
+ const cellPositions = nodeSet.map(([cellId]) => {
10982
+ const cellIdx = obsIndexMap.get(cellId);
10983
+ return [
10984
+ obsEmbedding.data[0][cellIdx],
10985
+ -obsEmbedding.data[1][cellIdx]
10986
+ ];
10987
+ }).filter((cell) => cell.every((i) => typeof i === "number"));
10988
+ if (cellPositions.length > 2) {
10989
+ const points = featureCollection(
10990
+ cellPositions.map(point)
10991
+ );
10992
+ const concavity = Infinity;
10993
+ const hullCoords = concaveman$1(cellPositions, concavity);
10994
+ if (hullCoords) {
10995
+ const centroidCoords = centroid(points).geometry.coordinates;
10996
+ cellSetPolygons.push({
10997
+ path: setNamePath,
10998
+ name: setNamePath[setNamePath.length - 1],
10999
+ hull: hullCoords,
11000
+ color: nodeColor,
11001
+ centroid: centroidCoords
11002
+ });
11003
+ }
10800
11004
  }
10801
11005
  }
10802
- function emitMany(handler, isFn, self2, args) {
10803
- if (isFn)
10804
- handler.apply(self2, args);
10805
- else {
10806
- var len = handler.length;
10807
- var listeners = arrayClone(handler, len);
10808
- for (var i = 0; i < len; ++i)
10809
- listeners[i].apply(self2, args);
11006
+ });
11007
+ return cellSetPolygons;
11008
+ }
11009
+ function treeToSetSizesBySetNames(currTree, allNamePaths, selectedNamePaths, setColor, theme) {
11010
+ const sizes = [];
11011
+ const contains = (path, paths) => paths.some((p) => isEqual(p, path));
11012
+ allNamePaths.forEach((clusterPath) => {
11013
+ var _a;
11014
+ const node = treeFindNodeByNamePath(currTree, clusterPath);
11015
+ if (node) {
11016
+ const nodeSet = nodeToSet(node);
11017
+ const nodeColor = ((_a = setColor == null ? void 0 : setColor.find((d) => isEqual(d.path, clusterPath))) == null ? void 0 : _a.color) || getDefaultColor(theme);
11018
+ const nodeProps = {
11019
+ key: generateKey(),
11020
+ name: node.name,
11021
+ size: nodeSet.length,
11022
+ color: nodeColor,
11023
+ setNamePath: clusterPath,
11024
+ // used by the CellSetSizesPlot to determine if the bar should be grayed out
11025
+ isGrayedOut: true
11026
+ };
11027
+ if (contains(clusterPath, selectedNamePaths)) {
11028
+ nodeProps.isGrayedOut = false;
10810
11029
  }
11030
+ sizes.push(nodeProps);
10811
11031
  }
10812
- EventEmitter.prototype.emit = function emit(type2) {
10813
- var er, handler, len, args, i, events, domain2;
10814
- var doError = type2 === "error";
10815
- events = this._events;
10816
- if (events)
10817
- doError = doError && events.error == null;
10818
- else if (!doError)
10819
- return false;
10820
- domain2 = this.domain;
10821
- if (doError) {
10822
- er = arguments[1];
10823
- if (domain2) {
10824
- if (!er)
10825
- er = new Error('Uncaught, unspecified "error" event');
10826
- er.domainEmitter = this;
10827
- er.domain = domain2;
10828
- er.domainThrown = false;
10829
- domain2.emit("error", er);
10830
- } else if (er instanceof Error) {
10831
- throw er;
10832
- } else {
10833
- var err = new Error('Uncaught, unspecified "error" event. (' + er + ")");
10834
- err.context = er;
10835
- throw err;
10836
- }
10837
- return false;
10838
- }
10839
- handler = events[type2];
10840
- if (!handler)
10841
- return false;
10842
- var isFn = typeof handler === "function";
10843
- len = arguments.length;
10844
- switch (len) {
10845
- case 1:
10846
- emitNone(handler, isFn, this);
10847
- break;
10848
- case 2:
10849
- emitOne(handler, isFn, this, arguments[1]);
10850
- break;
10851
- case 3:
10852
- emitTwo(handler, isFn, this, arguments[1], arguments[2]);
10853
- break;
10854
- case 4:
10855
- emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
10856
- break;
10857
- default:
10858
- args = new Array(len - 1);
10859
- for (i = 1; i < len; i++)
10860
- args[i - 1] = arguments[i];
10861
- emitMany(handler, isFn, this, args);
10862
- }
10863
- return true;
10864
- };
10865
- function _addListener(target, type2, listener, prepend) {
10866
- var m;
10867
- var events;
10868
- var existing;
10869
- if (typeof listener !== "function")
10870
- throw new TypeError('"listener" argument must be a function');
10871
- events = target._events;
10872
- if (!events) {
10873
- events = target._events = new EventHandlers();
10874
- target._eventsCount = 0;
10875
- } else {
10876
- if (events.newListener) {
10877
- target.emit(
10878
- "newListener",
10879
- type2,
10880
- listener.listener ? listener.listener : listener
10881
- );
10882
- events = target._events;
10883
- }
10884
- existing = events[type2];
10885
- }
10886
- if (!existing) {
10887
- existing = events[type2] = listener;
10888
- ++target._eventsCount;
10889
- } else {
10890
- if (typeof existing === "function") {
10891
- existing = events[type2] = prepend ? [listener, existing] : [existing, listener];
10892
- } else {
10893
- if (prepend) {
10894
- existing.unshift(listener);
10895
- } else {
10896
- existing.push(listener);
10897
- }
10898
- }
10899
- if (!existing.warned) {
10900
- m = $getMaxListeners(target);
10901
- if (m && m > 0 && existing.length > m) {
10902
- existing.warned = true;
10903
- var w = new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + type2 + " listeners added. Use emitter.setMaxListeners() to increase limit");
10904
- w.name = "MaxListenersExceededWarning";
10905
- w.emitter = target;
10906
- w.type = type2;
10907
- w.count = existing.length;
10908
- emitWarning(w);
10909
- }
11032
+ });
11033
+ return sizes;
11034
+ }
11035
+ function filterNode(node, prevPath, filterPath) {
11036
+ if (isEqual([...prevPath, node.name], filterPath)) {
11037
+ return null;
11038
+ }
11039
+ if (!node.children) {
11040
+ return node;
11041
+ }
11042
+ return {
11043
+ ...node,
11044
+ children: node.children.map(
11045
+ (c) => filterNode(c, [...prevPath, node.name], filterPath)
11046
+ ).filter(Boolean)
11047
+ };
11048
+ }
11049
+ function treeToExpectedCheckedLevel(currTree, checkedPaths) {
11050
+ let result = null;
11051
+ if (currTree) {
11052
+ currTree.tree.forEach((lzn) => {
11053
+ const levelZeroPath = [lzn.name];
11054
+ const height = nodeToHeight(lzn);
11055
+ range$2(height).forEach((i) => {
11056
+ const levelIndex = i + 1;
11057
+ const levelNodePaths = nodeToLevelDescendantNamePaths(lzn, levelIndex, [], true);
11058
+ if (isEqual(levelNodePaths, checkedPaths)) {
11059
+ result = { levelZeroPath, levelIndex };
10910
11060
  }
10911
- }
10912
- return target;
11061
+ });
11062
+ });
11063
+ }
11064
+ return result;
11065
+ }
11066
+ function treesConflict(cellSets, testCellSets) {
11067
+ const paths = [];
11068
+ const testPaths = [];
11069
+ let hasConflict = false;
11070
+ function getPaths2(node, prevPath) {
11071
+ paths.push([...prevPath, node.name]);
11072
+ if (node.children) {
11073
+ node.children.forEach((c) => getPaths2(c, [...prevPath, node.name]));
10913
11074
  }
10914
- function emitWarning(e) {
10915
- typeof console.warn === "function" ? console.warn(e) : console.log(e);
11075
+ }
11076
+ cellSets.tree.forEach((lzn) => getPaths2(lzn, []));
11077
+ function getTestPaths(node, prevPath) {
11078
+ testPaths.push([...prevPath, node.name]);
11079
+ if (node.children) {
11080
+ node.children.forEach((c) => getPaths2(c, [...prevPath, node.name]));
10916
11081
  }
10917
- EventEmitter.prototype.addListener = function addListener(type2, listener) {
10918
- return _addListener(this, type2, listener, false);
10919
- };
10920
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
10921
- EventEmitter.prototype.prependListener = function prependListener2(type2, listener) {
10922
- return _addListener(this, type2, listener, true);
10923
- };
10924
- function _onceWrap(target, type2, listener) {
10925
- var fired = false;
10926
- function g() {
10927
- target.removeListener(type2, g);
10928
- if (!fired) {
10929
- fired = true;
10930
- listener.apply(target, arguments);
10931
- }
10932
- }
10933
- g.listener = listener;
10934
- return g;
11082
+ }
11083
+ testCellSets.tree.forEach((lzn) => getTestPaths(lzn, []));
11084
+ testPaths.forEach((testPath) => {
11085
+ if (paths.find((p) => isEqual(p, testPath))) {
11086
+ hasConflict = true;
10935
11087
  }
10936
- EventEmitter.prototype.once = function once(type2, listener) {
10937
- if (typeof listener !== "function")
10938
- throw new TypeError('"listener" argument must be a function');
10939
- this.on(type2, _onceWrap(this, type2, listener));
10940
- return this;
10941
- };
10942
- EventEmitter.prototype.prependOnceListener = function prependOnceListener(type2, listener) {
10943
- if (typeof listener !== "function")
10944
- throw new TypeError('"listener" argument must be a function');
10945
- this.prependListener(type2, _onceWrap(this, type2, listener));
10946
- return this;
10947
- };
10948
- EventEmitter.prototype.removeListener = function removeListener(type2, listener) {
10949
- var list, events, position, i, originalListener;
10950
- if (typeof listener !== "function")
10951
- throw new TypeError('"listener" argument must be a function');
10952
- events = this._events;
10953
- if (!events)
10954
- return this;
10955
- list = events[type2];
10956
- if (!list)
10957
- return this;
10958
- if (list === listener || list.listener && list.listener === listener) {
10959
- if (--this._eventsCount === 0)
10960
- this._events = new EventHandlers();
10961
- else {
10962
- delete events[type2];
10963
- if (events.removeListener)
10964
- this.emit("removeListener", type2, list.listener || listener);
10965
- }
10966
- } else if (typeof list !== "function") {
10967
- position = -1;
10968
- for (i = list.length; i-- > 0; ) {
10969
- if (list[i] === listener || list[i].listener && list[i].listener === listener) {
10970
- originalListener = list[i].listener;
10971
- position = i;
10972
- break;
10973
- }
10974
- }
10975
- if (position < 0)
10976
- return this;
10977
- if (list.length === 1) {
10978
- list[0] = void 0;
10979
- if (--this._eventsCount === 0) {
10980
- this._events = new EventHandlers();
10981
- return this;
10982
- } else {
10983
- delete events[type2];
11088
+ });
11089
+ return hasConflict;
11090
+ }
11091
+ function initializeCellSetColor(cellSets, cellSetColor) {
11092
+ const nextCellSetColor = [...cellSetColor || []];
11093
+ const nodeCountPerTreePerLevel = cellSets.tree.map((tree) => Array.from({
11094
+ length: nodeToHeight(tree) + 1
11095
+ // Need to add one because its an array.
11096
+ }).fill(0));
11097
+ function processNode(node, prevPath, hierarchyLevel, treeIndex) {
11098
+ const index = nodeCountPerTreePerLevel[treeIndex][hierarchyLevel];
11099
+ const nodePath = [...prevPath, node.name];
11100
+ const nodeColor = nextCellSetColor.find((d) => isEqual(d.path, nodePath));
11101
+ if (!nodeColor) {
11102
+ const nodeColorArray = node.color ? node.color : PALETTE[index % PALETTE.length];
11103
+ nextCellSetColor.push({
11104
+ path: nodePath,
11105
+ color: nodeColorArray
11106
+ });
11107
+ }
11108
+ nodeCountPerTreePerLevel[treeIndex][hierarchyLevel] += 1;
11109
+ if (node.children) {
11110
+ node.children.forEach((c) => processNode(c, nodePath, hierarchyLevel + 1, treeIndex));
11111
+ }
11112
+ }
11113
+ cellSets.tree.forEach((lzn, treeIndex) => processNode(lzn, [], 0, treeIndex));
11114
+ return nextCellSetColor;
11115
+ }
11116
+ function getCellSetPolygons(params) {
11117
+ const {
11118
+ obsIndex,
11119
+ obsEmbedding,
11120
+ cellSets,
11121
+ cellSetSelection,
11122
+ cellSetColor,
11123
+ theme
11124
+ } = params;
11125
+ if (cellSetSelection && cellSetSelection.length > 0 && cellSets && obsIndex && obsEmbedding) {
11126
+ return treeToCellPolygonsBySetNames(
11127
+ cellSets,
11128
+ obsIndex,
11129
+ obsEmbedding,
11130
+ cellSetSelection,
11131
+ cellSetColor,
11132
+ theme
11133
+ );
11134
+ }
11135
+ return [];
11136
+ }
11137
+ function treeToMembershipMap(currTree) {
11138
+ const result = /* @__PURE__ */ new Map();
11139
+ if (currTree) {
11140
+ currTree.tree.forEach((lzn) => {
11141
+ const height = nodeToHeight(lzn);
11142
+ range$2(height).forEach((i) => {
11143
+ const levelIndex = i + 1;
11144
+ const levelNodePaths = nodeToLevelDescendantNamePaths(lzn, levelIndex, [], true);
11145
+ levelNodePaths.forEach((setNamePath) => {
11146
+ const node = treeFindNodeByNamePath(currTree, setNamePath);
11147
+ if (node && !node.children) {
11148
+ const nodeSet = nodeToSet(node);
11149
+ nodeSet.forEach(([obsId]) => {
11150
+ if (result.has(obsId)) {
11151
+ result.get(obsId).push(setNamePath);
11152
+ } else {
11153
+ result.set(obsId, [setNamePath]);
11154
+ }
11155
+ });
10984
11156
  }
10985
- } else {
10986
- spliceOne(list, position);
10987
- }
10988
- if (events.removeListener)
10989
- this.emit("removeListener", type2, originalListener || listener);
11157
+ });
11158
+ });
11159
+ });
11160
+ }
11161
+ return result;
11162
+ }
11163
+ function getPaths(node, currentPath = [], paths = []) {
11164
+ if (node.children) {
11165
+ node.children.forEach((child) => {
11166
+ const newPath = [...currentPath, child.name];
11167
+ paths.push(newPath);
11168
+ getPaths(child, newPath, paths);
11169
+ });
11170
+ }
11171
+ return paths;
11172
+ }
11173
+ function findLongestPath(arrOfPaths, path, isSubset) {
11174
+ if (Array.isArray(arrOfPaths)) {
11175
+ let longest = null;
11176
+ let longestLength = 0;
11177
+ arrOfPaths.forEach((subArray) => {
11178
+ const matchCount = subArray.filter((v, i) => v === path[i]).length;
11179
+ if (matchCount === (isSubset ? subArray.length : path.length) && subArray.length > longestLength) {
11180
+ longest = subArray;
11181
+ longestLength = subArray.length;
10990
11182
  }
10991
- return this;
10992
- };
10993
- EventEmitter.prototype.removeAllListeners = function removeAllListeners(type2) {
10994
- var listeners, events;
10995
- events = this._events;
10996
- if (!events)
10997
- return this;
10998
- if (!events.removeListener) {
10999
- if (arguments.length === 0) {
11000
- this._events = new EventHandlers();
11001
- this._eventsCount = 0;
11002
- } else if (events[type2]) {
11003
- if (--this._eventsCount === 0)
11004
- this._events = new EventHandlers();
11005
- else
11006
- delete events[type2];
11007
- }
11008
- return this;
11183
+ });
11184
+ if (longestLength > 0) {
11185
+ return longest;
11186
+ }
11187
+ if (isSubset) {
11188
+ return [];
11189
+ }
11190
+ }
11191
+ return [];
11192
+ }
11193
+ function findLongestCommonPath(arrOfPaths, cellSetSelection) {
11194
+ let maxCount = 0;
11195
+ let commonPath = [];
11196
+ cellSetSelection.forEach((currentCellSet) => {
11197
+ const longestPath = findLongestPath(arrOfPaths, currentCellSet, false);
11198
+ if (longestPath.length > maxCount) {
11199
+ maxCount = longestPath.length;
11200
+ commonPath = currentCellSet;
11201
+ }
11202
+ });
11203
+ return commonPath;
11204
+ }
11205
+ function filterPathsByExpansionAndSelection(mergedCellSets, hierarchy, cellSetExpansion, cellSetSelection) {
11206
+ const paths = getPaths({ children: mergedCellSets.tree });
11207
+ const contains = (allPaths, path) => allPaths == null ? void 0 : allPaths.some((p) => isEqual(p, path));
11208
+ return paths.filter((clusterPath) => {
11209
+ if (contains(cellSetExpansion, clusterPath))
11210
+ return false;
11211
+ if (!contains(cellSetSelection, clusterPath)) {
11212
+ if (findLongestPath(cellSetSelection, clusterPath, false).length > clusterPath.length) {
11213
+ return false;
11009
11214
  }
11010
- if (arguments.length === 0) {
11011
- var keys3 = Object.keys(events);
11012
- for (var i = 0, key; i < keys3.length; ++i) {
11013
- key = keys3[i];
11014
- if (key === "removeListener")
11015
- continue;
11016
- this.removeAllListeners(key);
11215
+ if (cellSetExpansion) {
11216
+ if (cellSetExpansion.length === 0 && clusterPath.length > 2)
11217
+ return false;
11218
+ const longestSubset = findLongestPath(cellSetExpansion, clusterPath, true);
11219
+ if (cellSetExpansion.length > 0 && longestSubset.length + 1 < clusterPath.length) {
11220
+ return false;
11017
11221
  }
11018
- this.removeAllListeners("removeListener");
11019
- this._events = new EventHandlers();
11020
- this._eventsCount = 0;
11021
- return this;
11022
- }
11023
- listeners = events[type2];
11024
- if (typeof listeners === "function") {
11025
- this.removeListener(type2, listeners);
11026
- } else if (listeners) {
11027
- do {
11028
- this.removeListener(type2, listeners[listeners.length - 1]);
11029
- } while (listeners[0]);
11030
- }
11031
- return this;
11032
- };
11033
- EventEmitter.prototype.listeners = function listeners(type2) {
11034
- var evlistener;
11035
- var ret;
11036
- var events = this._events;
11037
- if (!events)
11038
- ret = [];
11039
- else {
11040
- evlistener = events[type2];
11041
- if (!evlistener)
11042
- ret = [];
11043
- else if (typeof evlistener === "function")
11044
- ret = [evlistener.listener || evlistener];
11045
- else
11046
- ret = unwrapListeners(evlistener);
11047
11222
  }
11048
- return ret;
11049
- };
11050
- EventEmitter.listenerCount = function(emitter, type2) {
11051
- if (typeof emitter.listenerCount === "function") {
11052
- return emitter.listenerCount(type2);
11053
- } else {
11054
- return listenerCount.call(emitter, type2);
11223
+ }
11224
+ return clusterPath[0] === hierarchy[0];
11225
+ });
11226
+ }
11227
+ function findChangedHierarchy(prevSelectedPaths, currSelectedPaths) {
11228
+ const unselectedPaths = prevSelectedPaths.filter(
11229
+ (prevPath) => !currSelectedPaths.find((currPath) => isEqual(currPath, prevPath))
11230
+ );
11231
+ const newlySelectedPaths = currSelectedPaths.filter(
11232
+ (currPath) => !prevSelectedPaths.find((prevPath) => isEqual(currPath, prevPath))
11233
+ );
11234
+ if (unselectedPaths.length === 0 && newlySelectedPaths.length === 0) {
11235
+ return null;
11236
+ }
11237
+ const changedPath = newlySelectedPaths.length > 0 ? newlySelectedPaths[0] : unselectedPaths[0];
11238
+ return changedPath.slice(0, -1);
11239
+ }
11240
+ var EOL = {}, EOF = {}, QUOTE = 34, NEWLINE = 10, RETURN = 13;
11241
+ function objectConverter(columns) {
11242
+ return new Function("d", "return {" + columns.map(function(name, i) {
11243
+ return JSON.stringify(name) + ": d[" + i + '] || ""';
11244
+ }).join(",") + "}");
11245
+ }
11246
+ function customConverter(columns, f) {
11247
+ var object = objectConverter(columns);
11248
+ return function(row, i) {
11249
+ return f(object(row), i, columns);
11250
+ };
11251
+ }
11252
+ function inferColumns(rows) {
11253
+ var columnSet = /* @__PURE__ */ Object.create(null), columns = [];
11254
+ rows.forEach(function(row) {
11255
+ for (var column in row) {
11256
+ if (!(column in columnSet)) {
11257
+ columns.push(columnSet[column] = column);
11055
11258
  }
11056
- };
11057
- EventEmitter.prototype.listenerCount = listenerCount;
11058
- function listenerCount(type2) {
11059
- var events = this._events;
11060
- if (events) {
11061
- var evlistener = events[type2];
11062
- if (typeof evlistener === "function") {
11063
- return 1;
11064
- } else if (evlistener) {
11065
- return evlistener.length;
11259
+ }
11260
+ });
11261
+ return columns;
11262
+ }
11263
+ function pad(value, width) {
11264
+ var s = value + "", length = s.length;
11265
+ return length < width ? new Array(width - length + 1).join(0) + s : s;
11266
+ }
11267
+ function formatYear(year) {
11268
+ return year < 0 ? "-" + pad(-year, 6) : year > 9999 ? "+" + pad(year, 6) : pad(year, 4);
11269
+ }
11270
+ function formatDate(date) {
11271
+ var hours = date.getUTCHours(), minutes = date.getUTCMinutes(), seconds = date.getUTCSeconds(), milliseconds = date.getUTCMilliseconds();
11272
+ return isNaN(date) ? "Invalid Date" : formatYear(date.getUTCFullYear()) + "-" + pad(date.getUTCMonth() + 1, 2) + "-" + pad(date.getUTCDate(), 2) + (milliseconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "." + pad(milliseconds, 3) + "Z" : seconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "Z" : minutes || hours ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + "Z" : "");
11273
+ }
11274
+ function dsvFormat(delimiter) {
11275
+ var reFormat = new RegExp('["' + delimiter + "\n\r]"), DELIMITER = delimiter.charCodeAt(0);
11276
+ function parse2(text, f) {
11277
+ var convert, columns, rows = parseRows(text, function(row, i) {
11278
+ if (convert)
11279
+ return convert(row, i - 1);
11280
+ columns = row, convert = f ? customConverter(row, f) : objectConverter(row);
11281
+ });
11282
+ rows.columns = columns || [];
11283
+ return rows;
11284
+ }
11285
+ function parseRows(text, f) {
11286
+ var rows = [], N = text.length, I = 0, n = 0, t2, eof = N <= 0, eol = false;
11287
+ if (text.charCodeAt(N - 1) === NEWLINE)
11288
+ --N;
11289
+ if (text.charCodeAt(N - 1) === RETURN)
11290
+ --N;
11291
+ function token() {
11292
+ if (eof)
11293
+ return EOF;
11294
+ if (eol)
11295
+ return eol = false, EOL;
11296
+ var i, j = I, c;
11297
+ if (text.charCodeAt(j) === QUOTE) {
11298
+ while (I++ < N && text.charCodeAt(I) !== QUOTE || text.charCodeAt(++I) === QUOTE)
11299
+ ;
11300
+ if ((i = I) >= N)
11301
+ eof = true;
11302
+ else if ((c = text.charCodeAt(I++)) === NEWLINE)
11303
+ eol = true;
11304
+ else if (c === RETURN) {
11305
+ eol = true;
11306
+ if (text.charCodeAt(I) === NEWLINE)
11307
+ ++I;
11066
11308
  }
11309
+ return text.slice(j + 1, i - 1).replace(/""/g, '"');
11067
11310
  }
11068
- return 0;
11311
+ while (I < N) {
11312
+ if ((c = text.charCodeAt(i = I++)) === NEWLINE)
11313
+ eol = true;
11314
+ else if (c === RETURN) {
11315
+ eol = true;
11316
+ if (text.charCodeAt(I) === NEWLINE)
11317
+ ++I;
11318
+ } else if (c !== DELIMITER)
11319
+ continue;
11320
+ return text.slice(j, i);
11321
+ }
11322
+ return eof = true, text.slice(j, N);
11069
11323
  }
11070
- EventEmitter.prototype.eventNames = function eventNames() {
11071
- return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
11072
- };
11073
- function spliceOne(list, index) {
11074
- for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
11075
- list[i] = list[k];
11076
- list.pop();
11324
+ while ((t2 = token()) !== EOF) {
11325
+ var row = [];
11326
+ while (t2 !== EOL && t2 !== EOF)
11327
+ row.push(t2), t2 = token();
11328
+ if (f && (row = f(row, n++)) == null)
11329
+ continue;
11330
+ rows.push(row);
11077
11331
  }
11078
- function arrayClone(arr, i) {
11079
- var copy = new Array(i);
11080
- while (i--)
11081
- copy[i] = arr[i];
11082
- return copy;
11332
+ return rows;
11333
+ }
11334
+ function preformatBody(rows, columns) {
11335
+ return rows.map(function(row) {
11336
+ return columns.map(function(column) {
11337
+ return formatValue(row[column]);
11338
+ }).join(delimiter);
11339
+ });
11340
+ }
11341
+ function format(rows, columns) {
11342
+ if (columns == null)
11343
+ columns = inferColumns(rows);
11344
+ return [columns.map(formatValue).join(delimiter)].concat(preformatBody(rows, columns)).join("\n");
11345
+ }
11346
+ function formatBody(rows, columns) {
11347
+ if (columns == null)
11348
+ columns = inferColumns(rows);
11349
+ return preformatBody(rows, columns).join("\n");
11350
+ }
11351
+ function formatRows(rows) {
11352
+ return rows.map(formatRow).join("\n");
11353
+ }
11354
+ function formatRow(row) {
11355
+ return row.map(formatValue).join(delimiter);
11356
+ }
11357
+ function formatValue(value) {
11358
+ return value == null ? "" : value instanceof Date ? formatDate(value) : reFormat.test(value += "") ? '"' + value.replace(/"/g, '""') + '"' : value;
11359
+ }
11360
+ return {
11361
+ parse: parse2,
11362
+ parseRows,
11363
+ format,
11364
+ formatBody,
11365
+ formatRows,
11366
+ formatRow,
11367
+ formatValue
11368
+ };
11369
+ }
11370
+ var json2csv_umd = { exports: {} };
11371
+ (function(module2, exports2) {
11372
+ (function(global2, factory) {
11373
+ factory(exports2);
11374
+ })(commonjsGlobal, function(exports3) {
11375
+ var domain;
11376
+ function EventHandlers() {
11083
11377
  }
11084
- function unwrapListeners(arr) {
11085
- var ret = new Array(arr.length);
11086
- for (var i = 0; i < ret.length; ++i) {
11087
- ret[i] = arr[i].listener || arr[i];
11088
- }
11089
- return ret;
11378
+ EventHandlers.prototype = /* @__PURE__ */ Object.create(null);
11379
+ function EventEmitter() {
11380
+ EventEmitter.init.call(this);
11090
11381
  }
11091
- var global$1 = typeof commonjsGlobal !== "undefined" ? commonjsGlobal : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
11092
- var lookup = [];
11093
- var revLookup = [];
11094
- var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
11095
- var inited = false;
11096
- function init() {
11097
- inited = true;
11098
- var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
11099
- for (var i = 0, len = code.length; i < len; ++i) {
11100
- lookup[i] = code[i];
11101
- revLookup[code.charCodeAt(i)] = i;
11382
+ EventEmitter.EventEmitter = EventEmitter;
11383
+ EventEmitter.usingDomains = false;
11384
+ EventEmitter.prototype.domain = void 0;
11385
+ EventEmitter.prototype._events = void 0;
11386
+ EventEmitter.prototype._maxListeners = void 0;
11387
+ EventEmitter.defaultMaxListeners = 10;
11388
+ EventEmitter.init = function() {
11389
+ this.domain = null;
11390
+ if (EventEmitter.usingDomains) {
11391
+ if (domain.active)
11392
+ ;
11102
11393
  }
11103
- revLookup["-".charCodeAt(0)] = 62;
11104
- revLookup["_".charCodeAt(0)] = 63;
11394
+ if (!this._events || this._events === Object.getPrototypeOf(this)._events) {
11395
+ this._events = new EventHandlers();
11396
+ this._eventsCount = 0;
11397
+ }
11398
+ this._maxListeners = this._maxListeners || void 0;
11399
+ };
11400
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
11401
+ if (typeof n !== "number" || n < 0 || isNaN(n))
11402
+ throw new TypeError('"n" argument must be a positive number');
11403
+ this._maxListeners = n;
11404
+ return this;
11405
+ };
11406
+ function $getMaxListeners(that) {
11407
+ if (that._maxListeners === void 0)
11408
+ return EventEmitter.defaultMaxListeners;
11409
+ return that._maxListeners;
11105
11410
  }
11106
- function toByteArray(b64) {
11107
- if (!inited) {
11108
- init();
11411
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
11412
+ return $getMaxListeners(this);
11413
+ };
11414
+ function emitNone(handler, isFn, self2) {
11415
+ if (isFn)
11416
+ handler.call(self2);
11417
+ else {
11418
+ var len = handler.length;
11419
+ var listeners = arrayClone(handler, len);
11420
+ for (var i = 0; i < len; ++i)
11421
+ listeners[i].call(self2);
11109
11422
  }
11110
- var i, j, l, tmp, placeHolders, arr;
11111
- var len = b64.length;
11112
- if (len % 4 > 0) {
11113
- throw new Error("Invalid string. Length must be a multiple of 4");
11423
+ }
11424
+ function emitOne(handler, isFn, self2, arg1) {
11425
+ if (isFn)
11426
+ handler.call(self2, arg1);
11427
+ else {
11428
+ var len = handler.length;
11429
+ var listeners = arrayClone(handler, len);
11430
+ for (var i = 0; i < len; ++i)
11431
+ listeners[i].call(self2, arg1);
11114
11432
  }
11115
- placeHolders = b64[len - 2] === "=" ? 2 : b64[len - 1] === "=" ? 1 : 0;
11116
- arr = new Arr(len * 3 / 4 - placeHolders);
11117
- l = placeHolders > 0 ? len - 4 : len;
11118
- var L = 0;
11119
- for (i = 0, j = 0; i < l; i += 4, j += 3) {
11120
- tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
11121
- arr[L++] = tmp >> 16 & 255;
11122
- arr[L++] = tmp >> 8 & 255;
11123
- arr[L++] = tmp & 255;
11124
- }
11125
- if (placeHolders === 2) {
11126
- tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
11127
- arr[L++] = tmp & 255;
11128
- } else if (placeHolders === 1) {
11129
- tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
11130
- arr[L++] = tmp >> 8 & 255;
11131
- arr[L++] = tmp & 255;
11132
- }
11133
- return arr;
11134
11433
  }
11135
- function tripletToBase64(num) {
11136
- return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
11137
- }
11138
- function encodeChunk(uint8, start, end) {
11139
- var tmp;
11140
- var output = [];
11141
- for (var i = start; i < end; i += 3) {
11142
- tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
11143
- output.push(tripletToBase64(tmp));
11434
+ function emitTwo(handler, isFn, self2, arg1, arg2) {
11435
+ if (isFn)
11436
+ handler.call(self2, arg1, arg2);
11437
+ else {
11438
+ var len = handler.length;
11439
+ var listeners = arrayClone(handler, len);
11440
+ for (var i = 0; i < len; ++i)
11441
+ listeners[i].call(self2, arg1, arg2);
11144
11442
  }
11145
- return output.join("");
11146
11443
  }
11147
- function fromByteArray(uint8) {
11148
- if (!inited) {
11149
- init();
11150
- }
11151
- var tmp;
11152
- var len = uint8.length;
11153
- var extraBytes = len % 3;
11154
- var output = "";
11155
- var parts = [];
11156
- var maxChunkLength = 16383;
11157
- for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
11158
- parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
11444
+ function emitThree(handler, isFn, self2, arg1, arg2, arg3) {
11445
+ if (isFn)
11446
+ handler.call(self2, arg1, arg2, arg3);
11447
+ else {
11448
+ var len = handler.length;
11449
+ var listeners = arrayClone(handler, len);
11450
+ for (var i = 0; i < len; ++i)
11451
+ listeners[i].call(self2, arg1, arg2, arg3);
11159
11452
  }
11160
- if (extraBytes === 1) {
11161
- tmp = uint8[len - 1];
11162
- output += lookup[tmp >> 2];
11163
- output += lookup[tmp << 4 & 63];
11164
- output += "==";
11165
- } else if (extraBytes === 2) {
11166
- tmp = (uint8[len - 2] << 8) + uint8[len - 1];
11167
- output += lookup[tmp >> 10];
11168
- output += lookup[tmp >> 4 & 63];
11169
- output += lookup[tmp << 2 & 63];
11170
- output += "=";
11453
+ }
11454
+ function emitMany(handler, isFn, self2, args) {
11455
+ if (isFn)
11456
+ handler.apply(self2, args);
11457
+ else {
11458
+ var len = handler.length;
11459
+ var listeners = arrayClone(handler, len);
11460
+ for (var i = 0; i < len; ++i)
11461
+ listeners[i].apply(self2, args);
11171
11462
  }
11172
- parts.push(output);
11173
- return parts.join("");
11174
11463
  }
11175
- function read(buffer, offset, isLE, mLen, nBytes) {
11176
- var e, m;
11177
- var eLen = nBytes * 8 - mLen - 1;
11178
- var eMax = (1 << eLen) - 1;
11179
- var eBias = eMax >> 1;
11180
- var nBits = -7;
11181
- var i = isLE ? nBytes - 1 : 0;
11182
- var d = isLE ? -1 : 1;
11183
- var s = buffer[offset + i];
11184
- i += d;
11185
- e = s & (1 << -nBits) - 1;
11186
- s >>= -nBits;
11187
- nBits += eLen;
11188
- for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
11464
+ EventEmitter.prototype.emit = function emit(type2) {
11465
+ var er, handler, len, args, i, events, domain2;
11466
+ var doError = type2 === "error";
11467
+ events = this._events;
11468
+ if (events)
11469
+ doError = doError && events.error == null;
11470
+ else if (!doError)
11471
+ return false;
11472
+ domain2 = this.domain;
11473
+ if (doError) {
11474
+ er = arguments[1];
11475
+ if (domain2) {
11476
+ if (!er)
11477
+ er = new Error('Uncaught, unspecified "error" event');
11478
+ er.domainEmitter = this;
11479
+ er.domain = domain2;
11480
+ er.domainThrown = false;
11481
+ domain2.emit("error", er);
11482
+ } else if (er instanceof Error) {
11483
+ throw er;
11484
+ } else {
11485
+ var err = new Error('Uncaught, unspecified "error" event. (' + er + ")");
11486
+ err.context = er;
11487
+ throw err;
11488
+ }
11489
+ return false;
11189
11490
  }
11190
- m = e & (1 << -nBits) - 1;
11191
- e >>= -nBits;
11192
- nBits += mLen;
11193
- for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
11491
+ handler = events[type2];
11492
+ if (!handler)
11493
+ return false;
11494
+ var isFn = typeof handler === "function";
11495
+ len = arguments.length;
11496
+ switch (len) {
11497
+ case 1:
11498
+ emitNone(handler, isFn, this);
11499
+ break;
11500
+ case 2:
11501
+ emitOne(handler, isFn, this, arguments[1]);
11502
+ break;
11503
+ case 3:
11504
+ emitTwo(handler, isFn, this, arguments[1], arguments[2]);
11505
+ break;
11506
+ case 4:
11507
+ emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
11508
+ break;
11509
+ default:
11510
+ args = new Array(len - 1);
11511
+ for (i = 1; i < len; i++)
11512
+ args[i - 1] = arguments[i];
11513
+ emitMany(handler, isFn, this, args);
11194
11514
  }
11195
- if (e === 0) {
11196
- e = 1 - eBias;
11197
- } else if (e === eMax) {
11198
- return m ? NaN : (s ? -1 : 1) * Infinity;
11515
+ return true;
11516
+ };
11517
+ function _addListener(target, type2, listener, prepend) {
11518
+ var m;
11519
+ var events;
11520
+ var existing;
11521
+ if (typeof listener !== "function")
11522
+ throw new TypeError('"listener" argument must be a function');
11523
+ events = target._events;
11524
+ if (!events) {
11525
+ events = target._events = new EventHandlers();
11526
+ target._eventsCount = 0;
11199
11527
  } else {
11200
- m = m + Math.pow(2, mLen);
11201
- e = e - eBias;
11528
+ if (events.newListener) {
11529
+ target.emit(
11530
+ "newListener",
11531
+ type2,
11532
+ listener.listener ? listener.listener : listener
11533
+ );
11534
+ events = target._events;
11535
+ }
11536
+ existing = events[type2];
11202
11537
  }
11203
- return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
11204
- }
11205
- function write(buffer, value, offset, isLE, mLen, nBytes) {
11206
- var e, m, c;
11207
- var eLen = nBytes * 8 - mLen - 1;
11208
- var eMax = (1 << eLen) - 1;
11209
- var eBias = eMax >> 1;
11210
- var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
11211
- var i = isLE ? 0 : nBytes - 1;
11212
- var d = isLE ? 1 : -1;
11213
- var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
11214
- value = Math.abs(value);
11215
- if (isNaN(value) || value === Infinity) {
11216
- m = isNaN(value) ? 1 : 0;
11217
- e = eMax;
11538
+ if (!existing) {
11539
+ existing = events[type2] = listener;
11540
+ ++target._eventsCount;
11218
11541
  } else {
11219
- e = Math.floor(Math.log(value) / Math.LN2);
11220
- if (value * (c = Math.pow(2, -e)) < 1) {
11221
- e--;
11222
- c *= 2;
11223
- }
11224
- if (e + eBias >= 1) {
11225
- value += rt / c;
11542
+ if (typeof existing === "function") {
11543
+ existing = events[type2] = prepend ? [listener, existing] : [existing, listener];
11226
11544
  } else {
11227
- value += rt * Math.pow(2, 1 - eBias);
11228
- }
11229
- if (value * c >= 2) {
11230
- e++;
11231
- c /= 2;
11545
+ if (prepend) {
11546
+ existing.unshift(listener);
11547
+ } else {
11548
+ existing.push(listener);
11549
+ }
11232
11550
  }
11233
- if (e + eBias >= eMax) {
11234
- m = 0;
11235
- e = eMax;
11236
- } else if (e + eBias >= 1) {
11237
- m = (value * c - 1) * Math.pow(2, mLen);
11238
- e = e + eBias;
11239
- } else {
11240
- m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
11241
- e = 0;
11551
+ if (!existing.warned) {
11552
+ m = $getMaxListeners(target);
11553
+ if (m && m > 0 && existing.length > m) {
11554
+ existing.warned = true;
11555
+ var w = new Error("Possible EventEmitter memory leak detected. " + existing.length + " " + type2 + " listeners added. Use emitter.setMaxListeners() to increase limit");
11556
+ w.name = "MaxListenersExceededWarning";
11557
+ w.emitter = target;
11558
+ w.type = type2;
11559
+ w.count = existing.length;
11560
+ emitWarning(w);
11561
+ }
11242
11562
  }
11243
11563
  }
11244
- for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
11245
- }
11246
- e = e << mLen | m;
11247
- eLen += mLen;
11248
- for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
11249
- }
11250
- buffer[offset + i - d] |= s * 128;
11564
+ return target;
11251
11565
  }
11252
- var toString = {}.toString;
11253
- var isArray2 = Array.isArray || function(arr) {
11254
- return toString.call(arr) == "[object Array]";
11255
- };
11256
- var INSPECT_MAX_BYTES = 50;
11257
- Buffer2.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== void 0 ? global$1.TYPED_ARRAY_SUPPORT : true;
11258
- function kMaxLength() {
11259
- return Buffer2.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
11566
+ function emitWarning(e) {
11567
+ typeof console.warn === "function" ? console.warn(e) : console.log(e);
11260
11568
  }
11261
- function createBuffer(that, length) {
11262
- if (kMaxLength() < length) {
11263
- throw new RangeError("Invalid typed array length");
11264
- }
11265
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
11266
- that = new Uint8Array(length);
11267
- that.__proto__ = Buffer2.prototype;
11268
- } else {
11269
- if (that === null) {
11270
- that = new Buffer2(length);
11271
- }
11272
- that.length = length;
11569
+ EventEmitter.prototype.addListener = function addListener(type2, listener) {
11570
+ return _addListener(this, type2, listener, false);
11571
+ };
11572
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
11573
+ EventEmitter.prototype.prependListener = function prependListener2(type2, listener) {
11574
+ return _addListener(this, type2, listener, true);
11575
+ };
11576
+ function _onceWrap(target, type2, listener) {
11577
+ var fired = false;
11578
+ function g() {
11579
+ target.removeListener(type2, g);
11580
+ if (!fired) {
11581
+ fired = true;
11582
+ listener.apply(target, arguments);
11583
+ }
11273
11584
  }
11274
- return that;
11585
+ g.listener = listener;
11586
+ return g;
11275
11587
  }
11276
- function Buffer2(arg, encodingOrOffset, length) {
11277
- if (!Buffer2.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer2)) {
11278
- return new Buffer2(arg, encodingOrOffset, length);
11279
- }
11280
- if (typeof arg === "number") {
11281
- if (typeof encodingOrOffset === "string") {
11282
- throw new Error(
11283
- "If encoding is specified then the first argument must be a string"
11284
- );
11588
+ EventEmitter.prototype.once = function once(type2, listener) {
11589
+ if (typeof listener !== "function")
11590
+ throw new TypeError('"listener" argument must be a function');
11591
+ this.on(type2, _onceWrap(this, type2, listener));
11592
+ return this;
11593
+ };
11594
+ EventEmitter.prototype.prependOnceListener = function prependOnceListener(type2, listener) {
11595
+ if (typeof listener !== "function")
11596
+ throw new TypeError('"listener" argument must be a function');
11597
+ this.prependListener(type2, _onceWrap(this, type2, listener));
11598
+ return this;
11599
+ };
11600
+ EventEmitter.prototype.removeListener = function removeListener(type2, listener) {
11601
+ var list, events, position, i, originalListener;
11602
+ if (typeof listener !== "function")
11603
+ throw new TypeError('"listener" argument must be a function');
11604
+ events = this._events;
11605
+ if (!events)
11606
+ return this;
11607
+ list = events[type2];
11608
+ if (!list)
11609
+ return this;
11610
+ if (list === listener || list.listener && list.listener === listener) {
11611
+ if (--this._eventsCount === 0)
11612
+ this._events = new EventHandlers();
11613
+ else {
11614
+ delete events[type2];
11615
+ if (events.removeListener)
11616
+ this.emit("removeListener", type2, list.listener || listener);
11285
11617
  }
11286
- return allocUnsafe2(this, arg);
11618
+ } else if (typeof list !== "function") {
11619
+ position = -1;
11620
+ for (i = list.length; i-- > 0; ) {
11621
+ if (list[i] === listener || list[i].listener && list[i].listener === listener) {
11622
+ originalListener = list[i].listener;
11623
+ position = i;
11624
+ break;
11625
+ }
11626
+ }
11627
+ if (position < 0)
11628
+ return this;
11629
+ if (list.length === 1) {
11630
+ list[0] = void 0;
11631
+ if (--this._eventsCount === 0) {
11632
+ this._events = new EventHandlers();
11633
+ return this;
11634
+ } else {
11635
+ delete events[type2];
11636
+ }
11637
+ } else {
11638
+ spliceOne(list, position);
11639
+ }
11640
+ if (events.removeListener)
11641
+ this.emit("removeListener", type2, originalListener || listener);
11287
11642
  }
11288
- return from(this, arg, encodingOrOffset, length);
11289
- }
11290
- Buffer2.poolSize = 8192;
11291
- Buffer2._augment = function(arr) {
11292
- arr.__proto__ = Buffer2.prototype;
11293
- return arr;
11643
+ return this;
11294
11644
  };
11295
- function from(that, value, encodingOrOffset, length) {
11296
- if (typeof value === "number") {
11297
- throw new TypeError('"value" argument must not be a number');
11645
+ EventEmitter.prototype.removeAllListeners = function removeAllListeners(type2) {
11646
+ var listeners, events;
11647
+ events = this._events;
11648
+ if (!events)
11649
+ return this;
11650
+ if (!events.removeListener) {
11651
+ if (arguments.length === 0) {
11652
+ this._events = new EventHandlers();
11653
+ this._eventsCount = 0;
11654
+ } else if (events[type2]) {
11655
+ if (--this._eventsCount === 0)
11656
+ this._events = new EventHandlers();
11657
+ else
11658
+ delete events[type2];
11659
+ }
11660
+ return this;
11298
11661
  }
11299
- if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) {
11300
- return fromArrayBuffer(that, value, encodingOrOffset, length);
11662
+ if (arguments.length === 0) {
11663
+ var keys3 = Object.keys(events);
11664
+ for (var i = 0, key; i < keys3.length; ++i) {
11665
+ key = keys3[i];
11666
+ if (key === "removeListener")
11667
+ continue;
11668
+ this.removeAllListeners(key);
11669
+ }
11670
+ this.removeAllListeners("removeListener");
11671
+ this._events = new EventHandlers();
11672
+ this._eventsCount = 0;
11673
+ return this;
11301
11674
  }
11302
- if (typeof value === "string") {
11303
- return fromString(that, value, encodingOrOffset);
11675
+ listeners = events[type2];
11676
+ if (typeof listeners === "function") {
11677
+ this.removeListener(type2, listeners);
11678
+ } else if (listeners) {
11679
+ do {
11680
+ this.removeListener(type2, listeners[listeners.length - 1]);
11681
+ } while (listeners[0]);
11304
11682
  }
11305
- return fromObject(that, value);
11306
- }
11307
- Buffer2.from = function(value, encodingOrOffset, length) {
11308
- return from(null, value, encodingOrOffset, length);
11683
+ return this;
11309
11684
  };
11310
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
11311
- Buffer2.prototype.__proto__ = Uint8Array.prototype;
11312
- Buffer2.__proto__ = Uint8Array;
11313
- }
11314
- function assertSize(size) {
11315
- if (typeof size !== "number") {
11316
- throw new TypeError('"size" argument must be a number');
11317
- } else if (size < 0) {
11318
- throw new RangeError('"size" argument must not be negative');
11319
- }
11320
- }
11321
- function alloc(that, size, fill, encoding) {
11322
- assertSize(size);
11323
- if (size <= 0) {
11324
- return createBuffer(that, size);
11685
+ EventEmitter.prototype.listeners = function listeners(type2) {
11686
+ var evlistener;
11687
+ var ret;
11688
+ var events = this._events;
11689
+ if (!events)
11690
+ ret = [];
11691
+ else {
11692
+ evlistener = events[type2];
11693
+ if (!evlistener)
11694
+ ret = [];
11695
+ else if (typeof evlistener === "function")
11696
+ ret = [evlistener.listener || evlistener];
11697
+ else
11698
+ ret = unwrapListeners(evlistener);
11325
11699
  }
11326
- if (fill !== void 0) {
11327
- return typeof encoding === "string" ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill);
11700
+ return ret;
11701
+ };
11702
+ EventEmitter.listenerCount = function(emitter, type2) {
11703
+ if (typeof emitter.listenerCount === "function") {
11704
+ return emitter.listenerCount(type2);
11705
+ } else {
11706
+ return listenerCount.call(emitter, type2);
11328
11707
  }
11329
- return createBuffer(that, size);
11330
- }
11331
- Buffer2.alloc = function(size, fill, encoding) {
11332
- return alloc(null, size, fill, encoding);
11333
11708
  };
11334
- function allocUnsafe2(that, size) {
11335
- assertSize(size);
11336
- that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
11337
- if (!Buffer2.TYPED_ARRAY_SUPPORT) {
11338
- for (var i = 0; i < size; ++i) {
11339
- that[i] = 0;
11709
+ EventEmitter.prototype.listenerCount = listenerCount;
11710
+ function listenerCount(type2) {
11711
+ var events = this._events;
11712
+ if (events) {
11713
+ var evlistener = events[type2];
11714
+ if (typeof evlistener === "function") {
11715
+ return 1;
11716
+ } else if (evlistener) {
11717
+ return evlistener.length;
11340
11718
  }
11341
11719
  }
11342
- return that;
11720
+ return 0;
11343
11721
  }
11344
- Buffer2.allocUnsafe = function(size) {
11345
- return allocUnsafe2(null, size);
11346
- };
11347
- Buffer2.allocUnsafeSlow = function(size) {
11348
- return allocUnsafe2(null, size);
11722
+ EventEmitter.prototype.eventNames = function eventNames() {
11723
+ return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
11349
11724
  };
11350
- function fromString(that, string, encoding) {
11351
- if (typeof encoding !== "string" || encoding === "") {
11352
- encoding = "utf8";
11353
- }
11354
- if (!Buffer2.isEncoding(encoding)) {
11355
- throw new TypeError('"encoding" must be a valid string encoding');
11356
- }
11357
- var length = byteLength(string, encoding) | 0;
11358
- that = createBuffer(that, length);
11359
- var actual = that.write(string, encoding);
11360
- if (actual !== length) {
11361
- that = that.slice(0, actual);
11362
- }
11363
- return that;
11725
+ function spliceOne(list, index) {
11726
+ for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
11727
+ list[i] = list[k];
11728
+ list.pop();
11364
11729
  }
11365
- function fromArrayLike(that, array) {
11366
- var length = array.length < 0 ? 0 : checked(array.length) | 0;
11367
- that = createBuffer(that, length);
11368
- for (var i = 0; i < length; i += 1) {
11369
- that[i] = array[i] & 255;
11370
- }
11371
- return that;
11730
+ function arrayClone(arr, i) {
11731
+ var copy = new Array(i);
11732
+ while (i--)
11733
+ copy[i] = arr[i];
11734
+ return copy;
11372
11735
  }
11373
- function fromArrayBuffer(that, array, byteOffset, length) {
11374
- array.byteLength;
11375
- if (byteOffset < 0 || array.byteLength < byteOffset) {
11376
- throw new RangeError("'offset' is out of bounds");
11736
+ function unwrapListeners(arr) {
11737
+ var ret = new Array(arr.length);
11738
+ for (var i = 0; i < ret.length; ++i) {
11739
+ ret[i] = arr[i].listener || arr[i];
11377
11740
  }
11378
- if (array.byteLength < byteOffset + (length || 0)) {
11379
- throw new RangeError("'length' is out of bounds");
11741
+ return ret;
11742
+ }
11743
+ var global$1 = typeof commonjsGlobal !== "undefined" ? commonjsGlobal : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
11744
+ var lookup = [];
11745
+ var revLookup = [];
11746
+ var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
11747
+ var inited = false;
11748
+ function init() {
11749
+ inited = true;
11750
+ var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
11751
+ for (var i = 0, len = code.length; i < len; ++i) {
11752
+ lookup[i] = code[i];
11753
+ revLookup[code.charCodeAt(i)] = i;
11380
11754
  }
11381
- if (byteOffset === void 0 && length === void 0) {
11382
- array = new Uint8Array(array);
11383
- } else if (length === void 0) {
11384
- array = new Uint8Array(array, byteOffset);
11385
- } else {
11386
- array = new Uint8Array(array, byteOffset, length);
11755
+ revLookup["-".charCodeAt(0)] = 62;
11756
+ revLookup["_".charCodeAt(0)] = 63;
11757
+ }
11758
+ function toByteArray(b64) {
11759
+ if (!inited) {
11760
+ init();
11387
11761
  }
11388
- if (Buffer2.TYPED_ARRAY_SUPPORT) {
11389
- that = array;
11390
- that.__proto__ = Buffer2.prototype;
11391
- } else {
11392
- that = fromArrayLike(that, array);
11762
+ var i, j, l, tmp, placeHolders, arr;
11763
+ var len = b64.length;
11764
+ if (len % 4 > 0) {
11765
+ throw new Error("Invalid string. Length must be a multiple of 4");
11393
11766
  }
11394
- return that;
11395
- }
11396
- function fromObject(that, obj) {
11397
- if (internalIsBuffer(obj)) {
11398
- var len = checked(obj.length) | 0;
11399
- that = createBuffer(that, len);
11400
- if (that.length === 0) {
11401
- return that;
11402
- }
11403
- obj.copy(that, 0, 0, len);
11404
- return that;
11767
+ placeHolders = b64[len - 2] === "=" ? 2 : b64[len - 1] === "=" ? 1 : 0;
11768
+ arr = new Arr(len * 3 / 4 - placeHolders);
11769
+ l = placeHolders > 0 ? len - 4 : len;
11770
+ var L = 0;
11771
+ for (i = 0, j = 0; i < l; i += 4, j += 3) {
11772
+ tmp = revLookup[b64.charCodeAt(i)] << 18 | revLookup[b64.charCodeAt(i + 1)] << 12 | revLookup[b64.charCodeAt(i + 2)] << 6 | revLookup[b64.charCodeAt(i + 3)];
11773
+ arr[L++] = tmp >> 16 & 255;
11774
+ arr[L++] = tmp >> 8 & 255;
11775
+ arr[L++] = tmp & 255;
11405
11776
  }
11406
- if (obj) {
11407
- if (typeof ArrayBuffer !== "undefined" && obj.buffer instanceof ArrayBuffer || "length" in obj) {
11408
- if (typeof obj.length !== "number" || isnan(obj.length)) {
11409
- return createBuffer(that, 0);
11410
- }
11411
- return fromArrayLike(that, obj);
11412
- }
11413
- if (obj.type === "Buffer" && isArray2(obj.data)) {
11414
- return fromArrayLike(that, obj.data);
11415
- }
11777
+ if (placeHolders === 2) {
11778
+ tmp = revLookup[b64.charCodeAt(i)] << 2 | revLookup[b64.charCodeAt(i + 1)] >> 4;
11779
+ arr[L++] = tmp & 255;
11780
+ } else if (placeHolders === 1) {
11781
+ tmp = revLookup[b64.charCodeAt(i)] << 10 | revLookup[b64.charCodeAt(i + 1)] << 4 | revLookup[b64.charCodeAt(i + 2)] >> 2;
11782
+ arr[L++] = tmp >> 8 & 255;
11783
+ arr[L++] = tmp & 255;
11416
11784
  }
11417
- throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
11785
+ return arr;
11418
11786
  }
11419
- function checked(length) {
11420
- if (length >= kMaxLength()) {
11421
- throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + kMaxLength().toString(16) + " bytes");
11422
- }
11423
- return length | 0;
11787
+ function tripletToBase64(num) {
11788
+ return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
11424
11789
  }
11425
- Buffer2.isBuffer = isBuffer2;
11426
- function internalIsBuffer(b) {
11427
- return !!(b != null && b._isBuffer);
11790
+ function encodeChunk(uint8, start, end) {
11791
+ var tmp;
11792
+ var output = [];
11793
+ for (var i = start; i < end; i += 3) {
11794
+ tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + uint8[i + 2];
11795
+ output.push(tripletToBase64(tmp));
11796
+ }
11797
+ return output.join("");
11428
11798
  }
11429
- Buffer2.compare = function compare2(a, b) {
11430
- if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
11431
- throw new TypeError("Arguments must be Buffers");
11799
+ function fromByteArray(uint8) {
11800
+ if (!inited) {
11801
+ init();
11432
11802
  }
11433
- if (a === b)
11434
- return 0;
11435
- var x = a.length;
11436
- var y = b.length;
11437
- for (var i = 0, len = Math.min(x, y); i < len; ++i) {
11438
- if (a[i] !== b[i]) {
11439
- x = a[i];
11440
- y = b[i];
11441
- break;
11442
- }
11803
+ var tmp;
11804
+ var len = uint8.length;
11805
+ var extraBytes = len % 3;
11806
+ var output = "";
11807
+ var parts = [];
11808
+ var maxChunkLength = 16383;
11809
+ for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
11810
+ parts.push(encodeChunk(uint8, i, i + maxChunkLength > len2 ? len2 : i + maxChunkLength));
11443
11811
  }
11444
- if (x < y)
11445
- return -1;
11446
- if (y < x)
11447
- return 1;
11448
- return 0;
11449
- };
11450
- Buffer2.isEncoding = function isEncoding(encoding) {
11451
- switch (String(encoding).toLowerCase()) {
11452
- case "hex":
11453
- case "utf8":
11454
- case "utf-8":
11455
- case "ascii":
11456
- case "latin1":
11457
- case "binary":
11458
- case "base64":
11459
- case "ucs2":
11460
- case "ucs-2":
11461
- case "utf16le":
11462
- case "utf-16le":
11463
- return true;
11464
- default:
11465
- return false;
11812
+ if (extraBytes === 1) {
11813
+ tmp = uint8[len - 1];
11814
+ output += lookup[tmp >> 2];
11815
+ output += lookup[tmp << 4 & 63];
11816
+ output += "==";
11817
+ } else if (extraBytes === 2) {
11818
+ tmp = (uint8[len - 2] << 8) + uint8[len - 1];
11819
+ output += lookup[tmp >> 10];
11820
+ output += lookup[tmp >> 4 & 63];
11821
+ output += lookup[tmp << 2 & 63];
11822
+ output += "=";
11466
11823
  }
11467
- };
11468
- Buffer2.concat = function concat(list, length) {
11469
- if (!isArray2(list)) {
11470
- throw new TypeError('"list" argument must be an Array of Buffers');
11824
+ parts.push(output);
11825
+ return parts.join("");
11826
+ }
11827
+ function read(buffer, offset, isLE, mLen, nBytes) {
11828
+ var e, m;
11829
+ var eLen = nBytes * 8 - mLen - 1;
11830
+ var eMax = (1 << eLen) - 1;
11831
+ var eBias = eMax >> 1;
11832
+ var nBits = -7;
11833
+ var i = isLE ? nBytes - 1 : 0;
11834
+ var d = isLE ? -1 : 1;
11835
+ var s = buffer[offset + i];
11836
+ i += d;
11837
+ e = s & (1 << -nBits) - 1;
11838
+ s >>= -nBits;
11839
+ nBits += eLen;
11840
+ for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {
11471
11841
  }
11472
- if (list.length === 0) {
11473
- return Buffer2.alloc(0);
11842
+ m = e & (1 << -nBits) - 1;
11843
+ e >>= -nBits;
11844
+ nBits += mLen;
11845
+ for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {
11474
11846
  }
11475
- var i;
11476
- if (length === void 0) {
11477
- length = 0;
11478
- for (i = 0; i < list.length; ++i) {
11479
- length += list[i].length;
11480
- }
11847
+ if (e === 0) {
11848
+ e = 1 - eBias;
11849
+ } else if (e === eMax) {
11850
+ return m ? NaN : (s ? -1 : 1) * Infinity;
11851
+ } else {
11852
+ m = m + Math.pow(2, mLen);
11853
+ e = e - eBias;
11481
11854
  }
11482
- var buffer = Buffer2.allocUnsafe(length);
11483
- var pos = 0;
11484
- for (i = 0; i < list.length; ++i) {
11485
- var buf = list[i];
11486
- if (!internalIsBuffer(buf)) {
11487
- throw new TypeError('"list" argument must be an Array of Buffers');
11855
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
11856
+ }
11857
+ function write(buffer, value, offset, isLE, mLen, nBytes) {
11858
+ var e, m, c;
11859
+ var eLen = nBytes * 8 - mLen - 1;
11860
+ var eMax = (1 << eLen) - 1;
11861
+ var eBias = eMax >> 1;
11862
+ var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
11863
+ var i = isLE ? 0 : nBytes - 1;
11864
+ var d = isLE ? 1 : -1;
11865
+ var s = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
11866
+ value = Math.abs(value);
11867
+ if (isNaN(value) || value === Infinity) {
11868
+ m = isNaN(value) ? 1 : 0;
11869
+ e = eMax;
11870
+ } else {
11871
+ e = Math.floor(Math.log(value) / Math.LN2);
11872
+ if (value * (c = Math.pow(2, -e)) < 1) {
11873
+ e--;
11874
+ c *= 2;
11875
+ }
11876
+ if (e + eBias >= 1) {
11877
+ value += rt / c;
11878
+ } else {
11879
+ value += rt * Math.pow(2, 1 - eBias);
11880
+ }
11881
+ if (value * c >= 2) {
11882
+ e++;
11883
+ c /= 2;
11884
+ }
11885
+ if (e + eBias >= eMax) {
11886
+ m = 0;
11887
+ e = eMax;
11888
+ } else if (e + eBias >= 1) {
11889
+ m = (value * c - 1) * Math.pow(2, mLen);
11890
+ e = e + eBias;
11891
+ } else {
11892
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
11893
+ e = 0;
11488
11894
  }
11489
- buf.copy(buffer, pos);
11490
- pos += buf.length;
11491
11895
  }
11492
- return buffer;
11493
- };
11494
- function byteLength(string, encoding) {
11495
- if (internalIsBuffer(string)) {
11496
- return string.length;
11896
+ for (; mLen >= 8; buffer[offset + i] = m & 255, i += d, m /= 256, mLen -= 8) {
11497
11897
  }
11498
- if (typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
11499
- return string.byteLength;
11898
+ e = e << mLen | m;
11899
+ eLen += mLen;
11900
+ for (; eLen > 0; buffer[offset + i] = e & 255, i += d, e /= 256, eLen -= 8) {
11500
11901
  }
11501
- if (typeof string !== "string") {
11502
- string = "" + string;
11902
+ buffer[offset + i - d] |= s * 128;
11903
+ }
11904
+ var toString = {}.toString;
11905
+ var isArray2 = Array.isArray || function(arr) {
11906
+ return toString.call(arr) == "[object Array]";
11907
+ };
11908
+ var INSPECT_MAX_BYTES = 50;
11909
+ Buffer2.TYPED_ARRAY_SUPPORT = global$1.TYPED_ARRAY_SUPPORT !== void 0 ? global$1.TYPED_ARRAY_SUPPORT : true;
11910
+ function kMaxLength() {
11911
+ return Buffer2.TYPED_ARRAY_SUPPORT ? 2147483647 : 1073741823;
11912
+ }
11913
+ function createBuffer(that, length) {
11914
+ if (kMaxLength() < length) {
11915
+ throw new RangeError("Invalid typed array length");
11503
11916
  }
11504
- var len = string.length;
11505
- if (len === 0)
11506
- return 0;
11507
- var loweredCase = false;
11508
- for (; ; ) {
11509
- switch (encoding) {
11510
- case "ascii":
11511
- case "latin1":
11917
+ if (Buffer2.TYPED_ARRAY_SUPPORT) {
11918
+ that = new Uint8Array(length);
11919
+ that.__proto__ = Buffer2.prototype;
11920
+ } else {
11921
+ if (that === null) {
11922
+ that = new Buffer2(length);
11923
+ }
11924
+ that.length = length;
11925
+ }
11926
+ return that;
11927
+ }
11928
+ function Buffer2(arg, encodingOrOffset, length) {
11929
+ if (!Buffer2.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer2)) {
11930
+ return new Buffer2(arg, encodingOrOffset, length);
11931
+ }
11932
+ if (typeof arg === "number") {
11933
+ if (typeof encodingOrOffset === "string") {
11934
+ throw new Error(
11935
+ "If encoding is specified then the first argument must be a string"
11936
+ );
11937
+ }
11938
+ return allocUnsafe2(this, arg);
11939
+ }
11940
+ return from(this, arg, encodingOrOffset, length);
11941
+ }
11942
+ Buffer2.poolSize = 8192;
11943
+ Buffer2._augment = function(arr) {
11944
+ arr.__proto__ = Buffer2.prototype;
11945
+ return arr;
11946
+ };
11947
+ function from(that, value, encodingOrOffset, length) {
11948
+ if (typeof value === "number") {
11949
+ throw new TypeError('"value" argument must not be a number');
11950
+ }
11951
+ if (typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer) {
11952
+ return fromArrayBuffer(that, value, encodingOrOffset, length);
11953
+ }
11954
+ if (typeof value === "string") {
11955
+ return fromString(that, value, encodingOrOffset);
11956
+ }
11957
+ return fromObject(that, value);
11958
+ }
11959
+ Buffer2.from = function(value, encodingOrOffset, length) {
11960
+ return from(null, value, encodingOrOffset, length);
11961
+ };
11962
+ if (Buffer2.TYPED_ARRAY_SUPPORT) {
11963
+ Buffer2.prototype.__proto__ = Uint8Array.prototype;
11964
+ Buffer2.__proto__ = Uint8Array;
11965
+ }
11966
+ function assertSize(size) {
11967
+ if (typeof size !== "number") {
11968
+ throw new TypeError('"size" argument must be a number');
11969
+ } else if (size < 0) {
11970
+ throw new RangeError('"size" argument must not be negative');
11971
+ }
11972
+ }
11973
+ function alloc(that, size, fill, encoding) {
11974
+ assertSize(size);
11975
+ if (size <= 0) {
11976
+ return createBuffer(that, size);
11977
+ }
11978
+ if (fill !== void 0) {
11979
+ return typeof encoding === "string" ? createBuffer(that, size).fill(fill, encoding) : createBuffer(that, size).fill(fill);
11980
+ }
11981
+ return createBuffer(that, size);
11982
+ }
11983
+ Buffer2.alloc = function(size, fill, encoding) {
11984
+ return alloc(null, size, fill, encoding);
11985
+ };
11986
+ function allocUnsafe2(that, size) {
11987
+ assertSize(size);
11988
+ that = createBuffer(that, size < 0 ? 0 : checked(size) | 0);
11989
+ if (!Buffer2.TYPED_ARRAY_SUPPORT) {
11990
+ for (var i = 0; i < size; ++i) {
11991
+ that[i] = 0;
11992
+ }
11993
+ }
11994
+ return that;
11995
+ }
11996
+ Buffer2.allocUnsafe = function(size) {
11997
+ return allocUnsafe2(null, size);
11998
+ };
11999
+ Buffer2.allocUnsafeSlow = function(size) {
12000
+ return allocUnsafe2(null, size);
12001
+ };
12002
+ function fromString(that, string, encoding) {
12003
+ if (typeof encoding !== "string" || encoding === "") {
12004
+ encoding = "utf8";
12005
+ }
12006
+ if (!Buffer2.isEncoding(encoding)) {
12007
+ throw new TypeError('"encoding" must be a valid string encoding');
12008
+ }
12009
+ var length = byteLength(string, encoding) | 0;
12010
+ that = createBuffer(that, length);
12011
+ var actual = that.write(string, encoding);
12012
+ if (actual !== length) {
12013
+ that = that.slice(0, actual);
12014
+ }
12015
+ return that;
12016
+ }
12017
+ function fromArrayLike(that, array) {
12018
+ var length = array.length < 0 ? 0 : checked(array.length) | 0;
12019
+ that = createBuffer(that, length);
12020
+ for (var i = 0; i < length; i += 1) {
12021
+ that[i] = array[i] & 255;
12022
+ }
12023
+ return that;
12024
+ }
12025
+ function fromArrayBuffer(that, array, byteOffset, length) {
12026
+ array.byteLength;
12027
+ if (byteOffset < 0 || array.byteLength < byteOffset) {
12028
+ throw new RangeError("'offset' is out of bounds");
12029
+ }
12030
+ if (array.byteLength < byteOffset + (length || 0)) {
12031
+ throw new RangeError("'length' is out of bounds");
12032
+ }
12033
+ if (byteOffset === void 0 && length === void 0) {
12034
+ array = new Uint8Array(array);
12035
+ } else if (length === void 0) {
12036
+ array = new Uint8Array(array, byteOffset);
12037
+ } else {
12038
+ array = new Uint8Array(array, byteOffset, length);
12039
+ }
12040
+ if (Buffer2.TYPED_ARRAY_SUPPORT) {
12041
+ that = array;
12042
+ that.__proto__ = Buffer2.prototype;
12043
+ } else {
12044
+ that = fromArrayLike(that, array);
12045
+ }
12046
+ return that;
12047
+ }
12048
+ function fromObject(that, obj) {
12049
+ if (internalIsBuffer(obj)) {
12050
+ var len = checked(obj.length) | 0;
12051
+ that = createBuffer(that, len);
12052
+ if (that.length === 0) {
12053
+ return that;
12054
+ }
12055
+ obj.copy(that, 0, 0, len);
12056
+ return that;
12057
+ }
12058
+ if (obj) {
12059
+ if (typeof ArrayBuffer !== "undefined" && obj.buffer instanceof ArrayBuffer || "length" in obj) {
12060
+ if (typeof obj.length !== "number" || isnan(obj.length)) {
12061
+ return createBuffer(that, 0);
12062
+ }
12063
+ return fromArrayLike(that, obj);
12064
+ }
12065
+ if (obj.type === "Buffer" && isArray2(obj.data)) {
12066
+ return fromArrayLike(that, obj.data);
12067
+ }
12068
+ }
12069
+ throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.");
12070
+ }
12071
+ function checked(length) {
12072
+ if (length >= kMaxLength()) {
12073
+ throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + kMaxLength().toString(16) + " bytes");
12074
+ }
12075
+ return length | 0;
12076
+ }
12077
+ Buffer2.isBuffer = isBuffer2;
12078
+ function internalIsBuffer(b) {
12079
+ return !!(b != null && b._isBuffer);
12080
+ }
12081
+ Buffer2.compare = function compare2(a, b) {
12082
+ if (!internalIsBuffer(a) || !internalIsBuffer(b)) {
12083
+ throw new TypeError("Arguments must be Buffers");
12084
+ }
12085
+ if (a === b)
12086
+ return 0;
12087
+ var x = a.length;
12088
+ var y = b.length;
12089
+ for (var i = 0, len = Math.min(x, y); i < len; ++i) {
12090
+ if (a[i] !== b[i]) {
12091
+ x = a[i];
12092
+ y = b[i];
12093
+ break;
12094
+ }
12095
+ }
12096
+ if (x < y)
12097
+ return -1;
12098
+ if (y < x)
12099
+ return 1;
12100
+ return 0;
12101
+ };
12102
+ Buffer2.isEncoding = function isEncoding(encoding) {
12103
+ switch (String(encoding).toLowerCase()) {
12104
+ case "hex":
12105
+ case "utf8":
12106
+ case "utf-8":
12107
+ case "ascii":
12108
+ case "latin1":
12109
+ case "binary":
12110
+ case "base64":
12111
+ case "ucs2":
12112
+ case "ucs-2":
12113
+ case "utf16le":
12114
+ case "utf-16le":
12115
+ return true;
12116
+ default:
12117
+ return false;
12118
+ }
12119
+ };
12120
+ Buffer2.concat = function concat(list, length) {
12121
+ if (!isArray2(list)) {
12122
+ throw new TypeError('"list" argument must be an Array of Buffers');
12123
+ }
12124
+ if (list.length === 0) {
12125
+ return Buffer2.alloc(0);
12126
+ }
12127
+ var i;
12128
+ if (length === void 0) {
12129
+ length = 0;
12130
+ for (i = 0; i < list.length; ++i) {
12131
+ length += list[i].length;
12132
+ }
12133
+ }
12134
+ var buffer = Buffer2.allocUnsafe(length);
12135
+ var pos = 0;
12136
+ for (i = 0; i < list.length; ++i) {
12137
+ var buf = list[i];
12138
+ if (!internalIsBuffer(buf)) {
12139
+ throw new TypeError('"list" argument must be an Array of Buffers');
12140
+ }
12141
+ buf.copy(buffer, pos);
12142
+ pos += buf.length;
12143
+ }
12144
+ return buffer;
12145
+ };
12146
+ function byteLength(string, encoding) {
12147
+ if (internalIsBuffer(string)) {
12148
+ return string.length;
12149
+ }
12150
+ if (typeof ArrayBuffer !== "undefined" && typeof ArrayBuffer.isView === "function" && (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
12151
+ return string.byteLength;
12152
+ }
12153
+ if (typeof string !== "string") {
12154
+ string = "" + string;
12155
+ }
12156
+ var len = string.length;
12157
+ if (len === 0)
12158
+ return 0;
12159
+ var loweredCase = false;
12160
+ for (; ; ) {
12161
+ switch (encoding) {
12162
+ case "ascii":
12163
+ case "latin1":
11512
12164
  case "binary":
11513
12165
  return len;
11514
12166
  case "utf8":
@@ -16038,942 +16690,203 @@ var json2csv_umd = { exports: {} };
16038
16690
  processedData.forEach(function(row) {
16039
16691
  var line = _this2.processRow(row, _this2.opts);
16040
16692
  if (line === void 0)
16041
- return;
16042
- _this2.emit("line", line);
16043
- _this2.push(_this2._hasWritten ? _this2.opts.eol + line : line);
16044
- _this2._hasWritten = true;
16045
- });
16046
- }
16047
- }]);
16048
- return JSON2CSVTransform2;
16049
- }(Transform$1);
16050
- var JSON2CSVTransform_1 = JSON2CSVTransform;
16051
- var Transform$2 = Stream.Transform;
16052
- var fastJoin$3 = utils.fastJoin;
16053
- var JSON2CSVAsyncParser = /* @__PURE__ */ function() {
16054
- function JSON2CSVAsyncParser2(opts2, transformOpts) {
16055
- _classCallCheck(this, JSON2CSVAsyncParser2);
16056
- this.input = new Transform$2(transformOpts);
16057
- this.input._read = function() {
16058
- };
16059
- this.transform = new JSON2CSVTransform_1(opts2, transformOpts);
16060
- this.processor = this.input.pipe(this.transform);
16061
- }
16062
- _createClass(JSON2CSVAsyncParser2, [{
16063
- key: "fromInput",
16064
- value: function fromInput(input) {
16065
- if (this._input) {
16066
- throw new Error("Async parser already has an input.");
16067
- }
16068
- this._input = input;
16069
- this.input = this._input.pipe(this.processor);
16070
- return this;
16071
- }
16072
- }, {
16073
- key: "throughTransform",
16074
- value: function throughTransform(transform) {
16075
- if (this._output) {
16076
- throw new Error("Can't add transforms once an output has been added.");
16077
- }
16078
- this.processor = this.processor.pipe(transform);
16079
- return this;
16080
- }
16081
- }, {
16082
- key: "toOutput",
16083
- value: function toOutput(output) {
16084
- if (this._output) {
16085
- throw new Error("Async parser already has an output.");
16086
- }
16087
- this._output = output;
16088
- this.processor = this.processor.pipe(output);
16089
- return this;
16090
- }
16091
- }, {
16092
- key: "promise",
16093
- value: function promise() {
16094
- var _this = this;
16095
- var returnCSV = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
16096
- return new Promise(function(resolve, reject) {
16097
- if (!returnCSV) {
16098
- _this.processor.on("finish", function() {
16099
- return resolve();
16100
- }).on("error", function(err) {
16101
- return reject(err);
16102
- });
16103
- return;
16104
- }
16105
- var csvBuffer = [];
16106
- _this.processor.on("data", function(chunk) {
16107
- return csvBuffer.push(chunk.toString());
16108
- }).on("finish", function() {
16109
- return resolve(fastJoin$3(csvBuffer, ""));
16110
- }).on("error", function(err) {
16111
- return reject(err);
16112
- });
16113
- });
16114
- }
16115
- }]);
16116
- return JSON2CSVAsyncParser2;
16117
- }();
16118
- var JSON2CSVAsyncParser_1 = JSON2CSVAsyncParser;
16119
- function flatten() {
16120
- var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref$objects = _ref.objects, objects = _ref$objects === void 0 ? true : _ref$objects, _ref$arrays = _ref.arrays, arrays = _ref$arrays === void 0 ? false : _ref$arrays, _ref$separator = _ref.separator, separator = _ref$separator === void 0 ? "." : _ref$separator;
16121
- function step(obj, flatDataRow, currentPath) {
16122
- Object.keys(obj).forEach(function(key) {
16123
- var newPath = currentPath ? "".concat(currentPath).concat(separator).concat(key) : key;
16124
- var value = obj[key];
16125
- if (objects && _typeof(value) === "object" && value !== null && !Array.isArray(value) && Object.prototype.toString.call(value.toJSON) !== "[object Function]" && Object.keys(value).length) {
16126
- step(value, flatDataRow, newPath);
16127
- return;
16128
- }
16129
- if (arrays && Array.isArray(value)) {
16130
- step(value, flatDataRow, newPath);
16131
- return;
16132
- }
16133
- flatDataRow[newPath] = value;
16134
- });
16135
- return flatDataRow;
16136
- }
16137
- return function(dataRow) {
16138
- return step(dataRow, {});
16139
- };
16140
- }
16141
- var flatten_1 = flatten;
16142
- var setProp$1 = utils.setProp, unsetProp$1 = utils.unsetProp, flattenReducer$3 = utils.flattenReducer;
16143
- function getUnwindablePaths(obj, currentPath) {
16144
- return Object.keys(obj).reduce(function(unwindablePaths, key) {
16145
- var newPath = currentPath ? "".concat(currentPath, ".").concat(key) : key;
16146
- var value = obj[key];
16147
- if (_typeof(value) === "object" && value !== null && !Array.isArray(value) && Object.prototype.toString.call(value.toJSON) !== "[object Function]" && Object.keys(value).length) {
16148
- unwindablePaths = unwindablePaths.concat(getUnwindablePaths(value, newPath));
16149
- } else if (Array.isArray(value)) {
16150
- unwindablePaths.push(newPath);
16151
- unwindablePaths = unwindablePaths.concat(value.map(function(arrObj) {
16152
- return getUnwindablePaths(arrObj, newPath);
16153
- }).reduce(flattenReducer$3, []).filter(function(item, index, arr) {
16154
- return arr.indexOf(item) !== index;
16155
- }));
16156
- }
16157
- return unwindablePaths;
16158
- }, []);
16159
- }
16160
- function unwind() {
16161
- var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref$paths = _ref.paths, paths = _ref$paths === void 0 ? void 0 : _ref$paths, _ref$blankOut = _ref.blankOut, blankOut = _ref$blankOut === void 0 ? false : _ref$blankOut;
16162
- function unwindReducer(rows, unwindPath) {
16163
- return rows.map(function(row) {
16164
- var unwindArray = lodash_get(row, unwindPath);
16165
- if (!Array.isArray(unwindArray)) {
16166
- return row;
16167
- }
16168
- if (!unwindArray.length) {
16169
- return unsetProp$1(row, unwindPath);
16170
- }
16171
- return unwindArray.map(function(unwindRow, index) {
16172
- var clonedRow = blankOut && index > 0 ? {} : row;
16173
- return setProp$1(clonedRow, unwindPath, unwindRow);
16174
- });
16175
- }).reduce(flattenReducer$3, []);
16176
- }
16177
- paths = Array.isArray(paths) ? paths : paths ? [paths] : void 0;
16178
- return function(dataRow) {
16179
- return (paths || getUnwindablePaths(dataRow)).reduce(unwindReducer, [dataRow]);
16180
- };
16181
- }
16182
- var unwind_1 = unwind;
16183
- var Readable$1 = Stream.Readable;
16184
- var Parser$1 = JSON2CSVParser_1;
16185
- var AsyncParser = JSON2CSVAsyncParser_1;
16186
- var Transform$3 = JSON2CSVTransform_1;
16187
- var parse2 = function parse3(data, opts2) {
16188
- return new JSON2CSVParser_1(opts2).parse(data);
16189
- };
16190
- var parseAsync = function parseAsync2(data, opts2, transformOpts) {
16191
- try {
16192
- if (!(data instanceof Readable$1)) {
16193
- transformOpts = Object.assign({}, transformOpts, {
16194
- objectMode: true
16195
- });
16196
- }
16197
- var asyncParser = new JSON2CSVAsyncParser_1(opts2, transformOpts);
16198
- var promise = asyncParser.promise();
16199
- if (Array.isArray(data)) {
16200
- data.forEach(function(item) {
16201
- return asyncParser.input.push(item);
16202
- });
16203
- asyncParser.input.push(null);
16204
- } else if (data instanceof Readable$1) {
16205
- asyncParser.fromInput(data);
16206
- } else {
16207
- asyncParser.input.push(data);
16208
- asyncParser.input.push(null);
16209
- }
16210
- return promise;
16211
- } catch (err) {
16212
- return Promise.reject(err);
16213
- }
16214
- };
16215
- var transforms = {
16216
- flatten: flatten_1,
16217
- unwind: unwind_1
16218
- };
16219
- var json2csv = {
16220
- Parser: Parser$1,
16221
- AsyncParser,
16222
- Transform: Transform$3,
16223
- parse: parse2,
16224
- parseAsync,
16225
- transforms
16226
- };
16227
- exports3.AsyncParser = AsyncParser;
16228
- exports3.Parser = Parser$1;
16229
- exports3.Transform = Transform$3;
16230
- exports3.default = json2csv;
16231
- exports3.parse = parse2;
16232
- exports3.parseAsync = parseAsync;
16233
- exports3.transforms = transforms;
16234
- Object.defineProperty(exports3, "__esModule", { value: true });
16235
- });
16236
- })(json2csv_umd, json2csv_umd.exports);
16237
- var json2csv_umdExports = json2csv_umd.exports;
16238
- class InternMap extends Map {
16239
- constructor(entries, key = keyof) {
16240
- super();
16241
- Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } });
16242
- if (entries != null)
16243
- for (const [key2, value] of entries)
16244
- this.set(key2, value);
16245
- }
16246
- get(key) {
16247
- return super.get(intern_get(this, key));
16248
- }
16249
- has(key) {
16250
- return super.has(intern_get(this, key));
16251
- }
16252
- set(key, value) {
16253
- return super.set(intern_set(this, key), value);
16254
- }
16255
- delete(key) {
16256
- return super.delete(intern_delete(this, key));
16257
- }
16258
- }
16259
- function intern_get({ _intern, _key }, value) {
16260
- const key = _key(value);
16261
- return _intern.has(key) ? _intern.get(key) : value;
16262
- }
16263
- function intern_set({ _intern, _key }, value) {
16264
- const key = _key(value);
16265
- if (_intern.has(key))
16266
- return _intern.get(key);
16267
- _intern.set(key, value);
16268
- return value;
16269
- }
16270
- function intern_delete({ _intern, _key }, value) {
16271
- const key = _key(value);
16272
- if (_intern.has(key)) {
16273
- value = _intern.get(key);
16274
- _intern.delete(key);
16275
- }
16276
- return value;
16277
- }
16278
- function keyof(value) {
16279
- return value !== null && typeof value === "object" ? value.valueOf() : value;
16280
- }
16281
- const schemeRdBu = [[103, 0, 31], [178, 24, 43], [214, 96, 77], [244, 165, 130], [253, 219, 199], [247, 247, 247], [209, 229, 240], [146, 197, 222], [67, 147, 195], [33, 102, 172], [5, 48, 97]];
16282
- const schemePlasma = [[13, 8, 135], [16, 7, 136], [19, 7, 137], [22, 7, 138], [25, 6, 140], [27, 6, 141], [29, 6, 142], [32, 6, 143], [34, 6, 144], [36, 6, 145], [38, 5, 145], [40, 5, 146], [42, 5, 147], [44, 5, 148], [46, 5, 149], [47, 5, 150], [49, 5, 151], [51, 5, 151], [53, 4, 152], [55, 4, 153], [56, 4, 154], [58, 4, 154], [60, 4, 155], [62, 4, 156], [63, 4, 156], [65, 4, 157], [67, 3, 158], [68, 3, 158], [70, 3, 159], [72, 3, 159], [73, 3, 160], [75, 3, 161], [76, 2, 161], [78, 2, 162], [80, 2, 162], [81, 2, 163], [83, 2, 163], [85, 2, 164], [86, 1, 164], [88, 1, 164], [89, 1, 165], [91, 1, 165], [92, 1, 166], [94, 1, 166], [96, 1, 166], [97, 0, 167], [99, 0, 167], [100, 0, 167], [102, 0, 167], [103, 0, 168], [105, 0, 168], [106, 0, 168], [108, 0, 168], [110, 0, 168], [111, 0, 168], [113, 0, 168], [114, 1, 168], [116, 1, 168], [117, 1, 168], [119, 1, 168], [120, 1, 168], [122, 2, 168], [123, 2, 168], [125, 3, 168], [126, 3, 168], [128, 4, 168], [129, 4, 167], [131, 5, 167], [132, 5, 167], [134, 6, 166], [135, 7, 166], [136, 8, 166], [138, 9, 165], [139, 10, 165], [141, 11, 165], [142, 12, 164], [143, 13, 164], [145, 14, 163], [146, 15, 163], [148, 16, 162], [149, 17, 161], [150, 19, 161], [152, 20, 160], [153, 21, 159], [154, 22, 159], [156, 23, 158], [157, 24, 157], [158, 25, 157], [160, 26, 156], [161, 27, 155], [162, 29, 154], [163, 30, 154], [165, 31, 153], [166, 32, 152], [167, 33, 151], [168, 34, 150], [170, 35, 149], [171, 36, 148], [172, 38, 148], [173, 39, 147], [174, 40, 146], [176, 41, 145], [177, 42, 144], [178, 43, 143], [179, 44, 142], [180, 46, 141], [181, 47, 140], [182, 48, 139], [183, 49, 138], [184, 50, 137], [186, 51, 136], [187, 52, 136], [188, 53, 135], [189, 55, 134], [190, 56, 133], [191, 57, 132], [192, 58, 131], [193, 59, 130], [194, 60, 129], [195, 61, 128], [196, 62, 127], [197, 64, 126], [198, 65, 125], [199, 66, 124], [200, 67, 123], [201, 68, 122], [202, 69, 122], [203, 70, 121], [204, 71, 120], [204, 73, 119], [205, 74, 118], [206, 75, 117], [207, 76, 116], [208, 77, 115], [209, 78, 114], [210, 79, 113], [211, 81, 113], [212, 82, 112], [213, 83, 111], [213, 84, 110], [214, 85, 109], [215, 86, 108], [216, 87, 107], [217, 88, 106], [218, 90, 106], [218, 91, 105], [219, 92, 104], [220, 93, 103], [221, 94, 102], [222, 95, 101], [222, 97, 100], [223, 98, 99], [224, 99, 99], [225, 100, 98], [226, 101, 97], [226, 102, 96], [227, 104, 95], [228, 105, 94], [229, 106, 93], [229, 107, 93], [230, 108, 92], [231, 110, 91], [231, 111, 90], [232, 112, 89], [233, 113, 88], [233, 114, 87], [234, 116, 87], [235, 117, 86], [235, 118, 85], [236, 119, 84], [237, 121, 83], [237, 122, 82], [238, 123, 81], [239, 124, 81], [239, 126, 80], [240, 127, 79], [240, 128, 78], [241, 129, 77], [241, 131, 76], [242, 132, 75], [243, 133, 75], [243, 135, 74], [244, 136, 73], [244, 137, 72], [245, 139, 71], [245, 140, 70], [246, 141, 69], [246, 143, 68], [247, 144, 68], [247, 145, 67], [247, 147, 66], [248, 148, 65], [248, 149, 64], [249, 151, 63], [249, 152, 62], [249, 154, 62], [250, 155, 61], [250, 156, 60], [250, 158, 59], [251, 159, 58], [251, 161, 57], [251, 162, 56], [252, 163, 56], [252, 165, 55], [252, 166, 54], [252, 168, 53], [252, 169, 52], [253, 171, 51], [253, 172, 51], [253, 174, 50], [253, 175, 49], [253, 177, 48], [253, 178, 47], [253, 180, 47], [253, 181, 46], [254, 183, 45], [254, 184, 44], [254, 186, 44], [254, 187, 43], [254, 189, 42], [254, 190, 42], [254, 192, 41], [253, 194, 41], [253, 195, 40], [253, 197, 39], [253, 198, 39], [253, 200, 39], [253, 202, 38], [253, 203, 38], [252, 205, 37], [252, 206, 37], [252, 208, 37], [252, 210, 37], [251, 211, 36], [251, 213, 36], [251, 215, 36], [250, 216, 36], [250, 218, 36], [249, 220, 36], [249, 221, 37], [248, 223, 37], [248, 225, 37], [247, 226, 37], [247, 228, 37], [246, 230, 38], [246, 232, 38], [245, 233, 38], [245, 235, 39], [244, 237, 39], [243, 238, 39], [243, 240, 39], [242, 242, 39], [241, 244, 38], [241, 245, 37], [240, 247, 36], [240, 249, 33]];
16283
- function rgbSpline(spline) {
16284
- return (colors) => {
16285
- const n = colors.length;
16286
- const r = new Array(n);
16287
- const g = new Array(n);
16288
- const b = new Array(n);
16289
- let i;
16290
- let color;
16291
- for (i = 0; i < n; ++i) {
16292
- color = [colors[i][0], colors[i][1], colors[i][2]];
16293
- r[i] = color[0] || 0;
16294
- g[i] = color[1] || 0;
16295
- b[i] = color[2] || 0;
16296
- }
16297
- const rFunc = spline(r);
16298
- const gFunc = spline(g);
16299
- const bFunc = spline(b);
16300
- return (t2) => [rFunc(t2), gFunc(t2), bFunc(t2)];
16301
- };
16302
- }
16303
- function basis(values) {
16304
- function innerBasis(t1, v0, v1, v2, v3) {
16305
- const t2 = t1 * t1;
16306
- const t3 = t2 * t1;
16307
- return ((1 - 3 * t1 + 3 * t2 - t3) * v0 + (4 - 6 * t2 + 3 * t3) * v1 + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2 + t3 * v3) / 6;
16308
- }
16309
- const n = values.length - 1;
16310
- return (t2) => {
16311
- const i = t2 <= 0 ? t2 = 0 : t2 >= 1 ? (t2 = 1, n - 1) : Math.floor(t2 * n);
16312
- const v1 = values[i];
16313
- const v2 = values[i + 1];
16314
- const v0 = i > 0 ? values[i - 1] : 2 * v1 - v2;
16315
- const v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
16316
- return innerBasis((t2 - i / n) * n, v0, v1, v2, v3);
16317
- };
16318
- }
16319
- const interpolateRgbBasis = rgbSpline(basis);
16320
- function interpolateSequentialMulti(range2) {
16321
- const n = range2.length;
16322
- return (t2) => range2[Math.max(0, Math.min(n - 1, Math.floor(t2 * n)))];
16323
- }
16324
- interpolateRgbBasis(schemeRdBu);
16325
- interpolateSequentialMulti(schemePlasma);
16326
- const FILE_EXTENSION_JSON = "json";
16327
- const MIME_TYPE_JSON = "application/json";
16328
- const FILE_EXTENSION_TABULAR = "csv";
16329
- const MIME_TYPE_TABULAR = "text/csv";
16330
- const SEPARATOR_TABULAR = ",";
16331
- const NA_VALUE_TABULAR = "NA";
16332
- const SETS_DATATYPE_OBS = "obs";
16333
- const HIERARCHICAL_SCHEMAS = {
16334
- latestVersion: "0.1.3",
16335
- schema: obsSetsSchema
16336
- };
16337
- const TABULAR_SCHEMAS = {
16338
- schema: obsSetsTabularSchema
16339
- };
16340
- function callbackOnKeyPress(event, key, callback) {
16341
- if (event.key === key) {
16342
- event.preventDefault();
16343
- callback();
16344
- }
16345
- }
16346
- function colorArrayToString(rgbArray2) {
16347
- return tinycolor({ r: rgbArray2[0], g: rgbArray2[1], b: rgbArray2[2] }).toHexString();
16348
- }
16349
- function colorStringToArray(colorString) {
16350
- const colorObj = tinycolor(colorString).toRgb();
16351
- return [colorObj.r, colorObj.g, colorObj.b];
16352
- }
16353
- function getLevelTooltipText(i) {
16354
- if (i === 0)
16355
- return "Color by hierarchy";
16356
- if (i <= 2) {
16357
- const subs = (j) => "sub".repeat(j);
16358
- return `Color by ${subs(i - 1)}cluster`;
16359
- }
16360
- return `Color by cluster level ${i}`;
16361
- }
16362
- function isEqualOrPrefix(targetPath, testPath) {
16363
- if (targetPath.length <= testPath.length) {
16364
- return isEqual(targetPath, testPath.slice(0, targetPath.length));
16365
- }
16366
- return false;
16367
- }
16368
- function tryRenamePath(targetPath, testPath, nextTargetPath) {
16369
- if (isEqualOrPrefix(targetPath, testPath)) {
16370
- return [...nextTargetPath, ...testPath.slice(nextTargetPath.length)];
16371
- }
16372
- return testPath;
16373
- }
16374
- const PATH_SEP = "___";
16375
- function pathToKey(path) {
16376
- return path.join(PATH_SEP);
16377
- }
16378
- function getNextNumberedNodeName(nodes, prefix, suffix) {
16379
- let i = 1;
16380
- if (nodes) {
16381
- while (nodes.find((n) => n.name.includes(`${prefix}${i}`))) {
16382
- i++;
16383
- }
16384
- }
16385
- return `${prefix}${i}${suffix}`;
16386
- }
16387
- function setObsSelection(cellSelection, additionalCellSets, cellSetColor, setCellSetSelection, setAdditionalCellSets, setCellSetColor, setCellColorEncoding, prefix = "Selection ", suffix = "") {
16388
- const CELL_SELECTIONS_LEVEL_ZERO_NAME = "My Selections";
16389
- const selectionsLevelZeroNode = additionalCellSets == null ? void 0 : additionalCellSets.tree.find(
16390
- (n) => n.name === CELL_SELECTIONS_LEVEL_ZERO_NAME
16391
- );
16392
- const nextAdditionalCellSets = {
16393
- version: HIERARCHICAL_SCHEMAS.latestVersion,
16394
- datatype: SETS_DATATYPE_OBS,
16395
- tree: [...additionalCellSets ? additionalCellSets.tree : []]
16396
- };
16397
- const nextName = getNextNumberedNodeName(selectionsLevelZeroNode == null ? void 0 : selectionsLevelZeroNode.children, prefix, suffix);
16398
- let colorIndex = 0;
16399
- if (selectionsLevelZeroNode) {
16400
- colorIndex = selectionsLevelZeroNode.children.length;
16401
- selectionsLevelZeroNode.children.push({
16402
- name: nextName,
16403
- set: cellSelection.map((d) => [d, null])
16404
- });
16405
- } else {
16406
- nextAdditionalCellSets.tree.push({
16407
- name: CELL_SELECTIONS_LEVEL_ZERO_NAME,
16408
- children: [
16409
- {
16410
- name: nextName,
16411
- set: cellSelection.map((d) => [d, null])
16412
- }
16413
- ]
16414
- });
16415
- }
16416
- setAdditionalCellSets(nextAdditionalCellSets);
16417
- const nextPath = ["My Selections", nextName];
16418
- setCellSetColor([
16419
- ...cellSetColor || [],
16420
- {
16421
- path: nextPath,
16422
- color: PALETTE[colorIndex % PALETTE.length]
16423
- }
16424
- ]);
16425
- setCellSetSelection([nextPath]);
16426
- setCellColorEncoding("cellSetSelection");
16427
- }
16428
- function mergeObsSets(cellSets, additionalCellSets) {
16429
- return {
16430
- version: HIERARCHICAL_SCHEMAS.latestVersion,
16431
- datatype: SETS_DATATYPE_OBS,
16432
- tree: [
16433
- ...cellSets ? cellSets.tree : [],
16434
- ...additionalCellSets ? additionalCellSets.tree : []
16435
- ]
16436
- };
16437
- }
16438
- function getObsInfoFromDataWithinRange(range2, data) {
16439
- const [lowerBound, upperBound] = range2;
16440
- const cellIds = data.filter((item) => item.value >= lowerBound && item.value <= upperBound).map((item) => item.cellId);
16441
- return cellIds;
16442
- }
16443
- function generateKey() {
16444
- return v4();
16445
- }
16446
- function nodeToSet(currNode) {
16447
- if (!currNode) {
16448
- return [];
16449
- }
16450
- if (!currNode.children) {
16451
- return currNode.set || [];
16452
- }
16453
- return currNode.children.flatMap((c) => nodeToSet(c));
16454
- }
16455
- function nodeToHeight(currNode, level = 0) {
16456
- if (!currNode.children) {
16457
- return level;
16458
- }
16459
- const newLevel = level + 1;
16460
- const childrenHeights = currNode.children.map((c) => nodeToHeight(c, newLevel));
16461
- return Math.max(...childrenHeights, newLevel);
16462
- }
16463
- function getNodeLength(currNode) {
16464
- var _a;
16465
- if (!currNode) {
16466
- return 0;
16467
- }
16468
- if (!currNode.children) {
16469
- return ((_a = currNode.set) == null ? void 0 : _a.length) || 0;
16470
- }
16471
- return currNode.children.reduce((acc, curr) => acc + getNodeLength(curr), 0);
16472
- }
16473
- function nodeFindNodeByNamePath(node, path, currLevelIndex) {
16474
- const currNodeName = path[currLevelIndex];
16475
- if (node.name === currNodeName) {
16476
- if (currLevelIndex === path.length - 1) {
16477
- return node;
16478
- }
16479
- if (node.children) {
16480
- const foundNodes = node.children.map((child) => nodeFindNodeByNamePath(child, path, currLevelIndex + 1)).filter(Boolean);
16481
- if (foundNodes.length === 1) {
16482
- return foundNodes[0];
16483
- }
16484
- }
16485
- }
16486
- return null;
16487
- }
16488
- function treeFindNodeByNamePath(currTree, targetNamePath) {
16489
- const foundNodes = currTree.tree.map((levelZeroNode) => nodeFindNodeByNamePath(levelZeroNode, targetNamePath, 0)).filter(Boolean);
16490
- if (foundNodes.length === 1) {
16491
- return foundNodes[0];
16492
- }
16493
- return null;
16494
- }
16495
- function nodeTransform(node, predicate, transform, transformedPaths, currPath) {
16496
- let newPath;
16497
- if (!currPath) {
16498
- newPath = [node.name];
16499
- } else {
16500
- newPath = [...currPath];
16501
- }
16502
- if (predicate(node, newPath)) {
16503
- transformedPaths.push(newPath);
16504
- return transform(node, newPath);
16505
- }
16506
- if (node.children) {
16507
- return {
16508
- ...node,
16509
- children: node.children.map(
16510
- (child) => nodeTransform(
16511
- child,
16512
- predicate,
16513
- transform,
16514
- transformedPaths,
16515
- newPath.concat([child.name])
16516
- )
16517
- )
16518
- };
16519
- }
16520
- return node;
16521
- }
16522
- function nodeTransformAll(node, predicate, transform, transformedPaths, currPath) {
16523
- let newPath;
16524
- if (!currPath) {
16525
- newPath = [node.name];
16526
- } else {
16527
- newPath = [...currPath];
16528
- }
16529
- let newNode = node;
16530
- if (predicate(node, newPath)) {
16531
- transformedPaths.push(newPath);
16532
- newNode = transform(node, newPath);
16533
- }
16534
- if (node.children) {
16535
- return {
16536
- ...newNode,
16537
- children: newNode.children.map(
16538
- (child) => nodeTransformAll(
16539
- child,
16540
- predicate,
16541
- transform,
16542
- transformedPaths,
16543
- newPath.concat([child.name])
16544
- )
16545
- )
16546
- };
16547
- }
16548
- return newNode;
16549
- }
16550
- function nodeAppendChild(currNode, newChild) {
16551
- return {
16552
- ...currNode,
16553
- children: [...currNode.children, newChild]
16554
- };
16555
- }
16556
- function nodePrependChild(currNode, newChild) {
16557
- return {
16558
- ...currNode,
16559
- children: [newChild, ...currNode.children]
16560
- };
16561
- }
16562
- function nodeInsertChild(currNode, newChild, insertIndex) {
16563
- const newChildren = Array.from(currNode.children);
16564
- newChildren.splice(insertIndex, 0, newChild);
16565
- return {
16566
- ...currNode,
16567
- children: newChildren
16568
- };
16569
- }
16570
- function treeToUnion(currTree, checkedPaths) {
16571
- const nodes = checkedPaths.map((path) => treeFindNodeByNamePath(currTree, path));
16572
- const nodeSets = nodes.map((node) => nodeToSet(node).map(([cellId]) => cellId));
16573
- return nodeSets.reduce((a, h) => a.concat(h.filter((hEl) => !a.includes(hEl))), nodeSets[0] || []);
16574
- }
16575
- function treeToIntersection(currTree, checkedPaths) {
16576
- const nodes = checkedPaths.map((path) => treeFindNodeByNamePath(currTree, path));
16577
- const nodeSets = nodes.map((node) => nodeToSet(node).map(([cellId]) => cellId));
16578
- return nodeSets.reduce((a, h) => h.filter((hEl) => a.includes(hEl)), nodeSets[0] || []);
16579
- }
16580
- function treeToComplement(currTree, checkedPaths, items) {
16581
- const primaryUnion = treeToUnion(currTree, checkedPaths);
16582
- return items.filter((el) => !primaryUnion.includes(el));
16583
- }
16584
- function nodeToLevelDescendantNamePaths(node, level, prevPath, stopEarly = false) {
16585
- if (!node.children) {
16586
- if (!stopEarly) {
16587
- return null;
16588
- }
16589
- return [[...prevPath, node.name]];
16590
- }
16591
- if (level === 0) {
16592
- return [[...prevPath, node.name]];
16593
- }
16594
- return node.children.flatMap((c) => nodeToLevelDescendantNamePaths(c, level - 1, [...prevPath, node.name], stopEarly)).filter(Boolean);
16595
- }
16596
- function treeExport(currTree, datatype) {
16597
- return {
16598
- version: HIERARCHICAL_SCHEMAS.latestVersion,
16599
- datatype,
16600
- tree: currTree.tree
16601
- };
16602
- }
16603
- function treeExportLevelZeroNode(currTree, nodePath, datatype, cellSetColors, theme) {
16604
- const node = treeFindNodeByNamePath(currTree, nodePath);
16605
- const nodeWithColors = nodeTransformAll(node, () => true, (n, nPath) => {
16606
- var _a;
16607
- const nodeColor = ((_a = cellSetColors == null ? void 0 : cellSetColors.find((c) => isEqual(c.path, nPath))) == null ? void 0 : _a.color) ?? getDefaultColor(theme);
16608
- return {
16609
- ...n,
16610
- color: nodeColor.slice(0, 3)
16611
- };
16612
- }, []);
16613
- const treeWithOneLevelZeroNode = {
16614
- ...currTree,
16615
- tree: [nodeWithColors]
16616
- };
16617
- return {
16618
- treeToExport: treeExport(treeWithOneLevelZeroNode, datatype),
16619
- nodeName: node.name
16620
- };
16621
- }
16622
- function treeExportSet(currTree, nodePath) {
16623
- const node = treeFindNodeByNamePath(currTree, nodePath);
16624
- return { setToExport: nodeToSet(node), nodeName: node.name };
16625
- }
16626
- function treeInitialize(datatype) {
16627
- return {
16628
- version: HIERARCHICAL_SCHEMAS.latestVersion,
16629
- datatype,
16630
- tree: []
16631
- };
16632
- }
16633
- function nodeToRenderProps(node, path, cellSetColor) {
16634
- var _a;
16635
- const level = path.length - 1;
16636
- return {
16637
- title: node.name,
16638
- nodeKey: pathToKey(path),
16639
- path,
16640
- size: getNodeLength(node),
16641
- color: (_a = cellSetColor == null ? void 0 : cellSetColor.find((d) => isEqual(d.path, path))) == null ? void 0 : _a.color,
16642
- level,
16643
- isLeaf: (!node.children || node.children.length === 0) && Boolean(node.set),
16644
- height: nodeToHeight(node)
16645
- };
16646
- }
16647
- function colorMixWithUncertainty(originalColor, p, mixingColor = [128, 128, 128]) {
16648
- return [
16649
- (originalColor[0] - mixingColor[0]) * p + mixingColor[0],
16650
- (originalColor[1] - mixingColor[1]) * p + mixingColor[1],
16651
- (originalColor[2] - mixingColor[2]) * p + mixingColor[2]
16652
- ];
16653
- }
16654
- function treeToCellColorsBySetNames(currTree, selectedNamePaths, cellSetColor, theme) {
16655
- let cellColorsArray = [];
16656
- selectedNamePaths.forEach((setNamePath) => {
16657
- var _a;
16658
- const node = treeFindNodeByNamePath(currTree, setNamePath);
16659
- if (node) {
16660
- const nodeSet = nodeToSet(node);
16661
- const nodeColor = ((_a = cellSetColor == null ? void 0 : cellSetColor.find((d) => isEqual(d.path, setNamePath))) == null ? void 0 : _a.color) || getDefaultColor(theme);
16662
- cellColorsArray = [
16663
- ...cellColorsArray,
16664
- ...nodeSet.map(([cellId, prob]) => [
16665
- cellId,
16666
- isNil(prob) ? nodeColor : colorMixWithUncertainty(nodeColor, prob)
16667
- ])
16668
- ];
16669
- }
16670
- });
16671
- return new Map(cellColorsArray);
16672
- }
16673
- function treeToCellSetColorIndicesBySetNames(currTree, selectedNamePaths, cellSetColor) {
16674
- let cellColorsArray = [];
16675
- selectedNamePaths == null ? void 0 : selectedNamePaths.forEach((setNamePath) => {
16676
- const node = treeFindNodeByNamePath(currTree, setNamePath);
16677
- if (node) {
16678
- const nodeSet = nodeToSet(node);
16679
- const nodeColorIndex = cellSetColor == null ? void 0 : cellSetColor.findIndex((d) => isEqual(d.path, setNamePath));
16680
- cellColorsArray = [
16681
- ...cellColorsArray,
16682
- ...nodeSet.map(([cellId]) => [
16683
- cellId,
16684
- nodeColorIndex
16685
- ])
16686
- ];
16687
- }
16688
- });
16689
- return new Map(cellColorsArray);
16690
- }
16691
- function treeToObjectsBySetNames(currTree, selectedNamePaths, setColor, theme) {
16692
- var _a;
16693
- let cellsArray = [];
16694
- for (let i = 0; i < selectedNamePaths.length; i += 1) {
16695
- const setNamePath = selectedNamePaths[i];
16696
- const node = treeFindNodeByNamePath(currTree, setNamePath);
16697
- if (node) {
16698
- const nodeSet = nodeToSet(node);
16699
- const nodeColor = ((_a = setColor == null ? void 0 : setColor.find((d) => isEqual(d.path, setNamePath))) == null ? void 0 : _a.color) || getDefaultColor(theme);
16700
- cellsArray = cellsArray.concat(nodeSet.map(([cellId]) => ({
16701
- obsId: cellId,
16702
- name: node.name,
16703
- color: nodeColor
16704
- })));
16705
- }
16706
- }
16707
- return cellsArray;
16708
- }
16709
- function treeToCellPolygonsBySetNames(currTree, obsIndex, obsEmbedding, selectedNamePaths, cellSetColor, theme) {
16710
- const obsIndexMap = new Map(obsIndex.map((key, i) => [key, i]));
16711
- const cellSetPolygons = [];
16712
- selectedNamePaths.forEach((setNamePath) => {
16713
- var _a;
16714
- const node = treeFindNodeByNamePath(currTree, setNamePath);
16715
- if (node) {
16716
- const nodeSet = nodeToSet(node);
16717
- const nodeColor = ((_a = cellSetColor == null ? void 0 : cellSetColor.find((d) => isEqual(d.path, setNamePath))) == null ? void 0 : _a.color) || getDefaultColor(theme);
16718
- const cellPositions = nodeSet.map(([cellId]) => {
16719
- const cellIdx = obsIndexMap.get(cellId);
16720
- return [
16721
- obsEmbedding.data[0][cellIdx],
16722
- -obsEmbedding.data[1][cellIdx]
16723
- ];
16724
- }).filter((cell) => cell.every((i) => typeof i === "number"));
16725
- if (cellPositions.length > 2) {
16726
- const points = featureCollection(
16727
- cellPositions.map(point)
16728
- );
16729
- const concavity = Infinity;
16730
- const hullCoords = concaveman$1(cellPositions, concavity);
16731
- if (hullCoords) {
16732
- const centroidCoords = centroid(points).geometry.coordinates;
16733
- cellSetPolygons.push({
16734
- path: setNamePath,
16735
- name: setNamePath[setNamePath.length - 1],
16736
- hull: hullCoords,
16737
- color: nodeColor,
16738
- centroid: centroidCoords
16693
+ return;
16694
+ _this2.emit("line", line);
16695
+ _this2.push(_this2._hasWritten ? _this2.opts.eol + line : line);
16696
+ _this2._hasWritten = true;
16739
16697
  });
16740
16698
  }
16699
+ }]);
16700
+ return JSON2CSVTransform2;
16701
+ }(Transform$1);
16702
+ var JSON2CSVTransform_1 = JSON2CSVTransform;
16703
+ var Transform$2 = Stream.Transform;
16704
+ var fastJoin$3 = utils.fastJoin;
16705
+ var JSON2CSVAsyncParser = /* @__PURE__ */ function() {
16706
+ function JSON2CSVAsyncParser2(opts2, transformOpts) {
16707
+ _classCallCheck(this, JSON2CSVAsyncParser2);
16708
+ this.input = new Transform$2(transformOpts);
16709
+ this.input._read = function() {
16710
+ };
16711
+ this.transform = new JSON2CSVTransform_1(opts2, transformOpts);
16712
+ this.processor = this.input.pipe(this.transform);
16741
16713
  }
16742
- }
16743
- });
16744
- return cellSetPolygons;
16745
- }
16746
- function treeToSetSizesBySetNames(currTree, allNamePaths, selectedNamePaths, setColor, theme) {
16747
- const sizes = [];
16748
- const contains = (path, paths) => paths.some((p) => isEqual(p, path));
16749
- allNamePaths.forEach((clusterPath) => {
16750
- var _a;
16751
- const node = treeFindNodeByNamePath(currTree, clusterPath);
16752
- if (node) {
16753
- const nodeSet = nodeToSet(node);
16754
- const nodeColor = ((_a = setColor == null ? void 0 : setColor.find((d) => isEqual(d.path, clusterPath))) == null ? void 0 : _a.color) || getDefaultColor(theme);
16755
- const nodeProps = {
16756
- key: generateKey(),
16757
- name: node.name,
16758
- size: nodeSet.length,
16759
- color: nodeColor,
16760
- setNamePath: clusterPath,
16761
- // used by the CellSetSizesPlot to determine if the bar should be grayed out
16762
- isGrayedOut: true
16763
- };
16764
- if (contains(clusterPath, selectedNamePaths)) {
16765
- nodeProps.isGrayedOut = false;
16766
- }
16767
- sizes.push(nodeProps);
16768
- }
16769
- });
16770
- return sizes;
16771
- }
16772
- function filterNode(node, prevPath, filterPath) {
16773
- if (isEqual([...prevPath, node.name], filterPath)) {
16774
- return null;
16775
- }
16776
- if (!node.children) {
16777
- return node;
16778
- }
16779
- return {
16780
- ...node,
16781
- children: node.children.map(
16782
- (c) => filterNode(c, [...prevPath, node.name], filterPath)
16783
- ).filter(Boolean)
16784
- };
16785
- }
16786
- function treeToExpectedCheckedLevel(currTree, checkedPaths) {
16787
- let result = null;
16788
- if (currTree) {
16789
- currTree.tree.forEach((lzn) => {
16790
- const levelZeroPath = [lzn.name];
16791
- const height = nodeToHeight(lzn);
16792
- range$2(height).forEach((i) => {
16793
- const levelIndex = i + 1;
16794
- const levelNodePaths = nodeToLevelDescendantNamePaths(lzn, levelIndex, [], true);
16795
- if (isEqual(levelNodePaths, checkedPaths)) {
16796
- result = { levelZeroPath, levelIndex };
16714
+ _createClass(JSON2CSVAsyncParser2, [{
16715
+ key: "fromInput",
16716
+ value: function fromInput(input) {
16717
+ if (this._input) {
16718
+ throw new Error("Async parser already has an input.");
16719
+ }
16720
+ this._input = input;
16721
+ this.input = this._input.pipe(this.processor);
16722
+ return this;
16797
16723
  }
16798
- });
16799
- });
16800
- }
16801
- return result;
16802
- }
16803
- function treesConflict(cellSets, testCellSets) {
16804
- const paths = [];
16805
- const testPaths = [];
16806
- let hasConflict = false;
16807
- function getPaths2(node, prevPath) {
16808
- paths.push([...prevPath, node.name]);
16809
- if (node.children) {
16810
- node.children.forEach((c) => getPaths2(c, [...prevPath, node.name]));
16811
- }
16812
- }
16813
- cellSets.tree.forEach((lzn) => getPaths2(lzn, []));
16814
- function getTestPaths(node, prevPath) {
16815
- testPaths.push([...prevPath, node.name]);
16816
- if (node.children) {
16817
- node.children.forEach((c) => getPaths2(c, [...prevPath, node.name]));
16818
- }
16819
- }
16820
- testCellSets.tree.forEach((lzn) => getTestPaths(lzn, []));
16821
- testPaths.forEach((testPath) => {
16822
- if (paths.find((p) => isEqual(p, testPath))) {
16823
- hasConflict = true;
16824
- }
16825
- });
16826
- return hasConflict;
16827
- }
16828
- function initializeCellSetColor(cellSets, cellSetColor) {
16829
- const nextCellSetColor = [...cellSetColor || []];
16830
- const nodeCountPerTreePerLevel = cellSets.tree.map((tree) => Array.from({
16831
- length: nodeToHeight(tree) + 1
16832
- // Need to add one because its an array.
16833
- }).fill(0));
16834
- function processNode(node, prevPath, hierarchyLevel, treeIndex) {
16835
- const index = nodeCountPerTreePerLevel[treeIndex][hierarchyLevel];
16836
- const nodePath = [...prevPath, node.name];
16837
- const nodeColor = nextCellSetColor.find((d) => isEqual(d.path, nodePath));
16838
- if (!nodeColor) {
16839
- const nodeColorArray = node.color ? node.color : PALETTE[index % PALETTE.length];
16840
- nextCellSetColor.push({
16841
- path: nodePath,
16842
- color: nodeColorArray
16843
- });
16844
- }
16845
- nodeCountPerTreePerLevel[treeIndex][hierarchyLevel] += 1;
16846
- if (node.children) {
16847
- node.children.forEach((c) => processNode(c, nodePath, hierarchyLevel + 1, treeIndex));
16848
- }
16849
- }
16850
- cellSets.tree.forEach((lzn, treeIndex) => processNode(lzn, [], 0, treeIndex));
16851
- return nextCellSetColor;
16852
- }
16853
- function getCellSetPolygons(params) {
16854
- const {
16855
- obsIndex,
16856
- obsEmbedding,
16857
- cellSets,
16858
- cellSetSelection,
16859
- cellSetColor,
16860
- theme
16861
- } = params;
16862
- if (cellSetSelection && cellSetSelection.length > 0 && cellSets && obsIndex && obsEmbedding) {
16863
- return treeToCellPolygonsBySetNames(
16864
- cellSets,
16865
- obsIndex,
16866
- obsEmbedding,
16867
- cellSetSelection,
16868
- cellSetColor,
16869
- theme
16870
- );
16871
- }
16872
- return [];
16873
- }
16874
- function treeToMembershipMap(currTree) {
16875
- const result = /* @__PURE__ */ new Map();
16876
- if (currTree) {
16877
- currTree.tree.forEach((lzn) => {
16878
- const height = nodeToHeight(lzn);
16879
- range$2(height).forEach((i) => {
16880
- const levelIndex = i + 1;
16881
- const levelNodePaths = nodeToLevelDescendantNamePaths(lzn, levelIndex, [], true);
16882
- levelNodePaths.forEach((setNamePath) => {
16883
- const node = treeFindNodeByNamePath(currTree, setNamePath);
16884
- if (node && !node.children) {
16885
- const nodeSet = nodeToSet(node);
16886
- nodeSet.forEach(([obsId]) => {
16887
- if (result.has(obsId)) {
16888
- result.get(obsId).push(setNamePath);
16889
- } else {
16890
- result.set(obsId, [setNamePath]);
16891
- }
16724
+ }, {
16725
+ key: "throughTransform",
16726
+ value: function throughTransform(transform) {
16727
+ if (this._output) {
16728
+ throw new Error("Can't add transforms once an output has been added.");
16729
+ }
16730
+ this.processor = this.processor.pipe(transform);
16731
+ return this;
16732
+ }
16733
+ }, {
16734
+ key: "toOutput",
16735
+ value: function toOutput(output) {
16736
+ if (this._output) {
16737
+ throw new Error("Async parser already has an output.");
16738
+ }
16739
+ this._output = output;
16740
+ this.processor = this.processor.pipe(output);
16741
+ return this;
16742
+ }
16743
+ }, {
16744
+ key: "promise",
16745
+ value: function promise() {
16746
+ var _this = this;
16747
+ var returnCSV = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
16748
+ return new Promise(function(resolve, reject) {
16749
+ if (!returnCSV) {
16750
+ _this.processor.on("finish", function() {
16751
+ return resolve();
16752
+ }).on("error", function(err) {
16753
+ return reject(err);
16754
+ });
16755
+ return;
16756
+ }
16757
+ var csvBuffer = [];
16758
+ _this.processor.on("data", function(chunk) {
16759
+ return csvBuffer.push(chunk.toString());
16760
+ }).on("finish", function() {
16761
+ return resolve(fastJoin$3(csvBuffer, ""));
16762
+ }).on("error", function(err) {
16763
+ return reject(err);
16892
16764
  });
16765
+ });
16766
+ }
16767
+ }]);
16768
+ return JSON2CSVAsyncParser2;
16769
+ }();
16770
+ var JSON2CSVAsyncParser_1 = JSON2CSVAsyncParser;
16771
+ function flatten() {
16772
+ var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref$objects = _ref.objects, objects = _ref$objects === void 0 ? true : _ref$objects, _ref$arrays = _ref.arrays, arrays = _ref$arrays === void 0 ? false : _ref$arrays, _ref$separator = _ref.separator, separator = _ref$separator === void 0 ? "." : _ref$separator;
16773
+ function step(obj, flatDataRow, currentPath) {
16774
+ Object.keys(obj).forEach(function(key) {
16775
+ var newPath = currentPath ? "".concat(currentPath).concat(separator).concat(key) : key;
16776
+ var value = obj[key];
16777
+ if (objects && _typeof(value) === "object" && value !== null && !Array.isArray(value) && Object.prototype.toString.call(value.toJSON) !== "[object Function]" && Object.keys(value).length) {
16778
+ step(value, flatDataRow, newPath);
16779
+ return;
16893
16780
  }
16894
- });
16895
- });
16896
- });
16897
- }
16898
- return result;
16899
- }
16900
- function getPaths(node, currentPath = [], paths = []) {
16901
- if (node.children) {
16902
- node.children.forEach((child) => {
16903
- const newPath = [...currentPath, child.name];
16904
- paths.push(newPath);
16905
- getPaths(child, newPath, paths);
16906
- });
16907
- }
16908
- return paths;
16909
- }
16910
- function findLongestPath(arrOfPaths, path, isSubset) {
16911
- if (Array.isArray(arrOfPaths)) {
16912
- let longest = null;
16913
- let longestLength = 0;
16914
- arrOfPaths.forEach((subArray) => {
16915
- const matchCount = subArray.filter((v, i) => v === path[i]).length;
16916
- if (matchCount === (isSubset ? subArray.length : path.length) && subArray.length > longestLength) {
16917
- longest = subArray;
16918
- longestLength = subArray.length;
16781
+ if (arrays && Array.isArray(value)) {
16782
+ step(value, flatDataRow, newPath);
16783
+ return;
16784
+ }
16785
+ flatDataRow[newPath] = value;
16786
+ });
16787
+ return flatDataRow;
16919
16788
  }
16920
- });
16921
- if (longestLength > 0) {
16922
- return longest;
16923
- }
16924
- if (isSubset) {
16925
- return [];
16789
+ return function(dataRow) {
16790
+ return step(dataRow, {});
16791
+ };
16926
16792
  }
16927
- }
16928
- return [];
16929
- }
16930
- function findLongestCommonPath(arrOfPaths, cellSetSelection) {
16931
- let maxCount = 0;
16932
- let commonPath = [];
16933
- cellSetSelection.forEach((currentCellSet) => {
16934
- const longestPath = findLongestPath(arrOfPaths, currentCellSet, false);
16935
- if (longestPath.length > maxCount) {
16936
- maxCount = longestPath.length;
16937
- commonPath = currentCellSet;
16793
+ var flatten_1 = flatten;
16794
+ var setProp$1 = utils.setProp, unsetProp$1 = utils.unsetProp, flattenReducer$3 = utils.flattenReducer;
16795
+ function getUnwindablePaths(obj, currentPath) {
16796
+ return Object.keys(obj).reduce(function(unwindablePaths, key) {
16797
+ var newPath = currentPath ? "".concat(currentPath, ".").concat(key) : key;
16798
+ var value = obj[key];
16799
+ if (_typeof(value) === "object" && value !== null && !Array.isArray(value) && Object.prototype.toString.call(value.toJSON) !== "[object Function]" && Object.keys(value).length) {
16800
+ unwindablePaths = unwindablePaths.concat(getUnwindablePaths(value, newPath));
16801
+ } else if (Array.isArray(value)) {
16802
+ unwindablePaths.push(newPath);
16803
+ unwindablePaths = unwindablePaths.concat(value.map(function(arrObj) {
16804
+ return getUnwindablePaths(arrObj, newPath);
16805
+ }).reduce(flattenReducer$3, []).filter(function(item, index, arr) {
16806
+ return arr.indexOf(item) !== index;
16807
+ }));
16808
+ }
16809
+ return unwindablePaths;
16810
+ }, []);
16938
16811
  }
16939
- });
16940
- return commonPath;
16941
- }
16942
- function filterPathsByExpansionAndSelection(mergedCellSets, hierarchy, cellSetExpansion, cellSetSelection) {
16943
- const paths = getPaths({ children: mergedCellSets.tree });
16944
- const contains = (allPaths, path) => allPaths == null ? void 0 : allPaths.some((p) => isEqual(p, path));
16945
- return paths.filter((clusterPath) => {
16946
- if (contains(cellSetExpansion, clusterPath))
16947
- return false;
16948
- if (!contains(cellSetSelection, clusterPath)) {
16949
- if (findLongestPath(cellSetSelection, clusterPath, false).length > clusterPath.length) {
16950
- return false;
16812
+ function unwind() {
16813
+ var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref$paths = _ref.paths, paths = _ref$paths === void 0 ? void 0 : _ref$paths, _ref$blankOut = _ref.blankOut, blankOut = _ref$blankOut === void 0 ? false : _ref$blankOut;
16814
+ function unwindReducer(rows, unwindPath) {
16815
+ return rows.map(function(row) {
16816
+ var unwindArray = lodash_get(row, unwindPath);
16817
+ if (!Array.isArray(unwindArray)) {
16818
+ return row;
16819
+ }
16820
+ if (!unwindArray.length) {
16821
+ return unsetProp$1(row, unwindPath);
16822
+ }
16823
+ return unwindArray.map(function(unwindRow, index) {
16824
+ var clonedRow = blankOut && index > 0 ? {} : row;
16825
+ return setProp$1(clonedRow, unwindPath, unwindRow);
16826
+ });
16827
+ }).reduce(flattenReducer$3, []);
16951
16828
  }
16952
- if (cellSetExpansion) {
16953
- if (cellSetExpansion.length === 0 && clusterPath.length > 2)
16954
- return false;
16955
- const longestSubset = findLongestPath(cellSetExpansion, clusterPath, true);
16956
- if (cellSetExpansion.length > 0 && longestSubset.length + 1 < clusterPath.length) {
16957
- return false;
16829
+ paths = Array.isArray(paths) ? paths : paths ? [paths] : void 0;
16830
+ return function(dataRow) {
16831
+ return (paths || getUnwindablePaths(dataRow)).reduce(unwindReducer, [dataRow]);
16832
+ };
16833
+ }
16834
+ var unwind_1 = unwind;
16835
+ var Readable$1 = Stream.Readable;
16836
+ var Parser$1 = JSON2CSVParser_1;
16837
+ var AsyncParser = JSON2CSVAsyncParser_1;
16838
+ var Transform$3 = JSON2CSVTransform_1;
16839
+ var parse2 = function parse3(data, opts2) {
16840
+ return new JSON2CSVParser_1(opts2).parse(data);
16841
+ };
16842
+ var parseAsync = function parseAsync2(data, opts2, transformOpts) {
16843
+ try {
16844
+ if (!(data instanceof Readable$1)) {
16845
+ transformOpts = Object.assign({}, transformOpts, {
16846
+ objectMode: true
16847
+ });
16848
+ }
16849
+ var asyncParser = new JSON2CSVAsyncParser_1(opts2, transformOpts);
16850
+ var promise = asyncParser.promise();
16851
+ if (Array.isArray(data)) {
16852
+ data.forEach(function(item) {
16853
+ return asyncParser.input.push(item);
16854
+ });
16855
+ asyncParser.input.push(null);
16856
+ } else if (data instanceof Readable$1) {
16857
+ asyncParser.fromInput(data);
16858
+ } else {
16859
+ asyncParser.input.push(data);
16860
+ asyncParser.input.push(null);
16958
16861
  }
16862
+ return promise;
16863
+ } catch (err) {
16864
+ return Promise.reject(err);
16959
16865
  }
16960
- }
16961
- return clusterPath[0] === hierarchy[0];
16866
+ };
16867
+ var transforms = {
16868
+ flatten: flatten_1,
16869
+ unwind: unwind_1
16870
+ };
16871
+ var json2csv = {
16872
+ Parser: Parser$1,
16873
+ AsyncParser,
16874
+ Transform: Transform$3,
16875
+ parse: parse2,
16876
+ parseAsync,
16877
+ transforms
16878
+ };
16879
+ exports3.AsyncParser = AsyncParser;
16880
+ exports3.Parser = Parser$1;
16881
+ exports3.Transform = Transform$3;
16882
+ exports3.default = json2csv;
16883
+ exports3.parse = parse2;
16884
+ exports3.parseAsync = parseAsync;
16885
+ exports3.transforms = transforms;
16886
+ Object.defineProperty(exports3, "__esModule", { value: true });
16962
16887
  });
16963
- }
16964
- function findChangedHierarchy(prevSelectedPaths, currSelectedPaths) {
16965
- const unselectedPaths = prevSelectedPaths.filter(
16966
- (prevPath) => !currSelectedPaths.find((currPath) => isEqual(currPath, prevPath))
16967
- );
16968
- const newlySelectedPaths = currSelectedPaths.filter(
16969
- (currPath) => !prevSelectedPaths.find((prevPath) => isEqual(currPath, prevPath))
16970
- );
16971
- if (unselectedPaths.length === 0 && newlySelectedPaths.length === 0) {
16972
- return null;
16973
- }
16974
- const changedPath = newlySelectedPaths.length > 0 ? newlySelectedPaths[0] : unselectedPaths[0];
16975
- return changedPath.slice(0, -1);
16976
- }
16888
+ })(json2csv_umd, json2csv_umd.exports);
16889
+ var json2csv_umdExports = json2csv_umd.exports;
16977
16890
  function tryUpgradeTreeToLatestSchema(currTree, datatype) {
16978
16891
  const zodSchema = HIERARCHICAL_SCHEMAS.schema;
16979
16892
  const latestSchemaVersion = HIERARCHICAL_SCHEMAS.latestVersion;
@@ -17073,6 +16986,49 @@ function downloadForUser(dataString, fileName) {
17073
16986
  downloadAnchorNode.click();
17074
16987
  downloadAnchorNode.remove();
17075
16988
  }
16989
+ class InternMap extends Map {
16990
+ constructor(entries, key = keyof) {
16991
+ super();
16992
+ Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } });
16993
+ if (entries != null)
16994
+ for (const [key2, value] of entries)
16995
+ this.set(key2, value);
16996
+ }
16997
+ get(key) {
16998
+ return super.get(intern_get(this, key));
16999
+ }
17000
+ has(key) {
17001
+ return super.has(intern_get(this, key));
17002
+ }
17003
+ set(key, value) {
17004
+ return super.set(intern_set(this, key), value);
17005
+ }
17006
+ delete(key) {
17007
+ return super.delete(intern_delete(this, key));
17008
+ }
17009
+ }
17010
+ function intern_get({ _intern, _key }, value) {
17011
+ const key = _key(value);
17012
+ return _intern.has(key) ? _intern.get(key) : value;
17013
+ }
17014
+ function intern_set({ _intern, _key }, value) {
17015
+ const key = _key(value);
17016
+ if (_intern.has(key))
17017
+ return _intern.get(key);
17018
+ _intern.set(key, value);
17019
+ return value;
17020
+ }
17021
+ function intern_delete({ _intern, _key }, value) {
17022
+ const key = _key(value);
17023
+ if (_intern.has(key)) {
17024
+ value = _intern.get(key);
17025
+ _intern.delete(key);
17026
+ }
17027
+ return value;
17028
+ }
17029
+ function keyof(value) {
17030
+ return value !== null && typeof value === "object" ? value.valueOf() : value;
17031
+ }
17076
17032
  function dataToCellSetsTree(data, options) {
17077
17033
  const [cellNames, cellSets, cellSetScores] = data;
17078
17034
  const cellSetsTree = treeInitialize(SETS_DATATYPE_OBS);
@@ -17145,6 +17101,72 @@ function dataToCellSetsTree(data, options) {
17145
17101
  });
17146
17102
  return cellSetsTree;
17147
17103
  }
17104
+ const schemeRdBu = [[103, 0, 31], [178, 24, 43], [214, 96, 77], [244, 165, 130], [253, 219, 199], [247, 247, 247], [209, 229, 240], [146, 197, 222], [67, 147, 195], [33, 102, 172], [5, 48, 97]];
17105
+ const schemePlasma = [[13, 8, 135], [16, 7, 136], [19, 7, 137], [22, 7, 138], [25, 6, 140], [27, 6, 141], [29, 6, 142], [32, 6, 143], [34, 6, 144], [36, 6, 145], [38, 5, 145], [40, 5, 146], [42, 5, 147], [44, 5, 148], [46, 5, 149], [47, 5, 150], [49, 5, 151], [51, 5, 151], [53, 4, 152], [55, 4, 153], [56, 4, 154], [58, 4, 154], [60, 4, 155], [62, 4, 156], [63, 4, 156], [65, 4, 157], [67, 3, 158], [68, 3, 158], [70, 3, 159], [72, 3, 159], [73, 3, 160], [75, 3, 161], [76, 2, 161], [78, 2, 162], [80, 2, 162], [81, 2, 163], [83, 2, 163], [85, 2, 164], [86, 1, 164], [88, 1, 164], [89, 1, 165], [91, 1, 165], [92, 1, 166], [94, 1, 166], [96, 1, 166], [97, 0, 167], [99, 0, 167], [100, 0, 167], [102, 0, 167], [103, 0, 168], [105, 0, 168], [106, 0, 168], [108, 0, 168], [110, 0, 168], [111, 0, 168], [113, 0, 168], [114, 1, 168], [116, 1, 168], [117, 1, 168], [119, 1, 168], [120, 1, 168], [122, 2, 168], [123, 2, 168], [125, 3, 168], [126, 3, 168], [128, 4, 168], [129, 4, 167], [131, 5, 167], [132, 5, 167], [134, 6, 166], [135, 7, 166], [136, 8, 166], [138, 9, 165], [139, 10, 165], [141, 11, 165], [142, 12, 164], [143, 13, 164], [145, 14, 163], [146, 15, 163], [148, 16, 162], [149, 17, 161], [150, 19, 161], [152, 20, 160], [153, 21, 159], [154, 22, 159], [156, 23, 158], [157, 24, 157], [158, 25, 157], [160, 26, 156], [161, 27, 155], [162, 29, 154], [163, 30, 154], [165, 31, 153], [166, 32, 152], [167, 33, 151], [168, 34, 150], [170, 35, 149], [171, 36, 148], [172, 38, 148], [173, 39, 147], [174, 40, 146], [176, 41, 145], [177, 42, 144], [178, 43, 143], [179, 44, 142], [180, 46, 141], [181, 47, 140], [182, 48, 139], [183, 49, 138], [184, 50, 137], [186, 51, 136], [187, 52, 136], [188, 53, 135], [189, 55, 134], [190, 56, 133], [191, 57, 132], [192, 58, 131], [193, 59, 130], [194, 60, 129], [195, 61, 128], [196, 62, 127], [197, 64, 126], [198, 65, 125], [199, 66, 124], [200, 67, 123], [201, 68, 122], [202, 69, 122], [203, 70, 121], [204, 71, 120], [204, 73, 119], [205, 74, 118], [206, 75, 117], [207, 76, 116], [208, 77, 115], [209, 78, 114], [210, 79, 113], [211, 81, 113], [212, 82, 112], [213, 83, 111], [213, 84, 110], [214, 85, 109], [215, 86, 108], [216, 87, 107], [217, 88, 106], [218, 90, 106], [218, 91, 105], [219, 92, 104], [220, 93, 103], [221, 94, 102], [222, 95, 101], [222, 97, 100], [223, 98, 99], [224, 99, 99], [225, 100, 98], [226, 101, 97], [226, 102, 96], [227, 104, 95], [228, 105, 94], [229, 106, 93], [229, 107, 93], [230, 108, 92], [231, 110, 91], [231, 111, 90], [232, 112, 89], [233, 113, 88], [233, 114, 87], [234, 116, 87], [235, 117, 86], [235, 118, 85], [236, 119, 84], [237, 121, 83], [237, 122, 82], [238, 123, 81], [239, 124, 81], [239, 126, 80], [240, 127, 79], [240, 128, 78], [241, 129, 77], [241, 131, 76], [242, 132, 75], [243, 133, 75], [243, 135, 74], [244, 136, 73], [244, 137, 72], [245, 139, 71], [245, 140, 70], [246, 141, 69], [246, 143, 68], [247, 144, 68], [247, 145, 67], [247, 147, 66], [248, 148, 65], [248, 149, 64], [249, 151, 63], [249, 152, 62], [249, 154, 62], [250, 155, 61], [250, 156, 60], [250, 158, 59], [251, 159, 58], [251, 161, 57], [251, 162, 56], [252, 163, 56], [252, 165, 55], [252, 166, 54], [252, 168, 53], [252, 169, 52], [253, 171, 51], [253, 172, 51], [253, 174, 50], [253, 175, 49], [253, 177, 48], [253, 178, 47], [253, 180, 47], [253, 181, 46], [254, 183, 45], [254, 184, 44], [254, 186, 44], [254, 187, 43], [254, 189, 42], [254, 190, 42], [254, 192, 41], [253, 194, 41], [253, 195, 40], [253, 197, 39], [253, 198, 39], [253, 200, 39], [253, 202, 38], [253, 203, 38], [252, 205, 37], [252, 206, 37], [252, 208, 37], [252, 210, 37], [251, 211, 36], [251, 213, 36], [251, 215, 36], [250, 216, 36], [250, 218, 36], [249, 220, 36], [249, 221, 37], [248, 223, 37], [248, 225, 37], [247, 226, 37], [247, 228, 37], [246, 230, 38], [246, 232, 38], [245, 233, 38], [245, 235, 39], [244, 237, 39], [243, 238, 39], [243, 240, 39], [242, 242, 39], [241, 244, 38], [241, 245, 37], [240, 247, 36], [240, 249, 33]];
17106
+ function rgbSpline(spline) {
17107
+ return (colors) => {
17108
+ const n = colors.length;
17109
+ const r = new Array(n);
17110
+ const g = new Array(n);
17111
+ const b = new Array(n);
17112
+ let i;
17113
+ let color;
17114
+ for (i = 0; i < n; ++i) {
17115
+ color = [colors[i][0], colors[i][1], colors[i][2]];
17116
+ r[i] = color[0] || 0;
17117
+ g[i] = color[1] || 0;
17118
+ b[i] = color[2] || 0;
17119
+ }
17120
+ const rFunc = spline(r);
17121
+ const gFunc = spline(g);
17122
+ const bFunc = spline(b);
17123
+ return (t2) => [rFunc(t2), gFunc(t2), bFunc(t2)];
17124
+ };
17125
+ }
17126
+ function basis(values) {
17127
+ function innerBasis(t1, v0, v1, v2, v3) {
17128
+ const t2 = t1 * t1;
17129
+ const t3 = t2 * t1;
17130
+ return ((1 - 3 * t1 + 3 * t2 - t3) * v0 + (4 - 6 * t2 + 3 * t3) * v1 + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2 + t3 * v3) / 6;
17131
+ }
17132
+ const n = values.length - 1;
17133
+ return (t2) => {
17134
+ const i = t2 <= 0 ? t2 = 0 : t2 >= 1 ? (t2 = 1, n - 1) : Math.floor(t2 * n);
17135
+ const v1 = values[i];
17136
+ const v2 = values[i + 1];
17137
+ const v0 = i > 0 ? values[i - 1] : 2 * v1 - v2;
17138
+ const v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
17139
+ return innerBasis((t2 - i / n) * n, v0, v1, v2, v3);
17140
+ };
17141
+ }
17142
+ const interpolateRgbBasis = rgbSpline(basis);
17143
+ function interpolateSequentialMulti(range2) {
17144
+ const n = range2.length;
17145
+ return (t2) => range2[Math.max(0, Math.min(n - 1, Math.floor(t2 * n)))];
17146
+ }
17147
+ interpolateRgbBasis(schemeRdBu);
17148
+ interpolateSequentialMulti(schemePlasma);
17149
+ function getCellColors(params) {
17150
+ const {
17151
+ cellSets,
17152
+ cellSetSelection,
17153
+ cellSetColor,
17154
+ obsIndex,
17155
+ theme
17156
+ } = params;
17157
+ if (cellSetSelection && cellSets) {
17158
+ return treeToCellColorsBySetNames(
17159
+ cellSets,
17160
+ cellSetSelection,
17161
+ cellSetColor,
17162
+ theme
17163
+ );
17164
+ }
17165
+ if (obsIndex && theme) {
17166
+ return new Map(obsIndex.map((o) => [o, getDefaultColor(theme)]));
17167
+ }
17168
+ return /* @__PURE__ */ new Map();
17169
+ }
17148
17170
  export {
17149
17171
  FILE_EXTENSION_JSON,
17150
17172
  FILE_EXTENSION_TABULAR,
@@ -17160,6 +17182,7 @@ export {
17160
17182
  filterPathsByExpansionAndSelection,
17161
17183
  findChangedHierarchy,
17162
17184
  findLongestCommonPath,
17185
+ getCellColors,
17163
17186
  getCellSetPolygons,
17164
17187
  getLevelTooltipText,
17165
17188
  getNextNumberedNodeName,