quran-meta
Version:
Library with meta data and functionality related to Holy Quran
4,166 lines • 79 kB
JavaScript
//#region src/lists/WarshLists.ts
const HizbQuarterList$1 = [
0,
1,
32,
50,
66,
82,
98,
112,
130,
148,
164,
183,
195,
208,
224,
238,
248,
258,
269,
278,
289,
307,
325,
343,
366,
383,
405,
425,
445,
463,
478,
498,
505,
516,
528,
549,
565,
578,
591,
605,
621,
639,
657,
671,
680,
692,
710,
718,
736,
751,
766,
780,
803,
826,
849,
870,
885,
901,
917,
931,
941,
957,
984,
1002,
1020,
1043,
1072,
1098,
1112,
1127,
1144,
1167,
1184,
1203,
1223,
1243,
1257,
1272,
1284,
1299,
1314,
1332,
1350,
1362,
1379,
1394,
1417,
1439,
1461,
1483,
1501,
1518,
1538,
1560,
1582,
1608,
1631,
1651,
1675,
1699,
1714,
1730,
1745,
1766,
1783,
1808,
1856,
1907,
1936,
1957,
1977,
1996,
2017,
2035,
2057,
2084,
2104,
2133,
2161,
2176,
2197,
2218,
2239,
2270,
2308,
2349,
2402,
2429,
2456,
2483,
2512,
2533,
2568,
2594,
2612,
2629,
2651,
2670,
2705,
2745,
2785,
2809,
2823,
2839,
2849,
2871,
2895,
2928,
2977,
3038,
3108,
3159,
3180,
3211,
3237,
3259,
3277,
3299,
3324,
3343,
3361,
3382,
3413,
3435,
3458,
3485,
3508,
3533,
3547,
3558,
3578,
3587,
3607,
3624,
3646,
3669,
3694,
3727,
3759,
3804,
3865,
3927,
3984,
4015,
4059,
4081,
4100,
4123,
4143,
4163,
4188,
4214,
4231,
4252,
4270,
4290,
4307,
4332,
4372,
4422,
4464,
4491,
4510,
4535,
4558,
4581,
4593,
4606,
4637,
4686,
4737,
4788,
4841,
4879,
4937,
5033,
5069,
5083,
5096,
5114,
5134,
5155,
5174,
5190,
5206,
5219,
5268,
5339,
5393,
5428,
5473,
5529,
5586,
5649,
5729,
5790,
5875,
5924,
6001,
6068,
6134,
6215
];
const JuzList$1 = [
0,
1,
148,
258,
383,
516,
639,
751,
901,
1043,
1203,
1332,
1483,
1651,
1808,
2035,
2218,
2483,
2670,
2871,
3211,
3382,
3558,
3727,
4081,
4252,
4491,
4686,
5083,
5219,
5649,
6215
];
const ManzilList$1 = [
0,
1,
668,
1369,
2035,
2928,
3783,
4611,
6215
];
const PageList$1 = [
0,
1,
8,
12,
23,
31,
36,
44,
55,
64,
68,
76,
83,
90,
95,
100,
108,
112,
119,
126,
133,
141,
148,
152,
160,
170,
176,
183,
188,
193,
197,
203,
208,
216,
221,
225,
230,
236,
239,
243,
251,
254,
258,
263,
266,
271,
276,
281,
288,
289,
293,
302,
308,
315,
322,
330,
338,
344,
353,
362,
369,
375,
383,
393,
401,
408,
414,
425,
433,
441,
446,
450,
458,
466,
473,
479,
487,
493,
499,
504,
507,
512,
516,
519,
526,
530,
537,
543,
551,
557,
566,
571,
578,
583,
586,
593,
597,
605,
613,
619,
626,
632,
639,
646,
654,
662,
667,
671,
674,
678,
682,
687,
693,
701,
706,
711,
715,
720,
727,
734,
740,
747,
753,
760,
765,
773,
778,
783,
790,
799,
809,
818,
826,
835,
843,
850,
858,
864,
872,
881,
885,
892,
901,
909,
915,
921,
928,
933,
937,
942,
948,
957,
967,
978,
985,
992,
999,
1007,
1013,
1023,
1029,
1037,
1043,
1051,
1060,
1076,
1086,
1094,
1100,
1106,
1112,
1116,
1120,
1127,
1135,
1144,
1152,
1163,
1171,
1179,
1188,
1196,
1203,
1209,
1216,
1225,
1233,
1239,
1245,
1252,
1259,
1265,
1270,
1275,
1279,
1286,
1293,
1300,
1307,
1312,
1319,
1326,
1333,
1339,
1346,
1351,
1357,
1362,
1369,
1375,
1383,
1389,
1394,
1402,
1411,
1422,
1430,
1439,
1447,
1457,
1466,
1475,
1483,
1490,
1497,
1506,
1515,
1523,
1531,
1539,
1548,
1558,
1566,
1575,
1586,
1595,
1603,
1613,
1621,
1629,
1636,
1642,
1651,
1662,
1668,
1677,
1685,
1694,
1702,
1710,
1716,
1724,
1730,
1739,
1745,
1753,
1761,
1767,
1775,
1780,
1789,
1798,
1808,
1823,
1839,
1859,
1878,
1898,
1913,
1921,
1933,
1941,
1949,
1961,
1971,
1979,
1986,
1994,
2e3,
2009,
2017,
2025,
2035,
2042,
2052,
2062,
2073,
2084,
2093,
2101,
2110,
2121,
2131,
2139,
2149,
2160,
2165,
2172,
2179,
2189,
2197,
2205,
2218,
2227,
2238,
2250,
2260,
2274,
2287,
2301,
2314,
2327,
2346,
2360,
2385,
2399,
2412,
2424,
2435,
2445,
2459,
2472,
2483,
2493,
2507,
2518,
2527,
2540,
2554,
2563,
2572,
2583,
2594,
2599,
2609,
2615,
2622,
2630,
2638,
2647,
2656,
2664,
2670,
2687,
2697,
2712,
2730,
2745,
2760,
2775,
2789,
2799,
2809,
2816,
2820,
2825,
2831,
2840,
2845,
2848,
2853,
2862,
2871,
2883,
2894,
2906,
2918,
2928,
2946,
2966,
2988,
3011,
3039,
3064,
3087,
3111,
3134,
3154,
3167,
3176,
3190,
3200,
3211,
3219,
3232,
3244,
3253,
3261,
3269,
3277,
3284,
3292,
3299,
3308,
3319,
3326,
3333,
3342,
3350,
3359,
3367,
3375,
3382,
3389,
3400,
3410,
3420,
3429,
3437,
3446,
3455,
3465,
3475,
3483,
3492,
3498,
3509,
3518,
3528,
3534,
3543,
3550,
3558,
3563,
3571,
3578,
3582,
3590,
3601,
3608,
3615,
3623,
3632,
3640,
3649,
3658,
3666,
3673,
3685,
3693,
3700,
3712,
3727,
3740,
3754,
3770,
3783,
3807,
3834,
3859,
3885,
3909,
3936,
3965,
3980,
3990,
4006,
4025,
4047,
4057,
4062,
4071,
4081,
4088,
4095,
4104,
4115,
4122,
4129,
4138,
4148,
4156,
4163,
4172,
4181,
4189,
4199,
4207,
4217,
4226,
4235,
4244,
4252,
4260,
4268,
4273,
4280,
4289,
4301,
4308,
4319,
4331,
4342,
4356,
4370,
4383,
4399,
4416,
4436,
4455,
4467,
4476,
4486,
4495,
4504,
4510,
4518,
4525,
4537,
4545,
4555,
4564,
4573,
4579,
4587,
4592,
4597,
4604,
4611,
4626,
4646,
4662,
4686,
4707,
4728,
4745,
4763,
4789,
4806,
4830,
4851,
4873,
4895,
4919,
4947,
4974,
5009,
5035,
5058,
5066,
5072,
5078,
5083,
5089,
5094,
5103,
5107,
5113,
5120,
5128,
5133,
5139,
5146,
5155,
5163,
5170,
5177,
5186,
5195,
5200,
5207,
5214,
5219,
5232,
5246,
5266,
5292,
5309,
5337,
5364,
5394,
5408,
5428,
5441,
5456,
5473,
5492,
5520,
5547,
5573,
5593,
5618,
5649,
5679,
5705,
5734,
5774,
5805,
5828,
5857,
5884,
5907,
5934,
5965,
5993,
6019,
6045,
6070,
6096,
6114,
6131,
6155,
6172,
6186,
6200,
6215
];
const SajdaList$1 = [
1162,
1725,
1956,
2142,
2307,
2611,
2910,
3179,
3512,
3987,
4242,
4823,
5880,
6103
];
const SurahList$1 = [
[
-1,
1,
1,
1,
"",
false
],
[
1,
7,
1,
1,
"الفَاتِحة",
true
],
[
8,
285,
2,
1,
"البَقَرَة",
true
],
[
293,
200,
3,
1,
"آل عِمران",
true
],
[
493,
175,
4,
1,
"النِّسَاء",
true
],
[
668,
122,
5,
1,
"المَائدة",
true
],
[
790,
167,
6,
1,
"الأنعَام",
true
],
[
957,
206,
7,
1,
"الأعرَاف",
true
],
[
1163,
76,
8,
1,
"الأنفَال",
true
],
[
1239,
130,
9,
1,
"التوبَة",
true
],
[
1369,
109,
10,
1,
"يُونس",
true
],
[
1478,
121,
11,
1,
"هُود",
true
],
[
1599,
111,
12,
1,
"يُوسُف",
true
],
[
1710,
44,
13,
1,
"الرَّعد",
true
],
[
1754,
54,
14,
1,
"إبراهِيم",
true
],
[
1808,
99,
15,
1,
"الحِجر",
true
],
[
1907,
128,
16,
1,
"النَّحل",
true
],
[
2035,
110,
17,
1,
"الإسرَاء",
true
],
[
2145,
105,
18,
1,
"الكَهف",
true
],
[
2250,
99,
19,
1,
"مَريَم",
true
],
[
2349,
134,
20,
1,
"طه",
true
],
[
2483,
111,
21,
1,
"الأنبيَاء",
true
],
[
2594,
76,
22,
1,
"الحج",
true
],
[
2670,
119,
23,
1,
"المؤمنُون",
true
],
[
2789,
62,
24,
1,
"النور",
true
],
[
2851,
77,
25,
1,
"الفُرقَان",
true
],
[
2928,
226,
26,
1,
"الشعراء",
true
],
[
3154,
95,
27,
1,
"النَّمل",
true
],
[
3249,
88,
28,
1,
"القَصَص",
true
],
[
3337,
69,
29,
1,
"العَنكبُوت",
true
],
[
3406,
59,
30,
1,
"الرُّوم",
true
],
[
3465,
33,
31,
1,
"لُقمَان",
true
],
[
3498,
30,
32,
1,
"السَّجدة",
true
],
[
3528,
73,
33,
1,
"الأحزَاب",
true
],
[
3601,
54,
34,
1,
"سَبإ",
true
],
[
3655,
46,
35,
1,
"فَاطِر",
true
],
[
3701,
82,
36,
1,
"يسٓ",
true
],
[
3783,
182,
37,
1,
"الصَّافَات",
true
],
[
3965,
86,
38,
1,
"صٓ",
true
],
[
4051,
72,
39,
1,
"الزُّمَر",
true
],
[
4123,
84,
40,
1,
"غَافِر",
true
],
[
4207,
53,
41,
1,
"فُصِّلَت",
true
],
[
4260,
50,
42,
1,
"الشُّوري",
true
],
[
4310,
89,
43,
1,
"الزُّخرُف",
true
],
[
4399,
56,
44,
1,
"الدُّخان",
true
],
[
4455,
36,
45,
1,
"الجاثِية",
true
],
[
4491,
34,
46,
1,
"الأحقَاف",
true
],
[
4525,
39,
47,
1,
"مُحمد",
true
],
[
4564,
29,
48,
1,
"الفَتح",
true
],
[
4593,
18,
49,
1,
"الحُجُرَات",
true
],
[
4611,
45,
50,
1,
"قٓ",
true
],
[
4656,
60,
51,
1,
"الذَّاريَات",
true
],
[
4716,
47,
52,
1,
"الطُّور",
true
],
[
4763,
61,
53,
1,
"النَّجم",
true
],
[
4824,
55,
54,
1,
"القَمَر",
true
],
[
4879,
77,
55,
1,
"الرَّحمٰن",
true
],
[
4956,
99,
56,
1,
"الوَاقِعة",
true
],
[
5055,
28,
57,
1,
"الحدِيد",
true
],
[
5083,
21,
58,
1,
"المُجَادلة",
true
],
[
5104,
24,
59,
1,
"الحَشر",
true
],
[
5128,
13,
60,
1,
"المُمتَحنَة",
true
],
[
5141,
14,
61,
1,
"الصَّف",
true
],
[
5155,
11,
62,
1,
"الجُمعَة",
true
],
[
5166,
11,
63,
1,
"المُنَافِقُونَ",
true
],
[
5177,
18,
64,
1,
"التغَابُن",
true
],
[
5195,
12,
65,
1,
"الطَّلَاق",
true
],
[
5207,
12,
66,
1,
"التَّحرِيم",
true
],
[
5219,
31,
67,
1,
"المُلك",
true
],
[
5250,
52,
68,
1,
"القَلَم",
true
],
[
5302,
52,
69,
1,
"الحَاقة",
true
],
[
5354,
44,
70,
1,
"المَعَارج",
true
],
[
5398,
30,
71,
1,
"نُوح",
true
],
[
5428,
28,
72,
1,
"الجِن",
true
],
[
5456,
18,
73,
1,
"المُزمل",
true
],
[
5474,
55,
74,
1,
"المُدثر",
true
],
[
5529,
39,
75,
1,
"القِيَامة",
true
],
[
5568,
31,
76,
1,
"الإنسَان",
true
],
[
5599,
50,
77,
1,
"المُرسَلات",
true
],
[
5649,
40,
78,
1,
"النَّبَإ",
true
],
[
5689,
45,
79,
1,
"النَّازعَات",
true
],
[
5734,
42,
80,
1,
"عَبَسَ",
true
],
[
5776,
29,
81,
1,
"التَّكوير",
true
],
[
5805,
19,
82,
1,
"الانفِطَار",
true
],
[
5824,
36,
83,
1,
"المُطَففين",
true
],
[
5860,
25,
84,
1,
"الانشِقَاق",
true
],
[
5885,
22,
85,
1,
"البُرُوج",
true
],
[
5907,
17,
86,
1,
"الطَّارق",
true
],
[
5924,
19,
87,
1,
"الأعلى",
true
],
[
5943,
26,
88,
1,
"الغَاشِية",
true
],
[
5969,
32,
89,
1,
"الفَجر",
true
],
[
6001,
20,
90,
1,
"البَلَد",
true
],
[
6021,
15,
91,
1,
"الشَّمس",
true
],
[
6036,
21,
92,
1,
"اللَّيل",
true
],
[
6057,
11,
93,
1,
"الضُّحى",
true
],
[
6068,
8,
94,
1,
"الشَّرح",
true
],
[
6076,
8,
95,
1,
"التِّين",
true
],
[
6084,
20,
96,
1,
"العَلَق",
true
],
[
6104,
5,
97,
1,
"القَدر",
true
],
[
6109,
8,
98,
1,
"البَينَة",
true
],
[
6117,
9,
99,
1,
"الزَّلزَلة",
true
],
[
6126,
11,
100,
1,
"العَاديَات",
true
],
[
6137,
10,
101,
1,
"القَارعَة",
true
],
[
6147,
8,
102,
1,
"التَّكاثُر",
true
],
[
6155,
3,
103,
1,
"العَصر",
true
],
[
6158,
9,
104,
1,
"الهُمَزة",
true
],
[
6167,
5,
105,
1,
"الفِيل",
true
],
[
6172,
5,
106,
1,
"قُرَيش",
true
],
[
6177,
6,
107,
1,
"المَاعُون",
true
],
[
6183,
3,
108,
1,
"الكَوثر",
true
],
[
6186,
6,
109,
1,
"الكافِرون",
true
],
[
6192,
3,
110,
1,
"النَّصر",
true
],
[
6195,
5,
111,
1,
"المَسَد",
true
],
[
6200,
4,
112,
1,
"الإخلَاص",
true
],
[
6204,
5,
113,
1,
"الفَلَق",
true
],
[
6209,
6,
114,
1,
"النَّاس",
true
],
[
6215,
1,
1,
1,
"",
false
]
];
const RukuList$1 = [
0,
1,
8,
14,
27,
36,
46,
53,
66,
68,
78,
90,
93,
103,
110,
119,
128,
136,
148,
154,
159,
170,
174,
183,
189,
195,
203,
216,
224,
227,
234,
237,
241,
251,
254,
259,
264,
267,
273,
280,
288,
290,
293,
302,
313,
323,
334,
346,
355,
363,
372,
383,
394,
402,
413,
422,
436,
441,
448,
464,
473,
482,
493,
503,
507,
515,
518,
526,
535,
542,
551,
562,
568,
579,
583,
588,
592,
596,
604,
607,
618,
627,
633,
644,
654,
663,
668,
674,
680,
689,
696,
704,
713,
720,
723,
736,
747,
756,
759,
770,
778,
785,
790,
801,
811,
821,
832,
841,
846,
851,
860,
873,
881,
885,
891,
901,
912,
920,
931,
935,
941,
945,
957,
966,
981,
986,
995,
1003,
1009,
1014,
1020,
1028,
1040,
1049,
1055,
1064,
1082,
1085,
1098,
1104,
1108,
1114,
1119,
1128,
1138,
1145,
1163,
1173,
1182,
1191,
1200,
1208,
1212,
1222,
1227,
1233,
1239,
1245,
1255,
1263,
1268,
1276,
1281,
1298,
1305,
1312,
1320,
1329,
1339,
1350,
1358,
1362,
1369,
1379,
1389,
1399,
1409,
1422,
1429,
1439,
1451,
1461,
1472,
1478,
1486,
1502,
1513,
1527,
1537,
1545,
1560,
1573,
1587,
1599,
1605,
1619,
1628,
1634,
1641,
1648,
1656,
1667,
1678,
1692,
1703,
1710,
1718,
1730,
1737,
1742,
1748,
1754,
1762,
1769,
1777,
1783,
1790,
1797,
1808,
1823,
1833,
1852,
1868,
1887,
1907,
1916,
1928,
1932,
1941,
1947,
1957,
1967,
1972,
1977,
1983,
1990,
1996,
2007,
2017,
2026,
2035,
2045,
2057,
2065,
2075,
2087,
2095,
2105,
2112,
2119,
2128,
2135,
2145,
2157,
2162,
2168,
2176,
2188,
2193,
2197,
2203,
2214,
2226,
2242,
2250,
2264,
2289,
2300,
2315,
2333,
2349,
2372,
2402,
2424,
2437,
2451,
2461,
2475,
2483,
2493,
2512,
2524,
2533,
2557,
2575,
2594,
2604,
2614,
2617,
2625,
2630,
2640,
2649,
2656,
2664,
2670,
2692,
2702,
2721,
2748,
2763,
2789,
2799,
2809,
2815,
2823,
2828,
2837,
2844,
2848,
2851,
2860,
2871,
2885,
2895,
2911,
2928,
2936,
2960,
2980,
2997,
3032,
3050,
3068,
3087,
3103,
3119,
3154,
3168,
3185,
3200,
3211,
3222,
3238,
3249,
3261,
3269,
3277,
3291,
3299,
3309,
3324,
3337,
3349,
3358,
3367,
3381,
3388,
3400,
3406,
3415,
3425,
3432,
3445,
3458,
3465,
3475,
3483,
3498,
3509,
3520,
3528,
3536,
3548,
3555,
3558,
3568,
3580,
3586,
3596,
3601,
3610,
3622,
3631,
3637,
3646,
3655,
3662,
3669,
3681,
3692,
3701,
3712,
3732,
3750,
3767,
3783,
3804,
3857,
3896,
3921,
3965,
3978,
3990,
4004,
4028,
4051,
4061,
4071,
4081,
4089,
4100,
4111,
4118,
4123,
4131,
4143,
4150,
4160,
4173,
4183,
4191,
4200,
4207,
4214,
4224,
4231,
4238,
4250,
4260,
4267,
4277,
4287,
4300,
4310,
4324,
4334,
4344,
4354,
4366,
4377,
4399,
4427,
4439,
4455,
4465,
4475,
4480,
4491,
4500,
4510,
4516,
4525,
4537,
4545,
4554,
4564,
4574,
4581,
4590,
4593,
4603,
4611,
4626,
4640,
4656,
4679,
4702,
4716,
4742,
4763,
4788,
4794,
4824,
4846,
4864,
4879,
4902,
4923,
4956,
4996,
5033,
5055,
5065,
5073,
5079,
5083,
5089,
5096,
5104,
5114,
5121,
5128,
5134,
5141,
5150,
5155,
5163,
5166,
5174,
5177,
5187,
5195,
5202,
5207,
5214,
5219,
5234,
5250,
5283,
5302,
5339,
5354,
5389,
5398,
5418,
5428,
5447,
5456,
5473,
5474,
5505,
5529,
5558,
5568,
5590,
5599,
5639,
5649,
5679,
5689,
5715,
5734,
5776,
5805,
5824,
5860,
5885,
5907,
5924,
5943,
5969,
6001,
6021,
6036,
6057,
6068,
6076,
6084,
6104,
6109,
6117,
6126,
6137,
6147,
6155,
6158,
6167,
6172,
6177,
6183,
6186,
6192,
6195,
6200,
6204,
6209,
6215
];
/**
* Warsh riwaya metadata
*/
const WarshMeta = {
riwayaName: "Warsh",
numAyahs: 6214,
numSurahs: 114,
numPages: 604,
numJuzs: 30,
numHizbs: 60,
numRubAlHizbs: 240,
numThumunAlHizbs: 480,
numRubsInJuz: 8,
numSajdas: 14,
numRukus: 556,
numManzils: 7
};
const WarshLists = {
meta: WarshMeta,
HizbQuarterList: HizbQuarterList$1,
JuzList: JuzList$1,
ManzilList: ManzilList$1,
PageList: PageList$1,
RukuList: RukuList$1,
SajdaList: SajdaList$1,
SurahList: SurahList$1
};
//#endregion
//#region src/lists/types.ts
const parts = {
surah: "SurahList",
juz: "JuzList",
rubAlHizb: "HizbQuarterList",
thumunAlHizb: "HizbEighthList",
page: "PageList",
manzil: "ManzilList",
ruku: "RukuList"
};
//#endregion
//#region src/lists/getList.ts
function toPartFormatter(type, list) {
return type === "surah" ? ([startAyahId, ayahCount]) => ({
startAyahId,
ayahCount
}) : (ayahId, index) => {
return {
startAyahId: ayahId,
ayahCount: list[index + 2] - ayahId
};
};
}
/**
* Retrieves a formatted list of Quran parts based on the specified type.
* @param name - The type of parts to retrieve (e.g., juz, hizb, rub)
* @param data - The Lists object for the riwaya.
* @returns An array of formatted part blocks, excluding the first and last elements
*/
function generatePartBlocks$1(name, data) {
if (!parts[name]) throw new Error(`Invalid part type: ${name}`);
const listName = parts[name];
const list = data[listName];
if (!list) return null;
if (!Array.isArray(list)) throw new TypeError(`Expected array for ${String(listName)}`);
return list.slice(1, -1).map(toPartFormatter(name, list));
}
const getList$1 = (name, lists) => {
if (!parts[name]) throw new Error(`Invalid list name: ${name}`);
const listName = parts[name];
if (listName in lists) return lists[listName];
throw new Error(`List ${String(listName)} not found in ${lists.meta.riwayaName} riwaya`);
};
function getListNormalised$1(name, lists) {
const list = getList$1(name, lists);
return list.slice(1, list.length - 1).map(toPartFormatter(name, list));
}
//#endregion
//#region src/types.ts
/**
* The maximum number of ayahs (verses) that can exist in any surah (chapter) of the Quran.
* This maximum occurs in Surah Al-Baqarah (2), which has 286 ayahs.
*/
const maxAyahsInSurah = 286;
//#endregion
//#region src/validation.ts
/**
* Validates if the provided value is a valid Surah number.
*
* @param surah - The value to validate, can be a Surah object, number, or unknown type
* @throws TypeError When the provided value is not an integer
* @throws RangeError When the provided surah number is outside the valid range (1 to total number of surahs)
* @remarks This is a type assertion function that ensures the input is a valid Surah
*/
function checkValidSurah$1(surah, meta$1) {
if (typeof surah !== "number" || !Number.isInteger(surah)) throw new TypeError("Ayah ID must be an integer");
if (!isValidSurah$1(surah, meta$1)) throw new RangeError("Surah must be between 1 and " + meta$1.numSurahs);
}
/**
* Validates if the given surah and ayah numbers form a valid combination.
* @param surah - The surah number or Surah object to validate
* @param ayah - The ayah number or AyahNo object to validate
* @throws Error If the surah-ayah combination is invalid
*/
function checkValidSurahAyah$1(surah, ayah, data) {
checkValidSurahAyahPair$1([surah, ayah], data);
}
/**
* Validates that a surah-ayah pair contains valid values
* @param surahAyah - A tuple containing surah number/object and ayah number
* @throws RangeError If ayah number is not between 1 and the maximum ayah count for the given surah
* @throws If surah is invalid (from checkValidSurah)
* @example
* ```ts
* checkValidSurahAyahPair([1, 7]) // Valid
* checkValidSurahAyahPair([1, 8]) // Throws RangeError
* ```
*/
function checkValidSurahAyahPair$1(surahAyah, data) {
const [surah, ayah] = surahAyah;
checkValidSurah$1(surah, data.meta);
if (typeof ayah !== "number" || !Number.isInteger(ayah) || ayah < 1 || ayah > getAyahCountInSurah$1(surah, data)) throw new RangeError("Ayah must be between 1 and " + getAyahCountInSurah$1(surah, data));
}
/**
* Validates and asserts that the given value is a valid Ayah ID.
* An Ayah ID must be an integer between 1 and the total number of Ayahs.
*
* @param ayahId - The value to check as an Ayah ID
* @throws TypeError If the value is not an integer
* @throws RangeError If the value is not within valid Ayah ID range
*/
function checkValidAyahId$1(ayahId, meta$1) {
if (typeof ayahId !== "number" || !Number.isInteger(ayahId)) throw new TypeError("Ayah ID must be an integer");
if (!isValidAyahId$1(ayahId, meta$1)) throw new RangeError("Ayah ID must be between 1 and " + meta$1.numAyahs);
}
/**
* Checks if a value is a valid Page number.
* @param x - The value to check
* @throws {@link TypeError} When the value is not an integer
* @throws {@link RangeError} When the value is not within valid page range (1 to numPages)
* @remarks This is a type assertion function that ensures a value is a valid Page number
*/
function checkValidPage$1(x, meta$1) {
if (typeof x !== "number" || !Number.isInteger(x)) throw new TypeError("Page must be an integer");
if (!isValidPage$1(x, meta$1)) throw new RangeError("Page must be between 1 and " + meta$1.numPages);
}
/**
* Type guard that checks if a value is a valid Juz number.
* Throws TypeError if value is not an integer.
* Throws RangeError if value is outside valid Juz range.
*
* @param x - Value to check
* @throws {@link TypeError} If value is not an integer
* @throws {@link RangeError} If value is not between 1 and the total number of Juz
*/
function checkValidJuz$1(x, meta$1) {
if (typeof x !== "number" || !Number.isInteger(x)) throw new TypeError("Juz must be an integer");
if (!isValidJuz$1(x, meta$1)) throw new RangeError("Juz must be between 1 and " + meta$1.numJuzs);
}
/**
* Type guard that checks if a value is a valid Ruku number.
* @param x - The value to check
* @throws {@link TypeError} If the value is not an integer number
* @throws {@link RangeError} If the number is not within valid Ruku range
* @example
* ```ts
* checkValidRuku(5); // OK
* checkValidRuku("5"); // Throws TypeError
* checkValidRuku(999); // Throws RangeError
* ```
*/
function checkValidRuku$1(x, meta$1) {
if (typeof x !== "number" || !Number.isInteger(x)) throw new TypeError("Ruku must be an integer");
if (!isValidRuku$1(x, meta$1)) throw new RangeError("Ruku must be between 1 and " + meta$1.numRukus);
}
/**
* Type guard that checks if a value is a valid Manzil number.
* @param x - The value to check
* @throws {@link TypeError} If the value is not an integer
* @throws {@link RangeError} If the value is not within valid Manzil range (1 to max manzils)
* @remarks This is an assertion function that ensures the input is a valid Manzil type
*/
function checkValidManzil$1(x, meta$1) {
if (typeof x !== "number" || !Number.isInteger(x)) throw new TypeError("Manzil must be an integer");
if (!isValidManzil$1(x, meta$1)) throw new RangeError("Manzil must be between 1 and " + meta$1.numManzils);
}
//#endregion
//#region src/getSurahInfo.ts
/**
* Gets the metadata for the specified Surah.
*
* @param surah - The Surah to get the metadata for.
* @param data - The Lists object containing SurahList.
* @returns The metadata for the specified Surah.
*/
function getSurahInfo$1(surah, data) {
checkValidSurah$1(surah, data.meta);
return data.SurahList[surah];
}
//#endregion
//#region src/getAyahCountInSurah.ts
/**
* Get the number of ayahs (verses) in the specified surah.
* @param surah - The surah number.
* @param data - The Lists object containing SurahList.
* @returns The number of ayahs in the specified surah.
*/
function getAyahCountInSurah$1(surah, data) {
return getSurahInfo$1(surah, data)[1];
}
//#endregion
//#region src/typeGuards.ts
/**
* Checks if the given value is a valid AyahId.
*
* @param x - The value to check.
* @returns True if the value is a valid AyahId, otherwise false.
*/
function isValidAyahId$1(x, meta$1) {
return Number.isInteger(x) && 1 <= x && x <= meta$1.numAyahs;
}
/**
* Checks if the given value is a valid Ayah number.
*
* @param x - The value to check.
* @returns True if the value is a valid Ayah number, otherwise false.
*/
function isValidAyahNo(x) {
return Number.isInteger(x) && 1 <= x && x <= maxAyahsInSurah;
}
/**
* Checks if the given value is a valid Surah number.
*
* @param x - The value to check.
* @returns `true` if the value is a valid Surah number, otherwise `false`.
*/
function isValidSurah$1(x, meta$1) {
return Number.isInteger(x) && 1 <= x && x <= meta$1.numSurahs;
}
/**
* Type guard function that checks if a tuple of two numbers represents a valid Surah and Ayah combination.
*
* @param x - A tuple containing [surahNumber, ayahNumber]
* @param lists - The Lists object for the riwaya
* @returns True if the tuple represents a valid Surah-Ayah combination, false otherwise
*
* @example
* ```ts
* isValidSurahAyah([1, 7], HafsLists) // true - Al-Fatiha has 7 ayahs
* isValidSurahAyah([1, 8], HafsLists) // false - Al-Fatiha only has 7 ayahs
* isValidSurahAyah([115, 1], HafsLists) // false - there are only 114 surahs
* ```
*/
function isValidSurahAyah$1(x, data) {
const [surah, ayah] = x;
if (!isValidSurah$1(surah, data.meta)) return false;
return Number.isInteger(ayah) && ayah >= 1 && ayah <= getAyahCountInSurah$1(surah, data);
}
/**
* Type guard that checks if a number is a valid Juz number
* @param x - The number to check
* @returns True if the number is an integer between 1 and the total number of Juzs (inclusive)
*/
function isValidJuz$1(x, meta$1) {
return Number.isInteger(x) && 1 <= x && x <= meta$1.numJuzs;
}
/**
* Type guard to check if a number is a valid Quran page number
* @param x - The number to check
* @returns True if the number is an integer between 1 and the total number of pages (inclusive)
*/
function isValidPage$1(x, meta$1) {
return Number.isInteger(x) && 1 <= x && x <= meta$1.numPages;
}
/**
* Type guard that checks if a value is a valid Ruku number
* @param x - The value to check
* @returns True if x is an integer between 1 and the total number of Rukus
* @example
* ```ts
* if (isValidRuku(5)) {
* // 5 is a valid Ruku number
* }
* ```
*/
function isValidRuku$1(x, meta$1) {
return Number.isInteger(x) && 1 <= x && x <= meta$1.numRukus;
}
/**
* Type guard to check if a value is a valid Manzil number
*
* @param x - The value to check
* @returns True if the value is an integer between 1 and the total number of Manzils
*
* @example
* ```ts
* if (isValidManzil(3)) {
* // value is a valid Manzil number
* }
* ```
*/
function isValidManzil$1(x, meta$1) {
return Number.isInteger(x) && 1 <= x && x <= meta$1.numManzils;
}
//#endregion
//#region src/ayahStringSplitter.ts
/**
* Splits a string representation of Quran reference into surah and ayah components
* @param str - The string to parse, expected format: "surah:ayah" or "surah:ayahStart-ayahEnd"
* @param isStrict - If true, enforces strict format checking. Defaults to true. If false, allows for additional characters in the string
* @returns A tuple containing surah number and either a single ayah number or a range [start, end]
* @throws {@link Error} If the string format is invalid
* @throws {@link Error} If surah number is invalid
* @throws {@link Error} If ayah number(s) are invalid
* @throws {@link sError} If ayah range is invalid (start should be less than end)
* @example
* ```ts
* ayahStringSplitter("2:255") // returns [2, 255]
* ayahStringSplitter("1:1-7") // returns [1, [1, 7]]
* ```
*/
function ayahStringSplitter$1(str, isStrict = true, data) {
const result = isStrict ? string2NumberSplitterStrict(str) : string2NumberSplitter(str);
if (!result) throw new Error("Invalid string format: " + str);
const { surahOrAyah: surahX, ayah, ayahTo } = result;
const meta$1 = data.meta;
if (!isValidSurah$1(surahX, meta$1)) throw new Error("Invalid ayah number: " + str);
const surah = surahX;
let ayahs;
if (ayahTo) {
checkValidAyahId$1(ayah, meta$1);
checkValidAyahId$1(ayahTo, meta$1);
if (ayah > ayahTo) throw new Error("Invalid ayah range: " + str);
ayahs = [ayah, ayahTo];
} else {
if (!isValidAyahNo(ayah)) throw new Error("Error in data " + str);
checkValidSurahAyah$1(surah, ayah, data);
ayahs = ayah;
}
return [surah, ayahs];
}
/**
* Splits a string containing surah and ayah numbers into their numeric components.
*
* @param str - Input string containing numbers separated by non-digits (e.g., "2:255" or "2 255" or "2-255")
* @returns An object containing the parsed numbers, or null if parsing fails
* - ayah: The ayah number if present
* - ayahTo: The ending ayah number if a range is specified
* - surahOrAyah: The surah number
* @example
* stringNumberSplitter("2:255") // returns \{ ayah: 255, ayahTo: 0, surahOrAyah: 2 \}
* stringNumberSplitter("2:255-260") // returns \{ ayah: 255, ayahTo: 260, surahOrAyah: 2 \}
* stringNumberSplitter("invalid") // returns null
*/
function string2NumberSplitter(str) {
const sr = /(?<surah>\d{1,3})\D*(?<ayah>\d{0,3})\D*(?<ayahTo>\d{0,3})/.exec(str);
if (sr?.groups && +sr.groups.surah > 0) {
const { ayah, ayahTo, surah } = sr.groups;
return {
surahOrAyah: +surah,
ayah: +ayah,
ayahTo: +ayahTo
};
}
return null;
}
/**
* Splits a string in the format "surah:ayah" or "surah:ayah-ayah" into its numeric components.
*
* @param str - The input string to parse in the format "surah:ayah" or "surah:ayah-ayah"
* @returns An object containing the parsed numbers:
* - surahOrAyah: The surah number
* - ayah: The first or only ayah number
* - ayahTo: The ending ayah number (if range specified)
* @throws {@link Error} When the input string format is invalid or contains non-numeric values
*
* @example
* string2NumberSplitterStrict("2:255") // returns \{ surahOrAyah: 2, ayah: 255, ayahTo: NaN \}
* string2NumberSplitterStrict("2:255-260") // returns \{ surahOrAyah: 2, ayah: 255, ayahTo: 260 \}
*/
function string2NumberSplitterStrict(str) {
let [surahStr, ayahsStr] = str.trim().split(":");
surahStr = surahStr.trim();
const surahX = parseInt(surahStr.trim(), 10);
if (isNaN(surahX)) throw new Error("Error in surah format " + str);
ayahsStr = ayahsStr.trim();
if (!ayahsStr) throw new Error("Error in data " + str);
let ayahs;
if (ayahsStr.includes("-")) ayahs = ayahsStr.split("-").map((a) => {
const ayahX = parseInt(a, 10);
if (isNaN(ayahX)) throw new Error("Error in surah format " + str);
return ayahX;
});
else {
const ayahX = parseInt(ayahsStr, 10);
if (isNaN(ayahX)) throw new Error("Error in surah format " + str);
ayahs = [ayahX, NaN];
}
return {
surahOrAyah: +surahX,
ayah: +ayahs[0],
ayahTo: +ayahs[1]
};
}
//#endregion
//#region src/findAyahIdBySurah.ts
/**
* Get the ayah ID for the given surah and ayah number.
* @param surah - The surah number.
* @param ayah - The ayah number within the surah.
* @param data - The Lists object containing SurahList.
* @returns The ayah ID for the given surah and ayah number.
*/
function findAyahIdBySurah$1(surah, ayah, data) {
checkValidSurahAyah$1(surah, ayah, data);
const [startAyahId] = data.SurahList[surah];
return startAyahId + ayah - 1;
}
//#endregion
//#region src/utils.ts
/**
* Performs a binary search on the given array to find the index of the specified element.
*
* @param ar - The array to search.
* @param el - The element to search for.
* @param compare_fn - An optional comparison function to use for the search. Defaults to a simple numeric comparison.
* @returns The index of the element if found, or a negative value indicating the insertion point if not found.
*/
function binarySearch(ar, el, compare_fn = (a, b) => a - b) {
let m = 0;
let n = ar.length - 1;
while (m <= n) {
const k = n + m >> 1;
const cmp = compare_fn(el, ar[k]);
if (cmp > 0) m = k + 1;
else if (cmp < 0) n = k - 1;
else return k;
}
return -m - 1;
}
//#endregion
//#region src/findJuzByAyahId.ts
/**
* Finds the Juz (part) of the Quran that contains the given Ayah (verse) ID.
*
* @param ayahId - The ID of the Ayah (verse) to find the Juz for.
* @param data - The Lists object containing JuzList.
* @returns The Juz (part) of the Quran that contains the given Ayah ID.
*/
function findJuzByAyahId$1(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
const jj = binarySearch(data.JuzList, ayahId);
return jj < 0 ? -jj - 2 : jj;
}
//#endregion
//#region src/findJuz.ts
/**
* Finds the Juz (part) of the Quran that the given Ayah (verse) belongs to.
*
* @param surah - The Surah (chapter) number.
* @param ayah - The Ayah (verse) number. Defaults to 1 if not provided.
* @param lists - The Lists object containing JuzList and SurahList.
* @returns The Juz (part) number that the given Ayah belongs to.
*/
function findJuz$1(surah, ayah = 1, lists) {
return findJuzByAyahId$1(findAyahIdBySurah$1(surah, ayah, lists), lists);
}
//#endregion
//#region src/findSurahAyahByAyahId.ts
/**
* Finds the Surah (chapter) and Ayah (verse) numbers that the given Ayah ID belongs to.
*
* @param ayahId - The Ayah ID to find the Surah and Ayah numbers for.
* @param lists - The Lists object containing SurahList.
* @returns An array containing the Surah number and the Ayah number within that Surah.
*/
function findSurahAyahByAyahId$1(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
const SurahList$2 = data.SurahList;
const ss = binarySearch(SurahList$2, ayahId, (aya, b) => aya - b[0]);
const suraNum = ss < 0 ? -ss - 2 : ss;
return [suraNum, ayahId - SurahList$2[suraNum][0] + 1];
}
//#endregion
//#region src/findSurahByAyahId.ts
/**
* Finds a Surah based on the provided Ayah ID.
*
* @param ayaId - The unique identifier of the Ayah
* @param data - The Lists object containing SurahList.
* @returns The Surah that contains the specified Ayah
*
* @example
* const surah = findSurahByAyahId(1234, data);
*/
function findSurahByAyahId$1(ayaId, data) {
return findSurahAyahByAyahId$1(ayaId, data)[0];
}
//#endregion
//#region src/findJuzAndShift.ts
/**
* Finds the juz (section) that contains the specified ayah (verse) and calculates the number of ayahs between the start of the juz and the start of the surah (chapter) that contains the ayah.
*
* @param surah - The surah (chapter) that contains the ayah.
* @param ayah - The ayah (verse) number.
* @param lists - The Lists object for the riwaya.
* @returns An object containing the following properties:
* - `juz`: The juz (section) that contains the ayah.
* - `leftAyahId`: The ayah ID of the first ayah in the juz.
* - `ayahsBetweenJuzSurah`: The number of ayahs between the start of the juz and the start of the surah (positive if the surah starts is in the juz, negative if the surah starts before the juz).
*/
function findJuzAndShift$1(surah, ayah, lists) {
const ayahId = findAyahIdBySurah$1(surah, ayah, lists);
const JuzList$2 = lists.JuzList;
const SurahList$2 = lists.SurahList;
const juz = findJuzByAyahId$1(ayahId, lists);
const juzLeftAyahId = JuzList$2[juz];
const [surahStartAyahId] = SurahList$2[surah];
return {
juz,
ayahsBetweenJuzSurah: surahStartAyahId - juzLeftAyahId,
leftAyahId: juzLeftAyahId
};
}
/**
* Finds the Juz number and calculates the shift between Juz start and Surah start for a given Ayah ID
*
* @param ayahId - The unique identifier of an Ayah (verse) in the Quran
* @param data - The Lists object for the riwaya.
* @returns An object containing:
* - juz: The Juz number where the Ayah is located
* - leftAyahId: The starting Ayah ID of the Juz
* - ayahsBetweenJuzSurah: The number of Ayahs between the Juz start and the Surah start
*
* @throws Error If the provided Ayah ID is invalid
*/
function findJuzAndShiftByAyahId$1(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
const JuzList$2 = data.JuzList;
const SurahList$2 = data.SurahList;
const juz = findJuzByAyahId$1(ayahId, data);
const leftAyahId = JuzList$2[juz];
const [surahStartAyahId] = SurahList$2[findSurahByAyahId$1(ayahId, data)];
return {
juz,
ayahsBetweenJuzSurah: surahStartAyahId - leftAyahId,
leftAyahId
};
}
//#endregion
//#region src/findJuzMetaBySurah.ts
/**
* Finds the SurahJuzMeta for a given Surah and Ayah.
*
* @param surah - The Surah (chapter) number.
* @param ayah - The Ayah (verse) number.
* @param data - The Lists object for the riwaya.
* @returns The SurahJuzMeta object containing the left juz, ayahs between juz and surah, right juz, ayah ID of first ayah in left juz, and last ayah ID of right juz .
*/
function findJuzMetaBySurah$1(surah, ayah = 1, data) {
const { juz: leftjuz, ayahsBetweenJuzSurah, leftAyahId } = findJuzAndShift$1(surah, ayah, data);
const JuzList$2 = data.JuzList;
let rightJuz = leftjuz;
while (rightJuz < data.meta.numJuzs && findSurahByAyahId$1(JuzList$2[rightJuz + 1], data) === surah) rightJuz++;
return {
leftjuz,
ayahsBetweenJuzSurah,
rightJuz,
leftAyahId,
rightAyahId: JuzList$2[rightJuz + 1]
};
}
//#endregion
//#region src/findManzilByAyahId.ts
/**
* Finds the Manzil number for a given Ayah ID using binary search.
* A Manzil is one of seven approximately equal divisions of the Quran.
*
* @param ayahId - The ID of the Ayah to find the Manzil for
* @param data - The Lists object for the riwaya.
* @returns The Manzil number (1-7) containing the specified Ayah
* @throws {@link Error} If the provided Ayah ID is invalid
*
* @example
* ```typescript
* const manzil = findManzilByAyahId(2345, HafsLists); // Returns the Manzil containing Ayah 2345
* ```
*/
function findManzilByAyahId$1(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
const ManzilList$2 = data.ManzilList;
const jj = binarySearch(ManzilList$2, ayahId);
return jj < 0 ? -jj - 2 : jj;
}
//#endregion
//#region src/findManzil.ts
/**
* Finds the Manzil number for a given Surah and Ayah
* @param surah - The Surah number or object
* @param ayah - Optional Ayah number (defaults to 1)
* @param data - The Lists object for the riwaya.
* @returns The Manzil number (1-7) containing the specified Ayah
*/
function findManzil$1(surah, ayah = 1, data) {
return findManzilByAyahId$1(findAyahIdBySurah$1(surah, ayah, data), data);
}
//#endregion
//#region src/findPage.ts
/**
* Finds the page number for the given Surah and Ayah number.
*
* @param surah - The Surah to find the page for.
* @param ayah - The Ayah number to find the page for.
* @param data - The Lists object for the riwaya.
* @returns The page number for the given Surah and Ayah.
*/
function findPage$1(surah, ayah = 1, data) {
checkValidSurah$1(surah, data.meta);
const ayahId = findAyahIdBySurah$1(surah, ayah, data);
const PageList$2 = data.PageList;
const jj = binarySearch(PageList$2, ayahId);
return jj < 0 ? -jj - 2 : jj;
}
//#endregion
//#region src/findPagebyAyahId.ts
/**
* Returns the page number for a given ayah ID in the Quran.
*
* @param ayahId - A numeric identifier representing a verse (ayah) in the Quran
* @param data - The Lists object for the riwaya.
* @returns The page number where the specified ayah can be found
* @throws Will throw an error if the ayahId is invalid
*
* @example
* ```ts
* const page = findPagebyAyahId(142, HafsLists); // Returns the page number containing ayah 142
* ```
*/
function findPagebyAyahId$1(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
const PageList$2 = data.PageList;
const jj = binarySearch(PageList$2, ayahId);
return jj < 0 ? -jj - 2 : jj;
}
//#endregion
//#region src/findRukuByAyahId.ts
/**
* Finds the Ruku number for a given Ayah ID using binary search.
*
* @param ayahId - The unique identifier of an Ayah in format: surah:ayah (e.g., "2:255")
* @param data - The Lists object for the riwaya.
* @returns The Ruku number corresponding to the given Ayah ID
* @throws {@link Error} If the provided Ayah ID is invalid
*
* @example
* ```ts
* const ruku = findRukuByAyahId("2:255", HafsLists);
* // Returns the Ruku number containing Ayah 255 of Surah 2
* ```
*/
function findRukuByAyahId$1(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
const RukuList$2 = data.RukuList;
const jj = binarySearch(RukuList$2, ayahId);
return jj < 0 ? -jj - 2 : jj;
}
//#endregion
//#region src/findRangeAroundAyah.ts
/**
* Finds the range of ayahs surrounding a given ayah based on specified mode
* @param ayahId - The unique identifier of the ayah
* @param mode - The scope for finding the range:
* - "juz": Returns range of ayahs in the same juz
* - "surah": Returns range of ayahs in the same surah
* - "ayah": Returns the single ayah as both start and end of range
* - "page": Returns range of ayahs on the same page
* - "ruku": Returns range of ayahs on the same ruku
* - "all": Returns range covering all ayahs (1 to total number of ayahs)
* @param data - The Lists object for the riwaya.
* @returns An array of two numbers representing the start and end ayah IDs of the range [startAyahId, endAyahId]
*/
function findRangeAroundAyah$1(ayahId, mode, data) {
const JuzList$2 = data.JuzList;
const SurahList$2 = data.SurahList;
const PageList$2 = data.PageList;
const RukuList$2 = data.RukuList;
switch (mode) {
case "juz": {
const juz = findJuzByAyahId$1(ayahId, data);
return [JuzList$2[juz], JuzList$2[juz + 1] - 1];
}
case "surah": {
const surah = findSurahByAyahId$1(ayahId, data);
return [SurahList$2[surah][0], SurahList$2[surah + 1][0] - 1];
}
case "ayah": return [ayahId, ayahId];
case "page": {
const page = findPagebyAyahId$1(ayahId, data);
return [PageList$2[page], PageList$2[page + 1] - 1];
}
case "ruku": {
const ruku = findRukuByAyahId$1(ayahId, data);
return [RukuList$2[ruku], RukuList$2[ruku + 1] - 1];
}
case "all":
default: return [1, data.meta.numAyahs];
}
}
//#endregion
//#region src/findRangeAroundSurahAyah.ts
/**
* Finds a range of ayahs around a given ayah based on the specified mode.
*
* @param surah - The surah number (1-114)
* @param ayah - The ayah number within the surah
* @param mode - The range mode: "juz", "surah", "ayah", "page", "ruku" or "all"
* @param lists - The Lists object for the riwaya.
* @returns A tuple containing the start and end ayah IDs of the range
*/
function findRangeAroundSurahAyah$1(surah, ayah, mode, data) {
checkValidSurah$1(surah, data.meta);
const SurahList$2 = data.SurahList;
if (mode === "surah") return [SurahList$2[surah][0], SurahList$2[surah + 1][0] - 1];
return findRangeAroundAyah$1(findAyahIdBySurah$1(surah, ayah, data), mode, data);
}
//#endregion
//#region src/findRubAlHizbByAyahId.ts
/**
* Finds the Maqra/Rub-al-Hizb of the Quran that contains the given Ayah (verse) ID.
*
* @param ayahId - The ID of the Ayah (verse) to find the Juz for.
* @param lists - The Lists object for the riwaya.
* @returns The Maqra of the Quran that contains the given Ayah ID.
*/
function findRubAlHizbByAyahId$1(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
const HizbQuarterList$2 = data.HizbQuarterList;
const jj = binarySearch(HizbQuarterList$2, ayahId);
return jj < 0 ? -jj - 2 : jj;
}
//#endregion
//#region src/findRubAlHizb.ts
/**
* Finds the Juz (part) and Rub-ul-Hizb/Maqra (quarter section) of the Quran that the given Ayah (verse) belongs to.
*
* @param surah - The Surah (chapter) number.
* @param ayah - The Ayah (verse) number. Defaults to 1 if not provided.
* @param data - The Lists object containing SurahList and HizbQuarterList.
* @returns An object containing the Juz (part) number, Hizb (section) number, and the index of the Hizb that the given Ayah belongs to.
*/
function findRubAlHizb$1(surah, ayah = 1, data) {
checkValidSurah$1(surah, data.meta);
return findRubAlHizbByAyahId$1(findAyahIdBySurah$1(surah, ayah, data), data);
}
//#endregion
//#region src/getRubAlHizb.ts
/**
* Retrieves the basic metadata for a specific quarter (rub' al-hizb) of the Quran.
*
* @param quarterIndex - The index of the quarter (rub' al-hizb) to retrieve metadata for, where 1 is the first quarter.
* @param riwaya - The riwaya. Defaults to "Hafs" if not provided.
* @returns An object containing the metadata for the specified quarter, including the juz' (part), hizb (section), and the quarter (rub' al-hizb) index.
*/
function getRubAlHizb(quarterIndex) {
return {
juz: Math.floor((quarterIndex - 1) / 8) + 1,
hizbId: Math.floor((quarterIndex - 1) / 4) + 1,
juzPart: quarterIndex % 8 || 8,
rubAlHizbId: quarterIndex
};
}
//#endregion
//#region src/getRubAlHizbByAyahId.ts
/**
* Finds the Juz, Hizb, and Rub-el-Hizb id for the given Ayah ID.
*
* @param ayahId - The Ayah ID to find the Juz, Hizb, and Hizb ID for.
* @param data - The Lists object for the riwaya.
* @returns An object containing the Juz, Hizb, and Hizb ID for the given Ayah ID.
*/
function getRubAlHizbByAyahId$1(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
return getRubAlHizb(findRubAlHizbByAyahId$1(ayahId, data));
}
//#endregion
//#region src/getAyahMeta.ts
/**
* Retrieves metadata for a specific ayah of the Quran.
*
* @param ayahId - The ayahId number to retrieve metadata for (1-6236)
* @param data - The Lists object for the riwaya.
* @returns An object containing the ayah related meta, including information about the surah, juz, and quarter the ayah is in.
* @throws RangeError If the ayahId number is not between 1 and 6236
*/
function getAyahMeta$1(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
const { SurahList: SurahList$2, SajdaList: SajdaList$2, PageList: PageList$2, RukuList: RukuList$2, JuzList: JuzList$2, HizbQuarterList: HizbQuarterList$2 } = data;
const getThumunData = () => {
if ("HizbEighthList" in data && data.HizbEighthList) {
const jj = binarySearch(data.HizbEighthList, ayahId);
return { thumunAlHizbId: jj < 0 ? -jj - 2 : jj };
}
return {};
};
const quarterData = getRubAlHizbByAyahId$1(ayahId, data);
const [surah, ayah] = findSurahAyahByAyahId$1(ayahId, data);
const page = findPagebyAyahId$1(ayahId, data);
const isSajdahAyah = binarySearch(SajdaList$2, ayahId, (a, b) => a - b) >= 0;
const rk = binarySearch(RukuList$2, ayahId);
const isStartOfRuku = rk > 0;
const ruku = isStartOfRuku ? rk : -rk - 2;
const isStartOfSurah = SurahList$2[surah][0] === ayahId;
const isStartOfPage = PageList$2[page] === ayahId;
const isStartOfJuz = JuzList$2[quarterData.juz] === ayahId;
const isStartOfQuarter = HizbQuarterList$2[quarterData.rubAlHizbId] === ayahId;
const isEndOfSurah = SurahList$2[surah + 1][0] - 1 === ayahId;
const isEndOfPage = PageList$2[page + 1] - 1 === ayahId;
const isEndOfJuz = JuzList$2[quarterData.juz + 1] - 1 === ayahId;
const isEndOfRuku = binarySearch(RukuList$2, ayahId + 1) > 0;
const isEndOfQuarter = HizbQuarterList$2[quarterData.rubAlHizbId + 1] - 1 === ayahId;
return {
...quarterData,
...getThumunData(),
surah,
ayah,
page,
isStartOfQuarter,
isEndOfQuarter,
isSajdahAyah,
isStartOfPage,
isEndOfPage,
ruku,
isStartOfJuz,
isEndOfJuz,
isStartOfSurah,
isEndOfSurah,
isStartOfRuku,
isEndOfRuku
};
}
//#endregion
//#region src/getAyahMetasForSurah.ts
/**
* Retrieves metadata for all ayahs in a specific surah.
*
* @param surahNumber - The surah number (1-114)
* @param data - The Lists object for the riwaya.
* @returns Array of AyahMeta objects for each ayah in the surah
* @throws RangeError If the surah number is not between 1 and 114
*/
function getAyahMetasForSurah$1(surahNumber, data) {
checkValidSurah$1(surahNumber, data.meta);
const { SurahList: SurahList$2, SajdaList: SajdaList$2, PageList: PageList$2, RukuList: RukuList$2, JuzList: JuzList$2, HizbQuarterList: HizbQuarterList$2 } = data;
const [startAyahId, ayahCount] = SurahList$2[surahNumber];
const endAyahId = startAyahId + ayahCount - 1;
const result = [];
let meta$1 = getAyahMeta$1(startAyahId, data);
result.push(meta$1);
for (let ayahId = startAyahId + 1; ayahId <= endAyahId; ayahId++) {
meta$1 = structuredClone(meta$1);
meta$1.ayah += 1;
meta$1.isStartOfSurah = false;
meta$1.isEndOfSurah = endAyahId === ayahId;
if (PageList$2[meta$1.page + 1] === ayahId) {
meta$1.page += 1;
meta$1.isStartOfPage = true;
} else meta$1.isStartOfPage = false;
meta$1.isEndOfPage = PageList$2[meta$1.page + 1] === ayahId + 1;
if (RukuList$2[meta$1.ruku + 1] === ayahId) {
meta$1.ruku += 1;
meta$1.isStartOfRuku = true;
} else meta$1.isStartOfRuku = false;
meta$1.isEndOfRuku = RukuList$2[meta$1.ruku + 1] === ayahId + 1;
meta$1.isEndOfJuz = JuzList$2[meta$1.juz + 1] === ayahId + 1;
if (JuzList$2[meta$1.juz + 1] === ayahId) {
meta$1.juz += 1;
meta$1.hizbId += 1;
meta$1.isStartOfJuz = true;
} else meta$1.isStartOfJuz = false;
meta$1.isEndOfQuarter = HizbQuarterList$2[meta$1.rubAlHizbId + 1] === ayahId + 1;
if (HizbQuarterList$2[meta$1.rubAlHizbId + 1] === ayahId) {
meta$1.rubAlHizbId += 1;
meta$1.juzPart = meta$1.isStartOfJuz ? 1 : meta$1.juzPart + 1;
meta$1.isStartOfQuarter = true;
if (meta$1.juzPart === 5) meta$1.hizbId += 1;
} else meta$1.isStartOfQuarter = false;
meta$1.isSajdahAyah = SajdaList$2.includes(ayahId);
result.push(meta$1);
}
return result;
}
//#endregion
//#region src/getJuzMeta.ts
/**
* Retrieves metadata for a specific Juz of the Quran.
*
* @param juzNum - The Juz number to retrieve metadata for (1-30)
* @param data - The Lists object for the riwaya.
* @returns An object containing the Juz number, first ayah, and last ayah in the Juz
* @throws RangeError If the Juz number is not between 1 and 30
*/
function getJuzMeta$1(juzNum, data) {
checkValidJuz$1(juzNum, data.meta);
const JuzList$2 = data.JuzList;
const [firstAyahId, nextJuzAyahId] = [JuzList$2[juzNum], JuzList$2[juzNum + 1]];
const lastAyahId = nextJuzAyahId - 1;
return {
juzNum,
firstAyahId,
lastAyahId,
first: findSurahAyahByAyahId$1(firstAyahId, data),
last: findSurahAyahByAyahId$1(lastAyahId, data)
};
}
//#endregion
//#region src/getManzilMeta.ts
/**
* Retrieves metadata for a specific Manzil (section) of the Quran
*
* @param manzilNum - The number of the Manzil (1-7)
* @param data - The Lists object for the riwaya.
* @returns The metadata for the specified Manzil containing:
* - manzilNum: The Manzil number
* - firstAyahId: ID of the first ayah in the Manzil
* - lastAyahId: ID of the last ayah in the Manzil
* - first: Surah and ayah details of the first ayah
* - last: Surah and ayah details of the last ayah
* @throws Will throw an error if manzilNum is invalid
*/
function getManzilMeta$1(manzilNum, data) {
checkValidManzil$1(manzilNum, data.meta);
const ManzilList$2 = data.ManzilList;
const [firstAyahId, nextManzilAyahId] = [ManzilList$2[manzilNum], ManzilList$2[manzilNum + 1]];
const lastAyahId = nextManzilAyahId - 1;
return {
manzilNum,
firstAyahId,
lastAyahId,
first: findSurahAyahByAyahId$1(firstAyahId, data),
last: findSurahAyahByAyahId$1(lastAyahId, data)
};
}
//#endregion
//#region src/getPageMeta.ts
/**
* Retrieves metadata for a specific page of the Quran.
*
* @param pageNum - The page number to retrieve metadata for (1-604)
* @param data - The Lists object for the riwaya.
* @returns {@link PageMeta} An object containing the page number, first ayah, and last ayah on the page
* @throws {@link RangeError} If the page number is not between 1 and 604
*/
function getPageMeta$1(pageNum, data) {
checkValidPage$1(pageNum, data.meta);
const PageList$2 = data.PageList;
const [firstAyahId, nextPage] = [PageList$2[pageNum], PageList$2[pageNum + 1]];
const lastAyahId = nextPage - 1;
return {
pageNum,
firstAyahId,
lastAyahId,
first: findSurahAyahByAyahId$1(firstAyahId, data),
last: findSurahAyahByAyahId$1(lastAyahId, data)
};
}
//#endregion
//#region src/getRubAlHizbMeta.ts
/**
* Retrieves the metadata for a specific quarter (rub' al-hizb) of the Quran.
*
* @param quarterIndex - The index of the quarter (rub' al-hizb) to retrieve metadata for, where 1 is the first quarter.
* @param data - The Lists object for the riwaya.
* @returns An object containing the metadata for the specified quarter, including the juz' (part), hizb (section), and the quarter (rub' al-hizb) index.
*/
function getRubAlHizbMeta$1(quarterIndex, data) {
const res = getRubAlHizb(quarterIndex);
const HizbQuarterList$2 = data.HizbQuarterList;
const [firstAyahId, nextJuzAyahId] = [HizbQuarterList$2[quarterIndex], HizbQuarterList$2[quarterIndex + 1]];
const lastAyahId = nextJuzAyahId - 1;
return {
firstAyahId,
lastAyahId,
first: findSurahAyahByAyahId$1(firstAyahId, data),
last: findSurahAyahByAyahId$1(lastAyahId, data),
...res
};
}
//#endregion
//#region src/getRubAlHizbMetaByAyahId.ts
/**
* Finds the Juz, Hizb, and Rub-el-Hizb id for the given Ayah ID.
*
* @param ayahId - The Ayah ID to find the Juz, Hizb, and Hizb ID for.
* @param data - The Lists object containing HizbQuarterList.
* @returns An object containing the Juz, Hizb, and Hizb ID for the given Ayah ID.
*/
function getRubAlHizbMetaByAyahId$1(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
return getRubAlHizbMeta$1(findRubAlHizbByAyahId$1(ayahId, data), data);
}
//#endregion
//#region src/getRukuMeta.ts
/**
* Retrieves metadata for a specific Ruku (section) of the Quran.
* @param rukuNum - The number of the Ruku to retrieve metadata for
* @param data - The Lists object for the riwaya.
* @returns {@link RukuMeta} An object containing metadata about the Ruku including:
* - rukuNum: The Ruku number
* - firstAyahId: The global Ayah ID of the first verse in this Ruku
* - lastAyahId: The global Ayah ID of the last verse in this Ruku
* - first: The Surah and Ayah numbers for the first verse
* - last: The Surah and Ayah numbers for the last verse
* @throws Will throw an error if the provided Ruku number is invalid
*/
function getRukuMeta$1(rukuNum, data) {
checkValidRuku$1(rukuNum, data.meta);
const RukuList$2 = data.RukuList;
const [firstAyahId, nextRukuAyahId] = [RukuList$2[rukuNum], RukuList$2[rukuNum + 1]];
const lastAyahId = nextRukuAyahId - 1;
return {
rukuNum,
firstAyahId,
lastAyahId,
first: findSurahAyahByAyahId$1(firstAyahId, data),
last: findSurahAyahByAyahId$1(lastAyahId, data)
};
}
//#endregion
//#region src/getSurahMeta.ts
/**
* Gets the metadata for the specified Surah.
*
* @param surahNum - The Surah to get the metadata for.
* @param data - The Lists object containing SurahList.
* @returns The metadata for the specified Surah.
*/
function getSurahMeta$1(surahNum, data) {
const [firstAyahId, ayahCount, surahOrder, rukuCount, name, isMeccan] = getSurahInfo$1(surahNum, data);
return {
surahNum,
ayahCount,
surahOrder,
rukuCount,
name,
isMeccan,
firstAyahId,
lastAyahId: firstAyahId + ayahCount - 1,
first: [surahNum, 1],
last: [surahNum, ayahCount]
};
}
//#endregion
//#region src/isAyahJuzFirst.ts
/**
* Returns the Juz (part) number that the given Ayah (verse) belongs to.
*
*
* @param ayahId - The Ayah Id (verse) number.
* @param data - The Lists object for the riwaya.
* @returns The Juz (part) number that the given Ayah belongs to. Returns Positive number if ayah is first ayah of juz, number is juz number
*/
function isAyahJuzFirst$1(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
const JuzList$2 = data.JuzList;
return binarySearch(JuzList$2, ayahId);
}
//#endregion
//#region src/isAyahPageFirst.ts
/**
* Determines if the given ayah is the first ayah of a juz.
*
* @param ayahId - The ayah id .
* @param data - The Lists object for the riwaya.
* @returns The page number if the ayah is the first ayah of the page, otherwise -1.
*/
function isAyahPageFirst$1(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
const PageList$2 = data.PageList;
return binarySearch(PageList$2, ayahId);
}
//#endregion
//#region src/isSurahAyahJuzFirst.ts
/**
* Determines if a given Surah and Ayah combination marks the beginning of a Juz.
*
* @param surah - The Surah number to check
* @param ayah - The Ayah number within the Surah to check
* @param data - The Lists object for the riwaya.
* @returns The Juz number if the combination marks the start of a Juz, -1 otherwise
* @throws Error When the provided Surah number is invalid
*
* @example
* ```typescript
* isSurahAyahJuzFirst(2, 142, HafsLists) // Returns 2
* isSurahAyahJuzFirst(2, 143, HafsLists) // Returns -1
* ```
*/
function isSurahAyahJuzFirst$1(surah, ayah, data) {
checkValidSurah$1(surah, data.meta);
const ayahId = findAyahIdBySurah$1(surah, ayah, data);
const JuzList$2 = data.JuzList;
return binarySearch(JuzList$2, ayahId);
}
//#endregion
//#region src/isSurahAyahPageFirst.ts
/**
* Determines if an ayah is the first ayah on its page in the Quran
* @param surah - The surah number (1-114)
* @param ayah - The ayah number within the surah
* @param lists - The Lists object for the riwaya.
* @returns The page number if the ayah is first on its page, -1 otherwise
* @throws Error If surah number is invalid
*/
function isSurahAyahPageFirst$1(surah, ayah, data) {
checkValidSurah$1(surah, data.meta);
const ayahId = findAyahIdBySurah$1(surah, ayah, data);
const PageList$2 = data.PageList;
return binarySearch(PageList$2, ayahId);
}
//#endregion
//#region src/nextAyah.ts
/**
* Get the next ayah for the given surah and ayah number.
* @param surah - The surah number.
* @param ayah - The ayah number within the surah.
* @param data - The Lists object containing SurahList.
* @returns The surah and ayah number of the next ayah.
*/
function nextAyah$1(surah, ayah, data) {
if (surah < 1 || surah > data.meta.numSurahs) throw new RangeError("Surah must be between 1 and " + data.meta.numSurahs);
const ayahId = findAyahIdBySurah$1(surah, ayah, data);
return findSurahAyahByAyahId$1(ayahId == data.meta.numAyahs ? 1 : ayahId + 1, data);
}
//#endregion
//#region src/prevAyah.ts
/**
* Get the previous ayah for the given surah and ayah number.
* @param surah - The surah number.
* @param ayah - The ayah number within the surah.
* @param data - The Lists object containing SurahList.
* @returns The surah and ayah number of the previous ayah.
*/
function prevAyah$1(surah, ayah, data) {
checkValidSurah$1(surah, data.meta);
const ayahId = findAyahIdBySurah$1(surah, ayah, data);
return findSurahAyahByAyahId$1(ayahId == 1 ? data.meta.numAyahs : ayahId - 1, data);
}
//#endregion
//#region src/findThumunAlHizbByAyahId.ts
/**
* Finds the Maqra/Rub-al-Hizb of the Quran that contains the given Ayah (verse) ID.
*
* @param ayahId - The ID of the Ayah (verse) to find the Juz for.
* @param data - The Lists object for the riwaya.
* @returns The thumun of the Quran that contains the given Ayah ID.
*/
function findThumunAlHizbByAyahId(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
const HizbEighthList = data.HizbEighthList;
if (!HizbEighthList) throw new Error(`Riwaya ${data.meta.riwayaName} does not have Hizb Eighth List data.`);
const jj = binarySearch(HizbEighthList, ayahId);
return jj < 0 ? -jj - 2 : jj;
}
//#endregion
//#region src/findThumunAlHizb.ts
/**
* Finds the Juz (part) and thumun-ul-Hizb (Eighth section) of the Quran that the given Ayah (verse) belongs to.
*
* @param surah - The Surah (chapter) number.
* @param ayah - The Ayah (verse) number. Defaults to 1 if not provided.
* @param riwaya - The riwaya. Defaults to "Qalun" if not provided.
* @returns An object containing the Juz (part) number, Hizb (section) number, and the index of the Hizb that the given Ayah belongs to.
*/
function findThumunAlHizb(surah, ayah = 1, data) {
checkValidSurah$1(surah, data.meta);
return findThumunAlHizbByAyahId(findAyahIdBySurah$1(surah, ayah, data), data);
}
//#endregion
//#region src/getThumunAlHizb.ts
/**
* Retrieves the basic metadata for a specific Eighth (thumun' al-hizb) of the Quran.
*
* @param eighthIndex - The index of the Eighth (thumun' al-hizb) to retrieve metadata for, where 1 is the first quarter.
* @returns An object containing the metadata for the specified quarter, including the juz' (part), hizb (section), and the quarter (rub' al-hizb) index.
*/
function getThumunAlHizb(eighthIndex) {
return {
...getRubAlHizb(Math.floor((eighthIndex - 1) / 2) + 1),
thumunAlHizbId: eighthIndex
};
}
//#endregion
//#region src/getThumunAlHizbByAyahId.ts
/**
* Finds the Juz, Hizb, Rub-el-Hizb id and thuumun-el-Hizb id for the given Ayah ID.
*
* @param ayahId - The Ayah ID to find the Juz, Hizb, and Hizb ID for.
* @param data - The riwaya. Defaults to "Qalun" if not provided.
* @returns An object containing the Juz, Hizb, Hizb ID and thuumun-el-Hizb id for the given Ayah ID.
*/
function getThumunAlHizbByAyahId(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
return getThumunAlHizb(findThumunAlHizbByAyahId(ayahId, data));
}
//#endregion
//#region src/getThumunAlHizbMeta.ts
/**
* Retrieves the metadata for a specific quarter (rub' al-hizb) of the Quran.
*
* @param eighthIndex - The index of the Eighth (thumun' al-hizb) to retrieve metadata for, where 1 is the first quarter.
* @param data - The Lists object for the riwaya.
* @returns An object containing the metadata for the specified quarter, including the juz' (part), hizb (section), and the quarter (rub' al-hizb) index.
*/
function getThumunAlHizbMeta(eighthIndex, data) {
const res = getThumunAlHizb(eighthIndex);
const HizbEighthList = data.HizbEighthList;
if (!HizbEighthList) throw new Error(`Riwaya ${data.meta.riwayaName} does not have Hizb Eighth List data.`);
const [firstAyahId, nextJuzAyahId] = [HizbEighthList[eighthIndex], HizbEighthList[eighthIndex + 1]];
const lastAyahId = nextJuzAyahId - 1;
return {
firstAyahId,
lastAyahId,
first: findSurahAyahByAyahId$1(firstAyahId, data),
last: findSurahAyahByAyahId$1(lastAyahId, data),
...res
};
}
//#endregion
//#region src/getThumunAlHizbMetaByAyahId.ts
/**
* Finds the Juz, Hizb, and Rub-el-Hizb id for the given Ayah ID.
*
* @param ayahId - The Ayah ID to find the Juz, Hizb, and Hizb ID for.
* @param riwaya - The riwaya. Defaults to "Qalun" if not provided.
* @returns An object containing the Juz, Hizb, thumunAlHizb ID, and Hizb ID for the given Ayah ID.
*/
function getThumunAlHizbMetaByAyahId(ayahId, data) {
checkValidAyahId$1(ayahId, data.meta);
return getThumunAlHizbMeta(findThumunAlHizbByAyahId(ayahId, data), data);
}
//#endregion
//#region src/surahStringParser.ts
/**
* Parses a string representation of a Surah number and converts it to a valid Surah type
* @param str - The string containing the Surah number to parse
* @returns The parsed Surah number as a Surah type
* @throws {@link Error} If the string cannot be parsed as a number or if the number is not a valid Surah number
*/
function surahStringParser$1(str, isStrict = false, meta$1) {
const surahX = isStrict ? Number(str.trim()) : Number.parseInt(str.trim(), 10);
if (isNaN(surahX)) throw new Error("Error in surah format " + str);
if (!isValidSurah$1(surahX, meta$1)) throw new Error("Error in surah number " + str);
return surahX;
}
//#endregion
//#region src/QuranRiwaya.ts
/**
* QuranRiwaya class provides a clean API for Quran metadata operations
* with a specific riwaya (recitation tradition) context.
*
* Currently provides basic Surah and Ayah operations. For advanced features
* like Juz, Page, Manzil, RubAlHizb, etc., use the functional API directly.
*
* @example
* **Basic Usage with Hafs**
* ```typescript
* import { quran } from 'quran-meta/hafs'
*
* const surahMeta = quran.getSurahMeta(2) // Get Al-Baqarah metadata
* const ayahCount = quran.getAyahCountInSurah(2) // 286 ayahs
* const [surah, ayah] = quran.findSurahAyahByAyahId(100) // [2, 93]
* ```
*
* @example
* **Working with Qalun**
* ```typescript
* import { quran } from 'quran-meta/qalun'
*
* const meta = quran.meta
* console.log(meta.numAyahs) // 6214 (Qalun has fewer ayahs than Hafs)
* ```
*
* @example
* **Creating a custom instance**
* ```typescript
* import { QuranRiwaya } from 'quran-meta'
* import { WarshMeta, WarshLists } from 'quran-meta/lists/WarshLists'
*
* const warsh = QuranRiwaya.create(WarshLists)
* ```
*/
var QuranRiwaya = class QuranRiwaya {
#riwaya;
#meta;
#data;
constructor(rData) {
this.#riwaya = rData.meta.riwayaName;
this.#meta = rData.meta;
this.#data = rData;
}
/**
* Create a QuranRiwaya instance with the specified riwaya, metadata, and lists
* @param riwaya - The riwaya name ("Hafs", "Qalun", or "Warsh")
* @param meta - The metadata for this riwaya
* @param rData - The Lists object for this riwaya
*/
static create(rData) {
return new QuranRiwaya(rData);
}
/**
* Gets the metadata for the specified Surah
*/
getSurahMeta(surahNum) {
return getSurahMeta$1(surahNum, this.#data);
}
ayahStringSplitter(str, isStrict = true) {
return ayahStringSplitter$1(str, isStrict, this.#data);
}
/**
* Gets the surah info array [firstAyahId, ayahCount, surahOrder, rukuCount, name, isMeccan]
*/
getSurahInfo(surah) {
return getSurahInfo$1(surah, this.#data);
}
/**
* Gets the count of ayahs in a surah
*/
getAyahCountInSurah(surah) {
return getAyahCountInSurah$1(surah, this.#data);
}
/**
* Finds the surah number for a given ayah ID
*/
findSurahByAyahId(ayahId) {
return findSurahByAyahId$1(ayahId, this.#data);
}
/**
* Finds the [surah, ayah] tuple for a given ayah ID
*/
findSurahAyahByAyahId(ayahId) {
return findSurahAyahByAyahId$1(ayahId, this.#data);
}
/**
* Finds the ayah ID for a given surah and ayah number
*/
findAyahIdBySurah(surah, ayah) {
return findAyahIdBySurah$1(surah, ayah, this.#data);
}
generatePartBlocks(type) {
return generatePartBlocks$1(type, this.#data);
}
getList(type) {
return getList$1(type, this.#data);
}
getListNormalised(type) {
return getListNormalised$1(type, this.#data);
}
/**
* Gets the next ayah after the given surah and ayah
*/
nextAyah(surah, ayah) {
return nextAyah$1(surah, ayah, this.#data);
}
/**
* Gets the previous ayah before the given surah and ayah
*/
prevAyah(surah, ayah) {
return prevAyah$1(surah, ayah, this.#data);
}
/**
* Finds the juz number for a given surah and ayah
*/
findJuz(surah, ayah = 1) {
return findJuz$1(surah, ayah, this.#data);
}
/**
* Finds the juz number for a given ayah ID
*/
findJuzByAyahId(ayahId) {
return findJuzByAyahId$1(ayahId, this.#data);
}
/**
* Finds the page number for a given surah and ayah
*/
findPage(surah, ayah = 1) {
return findPage$1(surah, ayah, this.#data);
}
/**
* Finds the page number for a given ayah ID
*/
findPagebyAyahId(ayahId) {
return findPagebyAyahId$1(ayahId, this.#data);
}
/**
* Gets metadata for a specific page
*/
getPageMeta(pageNum) {
return getPageMeta$1(pageNum, this.#data);
}
/**
* Finds the manzil number for a given surah and ayah
*/
findManzil(surah, ayah = 1) {
return findManzil$1(surah, ayah, this.#data);
}
/**
* Finds the manzil number for a given ayah ID
*/
findManzilByAyahId(ayahId) {
return findManzilByAyahId$1(ayahId, this.#data);
}
/**
* Gets metadata for a specific manzil
*/
getManzilMeta(manzilNum) {
return getManzilMeta$1(manzilNum, this.#data);
}
/**
* Finds the ruku number for a given ayah ID
*/
findRukuByAyahId(ayahId) {
return findRukuByAyahId$1(ayahId, this.#data);
}
/**
* Gets metadata for a specific ruku
*/
getRukuMeta(rukuNum) {
return getRukuMeta$1(rukuNum, this.#data);
}
/**
* Gets metadata for a specific juz
*/
getJuzMeta(juzNum) {
return getJuzMeta$1(juzNum, this.#data);
}
/**
* Finds juz metadata for a given surah and ayah
*/
findJuzMetaBySurah(surah, ayah = 1) {
return findJuzMetaBySurah$1(surah, ayah, this.#data);
}
/**
* Finds juz and calculates shift between juz start and surah start
*/
findJuzAndShift(surah, ayah) {
return findJuzAndShift$1(surah, ayah, this.#data);
}
/**
* Finds juz and shift for a given ayah ID
*/
findJuzAndShiftByAyahId(ayahId) {
return findJuzAndShiftByAyahId$1(ayahId, this.#data);
}
/**
* Finds the RubAlHizb for a given surah and ayah
*/
findRubAlHizb(surah, ayah = 1) {
return findRubAlHizb$1(surah, ayah, this.#data);
}
/**
* Finds the RubAlHizb ID for a given ayah ID
*/
findRubAlHizbByAyahId(ayahId) {
return findRubAlHizbByAyahId$1(ayahId, this.#data);
}
/**
* Gets RubAlHizb data (juz, hizb, etc.) for a given ayah ID
*/
getRubAlHizbByAyahId(ayahId) {
return getRubAlHizbByAyahId$1(ayahId, this.#data);
}
/**
* Gets RubAlHizb data (juz, hizb, etc.) for a given ayah ID
*/
getRubAlHizb(quarterIndex) {
return getRubAlHizb(quarterIndex);
}
/**
* Gets complete RubAlHizb metadata for a given ayah ID
*/
getRubAlHizbMetaByAyahId(ayahId) {
return getRubAlHizbMetaByAyahId$1(ayahId, this.#data);
}
/**
* Gets metadata for a specific RubAlHizb
*/
getRubAlHizbMeta(quarterIndex) {
return getRubAlHizbMeta$1(quarterIndex, this.#data);
}
/**
* Finds the ThumunAlHizb ID for a given ayah ID (Qalun/Warsh only)
*/
findThumunAlHizbByAyahId(ayahId) {
return findThumunAlHizbByAyahId(ayahId, this.#data);
}
/**
* Finds the ThumunAlHizb ID for a given ayah ID (Qalun/Warsh only)
*/
findThumunAlHizb(surah, ayah = 1) {
return findThumunAlHizb(surah, ayah, this.#data);
}
/**
* Gets metadata for a specific ThumunAlHizb (Qalun/Warsh only)
*/
getThumunAlHizbMeta(eighthIndex) {
return getThumunAlHizbMeta(eighthIndex, this.#data);
}
getThumunAlHizbByAyahId(ayahId) {
return getThumunAlHizbByAyahId(ayahId, this.#data);
}
getThumunAlHizbMetaByAyahId(ayahId) {
return getThumunAlHizbMetaByAyahId(ayahId, this.#data);
}
getThumunAlHizb(eighthIndex) {
return getThumunAlHizb(eighthIndex);
}
/**
* Gets comprehensive metadata for a specific ayah
*/
getAyahMeta(ayahId) {
return getAyahMeta$1(ayahId, this.#data);
}
/**
* Gets metadata for all ayahs in a surah
*/
getAyahMetasForSurah(surahNumber) {
return getAyahMetasForSurah$1(surahNumber, this.#data);
}
/**
* Finds the range of ayahs around a given ayah
*/
findRangeAroundAyah(ayahId, mode) {
return findRangeAroundAyah$1(ayahId, mode, this.#data);
}
/**
* Finds the range of ayahs around a given surah and ayah
*/
findRangeAroundSurahAyah(surah, ayah, mode) {
return findRangeAroundSurahAyah$1(surah, ayah, mode, this.#data);
}
/**
* Checks if an ayah is the first ayah of a juz
*/
isAyahJuzFirst(ayahId) {
return isAyahJuzFirst$1(ayahId, this.#data);
}
/**
* Checks if an ayah is the first ayah of a page
*/
isAyahPageFirst(ayahId) {
return isAyahPageFirst$1(ayahId, this.#data);
}
/**
* Checks if a surah-ayah combination is the first ayah of a juz
*/
isSurahAyahJuzFirst(surah, ayah) {
return isSurahAyahJuzFirst$1(surah, ayah, this.#data);
}
/**
* Checks if a surah-ayah combination is the first ayah of a page
*/
isSurahAyahPageFirst(surah, ayah) {
return isSurahAyahPageFirst$1(surah, ayah, this.#data);
}
isValidAyahId(x) {
return isValidAyahId$1(x, this.#meta);
}
isValidPage(x) {
return isValidPage$1(x, this.#meta);
}
isValidSurah(x) {
return isValidSurah$1(x, this.#meta);
}
isValidJuz(x) {
return isValidJuz$1(x, this.#meta);
}
isValidRuku(x) {
return isValidRuku$1(x, this.#meta);
}
isValidSurahAyah(x) {
return isValidSurahAyah$1(x, this.#data);
}
static isValidAyahNo(x) {
return isValidAyahNo(x);
}
surahStringParser(str, isStrict = false) {
return surahStringParser$1(str, isStrict, this.#meta);
}
static string2NumberSplitter(str) {
return string2NumberSplitter(str);
}
/**
* Gets the riwaya name
*/
get riwayaName() {
return this.#riwaya;
}
/**
* Gets the metadata for this riwaya
*/
get meta() {
return this.#meta;
}
/**
* Gets the metadata for this riwaya
*/
get lists() {
return this.#data;
}
};
//#endregion
//#region src/warsh.ts
/**
* Warsh-specific entry point
*
* This module provides metadata and functional API for Warsh riwaya only.
* Functions are pre-bound to riwayaLists for convenience and optimal tree-shaking.
*
* @example
* ```typescript
* import { meta, findJuz, getAyahMeta } from 'quran-meta/Warsh'
*
* console.log(meta.numAyahs) // 6236
* const juz = findJuz(2, 142)
* const ayahMeta = getAyahMeta(1)
* ```
*/
/**
* Warsh metadata
*/
const meta = WarshLists.meta;
const getList = (listName) => getList$1(listName, WarshLists);
const getListNormalised = (listName) => getListNormalised$1(listName, WarshLists);
/**
* Warsh Lists (SurahList, JuzList, etc.)
*/
const HizbQuarterList = WarshLists.HizbQuarterList;
const JuzList = WarshLists.JuzList;
const ManzilList = WarshLists.ManzilList;
const PageList = WarshLists.PageList;
const SurahList = WarshLists.SurahList;
const RukuList = WarshLists.RukuList;
const SajdaList = WarshLists.SajdaList;
const ayahStringSplitter = (str, isStrict = true) => ayahStringSplitter$1(str, isStrict, WarshLists);
const surahStringParser = (str, isStrict = false) => surahStringParser$1(str, isStrict, meta);
const checkValidSurahAyah = (surah, ayah) => checkValidSurahAyah$1(surah, ayah, WarshLists);
const checkValidSurah = (surah) => checkValidSurah$1(surah, meta);
const checkValidSurahAyahPair = (pair) => checkValidSurahAyahPair$1(pair, WarshLists);
const checkValidAyahId = (ayahId) => checkValidAyahId$1(ayahId, meta);
const checkValidPage = (page) => checkValidPage$1(page, meta);
const checkValidJuz = (juz) => checkValidJuz$1(juz, meta);
const checkValidRuku = (ruku) => checkValidRuku$1(ruku, meta);
const checkValidManzil = (manzil) => checkValidManzil$1(manzil, meta);
const getSurahMeta = (surah) => getSurahMeta$1(surah, WarshLists);
const getSurahInfo = (surah) => getSurahInfo$1(surah, WarshLists);
const getAyahCountInSurah = (surah) => getAyahCountInSurah$1(surah, WarshLists);
const findAyahIdBySurah = (surah, ayah = 1) => findAyahIdBySurah$1(surah, ayah, WarshLists);
const findSurahByAyahId = (ayahId) => findSurahByAyahId$1(ayahId, WarshLists);
const findSurahAyahByAyahId = (ayahId) => findSurahAyahByAyahId$1(ayahId, WarshLists);
const nextAyah = (surah, ayah) => nextAyah$1(surah, ayah, WarshLists);
const prevAyah = (surah, ayah) => prevAyah$1(surah, ayah, WarshLists);
const findJuz = (surah, ayah = 1) => findJuz$1(surah, ayah, WarshLists);
const findJuzByAyahId = (ayahId) => findJuzByAyahId$1(ayahId, WarshLists);
const getJuzMeta = (juz) => getJuzMeta$1(juz, WarshLists);
const findJuzMetaBySurah = (surah, ayah = 1) => findJuzMetaBySurah$1(surah, ayah, WarshLists);
const findJuzAndShift = (surah, ayah = 1) => findJuzAndShift$1(surah, ayah, WarshLists);
const findJuzAndShiftByAyahId = (ayahId) => {
return findJuzAndShiftByAyahId$1(ayahId, WarshLists);
};
const findPage = (surah, ayah = 1) => findPage$1(surah, ayah, WarshLists);
const findPagebyAyahId = (ayahId) => findPagebyAyahId$1(ayahId, WarshLists);
const getPageMeta = (page) => getPageMeta$1(page, WarshLists);
const findManzil = (surah, ayah = 1) => findManzil$1(surah, ayah, WarshLists);
const findManzilByAyahId = (ayahId) => findManzilByAyahId$1(ayahId, WarshLists);
const getManzilMeta = (manzil) => getManzilMeta$1(manzil, WarshLists);
const findRukuByAyahId = (ayahId) => findRukuByAyahId$1(ayahId, WarshLists);
const getRukuMeta = (ruku) => getRukuMeta$1(ruku, WarshLists);
const findRubAlHizb = (surah, ayah = 1) => findRubAlHizb$1(surah, ayah, WarshLists);
const findRubAlHizbByAyahId = (ayahId) => findRubAlHizbByAyahId$1(ayahId, WarshLists);
const getRubAlHizbMeta = (quarterIndex) => getRubAlHizbMeta$1(quarterIndex, WarshLists);
const getRubAlHizbMetaByAyahId = (ayahId) => getRubAlHizbMetaByAyahId$1(ayahId, WarshLists);
const getRubAlHizbByAyahId = (ayahId) => getRubAlHizbByAyahId$1(ayahId, WarshLists);
const getAyahMeta = (ayahId) => getAyahMeta$1(ayahId, WarshLists);
const getAyahMetasForSurah = (surah) => getAyahMetasForSurah$1(surah, WarshLists);
const findRangeAroundAyah = (ayahId, mode) => findRangeAroundAyah$1(ayahId, mode, WarshLists);
const findRangeAroundSurahAyah = (surah, ayah, mode) => findRangeAroundSurahAyah$1(surah, ayah, mode, WarshLists);
const isAyahJuzFirst = (ayahId) => isAyahJuzFirst$1(ayahId, WarshLists);
const isAyahPageFirst = (ayahId) => isAyahPageFirst$1(ayahId, WarshLists);
const isSurahAyahJuzFirst = (surah, ayah) => isSurahAyahJuzFirst$1(surah, ayah, WarshLists);
const isSurahAyahPageFirst = (surah, ayah) => isSurahAyahPageFirst$1(surah, ayah, WarshLists);
const isValidSurah = (x) => isValidSurah$1(x, meta);
const isValidAyahId = (x) => isValidAyahId$1(x, meta);
const isValidManzil = (x) => isValidManzil$1(x, meta);
const isValidPage = (x) => isValidPage$1(x, meta);
const isValidJuz = (x) => isValidJuz$1(x, meta);
const isValidRuku = (x) => isValidRuku$1(x, meta);
const isValidSurahAyah = (x) => isValidSurahAyah$1(x, WarshLists);
const generatePartBlocks = (part) => generatePartBlocks$1(part, WarshLists);
/**
* Pre-initialized QuranRiwaya instance for Warsh
*
* @example
* ```typescript
* import { quran } from 'quran-meta/warsh'
*
* const ayahMeta = quran.getAyahMeta(1)
* const juz = quran.findJuz(1, 1)
* ```
*/
const createWarsh = () => QuranRiwaya.create(WarshLists);
//#endregion
export { HizbQuarterList, JuzList, ManzilList, PageList, RukuList, SajdaList, SurahList, ayahStringSplitter, checkValidAyahId, checkValidJuz, checkValidManzil, checkValidPage, checkValidRuku, checkValidSurah, checkValidSurahAyah, checkValidSurahAyahPair, createWarsh, findAyahIdBySurah, findJuz, findJuzAndShift, findJuzAndShiftByAyahId, findJuzByAyahId, findJuzMetaBySurah, findManzil, findManzilByAyahId, findPage, findPagebyAyahId, findRangeAroundAyah, findRangeAroundSurahAyah, findRubAlHizb, findRubAlHizbByAyahId, findRukuByAyahId, findSurahAyahByAyahId, findSurahByAyahId, generatePartBlocks, getAyahCountInSurah, getAyahMeta, getAyahMetasForSurah, getJuzMeta, getList, getListNormalised, getManzilMeta, getPageMeta, getRubAlHizb, getRubAlHizbByAyahId, getRubAlHizbMeta, getRubAlHizbMetaByAyahId, getRukuMeta, getSurahInfo, getSurahMeta, isAyahJuzFirst, isAyahPageFirst, isSurahAyahJuzFirst, isSurahAyahPageFirst, isValidAyahId, isValidAyahNo, isValidJuz, isValidManzil, isValidPage, isValidRuku, isValidSurah, isValidSurahAyah, meta, nextAyah, prevAyah, string2NumberSplitter, string2NumberSplitterStrict, surahStringParser };