// Multilingual Electoral Knowledge Base (Offline-First)
// Compliant with the Electoral Act 2022 and INEC Election Regulations and Guidelines

export type LanguageCode = 'en' | 'ha' | 'ig' | 'yo' | 'pg' | 'ff' | 'kr';

export interface KnowledgeEntry {
  id: string;
  category: 'BVAS' | 'LATE_ARRIVAL' | 'CUTOFF' | 'OVER_VOTING' | 'EC8A_SIGNING' | 'EMERGENCY' | 'ACCREDITATION';
  title: Record<LanguageCode, string>;
  quickSummary: Record<LanguageCode, string>;
  actionSteps: Record<LanguageCode, string[]>;
  electoralActRef: string;
  keywords: Record<LanguageCode, string[]>;
}

export const SUPPORTED_LANGUAGES: { code: LanguageCode; label: string; flag: string }[] = [
  { code: 'en', label: 'English', flag: '🇬🇧' },
  { code: 'ha', label: 'Hausa', flag: '🇳🇬' },
  { code: 'ig', label: 'Igbo', flag: '🇳🇬' },
  { code: 'yo', label: 'Yorùbá', flag: '🇳🇬' },
  { code: 'pg', label: 'Pidgin', flag: '🇳🇬' },
  { code: 'ff', label: 'Fulfulde (Fulani)', flag: '🇳🇬' },
  { code: 'kr', label: 'Kanuri', flag: '🇳🇬' },
];

export const KNOWLEDGE_BASE: KnowledgeEntry[] = [
  {
    id: 'bvas-zero-check',
    category: 'BVAS',
    title: {
      en: 'BVAS Startup & Zero Tally Verification',
      ha: 'Binciken Fara Aikin BVAS da Tabbatar da Sifiri (0)',
      ig: 'Nmalite BVAS na Nnwale Ndekọ Efù (0)',
      yo: 'Ìbẹ̀rẹ̀ Ẹ̀rọ BVAS àti Ìmúdájú Kókó Òfo (0)',
      pg: 'How to Start BVAS & Confirm Say Tally Dey 0',
      ff: 'Bille BVAS e tabintinde limoore 0 (Sifiri)',
      kr: 'BVAS dəga-tə e-na 0 (Sifir) far-tə-ram',
    },
    quickSummary: {
      en: 'Before voting commences at 8:30 AM, the Presiding Officer MUST display the BVAS screen to all agents showing accredited voters = 0.',
      ha: 'Kafin a fara zabe da karfe 8:30 na safe, Babban Jami\'in Zabe (PO) DOLE ne ya nuna allon BVAS ga wakilai yana nuna masu kada kuri\'a = 0.',
      ig: 'Tupu ntuli aka ebido n\'elekere 8:30 nke ụtụtụ, Onyeisi Ntuli Aka (PO) GA-Egosipụta ihuenyo BVAS nye ndị nnọchi anya niile na-egosi ndị debanyere aha = 0.',
      yo: 'Kí ìbò tó bẹ̀rẹ̀ ní aago 8:30 àárọ̀, Oṣìṣẹ́ Àgbà Ìbò (PO) GBỌ́DỌ̀ fi ojú-ìwòye BVAS hàn fún gbogbo aṣojú pé àwọn tí a fọwọ́sí = 0.',
      pg: 'Before voting start by 8:30 AM, INEC Presiding Officer MUST show everybody the BVAS screen say accredited voters na Zero (0).',
      ff: 'Fado cuɓiiɗi puɗɗoo e aago 8:30 subaka, gardiiɗo cuɓiiɗi (PO) ina fotii hollaade allo BVAS haa yimɓe fuu njiya limoore suɓatooɓe = 0.',
      kr: 'Saa 8:30 suba-nin zabe futə-ya, INEC PO-de BVAS screen-so am samma-ro maza zabe-be namba 0 surono.',
    },
    actionSteps: {
      en: [
        'Inspect the BVAS screen closely with other party agents.',
        'Confirm that total accredited voters displays exactly "0".',
        'Check that the device date and time match the current election day.',
        'Take note of the BVAS serial number on your tracking log.',
        'If the screen shows any number greater than 0, IMMEDIATELY raise an objection and trigger the Emergency Beacon.',
      ],
      ha: [
        'Duba allon BVAS sosai tare da sauran wakilan jam\'iyyu.',
        'Tabbatar cewa yawan mutanen da aka tantance ya nuna "0" daidai.',
        'Tabbatar cewa kwanan wata da lokaci na na\'urar sun yi daidai da ranar zaben.',
        'Rubuta lambar sirrin BVAS (Serial Number) a cikin littafin bibiyarka.',
        'Idan allon ya nuna wata lamba sama da 0, NAN TAKE ka nuna rashin amincewarka kuma ka tura rahoton gaggawa.',
      ],
      ig: [
        'Lebanye anya na ihuenyo BVAS nke ọma ya na ndị nnọchiteanya ọzọ.',
        'Kwenye na ọnụ ọgụgụ ndị a nwetara ikike na-egosi kpọmkwem "0".',
        'Lelee na ụbọchị na oge ngwaọrụ ahụ kwekọrọ na ụbọchị ntuli aka nke taa.',
        'Detuo nọmba usoro BVAS (Serial Number) na ndekọ gị.',
        'Ọ bụrụ na ihuenyo ahụ na-egosi nọmba karịrị 0, KWỤSỊ ọrụ ozugbo ma zipụ mkpu mberede.',
      ],
      yo: [
        'Ṣe àyẹ̀wò ojú-ìwòye BVAS pẹ̀lú àwọn aṣojú mìíràn.',
        'Mú dájú pé gbogbo àwọn tí a fọwọ́sí ń fi "0" hàn gbangba.',
        'Ṣayẹwo pé ọjọ́ àti àkókò orí ẹ̀rọ náà bára mu pẹ̀lú ọjọ́ ìbò lónìí.',
        'Kọ nọ́mbà ìdánimọ̀ ẹ̀rọ BVAS (Serial Number) sínú ìwé rẹ.',
        'Bí ẹ̀rọ náà bá fi nọ́mbà tó ju 0 hàn, KÒ GBỌ́DỌ̀ GBÀ, tẹ bọ́tìnnì ìkìlọ̀ pàjáwìrì kíákíá.',
      ],
      pg: [
        'Look the BVAS screen well well together with other party agents.',
        'Confirm say the total accredited voters dey show "0" patapata.',
        'Check say the date and time on the machine correct for today election.',
        'Write down the BVAS serial number inside your notebook or app.',
        'If the screen show anything pass 0, SHOUT IMMEDIATELY and press the SOS Beacon button!',
      ],
      ff: [
        'Ndāre allo BVAS ɗon ko moyyi bee wakili\'en gooɗe.',
        'Tabintin limoore suɓatooɓe e limoore "0" tabitnde.',
        'Ƴeewto nyalaande e jemma ngam na’ura on e nyalooma cuɓiiɗi.',
        'Winndu limoore BVAS (Serial Number) e deftere maa.',
        'So allo holliri limoore ɓurnde 0, semmbiɗin kaɗki maa e noddu kisal (SOS).',
      ],
      kr: [
        'BVAS screen-de am pati gadaye so suron-ne.',
        'Namba am zabe-be samma 0 walliya kəl-gəne.',
        'Nyala kuru saa machine-be zabe kərma-be kəllino.',
        'BVAS serial namba kitabu-nem-ro ruwone.',
        'Namba 0 kozəya, kella kalla-gəne, SOS button tula-gəne!',
      ],
    },
    electoralActRef: 'Electoral Act 2022, Section 47(2) & INEC Manual para 2.4.1',
    keywords: {
      en: ['bvas', 'zero', 'start', 'screen', 'accreditation', 'inspect', 'tamper', 'beginning'],
      ha: ['bvas', 'sifiri', 'fara', 'allo', 'tantancewa', 'bincike', 'magudi'],
      ig: ['bvas', 'efu', 'mbido', 'ihuenyo', 'ikike', 'nnwale', 'ndekọ'],
      yo: ['bvas', 'ofo', 'ibere', 'ero', 'ayewo', 'ijeri', 'ise'],
      pg: ['bvas', 'zero', 'start', 'screen', 'check', 'begin', 'morning'],
      ff: ['bvas', 'sifiri', 'fuɗɗode', 'allo', 'laaɓal', 'cuɓiiɗi'],
      kr: ['bvas', 'sifir', 'zabe', 'screen', 'am', 'hoto'],
    },
  },
  {
    id: 'late-arrival-inec',
    category: 'LATE_ARRIVAL',
    title: {
      en: 'Late Arrival of INEC Officials or Materials',
      ha: 'Jinkirin Zuwan Jami\'an INEC ko Kayan Zabe',
      ig: 'Bịara N\'oge nke Ndị Ọrụ INEC ma ọ bụ Ngwa Ntuli Aka',
      yo: 'Ìpẹ́ Dé Àwọn Oṣìṣẹ́ INEC tàbí Ohun Èlò Ìbò',
      pg: 'When INEC People or Election Materials Come Late',
      ff: 'Jangde arandewal alamaaji INEC malla gollotooɓe',
      kr: 'Am INEC-be au kare zabe-be koli-ya',
    },
    quickSummary: {
      en: 'If INEC officials or sensitive materials do not arrive by 8:30 AM, log an immediate delay incident. Voting hours MUST be extended accordingly.',
      ha: 'Idan jami\'an INEC ko muhimman kayan aiki ba su isa ba zuwa karfe 8:30 na safe, shigar da rahoton jinkiri nan take. DOLE ne a kara lokacin zabe daidai da jinkirin da aka samu.',
      ig: 'Ọ bụrụ na ndị ọrụ INEC ma ọ bụ ngwa ntuli aka abịaghị n\'elekere 8:30 nke ụtụtụ, depụta mkpesa jinkiri ozugbo. A GA-Agatụkwa oge ntuli aka n\'ihu dịka o siri gbuo oge.',
      yo: 'Bí àwọn oṣìṣẹ́ INEC tàbí ohun èlò kò bá dé ní aago 8:30 àárọ̀, fi àkọsílẹ̀ ránṣẹ́ lẹ́sẹ̀kẹsẹ̀. ÀKÓKÒ ÌBÒ GBỌ́DỌ̀ fẹ̀ síwájú gẹ́gẹ́ bí wọ́n ṣe pẹ́ tó.',
      pg: 'If INEC officials or materials never show face by 8:30 AM, report am quick for app! Any time wey waste, INEC must add am back before closing.',
      ff: 'So gollotooɓe INEC malla gollirɗe ardaaki aago 8:30 subaka, tura rahotto jangde kisal. Nyalooma cuɓiiɗi ina fotii ɓeydeede!',
      kr: 'Am INEC-be au kare zabe-be saa 8:30-nin isanyiya, app-ro report gade. Saa waste sədə-de INEC bəlitə sədə!',
    },
    actionSteps: {
      en: [
        'Verify arrival status with your Ward Supervisor via the app.',
        'Log the exact time materials finally arrive and inspect Ballot Boxes (must be empty).',
        'Verify that the ballot papers booklet serial numbers are intact and not pre-torn.',
        'Insist on extension of voting hours: if voting starts at 10:30 AM, polls must remain open until 4:30 PM.',
        'Capture photos/videos of late arrival timestamps.',
      ],
      ha: [
        'Tabbatar da halin da ake ciki tare da Mai Kula da Mazabarka ta hanyar manhaja.',
        'Rubuta ainihin lokacin da kayan aiki suka iso kuma duba Akwatin Zabe (dole ya zama babu komai a ciki).',
        'Tabbatar cewa lambobin takardun kada kuri\'a ba a yaga ko an cire ba a baya.',
        'Kada ka yarda a rufe zabe ba tare da an kara lokacin da ya bata ba.',
        'Dauki hotuna da lokaci na zuwan jami\'an.',
      ],
      ig: [
        'Kwenye ọnọdụ mbịarute ya na Onye Nlekọta Wọọdụ gị site na ngwa.',
        'Detuo oge ngwa ahụ mechara rute ma nyochaa Igbe Ntuli Aka (ọ ga-abụ nke efu).',
        'Kwenye na akwụkwọ ịtụ vootu emebighị ma ọ bụ dọkasịa tupu oge eruo.',
        'Gbaa mbọ hụ na agbatịkwuru oge ntuli aka iji kwụọ ụgwọ maka oge furu efu.',
        'Seta foto ma ọ bụ vidiyo nke na-egosi oge ha ji rute.',
      ],
      yo: [
        'Fidánilójú pẹ̀lú Alábòójútó Wọ́ọ̀dù rẹ nípasẹ̀ àpù yìí.',
        'Kọ àkókò pàtó tí ohun èlò dé, ṣàyẹ̀wò Àpótí Ìbò (ó gbọ́dọ̀ wà ní òfo).',
        'Ṣàyẹ̀wò pé àwọn ìwé ìbò wà ní tòrò-mọ́wọ́, kò sí èyí tí a ti ya tẹ́lẹ̀.',
        'Dúró gbọn-in pé àkókò ìbò gbọ́dọ̀ fẹ̀ síwájú láti sanpadà fún àkókò tí ó sọnù.',
        'Ya àwòrán fídíò pẹ̀lú àkókò bí ẹ̀rí.',
      ],
      pg: [
        'Call or message your Ward Supervisor inside the app.',
        'Write down the exact time wey INEC finally reach, and check the Ballot Box say nothing dey inside.',
        'Check the ballot papers say nobody don tear any sheet before voting start.',
        'Insist say if election start late, voting must continue until the hours complete!',
        'Snap picture or video of the delay as proof.',
      ],
      ff: [
        'Ƴeewto arandewal bee ardooɗo maa e nder app.',
        'Winndu wakkati laaɓɗo mo alamaaji e gollotooɓe njippii.',
        'Tabintin defte cuɓiiɗi ina njiida e ɗe kaɓɓataaki.',
        'Darii dow ɓeydugol jemma cuɓiiɗi tawa ko maɓɓaaki ko adii.',
        'Ƴettu natal malla vidiyo ko seedantaagal.',
      ],
      kr: [
        'Ward Supervisor-nem app-nin manane.',
        'Sa\'a kare isəna-de ruwone, kuru ballot box nji-ba surone.',
        'Ballot paper samma sa-təwənyi kurushe.',
        'Sa\'a late sədəya, zabe-de sa\'a bəlitə sədə-ro kalla-gəne!',
        'Hoto au video koli-be kəram-ro snap-gəne.',
      ],
    },
    electoralActRef: 'Electoral Act 2022, Section 46 & INEC Regulations Clause 18(c)',
    keywords: {
      en: ['late', 'arrival', 'delay', 'materials', 'missing', 'inec', 'start', 'wait'],
      ha: ['jinkiri', 'makara', 'kayan', 'zabe', 'rashin', 'zuwa', 'dakatarwa'],
      ig: ['akaha', 'mbịarute', 'ngwa', 'jinkiri', 'nchebe', 'mbido', 'ndị ọrụ'],
      yo: ['ipe', 'ide', 'ohun', 'elo', 'idilowo', 'iduro', 'osise'],
      pg: ['late', 'delay', 'materials', 'wait', 'empty', 'show', 'face', 'time'],
      ff: ['jangde', 'arandewal', 'gollotooɓe', 'cuɓiiɗi', 'wakkati'],
      kr: ['koli', 'late', 'materials', 'inec', 'sa\'a', 'zabe'],
    },
  },
  {
    id: 'cutoff-rule-230',
    category: 'CUTOFF',
    title: {
      en: '2:30 PM Cutoff & Right to Vote',
      ha: 'Dokar Karfe 2:30 na Rana da Hakkin Yin Zabe',
      ig: 'Iwu Elekere 2:30 nke Ehihie na Ikike Ịtụ Vootu',
      yo: 'Òfin Aago 2:30 Ọ̀sán àti Ètọ́ láti Dìbò',
      pg: 'The 2:30 PM Queue Rule: Everyone on the Line Must Vote!',
      ff: 'Sariya 2:30 caka naange: Kala jiɓaaɗo e ɗaɗol ina jogii hakke suɓaade',
      kr: 'Sa\'a 2:30 kaza shari\'a: Am saf-nin dagana samma vote sədə kura-be',
    },
    quickSummary: {
      en: 'Voting officially closes at 2:30 PM, BUT every voter who joined the queue before 2:30 PM MUST be accredited and allowed to vote.',
      ha: 'Zabe na karewa ne da karfe 2:30 na rana, AMMA duk mai kada kuri\'a da ya riga ya shiga layi kafin 2:30 DOLE ne a ba shi damar kada kuri\'arsa.',
      ig: 'Ntuli aka na-emechi n\'elekere 2:30 nke ehihie, MANA onye ọ bụla nọ n\'ahịrị tupu 2:30 GA-Ekwere ya ikike ịtụ vootu ya.',
      yo: 'Ìbò máa ń parí ní aago 2:30 ọ̀sán, ṢÙGBỌ́N gbogbo olùdìbò tí ó bá ti wà ní ìlà ṣáájú aago 2:30 GBỌ́DỌ̀ dìbò tirẹ̀ pátápátá.',
      pg: 'Election official closing time na 2:30 PM, BUT any voter wey don stand inside line before 2:30 PM MUST vote! Nobody fit chase dem commot.',
      ff: 'Cuɓiiɗi ina uddoo e aago 2:30 caka naange, AMMA kala suɓatooɗo dariiɗo e ɗaɗol ko adii 2:30 ina jogii hakke suɓaade!',
      kr: 'Zabe sa\'a 2:30 kaza-nin cinzo gartin, AMMAN am samma saf-nin aago 2:30 pəya dagana so vote sədə kura-be!',
    },
    actionSteps: {
      en: [
        'At exactly 2:30 PM, stand at the very end of the line alongside other agents.',
        'Count the number of voters currently in queue and note the last voter in line.',
        'Prevent any new person from joining behind the last confirmed voter.',
        'Ensure the Presiding Officer does NOT shut down the BVAS until all voters in line have voted.',
        'Log the queue count in Step 4 ("Cutoff") of your Agent App module.',
      ],
      ha: [
        'Daidai karfe 2:30 na rana, tsaya a karshen layin zabe tare da sauran wakilai.',
        'Kirga yawan mutanen da ke kan layi kuma ka gane mutum na karshe.',
        'Hana duk wani sabon mutum shiga bayan mutum na karshe.',
        'Tabbatar cewa jami\'in INEC bai kashe BVAS ba har sai kowa a layin ya jefa kuri\'a.',
        'Shigar da adadin mutanen layi a Mataki na 4 na manhajarka.',
      ],
      ig: [
        'N\'elekere 2:30 nke ehihie kpọmkwem, guzo n\'ọdụ ahịrị ya na ndị nnọchiteanya ọzọ.',
        'Gụọ ọnụ ọgụgụ ndị nọ n\'ahịrị ma rịba ama onye ikpeazụ n\'ahịrị.',
        'Gbochie onye ọhụrụ ọ bụla ịbanye n\'azụ onye ikpeazụ a kwadoro.',
        'Gbaa mbọ hụ na onye ọrụ INEC anaghị agbanyụ BVAS ruo mgbe ndị niile nọ n\'ahịrị tụrụ vootu.',
        'Detuo ọnụ ọgụgụ a na Nkebi nke 4 na ngwa gị.',
      ],
      yo: [
        'Ní aago 2:30 ọ̀sán pọ́ńbélé, dúró sí ìparí ìlà pẹ̀lú àwọn aṣojú mìíràn.',
        'Ka iye àwọn ènìyàn tó wà lórí ìlà, kí o sì mọ ẹni ìkẹyìn.',
        'Kò gbọ́dọ̀ gba ẹnikẹ́ni láyè láti darapọ̀ mọ́ ìlà mọ́ lẹ́yìn ẹni ìkẹyìn yìí.',
        'Mú dájú pé oṣìṣẹ́ INEC kò pa ẹ̀rọ BVAS títí gbogbo àwọn tó wà lórí ìlà yóò fi dìbò tán.',
        'Kọ iye ènìyàn náà sínú Ìpele 4 nínú àpù rẹ.',
      ],
      pg: [
        'As time reach 2:30 PM sharp, go stand for the back of the queue with other agents.',
        'Count everybody wey dey the line and know the exact person wey dey last.',
        'No allow any new person join the line again after 2:30 PM.',
        'Make sure say the INEC PO no turn off the BVAS machine until everybody on queue don vote finish!',
        'Enter the queue number inside Step 4 for your Agent app.',
      ],
      ff: [
        'E aago 2:30 caka naange, daro e sakkitorde ɗaɗol bee wakili\'en feere.',
        'Limtu suɓatooɓe e ɗaɗol nden annditu neɗɗo cakkitiiɗo.',
        'Haɗu neɗɗo keso kala naatde ɓaowo neɗɗo cakkitiiɗo on.',
        'Hollitu gardiiɗo (PO) haɗa nyiffingol BVAS tawa kala goniɗo e ɗaɗol suɓaaki.',
        'Winndu limoore ɗaɗol e Ɓeydaare 4 e app maa.',
      ],
      kr: [
        'Sa\'a 2:30 kaza pəya, saf daram-nin am gade so kəl-gəne.',
        'Am saf-nin dagana gano kuru am daram-be nyo-gəne.',
        'Am bəli maza daram-be daram-ro na-tsaye.',
        'INEC PO BVAS da-tsanyi har am saf-be vote samma dai-ya.',
        'Step 4 app-nem-nin saf namba ruwone.',
      ],
    },
    electoralActRef: 'Electoral Act 2022, Section 49 & INEC Regulations Clause 22(a)',
    keywords: {
      en: ['cutoff', '2:30', 'queue', 'close', 'line', 'right to vote', 'time', 'end'],
      ha: ['2:30', 'layi', 'rufe', 'lokaci', 'karshe', 'hakki', 'zabe'],
      ig: ['2:30', 'ahịrị', 'mmechi', 'oge', 'ikpeazụ', 'ikike', 'vootu'],
      yo: ['2:30', 'ila', 'pipade', 'akoko', 'ikeyin', 'eto', 'idibo'],
      pg: ['2:30', 'queue', 'line', 'close', 'time', 'last person', 'vote'],
      ff: ['2:30', 'ɗaɗol', 'hakke', 'suɓaade', 'jemma'],
      kr: ['2:30', 'saf', 'vote', 'sa\'a', 'daram'],
    },
  },
  {
    id: 'over-voting-protocol',
    category: 'OVER_VOTING',
    title: {
      en: 'Over-Voting Cancellation Protocol (Section 51)',
      ha: 'Dokar Soke Sakamako Don Magudin Karin Kuri\'a (Sashe na 51)',
      ig: 'Iwu Kagbu Ntuli Aka n\'ihi Vootu Karịrị Ndị Debanyere (Nkebi 51)',
      yo: 'Ìlànà Ìfagilé Ìbò fún Àṣejù Ìbò (Abala 51)',
      pg: 'Over-Voting Rules (Section 51): Total Votes Cannot Pass BVAS!',
      ff: 'Sariya de’itte cuɓiiɗi (Sasa 51): Limngal cuɓiiɗi waawaa ɓura ko BVAS winndi!',
      kr: 'Vote kozəna shari\'a (Sasa 51): Vote samani BVAS kozə kura ba!',
    },
    quickSummary: {
      en: 'Under Section 51(2) of Electoral Act 2022, if Total Votes Cast > Total Accredited Voters on BVAS, the election in that Polling Unit MUST be cancelled.',
      ha: 'A karkashin Sashe na 51(2) na Dokar Zabe ta 2022, idan Jimillar Kuri\'u da aka Kada ta zarce Adadin Mutanen da BVAS ta Tantance, DOLE ne a soke zaben wannan rumfa.',
      ig: 'N\'okpuru Nkebi nke 51(2) nke Iwu Ntuli Aka 2022, ọ bụrụ na Mkpokọta Vootu tụrụ karịrị Ndị nwetara ikike na BVAS, A GA-Akagbu ntuli aka ahụ n\'ebe ahụ.',
      yo: 'Lábẹ́ Abala 51(2) ti Òfin Ìbò 2022, bí Àpapọ̀ Ìbò tí a Dì bá ju Iye Àwọn tí BVAS fọwọ́sí lọ, WỌ́N GBỌ́DỌ̀ fagilé ìbò ní àpótí náà lẹ́sẹ̀kẹsẹ̀.',
      pg: 'Under Section 51 of Electoral Act 2022, if Total Votes Cast pass BVAS Accredited Voters, that Polling Unit election is VOID and CANCELLED!',
      ff: 'E ley Sasa 51(2) finnde cuɓiiɗi 2022, so limoore cuɓiiɗi ɓurii limoore maantinaande e BVAS, cuɓiiɗi ɗin foti ko haaɗeede!',
      kr: 'Shari\'a 51(2) Electoral Act 2022-nin, vote samani BVAS namba-ro kozəya, Polling Unit zabe-de CANCELLED sədə!',
    },
    actionSteps: {
      en: [
        'Check the BVAS screen for the final accredited voters number.',
        'Sum all votes scored by all parties on Form EC8A plus rejected ballots.',
        'Compare: Is (Valid Votes + Rejected Votes) > BVAS Accredited Count?',
        'If YES, this is illegal over-voting. DO NOT sign Form EC8A without recording a formal written protest.',
        'Immediately trigger SOS Beacon in the app and upload Form EC8A photos.',
      ],
      ha: [
        'Duba allon BVAS don ganin ainihin adadin mutanen da aka tantance.',
        'Hada jimillar kuri\'un dukkan jam\'iyyu a Fom EC8A tare da kuri\'un da aka lalata.',
        'Bincika: Shin kuri\'u sun fi adadin da BVAS ta nuna?',
        'Idan ENE, wannan haramtaccen karin kuri\'a ne. KADA ka sanya hannu a Fom EC8A ba tare da rubuta korafi a takarda ba.',
        'Nan take ka danna bọtin ɗin gaggawa na SOS a manhaja.',
      ],
      ig: [
        'Lelee ihuenyo BVAS maka ngụkọta ọnụ ọgụgụ ndị a nwetara ikike ikpeazụ.',
        'Gbakọọ vootu niile nke pati niile nwetara na Fọm EC8A tinyere vootu ndị a tụfuru atụfu.',
        'Tulee: Ọ bụ na vootu niile karịrị ndị BVAS kwadoro?',
        'Ọ bụrụ EE, nke a bụ mpụ na iwu. ABINYELA aka na Fọm EC8A n\'edebanyeghị mkpesa n\'akwụkwọ.',
        'Ziga mkpu mberede (SOS) n\'ime ngwa ahụ ozugbo.',
      ],
      yo: [
        'Ṣàyẹ̀wò ojú-ìwòye BVAS fún àpapọ̀ iye àwọn tí a fọwọ́sí gbẹ̀yìn.',
        'Ṣe àpapọ̀ gbogbo ìbò tí gbogbo ẹgbẹ́ jẹ lórí Fọ́ọ̀mù EC8A pẹ̀lú àwọn ìbò tí a kò tẹ́wọ́gbà.',
        'Bí Àpapọ̀ Ìbò bá ju iye tí BVAS fọwọ́sí lọ, àṣejù ìbò ti wáyé.',
        'MÁ ṢE fọwọ́bọ̀wé láìkọ ìwé àtakò sílẹ̀ gbangba.',
        'Tẹ bọ́tìnnì ìkìlọ̀ SOS kíákíá nínú àpù.',
      ],
      pg: [
        'Check the BVAS screen make you see the final number of accredited voters.',
        'Add all the votes wey every party score for Form EC8A plus rejected ballot papers.',
        'Calculate: If total votes pass BVAS accredited number, over-voting don happen!',
        'NO SIGN that Form EC8A unless you write official protest letter on top am.',
        'Press SOS Beacon immediately inside app and upload the EC8A photo.',
      ],
      ff: [
        'Ƴeewto allo BVAS ngam maantinirɗe jemma.',
        'Haɓɓo limoore partiiji fuu e Form EC8A e cuɓiiɗi moƴƴaani.',
        'Yerondir: So cuɓiiɗi fuu ɓurii maantinde BVAS, ɗum woni joolol cuɓiiɗi!',
        'TAA siynu Form EC8A tawa a winndaani daliila murtal e ɗerewol.',
        'Tura noddaango SOS e app nden njuɓɓina natal Form EC8A.',
      ],
      kr: [
        'BVAS screen-nin final accredited voter namba kurushe.',
        'Form EC8A-nin party samma vote kuru rejected votes-so kəl-gəne.',
        'Total votes BVAS kozəya, over-voting walliya!',
        'Form EC8A sa-təwəne har protest ruwo-gəne.',
        'SOS Beacon app-nin tula-gəne kuru EC8A hoto upload-gəne.',
      ],
    },
    electoralActRef: 'Electoral Act 2022, Section 51(2), (3) & (4)',
    keywords: {
      en: ['over-voting', 'cancel', 'section 51', 'accredited', 'discrepancy', 'bvas', 'rigging', 'fraud'],
      ha: ['magudi', 'karin kuri\'a', 'soke', 'sashe 51', 'bvas', 'rashin gaskiya'],
      ig: ['vootu karịrị', 'kagbu', 'nkebi 51', 'bvas', 'aghụghọ', 'mkpesa'],
      yo: ['aseju ibo', 'fagile', 'abala 51', 'bvas', 'ere', 'idanimo'],
      pg: ['over-voting', 'cancel', 'section 51', 'rigging', 'cheat', 'bvas', 'pass'],
      ff: ['joolol', 'cuɓiiɗi', 'haaɗeede', 'bvas', 'sasa 51'],
      kr: ['over-voting', 'cancel', 'shari\'a 51', 'bvas', 'vote'],
    },
  },
  {
    id: 'ec8a-signing-upload',
    category: 'EC8A_SIGNING',
    title: {
      en: 'Form EC8A Endorsement & High-Res Photo Capture',
      ha: 'Sa Hannu a Fom EC8A da Daukar Hoto Mai Kyau',
      ig: 'Nkwado Fọm EC8A na Isere Foto doro Anya',
      yo: 'Fífọwọ́bọ̀wé Fọ́ọ̀mù EC8A àti Yíya Àwòrán Rẹ̀ Ketekete',
      pg: 'How to Sign Form EC8A & Snap Clean Clear Photo',
      ff: 'Siynugol Form EC8A e ƴettugol natal laaɓngal',
      kr: 'Fom EC8A sa-təwo e kuru hoto təlala sa-gata',
    },
    quickSummary: {
      en: 'Ensure every number is legible. Check ADC votes carefully. Sign only after verifying math. Snap a clean, well-lit photo before PO leaves the unit.',
      ha: 'Tabbatar cewa kowace lamba a rubuce take a sarari. Bincika kuri\'un ADC da kyau. Sa hannu kawai bayan ka tabbatar da lissafin. Dauki hoto mai haske kafin jami\'in ya tashi.',
      ig: 'Gbaa mbọ hụ na nọmba ọ bụla doro anya. Lelee vootu ADC nke ọma. Banye naanị mgbe ị kwadoro ngụkọta. Seta foto doro anya tupu ndị ọrụ ahapụ ebe ahụ.',
      yo: 'Mú dájú pé gbogbo nọ́mbà hàn ketekete. Ṣàyẹ̀wò ìbò ADC dáadáa. Fọwọ́bọ̀wé kìkì lẹ́yìn tí o bá fọwọ́sí àpapọ̀ náà. Ya àwòrán tó mọ́ tónítóní kí oṣìṣẹ́ tó kúrò níbẹ̀.',
      pg: 'Make sure all numbers clear well well! Check ADC vote tallies. Sign only when math correct. Snap clear, bright photo before INEC leave the PU.',
      ff: 'Tabbintin kala limoore ina laaɓi. Ƴeewto cuɓiiɗi ADC boɗɗum. Siynu tan so a tabintinii limoore. Ƴettu natal laaɓngal ko PO yalta!',
      kr: 'Namba samma təlala surone. ADC vote kurushe. Math kəl-gəne daji sa-təwəne. PO tulo kəra-nin hoto təlala snap-gəne.',
    },
    actionSteps: {
      en: [
        'Cross-check the numbers entered for ADC: ensure no zero was added or subtracted.',
        'Verify that the Presiding Officer signs and stamps the Form EC8A first.',
        'Sign your copy and demand your duplicate carbon copy (Pink/Green copy).',
        'Hold the phone flat, parallel to the form, in good lighting. Ensure all 4 corners are visible.',
        'Upload directly in Step 5 ("Results") of the Situation Room app.',
      ],
      ha: [
        'Duba lambobin da aka rubuta wa jam\'iyyar ADC: tabbatar ba a rage ko kara wata lamba ba.',
        'Tabbatar cewa Babban Jami\'in ya sanya hannu da hatimi a Fom EC8A tukunna.',
        'Sanya hannunka kuma ka karbi kwafinka na asali (Pink/Green copy).',
        'Rike wayarka daidai a kan takardar a wuri mai haske. Tabbatar dukkan kusurwoyi 4 na takardar suna ciki.',
        'Loda hoton kai tsaye a Mataki na 5 ("Sakamako") na manhajar.',
      ],
      ig: [
        'Nyochaa ọnụ ọgụgụ e denyere maka ADC: gbaa mbọ hụ na ọ dịghị nọmba ewepụrụ ma ọ bụ tinye.',
        'Kwenye na Onye Ọrụ Presiding banyere aka ma tinye stampụ na Fọm EC8A ahụ na mbụ.',
        'Banye aka gị ma nata akwụkwọ oyiri nke gị (Pink/Green copy).',
        'Jide ekwentị gị kwụ ọtọ n\'elu fọm ahụ n\'ebe ọkụ dị mma. Hụ na akụkụ anọ niile pụtara ìhè.',
        'Tinye ya ozugbo na Nkebi nke 5 ("Nsonaazụ") na ngwa gị.',
      ],
      yo: [
        'Ṣàyẹ̀wò nọ́mbà tí a kọ sí ẹ̀gbgbẹ́ ADC dáadáa: kò gbọ́dọ̀ sí àfikún tàbí àyọkúrò.',
        'Fidánilójú pé Oṣìṣẹ́ Àgbà ti fọwọ́bọ̀wé tí ó sì tẹ èdìdì (stamp) sí orí Fọ́ọ̀mù EC8A náà ná.',
        'Fọwọ́bọ̀wé kí o sì gba ẹ̀dà tìrẹ lẹ́sẹ̀kefẹ̀ (Pink/Green copy).',
        'Dúró dáadáa kí o ya àwòrán níbi tí ìmọ́lẹ̀ ti wà. Jẹ́ kí igun mẹ́rẹ̀ẹ̀rin ìwé náà hàn ketekete.',
        'Gbé àwòrán náà wọlé ní Ìpele 5 ("Àbájáde") lórí àpù náà.',
      ],
      pg: [
        'Check the numbers wey dem write for ADC well: make sure say dem no minus your votes or add zero for other party.',
        'Confirm say INEC PO don sign and stamp the Form EC8A first.',
        'Sign your own name and collect your own duplicate paper (Pink/Green copy).',
        'Hold your phone flat and steady for good light. Make sure all 4 corners of the form show clearly inside camera.',
        'Upload am immediately inside Step 5 ("Results") for the app.',
      ],
      ff: [
        'Ƴeewto limoore winndaande ADC: taa hay sifiri ɓeydaama walla ɗoofaama.',
        'Tabintin gardiiɗo (PO) siynii e tafi hatmi Form EC8A arande.',
        'Siynu ɗerewol maa nden ɗaɓɓu kopeel maada (Pink/Green copy).',
        'Jogito ndeyyitaare e jayngol. Tabintin pempe 4 fuu ɗon njiida.',
        'Tura njuɓɓina natal ngal e Step 5 e app.',
      ],
      kr: [
        'ADC namba ruwo-gata-de kurushe: zero gade sa-təwənyi au minus-gənyi.',
        'INEC PO-de Form EC8A sa-təwəne kuru stamp sədə-ro kəllino.',
        'Gade-nem sa-təwəne kuru duplicate copy-nem (Pink/Green) kəl-gəne.',
        'Phone-nem flat jidde-gəne na kaji-nin. Corners 4 samma surone.',
        'Step 5 app-nin upload-gəne.',
      ],
    },
    electoralActRef: 'Electoral Act 2022, Section 60(3), (4) & (5)',
    keywords: {
      en: ['ec8a', 'form', 'signing', 'photo', 'camera', 'upload', 'result', 'stamp', 'carbon copy'],
      ha: ['fom ec8a', 'hoto', 'sa hannu', 'sakamako', 'hatimi', 'loda', 'takarda'],
      ig: ['fọm ec8a', 'foto', 'banye aka', 'nsonaazụ', 'stampụ', 'tinye'],
      yo: ['foomu ec8a', 'aworan', 'fowobowe', 'abajade', 'edidi', 'gba'],
      pg: ['ec8a', 'photo', 'snap', 'sign', 'camera', 'upload', 'result', 'paper'],
      ff: ['ec8a', 'form', 'siynu', 'natal', 'loda', 'adc'],
      kr: ['ec8a', 'fom', 'hoto', 'snap', 'sign', 'upload'],
    },
  },
  {
    id: 'emergency-sos-guidance',
    category: 'EMERGENCY',
    title: {
      en: 'Thuggery, Violence & Threat Escalation',
      ha: 'Tashin Hankali, Daba da Barazana ga Zabe',
      ig: 'Ọgbaghara, Ime Ihe Ike na Mkpu Egwu',
      yo: 'Ìwà Ìbàjẹ́, Ìjà àti Ìkìlọ̀ Ewu',
      pg: 'Thugs, Violence, Ballot Snatching & SOS Protocol',
      ff: 'Fitinaaji, Wuyɓe, e Noddugol Kisal (SOS)',
      kr: 'Barke ba, Wuya kuru Kare SOS be',
    },
    quickSummary: {
      en: 'Your physical safety comes first. Do not resist violent thugs physically. Discretely trigger the SOS Beacon in the app to notify National Tactical and Security Command.',
      ha: 'Lafiyarka da tsaron ranka ne a gaba. Kada ka yi kokarin fada da \'yan daba masu makamai. Cikin nutsuwa ka danna bọtin ɗin SOS a manhaja don sanar da Rundunar Tsaro ta Kasa.',
      ig: 'Nchekwa gị kacha mkpa. Ebusola ndị omekome agha n\'onwe gị. Pịa bọtịnụ SOS na ngwa ahụ na nzuzo iji gwa Ndị Ọrụ Nchebe Mba.',
      yo: 'Ààbò ẹ̀mí rẹ ló ṣe pàtàkì jùlọ. Má bá àwọn jàndùkú jà ní tààràtà. Tẹ bọ́tìnnì SOS ní ìkọ̀kọ̀ láti sọ fún Àwọn Ọ̀gá Ààbò Ilẹ̀ Náìjíríà.',
      pg: 'Your life first! No fight armed thugs. Just press the red SOS Emergency Beacon inside the app quietly to alert the National Situation Room & Security forces.',
      ff: 'Kisal nguurndam maa woni aranal. Taa haɓu e wuyɓe jogiiɓe kaɓirɗe. Ɓoornito e meem "SOS Beacon" e app ngam hollirde jamɗi kisal leydi!',
      kr: 'Ruwom kura! Am barke ba ka-təne. SOS Emergency Beacon button app-nin tula-gəne National Security-ro alert sa-tə-ro.',
    },
    actionSteps: {
      en: [
        'Move to a safe distance away from violence or gunfire.',
        'Tap the red "SOS Emergency Beacon" button on the screen.',
        'Select the incident type (e.g. Armed Ballot Snatching, Thuggery, BVAS Destruction).',
        'The app captures your GPS coordinates and broadcasts to State and National Security Desks.',
        'If safe to do so, discretely record video or audio evidence.',
      ],
      ha: [
        'Koma wuri mai aminci nesa da tashin hankali ko harbe-harbe.',
        'Danna bọtin ɗin "SOS Emergency Beacon" a allon wayarka.',
        'Zabi irin matsalar (misali: Satar Akwati, Daba, Fasa BVAS).',
        'Manhajar za ta tura ainihin inda kake (GPS) zuwa Sashen Tsaro na Jiha da na Kasa.',
        'Idan akwai aminci, dauki hoton bidiyo ko sautin murya a boye a matsayin shaida.',
      ],
      ig: [
        'Pụọ n\'ebe dị anya site na ọgbaghara ma ọ bụ egbe.',
        'Pịa bọtịnụ "SOS Emergency Beacon" na-acha uhie uhie.',
        'Họrọ ụdị ihe omume ahụ (dịka Ndị Ohi Igbe Vootu, Ndị Omekome, Mbibi BVAS).',
        'Ngwa ahụ ga-enweta ebe ị nọ (GPS) wee zigara ndị nchekwa nke mba.',
        'Ọ bụrụ na ọ dị mma, n\'ụzọ dị jụụ detuo ihe akaebe vidiyo ma ọ bụ ọdịyo.',
      ],
      yo: [
        'Kúrò ní àyíká ewu tàbí ibi tí ìbọn ti ń dún sí ibi ààbò.',
        'Tẹ bọ́tìnnì pupa "SOS Emergency Beacon" lórí ojú-ìwòye rẹ.',
        'Yan irú ewu náà (fún àpẹẹrẹ: Ìjígbé Àpótí Ìbò, Jàndùkú, Fífọ́ BVAS).',
        'Àpù yìí yóò fi ibi tí o wà gangan (GPS) ránṣẹ́ sí Àwọn Ọ̀gá Ààbò ti Ìpínlẹ̀ àti ti Orílẹ̀-èdè.',
        'Bí ó bá ní ààbò, fi ọwọ́ pẹ́ẹ́kí gba fídíò tàbí ohùn sílẹ̀ gẹ́gẹ́ bí ẹ̀rí.',
      ],
      pg: [
        'Move commot to safe place far from fighting or gunshots.',
        'Press that red "SOS Emergency Beacon" button for screen.',
        'Pick wetin dey happen (e.g. Ballot Box Snatching, Thug Attack, BVAS Smash).',
        'The app go lock your GPS location and send alert give National Security Command quick.',
        'If safe, snap photo or record video secretly as legal evidence.',
      ],
      ff: [
        'Korrino e nokku moƴƴo nesa fitinaaji.',
        'Meem boɗeejo "SOS Emergency Beacon" e allo.',
        'Subu sabaabu ewu (misal: Satar Akwati, Fitina, Fasa BVAS).',
        'App on ina jaɓa nokku maa (GPS) tura ɗum to Polisii e Kisal leydi.',
        'So ina woodi kisal, ƴettu vidiyo walla sawtu deeyɗum.',
      ],
      kr: [
        'Na safe-ro kəllino na barke ba-nin.',
        'Red "SOS Emergency Beacon" button tula-gəne.',
        'Wuya pick-gəne (e.g. Ballot Box Snatching, Thug Attack, BVAS Smash).',
        'App-de GPS location-nem njo-gəne Security Command-ro.',
        'Video au audio record-gəne proof-ro.',
      ],
    },
    electoralActRef: 'Electoral Act 2022, Section 126 & Criminal Code Act',
    keywords: {
      en: ['emergency', 'sos', 'violence', 'thugs', 'attack', 'snatching', 'police', 'danger', 'gun'],
      ha: ['gaggawa', 'sos', 'tashin hankali', 'daba', 'sata', 'hadari', '\'yan sanda'],
      ig: ['mberede', 'sos', 'ime ihe ike', 'ndị ohi', 'egbe', 'ndị uwe ojii', 'ihe ize ndụ'],
      yo: ['pajawiri', 'sos', 'ija', 'janduku', 'ewu', 'olopaa', 'ole'],
      pg: ['emergency', 'sos', 'fight', 'thugs', 'snatch', 'danger', 'police', 'gunshot'],
      ff: ['fitina', 'sos', 'kisal', 'wuyɓe', 'kasa'],
      kr: ['barke ba', 'sos', 'wuya', 'danger', 'police'],
    },
  },
];

// Offline instant search function
export function searchKnowledgeBase(
  query: string,
  language: LanguageCode = 'en'
): KnowledgeEntry[] {
  const q = query.trim().toLowerCase();
  if (!q) return KNOWLEDGE_BASE;

  return KNOWLEDGE_BASE.filter((entry) => {
    // Match in title
    if (entry.title[language]?.toLowerCase().includes(q)) return true;
    if (entry.title.en.toLowerCase().includes(q)) return true;

    // Match in summary
    if (entry.quickSummary[language]?.toLowerCase().includes(q)) return true;

    // Match in keywords
    const keywords = entry.keywords[language] || [];
    const enKeywords = entry.keywords.en || [];
    if (keywords.some((k) => k.toLowerCase().includes(q) || q.includes(k.toLowerCase()))) return true;
    if (enKeywords.some((k) => k.toLowerCase().includes(q) || q.includes(k.toLowerCase()))) return true;

    // Match in category
    if (entry.category.toLowerCase().includes(q)) return true;

    return false;
  });
}
