function getComponentKey(component, index) {
    if (component && component.key != null) {
        return escape(component.key);
    }
    return index.toString(36);
}
var escaperLookup = {
    "=": "=0",
    ":": "=2"
};
function escape(key) {
    var escapeRegex = /[=:]/g;

    var escapedString = ("" + key).replace(escapeRegex, function(match) {
        return escaperLookup[match];
    });

    return "$" + escapedString;
}
var SEPARATOR = ".";
var SUBSEPARATOR = ":";
function traverseAllChildrenImpl(
    children,
    nameSoFar,
    callback,
    traverseContext
) {
    var type = typeof children;

    if (type === "undefined" || type === "boolean") {
    // All of the above are perceived as null.
        children = null;
    }

    if (
        children === null ||
    type === "string" ||
    type === "number" ||
    (type === "object" && children.$$typeof)
    ) {
        callback(
            traverseContext,
            children,
            nameSoFar === "" ? SEPARATOR + getComponentKey(children, 0) : nameSoFar
        );
        return 1;
    }

    var child;
    var nextName;
    var subtreeCount = 0; // Count of children found in the current subtree.
    var nextNamePrefix = nameSoFar === "" ? SEPARATOR : nameSoFar + SUBSEPARATOR;
    var iteratorFn = children && children["@@iterator"];
    if (iteratorFn && typeof iteratorFn === "function") {
        var iterator = iteratorFn.call(children);
        var step;
        children = [];
        while (!(step = iterator.next()).done) {
            children.push(step.value);
        }
    }

    if (Array.isArray(children)) {
        for (var i = 0; i < children.length; i++) {
            child = children[i];
            nextName = nextNamePrefix + getComponentKey(child, i);
            subtreeCount += traverseAllChildrenImpl(
                child,
                nextName,
                callback,
                traverseContext
            );
        }
    }

    return subtreeCount;
}
function traverseAllChildren(children, callback, traverseContext) {
    if (children == null) {
        return 0;
    }
  
    return traverseAllChildrenImpl(children, "", callback, traverseContext);
}
function forEachChildren(children, forEachFunc, forEachContext) {
    if (children == null) {
        return children;
    }
    var traverseContext = {
        count: 0,
        forEachFunc,
        forEachContext
    };
    traverseAllChildren(children, forEachSingleChild, traverseContext);
}
function forEachSingleChild(bookKeeping, child) {
    var {func, context} = bookKeeping;
    func.call(context, child, bookKeeping.count++);
}