------------------------------------------------------------------ results / rawPositions helpers ------------------------------------------------------------------ NB: expects instance context
193441
function (section) {
  if (!this.grouped) {
    var ffaM = this.findMatch({ s: section, r: 1, m: 1 });
    return (ffaM && ffaM.m) ? ffaM : null;
  }

  var gs = $.firstBy(function (stage) {
    return stage.tbSection === section;
  }, this.groupStages);

  if (gs == null || !gs.isDone()) {
    return null;
  }
  var gsRes = gs.results();
  var positions = gs.rawPositions(gsRes);
  var match = { p: [], m: [] }; // match equivalent
  // convert from rawPosition - only used by matchTieCompute in updater
  positions[0].forEach(function (xps, x) {
    xps.forEach(function (p) {
      match.p.push(p);
      match.m.push(positions[0].length-x);
    });
  });
  return match;
}
1043070
function parseBorrows(params, constructor) {
        if (hasOwn(params, '$borrows')) {
            var current,
                mixins = toArray(params.$borrows),
                i = mixins.length,
                key,
                opts = {};

            // Verify argument type
            if (!i && !isArray(params.$borrows)) {
                throw new Error('$borrows of class "' + constructor.prototype.$name + '" must be a class/object or an array of classes/objects.');
            }
            // Verify duplicate entries
            if (i !== unique(mixins).length && compact(mixins).length === i) {
                throw new Error('There are duplicate entries defined in $borrows of class "' + constructor.prototype.$name + '".');
            }

            for (i -= 1; i >= 0; i -= 1) {
                current = mixins[i];

                // If is a vanilla object
                if (isObject(current)) {
                    if (current.$static) {
                        throw new Error('Entry at index ' + i + ' in $borrows of class "' + constructor.prototype.$name + '" is not a valid class/object.');
                    }
                    borrowFromVanilla(current, constructor);
                    continue;
                }
                // If is a vanilla class
                if (isFunction(current) && !current[$interface]) {
                    if (!current[$class]) {
                        borrowFromVanilla(current.prototype, constructor);
                        continue;
                    }
                } else {
                    throw new Error('Entry at index ' + i + ' in $borrows of class "' + constructor.prototype.$name + '" is not a valid class/object.');
                }

                current = current.prototype;

                // Verify if is an abstract class with unimplemented members
                if (current.$static[$abstract] && current.$static[$abstract].unimplemented) {
                    throw new Error('Entry at index ' + i + ' in $borrows of class "' + constructor.prototype.$name + '" is an abstract class with abstract members, which are not allowed.');
                }

                // Verify if it has parent
                if (current.$static.$parent) {
                    throw new Error('Entry at index ' + i + ' in $borrows of class "' + constructor.prototype.$name + '" is an inherited class (only root classes are supported).');
                }

                delete opts.isStatic;

                // Grab mixin members
                for (key in current.$static[$class].methods) {
                    if (!hasOwn(constructor.prototype, key)) {    // Already defined members are not overwritten
                        // We need to clone the metadata and delete the allowed because otherwise multiple classes borrowing from the same would have access
                        // Same applies to the things bellow
                        opts.metadata = mixIn({}, current.$static[$class].methods[key]);
                        delete opts.metadata.allowed;
                        addMethod(key, opts.metadata.implementation || current[key], constructor, opts);
                    }
                }

                for (key in current.$static[$class].properties) {
                    if (!hasOwn(constructor.prototype, key)) {    // Already defined members are not overwritten
                        opts.metadata = mixIn({}, current.$static[$class].properties[key]);
                        delete opts.metadata.allowed;
                        addProperty(key, opts.metadata.value || current[key], constructor, opts);
                    }
                }

                opts.isStatic = true;

                // Grab mixin static members
                for (key in current.$static[$class].staticMethods) {
                    opts.metadata = mixIn({}, current.$static[$class].staticMethods[key]);
                    delete opts.metadata.allowed;
                    addMethod(key, opts.metadata.implementation || current.$static[key], constructor, opts);
                }

                for (key in current.$static[$class].staticProperties) {
                    opts.metadata = mixIn({}, current.$static[$class].staticProperties[key]);
                    delete opts.metadata.allowed;
                    addProperty(key, opts.metadata.value || current.$static[key], constructor, opts);
                }

                if (current.$static[$class].isVanilla) {
                    constructor[$class].forceUnlocked = true;
                }

                // Merge the binds
                combine(constructor[$class].binds, current.$static[$class].binds);
            }

            delete params.$borrows;
        }
    }
1207290
function process_endpoint_result(raw_result) {
                const store_result = op.execute_on_store(raw_result);
                const result = NOOP === store_result
                    ? raw_result
                    : store_result
                    ;
                return resolve_promise(prepare_result(result));
            }
23364
function ctx() {
    return function context(req, res, next) {
        var data = {};

        req.set = function set(key, value) {
            assert.string(key, 'key must be string');

            if (key === '') {
                assert.fail('key must not be empty string');
            }
            data[key] = value;
        };

        req.get = function get(key) {
            assert.string(key, 'key must be string');

            if (key === '') {
                assert.fail('key must not be empty string');
            }
            return data[key];
        };

        // private method which returns the entire context object
        req._getAllContext = function _getAllContext() {
            return data;
        };

        return next();
    };
}
605778
function Context(resolve, reject, custom) {
    this.resolve = resolve;
    this.reject = reject;
    this.custom = custom;
  }
821957
function buildElementsTree(contexts) {

	contexts = contexts || [document];

	var queriesArray = Object.keys(queries).map(function(key) {
		return queries[key];
	});

	var selector = queriesArray.map(function(query) {
		return query._selector;
	}).join(',');

	var elements = [];
	contexts.forEach(function(context) {
		for (var node = context.parentNode; node; node = node.parentNode) {
			// Skip nested contexts
			if (contexts.indexOf(node) !== -1) {
				return;
			}
		}
		if (context !== document && elementMatchesSelector(context, selector)) {
			elements.push(context);
		}
		elements.push.apply(elements, arrayFrom(context.querySelectorAll(selector)));
	});

	var tree = [];
	var treeCache = createCacheMap();

	elements.forEach(function(element) {

		if (element === documentElement) {
			return;
		}

		var treeNode = {
			_element: element,
			_children: [],
			_queries: [],
			_changes: [],
			_done: false,
		};

		var children = tree;
		for (var node = element.parentNode; node; node = node.parentNode) {
			if (treeCache.get(node)) {
				children = treeCache.get(node)._children;
				break;
			}
		}

		treeCache.set(element, treeNode);

		children.push(treeNode);

		queriesArray.forEach(function(query) {
			if (elementMatchesSelector(element, query._selector)) {
				treeNode._queries.push(query);
			}
		});

	});

	return tree;

}
395061
function(results, done) {
                // Find the index of the fields we want
                var rawIndex = results.fields.indexOf("_raw");
                var sourcetypeIndex = results.fields.indexOf("sourcetype");
                var userIndex = results.fields.indexOf("user");
                
                // Print out each result and the key-value pairs we want
                console.log("Results: ");
                for(var i = 0; i < results.rows.length; i++) {
                    console.log("  Result " + i + ": ");
                    console.log("    sourcetype: " + results.rows[i][sourcetypeIndex]);
                    console.log("    user: " + results.rows[i][userIndex]);
                    console.log("    _raw: " + results.rows[i][rawIndex]);
                }
                
                done();
            }
1087190
function newContext(context, params) {
  if (!params) {
    return context;
  }

  return assign({}, context, {
    data: params.data ? arrayPush(params.data, context.data) : context.data,
    parent: params.newParent ? context : context.parent,
    index: 'index' in params ? params.index : context.index,
    item: 'item' in params ? params.item : context.item
  });
}
1143249
function parseNode(attrNode, parsers, context) {
    const attrNames = Object.keys(attrNode);
    const errorContext = context.errorContext;

    Object.keys(parsers).forEach(attrName => {
        const parser = parsers[attrName];

        context.errorContext = ` (option "${attrName}"${errorContext})`;
        removeValue(attrNames, attrName);

        if (attrName in attrNode && parser !== null) {
            attrNode[attrName] = parser(attrNode[attrName], context);
        }
    });

    context.errorContext = errorContext;

    if (attrNames.length > 0) {
        throw new ImplementationError(`Invalid option "${attrNames.join(', ')}"${context.errorContext}`);
    }
}
1328094
function newRecordInstance (raw) {
    // return raw data
    if (this.query.args.raw) {
        return raw
    }
    // return new model instance
    else {
        return this.query.model.newInstance({
            model: this.query.model,
            plain: this.query.args.plain,
            raw: raw,
            session: this.query.session,
        })
    }
}
829165
function context(value) {
  var out = {}

  value = value || {}

  ;['priority', 'timeout'].forEach(function eachIntKey(key) {
    if (value.hasOwnProperty(key)) {
      out[key] = parseInt(value[key], 10)

      if (isNaN(out[key])) {
        throw new FieldTypeError('context.' + key, 'number')
      }
    }
  })


  if (value.hasOwnProperty('queryId')) {
    out.queryId = value.queryId + ''
  }

  ['bySegment', 'populateCache', 'useCache', 'finalize', 'skipEmptyBuckets'].forEach(function eachBoolKey(key) {
    if (value.hasOwnProperty(key)) {
      out[key] = !!((value[key]||false).valueOf())
    }
  })

  return out
}
1252146
function Expectations(obj, method) {
    var debug = require('debug')(PREFIX + ':expectations:' + method);
    var timesCalled = 0;
    var calledWithArgs = {};

    function call() {
        calledWithArgs[timesCalled++] = _.cloneDeep(arguments);
    }

    function invocation(index) {
        if (!(index.toString() in calledWithArgs)) {
            throw new Error('invocation out of range');
        }
        var arg = calledWithArgs[index.toString()];
        return {
            withArg: withArg(arg)
        };
    }

    var self = {
        invocation: invocation,
        call: call
    };

    function checkArg(expected, values) {
        if (_.isArray(expected)) {
            var jsonExpected = JSON.stringify(expected);
            return _.some(_.filter(values, function(v) {
                return JSON.stringify(v) === jsonExpected;
            }));
        }
        if (_.isObject(expected)) {
            return _.some(_.filter(values, expected));
        }
        return _.includes(values, expected);
    }

    function checkArgs(expectedArgs, callArgs, evaluator) {
        var values = _.values(callArgs);
        var argResults = [];
        for (var argIndex = 0; argIndex < expectedArgs.length; argIndex++) {
            var expected = expectedArgs[argIndex];
            debug('expected', expected, 'in', values);
            var foundArg = checkArg(expected, values);
            argResults.push(foundArg);
        }
        return evaluator(argResults);
    }

    function checkAnyArgs(expectedArgs, callArgs) {
        return checkArgs(expectedArgs, callArgs, _.some);
    }

    function withArgs() {
        var args = _.values(arguments);
        assertArgsWithEvaluator(calledWithArgs, args, _.every);
    }

    function withSingleArg(arg) {
        var args = [arg];
        assertArgsWithEvaluator(calledWithArgs, args, _.some);
    }

    function withMatch(pattern) {
        debug(calledWithArgs);
        var matched = false;
        _.forEach(calledWithArgs, function(args) {
            if (matched) {
                return;
            }
            _.forEach(_.values(args), function(arg) {
                if (matched) {
                    return;
                }
                if (_.isObject(arg)) {
                    matched = objectPatternMatchProperties(arg, pattern);
                    debug('is object match?', matched, arg, pattern);
                    return;
                }
                matched = pattern.test(arg);
                debug('is match?', matched, arg, pattern);
            });
        });
        if (!matched) {
            assert.fail(calledWithArgs, pattern, 'Expected ' + method + ' to be called matching: ' + pattern);
        }
    }

    function matchExactly() {
        var expectedArgs = _.values(arguments);
        var matched = true;
        _.forEach(calledWithArgs, function(args) {
            _.forEach(_.values(args), function(arg, i) {
                if (!_.isEqual(arg, expectedArgs[i])) {
                    matched = false;
                    debug('is object match?', matched, arg, expectedArgs[i]);
                    return;
                }
                debug('is match?', matched, arg, expectedArgs[i]);
            });
        });
        if (!matched) {
            assert.fail(calledWithArgs, expectedArgs, 'Expected ' + method + ' to be called matchExactly args' + require('util').inspect(expectedArgs, {
                depth: 10
            }));
        }
    }

    function objectPatternMatchProperties(obj, pattern) {
        var matched = false;
        _.deepMapValues(obj, function(i) {
            if (!matched) {
                matched = pattern.test(i);
            }
            debug(i, matched);
        });
        return matched;
    }

    function assertArgsWithEvaluator(argsToCheck, args, evaluator) {
        var callResults = [];
        _.forEach(argsToCheck, function(value) {
            debug('checking', value, args);
            var argResult = checkArgs(args, value, evaluator);
            callResults.push(argResult);
        });
        var result = _.some(callResults);
        assert(result, 'Expected ' + method + ' to be called with: ' + args.join(', '));
    }

    function withArg(args) {
        return function(arg) {
            assert(checkAnyArgs([arg], args));
        };
    }

    function times(number, err) {
        if (!err) {
            err = 'Expected ' + method + ' to be called ' + utils.humanise(number) + ' but was ' + timesCalled;
        }
        assert.equal(timesCalled, number, err);
    }

    function calledLteGte(number, predicate, friendly, err) {
        if (!err) {
            err = 'Expected ' + method + ' to be called ' + friendly + ' ' + utils.humanise(number) + ' but was ' + timesCalled;
        }
        assert.ok(predicate(timesCalled, number), err);
    }

    function calledLt(number, err) {
        calledLteGte(number, _.lt, 'less than', err);
    }

    function calledLte(number, err) {
        calledLteGte(number, _.lte, 'less than or equal to', err);
    }

    function calledGt(number, err) {
        calledLteGte(number, _.gt, 'greater than', err);
    }

    function calledGte(number, err) {
        calledLteGte(number, _.gte, 'greater than or equal to', err);
    }

    function never(err) {
        times(0, err);
    }

    function calledOnce(err) {
        times(1, err);
    }

    function calledTwice(err) {
        times(2, err);
    }

    function reset() {
        timesCalled = 0;
        calledWithArgs = {};
    }

    function addNotMethods(obj) {
        function negate(func) {
            return function() {
                var args = _.values(arguments);
                try {
                    func.call(null, args);
                } catch (err) {
                    return self;
                }
                assert(false);
            };
        }

        var methods = {};
        var calledMethods = _.omit(utils.methods(obj.called), 'reset');
        _.forEach(calledMethods, function(method) {
            methods[method] = negate(obj.called[method]);
        });
        obj.called.not = methods;
        return obj;
    }

    self.called = {
        times: times,
        never: never,
        once: calledOnce,
        twice: calledTwice,
        lt: calledLt,
        lte: calledLte,
        gt: calledGt,
        gte: calledGte,
        reset: reset,
        matchExactly: matchExactly,
        withArgs: withArgs,
        withArg: withSingleArg,
        withMatch: withMatch
    };

    return (function() {
        return Object.freeze(addNotMethods(self));
    }());
}
242048
function createContext(req, res, context, done) {
  debug('default createContext - does nothing', context);
  process.nextTick(done.bind(null, null, context));
}
627178
function buildItem(parentAttrNode, row, context) {
    const item = {};

    if (context.primaryKey === null) resolvePrimaryKey(row, context);

    Object.keys(parentAttrNode.attributes).forEach(attrName => {
        const attrNode = parentAttrNode.attributes[attrName];

        if (context.selectedInternalLevel > 0) {
            if (!attrNode.selectedInternal) return;
            if (!attrNode.selectedInternal[context.selectedInternalLevel - 1]) return;
        } else if (!attrNode.selected) return;

        if (attrNode.attributes) {
            const subContext = Object.assign({}, context);
            subContext.attrPath = context.attrPath.concat([attrName]);

            if (attrNode.dataSources) {
                // resource context:
                subContext.resourceAttrNode = attrNode;
                subContext.primaryKey = null;
                subContext.secondaryRows = null;

                let rawResult;
                let keys;
                let keyIsNull = true;
                let parentKeyRow = row;

                if (
                    attrNode.parentDataSource &&
                    attrNode.parentDataSource !== context.resourceAttrNode.primaryDataSource
                ) {
                    parentKeyRow = context.secondaryRows[attrNode.parentDataSource];
                }

                if (parentKeyRow) {
                    rawResult = getResult(attrNode, attrNode.joinVia || attrNode.primaryDataSource, subContext);
                    keys = rawResult.parentKey.map(keyAttr => {
                        if (typeof parentKeyRow[keyAttr] === 'undefined') {
                            /*
                            // TODO: Strict mode?
                            throw new DataError(`Sub-resource "${subContext.attrPath.join('.')}" ` +
                                misses keyattribute "${keyAttr}" in parent result ` +
                                `(DataSource "${context.resourceAttrNode.primaryDataSource}")`);
                            */
                        } else if (parentKeyRow[keyAttr] !== null) {
                            keyIsNull = false;
                        }
                        return parentKeyRow[keyAttr];
                    });
                }

                if (keyIsNull) {
                    keys = [];
                } else if (!rawResult.multiValuedParentKey) {
                    // normal and composite parentKey: "keys" is a string (as array) afterwards:
                    keys = [keys.join(keySeparator)];
                } else {
                    // dereference parentKey array (key length must be 1 when multiValued)
                    // but "keys" is still an array (multiValued) afterwards:
                    keys = keys[0];

                    if (!Array.isArray(keys)) {
                        throw new DataError(
                            `Sub-resource "${subContext.attrPath.join('.')}" ` +
                                `multiValued key attribute "${rawResult.parentKey[0]}" ` +
                                'in parent result is not an array ' +
                                `(DataSource "${context.resourceAttrNode.primaryDataSource}")`
                        );
                    }
                }

                let secondaryRows = null;
                if (attrNode.joinVia) {
                    let primaryRawResult = null; // set on demand to avoid errors for empty results
                    const joinViaKeys = [];
                    secondaryRows = {};

                    keys.forEach(key => {
                        let joinViaRows = rawResult.indexedData[key];
                        if (!joinViaRows) return;

                        if (rawResult.uniqueChildKey) joinViaRows = [joinViaRows];

                        joinViaRows.forEach(joinViaRow => {
                            primaryRawResult =
                                primaryRawResult || getResult(attrNode, attrNode.primaryDataSource, subContext);

                            let childKeyIsNull = true;
                            const childKey = primaryRawResult.parentKey
                                .map(keyAttr => {
                                    if (typeof joinViaRow[keyAttr] === 'undefined') {
                                        throw new DataError(
                                            `Sub-resource "${subContext.attrPath.join('.')}" ` +
                                                `misses key attribute "${keyAttr}" in joinVia result ` +
                                                `(DataSource "${attrNode.joinVia}")`
                                        );
                                    } else if (joinViaRow[keyAttr] !== null) {
                                        childKeyIsNull = false;
                                    }
                                    return joinViaRow[keyAttr];
                                })
                                .join(keySeparator);

                            if (!childKeyIsNull) {
                                joinViaKeys.push(childKey);

                                secondaryRows[childKey] = {};
                                secondaryRows[childKey][attrNode.joinVia] = joinViaRow;
                            }
                        });
                    });

                    rawResult = primaryRawResult;
                    keys = joinViaKeys;
                }

                const subItem = [];
                keys.forEach(key => {
                    const subRow = rawResult.indexedData[key];
                    if (!subRow) {
                        // ignore
                    } else {
                        subContext.secondaryRows = secondaryRows ? secondaryRows[key] : null;

                        if (!rawResult.uniqueChildKey) {
                            subRow.forEach(singleSubRow => subItem.push(buildItem(attrNode, singleSubRow, subContext)));
                        } else {
                            subItem.push(buildItem(attrNode, subRow, subContext));
                        }
                    }
                });

                item[attrName] = attrNode.many ? subItem : subItem[0] || null;
            } else {
                // nested-attribute context:
                item[attrName] = buildItem(attrNode, row, subContext);
            }
        } else {
            item[attrName] = buildAttribute(attrNode, row, context);
        }
    });

    // Extension: "item"
    if (parentAttrNode.resourceName) {
        const resource = context.api.getResource(parentAttrNode.resourceName);
        if (resource && resource.extensions && resource.extensions.item) {
            resource.extensions.item({
                item,
                row,
                secondaryRows: context.secondaryRows,
                request: context.request,
                getAttribute: attribute => getAttribute(attribute || [], parentAttrNode),
                getResult: (attrNode, dataSourceName) =>
                    getResult(
                        attrNode || parentAttrNode,
                        dataSourceName || (attrNode || parentAttrNode).primaryDataSource,
                        context
                    ),
                buildItem: attributes => {
                    const maxRecursionLevel = 20;

                    function selectInternal(level, isSelected) {
                        attributes.forEach(attribute => {
                            let attrNode = parentAttrNode;
                            attribute.forEach(attrName => {
                                if (!(attrNode.attributes && attrNode.attributes[attrName])) {
                                    let attrStr = attribute.join('.');
                                    throw new ImplementationError(
                                        `item-extension/buildItem: Unknown attribute "${attrStr}"`
                                    );
                                }
                                attrNode = attrNode.attributes[attrName];

                                if (!attrNode.selectedInternal) {
                                    // we use a flag per recursion level to handle recursive buildItem calls independently
                                    attrNode.selectedInternal = new Array(maxRecursionLevel).fill(false);
                                }
                                attrNode.selectedInternal[level - 1] = isSelected;
                            });
                        });
                    }

                    const subContext = Object.assign({}, context);
                    subContext.selectedInternalLevel++;

                    if (subContext.selectedInternalLevel > maxRecursionLevel) {
                        let attrStr = attributes.map(attribute => attribute.join('.')).join(',');
                        throw new ImplementationError(
                            `item-extension/buildItem: Recursion depth for "${attrStr}" too big`
                        );
                    }

                    selectInternal(subContext.selectedInternalLevel, true);
                    const internalItem = buildItem(parentAttrNode, row, subContext);
                    selectInternal(subContext.selectedInternalLevel, false);

                    return internalItem;
                }
            });
        }
    }

    context.primaryKey = null; // clear primaryKey cache for next row

    return item;
}
200551
function bindCallback(callbackFunc, resultSelector, scheduler) {
    if (resultSelector) {
        if (Object(_util_isScheduler__WEBPACK_IMPORTED_MODULE_4__["isScheduler"])(resultSelector)) {
            scheduler = resultSelector;
        }
        else {
            return function () {
                var args = [];
                for (var _i = 0; _i < arguments.length; _i++) {
                    args[_i] = arguments[_i];
                }
                return bindCallback(callbackFunc, scheduler).apply(void 0, args).pipe(Object(_operators_map__WEBPACK_IMPORTED_MODULE_2__["map"])(function (args) { return Object(_util_isArray__WEBPACK_IMPORTED_MODULE_3__["isArray"])(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
            };
        }
    }
    return function () {
        var args = [];
        for (var _i = 0; _i < arguments.length; _i++) {
            args[_i] = arguments[_i];
        }
        var context = this;
        var subject;
        var params = {
            context: context,
            subject: subject,
            callbackFunc: callbackFunc,
            scheduler: scheduler,
        };
        return new _Observable__WEBPACK_IMPORTED_MODULE_0__["Observable"](function (subscriber) {
            if (!scheduler) {
                if (!subject) {
                    subject = new _AsyncSubject__WEBPACK_IMPORTED_MODULE_1__["AsyncSubject"]();
                    var handler = function () {
                        var innerArgs = [];
                        for (var _i = 0; _i < arguments.length; _i++) {
                            innerArgs[_i] = arguments[_i];
                        }
                        subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
                        subject.complete();
                    };
                    try {
                        callbackFunc.apply(context, args.concat([handler]));
                    }
                    catch (err) {
                        subject.error(err);
                    }
                }
                return subject.subscribe(subscriber);
            }
            else {
                var state = {
                    args: args, subscriber: subscriber, params: params,
                };
                return scheduler.schedule(dispatch, 0, state);
            }
        });
    };
}
1089902
function preprocessRawResults(rawResults, resolvedConfig) {
    rawResults.forEach((rawResult, resultId) => {
        if (!rawResult.attributePath) return; // e.g. sub-filter results don't need indexing

        // link resultIds into attribute tree (per DataSource):
        const attrNode = getAttribute(rawResult.attributePath, resolvedConfig);
        attrNode.dataSources[rawResult.dataSourceName].resultId = resultId;

        // index rows by childKey if available
        // (top-level result has no childKey and does not need to be indexed):
        if (rawResult.childKey) {
            const keyAttr = rawResult.childKey.length === 1 ? rawResult.childKey[0] : null;
            rawResult.indexedData = {};
            rawResult.data.forEach((row, i) => {
                function dereferenceKeyAttr(keyAttrib) {
                    const keyVal = row[keyAttrib];
                    if (keyVal === undefined) {
                        const attrPath =
                            rawResult.attributePath.length > 0 ? rawResult.attributePath.join('.') : '{root}';
                        throw new DataError(
                            `Result-row ${i} of "${attrPath}" (DataSource "${
                                rawResult.dataSourceName
                            }") misses child key attribute "${keyAttr}"`
                        );
                    }
                    return keyVal;
                }

                const key = keyAttr
                    ? '' + dereferenceKeyAttr(keyAttr) // speed up non-composite keys
                    : rawResult.childKey.map(dereferenceKeyAttr).join(keySeparator);

                if (!rawResult.uniqueChildKey) {
                    if (!rawResult.indexedData[key]) rawResult.indexedData[key] = [];
                    rawResult.indexedData[key].push(row);
                } else {
                    if (rawResult.indexedData[key]) {
                        const attrPath =
                            rawResult.attributePath.length > 0 ? rawResult.attributePath.join('.') : '{root}';
                        throw new DataError(
                            `Result-row ${i} of "${attrPath}" (DataSource "${
                                rawResult.dataSourceName
                            }") has duplicate child key "${key}"`
                        );
                    }
                    rawResult.indexedData[key] = row;
                }
            });
        }
    });
}
667059
function resolve(p, context) {
  try {
    return relative( p
                   , context.getFilename()
                   , context.settings
                   )
  } catch (err) {
    if (!erroredContexts.has(context)) {
      context.report({
        message: `Resolve error: ${err.message}`,
        loc: { line: 1, column: 0 },
      })
      erroredContexts.add(context)
    }
  }
}