import React, { useMemo } from 'react';
import { FileText } from 'lucide-react-native';

import type { SuperagentToolRendererProps } from '../../types';
import { ToolWidgetRow } from '../primitives/ToolWidgetRow';
import { getToolFilePath, getWidgetStatus, humanizeFilePath, parseToolArgs } from '../toolWidgetUtils';

// read_file — native port of the web ReadFile row (no detail body, same as the web).
export function ReadFileWidget({ toolCall }: SuperagentToolRendererProps) {
  const args = useMemo(() => parseToolArgs(toolCall), [toolCall]);
  const status = getWidgetStatus(toolCall.status);
  const humanPath = humanizeFilePath(getToolFilePath(args));

  return (
    <ToolWidgetRow
      chipText={humanPath}
      icon={FileText}
      status={status}
      title={status === 'running' ? 'Reading' : 'Read'}
    />
  );
}
