import type { TranslationSeedItem, TranslationSeedModule } from './translation-seed.types';

const additional: Array<[string, string, string]> = [
  ['page.title', 'RGC Decision', 'សេចក្តីសម្រេចរបស់រាជរដ្ឋាភិបាល'],
  ['grid_locale.column_menu_aria_label', 'Column menu {columnName}', 'ម៉ឺនុយជួរឈរ {columnName}'],
  ['detail.back', 'Back', 'ត្រឡប់'],
  ['detail.title', 'RGC Decision Detail', 'ព័ត៌មានលម្អិតសេចក្តីសម្រេចរបស់រាជរដ្ឋាភិបាល'],
  ['detail.description', 'Detail information of RGC Decision', 'ព័ត៌មានលម្អិតនៃសេចក្តីសម្រេចរបស់រាជរដ្ឋាភិបាល'],
  ['detail.ministry', 'Ministry', 'ក្រសួង'],
  ['detail.meeting_date', 'Meeting Date', 'កាលបរិច្ឆេទប្រជុំ'],
  ['detail.category', 'Category', 'ប្រភេទ'],
  ['detail.status', 'Status', 'ស្ថានភាព'],
  ['detail.focal_person', 'Focal Person (H.E)', 'មន្ត្រីទទួលបន្ទុក'],
  ['detail.issue_description', 'Issues Description', 'ការពិពណ៌នាបញ្ហា'],
  ['detail.recommendations', 'Recommendations', 'អនុសាសន៍'],
  ['detail.rgc_decision', 'RGC Decision', 'សេចក្តីសម្រេចរបស់រាជរដ្ឋាភិបាល'],
  ['detail.indicators', 'Indicators', 'សូចនាករ'],
  ['detail.progress_solution', 'Progress Solution', 'វឌ្ឍនភាពនៃដំណោះស្រាយ'],
  ['detail.implementation_challenges', 'Implementation Challenges', 'បញ្ហាប្រឈមក្នុងការអនុវត្ត'],
  ['detail.request', 'Request', 'សំណើ'],
  ['detail.next_step', 'Next Step', 'ជំហានបន្ទាប់'],
  ['detail.source_of_verification', 'Source of Verification', 'ប្រភពផ្ទៀងផ្ទាត់'],
  ['detail.verification_link', 'Link to Verification Source', 'តំណភ្ជាប់ប្រភពផ្ទៀងផ្ទាត់'],
  ['detail.not_found', 'RGC Decision not found.', 'រកមិនឃើញសេចក្តីសម្រេចនេះទេ។'],
  ['detail.plenary', 'Plenary', 'វេទិការ'],
  ['detail.plenary_number', 'Plenary #{id}', 'កិច្ចប្រជុំពេញអង្គ លេខ {id}'],
  ['error.load', 'Unable to load RGC Decisions.', 'មិនអាចទាញយកសេចក្តីសម្រេចរបស់រាជរដ្ឋាភិបាលបានទេ។'],
  ['filter_panel.filter', 'Filter', 'តម្រង'],
  ['filter_panel.filters', 'Filters', 'តម្រង'],
  ['filter_panel.noOptions', 'No options available', 'មិនមានជម្រើស'],
  ['filter_panel.clearAll', 'Clear all', 'សម្អាតទាំងអស់'],
  ['filter_panel.clearSelection', 'Clear', 'សម្អាត'],
  ['filter_panel.selectAll', 'Select all', 'ជ្រើសរើសទាំងអស់'],
  ['filter_panel.viewAll', 'View All', 'មើលទាំងអស់'],
  ['filter_panel.viewLess', 'View Less', 'មើលតិច'],
  ['filter_panel.applyFilters', 'Apply Filters', 'អនុវត្តតម្រង'],
  ['report.no_progress', 'No progress report', 'មិនមានរបាយការណ៍វឌ្ឍនភាព'],
  ['report.not_available', 'Not available', 'មិនមាន'],
  ['report.tab', 'Report {semester} {year}', 'របាយការណ៍ {semester} {year}'],
  ['report.issue_attachment', 'Issue attachment', 'ឯកសារភ្ជាប់បញ្ហា'],
  ['report.implementationDate', 'Implementation date', 'កាលបរិច្ឆេទអនុវត្ត'],
  ['report.referenceName', 'Reference Name', 'ឈ្មោះឯកសារយោង'],
  ['report.referenceLink', 'Reference Link', 'តំណភ្ជាប់ឯកសារយោង'],
  ['report.progressSolution', 'Progress Solution', 'វឌ្ឍនភាពនៃដំណោះស្រាយ'],
  ['report.solutionIndicators', 'Solution Indicators', 'សូចនាករដំណោះស្រាយ'],
  ['report.challenges', 'Challenges', 'បញ្ហាប្រឈម'],
  ['report.requests', 'Requests', 'សំណូមពរ'],
  ['report.rgcDecision', 'RGC Decision', 'សេចក្តីសម្រេចរបស់រាជរដ្ឋាភិបាល'],
  ['export.exported', 'Exported', 'បាននាំចេញ'],
  ['export.total_records', 'Total Records', 'ចំនួនកំណត់ត្រាសរុប'],
  ['export.no', 'No', 'ល.រ'],
  ['export.ministry', 'Ministry', 'ក្រសួង'],
  ['export.rgc_decision', 'RGC Decision', 'សេចក្តីសម្រេចរបស់រាជរដ្ឋាភិបាល'],
  ['export.linked_issues', 'Linked Issues', 'បញ្ហាដែលភ្ជាប់'],
  ['export.meeting_date', 'Meeting Date', 'កាលបរិច្ឆេទប្រជុំ'],
  ['export.category', 'Category', 'ប្រភេទ'],
  ['export.status', 'Status', 'ស្ថានភាព'],
  ['export.indicator', 'Indicator', 'សូចនាករ'],
  ['export.focal_person', 'Focal Person (H.E)', 'មន្ត្រីទទួលបន្ទុក'],
  ['export.source_of_verification', 'Source of Verification', 'ប្រភពផ្ទៀងផ្ទាត់'],
  ['export.verification_link', 'Link to Verification Source', 'តំណភ្ជាប់ប្រភពផ្ទៀងផ្ទាត់'],
];

/** The shared screen is mounted by CDC and CEFP, with independent Admin records. */
export function withRgcDecisionLabels(
  module: Extract<TranslationSeedModule, 'cdc' | 'cefp'>,
  existing: TranslationSeedItem[],
  source: TranslationSeedItem[] = [],
): TranslationSeedItem[] {
  const page = 'rgc_decision';
  const keys = new Set(existing.filter(item => item.page === page).map(item => item.translationKey));
  const copied = source.filter(item => item.page === page && item.translationKey !== 'export.title' && !keys.has(item.translationKey))
    .map(item => ({ ...item, module, parent: undefined }));
  copied.forEach(item => keys.add(item.translationKey));
  const gridLocale = existing
    .filter(item => item.page === 'issue_matrix' && item.translationKey.startsWith('grid_locale.') && !keys.has(item.translationKey))
    .map(item => ({ ...item, page, parent: undefined }));
  gridLocale.forEach(item => keys.add(item.translationKey));
  const extras = additional.filter(([key]) => !keys.has(key))
    .map(([translationKey, englishText, khmerText]) => ({
      module, page, translationKey, englishText, khmerText, isActive: true,
    }));
  const exportTitle = {
    module, page, translationKey: 'export.title',
    englishText: `${module.toUpperCase()} RGC Decisions`,
    khmerText: `សេចក្តីសម្រេចរបស់រាជរដ្ឋាភិបាល (${module.toUpperCase()})`,
    isActive: true,
  };
  return [...existing, ...copied, ...gridLocale, ...extras, ...(!keys.has('export.title') ? [exportTitle] : [])];
}
