import _ from 'lodash';
import '../../../../globals.js';
// Copyright 2023-2024, University of Colorado Boulder
/**
 * TODO: doc
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import { alpenglow, BufferSlot } from '../../imports.js';
export default class Module {
    constructor(pipelineBlueprints, execute) {
        this.pipelineBlueprints = pipelineBlueprints;
        this.execute = execute;
    }
    getResourceSlots() {
        const resourceSlots = new Set();
        for (const pipelineBlueprint of this.pipelineBlueprints) {
            for (const usage of pipelineBlueprint.usages) {
                resourceSlots.add(usage.resourceSlot);
            }
        }
        return Array.from(resourceSlots);
    }
    getTopLevelResourceSlots(sharedBufferSlots) {
        const slots = _.uniq([
            ...this.getResourceSlots(),
            ...sharedBufferSlots
        ]);
        const nonBufferSlots = slots.filter(slot => !(slot instanceof BufferSlot));
        const bufferSlots = slots.filter(slot => slot instanceof BufferSlot);
        return [
            ...nonBufferSlots,
            ...bufferSlots.filter(slot => {
                return !bufferSlots.some(otherSlot => otherSlot.hasChildSlot(slot));
            })
        ];
    }
}
alpenglow.register('Module', Module);
//# sourceMappingURL=Module.js.map