import { loadWorkflowFromFile, loadWorkflowFromFileForDiscovery } from './workflowFileLoader.js';
import { resolveWorkflowTrustInfo, } from './workflowTrustSource.js';
function buildWorkflowCallArgPolicy(parentTrustInfo, childTrustInfo) {
    if (!parentTrustInfo || parentTrustInfo.isProjectTrustRoot || !childTrustInfo.isProjectTrustRoot) {
        return undefined;
    }
    return {
        allowExternalFacetRefs: false,
    };
}
export function loadWorkflowFileWithResolutionOptions(filePath, options) {
    const trustInfo = resolveWorkflowTrustInfo({
        filePath,
        projectCwd: options.projectCwd,
        lookupCwd: options.lookupCwd,
        source: options.source,
    });
    const loadWorkflow = options.loadMode === 'discovery'
        ? loadWorkflowFromFileForDiscovery
        : loadWorkflowFromFile;
    const workflow = loadWorkflow(filePath, options.projectCwd, {
        trustInfo,
        callableArgs: options.callableArgs,
        callableArgPolicy: buildWorkflowCallArgPolicy(options.parentTrustInfo, trustInfo),
    });
    return workflow;
}
//# sourceMappingURL=workflowResolvedLoader.js.map