import { InterfaceTypes, runPipelineNode } from 'itk-wasm';
import path from 'path';
/**
 * Read the tags from a DICOM file
 *
 * @param {string} dicomFile - Input DICOM file.
 * @param {ReadDicomTagsOptions} options - options object
 *
 * @returns {Promise<ReadDicomTagsNodeResult>} - result object
 */
async function readDicomTagsNode(dicomFile, options = {}) {
    const mountDirs = new Set();
    const desiredOutputs = [
        { type: InterfaceTypes.JsonCompatible },
    ];
    mountDirs.add(path.dirname(dicomFile));
    const inputs = [];
    const args = [];
    // Inputs
    const dicomFileName = dicomFile;
    args.push(dicomFileName);
    // Outputs
    const tagsName = '0';
    args.push(tagsName);
    // Options
    args.push('--memory-io');
    if (typeof options.tagsToRead !== "undefined") {
        const inputCountString = inputs.length.toString();
        inputs.push({ type: InterfaceTypes.JsonCompatible, data: options.tagsToRead });
        args.push('--tags-to-read', inputCountString);
    }
    const pipelinePath = path.join(path.dirname(import.meta.url.substring(7)), 'pipelines', 'read-dicom-tags');
    const { returnValue, stderr, outputs } = await runPipelineNode(pipelinePath, args, desiredOutputs, inputs, mountDirs);
    if (returnValue !== 0) {
        throw new Error(stderr);
    }
    const result = {
        tags: outputs[0].data,
    };
    return result;
}
export default readDicomTagsNode;
//# sourceMappingURL=read-dicom-tags-node.js.map