@quranjs/api 1.1.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +7 -0
  2. package/dist/api.cjs.development.js +2723 -0
  3. package/dist/api.cjs.development.js.map +1 -0
  4. package/dist/api.cjs.production.min.js +2 -0
  5. package/dist/api.cjs.production.min.js.map +1 -0
  6. package/dist/api.esm.js +2715 -0
  7. package/dist/api.esm.js.map +1 -0
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.js +8 -0
  10. package/dist/sdk/index.d.ts +183 -0
  11. package/dist/sdk/utils.d.ts +125 -0
  12. package/dist/sdk/v4/_fetcher.d.ts +3 -0
  13. package/dist/sdk/v4/audio.d.ts +52 -0
  14. package/dist/sdk/v4/chapters.d.ts +13 -0
  15. package/dist/sdk/v4/index.d.ts +173 -0
  16. package/dist/sdk/v4/juzs.d.ts +5 -0
  17. package/dist/sdk/v4/resources.d.ts +26 -0
  18. package/dist/sdk/v4/search.d.ts +22 -0
  19. package/dist/sdk/v4/verses.d.ts +64 -0
  20. package/dist/types/ChapterId.d.ts +1 -0
  21. package/dist/types/HizbNumber.d.ts +1 -0
  22. package/dist/types/JuzNumber.d.ts +1 -0
  23. package/dist/types/PageNumber.d.ts +1 -0
  24. package/dist/types/RubNumber.d.ts +1 -0
  25. package/dist/types/VerseKey.d.ts +1 -0
  26. package/dist/types/api/ApiResponses.d.ts +18 -0
  27. package/dist/types/api/AudioData.d.ts +17 -0
  28. package/dist/types/api/AudioResponse.d.ts +8 -0
  29. package/dist/types/api/Chapter.d.ts +14 -0
  30. package/dist/types/api/ChapterInfo.d.ts +8 -0
  31. package/dist/types/api/Footnote.d.ts +6 -0
  32. package/dist/types/api/Juz.d.ts +8 -0
  33. package/dist/types/api/Pagination.d.ts +7 -0
  34. package/dist/types/api/Reciter.d.ts +21 -0
  35. package/dist/types/api/Resources.d.ts +70 -0
  36. package/dist/types/api/Segment.d.ts +4 -0
  37. package/dist/types/api/Tafsir.d.ts +7 -0
  38. package/dist/types/api/TafsirInfo.d.ts +9 -0
  39. package/dist/types/api/TranslatedName.d.ts +4 -0
  40. package/dist/types/api/Translation.d.ts +17 -0
  41. package/dist/types/api/Transliteration.d.ts +4 -0
  42. package/dist/types/api/Verse.d.ts +32 -0
  43. package/dist/types/api/Word.d.ts +28 -0
  44. package/dist/types/api/index.d.ts +18 -0
  45. package/dist/types/index.d.ts +88 -0
  46. package/dist/utils/misc.d.ts +1 -0
  47. package/dist/utils/qs-stringify.d.ts +21 -0
  48. package/package.json +1 -3
  49. package/src/sdk/v4/_fetcher.ts +2 -2
  50. package/src/sdk/v4/audio.ts +1 -1
  51. package/src/sdk/v4/chapters.ts +1 -1
  52. package/src/sdk/v4/juzs.ts +1 -1
  53. package/src/sdk/v4/resources.ts +1 -1
  54. package/src/sdk/v4/search.ts +1 -1
  55. package/src/sdk/v4/verses.ts +1 -1
@@ -0,0 +1,2715 @@
1
+ import fetch from 'cross-fetch';
2
+ import { camelizeKeys, decamelizeKeys, decamelize } from 'humps';
3
+
4
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
5
+ try {
6
+ var info = gen[key](arg);
7
+ var value = info.value;
8
+ } catch (error) {
9
+ reject(error);
10
+ return;
11
+ }
12
+
13
+ if (info.done) {
14
+ resolve(value);
15
+ } else {
16
+ Promise.resolve(value).then(_next, _throw);
17
+ }
18
+ }
19
+
20
+ function _asyncToGenerator(fn) {
21
+ return function () {
22
+ var self = this,
23
+ args = arguments;
24
+ return new Promise(function (resolve, reject) {
25
+ var gen = fn.apply(self, args);
26
+
27
+ function _next(value) {
28
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
29
+ }
30
+
31
+ function _throw(err) {
32
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
33
+ }
34
+
35
+ _next(undefined);
36
+ });
37
+ };
38
+ }
39
+
40
+ function _extends() {
41
+ _extends = Object.assign || function (target) {
42
+ for (var i = 1; i < arguments.length; i++) {
43
+ var source = arguments[i];
44
+
45
+ for (var key in source) {
46
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
47
+ target[key] = source[key];
48
+ }
49
+ }
50
+ }
51
+
52
+ return target;
53
+ };
54
+
55
+ return _extends.apply(this, arguments);
56
+ }
57
+
58
+ var runtime = {exports: {}};
59
+
60
+ /**
61
+ * Copyright (c) 2014-present, Facebook, Inc.
62
+ *
63
+ * This source code is licensed under the MIT license found in the
64
+ * LICENSE file in the root directory of this source tree.
65
+ */
66
+
67
+ (function (module) {
68
+ var runtime = (function (exports) {
69
+
70
+ var Op = Object.prototype;
71
+ var hasOwn = Op.hasOwnProperty;
72
+ var undefined$1; // More compressible than void 0.
73
+ var $Symbol = typeof Symbol === "function" ? Symbol : {};
74
+ var iteratorSymbol = $Symbol.iterator || "@@iterator";
75
+ var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
76
+ var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
77
+
78
+ function define(obj, key, value) {
79
+ Object.defineProperty(obj, key, {
80
+ value: value,
81
+ enumerable: true,
82
+ configurable: true,
83
+ writable: true
84
+ });
85
+ return obj[key];
86
+ }
87
+ try {
88
+ // IE 8 has a broken Object.defineProperty that only works on DOM objects.
89
+ define({}, "");
90
+ } catch (err) {
91
+ define = function(obj, key, value) {
92
+ return obj[key] = value;
93
+ };
94
+ }
95
+
96
+ function wrap(innerFn, outerFn, self, tryLocsList) {
97
+ // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
98
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
99
+ var generator = Object.create(protoGenerator.prototype);
100
+ var context = new Context(tryLocsList || []);
101
+
102
+ // The ._invoke method unifies the implementations of the .next,
103
+ // .throw, and .return methods.
104
+ generator._invoke = makeInvokeMethod(innerFn, self, context);
105
+
106
+ return generator;
107
+ }
108
+ exports.wrap = wrap;
109
+
110
+ // Try/catch helper to minimize deoptimizations. Returns a completion
111
+ // record like context.tryEntries[i].completion. This interface could
112
+ // have been (and was previously) designed to take a closure to be
113
+ // invoked without arguments, but in all the cases we care about we
114
+ // already have an existing method we want to call, so there's no need
115
+ // to create a new function object. We can even get away with assuming
116
+ // the method takes exactly one argument, since that happens to be true
117
+ // in every case, so we don't have to touch the arguments object. The
118
+ // only additional allocation required is the completion record, which
119
+ // has a stable shape and so hopefully should be cheap to allocate.
120
+ function tryCatch(fn, obj, arg) {
121
+ try {
122
+ return { type: "normal", arg: fn.call(obj, arg) };
123
+ } catch (err) {
124
+ return { type: "throw", arg: err };
125
+ }
126
+ }
127
+
128
+ var GenStateSuspendedStart = "suspendedStart";
129
+ var GenStateSuspendedYield = "suspendedYield";
130
+ var GenStateExecuting = "executing";
131
+ var GenStateCompleted = "completed";
132
+
133
+ // Returning this object from the innerFn has the same effect as
134
+ // breaking out of the dispatch switch statement.
135
+ var ContinueSentinel = {};
136
+
137
+ // Dummy constructor functions that we use as the .constructor and
138
+ // .constructor.prototype properties for functions that return Generator
139
+ // objects. For full spec compliance, you may wish to configure your
140
+ // minifier not to mangle the names of these two functions.
141
+ function Generator() {}
142
+ function GeneratorFunction() {}
143
+ function GeneratorFunctionPrototype() {}
144
+
145
+ // This is a polyfill for %IteratorPrototype% for environments that
146
+ // don't natively support it.
147
+ var IteratorPrototype = {};
148
+ define(IteratorPrototype, iteratorSymbol, function () {
149
+ return this;
150
+ });
151
+
152
+ var getProto = Object.getPrototypeOf;
153
+ var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
154
+ if (NativeIteratorPrototype &&
155
+ NativeIteratorPrototype !== Op &&
156
+ hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
157
+ // This environment has a native %IteratorPrototype%; use it instead
158
+ // of the polyfill.
159
+ IteratorPrototype = NativeIteratorPrototype;
160
+ }
161
+
162
+ var Gp = GeneratorFunctionPrototype.prototype =
163
+ Generator.prototype = Object.create(IteratorPrototype);
164
+ GeneratorFunction.prototype = GeneratorFunctionPrototype;
165
+ define(Gp, "constructor", GeneratorFunctionPrototype);
166
+ define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
167
+ GeneratorFunction.displayName = define(
168
+ GeneratorFunctionPrototype,
169
+ toStringTagSymbol,
170
+ "GeneratorFunction"
171
+ );
172
+
173
+ // Helper for defining the .next, .throw, and .return methods of the
174
+ // Iterator interface in terms of a single ._invoke method.
175
+ function defineIteratorMethods(prototype) {
176
+ ["next", "throw", "return"].forEach(function(method) {
177
+ define(prototype, method, function(arg) {
178
+ return this._invoke(method, arg);
179
+ });
180
+ });
181
+ }
182
+
183
+ exports.isGeneratorFunction = function(genFun) {
184
+ var ctor = typeof genFun === "function" && genFun.constructor;
185
+ return ctor
186
+ ? ctor === GeneratorFunction ||
187
+ // For the native GeneratorFunction constructor, the best we can
188
+ // do is to check its .name property.
189
+ (ctor.displayName || ctor.name) === "GeneratorFunction"
190
+ : false;
191
+ };
192
+
193
+ exports.mark = function(genFun) {
194
+ if (Object.setPrototypeOf) {
195
+ Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
196
+ } else {
197
+ genFun.__proto__ = GeneratorFunctionPrototype;
198
+ define(genFun, toStringTagSymbol, "GeneratorFunction");
199
+ }
200
+ genFun.prototype = Object.create(Gp);
201
+ return genFun;
202
+ };
203
+
204
+ // Within the body of any async function, `await x` is transformed to
205
+ // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
206
+ // `hasOwn.call(value, "__await")` to determine if the yielded value is
207
+ // meant to be awaited.
208
+ exports.awrap = function(arg) {
209
+ return { __await: arg };
210
+ };
211
+
212
+ function AsyncIterator(generator, PromiseImpl) {
213
+ function invoke(method, arg, resolve, reject) {
214
+ var record = tryCatch(generator[method], generator, arg);
215
+ if (record.type === "throw") {
216
+ reject(record.arg);
217
+ } else {
218
+ var result = record.arg;
219
+ var value = result.value;
220
+ if (value &&
221
+ typeof value === "object" &&
222
+ hasOwn.call(value, "__await")) {
223
+ return PromiseImpl.resolve(value.__await).then(function(value) {
224
+ invoke("next", value, resolve, reject);
225
+ }, function(err) {
226
+ invoke("throw", err, resolve, reject);
227
+ });
228
+ }
229
+
230
+ return PromiseImpl.resolve(value).then(function(unwrapped) {
231
+ // When a yielded Promise is resolved, its final value becomes
232
+ // the .value of the Promise<{value,done}> result for the
233
+ // current iteration.
234
+ result.value = unwrapped;
235
+ resolve(result);
236
+ }, function(error) {
237
+ // If a rejected Promise was yielded, throw the rejection back
238
+ // into the async generator function so it can be handled there.
239
+ return invoke("throw", error, resolve, reject);
240
+ });
241
+ }
242
+ }
243
+
244
+ var previousPromise;
245
+
246
+ function enqueue(method, arg) {
247
+ function callInvokeWithMethodAndArg() {
248
+ return new PromiseImpl(function(resolve, reject) {
249
+ invoke(method, arg, resolve, reject);
250
+ });
251
+ }
252
+
253
+ return previousPromise =
254
+ // If enqueue has been called before, then we want to wait until
255
+ // all previous Promises have been resolved before calling invoke,
256
+ // so that results are always delivered in the correct order. If
257
+ // enqueue has not been called before, then it is important to
258
+ // call invoke immediately, without waiting on a callback to fire,
259
+ // so that the async generator function has the opportunity to do
260
+ // any necessary setup in a predictable way. This predictability
261
+ // is why the Promise constructor synchronously invokes its
262
+ // executor callback, and why async functions synchronously
263
+ // execute code before the first await. Since we implement simple
264
+ // async functions in terms of async generators, it is especially
265
+ // important to get this right, even though it requires care.
266
+ previousPromise ? previousPromise.then(
267
+ callInvokeWithMethodAndArg,
268
+ // Avoid propagating failures to Promises returned by later
269
+ // invocations of the iterator.
270
+ callInvokeWithMethodAndArg
271
+ ) : callInvokeWithMethodAndArg();
272
+ }
273
+
274
+ // Define the unified helper method that is used to implement .next,
275
+ // .throw, and .return (see defineIteratorMethods).
276
+ this._invoke = enqueue;
277
+ }
278
+
279
+ defineIteratorMethods(AsyncIterator.prototype);
280
+ define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
281
+ return this;
282
+ });
283
+ exports.AsyncIterator = AsyncIterator;
284
+
285
+ // Note that simple async functions are implemented on top of
286
+ // AsyncIterator objects; they just return a Promise for the value of
287
+ // the final result produced by the iterator.
288
+ exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
289
+ if (PromiseImpl === void 0) PromiseImpl = Promise;
290
+
291
+ var iter = new AsyncIterator(
292
+ wrap(innerFn, outerFn, self, tryLocsList),
293
+ PromiseImpl
294
+ );
295
+
296
+ return exports.isGeneratorFunction(outerFn)
297
+ ? iter // If outerFn is a generator, return the full iterator.
298
+ : iter.next().then(function(result) {
299
+ return result.done ? result.value : iter.next();
300
+ });
301
+ };
302
+
303
+ function makeInvokeMethod(innerFn, self, context) {
304
+ var state = GenStateSuspendedStart;
305
+
306
+ return function invoke(method, arg) {
307
+ if (state === GenStateExecuting) {
308
+ throw new Error("Generator is already running");
309
+ }
310
+
311
+ if (state === GenStateCompleted) {
312
+ if (method === "throw") {
313
+ throw arg;
314
+ }
315
+
316
+ // Be forgiving, per 25.3.3.3.3 of the spec:
317
+ // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
318
+ return doneResult();
319
+ }
320
+
321
+ context.method = method;
322
+ context.arg = arg;
323
+
324
+ while (true) {
325
+ var delegate = context.delegate;
326
+ if (delegate) {
327
+ var delegateResult = maybeInvokeDelegate(delegate, context);
328
+ if (delegateResult) {
329
+ if (delegateResult === ContinueSentinel) continue;
330
+ return delegateResult;
331
+ }
332
+ }
333
+
334
+ if (context.method === "next") {
335
+ // Setting context._sent for legacy support of Babel's
336
+ // function.sent implementation.
337
+ context.sent = context._sent = context.arg;
338
+
339
+ } else if (context.method === "throw") {
340
+ if (state === GenStateSuspendedStart) {
341
+ state = GenStateCompleted;
342
+ throw context.arg;
343
+ }
344
+
345
+ context.dispatchException(context.arg);
346
+
347
+ } else if (context.method === "return") {
348
+ context.abrupt("return", context.arg);
349
+ }
350
+
351
+ state = GenStateExecuting;
352
+
353
+ var record = tryCatch(innerFn, self, context);
354
+ if (record.type === "normal") {
355
+ // If an exception is thrown from innerFn, we leave state ===
356
+ // GenStateExecuting and loop back for another invocation.
357
+ state = context.done
358
+ ? GenStateCompleted
359
+ : GenStateSuspendedYield;
360
+
361
+ if (record.arg === ContinueSentinel) {
362
+ continue;
363
+ }
364
+
365
+ return {
366
+ value: record.arg,
367
+ done: context.done
368
+ };
369
+
370
+ } else if (record.type === "throw") {
371
+ state = GenStateCompleted;
372
+ // Dispatch the exception by looping back around to the
373
+ // context.dispatchException(context.arg) call above.
374
+ context.method = "throw";
375
+ context.arg = record.arg;
376
+ }
377
+ }
378
+ };
379
+ }
380
+
381
+ // Call delegate.iterator[context.method](context.arg) and handle the
382
+ // result, either by returning a { value, done } result from the
383
+ // delegate iterator, or by modifying context.method and context.arg,
384
+ // setting context.delegate to null, and returning the ContinueSentinel.
385
+ function maybeInvokeDelegate(delegate, context) {
386
+ var method = delegate.iterator[context.method];
387
+ if (method === undefined$1) {
388
+ // A .throw or .return when the delegate iterator has no .throw
389
+ // method always terminates the yield* loop.
390
+ context.delegate = null;
391
+
392
+ if (context.method === "throw") {
393
+ // Note: ["return"] must be used for ES3 parsing compatibility.
394
+ if (delegate.iterator["return"]) {
395
+ // If the delegate iterator has a return method, give it a
396
+ // chance to clean up.
397
+ context.method = "return";
398
+ context.arg = undefined$1;
399
+ maybeInvokeDelegate(delegate, context);
400
+
401
+ if (context.method === "throw") {
402
+ // If maybeInvokeDelegate(context) changed context.method from
403
+ // "return" to "throw", let that override the TypeError below.
404
+ return ContinueSentinel;
405
+ }
406
+ }
407
+
408
+ context.method = "throw";
409
+ context.arg = new TypeError(
410
+ "The iterator does not provide a 'throw' method");
411
+ }
412
+
413
+ return ContinueSentinel;
414
+ }
415
+
416
+ var record = tryCatch(method, delegate.iterator, context.arg);
417
+
418
+ if (record.type === "throw") {
419
+ context.method = "throw";
420
+ context.arg = record.arg;
421
+ context.delegate = null;
422
+ return ContinueSentinel;
423
+ }
424
+
425
+ var info = record.arg;
426
+
427
+ if (! info) {
428
+ context.method = "throw";
429
+ context.arg = new TypeError("iterator result is not an object");
430
+ context.delegate = null;
431
+ return ContinueSentinel;
432
+ }
433
+
434
+ if (info.done) {
435
+ // Assign the result of the finished delegate to the temporary
436
+ // variable specified by delegate.resultName (see delegateYield).
437
+ context[delegate.resultName] = info.value;
438
+
439
+ // Resume execution at the desired location (see delegateYield).
440
+ context.next = delegate.nextLoc;
441
+
442
+ // If context.method was "throw" but the delegate handled the
443
+ // exception, let the outer generator proceed normally. If
444
+ // context.method was "next", forget context.arg since it has been
445
+ // "consumed" by the delegate iterator. If context.method was
446
+ // "return", allow the original .return call to continue in the
447
+ // outer generator.
448
+ if (context.method !== "return") {
449
+ context.method = "next";
450
+ context.arg = undefined$1;
451
+ }
452
+
453
+ } else {
454
+ // Re-yield the result returned by the delegate method.
455
+ return info;
456
+ }
457
+
458
+ // The delegate iterator is finished, so forget it and continue with
459
+ // the outer generator.
460
+ context.delegate = null;
461
+ return ContinueSentinel;
462
+ }
463
+
464
+ // Define Generator.prototype.{next,throw,return} in terms of the
465
+ // unified ._invoke helper method.
466
+ defineIteratorMethods(Gp);
467
+
468
+ define(Gp, toStringTagSymbol, "Generator");
469
+
470
+ // A Generator should always return itself as the iterator object when the
471
+ // @@iterator function is called on it. Some browsers' implementations of the
472
+ // iterator prototype chain incorrectly implement this, causing the Generator
473
+ // object to not be returned from this call. This ensures that doesn't happen.
474
+ // See https://github.com/facebook/regenerator/issues/274 for more details.
475
+ define(Gp, iteratorSymbol, function() {
476
+ return this;
477
+ });
478
+
479
+ define(Gp, "toString", function() {
480
+ return "[object Generator]";
481
+ });
482
+
483
+ function pushTryEntry(locs) {
484
+ var entry = { tryLoc: locs[0] };
485
+
486
+ if (1 in locs) {
487
+ entry.catchLoc = locs[1];
488
+ }
489
+
490
+ if (2 in locs) {
491
+ entry.finallyLoc = locs[2];
492
+ entry.afterLoc = locs[3];
493
+ }
494
+
495
+ this.tryEntries.push(entry);
496
+ }
497
+
498
+ function resetTryEntry(entry) {
499
+ var record = entry.completion || {};
500
+ record.type = "normal";
501
+ delete record.arg;
502
+ entry.completion = record;
503
+ }
504
+
505
+ function Context(tryLocsList) {
506
+ // The root entry object (effectively a try statement without a catch
507
+ // or a finally block) gives us a place to store values thrown from
508
+ // locations where there is no enclosing try statement.
509
+ this.tryEntries = [{ tryLoc: "root" }];
510
+ tryLocsList.forEach(pushTryEntry, this);
511
+ this.reset(true);
512
+ }
513
+
514
+ exports.keys = function(object) {
515
+ var keys = [];
516
+ for (var key in object) {
517
+ keys.push(key);
518
+ }
519
+ keys.reverse();
520
+
521
+ // Rather than returning an object with a next method, we keep
522
+ // things simple and return the next function itself.
523
+ return function next() {
524
+ while (keys.length) {
525
+ var key = keys.pop();
526
+ if (key in object) {
527
+ next.value = key;
528
+ next.done = false;
529
+ return next;
530
+ }
531
+ }
532
+
533
+ // To avoid creating an additional object, we just hang the .value
534
+ // and .done properties off the next function object itself. This
535
+ // also ensures that the minifier will not anonymize the function.
536
+ next.done = true;
537
+ return next;
538
+ };
539
+ };
540
+
541
+ function values(iterable) {
542
+ if (iterable) {
543
+ var iteratorMethod = iterable[iteratorSymbol];
544
+ if (iteratorMethod) {
545
+ return iteratorMethod.call(iterable);
546
+ }
547
+
548
+ if (typeof iterable.next === "function") {
549
+ return iterable;
550
+ }
551
+
552
+ if (!isNaN(iterable.length)) {
553
+ var i = -1, next = function next() {
554
+ while (++i < iterable.length) {
555
+ if (hasOwn.call(iterable, i)) {
556
+ next.value = iterable[i];
557
+ next.done = false;
558
+ return next;
559
+ }
560
+ }
561
+
562
+ next.value = undefined$1;
563
+ next.done = true;
564
+
565
+ return next;
566
+ };
567
+
568
+ return next.next = next;
569
+ }
570
+ }
571
+
572
+ // Return an iterator with no values.
573
+ return { next: doneResult };
574
+ }
575
+ exports.values = values;
576
+
577
+ function doneResult() {
578
+ return { value: undefined$1, done: true };
579
+ }
580
+
581
+ Context.prototype = {
582
+ constructor: Context,
583
+
584
+ reset: function(skipTempReset) {
585
+ this.prev = 0;
586
+ this.next = 0;
587
+ // Resetting context._sent for legacy support of Babel's
588
+ // function.sent implementation.
589
+ this.sent = this._sent = undefined$1;
590
+ this.done = false;
591
+ this.delegate = null;
592
+
593
+ this.method = "next";
594
+ this.arg = undefined$1;
595
+
596
+ this.tryEntries.forEach(resetTryEntry);
597
+
598
+ if (!skipTempReset) {
599
+ for (var name in this) {
600
+ // Not sure about the optimal order of these conditions:
601
+ if (name.charAt(0) === "t" &&
602
+ hasOwn.call(this, name) &&
603
+ !isNaN(+name.slice(1))) {
604
+ this[name] = undefined$1;
605
+ }
606
+ }
607
+ }
608
+ },
609
+
610
+ stop: function() {
611
+ this.done = true;
612
+
613
+ var rootEntry = this.tryEntries[0];
614
+ var rootRecord = rootEntry.completion;
615
+ if (rootRecord.type === "throw") {
616
+ throw rootRecord.arg;
617
+ }
618
+
619
+ return this.rval;
620
+ },
621
+
622
+ dispatchException: function(exception) {
623
+ if (this.done) {
624
+ throw exception;
625
+ }
626
+
627
+ var context = this;
628
+ function handle(loc, caught) {
629
+ record.type = "throw";
630
+ record.arg = exception;
631
+ context.next = loc;
632
+
633
+ if (caught) {
634
+ // If the dispatched exception was caught by a catch block,
635
+ // then let that catch block handle the exception normally.
636
+ context.method = "next";
637
+ context.arg = undefined$1;
638
+ }
639
+
640
+ return !! caught;
641
+ }
642
+
643
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
644
+ var entry = this.tryEntries[i];
645
+ var record = entry.completion;
646
+
647
+ if (entry.tryLoc === "root") {
648
+ // Exception thrown outside of any try block that could handle
649
+ // it, so set the completion value of the entire function to
650
+ // throw the exception.
651
+ return handle("end");
652
+ }
653
+
654
+ if (entry.tryLoc <= this.prev) {
655
+ var hasCatch = hasOwn.call(entry, "catchLoc");
656
+ var hasFinally = hasOwn.call(entry, "finallyLoc");
657
+
658
+ if (hasCatch && hasFinally) {
659
+ if (this.prev < entry.catchLoc) {
660
+ return handle(entry.catchLoc, true);
661
+ } else if (this.prev < entry.finallyLoc) {
662
+ return handle(entry.finallyLoc);
663
+ }
664
+
665
+ } else if (hasCatch) {
666
+ if (this.prev < entry.catchLoc) {
667
+ return handle(entry.catchLoc, true);
668
+ }
669
+
670
+ } else if (hasFinally) {
671
+ if (this.prev < entry.finallyLoc) {
672
+ return handle(entry.finallyLoc);
673
+ }
674
+
675
+ } else {
676
+ throw new Error("try statement without catch or finally");
677
+ }
678
+ }
679
+ }
680
+ },
681
+
682
+ abrupt: function(type, arg) {
683
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
684
+ var entry = this.tryEntries[i];
685
+ if (entry.tryLoc <= this.prev &&
686
+ hasOwn.call(entry, "finallyLoc") &&
687
+ this.prev < entry.finallyLoc) {
688
+ var finallyEntry = entry;
689
+ break;
690
+ }
691
+ }
692
+
693
+ if (finallyEntry &&
694
+ (type === "break" ||
695
+ type === "continue") &&
696
+ finallyEntry.tryLoc <= arg &&
697
+ arg <= finallyEntry.finallyLoc) {
698
+ // Ignore the finally entry if control is not jumping to a
699
+ // location outside the try/catch block.
700
+ finallyEntry = null;
701
+ }
702
+
703
+ var record = finallyEntry ? finallyEntry.completion : {};
704
+ record.type = type;
705
+ record.arg = arg;
706
+
707
+ if (finallyEntry) {
708
+ this.method = "next";
709
+ this.next = finallyEntry.finallyLoc;
710
+ return ContinueSentinel;
711
+ }
712
+
713
+ return this.complete(record);
714
+ },
715
+
716
+ complete: function(record, afterLoc) {
717
+ if (record.type === "throw") {
718
+ throw record.arg;
719
+ }
720
+
721
+ if (record.type === "break" ||
722
+ record.type === "continue") {
723
+ this.next = record.arg;
724
+ } else if (record.type === "return") {
725
+ this.rval = this.arg = record.arg;
726
+ this.method = "return";
727
+ this.next = "end";
728
+ } else if (record.type === "normal" && afterLoc) {
729
+ this.next = afterLoc;
730
+ }
731
+
732
+ return ContinueSentinel;
733
+ },
734
+
735
+ finish: function(finallyLoc) {
736
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
737
+ var entry = this.tryEntries[i];
738
+ if (entry.finallyLoc === finallyLoc) {
739
+ this.complete(entry.completion, entry.afterLoc);
740
+ resetTryEntry(entry);
741
+ return ContinueSentinel;
742
+ }
743
+ }
744
+ },
745
+
746
+ "catch": function(tryLoc) {
747
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
748
+ var entry = this.tryEntries[i];
749
+ if (entry.tryLoc === tryLoc) {
750
+ var record = entry.completion;
751
+ if (record.type === "throw") {
752
+ var thrown = record.arg;
753
+ resetTryEntry(entry);
754
+ }
755
+ return thrown;
756
+ }
757
+ }
758
+
759
+ // The context.catch method must only be called with a location
760
+ // argument that corresponds to a known catch block.
761
+ throw new Error("illegal catch attempt");
762
+ },
763
+
764
+ delegateYield: function(iterable, resultName, nextLoc) {
765
+ this.delegate = {
766
+ iterator: values(iterable),
767
+ resultName: resultName,
768
+ nextLoc: nextLoc
769
+ };
770
+
771
+ if (this.method === "next") {
772
+ // Deliberately forget the last sent value so that we don't
773
+ // accidentally pass it on to the delegate.
774
+ this.arg = undefined$1;
775
+ }
776
+
777
+ return ContinueSentinel;
778
+ }
779
+ };
780
+
781
+ // Regardless of whether this script is executing as a CommonJS module
782
+ // or not, return the runtime object so that we can declare the variable
783
+ // regeneratorRuntime in the outer scope, which allows this module to be
784
+ // injected easily by `bin/regenerator --include-runtime script.js`.
785
+ return exports;
786
+
787
+ }(
788
+ // If this script is executing as a CommonJS module, use module.exports
789
+ // as the regeneratorRuntime namespace. Otherwise create a new empty
790
+ // object. Either way, the resulting object will be used to initialize
791
+ // the regeneratorRuntime variable at the top of this file.
792
+ module.exports
793
+ ));
794
+
795
+ try {
796
+ regeneratorRuntime = runtime;
797
+ } catch (accidentalStrictMode) {
798
+ // This module should not be running in strict mode, so the above
799
+ // assignment should always work unless something is misconfigured. Just
800
+ // in case runtime.js accidentally runs in strict mode, in modern engines
801
+ // we can explicitly access globalThis. In older engines we can escape
802
+ // strict mode using a global Function call. This could conceivably fail
803
+ // if a Content Security Policy forbids using Function, but in that case
804
+ // the proper solution is to fix the accidental strict mode problem. If
805
+ // you've misconfigured your bundler to force strict mode and applied a
806
+ // CSP to forbid Function, and you're not willing to fix either of those
807
+ // problems, please detail your unique predicament in a GitHub issue.
808
+ if (typeof globalThis === "object") {
809
+ globalThis.regeneratorRuntime = runtime;
810
+ } else {
811
+ Function("r", "regeneratorRuntime = r")(runtime);
812
+ }
813
+ }
814
+ }(runtime));
815
+
816
+ var _regeneratorRuntime = runtime.exports;
817
+
818
+ var CharType;
819
+
820
+ (function (CharType) {
821
+ CharType["Word"] = "word";
822
+ CharType["End"] = "end";
823
+ CharType["Pause"] = "pause";
824
+ CharType["Sajdah"] = "sajdah";
825
+ CharType["RubElHizb"] = "rub-el-hizb";
826
+ })(CharType || (CharType = {}));
827
+
828
+ var Language;
829
+
830
+ (function (Language) {
831
+ Language["ARABIC"] = "ar";
832
+ Language["ENGLISH"] = "en";
833
+ Language["URDU"] = "ur";
834
+ Language["BENGALI"] = "bn";
835
+ Language["TURKISH"] = "tr";
836
+ Language["SPANISH"] = "es";
837
+ Language["GERMAN"] = "de";
838
+ Language["BOSNIAN"] = "bs";
839
+ Language["RUSSIAN"] = "ru";
840
+ Language["ALBANIAN_AL"] = "al";
841
+ Language["FRENCH"] = "fr";
842
+ Language["DUTCH"] = "nl";
843
+ Language["TAMIL"] = "ta";
844
+ Language["TAJIK"] = "tg";
845
+ Language["INDONESIAN"] = "id";
846
+ Language["UZBEK"] = "uz";
847
+ Language["VIETNAMESE"] = "vi";
848
+ Language["CHINESE"] = "zh";
849
+ Language["ITALIAN"] = "it";
850
+ Language["JAPANESE"] = "ja";
851
+ Language["MALAYALAM"] = "ml";
852
+ Language["AMHARIC"] = "am";
853
+ Language["KAZAKH"] = "kk";
854
+ Language["PORTUGUESE"] = "pt";
855
+ Language["TAGALOG"] = "tl";
856
+ Language["THAI"] = "th";
857
+ Language["KOREAN"] = "ko";
858
+ Language["HINDI"] = "hi";
859
+ Language["KURDISH"] = "ku";
860
+ Language["HAUSA"] = "ha";
861
+ Language["AZERI"] = "az";
862
+ Language["SWAHILI"] = "sw";
863
+ Language["PERSIAN"] = "fa";
864
+ Language["SERBIAN"] = "sr";
865
+ Language["MARANAO"] = "mrn";
866
+ Language["AMAZIGH"] = "zgh";
867
+ Language["ASSAMESE"] = "as";
868
+ Language["BULGARIAN"] = "bg";
869
+ Language["CHECHEN"] = "ce";
870
+ Language["CZECH"] = "cs";
871
+ Language["DIVEHI"] = "dv";
872
+ Language["DHIVEHI"] = "dv";
873
+ Language["MALDIVIAN"] = "dv";
874
+ Language["FINNISH"] = "fi";
875
+ Language["GUJAARATI"] = "gu";
876
+ Language["HEBREW"] = "he";
877
+ Language["GEORGIAN"] = "ka";
878
+ Language["CENTRAL_KHMER"] = "km";
879
+ Language["GANDA"] = "lg";
880
+ Language["MARATHI"] = "mr";
881
+ Language["YORUBA"] = "yo";
882
+ Language["MALAY"] = "ms";
883
+ Language["NEPALI"] = "ne";
884
+ Language["SWEDISH"] = "sv";
885
+ Language["TELUGU"] = "te";
886
+ Language["TATAR"] = "tt";
887
+ Language["UIGHUR"] = "ug";
888
+ Language["UYGHUR"] = "ug";
889
+ Language["UKRAINIAN"] = "uk";
890
+ Language["NORWEGIAN"] = "no";
891
+ Language["OROMO"] = "om";
892
+ Language["POLISH"] = "pl";
893
+ Language["PASHTO"] = "ps";
894
+ Language["ROMANIAN"] = "ro";
895
+ Language["SINDHI"] = "sd";
896
+ Language["NORTHERN_SAMI"] = "se";
897
+ Language["SINHALA"] = "si";
898
+ Language["SINHALESE"] = "si";
899
+ Language["SOMALI"] = "so";
900
+ Language["ALBANIAN_SQ"] = "sq";
901
+ })(Language || (Language = {}));
902
+
903
+ var QuranFont;
904
+
905
+ (function (QuranFont) {
906
+ QuranFont["MadaniV1"] = "code_v1";
907
+ QuranFont["MadaniV2"] = "code_v2";
908
+ QuranFont["Uthmani"] = "text_uthmani";
909
+ })(QuranFont || (QuranFont = {}));
910
+
911
+ // Reference: https://github.com/billjs/query-string/blob/master/src/index.ts
912
+ var defaultStringifyFunction = function defaultStringifyFunction(_key, value) {
913
+ return value;
914
+ };
915
+
916
+ var defaultEq = '=';
917
+ var defaultSep = '&';
918
+ var defaultConfig = {
919
+ eq: defaultEq,
920
+ sep: defaultSep,
921
+ prefix: '',
922
+ fn: defaultStringifyFunction
923
+ };
924
+ /**
925
+ * Given a query object, return the query string
926
+ * See qs-stringify.test.ts for examples
927
+ *
928
+ * @param {QueryObject} obj a query object to be converted to a query string
929
+ * @param {Config} config optional configuration
930
+ * @returns {string} query string
931
+ *
932
+ * @example
933
+ * stringify({a: 1, b: 2}) // returns 'a=1&b=s'
934
+ */
935
+
936
+ function stringify(obj, config) {
937
+ if (config === void 0) {
938
+ config = defaultConfig;
939
+ }
940
+
941
+ var _defaultConfig$config = _extends({}, defaultConfig, config),
942
+ eq = _defaultConfig$config.eq,
943
+ sep = _defaultConfig$config.sep,
944
+ fn = _defaultConfig$config.fn,
945
+ prefix = _defaultConfig$config.prefix;
946
+
947
+ if (obj == null || !isObject(obj)) {
948
+ return '';
949
+ }
950
+
951
+ return Object.entries(obj).filter(function (_ref) {
952
+ var value = _ref[1];
953
+ return value !== null;
954
+ }) // filter out null values
955
+ .map(function (_ref2) {
956
+ var key = _ref2[0],
957
+ value = _ref2[1];
958
+ if (Array.isArray(value)) return encode(key, value.join(','), {
959
+ eq: eq,
960
+ fn: fn,
961
+ prefix: prefix
962
+ });
963
+ if (isObject(value)) return stringify(value, {
964
+ eq: eq,
965
+ sep: sep,
966
+ fn: fn,
967
+ prefix: getKey(key, prefix)
968
+ });
969
+ return encode(key, value, {
970
+ eq: eq,
971
+ fn: fn,
972
+ prefix: prefix
973
+ });
974
+ }).join(sep);
975
+ } // encode the key and add prefix if necessary
976
+
977
+
978
+ var getKey = function getKey(key, prefix) {
979
+ if (prefix === void 0) {
980
+ prefix = '';
981
+ }
982
+
983
+ var encodedKey = encodeURIComponent(key);
984
+ if (prefix) return prefix + "[" + encodedKey + "]";
985
+ return encodedKey;
986
+ }; // encode the key and value of a query object
987
+
988
+
989
+ var encode = function encode(key, value, _ref3) {
990
+ var _ref3$eq = _ref3.eq,
991
+ eq = _ref3$eq === void 0 ? defaultEq : _ref3$eq,
992
+ _ref3$fn = _ref3.fn,
993
+ fn = _ref3$fn === void 0 ? defaultStringifyFunction : _ref3$fn,
994
+ _ref3$prefix = _ref3.prefix,
995
+ prefix = _ref3$prefix === void 0 ? '' : _ref3$prefix;
996
+ var newValue = encodeURIComponent(fn(key, value));
997
+ var newKey = getKey(key, prefix);
998
+ return [newKey, newValue].join(eq);
999
+ }; // check if the given value is an object
1000
+
1001
+
1002
+ function isObject(obj) {
1003
+ var type = typeof obj;
1004
+ return obj && (type === 'object' || type === 'function') || false;
1005
+ }
1006
+
1007
+ var removeBeginningSlash = function removeBeginningSlash(url) {
1008
+ return url.startsWith('/') ? url.slice(1) : url;
1009
+ };
1010
+
1011
+ var API_BASE_URL = 'https://api.quran.com/api/v4/';
1012
+ var makeUrl = function makeUrl(url, params) {
1013
+ var baseUrl = "" + API_BASE_URL + removeBeginningSlash(url);
1014
+ if (!params) return baseUrl;
1015
+ var decamelizedKeys = decamelizeKeys(params);
1016
+ var paramsString = stringify(decamelizedKeys);
1017
+ if (!paramsString) return baseUrl;
1018
+ return baseUrl + "?" + paramsString;
1019
+ };
1020
+ var fetcher = /*#__PURE__*/function () {
1021
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url, params) {
1022
+ var res, json;
1023
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1024
+ while (1) {
1025
+ switch (_context.prev = _context.next) {
1026
+ case 0:
1027
+ if (params === void 0) {
1028
+ params = {};
1029
+ }
1030
+
1031
+ _context.next = 3;
1032
+ return fetch(makeUrl(url, params));
1033
+
1034
+ case 3:
1035
+ res = _context.sent;
1036
+
1037
+ if (!(res.status >= 400)) {
1038
+ _context.next = 6;
1039
+ break;
1040
+ }
1041
+
1042
+ throw new Error(res.status + " " + res.statusText);
1043
+
1044
+ case 6:
1045
+ _context.next = 8;
1046
+ return res.json();
1047
+
1048
+ case 8:
1049
+ json = _context.sent;
1050
+ return _context.abrupt("return", camelizeKeys(json));
1051
+
1052
+ case 10:
1053
+ case "end":
1054
+ return _context.stop();
1055
+ }
1056
+ }
1057
+ }, _callee);
1058
+ }));
1059
+
1060
+ return function fetcher(_x, _x2) {
1061
+ return _ref.apply(this, arguments);
1062
+ };
1063
+ }();
1064
+
1065
+ // this maps chapterNumber to verseCount
1066
+ var versesMaping = {
1067
+ '1': 7,
1068
+ '2': 286,
1069
+ '3': 200,
1070
+ '4': 176,
1071
+ '5': 120,
1072
+ '6': 165,
1073
+ '7': 206,
1074
+ '8': 75,
1075
+ '9': 129,
1076
+ '10': 109,
1077
+ '11': 123,
1078
+ '12': 111,
1079
+ '13': 43,
1080
+ '14': 52,
1081
+ '15': 99,
1082
+ '16': 128,
1083
+ '17': 111,
1084
+ '18': 110,
1085
+ '19': 98,
1086
+ '20': 135,
1087
+ '21': 112,
1088
+ '22': 78,
1089
+ '23': 118,
1090
+ '24': 64,
1091
+ '25': 77,
1092
+ '26': 227,
1093
+ '27': 93,
1094
+ '28': 88,
1095
+ '29': 69,
1096
+ '30': 60,
1097
+ '31': 34,
1098
+ '32': 30,
1099
+ '33': 73,
1100
+ '34': 54,
1101
+ '35': 45,
1102
+ '36': 83,
1103
+ '37': 182,
1104
+ '38': 88,
1105
+ '39': 75,
1106
+ '40': 85,
1107
+ '41': 54,
1108
+ '42': 53,
1109
+ '43': 89,
1110
+ '44': 59,
1111
+ '45': 37,
1112
+ '46': 35,
1113
+ '47': 38,
1114
+ '48': 29,
1115
+ '49': 18,
1116
+ '50': 45,
1117
+ '51': 60,
1118
+ '52': 49,
1119
+ '53': 62,
1120
+ '54': 55,
1121
+ '55': 78,
1122
+ '56': 96,
1123
+ '57': 29,
1124
+ '58': 22,
1125
+ '59': 24,
1126
+ '60': 13,
1127
+ '61': 14,
1128
+ '62': 11,
1129
+ '63': 11,
1130
+ '64': 18,
1131
+ '65': 12,
1132
+ '66': 12,
1133
+ '67': 30,
1134
+ '68': 52,
1135
+ '69': 52,
1136
+ '70': 44,
1137
+ '71': 28,
1138
+ '72': 28,
1139
+ '73': 20,
1140
+ '74': 56,
1141
+ '75': 40,
1142
+ '76': 31,
1143
+ '77': 50,
1144
+ '78': 40,
1145
+ '79': 46,
1146
+ '80': 42,
1147
+ '81': 29,
1148
+ '82': 19,
1149
+ '83': 36,
1150
+ '84': 25,
1151
+ '85': 22,
1152
+ '86': 17,
1153
+ '87': 19,
1154
+ '88': 26,
1155
+ '89': 30,
1156
+ '90': 20,
1157
+ '91': 15,
1158
+ '92': 21,
1159
+ '93': 11,
1160
+ '94': 8,
1161
+ '95': 8,
1162
+ '96': 19,
1163
+ '97': 5,
1164
+ '98': 8,
1165
+ '99': 8,
1166
+ '100': 11,
1167
+ '101': 11,
1168
+ '102': 8,
1169
+ '103': 3,
1170
+ '104': 9,
1171
+ '105': 5,
1172
+ '106': 4,
1173
+ '107': 7,
1174
+ '108': 3,
1175
+ '109': 6,
1176
+ '110': 3,
1177
+ '111': 5,
1178
+ '112': 4,
1179
+ '113': 5,
1180
+ '114': 6
1181
+ };
1182
+ /**
1183
+ * Validates chapter id
1184
+ * @param id chapter id
1185
+ * @example
1186
+ isValidChapterId('1') // true
1187
+ isValidChapterId('114') // true
1188
+ isValidChapterId('0') // false
1189
+ isValidChapterId('-1') // false
1190
+ isValidChapterId('200') // false
1191
+ */
1192
+
1193
+ var isValidChapterId = function isValidChapterId(id) {
1194
+ var parsedId = typeof id === 'number' ? id : Number(id);
1195
+ if (!parsedId || parsedId <= 0 || parsedId > 114) return false;
1196
+ return true;
1197
+ };
1198
+ /**
1199
+ * Validates juz number
1200
+ * @param juz juz number
1201
+ * @example
1202
+ isValidJuz('1') // true
1203
+ isValidJuz('30') // true
1204
+ isValidJuz('0') // false
1205
+ isValidJuz('-1') // false
1206
+ isValidJuz('200') // false
1207
+ */
1208
+
1209
+
1210
+ var isValidJuz = function isValidJuz(juz) {
1211
+ var parsedJuz = typeof juz === 'number' ? juz : Number(juz);
1212
+ if (!parsedJuz || parsedJuz <= 0 || parsedJuz > 30) return false;
1213
+ return true;
1214
+ };
1215
+ /**
1216
+ * Validates rub number
1217
+ * @param rub rub number
1218
+ * @example
1219
+ isValidRub('1') // true
1220
+ isValidRub('240') // true
1221
+ isValidRub('0') // false
1222
+ isValidRub('-1') // false
1223
+ isValidRub('300') // false
1224
+ */
1225
+
1226
+
1227
+ var isValidRub = function isValidRub(rub) {
1228
+ var parsedRub = typeof rub === 'number' ? rub : Number(rub);
1229
+ if (!parsedRub || parsedRub <= 0 || parsedRub > 240) return false;
1230
+ return true;
1231
+ };
1232
+ /**
1233
+ * Validates hizb number
1234
+ * @param hizb hizb number
1235
+ * @example
1236
+ isValidHizb('1') // true
1237
+ isValidHizb('60') // true
1238
+ isValidHizb('0') // false
1239
+ isValidHizb('-1') // false
1240
+ isValidHizb('200') // false
1241
+ */
1242
+
1243
+
1244
+ var isValidHizb = function isValidHizb(hizb) {
1245
+ var parsedHizb = typeof hizb === 'number' ? hizb : Number(hizb);
1246
+ if (!parsedHizb || parsedHizb <= 0 || parsedHizb > 60) return false;
1247
+ return true;
1248
+ };
1249
+ /**
1250
+ * Validates mushaf page number
1251
+ * @param page mushaf page number
1252
+ * @example
1253
+ isValidQuranPage('1') // true
1254
+ isValidQuranPage('604') // true
1255
+ isValidQuranPage('0') // false
1256
+ isValidQuranPage('-1') // false
1257
+ isValidQuranPage('1000') // false
1258
+ */
1259
+
1260
+
1261
+ var isValidQuranPage = function isValidQuranPage(page) {
1262
+ var parsedPage = typeof page === 'number' ? page : Number(page);
1263
+ if (!parsedPage || parsedPage <= 0 || parsedPage > 604) return false;
1264
+ return true;
1265
+ };
1266
+ /**
1267
+ * Validates verse key
1268
+ * @param key colon separated verse key (chapter:verse)
1269
+ * @example
1270
+ isValidVerseKey('1:1') // true
1271
+ isValidVerseKey('30:1') // true
1272
+ isValidVerseKey('0') // false
1273
+ isValidVerseKey('1:-') // false
1274
+ isValidVerseKey('1_1') // false
1275
+ */
1276
+
1277
+
1278
+ var isValidVerseKey = function isValidVerseKey(key) {
1279
+ var _key$trim$split = key.trim().split(':'),
1280
+ chapterId = _key$trim$split[0],
1281
+ verseId = _key$trim$split[1];
1282
+
1283
+ if (!chapterId || !verseId || !isValidChapterId(chapterId)) return false;
1284
+ var parsedVerse = Number(verseId);
1285
+ var verseCount = versesMaping[chapterId];
1286
+ if (!parsedVerse || parsedVerse <= 0 || parsedVerse > verseCount) return false;
1287
+ return true;
1288
+ };
1289
+
1290
+ var Utils = {
1291
+ isValidChapterId: isValidChapterId,
1292
+ isValidJuz: isValidJuz,
1293
+ isValidRub: isValidRub,
1294
+ isValidHizb: isValidHizb,
1295
+ isValidQuranPage: isValidQuranPage,
1296
+ isValidVerseKey: isValidVerseKey
1297
+ };
1298
+
1299
+ var defaultOptions$2 = {
1300
+ language: Language.ARABIC
1301
+ };
1302
+
1303
+ var getChapterOptions = function getChapterOptions(options) {
1304
+ if (options === void 0) {
1305
+ options = {};
1306
+ }
1307
+
1308
+ var _final = _extends({}, defaultOptions$2, options);
1309
+
1310
+ return _final;
1311
+ };
1312
+ /**
1313
+ * Get all chapters.
1314
+ * @description https://quran.api-docs.io/v4/chapters/list-chapters
1315
+ * @param {Options} options
1316
+ * @example
1317
+ * quran.v4.chapters.findAll()
1318
+ */
1319
+
1320
+
1321
+ var findAll$1 = /*#__PURE__*/function () {
1322
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
1323
+ var params, _yield$fetcher, chapters;
1324
+
1325
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1326
+ while (1) {
1327
+ switch (_context.prev = _context.next) {
1328
+ case 0:
1329
+ params = getChapterOptions(options);
1330
+ _context.next = 3;
1331
+ return fetcher('/chapters', params);
1332
+
1333
+ case 3:
1334
+ _yield$fetcher = _context.sent;
1335
+ chapters = _yield$fetcher.chapters;
1336
+ return _context.abrupt("return", chapters);
1337
+
1338
+ case 6:
1339
+ case "end":
1340
+ return _context.stop();
1341
+ }
1342
+ }
1343
+ }, _callee);
1344
+ }));
1345
+
1346
+ return function findAll(_x) {
1347
+ return _ref.apply(this, arguments);
1348
+ };
1349
+ }();
1350
+ /**
1351
+ * Get chapter by id.
1352
+ * @description https://quran.api-docs.io/v4/chapters/get-chapter
1353
+ * @param {ChapterId} id chapter id, minimum 1, maximum 114
1354
+ * @param {Options} options
1355
+ * @example
1356
+ * quran.v4.chapters.findById('1')
1357
+ * quran.v4.chapters.findById('114')
1358
+ */
1359
+
1360
+
1361
+ var findById = /*#__PURE__*/function () {
1362
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, options) {
1363
+ var params, _yield$fetcher2, chapter;
1364
+
1365
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1366
+ while (1) {
1367
+ switch (_context2.prev = _context2.next) {
1368
+ case 0:
1369
+ if (Utils.isValidChapterId(id)) {
1370
+ _context2.next = 2;
1371
+ break;
1372
+ }
1373
+
1374
+ throw new Error('Invalid chapter id');
1375
+
1376
+ case 2:
1377
+ params = getChapterOptions(options);
1378
+ _context2.next = 5;
1379
+ return fetcher("/chapters/" + id, params);
1380
+
1381
+ case 5:
1382
+ _yield$fetcher2 = _context2.sent;
1383
+ chapter = _yield$fetcher2.chapter;
1384
+ return _context2.abrupt("return", chapter);
1385
+
1386
+ case 8:
1387
+ case "end":
1388
+ return _context2.stop();
1389
+ }
1390
+ }
1391
+ }, _callee2);
1392
+ }));
1393
+
1394
+ return function findById(_x2, _x3) {
1395
+ return _ref2.apply(this, arguments);
1396
+ };
1397
+ }();
1398
+ /**
1399
+ * Get chapter info by id.
1400
+ * @description https://quran.api-docs.io/v4/chapters/chapter_info
1401
+ * @param {ChapterId} id chapter id, minimum 1, maximum 114
1402
+ * @param {Options} options
1403
+ * @example
1404
+ * quran.v4.chapters.findInfoById('1')
1405
+ * quran.v4.chapters.findInfoById('114')
1406
+ */
1407
+
1408
+
1409
+ var findInfoById = /*#__PURE__*/function () {
1410
+ var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(id, options) {
1411
+ var params, _yield$fetcher3, chapterInfo;
1412
+
1413
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
1414
+ while (1) {
1415
+ switch (_context3.prev = _context3.next) {
1416
+ case 0:
1417
+ if (Utils.isValidChapterId(id)) {
1418
+ _context3.next = 2;
1419
+ break;
1420
+ }
1421
+
1422
+ throw new Error('Invalid chapter id');
1423
+
1424
+ case 2:
1425
+ params = getChapterOptions(options);
1426
+ _context3.next = 5;
1427
+ return fetcher("/chapters/" + id + "/info", params);
1428
+
1429
+ case 5:
1430
+ _yield$fetcher3 = _context3.sent;
1431
+ chapterInfo = _yield$fetcher3.chapterInfo;
1432
+ return _context3.abrupt("return", chapterInfo);
1433
+
1434
+ case 8:
1435
+ case "end":
1436
+ return _context3.stop();
1437
+ }
1438
+ }
1439
+ }, _callee3);
1440
+ }));
1441
+
1442
+ return function findInfoById(_x4, _x5) {
1443
+ return _ref3.apply(this, arguments);
1444
+ };
1445
+ }();
1446
+
1447
+ var chapters = {
1448
+ findAll: findAll$1,
1449
+ findById: findById,
1450
+ findInfoById: findInfoById
1451
+ };
1452
+
1453
+ var defaultOptions$1 = {
1454
+ language: Language.ARABIC,
1455
+ perPage: 50
1456
+ };
1457
+
1458
+ var getVerseOptions = function getVerseOptions(options) {
1459
+ if (options === void 0) {
1460
+ options = {};
1461
+ }
1462
+
1463
+ var initial = _extends({}, defaultOptions$1, options);
1464
+
1465
+ var result = {
1466
+ language: initial.language,
1467
+ perPage: initial.perPage
1468
+ };
1469
+ if (initial.page) result.page = initial.page;
1470
+ if (initial.words !== undefined) result.words = initial.words;
1471
+ if (initial.translations) result.translations = initial.translations.join(',');
1472
+ if (initial.tafsirs) result.tafsirs = initial.tafsirs.join(',');
1473
+
1474
+ if (initial.fields) {
1475
+ var fields = [];
1476
+
1477
+ for (var _i = 0, _Object$entries = Object.entries(initial.fields); _i < _Object$entries.length; _i++) {
1478
+ var _Object$entries$_i = _Object$entries[_i],
1479
+ key = _Object$entries$_i[0],
1480
+ value = _Object$entries$_i[1];
1481
+ if (value) fields.push(decamelize(key));
1482
+ }
1483
+
1484
+ result.fields = fields.join(',');
1485
+ }
1486
+
1487
+ if (initial.wordFields) {
1488
+ var wordFields = [];
1489
+
1490
+ for (var _i2 = 0, _Object$entries2 = Object.entries(initial.wordFields); _i2 < _Object$entries2.length; _i2++) {
1491
+ var _Object$entries2$_i = _Object$entries2[_i2],
1492
+ _key = _Object$entries2$_i[0],
1493
+ _value = _Object$entries2$_i[1];
1494
+ if (_value) wordFields.push(decamelize(_key));
1495
+ }
1496
+
1497
+ result.wordFields = wordFields.join(',');
1498
+ }
1499
+
1500
+ if (initial.translationFields) {
1501
+ var translationFields = [];
1502
+
1503
+ for (var _i3 = 0, _Object$entries3 = Object.entries(initial.translationFields); _i3 < _Object$entries3.length; _i3++) {
1504
+ var _Object$entries3$_i = _Object$entries3[_i3],
1505
+ _key2 = _Object$entries3$_i[0],
1506
+ _value2 = _Object$entries3$_i[1];
1507
+ if (_value2) translationFields.push(decamelize(_key2));
1508
+ }
1509
+
1510
+ result.translationFields = translationFields.join(',');
1511
+ }
1512
+
1513
+ if (initial.reciter) result.audio = initial.reciter;
1514
+ return result;
1515
+ };
1516
+ /**
1517
+ * Get a specific ayah with key. Key is combination of surah number and ayah number.
1518
+ * @description https://quran.api-docs.io/v4/verses/by-specific-verse-by-key
1519
+ * @param {VerseKey} key - surah number and ayah number separated by a colon.
1520
+ * @param {GetVerseOptions} options
1521
+ * @example
1522
+ * quran.v4.verses.findByKey('1:1')
1523
+ * quran.v4.verses.findByKey('101:5')
1524
+ */
1525
+
1526
+
1527
+ var findByKey = /*#__PURE__*/function () {
1528
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(key, options) {
1529
+ var params, url, _yield$fetcher, verse;
1530
+
1531
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1532
+ while (1) {
1533
+ switch (_context.prev = _context.next) {
1534
+ case 0:
1535
+ if (Utils.isValidVerseKey(key)) {
1536
+ _context.next = 2;
1537
+ break;
1538
+ }
1539
+
1540
+ throw new Error('Invalid verse key');
1541
+
1542
+ case 2:
1543
+ params = getVerseOptions(options);
1544
+ url = "/verses/by_key/" + key;
1545
+ _context.next = 6;
1546
+ return fetcher(url, params);
1547
+
1548
+ case 6:
1549
+ _yield$fetcher = _context.sent;
1550
+ verse = _yield$fetcher.verse;
1551
+ return _context.abrupt("return", verse);
1552
+
1553
+ case 9:
1554
+ case "end":
1555
+ return _context.stop();
1556
+ }
1557
+ }
1558
+ }, _callee);
1559
+ }));
1560
+
1561
+ return function findByKey(_x, _x2) {
1562
+ return _ref.apply(this, arguments);
1563
+ };
1564
+ }();
1565
+ /**
1566
+ * Get all ayahs for a specific chapter (surah).
1567
+ * @description https://quran.api-docs.io/v4/verses/by_chapter
1568
+ * @param {ChapterId} id - chapter id (surah number)
1569
+ * @param {GetVerseOptions} options
1570
+ * @example
1571
+ * quran.v4.verses.findByChapter('1')
1572
+ * quran.v4.verses.findByChapter('101')
1573
+ */
1574
+
1575
+
1576
+ var findByChapter = /*#__PURE__*/function () {
1577
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(id, options) {
1578
+ var params, url, _yield$fetcher2, verses;
1579
+
1580
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1581
+ while (1) {
1582
+ switch (_context2.prev = _context2.next) {
1583
+ case 0:
1584
+ if (Utils.isValidChapterId(id)) {
1585
+ _context2.next = 2;
1586
+ break;
1587
+ }
1588
+
1589
+ throw new Error('Invalid chapter id');
1590
+
1591
+ case 2:
1592
+ params = getVerseOptions(options);
1593
+ url = "/verses/by_chapter/" + id;
1594
+ _context2.next = 6;
1595
+ return fetcher(url, params);
1596
+
1597
+ case 6:
1598
+ _yield$fetcher2 = _context2.sent;
1599
+ verses = _yield$fetcher2.verses;
1600
+ return _context2.abrupt("return", verses);
1601
+
1602
+ case 9:
1603
+ case "end":
1604
+ return _context2.stop();
1605
+ }
1606
+ }
1607
+ }, _callee2);
1608
+ }));
1609
+
1610
+ return function findByChapter(_x3, _x4) {
1611
+ return _ref2.apply(this, arguments);
1612
+ };
1613
+ }();
1614
+ /**
1615
+ * Get all ayahs for a specific page in the Quran.
1616
+ * @description https://quran.api-docs.io/v4/verses/by-page
1617
+ * @param {PageNumber} page - Quran page number
1618
+ * @param {GetVerseOptions} options
1619
+ * @example
1620
+ * quran.v4.verses.findByPage('1')
1621
+ * quran.v4.verses.findByPage('101')
1622
+ */
1623
+
1624
+
1625
+ var findByPage = /*#__PURE__*/function () {
1626
+ var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(page, options) {
1627
+ var params, url, _yield$fetcher3, verses;
1628
+
1629
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
1630
+ while (1) {
1631
+ switch (_context3.prev = _context3.next) {
1632
+ case 0:
1633
+ if (Utils.isValidQuranPage(page)) {
1634
+ _context3.next = 2;
1635
+ break;
1636
+ }
1637
+
1638
+ throw new Error('Invalid page');
1639
+
1640
+ case 2:
1641
+ params = getVerseOptions(options);
1642
+ url = "/verses/by_page/" + page;
1643
+ _context3.next = 6;
1644
+ return fetcher(url, params);
1645
+
1646
+ case 6:
1647
+ _yield$fetcher3 = _context3.sent;
1648
+ verses = _yield$fetcher3.verses;
1649
+ return _context3.abrupt("return", verses);
1650
+
1651
+ case 9:
1652
+ case "end":
1653
+ return _context3.stop();
1654
+ }
1655
+ }
1656
+ }, _callee3);
1657
+ }));
1658
+
1659
+ return function findByPage(_x5, _x6) {
1660
+ return _ref3.apply(this, arguments);
1661
+ };
1662
+ }();
1663
+ /**
1664
+ * Get all ayahs for a Juz.
1665
+ * @description https://quran.api-docs.io/v4/verses/by-juz
1666
+ * @param {JuzNumber} id - juz number
1667
+ * @param {GetVerseOptions} options
1668
+ * @example
1669
+ * quran.v4.verses.findByJuz('1')
1670
+ * quran.v4.verses.findByJuz('29')
1671
+ */
1672
+
1673
+
1674
+ var findByJuz = /*#__PURE__*/function () {
1675
+ var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(juz, options) {
1676
+ var params, url, _yield$fetcher4, verses;
1677
+
1678
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
1679
+ while (1) {
1680
+ switch (_context4.prev = _context4.next) {
1681
+ case 0:
1682
+ if (Utils.isValidJuz(juz)) {
1683
+ _context4.next = 2;
1684
+ break;
1685
+ }
1686
+
1687
+ throw new Error('Invalid juz');
1688
+
1689
+ case 2:
1690
+ params = getVerseOptions(options);
1691
+ url = "/verses/by_juz/" + juz;
1692
+ _context4.next = 6;
1693
+ return fetcher(url, params);
1694
+
1695
+ case 6:
1696
+ _yield$fetcher4 = _context4.sent;
1697
+ verses = _yield$fetcher4.verses;
1698
+ return _context4.abrupt("return", verses);
1699
+
1700
+ case 9:
1701
+ case "end":
1702
+ return _context4.stop();
1703
+ }
1704
+ }
1705
+ }, _callee4);
1706
+ }));
1707
+
1708
+ return function findByJuz(_x7, _x8) {
1709
+ return _ref4.apply(this, arguments);
1710
+ };
1711
+ }(); // TODO: uncomment when API is fixed
1712
+
1713
+ /**
1714
+ * Get all ayahs for a Hizb.
1715
+ * @description https://quran.api-docs.io/v4/verses/by-hizb-number
1716
+ * @param {HizbNumber} hizb - hizb number
1717
+ * @param {GetVerseOptions} options
1718
+ * @example
1719
+ * quran.v4.verses.findByHizb('1')
1720
+ * quran.v4.verses.findByHizb('29')
1721
+ */
1722
+ // const findByHizb = async (hizb: HizbNumber, options?: GetVerseOptions) => {
1723
+ // if (!Utils.isValidHizb(hizb)) throw new Error('Invalid hizb');
1724
+ // const params = getVerseOptions(options);
1725
+ // const url = `/verses/by_hizb/${hizb}`;
1726
+ // const { verses } = await fetcher<{ verses: Verse[] }>(url, params);
1727
+ // return verses;
1728
+ // };
1729
+ // TODO: uncomment when API is fixed
1730
+
1731
+ /**
1732
+ * Get all ayahs for a Rub.
1733
+ * @description https://quran.api-docs.io/v4/verses/by-rub-number
1734
+ * @param {RubNumber} rub - rub number
1735
+ * @param {GetVerseOptions} options
1736
+ * @example
1737
+ * quran.v4.verses.findByRub('1')
1738
+ * quran.v4.verses.findByRub('29')
1739
+ */
1740
+ // const findByRub = async (rub: RubNumber, options?: GetVerseOptions) => {
1741
+ // if (!Utils.isValidRub(rub)) throw new Error('Invalid rub');
1742
+ // const params = getVerseOptions(options);
1743
+ // const url = `/verses/by_rub/${rub}`;
1744
+ // const { verses } = await fetcher<{ verses: Verse[] }>(url, params);
1745
+ // return verses;
1746
+ // };
1747
+
1748
+ /**
1749
+ * Get a random ayah.
1750
+ * @description https://quran.api-docs.io/v4/verses/random
1751
+ * @param {GetVerseOptions} options
1752
+ * @example
1753
+ * quran.v4.verses.findRandom()
1754
+ */
1755
+
1756
+
1757
+ var findRandom = /*#__PURE__*/function () {
1758
+ var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(options) {
1759
+ var params, _yield$fetcher5, verse;
1760
+
1761
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
1762
+ while (1) {
1763
+ switch (_context5.prev = _context5.next) {
1764
+ case 0:
1765
+ params = getVerseOptions(options);
1766
+ _context5.next = 3;
1767
+ return fetcher('/verses/random', params);
1768
+
1769
+ case 3:
1770
+ _yield$fetcher5 = _context5.sent;
1771
+ verse = _yield$fetcher5.verse;
1772
+ return _context5.abrupt("return", verse);
1773
+
1774
+ case 6:
1775
+ case "end":
1776
+ return _context5.stop();
1777
+ }
1778
+ }
1779
+ }, _callee5);
1780
+ }));
1781
+
1782
+ return function findRandom(_x9) {
1783
+ return _ref5.apply(this, arguments);
1784
+ };
1785
+ }();
1786
+
1787
+ var verses = {
1788
+ findByKey: findByKey,
1789
+ findByChapter: findByChapter,
1790
+ findByPage: findByPage,
1791
+ findByJuz: findByJuz,
1792
+ // findByHizb,
1793
+ // findByRub,
1794
+ findRandom: findRandom
1795
+ };
1796
+
1797
+ /**
1798
+ * Get All Juzs
1799
+ * @description https://quran.api-docs.io/v4/juz/get-all-juzs
1800
+ * @example
1801
+ * quran.v4.juzs.findAll()
1802
+ */
1803
+
1804
+ var findAll = /*#__PURE__*/function () {
1805
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
1806
+ var _yield$fetcher, juzs;
1807
+
1808
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1809
+ while (1) {
1810
+ switch (_context.prev = _context.next) {
1811
+ case 0:
1812
+ _context.next = 2;
1813
+ return fetcher('/juzs');
1814
+
1815
+ case 2:
1816
+ _yield$fetcher = _context.sent;
1817
+ juzs = _yield$fetcher.juzs;
1818
+ return _context.abrupt("return", juzs);
1819
+
1820
+ case 5:
1821
+ case "end":
1822
+ return _context.stop();
1823
+ }
1824
+ }
1825
+ }, _callee);
1826
+ }));
1827
+
1828
+ return function findAll() {
1829
+ return _ref.apply(this, arguments);
1830
+ };
1831
+ }();
1832
+
1833
+ var juzs = {
1834
+ findAll: findAll
1835
+ };
1836
+
1837
+ var defaultChapterRecitationsOptions = {
1838
+ language: Language.ARABIC
1839
+ };
1840
+
1841
+ var getChapterRecitationsOptions = function getChapterRecitationsOptions(options) {
1842
+ if (options === void 0) {
1843
+ options = {};
1844
+ }
1845
+
1846
+ var _final = _extends({}, defaultChapterRecitationsOptions, options);
1847
+
1848
+ return _final;
1849
+ };
1850
+
1851
+ var defaultVerseRecitationsOptions = {
1852
+ language: Language.ARABIC
1853
+ };
1854
+
1855
+ var getVerseRecitationsOptions = function getVerseRecitationsOptions(options) {
1856
+ if (options === void 0) {
1857
+ options = {};
1858
+ }
1859
+
1860
+ var initial = _extends({}, defaultVerseRecitationsOptions, options);
1861
+
1862
+ var _final2 = {
1863
+ language: initial.language
1864
+ };
1865
+
1866
+ if (initial.fields) {
1867
+ var fields = [];
1868
+
1869
+ for (var _i = 0, _Object$entries = Object.entries(initial.fields); _i < _Object$entries.length; _i++) {
1870
+ var _Object$entries$_i = _Object$entries[_i],
1871
+ key = _Object$entries$_i[0],
1872
+ value = _Object$entries$_i[1];
1873
+ if (value) fields.push(decamelize(key));
1874
+ }
1875
+
1876
+ _final2.fields = fields.join(',');
1877
+ }
1878
+
1879
+ return _final2;
1880
+ };
1881
+ /**
1882
+ * Get all chapter recitations for specific reciter
1883
+ * @description https://quran.api-docs.io/v4/audio-recitations/list-of-all-surah-audio-files-for-specific-reciter
1884
+ * @param {string} reciterId
1885
+ * @param {GetChapterRecitationsOptions} options
1886
+ * @example
1887
+ * quran.v4.audio.findAllChapterRecitations('2')
1888
+ */
1889
+
1890
+
1891
+ var findAllChapterRecitations = /*#__PURE__*/function () {
1892
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(reciterId, options) {
1893
+ var params, _yield$fetcher, audioFiles;
1894
+
1895
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
1896
+ while (1) {
1897
+ switch (_context.prev = _context.next) {
1898
+ case 0:
1899
+ params = getChapterRecitationsOptions(options);
1900
+ _context.next = 3;
1901
+ return fetcher("/chapter_recitations/" + reciterId, params);
1902
+
1903
+ case 3:
1904
+ _yield$fetcher = _context.sent;
1905
+ audioFiles = _yield$fetcher.audioFiles;
1906
+ return _context.abrupt("return", audioFiles);
1907
+
1908
+ case 6:
1909
+ case "end":
1910
+ return _context.stop();
1911
+ }
1912
+ }
1913
+ }, _callee);
1914
+ }));
1915
+
1916
+ return function findAllChapterRecitations(_x, _x2) {
1917
+ return _ref.apply(this, arguments);
1918
+ };
1919
+ }();
1920
+ /**
1921
+ * Get chapter recitation for specific reciter and a specific chapter
1922
+ * @description https://quran.api-docs.io/v4/audio-recitations/get-single-surah-audio-for-specific-reciter
1923
+ * @param {ChapterId} chapterId
1924
+ * @param {string} reciterId
1925
+ * @param {GetChapterRecitationsOptions} options
1926
+ * @example
1927
+ * quran.v4.audio.findChapterRecitationById('1', '2') // first chapter recitation for reciter 2
1928
+ */
1929
+
1930
+
1931
+ var findChapterRecitationById = /*#__PURE__*/function () {
1932
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(chapterId, reciterId, options) {
1933
+ var params, _yield$fetcher2, audioFile;
1934
+
1935
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
1936
+ while (1) {
1937
+ switch (_context2.prev = _context2.next) {
1938
+ case 0:
1939
+ if (Utils.isValidChapterId(chapterId)) {
1940
+ _context2.next = 2;
1941
+ break;
1942
+ }
1943
+
1944
+ throw new Error('Invalid chapter id');
1945
+
1946
+ case 2:
1947
+ params = getChapterRecitationsOptions(options);
1948
+ _context2.next = 5;
1949
+ return fetcher("/chapter_recitations/" + reciterId + "/" + chapterId, params);
1950
+
1951
+ case 5:
1952
+ _yield$fetcher2 = _context2.sent;
1953
+ audioFile = _yield$fetcher2.audioFile;
1954
+ return _context2.abrupt("return", audioFile);
1955
+
1956
+ case 8:
1957
+ case "end":
1958
+ return _context2.stop();
1959
+ }
1960
+ }
1961
+ }, _callee2);
1962
+ }));
1963
+
1964
+ return function findChapterRecitationById(_x3, _x4, _x5) {
1965
+ return _ref2.apply(this, arguments);
1966
+ };
1967
+ }();
1968
+ /**
1969
+ * Get all verse audio files for a specific reciter and a specific chapter
1970
+ * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-surah
1971
+ * @param {ChapterId} chapterId
1972
+ * @param {string} recitationId
1973
+ * @param {GetVerseRecitationsOptions} options
1974
+ * @example
1975
+ * quran.v4.audio.findVerseRecitationsByChapter('1', '2')
1976
+ */
1977
+
1978
+
1979
+ var findVerseRecitationsByChapter = /*#__PURE__*/function () {
1980
+ var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(chapterId, recitationId, options) {
1981
+ var params, data;
1982
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
1983
+ while (1) {
1984
+ switch (_context3.prev = _context3.next) {
1985
+ case 0:
1986
+ if (Utils.isValidChapterId(chapterId)) {
1987
+ _context3.next = 2;
1988
+ break;
1989
+ }
1990
+
1991
+ throw new Error('Invalid chapter id');
1992
+
1993
+ case 2:
1994
+ params = getVerseRecitationsOptions(options);
1995
+ _context3.next = 5;
1996
+ return fetcher("/recitations/" + recitationId + "/by_chapter/" + chapterId, params);
1997
+
1998
+ case 5:
1999
+ data = _context3.sent;
2000
+ return _context3.abrupt("return", data);
2001
+
2002
+ case 7:
2003
+ case "end":
2004
+ return _context3.stop();
2005
+ }
2006
+ }
2007
+ }, _callee3);
2008
+ }));
2009
+
2010
+ return function findVerseRecitationsByChapter(_x6, _x7, _x8) {
2011
+ return _ref3.apply(this, arguments);
2012
+ };
2013
+ }();
2014
+ /**
2015
+ * Get all verse audio files for a specific reciter and a specific juz
2016
+ * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-juz
2017
+ * @param {JuzNumber} juz
2018
+ * @param {string} recitationId
2019
+ * @param {GetRecitationsOptions} options
2020
+ * @example
2021
+ * quran.v4.audio.findVerseRecitationsByJuz('1', '2')
2022
+ */
2023
+
2024
+
2025
+ var findVerseRecitationsByJuz = /*#__PURE__*/function () {
2026
+ var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(juz, recitationId, options) {
2027
+ var params, data;
2028
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
2029
+ while (1) {
2030
+ switch (_context4.prev = _context4.next) {
2031
+ case 0:
2032
+ if (Utils.isValidJuz(juz)) {
2033
+ _context4.next = 2;
2034
+ break;
2035
+ }
2036
+
2037
+ throw new Error('Invalid juz');
2038
+
2039
+ case 2:
2040
+ params = getVerseRecitationsOptions(options);
2041
+ _context4.next = 5;
2042
+ return fetcher("/recitations/" + recitationId + "/by_juz/" + juz, params);
2043
+
2044
+ case 5:
2045
+ data = _context4.sent;
2046
+ return _context4.abrupt("return", data);
2047
+
2048
+ case 7:
2049
+ case "end":
2050
+ return _context4.stop();
2051
+ }
2052
+ }
2053
+ }, _callee4);
2054
+ }));
2055
+
2056
+ return function findVerseRecitationsByJuz(_x9, _x10, _x11) {
2057
+ return _ref4.apply(this, arguments);
2058
+ };
2059
+ }();
2060
+ /**
2061
+ * Get all verse audio files for a specific reciter and a specific mushaf page
2062
+ * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-madani-mushaf-page
2063
+ * @param {PageNumber} page
2064
+ * @param {string} recitationId
2065
+ * @param {GetVerseRecitationsOptions} options
2066
+ * @example
2067
+ * quran.v4.audio.findVerseRecitationsByPage('1', '2')
2068
+ */
2069
+
2070
+
2071
+ var findVerseRecitationsByPage = /*#__PURE__*/function () {
2072
+ var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(page, recitationId, options) {
2073
+ var params, data;
2074
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
2075
+ while (1) {
2076
+ switch (_context5.prev = _context5.next) {
2077
+ case 0:
2078
+ if (Utils.isValidQuranPage(page)) {
2079
+ _context5.next = 2;
2080
+ break;
2081
+ }
2082
+
2083
+ throw new Error('Invalid page');
2084
+
2085
+ case 2:
2086
+ params = getVerseRecitationsOptions(options);
2087
+ _context5.next = 5;
2088
+ return fetcher("/recitations/" + recitationId + "/by_page/" + page, params);
2089
+
2090
+ case 5:
2091
+ data = _context5.sent;
2092
+ return _context5.abrupt("return", data);
2093
+
2094
+ case 7:
2095
+ case "end":
2096
+ return _context5.stop();
2097
+ }
2098
+ }
2099
+ }, _callee5);
2100
+ }));
2101
+
2102
+ return function findVerseRecitationsByPage(_x12, _x13, _x14) {
2103
+ return _ref5.apply(this, arguments);
2104
+ };
2105
+ }();
2106
+ /**
2107
+ * Get all verse audio files for a specific reciter and a specific rub
2108
+ * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-rub
2109
+ * @param {RubNumber} rub
2110
+ * @param {string} recitationId
2111
+ * @param {GetVerseRecitationsOptions} options
2112
+ * @example
2113
+ * quran.v4.audio.findVerseRecitationsByRub('1', '2')
2114
+ */
2115
+
2116
+
2117
+ var findVerseRecitationsByRub = /*#__PURE__*/function () {
2118
+ var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(rub, recitationId, options) {
2119
+ var params, data;
2120
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
2121
+ while (1) {
2122
+ switch (_context6.prev = _context6.next) {
2123
+ case 0:
2124
+ if (Utils.isValidRub(rub)) {
2125
+ _context6.next = 2;
2126
+ break;
2127
+ }
2128
+
2129
+ throw new Error('Invalid rub');
2130
+
2131
+ case 2:
2132
+ params = getVerseRecitationsOptions(options);
2133
+ _context6.next = 5;
2134
+ return fetcher("/recitations/" + recitationId + "/by_rub/" + rub, params);
2135
+
2136
+ case 5:
2137
+ data = _context6.sent;
2138
+ return _context6.abrupt("return", data);
2139
+
2140
+ case 7:
2141
+ case "end":
2142
+ return _context6.stop();
2143
+ }
2144
+ }
2145
+ }, _callee6);
2146
+ }));
2147
+
2148
+ return function findVerseRecitationsByRub(_x15, _x16, _x17) {
2149
+ return _ref6.apply(this, arguments);
2150
+ };
2151
+ }();
2152
+ /**
2153
+ * Get all verse audio files for a specific reciter and a specific hizb
2154
+ * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-hizb
2155
+ * @param {HizbNumber} hizb
2156
+ * @param {string} recitationId
2157
+ * @param {GetVerseRecitationsOptions} options
2158
+ * @example
2159
+ * quran.v4.audio.findVerseRecitationsByHizb('1', '2')
2160
+ */
2161
+
2162
+
2163
+ var findVerseRecitationsByHizb = /*#__PURE__*/function () {
2164
+ var _ref7 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(hizb, recitationId, options) {
2165
+ var params, data;
2166
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
2167
+ while (1) {
2168
+ switch (_context7.prev = _context7.next) {
2169
+ case 0:
2170
+ if (Utils.isValidHizb(hizb)) {
2171
+ _context7.next = 2;
2172
+ break;
2173
+ }
2174
+
2175
+ throw new Error('Invalid hizb');
2176
+
2177
+ case 2:
2178
+ params = getVerseRecitationsOptions(options);
2179
+ _context7.next = 5;
2180
+ return fetcher("/recitations/" + recitationId + "/by_hizb/" + hizb, params);
2181
+
2182
+ case 5:
2183
+ data = _context7.sent;
2184
+ return _context7.abrupt("return", data);
2185
+
2186
+ case 7:
2187
+ case "end":
2188
+ return _context7.stop();
2189
+ }
2190
+ }
2191
+ }, _callee7);
2192
+ }));
2193
+
2194
+ return function findVerseRecitationsByHizb(_x18, _x19, _x20) {
2195
+ return _ref7.apply(this, arguments);
2196
+ };
2197
+ }();
2198
+ /**
2199
+ * Get all verse audio files for a specific reciter and a specific hizb
2200
+ * @description https://quran.api-docs.io/v4/audio-recitations/get-ayah-recitations-for-specific-ayah
2201
+ * @param {VerseKey} key
2202
+ * @param {string} recitationId
2203
+ * @param {GetVerseRecitationsOptions} options
2204
+ * @example
2205
+ * quran.v4.audio.findVerseRecitationsByKey('1:1', '2')
2206
+ */
2207
+
2208
+
2209
+ var findVerseRecitationsByKey = /*#__PURE__*/function () {
2210
+ var _ref8 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(key, recitationId, options) {
2211
+ var params, data;
2212
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
2213
+ while (1) {
2214
+ switch (_context8.prev = _context8.next) {
2215
+ case 0:
2216
+ if (Utils.isValidVerseKey(key)) {
2217
+ _context8.next = 2;
2218
+ break;
2219
+ }
2220
+
2221
+ throw new Error('Invalid verse key');
2222
+
2223
+ case 2:
2224
+ params = getVerseRecitationsOptions(options);
2225
+ _context8.next = 5;
2226
+ return fetcher("/recitations/" + recitationId + "/by_ayah/" + key, params);
2227
+
2228
+ case 5:
2229
+ data = _context8.sent;
2230
+ return _context8.abrupt("return", data);
2231
+
2232
+ case 7:
2233
+ case "end":
2234
+ return _context8.stop();
2235
+ }
2236
+ }
2237
+ }, _callee8);
2238
+ }));
2239
+
2240
+ return function findVerseRecitationsByKey(_x21, _x22, _x23) {
2241
+ return _ref8.apply(this, arguments);
2242
+ };
2243
+ }();
2244
+
2245
+ var audio = {
2246
+ findAllChapterRecitations: findAllChapterRecitations,
2247
+ findChapterRecitationById: findChapterRecitationById,
2248
+ findVerseRecitationsByChapter: findVerseRecitationsByChapter,
2249
+ findVerseRecitationsByJuz: findVerseRecitationsByJuz,
2250
+ findVerseRecitationsByPage: findVerseRecitationsByPage,
2251
+ findVerseRecitationsByRub: findVerseRecitationsByRub,
2252
+ findVerseRecitationsByHizb: findVerseRecitationsByHizb,
2253
+ findVerseRecitationsByKey: findVerseRecitationsByKey
2254
+ };
2255
+
2256
+ var defaultOptions = {
2257
+ language: Language.ARABIC
2258
+ };
2259
+
2260
+ var getResourcesOptions = function getResourcesOptions(options) {
2261
+ if (options === void 0) {
2262
+ options = {};
2263
+ }
2264
+
2265
+ var _final = _extends({}, defaultOptions, options);
2266
+
2267
+ return _final;
2268
+ };
2269
+ /**
2270
+ * Get all recitations.
2271
+ * @description https://quran.api-docs.io/v4/resources/recitations
2272
+ * @param {GetResourcesOptions} options
2273
+ * @example
2274
+ * quran.v4.resources.findAllRecitations()
2275
+ */
2276
+
2277
+
2278
+ var findAllRecitations = /*#__PURE__*/function () {
2279
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
2280
+ var params, _yield$fetcher, recitations;
2281
+
2282
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
2283
+ while (1) {
2284
+ switch (_context.prev = _context.next) {
2285
+ case 0:
2286
+ params = getResourcesOptions(options);
2287
+ _context.next = 3;
2288
+ return fetcher('/resources/recitations', params);
2289
+
2290
+ case 3:
2291
+ _yield$fetcher = _context.sent;
2292
+ recitations = _yield$fetcher.recitations;
2293
+ return _context.abrupt("return", recitations);
2294
+
2295
+ case 6:
2296
+ case "end":
2297
+ return _context.stop();
2298
+ }
2299
+ }
2300
+ }, _callee);
2301
+ }));
2302
+
2303
+ return function findAllRecitations(_x) {
2304
+ return _ref.apply(this, arguments);
2305
+ };
2306
+ }(); // TODO: uncomment when API is ready
2307
+
2308
+ /**
2309
+ * Get all recitation info.
2310
+ * @description https://quran.api-docs.io/v4/resources/recitation-info
2311
+ * @param {string} id recitation id
2312
+ * @param {GetResourcesOptions} options
2313
+ * @example
2314
+ * quran.v4.resources.findRecitationInfo('1')
2315
+ */
2316
+ // const findRecitationInfo = async (id: string, options?: GetResourcesOptions) => {
2317
+ // const params = getResourcesOptions(options);
2318
+ // const { info } = await fetcher<{
2319
+ // info: RecitationInfoResource;
2320
+ // }>(`/resources/recitations/${id}/info`, params);
2321
+ // return info;
2322
+ // };
2323
+
2324
+ /**
2325
+ * Get all translations.
2326
+ * @description https://quran.api-docs.io/v4/resources/translations
2327
+ * @param {GetResourcesOptions} options
2328
+ * @example
2329
+ * quran.v4.resources.findAllTranslations()
2330
+ */
2331
+
2332
+
2333
+ var findAllTranslations = /*#__PURE__*/function () {
2334
+ var _ref2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(options) {
2335
+ var params, _yield$fetcher2, translations;
2336
+
2337
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
2338
+ while (1) {
2339
+ switch (_context2.prev = _context2.next) {
2340
+ case 0:
2341
+ params = getResourcesOptions(options);
2342
+ _context2.next = 3;
2343
+ return fetcher('/resources/translations', params);
2344
+
2345
+ case 3:
2346
+ _yield$fetcher2 = _context2.sent;
2347
+ translations = _yield$fetcher2.translations;
2348
+ return _context2.abrupt("return", translations);
2349
+
2350
+ case 6:
2351
+ case "end":
2352
+ return _context2.stop();
2353
+ }
2354
+ }
2355
+ }, _callee2);
2356
+ }));
2357
+
2358
+ return function findAllTranslations(_x2) {
2359
+ return _ref2.apply(this, arguments);
2360
+ };
2361
+ }(); // TODO: uncomment when API is ready
2362
+
2363
+ /**
2364
+ * Get translation info.
2365
+ * @description https://quran.api-docs.io/v4/resources/translation-info
2366
+ * @param {string} id translation id
2367
+ * @param {GetResourcesOptions} options
2368
+ * @example
2369
+ * quran.v4.resources.findTranslationInfo('169')
2370
+ */
2371
+ // const findTranslationInfo = async (id: string, options?: GetResourcesOptions) => {
2372
+ // const params = getResourcesOptions(options);
2373
+ // const { info } = await fetcher<{
2374
+ // info: TranslationInfoResource;
2375
+ // }>(`/resources/translations/${id}/info`, params);
2376
+ // return info;
2377
+ // };
2378
+
2379
+ /**
2380
+ * Get all tafsirs.
2381
+ * @description https://quran.api-docs.io/v4/resources/tafsirs
2382
+ * @param {GetResourcesOptions} options
2383
+ * @example
2384
+ * quran.v4.resources.findAllTafsirs()
2385
+ */
2386
+
2387
+
2388
+ var findAllTafsirs = /*#__PURE__*/function () {
2389
+ var _ref3 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(options) {
2390
+ var params, _yield$fetcher3, tafsirs;
2391
+
2392
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
2393
+ while (1) {
2394
+ switch (_context3.prev = _context3.next) {
2395
+ case 0:
2396
+ params = getResourcesOptions(options);
2397
+ _context3.next = 3;
2398
+ return fetcher('/resources/tafsirs', params);
2399
+
2400
+ case 3:
2401
+ _yield$fetcher3 = _context3.sent;
2402
+ tafsirs = _yield$fetcher3.tafsirs;
2403
+ return _context3.abrupt("return", tafsirs);
2404
+
2405
+ case 6:
2406
+ case "end":
2407
+ return _context3.stop();
2408
+ }
2409
+ }
2410
+ }, _callee3);
2411
+ }));
2412
+
2413
+ return function findAllTafsirs(_x3) {
2414
+ return _ref3.apply(this, arguments);
2415
+ };
2416
+ }(); // TODO: uncomment when API is ready
2417
+
2418
+ /**
2419
+ * Get tafsir info.
2420
+ * @description https://quran.api-docs.io/v4/resources/tafsirs-info
2421
+ * @param {string} id tafsir id
2422
+ * @param {GetResourcesOptions} options
2423
+ * @example
2424
+ * quran.v4.resources.findTranslationInfo('1')
2425
+ */
2426
+ // const findTafsirInfo = async (id: string, options?: GetResourcesOptions) => {
2427
+ // const params = getResourcesOptions(options);
2428
+ // const { info } = await fetcher<{
2429
+ // info: TafsirInfoResource;
2430
+ // }>(`/resources/tafsirs/${id}/info`, params);
2431
+ // return info;
2432
+ // };
2433
+
2434
+ /**
2435
+ * Get all recitation styles.
2436
+ * @description https://quran.api-docs.io/v4/resources/recitation-styles
2437
+ * @example
2438
+ * quran.v4.resources.findAllRecitationStyles()
2439
+ */
2440
+
2441
+
2442
+ var findAllRecitationStyles = /*#__PURE__*/function () {
2443
+ var _ref4 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
2444
+ var _yield$fetcher4, recitationStyles;
2445
+
2446
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
2447
+ while (1) {
2448
+ switch (_context4.prev = _context4.next) {
2449
+ case 0:
2450
+ _context4.next = 2;
2451
+ return fetcher('/resources/recitation_styles');
2452
+
2453
+ case 2:
2454
+ _yield$fetcher4 = _context4.sent;
2455
+ recitationStyles = _yield$fetcher4.recitationStyles;
2456
+ return _context4.abrupt("return", recitationStyles);
2457
+
2458
+ case 5:
2459
+ case "end":
2460
+ return _context4.stop();
2461
+ }
2462
+ }
2463
+ }, _callee4);
2464
+ }));
2465
+
2466
+ return function findAllRecitationStyles() {
2467
+ return _ref4.apply(this, arguments);
2468
+ };
2469
+ }();
2470
+ /**
2471
+ * Get all languages.
2472
+ * @description https://quran.api-docs.io/v4/resources/languages
2473
+ * @param {GetResourcesOptions} options
2474
+ * @example
2475
+ * quran.v4.resources.findAllLanguages()
2476
+ */
2477
+
2478
+
2479
+ var findAllLanguages = /*#__PURE__*/function () {
2480
+ var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(options) {
2481
+ var params, _yield$fetcher5, languages;
2482
+
2483
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
2484
+ while (1) {
2485
+ switch (_context5.prev = _context5.next) {
2486
+ case 0:
2487
+ params = getResourcesOptions(options);
2488
+ _context5.next = 3;
2489
+ return fetcher('/resources/languages', params);
2490
+
2491
+ case 3:
2492
+ _yield$fetcher5 = _context5.sent;
2493
+ languages = _yield$fetcher5.languages;
2494
+ return _context5.abrupt("return", languages);
2495
+
2496
+ case 6:
2497
+ case "end":
2498
+ return _context5.stop();
2499
+ }
2500
+ }
2501
+ }, _callee5);
2502
+ }));
2503
+
2504
+ return function findAllLanguages(_x4) {
2505
+ return _ref5.apply(this, arguments);
2506
+ };
2507
+ }();
2508
+ /**
2509
+ * Get all chapter infos.
2510
+ * @description https://quran.api-docs.io/v4/resources/chapter-info
2511
+ * @param {GetResourcesOptions} options
2512
+ * @example
2513
+ * quran.v4.resources.findAllChapterInfos()
2514
+ */
2515
+
2516
+
2517
+ var findAllChapterInfos = /*#__PURE__*/function () {
2518
+ var _ref6 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(options) {
2519
+ var params, _yield$fetcher6, chapterInfos;
2520
+
2521
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
2522
+ while (1) {
2523
+ switch (_context6.prev = _context6.next) {
2524
+ case 0:
2525
+ params = getResourcesOptions(options);
2526
+ _context6.next = 3;
2527
+ return fetcher('/resources/chapter_infos', params);
2528
+
2529
+ case 3:
2530
+ _yield$fetcher6 = _context6.sent;
2531
+ chapterInfos = _yield$fetcher6.chapterInfos;
2532
+ return _context6.abrupt("return", chapterInfos);
2533
+
2534
+ case 6:
2535
+ case "end":
2536
+ return _context6.stop();
2537
+ }
2538
+ }
2539
+ }, _callee6);
2540
+ }));
2541
+
2542
+ return function findAllChapterInfos(_x5) {
2543
+ return _ref6.apply(this, arguments);
2544
+ };
2545
+ }();
2546
+ /**
2547
+ * Get verse media.
2548
+ * @description https://quran.api-docs.io/v4/resources/verse_media
2549
+ * @param {GetResourcesOptions} options
2550
+ * @example
2551
+ * quran.v4.resources.findVerseMedia()
2552
+ */
2553
+
2554
+
2555
+ var findVerseMedia = /*#__PURE__*/function () {
2556
+ var _ref7 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(options) {
2557
+ var params, _yield$fetcher7, verseMedia;
2558
+
2559
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
2560
+ while (1) {
2561
+ switch (_context7.prev = _context7.next) {
2562
+ case 0:
2563
+ params = getResourcesOptions(options);
2564
+ _context7.next = 3;
2565
+ return fetcher("/resources/verse_media", params);
2566
+
2567
+ case 3:
2568
+ _yield$fetcher7 = _context7.sent;
2569
+ verseMedia = _yield$fetcher7.verseMedia;
2570
+ return _context7.abrupt("return", verseMedia);
2571
+
2572
+ case 6:
2573
+ case "end":
2574
+ return _context7.stop();
2575
+ }
2576
+ }
2577
+ }, _callee7);
2578
+ }));
2579
+
2580
+ return function findVerseMedia(_x6) {
2581
+ return _ref7.apply(this, arguments);
2582
+ };
2583
+ }();
2584
+ /**
2585
+ * Get all chapter reciters.
2586
+ * @description https://quran.api-docs.io/v4/resources/list-of-chapter-reciters
2587
+ * @param {GetResourcesOptions} options
2588
+ * @example
2589
+ * quran.v4.resources.findAllChapterReciters()
2590
+ */
2591
+
2592
+
2593
+ var findAllChapterReciters = /*#__PURE__*/function () {
2594
+ var _ref8 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(options) {
2595
+ var params, _yield$fetcher8, reciters;
2596
+
2597
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
2598
+ while (1) {
2599
+ switch (_context8.prev = _context8.next) {
2600
+ case 0:
2601
+ params = getResourcesOptions(options);
2602
+ _context8.next = 3;
2603
+ return fetcher("/resources/chapter_reciters", params);
2604
+
2605
+ case 3:
2606
+ _yield$fetcher8 = _context8.sent;
2607
+ reciters = _yield$fetcher8.reciters;
2608
+ return _context8.abrupt("return", reciters);
2609
+
2610
+ case 6:
2611
+ case "end":
2612
+ return _context8.stop();
2613
+ }
2614
+ }
2615
+ }, _callee8);
2616
+ }));
2617
+
2618
+ return function findAllChapterReciters(_x7) {
2619
+ return _ref8.apply(this, arguments);
2620
+ };
2621
+ }();
2622
+
2623
+ var resources = {
2624
+ findAllRecitations: findAllRecitations,
2625
+ findAllTranslations: findAllTranslations,
2626
+ findAllTafsirs: findAllTafsirs,
2627
+ findAllRecitationStyles: findAllRecitationStyles,
2628
+ findAllLanguages: findAllLanguages,
2629
+ findVerseMedia: findVerseMedia,
2630
+ findAllChapterReciters: findAllChapterReciters,
2631
+ findAllChapterInfos: findAllChapterInfos // findRecitationInfo
2632
+ // findTranslationInfo
2633
+ // findTafsirInfo
2634
+
2635
+ };
2636
+
2637
+ var defaultSearchOptions = {
2638
+ language: Language.ARABIC,
2639
+ size: 30
2640
+ };
2641
+
2642
+ var getSearchOptions = function getSearchOptions(q, options) {
2643
+ if (options === void 0) {
2644
+ options = {};
2645
+ }
2646
+
2647
+ var all = _extends({}, defaultSearchOptions, options, {
2648
+ q: q
2649
+ });
2650
+
2651
+ return all;
2652
+ };
2653
+ /**
2654
+ * Search
2655
+ * @description https://quran.api-docs.io/v4/search/KfCmk4KQYbtyK9adj
2656
+ * @param q search query
2657
+ * @param options search options
2658
+ * @example
2659
+ * quran.v4.search.search('الله')
2660
+ * quran.v4.search.search('الله', { language: Language.ENGLISH })
2661
+ * quran.v4.search.search('الله', { language: Language.ENGLISH, size: 10 })
2662
+ * quran.v4.search.search('الله', { language: Language.ENGLISH, page: 2 })
2663
+ */
2664
+
2665
+
2666
+ var search = /*#__PURE__*/function () {
2667
+ var _ref = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(q, options) {
2668
+ var params, _yield$fetcher, search;
2669
+
2670
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
2671
+ while (1) {
2672
+ switch (_context.prev = _context.next) {
2673
+ case 0:
2674
+ params = getSearchOptions(q, options);
2675
+ _context.next = 3;
2676
+ return fetcher('/search', params);
2677
+
2678
+ case 3:
2679
+ _yield$fetcher = _context.sent;
2680
+ search = _yield$fetcher.search;
2681
+ return _context.abrupt("return", search);
2682
+
2683
+ case 6:
2684
+ case "end":
2685
+ return _context.stop();
2686
+ }
2687
+ }
2688
+ }, _callee);
2689
+ }));
2690
+
2691
+ return function search(_x, _x2) {
2692
+ return _ref.apply(this, arguments);
2693
+ };
2694
+ }();
2695
+
2696
+ var searchApi = {
2697
+ search: search
2698
+ };
2699
+
2700
+ var v4 = {
2701
+ chapters: chapters,
2702
+ verses: verses,
2703
+ juzs: juzs,
2704
+ audio: audio,
2705
+ resources: resources,
2706
+ search: searchApi
2707
+ };
2708
+
2709
+ var quran = {
2710
+ v4: v4,
2711
+ utils: Utils
2712
+ };
2713
+
2714
+ export { CharType, Language, QuranFont, quran };
2715
+ //# sourceMappingURL=api.esm.js.map