import { renderEmptyState } from './helpdesk-empty-state.js'; function esc(str) { const d = document.createElement('div'); d.textContent = String(str ?? ''); return d.innerHTML; } function activityActionLabel(typeVariant, type, stateSubtype, t) { if (typeVariant === 'status') { const base = t('changed status'); return stateSubtype ? `${base} (${stateSubtype})` : base; } if (typeVariant === 'forward') { return t('Forwarded'); } if (typeVariant === 'file') { return t('attached a file'); } if (type && String(type).trim() !== '') { return type; } return t('logged an activity'); } function entryTimestamp(entry, t) { const date = entry.date || ''; const timeRaw = entry.time || ''; const time = timeRaw.length >= 5 ? timeRaw.slice(0, 5) : timeRaw; if (date && time) return `${date} ${time}`; if (entry.timestamp_iso) return entry.timestamp_iso; if (date) return date; return '—'; } function participantRole(entry) { const explicitRole = String(entry.actor_role || '').trim().toLowerCase(); if (explicitRole === 'customer' || explicitRole === 'support') { return explicitRole; } const actor = String(entry.actor || '').trim().toLowerCase(); if (actor.startsWith('kt') || actor.includes('kontakt') || actor.includes('contact')) { return 'customer'; } return 'support'; } function ticketHref(baseUrl, ticketNo) { const base = String(baseUrl || '').trim(); const no = String(ticketNo || '').trim(); if (!base || !no) return ''; return `${base}${encodeURIComponent(no)}`; } export function renderCommunicationError(message) { return `
${esc(message)}
${esc(message)}
`; } export function renderCommunicationFeed(entries, options = {}) { const { t = (k) => k, emptyMessage = 'No communication found.', showTicketNo = false, ticketBaseUrl = '', fileDownloadUrl = '', } = options; const list = Array.isArray(entries) ? entries : []; if (list.length === 0) { return renderEmptyState({ message: t(emptyMessage), size: 'compact', align: 'center', icon: false, }); } let html = '