import { completedIcon, pendingIcon, processingIcon } from './constants.js'; import { apiBaseUrl, clientId, estTimeStep1, estTimeStep2 } from './main.js'; import { t, onLanguageChange } from './i18n.js'; const statusFaceCheckElement = document.getElementById('status-face-check'); const baseServices = [ { id: 1, name: 'Geolocation', displayKey: 'serviceGeolocation', }, { id: 2, name: 'Timestamp', displayKey: 'serviceTimestamp', }, { id: 3, name: 'AIGVDetection', displayKey: 'serviceAIGVDetection', }, { id: 4, name: 'Report', displayKey: 'serviceReport', }, ]; const createInitData = () => baseServices.map((service) => ({ ...service, status: 'pending', percent: 0, })); export let statusStep1 = 'pending'; export let statusStep2 = 'pending'; let _estTimeStep1 = 0; let _estTimeStep2 = 0; function formatText(key, params = {}) { let value = t(key) || ''; Object.entries(params).forEach(([k, v]) => { value = value.replace(`{${k}}`, v); }); return value; } function getDisplayName(item) { if (item.displayKey) { const translated = t(item.displayKey); if (translated) return translated; } return item.displayName || item.name || ''; } function renderStatus(newValue, countItem, countItemCompleted) { const percent = Math.round((countItemCompleted / countItem) * 100); const step1Message = statusStep1 === 'pending' ? `${t('waitingLabel')} - ${ _estTimeStep1 === 0 ? t('calculatingLabel') : formatText('minutesRemaining', { minutes: _estTimeStep1 }) }` : statusStep1 === 'processing' ? formatText('processingEstimate', { minutes: _estTimeStep1 }) : t('completedLabel'); const step2Message = statusStep2 === 'pending' ? `${t('waitingLabel')} - ${ _estTimeStep2 === 0 ? t('calculatingLabel') : formatText('beginsAfterStep1', { minutes: _estTimeStep2 }) }` : statusStep2 === 'processing' ? formatText('processingEstimate', { minutes: _estTimeStep2 }) : t('completedLabel'); return `
${formatText('statusHeaderCompleted', { completed: countItemCompleted, total: countItem, })}
${formatText('statusPercent', { percent })}
${formatText('serviceLabel', { index: index + 1, total: countItem, name: getDisplayName(item), })}
${ item.status === 'processing' ? t('statusProcessing') : item.status === 'completed' ? t('statusCompleted') : t('statusPending') }