1286 lines
41 KiB
JavaScript
1286 lines
41 KiB
JavaScript
import { aK as isObjectLike, aL as baseGetTag, aM as Symbol$1, ah as isArray, ag as isArrayLike, aN as arrayLikeKeys, aO as baseKeys, aP as memoize, aQ as isArguments, aR as copyObject, ae as keysIn, aS as getPrototype, aT as cloneArrayBuffer, aU as cloneTypedArray, aV as getTag, aW as nodeUtil, an as baseUnary, a8 as isObject, aX as copyArray, aY as isBuffer, aZ as cloneBuffer, a_ as initCloneObject, a$ as Stack, am as assignValue, b0 as MapCache, af as eq, b1 as Uint8Array, b2 as isTypedArray, b3 as isLength, al as isIndex, ak as identity, ai as baseFor, b4 as Set, ac as baseRest, b5 as isArrayLikeObject, ao as constant, z as isFunction, b6 as isEmpty } from "./mermaid-dcacb631.js";
|
||
var symbolTag$3 = "[object Symbol]";
|
||
function isSymbol(value) {
|
||
return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag$3;
|
||
}
|
||
function arrayMap(array, iteratee) {
|
||
var index = -1, length = array == null ? 0 : array.length, result = Array(length);
|
||
while (++index < length) {
|
||
result[index] = iteratee(array[index], index, array);
|
||
}
|
||
return result;
|
||
}
|
||
var INFINITY$2 = 1 / 0;
|
||
var symbolProto$2 = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto$2 ? symbolProto$2.toString : void 0;
|
||
function baseToString(value) {
|
||
if (typeof value == "string") {
|
||
return value;
|
||
}
|
||
if (isArray(value)) {
|
||
return arrayMap(value, baseToString) + "";
|
||
}
|
||
if (isSymbol(value)) {
|
||
return symbolToString ? symbolToString.call(value) : "";
|
||
}
|
||
var result = value + "";
|
||
return result == "0" && 1 / value == -INFINITY$2 ? "-0" : result;
|
||
}
|
||
function noop() {
|
||
}
|
||
function arrayEach(array, iteratee) {
|
||
var index = -1, length = array == null ? 0 : array.length;
|
||
while (++index < length) {
|
||
if (iteratee(array[index], index, array) === false) {
|
||
break;
|
||
}
|
||
}
|
||
return array;
|
||
}
|
||
function baseFindIndex(array, predicate, fromIndex, fromRight) {
|
||
var length = array.length, index = fromIndex + (fromRight ? 1 : -1);
|
||
while (fromRight ? index-- : ++index < length) {
|
||
if (predicate(array[index], index, array)) {
|
||
return index;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
function baseIsNaN(value) {
|
||
return value !== value;
|
||
}
|
||
function strictIndexOf(array, value, fromIndex) {
|
||
var index = fromIndex - 1, length = array.length;
|
||
while (++index < length) {
|
||
if (array[index] === value) {
|
||
return index;
|
||
}
|
||
}
|
||
return -1;
|
||
}
|
||
function baseIndexOf(array, value, fromIndex) {
|
||
return value === value ? strictIndexOf(array, value, fromIndex) : baseFindIndex(array, baseIsNaN, fromIndex);
|
||
}
|
||
function arrayIncludes(array, value) {
|
||
var length = array == null ? 0 : array.length;
|
||
return !!length && baseIndexOf(array, value, 0) > -1;
|
||
}
|
||
function keys(object) {
|
||
return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
|
||
}
|
||
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
|
||
function isKey(value, object) {
|
||
if (isArray(value)) {
|
||
return false;
|
||
}
|
||
var type = typeof value;
|
||
if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol(value)) {
|
||
return true;
|
||
}
|
||
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
|
||
}
|
||
var MAX_MEMOIZE_SIZE = 500;
|
||
function memoizeCapped(func) {
|
||
var result = memoize(func, function(key) {
|
||
if (cache.size === MAX_MEMOIZE_SIZE) {
|
||
cache.clear();
|
||
}
|
||
return key;
|
||
});
|
||
var cache = result.cache;
|
||
return result;
|
||
}
|
||
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
||
var reEscapeChar = /\\(\\)?/g;
|
||
var stringToPath = memoizeCapped(function(string) {
|
||
var result = [];
|
||
if (string.charCodeAt(0) === 46) {
|
||
result.push("");
|
||
}
|
||
string.replace(rePropName, function(match, number, quote, subString) {
|
||
result.push(quote ? subString.replace(reEscapeChar, "$1") : number || match);
|
||
});
|
||
return result;
|
||
});
|
||
const stringToPath$1 = stringToPath;
|
||
function toString(value) {
|
||
return value == null ? "" : baseToString(value);
|
||
}
|
||
function castPath(value, object) {
|
||
if (isArray(value)) {
|
||
return value;
|
||
}
|
||
return isKey(value, object) ? [value] : stringToPath$1(toString(value));
|
||
}
|
||
var INFINITY$1 = 1 / 0;
|
||
function toKey(value) {
|
||
if (typeof value == "string" || isSymbol(value)) {
|
||
return value;
|
||
}
|
||
var result = value + "";
|
||
return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result;
|
||
}
|
||
function baseGet(object, path) {
|
||
path = castPath(path, object);
|
||
var index = 0, length = path.length;
|
||
while (object != null && index < length) {
|
||
object = object[toKey(path[index++])];
|
||
}
|
||
return index && index == length ? object : void 0;
|
||
}
|
||
function get(object, path, defaultValue) {
|
||
var result = object == null ? void 0 : baseGet(object, path);
|
||
return result === void 0 ? defaultValue : result;
|
||
}
|
||
function arrayPush(array, values2) {
|
||
var index = -1, length = values2.length, offset = array.length;
|
||
while (++index < length) {
|
||
array[offset + index] = values2[index];
|
||
}
|
||
return array;
|
||
}
|
||
var spreadableSymbol = Symbol$1 ? Symbol$1.isConcatSpreadable : void 0;
|
||
function isFlattenable(value) {
|
||
return isArray(value) || isArguments(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
|
||
}
|
||
function baseFlatten(array, depth, predicate, isStrict, result) {
|
||
var index = -1, length = array.length;
|
||
predicate || (predicate = isFlattenable);
|
||
result || (result = []);
|
||
while (++index < length) {
|
||
var value = array[index];
|
||
if (depth > 0 && predicate(value)) {
|
||
if (depth > 1) {
|
||
baseFlatten(value, depth - 1, predicate, isStrict, result);
|
||
} else {
|
||
arrayPush(result, value);
|
||
}
|
||
} else if (!isStrict) {
|
||
result[result.length] = value;
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
function arrayReduce(array, iteratee, accumulator, initAccum) {
|
||
var index = -1, length = array == null ? 0 : array.length;
|
||
if (initAccum && length) {
|
||
accumulator = array[++index];
|
||
}
|
||
while (++index < length) {
|
||
accumulator = iteratee(accumulator, array[index], index, array);
|
||
}
|
||
return accumulator;
|
||
}
|
||
function baseAssign(object, source) {
|
||
return object && copyObject(source, keys(source), object);
|
||
}
|
||
function baseAssignIn(object, source) {
|
||
return object && copyObject(source, keysIn(source), object);
|
||
}
|
||
function arrayFilter(array, predicate) {
|
||
var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
|
||
while (++index < length) {
|
||
var value = array[index];
|
||
if (predicate(value, index, array)) {
|
||
result[resIndex++] = value;
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
function stubArray() {
|
||
return [];
|
||
}
|
||
var objectProto$4 = Object.prototype;
|
||
var propertyIsEnumerable = objectProto$4.propertyIsEnumerable;
|
||
var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
|
||
var getSymbols = !nativeGetSymbols$1 ? stubArray : function(object) {
|
||
if (object == null) {
|
||
return [];
|
||
}
|
||
object = Object(object);
|
||
return arrayFilter(nativeGetSymbols$1(object), function(symbol) {
|
||
return propertyIsEnumerable.call(object, symbol);
|
||
});
|
||
};
|
||
const getSymbols$1 = getSymbols;
|
||
function copySymbols(source, object) {
|
||
return copyObject(source, getSymbols$1(source), object);
|
||
}
|
||
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
||
var getSymbolsIn = !nativeGetSymbols ? stubArray : function(object) {
|
||
var result = [];
|
||
while (object) {
|
||
arrayPush(result, getSymbols$1(object));
|
||
object = getPrototype(object);
|
||
}
|
||
return result;
|
||
};
|
||
const getSymbolsIn$1 = getSymbolsIn;
|
||
function copySymbolsIn(source, object) {
|
||
return copyObject(source, getSymbolsIn$1(source), object);
|
||
}
|
||
function baseGetAllKeys(object, keysFunc, symbolsFunc) {
|
||
var result = keysFunc(object);
|
||
return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
|
||
}
|
||
function getAllKeys(object) {
|
||
return baseGetAllKeys(object, keys, getSymbols$1);
|
||
}
|
||
function getAllKeysIn(object) {
|
||
return baseGetAllKeys(object, keysIn, getSymbolsIn$1);
|
||
}
|
||
var objectProto$3 = Object.prototype;
|
||
var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
|
||
function initCloneArray(array) {
|
||
var length = array.length, result = new array.constructor(length);
|
||
if (length && typeof array[0] == "string" && hasOwnProperty$3.call(array, "index")) {
|
||
result.index = array.index;
|
||
result.input = array.input;
|
||
}
|
||
return result;
|
||
}
|
||
function cloneDataView(dataView, isDeep) {
|
||
var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
|
||
return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
|
||
}
|
||
var reFlags = /\w*$/;
|
||
function cloneRegExp(regexp) {
|
||
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
|
||
result.lastIndex = regexp.lastIndex;
|
||
return result;
|
||
}
|
||
var symbolProto$1 = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf$1 = symbolProto$1 ? symbolProto$1.valueOf : void 0;
|
||
function cloneSymbol(symbol) {
|
||
return symbolValueOf$1 ? Object(symbolValueOf$1.call(symbol)) : {};
|
||
}
|
||
var boolTag$2 = "[object Boolean]", dateTag$2 = "[object Date]", mapTag$3 = "[object Map]", numberTag$2 = "[object Number]", regexpTag$2 = "[object RegExp]", setTag$3 = "[object Set]", stringTag$2 = "[object String]", symbolTag$2 = "[object Symbol]";
|
||
var arrayBufferTag$2 = "[object ArrayBuffer]", dataViewTag$2 = "[object DataView]", float32Tag$1 = "[object Float32Array]", float64Tag$1 = "[object Float64Array]", int8Tag$1 = "[object Int8Array]", int16Tag$1 = "[object Int16Array]", int32Tag$1 = "[object Int32Array]", uint8Tag$1 = "[object Uint8Array]", uint8ClampedTag$1 = "[object Uint8ClampedArray]", uint16Tag$1 = "[object Uint16Array]", uint32Tag$1 = "[object Uint32Array]";
|
||
function initCloneByTag(object, tag, isDeep) {
|
||
var Ctor = object.constructor;
|
||
switch (tag) {
|
||
case arrayBufferTag$2:
|
||
return cloneArrayBuffer(object);
|
||
case boolTag$2:
|
||
case dateTag$2:
|
||
return new Ctor(+object);
|
||
case dataViewTag$2:
|
||
return cloneDataView(object, isDeep);
|
||
case float32Tag$1:
|
||
case float64Tag$1:
|
||
case int8Tag$1:
|
||
case int16Tag$1:
|
||
case int32Tag$1:
|
||
case uint8Tag$1:
|
||
case uint8ClampedTag$1:
|
||
case uint16Tag$1:
|
||
case uint32Tag$1:
|
||
return cloneTypedArray(object, isDeep);
|
||
case mapTag$3:
|
||
return new Ctor();
|
||
case numberTag$2:
|
||
case stringTag$2:
|
||
return new Ctor(object);
|
||
case regexpTag$2:
|
||
return cloneRegExp(object);
|
||
case setTag$3:
|
||
return new Ctor();
|
||
case symbolTag$2:
|
||
return cloneSymbol(object);
|
||
}
|
||
}
|
||
var mapTag$2 = "[object Map]";
|
||
function baseIsMap(value) {
|
||
return isObjectLike(value) && getTag(value) == mapTag$2;
|
||
}
|
||
var nodeIsMap = nodeUtil && nodeUtil.isMap;
|
||
var isMap = nodeIsMap ? baseUnary(nodeIsMap) : baseIsMap;
|
||
const isMap$1 = isMap;
|
||
var setTag$2 = "[object Set]";
|
||
function baseIsSet(value) {
|
||
return isObjectLike(value) && getTag(value) == setTag$2;
|
||
}
|
||
var nodeIsSet = nodeUtil && nodeUtil.isSet;
|
||
var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
|
||
const isSet$1 = isSet;
|
||
var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4;
|
||
var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", errorTag$1 = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag$1 = "[object Map]", numberTag$1 = "[object Number]", objectTag$1 = "[object Object]", regexpTag$1 = "[object RegExp]", setTag$1 = "[object Set]", stringTag$1 = "[object String]", symbolTag$1 = "[object Symbol]", weakMapTag = "[object WeakMap]";
|
||
var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$1 = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
|
||
var cloneableTags = {};
|
||
cloneableTags[argsTag$1] = cloneableTags[arrayTag$1] = cloneableTags[arrayBufferTag$1] = cloneableTags[dataViewTag$1] = cloneableTags[boolTag$1] = cloneableTags[dateTag$1] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag$1] = cloneableTags[numberTag$1] = cloneableTags[objectTag$1] = cloneableTags[regexpTag$1] = cloneableTags[setTag$1] = cloneableTags[stringTag$1] = cloneableTags[symbolTag$1] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
|
||
cloneableTags[errorTag$1] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
|
||
function baseClone(value, bitmask, customizer, key, object, stack) {
|
||
var result, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
|
||
if (customizer) {
|
||
result = object ? customizer(value, key, object, stack) : customizer(value);
|
||
}
|
||
if (result !== void 0) {
|
||
return result;
|
||
}
|
||
if (!isObject(value)) {
|
||
return value;
|
||
}
|
||
var isArr = isArray(value);
|
||
if (isArr) {
|
||
result = initCloneArray(value);
|
||
if (!isDeep) {
|
||
return copyArray(value, result);
|
||
}
|
||
} else {
|
||
var tag = getTag(value), isFunc = tag == funcTag || tag == genTag;
|
||
if (isBuffer(value)) {
|
||
return cloneBuffer(value, isDeep);
|
||
}
|
||
if (tag == objectTag$1 || tag == argsTag$1 || isFunc && !object) {
|
||
result = isFlat || isFunc ? {} : initCloneObject(value);
|
||
if (!isDeep) {
|
||
return isFlat ? copySymbolsIn(value, baseAssignIn(result, value)) : copySymbols(value, baseAssign(result, value));
|
||
}
|
||
} else {
|
||
if (!cloneableTags[tag]) {
|
||
return object ? value : {};
|
||
}
|
||
result = initCloneByTag(value, tag, isDeep);
|
||
}
|
||
}
|
||
stack || (stack = new Stack());
|
||
var stacked = stack.get(value);
|
||
if (stacked) {
|
||
return stacked;
|
||
}
|
||
stack.set(value, result);
|
||
if (isSet$1(value)) {
|
||
value.forEach(function(subValue) {
|
||
result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
|
||
});
|
||
} else if (isMap$1(value)) {
|
||
value.forEach(function(subValue, key2) {
|
||
result.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
|
||
});
|
||
}
|
||
var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys : isFlat ? keysIn : keys;
|
||
var props = isArr ? void 0 : keysFunc(value);
|
||
arrayEach(props || value, function(subValue, key2) {
|
||
if (props) {
|
||
key2 = subValue;
|
||
subValue = value[key2];
|
||
}
|
||
assignValue(result, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
|
||
});
|
||
return result;
|
||
}
|
||
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
||
function setCacheAdd(value) {
|
||
this.__data__.set(value, HASH_UNDEFINED);
|
||
return this;
|
||
}
|
||
function setCacheHas(value) {
|
||
return this.__data__.has(value);
|
||
}
|
||
function SetCache(values2) {
|
||
var index = -1, length = values2 == null ? 0 : values2.length;
|
||
this.__data__ = new MapCache();
|
||
while (++index < length) {
|
||
this.add(values2[index]);
|
||
}
|
||
}
|
||
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
||
SetCache.prototype.has = setCacheHas;
|
||
function arraySome(array, predicate) {
|
||
var index = -1, length = array == null ? 0 : array.length;
|
||
while (++index < length) {
|
||
if (predicate(array[index], index, array)) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
function cacheHas(cache, key) {
|
||
return cache.has(key);
|
||
}
|
||
var COMPARE_PARTIAL_FLAG$5 = 1, COMPARE_UNORDERED_FLAG$3 = 2;
|
||
function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
|
||
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5, arrLength = array.length, othLength = other.length;
|
||
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
||
return false;
|
||
}
|
||
var arrStacked = stack.get(array);
|
||
var othStacked = stack.get(other);
|
||
if (arrStacked && othStacked) {
|
||
return arrStacked == other && othStacked == array;
|
||
}
|
||
var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG$3 ? new SetCache() : void 0;
|
||
stack.set(array, other);
|
||
stack.set(other, array);
|
||
while (++index < arrLength) {
|
||
var arrValue = array[index], othValue = other[index];
|
||
if (customizer) {
|
||
var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
|
||
}
|
||
if (compared !== void 0) {
|
||
if (compared) {
|
||
continue;
|
||
}
|
||
result = false;
|
||
break;
|
||
}
|
||
if (seen) {
|
||
if (!arraySome(other, function(othValue2, othIndex) {
|
||
if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
|
||
return seen.push(othIndex);
|
||
}
|
||
})) {
|
||
result = false;
|
||
break;
|
||
}
|
||
} else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
||
result = false;
|
||
break;
|
||
}
|
||
}
|
||
stack["delete"](array);
|
||
stack["delete"](other);
|
||
return result;
|
||
}
|
||
function mapToArray(map) {
|
||
var index = -1, result = Array(map.size);
|
||
map.forEach(function(value, key) {
|
||
result[++index] = [key, value];
|
||
});
|
||
return result;
|
||
}
|
||
function setToArray(set) {
|
||
var index = -1, result = Array(set.size);
|
||
set.forEach(function(value) {
|
||
result[++index] = value;
|
||
});
|
||
return result;
|
||
}
|
||
var COMPARE_PARTIAL_FLAG$4 = 1, COMPARE_UNORDERED_FLAG$2 = 2;
|
||
var boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", mapTag = "[object Map]", numberTag = "[object Number]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]";
|
||
var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]";
|
||
var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
|
||
function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
|
||
switch (tag) {
|
||
case dataViewTag:
|
||
if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
|
||
return false;
|
||
}
|
||
object = object.buffer;
|
||
other = other.buffer;
|
||
case arrayBufferTag:
|
||
if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
|
||
return false;
|
||
}
|
||
return true;
|
||
case boolTag:
|
||
case dateTag:
|
||
case numberTag:
|
||
return eq(+object, +other);
|
||
case errorTag:
|
||
return object.name == other.name && object.message == other.message;
|
||
case regexpTag:
|
||
case stringTag:
|
||
return object == other + "";
|
||
case mapTag:
|
||
var convert = mapToArray;
|
||
case setTag:
|
||
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
|
||
convert || (convert = setToArray);
|
||
if (object.size != other.size && !isPartial) {
|
||
return false;
|
||
}
|
||
var stacked = stack.get(object);
|
||
if (stacked) {
|
||
return stacked == other;
|
||
}
|
||
bitmask |= COMPARE_UNORDERED_FLAG$2;
|
||
stack.set(object, other);
|
||
var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
|
||
stack["delete"](object);
|
||
return result;
|
||
case symbolTag:
|
||
if (symbolValueOf) {
|
||
return symbolValueOf.call(object) == symbolValueOf.call(other);
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
var COMPARE_PARTIAL_FLAG$3 = 1;
|
||
var objectProto$2 = Object.prototype;
|
||
var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
|
||
function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
|
||
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length;
|
||
if (objLength != othLength && !isPartial) {
|
||
return false;
|
||
}
|
||
var index = objLength;
|
||
while (index--) {
|
||
var key = objProps[index];
|
||
if (!(isPartial ? key in other : hasOwnProperty$2.call(other, key))) {
|
||
return false;
|
||
}
|
||
}
|
||
var objStacked = stack.get(object);
|
||
var othStacked = stack.get(other);
|
||
if (objStacked && othStacked) {
|
||
return objStacked == other && othStacked == object;
|
||
}
|
||
var result = true;
|
||
stack.set(object, other);
|
||
stack.set(other, object);
|
||
var skipCtor = isPartial;
|
||
while (++index < objLength) {
|
||
key = objProps[index];
|
||
var objValue = object[key], othValue = other[key];
|
||
if (customizer) {
|
||
var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
|
||
}
|
||
if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
|
||
result = false;
|
||
break;
|
||
}
|
||
skipCtor || (skipCtor = key == "constructor");
|
||
}
|
||
if (result && !skipCtor) {
|
||
var objCtor = object.constructor, othCtor = other.constructor;
|
||
if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
|
||
result = false;
|
||
}
|
||
}
|
||
stack["delete"](object);
|
||
stack["delete"](other);
|
||
return result;
|
||
}
|
||
var COMPARE_PARTIAL_FLAG$2 = 1;
|
||
var argsTag = "[object Arguments]", arrayTag = "[object Array]", objectTag = "[object Object]";
|
||
var objectProto$1 = Object.prototype;
|
||
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
||
function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
|
||
var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other);
|
||
objTag = objTag == argsTag ? objectTag : objTag;
|
||
othTag = othTag == argsTag ? objectTag : othTag;
|
||
var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag;
|
||
if (isSameTag && isBuffer(object)) {
|
||
if (!isBuffer(other)) {
|
||
return false;
|
||
}
|
||
objIsArr = true;
|
||
objIsObj = false;
|
||
}
|
||
if (isSameTag && !objIsObj) {
|
||
stack || (stack = new Stack());
|
||
return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
|
||
}
|
||
if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
|
||
var objIsWrapped = objIsObj && hasOwnProperty$1.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty$1.call(other, "__wrapped__");
|
||
if (objIsWrapped || othIsWrapped) {
|
||
var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
|
||
stack || (stack = new Stack());
|
||
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
||
}
|
||
}
|
||
if (!isSameTag) {
|
||
return false;
|
||
}
|
||
stack || (stack = new Stack());
|
||
return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
|
||
}
|
||
function baseIsEqual(value, other, bitmask, customizer, stack) {
|
||
if (value === other) {
|
||
return true;
|
||
}
|
||
if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) {
|
||
return value !== value && other !== other;
|
||
}
|
||
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
|
||
}
|
||
var COMPARE_PARTIAL_FLAG$1 = 1, COMPARE_UNORDERED_FLAG$1 = 2;
|
||
function baseIsMatch(object, source, matchData, customizer) {
|
||
var index = matchData.length, length = index, noCustomizer = !customizer;
|
||
if (object == null) {
|
||
return !length;
|
||
}
|
||
object = Object(object);
|
||
while (index--) {
|
||
var data = matchData[index];
|
||
if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
|
||
return false;
|
||
}
|
||
}
|
||
while (++index < length) {
|
||
data = matchData[index];
|
||
var key = data[0], objValue = object[key], srcValue = data[1];
|
||
if (noCustomizer && data[2]) {
|
||
if (objValue === void 0 && !(key in object)) {
|
||
return false;
|
||
}
|
||
} else {
|
||
var stack = new Stack();
|
||
if (customizer) {
|
||
var result = customizer(objValue, srcValue, key, object, source, stack);
|
||
}
|
||
if (!(result === void 0 ? baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) : result)) {
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
function isStrictComparable(value) {
|
||
return value === value && !isObject(value);
|
||
}
|
||
function getMatchData(object) {
|
||
var result = keys(object), length = result.length;
|
||
while (length--) {
|
||
var key = result[length], value = object[key];
|
||
result[length] = [key, value, isStrictComparable(value)];
|
||
}
|
||
return result;
|
||
}
|
||
function matchesStrictComparable(key, srcValue) {
|
||
return function(object) {
|
||
if (object == null) {
|
||
return false;
|
||
}
|
||
return object[key] === srcValue && (srcValue !== void 0 || key in Object(object));
|
||
};
|
||
}
|
||
function baseMatches(source) {
|
||
var matchData = getMatchData(source);
|
||
if (matchData.length == 1 && matchData[0][2]) {
|
||
return matchesStrictComparable(matchData[0][0], matchData[0][1]);
|
||
}
|
||
return function(object) {
|
||
return object === source || baseIsMatch(object, source, matchData);
|
||
};
|
||
}
|
||
function baseHasIn(object, key) {
|
||
return object != null && key in Object(object);
|
||
}
|
||
function hasPath(object, path, hasFunc) {
|
||
path = castPath(path, object);
|
||
var index = -1, length = path.length, result = false;
|
||
while (++index < length) {
|
||
var key = toKey(path[index]);
|
||
if (!(result = object != null && hasFunc(object, key))) {
|
||
break;
|
||
}
|
||
object = object[key];
|
||
}
|
||
if (result || ++index != length) {
|
||
return result;
|
||
}
|
||
length = object == null ? 0 : object.length;
|
||
return !!length && isLength(length) && isIndex(key, length) && (isArray(object) || isArguments(object));
|
||
}
|
||
function hasIn(object, path) {
|
||
return object != null && hasPath(object, path, baseHasIn);
|
||
}
|
||
var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2;
|
||
function baseMatchesProperty(path, srcValue) {
|
||
if (isKey(path) && isStrictComparable(srcValue)) {
|
||
return matchesStrictComparable(toKey(path), srcValue);
|
||
}
|
||
return function(object) {
|
||
var objValue = get(object, path);
|
||
return objValue === void 0 && objValue === srcValue ? hasIn(object, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
|
||
};
|
||
}
|
||
function baseProperty(key) {
|
||
return function(object) {
|
||
return object == null ? void 0 : object[key];
|
||
};
|
||
}
|
||
function basePropertyDeep(path) {
|
||
return function(object) {
|
||
return baseGet(object, path);
|
||
};
|
||
}
|
||
function property(path) {
|
||
return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
|
||
}
|
||
function baseIteratee(value) {
|
||
if (typeof value == "function") {
|
||
return value;
|
||
}
|
||
if (value == null) {
|
||
return identity;
|
||
}
|
||
if (typeof value == "object") {
|
||
return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
|
||
}
|
||
return property(value);
|
||
}
|
||
function baseForOwn(object, iteratee) {
|
||
return object && baseFor(object, iteratee, keys);
|
||
}
|
||
function createBaseEach(eachFunc, fromRight) {
|
||
return function(collection, iteratee) {
|
||
if (collection == null) {
|
||
return collection;
|
||
}
|
||
if (!isArrayLike(collection)) {
|
||
return eachFunc(collection, iteratee);
|
||
}
|
||
var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection);
|
||
while (fromRight ? index-- : ++index < length) {
|
||
if (iteratee(iterable[index], index, iterable) === false) {
|
||
break;
|
||
}
|
||
}
|
||
return collection;
|
||
};
|
||
}
|
||
var baseEach = createBaseEach(baseForOwn);
|
||
const baseEach$1 = baseEach;
|
||
function arrayIncludesWith(array, value, comparator) {
|
||
var index = -1, length = array == null ? 0 : array.length;
|
||
while (++index < length) {
|
||
if (comparator(value, array[index])) {
|
||
return true;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
function castFunction(value) {
|
||
return typeof value == "function" ? value : identity;
|
||
}
|
||
function forEach(collection, iteratee) {
|
||
var func = isArray(collection) ? arrayEach : baseEach$1;
|
||
return func(collection, castFunction(iteratee));
|
||
}
|
||
function baseFilter(collection, predicate) {
|
||
var result = [];
|
||
baseEach$1(collection, function(value, index, collection2) {
|
||
if (predicate(value, index, collection2)) {
|
||
result.push(value);
|
||
}
|
||
});
|
||
return result;
|
||
}
|
||
function filter(collection, predicate) {
|
||
var func = isArray(collection) ? arrayFilter : baseFilter;
|
||
return func(collection, baseIteratee(predicate));
|
||
}
|
||
var objectProto = Object.prototype;
|
||
var hasOwnProperty = objectProto.hasOwnProperty;
|
||
function baseHas(object, key) {
|
||
return object != null && hasOwnProperty.call(object, key);
|
||
}
|
||
function has(object, path) {
|
||
return object != null && hasPath(object, path, baseHas);
|
||
}
|
||
function baseValues(object, props) {
|
||
return arrayMap(props, function(key) {
|
||
return object[key];
|
||
});
|
||
}
|
||
function values(object) {
|
||
return object == null ? [] : baseValues(object, keys(object));
|
||
}
|
||
function isUndefined(value) {
|
||
return value === void 0;
|
||
}
|
||
function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
|
||
eachFunc(collection, function(value, index, collection2) {
|
||
accumulator = initAccum ? (initAccum = false, value) : iteratee(accumulator, value, index, collection2);
|
||
});
|
||
return accumulator;
|
||
}
|
||
function reduce(collection, iteratee, accumulator) {
|
||
var func = isArray(collection) ? arrayReduce : baseReduce, initAccum = arguments.length < 3;
|
||
return func(collection, baseIteratee(iteratee), accumulator, initAccum, baseEach$1);
|
||
}
|
||
var INFINITY = 1 / 0;
|
||
var createSet = !(Set && 1 / setToArray(new Set([, -0]))[1] == INFINITY) ? noop : function(values2) {
|
||
return new Set(values2);
|
||
};
|
||
const createSet$1 = createSet;
|
||
var LARGE_ARRAY_SIZE = 200;
|
||
function baseUniq(array, iteratee, comparator) {
|
||
var index = -1, includes = arrayIncludes, length = array.length, isCommon = true, result = [], seen = result;
|
||
if (comparator) {
|
||
isCommon = false;
|
||
includes = arrayIncludesWith;
|
||
} else if (length >= LARGE_ARRAY_SIZE) {
|
||
var set = iteratee ? null : createSet$1(array);
|
||
if (set) {
|
||
return setToArray(set);
|
||
}
|
||
isCommon = false;
|
||
includes = cacheHas;
|
||
seen = new SetCache();
|
||
} else {
|
||
seen = iteratee ? [] : result;
|
||
}
|
||
outer:
|
||
while (++index < length) {
|
||
var value = array[index], computed = iteratee ? iteratee(value) : value;
|
||
value = comparator || value !== 0 ? value : 0;
|
||
if (isCommon && computed === computed) {
|
||
var seenIndex = seen.length;
|
||
while (seenIndex--) {
|
||
if (seen[seenIndex] === computed) {
|
||
continue outer;
|
||
}
|
||
}
|
||
if (iteratee) {
|
||
seen.push(computed);
|
||
}
|
||
result.push(value);
|
||
} else if (!includes(seen, computed, comparator)) {
|
||
if (seen !== result) {
|
||
seen.push(computed);
|
||
}
|
||
result.push(value);
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
var union = baseRest(function(arrays) {
|
||
return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
|
||
});
|
||
const union$1 = union;
|
||
var DEFAULT_EDGE_NAME = "\0";
|
||
var GRAPH_NODE = "\0";
|
||
var EDGE_KEY_DELIM = "";
|
||
class Graph {
|
||
constructor(opts = {}) {
|
||
this._isDirected = has(opts, "directed") ? opts.directed : true;
|
||
this._isMultigraph = has(opts, "multigraph") ? opts.multigraph : false;
|
||
this._isCompound = has(opts, "compound") ? opts.compound : false;
|
||
this._label = void 0;
|
||
this._defaultNodeLabelFn = constant(void 0);
|
||
this._defaultEdgeLabelFn = constant(void 0);
|
||
this._nodes = {};
|
||
if (this._isCompound) {
|
||
this._parent = {};
|
||
this._children = {};
|
||
this._children[GRAPH_NODE] = {};
|
||
}
|
||
this._in = {};
|
||
this._preds = {};
|
||
this._out = {};
|
||
this._sucs = {};
|
||
this._edgeObjs = {};
|
||
this._edgeLabels = {};
|
||
}
|
||
/* === Graph functions ========= */
|
||
isDirected() {
|
||
return this._isDirected;
|
||
}
|
||
isMultigraph() {
|
||
return this._isMultigraph;
|
||
}
|
||
isCompound() {
|
||
return this._isCompound;
|
||
}
|
||
setGraph(label) {
|
||
this._label = label;
|
||
return this;
|
||
}
|
||
graph() {
|
||
return this._label;
|
||
}
|
||
/* === Node functions ========== */
|
||
setDefaultNodeLabel(newDefault) {
|
||
if (!isFunction(newDefault)) {
|
||
newDefault = constant(newDefault);
|
||
}
|
||
this._defaultNodeLabelFn = newDefault;
|
||
return this;
|
||
}
|
||
nodeCount() {
|
||
return this._nodeCount;
|
||
}
|
||
nodes() {
|
||
return keys(this._nodes);
|
||
}
|
||
sources() {
|
||
var self = this;
|
||
return filter(this.nodes(), function(v) {
|
||
return isEmpty(self._in[v]);
|
||
});
|
||
}
|
||
sinks() {
|
||
var self = this;
|
||
return filter(this.nodes(), function(v) {
|
||
return isEmpty(self._out[v]);
|
||
});
|
||
}
|
||
setNodes(vs, value) {
|
||
var args = arguments;
|
||
var self = this;
|
||
forEach(vs, function(v) {
|
||
if (args.length > 1) {
|
||
self.setNode(v, value);
|
||
} else {
|
||
self.setNode(v);
|
||
}
|
||
});
|
||
return this;
|
||
}
|
||
setNode(v, value) {
|
||
if (has(this._nodes, v)) {
|
||
if (arguments.length > 1) {
|
||
this._nodes[v] = value;
|
||
}
|
||
return this;
|
||
}
|
||
this._nodes[v] = arguments.length > 1 ? value : this._defaultNodeLabelFn(v);
|
||
if (this._isCompound) {
|
||
this._parent[v] = GRAPH_NODE;
|
||
this._children[v] = {};
|
||
this._children[GRAPH_NODE][v] = true;
|
||
}
|
||
this._in[v] = {};
|
||
this._preds[v] = {};
|
||
this._out[v] = {};
|
||
this._sucs[v] = {};
|
||
++this._nodeCount;
|
||
return this;
|
||
}
|
||
node(v) {
|
||
return this._nodes[v];
|
||
}
|
||
hasNode(v) {
|
||
return has(this._nodes, v);
|
||
}
|
||
removeNode(v) {
|
||
var self = this;
|
||
if (has(this._nodes, v)) {
|
||
var removeEdge = function(e) {
|
||
self.removeEdge(self._edgeObjs[e]);
|
||
};
|
||
delete this._nodes[v];
|
||
if (this._isCompound) {
|
||
this._removeFromParentsChildList(v);
|
||
delete this._parent[v];
|
||
forEach(this.children(v), function(child) {
|
||
self.setParent(child);
|
||
});
|
||
delete this._children[v];
|
||
}
|
||
forEach(keys(this._in[v]), removeEdge);
|
||
delete this._in[v];
|
||
delete this._preds[v];
|
||
forEach(keys(this._out[v]), removeEdge);
|
||
delete this._out[v];
|
||
delete this._sucs[v];
|
||
--this._nodeCount;
|
||
}
|
||
return this;
|
||
}
|
||
setParent(v, parent) {
|
||
if (!this._isCompound) {
|
||
throw new Error("Cannot set parent in a non-compound graph");
|
||
}
|
||
if (isUndefined(parent)) {
|
||
parent = GRAPH_NODE;
|
||
} else {
|
||
parent += "";
|
||
for (var ancestor = parent; !isUndefined(ancestor); ancestor = this.parent(ancestor)) {
|
||
if (ancestor === v) {
|
||
throw new Error("Setting " + parent + " as parent of " + v + " would create a cycle");
|
||
}
|
||
}
|
||
this.setNode(parent);
|
||
}
|
||
this.setNode(v);
|
||
this._removeFromParentsChildList(v);
|
||
this._parent[v] = parent;
|
||
this._children[parent][v] = true;
|
||
return this;
|
||
}
|
||
_removeFromParentsChildList(v) {
|
||
delete this._children[this._parent[v]][v];
|
||
}
|
||
parent(v) {
|
||
if (this._isCompound) {
|
||
var parent = this._parent[v];
|
||
if (parent !== GRAPH_NODE) {
|
||
return parent;
|
||
}
|
||
}
|
||
}
|
||
children(v) {
|
||
if (isUndefined(v)) {
|
||
v = GRAPH_NODE;
|
||
}
|
||
if (this._isCompound) {
|
||
var children = this._children[v];
|
||
if (children) {
|
||
return keys(children);
|
||
}
|
||
} else if (v === GRAPH_NODE) {
|
||
return this.nodes();
|
||
} else if (this.hasNode(v)) {
|
||
return [];
|
||
}
|
||
}
|
||
predecessors(v) {
|
||
var predsV = this._preds[v];
|
||
if (predsV) {
|
||
return keys(predsV);
|
||
}
|
||
}
|
||
successors(v) {
|
||
var sucsV = this._sucs[v];
|
||
if (sucsV) {
|
||
return keys(sucsV);
|
||
}
|
||
}
|
||
neighbors(v) {
|
||
var preds = this.predecessors(v);
|
||
if (preds) {
|
||
return union$1(preds, this.successors(v));
|
||
}
|
||
}
|
||
isLeaf(v) {
|
||
var neighbors;
|
||
if (this.isDirected()) {
|
||
neighbors = this.successors(v);
|
||
} else {
|
||
neighbors = this.neighbors(v);
|
||
}
|
||
return neighbors.length === 0;
|
||
}
|
||
filterNodes(filter2) {
|
||
var copy = new this.constructor({
|
||
directed: this._isDirected,
|
||
multigraph: this._isMultigraph,
|
||
compound: this._isCompound
|
||
});
|
||
copy.setGraph(this.graph());
|
||
var self = this;
|
||
forEach(this._nodes, function(value, v) {
|
||
if (filter2(v)) {
|
||
copy.setNode(v, value);
|
||
}
|
||
});
|
||
forEach(this._edgeObjs, function(e) {
|
||
if (copy.hasNode(e.v) && copy.hasNode(e.w)) {
|
||
copy.setEdge(e, self.edge(e));
|
||
}
|
||
});
|
||
var parents = {};
|
||
function findParent(v) {
|
||
var parent = self.parent(v);
|
||
if (parent === void 0 || copy.hasNode(parent)) {
|
||
parents[v] = parent;
|
||
return parent;
|
||
} else if (parent in parents) {
|
||
return parents[parent];
|
||
} else {
|
||
return findParent(parent);
|
||
}
|
||
}
|
||
if (this._isCompound) {
|
||
forEach(copy.nodes(), function(v) {
|
||
copy.setParent(v, findParent(v));
|
||
});
|
||
}
|
||
return copy;
|
||
}
|
||
/* === Edge functions ========== */
|
||
setDefaultEdgeLabel(newDefault) {
|
||
if (!isFunction(newDefault)) {
|
||
newDefault = constant(newDefault);
|
||
}
|
||
this._defaultEdgeLabelFn = newDefault;
|
||
return this;
|
||
}
|
||
edgeCount() {
|
||
return this._edgeCount;
|
||
}
|
||
edges() {
|
||
return values(this._edgeObjs);
|
||
}
|
||
setPath(vs, value) {
|
||
var self = this;
|
||
var args = arguments;
|
||
reduce(vs, function(v, w) {
|
||
if (args.length > 1) {
|
||
self.setEdge(v, w, value);
|
||
} else {
|
||
self.setEdge(v, w);
|
||
}
|
||
return w;
|
||
});
|
||
return this;
|
||
}
|
||
/*
|
||
* setEdge(v, w, [value, [name]])
|
||
* setEdge({ v, w, [name] }, [value])
|
||
*/
|
||
setEdge() {
|
||
var v, w, name, value;
|
||
var valueSpecified = false;
|
||
var arg0 = arguments[0];
|
||
if (typeof arg0 === "object" && arg0 !== null && "v" in arg0) {
|
||
v = arg0.v;
|
||
w = arg0.w;
|
||
name = arg0.name;
|
||
if (arguments.length === 2) {
|
||
value = arguments[1];
|
||
valueSpecified = true;
|
||
}
|
||
} else {
|
||
v = arg0;
|
||
w = arguments[1];
|
||
name = arguments[3];
|
||
if (arguments.length > 2) {
|
||
value = arguments[2];
|
||
valueSpecified = true;
|
||
}
|
||
}
|
||
v = "" + v;
|
||
w = "" + w;
|
||
if (!isUndefined(name)) {
|
||
name = "" + name;
|
||
}
|
||
var e = edgeArgsToId(this._isDirected, v, w, name);
|
||
if (has(this._edgeLabels, e)) {
|
||
if (valueSpecified) {
|
||
this._edgeLabels[e] = value;
|
||
}
|
||
return this;
|
||
}
|
||
if (!isUndefined(name) && !this._isMultigraph) {
|
||
throw new Error("Cannot set a named edge when isMultigraph = false");
|
||
}
|
||
this.setNode(v);
|
||
this.setNode(w);
|
||
this._edgeLabels[e] = valueSpecified ? value : this._defaultEdgeLabelFn(v, w, name);
|
||
var edgeObj = edgeArgsToObj(this._isDirected, v, w, name);
|
||
v = edgeObj.v;
|
||
w = edgeObj.w;
|
||
Object.freeze(edgeObj);
|
||
this._edgeObjs[e] = edgeObj;
|
||
incrementOrInitEntry(this._preds[w], v);
|
||
incrementOrInitEntry(this._sucs[v], w);
|
||
this._in[w][e] = edgeObj;
|
||
this._out[v][e] = edgeObj;
|
||
this._edgeCount++;
|
||
return this;
|
||
}
|
||
edge(v, w, name) {
|
||
var e = arguments.length === 1 ? edgeObjToId(this._isDirected, arguments[0]) : edgeArgsToId(this._isDirected, v, w, name);
|
||
return this._edgeLabels[e];
|
||
}
|
||
hasEdge(v, w, name) {
|
||
var e = arguments.length === 1 ? edgeObjToId(this._isDirected, arguments[0]) : edgeArgsToId(this._isDirected, v, w, name);
|
||
return has(this._edgeLabels, e);
|
||
}
|
||
removeEdge(v, w, name) {
|
||
var e = arguments.length === 1 ? edgeObjToId(this._isDirected, arguments[0]) : edgeArgsToId(this._isDirected, v, w, name);
|
||
var edge = this._edgeObjs[e];
|
||
if (edge) {
|
||
v = edge.v;
|
||
w = edge.w;
|
||
delete this._edgeLabels[e];
|
||
delete this._edgeObjs[e];
|
||
decrementOrRemoveEntry(this._preds[w], v);
|
||
decrementOrRemoveEntry(this._sucs[v], w);
|
||
delete this._in[w][e];
|
||
delete this._out[v][e];
|
||
this._edgeCount--;
|
||
}
|
||
return this;
|
||
}
|
||
inEdges(v, u) {
|
||
var inV = this._in[v];
|
||
if (inV) {
|
||
var edges = values(inV);
|
||
if (!u) {
|
||
return edges;
|
||
}
|
||
return filter(edges, function(edge) {
|
||
return edge.v === u;
|
||
});
|
||
}
|
||
}
|
||
outEdges(v, w) {
|
||
var outV = this._out[v];
|
||
if (outV) {
|
||
var edges = values(outV);
|
||
if (!w) {
|
||
return edges;
|
||
}
|
||
return filter(edges, function(edge) {
|
||
return edge.w === w;
|
||
});
|
||
}
|
||
}
|
||
nodeEdges(v, w) {
|
||
var inEdges = this.inEdges(v, w);
|
||
if (inEdges) {
|
||
return inEdges.concat(this.outEdges(v, w));
|
||
}
|
||
}
|
||
}
|
||
Graph.prototype._nodeCount = 0;
|
||
Graph.prototype._edgeCount = 0;
|
||
function incrementOrInitEntry(map, k) {
|
||
if (map[k]) {
|
||
map[k]++;
|
||
} else {
|
||
map[k] = 1;
|
||
}
|
||
}
|
||
function decrementOrRemoveEntry(map, k) {
|
||
if (!--map[k]) {
|
||
delete map[k];
|
||
}
|
||
}
|
||
function edgeArgsToId(isDirected, v_, w_, name) {
|
||
var v = "" + v_;
|
||
var w = "" + w_;
|
||
if (!isDirected && v > w) {
|
||
var tmp = v;
|
||
v = w;
|
||
w = tmp;
|
||
}
|
||
return v + EDGE_KEY_DELIM + w + EDGE_KEY_DELIM + (isUndefined(name) ? DEFAULT_EDGE_NAME : name);
|
||
}
|
||
function edgeArgsToObj(isDirected, v_, w_, name) {
|
||
var v = "" + v_;
|
||
var w = "" + w_;
|
||
if (!isDirected && v > w) {
|
||
var tmp = v;
|
||
v = w;
|
||
w = tmp;
|
||
}
|
||
var edgeObj = { v, w };
|
||
if (name) {
|
||
edgeObj.name = name;
|
||
}
|
||
return edgeObj;
|
||
}
|
||
function edgeObjToId(isDirected, edgeObj) {
|
||
return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name);
|
||
}
|
||
export {
|
||
Graph as G,
|
||
isSymbol as a,
|
||
baseFlatten as b,
|
||
baseClone as c,
|
||
baseIteratee as d,
|
||
baseFindIndex as e,
|
||
forEach as f,
|
||
baseEach$1 as g,
|
||
has as h,
|
||
isUndefined as i,
|
||
arrayMap as j,
|
||
keys as k,
|
||
castFunction as l,
|
||
baseForOwn as m,
|
||
castPath as n,
|
||
baseGet as o,
|
||
hasIn as p,
|
||
toString as q,
|
||
filter as r,
|
||
reduce as s,
|
||
toKey as t,
|
||
values as v
|
||
};
|