"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.formatOffsetDetectionStepValue = exports.offsetDetectionSteps = void 0;
/**
 * Template describing the ordered offset detection steps and their initial state.
 *
 * This array serves as the baseline structure for reporting progress during the
 * offset detection procedure. It is typically cloned and mutated as the procedure
 * executes, with each step transitioning through statuses such as:
 * - 'idle'
 * - 'running'
 * - 'succeeded'
 * - 'failed'
 *
 * The structure and order of this array define:
 * - The sequence in which diagnostic steps are executed
 * - The shape of progress updates emitted during the procedure
 *
 * Consumers should treat this array as immutable and use a cloned copy when
 * tracking or displaying runtime progress.
 */
exports.offsetDetectionSteps = [
    {
        id: 'openPhaseDetection',
        label: 'Open Phase Detection',
        status: 'idle',
    },
    {
        id: 'phaseResistanceMeasurement',
        label: 'Phase Resistance Measurement',
        status: 'idle',
    },
    {
        id: 'phaseInductanceMeasurement',
        label: 'Phase Inductance Measurement',
        status: 'idle',
    },
    {
        id: 'polePairDetection',
        label: 'Pole Pair Detection',
        status: 'idle',
    },
    {
        id: 'motorPhaseOrderDetection',
        label: 'Motor Phase Order Detection',
        status: 'idle',
    },
    {
        id: 'commutationOffsetMeasurement',
        label: 'Commutation Offset Measurement',
        status: 'idle',
    },
];
/**
 * Formats the value associated with a specific offset detection step.
 *
 * Depending on the provided `stepId`, this function will convert the raw `value` into a human-readable string
 * or return the value as-is. The formatting is tailored to the type of step:
 * - For 'openPhaseDetection', returns 'Yes' or 'No' based on the truthiness of `value`.
 * - For 'phaseResistanceMeasurement', appends 'mΩ' to the value if defined.
 * - For 'phaseInductanceMeasurement', appends 'μH' to the value if defined.
 * - For 'polePairDetection', returns the value directly.
 * - For 'motorPhaseOrderDetection', returns 'Normal' or 'Inverted' based on the value.
 * - For 'commutationOffsetMeasurement', returns the value if defined.
 * - For any other step, returns the value as-is.
 *
 * @param stepId - The identifier of the offset detection step.
 * @param value - The value to be parsed and formatted.
 * @returns The formatted value as a string or the original value, depending on the step.
 */
function formatOffsetDetectionStepValue(stepId, value) {
    var _a;
    switch (stepId) {
        case 'openPhaseDetection': {
            return value ? 'Yes' : 'No';
        }
        case 'phaseResistanceMeasurement': {
            return typeof value !== 'undefined' ? `${value} mΩ` : '';
        }
        case 'phaseInductanceMeasurement': {
            return typeof value !== 'undefined' ? `${value} μH` : '';
        }
        case 'polePairDetection': {
            return value;
        }
        case 'motorPhaseOrderDetection': {
            const phases = ['Normal', 'Inverted'];
            return (_a = phases[value]) !== null && _a !== void 0 ? _a : '';
        }
        case 'commutationOffsetMeasurement': {
            return typeof value !== 'undefined' ? value : '';
        }
        default: {
            return value;
        }
    }
}
exports.formatOffsetDetectionStepValue = formatOffsetDetectionStepValue;
//# sourceMappingURL=offset-detection.js.map