"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildWorkflowHierarchicalStateFields = buildWorkflowHierarchicalStateFields;
function buildWorkflowHierarchicalStateFields(input) {
    const fields = {};
    const parentLink = input.overrides?.parentLink ?? input.previousState?.parentLink;
    if (parentLink !== undefined) {
        fields.parentLink = parentLink;
    }
    const originLink = input.overrides?.originLink ?? input.previousState?.originLink;
    if (originLink !== undefined) {
        fields.originLink = originLink;
    }
    if (input.previousState !== null) {
        fields.executionContract = input.previousState.executionContract;
        if (input.previousState.parentContractRevision !== undefined) {
            fields.parentContractRevision =
                input.previousState.parentContractRevision;
        }
        if (input.previousState.parentStepContractSnapshot !== undefined) {
            fields.parentStepContractSnapshot =
                input.previousState.parentStepContractSnapshot;
        }
        if (input.previousState.detachedFromParentReason !== undefined) {
            fields.detachedFromParentReason =
                input.previousState.detachedFromParentReason;
        }
        if (input.previousState.cancelledChildReason !== undefined) {
            fields.cancelledChildReason = input.previousState.cancelledChildReason;
        }
    }
    return fields;
}
