import { WorkflowExecutionMode, WorkflowNodeType, WorkflowResumeStrategy, } from './generated/runtime/v1/workflow.js';
function createNode(base, nodeType, typeConfig) {
    return {
        nodeId: String(base.nodeId || '').trim(),
        nodeType,
        dependsOn: [...(base.dependsOn || [])],
        typeConfig,
        retryMaxAttempts: Number(base.retryMaxAttempts || 0),
        retryBackoff: String(base.retryBackoff || '').trim(),
        executionMode: base.executionMode ?? WorkflowExecutionMode.INLINE,
        resumeStrategy: base.resumeStrategy ?? WorkflowResumeStrategy.AUTO,
        callbackRef: String(base.callbackRef || '').trim(),
    };
}
export function workflowEdge(input) {
    return {
        fromNodeId: String(input.fromNodeId || '').trim(),
        fromOutput: String(input.fromOutput || '').trim(),
        toNodeId: String(input.toNodeId || '').trim(),
        toInput: String(input.toInput || '').trim(),
    };
}
export function workflowDefinition(input) {
    return {
        workflowType: String(input.workflowType || '').trim(),
        nodes: [...input.nodes],
        edges: [...(input.edges || [])],
    };
}
export function aiGenerateNode(input) {
    return createNode(input, WorkflowNodeType.WORKFLOW_NODE_AI_GENERATE, {
        oneofKind: 'aiGenerateConfig',
        aiGenerateConfig: input.config,
    });
}
export function aiStreamNode(input) {
    return createNode(input, WorkflowNodeType.WORKFLOW_NODE_AI_STREAM, {
        oneofKind: 'aiStreamConfig',
        aiStreamConfig: input.config,
    });
}
export function aiEmbedNode(input) {
    return createNode(input, WorkflowNodeType.WORKFLOW_NODE_AI_EMBED, {
        oneofKind: 'aiEmbedConfig',
        aiEmbedConfig: input.config,
    });
}
export function aiImageNode(input) {
    return createNode(input, WorkflowNodeType.WORKFLOW_NODE_AI_IMAGE, {
        oneofKind: 'aiImageConfig',
        aiImageConfig: input.config,
    });
}
export function aiVideoNode(input) {
    return createNode(input, WorkflowNodeType.WORKFLOW_NODE_AI_VIDEO, {
        oneofKind: 'aiVideoConfig',
        aiVideoConfig: input.config,
    });
}
export function aiTtsNode(input) {
    return createNode(input, WorkflowNodeType.WORKFLOW_NODE_AI_TTS, {
        oneofKind: 'aiTtsConfig',
        aiTtsConfig: input.config,
    });
}
export function aiSttNode(input) {
    return createNode(input, WorkflowNodeType.WORKFLOW_NODE_AI_STT, {
        oneofKind: 'aiSttConfig',
        aiSttConfig: input.config,
    });
}
export function extractNode(input) {
    return createNode(input, WorkflowNodeType.WORKFLOW_NODE_TRANSFORM_EXTRACT, {
        oneofKind: 'extractConfig',
        extractConfig: input.config,
    });
}
export function templateNode(input) {
    return createNode(input, WorkflowNodeType.WORKFLOW_NODE_TRANSFORM_TEMPLATE, {
        oneofKind: 'templateConfig',
        templateConfig: input.config,
    });
}
export function scriptNode(input) {
    return createNode(input, WorkflowNodeType.WORKFLOW_NODE_TRANSFORM_SCRIPT, {
        oneofKind: 'scriptConfig',
        scriptConfig: input.config,
    });
}
export function branchNode(input) {
    return createNode(input, WorkflowNodeType.WORKFLOW_NODE_CONTROL_BRANCH, {
        oneofKind: 'branchConfig',
        branchConfig: input.config,
    });
}
export function mergeNode(input) {
    return createNode(input, WorkflowNodeType.WORKFLOW_NODE_CONTROL_MERGE, {
        oneofKind: 'mergeConfig',
        mergeConfig: input.config,
    });
}
export function noopNode(input) {
    return createNode(input, WorkflowNodeType.WORKFLOW_NODE_CONTROL_NOOP, {
        oneofKind: 'noopConfig',
        noopConfig: input.config || {},
    });
}
//# sourceMappingURL=workflow-builder.js.map