"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.transformGraphicModelToStedModel = void 0;
function transform(graphicNodes, equipment) {
    const { type, refid } = equipment;
    const links = graphicNodes.filter(node => {
        const { from, to } = node;
        return from && to && from.component && to.component && (from.component === refid || to.component === refid);
    });
    const outlets = links
        .filter(link => link.from.component === refid)
        .map(link => {
        const { refid, streamType = 'fluid' } = link;
        const { component, anchor } = link.to;
        return {
            name: refid,
            type: streamType,
            kind: link.from.anchor,
            dstNode: component,
            dstEdge: anchor
        };
    });
    const inlets = links
        .filter(link => link.to.component === refid)
        .map(link => {
        const { refid, streamType = 'fluid' } = link;
        const { component, anchor } = link.from;
        return {
            name: refid,
            type: streamType,
            kind: link.to.anchor,
            srcNode: component,
            srcEdge: anchor
        };
    });
    return {
        type,
        name: String(refid),
        params: Object.assign({}, equipment),
        inlets,
        outlets
    };
}
function transformGraphicModelToStedModel(graphicModel) {
    var graphicNodes = graphicModel.components || [];
    return {
        stedNodes: graphicNodes.filter(node => node.equipment).map(node => transform(graphicNodes, node))
    };
}
exports.transformGraphicModelToStedModel = transformGraphicModelToStedModel;
//# sourceMappingURL=transformer.js.map