// Generated file. To retain edits, remove this comment.
import { InterfaceTypes, runPipeline } from 'itk-wasm';
import { getPipelinesBaseUrl } from './pipelines-base-url.js';
import { getPipelineWorkerUrl } from './pipeline-worker-url.js';
import { getDefaultWebWorker } from './default-web-worker.js';
/**
 * Read DICOM segmentation object with overlapping segments into a VectorImage.
 *
 * @param {File | BinaryFile} dicomFile - Input DICOM file
 * @param {ReadOverlappingSegmentationOptions} options - options object
 *
 * @returns {Promise<ReadOverlappingSegmentationResult>} - result object
 */
async function readOverlappingSegmentation(dicomFile, options = {}) {
    const desiredOutputs = [
        { type: InterfaceTypes.Image },
        { type: InterfaceTypes.JsonCompatible },
    ];
    let dicomFileFile = dicomFile;
    if (dicomFile instanceof File) {
        const dicomFileBuffer = await dicomFile.arrayBuffer();
        dicomFileFile = { path: dicomFile.name, data: new Uint8Array(dicomFileBuffer) };
    }
    const inputs = [
        { type: InterfaceTypes.BinaryFile, data: dicomFileFile },
    ];
    const args = [];
    // Inputs
    const dicomFileName = dicomFileFile.path;
    args.push(dicomFileName);
    // Outputs
    const segImageName = '0';
    args.push(segImageName);
    const metaInfoName = '1';
    args.push(metaInfoName);
    // Options
    args.push('--memory-io');
    if (options.mergeSegments) {
        options.mergeSegments && args.push('--merge-segments');
    }
    const pipelinePath = 'read-overlapping-segmentation';
    let workerToUse = options?.webWorker;
    if (workerToUse === undefined) {
        workerToUse = await getDefaultWebWorker();
    }
    const { webWorker: usedWebWorker, returnValue, stderr, outputs } = await runPipeline(pipelinePath, args, desiredOutputs, inputs, { pipelineBaseUrl: getPipelinesBaseUrl(), pipelineWorkerUrl: getPipelineWorkerUrl(), webWorker: workerToUse, noCopy: options?.noCopy });
    if (returnValue !== 0 && stderr !== "") {
        throw new Error(stderr);
    }
    const result = {
        webWorker: usedWebWorker,
        segImage: outputs[0]?.data,
        metaInfo: outputs[1]?.data,
    };
    return result;
}
export default readOverlappingSegmentation;
//# sourceMappingURL=read-overlapping-segmentation.js.map