/**
 * Export Node Component
 *
 * Node for exporting workflow results to various formats.
 */

import React, { memo } from 'react';
import { Handle, Position, NodeProps } from '@xyflow/react';
import type { ExportNodeData } from '../../../lib/workflow-builder/types';

export const ExportNode = memo(({ data, selected }: NodeProps<ExportNodeData>) => {
  const formatLabels: Record<string, string> = {
    pptx: 'PowerPoint',
    html: 'HTML',
    pdf: 'PDF',
    markdown: 'Markdown',
    json: 'JSON',
  };

  return (
    <div
      className={`
        px-4 py-3 rounded-lg border-2 min-w-[180px]
        bg-blue-50 border-blue-300
        ${selected ? 'border-blue-500 shadow-lg shadow-blue-200' : ''}
      `}
    >
      {/* Input Handle */}
      <Handle
        type="target"
        position={Position.Left}
        className="w-3 h-3 bg-blue-400 border-2 border-white"
      />

      {/* Output Handle */}
      <Handle
        type="source"
        position={Position.Right}
        className="w-3 h-3 bg-blue-500 border-2 border-white"
      />

      {/* Header */}
      <div className="flex items-center gap-2 mb-2">
        <span className="text-lg">📤</span>
        <span className="font-medium text-blue-800">{data.label}</span>
      </div>

      {/* Formats */}
      <div className="flex flex-wrap gap-1">
        {data.formats.map((format) => (
          <span
            key={format}
            className="text-xs bg-blue-100 text-blue-700 px-2 py-0.5 rounded"
          >
            {formatLabels[format] || format}
          </span>
        ))}
      </div>

      {/* Output Directory */}
      {data.outputDir && (
        <div className="text-xs text-blue-500 mt-2 truncate">
          📁 {data.outputDir}
        </div>
      )}
    </div>
  );
});

ExportNode.displayName = 'ExportNode';

export default ExportNode;
