import api from '../utils/api'; const { __ } = wp.i18n; const providerIcons = { openai: ( ), google: ( ), grok: ( ), deepseek: ( ), }; export default function AgentCard({ agent, onEdit, onDelete, onToggle, onRun, onDuplicate, }) { const isActive = agent.status === 'active'; const providerIcon = providerIcons[agent.provider]; const formatRecurrence = () => { if (agent.recurrence_type === 'interval') { const interval = agent.recurrence_interval; const time = agent.recurrence_time || '09:00'; if (interval === 1) { return __('Every day at %s', 'ai-bulk-post').replace('%s', time); } return __('Every %d days at %s', 'ai-bulk-post') .replace('%d', interval) .replace('%s', time); } if (agent.recurrence_type === 'schedule') { const dayMap = { sun: __('Sun', 'ai-bulk-post'), mon: __('Mon', 'ai-bulk-post'), tue: __('Tue', 'ai-bulk-post'), wed: __('Wed', 'ai-bulk-post'), thu: __('Thu', 'ai-bulk-post'), fri: __('Fri', 'ai-bulk-post'), sat: __('Sat', 'ai-bulk-post'), }; const days = (agent.recurrence_days || []) .map((d) => dayMap[d] || d) .join(', '); const time = agent.recurrence_time || '09:00'; return __('%s at %s', 'ai-bulk-post') .replace('%s', days) .replace('%s', time); } return __('Not scheduled', 'ai-bulk-post'); }; const formatLastRun = () => { if (!agent.last_run) return __('Never', 'ai-bulk-post'); const date = new Date(agent.last_run + ' UTC'); const now = new Date(); const diffMs = now - date; const diffMin = Math.floor(diffMs / 60000); if (diffMin < 1) return __('Just now', 'ai-bulk-post'); if (diffMin < 60) return __('%d min ago', 'ai-bulk-post').replace('%d', diffMin); const diffHours = Math.floor(diffMin / 60); if (diffHours < 24) { return __('%d hours ago', 'ai-bulk-post').replace('%d', diffHours); } const diffDays = Math.floor(diffHours / 24); return __('%d days ago', 'ai-bulk-post').replace('%d', diffDays); }; return (