import { Handle, Position } from "@xyflow/react";
import type { NodeProps } from "@xyflow/react";
import type { DiagramNode } from "../graph";
import { HIDDEN_HANDLE } from "../architecture/constants";

export function FlowIoNode({ data }: NodeProps) {
  const d = data as unknown as DiagramNode & { label: string };

  return (
    <div className="flow-io">
      <div
        className="flow-io-skew"
        style={d.color ? { borderColor: d.color } : undefined}
      >
        <span className="flow-node-label">{d.label}</span>
      </div>
      <Handle type="target" position={Position.Top} style={HIDDEN_HANDLE} />
      <Handle
        type="target"
        position={Position.Left}
        id="left"
        style={HIDDEN_HANDLE}
      />
      <Handle
        type="source"
        position={Position.Bottom}
        style={HIDDEN_HANDLE}
      />
      <Handle
        type="source"
        position={Position.Right}
        id="right"
        style={HIDDEN_HANDLE}
      />
    </div>
  );
}
