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