export class EdgeView{constructor(data,type){const{edgeId,sourcePortId,destinationPortId}=generateEdgePortIdsByData(data,type);this.id=edgeId;this.type=type;this.sourceId=data.sourceId;this.destinationId=data.destinationId;this.sourcePortId=sourcePortId;this.destinationPortId=destinationPortId;}}
export const generateEdgePortIdsByData=(data,type)=>{if(!data.sourceId||!data.destinationId){console.error(`Undefined node message: ${JSON.stringify(data)}`);return null;}
const sourcePortId=WebAudio.GraphVisualizer.generateOutputPortId(data.sourceId,data.sourceOutputIndex);const destinationPortId=getDestinationPortId(data,type);return{edgeId:`${sourcePortId}->${destinationPortId}`,sourcePortId:sourcePortId,destinationPortId:destinationPortId,};function getDestinationPortId(data,type){if(type===EdgeTypes.NodeToNode){return WebAudio.GraphVisualizer.generateInputPortId(data.destinationId,data.destinationInputIndex);}else if(type===EdgeTypes.NodeToParam){return WebAudio.GraphVisualizer.generateParamPortId(data.destinationId,data.destinationParamId);}else{console.error(`Unknown edge type: ${type}`);return'';}}};export const EdgeTypes={NodeToNode:Symbol('NodeToNode'),NodeToParam:Symbol('NodeToParam'),};self.WebAudio=self.WebAudio||{};WebAudio=WebAudio||{};WebAudio.GraphVisualizer=WebAudio.GraphVisualizer||{};WebAudio.GraphVisualizer.EdgeView=EdgeView;WebAudio.GraphVisualizer.generateEdgePortIdsByData=generateEdgePortIdsByData;WebAudio.GraphVisualizer.EdgeTypes=EdgeTypes;