package com.anas.alqurancloudapi.consts;

import java.util.ArrayList;

public enum Surahs {
    AL_FATIHA("سورة الفاتحة", "Al-Fatiha", 7),  // 1 - Surah Al-Fatiha
    AL_BAQARA("سورة البقرة", "Al-Baqara", 286),  // 2 - Surah Al-Baqara
    AAL_I_IMRAAN("سورة آل عمران", "Aal-i-Imraan", 200),  // 3 - Surah Al-Imraan
    AN_NISAA("سورة النساء", "An-Nisaa", 176),  // 4 - Surah Al-Nisaa
    AL_MAAIDA("سورة المائدة", "Al-Maaida", 120),  // 5 - Surah Al-Maaida
    AL_ANAAM("سورة الأنعام", "Al-An'aam", 165),  // 6 - Surah Al-An'aam
    AL_ARAAF("سورة الأعراف", "Al-A'raaf", 206),  // 7 - Surah Al-A'raaf
    AL_ANFAAL("سورة الأنفال", "Al-Anfaal", 75),  // 8 - Surah Al-Anfaal
    AT_TAWBA("سورة التوبة", "At-Tawba", 129),  // 9 - Surah Al-Tawba
    YUNUS("سورة يونس", "Yunus", 109),  // 10 - Surah Yunus
    HUD("سورة هود", "Hud", 123),  // 11 - Surah Hud
    YUSUF("سورة يوسف", "Yusuf", 111),  // 12 - Surah Yusuf
    AR_RAD("سورة الرعد", "Ar-R'ad", 43),  // 13 - Surah Al-Rad
    IBRAHIM("سورة إبراهيم", "Ibrahim", 52),  // 14 - Surah Ibrahim
    AL_HIJR("سورة الحجر", "Al-Hijr", 99),  // 15 - Surah Al-Hijr
    AN_NAHL("سورة النحل", "An-Nahl", 128),  // 16 - Surah An-Nahl
    AL_ISRAA("سورة الإسراء", "Al-Israa", 111),  // 17 - Surah Al-Israa
    AL_KAHF("سورة الكهف", "Al-Kahf", 110),  // 18 - Surah Al-Kahf
    MARYAM("سورة مريم", "Maryam", 98),  // 19 - Surah Maryam
    TAAHAA("سورة طه", "Taa-Haa", 135),  // 20 - Surah Taa-Haa
    AL_ANBIYAA("سورة الأنبياء", "Al-Anbiyaa", 112),  // 21 - Surah Al-Anbiyaa
    AL_HAJJ("سورة الحج", "Al-Hajj", 78),  // 22 - Surah Al-Hajj
    AL_MUMINOON("سورة المؤمنون", "Al-Muminoon", 118),  // 23 - Surah Al-Muminoon
    AN_NOOR("سورة النور", "An-Noor", 64),  // 24 - Surah Al-Noor
    AL_FURQAAN("سورة الفرقان", "Al-Furqaan", 77),  // 25 - Surah Al-Furqaan
    ASH_SHUARAA("سورة الشعراء", "Ash-Shuaraa", 227),  // 26 - Surah Ash-Shuaraa
    AN_NAML("سورة النمل", "An-Naml", 93),  // 27 - Surah Al-Naml
    AL_QASAS("سورة القصص", "Al-Qasas", 88),  // 28 - Surah Al-Qasas
    AL_ANKABOOT("سورة العنكبوت", "Al-Ankaboot", 69),  // 29 - Surah Al-Ankaboot
    AR_ROOM("سورة الروم", "Ar-Room", 60),  // 30 - Surah Al-Room
    LUQMAN("سورة لقمان", "Luqman", 34),  // 31 - Surah Luqman
    AS_SAJDA("سورة السجدة", "As-Sajda", 30),  // 32 - Surah Al-Sajda
    AL_AHZAAB("سورة الأحزاب", "Al-Ahzaab", 73),  // 33 - Surah Al-Ahzaab
    SABA("سورة سبإ", "Saba", 54),  // 34 - Surah Saba
    FAATIR("سورة فاطر", "Faatir", 45),  // 35 - Surah Faatir
    YASEEN("سورة يس", "Yaseen", 83),  // 36 - Surah Yaseen
    AS_SAAFFAAT("سورة الصافات", "As-Saaffaat", 182),  // 37 - Surah Al-Saaffaat
    SAAD("سورة ص", "Saad", 88),  // 38 - Surah Saad
    AZ_ZUMAR("سورة الزمر", "Az-Zumar", 75),  // 39 - Surah Al-Zumar
    GHAFIR("سورة غافر", "Ghafir", 85),  // 40 - Surah Ghaafir
    FUSSILAT("سورة فصلت", "Fussilat", 54),  // 41 - Surah Fussilat
    ASH_SHURA("سورة الشورى", "Ash-Shura", 53),  // 42 - Surah Ash-Shura
    AZ_ZUKHRUF("سورة الزخرف", "Az-Zukhruf", 89),  // 43 - Surah Al-Zukhruf
    AD_DUKHAAN("سورة الدخان", "Ad-Dukhaan", 59),  // 44 - Surah Al-Dukhaan
    AL_JAATHIYA("سورة الجاثية", "Al-Jaathiya", 37),  // 45 - Surah Al-Jaathiya
    AL_AHQAF("سورة الأحقاف", "Al-Ahqaf", 35),  // 46 - Surah Al-Ahqaf
    MUHAMMAD("سورة محمد", "Muhammad", 38),  // 47 - Surah Muhammad
    AL_FATH("سورة الفتح", "Al-Fath", 29),  // 48 - Surah Al-Fath
    AL_HUJURAAT("سورة الحجرات", "Al-Hujuraat", 18),  // 49 - Surah Al-Hujuraat
    QAAF("سورة ق", "Qaaf", 45),  // 50 - Surah Qaaf
    ADH_DHAARIYAT("سورة الذاريات", "Adh-Dhaariyat", 60),  // 51 - Surah Al-Dhariyat
    AT_TUR("سورة الطور", "At-Tur", 49),  // 52 - Surah Al-Tur
    AN_NAJM("سورة النجم", "An-Najm", 62),  // 53 - Surah Al-Najm
    AL_QAMAR("سورة القمر", "Al-Qamar", 55),  // 54 - Surah Al-Qamar
    AL_RAHMAAN("سورة الرحمن", "Al-Rahmaan", 78),  // 55 - Surah Al-Rahmaan
    AL_WAAQIA("سورة الواقعة", "Al-Waaqia", 96),  // 56 - Surah Al-Waaqia
    AL_HADID("سورة الحديد", "Al-Hadid", 29),  // 57 - Surah Al-Hadid
    AL_MUJAADILA("سورة المجادلة", "Al-Mujadila", 22),  // 58 - Surah Al-Mujadila
    AL_HASHR("سورة الحشر", "Al-Hashr", 24),  // 59 - Surah Al-Hashr
    AL_MUMTAHANA("سورة الممتحنة", "Al-Mumtahana", 13),  // 60 - Surah Al-Mumtahana
    AS_SAFF("سورة الصف", "As-Saff", 14),  // 61 - Surah Al-Saff
    AL_JUMUA("سورة الجمعة", "Al-Jumu'a", 11),  // 62 - Surah Al-Jumu'a
    AL_MUNAAFIQOON("سورة المنافقون", "Al-Munaafiqoon", 11),  // 63 - Surah Al-Munaafiqoon
    AT_TAGHAABUN("سورة التغابن", "At-Taghaabun", 18),  // 64 - Surah Al-Taghaabun
    AT_TALAAQ("سورة الطلاق", "At-Talaaq", 12),  // 65 - Surah Al-Talaaq
    AT_TAHRIM("سورة التحريم", "At-Tahrim", 12),  // 66 - Surah Al-Tahrim
    AL_MULK("سورة الملك", "Al-Mulk", 30),  // 67 - Surah Al-Mulk
    AL_QALAM("سورة القلم", "Al-Qalam", 52),  // 68 - Surah Al-Qalam
    AL_HAAQQA("سورة الحاقة", "Al-Haaqqa", 52),  // 69 - Surah Al-Haaqqa
    AL_MAAARIJ("سورة المعارج", "Al-Ma'aarij", 44),  // 70 - Surah Al-Ma'aarij
    NOOH("سورة نوح", "Nooh", 28),  // 71 - Surah Nooh
    AL_JINN("سورة الجن", "Al-Jinn", 28),  // 72 - Surah Al-Jinn
    AL_MUZZAMMIL("سورة المزمل", "Al-Muzzammil", 20),  // 73 - Surah Al-Muzzammil
    AL_MUDDATHTHIRIYAH("سورة المدثر", "Al-Muddaththiriyah", 56),  // 74 - Surah Al-Muddaththiriyah
    AL_QIYAAMA("سورة القيامة", "Al-Qiyaama", 40),  // 75 - Surah Al-Qiyaama
    AL_INSAAN("سورة الانسان", "Al-Insaan", 31),  // 76 - Surah Al-Insaan
    AL_MURSALAAT("سورة المرسلات", "Al-Mursalaat", 50),  // 77 - Surah Al-Mursalaat
    AN_NABA("سورة النبإ", "An-Naba", 40),  // 78 - Surah An-Naba
    AN_NAAZIAAT("سورة النازعات", "An-Naazi'aat", 46),  // 79 - Surah An-Naazi'aat
    ABASA("سوررة عبس", "Abasa", 42),  // 80 - Surah Abasa
    AT_TAKWIR("سورة التكوير", "At-Takwir", 29),  // 81 - Surah Al-Takwir
    AL_INFITAAR("سورة الانفطار", "Al-Infitaar", 19),  // 82 - Surah Al-Infitaar
    AL_MUTAFFIFIN("سورة المطففين", "Al-Muthaffifin", 36),  // 83 - Surah Al-Muthaffifin
    AL_INSHIQAAQ("سورة الانشقاق", "Al-Inshiqaaq", 25),  // 84 - Surah Al-Inshiqaaq
    AL_BUROOJ("سورة البروج", "Al-Burooj", 22),  // 85 - Surah Al-Burooj
    AL_TAARIQ("سورة الطارق", "Al-Taariq", 17),  // 86 - Surah Al-Taariq
    AL_ALAA("سورة الاعلى", "Al-A'laa", 19),  // 87 - Surah Al-A'laa
    AL_GHAASHIYA("سورة الغاشية", "Al-Ghaashiya", 26),  // 88 - Surah Al-Ghaashiya
    AL_FAJR("سورة الفجر", "Al-Fajr", 30),  // 89 - Surah Al-Fajr
    AL_BALAD("سورة البلد", "Al-Balad", 20),  // 90 - Surah Al-Balad
    ASH_SHAMS("سورة الشمس", "Ash-Shams", 15),  // 91 - Surah Al-Shams
    AL_LAILA("سورة الليل", "Al-Lail", 21),  // 92 - Surah Al-Lail
    AD_DUHAA("سورة الضحى", "Ad-Dhuhaa", 11),  // 93 - Surah Al-Dhuhaa
    ASH_SHARH("سورة الشرح", "Ash-Sharh", 8),  // 94 - Surah Al-Sharh
    AT_TIN("سورة التين", "At-Tin", 8),  // 95 - Surah Al-Tin
    AL_ALAQ("سورة العلق", "Al-Alaq", 19),  // 96 - Surah Al-Alaq
    AL_QADR("سورة القدر", "Al-Qadr", 5),  // 97 - Surah Al-Qadr
    AL_BAYYINA("سورة البينة", "Al-Bayyina", 8),  // 98 - Surah Al-Bayyina
    AL_ZALZALA("سورة الزلزلة", "Al-Zalzala", 8),  // 99 - Surah Al-Zalzala
    AL_AADIYAAT("سورة العاديات", "Al-Aadiyaat", 11),  // 100 - Surah Al-Aadiyaat
    AL_QAARIA("سورة القارعة", "Al-Qaari'a", 11),  // 101 - Surah Al-Qaari'a
    AT_TAKAATHUR("سورة التكاثر", "At-Takaathur", 8),  // 102 - Surah Al-Takaathur
    AL_ASR("سورة العصر", "Al-Asr", 3),  // 103 - Surah Al-Asr
    AL_HUMAZA("سورة الهمزة", "Al-Humaza", 9),  // 104 - Surah Al-Humaza
    AL_FIL("سورة الفيل", "Al-Fil", 5),  // 105 - Surah Al-Fil
    QURAISH("سورة القريش", "Quraish", 4),  // 106 - Surah Al-Quraish
    AL_MAAUN("سورة الماعون", "Al-Maa'un", 7),  // 107 - Surah Al-Maa'un
    AL_KAWTHAR("سورة الكوثر", "Al-Kawthar", 3),  // 108 - Surah Al-Kawthar
    AL_KAAFIROON("سورة الكافرون", "Al-Kaafiroon", 6),  // 109 - Surah Al-Kaafiroon
    AN_NASR("سورة النصؤ", "An-Nasr", 3),  // 110 - Surah An-Nasr
    AL_MASAD("سورة المسد", "Al-Masad", 5),  // 111 - Surah Al-Masad
    AL_IKHLAAS("سورة الأخلاص", "Al-Ikhlaas", 4),  // 112 - Surah Al-Ikhlaas
    AL_FALAQ("سورة الفلق", "Al-Falaq", 5),  // 113 - Surah Al-Falaq
    AN_NAAS("سورة الناس", "An-Nas", 6)  // 114 - Surah An-Nas
    // END OF SURAS :D
    ;
    private final String arabicName;
    private final String englishName;
    private final short numberOfAyahs;

    Surahs(final String arabicName,
           final String englishName,
           final int numberOfAyahs) {
        this.arabicName = arabicName;
        this.englishName = englishName;
        this.numberOfAyahs = (short) numberOfAyahs;
    }

    public static Surahs[] getAvailableSurahsForOffset(final int offset) {
        final var s = new ArrayList<Surahs>();
        for (final var surah : Surahs.values()) {
            if (surah.getNumber() > offset) {
                s.add(surah);
            }
        }
        return s.toArray(new Surahs[0]);
    }

    public String getArabicName() {
        return arabicName;
    }

    public String getEnglishName() {
        return englishName;
    }

    public int getNumberOfAyahs() {
        return numberOfAyahs;
    }
    public int getNumber() {
        return this.ordinal() + 1;
    }

    /**
     * Get the ayah number in all quran.
     * @param ayahNumber the ayah number in the surah
     * @return the ayah number in the quran
     */
    public int getFactAyahNumber(final int ayahNumber) {
        var factAyahNumber = 0;
        final var surahs = Surahs.values();
        for (var i = 0; i < this.ordinal(); i++) {
            factAyahNumber += surahs[i].getNumberOfAyahs();
        }
        factAyahNumber += ayahNumber;
        return factAyahNumber;
    }
}
