"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertionRuntimeExtras = assertionRuntimeExtras;
exports.buildMetricKey = buildMetricKey;
exports.componentMetricFields = componentMetricFields;
exports.syntheticMetricKeysFromTestCase = syntheticMetricKeysFromTestCase;
function assertionRuntimeExtras(assertion) {
    if (assertion == null) {
        return undefined;
    }
    return assertion;
}
function buildMetricKey(assertion) {
    if (!assertion) {
        return null;
    }
    const label = assertion.displayLabel?.trim();
    if (label) {
        return label;
    }
    const type = assertion.type?.trim();
    return type || null;
}
function componentMetricFields(component) {
    const assertion = assertionRuntimeExtras(component.assertion);
    const assertionType = component.assertion?.type?.trim() || null;
    const assertionDisplayLabel = assertion?.displayLabel?.trim() || null;
    const metricKey = buildMetricKey(component.assertion ?? undefined);
    return { assertionType, assertionDisplayLabel, metricKey };
}
/** Assert types from test_case when failure_reason = ERROR (infra). */
function syntheticMetricKeysFromTestCase(testCase) {
    if (!testCase) {
        return [];
    }
    const asserts = testCase.assert;
    if (!Array.isArray(asserts)) {
        return [];
    }
    const keys = [];
    for (const item of asserts) {
        if (item && typeof item === 'object' && 'type' in item) {
            const type = String(item.type ?? '').trim();
            if (type) {
                keys.push(type);
            }
        }
    }
    return [...new Set(keys)];
}
//# sourceMappingURL=metricIdentity.js.map