import { memo } from 'react';
import { Handle, Position, type NodeProps } from '@xyflow/react';
import { Cloud } from 'lucide-react';

export const ExternalNode = memo(({ data, selected }: NodeProps) => {
  const label = (data as { label?: string }).label ?? 'External';
  return (
    <div className={`min-w-[140px] bg-slate-800 border-2 border-dashed rounded-lg shadow-lg ${selected ? 'ring-2 ring-slate-400 border-slate-400' : 'border-slate-500'}`}>
      <Handle type="target" position={Position.Top} className="!bg-slate-400 !border-slate-600" />
      <div className="px-3 py-2 flex items-center gap-2">
        <Cloud size={13} className="text-slate-400 shrink-0" />
        <span className="text-xs font-medium text-slate-300 truncate">{label}</span>
      </div>
      <Handle type="source" position={Position.Bottom} className="!bg-slate-400 !border-slate-600" />
    </div>
  );
});
ExternalNode.displayName = 'ExternalNode';
